diff --git a/.gitignore b/.gitignore index 63d98f7..fd63e79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.iml .idea/ *~ +*.swp diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 580a3f6..6e211d3 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,10 +1,7 @@ { "ImportPath": "github.com/subgraph/fw-daemon", "GoVersion": "go1.7", - "GodepVersion": "v74", - "Packages": [ - "./..." - ], + "GodepVersion": "v79", "Deps": [ { "ImportPath": "github.com/godbus/dbus", @@ -17,29 +14,14 @@ "Rev": "32c6cc29c14570de4cf6d7e7737d68fb2d01ad15" }, { - "ImportPath": "github.com/gotk3/gotk3/cairo", - "Comment": "GOTK3_0_2_0-467-gefaac8f", - "Rev": "efaac8f907aac2f965675d64fd163097db109f95" + "ImportPath": "github.com/google/gopacket", + "Comment": "v1.1.12-75-g8af772c", + "Rev": "8af772c0bcc826f671fd7c133917fec9686d720d" }, { - "ImportPath": "github.com/gotk3/gotk3/gdk", - "Comment": "GOTK3_0_2_0-467-gefaac8f", - "Rev": "efaac8f907aac2f965675d64fd163097db109f95" - }, - { - "ImportPath": "github.com/gotk3/gotk3/glib", - "Comment": "GOTK3_0_2_0-467-gefaac8f", - "Rev": "efaac8f907aac2f965675d64fd163097db109f95" - }, - { - "ImportPath": "github.com/gotk3/gotk3/gtk", - "Comment": "GOTK3_0_2_0-467-gefaac8f", - "Rev": "efaac8f907aac2f965675d64fd163097db109f95" - }, - { - "ImportPath": "github.com/gotk3/gotk3/pango", - "Comment": "GOTK3_0_2_0-467-gefaac8f", - "Rev": "efaac8f907aac2f965675d64fd163097db109f95" + "ImportPath": "github.com/google/gopacket/layers", + "Comment": "v1.1.12-75-g8af772c", + "Rev": "8af772c0bcc826f671fd7c133917fec9686d720d" }, { "ImportPath": "github.com/naoina/go-stringutil", @@ -61,13 +43,26 @@ "Comment": "v1-7-g970db52", "Rev": "970db520ece77730c7e4724c61121037378659d9" }, + { + "ImportPath": "github.com/subgraph/go-nfnetlink", + "Rev": "34abd96bd88d0fbc1a5bbba9fff1bdc2c0448f47" + }, + { + "ImportPath": "github.com/subgraph/go-nfnetlink/nfqueue", + "Rev": "34abd96bd88d0fbc1a5bbba9fff1bdc2c0448f47" + }, { "ImportPath": "github.com/subgraph/go-procsnitch", "Rev": "fbc2965632eec2dcea9b8d630b081b10980d325d" }, { - "ImportPath": "golang.org/x/net/proxy", - "Rev": "ef2e00e88c5e0a3569f0bb9df697e9cbc6215fea" + "ImportPath": "github.com/subgraph/oz/ipc", + "Comment": "0.2.5", + "Rev": "69e556d2d33a76f19546471d813a21f7b7fa4181" + }, + { + "ImportPath": "github.com/subgraph/ozipc", + "Rev": "2cbf2ba8878e9dea012edb021f3b4836f7c93202" } ] } diff --git a/README-DEV.txt b/README-DEV.txt index a68758e..63a0c7c 100644 --- a/README-DEV.txt +++ b/README-DEV.txt @@ -1,3 +1,15 @@ +*** Please also refer to the notes found in fw-prompt/README.txt: you will need to copy both files in sources/etc/dbus-1/system.d/ into /etc/dbus-1/system.d/ + +Build complications: +You may need to run the following first, esp. on Ubuntu 16.04: +go install -tags gtk_3_18 github.com/gotk3/gotk3/gtk + +and build with the following: +go build -v -tags gtk_3_18 -gcflags "-N -l" fw-prompt + +Otherwise standard go build and go install procedures should suffice. + + Before running fw-daemon, make sure to export: GODEBUG=cgocheck=0 Also, here's a default fw-daemon-socks.json config file: diff --git a/README.md b/README.md index fcf52c5..ce62ff0 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ Read more in the [Subgraph OS Handbook](https://subgraph.com/sgos-handbook/sgos_ ``` +# First install the build dependencies +apt install debhelper dh-golang dh-systemd golang-go libcairo2-dev libglib2.0-dev libgtk-3-dev libnetfilter-queue-dev # To build the Debian package: git clone -b debian https://github.com/subgraph/fw-daemon.git cd fw-daemon @@ -38,3 +40,14 @@ gbp buildpackage -us -uc --git-upstream-tree=master dpkg -i /tmp/build-area/fw-daemon{,-gnome}-*.deb ## Refresh your gnome-shell session 'alt-r' type 'r' hit enter. ``` + +You will be left to install the matching iptables rules. While this may vary depending on your environment, pre-existing ruleset +and preferred mechanism; something like the following needs to be added: + +``` +iptables -t mangle -A OUTPUT -m conntrack --ctstate NEW -j NFQUEUE --queue-num 0 --queue-bypass +iptables -A INPUT -p udp -m udp --sport 53 -j NFQUEUE --queue-num 0 --queue-bypass +iptables -A OUTPUT -p tcp -m mark --mark 0x1 -j LOG +iptables -A OUTPUT -p tcp -m mark --mark 0x1 -j REJECT --reject-with icmp-port-unreachable + +``` diff --git a/fw-ozcli/fw-ozcli.go b/fw-ozcli/fw-ozcli.go index ced280d..4502442 100644 --- a/fw-ozcli/fw-ozcli.go +++ b/fw-ozcli/fw-ozcli.go @@ -1,12 +1,12 @@ package main import ( - "fmt" "flag" - "strconv" + "fmt" "io" "log" "net" + "strconv" ) const ReceiverSocketPath = "/var/run/fw-daemon/fwoz.sock" @@ -19,8 +19,8 @@ func reader(r io.Reader) { if err != nil { return } - fmt.Println(string(buf[0:n])) - } + fmt.Println(string(buf[0:n])) + } } func main() { @@ -87,4 +87,3 @@ func main() { } } - diff --git a/fw-prompt/dbus.go b/fw-prompt/dbus.go index 9227f2e..3344a62 100644 --- a/fw-prompt/dbus.go +++ b/fw-prompt/dbus.go @@ -4,13 +4,12 @@ import ( "errors" "github.com/godbus/dbus" "log" -// "github.com/gotk3/gotk3/glib" + // "github.com/gotk3/gotk3/glib" ) - type dbusServer struct { conn *dbus.Conn - run bool + run bool } type promptData struct { @@ -34,7 +33,6 @@ type promptData struct { Action int } - func newDbusServer() (*dbusServer, error) { conn, err := dbus.SystemBus() @@ -65,9 +63,9 @@ func newDbusServer() (*dbusServer, error) { } func (ds *dbusServer) RequestPrompt(application, icon, path, address string, port int32, ip, origin, proto string, uid, gid int32, username, groupname string, pid int32, sandbox string, - optstring string, expanded, expert bool, action int32) (int32, string, *dbus.Error) { - log.Printf("request prompt: app = %s, icon = %s, path = %s, address = %s, action = %v\n", application, icon, path, address, action) - decision := addRequest(nil, path, proto, int(pid), ip, address, int(port), int(uid), int(gid), origin, optstring, sandbox) + is_socks bool, optstring string, expanded, expert bool, action int32) (int32, string, *dbus.Error) { + log.Printf("request prompt: app = %s, icon = %s, path = %s, address = %s, is_socks = %v, action = %v\n", application, icon, path, address, is_socks, action) + decision := addRequest(nil, path, proto, int(pid), ip, address, int(port), int(uid), int(gid), origin, is_socks, optstring, sandbox) log.Print("Waiting on decision...") decision.Cond.L.Lock() for !decision.Ready { @@ -75,6 +73,6 @@ func (ds *dbusServer) RequestPrompt(application, icon, path, address string, por } log.Print("Decision returned: ", decision.Rule) decision.Cond.L.Unlock() -// glib.IdleAdd(func, data) + // glib.IdleAdd(func, data) return int32(decision.Scope), decision.Rule, nil } diff --git a/fw-prompt/fw-prompt.go b/fw-prompt/fw-prompt.go index 9a53812..36fecf7 100644 --- a/fw-prompt/fw-prompt.go +++ b/fw-prompt/fw-prompt.go @@ -1,37 +1,36 @@ package main - import ( - "github.com/gotk3/gotk3/gtk" + "encoding/json" + "errors" + "fmt" "github.com/gotk3/gotk3/glib" + "github.com/gotk3/gotk3/gtk" + "io/ioutil" "log" - "fmt" - "strings" - "strconv" "os" - "io/ioutil" - "encoding/json" "os/user" + "strconv" + "strings" "sync" - "errors" + "time" "github.com/subgraph/fw-daemon/sgfw" ) - type fpPreferences struct { Winheight uint - Winwidth uint - Wintop uint - Winleft uint + Winwidth uint + Wintop uint + Winleft uint } type decisionWaiter struct { - Cond *sync.Cond - Lock sync.Locker - Ready bool - Scope int - Rule string + Cond *sync.Cond + Lock sync.Locker + Ready bool + Scope int + Rule string } type ruleColumns struct { @@ -46,10 +45,9 @@ type ruleColumns struct { Uname string Gname string Origin string - Scope int + Scope int } - var userPrefs fpPreferences var mainWin *gtk.Window var Notebook *gtk.Notebook @@ -63,7 +61,6 @@ var radioOnce, radioProcess, radioParent, radioSession, radioPermanent *gtk.Radi var btnApprove, btnDeny, btnIgnore *gtk.Button var chkUser, chkGroup *gtk.CheckButton - func dumpDecisions() { fmt.Println("XXX Total of decisions pending: ", len(decisionWaiters)) for i := 0; i < len(decisionWaiters); i++ { @@ -80,7 +77,7 @@ func addDecision() *decisionWaiter { func promptInfo(msg string) { dialog := gtk.MessageDialogNew(mainWin, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "Displaying full log info:") -// dialog.SetDefaultGeometry(500, 200) + // dialog.SetDefaultGeometry(500, 200) tv, err := gtk.TextViewNew() @@ -105,7 +102,7 @@ func promptInfo(msg string) { } scrollbox.Add(tv) - scrollbox.SetSizeRequest(600, 100) + scrollbox.SetSizeRequest(500, 100) box, err := dialog.GetContentArea() @@ -117,7 +114,7 @@ func promptInfo(msg string) { dialog.ShowAll() dialog.Run() dialog.Destroy() -//self.set_default_size(150, 100) + //self.set_default_size(150, 100) } func promptChoice(msg string) int { @@ -137,7 +134,7 @@ func getConfigPath() string { usr, err := user.Current() if err != nil { - fmt.Fprintf(os.Stderr, "Error: could not determine location of user preferences file:", err, "\n"); + fmt.Fprintf(os.Stderr, "Error: could not determine location of user preferences file:", err, "\n") return "" } @@ -149,7 +146,7 @@ func savePreferences() bool { usr, err := user.Current() if err != nil { - fmt.Fprintf(os.Stderr, "Error: could not determine location of user preferences file:", err, "\n"); + fmt.Fprintf(os.Stderr, "Error: could not determine location of user preferences file:", err, "\n") return false } @@ -176,7 +173,7 @@ func loadPreferences() bool { usr, err := user.Current() if err != nil { - fmt.Fprintf(os.Stderr, "Error: could not determine location of user preferences file: %v", err, "\n"); + fmt.Fprintf(os.Stderr, "Error: could not determine location of user preferences file: %v", err, "\n") return false } @@ -192,7 +189,7 @@ func loadPreferences() bool { err = json.Unmarshal(jfile, &userPrefs) if err != nil { - fmt.Fprintf(os.Stderr, "Error: could not load preferences data from file: %v", err, "\n") + fmt.Fprintf(os.Stderr, "Error: could not load preferences data from file: %v", err, "\n") return false } @@ -201,23 +198,23 @@ func loadPreferences() bool { } func get_hbox() *gtk.Box { - hbox, err := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0) + hbox, err := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0) - if err != nil { - log.Fatal("Unable to create horizontal box:", err) - } + if err != nil { + log.Fatal("Unable to create horizontal box:", err) + } - return hbox + return hbox } func get_vbox() *gtk.Box { - vbox, err := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0) + vbox, err := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0) - if err != nil { - log.Fatal("Unable to create vertical box:", err) - } + if err != nil { + log.Fatal("Unable to create vertical box:", err) + } - return vbox + return vbox } func get_checkbox(text string, activated bool) *gtk.CheckButton { @@ -319,13 +316,42 @@ func createListStore(general bool) *gtk.ListStore { return listStore } -func addRequest(listStore *gtk.ListStore, path, proto string, pid int, ipaddr, hostname string, port, uid, gid int, origin, optstring string, sandbox string) *decisionWaiter { +func addRequest(listStore *gtk.ListStore, path, proto string, pid int, ipaddr, hostname string, port, uid, gid int, origin string, is_socks bool, optstring string, sandbox string) *decisionWaiter { if listStore == nil { listStore = globalLS + waitTimes := []int{1, 2, 5, 10} + + if listStore == nil { + log.Print("SGFW prompter was not ready to receive firewall request... waiting") + } + + for _, wtime := range waitTimes { + time.Sleep(time.Duration(wtime) * time.Second) + listStore = globalLS + + if listStore != nil { + break + } + + log.Print("SGFW prompter is still waiting...") + } + + } + + if listStore == nil { + log.Fatal("SGFW prompter GUI failed to load for unknown reasons") } iter := listStore.Append() + if is_socks { + if (optstring != "") && (strings.Index(optstring, "SOCKS") == -1) { + optstring = "SOCKS5 / " + optstring + } else if optstring == "" { + optstring = "SOCKS5" + } + } + colVals := make([]interface{}, 11) colVals[0] = 1 colVals[1] = path @@ -416,7 +442,7 @@ func setup_settings() { fmt.Println("CLICKED") if err != nil { - promptError("Unexpected error saving log file info: "+err.Error()) + promptError("Unexpected error saving log file info: " + err.Error()) return } @@ -508,7 +534,6 @@ func toggleValidRuleState() { } } - btnApprove.SetSensitive(ok) btnDeny.SetSensitive(ok) btnIgnore.SetSensitive(ok) @@ -554,8 +579,8 @@ func createCurrentRule() (ruleColumns, error) { rule.UID, rule.GID = 0, 0 rule.Uname, rule.Gname = "", "" -/* Pid int - Origin string */ + /* Pid int + Origin string */ return rule, nil } @@ -690,7 +715,7 @@ func getSelectedRule() (ruleColumns, int, error) { func main() { decisionWaiters = make([]*decisionWaiter, 0) - _, err := newDbusServer(); + _, err := newDbusServer() if err != nil { log.Fatal("Error:", err) return @@ -711,7 +736,7 @@ func main() { mainWin.Connect("destroy", func() { fmt.Println("Shutting down...") savePreferences() - gtk.MainQuit() + gtk.MainQuit() }) mainWin.Connect("configure-event", func() { @@ -749,9 +774,6 @@ func main() { log.Fatal("Unable to create scrolled window:", err) } - scrollbox.Add(box) - - tv, err := gtk.TreeViewNew() if err != nil { @@ -845,7 +867,9 @@ func main() { box.PackStart(bb, false, false, 5) box.PackStart(editbox, false, false, 5) - box.PackStart(tv, false, true, 5) + scrollbox.Add(tv) + // box.PackStart(tv, false, true, 5) + box.PackStart(scrollbox, false, true, 5) tv.AppendColumn(createColumn("#", 0)) tv.AppendColumn(createColumn("Path", 1)) @@ -867,13 +891,13 @@ func main() { btnApprove.Connect("clicked", func() { rule, idx, err := getSelectedRule() if err != nil { - promptError("Error occurred processing request: "+err.Error()) + promptError("Error occurred processing request: " + err.Error()) return } rule, err = createCurrentRule() if err != nil { - promptError("Error occurred constructing new rule: "+err.Error()) + promptError("Error occurred constructing new rule: " + err.Error()) return } @@ -886,20 +910,20 @@ func main() { if err == nil { clearEditor() } else { - promptError("Error setting new rule: "+err.Error()) + promptError("Error setting new rule: " + err.Error()) } }) btnDeny.Connect("clicked", func() { rule, idx, err := getSelectedRule() if err != nil { - promptError("Error occurred processing request: "+err.Error()) + promptError("Error occurred processing request: " + err.Error()) return } rule, err = createCurrentRule() if err != nil { - promptError("Error occurred constructing new rule: "+err.Error()) + promptError("Error occurred constructing new rule: " + err.Error()) return } @@ -912,14 +936,14 @@ func main() { if err == nil { clearEditor() } else { - promptError("Error setting new rule: "+err.Error()) + promptError("Error setting new rule: " + err.Error()) } }) btnIgnore.Connect("clicked", func() { _, idx, err := getSelectedRule() if err != nil { - promptError("Error occurred processing request: "+err.Error()) + promptError("Error occurred processing request: " + err.Error()) return } @@ -929,15 +953,15 @@ func main() { if err == nil { clearEditor() } else { - promptError("Error setting new rule: "+err.Error()) + promptError("Error setting new rule: " + err.Error()) } }) -// tv.SetActivateOnSingleClick(true) + // tv.SetActivateOnSingleClick(true) tv.Connect("row-activated", func() { seldata, _, err := getSelectedRule() if err != nil { - promptError("Unexpected error reading selected rule: "+err.Error()) + promptError("Unexpected error reading selected rule: " + err.Error()) return } @@ -980,14 +1004,14 @@ func main() { return }) - scrollbox.SetSizeRequest(600, 400) - Notebook.AppendPage(scrollbox, nbLabel) -// setup_settings() + // Notebook.AppendPage(scrollbox, nbLabel) + Notebook.AppendPage(box, nbLabel) + // setup_settings() mainWin.Add(Notebook) if userPrefs.Winheight > 0 && userPrefs.Winwidth > 0 { -// fmt.Printf("height was %d, width was %d\n", userPrefs.Winheight, userPrefs.Winwidth) + // fmt.Printf("height was %d, width was %d\n", userPrefs.Winheight, userPrefs.Winwidth) mainWin.Resize(int(userPrefs.Winwidth), int(userPrefs.Winheight)) } else { mainWin.SetDefaultSize(850, 450) @@ -998,6 +1022,6 @@ func main() { } mainWin.ShowAll() -// mainWin.SetKeepAbove(true) + // mainWin.SetKeepAbove(true) gtk.Main() } diff --git a/fw-settings/builder.go b/fw-settings/builder.go index c66bca2..b19593f 100644 --- a/fw-settings/builder.go +++ b/fw-settings/builder.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" "reflect" + "regexp" "github.com/gotk3/gotk3/glib" "github.com/gotk3/gotk3/gtk" @@ -35,6 +36,19 @@ func builderForDefinition(uiName string) *gtk.Builder { template := getDefinitionWithFileFallback(uiName) + maj := gtk.GetMajorVersion() + min := gtk.GetMinorVersion() + + if (maj == 3) && (min < 20) { + fmt.Fprintf(os.Stderr, + "Attempting runtime work-around for older versions of libgtk-3...\n") + dep_re := regexp.MustCompile(`<\s?property\s+name\s?=\s?"icon_size"\s?>.+<\s?/property\s?>`) + template = dep_re.ReplaceAllString(template, ``) + + dep_re2 := regexp.MustCompile(`version\s?=\s?"3.20"`) + template = dep_re2.ReplaceAllString(template, `version="3.18"`) + } + builder, err := gtk.BuilderNew() if err != nil { //We cant recover from this diff --git a/fw-settings/dbus.go b/fw-settings/dbus.go index 102dc3c..1e877b1 100644 --- a/fw-settings/dbus.go +++ b/fw-settings/dbus.go @@ -3,12 +3,11 @@ package main import ( "errors" "fmt" - "github.com/subgraph/fw-daemon/sgfw" "github.com/godbus/dbus" "github.com/gotk3/gotk3/glib" + "github.com/subgraph/fw-daemon/sgfw" ) - type dbusObject struct { dbus.BusObject } @@ -19,7 +18,7 @@ type dbusObjectP struct { type dbusServer struct { conn *dbus.Conn - run bool + run bool } func newDbusObject() (*dbusObject, error) { @@ -114,5 +113,5 @@ func (ds *dbusServer) Alert(data string) *dbus.Error { } func (ob *dbusObjectP) alertRule(data string) { - ob.Call("com.subgraph.fwprompt.EventNotifier.Alert", 0, data) + ob.Call("com.subgraph.fwprompt.EventNotifier.Alert", 0, data) } diff --git a/fw-settings/definitions/RuleEdit.ui b/fw-settings/definitions/RuleEdit.ui index cb34054..4b11b9d 100644 --- a/fw-settings/definitions/RuleEdit.ui +++ b/fw-settings/definitions/RuleEdit.ui @@ -98,6 +98,7 @@ 0 Allow + Allow TLS Only Deny @@ -162,7 +163,7 @@ 0 - 2 + 3 2 @@ -184,6 +185,34 @@ 1 + + + True + False + start + False + Sandbox: + + + + + + 0 + 2 + + + + + True + False + start + True + + + 1 + 2 + + False diff --git a/fw-settings/definitions/rule_edit.go b/fw-settings/definitions/rule_edit.go index 1ec46ab..325c071 100644 --- a/fw-settings/definitions/rule_edit.go +++ b/fw-settings/definitions/rule_edit.go @@ -108,6 +108,7 @@ func (*defRuleEdit) String() string { 0 Allow + Allow TLS Only Deny @@ -172,7 +173,7 @@ func (*defRuleEdit) String() string { 0 - 2 + 3 2 @@ -194,6 +195,34 @@ func (*defRuleEdit) String() string { 1 + + + True + False + start + False + Sandbox: + + + + + + 0 + 2 + + + + + True + False + start + True + + + 1 + 2 + + False diff --git a/fw-settings/main.go b/fw-settings/main.go index 05fe3b8..07142d4 100644 --- a/fw-settings/main.go +++ b/fw-settings/main.go @@ -108,7 +108,7 @@ func repopulateWin() { rlSystem.loadRules(sgfw.RULE_MODE_SYSTEM) loadConfig(win, fwsbuilder, dbus) -// app.AddWindow(win) + // app.AddWindow(win) win.ShowAll() } @@ -179,11 +179,11 @@ func main() { } app.Connect("activate", activate) - _, err = newDbusServer(); + _, err = newDbusServer() if err != nil { panic(fmt.Sprintf("Error initializing Dbus server: %v", err)) - } + } app.Run(os.Args) } diff --git a/fw-settings/rule_edit.go b/fw-settings/rule_edit.go index d3c2263..6269950 100644 --- a/fw-settings/rule_edit.go +++ b/fw-settings/rule_edit.go @@ -18,13 +18,15 @@ const ( ) type ruleEdit struct { - row *ruleRow - dialog *gtk.Dialog - pathLabel *gtk.Label - verbCombo *gtk.ComboBoxText - hostEntry *gtk.Entry - portEntry *gtk.Entry - ok *gtk.Button + row *ruleRow + dialog *gtk.Dialog + pathLabel *gtk.Label + sandboxLabel *gtk.Label + sandboxTitle *gtk.Label + verbCombo *gtk.ComboBoxText + hostEntry *gtk.Entry + portEntry *gtk.Entry + ok *gtk.Button } func newRuleEdit(rr *ruleRow, saveasnew bool) *ruleEdit { @@ -33,6 +35,8 @@ func newRuleEdit(rr *ruleRow, saveasnew bool) *ruleEdit { b.getItems( "dialog", &redit.dialog, "path_label", &redit.pathLabel, + "sandbox_label", &redit.sandboxLabel, + "sandbox_title", &redit.sandboxTitle, "verb_combo", &redit.verbCombo, "host_entry", &redit.hostEntry, "port_entry", &redit.portEntry, @@ -54,9 +58,17 @@ func (re *ruleEdit) updateDialogFields() { re.pathLabel.SetText(r.Path) if sgfw.RuleAction(r.Verb) == sgfw.RULE_ACTION_ALLOW { re.verbCombo.SetActiveID("allow") + } else if sgfw.RuleAction(r.Verb) == sgfw.RULE_ACTION_ALLOW_TLSONLY { + re.verbCombo.SetActiveID("allow_tls") } else { re.verbCombo.SetActiveID("deny") } + if r.Sandbox != "" { + re.sandboxLabel.SetText(r.Sandbox) + } else { + re.sandboxLabel.SetVisible(false) + re.sandboxTitle.SetVisible(false) + } target := strings.Split(r.Target, ":") if len(target) != 2 { return @@ -67,7 +79,7 @@ func (re *ruleEdit) updateDialogFields() { func (re *ruleEdit) validateFields() bool { id := re.verbCombo.GetActiveID() - if id != "allow" && id != "deny" { + if id != "allow" && id != "allow_tls" && id != "deny" { return false } host, _ := re.hostEntry.GetText() @@ -121,6 +133,8 @@ func (re *ruleEdit) updateRow() { switch re.verbCombo.GetActiveID() { case "allow": r.Verb = uint16(sgfw.RULE_ACTION_ALLOW) + case "allow_tls": + r.Verb = uint16(sgfw.RULE_ACTION_ALLOW_TLSONLY) case "deny": r.Verb = uint16(sgfw.RULE_ACTION_DENY) } diff --git a/fw-settings/rules.go b/fw-settings/rules.go index 38f2397..bb3d9f1 100644 --- a/fw-settings/rules.go +++ b/fw-settings/rules.go @@ -3,8 +3,8 @@ package main import ( "fmt" "os" - "strings" "strconv" + "strings" "github.com/subgraph/fw-daemon/sgfw" @@ -122,7 +122,7 @@ func (rr *ruleRow) update() { } rr.gtkLabelApp.SetTooltipText(rr.rule.Path) rr.gtkLabelVerb.SetText(getVerbText(rr.rule)) - if (rr.rule.Proto == "tcp") { + if rr.rule.Proto == "tcp" { rr.gtkLabelOrigin.SetText(rr.rule.Origin) } else { rr.gtkLabelOrigin.SetText(rr.rule.Origin + " (" + rr.rule.Proto + ")") @@ -135,6 +135,9 @@ func getVerbText(rule *sgfw.DbusRule) string { if sgfw.RuleAction(rule.Verb) == sgfw.RULE_ACTION_ALLOW { return sgfw.RuleActionString[sgfw.RULE_ACTION_ALLOW] + ":" } + if sgfw.RuleAction(rule.Verb) == sgfw.RULE_ACTION_ALLOW_TLSONLY { + return sgfw.RuleActionString[sgfw.RULE_ACTION_ALLOW_TLSONLY] + ":" + } return sgfw.RuleActionString[sgfw.RULE_ACTION_DENY] + ":" } @@ -180,11 +183,24 @@ func (rr *ruleRow) onEdit() { } func (rr *ruleRow) onDelete() { - body := fmt.Sprintf(`Are you sure you want to delete this rule: + var body string + if rr.rule.Sandbox != "" { + ss := `Are you sure you want to delete this rule: Path: %s - Rule: %s %s`, rr.rule.Path, getVerbText(rr.rule), getTargetText(rr.rule)) + Sandbox: %s + + Rule: %s %s` + body = fmt.Sprintf(ss, rr.rule.Path, rr.rule.Sandbox, getVerbText(rr.rule), getTargetText(rr.rule)) + } else { + ss := `Are you sure you want to delete this rule: + + Path: %s + + Rule: %s %s` + body = fmt.Sprintf(ss, rr.rule.Path, getVerbText(rr.rule), getTargetText(rr.rule)) + } d := gtk.MessageDialogNewWithMarkup( rr.rl.win, gtk.DIALOG_DESTROY_WITH_PARENT, diff --git a/gnome-shell/firewall@subgraph.com/dialog.js b/gnome-shell/firewall@subgraph.com/dialog.js index f4d3b58..a1fd55d 100644 --- a/gnome-shell/firewall@subgraph.com/dialog.js +++ b/gnome-shell/firewall@subgraph.com/dialog.js @@ -458,7 +458,7 @@ const PromptDialog = new Lang.Class({ Name: 'PromptDialog', Extends: ModalDialog.ModalDialog, - _init: function(invocation, pid_known, sandboxed) { + _init: function(invocation, pid_known, sandboxed, tlsguard) { this.parent({ styleClass: 'fw-prompt-dialog' }); this._invocation = invocation; this.header = new PromptDialogHeader(); @@ -471,7 +471,7 @@ const PromptDialog = new Lang.Class({ this.info = new DetailSection(sandboxed); box.add_child(this.info.actor); - this.optionList = new OptionList(pid_known, sandboxed); + this.optionList = new OptionList(pid_known, tlsguard); box.add_child(this.optionList.actor); this.optionList.addOptions([ "Only PORT AND ADDRESS", @@ -479,7 +479,7 @@ const PromptDialog = new Lang.Class({ "Only PORT", "Any Connection"]); - if (sandboxed) { + if (tlsguard) { this.optionList.addTLSOption(true); } @@ -548,12 +548,12 @@ const PromptDialog = new Lang.Class({ return this.optionList.tlsGuard; }, - update: function(application, icon, path, address, port, ip, origin, uid, gid, user, group, pid, proto, optstring, sandbox, expanded, expert, action) { + update: function(application, icon, path, address, port, ip, origin, uid, gid, user, group, pid, proto, tlsguard, optstring, sandbox, expanded, expert, action) { this._address = address; this._port = port; this._proto = proto; this._sandbox = sandbox; - this._tlsGuard; + this._tlsGuard = tlsguard; let port_str = (proto+"").toUpperCase() + " Port "+ port; diff --git a/gnome-shell/firewall@subgraph.com/extension.js b/gnome-shell/firewall@subgraph.com/extension.js index 59d63b9..b5444a7 100644 --- a/gnome-shell/firewall@subgraph.com/extension.js +++ b/gnome-shell/firewall@subgraph.com/extension.js @@ -58,6 +58,7 @@ const FirewallPromptInterface = ' \ \ \ \ + \ \ \ \ @@ -93,11 +94,11 @@ const FirewallPromptHandler = new Lang.Class({ }, RequestPromptAsync: function(params, invocation) { - let [app, icon, path, address, port, ip, origin, proto, uid, gid, user, group, pid, sandbox, optstring, expanded, expert, action] = params; + let [app, icon, path, address, port, ip, origin, proto, uid, gid, user, group, pid, sandbox, tlsguard, optstring, expanded, expert, action] = params; // this._closeDialog(); - this._dialog = new Dialog.PromptDialog(invocation, (pid >= 0), (sandbox != "")); + this._dialog = new Dialog.PromptDialog(invocation, (pid >= 0), (sandbox != ""), tlsguard); this._invocation = invocation; - this._dialog.update(app, icon, path, address, port, ip, origin, uid, gid, user, group, pid, proto, optstring, sandbox, expanded, expert, action); + this._dialog.update(app, icon, path, address, port, ip, origin, uid, gid, user, group, pid, proto, tlsguard, optstring, sandbox, expanded, expert, action); this._dialog.open(); }, diff --git a/gnome-shell/firewall@subgraph.com/stylesheet.css b/gnome-shell/firewall@subgraph.com/stylesheet.css index c7851a7..1389be3 100644 --- a/gnome-shell/firewall@subgraph.com/stylesheet.css +++ b/gnome-shell/firewall@subgraph.com/stylesheet.css @@ -8,8 +8,8 @@ } .fw-prompt-dialog { - min-width: 450px; - max-width: 550px; + min-width: 600px; + max-width: 700px; } .fw-group-button:checked { diff --git a/proc-coroner/pcoroner.go b/proc-coroner/pcoroner.go index 23e7a7d..4dd43c9 100644 --- a/proc-coroner/pcoroner.go +++ b/proc-coroner/pcoroner.go @@ -2,15 +2,14 @@ package pcoroner import ( "fmt" - "time" - "strings" + "os" "strconv" + "strings" "sync" - "os" "syscall" + "time" ) - type WatchProcess struct { Pid int Inode uint64 @@ -25,14 +24,11 @@ type CallbackEntry struct { type procCB func(int, interface{}) - var Callbacks []CallbackEntry - var pmutex = &sync.Mutex{} var pidMap map[int]WatchProcess = make(map[int]WatchProcess) - func MonitorProcess(pid int) bool { pmutex.Lock() defer pmutex.Unlock() @@ -68,14 +64,14 @@ func AddCallback(cbfunc procCB, param interface{}) { func MonitorThread(cbfunc procCB, param interface{}) { for { -/* if len(pidMap) == 0 { - fmt.Println("TICK") - } else { fmt.Println("len = ", len(pidMap)) } */ + /* if len(pidMap) == 0 { + fmt.Println("TICK") + } else { fmt.Println("len = ", len(pidMap)) } */ pmutex.Lock() pmutex.Unlock() for pkey, pval := range pidMap { -// fmt.Printf("PID %v -> %v\n", pkey, pval) + // fmt.Printf("PID %v -> %v\n", pkey, pval) res := checkProcess(&pval, false) if !res { @@ -100,7 +96,7 @@ func checkProcess(proc *WatchProcess, init bool) bool { ppath := fmt.Sprintf("/proc/%d/stat", proc.Pid) f, err := os.Open(ppath) if err != nil { -// fmt.Printf("Error opening path %s: %s\n", ppath, err) + // fmt.Printf("Error opening path %s: %s\n", ppath, err) return false } defer f.Close() @@ -133,7 +129,7 @@ func checkProcess(proc *WatchProcess, init bool) bool { } bstr := string(buf[:]) -// fmt.Println("sstr = ", bstr) + // fmt.Println("sstr = ", bstr) fields := strings.Split(bstr, " ") diff --git a/sgfw/config.go b/sgfw/config.go index bacd7cc..81b0564 100644 --- a/sgfw/config.go +++ b/sgfw/config.go @@ -27,7 +27,13 @@ type FirewallConfigs struct { var FirewallConfig FirewallConfigs func _readConfig(file string) []byte { - f, err := os.Open(configDefaultPath) + envFile := os.Getenv("SGFW_CONF") + + if envFile != "" { + file = envFile + } + + f, err := os.Open(file) if err != nil { log.Warning(err.Error()) return []byte{} diff --git a/sgfw/const.go b/sgfw/const.go index cb0d8f0..f0f8bd1 100644 --- a/sgfw/const.go +++ b/sgfw/const.go @@ -12,32 +12,37 @@ const ( //RuleAction is the action to apply to a rule type RuleAction uint16 + const ( RULE_ACTION_DENY RuleAction = iota RULE_ACTION_ALLOW RULE_ACTION_ALLOW_TLSONLY ) + // RuleActionString is used to get a string from an action id var RuleActionString = map[RuleAction]string{ - RULE_ACTION_DENY: "DENY", - RULE_ACTION_ALLOW: "ALLOW", + RULE_ACTION_DENY: "DENY", + RULE_ACTION_ALLOW: "ALLOW", RULE_ACTION_ALLOW_TLSONLY: "ALLOW_TLSONLY", } + // RuleActionValue is used to get an action id using the action string var RuleActionValue = map[string]RuleAction{ - RuleActionString[RULE_ACTION_DENY]: RULE_ACTION_DENY, - RuleActionString[RULE_ACTION_ALLOW]: RULE_ACTION_ALLOW, + RuleActionString[RULE_ACTION_DENY]: RULE_ACTION_DENY, + RuleActionString[RULE_ACTION_ALLOW]: RULE_ACTION_ALLOW, RuleActionString[RULE_ACTION_ALLOW_TLSONLY]: RULE_ACTION_ALLOW_TLSONLY, } //RuleMode contains the time scope of a rule type RuleMode uint16 + const ( RULE_MODE_SESSION RuleMode = iota RULE_MODE_PROCESS RULE_MODE_PERMANENT RULE_MODE_SYSTEM ) + // RuleModeString is used to get a rule mode string from its id var RuleModeString = map[RuleMode]string{ RULE_MODE_SESSION: "SESSION", @@ -45,6 +50,7 @@ var RuleModeString = map[RuleMode]string{ RULE_MODE_PERMANENT: "PERMANENT", RULE_MODE_SYSTEM: "SYSTEM", } + // RuleModeValue converts a mode string to its id var RuleModeValue = map[string]RuleMode{ RuleModeString[RULE_MODE_SESSION]: RULE_MODE_SESSION, @@ -55,12 +61,14 @@ var RuleModeValue = map[string]RuleMode{ //FilterScope contains a filter's time scope type FilterScope uint16 + const ( APPLY_ONCE FilterScope = iota APPLY_SESSION APPLY_PROCESS APPLY_FOREVER ) + // FilterScopeString converts a filter scope ID to its string var FilterScopeString = map[FilterScope]string{ APPLY_ONCE: "ONCE", @@ -68,6 +76,7 @@ var FilterScopeString = map[FilterScope]string{ APPLY_PROCESS: "PROCESS", APPLY_FOREVER: "FOREVER", } + // FilterScopeString converts a filter scope string to its ID var FilterScopeValue = map[string]FilterScope{ FilterScopeString[APPLY_ONCE]: APPLY_ONCE, @@ -75,6 +84,7 @@ var FilterScopeValue = map[string]FilterScope{ FilterScopeString[APPLY_PROCESS]: APPLY_PROCESS, FilterScopeString[APPLY_FOREVER]: APPLY_FOREVER, } + // GetFilterScopeString is used to safely return a filter scope string func GetFilterScopeString(scope FilterScope) string { if val, ok := FilterScopeString[scope]; ok { @@ -82,6 +92,7 @@ func GetFilterScopeString(scope FilterScope) string { } return FilterScopeString[APPLY_SESSION] } + // GetFilterScopeValue is used to safely return a filter scope ID func GetFilterScopeValue(scope string) FilterScope { scope = strings.ToUpper(scope) @@ -93,40 +104,44 @@ func GetFilterScopeValue(scope string) FilterScope { //FilterResult contains the filtering resulting action type FilterResult uint16 + const ( FILTER_DENY FilterResult = iota FILTER_ALLOW FILTER_PROMPT FILTER_ALLOW_TLSONLY ) + // FilterResultString converts a filter value ID to its string var FilterResultString = map[FilterResult]string{ - FILTER_DENY: "DENY", - FILTER_ALLOW: "ALLOW", - FILTER_PROMPT: "PROMPT", + FILTER_DENY: "DENY", + FILTER_ALLOW: "ALLOW", + FILTER_PROMPT: "PROMPT", FILTER_ALLOW_TLSONLY: "ALLOW_TLSONLY", } + // FilterResultValue converts a filter value string to its ID var FilterResultValue = map[string]FilterResult{ - FilterResultString[FILTER_DENY]: FILTER_DENY, - FilterResultString[FILTER_ALLOW]: FILTER_ALLOW, - FilterResultString[FILTER_PROMPT]: FILTER_PROMPT, + FilterResultString[FILTER_DENY]: FILTER_DENY, + FilterResultString[FILTER_ALLOW]: FILTER_ALLOW, + FilterResultString[FILTER_PROMPT]: FILTER_PROMPT, FilterResultString[FILTER_ALLOW_TLSONLY]: FILTER_ALLOW_TLSONLY, } // DbusRule struct of the rule passed to the dbus interface type DbusRule struct { - ID uint32 - Net string - Origin string - Proto string - Pid uint32 - Privs string - App string - Path string - Verb uint16 - Target string - Mode uint16 + ID uint32 + Net string + Origin string + Proto string + Pid uint32 + Privs string + App string + Path string + Verb uint16 + Target string + Mode uint16 + Sandbox string } /*const ( diff --git a/sgfw/dbus.go b/sgfw/dbus.go index d445c01..14547ce 100644 --- a/sgfw/dbus.go +++ b/sgfw/dbus.go @@ -62,7 +62,6 @@ func newDbusObjectPrompt() (*dbusObjectP, error) { return &dbusObjectP{conn.Object("com.subgraph.fwprompt.EventNotifier", "/com/subgraph/fwprompt/EventNotifier")}, nil } - type dbusServer struct { fw *Firewall conn *dbus.Conn @@ -154,18 +153,20 @@ func createDbusRule(r *Rule) DbusRule { } else if r.gid >= 0 { pstr += ":" + strconv.Itoa(r.gid) } + log.Debugf("SANDBOX SANDBOX SANDBOX: %s", r.sandbox) return DbusRule{ - ID: uint32(r.id), - Net: netstr, - Origin: ostr, - Proto: r.proto, - Pid: uint32(r.pid), - Privs: pstr, - App: path.Base(r.policy.path), - Path: r.policy.path, - Verb: uint16(r.rtype), - Target: r.AddrString(false), - Mode: uint16(r.mode), + ID: uint32(r.id), + Net: netstr, + Origin: ostr, + Proto: r.proto, + Pid: uint32(r.pid), + Privs: pstr, + App: path.Base(r.policy.path), + Path: r.policy.path, + Verb: uint16(r.rtype), + Target: r.AddrString(false), + Mode: uint16(r.mode), + Sandbox: r.sandbox, } } @@ -224,6 +225,7 @@ func (ds *dbusServer) UpdateRule(rule DbusRule) *dbus.Error { r.addr = tmp.addr r.port = tmp.port r.mode = RuleMode(rule.Mode) + r.sandbox = rule.Sandbox r.policy.lock.Unlock() if r.mode != RULE_MODE_SESSION { ds.fw.saveRules() diff --git a/sgfw/dns.go b/sgfw/dns.go index aaa1355..05df439 100644 --- a/sgfw/dns.go +++ b/sgfw/dns.go @@ -1,23 +1,23 @@ package sgfw import ( + "encoding/binary" "net" "strings" "sync" "time" - "encoding/binary" -// "github.com/subgraph/go-nfnetlink" + // "github.com/subgraph/go-nfnetlink" "github.com/google/gopacket/layers" + "github.com/subgraph/fw-daemon/proc-coroner" nfqueue "github.com/subgraph/go-nfnetlink/nfqueue" "github.com/subgraph/go-procsnitch" - "github.com/subgraph/fw-daemon/proc-coroner" ) type dnsEntry struct { name string - ttl uint32 - exp time.Time + ttl uint32 + exp time.Time } type dnsCache struct { @@ -66,14 +66,14 @@ func (dc *dnsCache) processDNS(pkt *nfqueue.NFQPacket) { srcip, _ := getPacketIPAddrs(pkt) pinfo := getEmptyPInfo() if !isNSTrusted(srcip) { - pinfo, _ = findProcessForPacket(pkt, true, procsnitch.MATCH_LOOSEST) + pinfo, _ = findProcessForPacket(pkt, true, procsnitch.MATCH_LOOSEST) if pinfo == nil { log.Warningf("Skipping attempted DNS cache entry for process that can't be found: %v -> %v\n", q.Name, dns.answer) return } } -//log.Notice("XXX: PROCESS LOOKUP -> ", pinfo) + //log.Notice("XXX: PROCESS LOOKUP -> ", pinfo) dc.processRecordAddress(q.Name, dns.answer, pinfo.Pid) return } @@ -166,7 +166,7 @@ func (dc *dnsCache) Lookup(ip net.IP, pid int) string { entry, ok := dc.ipMap[pid][ip.String()] if ok { if now.Before(entry.exp) { -// log.Noticef("XXX: LOOKUP on %v / %v = %v, ttl = %v / %v\n", pid, ip.String(), entry.name, entry.ttl, entry.exp) + // log.Noticef("XXX: LOOKUP on %v / %v = %v, ttl = %v / %v\n", pid, ip.String(), entry.name, entry.ttl, entry.exp) return entry.name } else { log.Warningf("Skipping expired per-pid (%d) DNS cache entry: %s -> %s / exp. %v (%ds)\n", @@ -180,13 +180,13 @@ func (dc *dnsCache) Lookup(ip net.IP, pid int) string { if ok { if now.Before(entry.exp) { str = entry.name -// log.Noticef("XXX: LOOKUP on %v / 0 RETURNING %v, ttl = %v / %v\n", ip.String(), str, entry.ttl, entry.exp) + // log.Noticef("XXX: LOOKUP on %v / 0 RETURNING %v, ttl = %v / %v\n", ip.String(), str, entry.ttl, entry.exp) } else { log.Warningf("Skipping expired global DNS cache entry: %s -> %s / exp. %v (%ds)\n", ip.String(), entry.name, entry.exp, entry.ttl) } } -//log.Noticef("XXX: LOOKUP on %v / 0 RETURNING %v\n", ip.String(), str) + //log.Noticef("XXX: LOOKUP on %v / 0 RETURNING %v\n", ip.String(), str) return str } diff --git a/sgfw/dnsmsg.go b/sgfw/dnsmsg.go index ece43fe..e59551d 100644 --- a/sgfw/dnsmsg.go +++ b/sgfw/dnsmsg.go @@ -758,14 +758,14 @@ func unpackRR(msg []byte, off int) (rr dnsRR, off1 int, ok bool) { // A manually-unpacked version of (id, bits). // This is in its own struct for easy printing. type dnsMsgHdr struct { - id uint16 - response bool - opcode int - authoritative bool - truncated bool - recursionDesired bool - recursionAvailable bool - rcode int + id uint16 + response bool + opcode int + authoritative bool + truncated bool + recursionDesired bool + recursionAvailable bool + rcode int } func (h *dnsMsgHdr) Walk(f func(v interface{}, name, tag string) bool) bool { diff --git a/sgfw/ipc.go b/sgfw/ipc.go index 8c80036..cabe8f8 100644 --- a/sgfw/ipc.go +++ b/sgfw/ipc.go @@ -1,31 +1,29 @@ package sgfw import ( + "bufio" + "errors" "fmt" "net" "os" - "bufio" - "strings" "strconv" - "errors" + "strings" - "github.com/subgraph/oz/ipc" + "github.com/subgraph/oz/ipc" ) const ReceiverSocketPath = "/var/run/fw-daemon/fwoz.sock" - type OzInitProc struct { - Name string - Pid int + Name string + Pid int SandboxID int } var OzInitPids []OzInitProc = []OzInitProc{} - func addInitPid(pid int, name string, sboxid int) { -fmt.Println("::::::::::: init pid added: ", pid, " -> ", name) + fmt.Println("::::::::::: init pid added: ", pid, " -> ", name) for i := 0; i < len(OzInitPids); i++ { if OzInitPids[i].Pid == pid { return @@ -37,7 +35,7 @@ fmt.Println("::::::::::: init pid added: ", pid, " -> ", name) } func removeInitPid(pid int) { -fmt.Println("::::::::::: removing PID: ", pid) + fmt.Println("::::::::::: removing PID: ", pid) for i := 0; i < len(OzInitPids); i++ { if OzInitPids[i].Pid == pid { OzInitPids = append(OzInitPids[:i], OzInitPids[i+1:]...) @@ -63,7 +61,7 @@ func addFWRule(fw *Firewall, whitelist bool, srchost, dsthost, dstport string) e } func removeAllByIP(fw *Firewall, srcip string) bool { -log.Notice("XXX: Attempting to remove all rules associated with Oz interface: ", srcip) + log.Notice("XXX: Attempting to remove all rules associated with Oz interface: ", srcip) saddr := net.ParseIP(srcip) if saddr == nil { @@ -73,13 +71,13 @@ log.Notice("XXX: Attempting to remove all rules associated with Oz interface: ", policy := fw.PolicyForPath("*") nrm := 0 - for _, rr := range policy.rules { + for _, rr := range policy.rules { if rr.saddr != nil && rr.saddr.Equal(saddr) { log.Notice("XXX: removing ephemeral rules by Oz interface ", srcip, ": ", rr) policy.removeRule(rr) nrm++ } - } + } if nrm == 0 { log.Notice("XXX: did not remove any rules for interface") @@ -102,10 +100,10 @@ func ReceiverLoop(fw *Firewall, c net.Conn) { data := string(buf) - log.Notice("Received incoming IPC:",data) + log.Notice("Received incoming IPC:", data) if data[len(data)-1] == '\n' { - data = data[0:len(data)-1] + data = data[0 : len(data)-1] } if data == "dump" { @@ -141,18 +139,18 @@ func ReceiverLoop(fw *Firewall, c net.Conn) { c.Write([]byte(ruledesc)) } -/* for i := 0; i < len(sandboxRules); i++ { - rulestr := "" + /* for i := 0; i < len(sandboxRules); i++ { + rulestr := "" - if sandboxRules[i].Whitelist { - rulestr += "whitelist" - } else { - rulestr += "blacklist" - } + if sandboxRules[i].Whitelist { + rulestr += "whitelist" + } else { + rulestr += "blacklist" + } - rulestr += " " + sandboxRules[i].SrcIf.String() + " -> " + sandboxRules[i].DstIP.String() + " : " + strconv.Itoa(int(sandboxRules[i].DstPort)) + "\n" - c.Write([]byte(rulestr)) - } */ + rulestr += " " + sandboxRules[i].SrcIf.String() + " -> " + sandboxRules[i].DstIP.String() + " : " + strconv.Itoa(int(sandboxRules[i].DstPort)) + "\n" + c.Write([]byte(rulestr)) + } */ return } else { @@ -166,7 +164,7 @@ func ReceiverLoop(fw *Firewall, c net.Conn) { if tokens[0] == "register-init" && len(tokens) >= 3 { initp := tokens[1] - + initpid, err := strconv.Atoi(initp) if err != nil { @@ -177,7 +175,7 @@ func ReceiverLoop(fw *Firewall, c net.Conn) { sboxid, err := strconv.Atoi(tokens[3]) if err != nil { - log.Notice("IPC received invalid oz sbox number: ",tokens[3]) + log.Notice("IPC received invalid oz sbox number: ", tokens[3]) log.Notice("Data: %v", data) c.Write([]byte("Bad command: sandbox id was invalid")) return @@ -234,30 +232,30 @@ func ReceiverLoop(fw *Firewall, c net.Conn) { if srcip == nil { log.Notice("IP conversion failed: ", srchost) - srcip = net.IP{0,0,0,0} + srcip = net.IP{0, 0, 0, 0} } dstport := tokens[4] dstp, err := strconv.Atoi(dstport) - if dstport != "*" && (err != nil || dstp < 0 || dstp > 65535) { + if dstport != "*" && (err != nil || dstp < 0 || dstp > 65535) { log.Notice("IPC received invalid destination port: ", tokens[4]) c.Write([]byte("Bad command: dst port was invalid")) return } -/* initp := tokens[5] - initpid, err := strconv.Atoi(initp) + /* initp := tokens[5] + initpid, err := strconv.Atoi(initp) - if err != nil { - log.Notice("IPC received invalid oz-init pid: ", initp) - c.Write([]byte("Bad command: init pid was invalid")) - return - } */ + if err != nil { + log.Notice("IPC received invalid oz-init pid: ", initp) + c.Write([]byte("Bad command: init pid was invalid")) + return + } */ if add { log.Noticef("Adding new rule to oz sandbox/fw: %v / %v -> %v : %v", w, srchost, dsthost, dstport) -// addInitPid(initpid) + // addInitPid(initpid) err := addFWRule(fw, w, srchost, dsthost, dstport) if err != nil { log.Error("Error adding dynamic OZ firewall rule to fw-daemon: ", err) @@ -268,13 +266,11 @@ func ReceiverLoop(fw *Firewall, c net.Conn) { log.Notice("Removing new rule from oz sandbox/fw... ") } - log.Notice("IPC received command: " + data) c.Write([]byte("OK.\n")) return } - } } @@ -303,7 +299,7 @@ func OzReceiver(fw *Firewall) { os.Remove(ReceiverSocketPath) lfd, err := net.Listen("unix", ReceiverSocketPath) if err != nil { - log.Fatal("Could not open oz receiver socket:", err) + log.Fatal("Could not open oz receiver socket:", err) } for { @@ -313,11 +309,10 @@ func OzReceiver(fw *Firewall) { } go ReceiverLoop(fw, fd) - } + } } - type ListProxiesMsg struct { _ string "ListProxies" } @@ -339,11 +334,12 @@ func ListProxies() ([]string, error) { } const OzSocketName = "@oz-control" + var bSockName = OzSocketName var messageFactory = ipc.NewMsgFactory( - new(ListProxiesMsg), - new(ListProxiesResp), + new(ListProxiesMsg), + new(ListProxiesResp), ) func clientConnect() (*ipc.MsgConn, error) { diff --git a/sgfw/log.go b/sgfw/log.go index 54b1111..f91f0a8 100644 --- a/sgfw/log.go +++ b/sgfw/log.go @@ -1,10 +1,10 @@ package sgfw import ( + "fmt" "os" "syscall" "unsafe" - "fmt" "github.com/op/go-logging" ) diff --git a/sgfw/policy.go b/sgfw/policy.go index e0320ed..cd82843 100644 --- a/sgfw/policy.go +++ b/sgfw/policy.go @@ -46,6 +46,7 @@ type pendingConnection interface { dst() net.IP dstPort() uint16 sandbox() string + socks() bool accept() acceptTLSOnly() drop() @@ -78,6 +79,10 @@ func (pp *pendingPkt) sandbox() string { return pp.pinfo.Sandbox } +func (pp *pendingPkt) socks() bool { + return false +} + func (pp *pendingPkt) policy() *Policy { return pp.pol } @@ -175,7 +180,7 @@ func (pp *pendingPkt) print() string { type Policy struct { fw *Firewall path string - sandbox string + sandbox string application string icon string rules RuleList @@ -194,7 +199,7 @@ func (fw *Firewall) PolicyForPath(path string) *Policy { func (fw *Firewall) PolicyForPathAndSandbox(path string, sandbox string) *Policy { fw.lock.Lock() defer fw.lock.Unlock() - + return fw.policyForPathAndSandbox(path, sandbox) } @@ -212,7 +217,7 @@ func (fw *Firewall) policyForPathAndSandbox(path string, sandbox string) *Policy p.icon = entry.icon } fw.policyMap[policykey] = p - log.Infof("Creating new policy for path and sandbox: %s\n",policykey) + log.Infof("Creating new policy for path and sandbox: %s\n", policykey) fw.policies = append(fw.policies, p) } return fw.policyMap[policykey] @@ -268,8 +273,7 @@ func (p *Policy) processPacket(pkt *nfqueue.NFQPacket, pinfo *procsnitch.Info, o func (p *Policy) processPromptResult(pc pendingConnection) { p.pendingQueue = append(p.pendingQueue, pc) - fmt.Println("im here now.. processing prompt result..") - fmt.Println("processPromptResult(): p.promptInProgress = ", p.promptInProgress) + //fmt.Println("processPromptResult(): p.promptInProgress = ", p.promptInProgress) if DoMultiPrompt || (!DoMultiPrompt && !p.promptInProgress) { p.promptInProgress = true go p.fw.dbus.prompt(p) @@ -332,7 +336,7 @@ func (p *Policy) processNewRule(r *Rule, scope FilterScope) bool { } func (p *Policy) parseRule(s string, add bool) (*Rule, error) { - log.Noticef("XXX: attempt to parse rule: |%s|\n", s) + //log.Noticef("XXX: attempt to parse rule: |%s|\n", s) r := new(Rule) r.pid = -1 r.mode = RULE_MODE_PERMANENT @@ -367,7 +371,7 @@ func (p *Policy) filterPending(rule *Rule) { for _, pc := range p.pendingQueue { if rule.match(pc.src(), pc.dst(), pc.dstPort(), pc.hostname(), pc.proto(), pc.procInfo().UID, pc.procInfo().GID, uidToUser(pc.procInfo().UID), gidToGroup(pc.procInfo().GID)) { log.Infof("Adding rule for: %s", rule.getString(FirewallConfig.LogRedact)) - log.Noticef("%s > %s", rule.getString(FirewallConfig.LogRedact), pc.print()) + // log.Noticef("%s > %s", rule.getString(FirewallConfig.LogRedact), pc.print()) if rule.rtype == RULE_ACTION_ALLOW { pc.accept() } else if rule.rtype == RULE_ACTION_ALLOW_TLSONLY { @@ -502,7 +506,7 @@ func (fw *Firewall) filterPacket(pkt *nfqueue.NFQPacket) { return } */ - policy := fw.PolicyForPathAndSandbox(ppath,pinfo.Sandbox) + policy := fw.PolicyForPathAndSandbox(ppath, pinfo.Sandbox) //log.Notice("XXX: flunked basicallowpacket; policy = ", policy) policy.processPacket(pkt, pinfo, optstring) } @@ -524,18 +528,33 @@ func readFileDirect(filename string) ([]byte, error) { fd := int(res) data := make([]byte, 65535) - val, err := syscall.Read(fd, data) - - if err != nil { - return nil, err + i := 0 + val := 0 + for i = 0; i < 65535; { + val, err = syscall.Read(fd, data[i:]) + i += val + if err != nil && val != 0 { + return nil, err + } + if val == 0 { + break + } } - syscall.Close(fd) - - if val < 65535 { - data = data[0:val] - } + data = data[0:i] + /* + val, err := syscall.Read(fd, data) + if err != nil { + return nil, err + } + */ + syscall.Close(fd) + /* + if val < 65535 { + data = data[0:val] + } + */ return data, nil } @@ -584,6 +603,10 @@ func GetRealRoot(pathname string, pid int) string { return pathname } + if lnk == "/" { + return pathname + } + if strings.HasPrefix(pathname, lnk) { return pathname[len(lnk):] } @@ -615,7 +638,6 @@ func LookupSandboxProc(srcip net.IP, srcp uint16, dstip net.IP, dstp uint16, pro data = string(bdata) lines := strings.Split(data, "\n") rlines := make([]string, 0) - for l := 0; l < len(lines); l++ { lines[l] = strings.TrimSpace(lines[l]) ssplit := strings.Split(lines[l], ":") @@ -627,12 +649,16 @@ func LookupSandboxProc(srcip net.IP, srcp uint16, dstip net.IP, dstp uint16, pro rlines = append(rlines, strings.Join(ssplit, ":")) } + // log.Warningf("Looking for %s:%d => %s:%d \n %s\n******\n", srcip, srcp, dstip, dstp, data) + if proto == "tcp" { res = procsnitch.LookupTCPSocketProcessAll(srcip, srcp, dstip, dstp, rlines) } else if proto == "udp" { res = procsnitch.LookupUDPSocketProcessAll(srcip, srcp, dstip, dstp, rlines, strictness) } else if proto == "icmp" { res = procsnitch.LookupICMPSocketProcessAll(srcip, dstip, icode, rlines) + } else { + fmt.Printf("unknown proto: %s", proto) } if res != nil { @@ -640,7 +666,9 @@ func LookupSandboxProc(srcip net.IP, srcp uint16, dstip net.IP, dstp uint16, pro res.Sandbox = OzInitPids[i].Name res.ExePath = GetRealRoot(res.ExePath, OzInitPids[i].Pid) break - } + } /*else { + log.Warningf("*****\nCouldn't find proc for %s:%d => %s:%d \n %s\n******\n", srcip, srcp, dstip, dstp, data) + } */ } } @@ -681,7 +709,7 @@ func findProcessForPacket(pkt *nfqueue.NFQPacket, reverse bool, strictness int) return nil, optstr } - log.Noticef("XXX proto = %s, from %v : %v -> %v : %v\n", proto, srcip, srcp, dstip, dstp) + // log.Noticef("XXX proto = %s, from %v : %v -> %v : %v\n", proto, srcip, srcp, dstip, dstp) var res *procsnitch.Info = nil diff --git a/sgfw/prompt.go b/sgfw/prompt.go index 2e662f4..4c03c6c 100644 --- a/sgfw/prompt.go +++ b/sgfw/prompt.go @@ -13,9 +13,10 @@ import ( "github.com/subgraph/fw-daemon/proc-coroner" ) - var DoMultiPrompt = true -const MAX_PROMPTS = 3 + +const MAX_PROMPTS = 5 + var outstandingPrompts = 0 var promptLock = &sync.Mutex{} @@ -39,12 +40,12 @@ type prompter struct { func (p *prompter) prompt(policy *Policy) { p.lock.Lock() defer p.lock.Unlock() - _, ok := p.policyMap[policy.sandbox + "|" + policy.path] + _, ok := p.policyMap[policy.sandbox+"|"+policy.path] if ok { return } - p.policyMap[policy.sandbox + "|" + policy.path] = policy - fmt.Println("Saving policy key:"+policy.sandbox + "|" + policy.path) + p.policyMap[policy.sandbox+"|"+policy.path] = policy + fmt.Println("Saving policy key:" + policy.sandbox + "|" + policy.path) p.policyQueue = append(p.policyQueue, policy) p.cond.Signal() } @@ -52,11 +53,11 @@ func (p *prompter) prompt(policy *Policy) { func (p *prompter) promptLoop() { p.lock.Lock() for { -fmt.Println("promptLoop() outer") + // fmt.Println("XXX: promptLoop() outer") for p.processNextPacket() { -fmt.Println("promptLoop() inner") + // fmt.Println("XXX: promptLoop() inner") } -fmt.Println("promptLoop() wait") + // fmt.Println("promptLoop() wait") p.cond.Wait() } } @@ -78,7 +79,7 @@ func (p *prompter) processNextPacket() bool { empty := true for { pc, empty = p.nextConnection() -fmt.Println("processNextPacket() loop; empty = ", empty, " / pc = ", pc) + // fmt.Println("XXX: processNextPacket() loop; empty = ", empty, " / pc = ", pc) if pc == nil && empty { return false } else if pc == nil { @@ -89,7 +90,7 @@ fmt.Println("processNextPacket() loop; empty = ", empty, " / pc = ", pc) } p.lock.Unlock() defer p.lock.Lock() - fmt.Println("Waiting for prompt lock go...") + // fmt.Println("XXX: Waiting for prompt lock go...") for { promptLock.Lock() if outstandingPrompts >= MAX_PROMPTS { @@ -105,21 +106,21 @@ fmt.Println("processNextPacket() loop; empty = ", empty, " / pc = ", pc) break } - fmt.Println("Passed prompt lock!") + // fmt.Println("XXX: Passed prompt lock!") outstandingPrompts++ - fmt.Println("Incremented outstanding to ", outstandingPrompts) + // fmt.Println("XXX: Incremented outstanding to ", outstandingPrompts) promptLock.Unlock() -// if !pc.getPrompting() { - pc.setPrompting(true) - go p.processConnection(pc) -// } + // if !pc.getPrompting() { + pc.setPrompting(true) + go p.processConnection(pc) + // } return true } -func processReturn (pc pendingConnection) { +func processReturn(pc pendingConnection) { promptLock.Lock() outstandingPrompts-- - fmt.Println("Return decremented outstanding to ", outstandingPrompts) + // fmt.Println("XXX: Return decremented outstanding to ", outstandingPrompts) promptLock.Unlock() pc.setPrompting(false) } @@ -161,6 +162,7 @@ func (p *prompter) processConnection(pc pendingConnection) { gidToGroup(pc.procInfo().GID), int32(pc.procInfo().Pid), pc.sandbox(), + pc.socks(), pc.getOptString(), FirewallConfig.PromptExpanded, FirewallConfig.PromptExpert, @@ -173,14 +175,14 @@ func (p *prompter) processConnection(pc pendingConnection) { return } - // the prompt sends: - // ALLOW|dest or DENY|dest - // - // rule string needs to be: - // VERB|dst|class|uid:gid|sandbox|[src] + // the prompt sends: + // ALLOW|dest or DENY|dest + // + // rule string needs to be: + // VERB|dst|class|uid:gid|sandbox|[src] - // sometimes there's a src - // this needs to be re-visited + // sometimes there's a src + // this needs to be re-visited toks := strings.Split(rule, "|") //verb := toks[0] @@ -190,19 +192,19 @@ func (p *prompter) processConnection(pc pendingConnection) { if len(toks) > 2 { sandbox = toks[2] } - - tempRule := fmt.Sprintf("%s|%s",toks[0],toks[1]) - if (pc.src() != nil && !pc.src().Equal(net.ParseIP("127.0.0.1")) && sandbox != "") { + tempRule := fmt.Sprintf("%s|%s", toks[0], toks[1]) + + if pc.src() != nil && !pc.src().Equal(net.ParseIP("127.0.0.1")) && sandbox != "" { //if !strings.HasSuffix(rule, "SYSTEM") && !strings.HasSuffix(rule, "||") { - //rule += "||" + //rule += "||" //} //ule += "|||" + pc.src().String() - - tempRule += "||-1:-1|"+sandbox+"|" + pc.src().String() + + tempRule += "||-1:-1|" + sandbox + "|" + pc.src().String() } else { - tempRule += "||-1:-1|"+sandbox+"|" + tempRule += "||-1:-1|" + sandbox + "|" } r, err := policy.parseRule(tempRule, false) if err != nil { @@ -228,7 +230,7 @@ func (p *prompter) processConnection(pc pendingConnection) { r.mode = RULE_MODE_PERMANENT policy.fw.saveRules() } - log.Warningf("Prompt returning rule: %v", rule) + log.Warningf("Prompt returning rule: %v", tempRule) dbusp.alertRule("sgfw prompt added new rule") } @@ -270,7 +272,7 @@ func (p *prompter) removePolicy(policy *Policy) { } } p.policyQueue = newQueue - delete(p.policyMap, policy.sandbox + "|" + policy.path) + delete(p.policyMap, policy.sandbox+"|"+policy.path) } var userMap = make(map[int]string) diff --git a/sgfw/rules.go b/sgfw/rules.go index c568ee6..7a512dd 100644 --- a/sgfw/rules.go +++ b/sgfw/rules.go @@ -1,7 +1,7 @@ package sgfw import ( - "encoding/binary" + // "encoding/binary" "fmt" "io/ioutil" "net" @@ -71,8 +71,6 @@ func (r *Rule) getString(redact bool) string { sbox := "|" if r.sandbox != "" { sbox = "|" + sbox - } else { - log.Notice("sandbox is ", r.sandbox) } return fmt.Sprintf("%s|%s%s%s%s%s", rtype, protostr, r.AddrString(redact), rmode, rpriv, sbox) @@ -119,7 +117,7 @@ func (r *Rule) match(src net.IP, dst net.IP, dstPort uint16, hostname string, pr return false } - log.Notice("comparison: ", hostname, " / ", dst, " : ", dstPort, " -> ", r.addr, " / ", r.hostname, " : ", r.port) + // log.Notice("comparison: ", hostname, " / ", dst, " : ", dstPort, " -> ", r.addr, " / ", r.hostname, " : ", r.port) if r.port != matchAny && r.port != dstPort { return false } @@ -127,7 +125,6 @@ func (r *Rule) match(src net.IP, dst net.IP, dstPort uint16, hostname string, pr return true } if r.hostname != "" { - log.Notice("comparing hostname") if strings.ContainsAny(r.hostname, "*") { regstr := strings.Replace(r.hostname, "*", ".?", -1) match, err := regexp.MatchString(regstr, hostname) @@ -144,7 +141,7 @@ func (r *Rule) match(src net.IP, dst net.IP, dstPort uint16, hostname string, pr return true } if proto == "icmp" { - fmt.Printf("network = %v, src = %v, r.addr = %x, src to4 = %x\n", r.network, src, r.addr, binary.BigEndian.Uint32(src.To4())) + //fmt.Printf("network = %v, src = %v, r.addr = %x, src to4 = %x\n", r.network, src, r.addr, binary.BigEndian.Uint32(src.To4())) if (r.network != nil && r.network.Contains(src)) || (r.addr.Equal(src)) { return true } @@ -169,10 +166,9 @@ func (rl *RuleList) filter(pkt *nfqueue.NFQPacket, src, dst net.IP, dstPort uint } // sandboxed := strings.HasPrefix(optstr, "SOCKS5|Tor / Sandbox") for _, r := range *rl { - log.Notice("fuck ",r) nfqproto := "" - log.Notice("------------ trying match of src ", src, " against: ", r, " | ", r.saddr, " / optstr = ", optstr, "; pid ", pinfo.Pid, " vs rule pid ", r.pid) - log.Notice("r.saddr: ", r.saddr, "src: ", src, "sandboxed ", sandboxed, "optstr: ", optstr) + //log.Notice("------------ trying match of src ", src, " against: ", r, " | ", r.saddr, " / optstr = ", optstr, "; pid ", pinfo.Pid, " vs rule pid ", r.pid) + //log.Notice("r.saddr: ", r.saddr, "src: ", src, "sandboxed ", sandboxed, "optstr: ", optstr) if r.saddr == nil && src != nil && sandboxed { log.Notice("! Skipping comparison against incompatible rule types: rule src = ", r.saddr, " / packet src = ", src) // continue @@ -187,16 +183,27 @@ func (rl *RuleList) filter(pkt *nfqueue.NFQPacket, src, dst net.IP, dstPort uint if pkt != nil { nfqproto = getNFQProto(pkt) } else { - log.Notice("Weird state.") + if r.saddr == nil && src == nil && sandboxed == false && (r.port == dstPort || r.port == matchAny) && (r.addr.Equal(anyAddress) || r.hostname == "" || r.hostname == hostname) { + // log.Notice("+ Socks5 MATCH SUCCEEDED") + if r.rtype == RULE_ACTION_DENY { + return FILTER_DENY + } else if r.rtype == RULE_ACTION_ALLOW { + return FILTER_ALLOW + } else if r.rtype == RULE_ACTION_ALLOW_TLSONLY { + return FILTER_ALLOW_TLSONLY + } + } else { + return FILTER_PROMPT + } } } - log.Notice("r.saddr = ", r.saddr, "src = ", src, "\n") + // log.Notice("r.saddr = ", r.saddr, "src = ", src, "\n") if r.pid >= 0 && r.pid != pinfo.Pid { //log.Notice("! Skipping comparison of mismatching PIDs") continue } if r.match(src, dst, dstPort, hostname, nfqproto, pinfo.UID, pinfo.GID, uidToUser(pinfo.UID), gidToGroup(pinfo.GID)) { - log.Notice("+ MATCH SUCCEEDED") + // log.Notice("+ MATCH SUCCEEDED") dstStr := dst.String() if FirewallConfig.LogRedact { dstStr = STR_REDACTED @@ -207,12 +214,10 @@ func (rl *RuleList) filter(pkt *nfqueue.NFQPacket, src, dst net.IP, dstPort uint srcp, _ := getPacketPorts(pkt) srcStr = fmt.Sprintf("%s:%d", srcip, srcp) } - log.Noticef("%s > %s %s %s -> %s:%d", - r.getString(FirewallConfig.LogRedact), - pinfo.ExePath, r.proto, - srcStr, - dstStr, dstPort) + // log.Noticef("%s > %s %s %s -> %s:%d", + //r.getString(FirewallConfig.LogRedact), pinfo.ExePath, r.proto, srcStr, dstStr, dstPort) if r.rtype == RULE_ACTION_DENY { + //TODO: Optionally redact below log entry log.Warningf("DENIED outgoing connection attempt by %s from %s %s -> %s:%d", pinfo.ExePath, r.proto, srcStr, @@ -222,19 +227,20 @@ func (rl *RuleList) filter(pkt *nfqueue.NFQPacket, src, dst net.IP, dstPort uint result = FILTER_ALLOW return result /* - if r.saddr != nil { - return result - } + if r.saddr != nil { + return result + } */ } else if r.rtype == RULE_ACTION_ALLOW_TLSONLY { result = FILTER_ALLOW_TLSONLY return result - } - } else { - log.Notice("+ MATCH FAILED") + } } + /**else { + log.Notice("+ MATCH FAILED") + } */ } - log.Notice("--- RESULT = ", result) + // log.Notice("--- RESULT = ", result) return result } @@ -269,7 +275,7 @@ func (r *Rule) parse(s string) bool { return false } - fmt.Printf("uid = %v, gid = %v, user = %v, group = %v, hostname = %v, sandbox = %v\n", r.uid, r.gid, r.uname, r.gname, r.hostname, r.sandbox) + // fmt.Printf("uid = %v, gid = %v, user = %v, group = %v, hostname = %v, sandbox = %v\n", r.uid, r.gid, r.uname, r.gname, r.hostname, r.sandbox) if len(parts) == 6 && len(strings.TrimSpace(parts[5])) > 0 { r.saddr = net.ParseIP(parts[5]) @@ -439,7 +445,7 @@ func savePolicy(f *os.File, p *Policy) { if !p.hasPersistentRules() { return } - log.Warningf("p.path: ",p.path) + log.Warningf("p.path: ", p.path) if !writeLine(f, "["+p.sandbox+"|"+p.path+"]") { return } @@ -495,7 +501,7 @@ func (fw *Firewall) loadRules() { func (fw *Firewall) processPathLine(line string) *Policy { pathLine := line[1 : len(line)-1] toks := strings.Split(pathLine, "|") - policy := fw.policyForPathAndSandbox(toks[1],toks[0]) + policy := fw.policyForPathAndSandbox(toks[1], toks[0]) policy.lock.Lock() defer policy.lock.Unlock() policy.rules = nil diff --git a/sgfw/sgfw.go b/sgfw/sgfw.go index af8faf9..8aa49ac 100644 --- a/sgfw/sgfw.go +++ b/sgfw/sgfw.go @@ -241,7 +241,13 @@ func Main() { wg := sync.WaitGroup{} - config, err := loadSocksConfiguration(defaultSocksCfgPath) + scfile := os.Getenv("SGFW_SOCKS_CONFIG") + + if scfile == "" { + scfile = defaultSocksCfgPath + } + + config, err := loadSocksConfiguration(scfile) if err != nil && !os.IsNotExist(err) { panic(err) } @@ -250,7 +256,7 @@ func Main() { chain := NewSocksChain(socksConfig, &wg, fw) chain.start() } else { - log.Notice("Did not find SOCKS5 configuration file at", defaultSocksCfgPath, "; ignoring subsystem...") + log.Notice("Did not find SOCKS5 configuration file at", scfile, "; ignoring subsystem...") } dbusp, err = newDbusObjectPrompt() diff --git a/sgfw/socks_server_chain.go b/sgfw/socks_server_chain.go index 537879b..6836d58 100644 --- a/sgfw/socks_server_chain.go +++ b/sgfw/socks_server_chain.go @@ -8,8 +8,8 @@ import ( "time" "github.com/subgraph/go-procsnitch" - "strings" "strconv" + "strings" ) type socksChainConfig struct { @@ -17,7 +17,7 @@ type socksChainConfig struct { TargetSocksAddr string ListenSocksNet string ListenSocksAddr string - Name string + Name string } type socksChain struct { @@ -36,33 +36,37 @@ type socksChainSession struct { bndAddr *Address optData []byte procInfo procsnitch.ProcInfo - pinfo *procsnitch.Info + pinfo *procsnitch.Info server *socksChain } const ( - socksVerdictDrop = 1 - socksVerdictAccept = 2 + socksVerdictDrop = 1 + socksVerdictAccept = 2 socksVerdictAcceptTLSOnly = 3 ) type pendingSocksConnection struct { - pol *Policy - hname string - srcIP net.IP - destIP net.IP + pol *Policy + hname string + srcIP net.IP + destIP net.IP sourcePort uint16 - destPort uint16 - pinfo *procsnitch.Info - verdict chan int - prompting bool - optstr string + destPort uint16 + pinfo *procsnitch.Info + verdict chan int + prompting bool + optstr string } func (sc *pendingSocksConnection) sandbox() string { return sc.pinfo.Sandbox } +func (sc *pendingSocksConnection) socks() bool { + return true +} + func (sc *pendingSocksConnection) policy() *Policy { return sc.pol } @@ -97,15 +101,21 @@ func (sc *pendingSocksConnection) src() net.IP { } func (sc *pendingSocksConnection) deliverVerdict(v int) { + defer func() { + if r := recover(); r != nil { + log.Warning("SOCKS5 server recovered from panic while delivering firewall verdict:", r) + } + }() + sc.verdict <- v close(sc.verdict) } func (sc *pendingSocksConnection) accept() { sc.deliverVerdict(socksVerdictAccept) } -// need to generalize special accept +// need to generalize special accept -func (sc *pendingSocksConnection) acceptTLSOnly() {sc.deliverVerdict(socksVerdictAcceptTLSOnly) } +func (sc *pendingSocksConnection) acceptTLSOnly() { sc.deliverVerdict(socksVerdictAcceptTLSOnly) } func (sc *pendingSocksConnection) drop() { sc.deliverVerdict(socksVerdictDrop) } @@ -172,7 +182,7 @@ func (c *socksChainSession) sessionWorker() { if len(c.req.Auth.Uname) == 0 && len(c.req.Auth.Passwd) == 0 { // Randomize username and password to force a new TOR circuit with each connection - rndbytes := []byte("sgfw" + strconv.Itoa(int(time.Now().UnixNano()) ^ os.Getpid())) + rndbytes := []byte("sgfw" + strconv.Itoa(int(time.Now().UnixNano())^os.Getpid())) c.req.Auth.Uname = rndbytes c.req.Auth.Passwd = rndbytes } @@ -230,7 +240,7 @@ func findProxyEndpoint(pdata []string, conn net.Conn) (*procsnitch.Info, string) s1, d1, s2, d2 := toks[0], toks[2], toks[3], toks[5] if strings.HasSuffix(d1, ",") { - d1 = d1[0:len(d1)-1] + d1 = d1[0 : len(d1)-1] } if conn.LocalAddr().String() == d2 && conn.RemoteAddr().String() == s2 { @@ -275,14 +285,21 @@ func (c *socksChainSession) filterConnect() (bool, bool) { var pinfo *procsnitch.Info = nil var optstr = "" + // try to find process via oz-daemon known proxy endpoints + if err == nil { pinfo, optstr = findProxyEndpoint(allProxies, c.clientConn) } + // fall back to system-wide processes + if pinfo == nil { pinfo = procsnitch.FindProcessForConnection(c.clientConn, c.procInfo) + } + // connection maybe doesn't exist anymore + if pinfo == nil { log.Warningf("No proc found for [socks5] connection from: %s", c.clientConn.RemoteAddr()) return false, false @@ -296,15 +313,13 @@ func (c *socksChainSession) filterConnect() (bool, bool) { optstr = "[Via SOCKS5: " + c.cfg.Name + "] " + optstr } - log.Warningf("Lookup policy for %v %v",pinfo.ExePath,pinfo.Sandbox) - policy := c.server.fw.PolicyForPathAndSandbox(GetRealRoot(pinfo.ExePath,pinfo.Pid),pinfo.Sandbox) + policy := c.server.fw.PolicyForPathAndSandbox(GetRealRoot(pinfo.ExePath, pinfo.Pid), pinfo.Sandbox) hostname, ip, port := c.addressDetails() if ip == nil && hostname == "" { return false, false } result := policy.rules.filter(nil, nil, ip, port, hostname, pinfo, optstr) - log.Errorf("result %v",result) switch result { case FILTER_DENY: return false, false @@ -315,7 +330,7 @@ func (c *socksChainSession) filterConnect() (bool, bool) { case FILTER_PROMPT: caddr := c.clientConn.RemoteAddr().String() caddrt := strings.Split(caddr, ":") - caddrIP := net.IP{0,0,0,0} + caddrIP := net.IP{0, 0, 0, 0} caddrPort := uint16(0) if len(caddrt) != 2 { @@ -392,9 +407,9 @@ func (c *socksChainSession) forwardTraffic(tls bool) { if err != nil { if c.pinfo.Sandbox != "" { - log.Errorf("Dropping traffic from %s (sandbox: %s) to %s due to TLSGuard violation: %v", c.pinfo.ExePath, c.pinfo.Sandbox, c.req.Addr.addrStr, err) + log.Errorf("TLSGuard violation: Dropping traffic from %s (sandbox: %s) to %s: %v", c.pinfo.ExePath, c.pinfo.Sandbox, c.req.Addr.addrStr, err) } else { - log.Errorf("Dropping traffic from %s (unsandboxed) to %s due to TLSGuard violation: %v", c.pinfo.ExePath, c.req.Addr.addrStr, err) + log.Errorf("TLSGuard violation: Dropping traffic from %s (unsandboxed) to %s: %v", c.pinfo.ExePath, c.req.Addr.addrStr, err) } return } else { diff --git a/sgfw/tlsguard.go b/sgfw/tlsguard.go index 84333be..0fe2781 100644 --- a/sgfw/tlsguard.go +++ b/sgfw/tlsguard.go @@ -2,15 +2,14 @@ package sgfw import ( "crypto/x509" + "errors" "io" "net" - "errors" ) - func TLSGuard(conn, conn2 net.Conn, fqdn string) error { -// Should this be a requirement? -// if strings.HasSuffix(request.DestAddr.FQDN, "onion") { + // Should this be a requirement? + // if strings.HasSuffix(request.DestAddr.FQDN, "onion") { handshakeByte, err := readNBytes(conn, 1) if err != nil { @@ -118,7 +117,7 @@ func TLSGuard(conn, conn2 net.Conn, fqdn string) error { for remaining > 0 { certLen := int(int(pos[0])<<16 | int(pos[1])<<8 | int(pos[2])) -// fmt.Printf("Certs chain len %d, cert 1 len %d:\n", certChainLen, certLen) + // fmt.Printf("Certs chain len %d, cert 1 len %d:\n", certChainLen, certLen) cert := pos[3 : 3+certLen] certs, err := x509.ParseCertificates(cert) if remaining == certChainLen { @@ -143,18 +142,18 @@ func TLSGuard(conn, conn2 net.Conn, fqdn string) error { } else { valid = true } -// else if s == 0x0d { fmt.Printf("found a client cert request, sending buf to client\n") } + // else if s == 0x0d { fmt.Printf("found a client cert request, sending buf to client\n") } } else if s == 0x0e { sendToClient = true } else if s == 0x0d { sendToClient = true } -// fmt.Printf("Version bytes: %x %x\n", responseBuf[1], responseBuf[2]) -// fmt.Printf("Len bytes: %x %x\n", responseBuf[3], responseBuf[4]) -// fmt.Printf("Message type: %x\n", responseBuf[5]) -// fmt.Printf("Message len: %x %x %x\n", responseBuf[6], responseBuf[7], responseBuf[8]) -// fmt.Printf("Message body: %v\n", responseBuf[9:]) + // fmt.Printf("Version bytes: %x %x\n", responseBuf[1], responseBuf[2]) + // fmt.Printf("Len bytes: %x %x\n", responseBuf[3], responseBuf[4]) + // fmt.Printf("Message type: %x\n", responseBuf[5]) + // fmt.Printf("Message len: %x %x %x\n", responseBuf[6], responseBuf[7], responseBuf[8]) + // fmt.Printf("Message body: %v\n", responseBuf[9:]) conn.Write(responseBuf) responseBuf = []byte{} } diff --git a/sources/etc/sgfw/sgfw.conf b/sources/etc/sgfw/sgfw.conf new file mode 100644 index 0000000..5dbc668 --- /dev/null +++ b/sources/etc/sgfw/sgfw.conf @@ -0,0 +1,5 @@ +log_level="NOTICE" +log_redact=false +prompt_expanded=true +prompt_expert=true +default_action="SESSION" diff --git a/sources/lib/systemd/system/fw-daemon.service b/sources/lib/systemd/system/fw-daemon.service deleted file mode 100644 index 0a9fba8..0000000 --- a/sources/lib/systemd/system/fw-daemon.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Documentation=https://github.com/subgraph/fw-daemon -Description=Subgraph Firewall Daemon - -[Service] -Environment="GODEBUG=cgocheck=0" -ExecStartPre=/usr/bin/install -d /var/run/fw-daemon -ExecStart=/usr/sbin/fw-daemon - -[Install] -WantedBy=multi-user.target diff --git a/sources/usr/share/applications/subgraph-firewall.desktop b/sources/usr/share/applications/subgraph-firewall.desktop index 6df5f48..c77798d 100644 --- a/sources/usr/share/applications/subgraph-firewall.desktop +++ b/sources/usr/share/applications/subgraph-firewall.desktop @@ -1,5 +1,4 @@ [Desktop Entry] -Encoding=UTF-8 Name=Subgraph Firewall Settings Comment=Launch the Subgraph Firewall Settings TryExec=fw-settings @@ -7,4 +6,5 @@ Exec=fw-settings Terminal=false Type=Application Icon=security-medium -Categories=Network;Admin; +Categories=Security;Settings; +X-Desktop-File-Install-Version=0.23 diff --git a/vendor/github.com/google/gopacket/.gitignore b/vendor/github.com/google/gopacket/.gitignore new file mode 100644 index 0000000..149266f --- /dev/null +++ b/vendor/github.com/google/gopacket/.gitignore @@ -0,0 +1,38 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +#* +*~ + +# examples binaries +examples/synscan/synscan +examples/pfdump/pfdump +examples/pcapdump/pcapdump +examples/httpassembly/httpassembly +examples/statsassembly/statsassembly +examples/arpscan/arpscan +examples/bidirectional/bidirectional +examples/bytediff/bytediff +examples/reassemblydump/reassemblydump +layers/gen +macs/gen +pcap/pcap_tester diff --git a/vendor/github.com/google/gopacket/.travis.gofmt.sh b/vendor/github.com/google/gopacket/.travis.gofmt.sh new file mode 100755 index 0000000..e341a1c --- /dev/null +++ b/vendor/github.com/google/gopacket/.travis.gofmt.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +cd "$(dirname $0)" +if [ -n "$(go fmt ./...)" ]; then + echo "Go code is not formatted, run 'go fmt github.com/google/stenographer/...'" >&2 + exit 1 +fi diff --git a/vendor/github.com/google/gopacket/.travis.golint.sh b/vendor/github.com/google/gopacket/.travis.golint.sh new file mode 100755 index 0000000..ed74c65 --- /dev/null +++ b/vendor/github.com/google/gopacket/.travis.golint.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +cd "$(dirname $0)" + +go get github.com/golang/lint/golint +DIRS=". tcpassembly tcpassembly/tcpreader ip4defrag reassembly macs pcapgo pcap afpacket pfring routing" +# Add subdirectories here as we clean up golint on each. +for subdir in $DIRS; do + pushd $subdir + if golint | + grep -v CannotSetRFMon | # pcap exported error name + grep -v DataLost | # tcpassembly/tcpreader exported error name + grep .; then + exit 1 + fi + popd +done + +pushd layers +for file in $(cat .linted); do + if golint $file | grep .; then + exit 1 + fi +done +popd diff --git a/vendor/github.com/google/gopacket/.travis.govet.sh b/vendor/github.com/google/gopacket/.travis.govet.sh new file mode 100755 index 0000000..52ad084 --- /dev/null +++ b/vendor/github.com/google/gopacket/.travis.govet.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +cd "$(dirname $0)" +DIRS=". layers pcap pcapgo pfring tcpassembly tcpassembly/tcpreader routing ip4defrag bytediff macs" +set -e +for subdir in $DIRS; do + pushd $subdir + go vet + popd +done diff --git a/vendor/github.com/google/gopacket/.travis.yml b/vendor/github.com/google/gopacket/.travis.yml new file mode 100644 index 0000000..7d73126 --- /dev/null +++ b/vendor/github.com/google/gopacket/.travis.yml @@ -0,0 +1,14 @@ +language: go +install: + - go get github.com/google/gopacket + - go get github.com/google/gopacket/layers + - go get github.com/google/gopacket/tcpassembly + - go get github.com/google/gopacket/reassembly +script: + - go test github.com/google/gopacket + - go test github.com/google/gopacket/layers + - go test github.com/google/gopacket/tcpassembly + - go test github.com/google/gopacket/reassembly + - ./.travis.gofmt.sh + - ./.travis.govet.sh + - ./.travis.golint.sh diff --git a/vendor/github.com/google/gopacket/AUTHORS b/vendor/github.com/google/gopacket/AUTHORS new file mode 100644 index 0000000..eba34f0 --- /dev/null +++ b/vendor/github.com/google/gopacket/AUTHORS @@ -0,0 +1,46 @@ +AUTHORS AND MAINTAINERS: + +MAIN DEVELOPERS: +Graeme Connell + +AUTHORS: +Nigel Tao +Cole Mickens +Ben Daglish +Luis Martinez +Remco Verhoef +Hiroaki Kawai +Lukas Lueg +Laurent Hausermann +Bill Green + +CONTRIBUTORS: +Attila Oláh +Vittus Mikiassen +Matthias Radestock +Matthew Sackman +Loic Prylli +Alexandre Fiori +Adrian Tam +Satoshi Matsumoto +David Stainton +Jesse Ward +Kane Mathers + +----------------------------------------------- +FORKED FROM github.com/akrennmair/gopcap +ALL THE FOLLOWING ARE FOR THAT PROJECT + +MAIN DEVELOPERS: +Andreas Krennmair + +CONTRIBUTORS: +Andrea Nall +Daniel Arndt +Dustin Sallings +Graeme Connell +Guillaume Savary +Mark Smith +Miek Gieben +Mike Bell +Trevor Strohman diff --git a/vendor/github.com/google/gopacket/CONTRIBUTING.md b/vendor/github.com/google/gopacket/CONTRIBUTING.md new file mode 100644 index 0000000..99ab7a2 --- /dev/null +++ b/vendor/github.com/google/gopacket/CONTRIBUTING.md @@ -0,0 +1,215 @@ +Contributing To gopacket +======================== + +So you've got some code and you'd like it to be part of gopacket... wonderful! +We're happy to accept contributions, whether they're fixes to old protocols, new +protocols entirely, or anything else you think would improve the gopacket +library. This document is designed to help you to do just that. + +The first section deals with the plumbing: how to actually get a change +submitted. + +The second section deals with coding style... Go is great in that it +has a uniform style implemented by 'go fmt', but there's still some decisions +we've made that go above and beyond, and if you follow them, they won't come up +in your code review. + +The third section deals with some of the implementation decisions we've made, +which may help you to understand the current code and which we may ask you to +conform to (or provide compelling reasons for ignoring). + +Overall, we hope this document will help you to understand our system and write +great code which fits in, and help us to turn around on your code review quickly +so the code can make it into the master branch as quickly as possible. + + +How To Submit Code +------------------ + +We use github.com's Pull Request feature to receive code contributions from +external contributors. See +https://help.github.com/articles/creating-a-pull-request/ for details on +how to create a request. + +Also, there's a local script `gc` in the base directory of GoPacket that +runs a local set of checks, which should give you relatively high confidence +that your pull won't fail github pull checks. + +```sh +go get github.com/google/gopacket +cd $GOROOT/src/pkg/github.com/google/gopacket +git checkout -b # create a new branch to work from +... code code code ... +./gc # Run this to do local commits, it performs a number of checks +``` + +To sum up: + +* DO + + Pull down the latest version. + + Make a feature-specific branch. + + Code using the style and methods discussed in the rest of this document. + + Use the ./gc command to do local commits or check correctness. + + Push your new feature branch up to github.com, as a pull request. + + Handle comments and requests from reviewers, pushing new commits up to + your feature branch as problems are addressed. + + Put interesting comments and discussions into commit comments. +* DON'T + + Push to someone else's branch without their permission. + + +Coding Style +------------ + +* Go code must be run through `go fmt`, `go vet`, and `golint` +* Follow http://golang.org/doc/effective_go.html as much as possible. + + In particular, http://golang.org/doc/effective_go.html#mixed-caps. Enums + should be be CamelCase, with acronyms capitalized (TCPSourcePort, vs. + TcpSourcePort or TCP_SOURCE_PORT). +* Bonus points for giving enum types a String() field. +* Any exported types or functions should have commentary + (http://golang.org/doc/effective_go.html#commentary) + + +Coding Methods And Implementation Notes +--------------------------------------- + +### Error Handling + +Many times, you'll be decoding a protocol and run across something bad, a packet +corruption or the like. How do you handle this? First off, ALWAYS report the +error. You can do this either by returning the error from the decode() function +(most common), or if you're up for it you can implement and add an ErrorLayer +through the packet builder (the first method is a simple shortcut that does +exactly this, then stops any future decoding). + +Often, you'll already have decode some part of your protocol by the time you hit +your error. Use your own discretion to determine whether the stuff you've +already decoded should be returned to the caller or not: + +```go +func decodeMyProtocol(data []byte, p gopacket.PacketBuilder) error { + prot := &MyProtocol{} + if len(data) < 10 { + // This error occurred before we did ANYTHING, so there's nothing in my + // protocol that the caller could possibly want. Just return the error. + return fmt.Errorf("Length %d less than 10", len(data)) + } + prot.ImportantField1 = data[:5] + prot.ImportantField2 = data[5:10] + // At this point, we've already got enough information in 'prot' to + // warrant returning it to the caller, so we'll add it now. + p.AddLayer(prot) + if len(data) < 15 { + // We encountered an error later in the packet, but the caller already + // has the important info we've gleaned so far. + return fmt.Errorf("Length %d less than 15", len(data)) + } + prot.ImportantField3 = data[10:15] + return nil // We've already added the layer, we can just return success. +} +``` + +In general, our code follows the approach of returning the first error it +encounters. In general, we don't trust any bytes after the first error we see. + +### What Is A Layer? + +The definition of a layer is up to the discretion of the coder. It should be +something important enough that it's actually useful to the caller (IE: every +TLV value should probably NOT be a layer). However, it can be more granular +than a single protocol... IPv6 and SCTP both implement many layers to handle the +various parts of the protocol. Use your best judgement, and prepare to defend +your decisions during code review. ;) + +### Performance + +We strive to make gopacket as fast as possible while still providing lots of +features. In general, this means: + +* Focus performance tuning on common protocols (IP4/6, TCP, etc), and optimize + others on an as-needed basis (tons of MPLS on your network? Time to optimize + MPLS!) +* Use fast operations. See the toplevel benchmark_test for benchmarks of some + of Go's underlying features and types. +* Test your performance changes! You should use the ./gc script's --benchmark + flag to submit any performance-related changes. Use pcap/gopacket_benchmark + to test your change against a PCAP file based on your traffic patterns. +* Don't be TOO hacky. Sometimes, removing an unused struct from a field causes + a huge performance hit, due to the way that Go currently handles its segmented + stack... don't be afraid to clean it up anyway. We'll trust the Go compiler + to get good enough over time to handle this. Also, this type of + compiler-specific optimization is very fragile; someone adding a field to an + entirely different struct elsewhere in the codebase could reverse any gains + you might achieve by aligning your allocations. +* Try to minimize memory allocations. If possible, use []byte to reference + pieces of the input, instead of using string, which requires copying the bytes + into a new memory allocation. +* Think hard about what should be evaluated lazily vs. not. In general, a + layer's struct should almost exactly mirror the layer's frame. Anything + that's more interesting should be a function. This may not always be + possible, but it's a good rule of thumb. +* Don't fear micro-optimizations. With the above in mind, we welcome + micro-optimizations that we think will have positive/neutral impacts on the + majority of workloads. A prime example of this is pre-allocating certain + structs within a larger one: + +```go +type MyProtocol struct { + // Most packets have 1-4 of VeryCommon, so we preallocate it here. + initialAllocation [4]uint32 + VeryCommon []uint32 +} + +func decodeMyProtocol(data []byte, p gopacket.PacketBuilder) error { + prot := &MyProtocol{} + prot.VeryCommon = proto.initialAllocation[:0] + for len(data) > 4 { + field := binary.BigEndian.Uint32(data[:4]) + data = data[4:] + // Since we're using the underlying initialAllocation, we won't need to + // allocate new memory for the following append unless we more than 16 + // bytes of data, which should be the uncommon case. + prot.VeryCommon = append(prot.VeryCommon, field) + } + p.AddLayer(prot) + if len(data) > 0 { + return fmt.Errorf("MyProtocol packet has %d bytes left after decoding", len(data)) + } + return nil +} +``` + +### Slices And Data + +If you're pulling a slice from the data you're decoding, don't copy it. Just +use the slice itself. + +```go +type MyProtocol struct { + A, B net.IP +} +func decodeMyProtocol(data []byte, p gopacket.PacketBuilder) error { + p.AddLayer(&MyProtocol{ + A: data[:4], + B: data[4:8], + }) + return nil +} +``` + +The caller has already agreed, by using this library, that they won't modify the +set of bytes they pass in to the decoder, or the library has already copied the +set of bytes to a read-only location. See DecodeOptions.NoCopy for more +information. + +### Enums/Types + +If a protocol has an integer field (uint8, uint16, etc) with a couple of known +values that mean something special, make it a type. This allows us to do really +nice things like adding a String() function to them, so we can more easily +display those to users. Check out layers/enums.go for one example, as well as +layers/icmp.go for layer-specific enums. + +When naming things, try for descriptiveness over suscinctness. For example, +choose DNSResponseRecord over DNSRR. diff --git a/vendor/github.com/google/gopacket/LICENSE b/vendor/github.com/google/gopacket/LICENSE new file mode 100644 index 0000000..2100d52 --- /dev/null +++ b/vendor/github.com/google/gopacket/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2012 Google, Inc. All rights reserved. +Copyright (c) 2009-2011 Andreas Krennmair. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Andreas Krennmair, Google, nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/google/gopacket/README.md b/vendor/github.com/google/gopacket/README.md new file mode 100644 index 0000000..f71854c --- /dev/null +++ b/vendor/github.com/google/gopacket/README.md @@ -0,0 +1,10 @@ +# GoPacket + +This library provides packet decoding capabilities for Go. +See [godoc](https://godoc.org/github.com/google/gopacket) for more details. + +[![Build Status](https://travis-ci.org/google/gopacket.svg?branch=master)](https://travis-ci.org/google/gopacket) +[![GoDoc](https://godoc.org/github.com/google/gopacket?status.svg)](https://godoc.org/github.com/google/gopacket) + +Originally forked from the gopcap project written by Andreas +Krennmair (http://github.com/akrennmair/gopcap). diff --git a/vendor/github.com/google/gopacket/base.go b/vendor/github.com/google/gopacket/base.go new file mode 100644 index 0000000..797b55f --- /dev/null +++ b/vendor/github.com/google/gopacket/base.go @@ -0,0 +1,178 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package gopacket + +import ( + "fmt" +) + +// Layer represents a single decoded packet layer (using either the +// OSI or TCP/IP definition of a layer). When decoding, a packet's data is +// broken up into a number of layers. The caller may call LayerType() to +// figure out which type of layer they've received from the packet. Optionally, +// they may then use a type assertion to get the actual layer type for deep +// inspection of the data. +type Layer interface { + // LayerType is the gopacket type for this layer. + LayerType() LayerType + // LayerContents returns the set of bytes that make up this layer. + LayerContents() []byte + // LayerPayload returns the set of bytes contained within this layer, not + // including the layer itself. + LayerPayload() []byte +} + +// Payload is a Layer containing the payload of a packet. The definition of +// what constitutes the payload of a packet depends on previous layers; for +// TCP and UDP, we stop decoding above layer 4 and return the remaining +// bytes as a Payload. Payload is an ApplicationLayer. +type Payload []byte + +// LayerType returns LayerTypePayload +func (p Payload) LayerType() LayerType { return LayerTypePayload } + +// LayerContents returns the bytes making up this layer. +func (p Payload) LayerContents() []byte { return []byte(p) } + +// LayerPayload returns the payload within this layer. +func (p Payload) LayerPayload() []byte { return nil } + +// Payload returns this layer as bytes. +func (p Payload) Payload() []byte { return []byte(p) } + +// String implements fmt.Stringer. +func (p Payload) String() string { return fmt.Sprintf("%d byte(s)", len(p)) } + +// GoString implements fmt.GoStringer. +func (p Payload) GoString() string { return LongBytesGoString([]byte(p)) } + +// CanDecode implements DecodingLayer. +func (p Payload) CanDecode() LayerClass { return LayerTypePayload } + +// NextLayerType implements DecodingLayer. +func (p Payload) NextLayerType() LayerType { return LayerTypeZero } + +// DecodeFromBytes implements DecodingLayer. +func (p *Payload) DecodeFromBytes(data []byte, df DecodeFeedback) error { + *p = Payload(data) + return nil +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (p Payload) SerializeTo(b SerializeBuffer, opts SerializeOptions) error { + bytes, err := b.PrependBytes(len(p)) + if err != nil { + return err + } + copy(bytes, p) + return nil +} + +// decodePayload decodes data by returning it all in a Payload layer. +func decodePayload(data []byte, p PacketBuilder) error { + payload := &Payload{} + if err := payload.DecodeFromBytes(data, p); err != nil { + return nil + } + p.AddLayer(payload) + p.SetApplicationLayer(payload) + return nil +} + +// Fragment is a Layer containing a fragment of a larger frame, used by layers +// like IPv4 and IPv6 that allow for fragmentation of their payloads. +type Fragment []byte + +// LayerType returns LayerTypeFragment +func (p *Fragment) LayerType() LayerType { return LayerTypeFragment } + +// LayerContents implements Layer. +func (p *Fragment) LayerContents() []byte { return []byte(*p) } + +// LayerPayload implements Layer. +func (p *Fragment) LayerPayload() []byte { return nil } + +// Payload returns this layer as a byte slice. +func (p *Fragment) Payload() []byte { return []byte(*p) } + +// String implements fmt.Stringer. +func (p *Fragment) String() string { return fmt.Sprintf("%d byte(s)", len(*p)) } + +// CanDecode implements DecodingLayer. +func (p *Fragment) CanDecode() LayerClass { return LayerTypeFragment } + +// NextLayerType implements DecodingLayer. +func (p *Fragment) NextLayerType() LayerType { return LayerTypeZero } + +// DecodeFromBytes implements DecodingLayer. +func (p *Fragment) DecodeFromBytes(data []byte, df DecodeFeedback) error { + *p = Fragment(data) + return nil +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (p *Fragment) SerializeTo(b SerializeBuffer, opts SerializeOptions) error { + bytes, err := b.PrependBytes(len(*p)) + if err != nil { + return err + } + copy(bytes, *p) + return nil +} + +// decodeFragment decodes data by returning it all in a Fragment layer. +func decodeFragment(data []byte, p PacketBuilder) error { + payload := &Fragment{} + if err := payload.DecodeFromBytes(data, p); err != nil { + return nil + } + p.AddLayer(payload) + p.SetApplicationLayer(payload) + return nil +} + +// These layers correspond to Internet Protocol Suite (TCP/IP) layers, and their +// corresponding OSI layers, as best as possible. + +// LinkLayer is the packet layer corresponding to TCP/IP layer 1 (OSI layer 2) +type LinkLayer interface { + Layer + LinkFlow() Flow +} + +// NetworkLayer is the packet layer corresponding to TCP/IP layer 2 (OSI +// layer 3) +type NetworkLayer interface { + Layer + NetworkFlow() Flow +} + +// TransportLayer is the packet layer corresponding to the TCP/IP layer 3 (OSI +// layer 4) +type TransportLayer interface { + Layer + TransportFlow() Flow +} + +// ApplicationLayer is the packet layer corresponding to the TCP/IP layer 4 (OSI +// layer 7), also known as the packet payload. +type ApplicationLayer interface { + Layer + Payload() []byte +} + +// ErrorLayer is a packet layer created when decoding of the packet has failed. +// Its payload is all the bytes that we were unable to decode, and the returned +// error details why the decoding failed. +type ErrorLayer interface { + Layer + Error() error +} diff --git a/vendor/github.com/google/gopacket/decode.go b/vendor/github.com/google/gopacket/decode.go new file mode 100644 index 0000000..2633f84 --- /dev/null +++ b/vendor/github.com/google/gopacket/decode.go @@ -0,0 +1,157 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package gopacket + +import ( + "errors" +) + +// DecodeFeedback is used by DecodingLayer layers to provide decoding metadata. +type DecodeFeedback interface { + // SetTruncated should be called if during decoding you notice that a packet + // is shorter than internal layer variables (HeaderLength, or the like) say it + // should be. It sets packet.Metadata().Truncated. + SetTruncated() +} + +type nilDecodeFeedback struct{} + +func (nilDecodeFeedback) SetTruncated() {} + +// NilDecodeFeedback implements DecodeFeedback by doing nothing. +var NilDecodeFeedback DecodeFeedback = nilDecodeFeedback{} + +// PacketBuilder is used by layer decoders to store the layers they've decoded, +// and to defer future decoding via NextDecoder. +// Typically, the pattern for use is: +// func (m *myDecoder) Decode(data []byte, p PacketBuilder) error { +// if myLayer, err := myDecodingLogic(data); err != nil { +// return err +// } else { +// p.AddLayer(myLayer) +// } +// // maybe do this, if myLayer is a LinkLayer +// p.SetLinkLayer(myLayer) +// return p.NextDecoder(nextDecoder) +// } +type PacketBuilder interface { + DecodeFeedback + // AddLayer should be called by a decoder immediately upon successful + // decoding of a layer. + AddLayer(l Layer) + // The following functions set the various specific layers in the final + // packet. Note that if many layers call SetX, the first call is kept and all + // other calls are ignored. + SetLinkLayer(LinkLayer) + SetNetworkLayer(NetworkLayer) + SetTransportLayer(TransportLayer) + SetApplicationLayer(ApplicationLayer) + SetErrorLayer(ErrorLayer) + // NextDecoder should be called by a decoder when they're done decoding a + // packet layer but not done with decoding the entire packet. The next + // decoder will be called to decode the last AddLayer's LayerPayload. + // Because of this, NextDecoder must only be called once all other + // PacketBuilder calls have been made. Set*Layer and AddLayer calls after + // NextDecoder calls will behave incorrectly. + NextDecoder(next Decoder) error + // DumpPacketData is used solely for decoding. If you come across an error + // you need to diagnose while processing a packet, call this and your packet's + // data will be dumped to stderr so you can create a test. This should never + // be called from a production decoder. + DumpPacketData() + // DecodeOptions returns the decode options + DecodeOptions() *DecodeOptions +} + +// Decoder is an interface for logic to decode a packet layer. Users may +// implement a Decoder to handle their own strange packet types, or may use one +// of the many decoders available in the 'layers' subpackage to decode things +// for them. +type Decoder interface { + // Decode decodes the bytes of a packet, sending decoded values and other + // information to PacketBuilder, and returning an error if unsuccessful. See + // the PacketBuilder documentation for more details. + Decode([]byte, PacketBuilder) error +} + +// DecodeFunc wraps a function to make it a Decoder. +type DecodeFunc func([]byte, PacketBuilder) error + +// Decode implements Decoder by calling itself. +func (d DecodeFunc) Decode(data []byte, p PacketBuilder) error { + // function, call thyself. + return d(data, p) +} + +// DecodePayload is a Decoder that returns a Payload layer containing all +// remaining bytes. +var DecodePayload Decoder = DecodeFunc(decodePayload) + +// DecodeUnknown is a Decoder that returns an Unknown layer containing all +// remaining bytes, useful if you run up against a layer that you're unable to +// decode yet. This layer is considered an ErrorLayer. +var DecodeUnknown Decoder = DecodeFunc(decodeUnknown) + +// DecodeFragment is a Decoder that returns a Fragment layer containing all +// remaining bytes. +var DecodeFragment Decoder = DecodeFunc(decodeFragment) + +// LayerTypeZero is an invalid layer type, but can be used to determine whether +// layer type has actually been set correctly. +var LayerTypeZero = RegisterLayerType(0, LayerTypeMetadata{Name: "Unknown", Decoder: DecodeUnknown}) + +// LayerTypeDecodeFailure is the layer type for the default error layer. +var LayerTypeDecodeFailure = RegisterLayerType(1, LayerTypeMetadata{Name: "DecodeFailure", Decoder: DecodeUnknown}) + +// LayerTypePayload is the layer type for a payload that we don't try to decode +// but treat as a success, IE: an application-level payload. +var LayerTypePayload = RegisterLayerType(2, LayerTypeMetadata{Name: "Payload", Decoder: DecodePayload}) + +// LayerTypeFragment is the layer type for a fragment of a layer transported +// by an underlying layer that supports fragmentation. +var LayerTypeFragment = RegisterLayerType(3, LayerTypeMetadata{Name: "Fragment", Decoder: DecodeFragment}) + +// DecodeFailure is a packet layer created if decoding of the packet data failed +// for some reason. It implements ErrorLayer. LayerContents will be the entire +// set of bytes that failed to parse, and Error will return the reason parsing +// failed. +type DecodeFailure struct { + data []byte + err error + stack []byte +} + +// Error returns the error encountered during decoding. +func (d *DecodeFailure) Error() error { return d.err } + +// LayerContents implements Layer. +func (d *DecodeFailure) LayerContents() []byte { return d.data } + +// LayerPayload implements Layer. +func (d *DecodeFailure) LayerPayload() []byte { return nil } + +// String implements fmt.Stringer. +func (d *DecodeFailure) String() string { + return "Packet decoding error: " + d.Error().Error() +} + +// Dump implements Dumper. +func (d *DecodeFailure) Dump() (s string) { + if d.stack != nil { + s = string(d.stack) + } + return +} + +// LayerType returns LayerTypeDecodeFailure +func (d *DecodeFailure) LayerType() LayerType { return LayerTypeDecodeFailure } + +// decodeUnknown "decodes" unsupported data types by returning an error. +// This decoder will thus always return a DecodeFailure layer. +func decodeUnknown(data []byte, p PacketBuilder) error { + return errors.New("Layer type not currently supported") +} diff --git a/vendor/github.com/google/gopacket/doc.go b/vendor/github.com/google/gopacket/doc.go new file mode 100644 index 0000000..d49656e --- /dev/null +++ b/vendor/github.com/google/gopacket/doc.go @@ -0,0 +1,365 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +/* +Package gopacket provides packet decoding for the Go language. + +gopacket contains many sub-packages with additional functionality you may find +useful, including: + + * layers: You'll probably use this every time. This contains of the logic + built into gopacket for decoding packet protocols. Note that all example + code below assumes that you have imported both gopacket and + gopacket/layers. + * pcap: C bindings to use libpcap to read packets off the wire. + * pfring: C bindings to use PF_RING to read packets off the wire. + * afpacket: C bindings for Linux's AF_PACKET to read packets off the wire. + * tcpassembly: TCP stream reassembly + +Also, if you're looking to dive right into code, see the examples subdirectory +for numerous simple binaries built using gopacket libraries. + +Basic Usage + +gopacket takes in packet data as a []byte and decodes it into a packet with +a non-zero number of "layers". Each layer corresponds to a protocol +within the bytes. Once a packet has been decoded, the layers of the packet +can be requested from the packet. + + // Decode a packet + packet := gopacket.NewPacket(myPacketData, layers.LayerTypeEthernet, gopacket.Default) + // Get the TCP layer from this packet + if tcpLayer := packet.Layer(layers.LayerTypeTCP); tcpLayer != nil { + fmt.Println("This is a TCP packet!") + // Get actual TCP data from this layer + tcp, _ := tcpLayer.(*layers.TCP) + fmt.Printf("From src port %d to dst port %d\n", tcp.SrcPort, tcp.DstPort) + } + // Iterate over all layers, printing out each layer type + for _, layer := range packet.Layers() { + fmt.Println("PACKET LAYER:", layer.LayerType()) + } + +Packets can be decoded from a number of starting points. Many of our base +types implement Decoder, which allow us to decode packets for which +we don't have full data. + + // Decode an ethernet packet + ethP := gopacket.NewPacket(p1, layers.LayerTypeEthernet, gopacket.Default) + // Decode an IPv6 header and everything it contains + ipP := gopacket.NewPacket(p2, layers.LayerTypeIPv6, gopacket.Default) + // Decode a TCP header and its payload + tcpP := gopacket.NewPacket(p3, layers.LayerTypeTCP, gopacket.Default) + + +Reading Packets From A Source + +Most of the time, you won't just have a []byte of packet data lying around. +Instead, you'll want to read packets in from somewhere (file, interface, etc) +and process them. To do that, you'll want to build a PacketSource. + +First, you'll need to construct an object that implements the PacketDataSource +interface. There are implementations of this interface bundled with gopacket +in the gopacket/pcap and gopacket/pfring subpackages... see their documentation +for more information on their usage. Once you have a PacketDataSource, you can +pass it into NewPacketSource, along with a Decoder of your choice, to create +a PacketSource. + +Once you have a PacketSource, you can read packets from it in multiple ways. +See the docs for PacketSource for more details. The easiest method is the +Packets function, which returns a channel, then asynchronously writes new +packets into that channel, closing the channel if the packetSource hits an +end-of-file. + + packetSource := ... // construct using pcap or pfring + for packet := range packetSource.Packets() { + handlePacket(packet) // do something with each packet + } + +You can change the decoding options of the packetSource by setting fields in +packetSource.DecodeOptions... see the following sections for more details. + + +Lazy Decoding + +gopacket optionally decodes packet data lazily, meaning it +only decodes a packet layer when it needs to handle a function call. + + // Create a packet, but don't actually decode anything yet + packet := gopacket.NewPacket(myPacketData, layers.LayerTypeEthernet, gopacket.Lazy) + // Now, decode the packet up to the first IPv4 layer found but no further. + // If no IPv4 layer was found, the whole packet will be decoded looking for + // it. + ip4 := packet.Layer(layers.LayerTypeIPv4) + // Decode all layers and return them. The layers up to the first IPv4 layer + // are already decoded, and will not require decoding a second time. + layers := packet.Layers() + +Lazily-decoded packets are not concurrency-safe. Since layers have not all been +decoded, each call to Layer() or Layers() has the potential to mutate the packet +in order to decode the next layer. If a packet is used +in multiple goroutines concurrently, don't use gopacket.Lazy. Then gopacket +will decode the packet fully, and all future function calls won't mutate the +object. + + +NoCopy Decoding + +By default, gopacket will copy the slice passed to NewPacket and store the +copy within the packet, so future mutations to the bytes underlying the slice +don't affect the packet and its layers. If you can guarantee that the +underlying slice bytes won't be changed, you can use NoCopy to tell +gopacket.NewPacket, and it'll use the passed-in slice itself. + + // This channel returns new byte slices, each of which points to a new + // memory location that's guaranteed immutable for the duration of the + // packet. + for data := range myByteSliceChannel { + p := gopacket.NewPacket(data, layers.LayerTypeEthernet, gopacket.NoCopy) + doSomethingWithPacket(p) + } + +The fastest method of decoding is to use both Lazy and NoCopy, but note from +the many caveats above that for some implementations either or both may be +dangerous. + + +Pointers To Known Layers + +During decoding, certain layers are stored in the packet as well-known +layer types. For example, IPv4 and IPv6 are both considered NetworkLayer +layers, while TCP and UDP are both TransportLayer layers. We support 4 +layers, corresponding to the 4 layers of the TCP/IP layering scheme (roughly +anagalous to layers 2, 3, 4, and 7 of the OSI model). To access these, +you can use the packet.LinkLayer, packet.NetworkLayer, +packet.TransportLayer, and packet.ApplicationLayer functions. Each of +these functions returns a corresponding interface +(gopacket.{Link,Network,Transport,Application}Layer). The first three +provide methods for getting src/dst addresses for that particular layer, +while the final layer provides a Payload function to get payload data. +This is helpful, for example, to get payloads for all packets regardless +of their underlying data type: + + // Get packets from some source + for packet := range someSource { + if app := packet.ApplicationLayer(); app != nil { + if strings.Contains(string(app.Payload()), "magic string") { + fmt.Println("Found magic string in a packet!") + } + } + } + +A particularly useful layer is ErrorLayer, which is set whenever there's +an error parsing part of the packet. + + packet := gopacket.NewPacket(myPacketData, layers.LayerTypeEthernet, gopacket.Default) + if err := packet.ErrorLayer(); err != nil { + fmt.Println("Error decoding some part of the packet:", err) + } + +Note that we don't return an error from NewPacket because we may have decoded +a number of layers successfully before running into our erroneous layer. You +may still be able to get your Ethernet and IPv4 layers correctly, even if +your TCP layer is malformed. + + +Flow And Endpoint + +gopacket has two useful objects, Flow and Endpoint, for communicating in a protocol +independent manner the fact that a packet is coming from A and going to B. +The general layer types LinkLayer, NetworkLayer, and TransportLayer all provide +methods for extracting their flow information, without worrying about the type +of the underlying Layer. + +A Flow is a simple object made up of a set of two Endpoints, one source and one +destination. It details the sender and receiver of the Layer of the Packet. + +An Endpoint is a hashable representation of a source or destination. For +example, for LayerTypeIPv4, an Endpoint contains the IP address bytes for a v4 +IP packet. A Flow can be broken into Endpoints, and Endpoints can be combined +into Flows: + + packet := gopacket.NewPacket(myPacketData, layers.LayerTypeEthernet, gopacket.Lazy) + netFlow := packet.NetworkLayer().NetworkFlow() + src, dst := netFlow.Endpoints() + reverseFlow := gopacket.NewFlow(dst, src) + +Both Endpoint and Flow objects can be used as map keys, and the equality +operator can compare them, so you can easily group together all packets +based on endpoint criteria: + + flows := map[gopacket.Endpoint]chan gopacket.Packet + packet := gopacket.NewPacket(myPacketData, layers.LayerTypeEthernet, gopacket.Lazy) + // Send all TCP packets to channels based on their destination port. + if tcp := packet.Layer(layers.LayerTypeTCP); tcp != nil { + flows[tcp.TransportFlow().Dst()] <- packet + } + // Look for all packets with the same source and destination network address + if net := packet.NetworkLayer(); net != nil { + src, dst := net.NetworkFlow().Endpoints() + if src == dst { + fmt.Println("Fishy packet has same network source and dst: %s", src) + } + } + // Find all packets coming from UDP port 1000 to UDP port 500 + interestingFlow := gopacket.NewFlow(layers.NewUDPPortEndpoint(1000), layers.NewUDPPortEndpoint(500)) + if t := packet.NetworkLayer(); t != nil && t.TransportFlow() == interestingFlow { + fmt.Println("Found that UDP flow I was looking for!") + } + +For load-balancing purposes, both Flow and Endpoint have FastHash() functions, +which provide quick, non-cryptographic hashes of their contents. Of particular +importance is the fact that Flow FastHash() is symmetric: A->B will have the same +hash as B->A. An example usage could be: + + channels := [8]chan gopacket.Packet + for i := 0; i < 8; i++ { + channels[i] = make(chan gopacket.Packet) + go packetHandler(channels[i]) + } + for packet := range getPackets() { + if net := packet.NetworkLayer(); net != nil { + channels[int(net.NetworkFlow().FastHash()) & 0x7] <- packet + } + } + +This allows us to split up a packet stream while still making sure that each +stream sees all packets for a flow (and its bidirectional opposite). + + +Implementing Your Own Decoder + +If your network has some strange encapsulation, you can implement your own +decoder. In this example, we handle Ethernet packets which are encapsulated +in a 4-byte header. + + // Create a layer type, should be unique and high, so it doesn't conflict, + // giving it a name and a decoder to use. + var MyLayerType = gopacket.RegisterLayerType(12345, "MyLayerType", gopacket.DecodeFunc(decodeMyLayer)) + + // Implement my layer + type MyLayer struct { + StrangeHeader []byte + payload []byte + } + func (m MyLayer) LayerType() LayerType { return MyLayerType } + func (m MyLayer) LayerContents() []byte { return m.StrangeHeader } + func (m MyLayer) LayerPayload() []byte { return m.payload } + + // Now implement a decoder... this one strips off the first 4 bytes of the + // packet. + func decodeMyLayer(data []byte, p gopacket.PacketBuilder) error { + // Create my layer + p.AddLayer(&MyLayer{data[:4], data[4:]}) + // Determine how to handle the rest of the packet + return p.NextDecoder(layers.LayerTypeEthernet) + } + + // Finally, decode your packets: + p := gopacket.NewPacket(data, MyLayerType, gopacket.Lazy) + +See the docs for Decoder and PacketBuilder for more details on how coding +decoders works, or look at RegisterLayerType and RegisterEndpointType to see how +to add layer/endpoint types to gopacket. + + +Fast Decoding With DecodingLayerParser + +TLDR: DecodingLayerParser takes about 10% of the time as NewPacket to decode +packet data, but only for known packet stacks. + +Basic decoding using gopacket.NewPacket or PacketSource.Packets is somewhat slow +due to its need to allocate a new packet and every respective layer. It's very +versatile and can handle all known layer types, but sometimes you really only +care about a specific set of layers regardless, so that versatility is wasted. + +DecodingLayerParser avoids memory allocation altogether by decoding packet +layers directly into preallocated objects, which you can then reference to get +the packet's information. A quick example: + + func main() { + var eth layers.Ethernet + var ip4 layers.IPv4 + var ip6 layers.IPv6 + var tcp layers.TCP + parser := gopacket.NewDecodingLayerParser(layers.LayerTypeEthernet, ð, &ip4, &ip6, &tcp) + decoded := []gopacket.LayerType{} + for packetData := range somehowGetPacketData() { + err := parser.DecodeLayers(packetData, &decoded) + for _, layerType := range decoded { + switch layerType { + case layers.LayerTypeIPv6: + fmt.Println(" IP6 ", ip6.SrcIP, ip6.DstIP) + case layers.LayerTypeIPv4: + fmt.Println(" IP4 ", ip4.SrcIP, ip4.DstIP) + } + } + } + } + +The important thing to note here is that the parser is modifying the passed in +layers (eth, ip4, ip6, tcp) instead of allocating new ones, thus greatly +speeding up the decoding process. It's even branching based on layer type... +it'll handle an (eth, ip4, tcp) or (eth, ip6, tcp) stack. However, it won't +handle any other type... since no other decoders were passed in, an (eth, ip4, +udp) stack will stop decoding after ip4, and only pass back [LayerTypeEthernet, +LayerTypeIPv4] through the 'decoded' slice (along with an error saying it can't +decode a UDP packet). + +Unfortunately, not all layers can be used by DecodingLayerParser... only those +implementing the DecodingLayer interface are usable. Also, it's possible to +create DecodingLayers that are not themselves Layers... see +layers.IPv6ExtensionSkipper for an example of this. + + +Creating Packet Data + +As well as offering the ability to decode packet data, gopacket will allow you +to create packets from scratch, as well. A number of gopacket layers implement +the SerializableLayer interface; these layers can be serialized to a []byte in +the following manner: + + ip := &layers.IPv4{ + SrcIP: net.IP{1, 2, 3, 4}, + DstIP: net.IP{5, 6, 7, 8}, + // etc... + } + buf := gopacket.NewSerializeBuffer() + opts := gopacket.SerializeOptions{} // See SerializeOptions for more details. + err := ip.SerializeTo(&buf, opts) + if err != nil { panic(err) } + fmt.Println(buf.Bytes()) // prints out a byte slice containing the serialized IPv4 layer. + +SerializeTo PREPENDS the given layer onto the SerializeBuffer, and they treat +the current buffer's Bytes() slice as the payload of the serializing layer. +Therefore, you can serialize an entire packet by serializing a set of layers in +reverse order (Payload, then TCP, then IP, then Ethernet, for example). The +SerializeBuffer's SerializeLayers function is a helper that does exactly that. + +To generate a (empty and useless, because no fields are set) +Ethernet(IPv4(TCP(Payload))) packet, for example, you can run: + + buf := gopacket.NewSerializeBuffer() + opts := gopacket.SerializeOptions{} + gopacket.SerializeLayers(buf, opts, + &layers.Ethernet{}, + &layers.IPv4{}, + &layers.TCP{}, + gopacket.Payload([]byte{1, 2, 3, 4})) + packetData := buf.Bytes() + +A Final Note + +If you use gopacket, you'll almost definitely want to make sure gopacket/layers +is imported, since when imported it sets all the LayerType variables and fills +in a lot of interesting variables/maps (DecodersByLayerName, etc). Therefore, +it's recommended that even if you don't use any layers functions directly, you still import with: + + import ( + _ "github.com/google/gopacket/layers" + ) +*/ +package gopacket diff --git a/vendor/github.com/google/gopacket/flows.go b/vendor/github.com/google/gopacket/flows.go new file mode 100644 index 0000000..7203ead --- /dev/null +++ b/vendor/github.com/google/gopacket/flows.go @@ -0,0 +1,236 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package gopacket + +import ( + "bytes" + "fmt" + "strconv" +) + +// MaxEndpointSize determines the maximum size in bytes of an endpoint address. +// +// Endpoints/Flows have a problem: They need to be hashable. Therefore, they +// can't use a byte slice. The two obvious choices are to use a string or a +// byte array. Strings work great, but string creation requires memory +// allocation, which can be slow. Arrays work great, but have a fixed size. We +// originally used the former, now we've switched to the latter. Use of a fixed +// byte-array doubles the speed of constructing a flow (due to not needing to +// allocate). This is a huge increase... too much for us to pass up. +// +// The end result of this, though, is that an endpoint/flow can't be created +// using more than MaxEndpointSize bytes per address. +const MaxEndpointSize = 16 + +// Endpoint is the set of bytes used to address packets at various layers. +// See LinkLayer, NetworkLayer, and TransportLayer specifications. +// Endpoints are usable as map keys. +type Endpoint struct { + typ EndpointType + len int + raw [MaxEndpointSize]byte +} + +// EndpointType returns the endpoint type associated with this endpoint. +func (a Endpoint) EndpointType() EndpointType { return a.typ } + +// Raw returns the raw bytes of this endpoint. These aren't human-readable +// most of the time, but they are faster than calling String. +func (a Endpoint) Raw() []byte { return a.raw[:a.len] } + +// LessThan provides a stable ordering for all endpoints. It sorts first based +// on the EndpointType of an endpoint, then based on the raw bytes of that +// endpoint. +// +// For some endpoints, the actual comparison may not make sense, however this +// ordering does provide useful information for most Endpoint types. +// Ordering is based first on endpoint type, then on raw endpoint bytes. +// Endpoint bytes are sorted lexigraphically. +func (a Endpoint) LessThan(b Endpoint) bool { + return a.typ < b.typ || (a.typ == b.typ && bytes.Compare(a.raw[:a.len], b.raw[:b.len]) < 0) +} + +// fnvHash is used by our FastHash functions, and implements the FNV hash +// created by Glenn Fowler, Landon Curt Noll, and Phong Vo. +// See http://isthe.com/chongo/tech/comp/fnv/. +func fnvHash(s []byte) (h uint64) { + h = fnvBasis + for i := 0; i < len(s); i++ { + h ^= uint64(s[i]) + h *= fnvPrime + } + return +} + +const fnvBasis = 14695981039346656037 +const fnvPrime = 1099511628211 + +// FastHash provides a quick hashing function for an endpoint, useful if you'd +// like to split up endpoints by modulos or other load-balancing techniques. +// It uses a variant of Fowler-Noll-Vo hashing. +// +// The output of FastHash is not guaranteed to remain the same through future +// code revisions, so should not be used to key values in persistent storage. +func (a Endpoint) FastHash() (h uint64) { + h = fnvHash(a.raw[:a.len]) + h ^= uint64(a.typ) + h *= fnvPrime + return +} + +// NewEndpoint creates a new Endpoint object. +// +// The size of raw must be less than MaxEndpointSize, otherwise this function +// will panic. +func NewEndpoint(typ EndpointType, raw []byte) (e Endpoint) { + e.len = len(raw) + if e.len > MaxEndpointSize { + panic("raw byte length greater than MaxEndpointSize") + } + e.typ = typ + copy(e.raw[:], raw) + return +} + +// EndpointTypeMetadata is used to register a new endpoint type. +type EndpointTypeMetadata struct { + // Name is the string returned by an EndpointType's String function. + Name string + // Formatter is called from an Endpoint's String function to format the raw + // bytes in an Endpoint into a human-readable string. + Formatter func([]byte) string +} + +// EndpointType is the type of a gopacket Endpoint. This type determines how +// the bytes stored in the endpoint should be interpreted. +type EndpointType int64 + +var endpointTypes = map[EndpointType]EndpointTypeMetadata{} + +// RegisterEndpointType creates a new EndpointType and registers it globally. +// It MUST be passed a unique number, or it will panic. Numbers 0-999 are +// reserved for gopacket's use. +func RegisterEndpointType(num int, meta EndpointTypeMetadata) EndpointType { + t := EndpointType(num) + if _, ok := endpointTypes[t]; ok { + panic("Endpoint type number already in use") + } + endpointTypes[t] = meta + return t +} + +func (e EndpointType) String() string { + if t, ok := endpointTypes[e]; ok { + return t.Name + } + return strconv.Itoa(int(e)) +} + +func (a Endpoint) String() string { + if t, ok := endpointTypes[a.typ]; ok && t.Formatter != nil { + return t.Formatter(a.raw[:a.len]) + } + return fmt.Sprintf("%v:%v", a.typ, a.raw) +} + +// Flow represents the direction of traffic for a packet layer, as a source and destination Endpoint. +// Flows are usable as map keys. +type Flow struct { + typ EndpointType + slen, dlen int + src, dst [MaxEndpointSize]byte +} + +// FlowFromEndpoints creates a new flow by pasting together two endpoints. +// The endpoints must have the same EndpointType, or this function will return +// an error. +func FlowFromEndpoints(src, dst Endpoint) (_ Flow, err error) { + if src.typ != dst.typ { + err = fmt.Errorf("Mismatched endpoint types: %v->%v", src.typ, dst.typ) + return + } + return Flow{src.typ, src.len, dst.len, src.raw, dst.raw}, nil +} + +// FastHash provides a quick hashing function for a flow, useful if you'd +// like to split up flows by modulos or other load-balancing techniques. +// It uses a variant of Fowler-Noll-Vo hashing, and is guaranteed to collide +// with its reverse flow. IE: the flow A->B will have the same hash as the flow +// B->A. +// +// The output of FastHash is not guaranteed to remain the same through future +// code revisions, so should not be used to key values in persistent storage. +func (f Flow) FastHash() (h uint64) { + // This combination must be commutative. We don't use ^, since that would + // give the same hash for all A->A flows. + h = fnvHash(f.src[:f.slen]) + fnvHash(f.dst[:f.dlen]) + h ^= uint64(f.typ) + h *= fnvPrime + return +} + +// String returns a human-readable representation of this flow, in the form +// "Src->Dst" +func (f Flow) String() string { + s, d := f.Endpoints() + return fmt.Sprintf("%v->%v", s, d) +} + +// EndpointType returns the EndpointType for this Flow. +func (f Flow) EndpointType() EndpointType { + return f.typ +} + +// Endpoints returns the two Endpoints for this flow. +func (f Flow) Endpoints() (src, dst Endpoint) { + return Endpoint{f.typ, f.slen, f.src}, Endpoint{f.typ, f.dlen, f.dst} +} + +// Src returns the source Endpoint for this flow. +func (f Flow) Src() (src Endpoint) { + src, _ = f.Endpoints() + return +} + +// Dst returns the destination Endpoint for this flow. +func (f Flow) Dst() (dst Endpoint) { + _, dst = f.Endpoints() + return +} + +// Reverse returns a new flow with endpoints reversed. +func (f Flow) Reverse() Flow { + return Flow{f.typ, f.dlen, f.slen, f.dst, f.src} +} + +// NewFlow creates a new flow. +// +// src and dst must have length <= MaxEndpointSize, otherwise NewFlow will +// panic. +func NewFlow(t EndpointType, src, dst []byte) (f Flow) { + f.slen = len(src) + f.dlen = len(dst) + if f.slen > MaxEndpointSize || f.dlen > MaxEndpointSize { + panic("flow raw byte length greater than MaxEndpointSize") + } + f.typ = t + copy(f.src[:], src) + copy(f.dst[:], dst) + return +} + +// EndpointInvalid is an endpoint type used for invalid endpoints, IE endpoints +// that are specified incorrectly during creation. +var EndpointInvalid = RegisterEndpointType(0, EndpointTypeMetadata{Name: "invalid", Formatter: func(b []byte) string { + return fmt.Sprintf("%v", b) +}}) + +// InvalidEndpoint is a singleton Endpoint of type EndpointInvalid. +var InvalidEndpoint = NewEndpoint(EndpointInvalid, nil) + +// InvalidFlow is a singleton Flow of type EndpointInvalid. +var InvalidFlow = NewFlow(EndpointInvalid, nil, nil) diff --git a/vendor/github.com/google/gopacket/gc b/vendor/github.com/google/gopacket/gc new file mode 100755 index 0000000..57bcdee --- /dev/null +++ b/vendor/github.com/google/gopacket/gc @@ -0,0 +1,278 @@ +#!/bin/bash +# Copyright 2012 Google, Inc. All rights reserved. + +# This script provides a simple way to run benchmarks against previous code and +# keep a log of how benchmarks change over time. When used with the --benchmark +# flag, it runs benchmarks from the current code and from the last commit run +# with --benchmark, then stores the results in the git commit description. We +# rerun the old benchmarks along with the new ones, since there's no guarantee +# that git commits will happen on the same machine, so machine differences could +# cause wildly inaccurate results. +# +# If you're making changes to 'gopacket' which could cause performance changes, +# you may be requested to use this commit script to make sure your changes don't +# have large detrimental effects (or to show off how awesome your performance +# improvements are). +# +# If not run with the --benchmark flag, this script is still very useful... it +# makes sure all the correct go formatting, building, and testing work as +# expected. + +function Usage { + cat < + +--benchmark: Run benchmark comparisons against last benchmark'd commit +--root: Run tests that require root priviledges +--gen: Generate code for MACs/ports by pulling down external data + +Note, some 'git commit' flags are necessary, if all else fails, pass in -a +EOF + exit 1 +} + +BENCH="" +GEN="" +ROOT="" +while [ ! -z "$1" ]; do + case "$1" in + "--benchmark") + BENCH="$2" + shift + shift + ;; + "--gen") + GEN="yes" + shift + ;; + "--root") + ROOT="yes" + shift + ;; + "--help") + Usage + ;; + "-h") + Usage + ;; + "help") + Usage + ;; + *) + break + ;; + esac +done + +function Root { + if [ ! -z "$ROOT" ]; then + local exec="$1" + # Some folks (like me) keep source code in places inaccessible by root (like + # NFS), so to make sure things run smoothly we copy them to a /tmp location. + local tmpfile="$(mktemp -t gopacket_XXXXXXXX)" + echo "Running root test executable $exec as $tmpfile" + cp "$exec" "$tmpfile" + chmod a+x "$tmpfile" + shift + sudo "$tmpfile" "$@" + fi +} + +if [ "$#" -eq "0" ]; then + Usage +fi + +cd $(dirname $0) + +# Check for copyright notices. +for filename in $(find ./ -type f -name '*.go'); do + if ! head -n 1 "$filename" | grep -q Copyright; then + echo "File '$filename' may not have copyright notice" + exit 1 + fi +done + +set -e +set -x + +if [ ! -z "$ROOT" ]; then + echo "Running SUDO to get root priviledges for root tests" + sudo echo "have root" +fi + +if [ ! -z "$GEN" ]; then + pushd macs + go run gen.go | gofmt > valid_mac_prefixes.go + popd + pushd layers + go run gen.go | gofmt > iana_ports.go + popd +fi + +# Make sure everything is formatted, compiles, and tests pass. +go fmt ./... +go test -i ./... 2>/dev/null >/dev/null || true +go test +go build +pushd examples/bytediff +go build +popd +if [ -f /usr/include/pcap.h ]; then + pushd pcap + go test ./... + go build ./... + go build pcap_tester.go + Root pcap_tester --mode=basic + Root pcap_tester --mode=filtered + Root pcap_tester --mode=timestamp || echo "You might not support timestamp sources" + popd + pushd examples/pcapdump + go build + popd + pushd examples/arpscan + go build + popd + pushd examples/bidirectional + go build + popd + pushd examples/synscan + go build + popd + pushd examples/httpassembly + go build + popd + pushd examples/statsassembly + go build + popd +fi +pushd macs +go test ./... +gofmt -w gen.go +go build gen.go +popd +pushd tcpassembly +go test ./... +popd +pushd reassembly +go test ./... +popd +pushd layers +gofmt -w gen.go +go build gen.go +go test ./... +popd +pushd pcapgo +go test ./... +go build ./... +popd +if [ -f /usr/include/linux/if_packet.h ]; then + if grep -q TPACKET_V3 /usr/include/linux/if_packet.h; then + pushd afpacket + go build ./... + go test ./... + popd + fi +fi +if [ -f /usr/include/pfring.h ]; then + pushd pfring + go test ./... + go build ./... + popd + pushd examples/pfdump + go build + popd +fi + +for travis_script in `ls .travis.*.sh`; do + ./$travis_script +done + +# Run our initial commit +git commit "$@" + +if [ -z "$BENCH" ]; then + set +x + echo "We're not benchmarking and we've committed... we're done!" + exit +fi + +### If we get here, we want to run benchmarks from current commit, and compare +### then to benchmarks from the last --benchmark commit. + +# Get our current branch. +BRANCH="$(git branch | grep '^*' | awk '{print $2}')" + +# File we're going to build our commit description in. +COMMIT_FILE="$(mktemp /tmp/tmp.XXXXXXXX)" + +# Add the word "BENCH" to the start of the git commit. +echo -n "BENCH " > $COMMIT_FILE + +# Get the current description... there must be an easier way. +git log -n 1 | grep '^ ' | sed 's/^ //' >> $COMMIT_FILE + +# Get the commit sha for the last benchmark commit +PREV=$(git log -n 1 --grep='BENCHMARK_MARKER_DO_NOT_CHANGE' | head -n 1 | awk '{print $2}') + +## Run current benchmarks + +cat >> $COMMIT_FILE <&1 | tee -a $COMMIT_FILE +pushd layers +go test --test.bench="$BENCH" 2>&1 | tee -a $COMMIT_FILE +popd +cat >> $COMMIT_FILE <&1 | tee -a $COMMIT_FILE +fi + + + +## Reset to last benchmark commit, run benchmarks + +git checkout $PREV + +cat >> $COMMIT_FILE <&1 | tee -a $COMMIT_FILE +pushd layers +go test --test.bench="$BENCH" 2>&1 | tee -a $COMMIT_FILE +popd +cat >> $COMMIT_FILE <&1 | tee -a $COMMIT_FILE +fi + + + +## Reset back to the most recent commit, edit the commit message by appending +## benchmark results. +git checkout $BRANCH +git commit --amend -F $COMMIT_FILE diff --git a/vendor/github.com/google/gopacket/layerclass.go b/vendor/github.com/google/gopacket/layerclass.go new file mode 100644 index 0000000..775cd09 --- /dev/null +++ b/vendor/github.com/google/gopacket/layerclass.go @@ -0,0 +1,107 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package gopacket + +// LayerClass is a set of LayerTypes, used for grabbing one of a number of +// different types from a packet. +type LayerClass interface { + // Contains returns true if the given layer type should be considered part + // of this layer class. + Contains(LayerType) bool + // LayerTypes returns the set of all layer types in this layer class. + // Note that this may not be a fast operation on all LayerClass + // implementations. + LayerTypes() []LayerType +} + +// Contains implements LayerClass. +func (l LayerType) Contains(a LayerType) bool { + return l == a +} + +// LayerTypes implements LayerClass. +func (l LayerType) LayerTypes() []LayerType { + return []LayerType{l} +} + +// LayerClassSlice implements a LayerClass with a slice. +type LayerClassSlice []bool + +// Contains returns true if the given layer type should be considered part +// of this layer class. +func (s LayerClassSlice) Contains(t LayerType) bool { + return int(t) < len(s) && s[t] +} + +// LayerTypes returns all layer types in this LayerClassSlice. +// Because of LayerClassSlice's implementation, this could be quite slow. +func (s LayerClassSlice) LayerTypes() (all []LayerType) { + for i := 0; i < len(s); i++ { + if s[i] { + all = append(all, LayerType(i)) + } + } + return +} + +// NewLayerClassSlice creates a new LayerClassSlice by creating a slice of +// size max(types) and setting slice[t] to true for each type t. Note, if +// you implement your own LayerType and give it a high value, this WILL create +// a very large slice. +func NewLayerClassSlice(types []LayerType) LayerClassSlice { + var max LayerType + for _, typ := range types { + if typ > max { + max = typ + } + } + t := make([]bool, int(max+1)) + for _, typ := range types { + t[typ] = true + } + return t +} + +// LayerClassMap implements a LayerClass with a map. +type LayerClassMap map[LayerType]bool + +// Contains returns true if the given layer type should be considered part +// of this layer class. +func (m LayerClassMap) Contains(t LayerType) bool { + return m[t] +} + +// LayerTypes returns all layer types in this LayerClassMap. +func (m LayerClassMap) LayerTypes() (all []LayerType) { + for t := range m { + all = append(all, t) + } + return +} + +// NewLayerClassMap creates a LayerClassMap and sets map[t] to true for each +// type in types. +func NewLayerClassMap(types []LayerType) LayerClassMap { + m := LayerClassMap{} + for _, typ := range types { + m[typ] = true + } + return m +} + +// NewLayerClass creates a LayerClass, attempting to be smart about which type +// it creates based on which types are passed in. +func NewLayerClass(types []LayerType) LayerClass { + for _, typ := range types { + if typ > maxLayerType { + // NewLayerClassSlice could create a very large object, so instead create + // a map. + return NewLayerClassMap(types) + } + } + return NewLayerClassSlice(types) +} diff --git a/vendor/github.com/google/gopacket/layers/.linted b/vendor/github.com/google/gopacket/layers/.linted new file mode 100644 index 0000000..b2b2972 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/.linted @@ -0,0 +1,40 @@ +arp.go +base.go +base_test.go +cdp.go +ctp.go +decode_test.go +dhcp_test.go +dhcpv4.go +dns.go +dns_test.go +doc.go +dot11_test.go +dot1q.go +dot1q_test.go +eapol.go +etherip.go +fddi.go +gen.go +gre.go +gre_test.go +iana_ports.go +icmp6_test.go +igmp_test.go +ip4_test.go +ipsec.go +ipsec_test.go +loopback.go +mpls_test.go +ntp_test.go +ports.go +ppp.go +prism_test.go +radiotap_test.go +sflow_test.go +tcp_test.go +udp_test.go +usb_test.go +vrrp_test.go +vxlan.go +vxlan_test.go diff --git a/vendor/github.com/google/gopacket/layers/arp.go b/vendor/github.com/google/gopacket/layers/arp.go new file mode 100644 index 0000000..49e05ac --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/arp.go @@ -0,0 +1,109 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + + "github.com/google/gopacket" +) + +// Potential values for ARP.Operation. +const ( + ARPRequest = 1 + ARPReply = 2 +) + +// ARP is a ARP packet header. +type ARP struct { + BaseLayer + AddrType LinkType + Protocol EthernetType + HwAddressSize uint8 + ProtAddressSize uint8 + Operation uint16 + SourceHwAddress []byte + SourceProtAddress []byte + DstHwAddress []byte + DstProtAddress []byte +} + +// LayerType returns LayerTypeARP +func (arp *ARP) LayerType() gopacket.LayerType { return LayerTypeARP } + +// DecodeFromBytes decodes the given bytes into this layer. +func (arp *ARP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + arp.AddrType = LinkType(binary.BigEndian.Uint16(data[0:2])) + arp.Protocol = EthernetType(binary.BigEndian.Uint16(data[2:4])) + arp.HwAddressSize = data[4] + arp.ProtAddressSize = data[5] + arp.Operation = binary.BigEndian.Uint16(data[6:8]) + arp.SourceHwAddress = data[8 : 8+arp.HwAddressSize] + arp.SourceProtAddress = data[8+arp.HwAddressSize : 8+arp.HwAddressSize+arp.ProtAddressSize] + arp.DstHwAddress = data[8+arp.HwAddressSize+arp.ProtAddressSize : 8+2*arp.HwAddressSize+arp.ProtAddressSize] + arp.DstProtAddress = data[8+2*arp.HwAddressSize+arp.ProtAddressSize : 8+2*arp.HwAddressSize+2*arp.ProtAddressSize] + + arpLength := 8 + 2*arp.HwAddressSize + 2*arp.ProtAddressSize + arp.Contents = data[:arpLength] + arp.Payload = data[arpLength:] + return nil +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (arp *ARP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + size := 8 + len(arp.SourceHwAddress) + len(arp.SourceProtAddress) + len(arp.DstHwAddress) + len(arp.DstProtAddress) + bytes, err := b.PrependBytes(size) + if err != nil { + return err + } + if opts.FixLengths { + if len(arp.SourceHwAddress) != len(arp.DstHwAddress) { + return errors.New("mismatched hardware address sizes") + } + arp.HwAddressSize = uint8(len(arp.SourceHwAddress)) + if len(arp.SourceProtAddress) != len(arp.DstProtAddress) { + return errors.New("mismatched prot address sizes") + } + arp.ProtAddressSize = uint8(len(arp.SourceProtAddress)) + } + binary.BigEndian.PutUint16(bytes, uint16(arp.AddrType)) + binary.BigEndian.PutUint16(bytes[2:], uint16(arp.Protocol)) + bytes[4] = arp.HwAddressSize + bytes[5] = arp.ProtAddressSize + binary.BigEndian.PutUint16(bytes[6:], arp.Operation) + start := 8 + for _, addr := range [][]byte{ + arp.SourceHwAddress, + arp.SourceProtAddress, + arp.DstHwAddress, + arp.DstProtAddress, + } { + copy(bytes[start:], addr) + start += len(addr) + } + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (arp *ARP) CanDecode() gopacket.LayerClass { + return LayerTypeARP +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (arp *ARP) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +func decodeARP(data []byte, p gopacket.PacketBuilder) error { + + arp := &ARP{} + return decodingLayerDecoder(arp, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/base.go b/vendor/github.com/google/gopacket/layers/base.go new file mode 100644 index 0000000..cd59b46 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/base.go @@ -0,0 +1,52 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "github.com/google/gopacket" +) + +// BaseLayer is a convenience struct which implements the LayerData and +// LayerPayload functions of the Layer interface. +type BaseLayer struct { + // Contents is the set of bytes that make up this layer. IE: for an + // Ethernet packet, this would be the set of bytes making up the + // Ethernet frame. + Contents []byte + // Payload is the set of bytes contained by (but not part of) this + // Layer. Again, to take Ethernet as an example, this would be the + // set of bytes encapsulated by the Ethernet protocol. + Payload []byte +} + +// LayerContents returns the bytes of the packet layer. +func (b *BaseLayer) LayerContents() []byte { return b.Contents } + +// LayerPayload returns the bytes contained within the packet layer. +func (b *BaseLayer) LayerPayload() []byte { return b.Payload } + +type layerDecodingLayer interface { + gopacket.Layer + DecodeFromBytes([]byte, gopacket.DecodeFeedback) error + NextLayerType() gopacket.LayerType +} + +func decodingLayerDecoder(d layerDecodingLayer, data []byte, p gopacket.PacketBuilder) error { + err := d.DecodeFromBytes(data, p) + if err != nil { + return err + } + p.AddLayer(d) + next := d.NextLayerType() + if next == gopacket.LayerTypeZero { + return nil + } + return p.NextDecoder(next) +} + +// hacky way to zero out memory... there must be a better way? +var lotsOfZeros [1024]byte diff --git a/vendor/github.com/google/gopacket/layers/cdp.go b/vendor/github.com/google/gopacket/layers/cdp.go new file mode 100644 index 0000000..d67203e --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/cdp.go @@ -0,0 +1,651 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +// Enum types courtesy of... +// http://search.cpan.org/~mchapman/Net-CDP-0.09/lib/Net/CDP.pm +// https://code.google.com/p/ladvd/ +// http://anonsvn.wireshark.org/viewvc/releases/wireshark-1.8.6/epan/dissectors/packet-cdp.c + +package layers + +import ( + "encoding/binary" + "fmt" + "net" + + "github.com/google/gopacket" +) + +// CDPTLVType is the type of each TLV value in a CiscoDiscovery packet. +type CDPTLVType uint16 + +// CDPTLVType values. +const ( + CDPTLVDevID CDPTLVType = 0x0001 + CDPTLVAddress CDPTLVType = 0x0002 + CDPTLVPortID CDPTLVType = 0x0003 + CDPTLVCapabilities CDPTLVType = 0x0004 + CDPTLVVersion CDPTLVType = 0x0005 + CDPTLVPlatform CDPTLVType = 0x0006 + CDPTLVIPPrefix CDPTLVType = 0x0007 + CDPTLVHello CDPTLVType = 0x0008 + CDPTLVVTPDomain CDPTLVType = 0x0009 + CDPTLVNativeVLAN CDPTLVType = 0x000a + CDPTLVFullDuplex CDPTLVType = 0x000b + CDPTLVVLANReply CDPTLVType = 0x000e + CDPTLVVLANQuery CDPTLVType = 0x000f + CDPTLVPower CDPTLVType = 0x0010 + CDPTLVMTU CDPTLVType = 0x0011 + CDPTLVExtendedTrust CDPTLVType = 0x0012 + CDPTLVUntrustedCOS CDPTLVType = 0x0013 + CDPTLVSysName CDPTLVType = 0x0014 + CDPTLVSysOID CDPTLVType = 0x0015 + CDPTLVMgmtAddresses CDPTLVType = 0x0016 + CDPTLVLocation CDPTLVType = 0x0017 + CDPTLVExternalPortID CDPTLVType = 0x0018 + CDPTLVPowerRequested CDPTLVType = 0x0019 + CDPTLVPowerAvailable CDPTLVType = 0x001a + CDPTLVPortUnidirectional CDPTLVType = 0x001b + CDPTLVEnergyWise CDPTLVType = 0x001d + CDPTLVSparePairPOE CDPTLVType = 0x001f +) + +// CiscoDiscoveryValue is a TLV value inside a CiscoDiscovery packet layer. +type CiscoDiscoveryValue struct { + Type CDPTLVType + Length uint16 + Value []byte +} + +// CiscoDiscovery is a packet layer containing the Cisco Discovery Protocol. +// See http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm#31885 +type CiscoDiscovery struct { + BaseLayer + Version byte + TTL byte + Checksum uint16 + Values []CiscoDiscoveryValue +} + +// CDPCapability is the set of capabilities advertised by a CDP device. +type CDPCapability uint32 + +// CDPCapability values. +const ( + CDPCapMaskRouter CDPCapability = 0x0001 + CDPCapMaskTBBridge CDPCapability = 0x0002 + CDPCapMaskSPBridge CDPCapability = 0x0004 + CDPCapMaskSwitch CDPCapability = 0x0008 + CDPCapMaskHost CDPCapability = 0x0010 + CDPCapMaskIGMPFilter CDPCapability = 0x0020 + CDPCapMaskRepeater CDPCapability = 0x0040 + CDPCapMaskPhone CDPCapability = 0x0080 + CDPCapMaskRemote CDPCapability = 0x0100 +) + +// CDPCapabilities represents the capabilities of a device +type CDPCapabilities struct { + L3Router bool + TBBridge bool + SPBridge bool + L2Switch bool + IsHost bool + IGMPFilter bool + L1Repeater bool + IsPhone bool + RemotelyManaged bool +} + +// CDP Power-over-Ethernet values. +const ( + CDPPoEFourWire byte = 0x01 + CDPPoEPDArch byte = 0x02 + CDPPoEPDRequest byte = 0x04 + CDPPoEPSE byte = 0x08 +) + +// CDPSparePairPoE provides information on PoE. +type CDPSparePairPoE struct { + PSEFourWire bool // Supported / Not supported + PDArchShared bool // Shared / Independent + PDRequestOn bool // On / Off + PSEOn bool // On / Off +} + +// CDPVLANDialogue encapsulates a VLAN Query/Reply +type CDPVLANDialogue struct { + ID uint8 + VLAN uint16 +} + +// CDPPowerDialogue encapsulates a Power Query/Reply +type CDPPowerDialogue struct { + ID uint16 + MgmtID uint16 + Values []uint32 +} + +// CDPLocation provides location information for a CDP device. +type CDPLocation struct { + Type uint8 // Undocumented + Location string +} + +// CDPHello is a Cisco Hello message (undocumented, hence the "Unknown" fields) +type CDPHello struct { + OUI []byte + ProtocolID uint16 + ClusterMaster net.IP + Unknown1 net.IP + Version byte + SubVersion byte + Status byte + Unknown2 byte + ClusterCommander net.HardwareAddr + SwitchMAC net.HardwareAddr + Unknown3 byte + ManagementVLAN uint16 +} + +// CDPEnergyWiseSubtype is used within CDP to define TLV values. +type CDPEnergyWiseSubtype uint32 + +// CDPEnergyWiseSubtype values. +const ( + CDPEnergyWiseRole CDPEnergyWiseSubtype = 0x00000007 + CDPEnergyWiseDomain CDPEnergyWiseSubtype = 0x00000008 + CDPEnergyWiseName CDPEnergyWiseSubtype = 0x00000009 + CDPEnergyWiseReplyTo CDPEnergyWiseSubtype = 0x00000017 +) + +// CDPEnergyWise is used by CDP to monitor and control power usage. +type CDPEnergyWise struct { + EncryptedData []byte + Unknown1 uint32 + SequenceNumber uint32 + ModelNumber string + Unknown2 uint16 + HardwareID string + SerialNum string + Unknown3 []byte + Role string + Domain string + Name string + ReplyUnknown1 []byte + ReplyPort []byte + ReplyAddress []byte + ReplyUnknown2 []byte + ReplyUnknown3 []byte +} + +// CiscoDiscoveryInfo represents the decoded details for a set of CiscoDiscoveryValues +type CiscoDiscoveryInfo struct { + BaseLayer + CDPHello + DeviceID string + Addresses []net.IP + PortID string + Capabilities CDPCapabilities + Version string + Platform string + IPPrefixes []net.IPNet + VTPDomain string + NativeVLAN uint16 + FullDuplex bool + VLANReply CDPVLANDialogue + VLANQuery CDPVLANDialogue + PowerConsumption uint16 + MTU uint32 + ExtendedTrust uint8 + UntrustedCOS uint8 + SysName string + SysOID string + MgmtAddresses []net.IP + Location CDPLocation + PowerRequest CDPPowerDialogue + PowerAvailable CDPPowerDialogue + SparePairPoe CDPSparePairPoE + EnergyWise CDPEnergyWise + Unknown []CiscoDiscoveryValue +} + +// LayerType returns gopacket.LayerTypeCiscoDiscovery. +func (c *CiscoDiscovery) LayerType() gopacket.LayerType { + return LayerTypeCiscoDiscovery +} + +func decodeCiscoDiscovery(data []byte, p gopacket.PacketBuilder) error { + c := &CiscoDiscovery{ + Version: data[0], + TTL: data[1], + Checksum: binary.BigEndian.Uint16(data[2:4]), + } + if c.Version != 1 && c.Version != 2 { + return fmt.Errorf("Invalid CiscoDiscovery version number %d", c.Version) + } + var err error + c.Values, err = decodeCiscoDiscoveryTLVs(data[4:]) + if err != nil { + return err + } + c.Contents = data[0:4] + c.Payload = data[4:] + p.AddLayer(c) + return p.NextDecoder(gopacket.DecodeFunc(decodeCiscoDiscoveryInfo)) +} + +// LayerType returns gopacket.LayerTypeCiscoDiscoveryInfo. +func (c *CiscoDiscoveryInfo) LayerType() gopacket.LayerType { + return LayerTypeCiscoDiscoveryInfo +} + +func decodeCiscoDiscoveryTLVs(data []byte) (values []CiscoDiscoveryValue, err error) { + for len(data) > 0 { + val := CiscoDiscoveryValue{ + Type: CDPTLVType(binary.BigEndian.Uint16(data[:2])), + Length: binary.BigEndian.Uint16(data[2:4]), + } + if val.Length < 4 { + err = fmt.Errorf("Invalid CiscoDiscovery value length %d", val.Length) + break + } + val.Value = data[4:val.Length] + values = append(values, val) + data = data[val.Length:] + } + return +} + +func decodeCiscoDiscoveryInfo(data []byte, p gopacket.PacketBuilder) error { + var err error + info := &CiscoDiscoveryInfo{BaseLayer: BaseLayer{Contents: data}} + p.AddLayer(info) + values, err := decodeCiscoDiscoveryTLVs(data) + if err != nil { // Unlikely, as parent decode will fail, but better safe... + return err + } + for _, val := range values { + switch val.Type { + case CDPTLVDevID: + info.DeviceID = string(val.Value) + case CDPTLVAddress: + if err = checkCDPTLVLen(val, 4); err != nil { + return err + } + info.Addresses, err = decodeAddresses(val.Value) + if err != nil { + return err + } + case CDPTLVPortID: + info.PortID = string(val.Value) + case CDPTLVCapabilities: + if err = checkCDPTLVLen(val, 4); err != nil { + return err + } + val := CDPCapability(binary.BigEndian.Uint32(val.Value[0:4])) + info.Capabilities.L3Router = (val&CDPCapMaskRouter > 0) + info.Capabilities.TBBridge = (val&CDPCapMaskTBBridge > 0) + info.Capabilities.SPBridge = (val&CDPCapMaskSPBridge > 0) + info.Capabilities.L2Switch = (val&CDPCapMaskSwitch > 0) + info.Capabilities.IsHost = (val&CDPCapMaskHost > 0) + info.Capabilities.IGMPFilter = (val&CDPCapMaskIGMPFilter > 0) + info.Capabilities.L1Repeater = (val&CDPCapMaskRepeater > 0) + info.Capabilities.IsPhone = (val&CDPCapMaskPhone > 0) + info.Capabilities.RemotelyManaged = (val&CDPCapMaskRemote > 0) + case CDPTLVVersion: + info.Version = string(val.Value) + case CDPTLVPlatform: + info.Platform = string(val.Value) + case CDPTLVIPPrefix: + v := val.Value + l := len(v) + if l%5 == 0 && l >= 5 { + for len(v) > 0 { + _, ipnet, _ := net.ParseCIDR(fmt.Sprintf("%d.%d.%d.%d/%d", v[0], v[1], v[2], v[3], v[4])) + info.IPPrefixes = append(info.IPPrefixes, *ipnet) + v = v[5:] + } + } else { + return fmt.Errorf("Invalid TLV %v length %d", val.Type, len(val.Value)) + } + case CDPTLVHello: + if err = checkCDPTLVLen(val, 32); err != nil { + return err + } + v := val.Value + info.CDPHello.OUI = v[0:3] + info.CDPHello.ProtocolID = binary.BigEndian.Uint16(v[3:5]) + info.CDPHello.ClusterMaster = v[5:9] + info.CDPHello.Unknown1 = v[9:13] + info.CDPHello.Version = v[13] + info.CDPHello.SubVersion = v[14] + info.CDPHello.Status = v[15] + info.CDPHello.Unknown2 = v[16] + info.CDPHello.ClusterCommander = v[17:23] + info.CDPHello.SwitchMAC = v[23:29] + info.CDPHello.Unknown3 = v[29] + info.CDPHello.ManagementVLAN = binary.BigEndian.Uint16(v[30:32]) + case CDPTLVVTPDomain: + info.VTPDomain = string(val.Value) + case CDPTLVNativeVLAN: + if err = checkCDPTLVLen(val, 2); err != nil { + return err + } + info.NativeVLAN = binary.BigEndian.Uint16(val.Value[0:2]) + case CDPTLVFullDuplex: + if err = checkCDPTLVLen(val, 1); err != nil { + return err + } + info.FullDuplex = (val.Value[0] == 1) + case CDPTLVVLANReply: + if err = checkCDPTLVLen(val, 3); err != nil { + return err + } + info.VLANReply.ID = uint8(val.Value[0]) + info.VLANReply.VLAN = binary.BigEndian.Uint16(val.Value[1:3]) + case CDPTLVVLANQuery: + if err = checkCDPTLVLen(val, 3); err != nil { + return err + } + info.VLANQuery.ID = uint8(val.Value[0]) + info.VLANQuery.VLAN = binary.BigEndian.Uint16(val.Value[1:3]) + case CDPTLVPower: + if err = checkCDPTLVLen(val, 2); err != nil { + return err + } + info.PowerConsumption = binary.BigEndian.Uint16(val.Value[0:2]) + case CDPTLVMTU: + if err = checkCDPTLVLen(val, 4); err != nil { + return err + } + info.MTU = binary.BigEndian.Uint32(val.Value[0:4]) + case CDPTLVExtendedTrust: + if err = checkCDPTLVLen(val, 1); err != nil { + return err + } + info.ExtendedTrust = uint8(val.Value[0]) + case CDPTLVUntrustedCOS: + if err = checkCDPTLVLen(val, 1); err != nil { + return err + } + info.UntrustedCOS = uint8(val.Value[0]) + case CDPTLVSysName: + info.SysName = string(val.Value) + case CDPTLVSysOID: + info.SysOID = string(val.Value) + case CDPTLVMgmtAddresses: + if err = checkCDPTLVLen(val, 4); err != nil { + return err + } + info.MgmtAddresses, err = decodeAddresses(val.Value) + if err != nil { + return err + } + case CDPTLVLocation: + if err = checkCDPTLVLen(val, 2); err != nil { + return err + } + info.Location.Type = uint8(val.Value[0]) + info.Location.Location = string(val.Value[1:]) + + // case CDPTLVLExternalPortID: + // Undocumented + case CDPTLVPowerRequested: + if err = checkCDPTLVLen(val, 4); err != nil { + return err + } + info.PowerRequest.ID = binary.BigEndian.Uint16(val.Value[0:2]) + info.PowerRequest.MgmtID = binary.BigEndian.Uint16(val.Value[2:4]) + for n := 4; n < len(val.Value); n += 4 { + info.PowerRequest.Values = append(info.PowerRequest.Values, binary.BigEndian.Uint32(val.Value[n:n+4])) + } + case CDPTLVPowerAvailable: + if err = checkCDPTLVLen(val, 4); err != nil { + return err + } + info.PowerAvailable.ID = binary.BigEndian.Uint16(val.Value[0:2]) + info.PowerAvailable.MgmtID = binary.BigEndian.Uint16(val.Value[2:4]) + for n := 4; n < len(val.Value); n += 4 { + info.PowerAvailable.Values = append(info.PowerAvailable.Values, binary.BigEndian.Uint32(val.Value[n:n+4])) + } + // case CDPTLVPortUnidirectional + // Undocumented + case CDPTLVEnergyWise: + if err = checkCDPTLVLen(val, 72); err != nil { + return err + } + info.EnergyWise.EncryptedData = val.Value[0:20] + info.EnergyWise.Unknown1 = binary.BigEndian.Uint32(val.Value[20:24]) + info.EnergyWise.SequenceNumber = binary.BigEndian.Uint32(val.Value[24:28]) + info.EnergyWise.ModelNumber = string(val.Value[28:44]) + info.EnergyWise.Unknown2 = binary.BigEndian.Uint16(val.Value[44:46]) + info.EnergyWise.HardwareID = string(val.Value[46:49]) + info.EnergyWise.SerialNum = string(val.Value[49:60]) + info.EnergyWise.Unknown3 = val.Value[60:68] + tlvLen := binary.BigEndian.Uint16(val.Value[68:70]) + tlvNum := binary.BigEndian.Uint16(val.Value[70:72]) + data := val.Value[72:] + if len(data) < int(tlvLen) { + return fmt.Errorf("Invalid TLV length %d vs %d", tlvLen, len(data)) + } + numSeen := 0 + for len(data) > 8 { + numSeen++ + if numSeen > int(tlvNum) { // Too many TLV's ? + return fmt.Errorf("Too many TLV's - wanted %d, saw %d", tlvNum, numSeen) + } + tType := CDPEnergyWiseSubtype(binary.BigEndian.Uint32(data[0:4])) + tLen := int(binary.BigEndian.Uint32(data[4:8])) + if tLen > len(data)-8 { + return fmt.Errorf("Invalid TLV length %d vs %d", tLen, len(data)-8) + } + data = data[8:] + switch tType { + case CDPEnergyWiseRole: + info.EnergyWise.Role = string(data[:]) + case CDPEnergyWiseDomain: + info.EnergyWise.Domain = string(data[:]) + case CDPEnergyWiseName: + info.EnergyWise.Name = string(data[:]) + case CDPEnergyWiseReplyTo: + if len(data) >= 18 { + info.EnergyWise.ReplyUnknown1 = data[0:2] + info.EnergyWise.ReplyPort = data[2:4] + info.EnergyWise.ReplyAddress = data[4:8] + info.EnergyWise.ReplyUnknown2 = data[8:10] + info.EnergyWise.ReplyUnknown3 = data[10:14] + } + } + data = data[tLen:] + } + case CDPTLVSparePairPOE: + if err = checkCDPTLVLen(val, 1); err != nil { + return err + } + v := val.Value[0] + info.SparePairPoe.PSEFourWire = (v&CDPPoEFourWire > 0) + info.SparePairPoe.PDArchShared = (v&CDPPoEPDArch > 0) + info.SparePairPoe.PDRequestOn = (v&CDPPoEPDRequest > 0) + info.SparePairPoe.PSEOn = (v&CDPPoEPSE > 0) + default: + info.Unknown = append(info.Unknown, val) + } + } + return nil +} + +// CDP Protocol Types +const ( + CDPProtocolTypeNLPID byte = 1 + CDPProtocolType802_2 byte = 2 +) + +// CDPAddressType is used to define TLV values within CDP addresses. +type CDPAddressType uint64 + +// CDP Address types. +const ( + CDPAddressTypeCLNP CDPAddressType = 0x81 + CDPAddressTypeIPV4 CDPAddressType = 0xcc + CDPAddressTypeIPV6 CDPAddressType = 0xaaaa030000000800 + CDPAddressTypeDECNET CDPAddressType = 0xaaaa030000006003 + CDPAddressTypeAPPLETALK CDPAddressType = 0xaaaa03000000809b + CDPAddressTypeIPX CDPAddressType = 0xaaaa030000008137 + CDPAddressTypeVINES CDPAddressType = 0xaaaa0300000080c4 + CDPAddressTypeXNS CDPAddressType = 0xaaaa030000000600 + CDPAddressTypeAPOLLO CDPAddressType = 0xaaaa030000008019 +) + +func decodeAddresses(v []byte) (addresses []net.IP, err error) { + numaddr := int(binary.BigEndian.Uint32(v[0:4])) + if numaddr < 1 { + return nil, fmt.Errorf("Invalid Address TLV number %d", numaddr) + } + v = v[4:] + if len(v) < numaddr*8 { + return nil, fmt.Errorf("Invalid Address TLV length %d", len(v)) + } + for i := 0; i < numaddr; i++ { + prottype := v[0] + if prottype != CDPProtocolTypeNLPID && prottype != CDPProtocolType802_2 { // invalid protocol type + return nil, fmt.Errorf("Invalid Address Protocol %d", prottype) + } + protlen := int(v[1]) + if (prottype == CDPProtocolTypeNLPID && protlen != 1) || + (prottype == CDPProtocolType802_2 && protlen != 3 && protlen != 8) { // invalid length + return nil, fmt.Errorf("Invalid Address Protocol length %d", protlen) + } + plen := make([]byte, 8) + copy(plen[8-protlen:], v[2:2+protlen]) + protocol := CDPAddressType(binary.BigEndian.Uint64(plen)) + v = v[2+protlen:] + addrlen := binary.BigEndian.Uint16(v[0:2]) + ab := v[2 : 2+addrlen] + if protocol == CDPAddressTypeIPV4 && addrlen == 4 { + addresses = append(addresses, net.IPv4(ab[0], ab[1], ab[2], ab[3])) + } else if protocol == CDPAddressTypeIPV6 && addrlen == 16 { + addresses = append(addresses, net.IP(ab)) + } else { + // only handle IPV4 & IPV6 for now + } + v = v[2+addrlen:] + if len(v) < 8 { + break + } + } + return +} + +func (t CDPTLVType) String() (s string) { + switch t { + case CDPTLVDevID: + s = "Device ID" + case CDPTLVAddress: + s = "Addresses" + case CDPTLVPortID: + s = "Port ID" + case CDPTLVCapabilities: + s = "Capabilities" + case CDPTLVVersion: + s = "Software Version" + case CDPTLVPlatform: + s = "Platform" + case CDPTLVIPPrefix: + s = "IP Prefix" + case CDPTLVHello: + s = "Protocol Hello" + case CDPTLVVTPDomain: + s = "VTP Management Domain" + case CDPTLVNativeVLAN: + s = "Native VLAN" + case CDPTLVFullDuplex: + s = "Full Duplex" + case CDPTLVVLANReply: + s = "VoIP VLAN Reply" + case CDPTLVVLANQuery: + s = "VLANQuery" + case CDPTLVPower: + s = "Power consumption" + case CDPTLVMTU: + s = "MTU" + case CDPTLVExtendedTrust: + s = "Extended Trust Bitmap" + case CDPTLVUntrustedCOS: + s = "Untrusted Port CoS" + case CDPTLVSysName: + s = "System Name" + case CDPTLVSysOID: + s = "System OID" + case CDPTLVMgmtAddresses: + s = "Management Addresses" + case CDPTLVLocation: + s = "Location" + case CDPTLVExternalPortID: + s = "External Port ID" + case CDPTLVPowerRequested: + s = "Power Requested" + case CDPTLVPowerAvailable: + s = "Power Available" + case CDPTLVPortUnidirectional: + s = "Port Unidirectional" + case CDPTLVEnergyWise: + s = "Energy Wise" + case CDPTLVSparePairPOE: + s = "Spare Pair POE" + default: + s = "Unknown" + } + return +} + +func (a CDPAddressType) String() (s string) { + switch a { + case CDPAddressTypeCLNP: + s = "Connectionless Network Protocol" + case CDPAddressTypeIPV4: + s = "IPv4" + case CDPAddressTypeIPV6: + s = "IPv6" + case CDPAddressTypeDECNET: + s = "DECnet Phase IV" + case CDPAddressTypeAPPLETALK: + s = "Apple Talk" + case CDPAddressTypeIPX: + s = "Novell IPX" + case CDPAddressTypeVINES: + s = "Banyan VINES" + case CDPAddressTypeXNS: + s = "Xerox Network Systems" + case CDPAddressTypeAPOLLO: + s = "Apollo" + default: + s = "Unknown" + } + return +} + +func (t CDPEnergyWiseSubtype) String() (s string) { + switch t { + case CDPEnergyWiseRole: + s = "Role" + case CDPEnergyWiseDomain: + s = "Domain" + case CDPEnergyWiseName: + s = "Name" + case CDPEnergyWiseReplyTo: + s = "ReplyTo" + default: + s = "Unknown" + } + return +} + +func checkCDPTLVLen(v CiscoDiscoveryValue, l int) (err error) { + if len(v.Value) < l { + err = fmt.Errorf("Invalid TLV %v length %d", v.Type, len(v.Value)) + } + return +} diff --git a/vendor/github.com/google/gopacket/layers/ctp.go b/vendor/github.com/google/gopacket/layers/ctp.go new file mode 100644 index 0000000..8287584 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/ctp.go @@ -0,0 +1,109 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "fmt" + "github.com/google/gopacket" +) + +// EthernetCTPFunction is the function code used by the EthernetCTP protocol to identify each +// EthernetCTP layer. +type EthernetCTPFunction uint16 + +// EthernetCTPFunction values. +const ( + EthernetCTPFunctionReply EthernetCTPFunction = 1 + EthernetCTPFunctionForwardData EthernetCTPFunction = 2 +) + +// EthernetCTP implements the EthernetCTP protocol, see http://www.mit.edu/people/jhawk/ctp.html. +// We split EthernetCTP up into the top-level EthernetCTP layer, followed by zero or more +// EthernetCTPForwardData layers, followed by a final EthernetCTPReply layer. +type EthernetCTP struct { + BaseLayer + SkipCount uint16 +} + +// LayerType returns gopacket.LayerTypeEthernetCTP. +func (c *EthernetCTP) LayerType() gopacket.LayerType { + return LayerTypeEthernetCTP +} + +// EthernetCTPForwardData is the ForwardData layer inside EthernetCTP. See EthernetCTP's docs for more +// details. +type EthernetCTPForwardData struct { + BaseLayer + Function EthernetCTPFunction + ForwardAddress []byte +} + +// LayerType returns gopacket.LayerTypeEthernetCTPForwardData. +func (c *EthernetCTPForwardData) LayerType() gopacket.LayerType { + return LayerTypeEthernetCTPForwardData +} + +// ForwardEndpoint returns the EthernetCTPForwardData ForwardAddress as an endpoint. +func (c *EthernetCTPForwardData) ForwardEndpoint() gopacket.Endpoint { + return gopacket.NewEndpoint(EndpointMAC, c.ForwardAddress) +} + +// EthernetCTPReply is the Reply layer inside EthernetCTP. See EthernetCTP's docs for more details. +type EthernetCTPReply struct { + BaseLayer + Function EthernetCTPFunction + ReceiptNumber uint16 + Data []byte +} + +// LayerType returns gopacket.LayerTypeEthernetCTPReply. +func (c *EthernetCTPReply) LayerType() gopacket.LayerType { + return LayerTypeEthernetCTPReply +} + +// Payload returns the EthernetCTP reply's Data bytes. +func (c *EthernetCTPReply) Payload() []byte { return c.Data } + +func decodeEthernetCTP(data []byte, p gopacket.PacketBuilder) error { + c := &EthernetCTP{ + SkipCount: binary.LittleEndian.Uint16(data[:2]), + BaseLayer: BaseLayer{data[:2], data[2:]}, + } + if c.SkipCount%2 != 0 { + return fmt.Errorf("EthernetCTP skip count is odd: %d", c.SkipCount) + } + p.AddLayer(c) + return p.NextDecoder(gopacket.DecodeFunc(decodeEthernetCTPFromFunctionType)) +} + +// decodeEthernetCTPFromFunctionType reads in the first 2 bytes to determine the EthernetCTP +// layer type to decode next, then decodes based on that. +func decodeEthernetCTPFromFunctionType(data []byte, p gopacket.PacketBuilder) error { + function := EthernetCTPFunction(binary.LittleEndian.Uint16(data[:2])) + switch function { + case EthernetCTPFunctionReply: + reply := &EthernetCTPReply{ + Function: function, + ReceiptNumber: binary.LittleEndian.Uint16(data[2:4]), + Data: data[4:], + BaseLayer: BaseLayer{data, nil}, + } + p.AddLayer(reply) + p.SetApplicationLayer(reply) + return nil + case EthernetCTPFunctionForwardData: + forward := &EthernetCTPForwardData{ + Function: function, + ForwardAddress: data[2:8], + BaseLayer: BaseLayer{data[:8], data[8:]}, + } + p.AddLayer(forward) + return p.NextDecoder(gopacket.DecodeFunc(decodeEthernetCTPFromFunctionType)) + } + return fmt.Errorf("Unknown EthernetCTP function type %v", function) +} diff --git a/vendor/github.com/google/gopacket/layers/dhcpv4.go b/vendor/github.com/google/gopacket/layers/dhcpv4.go new file mode 100644 index 0000000..761b201 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/dhcpv4.go @@ -0,0 +1,571 @@ +// Copyright 2016 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "bytes" + "encoding/binary" + "errors" + "fmt" + "net" + + "github.com/google/gopacket" +) + +// DHCPOp rerprents a bootp operation +type DHCPOp byte + +// bootp operations +const ( + DHCPOpRequest DHCPOp = 1 + DHCPOpReply DHCPOp = 2 +) + +// String returns a string version of a DHCPOp. +func (o DHCPOp) String() string { + switch o { + case DHCPOpRequest: + return "Request" + case DHCPOpReply: + return "Reply" + default: + return "Unknown" + } +} + +// DHCPMsgType represents a DHCP operation +type DHCPMsgType byte + +// Constants that represent DHCP operations +const ( + DHCPMsgTypeUnspecified DHCPMsgType = iota + DHCPMsgTypeDiscover + DHCPMsgTypeOffer + DHCPMsgTypeRequest + DHCPMsgTypeDecline + DHCPMsgTypeAck + DHCPMsgTypeNak + DHCPMsgTypeRelease + DHCPMsgTypeInform +) + +// String returns a string version of a DHCPMsgType. +func (o DHCPMsgType) String() string { + switch o { + case DHCPMsgTypeUnspecified: + return "Unspecified" + case DHCPMsgTypeDiscover: + return "Discover" + case DHCPMsgTypeOffer: + return "Offer" + case DHCPMsgTypeRequest: + return "Request" + case DHCPMsgTypeDecline: + return "Decline" + case DHCPMsgTypeAck: + return "Ack" + case DHCPMsgTypeNak: + return "Nak" + case DHCPMsgTypeRelease: + return "Release" + case DHCPMsgTypeInform: + return "Inform" + default: + return "Unknown" + } +} + +//DHCPMagic is the RFC 2131 "magic cooke" for DHCP. +var DHCPMagic uint32 = 0x63825363 + +// DHCPv4 contains data for a single DHCP packet. +type DHCPv4 struct { + BaseLayer + Operation DHCPOp + HardwareType LinkType + HardwareLen uint8 + HardwareOpts uint8 + Xid uint32 + Secs uint16 + Flags uint16 + ClientIP net.IP + YourClientIP net.IP + NextServerIP net.IP + RelayAgentIP net.IP + ClientHWAddr net.HardwareAddr + ServerName []byte + File []byte + Options DHCPOptions +} + +// DHCPOptions is used to get nicely printed option lists which would normally +// be cut off after 5 options. +type DHCPOptions []DHCPOption + +// String returns a string version of the options list. +func (o DHCPOptions) String() string { + buf := &bytes.Buffer{} + buf.WriteByte('[') + for i, opt := range o { + buf.WriteString(opt.String()) + if i+1 != len(o) { + buf.WriteString(", ") + } + } + buf.WriteByte(']') + return buf.String() +} + +// LayerType returns gopacket.LayerTypeDHCPv4 +func (d *DHCPv4) LayerType() gopacket.LayerType { return LayerTypeDHCPv4 } + +// DecodeFromBytes decodes the given bytes into this layer. +func (d *DHCPv4) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + d.Operation = DHCPOp(data[0]) + d.HardwareType = LinkType(data[1]) + d.HardwareLen = data[2] + d.HardwareOpts = data[3] + d.Xid = binary.BigEndian.Uint32(data[4:8]) + d.Secs = binary.BigEndian.Uint16(data[8:10]) + d.Flags = binary.BigEndian.Uint16(data[10:12]) + d.ClientIP = net.IP(data[12:16]) + d.YourClientIP = net.IP(data[16:20]) + d.NextServerIP = net.IP(data[20:24]) + d.RelayAgentIP = net.IP(data[24:28]) + d.ClientHWAddr = net.HardwareAddr(data[28 : 28+d.HardwareLen]) + d.ServerName = data[44:108] + d.File = data[108:236] + if binary.BigEndian.Uint32(data[236:240]) != DHCPMagic { + return errors.New("Bad DHCP header") + } + + if len(data) <= 240 { + // DHCP Packet could have no option (??) + return nil + } + + options := data[240:] + + stop := len(options) + start := 0 + for start < stop { + o := DHCPOption{} + if err := o.decode(options[start:]); err != nil { + return err + } + if o.Type == DHCPOptEnd { + break + } + d.Options = append(d.Options, o) + // Check if the option is a single byte pad + if o.Type == DHCPOptPad { + start++ + } else { + start += int(o.Length) + 2 + } + } + return nil +} + +// Len returns the length of a DHCPv4 packet. +func (d *DHCPv4) Len() uint16 { + n := uint16(240) + for _, o := range d.Options { + if o.Type == DHCPOptPad { + n++ + } else { + n += uint16(o.Length) + 2 + } + } + n++ // for opt end + return n +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (d *DHCPv4) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + plen := int(d.Len()) + + data, err := b.PrependBytes(plen) + if err != nil { + return err + } + + data[0] = byte(d.Operation) + data[1] = byte(d.HardwareType) + if opts.FixLengths { + d.HardwareLen = uint8(len(d.ClientHWAddr)) + } + data[2] = d.HardwareLen + data[3] = d.HardwareOpts + binary.BigEndian.PutUint32(data[4:8], d.Xid) + binary.BigEndian.PutUint16(data[8:10], d.Secs) + binary.BigEndian.PutUint16(data[10:12], d.Flags) + copy(data[12:16], d.ClientIP.To4()) + copy(data[16:20], d.YourClientIP.To4()) + copy(data[20:24], d.NextServerIP.To4()) + copy(data[24:28], d.RelayAgentIP.To4()) + copy(data[28:44], d.ClientHWAddr) + copy(data[44:108], d.ServerName) + copy(data[108:236], d.File) + binary.BigEndian.PutUint32(data[236:240], DHCPMagic) + + if len(d.Options) > 0 { + offset := 240 + for _, o := range d.Options { + if err := o.encode(data[offset:]); err != nil { + return err + } + // A pad option is only a single byte + if o.Type == DHCPOptPad { + offset++ + } else { + offset += 2 + len(o.Data) + } + } + optend := NewDHCPOption(DHCPOptEnd, nil) + if err := optend.encode(data[offset:]); err != nil { + return err + } + } + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (d *DHCPv4) CanDecode() gopacket.LayerClass { + return LayerTypeDHCPv4 +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (d *DHCPv4) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +func decodeDHCPv4(data []byte, p gopacket.PacketBuilder) error { + dhcp := &DHCPv4{} + err := dhcp.DecodeFromBytes(data, p) + if err != nil { + return err + } + p.AddLayer(dhcp) + return p.NextDecoder(gopacket.LayerTypePayload) +} + +// DHCPOpt represents a DHCP option or parameter from RFC-2132 +type DHCPOpt byte + +// Constants for the DHCPOpt options. +const ( + DHCPOptPad DHCPOpt = 0 + DHCPOptSubnetMask DHCPOpt = 1 // 4, net.IP + DHCPOptTimeOffset DHCPOpt = 2 // 4, int32 (signed seconds from UTC) + DHCPOptRouter DHCPOpt = 3 // n*4, [n]net.IP + DHCPOptTimeServer DHCPOpt = 4 // n*4, [n]net.IP + DHCPOptNameServer DHCPOpt = 5 // n*4, [n]net.IP + DHCPOptDNS DHCPOpt = 6 // n*4, [n]net.IP + DHCPOptLogServer DHCPOpt = 7 // n*4, [n]net.IP + DHCPOptCookieServer DHCPOpt = 8 // n*4, [n]net.IP + DHCPOptLPRServer DHCPOpt = 9 // n*4, [n]net.IP + DHCPOptImpressServer DHCPOpt = 10 // n*4, [n]net.IP + DHCPOptResLocServer DHCPOpt = 11 // n*4, [n]net.IP + DHCPOptHostname DHCPOpt = 12 // n, string + DHCPOptBootfileSize DHCPOpt = 13 // 2, uint16 + DHCPOptMeritDumpFile DHCPOpt = 14 // >1, string + DHCPOptDomainName DHCPOpt = 15 // n, string + DHCPOptSwapServer DHCPOpt = 16 // n*4, [n]net.IP + DHCPOptRootPath DHCPOpt = 17 // n, string + DHCPOptExtensionsPath DHCPOpt = 18 // n, string + DHCPOptIPForwarding DHCPOpt = 19 // 1, bool + DHCPOptSourceRouting DHCPOpt = 20 // 1, bool + DHCPOptPolicyFilter DHCPOpt = 21 // 8*n, [n]{net.IP/net.IP} + DHCPOptDatagramMTU DHCPOpt = 22 // 2, uint16 + DHCPOptDefaultTTL DHCPOpt = 23 // 1, byte + DHCPOptPathMTUAgingTimeout DHCPOpt = 24 // 4, uint32 + DHCPOptPathPlateuTableOption DHCPOpt = 25 // 2*n, []uint16 + DHCPOptInterfaceMTU DHCPOpt = 26 // 2, uint16 + DHCPOptAllSubsLocal DHCPOpt = 27 // 1, bool + DHCPOptBroadcastAddr DHCPOpt = 28 // 4, net.IP + DHCPOptMaskDiscovery DHCPOpt = 29 // 1, bool + DHCPOptMaskSupplier DHCPOpt = 30 // 1, bool + DHCPOptRouterDiscovery DHCPOpt = 31 // 1, bool + DHCPOptSolicitAddr DHCPOpt = 32 // 4, net.IP + DHCPOptStaticRoute DHCPOpt = 33 // n*8, [n]{net.IP/net.IP} -- note the 2nd is router not mask + DHCPOptARPTrailers DHCPOpt = 34 // 1, bool + DHCPOptARPTimeout DHCPOpt = 35 // 4, uint32 + DHCPOptEthernetEncap DHCPOpt = 36 // 1, bool + DHCPOptTCPTTL DHCPOpt = 37 // 1, byte + DHCPOptTCPKeepAliveInt DHCPOpt = 38 // 4, uint32 + DHCPOptTCPKeepAliveGarbage DHCPOpt = 39 // 1, bool + DHCPOptNISDomain DHCPOpt = 40 // n, string + DHCPOptNISServers DHCPOpt = 41 // 4*n, [n]net.IP + DHCPOptNTPServers DHCPOpt = 42 // 4*n, [n]net.IP + DHCPOptVendorOption DHCPOpt = 43 // n, [n]byte // may be encapsulated. + DHCPOptNetBIOSTCPNS DHCPOpt = 44 // 4*n, [n]net.IP + DHCPOptNetBIOSTCPDDS DHCPOpt = 45 // 4*n, [n]net.IP + DHCPOptNETBIOSTCPNodeType DHCPOpt = 46 // 1, magic byte + DHCPOptNetBIOSTCPScope DHCPOpt = 47 // n, string + DHCPOptXFontServer DHCPOpt = 48 // n, string + DHCPOptXDisplayManager DHCPOpt = 49 // n, string + DHCPOptRequestIP DHCPOpt = 50 // 4, net.IP + DHCPOptLeaseTime DHCPOpt = 51 // 4, uint32 + DHCPOptExtOptions DHCPOpt = 52 // 1, 1/2/3 + DHCPOptMessageType DHCPOpt = 53 // 1, 1-7 + DHCPOptServerID DHCPOpt = 54 // 4, net.IP + DHCPOptParamsRequest DHCPOpt = 55 // n, []byte + DHCPOptMessage DHCPOpt = 56 // n, 3 + DHCPOptMaxMessageSize DHCPOpt = 57 // 2, uint16 + DHCPOptT1 DHCPOpt = 58 // 4, uint32 + DHCPOptT2 DHCPOpt = 59 // 4, uint32 + DHCPOptClassID DHCPOpt = 60 // n, []byte + DHCPOptClientID DHCPOpt = 61 // n >= 2, []byte + DHCPOptDomainSearch DHCPOpt = 119 // n, string + DHCPOptSIPServers DHCPOpt = 120 // n, url + DHCPOptClasslessStaticRoute DHCPOpt = 121 // + DHCPOptEnd DHCPOpt = 255 +) + +// String returns a string version of a DHCPOpt. +func (o DHCPOpt) String() string { + switch o { + case DHCPOptPad: + return "(padding)" + case DHCPOptSubnetMask: + return "SubnetMask" + case DHCPOptTimeOffset: + return "TimeOffset" + case DHCPOptRouter: + return "Router" + case DHCPOptTimeServer: + return "rfc868" // old time server protocol stringified to dissuade confusion w. NTP + case DHCPOptNameServer: + return "ien116" // obscure nameserver protocol stringified to dissuade confusion w. DNS + case DHCPOptDNS: + return "DNS" + case DHCPOptLogServer: + return "mitLCS" // MIT LCS server protocol yada yada w. Syslog + case DHCPOptCookieServer: + return "CookieServer" + case DHCPOptLPRServer: + return "LPRServer" + case DHCPOptImpressServer: + return "ImpressServer" + case DHCPOptResLocServer: + return "ResourceLocationServer" + case DHCPOptHostname: + return "Hostname" + case DHCPOptBootfileSize: + return "BootfileSize" + case DHCPOptMeritDumpFile: + return "MeritDumpFile" + case DHCPOptDomainName: + return "DomainName" + case DHCPOptSwapServer: + return "SwapServer" + case DHCPOptRootPath: + return "RootPath" + case DHCPOptExtensionsPath: + return "ExtensionsPath" + case DHCPOptIPForwarding: + return "IPForwarding" + case DHCPOptSourceRouting: + return "SourceRouting" + case DHCPOptPolicyFilter: + return "PolicyFilter" + case DHCPOptDatagramMTU: + return "DatagramMTU" + case DHCPOptDefaultTTL: + return "DefaultTTL" + case DHCPOptPathMTUAgingTimeout: + return "PathMTUAgingTimeout" + case DHCPOptPathPlateuTableOption: + return "PathPlateuTableOption" + case DHCPOptInterfaceMTU: + return "InterfaceMTU" + case DHCPOptAllSubsLocal: + return "AllSubsLocal" + case DHCPOptBroadcastAddr: + return "BroadcastAddress" + case DHCPOptMaskDiscovery: + return "MaskDiscovery" + case DHCPOptMaskSupplier: + return "MaskSupplier" + case DHCPOptRouterDiscovery: + return "RouterDiscovery" + case DHCPOptSolicitAddr: + return "SolicitAddr" + case DHCPOptStaticRoute: + return "StaticRoute" + case DHCPOptARPTrailers: + return "ARPTrailers" + case DHCPOptARPTimeout: + return "ARPTimeout" + case DHCPOptEthernetEncap: + return "EthernetEncap" + case DHCPOptTCPTTL: + return "TCPTTL" + case DHCPOptTCPKeepAliveInt: + return "TCPKeepAliveInt" + case DHCPOptTCPKeepAliveGarbage: + return "TCPKeepAliveGarbage" + case DHCPOptNISDomain: + return "NISDomain" + case DHCPOptNISServers: + return "NISServers" + case DHCPOptNTPServers: + return "NTPServers" + case DHCPOptVendorOption: + return "VendorOption" + case DHCPOptNetBIOSTCPNS: + return "NetBIOSOverTCPNS" + case DHCPOptNetBIOSTCPDDS: + return "NetBiosOverTCPDDS" + case DHCPOptNETBIOSTCPNodeType: + return "NetBIOSOverTCPNodeType" + case DHCPOptNetBIOSTCPScope: + return "NetBIOSOverTCPScope" + case DHCPOptXFontServer: + return "XFontServer" + case DHCPOptXDisplayManager: + return "XDisplayManager" + case DHCPOptEnd: + return "(end)" + case DHCPOptSIPServers: + return "SipServers" + case DHCPOptRequestIP: + return "RequestIP" + case DHCPOptLeaseTime: + return "LeaseTime" + case DHCPOptExtOptions: + return "ExtOpts" + case DHCPOptMessageType: + return "MessageType" + case DHCPOptServerID: + return "ServerID" + case DHCPOptParamsRequest: + return "ParamsRequest" + case DHCPOptMessage: + return "Message" + case DHCPOptMaxMessageSize: + return "MaxDHCPSize" + case DHCPOptT1: + return "Timer1" + case DHCPOptT2: + return "Timer2" + case DHCPOptClassID: + return "ClassID" + case DHCPOptClientID: + return "ClientID" + case DHCPOptDomainSearch: + return "DomainSearch" + case DHCPOptClasslessStaticRoute: + return "ClasslessStaticRoute" + default: + return "Unknown" + } +} + +// DHCPOption rerpresents a DHCP option. +type DHCPOption struct { + Type DHCPOpt + Length uint8 + Data []byte +} + +// String returns a string version of a DHCP Option. +func (o DHCPOption) String() string { + switch o.Type { + + case DHCPOptHostname, DHCPOptMeritDumpFile, DHCPOptDomainName, DHCPOptRootPath, + DHCPOptExtensionsPath, DHCPOptNISDomain, DHCPOptNetBIOSTCPScope, DHCPOptXFontServer, + DHCPOptXDisplayManager, DHCPOptMessage, DHCPOptDomainSearch: // string + return fmt.Sprintf("Option(%s:%s)", o.Type, string(o.Data)) + + case DHCPOptMessageType: + if len(o.Data) != 1 { + return fmt.Sprintf("Option(%s:INVALID)", o.Type) + } + return fmt.Sprintf("Option(%s:%s)", o.Type, DHCPMsgType(o.Data[0])) + + case DHCPOptSubnetMask, DHCPOptServerID, DHCPOptBroadcastAddr, + DHCPOptSolicitAddr, DHCPOptRequestIP: // net.IP + if len(o.Data) < 4 { + return fmt.Sprintf("Option(%s:INVALID)", o.Type) + } + return fmt.Sprintf("Option(%s:%s)", o.Type, net.IP(o.Data)) + + case DHCPOptT1, DHCPOptT2, DHCPOptLeaseTime, DHCPOptPathMTUAgingTimeout, + DHCPOptARPTimeout, DHCPOptTCPKeepAliveInt: // uint32 + if len(o.Data) != 4 { + return fmt.Sprintf("Option(%s:INVALID)", o.Type) + } + return fmt.Sprintf("Option(%s:%d)", o.Type, + uint32(o.Data[0])<<24|uint32(o.Data[1])<<16|uint32(o.Data[2])<<8|uint32(o.Data[3])) + + case DHCPOptParamsRequest: + buf := &bytes.Buffer{} + buf.WriteString(fmt.Sprintf("Option(%s:", o.Type)) + for i, v := range o.Data { + buf.WriteString(DHCPOpt(v).String()) + if i+1 != len(o.Data) { + buf.WriteByte(',') + } + } + buf.WriteString(")") + return buf.String() + + default: + return fmt.Sprintf("Option(%s:%v)", o.Type, o.Data) + } +} + +// NewDHCPOption constructs a new DHCPOption with a given type and data. +func NewDHCPOption(t DHCPOpt, data []byte) DHCPOption { + o := DHCPOption{Type: t} + if data != nil { + o.Data = data + o.Length = uint8(len(data)) + } + return o +} + +func (o *DHCPOption) encode(b []byte) error { + switch o.Type { + case DHCPOptPad, DHCPOptEnd: + b[0] = byte(o.Type) + default: + if o.Length > 253 { + return errors.New("data too long to encode") + } + b[0] = byte(o.Type) + b[1] = o.Length + copy(b[2:], o.Data) + } + return nil +} + +func (o *DHCPOption) decode(data []byte) error { + if len(data) < 1 { + // Pad/End have a length of 1 + return errors.New("Not enough data to decode") + } + o.Type = DHCPOpt(data[0]) + switch o.Type { + case DHCPOptPad, DHCPOptEnd: + o.Data = nil + default: + if len(data) < 3 { + return errors.New("Not enough data to decode") + } + o.Length = data[1] + if o.Length > 253 { + return errors.New("data too long to decode") + } + o.Data = data[2 : 2+o.Length] + } + return nil +} diff --git a/vendor/github.com/google/gopacket/layers/dns.go b/vendor/github.com/google/gopacket/layers/dns.go new file mode 100644 index 0000000..2368a28 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/dns.go @@ -0,0 +1,894 @@ +// Copyright 2014 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "fmt" + "net" + + "github.com/google/gopacket" +) + +// DNSClass defines the class associated with a request/response. Different DNS +// classes can be thought of as an array of parallel namespace trees. +type DNSClass uint16 + +// DNSClass known values. +const ( + DNSClassIN DNSClass = 1 // Internet + DNSClassCS DNSClass = 2 // the CSNET class (Obsolete) + DNSClassCH DNSClass = 3 // the CHAOS class + DNSClassHS DNSClass = 4 // Hesiod [Dyer 87] + DNSClassAny DNSClass = 255 // AnyClass +) + +func (dc DNSClass) String() string { + switch dc { + default: + return "Unknown" + case DNSClassIN: + return "IN" + case DNSClassCS: + return "CS" + case DNSClassCH: + return "CH" + case DNSClassHS: + return "HS" + case DNSClassAny: + return "Any" + } +} + +// DNSType defines the type of data being requested/returned in a +// question/answer. +type DNSType uint16 + +// DNSType known values. +const ( + DNSTypeA DNSType = 1 // a host address + DNSTypeNS DNSType = 2 // an authoritative name server + DNSTypeMD DNSType = 3 // a mail destination (Obsolete - use MX) + DNSTypeMF DNSType = 4 // a mail forwarder (Obsolete - use MX) + DNSTypeCNAME DNSType = 5 // the canonical name for an alias + DNSTypeSOA DNSType = 6 // marks the start of a zone of authority + DNSTypeMB DNSType = 7 // a mailbox domain name (EXPERIMENTAL) + DNSTypeMG DNSType = 8 // a mail group member (EXPERIMENTAL) + DNSTypeMR DNSType = 9 // a mail rename domain name (EXPERIMENTAL) + DNSTypeNULL DNSType = 10 // a null RR (EXPERIMENTAL) + DNSTypeWKS DNSType = 11 // a well known service description + DNSTypePTR DNSType = 12 // a domain name pointer + DNSTypeHINFO DNSType = 13 // host information + DNSTypeMINFO DNSType = 14 // mailbox or mail list information + DNSTypeMX DNSType = 15 // mail exchange + DNSTypeTXT DNSType = 16 // text strings + DNSTypeAAAA DNSType = 28 // a IPv6 host address [RFC3596] + DNSTypeSRV DNSType = 33 // server discovery [RFC2782] [RFC6195] +) + +func (dt DNSType) String() string { + switch dt { + default: + return "Unknown" + case DNSTypeA: + return "A" + case DNSTypeNS: + return "NS" + case DNSTypeMD: + return "MD" + case DNSTypeMF: + return "MF" + case DNSTypeCNAME: + return "CNAME" + case DNSTypeSOA: + return "SOA" + case DNSTypeMB: + return "MB" + case DNSTypeMG: + return "MG" + case DNSTypeMR: + return "MR" + case DNSTypeNULL: + return "NULL" + case DNSTypeWKS: + return "WKS" + case DNSTypePTR: + return "PTR" + case DNSTypeHINFO: + return "HINFO" + case DNSTypeMINFO: + return "MINFO" + case DNSTypeMX: + return "MX" + case DNSTypeTXT: + return "TXT" + case DNSTypeAAAA: + return "AAAA" + case DNSTypeSRV: + return "SRV" + } +} + +// DNSResponseCode provides response codes for question answers. +type DNSResponseCode uint8 + +// DNSResponseCode known values. +const ( + DNSResponseCodeNoErr DNSResponseCode = 0 // No error + DNSResponseCodeFormErr DNSResponseCode = 1 // Format Error [RFC1035] + DNSResponseCodeServFail DNSResponseCode = 2 // Server Failure [RFC1035] + DNSResponseCodeNXDomain DNSResponseCode = 3 // Non-Existent Domain [RFC1035] + DNSResponseCodeNotImp DNSResponseCode = 4 // Not Implemented [RFC1035] + DNSResponseCodeRefused DNSResponseCode = 5 // Query Refused [RFC1035] + DNSResponseCodeYXDomain DNSResponseCode = 6 // Name Exists when it should not [RFC2136] + DNSResponseCodeYXRRSet DNSResponseCode = 7 // RR Set Exists when it should not [RFC2136] + DNSResponseCodeNXRRSet DNSResponseCode = 8 // RR Set that should exist does not [RFC2136] + DNSResponseCodeNotAuth DNSResponseCode = 9 // Server Not Authoritative for zone [RFC2136] + DNSResponseCodeNotZone DNSResponseCode = 10 // Name not contained in zone [RFC2136] + DNSResponseCodeBadVers DNSResponseCode = 16 // Bad OPT Version [RFC2671] + DNSResponseCodeBadSig DNSResponseCode = 16 // TSIG Signature Failure [RFC2845] + DNSResponseCodeBadKey DNSResponseCode = 17 // Key not recognized [RFC2845] + DNSResponseCodeBadTime DNSResponseCode = 18 // Signature out of time window [RFC2845] + DNSResponseCodeBadMode DNSResponseCode = 19 // Bad TKEY Mode [RFC2930] + DNSResponseCodeBadName DNSResponseCode = 20 // Duplicate key name [RFC2930] + DNSResponseCodeBadAlg DNSResponseCode = 21 // Algorithm not supported [RFC2930] + DNSResponseCodeBadTruc DNSResponseCode = 22 // Bad Truncation [RFC4635] +) + +func (drc DNSResponseCode) String() string { + switch drc { + default: + return "Unknown" + case DNSResponseCodeNoErr: + return "No Error" + case DNSResponseCodeFormErr: + return "Format Error" + case DNSResponseCodeServFail: + return "Server Failure " + case DNSResponseCodeNXDomain: + return "Non-Existent Domain" + case DNSResponseCodeNotImp: + return "Not Implemented" + case DNSResponseCodeRefused: + return "Query Refused" + case DNSResponseCodeYXDomain: + return "Name Exists when it should not" + case DNSResponseCodeYXRRSet: + return "RR Set Exists when it should not" + case DNSResponseCodeNXRRSet: + return "RR Set that should exist does not" + case DNSResponseCodeNotAuth: + return "Server Not Authoritative for zone" + case DNSResponseCodeNotZone: + return "Name not contained in zone" + case DNSResponseCodeBadVers: + return "Bad OPT Version" + case DNSResponseCodeBadKey: + return "Key not recognized" + case DNSResponseCodeBadTime: + return "Signature out of time window" + case DNSResponseCodeBadMode: + return "Bad TKEY Mode" + case DNSResponseCodeBadName: + return "Duplicate key name" + case DNSResponseCodeBadAlg: + return "Algorithm not supported" + case DNSResponseCodeBadTruc: + return "Bad Truncation" + } +} + +// DNSOpCode defines a set of different operation types. +type DNSOpCode uint8 + +// DNSOpCode known values. +const ( + DNSOpCodeQuery DNSOpCode = 0 // Query [RFC1035] + DNSOpCodeIQuery DNSOpCode = 1 // Inverse Query Obsolete [RFC3425] + DNSOpCodeStatus DNSOpCode = 2 // Status [RFC1035] + DNSOpCodeNotify DNSOpCode = 4 // Notify [RFC1996] + DNSOpCodeUpdate DNSOpCode = 5 // Update [RFC2136] +) + +func (doc DNSOpCode) String() string { + switch doc { + default: + return "Unknown" + case DNSOpCodeQuery: + return "Query" + case DNSOpCodeIQuery: + return "Inverse Query" + case DNSOpCodeStatus: + return "Status" + case DNSOpCodeNotify: + return "Notify" + case DNSOpCodeUpdate: + return "Update" + } +} + +// DNS is specified in RFC 1034 / RFC 1035 +// +---------------------+ +// | Header | +// +---------------------+ +// | Question | the question for the name server +// +---------------------+ +// | Answer | RRs answering the question +// +---------------------+ +// | Authority | RRs pointing toward an authority +// +---------------------+ +// | Additional | RRs holding additional information +// +---------------------+ +// +// DNS Header +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | ID | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// |QR| Opcode |AA|TC|RD|RA| Z | RCODE | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | QDCOUNT | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | ANCOUNT | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | NSCOUNT | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | ARCOUNT | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +// DNS contains data from a single Domain Name Service packet. +type DNS struct { + BaseLayer + + // Header fields + ID uint16 + QR bool + OpCode DNSOpCode + + AA bool // Authoritative answer + TC bool // Truncated + RD bool // Recursion desired + RA bool // Recursion available + Z uint8 // Resrved for future use + + ResponseCode DNSResponseCode + QDCount uint16 // Number of questions to expect + ANCount uint16 // Number of answers to expect + NSCount uint16 // Number of authorities to expect + ARCount uint16 // Number of additional records to expect + + // Entries + Questions []DNSQuestion + Answers []DNSResourceRecord + Authorities []DNSResourceRecord + Additionals []DNSResourceRecord + + // buffer for doing name decoding. We use a single reusable buffer to avoid + // name decoding on a single object via multiple DecodeFromBytes calls + // requiring constant allocation of small byte slices. + buffer []byte +} + +// LayerType returns gopacket.LayerTypeDNS. +func (d *DNS) LayerType() gopacket.LayerType { return LayerTypeDNS } + +// decodeDNS decodes the byte slice into a DNS type. It also +// setups the application Layer in PacketBuilder. +func decodeDNS(data []byte, p gopacket.PacketBuilder) error { + d := &DNS{} + err := d.DecodeFromBytes(data, p) + if err != nil { + return err + } + p.AddLayer(d) + p.SetApplicationLayer(d) + return nil +} + +// DecodeFromBytes decodes the slice into the DNS struct. +func (d *DNS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + d.buffer = d.buffer[:0] + + if len(data) < 12 { + df.SetTruncated() + return errors.New("DNS packet too short") + } + + // since there are no further layers, the baselayer's content is + // pointing to this layer + d.BaseLayer = BaseLayer{Contents: data[:len(data)]} + d.ID = binary.BigEndian.Uint16(data[:2]) + d.QR = data[2]&0x80 != 0 + d.OpCode = DNSOpCode(data[2]>>3) & 0x0F + d.AA = data[2]&0x04 != 0 + d.TC = data[2]&0x02 != 0 + d.RD = data[2]&0x01 != 0 + d.RA = data[3]&0x80 != 0 + d.Z = uint8(data[3]>>4) & 0x7 + d.ResponseCode = DNSResponseCode(data[3] & 0xF) + d.QDCount = binary.BigEndian.Uint16(data[4:6]) + d.ANCount = binary.BigEndian.Uint16(data[6:8]) + d.NSCount = binary.BigEndian.Uint16(data[8:10]) + d.ARCount = binary.BigEndian.Uint16(data[10:12]) + + d.Questions = d.Questions[:0] + d.Answers = d.Answers[:0] + d.Authorities = d.Authorities[:0] + d.Additionals = d.Additionals[:0] + + offset := 12 + var err error + for i := 0; i < int(d.QDCount); i++ { + var q DNSQuestion + if offset, err = q.decode(data, offset, df, &d.buffer); err != nil { + return err + } + d.Questions = append(d.Questions, q) + } + + // For some horrible reason, if we do the obvious thing in this loop: + // var r DNSResourceRecord + // if blah := r.decode(blah); err != nil { + // return err + // } + // d.Foo = append(d.Foo, r) + // the Go compiler thinks that 'r' escapes to the heap, causing a malloc for + // every Answer, Authority, and Additional. To get around this, we do + // something really silly: we append an empty resource record to our slice, + // then use the last value in the slice to call decode. Since the value is + // already in the slice, there's no WAY it can escape... on the other hand our + // code is MUCH uglier :( + for i := 0; i < int(d.ANCount); i++ { + d.Answers = append(d.Answers, DNSResourceRecord{}) + if offset, err = d.Answers[i].decode(data, offset, df, &d.buffer); err != nil { + d.Answers = d.Answers[:i] // strip off erroneous value + return err + } + } + for i := 0; i < int(d.NSCount); i++ { + d.Authorities = append(d.Authorities, DNSResourceRecord{}) + if offset, err = d.Authorities[i].decode(data, offset, df, &d.buffer); err != nil { + d.Authorities = d.Authorities[:i] // strip off erroneous value + return err + } + } + for i := 0; i < int(d.ARCount); i++ { + d.Additionals = append(d.Additionals, DNSResourceRecord{}) + if offset, err = d.Additionals[i].decode(data, offset, df, &d.buffer); err != nil { + d.Additionals = d.Additionals[:i] // strip off erroneous value + return err + } + } + + if uint16(len(d.Questions)) != d.QDCount { + return errors.New("Invalid query decoding, not the right number of questions") + } else if uint16(len(d.Answers)) != d.ANCount { + return errors.New("Invalid query decoding, not the right number of answers") + } else if uint16(len(d.Authorities)) != d.NSCount { + return errors.New("Invalid query decoding, not the right number of authorities") + } else if uint16(len(d.Additionals)) != d.ARCount { + return errors.New("Invalid query decoding, not the right number of additionals info") + } + return nil +} + +// CanDecode implements gopacket.DecodingLayer. +func (d *DNS) CanDecode() gopacket.LayerClass { + return LayerTypeDNS +} + +// NextLayerType implements gopacket.DecodingLayer. +func (d *DNS) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +// Payload returns nil. +func (d *DNS) Payload() []byte { + return nil +} + +func b2i(b bool) int { + if b { + return 1 + } + return 0 +} + +func recSize(rr *DNSResourceRecord) int { + switch rr.Type { + case DNSTypeA: + return 4 + case DNSTypeAAAA: + return 16 + case DNSTypeNS: + return len(rr.NS) + 2 + case DNSTypeCNAME: + return len(rr.CNAME) + 2 + case DNSTypePTR: + return len(rr.PTR) + 2 + case DNSTypeSOA: + return len(rr.SOA.MName) + 2 + len(rr.SOA.RName) + 2 + 20 + case DNSTypeMX: + return 2 + len(rr.MX.Name) + 2 + case DNSTypeTXT: + l := len(rr.TXTs) + for _, txt := range rr.TXTs { + l += len(txt) + } + return l + case DNSTypeSRV: + return 6 + len(rr.SRV.Name) + 2 + } + + return 0 +} + +func computeSize(recs []DNSResourceRecord) int { + sz := 0 + for _, rr := range recs { + sz += len(rr.Name) + 14 + sz += recSize(&rr) + } + return sz +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +func (d *DNS) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + dsz := 0 + for _, q := range d.Questions { + dsz += len(q.Name) + 6 + } + dsz += computeSize(d.Answers) + dsz += computeSize(d.Authorities) + dsz += computeSize(d.Additionals) + + bytes, err := b.PrependBytes(12 + dsz) + if err != nil { + return err + } + binary.BigEndian.PutUint16(bytes, d.ID) + bytes[2] = byte((b2i(d.QR) << 7) | (int(d.OpCode) << 3) | (b2i(d.AA) << 2) | (b2i(d.TC) << 1) | b2i(d.RD)) + bytes[3] = byte((b2i(d.RA) << 7) | (int(d.Z) << 4) | int(d.ResponseCode)) + + if opts.FixLengths { + d.QDCount = uint16(len(d.Questions)) + d.ANCount = uint16(len(d.Answers)) + d.NSCount = uint16(len(d.Authorities)) + d.ARCount = uint16(len(d.Additionals)) + } + binary.BigEndian.PutUint16(bytes[4:], d.QDCount) + binary.BigEndian.PutUint16(bytes[6:], d.ANCount) + binary.BigEndian.PutUint16(bytes[8:], d.NSCount) + binary.BigEndian.PutUint16(bytes[10:], d.ARCount) + + off := 12 + for _, qd := range d.Questions { + n := qd.encode(bytes, off) + off += n + } + + for i := range d.Answers { + // done this way so we can modify DNSResourceRecord to fix + // lengths if requested + qa := &d.Answers[i] + n, err := qa.encode(bytes, off, opts) + if err != nil { + return err + } + off += n + } + + for i := range d.Authorities { + qa := &d.Authorities[i] + n, err := qa.encode(bytes, off, opts) + if err != nil { + return err + } + off += n + } + for i := range d.Additionals { + qa := &d.Additionals[i] + n, err := qa.encode(bytes, off, opts) + if err != nil { + return err + } + off += n + } + + return nil +} + +var errMaxRecursion = errors.New("max DNS recursion level hit") + +const maxRecursionLevel = 255 + +func decodeName(data []byte, offset int, buffer *[]byte, level int) ([]byte, int, error) { + if level > maxRecursionLevel { + return nil, 0, errMaxRecursion + } else if offset >= len(data) { + return nil, 0, errors.New("dns name offset too high") + } else if offset < 0 { + return nil, 0, errors.New("dns name offset is negative") + } + start := len(*buffer) + index := offset + if data[index] == 0x00 { + return nil, index + 1, nil + } +loop: + for data[index] != 0x00 { + switch data[index] & 0xc0 { + default: + /* RFC 1035 + A domain name represented as a sequence of labels, where + each label consists of a length octet followed by that + number of octets. The domain name terminates with the + zero length octet for the null label of the root. Note + that this field may be an odd number of octets; no + padding is used. + */ + index2 := index + int(data[index]) + 1 + if index2-offset > 255 { + return nil, 0, errors.New("dns name is too long") + } else if index2 < index+1 || index2 > len(data) { + return nil, 0, errors.New("dns name uncomputable: invalid index") + } + *buffer = append(*buffer, '.') + *buffer = append(*buffer, data[index+1:index2]...) + index = index2 + + case 0xc0: + /* RFC 1035 + The pointer takes the form of a two octet sequence. + + The first two bits are ones. This allows a pointer to + be distinguished from a label, since the label must + begin with two zero bits because labels are restricted + to 63 octets or less. (The 10 and 01 combinations are + reserved for future use.) The OFFSET field specifies + an offset from the start of the message (i.e., the + first octet of the ID field in the domain header). A + zero offset specifies the first byte of the ID field, + etc. + + The compression scheme allows a domain name in a message to be + represented as either: + - a sequence of labels ending in a zero octet + - a pointer + - a sequence of labels ending with a pointer + */ + if index+2 > len(data) { + return nil, 0, errors.New("dns offset pointer too high") + } + offsetp := int(binary.BigEndian.Uint16(data[index:index+2]) & 0x3fff) + if offsetp > len(data) { + return nil, 0, errors.New("dns offset pointer too high") + } + // This looks a little tricky, but actually isn't. Because of how + // decodeName is written, calling it appends the decoded name to the + // current buffer. We already have the start of the buffer, then, so + // once this call is done buffer[start:] will contain our full name. + _, _, err := decodeName(data, offsetp, buffer, level+1) + if err != nil { + return nil, 0, err + } + index++ // pointer is two bytes, so add an extra byte here. + break loop + /* EDNS, or other DNS option ? */ + case 0x40: // RFC 2673 + return nil, 0, fmt.Errorf("qname '0x40' - RFC 2673 unsupported yet (data=%x index=%d)", + data[index], index) + + case 0x80: + return nil, 0, fmt.Errorf("qname '0x80' unsupported yet (data=%x index=%d)", + data[index], index) + } + if index >= len(data) { + return nil, 0, errors.New("dns index walked out of range") + } + } + if len(*buffer) <= start { + return nil, 0, errors.New("no dns data found for name") + } + return (*buffer)[start+1:], index + 1, nil +} + +// DNSQuestion wraps a single request (question) within a DNS query. +type DNSQuestion struct { + Name []byte + Type DNSType + Class DNSClass +} + +func (q *DNSQuestion) decode(data []byte, offset int, df gopacket.DecodeFeedback, buffer *[]byte) (int, error) { + name, endq, err := decodeName(data, offset, buffer, 1) + if err != nil { + return 0, err + } + + q.Name = name + q.Type = DNSType(binary.BigEndian.Uint16(data[endq : endq+2])) + q.Class = DNSClass(binary.BigEndian.Uint16(data[endq+2 : endq+4])) + + return endq + 4, nil +} + +func (q *DNSQuestion) encode(data []byte, offset int) int { + noff := encodeName(q.Name, data, offset) + binary.BigEndian.PutUint16(data[noff:], uint16(q.Type)) + binary.BigEndian.PutUint16(data[noff+2:], uint16(q.Class)) + return len(q.Name) + 6 +} + +// DNSResourceRecord +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | | +// / / +// / NAME / +// | | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | TYPE | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | CLASS | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | TTL | +// | | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | RDLENGTH | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--| +// / RDATA / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +// DNSResourceRecord wraps the data from a single DNS resource within a +// response. +type DNSResourceRecord struct { + // Header + Name []byte + Type DNSType + Class DNSClass + TTL uint32 + + // RDATA Raw Values + DataLength uint16 + Data []byte + + // RDATA Decoded Values + IP net.IP + NS, CNAME, PTR []byte + TXTs [][]byte + SOA DNSSOA + SRV DNSSRV + MX DNSMX + + // Undecoded TXT for backward compatibility + TXT []byte +} + +// decode decodes the resource record, returning the total length of the record. +func (rr *DNSResourceRecord) decode(data []byte, offset int, df gopacket.DecodeFeedback, buffer *[]byte) (int, error) { + name, endq, err := decodeName(data, offset, buffer, 1) + if err != nil { + return 0, err + } + + rr.Name = name + rr.Type = DNSType(binary.BigEndian.Uint16(data[endq : endq+2])) + rr.Class = DNSClass(binary.BigEndian.Uint16(data[endq+2 : endq+4])) + rr.TTL = binary.BigEndian.Uint32(data[endq+4 : endq+8]) + rr.DataLength = binary.BigEndian.Uint16(data[endq+8 : endq+10]) + end := endq + 10 + int(rr.DataLength) + if end > len(data) { + return 0, fmt.Errorf("resource record length exceeds data") + } + rr.Data = data[endq+10 : end] + + if err = rr.decodeRData(data, endq+10, buffer); err != nil { + return 0, err + } + + return endq + 10 + int(rr.DataLength), nil +} + +func encodeName(name []byte, data []byte, offset int) int { + l := 0 + for i := range name { + if name[i] == '.' { + data[offset+i-l] = byte(l) + l = 0 + } else { + // skip one to write the length + data[offset+i+1] = name[i] + l++ + } + } + // length for final portion + data[offset+len(name)-l] = byte(l) + data[offset+len(name)+1] = 0x00 // terminal + return offset + len(name) + 2 +} + +func (rr *DNSResourceRecord) encode(data []byte, offset int, opts gopacket.SerializeOptions) (int, error) { + + noff := encodeName(rr.Name, data, offset) + + binary.BigEndian.PutUint16(data[noff:], uint16(rr.Type)) + binary.BigEndian.PutUint16(data[noff+2:], uint16(rr.Class)) + binary.BigEndian.PutUint32(data[noff+4:], uint32(rr.TTL)) + + switch rr.Type { + case DNSTypeA: + copy(data[noff+10:], rr.IP.To4()) + case DNSTypeAAAA: + copy(data[noff+10:], rr.IP) + case DNSTypeNS: + encodeName(rr.NS, data, noff+10) + case DNSTypeCNAME: + encodeName(rr.CNAME, data, noff+10) + case DNSTypePTR: + encodeName(rr.PTR, data, noff+10) + case DNSTypeSOA: + noff2 := encodeName(rr.SOA.MName, data, noff+10) + noff2 = encodeName(rr.SOA.RName, data, noff2) + binary.BigEndian.PutUint32(data[noff2:], rr.SOA.Serial) + binary.BigEndian.PutUint32(data[noff2+4:], rr.SOA.Refresh) + binary.BigEndian.PutUint32(data[noff2+8:], rr.SOA.Retry) + binary.BigEndian.PutUint32(data[noff2+12:], rr.SOA.Expire) + binary.BigEndian.PutUint32(data[noff2+16:], rr.SOA.Minimum) + case DNSTypeMX: + binary.BigEndian.PutUint16(data[noff+10:], rr.MX.Preference) + encodeName(rr.MX.Name, data, noff+12) + case DNSTypeTXT: + noff2 := noff + 10 + for _, txt := range rr.TXTs { + data[noff2] = byte(len(txt)) + copy(data[noff2+1:], txt) + noff2 += 1 + len(txt) + } + case DNSTypeSRV: + binary.BigEndian.PutUint16(data[noff+10:], rr.SRV.Priority) + binary.BigEndian.PutUint16(data[noff+12:], rr.SRV.Weight) + binary.BigEndian.PutUint16(data[noff+14:], rr.SRV.Port) + encodeName(rr.SRV.Name, data, noff+16) + default: + return 0, fmt.Errorf("serializing resource record of type %v not supported", rr.Type) + } + + // DataLength + dSz := recSize(rr) + binary.BigEndian.PutUint16(data[noff+8:], uint16(dSz)) + + if opts.FixLengths { + rr.DataLength = uint16(dSz) + } + + return len(rr.Name) + 1 + 11 + dSz, nil +} + +func (rr *DNSResourceRecord) String() string { + + if rr.Class == DNSClassIN { + switch rr.Type { + case DNSTypeA, DNSTypeAAAA: + return rr.IP.String() + case DNSTypeNS: + return "NS " + string(rr.NS) + case DNSTypeCNAME: + return "CNAME " + string(rr.CNAME) + case DNSTypePTR: + return "PTR " + string(rr.PTR) + case DNSTypeTXT: + return "TXT " + string(rr.TXT) + } + } + + return fmt.Sprintf("<%v, %v>", rr.Class, rr.Type) +} + +func decodeCharacterStrings(data []byte) ([][]byte, error) { + strings := make([][]byte, 0, 1) + end := len(data) + for index, index2 := 0, 0; index != end; index = index2 { + index2 = index + 1 + int(data[index]) // index increases by 1..256 and does not overflow + if index2 > end { + return nil, errors.New("Insufficient data for a ") + } + strings = append(strings, data[index+1:index2]) + } + return strings, nil +} + +func (rr *DNSResourceRecord) decodeRData(data []byte, offset int, buffer *[]byte) error { + switch rr.Type { + case DNSTypeA: + rr.IP = rr.Data + case DNSTypeAAAA: + rr.IP = rr.Data + case DNSTypeTXT, DNSTypeHINFO: + rr.TXT = rr.Data + txts, err := decodeCharacterStrings(rr.Data) + if err != nil { + return err + } + rr.TXTs = txts + case DNSTypeNS: + name, _, err := decodeName(data, offset, buffer, 1) + if err != nil { + return err + } + rr.NS = name + case DNSTypeCNAME: + name, _, err := decodeName(data, offset, buffer, 1) + if err != nil { + return err + } + rr.CNAME = name + case DNSTypePTR: + name, _, err := decodeName(data, offset, buffer, 1) + if err != nil { + return err + } + rr.PTR = name + case DNSTypeSOA: + name, endq, err := decodeName(data, offset, buffer, 1) + if err != nil { + return err + } + rr.SOA.MName = name + name, endq, err = decodeName(data, endq, buffer, 1) + if err != nil { + return err + } + rr.SOA.RName = name + rr.SOA.Serial = binary.BigEndian.Uint32(data[endq : endq+4]) + rr.SOA.Refresh = binary.BigEndian.Uint32(data[endq+4 : endq+8]) + rr.SOA.Retry = binary.BigEndian.Uint32(data[endq+8 : endq+12]) + rr.SOA.Expire = binary.BigEndian.Uint32(data[endq+12 : endq+16]) + rr.SOA.Minimum = binary.BigEndian.Uint32(data[endq+16 : endq+20]) + case DNSTypeMX: + rr.MX.Preference = binary.BigEndian.Uint16(data[offset : offset+2]) + name, _, err := decodeName(data, offset+2, buffer, 1) + if err != nil { + return err + } + rr.MX.Name = name + case DNSTypeSRV: + rr.SRV.Priority = binary.BigEndian.Uint16(data[offset : offset+2]) + rr.SRV.Weight = binary.BigEndian.Uint16(data[offset+2 : offset+4]) + rr.SRV.Port = binary.BigEndian.Uint16(data[offset+4 : offset+6]) + name, _, err := decodeName(data, offset+6, buffer, 1) + if err != nil { + return err + } + rr.SRV.Name = name + } + return nil +} + +// DNSSOA is a Start of Authority record. Each domain requires a SOA record at +// the cutover where a domain is delegated from its parent. +type DNSSOA struct { + MName, RName []byte + Serial, Refresh, Retry, Expire, Minimum uint32 +} + +// DNSSRV is a Service record, defining a location (hostname/port) of a +// server/service. +type DNSSRV struct { + Priority, Weight, Port uint16 + Name []byte +} + +// DNSMX is a mail exchange record, defining a mail server for a recipient's +// domain. +type DNSMX struct { + Preference uint16 + Name []byte +} diff --git a/vendor/github.com/google/gopacket/layers/doc.go b/vendor/github.com/google/gopacket/layers/doc.go new file mode 100644 index 0000000..3c882c3 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/doc.go @@ -0,0 +1,61 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +/* +Package layers provides decoding layers for many common protocols. + +The layers package contains decode implementations for a number of different +types of packet layers. Users of gopacket will almost always want to also use +layers to actually decode packet data into useful pieces. To see the set of +protocols that gopacket/layers is currently able to decode, +look at the set of LayerTypes defined in the Variables sections. The +layers package also defines endpoints for many of the common packet layers +that have source/destination addresses associated with them, for example IPv4/6 +(IPs) and TCP/UDP (ports). +Finally, layers contains a number of useful enumerations (IPProtocol, +EthernetType, LinkType, PPPType, etc...). Many of these implement the +gopacket.Decoder interface, so they can be passed into gopacket as decoders. + +Most common protocol layers are named using acronyms or other industry-common +names (IPv4, TCP, PPP). Some of the less common ones have their names expanded +(CiscoDiscoveryProtocol). +For certain protocols, sub-parts of the protocol are split out into their own +layers (SCTP, for example). This is done mostly in cases where portions of the +protocol may fulfill the capabilities of interesting layers (SCTPData implements +ApplicationLayer, while base SCTP implements TransportLayer), or possibly +because splitting a protocol into a few layers makes decoding easier. + +This package is meant to be used with its parent, +http://github.com/google/gopacket. + +Port Types + +Instead of using raw uint16 or uint8 values for ports, we use a different port +type for every protocol, for example TCPPort and UDPPort. This allows us to +override string behavior for each port, which we do by setting up port name +maps (TCPPortNames, UDPPortNames, etc...). Well-known ports are annotated with +their protocol names, and their String function displays these names: + + p := TCPPort(80) + fmt.Printf("Number: %d String: %v", p, p) + // Prints: "Number: 80 String: 80(http)" + +Modifying Decode Behavior + +layers links together decoding through its enumerations. For example, after +decoding layer type Ethernet, it uses Ethernet.EthernetType as its next decoder. +All enumerations that act as decoders, like EthernetType, can be modified by +users depending on their preferences. For example, if you have a spiffy new +IPv4 decoder that works way better than the one built into layers, you can do +this: + + var mySpiffyIPv4Decoder gopacket.Decoder = ... + layers.EthernetTypeMetadata[EthernetTypeIPv4].DecodeWith = mySpiffyIPv4Decoder + +This will make all future ethernet packets use your new decoder to decode IPv4 +packets, instead of the built-in decoder used by gopacket. +*/ +package layers diff --git a/vendor/github.com/google/gopacket/layers/dot11.go b/vendor/github.com/google/gopacket/layers/dot11.go new file mode 100644 index 0000000..1b53026 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/dot11.go @@ -0,0 +1,1430 @@ +// Copyright 2014 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +// See http://standards.ieee.org/findstds/standard/802.11-2012.html for info on +// all of the layers in this file. + +package layers + +import ( + "bytes" + "encoding/binary" + "fmt" + "hash/crc32" + "net" + + "github.com/google/gopacket" +) + +// Dot11Flags contains the set of 8 flags in the IEEE 802.11 frame control +// header, all in one place. +type Dot11Flags uint8 + +const ( + Dot11FlagsToDS Dot11Flags = 1 << iota + Dot11FlagsFromDS + Dot11FlagsMF + Dot11FlagsRetry + Dot11FlagsPowerManagement + Dot11FlagsMD + Dot11FlagsWEP + Dot11FlagsOrder +) + +func (d Dot11Flags) ToDS() bool { + return d&Dot11FlagsToDS != 0 +} +func (d Dot11Flags) FromDS() bool { + return d&Dot11FlagsFromDS != 0 +} +func (d Dot11Flags) MF() bool { + return d&Dot11FlagsMF != 0 +} +func (d Dot11Flags) Retry() bool { + return d&Dot11FlagsRetry != 0 +} +func (d Dot11Flags) PowerManagement() bool { + return d&Dot11FlagsPowerManagement != 0 +} +func (d Dot11Flags) MD() bool { + return d&Dot11FlagsMD != 0 +} +func (d Dot11Flags) WEP() bool { + return d&Dot11FlagsWEP != 0 +} +func (d Dot11Flags) Order() bool { + return d&Dot11FlagsOrder != 0 +} + +// String provides a human readable string for Dot11Flags. +// This string is possibly subject to change over time; if you're storing this +// persistently, you should probably store the Dot11Flags value, not its string. +func (a Dot11Flags) String() string { + var out bytes.Buffer + if a.ToDS() { + out.WriteString("TO-DS,") + } + if a.FromDS() { + out.WriteString("FROM-DS,") + } + if a.MF() { + out.WriteString("MF,") + } + if a.Retry() { + out.WriteString("Retry,") + } + if a.PowerManagement() { + out.WriteString("PowerManagement,") + } + if a.MD() { + out.WriteString("MD,") + } + if a.WEP() { + out.WriteString("WEP,") + } + if a.Order() { + out.WriteString("Order,") + } + + if length := out.Len(); length > 0 { + return string(out.Bytes()[:length-1]) // strip final comma + } + return "" +} + +type Dot11Reason uint16 + +// TODO: Verify these reasons, and append more reasons if necessary. + +const ( + Dot11ReasonReserved Dot11Reason = 1 + Dot11ReasonUnspecified Dot11Reason = 2 + Dot11ReasonAuthExpired Dot11Reason = 3 + Dot11ReasonDeauthStLeaving Dot11Reason = 4 + Dot11ReasonInactivity Dot11Reason = 5 + Dot11ReasonApFull Dot11Reason = 6 + Dot11ReasonClass2FromNonAuth Dot11Reason = 7 + Dot11ReasonClass3FromNonAss Dot11Reason = 8 + Dot11ReasonDisasStLeaving Dot11Reason = 9 + Dot11ReasonStNotAuth Dot11Reason = 10 +) + +// String provides a human readable string for Dot11Reason. +// This string is possibly subject to change over time; if you're storing this +// persistently, you should probably store the Dot11Reason value, not its string. +func (a Dot11Reason) String() string { + switch a { + case Dot11ReasonReserved: + return "Reserved" + case Dot11ReasonUnspecified: + return "Unspecified" + case Dot11ReasonAuthExpired: + return "Auth. expired" + case Dot11ReasonDeauthStLeaving: + return "Deauth. st. leaving" + case Dot11ReasonInactivity: + return "Inactivity" + case Dot11ReasonApFull: + return "Ap. full" + case Dot11ReasonClass2FromNonAuth: + return "Class2 from non auth." + case Dot11ReasonClass3FromNonAss: + return "Class3 from non ass." + case Dot11ReasonDisasStLeaving: + return "Disass st. leaving" + case Dot11ReasonStNotAuth: + return "St. not auth." + default: + return "Unknown reason" + } +} + +type Dot11Status uint16 + +const ( + Dot11StatusSuccess Dot11Status = 0 + Dot11StatusFailure Dot11Status = 1 // Unspecified failure + Dot11StatusCannotSupportAllCapabilities Dot11Status = 10 // Cannot support all requested capabilities in the Capability Information field + Dot11StatusInabilityExistsAssociation Dot11Status = 11 // Reassociation denied due to inability to confirm that association exists + Dot11StatusAssociationDenied Dot11Status = 12 // Association denied due to reason outside the scope of this standard + Dot11StatusAlgorithmUnsupported Dot11Status = 13 // Responding station does not support the specified authentication algorithm + Dot11StatusOufOfExpectedSequence Dot11Status = 14 // Received an Authentication frame with authentication transaction sequence number out of expected sequence + Dot11StatusChallengeFailure Dot11Status = 15 // Authentication rejected because of challenge failure + Dot11StatusTimeout Dot11Status = 16 // Authentication rejected due to timeout waiting for next frame in sequence + Dot11StatusAPUnableToHandle Dot11Status = 17 // Association denied because AP is unable to handle additional associated stations + Dot11StatusRateUnsupported Dot11Status = 18 // Association denied due to requesting station not supporting all of the data rates in the BSSBasicRateSet parameter +) + +// String provides a human readable string for Dot11Status. +// This string is possibly subject to change over time; if you're storing this +// persistently, you should probably store the Dot11Status value, not its string. +func (a Dot11Status) String() string { + switch a { + case Dot11StatusSuccess: + return "success" + case Dot11StatusFailure: + return "failure" + case Dot11StatusCannotSupportAllCapabilities: + return "cannot-support-all-capabilities" + case Dot11StatusInabilityExistsAssociation: + return "inability-exists-association" + case Dot11StatusAssociationDenied: + return "association-denied" + case Dot11StatusAlgorithmUnsupported: + return "algorithm-unsupported" + case Dot11StatusOufOfExpectedSequence: + return "out-of-expected-sequence" + case Dot11StatusChallengeFailure: + return "challenge-failure" + case Dot11StatusTimeout: + return "timeout" + case Dot11StatusAPUnableToHandle: + return "ap-unable-to-handle" + case Dot11StatusRateUnsupported: + return "rate-unsupported" + default: + return "unknown status" + } +} + +type Dot11AckPolicy uint8 + +const ( + Dot11AckPolicyNormal Dot11AckPolicy = 0 + Dot11AckPolicyNone Dot11AckPolicy = 1 + Dot11AckPolicyNoExplicit Dot11AckPolicy = 2 + Dot11AckPolicyBlock Dot11AckPolicy = 3 +) + +// String provides a human readable string for Dot11AckPolicy. +// This string is possibly subject to change over time; if you're storing this +// persistently, you should probably store the Dot11AckPolicy value, not its string. +func (a Dot11AckPolicy) String() string { + switch a { + case Dot11AckPolicyNormal: + return "normal-ack" + case Dot11AckPolicyNone: + return "no-ack" + case Dot11AckPolicyNoExplicit: + return "no-explicit-ack" + case Dot11AckPolicyBlock: + return "block-ack" + default: + return "unknown-ack-policy" + } +} + +type Dot11Algorithm uint16 + +const ( + Dot11AlgorithmOpen Dot11Algorithm = 0 + Dot11AlgorithmSharedKey Dot11Algorithm = 1 +) + +// String provides a human readable string for Dot11Algorithm. +// This string is possibly subject to change over time; if you're storing this +// persistently, you should probably store the Dot11Algorithm value, not its string. +func (a Dot11Algorithm) String() string { + switch a { + case Dot11AlgorithmOpen: + return "open" + case Dot11AlgorithmSharedKey: + return "shared-key" + default: + return "unknown-algorithm" + } +} + +type Dot11InformationElementID uint8 + +// TODO: Verify these element ids, and append more ids if more. + +const ( + Dot11InformationElementIDSSID Dot11InformationElementID = 0 + Dot11InformationElementIDRates Dot11InformationElementID = 1 + Dot11InformationElementIDFHSet Dot11InformationElementID = 2 + Dot11InformationElementIDDSSet Dot11InformationElementID = 3 + Dot11InformationElementIDCFSet Dot11InformationElementID = 4 + Dot11InformationElementIDTIM Dot11InformationElementID = 5 + Dot11InformationElementIDIBSSSet Dot11InformationElementID = 6 + Dot11InformationElementIDChallenge Dot11InformationElementID = 16 + Dot11InformationElementIDERPInfo Dot11InformationElementID = 42 + Dot11InformationElementIDQOSCapability Dot11InformationElementID = 46 + Dot11InformationElementIDERPInfo2 Dot11InformationElementID = 47 + Dot11InformationElementIDRSNInfo Dot11InformationElementID = 48 + Dot11InformationElementIDESRates Dot11InformationElementID = 50 + Dot11InformationElementIDVendor Dot11InformationElementID = 221 + Dot11InformationElementIDReserved Dot11InformationElementID = 68 +) + +// String provides a human readable string for Dot11InformationElementID. +// This string is possibly subject to change over time; if you're storing this +// persistently, you should probably store the Dot11InformationElementID value, +// not its string. +func (a Dot11InformationElementID) String() string { + switch a { + case Dot11InformationElementIDSSID: + return "SSID" + case Dot11InformationElementIDRates: + return "Rates" + case Dot11InformationElementIDFHSet: + return "FHset" + case Dot11InformationElementIDDSSet: + return "DSset" + case Dot11InformationElementIDCFSet: + return "CFset" + case Dot11InformationElementIDTIM: + return "TIM" + case Dot11InformationElementIDIBSSSet: + return "IBSSset" + case Dot11InformationElementIDChallenge: + return "Challenge" + case Dot11InformationElementIDERPInfo: + return "ERPinfo" + case Dot11InformationElementIDQOSCapability: + return "QOS capability" + case Dot11InformationElementIDERPInfo2: + return "ERPinfo2" + case Dot11InformationElementIDRSNInfo: + return "RSNinfo" + case Dot11InformationElementIDESRates: + return "ESrates" + case Dot11InformationElementIDVendor: + return "Vendor" + case Dot11InformationElementIDReserved: + return "Reserved" + default: + return "Unknown information element id" + } +} + +// Dot11 provides an IEEE 802.11 base packet header. +// See http://standards.ieee.org/findstds/standard/802.11-2012.html +// for excrutiating detail. +type Dot11 struct { + BaseLayer + Type Dot11Type + Proto uint8 + Flags Dot11Flags + DurationID uint16 + Address1 net.HardwareAddr + Address2 net.HardwareAddr + Address3 net.HardwareAddr + Address4 net.HardwareAddr + SequenceNumber uint16 + FragmentNumber uint16 + Checksum uint32 +} + +func decodeDot11(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11) LayerType() gopacket.LayerType { return LayerTypeDot11 } +func (m *Dot11) CanDecode() gopacket.LayerClass { return LayerTypeDot11 } +func (m *Dot11) NextLayerType() gopacket.LayerType { + if m.Flags.WEP() { + return (LayerTypeDot11WEP) + } + + return m.Type.LayerType() +} + +func (m *Dot11) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 10 { + df.SetTruncated() + return fmt.Errorf("Dot11 length %v too short, %v required", len(data), 10) + } + m.Type = Dot11Type((data[0])&0xFC) >> 2 + + m.Proto = uint8(data[0]) & 0x0003 + m.Flags = Dot11Flags(data[1]) + m.DurationID = binary.LittleEndian.Uint16(data[2:4]) + m.Address1 = net.HardwareAddr(data[4:10]) + + offset := 10 + + mainType := m.Type.MainType() + + switch mainType { + case Dot11TypeCtrl: + switch m.Type { + case Dot11TypeCtrlRTS, Dot11TypeCtrlPowersavePoll, Dot11TypeCtrlCFEnd, Dot11TypeCtrlCFEndAck: + if len(data) < offset+6 { + df.SetTruncated() + return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+6) + } + m.Address2 = net.HardwareAddr(data[offset : offset+6]) + offset += 6 + } + case Dot11TypeMgmt, Dot11TypeData: + if len(data) < offset+14 { + df.SetTruncated() + return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+14) + } + m.Address2 = net.HardwareAddr(data[offset : offset+6]) + offset += 6 + m.Address3 = net.HardwareAddr(data[offset : offset+6]) + offset += 6 + + m.SequenceNumber = (binary.LittleEndian.Uint16(data[offset:offset+2]) & 0xFFF0) >> 4 + m.FragmentNumber = (binary.LittleEndian.Uint16(data[offset:offset+2]) & 0x000F) + offset += 2 + } + + if mainType == Dot11TypeData && m.Flags.FromDS() && m.Flags.ToDS() { + if len(data) < offset+6 { + df.SetTruncated() + return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+6) + } + m.Address4 = net.HardwareAddr(data[offset : offset+6]) + offset += 6 + } + + m.BaseLayer = BaseLayer{Contents: data[0:offset], Payload: data[offset : len(data)-4]} + m.Checksum = binary.LittleEndian.Uint32(data[len(data)-4 : len(data)]) + return nil +} + +func (m *Dot11) ChecksumValid() bool { + // only for CTRL and MGMT frames + h := crc32.NewIEEE() + h.Write(m.Contents) + h.Write(m.Payload) + return m.Checksum == h.Sum32() +} + +func (m Dot11) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + buf, err := b.PrependBytes(24) + + if err != nil { + return err + } + + buf[0] = (uint8(m.Type) << 2) | m.Proto + buf[1] = uint8(m.Flags) + + binary.LittleEndian.PutUint16(buf[2:4], m.DurationID) + + copy(buf[4:10], m.Address1) + + offset := 10 + + switch m.Type.MainType() { + case Dot11TypeCtrl: + switch m.Type { + case Dot11TypeCtrlRTS, Dot11TypeCtrlPowersavePoll, Dot11TypeCtrlCFEnd, Dot11TypeCtrlCFEndAck: + copy(buf[offset:offset+6], m.Address2) + offset += 6 + } + case Dot11TypeMgmt, Dot11TypeData: + copy(buf[offset:offset+6], m.Address2) + offset += 6 + copy(buf[offset:offset+6], m.Address3) + offset += 6 + + binary.LittleEndian.PutUint16(buf[offset:offset+2], (m.SequenceNumber<<4)|m.FragmentNumber) + offset += 2 + } + + if m.Type.MainType() == Dot11TypeData && m.Flags.FromDS() && m.Flags.ToDS() { + copy(buf[offset:offset+6], m.Address4) + offset += 6 + } + + return nil +} + +// Dot11Mgmt is a base for all IEEE 802.11 management layers. +type Dot11Mgmt struct { + BaseLayer +} + +func (m *Dot11Mgmt) NextLayerType() gopacket.LayerType { return gopacket.LayerTypePayload } +func (m *Dot11Mgmt) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + m.Contents = data + return nil +} + +// Dot11Ctrl is a base for all IEEE 802.11 control layers. +type Dot11Ctrl struct { + BaseLayer +} + +func (m *Dot11Ctrl) NextLayerType() gopacket.LayerType { return gopacket.LayerTypePayload } + +func (m *Dot11Ctrl) LayerType() gopacket.LayerType { return LayerTypeDot11Ctrl } +func (m *Dot11Ctrl) CanDecode() gopacket.LayerClass { return LayerTypeDot11Ctrl } +func (m *Dot11Ctrl) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + m.Contents = data + return nil +} + +func decodeDot11Ctrl(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11Ctrl{} + return decodingLayerDecoder(d, data, p) +} + +// Dot11WEP contains WEP encrpted IEEE 802.11 data. +type Dot11WEP struct { + BaseLayer +} + +func (m *Dot11WEP) NextLayerType() gopacket.LayerType { return LayerTypeLLC } + +func (m *Dot11WEP) LayerType() gopacket.LayerType { return LayerTypeDot11WEP } +func (m *Dot11WEP) CanDecode() gopacket.LayerClass { return LayerTypeDot11WEP } +func (m *Dot11WEP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + m.Contents = data + return nil +} + +func decodeDot11WEP(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11WEP{} + return decodingLayerDecoder(d, data, p) +} + +// Dot11Data is a base for all IEEE 802.11 data layers. +type Dot11Data struct { + BaseLayer +} + +func (m *Dot11Data) NextLayerType() gopacket.LayerType { return LayerTypeLLC } + +func (m *Dot11Data) LayerType() gopacket.LayerType { return LayerTypeDot11Data } +func (m *Dot11Data) CanDecode() gopacket.LayerClass { return LayerTypeDot11Data } +func (m *Dot11Data) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + m.Payload = data + return nil +} + +func decodeDot11Data(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11Data{} + return decodingLayerDecoder(d, data, p) +} + +type Dot11DataCFAck struct { + Dot11Data +} + +func decodeDot11DataCFAck(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataCFAck{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataCFAck) LayerType() gopacket.LayerType { return LayerTypeDot11DataCFAck } +func (m *Dot11DataCFAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFAck } +func (m *Dot11DataCFAck) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Data.DecodeFromBytes(data, df) +} + +type Dot11DataCFPoll struct { + Dot11Data +} + +func decodeDot11DataCFPoll(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataCFPoll{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataCFPoll) LayerType() gopacket.LayerType { return LayerTypeDot11DataCFPoll } +func (m *Dot11DataCFPoll) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFPoll } +func (m *Dot11DataCFPoll) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Data.DecodeFromBytes(data, df) +} + +type Dot11DataCFAckPoll struct { + Dot11Data +} + +func decodeDot11DataCFAckPoll(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataCFAckPoll{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataCFAckPoll) LayerType() gopacket.LayerType { return LayerTypeDot11DataCFAckPoll } +func (m *Dot11DataCFAckPoll) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFAckPoll } +func (m *Dot11DataCFAckPoll) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Data.DecodeFromBytes(data, df) +} + +type Dot11DataNull struct { + Dot11Data +} + +func decodeDot11DataNull(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataNull{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataNull) LayerType() gopacket.LayerType { return LayerTypeDot11DataNull } +func (m *Dot11DataNull) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataNull } +func (m *Dot11DataNull) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Data.DecodeFromBytes(data, df) +} + +type Dot11DataCFAckNoData struct { + Dot11Data +} + +func decodeDot11DataCFAckNoData(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataCFAckNoData{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataCFAckNoData) LayerType() gopacket.LayerType { return LayerTypeDot11DataCFAckNoData } +func (m *Dot11DataCFAckNoData) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFAckNoData } +func (m *Dot11DataCFAckNoData) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Data.DecodeFromBytes(data, df) +} + +type Dot11DataCFPollNoData struct { + Dot11Data +} + +func decodeDot11DataCFPollNoData(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataCFPollNoData{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataCFPollNoData) LayerType() gopacket.LayerType { return LayerTypeDot11DataCFPollNoData } +func (m *Dot11DataCFPollNoData) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFPollNoData } +func (m *Dot11DataCFPollNoData) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Data.DecodeFromBytes(data, df) +} + +type Dot11DataCFAckPollNoData struct { + Dot11Data +} + +func decodeDot11DataCFAckPollNoData(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataCFAckPollNoData{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataCFAckPollNoData) LayerType() gopacket.LayerType { + return LayerTypeDot11DataCFAckPollNoData +} +func (m *Dot11DataCFAckPollNoData) CanDecode() gopacket.LayerClass { + return LayerTypeDot11DataCFAckPollNoData +} +func (m *Dot11DataCFAckPollNoData) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Data.DecodeFromBytes(data, df) +} + +type Dot11DataQOS struct { + Dot11Ctrl + TID uint8 /* Traffic IDentifier */ + EOSP bool /* End of service period */ + AckPolicy Dot11AckPolicy + TXOP uint8 +} + +func (m *Dot11DataQOS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 4 { + df.SetTruncated() + return fmt.Errorf("Dot11DataQOS length %v too short, %v required", len(data), 4) + } + m.TID = (uint8(data[0]) & 0x0F) + m.EOSP = (uint8(data[0]) & 0x10) == 0x10 + m.AckPolicy = Dot11AckPolicy((uint8(data[0]) & 0x60) >> 5) + m.TXOP = uint8(data[1]) + // TODO: Mesh Control bytes 2:4 + m.BaseLayer = BaseLayer{Contents: data[0:4], Payload: data[4:]} + return nil +} + +type Dot11DataQOSData struct { + Dot11DataQOS +} + +func decodeDot11DataQOSData(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataQOSData{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataQOSData) LayerType() gopacket.LayerType { return LayerTypeDot11DataQOSData } +func (m *Dot11DataQOSData) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataQOSData } + +func (m *Dot11DataQOSData) NextLayerType() gopacket.LayerType { + return LayerTypeDot11Data +} + +type Dot11DataQOSDataCFAck struct { + Dot11DataQOS +} + +func decodeDot11DataQOSDataCFAck(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataQOSDataCFAck{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataQOSDataCFAck) LayerType() gopacket.LayerType { return LayerTypeDot11DataQOSDataCFAck } +func (m *Dot11DataQOSDataCFAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataQOSDataCFAck } +func (m *Dot11DataQOSDataCFAck) NextLayerType() gopacket.LayerType { return LayerTypeDot11DataCFAck } + +type Dot11DataQOSDataCFPoll struct { + Dot11DataQOS +} + +func decodeDot11DataQOSDataCFPoll(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataQOSDataCFPoll{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataQOSDataCFPoll) LayerType() gopacket.LayerType { + return LayerTypeDot11DataQOSDataCFPoll +} +func (m *Dot11DataQOSDataCFPoll) CanDecode() gopacket.LayerClass { + return LayerTypeDot11DataQOSDataCFPoll +} +func (m *Dot11DataQOSDataCFPoll) NextLayerType() gopacket.LayerType { return LayerTypeDot11DataCFPoll } + +type Dot11DataQOSDataCFAckPoll struct { + Dot11DataQOS +} + +func decodeDot11DataQOSDataCFAckPoll(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataQOSDataCFAckPoll{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataQOSDataCFAckPoll) LayerType() gopacket.LayerType { + return LayerTypeDot11DataQOSDataCFAckPoll +} +func (m *Dot11DataQOSDataCFAckPoll) CanDecode() gopacket.LayerClass { + return LayerTypeDot11DataQOSDataCFAckPoll +} +func (m *Dot11DataQOSDataCFAckPoll) NextLayerType() gopacket.LayerType { + return LayerTypeDot11DataCFAckPoll +} + +type Dot11DataQOSNull struct { + Dot11DataQOS +} + +func decodeDot11DataQOSNull(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataQOSNull{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataQOSNull) LayerType() gopacket.LayerType { return LayerTypeDot11DataQOSNull } +func (m *Dot11DataQOSNull) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataQOSNull } +func (m *Dot11DataQOSNull) NextLayerType() gopacket.LayerType { return LayerTypeDot11DataNull } + +type Dot11DataQOSCFPollNoData struct { + Dot11DataQOS +} + +func decodeDot11DataQOSCFPollNoData(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataQOSCFPollNoData{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataQOSCFPollNoData) LayerType() gopacket.LayerType { + return LayerTypeDot11DataQOSCFPollNoData +} +func (m *Dot11DataQOSCFPollNoData) CanDecode() gopacket.LayerClass { + return LayerTypeDot11DataQOSCFPollNoData +} +func (m *Dot11DataQOSCFPollNoData) NextLayerType() gopacket.LayerType { + return LayerTypeDot11DataCFPollNoData +} + +type Dot11DataQOSCFAckPollNoData struct { + Dot11DataQOS +} + +func decodeDot11DataQOSCFAckPollNoData(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11DataQOSCFAckPollNoData{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11DataQOSCFAckPollNoData) LayerType() gopacket.LayerType { + return LayerTypeDot11DataQOSCFAckPollNoData +} +func (m *Dot11DataQOSCFAckPollNoData) CanDecode() gopacket.LayerClass { + return LayerTypeDot11DataQOSCFAckPollNoData +} +func (m *Dot11DataQOSCFAckPollNoData) NextLayerType() gopacket.LayerType { + return LayerTypeDot11DataCFAckPollNoData +} + +type Dot11InformationElement struct { + BaseLayer + ID Dot11InformationElementID + Length uint8 + OUI []byte + Info []byte +} + +func (m *Dot11InformationElement) LayerType() gopacket.LayerType { + return LayerTypeDot11InformationElement +} +func (m *Dot11InformationElement) CanDecode() gopacket.LayerClass { + return LayerTypeDot11InformationElement +} + +func (m *Dot11InformationElement) NextLayerType() gopacket.LayerType { + return LayerTypeDot11InformationElement +} + +func (m *Dot11InformationElement) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 2 { + df.SetTruncated() + return fmt.Errorf("Dot11InformationElement length %v too short, %v required", len(data), 2) + } + m.ID = Dot11InformationElementID(data[0]) + m.Length = data[1] + offset := int(2) + + if len(data) < offset+int(m.Length) { + df.SetTruncated() + return fmt.Errorf("Dot11InformationElement length %v too short, %v required", len(data), offset+int(m.Length)) + } + if m.ID == 221 { + // Vendor extension + m.OUI = data[offset : offset+4] + m.Info = data[offset+4 : offset+int(m.Length)] + } else { + m.Info = data[offset : offset+int(m.Length)] + } + + offset += int(m.Length) + + m.BaseLayer = BaseLayer{Contents: data[:offset], Payload: data[offset:]} + return nil +} + +func (d *Dot11InformationElement) String() string { + if d.ID == 0 { + return fmt.Sprintf("802.11 Information Element (SSID: %v)", string(d.Info)) + } else if d.ID == 1 { + rates := "" + for i := 0; i < len(d.Info); i++ { + if d.Info[i]&0x80 == 0 { + rates += fmt.Sprintf("%.1f ", float32(d.Info[i])*0.5) + } else { + rates += fmt.Sprintf("%.1f* ", float32(d.Info[i]&0x7F)*0.5) + } + } + return fmt.Sprintf("802.11 Information Element (Rates: %s Mbit)", rates) + } else if d.ID == 221 { + return fmt.Sprintf("802.11 Information Element (Vendor: ID: %v, Length: %v, OUI: %X, Info: %X)", d.ID, d.Length, d.OUI, d.Info) + } else { + return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, Info: %X)", d.ID, d.Length, d.Info) + } +} + +func (m Dot11InformationElement) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + length := len(m.Info) + len(m.OUI) + if buf, err := b.PrependBytes(2 + length); err != nil { + return err + } else { + buf[0] = uint8(m.ID) + buf[1] = uint8(length) + copy(buf[2:], m.OUI) + copy(buf[2+len(m.OUI):], m.Info) + } + return nil +} + +func decodeDot11InformationElement(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11InformationElement{} + return decodingLayerDecoder(d, data, p) +} + +type Dot11CtrlCTS struct { + Dot11Ctrl +} + +func decodeDot11CtrlCTS(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11CtrlCTS{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11CtrlCTS) LayerType() gopacket.LayerType { + return LayerTypeDot11CtrlCTS +} +func (m *Dot11CtrlCTS) CanDecode() gopacket.LayerClass { + return LayerTypeDot11CtrlCTS +} +func (m *Dot11CtrlCTS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Ctrl.DecodeFromBytes(data, df) +} + +type Dot11CtrlRTS struct { + Dot11Ctrl +} + +func decodeDot11CtrlRTS(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11CtrlRTS{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11CtrlRTS) LayerType() gopacket.LayerType { + return LayerTypeDot11CtrlRTS +} +func (m *Dot11CtrlRTS) CanDecode() gopacket.LayerClass { + return LayerTypeDot11CtrlRTS +} +func (m *Dot11CtrlRTS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Ctrl.DecodeFromBytes(data, df) +} + +type Dot11CtrlBlockAckReq struct { + Dot11Ctrl +} + +func decodeDot11CtrlBlockAckReq(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11CtrlBlockAckReq{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11CtrlBlockAckReq) LayerType() gopacket.LayerType { + return LayerTypeDot11CtrlBlockAckReq +} +func (m *Dot11CtrlBlockAckReq) CanDecode() gopacket.LayerClass { + return LayerTypeDot11CtrlBlockAckReq +} +func (m *Dot11CtrlBlockAckReq) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Ctrl.DecodeFromBytes(data, df) +} + +type Dot11CtrlBlockAck struct { + Dot11Ctrl +} + +func decodeDot11CtrlBlockAck(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11CtrlBlockAck{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11CtrlBlockAck) LayerType() gopacket.LayerType { return LayerTypeDot11CtrlBlockAck } +func (m *Dot11CtrlBlockAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11CtrlBlockAck } +func (m *Dot11CtrlBlockAck) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Ctrl.DecodeFromBytes(data, df) +} + +type Dot11CtrlPowersavePoll struct { + Dot11Ctrl +} + +func decodeDot11CtrlPowersavePoll(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11CtrlPowersavePoll{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11CtrlPowersavePoll) LayerType() gopacket.LayerType { + return LayerTypeDot11CtrlPowersavePoll +} +func (m *Dot11CtrlPowersavePoll) CanDecode() gopacket.LayerClass { + return LayerTypeDot11CtrlPowersavePoll +} +func (m *Dot11CtrlPowersavePoll) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Ctrl.DecodeFromBytes(data, df) +} + +type Dot11CtrlAck struct { + Dot11Ctrl +} + +func decodeDot11CtrlAck(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11CtrlAck{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11CtrlAck) LayerType() gopacket.LayerType { return LayerTypeDot11CtrlAck } +func (m *Dot11CtrlAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11CtrlAck } +func (m *Dot11CtrlAck) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Ctrl.DecodeFromBytes(data, df) +} + +type Dot11CtrlCFEnd struct { + Dot11Ctrl +} + +func decodeDot11CtrlCFEnd(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11CtrlCFEnd{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11CtrlCFEnd) LayerType() gopacket.LayerType { + return LayerTypeDot11CtrlCFEnd +} +func (m *Dot11CtrlCFEnd) CanDecode() gopacket.LayerClass { + return LayerTypeDot11CtrlCFEnd +} +func (m *Dot11CtrlCFEnd) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Ctrl.DecodeFromBytes(data, df) +} + +type Dot11CtrlCFEndAck struct { + Dot11Ctrl +} + +func decodeDot11CtrlCFEndAck(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11CtrlCFEndAck{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11CtrlCFEndAck) LayerType() gopacket.LayerType { + return LayerTypeDot11CtrlCFEndAck +} +func (m *Dot11CtrlCFEndAck) CanDecode() gopacket.LayerClass { + return LayerTypeDot11CtrlCFEndAck +} +func (m *Dot11CtrlCFEndAck) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + return m.Dot11Ctrl.DecodeFromBytes(data, df) +} + +type Dot11MgmtAssociationReq struct { + Dot11Mgmt + CapabilityInfo uint16 + ListenInterval uint16 +} + +func decodeDot11MgmtAssociationReq(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtAssociationReq{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtAssociationReq) LayerType() gopacket.LayerType { + return LayerTypeDot11MgmtAssociationReq +} +func (m *Dot11MgmtAssociationReq) CanDecode() gopacket.LayerClass { + return LayerTypeDot11MgmtAssociationReq +} +func (m *Dot11MgmtAssociationReq) NextLayerType() gopacket.LayerType { + return LayerTypeDot11InformationElement +} +func (m *Dot11MgmtAssociationReq) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 4 { + df.SetTruncated() + return fmt.Errorf("Dot11MgmtAssociationReq length %v too short, %v required", len(data), 4) + } + m.CapabilityInfo = binary.LittleEndian.Uint16(data[0:2]) + m.ListenInterval = binary.LittleEndian.Uint16(data[2:4]) + m.Payload = data[4:] + return m.Dot11Mgmt.DecodeFromBytes(data, df) +} + +func (m Dot11MgmtAssociationReq) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + buf, err := b.PrependBytes(4) + + if err != nil { + return err + } + + binary.LittleEndian.PutUint16(buf[0:2], m.CapabilityInfo) + binary.LittleEndian.PutUint16(buf[2:4], m.ListenInterval) + + return nil +} + +type Dot11MgmtAssociationResp struct { + Dot11Mgmt + CapabilityInfo uint16 + Status Dot11Status + AID uint16 +} + +func decodeDot11MgmtAssociationResp(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtAssociationResp{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtAssociationResp) CanDecode() gopacket.LayerClass { + return LayerTypeDot11MgmtAssociationResp +} +func (m *Dot11MgmtAssociationResp) LayerType() gopacket.LayerType { + return LayerTypeDot11MgmtAssociationResp +} +func (m *Dot11MgmtAssociationResp) NextLayerType() gopacket.LayerType { + return LayerTypeDot11InformationElement +} +func (m *Dot11MgmtAssociationResp) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 6 { + df.SetTruncated() + return fmt.Errorf("Dot11MgmtAssociationResp length %v too short, %v required", len(data), 6) + } + m.CapabilityInfo = binary.LittleEndian.Uint16(data[0:2]) + m.Status = Dot11Status(binary.LittleEndian.Uint16(data[2:4])) + m.AID = binary.LittleEndian.Uint16(data[4:6]) + m.Payload = data[6:] + return m.Dot11Mgmt.DecodeFromBytes(data, df) +} + +func (m Dot11MgmtAssociationResp) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + buf, err := b.PrependBytes(6) + + if err != nil { + return err + } + + binary.LittleEndian.PutUint16(buf[0:2], m.CapabilityInfo) + binary.LittleEndian.PutUint16(buf[2:4], uint16(m.Status)) + binary.LittleEndian.PutUint16(buf[4:6], m.AID) + + return nil +} + +type Dot11MgmtReassociationReq struct { + Dot11Mgmt + CapabilityInfo uint16 + ListenInterval uint16 + CurrentApAddress net.HardwareAddr +} + +func decodeDot11MgmtReassociationReq(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtReassociationReq{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtReassociationReq) LayerType() gopacket.LayerType { + return LayerTypeDot11MgmtReassociationReq +} +func (m *Dot11MgmtReassociationReq) CanDecode() gopacket.LayerClass { + return LayerTypeDot11MgmtReassociationReq +} +func (m *Dot11MgmtReassociationReq) NextLayerType() gopacket.LayerType { + return LayerTypeDot11InformationElement +} +func (m *Dot11MgmtReassociationReq) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 10 { + df.SetTruncated() + return fmt.Errorf("Dot11MgmtReassociationReq length %v too short, %v required", len(data), 10) + } + m.CapabilityInfo = binary.LittleEndian.Uint16(data[0:2]) + m.ListenInterval = binary.LittleEndian.Uint16(data[2:4]) + m.CurrentApAddress = net.HardwareAddr(data[4:10]) + m.Payload = data[10:] + return m.Dot11Mgmt.DecodeFromBytes(data, df) +} + +func (m Dot11MgmtReassociationReq) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + buf, err := b.PrependBytes(10) + + if err != nil { + return err + } + + binary.LittleEndian.PutUint16(buf[0:2], m.CapabilityInfo) + binary.LittleEndian.PutUint16(buf[2:4], m.ListenInterval) + + copy(buf[4:10], m.CurrentApAddress) + + return nil +} + +type Dot11MgmtReassociationResp struct { + Dot11Mgmt +} + +func decodeDot11MgmtReassociationResp(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtReassociationResp{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtReassociationResp) LayerType() gopacket.LayerType { + return LayerTypeDot11MgmtReassociationResp +} +func (m *Dot11MgmtReassociationResp) CanDecode() gopacket.LayerClass { + return LayerTypeDot11MgmtReassociationResp +} +func (m *Dot11MgmtReassociationResp) NextLayerType() gopacket.LayerType { + return LayerTypeDot11InformationElement +} + +type Dot11MgmtProbeReq struct { + Dot11Mgmt +} + +func decodeDot11MgmtProbeReq(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtProbeReq{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtProbeReq) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtProbeReq } +func (m *Dot11MgmtProbeReq) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtProbeReq } +func (m *Dot11MgmtProbeReq) NextLayerType() gopacket.LayerType { + return LayerTypeDot11InformationElement +} + +type Dot11MgmtProbeResp struct { + Dot11Mgmt + Timestamp uint64 + Interval uint16 + Flags uint16 +} + +func decodeDot11MgmtProbeResp(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtProbeResp{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtProbeResp) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtProbeResp } +func (m *Dot11MgmtProbeResp) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtProbeResp } +func (m *Dot11MgmtProbeResp) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 12 { + df.SetTruncated() + + return fmt.Errorf("Dot11MgmtProbeResp length %v too short, %v required", len(data), 12) + } + + m.Timestamp = binary.LittleEndian.Uint64(data[0:8]) + m.Interval = binary.LittleEndian.Uint16(data[8:10]) + m.Flags = binary.LittleEndian.Uint16(data[10:12]) + m.Payload = data[12:] + + return m.Dot11Mgmt.DecodeFromBytes(data, df) +} + +func (m *Dot11MgmtProbeResp) NextLayerType() gopacket.LayerType { + return LayerTypeDot11InformationElement +} + +func (m Dot11MgmtProbeResp) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + buf, err := b.PrependBytes(12) + + if err != nil { + return err + } + + binary.LittleEndian.PutUint64(buf[0:8], m.Timestamp) + binary.LittleEndian.PutUint16(buf[8:10], m.Interval) + binary.LittleEndian.PutUint16(buf[10:12], m.Flags) + + return nil +} + +type Dot11MgmtMeasurementPilot struct { + Dot11Mgmt +} + +func decodeDot11MgmtMeasurementPilot(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtMeasurementPilot{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtMeasurementPilot) LayerType() gopacket.LayerType { + return LayerTypeDot11MgmtMeasurementPilot +} +func (m *Dot11MgmtMeasurementPilot) CanDecode() gopacket.LayerClass { + return LayerTypeDot11MgmtMeasurementPilot +} + +type Dot11MgmtBeacon struct { + Dot11Mgmt + Timestamp uint64 + Interval uint16 + Flags uint16 +} + +func decodeDot11MgmtBeacon(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtBeacon{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtBeacon) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtBeacon } +func (m *Dot11MgmtBeacon) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtBeacon } +func (m *Dot11MgmtBeacon) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 12 { + df.SetTruncated() + return fmt.Errorf("Dot11MgmtBeacon length %v too short, %v required", len(data), 12) + } + m.Timestamp = binary.LittleEndian.Uint64(data[0:8]) + m.Interval = binary.LittleEndian.Uint16(data[8:10]) + m.Flags = binary.LittleEndian.Uint16(data[10:12]) + m.Payload = data[12:] + return m.Dot11Mgmt.DecodeFromBytes(data, df) +} + +func (m *Dot11MgmtBeacon) NextLayerType() gopacket.LayerType { return LayerTypeDot11InformationElement } + +func (m Dot11MgmtBeacon) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + buf, err := b.PrependBytes(12) + + if err != nil { + return err + } + + binary.LittleEndian.PutUint64(buf[0:8], m.Timestamp) + binary.LittleEndian.PutUint16(buf[8:10], m.Interval) + binary.LittleEndian.PutUint16(buf[10:12], m.Flags) + + return nil +} + +type Dot11MgmtATIM struct { + Dot11Mgmt +} + +func decodeDot11MgmtATIM(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtATIM{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtATIM) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtATIM } +func (m *Dot11MgmtATIM) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtATIM } + +type Dot11MgmtDisassociation struct { + Dot11Mgmt + Reason Dot11Reason +} + +func decodeDot11MgmtDisassociation(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtDisassociation{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtDisassociation) LayerType() gopacket.LayerType { + return LayerTypeDot11MgmtDisassociation +} +func (m *Dot11MgmtDisassociation) CanDecode() gopacket.LayerClass { + return LayerTypeDot11MgmtDisassociation +} +func (m *Dot11MgmtDisassociation) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 2 { + df.SetTruncated() + return fmt.Errorf("Dot11MgmtDisassociation length %v too short, %v required", len(data), 2) + } + m.Reason = Dot11Reason(binary.LittleEndian.Uint16(data[0:2])) + return m.Dot11Mgmt.DecodeFromBytes(data, df) +} + +func (m Dot11MgmtDisassociation) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + buf, err := b.PrependBytes(2) + + if err != nil { + return err + } + + binary.LittleEndian.PutUint16(buf[0:2], uint16(m.Reason)) + + return nil +} + +type Dot11MgmtAuthentication struct { + Dot11Mgmt + Algorithm Dot11Algorithm + Sequence uint16 + Status Dot11Status +} + +func decodeDot11MgmtAuthentication(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtAuthentication{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtAuthentication) LayerType() gopacket.LayerType { + return LayerTypeDot11MgmtAuthentication +} +func (m *Dot11MgmtAuthentication) CanDecode() gopacket.LayerClass { + return LayerTypeDot11MgmtAuthentication +} +func (m *Dot11MgmtAuthentication) NextLayerType() gopacket.LayerType { + return LayerTypeDot11InformationElement +} +func (m *Dot11MgmtAuthentication) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 6 { + df.SetTruncated() + return fmt.Errorf("Dot11MgmtAuthentication length %v too short, %v required", len(data), 6) + } + m.Algorithm = Dot11Algorithm(binary.LittleEndian.Uint16(data[0:2])) + m.Sequence = binary.LittleEndian.Uint16(data[2:4]) + m.Status = Dot11Status(binary.LittleEndian.Uint16(data[4:6])) + m.Payload = data[6:] + return m.Dot11Mgmt.DecodeFromBytes(data, df) +} + +func (m Dot11MgmtAuthentication) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + buf, err := b.PrependBytes(6) + + if err != nil { + return err + } + + binary.LittleEndian.PutUint16(buf[0:2], uint16(m.Algorithm)) + binary.LittleEndian.PutUint16(buf[2:4], m.Sequence) + binary.LittleEndian.PutUint16(buf[4:6], uint16(m.Status)) + + return nil +} + +type Dot11MgmtDeauthentication struct { + Dot11Mgmt + Reason Dot11Reason +} + +func decodeDot11MgmtDeauthentication(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtDeauthentication{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtDeauthentication) LayerType() gopacket.LayerType { + return LayerTypeDot11MgmtDeauthentication +} +func (m *Dot11MgmtDeauthentication) CanDecode() gopacket.LayerClass { + return LayerTypeDot11MgmtDeauthentication +} +func (m *Dot11MgmtDeauthentication) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 2 { + df.SetTruncated() + return fmt.Errorf("Dot11MgmtDeauthentication length %v too short, %v required", len(data), 2) + } + m.Reason = Dot11Reason(binary.LittleEndian.Uint16(data[0:2])) + return m.Dot11Mgmt.DecodeFromBytes(data, df) +} + +func (m Dot11MgmtDeauthentication) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + buf, err := b.PrependBytes(2) + + if err != nil { + return err + } + + binary.LittleEndian.PutUint16(buf[0:2], uint16(m.Reason)) + + return nil +} + +type Dot11MgmtAction struct { + Dot11Mgmt +} + +func decodeDot11MgmtAction(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtAction{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtAction) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtAction } +func (m *Dot11MgmtAction) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtAction } + +type Dot11MgmtActionNoAck struct { + Dot11Mgmt +} + +func decodeDot11MgmtActionNoAck(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtActionNoAck{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtActionNoAck) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtActionNoAck } +func (m *Dot11MgmtActionNoAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtActionNoAck } + +type Dot11MgmtArubaWLAN struct { + Dot11Mgmt +} + +func decodeDot11MgmtArubaWLAN(data []byte, p gopacket.PacketBuilder) error { + d := &Dot11MgmtArubaWLAN{} + return decodingLayerDecoder(d, data, p) +} + +func (m *Dot11MgmtArubaWLAN) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtArubaWLAN } +func (m *Dot11MgmtArubaWLAN) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtArubaWLAN } diff --git a/vendor/github.com/google/gopacket/layers/dot1q.go b/vendor/github.com/google/gopacket/layers/dot1q.go new file mode 100644 index 0000000..47f93d7 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/dot1q.go @@ -0,0 +1,71 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "fmt" + "github.com/google/gopacket" +) + +// Dot1Q is the packet layer for 802.1Q VLAN headers. +type Dot1Q struct { + BaseLayer + Priority uint8 + DropEligible bool + VLANIdentifier uint16 + Type EthernetType +} + +// LayerType returns gopacket.LayerTypeDot1Q +func (d *Dot1Q) LayerType() gopacket.LayerType { return LayerTypeDot1Q } + +// DecodeFromBytes decodes the given bytes into this layer. +func (d *Dot1Q) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + d.Priority = (data[0] & 0xE0) >> 5 + d.DropEligible = data[0]&0x10 != 0 + d.VLANIdentifier = binary.BigEndian.Uint16(data[:2]) & 0x0FFF + d.Type = EthernetType(binary.BigEndian.Uint16(data[2:4])) + d.BaseLayer = BaseLayer{Contents: data[:4], Payload: data[4:]} + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (d *Dot1Q) CanDecode() gopacket.LayerClass { + return LayerTypeDot1Q +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (d *Dot1Q) NextLayerType() gopacket.LayerType { + return d.Type.LayerType() +} + +func decodeDot1Q(data []byte, p gopacket.PacketBuilder) error { + d := &Dot1Q{} + return decodingLayerDecoder(d, data, p) +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (d *Dot1Q) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + bytes, err := b.PrependBytes(4) + if err != nil { + return err + } + if d.VLANIdentifier > 0xFFF { + return fmt.Errorf("vlan identifier %v is too high", d.VLANIdentifier) + } + firstBytes := uint16(d.Priority)<<13 | d.VLANIdentifier + if d.DropEligible { + firstBytes |= 0x1000 + } + binary.BigEndian.PutUint16(bytes, firstBytes) + binary.BigEndian.PutUint16(bytes[2:], uint16(d.Type)) + return nil +} diff --git a/vendor/github.com/google/gopacket/layers/eap.go b/vendor/github.com/google/gopacket/layers/eap.go new file mode 100644 index 0000000..250f857 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/eap.go @@ -0,0 +1,106 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "fmt" + "github.com/google/gopacket" +) + +type EAPCode uint8 +type EAPType uint8 + +const ( + EAPCodeRequest EAPCode = 1 + EAPCodeResponse EAPCode = 2 + EAPCodeSuccess EAPCode = 3 + EAPCodeFailure EAPCode = 4 + + // EAPTypeNone means that this EAP layer has no Type or TypeData. + // Success and Failure EAPs will have this set. + EAPTypeNone EAPType = 0 + + EAPTypeIdentity EAPType = 1 + EAPTypeNotification EAPType = 2 + EAPTypeNACK EAPType = 3 + EAPTypeOTP EAPType = 4 + EAPTypeTokenCard EAPType = 5 +) + +// EAP defines an Extensible Authentication Protocol (rfc 3748) layer. +type EAP struct { + BaseLayer + Code EAPCode + Id uint8 + Length uint16 + Type EAPType + TypeData []byte +} + +// LayerType returns LayerTypeEAP. +func (e *EAP) LayerType() gopacket.LayerType { return LayerTypeEAP } + +// DecodeFromBytes decodes the given bytes into this layer. +func (e *EAP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + e.Code = EAPCode(data[0]) + e.Id = data[1] + e.Length = binary.BigEndian.Uint16(data[2:4]) + switch { + case e.Length > 4: + e.Type = EAPType(data[4]) + e.TypeData = data[5:] + case e.Length == 4: + e.Type = 0 + e.TypeData = nil + default: + return fmt.Errorf("invalid EAP length %d", e.Length) + } + e.BaseLayer.Contents = data[:e.Length] + e.BaseLayer.Payload = data[e.Length:] // Should be 0 bytes + return nil +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (e *EAP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + if opts.FixLengths { + e.Length = uint16(len(e.TypeData) + 1) + } + size := len(e.TypeData) + 4 + if size > 4 { + size++ + } + bytes, err := b.PrependBytes(size) + if err != nil { + return err + } + bytes[0] = byte(e.Code) + bytes[1] = e.Id + binary.BigEndian.PutUint16(bytes[2:], e.Length) + if size > 4 { + bytes[4] = byte(e.Type) + copy(bytes[5:], e.TypeData) + } + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (e *EAP) CanDecode() gopacket.LayerClass { + return LayerTypeEAP +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (e *EAP) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypeZero +} + +func decodeEAP(data []byte, p gopacket.PacketBuilder) error { + e := &EAP{} + return decodingLayerDecoder(e, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/eapol.go b/vendor/github.com/google/gopacket/layers/eapol.go new file mode 100644 index 0000000..041cd59 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/eapol.go @@ -0,0 +1,57 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "github.com/google/gopacket" +) + +// EAPOL defines an EAP over LAN (802.1x) layer. +type EAPOL struct { + BaseLayer + Version uint8 + Type EAPOLType + Length uint16 +} + +// LayerType returns LayerTypeEAPOL. +func (e *EAPOL) LayerType() gopacket.LayerType { return LayerTypeEAPOL } + +// DecodeFromBytes decodes the given bytes into this layer. +func (e *EAPOL) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + e.Version = data[0] + e.Type = EAPOLType(data[1]) + e.Length = binary.BigEndian.Uint16(data[2:4]) + e.BaseLayer = BaseLayer{data[:4], data[4:]} + return nil +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer +func (e *EAPOL) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + bytes, _ := b.PrependBytes(4) + bytes[0] = e.Version + bytes[1] = byte(e.Type) + binary.BigEndian.PutUint16(bytes[2:], e.Length) + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (e *EAPOL) CanDecode() gopacket.LayerClass { + return LayerTypeEAPOL +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (e *EAPOL) NextLayerType() gopacket.LayerType { + return e.Type.LayerType() +} + +func decodeEAPOL(data []byte, p gopacket.PacketBuilder) error { + e := &EAPOL{} + return decodingLayerDecoder(e, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/endpoints.go b/vendor/github.com/google/gopacket/layers/endpoints.go new file mode 100644 index 0000000..4c91cc3 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/endpoints.go @@ -0,0 +1,97 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "github.com/google/gopacket" + "net" + "strconv" +) + +var ( + // We use two different endpoint types for IPv4 vs IPv6 addresses, so that + // ordering with endpointA.LessThan(endpointB) sanely groups all IPv4 + // addresses and all IPv6 addresses, such that IPv6 > IPv4 for all addresses. + EndpointIPv4 = gopacket.RegisterEndpointType(1, gopacket.EndpointTypeMetadata{Name: "IPv4", Formatter: func(b []byte) string { + return net.IP(b).String() + }}) + EndpointIPv6 = gopacket.RegisterEndpointType(2, gopacket.EndpointTypeMetadata{Name: "IPv6", Formatter: func(b []byte) string { + return net.IP(b).String() + }}) + + EndpointMAC = gopacket.RegisterEndpointType(3, gopacket.EndpointTypeMetadata{Name: "MAC", Formatter: func(b []byte) string { + return net.HardwareAddr(b).String() + }}) + EndpointTCPPort = gopacket.RegisterEndpointType(4, gopacket.EndpointTypeMetadata{Name: "TCP", Formatter: func(b []byte) string { + return strconv.Itoa(int(binary.BigEndian.Uint16(b))) + }}) + EndpointUDPPort = gopacket.RegisterEndpointType(5, gopacket.EndpointTypeMetadata{Name: "UDP", Formatter: func(b []byte) string { + return strconv.Itoa(int(binary.BigEndian.Uint16(b))) + }}) + EndpointSCTPPort = gopacket.RegisterEndpointType(6, gopacket.EndpointTypeMetadata{Name: "SCTP", Formatter: func(b []byte) string { + return strconv.Itoa(int(binary.BigEndian.Uint16(b))) + }}) + EndpointRUDPPort = gopacket.RegisterEndpointType(7, gopacket.EndpointTypeMetadata{Name: "RUDP", Formatter: func(b []byte) string { + return strconv.Itoa(int(b[0])) + }}) + EndpointUDPLitePort = gopacket.RegisterEndpointType(8, gopacket.EndpointTypeMetadata{Name: "UDPLite", Formatter: func(b []byte) string { + return strconv.Itoa(int(binary.BigEndian.Uint16(b))) + }}) + EndpointPPP = gopacket.RegisterEndpointType(9, gopacket.EndpointTypeMetadata{Name: "PPP", Formatter: func([]byte) string { + return "point" + }}) +) + +// NewIPEndpoint creates a new IP (v4 or v6) endpoint from a net.IP address. +// It returns gopacket.InvalidEndpoint if the IP address is invalid. +func NewIPEndpoint(a net.IP) gopacket.Endpoint { + ipv4 := a.To4() + if ipv4 != nil { + return gopacket.NewEndpoint(EndpointIPv4, []byte(ipv4)) + } + + ipv6 := a.To16() + if ipv6 != nil { + return gopacket.NewEndpoint(EndpointIPv6, []byte(ipv6)) + } + + return gopacket.InvalidEndpoint +} + +// NewMACEndpoint returns a new MAC address endpoint. +func NewMACEndpoint(a net.HardwareAddr) gopacket.Endpoint { + return gopacket.NewEndpoint(EndpointMAC, []byte(a)) +} +func newPortEndpoint(t gopacket.EndpointType, p uint16) gopacket.Endpoint { + return gopacket.NewEndpoint(t, []byte{byte(p >> 8), byte(p)}) +} + +// NewTCPPortEndpoint returns an endpoint based on a TCP port. +func NewTCPPortEndpoint(p TCPPort) gopacket.Endpoint { + return newPortEndpoint(EndpointTCPPort, uint16(p)) +} + +// NewUDPPortEndpoint returns an endpoint based on a UDP port. +func NewUDPPortEndpoint(p UDPPort) gopacket.Endpoint { + return newPortEndpoint(EndpointUDPPort, uint16(p)) +} + +// NewSCTPPortEndpoint returns an endpoint based on a SCTP port. +func NewSCTPPortEndpoint(p SCTPPort) gopacket.Endpoint { + return newPortEndpoint(EndpointSCTPPort, uint16(p)) +} + +// NewRUDPPortEndpoint returns an endpoint based on a RUDP port. +func NewRUDPPortEndpoint(p RUDPPort) gopacket.Endpoint { + return gopacket.NewEndpoint(EndpointRUDPPort, []byte{byte(p)}) +} + +// NewUDPLitePortEndpoint returns an endpoint based on a UDPLite port. +func NewUDPLitePortEndpoint(p UDPLitePort) gopacket.Endpoint { + return newPortEndpoint(EndpointUDPLitePort, uint16(p)) +} diff --git a/vendor/github.com/google/gopacket/layers/enums.go b/vendor/github.com/google/gopacket/layers/enums.go new file mode 100644 index 0000000..f28bcbd --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/enums.go @@ -0,0 +1,562 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "errors" + "fmt" + + "github.com/google/gopacket" +) + +// EnumMetadata keeps track of a set of metadata for each enumeration value +// for protocol enumerations. +type EnumMetadata struct { + // DecodeWith is the decoder to use to decode this protocol's data. + DecodeWith gopacket.Decoder + // Name is the name of the enumeration value. + Name string + // LayerType is the layer type implied by the given enum. + LayerType gopacket.LayerType +} + +// errorFunc returns a decoder that spits out a specific error message. +func errorFunc(msg string) gopacket.Decoder { + var e = errors.New(msg) + return gopacket.DecodeFunc(func([]byte, gopacket.PacketBuilder) error { + return e + }) +} + +// EthernetType is an enumeration of ethernet type values, and acts as a decoder +// for any type it supports. +type EthernetType uint16 + +const ( + // EthernetTypeLLC is not an actual ethernet type. It is instead a + // placeholder we use in Ethernet frames that use the 802.3 standard of + // srcmac|dstmac|length|LLC instead of srcmac|dstmac|ethertype. + EthernetTypeLLC EthernetType = 0 + EthernetTypeIPv4 EthernetType = 0x0800 + EthernetTypeARP EthernetType = 0x0806 + EthernetTypeIPv6 EthernetType = 0x86DD + EthernetTypeCiscoDiscovery EthernetType = 0x2000 + EthernetTypeNortelDiscovery EthernetType = 0x01a2 + EthernetTypeTransparentEthernetBridging EthernetType = 0x6558 + EthernetTypeDot1Q EthernetType = 0x8100 + EthernetTypePPPoEDiscovery EthernetType = 0x8863 + EthernetTypePPPoESession EthernetType = 0x8864 + EthernetTypeMPLSUnicast EthernetType = 0x8847 + EthernetTypeMPLSMulticast EthernetType = 0x8848 + EthernetTypeEAPOL EthernetType = 0x888e + EthernetTypeQinQ EthernetType = 0x88a8 + EthernetTypeLinkLayerDiscovery EthernetType = 0x88cc + EthernetTypeEthernetCTP EthernetType = 0x9000 +) + +// IPProtocol is an enumeration of IP protocol values, and acts as a decoder +// for any type it supports. +type IPProtocol uint8 + +const ( + IPProtocolIPv6HopByHop IPProtocol = 0 + IPProtocolICMPv4 IPProtocol = 1 + IPProtocolIGMP IPProtocol = 2 + IPProtocolIPv4 IPProtocol = 4 + IPProtocolTCP IPProtocol = 6 + IPProtocolUDP IPProtocol = 17 + IPProtocolRUDP IPProtocol = 27 + IPProtocolIPv6 IPProtocol = 41 + IPProtocolIPv6Routing IPProtocol = 43 + IPProtocolIPv6Fragment IPProtocol = 44 + IPProtocolGRE IPProtocol = 47 + IPProtocolESP IPProtocol = 50 + IPProtocolAH IPProtocol = 51 + IPProtocolICMPv6 IPProtocol = 58 + IPProtocolNoNextHeader IPProtocol = 59 + IPProtocolIPv6Destination IPProtocol = 60 + IPProtocolIPIP IPProtocol = 94 + IPProtocolEtherIP IPProtocol = 97 + IPProtocolVRRP IPProtocol = 112 + IPProtocolSCTP IPProtocol = 132 + IPProtocolUDPLite IPProtocol = 136 + IPProtocolMPLSInIP IPProtocol = 137 +) + +// LinkType is an enumeration of link types, and acts as a decoder for any +// link type it supports. +type LinkType uint8 + +const ( + // According to pcap-linktype(7) and http://www.tcpdump.org/linktypes.html + LinkTypeNull LinkType = 0 + LinkTypeEthernet LinkType = 1 + LinkTypeAX25 LinkType = 3 + LinkTypeTokenRing LinkType = 6 + LinkTypeArcNet LinkType = 7 + LinkTypeSLIP LinkType = 8 + LinkTypePPP LinkType = 9 + LinkTypeFDDI LinkType = 10 + LinkTypePPP_HDLC LinkType = 50 + LinkTypePPPEthernet LinkType = 51 + LinkTypeATM_RFC1483 LinkType = 100 + LinkTypeRaw LinkType = 101 + LinkTypeC_HDLC LinkType = 104 + LinkTypeIEEE802_11 LinkType = 105 + LinkTypeFRelay LinkType = 107 + LinkTypeLoop LinkType = 108 + LinkTypeLinuxSLL LinkType = 113 + LinkTypeLTalk LinkType = 114 + LinkTypePFLog LinkType = 117 + LinkTypePrismHeader LinkType = 119 + LinkTypeIPOverFC LinkType = 122 + LinkTypeSunATM LinkType = 123 + LinkTypeIEEE80211Radio LinkType = 127 + LinkTypeARCNetLinux LinkType = 129 + LinkTypeIPOver1394 LinkType = 138 + LinkTypeMTP2Phdr LinkType = 139 + LinkTypeMTP2 LinkType = 140 + LinkTypeMTP3 LinkType = 141 + LinkTypeSCCP LinkType = 142 + LinkTypeDOCSIS LinkType = 143 + LinkTypeLinuxIRDA LinkType = 144 + LinkTypeLinuxLAPD LinkType = 177 + LinkTypeLinuxUSB LinkType = 220 + LinkTypeIPv4 LinkType = 228 + LinkTypeIPv6 LinkType = 229 +) + +// PPPoECode is the PPPoE code enum, taken from http://tools.ietf.org/html/rfc2516 +type PPPoECode uint8 + +const ( + PPPoECodePADI PPPoECode = 0x09 + PPPoECodePADO PPPoECode = 0x07 + PPPoECodePADR PPPoECode = 0x19 + PPPoECodePADS PPPoECode = 0x65 + PPPoECodePADT PPPoECode = 0xA7 + PPPoECodeSession PPPoECode = 0x00 +) + +// PPPType is an enumeration of PPP type values, and acts as a decoder for any +// type it supports. +type PPPType uint16 + +const ( + PPPTypeIPv4 PPPType = 0x0021 + PPPTypeIPv6 PPPType = 0x0057 + PPPTypeMPLSUnicast PPPType = 0x0281 + PPPTypeMPLSMulticast PPPType = 0x0283 +) + +// SCTPChunkType is an enumeration of chunk types inside SCTP packets. +type SCTPChunkType uint8 + +const ( + SCTPChunkTypeData SCTPChunkType = 0 + SCTPChunkTypeInit SCTPChunkType = 1 + SCTPChunkTypeInitAck SCTPChunkType = 2 + SCTPChunkTypeSack SCTPChunkType = 3 + SCTPChunkTypeHeartbeat SCTPChunkType = 4 + SCTPChunkTypeHeartbeatAck SCTPChunkType = 5 + SCTPChunkTypeAbort SCTPChunkType = 6 + SCTPChunkTypeShutdown SCTPChunkType = 7 + SCTPChunkTypeShutdownAck SCTPChunkType = 8 + SCTPChunkTypeError SCTPChunkType = 9 + SCTPChunkTypeCookieEcho SCTPChunkType = 10 + SCTPChunkTypeCookieAck SCTPChunkType = 11 + SCTPChunkTypeShutdownComplete SCTPChunkType = 14 +) + +// FDDIFrameControl is an enumeration of FDDI frame control bytes. +type FDDIFrameControl uint8 + +const ( + FDDIFrameControlLLC FDDIFrameControl = 0x50 +) + +// EAPOLType is an enumeration of EAPOL packet types. +type EAPOLType uint8 + +const ( + EAPOLTypeEAP EAPOLType = 0 + EAPOLTypeStart EAPOLType = 1 + EAPOLTypeLogOff EAPOLType = 2 + EAPOLTypeKey EAPOLType = 3 + EAPOLTypeASFAlert EAPOLType = 4 +) + +// ProtocolFamily is the set of values defined as PF_* in sys/socket.h +type ProtocolFamily uint8 + +const ( + ProtocolFamilyIPv4 ProtocolFamily = 2 + // BSDs use different values for INET6... glory be. These values taken from + // tcpdump 4.3.0. + ProtocolFamilyIPv6BSD ProtocolFamily = 24 + ProtocolFamilyIPv6FreeBSD ProtocolFamily = 28 + ProtocolFamilyIPv6Darwin ProtocolFamily = 30 + ProtocolFamilyIPv6Linux ProtocolFamily = 10 +) + +// Dot11Type is a combination of IEEE 802.11 frame's Type and Subtype fields. +// By combining these two fields together into a single type, we're able to +// provide a String function that correctly displays the subtype given the +// top-level type. +// +// If you just care about the top-level type, use the MainType function. +type Dot11Type uint8 + +// MainType strips the subtype information from the given type, +// returning just the overarching type (Mgmt, Ctrl, Data, Reserved). +func (d Dot11Type) MainType() Dot11Type { + return d & dot11TypeMask +} + +const ( + Dot11TypeMgmt Dot11Type = 0x00 + Dot11TypeCtrl Dot11Type = 0x01 + Dot11TypeData Dot11Type = 0x02 + Dot11TypeReserved Dot11Type = 0x03 + dot11TypeMask = 0x03 + + // The following are type/subtype conglomerations. + + // Management + Dot11TypeMgmtAssociationReq Dot11Type = 0x00 + Dot11TypeMgmtAssociationResp Dot11Type = 0x04 + Dot11TypeMgmtReassociationReq Dot11Type = 0x08 + Dot11TypeMgmtReassociationResp Dot11Type = 0x0c + Dot11TypeMgmtProbeReq Dot11Type = 0x10 + Dot11TypeMgmtProbeResp Dot11Type = 0x14 + Dot11TypeMgmtMeasurementPilot Dot11Type = 0x18 + Dot11TypeMgmtBeacon Dot11Type = 0x20 + Dot11TypeMgmtATIM Dot11Type = 0x24 + Dot11TypeMgmtDisassociation Dot11Type = 0x28 + Dot11TypeMgmtAuthentication Dot11Type = 0x2c + Dot11TypeMgmtDeauthentication Dot11Type = 0x30 + Dot11TypeMgmtAction Dot11Type = 0x34 + Dot11TypeMgmtActionNoAck Dot11Type = 0x38 + + // Control + Dot11TypeCtrlWrapper Dot11Type = 0x1d + Dot11TypeCtrlBlockAckReq Dot11Type = 0x21 + Dot11TypeCtrlBlockAck Dot11Type = 0x25 + Dot11TypeCtrlPowersavePoll Dot11Type = 0x29 + Dot11TypeCtrlRTS Dot11Type = 0x2d + Dot11TypeCtrlCTS Dot11Type = 0x31 + Dot11TypeCtrlAck Dot11Type = 0x35 + Dot11TypeCtrlCFEnd Dot11Type = 0x39 + Dot11TypeCtrlCFEndAck Dot11Type = 0x3d + + // Data + Dot11TypeDataCFAck Dot11Type = 0x06 + Dot11TypeDataCFPoll Dot11Type = 0x0a + Dot11TypeDataCFAckPoll Dot11Type = 0x0e + Dot11TypeDataNull Dot11Type = 0x12 + Dot11TypeDataCFAckNoData Dot11Type = 0x16 + Dot11TypeDataCFPollNoData Dot11Type = 0x1a + Dot11TypeDataCFAckPollNoData Dot11Type = 0x1e + Dot11TypeDataQOSData Dot11Type = 0x22 + Dot11TypeDataQOSDataCFAck Dot11Type = 0x26 + Dot11TypeDataQOSDataCFPoll Dot11Type = 0x2a + Dot11TypeDataQOSDataCFAckPoll Dot11Type = 0x2e + Dot11TypeDataQOSNull Dot11Type = 0x32 + Dot11TypeDataQOSCFPollNoData Dot11Type = 0x3a + Dot11TypeDataQOSCFAckPollNoData Dot11Type = 0x3e +) + +var ( + // Each of the following arrays contains mappings of how to handle enum + // values for various enum types in gopacket/layers. + // + // So, EthernetTypeMetadata[2] contains information on how to handle EthernetType + // 2, including which name to give it and which decoder to use to decode + // packet data of that type. These arrays are filled by default with all of the + // protocols gopacket/layers knows how to handle, but users of the library can + // add new decoders or override existing ones. For example, if you write a better + // TCP decoder, you can override IPProtocolMetadata[IPProtocolTCP].DecodeWith + // with your new decoder, and all gopacket/layers decoding will use your new + // decoder whenever they encounter that IPProtocol. + EthernetTypeMetadata [65536]EnumMetadata + IPProtocolMetadata [256]EnumMetadata + SCTPChunkTypeMetadata [256]EnumMetadata + PPPTypeMetadata [65536]EnumMetadata + PPPoECodeMetadata [256]EnumMetadata + LinkTypeMetadata [256]EnumMetadata + FDDIFrameControlMetadata [256]EnumMetadata + EAPOLTypeMetadata [256]EnumMetadata + ProtocolFamilyMetadata [256]EnumMetadata + Dot11TypeMetadata [256]EnumMetadata + USBTypeMetadata [256]EnumMetadata +) + +func (a EthernetType) Decode(data []byte, p gopacket.PacketBuilder) error { + return EthernetTypeMetadata[a].DecodeWith.Decode(data, p) +} +func (a EthernetType) String() string { + return EthernetTypeMetadata[a].Name +} +func (a EthernetType) LayerType() gopacket.LayerType { + return EthernetTypeMetadata[a].LayerType +} +func (a IPProtocol) Decode(data []byte, p gopacket.PacketBuilder) error { + return IPProtocolMetadata[a].DecodeWith.Decode(data, p) +} +func (a IPProtocol) String() string { + return IPProtocolMetadata[a].Name +} +func (a IPProtocol) LayerType() gopacket.LayerType { + return IPProtocolMetadata[a].LayerType +} +func (a SCTPChunkType) Decode(data []byte, p gopacket.PacketBuilder) error { + return SCTPChunkTypeMetadata[a].DecodeWith.Decode(data, p) +} +func (a SCTPChunkType) String() string { + return SCTPChunkTypeMetadata[a].Name +} +func (a PPPType) Decode(data []byte, p gopacket.PacketBuilder) error { + return PPPTypeMetadata[a].DecodeWith.Decode(data, p) +} +func (a PPPType) String() string { + return PPPTypeMetadata[a].Name +} +func (a LinkType) Decode(data []byte, p gopacket.PacketBuilder) error { + return LinkTypeMetadata[a].DecodeWith.Decode(data, p) +} +func (a LinkType) String() string { + return LinkTypeMetadata[a].Name +} +func (a PPPoECode) Decode(data []byte, p gopacket.PacketBuilder) error { + return PPPoECodeMetadata[a].DecodeWith.Decode(data, p) +} +func (a PPPoECode) String() string { + return PPPoECodeMetadata[a].Name +} +func (a FDDIFrameControl) Decode(data []byte, p gopacket.PacketBuilder) error { + return FDDIFrameControlMetadata[a].DecodeWith.Decode(data, p) +} +func (a FDDIFrameControl) String() string { + return FDDIFrameControlMetadata[a].Name +} +func (a EAPOLType) Decode(data []byte, p gopacket.PacketBuilder) error { + return EAPOLTypeMetadata[a].DecodeWith.Decode(data, p) +} +func (a EAPOLType) String() string { + return EAPOLTypeMetadata[a].Name +} +func (a EAPOLType) LayerType() gopacket.LayerType { + return EAPOLTypeMetadata[a].LayerType +} +func (a ProtocolFamily) Decode(data []byte, p gopacket.PacketBuilder) error { + return ProtocolFamilyMetadata[a].DecodeWith.Decode(data, p) +} +func (a ProtocolFamily) String() string { + return ProtocolFamilyMetadata[a].Name +} +func (a ProtocolFamily) LayerType() gopacket.LayerType { + return ProtocolFamilyMetadata[a].LayerType +} +func (a Dot11Type) Decode(data []byte, p gopacket.PacketBuilder) error { + return Dot11TypeMetadata[a].DecodeWith.Decode(data, p) +} +func (a Dot11Type) String() string { + return Dot11TypeMetadata[a].Name +} +func (a Dot11Type) LayerType() gopacket.LayerType { + return Dot11TypeMetadata[a].LayerType +} + +// Decode a raw v4 or v6 IP packet. +func decodeIPv4or6(data []byte, p gopacket.PacketBuilder) error { + version := data[0] >> 4 + switch version { + case 4: + return decodeIPv4(data, p) + case 6: + return decodeIPv6(data, p) + } + return fmt.Errorf("Invalid IP packet version %v", version) +} + +func init() { + // Here we link up all enumerations with their respective names and decoders. + for i := 0; i < 65536; i++ { + EthernetTypeMetadata[i] = EnumMetadata{ + DecodeWith: errorFunc(fmt.Sprintf("Unable to decode ethernet type %d", i)), + Name: fmt.Sprintf("UnknownEthernetType(%d)", i), + } + PPPTypeMetadata[i] = EnumMetadata{ + DecodeWith: errorFunc(fmt.Sprintf("Unable to decode PPP type %d", i)), + Name: fmt.Sprintf("UnknownPPPType(%d)", i), + } + } + for i := 0; i < 256; i++ { + IPProtocolMetadata[i] = EnumMetadata{ + DecodeWith: errorFunc(fmt.Sprintf("Unable to decode IP protocol %d", i)), + Name: fmt.Sprintf("UnknownIPProtocol(%d)", i), + } + SCTPChunkTypeMetadata[i] = EnumMetadata{ + DecodeWith: errorFunc(fmt.Sprintf("Unable to decode SCTP chunk type %d", i)), + Name: fmt.Sprintf("UnknownSCTPChunkType(%d)", i), + } + PPPoECodeMetadata[i] = EnumMetadata{ + DecodeWith: errorFunc(fmt.Sprintf("Unable to decode PPPoE code %d", i)), + Name: fmt.Sprintf("UnknownPPPoECode(%d)", i), + } + LinkTypeMetadata[i] = EnumMetadata{ + DecodeWith: errorFunc(fmt.Sprintf("Unable to decode link type %d", i)), + Name: fmt.Sprintf("UnknownLinkType(%d)", i), + } + FDDIFrameControlMetadata[i] = EnumMetadata{ + DecodeWith: errorFunc(fmt.Sprintf("Unable to decode FDDI frame control %d", i)), + Name: fmt.Sprintf("UnknownFDDIFrameControl(%d)", i), + } + EAPOLTypeMetadata[i] = EnumMetadata{ + DecodeWith: errorFunc(fmt.Sprintf("Unable to decode EAPOL type %d", i)), + Name: fmt.Sprintf("UnknownEAPOLType(%d)", i), + } + ProtocolFamilyMetadata[i] = EnumMetadata{ + DecodeWith: errorFunc(fmt.Sprintf("Unable to decode protocol family %d", i)), + Name: fmt.Sprintf("UnknownProtocolFamily(%d)", i), + } + Dot11TypeMetadata[i] = EnumMetadata{ + DecodeWith: errorFunc(fmt.Sprintf("Unable to decode Dot11 type %d", i)), + Name: fmt.Sprintf("UnknownDot11Type(%d)", i), + } + } + + EthernetTypeMetadata[EthernetTypeLLC] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLLC), Name: "LLC", LayerType: LayerTypeLLC} + EthernetTypeMetadata[EthernetTypeIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4} + EthernetTypeMetadata[EthernetTypeIPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} + EthernetTypeMetadata[EthernetTypeARP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeARP), Name: "ARP", LayerType: LayerTypeARP} + EthernetTypeMetadata[EthernetTypeDot1Q] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot1Q), Name: "Dot1Q", LayerType: LayerTypeDot1Q} + EthernetTypeMetadata[EthernetTypePPPoEDiscovery] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPPoE), Name: "PPPoEDiscovery", LayerType: LayerTypePPPoE} + EthernetTypeMetadata[EthernetTypePPPoESession] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPPoE), Name: "PPPoESession", LayerType: LayerTypePPPoE} + EthernetTypeMetadata[EthernetTypeEthernetCTP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEthernetCTP), Name: "EthernetCTP", LayerType: LayerTypeEthernetCTP} + EthernetTypeMetadata[EthernetTypeCiscoDiscovery] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeCiscoDiscovery), Name: "CiscoDiscovery", LayerType: LayerTypeCiscoDiscovery} + EthernetTypeMetadata[EthernetTypeNortelDiscovery] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeNortelDiscovery), Name: "NortelDiscovery", LayerType: LayerTypeNortelDiscovery} + EthernetTypeMetadata[EthernetTypeLinkLayerDiscovery] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLinkLayerDiscovery), Name: "LinkLayerDiscovery", LayerType: LayerTypeLinkLayerDiscovery} + EthernetTypeMetadata[EthernetTypeMPLSUnicast] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLSUnicast", LayerType: LayerTypeMPLS} + EthernetTypeMetadata[EthernetTypeMPLSMulticast] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLSMulticast", LayerType: LayerTypeMPLS} + EthernetTypeMetadata[EthernetTypeEAPOL] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEAPOL), Name: "EAPOL", LayerType: LayerTypeEAPOL} + EthernetTypeMetadata[EthernetTypeQinQ] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot1Q), Name: "Dot1Q", LayerType: LayerTypeDot1Q} + EthernetTypeMetadata[EthernetTypeTransparentEthernetBridging] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEthernet), Name: "TransparentEthernetBridging", LayerType: LayerTypeEthernet} + + IPProtocolMetadata[IPProtocolIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4} + IPProtocolMetadata[IPProtocolTCP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeTCP), Name: "TCP", LayerType: LayerTypeTCP} + IPProtocolMetadata[IPProtocolUDP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUDP), Name: "UDP", LayerType: LayerTypeUDP} + IPProtocolMetadata[IPProtocolICMPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeICMPv4), Name: "ICMPv4", LayerType: LayerTypeICMPv4} + IPProtocolMetadata[IPProtocolICMPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeICMPv6), Name: "ICMPv6", LayerType: LayerTypeICMPv6} + IPProtocolMetadata[IPProtocolSCTP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTP), Name: "SCTP", LayerType: LayerTypeSCTP} + IPProtocolMetadata[IPProtocolIPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} + IPProtocolMetadata[IPProtocolIPIP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4} + IPProtocolMetadata[IPProtocolEtherIP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEtherIP), Name: "EtherIP", LayerType: LayerTypeEtherIP} + IPProtocolMetadata[IPProtocolRUDP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeRUDP), Name: "RUDP", LayerType: LayerTypeRUDP} + IPProtocolMetadata[IPProtocolGRE] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeGRE), Name: "GRE", LayerType: LayerTypeGRE} + IPProtocolMetadata[IPProtocolIPv6HopByHop] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6HopByHop), Name: "IPv6HopByHop", LayerType: LayerTypeIPv6HopByHop} + IPProtocolMetadata[IPProtocolIPv6Routing] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Routing), Name: "IPv6Routing", LayerType: LayerTypeIPv6Routing} + IPProtocolMetadata[IPProtocolIPv6Fragment] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Fragment), Name: "IPv6Fragment", LayerType: LayerTypeIPv6Fragment} + IPProtocolMetadata[IPProtocolIPv6Destination] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Destination), Name: "IPv6Destination", LayerType: LayerTypeIPv6Destination} + IPProtocolMetadata[IPProtocolAH] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPSecAH), Name: "IPSecAH", LayerType: LayerTypeIPSecAH} + IPProtocolMetadata[IPProtocolESP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPSecESP), Name: "IPSecESP", LayerType: LayerTypeIPSecESP} + IPProtocolMetadata[IPProtocolUDPLite] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUDPLite), Name: "UDPLite", LayerType: LayerTypeUDPLite} + IPProtocolMetadata[IPProtocolMPLSInIP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLS", LayerType: LayerTypeMPLS} + IPProtocolMetadata[IPProtocolNoNextHeader] = EnumMetadata{DecodeWith: gopacket.DecodePayload, Name: "NoNextHeader", LayerType: gopacket.LayerTypePayload} + IPProtocolMetadata[IPProtocolIGMP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIGMP), Name: "IGMP", LayerType: LayerTypeIGMP} + IPProtocolMetadata[IPProtocolVRRP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeVRRP), Name: "VRRP", LayerType: LayerTypeVRRP} + + SCTPChunkTypeMetadata[SCTPChunkTypeData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPData), Name: "Data"} + SCTPChunkTypeMetadata[SCTPChunkTypeInit] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPInit), Name: "Init"} + SCTPChunkTypeMetadata[SCTPChunkTypeInitAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPInit), Name: "InitAck"} + SCTPChunkTypeMetadata[SCTPChunkTypeSack] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPSack), Name: "Sack"} + SCTPChunkTypeMetadata[SCTPChunkTypeHeartbeat] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPHeartbeat), Name: "Heartbeat"} + SCTPChunkTypeMetadata[SCTPChunkTypeHeartbeatAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPHeartbeat), Name: "HeartbeatAck"} + SCTPChunkTypeMetadata[SCTPChunkTypeAbort] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPError), Name: "Abort"} + SCTPChunkTypeMetadata[SCTPChunkTypeError] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPError), Name: "Error"} + SCTPChunkTypeMetadata[SCTPChunkTypeShutdown] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPShutdown), Name: "Shutdown"} + SCTPChunkTypeMetadata[SCTPChunkTypeShutdownAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPShutdownAck), Name: "ShutdownAck"} + SCTPChunkTypeMetadata[SCTPChunkTypeCookieEcho] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPCookieEcho), Name: "CookieEcho"} + SCTPChunkTypeMetadata[SCTPChunkTypeCookieAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPEmptyLayer), Name: "CookieAck"} + SCTPChunkTypeMetadata[SCTPChunkTypeShutdownComplete] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPEmptyLayer), Name: "ShutdownComplete"} + + PPPTypeMetadata[PPPTypeIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4"} + PPPTypeMetadata[PPPTypeIPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6"} + PPPTypeMetadata[PPPTypeMPLSUnicast] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLSUnicast"} + PPPTypeMetadata[PPPTypeMPLSMulticast] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLSMulticast"} + + PPPoECodeMetadata[PPPoECodeSession] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPP), Name: "PPP"} + + LinkTypeMetadata[LinkTypeEthernet] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEthernet), Name: "Ethernet"} + LinkTypeMetadata[LinkTypePPP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPP), Name: "PPP"} + LinkTypeMetadata[LinkTypeFDDI] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeFDDI), Name: "FDDI"} + LinkTypeMetadata[LinkTypeNull] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLoopback), Name: "Null"} + LinkTypeMetadata[LinkTypeIEEE802_11] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11), Name: "Dot11"} + LinkTypeMetadata[LinkTypeLoop] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLoopback), Name: "Loop"} + LinkTypeMetadata[LinkTypeIEEE802_11] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11), Name: "802.11"} + LinkTypeMetadata[LinkTypeRaw] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4or6), Name: "Raw"} + LinkTypeMetadata[LinkTypePFLog] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePFLog), Name: "PFLog"} + LinkTypeMetadata[LinkTypeIEEE80211Radio] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeRadioTap), Name: "RadioTap"} + LinkTypeMetadata[LinkTypeLinuxUSB] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSB), Name: "USB"} + LinkTypeMetadata[LinkTypeLinuxSLL] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLinuxSLL), Name: "Linux SLL"} + LinkTypeMetadata[LinkTypePrismHeader] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePrismHeader), Name: "Prism"} + + FDDIFrameControlMetadata[FDDIFrameControlLLC] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLLC), Name: "LLC"} + + EAPOLTypeMetadata[EAPOLTypeEAP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEAP), Name: "EAP", LayerType: LayerTypeEAP} + + ProtocolFamilyMetadata[ProtocolFamilyIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4} + ProtocolFamilyMetadata[ProtocolFamilyIPv6BSD] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} + ProtocolFamilyMetadata[ProtocolFamilyIPv6FreeBSD] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} + ProtocolFamilyMetadata[ProtocolFamilyIPv6Darwin] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} + ProtocolFamilyMetadata[ProtocolFamilyIPv6Linux] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} + + Dot11TypeMetadata[Dot11TypeMgmtAssociationReq] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtAssociationReq), Name: "MgmtAssociationReq", LayerType: LayerTypeDot11MgmtAssociationReq} + Dot11TypeMetadata[Dot11TypeMgmtAssociationResp] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtAssociationResp), Name: "MgmtAssociationResp", LayerType: LayerTypeDot11MgmtAssociationResp} + Dot11TypeMetadata[Dot11TypeMgmtReassociationReq] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtReassociationReq), Name: "MgmtReassociationReq", LayerType: LayerTypeDot11MgmtReassociationReq} + Dot11TypeMetadata[Dot11TypeMgmtReassociationResp] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtReassociationResp), Name: "MgmtReassociationResp", LayerType: LayerTypeDot11MgmtReassociationResp} + Dot11TypeMetadata[Dot11TypeMgmtProbeReq] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtProbeReq), Name: "MgmtProbeReq", LayerType: LayerTypeDot11MgmtProbeReq} + Dot11TypeMetadata[Dot11TypeMgmtProbeResp] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtProbeResp), Name: "MgmtProbeResp", LayerType: LayerTypeDot11MgmtProbeResp} + Dot11TypeMetadata[Dot11TypeMgmtMeasurementPilot] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtMeasurementPilot), Name: "MgmtMeasurementPilot", LayerType: LayerTypeDot11MgmtMeasurementPilot} + Dot11TypeMetadata[Dot11TypeMgmtBeacon] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtBeacon), Name: "MgmtBeacon", LayerType: LayerTypeDot11MgmtBeacon} + Dot11TypeMetadata[Dot11TypeMgmtATIM] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtATIM), Name: "MgmtATIM", LayerType: LayerTypeDot11MgmtATIM} + Dot11TypeMetadata[Dot11TypeMgmtDisassociation] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtDisassociation), Name: "MgmtDisassociation", LayerType: LayerTypeDot11MgmtDisassociation} + Dot11TypeMetadata[Dot11TypeMgmtAuthentication] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtAuthentication), Name: "MgmtAuthentication", LayerType: LayerTypeDot11MgmtAuthentication} + Dot11TypeMetadata[Dot11TypeMgmtDeauthentication] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtDeauthentication), Name: "MgmtDeauthentication", LayerType: LayerTypeDot11MgmtDeauthentication} + Dot11TypeMetadata[Dot11TypeMgmtAction] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtAction), Name: "MgmtAction", LayerType: LayerTypeDot11MgmtAction} + Dot11TypeMetadata[Dot11TypeMgmtActionNoAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtActionNoAck), Name: "MgmtActionNoAck", LayerType: LayerTypeDot11MgmtActionNoAck} + Dot11TypeMetadata[Dot11TypeCtrl] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11Ctrl), Name: "Ctrl", LayerType: LayerTypeDot11Ctrl} + Dot11TypeMetadata[Dot11TypeCtrlWrapper] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11Ctrl), Name: "CtrlWrapper", LayerType: LayerTypeDot11Ctrl} + Dot11TypeMetadata[Dot11TypeCtrlBlockAckReq] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlBlockAckReq), Name: "CtrlBlockAckReq", LayerType: LayerTypeDot11CtrlBlockAckReq} + Dot11TypeMetadata[Dot11TypeCtrlBlockAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlBlockAck), Name: "CtrlBlockAck", LayerType: LayerTypeDot11CtrlBlockAck} + Dot11TypeMetadata[Dot11TypeCtrlPowersavePoll] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlPowersavePoll), Name: "CtrlPowersavePoll", LayerType: LayerTypeDot11CtrlPowersavePoll} + Dot11TypeMetadata[Dot11TypeCtrlRTS] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlRTS), Name: "CtrlRTS", LayerType: LayerTypeDot11CtrlRTS} + Dot11TypeMetadata[Dot11TypeCtrlCTS] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlCTS), Name: "CtrlCTS", LayerType: LayerTypeDot11CtrlCTS} + Dot11TypeMetadata[Dot11TypeCtrlAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlAck), Name: "CtrlAck", LayerType: LayerTypeDot11CtrlAck} + Dot11TypeMetadata[Dot11TypeCtrlCFEnd] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlCFEnd), Name: "CtrlCFEnd", LayerType: LayerTypeDot11CtrlCFEnd} + Dot11TypeMetadata[Dot11TypeCtrlCFEndAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlCFEndAck), Name: "CtrlCFEndAck", LayerType: LayerTypeDot11CtrlCFEndAck} + Dot11TypeMetadata[Dot11TypeData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11Data), Name: "Data", LayerType: LayerTypeDot11Data} + Dot11TypeMetadata[Dot11TypeDataCFAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataCFAck), Name: "DataCFAck", LayerType: LayerTypeDot11DataCFAck} + Dot11TypeMetadata[Dot11TypeDataCFPoll] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataCFPoll), Name: "DataCFPoll", LayerType: LayerTypeDot11DataCFPoll} + Dot11TypeMetadata[Dot11TypeDataCFAckPoll] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataCFAckPoll), Name: "DataCFAckPoll", LayerType: LayerTypeDot11DataCFAckPoll} + Dot11TypeMetadata[Dot11TypeDataNull] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataNull), Name: "DataNull", LayerType: LayerTypeDot11DataNull} + Dot11TypeMetadata[Dot11TypeDataCFAckNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataCFAckNoData), Name: "DataCFAckNoData", LayerType: LayerTypeDot11DataCFAckNoData} + Dot11TypeMetadata[Dot11TypeDataCFPollNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataCFPollNoData), Name: "DataCFPollNoData", LayerType: LayerTypeDot11DataCFPollNoData} + Dot11TypeMetadata[Dot11TypeDataCFAckPollNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataCFAckPollNoData), Name: "DataCFAckPollNoData", LayerType: LayerTypeDot11DataCFAckPollNoData} + Dot11TypeMetadata[Dot11TypeDataQOSData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSData), Name: "DataQOSData", LayerType: LayerTypeDot11DataQOSData} + Dot11TypeMetadata[Dot11TypeDataQOSDataCFAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSDataCFAck), Name: "DataQOSDataCFAck", LayerType: LayerTypeDot11DataQOSDataCFAck} + Dot11TypeMetadata[Dot11TypeDataQOSDataCFPoll] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSDataCFPoll), Name: "DataQOSDataCFPoll", LayerType: LayerTypeDot11DataQOSDataCFPoll} + Dot11TypeMetadata[Dot11TypeDataQOSDataCFAckPoll] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSDataCFAckPoll), Name: "DataQOSDataCFAckPoll", LayerType: LayerTypeDot11DataQOSDataCFAckPoll} + Dot11TypeMetadata[Dot11TypeDataQOSNull] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSNull), Name: "DataQOSNull", LayerType: LayerTypeDot11DataQOSNull} + Dot11TypeMetadata[Dot11TypeDataQOSCFPollNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSCFPollNoData), Name: "DataQOSCFPollNoData", LayerType: LayerTypeDot11DataQOSCFPollNoData} + Dot11TypeMetadata[Dot11TypeDataQOSCFAckPollNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSCFAckPollNoData), Name: "DataQOSCFAckPollNoData", LayerType: LayerTypeDot11DataQOSCFAckPollNoData} + + USBTypeMetadata[USBTransportTypeInterrupt] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBInterrupt), Name: "Interrupt", LayerType: LayerTypeUSBInterrupt} + USBTypeMetadata[USBTransportTypeControl] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBControl), Name: "Control", LayerType: LayerTypeUSBControl} + USBTypeMetadata[USBTransportTypeBulk] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBBulk), Name: "Bulk", LayerType: LayerTypeUSBBulk} +} diff --git a/vendor/github.com/google/gopacket/layers/etherip.go b/vendor/github.com/google/gopacket/layers/etherip.go new file mode 100644 index 0000000..5b7b722 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/etherip.go @@ -0,0 +1,45 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "github.com/google/gopacket" +) + +// EtherIP is the struct for storing RFC 3378 EtherIP packet headers. +type EtherIP struct { + BaseLayer + Version uint8 + Reserved uint16 +} + +// LayerType returns gopacket.LayerTypeEtherIP. +func (e *EtherIP) LayerType() gopacket.LayerType { return LayerTypeEtherIP } + +// DecodeFromBytes decodes the given bytes into this layer. +func (e *EtherIP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + e.Version = data[0] >> 4 + e.Reserved = binary.BigEndian.Uint16(data[:2]) & 0x0fff + e.BaseLayer = BaseLayer{data[:2], data[2:]} + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (e *EtherIP) CanDecode() gopacket.LayerClass { + return LayerTypeEtherIP +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (e *EtherIP) NextLayerType() gopacket.LayerType { + return LayerTypeEthernet +} + +func decodeEtherIP(data []byte, p gopacket.PacketBuilder) error { + e := &EtherIP{} + return decodingLayerDecoder(e, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/ethernet.go b/vendor/github.com/google/gopacket/layers/ethernet.go new file mode 100644 index 0000000..115fd27 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/ethernet.go @@ -0,0 +1,122 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "fmt" + "github.com/google/gopacket" + "net" +) + +// EthernetBroadcast is the broadcast MAC address used by Ethernet. +var EthernetBroadcast = net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff} + +// Ethernet is the layer for Ethernet frame headers. +type Ethernet struct { + BaseLayer + SrcMAC, DstMAC net.HardwareAddr + EthernetType EthernetType + // Length is only set if a length field exists within this header. Ethernet + // headers follow two different standards, one that uses an EthernetType, the + // other which defines a length the follows with a LLC header (802.3). If the + // former is the case, we set EthernetType and Length stays 0. In the latter + // case, we set Length and EthernetType = EthernetTypeLLC. + Length uint16 +} + +// LayerType returns LayerTypeEthernet +func (e *Ethernet) LayerType() gopacket.LayerType { return LayerTypeEthernet } + +func (e *Ethernet) LinkFlow() gopacket.Flow { + return gopacket.NewFlow(EndpointMAC, e.SrcMAC, e.DstMAC) +} + +func (eth *Ethernet) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 14 { + return errors.New("Ethernet packet too small") + } + eth.DstMAC = net.HardwareAddr(data[0:6]) + eth.SrcMAC = net.HardwareAddr(data[6:12]) + eth.EthernetType = EthernetType(binary.BigEndian.Uint16(data[12:14])) + eth.BaseLayer = BaseLayer{data[:14], data[14:]} + if eth.EthernetType < 0x0600 { + eth.Length = uint16(eth.EthernetType) + eth.EthernetType = EthernetTypeLLC + if cmp := len(eth.Payload) - int(eth.Length); cmp < 0 { + df.SetTruncated() + } else if cmp > 0 { + // Strip off bytes at the end, since we have too many bytes + eth.Payload = eth.Payload[:len(eth.Payload)-cmp] + } + // fmt.Println(eth) + } + return nil +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (eth *Ethernet) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + if len(eth.DstMAC) != 6 { + return fmt.Errorf("invalid dst MAC: %v", eth.DstMAC) + } + if len(eth.SrcMAC) != 6 { + return fmt.Errorf("invalid src MAC: %v", eth.SrcMAC) + } + payload := b.Bytes() + bytes, err := b.PrependBytes(14) + if err != nil { + return err + } + copy(bytes, eth.DstMAC) + copy(bytes[6:], eth.SrcMAC) + if eth.Length != 0 || eth.EthernetType == EthernetTypeLLC { + if opts.FixLengths { + eth.Length = uint16(len(payload)) + } + if eth.EthernetType != EthernetTypeLLC { + return fmt.Errorf("ethernet type %v not compatible with length value %v", eth.EthernetType, eth.Length) + } else if eth.Length > 0x0600 { + return fmt.Errorf("invalid ethernet length %v", eth.Length) + } + binary.BigEndian.PutUint16(bytes[12:], eth.Length) + } else { + binary.BigEndian.PutUint16(bytes[12:], uint16(eth.EthernetType)) + } + length := len(b.Bytes()) + if length < 60 { + // Pad out to 60 bytes. + padding, err := b.AppendBytes(60 - length) + if err != nil { + return err + } + copy(padding, lotsOfZeros[:]) + } + return nil +} + +func (eth *Ethernet) CanDecode() gopacket.LayerClass { + return LayerTypeEthernet +} + +func (eth *Ethernet) NextLayerType() gopacket.LayerType { + return eth.EthernetType.LayerType() +} + +func decodeEthernet(data []byte, p gopacket.PacketBuilder) error { + eth := &Ethernet{} + err := eth.DecodeFromBytes(data, p) + if err != nil { + return err + } + p.AddLayer(eth) + p.SetLinkLayer(eth) + return p.NextDecoder(eth.EthernetType) +} diff --git a/vendor/github.com/google/gopacket/layers/fddi.go b/vendor/github.com/google/gopacket/layers/fddi.go new file mode 100644 index 0000000..ed9e195 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/fddi.go @@ -0,0 +1,41 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "github.com/google/gopacket" + "net" +) + +// FDDI contains the header for FDDI frames. +type FDDI struct { + BaseLayer + FrameControl FDDIFrameControl + Priority uint8 + SrcMAC, DstMAC net.HardwareAddr +} + +// LayerType returns LayerTypeFDDI. +func (f *FDDI) LayerType() gopacket.LayerType { return LayerTypeFDDI } + +// LinkFlow returns a new flow of type EndpointMAC. +func (f *FDDI) LinkFlow() gopacket.Flow { + return gopacket.NewFlow(EndpointMAC, f.SrcMAC, f.DstMAC) +} + +func decodeFDDI(data []byte, p gopacket.PacketBuilder) error { + f := &FDDI{ + FrameControl: FDDIFrameControl(data[0] & 0xF8), + Priority: data[0] & 0x07, + SrcMAC: net.HardwareAddr(data[1:7]), + DstMAC: net.HardwareAddr(data[7:13]), + BaseLayer: BaseLayer{data[:13], data[13:]}, + } + p.SetLinkLayer(f) + p.AddLayer(f) + return p.NextDecoder(f.FrameControl) +} diff --git a/vendor/github.com/google/gopacket/layers/gen.go b/vendor/github.com/google/gopacket/layers/gen.go new file mode 100644 index 0000000..ab7a0c0 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/gen.go @@ -0,0 +1,109 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +// +build ignore + +// This binary pulls known ports from IANA, and uses them to populate +// iana_ports.go's TCPPortNames and UDPPortNames maps. +// +// go run gen.go | gofmt > iana_ports.go +package main + +import ( + "bytes" + "encoding/xml" + "flag" + "fmt" + "io/ioutil" + "net/http" + "os" + "strconv" + "time" +) + +const fmtString = `// Copyright 2012 Google, Inc. All rights reserved. + +package layers + +// Created by gen.go, don't edit manually +// Generated at %s +// Fetched from %q + +// TCPPortNames contains the port names for all TCP ports. +var TCPPortNames = tcpPortNames + +// UDPPortNames contains the port names for all UDP ports. +var UDPPortNames = udpPortNames + +// SCTPPortNames contains the port names for all SCTP ports. +var SCTPPortNames = sctpPortNames + +var tcpPortNames = map[TCPPort]string{ +%s} +var udpPortNames = map[UDPPort]string{ +%s} +var sctpPortNames = map[SCTPPort]string{ +%s} +` + +var url = flag.String("url", "http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml", "URL to grab port numbers from") + +func main() { + fmt.Fprintf(os.Stderr, "Fetching ports from %q\n", *url) + resp, err := http.Get(*url) + if err != nil { + panic(err) + } + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + panic(err) + } + fmt.Fprintln(os.Stderr, "Parsing XML") + var registry struct { + Records []struct { + Protocol string `xml:"protocol"` + Number string `xml:"number"` + Name string `xml:"name"` + } `xml:"record"` + } + xml.Unmarshal(body, ®istry) + var tcpPorts bytes.Buffer + var udpPorts bytes.Buffer + var sctpPorts bytes.Buffer + done := map[string]map[int]bool{ + "tcp": map[int]bool{}, + "udp": map[int]bool{}, + "sctp": map[int]bool{}, + } + for _, r := range registry.Records { + port, err := strconv.Atoi(r.Number) + if err != nil { + continue + } + if r.Name == "" { + continue + } + var b *bytes.Buffer + switch r.Protocol { + case "tcp": + b = &tcpPorts + case "udp": + b = &udpPorts + case "sctp": + b = &sctpPorts + default: + continue + } + if done[r.Protocol][port] { + continue + } + done[r.Protocol][port] = true + fmt.Fprintf(b, "\t%d: %q,\n", port, r.Name) + } + fmt.Fprintln(os.Stderr, "Writing results to stdout") + fmt.Printf(fmtString, time.Now(), *url, tcpPorts.String(), udpPorts.String(), sctpPorts.String()) +} diff --git a/vendor/github.com/google/gopacket/layers/gen_linted.sh b/vendor/github.com/google/gopacket/layers/gen_linted.sh new file mode 100644 index 0000000..75c701f --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/gen_linted.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +for i in *.go; do golint $i | grep -q . || echo $i; done > .linted diff --git a/vendor/github.com/google/gopacket/layers/geneve.go b/vendor/github.com/google/gopacket/layers/geneve.go new file mode 100644 index 0000000..6dc05cf --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/geneve.go @@ -0,0 +1,98 @@ +// Copyright 2016 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + + "github.com/google/gopacket" +) + +// Geneve is specifed here https://tools.ietf.org/html/draft-ietf-nvo3-geneve-03 +// Geneve Header: +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// |Ver| Opt Len |O|C| Rsvd. | Protocol Type | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Virtual Network Identifier (VNI) | Reserved | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Variable Length Options | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +type Geneve struct { + BaseLayer + Version uint8 // 2 bits + OptionsLength uint8 // 6 bits + OAMPacket bool // 1 bits + CriticalOption bool // 1 bits + Protocol EthernetType // 16 bits + VNI uint32 // 24bits + Options []*GeneveOption +} + +// Geneve Tunnel Options +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Option Class | Type |R|R|R| Length | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Variable Option Data | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +type GeneveOption struct { + Class uint16 // 16 bits + Type uint8 // 8 bits + Flags uint8 // 3 bits + Length uint8 // 5 bits + Data []byte +} + +// LayerType returns LayerTypeGeneve +func (gn *Geneve) LayerType() gopacket.LayerType { return LayerTypeGeneve } + +func decodeGeneveOption(data []byte, gn *Geneve) (*GeneveOption, uint8) { + opt := &GeneveOption{} + + opt.Class = binary.BigEndian.Uint16(data[0:1]) + opt.Type = data[2] + opt.Flags = data[3] >> 4 + opt.Length = data[3] & 0xf + + copy(opt.Data, data[4:opt.Length]) + + return opt, 4 + opt.Length +} + +func (gn *Geneve) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + gn.Version = data[0] >> 7 + gn.OptionsLength = data[0] & 0x3f + + gn.OAMPacket = data[1]&0x80 > 0 + gn.CriticalOption = data[1]&0x40 > 0 + gn.Protocol = EthernetType(binary.BigEndian.Uint16(data[2:4])) + + var buf [4]byte + copy(buf[1:], data[4:7]) + gn.VNI = binary.BigEndian.Uint32(buf[:]) + + offset, length := uint8(8), gn.OptionsLength + for length > 0 { + opt, len := decodeGeneveOption(data[offset:], gn) + gn.Options = append(gn.Options, opt) + + length -= len + offset += len + } + + gn.BaseLayer = BaseLayer{data[:offset], data[offset:]} + + return nil +} + +func (gn *Geneve) NextLayerType() gopacket.LayerType { + return gn.Protocol.LayerType() +} + +func decodeGeneve(data []byte, p gopacket.PacketBuilder) error { + gn := &Geneve{} + return decodingLayerDecoder(gn, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/gre.go b/vendor/github.com/google/gopacket/layers/gre.go new file mode 100644 index 0000000..15d5290 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/gre.go @@ -0,0 +1,185 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + + "github.com/google/gopacket" +) + +// GRE is a Generic Routing Encapsulation header. +type GRE struct { + BaseLayer + ChecksumPresent, RoutingPresent, KeyPresent, SeqPresent, StrictSourceRoute bool + RecursionControl, Flags, Version uint8 + Protocol EthernetType + Checksum, Offset uint16 + Key, Seq uint32 + *GRERouting +} + +// GRERouting is GRE routing information, present if the RoutingPresent flag is +// set. +type GRERouting struct { + AddressFamily uint16 + SREOffset, SRELength uint8 + RoutingInformation []byte + Next *GRERouting +} + +// LayerType returns gopacket.LayerTypeGRE. +func (g *GRE) LayerType() gopacket.LayerType { return LayerTypeGRE } + +// DecodeFromBytes decodes the given bytes into this layer. +func (g *GRE) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + g.ChecksumPresent = data[0]&0x80 != 0 + g.RoutingPresent = data[0]&0x40 != 0 + g.KeyPresent = data[0]&0x20 != 0 + g.SeqPresent = data[0]&0x10 != 0 + g.StrictSourceRoute = data[0]&0x08 != 0 + g.RecursionControl = data[0] & 0x7 + g.Flags = data[1] >> 3 + g.Version = data[1] & 0x7 + g.Protocol = EthernetType(binary.BigEndian.Uint16(data[2:4])) + offset := 4 + if g.ChecksumPresent || g.RoutingPresent { + g.Checksum = binary.BigEndian.Uint16(data[offset : offset+2]) + g.Offset = binary.BigEndian.Uint16(data[offset+2 : offset+4]) + offset += 4 + } + if g.KeyPresent { + g.Key = binary.BigEndian.Uint32(data[offset : offset+4]) + offset += 4 + } + if g.SeqPresent { + g.Seq = binary.BigEndian.Uint32(data[offset : offset+4]) + offset += 4 + } + if g.RoutingPresent { + tail := &g.GRERouting + for { + sre := &GRERouting{ + AddressFamily: binary.BigEndian.Uint16(data[offset : offset+2]), + SREOffset: data[offset+2], + SRELength: data[offset+3], + } + sre.RoutingInformation = data[offset+4 : offset+4+int(sre.SRELength)] + offset += 4 + int(sre.SRELength) + if sre.AddressFamily == 0 && sre.SRELength == 0 { + break + } + (*tail) = sre + tail = &sre.Next + } + } + g.BaseLayer = BaseLayer{data[:offset], data[offset:]} + return nil +} + +// SerializeTo writes the serialized form of this layer into the SerializationBuffer, +// implementing gopacket.SerializableLayer. See the docs for gopacket.SerializableLayer for more info. +func (g *GRE) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + size := 4 + if g.ChecksumPresent || g.RoutingPresent { + size += 4 + } + if g.KeyPresent { + size += 4 + } + if g.SeqPresent { + size += 4 + } + if g.RoutingPresent { + r := g.GRERouting + for r != nil { + size += 4 + int(r.SRELength) + r = r.Next + } + size += 4 + } + buf, err := b.PrependBytes(size) + if err != nil { + return err + } + // Reset any potentially dirty memory in the first 2 bytes, as these use OR to set flags. + buf[0] = 0 + buf[1] = 0 + if g.ChecksumPresent { + buf[0] |= 0x80 + } + if g.RoutingPresent { + buf[0] |= 0x40 + } + if g.KeyPresent { + buf[0] |= 0x20 + } + if g.SeqPresent { + buf[0] |= 0x10 + } + if g.StrictSourceRoute { + buf[0] |= 0x08 + } + buf[0] |= g.RecursionControl + buf[1] |= g.Flags << 3 + buf[1] |= g.Version + binary.BigEndian.PutUint16(buf[2:4], uint16(g.Protocol)) + offset := 4 + if g.ChecksumPresent || g.RoutingPresent { + // Don't write the checksum value yet, as we may need to compute it, + // which requires the entire header be complete. + // Instead we zeroize the memory in case it is dirty. + buf[offset] = 0 + buf[offset+1] = 0 + binary.BigEndian.PutUint16(buf[offset+2:offset+4], g.Offset) + offset += 4 + } + if g.KeyPresent { + binary.BigEndian.PutUint32(buf[offset:offset+4], g.Key) + offset += 4 + } + if g.SeqPresent { + binary.BigEndian.PutUint32(buf[offset:offset+4], g.Seq) + offset += 4 + } + if g.RoutingPresent { + sre := g.GRERouting + for sre != nil { + binary.BigEndian.PutUint16(buf[offset:offset+2], sre.AddressFamily) + buf[offset+2] = sre.SREOffset + buf[offset+3] = sre.SRELength + copy(buf[offset+4:offset+4+int(sre.SRELength)], sre.RoutingInformation) + offset += 4 + int(sre.SRELength) + sre = sre.Next + } + // Terminate routing field with a "NULL" SRE. + binary.BigEndian.PutUint32(buf[offset:offset+4], 0) + } + if g.ChecksumPresent { + if opts.ComputeChecksums { + g.Checksum = tcpipChecksum(b.Bytes(), 0) + } + + binary.BigEndian.PutUint16(buf[4:6], g.Checksum) + } + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (g *GRE) CanDecode() gopacket.LayerClass { + return LayerTypeGRE +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (g *GRE) NextLayerType() gopacket.LayerType { + return g.Protocol.LayerType() +} + +func decodeGRE(data []byte, p gopacket.PacketBuilder) error { + g := &GRE{} + return decodingLayerDecoder(g, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/iana_ports.go b/vendor/github.com/google/gopacket/layers/iana_ports.go new file mode 100644 index 0000000..5440635 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/iana_ports.go @@ -0,0 +1,11314 @@ +// Copyright 2012 Google, Inc. All rights reserved. + +package layers + +// Created by gen.go, don't edit manually +// Generated at 2017-01-04 15:05:26.649794815 -0700 MST +// Fetched from "http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml" + +// TCPPortNames contains the port names for all TCP ports. +var TCPPortNames = tcpPortNames + +// UDPPortNames contains the port names for all UDP ports. +var UDPPortNames = udpPortNames + +// SCTPPortNames contains the port names for all SCTP ports. +var SCTPPortNames = sctpPortNames + +var tcpPortNames = map[TCPPort]string{ + 1: "tcpmux", + 2: "compressnet", + 3: "compressnet", + 5: "rje", + 7: "echo", + 9: "discard", + 11: "systat", + 13: "daytime", + 17: "qotd", + 18: "msp", + 19: "chargen", + 20: "ftp-data", + 21: "ftp", + 22: "ssh", + 23: "telnet", + 25: "smtp", + 27: "nsw-fe", + 29: "msg-icp", + 31: "msg-auth", + 33: "dsp", + 37: "time", + 38: "rap", + 39: "rlp", + 41: "graphics", + 42: "name", + 43: "nicname", + 44: "mpm-flags", + 45: "mpm", + 46: "mpm-snd", + 47: "ni-ftp", + 48: "auditd", + 49: "tacacs", + 50: "re-mail-ck", + 52: "xns-time", + 53: "domain", + 54: "xns-ch", + 55: "isi-gl", + 56: "xns-auth", + 58: "xns-mail", + 61: "ni-mail", + 62: "acas", + 63: "whoispp", + 64: "covia", + 65: "tacacs-ds", + 66: "sql-net", + 67: "bootps", + 68: "bootpc", + 69: "tftp", + 70: "gopher", + 71: "netrjs-1", + 72: "netrjs-2", + 73: "netrjs-3", + 74: "netrjs-4", + 76: "deos", + 78: "vettcp", + 79: "finger", + 80: "http", + 82: "xfer", + 83: "mit-ml-dev", + 84: "ctf", + 85: "mit-ml-dev", + 86: "mfcobol", + 88: "kerberos", + 89: "su-mit-tg", + 90: "dnsix", + 91: "mit-dov", + 92: "npp", + 93: "dcp", + 94: "objcall", + 95: "supdup", + 96: "dixie", + 97: "swift-rvf", + 98: "tacnews", + 99: "metagram", + 101: "hostname", + 102: "iso-tsap", + 103: "gppitnp", + 104: "acr-nema", + 105: "cso", + 106: "3com-tsmux", + 107: "rtelnet", + 108: "snagas", + 109: "pop2", + 110: "pop3", + 111: "sunrpc", + 112: "mcidas", + 113: "ident", + 115: "sftp", + 116: "ansanotify", + 117: "uucp-path", + 118: "sqlserv", + 119: "nntp", + 120: "cfdptkt", + 121: "erpc", + 122: "smakynet", + 123: "ntp", + 124: "ansatrader", + 125: "locus-map", + 126: "nxedit", + 127: "locus-con", + 128: "gss-xlicen", + 129: "pwdgen", + 130: "cisco-fna", + 131: "cisco-tna", + 132: "cisco-sys", + 133: "statsrv", + 134: "ingres-net", + 135: "epmap", + 136: "profile", + 137: "netbios-ns", + 138: "netbios-dgm", + 139: "netbios-ssn", + 140: "emfis-data", + 141: "emfis-cntl", + 142: "bl-idm", + 143: "imap", + 144: "uma", + 145: "uaac", + 146: "iso-tp0", + 147: "iso-ip", + 148: "jargon", + 149: "aed-512", + 150: "sql-net", + 151: "hems", + 152: "bftp", + 153: "sgmp", + 154: "netsc-prod", + 155: "netsc-dev", + 156: "sqlsrv", + 157: "knet-cmp", + 158: "pcmail-srv", + 159: "nss-routing", + 160: "sgmp-traps", + 161: "snmp", + 162: "snmptrap", + 163: "cmip-man", + 164: "cmip-agent", + 165: "xns-courier", + 166: "s-net", + 167: "namp", + 168: "rsvd", + 169: "send", + 170: "print-srv", + 171: "multiplex", + 172: "cl-1", + 173: "xyplex-mux", + 174: "mailq", + 175: "vmnet", + 176: "genrad-mux", + 177: "xdmcp", + 178: "nextstep", + 179: "bgp", + 180: "ris", + 181: "unify", + 182: "audit", + 183: "ocbinder", + 184: "ocserver", + 185: "remote-kis", + 186: "kis", + 187: "aci", + 188: "mumps", + 189: "qft", + 190: "gacp", + 191: "prospero", + 192: "osu-nms", + 193: "srmp", + 194: "irc", + 195: "dn6-nlm-aud", + 196: "dn6-smm-red", + 197: "dls", + 198: "dls-mon", + 199: "smux", + 200: "src", + 201: "at-rtmp", + 202: "at-nbp", + 203: "at-3", + 204: "at-echo", + 205: "at-5", + 206: "at-zis", + 207: "at-7", + 208: "at-8", + 209: "qmtp", + 210: "z39-50", + 211: "914c-g", + 212: "anet", + 213: "ipx", + 214: "vmpwscs", + 215: "softpc", + 216: "CAIlic", + 217: "dbase", + 218: "mpp", + 219: "uarps", + 220: "imap3", + 221: "fln-spx", + 222: "rsh-spx", + 223: "cdc", + 224: "masqdialer", + 242: "direct", + 243: "sur-meas", + 244: "inbusiness", + 245: "link", + 246: "dsp3270", + 247: "subntbcst-tftp", + 248: "bhfhs", + 256: "rap", + 257: "set", + 259: "esro-gen", + 260: "openport", + 261: "nsiiops", + 262: "arcisdms", + 263: "hdap", + 264: "bgmp", + 265: "x-bone-ctl", + 266: "sst", + 267: "td-service", + 268: "td-replica", + 269: "manet", + 271: "pt-tls", + 280: "http-mgmt", + 281: "personal-link", + 282: "cableport-ax", + 283: "rescap", + 284: "corerjd", + 286: "fxp", + 287: "k-block", + 308: "novastorbakcup", + 309: "entrusttime", + 310: "bhmds", + 311: "asip-webadmin", + 312: "vslmp", + 313: "magenta-logic", + 314: "opalis-robot", + 315: "dpsi", + 316: "decauth", + 317: "zannet", + 318: "pkix-timestamp", + 319: "ptp-event", + 320: "ptp-general", + 321: "pip", + 322: "rtsps", + 323: "rpki-rtr", + 324: "rpki-rtr-tls", + 333: "texar", + 344: "pdap", + 345: "pawserv", + 346: "zserv", + 347: "fatserv", + 348: "csi-sgwp", + 349: "mftp", + 350: "matip-type-a", + 351: "matip-type-b", + 352: "dtag-ste-sb", + 353: "ndsauth", + 354: "bh611", + 355: "datex-asn", + 356: "cloanto-net-1", + 357: "bhevent", + 358: "shrinkwrap", + 359: "nsrmp", + 360: "scoi2odialog", + 361: "semantix", + 362: "srssend", + 363: "rsvp-tunnel", + 364: "aurora-cmgr", + 365: "dtk", + 366: "odmr", + 367: "mortgageware", + 368: "qbikgdp", + 369: "rpc2portmap", + 370: "codaauth2", + 371: "clearcase", + 372: "ulistproc", + 373: "legent-1", + 374: "legent-2", + 375: "hassle", + 376: "nip", + 377: "tnETOS", + 378: "dsETOS", + 379: "is99c", + 380: "is99s", + 381: "hp-collector", + 382: "hp-managed-node", + 383: "hp-alarm-mgr", + 384: "arns", + 385: "ibm-app", + 386: "asa", + 387: "aurp", + 388: "unidata-ldm", + 389: "ldap", + 390: "uis", + 391: "synotics-relay", + 392: "synotics-broker", + 393: "meta5", + 394: "embl-ndt", + 395: "netcp", + 396: "netware-ip", + 397: "mptn", + 398: "kryptolan", + 399: "iso-tsap-c2", + 400: "osb-sd", + 401: "ups", + 402: "genie", + 403: "decap", + 404: "nced", + 405: "ncld", + 406: "imsp", + 407: "timbuktu", + 408: "prm-sm", + 409: "prm-nm", + 410: "decladebug", + 411: "rmt", + 412: "synoptics-trap", + 413: "smsp", + 414: "infoseek", + 415: "bnet", + 416: "silverplatter", + 417: "onmux", + 418: "hyper-g", + 419: "ariel1", + 420: "smpte", + 421: "ariel2", + 422: "ariel3", + 423: "opc-job-start", + 424: "opc-job-track", + 425: "icad-el", + 426: "smartsdp", + 427: "svrloc", + 428: "ocs-cmu", + 429: "ocs-amu", + 430: "utmpsd", + 431: "utmpcd", + 432: "iasd", + 433: "nnsp", + 434: "mobileip-agent", + 435: "mobilip-mn", + 436: "dna-cml", + 437: "comscm", + 438: "dsfgw", + 439: "dasp", + 440: "sgcp", + 441: "decvms-sysmgt", + 442: "cvc-hostd", + 443: "https", + 444: "snpp", + 445: "microsoft-ds", + 446: "ddm-rdb", + 447: "ddm-dfm", + 448: "ddm-ssl", + 449: "as-servermap", + 450: "tserver", + 451: "sfs-smp-net", + 452: "sfs-config", + 453: "creativeserver", + 454: "contentserver", + 455: "creativepartnr", + 456: "macon-tcp", + 457: "scohelp", + 458: "appleqtc", + 459: "ampr-rcmd", + 460: "skronk", + 461: "datasurfsrv", + 462: "datasurfsrvsec", + 463: "alpes", + 464: "kpasswd", + 465: "urd", + 466: "digital-vrc", + 467: "mylex-mapd", + 468: "photuris", + 469: "rcp", + 470: "scx-proxy", + 471: "mondex", + 472: "ljk-login", + 473: "hybrid-pop", + 474: "tn-tl-w1", + 475: "tcpnethaspsrv", + 476: "tn-tl-fd1", + 477: "ss7ns", + 478: "spsc", + 479: "iafserver", + 480: "iafdbase", + 481: "ph", + 482: "bgs-nsi", + 483: "ulpnet", + 484: "integra-sme", + 485: "powerburst", + 486: "avian", + 487: "saft", + 488: "gss-http", + 489: "nest-protocol", + 490: "micom-pfs", + 491: "go-login", + 492: "ticf-1", + 493: "ticf-2", + 494: "pov-ray", + 495: "intecourier", + 496: "pim-rp-disc", + 497: "retrospect", + 498: "siam", + 499: "iso-ill", + 500: "isakmp", + 501: "stmf", + 502: "mbap", + 503: "intrinsa", + 504: "citadel", + 505: "mailbox-lm", + 506: "ohimsrv", + 507: "crs", + 508: "xvttp", + 509: "snare", + 510: "fcp", + 511: "passgo", + 512: "exec", + 513: "login", + 514: "shell", + 515: "printer", + 516: "videotex", + 517: "talk", + 518: "ntalk", + 519: "utime", + 520: "efs", + 521: "ripng", + 522: "ulp", + 523: "ibm-db2", + 524: "ncp", + 525: "timed", + 526: "tempo", + 527: "stx", + 528: "custix", + 529: "irc-serv", + 530: "courier", + 531: "conference", + 532: "netnews", + 533: "netwall", + 534: "windream", + 535: "iiop", + 536: "opalis-rdv", + 537: "nmsp", + 538: "gdomap", + 539: "apertus-ldp", + 540: "uucp", + 541: "uucp-rlogin", + 542: "commerce", + 543: "klogin", + 544: "kshell", + 545: "appleqtcsrvr", + 546: "dhcpv6-client", + 547: "dhcpv6-server", + 548: "afpovertcp", + 549: "idfp", + 550: "new-rwho", + 551: "cybercash", + 552: "devshr-nts", + 553: "pirp", + 554: "rtsp", + 555: "dsf", + 556: "remotefs", + 557: "openvms-sysipc", + 558: "sdnskmp", + 559: "teedtap", + 560: "rmonitor", + 561: "monitor", + 562: "chshell", + 563: "nntps", + 564: "9pfs", + 565: "whoami", + 566: "streettalk", + 567: "banyan-rpc", + 568: "ms-shuttle", + 569: "ms-rome", + 570: "meter", + 571: "meter", + 572: "sonar", + 573: "banyan-vip", + 574: "ftp-agent", + 575: "vemmi", + 576: "ipcd", + 577: "vnas", + 578: "ipdd", + 579: "decbsrv", + 580: "sntp-heartbeat", + 581: "bdp", + 582: "scc-security", + 583: "philips-vc", + 584: "keyserver", + 586: "password-chg", + 587: "submission", + 588: "cal", + 589: "eyelink", + 590: "tns-cml", + 591: "http-alt", + 592: "eudora-set", + 593: "http-rpc-epmap", + 594: "tpip", + 595: "cab-protocol", + 596: "smsd", + 597: "ptcnameservice", + 598: "sco-websrvrmg3", + 599: "acp", + 600: "ipcserver", + 601: "syslog-conn", + 602: "xmlrpc-beep", + 603: "idxp", + 604: "tunnel", + 605: "soap-beep", + 606: "urm", + 607: "nqs", + 608: "sift-uft", + 609: "npmp-trap", + 610: "npmp-local", + 611: "npmp-gui", + 612: "hmmp-ind", + 613: "hmmp-op", + 614: "sshell", + 615: "sco-inetmgr", + 616: "sco-sysmgr", + 617: "sco-dtmgr", + 618: "dei-icda", + 619: "compaq-evm", + 620: "sco-websrvrmgr", + 621: "escp-ip", + 622: "collaborator", + 623: "oob-ws-http", + 624: "cryptoadmin", + 625: "dec-dlm", + 626: "asia", + 627: "passgo-tivoli", + 628: "qmqp", + 629: "3com-amp3", + 630: "rda", + 631: "ipp", + 632: "bmpp", + 633: "servstat", + 634: "ginad", + 635: "rlzdbase", + 636: "ldaps", + 637: "lanserver", + 638: "mcns-sec", + 639: "msdp", + 640: "entrust-sps", + 641: "repcmd", + 642: "esro-emsdp", + 643: "sanity", + 644: "dwr", + 645: "pssc", + 646: "ldp", + 647: "dhcp-failover", + 648: "rrp", + 649: "cadview-3d", + 650: "obex", + 651: "ieee-mms", + 652: "hello-port", + 653: "repscmd", + 654: "aodv", + 655: "tinc", + 656: "spmp", + 657: "rmc", + 658: "tenfold", + 660: "mac-srvr-admin", + 661: "hap", + 662: "pftp", + 663: "purenoise", + 664: "oob-ws-https", + 665: "sun-dr", + 666: "mdqs", + 667: "disclose", + 668: "mecomm", + 669: "meregister", + 670: "vacdsm-sws", + 671: "vacdsm-app", + 672: "vpps-qua", + 673: "cimplex", + 674: "acap", + 675: "dctp", + 676: "vpps-via", + 677: "vpp", + 678: "ggf-ncp", + 679: "mrm", + 680: "entrust-aaas", + 681: "entrust-aams", + 682: "xfr", + 683: "corba-iiop", + 684: "corba-iiop-ssl", + 685: "mdc-portmapper", + 686: "hcp-wismar", + 687: "asipregistry", + 688: "realm-rusd", + 689: "nmap", + 690: "vatp", + 691: "msexch-routing", + 692: "hyperwave-isp", + 693: "connendp", + 694: "ha-cluster", + 695: "ieee-mms-ssl", + 696: "rushd", + 697: "uuidgen", + 698: "olsr", + 699: "accessnetwork", + 700: "epp", + 701: "lmp", + 702: "iris-beep", + 704: "elcsd", + 705: "agentx", + 706: "silc", + 707: "borland-dsj", + 709: "entrust-kmsh", + 710: "entrust-ash", + 711: "cisco-tdp", + 712: "tbrpf", + 713: "iris-xpc", + 714: "iris-xpcs", + 715: "iris-lwz", + 729: "netviewdm1", + 730: "netviewdm2", + 731: "netviewdm3", + 741: "netgw", + 742: "netrcs", + 744: "flexlm", + 747: "fujitsu-dev", + 748: "ris-cm", + 749: "kerberos-adm", + 750: "rfile", + 751: "pump", + 752: "qrh", + 753: "rrh", + 754: "tell", + 758: "nlogin", + 759: "con", + 760: "ns", + 761: "rxe", + 762: "quotad", + 763: "cycleserv", + 764: "omserv", + 765: "webster", + 767: "phonebook", + 769: "vid", + 770: "cadlock", + 771: "rtip", + 772: "cycleserv2", + 773: "submit", + 774: "rpasswd", + 775: "entomb", + 776: "wpages", + 777: "multiling-http", + 780: "wpgs", + 800: "mdbs-daemon", + 801: "device", + 802: "mbap-s", + 810: "fcp-udp", + 828: "itm-mcell-s", + 829: "pkix-3-ca-ra", + 830: "netconf-ssh", + 831: "netconf-beep", + 832: "netconfsoaphttp", + 833: "netconfsoapbeep", + 847: "dhcp-failover2", + 848: "gdoi", + 853: "domain-s", + 860: "iscsi", + 861: "owamp-control", + 862: "twamp-control", + 873: "rsync", + 886: "iclcnet-locate", + 887: "iclcnet-svinfo", + 888: "accessbuilder", + 900: "omginitialrefs", + 901: "smpnameres", + 902: "ideafarm-door", + 903: "ideafarm-panic", + 910: "kink", + 911: "xact-backup", + 912: "apex-mesh", + 913: "apex-edge", + 989: "ftps-data", + 990: "ftps", + 991: "nas", + 992: "telnets", + 993: "imaps", + 995: "pop3s", + 996: "vsinet", + 997: "maitrd", + 998: "busboy", + 999: "garcon", + 1000: "cadlock2", + 1001: "webpush", + 1010: "surf", + 1021: "exp1", + 1022: "exp2", + 1025: "blackjack", + 1026: "cap", + 1029: "solid-mux", + 1033: "netinfo-local", + 1034: "activesync", + 1035: "mxxrlogin", + 1036: "nsstp", + 1037: "ams", + 1038: "mtqp", + 1039: "sbl", + 1040: "netarx", + 1041: "danf-ak2", + 1042: "afrog", + 1043: "boinc-client", + 1044: "dcutility", + 1045: "fpitp", + 1046: "wfremotertm", + 1047: "neod1", + 1048: "neod2", + 1049: "td-postman", + 1050: "cma", + 1051: "optima-vnet", + 1052: "ddt", + 1053: "remote-as", + 1054: "brvread", + 1055: "ansyslmd", + 1056: "vfo", + 1057: "startron", + 1058: "nim", + 1059: "nimreg", + 1060: "polestar", + 1061: "kiosk", + 1062: "veracity", + 1063: "kyoceranetdev", + 1064: "jstel", + 1065: "syscomlan", + 1066: "fpo-fns", + 1067: "instl-boots", + 1068: "instl-bootc", + 1069: "cognex-insight", + 1070: "gmrupdateserv", + 1071: "bsquare-voip", + 1072: "cardax", + 1073: "bridgecontrol", + 1074: "warmspotMgmt", + 1075: "rdrmshc", + 1076: "dab-sti-c", + 1077: "imgames", + 1078: "avocent-proxy", + 1079: "asprovatalk", + 1080: "socks", + 1081: "pvuniwien", + 1082: "amt-esd-prot", + 1083: "ansoft-lm-1", + 1084: "ansoft-lm-2", + 1085: "webobjects", + 1086: "cplscrambler-lg", + 1087: "cplscrambler-in", + 1088: "cplscrambler-al", + 1089: "ff-annunc", + 1090: "ff-fms", + 1091: "ff-sm", + 1092: "obrpd", + 1093: "proofd", + 1094: "rootd", + 1095: "nicelink", + 1096: "cnrprotocol", + 1097: "sunclustermgr", + 1098: "rmiactivation", + 1099: "rmiregistry", + 1100: "mctp", + 1101: "pt2-discover", + 1102: "adobeserver-1", + 1103: "adobeserver-2", + 1104: "xrl", + 1105: "ftranhc", + 1106: "isoipsigport-1", + 1107: "isoipsigport-2", + 1108: "ratio-adp", + 1110: "webadmstart", + 1111: "lmsocialserver", + 1112: "icp", + 1113: "ltp-deepspace", + 1114: "mini-sql", + 1115: "ardus-trns", + 1116: "ardus-cntl", + 1117: "ardus-mtrns", + 1118: "sacred", + 1119: "bnetgame", + 1120: "bnetfile", + 1121: "rmpp", + 1122: "availant-mgr", + 1123: "murray", + 1124: "hpvmmcontrol", + 1125: "hpvmmagent", + 1126: "hpvmmdata", + 1127: "kwdb-commn", + 1128: "saphostctrl", + 1129: "saphostctrls", + 1130: "casp", + 1131: "caspssl", + 1132: "kvm-via-ip", + 1133: "dfn", + 1134: "aplx", + 1135: "omnivision", + 1136: "hhb-gateway", + 1137: "trim", + 1138: "encrypted-admin", + 1139: "evm", + 1140: "autonoc", + 1141: "mxomss", + 1142: "edtools", + 1143: "imyx", + 1144: "fuscript", + 1145: "x9-icue", + 1146: "audit-transfer", + 1147: "capioverlan", + 1148: "elfiq-repl", + 1149: "bvtsonar", + 1150: "blaze", + 1151: "unizensus", + 1152: "winpoplanmess", + 1153: "c1222-acse", + 1154: "resacommunity", + 1155: "nfa", + 1156: "iascontrol-oms", + 1157: "iascontrol", + 1158: "dbcontrol-oms", + 1159: "oracle-oms", + 1160: "olsv", + 1161: "health-polling", + 1162: "health-trap", + 1163: "sddp", + 1164: "qsm-proxy", + 1165: "qsm-gui", + 1166: "qsm-remote", + 1167: "cisco-ipsla", + 1168: "vchat", + 1169: "tripwire", + 1170: "atc-lm", + 1171: "atc-appserver", + 1172: "dnap", + 1173: "d-cinema-rrp", + 1174: "fnet-remote-ui", + 1175: "dossier", + 1176: "indigo-server", + 1177: "dkmessenger", + 1178: "sgi-storman", + 1179: "b2n", + 1180: "mc-client", + 1181: "3comnetman", + 1182: "accelenet", + 1183: "llsurfup-http", + 1184: "llsurfup-https", + 1185: "catchpole", + 1186: "mysql-cluster", + 1187: "alias", + 1188: "hp-webadmin", + 1189: "unet", + 1190: "commlinx-avl", + 1191: "gpfs", + 1192: "caids-sensor", + 1193: "fiveacross", + 1194: "openvpn", + 1195: "rsf-1", + 1196: "netmagic", + 1197: "carrius-rshell", + 1198: "cajo-discovery", + 1199: "dmidi", + 1200: "scol", + 1201: "nucleus-sand", + 1202: "caiccipc", + 1203: "ssslic-mgr", + 1204: "ssslog-mgr", + 1205: "accord-mgc", + 1206: "anthony-data", + 1207: "metasage", + 1208: "seagull-ais", + 1209: "ipcd3", + 1210: "eoss", + 1211: "groove-dpp", + 1212: "lupa", + 1213: "mpc-lifenet", + 1214: "kazaa", + 1215: "scanstat-1", + 1216: "etebac5", + 1217: "hpss-ndapi", + 1218: "aeroflight-ads", + 1219: "aeroflight-ret", + 1220: "qt-serveradmin", + 1221: "sweetware-apps", + 1222: "nerv", + 1223: "tgp", + 1224: "vpnz", + 1225: "slinkysearch", + 1226: "stgxfws", + 1227: "dns2go", + 1228: "florence", + 1229: "zented", + 1230: "periscope", + 1231: "menandmice-lpm", + 1232: "first-defense", + 1233: "univ-appserver", + 1234: "search-agent", + 1235: "mosaicsyssvc1", + 1236: "bvcontrol", + 1237: "tsdos390", + 1238: "hacl-qs", + 1239: "nmsd", + 1240: "instantia", + 1241: "nessus", + 1242: "nmasoverip", + 1243: "serialgateway", + 1244: "isbconference1", + 1245: "isbconference2", + 1246: "payrouter", + 1247: "visionpyramid", + 1248: "hermes", + 1249: "mesavistaco", + 1250: "swldy-sias", + 1251: "servergraph", + 1252: "bspne-pcc", + 1253: "q55-pcc", + 1254: "de-noc", + 1255: "de-cache-query", + 1256: "de-server", + 1257: "shockwave2", + 1258: "opennl", + 1259: "opennl-voice", + 1260: "ibm-ssd", + 1261: "mpshrsv", + 1262: "qnts-orb", + 1263: "dka", + 1264: "prat", + 1265: "dssiapi", + 1266: "dellpwrappks", + 1267: "epc", + 1268: "propel-msgsys", + 1269: "watilapp", + 1270: "opsmgr", + 1271: "excw", + 1272: "cspmlockmgr", + 1273: "emc-gateway", + 1274: "t1distproc", + 1275: "ivcollector", + 1277: "miva-mqs", + 1278: "dellwebadmin-1", + 1279: "dellwebadmin-2", + 1280: "pictrography", + 1281: "healthd", + 1282: "emperion", + 1283: "productinfo", + 1284: "iee-qfx", + 1285: "neoiface", + 1286: "netuitive", + 1287: "routematch", + 1288: "navbuddy", + 1289: "jwalkserver", + 1290: "winjaserver", + 1291: "seagulllms", + 1292: "dsdn", + 1293: "pkt-krb-ipsec", + 1294: "cmmdriver", + 1295: "ehtp", + 1296: "dproxy", + 1297: "sdproxy", + 1298: "lpcp", + 1299: "hp-sci", + 1300: "h323hostcallsc", + 1301: "ci3-software-1", + 1302: "ci3-software-2", + 1303: "sftsrv", + 1304: "boomerang", + 1305: "pe-mike", + 1306: "re-conn-proto", + 1307: "pacmand", + 1308: "odsi", + 1309: "jtag-server", + 1310: "husky", + 1311: "rxmon", + 1312: "sti-envision", + 1313: "bmc-patroldb", + 1314: "pdps", + 1315: "els", + 1316: "exbit-escp", + 1317: "vrts-ipcserver", + 1318: "krb5gatekeeper", + 1319: "amx-icsp", + 1320: "amx-axbnet", + 1321: "pip", + 1322: "novation", + 1323: "brcd", + 1324: "delta-mcp", + 1325: "dx-instrument", + 1326: "wimsic", + 1327: "ultrex", + 1328: "ewall", + 1329: "netdb-export", + 1330: "streetperfect", + 1331: "intersan", + 1332: "pcia-rxp-b", + 1333: "passwrd-policy", + 1334: "writesrv", + 1335: "digital-notary", + 1336: "ischat", + 1337: "menandmice-dns", + 1338: "wmc-log-svc", + 1339: "kjtsiteserver", + 1340: "naap", + 1341: "qubes", + 1342: "esbroker", + 1343: "re101", + 1344: "icap", + 1345: "vpjp", + 1346: "alta-ana-lm", + 1347: "bbn-mmc", + 1348: "bbn-mmx", + 1349: "sbook", + 1350: "editbench", + 1351: "equationbuilder", + 1352: "lotusnote", + 1353: "relief", + 1354: "XSIP-network", + 1355: "intuitive-edge", + 1356: "cuillamartin", + 1357: "pegboard", + 1358: "connlcli", + 1359: "ftsrv", + 1360: "mimer", + 1361: "linx", + 1362: "timeflies", + 1363: "ndm-requester", + 1364: "ndm-server", + 1365: "adapt-sna", + 1366: "netware-csp", + 1367: "dcs", + 1368: "screencast", + 1369: "gv-us", + 1370: "us-gv", + 1371: "fc-cli", + 1372: "fc-ser", + 1373: "chromagrafx", + 1374: "molly", + 1375: "bytex", + 1376: "ibm-pps", + 1377: "cichlid", + 1378: "elan", + 1379: "dbreporter", + 1380: "telesis-licman", + 1381: "apple-licman", + 1382: "udt-os", + 1383: "gwha", + 1384: "os-licman", + 1385: "atex-elmd", + 1386: "checksum", + 1387: "cadsi-lm", + 1388: "objective-dbc", + 1389: "iclpv-dm", + 1390: "iclpv-sc", + 1391: "iclpv-sas", + 1392: "iclpv-pm", + 1393: "iclpv-nls", + 1394: "iclpv-nlc", + 1395: "iclpv-wsm", + 1396: "dvl-activemail", + 1397: "audio-activmail", + 1398: "video-activmail", + 1399: "cadkey-licman", + 1400: "cadkey-tablet", + 1401: "goldleaf-licman", + 1402: "prm-sm-np", + 1403: "prm-nm-np", + 1404: "igi-lm", + 1405: "ibm-res", + 1406: "netlabs-lm", + 1407: "tibet-server", + 1408: "sophia-lm", + 1409: "here-lm", + 1410: "hiq", + 1411: "af", + 1412: "innosys", + 1413: "innosys-acl", + 1414: "ibm-mqseries", + 1415: "dbstar", + 1416: "novell-lu6-2", + 1417: "timbuktu-srv1", + 1418: "timbuktu-srv2", + 1419: "timbuktu-srv3", + 1420: "timbuktu-srv4", + 1421: "gandalf-lm", + 1422: "autodesk-lm", + 1423: "essbase", + 1424: "hybrid", + 1425: "zion-lm", + 1426: "sais", + 1427: "mloadd", + 1428: "informatik-lm", + 1429: "nms", + 1430: "tpdu", + 1431: "rgtp", + 1432: "blueberry-lm", + 1433: "ms-sql-s", + 1434: "ms-sql-m", + 1435: "ibm-cics", + 1436: "saism", + 1437: "tabula", + 1438: "eicon-server", + 1439: "eicon-x25", + 1440: "eicon-slp", + 1441: "cadis-1", + 1442: "cadis-2", + 1443: "ies-lm", + 1444: "marcam-lm", + 1445: "proxima-lm", + 1446: "ora-lm", + 1447: "apri-lm", + 1448: "oc-lm", + 1449: "peport", + 1450: "dwf", + 1451: "infoman", + 1452: "gtegsc-lm", + 1453: "genie-lm", + 1454: "interhdl-elmd", + 1455: "esl-lm", + 1456: "dca", + 1457: "valisys-lm", + 1458: "nrcabq-lm", + 1459: "proshare1", + 1460: "proshare2", + 1461: "ibm-wrless-lan", + 1462: "world-lm", + 1463: "nucleus", + 1464: "msl-lmd", + 1465: "pipes", + 1466: "oceansoft-lm", + 1467: "csdmbase", + 1468: "csdm", + 1469: "aal-lm", + 1470: "uaiact", + 1471: "csdmbase", + 1472: "csdm", + 1473: "openmath", + 1474: "telefinder", + 1475: "taligent-lm", + 1476: "clvm-cfg", + 1477: "ms-sna-server", + 1478: "ms-sna-base", + 1479: "dberegister", + 1480: "pacerforum", + 1481: "airs", + 1482: "miteksys-lm", + 1483: "afs", + 1484: "confluent", + 1485: "lansource", + 1486: "nms-topo-serv", + 1487: "localinfosrvr", + 1488: "docstor", + 1489: "dmdocbroker", + 1490: "insitu-conf", + 1492: "stone-design-1", + 1493: "netmap-lm", + 1494: "ica", + 1495: "cvc", + 1496: "liberty-lm", + 1497: "rfx-lm", + 1498: "sybase-sqlany", + 1499: "fhc", + 1500: "vlsi-lm", + 1501: "saiscm", + 1502: "shivadiscovery", + 1503: "imtc-mcs", + 1504: "evb-elm", + 1505: "funkproxy", + 1506: "utcd", + 1507: "symplex", + 1508: "diagmond", + 1509: "robcad-lm", + 1510: "mvx-lm", + 1511: "3l-l1", + 1512: "wins", + 1513: "fujitsu-dtc", + 1514: "fujitsu-dtcns", + 1515: "ifor-protocol", + 1516: "vpad", + 1517: "vpac", + 1518: "vpvd", + 1519: "vpvc", + 1520: "atm-zip-office", + 1521: "ncube-lm", + 1522: "ricardo-lm", + 1523: "cichild-lm", + 1524: "ingreslock", + 1525: "orasrv", + 1526: "pdap-np", + 1527: "tlisrv", + 1529: "coauthor", + 1530: "rap-service", + 1531: "rap-listen", + 1532: "miroconnect", + 1533: "virtual-places", + 1534: "micromuse-lm", + 1535: "ampr-info", + 1536: "ampr-inter", + 1537: "sdsc-lm", + 1538: "3ds-lm", + 1539: "intellistor-lm", + 1540: "rds", + 1541: "rds2", + 1542: "gridgen-elmd", + 1543: "simba-cs", + 1544: "aspeclmd", + 1545: "vistium-share", + 1546: "abbaccuray", + 1547: "laplink", + 1548: "axon-lm", + 1549: "shivahose", + 1550: "3m-image-lm", + 1551: "hecmtl-db", + 1552: "pciarray", + 1553: "sna-cs", + 1554: "caci-lm", + 1555: "livelan", + 1556: "veritas-pbx", + 1557: "arbortext-lm", + 1558: "xingmpeg", + 1559: "web2host", + 1560: "asci-val", + 1561: "facilityview", + 1562: "pconnectmgr", + 1563: "cadabra-lm", + 1564: "pay-per-view", + 1565: "winddlb", + 1566: "corelvideo", + 1567: "jlicelmd", + 1568: "tsspmap", + 1569: "ets", + 1570: "orbixd", + 1571: "rdb-dbs-disp", + 1572: "chip-lm", + 1573: "itscomm-ns", + 1574: "mvel-lm", + 1575: "oraclenames", + 1576: "moldflow-lm", + 1577: "hypercube-lm", + 1578: "jacobus-lm", + 1579: "ioc-sea-lm", + 1580: "tn-tl-r1", + 1581: "mil-2045-47001", + 1582: "msims", + 1583: "simbaexpress", + 1584: "tn-tl-fd2", + 1585: "intv", + 1586: "ibm-abtact", + 1587: "pra-elmd", + 1588: "triquest-lm", + 1589: "vqp", + 1590: "gemini-lm", + 1591: "ncpm-pm", + 1592: "commonspace", + 1593: "mainsoft-lm", + 1594: "sixtrak", + 1595: "radio", + 1596: "radio-sm", + 1597: "orbplus-iiop", + 1598: "picknfs", + 1599: "simbaservices", + 1600: "issd", + 1601: "aas", + 1602: "inspect", + 1603: "picodbc", + 1604: "icabrowser", + 1605: "slp", + 1606: "slm-api", + 1607: "stt", + 1608: "smart-lm", + 1609: "isysg-lm", + 1610: "taurus-wh", + 1611: "ill", + 1612: "netbill-trans", + 1613: "netbill-keyrep", + 1614: "netbill-cred", + 1615: "netbill-auth", + 1616: "netbill-prod", + 1617: "nimrod-agent", + 1618: "skytelnet", + 1619: "xs-openstorage", + 1620: "faxportwinport", + 1621: "softdataphone", + 1622: "ontime", + 1623: "jaleosnd", + 1624: "udp-sr-port", + 1625: "svs-omagent", + 1626: "shockwave", + 1627: "t128-gateway", + 1628: "lontalk-norm", + 1629: "lontalk-urgnt", + 1630: "oraclenet8cman", + 1631: "visitview", + 1632: "pammratc", + 1633: "pammrpc", + 1634: "loaprobe", + 1635: "edb-server1", + 1636: "isdc", + 1637: "islc", + 1638: "ismc", + 1639: "cert-initiator", + 1640: "cert-responder", + 1641: "invision", + 1642: "isis-am", + 1643: "isis-ambc", + 1644: "saiseh", + 1645: "sightline", + 1646: "sa-msg-port", + 1647: "rsap", + 1648: "concurrent-lm", + 1649: "kermit", + 1650: "nkd", + 1651: "shiva-confsrvr", + 1652: "xnmp", + 1653: "alphatech-lm", + 1654: "stargatealerts", + 1655: "dec-mbadmin", + 1656: "dec-mbadmin-h", + 1657: "fujitsu-mmpdc", + 1658: "sixnetudr", + 1659: "sg-lm", + 1660: "skip-mc-gikreq", + 1661: "netview-aix-1", + 1662: "netview-aix-2", + 1663: "netview-aix-3", + 1664: "netview-aix-4", + 1665: "netview-aix-5", + 1666: "netview-aix-6", + 1667: "netview-aix-7", + 1668: "netview-aix-8", + 1669: "netview-aix-9", + 1670: "netview-aix-10", + 1671: "netview-aix-11", + 1672: "netview-aix-12", + 1673: "proshare-mc-1", + 1674: "proshare-mc-2", + 1675: "pdp", + 1676: "netcomm1", + 1677: "groupwise", + 1678: "prolink", + 1679: "darcorp-lm", + 1680: "microcom-sbp", + 1681: "sd-elmd", + 1682: "lanyon-lantern", + 1683: "ncpm-hip", + 1684: "snaresecure", + 1685: "n2nremote", + 1686: "cvmon", + 1687: "nsjtp-ctrl", + 1688: "nsjtp-data", + 1689: "firefox", + 1690: "ng-umds", + 1691: "empire-empuma", + 1692: "sstsys-lm", + 1693: "rrirtr", + 1694: "rrimwm", + 1695: "rrilwm", + 1696: "rrifmm", + 1697: "rrisat", + 1698: "rsvp-encap-1", + 1699: "rsvp-encap-2", + 1700: "mps-raft", + 1701: "l2f", + 1702: "deskshare", + 1703: "hb-engine", + 1704: "bcs-broker", + 1705: "slingshot", + 1706: "jetform", + 1707: "vdmplay", + 1708: "gat-lmd", + 1709: "centra", + 1710: "impera", + 1711: "pptconference", + 1712: "registrar", + 1713: "conferencetalk", + 1714: "sesi-lm", + 1715: "houdini-lm", + 1716: "xmsg", + 1717: "fj-hdnet", + 1718: "h323gatedisc", + 1719: "h323gatestat", + 1720: "h323hostcall", + 1721: "caicci", + 1722: "hks-lm", + 1723: "pptp", + 1724: "csbphonemaster", + 1725: "iden-ralp", + 1726: "iberiagames", + 1727: "winddx", + 1728: "telindus", + 1729: "citynl", + 1730: "roketz", + 1731: "msiccp", + 1732: "proxim", + 1733: "siipat", + 1734: "cambertx-lm", + 1735: "privatechat", + 1736: "street-stream", + 1737: "ultimad", + 1738: "gamegen1", + 1739: "webaccess", + 1740: "encore", + 1741: "cisco-net-mgmt", + 1742: "3Com-nsd", + 1743: "cinegrfx-lm", + 1744: "ncpm-ft", + 1745: "remote-winsock", + 1746: "ftrapid-1", + 1747: "ftrapid-2", + 1748: "oracle-em1", + 1749: "aspen-services", + 1750: "sslp", + 1751: "swiftnet", + 1752: "lofr-lm", + 1753: "predatar-comms", + 1754: "oracle-em2", + 1755: "ms-streaming", + 1756: "capfast-lmd", + 1757: "cnhrp", + 1758: "tftp-mcast", + 1759: "spss-lm", + 1760: "www-ldap-gw", + 1761: "cft-0", + 1762: "cft-1", + 1763: "cft-2", + 1764: "cft-3", + 1765: "cft-4", + 1766: "cft-5", + 1767: "cft-6", + 1768: "cft-7", + 1769: "bmc-net-adm", + 1770: "bmc-net-svc", + 1771: "vaultbase", + 1772: "essweb-gw", + 1773: "kmscontrol", + 1774: "global-dtserv", + 1775: "vdab", + 1776: "femis", + 1777: "powerguardian", + 1778: "prodigy-intrnet", + 1779: "pharmasoft", + 1780: "dpkeyserv", + 1781: "answersoft-lm", + 1782: "hp-hcip", + 1784: "finle-lm", + 1785: "windlm", + 1786: "funk-logger", + 1787: "funk-license", + 1788: "psmond", + 1789: "hello", + 1790: "nmsp", + 1791: "ea1", + 1792: "ibm-dt-2", + 1793: "rsc-robot", + 1794: "cera-bcm", + 1795: "dpi-proxy", + 1796: "vocaltec-admin", + 1797: "uma", + 1798: "etp", + 1799: "netrisk", + 1800: "ansys-lm", + 1801: "msmq", + 1802: "concomp1", + 1803: "hp-hcip-gwy", + 1804: "enl", + 1805: "enl-name", + 1806: "musiconline", + 1807: "fhsp", + 1808: "oracle-vp2", + 1809: "oracle-vp1", + 1810: "jerand-lm", + 1811: "scientia-sdb", + 1812: "radius", + 1813: "radius-acct", + 1814: "tdp-suite", + 1815: "mmpft", + 1816: "harp", + 1817: "rkb-oscs", + 1818: "etftp", + 1819: "plato-lm", + 1820: "mcagent", + 1821: "donnyworld", + 1822: "es-elmd", + 1823: "unisys-lm", + 1824: "metrics-pas", + 1825: "direcpc-video", + 1826: "ardt", + 1827: "asi", + 1828: "itm-mcell-u", + 1829: "optika-emedia", + 1830: "net8-cman", + 1831: "myrtle", + 1832: "tht-treasure", + 1833: "udpradio", + 1834: "ardusuni", + 1835: "ardusmul", + 1836: "ste-smsc", + 1837: "csoft1", + 1838: "talnet", + 1839: "netopia-vo1", + 1840: "netopia-vo2", + 1841: "netopia-vo3", + 1842: "netopia-vo4", + 1843: "netopia-vo5", + 1844: "direcpc-dll", + 1845: "altalink", + 1846: "tunstall-pnc", + 1847: "slp-notify", + 1848: "fjdocdist", + 1849: "alpha-sms", + 1850: "gsi", + 1851: "ctcd", + 1852: "virtual-time", + 1853: "vids-avtp", + 1854: "buddy-draw", + 1855: "fiorano-rtrsvc", + 1856: "fiorano-msgsvc", + 1857: "datacaptor", + 1858: "privateark", + 1859: "gammafetchsvr", + 1860: "sunscalar-svc", + 1861: "lecroy-vicp", + 1862: "mysql-cm-agent", + 1863: "msnp", + 1864: "paradym-31port", + 1865: "entp", + 1866: "swrmi", + 1867: "udrive", + 1868: "viziblebrowser", + 1869: "transact", + 1870: "sunscalar-dns", + 1871: "canocentral0", + 1872: "canocentral1", + 1873: "fjmpjps", + 1874: "fjswapsnp", + 1875: "westell-stats", + 1876: "ewcappsrv", + 1877: "hp-webqosdb", + 1878: "drmsmc", + 1879: "nettgain-nms", + 1880: "vsat-control", + 1881: "ibm-mqseries2", + 1882: "ecsqdmn", + 1883: "mqtt", + 1884: "idmaps", + 1885: "vrtstrapserver", + 1886: "leoip", + 1887: "filex-lport", + 1888: "ncconfig", + 1889: "unify-adapter", + 1890: "wilkenlistener", + 1891: "childkey-notif", + 1892: "childkey-ctrl", + 1893: "elad", + 1894: "o2server-port", + 1896: "b-novative-ls", + 1897: "metaagent", + 1898: "cymtec-port", + 1899: "mc2studios", + 1900: "ssdp", + 1901: "fjicl-tep-a", + 1902: "fjicl-tep-b", + 1903: "linkname", + 1904: "fjicl-tep-c", + 1905: "sugp", + 1906: "tpmd", + 1907: "intrastar", + 1908: "dawn", + 1909: "global-wlink", + 1910: "ultrabac", + 1911: "mtp", + 1912: "rhp-iibp", + 1913: "armadp", + 1914: "elm-momentum", + 1915: "facelink", + 1916: "persona", + 1917: "noagent", + 1918: "can-nds", + 1919: "can-dch", + 1920: "can-ferret", + 1921: "noadmin", + 1922: "tapestry", + 1923: "spice", + 1924: "xiip", + 1925: "discovery-port", + 1926: "egs", + 1927: "videte-cipc", + 1928: "emsd-port", + 1929: "bandwiz-system", + 1930: "driveappserver", + 1931: "amdsched", + 1932: "ctt-broker", + 1933: "xmapi", + 1934: "xaapi", + 1935: "macromedia-fcs", + 1936: "jetcmeserver", + 1937: "jwserver", + 1938: "jwclient", + 1939: "jvserver", + 1940: "jvclient", + 1941: "dic-aida", + 1942: "res", + 1943: "beeyond-media", + 1944: "close-combat", + 1945: "dialogic-elmd", + 1946: "tekpls", + 1947: "sentinelsrm", + 1948: "eye2eye", + 1949: "ismaeasdaqlive", + 1950: "ismaeasdaqtest", + 1951: "bcs-lmserver", + 1952: "mpnjsc", + 1953: "rapidbase", + 1954: "abr-api", + 1955: "abr-secure", + 1956: "vrtl-vmf-ds", + 1957: "unix-status", + 1958: "dxadmind", + 1959: "simp-all", + 1960: "nasmanager", + 1961: "bts-appserver", + 1962: "biap-mp", + 1963: "webmachine", + 1964: "solid-e-engine", + 1965: "tivoli-npm", + 1966: "slush", + 1967: "sns-quote", + 1968: "lipsinc", + 1969: "lipsinc1", + 1970: "netop-rc", + 1971: "netop-school", + 1972: "intersys-cache", + 1973: "dlsrap", + 1974: "drp", + 1975: "tcoflashagent", + 1976: "tcoregagent", + 1977: "tcoaddressbook", + 1978: "unisql", + 1979: "unisql-java", + 1980: "pearldoc-xact", + 1981: "p2pq", + 1982: "estamp", + 1983: "lhtp", + 1984: "bb", + 1985: "hsrp", + 1986: "licensedaemon", + 1987: "tr-rsrb-p1", + 1988: "tr-rsrb-p2", + 1989: "tr-rsrb-p3", + 1990: "stun-p1", + 1991: "stun-p2", + 1992: "stun-p3", + 1993: "snmp-tcp-port", + 1994: "stun-port", + 1995: "perf-port", + 1996: "tr-rsrb-port", + 1997: "gdp-port", + 1998: "x25-svc-port", + 1999: "tcp-id-port", + 2000: "cisco-sccp", + 2001: "dc", + 2002: "globe", + 2003: "brutus", + 2004: "mailbox", + 2005: "berknet", + 2006: "invokator", + 2007: "dectalk", + 2008: "conf", + 2009: "news", + 2010: "search", + 2011: "raid-cc", + 2012: "ttyinfo", + 2013: "raid-am", + 2014: "troff", + 2015: "cypress", + 2016: "bootserver", + 2017: "cypress-stat", + 2018: "terminaldb", + 2019: "whosockami", + 2020: "xinupageserver", + 2021: "servexec", + 2022: "down", + 2023: "xinuexpansion3", + 2024: "xinuexpansion4", + 2025: "ellpack", + 2026: "scrabble", + 2027: "shadowserver", + 2028: "submitserver", + 2029: "hsrpv6", + 2030: "device2", + 2031: "mobrien-chat", + 2032: "blackboard", + 2033: "glogger", + 2034: "scoremgr", + 2035: "imsldoc", + 2036: "e-dpnet", + 2037: "applus", + 2038: "objectmanager", + 2039: "prizma", + 2040: "lam", + 2041: "interbase", + 2042: "isis", + 2043: "isis-bcast", + 2044: "rimsl", + 2045: "cdfunc", + 2046: "sdfunc", + 2047: "dls", + 2048: "dls-monitor", + 2049: "shilp", + 2050: "av-emb-config", + 2051: "epnsdp", + 2052: "clearvisn", + 2053: "lot105-ds-upd", + 2054: "weblogin", + 2055: "iop", + 2056: "omnisky", + 2057: "rich-cp", + 2058: "newwavesearch", + 2059: "bmc-messaging", + 2060: "teleniumdaemon", + 2061: "netmount", + 2062: "icg-swp", + 2063: "icg-bridge", + 2064: "icg-iprelay", + 2065: "dlsrpn", + 2066: "aura", + 2067: "dlswpn", + 2068: "avauthsrvprtcl", + 2069: "event-port", + 2070: "ah-esp-encap", + 2071: "acp-port", + 2072: "msync", + 2073: "gxs-data-port", + 2074: "vrtl-vmf-sa", + 2075: "newlixengine", + 2076: "newlixconfig", + 2077: "tsrmagt", + 2078: "tpcsrvr", + 2079: "idware-router", + 2080: "autodesk-nlm", + 2081: "kme-trap-port", + 2082: "infowave", + 2083: "radsec", + 2084: "sunclustergeo", + 2085: "ada-cip", + 2086: "gnunet", + 2087: "eli", + 2088: "ip-blf", + 2089: "sep", + 2090: "lrp", + 2091: "prp", + 2092: "descent3", + 2093: "nbx-cc", + 2094: "nbx-au", + 2095: "nbx-ser", + 2096: "nbx-dir", + 2097: "jetformpreview", + 2098: "dialog-port", + 2099: "h2250-annex-g", + 2100: "amiganetfs", + 2101: "rtcm-sc104", + 2102: "zephyr-srv", + 2103: "zephyr-clt", + 2104: "zephyr-hm", + 2105: "minipay", + 2106: "mzap", + 2107: "bintec-admin", + 2108: "comcam", + 2109: "ergolight", + 2110: "umsp", + 2111: "dsatp", + 2112: "idonix-metanet", + 2113: "hsl-storm", + 2114: "newheights", + 2115: "kdm", + 2116: "ccowcmr", + 2117: "mentaclient", + 2118: "mentaserver", + 2119: "gsigatekeeper", + 2120: "qencp", + 2121: "scientia-ssdb", + 2122: "caupc-remote", + 2123: "gtp-control", + 2124: "elatelink", + 2125: "lockstep", + 2126: "pktcable-cops", + 2127: "index-pc-wb", + 2128: "net-steward", + 2129: "cs-live", + 2130: "xds", + 2131: "avantageb2b", + 2132: "solera-epmap", + 2133: "zymed-zpp", + 2134: "avenue", + 2135: "gris", + 2136: "appworxsrv", + 2137: "connect", + 2138: "unbind-cluster", + 2139: "ias-auth", + 2140: "ias-reg", + 2141: "ias-admind", + 2142: "tdmoip", + 2143: "lv-jc", + 2144: "lv-ffx", + 2145: "lv-pici", + 2146: "lv-not", + 2147: "lv-auth", + 2148: "veritas-ucl", + 2149: "acptsys", + 2150: "dynamic3d", + 2151: "docent", + 2152: "gtp-user", + 2153: "ctlptc", + 2154: "stdptc", + 2155: "brdptc", + 2156: "trp", + 2157: "xnds", + 2158: "touchnetplus", + 2159: "gdbremote", + 2160: "apc-2160", + 2161: "apc-2161", + 2162: "navisphere", + 2163: "navisphere-sec", + 2164: "ddns-v3", + 2165: "x-bone-api", + 2166: "iwserver", + 2167: "raw-serial", + 2168: "easy-soft-mux", + 2169: "brain", + 2170: "eyetv", + 2171: "msfw-storage", + 2172: "msfw-s-storage", + 2173: "msfw-replica", + 2174: "msfw-array", + 2175: "airsync", + 2176: "rapi", + 2177: "qwave", + 2178: "bitspeer", + 2179: "vmrdp", + 2180: "mc-gt-srv", + 2181: "eforward", + 2182: "cgn-stat", + 2183: "cgn-config", + 2184: "nvd", + 2185: "onbase-dds", + 2186: "gtaua", + 2187: "ssmc", + 2188: "radware-rpm", + 2189: "radware-rpm-s", + 2190: "tivoconnect", + 2191: "tvbus", + 2192: "asdis", + 2193: "drwcs", + 2197: "mnp-exchange", + 2198: "onehome-remote", + 2199: "onehome-help", + 2200: "ici", + 2201: "ats", + 2202: "imtc-map", + 2203: "b2-runtime", + 2204: "b2-license", + 2205: "jps", + 2206: "hpocbus", + 2207: "hpssd", + 2208: "hpiod", + 2209: "rimf-ps", + 2210: "noaaport", + 2211: "emwin", + 2212: "leecoposserver", + 2213: "kali", + 2214: "rpi", + 2215: "ipcore", + 2216: "vtu-comms", + 2217: "gotodevice", + 2218: "bounzza", + 2219: "netiq-ncap", + 2220: "netiq", + 2221: "ethernet-ip-s", + 2222: "EtherNet-IP-1", + 2223: "rockwell-csp2", + 2224: "efi-mg", + 2225: "rcip-itu", + 2226: "di-drm", + 2227: "di-msg", + 2228: "ehome-ms", + 2229: "datalens", + 2230: "queueadm", + 2231: "wimaxasncp", + 2232: "ivs-video", + 2233: "infocrypt", + 2234: "directplay", + 2235: "sercomm-wlink", + 2236: "nani", + 2237: "optech-port1-lm", + 2238: "aviva-sna", + 2239: "imagequery", + 2240: "recipe", + 2241: "ivsd", + 2242: "foliocorp", + 2243: "magicom", + 2244: "nmsserver", + 2245: "hao", + 2246: "pc-mta-addrmap", + 2247: "antidotemgrsvr", + 2248: "ums", + 2249: "rfmp", + 2250: "remote-collab", + 2251: "dif-port", + 2252: "njenet-ssl", + 2253: "dtv-chan-req", + 2254: "seispoc", + 2255: "vrtp", + 2256: "pcc-mfp", + 2257: "simple-tx-rx", + 2258: "rcts", + 2260: "apc-2260", + 2261: "comotionmaster", + 2262: "comotionback", + 2263: "ecwcfg", + 2264: "apx500api-1", + 2265: "apx500api-2", + 2266: "mfserver", + 2267: "ontobroker", + 2268: "amt", + 2269: "mikey", + 2270: "starschool", + 2271: "mmcals", + 2272: "mmcal", + 2273: "mysql-im", + 2274: "pcttunnell", + 2275: "ibridge-data", + 2276: "ibridge-mgmt", + 2277: "bluectrlproxy", + 2278: "s3db", + 2279: "xmquery", + 2280: "lnvpoller", + 2281: "lnvconsole", + 2282: "lnvalarm", + 2283: "lnvstatus", + 2284: "lnvmaps", + 2285: "lnvmailmon", + 2286: "nas-metering", + 2287: "dna", + 2288: "netml", + 2289: "dict-lookup", + 2290: "sonus-logging", + 2291: "eapsp", + 2292: "mib-streaming", + 2293: "npdbgmngr", + 2294: "konshus-lm", + 2295: "advant-lm", + 2296: "theta-lm", + 2297: "d2k-datamover1", + 2298: "d2k-datamover2", + 2299: "pc-telecommute", + 2300: "cvmmon", + 2301: "cpq-wbem", + 2302: "binderysupport", + 2303: "proxy-gateway", + 2304: "attachmate-uts", + 2305: "mt-scaleserver", + 2306: "tappi-boxnet", + 2307: "pehelp", + 2308: "sdhelp", + 2309: "sdserver", + 2310: "sdclient", + 2311: "messageservice", + 2312: "wanscaler", + 2313: "iapp", + 2314: "cr-websystems", + 2315: "precise-sft", + 2316: "sent-lm", + 2317: "attachmate-g32", + 2318: "cadencecontrol", + 2319: "infolibria", + 2320: "siebel-ns", + 2321: "rdlap", + 2322: "ofsd", + 2323: "3d-nfsd", + 2324: "cosmocall", + 2325: "ansysli", + 2326: "idcp", + 2327: "xingcsm", + 2328: "netrix-sftm", + 2329: "nvd", + 2330: "tscchat", + 2331: "agentview", + 2332: "rcc-host", + 2333: "snapp", + 2334: "ace-client", + 2335: "ace-proxy", + 2336: "appleugcontrol", + 2337: "ideesrv", + 2338: "norton-lambert", + 2339: "3com-webview", + 2340: "wrs-registry", + 2341: "xiostatus", + 2342: "manage-exec", + 2343: "nati-logos", + 2344: "fcmsys", + 2345: "dbm", + 2346: "redstorm-join", + 2347: "redstorm-find", + 2348: "redstorm-info", + 2349: "redstorm-diag", + 2350: "psbserver", + 2351: "psrserver", + 2352: "pslserver", + 2353: "pspserver", + 2354: "psprserver", + 2355: "psdbserver", + 2356: "gxtelmd", + 2357: "unihub-server", + 2358: "futrix", + 2359: "flukeserver", + 2360: "nexstorindltd", + 2361: "tl1", + 2362: "digiman", + 2363: "mediacntrlnfsd", + 2364: "oi-2000", + 2365: "dbref", + 2366: "qip-login", + 2367: "service-ctrl", + 2368: "opentable", + 2370: "l3-hbmon", + 2371: "hp-rda", + 2372: "lanmessenger", + 2373: "remographlm", + 2374: "hydra", + 2375: "docker", + 2376: "docker-s", + 2377: "swarm", + 2379: "etcd-client", + 2380: "etcd-server", + 2381: "compaq-https", + 2382: "ms-olap3", + 2383: "ms-olap4", + 2384: "sd-request", + 2385: "sd-data", + 2386: "virtualtape", + 2387: "vsamredirector", + 2388: "mynahautostart", + 2389: "ovsessionmgr", + 2390: "rsmtp", + 2391: "3com-net-mgmt", + 2392: "tacticalauth", + 2393: "ms-olap1", + 2394: "ms-olap2", + 2395: "lan900-remote", + 2396: "wusage", + 2397: "ncl", + 2398: "orbiter", + 2399: "fmpro-fdal", + 2400: "opequus-server", + 2401: "cvspserver", + 2402: "taskmaster2000", + 2403: "taskmaster2000", + 2404: "iec-104", + 2405: "trc-netpoll", + 2406: "jediserver", + 2407: "orion", + 2408: "railgun-webaccl", + 2409: "sns-protocol", + 2410: "vrts-registry", + 2411: "netwave-ap-mgmt", + 2412: "cdn", + 2413: "orion-rmi-reg", + 2414: "beeyond", + 2415: "codima-rtp", + 2416: "rmtserver", + 2417: "composit-server", + 2418: "cas", + 2419: "attachmate-s2s", + 2420: "dslremote-mgmt", + 2421: "g-talk", + 2422: "crmsbits", + 2423: "rnrp", + 2424: "kofax-svr", + 2425: "fjitsuappmgr", + 2426: "vcmp", + 2427: "mgcp-gateway", + 2428: "ott", + 2429: "ft-role", + 2430: "venus", + 2431: "venus-se", + 2432: "codasrv", + 2433: "codasrv-se", + 2434: "pxc-epmap", + 2435: "optilogic", + 2436: "topx", + 2437: "unicontrol", + 2438: "msp", + 2439: "sybasedbsynch", + 2440: "spearway", + 2441: "pvsw-inet", + 2442: "netangel", + 2443: "powerclientcsf", + 2444: "btpp2sectrans", + 2445: "dtn1", + 2446: "bues-service", + 2447: "ovwdb", + 2448: "hpppssvr", + 2449: "ratl", + 2450: "netadmin", + 2451: "netchat", + 2452: "snifferclient", + 2453: "madge-ltd", + 2454: "indx-dds", + 2455: "wago-io-system", + 2456: "altav-remmgt", + 2457: "rapido-ip", + 2458: "griffin", + 2459: "community", + 2460: "ms-theater", + 2461: "qadmifoper", + 2462: "qadmifevent", + 2463: "lsi-raid-mgmt", + 2464: "direcpc-si", + 2465: "lbm", + 2466: "lbf", + 2467: "high-criteria", + 2468: "qip-msgd", + 2469: "mti-tcs-comm", + 2470: "taskman-port", + 2471: "seaodbc", + 2472: "c3", + 2473: "aker-cdp", + 2474: "vitalanalysis", + 2475: "ace-server", + 2476: "ace-svr-prop", + 2477: "ssm-cvs", + 2478: "ssm-cssps", + 2479: "ssm-els", + 2480: "powerexchange", + 2481: "giop", + 2482: "giop-ssl", + 2483: "ttc", + 2484: "ttc-ssl", + 2485: "netobjects1", + 2486: "netobjects2", + 2487: "pns", + 2488: "moy-corp", + 2489: "tsilb", + 2490: "qip-qdhcp", + 2491: "conclave-cpp", + 2492: "groove", + 2493: "talarian-mqs", + 2494: "bmc-ar", + 2495: "fast-rem-serv", + 2496: "dirgis", + 2497: "quaddb", + 2498: "odn-castraq", + 2499: "unicontrol", + 2500: "rtsserv", + 2501: "rtsclient", + 2502: "kentrox-prot", + 2503: "nms-dpnss", + 2504: "wlbs", + 2505: "ppcontrol", + 2506: "jbroker", + 2507: "spock", + 2508: "jdatastore", + 2509: "fjmpss", + 2510: "fjappmgrbulk", + 2511: "metastorm", + 2512: "citrixima", + 2513: "citrixadmin", + 2514: "facsys-ntp", + 2515: "facsys-router", + 2516: "maincontrol", + 2517: "call-sig-trans", + 2518: "willy", + 2519: "globmsgsvc", + 2520: "pvsw", + 2521: "adaptecmgr", + 2522: "windb", + 2523: "qke-llc-v3", + 2524: "optiwave-lm", + 2525: "ms-v-worlds", + 2526: "ema-sent-lm", + 2527: "iqserver", + 2528: "ncr-ccl", + 2529: "utsftp", + 2530: "vrcommerce", + 2531: "ito-e-gui", + 2532: "ovtopmd", + 2533: "snifferserver", + 2534: "combox-web-acc", + 2535: "madcap", + 2536: "btpp2audctr1", + 2537: "upgrade", + 2538: "vnwk-prapi", + 2539: "vsiadmin", + 2540: "lonworks", + 2541: "lonworks2", + 2542: "udrawgraph", + 2543: "reftek", + 2544: "novell-zen", + 2545: "sis-emt", + 2546: "vytalvaultbrtp", + 2547: "vytalvaultvsmp", + 2548: "vytalvaultpipe", + 2549: "ipass", + 2550: "ads", + 2551: "isg-uda-server", + 2552: "call-logging", + 2553: "efidiningport", + 2554: "vcnet-link-v10", + 2555: "compaq-wcp", + 2556: "nicetec-nmsvc", + 2557: "nicetec-mgmt", + 2558: "pclemultimedia", + 2559: "lstp", + 2560: "labrat", + 2561: "mosaixcc", + 2562: "delibo", + 2563: "cti-redwood", + 2564: "hp-3000-telnet", + 2565: "coord-svr", + 2566: "pcs-pcw", + 2567: "clp", + 2568: "spamtrap", + 2569: "sonuscallsig", + 2570: "hs-port", + 2571: "cecsvc", + 2572: "ibp", + 2573: "trustestablish", + 2574: "blockade-bpsp", + 2575: "hl7", + 2576: "tclprodebugger", + 2577: "scipticslsrvr", + 2578: "rvs-isdn-dcp", + 2579: "mpfoncl", + 2580: "tributary", + 2581: "argis-te", + 2582: "argis-ds", + 2583: "mon", + 2584: "cyaserv", + 2585: "netx-server", + 2586: "netx-agent", + 2587: "masc", + 2588: "privilege", + 2589: "quartus-tcl", + 2590: "idotdist", + 2591: "maytagshuffle", + 2592: "netrek", + 2593: "mns-mail", + 2594: "dts", + 2595: "worldfusion1", + 2596: "worldfusion2", + 2597: "homesteadglory", + 2598: "citriximaclient", + 2599: "snapd", + 2600: "hpstgmgr", + 2601: "discp-client", + 2602: "discp-server", + 2603: "servicemeter", + 2604: "nsc-ccs", + 2605: "nsc-posa", + 2606: "netmon", + 2607: "connection", + 2608: "wag-service", + 2609: "system-monitor", + 2610: "versa-tek", + 2611: "lionhead", + 2612: "qpasa-agent", + 2613: "smntubootstrap", + 2614: "neveroffline", + 2615: "firepower", + 2616: "appswitch-emp", + 2617: "cmadmin", + 2618: "priority-e-com", + 2619: "bruce", + 2620: "lpsrecommender", + 2621: "miles-apart", + 2622: "metricadbc", + 2623: "lmdp", + 2624: "aria", + 2625: "blwnkl-port", + 2626: "gbjd816", + 2627: "moshebeeri", + 2628: "dict", + 2629: "sitaraserver", + 2630: "sitaramgmt", + 2631: "sitaradir", + 2632: "irdg-post", + 2633: "interintelli", + 2634: "pk-electronics", + 2635: "backburner", + 2636: "solve", + 2637: "imdocsvc", + 2638: "sybaseanywhere", + 2639: "aminet", + 2640: "ami-control", + 2641: "hdl-srv", + 2642: "tragic", + 2643: "gte-samp", + 2644: "travsoft-ipx-t", + 2645: "novell-ipx-cmd", + 2646: "and-lm", + 2647: "syncserver", + 2648: "upsnotifyprot", + 2649: "vpsipport", + 2650: "eristwoguns", + 2651: "ebinsite", + 2652: "interpathpanel", + 2653: "sonus", + 2654: "corel-vncadmin", + 2655: "unglue", + 2656: "kana", + 2657: "sns-dispatcher", + 2658: "sns-admin", + 2659: "sns-query", + 2660: "gcmonitor", + 2661: "olhost", + 2662: "bintec-capi", + 2663: "bintec-tapi", + 2664: "patrol-mq-gm", + 2665: "patrol-mq-nm", + 2666: "extensis", + 2667: "alarm-clock-s", + 2668: "alarm-clock-c", + 2669: "toad", + 2670: "tve-announce", + 2671: "newlixreg", + 2672: "nhserver", + 2673: "firstcall42", + 2674: "ewnn", + 2675: "ttc-etap", + 2676: "simslink", + 2677: "gadgetgate1way", + 2678: "gadgetgate2way", + 2679: "syncserverssl", + 2680: "pxc-sapxom", + 2681: "mpnjsomb", + 2683: "ncdloadbalance", + 2684: "mpnjsosv", + 2685: "mpnjsocl", + 2686: "mpnjsomg", + 2687: "pq-lic-mgmt", + 2688: "md-cg-http", + 2689: "fastlynx", + 2690: "hp-nnm-data", + 2691: "itinternet", + 2692: "admins-lms", + 2694: "pwrsevent", + 2695: "vspread", + 2696: "unifyadmin", + 2697: "oce-snmp-trap", + 2698: "mck-ivpip", + 2699: "csoft-plusclnt", + 2700: "tqdata", + 2701: "sms-rcinfo", + 2702: "sms-xfer", + 2703: "sms-chat", + 2704: "sms-remctrl", + 2705: "sds-admin", + 2706: "ncdmirroring", + 2707: "emcsymapiport", + 2708: "banyan-net", + 2709: "supermon", + 2710: "sso-service", + 2711: "sso-control", + 2712: "aocp", + 2713: "raventbs", + 2714: "raventdm", + 2715: "hpstgmgr2", + 2716: "inova-ip-disco", + 2717: "pn-requester", + 2718: "pn-requester2", + 2719: "scan-change", + 2720: "wkars", + 2721: "smart-diagnose", + 2722: "proactivesrvr", + 2723: "watchdog-nt", + 2724: "qotps", + 2725: "msolap-ptp2", + 2726: "tams", + 2727: "mgcp-callagent", + 2728: "sqdr", + 2729: "tcim-control", + 2730: "nec-raidplus", + 2731: "fyre-messanger", + 2732: "g5m", + 2733: "signet-ctf", + 2734: "ccs-software", + 2735: "netiq-mc", + 2736: "radwiz-nms-srv", + 2737: "srp-feedback", + 2738: "ndl-tcp-ois-gw", + 2739: "tn-timing", + 2740: "alarm", + 2741: "tsb", + 2742: "tsb2", + 2743: "murx", + 2744: "honyaku", + 2745: "urbisnet", + 2746: "cpudpencap", + 2747: "fjippol-swrly", + 2748: "fjippol-polsvr", + 2749: "fjippol-cnsl", + 2750: "fjippol-port1", + 2751: "fjippol-port2", + 2752: "rsisysaccess", + 2753: "de-spot", + 2754: "apollo-cc", + 2755: "expresspay", + 2756: "simplement-tie", + 2757: "cnrp", + 2758: "apollo-status", + 2759: "apollo-gms", + 2760: "sabams", + 2761: "dicom-iscl", + 2762: "dicom-tls", + 2763: "desktop-dna", + 2764: "data-insurance", + 2765: "qip-audup", + 2766: "compaq-scp", + 2767: "uadtc", + 2768: "uacs", + 2769: "exce", + 2770: "veronica", + 2771: "vergencecm", + 2772: "auris", + 2773: "rbakcup1", + 2774: "rbakcup2", + 2775: "smpp", + 2776: "ridgeway1", + 2777: "ridgeway2", + 2778: "gwen-sonya", + 2779: "lbc-sync", + 2780: "lbc-control", + 2781: "whosells", + 2782: "everydayrc", + 2783: "aises", + 2784: "www-dev", + 2785: "aic-np", + 2786: "aic-oncrpc", + 2787: "piccolo", + 2788: "fryeserv", + 2789: "media-agent", + 2790: "plgproxy", + 2791: "mtport-regist", + 2792: "f5-globalsite", + 2793: "initlsmsad", + 2795: "livestats", + 2796: "ac-tech", + 2797: "esp-encap", + 2798: "tmesis-upshot", + 2799: "icon-discover", + 2800: "acc-raid", + 2801: "igcp", + 2802: "veritas-tcp1", + 2803: "btprjctrl", + 2804: "dvr-esm", + 2805: "wta-wsp-s", + 2806: "cspuni", + 2807: "cspmulti", + 2808: "j-lan-p", + 2809: "corbaloc", + 2810: "netsteward", + 2811: "gsiftp", + 2812: "atmtcp", + 2813: "llm-pass", + 2814: "llm-csv", + 2815: "lbc-measure", + 2816: "lbc-watchdog", + 2817: "nmsigport", + 2818: "rmlnk", + 2819: "fc-faultnotify", + 2820: "univision", + 2821: "vrts-at-port", + 2822: "ka0wuc", + 2823: "cqg-netlan", + 2824: "cqg-netlan-1", + 2826: "slc-systemlog", + 2827: "slc-ctrlrloops", + 2828: "itm-lm", + 2829: "silkp1", + 2830: "silkp2", + 2831: "silkp3", + 2832: "silkp4", + 2833: "glishd", + 2834: "evtp", + 2835: "evtp-data", + 2836: "catalyst", + 2837: "repliweb", + 2838: "starbot", + 2839: "nmsigport", + 2840: "l3-exprt", + 2841: "l3-ranger", + 2842: "l3-hawk", + 2843: "pdnet", + 2844: "bpcp-poll", + 2845: "bpcp-trap", + 2846: "aimpp-hello", + 2847: "aimpp-port-req", + 2848: "amt-blc-port", + 2849: "fxp", + 2850: "metaconsole", + 2851: "webemshttp", + 2852: "bears-01", + 2853: "ispipes", + 2854: "infomover", + 2855: "msrp", + 2856: "cesdinv", + 2857: "simctlp", + 2858: "ecnp", + 2859: "activememory", + 2860: "dialpad-voice1", + 2861: "dialpad-voice2", + 2862: "ttg-protocol", + 2863: "sonardata", + 2864: "astromed-main", + 2865: "pit-vpn", + 2866: "iwlistener", + 2867: "esps-portal", + 2868: "npep-messaging", + 2869: "icslap", + 2870: "daishi", + 2871: "msi-selectplay", + 2872: "radix", + 2874: "dxmessagebase1", + 2875: "dxmessagebase2", + 2876: "sps-tunnel", + 2877: "bluelance", + 2878: "aap", + 2879: "ucentric-ds", + 2880: "synapse", + 2881: "ndsp", + 2882: "ndtp", + 2883: "ndnp", + 2884: "flashmsg", + 2885: "topflow", + 2886: "responselogic", + 2887: "aironetddp", + 2888: "spcsdlobby", + 2889: "rsom", + 2890: "cspclmulti", + 2891: "cinegrfx-elmd", + 2892: "snifferdata", + 2893: "vseconnector", + 2894: "abacus-remote", + 2895: "natuslink", + 2896: "ecovisiong6-1", + 2897: "citrix-rtmp", + 2898: "appliance-cfg", + 2899: "powergemplus", + 2900: "quicksuite", + 2901: "allstorcns", + 2902: "netaspi", + 2903: "suitcase", + 2904: "m2ua", + 2905: "m3ua", + 2906: "caller9", + 2907: "webmethods-b2b", + 2908: "mao", + 2909: "funk-dialout", + 2910: "tdaccess", + 2911: "blockade", + 2912: "epicon", + 2913: "boosterware", + 2914: "gamelobby", + 2915: "tksocket", + 2916: "elvin-server", + 2917: "elvin-client", + 2918: "kastenchasepad", + 2919: "roboer", + 2920: "roboeda", + 2921: "cesdcdman", + 2922: "cesdcdtrn", + 2923: "wta-wsp-wtp-s", + 2924: "precise-vip", + 2926: "mobile-file-dl", + 2927: "unimobilectrl", + 2928: "redstone-cpss", + 2929: "amx-webadmin", + 2930: "amx-weblinx", + 2931: "circle-x", + 2932: "incp", + 2933: "4-tieropmgw", + 2934: "4-tieropmcli", + 2935: "qtp", + 2936: "otpatch", + 2937: "pnaconsult-lm", + 2938: "sm-pas-1", + 2939: "sm-pas-2", + 2940: "sm-pas-3", + 2941: "sm-pas-4", + 2942: "sm-pas-5", + 2943: "ttnrepository", + 2944: "megaco-h248", + 2945: "h248-binary", + 2946: "fjsvmpor", + 2947: "gpsd", + 2948: "wap-push", + 2949: "wap-pushsecure", + 2950: "esip", + 2951: "ottp", + 2952: "mpfwsas", + 2953: "ovalarmsrv", + 2954: "ovalarmsrv-cmd", + 2955: "csnotify", + 2956: "ovrimosdbman", + 2957: "jmact5", + 2958: "jmact6", + 2959: "rmopagt", + 2960: "dfoxserver", + 2961: "boldsoft-lm", + 2962: "iph-policy-cli", + 2963: "iph-policy-adm", + 2964: "bullant-srap", + 2965: "bullant-rap", + 2966: "idp-infotrieve", + 2967: "ssc-agent", + 2968: "enpp", + 2969: "essp", + 2970: "index-net", + 2971: "netclip", + 2972: "pmsm-webrctl", + 2973: "svnetworks", + 2974: "signal", + 2975: "fjmpcm", + 2976: "cns-srv-port", + 2977: "ttc-etap-ns", + 2978: "ttc-etap-ds", + 2979: "h263-video", + 2980: "wimd", + 2981: "mylxamport", + 2982: "iwb-whiteboard", + 2983: "netplan", + 2984: "hpidsadmin", + 2985: "hpidsagent", + 2986: "stonefalls", + 2987: "identify", + 2988: "hippad", + 2989: "zarkov", + 2990: "boscap", + 2991: "wkstn-mon", + 2992: "avenyo", + 2993: "veritas-vis1", + 2994: "veritas-vis2", + 2995: "idrs", + 2996: "vsixml", + 2997: "rebol", + 2998: "realsecure", + 2999: "remoteware-un", + 3000: "hbci", + 3001: "origo-native", + 3002: "exlm-agent", + 3003: "cgms", + 3004: "csoftragent", + 3005: "geniuslm", + 3006: "ii-admin", + 3007: "lotusmtap", + 3008: "midnight-tech", + 3009: "pxc-ntfy", + 3010: "gw", + 3011: "trusted-web", + 3012: "twsdss", + 3013: "gilatskysurfer", + 3014: "broker-service", + 3015: "nati-dstp", + 3016: "notify-srvr", + 3017: "event-listener", + 3018: "srvc-registry", + 3019: "resource-mgr", + 3020: "cifs", + 3021: "agriserver", + 3022: "csregagent", + 3023: "magicnotes", + 3024: "nds-sso", + 3025: "arepa-raft", + 3026: "agri-gateway", + 3027: "LiebDevMgmt-C", + 3028: "LiebDevMgmt-DM", + 3029: "LiebDevMgmt-A", + 3030: "arepa-cas", + 3031: "eppc", + 3032: "redwood-chat", + 3033: "pdb", + 3034: "osmosis-aeea", + 3035: "fjsv-gssagt", + 3036: "hagel-dump", + 3037: "hp-san-mgmt", + 3038: "santak-ups", + 3039: "cogitate", + 3040: "tomato-springs", + 3041: "di-traceware", + 3042: "journee", + 3043: "brp", + 3044: "epp", + 3045: "responsenet", + 3046: "di-ase", + 3047: "hlserver", + 3048: "pctrader", + 3049: "nsws", + 3050: "gds-db", + 3051: "galaxy-server", + 3052: "apc-3052", + 3053: "dsom-server", + 3054: "amt-cnf-prot", + 3055: "policyserver", + 3056: "cdl-server", + 3057: "goahead-fldup", + 3058: "videobeans", + 3059: "qsoft", + 3060: "interserver", + 3061: "cautcpd", + 3062: "ncacn-ip-tcp", + 3063: "ncadg-ip-udp", + 3064: "rprt", + 3065: "slinterbase", + 3066: "netattachsdmp", + 3067: "fjhpjp", + 3068: "ls3bcast", + 3069: "ls3", + 3070: "mgxswitch", + 3071: "csd-mgmt-port", + 3072: "csd-monitor", + 3073: "vcrp", + 3074: "xbox", + 3075: "orbix-locator", + 3076: "orbix-config", + 3077: "orbix-loc-ssl", + 3078: "orbix-cfg-ssl", + 3079: "lv-frontpanel", + 3080: "stm-pproc", + 3081: "tl1-lv", + 3082: "tl1-raw", + 3083: "tl1-telnet", + 3084: "itm-mccs", + 3085: "pcihreq", + 3086: "jdl-dbkitchen", + 3087: "asoki-sma", + 3088: "xdtp", + 3089: "ptk-alink", + 3090: "stss", + 3091: "1ci-smcs", + 3093: "rapidmq-center", + 3094: "rapidmq-reg", + 3095: "panasas", + 3096: "ndl-aps", + 3098: "umm-port", + 3099: "chmd", + 3100: "opcon-xps", + 3101: "hp-pxpib", + 3102: "slslavemon", + 3103: "autocuesmi", + 3104: "autocuelog", + 3105: "cardbox", + 3106: "cardbox-http", + 3107: "business", + 3108: "geolocate", + 3109: "personnel", + 3110: "sim-control", + 3111: "wsynch", + 3112: "ksysguard", + 3113: "cs-auth-svr", + 3114: "ccmad", + 3115: "mctet-master", + 3116: "mctet-gateway", + 3117: "mctet-jserv", + 3118: "pkagent", + 3119: "d2000kernel", + 3120: "d2000webserver", + 3121: "pcmk-remote", + 3122: "vtr-emulator", + 3123: "edix", + 3124: "beacon-port", + 3125: "a13-an", + 3127: "ctx-bridge", + 3128: "ndl-aas", + 3129: "netport-id", + 3130: "icpv2", + 3131: "netbookmark", + 3132: "ms-rule-engine", + 3133: "prism-deploy", + 3134: "ecp", + 3135: "peerbook-port", + 3136: "grubd", + 3137: "rtnt-1", + 3138: "rtnt-2", + 3139: "incognitorv", + 3140: "ariliamulti", + 3141: "vmodem", + 3142: "rdc-wh-eos", + 3143: "seaview", + 3144: "tarantella", + 3145: "csi-lfap", + 3146: "bears-02", + 3147: "rfio", + 3148: "nm-game-admin", + 3149: "nm-game-server", + 3150: "nm-asses-admin", + 3151: "nm-assessor", + 3152: "feitianrockey", + 3153: "s8-client-port", + 3154: "ccmrmi", + 3155: "jpegmpeg", + 3156: "indura", + 3157: "e3consultants", + 3158: "stvp", + 3159: "navegaweb-port", + 3160: "tip-app-server", + 3161: "doc1lm", + 3162: "sflm", + 3163: "res-sap", + 3164: "imprs", + 3165: "newgenpay", + 3166: "sossecollector", + 3167: "nowcontact", + 3168: "poweronnud", + 3169: "serverview-as", + 3170: "serverview-asn", + 3171: "serverview-gf", + 3172: "serverview-rm", + 3173: "serverview-icc", + 3174: "armi-server", + 3175: "t1-e1-over-ip", + 3176: "ars-master", + 3177: "phonex-port", + 3178: "radclientport", + 3179: "h2gf-w-2m", + 3180: "mc-brk-srv", + 3181: "bmcpatrolagent", + 3182: "bmcpatrolrnvu", + 3183: "cops-tls", + 3184: "apogeex-port", + 3185: "smpppd", + 3186: "iiw-port", + 3187: "odi-port", + 3188: "brcm-comm-port", + 3189: "pcle-infex", + 3190: "csvr-proxy", + 3191: "csvr-sslproxy", + 3192: "firemonrcc", + 3193: "spandataport", + 3194: "magbind", + 3195: "ncu-1", + 3196: "ncu-2", + 3197: "embrace-dp-s", + 3198: "embrace-dp-c", + 3199: "dmod-workspace", + 3200: "tick-port", + 3201: "cpq-tasksmart", + 3202: "intraintra", + 3203: "netwatcher-mon", + 3204: "netwatcher-db", + 3205: "isns", + 3206: "ironmail", + 3207: "vx-auth-port", + 3208: "pfu-prcallback", + 3209: "netwkpathengine", + 3210: "flamenco-proxy", + 3211: "avsecuremgmt", + 3212: "surveyinst", + 3213: "neon24x7", + 3214: "jmq-daemon-1", + 3215: "jmq-daemon-2", + 3216: "ferrari-foam", + 3217: "unite", + 3218: "smartpackets", + 3219: "wms-messenger", + 3220: "xnm-ssl", + 3221: "xnm-clear-text", + 3222: "glbp", + 3223: "digivote", + 3224: "aes-discovery", + 3225: "fcip-port", + 3226: "isi-irp", + 3227: "dwnmshttp", + 3228: "dwmsgserver", + 3229: "global-cd-port", + 3230: "sftdst-port", + 3231: "vidigo", + 3232: "mdtp", + 3233: "whisker", + 3234: "alchemy", + 3235: "mdap-port", + 3236: "apparenet-ts", + 3237: "apparenet-tps", + 3238: "apparenet-as", + 3239: "apparenet-ui", + 3240: "triomotion", + 3241: "sysorb", + 3242: "sdp-id-port", + 3243: "timelot", + 3244: "onesaf", + 3245: "vieo-fe", + 3246: "dvt-system", + 3247: "dvt-data", + 3248: "procos-lm", + 3249: "ssp", + 3250: "hicp", + 3251: "sysscanner", + 3252: "dhe", + 3253: "pda-data", + 3254: "pda-sys", + 3255: "semaphore", + 3256: "cpqrpm-agent", + 3257: "cpqrpm-server", + 3258: "ivecon-port", + 3259: "epncdp2", + 3260: "iscsi-target", + 3261: "winshadow", + 3262: "necp", + 3263: "ecolor-imager", + 3264: "ccmail", + 3265: "altav-tunnel", + 3266: "ns-cfg-server", + 3267: "ibm-dial-out", + 3268: "msft-gc", + 3269: "msft-gc-ssl", + 3270: "verismart", + 3271: "csoft-prev", + 3272: "user-manager", + 3273: "sxmp", + 3274: "ordinox-server", + 3275: "samd", + 3276: "maxim-asics", + 3277: "awg-proxy", + 3278: "lkcmserver", + 3279: "admind", + 3280: "vs-server", + 3281: "sysopt", + 3282: "datusorb", + 3283: "Apple Remote Desktop (Net Assistant)", + 3284: "4talk", + 3285: "plato", + 3286: "e-net", + 3287: "directvdata", + 3288: "cops", + 3289: "enpc", + 3290: "caps-lm", + 3291: "sah-lm", + 3292: "cart-o-rama", + 3293: "fg-fps", + 3294: "fg-gip", + 3295: "dyniplookup", + 3296: "rib-slm", + 3297: "cytel-lm", + 3298: "deskview", + 3299: "pdrncs", + 3300: "ceph", + 3302: "mcs-fastmail", + 3303: "opsession-clnt", + 3304: "opsession-srvr", + 3305: "odette-ftp", + 3306: "mysql", + 3307: "opsession-prxy", + 3308: "tns-server", + 3309: "tns-adv", + 3310: "dyna-access", + 3311: "mcns-tel-ret", + 3312: "appman-server", + 3313: "uorb", + 3314: "uohost", + 3315: "cdid", + 3316: "aicc-cmi", + 3317: "vsaiport", + 3318: "ssrip", + 3319: "sdt-lmd", + 3320: "officelink2000", + 3321: "vnsstr", + 3326: "sftu", + 3327: "bbars", + 3328: "egptlm", + 3329: "hp-device-disc", + 3330: "mcs-calypsoicf", + 3331: "mcs-messaging", + 3332: "mcs-mailsvr", + 3333: "dec-notes", + 3334: "directv-web", + 3335: "directv-soft", + 3336: "directv-tick", + 3337: "directv-catlg", + 3338: "anet-b", + 3339: "anet-l", + 3340: "anet-m", + 3341: "anet-h", + 3342: "webtie", + 3343: "ms-cluster-net", + 3344: "bnt-manager", + 3345: "influence", + 3346: "trnsprntproxy", + 3347: "phoenix-rpc", + 3348: "pangolin-laser", + 3349: "chevinservices", + 3350: "findviatv", + 3351: "btrieve", + 3352: "ssql", + 3353: "fatpipe", + 3354: "suitjd", + 3355: "ordinox-dbase", + 3356: "upnotifyps", + 3357: "adtech-test", + 3358: "mpsysrmsvr", + 3359: "wg-netforce", + 3360: "kv-server", + 3361: "kv-agent", + 3362: "dj-ilm", + 3363: "nati-vi-server", + 3364: "creativeserver", + 3365: "contentserver", + 3366: "creativepartnr", + 3372: "tip2", + 3373: "lavenir-lm", + 3374: "cluster-disc", + 3375: "vsnm-agent", + 3376: "cdbroker", + 3377: "cogsys-lm", + 3378: "wsicopy", + 3379: "socorfs", + 3380: "sns-channels", + 3381: "geneous", + 3382: "fujitsu-neat", + 3383: "esp-lm", + 3384: "hp-clic", + 3385: "qnxnetman", + 3386: "gprs-data", + 3387: "backroomnet", + 3388: "cbserver", + 3389: "ms-wbt-server", + 3390: "dsc", + 3391: "savant", + 3392: "efi-lm", + 3393: "d2k-tapestry1", + 3394: "d2k-tapestry2", + 3395: "dyna-lm", + 3396: "printer-agent", + 3397: "cloanto-lm", + 3398: "mercantile", + 3399: "csms", + 3400: "csms2", + 3401: "filecast", + 3402: "fxaengine-net", + 3405: "nokia-ann-ch1", + 3406: "nokia-ann-ch2", + 3407: "ldap-admin", + 3408: "BESApi", + 3409: "networklens", + 3410: "networklenss", + 3411: "biolink-auth", + 3412: "xmlblaster", + 3413: "svnet", + 3414: "wip-port", + 3415: "bcinameservice", + 3416: "commandport", + 3417: "csvr", + 3418: "rnmap", + 3419: "softaudit", + 3420: "ifcp-port", + 3421: "bmap", + 3422: "rusb-sys-port", + 3423: "xtrm", + 3424: "xtrms", + 3425: "agps-port", + 3426: "arkivio", + 3427: "websphere-snmp", + 3428: "twcss", + 3429: "gcsp", + 3430: "ssdispatch", + 3431: "ndl-als", + 3432: "osdcp", + 3433: "opnet-smp", + 3434: "opencm", + 3435: "pacom", + 3436: "gc-config", + 3437: "autocueds", + 3438: "spiral-admin", + 3439: "hri-port", + 3440: "ans-console", + 3441: "connect-client", + 3442: "connect-server", + 3443: "ov-nnm-websrv", + 3444: "denali-server", + 3445: "monp", + 3446: "3comfaxrpc", + 3447: "directnet", + 3448: "dnc-port", + 3449: "hotu-chat", + 3450: "castorproxy", + 3451: "asam", + 3452: "sabp-signal", + 3453: "pscupd", + 3454: "mira", + 3455: "prsvp", + 3456: "vat", + 3457: "vat-control", + 3458: "d3winosfi", + 3459: "integral", + 3460: "edm-manager", + 3461: "edm-stager", + 3462: "edm-std-notify", + 3463: "edm-adm-notify", + 3464: "edm-mgr-sync", + 3465: "edm-mgr-cntrl", + 3466: "workflow", + 3467: "rcst", + 3468: "ttcmremotectrl", + 3469: "pluribus", + 3470: "jt400", + 3471: "jt400-ssl", + 3472: "jaugsremotec-1", + 3473: "jaugsremotec-2", + 3474: "ttntspauto", + 3475: "genisar-port", + 3476: "nppmp", + 3477: "ecomm", + 3478: "stun", + 3479: "twrpc", + 3480: "plethora", + 3481: "cleanerliverc", + 3482: "vulture", + 3483: "slim-devices", + 3484: "gbs-stp", + 3485: "celatalk", + 3486: "ifsf-hb-port", + 3487: "ltctcp", + 3488: "fs-rh-srv", + 3489: "dtp-dia", + 3490: "colubris", + 3491: "swr-port", + 3492: "tvdumtray-port", + 3493: "nut", + 3494: "ibm3494", + 3495: "seclayer-tcp", + 3496: "seclayer-tls", + 3497: "ipether232port", + 3498: "dashpas-port", + 3499: "sccip-media", + 3500: "rtmp-port", + 3501: "isoft-p2p", + 3502: "avinstalldisc", + 3503: "lsp-ping", + 3504: "ironstorm", + 3505: "ccmcomm", + 3506: "apc-3506", + 3507: "nesh-broker", + 3508: "interactionweb", + 3509: "vt-ssl", + 3510: "xss-port", + 3511: "webmail-2", + 3512: "aztec", + 3513: "arcpd", + 3514: "must-p2p", + 3515: "must-backplane", + 3516: "smartcard-port", + 3517: "802-11-iapp", + 3518: "artifact-msg", + 3519: "nvmsgd", + 3520: "galileolog", + 3521: "mc3ss", + 3522: "nssocketport", + 3523: "odeumservlink", + 3524: "ecmport", + 3525: "eisport", + 3526: "starquiz-port", + 3527: "beserver-msg-q", + 3528: "jboss-iiop", + 3529: "jboss-iiop-ssl", + 3530: "gf", + 3531: "joltid", + 3532: "raven-rmp", + 3533: "raven-rdp", + 3534: "urld-port", + 3535: "ms-la", + 3536: "snac", + 3537: "ni-visa-remote", + 3538: "ibm-diradm", + 3539: "ibm-diradm-ssl", + 3540: "pnrp-port", + 3541: "voispeed-port", + 3542: "hacl-monitor", + 3543: "qftest-lookup", + 3544: "teredo", + 3545: "camac", + 3547: "symantec-sim", + 3548: "interworld", + 3549: "tellumat-nms", + 3550: "ssmpp", + 3551: "apcupsd", + 3552: "taserver", + 3553: "rbr-discovery", + 3554: "questnotify", + 3555: "razor", + 3556: "sky-transport", + 3557: "personalos-001", + 3558: "mcp-port", + 3559: "cctv-port", + 3560: "iniserve-port", + 3561: "bmc-onekey", + 3562: "sdbproxy", + 3563: "watcomdebug", + 3564: "esimport", + 3565: "m2pa", + 3566: "quest-data-hub", + 3567: "dof-eps", + 3568: "dof-tunnel-sec", + 3569: "mbg-ctrl", + 3570: "mccwebsvr-port", + 3571: "megardsvr-port", + 3572: "megaregsvrport", + 3573: "tag-ups-1", + 3574: "dmaf-server", + 3575: "ccm-port", + 3576: "cmc-port", + 3577: "config-port", + 3578: "data-port", + 3579: "ttat3lb", + 3580: "nati-svrloc", + 3581: "kfxaclicensing", + 3582: "press", + 3583: "canex-watch", + 3584: "u-dbap", + 3585: "emprise-lls", + 3586: "emprise-lsc", + 3587: "p2pgroup", + 3588: "sentinel", + 3589: "isomair", + 3590: "wv-csp-sms", + 3591: "gtrack-server", + 3592: "gtrack-ne", + 3593: "bpmd", + 3594: "mediaspace", + 3595: "shareapp", + 3596: "iw-mmogame", + 3597: "a14", + 3598: "a15", + 3599: "quasar-server", + 3600: "trap-daemon", + 3601: "visinet-gui", + 3602: "infiniswitchcl", + 3603: "int-rcv-cntrl", + 3604: "bmc-jmx-port", + 3605: "comcam-io", + 3606: "splitlock", + 3607: "precise-i3", + 3608: "trendchip-dcp", + 3609: "cpdi-pidas-cm", + 3610: "echonet", + 3611: "six-degrees", + 3612: "hp-dataprotect", + 3613: "alaris-disc", + 3614: "sigma-port", + 3615: "start-network", + 3616: "cd3o-protocol", + 3617: "sharp-server", + 3618: "aairnet-1", + 3619: "aairnet-2", + 3620: "ep-pcp", + 3621: "ep-nsp", + 3622: "ff-lr-port", + 3623: "haipe-discover", + 3624: "dist-upgrade", + 3625: "volley", + 3626: "bvcdaemon-port", + 3627: "jamserverport", + 3628: "ept-machine", + 3629: "escvpnet", + 3630: "cs-remote-db", + 3631: "cs-services", + 3632: "distcc", + 3633: "wacp", + 3634: "hlibmgr", + 3635: "sdo", + 3636: "servistaitsm", + 3637: "scservp", + 3638: "ehp-backup", + 3639: "xap-ha", + 3640: "netplay-port1", + 3641: "netplay-port2", + 3642: "juxml-port", + 3643: "audiojuggler", + 3644: "ssowatch", + 3645: "cyc", + 3646: "xss-srv-port", + 3647: "splitlock-gw", + 3648: "fjcp", + 3649: "nmmp", + 3650: "prismiq-plugin", + 3651: "xrpc-registry", + 3652: "vxcrnbuport", + 3653: "tsp", + 3654: "vaprtm", + 3655: "abatemgr", + 3656: "abatjss", + 3657: "immedianet-bcn", + 3658: "ps-ams", + 3659: "apple-sasl", + 3660: "can-nds-ssl", + 3661: "can-ferret-ssl", + 3662: "pserver", + 3663: "dtp", + 3664: "ups-engine", + 3665: "ent-engine", + 3666: "eserver-pap", + 3667: "infoexch", + 3668: "dell-rm-port", + 3669: "casanswmgmt", + 3670: "smile", + 3671: "efcp", + 3672: "lispworks-orb", + 3673: "mediavault-gui", + 3674: "wininstall-ipc", + 3675: "calltrax", + 3676: "va-pacbase", + 3677: "roverlog", + 3678: "ipr-dglt", + 3679: "Escale (Newton Dock)", + 3680: "npds-tracker", + 3681: "bts-x73", + 3682: "cas-mapi", + 3683: "bmc-ea", + 3684: "faxstfx-port", + 3685: "dsx-agent", + 3686: "tnmpv2", + 3687: "simple-push", + 3688: "simple-push-s", + 3689: "daap", + 3690: "svn", + 3691: "magaya-network", + 3692: "intelsync", + 3693: "easl", + 3695: "bmc-data-coll", + 3696: "telnetcpcd", + 3697: "nw-license", + 3698: "sagectlpanel", + 3699: "kpn-icw", + 3700: "lrs-paging", + 3701: "netcelera", + 3702: "ws-discovery", + 3703: "adobeserver-3", + 3704: "adobeserver-4", + 3705: "adobeserver-5", + 3706: "rt-event", + 3707: "rt-event-s", + 3708: "sun-as-iiops", + 3709: "ca-idms", + 3710: "portgate-auth", + 3711: "edb-server2", + 3712: "sentinel-ent", + 3713: "tftps", + 3714: "delos-dms", + 3715: "anoto-rendezv", + 3716: "wv-csp-sms-cir", + 3717: "wv-csp-udp-cir", + 3718: "opus-services", + 3719: "itelserverport", + 3720: "ufastro-instr", + 3721: "xsync", + 3722: "xserveraid", + 3723: "sychrond", + 3724: "blizwow", + 3725: "na-er-tip", + 3726: "array-manager", + 3727: "e-mdu", + 3728: "e-woa", + 3729: "fksp-audit", + 3730: "client-ctrl", + 3731: "smap", + 3732: "m-wnn", + 3733: "multip-msg", + 3734: "synel-data", + 3735: "pwdis", + 3736: "rs-rmi", + 3737: "xpanel", + 3738: "versatalk", + 3739: "launchbird-lm", + 3740: "heartbeat", + 3741: "wysdma", + 3742: "cst-port", + 3743: "ipcs-command", + 3744: "sasg", + 3745: "gw-call-port", + 3746: "linktest", + 3747: "linktest-s", + 3748: "webdata", + 3749: "cimtrak", + 3750: "cbos-ip-port", + 3751: "gprs-cube", + 3752: "vipremoteagent", + 3753: "nattyserver", + 3754: "timestenbroker", + 3755: "sas-remote-hlp", + 3756: "canon-capt", + 3757: "grf-port", + 3758: "apw-registry", + 3759: "exapt-lmgr", + 3760: "adtempusclient", + 3761: "gsakmp", + 3762: "gbs-smp", + 3763: "xo-wave", + 3764: "mni-prot-rout", + 3765: "rtraceroute", + 3766: "sitewatch-s", + 3767: "listmgr-port", + 3768: "rblcheckd", + 3769: "haipe-otnk", + 3770: "cindycollab", + 3771: "paging-port", + 3772: "ctp", + 3773: "ctdhercules", + 3774: "zicom", + 3775: "ispmmgr", + 3776: "dvcprov-port", + 3777: "jibe-eb", + 3778: "c-h-it-port", + 3779: "cognima", + 3780: "nnp", + 3781: "abcvoice-port", + 3782: "iso-tp0s", + 3783: "bim-pem", + 3784: "bfd-control", + 3785: "bfd-echo", + 3786: "upstriggervsw", + 3787: "fintrx", + 3788: "isrp-port", + 3789: "remotedeploy", + 3790: "quickbooksrds", + 3791: "tvnetworkvideo", + 3792: "sitewatch", + 3793: "dcsoftware", + 3794: "jaus", + 3795: "myblast", + 3796: "spw-dialer", + 3797: "idps", + 3798: "minilock", + 3799: "radius-dynauth", + 3800: "pwgpsi", + 3801: "ibm-mgr", + 3802: "vhd", + 3803: "soniqsync", + 3804: "iqnet-port", + 3805: "tcpdataserver", + 3806: "wsmlb", + 3807: "spugna", + 3808: "sun-as-iiops-ca", + 3809: "apocd", + 3810: "wlanauth", + 3811: "amp", + 3812: "neto-wol-server", + 3813: "rap-ip", + 3814: "neto-dcs", + 3815: "lansurveyorxml", + 3816: "sunlps-http", + 3817: "tapeware", + 3818: "crinis-hb", + 3819: "epl-slp", + 3820: "scp", + 3821: "pmcp", + 3822: "acp-discovery", + 3823: "acp-conduit", + 3824: "acp-policy", + 3825: "ffserver", + 3826: "warmux", + 3827: "netmpi", + 3828: "neteh", + 3829: "neteh-ext", + 3830: "cernsysmgmtagt", + 3831: "dvapps", + 3832: "xxnetserver", + 3833: "aipn-auth", + 3834: "spectardata", + 3835: "spectardb", + 3836: "markem-dcp", + 3837: "mkm-discovery", + 3838: "sos", + 3839: "amx-rms", + 3840: "flirtmitmir", + 3841: "shiprush-db-svr", + 3842: "nhci", + 3843: "quest-agent", + 3844: "rnm", + 3845: "v-one-spp", + 3846: "an-pcp", + 3847: "msfw-control", + 3848: "item", + 3849: "spw-dnspreload", + 3850: "qtms-bootstrap", + 3851: "spectraport", + 3852: "sse-app-config", + 3853: "sscan", + 3854: "stryker-com", + 3855: "opentrac", + 3856: "informer", + 3857: "trap-port", + 3858: "trap-port-mom", + 3859: "nav-port", + 3860: "sasp", + 3861: "winshadow-hd", + 3862: "giga-pocket", + 3863: "asap-tcp", + 3864: "asap-tcp-tls", + 3865: "xpl", + 3866: "dzdaemon", + 3867: "dzoglserver", + 3868: "diameter", + 3869: "ovsam-mgmt", + 3870: "ovsam-d-agent", + 3871: "avocent-adsap", + 3872: "oem-agent", + 3873: "fagordnc", + 3874: "sixxsconfig", + 3875: "pnbscada", + 3876: "dl-agent", + 3877: "xmpcr-interface", + 3878: "fotogcad", + 3879: "appss-lm", + 3880: "igrs", + 3881: "idac", + 3882: "msdts1", + 3883: "vrpn", + 3884: "softrack-meter", + 3885: "topflow-ssl", + 3886: "nei-management", + 3887: "ciphire-data", + 3888: "ciphire-serv", + 3889: "dandv-tester", + 3890: "ndsconnect", + 3891: "rtc-pm-port", + 3892: "pcc-image-port", + 3893: "cgi-starapi", + 3894: "syam-agent", + 3895: "syam-smc", + 3896: "sdo-tls", + 3897: "sdo-ssh", + 3898: "senip", + 3899: "itv-control", + 3900: "udt-os", + 3901: "nimsh", + 3902: "nimaux", + 3903: "charsetmgr", + 3904: "omnilink-port", + 3905: "mupdate", + 3906: "topovista-data", + 3907: "imoguia-port", + 3908: "hppronetman", + 3909: "surfcontrolcpa", + 3910: "prnrequest", + 3911: "prnstatus", + 3912: "gbmt-stars", + 3913: "listcrt-port", + 3914: "listcrt-port-2", + 3915: "agcat", + 3916: "wysdmc", + 3917: "aftmux", + 3918: "pktcablemmcops", + 3919: "hyperip", + 3920: "exasoftport1", + 3921: "herodotus-net", + 3922: "sor-update", + 3923: "symb-sb-port", + 3924: "mpl-gprs-port", + 3925: "zmp", + 3926: "winport", + 3927: "natdataservice", + 3928: "netboot-pxe", + 3929: "smauth-port", + 3930: "syam-webserver", + 3931: "msr-plugin-port", + 3932: "dyn-site", + 3933: "plbserve-port", + 3934: "sunfm-port", + 3935: "sdp-portmapper", + 3936: "mailprox", + 3937: "dvbservdsc", + 3938: "dbcontrol-agent", + 3939: "aamp", + 3940: "xecp-node", + 3941: "homeportal-web", + 3942: "srdp", + 3943: "tig", + 3944: "sops", + 3945: "emcads", + 3946: "backupedge", + 3947: "ccp", + 3948: "apdap", + 3949: "drip", + 3950: "namemunge", + 3951: "pwgippfax", + 3952: "i3-sessionmgr", + 3953: "xmlink-connect", + 3954: "adrep", + 3955: "p2pcommunity", + 3956: "gvcp", + 3957: "mqe-broker", + 3958: "mqe-agent", + 3959: "treehopper", + 3960: "bess", + 3961: "proaxess", + 3962: "sbi-agent", + 3963: "thrp", + 3964: "sasggprs", + 3965: "ati-ip-to-ncpe", + 3966: "bflckmgr", + 3967: "ppsms", + 3968: "ianywhere-dbns", + 3969: "landmarks", + 3970: "lanrevagent", + 3971: "lanrevserver", + 3972: "iconp", + 3973: "progistics", + 3974: "citysearch", + 3975: "airshot", + 3976: "opswagent", + 3977: "opswmanager", + 3978: "secure-cfg-svr", + 3979: "smwan", + 3980: "acms", + 3981: "starfish", + 3982: "eis", + 3983: "eisp", + 3984: "mapper-nodemgr", + 3985: "mapper-mapethd", + 3986: "mapper-ws-ethd", + 3987: "centerline", + 3988: "dcs-config", + 3989: "bv-queryengine", + 3990: "bv-is", + 3991: "bv-smcsrv", + 3992: "bv-ds", + 3993: "bv-agent", + 3995: "iss-mgmt-ssl", + 3996: "abcsoftware", + 3997: "agentsease-db", + 3998: "dnx", + 3999: "nvcnet", + 4000: "terabase", + 4001: "newoak", + 4002: "pxc-spvr-ft", + 4003: "pxc-splr-ft", + 4004: "pxc-roid", + 4005: "pxc-pin", + 4006: "pxc-spvr", + 4007: "pxc-splr", + 4008: "netcheque", + 4009: "chimera-hwm", + 4010: "samsung-unidex", + 4011: "altserviceboot", + 4012: "pda-gate", + 4013: "acl-manager", + 4014: "taiclock", + 4015: "talarian-mcast1", + 4016: "talarian-mcast2", + 4017: "talarian-mcast3", + 4018: "talarian-mcast4", + 4019: "talarian-mcast5", + 4020: "trap", + 4021: "nexus-portal", + 4022: "dnox", + 4023: "esnm-zoning", + 4024: "tnp1-port", + 4025: "partimage", + 4026: "as-debug", + 4027: "bxp", + 4028: "dtserver-port", + 4029: "ip-qsig", + 4030: "jdmn-port", + 4031: "suucp", + 4032: "vrts-auth-port", + 4033: "sanavigator", + 4034: "ubxd", + 4035: "wap-push-http", + 4036: "wap-push-https", + 4037: "ravehd", + 4038: "fazzt-ptp", + 4039: "fazzt-admin", + 4040: "yo-main", + 4041: "houston", + 4042: "ldxp", + 4043: "nirp", + 4044: "ltp", + 4045: "npp", + 4046: "acp-proto", + 4047: "ctp-state", + 4049: "wafs", + 4050: "cisco-wafs", + 4051: "cppdp", + 4052: "interact", + 4053: "ccu-comm-1", + 4054: "ccu-comm-2", + 4055: "ccu-comm-3", + 4056: "lms", + 4057: "wfm", + 4058: "kingfisher", + 4059: "dlms-cosem", + 4060: "dsmeter-iatc", + 4061: "ice-location", + 4062: "ice-slocation", + 4063: "ice-router", + 4064: "ice-srouter", + 4065: "avanti-cdp", + 4066: "pmas", + 4067: "idp", + 4068: "ipfltbcst", + 4069: "minger", + 4070: "tripe", + 4071: "aibkup", + 4072: "zieto-sock", + 4073: "iRAPP", + 4074: "cequint-cityid", + 4075: "perimlan", + 4076: "seraph", + 4078: "cssp", + 4079: "santools", + 4080: "lorica-in", + 4081: "lorica-in-sec", + 4082: "lorica-out", + 4083: "lorica-out-sec", + 4085: "ezmessagesrv", + 4087: "applusservice", + 4088: "npsp", + 4089: "opencore", + 4090: "omasgport", + 4091: "ewinstaller", + 4092: "ewdgs", + 4093: "pvxpluscs", + 4094: "sysrqd", + 4095: "xtgui", + 4096: "bre", + 4097: "patrolview", + 4098: "drmsfsd", + 4099: "dpcp", + 4100: "igo-incognito", + 4101: "brlp-0", + 4102: "brlp-1", + 4103: "brlp-2", + 4104: "brlp-3", + 4105: "shofar", + 4106: "synchronite", + 4107: "j-ac", + 4108: "accel", + 4109: "izm", + 4110: "g2tag", + 4111: "xgrid", + 4112: "apple-vpns-rp", + 4113: "aipn-reg", + 4114: "jomamqmonitor", + 4115: "cds", + 4116: "smartcard-tls", + 4117: "hillrserv", + 4118: "netscript", + 4119: "assuria-slm", + 4121: "e-builder", + 4122: "fprams", + 4123: "z-wave", + 4124: "tigv2", + 4125: "opsview-envoy", + 4126: "ddrepl", + 4127: "unikeypro", + 4128: "nufw", + 4129: "nuauth", + 4130: "fronet", + 4131: "stars", + 4132: "nuts-dem", + 4133: "nuts-bootp", + 4134: "nifty-hmi", + 4135: "cl-db-attach", + 4136: "cl-db-request", + 4137: "cl-db-remote", + 4138: "nettest", + 4139: "thrtx", + 4140: "cedros-fds", + 4141: "oirtgsvc", + 4142: "oidocsvc", + 4143: "oidsr", + 4145: "vvr-control", + 4146: "tgcconnect", + 4147: "vrxpservman", + 4148: "hhb-handheld", + 4149: "agslb", + 4150: "PowerAlert-nsa", + 4151: "menandmice-noh", + 4152: "idig-mux", + 4153: "mbl-battd", + 4154: "atlinks", + 4155: "bzr", + 4156: "stat-results", + 4157: "stat-scanner", + 4158: "stat-cc", + 4159: "nss", + 4160: "jini-discovery", + 4161: "omscontact", + 4162: "omstopology", + 4163: "silverpeakpeer", + 4164: "silverpeakcomm", + 4165: "altcp", + 4166: "joost", + 4167: "ddgn", + 4168: "pslicser", + 4169: "iadt", + 4170: "d-cinema-csp", + 4171: "ml-svnet", + 4172: "pcoip", + 4174: "smcluster", + 4175: "bccp", + 4176: "tl-ipcproxy", + 4177: "wello", + 4178: "storman", + 4179: "MaxumSP", + 4180: "httpx", + 4181: "macbak", + 4182: "pcptcpservice", + 4183: "cyborgnet", + 4184: "universe-suite", + 4185: "wcpp", + 4186: "boxbackupstore", + 4187: "csc-proxy", + 4188: "vatata", + 4189: "pcep", + 4190: "sieve", + 4192: "azeti", + 4193: "pvxplusio", + 4199: "eims-admin", + 4300: "corelccam", + 4301: "d-data", + 4302: "d-data-control", + 4303: "srcp", + 4304: "owserver", + 4305: "batman", + 4306: "pinghgl", + 4307: "visicron-vs", + 4308: "compx-lockview", + 4309: "dserver", + 4310: "mirrtex", + 4311: "p6ssmc", + 4312: "pscl-mgt", + 4313: "perrla", + 4314: "choiceview-agt", + 4316: "choiceview-clt", + 4320: "fdt-rcatp", + 4321: "rwhois", + 4322: "trim-event", + 4323: "trim-ice", + 4325: "geognosisman", + 4326: "geognosis", + 4327: "jaxer-web", + 4328: "jaxer-manager", + 4329: "publiqare-sync", + 4330: "dey-sapi", + 4331: "ktickets-rest", + 4333: "ahsp", + 4334: "netconf-ch-ssh", + 4335: "netconf-ch-tls", + 4336: "restconf-ch-tls", + 4340: "gaia", + 4341: "lisp-data", + 4342: "lisp-cons", + 4343: "unicall", + 4344: "vinainstall", + 4345: "m4-network-as", + 4346: "elanlm", + 4347: "lansurveyor", + 4348: "itose", + 4349: "fsportmap", + 4350: "net-device", + 4351: "plcy-net-svcs", + 4352: "pjlink", + 4353: "f5-iquery", + 4354: "qsnet-trans", + 4355: "qsnet-workst", + 4356: "qsnet-assist", + 4357: "qsnet-cond", + 4358: "qsnet-nucl", + 4359: "omabcastltkm", + 4360: "matrix-vnet", + 4368: "wxbrief", + 4369: "epmd", + 4370: "elpro-tunnel", + 4371: "l2c-control", + 4372: "l2c-data", + 4373: "remctl", + 4374: "psi-ptt", + 4375: "tolteces", + 4376: "bip", + 4377: "cp-spxsvr", + 4378: "cp-spxdpy", + 4379: "ctdb", + 4389: "xandros-cms", + 4390: "wiegand", + 4391: "apwi-imserver", + 4392: "apwi-rxserver", + 4393: "apwi-rxspooler", + 4395: "omnivisionesx", + 4396: "fly", + 4400: "ds-srv", + 4401: "ds-srvr", + 4402: "ds-clnt", + 4403: "ds-user", + 4404: "ds-admin", + 4405: "ds-mail", + 4406: "ds-slp", + 4407: "nacagent", + 4408: "slscc", + 4409: "netcabinet-com", + 4410: "itwo-server", + 4411: "found", + 4413: "avi-nms", + 4414: "updog", + 4415: "brcd-vr-req", + 4416: "pjj-player", + 4417: "workflowdir", + 4419: "cbp", + 4420: "nvm-express", + 4421: "scaleft", + 4422: "tsepisp", + 4423: "thingkit", + 4425: "netrockey6", + 4426: "beacon-port-2", + 4427: "drizzle", + 4428: "omviserver", + 4429: "omviagent", + 4430: "rsqlserver", + 4431: "wspipe", + 4432: "l-acoustics", + 4433: "vop", + 4442: "saris", + 4443: "pharos", + 4444: "krb524", + 4445: "upnotifyp", + 4446: "n1-fwp", + 4447: "n1-rmgmt", + 4448: "asc-slmd", + 4449: "privatewire", + 4450: "camp", + 4451: "ctisystemmsg", + 4452: "ctiprogramload", + 4453: "nssalertmgr", + 4454: "nssagentmgr", + 4455: "prchat-user", + 4456: "prchat-server", + 4457: "prRegister", + 4458: "mcp", + 4484: "hpssmgmt", + 4485: "assyst-dr", + 4486: "icms", + 4487: "prex-tcp", + 4488: "awacs-ice", + 4500: "ipsec-nat-t", + 4535: "ehs", + 4536: "ehs-ssl", + 4537: "wssauthsvc", + 4538: "swx-gate", + 4545: "worldscores", + 4546: "sf-lm", + 4547: "lanner-lm", + 4548: "synchromesh", + 4549: "aegate", + 4550: "gds-adppiw-db", + 4551: "ieee-mih", + 4552: "menandmice-mon", + 4553: "icshostsvc", + 4554: "msfrs", + 4555: "rsip", + 4556: "dtn-bundle", + 4559: "hylafax", + 4563: "amahi-anywhere", + 4566: "kwtc", + 4567: "tram", + 4568: "bmc-reporting", + 4569: "iax", + 4570: "deploymentmap", + 4573: "cardifftec-back", + 4590: "rid", + 4591: "l3t-at-an", + 4593: "ipt-anri-anri", + 4594: "ias-session", + 4595: "ias-paging", + 4596: "ias-neighbor", + 4597: "a21-an-1xbs", + 4598: "a16-an-an", + 4599: "a17-an-an", + 4600: "piranha1", + 4601: "piranha2", + 4602: "mtsserver", + 4603: "menandmice-upg", + 4604: "irp", + 4605: "sixchat", + 4658: "playsta2-app", + 4659: "playsta2-lob", + 4660: "smaclmgr", + 4661: "kar2ouche", + 4662: "oms", + 4663: "noteit", + 4664: "ems", + 4665: "contclientms", + 4666: "eportcomm", + 4667: "mmacomm", + 4668: "mmaeds", + 4669: "eportcommdata", + 4670: "light", + 4671: "acter", + 4672: "rfa", + 4673: "cxws", + 4674: "appiq-mgmt", + 4675: "dhct-status", + 4676: "dhct-alerts", + 4677: "bcs", + 4678: "traversal", + 4679: "mgesupervision", + 4680: "mgemanagement", + 4681: "parliant", + 4682: "finisar", + 4683: "spike", + 4684: "rfid-rp1", + 4685: "autopac", + 4686: "msp-os", + 4687: "nst", + 4688: "mobile-p2p", + 4689: "altovacentral", + 4690: "prelude", + 4691: "mtn", + 4692: "conspiracy", + 4700: "netxms-agent", + 4701: "netxms-mgmt", + 4702: "netxms-sync", + 4703: "npqes-test", + 4704: "assuria-ins", + 4725: "truckstar", + 4727: "fcis", + 4728: "capmux", + 4730: "gearman", + 4731: "remcap", + 4733: "resorcs", + 4737: "ipdr-sp", + 4738: "solera-lpn", + 4739: "ipfix", + 4740: "ipfixs", + 4741: "lumimgrd", + 4742: "sicct", + 4743: "openhpid", + 4744: "ifsp", + 4745: "fmp", + 4749: "profilemac", + 4750: "ssad", + 4751: "spocp", + 4752: "snap", + 4753: "simon", + 4756: "RDCenter", + 4774: "converge", + 4784: "bfd-multi-ctl", + 4786: "smart-install", + 4787: "sia-ctrl-plane", + 4788: "xmcp", + 4800: "iims", + 4801: "iwec", + 4802: "ilss", + 4803: "notateit", + 4827: "htcp", + 4837: "varadero-0", + 4838: "varadero-1", + 4839: "varadero-2", + 4840: "opcua-tcp", + 4841: "quosa", + 4842: "gw-asv", + 4843: "opcua-tls", + 4844: "gw-log", + 4845: "wcr-remlib", + 4846: "contamac-icm", + 4847: "wfc", + 4848: "appserv-http", + 4849: "appserv-https", + 4850: "sun-as-nodeagt", + 4851: "derby-repli", + 4867: "unify-debug", + 4868: "phrelay", + 4869: "phrelaydbg", + 4870: "cc-tracking", + 4871: "wired", + 4876: "tritium-can", + 4877: "lmcs", + 4879: "wsdl-event", + 4880: "hislip", + 4883: "wmlserver", + 4884: "hivestor", + 4885: "abbs", + 4894: "lyskom", + 4899: "radmin-port", + 4900: "hfcs", + 4901: "flr-agent", + 4902: "magiccontrol", + 4912: "lutap", + 4913: "lutcp", + 4914: "bones", + 4915: "frcs", + 4940: "eq-office-4940", + 4941: "eq-office-4941", + 4942: "eq-office-4942", + 4949: "munin", + 4950: "sybasesrvmon", + 4951: "pwgwims", + 4952: "sagxtsds", + 4953: "dbsyncarbiter", + 4969: "ccss-qmm", + 4970: "ccss-qsm", + 4984: "webyast", + 4985: "gerhcs", + 4986: "mrip", + 4987: "smar-se-port1", + 4988: "smar-se-port2", + 4989: "parallel", + 4990: "busycal", + 4991: "vrt", + 4999: "hfcs-manager", + 5000: "commplex-main", + 5001: "commplex-link", + 5002: "rfe", + 5003: "fmpro-internal", + 5004: "avt-profile-1", + 5005: "avt-profile-2", + 5006: "wsm-server", + 5007: "wsm-server-ssl", + 5008: "synapsis-edge", + 5009: "winfs", + 5010: "telelpathstart", + 5011: "telelpathattack", + 5012: "nsp", + 5013: "fmpro-v6", + 5015: "fmwp", + 5020: "zenginkyo-1", + 5021: "zenginkyo-2", + 5022: "mice", + 5023: "htuilsrv", + 5024: "scpi-telnet", + 5025: "scpi-raw", + 5026: "strexec-d", + 5027: "strexec-s", + 5028: "qvr", + 5029: "infobright", + 5030: "surfpass", + 5032: "signacert-agent", + 5033: "jtnetd-server", + 5034: "jtnetd-status", + 5042: "asnaacceler8db", + 5043: "swxadmin", + 5044: "lxi-evntsvc", + 5045: "osp", + 5048: "texai", + 5049: "ivocalize", + 5050: "mmcc", + 5051: "ita-agent", + 5052: "ita-manager", + 5053: "rlm", + 5054: "rlm-admin", + 5055: "unot", + 5056: "intecom-ps1", + 5057: "intecom-ps2", + 5059: "sds", + 5060: "sip", + 5061: "sips", + 5062: "na-localise", + 5063: "csrpc", + 5064: "ca-1", + 5065: "ca-2", + 5066: "stanag-5066", + 5067: "authentx", + 5068: "bitforestsrv", + 5069: "i-net-2000-npr", + 5070: "vtsas", + 5071: "powerschool", + 5072: "ayiya", + 5073: "tag-pm", + 5074: "alesquery", + 5075: "pvaccess", + 5080: "onscreen", + 5081: "sdl-ets", + 5082: "qcp", + 5083: "qfp", + 5084: "llrp", + 5085: "encrypted-llrp", + 5086: "aprigo-cs", + 5087: "biotic", + 5093: "sentinel-lm", + 5094: "hart-ip", + 5099: "sentlm-srv2srv", + 5100: "socalia", + 5101: "talarian-tcp", + 5102: "oms-nonsecure", + 5103: "actifio-c2c", + 5106: "actifioudsagent", + 5107: "actifioreplic", + 5111: "taep-as-svc", + 5112: "pm-cmdsvr", + 5114: "ev-services", + 5115: "autobuild", + 5117: "gradecam", + 5120: "barracuda-bbs", + 5133: "nbt-pc", + 5134: "ppactivation", + 5135: "erp-scale", + 5137: "ctsd", + 5145: "rmonitor-secure", + 5146: "social-alarm", + 5150: "atmp", + 5151: "esri-sde", + 5152: "sde-discovery", + 5153: "toruxserver", + 5154: "bzflag", + 5155: "asctrl-agent", + 5156: "rugameonline", + 5157: "mediat", + 5161: "snmpssh", + 5162: "snmpssh-trap", + 5163: "sbackup", + 5164: "vpa", + 5165: "ife-icorp", + 5166: "winpcs", + 5167: "scte104", + 5168: "scte30", + 5172: "pcoip-mgmt", + 5190: "aol", + 5191: "aol-1", + 5192: "aol-2", + 5193: "aol-3", + 5194: "cpscomm", + 5195: "ampl-lic", + 5196: "ampl-tableproxy", + 5197: "tunstall-lwp", + 5200: "targus-getdata", + 5201: "targus-getdata1", + 5202: "targus-getdata2", + 5203: "targus-getdata3", + 5209: "nomad", + 5215: "noteza", + 5221: "3exmp", + 5222: "xmpp-client", + 5223: "hpvirtgrp", + 5224: "hpvirtctrl", + 5225: "hp-server", + 5226: "hp-status", + 5227: "perfd", + 5228: "hpvroom", + 5229: "jaxflow", + 5230: "jaxflow-data", + 5231: "crusecontrol", + 5232: "csedaemon", + 5233: "enfs", + 5234: "eenet", + 5235: "galaxy-network", + 5236: "padl2sim", + 5237: "mnet-discovery", + 5245: "downtools", + 5248: "caacws", + 5249: "caaclang2", + 5250: "soagateway", + 5251: "caevms", + 5252: "movaz-ssc", + 5253: "kpdp", + 5254: "logcabin", + 5264: "3com-njack-1", + 5265: "3com-njack-2", + 5269: "xmpp-server", + 5270: "cartographerxmp", + 5271: "cuelink", + 5272: "pk", + 5280: "xmpp-bosh", + 5281: "undo-lm", + 5282: "transmit-port", + 5298: "presence", + 5299: "nlg-data", + 5300: "hacl-hb", + 5301: "hacl-gs", + 5302: "hacl-cfg", + 5303: "hacl-probe", + 5304: "hacl-local", + 5305: "hacl-test", + 5306: "sun-mc-grp", + 5307: "sco-aip", + 5308: "cfengine", + 5309: "jprinter", + 5310: "outlaws", + 5312: "permabit-cs", + 5313: "rrdp", + 5314: "opalis-rbt-ipc", + 5315: "hacl-poll", + 5316: "hpbladems", + 5317: "hpdevms", + 5318: "pkix-cmc", + 5320: "bsfserver-zn", + 5321: "bsfsvr-zn-ssl", + 5343: "kfserver", + 5344: "xkotodrcp", + 5349: "stuns", + 5352: "dns-llq", + 5353: "mdns", + 5354: "mdnsresponder", + 5355: "llmnr", + 5356: "ms-smlbiz", + 5357: "wsdapi", + 5358: "wsdapi-s", + 5359: "ms-alerter", + 5360: "ms-sideshow", + 5361: "ms-s-sideshow", + 5362: "serverwsd2", + 5363: "net-projection", + 5397: "stresstester", + 5398: "elektron-admin", + 5399: "securitychase", + 5400: "excerpt", + 5401: "excerpts", + 5402: "mftp", + 5403: "hpoms-ci-lstn", + 5404: "hpoms-dps-lstn", + 5405: "netsupport", + 5406: "systemics-sox", + 5407: "foresyte-clear", + 5408: "foresyte-sec", + 5409: "salient-dtasrv", + 5410: "salient-usrmgr", + 5411: "actnet", + 5412: "continuus", + 5413: "wwiotalk", + 5414: "statusd", + 5415: "ns-server", + 5416: "sns-gateway", + 5417: "sns-agent", + 5418: "mcntp", + 5419: "dj-ice", + 5420: "cylink-c", + 5421: "netsupport2", + 5422: "salient-mux", + 5423: "virtualuser", + 5424: "beyond-remote", + 5425: "br-channel", + 5426: "devbasic", + 5427: "sco-peer-tta", + 5428: "telaconsole", + 5429: "base", + 5430: "radec-corp", + 5431: "park-agent", + 5432: "postgresql", + 5433: "pyrrho", + 5434: "sgi-arrayd", + 5435: "sceanics", + 5443: "spss", + 5445: "smbdirect", + 5450: "tiepie", + 5453: "surebox", + 5454: "apc-5454", + 5455: "apc-5455", + 5456: "apc-5456", + 5461: "silkmeter", + 5462: "ttl-publisher", + 5463: "ttlpriceproxy", + 5464: "quailnet", + 5465: "netops-broker", + 5470: "apsolab-col", + 5471: "apsolab-cols", + 5472: "apsolab-tag", + 5473: "apsolab-tags", + 5475: "apsolab-data", + 5500: "fcp-addr-srvr1", + 5501: "fcp-addr-srvr2", + 5502: "fcp-srvr-inst1", + 5503: "fcp-srvr-inst2", + 5504: "fcp-cics-gw1", + 5505: "checkoutdb", + 5506: "amc", + 5507: "psl-management", + 5550: "cbus", + 5553: "sgi-eventmond", + 5554: "sgi-esphttp", + 5555: "personal-agent", + 5556: "freeciv", + 5557: "farenet", + 5565: "hpe-dp-bura", + 5566: "westec-connect", + 5567: "dof-dps-mc-sec", + 5568: "sdt", + 5569: "rdmnet-ctrl", + 5573: "sdmmp", + 5574: "lsi-bobcat", + 5575: "ora-oap", + 5579: "fdtracks", + 5580: "tmosms0", + 5581: "tmosms1", + 5582: "fac-restore", + 5583: "tmo-icon-sync", + 5584: "bis-web", + 5585: "bis-sync", + 5586: "att-mt-sms", + 5597: "ininmessaging", + 5598: "mctfeed", + 5599: "esinstall", + 5600: "esmmanager", + 5601: "esmagent", + 5602: "a1-msc", + 5603: "a1-bs", + 5604: "a3-sdunode", + 5605: "a4-sdunode", + 5618: "efr", + 5627: "ninaf", + 5628: "htrust", + 5629: "symantec-sfdb", + 5630: "precise-comm", + 5631: "pcanywheredata", + 5632: "pcanywherestat", + 5633: "beorl", + 5634: "xprtld", + 5635: "sfmsso", + 5636: "sfm-db-server", + 5637: "cssc", + 5638: "flcrs", + 5639: "ics", + 5646: "vfmobile", + 5670: "filemq", + 5671: "amqps", + 5672: "amqp", + 5673: "jms", + 5674: "hyperscsi-port", + 5675: "v5ua", + 5676: "raadmin", + 5677: "questdb2-lnchr", + 5678: "rrac", + 5679: "dccm", + 5680: "auriga-router", + 5681: "ncxcp", + 5688: "ggz", + 5689: "qmvideo", + 5693: "rbsystem", + 5696: "kmip", + 5700: "supportassist", + 5713: "proshareaudio", + 5714: "prosharevideo", + 5715: "prosharedata", + 5716: "prosharerequest", + 5717: "prosharenotify", + 5718: "dpm", + 5719: "dpm-agent", + 5720: "ms-licensing", + 5721: "dtpt", + 5722: "msdfsr", + 5723: "omhs", + 5724: "omsdk", + 5725: "ms-ilm", + 5726: "ms-ilm-sts", + 5727: "asgenf", + 5728: "io-dist-data", + 5729: "openmail", + 5730: "unieng", + 5741: "ida-discover1", + 5742: "ida-discover2", + 5743: "watchdoc-pod", + 5744: "watchdoc", + 5745: "fcopy-server", + 5746: "fcopys-server", + 5747: "tunatic", + 5748: "tunalyzer", + 5750: "rscd", + 5755: "openmailg", + 5757: "x500ms", + 5766: "openmailns", + 5767: "s-openmail", + 5768: "openmailpxy", + 5769: "spramsca", + 5770: "spramsd", + 5771: "netagent", + 5777: "dali-port", + 5780: "vts-rpc", + 5781: "3par-evts", + 5782: "3par-mgmt", + 5783: "3par-mgmt-ssl", + 5785: "3par-rcopy", + 5793: "xtreamx", + 5813: "icmpd", + 5814: "spt-automation", + 5841: "shiprush-d-ch", + 5842: "reversion", + 5859: "wherehoo", + 5863: "ppsuitemsg", + 5868: "diameters", + 5883: "jute", + 5900: "rfb", + 5910: "cm", + 5911: "cpdlc", + 5912: "fis", + 5913: "ads-c", + 5963: "indy", + 5968: "mppolicy-v5", + 5969: "mppolicy-mgr", + 5984: "couchdb", + 5985: "wsman", + 5986: "wsmans", + 5987: "wbem-rmi", + 5988: "wbem-http", + 5989: "wbem-https", + 5990: "wbem-exp-https", + 5991: "nuxsl", + 5992: "consul-insight", + 5993: "cim-rs", + 5999: "cvsup", + 6064: "ndl-ahp-svc", + 6065: "winpharaoh", + 6066: "ewctsp", + 6068: "gsmp-ancp", + 6069: "trip", + 6070: "messageasap", + 6071: "ssdtp", + 6072: "diagnose-proc", + 6073: "directplay8", + 6074: "max", + 6075: "dpm-acm", + 6076: "msft-dpm-cert", + 6077: "iconstructsrv", + 6084: "reload-config", + 6085: "konspire2b", + 6086: "pdtp", + 6087: "ldss", + 6088: "doglms", + 6099: "raxa-mgmt", + 6100: "synchronet-db", + 6101: "synchronet-rtc", + 6102: "synchronet-upd", + 6103: "rets", + 6104: "dbdb", + 6105: "primaserver", + 6106: "mpsserver", + 6107: "etc-control", + 6108: "sercomm-scadmin", + 6109: "globecast-id", + 6110: "softcm", + 6111: "spc", + 6112: "dtspcd", + 6113: "dayliteserver", + 6114: "wrspice", + 6115: "xic", + 6116: "xtlserv", + 6117: "daylitetouch", + 6121: "spdy", + 6122: "bex-webadmin", + 6123: "backup-express", + 6124: "pnbs", + 6130: "damewaremobgtwy", + 6133: "nbt-wol", + 6140: "pulsonixnls", + 6141: "meta-corp", + 6142: "aspentec-lm", + 6143: "watershed-lm", + 6144: "statsci1-lm", + 6145: "statsci2-lm", + 6146: "lonewolf-lm", + 6147: "montage-lm", + 6148: "ricardo-lm", + 6149: "tal-pod", + 6159: "efb-aci", + 6160: "ecmp", + 6161: "patrol-ism", + 6162: "patrol-coll", + 6163: "pscribe", + 6200: "lm-x", + 6209: "qmtps", + 6222: "radmind", + 6241: "jeol-nsdtp-1", + 6242: "jeol-nsdtp-2", + 6243: "jeol-nsdtp-3", + 6244: "jeol-nsdtp-4", + 6251: "tl1-raw-ssl", + 6252: "tl1-ssh", + 6253: "crip", + 6267: "gld", + 6268: "grid", + 6269: "grid-alt", + 6300: "bmc-grx", + 6301: "bmc-ctd-ldap", + 6306: "ufmp", + 6315: "scup", + 6316: "abb-escp", + 6317: "nav-data-cmd", + 6320: "repsvc", + 6321: "emp-server1", + 6322: "emp-server2", + 6324: "hrd-ncs", + 6325: "dt-mgmtsvc", + 6326: "dt-vra", + 6343: "sflow", + 6344: "streletz", + 6346: "gnutella-svc", + 6347: "gnutella-rtr", + 6350: "adap", + 6355: "pmcs", + 6360: "metaedit-mu", + 6370: "metaedit-se", + 6379: "redis", + 6382: "metatude-mds", + 6389: "clariion-evr01", + 6390: "metaedit-ws", + 6417: "faxcomservice", + 6418: "syserverremote", + 6419: "svdrp", + 6420: "nim-vdrshell", + 6421: "nim-wan", + 6432: "pgbouncer", + 6442: "tarp", + 6443: "sun-sr-https", + 6444: "sge-qmaster", + 6445: "sge-execd", + 6446: "mysql-proxy", + 6455: "skip-cert-recv", + 6456: "skip-cert-send", + 6471: "lvision-lm", + 6480: "sun-sr-http", + 6481: "servicetags", + 6482: "ldoms-mgmt", + 6483: "SunVTS-RMI", + 6484: "sun-sr-jms", + 6485: "sun-sr-iiop", + 6486: "sun-sr-iiops", + 6487: "sun-sr-iiop-aut", + 6488: "sun-sr-jmx", + 6489: "sun-sr-admin", + 6500: "boks", + 6501: "boks-servc", + 6502: "boks-servm", + 6503: "boks-clntd", + 6505: "badm-priv", + 6506: "badm-pub", + 6507: "bdir-priv", + 6508: "bdir-pub", + 6509: "mgcs-mfp-port", + 6510: "mcer-port", + 6513: "netconf-tls", + 6514: "syslog-tls", + 6515: "elipse-rec", + 6543: "lds-distrib", + 6544: "lds-dump", + 6547: "apc-6547", + 6548: "apc-6548", + 6549: "apc-6549", + 6550: "fg-sysupdate", + 6551: "sum", + 6558: "xdsxdm", + 6566: "sane-port", + 6568: "canit-store", + 6579: "affiliate", + 6580: "parsec-master", + 6581: "parsec-peer", + 6582: "parsec-game", + 6583: "joaJewelSuite", + 6600: "mshvlm", + 6601: "mstmg-sstp", + 6602: "wsscomfrmwk", + 6619: "odette-ftps", + 6620: "kftp-data", + 6621: "kftp", + 6622: "mcftp", + 6623: "ktelnet", + 6624: "datascaler-db", + 6625: "datascaler-ctl", + 6626: "wago-service", + 6627: "nexgen", + 6628: "afesc-mc", + 6629: "nexgen-aux", + 6632: "mxodbc-connect", + 6640: "ovsdb", + 6653: "openflow", + 6655: "pcs-sf-ui-man", + 6656: "emgmsg", + 6670: "vocaltec-gold", + 6671: "p4p-portal", + 6672: "vision-server", + 6673: "vision-elmd", + 6678: "vfbp", + 6679: "osaut", + 6687: "clever-ctrace", + 6688: "clever-tcpip", + 6689: "tsa", + 6690: "cleverdetect", + 6697: "ircs-u", + 6701: "kti-icad-srvr", + 6702: "e-design-net", + 6703: "e-design-web", + 6714: "ibprotocol", + 6715: "fibotrader-com", + 6716: "princity-agent", + 6767: "bmc-perf-agent", + 6768: "bmc-perf-mgrd", + 6769: "adi-gxp-srvprt", + 6770: "plysrv-http", + 6771: "plysrv-https", + 6777: "ntz-tracker", + 6778: "ntz-p2p-storage", + 6785: "dgpf-exchg", + 6786: "smc-jmx", + 6787: "smc-admin", + 6788: "smc-http", + 6789: "radg", + 6790: "hnmp", + 6791: "hnm", + 6801: "acnet", + 6817: "pentbox-sim", + 6831: "ambit-lm", + 6841: "netmo-default", + 6842: "netmo-http", + 6850: "iccrushmore", + 6868: "acctopus-cc", + 6888: "muse", + 6900: "rtimeviewer", + 6901: "jetstream", + 6935: "ethoscan", + 6936: "xsmsvc", + 6946: "bioserver", + 6951: "otlp", + 6961: "jmact3", + 6962: "jmevt2", + 6963: "swismgr1", + 6964: "swismgr2", + 6965: "swistrap", + 6966: "swispol", + 6969: "acmsoda", + 6970: "conductor", + 6997: "MobilitySrv", + 6998: "iatp-highpri", + 6999: "iatp-normalpri", + 7000: "afs3-fileserver", + 7001: "afs3-callback", + 7002: "afs3-prserver", + 7003: "afs3-vlserver", + 7004: "afs3-kaserver", + 7005: "afs3-volser", + 7006: "afs3-errors", + 7007: "afs3-bos", + 7008: "afs3-update", + 7009: "afs3-rmtsys", + 7010: "ups-onlinet", + 7011: "talon-disc", + 7012: "talon-engine", + 7013: "microtalon-dis", + 7014: "microtalon-com", + 7015: "talon-webserver", + 7018: "fisa-svc", + 7019: "doceri-ctl", + 7020: "dpserve", + 7021: "dpserveadmin", + 7022: "ctdp", + 7023: "ct2nmcs", + 7024: "vmsvc", + 7025: "vmsvc-2", + 7030: "op-probe", + 7031: "iposplanet", + 7070: "arcp", + 7071: "iwg1", + 7073: "martalk", + 7080: "empowerid", + 7099: "lazy-ptop", + 7100: "font-service", + 7101: "elcn", + 7117: "rothaga", + 7121: "virprot-lm", + 7128: "scenidm", + 7129: "scenccs", + 7161: "cabsm-comm", + 7162: "caistoragemgr", + 7163: "cacsambroker", + 7164: "fsr", + 7165: "doc-server", + 7166: "aruba-server", + 7167: "casrmagent", + 7168: "cnckadserver", + 7169: "ccag-pib", + 7170: "nsrp", + 7171: "drm-production", + 7172: "metalbend", + 7173: "zsecure", + 7174: "clutild", + 7200: "fodms", + 7201: "dlip", + 7215: "PS-Server", + 7216: "PS-Capture-Pro", + 7227: "ramp", + 7228: "citrixupp", + 7229: "citrixuppg", + 7236: "display", + 7237: "pads", + 7244: "frc-hicp", + 7262: "cnap", + 7272: "watchme-7272", + 7273: "oma-rlp", + 7274: "oma-rlp-s", + 7275: "oma-ulp", + 7276: "oma-ilp", + 7277: "oma-ilp-s", + 7278: "oma-dcdocbs", + 7279: "ctxlic", + 7280: "itactionserver1", + 7281: "itactionserver2", + 7282: "mzca-action", + 7283: "genstat", + 7365: "lcm-server", + 7391: "mindfilesys", + 7392: "mrssrendezvous", + 7393: "nfoldman", + 7394: "fse", + 7395: "winqedit", + 7397: "hexarc", + 7400: "rtps-discovery", + 7401: "rtps-dd-ut", + 7402: "rtps-dd-mt", + 7410: "ionixnetmon", + 7411: "daqstream", + 7421: "mtportmon", + 7426: "pmdmgr", + 7427: "oveadmgr", + 7428: "ovladmgr", + 7429: "opi-sock", + 7430: "xmpv7", + 7431: "pmd", + 7437: "faximum", + 7443: "oracleas-https", + 7471: "sttunnel", + 7473: "rise", + 7474: "neo4j", + 7478: "openit", + 7491: "telops-lmd", + 7500: "silhouette", + 7501: "ovbus", + 7508: "adcp", + 7509: "acplt", + 7510: "ovhpas", + 7511: "pafec-lm", + 7542: "saratoga", + 7543: "atul", + 7544: "nta-ds", + 7545: "nta-us", + 7546: "cfs", + 7547: "cwmp", + 7548: "tidp", + 7549: "nls-tl", + 7551: "controlone-con", + 7560: "sncp", + 7563: "cfw", + 7566: "vsi-omega", + 7569: "dell-eql-asm", + 7570: "aries-kfinder", + 7574: "coherence", + 7588: "sun-lm", + 7606: "mipi-debug", + 7624: "indi", + 7626: "simco", + 7627: "soap-http", + 7628: "zen-pawn", + 7629: "xdas", + 7630: "hawk", + 7631: "tesla-sys-msg", + 7633: "pmdfmgt", + 7648: "cuseeme", + 7672: "imqstomp", + 7673: "imqstomps", + 7674: "imqtunnels", + 7675: "imqtunnel", + 7676: "imqbrokerd", + 7677: "sun-user-https", + 7680: "pando-pub", + 7683: "dmt", + 7687: "bolt", + 7689: "collaber", + 7697: "klio", + 7700: "em7-secom", + 7707: "sync-em7", + 7708: "scinet", + 7720: "medimageportal", + 7724: "nsdeepfreezectl", + 7725: "nitrogen", + 7726: "freezexservice", + 7727: "trident-data", + 7728: "osvr", + 7734: "smip", + 7738: "aiagent", + 7741: "scriptview", + 7742: "msss", + 7743: "sstp-1", + 7744: "raqmon-pdu", + 7747: "prgp", + 7775: "inetfs", + 7777: "cbt", + 7778: "interwise", + 7779: "vstat", + 7781: "accu-lmgr", + 7786: "minivend", + 7787: "popup-reminders", + 7789: "office-tools", + 7794: "q3ade", + 7797: "pnet-conn", + 7798: "pnet-enc", + 7799: "altbsdp", + 7800: "asr", + 7801: "ssp-client", + 7810: "rbt-wanopt", + 7845: "apc-7845", + 7846: "apc-7846", + 7847: "csoauth", + 7869: "mobileanalyzer", + 7870: "rbt-smc", + 7871: "mdm", + 7878: "owms", + 7880: "pss", + 7887: "ubroker", + 7900: "mevent", + 7901: "tnos-sp", + 7902: "tnos-dp", + 7903: "tnos-dps", + 7913: "qo-secure", + 7932: "t2-drm", + 7933: "t2-brm", + 7962: "generalsync", + 7967: "supercell", + 7979: "micromuse-ncps", + 7980: "quest-vista", + 7981: "sossd-collect", + 7982: "sossd-agent", + 7997: "pushns", + 7999: "irdmi2", + 8000: "irdmi", + 8001: "vcom-tunnel", + 8002: "teradataordbms", + 8003: "mcreport", + 8005: "mxi", + 8008: "http-alt", + 8019: "qbdb", + 8020: "intu-ec-svcdisc", + 8021: "intu-ec-client", + 8022: "oa-system", + 8025: "ca-audit-da", + 8026: "ca-audit-ds", + 8032: "pro-ed", + 8033: "mindprint", + 8034: "vantronix-mgmt", + 8040: "ampify", + 8042: "fs-agent", + 8043: "fs-server", + 8044: "fs-mgmt", + 8051: "rocrail", + 8052: "senomix01", + 8053: "senomix02", + 8054: "senomix03", + 8055: "senomix04", + 8056: "senomix05", + 8057: "senomix06", + 8058: "senomix07", + 8059: "senomix08", + 8066: "toad-bi-appsrvr", + 8067: "infi-async", + 8074: "gadugadu", + 8080: "http-alt", + 8081: "sunproxyadmin", + 8082: "us-cli", + 8083: "us-srv", + 8086: "d-s-n", + 8087: "simplifymedia", + 8088: "radan-http", + 8091: "jamlink", + 8097: "sac", + 8100: "xprint-server", + 8101: "ldoms-migr", + 8102: "kz-migr", + 8115: "mtl8000-matrix", + 8116: "cp-cluster", + 8117: "purityrpc", + 8118: "privoxy", + 8121: "apollo-data", + 8122: "apollo-admin", + 8128: "paycash-online", + 8129: "paycash-wbp", + 8130: "indigo-vrmi", + 8131: "indigo-vbcp", + 8132: "dbabble", + 8140: "puppet", + 8148: "isdd", + 8153: "quantastor", + 8160: "patrol", + 8161: "patrol-snmp", + 8162: "lpar2rrd", + 8181: "intermapper", + 8182: "vmware-fdm", + 8183: "proremote", + 8184: "itach", + 8190: "gcp-rphy", + 8191: "limnerpressure", + 8192: "spytechphone", + 8194: "blp1", + 8195: "blp2", + 8199: "vvr-data", + 8200: "trivnet1", + 8201: "trivnet2", + 8204: "lm-perfworks", + 8205: "lm-instmgr", + 8206: "lm-dta", + 8207: "lm-sserver", + 8208: "lm-webwatcher", + 8230: "rexecj", + 8243: "synapse-nhttps", + 8276: "pando-sec", + 8280: "synapse-nhttp", + 8282: "libelle", + 8292: "blp3", + 8293: "hiperscan-id", + 8294: "blp4", + 8300: "tmi", + 8301: "amberon", + 8313: "hub-open-net", + 8320: "tnp-discover", + 8321: "tnp", + 8322: "garmin-marine", + 8351: "server-find", + 8376: "cruise-enum", + 8377: "cruise-swroute", + 8378: "cruise-config", + 8379: "cruise-diags", + 8380: "cruise-update", + 8383: "m2mservices", + 8400: "cvd", + 8401: "sabarsd", + 8402: "abarsd", + 8403: "admind", + 8404: "svcloud", + 8405: "svbackup", + 8415: "dlpx-sp", + 8416: "espeech", + 8417: "espeech-rtp", + 8442: "cybro-a-bus", + 8443: "pcsync-https", + 8444: "pcsync-http", + 8445: "copy", + 8450: "npmp", + 8457: "nexentamv", + 8470: "cisco-avp", + 8471: "pim-port", + 8472: "otv", + 8473: "vp2p", + 8474: "noteshare", + 8500: "fmtp", + 8501: "cmtp-mgt", + 8502: "ftnmtp", + 8554: "rtsp-alt", + 8555: "d-fence", + 8567: "dof-tunnel", + 8600: "asterix", + 8610: "canon-mfnp", + 8611: "canon-bjnp1", + 8612: "canon-bjnp2", + 8613: "canon-bjnp3", + 8614: "canon-bjnp4", + 8615: "imink", + 8665: "monetra", + 8666: "monetra-admin", + 8675: "msi-cps-rm", + 8686: "sun-as-jmxrmi", + 8688: "openremote-ctrl", + 8699: "vnyx", + 8711: "nvc", + 8733: "ibus", + 8750: "dey-keyneg", + 8763: "mc-appserver", + 8764: "openqueue", + 8765: "ultraseek-http", + 8766: "amcs", + 8770: "dpap", + 8778: "uec", + 8786: "msgclnt", + 8787: "msgsrvr", + 8793: "acd-pm", + 8800: "sunwebadmin", + 8804: "truecm", + 8873: "dxspider", + 8880: "cddbp-alt", + 8881: "galaxy4d", + 8883: "secure-mqtt", + 8888: "ddi-tcp-1", + 8889: "ddi-tcp-2", + 8890: "ddi-tcp-3", + 8891: "ddi-tcp-4", + 8892: "ddi-tcp-5", + 8893: "ddi-tcp-6", + 8894: "ddi-tcp-7", + 8899: "ospf-lite", + 8900: "jmb-cds1", + 8901: "jmb-cds2", + 8910: "manyone-http", + 8911: "manyone-xml", + 8912: "wcbackup", + 8913: "dragonfly", + 8937: "twds", + 8953: "ub-dns-control", + 8954: "cumulus-admin", + 8980: "nod-provider", + 8989: "sunwebadmins", + 8990: "http-wmap", + 8991: "https-wmap", + 8997: "oracle-ms-ens", + 8998: "canto-roboflow", + 8999: "bctp", + 9000: "cslistener", + 9001: "etlservicemgr", + 9002: "dynamid", + 9005: "golem", + 9008: "ogs-server", + 9009: "pichat", + 9010: "sdr", + 9020: "tambora", + 9021: "panagolin-ident", + 9022: "paragent", + 9023: "swa-1", + 9024: "swa-2", + 9025: "swa-3", + 9026: "swa-4", + 9050: "versiera", + 9051: "fio-cmgmt", + 9060: "CardWeb-IO", + 9080: "glrpc", + 9083: "emc-pp-mgmtsvc", + 9084: "aurora", + 9085: "ibm-rsyscon", + 9086: "net2display", + 9087: "classic", + 9088: "sqlexec", + 9089: "sqlexec-ssl", + 9090: "websm", + 9091: "xmltec-xmlmail", + 9092: "XmlIpcRegSvc", + 9093: "copycat", + 9100: "hp-pdl-datastr", + 9101: "bacula-dir", + 9102: "bacula-fd", + 9103: "bacula-sd", + 9104: "peerwire", + 9105: "xadmin", + 9106: "astergate", + 9107: "astergatefax", + 9119: "mxit", + 9122: "grcmp", + 9123: "grcp", + 9131: "dddp", + 9160: "apani1", + 9161: "apani2", + 9162: "apani3", + 9163: "apani4", + 9164: "apani5", + 9191: "sun-as-jpda", + 9200: "wap-wsp", + 9201: "wap-wsp-wtp", + 9202: "wap-wsp-s", + 9203: "wap-wsp-wtp-s", + 9204: "wap-vcard", + 9205: "wap-vcal", + 9206: "wap-vcard-s", + 9207: "wap-vcal-s", + 9208: "rjcdb-vcards", + 9209: "almobile-system", + 9210: "oma-mlp", + 9211: "oma-mlp-s", + 9212: "serverviewdbms", + 9213: "serverstart", + 9214: "ipdcesgbs", + 9215: "insis", + 9216: "acme", + 9217: "fsc-port", + 9222: "teamcoherence", + 9255: "mon", + 9278: "pegasus", + 9279: "pegasus-ctl", + 9280: "pgps", + 9281: "swtp-port1", + 9282: "swtp-port2", + 9283: "callwaveiam", + 9284: "visd", + 9285: "n2h2server", + 9287: "cumulus", + 9292: "armtechdaemon", + 9293: "storview", + 9294: "armcenterhttp", + 9295: "armcenterhttps", + 9300: "vrace", + 9306: "sphinxql", + 9312: "sphinxapi", + 9318: "secure-ts", + 9321: "guibase", + 9343: "mpidcmgr", + 9344: "mphlpdmc", + 9345: "rancher", + 9346: "ctechlicensing", + 9374: "fjdmimgr", + 9380: "boxp", + 9387: "d2dconfig", + 9388: "d2ddatatrans", + 9389: "adws", + 9390: "otp", + 9396: "fjinvmgr", + 9397: "mpidcagt", + 9400: "sec-t4net-srv", + 9401: "sec-t4net-clt", + 9402: "sec-pc2fax-srv", + 9418: "git", + 9443: "tungsten-https", + 9444: "wso2esb-console", + 9445: "mindarray-ca", + 9450: "sntlkeyssrvr", + 9500: "ismserver", + 9535: "mngsuite", + 9536: "laes-bf", + 9555: "trispen-sra", + 9592: "ldgateway", + 9593: "cba8", + 9594: "msgsys", + 9595: "pds", + 9596: "mercury-disc", + 9597: "pd-admin", + 9598: "vscp", + 9599: "robix", + 9600: "micromuse-ncpw", + 9612: "streamcomm-ds", + 9614: "iadt-tls", + 9616: "erunbook-agent", + 9617: "erunbook-server", + 9618: "condor", + 9628: "odbcpathway", + 9629: "uniport", + 9630: "peoctlr", + 9631: "peocoll", + 9640: "pqsflows", + 9666: "zoomcp", + 9667: "xmms2", + 9668: "tec5-sdctp", + 9694: "client-wakeup", + 9695: "ccnx", + 9700: "board-roar", + 9747: "l5nas-parchan", + 9750: "board-voip", + 9753: "rasadv", + 9762: "tungsten-http", + 9800: "davsrc", + 9801: "sstp-2", + 9802: "davsrcs", + 9875: "sapv1", + 9876: "sd", + 9888: "cyborg-systems", + 9889: "gt-proxy", + 9898: "monkeycom", + 9900: "iua", + 9909: "domaintime", + 9911: "sype-transport", + 9925: "xybrid-cloud", + 9950: "apc-9950", + 9951: "apc-9951", + 9952: "apc-9952", + 9953: "acis", + 9954: "hinp", + 9955: "alljoyn-stm", + 9966: "odnsp", + 9978: "xybrid-rt", + 9987: "dsm-scm-target", + 9988: "nsesrvr", + 9990: "osm-appsrvr", + 9991: "osm-oev", + 9992: "palace-1", + 9993: "palace-2", + 9994: "palace-3", + 9995: "palace-4", + 9996: "palace-5", + 9997: "palace-6", + 9998: "distinct32", + 9999: "distinct", + 10000: "ndmp", + 10001: "scp-config", + 10002: "documentum", + 10003: "documentum-s", + 10004: "emcrmirccd", + 10005: "emcrmird", + 10006: "netapp-sync", + 10007: "mvs-capacity", + 10008: "octopus", + 10009: "swdtp-sv", + 10010: "rxapi", + 10050: "zabbix-agent", + 10051: "zabbix-trapper", + 10055: "qptlmd", + 10080: "amanda", + 10081: "famdc", + 10100: "itap-ddtp", + 10101: "ezmeeting-2", + 10102: "ezproxy-2", + 10103: "ezrelay", + 10104: "swdtp", + 10107: "bctp-server", + 10110: "nmea-0183", + 10113: "netiq-endpoint", + 10114: "netiq-qcheck", + 10115: "netiq-endpt", + 10116: "netiq-voipa", + 10117: "iqrm", + 10125: "cimple", + 10128: "bmc-perf-sd", + 10129: "bmc-gms", + 10160: "qb-db-server", + 10161: "snmptls", + 10162: "snmptls-trap", + 10200: "trisoap", + 10201: "rsms", + 10252: "apollo-relay", + 10260: "axis-wimp-port", + 10261: "tile-ml", + 10288: "blocks", + 10321: "cosir", + 10540: "MOS-lower", + 10541: "MOS-upper", + 10542: "MOS-aux", + 10543: "MOS-soap", + 10544: "MOS-soap-opt", + 10548: "serverdocs", + 10631: "printopia", + 10800: "gap", + 10805: "lpdg", + 10809: "nbd", + 10860: "helix", + 10880: "bveapi", + 10933: "octopustentacle", + 10990: "rmiaux", + 11000: "irisa", + 11001: "metasys", + 11095: "weave", + 11103: "origo-sync", + 11104: "netapp-icmgmt", + 11105: "netapp-icdata", + 11106: "sgi-lk", + 11109: "sgi-dmfmgr", + 11110: "sgi-soap", + 11111: "vce", + 11112: "dicom", + 11161: "suncacao-snmp", + 11162: "suncacao-jmxmp", + 11163: "suncacao-rmi", + 11164: "suncacao-csa", + 11165: "suncacao-websvc", + 11172: "oemcacao-jmxmp", + 11173: "t5-straton", + 11174: "oemcacao-rmi", + 11175: "oemcacao-websvc", + 11201: "smsqp", + 11202: "dcsl-backup", + 11208: "wifree", + 11211: "memcache", + 11319: "imip", + 11320: "imip-channels", + 11321: "arena-server", + 11367: "atm-uhas", + 11371: "hkp", + 11489: "asgcypresstcps", + 11600: "tempest-port", + 11623: "emc-xsw-dconfig", + 11720: "h323callsigalt", + 11723: "emc-xsw-dcache", + 11751: "intrepid-ssl", + 11796: "lanschool", + 11876: "xoraya", + 11967: "sysinfo-sp", + 12000: "entextxid", + 12001: "entextnetwk", + 12002: "entexthigh", + 12003: "entextmed", + 12004: "entextlow", + 12005: "dbisamserver1", + 12006: "dbisamserver2", + 12007: "accuracer", + 12008: "accuracer-dbms", + 12010: "edbsrvr", + 12012: "vipera", + 12013: "vipera-ssl", + 12109: "rets-ssl", + 12121: "nupaper-ss", + 12168: "cawas", + 12172: "hivep", + 12300: "linogridengine", + 12302: "rads", + 12321: "warehouse-sss", + 12322: "warehouse", + 12345: "italk", + 12753: "tsaf", + 12865: "netperf", + 13160: "i-zipqd", + 13216: "bcslogc", + 13217: "rs-pias", + 13218: "emc-vcas-tcp", + 13223: "powwow-client", + 13224: "powwow-server", + 13400: "doip-data", + 13720: "bprd", + 13721: "bpdbm", + 13722: "bpjava-msvc", + 13724: "vnetd", + 13782: "bpcd", + 13783: "vopied", + 13785: "nbdb", + 13786: "nomdb", + 13818: "dsmcc-config", + 13819: "dsmcc-session", + 13820: "dsmcc-passthru", + 13821: "dsmcc-download", + 13822: "dsmcc-ccp", + 13823: "bmdss", + 13894: "ucontrol", + 13929: "dta-systems", + 13930: "medevolve", + 14000: "scotty-ft", + 14001: "sua", + 14033: "sage-best-com1", + 14034: "sage-best-com2", + 14141: "vcs-app", + 14142: "icpp", + 14143: "icpps", + 14145: "gcm-app", + 14149: "vrts-tdd", + 14150: "vcscmd", + 14154: "vad", + 14250: "cps", + 14414: "ca-web-update", + 14500: "xpra", + 14936: "hde-lcesrvr-1", + 14937: "hde-lcesrvr-2", + 15000: "hydap", + 15002: "onep-tls", + 15345: "xpilot", + 15363: "3link", + 15555: "cisco-snat", + 15660: "bex-xr", + 15740: "ptp", + 15999: "programmar", + 16000: "fmsas", + 16001: "fmsascon", + 16002: "gsms", + 16020: "jwpc", + 16021: "jwpc-bin", + 16161: "sun-sea-port", + 16162: "solaris-audit", + 16309: "etb4j", + 16310: "pduncs", + 16311: "pdefmns", + 16360: "netserialext1", + 16361: "netserialext2", + 16367: "netserialext3", + 16368: "netserialext4", + 16384: "connected", + 16385: "rdgs", + 16619: "xoms", + 16665: "axon-tunnel", + 16789: "cadsisvr", + 16900: "newbay-snc-mc", + 16950: "sgcip", + 16991: "intel-rci-mp", + 16992: "amt-soap-http", + 16993: "amt-soap-https", + 16994: "amt-redir-tcp", + 16995: "amt-redir-tls", + 17007: "isode-dua", + 17184: "vestasdlp", + 17185: "soundsvirtual", + 17219: "chipper", + 17220: "avtp", + 17221: "avdecc", + 17223: "isa100-gci", + 17225: "trdp-md", + 17234: "integrius-stp", + 17235: "ssh-mgmt", + 17500: "db-lsp", + 17555: "ailith", + 17729: "ea", + 17754: "zep", + 17755: "zigbee-ip", + 17756: "zigbee-ips", + 17777: "sw-orion", + 18000: "biimenu", + 18104: "radpdf", + 18136: "racf", + 18181: "opsec-cvp", + 18182: "opsec-ufp", + 18183: "opsec-sam", + 18184: "opsec-lea", + 18185: "opsec-omi", + 18186: "ohsc", + 18187: "opsec-ela", + 18241: "checkpoint-rtm", + 18242: "iclid", + 18243: "clusterxl", + 18262: "gv-pf", + 18463: "ac-cluster", + 18634: "rds-ib", + 18635: "rds-ip", + 18668: "vdmmesh", + 18769: "ique", + 18881: "infotos", + 18888: "apc-necmp", + 19000: "igrid", + 19007: "scintilla", + 19020: "j-link", + 19191: "opsec-uaa", + 19194: "ua-secureagent", + 19220: "cora", + 19283: "keysrvr", + 19315: "keyshadow", + 19398: "mtrgtrans", + 19410: "hp-sco", + 19411: "hp-sca", + 19412: "hp-sessmon", + 19539: "fxuptp", + 19540: "sxuptp", + 19541: "jcp", + 19998: "iec-104-sec", + 19999: "dnp-sec", + 20000: "dnp", + 20001: "microsan", + 20002: "commtact-http", + 20003: "commtact-https", + 20005: "openwebnet", + 20013: "ss-idi", + 20014: "opendeploy", + 20034: "nburn-id", + 20046: "tmophl7mts", + 20048: "mountd", + 20049: "nfsrdma", + 20057: "avesterra", + 20167: "tolfab", + 20202: "ipdtp-port", + 20222: "ipulse-ics", + 20480: "emwavemsg", + 20670: "track", + 20999: "athand-mmp", + 21000: "irtrans", + 21010: "notezilla-lan", + 21553: "rdm-tfs", + 21554: "dfserver", + 21590: "vofr-gateway", + 21800: "tvpm", + 21845: "webphone", + 21846: "netspeak-is", + 21847: "netspeak-cs", + 21848: "netspeak-acd", + 21849: "netspeak-cps", + 22000: "snapenetio", + 22001: "optocontrol", + 22002: "optohost002", + 22003: "optohost003", + 22004: "optohost004", + 22005: "optohost004", + 22125: "dcap", + 22128: "gsidcap", + 22222: "easyengine", + 22273: "wnn6", + 22305: "cis", + 22335: "shrewd-control", + 22343: "cis-secure", + 22347: "wibukey", + 22350: "codemeter", + 22351: "codemeter-cmwan", + 22537: "caldsoft-backup", + 22555: "vocaltec-wconf", + 22763: "talikaserver", + 22800: "aws-brf", + 22951: "brf-gw", + 23000: "inovaport1", + 23001: "inovaport2", + 23002: "inovaport3", + 23003: "inovaport4", + 23004: "inovaport5", + 23005: "inovaport6", + 23053: "gntp", + 23294: "5afe-dir", + 23333: "elxmgmt", + 23400: "novar-dbase", + 23401: "novar-alarm", + 23402: "novar-global", + 23456: "aequus", + 23457: "aequus-alt", + 23546: "areaguard-neo", + 24000: "med-ltp", + 24001: "med-fsp-rx", + 24002: "med-fsp-tx", + 24003: "med-supp", + 24004: "med-ovw", + 24005: "med-ci", + 24006: "med-net-svc", + 24242: "filesphere", + 24249: "vista-4gl", + 24321: "ild", + 24386: "intel-rci", + 24465: "tonidods", + 24554: "binkp", + 24577: "bilobit", + 24666: "sdtvwcam", + 24676: "canditv", + 24677: "flashfiler", + 24678: "proactivate", + 24680: "tcc-http", + 24754: "cslg", + 24922: "find", + 25000: "icl-twobase1", + 25001: "icl-twobase2", + 25002: "icl-twobase3", + 25003: "icl-twobase4", + 25004: "icl-twobase5", + 25005: "icl-twobase6", + 25006: "icl-twobase7", + 25007: "icl-twobase8", + 25008: "icl-twobase9", + 25009: "icl-twobase10", + 25576: "sauterdongle", + 25604: "idtp", + 25793: "vocaltec-hos", + 25900: "tasp-net", + 25901: "niobserver", + 25902: "nilinkanalyst", + 25903: "niprobe", + 26000: "quake", + 26133: "scscp", + 26208: "wnn6-ds", + 26257: "cockroach", + 26260: "ezproxy", + 26261: "ezmeeting", + 26262: "k3software-svr", + 26263: "k3software-cli", + 26486: "exoline-tcp", + 26487: "exoconfig", + 26489: "exonet", + 27345: "imagepump", + 27442: "jesmsjc", + 27504: "kopek-httphead", + 27782: "ars-vista", + 27876: "astrolink", + 27999: "tw-auth-key", + 28000: "nxlmd", + 28001: "pqsp", + 28200: "voxelstorm", + 28240: "siemensgsm", + 28589: "bosswave", + 29167: "otmp", + 29999: "bingbang", + 30000: "ndmps", + 30001: "pago-services1", + 30002: "pago-services2", + 30003: "amicon-fpsu-ra", + 30100: "rwp", + 30260: "kingdomsonline", + 30999: "ovobs", + 31016: "ka-sddp", + 31020: "autotrac-acp", + 31400: "pace-licensed", + 31416: "xqosd", + 31457: "tetrinet", + 31620: "lm-mon", + 31685: "dsx-monitor", + 31765: "gamesmith-port", + 31948: "iceedcp-tx", + 31949: "iceedcp-rx", + 32034: "iracinghelper", + 32249: "t1distproc60", + 32400: "plex", + 32483: "apm-link", + 32635: "sec-ntb-clnt", + 32636: "DMExpress", + 32767: "filenet-powsrm", + 32768: "filenet-tms", + 32769: "filenet-rpc", + 32770: "filenet-nch", + 32771: "filenet-rmi", + 32772: "filenet-pa", + 32773: "filenet-cm", + 32774: "filenet-re", + 32775: "filenet-pch", + 32776: "filenet-peior", + 32777: "filenet-obrok", + 32801: "mlsn", + 32811: "retp", + 32896: "idmgratm", + 33060: "mysqlx", + 33123: "aurora-balaena", + 33331: "diamondport", + 33333: "dgi-serv", + 33334: "speedtrace", + 33434: "traceroute", + 33656: "snip-slave", + 34249: "turbonote-2", + 34378: "p-net-local", + 34379: "p-net-remote", + 34567: "dhanalakshmi", + 34962: "profinet-rt", + 34963: "profinet-rtm", + 34964: "profinet-cm", + 34980: "ethercat", + 35000: "heathview", + 35001: "rt-viewer", + 35002: "rt-sound", + 35003: "rt-devicemapper", + 35004: "rt-classmanager", + 35005: "rt-labtracker", + 35006: "rt-helper", + 35100: "axio-disc", + 35354: "kitim", + 35355: "altova-lm", + 35356: "guttersnex", + 35357: "openstack-id", + 36001: "allpeers", + 36524: "febooti-aw", + 36602: "observium-agent", + 36700: "mapx", + 36865: "kastenxpipe", + 37475: "neckar", + 37483: "gdrive-sync", + 37601: "eftp", + 37654: "unisys-eportal", + 38000: "ivs-database", + 38001: "ivs-insertion", + 38002: "cresco-control", + 38201: "galaxy7-data", + 38202: "fairview", + 38203: "agpolicy", + 38800: "sruth", + 38865: "secrmmsafecopya", + 39681: "turbonote-1", + 40000: "safetynetp", + 40404: "sptx", + 40841: "cscp", + 40842: "csccredir", + 40843: "csccfirewall", + 41111: "fs-qos", + 41121: "tentacle", + 41230: "z-wave-s", + 41794: "crestron-cip", + 41795: "crestron-ctp", + 41796: "crestron-cips", + 41797: "crestron-ctps", + 42508: "candp", + 42509: "candrp", + 42510: "caerpc", + 43000: "recvr-rc", + 43188: "reachout", + 43189: "ndm-agent-port", + 43190: "ip-provision", + 43191: "noit-transport", + 43210: "shaperai", + 43439: "eq3-update", + 43440: "ew-mgmt", + 43441: "ciscocsdb", + 44123: "z-wave-tunnel", + 44321: "pmcd", + 44322: "pmcdproxy", + 44323: "pmwebapi", + 44444: "cognex-dataman", + 44553: "rbr-debug", + 44818: "EtherNet-IP-2", + 44900: "m3da", + 45000: "asmp", + 45001: "asmps", + 45002: "rs-status", + 45045: "synctest", + 45054: "invision-ag", + 45514: "cloudcheck", + 45678: "eba", + 45824: "dai-shell", + 45825: "qdb2service", + 45966: "ssr-servermgr", + 46336: "inedo", + 46998: "spremotetablet", + 46999: "mediabox", + 47000: "mbus", + 47001: "winrm", + 47557: "dbbrowse", + 47624: "directplaysrvr", + 47806: "ap", + 47808: "bacnet", + 48000: "nimcontroller", + 48001: "nimspooler", + 48002: "nimhub", + 48003: "nimgtw", + 48004: "nimbusdb", + 48005: "nimbusdbctrl", + 48049: "3gpp-cbsp", + 48050: "weandsf", + 48128: "isnetserv", + 48129: "blp5", + 48556: "com-bardac-dw", + 48619: "iqobject", + 48653: "robotraconteur", + 49000: "matahari", +} +var udpPortNames = map[UDPPort]string{ + 1: "tcpmux", + 2: "compressnet", + 3: "compressnet", + 5: "rje", + 7: "echo", + 9: "discard", + 11: "systat", + 13: "daytime", + 17: "qotd", + 18: "msp", + 19: "chargen", + 20: "ftp-data", + 21: "ftp", + 22: "ssh", + 23: "telnet", + 25: "smtp", + 27: "nsw-fe", + 29: "msg-icp", + 31: "msg-auth", + 33: "dsp", + 37: "time", + 38: "rap", + 39: "rlp", + 41: "graphics", + 42: "name", + 43: "nicname", + 44: "mpm-flags", + 45: "mpm", + 46: "mpm-snd", + 47: "ni-ftp", + 48: "auditd", + 49: "tacacs", + 50: "re-mail-ck", + 52: "xns-time", + 53: "domain", + 54: "xns-ch", + 55: "isi-gl", + 56: "xns-auth", + 58: "xns-mail", + 61: "ni-mail", + 62: "acas", + 63: "whoispp", + 64: "covia", + 65: "tacacs-ds", + 66: "sql-net", + 67: "bootps", + 68: "bootpc", + 69: "tftp", + 70: "gopher", + 71: "netrjs-1", + 72: "netrjs-2", + 73: "netrjs-3", + 74: "netrjs-4", + 76: "deos", + 78: "vettcp", + 79: "finger", + 80: "http", + 82: "xfer", + 83: "mit-ml-dev", + 84: "ctf", + 85: "mit-ml-dev", + 86: "mfcobol", + 88: "kerberos", + 89: "su-mit-tg", + 90: "dnsix", + 91: "mit-dov", + 92: "npp", + 93: "dcp", + 94: "objcall", + 95: "supdup", + 96: "dixie", + 97: "swift-rvf", + 98: "tacnews", + 99: "metagram", + 101: "hostname", + 102: "iso-tsap", + 103: "gppitnp", + 104: "acr-nema", + 105: "cso", + 106: "3com-tsmux", + 107: "rtelnet", + 108: "snagas", + 109: "pop2", + 110: "pop3", + 111: "sunrpc", + 112: "mcidas", + 113: "auth", + 115: "sftp", + 116: "ansanotify", + 117: "uucp-path", + 118: "sqlserv", + 119: "nntp", + 120: "cfdptkt", + 121: "erpc", + 122: "smakynet", + 123: "ntp", + 124: "ansatrader", + 125: "locus-map", + 126: "nxedit", + 127: "locus-con", + 128: "gss-xlicen", + 129: "pwdgen", + 130: "cisco-fna", + 131: "cisco-tna", + 132: "cisco-sys", + 133: "statsrv", + 134: "ingres-net", + 135: "epmap", + 136: "profile", + 137: "netbios-ns", + 138: "netbios-dgm", + 139: "netbios-ssn", + 140: "emfis-data", + 141: "emfis-cntl", + 142: "bl-idm", + 143: "imap", + 144: "uma", + 145: "uaac", + 146: "iso-tp0", + 147: "iso-ip", + 148: "jargon", + 149: "aed-512", + 150: "sql-net", + 151: "hems", + 152: "bftp", + 153: "sgmp", + 154: "netsc-prod", + 155: "netsc-dev", + 156: "sqlsrv", + 157: "knet-cmp", + 158: "pcmail-srv", + 159: "nss-routing", + 160: "sgmp-traps", + 161: "snmp", + 162: "snmptrap", + 163: "cmip-man", + 164: "cmip-agent", + 165: "xns-courier", + 166: "s-net", + 167: "namp", + 168: "rsvd", + 169: "send", + 170: "print-srv", + 171: "multiplex", + 172: "cl-1", + 173: "xyplex-mux", + 174: "mailq", + 175: "vmnet", + 176: "genrad-mux", + 177: "xdmcp", + 178: "nextstep", + 179: "bgp", + 180: "ris", + 181: "unify", + 182: "audit", + 183: "ocbinder", + 184: "ocserver", + 185: "remote-kis", + 186: "kis", + 187: "aci", + 188: "mumps", + 189: "qft", + 190: "gacp", + 191: "prospero", + 192: "osu-nms", + 193: "srmp", + 194: "irc", + 195: "dn6-nlm-aud", + 196: "dn6-smm-red", + 197: "dls", + 198: "dls-mon", + 199: "smux", + 200: "src", + 201: "at-rtmp", + 202: "at-nbp", + 203: "at-3", + 204: "at-echo", + 205: "at-5", + 206: "at-zis", + 207: "at-7", + 208: "at-8", + 209: "qmtp", + 210: "z39-50", + 211: "914c-g", + 212: "anet", + 213: "ipx", + 214: "vmpwscs", + 215: "softpc", + 216: "CAIlic", + 217: "dbase", + 218: "mpp", + 219: "uarps", + 220: "imap3", + 221: "fln-spx", + 222: "rsh-spx", + 223: "cdc", + 224: "masqdialer", + 242: "direct", + 243: "sur-meas", + 244: "inbusiness", + 245: "link", + 246: "dsp3270", + 247: "subntbcst-tftp", + 248: "bhfhs", + 256: "rap", + 257: "set", + 259: "esro-gen", + 260: "openport", + 261: "nsiiops", + 262: "arcisdms", + 263: "hdap", + 264: "bgmp", + 265: "x-bone-ctl", + 266: "sst", + 267: "td-service", + 268: "td-replica", + 269: "manet", + 270: "gist", + 280: "http-mgmt", + 281: "personal-link", + 282: "cableport-ax", + 283: "rescap", + 284: "corerjd", + 286: "fxp", + 287: "k-block", + 308: "novastorbakcup", + 309: "entrusttime", + 310: "bhmds", + 311: "asip-webadmin", + 312: "vslmp", + 313: "magenta-logic", + 314: "opalis-robot", + 315: "dpsi", + 316: "decauth", + 317: "zannet", + 318: "pkix-timestamp", + 319: "ptp-event", + 320: "ptp-general", + 321: "pip", + 322: "rtsps", + 333: "texar", + 344: "pdap", + 345: "pawserv", + 346: "zserv", + 347: "fatserv", + 348: "csi-sgwp", + 349: "mftp", + 350: "matip-type-a", + 351: "matip-type-b", + 352: "dtag-ste-sb", + 353: "ndsauth", + 354: "bh611", + 355: "datex-asn", + 356: "cloanto-net-1", + 357: "bhevent", + 358: "shrinkwrap", + 359: "nsrmp", + 360: "scoi2odialog", + 361: "semantix", + 362: "srssend", + 363: "rsvp-tunnel", + 364: "aurora-cmgr", + 365: "dtk", + 366: "odmr", + 367: "mortgageware", + 368: "qbikgdp", + 369: "rpc2portmap", + 370: "codaauth2", + 371: "clearcase", + 372: "ulistproc", + 373: "legent-1", + 374: "legent-2", + 375: "hassle", + 376: "nip", + 377: "tnETOS", + 378: "dsETOS", + 379: "is99c", + 380: "is99s", + 381: "hp-collector", + 382: "hp-managed-node", + 383: "hp-alarm-mgr", + 384: "arns", + 385: "ibm-app", + 386: "asa", + 387: "aurp", + 388: "unidata-ldm", + 389: "ldap", + 390: "uis", + 391: "synotics-relay", + 392: "synotics-broker", + 393: "meta5", + 394: "embl-ndt", + 395: "netcp", + 396: "netware-ip", + 397: "mptn", + 398: "kryptolan", + 399: "iso-tsap-c2", + 400: "osb-sd", + 401: "ups", + 402: "genie", + 403: "decap", + 404: "nced", + 405: "ncld", + 406: "imsp", + 407: "timbuktu", + 408: "prm-sm", + 409: "prm-nm", + 410: "decladebug", + 411: "rmt", + 412: "synoptics-trap", + 413: "smsp", + 414: "infoseek", + 415: "bnet", + 416: "silverplatter", + 417: "onmux", + 418: "hyper-g", + 419: "ariel1", + 420: "smpte", + 421: "ariel2", + 422: "ariel3", + 423: "opc-job-start", + 424: "opc-job-track", + 425: "icad-el", + 426: "smartsdp", + 427: "svrloc", + 428: "ocs-cmu", + 429: "ocs-amu", + 430: "utmpsd", + 431: "utmpcd", + 432: "iasd", + 433: "nnsp", + 434: "mobileip-agent", + 435: "mobilip-mn", + 436: "dna-cml", + 437: "comscm", + 438: "dsfgw", + 439: "dasp", + 440: "sgcp", + 441: "decvms-sysmgt", + 442: "cvc-hostd", + 443: "https", + 444: "snpp", + 445: "microsoft-ds", + 446: "ddm-rdb", + 447: "ddm-dfm", + 448: "ddm-ssl", + 449: "as-servermap", + 450: "tserver", + 451: "sfs-smp-net", + 452: "sfs-config", + 453: "creativeserver", + 454: "contentserver", + 455: "creativepartnr", + 456: "macon-udp", + 457: "scohelp", + 458: "appleqtc", + 459: "ampr-rcmd", + 460: "skronk", + 461: "datasurfsrv", + 462: "datasurfsrvsec", + 463: "alpes", + 464: "kpasswd", + 465: "igmpv3lite", + 466: "digital-vrc", + 467: "mylex-mapd", + 468: "photuris", + 469: "rcp", + 470: "scx-proxy", + 471: "mondex", + 472: "ljk-login", + 473: "hybrid-pop", + 474: "tn-tl-w2", + 475: "tcpnethaspsrv", + 476: "tn-tl-fd1", + 477: "ss7ns", + 478: "spsc", + 479: "iafserver", + 480: "iafdbase", + 481: "ph", + 482: "bgs-nsi", + 483: "ulpnet", + 484: "integra-sme", + 485: "powerburst", + 486: "avian", + 487: "saft", + 488: "gss-http", + 489: "nest-protocol", + 490: "micom-pfs", + 491: "go-login", + 492: "ticf-1", + 493: "ticf-2", + 494: "pov-ray", + 495: "intecourier", + 496: "pim-rp-disc", + 497: "retrospect", + 498: "siam", + 499: "iso-ill", + 500: "isakmp", + 501: "stmf", + 502: "mbap", + 503: "intrinsa", + 504: "citadel", + 505: "mailbox-lm", + 506: "ohimsrv", + 507: "crs", + 508: "xvttp", + 509: "snare", + 510: "fcp", + 511: "passgo", + 512: "comsat", + 513: "who", + 514: "syslog", + 515: "printer", + 516: "videotex", + 517: "talk", + 518: "ntalk", + 519: "utime", + 520: "router", + 521: "ripng", + 522: "ulp", + 523: "ibm-db2", + 524: "ncp", + 525: "timed", + 526: "tempo", + 527: "stx", + 528: "custix", + 529: "irc-serv", + 530: "courier", + 531: "conference", + 532: "netnews", + 533: "netwall", + 534: "windream", + 535: "iiop", + 536: "opalis-rdv", + 537: "nmsp", + 538: "gdomap", + 539: "apertus-ldp", + 540: "uucp", + 541: "uucp-rlogin", + 542: "commerce", + 543: "klogin", + 544: "kshell", + 545: "appleqtcsrvr", + 546: "dhcpv6-client", + 547: "dhcpv6-server", + 548: "afpovertcp", + 549: "idfp", + 550: "new-rwho", + 551: "cybercash", + 552: "devshr-nts", + 553: "pirp", + 554: "rtsp", + 555: "dsf", + 556: "remotefs", + 557: "openvms-sysipc", + 558: "sdnskmp", + 559: "teedtap", + 560: "rmonitor", + 561: "monitor", + 562: "chshell", + 563: "nntps", + 564: "9pfs", + 565: "whoami", + 566: "streettalk", + 567: "banyan-rpc", + 568: "ms-shuttle", + 569: "ms-rome", + 570: "meter", + 571: "meter", + 572: "sonar", + 573: "banyan-vip", + 574: "ftp-agent", + 575: "vemmi", + 576: "ipcd", + 577: "vnas", + 578: "ipdd", + 579: "decbsrv", + 580: "sntp-heartbeat", + 581: "bdp", + 582: "scc-security", + 583: "philips-vc", + 584: "keyserver", + 586: "password-chg", + 587: "submission", + 588: "cal", + 589: "eyelink", + 590: "tns-cml", + 591: "http-alt", + 592: "eudora-set", + 593: "http-rpc-epmap", + 594: "tpip", + 595: "cab-protocol", + 596: "smsd", + 597: "ptcnameservice", + 598: "sco-websrvrmg3", + 599: "acp", + 600: "ipcserver", + 601: "syslog-conn", + 602: "xmlrpc-beep", + 603: "idxp", + 604: "tunnel", + 605: "soap-beep", + 606: "urm", + 607: "nqs", + 608: "sift-uft", + 609: "npmp-trap", + 610: "npmp-local", + 611: "npmp-gui", + 612: "hmmp-ind", + 613: "hmmp-op", + 614: "sshell", + 615: "sco-inetmgr", + 616: "sco-sysmgr", + 617: "sco-dtmgr", + 618: "dei-icda", + 619: "compaq-evm", + 620: "sco-websrvrmgr", + 621: "escp-ip", + 622: "collaborator", + 623: "asf-rmcp", + 624: "cryptoadmin", + 625: "dec-dlm", + 626: "asia", + 627: "passgo-tivoli", + 628: "qmqp", + 629: "3com-amp3", + 630: "rda", + 631: "ipp", + 632: "bmpp", + 633: "servstat", + 634: "ginad", + 635: "rlzdbase", + 636: "ldaps", + 637: "lanserver", + 638: "mcns-sec", + 639: "msdp", + 640: "entrust-sps", + 641: "repcmd", + 642: "esro-emsdp", + 643: "sanity", + 644: "dwr", + 645: "pssc", + 646: "ldp", + 647: "dhcp-failover", + 648: "rrp", + 649: "cadview-3d", + 650: "obex", + 651: "ieee-mms", + 652: "hello-port", + 653: "repscmd", + 654: "aodv", + 655: "tinc", + 656: "spmp", + 657: "rmc", + 658: "tenfold", + 660: "mac-srvr-admin", + 661: "hap", + 662: "pftp", + 663: "purenoise", + 664: "asf-secure-rmcp", + 665: "sun-dr", + 666: "mdqs", + 667: "disclose", + 668: "mecomm", + 669: "meregister", + 670: "vacdsm-sws", + 671: "vacdsm-app", + 672: "vpps-qua", + 673: "cimplex", + 674: "acap", + 675: "dctp", + 676: "vpps-via", + 677: "vpp", + 678: "ggf-ncp", + 679: "mrm", + 680: "entrust-aaas", + 681: "entrust-aams", + 682: "xfr", + 683: "corba-iiop", + 684: "corba-iiop-ssl", + 685: "mdc-portmapper", + 686: "hcp-wismar", + 687: "asipregistry", + 688: "realm-rusd", + 689: "nmap", + 690: "vatp", + 691: "msexch-routing", + 692: "hyperwave-isp", + 693: "connendp", + 694: "ha-cluster", + 695: "ieee-mms-ssl", + 696: "rushd", + 697: "uuidgen", + 698: "olsr", + 699: "accessnetwork", + 700: "epp", + 701: "lmp", + 702: "iris-beep", + 704: "elcsd", + 705: "agentx", + 706: "silc", + 707: "borland-dsj", + 709: "entrust-kmsh", + 710: "entrust-ash", + 711: "cisco-tdp", + 712: "tbrpf", + 713: "iris-xpc", + 714: "iris-xpcs", + 715: "iris-lwz", + 716: "pana", + 729: "netviewdm1", + 730: "netviewdm2", + 731: "netviewdm3", + 741: "netgw", + 742: "netrcs", + 744: "flexlm", + 747: "fujitsu-dev", + 748: "ris-cm", + 749: "kerberos-adm", + 750: "loadav", + 751: "pump", + 752: "qrh", + 753: "rrh", + 754: "tell", + 758: "nlogin", + 759: "con", + 760: "ns", + 761: "rxe", + 762: "quotad", + 763: "cycleserv", + 764: "omserv", + 765: "webster", + 767: "phonebook", + 769: "vid", + 770: "cadlock", + 771: "rtip", + 772: "cycleserv2", + 773: "notify", + 774: "acmaint-dbd", + 775: "acmaint-transd", + 776: "wpages", + 777: "multiling-http", + 780: "wpgs", + 800: "mdbs-daemon", + 801: "device", + 802: "mbap-s", + 810: "fcp-udp", + 828: "itm-mcell-s", + 829: "pkix-3-ca-ra", + 830: "netconf-ssh", + 831: "netconf-beep", + 832: "netconfsoaphttp", + 833: "netconfsoapbeep", + 847: "dhcp-failover2", + 848: "gdoi", + 853: "domain-s", + 860: "iscsi", + 861: "owamp-control", + 862: "twamp-control", + 873: "rsync", + 886: "iclcnet-locate", + 887: "iclcnet-svinfo", + 888: "accessbuilder", + 900: "omginitialrefs", + 901: "smpnameres", + 902: "ideafarm-door", + 903: "ideafarm-panic", + 910: "kink", + 911: "xact-backup", + 912: "apex-mesh", + 913: "apex-edge", + 989: "ftps-data", + 990: "ftps", + 991: "nas", + 992: "telnets", + 993: "imaps", + 995: "pop3s", + 996: "vsinet", + 997: "maitrd", + 998: "puparp", + 999: "applix", + 1000: "cadlock2", + 1010: "surf", + 1021: "exp1", + 1022: "exp2", + 1025: "blackjack", + 1026: "cap", + 1027: "6a44", + 1029: "solid-mux", + 1033: "netinfo-local", + 1034: "activesync", + 1035: "mxxrlogin", + 1036: "nsstp", + 1037: "ams", + 1038: "mtqp", + 1039: "sbl", + 1040: "netarx", + 1041: "danf-ak2", + 1042: "afrog", + 1043: "boinc-client", + 1044: "dcutility", + 1045: "fpitp", + 1046: "wfremotertm", + 1047: "neod1", + 1048: "neod2", + 1049: "td-postman", + 1050: "cma", + 1051: "optima-vnet", + 1052: "ddt", + 1053: "remote-as", + 1054: "brvread", + 1055: "ansyslmd", + 1056: "vfo", + 1057: "startron", + 1058: "nim", + 1059: "nimreg", + 1060: "polestar", + 1061: "kiosk", + 1062: "veracity", + 1063: "kyoceranetdev", + 1064: "jstel", + 1065: "syscomlan", + 1066: "fpo-fns", + 1067: "instl-boots", + 1068: "instl-bootc", + 1069: "cognex-insight", + 1070: "gmrupdateserv", + 1071: "bsquare-voip", + 1072: "cardax", + 1073: "bridgecontrol", + 1074: "warmspotMgmt", + 1075: "rdrmshc", + 1076: "dab-sti-c", + 1077: "imgames", + 1078: "avocent-proxy", + 1079: "asprovatalk", + 1080: "socks", + 1081: "pvuniwien", + 1082: "amt-esd-prot", + 1083: "ansoft-lm-1", + 1084: "ansoft-lm-2", + 1085: "webobjects", + 1086: "cplscrambler-lg", + 1087: "cplscrambler-in", + 1088: "cplscrambler-al", + 1089: "ff-annunc", + 1090: "ff-fms", + 1091: "ff-sm", + 1092: "obrpd", + 1093: "proofd", + 1094: "rootd", + 1095: "nicelink", + 1096: "cnrprotocol", + 1097: "sunclustermgr", + 1098: "rmiactivation", + 1099: "rmiregistry", + 1100: "mctp", + 1101: "pt2-discover", + 1102: "adobeserver-1", + 1103: "adobeserver-2", + 1104: "xrl", + 1105: "ftranhc", + 1106: "isoipsigport-1", + 1107: "isoipsigport-2", + 1108: "ratio-adp", + 1110: "nfsd-keepalive", + 1111: "lmsocialserver", + 1112: "icp", + 1113: "ltp-deepspace", + 1114: "mini-sql", + 1115: "ardus-trns", + 1116: "ardus-cntl", + 1117: "ardus-mtrns", + 1118: "sacred", + 1119: "bnetgame", + 1120: "bnetfile", + 1121: "rmpp", + 1122: "availant-mgr", + 1123: "murray", + 1124: "hpvmmcontrol", + 1125: "hpvmmagent", + 1126: "hpvmmdata", + 1127: "kwdb-commn", + 1128: "saphostctrl", + 1129: "saphostctrls", + 1130: "casp", + 1131: "caspssl", + 1132: "kvm-via-ip", + 1133: "dfn", + 1134: "aplx", + 1135: "omnivision", + 1136: "hhb-gateway", + 1137: "trim", + 1138: "encrypted-admin", + 1139: "evm", + 1140: "autonoc", + 1141: "mxomss", + 1142: "edtools", + 1143: "imyx", + 1144: "fuscript", + 1145: "x9-icue", + 1146: "audit-transfer", + 1147: "capioverlan", + 1148: "elfiq-repl", + 1149: "bvtsonar", + 1150: "blaze", + 1151: "unizensus", + 1152: "winpoplanmess", + 1153: "c1222-acse", + 1154: "resacommunity", + 1155: "nfa", + 1156: "iascontrol-oms", + 1157: "iascontrol", + 1158: "dbcontrol-oms", + 1159: "oracle-oms", + 1160: "olsv", + 1161: "health-polling", + 1162: "health-trap", + 1163: "sddp", + 1164: "qsm-proxy", + 1165: "qsm-gui", + 1166: "qsm-remote", + 1167: "cisco-ipsla", + 1168: "vchat", + 1169: "tripwire", + 1170: "atc-lm", + 1171: "atc-appserver", + 1172: "dnap", + 1173: "d-cinema-rrp", + 1174: "fnet-remote-ui", + 1175: "dossier", + 1176: "indigo-server", + 1177: "dkmessenger", + 1178: "sgi-storman", + 1179: "b2n", + 1180: "mc-client", + 1181: "3comnetman", + 1182: "accelenet-data", + 1183: "llsurfup-http", + 1184: "llsurfup-https", + 1185: "catchpole", + 1186: "mysql-cluster", + 1187: "alias", + 1188: "hp-webadmin", + 1189: "unet", + 1190: "commlinx-avl", + 1191: "gpfs", + 1192: "caids-sensor", + 1193: "fiveacross", + 1194: "openvpn", + 1195: "rsf-1", + 1196: "netmagic", + 1197: "carrius-rshell", + 1198: "cajo-discovery", + 1199: "dmidi", + 1200: "scol", + 1201: "nucleus-sand", + 1202: "caiccipc", + 1203: "ssslic-mgr", + 1204: "ssslog-mgr", + 1205: "accord-mgc", + 1206: "anthony-data", + 1207: "metasage", + 1208: "seagull-ais", + 1209: "ipcd3", + 1210: "eoss", + 1211: "groove-dpp", + 1212: "lupa", + 1213: "mpc-lifenet", + 1214: "kazaa", + 1215: "scanstat-1", + 1216: "etebac5", + 1217: "hpss-ndapi", + 1218: "aeroflight-ads", + 1219: "aeroflight-ret", + 1220: "qt-serveradmin", + 1221: "sweetware-apps", + 1222: "nerv", + 1223: "tgp", + 1224: "vpnz", + 1225: "slinkysearch", + 1226: "stgxfws", + 1227: "dns2go", + 1228: "florence", + 1229: "zented", + 1230: "periscope", + 1231: "menandmice-lpm", + 1232: "first-defense", + 1233: "univ-appserver", + 1234: "search-agent", + 1235: "mosaicsyssvc1", + 1236: "bvcontrol", + 1237: "tsdos390", + 1238: "hacl-qs", + 1239: "nmsd", + 1240: "instantia", + 1241: "nessus", + 1242: "nmasoverip", + 1243: "serialgateway", + 1244: "isbconference1", + 1245: "isbconference2", + 1246: "payrouter", + 1247: "visionpyramid", + 1248: "hermes", + 1249: "mesavistaco", + 1250: "swldy-sias", + 1251: "servergraph", + 1252: "bspne-pcc", + 1253: "q55-pcc", + 1254: "de-noc", + 1255: "de-cache-query", + 1256: "de-server", + 1257: "shockwave2", + 1258: "opennl", + 1259: "opennl-voice", + 1260: "ibm-ssd", + 1261: "mpshrsv", + 1262: "qnts-orb", + 1263: "dka", + 1264: "prat", + 1265: "dssiapi", + 1266: "dellpwrappks", + 1267: "epc", + 1268: "propel-msgsys", + 1269: "watilapp", + 1270: "opsmgr", + 1271: "excw", + 1272: "cspmlockmgr", + 1273: "emc-gateway", + 1274: "t1distproc", + 1275: "ivcollector", + 1277: "miva-mqs", + 1278: "dellwebadmin-1", + 1279: "dellwebadmin-2", + 1280: "pictrography", + 1281: "healthd", + 1282: "emperion", + 1283: "productinfo", + 1284: "iee-qfx", + 1285: "neoiface", + 1286: "netuitive", + 1287: "routematch", + 1288: "navbuddy", + 1289: "jwalkserver", + 1290: "winjaserver", + 1291: "seagulllms", + 1292: "dsdn", + 1293: "pkt-krb-ipsec", + 1294: "cmmdriver", + 1295: "ehtp", + 1296: "dproxy", + 1297: "sdproxy", + 1298: "lpcp", + 1299: "hp-sci", + 1300: "h323hostcallsc", + 1301: "ci3-software-1", + 1302: "ci3-software-2", + 1303: "sftsrv", + 1304: "boomerang", + 1305: "pe-mike", + 1306: "re-conn-proto", + 1307: "pacmand", + 1308: "odsi", + 1309: "jtag-server", + 1310: "husky", + 1311: "rxmon", + 1312: "sti-envision", + 1313: "bmc-patroldb", + 1314: "pdps", + 1315: "els", + 1316: "exbit-escp", + 1317: "vrts-ipcserver", + 1318: "krb5gatekeeper", + 1319: "amx-icsp", + 1320: "amx-axbnet", + 1321: "pip", + 1322: "novation", + 1323: "brcd", + 1324: "delta-mcp", + 1325: "dx-instrument", + 1326: "wimsic", + 1327: "ultrex", + 1328: "ewall", + 1329: "netdb-export", + 1330: "streetperfect", + 1331: "intersan", + 1332: "pcia-rxp-b", + 1333: "passwrd-policy", + 1334: "writesrv", + 1335: "digital-notary", + 1336: "ischat", + 1337: "menandmice-dns", + 1338: "wmc-log-svc", + 1339: "kjtsiteserver", + 1340: "naap", + 1341: "qubes", + 1342: "esbroker", + 1343: "re101", + 1344: "icap", + 1345: "vpjp", + 1346: "alta-ana-lm", + 1347: "bbn-mmc", + 1348: "bbn-mmx", + 1349: "sbook", + 1350: "editbench", + 1351: "equationbuilder", + 1352: "lotusnote", + 1353: "relief", + 1354: "XSIP-network", + 1355: "intuitive-edge", + 1356: "cuillamartin", + 1357: "pegboard", + 1358: "connlcli", + 1359: "ftsrv", + 1360: "mimer", + 1361: "linx", + 1362: "timeflies", + 1363: "ndm-requester", + 1364: "ndm-server", + 1365: "adapt-sna", + 1366: "netware-csp", + 1367: "dcs", + 1368: "screencast", + 1369: "gv-us", + 1370: "us-gv", + 1371: "fc-cli", + 1372: "fc-ser", + 1373: "chromagrafx", + 1374: "molly", + 1375: "bytex", + 1376: "ibm-pps", + 1377: "cichlid", + 1378: "elan", + 1379: "dbreporter", + 1380: "telesis-licman", + 1381: "apple-licman", + 1382: "udt-os", + 1383: "gwha", + 1384: "os-licman", + 1385: "atex-elmd", + 1386: "checksum", + 1387: "cadsi-lm", + 1388: "objective-dbc", + 1389: "iclpv-dm", + 1390: "iclpv-sc", + 1391: "iclpv-sas", + 1392: "iclpv-pm", + 1393: "iclpv-nls", + 1394: "iclpv-nlc", + 1395: "iclpv-wsm", + 1396: "dvl-activemail", + 1397: "audio-activmail", + 1398: "video-activmail", + 1399: "cadkey-licman", + 1400: "cadkey-tablet", + 1401: "goldleaf-licman", + 1402: "prm-sm-np", + 1403: "prm-nm-np", + 1404: "igi-lm", + 1405: "ibm-res", + 1406: "netlabs-lm", + 1408: "sophia-lm", + 1409: "here-lm", + 1410: "hiq", + 1411: "af", + 1412: "innosys", + 1413: "innosys-acl", + 1414: "ibm-mqseries", + 1415: "dbstar", + 1416: "novell-lu6-2", + 1417: "timbuktu-srv1", + 1418: "timbuktu-srv2", + 1419: "timbuktu-srv3", + 1420: "timbuktu-srv4", + 1421: "gandalf-lm", + 1422: "autodesk-lm", + 1423: "essbase", + 1424: "hybrid", + 1425: "zion-lm", + 1426: "sais", + 1427: "mloadd", + 1428: "informatik-lm", + 1429: "nms", + 1430: "tpdu", + 1431: "rgtp", + 1432: "blueberry-lm", + 1433: "ms-sql-s", + 1434: "ms-sql-m", + 1435: "ibm-cics", + 1436: "saism", + 1437: "tabula", + 1438: "eicon-server", + 1439: "eicon-x25", + 1440: "eicon-slp", + 1441: "cadis-1", + 1442: "cadis-2", + 1443: "ies-lm", + 1444: "marcam-lm", + 1445: "proxima-lm", + 1446: "ora-lm", + 1447: "apri-lm", + 1448: "oc-lm", + 1449: "peport", + 1450: "dwf", + 1451: "infoman", + 1452: "gtegsc-lm", + 1453: "genie-lm", + 1454: "interhdl-elmd", + 1455: "esl-lm", + 1456: "dca", + 1457: "valisys-lm", + 1458: "nrcabq-lm", + 1459: "proshare1", + 1460: "proshare2", + 1461: "ibm-wrless-lan", + 1462: "world-lm", + 1463: "nucleus", + 1464: "msl-lmd", + 1465: "pipes", + 1466: "oceansoft-lm", + 1467: "csdmbase", + 1468: "csdm", + 1469: "aal-lm", + 1470: "uaiact", + 1471: "csdmbase", + 1472: "csdm", + 1473: "openmath", + 1474: "telefinder", + 1475: "taligent-lm", + 1476: "clvm-cfg", + 1477: "ms-sna-server", + 1478: "ms-sna-base", + 1479: "dberegister", + 1480: "pacerforum", + 1481: "airs", + 1482: "miteksys-lm", + 1483: "afs", + 1484: "confluent", + 1485: "lansource", + 1486: "nms-topo-serv", + 1487: "localinfosrvr", + 1488: "docstor", + 1489: "dmdocbroker", + 1490: "insitu-conf", + 1492: "stone-design-1", + 1493: "netmap-lm", + 1494: "ica", + 1495: "cvc", + 1496: "liberty-lm", + 1497: "rfx-lm", + 1498: "sybase-sqlany", + 1499: "fhc", + 1500: "vlsi-lm", + 1501: "saiscm", + 1502: "shivadiscovery", + 1503: "imtc-mcs", + 1504: "evb-elm", + 1505: "funkproxy", + 1506: "utcd", + 1507: "symplex", + 1508: "diagmond", + 1509: "robcad-lm", + 1510: "mvx-lm", + 1511: "3l-l1", + 1512: "wins", + 1513: "fujitsu-dtc", + 1514: "fujitsu-dtcns", + 1515: "ifor-protocol", + 1516: "vpad", + 1517: "vpac", + 1518: "vpvd", + 1519: "vpvc", + 1520: "atm-zip-office", + 1521: "ncube-lm", + 1522: "ricardo-lm", + 1523: "cichild-lm", + 1524: "ingreslock", + 1525: "orasrv", + 1526: "pdap-np", + 1527: "tlisrv", + 1528: "ngr-t", + 1529: "coauthor", + 1530: "rap-service", + 1531: "rap-listen", + 1532: "miroconnect", + 1533: "virtual-places", + 1534: "micromuse-lm", + 1535: "ampr-info", + 1536: "ampr-inter", + 1537: "sdsc-lm", + 1538: "3ds-lm", + 1539: "intellistor-lm", + 1540: "rds", + 1541: "rds2", + 1542: "gridgen-elmd", + 1543: "simba-cs", + 1544: "aspeclmd", + 1545: "vistium-share", + 1546: "abbaccuray", + 1547: "laplink", + 1548: "axon-lm", + 1549: "shivasound", + 1550: "3m-image-lm", + 1551: "hecmtl-db", + 1552: "pciarray", + 1553: "sna-cs", + 1554: "caci-lm", + 1555: "livelan", + 1556: "veritas-pbx", + 1557: "arbortext-lm", + 1558: "xingmpeg", + 1559: "web2host", + 1560: "asci-val", + 1561: "facilityview", + 1562: "pconnectmgr", + 1563: "cadabra-lm", + 1564: "pay-per-view", + 1565: "winddlb", + 1566: "corelvideo", + 1567: "jlicelmd", + 1568: "tsspmap", + 1569: "ets", + 1570: "orbixd", + 1571: "rdb-dbs-disp", + 1572: "chip-lm", + 1573: "itscomm-ns", + 1574: "mvel-lm", + 1575: "oraclenames", + 1576: "moldflow-lm", + 1577: "hypercube-lm", + 1578: "jacobus-lm", + 1579: "ioc-sea-lm", + 1580: "tn-tl-r2", + 1581: "mil-2045-47001", + 1582: "msims", + 1583: "simbaexpress", + 1584: "tn-tl-fd2", + 1585: "intv", + 1586: "ibm-abtact", + 1587: "pra-elmd", + 1588: "triquest-lm", + 1589: "vqp", + 1590: "gemini-lm", + 1591: "ncpm-pm", + 1592: "commonspace", + 1593: "mainsoft-lm", + 1594: "sixtrak", + 1595: "radio", + 1596: "radio-bc", + 1597: "orbplus-iiop", + 1598: "picknfs", + 1599: "simbaservices", + 1600: "issd", + 1601: "aas", + 1602: "inspect", + 1603: "picodbc", + 1604: "icabrowser", + 1605: "slp", + 1606: "slm-api", + 1607: "stt", + 1608: "smart-lm", + 1609: "isysg-lm", + 1610: "taurus-wh", + 1611: "ill", + 1612: "netbill-trans", + 1613: "netbill-keyrep", + 1614: "netbill-cred", + 1615: "netbill-auth", + 1616: "netbill-prod", + 1617: "nimrod-agent", + 1618: "skytelnet", + 1619: "xs-openstorage", + 1620: "faxportwinport", + 1621: "softdataphone", + 1622: "ontime", + 1623: "jaleosnd", + 1624: "udp-sr-port", + 1625: "svs-omagent", + 1626: "shockwave", + 1627: "t128-gateway", + 1628: "lontalk-norm", + 1629: "lontalk-urgnt", + 1630: "oraclenet8cman", + 1631: "visitview", + 1632: "pammratc", + 1633: "pammrpc", + 1634: "loaprobe", + 1635: "edb-server1", + 1636: "isdc", + 1637: "islc", + 1638: "ismc", + 1639: "cert-initiator", + 1640: "cert-responder", + 1641: "invision", + 1642: "isis-am", + 1643: "isis-ambc", + 1644: "saiseh", + 1645: "sightline", + 1646: "sa-msg-port", + 1647: "rsap", + 1648: "concurrent-lm", + 1649: "kermit", + 1650: "nkd", + 1651: "shiva-confsrvr", + 1652: "xnmp", + 1653: "alphatech-lm", + 1654: "stargatealerts", + 1655: "dec-mbadmin", + 1656: "dec-mbadmin-h", + 1657: "fujitsu-mmpdc", + 1658: "sixnetudr", + 1659: "sg-lm", + 1660: "skip-mc-gikreq", + 1661: "netview-aix-1", + 1662: "netview-aix-2", + 1663: "netview-aix-3", + 1664: "netview-aix-4", + 1665: "netview-aix-5", + 1666: "netview-aix-6", + 1667: "netview-aix-7", + 1668: "netview-aix-8", + 1669: "netview-aix-9", + 1670: "netview-aix-10", + 1671: "netview-aix-11", + 1672: "netview-aix-12", + 1673: "proshare-mc-1", + 1674: "proshare-mc-2", + 1675: "pdp", + 1676: "netcomm2", + 1677: "groupwise", + 1678: "prolink", + 1679: "darcorp-lm", + 1680: "microcom-sbp", + 1681: "sd-elmd", + 1682: "lanyon-lantern", + 1683: "ncpm-hip", + 1684: "snaresecure", + 1685: "n2nremote", + 1686: "cvmon", + 1687: "nsjtp-ctrl", + 1688: "nsjtp-data", + 1689: "firefox", + 1690: "ng-umds", + 1691: "empire-empuma", + 1692: "sstsys-lm", + 1693: "rrirtr", + 1694: "rrimwm", + 1695: "rrilwm", + 1696: "rrifmm", + 1697: "rrisat", + 1698: "rsvp-encap-1", + 1699: "rsvp-encap-2", + 1700: "mps-raft", + 1701: "l2f", + 1702: "deskshare", + 1703: "hb-engine", + 1704: "bcs-broker", + 1705: "slingshot", + 1706: "jetform", + 1707: "vdmplay", + 1708: "gat-lmd", + 1709: "centra", + 1710: "impera", + 1711: "pptconference", + 1712: "registrar", + 1713: "conferencetalk", + 1714: "sesi-lm", + 1715: "houdini-lm", + 1716: "xmsg", + 1717: "fj-hdnet", + 1718: "h323gatedisc", + 1719: "h323gatestat", + 1720: "h323hostcall", + 1721: "caicci", + 1722: "hks-lm", + 1723: "pptp", + 1724: "csbphonemaster", + 1725: "iden-ralp", + 1726: "iberiagames", + 1727: "winddx", + 1728: "telindus", + 1729: "citynl", + 1730: "roketz", + 1731: "msiccp", + 1732: "proxim", + 1733: "siipat", + 1734: "cambertx-lm", + 1735: "privatechat", + 1736: "street-stream", + 1737: "ultimad", + 1738: "gamegen1", + 1739: "webaccess", + 1740: "encore", + 1741: "cisco-net-mgmt", + 1742: "3Com-nsd", + 1743: "cinegrfx-lm", + 1744: "ncpm-ft", + 1745: "remote-winsock", + 1746: "ftrapid-1", + 1747: "ftrapid-2", + 1748: "oracle-em1", + 1749: "aspen-services", + 1750: "sslp", + 1751: "swiftnet", + 1752: "lofr-lm", + 1754: "oracle-em2", + 1755: "ms-streaming", + 1756: "capfast-lmd", + 1757: "cnhrp", + 1758: "tftp-mcast", + 1759: "spss-lm", + 1760: "www-ldap-gw", + 1761: "cft-0", + 1762: "cft-1", + 1763: "cft-2", + 1764: "cft-3", + 1765: "cft-4", + 1766: "cft-5", + 1767: "cft-6", + 1768: "cft-7", + 1769: "bmc-net-adm", + 1770: "bmc-net-svc", + 1771: "vaultbase", + 1772: "essweb-gw", + 1773: "kmscontrol", + 1774: "global-dtserv", + 1776: "femis", + 1777: "powerguardian", + 1778: "prodigy-intrnet", + 1779: "pharmasoft", + 1780: "dpkeyserv", + 1781: "answersoft-lm", + 1782: "hp-hcip", + 1784: "finle-lm", + 1785: "windlm", + 1786: "funk-logger", + 1787: "funk-license", + 1788: "psmond", + 1789: "hello", + 1790: "nmsp", + 1791: "ea1", + 1792: "ibm-dt-2", + 1793: "rsc-robot", + 1794: "cera-bcm", + 1795: "dpi-proxy", + 1796: "vocaltec-admin", + 1797: "uma", + 1798: "etp", + 1799: "netrisk", + 1800: "ansys-lm", + 1801: "msmq", + 1802: "concomp1", + 1803: "hp-hcip-gwy", + 1804: "enl", + 1805: "enl-name", + 1806: "musiconline", + 1807: "fhsp", + 1808: "oracle-vp2", + 1809: "oracle-vp1", + 1810: "jerand-lm", + 1811: "scientia-sdb", + 1812: "radius", + 1813: "radius-acct", + 1814: "tdp-suite", + 1815: "mmpft", + 1816: "harp", + 1817: "rkb-oscs", + 1818: "etftp", + 1819: "plato-lm", + 1820: "mcagent", + 1821: "donnyworld", + 1822: "es-elmd", + 1823: "unisys-lm", + 1824: "metrics-pas", + 1825: "direcpc-video", + 1826: "ardt", + 1827: "asi", + 1828: "itm-mcell-u", + 1829: "optika-emedia", + 1830: "net8-cman", + 1831: "myrtle", + 1832: "tht-treasure", + 1833: "udpradio", + 1834: "ardusuni", + 1835: "ardusmul", + 1836: "ste-smsc", + 1837: "csoft1", + 1838: "talnet", + 1839: "netopia-vo1", + 1840: "netopia-vo2", + 1841: "netopia-vo3", + 1842: "netopia-vo4", + 1843: "netopia-vo5", + 1844: "direcpc-dll", + 1845: "altalink", + 1846: "tunstall-pnc", + 1847: "slp-notify", + 1848: "fjdocdist", + 1849: "alpha-sms", + 1850: "gsi", + 1851: "ctcd", + 1852: "virtual-time", + 1853: "vids-avtp", + 1854: "buddy-draw", + 1855: "fiorano-rtrsvc", + 1856: "fiorano-msgsvc", + 1857: "datacaptor", + 1858: "privateark", + 1859: "gammafetchsvr", + 1860: "sunscalar-svc", + 1861: "lecroy-vicp", + 1862: "mysql-cm-agent", + 1863: "msnp", + 1864: "paradym-31port", + 1865: "entp", + 1866: "swrmi", + 1867: "udrive", + 1868: "viziblebrowser", + 1869: "transact", + 1870: "sunscalar-dns", + 1871: "canocentral0", + 1872: "canocentral1", + 1873: "fjmpjps", + 1874: "fjswapsnp", + 1875: "westell-stats", + 1876: "ewcappsrv", + 1877: "hp-webqosdb", + 1878: "drmsmc", + 1879: "nettgain-nms", + 1880: "vsat-control", + 1881: "ibm-mqseries2", + 1882: "ecsqdmn", + 1883: "mqtt", + 1884: "idmaps", + 1885: "vrtstrapserver", + 1886: "leoip", + 1887: "filex-lport", + 1888: "ncconfig", + 1889: "unify-adapter", + 1890: "wilkenlistener", + 1891: "childkey-notif", + 1892: "childkey-ctrl", + 1893: "elad", + 1894: "o2server-port", + 1896: "b-novative-ls", + 1897: "metaagent", + 1898: "cymtec-port", + 1899: "mc2studios", + 1900: "ssdp", + 1901: "fjicl-tep-a", + 1902: "fjicl-tep-b", + 1903: "linkname", + 1904: "fjicl-tep-c", + 1905: "sugp", + 1906: "tpmd", + 1907: "intrastar", + 1908: "dawn", + 1909: "global-wlink", + 1910: "ultrabac", + 1911: "mtp", + 1912: "rhp-iibp", + 1913: "armadp", + 1914: "elm-momentum", + 1915: "facelink", + 1916: "persona", + 1917: "noagent", + 1918: "can-nds", + 1919: "can-dch", + 1920: "can-ferret", + 1921: "noadmin", + 1922: "tapestry", + 1923: "spice", + 1924: "xiip", + 1925: "discovery-port", + 1926: "egs", + 1927: "videte-cipc", + 1928: "emsd-port", + 1929: "bandwiz-system", + 1930: "driveappserver", + 1931: "amdsched", + 1932: "ctt-broker", + 1933: "xmapi", + 1934: "xaapi", + 1935: "macromedia-fcs", + 1936: "jetcmeserver", + 1937: "jwserver", + 1938: "jwclient", + 1939: "jvserver", + 1940: "jvclient", + 1941: "dic-aida", + 1942: "res", + 1943: "beeyond-media", + 1944: "close-combat", + 1945: "dialogic-elmd", + 1946: "tekpls", + 1947: "sentinelsrm", + 1948: "eye2eye", + 1949: "ismaeasdaqlive", + 1950: "ismaeasdaqtest", + 1951: "bcs-lmserver", + 1952: "mpnjsc", + 1953: "rapidbase", + 1954: "abr-api", + 1955: "abr-secure", + 1956: "vrtl-vmf-ds", + 1957: "unix-status", + 1958: "dxadmind", + 1959: "simp-all", + 1960: "nasmanager", + 1961: "bts-appserver", + 1962: "biap-mp", + 1963: "webmachine", + 1964: "solid-e-engine", + 1965: "tivoli-npm", + 1966: "slush", + 1967: "sns-quote", + 1968: "lipsinc", + 1969: "lipsinc1", + 1970: "netop-rc", + 1971: "netop-school", + 1972: "intersys-cache", + 1973: "dlsrap", + 1974: "drp", + 1975: "tcoflashagent", + 1976: "tcoregagent", + 1977: "tcoaddressbook", + 1978: "unisql", + 1979: "unisql-java", + 1980: "pearldoc-xact", + 1981: "p2pq", + 1982: "estamp", + 1983: "lhtp", + 1984: "bb", + 1985: "hsrp", + 1986: "licensedaemon", + 1987: "tr-rsrb-p1", + 1988: "tr-rsrb-p2", + 1989: "tr-rsrb-p3", + 1990: "stun-p1", + 1991: "stun-p2", + 1992: "stun-p3", + 1993: "snmp-tcp-port", + 1994: "stun-port", + 1995: "perf-port", + 1996: "tr-rsrb-port", + 1997: "gdp-port", + 1998: "x25-svc-port", + 1999: "tcp-id-port", + 2000: "cisco-sccp", + 2001: "wizard", + 2002: "globe", + 2003: "brutus", + 2004: "emce", + 2005: "oracle", + 2006: "raid-cd", + 2007: "raid-am", + 2008: "terminaldb", + 2009: "whosockami", + 2010: "pipe-server", + 2011: "servserv", + 2012: "raid-ac", + 2013: "raid-cd", + 2014: "raid-sf", + 2015: "raid-cs", + 2016: "bootserver", + 2017: "bootclient", + 2018: "rellpack", + 2019: "about", + 2020: "xinupageserver", + 2021: "xinuexpansion1", + 2022: "xinuexpansion2", + 2023: "xinuexpansion3", + 2024: "xinuexpansion4", + 2025: "xribs", + 2026: "scrabble", + 2027: "shadowserver", + 2028: "submitserver", + 2029: "hsrpv6", + 2030: "device2", + 2031: "mobrien-chat", + 2032: "blackboard", + 2033: "glogger", + 2034: "scoremgr", + 2035: "imsldoc", + 2036: "e-dpnet", + 2037: "applus", + 2038: "objectmanager", + 2039: "prizma", + 2040: "lam", + 2041: "interbase", + 2042: "isis", + 2043: "isis-bcast", + 2044: "rimsl", + 2045: "cdfunc", + 2046: "sdfunc", + 2047: "dls", + 2048: "dls-monitor", + 2049: "shilp", + 2050: "av-emb-config", + 2051: "epnsdp", + 2052: "clearvisn", + 2053: "lot105-ds-upd", + 2054: "weblogin", + 2055: "iop", + 2056: "omnisky", + 2057: "rich-cp", + 2058: "newwavesearch", + 2059: "bmc-messaging", + 2060: "teleniumdaemon", + 2061: "netmount", + 2062: "icg-swp", + 2063: "icg-bridge", + 2064: "icg-iprelay", + 2065: "dlsrpn", + 2066: "aura", + 2067: "dlswpn", + 2068: "avauthsrvprtcl", + 2069: "event-port", + 2070: "ah-esp-encap", + 2071: "acp-port", + 2072: "msync", + 2073: "gxs-data-port", + 2074: "vrtl-vmf-sa", + 2075: "newlixengine", + 2076: "newlixconfig", + 2077: "tsrmagt", + 2078: "tpcsrvr", + 2079: "idware-router", + 2080: "autodesk-nlm", + 2081: "kme-trap-port", + 2082: "infowave", + 2083: "radsec", + 2084: "sunclustergeo", + 2085: "ada-cip", + 2086: "gnunet", + 2087: "eli", + 2088: "ip-blf", + 2089: "sep", + 2090: "lrp", + 2091: "prp", + 2092: "descent3", + 2093: "nbx-cc", + 2094: "nbx-au", + 2095: "nbx-ser", + 2096: "nbx-dir", + 2097: "jetformpreview", + 2098: "dialog-port", + 2099: "h2250-annex-g", + 2100: "amiganetfs", + 2101: "rtcm-sc104", + 2102: "zephyr-srv", + 2103: "zephyr-clt", + 2104: "zephyr-hm", + 2105: "minipay", + 2106: "mzap", + 2107: "bintec-admin", + 2108: "comcam", + 2109: "ergolight", + 2110: "umsp", + 2111: "dsatp", + 2112: "idonix-metanet", + 2113: "hsl-storm", + 2114: "newheights", + 2115: "kdm", + 2116: "ccowcmr", + 2117: "mentaclient", + 2118: "mentaserver", + 2119: "gsigatekeeper", + 2120: "qencp", + 2121: "scientia-ssdb", + 2122: "caupc-remote", + 2123: "gtp-control", + 2124: "elatelink", + 2125: "lockstep", + 2126: "pktcable-cops", + 2127: "index-pc-wb", + 2128: "net-steward", + 2129: "cs-live", + 2130: "xds", + 2131: "avantageb2b", + 2132: "solera-epmap", + 2133: "zymed-zpp", + 2134: "avenue", + 2135: "gris", + 2136: "appworxsrv", + 2137: "connect", + 2138: "unbind-cluster", + 2139: "ias-auth", + 2140: "ias-reg", + 2141: "ias-admind", + 2142: "tdmoip", + 2143: "lv-jc", + 2144: "lv-ffx", + 2145: "lv-pici", + 2146: "lv-not", + 2147: "lv-auth", + 2148: "veritas-ucl", + 2149: "acptsys", + 2150: "dynamic3d", + 2151: "docent", + 2152: "gtp-user", + 2153: "ctlptc", + 2154: "stdptc", + 2155: "brdptc", + 2156: "trp", + 2157: "xnds", + 2158: "touchnetplus", + 2159: "gdbremote", + 2160: "apc-2160", + 2161: "apc-2161", + 2162: "navisphere", + 2163: "navisphere-sec", + 2164: "ddns-v3", + 2165: "x-bone-api", + 2166: "iwserver", + 2167: "raw-serial", + 2168: "easy-soft-mux", + 2169: "brain", + 2170: "eyetv", + 2171: "msfw-storage", + 2172: "msfw-s-storage", + 2173: "msfw-replica", + 2174: "msfw-array", + 2175: "airsync", + 2176: "rapi", + 2177: "qwave", + 2178: "bitspeer", + 2179: "vmrdp", + 2180: "mc-gt-srv", + 2181: "eforward", + 2182: "cgn-stat", + 2183: "cgn-config", + 2184: "nvd", + 2185: "onbase-dds", + 2186: "gtaua", + 2187: "ssmd", + 2190: "tivoconnect", + 2191: "tvbus", + 2192: "asdis", + 2193: "drwcs", + 2197: "mnp-exchange", + 2198: "onehome-remote", + 2199: "onehome-help", + 2200: "ici", + 2201: "ats", + 2202: "imtc-map", + 2203: "b2-runtime", + 2204: "b2-license", + 2205: "jps", + 2206: "hpocbus", + 2207: "hpssd", + 2208: "hpiod", + 2209: "rimf-ps", + 2210: "noaaport", + 2211: "emwin", + 2212: "leecoposserver", + 2213: "kali", + 2214: "rpi", + 2215: "ipcore", + 2216: "vtu-comms", + 2217: "gotodevice", + 2218: "bounzza", + 2219: "netiq-ncap", + 2220: "netiq", + 2221: "ethernet-ip-s", + 2222: "EtherNet-IP-1", + 2223: "rockwell-csp2", + 2224: "efi-mg", + 2226: "di-drm", + 2227: "di-msg", + 2228: "ehome-ms", + 2229: "datalens", + 2230: "queueadm", + 2231: "wimaxasncp", + 2232: "ivs-video", + 2233: "infocrypt", + 2234: "directplay", + 2235: "sercomm-wlink", + 2236: "nani", + 2237: "optech-port1-lm", + 2238: "aviva-sna", + 2239: "imagequery", + 2240: "recipe", + 2241: "ivsd", + 2242: "foliocorp", + 2243: "magicom", + 2244: "nmsserver", + 2245: "hao", + 2246: "pc-mta-addrmap", + 2247: "antidotemgrsvr", + 2248: "ums", + 2249: "rfmp", + 2250: "remote-collab", + 2251: "dif-port", + 2252: "njenet-ssl", + 2253: "dtv-chan-req", + 2254: "seispoc", + 2255: "vrtp", + 2256: "pcc-mfp", + 2257: "simple-tx-rx", + 2258: "rcts", + 2260: "apc-2260", + 2261: "comotionmaster", + 2262: "comotionback", + 2263: "ecwcfg", + 2264: "apx500api-1", + 2265: "apx500api-2", + 2266: "mfserver", + 2267: "ontobroker", + 2268: "amt", + 2269: "mikey", + 2270: "starschool", + 2271: "mmcals", + 2272: "mmcal", + 2273: "mysql-im", + 2274: "pcttunnell", + 2275: "ibridge-data", + 2276: "ibridge-mgmt", + 2277: "bluectrlproxy", + 2278: "s3db", + 2279: "xmquery", + 2280: "lnvpoller", + 2281: "lnvconsole", + 2282: "lnvalarm", + 2283: "lnvstatus", + 2284: "lnvmaps", + 2285: "lnvmailmon", + 2286: "nas-metering", + 2287: "dna", + 2288: "netml", + 2289: "dict-lookup", + 2290: "sonus-logging", + 2291: "eapsp", + 2292: "mib-streaming", + 2293: "npdbgmngr", + 2294: "konshus-lm", + 2295: "advant-lm", + 2296: "theta-lm", + 2297: "d2k-datamover1", + 2298: "d2k-datamover2", + 2299: "pc-telecommute", + 2300: "cvmmon", + 2301: "cpq-wbem", + 2302: "binderysupport", + 2303: "proxy-gateway", + 2304: "attachmate-uts", + 2305: "mt-scaleserver", + 2306: "tappi-boxnet", + 2307: "pehelp", + 2308: "sdhelp", + 2309: "sdserver", + 2310: "sdclient", + 2311: "messageservice", + 2312: "wanscaler", + 2313: "iapp", + 2314: "cr-websystems", + 2315: "precise-sft", + 2316: "sent-lm", + 2317: "attachmate-g32", + 2318: "cadencecontrol", + 2319: "infolibria", + 2320: "siebel-ns", + 2321: "rdlap", + 2322: "ofsd", + 2323: "3d-nfsd", + 2324: "cosmocall", + 2325: "ansysli", + 2326: "idcp", + 2327: "xingcsm", + 2328: "netrix-sftm", + 2329: "nvd", + 2330: "tscchat", + 2331: "agentview", + 2332: "rcc-host", + 2333: "snapp", + 2334: "ace-client", + 2335: "ace-proxy", + 2336: "appleugcontrol", + 2337: "ideesrv", + 2338: "norton-lambert", + 2339: "3com-webview", + 2340: "wrs-registry", + 2341: "xiostatus", + 2342: "manage-exec", + 2343: "nati-logos", + 2344: "fcmsys", + 2345: "dbm", + 2346: "redstorm-join", + 2347: "redstorm-find", + 2348: "redstorm-info", + 2349: "redstorm-diag", + 2350: "psbserver", + 2351: "psrserver", + 2352: "pslserver", + 2353: "pspserver", + 2354: "psprserver", + 2355: "psdbserver", + 2356: "gxtelmd", + 2357: "unihub-server", + 2358: "futrix", + 2359: "flukeserver", + 2360: "nexstorindltd", + 2361: "tl1", + 2362: "digiman", + 2363: "mediacntrlnfsd", + 2364: "oi-2000", + 2365: "dbref", + 2366: "qip-login", + 2367: "service-ctrl", + 2368: "opentable", + 2370: "l3-hbmon", + 2372: "lanmessenger", + 2381: "compaq-https", + 2382: "ms-olap3", + 2383: "ms-olap4", + 2384: "sd-capacity", + 2385: "sd-data", + 2386: "virtualtape", + 2387: "vsamredirector", + 2388: "mynahautostart", + 2389: "ovsessionmgr", + 2390: "rsmtp", + 2391: "3com-net-mgmt", + 2392: "tacticalauth", + 2393: "ms-olap1", + 2394: "ms-olap2", + 2395: "lan900-remote", + 2396: "wusage", + 2397: "ncl", + 2398: "orbiter", + 2399: "fmpro-fdal", + 2400: "opequus-server", + 2401: "cvspserver", + 2402: "taskmaster2000", + 2403: "taskmaster2000", + 2404: "iec-104", + 2405: "trc-netpoll", + 2406: "jediserver", + 2407: "orion", + 2409: "sns-protocol", + 2410: "vrts-registry", + 2411: "netwave-ap-mgmt", + 2412: "cdn", + 2413: "orion-rmi-reg", + 2414: "beeyond", + 2415: "codima-rtp", + 2416: "rmtserver", + 2417: "composit-server", + 2418: "cas", + 2419: "attachmate-s2s", + 2420: "dslremote-mgmt", + 2421: "g-talk", + 2422: "crmsbits", + 2423: "rnrp", + 2424: "kofax-svr", + 2425: "fjitsuappmgr", + 2426: "vcmp", + 2427: "mgcp-gateway", + 2428: "ott", + 2429: "ft-role", + 2430: "venus", + 2431: "venus-se", + 2432: "codasrv", + 2433: "codasrv-se", + 2434: "pxc-epmap", + 2435: "optilogic", + 2436: "topx", + 2437: "unicontrol", + 2438: "msp", + 2439: "sybasedbsynch", + 2440: "spearway", + 2441: "pvsw-inet", + 2442: "netangel", + 2443: "powerclientcsf", + 2444: "btpp2sectrans", + 2445: "dtn1", + 2446: "bues-service", + 2447: "ovwdb", + 2448: "hpppssvr", + 2449: "ratl", + 2450: "netadmin", + 2451: "netchat", + 2452: "snifferclient", + 2453: "madge-ltd", + 2454: "indx-dds", + 2455: "wago-io-system", + 2456: "altav-remmgt", + 2457: "rapido-ip", + 2458: "griffin", + 2459: "community", + 2460: "ms-theater", + 2461: "qadmifoper", + 2462: "qadmifevent", + 2463: "lsi-raid-mgmt", + 2464: "direcpc-si", + 2465: "lbm", + 2466: "lbf", + 2467: "high-criteria", + 2468: "qip-msgd", + 2469: "mti-tcs-comm", + 2470: "taskman-port", + 2471: "seaodbc", + 2472: "c3", + 2473: "aker-cdp", + 2474: "vitalanalysis", + 2475: "ace-server", + 2476: "ace-svr-prop", + 2477: "ssm-cvs", + 2478: "ssm-cssps", + 2479: "ssm-els", + 2480: "powerexchange", + 2481: "giop", + 2482: "giop-ssl", + 2483: "ttc", + 2484: "ttc-ssl", + 2485: "netobjects1", + 2486: "netobjects2", + 2487: "pns", + 2488: "moy-corp", + 2489: "tsilb", + 2490: "qip-qdhcp", + 2491: "conclave-cpp", + 2492: "groove", + 2493: "talarian-mqs", + 2494: "bmc-ar", + 2495: "fast-rem-serv", + 2496: "dirgis", + 2497: "quaddb", + 2498: "odn-castraq", + 2499: "unicontrol", + 2500: "rtsserv", + 2501: "rtsclient", + 2502: "kentrox-prot", + 2503: "nms-dpnss", + 2504: "wlbs", + 2505: "ppcontrol", + 2506: "jbroker", + 2507: "spock", + 2508: "jdatastore", + 2509: "fjmpss", + 2510: "fjappmgrbulk", + 2511: "metastorm", + 2512: "citrixima", + 2513: "citrixadmin", + 2514: "facsys-ntp", + 2515: "facsys-router", + 2516: "maincontrol", + 2517: "call-sig-trans", + 2518: "willy", + 2519: "globmsgsvc", + 2520: "pvsw", + 2521: "adaptecmgr", + 2522: "windb", + 2523: "qke-llc-v3", + 2524: "optiwave-lm", + 2525: "ms-v-worlds", + 2526: "ema-sent-lm", + 2527: "iqserver", + 2528: "ncr-ccl", + 2529: "utsftp", + 2530: "vrcommerce", + 2531: "ito-e-gui", + 2532: "ovtopmd", + 2533: "snifferserver", + 2534: "combox-web-acc", + 2535: "madcap", + 2536: "btpp2audctr1", + 2537: "upgrade", + 2538: "vnwk-prapi", + 2539: "vsiadmin", + 2540: "lonworks", + 2541: "lonworks2", + 2542: "udrawgraph", + 2543: "reftek", + 2544: "novell-zen", + 2545: "sis-emt", + 2546: "vytalvaultbrtp", + 2547: "vytalvaultvsmp", + 2548: "vytalvaultpipe", + 2549: "ipass", + 2550: "ads", + 2551: "isg-uda-server", + 2552: "call-logging", + 2553: "efidiningport", + 2554: "vcnet-link-v10", + 2555: "compaq-wcp", + 2556: "nicetec-nmsvc", + 2557: "nicetec-mgmt", + 2558: "pclemultimedia", + 2559: "lstp", + 2560: "labrat", + 2561: "mosaixcc", + 2562: "delibo", + 2563: "cti-redwood", + 2564: "hp-3000-telnet", + 2565: "coord-svr", + 2566: "pcs-pcw", + 2567: "clp", + 2568: "spamtrap", + 2569: "sonuscallsig", + 2570: "hs-port", + 2571: "cecsvc", + 2572: "ibp", + 2573: "trustestablish", + 2574: "blockade-bpsp", + 2575: "hl7", + 2576: "tclprodebugger", + 2577: "scipticslsrvr", + 2578: "rvs-isdn-dcp", + 2579: "mpfoncl", + 2580: "tributary", + 2581: "argis-te", + 2582: "argis-ds", + 2583: "mon", + 2584: "cyaserv", + 2585: "netx-server", + 2586: "netx-agent", + 2587: "masc", + 2588: "privilege", + 2589: "quartus-tcl", + 2590: "idotdist", + 2591: "maytagshuffle", + 2592: "netrek", + 2593: "mns-mail", + 2594: "dts", + 2595: "worldfusion1", + 2596: "worldfusion2", + 2597: "homesteadglory", + 2598: "citriximaclient", + 2599: "snapd", + 2600: "hpstgmgr", + 2601: "discp-client", + 2602: "discp-server", + 2603: "servicemeter", + 2604: "nsc-ccs", + 2605: "nsc-posa", + 2606: "netmon", + 2607: "connection", + 2608: "wag-service", + 2609: "system-monitor", + 2610: "versa-tek", + 2611: "lionhead", + 2612: "qpasa-agent", + 2613: "smntubootstrap", + 2614: "neveroffline", + 2615: "firepower", + 2616: "appswitch-emp", + 2617: "cmadmin", + 2618: "priority-e-com", + 2619: "bruce", + 2620: "lpsrecommender", + 2621: "miles-apart", + 2622: "metricadbc", + 2623: "lmdp", + 2624: "aria", + 2625: "blwnkl-port", + 2626: "gbjd816", + 2627: "moshebeeri", + 2628: "dict", + 2629: "sitaraserver", + 2630: "sitaramgmt", + 2631: "sitaradir", + 2632: "irdg-post", + 2633: "interintelli", + 2634: "pk-electronics", + 2635: "backburner", + 2636: "solve", + 2637: "imdocsvc", + 2638: "sybaseanywhere", + 2639: "aminet", + 2640: "ami-control", + 2641: "hdl-srv", + 2642: "tragic", + 2643: "gte-samp", + 2644: "travsoft-ipx-t", + 2645: "novell-ipx-cmd", + 2646: "and-lm", + 2647: "syncserver", + 2648: "upsnotifyprot", + 2649: "vpsipport", + 2650: "eristwoguns", + 2651: "ebinsite", + 2652: "interpathpanel", + 2653: "sonus", + 2654: "corel-vncadmin", + 2655: "unglue", + 2656: "kana", + 2657: "sns-dispatcher", + 2658: "sns-admin", + 2659: "sns-query", + 2660: "gcmonitor", + 2661: "olhost", + 2662: "bintec-capi", + 2663: "bintec-tapi", + 2664: "patrol-mq-gm", + 2665: "patrol-mq-nm", + 2666: "extensis", + 2667: "alarm-clock-s", + 2668: "alarm-clock-c", + 2669: "toad", + 2670: "tve-announce", + 2671: "newlixreg", + 2672: "nhserver", + 2673: "firstcall42", + 2674: "ewnn", + 2675: "ttc-etap", + 2676: "simslink", + 2677: "gadgetgate1way", + 2678: "gadgetgate2way", + 2679: "syncserverssl", + 2680: "pxc-sapxom", + 2681: "mpnjsomb", + 2683: "ncdloadbalance", + 2684: "mpnjsosv", + 2685: "mpnjsocl", + 2686: "mpnjsomg", + 2687: "pq-lic-mgmt", + 2688: "md-cg-http", + 2689: "fastlynx", + 2690: "hp-nnm-data", + 2691: "itinternet", + 2692: "admins-lms", + 2694: "pwrsevent", + 2695: "vspread", + 2696: "unifyadmin", + 2697: "oce-snmp-trap", + 2698: "mck-ivpip", + 2699: "csoft-plusclnt", + 2700: "tqdata", + 2701: "sms-rcinfo", + 2702: "sms-xfer", + 2703: "sms-chat", + 2704: "sms-remctrl", + 2705: "sds-admin", + 2706: "ncdmirroring", + 2707: "emcsymapiport", + 2708: "banyan-net", + 2709: "supermon", + 2710: "sso-service", + 2711: "sso-control", + 2712: "aocp", + 2713: "raventbs", + 2714: "raventdm", + 2715: "hpstgmgr2", + 2716: "inova-ip-disco", + 2717: "pn-requester", + 2718: "pn-requester2", + 2719: "scan-change", + 2720: "wkars", + 2721: "smart-diagnose", + 2722: "proactivesrvr", + 2723: "watchdog-nt", + 2724: "qotps", + 2725: "msolap-ptp2", + 2726: "tams", + 2727: "mgcp-callagent", + 2728: "sqdr", + 2729: "tcim-control", + 2730: "nec-raidplus", + 2731: "fyre-messanger", + 2732: "g5m", + 2733: "signet-ctf", + 2734: "ccs-software", + 2735: "netiq-mc", + 2736: "radwiz-nms-srv", + 2737: "srp-feedback", + 2738: "ndl-tcp-ois-gw", + 2739: "tn-timing", + 2740: "alarm", + 2741: "tsb", + 2742: "tsb2", + 2743: "murx", + 2744: "honyaku", + 2745: "urbisnet", + 2746: "cpudpencap", + 2747: "fjippol-swrly", + 2748: "fjippol-polsvr", + 2749: "fjippol-cnsl", + 2750: "fjippol-port1", + 2751: "fjippol-port2", + 2752: "rsisysaccess", + 2753: "de-spot", + 2754: "apollo-cc", + 2755: "expresspay", + 2756: "simplement-tie", + 2757: "cnrp", + 2758: "apollo-status", + 2759: "apollo-gms", + 2760: "sabams", + 2761: "dicom-iscl", + 2762: "dicom-tls", + 2763: "desktop-dna", + 2764: "data-insurance", + 2765: "qip-audup", + 2766: "compaq-scp", + 2767: "uadtc", + 2768: "uacs", + 2769: "exce", + 2770: "veronica", + 2771: "vergencecm", + 2772: "auris", + 2773: "rbakcup1", + 2774: "rbakcup2", + 2775: "smpp", + 2776: "ridgeway1", + 2777: "ridgeway2", + 2778: "gwen-sonya", + 2779: "lbc-sync", + 2780: "lbc-control", + 2781: "whosells", + 2782: "everydayrc", + 2783: "aises", + 2784: "www-dev", + 2785: "aic-np", + 2786: "aic-oncrpc", + 2787: "piccolo", + 2788: "fryeserv", + 2789: "media-agent", + 2790: "plgproxy", + 2791: "mtport-regist", + 2792: "f5-globalsite", + 2793: "initlsmsad", + 2795: "livestats", + 2796: "ac-tech", + 2797: "esp-encap", + 2798: "tmesis-upshot", + 2799: "icon-discover", + 2800: "acc-raid", + 2801: "igcp", + 2802: "veritas-udp1", + 2803: "btprjctrl", + 2804: "dvr-esm", + 2805: "wta-wsp-s", + 2806: "cspuni", + 2807: "cspmulti", + 2808: "j-lan-p", + 2809: "corbaloc", + 2810: "netsteward", + 2811: "gsiftp", + 2812: "atmtcp", + 2813: "llm-pass", + 2814: "llm-csv", + 2815: "lbc-measure", + 2816: "lbc-watchdog", + 2817: "nmsigport", + 2818: "rmlnk", + 2819: "fc-faultnotify", + 2820: "univision", + 2821: "vrts-at-port", + 2822: "ka0wuc", + 2823: "cqg-netlan", + 2824: "cqg-netlan-1", + 2826: "slc-systemlog", + 2827: "slc-ctrlrloops", + 2828: "itm-lm", + 2829: "silkp1", + 2830: "silkp2", + 2831: "silkp3", + 2832: "silkp4", + 2833: "glishd", + 2834: "evtp", + 2835: "evtp-data", + 2836: "catalyst", + 2837: "repliweb", + 2838: "starbot", + 2839: "nmsigport", + 2840: "l3-exprt", + 2841: "l3-ranger", + 2842: "l3-hawk", + 2843: "pdnet", + 2844: "bpcp-poll", + 2845: "bpcp-trap", + 2846: "aimpp-hello", + 2847: "aimpp-port-req", + 2848: "amt-blc-port", + 2849: "fxp", + 2850: "metaconsole", + 2851: "webemshttp", + 2852: "bears-01", + 2853: "ispipes", + 2854: "infomover", + 2856: "cesdinv", + 2857: "simctlp", + 2858: "ecnp", + 2859: "activememory", + 2860: "dialpad-voice1", + 2861: "dialpad-voice2", + 2862: "ttg-protocol", + 2863: "sonardata", + 2864: "astromed-main", + 2865: "pit-vpn", + 2866: "iwlistener", + 2867: "esps-portal", + 2868: "npep-messaging", + 2869: "icslap", + 2870: "daishi", + 2871: "msi-selectplay", + 2872: "radix", + 2874: "dxmessagebase1", + 2875: "dxmessagebase2", + 2876: "sps-tunnel", + 2877: "bluelance", + 2878: "aap", + 2879: "ucentric-ds", + 2880: "synapse", + 2881: "ndsp", + 2882: "ndtp", + 2883: "ndnp", + 2884: "flashmsg", + 2885: "topflow", + 2886: "responselogic", + 2887: "aironetddp", + 2888: "spcsdlobby", + 2889: "rsom", + 2890: "cspclmulti", + 2891: "cinegrfx-elmd", + 2892: "snifferdata", + 2893: "vseconnector", + 2894: "abacus-remote", + 2895: "natuslink", + 2896: "ecovisiong6-1", + 2897: "citrix-rtmp", + 2898: "appliance-cfg", + 2899: "powergemplus", + 2900: "quicksuite", + 2901: "allstorcns", + 2902: "netaspi", + 2903: "suitcase", + 2904: "m2ua", + 2906: "caller9", + 2907: "webmethods-b2b", + 2908: "mao", + 2909: "funk-dialout", + 2910: "tdaccess", + 2911: "blockade", + 2912: "epicon", + 2913: "boosterware", + 2914: "gamelobby", + 2915: "tksocket", + 2916: "elvin-server", + 2917: "elvin-client", + 2918: "kastenchasepad", + 2919: "roboer", + 2920: "roboeda", + 2921: "cesdcdman", + 2922: "cesdcdtrn", + 2923: "wta-wsp-wtp-s", + 2924: "precise-vip", + 2926: "mobile-file-dl", + 2927: "unimobilectrl", + 2928: "redstone-cpss", + 2929: "amx-webadmin", + 2930: "amx-weblinx", + 2931: "circle-x", + 2932: "incp", + 2933: "4-tieropmgw", + 2934: "4-tieropmcli", + 2935: "qtp", + 2936: "otpatch", + 2937: "pnaconsult-lm", + 2938: "sm-pas-1", + 2939: "sm-pas-2", + 2940: "sm-pas-3", + 2941: "sm-pas-4", + 2942: "sm-pas-5", + 2943: "ttnrepository", + 2944: "megaco-h248", + 2945: "h248-binary", + 2946: "fjsvmpor", + 2947: "gpsd", + 2948: "wap-push", + 2949: "wap-pushsecure", + 2950: "esip", + 2951: "ottp", + 2952: "mpfwsas", + 2953: "ovalarmsrv", + 2954: "ovalarmsrv-cmd", + 2955: "csnotify", + 2956: "ovrimosdbman", + 2957: "jmact5", + 2958: "jmact6", + 2959: "rmopagt", + 2960: "dfoxserver", + 2961: "boldsoft-lm", + 2962: "iph-policy-cli", + 2963: "iph-policy-adm", + 2964: "bullant-srap", + 2965: "bullant-rap", + 2966: "idp-infotrieve", + 2967: "ssc-agent", + 2968: "enpp", + 2969: "essp", + 2970: "index-net", + 2971: "netclip", + 2972: "pmsm-webrctl", + 2973: "svnetworks", + 2974: "signal", + 2975: "fjmpcm", + 2976: "cns-srv-port", + 2977: "ttc-etap-ns", + 2978: "ttc-etap-ds", + 2979: "h263-video", + 2980: "wimd", + 2981: "mylxamport", + 2982: "iwb-whiteboard", + 2983: "netplan", + 2984: "hpidsadmin", + 2985: "hpidsagent", + 2986: "stonefalls", + 2987: "identify", + 2988: "hippad", + 2989: "zarkov", + 2990: "boscap", + 2991: "wkstn-mon", + 2992: "avenyo", + 2993: "veritas-vis1", + 2994: "veritas-vis2", + 2995: "idrs", + 2996: "vsixml", + 2997: "rebol", + 2998: "realsecure", + 2999: "remoteware-un", + 3000: "hbci", + 3002: "exlm-agent", + 3003: "cgms", + 3004: "csoftragent", + 3005: "geniuslm", + 3006: "ii-admin", + 3007: "lotusmtap", + 3008: "midnight-tech", + 3009: "pxc-ntfy", + 3010: "ping-pong", + 3011: "trusted-web", + 3012: "twsdss", + 3013: "gilatskysurfer", + 3014: "broker-service", + 3015: "nati-dstp", + 3016: "notify-srvr", + 3017: "event-listener", + 3018: "srvc-registry", + 3019: "resource-mgr", + 3020: "cifs", + 3021: "agriserver", + 3022: "csregagent", + 3023: "magicnotes", + 3024: "nds-sso", + 3025: "arepa-raft", + 3026: "agri-gateway", + 3027: "LiebDevMgmt-C", + 3028: "LiebDevMgmt-DM", + 3029: "LiebDevMgmt-A", + 3030: "arepa-cas", + 3031: "eppc", + 3032: "redwood-chat", + 3033: "pdb", + 3034: "osmosis-aeea", + 3035: "fjsv-gssagt", + 3036: "hagel-dump", + 3037: "hp-san-mgmt", + 3038: "santak-ups", + 3039: "cogitate", + 3040: "tomato-springs", + 3041: "di-traceware", + 3042: "journee", + 3043: "brp", + 3044: "epp", + 3045: "responsenet", + 3046: "di-ase", + 3047: "hlserver", + 3048: "pctrader", + 3049: "nsws", + 3050: "gds-db", + 3051: "galaxy-server", + 3052: "apc-3052", + 3053: "dsom-server", + 3054: "amt-cnf-prot", + 3055: "policyserver", + 3056: "cdl-server", + 3057: "goahead-fldup", + 3058: "videobeans", + 3059: "qsoft", + 3060: "interserver", + 3061: "cautcpd", + 3062: "ncacn-ip-tcp", + 3063: "ncadg-ip-udp", + 3064: "rprt", + 3065: "slinterbase", + 3066: "netattachsdmp", + 3067: "fjhpjp", + 3068: "ls3bcast", + 3069: "ls3", + 3070: "mgxswitch", + 3071: "csd-mgmt-port", + 3072: "csd-monitor", + 3073: "vcrp", + 3074: "xbox", + 3075: "orbix-locator", + 3076: "orbix-config", + 3077: "orbix-loc-ssl", + 3078: "orbix-cfg-ssl", + 3079: "lv-frontpanel", + 3080: "stm-pproc", + 3081: "tl1-lv", + 3082: "tl1-raw", + 3083: "tl1-telnet", + 3084: "itm-mccs", + 3085: "pcihreq", + 3086: "jdl-dbkitchen", + 3087: "asoki-sma", + 3088: "xdtp", + 3089: "ptk-alink", + 3090: "stss", + 3091: "1ci-smcs", + 3093: "rapidmq-center", + 3094: "rapidmq-reg", + 3095: "panasas", + 3096: "ndl-aps", + 3098: "umm-port", + 3099: "chmd", + 3100: "opcon-xps", + 3101: "hp-pxpib", + 3102: "slslavemon", + 3103: "autocuesmi", + 3104: "autocuetime", + 3105: "cardbox", + 3106: "cardbox-http", + 3107: "business", + 3108: "geolocate", + 3109: "personnel", + 3110: "sim-control", + 3111: "wsynch", + 3112: "ksysguard", + 3113: "cs-auth-svr", + 3114: "ccmad", + 3115: "mctet-master", + 3116: "mctet-gateway", + 3117: "mctet-jserv", + 3118: "pkagent", + 3119: "d2000kernel", + 3120: "d2000webserver", + 3122: "vtr-emulator", + 3123: "edix", + 3124: "beacon-port", + 3125: "a13-an", + 3127: "ctx-bridge", + 3128: "ndl-aas", + 3129: "netport-id", + 3130: "icpv2", + 3131: "netbookmark", + 3132: "ms-rule-engine", + 3133: "prism-deploy", + 3134: "ecp", + 3135: "peerbook-port", + 3136: "grubd", + 3137: "rtnt-1", + 3138: "rtnt-2", + 3139: "incognitorv", + 3140: "ariliamulti", + 3141: "vmodem", + 3142: "rdc-wh-eos", + 3143: "seaview", + 3144: "tarantella", + 3145: "csi-lfap", + 3146: "bears-02", + 3147: "rfio", + 3148: "nm-game-admin", + 3149: "nm-game-server", + 3150: "nm-asses-admin", + 3151: "nm-assessor", + 3152: "feitianrockey", + 3153: "s8-client-port", + 3154: "ccmrmi", + 3155: "jpegmpeg", + 3156: "indura", + 3157: "e3consultants", + 3158: "stvp", + 3159: "navegaweb-port", + 3160: "tip-app-server", + 3161: "doc1lm", + 3162: "sflm", + 3163: "res-sap", + 3164: "imprs", + 3165: "newgenpay", + 3166: "sossecollector", + 3167: "nowcontact", + 3168: "poweronnud", + 3169: "serverview-as", + 3170: "serverview-asn", + 3171: "serverview-gf", + 3172: "serverview-rm", + 3173: "serverview-icc", + 3174: "armi-server", + 3175: "t1-e1-over-ip", + 3176: "ars-master", + 3177: "phonex-port", + 3178: "radclientport", + 3179: "h2gf-w-2m", + 3180: "mc-brk-srv", + 3181: "bmcpatrolagent", + 3182: "bmcpatrolrnvu", + 3183: "cops-tls", + 3184: "apogeex-port", + 3185: "smpppd", + 3186: "iiw-port", + 3187: "odi-port", + 3188: "brcm-comm-port", + 3189: "pcle-infex", + 3190: "csvr-proxy", + 3191: "csvr-sslproxy", + 3192: "firemonrcc", + 3193: "spandataport", + 3194: "magbind", + 3195: "ncu-1", + 3196: "ncu-2", + 3197: "embrace-dp-s", + 3198: "embrace-dp-c", + 3199: "dmod-workspace", + 3200: "tick-port", + 3201: "cpq-tasksmart", + 3202: "intraintra", + 3203: "netwatcher-mon", + 3204: "netwatcher-db", + 3205: "isns", + 3206: "ironmail", + 3207: "vx-auth-port", + 3208: "pfu-prcallback", + 3209: "netwkpathengine", + 3210: "flamenco-proxy", + 3211: "avsecuremgmt", + 3212: "surveyinst", + 3213: "neon24x7", + 3214: "jmq-daemon-1", + 3215: "jmq-daemon-2", + 3216: "ferrari-foam", + 3217: "unite", + 3218: "smartpackets", + 3219: "wms-messenger", + 3220: "xnm-ssl", + 3221: "xnm-clear-text", + 3222: "glbp", + 3223: "digivote", + 3224: "aes-discovery", + 3225: "fcip-port", + 3226: "isi-irp", + 3227: "dwnmshttp", + 3228: "dwmsgserver", + 3229: "global-cd-port", + 3230: "sftdst-port", + 3231: "vidigo", + 3232: "mdtp", + 3233: "whisker", + 3234: "alchemy", + 3235: "mdap-port", + 3236: "apparenet-ts", + 3237: "apparenet-tps", + 3238: "apparenet-as", + 3239: "apparenet-ui", + 3240: "triomotion", + 3241: "sysorb", + 3242: "sdp-id-port", + 3243: "timelot", + 3244: "onesaf", + 3245: "vieo-fe", + 3246: "dvt-system", + 3247: "dvt-data", + 3248: "procos-lm", + 3249: "ssp", + 3250: "hicp", + 3251: "sysscanner", + 3252: "dhe", + 3253: "pda-data", + 3254: "pda-sys", + 3255: "semaphore", + 3256: "cpqrpm-agent", + 3257: "cpqrpm-server", + 3258: "ivecon-port", + 3259: "epncdp2", + 3260: "iscsi-target", + 3261: "winshadow", + 3262: "necp", + 3263: "ecolor-imager", + 3264: "ccmail", + 3265: "altav-tunnel", + 3266: "ns-cfg-server", + 3267: "ibm-dial-out", + 3268: "msft-gc", + 3269: "msft-gc-ssl", + 3270: "verismart", + 3271: "csoft-prev", + 3272: "user-manager", + 3273: "sxmp", + 3274: "ordinox-server", + 3275: "samd", + 3276: "maxim-asics", + 3277: "awg-proxy", + 3278: "lkcmserver", + 3279: "admind", + 3280: "vs-server", + 3281: "sysopt", + 3282: "datusorb", + 3283: "Apple Remote Desktop (Net Assistant)", + 3284: "4talk", + 3285: "plato", + 3286: "e-net", + 3287: "directvdata", + 3288: "cops", + 3289: "enpc", + 3290: "caps-lm", + 3291: "sah-lm", + 3292: "cart-o-rama", + 3293: "fg-fps", + 3294: "fg-gip", + 3295: "dyniplookup", + 3296: "rib-slm", + 3297: "cytel-lm", + 3298: "deskview", + 3299: "pdrncs", + 3302: "mcs-fastmail", + 3303: "opsession-clnt", + 3304: "opsession-srvr", + 3305: "odette-ftp", + 3306: "mysql", + 3307: "opsession-prxy", + 3308: "tns-server", + 3309: "tns-adv", + 3310: "dyna-access", + 3311: "mcns-tel-ret", + 3312: "appman-server", + 3313: "uorb", + 3314: "uohost", + 3315: "cdid", + 3316: "aicc-cmi", + 3317: "vsaiport", + 3318: "ssrip", + 3319: "sdt-lmd", + 3320: "officelink2000", + 3321: "vnsstr", + 3326: "sftu", + 3327: "bbars", + 3328: "egptlm", + 3329: "hp-device-disc", + 3330: "mcs-calypsoicf", + 3331: "mcs-messaging", + 3332: "mcs-mailsvr", + 3333: "dec-notes", + 3334: "directv-web", + 3335: "directv-soft", + 3336: "directv-tick", + 3337: "directv-catlg", + 3338: "anet-b", + 3339: "anet-l", + 3340: "anet-m", + 3341: "anet-h", + 3342: "webtie", + 3343: "ms-cluster-net", + 3344: "bnt-manager", + 3345: "influence", + 3346: "trnsprntproxy", + 3347: "phoenix-rpc", + 3348: "pangolin-laser", + 3349: "chevinservices", + 3350: "findviatv", + 3351: "btrieve", + 3352: "ssql", + 3353: "fatpipe", + 3354: "suitjd", + 3355: "ordinox-dbase", + 3356: "upnotifyps", + 3357: "adtech-test", + 3358: "mpsysrmsvr", + 3359: "wg-netforce", + 3360: "kv-server", + 3361: "kv-agent", + 3362: "dj-ilm", + 3363: "nati-vi-server", + 3364: "creativeserver", + 3365: "contentserver", + 3366: "creativepartnr", + 3372: "tip2", + 3373: "lavenir-lm", + 3374: "cluster-disc", + 3375: "vsnm-agent", + 3376: "cdbroker", + 3377: "cogsys-lm", + 3378: "wsicopy", + 3379: "socorfs", + 3380: "sns-channels", + 3381: "geneous", + 3382: "fujitsu-neat", + 3383: "esp-lm", + 3384: "hp-clic", + 3385: "qnxnetman", + 3386: "gprs-sig", + 3387: "backroomnet", + 3388: "cbserver", + 3389: "ms-wbt-server", + 3390: "dsc", + 3391: "savant", + 3392: "efi-lm", + 3393: "d2k-tapestry1", + 3394: "d2k-tapestry2", + 3395: "dyna-lm", + 3396: "printer-agent", + 3397: "cloanto-lm", + 3398: "mercantile", + 3399: "csms", + 3400: "csms2", + 3401: "filecast", + 3402: "fxaengine-net", + 3405: "nokia-ann-ch1", + 3406: "nokia-ann-ch2", + 3407: "ldap-admin", + 3408: "BESApi", + 3409: "networklens", + 3410: "networklenss", + 3411: "biolink-auth", + 3412: "xmlblaster", + 3413: "svnet", + 3414: "wip-port", + 3415: "bcinameservice", + 3416: "commandport", + 3417: "csvr", + 3418: "rnmap", + 3419: "softaudit", + 3420: "ifcp-port", + 3421: "bmap", + 3422: "rusb-sys-port", + 3423: "xtrm", + 3424: "xtrms", + 3425: "agps-port", + 3426: "arkivio", + 3427: "websphere-snmp", + 3428: "twcss", + 3429: "gcsp", + 3430: "ssdispatch", + 3431: "ndl-als", + 3432: "osdcp", + 3433: "opnet-smp", + 3434: "opencm", + 3435: "pacom", + 3436: "gc-config", + 3437: "autocueds", + 3438: "spiral-admin", + 3439: "hri-port", + 3440: "ans-console", + 3441: "connect-client", + 3442: "connect-server", + 3443: "ov-nnm-websrv", + 3444: "denali-server", + 3445: "monp", + 3446: "3comfaxrpc", + 3447: "directnet", + 3448: "dnc-port", + 3449: "hotu-chat", + 3450: "castorproxy", + 3451: "asam", + 3452: "sabp-signal", + 3453: "pscupd", + 3454: "mira", + 3455: "prsvp", + 3456: "vat", + 3457: "vat-control", + 3458: "d3winosfi", + 3459: "integral", + 3460: "edm-manager", + 3461: "edm-stager", + 3462: "edm-std-notify", + 3463: "edm-adm-notify", + 3464: "edm-mgr-sync", + 3465: "edm-mgr-cntrl", + 3466: "workflow", + 3467: "rcst", + 3468: "ttcmremotectrl", + 3469: "pluribus", + 3470: "jt400", + 3471: "jt400-ssl", + 3472: "jaugsremotec-1", + 3473: "jaugsremotec-2", + 3474: "ttntspauto", + 3475: "genisar-port", + 3476: "nppmp", + 3477: "ecomm", + 3478: "stun", + 3479: "twrpc", + 3480: "plethora", + 3481: "cleanerliverc", + 3482: "vulture", + 3483: "slim-devices", + 3484: "gbs-stp", + 3485: "celatalk", + 3486: "ifsf-hb-port", + 3487: "ltcudp", + 3488: "fs-rh-srv", + 3489: "dtp-dia", + 3490: "colubris", + 3491: "swr-port", + 3492: "tvdumtray-port", + 3493: "nut", + 3494: "ibm3494", + 3495: "seclayer-tcp", + 3496: "seclayer-tls", + 3497: "ipether232port", + 3498: "dashpas-port", + 3499: "sccip-media", + 3500: "rtmp-port", + 3501: "isoft-p2p", + 3502: "avinstalldisc", + 3503: "lsp-ping", + 3504: "ironstorm", + 3505: "ccmcomm", + 3506: "apc-3506", + 3507: "nesh-broker", + 3508: "interactionweb", + 3509: "vt-ssl", + 3510: "xss-port", + 3511: "webmail-2", + 3512: "aztec", + 3513: "arcpd", + 3514: "must-p2p", + 3515: "must-backplane", + 3516: "smartcard-port", + 3517: "802-11-iapp", + 3518: "artifact-msg", + 3519: "galileo", + 3520: "galileolog", + 3521: "mc3ss", + 3522: "nssocketport", + 3523: "odeumservlink", + 3524: "ecmport", + 3525: "eisport", + 3526: "starquiz-port", + 3527: "beserver-msg-q", + 3528: "jboss-iiop", + 3529: "jboss-iiop-ssl", + 3530: "gf", + 3531: "joltid", + 3532: "raven-rmp", + 3533: "raven-rdp", + 3534: "urld-port", + 3535: "ms-la", + 3536: "snac", + 3537: "ni-visa-remote", + 3538: "ibm-diradm", + 3539: "ibm-diradm-ssl", + 3540: "pnrp-port", + 3541: "voispeed-port", + 3542: "hacl-monitor", + 3543: "qftest-lookup", + 3544: "teredo", + 3545: "camac", + 3547: "symantec-sim", + 3548: "interworld", + 3549: "tellumat-nms", + 3550: "ssmpp", + 3551: "apcupsd", + 3552: "taserver", + 3553: "rbr-discovery", + 3554: "questnotify", + 3555: "razor", + 3556: "sky-transport", + 3557: "personalos-001", + 3558: "mcp-port", + 3559: "cctv-port", + 3560: "iniserve-port", + 3561: "bmc-onekey", + 3562: "sdbproxy", + 3563: "watcomdebug", + 3564: "esimport", + 3567: "dof-eps", + 3568: "dof-tunnel-sec", + 3569: "mbg-ctrl", + 3570: "mccwebsvr-port", + 3571: "megardsvr-port", + 3572: "megaregsvrport", + 3573: "tag-ups-1", + 3574: "dmaf-caster", + 3575: "ccm-port", + 3576: "cmc-port", + 3577: "config-port", + 3578: "data-port", + 3579: "ttat3lb", + 3580: "nati-svrloc", + 3581: "kfxaclicensing", + 3582: "press", + 3583: "canex-watch", + 3584: "u-dbap", + 3585: "emprise-lls", + 3586: "emprise-lsc", + 3587: "p2pgroup", + 3588: "sentinel", + 3589: "isomair", + 3590: "wv-csp-sms", + 3591: "gtrack-server", + 3592: "gtrack-ne", + 3593: "bpmd", + 3594: "mediaspace", + 3595: "shareapp", + 3596: "iw-mmogame", + 3597: "a14", + 3598: "a15", + 3599: "quasar-server", + 3600: "trap-daemon", + 3601: "visinet-gui", + 3602: "infiniswitchcl", + 3603: "int-rcv-cntrl", + 3604: "bmc-jmx-port", + 3605: "comcam-io", + 3606: "splitlock", + 3607: "precise-i3", + 3608: "trendchip-dcp", + 3609: "cpdi-pidas-cm", + 3610: "echonet", + 3611: "six-degrees", + 3612: "hp-dataprotect", + 3613: "alaris-disc", + 3614: "sigma-port", + 3615: "start-network", + 3616: "cd3o-protocol", + 3617: "sharp-server", + 3618: "aairnet-1", + 3619: "aairnet-2", + 3620: "ep-pcp", + 3621: "ep-nsp", + 3622: "ff-lr-port", + 3623: "haipe-discover", + 3624: "dist-upgrade", + 3625: "volley", + 3626: "bvcdaemon-port", + 3627: "jamserverport", + 3628: "ept-machine", + 3629: "escvpnet", + 3630: "cs-remote-db", + 3631: "cs-services", + 3632: "distcc", + 3633: "wacp", + 3634: "hlibmgr", + 3635: "sdo", + 3636: "servistaitsm", + 3637: "scservp", + 3638: "ehp-backup", + 3639: "xap-ha", + 3640: "netplay-port1", + 3641: "netplay-port2", + 3642: "juxml-port", + 3643: "audiojuggler", + 3644: "ssowatch", + 3645: "cyc", + 3646: "xss-srv-port", + 3647: "splitlock-gw", + 3648: "fjcp", + 3649: "nmmp", + 3650: "prismiq-plugin", + 3651: "xrpc-registry", + 3652: "vxcrnbuport", + 3653: "tsp", + 3654: "vaprtm", + 3655: "abatemgr", + 3656: "abatjss", + 3657: "immedianet-bcn", + 3658: "ps-ams", + 3659: "apple-sasl", + 3660: "can-nds-ssl", + 3661: "can-ferret-ssl", + 3662: "pserver", + 3663: "dtp", + 3664: "ups-engine", + 3665: "ent-engine", + 3666: "eserver-pap", + 3667: "infoexch", + 3668: "dell-rm-port", + 3669: "casanswmgmt", + 3670: "smile", + 3671: "efcp", + 3672: "lispworks-orb", + 3673: "mediavault-gui", + 3674: "wininstall-ipc", + 3675: "calltrax", + 3676: "va-pacbase", + 3677: "roverlog", + 3678: "ipr-dglt", + 3679: "Escale (Newton Dock)", + 3680: "npds-tracker", + 3681: "bts-x73", + 3682: "cas-mapi", + 3683: "bmc-ea", + 3684: "faxstfx-port", + 3685: "dsx-agent", + 3686: "tnmpv2", + 3687: "simple-push", + 3688: "simple-push-s", + 3689: "daap", + 3690: "svn", + 3691: "magaya-network", + 3692: "intelsync", + 3695: "bmc-data-coll", + 3696: "telnetcpcd", + 3697: "nw-license", + 3698: "sagectlpanel", + 3699: "kpn-icw", + 3700: "lrs-paging", + 3701: "netcelera", + 3702: "ws-discovery", + 3703: "adobeserver-3", + 3704: "adobeserver-4", + 3705: "adobeserver-5", + 3706: "rt-event", + 3707: "rt-event-s", + 3708: "sun-as-iiops", + 3709: "ca-idms", + 3710: "portgate-auth", + 3711: "edb-server2", + 3712: "sentinel-ent", + 3713: "tftps", + 3714: "delos-dms", + 3715: "anoto-rendezv", + 3716: "wv-csp-sms-cir", + 3717: "wv-csp-udp-cir", + 3718: "opus-services", + 3719: "itelserverport", + 3720: "ufastro-instr", + 3721: "xsync", + 3722: "xserveraid", + 3723: "sychrond", + 3724: "blizwow", + 3725: "na-er-tip", + 3726: "array-manager", + 3727: "e-mdu", + 3728: "e-woa", + 3729: "fksp-audit", + 3730: "client-ctrl", + 3731: "smap", + 3732: "m-wnn", + 3733: "multip-msg", + 3734: "synel-data", + 3735: "pwdis", + 3736: "rs-rmi", + 3738: "versatalk", + 3739: "launchbird-lm", + 3740: "heartbeat", + 3741: "wysdma", + 3742: "cst-port", + 3743: "ipcs-command", + 3744: "sasg", + 3745: "gw-call-port", + 3746: "linktest", + 3747: "linktest-s", + 3748: "webdata", + 3749: "cimtrak", + 3750: "cbos-ip-port", + 3751: "gprs-cube", + 3752: "vipremoteagent", + 3753: "nattyserver", + 3754: "timestenbroker", + 3755: "sas-remote-hlp", + 3756: "canon-capt", + 3757: "grf-port", + 3758: "apw-registry", + 3759: "exapt-lmgr", + 3760: "adtempusclient", + 3761: "gsakmp", + 3762: "gbs-smp", + 3763: "xo-wave", + 3764: "mni-prot-rout", + 3765: "rtraceroute", + 3767: "listmgr-port", + 3768: "rblcheckd", + 3769: "haipe-otnk", + 3770: "cindycollab", + 3771: "paging-port", + 3772: "ctp", + 3773: "ctdhercules", + 3774: "zicom", + 3775: "ispmmgr", + 3776: "dvcprov-port", + 3777: "jibe-eb", + 3778: "c-h-it-port", + 3779: "cognima", + 3780: "nnp", + 3781: "abcvoice-port", + 3782: "iso-tp0s", + 3783: "bim-pem", + 3784: "bfd-control", + 3785: "bfd-echo", + 3786: "upstriggervsw", + 3787: "fintrx", + 3788: "isrp-port", + 3789: "remotedeploy", + 3790: "quickbooksrds", + 3791: "tvnetworkvideo", + 3792: "sitewatch", + 3793: "dcsoftware", + 3794: "jaus", + 3795: "myblast", + 3796: "spw-dialer", + 3797: "idps", + 3798: "minilock", + 3799: "radius-dynauth", + 3800: "pwgpsi", + 3801: "ibm-mgr", + 3802: "vhd", + 3803: "soniqsync", + 3804: "iqnet-port", + 3805: "tcpdataserver", + 3806: "wsmlb", + 3807: "spugna", + 3808: "sun-as-iiops-ca", + 3809: "apocd", + 3810: "wlanauth", + 3811: "amp", + 3812: "neto-wol-server", + 3813: "rap-ip", + 3814: "neto-dcs", + 3815: "lansurveyorxml", + 3816: "sunlps-http", + 3817: "tapeware", + 3818: "crinis-hb", + 3819: "epl-slp", + 3820: "scp", + 3821: "pmcp", + 3822: "acp-discovery", + 3823: "acp-conduit", + 3824: "acp-policy", + 3825: "ffserver", + 3826: "warmux", + 3827: "netmpi", + 3828: "neteh", + 3829: "neteh-ext", + 3830: "cernsysmgmtagt", + 3831: "dvapps", + 3832: "xxnetserver", + 3833: "aipn-auth", + 3834: "spectardata", + 3835: "spectardb", + 3836: "markem-dcp", + 3837: "mkm-discovery", + 3838: "sos", + 3839: "amx-rms", + 3840: "flirtmitmir", + 3842: "nhci", + 3843: "quest-agent", + 3844: "rnm", + 3845: "v-one-spp", + 3846: "an-pcp", + 3847: "msfw-control", + 3848: "item", + 3849: "spw-dnspreload", + 3850: "qtms-bootstrap", + 3851: "spectraport", + 3852: "sse-app-config", + 3853: "sscan", + 3854: "stryker-com", + 3855: "opentrac", + 3856: "informer", + 3857: "trap-port", + 3858: "trap-port-mom", + 3859: "nav-port", + 3860: "sasp", + 3861: "winshadow-hd", + 3862: "giga-pocket", + 3863: "asap-udp", + 3865: "xpl", + 3866: "dzdaemon", + 3867: "dzoglserver", + 3869: "ovsam-mgmt", + 3870: "ovsam-d-agent", + 3871: "avocent-adsap", + 3872: "oem-agent", + 3873: "fagordnc", + 3874: "sixxsconfig", + 3875: "pnbscada", + 3876: "dl-agent", + 3877: "xmpcr-interface", + 3878: "fotogcad", + 3879: "appss-lm", + 3880: "igrs", + 3881: "idac", + 3882: "msdts1", + 3883: "vrpn", + 3884: "softrack-meter", + 3885: "topflow-ssl", + 3886: "nei-management", + 3887: "ciphire-data", + 3888: "ciphire-serv", + 3889: "dandv-tester", + 3890: "ndsconnect", + 3891: "rtc-pm-port", + 3892: "pcc-image-port", + 3893: "cgi-starapi", + 3894: "syam-agent", + 3895: "syam-smc", + 3896: "sdo-tls", + 3897: "sdo-ssh", + 3898: "senip", + 3899: "itv-control", + 3900: "udt-os", + 3901: "nimsh", + 3902: "nimaux", + 3903: "charsetmgr", + 3904: "omnilink-port", + 3905: "mupdate", + 3906: "topovista-data", + 3907: "imoguia-port", + 3908: "hppronetman", + 3909: "surfcontrolcpa", + 3910: "prnrequest", + 3911: "prnstatus", + 3912: "gbmt-stars", + 3913: "listcrt-port", + 3914: "listcrt-port-2", + 3915: "agcat", + 3916: "wysdmc", + 3917: "aftmux", + 3918: "pktcablemmcops", + 3919: "hyperip", + 3920: "exasoftport1", + 3921: "herodotus-net", + 3922: "sor-update", + 3923: "symb-sb-port", + 3924: "mpl-gprs-port", + 3925: "zmp", + 3926: "winport", + 3927: "natdataservice", + 3928: "netboot-pxe", + 3929: "smauth-port", + 3930: "syam-webserver", + 3931: "msr-plugin-port", + 3932: "dyn-site", + 3933: "plbserve-port", + 3934: "sunfm-port", + 3935: "sdp-portmapper", + 3936: "mailprox", + 3937: "dvbservdsc", + 3938: "dbcontrol-agent", + 3939: "aamp", + 3940: "xecp-node", + 3941: "homeportal-web", + 3942: "srdp", + 3943: "tig", + 3944: "sops", + 3945: "emcads", + 3946: "backupedge", + 3947: "ccp", + 3948: "apdap", + 3949: "drip", + 3950: "namemunge", + 3951: "pwgippfax", + 3952: "i3-sessionmgr", + 3953: "xmlink-connect", + 3954: "adrep", + 3955: "p2pcommunity", + 3956: "gvcp", + 3957: "mqe-broker", + 3958: "mqe-agent", + 3959: "treehopper", + 3960: "bess", + 3961: "proaxess", + 3962: "sbi-agent", + 3963: "thrp", + 3964: "sasggprs", + 3965: "ati-ip-to-ncpe", + 3966: "bflckmgr", + 3967: "ppsms", + 3968: "ianywhere-dbns", + 3969: "landmarks", + 3970: "lanrevagent", + 3971: "lanrevserver", + 3972: "iconp", + 3973: "progistics", + 3974: "citysearch", + 3975: "airshot", + 3976: "opswagent", + 3977: "opswmanager", + 3978: "secure-cfg-svr", + 3979: "smwan", + 3980: "acms", + 3981: "starfish", + 3982: "eis", + 3983: "eisp", + 3984: "mapper-nodemgr", + 3985: "mapper-mapethd", + 3986: "mapper-ws-ethd", + 3987: "centerline", + 3988: "dcs-config", + 3989: "bv-queryengine", + 3990: "bv-is", + 3991: "bv-smcsrv", + 3992: "bv-ds", + 3993: "bv-agent", + 3995: "iss-mgmt-ssl", + 3996: "abcsoftware", + 3997: "agentsease-db", + 3998: "dnx", + 3999: "nvcnet", + 4000: "terabase", + 4001: "newoak", + 4002: "pxc-spvr-ft", + 4003: "pxc-splr-ft", + 4004: "pxc-roid", + 4005: "pxc-pin", + 4006: "pxc-spvr", + 4007: "pxc-splr", + 4008: "netcheque", + 4009: "chimera-hwm", + 4010: "samsung-unidex", + 4011: "altserviceboot", + 4012: "pda-gate", + 4013: "acl-manager", + 4014: "taiclock", + 4015: "talarian-mcast1", + 4016: "talarian-mcast2", + 4017: "talarian-mcast3", + 4018: "talarian-mcast4", + 4019: "talarian-mcast5", + 4020: "trap", + 4021: "nexus-portal", + 4022: "dnox", + 4023: "esnm-zoning", + 4024: "tnp1-port", + 4025: "partimage", + 4026: "as-debug", + 4027: "bxp", + 4028: "dtserver-port", + 4029: "ip-qsig", + 4030: "jdmn-port", + 4031: "suucp", + 4032: "vrts-auth-port", + 4033: "sanavigator", + 4034: "ubxd", + 4035: "wap-push-http", + 4036: "wap-push-https", + 4037: "ravehd", + 4038: "fazzt-ptp", + 4039: "fazzt-admin", + 4040: "yo-main", + 4041: "houston", + 4042: "ldxp", + 4043: "nirp", + 4044: "ltp", + 4045: "npp", + 4046: "acp-proto", + 4047: "ctp-state", + 4049: "wafs", + 4050: "cisco-wafs", + 4051: "cppdp", + 4052: "interact", + 4053: "ccu-comm-1", + 4054: "ccu-comm-2", + 4055: "ccu-comm-3", + 4056: "lms", + 4057: "wfm", + 4058: "kingfisher", + 4059: "dlms-cosem", + 4060: "dsmeter-iatc", + 4061: "ice-location", + 4062: "ice-slocation", + 4063: "ice-router", + 4064: "ice-srouter", + 4065: "avanti-cdp", + 4066: "pmas", + 4067: "idp", + 4068: "ipfltbcst", + 4069: "minger", + 4070: "tripe", + 4071: "aibkup", + 4072: "zieto-sock", + 4073: "iRAPP", + 4074: "cequint-cityid", + 4075: "perimlan", + 4076: "seraph", + 4077: "ascomalarm", + 4079: "santools", + 4080: "lorica-in", + 4081: "lorica-in-sec", + 4082: "lorica-out", + 4083: "lorica-out-sec", + 4084: "fortisphere-vm", + 4086: "ftsync", + 4089: "opencore", + 4090: "omasgport", + 4091: "ewinstaller", + 4092: "ewdgs", + 4093: "pvxpluscs", + 4094: "sysrqd", + 4095: "xtgui", + 4096: "bre", + 4097: "patrolview", + 4098: "drmsfsd", + 4099: "dpcp", + 4100: "igo-incognito", + 4101: "brlp-0", + 4102: "brlp-1", + 4103: "brlp-2", + 4104: "brlp-3", + 4105: "shofar", + 4106: "synchronite", + 4107: "j-ac", + 4108: "accel", + 4109: "izm", + 4110: "g2tag", + 4111: "xgrid", + 4112: "apple-vpns-rp", + 4113: "aipn-reg", + 4114: "jomamqmonitor", + 4115: "cds", + 4116: "smartcard-tls", + 4117: "hillrserv", + 4118: "netscript", + 4119: "assuria-slm", + 4121: "e-builder", + 4122: "fprams", + 4123: "z-wave", + 4124: "tigv2", + 4125: "opsview-envoy", + 4126: "ddrepl", + 4127: "unikeypro", + 4128: "nufw", + 4129: "nuauth", + 4130: "fronet", + 4131: "stars", + 4132: "nuts-dem", + 4133: "nuts-bootp", + 4134: "nifty-hmi", + 4135: "cl-db-attach", + 4136: "cl-db-request", + 4137: "cl-db-remote", + 4138: "nettest", + 4139: "thrtx", + 4140: "cedros-fds", + 4141: "oirtgsvc", + 4142: "oidocsvc", + 4143: "oidsr", + 4145: "vvr-control", + 4146: "tgcconnect", + 4147: "vrxpservman", + 4148: "hhb-handheld", + 4149: "agslb", + 4150: "PowerAlert-nsa", + 4151: "menandmice-noh", + 4152: "idig-mux", + 4153: "mbl-battd", + 4154: "atlinks", + 4155: "bzr", + 4156: "stat-results", + 4157: "stat-scanner", + 4158: "stat-cc", + 4159: "nss", + 4160: "jini-discovery", + 4161: "omscontact", + 4162: "omstopology", + 4163: "silverpeakpeer", + 4164: "silverpeakcomm", + 4165: "altcp", + 4166: "joost", + 4167: "ddgn", + 4168: "pslicser", + 4169: "iadt-disc", + 4172: "pcoip", + 4173: "mma-discovery", + 4174: "sm-disc", + 4177: "wello", + 4178: "storman", + 4179: "MaxumSP", + 4180: "httpx", + 4181: "macbak", + 4182: "pcptcpservice", + 4183: "cyborgnet", + 4184: "universe-suite", + 4185: "wcpp", + 4188: "vatata", + 4191: "dsmipv6", + 4192: "azeti-bd", + 4199: "eims-admin", + 4300: "corelccam", + 4301: "d-data", + 4302: "d-data-control", + 4303: "srcp", + 4304: "owserver", + 4305: "batman", + 4306: "pinghgl", + 4307: "visicron-vs", + 4308: "compx-lockview", + 4309: "dserver", + 4310: "mirrtex", + 4320: "fdt-rcatp", + 4321: "rwhois", + 4322: "trim-event", + 4323: "trim-ice", + 4325: "geognosisman", + 4326: "geognosis", + 4327: "jaxer-web", + 4328: "jaxer-manager", + 4333: "ahsp", + 4340: "gaia", + 4341: "lisp-data", + 4342: "lisp-control", + 4343: "unicall", + 4344: "vinainstall", + 4345: "m4-network-as", + 4346: "elanlm", + 4347: "lansurveyor", + 4348: "itose", + 4349: "fsportmap", + 4350: "net-device", + 4351: "plcy-net-svcs", + 4352: "pjlink", + 4353: "f5-iquery", + 4354: "qsnet-trans", + 4355: "qsnet-workst", + 4356: "qsnet-assist", + 4357: "qsnet-cond", + 4358: "qsnet-nucl", + 4359: "omabcastltkm", + 4361: "nacnl", + 4362: "afore-vdp-disc", + 4366: "shadowstream", + 4368: "wxbrief", + 4369: "epmd", + 4370: "elpro-tunnel", + 4371: "l2c-disc", + 4372: "l2c-data", + 4373: "remctl", + 4375: "tolteces", + 4376: "bip", + 4377: "cp-spxsvr", + 4378: "cp-spxdpy", + 4379: "ctdb", + 4389: "xandros-cms", + 4390: "wiegand", + 4394: "apwi-disc", + 4395: "omnivisionesx", + 4400: "ds-srv", + 4401: "ds-srvr", + 4402: "ds-clnt", + 4403: "ds-user", + 4404: "ds-admin", + 4405: "ds-mail", + 4406: "ds-slp", + 4412: "smallchat", + 4413: "avi-nms-disc", + 4416: "pjj-player-disc", + 4418: "axysbridge", + 4420: "nvm-express", + 4425: "netrockey6", + 4426: "beacon-port-2", + 4430: "rsqlserver", + 4432: "l-acoustics", + 4441: "netblox", + 4442: "saris", + 4443: "pharos", + 4444: "krb524", + 4445: "upnotifyp", + 4446: "n1-fwp", + 4447: "n1-rmgmt", + 4448: "asc-slmd", + 4449: "privatewire", + 4450: "camp", + 4451: "ctisystemmsg", + 4452: "ctiprogramload", + 4453: "nssalertmgr", + 4454: "nssagentmgr", + 4455: "prchat-user", + 4456: "prchat-server", + 4457: "prRegister", + 4458: "mcp", + 4484: "hpssmgmt", + 4486: "icms", + 4488: "awacs-ice", + 4500: "ipsec-nat-t", + 4534: "armagetronad", + 4535: "ehs", + 4536: "ehs-ssl", + 4537: "wssauthsvc", + 4538: "swx-gate", + 4545: "worldscores", + 4546: "sf-lm", + 4547: "lanner-lm", + 4548: "synchromesh", + 4549: "aegate", + 4550: "gds-adppiw-db", + 4551: "ieee-mih", + 4552: "menandmice-mon", + 4554: "msfrs", + 4555: "rsip", + 4556: "dtn-bundle", + 4557: "mtcevrunqss", + 4558: "mtcevrunqman", + 4559: "hylafax", + 4566: "kwtc", + 4567: "tram", + 4568: "bmc-reporting", + 4569: "iax", + 4591: "l3t-at-an", + 4592: "hrpd-ith-at-an", + 4593: "ipt-anri-anri", + 4594: "ias-session", + 4595: "ias-paging", + 4596: "ias-neighbor", + 4597: "a21-an-1xbs", + 4598: "a16-an-an", + 4599: "a17-an-an", + 4600: "piranha1", + 4601: "piranha2", + 4621: "ventoso", + 4658: "playsta2-app", + 4659: "playsta2-lob", + 4660: "smaclmgr", + 4661: "kar2ouche", + 4662: "oms", + 4663: "noteit", + 4664: "ems", + 4665: "contclientms", + 4666: "eportcomm", + 4667: "mmacomm", + 4668: "mmaeds", + 4669: "eportcommdata", + 4670: "light", + 4671: "acter", + 4672: "rfa", + 4673: "cxws", + 4674: "appiq-mgmt", + 4675: "dhct-status", + 4676: "dhct-alerts", + 4677: "bcs", + 4678: "traversal", + 4679: "mgesupervision", + 4680: "mgemanagement", + 4681: "parliant", + 4682: "finisar", + 4683: "spike", + 4684: "rfid-rp1", + 4685: "autopac", + 4686: "msp-os", + 4687: "nst", + 4688: "mobile-p2p", + 4689: "altovacentral", + 4690: "prelude", + 4691: "mtn", + 4692: "conspiracy", + 4700: "netxms-agent", + 4701: "netxms-mgmt", + 4702: "netxms-sync", + 4725: "truckstar", + 4726: "a26-fap-fgw", + 4727: "fcis-disc", + 4728: "capmux", + 4729: "gsmtap", + 4730: "gearman", + 4732: "ohmtrigger", + 4737: "ipdr-sp", + 4738: "solera-lpn", + 4739: "ipfix", + 4740: "ipfixs", + 4741: "lumimgrd", + 4742: "sicct-sdp", + 4743: "openhpid", + 4744: "ifsp", + 4745: "fmp", + 4746: "intelliadm-disc", + 4747: "buschtrommel", + 4749: "profilemac", + 4750: "ssad", + 4751: "spocp", + 4752: "snap", + 4753: "simon-disc", + 4754: "gre-in-udp", + 4755: "gre-udp-dtls", + 4784: "bfd-multi-ctl", + 4785: "cncp", + 4789: "vxlan", + 4790: "vxlan-gpe", + 4791: "roce", + 4800: "iims", + 4801: "iwec", + 4802: "ilss", + 4803: "notateit-disc", + 4804: "aja-ntv4-disc", + 4827: "htcp", + 4837: "varadero-0", + 4838: "varadero-1", + 4839: "varadero-2", + 4840: "opcua-udp", + 4841: "quosa", + 4842: "gw-asv", + 4843: "opcua-tls", + 4844: "gw-log", + 4845: "wcr-remlib", + 4846: "contamac-icm", + 4847: "wfc", + 4848: "appserv-http", + 4849: "appserv-https", + 4850: "sun-as-nodeagt", + 4851: "derby-repli", + 4867: "unify-debug", + 4868: "phrelay", + 4869: "phrelaydbg", + 4870: "cc-tracking", + 4871: "wired", + 4876: "tritium-can", + 4877: "lmcs", + 4878: "inst-discovery", + 4881: "socp-t", + 4882: "socp-c", + 4884: "hivestor", + 4885: "abbs", + 4894: "lyskom", + 4899: "radmin-port", + 4900: "hfcs", + 4914: "bones", + 4936: "an-signaling", + 4937: "atsc-mh-ssc", + 4940: "eq-office-4940", + 4941: "eq-office-4941", + 4942: "eq-office-4942", + 4949: "munin", + 4950: "sybasesrvmon", + 4951: "pwgwims", + 4952: "sagxtsds", + 4969: "ccss-qmm", + 4970: "ccss-qsm", + 4980: "ctxs-vpp", + 4986: "mrip", + 4987: "smar-se-port1", + 4988: "smar-se-port2", + 4989: "parallel", + 4990: "busycal", + 4991: "vrt", + 4999: "hfcs-manager", + 5000: "commplex-main", + 5001: "commplex-link", + 5002: "rfe", + 5003: "fmpro-internal", + 5004: "avt-profile-1", + 5005: "avt-profile-2", + 5006: "wsm-server", + 5007: "wsm-server-ssl", + 5008: "synapsis-edge", + 5009: "winfs", + 5010: "telelpathstart", + 5011: "telelpathattack", + 5012: "nsp", + 5013: "fmpro-v6", + 5014: "onpsocket", + 5020: "zenginkyo-1", + 5021: "zenginkyo-2", + 5022: "mice", + 5023: "htuilsrv", + 5024: "scpi-telnet", + 5025: "scpi-raw", + 5026: "strexec-d", + 5027: "strexec-s", + 5029: "infobright", + 5030: "surfpass", + 5031: "dmp", + 5042: "asnaacceler8db", + 5043: "swxadmin", + 5044: "lxi-evntsvc", + 5046: "vpm-udp", + 5047: "iscape", + 5049: "ivocalize", + 5050: "mmcc", + 5051: "ita-agent", + 5052: "ita-manager", + 5053: "rlm-disc", + 5055: "unot", + 5056: "intecom-ps1", + 5057: "intecom-ps2", + 5058: "locus-disc", + 5059: "sds", + 5060: "sip", + 5061: "sips", + 5062: "na-localise", + 5064: "ca-1", + 5065: "ca-2", + 5066: "stanag-5066", + 5067: "authentx", + 5069: "i-net-2000-npr", + 5070: "vtsas", + 5071: "powerschool", + 5072: "ayiya", + 5073: "tag-pm", + 5074: "alesquery", + 5078: "pixelpusher", + 5079: "cp-spxrpts", + 5080: "onscreen", + 5081: "sdl-ets", + 5082: "qcp", + 5083: "qfp", + 5084: "llrp", + 5085: "encrypted-llrp", + 5092: "magpie", + 5093: "sentinel-lm", + 5094: "hart-ip", + 5099: "sentlm-srv2srv", + 5100: "socalia", + 5101: "talarian-udp", + 5102: "oms-nonsecure", + 5104: "tinymessage", + 5105: "hughes-ap", + 5111: "taep-as-svc", + 5112: "pm-cmdsvr", + 5116: "emb-proj-cmd", + 5120: "barracuda-bbs", + 5133: "nbt-pc", + 5136: "minotaur-sa", + 5137: "ctsd", + 5145: "rmonitor-secure", + 5150: "atmp", + 5151: "esri-sde", + 5152: "sde-discovery", + 5154: "bzflag", + 5155: "asctrl-agent", + 5164: "vpa-disc", + 5165: "ife-icorp", + 5166: "winpcs", + 5167: "scte104", + 5168: "scte30", + 5190: "aol", + 5191: "aol-1", + 5192: "aol-2", + 5193: "aol-3", + 5200: "targus-getdata", + 5201: "targus-getdata1", + 5202: "targus-getdata2", + 5203: "targus-getdata3", + 5223: "hpvirtgrp", + 5224: "hpvirtctrl", + 5225: "hp-server", + 5226: "hp-status", + 5227: "perfd", + 5234: "eenet", + 5235: "galaxy-network", + 5236: "padl2sim", + 5237: "mnet-discovery", + 5245: "downtools-disc", + 5246: "capwap-control", + 5247: "capwap-data", + 5248: "caacws", + 5249: "caaclang2", + 5250: "soagateway", + 5251: "caevms", + 5252: "movaz-ssc", + 5264: "3com-njack-1", + 5265: "3com-njack-2", + 5270: "cartographerxmp", + 5271: "cuelink-disc", + 5272: "pk", + 5282: "transmit-port", + 5298: "presence", + 5299: "nlg-data", + 5300: "hacl-hb", + 5301: "hacl-gs", + 5302: "hacl-cfg", + 5303: "hacl-probe", + 5304: "hacl-local", + 5305: "hacl-test", + 5306: "sun-mc-grp", + 5307: "sco-aip", + 5308: "cfengine", + 5309: "jprinter", + 5310: "outlaws", + 5312: "permabit-cs", + 5313: "rrdp", + 5314: "opalis-rbt-ipc", + 5315: "hacl-poll", + 5343: "kfserver", + 5344: "xkotodrcp", + 5349: "stuns", + 5350: "pcp-multicast", + 5351: "pcp", + 5352: "dns-llq", + 5353: "mdns", + 5354: "mdnsresponder", + 5355: "llmnr", + 5356: "ms-smlbiz", + 5357: "wsdapi", + 5358: "wsdapi-s", + 5359: "ms-alerter", + 5360: "ms-sideshow", + 5361: "ms-s-sideshow", + 5362: "serverwsd2", + 5363: "net-projection", + 5364: "kdnet", + 5397: "stresstester", + 5398: "elektron-admin", + 5399: "securitychase", + 5400: "excerpt", + 5401: "excerpts", + 5402: "mftp", + 5403: "hpoms-ci-lstn", + 5404: "hpoms-dps-lstn", + 5405: "netsupport", + 5406: "systemics-sox", + 5407: "foresyte-clear", + 5408: "foresyte-sec", + 5409: "salient-dtasrv", + 5410: "salient-usrmgr", + 5411: "actnet", + 5412: "continuus", + 5413: "wwiotalk", + 5414: "statusd", + 5415: "ns-server", + 5416: "sns-gateway", + 5417: "sns-agent", + 5418: "mcntp", + 5419: "dj-ice", + 5420: "cylink-c", + 5421: "netsupport2", + 5422: "salient-mux", + 5423: "virtualuser", + 5424: "beyond-remote", + 5425: "br-channel", + 5426: "devbasic", + 5427: "sco-peer-tta", + 5428: "telaconsole", + 5429: "base", + 5430: "radec-corp", + 5431: "park-agent", + 5432: "postgresql", + 5433: "pyrrho", + 5434: "sgi-arrayd", + 5435: "sceanics", + 5436: "pmip6-cntl", + 5437: "pmip6-data", + 5443: "spss", + 5450: "tiepie-disc", + 5453: "surebox", + 5454: "apc-5454", + 5455: "apc-5455", + 5456: "apc-5456", + 5461: "silkmeter", + 5462: "ttl-publisher", + 5463: "ttlpriceproxy", + 5464: "quailnet", + 5465: "netops-broker", + 5474: "apsolab-rpc", + 5500: "fcp-addr-srvr1", + 5501: "fcp-addr-srvr2", + 5502: "fcp-srvr-inst1", + 5503: "fcp-srvr-inst2", + 5504: "fcp-cics-gw1", + 5505: "checkoutdb", + 5506: "amc", + 5553: "sgi-eventmond", + 5554: "sgi-esphttp", + 5555: "personal-agent", + 5556: "freeciv", + 5567: "dof-dps-mc-sec", + 5568: "sdt", + 5569: "rdmnet-device", + 5573: "sdmmp", + 5580: "tmosms0", + 5581: "tmosms1", + 5582: "fac-restore", + 5583: "tmo-icon-sync", + 5584: "bis-web", + 5585: "bis-sync", + 5597: "ininmessaging", + 5598: "mctfeed", + 5599: "esinstall", + 5600: "esmmanager", + 5601: "esmagent", + 5602: "a1-msc", + 5603: "a1-bs", + 5604: "a3-sdunode", + 5605: "a4-sdunode", + 5627: "ninaf", + 5628: "htrust", + 5629: "symantec-sfdb", + 5630: "precise-comm", + 5631: "pcanywheredata", + 5632: "pcanywherestat", + 5633: "beorl", + 5634: "xprtld", + 5670: "zre-disc", + 5671: "amqps", + 5672: "amqp", + 5673: "jms", + 5674: "hyperscsi-port", + 5675: "v5ua", + 5676: "raadmin", + 5677: "questdb2-lnchr", + 5678: "rrac", + 5679: "dccm", + 5680: "auriga-router", + 5681: "ncxcp", + 5682: "brightcore", + 5683: "coap", + 5684: "coaps", + 5687: "gog-multiplayer", + 5688: "ggz", + 5689: "qmvideo", + 5713: "proshareaudio", + 5714: "prosharevideo", + 5715: "prosharedata", + 5716: "prosharerequest", + 5717: "prosharenotify", + 5718: "dpm", + 5719: "dpm-agent", + 5720: "ms-licensing", + 5721: "dtpt", + 5722: "msdfsr", + 5723: "omhs", + 5724: "omsdk", + 5728: "io-dist-group", + 5729: "openmail", + 5730: "unieng", + 5741: "ida-discover1", + 5742: "ida-discover2", + 5743: "watchdoc-pod", + 5744: "watchdoc", + 5745: "fcopy-server", + 5746: "fcopys-server", + 5747: "tunatic", + 5748: "tunalyzer", + 5750: "rscd", + 5755: "openmailg", + 5757: "x500ms", + 5766: "openmailns", + 5767: "s-openmail", + 5768: "openmailpxy", + 5769: "spramsca", + 5770: "spramsd", + 5771: "netagent", + 5777: "dali-port", + 5781: "3par-evts", + 5782: "3par-mgmt", + 5783: "3par-mgmt-ssl", + 5784: "ibar", + 5785: "3par-rcopy", + 5786: "cisco-redu", + 5787: "waascluster", + 5793: "xtreamx", + 5794: "spdp", + 5813: "icmpd", + 5814: "spt-automation", + 5859: "wherehoo", + 5863: "ppsuitemsg", + 5900: "rfb", + 5910: "cm", + 5911: "cpdlc", + 5912: "fis", + 5913: "ads-c", + 5963: "indy", + 5968: "mppolicy-v5", + 5969: "mppolicy-mgr", + 5984: "couchdb", + 5985: "wsman", + 5986: "wsmans", + 5987: "wbem-rmi", + 5988: "wbem-http", + 5989: "wbem-https", + 5990: "wbem-exp-https", + 5991: "nuxsl", + 5992: "consul-insight", + 5999: "cvsup", + 6064: "ndl-ahp-svc", + 6065: "winpharaoh", + 6066: "ewctsp", + 6069: "trip", + 6070: "messageasap", + 6071: "ssdtp", + 6072: "diagnose-proc", + 6073: "directplay8", + 6074: "max", + 6080: "gue", + 6081: "geneve", + 6082: "p25cai", + 6083: "miami-bcast", + 6085: "konspire2b", + 6086: "pdtp", + 6087: "ldss", + 6088: "doglms-notify", + 6100: "synchronet-db", + 6101: "synchronet-rtc", + 6102: "synchronet-upd", + 6103: "rets", + 6104: "dbdb", + 6105: "primaserver", + 6106: "mpsserver", + 6107: "etc-control", + 6108: "sercomm-scadmin", + 6109: "globecast-id", + 6110: "softcm", + 6111: "spc", + 6112: "dtspcd", + 6118: "tipc", + 6122: "bex-webadmin", + 6123: "backup-express", + 6124: "pnbs", + 6133: "nbt-wol", + 6140: "pulsonixnls", + 6141: "meta-corp", + 6142: "aspentec-lm", + 6143: "watershed-lm", + 6144: "statsci1-lm", + 6145: "statsci2-lm", + 6146: "lonewolf-lm", + 6147: "montage-lm", + 6148: "ricardo-lm", + 6149: "tal-pod", + 6160: "ecmp-data", + 6161: "patrol-ism", + 6162: "patrol-coll", + 6163: "pscribe", + 6200: "lm-x", + 6201: "thermo-calc", + 6209: "qmtps", + 6222: "radmind", + 6241: "jeol-nsddp-1", + 6242: "jeol-nsddp-2", + 6243: "jeol-nsddp-3", + 6244: "jeol-nsddp-4", + 6251: "tl1-raw-ssl", + 6252: "tl1-ssh", + 6253: "crip", + 6268: "grid", + 6269: "grid-alt", + 6300: "bmc-grx", + 6301: "bmc-ctd-ldap", + 6306: "ufmp", + 6315: "scup-disc", + 6316: "abb-escp", + 6317: "nav-data", + 6320: "repsvc", + 6321: "emp-server1", + 6322: "emp-server2", + 6324: "hrd-ns-disc", + 6343: "sflow", + 6346: "gnutella-svc", + 6347: "gnutella-rtr", + 6350: "adap", + 6355: "pmcs", + 6360: "metaedit-mu", + 6363: "ndn", + 6370: "metaedit-se", + 6382: "metatude-mds", + 6389: "clariion-evr01", + 6390: "metaedit-ws", + 6417: "faxcomservice", + 6419: "svdrp-disc", + 6420: "nim-vdrshell", + 6421: "nim-wan", + 6443: "sun-sr-https", + 6444: "sge-qmaster", + 6445: "sge-execd", + 6446: "mysql-proxy", + 6455: "skip-cert-recv", + 6456: "skip-cert-send", + 6471: "lvision-lm", + 6480: "sun-sr-http", + 6481: "servicetags", + 6482: "ldoms-mgmt", + 6483: "SunVTS-RMI", + 6484: "sun-sr-jms", + 6485: "sun-sr-iiop", + 6486: "sun-sr-iiops", + 6487: "sun-sr-iiop-aut", + 6488: "sun-sr-jmx", + 6489: "sun-sr-admin", + 6500: "boks", + 6501: "boks-servc", + 6502: "boks-servm", + 6503: "boks-clntd", + 6505: "badm-priv", + 6506: "badm-pub", + 6507: "bdir-priv", + 6508: "bdir-pub", + 6509: "mgcs-mfp-port", + 6510: "mcer-port", + 6511: "dccp-udp", + 6514: "syslog-tls", + 6515: "elipse-rec", + 6543: "lds-distrib", + 6544: "lds-dump", + 6547: "apc-6547", + 6548: "apc-6548", + 6549: "apc-6549", + 6550: "fg-sysupdate", + 6551: "sum", + 6558: "xdsxdm", + 6566: "sane-port", + 6568: "rp-reputation", + 6579: "affiliate", + 6580: "parsec-master", + 6581: "parsec-peer", + 6582: "parsec-game", + 6583: "joaJewelSuite", + 6619: "odette-ftps", + 6620: "kftp-data", + 6621: "kftp", + 6622: "mcftp", + 6623: "ktelnet", + 6626: "wago-service", + 6627: "nexgen", + 6628: "afesc-mc", + 6629: "nexgen-aux", + 6633: "cisco-vpath-tun", + 6634: "mpls-pm", + 6635: "mpls-udp", + 6636: "mpls-udp-dtls", + 6653: "openflow", + 6657: "palcom-disc", + 6670: "vocaltec-gold", + 6671: "p4p-portal", + 6672: "vision-server", + 6673: "vision-elmd", + 6678: "vfbp-disc", + 6679: "osaut", + 6689: "tsa", + 6696: "babel", + 6701: "kti-icad-srvr", + 6702: "e-design-net", + 6703: "e-design-web", + 6714: "ibprotocol", + 6715: "fibotrader-com", + 6767: "bmc-perf-agent", + 6768: "bmc-perf-mgrd", + 6769: "adi-gxp-srvprt", + 6770: "plysrv-http", + 6771: "plysrv-https", + 6784: "bfd-lag", + 6785: "dgpf-exchg", + 6786: "smc-jmx", + 6787: "smc-admin", + 6788: "smc-http", + 6790: "hnmp", + 6791: "hnm", + 6801: "acnet", + 6831: "ambit-lm", + 6841: "netmo-default", + 6842: "netmo-http", + 6850: "iccrushmore", + 6868: "acctopus-st", + 6888: "muse", + 6935: "ethoscan", + 6936: "xsmsvc", + 6946: "bioserver", + 6951: "otlp", + 6961: "jmact3", + 6962: "jmevt2", + 6963: "swismgr1", + 6964: "swismgr2", + 6965: "swistrap", + 6966: "swispol", + 6969: "acmsoda", + 6997: "MobilitySrv", + 6998: "iatp-highpri", + 6999: "iatp-normalpri", + 7000: "afs3-fileserver", + 7001: "afs3-callback", + 7002: "afs3-prserver", + 7003: "afs3-vlserver", + 7004: "afs3-kaserver", + 7005: "afs3-volser", + 7006: "afs3-errors", + 7007: "afs3-bos", + 7008: "afs3-update", + 7009: "afs3-rmtsys", + 7010: "ups-onlinet", + 7011: "talon-disc", + 7012: "talon-engine", + 7013: "microtalon-dis", + 7014: "microtalon-com", + 7015: "talon-webserver", + 7019: "doceri-view", + 7020: "dpserve", + 7021: "dpserveadmin", + 7022: "ctdp", + 7023: "ct2nmcs", + 7024: "vmsvc", + 7025: "vmsvc-2", + 7030: "op-probe", + 7040: "quest-disc", + 7070: "arcp", + 7071: "iwg1", + 7080: "empowerid", + 7088: "zixi-transport", + 7095: "jdp-disc", + 7099: "lazy-ptop", + 7100: "font-service", + 7101: "elcn", + 7107: "aes-x170", + 7121: "virprot-lm", + 7128: "scenidm", + 7129: "scenccs", + 7161: "cabsm-comm", + 7162: "caistoragemgr", + 7163: "cacsambroker", + 7164: "fsr", + 7165: "doc-server", + 7166: "aruba-server", + 7169: "ccag-pib", + 7170: "nsrp", + 7171: "drm-production", + 7174: "clutild", + 7181: "janus-disc", + 7200: "fodms", + 7201: "dlip", + 7227: "ramp", + 7235: "aspcoordination", + 7244: "frc-hicp-disc", + 7262: "cnap", + 7272: "watchme-7272", + 7273: "oma-rlp", + 7274: "oma-rlp-s", + 7275: "oma-ulp", + 7276: "oma-ilp", + 7277: "oma-ilp-s", + 7278: "oma-dcdocbs", + 7279: "ctxlic", + 7280: "itactionserver1", + 7281: "itactionserver2", + 7282: "mzca-alert", + 7365: "lcm-server", + 7391: "mindfilesys", + 7392: "mrssrendezvous", + 7393: "nfoldman", + 7394: "fse", + 7395: "winqedit", + 7397: "hexarc", + 7400: "rtps-discovery", + 7401: "rtps-dd-ut", + 7402: "rtps-dd-mt", + 7410: "ionixnetmon", + 7411: "daqstream", + 7421: "mtportmon", + 7426: "pmdmgr", + 7427: "oveadmgr", + 7428: "ovladmgr", + 7429: "opi-sock", + 7430: "xmpv7", + 7431: "pmd", + 7437: "faximum", + 7443: "oracleas-https", + 7473: "rise", + 7491: "telops-lmd", + 7500: "silhouette", + 7501: "ovbus", + 7510: "ovhpas", + 7511: "pafec-lm", + 7542: "saratoga", + 7543: "atul", + 7544: "nta-ds", + 7545: "nta-us", + 7546: "cfs", + 7547: "cwmp", + 7548: "tidp", + 7549: "nls-tl", + 7550: "cloudsignaling", + 7560: "sncp", + 7566: "vsi-omega", + 7570: "aries-kfinder", + 7574: "coherence-disc", + 7588: "sun-lm", + 7606: "mipi-debug", + 7624: "indi", + 7627: "soap-http", + 7628: "zen-pawn", + 7629: "xdas", + 7633: "pmdfmgt", + 7648: "cuseeme", + 7674: "imqtunnels", + 7675: "imqtunnel", + 7676: "imqbrokerd", + 7677: "sun-user-https", + 7680: "pando-pub", + 7689: "collaber", + 7697: "klio", + 7707: "sync-em7", + 7708: "scinet", + 7720: "medimageportal", + 7724: "nsdeepfreezectl", + 7725: "nitrogen", + 7726: "freezexservice", + 7727: "trident-data", + 7728: "osvr", + 7734: "smip", + 7738: "aiagent", + 7741: "scriptview", + 7743: "sstp-1", + 7744: "raqmon-pdu", + 7747: "prgp", + 7777: "cbt", + 7778: "interwise", + 7779: "vstat", + 7781: "accu-lmgr", + 7784: "s-bfd", + 7786: "minivend", + 7787: "popup-reminders", + 7789: "office-tools", + 7794: "q3ade", + 7797: "pnet-conn", + 7798: "pnet-enc", + 7799: "altbsdp", + 7800: "asr", + 7801: "ssp-client", + 7802: "vns-tp", + 7810: "rbt-wanopt", + 7845: "apc-7845", + 7846: "apc-7846", + 7872: "mipv6tls", + 7880: "pss", + 7887: "ubroker", + 7900: "mevent", + 7901: "tnos-sp", + 7902: "tnos-dp", + 7903: "tnos-dps", + 7913: "qo-secure", + 7932: "t2-drm", + 7933: "t2-brm", + 7962: "generalsync", + 7967: "supercell", + 7979: "micromuse-ncps", + 7980: "quest-vista", + 7982: "sossd-disc", + 7998: "usicontentpush", + 7999: "irdmi2", + 8000: "irdmi", + 8001: "vcom-tunnel", + 8002: "teradataordbms", + 8003: "mcreport", + 8005: "mxi", + 8008: "http-alt", + 8019: "qbdb", + 8020: "intu-ec-svcdisc", + 8021: "intu-ec-client", + 8022: "oa-system", + 8025: "ca-audit-da", + 8026: "ca-audit-ds", + 8032: "pro-ed", + 8033: "mindprint", + 8034: "vantronix-mgmt", + 8040: "ampify", + 8052: "senomix01", + 8053: "senomix02", + 8054: "senomix03", + 8055: "senomix04", + 8056: "senomix05", + 8057: "senomix06", + 8058: "senomix07", + 8059: "senomix08", + 8060: "aero", + 8074: "gadugadu", + 8080: "http-alt", + 8081: "sunproxyadmin", + 8082: "us-cli", + 8083: "us-srv", + 8086: "d-s-n", + 8087: "simplifymedia", + 8088: "radan-http", + 8097: "sac", + 8100: "xprint-server", + 8115: "mtl8000-matrix", + 8116: "cp-cluster", + 8118: "privoxy", + 8121: "apollo-data", + 8122: "apollo-admin", + 8128: "paycash-online", + 8129: "paycash-wbp", + 8130: "indigo-vrmi", + 8131: "indigo-vbcp", + 8132: "dbabble", + 8148: "isdd", + 8149: "eor-game", + 8160: "patrol", + 8161: "patrol-snmp", + 8182: "vmware-fdm", + 8184: "itach", + 8192: "spytechphone", + 8194: "blp1", + 8195: "blp2", + 8199: "vvr-data", + 8200: "trivnet1", + 8201: "trivnet2", + 8202: "aesop", + 8204: "lm-perfworks", + 8205: "lm-instmgr", + 8206: "lm-dta", + 8207: "lm-sserver", + 8208: "lm-webwatcher", + 8230: "rexecj", + 8231: "hncp-udp-port", + 8232: "hncp-dtls-port", + 8243: "synapse-nhttps", + 8276: "pando-sec", + 8280: "synapse-nhttp", + 8282: "libelle-disc", + 8292: "blp3", + 8294: "blp4", + 8300: "tmi", + 8301: "amberon", + 8320: "tnp-discover", + 8321: "tnp", + 8322: "garmin-marine", + 8351: "server-find", + 8376: "cruise-enum", + 8377: "cruise-swroute", + 8378: "cruise-config", + 8379: "cruise-diags", + 8380: "cruise-update", + 8383: "m2mservices", + 8384: "marathontp", + 8400: "cvd", + 8401: "sabarsd", + 8402: "abarsd", + 8403: "admind", + 8416: "espeech", + 8417: "espeech-rtp", + 8442: "cybro-a-bus", + 8443: "pcsync-https", + 8444: "pcsync-http", + 8445: "copy-disc", + 8450: "npmp", + 8472: "otv", + 8473: "vp2p", + 8474: "noteshare", + 8500: "fmtp", + 8501: "cmtp-av", + 8503: "lsp-self-ping", + 8554: "rtsp-alt", + 8555: "d-fence", + 8567: "dof-tunnel", + 8600: "asterix", + 8609: "canon-cpp-disc", + 8610: "canon-mfnp", + 8611: "canon-bjnp1", + 8612: "canon-bjnp2", + 8613: "canon-bjnp3", + 8614: "canon-bjnp4", + 8675: "msi-cps-rm-disc", + 8686: "sun-as-jmxrmi", + 8732: "dtp-net", + 8733: "ibus", + 8763: "mc-appserver", + 8764: "openqueue", + 8765: "ultraseek-http", + 8766: "amcs", + 8770: "dpap", + 8786: "msgclnt", + 8787: "msgsrvr", + 8793: "acd-pm", + 8800: "sunwebadmin", + 8804: "truecm", + 8808: "ssports-bcast", + 8873: "dxspider", + 8880: "cddbp-alt", + 8883: "secure-mqtt", + 8888: "ddi-udp-1", + 8889: "ddi-udp-2", + 8890: "ddi-udp-3", + 8891: "ddi-udp-4", + 8892: "ddi-udp-5", + 8893: "ddi-udp-6", + 8894: "ddi-udp-7", + 8899: "ospf-lite", + 8900: "jmb-cds1", + 8901: "jmb-cds2", + 8910: "manyone-http", + 8911: "manyone-xml", + 8912: "wcbackup", + 8913: "dragonfly", + 8954: "cumulus-admin", + 8980: "nod-provider", + 8981: "nod-client", + 8989: "sunwebadmins", + 8990: "http-wmap", + 8991: "https-wmap", + 8999: "bctp", + 9000: "cslistener", + 9001: "etlservicemgr", + 9002: "dynamid", + 9007: "ogs-client", + 9009: "pichat", + 9020: "tambora", + 9021: "panagolin-ident", + 9022: "paragent", + 9023: "swa-1", + 9024: "swa-2", + 9025: "swa-3", + 9026: "swa-4", + 9060: "CardWeb-RT", + 9080: "glrpc", + 9084: "aurora", + 9085: "ibm-rsyscon", + 9086: "net2display", + 9087: "classic", + 9088: "sqlexec", + 9089: "sqlexec-ssl", + 9090: "websm", + 9091: "xmltec-xmlmail", + 9092: "XmlIpcRegSvc", + 9100: "hp-pdl-datastr", + 9101: "bacula-dir", + 9102: "bacula-fd", + 9103: "bacula-sd", + 9104: "peerwire", + 9105: "xadmin", + 9106: "astergate-disc", + 9119: "mxit", + 9131: "dddp", + 9160: "apani1", + 9161: "apani2", + 9162: "apani3", + 9163: "apani4", + 9164: "apani5", + 9191: "sun-as-jpda", + 9200: "wap-wsp", + 9201: "wap-wsp-wtp", + 9202: "wap-wsp-s", + 9203: "wap-wsp-wtp-s", + 9204: "wap-vcard", + 9205: "wap-vcal", + 9206: "wap-vcard-s", + 9207: "wap-vcal-s", + 9208: "rjcdb-vcards", + 9209: "almobile-system", + 9210: "oma-mlp", + 9211: "oma-mlp-s", + 9212: "serverviewdbms", + 9213: "serverstart", + 9214: "ipdcesgbs", + 9215: "insis", + 9216: "acme", + 9217: "fsc-port", + 9222: "teamcoherence", + 9255: "mon", + 9277: "traingpsdata", + 9278: "pegasus", + 9279: "pegasus-ctl", + 9280: "pgps", + 9281: "swtp-port1", + 9282: "swtp-port2", + 9283: "callwaveiam", + 9284: "visd", + 9285: "n2h2server", + 9286: "n2receive", + 9287: "cumulus", + 9292: "armtechdaemon", + 9293: "storview", + 9294: "armcenterhttp", + 9295: "armcenterhttps", + 9300: "vrace", + 9318: "secure-ts", + 9321: "guibase", + 9343: "mpidcmgr", + 9344: "mphlpdmc", + 9346: "ctechlicensing", + 9374: "fjdmimgr", + 9380: "boxp", + 9396: "fjinvmgr", + 9397: "mpidcagt", + 9400: "sec-t4net-srv", + 9401: "sec-t4net-clt", + 9402: "sec-pc2fax-srv", + 9418: "git", + 9443: "tungsten-https", + 9444: "wso2esb-console", + 9450: "sntlkeyssrvr", + 9500: "ismserver", + 9522: "sma-spw", + 9535: "mngsuite", + 9536: "laes-bf", + 9555: "trispen-sra", + 9592: "ldgateway", + 9593: "cba8", + 9594: "msgsys", + 9595: "pds", + 9596: "mercury-disc", + 9597: "pd-admin", + 9598: "vscp", + 9599: "robix", + 9600: "micromuse-ncpw", + 9612: "streamcomm-ds", + 9618: "condor", + 9628: "odbcpathway", + 9629: "uniport", + 9632: "mc-comm", + 9667: "xmms2", + 9668: "tec5-sdctp", + 9694: "client-wakeup", + 9695: "ccnx", + 9700: "board-roar", + 9747: "l5nas-parchan", + 9750: "board-voip", + 9753: "rasadv", + 9762: "tungsten-http", + 9800: "davsrc", + 9801: "sstp-2", + 9802: "davsrcs", + 9875: "sapv1", + 9878: "kca-service", + 9888: "cyborg-systems", + 9889: "gt-proxy", + 9898: "monkeycom", + 9899: "sctp-tunneling", + 9900: "iua", + 9901: "enrp", + 9903: "multicast-ping", + 9909: "domaintime", + 9911: "sype-transport", + 9950: "apc-9950", + 9951: "apc-9951", + 9952: "apc-9952", + 9953: "acis", + 9955: "alljoyn-mcm", + 9956: "alljoyn", + 9966: "odnsp", + 9987: "dsm-scm-target", + 9990: "osm-appsrvr", + 9991: "osm-oev", + 9992: "palace-1", + 9993: "palace-2", + 9994: "palace-3", + 9995: "palace-4", + 9996: "palace-5", + 9997: "palace-6", + 9998: "distinct32", + 9999: "distinct", + 10000: "ndmp", + 10001: "scp-config", + 10002: "documentum", + 10003: "documentum-s", + 10007: "mvs-capacity", + 10008: "octopus", + 10009: "swdtp-sv", + 10050: "zabbix-agent", + 10051: "zabbix-trapper", + 10080: "amanda", + 10081: "famdc", + 10100: "itap-ddtp", + 10101: "ezmeeting-2", + 10102: "ezproxy-2", + 10103: "ezrelay", + 10104: "swdtp", + 10107: "bctp-server", + 10110: "nmea-0183", + 10111: "nmea-onenet", + 10113: "netiq-endpoint", + 10114: "netiq-qcheck", + 10115: "netiq-endpt", + 10116: "netiq-voipa", + 10117: "iqrm", + 10128: "bmc-perf-sd", + 10160: "qb-db-server", + 10161: "snmpdtls", + 10162: "snmpdtls-trap", + 10200: "trisoap", + 10201: "rscs", + 10252: "apollo-relay", + 10253: "eapol-relay", + 10260: "axis-wimp-port", + 10288: "blocks", + 10439: "bngsync", + 10500: "hip-nat-t", + 10540: "MOS-lower", + 10541: "MOS-upper", + 10542: "MOS-aux", + 10543: "MOS-soap", + 10544: "MOS-soap-opt", + 10800: "gap", + 10805: "lpdg", + 10810: "nmc-disc", + 10860: "helix", + 10880: "bveapi", + 10990: "rmiaux", + 11000: "irisa", + 11001: "metasys", + 10023: "cefd-vmp", + 11095: "weave", + 11106: "sgi-lk", + 11108: "myq-termlink", + 11111: "vce", + 11112: "dicom", + 11161: "suncacao-snmp", + 11162: "suncacao-jmxmp", + 11163: "suncacao-rmi", + 11164: "suncacao-csa", + 11165: "suncacao-websvc", + 11171: "snss", + 11201: "smsqp", + 11208: "wifree", + 11211: "memcache", + 11319: "imip", + 11320: "imip-channels", + 11321: "arena-server", + 11367: "atm-uhas", + 11371: "hkp", + 11430: "lsdp", + 11600: "tempest-port", + 11720: "h323callsigalt", + 11723: "emc-xsw-dcache", + 11751: "intrepid-ssl", + 11796: "lanschool-mpt", + 11876: "xoraya", + 11877: "x2e-disc", + 11967: "sysinfo-sp", + 12000: "entextxid", + 12001: "entextnetwk", + 12002: "entexthigh", + 12003: "entextmed", + 12004: "entextlow", + 12005: "dbisamserver1", + 12006: "dbisamserver2", + 12007: "accuracer", + 12008: "accuracer-dbms", + 12009: "ghvpn", + 12012: "vipera", + 12013: "vipera-ssl", + 12109: "rets-ssl", + 12121: "nupaper-ss", + 12168: "cawas", + 12172: "hivep", + 12300: "linogridengine", + 12321: "warehouse-sss", + 12322: "warehouse", + 12345: "italk", + 12753: "tsaf", + 13160: "i-zipqd", + 13216: "bcslogc", + 13217: "rs-pias", + 13218: "emc-vcas-udp", + 13223: "powwow-client", + 13224: "powwow-server", + 13400: "doip-disc", + 13720: "bprd", + 13721: "bpdbm", + 13722: "bpjava-msvc", + 13724: "vnetd", + 13782: "bpcd", + 13783: "vopied", + 13785: "nbdb", + 13786: "nomdb", + 13818: "dsmcc-config", + 13819: "dsmcc-session", + 13820: "dsmcc-passthru", + 13821: "dsmcc-download", + 13822: "dsmcc-ccp", + 13894: "ucontrol", + 13929: "dta-systems", + 14000: "scotty-ft", + 14001: "sua", + 14002: "scotty-disc", + 14033: "sage-best-com1", + 14034: "sage-best-com2", + 14141: "vcs-app", + 14142: "icpp", + 14145: "gcm-app", + 14149: "vrts-tdd", + 14154: "vad", + 14250: "cps", + 14414: "ca-web-update", + 14936: "hde-lcesrvr-1", + 14937: "hde-lcesrvr-2", + 15000: "hydap", + 15118: "v2g-secc", + 15345: "xpilot", + 15363: "3link", + 15555: "cisco-snat", + 15660: "bex-xr", + 15740: "ptp", + 15998: "2ping", + 16003: "alfin", + 16161: "sun-sea-port", + 16309: "etb4j", + 16310: "pduncs", + 16311: "pdefmns", + 16360: "netserialext1", + 16361: "netserialext2", + 16367: "netserialext3", + 16368: "netserialext4", + 16384: "connected", + 16666: "vtp", + 16900: "newbay-snc-mc", + 16950: "sgcip", + 16991: "intel-rci-mp", + 16992: "amt-soap-http", + 16993: "amt-soap-https", + 16994: "amt-redir-tcp", + 16995: "amt-redir-tls", + 17007: "isode-dua", + 17185: "soundsvirtual", + 17219: "chipper", + 17220: "avtp", + 17221: "avdecc", + 17222: "cpsp", + 17224: "trdp-pd", + 17225: "trdp-md", + 17234: "integrius-stp", + 17235: "ssh-mgmt", + 17500: "db-lsp-disc", + 17729: "ea", + 17754: "zep", + 17755: "zigbee-ip", + 17756: "zigbee-ips", + 18000: "biimenu", + 18181: "opsec-cvp", + 18182: "opsec-ufp", + 18183: "opsec-sam", + 18184: "opsec-lea", + 18185: "opsec-omi", + 18186: "ohsc", + 18187: "opsec-ela", + 18241: "checkpoint-rtm", + 18262: "gv-pf", + 18463: "ac-cluster", + 18634: "rds-ib", + 18635: "rds-ip", + 18668: "vdmmesh-disc", + 18769: "ique", + 18881: "infotos", + 18888: "apc-necmp", + 19000: "igrid", + 19007: "scintilla", + 19191: "opsec-uaa", + 19194: "ua-secureagent", + 19220: "cora-disc", + 19283: "keysrvr", + 19315: "keyshadow", + 19398: "mtrgtrans", + 19410: "hp-sco", + 19411: "hp-sca", + 19412: "hp-sessmon", + 19539: "fxuptp", + 19540: "sxuptp", + 19541: "jcp", + 19788: "mle", + 19999: "dnp-sec", + 20000: "dnp", + 20001: "microsan", + 20002: "commtact-http", + 20003: "commtact-https", + 20005: "openwebnet", + 20012: "ss-idi-disc", + 20014: "opendeploy", + 20034: "nburn-id", + 20046: "tmophl7mts", + 20048: "mountd", + 20049: "nfsrdma", + 20167: "tolfab", + 20202: "ipdtp-port", + 20222: "ipulse-ics", + 20480: "emwavemsg", + 20670: "track", + 20999: "athand-mmp", + 21000: "irtrans", + 21554: "dfserver", + 21590: "vofr-gateway", + 21800: "tvpm", + 21845: "webphone", + 21846: "netspeak-is", + 21847: "netspeak-cs", + 21848: "netspeak-acd", + 21849: "netspeak-cps", + 22000: "snapenetio", + 22001: "optocontrol", + 22002: "optohost002", + 22003: "optohost003", + 22004: "optohost004", + 22005: "optohost004", + 22273: "wnn6", + 22305: "cis", + 22335: "shrewd-stream", + 22343: "cis-secure", + 22347: "wibukey", + 22350: "codemeter", + 22555: "vocaltec-phone", + 22763: "talikaserver", + 22800: "aws-brf", + 22951: "brf-gw", + 23000: "inovaport1", + 23001: "inovaport2", + 23002: "inovaport3", + 23003: "inovaport4", + 23004: "inovaport5", + 23005: "inovaport6", + 23272: "s102", + 23294: "5afe-disc", + 23333: "elxmgmt", + 23400: "novar-dbase", + 23401: "novar-alarm", + 23402: "novar-global", + 24000: "med-ltp", + 24001: "med-fsp-rx", + 24002: "med-fsp-tx", + 24003: "med-supp", + 24004: "med-ovw", + 24005: "med-ci", + 24006: "med-net-svc", + 24242: "filesphere", + 24249: "vista-4gl", + 24321: "ild", + 24322: "hid", + 24386: "intel-rci", + 24465: "tonidods", + 24554: "binkp", + 24577: "bilobit-update", + 24676: "canditv", + 24677: "flashfiler", + 24678: "proactivate", + 24680: "tcc-http", + 24850: "assoc-disc", + 24922: "find", + 25000: "icl-twobase1", + 25001: "icl-twobase2", + 25002: "icl-twobase3", + 25003: "icl-twobase4", + 25004: "icl-twobase5", + 25005: "icl-twobase6", + 25006: "icl-twobase7", + 25007: "icl-twobase8", + 25008: "icl-twobase9", + 25009: "icl-twobase10", + 25793: "vocaltec-hos", + 25900: "tasp-net", + 25901: "niobserver", + 25902: "nilinkanalyst", + 25903: "niprobe", + 25954: "bf-game", + 25955: "bf-master", + 26000: "quake", + 26133: "scscp", + 26208: "wnn6-ds", + 26260: "ezproxy", + 26261: "ezmeeting", + 26262: "k3software-svr", + 26263: "k3software-cli", + 26486: "exoline-udp", + 26487: "exoconfig", + 26489: "exonet", + 27345: "imagepump", + 27442: "jesmsjc", + 27504: "kopek-httphead", + 27782: "ars-vista", + 27999: "tw-auth-key", + 28000: "nxlmd", + 28119: "a27-ran-ran", + 28200: "voxelstorm", + 28240: "siemensgsm", + 29167: "otmp", + 30001: "pago-services1", + 30002: "pago-services2", + 30003: "amicon-fpsu-ra", + 30004: "amicon-fpsu-s", + 30260: "kingdomsonline", + 30832: "samsung-disc", + 30999: "ovobs", + 31016: "ka-kdp", + 31029: "yawn", + 31416: "xqosd", + 31457: "tetrinet", + 31620: "lm-mon", + 31765: "gamesmith-port", + 31948: "iceedcp-tx", + 31949: "iceedcp-rx", + 32034: "iracinghelper", + 32249: "t1distproc60", + 32483: "apm-link", + 32635: "sec-ntb-clnt", + 32636: "DMExpress", + 32767: "filenet-powsrm", + 32768: "filenet-tms", + 32769: "filenet-rpc", + 32770: "filenet-nch", + 32771: "filenet-rmi", + 32772: "filenet-pa", + 32773: "filenet-cm", + 32774: "filenet-re", + 32775: "filenet-pch", + 32776: "filenet-peior", + 32777: "filenet-obrok", + 32801: "mlsn", + 32896: "idmgratm", + 33123: "aurora-balaena", + 33331: "diamondport", + 33334: "speedtrace-disc", + 33434: "traceroute", + 33656: "snip-slave", + 34249: "turbonote-2", + 34378: "p-net-local", + 34379: "p-net-remote", + 34567: "edi_service", + 34962: "profinet-rt", + 34963: "profinet-rtm", + 34964: "profinet-cm", + 34980: "ethercat", + 35001: "rt-viewer", + 35004: "rt-classmanager", + 35100: "axio-disc", + 35355: "altova-lm-disc", + 36001: "allpeers", + 36411: "wlcp", + 36865: "kastenxpipe", + 37475: "neckar", + 37654: "unisys-eportal", + 38002: "crescoctrl-disc", + 38201: "galaxy7-data", + 38202: "fairview", + 38203: "agpolicy", + 39681: "turbonote-1", + 40000: "safetynetp", + 40023: "k-patentssensor", + 40841: "cscp", + 40842: "csccredir", + 40843: "csccfirewall", + 40853: "ortec-disc", + 41111: "fs-qos", + 41230: "z-wave-s", + 41794: "crestron-cip", + 41795: "crestron-ctp", + 42508: "candp", + 42509: "candrp", + 42510: "caerpc", + 43000: "recvr-rc-disc", + 43188: "reachout", + 43189: "ndm-agent-port", + 43190: "ip-provision", + 43210: "shaperai-disc", + 43439: "eq3-config", + 43440: "ew-disc-cmd", + 43441: "ciscocsdb", + 44321: "pmcd", + 44322: "pmcdproxy", + 44544: "domiq", + 44553: "rbr-debug", + 44600: "asihpi", + 44818: "EtherNet-IP-2", + 44900: "m3da-disc", + 45000: "asmp-mon", + 45054: "invision-ag", + 45514: "cloudcheck-ping", + 45678: "eba", + 45825: "qdb2service", + 45966: "ssr-servermgr", + 46999: "mediabox", + 47000: "mbus", + 47100: "jvl-mactalk", + 47557: "dbbrowse", + 47624: "directplaysrvr", + 47806: "ap", + 47808: "bacnet", + 47809: "presonus-ucnet", + 48000: "nimcontroller", + 48001: "nimspooler", + 48002: "nimhub", + 48003: "nimgtw", + 48128: "isnetserv", + 48129: "blp5", + 48556: "com-bardac-dw", + 48619: "iqobject", + 48653: "robotraconteur", +} +var sctpPortNames = map[SCTPPort]string{ + 9: "discard", + 20: "ftp-data", + 21: "ftp", + 22: "ssh", + 80: "http", + 179: "bgp", + 443: "https", + 1021: "exp1", + 1022: "exp2", + 1167: "cisco-ipsla", + 1720: "h323hostcall", + 2049: "nfs", + 2225: "rcip-itu", + 2904: "m2ua", + 2905: "m3ua", + 2944: "megaco-h248", + 2945: "h248-binary", + 3097: "itu-bicc-stc", + 3565: "m2pa", + 3863: "asap-sctp", + 3864: "asap-sctp-tls", + 3868: "diameter", + 4333: "ahsp", + 4502: "a25-fap-fgw", + 4739: "ipfix", + 4740: "ipfixs", + 5060: "sip", + 5061: "sips", + 5090: "car", + 5091: "cxtp", + 5215: "noteza", + 5445: "smbdirect", + 5672: "amqp", + 5675: "v5ua", + 5868: "diameters", + 5910: "cm", + 5911: "cpdlc", + 5912: "fis", + 5913: "ads-c", + 6704: "frc-hp", + 6705: "frc-mp", + 6706: "frc-lp", + 6970: "conductor-mpx", + 7626: "simco", + 7728: "osvr", + 8471: "pim-port", + 9082: "lcs-ap", + 9084: "aurora", + 9900: "iua", + 9901: "enrp-sctp", + 9902: "enrp-sctp-tls", + 11997: "wmereceiving", + 11998: "wmedistribution", + 11999: "wmereporting", + 14001: "sua", + 20049: "nfsrdma", + 25471: "rna", + 29118: "sgsap", + 29168: "sbcap", + 29169: "iuhsctpassoc", + 30100: "rwp", + 36412: "s1-control", + 36422: "x2-control", + 36423: "slmap", + 36424: "nq-ap", + 36443: "m2ap", + 36444: "m3ap", + 36462: "xw-control", +} diff --git a/vendor/github.com/google/gopacket/layers/icmp4.go b/vendor/github.com/google/gopacket/layers/icmp4.go new file mode 100644 index 0000000..bd3f03f --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/icmp4.go @@ -0,0 +1,267 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "fmt" + "reflect" + + "github.com/google/gopacket" +) + +const ( + ICMPv4TypeEchoReply = 0 + ICMPv4TypeDestinationUnreachable = 3 + ICMPv4TypeSourceQuench = 4 + ICMPv4TypeRedirect = 5 + ICMPv4TypeEchoRequest = 8 + ICMPv4TypeRouterAdvertisement = 9 + ICMPv4TypeRouterSolicitation = 10 + ICMPv4TypeTimeExceeded = 11 + ICMPv4TypeParameterProblem = 12 + ICMPv4TypeTimestampRequest = 13 + ICMPv4TypeTimestampReply = 14 + ICMPv4TypeInfoRequest = 15 + ICMPv4TypeInfoReply = 16 + ICMPv4TypeAddressMaskRequest = 17 + ICMPv4TypeAddressMaskReply = 18 +) + +const ( + // DestinationUnreachable + ICMPv4CodeNet = 0 + ICMPv4CodeHost = 1 + ICMPv4CodeProtocol = 2 + ICMPv4CodePort = 3 + ICMPv4CodeFragmentationNeeded = 4 + ICMPv4CodeSourceRoutingFailed = 5 + ICMPv4CodeNetUnknown = 6 + ICMPv4CodeHostUnknown = 7 + ICMPv4CodeSourceIsolated = 8 + ICMPv4CodeNetAdminProhibited = 9 + ICMPv4CodeHostAdminProhibited = 10 + ICMPv4CodeNetTOS = 11 + ICMPv4CodeHostTOS = 12 + ICMPv4CodeCommAdminProhibited = 13 + ICMPv4CodeHostPrecedence = 14 + ICMPv4CodePrecedenceCutoff = 15 + + // TimeExceeded + ICMPv4CodeTTLExceeded = 0 + ICMPv4CodeFragmentReassemblyTimeExceeded = 1 + + // ParameterProblem + ICMPv4CodePointerIndicatesError = 0 + ICMPv4CodeMissingOption = 1 + ICMPv4CodeBadLength = 2 + + // Redirect + // ICMPv4CodeNet = same as for DestinationUnreachable + // ICMPv4CodeHost = same as for DestinationUnreachable + ICMPv4CodeTOSNet = 2 + ICMPv4CodeTOSHost = 3 +) + +type icmpv4TypeCodeInfoStruct struct { + typeStr string + codeStr *map[uint8]string +} + +var ( + icmpv4TypeCodeInfo = map[uint8]icmpv4TypeCodeInfoStruct{ + ICMPv4TypeDestinationUnreachable: icmpv4TypeCodeInfoStruct{ + "DestinationUnreachable", &map[uint8]string{ + ICMPv4CodeNet: "Net", + ICMPv4CodeHost: "Host", + ICMPv4CodeProtocol: "Protocol", + ICMPv4CodePort: "Port", + ICMPv4CodeFragmentationNeeded: "FragmentationNeeded", + ICMPv4CodeSourceRoutingFailed: "SourceRoutingFailed", + ICMPv4CodeNetUnknown: "NetUnknown", + ICMPv4CodeHostUnknown: "HostUnknown", + ICMPv4CodeSourceIsolated: "SourceIsolated", + ICMPv4CodeNetAdminProhibited: "NetAdminProhibited", + ICMPv4CodeHostAdminProhibited: "HostAdminProhibited", + ICMPv4CodeNetTOS: "NetTOS", + ICMPv4CodeHostTOS: "HostTOS", + ICMPv4CodeCommAdminProhibited: "CommAdminProhibited", + ICMPv4CodeHostPrecedence: "HostPrecedence", + ICMPv4CodePrecedenceCutoff: "PrecedenceCutoff", + }, + }, + ICMPv4TypeTimeExceeded: icmpv4TypeCodeInfoStruct{ + "TimeExceeded", &map[uint8]string{ + ICMPv4CodeTTLExceeded: "TTLExceeded", + ICMPv4CodeFragmentReassemblyTimeExceeded: "FragmentReassemblyTimeExceeded", + }, + }, + ICMPv4TypeParameterProblem: icmpv4TypeCodeInfoStruct{ + "ParameterProblem", &map[uint8]string{ + ICMPv4CodePointerIndicatesError: "PointerIndicatesError", + ICMPv4CodeMissingOption: "MissingOption", + ICMPv4CodeBadLength: "BadLength", + }, + }, + ICMPv4TypeSourceQuench: icmpv4TypeCodeInfoStruct{ + "SourceQuench", nil, + }, + ICMPv4TypeRedirect: icmpv4TypeCodeInfoStruct{ + "Redirect", &map[uint8]string{ + ICMPv4CodeNet: "Net", + ICMPv4CodeHost: "Host", + ICMPv4CodeTOSNet: "TOS+Net", + ICMPv4CodeTOSHost: "TOS+Host", + }, + }, + ICMPv4TypeEchoRequest: icmpv4TypeCodeInfoStruct{ + "EchoRequest", nil, + }, + ICMPv4TypeEchoReply: icmpv4TypeCodeInfoStruct{ + "EchoReply", nil, + }, + ICMPv4TypeTimestampRequest: icmpv4TypeCodeInfoStruct{ + "TimestampRequest", nil, + }, + ICMPv4TypeTimestampReply: icmpv4TypeCodeInfoStruct{ + "TimestampReply", nil, + }, + ICMPv4TypeInfoRequest: icmpv4TypeCodeInfoStruct{ + "InfoRequest", nil, + }, + ICMPv4TypeInfoReply: icmpv4TypeCodeInfoStruct{ + "InfoReply", nil, + }, + ICMPv4TypeRouterSolicitation: icmpv4TypeCodeInfoStruct{ + "RouterSolicitation", nil, + }, + ICMPv4TypeRouterAdvertisement: icmpv4TypeCodeInfoStruct{ + "RouterAdvertisement", nil, + }, + ICMPv4TypeAddressMaskRequest: icmpv4TypeCodeInfoStruct{ + "AddressMaskRequest", nil, + }, + ICMPv4TypeAddressMaskReply: icmpv4TypeCodeInfoStruct{ + "AddressMaskReply", nil, + }, + } +) + +type ICMPv4TypeCode uint16 + +// Type returns the ICMPv4 type field. +func (a ICMPv4TypeCode) Type() uint8 { + return uint8(a >> 8) +} + +// Code returns the ICMPv4 code field. +func (a ICMPv4TypeCode) Code() uint8 { + return uint8(a) +} + +func (a ICMPv4TypeCode) String() string { + t, c := a.Type(), a.Code() + strInfo, ok := icmpv4TypeCodeInfo[t] + if !ok { + // Unknown ICMPv4 type field + return fmt.Sprintf("%d(%d)", t, c) + } + typeStr := strInfo.typeStr + if strInfo.codeStr == nil && c == 0 { + // The ICMPv4 type does not make use of the code field + return fmt.Sprintf("%s", strInfo.typeStr) + } + if strInfo.codeStr == nil && c != 0 { + // The ICMPv4 type does not make use of the code field, but it is present anyway + return fmt.Sprintf("%s(Code: %d)", typeStr, c) + } + codeStr, ok := (*strInfo.codeStr)[c] + if !ok { + // We don't know this ICMPv4 code; print the numerical value + return fmt.Sprintf("%s(Code: %d)", typeStr, c) + } + return fmt.Sprintf("%s(%s)", typeStr, codeStr) +} + +func (a ICMPv4TypeCode) GoString() string { + t := reflect.TypeOf(a) + return fmt.Sprintf("%s(%d, %d)", t.String(), a.Type(), a.Code()) +} + +// SerializeTo writes the ICMPv4TypeCode value to the 'bytes' buffer. +func (a ICMPv4TypeCode) SerializeTo(bytes []byte) { + binary.BigEndian.PutUint16(bytes, uint16(a)) +} + +// CreateICMPv4TypeCode is a convenience function to create an ICMPv4TypeCode +// gopacket type from the ICMPv4 type and code values. +func CreateICMPv4TypeCode(typ uint8, code uint8) ICMPv4TypeCode { + return ICMPv4TypeCode(binary.BigEndian.Uint16([]byte{typ, code})) +} + +// ICMPv4 is the layer for IPv4 ICMP packet data. +type ICMPv4 struct { + BaseLayer + TypeCode ICMPv4TypeCode + Checksum uint16 + Id uint16 + Seq uint16 +} + +// LayerType returns LayerTypeICMPv4. +func (i *ICMPv4) LayerType() gopacket.LayerType { return LayerTypeICMPv4 } + +// DecodeFromBytes decodes the given bytes into this layer. +func (i *ICMPv4) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 8 { + df.SetTruncated() + return errors.New("ICMP layer less then 8 bytes for ICMPv4 packet") + } + i.TypeCode = CreateICMPv4TypeCode(data[0], data[1]) + i.Checksum = binary.BigEndian.Uint16(data[2:4]) + i.Id = binary.BigEndian.Uint16(data[4:6]) + i.Seq = binary.BigEndian.Uint16(data[6:8]) + i.BaseLayer = BaseLayer{data[:8], data[8:]} + return nil +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (i *ICMPv4) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + bytes, err := b.PrependBytes(8) + if err != nil { + return err + } + i.TypeCode.SerializeTo(bytes) + binary.BigEndian.PutUint16(bytes[4:], i.Id) + binary.BigEndian.PutUint16(bytes[6:], i.Seq) + if opts.ComputeChecksums { + bytes[2] = 0 + bytes[3] = 0 + i.Checksum = tcpipChecksum(b.Bytes(), 0) + } + binary.BigEndian.PutUint16(bytes[2:], i.Checksum) + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (i *ICMPv4) CanDecode() gopacket.LayerClass { + return LayerTypeICMPv4 +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (i *ICMPv4) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +func decodeICMPv4(data []byte, p gopacket.PacketBuilder) error { + i := &ICMPv4{} + return decodingLayerDecoder(i, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/icmp6.go b/vendor/github.com/google/gopacket/layers/icmp6.go new file mode 100644 index 0000000..03a3213 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/icmp6.go @@ -0,0 +1,231 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "fmt" + "reflect" + + "github.com/google/gopacket" +) + +const ( + // The following are from RFC 4443 + ICMPv6TypeDestinationUnreachable = 1 + ICMPv6TypePacketTooBig = 2 + ICMPv6TypeTimeExceeded = 3 + ICMPv6TypeParameterProblem = 4 + ICMPv6TypeEchoRequest = 128 + ICMPv6TypeEchoReply = 129 + // The following are from RFC 4861 + ICMPv6TypeRouterSolicitation = 133 + ICMPv6TypeRouterAdvertisement = 134 + ICMPv6TypeNeighborSolicitation = 135 + ICMPv6TypeNeighborAdvertisement = 136 + ICMPv6TypeRedirect = 137 +) + +const ( + // DestinationUnreachable + ICMPv6CodeNoRouteToDst = 0 + ICMPv6CodeAdminProhibited = 1 + ICMPv6CodeBeyondScopeOfSrc = 2 + ICMPv6CodeAddressUnreachable = 3 + ICMPv6CodePortUnreachable = 4 + ICMPv6CodeSrcAddressFailedPolicy = 5 + ICMPv6CodeRejectRouteToDst = 6 + + // TimeExceeded + ICMPv6CodeHopLimitExceeded = 0 + ICMPv6CodeFragmentReassemblyTimeExceeded = 1 + + // ParameterProblem + ICMPv6CodeErroneousHeaderField = 0 + ICMPv6CodeUnrecognizedNextHeader = 1 + ICMPv6CodeUnrecognizedIPv6Option = 2 +) + +type icmpv6TypeCodeInfoStruct struct { + typeStr string + codeStr *map[uint8]string +} + +var ( + icmpv6TypeCodeInfo = map[uint8]icmpv6TypeCodeInfoStruct{ + ICMPv6TypeDestinationUnreachable: icmpv6TypeCodeInfoStruct{ + "DestinationUnreachable", &map[uint8]string{ + ICMPv6CodeNoRouteToDst: "NoRouteToDst", + ICMPv6CodeAdminProhibited: "AdminProhibited", + ICMPv6CodeBeyondScopeOfSrc: "BeyondScopeOfSrc", + ICMPv6CodeAddressUnreachable: "AddressUnreachable", + ICMPv6CodePortUnreachable: "PortUnreachable", + ICMPv6CodeSrcAddressFailedPolicy: "SrcAddressFailedPolicy", + ICMPv6CodeRejectRouteToDst: "RejectRouteToDst", + }, + }, + ICMPv6TypePacketTooBig: icmpv6TypeCodeInfoStruct{ + "PacketTooBig", nil, + }, + ICMPv6TypeTimeExceeded: icmpv6TypeCodeInfoStruct{ + "TimeExceeded", &map[uint8]string{ + ICMPv6CodeHopLimitExceeded: "HopLimitExceeded", + ICMPv6CodeFragmentReassemblyTimeExceeded: "FragmentReassemblyTimeExceeded", + }, + }, + ICMPv6TypeParameterProblem: icmpv6TypeCodeInfoStruct{ + "ParameterProblem", &map[uint8]string{ + ICMPv6CodeErroneousHeaderField: "ErroneousHeaderField", + ICMPv6CodeUnrecognizedNextHeader: "UnrecognizedNextHeader", + ICMPv6CodeUnrecognizedIPv6Option: "UnrecognizedIPv6Option", + }, + }, + ICMPv6TypeEchoRequest: icmpv6TypeCodeInfoStruct{ + "EchoRequest", nil, + }, + ICMPv6TypeEchoReply: icmpv6TypeCodeInfoStruct{ + "EchoReply", nil, + }, + ICMPv6TypeRouterSolicitation: icmpv6TypeCodeInfoStruct{ + "RouterSolicitation", nil, + }, + ICMPv6TypeRouterAdvertisement: icmpv6TypeCodeInfoStruct{ + "RouterAdvertisement", nil, + }, + ICMPv6TypeNeighborSolicitation: icmpv6TypeCodeInfoStruct{ + "NeighborSolicitation", nil, + }, + ICMPv6TypeNeighborAdvertisement: icmpv6TypeCodeInfoStruct{ + "NeighborAdvertisement", nil, + }, + ICMPv6TypeRedirect: icmpv6TypeCodeInfoStruct{ + "Redirect", nil, + }, + } +) + +type ICMPv6TypeCode uint16 + +// Type returns the ICMPv6 type field. +func (a ICMPv6TypeCode) Type() uint8 { + return uint8(a >> 8) +} + +// Code returns the ICMPv6 code field. +func (a ICMPv6TypeCode) Code() uint8 { + return uint8(a) +} + +func (a ICMPv6TypeCode) String() string { + t, c := a.Type(), a.Code() + strInfo, ok := icmpv6TypeCodeInfo[t] + if !ok { + // Unknown ICMPv6 type field + return fmt.Sprintf("%d(%d)", t, c) + } + typeStr := strInfo.typeStr + if strInfo.codeStr == nil && c == 0 { + // The ICMPv6 type does not make use of the code field + return fmt.Sprintf("%s", strInfo.typeStr) + } + if strInfo.codeStr == nil && c != 0 { + // The ICMPv6 type does not make use of the code field, but it is present anyway + return fmt.Sprintf("%s(Code: %d)", typeStr, c) + } + codeStr, ok := (*strInfo.codeStr)[c] + if !ok { + // We don't know this ICMPv6 code; print the numerical value + return fmt.Sprintf("%s(Code: %d)", typeStr, c) + } + return fmt.Sprintf("%s(%s)", typeStr, codeStr) +} + +func (a ICMPv6TypeCode) GoString() string { + t := reflect.TypeOf(a) + return fmt.Sprintf("%s(%d, %d)", t.String(), a.Type(), a.Code()) +} + +// SerializeTo writes the ICMPv6TypeCode value to the 'bytes' buffer. +func (a ICMPv6TypeCode) SerializeTo(bytes []byte) { + binary.BigEndian.PutUint16(bytes, uint16(a)) +} + +// CreateICMPv6TypeCode is a convenience function to create an ICMPv6TypeCode +// gopacket type from the ICMPv6 type and code values. +func CreateICMPv6TypeCode(typ uint8, code uint8) ICMPv6TypeCode { + return ICMPv6TypeCode(binary.BigEndian.Uint16([]byte{typ, code})) +} + +// ICMPv6 is the layer for IPv6 ICMP packet data +type ICMPv6 struct { + BaseLayer + TypeCode ICMPv6TypeCode + Checksum uint16 + TypeBytes []byte + tcpipchecksum +} + +// LayerType returns LayerTypeICMPv6. +func (i *ICMPv6) LayerType() gopacket.LayerType { return LayerTypeICMPv6 } + +// DecodeFromBytes decodes the given bytes into this layer. +func (i *ICMPv6) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 8 { + df.SetTruncated() + return errors.New("ICMP layer less then 8 bytes for ICMPv6 packet") + } + i.TypeCode = CreateICMPv6TypeCode(data[0], data[1]) + i.Checksum = binary.BigEndian.Uint16(data[2:4]) + i.TypeBytes = data[4:8] + i.BaseLayer = BaseLayer{data[:8], data[8:]} + return nil +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (i *ICMPv6) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + if i.TypeBytes == nil { + i.TypeBytes = lotsOfZeros[:4] + } else if len(i.TypeBytes) != 4 { + return fmt.Errorf("invalid type bytes for ICMPv6 packet: %v", i.TypeBytes) + } + bytes, err := b.PrependBytes(8) + if err != nil { + return err + } + i.TypeCode.SerializeTo(bytes) + copy(bytes[4:8], i.TypeBytes) + if opts.ComputeChecksums { + bytes[2] = 0 + bytes[3] = 0 + csum, err := i.computeChecksum(b.Bytes(), IPProtocolICMPv6) + if err != nil { + return err + } + i.Checksum = csum + } + binary.BigEndian.PutUint16(bytes[2:], i.Checksum) + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (i *ICMPv6) CanDecode() gopacket.LayerClass { + return LayerTypeICMPv6 +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (i *ICMPv6) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +func decodeICMPv6(data []byte, p gopacket.PacketBuilder) error { + i := &ICMPv6{} + return decodingLayerDecoder(i, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/igmp.go b/vendor/github.com/google/gopacket/layers/igmp.go new file mode 100644 index 0000000..d008415 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/igmp.go @@ -0,0 +1,355 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "net" + "time" + + "github.com/google/gopacket" +) + +type IGMPType uint8 + +const ( + IGMPMembershipQuery IGMPType = 0x11 // General or group specific query + IGMPMembershipReportV1 IGMPType = 0x12 // Version 1 Membership Report + IGMPMembershipReportV2 IGMPType = 0x16 // Version 2 Membership Report + IGMPLeaveGroup IGMPType = 0x17 // Leave Group + IGMPMembershipReportV3 IGMPType = 0x22 // Version 3 Membership Report +) + +// String conversions for IGMP message types +func (i IGMPType) String() string { + switch i { + case IGMPMembershipQuery: + return "IGMP Membership Query" + case IGMPMembershipReportV1: + return "IGMPv1 Membership Report" + case IGMPMembershipReportV2: + return "IGMPv2 Membership Report" + case IGMPMembershipReportV3: + return "IGMPv3 Membership Report" + case IGMPLeaveGroup: + return "Leave Group" + default: + return "" + } +} + +type IGMPv3GroupRecordType uint8 + +const ( + IGMPIsIn IGMPv3GroupRecordType = 0x01 // Type MODE_IS_INCLUDE, source addresses x + IGMPIsEx IGMPv3GroupRecordType = 0x02 // Type MODE_IS_EXCLUDE, source addresses x + IGMPToIn IGMPv3GroupRecordType = 0x03 // Type CHANGE_TO_INCLUDE_MODE, source addresses x + IGMPToEx IGMPv3GroupRecordType = 0x04 // Type CHANGE_TO_EXCLUDE_MODE, source addresses x + IGMPAllow IGMPv3GroupRecordType = 0x05 // Type ALLOW_NEW_SOURCES, source addresses x + IGMPBlock IGMPv3GroupRecordType = 0x06 // Type BLOCK_OLD_SOURCES, source addresses x +) + +func (i IGMPv3GroupRecordType) String() string { + switch i { + case IGMPIsIn: + return "MODE_IS_INCLUDE" + case IGMPIsEx: + return "MODE_IS_EXCLUDE" + case IGMPToIn: + return "CHANGE_TO_INCLUDE_MODE" + case IGMPToEx: + return "CHANGE_TO_EXCLUDE_MODE" + case IGMPAllow: + return "ALLOW_NEW_SOURCES" + case IGMPBlock: + return "BLOCK_OLD_SOURCES" + default: + return "" + } +} + +// IGMP represents an IGMPv3 message. +type IGMP struct { + BaseLayer + Type IGMPType + MaxResponseTime time.Duration + Checksum uint16 + GroupAddress net.IP + SupressRouterProcessing bool + RobustnessValue uint8 + IntervalTime time.Duration + SourceAddresses []net.IP + NumberOfGroupRecords uint16 + NumberOfSources uint16 + GroupRecords []IGMPv3GroupRecord + Version uint8 // IGMP protocol version +} + +// IGMPv1or2 stores header details for an IGMPv1 or IGMPv2 packet. +// +// 0 1 2 3 +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Type | Max Resp Time | Checksum | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Group Address | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +type IGMPv1or2 struct { + BaseLayer + Type IGMPType // IGMP message type + MaxResponseTime time.Duration // meaningful only in Membership Query messages + Checksum uint16 // 16-bit checksum of entire ip payload + GroupAddress net.IP // either 0 or an IP multicast address + Version uint8 +} + +// decodeResponse dissects IGMPv1 or IGMPv2 packet. +func (i *IGMPv1or2) decodeResponse(data []byte) error { + if len(data) < 8 { + return errors.New("IGMP packet too small") + } + + i.MaxResponseTime = igmpTimeDecode(data[1]) + i.Checksum = binary.BigEndian.Uint16(data[2:4]) + i.GroupAddress = net.IP(data[4:8]) + + return nil +} + +// 0 1 2 3 +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Type = 0x22 | Reserved | Checksum | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Reserved | Number of Group Records (M) | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// . Group Record [1] . +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// . Group Record [2] . +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// . Group Record [M] . +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Record Type | Aux Data Len | Number of Sources (N) | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Multicast Address | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Source Address [1] | +// +- -+ +// | Source Address [2] | +// +- -+ +// | Source Address [N] | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// . Auxiliary Data . +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +// IGMPv3GroupRecord stores individual group records for a V3 Membership Report message. +type IGMPv3GroupRecord struct { + Type IGMPv3GroupRecordType + AuxDataLen uint8 // this should always be 0 as per IGMPv3 spec. + NumberOfSources uint16 + MulticastAddress net.IP + SourceAddresses []net.IP + AuxData uint32 // NOT USED +} + +func (i *IGMP) decodeIGMPv3MembershipReport(data []byte) error { + if len(data) < 8 { + return errors.New("IGMPv3 Membership Report too small #1") + } + + i.Checksum = binary.BigEndian.Uint16(data[2:4]) + i.NumberOfGroupRecords = binary.BigEndian.Uint16(data[6:8]) + + recordOffset := 8 + for j := 0; j < int(i.NumberOfGroupRecords); j++ { + if len(data) < recordOffset+8 { + return errors.New("IGMPv3 Membership Report too small #2") + } + + var gr IGMPv3GroupRecord + gr.Type = IGMPv3GroupRecordType(data[recordOffset]) + gr.AuxDataLen = data[recordOffset+1] + gr.NumberOfSources = binary.BigEndian.Uint16(data[recordOffset+2 : recordOffset+4]) + gr.MulticastAddress = net.IP(data[recordOffset+4 : recordOffset+8]) + + if len(data) < recordOffset+8+int(gr.NumberOfSources)*4 { + return errors.New("IGMPv3 Membership Report too small #3") + } + + // append source address records. + for i := 0; i < int(gr.NumberOfSources); i++ { + sourceAddr := net.IP(data[recordOffset+8+i*4 : recordOffset+12+i*4]) + gr.SourceAddresses = append(gr.SourceAddresses, sourceAddr) + } + + i.GroupRecords = append(i.GroupRecords, gr) + recordOffset += 8 + 4*int(gr.NumberOfSources) + } + return nil +} + +// 0 1 2 3 +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Type = 0x11 | Max Resp Code | Checksum | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Group Address | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Resv |S| QRV | QQIC | Number of Sources (N) | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Source Address [1] | +// +- -+ +// | Source Address [2] | +// +- . -+ +// | Source Address [N] | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// +// decodeIGMPv3MembershipQuery parses the IGMPv3 message of type 0x11 +func (i *IGMP) decodeIGMPv3MembershipQuery(data []byte) error { + if len(data) < 12 { + return errors.New("IGMPv3 Membership Query too small #1") + } + + i.MaxResponseTime = igmpTimeDecode(data[1]) + i.Checksum = binary.BigEndian.Uint16(data[2:4]) + i.SupressRouterProcessing = data[8]&0x8 != 0 + i.GroupAddress = net.IP(data[4:8]) + i.RobustnessValue = data[8] & 0x7 + i.IntervalTime = igmpTimeDecode(data[9]) + i.NumberOfSources = binary.BigEndian.Uint16(data[10:12]) + + if len(data) < 12+int(i.NumberOfSources)*4 { + return errors.New("IGMPv3 Membership Query too small #2") + } + + for j := 0; j < int(i.NumberOfSources); j++ { + i.SourceAddresses = append(i.SourceAddresses, net.IP(data[12+j*4:16+j*4])) + } + + return nil +} + +// igmpTimeDecode decodes the duration created by the given byte, using the +// algorithm in http://www.rfc-base.org/txt/rfc-3376.txt section 4.1.1. +func igmpTimeDecode(t uint8) time.Duration { + if t&0x80 == 0 { + return time.Millisecond * 100 * time.Duration(t) + } + mant := (t & 0x70) >> 4 + exp := t & 0x0F + return time.Millisecond * 100 * time.Duration((mant|0x10)<<(exp+3)) +} + +// LayerType returns LayerTypeIGMP for the V1,2,3 message protocol formats. +func (i *IGMP) LayerType() gopacket.LayerType { return LayerTypeIGMP } +func (i *IGMPv1or2) LayerType() gopacket.LayerType { return LayerTypeIGMP } + +func (i *IGMPv1or2) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 8 { + return errors.New("IGMP Packet too small") + } + + i.Type = IGMPType(data[0]) + i.MaxResponseTime = igmpTimeDecode(data[1]) + i.Checksum = binary.BigEndian.Uint16(data[2:4]) + i.GroupAddress = net.IP(data[4:8]) + + return nil +} + +func (i *IGMPv1or2) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypeZero +} + +func (i *IGMPv1or2) CanDecode() gopacket.LayerClass { + return LayerTypeIGMP +} + +// DecodeFromBytes decodes the given bytes into this layer. +func (i *IGMP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 1 { + return errors.New("IGMP packet is too small") + } + + // common IGMP header values between versions 1..3 of IGMP specification.. + i.Type = IGMPType(data[0]) + + switch i.Type { + case IGMPMembershipQuery: + i.decodeIGMPv3MembershipQuery(data) + case IGMPMembershipReportV3: + i.decodeIGMPv3MembershipReport(data) + default: + return errors.New("unsupported IGMP type") + } + + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (i *IGMP) CanDecode() gopacket.LayerClass { + return LayerTypeIGMP +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (i *IGMP) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypeZero +} + +// decodeIGMP will parse IGMP v1,2 or 3 protocols. Checks against the +// IGMP type are performed against byte[0], logic then iniitalizes and +// passes the appropriate struct (IGMP or IGMPv1or2) to +// decodingLayerDecoder. +func decodeIGMP(data []byte, p gopacket.PacketBuilder) error { + if len(data) < 1 { + return errors.New("IGMP packet is too small") + } + + // byte 0 contains IGMP message type. + switch IGMPType(data[0]) { + case IGMPMembershipQuery: + // IGMPv3 Membership Query payload is >= 12 + if len(data) >= 12 { + i := &IGMP{Version: 3} + return decodingLayerDecoder(i, data, p) + } else if len(data) == 8 { + i := &IGMPv1or2{} + if data[1] == 0x00 { + i.Version = 1 // IGMPv1 has a query length of 8 and MaxResp = 0 + } else { + i.Version = 2 // IGMPv2 has a query length of 8 and MaxResp != 0 + } + + return decodingLayerDecoder(i, data, p) + } + case IGMPMembershipReportV3: + i := &IGMP{Version: 3} + return decodingLayerDecoder(i, data, p) + case IGMPMembershipReportV1: + i := &IGMPv1or2{Version: 1} + return decodingLayerDecoder(i, data, p) + case IGMPLeaveGroup, IGMPMembershipReportV2: + // leave group and Query Report v2 used in IGMPv2 only. + i := &IGMPv1or2{Version: 2} + return decodingLayerDecoder(i, data, p) + default: + } + + return errors.New("Unable to determine IGMP type.") +} diff --git a/vendor/github.com/google/gopacket/layers/ip4.go b/vendor/github.com/google/gopacket/layers/ip4.go new file mode 100644 index 0000000..3f31b27 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/ip4.go @@ -0,0 +1,311 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "fmt" + "net" + "strings" + + "github.com/google/gopacket" +) + +type IPv4Flag uint8 + +const ( + IPv4EvilBit IPv4Flag = 1 << 2 // http://tools.ietf.org/html/rfc3514 ;) + IPv4DontFragment IPv4Flag = 1 << 1 + IPv4MoreFragments IPv4Flag = 1 << 0 +) + +func (f IPv4Flag) String() string { + var s []string + if f&IPv4EvilBit != 0 { + s = append(s, "Evil") + } + if f&IPv4DontFragment != 0 { + s = append(s, "DF") + } + if f&IPv4MoreFragments != 0 { + s = append(s, "MF") + } + return strings.Join(s, "|") +} + +// IPv4 is the header of an IP packet. +type IPv4 struct { + BaseLayer + Version uint8 + IHL uint8 + TOS uint8 + Length uint16 + Id uint16 + Flags IPv4Flag + FragOffset uint16 + TTL uint8 + Protocol IPProtocol + Checksum uint16 + SrcIP net.IP + DstIP net.IP + Options []IPv4Option + Padding []byte +} + +// LayerType returns LayerTypeIPv4 +func (i *IPv4) LayerType() gopacket.LayerType { return LayerTypeIPv4 } +func (i *IPv4) NetworkFlow() gopacket.Flow { + return gopacket.NewFlow(EndpointIPv4, i.SrcIP, i.DstIP) +} + +type IPv4Option struct { + OptionType uint8 + OptionLength uint8 + OptionData []byte +} + +func (i IPv4Option) String() string { + return fmt.Sprintf("IPv4Option(%v:%v)", i.OptionType, i.OptionData) +} + +// for the current ipv4 options, return the number of bytes (including +// padding that the options used) +func (ip *IPv4) getIPv4OptionSize() uint8 { + optionSize := uint8(0) + for _, opt := range ip.Options { + switch opt.OptionType { + case 0: + // this is the end of option lists + optionSize++ + case 1: + // this is the padding + optionSize++ + default: + optionSize += opt.OptionLength + + } + } + // make sure the options are aligned to 32 bit boundary + if (optionSize % 4) != 0 { + optionSize += 4 - (optionSize % 4) + } + return optionSize +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +func (ip *IPv4) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + optionLength := ip.getIPv4OptionSize() + bytes, err := b.PrependBytes(20 + int(optionLength)) + if err != nil { + return err + } + if opts.FixLengths { + ip.IHL = 5 + (optionLength / 4) + ip.Length = uint16(len(b.Bytes())) + } + bytes[0] = (ip.Version << 4) | ip.IHL + bytes[1] = ip.TOS + binary.BigEndian.PutUint16(bytes[2:], ip.Length) + binary.BigEndian.PutUint16(bytes[4:], ip.Id) + binary.BigEndian.PutUint16(bytes[6:], ip.flagsfrags()) + bytes[8] = ip.TTL + bytes[9] = byte(ip.Protocol) + if err := ip.AddressTo4(); err != nil { + return err + } + copy(bytes[12:16], ip.SrcIP) + copy(bytes[16:20], ip.DstIP) + + curLocation := 20 + // Now, we will encode the options + for _, opt := range ip.Options { + switch opt.OptionType { + case 0: + // this is the end of option lists + bytes[curLocation] = 0 + curLocation++ + case 1: + // this is the padding + bytes[curLocation] = 1 + curLocation++ + default: + bytes[curLocation] = opt.OptionType + bytes[curLocation+1] = opt.OptionLength + + // sanity checking to protect us from buffer overrun + if len(opt.OptionData) > int(opt.OptionLength-2) { + return errors.New("option length is smaller than length of option data") + } + copy(bytes[curLocation+2:curLocation+int(opt.OptionLength)], opt.OptionData) + curLocation += int(opt.OptionLength) + } + } + + if opts.ComputeChecksums { + ip.Checksum = checksum(bytes) + } + binary.BigEndian.PutUint16(bytes[10:], ip.Checksum) + return nil +} + +func checksum(bytes []byte) uint16 { + // Clear checksum bytes + bytes[10] = 0 + bytes[11] = 0 + + // Compute checksum + var csum uint32 + for i := 0; i < len(bytes); i += 2 { + csum += uint32(bytes[i]) << 8 + csum += uint32(bytes[i+1]) + } + for { + // Break when sum is less or equals to 0xFFFF + if csum <= 65535 { + break + } + // Add carry to the sum + csum = (csum >> 16) + uint32(uint16(csum)) + } + // Flip all the bits + return ^uint16(csum) +} + +func (ip *IPv4) flagsfrags() (ff uint16) { + ff |= uint16(ip.Flags) << 13 + ff |= ip.FragOffset + return +} + +// DecodeFromBytes decodes the given bytes into this layer. +func (ip *IPv4) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + flagsfrags := binary.BigEndian.Uint16(data[6:8]) + + ip.Version = uint8(data[0]) >> 4 + ip.IHL = uint8(data[0]) & 0x0F + ip.TOS = data[1] + ip.Length = binary.BigEndian.Uint16(data[2:4]) + ip.Id = binary.BigEndian.Uint16(data[4:6]) + ip.Flags = IPv4Flag(flagsfrags >> 13) + ip.FragOffset = flagsfrags & 0x1FFF + ip.TTL = data[8] + ip.Protocol = IPProtocol(data[9]) + ip.Checksum = binary.BigEndian.Uint16(data[10:12]) + ip.SrcIP = data[12:16] + ip.DstIP = data[16:20] + ip.Options = ip.Options[:0] + // Set up an initial guess for contents/payload... we'll reset these soon. + ip.BaseLayer = BaseLayer{Contents: data} + + // This code is added for the following enviroment: + // * Windows 10 with TSO option activated. ( tested on Hyper-V, RealTek ethernet driver ) + if ip.Length == 0 { + // If using TSO(TCP Segmentation Offload), length is zero. + // The actual packet length is the length of data. + ip.Length = uint16(len(data)) + } + + if ip.Length < 20 { + return fmt.Errorf("Invalid (too small) IP length (%d < 20)", ip.Length) + } else if ip.IHL < 5 { + return fmt.Errorf("Invalid (too small) IP header length (%d < 5)", ip.IHL) + } else if int(ip.IHL*4) > int(ip.Length) { + return fmt.Errorf("Invalid IP header length > IP length (%d > %d)", ip.IHL, ip.Length) + } + if cmp := len(data) - int(ip.Length); cmp > 0 { + data = data[:ip.Length] + } else if cmp < 0 { + df.SetTruncated() + if int(ip.IHL)*4 > len(data) { + return errors.New("Not all IP header bytes available") + } + } + ip.Contents = data[:ip.IHL*4] + ip.Payload = data[ip.IHL*4:] + // From here on, data contains the header options. + data = data[20 : ip.IHL*4] + // Pull out IP options + for len(data) > 0 { + if ip.Options == nil { + // Pre-allocate to avoid growing the slice too much. + ip.Options = make([]IPv4Option, 0, 4) + } + opt := IPv4Option{OptionType: data[0]} + switch opt.OptionType { + case 0: // End of options + opt.OptionLength = 1 + ip.Options = append(ip.Options, opt) + ip.Padding = data[1:] + break + case 1: // 1 byte padding + opt.OptionLength = 1 + default: + opt.OptionLength = data[1] + opt.OptionData = data[2:opt.OptionLength] + } + if len(data) >= int(opt.OptionLength) { + data = data[opt.OptionLength:] + } else { + return fmt.Errorf("IP option length exceeds remaining IP header size, option type %v length %v", opt.OptionType, opt.OptionLength) + } + ip.Options = append(ip.Options, opt) + } + return nil +} + +func (i *IPv4) CanDecode() gopacket.LayerClass { + return LayerTypeIPv4 +} + +func (i *IPv4) NextLayerType() gopacket.LayerType { + if i.Flags&IPv4MoreFragments != 0 || i.FragOffset != 0 { + return gopacket.LayerTypeFragment + } + return i.Protocol.LayerType() +} + +func decodeIPv4(data []byte, p gopacket.PacketBuilder) error { + ip := &IPv4{} + err := ip.DecodeFromBytes(data, p) + p.AddLayer(ip) + p.SetNetworkLayer(ip) + if err != nil { + return err + } + return p.NextDecoder(ip.NextLayerType()) +} + +func checkIPv4Address(addr net.IP) (net.IP, error) { + if c := addr.To4(); c != nil { + return c, nil + } + if len(addr) == net.IPv6len { + return nil, errors.New("address is IPv6") + } + return nil, fmt.Errorf("wrong length of %d bytes instead of %d", len(addr), net.IPv4len) +} + +func (ip *IPv4) AddressTo4() error { + var src, dst net.IP + + if addr, err := checkIPv4Address(ip.SrcIP); err != nil { + return fmt.Errorf("Invalid source IPv4 address (%s)", err) + } else { + src = addr + } + if addr, err := checkIPv4Address(ip.DstIP); err != nil { + return fmt.Errorf("Invalid destination IPv4 address (%s)", err) + } else { + dst = addr + } + ip.SrcIP = src + ip.DstIP = dst + return nil +} diff --git a/vendor/github.com/google/gopacket/layers/ip6.go b/vendor/github.com/google/gopacket/layers/ip6.go new file mode 100644 index 0000000..b5befe9 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/ip6.go @@ -0,0 +1,650 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "fmt" + "net" + + "github.com/google/gopacket" +) + +const ( + IPv6HopByHopOptionJumbogram = 0xC2 // RFC 2675 +) + +const ( + ipv6MaxPayloadLength = 65535 +) + +// IPv6 is the layer for the IPv6 header. +type IPv6 struct { + // http://www.networksorcery.com/enp/protocol/ipv6.htm + BaseLayer + Version uint8 + TrafficClass uint8 + FlowLabel uint32 + Length uint16 + NextHeader IPProtocol + HopLimit uint8 + SrcIP net.IP + DstIP net.IP + HopByHop *IPv6HopByHop + // hbh will be pointed to by HopByHop if that layer exists. + hbh IPv6HopByHop +} + +// LayerType returns LayerTypeIPv6 +func (i *IPv6) LayerType() gopacket.LayerType { return LayerTypeIPv6 } + +func (i *IPv6) NetworkFlow() gopacket.Flow { + return gopacket.NewFlow(EndpointIPv6, i.SrcIP, i.DstIP) +} + +// Search for Jumbo Payload TLV in IPv6HopByHop and return (length, true) if found +func getIPv6HopByHopJumboLength(hopopts *IPv6HopByHop) (uint32, bool, error) { + var tlv *IPv6HopByHopOption + + for _, t := range hopopts.Options { + if t.OptionType == IPv6HopByHopOptionJumbogram { + tlv = t + break + } + } + if tlv == nil { + // Not found + return 0, false, nil + } + if len(tlv.OptionData) != 4 { + return 0, false, errors.New("Jumbo length TLV data must have length 4") + } + l := binary.BigEndian.Uint32(tlv.OptionData) + if l <= ipv6MaxPayloadLength { + return 0, false, fmt.Errorf("Jumbo length cannot be less than %d", ipv6MaxPayloadLength+1) + } + // Found + return l, true, nil +} + +// Adds zero-valued Jumbo TLV to IPv6 header if it does not exist +// (if necessary add hop-by-hop header) +func addIPv6JumboOption(ip6 *IPv6) { + var tlv *IPv6HopByHopOption + + if ip6.HopByHop == nil { + // Add IPv6 HopByHop + ip6.HopByHop = &IPv6HopByHop{} + ip6.HopByHop.NextHeader = ip6.NextHeader + ip6.HopByHop.HeaderLength = 0 + ip6.NextHeader = IPProtocolIPv6HopByHop + } + for _, t := range ip6.HopByHop.Options { + if t.OptionType == IPv6HopByHopOptionJumbogram { + tlv = t + break + } + } + if tlv == nil { + // Add Jumbo TLV + tlv = &IPv6HopByHopOption{} + ip6.HopByHop.Options = append(ip6.HopByHop.Options, tlv) + } + tlv.SetJumboLength(0) +} + +// Set jumbo length in serialized IPv6 payload (starting with HopByHop header) +func setIPv6PayloadJumboLength(hbh []byte) error { + pLen := len(hbh) + if pLen < 8 { + //HopByHop is minimum 8 bytes + return fmt.Errorf("Invalid IPv6 payload (length %d)", pLen) + } + hbhLen := int((hbh[1] + 1) * 8) + if hbhLen > pLen { + return fmt.Errorf("Invalid hop-by-hop length (length: %d, payload: %d", hbhLen, pLen) + } + offset := 2 //start with options + for offset < hbhLen { + opt := hbh[offset] + if opt == 0 { + //Pad1 + offset += 1 + continue + } + optLen := int(hbh[offset+1]) + if opt == IPv6HopByHopOptionJumbogram { + if optLen == 4 { + binary.BigEndian.PutUint32(hbh[offset+2:], uint32(pLen)) + return nil + } + return fmt.Errorf("Jumbo TLV too short (%d bytes)", optLen) + } + offset += 2 + optLen + } + return errors.New("Jumbo TLV not found") +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (ip6 *IPv6) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + var jumbo bool + var err error + + payload := b.Bytes() + pLen := len(payload) + if pLen > ipv6MaxPayloadLength { + jumbo = true + if opts.FixLengths { + // We need to set the length later because the hop-by-hop header may + // not exist or else need padding, so pLen may yet change + addIPv6JumboOption(ip6) + } else if ip6.HopByHop == nil { + return fmt.Errorf("Cannot fit payload length of %d into IPv6 packet", pLen) + } else { + _, ok, err := getIPv6HopByHopJumboLength(ip6.HopByHop) + if err != nil { + return err + } + if !ok { + return errors.New("Missing jumbo length hop-by-hop option") + } + } + } + if ip6.HopByHop != nil { + if ip6.NextHeader != IPProtocolIPv6HopByHop { + // Just fix it instead of throwing an error + ip6.NextHeader = IPProtocolIPv6HopByHop + } + err = ip6.HopByHop.SerializeTo(b, opts) + if err != nil { + return err + } + payload = b.Bytes() + pLen = len(payload) + if opts.FixLengths && jumbo { + err := setIPv6PayloadJumboLength(payload) + if err != nil { + return err + } + } + } + if !jumbo && pLen > ipv6MaxPayloadLength { + return errors.New("Cannot fit payload into IPv6 header") + } + bytes, err := b.PrependBytes(40) + if err != nil { + return err + } + bytes[0] = (ip6.Version << 4) | (ip6.TrafficClass >> 4) + bytes[1] = (ip6.TrafficClass << 4) | uint8(ip6.FlowLabel>>16) + binary.BigEndian.PutUint16(bytes[2:], uint16(ip6.FlowLabel)) + if opts.FixLengths { + if jumbo { + ip6.Length = 0 + } else { + ip6.Length = uint16(pLen) + } + } + binary.BigEndian.PutUint16(bytes[4:], ip6.Length) + bytes[6] = byte(ip6.NextHeader) + bytes[7] = byte(ip6.HopLimit) + if err := ip6.AddressTo16(); err != nil { + return err + } + copy(bytes[8:], ip6.SrcIP) + copy(bytes[24:], ip6.DstIP) + return nil +} + +func (ip6 *IPv6) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + ip6.Version = uint8(data[0]) >> 4 + ip6.TrafficClass = uint8((binary.BigEndian.Uint16(data[0:2]) >> 4) & 0x00FF) + ip6.FlowLabel = binary.BigEndian.Uint32(data[0:4]) & 0x000FFFFF + ip6.Length = binary.BigEndian.Uint16(data[4:6]) + ip6.NextHeader = IPProtocol(data[6]) + ip6.HopLimit = data[7] + ip6.SrcIP = data[8:24] + ip6.DstIP = data[24:40] + ip6.HopByHop = nil + ip6.BaseLayer = BaseLayer{data[:40], data[40:]} + + // We treat a HopByHop IPv6 option as part of the IPv6 packet, since its + // options are crucial for understanding what's actually happening per packet. + if ip6.NextHeader == IPProtocolIPv6HopByHop { + err := ip6.hbh.DecodeFromBytes(ip6.Payload, df) + if err != nil { + return err + } + ip6.HopByHop = &ip6.hbh + pEnd, jumbo, err := getIPv6HopByHopJumboLength(ip6.HopByHop) + if err != nil { + return err + } + if jumbo && ip6.Length == 0 { + pEnd := int(pEnd) + if pEnd > len(ip6.Payload) { + df.SetTruncated() + pEnd = len(ip6.Payload) + } + ip6.Payload = ip6.Payload[:pEnd] + return nil + } else if jumbo && ip6.Length != 0 { + return errors.New("IPv6 has jumbo length and IPv6 length is not 0") + } else if !jumbo && ip6.Length == 0 { + return errors.New("IPv6 length 0, but HopByHop header does not have jumbogram option") + } + } + + if ip6.Length == 0 { + return fmt.Errorf("IPv6 length 0, but next header is %v, not HopByHop", ip6.NextHeader) + } else { + pEnd := int(ip6.Length) + if pEnd > len(ip6.Payload) { + df.SetTruncated() + pEnd = len(ip6.Payload) + } + ip6.Payload = ip6.Payload[:pEnd] + } + return nil +} + +func (i *IPv6) CanDecode() gopacket.LayerClass { + return LayerTypeIPv6 +} + +func (i *IPv6) NextLayerType() gopacket.LayerType { + if i.HopByHop != nil { + return i.HopByHop.NextHeader.LayerType() + } + return i.NextHeader.LayerType() +} + +func decodeIPv6(data []byte, p gopacket.PacketBuilder) error { + ip6 := &IPv6{} + err := ip6.DecodeFromBytes(data, p) + p.AddLayer(ip6) + p.SetNetworkLayer(ip6) + if ip6.HopByHop != nil { + p.AddLayer(ip6.HopByHop) + } + if err != nil { + return err + } + return p.NextDecoder(ip6.NextLayerType()) +} + +type ipv6HeaderTLVOption struct { + OptionType, OptionLength uint8 + ActualLength int + OptionData []byte + OptionAlignment [2]uint8 // Xn+Y = [2]uint8{X, Y} +} + +func (h *ipv6HeaderTLVOption) serializeTo(data []byte, fixLengths bool, dryrun bool) int { + if fixLengths { + h.OptionLength = uint8(len(h.OptionData)) + } + length := int(h.OptionLength) + 2 + if !dryrun { + data[0] = h.OptionType + data[1] = h.OptionLength + copy(data[2:], h.OptionData) + } + return length +} + +func decodeIPv6HeaderTLVOption(data []byte) (h *ipv6HeaderTLVOption) { + h = &ipv6HeaderTLVOption{} + if data[0] == 0 { + h.ActualLength = 1 + return + } + h.OptionType = data[0] + h.OptionLength = data[1] + h.ActualLength = int(h.OptionLength) + 2 + h.OptionData = data[2:h.ActualLength] + return +} + +func serializeTLVOptionPadding(data []byte, padLength int) { + if padLength <= 0 { + return + } + if padLength == 1 { + data[0] = 0x0 + return + } + tlvLength := uint8(padLength) - 2 + data[0] = 0x1 + data[1] = tlvLength + if tlvLength != 0 { + for k := range data[2:] { + data[k+2] = 0x0 + } + } + return +} + +// If buf is 'nil' do a serialize dry run +func serializeIPv6HeaderTLVOptions(buf []byte, options []*ipv6HeaderTLVOption, fixLengths bool) int { + var l int + + dryrun := buf == nil + length := 2 + for _, opt := range options { + if fixLengths { + x := int(opt.OptionAlignment[0]) + y := int(opt.OptionAlignment[1]) + if x != 0 { + n := length / x + offset := x*n + y + if offset < length { + offset += x + } + if length != offset { + pad := offset - length + if !dryrun { + serializeTLVOptionPadding(buf[length-2:], pad) + } + length += pad + } + } + } + if dryrun { + l = opt.serializeTo(nil, fixLengths, true) + } else { + l = opt.serializeTo(buf[length-2:], fixLengths, false) + } + length += l + } + if fixLengths { + pad := length % 8 + if pad != 0 { + if !dryrun { + serializeTLVOptionPadding(buf[length-2:], pad) + } + length += pad + } + } + return length - 2 +} + +type ipv6ExtensionBase struct { + BaseLayer + NextHeader IPProtocol + HeaderLength uint8 + ActualLength int +} + +func decodeIPv6ExtensionBase(data []byte) (i ipv6ExtensionBase) { + i.NextHeader = IPProtocol(data[0]) + i.HeaderLength = data[1] + i.ActualLength = int(i.HeaderLength)*8 + 8 + i.Contents = data[:i.ActualLength] + i.Payload = data[i.ActualLength:] + return +} + +// IPv6ExtensionSkipper is a DecodingLayer which decodes and ignores v6 +// extensions. You can use it with a DecodingLayerParser to handle IPv6 stacks +// which may or may not have extensions. +type IPv6ExtensionSkipper struct { + NextHeader IPProtocol + BaseLayer +} + +func (i *IPv6ExtensionSkipper) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + extension := decodeIPv6ExtensionBase(data) + i.BaseLayer = BaseLayer{data[:extension.ActualLength], data[extension.ActualLength:]} + i.NextHeader = extension.NextHeader + return nil +} + +func (i *IPv6ExtensionSkipper) CanDecode() gopacket.LayerClass { + return LayerClassIPv6Extension +} + +func (i *IPv6ExtensionSkipper) NextLayerType() gopacket.LayerType { + return i.NextHeader.LayerType() +} + +// IPv6HopByHopOption is a TLV option present in an IPv6 hop-by-hop extension. +type IPv6HopByHopOption ipv6HeaderTLVOption + +// IPv6HopByHop is the IPv6 hop-by-hop extension. +type IPv6HopByHop struct { + ipv6ExtensionBase + Options []*IPv6HopByHopOption +} + +// LayerType returns LayerTypeIPv6HopByHop. +func (i *IPv6HopByHop) LayerType() gopacket.LayerType { return LayerTypeIPv6HopByHop } + +func (i *IPv6HopByHop) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + var bytes []byte + var err error + + o := make([]*ipv6HeaderTLVOption, 0, len(i.Options)) + for _, v := range i.Options { + o = append(o, (*ipv6HeaderTLVOption)(v)) + } + + l := serializeIPv6HeaderTLVOptions(nil, o, opts.FixLengths) + bytes, err = b.PrependBytes(l) + if err != nil { + return err + } + serializeIPv6HeaderTLVOptions(bytes, o, opts.FixLengths) + + length := len(bytes) + 2 + if length%8 != 0 { + return errors.New("IPv6HopByHop actual length must be multiple of 8") + } + bytes, err = b.PrependBytes(2) + if err != nil { + return err + } + bytes[0] = uint8(i.NextHeader) + if opts.FixLengths { + i.HeaderLength = uint8((length / 8) - 1) + } + bytes[1] = uint8(i.HeaderLength) + return nil +} + +func (i *IPv6HopByHop) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + i.ipv6ExtensionBase = decodeIPv6ExtensionBase(data) + offset := 2 + for offset < i.ActualLength { + opt := decodeIPv6HeaderTLVOption(data[offset:]) + i.Options = append(i.Options, (*IPv6HopByHopOption)(opt)) + offset += opt.ActualLength + } + return nil +} + +func decodeIPv6HopByHop(data []byte, p gopacket.PacketBuilder) error { + i := &IPv6HopByHop{} + err := i.DecodeFromBytes(data, p) + p.AddLayer(i) + if err != nil { + return err + } + return p.NextDecoder(i.NextHeader) +} + +func (o *IPv6HopByHopOption) SetJumboLength(len uint32) { + o.OptionType = IPv6HopByHopOptionJumbogram + o.OptionLength = 4 + o.ActualLength = 6 + if o.OptionData == nil { + o.OptionData = make([]byte, 4) + } + binary.BigEndian.PutUint32(o.OptionData, len) + o.OptionAlignment = [2]uint8{4, 2} +} + +// IPv6Routing is the IPv6 routing extension. +type IPv6Routing struct { + ipv6ExtensionBase + RoutingType uint8 + SegmentsLeft uint8 + // This segment is supposed to be zero according to RFC2460, the second set of + // 4 bytes in the extension. + Reserved []byte + // SourceRoutingIPs is the set of IPv6 addresses requested for source routing, + // set only if RoutingType == 0. + SourceRoutingIPs []net.IP +} + +// LayerType returns LayerTypeIPv6Routing. +func (i *IPv6Routing) LayerType() gopacket.LayerType { return LayerTypeIPv6Routing } + +func decodeIPv6Routing(data []byte, p gopacket.PacketBuilder) error { + i := &IPv6Routing{ + ipv6ExtensionBase: decodeIPv6ExtensionBase(data), + RoutingType: data[2], + SegmentsLeft: data[3], + Reserved: data[4:8], + } + switch i.RoutingType { + case 0: // Source routing + if (i.ActualLength-8)%16 != 0 { + return fmt.Errorf("Invalid IPv6 source routing, length of type 0 packet %d", i.ActualLength) + } + for d := i.Contents[8:]; len(d) >= 16; d = d[16:] { + i.SourceRoutingIPs = append(i.SourceRoutingIPs, net.IP(d[:16])) + } + default: + return fmt.Errorf("Unknown IPv6 routing header type %d", i.RoutingType) + } + p.AddLayer(i) + return p.NextDecoder(i.NextHeader) +} + +// IPv6Fragment is the IPv6 fragment header, used for packet +// fragmentation/defragmentation. +type IPv6Fragment struct { + BaseLayer + NextHeader IPProtocol + // Reserved1 is bits [8-16), from least to most significant, 0-indexed + Reserved1 uint8 + FragmentOffset uint16 + // Reserved2 is bits [29-31), from least to most significant, 0-indexed + Reserved2 uint8 + MoreFragments bool + Identification uint32 +} + +// LayerType returns LayerTypeIPv6Fragment. +func (i *IPv6Fragment) LayerType() gopacket.LayerType { return LayerTypeIPv6Fragment } + +func decodeIPv6Fragment(data []byte, p gopacket.PacketBuilder) error { + i := &IPv6Fragment{ + BaseLayer: BaseLayer{data[:8], data[8:]}, + NextHeader: IPProtocol(data[0]), + Reserved1: data[1], + FragmentOffset: binary.BigEndian.Uint16(data[2:4]) >> 3, + Reserved2: data[3] & 0x6 >> 1, + MoreFragments: data[3]&0x1 != 0, + Identification: binary.BigEndian.Uint32(data[4:8]), + } + p.AddLayer(i) + return p.NextDecoder(gopacket.DecodeFragment) +} + +// IPv6DestinationOption is a TLV option present in an IPv6 destination options extension. +type IPv6DestinationOption ipv6HeaderTLVOption + +// IPv6Destination is the IPv6 destination options header. +type IPv6Destination struct { + ipv6ExtensionBase + Options []*IPv6DestinationOption +} + +// LayerType returns LayerTypeIPv6Destination. +func (i *IPv6Destination) LayerType() gopacket.LayerType { return LayerTypeIPv6Destination } + +func (i *IPv6Destination) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + i.ipv6ExtensionBase = decodeIPv6ExtensionBase(data) + offset := 2 + for offset < i.ActualLength { + opt := decodeIPv6HeaderTLVOption(data[offset:]) + i.Options = append(i.Options, (*IPv6DestinationOption)(opt)) + offset += opt.ActualLength + } + return nil +} + +func decodeIPv6Destination(data []byte, p gopacket.PacketBuilder) error { + i := &IPv6Destination{} + err := i.DecodeFromBytes(data, p) + p.AddLayer(i) + if err != nil { + return err + } + return p.NextDecoder(i.NextHeader) +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (i *IPv6Destination) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + var bytes []byte + var err error + + o := make([]*ipv6HeaderTLVOption, 0, len(i.Options)) + for _, v := range i.Options { + o = append(o, (*ipv6HeaderTLVOption)(v)) + } + + l := serializeIPv6HeaderTLVOptions(nil, o, opts.FixLengths) + bytes, err = b.PrependBytes(l) + if err != nil { + return err + } + serializeIPv6HeaderTLVOptions(bytes, o, opts.FixLengths) + + length := len(bytes) + 2 + if length%8 != 0 { + return errors.New("IPv6Destination actual length must be multiple of 8") + } + bytes, err = b.PrependBytes(2) + if err != nil { + return err + } + bytes[0] = uint8(i.NextHeader) + if opts.FixLengths { + i.HeaderLength = uint8((length / 8) - 1) + } + bytes[1] = uint8(i.HeaderLength) + return nil +} + +func checkIPv6Address(addr net.IP) error { + if len(addr) == net.IPv6len { + return nil + } + if len(addr) == net.IPv4len { + return errors.New("address is IPv4") + } + return fmt.Errorf("wrong length of %d bytes instead of %d", len(addr), net.IPv6len) +} + +func (ip *IPv6) AddressTo16() error { + if err := checkIPv6Address(ip.SrcIP); err != nil { + return fmt.Errorf("Invalid source IPv6 address (%s)", err) + } + if err := checkIPv6Address(ip.DstIP); err != nil { + return fmt.Errorf("Invalid destination IPv6 address (%s)", err) + } + return nil +} diff --git a/vendor/github.com/google/gopacket/layers/ipsec.go b/vendor/github.com/google/gopacket/layers/ipsec.go new file mode 100644 index 0000000..19163fa --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/ipsec.go @@ -0,0 +1,68 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "github.com/google/gopacket" +) + +// IPSecAH is the authentication header for IPv4/6 defined in +// http://tools.ietf.org/html/rfc2402 +type IPSecAH struct { + // While the auth header can be used for both IPv4 and v6, its format is that of + // an IPv6 extension (NextHeader, PayloadLength, etc...), so we use ipv6ExtensionBase + // to build it. + ipv6ExtensionBase + Reserved uint16 + SPI, Seq uint32 + AuthenticationData []byte +} + +// LayerType returns LayerTypeIPSecAH. +func (i *IPSecAH) LayerType() gopacket.LayerType { return LayerTypeIPSecAH } + +func decodeIPSecAH(data []byte, p gopacket.PacketBuilder) error { + i := &IPSecAH{ + ipv6ExtensionBase: ipv6ExtensionBase{ + NextHeader: IPProtocol(data[0]), + HeaderLength: data[1], + }, + Reserved: binary.BigEndian.Uint16(data[2:4]), + SPI: binary.BigEndian.Uint32(data[4:8]), + Seq: binary.BigEndian.Uint32(data[8:12]), + } + i.ActualLength = (int(i.HeaderLength) + 2) * 4 + i.AuthenticationData = data[12:i.ActualLength] + i.Contents = data[:i.ActualLength] + i.Payload = data[i.ActualLength:] + p.AddLayer(i) + return p.NextDecoder(i.NextHeader) +} + +// IPSecESP is the encapsulating security payload defined in +// http://tools.ietf.org/html/rfc2406 +type IPSecESP struct { + BaseLayer + SPI, Seq uint32 + // Encrypted contains the encrypted set of bytes sent in an ESP + Encrypted []byte +} + +// LayerType returns LayerTypeIPSecESP. +func (i *IPSecESP) LayerType() gopacket.LayerType { return LayerTypeIPSecESP } + +func decodeIPSecESP(data []byte, p gopacket.PacketBuilder) error { + i := &IPSecESP{ + BaseLayer: BaseLayer{data, nil}, + SPI: binary.BigEndian.Uint32(data[:4]), + Seq: binary.BigEndian.Uint32(data[4:8]), + Encrypted: data[8:], + } + p.AddLayer(i) + return nil +} diff --git a/vendor/github.com/google/gopacket/layers/layertypes.go b/vendor/github.com/google/gopacket/layers/layertypes.go new file mode 100644 index 0000000..9b50b37 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/layertypes.go @@ -0,0 +1,174 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "github.com/google/gopacket" +) + +var ( + LayerTypeARP = gopacket.RegisterLayerType(10, gopacket.LayerTypeMetadata{Name: "ARP", Decoder: gopacket.DecodeFunc(decodeARP)}) + LayerTypeCiscoDiscovery = gopacket.RegisterLayerType(11, gopacket.LayerTypeMetadata{Name: "CiscoDiscovery", Decoder: gopacket.DecodeFunc(decodeCiscoDiscovery)}) + LayerTypeEthernetCTP = gopacket.RegisterLayerType(12, gopacket.LayerTypeMetadata{Name: "EthernetCTP", Decoder: gopacket.DecodeFunc(decodeEthernetCTP)}) + LayerTypeEthernetCTPForwardData = gopacket.RegisterLayerType(13, gopacket.LayerTypeMetadata{Name: "EthernetCTPForwardData", Decoder: nil}) + LayerTypeEthernetCTPReply = gopacket.RegisterLayerType(14, gopacket.LayerTypeMetadata{Name: "EthernetCTPReply", Decoder: nil}) + LayerTypeDot1Q = gopacket.RegisterLayerType(15, gopacket.LayerTypeMetadata{Name: "Dot1Q", Decoder: gopacket.DecodeFunc(decodeDot1Q)}) + LayerTypeEtherIP = gopacket.RegisterLayerType(16, gopacket.LayerTypeMetadata{Name: "EtherIP", Decoder: gopacket.DecodeFunc(decodeEtherIP)}) + LayerTypeEthernet = gopacket.RegisterLayerType(17, gopacket.LayerTypeMetadata{Name: "Ethernet", Decoder: gopacket.DecodeFunc(decodeEthernet)}) + LayerTypeGRE = gopacket.RegisterLayerType(18, gopacket.LayerTypeMetadata{Name: "GRE", Decoder: gopacket.DecodeFunc(decodeGRE)}) + LayerTypeICMPv4 = gopacket.RegisterLayerType(19, gopacket.LayerTypeMetadata{Name: "ICMPv4", Decoder: gopacket.DecodeFunc(decodeICMPv4)}) + LayerTypeIPv4 = gopacket.RegisterLayerType(20, gopacket.LayerTypeMetadata{Name: "IPv4", Decoder: gopacket.DecodeFunc(decodeIPv4)}) + LayerTypeIPv6 = gopacket.RegisterLayerType(21, gopacket.LayerTypeMetadata{Name: "IPv6", Decoder: gopacket.DecodeFunc(decodeIPv6)}) + LayerTypeLLC = gopacket.RegisterLayerType(22, gopacket.LayerTypeMetadata{Name: "LLC", Decoder: gopacket.DecodeFunc(decodeLLC)}) + LayerTypeSNAP = gopacket.RegisterLayerType(23, gopacket.LayerTypeMetadata{Name: "SNAP", Decoder: gopacket.DecodeFunc(decodeSNAP)}) + LayerTypeMPLS = gopacket.RegisterLayerType(24, gopacket.LayerTypeMetadata{Name: "MPLS", Decoder: gopacket.DecodeFunc(decodeMPLS)}) + LayerTypePPP = gopacket.RegisterLayerType(25, gopacket.LayerTypeMetadata{Name: "PPP", Decoder: gopacket.DecodeFunc(decodePPP)}) + LayerTypePPPoE = gopacket.RegisterLayerType(26, gopacket.LayerTypeMetadata{Name: "PPPoE", Decoder: gopacket.DecodeFunc(decodePPPoE)}) + LayerTypeRUDP = gopacket.RegisterLayerType(27, gopacket.LayerTypeMetadata{Name: "RUDP", Decoder: gopacket.DecodeFunc(decodeRUDP)}) + LayerTypeSCTP = gopacket.RegisterLayerType(28, gopacket.LayerTypeMetadata{Name: "SCTP", Decoder: gopacket.DecodeFunc(decodeSCTP)}) + LayerTypeSCTPUnknownChunkType = gopacket.RegisterLayerType(29, gopacket.LayerTypeMetadata{Name: "SCTPUnknownChunkType", Decoder: nil}) + LayerTypeSCTPData = gopacket.RegisterLayerType(30, gopacket.LayerTypeMetadata{Name: "SCTPData", Decoder: nil}) + LayerTypeSCTPInit = gopacket.RegisterLayerType(31, gopacket.LayerTypeMetadata{Name: "SCTPInit", Decoder: nil}) + LayerTypeSCTPSack = gopacket.RegisterLayerType(32, gopacket.LayerTypeMetadata{Name: "SCTPSack", Decoder: nil}) + LayerTypeSCTPHeartbeat = gopacket.RegisterLayerType(33, gopacket.LayerTypeMetadata{Name: "SCTPHeartbeat", Decoder: nil}) + LayerTypeSCTPError = gopacket.RegisterLayerType(34, gopacket.LayerTypeMetadata{Name: "SCTPError", Decoder: nil}) + LayerTypeSCTPShutdown = gopacket.RegisterLayerType(35, gopacket.LayerTypeMetadata{Name: "SCTPShutdown", Decoder: nil}) + LayerTypeSCTPShutdownAck = gopacket.RegisterLayerType(36, gopacket.LayerTypeMetadata{Name: "SCTPShutdownAck", Decoder: nil}) + LayerTypeSCTPCookieEcho = gopacket.RegisterLayerType(37, gopacket.LayerTypeMetadata{Name: "SCTPCookieEcho", Decoder: nil}) + LayerTypeSCTPEmptyLayer = gopacket.RegisterLayerType(38, gopacket.LayerTypeMetadata{Name: "SCTPEmptyLayer", Decoder: nil}) + LayerTypeSCTPInitAck = gopacket.RegisterLayerType(39, gopacket.LayerTypeMetadata{Name: "SCTPInitAck", Decoder: nil}) + LayerTypeSCTPHeartbeatAck = gopacket.RegisterLayerType(40, gopacket.LayerTypeMetadata{Name: "SCTPHeartbeatAck", Decoder: nil}) + LayerTypeSCTPAbort = gopacket.RegisterLayerType(41, gopacket.LayerTypeMetadata{Name: "SCTPAbort", Decoder: nil}) + LayerTypeSCTPShutdownComplete = gopacket.RegisterLayerType(42, gopacket.LayerTypeMetadata{Name: "SCTPShutdownComplete", Decoder: nil}) + LayerTypeSCTPCookieAck = gopacket.RegisterLayerType(43, gopacket.LayerTypeMetadata{Name: "SCTPCookieAck", Decoder: nil}) + LayerTypeTCP = gopacket.RegisterLayerType(44, gopacket.LayerTypeMetadata{Name: "TCP", Decoder: gopacket.DecodeFunc(decodeTCP)}) + LayerTypeUDP = gopacket.RegisterLayerType(45, gopacket.LayerTypeMetadata{Name: "UDP", Decoder: gopacket.DecodeFunc(decodeUDP)}) + LayerTypeIPv6HopByHop = gopacket.RegisterLayerType(46, gopacket.LayerTypeMetadata{Name: "IPv6HopByHop", Decoder: gopacket.DecodeFunc(decodeIPv6HopByHop)}) + LayerTypeIPv6Routing = gopacket.RegisterLayerType(47, gopacket.LayerTypeMetadata{Name: "IPv6Routing", Decoder: gopacket.DecodeFunc(decodeIPv6Routing)}) + LayerTypeIPv6Fragment = gopacket.RegisterLayerType(48, gopacket.LayerTypeMetadata{Name: "IPv6Fragment", Decoder: gopacket.DecodeFunc(decodeIPv6Fragment)}) + LayerTypeIPv6Destination = gopacket.RegisterLayerType(49, gopacket.LayerTypeMetadata{Name: "IPv6Destination", Decoder: gopacket.DecodeFunc(decodeIPv6Destination)}) + LayerTypeIPSecAH = gopacket.RegisterLayerType(50, gopacket.LayerTypeMetadata{Name: "IPSecAH", Decoder: gopacket.DecodeFunc(decodeIPSecAH)}) + LayerTypeIPSecESP = gopacket.RegisterLayerType(51, gopacket.LayerTypeMetadata{Name: "IPSecESP", Decoder: gopacket.DecodeFunc(decodeIPSecESP)}) + LayerTypeUDPLite = gopacket.RegisterLayerType(52, gopacket.LayerTypeMetadata{Name: "UDPLite", Decoder: gopacket.DecodeFunc(decodeUDPLite)}) + LayerTypeFDDI = gopacket.RegisterLayerType(53, gopacket.LayerTypeMetadata{Name: "FDDI", Decoder: gopacket.DecodeFunc(decodeFDDI)}) + LayerTypeLoopback = gopacket.RegisterLayerType(54, gopacket.LayerTypeMetadata{Name: "Loopback", Decoder: gopacket.DecodeFunc(decodeLoopback)}) + LayerTypeEAP = gopacket.RegisterLayerType(55, gopacket.LayerTypeMetadata{Name: "EAP", Decoder: gopacket.DecodeFunc(decodeEAP)}) + LayerTypeEAPOL = gopacket.RegisterLayerType(56, gopacket.LayerTypeMetadata{Name: "EAPOL", Decoder: gopacket.DecodeFunc(decodeEAPOL)}) + LayerTypeICMPv6 = gopacket.RegisterLayerType(57, gopacket.LayerTypeMetadata{Name: "ICMPv6", Decoder: gopacket.DecodeFunc(decodeICMPv6)}) + LayerTypeLinkLayerDiscovery = gopacket.RegisterLayerType(58, gopacket.LayerTypeMetadata{Name: "LinkLayerDiscovery", Decoder: gopacket.DecodeFunc(decodeLinkLayerDiscovery)}) + LayerTypeCiscoDiscoveryInfo = gopacket.RegisterLayerType(59, gopacket.LayerTypeMetadata{Name: "CiscoDiscoveryInfo", Decoder: gopacket.DecodeFunc(decodeCiscoDiscoveryInfo)}) + LayerTypeLinkLayerDiscoveryInfo = gopacket.RegisterLayerType(60, gopacket.LayerTypeMetadata{Name: "LinkLayerDiscoveryInfo", Decoder: nil}) + LayerTypeNortelDiscovery = gopacket.RegisterLayerType(61, gopacket.LayerTypeMetadata{Name: "NortelDiscovery", Decoder: gopacket.DecodeFunc(decodeNortelDiscovery)}) + LayerTypeIGMP = gopacket.RegisterLayerType(62, gopacket.LayerTypeMetadata{Name: "IGMP", Decoder: gopacket.DecodeFunc(decodeIGMP)}) + LayerTypePFLog = gopacket.RegisterLayerType(63, gopacket.LayerTypeMetadata{Name: "PFLog", Decoder: gopacket.DecodeFunc(decodePFLog)}) + LayerTypeRadioTap = gopacket.RegisterLayerType(64, gopacket.LayerTypeMetadata{Name: "RadioTap", Decoder: gopacket.DecodeFunc(decodeRadioTap)}) + LayerTypeDot11 = gopacket.RegisterLayerType(65, gopacket.LayerTypeMetadata{Name: "Dot11", Decoder: gopacket.DecodeFunc(decodeDot11)}) + LayerTypeDot11Ctrl = gopacket.RegisterLayerType(66, gopacket.LayerTypeMetadata{Name: "Dot11Ctrl", Decoder: gopacket.DecodeFunc(decodeDot11Ctrl)}) + LayerTypeDot11Data = gopacket.RegisterLayerType(67, gopacket.LayerTypeMetadata{Name: "Dot11Data", Decoder: gopacket.DecodeFunc(decodeDot11Data)}) + LayerTypeDot11DataCFAck = gopacket.RegisterLayerType(68, gopacket.LayerTypeMetadata{Name: "Dot11DataCFAck", Decoder: gopacket.DecodeFunc(decodeDot11DataCFAck)}) + LayerTypeDot11DataCFPoll = gopacket.RegisterLayerType(69, gopacket.LayerTypeMetadata{Name: "Dot11DataCFPoll", Decoder: gopacket.DecodeFunc(decodeDot11DataCFPoll)}) + LayerTypeDot11DataCFAckPoll = gopacket.RegisterLayerType(70, gopacket.LayerTypeMetadata{Name: "Dot11DataCFAckPoll", Decoder: gopacket.DecodeFunc(decodeDot11DataCFAckPoll)}) + LayerTypeDot11DataNull = gopacket.RegisterLayerType(71, gopacket.LayerTypeMetadata{Name: "Dot11DataNull", Decoder: gopacket.DecodeFunc(decodeDot11DataNull)}) + LayerTypeDot11DataCFAckNoData = gopacket.RegisterLayerType(72, gopacket.LayerTypeMetadata{Name: "Dot11DataCFAck", Decoder: gopacket.DecodeFunc(decodeDot11DataCFAck)}) + LayerTypeDot11DataCFPollNoData = gopacket.RegisterLayerType(73, gopacket.LayerTypeMetadata{Name: "Dot11DataCFPoll", Decoder: gopacket.DecodeFunc(decodeDot11DataCFPoll)}) + LayerTypeDot11DataCFAckPollNoData = gopacket.RegisterLayerType(74, gopacket.LayerTypeMetadata{Name: "Dot11DataCFAckPoll", Decoder: gopacket.DecodeFunc(decodeDot11DataCFAckPoll)}) + LayerTypeDot11DataQOSData = gopacket.RegisterLayerType(75, gopacket.LayerTypeMetadata{Name: "Dot11DataQOSData", Decoder: gopacket.DecodeFunc(decodeDot11DataQOSData)}) + LayerTypeDot11DataQOSDataCFAck = gopacket.RegisterLayerType(76, gopacket.LayerTypeMetadata{Name: "Dot11DataQOSDataCFAck", Decoder: gopacket.DecodeFunc(decodeDot11DataQOSDataCFAck)}) + LayerTypeDot11DataQOSDataCFPoll = gopacket.RegisterLayerType(77, gopacket.LayerTypeMetadata{Name: "Dot11DataQOSDataCFPoll", Decoder: gopacket.DecodeFunc(decodeDot11DataQOSDataCFPoll)}) + LayerTypeDot11DataQOSDataCFAckPoll = gopacket.RegisterLayerType(78, gopacket.LayerTypeMetadata{Name: "Dot11DataQOSDataCFAckPoll", Decoder: gopacket.DecodeFunc(decodeDot11DataQOSDataCFAckPoll)}) + LayerTypeDot11DataQOSNull = gopacket.RegisterLayerType(79, gopacket.LayerTypeMetadata{Name: "Dot11DataQOSNull", Decoder: gopacket.DecodeFunc(decodeDot11DataQOSNull)}) + LayerTypeDot11DataQOSCFPollNoData = gopacket.RegisterLayerType(80, gopacket.LayerTypeMetadata{Name: "Dot11DataQOSCFPoll", Decoder: gopacket.DecodeFunc(decodeDot11DataQOSCFPollNoData)}) + LayerTypeDot11DataQOSCFAckPollNoData = gopacket.RegisterLayerType(81, gopacket.LayerTypeMetadata{Name: "Dot11DataQOSCFAckPoll", Decoder: gopacket.DecodeFunc(decodeDot11DataQOSCFAckPollNoData)}) + LayerTypeDot11InformationElement = gopacket.RegisterLayerType(82, gopacket.LayerTypeMetadata{Name: "Dot11InformationElement", Decoder: gopacket.DecodeFunc(decodeDot11InformationElement)}) + LayerTypeDot11CtrlCTS = gopacket.RegisterLayerType(83, gopacket.LayerTypeMetadata{Name: "Dot11CtrlCTS", Decoder: gopacket.DecodeFunc(decodeDot11CtrlCTS)}) + LayerTypeDot11CtrlRTS = gopacket.RegisterLayerType(84, gopacket.LayerTypeMetadata{Name: "Dot11CtrlRTS", Decoder: gopacket.DecodeFunc(decodeDot11CtrlRTS)}) + LayerTypeDot11CtrlBlockAckReq = gopacket.RegisterLayerType(85, gopacket.LayerTypeMetadata{Name: "Dot11CtrlBlockAckReq", Decoder: gopacket.DecodeFunc(decodeDot11CtrlBlockAckReq)}) + LayerTypeDot11CtrlBlockAck = gopacket.RegisterLayerType(86, gopacket.LayerTypeMetadata{Name: "Dot11CtrlBlockAck", Decoder: gopacket.DecodeFunc(decodeDot11CtrlBlockAck)}) + LayerTypeDot11CtrlPowersavePoll = gopacket.RegisterLayerType(87, gopacket.LayerTypeMetadata{Name: "Dot11CtrlPowersavePoll", Decoder: gopacket.DecodeFunc(decodeDot11CtrlPowersavePoll)}) + LayerTypeDot11CtrlAck = gopacket.RegisterLayerType(88, gopacket.LayerTypeMetadata{Name: "Dot11CtrlAck", Decoder: gopacket.DecodeFunc(decodeDot11CtrlAck)}) + LayerTypeDot11CtrlCFEnd = gopacket.RegisterLayerType(89, gopacket.LayerTypeMetadata{Name: "Dot11CtrlCFEnd", Decoder: gopacket.DecodeFunc(decodeDot11CtrlCFEnd)}) + LayerTypeDot11CtrlCFEndAck = gopacket.RegisterLayerType(90, gopacket.LayerTypeMetadata{Name: "Dot11CtrlCFEndAck", Decoder: gopacket.DecodeFunc(decodeDot11CtrlCFEndAck)}) + LayerTypeDot11MgmtAssociationReq = gopacket.RegisterLayerType(91, gopacket.LayerTypeMetadata{Name: "Dot11MgmtAssociationReq", Decoder: gopacket.DecodeFunc(decodeDot11MgmtAssociationReq)}) + LayerTypeDot11MgmtAssociationResp = gopacket.RegisterLayerType(92, gopacket.LayerTypeMetadata{Name: "Dot11MgmtAssociationResp", Decoder: gopacket.DecodeFunc(decodeDot11MgmtAssociationResp)}) + LayerTypeDot11MgmtReassociationReq = gopacket.RegisterLayerType(93, gopacket.LayerTypeMetadata{Name: "Dot11MgmtReassociationReq", Decoder: gopacket.DecodeFunc(decodeDot11MgmtReassociationReq)}) + LayerTypeDot11MgmtReassociationResp = gopacket.RegisterLayerType(94, gopacket.LayerTypeMetadata{Name: "Dot11MgmtReassociationResp", Decoder: gopacket.DecodeFunc(decodeDot11MgmtReassociationResp)}) + LayerTypeDot11MgmtProbeReq = gopacket.RegisterLayerType(95, gopacket.LayerTypeMetadata{Name: "Dot11MgmtProbeReq", Decoder: gopacket.DecodeFunc(decodeDot11MgmtProbeReq)}) + LayerTypeDot11MgmtProbeResp = gopacket.RegisterLayerType(96, gopacket.LayerTypeMetadata{Name: "Dot11MgmtProbeResp", Decoder: gopacket.DecodeFunc(decodeDot11MgmtProbeResp)}) + LayerTypeDot11MgmtMeasurementPilot = gopacket.RegisterLayerType(97, gopacket.LayerTypeMetadata{Name: "Dot11MgmtMeasurementPilot", Decoder: gopacket.DecodeFunc(decodeDot11MgmtMeasurementPilot)}) + LayerTypeDot11MgmtBeacon = gopacket.RegisterLayerType(98, gopacket.LayerTypeMetadata{Name: "Dot11MgmtBeacon", Decoder: gopacket.DecodeFunc(decodeDot11MgmtBeacon)}) + LayerTypeDot11MgmtATIM = gopacket.RegisterLayerType(99, gopacket.LayerTypeMetadata{Name: "Dot11MgmtATIM", Decoder: gopacket.DecodeFunc(decodeDot11MgmtATIM)}) + LayerTypeDot11MgmtDisassociation = gopacket.RegisterLayerType(100, gopacket.LayerTypeMetadata{Name: "Dot11MgmtDisassociation", Decoder: gopacket.DecodeFunc(decodeDot11MgmtDisassociation)}) + LayerTypeDot11MgmtAuthentication = gopacket.RegisterLayerType(101, gopacket.LayerTypeMetadata{Name: "Dot11MgmtAuthentication", Decoder: gopacket.DecodeFunc(decodeDot11MgmtAuthentication)}) + LayerTypeDot11MgmtDeauthentication = gopacket.RegisterLayerType(102, gopacket.LayerTypeMetadata{Name: "Dot11MgmtDeauthentication", Decoder: gopacket.DecodeFunc(decodeDot11MgmtDeauthentication)}) + LayerTypeDot11MgmtAction = gopacket.RegisterLayerType(103, gopacket.LayerTypeMetadata{Name: "Dot11MgmtAction", Decoder: gopacket.DecodeFunc(decodeDot11MgmtAction)}) + LayerTypeDot11MgmtActionNoAck = gopacket.RegisterLayerType(104, gopacket.LayerTypeMetadata{Name: "Dot11MgmtActionNoAck", Decoder: gopacket.DecodeFunc(decodeDot11MgmtActionNoAck)}) + LayerTypeDot11MgmtArubaWLAN = gopacket.RegisterLayerType(105, gopacket.LayerTypeMetadata{Name: "Dot11MgmtArubaWLAN", Decoder: gopacket.DecodeFunc(decodeDot11MgmtArubaWLAN)}) + LayerTypeDot11WEP = gopacket.RegisterLayerType(106, gopacket.LayerTypeMetadata{Name: "Dot11WEP", Decoder: gopacket.DecodeFunc(decodeDot11WEP)}) + LayerTypeDNS = gopacket.RegisterLayerType(107, gopacket.LayerTypeMetadata{Name: "DNS", Decoder: gopacket.DecodeFunc(decodeDNS)}) + LayerTypeUSB = gopacket.RegisterLayerType(108, gopacket.LayerTypeMetadata{Name: "USB", Decoder: gopacket.DecodeFunc(decodeUSB)}) + LayerTypeUSBRequestBlockSetup = gopacket.RegisterLayerType(109, gopacket.LayerTypeMetadata{Name: "USBRequestBlockSetup", Decoder: gopacket.DecodeFunc(decodeUSBRequestBlockSetup)}) + LayerTypeUSBControl = gopacket.RegisterLayerType(110, gopacket.LayerTypeMetadata{Name: "USBControl", Decoder: gopacket.DecodeFunc(decodeUSBControl)}) + LayerTypeUSBInterrupt = gopacket.RegisterLayerType(111, gopacket.LayerTypeMetadata{Name: "USBInterrupt", Decoder: gopacket.DecodeFunc(decodeUSBInterrupt)}) + LayerTypeUSBBulk = gopacket.RegisterLayerType(112, gopacket.LayerTypeMetadata{Name: "USBBulk", Decoder: gopacket.DecodeFunc(decodeUSBBulk)}) + LayerTypeLinuxSLL = gopacket.RegisterLayerType(113, gopacket.LayerTypeMetadata{Name: "Linux SLL", Decoder: gopacket.DecodeFunc(decodeLinuxSLL)}) + LayerTypeSFlow = gopacket.RegisterLayerType(114, gopacket.LayerTypeMetadata{Name: "SFlow", Decoder: gopacket.DecodeFunc(decodeSFlow)}) + LayerTypePrismHeader = gopacket.RegisterLayerType(115, gopacket.LayerTypeMetadata{Name: "Prism monitor mode header", Decoder: gopacket.DecodeFunc(decodePrismHeader)}) + LayerTypeVXLAN = gopacket.RegisterLayerType(116, gopacket.LayerTypeMetadata{Name: "VXLAN", Decoder: gopacket.DecodeFunc(decodeVXLAN)}) + LayerTypeNTP = gopacket.RegisterLayerType(117, gopacket.LayerTypeMetadata{Name: "NTP", Decoder: gopacket.DecodeFunc(decodeNTP)}) + LayerTypeDHCPv4 = gopacket.RegisterLayerType(118, gopacket.LayerTypeMetadata{Name: "DHCPv4", Decoder: gopacket.DecodeFunc(decodeDHCPv4)}) + LayerTypeVRRP = gopacket.RegisterLayerType(119, gopacket.LayerTypeMetadata{Name: "VRRP", Decoder: gopacket.DecodeFunc(decodeVRRP)}) + LayerTypeGeneve = gopacket.RegisterLayerType(120, gopacket.LayerTypeMetadata{Name: "Geneve", Decoder: gopacket.DecodeFunc(decodeGeneve)}) +) + +var ( + // LayerClassIPNetwork contains TCP/IP network layer types. + LayerClassIPNetwork = gopacket.NewLayerClass([]gopacket.LayerType{ + LayerTypeIPv4, + LayerTypeIPv6, + }) + // LayerClassIPTransport contains TCP/IP transport layer types. + LayerClassIPTransport = gopacket.NewLayerClass([]gopacket.LayerType{ + LayerTypeTCP, + LayerTypeUDP, + LayerTypeSCTP, + }) + // LayerClassIPControl contains TCP/IP control protocols. + LayerClassIPControl = gopacket.NewLayerClass([]gopacket.LayerType{ + LayerTypeICMPv4, + LayerTypeICMPv6, + }) + // LayerClassSCTPChunk contains SCTP chunk types (not the top-level SCTP + // layer). + LayerClassSCTPChunk = gopacket.NewLayerClass([]gopacket.LayerType{ + LayerTypeSCTPUnknownChunkType, + LayerTypeSCTPData, + LayerTypeSCTPInit, + LayerTypeSCTPSack, + LayerTypeSCTPHeartbeat, + LayerTypeSCTPError, + LayerTypeSCTPShutdown, + LayerTypeSCTPShutdownAck, + LayerTypeSCTPCookieEcho, + LayerTypeSCTPEmptyLayer, + LayerTypeSCTPInitAck, + LayerTypeSCTPHeartbeatAck, + LayerTypeSCTPAbort, + LayerTypeSCTPShutdownComplete, + LayerTypeSCTPCookieAck, + }) + // LayerClassIPv6Extension contains IPv6 extension headers. + LayerClassIPv6Extension = gopacket.NewLayerClass([]gopacket.LayerType{ + LayerTypeIPv6HopByHop, + LayerTypeIPv6Routing, + LayerTypeIPv6Fragment, + LayerTypeIPv6Destination, + }) + LayerClassIPSec = gopacket.NewLayerClass([]gopacket.LayerType{ + LayerTypeIPSecAH, + LayerTypeIPSecESP, + }) +) diff --git a/vendor/github.com/google/gopacket/layers/linux_sll.go b/vendor/github.com/google/gopacket/layers/linux_sll.go new file mode 100644 index 0000000..b186053 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/linux_sll.go @@ -0,0 +1,96 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "fmt" + "net" + + "github.com/google/gopacket" +) + +type LinuxSLLPacketType uint16 + +const ( + LinuxSLLPacketTypeHost LinuxSLLPacketType = 0 // To us + LinuxSLLPacketTypeBroadcast LinuxSLLPacketType = 1 // To all + LinuxSLLPacketTypeMulticast LinuxSLLPacketType = 2 // To group + LinuxSLLPacketTypeOtherhost LinuxSLLPacketType = 3 // To someone else + LinuxSLLPacketTypeOutgoing LinuxSLLPacketType = 4 // Outgoing of any type + // These ones are invisible by user level + LinuxSLLPacketTypeLoopback LinuxSLLPacketType = 5 // MC/BRD frame looped back + LinuxSLLPacketTypeFastroute LinuxSLLPacketType = 6 // Fastrouted frame +) + +func (l LinuxSLLPacketType) String() string { + switch l { + case LinuxSLLPacketTypeHost: + return "host" + case LinuxSLLPacketTypeBroadcast: + return "broadcast" + case LinuxSLLPacketTypeMulticast: + return "multicast" + case LinuxSLLPacketTypeOtherhost: + return "otherhost" + case LinuxSLLPacketTypeOutgoing: + return "outgoing" + case LinuxSLLPacketTypeLoopback: + return "loopback" + case LinuxSLLPacketTypeFastroute: + return "fastroute" + } + return fmt.Sprintf("Unknown(%d)", int(l)) +} + +type LinuxSLL struct { + BaseLayer + PacketType LinuxSLLPacketType + AddrLen uint16 + Addr net.HardwareAddr + EthernetType EthernetType +} + +// LayerType returns LayerTypeLinuxSLL. +func (sll *LinuxSLL) LayerType() gopacket.LayerType { return LayerTypeLinuxSLL } + +func (sll *LinuxSLL) CanDecode() gopacket.LayerClass { + return LayerTypeLinuxSLL +} + +func (sll *LinuxSLL) LinkFlow() gopacket.Flow { + return gopacket.NewFlow(EndpointMAC, sll.Addr, nil) +} + +func (sll *LinuxSLL) NextLayerType() gopacket.LayerType { + return sll.EthernetType.LayerType() +} + +func (sll *LinuxSLL) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 16 { + return errors.New("Linux SLL packet too small") + } + sll.PacketType = LinuxSLLPacketType(binary.BigEndian.Uint16(data[0:2])) + sll.AddrLen = binary.BigEndian.Uint16(data[4:6]) + + sll.Addr = net.HardwareAddr(data[6 : sll.AddrLen+6]) + sll.EthernetType = EthernetType(binary.BigEndian.Uint16(data[14:16])) + sll.BaseLayer = BaseLayer{data[:16], data[16:]} + + return nil +} + +func decodeLinuxSLL(data []byte, p gopacket.PacketBuilder) error { + sll := &LinuxSLL{} + if err := sll.DecodeFromBytes(data, p); err != nil { + return err + } + p.AddLayer(sll) + p.SetLinkLayer(sll) + return p.NextDecoder(sll.EthernetType) +} diff --git a/vendor/github.com/google/gopacket/layers/llc.go b/vendor/github.com/google/gopacket/layers/llc.go new file mode 100644 index 0000000..f7d922b --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/llc.go @@ -0,0 +1,143 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + + "github.com/google/gopacket" +) + +// LLC is the layer used for 802.2 Logical Link Control headers. +// See http://standards.ieee.org/getieee802/download/802.2-1998.pdf +type LLC struct { + BaseLayer + DSAP uint8 + IG bool // true means group, false means individual + SSAP uint8 + CR bool // true means response, false means command + Control uint16 +} + +// LayerType returns gopacket.LayerTypeLLC. +func (l *LLC) LayerType() gopacket.LayerType { return LayerTypeLLC } + +// SNAP is used inside LLC. See +// http://standards.ieee.org/getieee802/download/802-2001.pdf. +// From http://en.wikipedia.org/wiki/Subnetwork_Access_Protocol: +// "[T]he Subnetwork Access Protocol (SNAP) is a mechanism for multiplexing, +// on networks using IEEE 802.2 LLC, more protocols than can be distinguished +// by the 8-bit 802.2 Service Access Point (SAP) fields." +type SNAP struct { + BaseLayer + OrganizationalCode []byte + Type EthernetType +} + +// LayerType returns gopacket.LayerTypeSNAP. +func (s *SNAP) LayerType() gopacket.LayerType { return LayerTypeSNAP } + +func decodeLLC(data []byte, p gopacket.PacketBuilder) error { + l := &LLC{ + DSAP: data[0] & 0xFE, + IG: data[0]&0x1 != 0, + SSAP: data[1] & 0xFE, + CR: data[1]&0x1 != 0, + Control: uint16(data[2]), + } + if l.Control&0x1 == 0 || l.Control&0x3 == 0x1 { + l.Control = l.Control<<8 | uint16(data[3]) + l.Contents = data[:4] + l.Payload = data[4:] + } else { + l.Contents = data[:3] + l.Payload = data[3:] + } + p.AddLayer(l) + if l.DSAP == 0xAA && l.SSAP == 0xAA { + return p.NextDecoder(LayerTypeSNAP) + } + return p.NextDecoder(gopacket.DecodeUnknown) +} + +func decodeSNAP(data []byte, p gopacket.PacketBuilder) error { + s := &SNAP{ + OrganizationalCode: data[:3], + Type: EthernetType(binary.BigEndian.Uint16(data[3:5])), + BaseLayer: BaseLayer{data[:5], data[5:]}, + } + p.AddLayer(s) + // BUG(gconnell): When decoding SNAP, we treat the SNAP type as an Ethernet + // type. This may not actually be an ethernet type in all cases, + // depending on the organizational code. Right now, we don't check. + return p.NextDecoder(s.Type) +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (l *LLC) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + var ig_flag, cr_flag byte + var length int + + if l.Control&0xFF00 != 0 { + length = 4 + } else { + length = 3 + } + + if l.DSAP&0x1 != 0 { + return errors.New("DSAP value invalid, should not include IG flag bit") + } + + if l.SSAP&0x1 != 0 { + return errors.New("SSAP value invalid, should not include CR flag bit") + } + + if buf, err := b.PrependBytes(length); err != nil { + return err + } else { + ig_flag = 0 + if l.IG { + ig_flag = 0x1 + } + + cr_flag = 0 + if l.CR { + cr_flag = 0x1 + } + + buf[0] = l.DSAP + ig_flag + buf[1] = l.SSAP + cr_flag + + if length == 4 { + buf[2] = uint8(l.Control >> 8) + buf[3] = uint8(l.Control) + } else { + buf[2] = uint8(l.Control) + } + } + + return nil +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (s *SNAP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + if buf, err := b.PrependBytes(5); err != nil { + return err + } else { + buf[0] = s.OrganizationalCode[0] + buf[1] = s.OrganizationalCode[1] + buf[2] = s.OrganizationalCode[2] + binary.BigEndian.PutUint16(buf[3:5], uint16(s.Type)) + } + + return nil +} diff --git a/vendor/github.com/google/gopacket/layers/lldp.go b/vendor/github.com/google/gopacket/layers/lldp.go new file mode 100644 index 0000000..92ec7da --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/lldp.go @@ -0,0 +1,1530 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "fmt" + + "github.com/google/gopacket" +) + +// LLDPTLVType is the type of each TLV value in a LinkLayerDiscovery packet. +type LLDPTLVType byte + +const ( + LLDPTLVEnd LLDPTLVType = 0 + LLDPTLVChassisID LLDPTLVType = 1 + LLDPTLVPortID LLDPTLVType = 2 + LLDPTLVTTL LLDPTLVType = 3 + LLDPTLVPortDescription LLDPTLVType = 4 + LLDPTLVSysName LLDPTLVType = 5 + LLDPTLVSysDescription LLDPTLVType = 6 + LLDPTLVSysCapabilities LLDPTLVType = 7 + LLDPTLVMgmtAddress LLDPTLVType = 8 + LLDPTLVOrgSpecific LLDPTLVType = 127 +) + +// LinkLayerDiscoveryValue is a TLV value inside a LinkLayerDiscovery packet layer. +type LinkLayerDiscoveryValue struct { + Type LLDPTLVType + Length uint16 + Value []byte +} + +// LLDPChassisIDSubType specifies the value type for a single LLDPChassisID.ID +type LLDPChassisIDSubType byte + +// LLDP Chassis Types +const ( + LLDPChassisIDSubTypeReserved LLDPChassisIDSubType = 0 + LLDPChassisIDSubTypeChassisComp LLDPChassisIDSubType = 1 + LLDPChassisIDSubtypeIfaceAlias LLDPChassisIDSubType = 2 + LLDPChassisIDSubTypePortComp LLDPChassisIDSubType = 3 + LLDPChassisIDSubTypeMACAddr LLDPChassisIDSubType = 4 + LLDPChassisIDSubTypeNetworkAddr LLDPChassisIDSubType = 5 + LLDPChassisIDSubtypeIfaceName LLDPChassisIDSubType = 6 + LLDPChassisIDSubTypeLocal LLDPChassisIDSubType = 7 +) + +type LLDPChassisID struct { + Subtype LLDPChassisIDSubType + ID []byte +} + +// LLDPPortIDSubType specifies the value type for a single LLDPPortID.ID +type LLDPPortIDSubType byte + +// LLDP PortID types +const ( + LLDPPortIDSubtypeReserved LLDPPortIDSubType = 0 + LLDPPortIDSubtypeIfaceAlias LLDPPortIDSubType = 1 + LLDPPortIDSubtypePortComp LLDPPortIDSubType = 2 + LLDPPortIDSubtypeMACAddr LLDPPortIDSubType = 3 + LLDPPortIDSubtypeNetworkAddr LLDPPortIDSubType = 4 + LLDPPortIDSubtypeIfaceName LLDPPortIDSubType = 5 + LLDPPortIDSubtypeAgentCircuitID LLDPPortIDSubType = 6 + LLDPPortIDSubtypeLocal LLDPPortIDSubType = 7 +) + +type LLDPPortID struct { + Subtype LLDPPortIDSubType + ID []byte +} + +// LinkLayerDiscovery is a packet layer containing the LinkLayer Discovery Protocol. +// See http:http://standards.ieee.org/getieee802/download/802.1AB-2009.pdf +// ChassisID, PortID and TTL are mandatory TLV's. Other values can be decoded +// with DecodeValues() +type LinkLayerDiscovery struct { + BaseLayer + ChassisID LLDPChassisID + PortID LLDPPortID + TTL uint16 + Values []LinkLayerDiscoveryValue +} + +type IEEEOUI uint32 + +// http://standards.ieee.org/develop/regauth/oui/oui.txt +const ( + IEEEOUI8021 IEEEOUI = 0x0080c2 + IEEEOUI8023 IEEEOUI = 0x00120f + IEEEOUI80211 IEEEOUI = 0x000fac + IEEEOUI8021Qbg IEEEOUI = 0x0013BF + IEEEOUICisco2 IEEEOUI = 0x000142 + IEEEOUIMedia IEEEOUI = 0x0012bb // TR-41 + IEEEOUIProfinet IEEEOUI = 0x000ecf + IEEEOUIDCBX IEEEOUI = 0x001b21 +) + +// LLDPOrgSpecificTLV is an Organisation-specific TLV +type LLDPOrgSpecificTLV struct { + OUI IEEEOUI + SubType uint8 + Info []byte +} + +// LLDPCapabilities Types +const ( + LLDPCapsOther uint16 = 1 << 0 + LLDPCapsRepeater uint16 = 1 << 1 + LLDPCapsBridge uint16 = 1 << 2 + LLDPCapsWLANAP uint16 = 1 << 3 + LLDPCapsRouter uint16 = 1 << 4 + LLDPCapsPhone uint16 = 1 << 5 + LLDPCapsDocSis uint16 = 1 << 6 + LLDPCapsStationOnly uint16 = 1 << 7 + LLDPCapsCVLAN uint16 = 1 << 8 + LLDPCapsSVLAN uint16 = 1 << 9 + LLDPCapsTmpr uint16 = 1 << 10 +) + +// LLDPCapabilities represents the capabilities of a device +type LLDPCapabilities struct { + Other bool + Repeater bool + Bridge bool + WLANAP bool + Router bool + Phone bool + DocSis bool + StationOnly bool + CVLAN bool + SVLAN bool + TMPR bool +} + +type LLDPSysCapabilities struct { + SystemCap LLDPCapabilities + EnabledCap LLDPCapabilities +} + +type IANAAddressFamily byte + +// LLDP Management Address Subtypes +// http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xml +const ( + IANAAddressFamilyReserved IANAAddressFamily = 0 + IANAAddressFamilyIPV4 IANAAddressFamily = 1 + IANAAddressFamilyIPV6 IANAAddressFamily = 2 + IANAAddressFamilyNSAP IANAAddressFamily = 3 + IANAAddressFamilyHDLC IANAAddressFamily = 4 + IANAAddressFamilyBBN1822 IANAAddressFamily = 5 + IANAAddressFamily802 IANAAddressFamily = 6 + IANAAddressFamilyE163 IANAAddressFamily = 7 + IANAAddressFamilyE164 IANAAddressFamily = 8 + IANAAddressFamilyF69 IANAAddressFamily = 9 + IANAAddressFamilyX121 IANAAddressFamily = 10 + IANAAddressFamilyIPX IANAAddressFamily = 11 + IANAAddressFamilyAtalk IANAAddressFamily = 12 + IANAAddressFamilyDecnet IANAAddressFamily = 13 + IANAAddressFamilyBanyan IANAAddressFamily = 14 + IANAAddressFamilyE164NSAP IANAAddressFamily = 15 + IANAAddressFamilyDNS IANAAddressFamily = 16 + IANAAddressFamilyDistname IANAAddressFamily = 17 + IANAAddressFamilyASNumber IANAAddressFamily = 18 + IANAAddressFamilyXTPIPV4 IANAAddressFamily = 19 + IANAAddressFamilyXTPIPV6 IANAAddressFamily = 20 + IANAAddressFamilyXTP IANAAddressFamily = 21 + IANAAddressFamilyFcWWPN IANAAddressFamily = 22 + IANAAddressFamilyFcWWNN IANAAddressFamily = 23 + IANAAddressFamilyGWID IANAAddressFamily = 24 + IANAAddressFamilyL2VPN IANAAddressFamily = 25 +) + +type LLDPInterfaceSubtype byte + +// LLDP Interface Subtypes +const ( + LLDPInterfaceSubtypeUnknown LLDPInterfaceSubtype = 1 + LLDPInterfaceSubtypeifIndex LLDPInterfaceSubtype = 2 + LLDPInterfaceSubtypeSysPort LLDPInterfaceSubtype = 3 +) + +type LLDPMgmtAddress struct { + Subtype IANAAddressFamily + Address []byte + InterfaceSubtype LLDPInterfaceSubtype + InterfaceNumber uint32 + OID string +} + +// LinkLayerDiscoveryInfo represents the decoded details for a set of LinkLayerDiscoveryValues +// Organisation-specific TLV's can be decoded using the various Decode() methods +type LinkLayerDiscoveryInfo struct { + BaseLayer + PortDescription string + SysName string + SysDescription string + SysCapabilities LLDPSysCapabilities + MgmtAddress LLDPMgmtAddress + OrgTLVs []LLDPOrgSpecificTLV // Private TLVs + Unknown []LinkLayerDiscoveryValue // undecoded TLVs +} + +/// IEEE 802.1 TLV Subtypes +const ( + LLDP8021SubtypePortVLANID uint8 = 1 + LLDP8021SubtypeProtocolVLANID uint8 = 2 + LLDP8021SubtypeVLANName uint8 = 3 + LLDP8021SubtypeProtocolIdentity uint8 = 4 + LLDP8021SubtypeVDIUsageDigest uint8 = 5 + LLDP8021SubtypeManagementVID uint8 = 6 + LLDP8021SubtypeLinkAggregation uint8 = 7 +) + +// VLAN Port Protocol ID options +const ( + LLDPProtocolVLANIDCapability byte = 1 << 1 + LLDPProtocolVLANIDStatus byte = 1 << 2 +) + +type PortProtocolVLANID struct { + Supported bool + Enabled bool + ID uint16 +} + +type VLANName struct { + ID uint16 + Name string +} + +type ProtocolIdentity []byte + +// LACP options +const ( + LLDPAggregationCapability byte = 1 << 0 + LLDPAggregationStatus byte = 1 << 1 +) + +// IEEE 802 Link Aggregation parameters +type LLDPLinkAggregation struct { + Supported bool + Enabled bool + PortID uint32 +} + +// LLDPInfo8021 represents the information carried in 802.1 Org-specific TLVs +type LLDPInfo8021 struct { + PVID uint16 + PPVIDs []PortProtocolVLANID + VLANNames []VLANName + ProtocolIdentities []ProtocolIdentity + VIDUsageDigest uint32 + ManagementVID uint16 + LinkAggregation LLDPLinkAggregation +} + +// IEEE 802.3 TLV Subtypes +const ( + LLDP8023SubtypeMACPHY uint8 = 1 + LLDP8023SubtypeMDIPower uint8 = 2 + LLDP8023SubtypeLinkAggregation uint8 = 3 + LLDP8023SubtypeMTU uint8 = 4 +) + +// MACPHY options +const ( + LLDPMACPHYCapability byte = 1 << 0 + LLDPMACPHYStatus byte = 1 << 1 +) + +// From IANA-MAU-MIB (introduced by RFC 4836) - dot3MauType +const ( + LLDPMAUTypeUnknown uint16 = 0 + LLDPMAUTypeAUI uint16 = 1 + LLDPMAUType10Base5 uint16 = 2 + LLDPMAUTypeFOIRL uint16 = 3 + LLDPMAUType10Base2 uint16 = 4 + LLDPMAUType10BaseT uint16 = 5 + LLDPMAUType10BaseFP uint16 = 6 + LLDPMAUType10BaseFB uint16 = 7 + LLDPMAUType10BaseFL uint16 = 8 + LLDPMAUType10BROAD36 uint16 = 9 + LLDPMAUType10BaseT_HD uint16 = 10 + LLDPMAUType10BaseT_FD uint16 = 11 + LLDPMAUType10BaseFL_HD uint16 = 12 + LLDPMAUType10BaseFL_FD uint16 = 13 + LLDPMAUType100BaseT4 uint16 = 14 + LLDPMAUType100BaseTX_HD uint16 = 15 + LLDPMAUType100BaseTX_FD uint16 = 16 + LLDPMAUType100BaseFX_HD uint16 = 17 + LLDPMAUType100BaseFX_FD uint16 = 18 + LLDPMAUType100BaseT2_HD uint16 = 19 + LLDPMAUType100BaseT2_FD uint16 = 20 + LLDPMAUType1000BaseX_HD uint16 = 21 + LLDPMAUType1000BaseX_FD uint16 = 22 + LLDPMAUType1000BaseLX_HD uint16 = 23 + LLDPMAUType1000BaseLX_FD uint16 = 24 + LLDPMAUType1000BaseSX_HD uint16 = 25 + LLDPMAUType1000BaseSX_FD uint16 = 26 + LLDPMAUType1000BaseCX_HD uint16 = 27 + LLDPMAUType1000BaseCX_FD uint16 = 28 + LLDPMAUType1000BaseT_HD uint16 = 29 + LLDPMAUType1000BaseT_FD uint16 = 30 + LLDPMAUType10GBaseX uint16 = 31 + LLDPMAUType10GBaseLX4 uint16 = 32 + LLDPMAUType10GBaseR uint16 = 33 + LLDPMAUType10GBaseER uint16 = 34 + LLDPMAUType10GBaseLR uint16 = 35 + LLDPMAUType10GBaseSR uint16 = 36 + LLDPMAUType10GBaseW uint16 = 37 + LLDPMAUType10GBaseEW uint16 = 38 + LLDPMAUType10GBaseLW uint16 = 39 + LLDPMAUType10GBaseSW uint16 = 40 + LLDPMAUType10GBaseCX4 uint16 = 41 + LLDPMAUType2BaseTL uint16 = 42 + LLDPMAUType10PASS_TS uint16 = 43 + LLDPMAUType100BaseBX10D uint16 = 44 + LLDPMAUType100BaseBX10U uint16 = 45 + LLDPMAUType100BaseLX10 uint16 = 46 + LLDPMAUType1000BaseBX10D uint16 = 47 + LLDPMAUType1000BaseBX10U uint16 = 48 + LLDPMAUType1000BaseLX10 uint16 = 49 + LLDPMAUType1000BasePX10D uint16 = 50 + LLDPMAUType1000BasePX10U uint16 = 51 + LLDPMAUType1000BasePX20D uint16 = 52 + LLDPMAUType1000BasePX20U uint16 = 53 + LLDPMAUType10GBaseT uint16 = 54 + LLDPMAUType10GBaseLRM uint16 = 55 + LLDPMAUType1000BaseKX uint16 = 56 + LLDPMAUType10GBaseKX4 uint16 = 57 + LLDPMAUType10GBaseKR uint16 = 58 + LLDPMAUType10_1GBasePRX_D1 uint16 = 59 + LLDPMAUType10_1GBasePRX_D2 uint16 = 60 + LLDPMAUType10_1GBasePRX_D3 uint16 = 61 + LLDPMAUType10_1GBasePRX_U1 uint16 = 62 + LLDPMAUType10_1GBasePRX_U2 uint16 = 63 + LLDPMAUType10_1GBasePRX_U3 uint16 = 64 + LLDPMAUType10GBasePR_D1 uint16 = 65 + LLDPMAUType10GBasePR_D2 uint16 = 66 + LLDPMAUType10GBasePR_D3 uint16 = 67 + LLDPMAUType10GBasePR_U1 uint16 = 68 + LLDPMAUType10GBasePR_U3 uint16 = 69 +) + +// From RFC 3636 - ifMauAutoNegCapAdvertisedBits +const ( + LLDPMAUPMDOther uint16 = 1 << 15 + LLDPMAUPMD10BaseT uint16 = 1 << 14 + LLDPMAUPMD10BaseT_FD uint16 = 1 << 13 + LLDPMAUPMD100BaseT4 uint16 = 1 << 12 + LLDPMAUPMD100BaseTX uint16 = 1 << 11 + LLDPMAUPMD100BaseTX_FD uint16 = 1 << 10 + LLDPMAUPMD100BaseT2 uint16 = 1 << 9 + LLDPMAUPMD100BaseT2_FD uint16 = 1 << 8 + LLDPMAUPMDFDXPAUSE uint16 = 1 << 7 + LLDPMAUPMDFDXAPAUSE uint16 = 1 << 6 + LLDPMAUPMDFDXSPAUSE uint16 = 1 << 5 + LLDPMAUPMDFDXBPAUSE uint16 = 1 << 4 + LLDPMAUPMD1000BaseX uint16 = 1 << 3 + LLDPMAUPMD1000BaseX_FD uint16 = 1 << 2 + LLDPMAUPMD1000BaseT uint16 = 1 << 1 + LLDPMAUPMD1000BaseT_FD uint16 = 1 << 0 +) + +// Inverted ifMauAutoNegCapAdvertisedBits if required +// (Some manufacturers misinterpreted the spec - +// see https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1455) +const ( + LLDPMAUPMDOtherInv uint16 = 1 << 0 + LLDPMAUPMD10BaseTInv uint16 = 1 << 1 + LLDPMAUPMD10BaseT_FDInv uint16 = 1 << 2 + LLDPMAUPMD100BaseT4Inv uint16 = 1 << 3 + LLDPMAUPMD100BaseTXInv uint16 = 1 << 4 + LLDPMAUPMD100BaseTX_FDInv uint16 = 1 << 5 + LLDPMAUPMD100BaseT2Inv uint16 = 1 << 6 + LLDPMAUPMD100BaseT2_FDInv uint16 = 1 << 7 + LLDPMAUPMDFDXPAUSEInv uint16 = 1 << 8 + LLDPMAUPMDFDXAPAUSEInv uint16 = 1 << 9 + LLDPMAUPMDFDXSPAUSEInv uint16 = 1 << 10 + LLDPMAUPMDFDXBPAUSEInv uint16 = 1 << 11 + LLDPMAUPMD1000BaseXInv uint16 = 1 << 12 + LLDPMAUPMD1000BaseX_FDInv uint16 = 1 << 13 + LLDPMAUPMD1000BaseTInv uint16 = 1 << 14 + LLDPMAUPMD1000BaseT_FDInv uint16 = 1 << 15 +) + +type LLDPMACPHYConfigStatus struct { + AutoNegSupported bool + AutoNegEnabled bool + AutoNegCapability uint16 + MAUType uint16 +} + +// MDI Power options +const ( + LLDPMDIPowerPortClass byte = 1 << 0 + LLDPMDIPowerCapability byte = 1 << 1 + LLDPMDIPowerStatus byte = 1 << 2 + LLDPMDIPowerPairsAbility byte = 1 << 3 +) + +type LLDPPowerType byte + +type LLDPPowerSource byte + +type LLDPPowerPriority byte + +const ( + LLDPPowerPriorityUnknown LLDPPowerPriority = 0 + LLDPPowerPriorityMedium LLDPPowerPriority = 1 + LLDPPowerPriorityHigh LLDPPowerPriority = 2 + LLDPPowerPriorityLow LLDPPowerPriority = 3 +) + +type LLDPPowerViaMDI8023 struct { + PortClassPSE bool // false = PD + PSESupported bool + PSEEnabled bool + PSEPairsAbility bool + PSEPowerPair uint8 + PSEClass uint8 + Type LLDPPowerType + Source LLDPPowerSource + Priority LLDPPowerPriority + Requested uint16 // 1-510 Watts + Allocated uint16 // 1-510 Watts +} + +// LLDPInfo8023 represents the information carried in 802.3 Org-specific TLVs +type LLDPInfo8023 struct { + MACPHYConfigStatus LLDPMACPHYConfigStatus + PowerViaMDI LLDPPowerViaMDI8023 + LinkAggregation LLDPLinkAggregation + MTU uint16 +} + +// IEEE 802.1Qbg TLV Subtypes +const ( + LLDP8021QbgEVB uint8 = 0 + LLDP8021QbgCDCP uint8 = 1 + LLDP8021QbgVDP uint8 = 2 + LLDP8021QbgEVB22 uint8 = 13 +) + +// LLDPEVBCapabilities Types +const ( + LLDPEVBCapsSTD uint16 = 1 << 7 + LLDPEVBCapsRR uint16 = 1 << 6 + LLDPEVBCapsRTE uint16 = 1 << 2 + LLDPEVBCapsECP uint16 = 1 << 1 + LLDPEVBCapsVDP uint16 = 1 << 0 +) + +// LLDPEVBCapabilities represents the EVB capabilities of a device +type LLDPEVBCapabilities struct { + StandardBridging bool + ReflectiveRelay bool + RetransmissionTimerExponent bool + EdgeControlProtocol bool + VSIDiscoveryProtocol bool +} + +type LLDPEVBSettings struct { + Supported LLDPEVBCapabilities + Enabled LLDPEVBCapabilities + SupportedVSIs uint16 + ConfiguredVSIs uint16 + RTEExponent uint8 +} + +// LLDPInfo8021Qbg represents the information carried in 802.1Qbg Org-specific TLVs +type LLDPInfo8021Qbg struct { + EVBSettings LLDPEVBSettings +} + +type LLDPMediaSubtype uint8 + +// Media TLV Subtypes +const ( + LLDPMediaTypeCapabilities LLDPMediaSubtype = 1 + LLDPMediaTypeNetwork LLDPMediaSubtype = 2 + LLDPMediaTypeLocation LLDPMediaSubtype = 3 + LLDPMediaTypePower LLDPMediaSubtype = 4 + LLDPMediaTypeHardware LLDPMediaSubtype = 5 + LLDPMediaTypeFirmware LLDPMediaSubtype = 6 + LLDPMediaTypeSoftware LLDPMediaSubtype = 7 + LLDPMediaTypeSerial LLDPMediaSubtype = 8 + LLDPMediaTypeManufacturer LLDPMediaSubtype = 9 + LLDPMediaTypeModel LLDPMediaSubtype = 10 + LLDPMediaTypeAssetID LLDPMediaSubtype = 11 +) + +type LLDPMediaClass uint8 + +// Media Class Values +const ( + LLDPMediaClassUndefined LLDPMediaClass = 0 + LLDPMediaClassEndpointI LLDPMediaClass = 1 + LLDPMediaClassEndpointII LLDPMediaClass = 2 + LLDPMediaClassEndpointIII LLDPMediaClass = 3 + LLDPMediaClassNetwork LLDPMediaClass = 4 +) + +// LLDPMediaCapabilities Types +const ( + LLDPMediaCapsLLDP uint16 = 1 << 0 + LLDPMediaCapsNetwork uint16 = 1 << 1 + LLDPMediaCapsLocation uint16 = 1 << 2 + LLDPMediaCapsPowerPSE uint16 = 1 << 3 + LLDPMediaCapsPowerPD uint16 = 1 << 4 + LLDPMediaCapsInventory uint16 = 1 << 5 +) + +// LLDPMediaCapabilities represents the LLDP Media capabilities of a device +type LLDPMediaCapabilities struct { + Capabilities bool + NetworkPolicy bool + Location bool + PowerPSE bool + PowerPD bool + Inventory bool + Class LLDPMediaClass +} + +type LLDPApplicationType uint8 + +const ( + LLDPAppTypeReserved LLDPApplicationType = 0 + LLDPAppTypeVoice LLDPApplicationType = 1 + LLDPappTypeVoiceSignaling LLDPApplicationType = 2 + LLDPappTypeGuestVoice LLDPApplicationType = 3 + LLDPappTypeGuestVoiceSignaling LLDPApplicationType = 4 + LLDPappTypeSoftphoneVoice LLDPApplicationType = 5 + LLDPappTypeVideoConferencing LLDPApplicationType = 6 + LLDPappTypeStreamingVideo LLDPApplicationType = 7 + LLDPappTypeVideoSignaling LLDPApplicationType = 8 +) + +type LLDPNetworkPolicy struct { + ApplicationType LLDPApplicationType + Defined bool + Tagged bool + VLANId uint16 + L2Priority uint16 + DSCPValue uint8 +} + +type LLDPLocationFormat uint8 + +const ( + LLDPLocationFormatInvalid LLDPLocationFormat = 0 + LLDPLocationFormatCoordinate LLDPLocationFormat = 1 + LLDPLocationFormatAddress LLDPLocationFormat = 2 + LLDPLocationFormatECS LLDPLocationFormat = 3 +) + +type LLDPLocationAddressWhat uint8 + +const ( + LLDPLocationAddressWhatDHCP LLDPLocationAddressWhat = 0 + LLDPLocationAddressWhatNetwork LLDPLocationAddressWhat = 1 + LLDPLocationAddressWhatClient LLDPLocationAddressWhat = 2 +) + +type LLDPLocationAddressType uint8 + +const ( + LLDPLocationAddressTypeLanguage LLDPLocationAddressType = 0 + LLDPLocationAddressTypeNational LLDPLocationAddressType = 1 + LLDPLocationAddressTypeCounty LLDPLocationAddressType = 2 + LLDPLocationAddressTypeCity LLDPLocationAddressType = 3 + LLDPLocationAddressTypeCityDivision LLDPLocationAddressType = 4 + LLDPLocationAddressTypeNeighborhood LLDPLocationAddressType = 5 + LLDPLocationAddressTypeStreet LLDPLocationAddressType = 6 + LLDPLocationAddressTypeLeadingStreet LLDPLocationAddressType = 16 + LLDPLocationAddressTypeTrailingStreet LLDPLocationAddressType = 17 + LLDPLocationAddressTypeStreetSuffix LLDPLocationAddressType = 18 + LLDPLocationAddressTypeHouseNum LLDPLocationAddressType = 19 + LLDPLocationAddressTypeHouseSuffix LLDPLocationAddressType = 20 + LLDPLocationAddressTypeLandmark LLDPLocationAddressType = 21 + LLDPLocationAddressTypeAdditional LLDPLocationAddressType = 22 + LLDPLocationAddressTypeName LLDPLocationAddressType = 23 + LLDPLocationAddressTypePostal LLDPLocationAddressType = 24 + LLDPLocationAddressTypeBuilding LLDPLocationAddressType = 25 + LLDPLocationAddressTypeUnit LLDPLocationAddressType = 26 + LLDPLocationAddressTypeFloor LLDPLocationAddressType = 27 + LLDPLocationAddressTypeRoom LLDPLocationAddressType = 28 + LLDPLocationAddressTypePlace LLDPLocationAddressType = 29 + LLDPLocationAddressTypeScript LLDPLocationAddressType = 128 +) + +type LLDPLocationCoordinate struct { + LatitudeResolution uint8 + Latitude uint64 + LongitudeResolution uint8 + Longitude uint64 + AltitudeType uint8 + AltitudeResolution uint16 + Altitude uint32 + Datum uint8 +} + +type LLDPLocationAddressLine struct { + Type LLDPLocationAddressType + Value string +} + +type LLDPLocationAddress struct { + What LLDPLocationAddressWhat + CountryCode string + AddressLines []LLDPLocationAddressLine +} + +type LLDPLocationECS struct { + ELIN string +} + +// LLDP represents a physical location. +// Only one of the embedded types will contain values, depending on Format. +type LLDPLocation struct { + Format LLDPLocationFormat + Coordinate LLDPLocationCoordinate + Address LLDPLocationAddress + ECS LLDPLocationECS +} + +type LLDPPowerViaMDI struct { + Type LLDPPowerType + Source LLDPPowerSource + Priority LLDPPowerPriority + Value uint16 +} + +// LLDPInfoMedia represents the information carried in TR-41 Org-specific TLVs +type LLDPInfoMedia struct { + MediaCapabilities LLDPMediaCapabilities + NetworkPolicy LLDPNetworkPolicy + Location LLDPLocation + PowerViaMDI LLDPPowerViaMDI + HardwareRevision string + FirmwareRevision string + SoftwareRevision string + SerialNumber string + Manufacturer string + Model string + AssetID string +} + +type LLDPCisco2Subtype uint8 + +// Cisco2 TLV Subtypes +const ( + LLDPCisco2PowerViaMDI LLDPCisco2Subtype = 1 +) + +const ( + LLDPCiscoPSESupport uint8 = 1 << 0 + LLDPCiscoArchShared uint8 = 1 << 1 + LLDPCiscoPDSparePair uint8 = 1 << 2 + LLDPCiscoPSESparePair uint8 = 1 << 3 +) + +// LLDPInfoCisco2 represents the information carried in Cisco Org-specific TLVs +type LLDPInfoCisco2 struct { + PSEFourWirePoESupported bool + PDSparePairArchitectureShared bool + PDRequestSparePairPoEOn bool + PSESparePairPoEOn bool +} + +// Profinet Subtypes +type LLDPProfinetSubtype uint8 + +const ( + LLDPProfinetPNIODelay LLDPProfinetSubtype = 1 + LLDPProfinetPNIOPortStatus LLDPProfinetSubtype = 2 + LLDPProfinetPNIOMRPPortStatus LLDPProfinetSubtype = 4 + LLDPProfinetPNIOChassisMAC LLDPProfinetSubtype = 5 + LLDPProfinetPNIOPTCPStatus LLDPProfinetSubtype = 6 +) + +type LLDPPNIODelay struct { + RXLocal uint32 + RXRemote uint32 + TXLocal uint32 + TXRemote uint32 + CableLocal uint32 +} + +type LLDPPNIOPortStatus struct { + Class2 uint16 + Class3 uint16 +} + +type LLDPPNIOMRPPortStatus struct { + UUID []byte + Status uint16 +} + +type LLDPPNIOPTCPStatus struct { + MasterAddress []byte + SubdomainUUID []byte + IRDataUUID []byte + PeriodValid bool + PeriodLength uint32 + RedPeriodValid bool + RedPeriodBegin uint32 + OrangePeriodValid bool + OrangePeriodBegin uint32 + GreenPeriodValid bool + GreenPeriodBegin uint32 +} + +// LLDPInfoProfinet represents the information carried in Profinet Org-specific TLVs +type LLDPInfoProfinet struct { + PNIODelay LLDPPNIODelay + PNIOPortStatus LLDPPNIOPortStatus + PNIOMRPPortStatus LLDPPNIOMRPPortStatus + ChassisMAC []byte + PNIOPTCPStatus LLDPPNIOPTCPStatus +} + +// LayerType returns gopacket.LayerTypeLinkLayerDiscovery. +func (c *LinkLayerDiscovery) LayerType() gopacket.LayerType { + return LayerTypeLinkLayerDiscovery +} + +func decodeLinkLayerDiscovery(data []byte, p gopacket.PacketBuilder) error { + var vals []LinkLayerDiscoveryValue + vData := data[0:] + for len(vData) > 0 { + nbit := vData[0] & 0x01 + t := LLDPTLVType(vData[0] >> 1) + val := LinkLayerDiscoveryValue{Type: t, Length: uint16(nbit)<<8 + uint16(vData[1])} + if val.Length > 0 { + val.Value = vData[2 : val.Length+2] + } + vals = append(vals, val) + if t == LLDPTLVEnd { + break + } + if len(vData) < int(2+val.Length) { + return errors.New("Malformed LinkLayerDiscovery Header") + } + vData = vData[2+val.Length:] + } + if len(vals) < 4 { + return errors.New("Missing mandatory LinkLayerDiscovery TLV") + } + c := &LinkLayerDiscovery{} + gotEnd := false + for _, v := range vals { + switch v.Type { + case LLDPTLVEnd: + gotEnd = true + case LLDPTLVChassisID: + if len(v.Value) < 2 { + return errors.New("Malformed LinkLayerDiscovery ChassisID TLV") + } + c.ChassisID.Subtype = LLDPChassisIDSubType(v.Value[0]) + c.ChassisID.ID = v.Value[1:] + case LLDPTLVPortID: + if len(v.Value) < 2 { + return errors.New("Malformed LinkLayerDiscovery PortID TLV") + } + c.PortID.Subtype = LLDPPortIDSubType(v.Value[0]) + c.PortID.ID = v.Value[1:] + case LLDPTLVTTL: + if len(v.Value) < 2 { + return errors.New("Malformed LinkLayerDiscovery TTL TLV") + } + c.TTL = binary.BigEndian.Uint16(v.Value[0:2]) + default: + c.Values = append(c.Values, v) + } + } + if c.ChassisID.Subtype == 0 || c.PortID.Subtype == 0 || !gotEnd { + return errors.New("Missing mandatory LinkLayerDiscovery TLV") + } + c.Contents = data + p.AddLayer(c) + + info := &LinkLayerDiscoveryInfo{} + p.AddLayer(info) + for _, v := range c.Values { + switch v.Type { + case LLDPTLVPortDescription: + info.PortDescription = string(v.Value) + case LLDPTLVSysName: + info.SysName = string(v.Value) + case LLDPTLVSysDescription: + info.SysDescription = string(v.Value) + case LLDPTLVSysCapabilities: + if err := checkLLDPTLVLen(v, 4); err != nil { + return err + } + info.SysCapabilities.SystemCap = getCapabilities(binary.BigEndian.Uint16(v.Value[0:2])) + info.SysCapabilities.EnabledCap = getCapabilities(binary.BigEndian.Uint16(v.Value[2:4])) + case LLDPTLVMgmtAddress: + if err := checkLLDPTLVLen(v, 9); err != nil { + return err + } + mlen := v.Value[0] + if err := checkLLDPTLVLen(v, int(mlen+7)); err != nil { + return err + } + info.MgmtAddress.Subtype = IANAAddressFamily(v.Value[1]) + info.MgmtAddress.Address = v.Value[2 : mlen+1] + info.MgmtAddress.InterfaceSubtype = LLDPInterfaceSubtype(v.Value[mlen+1]) + info.MgmtAddress.InterfaceNumber = binary.BigEndian.Uint32(v.Value[mlen+2 : mlen+6]) + olen := v.Value[mlen+6] + if err := checkLLDPTLVLen(v, int(mlen+6+olen)); err != nil { + return err + } + info.MgmtAddress.OID = string(v.Value[mlen+9 : mlen+9+olen]) + case LLDPTLVOrgSpecific: + if err := checkLLDPTLVLen(v, 4); err != nil { + return err + } + info.OrgTLVs = append(info.OrgTLVs, LLDPOrgSpecificTLV{IEEEOUI(binary.BigEndian.Uint32(append([]byte{byte(0)}, v.Value[0:3]...))), uint8(v.Value[3]), v.Value[4:]}) + } + } + return nil +} + +func (l *LinkLayerDiscoveryInfo) Decode8021() (info LLDPInfo8021, err error) { + for _, o := range l.OrgTLVs { + if o.OUI != IEEEOUI8021 { + continue + } + switch o.SubType { + case LLDP8021SubtypePortVLANID: + if err = checkLLDPOrgSpecificLen(o, 2); err != nil { + return + } + info.PVID = binary.BigEndian.Uint16(o.Info[0:2]) + case LLDP8021SubtypeProtocolVLANID: + if err = checkLLDPOrgSpecificLen(o, 3); err != nil { + return + } + sup := (o.Info[0]&LLDPProtocolVLANIDCapability > 0) + en := (o.Info[0]&LLDPProtocolVLANIDStatus > 0) + id := binary.BigEndian.Uint16(o.Info[1:3]) + info.PPVIDs = append(info.PPVIDs, PortProtocolVLANID{sup, en, id}) + case LLDP8021SubtypeVLANName: + if err = checkLLDPOrgSpecificLen(o, 2); err != nil { + return + } + id := binary.BigEndian.Uint16(o.Info[0:2]) + info.VLANNames = append(info.VLANNames, VLANName{id, string(o.Info[3:])}) + case LLDP8021SubtypeProtocolIdentity: + if err = checkLLDPOrgSpecificLen(o, 1); err != nil { + return + } + l := int(o.Info[0]) + if l > 0 { + info.ProtocolIdentities = append(info.ProtocolIdentities, o.Info[1:1+l]) + } + case LLDP8021SubtypeVDIUsageDigest: + if err = checkLLDPOrgSpecificLen(o, 4); err != nil { + return + } + info.VIDUsageDigest = binary.BigEndian.Uint32(o.Info[0:4]) + case LLDP8021SubtypeManagementVID: + if err = checkLLDPOrgSpecificLen(o, 2); err != nil { + return + } + info.ManagementVID = binary.BigEndian.Uint16(o.Info[0:2]) + case LLDP8021SubtypeLinkAggregation: + if err = checkLLDPOrgSpecificLen(o, 5); err != nil { + return + } + sup := (o.Info[0]&LLDPAggregationCapability > 0) + en := (o.Info[0]&LLDPAggregationStatus > 0) + info.LinkAggregation = LLDPLinkAggregation{sup, en, binary.BigEndian.Uint32(o.Info[1:5])} + } + } + return +} + +func (l *LinkLayerDiscoveryInfo) Decode8023() (info LLDPInfo8023, err error) { + for _, o := range l.OrgTLVs { + if o.OUI != IEEEOUI8023 { + continue + } + switch o.SubType { + case LLDP8023SubtypeMACPHY: + if err = checkLLDPOrgSpecificLen(o, 5); err != nil { + return + } + sup := (o.Info[0]&LLDPMACPHYCapability > 0) + en := (o.Info[0]&LLDPMACPHYStatus > 0) + ca := binary.BigEndian.Uint16(o.Info[1:3]) + mau := binary.BigEndian.Uint16(o.Info[3:5]) + info.MACPHYConfigStatus = LLDPMACPHYConfigStatus{sup, en, ca, mau} + case LLDP8023SubtypeMDIPower: + if err = checkLLDPOrgSpecificLen(o, 3); err != nil { + return + } + info.PowerViaMDI.PortClassPSE = (o.Info[0]&LLDPMDIPowerPortClass > 0) + info.PowerViaMDI.PSESupported = (o.Info[0]&LLDPMDIPowerCapability > 0) + info.PowerViaMDI.PSEEnabled = (o.Info[0]&LLDPMDIPowerStatus > 0) + info.PowerViaMDI.PSEPairsAbility = (o.Info[0]&LLDPMDIPowerPairsAbility > 0) + info.PowerViaMDI.PSEPowerPair = uint8(o.Info[1]) + info.PowerViaMDI.PSEClass = uint8(o.Info[2]) + if len(o.Info) >= 7 { + info.PowerViaMDI.Type = LLDPPowerType((o.Info[3] & 0xc0) >> 6) + info.PowerViaMDI.Source = LLDPPowerSource((o.Info[3] & 0x30) >> 4) + if info.PowerViaMDI.Type == 1 || info.PowerViaMDI.Type == 3 { + info.PowerViaMDI.Source += 128 // For Stringify purposes + } + info.PowerViaMDI.Priority = LLDPPowerPriority(o.Info[3] & 0x0f) + info.PowerViaMDI.Requested = binary.BigEndian.Uint16(o.Info[4:6]) + info.PowerViaMDI.Allocated = binary.BigEndian.Uint16(o.Info[6:8]) + } + case LLDP8023SubtypeLinkAggregation: + if err = checkLLDPOrgSpecificLen(o, 5); err != nil { + return + } + sup := (o.Info[0]&LLDPAggregationCapability > 0) + en := (o.Info[0]&LLDPAggregationStatus > 0) + info.LinkAggregation = LLDPLinkAggregation{sup, en, binary.BigEndian.Uint32(o.Info[1:5])} + case LLDP8023SubtypeMTU: + if err = checkLLDPOrgSpecificLen(o, 2); err != nil { + return + } + info.MTU = binary.BigEndian.Uint16(o.Info[0:2]) + } + } + return +} + +func (l *LinkLayerDiscoveryInfo) Decode8021Qbg() (info LLDPInfo8021Qbg, err error) { + for _, o := range l.OrgTLVs { + if o.OUI != IEEEOUI8021Qbg { + continue + } + switch o.SubType { + case LLDP8021QbgEVB: + if err = checkLLDPOrgSpecificLen(o, 9); err != nil { + return + } + info.EVBSettings.Supported = getEVBCapabilities(binary.BigEndian.Uint16(o.Info[0:2])) + info.EVBSettings.Enabled = getEVBCapabilities(binary.BigEndian.Uint16(o.Info[2:4])) + info.EVBSettings.SupportedVSIs = binary.BigEndian.Uint16(o.Info[4:6]) + info.EVBSettings.ConfiguredVSIs = binary.BigEndian.Uint16(o.Info[6:8]) + info.EVBSettings.RTEExponent = uint8(o.Info[8]) + } + } + return +} + +func (l *LinkLayerDiscoveryInfo) DecodeMedia() (info LLDPInfoMedia, err error) { + for _, o := range l.OrgTLVs { + if o.OUI != IEEEOUIMedia { + continue + } + switch LLDPMediaSubtype(o.SubType) { + case LLDPMediaTypeCapabilities: + if err = checkLLDPOrgSpecificLen(o, 3); err != nil { + return + } + b := binary.BigEndian.Uint16(o.Info[0:2]) + info.MediaCapabilities.Capabilities = (b & LLDPMediaCapsLLDP) > 0 + info.MediaCapabilities.NetworkPolicy = (b & LLDPMediaCapsNetwork) > 0 + info.MediaCapabilities.Location = (b & LLDPMediaCapsLocation) > 0 + info.MediaCapabilities.PowerPSE = (b & LLDPMediaCapsPowerPSE) > 0 + info.MediaCapabilities.PowerPD = (b & LLDPMediaCapsPowerPD) > 0 + info.MediaCapabilities.Inventory = (b & LLDPMediaCapsInventory) > 0 + info.MediaCapabilities.Class = LLDPMediaClass(o.Info[2]) + case LLDPMediaTypeNetwork: + if err = checkLLDPOrgSpecificLen(o, 4); err != nil { + return + } + info.NetworkPolicy.ApplicationType = LLDPApplicationType(o.Info[0]) + b := binary.BigEndian.Uint16(o.Info[1:3]) + info.NetworkPolicy.Defined = (b & 0x8000) == 0 + info.NetworkPolicy.Tagged = (b & 0x4000) > 0 + info.NetworkPolicy.VLANId = (b & 0x1ffe) >> 1 + b = binary.BigEndian.Uint16(o.Info[2:4]) + info.NetworkPolicy.L2Priority = (b & 0x01c0) >> 6 + info.NetworkPolicy.DSCPValue = uint8(o.Info[3] & 0x3f) + case LLDPMediaTypeLocation: + if err = checkLLDPOrgSpecificLen(o, 1); err != nil { + return + } + info.Location.Format = LLDPLocationFormat(o.Info[0]) + o.Info = o.Info[1:] + switch info.Location.Format { + case LLDPLocationFormatCoordinate: + if err = checkLLDPOrgSpecificLen(o, 16); err != nil { + return + } + info.Location.Coordinate.LatitudeResolution = uint8(o.Info[0]&0xfc) >> 2 + b := binary.BigEndian.Uint64(o.Info[0:8]) + info.Location.Coordinate.Latitude = (b & 0x03ffffffff000000) >> 24 + info.Location.Coordinate.LongitudeResolution = uint8(o.Info[5]&0xfc) >> 2 + b = binary.BigEndian.Uint64(o.Info[5:13]) + info.Location.Coordinate.Longitude = (b & 0x03ffffffff000000) >> 24 + info.Location.Coordinate.AltitudeType = uint8((o.Info[10] & 0x30) >> 4) + b1 := binary.BigEndian.Uint16(o.Info[10:12]) + info.Location.Coordinate.AltitudeResolution = (b1 & 0xfc0) >> 6 + b2 := binary.BigEndian.Uint32(o.Info[11:15]) + info.Location.Coordinate.Altitude = b2 & 0x3fffffff + info.Location.Coordinate.Datum = uint8(o.Info[15]) + case LLDPLocationFormatAddress: + if err = checkLLDPOrgSpecificLen(o, 3); err != nil { + return + } + //ll := uint8(o.Info[0]) + info.Location.Address.What = LLDPLocationAddressWhat(o.Info[1]) + info.Location.Address.CountryCode = string(o.Info[2:4]) + data := o.Info[4:] + for len(data) > 1 { + aType := LLDPLocationAddressType(data[0]) + aLen := int(data[1]) + if len(data) >= aLen+2 { + info.Location.Address.AddressLines = append(info.Location.Address.AddressLines, LLDPLocationAddressLine{aType, string(data[2 : aLen+2])}) + data = data[aLen+2:] + } else { + break + } + } + case LLDPLocationFormatECS: + info.Location.ECS.ELIN = string(o.Info) + } + case LLDPMediaTypePower: + if err = checkLLDPOrgSpecificLen(o, 3); err != nil { + return + } + info.PowerViaMDI.Type = LLDPPowerType((o.Info[0] & 0xc0) >> 6) + info.PowerViaMDI.Source = LLDPPowerSource((o.Info[0] & 0x30) >> 4) + if info.PowerViaMDI.Type == 1 || info.PowerViaMDI.Type == 3 { + info.PowerViaMDI.Source += 128 // For Stringify purposes + } + info.PowerViaMDI.Priority = LLDPPowerPriority(o.Info[0] & 0x0f) + info.PowerViaMDI.Value = binary.BigEndian.Uint16(o.Info[1:3]) * 100 // 0 to 102.3 w, 0.1W increments + case LLDPMediaTypeHardware: + info.HardwareRevision = string(o.Info) + case LLDPMediaTypeFirmware: + info.FirmwareRevision = string(o.Info) + case LLDPMediaTypeSoftware: + info.SoftwareRevision = string(o.Info) + case LLDPMediaTypeSerial: + info.SerialNumber = string(o.Info) + case LLDPMediaTypeManufacturer: + info.Manufacturer = string(o.Info) + case LLDPMediaTypeModel: + info.Model = string(o.Info) + case LLDPMediaTypeAssetID: + info.AssetID = string(o.Info) + } + } + return +} + +func (l *LinkLayerDiscoveryInfo) DecodeCisco2() (info LLDPInfoCisco2, err error) { + for _, o := range l.OrgTLVs { + if o.OUI != IEEEOUICisco2 { + continue + } + switch LLDPCisco2Subtype(o.SubType) { + case LLDPCisco2PowerViaMDI: + if err = checkLLDPOrgSpecificLen(o, 1); err != nil { + return + } + info.PSEFourWirePoESupported = (o.Info[0] & LLDPCiscoPSESupport) > 0 + info.PDSparePairArchitectureShared = (o.Info[0] & LLDPCiscoArchShared) > 0 + info.PDRequestSparePairPoEOn = (o.Info[0] & LLDPCiscoPDSparePair) > 0 + info.PSESparePairPoEOn = (o.Info[0] & LLDPCiscoPSESparePair) > 0 + } + } + return +} + +func (l *LinkLayerDiscoveryInfo) DecodeProfinet() (info LLDPInfoProfinet, err error) { + for _, o := range l.OrgTLVs { + if o.OUI != IEEEOUIProfinet { + continue + } + switch LLDPProfinetSubtype(o.SubType) { + case LLDPProfinetPNIODelay: + if err = checkLLDPOrgSpecificLen(o, 20); err != nil { + return + } + info.PNIODelay.RXLocal = binary.BigEndian.Uint32(o.Info[0:4]) + info.PNIODelay.RXRemote = binary.BigEndian.Uint32(o.Info[4:8]) + info.PNIODelay.TXLocal = binary.BigEndian.Uint32(o.Info[8:12]) + info.PNIODelay.TXRemote = binary.BigEndian.Uint32(o.Info[12:16]) + info.PNIODelay.CableLocal = binary.BigEndian.Uint32(o.Info[16:20]) + case LLDPProfinetPNIOPortStatus: + if err = checkLLDPOrgSpecificLen(o, 4); err != nil { + return + } + info.PNIOPortStatus.Class2 = binary.BigEndian.Uint16(o.Info[0:2]) + info.PNIOPortStatus.Class3 = binary.BigEndian.Uint16(o.Info[2:4]) + case LLDPProfinetPNIOMRPPortStatus: + if err = checkLLDPOrgSpecificLen(o, 18); err != nil { + return + } + info.PNIOMRPPortStatus.UUID = o.Info[0:16] + info.PNIOMRPPortStatus.Status = binary.BigEndian.Uint16(o.Info[16:18]) + case LLDPProfinetPNIOChassisMAC: + if err = checkLLDPOrgSpecificLen(o, 6); err != nil { + return + } + info.ChassisMAC = o.Info[0:6] + case LLDPProfinetPNIOPTCPStatus: + if err = checkLLDPOrgSpecificLen(o, 54); err != nil { + return + } + info.PNIOPTCPStatus.MasterAddress = o.Info[0:6] + info.PNIOPTCPStatus.SubdomainUUID = o.Info[6:22] + info.PNIOPTCPStatus.IRDataUUID = o.Info[22:38] + b := binary.BigEndian.Uint32(o.Info[38:42]) + info.PNIOPTCPStatus.PeriodValid = (b & 0x80000000) > 0 + info.PNIOPTCPStatus.PeriodLength = b & 0x7fffffff + b = binary.BigEndian.Uint32(o.Info[42:46]) + info.PNIOPTCPStatus.RedPeriodValid = (b & 0x80000000) > 0 + info.PNIOPTCPStatus.RedPeriodBegin = b & 0x7fffffff + b = binary.BigEndian.Uint32(o.Info[46:50]) + info.PNIOPTCPStatus.OrangePeriodValid = (b & 0x80000000) > 0 + info.PNIOPTCPStatus.OrangePeriodBegin = b & 0x7fffffff + b = binary.BigEndian.Uint32(o.Info[50:54]) + info.PNIOPTCPStatus.GreenPeriodValid = (b & 0x80000000) > 0 + info.PNIOPTCPStatus.GreenPeriodBegin = b & 0x7fffffff + } + } + return +} + +// LayerType returns gopacket.LayerTypeLinkLayerDiscoveryInfo. +func (c *LinkLayerDiscoveryInfo) LayerType() gopacket.LayerType { + return LayerTypeLinkLayerDiscoveryInfo +} + +func getCapabilities(v uint16) (c LLDPCapabilities) { + c.Other = (v&LLDPCapsOther > 0) + c.Repeater = (v&LLDPCapsRepeater > 0) + c.Bridge = (v&LLDPCapsBridge > 0) + c.WLANAP = (v&LLDPCapsWLANAP > 0) + c.Router = (v&LLDPCapsRouter > 0) + c.Phone = (v&LLDPCapsPhone > 0) + c.DocSis = (v&LLDPCapsDocSis > 0) + c.StationOnly = (v&LLDPCapsStationOnly > 0) + c.CVLAN = (v&LLDPCapsCVLAN > 0) + c.SVLAN = (v&LLDPCapsSVLAN > 0) + c.TMPR = (v&LLDPCapsTmpr > 0) + return +} + +func getEVBCapabilities(v uint16) (c LLDPEVBCapabilities) { + c.StandardBridging = (v & LLDPEVBCapsSTD) > 0 + c.StandardBridging = (v & LLDPEVBCapsSTD) > 0 + c.ReflectiveRelay = (v & LLDPEVBCapsRR) > 0 + c.RetransmissionTimerExponent = (v & LLDPEVBCapsRTE) > 0 + c.EdgeControlProtocol = (v & LLDPEVBCapsECP) > 0 + c.VSIDiscoveryProtocol = (v & LLDPEVBCapsVDP) > 0 + return +} + +func (t LLDPTLVType) String() (s string) { + switch t { + case LLDPTLVEnd: + s = "TLV End" + case LLDPTLVChassisID: + s = "Chassis ID" + case LLDPTLVPortID: + s = "Port ID" + case LLDPTLVTTL: + s = "TTL" + case LLDPTLVPortDescription: + s = "Port Description" + case LLDPTLVSysName: + s = "System Name" + case LLDPTLVSysDescription: + s = "System Description" + case LLDPTLVSysCapabilities: + s = "System Capabilities" + case LLDPTLVMgmtAddress: + s = "Management Address" + case LLDPTLVOrgSpecific: + s = "Organisation Specific" + default: + s = "Unknown" + } + return +} + +func (t LLDPChassisIDSubType) String() (s string) { + switch t { + case LLDPChassisIDSubTypeReserved: + s = "Reserved" + case LLDPChassisIDSubTypeChassisComp: + s = "Chassis Component" + case LLDPChassisIDSubtypeIfaceAlias: + s = "Interface Alias" + case LLDPChassisIDSubTypePortComp: + s = "Port Component" + case LLDPChassisIDSubTypeMACAddr: + s = "MAC Address" + case LLDPChassisIDSubTypeNetworkAddr: + s = "Network Address" + case LLDPChassisIDSubtypeIfaceName: + s = "Interface Name" + case LLDPChassisIDSubTypeLocal: + s = "Local" + default: + s = "Unknown" + } + return +} + +func (t LLDPPortIDSubType) String() (s string) { + switch t { + case LLDPPortIDSubtypeReserved: + s = "Reserved" + case LLDPPortIDSubtypeIfaceAlias: + s = "Interface Alias" + case LLDPPortIDSubtypePortComp: + s = "Port Component" + case LLDPPortIDSubtypeMACAddr: + s = "MAC Address" + case LLDPPortIDSubtypeNetworkAddr: + s = "Network Address" + case LLDPPortIDSubtypeIfaceName: + s = "Interface Name" + case LLDPPortIDSubtypeAgentCircuitID: + s = "Agent Circuit ID" + case LLDPPortIDSubtypeLocal: + s = "Local" + default: + s = "Unknown" + } + return +} + +func (t IANAAddressFamily) String() (s string) { + switch t { + case IANAAddressFamilyReserved: + s = "Reserved" + case IANAAddressFamilyIPV4: + s = "IPv4" + case IANAAddressFamilyIPV6: + s = "IPv6" + case IANAAddressFamilyNSAP: + s = "NSAP" + case IANAAddressFamilyHDLC: + s = "HDLC" + case IANAAddressFamilyBBN1822: + s = "BBN 1822" + case IANAAddressFamily802: + s = "802 media plus Ethernet 'canonical format'" + case IANAAddressFamilyE163: + s = "E.163" + case IANAAddressFamilyE164: + s = "E.164 (SMDS, Frame Relay, ATM)" + case IANAAddressFamilyF69: + s = "F.69 (Telex)" + case IANAAddressFamilyX121: + s = "X.121, X.25, Frame Relay" + case IANAAddressFamilyIPX: + s = "IPX" + case IANAAddressFamilyAtalk: + s = "Appletalk" + case IANAAddressFamilyDecnet: + s = "Decnet IV" + case IANAAddressFamilyBanyan: + s = "Banyan Vines" + case IANAAddressFamilyE164NSAP: + s = "E.164 with NSAP format subaddress" + case IANAAddressFamilyDNS: + s = "DNS" + case IANAAddressFamilyDistname: + s = "Distinguished Name" + case IANAAddressFamilyASNumber: + s = "AS Number" + case IANAAddressFamilyXTPIPV4: + s = "XTP over IP version 4" + case IANAAddressFamilyXTPIPV6: + s = "XTP over IP version 6" + case IANAAddressFamilyXTP: + s = "XTP native mode XTP" + case IANAAddressFamilyFcWWPN: + s = "Fibre Channel World-Wide Port Name" + case IANAAddressFamilyFcWWNN: + s = "Fibre Channel World-Wide Node Name" + case IANAAddressFamilyGWID: + s = "GWID" + case IANAAddressFamilyL2VPN: + s = "AFI for Layer 2 VPN" + default: + s = "Unknown" + } + return +} + +func (t LLDPInterfaceSubtype) String() (s string) { + switch t { + case LLDPInterfaceSubtypeUnknown: + s = "Unknown" + case LLDPInterfaceSubtypeifIndex: + s = "IfIndex" + case LLDPInterfaceSubtypeSysPort: + s = "System Port Number" + default: + s = "Unknown" + } + return +} + +func (t LLDPPowerType) String() (s string) { + switch t { + case 0: + s = "Type 2 PSE Device" + case 1: + s = "Type 2 PD Device" + case 2: + s = "Type 1 PSE Device" + case 3: + s = "Type 1 PD Device" + default: + s = "Unknown" + } + return +} + +func (t LLDPPowerSource) String() (s string) { + switch t { + // PD Device + case 0: + s = "Unknown" + case 1: + s = "PSE" + case 2: + s = "Local" + case 3: + s = "PSE and Local" + // PSE Device (Actual value + 128) + case 128: + s = "Unknown" + case 129: + s = "Primary Power Source" + case 130: + s = "Backup Power Source" + default: + s = "Unknown" + } + return +} + +func (t LLDPPowerPriority) String() (s string) { + switch t { + case 0: + s = "Unknown" + case 1: + s = "Critical" + case 2: + s = "High" + case 3: + s = "Low" + default: + s = "Unknown" + } + return +} + +func (t LLDPMediaSubtype) String() (s string) { + switch t { + case LLDPMediaTypeCapabilities: + s = "Media Capabilities " + case LLDPMediaTypeNetwork: + s = "Network Policy" + case LLDPMediaTypeLocation: + s = "Location Identification" + case LLDPMediaTypePower: + s = "Extended Power-via-MDI" + case LLDPMediaTypeHardware: + s = "Hardware Revision" + case LLDPMediaTypeFirmware: + s = "Firmware Revision" + case LLDPMediaTypeSoftware: + s = "Software Revision" + case LLDPMediaTypeSerial: + s = "Serial Number" + case LLDPMediaTypeManufacturer: + s = "Manufacturer" + case LLDPMediaTypeModel: + s = "Model" + case LLDPMediaTypeAssetID: + s = "Asset ID" + default: + s = "Unknown" + } + return +} + +func (t LLDPMediaClass) String() (s string) { + switch t { + case LLDPMediaClassUndefined: + s = "Undefined" + case LLDPMediaClassEndpointI: + s = "Endpoint Class I" + case LLDPMediaClassEndpointII: + s = "Endpoint Class II" + case LLDPMediaClassEndpointIII: + s = "Endpoint Class III" + case LLDPMediaClassNetwork: + s = "Network connectivity " + default: + s = "Unknown" + } + return +} + +func (t LLDPApplicationType) String() (s string) { + switch t { + case LLDPAppTypeReserved: + s = "Reserved" + case LLDPAppTypeVoice: + s = "Voice" + case LLDPappTypeVoiceSignaling: + s = "Voice Signaling" + case LLDPappTypeGuestVoice: + s = "Guest Voice" + case LLDPappTypeGuestVoiceSignaling: + s = "Guest Voice Signaling" + case LLDPappTypeSoftphoneVoice: + s = "Softphone Voice" + case LLDPappTypeVideoConferencing: + s = "Video Conferencing" + case LLDPappTypeStreamingVideo: + s = "Streaming Video" + case LLDPappTypeVideoSignaling: + s = "Video Signaling" + default: + s = "Unknown" + } + return +} + +func (t LLDPLocationFormat) String() (s string) { + switch t { + case LLDPLocationFormatInvalid: + s = "Invalid" + case LLDPLocationFormatCoordinate: + s = "Coordinate-based LCI" + case LLDPLocationFormatAddress: + s = "Address-based LCO" + case LLDPLocationFormatECS: + s = "ECS ELIN" + default: + s = "Unknown" + } + return +} + +func (t LLDPLocationAddressType) String() (s string) { + switch t { + case LLDPLocationAddressTypeLanguage: + s = "Language" + case LLDPLocationAddressTypeNational: + s = "National subdivisions (province, state, etc)" + case LLDPLocationAddressTypeCounty: + s = "County, parish, district" + case LLDPLocationAddressTypeCity: + s = "City, township" + case LLDPLocationAddressTypeCityDivision: + s = "City division, borough, ward" + case LLDPLocationAddressTypeNeighborhood: + s = "Neighborhood, block" + case LLDPLocationAddressTypeStreet: + s = "Street" + case LLDPLocationAddressTypeLeadingStreet: + s = "Leading street direction" + case LLDPLocationAddressTypeTrailingStreet: + s = "Trailing street suffix" + case LLDPLocationAddressTypeStreetSuffix: + s = "Street suffix" + case LLDPLocationAddressTypeHouseNum: + s = "House number" + case LLDPLocationAddressTypeHouseSuffix: + s = "House number suffix" + case LLDPLocationAddressTypeLandmark: + s = "Landmark or vanity address" + case LLDPLocationAddressTypeAdditional: + s = "Additional location information" + case LLDPLocationAddressTypeName: + s = "Name" + case LLDPLocationAddressTypePostal: + s = "Postal/ZIP code" + case LLDPLocationAddressTypeBuilding: + s = "Building" + case LLDPLocationAddressTypeUnit: + s = "Unit" + case LLDPLocationAddressTypeFloor: + s = "Floor" + case LLDPLocationAddressTypeRoom: + s = "Room number" + case LLDPLocationAddressTypePlace: + s = "Place type" + case LLDPLocationAddressTypeScript: + s = "Script" + default: + s = "Unknown" + } + return +} + +func checkLLDPTLVLen(v LinkLayerDiscoveryValue, l int) (err error) { + if len(v.Value) < l { + err = fmt.Errorf("Invalid TLV %v length %d (wanted mimimum %v", v.Type, len(v.Value), l) + } + return +} + +func checkLLDPOrgSpecificLen(o LLDPOrgSpecificTLV, l int) (err error) { + if len(o.Info) < l { + err = fmt.Errorf("Invalid Org Specific TLV %v length %d (wanted minimum %v)", o.SubType, len(o.Info), l) + } + return +} diff --git a/vendor/github.com/google/gopacket/layers/loopback.go b/vendor/github.com/google/gopacket/layers/loopback.go new file mode 100644 index 0000000..839f760 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/loopback.go @@ -0,0 +1,80 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "fmt" + + "github.com/google/gopacket" +) + +// Loopback contains the header for loopback encapsulation. This header is +// used by both BSD and OpenBSD style loopback decoding (pcap's DLT_NULL +// and DLT_LOOP, respectively). +type Loopback struct { + BaseLayer + Family ProtocolFamily +} + +// LayerType returns LayerTypeLoopback. +func (l *Loopback) LayerType() gopacket.LayerType { return LayerTypeLoopback } + +// DecodeFromBytes decodes the given bytes into this layer. +func (l *Loopback) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 4 { + return errors.New("Loopback packet too small") + } + + // The protocol could be either big-endian or little-endian, we're + // not sure. But we're PRETTY sure that the value is less than + // 256, so we can check the first two bytes. + var prot uint32 + if data[0] == 0 && data[1] == 0 { + prot = binary.BigEndian.Uint32(data[:4]) + } else { + prot = binary.LittleEndian.Uint32(data[:4]) + } + if prot > 0xFF { + return fmt.Errorf("Invalid loopback protocol %q", data[:4]) + } + + l.Family = ProtocolFamily(prot) + l.BaseLayer = BaseLayer{data[:4], data[4:]} + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (l *Loopback) CanDecode() gopacket.LayerClass { + return LayerTypeLoopback +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (l *Loopback) NextLayerType() gopacket.LayerType { + return l.Family.LayerType() +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +func (l *Loopback) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + bytes, err := b.PrependBytes(4) + if err != nil { + return err + } + binary.LittleEndian.PutUint32(bytes, uint32(l.Family)) + return nil +} + +func decodeLoopback(data []byte, p gopacket.PacketBuilder) error { + l := Loopback{} + if err := l.DecodeFromBytes(data, gopacket.NilDecodeFeedback); err != nil { + return err + } + p.AddLayer(&l) + return p.NextDecoder(l.Family) +} diff --git a/vendor/github.com/google/gopacket/layers/mpls.go b/vendor/github.com/google/gopacket/layers/mpls.go new file mode 100644 index 0000000..83079a0 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/mpls.go @@ -0,0 +1,87 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "github.com/google/gopacket" +) + +// MPLS is the MPLS packet header. +type MPLS struct { + BaseLayer + Label uint32 + TrafficClass uint8 + StackBottom bool + TTL uint8 +} + +// LayerType returns gopacket.LayerTypeMPLS. +func (m *MPLS) LayerType() gopacket.LayerType { return LayerTypeMPLS } + +// ProtocolGuessingDecoder attempts to guess the protocol of the bytes it's +// given, then decode the packet accordingly. Its algorithm for guessing is: +// If the packet starts with byte 0x45-0x4F: IPv4 +// If the packet starts with byte 0x60-0x6F: IPv6 +// Otherwise: Error +// See draft-hsmit-isis-aal5mux-00.txt for more detail on this approach. +type ProtocolGuessingDecoder struct{} + +func (ProtocolGuessingDecoder) Decode(data []byte, p gopacket.PacketBuilder) error { + switch data[0] { + // 0x40 | header_len, where header_len is at least 5. + case 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f: + return decodeIPv4(data, p) + // IPv6 can start with any byte whose first 4 bits are 0x6. + case 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f: + return decodeIPv6(data, p) + } + return errors.New("Unable to guess protocol of packet data") +} + +// MPLSPayloadDecoder is the decoder used to data encapsulated by each MPLS +// layer. MPLS contains no type information, so we have to explicitly decide +// which decoder to use. This is initially set to ProtocolGuessingDecoder, our +// simple attempt at guessing protocols based on the first few bytes of data +// available to us. However, if you know that in your environment MPLS always +// encapsulates a specific protocol, you may reset this. +var MPLSPayloadDecoder gopacket.Decoder = ProtocolGuessingDecoder{} + +func decodeMPLS(data []byte, p gopacket.PacketBuilder) error { + decoded := binary.BigEndian.Uint32(data[:4]) + mpls := &MPLS{ + Label: decoded >> 12, + TrafficClass: uint8(decoded>>9) & 0x7, + StackBottom: decoded&0x100 != 0, + TTL: uint8(decoded), + BaseLayer: BaseLayer{data[:4], data[4:]}, + } + p.AddLayer(mpls) + if mpls.StackBottom { + return p.NextDecoder(MPLSPayloadDecoder) + } + return p.NextDecoder(gopacket.DecodeFunc(decodeMPLS)) +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (m *MPLS) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + bytes, err := b.PrependBytes(4) + if err != nil { + return err + } + encoded := m.Label << 12 + encoded |= uint32(m.TrafficClass) << 9 + encoded |= uint32(m.TTL) + if m.StackBottom { + encoded |= 0x100 + } + binary.BigEndian.PutUint32(bytes, encoded) + return nil +} diff --git a/vendor/github.com/google/gopacket/layers/ndp.go b/vendor/github.com/google/gopacket/layers/ndp.go new file mode 100644 index 0000000..f7ca1b2 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/ndp.go @@ -0,0 +1,611 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +// Enum types courtesy of... +// http://anonsvn.wireshark.org/wireshark/trunk/epan/dissectors/packet-ndp.c + +package layers + +import ( + "fmt" + "github.com/google/gopacket" + "net" +) + +type NDPChassisType uint8 + +// Nortel Chassis Types +const ( + NDPChassisother NDPChassisType = 1 + NDPChassis3000 NDPChassisType = 2 + NDPChassis3030 NDPChassisType = 3 + NDPChassis2310 NDPChassisType = 4 + NDPChassis2810 NDPChassisType = 5 + NDPChassis2912 NDPChassisType = 6 + NDPChassis2914 NDPChassisType = 7 + NDPChassis271x NDPChassisType = 8 + NDPChassis2813 NDPChassisType = 9 + NDPChassis2814 NDPChassisType = 10 + NDPChassis2915 NDPChassisType = 11 + NDPChassis5000 NDPChassisType = 12 + NDPChassis2813SA NDPChassisType = 13 + NDPChassis2814SA NDPChassisType = 14 + NDPChassis810M NDPChassisType = 15 + NDPChassisEthercell NDPChassisType = 16 + NDPChassis5005 NDPChassisType = 17 + NDPChassisAlcatelEWC NDPChassisType = 18 + NDPChassis2715SA NDPChassisType = 20 + NDPChassis2486 NDPChassisType = 21 + NDPChassis28000series NDPChassisType = 22 + NDPChassis23000series NDPChassisType = 23 + NDPChassis5DN00xseries NDPChassisType = 24 + NDPChassisBayStackEthernet NDPChassisType = 25 + NDPChassis23100series NDPChassisType = 26 + NDPChassis100BaseTHub NDPChassisType = 27 + NDPChassis3000FastEthernet NDPChassisType = 28 + NDPChassisOrionSwitch NDPChassisType = 29 + NDPChassisDDS NDPChassisType = 31 + NDPChassisCentillion6slot NDPChassisType = 32 + NDPChassisCentillion12slot NDPChassisType = 33 + NDPChassisCentillion1slot NDPChassisType = 34 + NDPChassisBayStack301 NDPChassisType = 35 + NDPChassisBayStackTokenRingHub NDPChassisType = 36 + NDPChassisFVCMultimediaSwitch NDPChassisType = 37 + NDPChassisSwitchNode NDPChassisType = 38 + NDPChassisBayStack302Switch NDPChassisType = 39 + NDPChassisBayStack350Switch NDPChassisType = 40 + NDPChassisBayStack150EthernetHub NDPChassisType = 41 + NDPChassisCentillion50NSwitch NDPChassisType = 42 + NDPChassisCentillion50TSwitch NDPChassisType = 43 + NDPChassisBayStack303304Switches NDPChassisType = 44 + NDPChassisBayStack200EthernetHub NDPChassisType = 45 + NDPChassisBayStack25010100EthernetHub NDPChassisType = 46 + NDPChassisBayStack450101001000Switches NDPChassisType = 48 + NDPChassisBayStack41010100Switches NDPChassisType = 49 + NDPChassisPassport1200L3Switch NDPChassisType = 50 + NDPChassisPassport1250L3Switch NDPChassisType = 51 + NDPChassisPassport1100L3Switch NDPChassisType = 52 + NDPChassisPassport1150L3Switch NDPChassisType = 53 + NDPChassisPassport1050L3Switch NDPChassisType = 54 + NDPChassisPassport1051L3Switch NDPChassisType = 55 + NDPChassisPassport8610L3Switch NDPChassisType = 56 + NDPChassisPassport8606L3Switch NDPChassisType = 57 + NDPChassisPassport8010 NDPChassisType = 58 + NDPChassisPassport8006 NDPChassisType = 59 + NDPChassisBayStack670wirelessaccesspoint NDPChassisType = 60 + NDPChassisPassport740 NDPChassisType = 61 + NDPChassisPassport750 NDPChassisType = 62 + NDPChassisPassport790 NDPChassisType = 63 + NDPChassisBusinessPolicySwitch200010100Switches NDPChassisType = 64 + NDPChassisPassport8110L2Switch NDPChassisType = 65 + NDPChassisPassport8106L2Switch NDPChassisType = 66 + NDPChassisBayStack3580GigSwitch NDPChassisType = 67 + NDPChassisBayStack10PowerSupplyUnit NDPChassisType = 68 + NDPChassisBayStack42010100Switch NDPChassisType = 69 + NDPChassisOPTeraMetro1200EthernetServiceModule NDPChassisType = 70 + NDPChassisOPTera8010co NDPChassisType = 71 + NDPChassisOPTera8610coL3Switch NDPChassisType = 72 + NDPChassisOPTera8110coL2Switch NDPChassisType = 73 + NDPChassisOPTera8003 NDPChassisType = 74 + NDPChassisOPTera8603L3Switch NDPChassisType = 75 + NDPChassisOPTera8103L2Switch NDPChassisType = 76 + NDPChassisBayStack380101001000Switch NDPChassisType = 77 + NDPChassisEthernetSwitch47048T NDPChassisType = 78 + NDPChassisOPTeraMetro1450EthernetServiceModule NDPChassisType = 79 + NDPChassisOPTeraMetro1400EthernetServiceModule NDPChassisType = 80 + NDPChassisAlteonSwitchFamily NDPChassisType = 81 + NDPChassisEthernetSwitch46024TPWR NDPChassisType = 82 + NDPChassisOPTeraMetro8010OPML2Switch NDPChassisType = 83 + NDPChassisOPTeraMetro8010coOPML2Switch NDPChassisType = 84 + NDPChassisOPTeraMetro8006OPML2Switch NDPChassisType = 85 + NDPChassisOPTeraMetro8003OPML2Switch NDPChassisType = 86 + NDPChassisAlteon180e NDPChassisType = 87 + NDPChassisAlteonAD3 NDPChassisType = 88 + NDPChassisAlteon184 NDPChassisType = 89 + NDPChassisAlteonAD4 NDPChassisType = 90 + NDPChassisPassport1424L3Switch NDPChassisType = 91 + NDPChassisPassport1648L3Switch NDPChassisType = 92 + NDPChassisPassport1612L3Switch NDPChassisType = 93 + NDPChassisPassport1624L3Switch NDPChassisType = 94 + NDPChassisBayStack38024FFiber1000Switch NDPChassisType = 95 + NDPChassisEthernetRoutingSwitch551024T NDPChassisType = 96 + NDPChassisEthernetRoutingSwitch551048T NDPChassisType = 97 + NDPChassisEthernetSwitch47024T NDPChassisType = 98 + NDPChassisNortelNetworksWirelessLANAccessPoint2220 NDPChassisType = 99 + NDPChassisPassportRBS2402L3Switch NDPChassisType = 100 + NDPChassisAlteonApplicationSwitch2424 NDPChassisType = 101 + NDPChassisAlteonApplicationSwitch2224 NDPChassisType = 102 + NDPChassisAlteonApplicationSwitch2208 NDPChassisType = 103 + NDPChassisAlteonApplicationSwitch2216 NDPChassisType = 104 + NDPChassisAlteonApplicationSwitch3408 NDPChassisType = 105 + NDPChassisAlteonApplicationSwitch3416 NDPChassisType = 106 + NDPChassisNortelNetworksWirelessLANSecuritySwitch2250 NDPChassisType = 107 + NDPChassisEthernetSwitch42548T NDPChassisType = 108 + NDPChassisEthernetSwitch42524T NDPChassisType = 109 + NDPChassisNortelNetworksWirelessLANAccessPoint2221 NDPChassisType = 110 + NDPChassisNortelMetroEthernetServiceUnit24TSPFswitch NDPChassisType = 111 + NDPChassisNortelMetroEthernetServiceUnit24TLXDCswitch NDPChassisType = 112 + NDPChassisPassport830010slotchassis NDPChassisType = 113 + NDPChassisPassport83006slotchassis NDPChassisType = 114 + NDPChassisEthernetRoutingSwitch552024TPWR NDPChassisType = 115 + NDPChassisEthernetRoutingSwitch552048TPWR NDPChassisType = 116 + NDPChassisNortelNetworksVPNGateway3050 NDPChassisType = 117 + NDPChassisAlteonSSL31010100 NDPChassisType = 118 + NDPChassisAlteonSSL31010100Fiber NDPChassisType = 119 + NDPChassisAlteonSSL31010100FIPS NDPChassisType = 120 + NDPChassisAlteonSSL410101001000 NDPChassisType = 121 + NDPChassisAlteonSSL410101001000Fiber NDPChassisType = 122 + NDPChassisAlteonApplicationSwitch2424SSL NDPChassisType = 123 + NDPChassisEthernetSwitch32524T NDPChassisType = 124 + NDPChassisEthernetSwitch32524G NDPChassisType = 125 + NDPChassisNortelNetworksWirelessLANAccessPoint2225 NDPChassisType = 126 + NDPChassisNortelNetworksWirelessLANSecuritySwitch2270 NDPChassisType = 127 + NDPChassis24portEthernetSwitch47024TPWR NDPChassisType = 128 + NDPChassis48portEthernetSwitch47048TPWR NDPChassisType = 129 + NDPChassisEthernetRoutingSwitch553024TFD NDPChassisType = 130 + NDPChassisEthernetSwitch351024T NDPChassisType = 131 + NDPChassisNortelMetroEthernetServiceUnit12GACL3Switch NDPChassisType = 132 + NDPChassisNortelMetroEthernetServiceUnit12GDCL3Switch NDPChassisType = 133 + NDPChassisNortelSecureAccessSwitch NDPChassisType = 134 + NDPChassisNortelNetworksVPNGateway3070 NDPChassisType = 135 + NDPChassisOPTeraMetro3500 NDPChassisType = 136 + NDPChassisSMBBES101024T NDPChassisType = 137 + NDPChassisSMBBES101048T NDPChassisType = 138 + NDPChassisSMBBES102024TPWR NDPChassisType = 139 + NDPChassisSMBBES102048TPWR NDPChassisType = 140 + NDPChassisSMBBES201024T NDPChassisType = 141 + NDPChassisSMBBES201048T NDPChassisType = 142 + NDPChassisSMBBES202024TPWR NDPChassisType = 143 + NDPChassisSMBBES202048TPWR NDPChassisType = 144 + NDPChassisSMBBES11024T NDPChassisType = 145 + NDPChassisSMBBES11048T NDPChassisType = 146 + NDPChassisSMBBES12024TPWR NDPChassisType = 147 + NDPChassisSMBBES12048TPWR NDPChassisType = 148 + NDPChassisSMBBES21024T NDPChassisType = 149 + NDPChassisSMBBES21048T NDPChassisType = 150 + NDPChassisSMBBES22024TPWR NDPChassisType = 151 + NDPChassisSMBBES22048TPWR NDPChassisType = 152 + NDPChassisOME6500 NDPChassisType = 153 + NDPChassisEthernetRoutingSwitch4548GT NDPChassisType = 154 + NDPChassisEthernetRoutingSwitch4548GTPWR NDPChassisType = 155 + NDPChassisEthernetRoutingSwitch4550T NDPChassisType = 156 + NDPChassisEthernetRoutingSwitch4550TPWR NDPChassisType = 157 + NDPChassisEthernetRoutingSwitch4526FX NDPChassisType = 158 + NDPChassisEthernetRoutingSwitch250026T NDPChassisType = 159 + NDPChassisEthernetRoutingSwitch250026TPWR NDPChassisType = 160 + NDPChassisEthernetRoutingSwitch250050T NDPChassisType = 161 + NDPChassisEthernetRoutingSwitch250050TPWR NDPChassisType = 162 +) + +type NDPBackplaneType uint8 + +// Nortel Backplane Types +const ( + NDPBackplaneOther NDPBackplaneType = 1 + NDPBackplaneEthernet NDPBackplaneType = 2 + NDPBackplaneEthernetTokenring NDPBackplaneType = 3 + NDPBackplaneEthernetFDDI NDPBackplaneType = 4 + NDPBackplaneEthernetTokenringFDDI NDPBackplaneType = 5 + NDPBackplaneEthernetTokenringRedundantPower NDPBackplaneType = 6 + NDPBackplaneEthernetTokenringFDDIRedundantPower NDPBackplaneType = 7 + NDPBackplaneTokenRing NDPBackplaneType = 8 + NDPBackplaneEthernetTokenringFastEthernet NDPBackplaneType = 9 + NDPBackplaneEthernetFastEthernet NDPBackplaneType = 10 + NDPBackplaneEthernetTokenringFastEthernetRedundantPower NDPBackplaneType = 11 + NDPBackplaneEthernetFastEthernetGigabitEthernet NDPBackplaneType = 12 +) + +type NDPState uint8 + +// Device State +const ( + NDPStateTopology NDPState = 1 + NDPStateHeartbeat NDPState = 2 + NDPStateNew NDPState = 3 +) + +// NortelDiscovery is a packet layer containing the Nortel Discovery Protocol. +type NortelDiscovery struct { + BaseLayer + IPAddress net.IP + SegmentID []byte + Chassis NDPChassisType + Backplane NDPBackplaneType + State NDPState + NumLinks uint8 +} + +// LayerType returns gopacket.LayerTypeNortelDiscovery. +func (c *NortelDiscovery) LayerType() gopacket.LayerType { + return LayerTypeNortelDiscovery +} + +func decodeNortelDiscovery(data []byte, p gopacket.PacketBuilder) error { + c := &NortelDiscovery{} + if len(data) < 11 { + return fmt.Errorf("Invalid NortelDiscovery packet length %d", len(data)) + } + c.IPAddress = data[0:4] + c.SegmentID = data[4:7] + c.Chassis = NDPChassisType(data[7]) + c.Backplane = NDPBackplaneType(data[8]) + c.State = NDPState(data[9]) + c.NumLinks = uint8(data[10]) + p.AddLayer(c) + return nil +} + +func (t NDPChassisType) String() (s string) { + switch t { + case NDPChassisother: + s = "other" + case NDPChassis3000: + s = "3000" + case NDPChassis3030: + s = "3030" + case NDPChassis2310: + s = "2310" + case NDPChassis2810: + s = "2810" + case NDPChassis2912: + s = "2912" + case NDPChassis2914: + s = "2914" + case NDPChassis271x: + s = "271x" + case NDPChassis2813: + s = "2813" + case NDPChassis2814: + s = "2814" + case NDPChassis2915: + s = "2915" + case NDPChassis5000: + s = "5000" + case NDPChassis2813SA: + s = "2813SA" + case NDPChassis2814SA: + s = "2814SA" + case NDPChassis810M: + s = "810M" + case NDPChassisEthercell: + s = "Ethercell" + case NDPChassis5005: + s = "5005" + case NDPChassisAlcatelEWC: + s = "Alcatel Ethernet workgroup conc." + case NDPChassis2715SA: + s = "2715SA" + case NDPChassis2486: + s = "2486" + case NDPChassis28000series: + s = "28000 series" + case NDPChassis23000series: + s = "23000 series" + case NDPChassis5DN00xseries: + s = "5DN00x series" + case NDPChassisBayStackEthernet: + s = "BayStack Ethernet" + case NDPChassis23100series: + s = "23100 series" + case NDPChassis100BaseTHub: + s = "100Base-T Hub" + case NDPChassis3000FastEthernet: + s = "3000 Fast Ethernet" + case NDPChassisOrionSwitch: + s = "Orion switch" + case NDPChassisDDS: + s = "DDS" + case NDPChassisCentillion6slot: + s = "Centillion (6 slot)" + case NDPChassisCentillion12slot: + s = "Centillion (12 slot)" + case NDPChassisCentillion1slot: + s = "Centillion (1 slot)" + case NDPChassisBayStack301: + s = "BayStack 301" + case NDPChassisBayStackTokenRingHub: + s = "BayStack TokenRing Hub" + case NDPChassisFVCMultimediaSwitch: + s = "FVC Multimedia Switch" + case NDPChassisSwitchNode: + s = "Switch Node" + case NDPChassisBayStack302Switch: + s = "BayStack 302 Switch" + case NDPChassisBayStack350Switch: + s = "BayStack 350 Switch" + case NDPChassisBayStack150EthernetHub: + s = "BayStack 150 Ethernet Hub" + case NDPChassisCentillion50NSwitch: + s = "Centillion 50N switch" + case NDPChassisCentillion50TSwitch: + s = "Centillion 50T switch" + case NDPChassisBayStack303304Switches: + s = "BayStack 303 and 304 Switches" + case NDPChassisBayStack200EthernetHub: + s = "BayStack 200 Ethernet Hub" + case NDPChassisBayStack25010100EthernetHub: + s = "BayStack 250 10/100 Ethernet Hub" + case NDPChassisBayStack450101001000Switches: + s = "BayStack 450 10/100/1000 Switches" + case NDPChassisBayStack41010100Switches: + s = "BayStack 410 10/100 Switches" + case NDPChassisPassport1200L3Switch: + s = "Passport 1200 L3 Switch" + case NDPChassisPassport1250L3Switch: + s = "Passport 1250 L3 Switch" + case NDPChassisPassport1100L3Switch: + s = "Passport 1100 L3 Switch" + case NDPChassisPassport1150L3Switch: + s = "Passport 1150 L3 Switch" + case NDPChassisPassport1050L3Switch: + s = "Passport 1050 L3 Switch" + case NDPChassisPassport1051L3Switch: + s = "Passport 1051 L3 Switch" + case NDPChassisPassport8610L3Switch: + s = "Passport 8610 L3 Switch" + case NDPChassisPassport8606L3Switch: + s = "Passport 8606 L3 Switch" + case NDPChassisPassport8010: + s = "Passport 8010" + case NDPChassisPassport8006: + s = "Passport 8006" + case NDPChassisBayStack670wirelessaccesspoint: + s = "BayStack 670 wireless access point" + case NDPChassisPassport740: + s = "Passport 740" + case NDPChassisPassport750: + s = "Passport 750" + case NDPChassisPassport790: + s = "Passport 790" + case NDPChassisBusinessPolicySwitch200010100Switches: + s = "Business Policy Switch 2000 10/100 Switches" + case NDPChassisPassport8110L2Switch: + s = "Passport 8110 L2 Switch" + case NDPChassisPassport8106L2Switch: + s = "Passport 8106 L2 Switch" + case NDPChassisBayStack3580GigSwitch: + s = "BayStack 3580 Gig Switch" + case NDPChassisBayStack10PowerSupplyUnit: + s = "BayStack 10 Power Supply Unit" + case NDPChassisBayStack42010100Switch: + s = "BayStack 420 10/100 Switch" + case NDPChassisOPTeraMetro1200EthernetServiceModule: + s = "OPTera Metro 1200 Ethernet Service Module" + case NDPChassisOPTera8010co: + s = "OPTera 8010co" + case NDPChassisOPTera8610coL3Switch: + s = "OPTera 8610co L3 switch" + case NDPChassisOPTera8110coL2Switch: + s = "OPTera 8110co L2 switch" + case NDPChassisOPTera8003: + s = "OPTera 8003" + case NDPChassisOPTera8603L3Switch: + s = "OPTera 8603 L3 switch" + case NDPChassisOPTera8103L2Switch: + s = "OPTera 8103 L2 switch" + case NDPChassisBayStack380101001000Switch: + s = "BayStack 380 10/100/1000 Switch" + case NDPChassisEthernetSwitch47048T: + s = "Ethernet Switch 470-48T" + case NDPChassisOPTeraMetro1450EthernetServiceModule: + s = "OPTera Metro 1450 Ethernet Service Module" + case NDPChassisOPTeraMetro1400EthernetServiceModule: + s = "OPTera Metro 1400 Ethernet Service Module" + case NDPChassisAlteonSwitchFamily: + s = "Alteon Switch Family" + case NDPChassisEthernetSwitch46024TPWR: + s = "Ethernet Switch 460-24T-PWR" + case NDPChassisOPTeraMetro8010OPML2Switch: + s = "OPTera Metro 8010 OPM L2 Switch" + case NDPChassisOPTeraMetro8010coOPML2Switch: + s = "OPTera Metro 8010co OPM L2 Switch" + case NDPChassisOPTeraMetro8006OPML2Switch: + s = "OPTera Metro 8006 OPM L2 Switch" + case NDPChassisOPTeraMetro8003OPML2Switch: + s = "OPTera Metro 8003 OPM L2 Switch" + case NDPChassisAlteon180e: + s = "Alteon 180e" + case NDPChassisAlteonAD3: + s = "Alteon AD3" + case NDPChassisAlteon184: + s = "Alteon 184" + case NDPChassisAlteonAD4: + s = "Alteon AD4" + case NDPChassisPassport1424L3Switch: + s = "Passport 1424 L3 switch" + case NDPChassisPassport1648L3Switch: + s = "Passport 1648 L3 switch" + case NDPChassisPassport1612L3Switch: + s = "Passport 1612 L3 switch" + case NDPChassisPassport1624L3Switch: + s = "Passport 1624 L3 switch" + case NDPChassisBayStack38024FFiber1000Switch: + s = "BayStack 380-24F Fiber 1000 Switch" + case NDPChassisEthernetRoutingSwitch551024T: + s = "Ethernet Routing Switch 5510-24T" + case NDPChassisEthernetRoutingSwitch551048T: + s = "Ethernet Routing Switch 5510-48T" + case NDPChassisEthernetSwitch47024T: + s = "Ethernet Switch 470-24T" + case NDPChassisNortelNetworksWirelessLANAccessPoint2220: + s = "Nortel Networks Wireless LAN Access Point 2220" + case NDPChassisPassportRBS2402L3Switch: + s = "Passport RBS 2402 L3 switch" + case NDPChassisAlteonApplicationSwitch2424: + s = "Alteon Application Switch 2424" + case NDPChassisAlteonApplicationSwitch2224: + s = "Alteon Application Switch 2224" + case NDPChassisAlteonApplicationSwitch2208: + s = "Alteon Application Switch 2208" + case NDPChassisAlteonApplicationSwitch2216: + s = "Alteon Application Switch 2216" + case NDPChassisAlteonApplicationSwitch3408: + s = "Alteon Application Switch 3408" + case NDPChassisAlteonApplicationSwitch3416: + s = "Alteon Application Switch 3416" + case NDPChassisNortelNetworksWirelessLANSecuritySwitch2250: + s = "Nortel Networks Wireless LAN SecuritySwitch 2250" + case NDPChassisEthernetSwitch42548T: + s = "Ethernet Switch 425-48T" + case NDPChassisEthernetSwitch42524T: + s = "Ethernet Switch 425-24T" + case NDPChassisNortelNetworksWirelessLANAccessPoint2221: + s = "Nortel Networks Wireless LAN Access Point 2221" + case NDPChassisNortelMetroEthernetServiceUnit24TSPFswitch: + s = "Nortel Metro Ethernet Service Unit 24-T SPF switch" + case NDPChassisNortelMetroEthernetServiceUnit24TLXDCswitch: + s = " Nortel Metro Ethernet Service Unit 24-T LX DC switch" + case NDPChassisPassport830010slotchassis: + s = "Passport 8300 10-slot chassis" + case NDPChassisPassport83006slotchassis: + s = "Passport 8300 6-slot chassis" + case NDPChassisEthernetRoutingSwitch552024TPWR: + s = "Ethernet Routing Switch 5520-24T-PWR" + case NDPChassisEthernetRoutingSwitch552048TPWR: + s = "Ethernet Routing Switch 5520-48T-PWR" + case NDPChassisNortelNetworksVPNGateway3050: + s = "Nortel Networks VPN Gateway 3050" + case NDPChassisAlteonSSL31010100: + s = "Alteon SSL 310 10/100" + case NDPChassisAlteonSSL31010100Fiber: + s = "Alteon SSL 310 10/100 Fiber" + case NDPChassisAlteonSSL31010100FIPS: + s = "Alteon SSL 310 10/100 FIPS" + case NDPChassisAlteonSSL410101001000: + s = "Alteon SSL 410 10/100/1000" + case NDPChassisAlteonSSL410101001000Fiber: + s = "Alteon SSL 410 10/100/1000 Fiber" + case NDPChassisAlteonApplicationSwitch2424SSL: + s = "Alteon Application Switch 2424-SSL" + case NDPChassisEthernetSwitch32524T: + s = "Ethernet Switch 325-24T" + case NDPChassisEthernetSwitch32524G: + s = "Ethernet Switch 325-24G" + case NDPChassisNortelNetworksWirelessLANAccessPoint2225: + s = "Nortel Networks Wireless LAN Access Point 2225" + case NDPChassisNortelNetworksWirelessLANSecuritySwitch2270: + s = "Nortel Networks Wireless LAN SecuritySwitch 2270" + case NDPChassis24portEthernetSwitch47024TPWR: + s = "24-port Ethernet Switch 470-24T-PWR" + case NDPChassis48portEthernetSwitch47048TPWR: + s = "48-port Ethernet Switch 470-48T-PWR" + case NDPChassisEthernetRoutingSwitch553024TFD: + s = "Ethernet Routing Switch 5530-24TFD" + case NDPChassisEthernetSwitch351024T: + s = "Ethernet Switch 3510-24T" + case NDPChassisNortelMetroEthernetServiceUnit12GACL3Switch: + s = "Nortel Metro Ethernet Service Unit 12G AC L3 switch" + case NDPChassisNortelMetroEthernetServiceUnit12GDCL3Switch: + s = "Nortel Metro Ethernet Service Unit 12G DC L3 switch" + case NDPChassisNortelSecureAccessSwitch: + s = "Nortel Secure Access Switch" + case NDPChassisNortelNetworksVPNGateway3070: + s = "Nortel Networks VPN Gateway 3070" + case NDPChassisOPTeraMetro3500: + s = "OPTera Metro 3500" + case NDPChassisSMBBES101024T: + s = "SMB BES 1010 24T" + case NDPChassisSMBBES101048T: + s = "SMB BES 1010 48T" + case NDPChassisSMBBES102024TPWR: + s = "SMB BES 1020 24T PWR" + case NDPChassisSMBBES102048TPWR: + s = "SMB BES 1020 48T PWR" + case NDPChassisSMBBES201024T: + s = "SMB BES 2010 24T" + case NDPChassisSMBBES201048T: + s = "SMB BES 2010 48T" + case NDPChassisSMBBES202024TPWR: + s = "SMB BES 2020 24T PWR" + case NDPChassisSMBBES202048TPWR: + s = "SMB BES 2020 48T PWR" + case NDPChassisSMBBES11024T: + s = "SMB BES 110 24T" + case NDPChassisSMBBES11048T: + s = "SMB BES 110 48T" + case NDPChassisSMBBES12024TPWR: + s = "SMB BES 120 24T PWR" + case NDPChassisSMBBES12048TPWR: + s = "SMB BES 120 48T PWR" + case NDPChassisSMBBES21024T: + s = "SMB BES 210 24T" + case NDPChassisSMBBES21048T: + s = "SMB BES 210 48T" + case NDPChassisSMBBES22024TPWR: + s = "SMB BES 220 24T PWR" + case NDPChassisSMBBES22048TPWR: + s = "SMB BES 220 48T PWR" + case NDPChassisOME6500: + s = "OME 6500" + case NDPChassisEthernetRoutingSwitch4548GT: + s = "Ethernet Routing Switch 4548GT" + case NDPChassisEthernetRoutingSwitch4548GTPWR: + s = "Ethernet Routing Switch 4548GT-PWR" + case NDPChassisEthernetRoutingSwitch4550T: + s = "Ethernet Routing Switch 4550T" + case NDPChassisEthernetRoutingSwitch4550TPWR: + s = "Ethernet Routing Switch 4550T-PWR" + case NDPChassisEthernetRoutingSwitch4526FX: + s = "Ethernet Routing Switch 4526FX" + case NDPChassisEthernetRoutingSwitch250026T: + s = "Ethernet Routing Switch 2500-26T" + case NDPChassisEthernetRoutingSwitch250026TPWR: + s = "Ethernet Routing Switch 2500-26T-PWR" + case NDPChassisEthernetRoutingSwitch250050T: + s = "Ethernet Routing Switch 2500-50T" + case NDPChassisEthernetRoutingSwitch250050TPWR: + s = "Ethernet Routing Switch 2500-50T-PWR" + default: + s = "Unknown" + } + return +} + +func (t NDPBackplaneType) String() (s string) { + switch t { + case NDPBackplaneOther: + s = "Other" + case NDPBackplaneEthernet: + s = "Ethernet" + case NDPBackplaneEthernetTokenring: + s = "Ethernet and Tokenring" + case NDPBackplaneEthernetFDDI: + s = "Ethernet and FDDI" + case NDPBackplaneEthernetTokenringFDDI: + s = "Ethernet, Tokenring and FDDI" + case NDPBackplaneEthernetTokenringRedundantPower: + s = "Ethernet and Tokenring with redundant power" + case NDPBackplaneEthernetTokenringFDDIRedundantPower: + s = "Ethernet, Tokenring, FDDI with redundant power" + case NDPBackplaneTokenRing: + s = "Token Ring" + case NDPBackplaneEthernetTokenringFastEthernet: + s = "Ethernet, Tokenring and Fast Ethernet" + case NDPBackplaneEthernetFastEthernet: + s = "Ethernet and Fast Ethernet" + case NDPBackplaneEthernetTokenringFastEthernetRedundantPower: + s = "Ethernet, Tokenring, Fast Ethernet with redundant power" + case NDPBackplaneEthernetFastEthernetGigabitEthernet: + s = "Ethernet, Fast Ethernet and Gigabit Ethernet" + default: + s = "Unknown" + } + return +} + +func (t NDPState) String() (s string) { + switch t { + case NDPStateTopology: + s = "Topology Change" + case NDPStateHeartbeat: + s = "Heartbeat" + case NDPStateNew: + s = "New" + default: + s = "Unknown" + } + return +} diff --git a/vendor/github.com/google/gopacket/layers/ntp.go b/vendor/github.com/google/gopacket/layers/ntp.go new file mode 100644 index 0000000..33c15b3 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/ntp.go @@ -0,0 +1,416 @@ +// Copyright 2016 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. +// +//****************************************************************************** + +package layers + +import ( + "encoding/binary" + "errors" + + "github.com/google/gopacket" +) + +//****************************************************************************** +// +// Network Time Protocol (NTP) Decoding Layer +// ------------------------------------------ +// This file provides a GoPacket decoding layer for NTP. +// +//****************************************************************************** +// +// About The Network Time Protocol (NTP) +// ------------------------------------- +// NTP is a protocol that enables computers on the internet to set their +// clocks to the correct time (or to a time that is acceptably close to the +// correct time). NTP runs on top of UDP. +// +// There have been a series of versions of the NTP protocol. The latest +// version is V4 and is specified in RFC 5905: +// http://www.ietf.org/rfc/rfc5905.txt +// +//****************************************************************************** +// +// References +// ---------- +// +// Wikipedia's NTP entry: +// https://en.wikipedia.org/wiki/Network_Time_Protocol +// This is the best place to get an overview of NTP. +// +// Network Time Protocol Home Website: +// http://www.ntp.org/ +// This appears to be the official website of NTP. +// +// List of current NTP Protocol RFCs: +// http://www.ntp.org/rfc.html +// +// RFC 958: "Network Time Protocol (NTP)" (1985) +// https://tools.ietf.org/html/rfc958 +// This is the original NTP specification. +// +// RFC 1305: "Network Time Protocol (Version 3) Specification, Implementation and Analysis" (1992) +// https://tools.ietf.org/html/rfc1305 +// The protocol was updated in 1992 yielding NTP V3. +// +// RFC 5905: "Network Time Protocol Version 4: Protocol and Algorithms Specification" (2010) +// https://www.ietf.org/rfc/rfc5905.txt +// The protocol was updated in 2010 yielding NTP V4. +// V4 is backwards compatible with all previous versions of NTP. +// +// RFC 5906: "Network Time Protocol Version 4: Autokey Specification" +// https://tools.ietf.org/html/rfc5906 +// This document addresses the security of the NTP protocol +// and is probably not relevant to this package. +// +// RFC 5907: "Definitions of Managed Objects for Network Time Protocol Version 4 (NTPv4)" +// https://tools.ietf.org/html/rfc5907 +// This document addresses the management of NTP servers and +// is probably not relevant to this package. +// +// RFC 5908: "Network Time Protocol (NTP) Server Option for DHCPv6" +// https://tools.ietf.org/html/rfc5908 +// This document addresses the use of NTP in DHCPv6 and is +// probably not relevant to this package. +// +// "Let's make a NTP Client in C" +// https://lettier.github.io/posts/2016-04-26-lets-make-a-ntp-client-in-c.html +// This web page contains useful information about the details of NTP, +// including an NTP record struture in C, and C code. +// +// "NTP Packet Header (NTP Reference Implementation) (Computer Network Time Synchronization)" +// http://what-when-how.com/computer-network-time-synchronization/ +// ntp-packet-header-ntp-reference-implementation-computer-network-time-synchronization/ +// This web page contains useful information on the details of NTP. +// +// "Technical information - NTP Data Packet" +// https://www.meinbergglobal.com/english/info/ntp-packet.htm +// This page has a helpful diagram of an NTP V4 packet. +// +//****************************************************************************** +// +// Obsolete References +// ------------------- +// +// RFC 1119: "RFC-1119 "Network Time Protocol (Version 2) Specification and Implementation" (1989) +// https://tools.ietf.org/html/rfc1119 +// Version 2 was drafted in 1989. +// It is unclear whether V2 was ever implememented or whether the +// ideas ended up in V3 (which was implemented in 1992). +// +// RFC 1361: "Simple Network Time Protocol (SNTP)" +// https://tools.ietf.org/html/rfc1361 +// This document is obsoleted by RFC 1769 and is included only for completeness. +// +// RFC 1769: "Simple Network Time Protocol (SNTP)" +// https://tools.ietf.org/html/rfc1769 +// This document is obsoleted by RFC 2030 and RFC 4330 and is included only for completeness. +// +// RFC 2030: "Simple Network Time Protocol (SNTP) Version 4 for IPv4, IPv6 and OSI" +// https://tools.ietf.org/html/rfc2030 +// This document is obsoleted by RFC 4330 and is included only for completeness. +// +// RFC 4330: "Simple Network Time Protocol (SNTP) Version 4 for IPv4, IPv6 and OSI" +// https://tools.ietf.org/html/rfc4330 +// This document is obsoleted by RFC 5905 and is included only for completeness. +// +//****************************************************************************** +// +// Endian And Bit Numbering Issues +// ------------------------------- +// +// Endian and bit numbering issues can be confusing. Here is some +// clarification: +// +// ENDIAN: Values are sent big endian. +// https://en.wikipedia.org/wiki/Endianness +// +// BIT NUMBERING: Bits are numbered 0 upwards from the most significant +// bit to the least significant bit. This means that if there is a 32-bit +// value, the most significant bit is called bit 0 and the least +// significant bit is called bit 31. +// +// See RFC 791 Appendix B for more discussion. +// +//****************************************************************************** +// +// NTP V3 and V4 Packet Format +// --------------------------- +// NTP packets are UDP packets whose payload contains an NTP record. +// +// The NTP RFC defines the format of the NTP record. +// +// There have been four versions of the protocol: +// +// V1 in 1985 +// V2 in 1989 +// V3 in 1992 +// V4 in 2010 +// +// It is clear that V1 and V2 are obsolete, and there is no need to +// cater for these formats. +// +// V3 and V4 essentially use the same format, with V4 adding some optional +// fields on the end. So this package supports the V3 and V4 formats. +// +// The current version of NTP (NTP V4)'s RFC (V4 - RFC 5905) contains +// the following diagram for the NTP record format: + +// 0 1 2 3 +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// |LI | VN |Mode | Stratum | Poll | Precision | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Root Delay | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Root Dispersion | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Reference ID | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// + Reference Timestamp (64) + +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// + Origin Timestamp (64) + +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// + Receive Timestamp (64) + +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// + Transmit Timestamp (64) + +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// . . +// . Extension Field 1 (variable) . +// . . +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// . . +// . Extension Field 2 (variable) . +// . . +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Key Identifier | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | | +// | dgst (128) | +// | | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// From http://www.ietf.org/rfc/rfc5905.txt +// +// The fields "Extension Field 1 (variable)" and later are optional fields, +// and so we can set a minimum NTP record size of 48 bytes. +// +const ntpMinimumRecordSizeInBytes int = 48 + +//****************************************************************************** + +// NTP Type +// -------- +// Type NTP implements the DecodingLayer interface. Each NTP object +// represents in a structured form the NTP record present as the UDP +// payload in an NTP UDP packet. +// + +type NTPLeapIndicator uint8 +type NTPVersion uint8 +type NTPMode uint8 +type NTPStratum uint8 +type NTPLog2Seconds int8 +type NTPFixed16Seconds uint32 +type NTPReferenceID uint32 +type NTPTimestamp uint64 + +type NTP struct { + BaseLayer // Stores the packet bytes and payload bytes. + + LeapIndicator NTPLeapIndicator // [0,3]. Indicates whether leap second(s) is to be added. + Version NTPVersion // [0,7]. Version of the NTP protocol. + Mode NTPMode // [0,7]. Mode. + Stratum NTPStratum // [0,255]. Stratum of time server in the server tree. + Poll NTPLog2Seconds // [-128,127]. The maximum interval between successive messages, in log2 seconds. + Precision NTPLog2Seconds // [-128,127]. The precision of the system clock, in log2 seconds. + RootDelay NTPFixed16Seconds // [0,2^32-1]. Total round trip delay to the reference clock in seconds times 2^16. + RootDispersion NTPFixed16Seconds // [0,2^32-1]. Total dispersion to the reference clock, in seconds times 2^16. + ReferenceID NTPReferenceID // ID code of reference clock [0,2^32-1]. + ReferenceTimestamp NTPTimestamp // Most recent timestamp from the reference clock. + OriginTimestamp NTPTimestamp // Local time when request was sent from local host. + ReceiveTimestamp NTPTimestamp // Local time (on server) that request arrived at server host. + TransmitTimestamp NTPTimestamp // Local time (on server) that request departed server host. + + // FIX: This package should analyse the extension fields and represent the extension fields too. + ExtensionBytes []byte // Just put extensions in a byte slice. +} + +//****************************************************************************** + +// LayerType returns the layer type of the NTP object, which is LayerTypeNTP. +func (d *NTP) LayerType() gopacket.LayerType { + return LayerTypeNTP +} + +//****************************************************************************** + +// decodeNTP analyses a byte slice and attempts to decode it as an NTP +// record of a UDP packet. +// +// If it succeeds, it loads p with information about the packet and returns nil. +// If it fails, it returns an error (non nil). +// +// This function is employed in layertypes.go to register the NTP layer. +func decodeNTP(data []byte, p gopacket.PacketBuilder) error { + + // Attempt to decode the byte slice. + d := &NTP{} + err := d.DecodeFromBytes(data, p) + if err != nil { + return err + } + + // If the decoding worked, add the layer to the packet and set it + // as the application layer too, if there isn't already one. + p.AddLayer(d) + p.SetApplicationLayer(d) + + return nil +} + +//****************************************************************************** + +// DecodeFromBytes analyses a byte slice and attempts to decode it as an NTP +// record of a UDP packet. +// +// Upon succeeds, it loads the NTP object with information about the packet +// and returns nil. +// Upon failure, it returns an error (non nil). +func (d *NTP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + + // If the data block is too short to be a NTP record, then return an error. + if len(data) < ntpMinimumRecordSizeInBytes { + df.SetTruncated() + return errors.New("NTP packet too short") + } + + // RFC 5905 does not appear to define a maximum NTP record length. + // The protocol allows "extension fields" to be included in the record, + // and states about these fields:" + // + // "While the minimum field length containing required fields is + // four words (16 octets), a maximum field length remains to be + // established." + // + // For this reason, the packet length is not checked here for being too long. + + // NTP type embeds type BaseLayer which contains two fields: + // Contents is supposed to contain the bytes of the data at this level. + // Payload is supposed to contain the payload of this level. + // Here we set the baselayer to be the bytes of the NTP record. + d.BaseLayer = BaseLayer{Contents: data[:len(data)]} + + // Extract the fields from the block of bytes. + // To make sense of this, refer to the packet diagram + // above and the section on endian conventions. + + // The first few fields are all packed into the first 32 bits. Unpack them. + f := data[0] + d.LeapIndicator = NTPLeapIndicator((f & 0xC0) >> 6) + d.Version = NTPVersion((f & 0x38) >> 3) + d.Mode = NTPMode(f & 0x07) + d.Stratum = NTPStratum(data[1]) + d.Poll = NTPLog2Seconds(data[2]) + d.Precision = NTPLog2Seconds(data[3]) + + // The remaining fields can just be copied in big endian order. + d.RootDelay = NTPFixed16Seconds(binary.BigEndian.Uint32(data[4:8])) + d.RootDispersion = NTPFixed16Seconds(binary.BigEndian.Uint32(data[8:12])) + d.ReferenceID = NTPReferenceID(binary.BigEndian.Uint32(data[12:16])) + d.ReferenceTimestamp = NTPTimestamp(binary.BigEndian.Uint64(data[16:24])) + d.OriginTimestamp = NTPTimestamp(binary.BigEndian.Uint64(data[24:32])) + d.ReceiveTimestamp = NTPTimestamp(binary.BigEndian.Uint64(data[32:40])) + d.TransmitTimestamp = NTPTimestamp(binary.BigEndian.Uint64(data[40:48])) + + // This layer does not attempt to analyse the extension bytes. + // But if there are any, we'd like the user to know. So we just + // place them all in an ExtensionBytes field. + d.ExtensionBytes = data[48:] + + // Return no error. + return nil +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (d *NTP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + data, err := b.PrependBytes(ntpMinimumRecordSizeInBytes) + if err != nil { + return err + } + + // Pack the first few fields into the first 32 bits. + h := uint8(0) + h |= (uint8(d.LeapIndicator) << 6) & 0xC0 + h |= (uint8(d.Version) << 3) & 0x38 + h |= (uint8(d.Mode)) & 0x07 + data[0] = byte(h) + data[1] = byte(d.Stratum) + data[2] = byte(d.Poll) + data[3] = byte(d.Precision) + + // The remaining fields can just be copied in big endian order. + binary.BigEndian.PutUint32(data[4:8], uint32(d.RootDelay)) + binary.BigEndian.PutUint32(data[8:12], uint32(d.RootDispersion)) + binary.BigEndian.PutUint32(data[12:16], uint32(d.ReferenceID)) + binary.BigEndian.PutUint64(data[16:24], uint64(d.ReferenceTimestamp)) + binary.BigEndian.PutUint64(data[24:32], uint64(d.OriginTimestamp)) + binary.BigEndian.PutUint64(data[32:40], uint64(d.ReceiveTimestamp)) + binary.BigEndian.PutUint64(data[40:48], uint64(d.TransmitTimestamp)) + + ex, err := b.AppendBytes(len(d.ExtensionBytes)) + if err != nil { + return err + } + copy(ex, d.ExtensionBytes) + + return nil +} + +//****************************************************************************** + +// CanDecode returns a set of layers that NTP objects can decode. +// As NTP objects can only decide the NTP layer, we can return just that layer. +// Apparently a single layer type implements LayerClass. +func (d *NTP) CanDecode() gopacket.LayerClass { + return LayerTypeNTP +} + +//****************************************************************************** + +// NextLayerType specifies the next layer that GoPacket should attempt to +// analyse after this (NTP) layer. As NTP packets do not contain any payload +// bytes, there are no further layers to analyse. +func (d *NTP) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypeZero +} + +//****************************************************************************** + +// NTP packets do not carry any data payload, so the empty byte slice is retured. +// In Go, a nil slice is functionally identical to an empty slice, so we +// return nil to avoid a heap allocation. +func (d *NTP) Payload() []byte { + return nil +} + +//****************************************************************************** +//* End Of NTP File * +//****************************************************************************** diff --git a/vendor/github.com/google/gopacket/layers/pflog.go b/vendor/github.com/google/gopacket/layers/pflog.go new file mode 100644 index 0000000..853882f --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/pflog.go @@ -0,0 +1,76 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + + "github.com/google/gopacket" +) + +type PFDirection uint8 + +const ( + PFDirectionInOut PFDirection = 0 + PFDirectionIn PFDirection = 1 + PFDirectionOut PFDirection = 2 +) + +// PFLog provides the layer for 'pf' packet-filter logging, as described at +// http://www.freebsd.org/cgi/man.cgi?query=pflog&sektion=4 +type PFLog struct { + BaseLayer + Length uint8 + Family ProtocolFamily + Action, Reason uint8 + IFName, Ruleset []byte + RuleNum, SubruleNum uint32 + UID uint32 + PID int32 + RuleUID uint32 + RulePID int32 + Direction PFDirection + // The remainder is padding +} + +func (pf *PFLog) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + pf.Length = data[0] + pf.Family = ProtocolFamily(data[1]) + pf.Action = data[2] + pf.Reason = data[3] + pf.IFName = data[4:20] + pf.Ruleset = data[20:36] + pf.RuleNum = binary.BigEndian.Uint32(data[36:40]) + pf.SubruleNum = binary.BigEndian.Uint32(data[40:44]) + pf.UID = binary.BigEndian.Uint32(data[44:48]) + pf.PID = int32(binary.BigEndian.Uint32(data[48:52])) + pf.RuleUID = binary.BigEndian.Uint32(data[52:56]) + pf.RulePID = int32(binary.BigEndian.Uint32(data[56:60])) + pf.Direction = PFDirection(data[60]) + if pf.Length%4 != 1 { + return errors.New("PFLog header length should be 3 less than multiple of 4") + } + actualLength := int(pf.Length) + 3 + pf.Contents = data[:actualLength] + pf.Payload = data[actualLength:] + return nil +} + +// LayerType returns layers.LayerTypePFLog +func (pf *PFLog) LayerType() gopacket.LayerType { return LayerTypePFLog } + +func (pf *PFLog) CanDecode() gopacket.LayerClass { return LayerTypePFLog } + +func (pf *PFLog) NextLayerType() gopacket.LayerType { + return pf.Family.LayerType() +} + +func decodePFLog(data []byte, p gopacket.PacketBuilder) error { + pf := &PFLog{} + return decodingLayerDecoder(pf, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/ports.go b/vendor/github.com/google/gopacket/layers/ports.go new file mode 100644 index 0000000..e9dd5e1 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/ports.go @@ -0,0 +1,139 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "fmt" + "strconv" + + "github.com/google/gopacket" +) + +// TCPPort is a port in a TCP layer. +type TCPPort uint16 + +// UDPPort is a port in a UDP layer. +type UDPPort uint16 + +// RUDPPort is a port in a RUDP layer. +type RUDPPort uint8 + +// SCTPPort is a port in a SCTP layer. +type SCTPPort uint16 + +// UDPLitePort is a port in a UDPLite layer. +type UDPLitePort uint16 + +// RUDPPortNames contains the string names for all RUDP ports. +var RUDPPortNames = map[RUDPPort]string{} + +// UDPLitePortNames contains the string names for all UDPLite ports. +var UDPLitePortNames = map[UDPLitePort]string{} + +// {TCP,UDP,SCTP}PortNames can be found in iana_ports.go + +// String returns the port as "number(name)" if there's a well-known port name, +// or just "number" if there isn't. Well-known names are stored in +// TCPPortNames. +func (a TCPPort) String() string { + if name, ok := TCPPortNames[a]; ok { + return fmt.Sprintf("%d(%s)", a, name) + } + return strconv.Itoa(int(a)) +} + +// LayerType returns a LayerType that would be able to decode the +// application payload. It uses some well-known ports such as 53 for +// DNS. +// +// Returns gopacket.LayerTypePayload for unknown/unsupported port numbers. +func (a TCPPort) LayerType() gopacket.LayerType { + lt := tcpPortLayerType[uint16(a)] + if lt != 0 { + return lt + } + return gopacket.LayerTypePayload +} + +var tcpPortLayerType = [65536]gopacket.LayerType{ + 53: LayerTypeDNS, +} + +// RegisterTCPPortLayerType creates a new mapping between a TCPPort +// and an underlaying LayerType. +func RegisterTCPPortLayerType(port TCPPort, layerType gopacket.LayerType) { + tcpPortLayerType[port] = layerType +} + +// String returns the port as "number(name)" if there's a well-known port name, +// or just "number" if there isn't. Well-known names are stored in +// UDPPortNames. +func (a UDPPort) String() string { + if name, ok := UDPPortNames[a]; ok { + return fmt.Sprintf("%d(%s)", a, name) + } + return strconv.Itoa(int(a)) +} + +// LayerType returns a LayerType that would be able to decode the +// application payload. It uses some well-known ports such as 53 for +// DNS. +// +// Returns gopacket.LayerTypePayload for unknown/unsupported port numbers. +func (a UDPPort) LayerType() gopacket.LayerType { + lt := udpPortLayerType[uint16(a)] + if lt != 0 { + return lt + } + return gopacket.LayerTypePayload +} + +var udpPortLayerType = [65536]gopacket.LayerType{ + 53: LayerTypeDNS, + 123: LayerTypeNTP, + 4789: LayerTypeVXLAN, + 67: LayerTypeDHCPv4, + 68: LayerTypeDHCPv4, + 6343: LayerTypeSFlow, + 6081: LayerTypeGeneve, +} + +// RegisterUDPPortLayerType creates a new mapping between a UDPPort +// and an underlaying LayerType. +func RegisterUDPPortLayerType(port UDPPort, layerType gopacket.LayerType) { + udpPortLayerType[port] = layerType +} + +// String returns the port as "number(name)" if there's a well-known port name, +// or just "number" if there isn't. Well-known names are stored in +// RUDPPortNames. +func (a RUDPPort) String() string { + if name, ok := RUDPPortNames[a]; ok { + return fmt.Sprintf("%d(%s)", a, name) + } + return strconv.Itoa(int(a)) +} + +// String returns the port as "number(name)" if there's a well-known port name, +// or just "number" if there isn't. Well-known names are stored in +// SCTPPortNames. +func (a SCTPPort) String() string { + if name, ok := SCTPPortNames[a]; ok { + return fmt.Sprintf("%d(%s)", a, name) + } + return strconv.Itoa(int(a)) +} + +// String returns the port as "number(name)" if there's a well-known port name, +// or just "number" if there isn't. Well-known names are stored in +// UDPLitePortNames. +func (a UDPLitePort) String() string { + if name, ok := UDPLitePortNames[a]; ok { + return fmt.Sprintf("%d(%s)", a, name) + } + return strconv.Itoa(int(a)) +} diff --git a/vendor/github.com/google/gopacket/layers/ppp.go b/vendor/github.com/google/gopacket/layers/ppp.go new file mode 100644 index 0000000..1d2e7b8 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/ppp.go @@ -0,0 +1,74 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "github.com/google/gopacket" +) + +// PPP is the layer for PPP encapsulation headers. +type PPP struct { + BaseLayer + PPPType PPPType +} + +// PPPEndpoint is a singleton endpoint for PPP. Since there is no actual +// addressing for the two ends of a PPP connection, we use a singleton value +// named 'point' for each endpoint. +var PPPEndpoint = gopacket.NewEndpoint(EndpointPPP, nil) + +// PPPFlow is a singleton flow for PPP. Since there is no actual addressing for +// the two ends of a PPP connection, we use a singleton value to represent the +// flow for all PPP connections. +var PPPFlow = gopacket.NewFlow(EndpointPPP, nil, nil) + +// LayerType returns LayerTypePPP +func (p *PPP) LayerType() gopacket.LayerType { return LayerTypePPP } + +// LinkFlow returns PPPFlow. +func (p *PPP) LinkFlow() gopacket.Flow { return PPPFlow } + +func decodePPP(data []byte, p gopacket.PacketBuilder) error { + ppp := &PPP{} + if data[0]&0x1 == 0 { + if data[1]&0x1 == 0 { + return errors.New("PPP has invalid type") + } + ppp.PPPType = PPPType(binary.BigEndian.Uint16(data[:2])) + ppp.Contents = data[:2] + ppp.Payload = data[2:] + } else { + ppp.PPPType = PPPType(data[0]) + ppp.Contents = data[:1] + ppp.Payload = data[1:] + } + p.AddLayer(ppp) + p.SetLinkLayer(ppp) + return p.NextDecoder(ppp.PPPType) +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (p *PPP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + if p.PPPType&0x100 == 0 { + bytes, err := b.PrependBytes(2) + if err != nil { + return err + } + binary.BigEndian.PutUint16(bytes, uint16(p.PPPType)) + } else { + bytes, err := b.PrependBytes(1) + if err != nil { + return err + } + bytes[0] = uint8(p.PPPType) + } + return nil +} diff --git a/vendor/github.com/google/gopacket/layers/pppoe.go b/vendor/github.com/google/gopacket/layers/pppoe.go new file mode 100644 index 0000000..14cd63a --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/pppoe.go @@ -0,0 +1,60 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "github.com/google/gopacket" +) + +// PPPoE is the layer for PPPoE encapsulation headers. +type PPPoE struct { + BaseLayer + Version uint8 + Type uint8 + Code PPPoECode + SessionId uint16 + Length uint16 +} + +// LayerType returns gopacket.LayerTypePPPoE. +func (p *PPPoE) LayerType() gopacket.LayerType { + return LayerTypePPPoE +} + +// decodePPPoE decodes the PPPoE header (see http://tools.ietf.org/html/rfc2516). +func decodePPPoE(data []byte, p gopacket.PacketBuilder) error { + pppoe := &PPPoE{ + Version: data[0] >> 4, + Type: data[0] & 0x0F, + Code: PPPoECode(data[1]), + SessionId: binary.BigEndian.Uint16(data[2:4]), + Length: binary.BigEndian.Uint16(data[4:6]), + } + pppoe.BaseLayer = BaseLayer{data[:6], data[6 : 6+pppoe.Length]} + p.AddLayer(pppoe) + return p.NextDecoder(pppoe.Code) +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (p *PPPoE) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + payload := b.Bytes() + bytes, err := b.PrependBytes(6) + if err != nil { + return err + } + bytes[0] = (p.Version << 4) | p.Type + bytes[1] = byte(p.Code) + binary.BigEndian.PutUint16(bytes[2:], p.SessionId) + if opts.FixLengths { + p.Length = uint16(len(payload)) + } + binary.BigEndian.PutUint16(bytes[4:], p.Length) + return nil +} diff --git a/vendor/github.com/google/gopacket/layers/prism.go b/vendor/github.com/google/gopacket/layers/prism.go new file mode 100644 index 0000000..e1711e7 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/prism.go @@ -0,0 +1,146 @@ +// Copyright 2015 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +// http://www.tcpdump.org/linktypes/LINKTYPE_IEEE802_11_PRISM.html + +package layers + +import ( + "encoding/binary" + "errors" + + "github.com/google/gopacket" +) + +func decodePrismValue(data []byte, pv *PrismValue) { + pv.DID = PrismDID(binary.LittleEndian.Uint32(data[0:4])) + pv.Status = binary.LittleEndian.Uint16(data[4:6]) + pv.Length = binary.LittleEndian.Uint16(data[6:8]) + pv.Data = data[8 : 8+pv.Length] +} + +type PrismDID uint32 + +const ( + PrismDIDType1HostTime PrismDID = 0x10044 + PrismDIDType2HostTime PrismDID = 0x01041 + PrismDIDType1MACTime PrismDID = 0x20044 + PrismDIDType2MACTime PrismDID = 0x02041 + PrismDIDType1Channel PrismDID = 0x30044 + PrismDIDType2Channel PrismDID = 0x03041 + PrismDIDType1RSSI PrismDID = 0x40044 + PrismDIDType2RSSI PrismDID = 0x04041 + PrismDIDType1SignalQuality PrismDID = 0x50044 + PrismDIDType2SignalQuality PrismDID = 0x05041 + PrismDIDType1Signal PrismDID = 0x60044 + PrismDIDType2Signal PrismDID = 0x06041 + PrismDIDType1Noise PrismDID = 0x70044 + PrismDIDType2Noise PrismDID = 0x07041 + PrismDIDType1Rate PrismDID = 0x80044 + PrismDIDType2Rate PrismDID = 0x08041 + PrismDIDType1TransmittedFrameIndicator PrismDID = 0x90044 + PrismDIDType2TransmittedFrameIndicator PrismDID = 0x09041 + PrismDIDType1FrameLength PrismDID = 0xA0044 + PrismDIDType2FrameLength PrismDID = 0x0A041 +) + +const ( + PrismType1MessageCode uint16 = 0x00000044 + PrismType2MessageCode uint16 = 0x00000041 +) + +func (p PrismDID) String() string { + dids := map[PrismDID]string{ + PrismDIDType1HostTime: "Host Time", + PrismDIDType2HostTime: "Host Time", + PrismDIDType1MACTime: "MAC Time", + PrismDIDType2MACTime: "MAC Time", + PrismDIDType1Channel: "Channel", + PrismDIDType2Channel: "Channel", + PrismDIDType1RSSI: "RSSI", + PrismDIDType2RSSI: "RSSI", + PrismDIDType1SignalQuality: "Signal Quality", + PrismDIDType2SignalQuality: "Signal Quality", + PrismDIDType1Signal: "Signal", + PrismDIDType2Signal: "Signal", + PrismDIDType1Noise: "Noise", + PrismDIDType2Noise: "Noise", + PrismDIDType1Rate: "Rate", + PrismDIDType2Rate: "Rate", + PrismDIDType1TransmittedFrameIndicator: "Transmitted Frame Indicator", + PrismDIDType2TransmittedFrameIndicator: "Transmitted Frame Indicator", + PrismDIDType1FrameLength: "Frame Length", + PrismDIDType2FrameLength: "Frame Length", + } + + if str, ok := dids[p]; ok { + return str + } + + return "Unknown DID" +} + +type PrismValue struct { + DID PrismDID + Status uint16 + Length uint16 + Data []byte +} + +func (pv *PrismValue) IsSupplied() bool { + return pv.Status == 1 +} + +var ErrPrismExpectedMoreData = errors.New("Expected more data.") +var ErrPrismInvalidCode = errors.New("Invalid header code.") + +func decodePrismHeader(data []byte, p gopacket.PacketBuilder) error { + d := &PrismHeader{} + return decodingLayerDecoder(d, data, p) +} + +type PrismHeader struct { + BaseLayer + Code uint16 + Length uint16 + DeviceName string + Values []PrismValue +} + +func (m *PrismHeader) LayerType() gopacket.LayerType { return LayerTypePrismHeader } + +func (m *PrismHeader) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + m.Code = binary.LittleEndian.Uint16(data[0:4]) + m.Length = binary.LittleEndian.Uint16(data[4:8]) + m.DeviceName = string(data[8:24]) + m.BaseLayer = BaseLayer{Contents: data[:m.Length], Payload: data[m.Length:len(data)]} + + switch m.Code { + case PrismType1MessageCode: + fallthrough + case PrismType2MessageCode: + // valid message code + default: + return ErrPrismInvalidCode + } + + offset := uint16(24) + + m.Values = make([]PrismValue, (m.Length-offset)/12) + for i := 0; i < len(m.Values); i++ { + decodePrismValue(data[offset:offset+12], &m.Values[i]) + offset += 12 + } + + if offset != m.Length { + return ErrPrismExpectedMoreData + } + + return nil +} + +func (m *PrismHeader) CanDecode() gopacket.LayerClass { return LayerTypePrismHeader } +func (m *PrismHeader) NextLayerType() gopacket.LayerType { return LayerTypeDot11 } diff --git a/vendor/github.com/google/gopacket/layers/radiotap.go b/vendor/github.com/google/gopacket/layers/radiotap.go new file mode 100644 index 0000000..4304e75 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/radiotap.go @@ -0,0 +1,1045 @@ +// Copyright 2014 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "bytes" + "encoding/binary" + "fmt" + "hash/crc32" + "strings" + + "github.com/google/gopacket" +) + +// align calculates the number of bytes needed to align with the width +// on the offset, returning the number of bytes we need to skip to +// align to the offset (width). +func align(offset uint16, width uint16) uint16 { + return ((((offset) + ((width) - 1)) & (^((width) - 1))) - offset) +} + +type RadioTapPresent uint32 + +const ( + RadioTapPresentTSFT RadioTapPresent = 1 << iota + RadioTapPresentFlags + RadioTapPresentRate + RadioTapPresentChannel + RadioTapPresentFHSS + RadioTapPresentDBMAntennaSignal + RadioTapPresentDBMAntennaNoise + RadioTapPresentLockQuality + RadioTapPresentTxAttenuation + RadioTapPresentDBTxAttenuation + RadioTapPresentDBMTxPower + RadioTapPresentAntenna + RadioTapPresentDBAntennaSignal + RadioTapPresentDBAntennaNoise + RadioTapPresentRxFlags + RadioTapPresentTxFlags + RadioTapPresentRtsRetries + RadioTapPresentDataRetries + _ + RadioTapPresentMCS + RadioTapPresentAMPDUStatus + RadioTapPresentVHT + RadioTapPresentEXT RadioTapPresent = 1 << 31 +) + +func (r RadioTapPresent) TSFT() bool { + return r&RadioTapPresentTSFT != 0 +} +func (r RadioTapPresent) Flags() bool { + return r&RadioTapPresentFlags != 0 +} +func (r RadioTapPresent) Rate() bool { + return r&RadioTapPresentRate != 0 +} +func (r RadioTapPresent) Channel() bool { + return r&RadioTapPresentChannel != 0 +} +func (r RadioTapPresent) FHSS() bool { + return r&RadioTapPresentFHSS != 0 +} +func (r RadioTapPresent) DBMAntennaSignal() bool { + return r&RadioTapPresentDBMAntennaSignal != 0 +} +func (r RadioTapPresent) DBMAntennaNoise() bool { + return r&RadioTapPresentDBMAntennaNoise != 0 +} +func (r RadioTapPresent) LockQuality() bool { + return r&RadioTapPresentLockQuality != 0 +} +func (r RadioTapPresent) TxAttenuation() bool { + return r&RadioTapPresentTxAttenuation != 0 +} +func (r RadioTapPresent) DBTxAttenuation() bool { + return r&RadioTapPresentDBTxAttenuation != 0 +} +func (r RadioTapPresent) DBMTxPower() bool { + return r&RadioTapPresentDBMTxPower != 0 +} +func (r RadioTapPresent) Antenna() bool { + return r&RadioTapPresentAntenna != 0 +} +func (r RadioTapPresent) DBAntennaSignal() bool { + return r&RadioTapPresentDBAntennaSignal != 0 +} +func (r RadioTapPresent) DBAntennaNoise() bool { + return r&RadioTapPresentDBAntennaNoise != 0 +} +func (r RadioTapPresent) RxFlags() bool { + return r&RadioTapPresentRxFlags != 0 +} +func (r RadioTapPresent) TxFlags() bool { + return r&RadioTapPresentTxFlags != 0 +} +func (r RadioTapPresent) RtsRetries() bool { + return r&RadioTapPresentRtsRetries != 0 +} +func (r RadioTapPresent) DataRetries() bool { + return r&RadioTapPresentDataRetries != 0 +} +func (r RadioTapPresent) MCS() bool { + return r&RadioTapPresentMCS != 0 +} +func (r RadioTapPresent) AMPDUStatus() bool { + return r&RadioTapPresentAMPDUStatus != 0 +} +func (r RadioTapPresent) VHT() bool { + return r&RadioTapPresentVHT != 0 +} +func (r RadioTapPresent) EXT() bool { + return r&RadioTapPresentEXT != 0 +} + +type RadioTapChannelFlags uint16 + +const ( + RadioTapChannelFlagsTurbo RadioTapChannelFlags = 0x0010 // Turbo channel + RadioTapChannelFlagsCCK RadioTapChannelFlags = 0x0020 // CCK channel + RadioTapChannelFlagsOFDM RadioTapChannelFlags = 0x0040 // OFDM channel + RadioTapChannelFlagsGhz2 RadioTapChannelFlags = 0x0080 // 2 GHz spectrum channel. + RadioTapChannelFlagsGhz5 RadioTapChannelFlags = 0x0100 // 5 GHz spectrum channel + RadioTapChannelFlagsPassive RadioTapChannelFlags = 0x0200 // Only passive scan allowed + RadioTapChannelFlagsDynamic RadioTapChannelFlags = 0x0400 // Dynamic CCK-OFDM channel + RadioTapChannelFlagsGFSK RadioTapChannelFlags = 0x0800 // GFSK channel (FHSS PHY) +) + +func (r RadioTapChannelFlags) Turbo() bool { + return r&RadioTapChannelFlagsTurbo != 0 +} +func (r RadioTapChannelFlags) CCK() bool { + return r&RadioTapChannelFlagsCCK != 0 +} +func (r RadioTapChannelFlags) OFDM() bool { + return r&RadioTapChannelFlagsOFDM != 0 +} +func (r RadioTapChannelFlags) Ghz2() bool { + return r&RadioTapChannelFlagsGhz2 != 0 +} +func (r RadioTapChannelFlags) Ghz5() bool { + return r&RadioTapChannelFlagsGhz5 != 0 +} +func (r RadioTapChannelFlags) Passive() bool { + return r&RadioTapChannelFlagsPassive != 0 +} +func (r RadioTapChannelFlags) Dynamic() bool { + return r&RadioTapChannelFlagsDynamic != 0 +} +func (r RadioTapChannelFlags) GFSK() bool { + return r&RadioTapChannelFlagsGFSK != 0 +} + +// String provides a human readable string for RadioTapChannelFlags. +// This string is possibly subject to change over time; if you're storing this +// persistently, you should probably store the RadioTapChannelFlags value, not its string. +func (a RadioTapChannelFlags) String() string { + var out bytes.Buffer + if a.Turbo() { + out.WriteString("Turbo,") + } + if a.CCK() { + out.WriteString("CCK,") + } + if a.OFDM() { + out.WriteString("OFDM,") + } + if a.Ghz2() { + out.WriteString("Ghz2,") + } + if a.Ghz5() { + out.WriteString("Ghz5,") + } + if a.Passive() { + out.WriteString("Passive,") + } + if a.Dynamic() { + out.WriteString("Dynamic,") + } + if a.GFSK() { + out.WriteString("GFSK,") + } + + if length := out.Len(); length > 0 { + return string(out.Bytes()[:length-1]) // strip final comma + } + return "" +} + +type RadioTapFlags uint8 + +const ( + RadioTapFlagsCFP RadioTapFlags = 1 << iota // sent/received during CFP + RadioTapFlagsShortPreamble // sent/received * with short * preamble + RadioTapFlagsWEP // sent/received * with WEP encryption + RadioTapFlagsFrag // sent/received * with fragmentation + RadioTapFlagsFCS // frame includes FCS + RadioTapFlagsDatapad // frame has padding between * 802.11 header and payload * (to 32-bit boundary) + RadioTapFlagsBadFCS // does not pass FCS check + RadioTapFlagsShortGI // HT short GI +) + +func (r RadioTapFlags) CFP() bool { + return r&RadioTapFlagsCFP != 0 +} +func (r RadioTapFlags) ShortPreamble() bool { + return r&RadioTapFlagsShortPreamble != 0 +} +func (r RadioTapFlags) WEP() bool { + return r&RadioTapFlagsWEP != 0 +} +func (r RadioTapFlags) Frag() bool { + return r&RadioTapFlagsFrag != 0 +} +func (r RadioTapFlags) FCS() bool { + return r&RadioTapFlagsFCS != 0 +} +func (r RadioTapFlags) Datapad() bool { + return r&RadioTapFlagsDatapad != 0 +} +func (r RadioTapFlags) BadFCS() bool { + return r&RadioTapFlagsBadFCS != 0 +} +func (r RadioTapFlags) ShortGI() bool { + return r&RadioTapFlagsShortGI != 0 +} + +// String provides a human readable string for RadioTapFlags. +// This string is possibly subject to change over time; if you're storing this +// persistently, you should probably store the RadioTapFlags value, not its string. +func (a RadioTapFlags) String() string { + var out bytes.Buffer + if a.CFP() { + out.WriteString("CFP,") + } + if a.ShortPreamble() { + out.WriteString("SHORT-PREAMBLE,") + } + if a.WEP() { + out.WriteString("WEP,") + } + if a.Frag() { + out.WriteString("FRAG,") + } + if a.FCS() { + out.WriteString("FCS,") + } + if a.Datapad() { + out.WriteString("DATAPAD,") + } + if a.ShortGI() { + out.WriteString("SHORT-GI,") + } + + if length := out.Len(); length > 0 { + return string(out.Bytes()[:length-1]) // strip final comma + } + return "" +} + +type RadioTapRate uint8 + +func (a RadioTapRate) String() string { + return fmt.Sprintf("%v Mb/s", 0.5*float32(a)) +} + +type RadioTapChannelFrequency uint16 + +func (a RadioTapChannelFrequency) String() string { + return fmt.Sprintf("%d MHz", a) +} + +type RadioTapRxFlags uint16 + +const ( + RadioTapRxFlagsBadPlcp RadioTapRxFlags = 0x0002 +) + +func (self RadioTapRxFlags) BadPlcp() bool { + return self&RadioTapRxFlagsBadPlcp != 0 +} + +func (self RadioTapRxFlags) String() string { + if self.BadPlcp() { + return "BADPLCP" + } + return "" +} + +type RadioTapTxFlags uint16 + +const ( + RadioTapTxFlagsFail RadioTapTxFlags = 1 << iota + RadioTapTxFlagsCTS + RadioTapTxFlagsRTS + RadioTapTxFlagsNoACK +) + +func (self RadioTapTxFlags) Fail() bool { return self&RadioTapTxFlagsFail != 0 } +func (self RadioTapTxFlags) CTS() bool { return self&RadioTapTxFlagsCTS != 0 } +func (self RadioTapTxFlags) RTS() bool { return self&RadioTapTxFlagsRTS != 0 } +func (self RadioTapTxFlags) NoACK() bool { return self&RadioTapTxFlagsNoACK != 0 } + +func (self RadioTapTxFlags) String() string { + var tokens []string + if self.Fail() { + tokens = append(tokens, "Fail") + } + if self.CTS() { + tokens = append(tokens, "CTS") + } + if self.RTS() { + tokens = append(tokens, "RTS") + } + if self.NoACK() { + tokens = append(tokens, "NoACK") + } + return strings.Join(tokens, ",") +} + +type RadioTapMCS struct { + Known RadioTapMCSKnown + Flags RadioTapMCSFlags + MCS uint8 +} + +func (self RadioTapMCS) String() string { + var tokens []string + if self.Known.Bandwidth() { + token := "?" + switch self.Flags.Bandwidth() { + case 0: + token = "20" + case 1: + token = "40" + case 2: + token = "40(20L)" + case 3: + token = "40(20U)" + } + tokens = append(tokens, token) + } + if self.Known.MCSIndex() { + tokens = append(tokens, fmt.Sprintf("MCSIndex#%d", self.MCS)) + } + if self.Known.GuardInterval() { + if self.Flags.ShortGI() { + tokens = append(tokens, fmt.Sprintf("shortGI")) + } else { + tokens = append(tokens, fmt.Sprintf("longGI")) + } + } + if self.Known.HTFormat() { + if self.Flags.Greenfield() { + tokens = append(tokens, fmt.Sprintf("HT-greenfield")) + } else { + tokens = append(tokens, fmt.Sprintf("HT-mixed")) + } + } + if self.Known.FECType() { + if self.Flags.FECLDPC() { + tokens = append(tokens, fmt.Sprintf("LDPC")) + } else { + tokens = append(tokens, fmt.Sprintf("BCC")) + } + } + if self.Known.STBC() { + tokens = append(tokens, fmt.Sprintf("STBC#%d", self.Flags.STBC())) + } + if self.Known.NESS() { + num := 0 + if self.Known.NESS1() { + num |= 0x02 + } + if self.Flags.NESS0() { + num |= 0x01 + } + tokens = append(tokens, fmt.Sprintf("num-of-ESS#%d", num)) + } + return strings.Join(tokens, ",") +} + +type RadioTapMCSKnown uint8 + +const ( + RadioTapMCSKnownBandwidth RadioTapMCSKnown = 1 << iota + RadioTapMCSKnownMCSIndex + RadioTapMCSKnownGuardInterval + RadioTapMCSKnownHTFormat + RadioTapMCSKnownFECType + RadioTapMCSKnownSTBC + RadioTapMCSKnownNESS + RadioTapMCSKnownNESS1 +) + +func (self RadioTapMCSKnown) Bandwidth() bool { return self&RadioTapMCSKnownBandwidth != 0 } +func (self RadioTapMCSKnown) MCSIndex() bool { return self&RadioTapMCSKnownMCSIndex != 0 } +func (self RadioTapMCSKnown) GuardInterval() bool { return self&RadioTapMCSKnownGuardInterval != 0 } +func (self RadioTapMCSKnown) HTFormat() bool { return self&RadioTapMCSKnownHTFormat != 0 } +func (self RadioTapMCSKnown) FECType() bool { return self&RadioTapMCSKnownFECType != 0 } +func (self RadioTapMCSKnown) STBC() bool { return self&RadioTapMCSKnownSTBC != 0 } +func (self RadioTapMCSKnown) NESS() bool { return self&RadioTapMCSKnownNESS != 0 } +func (self RadioTapMCSKnown) NESS1() bool { return self&RadioTapMCSKnownNESS1 != 0 } + +type RadioTapMCSFlags uint8 + +const ( + RadioTapMCSFlagsBandwidthMask RadioTapMCSFlags = 0x03 + RadioTapMCSFlagsShortGI = 0x04 + RadioTapMCSFlagsGreenfield = 0x08 + RadioTapMCSFlagsFECLDPC = 0x10 + RadioTapMCSFlagsSTBCMask = 0x60 + RadioTapMCSFlagsNESS0 = 0x80 +) + +func (self RadioTapMCSFlags) Bandwidth() int { + return int(self & RadioTapMCSFlagsBandwidthMask) +} +func (self RadioTapMCSFlags) ShortGI() bool { return self&RadioTapMCSFlagsShortGI != 0 } +func (self RadioTapMCSFlags) Greenfield() bool { return self&RadioTapMCSFlagsGreenfield != 0 } +func (self RadioTapMCSFlags) FECLDPC() bool { return self&RadioTapMCSFlagsFECLDPC != 0 } +func (self RadioTapMCSFlags) STBC() int { + return int(self&RadioTapMCSFlagsSTBCMask) >> 5 +} +func (self RadioTapMCSFlags) NESS0() bool { return self&RadioTapMCSFlagsNESS0 != 0 } + +type RadioTapAMPDUStatus struct { + Reference uint32 + Flags RadioTapAMPDUStatusFlags + CRC uint8 +} + +func (self RadioTapAMPDUStatus) String() string { + tokens := []string{ + fmt.Sprintf("ref#%x", self.Reference), + } + if self.Flags.ReportZerolen() && self.Flags.IsZerolen() { + tokens = append(tokens, fmt.Sprintf("zero-length")) + } + if self.Flags.LastKnown() && self.Flags.IsLast() { + tokens = append(tokens, "last") + } + if self.Flags.DelimCRCErr() { + tokens = append(tokens, "delimiter CRC error") + } + if self.Flags.DelimCRCKnown() { + tokens = append(tokens, fmt.Sprintf("delimiter-CRC=%02x", self.CRC)) + } + return strings.Join(tokens, ",") +} + +type RadioTapAMPDUStatusFlags uint16 + +const ( + RadioTapAMPDUStatusFlagsReportZerolen RadioTapAMPDUStatusFlags = 1 << iota + RadioTapAMPDUIsZerolen + RadioTapAMPDULastKnown + RadioTapAMPDUIsLast + RadioTapAMPDUDelimCRCErr + RadioTapAMPDUDelimCRCKnown +) + +func (self RadioTapAMPDUStatusFlags) ReportZerolen() bool { + return self&RadioTapAMPDUStatusFlagsReportZerolen != 0 +} +func (self RadioTapAMPDUStatusFlags) IsZerolen() bool { return self&RadioTapAMPDUIsZerolen != 0 } +func (self RadioTapAMPDUStatusFlags) LastKnown() bool { return self&RadioTapAMPDULastKnown != 0 } +func (self RadioTapAMPDUStatusFlags) IsLast() bool { return self&RadioTapAMPDUIsLast != 0 } +func (self RadioTapAMPDUStatusFlags) DelimCRCErr() bool { return self&RadioTapAMPDUDelimCRCErr != 0 } +func (self RadioTapAMPDUStatusFlags) DelimCRCKnown() bool { return self&RadioTapAMPDUDelimCRCKnown != 0 } + +type RadioTapVHT struct { + Known RadioTapVHTKnown + Flags RadioTapVHTFlags + Bandwidth uint8 + MCSNSS [4]RadioTapVHTMCSNSS + Coding uint8 + GroupId uint8 + PartialAID uint16 +} + +func (self RadioTapVHT) String() string { + var tokens []string + if self.Known.STBC() { + if self.Flags.STBC() { + tokens = append(tokens, "STBC") + } else { + tokens = append(tokens, "no STBC") + } + } + if self.Known.TXOPPSNotAllowed() { + if self.Flags.TXOPPSNotAllowed() { + tokens = append(tokens, "TXOP doze not allowed") + } else { + tokens = append(tokens, "TXOP doze allowed") + } + } + if self.Known.GI() { + if self.Flags.SGI() { + tokens = append(tokens, "short GI") + } else { + tokens = append(tokens, "long GI") + } + } + if self.Known.SGINSYMDisambiguation() { + if self.Flags.SGINSYMMod() { + tokens = append(tokens, "NSYM mod 10=9") + } else { + tokens = append(tokens, "NSYM mod 10!=9 or no short GI") + } + } + if self.Known.LDPCExtraOFDMSymbol() { + if self.Flags.LDPCExtraOFDMSymbol() { + tokens = append(tokens, "LDPC extra OFDM symbols") + } else { + tokens = append(tokens, "no LDPC extra OFDM symbols") + } + } + if self.Known.Beamformed() { + if self.Flags.Beamformed() { + tokens = append(tokens, "beamformed") + } else { + tokens = append(tokens, "no beamformed") + } + } + if self.Known.Bandwidth() { + token := "?" + switch self.Bandwidth & 0x1f { + case 0: + token = "20" + case 1: + token = "40" + case 2: + token = "40(20L)" + case 3: + token = "40(20U)" + case 4: + token = "80" + case 5: + token = "80(40L)" + case 6: + token = "80(40U)" + case 7: + token = "80(20LL)" + case 8: + token = "80(20LU)" + case 9: + token = "80(20UL)" + case 10: + token = "80(20UU)" + case 11: + token = "160" + case 12: + token = "160(80L)" + case 13: + token = "160(80U)" + case 14: + token = "160(40LL)" + case 15: + token = "160(40LU)" + case 16: + token = "160(40UL)" + case 17: + token = "160(40UU)" + case 18: + token = "160(20LLL)" + case 19: + token = "160(20LLU)" + case 20: + token = "160(20LUL)" + case 21: + token = "160(20LUU)" + case 22: + token = "160(20ULL)" + case 23: + token = "160(20ULU)" + case 24: + token = "160(20UUL)" + case 25: + token = "160(20UUU)" + } + tokens = append(tokens, token) + } + for i, MCSNSS := range self.MCSNSS { + if MCSNSS.Present() { + fec := "?" + switch self.Coding & (1 << uint8(i)) { + case 0: + fec = "BCC" + case 1: + fec = "LDPC" + } + tokens = append(tokens, fmt.Sprintf("user%d(%s,%s)", i, MCSNSS.String(), fec)) + } + } + if self.Known.GroupId() { + tokens = append(tokens, + fmt.Sprintf("group=%d", self.GroupId)) + } + if self.Known.PartialAID() { + tokens = append(tokens, + fmt.Sprintf("partial-AID=%d", self.PartialAID)) + } + return strings.Join(tokens, ",") +} + +type RadioTapVHTKnown uint16 + +const ( + RadioTapVHTKnownSTBC RadioTapVHTKnown = 1 << iota + RadioTapVHTKnownTXOPPSNotAllowed + RadioTapVHTKnownGI + RadioTapVHTKnownSGINSYMDisambiguation + RadioTapVHTKnownLDPCExtraOFDMSymbol + RadioTapVHTKnownBeamformed + RadioTapVHTKnownBandwidth + RadioTapVHTKnownGroupId + RadioTapVHTKnownPartialAID +) + +func (self RadioTapVHTKnown) STBC() bool { return self&RadioTapVHTKnownSTBC != 0 } +func (self RadioTapVHTKnown) TXOPPSNotAllowed() bool { + return self&RadioTapVHTKnownTXOPPSNotAllowed != 0 +} +func (self RadioTapVHTKnown) GI() bool { return self&RadioTapVHTKnownGI != 0 } +func (self RadioTapVHTKnown) SGINSYMDisambiguation() bool { + return self&RadioTapVHTKnownSGINSYMDisambiguation != 0 +} +func (self RadioTapVHTKnown) LDPCExtraOFDMSymbol() bool { + return self&RadioTapVHTKnownLDPCExtraOFDMSymbol != 0 +} +func (self RadioTapVHTKnown) Beamformed() bool { return self&RadioTapVHTKnownBeamformed != 0 } +func (self RadioTapVHTKnown) Bandwidth() bool { return self&RadioTapVHTKnownBandwidth != 0 } +func (self RadioTapVHTKnown) GroupId() bool { return self&RadioTapVHTKnownGroupId != 0 } +func (self RadioTapVHTKnown) PartialAID() bool { return self&RadioTapVHTKnownPartialAID != 0 } + +type RadioTapVHTFlags uint8 + +const ( + RadioTapVHTFlagsSTBC RadioTapVHTFlags = 1 << iota + RadioTapVHTFlagsTXOPPSNotAllowed + RadioTapVHTFlagsSGI + RadioTapVHTFlagsSGINSYMMod + RadioTapVHTFlagsLDPCExtraOFDMSymbol + RadioTapVHTFlagsBeamformed +) + +func (self RadioTapVHTFlags) STBC() bool { return self&RadioTapVHTFlagsSTBC != 0 } +func (self RadioTapVHTFlags) TXOPPSNotAllowed() bool { + return self&RadioTapVHTFlagsTXOPPSNotAllowed != 0 +} +func (self RadioTapVHTFlags) SGI() bool { return self&RadioTapVHTFlagsSGI != 0 } +func (self RadioTapVHTFlags) SGINSYMMod() bool { return self&RadioTapVHTFlagsSGINSYMMod != 0 } +func (self RadioTapVHTFlags) LDPCExtraOFDMSymbol() bool { + return self&RadioTapVHTFlagsLDPCExtraOFDMSymbol != 0 +} +func (self RadioTapVHTFlags) Beamformed() bool { return self&RadioTapVHTFlagsBeamformed != 0 } + +type RadioTapVHTMCSNSS uint8 + +func (self RadioTapVHTMCSNSS) Present() bool { + return self&0x0F != 0 +} + +func (self RadioTapVHTMCSNSS) String() string { + return fmt.Sprintf("NSS#%dMCS#%d", uint32(self&0xf), uint32(self>>4)) +} + +func decodeRadioTap(data []byte, p gopacket.PacketBuilder) error { + d := &RadioTap{} + // TODO: Should we set LinkLayer here? And implement LinkFlow + return decodingLayerDecoder(d, data, p) +} + +type RadioTap struct { + BaseLayer + + // Version 0. Only increases for drastic changes, introduction of compatible new fields does not count. + Version uint8 + // Length of the whole header in bytes, including it_version, it_pad, it_len, and data fields. + Length uint16 + // Present is a bitmap telling which fields are present. Set bit 31 (0x80000000) to extend the bitmap by another 32 bits. Additional extensions are made by setting bit 31. + Present RadioTapPresent + // TSFT: value in microseconds of the MAC's 64-bit 802.11 Time Synchronization Function timer when the first bit of the MPDU arrived at the MAC. For received frames, only. + TSFT uint64 + Flags RadioTapFlags + // Rate Tx/Rx data rate + Rate RadioTapRate + // ChannelFrequency Tx/Rx frequency in MHz, followed by flags + ChannelFrequency RadioTapChannelFrequency + ChannelFlags RadioTapChannelFlags + // FHSS For frequency-hopping radios, the hop set (first byte) and pattern (second byte). + FHSS uint16 + // DBMAntennaSignal RF signal power at the antenna, decibel difference from one milliwatt. + DBMAntennaSignal int8 + // DBMAntennaNoise RF noise power at the antenna, decibel difference from one milliwatt. + DBMAntennaNoise int8 + // LockQuality Quality of Barker code lock. Unitless. Monotonically nondecreasing with "better" lock strength. Called "Signal Quality" in datasheets. + LockQuality uint16 + // TxAttenuation Transmit power expressed as unitless distance from max power set at factory calibration. 0 is max power. Monotonically nondecreasing with lower power levels. + TxAttenuation uint16 + // DBTxAttenuation Transmit power expressed as decibel distance from max power set at factory calibration. 0 is max power. Monotonically nondecreasing with lower power levels. + DBTxAttenuation uint16 + // DBMTxPower Transmit power expressed as dBm (decibels from a 1 milliwatt reference). This is the absolute power level measured at the antenna port. + DBMTxPower int8 + // Antenna Unitless indication of the Rx/Tx antenna for this packet. The first antenna is antenna 0. + Antenna uint8 + // DBAntennaSignal RF signal power at the antenna, decibel difference from an arbitrary, fixed reference. + DBAntennaSignal uint8 + // DBAntennaNoise RF noise power at the antenna, decibel difference from an arbitrary, fixed reference point. + DBAntennaNoise uint8 + // + RxFlags RadioTapRxFlags + TxFlags RadioTapTxFlags + RtsRetries uint8 + DataRetries uint8 + MCS RadioTapMCS + AMPDUStatus RadioTapAMPDUStatus + VHT RadioTapVHT +} + +func (m *RadioTap) LayerType() gopacket.LayerType { return LayerTypeRadioTap } + +func (m *RadioTap) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + m.Version = uint8(data[0]) + m.Length = binary.LittleEndian.Uint16(data[2:4]) + m.Present = RadioTapPresent(binary.LittleEndian.Uint32(data[4:8])) + + offset := uint16(4) + + for (binary.LittleEndian.Uint32(data[offset:offset+4]) & 0x80000000) != 0 { + // This parser only handles standard radiotap namespace, + // and expects all fields are packed in the first it_present. + // Extended bitmap will be just ignored. + offset += 4 + } + offset += 4 // skip the bitmap + + if m.Present.TSFT() { + offset += align(offset, 8) + m.TSFT = binary.LittleEndian.Uint64(data[offset : offset+8]) + offset += 8 + } + if m.Present.Flags() { + m.Flags = RadioTapFlags(data[offset]) + offset++ + } + if m.Present.Rate() { + m.Rate = RadioTapRate(data[offset]) + offset++ + } + if m.Present.Channel() { + offset += align(offset, 2) + m.ChannelFrequency = RadioTapChannelFrequency(binary.LittleEndian.Uint16(data[offset : offset+2])) + offset += 2 + m.ChannelFlags = RadioTapChannelFlags(binary.LittleEndian.Uint16(data[offset : offset+2])) + offset += 2 + } + if m.Present.FHSS() { + m.FHSS = binary.LittleEndian.Uint16(data[offset : offset+2]) + offset += 2 + } + if m.Present.DBMAntennaSignal() { + m.DBMAntennaSignal = int8(data[offset]) + offset++ + } + if m.Present.DBMAntennaNoise() { + m.DBMAntennaNoise = int8(data[offset]) + offset++ + } + if m.Present.LockQuality() { + offset += align(offset, 2) + m.LockQuality = binary.LittleEndian.Uint16(data[offset : offset+2]) + offset += 2 + } + if m.Present.TxAttenuation() { + offset += align(offset, 2) + m.TxAttenuation = binary.LittleEndian.Uint16(data[offset : offset+2]) + offset += 2 + } + if m.Present.DBTxAttenuation() { + offset += align(offset, 2) + m.DBTxAttenuation = binary.LittleEndian.Uint16(data[offset : offset+2]) + offset += 2 + } + if m.Present.DBMTxPower() { + m.DBMTxPower = int8(data[offset]) + offset++ + } + if m.Present.Antenna() { + m.Antenna = uint8(data[offset]) + offset++ + } + if m.Present.DBAntennaSignal() { + m.DBAntennaSignal = uint8(data[offset]) + offset++ + } + if m.Present.DBAntennaNoise() { + m.DBAntennaNoise = uint8(data[offset]) + offset++ + } + if m.Present.RxFlags() { + offset += align(offset, 2) + m.RxFlags = RadioTapRxFlags(binary.LittleEndian.Uint16(data[offset:])) + offset += 2 + } + if m.Present.TxFlags() { + offset += align(offset, 2) + m.TxFlags = RadioTapTxFlags(binary.LittleEndian.Uint16(data[offset:])) + offset += 2 + } + if m.Present.RtsRetries() { + m.RtsRetries = uint8(data[offset]) + offset++ + } + if m.Present.DataRetries() { + m.DataRetries = uint8(data[offset]) + offset++ + } + if m.Present.MCS() { + m.MCS = RadioTapMCS{ + RadioTapMCSKnown(data[offset]), + RadioTapMCSFlags(data[offset+1]), + uint8(data[offset+2]), + } + offset += 3 + } + if m.Present.AMPDUStatus() { + offset += align(offset, 4) + m.AMPDUStatus = RadioTapAMPDUStatus{ + Reference: binary.LittleEndian.Uint32(data[offset:]), + Flags: RadioTapAMPDUStatusFlags(binary.LittleEndian.Uint16(data[offset+4:])), + CRC: uint8(data[offset+6]), + } + offset += 8 + } + if m.Present.VHT() { + offset += align(offset, 2) + m.VHT = RadioTapVHT{ + Known: RadioTapVHTKnown(binary.LittleEndian.Uint16(data[offset:])), + Flags: RadioTapVHTFlags(data[offset+2]), + Bandwidth: uint8(data[offset+3]), + MCSNSS: [4]RadioTapVHTMCSNSS{ + RadioTapVHTMCSNSS(data[offset+4]), + RadioTapVHTMCSNSS(data[offset+5]), + RadioTapVHTMCSNSS(data[offset+6]), + RadioTapVHTMCSNSS(data[offset+7]), + }, + Coding: uint8(data[offset+8]), + GroupId: uint8(data[offset+9]), + PartialAID: binary.LittleEndian.Uint16(data[offset+10:]), + } + offset += 12 + } + + payload := data[m.Length:] + if !m.Flags.FCS() { // Dot11.DecodeFromBytes() expects FCS present + fcs := make([]byte, 4) + h := crc32.NewIEEE() + h.Write(payload) + binary.LittleEndian.PutUint32(fcs, h.Sum32()) + payload = append(payload, fcs...) + } + m.BaseLayer = BaseLayer{Contents: data[:m.Length], Payload: payload} + + return nil +} + +func (m RadioTap) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + buf := make([]byte, 1024) + + buf[0] = m.Version + buf[1] = 0 + + binary.LittleEndian.PutUint32(buf[4:8], uint32(m.Present)) + + offset := uint16(4) + + for (binary.LittleEndian.Uint32(buf[offset:offset+4]) & 0x80000000) != 0 { + offset += 4 + } + + offset += 4 + + if m.Present.TSFT() { + offset += align(offset, 8) + binary.LittleEndian.PutUint64(buf[offset:offset+8], m.TSFT) + offset += 8 + } + + if m.Present.Flags() { + buf[offset] = uint8(m.Flags) + offset++ + } + + if m.Present.Rate() { + buf[offset] = uint8(m.Rate) + offset++ + } + + if m.Present.Channel() { + offset += align(offset, 2) + binary.LittleEndian.PutUint16(buf[offset:offset+2], uint16(m.ChannelFrequency)) + offset += 2 + binary.LittleEndian.PutUint16(buf[offset:offset+2], uint16(m.ChannelFlags)) + offset += 2 + } + + if m.Present.FHSS() { + binary.LittleEndian.PutUint16(buf[offset:offset+2], m.FHSS) + offset += 2 + } + + if m.Present.DBMAntennaSignal() { + buf[offset] = byte(m.DBMAntennaSignal) + offset++ + } + + if m.Present.DBMAntennaNoise() { + buf[offset] = byte(m.DBMAntennaNoise) + offset++ + } + + if m.Present.LockQuality() { + offset += align(offset, 2) + binary.LittleEndian.PutUint16(buf[offset:offset+2], m.LockQuality) + offset += 2 + } + + if m.Present.TxAttenuation() { + offset += align(offset, 2) + binary.LittleEndian.PutUint16(buf[offset:offset+2], m.TxAttenuation) + offset += 2 + } + + if m.Present.DBTxAttenuation() { + offset += align(offset, 2) + binary.LittleEndian.PutUint16(buf[offset:offset+2], m.DBTxAttenuation) + offset += 2 + } + + if m.Present.DBMTxPower() { + buf[offset] = byte(m.DBMTxPower) + offset++ + } + + if m.Present.Antenna() { + buf[offset] = uint8(m.Antenna) + offset++ + } + + if m.Present.DBAntennaSignal() { + buf[offset] = uint8(m.DBAntennaSignal) + offset++ + } + + if m.Present.DBAntennaNoise() { + buf[offset] = uint8(m.DBAntennaNoise) + offset++ + } + + if m.Present.RxFlags() { + offset += align(offset, 2) + binary.LittleEndian.PutUint16(buf[offset:offset+2], uint16(m.RxFlags)) + offset += 2 + } + + if m.Present.TxFlags() { + offset += align(offset, 2) + binary.LittleEndian.PutUint16(buf[offset:offset+2], uint16(m.TxFlags)) + offset += 2 + } + + if m.Present.RtsRetries() { + buf[offset] = m.RtsRetries + offset++ + } + + if m.Present.DataRetries() { + buf[offset] = m.DataRetries + offset++ + } + + if m.Present.MCS() { + buf[offset] = uint8(m.MCS.Known) + buf[offset+1] = uint8(m.MCS.Flags) + buf[offset+2] = uint8(m.MCS.MCS) + + offset += 3 + } + + if m.Present.AMPDUStatus() { + offset += align(offset, 4) + + binary.LittleEndian.PutUint32(buf[offset:offset+4], m.AMPDUStatus.Reference) + binary.LittleEndian.PutUint16(buf[offset+4:offset+6], uint16(m.AMPDUStatus.Flags)) + + buf[offset+6] = m.AMPDUStatus.CRC + + offset += 8 + } + + if m.Present.VHT() { + offset += align(offset, 2) + + binary.LittleEndian.PutUint16(buf[offset:], uint16(m.VHT.Known)) + + buf[offset+2] = uint8(m.VHT.Flags) + buf[offset+3] = uint8(m.VHT.Bandwidth) + buf[offset+4] = uint8(m.VHT.MCSNSS[0]) + buf[offset+5] = uint8(m.VHT.MCSNSS[1]) + buf[offset+6] = uint8(m.VHT.MCSNSS[2]) + buf[offset+7] = uint8(m.VHT.MCSNSS[3]) + buf[offset+8] = uint8(m.VHT.Coding) + buf[offset+9] = uint8(m.VHT.GroupId) + + binary.LittleEndian.PutUint16(buf[offset+10:offset+12], m.VHT.PartialAID) + + offset += 12 + } + + packetBuf, err := b.PrependBytes(int(offset)) + + if err != nil { + return err + } + + if opts.FixLengths { + m.Length = offset + } + + binary.LittleEndian.PutUint16(buf[2:4], m.Length) + + copy(packetBuf, buf) + + return nil +} + +func (m *RadioTap) CanDecode() gopacket.LayerClass { return LayerTypeRadioTap } +func (m *RadioTap) NextLayerType() gopacket.LayerType { return LayerTypeDot11 } diff --git a/vendor/github.com/google/gopacket/layers/rudp.go b/vendor/github.com/google/gopacket/layers/rudp.go new file mode 100644 index 0000000..8435129 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/rudp.go @@ -0,0 +1,93 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "fmt" + "github.com/google/gopacket" +) + +type RUDP struct { + BaseLayer + SYN, ACK, EACK, RST, NUL bool + Version uint8 + HeaderLength uint8 + SrcPort, DstPort RUDPPort + DataLength uint16 + Seq, Ack, Checksum uint32 + VariableHeaderArea []byte + // RUDPHeaderSyn contains SYN information for the RUDP packet, + // if the SYN flag is set + *RUDPHeaderSYN + // RUDPHeaderEack contains EACK information for the RUDP packet, + // if the EACK flag is set. + *RUDPHeaderEACK +} + +type RUDPHeaderSYN struct { + MaxOutstandingSegments, MaxSegmentSize, OptionFlags uint16 +} + +type RUDPHeaderEACK struct { + SeqsReceivedOK []uint32 +} + +// LayerType returns gopacket.LayerTypeRUDP. +func (r *RUDP) LayerType() gopacket.LayerType { return LayerTypeRUDP } + +func decodeRUDP(data []byte, p gopacket.PacketBuilder) error { + r := &RUDP{ + SYN: data[0]&0x80 != 0, + ACK: data[0]&0x40 != 0, + EACK: data[0]&0x20 != 0, + RST: data[0]&0x10 != 0, + NUL: data[0]&0x08 != 0, + Version: data[0] & 0x3, + HeaderLength: data[1], + SrcPort: RUDPPort(data[2]), + DstPort: RUDPPort(data[3]), + DataLength: binary.BigEndian.Uint16(data[4:6]), + Seq: binary.BigEndian.Uint32(data[6:10]), + Ack: binary.BigEndian.Uint32(data[10:14]), + Checksum: binary.BigEndian.Uint32(data[14:18]), + } + if r.HeaderLength < 9 { + return fmt.Errorf("RUDP packet with too-short header length %d", r.HeaderLength) + } + hlen := int(r.HeaderLength) * 2 + r.Contents = data[:hlen] + r.Payload = data[hlen : hlen+int(r.DataLength)] + r.VariableHeaderArea = data[18:hlen] + headerData := r.VariableHeaderArea + switch { + case r.SYN: + if len(headerData) != 6 { + return fmt.Errorf("RUDP packet invalid SYN header length: %d", len(headerData)) + } + r.RUDPHeaderSYN = &RUDPHeaderSYN{ + MaxOutstandingSegments: binary.BigEndian.Uint16(headerData[:2]), + MaxSegmentSize: binary.BigEndian.Uint16(headerData[2:4]), + OptionFlags: binary.BigEndian.Uint16(headerData[4:6]), + } + case r.EACK: + if len(headerData)%4 != 0 { + return fmt.Errorf("RUDP packet invalid EACK header length: %d", len(headerData)) + } + r.RUDPHeaderEACK = &RUDPHeaderEACK{make([]uint32, len(headerData)/4)} + for i := 0; i < len(headerData); i += 4 { + r.SeqsReceivedOK[i/4] = binary.BigEndian.Uint32(headerData[i : i+4]) + } + } + p.AddLayer(r) + p.SetTransportLayer(r) + return p.NextDecoder(gopacket.LayerTypePayload) +} + +func (r *RUDP) TransportFlow() gopacket.Flow { + return gopacket.NewFlow(EndpointRUDPPort, []byte{byte(r.SrcPort)}, []byte{byte(r.DstPort)}) +} diff --git a/vendor/github.com/google/gopacket/layers/sctp.go b/vendor/github.com/google/gopacket/layers/sctp.go new file mode 100644 index 0000000..511176e --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/sctp.go @@ -0,0 +1,746 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "fmt" + "hash/crc32" + + "github.com/google/gopacket" +) + +// SCTP contains information on the top level of an SCTP packet. +type SCTP struct { + BaseLayer + SrcPort, DstPort SCTPPort + VerificationTag uint32 + Checksum uint32 + sPort, dPort []byte +} + +// LayerType returns gopacket.LayerTypeSCTP +func (s *SCTP) LayerType() gopacket.LayerType { return LayerTypeSCTP } + +func decodeSCTP(data []byte, p gopacket.PacketBuilder) error { + sctp := &SCTP{} + err := sctp.DecodeFromBytes(data, p) + p.AddLayer(sctp) + p.SetTransportLayer(sctp) + if err != nil { + return err + } + return p.NextDecoder(sctpChunkTypePrefixDecoder) +} + +var sctpChunkTypePrefixDecoder = gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix) + +// TransportFlow returns a flow based on the source and destination SCTP port. +func (s *SCTP) TransportFlow() gopacket.Flow { + return gopacket.NewFlow(EndpointSCTPPort, s.sPort, s.dPort) +} + +func decodeWithSCTPChunkTypePrefix(data []byte, p gopacket.PacketBuilder) error { + chunkType := SCTPChunkType(data[0]) + return chunkType.Decode(data, p) +} + +// SerializeTo is for gopacket.SerializableLayer. +func (s SCTP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + bytes, err := b.PrependBytes(12) + if err != nil { + return err + } + binary.BigEndian.PutUint16(bytes[0:2], uint16(s.SrcPort)) + binary.BigEndian.PutUint16(bytes[2:4], uint16(s.DstPort)) + binary.BigEndian.PutUint32(bytes[4:8], s.VerificationTag) + if opts.ComputeChecksums { + // Note: MakeTable(Castagnoli) actually only creates the table once, then + // passes back a singleton on every other call, so this shouldn't cause + // excessive memory allocation. + binary.LittleEndian.PutUint32(bytes[8:12], crc32.Checksum(b.Bytes(), crc32.MakeTable(crc32.Castagnoli))) + } + return nil +} + +func (sctp *SCTP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 12 { + return errors.New("Invalid SCTP common header length") + } + sctp.SrcPort = SCTPPort(binary.BigEndian.Uint16(data[:2])) + sctp.sPort = data[:2] + sctp.DstPort = SCTPPort(binary.BigEndian.Uint16(data[2:4])) + sctp.dPort = data[2:4] + sctp.VerificationTag = binary.BigEndian.Uint32(data[4:8]) + sctp.Checksum = binary.BigEndian.Uint32(data[8:12]) + sctp.BaseLayer = BaseLayer{data[:12], data[12:]} + + return nil +} + +func (t *SCTP) CanDecode() gopacket.LayerClass { + return LayerTypeSCTP +} + +func (t *SCTP) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +// SCTPChunk contains the common fields in all SCTP chunks. +type SCTPChunk struct { + BaseLayer + Type SCTPChunkType + Flags uint8 + Length uint16 + // ActualLength is the total length of an SCTP chunk, including padding. + // SCTP chunks start and end on 4-byte boundaries. So if a chunk has a length + // of 18, it means that it has data up to and including byte 18, then padding + // up to the next 4-byte boundary, 20. In this case, Length would be 18, and + // ActualLength would be 20. + ActualLength int +} + +func roundUpToNearest4(i int) int { + if i%4 == 0 { + return i + } + return i + 4 - (i % 4) +} + +func decodeSCTPChunk(data []byte) (SCTPChunk, error) { + length := binary.BigEndian.Uint16(data[2:4]) + if length < 4 { + return SCTPChunk{}, errors.New("invalid SCTP chunk length") + } + actual := roundUpToNearest4(int(length)) + ct := SCTPChunkType(data[0]) + + // For SCTP Data, use a separate layer for the payload + delta := 0 + if ct == SCTPChunkTypeData { + delta = int(actual) - int(length) + actual = 16 + } + + return SCTPChunk{ + Type: ct, + Flags: data[1], + Length: length, + ActualLength: actual, + BaseLayer: BaseLayer{data[:actual], data[actual : len(data)-delta]}, + }, nil +} + +// SCTPParameter is a TLV parameter inside a SCTPChunk. +type SCTPParameter struct { + Type uint16 + Length uint16 + ActualLength int + Value []byte +} + +func decodeSCTPParameter(data []byte) SCTPParameter { + length := binary.BigEndian.Uint16(data[2:4]) + return SCTPParameter{ + Type: binary.BigEndian.Uint16(data[0:2]), + Length: length, + Value: data[4:length], + ActualLength: roundUpToNearest4(int(length)), + } +} + +func (p SCTPParameter) Bytes() []byte { + length := 4 + len(p.Value) + data := make([]byte, roundUpToNearest4(length)) + binary.BigEndian.PutUint16(data[0:2], p.Type) + binary.BigEndian.PutUint16(data[2:4], uint16(length)) + copy(data[4:], p.Value) + return data +} + +// SCTPUnknownChunkType is the layer type returned when we don't recognize the +// chunk type. Since there's a length in a known location, we can skip over +// it even if we don't know what it is, and continue parsing the rest of the +// chunks. This chunk is stored as an ErrorLayer in the packet. +type SCTPUnknownChunkType struct { + SCTPChunk + bytes []byte +} + +func decodeSCTPChunkTypeUnknown(data []byte, p gopacket.PacketBuilder) error { + chunk, err := decodeSCTPChunk(data) + if err != nil { + return err + } + sc := &SCTPUnknownChunkType{SCTPChunk: chunk} + sc.bytes = data[:sc.ActualLength] + p.AddLayer(sc) + p.SetErrorLayer(sc) + return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix)) +} + +// SerializeTo is for gopacket.SerializableLayer. +func (s SCTPUnknownChunkType) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + bytes, err := b.PrependBytes(s.ActualLength) + if err != nil { + return err + } + copy(bytes, s.bytes) + return nil +} + +// LayerType returns gopacket.LayerTypeSCTPUnknownChunkType. +func (s *SCTPUnknownChunkType) LayerType() gopacket.LayerType { return LayerTypeSCTPUnknownChunkType } + +// Payload returns all bytes in this header, including the decoded Type, Length, +// and Flags. +func (s *SCTPUnknownChunkType) Payload() []byte { return s.bytes } + +// Error implements ErrorLayer. +func (s *SCTPUnknownChunkType) Error() error { + return fmt.Errorf("No decode method available for SCTP chunk type %s", s.Type) +} + +// SCTPData is the SCTP Data chunk layer. +type SCTPData struct { + SCTPChunk + Unordered, BeginFragment, EndFragment bool + TSN uint32 + StreamId uint16 + StreamSequence uint16 + PayloadProtocol SCTPPayloadProtocol +} + +// LayerType returns gopacket.LayerTypeSCTPData. +func (s *SCTPData) LayerType() gopacket.LayerType { return LayerTypeSCTPData } + +// SCTPPayloadProtocol represents a payload protocol +type SCTPPayloadProtocol uint32 + +// SCTPPayloadProtocol constonts from http://www.iana.org/assignments/sctp-parameters/sctp-parameters.xhtml +const ( + SCTPProtocolReserved SCTPPayloadProtocol = 0 + SCTPPayloadUIA = 1 + SCTPPayloadM2UA = 2 + SCTPPayloadM3UA = 3 + SCTPPayloadSUA = 4 + SCTPPayloadM2PA = 5 + SCTPPayloadV5UA = 6 + SCTPPayloadH248 = 7 + SCTPPayloadBICC = 8 + SCTPPayloadTALI = 9 + SCTPPayloadDUA = 10 + SCTPPayloadASAP = 11 + SCTPPayloadENRP = 12 + SCTPPayloadH323 = 13 + SCTPPayloadQIPC = 14 + SCTPPayloadSIMCO = 15 + SCTPPayloadDDPSegment = 16 + SCTPPayloadDDPStream = 17 + SCTPPayloadS1AP = 18 +) + +func (p SCTPPayloadProtocol) String() string { + switch p { + case SCTPProtocolReserved: + return "Reserved" + case SCTPPayloadUIA: + return "UIA" + case SCTPPayloadM2UA: + return "M2UA" + case SCTPPayloadM3UA: + return "M3UA" + case SCTPPayloadSUA: + return "SUA" + case SCTPPayloadM2PA: + return "M2PA" + case SCTPPayloadV5UA: + return "V5UA" + case SCTPPayloadH248: + return "H.248" + case SCTPPayloadBICC: + return "BICC" + case SCTPPayloadTALI: + return "TALI" + case SCTPPayloadDUA: + return "DUA" + case SCTPPayloadASAP: + return "ASAP" + case SCTPPayloadENRP: + return "ENRP" + case SCTPPayloadH323: + return "H.323" + case SCTPPayloadQIPC: + return "QIPC" + case SCTPPayloadSIMCO: + return "SIMCO" + case SCTPPayloadDDPSegment: + return "DDPSegment" + case SCTPPayloadDDPStream: + return "DDPStream" + case SCTPPayloadS1AP: + return "S1AP" + } + return fmt.Sprintf("Unknown(%d)", p) +} + +func decodeSCTPData(data []byte, p gopacket.PacketBuilder) error { + chunk, err := decodeSCTPChunk(data) + if err != nil { + return err + } + sc := &SCTPData{ + SCTPChunk: chunk, + Unordered: data[1]&0x4 != 0, + BeginFragment: data[1]&0x2 != 0, + EndFragment: data[1]&0x1 != 0, + TSN: binary.BigEndian.Uint32(data[4:8]), + StreamId: binary.BigEndian.Uint16(data[8:10]), + StreamSequence: binary.BigEndian.Uint16(data[10:12]), + PayloadProtocol: SCTPPayloadProtocol(binary.BigEndian.Uint32(data[12:16])), + } + // Length is the length in bytes of the data, INCLUDING the 16-byte header. + p.AddLayer(sc) + return p.NextDecoder(gopacket.LayerTypePayload) +} + +// SerializeTo is for gopacket.SerializableLayer. +func (sc SCTPData) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + payload := b.Bytes() + // Pad the payload to a 32 bit boundary + if rem := len(payload) % 4; rem != 0 { + b.AppendBytes(4 - rem) + } + length := 16 + bytes, err := b.PrependBytes(length) + if err != nil { + return err + } + bytes[0] = uint8(sc.Type) + flags := uint8(0) + if sc.Unordered { + flags |= 0x4 + } + if sc.BeginFragment { + flags |= 0x2 + } + if sc.EndFragment { + flags |= 0x1 + } + bytes[1] = flags + binary.BigEndian.PutUint16(bytes[2:4], uint16(length+len(payload))) + binary.BigEndian.PutUint32(bytes[4:8], sc.TSN) + binary.BigEndian.PutUint16(bytes[8:10], sc.StreamId) + binary.BigEndian.PutUint16(bytes[10:12], sc.StreamSequence) + binary.BigEndian.PutUint32(bytes[12:16], uint32(sc.PayloadProtocol)) + return nil +} + +// SCTPInitParameter is a parameter for an SCTP Init or InitAck packet. +type SCTPInitParameter SCTPParameter + +// SCTPInit is used as the return value for both SCTPInit and SCTPInitAck +// messages. +type SCTPInit struct { + SCTPChunk + InitiateTag uint32 + AdvertisedReceiverWindowCredit uint32 + OutboundStreams, InboundStreams uint16 + InitialTSN uint32 + Parameters []SCTPInitParameter +} + +// LayerType returns either gopacket.LayerTypeSCTPInit or gopacket.LayerTypeSCTPInitAck. +func (sc *SCTPInit) LayerType() gopacket.LayerType { + if sc.Type == SCTPChunkTypeInitAck { + return LayerTypeSCTPInitAck + } + // sc.Type == SCTPChunkTypeInit + return LayerTypeSCTPInit +} + +func decodeSCTPInit(data []byte, p gopacket.PacketBuilder) error { + chunk, err := decodeSCTPChunk(data) + if err != nil { + return err + } + sc := &SCTPInit{ + SCTPChunk: chunk, + InitiateTag: binary.BigEndian.Uint32(data[4:8]), + AdvertisedReceiverWindowCredit: binary.BigEndian.Uint32(data[8:12]), + OutboundStreams: binary.BigEndian.Uint16(data[12:14]), + InboundStreams: binary.BigEndian.Uint16(data[14:16]), + InitialTSN: binary.BigEndian.Uint32(data[16:20]), + } + paramData := data[20:sc.ActualLength] + for len(paramData) > 0 { + p := SCTPInitParameter(decodeSCTPParameter(paramData)) + paramData = paramData[p.ActualLength:] + sc.Parameters = append(sc.Parameters, p) + } + p.AddLayer(sc) + return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix)) +} + +// SerializeTo is for gopacket.SerializableLayer. +func (sc SCTPInit) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + var payload []byte + for _, param := range sc.Parameters { + payload = append(payload, SCTPParameter(param).Bytes()...) + } + length := 20 + len(payload) + bytes, err := b.PrependBytes(roundUpToNearest4(length)) + if err != nil { + return err + } + bytes[0] = uint8(sc.Type) + bytes[1] = sc.Flags + binary.BigEndian.PutUint16(bytes[2:4], uint16(length)) + binary.BigEndian.PutUint32(bytes[4:8], sc.InitiateTag) + binary.BigEndian.PutUint32(bytes[8:12], sc.AdvertisedReceiverWindowCredit) + binary.BigEndian.PutUint16(bytes[12:14], sc.OutboundStreams) + binary.BigEndian.PutUint16(bytes[14:16], sc.InboundStreams) + binary.BigEndian.PutUint32(bytes[16:20], sc.InitialTSN) + copy(bytes[20:], payload) + return nil +} + +// SCTPSack is the SCTP Selective ACK chunk layer. +type SCTPSack struct { + SCTPChunk + CumulativeTSNAck uint32 + AdvertisedReceiverWindowCredit uint32 + NumGapACKs, NumDuplicateTSNs uint16 + GapACKs []uint16 + DuplicateTSNs []uint32 +} + +// LayerType return LayerTypeSCTPSack +func (sc *SCTPSack) LayerType() gopacket.LayerType { + return LayerTypeSCTPSack +} + +func decodeSCTPSack(data []byte, p gopacket.PacketBuilder) error { + chunk, err := decodeSCTPChunk(data) + if err != nil { + return err + } + sc := &SCTPSack{ + SCTPChunk: chunk, + CumulativeTSNAck: binary.BigEndian.Uint32(data[4:8]), + AdvertisedReceiverWindowCredit: binary.BigEndian.Uint32(data[8:12]), + NumGapACKs: binary.BigEndian.Uint16(data[12:14]), + NumDuplicateTSNs: binary.BigEndian.Uint16(data[14:16]), + } + // We maximize gapAcks and dupTSNs here so we're not allocating tons + // of memory based on a user-controlable field. Our maximums are not exact, + // but should give us sane defaults... we'll still hit slice boundaries and + // fail if the user-supplied values are too high (in the for loops below), but + // the amount of memory we'll have allocated because of that should be small + // (< sc.ActualLength) + gapAcks := sc.SCTPChunk.ActualLength / 2 + dupTSNs := (sc.SCTPChunk.ActualLength - gapAcks*2) / 4 + if gapAcks > int(sc.NumGapACKs) { + gapAcks = int(sc.NumGapACKs) + } + if dupTSNs > int(sc.NumDuplicateTSNs) { + dupTSNs = int(sc.NumDuplicateTSNs) + } + sc.GapACKs = make([]uint16, 0, gapAcks) + sc.DuplicateTSNs = make([]uint32, 0, dupTSNs) + bytesRemaining := data[16:] + for i := 0; i < int(sc.NumGapACKs); i++ { + sc.GapACKs = append(sc.GapACKs, binary.BigEndian.Uint16(bytesRemaining[:2])) + bytesRemaining = bytesRemaining[2:] + } + for i := 0; i < int(sc.NumDuplicateTSNs); i++ { + sc.DuplicateTSNs = append(sc.DuplicateTSNs, binary.BigEndian.Uint32(bytesRemaining[:4])) + bytesRemaining = bytesRemaining[4:] + } + p.AddLayer(sc) + return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix)) +} + +// SerializeTo is for gopacket.SerializableLayer. +func (sc SCTPSack) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + length := 16 + 2*len(sc.GapACKs) + 4*len(sc.DuplicateTSNs) + bytes, err := b.PrependBytes(roundUpToNearest4(length)) + if err != nil { + return err + } + bytes[0] = uint8(sc.Type) + bytes[1] = sc.Flags + binary.BigEndian.PutUint16(bytes[2:4], uint16(length)) + binary.BigEndian.PutUint32(bytes[4:8], sc.CumulativeTSNAck) + binary.BigEndian.PutUint32(bytes[8:12], sc.AdvertisedReceiverWindowCredit) + binary.BigEndian.PutUint16(bytes[12:14], uint16(len(sc.GapACKs))) + binary.BigEndian.PutUint16(bytes[14:16], uint16(len(sc.DuplicateTSNs))) + for i, v := range sc.GapACKs { + binary.BigEndian.PutUint16(bytes[16+i*2:], v) + } + offset := 16 + 2*len(sc.GapACKs) + for i, v := range sc.DuplicateTSNs { + binary.BigEndian.PutUint32(bytes[offset+i*4:], v) + } + return nil +} + +// SCTPHeartbeatParameter is the parameter type used by SCTP heartbeat and +// heartbeat ack layers. +type SCTPHeartbeatParameter SCTPParameter + +// SCTPHeartbeat is the SCTP heartbeat layer, also used for heatbeat ack. +type SCTPHeartbeat struct { + SCTPChunk + Parameters []SCTPHeartbeatParameter +} + +// LayerType returns gopacket.LayerTypeSCTPHeartbeat. +func (sc *SCTPHeartbeat) LayerType() gopacket.LayerType { + if sc.Type == SCTPChunkTypeHeartbeatAck { + return LayerTypeSCTPHeartbeatAck + } + // sc.Type == SCTPChunkTypeHeartbeat + return LayerTypeSCTPHeartbeat +} + +func decodeSCTPHeartbeat(data []byte, p gopacket.PacketBuilder) error { + chunk, err := decodeSCTPChunk(data) + if err != nil { + return err + } + sc := &SCTPHeartbeat{ + SCTPChunk: chunk, + } + paramData := data[4:sc.Length] + for len(paramData) > 0 { + p := SCTPHeartbeatParameter(decodeSCTPParameter(paramData)) + paramData = paramData[p.ActualLength:] + sc.Parameters = append(sc.Parameters, p) + } + p.AddLayer(sc) + return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix)) +} + +// SerializeTo is for gopacket.SerializableLayer. +func (sc SCTPHeartbeat) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + var payload []byte + for _, param := range sc.Parameters { + payload = append(payload, SCTPParameter(param).Bytes()...) + } + length := 4 + len(payload) + + bytes, err := b.PrependBytes(roundUpToNearest4(length)) + if err != nil { + return err + } + bytes[0] = uint8(sc.Type) + bytes[1] = sc.Flags + binary.BigEndian.PutUint16(bytes[2:4], uint16(length)) + copy(bytes[4:], payload) + return nil +} + +// SCTPErrorParameter is the parameter type used by SCTP Abort and Error layers. +type SCTPErrorParameter SCTPParameter + +// SCTPError is the SCTP error layer, also used for SCTP aborts. +type SCTPError struct { + SCTPChunk + Parameters []SCTPErrorParameter +} + +// LayerType returns LayerTypeSCTPAbort or LayerTypeSCTPError. +func (sc *SCTPError) LayerType() gopacket.LayerType { + if sc.Type == SCTPChunkTypeAbort { + return LayerTypeSCTPAbort + } + // sc.Type == SCTPChunkTypeError + return LayerTypeSCTPError +} + +func decodeSCTPError(data []byte, p gopacket.PacketBuilder) error { + // remarkably similar to decodeSCTPHeartbeat ;) + chunk, err := decodeSCTPChunk(data) + if err != nil { + return err + } + sc := &SCTPError{ + SCTPChunk: chunk, + } + paramData := data[4:sc.Length] + for len(paramData) > 0 { + p := SCTPErrorParameter(decodeSCTPParameter(paramData)) + paramData = paramData[p.ActualLength:] + sc.Parameters = append(sc.Parameters, p) + } + p.AddLayer(sc) + return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix)) +} + +// SerializeTo is for gopacket.SerializableLayer. +func (sc SCTPError) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + var payload []byte + for _, param := range sc.Parameters { + payload = append(payload, SCTPParameter(param).Bytes()...) + } + length := 4 + len(payload) + + bytes, err := b.PrependBytes(roundUpToNearest4(length)) + if err != nil { + return err + } + bytes[0] = uint8(sc.Type) + bytes[1] = sc.Flags + binary.BigEndian.PutUint16(bytes[2:4], uint16(length)) + copy(bytes[4:], payload) + return nil +} + +// SCTPShutdown is the SCTP shutdown layer. +type SCTPShutdown struct { + SCTPChunk + CumulativeTSNAck uint32 +} + +// LayerType returns gopacket.LayerTypeSCTPShutdown. +func (sc *SCTPShutdown) LayerType() gopacket.LayerType { return LayerTypeSCTPShutdown } + +func decodeSCTPShutdown(data []byte, p gopacket.PacketBuilder) error { + chunk, err := decodeSCTPChunk(data) + if err != nil { + return err + } + sc := &SCTPShutdown{ + SCTPChunk: chunk, + CumulativeTSNAck: binary.BigEndian.Uint32(data[4:8]), + } + p.AddLayer(sc) + return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix)) +} + +// SerializeTo is for gopacket.SerializableLayer. +func (sc SCTPShutdown) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + bytes, err := b.PrependBytes(8) + if err != nil { + return err + } + bytes[0] = uint8(sc.Type) + bytes[1] = sc.Flags + binary.BigEndian.PutUint16(bytes[2:4], 8) + binary.BigEndian.PutUint32(bytes[4:8], sc.CumulativeTSNAck) + return nil +} + +// SCTPShutdownAck is the SCTP shutdown layer. +type SCTPShutdownAck struct { + SCTPChunk +} + +// LayerType returns gopacket.LayerTypeSCTPShutdownAck. +func (sc *SCTPShutdownAck) LayerType() gopacket.LayerType { return LayerTypeSCTPShutdownAck } + +func decodeSCTPShutdownAck(data []byte, p gopacket.PacketBuilder) error { + chunk, err := decodeSCTPChunk(data) + if err != nil { + return err + } + sc := &SCTPShutdownAck{ + SCTPChunk: chunk, + } + p.AddLayer(sc) + return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix)) +} + +// SerializeTo is for gopacket.SerializableLayer. +func (sc SCTPShutdownAck) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + bytes, err := b.PrependBytes(4) + if err != nil { + return err + } + bytes[0] = uint8(sc.Type) + bytes[1] = sc.Flags + binary.BigEndian.PutUint16(bytes[2:4], 4) + return nil +} + +// SCTPCookieEcho is the SCTP Cookie Echo layer. +type SCTPCookieEcho struct { + SCTPChunk + Cookie []byte +} + +// LayerType returns gopacket.LayerTypeSCTPCookieEcho. +func (sc *SCTPCookieEcho) LayerType() gopacket.LayerType { return LayerTypeSCTPCookieEcho } + +func decodeSCTPCookieEcho(data []byte, p gopacket.PacketBuilder) error { + chunk, err := decodeSCTPChunk(data) + if err != nil { + return err + } + sc := &SCTPCookieEcho{ + SCTPChunk: chunk, + } + sc.Cookie = data[4:sc.Length] + p.AddLayer(sc) + return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix)) +} + +// SerializeTo is for gopacket.SerializableLayer. +func (sc SCTPCookieEcho) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + length := 4 + len(sc.Cookie) + bytes, err := b.PrependBytes(roundUpToNearest4(length)) + if err != nil { + return err + } + bytes[0] = uint8(sc.Type) + bytes[1] = sc.Flags + binary.BigEndian.PutUint16(bytes[2:4], uint16(length)) + copy(bytes[4:], sc.Cookie) + return nil +} + +// This struct is used by all empty SCTP chunks (currently CookieAck and +// ShutdownComplete). +type SCTPEmptyLayer struct { + SCTPChunk +} + +// LayerType returns either gopacket.LayerTypeSCTPShutdownComplete or +// LayerTypeSCTPCookieAck. +func (sc *SCTPEmptyLayer) LayerType() gopacket.LayerType { + if sc.Type == SCTPChunkTypeShutdownComplete { + return LayerTypeSCTPShutdownComplete + } + // sc.Type == SCTPChunkTypeCookieAck + return LayerTypeSCTPCookieAck +} + +func decodeSCTPEmptyLayer(data []byte, p gopacket.PacketBuilder) error { + chunk, err := decodeSCTPChunk(data) + if err != nil { + return err + } + sc := &SCTPEmptyLayer{ + SCTPChunk: chunk, + } + p.AddLayer(sc) + return p.NextDecoder(gopacket.DecodeFunc(decodeWithSCTPChunkTypePrefix)) +} + +// SerializeTo is for gopacket.SerializableLayer. +func (sc SCTPEmptyLayer) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + bytes, err := b.PrependBytes(4) + if err != nil { + return err + } + bytes[0] = uint8(sc.Type) + bytes[1] = sc.Flags + binary.BigEndian.PutUint16(bytes[2:4], 4) + return nil +} diff --git a/vendor/github.com/google/gopacket/layers/sflow.go b/vendor/github.com/google/gopacket/layers/sflow.go new file mode 100644 index 0000000..0b7c69d --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/sflow.go @@ -0,0 +1,2179 @@ +// Copyright 2014 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +/* +This layer decodes SFlow version 5 datagrams. + +The specification can be found here: http://sflow.org/sflow_version_5.txt + +Additional developer information about sflow can be found at: +http://sflow.org/developers/specifications.php + +And SFlow in general: +http://sflow.org/index.php + +Two forms of sample data are defined: compact and expanded. The +Specification has this to say: + + Compact and expand forms of counter and flow samples are defined. + An agent must not mix compact/expanded encodings. If an agent + will never use ifIndex numbers >= 2^24 then it must use compact + encodings for all interfaces. Otherwise the expanded formats must + be used for all interfaces. + +This decoder only supports the compact form, because that is the only +one for which data was avaialble. + +The datagram is composed of one or more samples of type flow or counter, +and each sample is composed of one or more records describing the sample. +A sample is a single instance of sampled inforamtion, and each record in +the sample gives additional / supplimentary information about the sample. + +The following sample record types are supported: + + Raw Packet Header + opaque = flow_data; enterprise = 0; format = 1 + + Extended Switch Data + opaque = flow_data; enterprise = 0; format = 1001 + + Extended Router Data + opaque = flow_data; enterprise = 0; format = 1002 + + Extended Gateway Data + opaque = flow_data; enterprise = 0; format = 1003 + + Extended User Data + opaque = flow_data; enterprise = 0; format = 1004 + + Extended URL Data + opaque = flow_data; enterprise = 0; format = 1005 + +The following types of counter records are supported: + + Generic Interface Counters - see RFC 2233 + opaque = counter_data; enterprise = 0; format = 1 + + Ethernet Interface Counters - see RFC 2358 + opaque = counter_data; enterprise = 0; format = 2 + +SFlow is encoded using XDR (RFC4506). There are a few places +where the standard 4-byte fields are partitioned into two +bitfields of different lengths. I'm not sure why the designers +chose to pack together two values like this in some places, and +in others they use the entire 4-byte value to store a number that +will never be more than a few bits. In any case, there are a couple +of types defined to handle the decoding of these bitfields, and +that's why they're there. */ + +package layers + +import ( + "encoding/binary" + "errors" + "fmt" + "net" + + "github.com/google/gopacket" +) + +// SFlowRecord holds both flow sample records and counter sample records. +// A Record is the structure that actually holds the sampled data +// and / or counters. +type SFlowRecord interface { +} + +// SFlowDataSource encodes a 2-bit SFlowSourceFormat in its most significant +// 2 bits, and an SFlowSourceValue in its least significant 30 bits. +// These types and values define the meaning of the inteface information +// presented in the sample metadata. +type SFlowDataSource int32 + +func (sdc SFlowDataSource) decode() (SFlowSourceFormat, SFlowSourceValue) { + leftField := sdc >> 30 + rightField := uint32(0x3FFFFFFF) & uint32(sdc) + return SFlowSourceFormat(leftField), SFlowSourceValue(rightField) +} + +type SFlowDataSourceExpanded struct { + SourceIDClass SFlowSourceFormat + SourceIDIndex SFlowSourceValue +} + +func (sdce SFlowDataSourceExpanded) decode() (SFlowSourceFormat, SFlowSourceValue) { + leftField := sdce.SourceIDClass >> 30 + rightField := uint32(0x3FFFFFFF) & uint32(sdce.SourceIDIndex) + return SFlowSourceFormat(leftField), SFlowSourceValue(rightField) +} + +type SFlowSourceFormat uint32 + +type SFlowSourceValue uint32 + +const ( + SFlowTypeSingleInterface SFlowSourceFormat = 0 + SFlowTypePacketDiscarded SFlowSourceFormat = 1 + SFlowTypeMultipleDestinations SFlowSourceFormat = 2 +) + +func (sdf SFlowSourceFormat) String() string { + switch sdf { + case SFlowTypeSingleInterface: + return "Single Interface" + case SFlowTypePacketDiscarded: + return "Packet Discarded" + case SFlowTypeMultipleDestinations: + return "Multiple Destinations" + default: + return "UNKNOWN" + } +} + +func decodeSFlow(data []byte, p gopacket.PacketBuilder) error { + s := &SFlowDatagram{} + err := s.DecodeFromBytes(data, p) + if err != nil { + return err + } + p.AddLayer(s) + p.SetApplicationLayer(s) + return nil +} + +// SFlowDatagram is the outermost container which holds some basic information +// about the reporting agent, and holds at least one sample record +type SFlowDatagram struct { + BaseLayer + + DatagramVersion uint32 + AgentAddress net.IP + SubAgentID uint32 + SequenceNumber uint32 + AgentUptime uint32 + SampleCount uint32 + FlowSamples []SFlowFlowSample + CounterSamples []SFlowCounterSample +} + +// An SFlow datagram's outer container has the following +// structure: + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int sFlow version (2|4|5) | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int IP version of the Agent (1=v4|2=v6) | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / Agent IP address (v4=4byte|v6=16byte) / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int sub agent id | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int datagram sequence number | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int switch uptime in ms | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int n samples in datagram | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / n samples / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +// SFlowDataFormat encodes the EnterpriseID in the most +// significant 12 bits, and the SampleType in the least significant +// 20 bits. +type SFlowDataFormat uint32 + +func (sdf SFlowDataFormat) decode() (SFlowEnterpriseID, SFlowSampleType) { + leftField := sdf >> 12 + rightField := uint32(0xFFF) & uint32(sdf) + return SFlowEnterpriseID(leftField), SFlowSampleType(rightField) +} + +// SFlowEnterpriseID is used to differentiate between the +// official SFlow standard, and other, vendor-specific +// types of flow data. (Similiar to SNMP's enterprise MIB +// OIDs) Only the office SFlow Enterprise ID is decoded +// here. +type SFlowEnterpriseID uint32 + +const ( + SFlowStandard SFlowEnterpriseID = 0 +) + +func (eid SFlowEnterpriseID) String() string { + switch eid { + case SFlowStandard: + return "Standard SFlow" + default: + return "" + } +} + +func (eid SFlowEnterpriseID) GetType() SFlowEnterpriseID { + return SFlowStandard +} + +// SFlowSampleType specifies the type of sample. Only flow samples +// and counter samples are supported +type SFlowSampleType uint32 + +const ( + SFlowTypeFlowSample SFlowSampleType = 1 + SFlowTypeCounterSample SFlowSampleType = 2 + SFlowTypeExpandedFlowSample SFlowSampleType = 3 + SFlowTypeExpandedCounterSample SFlowSampleType = 4 +) + +func (st SFlowSampleType) GetType() SFlowSampleType { + switch st { + case SFlowTypeFlowSample: + return SFlowTypeFlowSample + case SFlowTypeCounterSample: + return SFlowTypeCounterSample + case SFlowTypeExpandedFlowSample: + return SFlowTypeExpandedFlowSample + case SFlowTypeExpandedCounterSample: + return SFlowTypeExpandedCounterSample + default: + panic("Invalid Sample Type") + } +} + +func (st SFlowSampleType) String() string { + switch st { + case SFlowTypeFlowSample: + return "Flow Sample" + case SFlowTypeCounterSample: + return "Counter Sample" + case SFlowTypeExpandedFlowSample: + return "Expanded Flow Sample" + case SFlowTypeExpandedCounterSample: + return "Expanded Counter Sample" + default: + return "" + } +} + +func (s *SFlowDatagram) LayerType() gopacket.LayerType { return LayerTypeSFlow } + +func (d *SFlowDatagram) Payload() []byte { return nil } + +func (d *SFlowDatagram) CanDecode() gopacket.LayerClass { return LayerTypeSFlow } + +func (d *SFlowDatagram) NextLayerType() gopacket.LayerType { return gopacket.LayerTypePayload } + +// SFlowIPType determines what form the IP address being decoded will +// take. This is an XDR union type allowing for both IPv4 and IPv6 +type SFlowIPType uint32 + +const ( + SFlowIPv4 SFlowIPType = 1 + SFlowIPv6 SFlowIPType = 2 +) + +func (s SFlowIPType) String() string { + switch s { + case SFlowIPv4: + return "IPv4" + case SFlowIPv6: + return "IPv6" + default: + return "" + } +} + +func (s SFlowIPType) Length() int { + switch s { + case SFlowIPv4: + return 4 + case SFlowIPv6: + return 16 + default: + return 0 + } +} + +func (s *SFlowDatagram) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + var agentAddressType SFlowIPType + + data, s.DatagramVersion = data[4:], binary.BigEndian.Uint32(data[:4]) + data, agentAddressType = data[4:], SFlowIPType(binary.BigEndian.Uint32(data[:4])) + data, s.AgentAddress = data[agentAddressType.Length():], data[:agentAddressType.Length()] + data, s.SubAgentID = data[4:], binary.BigEndian.Uint32(data[:4]) + data, s.SequenceNumber = data[4:], binary.BigEndian.Uint32(data[:4]) + data, s.AgentUptime = data[4:], binary.BigEndian.Uint32(data[:4]) + data, s.SampleCount = data[4:], binary.BigEndian.Uint32(data[:4]) + + if s.SampleCount < 1 { + return fmt.Errorf("SFlow Datagram has invalid sample length: %d", s.SampleCount) + } + for i := uint32(0); i < s.SampleCount; i++ { + sdf := SFlowDataFormat(binary.BigEndian.Uint32(data[:4])) + _, sampleType := sdf.decode() + switch sampleType { + case SFlowTypeFlowSample: + if flowSample, err := decodeFlowSample(&data, false); err == nil { + s.FlowSamples = append(s.FlowSamples, flowSample) + } else { + return err + } + case SFlowTypeCounterSample: + if counterSample, err := decodeCounterSample(&data, false); err == nil { + s.CounterSamples = append(s.CounterSamples, counterSample) + } else { + return err + } + case SFlowTypeExpandedFlowSample: + if flowSample, err := decodeFlowSample(&data, true); err == nil { + s.FlowSamples = append(s.FlowSamples, flowSample) + } else { + return err + } + case SFlowTypeExpandedCounterSample: + if counterSample, err := decodeCounterSample(&data, true); err == nil { + s.CounterSamples = append(s.CounterSamples, counterSample) + } else { + return err + } + + default: + return fmt.Errorf("Unsupported SFlow sample type %d", sampleType) + } + } + return nil +} + +// SFlowFlowSample represents a sampled packet and contains +// one or more records describing the packet +type SFlowFlowSample struct { + EnterpriseID SFlowEnterpriseID + Format SFlowSampleType + SampleLength uint32 + SequenceNumber uint32 + SourceIDClass SFlowSourceFormat + SourceIDIndex SFlowSourceValue + SamplingRate uint32 + SamplePool uint32 + Dropped uint32 + InputInterfaceFormat uint32 + InputInterface uint32 + OutputInterfaceFormat uint32 + OutputInterface uint32 + RecordCount uint32 + Records []SFlowRecord +} + +// Flow samples have the following structure. Note +// the bit fields to encode the Enterprise ID and the +// Flow record format: type 1 + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | sample length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int sample sequence number | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// |id type | src id index value | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int sampling rate | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int sample pool | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int drops | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int input ifIndex | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int output ifIndex | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int number of records | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / flow records / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +// Flow samples have the following structure. +// Flow record format: type 3 + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | sample length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int sample sequence number | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int src id type | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int src id index value | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int sampling rate | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int sample pool | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int drops | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int input interface format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int input interface value | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int output interface format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int output interface value | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int number of records | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / flow records / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +type SFlowFlowDataFormat uint32 + +func (fdf SFlowFlowDataFormat) decode() (SFlowEnterpriseID, SFlowFlowRecordType) { + leftField := fdf >> 12 + rightField := uint32(0xFFF) & uint32(fdf) + return SFlowEnterpriseID(leftField), SFlowFlowRecordType(rightField) +} + +func (fs SFlowFlowSample) GetRecords() []SFlowRecord { + return fs.Records +} + +func (fs SFlowFlowSample) GetType() SFlowSampleType { + return SFlowTypeFlowSample +} + +func skipRecord(data *[]byte) { + recordLength := int(binary.BigEndian.Uint32((*data)[4:])) + *data = (*data)[(recordLength+((4-recordLength)%4))+8:] +} + +func decodeFlowSample(data *[]byte, expanded bool) (SFlowFlowSample, error) { + s := SFlowFlowSample{} + var sdf SFlowDataFormat + *data, sdf = (*data)[4:], SFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + var sdc SFlowDataSource + + s.EnterpriseID, s.Format = sdf.decode() + *data, s.SampleLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, s.SequenceNumber = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + if expanded { + *data, s.SourceIDClass = (*data)[4:], SFlowSourceFormat(binary.BigEndian.Uint32((*data)[:4])) + *data, s.SourceIDIndex = (*data)[4:], SFlowSourceValue(binary.BigEndian.Uint32((*data)[:4])) + } else { + *data, sdc = (*data)[4:], SFlowDataSource(binary.BigEndian.Uint32((*data)[:4])) + s.SourceIDClass, s.SourceIDIndex = sdc.decode() + } + *data, s.SamplingRate = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, s.SamplePool = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, s.Dropped = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + + if expanded { + *data, s.InputInterfaceFormat = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, s.InputInterface = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, s.OutputInterfaceFormat = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, s.OutputInterface = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + } else { + *data, s.InputInterface = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, s.OutputInterface = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + } + *data, s.RecordCount = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + + for i := uint32(0); i < s.RecordCount; i++ { + rdf := SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + _, flowRecordType := rdf.decode() + + switch flowRecordType { + case SFlowTypeRawPacketFlow: + if record, err := decodeRawPacketFlowRecord(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedUserFlow: + if record, err := decodeExtendedUserFlow(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedUrlFlow: + if record, err := decodeExtendedURLRecord(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedSwitchFlow: + if record, err := decodeExtendedSwitchFlowRecord(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedRouterFlow: + if record, err := decodeExtendedRouterFlowRecord(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedGatewayFlow: + if record, err := decodeExtendedGatewayFlowRecord(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeEthernetFrameFlow: + // TODO + skipRecord(data) + return s, errors.New("skipping TypeEthernetFrameFlow") + case SFlowTypeIpv4Flow: + if record, err := decodeSFlowIpv4Record(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeIpv6Flow: + if record, err := decodeSFlowIpv6Record(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedMlpsFlow: + // TODO + skipRecord(data) + return s, errors.New("skipping TypeExtendedMlpsFlow") + case SFlowTypeExtendedNatFlow: + // TODO + skipRecord(data) + return s, errors.New("skipping TypeExtendedNatFlow") + case SFlowTypeExtendedMlpsTunnelFlow: + // TODO + skipRecord(data) + return s, errors.New("skipping TypeExtendedMlpsTunnelFlow") + case SFlowTypeExtendedMlpsVcFlow: + // TODO + skipRecord(data) + return s, errors.New("skipping TypeExtendedMlpsVcFlow") + case SFlowTypeExtendedMlpsFecFlow: + // TODO + skipRecord(data) + return s, errors.New("skipping TypeExtendedMlpsFecFlow") + case SFlowTypeExtendedMlpsLvpFecFlow: + // TODO + skipRecord(data) + return s, errors.New("skipping TypeExtendedMlpsLvpFecFlow") + case SFlowTypeExtendedVlanFlow: + // TODO + skipRecord(data) + return s, errors.New("skipping TypeExtendedVlanFlow") + case SFlowTypeExtendedIpv4TunnelEgressFlow: + if record, err := decodeExtendedIpv4TunnelEgress(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedIpv4TunnelIngressFlow: + if record, err := decodeExtendedIpv4TunnelIngress(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedIpv6TunnelEgressFlow: + if record, err := decodeExtendedIpv6TunnelEgress(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedIpv6TunnelIngressFlow: + if record, err := decodeExtendedIpv6TunnelIngress(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedDecapsulateEgressFlow: + if record, err := decodeExtendedDecapsulateEgress(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedDecapsulateIngressFlow: + if record, err := decodeExtendedDecapsulateIngress(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedVniEgressFlow: + if record, err := decodeExtendedVniEgress(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeExtendedVniIngressFlow: + if record, err := decodeExtendedVniIngress(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + default: + return s, fmt.Errorf("Unsupported flow record type: %d", flowRecordType) + } + } + return s, nil +} + +// Counter samples report information about various counter +// objects. Typically these are items like IfInOctets, or +// CPU / Memory stats, etc. SFlow will report these at regular +// intervals as configured on the agent. If one were sufficiently +// industrious, this could be used to replace the typical +// SNMP polling used for such things. +type SFlowCounterSample struct { + EnterpriseID SFlowEnterpriseID + Format SFlowSampleType + SampleLength uint32 + SequenceNumber uint32 + SourceIDClass SFlowSourceFormat + SourceIDIndex SFlowSourceValue + RecordCount uint32 + Records []SFlowRecord +} + +// Counter samples have the following structure: + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int sample sequence number | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// |id type | src id index value | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | int number of records | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / counter records / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +type SFlowCounterDataFormat uint32 + +func (cdf SFlowCounterDataFormat) decode() (SFlowEnterpriseID, SFlowCounterRecordType) { + leftField := cdf >> 12 + rightField := uint32(0xFFF) & uint32(cdf) + return SFlowEnterpriseID(leftField), SFlowCounterRecordType(rightField) +} + +// GetRecords will return a slice of interface types +// representing records. A type switch can be used to +// get at the underlying SFlowCounterRecordType. +func (cs SFlowCounterSample) GetRecords() []SFlowRecord { + return cs.Records +} + +// GetType will report the type of sample. Only the +// compact form of counter samples is supported +func (cs SFlowCounterSample) GetType() SFlowSampleType { + return SFlowTypeCounterSample +} + +type SFlowCounterRecordType uint32 + +const ( + SFlowTypeGenericInterfaceCounters SFlowCounterRecordType = 1 + SFlowTypeEthernetInterfaceCounters SFlowCounterRecordType = 2 + SFlowTypeTokenRingInterfaceCounters SFlowCounterRecordType = 3 + SFlowType100BaseVGInterfaceCounters SFlowCounterRecordType = 4 + SFlowTypeVLANCounters SFlowCounterRecordType = 5 + SFlowTypeProcessorCounters SFlowCounterRecordType = 1001 +) + +func (cr SFlowCounterRecordType) String() string { + switch cr { + case SFlowTypeGenericInterfaceCounters: + return "Generic Interface Counters" + case SFlowTypeEthernetInterfaceCounters: + return "Ethernet Interface Counters" + case SFlowTypeTokenRingInterfaceCounters: + return "Token Ring Interface Counters" + case SFlowType100BaseVGInterfaceCounters: + return "100BaseVG Interface Counters" + case SFlowTypeVLANCounters: + return "VLAN Counters" + case SFlowTypeProcessorCounters: + return "Processor Counters" + default: + return "" + + } +} + +func decodeCounterSample(data *[]byte, expanded bool) (SFlowCounterSample, error) { + s := SFlowCounterSample{} + var sdc SFlowDataSource + var sdce SFlowDataSourceExpanded + var sdf SFlowDataFormat + + *data, sdf = (*data)[4:], SFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + s.EnterpriseID, s.Format = sdf.decode() + *data, s.SampleLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, s.SequenceNumber = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + if expanded { + *data, sdce = (*data)[8:], SFlowDataSourceExpanded{SFlowSourceFormat(binary.BigEndian.Uint32((*data)[:4])), SFlowSourceValue(binary.BigEndian.Uint32((*data)[4:8]))} + s.SourceIDClass, s.SourceIDIndex = sdce.decode() + } else { + *data, sdc = (*data)[4:], SFlowDataSource(binary.BigEndian.Uint32((*data)[:4])) + s.SourceIDClass, s.SourceIDIndex = sdc.decode() + } + *data, s.RecordCount = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + + for i := uint32(0); i < s.RecordCount; i++ { + cdf := SFlowCounterDataFormat(binary.BigEndian.Uint32((*data)[:4])) + _, counterRecordType := cdf.decode() + switch counterRecordType { + case SFlowTypeGenericInterfaceCounters: + if record, err := decodeGenericInterfaceCounters(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeEthernetInterfaceCounters: + if record, err := decodeEthernetCounters(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + case SFlowTypeTokenRingInterfaceCounters: + skipRecord(data) + return s, errors.New("skipping TypeTokenRingInterfaceCounters") + case SFlowType100BaseVGInterfaceCounters: + skipRecord(data) + return s, errors.New("skipping Type100BaseVGInterfaceCounters") + case SFlowTypeVLANCounters: + skipRecord(data) + return s, errors.New("skipping TypeVLANCounters") + case SFlowTypeProcessorCounters: + if record, err := decodeProcessorCounters(data); err == nil { + s.Records = append(s.Records, record) + } else { + return s, err + } + default: + return s, fmt.Errorf("Invalid counter record type: %d", counterRecordType) + } + } + return s, nil +} + +// SFlowBaseFlowRecord holds the fields common to all records +// of type SFlowFlowRecordType +type SFlowBaseFlowRecord struct { + EnterpriseID SFlowEnterpriseID + Format SFlowFlowRecordType + FlowDataLength uint32 +} + +func (bfr SFlowBaseFlowRecord) GetType() SFlowFlowRecordType { + return bfr.Format +} + +// SFlowFlowRecordType denotes what kind of Flow Record is +// represented. See RFC 3176 +type SFlowFlowRecordType uint32 + +const ( + SFlowTypeRawPacketFlow SFlowFlowRecordType = 1 + SFlowTypeEthernetFrameFlow SFlowFlowRecordType = 2 + SFlowTypeIpv4Flow SFlowFlowRecordType = 3 + SFlowTypeIpv6Flow SFlowFlowRecordType = 4 + SFlowTypeExtendedSwitchFlow SFlowFlowRecordType = 1001 + SFlowTypeExtendedRouterFlow SFlowFlowRecordType = 1002 + SFlowTypeExtendedGatewayFlow SFlowFlowRecordType = 1003 + SFlowTypeExtendedUserFlow SFlowFlowRecordType = 1004 + SFlowTypeExtendedUrlFlow SFlowFlowRecordType = 1005 + SFlowTypeExtendedMlpsFlow SFlowFlowRecordType = 1006 + SFlowTypeExtendedNatFlow SFlowFlowRecordType = 1007 + SFlowTypeExtendedMlpsTunnelFlow SFlowFlowRecordType = 1008 + SFlowTypeExtendedMlpsVcFlow SFlowFlowRecordType = 1009 + SFlowTypeExtendedMlpsFecFlow SFlowFlowRecordType = 1010 + SFlowTypeExtendedMlpsLvpFecFlow SFlowFlowRecordType = 1011 + SFlowTypeExtendedVlanFlow SFlowFlowRecordType = 1012 + SFlowTypeExtendedIpv4TunnelEgressFlow SFlowFlowRecordType = 1023 + SFlowTypeExtendedIpv4TunnelIngressFlow SFlowFlowRecordType = 1024 + SFlowTypeExtendedIpv6TunnelEgressFlow SFlowFlowRecordType = 1025 + SFlowTypeExtendedIpv6TunnelIngressFlow SFlowFlowRecordType = 1026 + SFlowTypeExtendedDecapsulateEgressFlow SFlowFlowRecordType = 1027 + SFlowTypeExtendedDecapsulateIngressFlow SFlowFlowRecordType = 1028 + SFlowTypeExtendedVniEgressFlow SFlowFlowRecordType = 1029 + SFlowTypeExtendedVniIngressFlow SFlowFlowRecordType = 1030 +) + +func (rt SFlowFlowRecordType) String() string { + switch rt { + case SFlowTypeRawPacketFlow: + return "Raw Packet Flow Record" + case SFlowTypeEthernetFrameFlow: + return "Ethernet Frame Flow Record" + case SFlowTypeIpv4Flow: + return "IPv4 Flow Record" + case SFlowTypeIpv6Flow: + return "IPv6 Flow Record" + case SFlowTypeExtendedSwitchFlow: + return "Extended Switch Flow Record" + case SFlowTypeExtendedRouterFlow: + return "Extended Router Flow Record" + case SFlowTypeExtendedGatewayFlow: + return "Extended Gateway Flow Record" + case SFlowTypeExtendedUserFlow: + return "Extended User Flow Record" + case SFlowTypeExtendedUrlFlow: + return "Extended URL Flow Record" + case SFlowTypeExtendedMlpsFlow: + return "Extended MPLS Flow Record" + case SFlowTypeExtendedNatFlow: + return "Extended NAT Flow Record" + case SFlowTypeExtendedMlpsTunnelFlow: + return "Extended MPLS Tunnel Flow Record" + case SFlowTypeExtendedMlpsVcFlow: + return "Extended MPLS VC Flow Record" + case SFlowTypeExtendedMlpsFecFlow: + return "Extended MPLS FEC Flow Record" + case SFlowTypeExtendedMlpsLvpFecFlow: + return "Extended MPLS LVP FEC Flow Record" + case SFlowTypeExtendedVlanFlow: + return "Extended VLAN Flow Record" + case SFlowTypeExtendedIpv4TunnelEgressFlow: + return "Extended IPv4 Tunnel Egress Record" + case SFlowTypeExtendedIpv4TunnelIngressFlow: + return "Extended IPv4 Tunnel Ingress Record" + case SFlowTypeExtendedIpv6TunnelEgressFlow: + return "Extended IPv6 Tunnel Egress Record" + case SFlowTypeExtendedIpv6TunnelIngressFlow: + return "Extended IPv6 Tunnel Ingress Record" + case SFlowTypeExtendedDecapsulateEgressFlow: + return "Extended Decapsulate Egress Record" + case SFlowTypeExtendedDecapsulateIngressFlow: + return "Extended Decapsulate Ingress Record" + case SFlowTypeExtendedVniEgressFlow: + return "Extended VNI Ingress Record" + case SFlowTypeExtendedVniIngressFlow: + return "Extended VNI Ingress Record" + default: + return "" + } +} + +// SFlowRawPacketFlowRecords hold information about a sampled +// packet grabbed as it transited the agent. This is +// perhaps the most useful and interesting record type, +// as it holds the headers of the sampled packet and +// can be used to build up a complete picture of the +// traffic patterns on a network. +// +// The raw packet header is sent back into gopacket for +// decoding, and the resulting gopackt.Packet is stored +// in the Header member +type SFlowRawPacketFlowRecord struct { + SFlowBaseFlowRecord + HeaderProtocol SFlowRawHeaderProtocol + FrameLength uint32 + PayloadRemoved uint32 + HeaderLength uint32 + Header gopacket.Packet +} + +// Raw packet record types have the following structure: + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Header Protocol | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Frame Length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Payload Removed | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Header Length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// \ Header \ +// \ \ +// \ \ +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +type SFlowRawHeaderProtocol uint32 + +const ( + SFlowProtoEthernet SFlowRawHeaderProtocol = 1 + SFlowProtoISO88024 SFlowRawHeaderProtocol = 2 + SFlowProtoISO88025 SFlowRawHeaderProtocol = 3 + SFlowProtoFDDI SFlowRawHeaderProtocol = 4 + SFlowProtoFrameRelay SFlowRawHeaderProtocol = 5 + SFlowProtoX25 SFlowRawHeaderProtocol = 6 + SFlowProtoPPP SFlowRawHeaderProtocol = 7 + SFlowProtoSMDS SFlowRawHeaderProtocol = 8 + SFlowProtoAAL5 SFlowRawHeaderProtocol = 9 + SFlowProtoAAL5_IP SFlowRawHeaderProtocol = 10 /* e.g. Cisco AAL5 mux */ + SFlowProtoIPv4 SFlowRawHeaderProtocol = 11 + SFlowProtoIPv6 SFlowRawHeaderProtocol = 12 + SFlowProtoMPLS SFlowRawHeaderProtocol = 13 + SFlowProtoPOS SFlowRawHeaderProtocol = 14 /* RFC 1662, 2615 */ +) + +func (sfhp SFlowRawHeaderProtocol) String() string { + switch sfhp { + case SFlowProtoEthernet: + return "ETHERNET-ISO88023" + case SFlowProtoISO88024: + return "ISO88024-TOKENBUS" + case SFlowProtoISO88025: + return "ISO88025-TOKENRING" + case SFlowProtoFDDI: + return "FDDI" + case SFlowProtoFrameRelay: + return "FRAME-RELAY" + case SFlowProtoX25: + return "X25" + case SFlowProtoPPP: + return "PPP" + case SFlowProtoSMDS: + return "SMDS" + case SFlowProtoAAL5: + return "AAL5" + case SFlowProtoAAL5_IP: + return "AAL5-IP" + case SFlowProtoIPv4: + return "IPv4" + case SFlowProtoIPv6: + return "IPv6" + case SFlowProtoMPLS: + return "MPLS" + case SFlowProtoPOS: + return "POS" + } + return "UNKNOWN" +} + +func decodeRawPacketFlowRecord(data *[]byte) (SFlowRawPacketFlowRecord, error) { + rec := SFlowRawPacketFlowRecord{} + header := []byte{} + var fdf SFlowFlowDataFormat + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + rec.EnterpriseID, rec.Format = fdf.decode() + *data, rec.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, rec.HeaderProtocol = (*data)[4:], SFlowRawHeaderProtocol(binary.BigEndian.Uint32((*data)[:4])) + *data, rec.FrameLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, rec.PayloadRemoved = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, rec.HeaderLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + headerLenWithPadding := int(rec.HeaderLength + ((4 - rec.HeaderLength) % 4)) + *data, header = (*data)[headerLenWithPadding:], (*data)[:headerLenWithPadding] + rec.Header = gopacket.NewPacket(header, LayerTypeEthernet, gopacket.Default) + return rec, nil +} + +// SFlowExtendedSwitchFlowRecord give additional information +// about the sampled packet if it's available. It's mainly +// useful for getting at the incoming and outgoing VLANs +// An agent may or may not provide this information. +type SFlowExtendedSwitchFlowRecord struct { + SFlowBaseFlowRecord + IncomingVLAN uint32 + IncomingVLANPriority uint32 + OutgoingVLAN uint32 + OutgoingVLANPriority uint32 +} + +// Extended switch records have the following structure: + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Incoming VLAN | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Incoming VLAN Priority | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Outgoing VLAN | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Outgoing VLAN Priority | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +func decodeExtendedSwitchFlowRecord(data *[]byte) (SFlowExtendedSwitchFlowRecord, error) { + es := SFlowExtendedSwitchFlowRecord{} + var fdf SFlowFlowDataFormat + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + es.EnterpriseID, es.Format = fdf.decode() + *data, es.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, es.IncomingVLAN = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, es.IncomingVLANPriority = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, es.OutgoingVLAN = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, es.OutgoingVLANPriority = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + return es, nil +} + +// SFlowExtendedRouterFlowRecord gives additional information +// about the layer 3 routing information used to forward +// the packet +type SFlowExtendedRouterFlowRecord struct { + SFlowBaseFlowRecord + NextHop net.IP + NextHopSourceMask uint32 + NextHopDestinationMask uint32 +} + +// Extended router records have the following structure: + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Next Hop | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Next Hop Source Mask | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Next Hop Destination Mask | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +func decodeExtendedRouterFlowRecord(data *[]byte) (SFlowExtendedRouterFlowRecord, error) { + er := SFlowExtendedRouterFlowRecord{} + var fdf SFlowFlowDataFormat + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + er.EnterpriseID, er.Format = fdf.decode() + *data, er.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, er.NextHop = (*data)[4:], (*data)[:4] + *data, er.NextHopSourceMask = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, er.NextHopDestinationMask = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + return er, nil +} + +// SFlowExtendedGatewayFlowRecord describes information treasured by +// nework engineers everywhere: AS path information listing which +// BGP peer sent the packet, and various other BGP related info. +// This information is vital because it gives a picture of how much +// traffic is being sent from / received by various BGP peers. + +// Extended gatway records have the following structure: + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Next Hop | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | AS | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Source AS | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Peer AS | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | AS Path Count | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / AS Path / Sequence / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / Communities / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Local Pref | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +// AS Path / Sequence: + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | AS Source Type (Path=1 / Sequence=2) | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Path / Sequence length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / Path / Sequence Members / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +// Communities: + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | communitiy length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / communitiy Members / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +type SFlowExtendedGatewayFlowRecord struct { + SFlowBaseFlowRecord + NextHop net.IP + AS uint32 + SourceAS uint32 + PeerAS uint32 + ASPathCount uint32 + ASPath []SFlowASDestination + Communities []uint32 + LocalPref uint32 +} + +type SFlowASPathType uint32 + +const ( + SFlowASSet SFlowASPathType = 1 + SFlowASSequence SFlowASPathType = 2 +) + +func (apt SFlowASPathType) String() string { + switch apt { + case SFlowASSet: + return "AS Set" + case SFlowASSequence: + return "AS Sequence" + default: + return "" + } +} + +type SFlowASDestination struct { + Type SFlowASPathType + Count uint32 + Members []uint32 +} + +func (asd SFlowASDestination) String() string { + switch asd.Type { + case SFlowASSet: + return fmt.Sprint("AS Set:", asd.Members) + case SFlowASSequence: + return fmt.Sprint("AS Sequence:", asd.Members) + default: + return "" + } +} + +func (ad *SFlowASDestination) decodePath(data *[]byte) { + *data, ad.Type = (*data)[4:], SFlowASPathType(binary.BigEndian.Uint32((*data)[:4])) + *data, ad.Count = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + ad.Members = make([]uint32, ad.Count) + for i := uint32(0); i < ad.Count; i++ { + var member uint32 + *data, member = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + ad.Members[i] = member + } +} + +func decodeExtendedGatewayFlowRecord(data *[]byte) (SFlowExtendedGatewayFlowRecord, error) { + eg := SFlowExtendedGatewayFlowRecord{} + var fdf SFlowFlowDataFormat + var extendedGatewayAddressType SFlowIPType + var communitiesLength uint32 + var community uint32 + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + eg.EnterpriseID, eg.Format = fdf.decode() + *data, eg.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, extendedGatewayAddressType = (*data)[4:], SFlowIPType(binary.BigEndian.Uint32((*data)[:4])) + *data, eg.NextHop = (*data)[extendedGatewayAddressType.Length():], (*data)[:extendedGatewayAddressType.Length()] + *data, eg.AS = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, eg.SourceAS = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, eg.PeerAS = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, eg.ASPathCount = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + for i := uint32(0); i < eg.ASPathCount; i++ { + asPath := SFlowASDestination{} + asPath.decodePath(data) + eg.ASPath = append(eg.ASPath, asPath) + } + *data, communitiesLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + eg.Communities = make([]uint32, communitiesLength) + for j := uint32(0); j < communitiesLength; j++ { + *data, community = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + eg.Communities[j] = community + } + *data, eg.LocalPref = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + return eg, nil +} + +// ************************************************** +// Extended URL Flow Record +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | direction | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | URL | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Host | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +type SFlowURLDirection uint32 + +const ( + SFlowURLsrc SFlowURLDirection = 1 + SFlowURLdst SFlowURLDirection = 2 +) + +func (urld SFlowURLDirection) String() string { + switch urld { + case SFlowURLsrc: + return "Source address is the server" + case SFlowURLdst: + return "Destination address is the server" + default: + return "" + } +} + +type SFlowExtendedURLRecord struct { + SFlowBaseFlowRecord + Direction SFlowURLDirection + URL string + Host string +} + +func decodeExtendedURLRecord(data *[]byte) (SFlowExtendedURLRecord, error) { + eur := SFlowExtendedURLRecord{} + var fdf SFlowFlowDataFormat + var urlLen uint32 + var urlLenWithPad int + var hostLen uint32 + var hostLenWithPad int + var urlBytes []byte + var hostBytes []byte + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + eur.EnterpriseID, eur.Format = fdf.decode() + *data, eur.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, eur.Direction = (*data)[4:], SFlowURLDirection(binary.BigEndian.Uint32((*data)[:4])) + *data, urlLen = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + urlLenWithPad = int(urlLen + ((4 - urlLen) % 4)) + *data, urlBytes = (*data)[urlLenWithPad:], (*data)[:urlLenWithPad] + eur.URL = string(urlBytes[:urlLen]) + *data, hostLen = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + hostLenWithPad = int(hostLen + ((4 - hostLen) % 4)) + *data, hostBytes = (*data)[hostLenWithPad:], (*data)[:hostLenWithPad] + eur.Host = string(hostBytes[:hostLen]) + return eur, nil +} + +// ************************************************** +// Extended User Flow Record +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Source Character Set | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Source User Id | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Destination Character Set | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Destination User ID | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +type SFlowExtendedUserFlow struct { + SFlowBaseFlowRecord + SourceCharSet SFlowCharSet + SourceUserID string + DestinationCharSet SFlowCharSet + DestinationUserID string +} + +type SFlowCharSet uint32 + +const ( + SFlowCSunknown SFlowCharSet = 2 + SFlowCSASCII SFlowCharSet = 3 + SFlowCSISOLatin1 SFlowCharSet = 4 + SFlowCSISOLatin2 SFlowCharSet = 5 + SFlowCSISOLatin3 SFlowCharSet = 6 + SFlowCSISOLatin4 SFlowCharSet = 7 + SFlowCSISOLatinCyrillic SFlowCharSet = 8 + SFlowCSISOLatinArabic SFlowCharSet = 9 + SFlowCSISOLatinGreek SFlowCharSet = 10 + SFlowCSISOLatinHebrew SFlowCharSet = 11 + SFlowCSISOLatin5 SFlowCharSet = 12 + SFlowCSISOLatin6 SFlowCharSet = 13 + SFlowCSISOTextComm SFlowCharSet = 14 + SFlowCSHalfWidthKatakana SFlowCharSet = 15 + SFlowCSJISEncoding SFlowCharSet = 16 + SFlowCSShiftJIS SFlowCharSet = 17 + SFlowCSEUCPkdFmtJapanese SFlowCharSet = 18 + SFlowCSEUCFixWidJapanese SFlowCharSet = 19 + SFlowCSISO4UnitedKingdom SFlowCharSet = 20 + SFlowCSISO11SwedishForNames SFlowCharSet = 21 + SFlowCSISO15Italian SFlowCharSet = 22 + SFlowCSISO17Spanish SFlowCharSet = 23 + SFlowCSISO21German SFlowCharSet = 24 + SFlowCSISO60DanishNorwegian SFlowCharSet = 25 + SFlowCSISO69French SFlowCharSet = 26 + SFlowCSISO10646UTF1 SFlowCharSet = 27 + SFlowCSISO646basic1983 SFlowCharSet = 28 + SFlowCSINVARIANT SFlowCharSet = 29 + SFlowCSISO2IntlRefVersion SFlowCharSet = 30 + SFlowCSNATSSEFI SFlowCharSet = 31 + SFlowCSNATSSEFIADD SFlowCharSet = 32 + SFlowCSNATSDANO SFlowCharSet = 33 + SFlowCSNATSDANOADD SFlowCharSet = 34 + SFlowCSISO10Swedish SFlowCharSet = 35 + SFlowCSKSC56011987 SFlowCharSet = 36 + SFlowCSISO2022KR SFlowCharSet = 37 + SFlowCSEUCKR SFlowCharSet = 38 + SFlowCSISO2022JP SFlowCharSet = 39 + SFlowCSISO2022JP2 SFlowCharSet = 40 + SFlowCSISO13JISC6220jp SFlowCharSet = 41 + SFlowCSISO14JISC6220ro SFlowCharSet = 42 + SFlowCSISO16Portuguese SFlowCharSet = 43 + SFlowCSISO18Greek7Old SFlowCharSet = 44 + SFlowCSISO19LatinGreek SFlowCharSet = 45 + SFlowCSISO25French SFlowCharSet = 46 + SFlowCSISO27LatinGreek1 SFlowCharSet = 47 + SFlowCSISO5427Cyrillic SFlowCharSet = 48 + SFlowCSISO42JISC62261978 SFlowCharSet = 49 + SFlowCSISO47BSViewdata SFlowCharSet = 50 + SFlowCSISO49INIS SFlowCharSet = 51 + SFlowCSISO50INIS8 SFlowCharSet = 52 + SFlowCSISO51INISCyrillic SFlowCharSet = 53 + SFlowCSISO54271981 SFlowCharSet = 54 + SFlowCSISO5428Greek SFlowCharSet = 55 + SFlowCSISO57GB1988 SFlowCharSet = 56 + SFlowCSISO58GB231280 SFlowCharSet = 57 + SFlowCSISO61Norwegian2 SFlowCharSet = 58 + SFlowCSISO70VideotexSupp1 SFlowCharSet = 59 + SFlowCSISO84Portuguese2 SFlowCharSet = 60 + SFlowCSISO85Spanish2 SFlowCharSet = 61 + SFlowCSISO86Hungarian SFlowCharSet = 62 + SFlowCSISO87JISX0208 SFlowCharSet = 63 + SFlowCSISO88Greek7 SFlowCharSet = 64 + SFlowCSISO89ASMO449 SFlowCharSet = 65 + SFlowCSISO90 SFlowCharSet = 66 + SFlowCSISO91JISC62291984a SFlowCharSet = 67 + SFlowCSISO92JISC62991984b SFlowCharSet = 68 + SFlowCSISO93JIS62291984badd SFlowCharSet = 69 + SFlowCSISO94JIS62291984hand SFlowCharSet = 70 + SFlowCSISO95JIS62291984handadd SFlowCharSet = 71 + SFlowCSISO96JISC62291984kana SFlowCharSet = 72 + SFlowCSISO2033 SFlowCharSet = 73 + SFlowCSISO99NAPLPS SFlowCharSet = 74 + SFlowCSISO102T617bit SFlowCharSet = 75 + SFlowCSISO103T618bit SFlowCharSet = 76 + SFlowCSISO111ECMACyrillic SFlowCharSet = 77 + SFlowCSa71 SFlowCharSet = 78 + SFlowCSa72 SFlowCharSet = 79 + SFlowCSISO123CSAZ24341985gr SFlowCharSet = 80 + SFlowCSISO88596E SFlowCharSet = 81 + SFlowCSISO88596I SFlowCharSet = 82 + SFlowCSISO128T101G2 SFlowCharSet = 83 + SFlowCSISO88598E SFlowCharSet = 84 + SFlowCSISO88598I SFlowCharSet = 85 + SFlowCSISO139CSN369103 SFlowCharSet = 86 + SFlowCSISO141JUSIB1002 SFlowCharSet = 87 + SFlowCSISO143IECP271 SFlowCharSet = 88 + SFlowCSISO146Serbian SFlowCharSet = 89 + SFlowCSISO147Macedonian SFlowCharSet = 90 + SFlowCSISO150 SFlowCharSet = 91 + SFlowCSISO151Cuba SFlowCharSet = 92 + SFlowCSISO6937Add SFlowCharSet = 93 + SFlowCSISO153GOST1976874 SFlowCharSet = 94 + SFlowCSISO8859Supp SFlowCharSet = 95 + SFlowCSISO10367Box SFlowCharSet = 96 + SFlowCSISO158Lap SFlowCharSet = 97 + SFlowCSISO159JISX02121990 SFlowCharSet = 98 + SFlowCSISO646Danish SFlowCharSet = 99 + SFlowCSUSDK SFlowCharSet = 100 + SFlowCSDKUS SFlowCharSet = 101 + SFlowCSKSC5636 SFlowCharSet = 102 + SFlowCSUnicode11UTF7 SFlowCharSet = 103 + SFlowCSISO2022CN SFlowCharSet = 104 + SFlowCSISO2022CNEXT SFlowCharSet = 105 + SFlowCSUTF8 SFlowCharSet = 106 + SFlowCSISO885913 SFlowCharSet = 109 + SFlowCSISO885914 SFlowCharSet = 110 + SFlowCSISO885915 SFlowCharSet = 111 + SFlowCSISO885916 SFlowCharSet = 112 + SFlowCSGBK SFlowCharSet = 113 + SFlowCSGB18030 SFlowCharSet = 114 + SFlowCSOSDEBCDICDF0415 SFlowCharSet = 115 + SFlowCSOSDEBCDICDF03IRV SFlowCharSet = 116 + SFlowCSOSDEBCDICDF041 SFlowCharSet = 117 + SFlowCSISO115481 SFlowCharSet = 118 + SFlowCSKZ1048 SFlowCharSet = 119 + SFlowCSUnicode SFlowCharSet = 1000 + SFlowCSUCS4 SFlowCharSet = 1001 + SFlowCSUnicodeASCII SFlowCharSet = 1002 + SFlowCSUnicodeLatin1 SFlowCharSet = 1003 + SFlowCSUnicodeJapanese SFlowCharSet = 1004 + SFlowCSUnicodeIBM1261 SFlowCharSet = 1005 + SFlowCSUnicodeIBM1268 SFlowCharSet = 1006 + SFlowCSUnicodeIBM1276 SFlowCharSet = 1007 + SFlowCSUnicodeIBM1264 SFlowCharSet = 1008 + SFlowCSUnicodeIBM1265 SFlowCharSet = 1009 + SFlowCSUnicode11 SFlowCharSet = 1010 + SFlowCSSCSU SFlowCharSet = 1011 + SFlowCSUTF7 SFlowCharSet = 1012 + SFlowCSUTF16BE SFlowCharSet = 1013 + SFlowCSUTF16LE SFlowCharSet = 1014 + SFlowCSUTF16 SFlowCharSet = 1015 + SFlowCSCESU8 SFlowCharSet = 1016 + SFlowCSUTF32 SFlowCharSet = 1017 + SFlowCSUTF32BE SFlowCharSet = 1018 + SFlowCSUTF32LE SFlowCharSet = 1019 + SFlowCSBOCU1 SFlowCharSet = 1020 + SFlowCSWindows30Latin1 SFlowCharSet = 2000 + SFlowCSWindows31Latin1 SFlowCharSet = 2001 + SFlowCSWindows31Latin2 SFlowCharSet = 2002 + SFlowCSWindows31Latin5 SFlowCharSet = 2003 + SFlowCSHPRoman8 SFlowCharSet = 2004 + SFlowCSAdobeStandardEncoding SFlowCharSet = 2005 + SFlowCSVenturaUS SFlowCharSet = 2006 + SFlowCSVenturaInternational SFlowCharSet = 2007 + SFlowCSDECMCS SFlowCharSet = 2008 + SFlowCSPC850Multilingual SFlowCharSet = 2009 + SFlowCSPCp852 SFlowCharSet = 2010 + SFlowCSPC8CodePage437 SFlowCharSet = 2011 + SFlowCSPC8DanishNorwegian SFlowCharSet = 2012 + SFlowCSPC862LatinHebrew SFlowCharSet = 2013 + SFlowCSPC8Turkish SFlowCharSet = 2014 + SFlowCSIBMSymbols SFlowCharSet = 2015 + SFlowCSIBMThai SFlowCharSet = 2016 + SFlowCSHPLegal SFlowCharSet = 2017 + SFlowCSHPPiFont SFlowCharSet = 2018 + SFlowCSHPMath8 SFlowCharSet = 2019 + SFlowCSHPPSMath SFlowCharSet = 2020 + SFlowCSHPDesktop SFlowCharSet = 2021 + SFlowCSVenturaMath SFlowCharSet = 2022 + SFlowCSMicrosoftPublishing SFlowCharSet = 2023 + SFlowCSWindows31J SFlowCharSet = 2024 + SFlowCSGB2312 SFlowCharSet = 2025 + SFlowCSBig5 SFlowCharSet = 2026 + SFlowCSMacintosh SFlowCharSet = 2027 + SFlowCSIBM037 SFlowCharSet = 2028 + SFlowCSIBM038 SFlowCharSet = 2029 + SFlowCSIBM273 SFlowCharSet = 2030 + SFlowCSIBM274 SFlowCharSet = 2031 + SFlowCSIBM275 SFlowCharSet = 2032 + SFlowCSIBM277 SFlowCharSet = 2033 + SFlowCSIBM278 SFlowCharSet = 2034 + SFlowCSIBM280 SFlowCharSet = 2035 + SFlowCSIBM281 SFlowCharSet = 2036 + SFlowCSIBM284 SFlowCharSet = 2037 + SFlowCSIBM285 SFlowCharSet = 2038 + SFlowCSIBM290 SFlowCharSet = 2039 + SFlowCSIBM297 SFlowCharSet = 2040 + SFlowCSIBM420 SFlowCharSet = 2041 + SFlowCSIBM423 SFlowCharSet = 2042 + SFlowCSIBM424 SFlowCharSet = 2043 + SFlowCSIBM500 SFlowCharSet = 2044 + SFlowCSIBM851 SFlowCharSet = 2045 + SFlowCSIBM855 SFlowCharSet = 2046 + SFlowCSIBM857 SFlowCharSet = 2047 + SFlowCSIBM860 SFlowCharSet = 2048 + SFlowCSIBM861 SFlowCharSet = 2049 + SFlowCSIBM863 SFlowCharSet = 2050 + SFlowCSIBM864 SFlowCharSet = 2051 + SFlowCSIBM865 SFlowCharSet = 2052 + SFlowCSIBM868 SFlowCharSet = 2053 + SFlowCSIBM869 SFlowCharSet = 2054 + SFlowCSIBM870 SFlowCharSet = 2055 + SFlowCSIBM871 SFlowCharSet = 2056 + SFlowCSIBM880 SFlowCharSet = 2057 + SFlowCSIBM891 SFlowCharSet = 2058 + SFlowCSIBM903 SFlowCharSet = 2059 + SFlowCSIBBM904 SFlowCharSet = 2060 + SFlowCSIBM905 SFlowCharSet = 2061 + SFlowCSIBM918 SFlowCharSet = 2062 + SFlowCSIBM1026 SFlowCharSet = 2063 + SFlowCSIBMEBCDICATDE SFlowCharSet = 2064 + SFlowCSEBCDICATDEA SFlowCharSet = 2065 + SFlowCSEBCDICCAFR SFlowCharSet = 2066 + SFlowCSEBCDICDKNO SFlowCharSet = 2067 + SFlowCSEBCDICDKNOA SFlowCharSet = 2068 + SFlowCSEBCDICFISE SFlowCharSet = 2069 + SFlowCSEBCDICFISEA SFlowCharSet = 2070 + SFlowCSEBCDICFR SFlowCharSet = 2071 + SFlowCSEBCDICIT SFlowCharSet = 2072 + SFlowCSEBCDICPT SFlowCharSet = 2073 + SFlowCSEBCDICES SFlowCharSet = 2074 + SFlowCSEBCDICESA SFlowCharSet = 2075 + SFlowCSEBCDICESS SFlowCharSet = 2076 + SFlowCSEBCDICUK SFlowCharSet = 2077 + SFlowCSEBCDICUS SFlowCharSet = 2078 + SFlowCSUnknown8BiT SFlowCharSet = 2079 + SFlowCSMnemonic SFlowCharSet = 2080 + SFlowCSMnem SFlowCharSet = 2081 + SFlowCSVISCII SFlowCharSet = 2082 + SFlowCSVIQR SFlowCharSet = 2083 + SFlowCSKOI8R SFlowCharSet = 2084 + SFlowCSHZGB2312 SFlowCharSet = 2085 + SFlowCSIBM866 SFlowCharSet = 2086 + SFlowCSPC775Baltic SFlowCharSet = 2087 + SFlowCSKOI8U SFlowCharSet = 2088 + SFlowCSIBM00858 SFlowCharSet = 2089 + SFlowCSIBM00924 SFlowCharSet = 2090 + SFlowCSIBM01140 SFlowCharSet = 2091 + SFlowCSIBM01141 SFlowCharSet = 2092 + SFlowCSIBM01142 SFlowCharSet = 2093 + SFlowCSIBM01143 SFlowCharSet = 2094 + SFlowCSIBM01144 SFlowCharSet = 2095 + SFlowCSIBM01145 SFlowCharSet = 2096 + SFlowCSIBM01146 SFlowCharSet = 2097 + SFlowCSIBM01147 SFlowCharSet = 2098 + SFlowCSIBM01148 SFlowCharSet = 2099 + SFlowCSIBM01149 SFlowCharSet = 2100 + SFlowCSBig5HKSCS SFlowCharSet = 2101 + SFlowCSIBM1047 SFlowCharSet = 2102 + SFlowCSPTCP154 SFlowCharSet = 2103 + SFlowCSAmiga1251 SFlowCharSet = 2104 + SFlowCSKOI7switched SFlowCharSet = 2105 + SFlowCSBRF SFlowCharSet = 2106 + SFlowCSTSCII SFlowCharSet = 2107 + SFlowCSCP51932 SFlowCharSet = 2108 + SFlowCSWindows874 SFlowCharSet = 2109 + SFlowCSWindows1250 SFlowCharSet = 2250 + SFlowCSWindows1251 SFlowCharSet = 2251 + SFlowCSWindows1252 SFlowCharSet = 2252 + SFlowCSWindows1253 SFlowCharSet = 2253 + SFlowCSWindows1254 SFlowCharSet = 2254 + SFlowCSWindows1255 SFlowCharSet = 2255 + SFlowCSWindows1256 SFlowCharSet = 2256 + SFlowCSWindows1257 SFlowCharSet = 2257 + SFlowCSWindows1258 SFlowCharSet = 2258 + SFlowCSTIS620 SFlowCharSet = 2259 + SFlowCS50220 SFlowCharSet = 2260 + SFlowCSreserved SFlowCharSet = 3000 +) + +func decodeExtendedUserFlow(data *[]byte) (SFlowExtendedUserFlow, error) { + eu := SFlowExtendedUserFlow{} + var fdf SFlowFlowDataFormat + var srcUserLen uint32 + var srcUserLenWithPad int + var srcUserBytes []byte + var dstUserLen uint32 + var dstUserLenWithPad int + var dstUserBytes []byte + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + eu.EnterpriseID, eu.Format = fdf.decode() + *data, eu.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, eu.SourceCharSet = (*data)[4:], SFlowCharSet(binary.BigEndian.Uint32((*data)[:4])) + *data, srcUserLen = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + srcUserLenWithPad = int(srcUserLen + ((4 - srcUserLen) % 4)) + *data, srcUserBytes = (*data)[srcUserLenWithPad:], (*data)[:srcUserLenWithPad] + eu.SourceUserID = string(srcUserBytes[:srcUserLen]) + *data, eu.DestinationCharSet = (*data)[4:], SFlowCharSet(binary.BigEndian.Uint32((*data)[:4])) + *data, dstUserLen = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + dstUserLenWithPad = int(dstUserLen + ((4 - dstUserLen) % 4)) + *data, dstUserBytes = (*data)[dstUserLenWithPad:], (*data)[:dstUserLenWithPad] + eu.DestinationUserID = string(dstUserBytes[:dstUserLen]) + return eu, nil +} + +// ************************************************** +// Packet IP version 4 Record +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Protocol | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Source IPv4 | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Destination IPv4 | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Source Port | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Destionation Port | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | TCP Flags | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | TOS | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +type SFlowIpv4Record struct { + // The length of the IP packet excluding ower layer encapsulations + Length uint32 + // IP Protocol type (for example, TCP = 6, UDP = 17) + Protocol uint32 + // Source IP Address + IPSrc net.IP + // Destination IP Address + IPDst net.IP + // TCP/UDP source port number or equivalent + PortSrc uint32 + // TCP/UDP destination port number or equivalent + PortDst uint32 + // TCP flags + TCPFlags uint32 + // IP type of service + TOS uint32 +} + +func decodeSFlowIpv4Record(data *[]byte) (SFlowIpv4Record, error) { + si := SFlowIpv4Record{} + + *data, si.Length = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, si.Protocol = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, si.IPSrc = (*data)[4:], net.IP((*data)[:4]) + *data, si.IPDst = (*data)[4:], net.IP((*data)[:4]) + *data, si.PortSrc = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, si.PortDst = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, si.TCPFlags = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, si.TOS = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + + return si, nil +} + +// ************************************************** +// Packet IP version 6 Record +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Protocol | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Source IPv4 | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Destination IPv4 | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Source Port | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Destionation Port | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | TCP Flags | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Priority | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +type SFlowIpv6Record struct { + // The length of the IP packet excluding ower layer encapsulations + Length uint32 + // IP Protocol type (for example, TCP = 6, UDP = 17) + Protocol uint32 + // Source IP Address + IPSrc net.IP + // Destination IP Address + IPDst net.IP + // TCP/UDP source port number or equivalent + PortSrc uint32 + // TCP/UDP destination port number or equivalent + PortDst uint32 + // TCP flags + TCPFlags uint32 + // IP priority + Priority uint32 +} + +func decodeSFlowIpv6Record(data *[]byte) (SFlowIpv6Record, error) { + si := SFlowIpv6Record{} + + *data, si.Length = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, si.Protocol = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, si.IPSrc = (*data)[16:], net.IP((*data)[:16]) + *data, si.IPDst = (*data)[16:], net.IP((*data)[:16]) + *data, si.PortSrc = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, si.PortDst = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, si.TCPFlags = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, si.Priority = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + + return si, nil +} + +// ************************************************** +// Extended IPv4 Tunnel Egress +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / Packet IP version 4 Record / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +type SFlowExtendedIpv4TunnelEgressRecord struct { + SFlowBaseFlowRecord + SFlowIpv4Record SFlowIpv4Record +} + +func decodeExtendedIpv4TunnelEgress(data *[]byte) (SFlowExtendedIpv4TunnelEgressRecord, error) { + rec := SFlowExtendedIpv4TunnelEgressRecord{} + var fdf SFlowFlowDataFormat + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + rec.EnterpriseID, rec.Format = fdf.decode() + *data, rec.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + rec.SFlowIpv4Record, _ = decodeSFlowIpv4Record(data) + + return rec, nil +} + +// ************************************************** +// Extended IPv4 Tunnel Ingress +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / Packet IP version 4 Record / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +type SFlowExtendedIpv4TunnelIngressRecord struct { + SFlowBaseFlowRecord + SFlowIpv4Record SFlowIpv4Record +} + +func decodeExtendedIpv4TunnelIngress(data *[]byte) (SFlowExtendedIpv4TunnelIngressRecord, error) { + rec := SFlowExtendedIpv4TunnelIngressRecord{} + var fdf SFlowFlowDataFormat + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + rec.EnterpriseID, rec.Format = fdf.decode() + *data, rec.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + rec.SFlowIpv4Record, _ = decodeSFlowIpv4Record(data) + + return rec, nil +} + +// ************************************************** +// Extended IPv6 Tunnel Egress +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / Packet IP version 6 Record / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +type SFlowExtendedIpv6TunnelEgressRecord struct { + SFlowBaseFlowRecord + SFlowIpv6Record +} + +func decodeExtendedIpv6TunnelEgress(data *[]byte) (SFlowExtendedIpv6TunnelEgressRecord, error) { + rec := SFlowExtendedIpv6TunnelEgressRecord{} + var fdf SFlowFlowDataFormat + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + rec.EnterpriseID, rec.Format = fdf.decode() + *data, rec.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + rec.SFlowIpv6Record, _ = decodeSFlowIpv6Record(data) + + return rec, nil +} + +// ************************************************** +// Extended IPv6 Tunnel Ingress +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / Packet IP version 6 Record / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +type SFlowExtendedIpv6TunnelIngressRecord struct { + SFlowBaseFlowRecord + SFlowIpv6Record +} + +func decodeExtendedIpv6TunnelIngress(data *[]byte) (SFlowExtendedIpv6TunnelIngressRecord, error) { + rec := SFlowExtendedIpv6TunnelIngressRecord{} + var fdf SFlowFlowDataFormat + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + rec.EnterpriseID, rec.Format = fdf.decode() + *data, rec.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + rec.SFlowIpv6Record, _ = decodeSFlowIpv6Record(data) + + return rec, nil +} + +// ************************************************** +// Extended Decapsulate Egress +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Inner Header Offset | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +type SFlowExtendedDecapsulateEgressRecord struct { + SFlowBaseFlowRecord + InnerHeaderOffset uint32 +} + +func decodeExtendedDecapsulateEgress(data *[]byte) (SFlowExtendedDecapsulateEgressRecord, error) { + rec := SFlowExtendedDecapsulateEgressRecord{} + var fdf SFlowFlowDataFormat + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + rec.EnterpriseID, rec.Format = fdf.decode() + *data, rec.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, rec.InnerHeaderOffset = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + + return rec, nil +} + +// ************************************************** +// Extended Decapsulate Ingress +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | Inner Header Offset | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +type SFlowExtendedDecapsulateIngressRecord struct { + SFlowBaseFlowRecord + InnerHeaderOffset uint32 +} + +func decodeExtendedDecapsulateIngress(data *[]byte) (SFlowExtendedDecapsulateIngressRecord, error) { + rec := SFlowExtendedDecapsulateIngressRecord{} + var fdf SFlowFlowDataFormat + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + rec.EnterpriseID, rec.Format = fdf.decode() + *data, rec.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, rec.InnerHeaderOffset = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + + return rec, nil +} + +// ************************************************** +// Extended VNI Egress +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | VNI | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +type SFlowExtendedVniEgressRecord struct { + SFlowBaseFlowRecord + VNI uint32 +} + +func decodeExtendedVniEgress(data *[]byte) (SFlowExtendedVniEgressRecord, error) { + rec := SFlowExtendedVniEgressRecord{} + var fdf SFlowFlowDataFormat + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + rec.EnterpriseID, rec.Format = fdf.decode() + *data, rec.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, rec.VNI = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + + return rec, nil +} + +// ************************************************** +// Extended VNI Ingress +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | record length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | VNI | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +type SFlowExtendedVniIngressRecord struct { + SFlowBaseFlowRecord + VNI uint32 +} + +func decodeExtendedVniIngress(data *[]byte) (SFlowExtendedVniIngressRecord, error) { + rec := SFlowExtendedVniIngressRecord{} + var fdf SFlowFlowDataFormat + + *data, fdf = (*data)[4:], SFlowFlowDataFormat(binary.BigEndian.Uint32((*data)[:4])) + rec.EnterpriseID, rec.Format = fdf.decode() + *data, rec.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, rec.VNI = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + + return rec, nil +} + +// ************************************************** +// Counter Record +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | counter length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / counter data / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +type SFlowBaseCounterRecord struct { + EnterpriseID SFlowEnterpriseID + Format SFlowCounterRecordType + FlowDataLength uint32 +} + +func (bcr SFlowBaseCounterRecord) GetType() SFlowCounterRecordType { + switch bcr.Format { + case SFlowTypeGenericInterfaceCounters: + return SFlowTypeGenericInterfaceCounters + case SFlowTypeEthernetInterfaceCounters: + return SFlowTypeEthernetInterfaceCounters + case SFlowTypeTokenRingInterfaceCounters: + return SFlowTypeTokenRingInterfaceCounters + case SFlowType100BaseVGInterfaceCounters: + return SFlowType100BaseVGInterfaceCounters + case SFlowTypeVLANCounters: + return SFlowTypeVLANCounters + case SFlowTypeProcessorCounters: + return SFlowTypeProcessorCounters + + } + unrecognized := fmt.Sprint("Unrecognized counter record type:", bcr.Format) + panic(unrecognized) +} + +// ************************************************** +// Counter Record +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | counter length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfIndex | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfType | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfSpeed | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfDirection | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfStatus | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IFInOctets | +// | | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfInUcastPkts | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfInMulticastPkts | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfInBroadcastPkts | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfInDiscards | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | InInErrors | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfInUnknownProtos | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfOutOctets | +// | | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfOutUcastPkts | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfOutMulticastPkts | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfOutBroadcastPkts | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfOutDiscards | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfOUtErrors | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | IfPromiscouousMode | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +type SFlowGenericInterfaceCounters struct { + SFlowBaseCounterRecord + IfIndex uint32 + IfType uint32 + IfSpeed uint64 + IfDirection uint32 + IfStatus uint32 + IfInOctets uint64 + IfInUcastPkts uint32 + IfInMulticastPkts uint32 + IfInBroadcastPkts uint32 + IfInDiscards uint32 + IfInErrors uint32 + IfInUnknownProtos uint32 + IfOutOctets uint64 + IfOutUcastPkts uint32 + IfOutMulticastPkts uint32 + IfOutBroadcastPkts uint32 + IfOutDiscards uint32 + IfOutErrors uint32 + IfPromiscuousMode uint32 +} + +func decodeGenericInterfaceCounters(data *[]byte) (SFlowGenericInterfaceCounters, error) { + gic := SFlowGenericInterfaceCounters{} + var cdf SFlowCounterDataFormat + + *data, cdf = (*data)[4:], SFlowCounterDataFormat(binary.BigEndian.Uint32((*data)[:4])) + gic.EnterpriseID, gic.Format = cdf.decode() + *data, gic.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfIndex = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfType = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfSpeed = (*data)[8:], binary.BigEndian.Uint64((*data)[:8]) + *data, gic.IfDirection = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfStatus = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfInOctets = (*data)[8:], binary.BigEndian.Uint64((*data)[:8]) + *data, gic.IfInUcastPkts = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfInMulticastPkts = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfInBroadcastPkts = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfInDiscards = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfInErrors = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfInUnknownProtos = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfOutOctets = (*data)[8:], binary.BigEndian.Uint64((*data)[:8]) + *data, gic.IfOutUcastPkts = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfOutMulticastPkts = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfOutBroadcastPkts = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfOutDiscards = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfOutErrors = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, gic.IfPromiscuousMode = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + return gic, nil +} + +// ************************************************** +// Counter Record +// ************************************************** + +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | counter length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// / counter data / +// / / +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +type SFlowEthernetCounters struct { + SFlowBaseCounterRecord + AlignmentErrors uint32 + FCSErrors uint32 + SingleCollisionFrames uint32 + MultipleCollisionFrames uint32 + SQETestErrors uint32 + DeferredTransmissions uint32 + LateCollisions uint32 + ExcessiveCollisions uint32 + InternalMacTransmitErrors uint32 + CarrierSenseErrors uint32 + FrameTooLongs uint32 + InternalMacReceiveErrors uint32 + SymbolErrors uint32 +} + +func decodeEthernetCounters(data *[]byte) (SFlowEthernetCounters, error) { + ec := SFlowEthernetCounters{} + var cdf SFlowCounterDataFormat + + *data, cdf = (*data)[4:], SFlowCounterDataFormat(binary.BigEndian.Uint32((*data)[:4])) + ec.EnterpriseID, ec.Format = cdf.decode() + *data, ec.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.AlignmentErrors = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.FCSErrors = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.SingleCollisionFrames = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.MultipleCollisionFrames = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.SQETestErrors = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.DeferredTransmissions = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.LateCollisions = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.ExcessiveCollisions = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.InternalMacTransmitErrors = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.CarrierSenseErrors = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.FrameTooLongs = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.InternalMacReceiveErrors = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, ec.SymbolErrors = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + return ec, nil +} + +// ************************************************** +// Processor Counter Record +// ************************************************** +// 0 15 31 +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | 20 bit Interprise (0) |12 bit format | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | counter length | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | FiveSecCpu | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | OneMinCpu | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | GiveMinCpu | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | TotalMemory | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +// | FreeMemory | +// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +type SFlowProcessorCounters struct { + SFlowBaseCounterRecord + FiveSecCpu uint32 // 5 second average CPU utilization + OneMinCpu uint32 // 1 minute average CPU utilization + FiveMinCpu uint32 // 5 minute average CPU utilization + TotalMemory uint64 // total memory (in bytes) + FreeMemory uint64 // free memory (in bytes) +} + +func decodeProcessorCounters(data *[]byte) (SFlowProcessorCounters, error) { + pc := SFlowProcessorCounters{} + var cdf SFlowCounterDataFormat + var high32, low32 uint32 + + *data, cdf = (*data)[4:], SFlowCounterDataFormat(binary.BigEndian.Uint32((*data)[:4])) + pc.EnterpriseID, pc.Format = cdf.decode() + *data, pc.FlowDataLength = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + + *data, pc.FiveSecCpu = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, pc.OneMinCpu = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, pc.FiveMinCpu = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, high32 = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, low32 = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + pc.TotalMemory = (uint64(high32) << 32) + uint64(low32) + *data, high32 = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + *data, low32 = (*data)[4:], binary.BigEndian.Uint32((*data)[:4]) + pc.FreeMemory = (uint64(high32)) + uint64(low32) + + return pc, nil +} diff --git a/vendor/github.com/google/gopacket/layers/tcp.go b/vendor/github.com/google/gopacket/layers/tcp.go new file mode 100644 index 0000000..fb731da --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/tcp.go @@ -0,0 +1,327 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "encoding/hex" + "errors" + "fmt" + + "github.com/google/gopacket" +) + +// TCP is the layer for TCP headers. +type TCP struct { + BaseLayer + SrcPort, DstPort TCPPort + Seq uint32 + Ack uint32 + DataOffset uint8 + FIN, SYN, RST, PSH, ACK, URG, ECE, CWR, NS bool + Window uint16 + Checksum uint16 + Urgent uint16 + sPort, dPort []byte + Options []TCPOption + Padding []byte + opts [4]TCPOption + tcpipchecksum +} + +// TCPOptionKind represents a TCP option code. +type TCPOptionKind uint8 + +const ( + TCPOptionKindEndList = 0 + TCPOptionKindNop = 1 + TCPOptionKindMSS = 2 // len = 4 + TCPOptionKindWindowScale = 3 // len = 3 + TCPOptionKindSACKPermitted = 4 // len = 2 + TCPOptionKindSACK = 5 // len = n + TCPOptionKindEcho = 6 // len = 6, obsolete + TCPOptionKindEchoReply = 7 // len = 6, obsolete + TCPOptionKindTimestamps = 8 // len = 10 + TCPOptionKindPartialOrderConnectionPermitted = 9 // len = 2, obsolete + TCPOptionKindPartialOrderServiceProfile = 10 // len = 3, obsolete + TCPOptionKindCC = 11 // obsolete + TCPOptionKindCCNew = 12 // obsolete + TCPOptionKindCCEcho = 13 // obsolete + TCPOptionKindAltChecksum = 14 // len = 3, obsolete + TCPOptionKindAltChecksumData = 15 // len = n, obsolete +) + +func (k TCPOptionKind) String() string { + switch k { + case TCPOptionKindEndList: + return "EndList" + case TCPOptionKindNop: + return "NOP" + case TCPOptionKindMSS: + return "MSS" + case TCPOptionKindWindowScale: + return "WindowScale" + case TCPOptionKindSACKPermitted: + return "SACKPermitted" + case TCPOptionKindSACK: + return "SACK" + case TCPOptionKindEcho: + return "Echo" + case TCPOptionKindEchoReply: + return "EchoReply" + case TCPOptionKindTimestamps: + return "Timestamps" + case TCPOptionKindPartialOrderConnectionPermitted: + return "PartialOrderConnectionPermitted" + case TCPOptionKindPartialOrderServiceProfile: + return "PartialOrderServiceProfile" + case TCPOptionKindCC: + return "CC" + case TCPOptionKindCCNew: + return "CCNew" + case TCPOptionKindCCEcho: + return "CCEcho" + case TCPOptionKindAltChecksum: + return "AltChecksum" + case TCPOptionKindAltChecksumData: + return "AltChecksumData" + default: + return fmt.Sprintf("Unknown(%d)", k) + } +} + +type TCPOption struct { + OptionType TCPOptionKind + OptionLength uint8 + OptionData []byte +} + +func (t TCPOption) String() string { + hd := hex.EncodeToString(t.OptionData) + if len(hd) > 0 { + hd = " 0x" + hd + } + switch t.OptionType { + case TCPOptionKindMSS: + return fmt.Sprintf("TCPOption(%s:%v%s)", + t.OptionType, + binary.BigEndian.Uint16(t.OptionData), + hd) + + case TCPOptionKindTimestamps: + if len(t.OptionData) == 8 { + return fmt.Sprintf("TCPOption(%s:%v/%v%s)", + t.OptionType, + binary.BigEndian.Uint32(t.OptionData[:4]), + binary.BigEndian.Uint32(t.OptionData[4:8]), + hd) + } + } + return fmt.Sprintf("TCPOption(%s:%s)", t.OptionType, hd) +} + +// LayerType returns gopacket.LayerTypeTCP +func (t *TCP) LayerType() gopacket.LayerType { return LayerTypeTCP } + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (t *TCP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + var optionLength int + for _, o := range t.Options { + switch o.OptionType { + case 0, 1: + optionLength += 1 + default: + optionLength += 2 + len(o.OptionData) + } + } + if opts.FixLengths { + if rem := optionLength % 4; rem != 0 { + t.Padding = lotsOfZeros[:4-rem] + } + t.DataOffset = uint8((len(t.Padding) + optionLength + 20) / 4) + } + bytes, err := b.PrependBytes(20 + optionLength + len(t.Padding)) + if err != nil { + return err + } + binary.BigEndian.PutUint16(bytes, uint16(t.SrcPort)) + binary.BigEndian.PutUint16(bytes[2:], uint16(t.DstPort)) + binary.BigEndian.PutUint32(bytes[4:], t.Seq) + binary.BigEndian.PutUint32(bytes[8:], t.Ack) + binary.BigEndian.PutUint16(bytes[12:], t.flagsAndOffset()) + binary.BigEndian.PutUint16(bytes[14:], t.Window) + binary.BigEndian.PutUint16(bytes[18:], t.Urgent) + start := 20 + for _, o := range t.Options { + bytes[start] = byte(o.OptionType) + switch o.OptionType { + case 0, 1: + start++ + default: + if opts.FixLengths { + o.OptionLength = uint8(len(o.OptionData) + 2) + } + bytes[start+1] = o.OptionLength + copy(bytes[start+2:start+len(o.OptionData)+2], o.OptionData) + start += int(o.OptionLength) + } + } + copy(bytes[start:], t.Padding) + if opts.ComputeChecksums { + // zero out checksum bytes in current serialization. + bytes[16] = 0 + bytes[17] = 0 + csum, err := t.computeChecksum(b.Bytes(), IPProtocolTCP) + if err != nil { + return err + } + t.Checksum = csum + } + binary.BigEndian.PutUint16(bytes[16:], t.Checksum) + return nil +} + +func (t *TCP) ComputeChecksum() (uint16, error) { + return t.computeChecksum(append(t.Contents, t.Payload...), IPProtocolTCP) +} + +func (t *TCP) flagsAndOffset() uint16 { + f := uint16(t.DataOffset) << 12 + if t.FIN { + f |= 0x0001 + } + if t.SYN { + f |= 0x0002 + } + if t.RST { + f |= 0x0004 + } + if t.PSH { + f |= 0x0008 + } + if t.ACK { + f |= 0x0010 + } + if t.URG { + f |= 0x0020 + } + if t.ECE { + f |= 0x0040 + } + if t.CWR { + f |= 0x0080 + } + if t.NS { + f |= 0x0100 + } + return f +} + +func (tcp *TCP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + tcp.SrcPort = TCPPort(binary.BigEndian.Uint16(data[0:2])) + tcp.sPort = data[0:2] + tcp.DstPort = TCPPort(binary.BigEndian.Uint16(data[2:4])) + tcp.dPort = data[2:4] + tcp.Seq = binary.BigEndian.Uint32(data[4:8]) + tcp.Ack = binary.BigEndian.Uint32(data[8:12]) + tcp.DataOffset = data[12] >> 4 + tcp.FIN = data[13]&0x01 != 0 + tcp.SYN = data[13]&0x02 != 0 + tcp.RST = data[13]&0x04 != 0 + tcp.PSH = data[13]&0x08 != 0 + tcp.ACK = data[13]&0x10 != 0 + tcp.URG = data[13]&0x20 != 0 + tcp.ECE = data[13]&0x40 != 0 + tcp.CWR = data[13]&0x80 != 0 + tcp.NS = data[12]&0x01 != 0 + tcp.Window = binary.BigEndian.Uint16(data[14:16]) + tcp.Checksum = binary.BigEndian.Uint16(data[16:18]) + tcp.Urgent = binary.BigEndian.Uint16(data[18:20]) + tcp.Options = tcp.opts[:0] + if tcp.DataOffset < 5 { + return fmt.Errorf("Invalid TCP data offset %d < 5", tcp.DataOffset) + } + dataStart := int(tcp.DataOffset) * 4 + if dataStart > len(data) { + df.SetTruncated() + tcp.Payload = nil + tcp.Contents = data + return errors.New("TCP data offset greater than packet length") + } + tcp.Contents = data[:dataStart] + tcp.Payload = data[dataStart:] + // From here on, data points just to the header options. + data = data[20:dataStart] + for len(data) > 0 { + if tcp.Options == nil { + // Pre-allocate to avoid allocating a slice. + tcp.Options = tcp.opts[:0] + } + tcp.Options = append(tcp.Options, TCPOption{OptionType: TCPOptionKind(data[0])}) + opt := &tcp.Options[len(tcp.Options)-1] + switch opt.OptionType { + case TCPOptionKindEndList: // End of options + opt.OptionLength = 1 + tcp.Padding = data[1:] + break + case TCPOptionKindNop: // 1 byte padding + opt.OptionLength = 1 + default: + opt.OptionLength = data[1] + if opt.OptionLength < 2 { + return fmt.Errorf("Invalid TCP option length %d < 2", opt.OptionLength) + } else if int(opt.OptionLength) > len(data) { + return fmt.Errorf("Invalid TCP option length %d exceeds remaining %d bytes", opt.OptionLength, len(data)) + } + opt.OptionData = data[2:opt.OptionLength] + } + data = data[opt.OptionLength:] + } + return nil +} + +func (t *TCP) CanDecode() gopacket.LayerClass { + return LayerTypeTCP +} + +func (t *TCP) NextLayerType() gopacket.LayerType { + lt := t.DstPort.LayerType() + if lt == gopacket.LayerTypePayload { + lt = t.SrcPort.LayerType() + } + return lt +} + +func decodeTCP(data []byte, p gopacket.PacketBuilder) error { + tcp := &TCP{} + err := tcp.DecodeFromBytes(data, p) + p.AddLayer(tcp) + p.SetTransportLayer(tcp) + if err != nil { + return err + } + if p.DecodeOptions().DecodeStreamsAsDatagrams { + return p.NextDecoder(tcp.NextLayerType()) + } else { + return p.NextDecoder(gopacket.LayerTypePayload) + } +} + +func (t *TCP) TransportFlow() gopacket.Flow { + return gopacket.NewFlow(EndpointTCPPort, t.sPort, t.dPort) +} + +// For testing only +func (t *TCP) SetInternalPortsForTesting() { + t.sPort = make([]byte, 2) + t.dPort = make([]byte, 2) + binary.BigEndian.PutUint16(t.sPort, uint16(t.SrcPort)) + binary.BigEndian.PutUint16(t.dPort, uint16(t.DstPort)) +} diff --git a/vendor/github.com/google/gopacket/layers/tcpip.go b/vendor/github.com/google/gopacket/layers/tcpip.go new file mode 100644 index 0000000..64ba51c --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/tcpip.go @@ -0,0 +1,104 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "errors" + "fmt" + + "github.com/google/gopacket" +) + +// Checksum computation for TCP/UDP. +type tcpipchecksum struct { + pseudoheader tcpipPseudoHeader +} + +type tcpipPseudoHeader interface { + pseudoheaderChecksum() (uint32, error) +} + +func (ip *IPv4) pseudoheaderChecksum() (csum uint32, err error) { + if err := ip.AddressTo4(); err != nil { + return 0, err + } + csum += (uint32(ip.SrcIP[0]) + uint32(ip.SrcIP[2])) << 8 + csum += uint32(ip.SrcIP[1]) + uint32(ip.SrcIP[3]) + csum += (uint32(ip.DstIP[0]) + uint32(ip.DstIP[2])) << 8 + csum += uint32(ip.DstIP[1]) + uint32(ip.DstIP[3]) + return csum, nil +} + +func (ip *IPv6) pseudoheaderChecksum() (csum uint32, err error) { + if err := ip.AddressTo16(); err != nil { + return 0, err + } + for i := 0; i < 16; i += 2 { + csum += uint32(ip.SrcIP[i]) << 8 + csum += uint32(ip.SrcIP[i+1]) + csum += uint32(ip.DstIP[i]) << 8 + csum += uint32(ip.DstIP[i+1]) + } + return csum, nil +} + +// Calculate the TCP/IP checksum defined in rfc1071. The passed-in csum is any +// initial checksum data that's already been computed. +func tcpipChecksum(data []byte, csum uint32) uint16 { + // to handle odd lengths, we loop to length - 1, incrementing by 2, then + // handle the last byte specifically by checking against the original + // length. + length := len(data) - 1 + for i := 0; i < length; i += 2 { + // For our test packet, doing this manually is about 25% faster + // (740 ns vs. 1000ns) than doing it by calling binary.BigEndian.Uint16. + csum += uint32(data[i]) << 8 + csum += uint32(data[i+1]) + } + if len(data)%2 == 1 { + csum += uint32(data[length]) << 8 + } + for csum > 0xffff { + csum = (csum >> 16) + (csum & 0xffff) + } + return ^uint16(csum) +} + +// computeChecksum computes a TCP or UDP checksum. headerAndPayload is the +// serialized TCP or UDP header plus its payload, with the checksum zero'd +// out. headerProtocol is the IP protocol number of the upper-layer header. +func (c *tcpipchecksum) computeChecksum(headerAndPayload []byte, headerProtocol IPProtocol) (uint16, error) { + if c.pseudoheader == nil { + return 0, errors.New("TCP/IP layer 4 checksum cannot be computed without network layer... call SetNetworkLayerForChecksum to set which layer to use") + } + length := uint32(len(headerAndPayload)) + csum, err := c.pseudoheader.pseudoheaderChecksum() + if err != nil { + return 0, err + } + csum += uint32(headerProtocol) + csum += length & 0xffff + csum += length >> 16 + return tcpipChecksum(headerAndPayload, csum), nil +} + +// SetNetworkLayerForChecksum tells this layer which network layer is wrapping it. +// This is needed for computing the checksum when serializing, since TCP/IP transport +// layer checksums depends on fields in the IPv4 or IPv6 layer that contains it. +// The passed in layer must be an *IPv4 or *IPv6. +func (i *tcpipchecksum) SetNetworkLayerForChecksum(l gopacket.NetworkLayer) error { + switch v := l.(type) { + case *IPv4: + i.pseudoheader = v + case *IPv6: + i.pseudoheader = v + default: + return fmt.Errorf("cannot use layer type %v for tcp checksum network layer", l.LayerType()) + } + return nil +} diff --git a/vendor/github.com/google/gopacket/layers/test_creator.py b/vendor/github.com/google/gopacket/layers/test_creator.py new file mode 100755 index 0000000..c92d276 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/test_creator.py @@ -0,0 +1,103 @@ +#!/usr/bin/python +# Copyright 2012 Google, Inc. All rights reserved. + +"""TestCreator creates test templates from pcap files.""" + +import argparse +import base64 +import glob +import re +import string +import subprocess +import sys + + +class Packet(object): + """Helper class encapsulating packet from a pcap file.""" + + def __init__(self, packet_lines): + self.packet_lines = packet_lines + self.data = self._DecodeText(packet_lines) + + @classmethod + def _DecodeText(cls, packet_lines): + packet_bytes = [] + # First line is timestamp and stuff, skip it. + # Format: 0x0010: 0000 0020 3aff 3ffe 0000 0000 0000 0000 ....:.?......... + + for line in packet_lines[1:]: + m = re.match(r'\s+0x[a-f\d]+:\s+((?:[\da-f]{2,4}\s)*)', line, re.IGNORECASE) + if m is None: continue + for hexpart in m.group(1).split(): + packet_bytes.append(base64.b16decode(hexpart.upper())) + return ''.join(packet_bytes) + + def Test(self, name, link_type): + """Yields a test using this packet, as a set of lines.""" + yield '// testPacket%s is the packet:' % name + for line in self.packet_lines: + yield '// ' + line + yield 'var testPacket%s = []byte{' % name + data = list(self.data) + while data: + linebytes, data = data[:16], data[16:] + yield ''.join(['\t'] + ['0x%02x, ' % ord(c) for c in linebytes]) + yield '}' + yield 'func TestPacket%s(t *testing.T) {' % name + yield '\tp := gopacket.NewPacket(testPacket%s, LinkType%s, gopacket.Default)' % (name, link_type) + yield '\tif p.ErrorLayer() != nil {' + yield '\t\tt.Error("Failed to decode packet:", p.ErrorLayer().Error())' + yield '\t}' + yield '\tcheckLayers(p, []gopacket.LayerType{LayerType%s, FILL_ME_IN_WITH_ACTUAL_LAYERS}, t)' % link_type + yield '}' + yield 'func BenchmarkDecodePacket%s(b *testing.B) {' % name + yield '\tfor i := 0; i < b.N; i++ {' + yield '\t\tgopacket.NewPacket(testPacket%s, LinkType%s, gopacket.NoCopy)' % (name, link_type) + yield '\t}' + yield '}' + + + +def GetTcpdumpOutput(filename): + """Runs tcpdump on the given file, returning output as string.""" + return subprocess.check_output( + ['tcpdump', '-XX', '-s', '0', '-n', '-r', filename]) + + +def TcpdumpOutputToPackets(output): + """Reads a pcap file with TCPDump, yielding Packet objects.""" + pdata = [] + for line in output.splitlines(): + if line[0] not in string.whitespace and pdata: + yield Packet(pdata) + pdata = [] + pdata.append(line) + if pdata: + yield Packet(pdata) + + +def main(): + class CustomHelpFormatter(argparse.ArgumentDefaultsHelpFormatter): + def _format_usage(self, usage, actions, groups, prefix=None): + header =('TestCreator creates gopacket tests using a pcap file.\n\n' + 'Tests are written to standard out... they can then be \n' + 'copied into the file of your choice and modified as \n' + 'you see.\n\n') + return header + argparse.ArgumentDefaultsHelpFormatter._format_usage( + self, usage, actions, groups, prefix) + + parser = argparse.ArgumentParser(formatter_class=CustomHelpFormatter) + parser.add_argument('--link_type', default='Ethernet', help='the link type (default: %(default)s)') + parser.add_argument('--name', default='Packet%d', help='the layer type, must have "%d" inside it') + parser.add_argument('files', metavar='file.pcap', type=str, nargs='+', help='the files to process') + + args = parser.parse_args() + + for arg in args.files: + for path in glob.glob(arg): + for i, packet in enumerate(TcpdumpOutputToPackets(GetTcpdumpOutput(path))): + print '\n'.join(packet.Test( + args.name % i, args.link_type)) + +if __name__ == '__main__': + main() diff --git a/vendor/github.com/google/gopacket/layers/udp.go b/vendor/github.com/google/gopacket/layers/udp.go new file mode 100644 index 0000000..20f8c50 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/udp.go @@ -0,0 +1,120 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "fmt" + "github.com/google/gopacket" +) + +// UDP is the layer for UDP headers. +type UDP struct { + BaseLayer + SrcPort, DstPort UDPPort + Length uint16 + Checksum uint16 + sPort, dPort []byte + tcpipchecksum +} + +// LayerType returns gopacket.LayerTypeUDP +func (u *UDP) LayerType() gopacket.LayerType { return LayerTypeUDP } + +func (udp *UDP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + udp.SrcPort = UDPPort(binary.BigEndian.Uint16(data[0:2])) + udp.sPort = data[0:2] + udp.DstPort = UDPPort(binary.BigEndian.Uint16(data[2:4])) + udp.dPort = data[2:4] + udp.Length = binary.BigEndian.Uint16(data[4:6]) + udp.Checksum = binary.BigEndian.Uint16(data[6:8]) + udp.BaseLayer = BaseLayer{Contents: data[:8]} + switch { + case udp.Length >= 8: + hlen := int(udp.Length) + if hlen > len(data) { + df.SetTruncated() + hlen = len(data) + } + udp.Payload = data[8:hlen] + case udp.Length == 0: // Jumbogram, use entire rest of data + udp.Payload = data[8:] + default: + return fmt.Errorf("UDP packet too small: %d bytes", udp.Length) + } + return nil +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (u *UDP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + var jumbo bool + + payload := b.Bytes() + if _, ok := u.pseudoheader.(*IPv6); ok { + if len(payload)+8 > 65535 { + jumbo = true + } + } + bytes, err := b.PrependBytes(8) + if err != nil { + return err + } + binary.BigEndian.PutUint16(bytes, uint16(u.SrcPort)) + binary.BigEndian.PutUint16(bytes[2:], uint16(u.DstPort)) + if opts.FixLengths { + if jumbo { + u.Length = 0 + } else { + u.Length = uint16(len(payload)) + 8 + } + } + binary.BigEndian.PutUint16(bytes[4:], u.Length) + if opts.ComputeChecksums { + // zero out checksum bytes + bytes[6] = 0 + bytes[7] = 0 + csum, err := u.computeChecksum(b.Bytes(), IPProtocolUDP) + if err != nil { + return err + } + u.Checksum = csum + } + binary.BigEndian.PutUint16(bytes[6:], u.Checksum) + return nil +} + +func (u *UDP) CanDecode() gopacket.LayerClass { + return LayerTypeUDP +} + +// NextLayerType use the destination port to select the +// right next decoder. It tries first to decode via the +// destination port, then the source port. +func (u *UDP) NextLayerType() gopacket.LayerType { + if lt := u.DstPort.LayerType(); lt != gopacket.LayerTypePayload { + return lt + } + return u.SrcPort.LayerType() +} + +func decodeUDP(data []byte, p gopacket.PacketBuilder) error { + udp := &UDP{} + err := udp.DecodeFromBytes(data, p) + p.AddLayer(udp) + p.SetTransportLayer(udp) + if err != nil { + return err + } + return p.NextDecoder(udp.NextLayerType()) +} + +func (u *UDP) TransportFlow() gopacket.Flow { + return gopacket.NewFlow(EndpointUDPPort, u.sPort, u.dPort) +} diff --git a/vendor/github.com/google/gopacket/layers/udplite.go b/vendor/github.com/google/gopacket/layers/udplite.go new file mode 100644 index 0000000..7d84c51 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/udplite.go @@ -0,0 +1,44 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// Copyright 2009-2011 Andreas Krennmair. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "github.com/google/gopacket" +) + +// UDPLite is the layer for UDP-Lite headers (rfc 3828). +type UDPLite struct { + BaseLayer + SrcPort, DstPort UDPLitePort + ChecksumCoverage uint16 + Checksum uint16 + sPort, dPort []byte +} + +// LayerType returns gopacket.LayerTypeUDPLite +func (u *UDPLite) LayerType() gopacket.LayerType { return LayerTypeUDPLite } + +func decodeUDPLite(data []byte, p gopacket.PacketBuilder) error { + udp := &UDPLite{ + SrcPort: UDPLitePort(binary.BigEndian.Uint16(data[0:2])), + sPort: data[0:2], + DstPort: UDPLitePort(binary.BigEndian.Uint16(data[2:4])), + dPort: data[2:4], + ChecksumCoverage: binary.BigEndian.Uint16(data[4:6]), + Checksum: binary.BigEndian.Uint16(data[6:8]), + BaseLayer: BaseLayer{data[:8], data[8:]}, + } + p.AddLayer(udp) + p.SetTransportLayer(udp) + return p.NextDecoder(gopacket.LayerTypePayload) +} + +func (u *UDPLite) TransportFlow() gopacket.Flow { + return gopacket.NewFlow(EndpointUDPLitePort, u.sPort, u.dPort) +} diff --git a/vendor/github.com/google/gopacket/layers/usb.go b/vendor/github.com/google/gopacket/layers/usb.go new file mode 100644 index 0000000..d4f483c --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/usb.go @@ -0,0 +1,308 @@ +// Copyright 2014 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "github.com/google/gopacket" +) + +type USBEventType uint8 + +const ( + USBEventTypeSubmit USBEventType = 'S' + USBEventTypeComplete USBEventType = 'C' + USBEventTypeError USBEventType = 'E' +) + +func (a USBEventType) String() string { + switch a { + case USBEventTypeSubmit: + return "SUBMIT" + case USBEventTypeComplete: + return "COMPLETE" + case USBEventTypeError: + return "ERROR" + default: + return "Unknown event type" + } +} + +type USBRequestBlockSetupRequest uint8 + +const ( + USBRequestBlockSetupRequestGetStatus USBRequestBlockSetupRequest = 0x00 + USBRequestBlockSetupRequestClearFeature USBRequestBlockSetupRequest = 0x01 + USBRequestBlockSetupRequestSetFeature USBRequestBlockSetupRequest = 0x03 + USBRequestBlockSetupRequestSetAddress USBRequestBlockSetupRequest = 0x05 + USBRequestBlockSetupRequestGetDescriptor USBRequestBlockSetupRequest = 0x06 + USBRequestBlockSetupRequestSetDescriptor USBRequestBlockSetupRequest = 0x07 + USBRequestBlockSetupRequestGetConfiguration USBRequestBlockSetupRequest = 0x08 + USBRequestBlockSetupRequestSetConfiguration USBRequestBlockSetupRequest = 0x09 + USBRequestBlockSetupRequestSetIdle USBRequestBlockSetupRequest = 0x0a +) + +func (a USBRequestBlockSetupRequest) String() string { + switch a { + case USBRequestBlockSetupRequestGetStatus: + return "GET_STATUS" + case USBRequestBlockSetupRequestClearFeature: + return "CLEAR_FEATURE" + case USBRequestBlockSetupRequestSetFeature: + return "SET_FEATURE" + case USBRequestBlockSetupRequestSetAddress: + return "SET_ADDRESS" + case USBRequestBlockSetupRequestGetDescriptor: + return "GET_DESCRIPTOR" + case USBRequestBlockSetupRequestSetDescriptor: + return "SET_DESCRIPTOR" + case USBRequestBlockSetupRequestGetConfiguration: + return "GET_CONFIGURATION" + case USBRequestBlockSetupRequestSetConfiguration: + return "SET_CONFIGURATION" + case USBRequestBlockSetupRequestSetIdle: + return "SET_IDLE" + default: + return "UNKNOWN" + } +} + +type USBTransportType uint8 + +const ( + USBTransportTypeTransferIn USBTransportType = 0x80 // Indicates send or receive + USBTransportTypeIsochronous USBTransportType = 0x00 // Isochronous transfers occur continuously and periodically. They typically contain time sensitive information, such as an audio or video stream. + USBTransportTypeInterrupt USBTransportType = 0x01 // Interrupt transfers are typically non-periodic, small device "initiated" communication requiring bounded latency, such as pointing devices or keyboards. + USBTransportTypeControl USBTransportType = 0x02 // Control transfers are typically used for command and status operations. + USBTransportTypeBulk USBTransportType = 0x03 // Bulk transfers can be used for large bursty data, using all remaining available bandwidth, no guarantees on bandwidth or latency, such as file transfers. +) + +func (a USBTransportType) LayerType() gopacket.LayerType { + return USBTypeMetadata[a].LayerType +} + +func (a USBTransportType) String() string { + switch a { + case USBTransportTypeTransferIn: + return "Transfer In" + case USBTransportTypeIsochronous: + return "Isochronous" + case USBTransportTypeInterrupt: + return "Interrupt" + case USBTransportTypeControl: + return "Control" + case USBTransportTypeBulk: + return "Bulk" + default: + return "Unknown transport type" + } +} + +type USBDirectionType uint8 + +const ( + USBDirectionTypeUnknown USBDirectionType = iota + USBDirectionTypeIn + USBDirectionTypeOut +) + +func (a USBDirectionType) String() string { + switch a { + case USBDirectionTypeIn: + return "In" + case USBDirectionTypeOut: + return "Out" + default: + return "Unknown direction type" + } +} + +// The reference at http://www.beyondlogic.org/usbnutshell/usb1.shtml contains more information about the protocol. +type USB struct { + BaseLayer + ID uint64 + EventType USBEventType + TransferType USBTransportType + Direction USBDirectionType + EndpointNumber uint8 + DeviceAddress uint8 + BusID uint16 + TimestampSec int64 + TimestampUsec int32 + Setup bool + Data bool + Status int32 + UrbLength uint32 + UrbDataLength uint32 + + UrbInterval uint32 + UrbStartFrame uint32 + UrbCopyOfTransferFlags uint32 + IsoNumDesc uint32 +} + +func (u *USB) LayerType() gopacket.LayerType { return LayerTypeUSB } + +func (m *USB) NextLayerType() gopacket.LayerType { + if m.Setup { + return LayerTypeUSBRequestBlockSetup + } else if m.Data { + } + + return m.TransferType.LayerType() +} + +func decodeUSB(data []byte, p gopacket.PacketBuilder) error { + d := &USB{} + + return decodingLayerDecoder(d, data, p) +} + +func (m *USB) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + m.ID = binary.LittleEndian.Uint64(data[0:8]) + m.EventType = USBEventType(data[8]) + m.TransferType = USBTransportType(data[9]) + + m.EndpointNumber = data[10] & 0x7f + if data[10]&uint8(USBTransportTypeTransferIn) > 0 { + m.Direction = USBDirectionTypeIn + } else { + m.Direction = USBDirectionTypeOut + } + + m.DeviceAddress = data[11] + m.BusID = binary.LittleEndian.Uint16(data[12:14]) + + if uint(data[14]) == 0 { + m.Setup = true + } + + if uint(data[15]) == 0 { + m.Data = true + } + + m.TimestampSec = int64(binary.LittleEndian.Uint64(data[16:24])) + m.TimestampUsec = int32(binary.LittleEndian.Uint32(data[24:28])) + m.Status = int32(binary.LittleEndian.Uint32(data[28:32])) + m.UrbLength = binary.LittleEndian.Uint32(data[32:36]) + m.UrbDataLength = binary.LittleEndian.Uint32(data[36:40]) + + m.Contents = data[:40] + m.Payload = data[40:] + + if m.Setup { + m.Payload = data[40:] + } else if m.Data { + m.Payload = data[uint32(len(data))-m.UrbDataLength:] + } + + // if 64 bit, dissect_linux_usb_pseudo_header_ext + if false { + m.UrbInterval = binary.LittleEndian.Uint32(data[40:44]) + m.UrbStartFrame = binary.LittleEndian.Uint32(data[44:48]) + m.UrbDataLength = binary.LittleEndian.Uint32(data[48:52]) + m.IsoNumDesc = binary.LittleEndian.Uint32(data[52:56]) + m.Contents = data[:56] + m.Payload = data[56:] + } + + // crc5 or crc16 + // eop (end of packet) + + return nil +} + +type USBRequestBlockSetup struct { + BaseLayer + RequestType uint8 + Request USBRequestBlockSetupRequest + Value uint16 + Index uint16 + Length uint16 +} + +func (u *USBRequestBlockSetup) LayerType() gopacket.LayerType { return LayerTypeUSBRequestBlockSetup } + +func (m *USBRequestBlockSetup) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +func (m *USBRequestBlockSetup) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + m.RequestType = data[0] + m.Request = USBRequestBlockSetupRequest(data[1]) + m.Value = binary.LittleEndian.Uint16(data[2:4]) + m.Index = binary.LittleEndian.Uint16(data[4:6]) + m.Length = binary.LittleEndian.Uint16(data[6:8]) + m.Contents = data[:8] + m.Payload = data[8:] + return nil +} + +func decodeUSBRequestBlockSetup(data []byte, p gopacket.PacketBuilder) error { + d := &USBRequestBlockSetup{} + return decodingLayerDecoder(d, data, p) +} + +type USBControl struct { + BaseLayer +} + +func (u *USBControl) LayerType() gopacket.LayerType { return LayerTypeUSBControl } + +func (m *USBControl) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +func (m *USBControl) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + m.Contents = data + return nil +} + +func decodeUSBControl(data []byte, p gopacket.PacketBuilder) error { + d := &USBControl{} + return decodingLayerDecoder(d, data, p) +} + +type USBInterrupt struct { + BaseLayer +} + +func (u *USBInterrupt) LayerType() gopacket.LayerType { return LayerTypeUSBInterrupt } + +func (m *USBInterrupt) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +func (m *USBInterrupt) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + m.Contents = data + return nil +} + +func decodeUSBInterrupt(data []byte, p gopacket.PacketBuilder) error { + d := &USBInterrupt{} + return decodingLayerDecoder(d, data, p) +} + +type USBBulk struct { + BaseLayer +} + +func (u *USBBulk) LayerType() gopacket.LayerType { return LayerTypeUSBBulk } + +func (m *USBBulk) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +func (m *USBBulk) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + m.Contents = data + return nil +} + +func decodeUSBBulk(data []byte, p gopacket.PacketBuilder) error { + d := &USBBulk{} + return decodingLayerDecoder(d, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/vrrp.go b/vendor/github.com/google/gopacket/layers/vrrp.go new file mode 100644 index 0000000..ffaafe6 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/vrrp.go @@ -0,0 +1,156 @@ +// Copyright 2016 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "errors" + "net" + + "github.com/google/gopacket" +) + +/* + This layer provides decoding for Virtual Router Redundancy Protocol (VRRP) v2. + https://tools.ietf.org/html/rfc3768#section-5 + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |Version| Type | Virtual Rtr ID| Priority | Count IP Addrs| + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Auth Type | Adver Int | Checksum | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | IP Address (1) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | . | + | . | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | IP Address (n) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Authentication Data (1) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Authentication Data (2) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +*/ + +type VRRPv2Type uint8 +type VRRPv2AuthType uint8 + +const ( + VRRPv2Advertisement VRRPv2Type = 0x01 // router advertisement +) + +// String conversions for VRRP message types +func (v VRRPv2Type) String() string { + switch v { + case VRRPv2Advertisement: + return "VRRPv2 Advertisement" + default: + return "" + } +} + +const ( + VRRPv2AuthNoAuth VRRPv2AuthType = 0x00 // No Authentication + VRRPv2AuthReserved1 VRRPv2AuthType = 0x01 // Reserved field 1 + VRRPv2AuthReserved2 VRRPv2AuthType = 0x02 // Reserved field 2 +) + +func (v VRRPv2AuthType) String() string { + switch v { + case VRRPv2AuthNoAuth: + return "No Authentication" + case VRRPv2AuthReserved1: + return "Reserved" + case VRRPv2AuthReserved2: + return "Reserved" + default: + return "" + } +} + +// VRRPv2 represents an VRRP v2 message. +type VRRPv2 struct { + BaseLayer + Version uint8 // The version field specifies the VRRP protocol version of this packet (v2) + Type VRRPv2Type // The type field specifies the type of this VRRP packet. The only type defined in v2 is ADVERTISEMENT + VirtualRtrID uint8 // identifies the virtual router this packet is reporting status for + Priority uint8 // specifies the sending VRRP router's priority for the virtual router (100 = default) + CountIPAddr uint8 // The number of IP addresses contained in this VRRP advertisement. + AuthType VRRPv2AuthType // identifies the authentication method being utilized + AdverInt uint8 // The Advertisement interval indicates the time interval (in seconds) between ADVERTISEMENTS. The default is 1 second + Checksum uint16 // used to detect data corruption in the VRRP message. + IPAddress []net.IP // one or more IP addresses associated with the virtual router. Specified in the CountIPAddr field. +} + +// LayerType returns LayerTypeVRRP for VRRP v2 message. +func (v *VRRPv2) LayerType() gopacket.LayerType { return LayerTypeVRRP } + +func (v *VRRPv2) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + + v.BaseLayer = BaseLayer{Contents: data[:len(data)]} + v.Version = data[0] >> 4 // high nibble == VRRP version. We're expecting v2 + + v.Type = VRRPv2Type(data[0] & 0x0F) // low nibble == VRRP type. Expecting 1 (advertisement) + if v.Type != 1 { + // rfc3768: A packet with unknown type MUST be discarded. + return errors.New("Unrecognized VRRPv2 type field.") + } + + v.VirtualRtrID = data[1] + v.Priority = data[2] + + v.CountIPAddr = data[3] + if v.CountIPAddr < 1 { + return errors.New("VRRPv2 number of IP addresses is not valid.") + } + + v.AuthType = VRRPv2AuthType(data[4]) + v.AdverInt = uint8(data[5]) + v.Checksum = binary.BigEndian.Uint16(data[6:8]) + + // populate the IPAddress field. The number of addresses is specified in the v.CountIPAddr field + // offset references the starting byte containing the list of ip addresses + offset := 8 + for i := uint8(0); i < v.CountIPAddr; i++ { + v.IPAddress = append(v.IPAddress, data[offset:offset+4]) + offset += 4 + } + + // any trailing packets here may be authentication data and *should* be ignored in v2 as per RFC + // + // 5.3.10. Authentication Data + // + // The authentication string is currently only used to maintain + // backwards compatibility with RFC 2338. It SHOULD be set to zero on + // transmission and ignored on reception. + return nil +} + +// CanDecode specifies the layer type in which we are attempting to unwrap. +func (v *VRRPv2) CanDecode() gopacket.LayerClass { + return LayerTypeVRRP +} + +// NextLayerType specifies the next layer that should be decoded. VRRP does not contain any further payload, so we set to 0 +func (v *VRRPv2) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypeZero +} + +// The VRRP packet does not include payload data. Setting byte slice to nil +func (v *VRRPv2) Payload() []byte { + return nil +} + +// decodeVRRP will parse VRRP v2 +func decodeVRRP(data []byte, p gopacket.PacketBuilder) error { + if len(data) < 8 { + return errors.New("Not a valid VRRP packet. Packet length is too small.") + } + v := &VRRPv2{} + return decodingLayerDecoder(v, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/vxlan.go b/vendor/github.com/google/gopacket/layers/vxlan.go new file mode 100644 index 0000000..08f1ecb --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/vxlan.go @@ -0,0 +1,94 @@ +// Copyright 2016 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package layers + +import ( + "encoding/binary" + "fmt" + "github.com/google/gopacket" +) + +// VXLAN is specifed in RFC 7348 https://tools.ietf.org/html/rfc7348 +// G, D, A, Group Policy ID from https://tools.ietf.org/html/draft-smith-vxlan-group-policy-00 +// 0 1 2 3 +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// 0 8 16 24 32 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// |G|R|R|R|I|R|R|R|R|D|R|R|A|R|R|R| Group Policy ID | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | 24 bit VXLAN Network Identifier | Reserved | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +// VXLAN is a VXLAN packet header +type VXLAN struct { + BaseLayer + ValidIDFlag bool // 'I' bit per RFC 7348 + VNI uint32 // 'VXLAN Network Identifier' 24 bits per RFC 7348 + GBPExtension bool // 'G' bit per Group Policy https://tools.ietf.org/html/draft-smith-vxlan-group-policy-00 + GBPDontLearn bool // 'D' bit per Group Policy + GBPApplied bool // 'A' bit per Group Policy + GBPGroupPolicyID uint16 // 'Group Policy ID' 16 bits per Group Policy +} + +// LayerType returns LayerTypeVXLAN +func (vx *VXLAN) LayerType() gopacket.LayerType { return LayerTypeVXLAN } + +func decodeVXLAN(data []byte, p gopacket.PacketBuilder) error { + vx := &VXLAN{} + + // VNI is a 24bit number, Uint32 requires 32 bits + var buf [4]byte + copy(buf[1:], data[4:7]) + + // RFC 7348 https://tools.ietf.org/html/rfc7348 + vx.ValidIDFlag = data[0]&0x08 > 0 // 'I' bit per RFC7348 + vx.VNI = binary.BigEndian.Uint32(buf[:]) // VXLAN Network Identifier per RFC7348 + + // Group Based Policy https://tools.ietf.org/html/draft-smith-vxlan-group-policy-00 + vx.GBPExtension = data[0]&0x80 > 0 // 'G' bit per the group policy draft + vx.GBPDontLearn = data[1]&0x40 > 0 // 'D' bit - the egress VTEP MUST NOT learn the source address of the encapsulated frame. + vx.GBPApplied = data[1]&0x80 > 0 // 'A' bit - indicates that the group policy has already been applied to this packet. + vx.GBPGroupPolicyID = binary.BigEndian.Uint16(data[2:4]) // Policy ID as per the group policy draft + + // Layer information + const vxlanLength = 8 + vx.Contents = data[:vxlanLength] + vx.Payload = data[vxlanLength:] + + p.AddLayer(vx) + return p.NextDecoder(LinkTypeEthernet) +} + +// SerializeTo writes the serialized form of this layer into the +// SerializationBuffer, implementing gopacket.SerializableLayer. +// See the docs for gopacket.SerializableLayer for more info. +func (vx *VXLAN) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + bytes, err := b.PrependBytes(8) + if err != nil { + return err + } + + if vx.ValidIDFlag { + bytes[0] |= 0x08 + } + if vx.GBPExtension { + bytes[0] |= 0x80 + } + if vx.GBPDontLearn { + bytes[1] |= 0x40 + } + if vx.GBPApplied { + bytes[1] |= 0x80 + } + + binary.BigEndian.PutUint16(bytes[2:4], vx.GBPGroupPolicyID) + if vx.VNI >= 1<<24 { + return fmt.Errorf("Virtual Network Identifier = %x exceeds max for 24-bit uint", vx.VNI) + } + binary.BigEndian.PutUint32(bytes[4:8], vx.VNI<<8) + return nil +} diff --git a/vendor/github.com/google/gopacket/layertype.go b/vendor/github.com/google/gopacket/layertype.go new file mode 100644 index 0000000..3abfee1 --- /dev/null +++ b/vendor/github.com/google/gopacket/layertype.go @@ -0,0 +1,111 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package gopacket + +import ( + "fmt" + "strconv" +) + +// LayerType is a unique identifier for each type of layer. This enumeration +// does not match with any externally available numbering scheme... it's solely +// usable/useful within this library as a means for requesting layer types +// (see Packet.Layer) and determining which types of layers have been decoded. +// +// New LayerTypes may be created by calling gopacket.RegisterLayerType. +type LayerType int64 + +// LayerTypeMetadata contains metadata associated with each LayerType. +type LayerTypeMetadata struct { + // Name is the string returned by each layer type's String method. + Name string + // Decoder is the decoder to use when the layer type is passed in as a + // Decoder. + Decoder Decoder +} + +type layerTypeMetadata struct { + inUse bool + LayerTypeMetadata +} + +// DecodersByLayerName maps layer names to decoders for those layers. +// This allows users to specify decoders by name to a program and have that +// program pick the correct decoder accordingly. +var DecodersByLayerName = map[string]Decoder{} + +const maxLayerType = 2000 + +var ltMeta [maxLayerType]layerTypeMetadata +var ltMetaMap = map[LayerType]layerTypeMetadata{} + +// RegisterLayerType creates a new layer type and registers it globally. +// The number passed in must be unique, or a runtime panic will occur. Numbers +// 0-999 are reserved for the gopacket library. Numbers 1000-1999 should be +// used for common application-specific types, and are very fast. Any other +// number (negative or >= 2000) may be used for uncommon application-specific +// types, and are somewhat slower (they require a map lookup over an array +// index). +func RegisterLayerType(num int, meta LayerTypeMetadata) LayerType { + if 0 <= num && num < maxLayerType { + if ltMeta[num].inUse { + panic("Layer type already exists") + } + } else { + if ltMetaMap[LayerType(num)].inUse { + panic("Layer type already exists") + } + } + return OverrideLayerType(num, meta) +} + +// OverrideLayerType acts like RegisterLayerType, except that if the layer type +// has already been registered, it overrides the metadata with the passed-in +// metadata intead of panicing. +func OverrideLayerType(num int, meta LayerTypeMetadata) LayerType { + if 0 <= num && num < maxLayerType { + ltMeta[num] = layerTypeMetadata{ + inUse: true, + LayerTypeMetadata: meta, + } + } else { + ltMetaMap[LayerType(num)] = layerTypeMetadata{ + inUse: true, + LayerTypeMetadata: meta, + } + } + DecodersByLayerName[meta.Name] = meta.Decoder + return LayerType(num) +} + +// Decode decodes the given data using the decoder registered with the layer +// type. +func (t LayerType) Decode(data []byte, c PacketBuilder) error { + var d Decoder + if 0 <= int(t) && int(t) < maxLayerType { + d = ltMeta[int(t)].Decoder + } else { + d = ltMetaMap[t].Decoder + } + if d != nil { + return d.Decode(data, c) + } + return fmt.Errorf("Layer type %v has no associated decoder", t) +} + +// String returns the string associated with this layer type. +func (t LayerType) String() (s string) { + if 0 <= int(t) && int(t) < maxLayerType { + s = ltMeta[int(t)].Name + } else { + s = ltMetaMap[t].Name + } + if s == "" { + s = strconv.Itoa(int(t)) + } + return +} diff --git a/vendor/github.com/google/gopacket/packet.go b/vendor/github.com/google/gopacket/packet.go new file mode 100644 index 0000000..76b62d8 --- /dev/null +++ b/vendor/github.com/google/gopacket/packet.go @@ -0,0 +1,838 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package gopacket + +import ( + "bytes" + "encoding/hex" + "errors" + "fmt" + "io" + "os" + "reflect" + "runtime/debug" + "strings" + "time" +) + +// CaptureInfo provides standardized information about a packet captured off +// the wire or read from a file. +type CaptureInfo struct { + // Timestamp is the time the packet was captured, if that is known. + Timestamp time.Time + // CaptureLength is the total number of bytes read off of the wire. + CaptureLength int + // Length is the size of the original packet. Should always be >= + // CaptureLength. + Length int + // InterfaceIndex + InterfaceIndex int +} + +// PacketMetadata contains metadata for a packet. +type PacketMetadata struct { + CaptureInfo + // Truncated is true if packet decoding logic detects that there are fewer + // bytes in the packet than are detailed in various headers (for example, if + // the number of bytes in the IPv4 contents/payload is less than IPv4.Length). + // This is also set automatically for packets captured off the wire if + // CaptureInfo.CaptureLength < CaptureInfo.Length. + Truncated bool +} + +// Packet is the primary object used by gopacket. Packets are created by a +// Decoder's Decode call. A packet is made up of a set of Data, which +// is broken into a number of Layers as it is decoded. +type Packet interface { + //// Functions for outputting the packet as a human-readable string: + //// ------------------------------------------------------------------ + // String returns a human-readable string representation of the packet. + // It uses LayerString on each layer to output the layer. + String() string + // Dump returns a verbose human-readable string representation of the packet, + // including a hex dump of all layers. It uses LayerDump on each layer to + // output the layer. + Dump() string + + //// Functions for accessing arbitrary packet layers: + //// ------------------------------------------------------------------ + // Layers returns all layers in this packet, computing them as necessary + Layers() []Layer + // Layer returns the first layer in this packet of the given type, or nil + Layer(LayerType) Layer + // LayerClass returns the first layer in this packet of the given class, + // or nil. + LayerClass(LayerClass) Layer + + //// Functions for accessing specific types of packet layers. These functions + //// return the first layer of each type found within the packet. + //// ------------------------------------------------------------------ + // LinkLayer returns the first link layer in the packet + LinkLayer() LinkLayer + // NetworkLayer returns the first network layer in the packet + NetworkLayer() NetworkLayer + // TransportLayer returns the first transport layer in the packet + TransportLayer() TransportLayer + // ApplicationLayer returns the first application layer in the packet + ApplicationLayer() ApplicationLayer + // ErrorLayer is particularly useful, since it returns nil if the packet + // was fully decoded successfully, and non-nil if an error was encountered + // in decoding and the packet was only partially decoded. Thus, its output + // can be used to determine if the entire packet was able to be decoded. + ErrorLayer() ErrorLayer + + //// Functions for accessing data specific to the packet: + //// ------------------------------------------------------------------ + // Data returns the set of bytes that make up this entire packet. + Data() []byte + // Metadata returns packet metadata associated with this packet. + Metadata() *PacketMetadata +} + +// packet contains all the information we need to fulfill the Packet interface, +// and its two "subclasses" (yes, no such thing in Go, bear with me), +// eagerPacket and lazyPacket, provide eager and lazy decoding logic around the +// various functions needed to access this information. +type packet struct { + // data contains the entire packet data for a packet + data []byte + // initialLayers is space for an initial set of layers already created inside + // the packet. + initialLayers [6]Layer + // layers contains each layer we've already decoded + layers []Layer + // last is the last layer added to the packet + last Layer + // metadata is the PacketMetadata for this packet + metadata PacketMetadata + + decodeOptions DecodeOptions + + // Pointers to the various important layers + link LinkLayer + network NetworkLayer + transport TransportLayer + application ApplicationLayer + failure ErrorLayer +} + +func (p *packet) SetTruncated() { + p.metadata.Truncated = true +} + +func (p *packet) SetLinkLayer(l LinkLayer) { + if p.link == nil { + p.link = l + } +} + +func (p *packet) SetNetworkLayer(l NetworkLayer) { + if p.network == nil { + p.network = l + } +} + +func (p *packet) SetTransportLayer(l TransportLayer) { + if p.transport == nil { + p.transport = l + } +} + +func (p *packet) SetApplicationLayer(l ApplicationLayer) { + if p.application == nil { + p.application = l + } +} + +func (p *packet) SetErrorLayer(l ErrorLayer) { + if p.failure == nil { + p.failure = l + } +} + +func (p *packet) AddLayer(l Layer) { + p.layers = append(p.layers, l) + p.last = l +} + +func (p *packet) DumpPacketData() { + fmt.Fprint(os.Stderr, p.packetDump()) + os.Stderr.Sync() +} + +func (p *packet) Metadata() *PacketMetadata { + return &p.metadata +} + +func (p *packet) Data() []byte { + return p.data +} + +func (p *packet) DecodeOptions() *DecodeOptions { + return &p.decodeOptions +} + +func (p *packet) addFinalDecodeError(err error, stack []byte) { + fail := &DecodeFailure{err: err, stack: stack} + if p.last == nil { + fail.data = p.data + } else { + fail.data = p.last.LayerPayload() + } + p.AddLayer(fail) + p.SetErrorLayer(fail) +} + +func (p *packet) recoverDecodeError() { + if !p.decodeOptions.SkipDecodeRecovery { + if r := recover(); r != nil { + p.addFinalDecodeError(fmt.Errorf("%v", r), debug.Stack()) + } + } +} + +// LayerString outputs an individual layer as a string. The layer is output +// in a single line, with no trailing newline. This function is specifically +// designed to do the right thing for most layers... it follows the following +// rules: +// * If the Layer has a String function, just output that. +// * Otherwise, output all exported fields in the layer, recursing into +// exported slices and structs. +// NOTE: This is NOT THE SAME AS fmt's "%#v". %#v will output both exported +// and unexported fields... many times packet layers contain unexported stuff +// that would just mess up the output of the layer, see for example the +// Payload layer and it's internal 'data' field, which contains a large byte +// array that would really mess up formatting. +func LayerString(l Layer) string { + return fmt.Sprintf("%v\t%s", l.LayerType(), layerString(reflect.ValueOf(l), false, false)) +} + +// Dumper dumps verbose information on a value. If a layer type implements +// Dumper, then its LayerDump() string will include the results in its output. +type Dumper interface { + Dump() string +} + +// LayerDump outputs a very verbose string representation of a layer. Its +// output is a concatenation of LayerString(l) and hex.Dump(l.LayerContents()). +// It contains newlines and ends with a newline. +func LayerDump(l Layer) string { + var b bytes.Buffer + b.WriteString(LayerString(l)) + b.WriteByte('\n') + if d, ok := l.(Dumper); ok { + dump := d.Dump() + if dump != "" { + b.WriteString(dump) + if dump[len(dump)-1] != '\n' { + b.WriteByte('\n') + } + } + } + b.WriteString(hex.Dump(l.LayerContents())) + return b.String() +} + +// layerString outputs, recursively, a layer in a "smart" way. See docs for +// LayerString for more details. +// +// Params: +// i - value to write out +// anonymous: if we're currently recursing an anonymous member of a struct +// writeSpace: if we've already written a value in a struct, and need to +// write a space before writing more. This happens when we write various +// anonymous values, and need to keep writing more. +func layerString(v reflect.Value, anonymous bool, writeSpace bool) string { + // Let String() functions take precedence. + if v.CanInterface() { + if s, ok := v.Interface().(fmt.Stringer); ok { + return s.String() + } + } + // Reflect, and spit out all the exported fields as key=value. + switch v.Type().Kind() { + case reflect.Interface, reflect.Ptr: + if v.IsNil() { + return "nil" + } + r := v.Elem() + return layerString(r, anonymous, writeSpace) + case reflect.Struct: + var b bytes.Buffer + typ := v.Type() + if !anonymous { + b.WriteByte('{') + } + for i := 0; i < v.NumField(); i++ { + // Check if this is upper-case. + ftype := typ.Field(i) + f := v.Field(i) + if ftype.Anonymous { + anonStr := layerString(f, true, writeSpace) + writeSpace = writeSpace || anonStr != "" + b.WriteString(anonStr) + } else if ftype.PkgPath == "" { // exported + if writeSpace { + b.WriteByte(' ') + } + writeSpace = true + fmt.Fprintf(&b, "%s=%s", typ.Field(i).Name, layerString(f, false, writeSpace)) + } + } + if !anonymous { + b.WriteByte('}') + } + return b.String() + case reflect.Slice: + var b bytes.Buffer + b.WriteByte('[') + if v.Len() > 4 { + fmt.Fprintf(&b, "..%d..", v.Len()) + } else { + for j := 0; j < v.Len(); j++ { + if j != 0 { + b.WriteString(", ") + } + b.WriteString(layerString(v.Index(j), false, false)) + } + } + b.WriteByte(']') + return b.String() + } + return fmt.Sprintf("%v", v.Interface()) +} + +const ( + longBytesLength = 128 +) + +// LongBytesGoString returns a string representation of the byte slice shortened +// using the format '{ ... ( bytes)}' if it +// exceeds a predetermined length. Can be used to avoid filling the display with +// very long byte strings. +func LongBytesGoString(buf []byte) string { + if len(buf) < longBytesLength { + return fmt.Sprintf("%#v", buf) + } + s := fmt.Sprintf("%#v", buf[:longBytesLength-1]) + s = strings.TrimSuffix(s, "}") + return fmt.Sprintf("%s ... (%d bytes)}", s, len(buf)) +} + +func baseLayerString(value reflect.Value) string { + t := value.Type() + content := value.Field(0) + c := make([]byte, content.Len()) + for i := range c { + c[i] = byte(content.Index(i).Uint()) + } + payload := value.Field(1) + p := make([]byte, payload.Len()) + for i := range p { + p[i] = byte(payload.Index(i).Uint()) + } + return fmt.Sprintf("%s{Contents:%s, Payload:%s}", t.String(), + LongBytesGoString(c), + LongBytesGoString(p)) +} + +func layerGoString(i interface{}, b *bytes.Buffer) { + if s, ok := i.(fmt.GoStringer); ok { + b.WriteString(s.GoString()) + return + } + + var v reflect.Value + var ok bool + if v, ok = i.(reflect.Value); !ok { + v = reflect.ValueOf(i) + } + switch v.Kind() { + case reflect.Ptr, reflect.Interface: + if v.Kind() == reflect.Ptr { + b.WriteByte('&') + } + layerGoString(v.Elem().Interface(), b) + case reflect.Struct: + t := v.Type() + b.WriteString(t.String()) + b.WriteByte('{') + for i := 0; i < v.NumField(); i++ { + if i > 0 { + b.WriteString(", ") + } + if t.Field(i).Name == "BaseLayer" { + fmt.Fprintf(b, "BaseLayer:%s", baseLayerString(v.Field(i))) + } else if v.Field(i).Kind() == reflect.Struct { + fmt.Fprintf(b, "%s:", t.Field(i).Name) + layerGoString(v.Field(i), b) + } else if v.Field(i).Kind() == reflect.Ptr { + b.WriteByte('&') + layerGoString(v.Field(i), b) + } else { + fmt.Fprintf(b, "%s:%#v", t.Field(i).Name, v.Field(i)) + } + } + b.WriteByte('}') + default: + fmt.Fprintf(b, "%#v", i) + } +} + +// LayerGoString returns a representation of the layer in Go syntax, +// taking care to shorten "very long" BaseLayer byte slices +func LayerGoString(l Layer) string { + b := new(bytes.Buffer) + layerGoString(l, b) + return b.String() +} + +func (p *packet) packetString() string { + var b bytes.Buffer + fmt.Fprintf(&b, "PACKET: %d bytes", len(p.Data())) + if p.metadata.Truncated { + b.WriteString(", truncated") + } + if p.metadata.Length > 0 { + fmt.Fprintf(&b, ", wire length %d cap length %d", p.metadata.Length, p.metadata.CaptureLength) + } + if !p.metadata.Timestamp.IsZero() { + fmt.Fprintf(&b, " @ %v", p.metadata.Timestamp) + } + b.WriteByte('\n') + for i, l := range p.layers { + fmt.Fprintf(&b, "- Layer %d (%02d bytes) = %s\n", i+1, len(l.LayerContents()), LayerString(l)) + } + return b.String() +} + +func (p *packet) packetDump() string { + var b bytes.Buffer + fmt.Fprintf(&b, "-- FULL PACKET DATA (%d bytes) ------------------------------------\n%s", len(p.data), hex.Dump(p.data)) + for i, l := range p.layers { + fmt.Fprintf(&b, "--- Layer %d ---\n%s", i+1, LayerDump(l)) + } + return b.String() +} + +// eagerPacket is a packet implementation that does eager decoding. Upon +// initial construction, it decodes all the layers it can from packet data. +// eagerPacket implements Packet and PacketBuilder. +type eagerPacket struct { + packet +} + +var errNilDecoder = errors.New("NextDecoder passed nil decoder, probably an unsupported decode type") + +func (p *eagerPacket) NextDecoder(next Decoder) error { + if next == nil { + return errNilDecoder + } + if p.last == nil { + return errors.New("NextDecoder called, but no layers added yet") + } + d := p.last.LayerPayload() + if len(d) == 0 { + return nil + } + // Since we're eager, immediately call the next decoder. + return next.Decode(d, p) +} +func (p *eagerPacket) initialDecode(dec Decoder) { + defer p.recoverDecodeError() + err := dec.Decode(p.data, p) + if err != nil { + p.addFinalDecodeError(err, nil) + } +} +func (p *eagerPacket) LinkLayer() LinkLayer { + return p.link +} +func (p *eagerPacket) NetworkLayer() NetworkLayer { + return p.network +} +func (p *eagerPacket) TransportLayer() TransportLayer { + return p.transport +} +func (p *eagerPacket) ApplicationLayer() ApplicationLayer { + return p.application +} +func (p *eagerPacket) ErrorLayer() ErrorLayer { + return p.failure +} +func (p *eagerPacket) Layers() []Layer { + return p.layers +} +func (p *eagerPacket) Layer(t LayerType) Layer { + for _, l := range p.layers { + if l.LayerType() == t { + return l + } + } + return nil +} +func (p *eagerPacket) LayerClass(lc LayerClass) Layer { + for _, l := range p.layers { + if lc.Contains(l.LayerType()) { + return l + } + } + return nil +} +func (p *eagerPacket) String() string { return p.packetString() } +func (p *eagerPacket) Dump() string { return p.packetDump() } + +// lazyPacket does lazy decoding on its packet data. On construction it does +// no initial decoding. For each function call, it decodes only as many layers +// as are necessary to compute the return value for that function. +// lazyPacket implements Packet and PacketBuilder. +type lazyPacket struct { + packet + next Decoder +} + +func (p *lazyPacket) NextDecoder(next Decoder) error { + if next == nil { + return errNilDecoder + } + p.next = next + return nil +} +func (p *lazyPacket) decodeNextLayer() { + if p.next == nil { + return + } + d := p.data + if p.last != nil { + d = p.last.LayerPayload() + } + next := p.next + p.next = nil + // We've just set p.next to nil, so if we see we have no data, this should be + // the final call we get to decodeNextLayer if we return here. + if len(d) == 0 { + return + } + defer p.recoverDecodeError() + err := next.Decode(d, p) + if err != nil { + p.addFinalDecodeError(err, nil) + } +} +func (p *lazyPacket) LinkLayer() LinkLayer { + for p.link == nil && p.next != nil { + p.decodeNextLayer() + } + return p.link +} +func (p *lazyPacket) NetworkLayer() NetworkLayer { + for p.network == nil && p.next != nil { + p.decodeNextLayer() + } + return p.network +} +func (p *lazyPacket) TransportLayer() TransportLayer { + for p.transport == nil && p.next != nil { + p.decodeNextLayer() + } + return p.transport +} +func (p *lazyPacket) ApplicationLayer() ApplicationLayer { + for p.application == nil && p.next != nil { + p.decodeNextLayer() + } + return p.application +} +func (p *lazyPacket) ErrorLayer() ErrorLayer { + for p.failure == nil && p.next != nil { + p.decodeNextLayer() + } + return p.failure +} +func (p *lazyPacket) Layers() []Layer { + for p.next != nil { + p.decodeNextLayer() + } + return p.layers +} +func (p *lazyPacket) Layer(t LayerType) Layer { + for _, l := range p.layers { + if l.LayerType() == t { + return l + } + } + numLayers := len(p.layers) + for p.next != nil { + p.decodeNextLayer() + for _, l := range p.layers[numLayers:] { + if l.LayerType() == t { + return l + } + } + numLayers = len(p.layers) + } + return nil +} +func (p *lazyPacket) LayerClass(lc LayerClass) Layer { + for _, l := range p.layers { + if lc.Contains(l.LayerType()) { + return l + } + } + numLayers := len(p.layers) + for p.next != nil { + p.decodeNextLayer() + for _, l := range p.layers[numLayers:] { + if lc.Contains(l.LayerType()) { + return l + } + } + numLayers = len(p.layers) + } + return nil +} +func (p *lazyPacket) String() string { p.Layers(); return p.packetString() } +func (p *lazyPacket) Dump() string { p.Layers(); return p.packetDump() } + +// DecodeOptions tells gopacket how to decode a packet. +type DecodeOptions struct { + // Lazy decoding decodes the minimum number of layers needed to return data + // for a packet at each function call. Be careful using this with concurrent + // packet processors, as each call to packet.* could mutate the packet, and + // two concurrent function calls could interact poorly. + Lazy bool + // NoCopy decoding doesn't copy its input buffer into storage that's owned by + // the packet. If you can guarantee that the bytes underlying the slice + // passed into NewPacket aren't going to be modified, this can be faster. If + // there's any chance that those bytes WILL be changed, this will invalidate + // your packets. + NoCopy bool + // SkipDecodeRecovery skips over panic recovery during packet decoding. + // Normally, when packets decode, if a panic occurs, that panic is captured + // by a recover(), and a DecodeFailure layer is added to the packet detailing + // the issue. If this flag is set, panics are instead allowed to continue up + // the stack. + SkipDecodeRecovery bool + // DecodeStreamsAsDatagrams enables routing of application-level layers in the TCP + // decoder. If true, we should try to decode layers after TCP in single packets. + // This is disabled by default because the reassembly package drives the decoding + // of TCP payload data after reassembly. + DecodeStreamsAsDatagrams bool +} + +// Default decoding provides the safest (but slowest) method for decoding +// packets. It eagerly processes all layers (so it's concurrency-safe) and it +// copies its input buffer upon creation of the packet (so the packet remains +// valid if the underlying slice is modified. Both of these take time, +// though, so beware. If you can guarantee that the packet will only be used +// by one goroutine at a time, set Lazy decoding. If you can guarantee that +// the underlying slice won't change, set NoCopy decoding. +var Default = DecodeOptions{} + +// Lazy is a DecodeOptions with just Lazy set. +var Lazy = DecodeOptions{Lazy: true} + +// NoCopy is a DecodeOptions with just NoCopy set. +var NoCopy = DecodeOptions{NoCopy: true} + +// DecodeStreamsAsDatagrams is a DecodeOptions with just DecodeStreamsAsDatagrams set. +var DecodeStreamsAsDatagrams = DecodeOptions{DecodeStreamsAsDatagrams: true} + +// NewPacket creates a new Packet object from a set of bytes. The +// firstLayerDecoder tells it how to interpret the first layer from the bytes, +// future layers will be generated from that first layer automatically. +func NewPacket(data []byte, firstLayerDecoder Decoder, options DecodeOptions) Packet { + if !options.NoCopy { + dataCopy := make([]byte, len(data)) + copy(dataCopy, data) + data = dataCopy + } + if options.Lazy { + p := &lazyPacket{ + packet: packet{data: data, decodeOptions: options}, + next: firstLayerDecoder, + } + p.layers = p.initialLayers[:0] + // Crazy craziness: + // If the following return statemet is REMOVED, and Lazy is FALSE, then + // eager packet processing becomes 17% FASTER. No, there is no logical + // explanation for this. However, it's such a hacky micro-optimization that + // we really can't rely on it. It appears to have to do with the size the + // compiler guesses for this function's stack space, since one symptom is + // that with the return statement in place, we more than double calls to + // runtime.morestack/runtime.lessstack. We'll hope the compiler gets better + // over time and we get this optimization for free. Until then, we'll have + // to live with slower packet processing. + return p + } + p := &eagerPacket{ + packet: packet{data: data, decodeOptions: options}, + } + p.layers = p.initialLayers[:0] + p.initialDecode(firstLayerDecoder) + return p +} + +// PacketDataSource is an interface for some source of packet data. Users may +// create their own implementations, or use the existing implementations in +// gopacket/pcap (libpcap, allows reading from live interfaces or from +// pcap files) or gopacket/pfring (PF_RING, allows reading from live +// interfaces). +type PacketDataSource interface { + // ReadPacketData returns the next packet available from this data source. + // It returns: + // data: The bytes of an individual packet. + // ci: Metadata about the capture + // err: An error encountered while reading packet data. If err != nil, + // then data/ci will be ignored. + ReadPacketData() (data []byte, ci CaptureInfo, err error) +} + +// ConcatFinitePacketDataSources returns a PacketDataSource that wraps a set +// of internal PacketDataSources, each of which will stop with io.EOF after +// reading a finite number of packets. The returned PacketDataSource will +// return all packets from the first finite source, followed by all packets from +// the second, etc. Once all finite sources have returned io.EOF, the returned +// source will as well. +func ConcatFinitePacketDataSources(pds ...PacketDataSource) PacketDataSource { + c := concat(pds) + return &c +} + +type concat []PacketDataSource + +func (c *concat) ReadPacketData() (data []byte, ci CaptureInfo, err error) { + for len(*c) > 0 { + data, ci, err = (*c)[0].ReadPacketData() + if err == io.EOF { + *c = (*c)[1:] + continue + } + return + } + return nil, CaptureInfo{}, io.EOF +} + +// ZeroCopyPacketDataSource is an interface to pull packet data from sources +// that allow data to be returned without copying to a user-controlled buffer. +// It's very similar to PacketDataSource, except that the caller must be more +// careful in how the returned buffer is handled. +type ZeroCopyPacketDataSource interface { + // ZeroCopyReadPacketData returns the next packet available from this data source. + // It returns: + // data: The bytes of an individual packet. Unlike with + // PacketDataSource's ReadPacketData, the slice returned here points + // to a buffer owned by the data source. In particular, the bytes in + // this buffer may be changed by future calls to + // ZeroCopyReadPacketData. Do not use the returned buffer after + // subsequent ZeroCopyReadPacketData calls. + // ci: Metadata about the capture + // err: An error encountered while reading packet data. If err != nil, + // then data/ci will be ignored. + ZeroCopyReadPacketData() (data []byte, ci CaptureInfo, err error) +} + +// PacketSource reads in packets from a PacketDataSource, decodes them, and +// returns them. +// +// There are currently two different methods for reading packets in through +// a PacketSource: +// +// Reading With Packets Function +// +// This method is the most convenient and easiest to code, but lacks +// flexibility. Packets returns a 'chan Packet', then asynchronously writes +// packets into that channel. Packets uses a blocking channel, and closes +// it if an io.EOF is returned by the underlying PacketDataSource. All other +// PacketDataSource errors are ignored and discarded. +// for packet := range packetSource.Packets() { +// ... +// } +// +// Reading With NextPacket Function +// +// This method is the most flexible, and exposes errors that may be +// encountered by the underlying PacketDataSource. It's also the fastest +// in a tight loop, since it doesn't have the overhead of a channel +// read/write. However, it requires the user to handle errors, most +// importantly the io.EOF error in cases where packets are being read from +// a file. +// for { +// packet, err := packetSource.NextPacket() +// if err == io.EOF { +// break +// } else if err != nil { +// log.Println("Error:", err) +// continue +// } +// handlePacket(packet) // Do something with each packet. +// } +type PacketSource struct { + source PacketDataSource + decoder Decoder + // DecodeOptions is the set of options to use for decoding each piece + // of packet data. This can/should be changed by the user to reflect the + // way packets should be decoded. + DecodeOptions + c chan Packet +} + +// NewPacketSource creates a packet data source. +func NewPacketSource(source PacketDataSource, decoder Decoder) *PacketSource { + return &PacketSource{ + source: source, + decoder: decoder, + } +} + +// NextPacket returns the next decoded packet from the PacketSource. On error, +// it returns a nil packet and a non-nil error. +func (p *PacketSource) NextPacket() (Packet, error) { + data, ci, err := p.source.ReadPacketData() + if err != nil { + return nil, err + } + packet := NewPacket(data, p.decoder, p.DecodeOptions) + m := packet.Metadata() + m.CaptureInfo = ci + m.Truncated = m.Truncated || ci.CaptureLength < ci.Length + return packet, nil +} + +// packetsToChannel reads in all packets from the packet source and sends them +// to the given channel. When it receives an error, it ignores it. When it +// receives an io.EOF, it closes the channel. +func (p *PacketSource) packetsToChannel() { + defer close(p.c) + for { + packet, err := p.NextPacket() + if err == io.EOF { + return + } else if err == nil { + p.c <- packet + } + } +} + +// Packets returns a channel of packets, allowing easy iterating over +// packets. Packets will be asynchronously read in from the underlying +// PacketDataSource and written to the returned channel. If the underlying +// PacketDataSource returns an io.EOF error, the channel will be closed. +// If any other error is encountered, it is ignored. +// +// for packet := range packetSource.Packets() { +// handlePacket(packet) // Do something with each packet. +// } +// +// If called more than once, returns the same channel. +func (p *PacketSource) Packets() chan Packet { + if p.c == nil { + p.c = make(chan Packet, 1000) + go p.packetsToChannel() + } + return p.c +} diff --git a/vendor/github.com/google/gopacket/parser.go b/vendor/github.com/google/gopacket/parser.go new file mode 100644 index 0000000..f786834 --- /dev/null +++ b/vendor/github.com/google/gopacket/parser.go @@ -0,0 +1,198 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package gopacket + +import ( + "fmt" +) + +// DecodingLayer is an interface for packet layers that can decode themselves. +// +// The important part of DecodingLayer is that they decode themselves in-place. +// Calling DecodeFromBytes on a DecodingLayer totally resets the entire layer to +// the new state defined by the data passed in. A returned error leaves the +// DecodingLayer in an unknown intermediate state, thus its fields should not be +// trusted. +// +// Because the DecodingLayer is resetting its own fields, a call to +// DecodeFromBytes should normally not require any memory allocation. +type DecodingLayer interface { + // DecodeFromBytes resets the internal state of this layer to the state + // defined by the passed-in bytes. Slices in the DecodingLayer may + // reference the passed-in data, so care should be taken to copy it + // first should later modification of data be required before the + // DecodingLayer is discarded. + DecodeFromBytes(data []byte, df DecodeFeedback) error + // CanDecode returns the set of LayerTypes this DecodingLayer can + // decode. For Layers that are also DecodingLayers, this will most + // often be that Layer's LayerType(). + CanDecode() LayerClass + // NextLayerType returns the LayerType which should be used to decode + // the LayerPayload. + NextLayerType() LayerType + // LayerPayload is the set of bytes remaining to decode after a call to + // DecodeFromBytes. + LayerPayload() []byte +} + +// DecodingLayerParser parses a given set of layer types. See DecodeLayers for +// more information on how DecodingLayerParser should be used. +type DecodingLayerParser struct { + // DecodingLayerParserOptions is the set of options available to the + // user to define the parser's behavior. + DecodingLayerParserOptions + first LayerType + decoders map[LayerType]DecodingLayer + df DecodeFeedback + // Truncated is set when a decode layer detects that the packet has been + // truncated. + Truncated bool +} + +// AddDecodingLayer adds a decoding layer to the parser. This adds support for +// the decoding layer's CanDecode layers to the parser... should they be +// encountered, they'll be parsed. +func (l *DecodingLayerParser) AddDecodingLayer(d DecodingLayer) { + for _, typ := range d.CanDecode().LayerTypes() { + l.decoders[typ] = d + } +} + +// SetTruncated is used by DecodingLayers to set the Truncated boolean in the +// DecodingLayerParser. Users should simply read Truncated after calling +// DecodeLayers. +func (l *DecodingLayerParser) SetTruncated() { + l.Truncated = true +} + +// NewDecodingLayerParser creates a new DecodingLayerParser and adds in all +// of the given DecodingLayers with AddDecodingLayer. +// +// Each call to DecodeLayers will attempt to decode the given bytes first by +// treating them as a 'first'-type layer, then by using NextLayerType on +// subsequently decoded layers to find the next relevant decoder. Should a +// deoder not be available for the layer type returned by NextLayerType, +// decoding will stop. +func NewDecodingLayerParser(first LayerType, decoders ...DecodingLayer) *DecodingLayerParser { + dlp := &DecodingLayerParser{ + decoders: make(map[LayerType]DecodingLayer), + first: first, + } + dlp.df = dlp // Cast this once to the interface + for _, d := range decoders { + dlp.AddDecodingLayer(d) + } + return dlp +} + +// DecodeLayers decodes as many layers as possible from the given data. It +// initially treats the data as layer type 'typ', then uses NextLayerType on +// each subsequent decoded layer until it gets to a layer type it doesn't know +// how to parse. +// +// For each layer successfully decoded, DecodeLayers appends the layer type to +// the decoded slice. DecodeLayers truncates the 'decoded' slice initially, so +// there's no need to empty it yourself. +// +// This decoding method is about an order of magnitude faster than packet +// decoding, because it only decodes known layers that have already been +// allocated. This means it doesn't need to allocate each layer it returns... +// instead it overwrites the layers that already exist. +// +// Example usage: +// func main() { +// var eth layers.Ethernet +// var ip4 layers.IPv4 +// var ip6 layers.IPv6 +// var tcp layers.TCP +// var udp layers.UDP +// var payload gopacket.Payload +// parser := gopacket.NewDecodingLayerParser(layers.LayerTypeEthernet, ð, &ip4, &ip6, &tcp, &udp, &payload) +// var source gopacket.PacketDataSource = getMyDataSource() +// decodedLayers := make([]gopacket.LayerType, 0, 10) +// for { +// data, _, err := source.ReadPacketData() +// if err == nil { +// fmt.Println("Error reading packet data: ", err) +// continue +// } +// fmt.Println("Decoding packet") +// err = parser.DecodeLayers(data, &decodedLayers) +// for _, typ := range decodedLayers { +// fmt.Println(" Successfully decoded layer type", typ) +// switch typ { +// case layers.LayerTypeEthernet: +// fmt.Println(" Eth ", eth.SrcMAC, eth.DstMAC) +// case layers.LayerTypeIPv4: +// fmt.Println(" IP4 ", ip4.SrcIP, ip4.DstIP) +// case layers.LayerTypeIPv6: +// fmt.Println(" IP6 ", ip6.SrcIP, ip6.DstIP) +// case layers.LayerTypeTCP: +// fmt.Println(" TCP ", tcp.SrcPort, tcp.DstPort) +// case layers.LayerTypeUDP: +// fmt.Println(" UDP ", udp.SrcPort, udp.DstPort) +// } +// } +// if decodedLayers.Truncated { +// fmt.Println(" Packet has been truncated") +// } +// if err != nil { +// fmt.Println(" Error encountered:", err) +// } +// } +// } +// +// If DecodeLayers is unable to decode the next layer type, it will return the +// error UnsupportedLayerType. +func (l *DecodingLayerParser) DecodeLayers(data []byte, decoded *[]LayerType) (err error) { + l.Truncated = false + if !l.IgnorePanic { + defer panicToError(&err) + } + typ := l.first + *decoded = (*decoded)[:0] // Truncated decoded layers. + for len(data) > 0 { + decoder, ok := l.decoders[typ] + if !ok { + return UnsupportedLayerType(typ) + } else if err = decoder.DecodeFromBytes(data, l.df); err != nil { + return err + } + *decoded = append(*decoded, typ) + typ = decoder.NextLayerType() + data = decoder.LayerPayload() + } + return nil +} + +// UnsupportedLayerType is returned by DecodingLayerParser if DecodeLayers +// encounters a layer type that the DecodingLayerParser has no decoder for. +type UnsupportedLayerType LayerType + +// Error implements the error interface, returning a string to say that the +// given layer type is unsupported. +func (e UnsupportedLayerType) Error() string { + return fmt.Sprintf("No decoder for layer type %v", LayerType(e)) +} + +func panicToError(e *error) { + if r := recover(); r != nil { + *e = fmt.Errorf("panic: %v", r) + } +} + +// DecodingLayerParserOptions provides options to affect the behavior of a given +// DecodingLayerParser. +type DecodingLayerParserOptions struct { + // IgnorePanic determines whether a DecodingLayerParser should stop + // panics on its own (by returning them as an error from DecodeLayers) + // or should allow them to raise up the stack. Handling errors does add + // latency to the process of decoding layers, but is much safer for + // callers. IgnorePanic defaults to false, thus if the caller does + // nothing decode panics will be returned as errors. + IgnorePanic bool +} diff --git a/vendor/github.com/google/gopacket/writer.go b/vendor/github.com/google/gopacket/writer.go new file mode 100644 index 0000000..9e85a92 --- /dev/null +++ b/vendor/github.com/google/gopacket/writer.go @@ -0,0 +1,213 @@ +// Copyright 2012 Google, Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file in the root of the source +// tree. + +package gopacket + +import ( + "fmt" +) + +// SerializableLayer allows its implementations to be written out as a set of bytes, +// so those bytes may be sent on the wire or otherwise used by the caller. +// SerializableLayer is implemented by certain Layer types, and can be encoded to +// bytes using the LayerWriter object. +type SerializableLayer interface { + // SerializeTo writes this layer to a slice, growing that slice if necessary + // to make it fit the layer's data. + // Args: + // b: SerializeBuffer to write this layer on to. When called, b.Bytes() + // is the payload this layer should wrap, if any. Note that this + // layer can either prepend itself (common), append itself + // (uncommon), or both (sometimes padding or footers are required at + // the end of packet data). It's also possible (though probably very + // rarely needed) to overwrite any bytes in the current payload. + // After this call, b.Bytes() should return the byte encoding of + // this layer wrapping the original b.Bytes() payload. + // opts: options to use while writing out data. + // Returns: + // error if a problem was encountered during encoding. If an error is + // returned, the bytes in data should be considered invalidated, and + // not used. + // + // SerializeTo calls SHOULD entirely ignore LayerContents and + // LayerPayload. It just serializes based on struct fields, neither + // modifying nor using contents/payload. + SerializeTo(b SerializeBuffer, opts SerializeOptions) error +} + +// SerializeOptions provides options for behaviors that SerializableLayers may want to +// implement. +type SerializeOptions struct { + // FixLengths determines whether, during serialization, layers should fix + // the values for any length field that depends on the payload. + FixLengths bool + // ComputeChecksums determines whether, during serialization, layers + // should recompute checksums based on their payloads. + ComputeChecksums bool +} + +// SerializeBuffer is a helper used by gopacket for writing out packet layers. +// SerializeBuffer starts off as an empty []byte. Subsequent calls to PrependBytes +// return byte slices before the current Bytes(), AppendBytes returns byte +// slices after. +// +// Byte slices returned by PrependBytes/AppendBytes are NOT zero'd out, so if +// you want to make sure they're all zeros, set them as such. +// +// SerializeBuffer is specifically designed to handle packet writing, where unlike +// with normal writes it's easier to start writing at the inner-most layer and +// work out, meaning that we often need to prepend bytes. This runs counter to +// typical writes to byte slices using append(), where we only write at the end +// of the buffer. +// +// It can be reused via Clear. Note, however, that a Clear call will invalidate the +// byte slices returned by any previous Bytes() call (the same buffer is +// reused). +// +// 1) Reusing a write buffer is generally much faster than creating a new one, +// and with the default implementation it avoids additional memory allocations. +// 2) If a byte slice from a previous Bytes() call will continue to be used, +// it's better to create a new SerializeBuffer. +// +// The Clear method is specifically designed to minimize memory allocations for +// similar later workloads on the SerializeBuffer. IE: if you make a set of +// Prepend/Append calls, then clear, then make the same calls with the same +// sizes, the second round (and all future similar rounds) shouldn't allocate +// any new memory. +type SerializeBuffer interface { + // Bytes returns the contiguous set of bytes collected so far by Prepend/Append + // calls. The slice returned by Bytes will be modified by future Clear calls, + // so if you're planning on clearing this SerializeBuffer, you may want to copy + // Bytes somewhere safe first. + Bytes() []byte + // PrependBytes returns a set of bytes which prepends the current bytes in this + // buffer. These bytes start in an indeterminate state, so they should be + // overwritten by the caller. The caller must only call PrependBytes if they + // know they're going to immediately overwrite all bytes returned. + PrependBytes(num int) ([]byte, error) + // AppendBytes returns a set of bytes which appends the current bytes in this + // buffer. These bytes start in an indeterminate state, so they should be + // overwritten by the caller. The caller must only call AppendBytes if they + // know they're going to immediately overwrite all bytes returned. + AppendBytes(num int) ([]byte, error) + // Clear resets the SerializeBuffer to a new, empty buffer. After a call to clear, + // the byte slice returned by any previous call to Bytes() for this buffer + // should be considered invalidated. + Clear() error +} + +type serializeBuffer struct { + data []byte + start int + prepended, appended int +} + +// NewSerializeBuffer creates a new instance of the default implementation of +// the SerializeBuffer interface. +func NewSerializeBuffer() SerializeBuffer { + return &serializeBuffer{} +} + +// NewSerializeBufferExpectedSize creates a new buffer for serialization, optimized for an +// expected number of bytes prepended/appended. This tends to decrease the +// number of memory allocations made by the buffer during writes. +func NewSerializeBufferExpectedSize(expectedPrependLength, expectedAppendLength int) SerializeBuffer { + return &serializeBuffer{ + data: make([]byte, expectedPrependLength, expectedPrependLength+expectedAppendLength), + start: expectedPrependLength, + prepended: expectedPrependLength, + appended: expectedAppendLength, + } +} + +func (w *serializeBuffer) Bytes() []byte { + return w.data[w.start:] +} + +func (w *serializeBuffer) PrependBytes(num int) ([]byte, error) { + if num < 0 { + panic("num < 0") + } + if w.start < num { + toPrepend := w.prepended + if toPrepend < num { + toPrepend = num + } + w.prepended += toPrepend + length := cap(w.data) + toPrepend + newData := make([]byte, length) + newStart := w.start + toPrepend + copy(newData[newStart:], w.data[w.start:]) + w.start = newStart + w.data = newData[:toPrepend+len(w.data)] + } + w.start -= num + return w.data[w.start : w.start+num], nil +} + +func (w *serializeBuffer) AppendBytes(num int) ([]byte, error) { + if num < 0 { + panic("num < 0") + } + initialLength := len(w.data) + if cap(w.data)-initialLength < num { + toAppend := w.appended + if toAppend < num { + toAppend = num + } + w.appended += toAppend + newData := make([]byte, cap(w.data)+toAppend) + copy(newData[w.start:], w.data[w.start:]) + w.data = newData[:initialLength] + } + // Grow the buffer. We know it'll be under capacity given above. + w.data = w.data[:initialLength+num] + return w.data[initialLength:], nil +} + +func (w *serializeBuffer) Clear() error { + w.start = w.prepended + w.data = w.data[:w.start] + return nil +} + +// SerializeLayers clears the given write buffer, then writes all layers into it so +// they correctly wrap each other. Note that by clearing the buffer, it +// invalidates all slices previously returned by w.Bytes() +// +// Example: +// buf := gopacket.NewSerializeBuffer() +// opts := gopacket.SerializeOptions{} +// gopacket.SerializeLayers(buf, opts, a, b, c) +// firstPayload := buf.Bytes() // contains byte representation of a(b(c)) +// gopacket.SerializeLayers(buf, opts, d, e, f) +// secondPayload := buf.Bytes() // contains byte representation of d(e(f)). firstPayload is now invalidated, since the SerializeLayers call Clears buf. +func SerializeLayers(w SerializeBuffer, opts SerializeOptions, layers ...SerializableLayer) error { + w.Clear() + for i := len(layers) - 1; i >= 0; i-- { + layer := layers[i] + err := layer.SerializeTo(w, opts) + if err != nil { + return err + } + } + return nil +} + +// SerializePacket is a convenience function that calls SerializeLayers +// on packet's Layers(). +// It returns an error if one of the packet layers is not a SerializebleLayer. +func SerializePacket(buf SerializeBuffer, opts SerializeOptions, packet Packet) error { + sls := []SerializableLayer{} + for _, layer := range packet.Layers() { + sl, ok := layer.(SerializableLayer) + if !ok { + return fmt.Errorf("layer %s is not serializable", layer.LayerType().String()) + } + sls = append(sls, sl) + } + return SerializeLayers(buf, opts, sls...) +} diff --git a/vendor/github.com/gotk3/gotk3.old/LICENSE b/vendor/github.com/gotk3/gotk3.old/LICENSE deleted file mode 100644 index 53015ff..0000000 --- a/vendor/github.com/gotk3/gotk3.old/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2013-2014 Conformal Systems LLC. - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/antialias.go b/vendor/github.com/gotk3/gotk3.old/cairo/antialias.go deleted file mode 100644 index 4d5f6cf..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/antialias.go +++ /dev/null @@ -1,28 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" -import ( - "unsafe" -) - -// Antialias is a representation of Cairo's cairo_antialias_t. -type Antialias int - -const ( - ANTIALIAS_DEFAULT Antialias = C.CAIRO_ANTIALIAS_DEFAULT - ANTIALIAS_NONE Antialias = C.CAIRO_ANTIALIAS_NONE - ANTIALIAS_GRAY Antialias = C.CAIRO_ANTIALIAS_GRAY - ANTIALIAS_SUBPIXEL Antialias = C.CAIRO_ANTIALIAS_SUBPIXEL - // ANTIALIAS_FAST Antialias = C.CAIRO_ANTIALIAS_FAST (since 1.12) - // ANTIALIAS_GOOD Antialias = C.CAIRO_ANTIALIAS_GOOD (since 1.12) - // ANTIALIAS_BEST Antialias = C.CAIRO_ANTIALIAS_BEST (since 1.12) -) - -func marshalAntialias(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return Antialias(c), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/cairo.go b/vendor/github.com/gotk3/gotk3.old/cairo/cairo.go deleted file mode 100644 index f5df44f..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/cairo.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// Package cairo implements Go bindings for Cairo. Supports version 1.10 and -// later. -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - // Enums - {glib.Type(C.cairo_gobject_antialias_get_type()), marshalAntialias}, - {glib.Type(C.cairo_gobject_content_get_type()), marshalContent}, - {glib.Type(C.cairo_gobject_fill_rule_get_type()), marshalFillRule}, - {glib.Type(C.cairo_gobject_line_cap_get_type()), marshalLineCap}, - {glib.Type(C.cairo_gobject_line_join_get_type()), marshalLineJoin}, - {glib.Type(C.cairo_gobject_operator_get_type()), marshalOperator}, - {glib.Type(C.cairo_gobject_status_get_type()), marshalStatus}, - {glib.Type(C.cairo_gobject_surface_type_get_type()), marshalSurfaceType}, - - // Boxed - {glib.Type(C.cairo_gobject_context_get_type()), marshalContext}, - {glib.Type(C.cairo_gobject_surface_get_type()), marshalSurface}, - } - glib.RegisterGValueMarshalers(tm) -} - -// Constants - -// Content is a representation of Cairo's cairo_content_t. -type Content int - -const ( - CONTENT_COLOR Content = C.CAIRO_CONTENT_COLOR - CONTENT_ALPHA Content = C.CAIRO_CONTENT_ALPHA - CONTENT_COLOR_ALPHA Content = C.CAIRO_CONTENT_COLOR_ALPHA -) - -func marshalContent(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return Content(c), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/canvas.go b/vendor/github.com/gotk3/gotk3.old/cairo/canvas.go deleted file mode 100644 index 121b59f..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/canvas.go +++ /dev/null @@ -1,401 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" - -import ( - "reflect" - "runtime" - "unsafe" -) - -// Context is a representation of Cairo's cairo_t. -type Context struct { - context *C.cairo_t -} - -// native returns a pointer to the underlying cairo_t. -func (v *Context) native() *C.cairo_t { - if v == nil { - return nil - } - return v.context -} - -func (v *Context) GetCContext() *C.cairo_t { - return v.native() -} - -// Native returns a pointer to the underlying cairo_t. -func (v *Context) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalContext(p uintptr) (interface{}, error) { - c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) - context := (*C.cairo_t)(unsafe.Pointer(c)) - return wrapContext(context), nil -} - -func wrapContext(context *C.cairo_t) *Context { - return &Context{context} -} - -// Create is a wrapper around cairo_create(). -func Create(target *Surface) *Context { - c := C.cairo_create(target.native()) - ctx := wrapContext(c) - runtime.SetFinalizer(ctx, (*Context).destroy) - return ctx -} - -// reference is a wrapper around cairo_reference(). -func (v *Context) reference() { - v.context = C.cairo_reference(v.native()) -} - -// destroy is a wrapper around cairo_destroy(). -func (v *Context) destroy() { - C.cairo_destroy(v.native()) -} - -// Status is a wrapper around cairo_status(). -func (v *Context) Status() Status { - c := C.cairo_status(v.native()) - return Status(c) -} - -// Save is a wrapper around cairo_save(). -func (v *Context) Save() { - C.cairo_save(v.native()) -} - -// Restore is a wrapper around cairo_restore(). -func (v *Context) Restore() { - C.cairo_restore(v.native()) -} - -// GetTarget is a wrapper around cairo_get_target(). -func (v *Context) GetTarget() *Surface { - c := C.cairo_get_target(v.native()) - s := wrapSurface(c) - s.reference() - runtime.SetFinalizer(s, (*Surface).destroy) - return s -} - -// PushGroup is a wrapper around cairo_push_group(). -func (v *Context) PushGroup() { - C.cairo_push_group(v.native()) -} - -// PushGroupWithContent is a wrapper around cairo_push_group_with_content(). -func (v *Context) PushGroupWithContent(content Content) { - C.cairo_push_group_with_content(v.native(), C.cairo_content_t(content)) -} - -// TODO(jrick) PopGroup (depends on Pattern) - -// PopGroupToSource is a wrapper around cairo_pop_group_to_source(). -func (v *Context) PopGroupToSource() { - C.cairo_pop_group_to_source(v.native()) -} - -// GetGroupTarget is a wrapper around cairo_get_group_target(). -func (v *Context) GetGroupTarget() *Surface { - c := C.cairo_get_group_target(v.native()) - s := wrapSurface(c) - s.reference() - runtime.SetFinalizer(s, (*Surface).destroy) - return s -} - -// SetSourceRGB is a wrapper around cairo_set_source_rgb(). -func (v *Context) SetSourceRGB(red, green, blue float64) { - C.cairo_set_source_rgb(v.native(), C.double(red), C.double(green), - C.double(blue)) -} - -// SetSourceRGBA is a wrapper around cairo_set_source_rgba(). -func (v *Context) SetSourceRGBA(red, green, blue, alpha float64) { - C.cairo_set_source_rgba(v.native(), C.double(red), C.double(green), - C.double(blue), C.double(alpha)) -} - -// TODO(jrick) SetSource (depends on Pattern) - -// SetSourceSurface is a wrapper around cairo_set_source_surface(). -func (v *Context) SetSourceSurface(surface *Surface, x, y float64) { - C.cairo_set_source_surface(v.native(), surface.native(), C.double(x), - C.double(y)) -} - -// TODO(jrick) GetSource (depends on Pattern) - -// SetAntialias is a wrapper around cairo_set_antialias(). -func (v *Context) SetAntialias(antialias Antialias) { - C.cairo_set_antialias(v.native(), C.cairo_antialias_t(antialias)) -} - -// GetAntialias is a wrapper around cairo_get_antialias(). -func (v *Context) GetAntialias() Antialias { - c := C.cairo_get_antialias(v.native()) - return Antialias(c) -} - -// SetDash is a wrapper around cairo_set_dash(). -func (v *Context) SetDash(dashes []float64, offset float64) { - header := (*reflect.SliceHeader)(unsafe.Pointer(&dashes)) - cdashes := (*C.double)(unsafe.Pointer(header.Data)) - C.cairo_set_dash(v.native(), cdashes, C.int(header.Len), - C.double(offset)) -} - -// GetDashCount is a wrapper around cairo_get_dash_count(). -func (v *Context) GetDashCount() int { - c := C.cairo_get_dash_count(v.native()) - return int(c) -} - -// GetDash is a wrapper around cairo_get_dash(). -func (v *Context) GetDash() (dashes []float64, offset float64) { - dashCount := v.GetDashCount() - cdashes := (*C.double)(C.calloc(8, C.size_t(dashCount))) - var coffset C.double - C.cairo_get_dash(v.native(), cdashes, &coffset) - header := (*reflect.SliceHeader)((unsafe.Pointer(&dashes))) - header.Data = uintptr(unsafe.Pointer(cdashes)) - header.Len = dashCount - header.Cap = dashCount - return dashes, float64(coffset) -} - -// SetFillRule is a wrapper around cairo_set_fill_rule(). -func (v *Context) SetFillRule(fillRule FillRule) { - C.cairo_set_fill_rule(v.native(), C.cairo_fill_rule_t(fillRule)) -} - -// GetFillRule is a wrapper around cairo_get_fill_rule(). -func (v *Context) GetFillRule() FillRule { - c := C.cairo_get_fill_rule(v.native()) - return FillRule(c) -} - -// SetLineCap is a wrapper around cairo_set_line_cap(). -func (v *Context) SetLineCap(lineCap LineCap) { - C.cairo_set_line_cap(v.native(), C.cairo_line_cap_t(lineCap)) -} - -// GetLineCap is a wrapper around cairo_get_line_cap(). -func (v *Context) GetLineCap() LineCap { - c := C.cairo_get_line_cap(v.native()) - return LineCap(c) -} - -// SetLineJoin is a wrapper around cairo_set_line_join(). -func (v *Context) SetLineJoin(lineJoin LineJoin) { - C.cairo_set_line_join(v.native(), C.cairo_line_join_t(lineJoin)) -} - -// GetLineJoin is a wrapper around cairo_get_line_join(). -func (v *Context) GetLineJoin() LineJoin { - c := C.cairo_get_line_join(v.native()) - return LineJoin(c) -} - -// SetLineWidth is a wrapper around cairo_set_line_width(). -func (v *Context) SetLineWidth(width float64) { - C.cairo_set_line_width(v.native(), C.double(width)) -} - -// GetLineWidth is a wrapper cairo_get_line_width(). -func (v *Context) GetLineWidth() float64 { - c := C.cairo_get_line_width(v.native()) - return float64(c) -} - -// SetMiterLimit is a wrapper around cairo_set_miter_limit(). -func (v *Context) SetMiterLimit(limit float64) { - C.cairo_set_miter_limit(v.native(), C.double(limit)) -} - -// GetMiterLimit is a wrapper around cairo_get_miter_limit(). -func (v *Context) GetMiterLimit() float64 { - c := C.cairo_get_miter_limit(v.native()) - return float64(c) -} - -// SetOperator is a wrapper around cairo_set_operator(). -func (v *Context) SetOperator(op Operator) { - C.cairo_set_operator(v.native(), C.cairo_operator_t(op)) -} - -// GetOperator is a wrapper around cairo_get_operator(). -func (v *Context) GetOperator() Operator { - c := C.cairo_get_operator(v.native()) - return Operator(c) -} - -// SetTolerance is a wrapper around cairo_set_tolerance(). -func (v *Context) SetTolerance(tolerance float64) { - C.cairo_set_tolerance(v.native(), C.double(tolerance)) -} - -// GetTolerance is a wrapper around cairo_get_tolerance(). -func (v *Context) GetTolerance() float64 { - c := C.cairo_get_tolerance(v.native()) - return float64(c) -} - -// Clip is a wrapper around cairo_clip(). -func (v *Context) Clip() { - C.cairo_clip(v.native()) -} - -// ClipPreserve is a wrapper around cairo_clip_preserve(). -func (v *Context) ClipPreserve() { - C.cairo_clip_preserve(v.native()) -} - -// ClipExtents is a wrapper around cairo_clip_extents(). -func (v *Context) ClipExtents() (x1, y1, x2, y2 float64) { - var cx1, cy1, cx2, cy2 C.double - C.cairo_clip_extents(v.native(), &cx1, &cy1, &cx2, &cy2) - return float64(cx1), float64(cy1), float64(cx2), float64(cy2) -} - -// InClip is a wrapper around cairo_in_clip(). -func (v *Context) InClip(x, y float64) bool { - c := C.cairo_in_clip(v.native(), C.double(x), C.double(y)) - return gobool(c) -} - -// ResetClip is a wrapper around cairo_reset_clip(). -func (v *Context) ResetClip() { - C.cairo_reset_clip(v.native()) -} - -// Rectangle is a wrapper around cairo_rectangle(). -func (v *Context) Rectangle(x, y, w, h float64) { - C.cairo_rectangle(v.native(), C.double(x), C.double(y), C.double(w), C.double(h)) -} - -// Arc is a wrapper around cairo_arc(). -func (v *Context) Arc(xc, yc, radius, angle1, angle2 float64) { - C.cairo_arc(v.native(), C.double(xc), C.double(yc), C.double(radius), C.double(angle1), C.double(angle2)) -} - -// ArcNegative is a wrapper around cairo_arc_negative(). -func (v *Context) ArcNegative(xc, yc, radius, angle1, angle2 float64) { - C.cairo_arc_negative(v.native(), C.double(xc), C.double(yc), C.double(radius), C.double(angle1), C.double(angle2)) -} - -// LineTo is a wrapper around cairo_line_to(). -func (v *Context) LineTo(x, y float64) { - C.cairo_line_to(v.native(), C.double(x), C.double(y)) -} - -// CurveTo is a wrapper around cairo_curve_to(). -func (v *Context) CurveTo(x1, y1, x2, y2, x3, y3 float64) { - C.cairo_curve_to(v.native(), C.double(x1), C.double(y1), C.double(x2), C.double(y2), C.double(x3), C.double(y3)) -} - -// MoveTo is a wrapper around cairo_move_to(). -func (v *Context) MoveTo(x, y float64) { - C.cairo_move_to(v.native(), C.double(x), C.double(y)) -} - -// TODO(jrick) CopyRectangleList (depends on RectangleList) - -// Fill is a wrapper around cairo_fill(). -func (v *Context) Fill() { - C.cairo_fill(v.native()) -} - -// ClosePath is a wrapper around cairo_close_path(). -func (v *Context) ClosePath() { - C.cairo_close_path(v.native()) -} - -// NewPath is a wrapper around cairo_new_path(). -func (v *Context) NewPath() { - C.cairo_new_path(v.native()) -} - -// GetCurrentPoint is a wrapper around cairo_get_current_point(). -func (v *Context) GetCurrentPoint() (x, y float64) { - C.cairo_get_current_point(v.native(), (*C.double)(&x), (*C.double)(&y)) - return -} - -// FillPreserve is a wrapper around cairo_fill_preserve(). -func (v *Context) FillPreserve() { - C.cairo_fill_preserve(v.native()) -} - -// FillExtents is a wrapper around cairo_fill_extents(). -func (v *Context) FillExtents() (x1, y1, x2, y2 float64) { - var cx1, cy1, cx2, cy2 C.double - C.cairo_fill_extents(v.native(), &cx1, &cy1, &cx2, &cy2) - return float64(cx1), float64(cy1), float64(cx2), float64(cy2) -} - -// InFill is a wrapper around cairo_in_fill(). -func (v *Context) InFill(x, y float64) bool { - c := C.cairo_in_fill(v.native(), C.double(x), C.double(y)) - return gobool(c) -} - -// TODO(jrick) Mask (depends on Pattern) - -// MaskSurface is a wrapper around cairo_mask_surface(). -func (v *Context) MaskSurface(surface *Surface, surfaceX, surfaceY float64) { - C.cairo_mask_surface(v.native(), surface.native(), C.double(surfaceX), - C.double(surfaceY)) -} - -// Paint is a wrapper around cairo_paint(). -func (v *Context) Paint() { - C.cairo_paint(v.native()) -} - -// PaintWithAlpha is a wrapper around cairo_paint_with_alpha(). -func (v *Context) PaintWithAlpha(alpha float64) { - C.cairo_paint_with_alpha(v.native(), C.double(alpha)) -} - -// Stroke is a wrapper around cairo_stroke(). -func (v *Context) Stroke() { - C.cairo_stroke(v.native()) -} - -// StrokePreserve is a wrapper around cairo_stroke_preserve(). -func (v *Context) StrokePreserve() { - C.cairo_stroke_preserve(v.native()) -} - -// StrokeExtents is a wrapper around cairo_stroke_extents(). -func (v *Context) StrokeExtents() (x1, y1, x2, y2 float64) { - var cx1, cy1, cx2, cy2 C.double - C.cairo_stroke_extents(v.native(), &cx1, &cy1, &cx2, &cy2) - return float64(cx1), float64(cy1), float64(cx2), float64(cy2) -} - -// InStroke is a wrapper around cairo_in_stroke(). -func (v *Context) InStroke(x, y float64) bool { - c := C.cairo_in_stroke(v.native(), C.double(x), C.double(y)) - return gobool(c) -} - -// CopyPage is a wrapper around cairo_copy_page(). -func (v *Context) CopyPage() { - C.cairo_copy_page(v.native()) -} - -// ShowPage is a wrapper around cairo_show_page(). -func (v *Context) ShowPage() { - C.cairo_show_page(v.native()) -} diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/errors.go b/vendor/github.com/gotk3/gotk3.old/cairo/errors.go deleted file mode 100644 index 1e48a8a..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/errors.go +++ /dev/null @@ -1,7 +0,0 @@ -package cairo - -type ErrorStatus Status - -func (e ErrorStatus) Error() string { - return StatusToString(Status(e)) -} diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/fillrule.go b/vendor/github.com/gotk3/gotk3.old/cairo/fillrule.go deleted file mode 100644 index 91a6b1f..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/fillrule.go +++ /dev/null @@ -1,23 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" -import ( - "unsafe" -) - -// FillRule is a representation of Cairo's cairo_fill_rule_t. -type FillRule int - -const ( - FILL_RULE_WINDING FillRule = C.CAIRO_FILL_RULE_WINDING - FILL_RULE_EVEN_ODD FillRule = C.CAIRO_FILL_RULE_EVEN_ODD -) - -func marshalFillRule(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return FillRule(c), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/format.go b/vendor/github.com/gotk3/gotk3.old/cairo/format.go deleted file mode 100644 index e1853b8..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/format.go +++ /dev/null @@ -1,28 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" -import ( - "unsafe" -) - -// Format is a representation of Cairo's cairo_format_t. -type Format int - -const ( - FORMAT_INVALID Format = C.CAIRO_FORMAT_INVALID - FORMAT_ARGB32 Format = C.CAIRO_FORMAT_ARGB32 - FORMAT_RGB24 Format = C.CAIRO_FORMAT_RGB24 - FORMAT_A8 Format = C.CAIRO_FORMAT_A8 - FORMAT_A1 Format = C.CAIRO_FORMAT_A1 - FORMAT_RGB16_565 Format = C.CAIRO_FORMAT_RGB16_565 - FORMAT_RGB30 Format = C.CAIRO_FORMAT_RGB30 -) - -func marshalFormat(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return Format(c), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/linecap.go b/vendor/github.com/gotk3/gotk3.old/cairo/linecap.go deleted file mode 100644 index 3ff7ca0..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/linecap.go +++ /dev/null @@ -1,24 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" -import ( - "unsafe" -) - -// LineCap is a representation of Cairo's cairo_line_cap_t. -type LineCap int - -const ( - LINE_CAP_BUTT LineCap = C.CAIRO_LINE_CAP_BUTT - LINE_CAP_ROUND LineCap = C.CAIRO_LINE_CAP_ROUND - LINE_CAP_SQUARE LineCap = C.CAIRO_LINE_CAP_SQUARE -) - -func marshalLineCap(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return LineCap(c), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/linejoin.go b/vendor/github.com/gotk3/gotk3.old/cairo/linejoin.go deleted file mode 100644 index 71c715f..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/linejoin.go +++ /dev/null @@ -1,24 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" -import ( - "unsafe" -) - -// LineJoin is a representation of Cairo's cairo_line_join_t. -type LineJoin int - -const ( - LINE_JOIN_MITER LineJoin = C.CAIRO_LINE_JOIN_MITER - LINE_JOIN_ROUND LineJoin = C.CAIRO_LINE_JOIN_ROUND - LINE_JOIN_BEVEL LineJoin = C.CAIRO_LINE_JOIN_BEVEL -) - -func marshalLineJoin(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return LineJoin(c), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/mimetype.go b/vendor/github.com/gotk3/gotk3.old/cairo/mimetype.go deleted file mode 100644 index 406273e..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/mimetype.go +++ /dev/null @@ -1,13 +0,0 @@ -package cairo - -// MimeType is a representation of Cairo's CAIRO_MIME_TYPE_* -// preprocessor constants. -type MimeType string - -const ( - MIME_TYPE_JP2 MimeType = "image/jp2" - MIME_TYPE_JPEG MimeType = "image/jpeg" - MIME_TYPE_PNG MimeType = "image/png" - MIME_TYPE_URI MimeType = "image/x-uri" - MIME_TYPE_UNIQUE_ID MimeType = "application/x-cairo.uuid" -) diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/operator.go b/vendor/github.com/gotk3/gotk3.old/cairo/operator.go deleted file mode 100644 index b263c8d..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/operator.go +++ /dev/null @@ -1,50 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" -import ( - "unsafe" -) - -// Operator is a representation of Cairo's cairo_operator_t. -type Operator int - -const ( - OPERATOR_CLEAR Operator = C.CAIRO_OPERATOR_CLEAR - OPERATOR_SOURCE Operator = C.CAIRO_OPERATOR_SOURCE - OPERATOR_OVER Operator = C.CAIRO_OPERATOR_OVER - OPERATOR_IN Operator = C.CAIRO_OPERATOR_IN - OPERATOR_OUT Operator = C.CAIRO_OPERATOR_OUT - OPERATOR_ATOP Operator = C.CAIRO_OPERATOR_ATOP - OPERATOR_DEST Operator = C.CAIRO_OPERATOR_DEST - OPERATOR_DEST_OVER Operator = C.CAIRO_OPERATOR_DEST_OVER - OPERATOR_DEST_IN Operator = C.CAIRO_OPERATOR_DEST_IN - OPERATOR_DEST_OUT Operator = C.CAIRO_OPERATOR_DEST_OUT - OPERATOR_DEST_ATOP Operator = C.CAIRO_OPERATOR_DEST_ATOP - OPERATOR_XOR Operator = C.CAIRO_OPERATOR_XOR - OPERATOR_ADD Operator = C.CAIRO_OPERATOR_ADD - OPERATOR_SATURATE Operator = C.CAIRO_OPERATOR_SATURATE - OPERATOR_MULTIPLY Operator = C.CAIRO_OPERATOR_MULTIPLY - OPERATOR_SCREEN Operator = C.CAIRO_OPERATOR_SCREEN - OPERATOR_OVERLAY Operator = C.CAIRO_OPERATOR_OVERLAY - OPERATOR_DARKEN Operator = C.CAIRO_OPERATOR_DARKEN - OPERATOR_LIGHTEN Operator = C.CAIRO_OPERATOR_LIGHTEN - OPERATOR_COLOR_DODGE Operator = C.CAIRO_OPERATOR_COLOR_DODGE - OPERATOR_COLOR_BURN Operator = C.CAIRO_OPERATOR_COLOR_BURN - OPERATOR_HARD_LIGHT Operator = C.CAIRO_OPERATOR_HARD_LIGHT - OPERATOR_SOFT_LIGHT Operator = C.CAIRO_OPERATOR_SOFT_LIGHT - OPERATOR_DIFFERENCE Operator = C.CAIRO_OPERATOR_DIFFERENCE - OPERATOR_EXCLUSION Operator = C.CAIRO_OPERATOR_EXCLUSION - OPERATOR_HSL_HUE Operator = C.CAIRO_OPERATOR_HSL_HUE - OPERATOR_HSL_SATURATION Operator = C.CAIRO_OPERATOR_HSL_SATURATION - OPERATOR_HSL_COLOR Operator = C.CAIRO_OPERATOR_HSL_COLOR - OPERATOR_HSL_LUMINOSITY Operator = C.CAIRO_OPERATOR_HSL_LUMINOSITY -) - -func marshalOperator(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return Operator(c), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/status.go b/vendor/github.com/gotk3/gotk3.old/cairo/status.go deleted file mode 100644 index 5bd8aa4..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/status.go +++ /dev/null @@ -1,109 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" -import ( - "unsafe" -) - -// Status is a representation of Cairo's cairo_status_t. -type Status int - -const ( - STATUS_SUCCESS Status = C.CAIRO_STATUS_SUCCESS - STATUS_NO_MEMORY Status = C.CAIRO_STATUS_NO_MEMORY - STATUS_INVALID_RESTORE Status = C.CAIRO_STATUS_INVALID_RESTORE - STATUS_INVALID_POP_GROUP Status = C.CAIRO_STATUS_INVALID_POP_GROUP - STATUS_NO_CURRENT_POINT Status = C.CAIRO_STATUS_NO_CURRENT_POINT - STATUS_INVALID_MATRIX Status = C.CAIRO_STATUS_INVALID_MATRIX - STATUS_INVALID_STATUS Status = C.CAIRO_STATUS_INVALID_STATUS - STATUS_NULL_POINTER Status = C.CAIRO_STATUS_NULL_POINTER - STATUS_INVALID_STRING Status = C.CAIRO_STATUS_INVALID_STRING - STATUS_INVALID_PATH_DATA Status = C.CAIRO_STATUS_INVALID_PATH_DATA - STATUS_READ_ERROR Status = C.CAIRO_STATUS_READ_ERROR - STATUS_WRITE_ERROR Status = C.CAIRO_STATUS_WRITE_ERROR - STATUS_SURFACE_FINISHED Status = C.CAIRO_STATUS_SURFACE_FINISHED - STATUS_SURFACE_TYPE_MISMATCH Status = C.CAIRO_STATUS_SURFACE_TYPE_MISMATCH - STATUS_PATTERN_TYPE_MISMATCH Status = C.CAIRO_STATUS_PATTERN_TYPE_MISMATCH - STATUS_INVALID_CONTENT Status = C.CAIRO_STATUS_INVALID_CONTENT - STATUS_INVALID_FORMAT Status = C.CAIRO_STATUS_INVALID_FORMAT - STATUS_INVALID_VISUAL Status = C.CAIRO_STATUS_INVALID_VISUAL - STATUS_FILE_NOT_FOUND Status = C.CAIRO_STATUS_FILE_NOT_FOUND - STATUS_INVALID_DASH Status = C.CAIRO_STATUS_INVALID_DASH - STATUS_INVALID_DSC_COMMENT Status = C.CAIRO_STATUS_INVALID_DSC_COMMENT - STATUS_INVALID_INDEX Status = C.CAIRO_STATUS_INVALID_INDEX - STATUS_CLIP_NOT_REPRESENTABLE Status = C.CAIRO_STATUS_CLIP_NOT_REPRESENTABLE - STATUS_TEMP_FILE_ERROR Status = C.CAIRO_STATUS_TEMP_FILE_ERROR - STATUS_INVALID_STRIDE Status = C.CAIRO_STATUS_INVALID_STRIDE - STATUS_FONT_TYPE_MISMATCH Status = C.CAIRO_STATUS_FONT_TYPE_MISMATCH - STATUS_USER_FONT_IMMUTABLE Status = C.CAIRO_STATUS_USER_FONT_IMMUTABLE - STATUS_USER_FONT_ERROR Status = C.CAIRO_STATUS_USER_FONT_ERROR - STATUS_NEGATIVE_COUNT Status = C.CAIRO_STATUS_NEGATIVE_COUNT - STATUS_INVALID_CLUSTERS Status = C.CAIRO_STATUS_INVALID_CLUSTERS - STATUS_INVALID_SLANT Status = C.CAIRO_STATUS_INVALID_SLANT - STATUS_INVALID_WEIGHT Status = C.CAIRO_STATUS_INVALID_WEIGHT - STATUS_INVALID_SIZE Status = C.CAIRO_STATUS_INVALID_SIZE - STATUS_USER_FONT_NOT_IMPLEMENTED Status = C.CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED - STATUS_DEVICE_TYPE_MISMATCH Status = C.CAIRO_STATUS_DEVICE_TYPE_MISMATCH - STATUS_DEVICE_ERROR Status = C.CAIRO_STATUS_DEVICE_ERROR - // STATUS_INVALID_MESH_CONSTRUCTION Status = C.CAIRO_STATUS_INVALID_MESH_CONSTRUCTION (since 1.12) - // STATUS_DEVICE_FINISHED Status = C.CAIRO_STATUS_DEVICE_FINISHED (since 1.12) -) - -var key_Status = map[Status]string{ - - STATUS_SUCCESS: "CAIRO_STATUS_SUCCESS", - STATUS_NO_MEMORY: "CAIRO_STATUS_NO_MEMORY", - STATUS_INVALID_RESTORE: "CAIRO_STATUS_INVALID_RESTORE", - STATUS_INVALID_POP_GROUP: "CAIRO_STATUS_INVALID_POP_GROUP", - STATUS_NO_CURRENT_POINT: "CAIRO_STATUS_NO_CURRENT_POINT", - STATUS_INVALID_MATRIX: "CAIRO_STATUS_INVALID_MATRIX", - STATUS_INVALID_STATUS: "CAIRO_STATUS_INVALID_STATUS", - STATUS_NULL_POINTER: "CAIRO_STATUS_NULL_POINTER", - STATUS_INVALID_STRING: "CAIRO_STATUS_INVALID_STRING", - STATUS_INVALID_PATH_DATA: "CAIRO_STATUS_INVALID_PATH_DATA", - STATUS_READ_ERROR: "CAIRO_STATUS_READ_ERROR", - STATUS_WRITE_ERROR: "CAIRO_STATUS_WRITE_ERROR", - STATUS_SURFACE_FINISHED: "CAIRO_STATUS_SURFACE_FINISHED", - STATUS_SURFACE_TYPE_MISMATCH: "CAIRO_STATUS_SURFACE_TYPE_MISMATCH", - STATUS_PATTERN_TYPE_MISMATCH: "CAIRO_STATUS_PATTERN_TYPE_MISMATCH", - STATUS_INVALID_CONTENT: "CAIRO_STATUS_INVALID_CONTENT", - STATUS_INVALID_FORMAT: "CAIRO_STATUS_INVALID_FORMAT", - STATUS_INVALID_VISUAL: "CAIRO_STATUS_INVALID_VISUAL", - STATUS_FILE_NOT_FOUND: "CAIRO_STATUS_FILE_NOT_FOUND", - STATUS_INVALID_DASH: "CAIRO_STATUS_INVALID_DASH", - STATUS_INVALID_DSC_COMMENT: "CAIRO_STATUS_INVALID_DSC_COMMENT", - STATUS_INVALID_INDEX: "CAIRO_STATUS_INVALID_INDEX", - STATUS_CLIP_NOT_REPRESENTABLE: "CAIRO_STATUS_CLIP_NOT_REPRESENTABLE", - STATUS_TEMP_FILE_ERROR: "CAIRO_STATUS_TEMP_FILE_ERROR", - STATUS_INVALID_STRIDE: "CAIRO_STATUS_INVALID_STRIDE", - STATUS_FONT_TYPE_MISMATCH: "CAIRO_STATUS_FONT_TYPE_MISMATCH", - STATUS_USER_FONT_IMMUTABLE: "CAIRO_STATUS_USER_FONT_IMMUTABLE", - STATUS_USER_FONT_ERROR: "CAIRO_STATUS_USER_FONT_ERROR", - STATUS_NEGATIVE_COUNT: "CAIRO_STATUS_NEGATIVE_COUNT", - STATUS_INVALID_CLUSTERS: "CAIRO_STATUS_INVALID_CLUSTERS", - STATUS_INVALID_SLANT: "CAIRO_STATUS_INVALID_SLANT", - STATUS_INVALID_WEIGHT: "CAIRO_STATUS_INVALID_WEIGHT", - STATUS_INVALID_SIZE: "CAIRO_STATUS_INVALID_SIZE", - STATUS_USER_FONT_NOT_IMPLEMENTED: "CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED", - STATUS_DEVICE_TYPE_MISMATCH: "CAIRO_STATUS_DEVICE_TYPE_MISMATCH", - STATUS_DEVICE_ERROR: "CAIRO_STATUS_DEVICE_ERROR", -} - -func StatusToString(status Status) string { - - s, ok := key_Status[status] - if !ok { - s = "CAIRO_STATUS_UNDEFINED" - } - - return s -} - -func marshalStatus(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return Status(c), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/surface.go b/vendor/github.com/gotk3/gotk3.old/cairo/surface.go deleted file mode 100644 index 3b8a6d6..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/surface.go +++ /dev/null @@ -1,215 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" - -import ( - "runtime" - "unsafe" -) - -// TODO(jrick) SetUserData (depends on UserDataKey and DestroyFunc) - -// TODO(jrick) GetUserData (depends on UserDataKey) - -/* - * cairo_surface_t - */ - -// Surface is a representation of Cairo's cairo_surface_t. -type Surface struct { - surface *C.cairo_surface_t -} - -func NewSurfaceFromPNG(fileName string) (*Surface, error) { - - cstr := C.CString(fileName) - defer C.free(unsafe.Pointer(cstr)) - - surfaceNative := C.cairo_image_surface_create_from_png(cstr) - - status := Status(C.cairo_surface_status(surfaceNative)) - if status != STATUS_SUCCESS { - return nil, ErrorStatus(status) - } - - return &Surface{surfaceNative}, nil -} - -// CreateImageSurface is a wrapper around cairo_image_surface_create(). -func CreateImageSurface(format Format, width, height int) *Surface { - c := C.cairo_image_surface_create(C.cairo_format_t(format), - C.int(width), C.int(height)) - s := wrapSurface(c) - runtime.SetFinalizer(s, (*Surface).destroy) - return s -} - -// native returns a pointer to the underlying cairo_surface_t. -func (v *Surface) native() *C.cairo_surface_t { - if v == nil { - return nil - } - return v.surface -} - -// Native returns a pointer to the underlying cairo_surface_t. -func (v *Surface) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalSurface(p uintptr) (interface{}, error) { - c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) - surface := (*C.cairo_surface_t)(unsafe.Pointer(c)) - return wrapSurface(surface), nil -} - -func wrapSurface(surface *C.cairo_surface_t) *Surface { - return &Surface{surface} -} - -// NewSurface creates a gotk3 cairo Surface from a pointer to a -// C cairo_surface_t. This is primarily designed for use with other -// gotk3 packages and should be avoided by applications. -func NewSurface(s uintptr, needsRef bool) *Surface { - ptr := (*C.cairo_surface_t)(unsafe.Pointer(s)) - surface := wrapSurface(ptr) - if needsRef { - surface.reference() - } - runtime.SetFinalizer(surface, (*Surface).destroy) - return surface -} - -// CreateSimilar is a wrapper around cairo_surface_create_similar(). -func (v *Surface) CreateSimilar(content Content, width, height int) *Surface { - c := C.cairo_surface_create_similar(v.native(), - C.cairo_content_t(content), C.int(width), C.int(height)) - s := wrapSurface(c) - runtime.SetFinalizer(s, (*Surface).destroy) - return s -} - -// TODO cairo_surface_create_similar_image (since 1.12) - -// CreateForRectangle is a wrapper around cairo_surface_create_for_rectangle(). -func (v *Surface) CreateForRectangle(x, y, width, height float64) *Surface { - c := C.cairo_surface_create_for_rectangle(v.native(), C.double(x), - C.double(y), C.double(width), C.double(height)) - s := wrapSurface(c) - runtime.SetFinalizer(s, (*Surface).destroy) - return s -} - -// reference is a wrapper around cairo_surface_reference(). -func (v *Surface) reference() { - v.surface = C.cairo_surface_reference(v.native()) -} - -// destroy is a wrapper around cairo_surface_destroy(). -func (v *Surface) destroy() { - C.cairo_surface_destroy(v.native()) -} - -// Status is a wrapper around cairo_surface_status(). -func (v *Surface) Status() Status { - c := C.cairo_surface_status(v.native()) - return Status(c) -} - -// Flush is a wrapper around cairo_surface_flush(). -func (v *Surface) Flush() { - C.cairo_surface_flush(v.native()) -} - -// TODO(jrick) GetDevice (requires Device bindings) - -// TODO(jrick) GetFontOptions (require FontOptions bindings) - -// TODO(jrick) GetContent (requires Content bindings) - -// MarkDirty is a wrapper around cairo_surface_mark_dirty(). -func (v *Surface) MarkDirty() { - C.cairo_surface_mark_dirty(v.native()) -} - -// MarkDirtyRectangle is a wrapper around cairo_surface_mark_dirty_rectangle(). -func (v *Surface) MarkDirtyRectangle(x, y, width, height int) { - C.cairo_surface_mark_dirty_rectangle(v.native(), C.int(x), C.int(y), - C.int(width), C.int(height)) -} - -// SetDeviceOffset is a wrapper around cairo_surface_set_device_offset(). -func (v *Surface) SetDeviceOffset(x, y float64) { - C.cairo_surface_set_device_offset(v.native(), C.double(x), C.double(y)) -} - -// GetDeviceOffset is a wrapper around cairo_surface_get_device_offset(). -func (v *Surface) GetDeviceOffset() (x, y float64) { - var xOffset, yOffset C.double - C.cairo_surface_get_device_offset(v.native(), &xOffset, &yOffset) - return float64(xOffset), float64(yOffset) -} - -// SetFallbackResolution is a wrapper around -// cairo_surface_set_fallback_resolution(). -func (v *Surface) SetFallbackResolution(xPPI, yPPI float64) { - C.cairo_surface_set_fallback_resolution(v.native(), C.double(xPPI), - C.double(yPPI)) -} - -// GetFallbackResolution is a wrapper around -// cairo_surface_get_fallback_resolution(). -func (v *Surface) GetFallbackResolution() (xPPI, yPPI float64) { - var x, y C.double - C.cairo_surface_get_fallback_resolution(v.native(), &x, &y) - return float64(x), float64(y) -} - -// GetType is a wrapper around cairo_surface_get_type(). -func (v *Surface) GetType() SurfaceType { - c := C.cairo_surface_get_type(v.native()) - return SurfaceType(c) -} - -// TODO(jrick) SetUserData (depends on UserDataKey and DestroyFunc) - -// TODO(jrick) GetUserData (depends on UserDataKey) - -// CopyPage is a wrapper around cairo_surface_copy_page(). -func (v *Surface) CopyPage() { - C.cairo_surface_copy_page(v.native()) -} - -// ShowPage is a wrapper around cairo_surface_show_page(). -func (v *Surface) ShowPage() { - C.cairo_surface_show_page(v.native()) -} - -// HasShowTextGlyphs is a wrapper around cairo_surface_has_show_text_glyphs(). -func (v *Surface) HasShowTextGlyphs() bool { - c := C.cairo_surface_has_show_text_glyphs(v.native()) - return gobool(c) -} - -// TODO(jrick) SetMimeData (depends on DestroyFunc) - -// GetMimeData is a wrapper around cairo_surface_get_mime_data(). The -// returned mimetype data is returned as a Go byte slice. -func (v *Surface) GetMimeData(mimeType MimeType) []byte { - cstr := C.CString(string(mimeType)) - defer C.free(unsafe.Pointer(cstr)) - var data *C.uchar - var length C.ulong - C.cairo_surface_get_mime_data(v.native(), cstr, &data, &length) - return C.GoBytes(unsafe.Pointer(data), C.int(length)) -} - -// TODO(jrick) SupportsMimeType (since 1.12) - -// TODO(jrick) MapToImage (since 1.12) - -// TODO(jrick) UnmapImage (since 1.12) diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/surfacetype.go b/vendor/github.com/gotk3/gotk3.old/cairo/surfacetype.go deleted file mode 100644 index 30b9782..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/surfacetype.go +++ /dev/null @@ -1,46 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" -import ( - "unsafe" -) - -// SurfaceType is a representation of Cairo's cairo_surface_type_t. -type SurfaceType int - -const ( - SURFACE_TYPE_IMAGE SurfaceType = C.CAIRO_SURFACE_TYPE_IMAGE - SURFACE_TYPE_PDF SurfaceType = C.CAIRO_SURFACE_TYPE_PDF - SURFACE_TYPE_PS SurfaceType = C.CAIRO_SURFACE_TYPE_PS - SURFACE_TYPE_XLIB SurfaceType = C.CAIRO_SURFACE_TYPE_XLIB - SURFACE_TYPE_XCB SurfaceType = C.CAIRO_SURFACE_TYPE_XCB - SURFACE_TYPE_GLITZ SurfaceType = C.CAIRO_SURFACE_TYPE_GLITZ - SURFACE_TYPE_QUARTZ SurfaceType = C.CAIRO_SURFACE_TYPE_QUARTZ - SURFACE_TYPE_WIN32 SurfaceType = C.CAIRO_SURFACE_TYPE_WIN32 - SURFACE_TYPE_BEOS SurfaceType = C.CAIRO_SURFACE_TYPE_BEOS - SURFACE_TYPE_DIRECTFB SurfaceType = C.CAIRO_SURFACE_TYPE_DIRECTFB - SURFACE_TYPE_SVG SurfaceType = C.CAIRO_SURFACE_TYPE_SVG - SURFACE_TYPE_OS2 SurfaceType = C.CAIRO_SURFACE_TYPE_OS2 - SURFACE_TYPE_WIN32_PRINTING SurfaceType = C.CAIRO_SURFACE_TYPE_WIN32_PRINTING - SURFACE_TYPE_QUARTZ_IMAGE SurfaceType = C.CAIRO_SURFACE_TYPE_QUARTZ_IMAGE - SURFACE_TYPE_SCRIPT SurfaceType = C.CAIRO_SURFACE_TYPE_SCRIPT - SURFACE_TYPE_QT SurfaceType = C.CAIRO_SURFACE_TYPE_QT - SURFACE_TYPE_RECORDING SurfaceType = C.CAIRO_SURFACE_TYPE_RECORDING - SURFACE_TYPE_VG SurfaceType = C.CAIRO_SURFACE_TYPE_VG - SURFACE_TYPE_GL SurfaceType = C.CAIRO_SURFACE_TYPE_GL - SURFACE_TYPE_DRM SurfaceType = C.CAIRO_SURFACE_TYPE_DRM - SURFACE_TYPE_TEE SurfaceType = C.CAIRO_SURFACE_TYPE_TEE - SURFACE_TYPE_XML SurfaceType = C.CAIRO_SURFACE_TYPE_XML - SURFACE_TYPE_SKIA SurfaceType = C.CAIRO_SURFACE_TYPE_SKIA - SURFACE_TYPE_SUBSURFACE SurfaceType = C.CAIRO_SURFACE_TYPE_SUBSURFACE - // SURFACE_TYPE_COGL SurfaceType = C.CAIRO_SURFACE_TYPE_COGL (since 1.12) -) - -func marshalSurfaceType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return SurfaceType(c), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/text.go b/vendor/github.com/gotk3/gotk3.old/cairo/text.go deleted file mode 100644 index a14f6ef..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/text.go +++ /dev/null @@ -1,127 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" - -import ( - "unsafe" -) - -// FontSlant is a representation of Cairo's cairo_font_slant_t -type FontSlant int - -const ( - FONT_SLANT_NORMAL FontSlant = C.CAIRO_FONT_SLANT_NORMAL - FONT_SLANT_ITALIC FontSlant = C.CAIRO_FONT_SLANT_ITALIC - FONT_SLANT_OBLIQUE FontSlant = C.CAIRO_FONT_SLANT_OBLIQUE -) - -// FontWeight is a representation of Cairo's cairo_font_weight_t -type FontWeight int - -const ( - FONT_WEIGHT_NORMAL FontWeight = C.CAIRO_FONT_WEIGHT_NORMAL - FONT_WEIGHT_BOLD FontWeight = C.CAIRO_FONT_WEIGHT_BOLD -) - -func (v *Context) SelectFontFace(family string, slant FontSlant, weight FontWeight) { - cstr := C.CString(family) - defer C.free(unsafe.Pointer(cstr)) - C.cairo_select_font_face(v.native(), (*C.char)(cstr), C.cairo_font_slant_t(slant), C.cairo_font_weight_t(weight)) -} - -func (v *Context) SetFontSize(size float64) { - C.cairo_set_font_size(v.native(), C.double(size)) -} - -// TODO: cairo_set_font_matrix - -// TODO: cairo_get_font_matrix - -// TODO: cairo_set_font_options - -// TODO: cairo_get_font_options - -// TODO: cairo_set_font_face - -// TODO: cairo_get_font_face - -// TODO: cairo_set_scaled_font - -// TODO: cairo_get_scaled_font - -func (v *Context) ShowText(utf8 string) { - cstr := C.CString(utf8) - defer C.free(unsafe.Pointer(cstr)) - C.cairo_show_text(v.native(), (*C.char)(cstr)) -} - -// TODO: cairo_show_glyphs - -// TODO: cairo_show_text_glyphs - -type FontExtents struct { - Ascent float64 - Descent float64 - Height float64 - MaxXAdvance float64 - MaxYAdvance float64 -} - -func (v *Context) FontExtents() FontExtents { - var extents C.cairo_font_extents_t - C.cairo_font_extents(v.native(), &extents) - return FontExtents{ - Ascent: float64(extents.ascent), - Descent: float64(extents.descent), - Height: float64(extents.height), - MaxXAdvance: float64(extents.max_x_advance), - MaxYAdvance: float64(extents.max_y_advance), - } -} - -type TextExtents struct { - XBearing float64 - YBearing float64 - Width float64 - Height float64 - XAdvance float64 - YAdvance float64 -} - -func (v *Context) TextExtents(utf8 string) TextExtents { - cstr := C.CString(utf8) - defer C.free(unsafe.Pointer(cstr)) - var extents C.cairo_text_extents_t - C.cairo_text_extents(v.native(), (*C.char)(cstr), &extents) - return TextExtents{ - XBearing: float64(extents.x_bearing), - YBearing: float64(extents.y_bearing), - Width: float64(extents.width), - Height: float64(extents.height), - XAdvance: float64(extents.x_advance), - YAdvance: float64(extents.y_advance), - } -} - -// TODO: cairo_glyph_extents - -// TODO: cairo_toy_font_face_create - -// TODO: cairo_toy_font_face_get_family - -// TODO: cairo_toy_font_face_get_slant - -// TODO: cairo_toy_font_face_get_weight - -// TODO: cairo_glyph_allocate - -// TODO: cairo_glyph_free - -// TODO: cairo_text_cluster_allocate - -// TODO: cairo_text_cluster_free - diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/translations.go b/vendor/github.com/gotk3/gotk3.old/cairo/translations.go deleted file mode 100644 index d205a0e..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/translations.go +++ /dev/null @@ -1,32 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" - -// Translate is a wrapper around cairo_translate. -func (v *Context) Translate(tx, ty float64) { - C.cairo_translate(v.native(), C.double(tx), C.double(ty)) -} - -// Scale is a wrapper around cairo_scale. -func (v *Context) Scale(sx, sy float64) { - C.cairo_scale(v.native(), C.double(sx), C.double(sy)) -} - -// Rotate is a wrapper around cairo_rotate. -func (v *Context) Rotate(angle float64) { - C.cairo_rotate(v.native(), C.double(angle)) -} - -// TODO: The following depend on cairo_matrix_t: -//void cairo_transform () -//void cairo_set_matrix () -//void cairo_get_matrix () -//void cairo_identity_matrix () -//void cairo_user_to_device () -//void cairo_user_to_device_distance () -//void cairo_device_to_user () -//void cairo_device_to_user_distance () diff --git a/vendor/github.com/gotk3/gotk3.old/cairo/util.go b/vendor/github.com/gotk3/gotk3.old/cairo/util.go deleted file mode 100644 index 6659109..0000000 --- a/vendor/github.com/gotk3/gotk3.old/cairo/util.go +++ /dev/null @@ -1,21 +0,0 @@ -package cairo - -// #cgo pkg-config: cairo cairo-gobject -// #include -// #include -// #include -import "C" - -func cairobool(b bool) C.cairo_bool_t { - if b { - return C.cairo_bool_t(1) - } - return C.cairo_bool_t(0) -} - -func gobool(b C.cairo_bool_t) bool { - if b != 0 { - return true - } - return false -} diff --git a/vendor/github.com/gotk3/gotk3.old/gdk/gdk.go b/vendor/github.com/gotk3/gotk3.old/gdk/gdk.go deleted file mode 100644 index 9b7da4b..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gdk/gdk.go +++ /dev/null @@ -1,1641 +0,0 @@ -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// Go bindings for GDK 3. Supports version 3.6 and later. -package gdk - -// #cgo pkg-config: gdk-3.0 -// #include -// #include "gdk.go.h" -import "C" -import ( - "errors" - "reflect" - "runtime" - "strconv" - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - // Enums - {glib.Type(C.gdk_drag_action_get_type()), marshalDragAction}, - {glib.Type(C.gdk_colorspace_get_type()), marshalColorspace}, - {glib.Type(C.gdk_event_type_get_type()), marshalEventType}, - {glib.Type(C.gdk_interp_type_get_type()), marshalInterpType}, - {glib.Type(C.gdk_modifier_type_get_type()), marshalModifierType}, - {glib.Type(C.gdk_pixbuf_alpha_mode_get_type()), marshalPixbufAlphaMode}, - {glib.Type(C.gdk_event_mask_get_type()), marshalEventMask}, - - // Objects/Interfaces - {glib.Type(C.gdk_device_get_type()), marshalDevice}, - {glib.Type(C.gdk_cursor_get_type()), marshalCursor}, - {glib.Type(C.gdk_device_manager_get_type()), marshalDeviceManager}, - {glib.Type(C.gdk_display_get_type()), marshalDisplay}, - {glib.Type(C.gdk_drag_context_get_type()), marshalDragContext}, - {glib.Type(C.gdk_pixbuf_get_type()), marshalPixbuf}, - {glib.Type(C.gdk_rgba_get_type()), marshalRGBA}, - {glib.Type(C.gdk_screen_get_type()), marshalScreen}, - {glib.Type(C.gdk_visual_get_type()), marshalVisual}, - {glib.Type(C.gdk_window_get_type()), marshalWindow}, - - // Boxed - {glib.Type(C.gdk_event_get_type()), marshalEvent}, - } - glib.RegisterGValueMarshalers(tm) -} - -/* - * Type conversions - */ - -func gbool(b bool) C.gboolean { - if b { - return C.gboolean(1) - } - return C.gboolean(0) -} -func gobool(b C.gboolean) bool { - if b != 0 { - return true - } - return false -} - -/* - * Unexported vars - */ - -var nilPtrErr = errors.New("cgo returned unexpected nil pointer") - -/* - * Constants - */ - -// DragAction is a representation of GDK's GdkDragAction. -type DragAction int - -const ( - ACTION_DEFAULT DragAction = C.GDK_ACTION_DEFAULT - ACTION_COPY DragAction = C.GDK_ACTION_COPY - ACTION_MOVE DragAction = C.GDK_ACTION_MOVE - ACTION_LINK DragAction = C.GDK_ACTION_LINK - ACTION_PRIVATE DragAction = C.GDK_ACTION_PRIVATE - ACTION_ASK DragAction = C.GDK_ACTION_ASK -) - -func marshalDragAction(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return DragAction(c), nil -} - -// Colorspace is a representation of GDK's GdkColorspace. -type Colorspace int - -const ( - COLORSPACE_RGB Colorspace = C.GDK_COLORSPACE_RGB -) - -func marshalColorspace(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return Colorspace(c), nil -} - -// InterpType is a representation of GDK's GdkInterpType. -type InterpType int - -const ( - INTERP_NEAREST InterpType = C.GDK_INTERP_NEAREST - INTERP_TILES InterpType = C.GDK_INTERP_TILES - INTERP_BILINEAR InterpType = C.GDK_INTERP_BILINEAR - INTERP_HYPER InterpType = C.GDK_INTERP_HYPER -) - -// PixbufRotation is a representation of GDK's GdkPixbufRotation. -type PixbufRotation int - -const ( - PIXBUF_ROTATE_NONE PixbufRotation = C.GDK_PIXBUF_ROTATE_NONE - PIXBUF_ROTATE_COUNTERCLOCKWISE PixbufRotation = C.GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE - PIXBUF_ROTATE_UPSIDEDOWN PixbufRotation = C.GDK_PIXBUF_ROTATE_UPSIDEDOWN - PIXBUF_ROTATE_CLOCKWISE PixbufRotation = C.GDK_PIXBUF_ROTATE_CLOCKWISE -) - -func marshalInterpType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return InterpType(c), nil -} - -// ModifierType is a representation of GDK's GdkModifierType. -type ModifierType uint - -const ( - GDK_SHIFT_MASK ModifierType = C.GDK_SHIFT_MASK - GDK_LOCK_MASK = C.GDK_LOCK_MASK - GDK_CONTROL_MASK = C.GDK_CONTROL_MASK - GDK_MOD1_MASK = C.GDK_MOD1_MASK - GDK_MOD2_MASK = C.GDK_MOD2_MASK - GDK_MOD3_MASK = C.GDK_MOD3_MASK - GDK_MOD4_MASK = C.GDK_MOD4_MASK - GDK_MOD5_MASK = C.GDK_MOD5_MASK - GDK_BUTTON1_MASK = C.GDK_BUTTON1_MASK - GDK_BUTTON2_MASK = C.GDK_BUTTON2_MASK - GDK_BUTTON3_MASK = C.GDK_BUTTON3_MASK - GDK_BUTTON4_MASK = C.GDK_BUTTON4_MASK - GDK_BUTTON5_MASK = C.GDK_BUTTON5_MASK - GDK_SUPER_MASK = C.GDK_SUPER_MASK - GDK_HYPER_MASK = C.GDK_HYPER_MASK - GDK_META_MASK = C.GDK_META_MASK - GDK_RELEASE_MASK = C.GDK_RELEASE_MASK - GDK_MODIFIER_MASK = C.GDK_MODIFIER_MASK -) - -func marshalModifierType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return ModifierType(c), nil -} - -// PixbufAlphaMode is a representation of GDK's GdkPixbufAlphaMode. -type PixbufAlphaMode int - -const ( - GDK_PIXBUF_ALPHA_BILEVEL PixbufAlphaMode = C.GDK_PIXBUF_ALPHA_BILEVEL - GDK_PIXBUF_ALPHA_FULL PixbufAlphaMode = C.GDK_PIXBUF_ALPHA_FULL -) - -func marshalPixbufAlphaMode(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return PixbufAlphaMode(c), nil -} - -// Selections -const ( - SELECTION_PRIMARY Atom = 1 - SELECTION_SECONDARY Atom = 2 - SELECTION_CLIPBOARD Atom = 69 - TARGET_BITMAP Atom = 5 - TARGET_COLORMAP Atom = 7 - TARGET_DRAWABLE Atom = 17 - TARGET_PIXMAP Atom = 20 - TARGET_STRING Atom = 31 - SELECTION_TYPE_ATOM Atom = 4 - SELECTION_TYPE_BITMAP Atom = 5 - SELECTION_TYPE_COLORMAP Atom = 7 - SELECTION_TYPE_DRAWABLE Atom = 17 - SELECTION_TYPE_INTEGER Atom = 19 - SELECTION_TYPE_PIXMAP Atom = 20 - SELECTION_TYPE_WINDOW Atom = 33 - SELECTION_TYPE_STRING Atom = 31 -) - -// added by terrak -// EventMask is a representation of GDK's GdkEventMask. -type EventMask int - -const ( - EXPOSURE_MASK EventMask = C.GDK_EXPOSURE_MASK - POINTER_MOTION_MASK EventMask = C.GDK_POINTER_MOTION_MASK - POINTER_MOTION_HINT_MASK EventMask = C.GDK_POINTER_MOTION_HINT_MASK - BUTTON_MOTION_MASK EventMask = C.GDK_BUTTON_MOTION_MASK - BUTTON1_MOTION_MASK EventMask = C.GDK_BUTTON1_MOTION_MASK - BUTTON2_MOTION_MASK EventMask = C.GDK_BUTTON2_MOTION_MASK - BUTTON3_MOTION_MASK EventMask = C.GDK_BUTTON3_MOTION_MASK - BUTTON_PRESS_MASK EventMask = C.GDK_BUTTON_PRESS_MASK - BUTTON_RELEASE_MASK EventMask = C.GDK_BUTTON_RELEASE_MASK - KEY_PRESS_MASK EventMask = C.GDK_KEY_PRESS_MASK - KEY_RELEASE_MASK EventMask = C.GDK_KEY_RELEASE_MASK - ENTER_NOTIFY_MASK EventMask = C.GDK_ENTER_NOTIFY_MASK - LEAVE_NOTIFY_MASK EventMask = C.GDK_LEAVE_NOTIFY_MASK - FOCUS_CHANGE_MASK EventMask = C.GDK_FOCUS_CHANGE_MASK - STRUCTURE_MASK EventMask = C.GDK_STRUCTURE_MASK - PROPERTY_CHANGE_MASK EventMask = C.GDK_PROPERTY_CHANGE_MASK - VISIBILITY_NOTIFY_MASK EventMask = C.GDK_VISIBILITY_NOTIFY_MASK - PROXIMITY_IN_MASK EventMask = C.GDK_PROXIMITY_IN_MASK - PROXIMITY_OUT_MASK EventMask = C.GDK_PROXIMITY_OUT_MASK - SUBSTRUCTURE_MASK EventMask = C.GDK_SUBSTRUCTURE_MASK - SCROLL_MASK EventMask = C.GDK_SCROLL_MASK - TOUCH_MASK EventMask = C.GDK_TOUCH_MASK - SMOOTH_SCROLL_MASK EventMask = C.GDK_SMOOTH_SCROLL_MASK - ALL_EVENTS_MASK EventMask = C.GDK_ALL_EVENTS_MASK -) - -func marshalEventMask(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return EventMask(c), nil -} - -// added by lazyshot -// ScrollDirection is a representation of GDK's GdkScrollDirection - -type ScrollDirection int - -const ( - SCROLL_UP ScrollDirection = C.GDK_SCROLL_UP - SCROLL_DOWN ScrollDirection = C.GDK_SCROLL_DOWN - SCROLL_LEFT ScrollDirection = C.GDK_SCROLL_LEFT - SCROLL_RIGHT ScrollDirection = C.GDK_SCROLL_RIGHT - SCROLL_SMOOTH ScrollDirection = C.GDK_SCROLL_SMOOTH -) - -// CURRENT_TIME is a representation of GDK_CURRENT_TIME - -const CURRENT_TIME = C.GDK_CURRENT_TIME - -// GrabStatus is a representation of GdkGrabStatus - -type GrabStatus int - -const ( - GRAB_SUCCESS GrabStatus = C.GDK_GRAB_SUCCESS - GRAB_ALREADY_GRABBED GrabStatus = C.GDK_GRAB_ALREADY_GRABBED - GRAB_INVALID_TIME GrabStatus = C.GDK_GRAB_INVALID_TIME - GRAB_FROZEN GrabStatus = C.GDK_GRAB_FROZEN - // Only exists since 3.16 - // GRAB_FAILED GrabStatus = C.GDK_GRAB_FAILED - GRAB_FAILED GrabStatus = 5 -) - -// GrabOwnership is a representation of GdkGrabOwnership - -type GrabOwnership int - -const ( - OWNERSHIP_NONE GrabOwnership = C.GDK_OWNERSHIP_NONE - OWNERSHIP_WINDOW GrabOwnership = C.GDK_OWNERSHIP_WINDOW - OWNERSHIP_APPLICATION GrabOwnership = C.GDK_OWNERSHIP_APPLICATION -) - -// DeviceType is a representation of GdkDeviceType - -type DeviceType int - -const ( - DEVICE_TYPE_MASTER DeviceType = C.GDK_DEVICE_TYPE_MASTER - DEVICE_TYPE_SLAVE DeviceType = C.GDK_DEVICE_TYPE_SLAVE - DEVICE_TYPE_FLOATING DeviceType = C.GDK_DEVICE_TYPE_FLOATING -) - -/* - * GdkAtom - */ - -// Atom is a representation of GDK's GdkAtom. -type Atom uintptr - -// native returns the underlying GdkAtom. -func (v Atom) native() C.GdkAtom { - return C.toGdkAtom(unsafe.Pointer(uintptr(v))) -} - -func (v Atom) Name() string { - c := C.gdk_atom_name(v.native()) - defer C.g_free(C.gpointer(c)) - return C.GoString((*C.char)(c)) -} - -// GdkAtomIntern is a wrapper around gdk_atom_intern -func GdkAtomIntern(atomName string, onlyIfExists bool) Atom { - cstr := C.CString(atomName) - defer C.free(unsafe.Pointer(cstr)) - c := C.gdk_atom_intern((*C.gchar)(cstr), gbool(onlyIfExists)) - return Atom(uintptr(unsafe.Pointer(c))) -} - -/* - * GdkDevice - */ - -// Device is a representation of GDK's GdkDevice. -type Device struct { - *glib.Object -} - -// native returns a pointer to the underlying GdkDevice. -func (v *Device) native() *C.GdkDevice { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGdkDevice(p) -} - -// Native returns a pointer to the underlying GdkDevice. -func (v *Device) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalDevice(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - return &Device{obj}, nil -} - -// Grab() is a wrapper around gdk_device_grab(). -func (v *Device) Grab(w *Window, ownership GrabOwnership, owner_events bool, event_mask EventMask, cursor *Cursor, time uint32) GrabStatus { - ret := C.gdk_device_grab( - v.native(), - w.native(), - C.GdkGrabOwnership(ownership), - gbool(owner_events), - C.GdkEventMask(event_mask), - cursor.native(), - C.guint32(time), - ) - return GrabStatus(ret) -} - -// Ungrab() is a wrapper around gdk_device_ungrab(). -func (v *Device) Ungrab(time uint32) { - C.gdk_device_ungrab(v.native(), C.guint32(time)) -} - -/* - * GdkCursor - */ - -// Cursor is a representation of GdkCursor. -type Cursor struct { - *glib.Object -} - -// native returns a pointer to the underlying GdkCursor. -func (v *Cursor) native() *C.GdkCursor { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGdkCursor(p) -} - -// Native returns a pointer to the underlying GdkCursor. -func (v *Cursor) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalCursor(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - return &Cursor{obj}, nil -} - -/* - * GdkDeviceManager - */ - -// DeviceManager is a representation of GDK's GdkDeviceManager. -type DeviceManager struct { - *glib.Object -} - -// native returns a pointer to the underlying GdkDeviceManager. -func (v *DeviceManager) native() *C.GdkDeviceManager { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGdkDeviceManager(p) -} - -// Native returns a pointer to the underlying GdkDeviceManager. -func (v *DeviceManager) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalDeviceManager(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - return &DeviceManager{obj}, nil -} - -// GetClientPointer() is a wrapper around gdk_device_manager_get_client_pointer(). -func (v *DeviceManager) GetClientPointer() (*Device, error) { - c := C.gdk_device_manager_get_client_pointer(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return &Device{obj}, nil -} - -// GetDisplay() is a wrapper around gdk_device_manager_get_display(). -func (v *DeviceManager) GetDisplay() (*Display, error) { - c := C.gdk_device_manager_get_display(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return &Display{obj}, nil -} - -// ListDevices() is a wrapper around gdk_device_manager_list_devices(). -func (v *DeviceManager) ListDevices(tp DeviceType) *glib.List { - clist := C.gdk_device_manager_list_devices(v.native(), C.GdkDeviceType(tp)) - if clist == nil { - return nil - } - glist := glib.WrapList(uintptr(unsafe.Pointer(clist))) - glist.DataWrapper(func(ptr unsafe.Pointer) interface{} { - return &Device{&glib.Object{glib.ToGObject(ptr)}} - }) - runtime.SetFinalizer(glist, func(glist *glib.List) { - glist.Free() - }) - return glist -} - -/* - * GdkDisplay - */ - -// Display is a representation of GDK's GdkDisplay. -type Display struct { - *glib.Object -} - -// native returns a pointer to the underlying GdkDisplay. -func (v *Display) native() *C.GdkDisplay { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGdkDisplay(p) -} - -// Native returns a pointer to the underlying GdkDisplay. -func (v *Display) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalDisplay(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - return &Display{obj}, nil -} - -func toDisplay(s *C.GdkDisplay) (*Display, error) { - if s == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(s))} - return &Display{obj}, nil -} - -// DisplayOpen() is a wrapper around gdk_display_open(). -func DisplayOpen(displayName string) (*Display, error) { - cstr := C.CString(displayName) - defer C.free(unsafe.Pointer(cstr)) - c := C.gdk_display_open((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - d := &Display{obj} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return d, nil -} - -// DisplayGetDefault() is a wrapper around gdk_display_get_default(). -func DisplayGetDefault() (*Display, error) { - c := C.gdk_display_get_default() - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - d := &Display{obj} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return d, nil -} - -// GetName() is a wrapper around gdk_display_get_name(). -func (v *Display) GetName() (string, error) { - c := C.gdk_display_get_name(v.native()) - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// GetScreen() is a wrapper around gdk_display_get_screen(). -func (v *Display) GetScreen(screenNum int) (*Screen, error) { - c := C.gdk_display_get_screen(v.native(), C.gint(screenNum)) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - s := &Screen{obj} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return s, nil -} - -// GetDefaultScreen() is a wrapper around gdk_display_get_default_screen(). -func (v *Display) GetDefaultScreen() (*Screen, error) { - c := C.gdk_display_get_default_screen(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - s := &Screen{obj} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return s, nil -} - -// GetDeviceManager() is a wrapper around gdk_display_get_device_manager(). -func (v *Display) GetDeviceManager() (*DeviceManager, error) { - c := C.gdk_display_get_device_manager(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - d := &DeviceManager{obj} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return d, nil -} - -// DeviceIsGrabbed() is a wrapper around gdk_display_device_is_grabbed(). -func (v *Display) DeviceIsGrabbed(device *Device) bool { - c := C.gdk_display_device_is_grabbed(v.native(), device.native()) - return gobool(c) -} - -// Beep() is a wrapper around gdk_display_beep(). -func (v *Display) Beep() { - C.gdk_display_beep(v.native()) -} - -// Sync() is a wrapper around gdk_display_sync(). -func (v *Display) Sync() { - C.gdk_display_sync(v.native()) -} - -// Flush() is a wrapper around gdk_display_flush(). -func (v *Display) Flush() { - C.gdk_display_flush(v.native()) -} - -// Close() is a wrapper around gdk_display_close(). -func (v *Display) Close() { - C.gdk_display_close(v.native()) -} - -// IsClosed() is a wrapper around gdk_display_is_closed(). -func (v *Display) IsClosed() bool { - c := C.gdk_display_is_closed(v.native()) - return gobool(c) -} - -// GetEvent() is a wrapper around gdk_display_get_event(). -func (v *Display) GetEvent() (*Event, error) { - c := C.gdk_display_get_event(v.native()) - if c == nil { - return nil, nilPtrErr - } - e := &Event{c} - runtime.SetFinalizer(e, (*Event).free) - return e, nil -} - -// PeekEvent() is a wrapper around gdk_display_peek_event(). -func (v *Display) PeekEvent() (*Event, error) { - c := C.gdk_display_peek_event(v.native()) - if c == nil { - return nil, nilPtrErr - } - e := &Event{c} - runtime.SetFinalizer(e, (*Event).free) - return e, nil -} - -// PutEvent() is a wrapper around gdk_display_put_event(). -func (v *Display) PutEvent(event *Event) { - C.gdk_display_put_event(v.native(), event.native()) -} - -// HasPending() is a wrapper around gdk_display_has_pending(). -func (v *Display) HasPending() bool { - c := C.gdk_display_has_pending(v.native()) - return gobool(c) -} - -// SetDoubleClickTime() is a wrapper around gdk_display_set_double_click_time(). -func (v *Display) SetDoubleClickTime(msec uint) { - C.gdk_display_set_double_click_time(v.native(), C.guint(msec)) -} - -// SetDoubleClickDistance() is a wrapper around gdk_display_set_double_click_distance(). -func (v *Display) SetDoubleClickDistance(distance uint) { - C.gdk_display_set_double_click_distance(v.native(), C.guint(distance)) -} - -// SupportsColorCursor() is a wrapper around gdk_display_supports_cursor_color(). -func (v *Display) SupportsColorCursor() bool { - c := C.gdk_display_supports_cursor_color(v.native()) - return gobool(c) -} - -// SupportsCursorAlpha() is a wrapper around gdk_display_supports_cursor_alpha(). -func (v *Display) SupportsCursorAlpha() bool { - c := C.gdk_display_supports_cursor_alpha(v.native()) - return gobool(c) -} - -// GetDefaultCursorSize() is a wrapper around gdk_display_get_default_cursor_size(). -func (v *Display) GetDefaultCursorSize() uint { - c := C.gdk_display_get_default_cursor_size(v.native()) - return uint(c) -} - -// GetMaximalCursorSize() is a wrapper around gdk_display_get_maximal_cursor_size(). -func (v *Display) GetMaximalCursorSize() (width, height uint) { - var w, h C.guint - C.gdk_display_get_maximal_cursor_size(v.native(), &w, &h) - return uint(w), uint(h) -} - -// GetDefaultGroup() is a wrapper around gdk_display_get_default_group(). -func (v *Display) GetDefaultGroup() (*Window, error) { - c := C.gdk_display_get_default_group(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - w := &Window{obj} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return w, nil -} - -// SupportsSelectionNotification() is a wrapper around -// gdk_display_supports_selection_notification(). -func (v *Display) SupportsSelectionNotification() bool { - c := C.gdk_display_supports_selection_notification(v.native()) - return gobool(c) -} - -// RequestSelectionNotification() is a wrapper around -// gdk_display_request_selection_notification(). -func (v *Display) RequestSelectionNotification(selection Atom) bool { - c := C.gdk_display_request_selection_notification(v.native(), - selection.native()) - return gobool(c) -} - -// SupportsClipboardPersistence() is a wrapper around -// gdk_display_supports_clipboard_persistence(). -func (v *Display) SupportsClipboardPersistence() bool { - c := C.gdk_display_supports_clipboard_persistence(v.native()) - return gobool(c) -} - -// TODO(jrick) -func (v *Display) StoreClipboard(clipboardWindow *Window, time uint32, targets ...Atom) { -} - -// SupportsShapes() is a wrapper around gdk_display_supports_shapes(). -func (v *Display) SupportsShapes() bool { - c := C.gdk_display_supports_shapes(v.native()) - return gobool(c) -} - -// SupportsInputShapes() is a wrapper around gdk_display_supports_input_shapes(). -func (v *Display) SupportsInputShapes() bool { - c := C.gdk_display_supports_input_shapes(v.native()) - return gobool(c) -} - -// TODO(jrick) glib.AppLaunchContext GdkAppLaunchContext -func (v *Display) GetAppLaunchContext() { -} - -// NotifyStartupComplete() is a wrapper around gdk_display_notify_startup_complete(). -func (v *Display) NotifyStartupComplete(startupID string) { - cstr := C.CString(startupID) - defer C.free(unsafe.Pointer(cstr)) - C.gdk_display_notify_startup_complete(v.native(), (*C.gchar)(cstr)) -} - -// EventType is a representation of GDK's GdkEventType. -// Do not confuse these event types with the signals that GTK+ widgets emit -type EventType int - -func marshalEventType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return EventType(c), nil -} - -const ( - EVENT_NOTHING EventType = C.GDK_NOTHING - EVENT_DELETE EventType = C.GDK_DELETE - EVENT_DESTROY EventType = C.GDK_DESTROY - EVENT_EXPOSE EventType = C.GDK_EXPOSE - EVENT_MOTION_NOTIFY EventType = C.GDK_MOTION_NOTIFY - EVENT_BUTTON_PRESS EventType = C.GDK_BUTTON_PRESS - EVENT_2BUTTON_PRESS EventType = C.GDK_2BUTTON_PRESS - EVENT_DOUBLE_BUTTON_PRESS EventType = C.GDK_DOUBLE_BUTTON_PRESS - EVENT_3BUTTON_PRESS EventType = C.GDK_3BUTTON_PRESS - EVENT_TRIPLE_BUTTON_PRESS EventType = C.GDK_TRIPLE_BUTTON_PRESS - EVENT_BUTTON_RELEASE EventType = C.GDK_BUTTON_RELEASE - EVENT_KEY_PRESS EventType = C.GDK_KEY_PRESS - EVENT_KEY_RELEASE EventType = C.GDK_KEY_RELEASE - EVENT_LEAVE_NOTIFY EventType = C.GDK_ENTER_NOTIFY - EVENT_FOCUS_CHANGE EventType = C.GDK_FOCUS_CHANGE - EVENT_CONFIGURE EventType = C.GDK_CONFIGURE - EVENT_MAP EventType = C.GDK_MAP - EVENT_UNMAP EventType = C.GDK_UNMAP - EVENT_PROPERTY_NOTIFY EventType = C.GDK_PROPERTY_NOTIFY - EVENT_SELECTION_CLEAR EventType = C.GDK_SELECTION_CLEAR - EVENT_SELECTION_REQUEST EventType = C.GDK_SELECTION_REQUEST - EVENT_SELECTION_NOTIFY EventType = C.GDK_SELECTION_NOTIFY - EVENT_PROXIMITY_IN EventType = C.GDK_PROXIMITY_IN - EVENT_PROXIMITY_OUT EventType = C.GDK_PROXIMITY_OUT - EVENT_DRAG_ENTER EventType = C.GDK_DRAG_ENTER - EVENT_DRAG_LEAVE EventType = C.GDK_DRAG_LEAVE - EVENT_DRAG_MOTION EventType = C.GDK_DRAG_MOTION - EVENT_DRAG_STATUS EventType = C.GDK_DRAG_STATUS - EVENT_DROP_START EventType = C.GDK_DROP_START - EVENT_DROP_FINISHED EventType = C.GDK_DROP_FINISHED - EVENT_CLIENT_EVENT EventType = C.GDK_CLIENT_EVENT - EVENT_VISIBILITY_NOTIFY EventType = C.GDK_VISIBILITY_NOTIFY - EVENT_SCROLL EventType = C.GDK_SCROLL - EVENT_WINDOW_STATE EventType = C.GDK_WINDOW_STATE - EVENT_SETTING EventType = C.GDK_SETTING - EVENT_OWNER_CHANGE EventType = C.GDK_OWNER_CHANGE - EVENT_GRAB_BROKEN EventType = C.GDK_GRAB_BROKEN - EVENT_DAMAGE EventType = C.GDK_DAMAGE - EVENT_TOUCH_BEGIN EventType = C.GDK_TOUCH_BEGIN - EVENT_TOUCH_UPDATE EventType = C.GDK_TOUCH_UPDATE - EVENT_TOUCH_END EventType = C.GDK_TOUCH_END - EVENT_TOUCH_CANCEL EventType = C.GDK_TOUCH_CANCEL - EVENT_LAST EventType = C.GDK_EVENT_LAST -) - -/* - * GDK Keyval - */ - -// KeyvalFromName() is a wrapper around gdk_keyval_from_name(). -func KeyvalFromName(keyvalName string) uint { - str := (*C.gchar)(C.CString(keyvalName)) - defer C.free(unsafe.Pointer(str)) - return uint(C.gdk_keyval_from_name(str)) -} - -func KeyvalConvertCase(v uint) (lower, upper uint) { - var l, u C.guint - l = 0 - u = 0 - C.gdk_keyval_convert_case(C.guint(v), &l, &u) - return uint(l), uint(u) -} - -func KeyvalIsLower(v uint) bool { - return gobool(C.gdk_keyval_is_lower(C.guint(v))) -} - -func KeyvalIsUpper(v uint) bool { - return gobool(C.gdk_keyval_is_upper(C.guint(v))) -} - -func KeyvalToLower(v uint) uint { - return uint(C.gdk_keyval_to_lower(C.guint(v))) -} - -func KeyvalToUpper(v uint) uint { - return uint(C.gdk_keyval_to_upper(C.guint(v))) -} - -/* - * GdkDragContext - */ - -// DragContext is a representation of GDK's GdkDragContext. -type DragContext struct { - *glib.Object -} - -// native returns a pointer to the underlying GdkDragContext. -func (v *DragContext) native() *C.GdkDragContext { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGdkDragContext(p) -} - -// Native returns a pointer to the underlying GdkDragContext. -func (v *DragContext) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalDragContext(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - return &DragContext{obj}, nil -} - -func (v *DragContext) ListTargets() *glib.List { - c := C.gdk_drag_context_list_targets(v.native()) - return glib.WrapList(uintptr(unsafe.Pointer(c))) -} - -/* - * GdkEvent - */ - -// Event is a representation of GDK's GdkEvent. -type Event struct { - GdkEvent *C.GdkEvent -} - -// native returns a pointer to the underlying GdkEvent. -func (v *Event) native() *C.GdkEvent { - if v == nil { - return nil - } - return v.GdkEvent -} - -// Native returns a pointer to the underlying GdkEvent. -func (v *Event) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalEvent(p uintptr) (interface{}, error) { - c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) - return &Event{(*C.GdkEvent)(unsafe.Pointer(c))}, nil -} - -func (v *Event) free() { - C.gdk_event_free(v.native()) -} - -/* - * GdkEventButton - */ - -// EventButton is a representation of GDK's GdkEventButton. -type EventButton struct { - *Event -} - -// Native returns a pointer to the underlying GdkEventButton. -func (v *EventButton) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *EventButton) native() *C.GdkEventButton { - return (*C.GdkEventButton)(unsafe.Pointer(v.Event.native())) -} - -func (v *EventButton) X() float64 { - c := v.native().x - return float64(c) -} - -func (v *EventButton) Y() float64 { - c := v.native().y - return float64(c) -} - -// XRoot returns the x coordinate of the pointer relative to the root of the screen. -func (v *EventButton) XRoot() float64 { - c := v.native().x_root - return float64(c) -} - -// YRoot returns the y coordinate of the pointer relative to the root of the screen. -func (v *EventButton) YRoot() float64 { - c := v.native().y_root - return float64(c) -} - -func (v *EventButton) Button() uint { - c := v.native().button - return uint(c) -} - -func (v *EventButton) State() uint { - c := v.native().state - return uint(c) -} - -// Time returns the time of the event in milliseconds. -func (v *EventButton) Time() uint32 { - c := v.native().time - return uint32(c) -} - -func (v *EventButton) Type() EventType { - c := v.native()._type - return EventType(c) -} - -func (v *EventButton) MotionVal() (float64, float64) { - x := v.native().x - y := v.native().y - return float64(x), float64(y) -} - -func (v *EventButton) MotionValRoot() (float64, float64) { - x := v.native().x_root - y := v.native().y_root - return float64(x), float64(y) -} - -func (v *EventButton) ButtonVal() uint { - c := v.native().button - return uint(c) -} - -/* - * GdkEventKey - */ - -// EventKey is a representation of GDK's GdkEventKey. -type EventKey struct { - *Event -} - -func EventKeyNew() *EventKey { - ee := (*C.GdkEvent)(unsafe.Pointer(&C.GdkEventKey{})) - ev := Event{ee} - return &EventKey{&ev} -} - -// Native returns a pointer to the underlying GdkEventKey. -func (v *EventKey) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *EventKey) native() *C.GdkEventKey { - return (*C.GdkEventKey)(unsafe.Pointer(v.Event.native())) -} - -func (v *EventKey) KeyVal() uint { - c := v.native().keyval - return uint(c) -} - -func (v *EventKey) Type() EventType { - c := v.native()._type - return EventType(c) -} - -func (v *EventKey) State() uint { - c := v.native().state - return uint(c) -} - -/* - * GdkEventMotion - */ - -type EventMotion struct { - *Event -} - -// Native returns a pointer to the underlying GdkEventMotion. -func (v *EventMotion) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *EventMotion) native() *C.GdkEventMotion { - return (*C.GdkEventMotion)(unsafe.Pointer(v.Event.native())) -} - -func (v *EventMotion) MotionVal() (float64, float64) { - x := v.native().x - y := v.native().y - return float64(x), float64(y) -} - -func (v *EventMotion) MotionValRoot() (float64, float64) { - x := v.native().x_root - y := v.native().y_root - return float64(x), float64(y) -} - -/* - * GdkEventScroll - */ - -// EventScroll is a representation of GDK's GdkEventScroll. -type EventScroll struct { - *Event -} - -// Native returns a pointer to the underlying GdkEventScroll. -func (v *EventScroll) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *EventScroll) native() *C.GdkEventScroll { - return (*C.GdkEventScroll)(unsafe.Pointer(v.Event.native())) -} - -func (v *EventScroll) DeltaX() float64 { - return float64(v.native().delta_x) -} - -func (v *EventScroll) DeltaY() float64 { - return float64(v.native().delta_y) -} - -func (v *EventScroll) X() float64 { - return float64(v.native().x) -} - -func (v *EventScroll) Y() float64 { - return float64(v.native().y) -} - -func (v *EventScroll) Type() EventType { - c := v.native()._type - return EventType(c) -} - -func (v *EventScroll) Direction() ScrollDirection { - c := v.native().direction - return ScrollDirection(c) -} - -/* - * GdkGravity - */ -type GdkGravity int - -const ( - GDK_GRAVITY_NORTH_WEST = C.GDK_GRAVITY_NORTH_WEST - GDK_GRAVITY_NORTH = C.GDK_GRAVITY_NORTH - GDK_GRAVITY_NORTH_EAST = C.GDK_GRAVITY_NORTH_EAST - GDK_GRAVITY_WEST = C.GDK_GRAVITY_WEST - GDK_GRAVITY_CENTER = C.GDK_GRAVITY_CENTER - GDK_GRAVITY_EAST = C.GDK_GRAVITY_EAST - GDK_GRAVITY_SOUTH_WEST = C.GDK_GRAVITY_SOUTH_WEST - GDK_GRAVITY_SOUTH = C.GDK_GRAVITY_SOUTH - GDK_GRAVITY_SOUTH_EAST = C.GDK_GRAVITY_SOUTH_EAST - GDK_GRAVITY_STATIC = C.GDK_GRAVITY_STATIC -) - -/* - * GdkPixbuf - */ - -// Pixbuf is a representation of GDK's GdkPixbuf. -type Pixbuf struct { - *glib.Object -} - -// native returns a pointer to the underlying GdkPixbuf. -func (v *Pixbuf) native() *C.GdkPixbuf { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGdkPixbuf(p) -} - -// Native returns a pointer to the underlying GdkPixbuf. -func (v *Pixbuf) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalPixbuf(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - return &Pixbuf{obj}, nil -} - -// GetColorspace is a wrapper around gdk_pixbuf_get_colorspace(). -func (v *Pixbuf) GetColorspace() Colorspace { - c := C.gdk_pixbuf_get_colorspace(v.native()) - return Colorspace(c) -} - -// GetNChannels is a wrapper around gdk_pixbuf_get_n_channels(). -func (v *Pixbuf) GetNChannels() int { - c := C.gdk_pixbuf_get_n_channels(v.native()) - return int(c) -} - -// GetHasAlpha is a wrapper around gdk_pixbuf_get_has_alpha(). -func (v *Pixbuf) GetHasAlpha() bool { - c := C.gdk_pixbuf_get_has_alpha(v.native()) - return gobool(c) -} - -// GetBitsPerSample is a wrapper around gdk_pixbuf_get_bits_per_sample(). -func (v *Pixbuf) GetBitsPerSample() int { - c := C.gdk_pixbuf_get_bits_per_sample(v.native()) - return int(c) -} - -// GetPixels is a wrapper around gdk_pixbuf_get_pixels_with_length(). -// A Go slice is used to represent the underlying Pixbuf data array, one -// byte per channel. -func (v *Pixbuf) GetPixels() (channels []byte) { - var length C.guint - c := C.gdk_pixbuf_get_pixels_with_length(v.native(), &length) - sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&channels)) - sliceHeader.Data = uintptr(unsafe.Pointer(c)) - sliceHeader.Len = int(length) - sliceHeader.Cap = int(length) - // To make sure the slice doesn't outlive the Pixbuf, add a reference - v.Ref() - runtime.SetFinalizer(&channels, func(_ *[]byte) { - v.Unref() - }) - return -} - -// GetWidth is a wrapper around gdk_pixbuf_get_width(). -func (v *Pixbuf) GetWidth() int { - c := C.gdk_pixbuf_get_width(v.native()) - return int(c) -} - -// GetHeight is a wrapper around gdk_pixbuf_get_height(). -func (v *Pixbuf) GetHeight() int { - c := C.gdk_pixbuf_get_height(v.native()) - return int(c) -} - -// GetRowstride is a wrapper around gdk_pixbuf_get_rowstride(). -func (v *Pixbuf) GetRowstride() int { - c := C.gdk_pixbuf_get_rowstride(v.native()) - return int(c) -} - -// GetByteLength is a wrapper around gdk_pixbuf_get_byte_length(). -func (v *Pixbuf) GetByteLength() int { - c := C.gdk_pixbuf_get_byte_length(v.native()) - return int(c) -} - -// GetOption is a wrapper around gdk_pixbuf_get_option(). ok is true if -// the key has an associated value. -func (v *Pixbuf) GetOption(key string) (value string, ok bool) { - cstr := C.CString(key) - defer C.free(unsafe.Pointer(cstr)) - c := C.gdk_pixbuf_get_option(v.native(), (*C.gchar)(cstr)) - if c == nil { - return "", false - } - return C.GoString((*C.char)(c)), true -} - -// PixbufNew is a wrapper around gdk_pixbuf_new(). -func PixbufNew(colorspace Colorspace, hasAlpha bool, bitsPerSample, width, height int) (*Pixbuf, error) { - c := C.gdk_pixbuf_new(C.GdkColorspace(colorspace), gbool(hasAlpha), - C.int(bitsPerSample), C.int(width), C.int(height)) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - p := &Pixbuf{obj} - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return p, nil -} - -// PixbufCopy is a wrapper around gdk_pixbuf_copy(). -func PixbufCopy(v *Pixbuf) (*Pixbuf, error) { - c := C.gdk_pixbuf_copy(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - p := &Pixbuf{obj} - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return p, nil -} - -// PixbufNewFromFile is a wrapper around gdk_pixbuf_new_from_file(). -func PixbufNewFromFile(filename string) (*Pixbuf, error) { - cstr := C.CString(filename) - defer C.free(unsafe.Pointer(cstr)) - var err *C.GError - res := C.gdk_pixbuf_new_from_file((*C.char)(cstr), &err) - if res == nil { - defer C.g_error_free(err) - return nil, errors.New(C.GoString((*C.char)(err.message))) - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(res))} - p := &Pixbuf{obj} - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return p, nil -} - -// PixbufNewFromFileAtSize is a wrapper around gdk_pixbuf_new_from_file_at_size(). -func PixbufNewFromFileAtSize(filename string, width, height int) (*Pixbuf, error) { - cstr := C.CString(filename) - defer C.free(unsafe.Pointer(cstr)) - var err *C.GError = nil - res := C.gdk_pixbuf_new_from_file_at_size(cstr, C.int(width), C.int(height), &err) - if err != nil { - defer C.g_error_free(err) - return nil, errors.New(C.GoString((*C.char)(err.message))) - } - if res == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(res))} - p := &Pixbuf{obj} - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return p, nil -} - -// PixbufNewFromFileAtScale is a wrapper around gdk_pixbuf_new_from_file_at_scale(). -func PixbufNewFromFileAtScale(filename string, width, height int, preserveAspectRatio bool) (*Pixbuf, error) { - cstr := C.CString(filename) - defer C.free(unsafe.Pointer(cstr)) - var err *C.GError = nil - res := C.gdk_pixbuf_new_from_file_at_scale(cstr, C.int(width), C.int(height), - gbool(preserveAspectRatio), &err) - if err != nil { - defer C.g_error_free(err) - return nil, errors.New(C.GoString((*C.char)(err.message))) - } - if res == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(res))} - p := &Pixbuf{obj} - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return p, nil -} - -// ScaleSimple is a wrapper around gdk_pixbuf_scale_simple(). -func (v *Pixbuf) ScaleSimple(destWidth, destHeight int, interpType InterpType) (*Pixbuf, error) { - c := C.gdk_pixbuf_scale_simple(v.native(), C.int(destWidth), - C.int(destHeight), C.GdkInterpType(interpType)) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - p := &Pixbuf{obj} - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return p, nil -} - -// RotateSimple is a wrapper around gdk_pixbuf_rotate_simple(). -func (v *Pixbuf) RotateSimple(angle PixbufRotation) (*Pixbuf, error) { - c := C.gdk_pixbuf_rotate_simple(v.native(), C.GdkPixbufRotation(angle)) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - p := &Pixbuf{obj} - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return p, nil -} - -// ApplyEmbeddedOrientation is a wrapper around gdk_pixbuf_apply_embedded_orientation(). -func (v *Pixbuf) ApplyEmbeddedOrientation() (*Pixbuf, error) { - c := C.gdk_pixbuf_apply_embedded_orientation(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - p := &Pixbuf{obj} - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return p, nil -} - -// Flip is a wrapper around gdk_pixbuf_flip(). -func (v *Pixbuf) Flip(horizontal bool) (*Pixbuf, error) { - c := C.gdk_pixbuf_flip(v.native(), gbool(horizontal)) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - p := &Pixbuf{obj} - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return p, nil -} - -// SaveJPEG is a wrapper around gdk_pixbuf_save(). -// Quality is a number between 0...100 -func (v *Pixbuf) SaveJPEG(path string, quality int) error { - cpath := C.CString(path) - cquality := C.CString(strconv.Itoa(quality)) - defer C.free(unsafe.Pointer(cpath)) - defer C.free(unsafe.Pointer(cquality)) - - var err *C.GError - c := C._gdk_pixbuf_save_jpeg(v.native(), cpath, &err, cquality) - if !gobool(c) { - defer C.g_error_free(err) - return errors.New(C.GoString((*C.char)(err.message))) - } - return nil -} - -// SavePNG is a wrapper around gdk_pixbuf_save(). -// Compression is a number between 0...9 -func (v *Pixbuf) SavePNG(path string, compression int) error { - cpath := C.CString(path) - ccompression := C.CString(strconv.Itoa(compression)) - defer C.free(unsafe.Pointer(cpath)) - defer C.free(unsafe.Pointer(ccompression)) - - var err *C.GError - c := C._gdk_pixbuf_save_png(v.native(), cpath, &err, ccompression) - if !gobool(c) { - defer C.g_error_free(err) - return errors.New(C.GoString((*C.char)(err.message))) - } - return nil -} - -// PixbufGetFileInfo is a wrapper around gdk_pixbuf_get_file_info(). -// TODO: need to wrap the returned format to GdkPixbufFormat. -func PixbufGetFileInfo(filename string) (format interface{}, width, height int) { - cstr := C.CString(filename) - defer C.free(unsafe.Pointer(cstr)) - var cw, ch C.gint - format = C.gdk_pixbuf_get_file_info((*C.gchar)(cstr), &cw, &ch) - // TODO: need to wrap the returned format to GdkPixbufFormat. - return format, int(cw), int(ch) -} - -/* - * GdkPixbufLoader - */ - -// PixbufLoader is a representation of GDK's GdkPixbufLoader. -// Users of PixbufLoader are expected to call Close() when they are finished. -type PixbufLoader struct { - *glib.Object -} - -// native() returns a pointer to the underlying GdkPixbufLoader. -func (v *PixbufLoader) native() *C.GdkPixbufLoader { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGdkPixbufLoader(p) -} - -// PixbufLoaderNew() is a wrapper around gdk_pixbuf_loader_new(). -func PixbufLoaderNew() (*PixbufLoader, error) { - c := C.gdk_pixbuf_loader_new() - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - p := &PixbufLoader{obj} - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return p, nil -} - -// Write() is a wrapper around gdk_pixbuf_loader_write(). The -// function signature differs from the C equivalent to satisify the -// io.Writer interface. -func (v *PixbufLoader) Write(data []byte) (int, error) { - // n is set to 0 on error, and set to len(data) otherwise. - // This is a tiny hacky to satisfy io.Writer and io.WriteCloser, - // which would allow access to all io and ioutil goodies, - // and play along nice with go environment. - - if len(data) == 0 { - return 0, nil - } - - var err *C.GError - c := C.gdk_pixbuf_loader_write(v.native(), - (*C.guchar)(unsafe.Pointer(&data[0])), C.gsize(len(data)), - &err) - if !gobool(c) { - defer C.g_error_free(err) - return 0, errors.New(C.GoString((*C.char)(err.message))) - } - - return len(data), nil -} - -// Close is a wrapper around gdk_pixbuf_loader_close(). An error is -// returned instead of a bool like the native C function to support the -// io.Closer interface. -func (v *PixbufLoader) Close() error { - var err *C.GError - - if ok := gobool(C.gdk_pixbuf_loader_close(v.native(), &err)); !ok { - defer C.g_error_free(err) - return errors.New(C.GoString((*C.char)(err.message))) - } - return nil -} - -// SetSize is a wrapper around gdk_pixbuf_loader_set_size(). -func (v *PixbufLoader) SetSize(width, height int) { - C.gdk_pixbuf_loader_set_size(v.native(), C.int(width), C.int(height)) -} - -// GetPixbuf is a wrapper around gdk_pixbuf_loader_get_pixbuf(). -func (v *PixbufLoader) GetPixbuf() (*Pixbuf, error) { - c := C.gdk_pixbuf_loader_get_pixbuf(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - p := &Pixbuf{obj} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return p, nil -} - -type RGBA struct { - rgba *C.GdkRGBA -} - -func marshalRGBA(p uintptr) (interface{}, error) { - c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) - c2 := (*C.GdkRGBA)(unsafe.Pointer(c)) - return wrapRGBA(c2), nil -} - -func wrapRGBA(obj *C.GdkRGBA) *RGBA { - return &RGBA{obj} -} - -func NewRGBA(values ...float64) *RGBA { - cval := C.GdkRGBA{} - c := &RGBA{&cval} - if len(values) > 0 { - c.rgba.red = C.gdouble(values[0]) - } - if len(values) > 1 { - c.rgba.green = C.gdouble(values[1]) - } - if len(values) > 2 { - c.rgba.blue = C.gdouble(values[2]) - } - if len(values) > 3 { - c.rgba.alpha = C.gdouble(values[3]) - } - return c -} - -func (c *RGBA) Floats() []float64 { - return []float64{float64(c.rgba.red), float64(c.rgba.green), float64(c.rgba.blue), float64(c.rgba.alpha)} -} - -func (v *RGBA) Native() uintptr { - return uintptr(unsafe.Pointer(v.rgba)) -} - -// Parse is a representation of gdk_rgba_parse(). -func (v *RGBA) Parse(spec string) bool { - cstr := (*C.gchar)(C.CString(spec)) - defer C.free(unsafe.Pointer(cstr)) - - return gobool(C.gdk_rgba_parse(v.rgba, cstr)) -} - -// String is a representation of gdk_rgba_to_string(). -func (v *RGBA) String() string { - return C.GoString((*C.char)(C.gdk_rgba_to_string(v.rgba))) -} - -// GdkRGBA * gdk_rgba_copy () -// void gdk_rgba_free () -// gboolean gdk_rgba_equal () -// guint gdk_rgba_hash () - -// PixbufGetType is a wrapper around gdk_pixbuf_get_type(). -func PixbufGetType() glib.Type { - return glib.Type(C.gdk_pixbuf_get_type()) -} - -/* - * GdkRectangle - */ - -// Rectangle is a representation of GDK's GdkRectangle type. -type Rectangle struct { - GdkRectangle C.GdkRectangle -} - -func WrapRectangle(p uintptr) *Rectangle { - return wrapRectangle((*C.GdkRectangle)(unsafe.Pointer(p))) -} - -func wrapRectangle(obj *C.GdkRectangle) *Rectangle { - if obj == nil { - return nil - } - return &Rectangle{*obj} -} - -// Native() returns a pointer to the underlying GdkRectangle. -func (r *Rectangle) native() *C.GdkRectangle { - return &r.GdkRectangle -} - -// GetX returns x field of the underlying GdkRectangle. -func (r *Rectangle) GetX() int { - return int(r.native().x) -} - -// GetY returns y field of the underlying GdkRectangle. -func (r *Rectangle) GetY() int { - return int(r.native().y) -} - -// GetWidth returns width field of the underlying GdkRectangle. -func (r *Rectangle) GetWidth() int { - return int(r.native().width) -} - -// GetHeight returns height field of the underlying GdkRectangle. -func (r *Rectangle) GetHeight() int { - return int(r.native().height) -} - -/* - * GdkVisual - */ - -// Visual is a representation of GDK's GdkVisual. -type Visual struct { - *glib.Object -} - -func (v *Visual) native() *C.GdkVisual { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGdkVisual(p) -} - -func (v *Visual) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalVisual(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - return &Visual{obj}, nil -} - -/* - * GdkWindow - */ - -// Window is a representation of GDK's GdkWindow. -type Window struct { - *glib.Object -} - -// native returns a pointer to the underlying GdkWindow. -func (v *Window) native() *C.GdkWindow { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGdkWindow(p) -} - -// Native returns a pointer to the underlying GdkWindow. -func (v *Window) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalWindow(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - return &Window{obj}, nil -} - -func toWindow(s *C.GdkWindow) (*Window, error) { - if s == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(s))} - return &Window{obj}, nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/gdk/gdk.go.h b/vendor/github.com/gotk3/gotk3.old/gdk/gdk.go.h deleted file mode 100644 index d0d7dca..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gdk/gdk.go.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2013-2014 Conformal Systems - * - * This file originated from: http://opensource.conformal.com/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -// Type Casting -static GdkAtom -toGdkAtom(void *p) -{ - return ((GdkAtom)p); -} - -static GdkDevice * -toGdkDevice(void *p) -{ - return (GDK_DEVICE(p)); -} - -static GdkCursor * -toGdkCursor(void *p) -{ - return (GDK_CURSOR(p)); -} - -static GdkDeviceManager * -toGdkDeviceManager(void *p) -{ - return (GDK_DEVICE_MANAGER(p)); -} - -static GdkDisplay * -toGdkDisplay(void *p) -{ - return (GDK_DISPLAY(p)); -} - -static GdkDragContext * -toGdkDragContext(void *p) -{ - return (GDK_DRAG_CONTEXT(p)); -} - -static GdkPixbuf * -toGdkPixbuf(void *p) -{ - return (GDK_PIXBUF(p)); -} - -static gboolean -_gdk_pixbuf_save_png(GdkPixbuf *pixbuf, -const char *filename, GError ** err, const char *compression) -{ - return gdk_pixbuf_save(pixbuf, filename, "png", err, "compression", compression, NULL); -} - -static gboolean -_gdk_pixbuf_save_jpeg(GdkPixbuf *pixbuf, -const char *filename, GError ** err, const char *quality) -{ - return gdk_pixbuf_save(pixbuf, filename, "jpeg", err, "quality", quality, NULL); -} - -static GdkPixbufLoader * -toGdkPixbufLoader(void *p) -{ - return (GDK_PIXBUF_LOADER(p)); -} - -static GdkScreen * -toGdkScreen(void *p) -{ - return (GDK_SCREEN(p)); -} - -static GdkVisual * -toGdkVisual(void *p) -{ - return (GDK_VISUAL(p)); -} - -static GdkWindow * -toGdkWindow(void *p) -{ - return (GDK_WINDOW(p)); -} diff --git a/vendor/github.com/gotk3/gotk3.old/gdk/gdk_3_6-8.go b/vendor/github.com/gotk3/gotk3.old/gdk/gdk_3_6-8.go deleted file mode 100644 index 7e06b93..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gdk/gdk_3_6-8.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// This file includes wrapers for symbols deprecated beginning with GTK 3.10, -// and should only be included in a build targeted intended to target GTK -// 3.8 or earlier. To target an earlier build build, use the build tag -// gtk_MAJOR_MINOR. For example, to target GTK 3.8, run -// 'go build -tags gtk_3_8'. -// +build gtk_3_6 gtk_3_8 - -package gdk - -// #cgo pkg-config: gdk-3.0 -// #include -import "C" - -// GetNScreens is a wrapper around gdk_display_get_n_screens(). -func (v *Display) GetNScreens() int { - c := C.gdk_display_get_n_screens(v.native()) - return int(c) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gdk/gdk_deprecated_since_3_16.go b/vendor/github.com/gotk3/gotk3.old/gdk/gdk_deprecated_since_3_16.go deleted file mode 100644 index b7d1ffe..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gdk/gdk_deprecated_since_3_16.go +++ /dev/null @@ -1,13 +0,0 @@ -//+build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14 - -package gdk - -// #cgo pkg-config: gdk-3.0 -// #include -import "C" - -// SupportsComposite() is a wrapper around gdk_display_supports_composite(). -func (v *Display) SupportsComposite() bool { - c := C.gdk_display_supports_composite(v.native()) - return gobool(c) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gdk/keys.go b/vendor/github.com/gotk3/gotk3.old/gdk/keys.go deleted file mode 100644 index 3f52a90..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gdk/keys.go +++ /dev/null @@ -1,2279 +0,0 @@ -package gdk - -// #cgo pkg-config: gdk-3.0 -// #include -// #include "gdk.go.h" -import "C" - -const ( - KEY_VoidSymbol = uint(C.GDK_KEY_VoidSymbol) - KEY_BackSpace = uint(C.GDK_KEY_BackSpace) - KEY_Tab = uint(C.GDK_KEY_Tab) - KEY_Linefeed = uint(C.GDK_KEY_Linefeed) - KEY_Clear = uint(C.GDK_KEY_Clear) - KEY_Return = uint(C.GDK_KEY_Return) - KEY_Pause = uint(C.GDK_KEY_Pause) - KEY_Scroll_Lock = uint(C.GDK_KEY_Scroll_Lock) - KEY_Sys_Req = uint(C.GDK_KEY_Sys_Req) - KEY_Escape = uint(C.GDK_KEY_Escape) - KEY_Delete = uint(C.GDK_KEY_Delete) - KEY_Multi_key = uint(C.GDK_KEY_Multi_key) - KEY_Codeinput = uint(C.GDK_KEY_Codeinput) - KEY_SingleCandidate = uint(C.GDK_KEY_SingleCandidate) - KEY_MultipleCandidate = uint(C.GDK_KEY_MultipleCandidate) - KEY_PreviousCandidate = uint(C.GDK_KEY_PreviousCandidate) - KEY_Kanji = uint(C.GDK_KEY_Kanji) - KEY_Muhenkan = uint(C.GDK_KEY_Muhenkan) - KEY_Henkan_Mode = uint(C.GDK_KEY_Henkan_Mode) - KEY_Henkan = uint(C.GDK_KEY_Henkan) - KEY_Romaji = uint(C.GDK_KEY_Romaji) - KEY_Hiragana = uint(C.GDK_KEY_Hiragana) - KEY_Katakana = uint(C.GDK_KEY_Katakana) - KEY_Hiragana_Katakana = uint(C.GDK_KEY_Hiragana_Katakana) - KEY_Zenkaku = uint(C.GDK_KEY_Zenkaku) - KEY_Hankaku = uint(C.GDK_KEY_Hankaku) - KEY_Zenkaku_Hankaku = uint(C.GDK_KEY_Zenkaku_Hankaku) - KEY_Touroku = uint(C.GDK_KEY_Touroku) - KEY_Massyo = uint(C.GDK_KEY_Massyo) - KEY_Kana_Lock = uint(C.GDK_KEY_Kana_Lock) - KEY_Kana_Shift = uint(C.GDK_KEY_Kana_Shift) - KEY_Eisu_Shift = uint(C.GDK_KEY_Eisu_Shift) - KEY_Eisu_toggle = uint(C.GDK_KEY_Eisu_toggle) - KEY_Kanji_Bangou = uint(C.GDK_KEY_Kanji_Bangou) - KEY_Zen_Koho = uint(C.GDK_KEY_Zen_Koho) - KEY_Mae_Koho = uint(C.GDK_KEY_Mae_Koho) - KEY_Home = uint(C.GDK_KEY_Home) - KEY_Left = uint(C.GDK_KEY_Left) - KEY_Up = uint(C.GDK_KEY_Up) - KEY_Right = uint(C.GDK_KEY_Right) - KEY_Down = uint(C.GDK_KEY_Down) - KEY_Prior = uint(C.GDK_KEY_Prior) - KEY_Page_Up = uint(C.GDK_KEY_Page_Up) - KEY_Next = uint(C.GDK_KEY_Next) - KEY_Page_Down = uint(C.GDK_KEY_Page_Down) - KEY_End = uint(C.GDK_KEY_End) - KEY_Begin = uint(C.GDK_KEY_Begin) - KEY_Select = uint(C.GDK_KEY_Select) - KEY_Print = uint(C.GDK_KEY_Print) - KEY_Execute = uint(C.GDK_KEY_Execute) - KEY_Insert = uint(C.GDK_KEY_Insert) - KEY_Undo = uint(C.GDK_KEY_Undo) - KEY_Redo = uint(C.GDK_KEY_Redo) - KEY_Menu = uint(C.GDK_KEY_Menu) - KEY_Find = uint(C.GDK_KEY_Find) - KEY_Cancel = uint(C.GDK_KEY_Cancel) - KEY_Help = uint(C.GDK_KEY_Help) - KEY_Break = uint(C.GDK_KEY_Break) - KEY_Mode_switch = uint(C.GDK_KEY_Mode_switch) - KEY_script_switch = uint(C.GDK_KEY_script_switch) - KEY_Num_Lock = uint(C.GDK_KEY_Num_Lock) - KEY_KP_Space = uint(C.GDK_KEY_KP_Space) - KEY_KP_Tab = uint(C.GDK_KEY_KP_Tab) - KEY_KP_Enter = uint(C.GDK_KEY_KP_Enter) - KEY_KP_F1 = uint(C.GDK_KEY_KP_F1) - KEY_KP_F2 = uint(C.GDK_KEY_KP_F2) - KEY_KP_F3 = uint(C.GDK_KEY_KP_F3) - KEY_KP_F4 = uint(C.GDK_KEY_KP_F4) - KEY_KP_Home = uint(C.GDK_KEY_KP_Home) - KEY_KP_Left = uint(C.GDK_KEY_KP_Left) - KEY_KP_Up = uint(C.GDK_KEY_KP_Up) - KEY_KP_Right = uint(C.GDK_KEY_KP_Right) - KEY_KP_Down = uint(C.GDK_KEY_KP_Down) - KEY_KP_Prior = uint(C.GDK_KEY_KP_Prior) - KEY_KP_Page_Up = uint(C.GDK_KEY_KP_Page_Up) - KEY_KP_Next = uint(C.GDK_KEY_KP_Next) - KEY_KP_Page_Down = uint(C.GDK_KEY_KP_Page_Down) - KEY_KP_End = uint(C.GDK_KEY_KP_End) - KEY_KP_Begin = uint(C.GDK_KEY_KP_Begin) - KEY_KP_Insert = uint(C.GDK_KEY_KP_Insert) - KEY_KP_Delete = uint(C.GDK_KEY_KP_Delete) - KEY_KP_Equal = uint(C.GDK_KEY_KP_Equal) - KEY_KP_Multiply = uint(C.GDK_KEY_KP_Multiply) - KEY_KP_Add = uint(C.GDK_KEY_KP_Add) - KEY_KP_Separator = uint(C.GDK_KEY_KP_Separator) - KEY_KP_Subtract = uint(C.GDK_KEY_KP_Subtract) - KEY_KP_Decimal = uint(C.GDK_KEY_KP_Decimal) - KEY_KP_Divide = uint(C.GDK_KEY_KP_Divide) - KEY_KP_0 = uint(C.GDK_KEY_KP_0) - KEY_KP_1 = uint(C.GDK_KEY_KP_1) - KEY_KP_2 = uint(C.GDK_KEY_KP_2) - KEY_KP_3 = uint(C.GDK_KEY_KP_3) - KEY_KP_4 = uint(C.GDK_KEY_KP_4) - KEY_KP_5 = uint(C.GDK_KEY_KP_5) - KEY_KP_6 = uint(C.GDK_KEY_KP_6) - KEY_KP_7 = uint(C.GDK_KEY_KP_7) - KEY_KP_8 = uint(C.GDK_KEY_KP_8) - KEY_KP_9 = uint(C.GDK_KEY_KP_9) - KEY_F1 = uint(C.GDK_KEY_F1) - KEY_F2 = uint(C.GDK_KEY_F2) - KEY_F3 = uint(C.GDK_KEY_F3) - KEY_F4 = uint(C.GDK_KEY_F4) - KEY_F5 = uint(C.GDK_KEY_F5) - KEY_F6 = uint(C.GDK_KEY_F6) - KEY_F7 = uint(C.GDK_KEY_F7) - KEY_F8 = uint(C.GDK_KEY_F8) - KEY_F9 = uint(C.GDK_KEY_F9) - KEY_F10 = uint(C.GDK_KEY_F10) - KEY_F11 = uint(C.GDK_KEY_F11) - KEY_L1 = uint(C.GDK_KEY_L1) - KEY_F12 = uint(C.GDK_KEY_F12) - KEY_L2 = uint(C.GDK_KEY_L2) - KEY_F13 = uint(C.GDK_KEY_F13) - KEY_L3 = uint(C.GDK_KEY_L3) - KEY_F14 = uint(C.GDK_KEY_F14) - KEY_L4 = uint(C.GDK_KEY_L4) - KEY_F15 = uint(C.GDK_KEY_F15) - KEY_L5 = uint(C.GDK_KEY_L5) - KEY_F16 = uint(C.GDK_KEY_F16) - KEY_L6 = uint(C.GDK_KEY_L6) - KEY_F17 = uint(C.GDK_KEY_F17) - KEY_L7 = uint(C.GDK_KEY_L7) - KEY_F18 = uint(C.GDK_KEY_F18) - KEY_L8 = uint(C.GDK_KEY_L8) - KEY_F19 = uint(C.GDK_KEY_F19) - KEY_L9 = uint(C.GDK_KEY_L9) - KEY_F20 = uint(C.GDK_KEY_F20) - KEY_L10 = uint(C.GDK_KEY_L10) - KEY_F21 = uint(C.GDK_KEY_F21) - KEY_R1 = uint(C.GDK_KEY_R1) - KEY_F22 = uint(C.GDK_KEY_F22) - KEY_R2 = uint(C.GDK_KEY_R2) - KEY_F23 = uint(C.GDK_KEY_F23) - KEY_R3 = uint(C.GDK_KEY_R3) - KEY_F24 = uint(C.GDK_KEY_F24) - KEY_R4 = uint(C.GDK_KEY_R4) - KEY_F25 = uint(C.GDK_KEY_F25) - KEY_R5 = uint(C.GDK_KEY_R5) - KEY_F26 = uint(C.GDK_KEY_F26) - KEY_R6 = uint(C.GDK_KEY_R6) - KEY_F27 = uint(C.GDK_KEY_F27) - KEY_R7 = uint(C.GDK_KEY_R7) - KEY_F28 = uint(C.GDK_KEY_F28) - KEY_R8 = uint(C.GDK_KEY_R8) - KEY_F29 = uint(C.GDK_KEY_F29) - KEY_R9 = uint(C.GDK_KEY_R9) - KEY_F30 = uint(C.GDK_KEY_F30) - KEY_R10 = uint(C.GDK_KEY_R10) - KEY_F31 = uint(C.GDK_KEY_F31) - KEY_R11 = uint(C.GDK_KEY_R11) - KEY_F32 = uint(C.GDK_KEY_F32) - KEY_R12 = uint(C.GDK_KEY_R12) - KEY_F33 = uint(C.GDK_KEY_F33) - KEY_R13 = uint(C.GDK_KEY_R13) - KEY_F34 = uint(C.GDK_KEY_F34) - KEY_R14 = uint(C.GDK_KEY_R14) - KEY_F35 = uint(C.GDK_KEY_F35) - KEY_R15 = uint(C.GDK_KEY_R15) - KEY_Shift_L = uint(C.GDK_KEY_Shift_L) - KEY_Shift_R = uint(C.GDK_KEY_Shift_R) - KEY_Control_L = uint(C.GDK_KEY_Control_L) - KEY_Control_R = uint(C.GDK_KEY_Control_R) - KEY_Caps_Lock = uint(C.GDK_KEY_Caps_Lock) - KEY_Shift_Lock = uint(C.GDK_KEY_Shift_Lock) - KEY_Meta_L = uint(C.GDK_KEY_Meta_L) - KEY_Meta_R = uint(C.GDK_KEY_Meta_R) - KEY_Alt_L = uint(C.GDK_KEY_Alt_L) - KEY_Alt_R = uint(C.GDK_KEY_Alt_R) - KEY_Super_L = uint(C.GDK_KEY_Super_L) - KEY_Super_R = uint(C.GDK_KEY_Super_R) - KEY_Hyper_L = uint(C.GDK_KEY_Hyper_L) - KEY_Hyper_R = uint(C.GDK_KEY_Hyper_R) - KEY_ISO_Lock = uint(C.GDK_KEY_ISO_Lock) - KEY_ISO_Level2_Latch = uint(C.GDK_KEY_ISO_Level2_Latch) - KEY_ISO_Level3_Shift = uint(C.GDK_KEY_ISO_Level3_Shift) - KEY_ISO_Level3_Latch = uint(C.GDK_KEY_ISO_Level3_Latch) - KEY_ISO_Level3_Lock = uint(C.GDK_KEY_ISO_Level3_Lock) - KEY_ISO_Level5_Shift = uint(C.GDK_KEY_ISO_Level5_Shift) - KEY_ISO_Level5_Latch = uint(C.GDK_KEY_ISO_Level5_Latch) - KEY_ISO_Level5_Lock = uint(C.GDK_KEY_ISO_Level5_Lock) - KEY_ISO_Group_Shift = uint(C.GDK_KEY_ISO_Group_Shift) - KEY_ISO_Group_Latch = uint(C.GDK_KEY_ISO_Group_Latch) - KEY_ISO_Group_Lock = uint(C.GDK_KEY_ISO_Group_Lock) - KEY_ISO_Next_Group = uint(C.GDK_KEY_ISO_Next_Group) - KEY_ISO_Next_Group_Lock = uint(C.GDK_KEY_ISO_Next_Group_Lock) - KEY_ISO_Prev_Group = uint(C.GDK_KEY_ISO_Prev_Group) - KEY_ISO_Prev_Group_Lock = uint(C.GDK_KEY_ISO_Prev_Group_Lock) - KEY_ISO_First_Group = uint(C.GDK_KEY_ISO_First_Group) - KEY_ISO_First_Group_Lock = uint(C.GDK_KEY_ISO_First_Group_Lock) - KEY_ISO_Last_Group = uint(C.GDK_KEY_ISO_Last_Group) - KEY_ISO_Last_Group_Lock = uint(C.GDK_KEY_ISO_Last_Group_Lock) - KEY_ISO_Left_Tab = uint(C.GDK_KEY_ISO_Left_Tab) - KEY_ISO_Move_Line_Up = uint(C.GDK_KEY_ISO_Move_Line_Up) - KEY_ISO_Move_Line_Down = uint(C.GDK_KEY_ISO_Move_Line_Down) - KEY_ISO_Partial_Line_Up = uint(C.GDK_KEY_ISO_Partial_Line_Up) - KEY_ISO_Partial_Line_Down = uint(C.GDK_KEY_ISO_Partial_Line_Down) - KEY_ISO_Partial_Space_Left = uint(C.GDK_KEY_ISO_Partial_Space_Left) - KEY_ISO_Partial_Space_Right = uint(C.GDK_KEY_ISO_Partial_Space_Right) - KEY_ISO_Set_Margin_Left = uint(C.GDK_KEY_ISO_Set_Margin_Left) - KEY_ISO_Set_Margin_Right = uint(C.GDK_KEY_ISO_Set_Margin_Right) - KEY_ISO_Release_Margin_Left = uint(C.GDK_KEY_ISO_Release_Margin_Left) - KEY_ISO_Release_Margin_Right = uint(C.GDK_KEY_ISO_Release_Margin_Right) - KEY_ISO_Release_Both_Margins = uint(C.GDK_KEY_ISO_Release_Both_Margins) - KEY_ISO_Fast_Cursor_Left = uint(C.GDK_KEY_ISO_Fast_Cursor_Left) - KEY_ISO_Fast_Cursor_Right = uint(C.GDK_KEY_ISO_Fast_Cursor_Right) - KEY_ISO_Fast_Cursor_Up = uint(C.GDK_KEY_ISO_Fast_Cursor_Up) - KEY_ISO_Fast_Cursor_Down = uint(C.GDK_KEY_ISO_Fast_Cursor_Down) - KEY_ISO_Continuous_Underline = uint(C.GDK_KEY_ISO_Continuous_Underline) - KEY_ISO_Discontinuous_Underline = uint(C.GDK_KEY_ISO_Discontinuous_Underline) - KEY_ISO_Emphasize = uint(C.GDK_KEY_ISO_Emphasize) - KEY_ISO_Center_Object = uint(C.GDK_KEY_ISO_Center_Object) - KEY_ISO_Enter = uint(C.GDK_KEY_ISO_Enter) - KEY_dead_grave = uint(C.GDK_KEY_dead_grave) - KEY_dead_acute = uint(C.GDK_KEY_dead_acute) - KEY_dead_circumflex = uint(C.GDK_KEY_dead_circumflex) - KEY_dead_tilde = uint(C.GDK_KEY_dead_tilde) - KEY_dead_perispomeni = uint(C.GDK_KEY_dead_perispomeni) - KEY_dead_macron = uint(C.GDK_KEY_dead_macron) - KEY_dead_breve = uint(C.GDK_KEY_dead_breve) - KEY_dead_abovedot = uint(C.GDK_KEY_dead_abovedot) - KEY_dead_diaeresis = uint(C.GDK_KEY_dead_diaeresis) - KEY_dead_abovering = uint(C.GDK_KEY_dead_abovering) - KEY_dead_doubleacute = uint(C.GDK_KEY_dead_doubleacute) - KEY_dead_caron = uint(C.GDK_KEY_dead_caron) - KEY_dead_cedilla = uint(C.GDK_KEY_dead_cedilla) - KEY_dead_ogonek = uint(C.GDK_KEY_dead_ogonek) - KEY_dead_iota = uint(C.GDK_KEY_dead_iota) - KEY_dead_voiced_sound = uint(C.GDK_KEY_dead_voiced_sound) - KEY_dead_semivoiced_sound = uint(C.GDK_KEY_dead_semivoiced_sound) - KEY_dead_belowdot = uint(C.GDK_KEY_dead_belowdot) - KEY_dead_hook = uint(C.GDK_KEY_dead_hook) - KEY_dead_horn = uint(C.GDK_KEY_dead_horn) - KEY_dead_stroke = uint(C.GDK_KEY_dead_stroke) - KEY_dead_abovecomma = uint(C.GDK_KEY_dead_abovecomma) - KEY_dead_psili = uint(C.GDK_KEY_dead_psili) - KEY_dead_abovereversedcomma = uint(C.GDK_KEY_dead_abovereversedcomma) - KEY_dead_dasia = uint(C.GDK_KEY_dead_dasia) - KEY_dead_doublegrave = uint(C.GDK_KEY_dead_doublegrave) - KEY_dead_belowring = uint(C.GDK_KEY_dead_belowring) - KEY_dead_belowmacron = uint(C.GDK_KEY_dead_belowmacron) - KEY_dead_belowcircumflex = uint(C.GDK_KEY_dead_belowcircumflex) - KEY_dead_belowtilde = uint(C.GDK_KEY_dead_belowtilde) - KEY_dead_belowbreve = uint(C.GDK_KEY_dead_belowbreve) - KEY_dead_belowdiaeresis = uint(C.GDK_KEY_dead_belowdiaeresis) - KEY_dead_invertedbreve = uint(C.GDK_KEY_dead_invertedbreve) - KEY_dead_belowcomma = uint(C.GDK_KEY_dead_belowcomma) - KEY_dead_currency = uint(C.GDK_KEY_dead_currency) - KEY_dead_a = uint(C.GDK_KEY_dead_a) - KEY_dead_A = uint(C.GDK_KEY_dead_A) - KEY_dead_e = uint(C.GDK_KEY_dead_e) - KEY_dead_E = uint(C.GDK_KEY_dead_E) - KEY_dead_i = uint(C.GDK_KEY_dead_i) - KEY_dead_I = uint(C.GDK_KEY_dead_I) - KEY_dead_o = uint(C.GDK_KEY_dead_o) - KEY_dead_O = uint(C.GDK_KEY_dead_O) - KEY_dead_u = uint(C.GDK_KEY_dead_u) - KEY_dead_U = uint(C.GDK_KEY_dead_U) - KEY_dead_small_schwa = uint(C.GDK_KEY_dead_small_schwa) - KEY_dead_capital_schwa = uint(C.GDK_KEY_dead_capital_schwa) - KEY_dead_greek = uint(C.GDK_KEY_dead_greek) - KEY_First_Virtual_Screen = uint(C.GDK_KEY_First_Virtual_Screen) - KEY_Prev_Virtual_Screen = uint(C.GDK_KEY_Prev_Virtual_Screen) - KEY_Next_Virtual_Screen = uint(C.GDK_KEY_Next_Virtual_Screen) - KEY_Last_Virtual_Screen = uint(C.GDK_KEY_Last_Virtual_Screen) - KEY_Terminate_Server = uint(C.GDK_KEY_Terminate_Server) - KEY_AccessX_Enable = uint(C.GDK_KEY_AccessX_Enable) - KEY_AccessX_Feedback_Enable = uint(C.GDK_KEY_AccessX_Feedback_Enable) - KEY_RepeatKeys_Enable = uint(C.GDK_KEY_RepeatKeys_Enable) - KEY_SlowKeys_Enable = uint(C.GDK_KEY_SlowKeys_Enable) - KEY_BounceKeys_Enable = uint(C.GDK_KEY_BounceKeys_Enable) - KEY_StickyKeys_Enable = uint(C.GDK_KEY_StickyKeys_Enable) - KEY_MouseKeys_Enable = uint(C.GDK_KEY_MouseKeys_Enable) - KEY_MouseKeys_Accel_Enable = uint(C.GDK_KEY_MouseKeys_Accel_Enable) - KEY_Overlay1_Enable = uint(C.GDK_KEY_Overlay1_Enable) - KEY_Overlay2_Enable = uint(C.GDK_KEY_Overlay2_Enable) - KEY_AudibleBell_Enable = uint(C.GDK_KEY_AudibleBell_Enable) - KEY_Pointer_Left = uint(C.GDK_KEY_Pointer_Left) - KEY_Pointer_Right = uint(C.GDK_KEY_Pointer_Right) - KEY_Pointer_Up = uint(C.GDK_KEY_Pointer_Up) - KEY_Pointer_Down = uint(C.GDK_KEY_Pointer_Down) - KEY_Pointer_UpLeft = uint(C.GDK_KEY_Pointer_UpLeft) - KEY_Pointer_UpRight = uint(C.GDK_KEY_Pointer_UpRight) - KEY_Pointer_DownLeft = uint(C.GDK_KEY_Pointer_DownLeft) - KEY_Pointer_DownRight = uint(C.GDK_KEY_Pointer_DownRight) - KEY_Pointer_Button_Dflt = uint(C.GDK_KEY_Pointer_Button_Dflt) - KEY_Pointer_Button1 = uint(C.GDK_KEY_Pointer_Button1) - KEY_Pointer_Button2 = uint(C.GDK_KEY_Pointer_Button2) - KEY_Pointer_Button3 = uint(C.GDK_KEY_Pointer_Button3) - KEY_Pointer_Button4 = uint(C.GDK_KEY_Pointer_Button4) - KEY_Pointer_Button5 = uint(C.GDK_KEY_Pointer_Button5) - KEY_Pointer_DblClick_Dflt = uint(C.GDK_KEY_Pointer_DblClick_Dflt) - KEY_Pointer_DblClick1 = uint(C.GDK_KEY_Pointer_DblClick1) - KEY_Pointer_DblClick2 = uint(C.GDK_KEY_Pointer_DblClick2) - KEY_Pointer_DblClick3 = uint(C.GDK_KEY_Pointer_DblClick3) - KEY_Pointer_DblClick4 = uint(C.GDK_KEY_Pointer_DblClick4) - KEY_Pointer_DblClick5 = uint(C.GDK_KEY_Pointer_DblClick5) - KEY_Pointer_Drag_Dflt = uint(C.GDK_KEY_Pointer_Drag_Dflt) - KEY_Pointer_Drag1 = uint(C.GDK_KEY_Pointer_Drag1) - KEY_Pointer_Drag2 = uint(C.GDK_KEY_Pointer_Drag2) - KEY_Pointer_Drag3 = uint(C.GDK_KEY_Pointer_Drag3) - KEY_Pointer_Drag4 = uint(C.GDK_KEY_Pointer_Drag4) - KEY_Pointer_Drag5 = uint(C.GDK_KEY_Pointer_Drag5) - KEY_Pointer_EnableKeys = uint(C.GDK_KEY_Pointer_EnableKeys) - KEY_Pointer_Accelerate = uint(C.GDK_KEY_Pointer_Accelerate) - KEY_Pointer_DfltBtnNext = uint(C.GDK_KEY_Pointer_DfltBtnNext) - KEY_Pointer_DfltBtnPrev = uint(C.GDK_KEY_Pointer_DfltBtnPrev) - KEY_ch = uint(C.GDK_KEY_ch) - KEY_Ch = uint(C.GDK_KEY_Ch) - KEY_CH = uint(C.GDK_KEY_CH) - KEY_c_h = uint(C.GDK_KEY_c_h) - KEY_C_h = uint(C.GDK_KEY_C_h) - KEY_C_H = uint(C.GDK_KEY_C_H) - KEY_3270_Duplicate = uint(C.GDK_KEY_3270_Duplicate) - KEY_3270_FieldMark = uint(C.GDK_KEY_3270_FieldMark) - KEY_3270_Right2 = uint(C.GDK_KEY_3270_Right2) - KEY_3270_Left2 = uint(C.GDK_KEY_3270_Left2) - KEY_3270_BackTab = uint(C.GDK_KEY_3270_BackTab) - KEY_3270_EraseEOF = uint(C.GDK_KEY_3270_EraseEOF) - KEY_3270_EraseInput = uint(C.GDK_KEY_3270_EraseInput) - KEY_3270_Reset = uint(C.GDK_KEY_3270_Reset) - KEY_3270_Quit = uint(C.GDK_KEY_3270_Quit) - KEY_3270_PA1 = uint(C.GDK_KEY_3270_PA1) - KEY_3270_PA2 = uint(C.GDK_KEY_3270_PA2) - KEY_3270_PA3 = uint(C.GDK_KEY_3270_PA3) - KEY_3270_Test = uint(C.GDK_KEY_3270_Test) - KEY_3270_Attn = uint(C.GDK_KEY_3270_Attn) - KEY_3270_CursorBlink = uint(C.GDK_KEY_3270_CursorBlink) - KEY_3270_AltCursor = uint(C.GDK_KEY_3270_AltCursor) - KEY_3270_KeyClick = uint(C.GDK_KEY_3270_KeyClick) - KEY_3270_Jump = uint(C.GDK_KEY_3270_Jump) - KEY_3270_Ident = uint(C.GDK_KEY_3270_Ident) - KEY_3270_Rule = uint(C.GDK_KEY_3270_Rule) - KEY_3270_Copy = uint(C.GDK_KEY_3270_Copy) - KEY_3270_Play = uint(C.GDK_KEY_3270_Play) - KEY_3270_Setup = uint(C.GDK_KEY_3270_Setup) - KEY_3270_Record = uint(C.GDK_KEY_3270_Record) - KEY_3270_ChangeScreen = uint(C.GDK_KEY_3270_ChangeScreen) - KEY_3270_DeleteWord = uint(C.GDK_KEY_3270_DeleteWord) - KEY_3270_ExSelect = uint(C.GDK_KEY_3270_ExSelect) - KEY_3270_CursorSelect = uint(C.GDK_KEY_3270_CursorSelect) - KEY_3270_PrintScreen = uint(C.GDK_KEY_3270_PrintScreen) - KEY_3270_Enter = uint(C.GDK_KEY_3270_Enter) - KEY_space = uint(C.GDK_KEY_space) - KEY_exclam = uint(C.GDK_KEY_exclam) - KEY_quotedbl = uint(C.GDK_KEY_quotedbl) - KEY_numbersign = uint(C.GDK_KEY_numbersign) - KEY_dollar = uint(C.GDK_KEY_dollar) - KEY_percent = uint(C.GDK_KEY_percent) - KEY_ampersand = uint(C.GDK_KEY_ampersand) - KEY_apostrophe = uint(C.GDK_KEY_apostrophe) - KEY_quoteright = uint(C.GDK_KEY_quoteright) - KEY_parenleft = uint(C.GDK_KEY_parenleft) - KEY_parenright = uint(C.GDK_KEY_parenright) - KEY_asterisk = uint(C.GDK_KEY_asterisk) - KEY_plus = uint(C.GDK_KEY_plus) - KEY_comma = uint(C.GDK_KEY_comma) - KEY_minus = uint(C.GDK_KEY_minus) - KEY_period = uint(C.GDK_KEY_period) - KEY_slash = uint(C.GDK_KEY_slash) - KEY_0 = uint(C.GDK_KEY_0) - KEY_1 = uint(C.GDK_KEY_1) - KEY_2 = uint(C.GDK_KEY_2) - KEY_3 = uint(C.GDK_KEY_3) - KEY_4 = uint(C.GDK_KEY_4) - KEY_5 = uint(C.GDK_KEY_5) - KEY_6 = uint(C.GDK_KEY_6) - KEY_7 = uint(C.GDK_KEY_7) - KEY_8 = uint(C.GDK_KEY_8) - KEY_9 = uint(C.GDK_KEY_9) - KEY_colon = uint(C.GDK_KEY_colon) - KEY_semicolon = uint(C.GDK_KEY_semicolon) - KEY_less = uint(C.GDK_KEY_less) - KEY_equal = uint(C.GDK_KEY_equal) - KEY_greater = uint(C.GDK_KEY_greater) - KEY_question = uint(C.GDK_KEY_question) - KEY_at = uint(C.GDK_KEY_at) - KEY_A = uint(C.GDK_KEY_A) - KEY_B = uint(C.GDK_KEY_B) - KEY_C = uint(C.GDK_KEY_C) - KEY_D = uint(C.GDK_KEY_D) - KEY_E = uint(C.GDK_KEY_E) - KEY_F = uint(C.GDK_KEY_F) - KEY_G = uint(C.GDK_KEY_G) - KEY_H = uint(C.GDK_KEY_H) - KEY_I = uint(C.GDK_KEY_I) - KEY_J = uint(C.GDK_KEY_J) - KEY_K = uint(C.GDK_KEY_K) - KEY_L = uint(C.GDK_KEY_L) - KEY_M = uint(C.GDK_KEY_M) - KEY_N = uint(C.GDK_KEY_N) - KEY_O = uint(C.GDK_KEY_O) - KEY_P = uint(C.GDK_KEY_P) - KEY_Q = uint(C.GDK_KEY_Q) - KEY_R = uint(C.GDK_KEY_R) - KEY_S = uint(C.GDK_KEY_S) - KEY_T = uint(C.GDK_KEY_T) - KEY_U = uint(C.GDK_KEY_U) - KEY_V = uint(C.GDK_KEY_V) - KEY_W = uint(C.GDK_KEY_W) - KEY_X = uint(C.GDK_KEY_X) - KEY_Y = uint(C.GDK_KEY_Y) - KEY_Z = uint(C.GDK_KEY_Z) - KEY_bracketleft = uint(C.GDK_KEY_bracketleft) - KEY_backslash = uint(C.GDK_KEY_backslash) - KEY_bracketright = uint(C.GDK_KEY_bracketright) - KEY_asciicircum = uint(C.GDK_KEY_asciicircum) - KEY_underscore = uint(C.GDK_KEY_underscore) - KEY_grave = uint(C.GDK_KEY_grave) - KEY_quoteleft = uint(C.GDK_KEY_quoteleft) - KEY_a = uint(C.GDK_KEY_a) - KEY_b = uint(C.GDK_KEY_b) - KEY_c = uint(C.GDK_KEY_c) - KEY_d = uint(C.GDK_KEY_d) - KEY_e = uint(C.GDK_KEY_e) - KEY_f = uint(C.GDK_KEY_f) - KEY_g = uint(C.GDK_KEY_g) - KEY_h = uint(C.GDK_KEY_h) - KEY_i = uint(C.GDK_KEY_i) - KEY_j = uint(C.GDK_KEY_j) - KEY_k = uint(C.GDK_KEY_k) - KEY_l = uint(C.GDK_KEY_l) - KEY_m = uint(C.GDK_KEY_m) - KEY_n = uint(C.GDK_KEY_n) - KEY_o = uint(C.GDK_KEY_o) - KEY_p = uint(C.GDK_KEY_p) - KEY_q = uint(C.GDK_KEY_q) - KEY_r = uint(C.GDK_KEY_r) - KEY_s = uint(C.GDK_KEY_s) - KEY_t = uint(C.GDK_KEY_t) - KEY_u = uint(C.GDK_KEY_u) - KEY_v = uint(C.GDK_KEY_v) - KEY_w = uint(C.GDK_KEY_w) - KEY_x = uint(C.GDK_KEY_x) - KEY_y = uint(C.GDK_KEY_y) - KEY_z = uint(C.GDK_KEY_z) - KEY_braceleft = uint(C.GDK_KEY_braceleft) - KEY_bar = uint(C.GDK_KEY_bar) - KEY_braceright = uint(C.GDK_KEY_braceright) - KEY_asciitilde = uint(C.GDK_KEY_asciitilde) - KEY_nobreakspace = uint(C.GDK_KEY_nobreakspace) - KEY_exclamdown = uint(C.GDK_KEY_exclamdown) - KEY_cent = uint(C.GDK_KEY_cent) - KEY_sterling = uint(C.GDK_KEY_sterling) - KEY_currency = uint(C.GDK_KEY_currency) - KEY_yen = uint(C.GDK_KEY_yen) - KEY_brokenbar = uint(C.GDK_KEY_brokenbar) - KEY_section = uint(C.GDK_KEY_section) - KEY_diaeresis = uint(C.GDK_KEY_diaeresis) - KEY_copyright = uint(C.GDK_KEY_copyright) - KEY_ordfeminine = uint(C.GDK_KEY_ordfeminine) - KEY_guillemotleft = uint(C.GDK_KEY_guillemotleft) - KEY_notsign = uint(C.GDK_KEY_notsign) - KEY_hyphen = uint(C.GDK_KEY_hyphen) - KEY_registered = uint(C.GDK_KEY_registered) - KEY_macron = uint(C.GDK_KEY_macron) - KEY_degree = uint(C.GDK_KEY_degree) - KEY_plusminus = uint(C.GDK_KEY_plusminus) - KEY_twosuperior = uint(C.GDK_KEY_twosuperior) - KEY_threesuperior = uint(C.GDK_KEY_threesuperior) - KEY_acute = uint(C.GDK_KEY_acute) - KEY_mu = uint(C.GDK_KEY_mu) - KEY_paragraph = uint(C.GDK_KEY_paragraph) - KEY_periodcentered = uint(C.GDK_KEY_periodcentered) - KEY_cedilla = uint(C.GDK_KEY_cedilla) - KEY_onesuperior = uint(C.GDK_KEY_onesuperior) - KEY_masculine = uint(C.GDK_KEY_masculine) - KEY_guillemotright = uint(C.GDK_KEY_guillemotright) - KEY_onequarter = uint(C.GDK_KEY_onequarter) - KEY_onehalf = uint(C.GDK_KEY_onehalf) - KEY_threequarters = uint(C.GDK_KEY_threequarters) - KEY_questiondown = uint(C.GDK_KEY_questiondown) - KEY_Agrave = uint(C.GDK_KEY_Agrave) - KEY_Aacute = uint(C.GDK_KEY_Aacute) - KEY_Acircumflex = uint(C.GDK_KEY_Acircumflex) - KEY_Atilde = uint(C.GDK_KEY_Atilde) - KEY_Adiaeresis = uint(C.GDK_KEY_Adiaeresis) - KEY_Aring = uint(C.GDK_KEY_Aring) - KEY_AE = uint(C.GDK_KEY_AE) - KEY_Ccedilla = uint(C.GDK_KEY_Ccedilla) - KEY_Egrave = uint(C.GDK_KEY_Egrave) - KEY_Eacute = uint(C.GDK_KEY_Eacute) - KEY_Ecircumflex = uint(C.GDK_KEY_Ecircumflex) - KEY_Ediaeresis = uint(C.GDK_KEY_Ediaeresis) - KEY_Igrave = uint(C.GDK_KEY_Igrave) - KEY_Iacute = uint(C.GDK_KEY_Iacute) - KEY_Icircumflex = uint(C.GDK_KEY_Icircumflex) - KEY_Idiaeresis = uint(C.GDK_KEY_Idiaeresis) - KEY_ETH = uint(C.GDK_KEY_ETH) - KEY_Eth = uint(C.GDK_KEY_Eth) - KEY_Ntilde = uint(C.GDK_KEY_Ntilde) - KEY_Ograve = uint(C.GDK_KEY_Ograve) - KEY_Oacute = uint(C.GDK_KEY_Oacute) - KEY_Ocircumflex = uint(C.GDK_KEY_Ocircumflex) - KEY_Otilde = uint(C.GDK_KEY_Otilde) - KEY_Odiaeresis = uint(C.GDK_KEY_Odiaeresis) - KEY_multiply = uint(C.GDK_KEY_multiply) - KEY_Oslash = uint(C.GDK_KEY_Oslash) - KEY_Ooblique = uint(C.GDK_KEY_Ooblique) - KEY_Ugrave = uint(C.GDK_KEY_Ugrave) - KEY_Uacute = uint(C.GDK_KEY_Uacute) - KEY_Ucircumflex = uint(C.GDK_KEY_Ucircumflex) - KEY_Udiaeresis = uint(C.GDK_KEY_Udiaeresis) - KEY_Yacute = uint(C.GDK_KEY_Yacute) - KEY_THORN = uint(C.GDK_KEY_THORN) - KEY_Thorn = uint(C.GDK_KEY_Thorn) - KEY_ssharp = uint(C.GDK_KEY_ssharp) - KEY_agrave = uint(C.GDK_KEY_agrave) - KEY_aacute = uint(C.GDK_KEY_aacute) - KEY_acircumflex = uint(C.GDK_KEY_acircumflex) - KEY_atilde = uint(C.GDK_KEY_atilde) - KEY_adiaeresis = uint(C.GDK_KEY_adiaeresis) - KEY_aring = uint(C.GDK_KEY_aring) - KEY_ae = uint(C.GDK_KEY_ae) - KEY_ccedilla = uint(C.GDK_KEY_ccedilla) - KEY_egrave = uint(C.GDK_KEY_egrave) - KEY_eacute = uint(C.GDK_KEY_eacute) - KEY_ecircumflex = uint(C.GDK_KEY_ecircumflex) - KEY_ediaeresis = uint(C.GDK_KEY_ediaeresis) - KEY_igrave = uint(C.GDK_KEY_igrave) - KEY_iacute = uint(C.GDK_KEY_iacute) - KEY_icircumflex = uint(C.GDK_KEY_icircumflex) - KEY_idiaeresis = uint(C.GDK_KEY_idiaeresis) - KEY_eth = uint(C.GDK_KEY_eth) - KEY_ntilde = uint(C.GDK_KEY_ntilde) - KEY_ograve = uint(C.GDK_KEY_ograve) - KEY_oacute = uint(C.GDK_KEY_oacute) - KEY_ocircumflex = uint(C.GDK_KEY_ocircumflex) - KEY_otilde = uint(C.GDK_KEY_otilde) - KEY_odiaeresis = uint(C.GDK_KEY_odiaeresis) - KEY_division = uint(C.GDK_KEY_division) - KEY_oslash = uint(C.GDK_KEY_oslash) - KEY_ooblique = uint(C.GDK_KEY_ooblique) - KEY_ugrave = uint(C.GDK_KEY_ugrave) - KEY_uacute = uint(C.GDK_KEY_uacute) - KEY_ucircumflex = uint(C.GDK_KEY_ucircumflex) - KEY_udiaeresis = uint(C.GDK_KEY_udiaeresis) - KEY_yacute = uint(C.GDK_KEY_yacute) - KEY_thorn = uint(C.GDK_KEY_thorn) - KEY_ydiaeresis = uint(C.GDK_KEY_ydiaeresis) - KEY_Aogonek = uint(C.GDK_KEY_Aogonek) - KEY_breve = uint(C.GDK_KEY_breve) - KEY_Lstroke = uint(C.GDK_KEY_Lstroke) - KEY_Lcaron = uint(C.GDK_KEY_Lcaron) - KEY_Sacute = uint(C.GDK_KEY_Sacute) - KEY_Scaron = uint(C.GDK_KEY_Scaron) - KEY_Scedilla = uint(C.GDK_KEY_Scedilla) - KEY_Tcaron = uint(C.GDK_KEY_Tcaron) - KEY_Zacute = uint(C.GDK_KEY_Zacute) - KEY_Zcaron = uint(C.GDK_KEY_Zcaron) - KEY_Zabovedot = uint(C.GDK_KEY_Zabovedot) - KEY_aogonek = uint(C.GDK_KEY_aogonek) - KEY_ogonek = uint(C.GDK_KEY_ogonek) - KEY_lstroke = uint(C.GDK_KEY_lstroke) - KEY_lcaron = uint(C.GDK_KEY_lcaron) - KEY_sacute = uint(C.GDK_KEY_sacute) - KEY_caron = uint(C.GDK_KEY_caron) - KEY_scaron = uint(C.GDK_KEY_scaron) - KEY_scedilla = uint(C.GDK_KEY_scedilla) - KEY_tcaron = uint(C.GDK_KEY_tcaron) - KEY_zacute = uint(C.GDK_KEY_zacute) - KEY_doubleacute = uint(C.GDK_KEY_doubleacute) - KEY_zcaron = uint(C.GDK_KEY_zcaron) - KEY_zabovedot = uint(C.GDK_KEY_zabovedot) - KEY_Racute = uint(C.GDK_KEY_Racute) - KEY_Abreve = uint(C.GDK_KEY_Abreve) - KEY_Lacute = uint(C.GDK_KEY_Lacute) - KEY_Cacute = uint(C.GDK_KEY_Cacute) - KEY_Ccaron = uint(C.GDK_KEY_Ccaron) - KEY_Eogonek = uint(C.GDK_KEY_Eogonek) - KEY_Ecaron = uint(C.GDK_KEY_Ecaron) - KEY_Dcaron = uint(C.GDK_KEY_Dcaron) - KEY_Dstroke = uint(C.GDK_KEY_Dstroke) - KEY_Nacute = uint(C.GDK_KEY_Nacute) - KEY_Ncaron = uint(C.GDK_KEY_Ncaron) - KEY_Odoubleacute = uint(C.GDK_KEY_Odoubleacute) - KEY_Rcaron = uint(C.GDK_KEY_Rcaron) - KEY_Uring = uint(C.GDK_KEY_Uring) - KEY_Udoubleacute = uint(C.GDK_KEY_Udoubleacute) - KEY_Tcedilla = uint(C.GDK_KEY_Tcedilla) - KEY_racute = uint(C.GDK_KEY_racute) - KEY_abreve = uint(C.GDK_KEY_abreve) - KEY_lacute = uint(C.GDK_KEY_lacute) - KEY_cacute = uint(C.GDK_KEY_cacute) - KEY_ccaron = uint(C.GDK_KEY_ccaron) - KEY_eogonek = uint(C.GDK_KEY_eogonek) - KEY_ecaron = uint(C.GDK_KEY_ecaron) - KEY_dcaron = uint(C.GDK_KEY_dcaron) - KEY_dstroke = uint(C.GDK_KEY_dstroke) - KEY_nacute = uint(C.GDK_KEY_nacute) - KEY_ncaron = uint(C.GDK_KEY_ncaron) - KEY_odoubleacute = uint(C.GDK_KEY_odoubleacute) - KEY_rcaron = uint(C.GDK_KEY_rcaron) - KEY_uring = uint(C.GDK_KEY_uring) - KEY_udoubleacute = uint(C.GDK_KEY_udoubleacute) - KEY_tcedilla = uint(C.GDK_KEY_tcedilla) - KEY_abovedot = uint(C.GDK_KEY_abovedot) - KEY_Hstroke = uint(C.GDK_KEY_Hstroke) - KEY_Hcircumflex = uint(C.GDK_KEY_Hcircumflex) - KEY_Iabovedot = uint(C.GDK_KEY_Iabovedot) - KEY_Gbreve = uint(C.GDK_KEY_Gbreve) - KEY_Jcircumflex = uint(C.GDK_KEY_Jcircumflex) - KEY_hstroke = uint(C.GDK_KEY_hstroke) - KEY_hcircumflex = uint(C.GDK_KEY_hcircumflex) - KEY_idotless = uint(C.GDK_KEY_idotless) - KEY_gbreve = uint(C.GDK_KEY_gbreve) - KEY_jcircumflex = uint(C.GDK_KEY_jcircumflex) - KEY_Cabovedot = uint(C.GDK_KEY_Cabovedot) - KEY_Ccircumflex = uint(C.GDK_KEY_Ccircumflex) - KEY_Gabovedot = uint(C.GDK_KEY_Gabovedot) - KEY_Gcircumflex = uint(C.GDK_KEY_Gcircumflex) - KEY_Ubreve = uint(C.GDK_KEY_Ubreve) - KEY_Scircumflex = uint(C.GDK_KEY_Scircumflex) - KEY_cabovedot = uint(C.GDK_KEY_cabovedot) - KEY_ccircumflex = uint(C.GDK_KEY_ccircumflex) - KEY_gabovedot = uint(C.GDK_KEY_gabovedot) - KEY_gcircumflex = uint(C.GDK_KEY_gcircumflex) - KEY_ubreve = uint(C.GDK_KEY_ubreve) - KEY_scircumflex = uint(C.GDK_KEY_scircumflex) - KEY_kra = uint(C.GDK_KEY_kra) - KEY_kappa = uint(C.GDK_KEY_kappa) - KEY_Rcedilla = uint(C.GDK_KEY_Rcedilla) - KEY_Itilde = uint(C.GDK_KEY_Itilde) - KEY_Lcedilla = uint(C.GDK_KEY_Lcedilla) - KEY_Emacron = uint(C.GDK_KEY_Emacron) - KEY_Gcedilla = uint(C.GDK_KEY_Gcedilla) - KEY_Tslash = uint(C.GDK_KEY_Tslash) - KEY_rcedilla = uint(C.GDK_KEY_rcedilla) - KEY_itilde = uint(C.GDK_KEY_itilde) - KEY_lcedilla = uint(C.GDK_KEY_lcedilla) - KEY_emacron = uint(C.GDK_KEY_emacron) - KEY_gcedilla = uint(C.GDK_KEY_gcedilla) - KEY_tslash = uint(C.GDK_KEY_tslash) - KEY_ENG = uint(C.GDK_KEY_ENG) - KEY_eng = uint(C.GDK_KEY_eng) - KEY_Amacron = uint(C.GDK_KEY_Amacron) - KEY_Iogonek = uint(C.GDK_KEY_Iogonek) - KEY_Eabovedot = uint(C.GDK_KEY_Eabovedot) - KEY_Imacron = uint(C.GDK_KEY_Imacron) - KEY_Ncedilla = uint(C.GDK_KEY_Ncedilla) - KEY_Omacron = uint(C.GDK_KEY_Omacron) - KEY_Kcedilla = uint(C.GDK_KEY_Kcedilla) - KEY_Uogonek = uint(C.GDK_KEY_Uogonek) - KEY_Utilde = uint(C.GDK_KEY_Utilde) - KEY_Umacron = uint(C.GDK_KEY_Umacron) - KEY_amacron = uint(C.GDK_KEY_amacron) - KEY_iogonek = uint(C.GDK_KEY_iogonek) - KEY_eabovedot = uint(C.GDK_KEY_eabovedot) - KEY_imacron = uint(C.GDK_KEY_imacron) - KEY_ncedilla = uint(C.GDK_KEY_ncedilla) - KEY_omacron = uint(C.GDK_KEY_omacron) - KEY_kcedilla = uint(C.GDK_KEY_kcedilla) - KEY_uogonek = uint(C.GDK_KEY_uogonek) - KEY_utilde = uint(C.GDK_KEY_utilde) - KEY_umacron = uint(C.GDK_KEY_umacron) - KEY_Wcircumflex = uint(C.GDK_KEY_Wcircumflex) - KEY_wcircumflex = uint(C.GDK_KEY_wcircumflex) - KEY_Ycircumflex = uint(C.GDK_KEY_Ycircumflex) - KEY_ycircumflex = uint(C.GDK_KEY_ycircumflex) - KEY_Babovedot = uint(C.GDK_KEY_Babovedot) - KEY_babovedot = uint(C.GDK_KEY_babovedot) - KEY_Dabovedot = uint(C.GDK_KEY_Dabovedot) - KEY_dabovedot = uint(C.GDK_KEY_dabovedot) - KEY_Fabovedot = uint(C.GDK_KEY_Fabovedot) - KEY_fabovedot = uint(C.GDK_KEY_fabovedot) - KEY_Mabovedot = uint(C.GDK_KEY_Mabovedot) - KEY_mabovedot = uint(C.GDK_KEY_mabovedot) - KEY_Pabovedot = uint(C.GDK_KEY_Pabovedot) - KEY_pabovedot = uint(C.GDK_KEY_pabovedot) - KEY_Sabovedot = uint(C.GDK_KEY_Sabovedot) - KEY_sabovedot = uint(C.GDK_KEY_sabovedot) - KEY_Tabovedot = uint(C.GDK_KEY_Tabovedot) - KEY_tabovedot = uint(C.GDK_KEY_tabovedot) - KEY_Wgrave = uint(C.GDK_KEY_Wgrave) - KEY_wgrave = uint(C.GDK_KEY_wgrave) - KEY_Wacute = uint(C.GDK_KEY_Wacute) - KEY_wacute = uint(C.GDK_KEY_wacute) - KEY_Wdiaeresis = uint(C.GDK_KEY_Wdiaeresis) - KEY_wdiaeresis = uint(C.GDK_KEY_wdiaeresis) - KEY_Ygrave = uint(C.GDK_KEY_Ygrave) - KEY_ygrave = uint(C.GDK_KEY_ygrave) - KEY_OE = uint(C.GDK_KEY_OE) - KEY_oe = uint(C.GDK_KEY_oe) - KEY_Ydiaeresis = uint(C.GDK_KEY_Ydiaeresis) - KEY_overline = uint(C.GDK_KEY_overline) - KEY_kana_fullstop = uint(C.GDK_KEY_kana_fullstop) - KEY_kana_openingbracket = uint(C.GDK_KEY_kana_openingbracket) - KEY_kana_closingbracket = uint(C.GDK_KEY_kana_closingbracket) - KEY_kana_comma = uint(C.GDK_KEY_kana_comma) - KEY_kana_conjunctive = uint(C.GDK_KEY_kana_conjunctive) - KEY_kana_middledot = uint(C.GDK_KEY_kana_middledot) - KEY_kana_WO = uint(C.GDK_KEY_kana_WO) - KEY_kana_a = uint(C.GDK_KEY_kana_a) - KEY_kana_i = uint(C.GDK_KEY_kana_i) - KEY_kana_u = uint(C.GDK_KEY_kana_u) - KEY_kana_e = uint(C.GDK_KEY_kana_e) - KEY_kana_o = uint(C.GDK_KEY_kana_o) - KEY_kana_ya = uint(C.GDK_KEY_kana_ya) - KEY_kana_yu = uint(C.GDK_KEY_kana_yu) - KEY_kana_yo = uint(C.GDK_KEY_kana_yo) - KEY_kana_tsu = uint(C.GDK_KEY_kana_tsu) - KEY_kana_tu = uint(C.GDK_KEY_kana_tu) - KEY_prolongedsound = uint(C.GDK_KEY_prolongedsound) - KEY_kana_A = uint(C.GDK_KEY_kana_A) - KEY_kana_I = uint(C.GDK_KEY_kana_I) - KEY_kana_U = uint(C.GDK_KEY_kana_U) - KEY_kana_E = uint(C.GDK_KEY_kana_E) - KEY_kana_O = uint(C.GDK_KEY_kana_O) - KEY_kana_KA = uint(C.GDK_KEY_kana_KA) - KEY_kana_KI = uint(C.GDK_KEY_kana_KI) - KEY_kana_KU = uint(C.GDK_KEY_kana_KU) - KEY_kana_KE = uint(C.GDK_KEY_kana_KE) - KEY_kana_KO = uint(C.GDK_KEY_kana_KO) - KEY_kana_SA = uint(C.GDK_KEY_kana_SA) - KEY_kana_SHI = uint(C.GDK_KEY_kana_SHI) - KEY_kana_SU = uint(C.GDK_KEY_kana_SU) - KEY_kana_SE = uint(C.GDK_KEY_kana_SE) - KEY_kana_SO = uint(C.GDK_KEY_kana_SO) - KEY_kana_TA = uint(C.GDK_KEY_kana_TA) - KEY_kana_CHI = uint(C.GDK_KEY_kana_CHI) - KEY_kana_TI = uint(C.GDK_KEY_kana_TI) - KEY_kana_TSU = uint(C.GDK_KEY_kana_TSU) - KEY_kana_TU = uint(C.GDK_KEY_kana_TU) - KEY_kana_TE = uint(C.GDK_KEY_kana_TE) - KEY_kana_TO = uint(C.GDK_KEY_kana_TO) - KEY_kana_NA = uint(C.GDK_KEY_kana_NA) - KEY_kana_NI = uint(C.GDK_KEY_kana_NI) - KEY_kana_NU = uint(C.GDK_KEY_kana_NU) - KEY_kana_NE = uint(C.GDK_KEY_kana_NE) - KEY_kana_NO = uint(C.GDK_KEY_kana_NO) - KEY_kana_HA = uint(C.GDK_KEY_kana_HA) - KEY_kana_HI = uint(C.GDK_KEY_kana_HI) - KEY_kana_FU = uint(C.GDK_KEY_kana_FU) - KEY_kana_HU = uint(C.GDK_KEY_kana_HU) - KEY_kana_HE = uint(C.GDK_KEY_kana_HE) - KEY_kana_HO = uint(C.GDK_KEY_kana_HO) - KEY_kana_MA = uint(C.GDK_KEY_kana_MA) - KEY_kana_MI = uint(C.GDK_KEY_kana_MI) - KEY_kana_MU = uint(C.GDK_KEY_kana_MU) - KEY_kana_ME = uint(C.GDK_KEY_kana_ME) - KEY_kana_MO = uint(C.GDK_KEY_kana_MO) - KEY_kana_YA = uint(C.GDK_KEY_kana_YA) - KEY_kana_YU = uint(C.GDK_KEY_kana_YU) - KEY_kana_YO = uint(C.GDK_KEY_kana_YO) - KEY_kana_RA = uint(C.GDK_KEY_kana_RA) - KEY_kana_RI = uint(C.GDK_KEY_kana_RI) - KEY_kana_RU = uint(C.GDK_KEY_kana_RU) - KEY_kana_RE = uint(C.GDK_KEY_kana_RE) - KEY_kana_RO = uint(C.GDK_KEY_kana_RO) - KEY_kana_WA = uint(C.GDK_KEY_kana_WA) - KEY_kana_N = uint(C.GDK_KEY_kana_N) - KEY_voicedsound = uint(C.GDK_KEY_voicedsound) - KEY_semivoicedsound = uint(C.GDK_KEY_semivoicedsound) - KEY_kana_switch = uint(C.GDK_KEY_kana_switch) - KEY_Farsi_0 = uint(C.GDK_KEY_Farsi_0) - KEY_Farsi_1 = uint(C.GDK_KEY_Farsi_1) - KEY_Farsi_2 = uint(C.GDK_KEY_Farsi_2) - KEY_Farsi_3 = uint(C.GDK_KEY_Farsi_3) - KEY_Farsi_4 = uint(C.GDK_KEY_Farsi_4) - KEY_Farsi_5 = uint(C.GDK_KEY_Farsi_5) - KEY_Farsi_6 = uint(C.GDK_KEY_Farsi_6) - KEY_Farsi_7 = uint(C.GDK_KEY_Farsi_7) - KEY_Farsi_8 = uint(C.GDK_KEY_Farsi_8) - KEY_Farsi_9 = uint(C.GDK_KEY_Farsi_9) - KEY_Arabic_percent = uint(C.GDK_KEY_Arabic_percent) - KEY_Arabic_superscript_alef = uint(C.GDK_KEY_Arabic_superscript_alef) - KEY_Arabic_tteh = uint(C.GDK_KEY_Arabic_tteh) - KEY_Arabic_peh = uint(C.GDK_KEY_Arabic_peh) - KEY_Arabic_tcheh = uint(C.GDK_KEY_Arabic_tcheh) - KEY_Arabic_ddal = uint(C.GDK_KEY_Arabic_ddal) - KEY_Arabic_rreh = uint(C.GDK_KEY_Arabic_rreh) - KEY_Arabic_comma = uint(C.GDK_KEY_Arabic_comma) - KEY_Arabic_fullstop = uint(C.GDK_KEY_Arabic_fullstop) - KEY_Arabic_0 = uint(C.GDK_KEY_Arabic_0) - KEY_Arabic_1 = uint(C.GDK_KEY_Arabic_1) - KEY_Arabic_2 = uint(C.GDK_KEY_Arabic_2) - KEY_Arabic_3 = uint(C.GDK_KEY_Arabic_3) - KEY_Arabic_4 = uint(C.GDK_KEY_Arabic_4) - KEY_Arabic_5 = uint(C.GDK_KEY_Arabic_5) - KEY_Arabic_6 = uint(C.GDK_KEY_Arabic_6) - KEY_Arabic_7 = uint(C.GDK_KEY_Arabic_7) - KEY_Arabic_8 = uint(C.GDK_KEY_Arabic_8) - KEY_Arabic_9 = uint(C.GDK_KEY_Arabic_9) - KEY_Arabic_semicolon = uint(C.GDK_KEY_Arabic_semicolon) - KEY_Arabic_question_mark = uint(C.GDK_KEY_Arabic_question_mark) - KEY_Arabic_hamza = uint(C.GDK_KEY_Arabic_hamza) - KEY_Arabic_maddaonalef = uint(C.GDK_KEY_Arabic_maddaonalef) - KEY_Arabic_hamzaonalef = uint(C.GDK_KEY_Arabic_hamzaonalef) - KEY_Arabic_hamzaonwaw = uint(C.GDK_KEY_Arabic_hamzaonwaw) - KEY_Arabic_hamzaunderalef = uint(C.GDK_KEY_Arabic_hamzaunderalef) - KEY_Arabic_hamzaonyeh = uint(C.GDK_KEY_Arabic_hamzaonyeh) - KEY_Arabic_alef = uint(C.GDK_KEY_Arabic_alef) - KEY_Arabic_beh = uint(C.GDK_KEY_Arabic_beh) - KEY_Arabic_tehmarbuta = uint(C.GDK_KEY_Arabic_tehmarbuta) - KEY_Arabic_teh = uint(C.GDK_KEY_Arabic_teh) - KEY_Arabic_theh = uint(C.GDK_KEY_Arabic_theh) - KEY_Arabic_jeem = uint(C.GDK_KEY_Arabic_jeem) - KEY_Arabic_hah = uint(C.GDK_KEY_Arabic_hah) - KEY_Arabic_khah = uint(C.GDK_KEY_Arabic_khah) - KEY_Arabic_dal = uint(C.GDK_KEY_Arabic_dal) - KEY_Arabic_thal = uint(C.GDK_KEY_Arabic_thal) - KEY_Arabic_ra = uint(C.GDK_KEY_Arabic_ra) - KEY_Arabic_zain = uint(C.GDK_KEY_Arabic_zain) - KEY_Arabic_seen = uint(C.GDK_KEY_Arabic_seen) - KEY_Arabic_sheen = uint(C.GDK_KEY_Arabic_sheen) - KEY_Arabic_sad = uint(C.GDK_KEY_Arabic_sad) - KEY_Arabic_dad = uint(C.GDK_KEY_Arabic_dad) - KEY_Arabic_tah = uint(C.GDK_KEY_Arabic_tah) - KEY_Arabic_zah = uint(C.GDK_KEY_Arabic_zah) - KEY_Arabic_ain = uint(C.GDK_KEY_Arabic_ain) - KEY_Arabic_ghain = uint(C.GDK_KEY_Arabic_ghain) - KEY_Arabic_tatweel = uint(C.GDK_KEY_Arabic_tatweel) - KEY_Arabic_feh = uint(C.GDK_KEY_Arabic_feh) - KEY_Arabic_qaf = uint(C.GDK_KEY_Arabic_qaf) - KEY_Arabic_kaf = uint(C.GDK_KEY_Arabic_kaf) - KEY_Arabic_lam = uint(C.GDK_KEY_Arabic_lam) - KEY_Arabic_meem = uint(C.GDK_KEY_Arabic_meem) - KEY_Arabic_noon = uint(C.GDK_KEY_Arabic_noon) - KEY_Arabic_ha = uint(C.GDK_KEY_Arabic_ha) - KEY_Arabic_heh = uint(C.GDK_KEY_Arabic_heh) - KEY_Arabic_waw = uint(C.GDK_KEY_Arabic_waw) - KEY_Arabic_alefmaksura = uint(C.GDK_KEY_Arabic_alefmaksura) - KEY_Arabic_yeh = uint(C.GDK_KEY_Arabic_yeh) - KEY_Arabic_fathatan = uint(C.GDK_KEY_Arabic_fathatan) - KEY_Arabic_dammatan = uint(C.GDK_KEY_Arabic_dammatan) - KEY_Arabic_kasratan = uint(C.GDK_KEY_Arabic_kasratan) - KEY_Arabic_fatha = uint(C.GDK_KEY_Arabic_fatha) - KEY_Arabic_damma = uint(C.GDK_KEY_Arabic_damma) - KEY_Arabic_kasra = uint(C.GDK_KEY_Arabic_kasra) - KEY_Arabic_shadda = uint(C.GDK_KEY_Arabic_shadda) - KEY_Arabic_sukun = uint(C.GDK_KEY_Arabic_sukun) - KEY_Arabic_madda_above = uint(C.GDK_KEY_Arabic_madda_above) - KEY_Arabic_hamza_above = uint(C.GDK_KEY_Arabic_hamza_above) - KEY_Arabic_hamza_below = uint(C.GDK_KEY_Arabic_hamza_below) - KEY_Arabic_jeh = uint(C.GDK_KEY_Arabic_jeh) - KEY_Arabic_veh = uint(C.GDK_KEY_Arabic_veh) - KEY_Arabic_keheh = uint(C.GDK_KEY_Arabic_keheh) - KEY_Arabic_gaf = uint(C.GDK_KEY_Arabic_gaf) - KEY_Arabic_noon_ghunna = uint(C.GDK_KEY_Arabic_noon_ghunna) - KEY_Arabic_heh_doachashmee = uint(C.GDK_KEY_Arabic_heh_doachashmee) - KEY_Farsi_yeh = uint(C.GDK_KEY_Farsi_yeh) - KEY_Arabic_farsi_yeh = uint(C.GDK_KEY_Arabic_farsi_yeh) - KEY_Arabic_yeh_baree = uint(C.GDK_KEY_Arabic_yeh_baree) - KEY_Arabic_heh_goal = uint(C.GDK_KEY_Arabic_heh_goal) - KEY_Arabic_switch = uint(C.GDK_KEY_Arabic_switch) - KEY_Cyrillic_GHE_bar = uint(C.GDK_KEY_Cyrillic_GHE_bar) - KEY_Cyrillic_ghe_bar = uint(C.GDK_KEY_Cyrillic_ghe_bar) - KEY_Cyrillic_ZHE_descender = uint(C.GDK_KEY_Cyrillic_ZHE_descender) - KEY_Cyrillic_zhe_descender = uint(C.GDK_KEY_Cyrillic_zhe_descender) - KEY_Cyrillic_KA_descender = uint(C.GDK_KEY_Cyrillic_KA_descender) - KEY_Cyrillic_ka_descender = uint(C.GDK_KEY_Cyrillic_ka_descender) - KEY_Cyrillic_KA_vertstroke = uint(C.GDK_KEY_Cyrillic_KA_vertstroke) - KEY_Cyrillic_ka_vertstroke = uint(C.GDK_KEY_Cyrillic_ka_vertstroke) - KEY_Cyrillic_EN_descender = uint(C.GDK_KEY_Cyrillic_EN_descender) - KEY_Cyrillic_en_descender = uint(C.GDK_KEY_Cyrillic_en_descender) - KEY_Cyrillic_U_straight = uint(C.GDK_KEY_Cyrillic_U_straight) - KEY_Cyrillic_u_straight = uint(C.GDK_KEY_Cyrillic_u_straight) - KEY_Cyrillic_U_straight_bar = uint(C.GDK_KEY_Cyrillic_U_straight_bar) - KEY_Cyrillic_u_straight_bar = uint(C.GDK_KEY_Cyrillic_u_straight_bar) - KEY_Cyrillic_HA_descender = uint(C.GDK_KEY_Cyrillic_HA_descender) - KEY_Cyrillic_ha_descender = uint(C.GDK_KEY_Cyrillic_ha_descender) - KEY_Cyrillic_CHE_descender = uint(C.GDK_KEY_Cyrillic_CHE_descender) - KEY_Cyrillic_che_descender = uint(C.GDK_KEY_Cyrillic_che_descender) - KEY_Cyrillic_CHE_vertstroke = uint(C.GDK_KEY_Cyrillic_CHE_vertstroke) - KEY_Cyrillic_che_vertstroke = uint(C.GDK_KEY_Cyrillic_che_vertstroke) - KEY_Cyrillic_SHHA = uint(C.GDK_KEY_Cyrillic_SHHA) - KEY_Cyrillic_shha = uint(C.GDK_KEY_Cyrillic_shha) - KEY_Cyrillic_SCHWA = uint(C.GDK_KEY_Cyrillic_SCHWA) - KEY_Cyrillic_schwa = uint(C.GDK_KEY_Cyrillic_schwa) - KEY_Cyrillic_I_macron = uint(C.GDK_KEY_Cyrillic_I_macron) - KEY_Cyrillic_i_macron = uint(C.GDK_KEY_Cyrillic_i_macron) - KEY_Cyrillic_O_bar = uint(C.GDK_KEY_Cyrillic_O_bar) - KEY_Cyrillic_o_bar = uint(C.GDK_KEY_Cyrillic_o_bar) - KEY_Cyrillic_U_macron = uint(C.GDK_KEY_Cyrillic_U_macron) - KEY_Cyrillic_u_macron = uint(C.GDK_KEY_Cyrillic_u_macron) - KEY_Serbian_dje = uint(C.GDK_KEY_Serbian_dje) - KEY_Macedonia_gje = uint(C.GDK_KEY_Macedonia_gje) - KEY_Cyrillic_io = uint(C.GDK_KEY_Cyrillic_io) - KEY_Ukrainian_ie = uint(C.GDK_KEY_Ukrainian_ie) - KEY_Ukranian_je = uint(C.GDK_KEY_Ukranian_je) - KEY_Macedonia_dse = uint(C.GDK_KEY_Macedonia_dse) - KEY_Ukrainian_i = uint(C.GDK_KEY_Ukrainian_i) - KEY_Ukranian_i = uint(C.GDK_KEY_Ukranian_i) - KEY_Ukrainian_yi = uint(C.GDK_KEY_Ukrainian_yi) - KEY_Ukranian_yi = uint(C.GDK_KEY_Ukranian_yi) - KEY_Cyrillic_je = uint(C.GDK_KEY_Cyrillic_je) - KEY_Serbian_je = uint(C.GDK_KEY_Serbian_je) - KEY_Cyrillic_lje = uint(C.GDK_KEY_Cyrillic_lje) - KEY_Serbian_lje = uint(C.GDK_KEY_Serbian_lje) - KEY_Cyrillic_nje = uint(C.GDK_KEY_Cyrillic_nje) - KEY_Serbian_nje = uint(C.GDK_KEY_Serbian_nje) - KEY_Serbian_tshe = uint(C.GDK_KEY_Serbian_tshe) - KEY_Macedonia_kje = uint(C.GDK_KEY_Macedonia_kje) - KEY_Ukrainian_ghe_with_upturn = uint(C.GDK_KEY_Ukrainian_ghe_with_upturn) - KEY_Byelorussian_shortu = uint(C.GDK_KEY_Byelorussian_shortu) - KEY_Cyrillic_dzhe = uint(C.GDK_KEY_Cyrillic_dzhe) - KEY_Serbian_dze = uint(C.GDK_KEY_Serbian_dze) - KEY_numerosign = uint(C.GDK_KEY_numerosign) - KEY_Serbian_DJE = uint(C.GDK_KEY_Serbian_DJE) - KEY_Macedonia_GJE = uint(C.GDK_KEY_Macedonia_GJE) - KEY_Cyrillic_IO = uint(C.GDK_KEY_Cyrillic_IO) - KEY_Ukrainian_IE = uint(C.GDK_KEY_Ukrainian_IE) - KEY_Ukranian_JE = uint(C.GDK_KEY_Ukranian_JE) - KEY_Macedonia_DSE = uint(C.GDK_KEY_Macedonia_DSE) - KEY_Ukrainian_I = uint(C.GDK_KEY_Ukrainian_I) - KEY_Ukranian_I = uint(C.GDK_KEY_Ukranian_I) - KEY_Ukrainian_YI = uint(C.GDK_KEY_Ukrainian_YI) - KEY_Ukranian_YI = uint(C.GDK_KEY_Ukranian_YI) - KEY_Cyrillic_JE = uint(C.GDK_KEY_Cyrillic_JE) - KEY_Serbian_JE = uint(C.GDK_KEY_Serbian_JE) - KEY_Cyrillic_LJE = uint(C.GDK_KEY_Cyrillic_LJE) - KEY_Serbian_LJE = uint(C.GDK_KEY_Serbian_LJE) - KEY_Cyrillic_NJE = uint(C.GDK_KEY_Cyrillic_NJE) - KEY_Serbian_NJE = uint(C.GDK_KEY_Serbian_NJE) - KEY_Serbian_TSHE = uint(C.GDK_KEY_Serbian_TSHE) - KEY_Macedonia_KJE = uint(C.GDK_KEY_Macedonia_KJE) - KEY_Ukrainian_GHE_WITH_UPTURN = uint(C.GDK_KEY_Ukrainian_GHE_WITH_UPTURN) - KEY_Byelorussian_SHORTU = uint(C.GDK_KEY_Byelorussian_SHORTU) - KEY_Cyrillic_DZHE = uint(C.GDK_KEY_Cyrillic_DZHE) - KEY_Serbian_DZE = uint(C.GDK_KEY_Serbian_DZE) - KEY_Cyrillic_yu = uint(C.GDK_KEY_Cyrillic_yu) - KEY_Cyrillic_a = uint(C.GDK_KEY_Cyrillic_a) - KEY_Cyrillic_be = uint(C.GDK_KEY_Cyrillic_be) - KEY_Cyrillic_tse = uint(C.GDK_KEY_Cyrillic_tse) - KEY_Cyrillic_de = uint(C.GDK_KEY_Cyrillic_de) - KEY_Cyrillic_ie = uint(C.GDK_KEY_Cyrillic_ie) - KEY_Cyrillic_ef = uint(C.GDK_KEY_Cyrillic_ef) - KEY_Cyrillic_ghe = uint(C.GDK_KEY_Cyrillic_ghe) - KEY_Cyrillic_ha = uint(C.GDK_KEY_Cyrillic_ha) - KEY_Cyrillic_i = uint(C.GDK_KEY_Cyrillic_i) - KEY_Cyrillic_shorti = uint(C.GDK_KEY_Cyrillic_shorti) - KEY_Cyrillic_ka = uint(C.GDK_KEY_Cyrillic_ka) - KEY_Cyrillic_el = uint(C.GDK_KEY_Cyrillic_el) - KEY_Cyrillic_em = uint(C.GDK_KEY_Cyrillic_em) - KEY_Cyrillic_en = uint(C.GDK_KEY_Cyrillic_en) - KEY_Cyrillic_o = uint(C.GDK_KEY_Cyrillic_o) - KEY_Cyrillic_pe = uint(C.GDK_KEY_Cyrillic_pe) - KEY_Cyrillic_ya = uint(C.GDK_KEY_Cyrillic_ya) - KEY_Cyrillic_er = uint(C.GDK_KEY_Cyrillic_er) - KEY_Cyrillic_es = uint(C.GDK_KEY_Cyrillic_es) - KEY_Cyrillic_te = uint(C.GDK_KEY_Cyrillic_te) - KEY_Cyrillic_u = uint(C.GDK_KEY_Cyrillic_u) - KEY_Cyrillic_zhe = uint(C.GDK_KEY_Cyrillic_zhe) - KEY_Cyrillic_ve = uint(C.GDK_KEY_Cyrillic_ve) - KEY_Cyrillic_softsign = uint(C.GDK_KEY_Cyrillic_softsign) - KEY_Cyrillic_yeru = uint(C.GDK_KEY_Cyrillic_yeru) - KEY_Cyrillic_ze = uint(C.GDK_KEY_Cyrillic_ze) - KEY_Cyrillic_sha = uint(C.GDK_KEY_Cyrillic_sha) - KEY_Cyrillic_e = uint(C.GDK_KEY_Cyrillic_e) - KEY_Cyrillic_shcha = uint(C.GDK_KEY_Cyrillic_shcha) - KEY_Cyrillic_che = uint(C.GDK_KEY_Cyrillic_che) - KEY_Cyrillic_hardsign = uint(C.GDK_KEY_Cyrillic_hardsign) - KEY_Cyrillic_YU = uint(C.GDK_KEY_Cyrillic_YU) - KEY_Cyrillic_A = uint(C.GDK_KEY_Cyrillic_A) - KEY_Cyrillic_BE = uint(C.GDK_KEY_Cyrillic_BE) - KEY_Cyrillic_TSE = uint(C.GDK_KEY_Cyrillic_TSE) - KEY_Cyrillic_DE = uint(C.GDK_KEY_Cyrillic_DE) - KEY_Cyrillic_IE = uint(C.GDK_KEY_Cyrillic_IE) - KEY_Cyrillic_EF = uint(C.GDK_KEY_Cyrillic_EF) - KEY_Cyrillic_GHE = uint(C.GDK_KEY_Cyrillic_GHE) - KEY_Cyrillic_HA = uint(C.GDK_KEY_Cyrillic_HA) - KEY_Cyrillic_I = uint(C.GDK_KEY_Cyrillic_I) - KEY_Cyrillic_SHORTI = uint(C.GDK_KEY_Cyrillic_SHORTI) - KEY_Cyrillic_KA = uint(C.GDK_KEY_Cyrillic_KA) - KEY_Cyrillic_EL = uint(C.GDK_KEY_Cyrillic_EL) - KEY_Cyrillic_EM = uint(C.GDK_KEY_Cyrillic_EM) - KEY_Cyrillic_EN = uint(C.GDK_KEY_Cyrillic_EN) - KEY_Cyrillic_O = uint(C.GDK_KEY_Cyrillic_O) - KEY_Cyrillic_PE = uint(C.GDK_KEY_Cyrillic_PE) - KEY_Cyrillic_YA = uint(C.GDK_KEY_Cyrillic_YA) - KEY_Cyrillic_ER = uint(C.GDK_KEY_Cyrillic_ER) - KEY_Cyrillic_ES = uint(C.GDK_KEY_Cyrillic_ES) - KEY_Cyrillic_TE = uint(C.GDK_KEY_Cyrillic_TE) - KEY_Cyrillic_U = uint(C.GDK_KEY_Cyrillic_U) - KEY_Cyrillic_ZHE = uint(C.GDK_KEY_Cyrillic_ZHE) - KEY_Cyrillic_VE = uint(C.GDK_KEY_Cyrillic_VE) - KEY_Cyrillic_SOFTSIGN = uint(C.GDK_KEY_Cyrillic_SOFTSIGN) - KEY_Cyrillic_YERU = uint(C.GDK_KEY_Cyrillic_YERU) - KEY_Cyrillic_ZE = uint(C.GDK_KEY_Cyrillic_ZE) - KEY_Cyrillic_SHA = uint(C.GDK_KEY_Cyrillic_SHA) - KEY_Cyrillic_E = uint(C.GDK_KEY_Cyrillic_E) - KEY_Cyrillic_SHCHA = uint(C.GDK_KEY_Cyrillic_SHCHA) - KEY_Cyrillic_CHE = uint(C.GDK_KEY_Cyrillic_CHE) - KEY_Cyrillic_HARDSIGN = uint(C.GDK_KEY_Cyrillic_HARDSIGN) - KEY_Greek_ALPHAaccent = uint(C.GDK_KEY_Greek_ALPHAaccent) - KEY_Greek_EPSILONaccent = uint(C.GDK_KEY_Greek_EPSILONaccent) - KEY_Greek_ETAaccent = uint(C.GDK_KEY_Greek_ETAaccent) - KEY_Greek_IOTAaccent = uint(C.GDK_KEY_Greek_IOTAaccent) - KEY_Greek_IOTAdieresis = uint(C.GDK_KEY_Greek_IOTAdieresis) - KEY_Greek_IOTAdiaeresis = uint(C.GDK_KEY_Greek_IOTAdiaeresis) - KEY_Greek_OMICRONaccent = uint(C.GDK_KEY_Greek_OMICRONaccent) - KEY_Greek_UPSILONaccent = uint(C.GDK_KEY_Greek_UPSILONaccent) - KEY_Greek_UPSILONdieresis = uint(C.GDK_KEY_Greek_UPSILONdieresis) - KEY_Greek_OMEGAaccent = uint(C.GDK_KEY_Greek_OMEGAaccent) - KEY_Greek_accentdieresis = uint(C.GDK_KEY_Greek_accentdieresis) - KEY_Greek_horizbar = uint(C.GDK_KEY_Greek_horizbar) - KEY_Greek_alphaaccent = uint(C.GDK_KEY_Greek_alphaaccent) - KEY_Greek_epsilonaccent = uint(C.GDK_KEY_Greek_epsilonaccent) - KEY_Greek_etaaccent = uint(C.GDK_KEY_Greek_etaaccent) - KEY_Greek_iotaaccent = uint(C.GDK_KEY_Greek_iotaaccent) - KEY_Greek_iotadieresis = uint(C.GDK_KEY_Greek_iotadieresis) - KEY_Greek_iotaaccentdieresis = uint(C.GDK_KEY_Greek_iotaaccentdieresis) - KEY_Greek_omicronaccent = uint(C.GDK_KEY_Greek_omicronaccent) - KEY_Greek_upsilonaccent = uint(C.GDK_KEY_Greek_upsilonaccent) - KEY_Greek_upsilondieresis = uint(C.GDK_KEY_Greek_upsilondieresis) - KEY_Greek_upsilonaccentdieresis = uint(C.GDK_KEY_Greek_upsilonaccentdieresis) - KEY_Greek_omegaaccent = uint(C.GDK_KEY_Greek_omegaaccent) - KEY_Greek_ALPHA = uint(C.GDK_KEY_Greek_ALPHA) - KEY_Greek_BETA = uint(C.GDK_KEY_Greek_BETA) - KEY_Greek_GAMMA = uint(C.GDK_KEY_Greek_GAMMA) - KEY_Greek_DELTA = uint(C.GDK_KEY_Greek_DELTA) - KEY_Greek_EPSILON = uint(C.GDK_KEY_Greek_EPSILON) - KEY_Greek_ZETA = uint(C.GDK_KEY_Greek_ZETA) - KEY_Greek_ETA = uint(C.GDK_KEY_Greek_ETA) - KEY_Greek_THETA = uint(C.GDK_KEY_Greek_THETA) - KEY_Greek_IOTA = uint(C.GDK_KEY_Greek_IOTA) - KEY_Greek_KAPPA = uint(C.GDK_KEY_Greek_KAPPA) - KEY_Greek_LAMDA = uint(C.GDK_KEY_Greek_LAMDA) - KEY_Greek_LAMBDA = uint(C.GDK_KEY_Greek_LAMBDA) - KEY_Greek_MU = uint(C.GDK_KEY_Greek_MU) - KEY_Greek_NU = uint(C.GDK_KEY_Greek_NU) - KEY_Greek_XI = uint(C.GDK_KEY_Greek_XI) - KEY_Greek_OMICRON = uint(C.GDK_KEY_Greek_OMICRON) - KEY_Greek_PI = uint(C.GDK_KEY_Greek_PI) - KEY_Greek_RHO = uint(C.GDK_KEY_Greek_RHO) - KEY_Greek_SIGMA = uint(C.GDK_KEY_Greek_SIGMA) - KEY_Greek_TAU = uint(C.GDK_KEY_Greek_TAU) - KEY_Greek_UPSILON = uint(C.GDK_KEY_Greek_UPSILON) - KEY_Greek_PHI = uint(C.GDK_KEY_Greek_PHI) - KEY_Greek_CHI = uint(C.GDK_KEY_Greek_CHI) - KEY_Greek_PSI = uint(C.GDK_KEY_Greek_PSI) - KEY_Greek_OMEGA = uint(C.GDK_KEY_Greek_OMEGA) - KEY_Greek_alpha = uint(C.GDK_KEY_Greek_alpha) - KEY_Greek_beta = uint(C.GDK_KEY_Greek_beta) - KEY_Greek_gamma = uint(C.GDK_KEY_Greek_gamma) - KEY_Greek_delta = uint(C.GDK_KEY_Greek_delta) - KEY_Greek_epsilon = uint(C.GDK_KEY_Greek_epsilon) - KEY_Greek_zeta = uint(C.GDK_KEY_Greek_zeta) - KEY_Greek_eta = uint(C.GDK_KEY_Greek_eta) - KEY_Greek_theta = uint(C.GDK_KEY_Greek_theta) - KEY_Greek_iota = uint(C.GDK_KEY_Greek_iota) - KEY_Greek_kappa = uint(C.GDK_KEY_Greek_kappa) - KEY_Greek_lamda = uint(C.GDK_KEY_Greek_lamda) - KEY_Greek_lambda = uint(C.GDK_KEY_Greek_lambda) - KEY_Greek_mu = uint(C.GDK_KEY_Greek_mu) - KEY_Greek_nu = uint(C.GDK_KEY_Greek_nu) - KEY_Greek_xi = uint(C.GDK_KEY_Greek_xi) - KEY_Greek_omicron = uint(C.GDK_KEY_Greek_omicron) - KEY_Greek_pi = uint(C.GDK_KEY_Greek_pi) - KEY_Greek_rho = uint(C.GDK_KEY_Greek_rho) - KEY_Greek_sigma = uint(C.GDK_KEY_Greek_sigma) - KEY_Greek_finalsmallsigma = uint(C.GDK_KEY_Greek_finalsmallsigma) - KEY_Greek_tau = uint(C.GDK_KEY_Greek_tau) - KEY_Greek_upsilon = uint(C.GDK_KEY_Greek_upsilon) - KEY_Greek_phi = uint(C.GDK_KEY_Greek_phi) - KEY_Greek_chi = uint(C.GDK_KEY_Greek_chi) - KEY_Greek_psi = uint(C.GDK_KEY_Greek_psi) - KEY_Greek_omega = uint(C.GDK_KEY_Greek_omega) - KEY_Greek_switch = uint(C.GDK_KEY_Greek_switch) - KEY_leftradical = uint(C.GDK_KEY_leftradical) - KEY_topleftradical = uint(C.GDK_KEY_topleftradical) - KEY_horizconnector = uint(C.GDK_KEY_horizconnector) - KEY_topintegral = uint(C.GDK_KEY_topintegral) - KEY_botintegral = uint(C.GDK_KEY_botintegral) - KEY_vertconnector = uint(C.GDK_KEY_vertconnector) - KEY_topleftsqbracket = uint(C.GDK_KEY_topleftsqbracket) - KEY_botleftsqbracket = uint(C.GDK_KEY_botleftsqbracket) - KEY_toprightsqbracket = uint(C.GDK_KEY_toprightsqbracket) - KEY_botrightsqbracket = uint(C.GDK_KEY_botrightsqbracket) - KEY_topleftparens = uint(C.GDK_KEY_topleftparens) - KEY_botleftparens = uint(C.GDK_KEY_botleftparens) - KEY_toprightparens = uint(C.GDK_KEY_toprightparens) - KEY_botrightparens = uint(C.GDK_KEY_botrightparens) - KEY_leftmiddlecurlybrace = uint(C.GDK_KEY_leftmiddlecurlybrace) - KEY_rightmiddlecurlybrace = uint(C.GDK_KEY_rightmiddlecurlybrace) - KEY_topleftsummation = uint(C.GDK_KEY_topleftsummation) - KEY_botleftsummation = uint(C.GDK_KEY_botleftsummation) - KEY_topvertsummationconnector = uint(C.GDK_KEY_topvertsummationconnector) - KEY_botvertsummationconnector = uint(C.GDK_KEY_botvertsummationconnector) - KEY_toprightsummation = uint(C.GDK_KEY_toprightsummation) - KEY_botrightsummation = uint(C.GDK_KEY_botrightsummation) - KEY_rightmiddlesummation = uint(C.GDK_KEY_rightmiddlesummation) - KEY_lessthanequal = uint(C.GDK_KEY_lessthanequal) - KEY_notequal = uint(C.GDK_KEY_notequal) - KEY_greaterthanequal = uint(C.GDK_KEY_greaterthanequal) - KEY_integral = uint(C.GDK_KEY_integral) - KEY_therefore = uint(C.GDK_KEY_therefore) - KEY_variation = uint(C.GDK_KEY_variation) - KEY_infinity = uint(C.GDK_KEY_infinity) - KEY_nabla = uint(C.GDK_KEY_nabla) - KEY_approximate = uint(C.GDK_KEY_approximate) - KEY_similarequal = uint(C.GDK_KEY_similarequal) - KEY_ifonlyif = uint(C.GDK_KEY_ifonlyif) - KEY_implies = uint(C.GDK_KEY_implies) - KEY_identical = uint(C.GDK_KEY_identical) - KEY_radical = uint(C.GDK_KEY_radical) - KEY_includedin = uint(C.GDK_KEY_includedin) - KEY_includes = uint(C.GDK_KEY_includes) - KEY_intersection = uint(C.GDK_KEY_intersection) - KEY_union = uint(C.GDK_KEY_union) - KEY_logicaland = uint(C.GDK_KEY_logicaland) - KEY_logicalor = uint(C.GDK_KEY_logicalor) - KEY_partialderivative = uint(C.GDK_KEY_partialderivative) - KEY_function = uint(C.GDK_KEY_function) - KEY_leftarrow = uint(C.GDK_KEY_leftarrow) - KEY_uparrow = uint(C.GDK_KEY_uparrow) - KEY_rightarrow = uint(C.GDK_KEY_rightarrow) - KEY_downarrow = uint(C.GDK_KEY_downarrow) - KEY_blank = uint(C.GDK_KEY_blank) - KEY_soliddiamond = uint(C.GDK_KEY_soliddiamond) - KEY_checkerboard = uint(C.GDK_KEY_checkerboard) - KEY_ht = uint(C.GDK_KEY_ht) - KEY_ff = uint(C.GDK_KEY_ff) - KEY_cr = uint(C.GDK_KEY_cr) - KEY_lf = uint(C.GDK_KEY_lf) - KEY_nl = uint(C.GDK_KEY_nl) - KEY_vt = uint(C.GDK_KEY_vt) - KEY_lowrightcorner = uint(C.GDK_KEY_lowrightcorner) - KEY_uprightcorner = uint(C.GDK_KEY_uprightcorner) - KEY_upleftcorner = uint(C.GDK_KEY_upleftcorner) - KEY_lowleftcorner = uint(C.GDK_KEY_lowleftcorner) - KEY_crossinglines = uint(C.GDK_KEY_crossinglines) - KEY_horizlinescan1 = uint(C.GDK_KEY_horizlinescan1) - KEY_horizlinescan3 = uint(C.GDK_KEY_horizlinescan3) - KEY_horizlinescan5 = uint(C.GDK_KEY_horizlinescan5) - KEY_horizlinescan7 = uint(C.GDK_KEY_horizlinescan7) - KEY_horizlinescan9 = uint(C.GDK_KEY_horizlinescan9) - KEY_leftt = uint(C.GDK_KEY_leftt) - KEY_rightt = uint(C.GDK_KEY_rightt) - KEY_bott = uint(C.GDK_KEY_bott) - KEY_topt = uint(C.GDK_KEY_topt) - KEY_vertbar = uint(C.GDK_KEY_vertbar) - KEY_emspace = uint(C.GDK_KEY_emspace) - KEY_enspace = uint(C.GDK_KEY_enspace) - KEY_em3space = uint(C.GDK_KEY_em3space) - KEY_em4space = uint(C.GDK_KEY_em4space) - KEY_digitspace = uint(C.GDK_KEY_digitspace) - KEY_punctspace = uint(C.GDK_KEY_punctspace) - KEY_thinspace = uint(C.GDK_KEY_thinspace) - KEY_hairspace = uint(C.GDK_KEY_hairspace) - KEY_emdash = uint(C.GDK_KEY_emdash) - KEY_endash = uint(C.GDK_KEY_endash) - KEY_signifblank = uint(C.GDK_KEY_signifblank) - KEY_ellipsis = uint(C.GDK_KEY_ellipsis) - KEY_doubbaselinedot = uint(C.GDK_KEY_doubbaselinedot) - KEY_onethird = uint(C.GDK_KEY_onethird) - KEY_twothirds = uint(C.GDK_KEY_twothirds) - KEY_onefifth = uint(C.GDK_KEY_onefifth) - KEY_twofifths = uint(C.GDK_KEY_twofifths) - KEY_threefifths = uint(C.GDK_KEY_threefifths) - KEY_fourfifths = uint(C.GDK_KEY_fourfifths) - KEY_onesixth = uint(C.GDK_KEY_onesixth) - KEY_fivesixths = uint(C.GDK_KEY_fivesixths) - KEY_careof = uint(C.GDK_KEY_careof) - KEY_figdash = uint(C.GDK_KEY_figdash) - KEY_leftanglebracket = uint(C.GDK_KEY_leftanglebracket) - KEY_decimalpoint = uint(C.GDK_KEY_decimalpoint) - KEY_rightanglebracket = uint(C.GDK_KEY_rightanglebracket) - KEY_marker = uint(C.GDK_KEY_marker) - KEY_oneeighth = uint(C.GDK_KEY_oneeighth) - KEY_threeeighths = uint(C.GDK_KEY_threeeighths) - KEY_fiveeighths = uint(C.GDK_KEY_fiveeighths) - KEY_seveneighths = uint(C.GDK_KEY_seveneighths) - KEY_trademark = uint(C.GDK_KEY_trademark) - KEY_signaturemark = uint(C.GDK_KEY_signaturemark) - KEY_trademarkincircle = uint(C.GDK_KEY_trademarkincircle) - KEY_leftopentriangle = uint(C.GDK_KEY_leftopentriangle) - KEY_rightopentriangle = uint(C.GDK_KEY_rightopentriangle) - KEY_emopencircle = uint(C.GDK_KEY_emopencircle) - KEY_emopenrectangle = uint(C.GDK_KEY_emopenrectangle) - KEY_leftsinglequotemark = uint(C.GDK_KEY_leftsinglequotemark) - KEY_rightsinglequotemark = uint(C.GDK_KEY_rightsinglequotemark) - KEY_leftdoublequotemark = uint(C.GDK_KEY_leftdoublequotemark) - KEY_rightdoublequotemark = uint(C.GDK_KEY_rightdoublequotemark) - KEY_prescription = uint(C.GDK_KEY_prescription) - KEY_permille = uint(C.GDK_KEY_permille) - KEY_minutes = uint(C.GDK_KEY_minutes) - KEY_seconds = uint(C.GDK_KEY_seconds) - KEY_latincross = uint(C.GDK_KEY_latincross) - KEY_hexagram = uint(C.GDK_KEY_hexagram) - KEY_filledrectbullet = uint(C.GDK_KEY_filledrectbullet) - KEY_filledlefttribullet = uint(C.GDK_KEY_filledlefttribullet) - KEY_filledrighttribullet = uint(C.GDK_KEY_filledrighttribullet) - KEY_emfilledcircle = uint(C.GDK_KEY_emfilledcircle) - KEY_emfilledrect = uint(C.GDK_KEY_emfilledrect) - KEY_enopencircbullet = uint(C.GDK_KEY_enopencircbullet) - KEY_enopensquarebullet = uint(C.GDK_KEY_enopensquarebullet) - KEY_openrectbullet = uint(C.GDK_KEY_openrectbullet) - KEY_opentribulletup = uint(C.GDK_KEY_opentribulletup) - KEY_opentribulletdown = uint(C.GDK_KEY_opentribulletdown) - KEY_openstar = uint(C.GDK_KEY_openstar) - KEY_enfilledcircbullet = uint(C.GDK_KEY_enfilledcircbullet) - KEY_enfilledsqbullet = uint(C.GDK_KEY_enfilledsqbullet) - KEY_filledtribulletup = uint(C.GDK_KEY_filledtribulletup) - KEY_filledtribulletdown = uint(C.GDK_KEY_filledtribulletdown) - KEY_leftpointer = uint(C.GDK_KEY_leftpointer) - KEY_rightpointer = uint(C.GDK_KEY_rightpointer) - KEY_club = uint(C.GDK_KEY_club) - KEY_diamond = uint(C.GDK_KEY_diamond) - KEY_heart = uint(C.GDK_KEY_heart) - KEY_maltesecross = uint(C.GDK_KEY_maltesecross) - KEY_dagger = uint(C.GDK_KEY_dagger) - KEY_doubledagger = uint(C.GDK_KEY_doubledagger) - KEY_checkmark = uint(C.GDK_KEY_checkmark) - KEY_ballotcross = uint(C.GDK_KEY_ballotcross) - KEY_musicalsharp = uint(C.GDK_KEY_musicalsharp) - KEY_musicalflat = uint(C.GDK_KEY_musicalflat) - KEY_malesymbol = uint(C.GDK_KEY_malesymbol) - KEY_femalesymbol = uint(C.GDK_KEY_femalesymbol) - KEY_telephone = uint(C.GDK_KEY_telephone) - KEY_telephonerecorder = uint(C.GDK_KEY_telephonerecorder) - KEY_phonographcopyright = uint(C.GDK_KEY_phonographcopyright) - KEY_caret = uint(C.GDK_KEY_caret) - KEY_singlelowquotemark = uint(C.GDK_KEY_singlelowquotemark) - KEY_doublelowquotemark = uint(C.GDK_KEY_doublelowquotemark) - KEY_cursor = uint(C.GDK_KEY_cursor) - KEY_leftcaret = uint(C.GDK_KEY_leftcaret) - KEY_rightcaret = uint(C.GDK_KEY_rightcaret) - KEY_downcaret = uint(C.GDK_KEY_downcaret) - KEY_upcaret = uint(C.GDK_KEY_upcaret) - KEY_overbar = uint(C.GDK_KEY_overbar) - KEY_downtack = uint(C.GDK_KEY_downtack) - KEY_upshoe = uint(C.GDK_KEY_upshoe) - KEY_downstile = uint(C.GDK_KEY_downstile) - KEY_underbar = uint(C.GDK_KEY_underbar) - KEY_jot = uint(C.GDK_KEY_jot) - KEY_quad = uint(C.GDK_KEY_quad) - KEY_uptack = uint(C.GDK_KEY_uptack) - KEY_circle = uint(C.GDK_KEY_circle) - KEY_upstile = uint(C.GDK_KEY_upstile) - KEY_downshoe = uint(C.GDK_KEY_downshoe) - KEY_rightshoe = uint(C.GDK_KEY_rightshoe) - KEY_leftshoe = uint(C.GDK_KEY_leftshoe) - KEY_lefttack = uint(C.GDK_KEY_lefttack) - KEY_righttack = uint(C.GDK_KEY_righttack) - KEY_hebrew_doublelowline = uint(C.GDK_KEY_hebrew_doublelowline) - KEY_hebrew_aleph = uint(C.GDK_KEY_hebrew_aleph) - KEY_hebrew_bet = uint(C.GDK_KEY_hebrew_bet) - KEY_hebrew_beth = uint(C.GDK_KEY_hebrew_beth) - KEY_hebrew_gimel = uint(C.GDK_KEY_hebrew_gimel) - KEY_hebrew_gimmel = uint(C.GDK_KEY_hebrew_gimmel) - KEY_hebrew_dalet = uint(C.GDK_KEY_hebrew_dalet) - KEY_hebrew_daleth = uint(C.GDK_KEY_hebrew_daleth) - KEY_hebrew_he = uint(C.GDK_KEY_hebrew_he) - KEY_hebrew_waw = uint(C.GDK_KEY_hebrew_waw) - KEY_hebrew_zain = uint(C.GDK_KEY_hebrew_zain) - KEY_hebrew_zayin = uint(C.GDK_KEY_hebrew_zayin) - KEY_hebrew_chet = uint(C.GDK_KEY_hebrew_chet) - KEY_hebrew_het = uint(C.GDK_KEY_hebrew_het) - KEY_hebrew_tet = uint(C.GDK_KEY_hebrew_tet) - KEY_hebrew_teth = uint(C.GDK_KEY_hebrew_teth) - KEY_hebrew_yod = uint(C.GDK_KEY_hebrew_yod) - KEY_hebrew_finalkaph = uint(C.GDK_KEY_hebrew_finalkaph) - KEY_hebrew_kaph = uint(C.GDK_KEY_hebrew_kaph) - KEY_hebrew_lamed = uint(C.GDK_KEY_hebrew_lamed) - KEY_hebrew_finalmem = uint(C.GDK_KEY_hebrew_finalmem) - KEY_hebrew_mem = uint(C.GDK_KEY_hebrew_mem) - KEY_hebrew_finalnun = uint(C.GDK_KEY_hebrew_finalnun) - KEY_hebrew_nun = uint(C.GDK_KEY_hebrew_nun) - KEY_hebrew_samech = uint(C.GDK_KEY_hebrew_samech) - KEY_hebrew_samekh = uint(C.GDK_KEY_hebrew_samekh) - KEY_hebrew_ayin = uint(C.GDK_KEY_hebrew_ayin) - KEY_hebrew_finalpe = uint(C.GDK_KEY_hebrew_finalpe) - KEY_hebrew_pe = uint(C.GDK_KEY_hebrew_pe) - KEY_hebrew_finalzade = uint(C.GDK_KEY_hebrew_finalzade) - KEY_hebrew_finalzadi = uint(C.GDK_KEY_hebrew_finalzadi) - KEY_hebrew_zade = uint(C.GDK_KEY_hebrew_zade) - KEY_hebrew_zadi = uint(C.GDK_KEY_hebrew_zadi) - KEY_hebrew_qoph = uint(C.GDK_KEY_hebrew_qoph) - KEY_hebrew_kuf = uint(C.GDK_KEY_hebrew_kuf) - KEY_hebrew_resh = uint(C.GDK_KEY_hebrew_resh) - KEY_hebrew_shin = uint(C.GDK_KEY_hebrew_shin) - KEY_hebrew_taw = uint(C.GDK_KEY_hebrew_taw) - KEY_hebrew_taf = uint(C.GDK_KEY_hebrew_taf) - KEY_Hebrew_switch = uint(C.GDK_KEY_Hebrew_switch) - KEY_Thai_kokai = uint(C.GDK_KEY_Thai_kokai) - KEY_Thai_khokhai = uint(C.GDK_KEY_Thai_khokhai) - KEY_Thai_khokhuat = uint(C.GDK_KEY_Thai_khokhuat) - KEY_Thai_khokhwai = uint(C.GDK_KEY_Thai_khokhwai) - KEY_Thai_khokhon = uint(C.GDK_KEY_Thai_khokhon) - KEY_Thai_khorakhang = uint(C.GDK_KEY_Thai_khorakhang) - KEY_Thai_ngongu = uint(C.GDK_KEY_Thai_ngongu) - KEY_Thai_chochan = uint(C.GDK_KEY_Thai_chochan) - KEY_Thai_choching = uint(C.GDK_KEY_Thai_choching) - KEY_Thai_chochang = uint(C.GDK_KEY_Thai_chochang) - KEY_Thai_soso = uint(C.GDK_KEY_Thai_soso) - KEY_Thai_chochoe = uint(C.GDK_KEY_Thai_chochoe) - KEY_Thai_yoying = uint(C.GDK_KEY_Thai_yoying) - KEY_Thai_dochada = uint(C.GDK_KEY_Thai_dochada) - KEY_Thai_topatak = uint(C.GDK_KEY_Thai_topatak) - KEY_Thai_thothan = uint(C.GDK_KEY_Thai_thothan) - KEY_Thai_thonangmontho = uint(C.GDK_KEY_Thai_thonangmontho) - KEY_Thai_thophuthao = uint(C.GDK_KEY_Thai_thophuthao) - KEY_Thai_nonen = uint(C.GDK_KEY_Thai_nonen) - KEY_Thai_dodek = uint(C.GDK_KEY_Thai_dodek) - KEY_Thai_totao = uint(C.GDK_KEY_Thai_totao) - KEY_Thai_thothung = uint(C.GDK_KEY_Thai_thothung) - KEY_Thai_thothahan = uint(C.GDK_KEY_Thai_thothahan) - KEY_Thai_thothong = uint(C.GDK_KEY_Thai_thothong) - KEY_Thai_nonu = uint(C.GDK_KEY_Thai_nonu) - KEY_Thai_bobaimai = uint(C.GDK_KEY_Thai_bobaimai) - KEY_Thai_popla = uint(C.GDK_KEY_Thai_popla) - KEY_Thai_phophung = uint(C.GDK_KEY_Thai_phophung) - KEY_Thai_fofa = uint(C.GDK_KEY_Thai_fofa) - KEY_Thai_phophan = uint(C.GDK_KEY_Thai_phophan) - KEY_Thai_fofan = uint(C.GDK_KEY_Thai_fofan) - KEY_Thai_phosamphao = uint(C.GDK_KEY_Thai_phosamphao) - KEY_Thai_moma = uint(C.GDK_KEY_Thai_moma) - KEY_Thai_yoyak = uint(C.GDK_KEY_Thai_yoyak) - KEY_Thai_rorua = uint(C.GDK_KEY_Thai_rorua) - KEY_Thai_ru = uint(C.GDK_KEY_Thai_ru) - KEY_Thai_loling = uint(C.GDK_KEY_Thai_loling) - KEY_Thai_lu = uint(C.GDK_KEY_Thai_lu) - KEY_Thai_wowaen = uint(C.GDK_KEY_Thai_wowaen) - KEY_Thai_sosala = uint(C.GDK_KEY_Thai_sosala) - KEY_Thai_sorusi = uint(C.GDK_KEY_Thai_sorusi) - KEY_Thai_sosua = uint(C.GDK_KEY_Thai_sosua) - KEY_Thai_hohip = uint(C.GDK_KEY_Thai_hohip) - KEY_Thai_lochula = uint(C.GDK_KEY_Thai_lochula) - KEY_Thai_oang = uint(C.GDK_KEY_Thai_oang) - KEY_Thai_honokhuk = uint(C.GDK_KEY_Thai_honokhuk) - KEY_Thai_paiyannoi = uint(C.GDK_KEY_Thai_paiyannoi) - KEY_Thai_saraa = uint(C.GDK_KEY_Thai_saraa) - KEY_Thai_maihanakat = uint(C.GDK_KEY_Thai_maihanakat) - KEY_Thai_saraaa = uint(C.GDK_KEY_Thai_saraaa) - KEY_Thai_saraam = uint(C.GDK_KEY_Thai_saraam) - KEY_Thai_sarai = uint(C.GDK_KEY_Thai_sarai) - KEY_Thai_saraii = uint(C.GDK_KEY_Thai_saraii) - KEY_Thai_saraue = uint(C.GDK_KEY_Thai_saraue) - KEY_Thai_sarauee = uint(C.GDK_KEY_Thai_sarauee) - KEY_Thai_sarau = uint(C.GDK_KEY_Thai_sarau) - KEY_Thai_sarauu = uint(C.GDK_KEY_Thai_sarauu) - KEY_Thai_phinthu = uint(C.GDK_KEY_Thai_phinthu) - KEY_Thai_maihanakat_maitho = uint(C.GDK_KEY_Thai_maihanakat_maitho) - KEY_Thai_baht = uint(C.GDK_KEY_Thai_baht) - KEY_Thai_sarae = uint(C.GDK_KEY_Thai_sarae) - KEY_Thai_saraae = uint(C.GDK_KEY_Thai_saraae) - KEY_Thai_sarao = uint(C.GDK_KEY_Thai_sarao) - KEY_Thai_saraaimaimuan = uint(C.GDK_KEY_Thai_saraaimaimuan) - KEY_Thai_saraaimaimalai = uint(C.GDK_KEY_Thai_saraaimaimalai) - KEY_Thai_lakkhangyao = uint(C.GDK_KEY_Thai_lakkhangyao) - KEY_Thai_maiyamok = uint(C.GDK_KEY_Thai_maiyamok) - KEY_Thai_maitaikhu = uint(C.GDK_KEY_Thai_maitaikhu) - KEY_Thai_maiek = uint(C.GDK_KEY_Thai_maiek) - KEY_Thai_maitho = uint(C.GDK_KEY_Thai_maitho) - KEY_Thai_maitri = uint(C.GDK_KEY_Thai_maitri) - KEY_Thai_maichattawa = uint(C.GDK_KEY_Thai_maichattawa) - KEY_Thai_thanthakhat = uint(C.GDK_KEY_Thai_thanthakhat) - KEY_Thai_nikhahit = uint(C.GDK_KEY_Thai_nikhahit) - KEY_Thai_leksun = uint(C.GDK_KEY_Thai_leksun) - KEY_Thai_leknung = uint(C.GDK_KEY_Thai_leknung) - KEY_Thai_leksong = uint(C.GDK_KEY_Thai_leksong) - KEY_Thai_leksam = uint(C.GDK_KEY_Thai_leksam) - KEY_Thai_leksi = uint(C.GDK_KEY_Thai_leksi) - KEY_Thai_lekha = uint(C.GDK_KEY_Thai_lekha) - KEY_Thai_lekhok = uint(C.GDK_KEY_Thai_lekhok) - KEY_Thai_lekchet = uint(C.GDK_KEY_Thai_lekchet) - KEY_Thai_lekpaet = uint(C.GDK_KEY_Thai_lekpaet) - KEY_Thai_lekkao = uint(C.GDK_KEY_Thai_lekkao) - KEY_Hangul = uint(C.GDK_KEY_Hangul) - KEY_Hangul_Start = uint(C.GDK_KEY_Hangul_Start) - KEY_Hangul_End = uint(C.GDK_KEY_Hangul_End) - KEY_Hangul_Hanja = uint(C.GDK_KEY_Hangul_Hanja) - KEY_Hangul_Jamo = uint(C.GDK_KEY_Hangul_Jamo) - KEY_Hangul_Romaja = uint(C.GDK_KEY_Hangul_Romaja) - KEY_Hangul_Codeinput = uint(C.GDK_KEY_Hangul_Codeinput) - KEY_Hangul_Jeonja = uint(C.GDK_KEY_Hangul_Jeonja) - KEY_Hangul_Banja = uint(C.GDK_KEY_Hangul_Banja) - KEY_Hangul_PreHanja = uint(C.GDK_KEY_Hangul_PreHanja) - KEY_Hangul_PostHanja = uint(C.GDK_KEY_Hangul_PostHanja) - KEY_Hangul_SingleCandidate = uint(C.GDK_KEY_Hangul_SingleCandidate) - KEY_Hangul_MultipleCandidate = uint(C.GDK_KEY_Hangul_MultipleCandidate) - KEY_Hangul_PreviousCandidate = uint(C.GDK_KEY_Hangul_PreviousCandidate) - KEY_Hangul_Special = uint(C.GDK_KEY_Hangul_Special) - KEY_Hangul_switch = uint(C.GDK_KEY_Hangul_switch) - KEY_Hangul_Kiyeog = uint(C.GDK_KEY_Hangul_Kiyeog) - KEY_Hangul_SsangKiyeog = uint(C.GDK_KEY_Hangul_SsangKiyeog) - KEY_Hangul_KiyeogSios = uint(C.GDK_KEY_Hangul_KiyeogSios) - KEY_Hangul_Nieun = uint(C.GDK_KEY_Hangul_Nieun) - KEY_Hangul_NieunJieuj = uint(C.GDK_KEY_Hangul_NieunJieuj) - KEY_Hangul_NieunHieuh = uint(C.GDK_KEY_Hangul_NieunHieuh) - KEY_Hangul_Dikeud = uint(C.GDK_KEY_Hangul_Dikeud) - KEY_Hangul_SsangDikeud = uint(C.GDK_KEY_Hangul_SsangDikeud) - KEY_Hangul_Rieul = uint(C.GDK_KEY_Hangul_Rieul) - KEY_Hangul_RieulKiyeog = uint(C.GDK_KEY_Hangul_RieulKiyeog) - KEY_Hangul_RieulMieum = uint(C.GDK_KEY_Hangul_RieulMieum) - KEY_Hangul_RieulPieub = uint(C.GDK_KEY_Hangul_RieulPieub) - KEY_Hangul_RieulSios = uint(C.GDK_KEY_Hangul_RieulSios) - KEY_Hangul_RieulTieut = uint(C.GDK_KEY_Hangul_RieulTieut) - KEY_Hangul_RieulPhieuf = uint(C.GDK_KEY_Hangul_RieulPhieuf) - KEY_Hangul_RieulHieuh = uint(C.GDK_KEY_Hangul_RieulHieuh) - KEY_Hangul_Mieum = uint(C.GDK_KEY_Hangul_Mieum) - KEY_Hangul_Pieub = uint(C.GDK_KEY_Hangul_Pieub) - KEY_Hangul_SsangPieub = uint(C.GDK_KEY_Hangul_SsangPieub) - KEY_Hangul_PieubSios = uint(C.GDK_KEY_Hangul_PieubSios) - KEY_Hangul_Sios = uint(C.GDK_KEY_Hangul_Sios) - KEY_Hangul_SsangSios = uint(C.GDK_KEY_Hangul_SsangSios) - KEY_Hangul_Ieung = uint(C.GDK_KEY_Hangul_Ieung) - KEY_Hangul_Jieuj = uint(C.GDK_KEY_Hangul_Jieuj) - KEY_Hangul_SsangJieuj = uint(C.GDK_KEY_Hangul_SsangJieuj) - KEY_Hangul_Cieuc = uint(C.GDK_KEY_Hangul_Cieuc) - KEY_Hangul_Khieuq = uint(C.GDK_KEY_Hangul_Khieuq) - KEY_Hangul_Tieut = uint(C.GDK_KEY_Hangul_Tieut) - KEY_Hangul_Phieuf = uint(C.GDK_KEY_Hangul_Phieuf) - KEY_Hangul_Hieuh = uint(C.GDK_KEY_Hangul_Hieuh) - KEY_Hangul_A = uint(C.GDK_KEY_Hangul_A) - KEY_Hangul_AE = uint(C.GDK_KEY_Hangul_AE) - KEY_Hangul_YA = uint(C.GDK_KEY_Hangul_YA) - KEY_Hangul_YAE = uint(C.GDK_KEY_Hangul_YAE) - KEY_Hangul_EO = uint(C.GDK_KEY_Hangul_EO) - KEY_Hangul_E = uint(C.GDK_KEY_Hangul_E) - KEY_Hangul_YEO = uint(C.GDK_KEY_Hangul_YEO) - KEY_Hangul_YE = uint(C.GDK_KEY_Hangul_YE) - KEY_Hangul_O = uint(C.GDK_KEY_Hangul_O) - KEY_Hangul_WA = uint(C.GDK_KEY_Hangul_WA) - KEY_Hangul_WAE = uint(C.GDK_KEY_Hangul_WAE) - KEY_Hangul_OE = uint(C.GDK_KEY_Hangul_OE) - KEY_Hangul_YO = uint(C.GDK_KEY_Hangul_YO) - KEY_Hangul_U = uint(C.GDK_KEY_Hangul_U) - KEY_Hangul_WEO = uint(C.GDK_KEY_Hangul_WEO) - KEY_Hangul_WE = uint(C.GDK_KEY_Hangul_WE) - KEY_Hangul_WI = uint(C.GDK_KEY_Hangul_WI) - KEY_Hangul_YU = uint(C.GDK_KEY_Hangul_YU) - KEY_Hangul_EU = uint(C.GDK_KEY_Hangul_EU) - KEY_Hangul_YI = uint(C.GDK_KEY_Hangul_YI) - KEY_Hangul_I = uint(C.GDK_KEY_Hangul_I) - KEY_Hangul_J_Kiyeog = uint(C.GDK_KEY_Hangul_J_Kiyeog) - KEY_Hangul_J_SsangKiyeog = uint(C.GDK_KEY_Hangul_J_SsangKiyeog) - KEY_Hangul_J_KiyeogSios = uint(C.GDK_KEY_Hangul_J_KiyeogSios) - KEY_Hangul_J_Nieun = uint(C.GDK_KEY_Hangul_J_Nieun) - KEY_Hangul_J_NieunJieuj = uint(C.GDK_KEY_Hangul_J_NieunJieuj) - KEY_Hangul_J_NieunHieuh = uint(C.GDK_KEY_Hangul_J_NieunHieuh) - KEY_Hangul_J_Dikeud = uint(C.GDK_KEY_Hangul_J_Dikeud) - KEY_Hangul_J_Rieul = uint(C.GDK_KEY_Hangul_J_Rieul) - KEY_Hangul_J_RieulKiyeog = uint(C.GDK_KEY_Hangul_J_RieulKiyeog) - KEY_Hangul_J_RieulMieum = uint(C.GDK_KEY_Hangul_J_RieulMieum) - KEY_Hangul_J_RieulPieub = uint(C.GDK_KEY_Hangul_J_RieulPieub) - KEY_Hangul_J_RieulSios = uint(C.GDK_KEY_Hangul_J_RieulSios) - KEY_Hangul_J_RieulTieut = uint(C.GDK_KEY_Hangul_J_RieulTieut) - KEY_Hangul_J_RieulPhieuf = uint(C.GDK_KEY_Hangul_J_RieulPhieuf) - KEY_Hangul_J_RieulHieuh = uint(C.GDK_KEY_Hangul_J_RieulHieuh) - KEY_Hangul_J_Mieum = uint(C.GDK_KEY_Hangul_J_Mieum) - KEY_Hangul_J_Pieub = uint(C.GDK_KEY_Hangul_J_Pieub) - KEY_Hangul_J_PieubSios = uint(C.GDK_KEY_Hangul_J_PieubSios) - KEY_Hangul_J_Sios = uint(C.GDK_KEY_Hangul_J_Sios) - KEY_Hangul_J_SsangSios = uint(C.GDK_KEY_Hangul_J_SsangSios) - KEY_Hangul_J_Ieung = uint(C.GDK_KEY_Hangul_J_Ieung) - KEY_Hangul_J_Jieuj = uint(C.GDK_KEY_Hangul_J_Jieuj) - KEY_Hangul_J_Cieuc = uint(C.GDK_KEY_Hangul_J_Cieuc) - KEY_Hangul_J_Khieuq = uint(C.GDK_KEY_Hangul_J_Khieuq) - KEY_Hangul_J_Tieut = uint(C.GDK_KEY_Hangul_J_Tieut) - KEY_Hangul_J_Phieuf = uint(C.GDK_KEY_Hangul_J_Phieuf) - KEY_Hangul_J_Hieuh = uint(C.GDK_KEY_Hangul_J_Hieuh) - KEY_Hangul_RieulYeorinHieuh = uint(C.GDK_KEY_Hangul_RieulYeorinHieuh) - KEY_Hangul_SunkyeongeumMieum = uint(C.GDK_KEY_Hangul_SunkyeongeumMieum) - KEY_Hangul_SunkyeongeumPieub = uint(C.GDK_KEY_Hangul_SunkyeongeumPieub) - KEY_Hangul_PanSios = uint(C.GDK_KEY_Hangul_PanSios) - KEY_Hangul_KkogjiDalrinIeung = uint(C.GDK_KEY_Hangul_KkogjiDalrinIeung) - KEY_Hangul_SunkyeongeumPhieuf = uint(C.GDK_KEY_Hangul_SunkyeongeumPhieuf) - KEY_Hangul_YeorinHieuh = uint(C.GDK_KEY_Hangul_YeorinHieuh) - KEY_Hangul_AraeA = uint(C.GDK_KEY_Hangul_AraeA) - KEY_Hangul_AraeAE = uint(C.GDK_KEY_Hangul_AraeAE) - KEY_Hangul_J_PanSios = uint(C.GDK_KEY_Hangul_J_PanSios) - KEY_Hangul_J_KkogjiDalrinIeung = uint(C.GDK_KEY_Hangul_J_KkogjiDalrinIeung) - KEY_Hangul_J_YeorinHieuh = uint(C.GDK_KEY_Hangul_J_YeorinHieuh) - KEY_Korean_Won = uint(C.GDK_KEY_Korean_Won) - KEY_Armenian_ligature_ew = uint(C.GDK_KEY_Armenian_ligature_ew) - KEY_Armenian_full_stop = uint(C.GDK_KEY_Armenian_full_stop) - KEY_Armenian_verjaket = uint(C.GDK_KEY_Armenian_verjaket) - KEY_Armenian_separation_mark = uint(C.GDK_KEY_Armenian_separation_mark) - KEY_Armenian_but = uint(C.GDK_KEY_Armenian_but) - KEY_Armenian_hyphen = uint(C.GDK_KEY_Armenian_hyphen) - KEY_Armenian_yentamna = uint(C.GDK_KEY_Armenian_yentamna) - KEY_Armenian_exclam = uint(C.GDK_KEY_Armenian_exclam) - KEY_Armenian_amanak = uint(C.GDK_KEY_Armenian_amanak) - KEY_Armenian_accent = uint(C.GDK_KEY_Armenian_accent) - KEY_Armenian_shesht = uint(C.GDK_KEY_Armenian_shesht) - KEY_Armenian_question = uint(C.GDK_KEY_Armenian_question) - KEY_Armenian_paruyk = uint(C.GDK_KEY_Armenian_paruyk) - KEY_Armenian_AYB = uint(C.GDK_KEY_Armenian_AYB) - KEY_Armenian_ayb = uint(C.GDK_KEY_Armenian_ayb) - KEY_Armenian_BEN = uint(C.GDK_KEY_Armenian_BEN) - KEY_Armenian_ben = uint(C.GDK_KEY_Armenian_ben) - KEY_Armenian_GIM = uint(C.GDK_KEY_Armenian_GIM) - KEY_Armenian_gim = uint(C.GDK_KEY_Armenian_gim) - KEY_Armenian_DA = uint(C.GDK_KEY_Armenian_DA) - KEY_Armenian_da = uint(C.GDK_KEY_Armenian_da) - KEY_Armenian_YECH = uint(C.GDK_KEY_Armenian_YECH) - KEY_Armenian_yech = uint(C.GDK_KEY_Armenian_yech) - KEY_Armenian_ZA = uint(C.GDK_KEY_Armenian_ZA) - KEY_Armenian_za = uint(C.GDK_KEY_Armenian_za) - KEY_Armenian_E = uint(C.GDK_KEY_Armenian_E) - KEY_Armenian_e = uint(C.GDK_KEY_Armenian_e) - KEY_Armenian_AT = uint(C.GDK_KEY_Armenian_AT) - KEY_Armenian_at = uint(C.GDK_KEY_Armenian_at) - KEY_Armenian_TO = uint(C.GDK_KEY_Armenian_TO) - KEY_Armenian_to = uint(C.GDK_KEY_Armenian_to) - KEY_Armenian_ZHE = uint(C.GDK_KEY_Armenian_ZHE) - KEY_Armenian_zhe = uint(C.GDK_KEY_Armenian_zhe) - KEY_Armenian_INI = uint(C.GDK_KEY_Armenian_INI) - KEY_Armenian_ini = uint(C.GDK_KEY_Armenian_ini) - KEY_Armenian_LYUN = uint(C.GDK_KEY_Armenian_LYUN) - KEY_Armenian_lyun = uint(C.GDK_KEY_Armenian_lyun) - KEY_Armenian_KHE = uint(C.GDK_KEY_Armenian_KHE) - KEY_Armenian_khe = uint(C.GDK_KEY_Armenian_khe) - KEY_Armenian_TSA = uint(C.GDK_KEY_Armenian_TSA) - KEY_Armenian_tsa = uint(C.GDK_KEY_Armenian_tsa) - KEY_Armenian_KEN = uint(C.GDK_KEY_Armenian_KEN) - KEY_Armenian_ken = uint(C.GDK_KEY_Armenian_ken) - KEY_Armenian_HO = uint(C.GDK_KEY_Armenian_HO) - KEY_Armenian_ho = uint(C.GDK_KEY_Armenian_ho) - KEY_Armenian_DZA = uint(C.GDK_KEY_Armenian_DZA) - KEY_Armenian_dza = uint(C.GDK_KEY_Armenian_dza) - KEY_Armenian_GHAT = uint(C.GDK_KEY_Armenian_GHAT) - KEY_Armenian_ghat = uint(C.GDK_KEY_Armenian_ghat) - KEY_Armenian_TCHE = uint(C.GDK_KEY_Armenian_TCHE) - KEY_Armenian_tche = uint(C.GDK_KEY_Armenian_tche) - KEY_Armenian_MEN = uint(C.GDK_KEY_Armenian_MEN) - KEY_Armenian_men = uint(C.GDK_KEY_Armenian_men) - KEY_Armenian_HI = uint(C.GDK_KEY_Armenian_HI) - KEY_Armenian_hi = uint(C.GDK_KEY_Armenian_hi) - KEY_Armenian_NU = uint(C.GDK_KEY_Armenian_NU) - KEY_Armenian_nu = uint(C.GDK_KEY_Armenian_nu) - KEY_Armenian_SHA = uint(C.GDK_KEY_Armenian_SHA) - KEY_Armenian_sha = uint(C.GDK_KEY_Armenian_sha) - KEY_Armenian_VO = uint(C.GDK_KEY_Armenian_VO) - KEY_Armenian_vo = uint(C.GDK_KEY_Armenian_vo) - KEY_Armenian_CHA = uint(C.GDK_KEY_Armenian_CHA) - KEY_Armenian_cha = uint(C.GDK_KEY_Armenian_cha) - KEY_Armenian_PE = uint(C.GDK_KEY_Armenian_PE) - KEY_Armenian_pe = uint(C.GDK_KEY_Armenian_pe) - KEY_Armenian_JE = uint(C.GDK_KEY_Armenian_JE) - KEY_Armenian_je = uint(C.GDK_KEY_Armenian_je) - KEY_Armenian_RA = uint(C.GDK_KEY_Armenian_RA) - KEY_Armenian_ra = uint(C.GDK_KEY_Armenian_ra) - KEY_Armenian_SE = uint(C.GDK_KEY_Armenian_SE) - KEY_Armenian_se = uint(C.GDK_KEY_Armenian_se) - KEY_Armenian_VEV = uint(C.GDK_KEY_Armenian_VEV) - KEY_Armenian_vev = uint(C.GDK_KEY_Armenian_vev) - KEY_Armenian_TYUN = uint(C.GDK_KEY_Armenian_TYUN) - KEY_Armenian_tyun = uint(C.GDK_KEY_Armenian_tyun) - KEY_Armenian_RE = uint(C.GDK_KEY_Armenian_RE) - KEY_Armenian_re = uint(C.GDK_KEY_Armenian_re) - KEY_Armenian_TSO = uint(C.GDK_KEY_Armenian_TSO) - KEY_Armenian_tso = uint(C.GDK_KEY_Armenian_tso) - KEY_Armenian_VYUN = uint(C.GDK_KEY_Armenian_VYUN) - KEY_Armenian_vyun = uint(C.GDK_KEY_Armenian_vyun) - KEY_Armenian_PYUR = uint(C.GDK_KEY_Armenian_PYUR) - KEY_Armenian_pyur = uint(C.GDK_KEY_Armenian_pyur) - KEY_Armenian_KE = uint(C.GDK_KEY_Armenian_KE) - KEY_Armenian_ke = uint(C.GDK_KEY_Armenian_ke) - KEY_Armenian_O = uint(C.GDK_KEY_Armenian_O) - KEY_Armenian_o = uint(C.GDK_KEY_Armenian_o) - KEY_Armenian_FE = uint(C.GDK_KEY_Armenian_FE) - KEY_Armenian_fe = uint(C.GDK_KEY_Armenian_fe) - KEY_Armenian_apostrophe = uint(C.GDK_KEY_Armenian_apostrophe) - KEY_Georgian_an = uint(C.GDK_KEY_Georgian_an) - KEY_Georgian_ban = uint(C.GDK_KEY_Georgian_ban) - KEY_Georgian_gan = uint(C.GDK_KEY_Georgian_gan) - KEY_Georgian_don = uint(C.GDK_KEY_Georgian_don) - KEY_Georgian_en = uint(C.GDK_KEY_Georgian_en) - KEY_Georgian_vin = uint(C.GDK_KEY_Georgian_vin) - KEY_Georgian_zen = uint(C.GDK_KEY_Georgian_zen) - KEY_Georgian_tan = uint(C.GDK_KEY_Georgian_tan) - KEY_Georgian_in = uint(C.GDK_KEY_Georgian_in) - KEY_Georgian_kan = uint(C.GDK_KEY_Georgian_kan) - KEY_Georgian_las = uint(C.GDK_KEY_Georgian_las) - KEY_Georgian_man = uint(C.GDK_KEY_Georgian_man) - KEY_Georgian_nar = uint(C.GDK_KEY_Georgian_nar) - KEY_Georgian_on = uint(C.GDK_KEY_Georgian_on) - KEY_Georgian_par = uint(C.GDK_KEY_Georgian_par) - KEY_Georgian_zhar = uint(C.GDK_KEY_Georgian_zhar) - KEY_Georgian_rae = uint(C.GDK_KEY_Georgian_rae) - KEY_Georgian_san = uint(C.GDK_KEY_Georgian_san) - KEY_Georgian_tar = uint(C.GDK_KEY_Georgian_tar) - KEY_Georgian_un = uint(C.GDK_KEY_Georgian_un) - KEY_Georgian_phar = uint(C.GDK_KEY_Georgian_phar) - KEY_Georgian_khar = uint(C.GDK_KEY_Georgian_khar) - KEY_Georgian_ghan = uint(C.GDK_KEY_Georgian_ghan) - KEY_Georgian_qar = uint(C.GDK_KEY_Georgian_qar) - KEY_Georgian_shin = uint(C.GDK_KEY_Georgian_shin) - KEY_Georgian_chin = uint(C.GDK_KEY_Georgian_chin) - KEY_Georgian_can = uint(C.GDK_KEY_Georgian_can) - KEY_Georgian_jil = uint(C.GDK_KEY_Georgian_jil) - KEY_Georgian_cil = uint(C.GDK_KEY_Georgian_cil) - KEY_Georgian_char = uint(C.GDK_KEY_Georgian_char) - KEY_Georgian_xan = uint(C.GDK_KEY_Georgian_xan) - KEY_Georgian_jhan = uint(C.GDK_KEY_Georgian_jhan) - KEY_Georgian_hae = uint(C.GDK_KEY_Georgian_hae) - KEY_Georgian_he = uint(C.GDK_KEY_Georgian_he) - KEY_Georgian_hie = uint(C.GDK_KEY_Georgian_hie) - KEY_Georgian_we = uint(C.GDK_KEY_Georgian_we) - KEY_Georgian_har = uint(C.GDK_KEY_Georgian_har) - KEY_Georgian_hoe = uint(C.GDK_KEY_Georgian_hoe) - KEY_Georgian_fi = uint(C.GDK_KEY_Georgian_fi) - KEY_Xabovedot = uint(C.GDK_KEY_Xabovedot) - KEY_Ibreve = uint(C.GDK_KEY_Ibreve) - KEY_Zstroke = uint(C.GDK_KEY_Zstroke) - KEY_Gcaron = uint(C.GDK_KEY_Gcaron) - KEY_Ocaron = uint(C.GDK_KEY_Ocaron) - KEY_Obarred = uint(C.GDK_KEY_Obarred) - KEY_xabovedot = uint(C.GDK_KEY_xabovedot) - KEY_ibreve = uint(C.GDK_KEY_ibreve) - KEY_zstroke = uint(C.GDK_KEY_zstroke) - KEY_gcaron = uint(C.GDK_KEY_gcaron) - KEY_ocaron = uint(C.GDK_KEY_ocaron) - KEY_obarred = uint(C.GDK_KEY_obarred) - KEY_SCHWA = uint(C.GDK_KEY_SCHWA) - KEY_schwa = uint(C.GDK_KEY_schwa) - KEY_EZH = uint(C.GDK_KEY_EZH) - KEY_ezh = uint(C.GDK_KEY_ezh) - KEY_Lbelowdot = uint(C.GDK_KEY_Lbelowdot) - KEY_lbelowdot = uint(C.GDK_KEY_lbelowdot) - KEY_Abelowdot = uint(C.GDK_KEY_Abelowdot) - KEY_abelowdot = uint(C.GDK_KEY_abelowdot) - KEY_Ahook = uint(C.GDK_KEY_Ahook) - KEY_ahook = uint(C.GDK_KEY_ahook) - KEY_Acircumflexacute = uint(C.GDK_KEY_Acircumflexacute) - KEY_acircumflexacute = uint(C.GDK_KEY_acircumflexacute) - KEY_Acircumflexgrave = uint(C.GDK_KEY_Acircumflexgrave) - KEY_acircumflexgrave = uint(C.GDK_KEY_acircumflexgrave) - KEY_Acircumflexhook = uint(C.GDK_KEY_Acircumflexhook) - KEY_acircumflexhook = uint(C.GDK_KEY_acircumflexhook) - KEY_Acircumflextilde = uint(C.GDK_KEY_Acircumflextilde) - KEY_acircumflextilde = uint(C.GDK_KEY_acircumflextilde) - KEY_Acircumflexbelowdot = uint(C.GDK_KEY_Acircumflexbelowdot) - KEY_acircumflexbelowdot = uint(C.GDK_KEY_acircumflexbelowdot) - KEY_Abreveacute = uint(C.GDK_KEY_Abreveacute) - KEY_abreveacute = uint(C.GDK_KEY_abreveacute) - KEY_Abrevegrave = uint(C.GDK_KEY_Abrevegrave) - KEY_abrevegrave = uint(C.GDK_KEY_abrevegrave) - KEY_Abrevehook = uint(C.GDK_KEY_Abrevehook) - KEY_abrevehook = uint(C.GDK_KEY_abrevehook) - KEY_Abrevetilde = uint(C.GDK_KEY_Abrevetilde) - KEY_abrevetilde = uint(C.GDK_KEY_abrevetilde) - KEY_Abrevebelowdot = uint(C.GDK_KEY_Abrevebelowdot) - KEY_abrevebelowdot = uint(C.GDK_KEY_abrevebelowdot) - KEY_Ebelowdot = uint(C.GDK_KEY_Ebelowdot) - KEY_ebelowdot = uint(C.GDK_KEY_ebelowdot) - KEY_Ehook = uint(C.GDK_KEY_Ehook) - KEY_ehook = uint(C.GDK_KEY_ehook) - KEY_Etilde = uint(C.GDK_KEY_Etilde) - KEY_etilde = uint(C.GDK_KEY_etilde) - KEY_Ecircumflexacute = uint(C.GDK_KEY_Ecircumflexacute) - KEY_ecircumflexacute = uint(C.GDK_KEY_ecircumflexacute) - KEY_Ecircumflexgrave = uint(C.GDK_KEY_Ecircumflexgrave) - KEY_ecircumflexgrave = uint(C.GDK_KEY_ecircumflexgrave) - KEY_Ecircumflexhook = uint(C.GDK_KEY_Ecircumflexhook) - KEY_ecircumflexhook = uint(C.GDK_KEY_ecircumflexhook) - KEY_Ecircumflextilde = uint(C.GDK_KEY_Ecircumflextilde) - KEY_ecircumflextilde = uint(C.GDK_KEY_ecircumflextilde) - KEY_Ecircumflexbelowdot = uint(C.GDK_KEY_Ecircumflexbelowdot) - KEY_ecircumflexbelowdot = uint(C.GDK_KEY_ecircumflexbelowdot) - KEY_Ihook = uint(C.GDK_KEY_Ihook) - KEY_ihook = uint(C.GDK_KEY_ihook) - KEY_Ibelowdot = uint(C.GDK_KEY_Ibelowdot) - KEY_ibelowdot = uint(C.GDK_KEY_ibelowdot) - KEY_Obelowdot = uint(C.GDK_KEY_Obelowdot) - KEY_obelowdot = uint(C.GDK_KEY_obelowdot) - KEY_Ohook = uint(C.GDK_KEY_Ohook) - KEY_ohook = uint(C.GDK_KEY_ohook) - KEY_Ocircumflexacute = uint(C.GDK_KEY_Ocircumflexacute) - KEY_ocircumflexacute = uint(C.GDK_KEY_ocircumflexacute) - KEY_Ocircumflexgrave = uint(C.GDK_KEY_Ocircumflexgrave) - KEY_ocircumflexgrave = uint(C.GDK_KEY_ocircumflexgrave) - KEY_Ocircumflexhook = uint(C.GDK_KEY_Ocircumflexhook) - KEY_ocircumflexhook = uint(C.GDK_KEY_ocircumflexhook) - KEY_Ocircumflextilde = uint(C.GDK_KEY_Ocircumflextilde) - KEY_ocircumflextilde = uint(C.GDK_KEY_ocircumflextilde) - KEY_Ocircumflexbelowdot = uint(C.GDK_KEY_Ocircumflexbelowdot) - KEY_ocircumflexbelowdot = uint(C.GDK_KEY_ocircumflexbelowdot) - KEY_Ohornacute = uint(C.GDK_KEY_Ohornacute) - KEY_ohornacute = uint(C.GDK_KEY_ohornacute) - KEY_Ohorngrave = uint(C.GDK_KEY_Ohorngrave) - KEY_ohorngrave = uint(C.GDK_KEY_ohorngrave) - KEY_Ohornhook = uint(C.GDK_KEY_Ohornhook) - KEY_ohornhook = uint(C.GDK_KEY_ohornhook) - KEY_Ohorntilde = uint(C.GDK_KEY_Ohorntilde) - KEY_ohorntilde = uint(C.GDK_KEY_ohorntilde) - KEY_Ohornbelowdot = uint(C.GDK_KEY_Ohornbelowdot) - KEY_ohornbelowdot = uint(C.GDK_KEY_ohornbelowdot) - KEY_Ubelowdot = uint(C.GDK_KEY_Ubelowdot) - KEY_ubelowdot = uint(C.GDK_KEY_ubelowdot) - KEY_Uhook = uint(C.GDK_KEY_Uhook) - KEY_uhook = uint(C.GDK_KEY_uhook) - KEY_Uhornacute = uint(C.GDK_KEY_Uhornacute) - KEY_uhornacute = uint(C.GDK_KEY_uhornacute) - KEY_Uhorngrave = uint(C.GDK_KEY_Uhorngrave) - KEY_uhorngrave = uint(C.GDK_KEY_uhorngrave) - KEY_Uhornhook = uint(C.GDK_KEY_Uhornhook) - KEY_uhornhook = uint(C.GDK_KEY_uhornhook) - KEY_Uhorntilde = uint(C.GDK_KEY_Uhorntilde) - KEY_uhorntilde = uint(C.GDK_KEY_uhorntilde) - KEY_Uhornbelowdot = uint(C.GDK_KEY_Uhornbelowdot) - KEY_uhornbelowdot = uint(C.GDK_KEY_uhornbelowdot) - KEY_Ybelowdot = uint(C.GDK_KEY_Ybelowdot) - KEY_ybelowdot = uint(C.GDK_KEY_ybelowdot) - KEY_Yhook = uint(C.GDK_KEY_Yhook) - KEY_yhook = uint(C.GDK_KEY_yhook) - KEY_Ytilde = uint(C.GDK_KEY_Ytilde) - KEY_ytilde = uint(C.GDK_KEY_ytilde) - KEY_Ohorn = uint(C.GDK_KEY_Ohorn) - KEY_ohorn = uint(C.GDK_KEY_ohorn) - KEY_Uhorn = uint(C.GDK_KEY_Uhorn) - KEY_uhorn = uint(C.GDK_KEY_uhorn) - KEY_EcuSign = uint(C.GDK_KEY_EcuSign) - KEY_ColonSign = uint(C.GDK_KEY_ColonSign) - KEY_CruzeiroSign = uint(C.GDK_KEY_CruzeiroSign) - KEY_FFrancSign = uint(C.GDK_KEY_FFrancSign) - KEY_LiraSign = uint(C.GDK_KEY_LiraSign) - KEY_MillSign = uint(C.GDK_KEY_MillSign) - KEY_NairaSign = uint(C.GDK_KEY_NairaSign) - KEY_PesetaSign = uint(C.GDK_KEY_PesetaSign) - KEY_RupeeSign = uint(C.GDK_KEY_RupeeSign) - KEY_WonSign = uint(C.GDK_KEY_WonSign) - KEY_NewSheqelSign = uint(C.GDK_KEY_NewSheqelSign) - KEY_DongSign = uint(C.GDK_KEY_DongSign) - KEY_EuroSign = uint(C.GDK_KEY_EuroSign) - KEY_zerosuperior = uint(C.GDK_KEY_zerosuperior) - KEY_foursuperior = uint(C.GDK_KEY_foursuperior) - KEY_fivesuperior = uint(C.GDK_KEY_fivesuperior) - KEY_sixsuperior = uint(C.GDK_KEY_sixsuperior) - KEY_sevensuperior = uint(C.GDK_KEY_sevensuperior) - KEY_eightsuperior = uint(C.GDK_KEY_eightsuperior) - KEY_ninesuperior = uint(C.GDK_KEY_ninesuperior) - KEY_zerosubscript = uint(C.GDK_KEY_zerosubscript) - KEY_onesubscript = uint(C.GDK_KEY_onesubscript) - KEY_twosubscript = uint(C.GDK_KEY_twosubscript) - KEY_threesubscript = uint(C.GDK_KEY_threesubscript) - KEY_foursubscript = uint(C.GDK_KEY_foursubscript) - KEY_fivesubscript = uint(C.GDK_KEY_fivesubscript) - KEY_sixsubscript = uint(C.GDK_KEY_sixsubscript) - KEY_sevensubscript = uint(C.GDK_KEY_sevensubscript) - KEY_eightsubscript = uint(C.GDK_KEY_eightsubscript) - KEY_ninesubscript = uint(C.GDK_KEY_ninesubscript) - KEY_partdifferential = uint(C.GDK_KEY_partdifferential) - KEY_emptyset = uint(C.GDK_KEY_emptyset) - KEY_elementof = uint(C.GDK_KEY_elementof) - KEY_notelementof = uint(C.GDK_KEY_notelementof) - KEY_containsas = uint(C.GDK_KEY_containsas) - KEY_squareroot = uint(C.GDK_KEY_squareroot) - KEY_cuberoot = uint(C.GDK_KEY_cuberoot) - KEY_fourthroot = uint(C.GDK_KEY_fourthroot) - KEY_dintegral = uint(C.GDK_KEY_dintegral) - KEY_tintegral = uint(C.GDK_KEY_tintegral) - KEY_because = uint(C.GDK_KEY_because) - KEY_approxeq = uint(C.GDK_KEY_approxeq) - KEY_notapproxeq = uint(C.GDK_KEY_notapproxeq) - KEY_notidentical = uint(C.GDK_KEY_notidentical) - KEY_stricteq = uint(C.GDK_KEY_stricteq) - KEY_braille_dot_1 = uint(C.GDK_KEY_braille_dot_1) - KEY_braille_dot_2 = uint(C.GDK_KEY_braille_dot_2) - KEY_braille_dot_3 = uint(C.GDK_KEY_braille_dot_3) - KEY_braille_dot_4 = uint(C.GDK_KEY_braille_dot_4) - KEY_braille_dot_5 = uint(C.GDK_KEY_braille_dot_5) - KEY_braille_dot_6 = uint(C.GDK_KEY_braille_dot_6) - KEY_braille_dot_7 = uint(C.GDK_KEY_braille_dot_7) - KEY_braille_dot_8 = uint(C.GDK_KEY_braille_dot_8) - KEY_braille_dot_9 = uint(C.GDK_KEY_braille_dot_9) - KEY_braille_dot_10 = uint(C.GDK_KEY_braille_dot_10) - KEY_braille_blank = uint(C.GDK_KEY_braille_blank) - KEY_braille_dots_1 = uint(C.GDK_KEY_braille_dots_1) - KEY_braille_dots_2 = uint(C.GDK_KEY_braille_dots_2) - KEY_braille_dots_12 = uint(C.GDK_KEY_braille_dots_12) - KEY_braille_dots_3 = uint(C.GDK_KEY_braille_dots_3) - KEY_braille_dots_13 = uint(C.GDK_KEY_braille_dots_13) - KEY_braille_dots_23 = uint(C.GDK_KEY_braille_dots_23) - KEY_braille_dots_123 = uint(C.GDK_KEY_braille_dots_123) - KEY_braille_dots_4 = uint(C.GDK_KEY_braille_dots_4) - KEY_braille_dots_14 = uint(C.GDK_KEY_braille_dots_14) - KEY_braille_dots_24 = uint(C.GDK_KEY_braille_dots_24) - KEY_braille_dots_124 = uint(C.GDK_KEY_braille_dots_124) - KEY_braille_dots_34 = uint(C.GDK_KEY_braille_dots_34) - KEY_braille_dots_134 = uint(C.GDK_KEY_braille_dots_134) - KEY_braille_dots_234 = uint(C.GDK_KEY_braille_dots_234) - KEY_braille_dots_1234 = uint(C.GDK_KEY_braille_dots_1234) - KEY_braille_dots_5 = uint(C.GDK_KEY_braille_dots_5) - KEY_braille_dots_15 = uint(C.GDK_KEY_braille_dots_15) - KEY_braille_dots_25 = uint(C.GDK_KEY_braille_dots_25) - KEY_braille_dots_125 = uint(C.GDK_KEY_braille_dots_125) - KEY_braille_dots_35 = uint(C.GDK_KEY_braille_dots_35) - KEY_braille_dots_135 = uint(C.GDK_KEY_braille_dots_135) - KEY_braille_dots_235 = uint(C.GDK_KEY_braille_dots_235) - KEY_braille_dots_1235 = uint(C.GDK_KEY_braille_dots_1235) - KEY_braille_dots_45 = uint(C.GDK_KEY_braille_dots_45) - KEY_braille_dots_145 = uint(C.GDK_KEY_braille_dots_145) - KEY_braille_dots_245 = uint(C.GDK_KEY_braille_dots_245) - KEY_braille_dots_1245 = uint(C.GDK_KEY_braille_dots_1245) - KEY_braille_dots_345 = uint(C.GDK_KEY_braille_dots_345) - KEY_braille_dots_1345 = uint(C.GDK_KEY_braille_dots_1345) - KEY_braille_dots_2345 = uint(C.GDK_KEY_braille_dots_2345) - KEY_braille_dots_12345 = uint(C.GDK_KEY_braille_dots_12345) - KEY_braille_dots_6 = uint(C.GDK_KEY_braille_dots_6) - KEY_braille_dots_16 = uint(C.GDK_KEY_braille_dots_16) - KEY_braille_dots_26 = uint(C.GDK_KEY_braille_dots_26) - KEY_braille_dots_126 = uint(C.GDK_KEY_braille_dots_126) - KEY_braille_dots_36 = uint(C.GDK_KEY_braille_dots_36) - KEY_braille_dots_136 = uint(C.GDK_KEY_braille_dots_136) - KEY_braille_dots_236 = uint(C.GDK_KEY_braille_dots_236) - KEY_braille_dots_1236 = uint(C.GDK_KEY_braille_dots_1236) - KEY_braille_dots_46 = uint(C.GDK_KEY_braille_dots_46) - KEY_braille_dots_146 = uint(C.GDK_KEY_braille_dots_146) - KEY_braille_dots_246 = uint(C.GDK_KEY_braille_dots_246) - KEY_braille_dots_1246 = uint(C.GDK_KEY_braille_dots_1246) - KEY_braille_dots_346 = uint(C.GDK_KEY_braille_dots_346) - KEY_braille_dots_1346 = uint(C.GDK_KEY_braille_dots_1346) - KEY_braille_dots_2346 = uint(C.GDK_KEY_braille_dots_2346) - KEY_braille_dots_12346 = uint(C.GDK_KEY_braille_dots_12346) - KEY_braille_dots_56 = uint(C.GDK_KEY_braille_dots_56) - KEY_braille_dots_156 = uint(C.GDK_KEY_braille_dots_156) - KEY_braille_dots_256 = uint(C.GDK_KEY_braille_dots_256) - KEY_braille_dots_1256 = uint(C.GDK_KEY_braille_dots_1256) - KEY_braille_dots_356 = uint(C.GDK_KEY_braille_dots_356) - KEY_braille_dots_1356 = uint(C.GDK_KEY_braille_dots_1356) - KEY_braille_dots_2356 = uint(C.GDK_KEY_braille_dots_2356) - KEY_braille_dots_12356 = uint(C.GDK_KEY_braille_dots_12356) - KEY_braille_dots_456 = uint(C.GDK_KEY_braille_dots_456) - KEY_braille_dots_1456 = uint(C.GDK_KEY_braille_dots_1456) - KEY_braille_dots_2456 = uint(C.GDK_KEY_braille_dots_2456) - KEY_braille_dots_12456 = uint(C.GDK_KEY_braille_dots_12456) - KEY_braille_dots_3456 = uint(C.GDK_KEY_braille_dots_3456) - KEY_braille_dots_13456 = uint(C.GDK_KEY_braille_dots_13456) - KEY_braille_dots_23456 = uint(C.GDK_KEY_braille_dots_23456) - KEY_braille_dots_123456 = uint(C.GDK_KEY_braille_dots_123456) - KEY_braille_dots_7 = uint(C.GDK_KEY_braille_dots_7) - KEY_braille_dots_17 = uint(C.GDK_KEY_braille_dots_17) - KEY_braille_dots_27 = uint(C.GDK_KEY_braille_dots_27) - KEY_braille_dots_127 = uint(C.GDK_KEY_braille_dots_127) - KEY_braille_dots_37 = uint(C.GDK_KEY_braille_dots_37) - KEY_braille_dots_137 = uint(C.GDK_KEY_braille_dots_137) - KEY_braille_dots_237 = uint(C.GDK_KEY_braille_dots_237) - KEY_braille_dots_1237 = uint(C.GDK_KEY_braille_dots_1237) - KEY_braille_dots_47 = uint(C.GDK_KEY_braille_dots_47) - KEY_braille_dots_147 = uint(C.GDK_KEY_braille_dots_147) - KEY_braille_dots_247 = uint(C.GDK_KEY_braille_dots_247) - KEY_braille_dots_1247 = uint(C.GDK_KEY_braille_dots_1247) - KEY_braille_dots_347 = uint(C.GDK_KEY_braille_dots_347) - KEY_braille_dots_1347 = uint(C.GDK_KEY_braille_dots_1347) - KEY_braille_dots_2347 = uint(C.GDK_KEY_braille_dots_2347) - KEY_braille_dots_12347 = uint(C.GDK_KEY_braille_dots_12347) - KEY_braille_dots_57 = uint(C.GDK_KEY_braille_dots_57) - KEY_braille_dots_157 = uint(C.GDK_KEY_braille_dots_157) - KEY_braille_dots_257 = uint(C.GDK_KEY_braille_dots_257) - KEY_braille_dots_1257 = uint(C.GDK_KEY_braille_dots_1257) - KEY_braille_dots_357 = uint(C.GDK_KEY_braille_dots_357) - KEY_braille_dots_1357 = uint(C.GDK_KEY_braille_dots_1357) - KEY_braille_dots_2357 = uint(C.GDK_KEY_braille_dots_2357) - KEY_braille_dots_12357 = uint(C.GDK_KEY_braille_dots_12357) - KEY_braille_dots_457 = uint(C.GDK_KEY_braille_dots_457) - KEY_braille_dots_1457 = uint(C.GDK_KEY_braille_dots_1457) - KEY_braille_dots_2457 = uint(C.GDK_KEY_braille_dots_2457) - KEY_braille_dots_12457 = uint(C.GDK_KEY_braille_dots_12457) - KEY_braille_dots_3457 = uint(C.GDK_KEY_braille_dots_3457) - KEY_braille_dots_13457 = uint(C.GDK_KEY_braille_dots_13457) - KEY_braille_dots_23457 = uint(C.GDK_KEY_braille_dots_23457) - KEY_braille_dots_123457 = uint(C.GDK_KEY_braille_dots_123457) - KEY_braille_dots_67 = uint(C.GDK_KEY_braille_dots_67) - KEY_braille_dots_167 = uint(C.GDK_KEY_braille_dots_167) - KEY_braille_dots_267 = uint(C.GDK_KEY_braille_dots_267) - KEY_braille_dots_1267 = uint(C.GDK_KEY_braille_dots_1267) - KEY_braille_dots_367 = uint(C.GDK_KEY_braille_dots_367) - KEY_braille_dots_1367 = uint(C.GDK_KEY_braille_dots_1367) - KEY_braille_dots_2367 = uint(C.GDK_KEY_braille_dots_2367) - KEY_braille_dots_12367 = uint(C.GDK_KEY_braille_dots_12367) - KEY_braille_dots_467 = uint(C.GDK_KEY_braille_dots_467) - KEY_braille_dots_1467 = uint(C.GDK_KEY_braille_dots_1467) - KEY_braille_dots_2467 = uint(C.GDK_KEY_braille_dots_2467) - KEY_braille_dots_12467 = uint(C.GDK_KEY_braille_dots_12467) - KEY_braille_dots_3467 = uint(C.GDK_KEY_braille_dots_3467) - KEY_braille_dots_13467 = uint(C.GDK_KEY_braille_dots_13467) - KEY_braille_dots_23467 = uint(C.GDK_KEY_braille_dots_23467) - KEY_braille_dots_123467 = uint(C.GDK_KEY_braille_dots_123467) - KEY_braille_dots_567 = uint(C.GDK_KEY_braille_dots_567) - KEY_braille_dots_1567 = uint(C.GDK_KEY_braille_dots_1567) - KEY_braille_dots_2567 = uint(C.GDK_KEY_braille_dots_2567) - KEY_braille_dots_12567 = uint(C.GDK_KEY_braille_dots_12567) - KEY_braille_dots_3567 = uint(C.GDK_KEY_braille_dots_3567) - KEY_braille_dots_13567 = uint(C.GDK_KEY_braille_dots_13567) - KEY_braille_dots_23567 = uint(C.GDK_KEY_braille_dots_23567) - KEY_braille_dots_123567 = uint(C.GDK_KEY_braille_dots_123567) - KEY_braille_dots_4567 = uint(C.GDK_KEY_braille_dots_4567) - KEY_braille_dots_14567 = uint(C.GDK_KEY_braille_dots_14567) - KEY_braille_dots_24567 = uint(C.GDK_KEY_braille_dots_24567) - KEY_braille_dots_124567 = uint(C.GDK_KEY_braille_dots_124567) - KEY_braille_dots_34567 = uint(C.GDK_KEY_braille_dots_34567) - KEY_braille_dots_134567 = uint(C.GDK_KEY_braille_dots_134567) - KEY_braille_dots_234567 = uint(C.GDK_KEY_braille_dots_234567) - KEY_braille_dots_1234567 = uint(C.GDK_KEY_braille_dots_1234567) - KEY_braille_dots_8 = uint(C.GDK_KEY_braille_dots_8) - KEY_braille_dots_18 = uint(C.GDK_KEY_braille_dots_18) - KEY_braille_dots_28 = uint(C.GDK_KEY_braille_dots_28) - KEY_braille_dots_128 = uint(C.GDK_KEY_braille_dots_128) - KEY_braille_dots_38 = uint(C.GDK_KEY_braille_dots_38) - KEY_braille_dots_138 = uint(C.GDK_KEY_braille_dots_138) - KEY_braille_dots_238 = uint(C.GDK_KEY_braille_dots_238) - KEY_braille_dots_1238 = uint(C.GDK_KEY_braille_dots_1238) - KEY_braille_dots_48 = uint(C.GDK_KEY_braille_dots_48) - KEY_braille_dots_148 = uint(C.GDK_KEY_braille_dots_148) - KEY_braille_dots_248 = uint(C.GDK_KEY_braille_dots_248) - KEY_braille_dots_1248 = uint(C.GDK_KEY_braille_dots_1248) - KEY_braille_dots_348 = uint(C.GDK_KEY_braille_dots_348) - KEY_braille_dots_1348 = uint(C.GDK_KEY_braille_dots_1348) - KEY_braille_dots_2348 = uint(C.GDK_KEY_braille_dots_2348) - KEY_braille_dots_12348 = uint(C.GDK_KEY_braille_dots_12348) - KEY_braille_dots_58 = uint(C.GDK_KEY_braille_dots_58) - KEY_braille_dots_158 = uint(C.GDK_KEY_braille_dots_158) - KEY_braille_dots_258 = uint(C.GDK_KEY_braille_dots_258) - KEY_braille_dots_1258 = uint(C.GDK_KEY_braille_dots_1258) - KEY_braille_dots_358 = uint(C.GDK_KEY_braille_dots_358) - KEY_braille_dots_1358 = uint(C.GDK_KEY_braille_dots_1358) - KEY_braille_dots_2358 = uint(C.GDK_KEY_braille_dots_2358) - KEY_braille_dots_12358 = uint(C.GDK_KEY_braille_dots_12358) - KEY_braille_dots_458 = uint(C.GDK_KEY_braille_dots_458) - KEY_braille_dots_1458 = uint(C.GDK_KEY_braille_dots_1458) - KEY_braille_dots_2458 = uint(C.GDK_KEY_braille_dots_2458) - KEY_braille_dots_12458 = uint(C.GDK_KEY_braille_dots_12458) - KEY_braille_dots_3458 = uint(C.GDK_KEY_braille_dots_3458) - KEY_braille_dots_13458 = uint(C.GDK_KEY_braille_dots_13458) - KEY_braille_dots_23458 = uint(C.GDK_KEY_braille_dots_23458) - KEY_braille_dots_123458 = uint(C.GDK_KEY_braille_dots_123458) - KEY_braille_dots_68 = uint(C.GDK_KEY_braille_dots_68) - KEY_braille_dots_168 = uint(C.GDK_KEY_braille_dots_168) - KEY_braille_dots_268 = uint(C.GDK_KEY_braille_dots_268) - KEY_braille_dots_1268 = uint(C.GDK_KEY_braille_dots_1268) - KEY_braille_dots_368 = uint(C.GDK_KEY_braille_dots_368) - KEY_braille_dots_1368 = uint(C.GDK_KEY_braille_dots_1368) - KEY_braille_dots_2368 = uint(C.GDK_KEY_braille_dots_2368) - KEY_braille_dots_12368 = uint(C.GDK_KEY_braille_dots_12368) - KEY_braille_dots_468 = uint(C.GDK_KEY_braille_dots_468) - KEY_braille_dots_1468 = uint(C.GDK_KEY_braille_dots_1468) - KEY_braille_dots_2468 = uint(C.GDK_KEY_braille_dots_2468) - KEY_braille_dots_12468 = uint(C.GDK_KEY_braille_dots_12468) - KEY_braille_dots_3468 = uint(C.GDK_KEY_braille_dots_3468) - KEY_braille_dots_13468 = uint(C.GDK_KEY_braille_dots_13468) - KEY_braille_dots_23468 = uint(C.GDK_KEY_braille_dots_23468) - KEY_braille_dots_123468 = uint(C.GDK_KEY_braille_dots_123468) - KEY_braille_dots_568 = uint(C.GDK_KEY_braille_dots_568) - KEY_braille_dots_1568 = uint(C.GDK_KEY_braille_dots_1568) - KEY_braille_dots_2568 = uint(C.GDK_KEY_braille_dots_2568) - KEY_braille_dots_12568 = uint(C.GDK_KEY_braille_dots_12568) - KEY_braille_dots_3568 = uint(C.GDK_KEY_braille_dots_3568) - KEY_braille_dots_13568 = uint(C.GDK_KEY_braille_dots_13568) - KEY_braille_dots_23568 = uint(C.GDK_KEY_braille_dots_23568) - KEY_braille_dots_123568 = uint(C.GDK_KEY_braille_dots_123568) - KEY_braille_dots_4568 = uint(C.GDK_KEY_braille_dots_4568) - KEY_braille_dots_14568 = uint(C.GDK_KEY_braille_dots_14568) - KEY_braille_dots_24568 = uint(C.GDK_KEY_braille_dots_24568) - KEY_braille_dots_124568 = uint(C.GDK_KEY_braille_dots_124568) - KEY_braille_dots_34568 = uint(C.GDK_KEY_braille_dots_34568) - KEY_braille_dots_134568 = uint(C.GDK_KEY_braille_dots_134568) - KEY_braille_dots_234568 = uint(C.GDK_KEY_braille_dots_234568) - KEY_braille_dots_1234568 = uint(C.GDK_KEY_braille_dots_1234568) - KEY_braille_dots_78 = uint(C.GDK_KEY_braille_dots_78) - KEY_braille_dots_178 = uint(C.GDK_KEY_braille_dots_178) - KEY_braille_dots_278 = uint(C.GDK_KEY_braille_dots_278) - KEY_braille_dots_1278 = uint(C.GDK_KEY_braille_dots_1278) - KEY_braille_dots_378 = uint(C.GDK_KEY_braille_dots_378) - KEY_braille_dots_1378 = uint(C.GDK_KEY_braille_dots_1378) - KEY_braille_dots_2378 = uint(C.GDK_KEY_braille_dots_2378) - KEY_braille_dots_12378 = uint(C.GDK_KEY_braille_dots_12378) - KEY_braille_dots_478 = uint(C.GDK_KEY_braille_dots_478) - KEY_braille_dots_1478 = uint(C.GDK_KEY_braille_dots_1478) - KEY_braille_dots_2478 = uint(C.GDK_KEY_braille_dots_2478) - KEY_braille_dots_12478 = uint(C.GDK_KEY_braille_dots_12478) - KEY_braille_dots_3478 = uint(C.GDK_KEY_braille_dots_3478) - KEY_braille_dots_13478 = uint(C.GDK_KEY_braille_dots_13478) - KEY_braille_dots_23478 = uint(C.GDK_KEY_braille_dots_23478) - KEY_braille_dots_123478 = uint(C.GDK_KEY_braille_dots_123478) - KEY_braille_dots_578 = uint(C.GDK_KEY_braille_dots_578) - KEY_braille_dots_1578 = uint(C.GDK_KEY_braille_dots_1578) - KEY_braille_dots_2578 = uint(C.GDK_KEY_braille_dots_2578) - KEY_braille_dots_12578 = uint(C.GDK_KEY_braille_dots_12578) - KEY_braille_dots_3578 = uint(C.GDK_KEY_braille_dots_3578) - KEY_braille_dots_13578 = uint(C.GDK_KEY_braille_dots_13578) - KEY_braille_dots_23578 = uint(C.GDK_KEY_braille_dots_23578) - KEY_braille_dots_123578 = uint(C.GDK_KEY_braille_dots_123578) - KEY_braille_dots_4578 = uint(C.GDK_KEY_braille_dots_4578) - KEY_braille_dots_14578 = uint(C.GDK_KEY_braille_dots_14578) - KEY_braille_dots_24578 = uint(C.GDK_KEY_braille_dots_24578) - KEY_braille_dots_124578 = uint(C.GDK_KEY_braille_dots_124578) - KEY_braille_dots_34578 = uint(C.GDK_KEY_braille_dots_34578) - KEY_braille_dots_134578 = uint(C.GDK_KEY_braille_dots_134578) - KEY_braille_dots_234578 = uint(C.GDK_KEY_braille_dots_234578) - KEY_braille_dots_1234578 = uint(C.GDK_KEY_braille_dots_1234578) - KEY_braille_dots_678 = uint(C.GDK_KEY_braille_dots_678) - KEY_braille_dots_1678 = uint(C.GDK_KEY_braille_dots_1678) - KEY_braille_dots_2678 = uint(C.GDK_KEY_braille_dots_2678) - KEY_braille_dots_12678 = uint(C.GDK_KEY_braille_dots_12678) - KEY_braille_dots_3678 = uint(C.GDK_KEY_braille_dots_3678) - KEY_braille_dots_13678 = uint(C.GDK_KEY_braille_dots_13678) - KEY_braille_dots_23678 = uint(C.GDK_KEY_braille_dots_23678) - KEY_braille_dots_123678 = uint(C.GDK_KEY_braille_dots_123678) - KEY_braille_dots_4678 = uint(C.GDK_KEY_braille_dots_4678) - KEY_braille_dots_14678 = uint(C.GDK_KEY_braille_dots_14678) - KEY_braille_dots_24678 = uint(C.GDK_KEY_braille_dots_24678) - KEY_braille_dots_124678 = uint(C.GDK_KEY_braille_dots_124678) - KEY_braille_dots_34678 = uint(C.GDK_KEY_braille_dots_34678) - KEY_braille_dots_134678 = uint(C.GDK_KEY_braille_dots_134678) - KEY_braille_dots_234678 = uint(C.GDK_KEY_braille_dots_234678) - KEY_braille_dots_1234678 = uint(C.GDK_KEY_braille_dots_1234678) - KEY_braille_dots_5678 = uint(C.GDK_KEY_braille_dots_5678) - KEY_braille_dots_15678 = uint(C.GDK_KEY_braille_dots_15678) - KEY_braille_dots_25678 = uint(C.GDK_KEY_braille_dots_25678) - KEY_braille_dots_125678 = uint(C.GDK_KEY_braille_dots_125678) - KEY_braille_dots_35678 = uint(C.GDK_KEY_braille_dots_35678) - KEY_braille_dots_135678 = uint(C.GDK_KEY_braille_dots_135678) - KEY_braille_dots_235678 = uint(C.GDK_KEY_braille_dots_235678) - KEY_braille_dots_1235678 = uint(C.GDK_KEY_braille_dots_1235678) - KEY_braille_dots_45678 = uint(C.GDK_KEY_braille_dots_45678) - KEY_braille_dots_145678 = uint(C.GDK_KEY_braille_dots_145678) - KEY_braille_dots_245678 = uint(C.GDK_KEY_braille_dots_245678) - KEY_braille_dots_1245678 = uint(C.GDK_KEY_braille_dots_1245678) - KEY_braille_dots_345678 = uint(C.GDK_KEY_braille_dots_345678) - KEY_braille_dots_1345678 = uint(C.GDK_KEY_braille_dots_1345678) - KEY_braille_dots_2345678 = uint(C.GDK_KEY_braille_dots_2345678) - KEY_braille_dots_12345678 = uint(C.GDK_KEY_braille_dots_12345678) - KEY_Sinh_ng = uint(C.GDK_KEY_Sinh_ng) - KEY_Sinh_h2 = uint(C.GDK_KEY_Sinh_h2) - KEY_Sinh_a = uint(C.GDK_KEY_Sinh_a) - KEY_Sinh_aa = uint(C.GDK_KEY_Sinh_aa) - KEY_Sinh_ae = uint(C.GDK_KEY_Sinh_ae) - KEY_Sinh_aee = uint(C.GDK_KEY_Sinh_aee) - KEY_Sinh_i = uint(C.GDK_KEY_Sinh_i) - KEY_Sinh_ii = uint(C.GDK_KEY_Sinh_ii) - KEY_Sinh_u = uint(C.GDK_KEY_Sinh_u) - KEY_Sinh_uu = uint(C.GDK_KEY_Sinh_uu) - KEY_Sinh_ri = uint(C.GDK_KEY_Sinh_ri) - KEY_Sinh_rii = uint(C.GDK_KEY_Sinh_rii) - KEY_Sinh_lu = uint(C.GDK_KEY_Sinh_lu) - KEY_Sinh_luu = uint(C.GDK_KEY_Sinh_luu) - KEY_Sinh_e = uint(C.GDK_KEY_Sinh_e) - KEY_Sinh_ee = uint(C.GDK_KEY_Sinh_ee) - KEY_Sinh_ai = uint(C.GDK_KEY_Sinh_ai) - KEY_Sinh_o = uint(C.GDK_KEY_Sinh_o) - KEY_Sinh_oo = uint(C.GDK_KEY_Sinh_oo) - KEY_Sinh_au = uint(C.GDK_KEY_Sinh_au) - KEY_Sinh_ka = uint(C.GDK_KEY_Sinh_ka) - KEY_Sinh_kha = uint(C.GDK_KEY_Sinh_kha) - KEY_Sinh_ga = uint(C.GDK_KEY_Sinh_ga) - KEY_Sinh_gha = uint(C.GDK_KEY_Sinh_gha) - KEY_Sinh_ng2 = uint(C.GDK_KEY_Sinh_ng2) - KEY_Sinh_nga = uint(C.GDK_KEY_Sinh_nga) - KEY_Sinh_ca = uint(C.GDK_KEY_Sinh_ca) - KEY_Sinh_cha = uint(C.GDK_KEY_Sinh_cha) - KEY_Sinh_ja = uint(C.GDK_KEY_Sinh_ja) - KEY_Sinh_jha = uint(C.GDK_KEY_Sinh_jha) - KEY_Sinh_nya = uint(C.GDK_KEY_Sinh_nya) - KEY_Sinh_jnya = uint(C.GDK_KEY_Sinh_jnya) - KEY_Sinh_nja = uint(C.GDK_KEY_Sinh_nja) - KEY_Sinh_tta = uint(C.GDK_KEY_Sinh_tta) - KEY_Sinh_ttha = uint(C.GDK_KEY_Sinh_ttha) - KEY_Sinh_dda = uint(C.GDK_KEY_Sinh_dda) - KEY_Sinh_ddha = uint(C.GDK_KEY_Sinh_ddha) - KEY_Sinh_nna = uint(C.GDK_KEY_Sinh_nna) - KEY_Sinh_ndda = uint(C.GDK_KEY_Sinh_ndda) - KEY_Sinh_tha = uint(C.GDK_KEY_Sinh_tha) - KEY_Sinh_thha = uint(C.GDK_KEY_Sinh_thha) - KEY_Sinh_dha = uint(C.GDK_KEY_Sinh_dha) - KEY_Sinh_dhha = uint(C.GDK_KEY_Sinh_dhha) - KEY_Sinh_na = uint(C.GDK_KEY_Sinh_na) - KEY_Sinh_ndha = uint(C.GDK_KEY_Sinh_ndha) - KEY_Sinh_pa = uint(C.GDK_KEY_Sinh_pa) - KEY_Sinh_pha = uint(C.GDK_KEY_Sinh_pha) - KEY_Sinh_ba = uint(C.GDK_KEY_Sinh_ba) - KEY_Sinh_bha = uint(C.GDK_KEY_Sinh_bha) - KEY_Sinh_ma = uint(C.GDK_KEY_Sinh_ma) - KEY_Sinh_mba = uint(C.GDK_KEY_Sinh_mba) - KEY_Sinh_ya = uint(C.GDK_KEY_Sinh_ya) - KEY_Sinh_ra = uint(C.GDK_KEY_Sinh_ra) - KEY_Sinh_la = uint(C.GDK_KEY_Sinh_la) - KEY_Sinh_va = uint(C.GDK_KEY_Sinh_va) - KEY_Sinh_sha = uint(C.GDK_KEY_Sinh_sha) - KEY_Sinh_ssha = uint(C.GDK_KEY_Sinh_ssha) - KEY_Sinh_sa = uint(C.GDK_KEY_Sinh_sa) - KEY_Sinh_ha = uint(C.GDK_KEY_Sinh_ha) - KEY_Sinh_lla = uint(C.GDK_KEY_Sinh_lla) - KEY_Sinh_fa = uint(C.GDK_KEY_Sinh_fa) - KEY_Sinh_al = uint(C.GDK_KEY_Sinh_al) - KEY_Sinh_aa2 = uint(C.GDK_KEY_Sinh_aa2) - KEY_Sinh_ae2 = uint(C.GDK_KEY_Sinh_ae2) - KEY_Sinh_aee2 = uint(C.GDK_KEY_Sinh_aee2) - KEY_Sinh_i2 = uint(C.GDK_KEY_Sinh_i2) - KEY_Sinh_ii2 = uint(C.GDK_KEY_Sinh_ii2) - KEY_Sinh_u2 = uint(C.GDK_KEY_Sinh_u2) - KEY_Sinh_uu2 = uint(C.GDK_KEY_Sinh_uu2) - KEY_Sinh_ru2 = uint(C.GDK_KEY_Sinh_ru2) - KEY_Sinh_e2 = uint(C.GDK_KEY_Sinh_e2) - KEY_Sinh_ee2 = uint(C.GDK_KEY_Sinh_ee2) - KEY_Sinh_ai2 = uint(C.GDK_KEY_Sinh_ai2) - KEY_Sinh_o2 = uint(C.GDK_KEY_Sinh_o2) - KEY_Sinh_oo2 = uint(C.GDK_KEY_Sinh_oo2) - KEY_Sinh_au2 = uint(C.GDK_KEY_Sinh_au2) - KEY_Sinh_lu2 = uint(C.GDK_KEY_Sinh_lu2) - KEY_Sinh_ruu2 = uint(C.GDK_KEY_Sinh_ruu2) - KEY_Sinh_luu2 = uint(C.GDK_KEY_Sinh_luu2) - KEY_Sinh_kunddaliya = uint(C.GDK_KEY_Sinh_kunddaliya) - KEY_ModeLock = uint(C.GDK_KEY_ModeLock) - KEY_MonBrightnessUp = uint(C.GDK_KEY_MonBrightnessUp) - KEY_MonBrightnessDown = uint(C.GDK_KEY_MonBrightnessDown) - KEY_KbdLightOnOff = uint(C.GDK_KEY_KbdLightOnOff) - KEY_KbdBrightnessUp = uint(C.GDK_KEY_KbdBrightnessUp) - KEY_KbdBrightnessDown = uint(C.GDK_KEY_KbdBrightnessDown) - KEY_Standby = uint(C.GDK_KEY_Standby) - KEY_AudioLowerVolume = uint(C.GDK_KEY_AudioLowerVolume) - KEY_AudioMute = uint(C.GDK_KEY_AudioMute) - KEY_AudioRaiseVolume = uint(C.GDK_KEY_AudioRaiseVolume) - KEY_AudioPlay = uint(C.GDK_KEY_AudioPlay) - KEY_AudioStop = uint(C.GDK_KEY_AudioStop) - KEY_AudioPrev = uint(C.GDK_KEY_AudioPrev) - KEY_AudioNext = uint(C.GDK_KEY_AudioNext) - KEY_HomePage = uint(C.GDK_KEY_HomePage) - KEY_Mail = uint(C.GDK_KEY_Mail) - KEY_Start = uint(C.GDK_KEY_Start) - KEY_Search = uint(C.GDK_KEY_Search) - KEY_AudioRecord = uint(C.GDK_KEY_AudioRecord) - KEY_Calculator = uint(C.GDK_KEY_Calculator) - KEY_Memo = uint(C.GDK_KEY_Memo) - KEY_ToDoList = uint(C.GDK_KEY_ToDoList) - KEY_Calendar = uint(C.GDK_KEY_Calendar) - KEY_PowerDown = uint(C.GDK_KEY_PowerDown) - KEY_ContrastAdjust = uint(C.GDK_KEY_ContrastAdjust) - KEY_RockerUp = uint(C.GDK_KEY_RockerUp) - KEY_RockerDown = uint(C.GDK_KEY_RockerDown) - KEY_RockerEnter = uint(C.GDK_KEY_RockerEnter) - KEY_Back = uint(C.GDK_KEY_Back) - KEY_Forward = uint(C.GDK_KEY_Forward) - KEY_Stop = uint(C.GDK_KEY_Stop) - KEY_Refresh = uint(C.GDK_KEY_Refresh) - KEY_PowerOff = uint(C.GDK_KEY_PowerOff) - KEY_WakeUp = uint(C.GDK_KEY_WakeUp) - KEY_Eject = uint(C.GDK_KEY_Eject) - KEY_ScreenSaver = uint(C.GDK_KEY_ScreenSaver) - KEY_WWW = uint(C.GDK_KEY_WWW) - KEY_Sleep = uint(C.GDK_KEY_Sleep) - KEY_Favorites = uint(C.GDK_KEY_Favorites) - KEY_AudioPause = uint(C.GDK_KEY_AudioPause) - KEY_AudioMedia = uint(C.GDK_KEY_AudioMedia) - KEY_MyComputer = uint(C.GDK_KEY_MyComputer) - KEY_VendorHome = uint(C.GDK_KEY_VendorHome) - KEY_LightBulb = uint(C.GDK_KEY_LightBulb) - KEY_Shop = uint(C.GDK_KEY_Shop) - KEY_History = uint(C.GDK_KEY_History) - KEY_OpenURL = uint(C.GDK_KEY_OpenURL) - KEY_AddFavorite = uint(C.GDK_KEY_AddFavorite) - KEY_HotLinks = uint(C.GDK_KEY_HotLinks) - KEY_BrightnessAdjust = uint(C.GDK_KEY_BrightnessAdjust) - KEY_Finance = uint(C.GDK_KEY_Finance) - KEY_Community = uint(C.GDK_KEY_Community) - KEY_AudioRewind = uint(C.GDK_KEY_AudioRewind) - KEY_BackForward = uint(C.GDK_KEY_BackForward) - KEY_Launch0 = uint(C.GDK_KEY_Launch0) - KEY_Launch1 = uint(C.GDK_KEY_Launch1) - KEY_Launch2 = uint(C.GDK_KEY_Launch2) - KEY_Launch3 = uint(C.GDK_KEY_Launch3) - KEY_Launch4 = uint(C.GDK_KEY_Launch4) - KEY_Launch5 = uint(C.GDK_KEY_Launch5) - KEY_Launch6 = uint(C.GDK_KEY_Launch6) - KEY_Launch7 = uint(C.GDK_KEY_Launch7) - KEY_Launch8 = uint(C.GDK_KEY_Launch8) - KEY_Launch9 = uint(C.GDK_KEY_Launch9) - KEY_LaunchA = uint(C.GDK_KEY_LaunchA) - KEY_LaunchB = uint(C.GDK_KEY_LaunchB) - KEY_LaunchC = uint(C.GDK_KEY_LaunchC) - KEY_LaunchD = uint(C.GDK_KEY_LaunchD) - KEY_LaunchE = uint(C.GDK_KEY_LaunchE) - KEY_LaunchF = uint(C.GDK_KEY_LaunchF) - KEY_ApplicationLeft = uint(C.GDK_KEY_ApplicationLeft) - KEY_ApplicationRight = uint(C.GDK_KEY_ApplicationRight) - KEY_Book = uint(C.GDK_KEY_Book) - KEY_CD = uint(C.GDK_KEY_CD) - KEY_WindowClear = uint(C.GDK_KEY_WindowClear) - KEY_Close = uint(C.GDK_KEY_Close) - KEY_Copy = uint(C.GDK_KEY_Copy) - KEY_Cut = uint(C.GDK_KEY_Cut) - KEY_Display = uint(C.GDK_KEY_Display) - KEY_DOS = uint(C.GDK_KEY_DOS) - KEY_Documents = uint(C.GDK_KEY_Documents) - KEY_Excel = uint(C.GDK_KEY_Excel) - KEY_Explorer = uint(C.GDK_KEY_Explorer) - KEY_Game = uint(C.GDK_KEY_Game) - KEY_Go = uint(C.GDK_KEY_Go) - KEY_iTouch = uint(C.GDK_KEY_iTouch) - KEY_LogOff = uint(C.GDK_KEY_LogOff) - KEY_Market = uint(C.GDK_KEY_Market) - KEY_Meeting = uint(C.GDK_KEY_Meeting) - KEY_MenuKB = uint(C.GDK_KEY_MenuKB) - KEY_MenuPB = uint(C.GDK_KEY_MenuPB) - KEY_MySites = uint(C.GDK_KEY_MySites) - KEY_New = uint(C.GDK_KEY_New) - KEY_News = uint(C.GDK_KEY_News) - KEY_OfficeHome = uint(C.GDK_KEY_OfficeHome) - KEY_Open = uint(C.GDK_KEY_Open) - KEY_Option = uint(C.GDK_KEY_Option) - KEY_Paste = uint(C.GDK_KEY_Paste) - KEY_Phone = uint(C.GDK_KEY_Phone) - KEY_Reply = uint(C.GDK_KEY_Reply) - KEY_Reload = uint(C.GDK_KEY_Reload) - KEY_RotateWindows = uint(C.GDK_KEY_RotateWindows) - KEY_RotationPB = uint(C.GDK_KEY_RotationPB) - KEY_RotationKB = uint(C.GDK_KEY_RotationKB) - KEY_Save = uint(C.GDK_KEY_Save) - KEY_ScrollUp = uint(C.GDK_KEY_ScrollUp) - KEY_ScrollDown = uint(C.GDK_KEY_ScrollDown) - KEY_ScrollClick = uint(C.GDK_KEY_ScrollClick) - KEY_Send = uint(C.GDK_KEY_Send) - KEY_Spell = uint(C.GDK_KEY_Spell) - KEY_SplitScreen = uint(C.GDK_KEY_SplitScreen) - KEY_Support = uint(C.GDK_KEY_Support) - KEY_TaskPane = uint(C.GDK_KEY_TaskPane) - KEY_Terminal = uint(C.GDK_KEY_Terminal) - KEY_Tools = uint(C.GDK_KEY_Tools) - KEY_Travel = uint(C.GDK_KEY_Travel) - KEY_UserPB = uint(C.GDK_KEY_UserPB) - KEY_User1KB = uint(C.GDK_KEY_User1KB) - KEY_User2KB = uint(C.GDK_KEY_User2KB) - KEY_Video = uint(C.GDK_KEY_Video) - KEY_WheelButton = uint(C.GDK_KEY_WheelButton) - KEY_Word = uint(C.GDK_KEY_Word) - KEY_Xfer = uint(C.GDK_KEY_Xfer) - KEY_ZoomIn = uint(C.GDK_KEY_ZoomIn) - KEY_ZoomOut = uint(C.GDK_KEY_ZoomOut) - KEY_Away = uint(C.GDK_KEY_Away) - KEY_Messenger = uint(C.GDK_KEY_Messenger) - KEY_WebCam = uint(C.GDK_KEY_WebCam) - KEY_MailForward = uint(C.GDK_KEY_MailForward) - KEY_Pictures = uint(C.GDK_KEY_Pictures) - KEY_Music = uint(C.GDK_KEY_Music) - KEY_Battery = uint(C.GDK_KEY_Battery) - KEY_Bluetooth = uint(C.GDK_KEY_Bluetooth) - KEY_WLAN = uint(C.GDK_KEY_WLAN) - KEY_UWB = uint(C.GDK_KEY_UWB) - KEY_AudioForward = uint(C.GDK_KEY_AudioForward) - KEY_AudioRepeat = uint(C.GDK_KEY_AudioRepeat) - KEY_AudioRandomPlay = uint(C.GDK_KEY_AudioRandomPlay) - KEY_Subtitle = uint(C.GDK_KEY_Subtitle) - KEY_AudioCycleTrack = uint(C.GDK_KEY_AudioCycleTrack) - KEY_CycleAngle = uint(C.GDK_KEY_CycleAngle) - KEY_FrameBack = uint(C.GDK_KEY_FrameBack) - KEY_FrameForward = uint(C.GDK_KEY_FrameForward) - KEY_Time = uint(C.GDK_KEY_Time) - KEY_SelectButton = uint(C.GDK_KEY_SelectButton) - KEY_View = uint(C.GDK_KEY_View) - KEY_TopMenu = uint(C.GDK_KEY_TopMenu) - KEY_Red = uint(C.GDK_KEY_Red) - KEY_Green = uint(C.GDK_KEY_Green) - KEY_Yellow = uint(C.GDK_KEY_Yellow) - KEY_Blue = uint(C.GDK_KEY_Blue) - KEY_Suspend = uint(C.GDK_KEY_Suspend) - KEY_Hibernate = uint(C.GDK_KEY_Hibernate) - KEY_TouchpadToggle = uint(C.GDK_KEY_TouchpadToggle) - KEY_TouchpadOn = uint(C.GDK_KEY_TouchpadOn) - KEY_TouchpadOff = uint(C.GDK_KEY_TouchpadOff) - KEY_AudioMicMute = uint(C.GDK_KEY_AudioMicMute) - KEY_Switch_VT_1 = uint(C.GDK_KEY_Switch_VT_1) - KEY_Switch_VT_2 = uint(C.GDK_KEY_Switch_VT_2) - KEY_Switch_VT_3 = uint(C.GDK_KEY_Switch_VT_3) - KEY_Switch_VT_4 = uint(C.GDK_KEY_Switch_VT_4) - KEY_Switch_VT_5 = uint(C.GDK_KEY_Switch_VT_5) - KEY_Switch_VT_6 = uint(C.GDK_KEY_Switch_VT_6) - KEY_Switch_VT_7 = uint(C.GDK_KEY_Switch_VT_7) - KEY_Switch_VT_8 = uint(C.GDK_KEY_Switch_VT_8) - KEY_Switch_VT_9 = uint(C.GDK_KEY_Switch_VT_9) - KEY_Switch_VT_10 = uint(C.GDK_KEY_Switch_VT_10) - KEY_Switch_VT_11 = uint(C.GDK_KEY_Switch_VT_11) - KEY_Switch_VT_12 = uint(C.GDK_KEY_Switch_VT_12) - KEY_Ungrab = uint(C.GDK_KEY_Ungrab) - KEY_ClearGrab = uint(C.GDK_KEY_ClearGrab) - KEY_Next_VMode = uint(C.GDK_KEY_Next_VMode) - KEY_Prev_VMode = uint(C.GDK_KEY_Prev_VMode) - KEY_LogWindowTree = uint(C.GDK_KEY_LogWindowTree) - KEY_LogGrabInfo = uint(C.GDK_KEY_LogGrabInfo) -) diff --git a/vendor/github.com/gotk3/gotk3.old/gdk/screen.go b/vendor/github.com/gotk3/gotk3.old/gdk/screen.go deleted file mode 100644 index 6164731..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gdk/screen.go +++ /dev/null @@ -1,198 +0,0 @@ -package gdk - -// #cgo pkg-config: gdk-3.0 -// #include -// #include "gdk.go.h" -import "C" -import ( - "runtime" - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -/* - * GdkScreen - */ - -// Screen is a representation of GDK's GdkScreen. -type Screen struct { - *glib.Object -} - -// native returns a pointer to the underlying GdkScreen. -func (v *Screen) native() *C.GdkScreen { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGdkScreen(p) -} - -// Native returns a pointer to the underlying GdkScreen. -func (v *Screen) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalScreen(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - return &Screen{obj}, nil -} - -func toScreen(s *C.GdkScreen) (*Screen, error) { - if s == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(s))} - return &Screen{obj}, nil -} - -// GetRGBAVisual is a wrapper around gdk_screen_get_rgba_visual(). -func (v *Screen) GetRGBAVisual() (*Visual, error) { - c := C.gdk_screen_get_rgba_visual(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - visual := &Visual{obj} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return visual, nil -} - -// GetSystemVisual is a wrapper around gdk_screen_get_system_visual(). -func (v *Screen) GetSystemVisual() (*Visual, error) { - c := C.gdk_screen_get_system_visual(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - visual := &Visual{obj} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return visual, nil -} - -// GetWidth is a wrapper around gdk_screen_get_width(). -func (v *Screen) GetWidth() int { - c := C.gdk_screen_get_width(v.native()) - return int(c) -} - -// GetHeight is a wrapper around gdk_screen_get_height(). -func (v *Screen) GetHeight() int { - c := C.gdk_screen_get_height(v.native()) - return int(c) -} - -// ScreenGetDefault is a wrapper aroud gdk_screen_get_default(). -func ScreenGetDefault() (*Screen, error) { - return toScreen(C.gdk_screen_get_default()) -} - -// IsComposited is a wrapper around gdk_screen_is_composited(). -func (v *Screen) IsComposited() bool { - return gobool(C.gdk_screen_is_composited(v.native())) -} - -// GetRootWindow is a wrapper around gdk_screen_get_root_window(). -func (v *Screen) GetRootWindow() (*Window, error) { - return toWindow(C.gdk_screen_get_root_window(v.native())) -} - -// GetDisplay is a wrapper around gdk_screen_get_display(). -func (v *Screen) GetDisplay() (*Display, error) { - return toDisplay(C.gdk_screen_get_display(v.native())) -} - -// GetNumber is a wrapper around gdk_screen_get_number(). -func (v *Screen) GetNumber() int { - return int(C.gdk_screen_get_number(v.native())) -} - -// GetWidthMM is a wrapper around gdk_screen_get_width_mm(). -func (v *Screen) GetWidthMM() int { - return int(C.gdk_screen_get_width_mm(v.native())) -} - -// GetHeightMM is a wrapper around gdk_screen_get_height_mm(). -func (v *Screen) GetHeightMM() int { - return int(C.gdk_screen_get_height_mm(v.native())) -} - -func toString(c *C.gchar) (string, error) { - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// MakeDisplayName is a wrapper around gdk_screen_make_display_name(). -func (v *Screen) MakeDisplayName() (string, error) { - return toString(C.gdk_screen_make_display_name(v.native())) -} - -// GetNMonitors is a wrapper around gdk_screen_get_n_monitors(). -func (v *Screen) GetNMonitors() int { - return int(C.gdk_screen_get_n_monitors(v.native())) -} - -// GetPrimaryMonitor is a wrapper around gdk_screen_get_primary_monitor(). -func (v *Screen) GetPrimaryMonitor() int { - return int(C.gdk_screen_get_primary_monitor(v.native())) -} - -// GetMonitorAtPoint is a wrapper around gdk_screen_get_monitor_at_point(). -func (v *Screen) GetMonitorAtPoint(x, y int) int { - return int(C.gdk_screen_get_monitor_at_point(v.native(), C.gint(x), C.gint(y))) -} - -// GetMonitorAtWindow is a wrapper around gdk_screen_get_monitor_at_window(). -func (v *Screen) GetMonitorAtWindow(w *Window) int { - return int(C.gdk_screen_get_monitor_at_window(v.native(), w.native())) -} - -// GetMonitorHeightMM is a wrapper around gdk_screen_get_monitor_height_mm(). -func (v *Screen) GetMonitorHeightMM(m int) int { - return int(C.gdk_screen_get_monitor_height_mm(v.native(), C.gint(m))) -} - -// GetMonitorWidthMM is a wrapper around gdk_screen_get_monitor_width_mm(). -func (v *Screen) GetMonitorWidthMM(m int) int { - return int(C.gdk_screen_get_monitor_width_mm(v.native(), C.gint(m))) -} - -// GetMonitorPlugName is a wrapper around gdk_screen_get_monitor_plug_name(). -func (v *Screen) GetMonitorPlugName(m int) (string, error) { - return toString(C.gdk_screen_get_monitor_plug_name(v.native(), C.gint(m))) -} - -// GetMonitorScaleFactor is a wrapper around gdk_screen_get_monitor_scale_factor(). -func (v *Screen) GetMonitorScaleFactor(m int) int { - return int(C.gdk_screen_get_monitor_scale_factor(v.native(), C.gint(m))) -} - -// GetResolution is a wrapper around gdk_screen_get_resolution(). -func (v *Screen) GetResolution() float64 { - return float64(C.gdk_screen_get_resolution(v.native())) -} - -// SetResolution is a wrapper around gdk_screen_set_resolution(). -func (v *Screen) SetResolution(r float64) { - C.gdk_screen_set_resolution(v.native(), C.gdouble(r)) -} - -// GetActiveWindow is a wrapper around gdk_screen_get_active_window(). -func (v *Screen) GetActiveWindow() (*Window, error) { - return toWindow(C.gdk_screen_get_active_window(v.native())) -} - -// void gdk_screen_set_font_options () -// gboolean gdk_screen_get_setting () -// const cairo_font_options_t * gdk_screen_get_font_options () -// GList * gdk_screen_get_window_stack () -// GList * gdk_screen_list_visuals () -// GList * gdk_screen_get_toplevel_windows () -// void gdk_screen_get_monitor_geometry () -// void gdk_screen_get_monitor_workarea () diff --git a/vendor/github.com/gotk3/gotk3.old/gdk/screen_no_x11.go b/vendor/github.com/gotk3/gotk3.old/gdk/screen_no_x11.go deleted file mode 100644 index 9551598..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gdk/screen_no_x11.go +++ /dev/null @@ -1,25 +0,0 @@ -// +build !linux no_x11 - -package gdk - -func WorkspaceControlSupported() bool { - return false -} - -// GetScreenNumber is a wrapper around gdk_x11_screen_get_screen_number(). -// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false -func (v *Screen) GetScreenNumber() int { - return -1 -} - -// GetNumberOfDesktops is a wrapper around gdk_x11_screen_get_number_of_desktops(). -// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false -func (v *Screen) GetNumberOfDesktops() uint32 { - return 0 -} - -// GetCurrentDesktop is a wrapper around gdk_x11_screen_get_current_desktop(). -// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false -func (v *Screen) GetCurrentDesktop() uint32 { - return 0 -} diff --git a/vendor/github.com/gotk3/gotk3.old/gdk/screen_x11.go b/vendor/github.com/gotk3/gotk3.old/gdk/screen_x11.go deleted file mode 100644 index 084a52e..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gdk/screen_x11.go +++ /dev/null @@ -1,31 +0,0 @@ -// +build linux -// +build !no_x11 - -package gdk - -// #cgo pkg-config: gdk-x11-3.0 -// #include -// #include -import "C" - -func WorkspaceControlSupported() bool { - return true -} - -// GetScreenNumber is a wrapper around gdk_x11_screen_get_screen_number(). -// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false -func (v *Screen) GetScreenNumber() int { - return int(C.gdk_x11_screen_get_screen_number(v.native())) -} - -// GetNumberOfDesktops is a wrapper around gdk_x11_screen_get_number_of_desktops(). -// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false -func (v *Screen) GetNumberOfDesktops() uint32 { - return uint32(C.gdk_x11_screen_get_number_of_desktops(v.native())) -} - -// GetCurrentDesktop is a wrapper around gdk_x11_screen_get_current_desktop(). -// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false -func (v *Screen) GetCurrentDesktop() uint32 { - return uint32(C.gdk_x11_screen_get_current_desktop(v.native())) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gdk/window_no_x11.go b/vendor/github.com/gotk3/gotk3.old/gdk/window_no_x11.go deleted file mode 100644 index 72c5665..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gdk/window_no_x11.go +++ /dev/null @@ -1,17 +0,0 @@ -// +build !linux no_x11 - -package gdk - -func (v *Window) MoveToCurrentDesktop() { -} - -// GetDesktop is a wrapper around gdk_x11_window_get_desktop(). -// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false -func (v *Window) GetDesktop() uint32 { - return 0 -} - -// MoveToDesktop is a wrapper around gdk_x11_window_move_to_desktop(). -// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false -func (v *Window) MoveToDesktop(d uint32) { -} diff --git a/vendor/github.com/gotk3/gotk3.old/gdk/window_x11.go b/vendor/github.com/gotk3/gotk3.old/gdk/window_x11.go deleted file mode 100644 index 5f46200..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gdk/window_x11.go +++ /dev/null @@ -1,27 +0,0 @@ -// +build linux -// +build !no_x11 - -package gdk - -// #cgo pkg-config: gdk-x11-3.0 -// #include -// #include -import "C" - -// MoveToCurrentDesktop is a wrapper around gdk_x11_window_move_to_current_desktop(). -// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false -func (v *Window) MoveToCurrentDesktop() { - C.gdk_x11_window_move_to_current_desktop(v.native()) -} - -// GetDesktop is a wrapper around gdk_x11_window_get_desktop(). -// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false -func (v *Window) GetDesktop() uint32 { - return uint32(C.gdk_x11_window_get_desktop(v.native())) -} - -// MoveToDesktop is a wrapper around gdk_x11_window_move_to_desktop(). -// It only works on GDK versions compiled with X11 support - its return value can't be used if WorkspaceControlSupported returns false -func (v *Window) MoveToDesktop(d uint32) { - C.gdk_x11_window_move_to_desktop(v.native(), C.guint32(d)) -} diff --git a/vendor/github.com/gotk3/gotk3.old/glib/application.go b/vendor/github.com/gotk3/gotk3.old/glib/application.go deleted file mode 100644 index eef0eb0..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/application.go +++ /dev/null @@ -1,216 +0,0 @@ -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include -// #include "glib.go.h" -import "C" -import "unsafe" - -// Application is a representation of GApplication. -type Application struct { - *Object -} - -// native() returns a pointer to the underlying GApplication. -func (v *Application) native() *C.GApplication { - if v == nil || v.GObject == nil { - return nil - } - return C.toGApplication(unsafe.Pointer(v.GObject)) -} - -func (v *Application) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalApplication(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapApplication(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapApplication(obj *Object) *Application { - return &Application{obj} -} - -// ApplicationIDIsValid is a wrapper around g_application_id_is_valid(). -func ApplicationIDIsValid(id string) bool { - cstr1 := (*C.gchar)(C.CString(id)) - defer C.free(unsafe.Pointer(cstr1)) - - return gobool(C.g_application_id_is_valid(cstr1)) -} - -// ApplicationNew is a wrapper around g_application_new(). -func ApplicationNew(appID string, flags ApplicationFlags) *Application { - cstr1 := (*C.gchar)(C.CString(appID)) - defer C.free(unsafe.Pointer(cstr1)) - - c := C.g_application_new(cstr1, C.GApplicationFlags(flags)) - if c == nil { - return nil - } - return wrapApplication(wrapObject(unsafe.Pointer(c))) -} - -// GetApplicationID is a wrapper around g_application_get_application_id(). -func (v *Application) GetApplicationID() string { - c := C.g_application_get_application_id(v.native()) - - return C.GoString((*C.char)(c)) -} - -// SetApplicationID is a wrapper around g_application_set_application_id(). -func (v *Application) SetApplicationID(id string) { - cstr1 := (*C.gchar)(C.CString(id)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_application_set_application_id(v.native(), cstr1) -} - -// GetInactivityTimeout is a wrapper around g_application_get_inactivity_timeout(). -func (v *Application) GetInactivityTimeout() uint { - return uint(C.g_application_get_inactivity_timeout(v.native())) -} - -// SetInactivityTimeout is a wrapper around g_application_set_inactivity_timeout(). -func (v *Application) SetInactivityTimeout(timeout uint) { - C.g_application_set_inactivity_timeout(v.native(), C.guint(timeout)) -} - -// GetFlags is a wrapper around g_application_get_flags(). -func (v *Application) GetFlags() ApplicationFlags { - return ApplicationFlags(C.g_application_get_flags(v.native())) -} - -// SetFlags is a wrapper around g_application_set_flags(). -func (v *Application) SetFlags(flags ApplicationFlags) { - C.g_application_set_flags(v.native(), C.GApplicationFlags(flags)) -} - -// Only available in GLib 2.42+ -// // GetResourceBasePath is a wrapper around g_application_get_resource_base_path(). -// func (v *Application) GetResourceBasePath() string { -// c := C.g_application_get_resource_base_path(v.native()) - -// return C.GoString((*C.char)(c)) -// } - -// Only available in GLib 2.42+ -// // SetResourceBasePath is a wrapper around g_application_set_resource_base_path(). -// func (v *Application) SetResourceBasePath(bp string) { -// cstr1 := (*C.gchar)(C.CString(bp)) -// defer C.free(unsafe.Pointer(cstr1)) - -// C.g_application_set_resource_base_path(v.native(), cstr1) -// } - -// GetDbusObjectPath is a wrapper around g_application_get_dbus_object_path(). -func (v *Application) GetDbusObjectPath() string { - c := C.g_application_get_dbus_object_path(v.native()) - - return C.GoString((*C.char)(c)) -} - -// GetIsRegistered is a wrapper around g_application_get_is_registered(). -func (v *Application) GetIsRegistered() bool { - return gobool(C.g_application_get_is_registered(v.native())) -} - -// GetIsRemote is a wrapper around g_application_get_is_remote(). -func (v *Application) GetIsRemote() bool { - return gobool(C.g_application_get_is_remote(v.native())) -} - -// Hold is a wrapper around g_application_hold(). -func (v *Application) Hold() { - C.g_application_hold(v.native()) -} - -// Release is a wrapper around g_application_release(). -func (v *Application) Release() { - C.g_application_release(v.native()) -} - -// Quit is a wrapper around g_application_quit(). -func (v *Application) Quit() { - C.g_application_quit(v.native()) -} - -// Activate is a wrapper around g_application_activate(). -func (v *Application) Activate() { - C.g_application_activate(v.native()) -} - -// SendNotification is a wrapper around g_application_send_notification(). -func (v *Application) SendNotification(id string, notification *Notification) { - cstr1 := (*C.gchar)(C.CString(id)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_application_send_notification(v.native(), cstr1, notification.native()) -} - -// WithdrawNotification is a wrapper around g_application_withdraw_notification(). -func (v *Application) WithdrawNotification(id string) { - cstr1 := (*C.gchar)(C.CString(id)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_application_withdraw_notification(v.native(), cstr1) -} - -// SetDefault is a wrapper around g_application_set_default(). -func (v *Application) SetDefault() { - C.g_application_set_default(v.native()) -} - -// ApplicationGetDefault is a wrapper around g_application_get_default(). -func ApplicationGetDefault() *Application { - c := C.g_application_get_default() - if c == nil { - return nil - } - return wrapApplication(wrapObject(unsafe.Pointer(c))) -} - -// MarkBusy is a wrapper around g_application_mark_busy(). -func (v *Application) MarkBusy() { - C.g_application_mark_busy(v.native()) -} - -// UnmarkBusy is a wrapper around g_application_unmark_busy(). -func (v *Application) UnmarkBusy() { - C.g_application_unmark_busy(v.native()) -} - -// Run is a wrapper around g_application_run(). -func (v *Application) Run(args []string) int { - cargs := C.make_strings(C.int(len(args))) - defer C.destroy_strings(cargs) - - for i, arg := range args { - cstr := C.CString(arg) - defer C.free(unsafe.Pointer(cstr)) - C.set_string(cargs, C.int(i), (*C.char)(cstr)) - } - - C.set_string(cargs, C.int(len(args)), nil) - - return int(C.g_application_run(v.native(), C.int(len(args)), cargs)) -} - -// Only available in GLib 2.44+ -// // GetIsBusy is a wrapper around g_application_get_is_busy(). -// func (v *Application) GetIsBusy() bool { -// return gobool(C.g_application_get_is_busy(v.native())) -// } - -// void g_application_bind_busy_property () -// void g_application_unbind_busy_property () -// gboolean g_application_register () // requires GCancellable -// void g_application_set_action_group () // Deprecated since 2.32 -// GDBusConnection * g_application_get_dbus_connection () // No support for GDBusConnection -// void g_application_open () // Needs GFile -// void g_application_add_main_option_entries () //Needs GOptionEntry -// void g_application_add_main_option () //Needs GOptionFlags and GOptionArg -// void g_application_add_option_group () // Needs GOptionGroup diff --git a/vendor/github.com/gotk3/gotk3.old/glib/connect.go b/vendor/github.com/gotk3/gotk3.old/glib/connect.go deleted file mode 100644 index ffa1e44..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/connect.go +++ /dev/null @@ -1,117 +0,0 @@ -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include "glib.go.h" -import "C" -import ( - "errors" - "reflect" - "unsafe" -) - -/* - * Events - */ - -type SignalHandle uint - -func (v *Object) connectClosure(after bool, detailedSignal string, f interface{}, userData ...interface{}) (SignalHandle, error) { - if len(userData) > 1 { - return 0, errors.New("userData len must be 0 or 1") - } - - cstr := C.CString(detailedSignal) - defer C.free(unsafe.Pointer(cstr)) - - closure, err := ClosureNew(f, userData...) - if err != nil { - return 0, err - } - - C._g_closure_add_finalize_notifier(closure) - - c := C.g_signal_connect_closure(C.gpointer(v.native()), - (*C.gchar)(cstr), closure, gbool(after)) - handle := SignalHandle(c) - - // Map the signal handle to the closure. - signals[handle] = closure - - return handle, nil -} - -// Connect is a wrapper around g_signal_connect_closure(). f must be -// a function with a signaure matching the callback signature for -// detailedSignal. userData must either 0 or 1 elements which can -// be optionally passed to f. If f takes less arguments than it is -// passed from the GLib runtime, the extra arguments are ignored. -// -// Arguments for f must be a matching Go equivalent type for the -// C callback, or an interface type which the value may be packed in. -// If the type is not suitable, a runtime panic will occur when the -// signal is emitted. -func (v *Object) Connect(detailedSignal string, f interface{}, userData ...interface{}) (SignalHandle, error) { - return v.connectClosure(false, detailedSignal, f, userData...) -} - -// ConnectAfter is a wrapper around g_signal_connect_closure(). f must be -// a function with a signaure matching the callback signature for -// detailedSignal. userData must either 0 or 1 elements which can -// be optionally passed to f. If f takes less arguments than it is -// passed from the GLib runtime, the extra arguments are ignored. -// -// Arguments for f must be a matching Go equivalent type for the -// C callback, or an interface type which the value may be packed in. -// If the type is not suitable, a runtime panic will occur when the -// signal is emitted. -// -// The difference between Connect and ConnectAfter is that the latter -// will be invoked after the default handler, not before. -func (v *Object) ConnectAfter(detailedSignal string, f interface{}, userData ...interface{}) (SignalHandle, error) { - return v.connectClosure(true, detailedSignal, f, userData...) -} - -// ClosureNew creates a new GClosure and adds its callback function -// to the internally-maintained map. It's exported for visibility to other -// gotk3 packages and shouldn't be used in application code. -func ClosureNew(f interface{}, marshalData ...interface{}) (*C.GClosure, error) { - // Create a reflect.Value from f. This is called when the - // returned GClosure runs. - rf := reflect.ValueOf(f) - - // Create closure context which points to the reflected func. - cc := closureContext{rf: rf} - - // Closures can only be created from funcs. - if rf.Type().Kind() != reflect.Func { - return nil, errors.New("value is not a func") - } - - if len(marshalData) > 0 { - cc.userData = reflect.ValueOf(marshalData[0]) - } - - c := C._g_closure_new() - - // Associate the GClosure with rf. rf will be looked up in this - // map by the closure when the closure runs. - closures.Lock() - closures.m[c] = cc - closures.Unlock() - - return c, nil -} - -// removeClosure removes a closure from the internal closures map. This is -// needed to prevent a leak where Go code can access the closure context -// (along with rf and userdata) even after an object has been destroyed and -// the GClosure is invalidated and will never run. -// -//export removeClosure -func removeClosure(_ C.gpointer, closure *C.GClosure) { - closures.Lock() - delete(closures.m, closure) - closures.Unlock() -} diff --git a/vendor/github.com/gotk3/gotk3.old/glib/glib.go b/vendor/github.com/gotk3/gotk3.old/glib/glib.go deleted file mode 100644 index 891d9d7..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/glib.go +++ /dev/null @@ -1,1343 +0,0 @@ -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// Package glib provides Go bindings for GLib 2. Supports version 2.36 -// and later. -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 gio-2.0 -// #include -// #include -// #include -// #include "glib.go.h" -import "C" -import ( - "errors" - "fmt" - "os" - "reflect" - "runtime" - "sync" - "unsafe" -) - -/* - * Type conversions - */ - -func gbool(b bool) C.gboolean { - if b { - return C.gboolean(1) - } - return C.gboolean(0) -} -func gobool(b C.gboolean) bool { - if b != 0 { - return true - } - return false -} - -/* - * Unexported vars - */ - -type closureContext struct { - rf reflect.Value - userData reflect.Value -} - -var ( - errNilPtr = errors.New("cgo returned unexpected nil pointer") - - closures = struct { - sync.RWMutex - m map[*C.GClosure]closureContext - }{ - m: make(map[*C.GClosure]closureContext), - } - - signals = make(map[SignalHandle]*C.GClosure) -) - -/* - * Constants - */ - -// Type is a representation of GLib's GType. -type Type uint - -const ( - TYPE_INVALID Type = C.G_TYPE_INVALID - TYPE_NONE Type = C.G_TYPE_NONE - TYPE_INTERFACE Type = C.G_TYPE_INTERFACE - TYPE_CHAR Type = C.G_TYPE_CHAR - TYPE_UCHAR Type = C.G_TYPE_UCHAR - TYPE_BOOLEAN Type = C.G_TYPE_BOOLEAN - TYPE_INT Type = C.G_TYPE_INT - TYPE_UINT Type = C.G_TYPE_UINT - TYPE_LONG Type = C.G_TYPE_LONG - TYPE_ULONG Type = C.G_TYPE_ULONG - TYPE_INT64 Type = C.G_TYPE_INT64 - TYPE_UINT64 Type = C.G_TYPE_UINT64 - TYPE_ENUM Type = C.G_TYPE_ENUM - TYPE_FLAGS Type = C.G_TYPE_FLAGS - TYPE_FLOAT Type = C.G_TYPE_FLOAT - TYPE_DOUBLE Type = C.G_TYPE_DOUBLE - TYPE_STRING Type = C.G_TYPE_STRING - TYPE_POINTER Type = C.G_TYPE_POINTER - TYPE_BOXED Type = C.G_TYPE_BOXED - TYPE_PARAM Type = C.G_TYPE_PARAM - TYPE_OBJECT Type = C.G_TYPE_OBJECT - TYPE_VARIANT Type = C.G_TYPE_VARIANT -) - -// Name is a wrapper around g_type_name(). -func (t Type) Name() string { - return C.GoString((*C.char)(C.g_type_name(C.GType(t)))) -} - -// Depth is a wrapper around g_type_depth(). -func (t Type) Depth() uint { - return uint(C.g_type_depth(C.GType(t))) -} - -// Parent is a wrapper around g_type_parent(). -func (t Type) Parent() Type { - return Type(C.g_type_parent(C.GType(t))) -} - -// UserDirectory is a representation of GLib's GUserDirectory. -type UserDirectory int - -const ( - USER_DIRECTORY_DESKTOP UserDirectory = C.G_USER_DIRECTORY_DESKTOP - USER_DIRECTORY_DOCUMENTS UserDirectory = C.G_USER_DIRECTORY_DOCUMENTS - USER_DIRECTORY_DOWNLOAD UserDirectory = C.G_USER_DIRECTORY_DOWNLOAD - USER_DIRECTORY_MUSIC UserDirectory = C.G_USER_DIRECTORY_MUSIC - USER_DIRECTORY_PICTURES UserDirectory = C.G_USER_DIRECTORY_PICTURES - USER_DIRECTORY_PUBLIC_SHARE UserDirectory = C.G_USER_DIRECTORY_PUBLIC_SHARE - USER_DIRECTORY_TEMPLATES UserDirectory = C.G_USER_DIRECTORY_TEMPLATES - USER_DIRECTORY_VIDEOS UserDirectory = C.G_USER_DIRECTORY_VIDEOS -) - -const USER_N_DIRECTORIES int = C.G_USER_N_DIRECTORIES - -/* - * GApplicationFlags - */ - -type ApplicationFlags int - -const ( - APPLICATION_FLAGS_NONE ApplicationFlags = C.G_APPLICATION_FLAGS_NONE - APPLICATION_IS_SERVICE ApplicationFlags = C.G_APPLICATION_IS_SERVICE - APPLICATION_HANDLES_OPEN ApplicationFlags = C.G_APPLICATION_HANDLES_OPEN - APPLICATION_HANDLES_COMMAND_LINE ApplicationFlags = C.G_APPLICATION_HANDLES_COMMAND_LINE - APPLICATION_SEND_ENVIRONMENT ApplicationFlags = C.G_APPLICATION_SEND_ENVIRONMENT - APPLICATION_NON_UNIQUE ApplicationFlags = C.G_APPLICATION_NON_UNIQUE -) - -// goMarshal is called by the GLib runtime when a closure needs to be invoked. -// The closure will be invoked with as many arguments as it can take, from 0 to -// the full amount provided by the call. If the closure asks for more parameters -// than there are to give, a warning is printed to stderr and the closure is -// not run. -// -//export goMarshal -func goMarshal(closure *C.GClosure, retValue *C.GValue, - nParams C.guint, params *C.GValue, - invocationHint C.gpointer, marshalData *C.GValue) { - - // Get the context associated with this callback closure. - closures.RLock() - cc := closures.m[closure] - closures.RUnlock() - - // Get number of parameters passed in. If user data was saved with the - // closure context, increment the total number of parameters. - nGLibParams := int(nParams) - nTotalParams := nGLibParams - if cc.userData.IsValid() { - nTotalParams++ - } - - // Get number of parameters from the callback closure. If this exceeds - // the total number of marshaled parameters, a warning will be printed - // to stderr, and the callback will not be run. - nCbParams := cc.rf.Type().NumIn() - if nCbParams > nTotalParams { - fmt.Fprintf(os.Stderr, - "too many closure args: have %d, max allowed %d\n", - nCbParams, nTotalParams) - return - } - - // Create a slice of reflect.Values as arguments to call the function. - gValues := gValueSlice(params, nCbParams) - args := make([]reflect.Value, 0, nCbParams) - - // Fill beginning of args, up to the minimum of the total number of callback - // parameters and parameters from the glib runtime. - for i := 0; i < nCbParams && i < nGLibParams; i++ { - v := &Value{&gValues[i]} - val, err := v.GoValue() - if err != nil { - fmt.Fprintf(os.Stderr, - "no suitable Go value for arg %d: %v\n", i, err) - return - } - rv := reflect.ValueOf(val) - args = append(args, rv.Convert(cc.rf.Type().In(i))) - } - - // If non-nil user data was passed in and not all args have been set, - // get and set the reflect.Value directly from the GValue. - if cc.userData.IsValid() && len(args) < cap(args) { - args = append(args, cc.userData.Convert(cc.rf.Type().In(nCbParams-1))) - } - - // Call closure with args. If the callback returns one or more - // values, save the GValue equivalent of the first. - rv := cc.rf.Call(args) - if retValue != nil && len(rv) > 0 { - if g, err := GValue(rv[0].Interface()); err != nil { - fmt.Fprintf(os.Stderr, - "cannot save callback return value: %v", err) - } else { - *retValue = *g.native() - } - } -} - -// gValueSlice converts a C array of GValues to a Go slice. -func gValueSlice(values *C.GValue, nValues int) (slice []C.GValue) { - header := (*reflect.SliceHeader)((unsafe.Pointer(&slice))) - header.Cap = nValues - header.Len = nValues - header.Data = uintptr(unsafe.Pointer(values)) - return -} - -/* - * Main event loop - */ - -type SourceHandle uint - -// IdleAdd adds an idle source to the default main event loop -// context. After running once, the source func will be removed -// from the main event loop, unless f returns a single bool true. -// -// This function will cause a panic when f eventually runs if the -// types of args do not match those of f. -func IdleAdd(f interface{}, args ...interface{}) (SourceHandle, error) { - // f must be a func with no parameters. - rf := reflect.ValueOf(f) - if rf.Type().Kind() != reflect.Func { - return 0, errors.New("f is not a function") - } - - // Create an idle source func to be added to the main loop context. - idleSrc := C.g_idle_source_new() - if idleSrc == nil { - return 0, errNilPtr - } - return sourceAttach(idleSrc, rf, args...) -} - -// TimeoutAdd adds an timeout source to the default main event loop -// context. After running once, the source func will be removed -// from the main event loop, unless f returns a single bool true. -// -// This function will cause a panic when f eventually runs if the -// types of args do not match those of f. -// timeout is in milliseconds -func TimeoutAdd(timeout uint, f interface{}, args ...interface{}) (SourceHandle, error) { - // f must be a func with no parameters. - rf := reflect.ValueOf(f) - if rf.Type().Kind() != reflect.Func { - return 0, errors.New("f is not a function") - } - - // Create a timeout source func to be added to the main loop context. - timeoutSrc := C.g_timeout_source_new(C.guint(timeout)) - if timeoutSrc == nil { - return 0, errNilPtr - } - - return sourceAttach(timeoutSrc, rf, args...) -} - -// sourceAttach attaches a source to the default main loop context. -func sourceAttach(src *C.struct__GSource, rf reflect.Value, args ...interface{}) (SourceHandle, error) { - if src == nil { - return 0, errNilPtr - } - - // rf must be a func with no parameters. - if rf.Type().Kind() != reflect.Func { - C.g_source_destroy(src) - return 0, errors.New("rf is not a function") - } - - // Create a new GClosure from f that invalidates itself when - // f returns false. The error is ignored here, as this will - // always be a function. - var closure *C.GClosure - closure, _ = ClosureNew(func() { - // Create a slice of reflect.Values arguments to call the func. - rargs := make([]reflect.Value, len(args)) - for i := range args { - rargs[i] = reflect.ValueOf(args[i]) - } - - // Call func with args. The callback will be removed, unless - // it returns exactly one return value of true. - rv := rf.Call(rargs) - if len(rv) == 1 { - if rv[0].Kind() == reflect.Bool { - if rv[0].Bool() { - return - } - } - } - C.g_closure_invalidate(closure) - C.g_source_destroy(src) - }) - - // Remove closure context when closure is finalized. - C._g_closure_add_finalize_notifier(closure) - - // Set closure to run as a callback when the idle source runs. - C.g_source_set_closure(src, closure) - - // Attach the idle source func to the default main event loop - // context. - cid := C.g_source_attach(src, nil) - return SourceHandle(cid), nil -} - -/* - * Miscellaneous Utility Functions - */ - -// GetUserSpecialDir is a wrapper around g_get_user_special_dir(). A -// non-nil error is returned in the case that g_get_user_special_dir() -// returns NULL to differentiate between NULL and an empty string. -func GetUserSpecialDir(directory UserDirectory) (string, error) { - c := C.g_get_user_special_dir(C.GUserDirectory(directory)) - if c == nil { - return "", errNilPtr - } - return C.GoString((*C.char)(c)), nil -} - -/* - * GObject - */ - -// IObject is an interface type implemented by Object and all types which embed -// an Object. It is meant to be used as a type for function arguments which -// require GObjects or any subclasses thereof. -type IObject interface { - toGObject() *C.GObject - toObject() *Object -} - -// Object is a representation of GLib's GObject. -type Object struct { - GObject *C.GObject -} - -func (v *Object) toGObject() *C.GObject { - if v == nil { - return nil - } - return v.native() -} - -func (v *Object) toObject() *Object { - return v -} - -// newObject creates a new Object from a GObject pointer. -func newObject(p *C.GObject) *Object { - return &Object{GObject: p} -} - -// native returns a pointer to the underlying GObject. -func (v *Object) native() *C.GObject { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGObject(p) -} - -// Native returns a pointer to the underlying GObject. -func (v *Object) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -// IsA is a wrapper around g_type_is_a(). -func (v *Object) IsA(typ Type) bool { - return gobool(C.g_type_is_a(C.GType(v.TypeFromInstance()), C.GType(typ))) -} - -// TypeFromInstance is a wrapper around g_type_from_instance(). -func (v *Object) TypeFromInstance() Type { - c := C._g_type_from_instance(C.gpointer(unsafe.Pointer(v.native()))) - return Type(c) -} - -// ToGObject type converts an unsafe.Pointer as a native C GObject. -// This function is exported for visibility in other gotk3 packages and -// is not meant to be used by applications. -func ToGObject(p unsafe.Pointer) *C.GObject { - return C.toGObject(p) -} - -// Ref is a wrapper around g_object_ref(). -func (v *Object) Ref() { - C.g_object_ref(C.gpointer(v.GObject)) -} - -// Unref is a wrapper around g_object_unref(). -func (v *Object) Unref() { - C.g_object_unref(C.gpointer(v.GObject)) -} - -// RefSink is a wrapper around g_object_ref_sink(). -func (v *Object) RefSink() { - C.g_object_ref_sink(C.gpointer(v.GObject)) -} - -// IsFloating is a wrapper around g_object_is_floating(). -func (v *Object) IsFloating() bool { - c := C.g_object_is_floating(C.gpointer(v.GObject)) - return gobool(c) -} - -// ForceFloating is a wrapper around g_object_force_floating(). -func (v *Object) ForceFloating() { - C.g_object_force_floating(v.GObject) -} - -// StopEmission is a wrapper around g_signal_stop_emission_by_name(). -func (v *Object) StopEmission(s string) { - cstr := C.CString(s) - defer C.free(unsafe.Pointer(cstr)) - C.g_signal_stop_emission_by_name((C.gpointer)(v.GObject), - (*C.gchar)(cstr)) -} - -// Set is a wrapper around g_object_set(). However, unlike -// g_object_set(), this function only sets one name value pair. Make -// multiple calls to this function to set multiple properties. -func (v *Object) Set(name string, value interface{}) error { - return v.SetProperty(name, value) - /* - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - - if _, ok := value.(Object); ok { - value = value.(Object).GObject - } - - // Can't call g_object_set() as it uses a variable arg list, use a - // wrapper instead - var p unsafe.Pointer - switch v := value.(type) { - case bool: - c := gbool(v) - p = unsafe.Pointer(&c) - - case int8: - c := C.gint8(v) - p = unsafe.Pointer(&c) - - case int16: - c := C.gint16(v) - p = unsafe.Pointer(&c) - - case int32: - c := C.gint32(v) - p = unsafe.Pointer(&c) - - case int64: - c := C.gint64(v) - p = unsafe.Pointer(&c) - - case int: - c := C.gint(v) - p = unsafe.Pointer(&c) - - case uint8: - c := C.guchar(v) - p = unsafe.Pointer(&c) - - case uint16: - c := C.guint16(v) - p = unsafe.Pointer(&c) - - case uint32: - c := C.guint32(v) - p = unsafe.Pointer(&c) - - case uint64: - c := C.guint64(v) - p = unsafe.Pointer(&c) - - case uint: - c := C.guint(v) - p = unsafe.Pointer(&c) - - case uintptr: - p = unsafe.Pointer(C.gpointer(v)) - - case float32: - c := C.gfloat(v) - p = unsafe.Pointer(&c) - - case float64: - c := C.gdouble(v) - p = unsafe.Pointer(&c) - - case string: - cstr := C.CString(v) - defer C.g_free(C.gpointer(unsafe.Pointer(cstr))) - p = unsafe.Pointer(&cstr) - - default: - if pv, ok := value.(unsafe.Pointer); ok { - p = pv - } else { - val := reflect.ValueOf(value) - switch val.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, - reflect.Int32, reflect.Int64: - c := C.int(val.Int()) - p = unsafe.Pointer(&c) - - case reflect.Uintptr, reflect.Ptr, reflect.UnsafePointer: - p = unsafe.Pointer(C.gpointer(val.Pointer())) - } - } - } - if p == nil { - return errors.New("Unable to perform type conversion") - } - C._g_object_set_one(C.gpointer(v.GObject), (*C.gchar)(cstr), p) - return nil*/ -} - -// GetPropertyType returns the Type of a property of the underlying GObject. -// If the property is missing it will return TYPE_INVALID and an error. -func (v *Object) GetPropertyType(name string) (Type, error) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - - paramSpec := C.g_object_class_find_property(C._g_object_get_class(v.native()), (*C.gchar)(cstr)) - if paramSpec == nil { - return TYPE_INVALID, errors.New("couldn't find Property") - } - return Type(paramSpec.value_type), nil -} - -// GetProperty is a wrapper around g_object_get_property(). -func (v *Object) GetProperty(name string) (interface{}, error) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - - t, err := v.GetPropertyType(name) - if err != nil { - return nil, err - } - - p, err := ValueInit(t) - if err != nil { - return nil, errors.New("unable to allocate value") - } - C.g_object_get_property(v.GObject, (*C.gchar)(cstr), p.native()) - return p.GoValue() -} - -// SetProperty is a wrapper around g_object_set_property(). -func (v *Object) SetProperty(name string, value interface{}) error { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - - if _, ok := value.(Object); ok { - value = value.(Object).GObject - } - - p, err := GValue(value) - if err != nil { - return errors.New("Unable to perform type conversion") - } - C.g_object_set_property(v.GObject, (*C.gchar)(cstr), p.native()) - return nil -} - -// pointerVal attempts to return an unsafe.Pointer for value. -// Not all types are understood, in which case a nil Pointer -// is returned. -/*func pointerVal(value interface{}) unsafe.Pointer { - var p unsafe.Pointer - switch v := value.(type) { - case bool: - c := gbool(v) - p = unsafe.Pointer(&c) - - case int8: - c := C.gint8(v) - p = unsafe.Pointer(&c) - - case int16: - c := C.gint16(v) - p = unsafe.Pointer(&c) - - case int32: - c := C.gint32(v) - p = unsafe.Pointer(&c) - - case int64: - c := C.gint64(v) - p = unsafe.Pointer(&c) - - case int: - c := C.gint(v) - p = unsafe.Pointer(&c) - - case uint8: - c := C.guchar(v) - p = unsafe.Pointer(&c) - - case uint16: - c := C.guint16(v) - p = unsafe.Pointer(&c) - - case uint32: - c := C.guint32(v) - p = unsafe.Pointer(&c) - - case uint64: - c := C.guint64(v) - p = unsafe.Pointer(&c) - - case uint: - c := C.guint(v) - p = unsafe.Pointer(&c) - - case uintptr: - p = unsafe.Pointer(C.gpointer(v)) - - case float32: - c := C.gfloat(v) - p = unsafe.Pointer(&c) - - case float64: - c := C.gdouble(v) - p = unsafe.Pointer(&c) - - case string: - cstr := C.CString(v) - defer C.free(unsafe.Pointer(cstr)) - p = unsafe.Pointer(cstr) - - default: - if pv, ok := value.(unsafe.Pointer); ok { - p = pv - } else { - val := reflect.ValueOf(value) - switch val.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, - reflect.Int32, reflect.Int64: - c := C.int(val.Int()) - p = unsafe.Pointer(&c) - - case reflect.Uintptr, reflect.Ptr, reflect.UnsafePointer: - p = unsafe.Pointer(C.gpointer(val.Pointer())) - } - } - } - - return p -}*/ - -/* - * GObject Signals - */ - -// Emit is a wrapper around g_signal_emitv() and emits the signal -// specified by the string s to an Object. Arguments to callback -// functions connected to this signal must be specified in args. Emit() -// returns an interface{} which must be type asserted as the Go -// equivalent type to the return value for native C callback. -// -// Note that this code is unsafe in that the types of values in args are -// not checked against whether they are suitable for the callback. -func (v *Object) Emit(s string, args ...interface{}) (interface{}, error) { - cstr := C.CString(s) - defer C.free(unsafe.Pointer(cstr)) - - // Create array of this instance and arguments - valv := C.alloc_gvalue_list(C.int(len(args)) + 1) - defer C.free(unsafe.Pointer(valv)) - - // Add args and valv - val, err := GValue(v) - if err != nil { - return nil, errors.New("Error converting Object to GValue: " + err.Error()) - } - C.val_list_insert(valv, C.int(0), val.native()) - for i := range args { - val, err := GValue(args[i]) - if err != nil { - return nil, fmt.Errorf("Error converting arg %d to GValue: %s", i, err.Error()) - } - C.val_list_insert(valv, C.int(i+1), val.native()) - } - - t := v.TypeFromInstance() - // TODO: use just the signal name - id := C.g_signal_lookup((*C.gchar)(cstr), C.GType(t)) - - ret, err := ValueAlloc() - if err != nil { - return nil, errors.New("Error creating Value for return value") - } - C.g_signal_emitv(valv, id, C.GQuark(0), ret.native()) - - return ret.GoValue() -} - -// HandlerBlock is a wrapper around g_signal_handler_block(). -func (v *Object) HandlerBlock(handle SignalHandle) { - C.g_signal_handler_block(C.gpointer(v.GObject), C.gulong(handle)) -} - -// HandlerUnblock is a wrapper around g_signal_handler_unblock(). -func (v *Object) HandlerUnblock(handle SignalHandle) { - C.g_signal_handler_unblock(C.gpointer(v.GObject), C.gulong(handle)) -} - -// HandlerDisconnect is a wrapper around g_signal_handler_disconnect(). -func (v *Object) HandlerDisconnect(handle SignalHandle) { - C.g_signal_handler_disconnect(C.gpointer(v.GObject), C.gulong(handle)) - C.g_closure_invalidate(signals[handle]) - delete(closures.m, signals[handle]) - delete(signals, handle) -} - -// Wrapper function for new objects with reference management. -func wrapObject(ptr unsafe.Pointer) *Object { - obj := &Object{ToGObject(ptr)} - - if obj.IsFloating() { - obj.RefSink() - } else { - obj.Ref() - } - - runtime.SetFinalizer(obj, (*Object).Unref) - return obj -} - -/* - * GInitiallyUnowned - */ - -// InitiallyUnowned is a representation of GLib's GInitiallyUnowned. -type InitiallyUnowned struct { - // This must be a pointer so copies of the ref-sinked object - // do not outlive the original object, causing an unref - // finalizer to prematurely run. - *Object -} - -// Native returns a pointer to the underlying GObject. This is implemented -// here rather than calling Native on the embedded Object to prevent a nil -// pointer dereference. -func (v *InitiallyUnowned) Native() uintptr { - if v == nil || v.Object == nil { - return uintptr(unsafe.Pointer(nil)) - } - return v.Object.Native() -} - -/* - * GValue - */ - -// Value is a representation of GLib's GValue. -// -// Don't allocate Values on the stack or heap manually as they may not -// be properly unset when going out of scope. Instead, use ValueAlloc(), -// which will set the runtime finalizer to unset the Value after it has -// left scope. -type Value struct { - GValue *C.GValue -} - -// native returns a pointer to the underlying GValue. -func (v *Value) native() *C.GValue { - return v.GValue -} - -// Native returns a pointer to the underlying GValue. -func (v *Value) Native() unsafe.Pointer { - return unsafe.Pointer(v.native()) -} - -// ValueAlloc allocates a Value and sets a runtime finalizer to call -// g_value_unset() on the underlying GValue after leaving scope. -// ValueAlloc() returns a non-nil error if the allocation failed. -func ValueAlloc() (*Value, error) { - c := C._g_value_alloc() - if c == nil { - return nil, errNilPtr - } - - v := &Value{c} - - //An allocated GValue is not guaranteed to hold a value that can be unset - //We need to double check before unsetting, to prevent: - //`g_value_unset: assertion 'G_IS_VALUE (value)' failed` - runtime.SetFinalizer(v, func(f *Value) { - if t, _, err := f.Type(); err != nil || t == TYPE_INVALID || t == TYPE_NONE { - C.g_free(C.gpointer(f.native())) - return - } - - f.unset() - }) - - return v, nil -} - -// ValueInit is a wrapper around g_value_init() and allocates and -// initializes a new Value with the Type t. A runtime finalizer is set -// to call g_value_unset() on the underlying GValue after leaving scope. -// ValueInit() returns a non-nil error if the allocation failed. -func ValueInit(t Type) (*Value, error) { - c := C._g_value_init(C.GType(t)) - if c == nil { - return nil, errNilPtr - } - - v := &Value{c} - - runtime.SetFinalizer(v, (*Value).unset) - return v, nil -} - -// ValueFromNative returns a type-asserted pointer to the Value. -func ValueFromNative(l unsafe.Pointer) *Value { - //TODO why it does not add finalizer to the value? - return &Value{(*C.GValue)(l)} -} - -func (v *Value) unset() { - C.g_value_unset(v.native()) -} - -// Type is a wrapper around the G_VALUE_HOLDS_GTYPE() macro and -// the g_value_get_gtype() function. GetType() returns TYPE_INVALID if v -// does not hold a Type, or otherwise returns the Type of v. -func (v *Value) Type() (actual Type, fundamental Type, err error) { - if !gobool(C._g_is_value(v.native())) { - return actual, fundamental, errors.New("invalid GValue") - } - cActual := C._g_value_type(v.native()) - cFundamental := C._g_value_fundamental(cActual) - return Type(cActual), Type(cFundamental), nil -} - -// GValue converts a Go type to a comparable GValue. GValue() -// returns a non-nil error if the conversion was unsuccessful. -func GValue(v interface{}) (gvalue *Value, err error) { - if v == nil { - val, err := ValueInit(TYPE_POINTER) - if err != nil { - return nil, err - } - val.SetPointer(uintptr(unsafe.Pointer(nil))) - return val, nil - } - - switch e := v.(type) { - case bool: - val, err := ValueInit(TYPE_BOOLEAN) - if err != nil { - return nil, err - } - val.SetBool(e) - return val, nil - - case int8: - val, err := ValueInit(TYPE_CHAR) - if err != nil { - return nil, err - } - val.SetSChar(e) - return val, nil - - case int64: - val, err := ValueInit(TYPE_INT64) - if err != nil { - return nil, err - } - val.SetInt64(e) - return val, nil - - case int: - val, err := ValueInit(TYPE_INT) - if err != nil { - return nil, err - } - val.SetInt(e) - return val, nil - - case uint8: - val, err := ValueInit(TYPE_UCHAR) - if err != nil { - return nil, err - } - val.SetUChar(e) - return val, nil - - case uint64: - val, err := ValueInit(TYPE_UINT64) - if err != nil { - return nil, err - } - val.SetUInt64(e) - return val, nil - - case uint: - val, err := ValueInit(TYPE_UINT) - if err != nil { - return nil, err - } - val.SetUInt(e) - return val, nil - - case float32: - val, err := ValueInit(TYPE_FLOAT) - if err != nil { - return nil, err - } - val.SetFloat(e) - return val, nil - - case float64: - val, err := ValueInit(TYPE_DOUBLE) - if err != nil { - return nil, err - } - val.SetDouble(e) - return val, nil - - case string: - val, err := ValueInit(TYPE_STRING) - if err != nil { - return nil, err - } - val.SetString(e) - return val, nil - - case *Object: - val, err := ValueInit(TYPE_OBJECT) - if err != nil { - return nil, err - } - val.SetInstance(uintptr(unsafe.Pointer(e.GObject))) - return val, nil - - default: - /* Try this since above doesn't catch constants under other types */ - rval := reflect.ValueOf(v) - switch rval.Kind() { - case reflect.Int8: - val, err := ValueInit(TYPE_CHAR) - if err != nil { - return nil, err - } - val.SetSChar(int8(rval.Int())) - return val, nil - - case reflect.Int16: - return nil, errors.New("Type not implemented") - - case reflect.Int32: - return nil, errors.New("Type not implemented") - - case reflect.Int64: - val, err := ValueInit(TYPE_INT64) - if err != nil { - return nil, err - } - val.SetInt64(rval.Int()) - return val, nil - - case reflect.Int: - val, err := ValueInit(TYPE_INT) - if err != nil { - return nil, err - } - val.SetInt(int(rval.Int())) - return val, nil - - case reflect.Uintptr, reflect.Ptr: - val, err := ValueInit(TYPE_POINTER) - if err != nil { - return nil, err - } - val.SetPointer(rval.Pointer()) - return val, nil - } - } - - return nil, errors.New("Type not implemented") -} - -// GValueMarshaler is a marshal function to convert a GValue into an -// appropiate Go type. The uintptr parameter is a *C.GValue. -type GValueMarshaler func(uintptr) (interface{}, error) - -// TypeMarshaler represents an actual type and it's associated marshaler. -type TypeMarshaler struct { - T Type - F GValueMarshaler -} - -// RegisterGValueMarshalers adds marshalers for several types to the -// internal marshalers map. Once registered, calling GoValue on any -// Value witha registered type will return the data returned by the -// marshaler. -func RegisterGValueMarshalers(tm []TypeMarshaler) { - gValueMarshalers.register(tm) -} - -type marshalMap map[Type]GValueMarshaler - -// gValueMarshalers is a map of Glib types to functions to marshal a -// GValue to a native Go type. -var gValueMarshalers = marshalMap{ - TYPE_INVALID: marshalInvalid, - TYPE_NONE: marshalNone, - TYPE_INTERFACE: marshalInterface, - TYPE_CHAR: marshalChar, - TYPE_UCHAR: marshalUchar, - TYPE_BOOLEAN: marshalBoolean, - TYPE_INT: marshalInt, - TYPE_LONG: marshalLong, - TYPE_ENUM: marshalEnum, - TYPE_INT64: marshalInt64, - TYPE_UINT: marshalUint, - TYPE_ULONG: marshalUlong, - TYPE_FLAGS: marshalFlags, - TYPE_UINT64: marshalUint64, - TYPE_FLOAT: marshalFloat, - TYPE_DOUBLE: marshalDouble, - TYPE_STRING: marshalString, - TYPE_POINTER: marshalPointer, - TYPE_BOXED: marshalBoxed, - TYPE_OBJECT: marshalObject, - TYPE_VARIANT: marshalVariant, -} - -func (m marshalMap) register(tm []TypeMarshaler) { - for i := range tm { - m[tm[i].T] = tm[i].F - } -} - -func (m marshalMap) lookup(v *Value) (GValueMarshaler, error) { - actual, fundamental, err := v.Type() - if err != nil { - return nil, err - } - - if f, ok := m[actual]; ok { - return f, nil - } - if f, ok := m[fundamental]; ok { - return f, nil - } - return nil, errors.New("missing marshaler for type") -} - -func marshalInvalid(uintptr) (interface{}, error) { - return nil, errors.New("invalid type") -} - -func marshalNone(uintptr) (interface{}, error) { - return nil, nil -} - -func marshalInterface(uintptr) (interface{}, error) { - return nil, errors.New("interface conversion not yet implemented") -} - -func marshalChar(p uintptr) (interface{}, error) { - c := C.g_value_get_schar((*C.GValue)(unsafe.Pointer(p))) - return int8(c), nil -} - -func marshalUchar(p uintptr) (interface{}, error) { - c := C.g_value_get_uchar((*C.GValue)(unsafe.Pointer(p))) - return uint8(c), nil -} - -func marshalBoolean(p uintptr) (interface{}, error) { - c := C.g_value_get_boolean((*C.GValue)(unsafe.Pointer(p))) - return gobool(c), nil -} - -func marshalInt(p uintptr) (interface{}, error) { - c := C.g_value_get_int((*C.GValue)(unsafe.Pointer(p))) - return int(c), nil -} - -func marshalLong(p uintptr) (interface{}, error) { - c := C.g_value_get_long((*C.GValue)(unsafe.Pointer(p))) - return int(c), nil -} - -func marshalEnum(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return int(c), nil -} - -func marshalInt64(p uintptr) (interface{}, error) { - c := C.g_value_get_int64((*C.GValue)(unsafe.Pointer(p))) - return int64(c), nil -} - -func marshalUint(p uintptr) (interface{}, error) { - c := C.g_value_get_uint((*C.GValue)(unsafe.Pointer(p))) - return uint(c), nil -} - -func marshalUlong(p uintptr) (interface{}, error) { - c := C.g_value_get_ulong((*C.GValue)(unsafe.Pointer(p))) - return uint(c), nil -} - -func marshalFlags(p uintptr) (interface{}, error) { - c := C.g_value_get_flags((*C.GValue)(unsafe.Pointer(p))) - return uint(c), nil -} - -func marshalUint64(p uintptr) (interface{}, error) { - c := C.g_value_get_uint64((*C.GValue)(unsafe.Pointer(p))) - return uint64(c), nil -} - -func marshalFloat(p uintptr) (interface{}, error) { - c := C.g_value_get_float((*C.GValue)(unsafe.Pointer(p))) - return float32(c), nil -} - -func marshalDouble(p uintptr) (interface{}, error) { - c := C.g_value_get_double((*C.GValue)(unsafe.Pointer(p))) - return float64(c), nil -} - -func marshalString(p uintptr) (interface{}, error) { - c := C.g_value_get_string((*C.GValue)(unsafe.Pointer(p))) - return C.GoString((*C.char)(c)), nil -} - -func marshalBoxed(p uintptr) (interface{}, error) { - c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) - return uintptr(unsafe.Pointer(c)), nil -} - -func marshalPointer(p uintptr) (interface{}, error) { - c := C.g_value_get_pointer((*C.GValue)(unsafe.Pointer(p))) - return unsafe.Pointer(c), nil -} - -func marshalObject(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return newObject((*C.GObject)(c)), nil -} - -func marshalVariant(p uintptr) (interface{}, error) { - return nil, errors.New("variant conversion not yet implemented") -} - -// GoValue converts a Value to comparable Go type. GoValue() -// returns a non-nil error if the conversion was unsuccessful. The -// returned interface{} must be type asserted as the actual Go -// representation of the Value. -// -// This function is a wrapper around the many g_value_get_*() -// functions, depending on the type of the Value. -func (v *Value) GoValue() (interface{}, error) { - f, err := gValueMarshalers.lookup(v) - if err != nil { - return nil, err - } - - //No need to add finalizer because it is already done by ValueAlloc and ValueInit - rv, err := f(uintptr(unsafe.Pointer(v.native()))) - return rv, err -} - -// SetBool is a wrapper around g_value_set_boolean(). -func (v *Value) SetBool(val bool) { - C.g_value_set_boolean(v.native(), gbool(val)) -} - -// SetSChar is a wrapper around g_value_set_schar(). -func (v *Value) SetSChar(val int8) { - C.g_value_set_schar(v.native(), C.gint8(val)) -} - -// SetInt64 is a wrapper around g_value_set_int64(). -func (v *Value) SetInt64(val int64) { - C.g_value_set_int64(v.native(), C.gint64(val)) -} - -// SetInt is a wrapper around g_value_set_int(). -func (v *Value) SetInt(val int) { - C.g_value_set_int(v.native(), C.gint(val)) -} - -// SetUChar is a wrapper around g_value_set_uchar(). -func (v *Value) SetUChar(val uint8) { - C.g_value_set_uchar(v.native(), C.guchar(val)) -} - -// SetUInt64 is a wrapper around g_value_set_uint64(). -func (v *Value) SetUInt64(val uint64) { - C.g_value_set_uint64(v.native(), C.guint64(val)) -} - -// SetUInt is a wrapper around g_value_set_uint(). -func (v *Value) SetUInt(val uint) { - C.g_value_set_uint(v.native(), C.guint(val)) -} - -// SetFloat is a wrapper around g_value_set_float(). -func (v *Value) SetFloat(val float32) { - C.g_value_set_float(v.native(), C.gfloat(val)) -} - -// SetDouble is a wrapper around g_value_set_double(). -func (v *Value) SetDouble(val float64) { - C.g_value_set_double(v.native(), C.gdouble(val)) -} - -// SetString is a wrapper around g_value_set_string(). -func (v *Value) SetString(val string) { - cstr := C.CString(val) - defer C.free(unsafe.Pointer(cstr)) - C.g_value_set_string(v.native(), (*C.gchar)(cstr)) -} - -// SetInstance is a wrapper around g_value_set_instance(). -func (v *Value) SetInstance(instance uintptr) { - C.g_value_set_instance(v.native(), C.gpointer(instance)) -} - -// SetPointer is a wrapper around g_value_set_pointer(). -func (v *Value) SetPointer(p uintptr) { - C.g_value_set_pointer(v.native(), C.gpointer(p)) -} - -// GetPointer is a wrapper around g_value_get_pointer(). -func (v *Value) GetPointer() unsafe.Pointer { - return unsafe.Pointer(C.g_value_get_pointer(v.native())) -} - -// GetString is a wrapper around g_value_get_string(). GetString() -// returns a non-nil error if g_value_get_string() returned a NULL -// pointer to distinguish between returning a NULL pointer and returning -// an empty string. -func (v *Value) GetString() (string, error) { - c := C.g_value_get_string(v.native()) - if c == nil { - return "", errNilPtr - } - return C.GoString((*C.char)(c)), nil -} - -type Signal struct { - name string - signalId C.guint -} - -func SignalNew(s string) (*Signal, error) { - cstr := C.CString(s) - defer C.free(unsafe.Pointer(cstr)) - - signalId := C._g_signal_new((*C.gchar)(cstr)) - - if signalId == 0 { - return nil, fmt.Errorf("invalid signal name: %s", s) - } - - return &Signal{ - name: s, - signalId: signalId, - }, nil -} - -func (s *Signal) String() string { - return s.name -} - -type Quark uint32 - -// GetApplicationName is a wrapper around g_get_application_name(). -func GetApplicationName() string { - c := C.g_get_application_name() - - return C.GoString((*C.char)(c)) -} - -// SetApplicationName is a wrapper around g_set_application_name(). -func SetApplicationName(name string) { - cstr := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr)) - - C.g_set_application_name(cstr) -} - -// InitI18n initializes the i18n subsystem. -func InitI18n(domain string, dir string) { - domainStr := C.CString(domain) - defer C.free(unsafe.Pointer(domainStr)) - - dirStr := C.CString(dir) - defer C.free(unsafe.Pointer(dirStr)) - - C.init_i18n(domainStr, dirStr) -} - -// Local localizes a string using gettext -func Local(input string) string { - cstr := C.CString(input) - defer C.free(unsafe.Pointer(cstr)) - - return C.GoString(C.localize(cstr)) -} diff --git a/vendor/github.com/gotk3/gotk3.old/glib/glib.go.h b/vendor/github.com/gotk3/gotk3.old/glib/glib.go.h deleted file mode 100644 index a4e2605..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/glib.go.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (c) 2013-2014 Conformal Systems - * - * This file originated from: http://opensource.conformal.com/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef __GLIB_GO_H__ -#define __GLIB_GO_H__ - -#include -#include -#include - -#include -#define G_SETTINGS_ENABLE_BACKEND -#include -#include -#include -#include -#include - -/* GObject Type Casting */ -static GObject * -toGObject(void *p) -{ - return (G_OBJECT(p)); -} - -static GMenuModel * -toGMenuModel(void *p) -{ - return (G_MENU_MODEL(p)); -} - -static GMenu * -toGMenu(void *p) -{ - return (G_MENU(p)); -} - -static GMenuItem * -toGMenuItem(void *p) -{ - return (G_MENU_ITEM(p)); -} - -static GNotification * -toGNotification(void *p) -{ - return (G_NOTIFICATION(p)); -} - -static GApplication * -toGApplication(void *p) -{ - return (G_APPLICATION(p)); -} - -static GSettings * -toGSettings(void *p) -{ - return (G_SETTINGS(p)); -} - -static GSettingsBackend * -toGSettingsBackend(void *p) -{ - return (G_SETTINGS_BACKEND(p)); -} - - -static GType -_g_type_from_instance(gpointer instance) -{ - return (G_TYPE_FROM_INSTANCE(instance)); -} - -/* Wrapper to avoid variable arg list */ -static void -_g_object_set_one(gpointer object, const gchar *property_name, void *val) -{ - g_object_set(object, property_name, *(gpointer **)val, NULL); -} - -static GValue * -alloc_gvalue_list(int n) -{ - GValue *valv; - - valv = g_new0(GValue, n); - return (valv); -} - -static void -val_list_insert(GValue *valv, int i, GValue *val) -{ - valv[i] = *val; -} - -/* - * GValue - */ - -static GValue * -_g_value_alloc() -{ - return (g_new0(GValue, 1)); -} - -static GValue * -_g_value_init(GType g_type) -{ - GValue *value; - - value = g_new0(GValue, 1); - return (g_value_init(value, g_type)); -} - -static gboolean -_g_is_value(GValue *val) -{ - return (G_IS_VALUE(val)); -} - -static GType -_g_value_type(GValue *val) -{ - return (G_VALUE_TYPE(val)); -} - -static GType -_g_value_fundamental(GType type) -{ - return (G_TYPE_FUNDAMENTAL(type)); -} - -static GObjectClass * -_g_object_get_class (GObject *object) -{ - return (G_OBJECT_GET_CLASS(object)); -} - -/* - * Closure support - */ - -extern void goMarshal(GClosure *, GValue *, guint, GValue *, gpointer, GValue *); - -static GClosure * -_g_closure_new() -{ - GClosure *closure; - - closure = g_closure_new_simple(sizeof(GClosure), NULL); - g_closure_set_marshal(closure, (GClosureMarshal)(goMarshal)); - return (closure); -} - -extern void removeClosure(gpointer, GClosure *); - -static void -_g_closure_add_finalize_notifier(GClosure *closure) -{ - g_closure_add_finalize_notifier(closure, NULL, removeClosure); -} - -static inline guint _g_signal_new(const gchar *name) { - return g_signal_new(name, - G_TYPE_OBJECT, - G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - G_TYPE_POINTER); -} - -static void init_i18n(const char *domain, const char *dir) { - setlocale(LC_ALL, ""); - bindtextdomain(domain, dir); - bind_textdomain_codeset(domain, "UTF-8"); - textdomain(domain); -} - -static const char* localize(const char *string) { - return _(string); -} - -static inline char** make_strings(int count) { - return (char**)malloc(sizeof(char*) * count); -} - -static inline void destroy_strings(char** strings) { - free(strings); -} - -static inline char* get_string(char** strings, int n) { - return strings[n]; -} - -static inline void set_string(char** strings, int n, char* str) { - strings[n] = str; -} - -static inline gchar** next_gcharptr(gchar** s) { return (s+1); } - -#endif diff --git a/vendor/github.com/gotk3/gotk3.old/glib/glib_extension.go b/vendor/github.com/gotk3/gotk3.old/glib/glib_extension.go deleted file mode 100644 index 2d5b1ea..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/glib_extension.go +++ /dev/null @@ -1,18 +0,0 @@ -//glib_extension contains definitions and functions to interface between glib/gtk/gio and go universe - -package glib - -import ( - "reflect" -) - -// Should be implemented by any class which need special conversion like -// gtk.Application -> gio.Application -type IGlibConvert interface { - // If convertion can't be done, function have to panic with a message that it can't convert to type - Convert(reflect.Type) reflect.Value -} - -var ( - IGlibConvertType reflect.Type -) diff --git a/vendor/github.com/gotk3/gotk3.old/glib/gmain_context.go b/vendor/github.com/gotk3/gotk3.old/glib/gmain_context.go deleted file mode 100644 index da0a097..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/gmain_context.go +++ /dev/null @@ -1,32 +0,0 @@ -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 gio-2.0 -// #include -// #include -// #include -// #include "glib.go.h" -import "C" - -type MainContext C.GMainContext - -// native returns a pointer to the underlying GMainContext. -func (v *MainContext) native() *C.GMainContext { - if v == nil { - return nil - } - return (*C.GMainContext)(v) -} - -// MainContextDefault is a wrapper around g_main_context_default(). -func MainContextDefault() *MainContext { - c := C.g_main_context_default() - if c == nil { - return nil - } - return (*MainContext)(c) -} - -// MainDepth is a wrapper around g_main_depth(). -func MainDepth() int { - return int(C.g_main_depth()) -} diff --git a/vendor/github.com/gotk3/gotk3.old/glib/gsource.go b/vendor/github.com/gotk3/gotk3.old/glib/gsource.go deleted file mode 100644 index 427c946..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/gsource.go +++ /dev/null @@ -1,27 +0,0 @@ -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 gio-2.0 -// #include -// #include -// #include -// #include "glib.go.h" -import "C" - -type Source C.GSource - -// native returns a pointer to the underlying GSource. -func (v *Source) native() *C.GSource { - if v == nil { - return nil - } - return (*C.GSource)(v) -} - -// MainCurrentSource is a wrapper around g_main_current_source(). -func MainCurrentSource() *Source { - c := C.g_main_current_source() - if c == nil { - return nil - } - return (*Source)(c) -} diff --git a/vendor/github.com/gotk3/gotk3.old/glib/gvariant.go b/vendor/github.com/gotk3/gotk3.old/glib/gvariant.go deleted file mode 100644 index 34909ae..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/gvariant.go +++ /dev/null @@ -1,186 +0,0 @@ -//GVariant : GVariant — strongly typed value datatype -// https://developer.gnome.org/glib/2.26/glib-GVariant.html - -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include "glib.go.h" -// #include "gvariant.go.h" -//import "C" -//import "unsafe" - -/* - * GVariant - */ - -// IVariant is an interface type implemented by Variant and all types which embed -// an Variant. It is meant to be used as a type for function arguments which -// require GVariants or any subclasses thereof. -/* todo fix bugs -type IVariant interface { - ToGVariant() *C.GVariant - ToVariant() *Variant -} - -// Variant is a representation of GLib's GVariant. -type Variant struct { - GVariant *C.GVariant -} - -func (v *Variant) ToGVariant() *C.GVariant { - if v == nil { - return nil - } - return v.native() -} - -func (v *Variant) ToVariant() *Variant { - return v -} - -// newVariant creates a new Variant from a GVariant pointer. -func newVariant(p *C.GVariant) *Variant { - return &Variant{GVariant: p} -} - -func VariantFromUnsafePointer(p unsafe.Pointer) *Variant { - return &Variant{C.toGVariant(p)} -} - -// native returns a pointer to the underlying GVariant. -func (v *Variant) native() *C.GVariant { - if v == nil || v.GVariant == nil { - return nil - } - p := unsafe.Pointer(v.GVariant) - return C.toGVariant(p) -} - -// Native returns a pointer to the underlying GVariant. -func (v *Variant) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} -*/ - -//void g_variant_unref () -//GVariant * g_variant_ref () -//GVariant * g_variant_ref_sink () -//gboolean g_variant_is_floating () -//GVariant * g_variant_take_ref () -//const GVariantType * g_variant_get_type () -//const gchar * g_variant_get_type_string () -//gboolean g_variant_is_of_type () -//gboolean g_variant_is_container () -//gint g_variant_compare () -//GVariantClass g_variant_classify () -//gboolean g_variant_check_format_string () -//void g_variant_get () -//void g_variant_get_va () -//GVariant * g_variant_new () -//GVariant * g_variant_new_va () -//GVariant * g_variant_new_boolean () -//GVariant * g_variant_new_byte () -//GVariant * g_variant_new_int16 () -//GVariant * g_variant_new_uint16 () -//GVariant * g_variant_new_int32 () -//GVariant * g_variant_new_uint32 () -//GVariant * g_variant_new_int64 () -//GVariant * g_variant_new_uint64 () -//GVariant * g_variant_new_handle () -//GVariant * g_variant_new_double () -//GVariant * g_variant_new_string () -//GVariant * g_variant_new_take_string () -//GVariant * g_variant_new_printf () -//GVariant * g_variant_new_object_path () -//gboolean g_variant_is_object_path () -//GVariant * g_variant_new_signature () -//gboolean g_variant_is_signature () -//GVariant * g_variant_new_variant () -//GVariant * g_variant_new_strv () -//GVariant * g_variant_new_objv () -//GVariant * g_variant_new_bytestring () -//GVariant * g_variant_new_bytestring_array () -//gboolean g_variant_get_boolean () -//guchar g_variant_get_byte () -//gint16 g_variant_get_int16 () -//guint16 g_variant_get_uint16 () -//gint32 g_variant_get_int32 () -//guint32 g_variant_get_uint32 () -//gint64 g_variant_get_int64 () -//guint64 g_variant_get_uint64 () -//gint32 g_variant_get_handle () -//gdouble g_variant_get_double () -//const gchar * g_variant_get_string () -//gchar * g_variant_dup_string () -//GVariant * g_variant_get_variant () -//const gchar ** g_variant_get_strv () -//gchar ** g_variant_dup_strv () -//const gchar ** g_variant_get_objv () -//gchar ** g_variant_dup_objv () -//const gchar * g_variant_get_bytestring () -//gchar * g_variant_dup_bytestring () -//const gchar ** g_variant_get_bytestring_array () -//gchar ** g_variant_dup_bytestring_array () -//GVariant * g_variant_new_maybe () -//GVariant * g_variant_new_array () -//GVariant * g_variant_new_tuple () -//GVariant * g_variant_new_dict_entry () -//GVariant * g_variant_new_fixed_array () -//GVariant * g_variant_get_maybe () -//gsize g_variant_n_children () -//GVariant * g_variant_get_child_value () -//void g_variant_get_child () -//GVariant * g_variant_lookup_value () -//gboolean g_variant_lookup () -//gconstpointer g_variant_get_fixed_array () -//gsize g_variant_get_size () -//gconstpointer g_variant_get_data () -//GBytes * g_variant_get_data_as_bytes () -//void g_variant_store () -//GVariant * g_variant_new_from_data () -//GVariant * g_variant_new_from_bytes () -//GVariant * g_variant_byteswap () -//GVariant * g_variant_get_normal_form () -//gboolean g_variant_is_normal_form () -//guint g_variant_hash () -//gboolean g_variant_equal () -//gchar * g_variant_print () -//GString * g_variant_print_string () -//GVariantIter * g_variant_iter_copy () -//void g_variant_iter_free () -//gsize g_variant_iter_init () -//gsize g_variant_iter_n_children () -//GVariantIter * g_variant_iter_new () -//GVariant * g_variant_iter_next_value () -//gboolean g_variant_iter_next () -//gboolean g_variant_iter_loop () -//void g_variant_builder_unref () -//GVariantBuilder * g_variant_builder_ref () -//GVariantBuilder * g_variant_builder_new () -//void g_variant_builder_init () -//void g_variant_builder_clear () -//void g_variant_builder_add_value () -//void g_variant_builder_add () -//void g_variant_builder_add_parsed () -//GVariant * g_variant_builder_end () -//void g_variant_builder_open () -//void g_variant_builder_close () -//void g_variant_dict_unref () -//GVariantDict * g_variant_dict_ref () -//GVariantDict * g_variant_dict_new () -//void g_variant_dict_init () -//void g_variant_dict_clear () -//gboolean g_variant_dict_contains () -//gboolean g_variant_dict_lookup () -//GVariant * g_variant_dict_lookup_value () -//void g_variant_dict_insert () -//void g_variant_dict_insert_value () -//gboolean g_variant_dict_remove () -//GVariant * g_variant_dict_end () -//#define G_VARIANT_PARSE_ERROR -//GVariant * g_variant_parse () -//GVariant * g_variant_new_parsed_va () -//GVariant * g_variant_new_parsed () -//gchar * g_variant_parse_error_print_context () diff --git a/vendor/github.com/gotk3/gotk3.old/glib/gvariant.go.h b/vendor/github.com/gotk3/gotk3.old/glib/gvariant.go.h deleted file mode 100644 index 8f535c5..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/gvariant.go.h +++ /dev/null @@ -1,41 +0,0 @@ -// Same copyright and license as the rest of the files in this project - -//GVariant : GVariant — strongly typed value datatype -// https://developer.gnome.org/glib/2.26/glib-GVariant.html - -/* todo fix bugs -#ifndef __GVARIANT_GO_H__ -#define __GVARIANT_GO_H__ - -#include -#include -#include -#include - -// Type Casting -static GVariant * -toGVariant(void *p) -{ - return (_GVariant(p)); -} - -static GVariantBuilder * -toGVariantBuilder(void *p) -{ - return (GVariantBuilder(p)); -} - -static GVariantDict * -toGVariantDict(void *p) -{ - return (_GVariantDict(p)); -} - -static GVariantIter * -toGVariantIter(void *p) -{ - return (_GVariantIter(p)); -} - -#endif -*/ \ No newline at end of file diff --git a/vendor/github.com/gotk3/gotk3.old/glib/gvariantbuilder.go b/vendor/github.com/gotk3/gotk3.old/glib/gvariantbuilder.go deleted file mode 100644 index c7ef854..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/gvariantbuilder.go +++ /dev/null @@ -1,54 +0,0 @@ -// Same copyright and license as the rest of the files in this project - -// GVariant : GVariant — strongly typed value datatype -// https://developer.gnome.org/glib/2.26/glib-GVariant.html - -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include "glib.go.h" -// #include "gvariant.go.h" -//import "C" -//import "unsafe" - -/* - * GVariantBuilder - */ -/* todo fix bugs -// VariantBuilder is a representation of GLib's VariantBuilder. -type VariantBuilder struct { - GVariantBuilder *C.GVariantBuilder -} - -func (v *VariantBuilder) toGVariantBuilder() *C.GVariantBuilder { - if v == nil { - return nil - } - return v.native() -} - -func (v *VariantBuilder) toVariantBuilder() *VariantBuilder { - return v -} - -// newVariantBuilder creates a new VariantBuilder from a GVariantBuilder pointer. -func newVariantBuilder(p *C.GVariantBuilder) *VariantBuilder { - return &VariantBuilder{GVariantBuilder: p} -} - -// native returns a pointer to the underlying GVariantBuilder. -func (v *VariantBuilder) native() *C.GVariantBuilder { - if v == nil || v.GVariantBuilder == nil { - return nil - } - p := unsafe.Pointer(v.GVariantBuilder) - return C.toGVariantBuilder(p) -} - -// Native returns a pointer to the underlying GVariantBuilder. -func (v *VariantBuilder) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} -*/ diff --git a/vendor/github.com/gotk3/gotk3.old/glib/gvariantclass.go b/vendor/github.com/gotk3/gotk3.old/glib/gvariantclass.go deleted file mode 100644 index be6a237..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/gvariantclass.go +++ /dev/null @@ -1,39 +0,0 @@ -// Same copyright and license as the rest of the files in this project - -//GVariant : GVariant — strongly typed value datatype -// https://developer.gnome.org/glib/2.26/glib-GVariant.html - -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include "glib.go.h" -import "C" - -/* - * GVariantClass - */ - -type VariantClass int - -const ( - VARIANT_CLASS_BOOLEAN VariantClass = C.G_VARIANT_CLASS_BOOLEAN //The GVariant is a boolean. - VARIANT_CLASS_BYTE VariantClass = C.G_VARIANT_CLASS_BYTE //The GVariant is a byte. - VARIANT_CLASS_INT16 VariantClass = C.G_VARIANT_CLASS_INT16 //The GVariant is a signed 16 bit integer. - VARIANT_CLASS_UINT16 VariantClass = C.G_VARIANT_CLASS_UINT16 //The GVariant is an unsigned 16 bit integer. - VARIANT_CLASS_INT32 VariantClass = C.G_VARIANT_CLASS_INT32 //The GVariant is a signed 32 bit integer. - VARIANT_CLASS_UINT32 VariantClass = C.G_VARIANT_CLASS_UINT32 //The GVariant is an unsigned 32 bit integer. - VARIANT_CLASS_INT64 VariantClass = C.G_VARIANT_CLASS_INT64 //The GVariant is a signed 64 bit integer. - VARIANT_CLASS_UINT64 VariantClass = C.G_VARIANT_CLASS_UINT64 //The GVariant is an unsigned 64 bit integer. - VARIANT_CLASS_HANDLE VariantClass = C.G_VARIANT_CLASS_HANDLE //The GVariant is a file handle index. - VARIANT_CLASS_DOUBLE VariantClass = C.G_VARIANT_CLASS_DOUBLE //The GVariant is a double precision floating point value. - VARIANT_CLASS_STRING VariantClass = C.G_VARIANT_CLASS_STRING //The GVariant is a normal string. - VARIANT_CLASS_OBJECT_PATH VariantClass = C.G_VARIANT_CLASS_OBJECT_PATH //The GVariant is a D-Bus object path string. - VARIANT_CLASS_SIGNATURE VariantClass = C.G_VARIANT_CLASS_SIGNATURE //The GVariant is a D-Bus signature string. - VARIANT_CLASS_VARIANT VariantClass = C.G_VARIANT_CLASS_VARIANT //The GVariant is a variant. - VARIANT_CLASS_MAYBE VariantClass = C.G_VARIANT_CLASS_MAYBE //The GVariant is a maybe-typed value. - VARIANT_CLASS_ARRAY VariantClass = C.G_VARIANT_CLASS_ARRAY //The GVariant is an array. - VARIANT_CLASS_TUPLE VariantClass = C.G_VARIANT_CLASS_TUPLE //The GVariant is a tuple. - VARIANT_CLASS_DICT_ENTRY VariantClass = C.G_VARIANT_CLASS_DICT_ENTRY //The GVariant is a dictionary entry. -) diff --git a/vendor/github.com/gotk3/gotk3.old/glib/gvariantdict.go b/vendor/github.com/gotk3/gotk3.old/glib/gvariantdict.go deleted file mode 100644 index fcebb7a..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/gvariantdict.go +++ /dev/null @@ -1,54 +0,0 @@ -// Same copyright and license as the rest of the files in this project - -//GVariant : GVariant — strongly typed value datatype -// https://developer.gnome.org/glib/2.26/glib-GVariant.html - -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include "glib.go.h" -// #include "gvariant.go.h" -//import "C" -//import "unsafe" - -/* - * GVariantDict - */ -/* todo fix bugs -// VariantDict is a representation of GLib's VariantDict. -type VariantDict struct { - GVariantDict *C.GVariantDict -} - -func (v *VariantDict) toGVariantDict() *C.GVariantDict { - if v == nil { - return nil - } - return v.native() -} - -func (v *VariantDict) toVariantDict() *VariantDict { - return v -} - -// newVariantDict creates a new VariantDict from a GVariantDict pointer. -func newVariantDict(p *C.GVariantDict) *VariantDict { - return &VariantDict{GVariantDict: p} -} - -// native returns a pointer to the underlying GVariantDict. -func (v *VariantDict) native() *C.GVariantDict { - if v == nil || v.GVariantDict == nil { - return nil - } - p := unsafe.Pointer(v.GVariantDict) - return C.toGVariantDict(p) -} - -// Native returns a pointer to the underlying GVariantDict. -func (v *VariantDict) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} -*/ diff --git a/vendor/github.com/gotk3/gotk3.old/glib/gvariantiter.go b/vendor/github.com/gotk3/gotk3.old/glib/gvariantiter.go deleted file mode 100644 index 6bad360..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/gvariantiter.go +++ /dev/null @@ -1,54 +0,0 @@ -// Same copyright and license as the rest of the files in this project - -//GVariant : GVariant — strongly typed value datatype -// https://developer.gnome.org/glib/2.26/glib-GVariant.html - -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include "glib.go.h" -// #include "gvariant.go.h" -//import "C" -//import "unsafe" - -/* - * GVariantIter - */ -/* todo fix bugs -// VariantIter is a representation of GLib's GVariantIter. -type VariantIter struct { - GVariantIter *C.GVariantIter -} - -func (v *VariantIter) toGVariantIter() *C.GVariantIter { - if v == nil { - return nil - } - return v.native() -} - -func (v *VariantIter) toVariantIter() *VariantIter { - return v -} - -// newVariantIter creates a new VariantIter from a GVariantIter pointer. -func newVariantIter(p *C.GVariantIter) *VariantIter { - return &VariantIter{GVariantIter: p} -} - -// native returns a pointer to the underlying GVariantIter. -func (v *VariantIter) native() *C.GVariantIter { - if v == nil || v.GVariantIter == nil { - return nil - } - p := unsafe.Pointer(v.GVariantIter) - return C.toGVariantIter(p) -} - -// Native returns a pointer to the underlying GVariantIter. -func (v *VariantIter) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} -*/ diff --git a/vendor/github.com/gotk3/gotk3.old/glib/list.go b/vendor/github.com/gotk3/gotk3.old/glib/list.go deleted file mode 100644 index 2b7a0de..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/list.go +++ /dev/null @@ -1,156 +0,0 @@ -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include "glib.go.h" -import "C" -import "unsafe" - -/* - * Linked Lists - */ - -// List is a representation of Glib's GList. -type List struct { - list *C.struct__GList - // If set, dataWrap is called every time NthDataWrapped() - // or DataWrapped() is called to wrap raw underlying - // value into appropriate type. - dataWrap func(unsafe.Pointer) interface{} -} - -func WrapList(obj uintptr) *List { - return wrapList((*C.struct__GList)(unsafe.Pointer(obj))) -} - -func wrapList(obj *C.struct__GList) *List { - if obj == nil { - return nil - } - return &List{list: obj} -} - -func (v *List) wrapNewHead(obj *C.struct__GList) *List { - if obj == nil { - return nil - } - return &List{ - list: obj, - dataWrap: v.dataWrap, - } -} - -func (v *List) Native() uintptr { - return uintptr(unsafe.Pointer(v.list)) -} - -func (v *List) native() *C.struct__GList { - if v == nil || v.list == nil { - return nil - } - return v.list -} - -// DataWapper sets wrap functions, which is called during NthDataWrapped() -// and DataWrapped(). It's used to cast raw C data into appropriate -// Go structures and types every time that data is retreived. -func (v *List) DataWrapper(fn func(unsafe.Pointer) interface{}) { - if v == nil { - return - } - v.dataWrap = fn -} - -// Append is a wrapper around g_list_append(). -func (v *List) Append(data uintptr) *List { - glist := C.g_list_append(v.native(), C.gpointer(data)) - return v.wrapNewHead(glist) -} - -// Prepend is a wrapper around g_list_prepend(). -func (v *List) Prepend(data uintptr) *List { - glist := C.g_list_prepend(v.native(), C.gpointer(data)) - return v.wrapNewHead(glist) -} - -// Insert is a wrapper around g_list_insert(). -func (v *List) Insert(data uintptr, position int) *List { - glist := C.g_list_insert(v.native(), C.gpointer(data), C.gint(position)) - return v.wrapNewHead(glist) -} - -// Length is a wrapper around g_list_length(). -func (v *List) Length() uint { - return uint(C.g_list_length(v.native())) -} - -// nthDataRaw is a wrapper around g_list_nth_data(). -func (v *List) nthDataRaw(n uint) unsafe.Pointer { - return unsafe.Pointer(C.g_list_nth_data(v.native(), C.guint(n))) -} - -// Nth() is a wrapper around g_list_nth(). -func (v *List) Nth(n uint) *List { - list := wrapList(C.g_list_nth(v.native(), C.guint(n))) - list.DataWrapper(v.dataWrap) - return list -} - -// NthDataWrapped acts the same as g_list_nth_data(), but passes -// retrieved value before returning through wrap function, set by DataWrapper(). -// If no wrap function is set, it returns raw unsafe.Pointer. -func (v *List) NthData(n uint) interface{} { - ptr := v.nthDataRaw(n) - if v.dataWrap != nil { - return v.dataWrap(ptr) - } - return ptr -} - -// Free is a wrapper around g_list_free(). -func (v *List) Free() { - C.g_list_free(v.native()) -} - -// Next is a wrapper around the next struct field -func (v *List) Next() *List { - return v.wrapNewHead(v.native().next) -} - -// Previous is a wrapper around the prev struct field -func (v *List) Previous() *List { - return v.wrapNewHead(v.native().prev) -} - -// dataRaw is a wrapper around the data struct field -func (v *List) dataRaw() unsafe.Pointer { - return unsafe.Pointer(v.native().data) -} - -// DataWrapped acts the same as data struct field, but passes -// retrieved value before returning through wrap function, set by DataWrapper(). -// If no wrap function is set, it returns raw unsafe.Pointer. -func (v *List) Data() interface{} { - ptr := v.dataRaw() - if v.dataWrap != nil { - return v.dataWrap(ptr) - } - return ptr -} - -// Foreach acts the same as g_list_foreach(). -// No user_data arguement is implemented because of Go clojure capabilities. -func (v *List) Foreach(fn func(item interface{})) { - for l := v; l != nil; l = l.Next() { - fn(l.Data()) - } -} - -// FreeFull acts the same as g_list_free_full(). -// Calling list.FreeFull(fn) is equivalent to calling list.Foreach(fn) and -// list.Free() sequentially. -func (v *List) FreeFull(fn func(item interface{})) { - v.Foreach(fn) - v.Free() -} diff --git a/vendor/github.com/gotk3/gotk3.old/glib/menu.go b/vendor/github.com/gotk3/gotk3.old/glib/menu.go deleted file mode 100644 index b3b4cc8..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/menu.go +++ /dev/null @@ -1,333 +0,0 @@ -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include -// #include "glib.go.h" -import "C" -import "unsafe" - -// MenuModel is a representation of GMenuModel. -type MenuModel struct { - *Object -} - -// native() returns a pointer to the underlying GMenuModel. -func (v *MenuModel) native() *C.GMenuModel { - if v == nil || v.GObject == nil { - return nil - } - return C.toGMenuModel(unsafe.Pointer(v.GObject)) -} - -func (v *MenuModel) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalMenuModel(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapMenuModel(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapMenuModel(obj *Object) *MenuModel { - return &MenuModel{obj} -} - -// IsMutable is a wrapper around g_menu_model_is_mutable(). -func (v *MenuModel) IsMutable() bool { - return gobool(C.g_menu_model_is_mutable(v.native())) -} - -// GetNItems is a wrapper around g_menu_model_get_n_items(). -func (v *MenuModel) GetNItems() int { - return int(C.g_menu_model_get_n_items(v.native())) -} - -// GetItemLink is a wrapper around g_menu_model_get_item_link(). -func (v *MenuModel) GetItemLink(index int, link string) *MenuModel { - cstr := (*C.gchar)(C.CString(link)) - defer C.free(unsafe.Pointer(cstr)) - c := C.g_menu_model_get_item_link(v.native(), C.gint(index), cstr) - if c == nil { - return nil - } - return wrapMenuModel(wrapObject(unsafe.Pointer(c))) -} - -// ItemsChanged is a wrapper around g_menu_model_items_changed(). -func (v *MenuModel) ItemsChanged(position, removed, added int) { - C.g_menu_model_items_changed(v.native(), C.gint(position), C.gint(removed), C.gint(added)) -} - -// GVariant * g_menu_model_get_item_attribute_value () -// gboolean g_menu_model_get_item_attribute () -// GMenuAttributeIter * g_menu_model_iterate_item_attributes () -// GMenuLinkIter * g_menu_model_iterate_item_links () - -// Menu is a representation of GMenu. -type Menu struct { - MenuModel -} - -// native() returns a pointer to the underlying GMenu. -func (m *Menu) native() *C.GMenu { - if m == nil || m.GObject == nil { - return nil - } - p := unsafe.Pointer(m.GObject) - return C.toGMenu(p) -} - -func marshalMenu(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapMenu(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapMenu(obj *Object) *Menu { - return &Menu{MenuModel{obj}} -} - -// MenuNew is a wrapper around g_menu_new(). -func MenuNew() *Menu { - c := C.g_menu_new() - if c == nil { - return nil - } - return wrapMenu(wrapObject(unsafe.Pointer(c))) -} - -// Freeze is a wrapper around g_menu_freeze(). -func (v *Menu) Freeze() { - C.g_menu_freeze(v.native()) -} - -// Insert is a wrapper around g_menu_insert(). -func (v *Menu) Insert(position int, label, detailed_action string) { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - cstr2 := (*C.gchar)(C.CString(detailed_action)) - defer C.free(unsafe.Pointer(cstr2)) - - C.g_menu_insert(v.native(), C.gint(position), cstr1, cstr2) -} - -// Prepend is a wrapper around g_menu_prepend(). -func (v *Menu) Prepend(label, detailed_action string) { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - cstr2 := (*C.gchar)(C.CString(detailed_action)) - defer C.free(unsafe.Pointer(cstr2)) - - C.g_menu_prepend(v.native(), cstr1, cstr2) -} - -// Append is a wrapper around g_menu_append(). -func (v *Menu) Append(label, detailed_action string) { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - cstr2 := (*C.gchar)(C.CString(detailed_action)) - defer C.free(unsafe.Pointer(cstr2)) - - C.g_menu_append(v.native(), cstr1, cstr2) -} - -// InsertItem is a wrapper around g_menu_insert_item(). -func (v *Menu) InsertItem(position int, item *MenuItem) { - C.g_menu_insert_item(v.native(), C.gint(position), item.native()) -} - -// AppendItem is a wrapper around g_menu_append_item(). -func (v *Menu) AppendItem(item *MenuItem) { - C.g_menu_append_item(v.native(), item.native()) -} - -// PrependItem is a wrapper around g_menu_prepend_item(). -func (v *Menu) PrependItem(item *MenuItem) { - C.g_menu_prepend_item(v.native(), item.native()) -} - -// InsertSection is a wrapper around g_menu_insert_section(). -func (v *Menu) InsertSection(position int, label string, section *MenuModel) { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_menu_insert_section(v.native(), C.gint(position), cstr1, section.native()) -} - -// PrependSection is a wrapper around g_menu_prepend_section(). -func (v *Menu) PrependSection(label string, section *MenuModel) { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_menu_prepend_section(v.native(), cstr1, section.native()) -} - -// AppendSection is a wrapper around g_menu_append_section(). -func (v *Menu) AppendSection(label string, section *MenuModel) { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_menu_append_section(v.native(), cstr1, section.native()) -} - -// InsertSubmenu is a wrapper around g_menu_insert_submenu(). -func (v *Menu) InsertSubmenu(position int, label string, submenu *MenuModel) { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_menu_insert_submenu(v.native(), C.gint(position), cstr1, submenu.native()) -} - -// PrependSubmenu is a wrapper around g_menu_prepend_submenu(). -func (v *Menu) PrependSubmenu(label string, submenu *MenuModel) { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_menu_prepend_submenu(v.native(), cstr1, submenu.native()) -} - -// AppendSubmenu is a wrapper around g_menu_append_submenu(). -func (v *Menu) AppendSubmenu(label string, submenu *MenuModel) { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_menu_append_submenu(v.native(), cstr1, submenu.native()) -} - -// Remove is a wrapper around g_menu_remove(). -func (v *Menu) Remove(position int) { - C.g_menu_remove(v.native(), C.gint(position)) -} - -// RemoveAll is a wrapper around g_menu_remove_all(). -func (v *Menu) RemoveAll() { - C.g_menu_remove_all(v.native()) -} - -// MenuItem is a representation of GMenuItem. -type MenuItem struct { - *Object -} - -// native() returns a pointer to the underlying GMenuItem. -func (m *MenuItem) native() *C.GMenuItem { - if m == nil || m.GObject == nil { - return nil - } - p := unsafe.Pointer(m.GObject) - return C.toGMenuItem(p) -} - -func marshalMenuItem(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapMenuItem(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapMenuItem(obj *Object) *MenuItem { - return &MenuItem{obj} -} - -// MenuItemNew is a wrapper around g_menu_item_new(). -func MenuItemNew(label, detailed_action string) *MenuItem { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - cstr2 := (*C.gchar)(C.CString(detailed_action)) - defer C.free(unsafe.Pointer(cstr2)) - - c := C.g_menu_item_new(cstr1, cstr2) - if c == nil { - return nil - } - return wrapMenuItem(wrapObject(unsafe.Pointer(c))) -} - -// MenuItemNewSection is a wrapper around g_menu_item_new_section(). -func MenuItemNewSection(label string, section *MenuModel) *MenuItem { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - c := C.g_menu_item_new_section(cstr1, section.native()) - if c == nil { - return nil - } - return wrapMenuItem(wrapObject(unsafe.Pointer(c))) -} - -// MenuItemNewSubmenu is a wrapper around g_menu_item_new_submenu(). -func MenuItemNewSubmenu(label string, submenu *MenuModel) *MenuItem { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - c := C.g_menu_item_new_submenu(cstr1, submenu.native()) - if c == nil { - return nil - } - return wrapMenuItem(wrapObject(unsafe.Pointer(c))) -} - -// MenuItemNewFromModel is a wrapper around g_menu_item_new_from_model(). -func MenuItemNewFromModel(model *MenuModel, index int) *MenuItem { - c := C.g_menu_item_new_from_model(model.native(), C.gint(index)) - if c == nil { - return nil - } - return wrapMenuItem(wrapObject(unsafe.Pointer(c))) -} - -//SetLabel is a wrapper around g_menu_item_set_label(). -func (v *MenuItem) SetLabel(label string) { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_menu_item_set_label(v.native(), cstr1) -} - -//SetDetailedAction is a wrapper around g_menu_item_set_detailed_action(). -func (v *MenuItem) SetDetailedAction(act string) { - cstr1 := (*C.gchar)(C.CString(act)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_menu_item_set_detailed_action(v.native(), cstr1) -} - -//SetSection is a wrapper around g_menu_item_set_section(). -func (v *MenuItem) SetSection(section *MenuModel) { - C.g_menu_item_set_section(v.native(), section.native()) -} - -//SetSubmenu is a wrapper around g_menu_item_set_submenu(). -func (v *MenuItem) SetSubmenu(submenu *MenuModel) { - C.g_menu_item_set_submenu(v.native(), submenu.native()) -} - -//GetLink is a wrapper around g_menu_item_get_link(). -func (v *MenuItem) GetLink(link string) *MenuModel { - cstr1 := (*C.gchar)(C.CString(link)) - defer C.free(unsafe.Pointer(cstr1)) - - c := C.g_menu_item_get_link(v.native(), cstr1) - if c == nil { - return nil - } - return wrapMenuModel(wrapObject(unsafe.Pointer(c))) -} - -//SetLink is a wrapper around g_menu_item_Set_link(). -func (v *MenuItem) SetLink(link string, model *MenuModel) { - cstr1 := (*C.gchar)(C.CString(link)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_menu_item_set_link(v.native(), cstr1, model.native()) -} - -// void g_menu_item_set_action_and_target_value () -// void g_menu_item_set_action_and_target () -// GVariant * g_menu_item_get_attribute_value () -// gboolean g_menu_item_get_attribute () -// void g_menu_item_set_attribute_value () -// void g_menu_item_set_attribute () diff --git a/vendor/github.com/gotk3/gotk3.old/glib/notifications.go b/vendor/github.com/gotk3/gotk3.old/glib/notifications.go deleted file mode 100644 index 35ac322..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/notifications.go +++ /dev/null @@ -1,106 +0,0 @@ -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include -// #include "glib.go.h" -import "C" -import "unsafe" - -// Only available from 2.42 -// // NotificationPriority is a representation of GLib's GNotificationPriority. -// type NotificationPriority int - -// const ( -// NOTIFICATION_PRIORITY_NORMAL NotificationPriority = C.G_NOTIFICATION_PRIORITY_NORMAL -// NOTIFICATION_PRIORITY_LOW NotificationPriority = C.G_NOTIFICATION_PRIORITY_LOW -// NOTIFICATION_PRIORITY_HIGH NotificationPriority = C.G_NOTIFICATION_PRIORITY_HIGH -// NOTIFICATION_PRIORITY_URGENT NotificationPriority = C.G_NOTIFICATION_PRIORITY_URGENT -// ) - -// Notification is a representation of GNotification. -type Notification struct { - *Object -} - -// native() returns a pointer to the underlying GNotification. -func (v *Notification) native() *C.GNotification { - if v == nil || v.GObject == nil { - return nil - } - return C.toGNotification(unsafe.Pointer(v.GObject)) -} - -func (v *Notification) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalNotification(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapNotification(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapNotification(obj *Object) *Notification { - return &Notification{obj} -} - -// NotificationNew is a wrapper around g_notification_new(). -func NotificationNew(title string) *Notification { - cstr1 := (*C.gchar)(C.CString(title)) - defer C.free(unsafe.Pointer(cstr1)) - - c := C.g_notification_new(cstr1) - if c == nil { - return nil - } - return wrapNotification(wrapObject(unsafe.Pointer(c))) -} - -// SetTitle is a wrapper around g_notification_set_title(). -func (v *Notification) SetTitle(title string) { - cstr1 := (*C.gchar)(C.CString(title)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_notification_set_title(v.native(), cstr1) -} - -// SetBody is a wrapper around g_notification_set_body(). -func (v *Notification) SetBody(body string) { - cstr1 := (*C.gchar)(C.CString(body)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_notification_set_body(v.native(), cstr1) -} - -// Only available from 2.42 -// // SetPriority is a wrapper around g_notification_set_priority(). -// func (v *Notification) SetPriority(prio NotificationPriority) { -// C.g_notification_set_priority(v.native(), C.GNotificationPriority(prio)) -// } - -// SetDefaultAction is a wrapper around g_notification_set_default_action(). -func (v *Notification) SetDefaultAction(detailedAction string) { - cstr1 := (*C.gchar)(C.CString(detailedAction)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_notification_set_default_action(v.native(), cstr1) -} - -// AddButton is a wrapper around g_notification_add_button(). -func (v *Notification) AddButton(label, detailedAction string) { - cstr1 := (*C.gchar)(C.CString(label)) - defer C.free(unsafe.Pointer(cstr1)) - - cstr2 := (*C.gchar)(C.CString(detailedAction)) - defer C.free(unsafe.Pointer(cstr2)) - - C.g_notification_add_button(v.native(), cstr1, cstr2) -} - -// void g_notification_set_default_action_and_target () // requires varargs -// void g_notification_set_default_action_and_target_value () // requires variant -// void g_notification_add_button_with_target () // requires varargs -// void g_notification_add_button_with_target_value () //requires variant -// void g_notification_set_urgent () // Deprecated, so not implemented -// void g_notification_set_icon () // Requires support for GIcon, which we don't have yet. diff --git a/vendor/github.com/gotk3/gotk3.old/glib/settings.go b/vendor/github.com/gotk3/gotk3.old/glib/settings.go deleted file mode 100644 index 8cc68ee..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/settings.go +++ /dev/null @@ -1,277 +0,0 @@ -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include -// #include "glib.go.h" -import "C" -import "unsafe" - -// Settings is a representation of GSettings. -type Settings struct { - *Object -} - -// native() returns a pointer to the underlying GSettings. -func (v *Settings) native() *C.GSettings { - if v == nil || v.GObject == nil { - return nil - } - return C.toGSettings(unsafe.Pointer(v.GObject)) -} - -func (v *Settings) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalSettings(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapSettings(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapSettings(obj *Object) *Settings { - return &Settings{obj} -} - -func wrapFullSettings(obj *C.GSettings) *Settings { - if obj == nil { - return nil - } - return wrapSettings(wrapObject(unsafe.Pointer(obj))) -} - -// SettingsNew is a wrapper around g_settings_new(). -func SettingsNew(schemaID string) *Settings { - cstr := (*C.gchar)(C.CString(schemaID)) - defer C.free(unsafe.Pointer(cstr)) - - return wrapFullSettings(C.g_settings_new(cstr)) -} - -// SettingsNewWithPath is a wrapper around g_settings_new_with_path(). -func SettingsNewWithPath(schemaID, path string) *Settings { - cstr1 := (*C.gchar)(C.CString(schemaID)) - defer C.free(unsafe.Pointer(cstr1)) - - cstr2 := (*C.gchar)(C.CString(path)) - defer C.free(unsafe.Pointer(cstr2)) - - return wrapFullSettings(C.g_settings_new_with_path(cstr1, cstr2)) -} - -// SettingsNewWithBackend is a wrapper around g_settings_new_with_backend(). -func SettingsNewWithBackend(schemaID string, backend *SettingsBackend) *Settings { - cstr1 := (*C.gchar)(C.CString(schemaID)) - defer C.free(unsafe.Pointer(cstr1)) - - return wrapFullSettings(C.g_settings_new_with_backend(cstr1, backend.native())) -} - -// SettingsNewWithBackendAndPath is a wrapper around g_settings_new_with_backend_and_path(). -func SettingsNewWithBackendAndPath(schemaID string, backend *SettingsBackend, path string) *Settings { - cstr1 := (*C.gchar)(C.CString(schemaID)) - defer C.free(unsafe.Pointer(cstr1)) - - cstr2 := (*C.gchar)(C.CString(path)) - defer C.free(unsafe.Pointer(cstr2)) - - return wrapFullSettings(C.g_settings_new_with_backend_and_path(cstr1, backend.native(), cstr2)) -} - -// SettingsNewFull is a wrapper around g_settings_new_full(). -func SettingsNewFull(schema *SettingsSchema, backend *SettingsBackend, path string) *Settings { - cstr1 := (*C.gchar)(C.CString(path)) - defer C.free(unsafe.Pointer(cstr1)) - - return wrapFullSettings(C.g_settings_new_full(schema.native(), backend.native(), cstr1)) -} - -// SettingsSync is a wrapper around g_settings_sync(). -func SettingsSync() { - C.g_settings_sync() -} - -// IsWritable is a wrapper around g_settings_is_writable(). -func (v *Settings) IsWritable(name string) bool { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return gobool(C.g_settings_is_writable(v.native(), cstr1)) -} - -// Delay is a wrapper around g_settings_delay(). -func (v *Settings) Delay() { - C.g_settings_delay(v.native()) -} - -// Apply is a wrapper around g_settings_apply(). -func (v *Settings) Apply() { - C.g_settings_apply(v.native()) -} - -// Revert is a wrapper around g_settings_revert(). -func (v *Settings) Revert() { - C.g_settings_revert(v.native()) -} - -// GetHasUnapplied is a wrapper around g_settings_get_has_unapplied(). -func (v *Settings) GetHasUnapplied() bool { - return gobool(C.g_settings_get_has_unapplied(v.native())) -} - -// GetChild is a wrapper around g_settings_get_child(). -func (v *Settings) GetChild(name string) *Settings { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return wrapFullSettings(C.g_settings_get_child(v.native(), cstr1)) -} - -// Reset is a wrapper around g_settings_reset(). -func (v *Settings) Reset(name string) { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - C.g_settings_reset(v.native(), cstr1) -} - -// ListChildren is a wrapper around g_settings_list_children(). -func (v *Settings) ListChildren() []string { - return toGoStringArray(C.g_settings_list_children(v.native())) -} - -// GetBoolean is a wrapper around g_settings_get_boolean(). -func (v *Settings) GetBoolean(name string) bool { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return gobool(C.g_settings_get_boolean(v.native(), cstr1)) -} - -// SetBoolean is a wrapper around g_settings_set_boolean(). -func (v *Settings) SetBoolean(name string, value bool) bool { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return gobool(C.g_settings_set_boolean(v.native(), cstr1, gbool(value))) -} - -// GetInt is a wrapper around g_settings_get_int(). -func (v *Settings) GetInt(name string) int { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return int(C.g_settings_get_int(v.native(), cstr1)) -} - -// SetInt is a wrapper around g_settings_set_int(). -func (v *Settings) SetInt(name string, value int) bool { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return gobool(C.g_settings_set_int(v.native(), cstr1, C.gint(value))) -} - -// GetUInt is a wrapper around g_settings_get_uint(). -func (v *Settings) GetUInt(name string) uint { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return uint(C.g_settings_get_uint(v.native(), cstr1)) -} - -// SetUInt is a wrapper around g_settings_set_uint(). -func (v *Settings) SetUInt(name string, value uint) bool { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return gobool(C.g_settings_set_uint(v.native(), cstr1, C.guint(value))) -} - -// GetDouble is a wrapper around g_settings_get_double(). -func (v *Settings) GetDouble(name string) float64 { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return float64(C.g_settings_get_double(v.native(), cstr1)) -} - -// SetDouble is a wrapper around g_settings_set_double(). -func (v *Settings) SetDouble(name string, value float64) bool { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return gobool(C.g_settings_set_double(v.native(), cstr1, C.gdouble(value))) -} - -// GetString is a wrapper around g_settings_get_string(). -func (v *Settings) GetString(name string) string { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return C.GoString((*C.char)(C.g_settings_get_string(v.native(), cstr1))) -} - -// SetString is a wrapper around g_settings_set_string(). -func (v *Settings) SetString(name string, value string) bool { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - cstr2 := (*C.gchar)(C.CString(value)) - defer C.free(unsafe.Pointer(cstr2)) - - return gobool(C.g_settings_set_string(v.native(), cstr1, cstr2)) -} - -// GetEnum is a wrapper around g_settings_get_enum(). -func (v *Settings) GetEnum(name string) int { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return int(C.g_settings_get_enum(v.native(), cstr1)) -} - -// SetEnum is a wrapper around g_settings_set_enum(). -func (v *Settings) SetEnum(name string, value int) bool { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return gobool(C.g_settings_set_enum(v.native(), cstr1, C.gint(value))) -} - -// GetFlags is a wrapper around g_settings_get_flags(). -func (v *Settings) GetFlags(name string) uint { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return uint(C.g_settings_get_flags(v.native(), cstr1)) -} - -// SetFlags is a wrapper around g_settings_set_flags(). -func (v *Settings) SetFlags(name string, value uint) bool { - cstr1 := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr1)) - - return gobool(C.g_settings_set_flags(v.native(), cstr1, C.guint(value))) -} - -// GVariant * g_settings_get_value () -// gboolean g_settings_set_value () -// GVariant * g_settings_get_user_value () -// GVariant * g_settings_get_default_value () -// const gchar * const * g_settings_list_schemas () -// const gchar * const * g_settings_list_relocatable_schemas () -// gchar ** g_settings_list_keys () -// GVariant * g_settings_get_range () -// gboolean g_settings_range_check () -// void g_settings_get () -// gboolean g_settings_set () -// gpointer g_settings_get_mapped () -// void g_settings_bind () -// void g_settings_bind_with_mapping () -// void g_settings_bind_writable () -// void g_settings_unbind () -// gaction * g_settings_create_action () -// gchar ** g_settings_get_strv () -// gboolean g_settings_set_strv () diff --git a/vendor/github.com/gotk3/gotk3.old/glib/settings_backend.go b/vendor/github.com/gotk3/gotk3.old/glib/settings_backend.go deleted file mode 100644 index d988f3e..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/settings_backend.go +++ /dev/null @@ -1,71 +0,0 @@ -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include "glib.go.h" -import "C" -import "unsafe" - -// SettingsBackend is a representation of GSettingsBackend. -type SettingsBackend struct { - *Object -} - -// native() returns a pointer to the underlying GSettingsBackend. -func (v *SettingsBackend) native() *C.GSettingsBackend { - if v == nil || v.GObject == nil { - return nil - } - return C.toGSettingsBackend(unsafe.Pointer(v.GObject)) -} - -func (v *SettingsBackend) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func marshalSettingsBackend(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapSettingsBackend(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapSettingsBackend(obj *Object) *SettingsBackend { - return &SettingsBackend{obj} -} - -// SettingsBackendGetDefault is a wrapper around g_settings_backend_get_default(). -func SettingsBackendGetDefault() *SettingsBackend { - return wrapSettingsBackend(wrapObject(unsafe.Pointer(C.g_settings_backend_get_default()))) -} - -// KeyfileSettingsBackendNew is a wrapper around g_keyfile_settings_backend_new(). -func KeyfileSettingsBackendNew(filename, rootPath, rootGroup string) *SettingsBackend { - cstr1 := (*C.gchar)(C.CString(filename)) - defer C.free(unsafe.Pointer(cstr1)) - - cstr2 := (*C.gchar)(C.CString(rootPath)) - defer C.free(unsafe.Pointer(cstr2)) - - cstr3 := (*C.gchar)(C.CString(rootGroup)) - defer C.free(unsafe.Pointer(cstr3)) - - return wrapSettingsBackend(wrapObject(unsafe.Pointer(C.g_keyfile_settings_backend_new(cstr1, cstr2, cstr3)))) -} - -// MemorySettingsBackendNew is a wrapper around g_memory_settings_backend_new(). -func MemorySettingsBackendNew() *SettingsBackend { - return wrapSettingsBackend(wrapObject(unsafe.Pointer(C.g_memory_settings_backend_new()))) -} - -// NullSettingsBackendNew is a wrapper around g_null_settings_backend_new(). -func NullSettingsBackendNew() *SettingsBackend { - return wrapSettingsBackend(wrapObject(unsafe.Pointer(C.g_null_settings_backend_new()))) -} - -// void g_settings_backend_changed () -// void g_settings_backend_path_changed () -// void g_settings_backend_keys_changed () -// void g_settings_backend_path_writable_changed () -// void g_settings_backend_writable_changed () -// void g_settings_backend_changed_tree () -// void g_settings_backend_flatten_tree () diff --git a/vendor/github.com/gotk3/gotk3.old/glib/settings_schema.go b/vendor/github.com/gotk3/gotk3.old/glib/settings_schema.go deleted file mode 100644 index dfb17b0..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/settings_schema.go +++ /dev/null @@ -1,96 +0,0 @@ -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include -// #include "glib.go.h" -import "C" -import "unsafe" - -// SettingsSchema is a representation of GSettingsSchema. -type SettingsSchema struct { - schema *C.GSettingsSchema -} - -func wrapSettingsSchema(obj *C.GSettingsSchema) *SettingsSchema { - if obj == nil { - return nil - } - return &SettingsSchema{obj} -} - -func (v *SettingsSchema) Native() uintptr { - return uintptr(unsafe.Pointer(v.schema)) -} - -func (v *SettingsSchema) native() *C.GSettingsSchema { - if v == nil || v.schema == nil { - return nil - } - return v.schema -} - -// Ref() is a wrapper around g_settings_schema_ref(). -func (v *SettingsSchema) Ref() *SettingsSchema { - return wrapSettingsSchema(C.g_settings_schema_ref(v.native())) -} - -// Unref() is a wrapper around g_settings_schema_unref(). -func (v *SettingsSchema) Unref() { - C.g_settings_schema_unref(v.native()) -} - -// GetID() is a wrapper around g_settings_schema_get_id(). -func (v *SettingsSchema) GetID() string { - return C.GoString((*C.char)(C.g_settings_schema_get_id(v.native()))) -} - -// GetPath() is a wrapper around g_settings_schema_get_path(). -func (v *SettingsSchema) GetPath() string { - return C.GoString((*C.char)(C.g_settings_schema_get_path(v.native()))) -} - -// HasKey() is a wrapper around g_settings_schema_has_key(). -func (v *SettingsSchema) HasKey(v1 string) bool { - cstr := (*C.gchar)(C.CString(v1)) - defer C.free(unsafe.Pointer(cstr)) - - return gobool(C.g_settings_schema_has_key(v.native(), cstr)) -} - -func toGoStringArray(c **C.gchar) []string { - var strs []string - originalc := c - defer C.g_strfreev(originalc) - - for *c != nil { - strs = append(strs, C.GoString((*C.char)(*c))) - c = C.next_gcharptr(c) - } - - return strs - -} - -// // ListChildren() is a wrapper around g_settings_schema_list_children(). -// func (v *SettingsSchema) ListChildren() []string { -// return toGoStringArray(C.g_settings_schema_list_children(v.native())) -// } - -// // ListKeys() is a wrapper around g_settings_schema_list_keys(). -// func (v *SettingsSchema) ListKeys() []string { -// return toGoStringArray(C.g_settings_schema_list_keys(v.native())) -// } - -// const GVariantType * g_settings_schema_key_get_value_type () -// GVariant * g_settings_schema_key_get_default_value () -// GVariant * g_settings_schema_key_get_range () -// gboolean g_settings_schema_key_range_check () -// const gchar * g_settings_schema_key_get_name () -// const gchar * g_settings_schema_key_get_summary () -// const gchar * g_settings_schema_key_get_description () - -// GSettingsSchemaKey * g_settings_schema_get_key () -// GSettingsSchemaKey * g_settings_schema_key_ref () -// void g_settings_schema_key_unref () diff --git a/vendor/github.com/gotk3/gotk3.old/glib/settings_schema_source.go b/vendor/github.com/gotk3/gotk3.old/glib/settings_schema_source.go deleted file mode 100644 index 43286a1..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/settings_schema_source.go +++ /dev/null @@ -1,70 +0,0 @@ -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include -// #include "glib.go.h" -import "C" -import "unsafe" - -// SettingsSchemaSource is a representation of GSettingsSchemaSource. -type SettingsSchemaSource struct { - source *C.GSettingsSchemaSource -} - -func wrapSettingsSchemaSource(obj *C.GSettingsSchemaSource) *SettingsSchemaSource { - if obj == nil { - return nil - } - return &SettingsSchemaSource{obj} -} - -func (v *SettingsSchemaSource) Native() uintptr { - return uintptr(unsafe.Pointer(v.source)) -} - -func (v *SettingsSchemaSource) native() *C.GSettingsSchemaSource { - if v == nil || v.source == nil { - return nil - } - return v.source -} - -// SettingsSchemaSourceGetDefault is a wrapper around g_settings_schema_source_get_default(). -func SettingsSchemaSourceGetDefault() *SettingsSchemaSource { - return wrapSettingsSchemaSource(C.g_settings_schema_source_get_default()) -} - -// Ref() is a wrapper around g_settings_schema_source_ref(). -func (v *SettingsSchemaSource) Ref() *SettingsSchemaSource { - return wrapSettingsSchemaSource(C.g_settings_schema_source_ref(v.native())) -} - -// Unref() is a wrapper around g_settings_schema_source_unref(). -func (v *SettingsSchemaSource) Unref() { - C.g_settings_schema_source_unref(v.native()) -} - -// SettingsSchemaSourceNewFromDirectory() is a wrapper around g_settings_schema_source_new_from_directory(). -func SettingsSchemaSourceNewFromDirectory(dir string, parent *SettingsSchemaSource, trusted bool) *SettingsSchemaSource { - cstr := (*C.gchar)(C.CString(dir)) - defer C.free(unsafe.Pointer(cstr)) - - return wrapSettingsSchemaSource(C.g_settings_schema_source_new_from_directory(cstr, parent.native(), gbool(trusted), nil)) -} - -// Lookup() is a wrapper around g_settings_schema_source_lookup(). -func (v *SettingsSchemaSource) Lookup(schema string, recursive bool) *SettingsSchema { - cstr := (*C.gchar)(C.CString(schema)) - defer C.free(unsafe.Pointer(cstr)) - - return wrapSettingsSchema(C.g_settings_schema_source_lookup(v.native(), cstr, gbool(recursive))) -} - -// ListSchemas is a wrapper around g_settings_schema_source_list_schemas(). -func (v *SettingsSchemaSource) ListSchemas(recursive bool) (nonReolcatable, relocatable []string) { - var nonRel, rel **C.gchar - C.g_settings_schema_source_list_schemas(v.native(), gbool(recursive), &nonRel, &rel) - return toGoStringArray(nonRel), toGoStringArray(rel) -} diff --git a/vendor/github.com/gotk3/gotk3.old/glib/slist.go b/vendor/github.com/gotk3/gotk3.old/glib/slist.go deleted file mode 100644 index 66ab8f2..0000000 --- a/vendor/github.com/gotk3/gotk3.old/glib/slist.go +++ /dev/null @@ -1,71 +0,0 @@ -package glib - -// #cgo pkg-config: glib-2.0 gobject-2.0 -// #include -// #include -// #include "glib.go.h" -import "C" -import "unsafe" - -// SList is a representation of Glib's GSList. -type SList struct { - list *C.struct__GSList -} - -func WrapSList(obj uintptr) *SList { - return wrapSList((*C.struct__GSList)(unsafe.Pointer(obj))) -} - -func wrapSList(obj *C.struct__GSList) *SList { - return &SList{obj} -} - -func (v *SList) Native() uintptr { - return uintptr(unsafe.Pointer(v.list)) -} - -func (v *SList) native() *C.struct__GSList { - if v == nil || v.list == nil { - return nil - } - return v.list -} - -func (v *SList) Append(data uintptr) *SList { - ret := C.g_slist_append(v.native(), C.gpointer(data)) - if ret == v.native() { - return v - } else { - return wrapSList(ret) - } -} - -// GSList * g_slist_alloc () -// GSList * g_slist_prepend () -// GSList * g_slist_insert () -// GSList * g_slist_insert_before () -// GSList * g_slist_insert_sorted () -// GSList * g_slist_remove () -// GSList * g_slist_remove_link () -// GSList * g_slist_delete_link () -// GSList * g_slist_remove_all () -// void g_slist_free () -// void g_slist_free_full () -// void g_slist_free_1 () -// guint g_slist_length () -// GSList * g_slist_copy () -// GSList * g_slist_copy_deep () -// GSList * g_slist_reverse () -// GSList * g_slist_insert_sorted_with_data () -// GSList * g_slist_sort () -// GSList * g_slist_sort_with_data () -// GSList * g_slist_concat () -// void g_slist_foreach () -// GSList * g_slist_last () -// #define g_slist_next() -// GSList * g_slist_nth () -// gpointer g_slist_nth_data () -// GSList * g_slist_find () -// GSList * g_slist_find_custom () -// gint g_slist_position () -// gint g_slist_index () diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/aboutdialog.go b/vendor/github.com/gotk3/gotk3.old/gtk/aboutdialog.go deleted file mode 100644 index a648fed..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/aboutdialog.go +++ /dev/null @@ -1,313 +0,0 @@ -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/gdk" - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - {glib.Type(C.gtk_about_dialog_get_type()), marshalAboutDialog}, - } - - glib.RegisterGValueMarshalers(tm) - - WrapMap["GtkAboutDialog"] = wrapAboutDialog -} - -/* - * GtkAboutDialog - */ - -// AboutDialog is a representation of GTK's GtkAboutDialog. -type AboutDialog struct { - Dialog -} - -// native returns a pointer to the underlying GtkAboutDialog. -func (v *AboutDialog) native() *C.GtkAboutDialog { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkAboutDialog(p) -} - -func marshalAboutDialog(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapAboutDialog(obj), nil -} - -func wrapAboutDialog(obj *glib.Object) *AboutDialog { - return &AboutDialog{Dialog{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}}} -} - -// AboutDialogNew is a wrapper around gtk_about_dialog_new(). -func AboutDialogNew() (*AboutDialog, error) { - c := C.gtk_about_dialog_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapAboutDialog(obj), nil -} - -// GetComments is a wrapper around gtk_about_dialog_get_comments(). -func (v *AboutDialog) GetComments() string { - c := C.gtk_about_dialog_get_comments(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetComments is a wrapper around gtk_about_dialog_set_comments(). -func (v *AboutDialog) SetComments(comments string) { - cstr := C.CString(comments) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_about_dialog_set_comments(v.native(), (*C.gchar)(cstr)) -} - -// GetCopyright is a wrapper around gtk_about_dialog_get_copyright(). -func (v *AboutDialog) GetCopyright() string { - c := C.gtk_about_dialog_get_copyright(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetCopyright is a wrapper around gtk_about_dialog_set_copyright(). -func (v *AboutDialog) SetCopyright(copyright string) { - cstr := C.CString(copyright) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_about_dialog_set_copyright(v.native(), (*C.gchar)(cstr)) -} - -// GetLicense is a wrapper around gtk_about_dialog_get_license(). -func (v *AboutDialog) GetLicense() string { - c := C.gtk_about_dialog_get_license(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetLicense is a wrapper around gtk_about_dialog_set_license(). -func (v *AboutDialog) SetLicense(license string) { - cstr := C.CString(license) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_about_dialog_set_license(v.native(), (*C.gchar)(cstr)) -} - -// GetLicenseType is a wrapper around gtk_about_dialog_get_license_type(). -func (v *AboutDialog) GetLicenseType() License { - c := C.gtk_about_dialog_get_license_type(v.native()) - return License(c) -} - -// SetLicenseType is a wrapper around gtk_about_dialog_set_license_type(). -func (v *AboutDialog) SetLicenseType(license License) { - C.gtk_about_dialog_set_license_type(v.native(), C.GtkLicense(license)) -} - -// SetLogo is a wrapper around gtk_about_dialog_set_logo(). -func (v *AboutDialog) SetLogo(logo *gdk.Pixbuf) { - logoPtr := (*C.GdkPixbuf)(unsafe.Pointer(logo.Native())) - C.gtk_about_dialog_set_logo(v.native(), logoPtr) -} - -// GetLogoIconName is a wrapper around gtk_about_dialog_get_logo_icon_name(). -func (v *AboutDialog) GetLogoIconName() string { - c := C.gtk_about_dialog_get_logo_icon_name(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetLogoIconName is a wrapper around gtk_about_dialog_set_logo_icon_name(). -func (v *AboutDialog) SetLogoIconName(name string) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_about_dialog_set_logo_icon_name(v.native(), (*C.gchar)(cstr)) -} - -// GetProgramName is a wrapper around gtk_about_dialog_get_program_name(). -func (v *AboutDialog) GetProgramName() string { - c := C.gtk_about_dialog_get_program_name(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetProgramName is a wrapper around gtk_about_dialog_set_program_name(). -func (v *AboutDialog) SetProgramName(name string) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_about_dialog_set_program_name(v.native(), (*C.gchar)(cstr)) -} - -// GetAuthors is a wrapper around gtk_about_dialog_get_authors(). -func (v *AboutDialog) GetAuthors() []string { - var authors []string - cauthors := C.gtk_about_dialog_get_authors(v.native()) - if cauthors == nil { - return nil - } - for { - if *cauthors == nil { - break - } - authors = append(authors, C.GoString((*C.char)(*cauthors))) - cauthors = C.next_gcharptr(cauthors) - } - return authors -} - -// SetAuthors is a wrapper around gtk_about_dialog_set_authors(). -func (v *AboutDialog) SetAuthors(authors []string) { - cauthors := C.make_strings(C.int(len(authors) + 1)) - for i, author := range authors { - cstr := C.CString(author) - defer C.free(unsafe.Pointer(cstr)) - C.set_string(cauthors, C.int(i), (*C.gchar)(cstr)) - } - - C.set_string(cauthors, C.int(len(authors)), nil) - C.gtk_about_dialog_set_authors(v.native(), cauthors) - C.destroy_strings(cauthors) -} - -// GetArtists is a wrapper around gtk_about_dialog_get_artists(). -func (v *AboutDialog) GetArtists() []string { - var artists []string - cartists := C.gtk_about_dialog_get_artists(v.native()) - if cartists == nil { - return nil - } - for { - if *cartists == nil { - break - } - artists = append(artists, C.GoString((*C.char)(*cartists))) - cartists = C.next_gcharptr(cartists) - } - return artists -} - -// SetArtists is a wrapper around gtk_about_dialog_set_artists(). -func (v *AboutDialog) SetArtists(artists []string) { - cartists := C.make_strings(C.int(len(artists) + 1)) - for i, artist := range artists { - cstr := C.CString(artist) - defer C.free(unsafe.Pointer(cstr)) - C.set_string(cartists, C.int(i), (*C.gchar)(cstr)) - } - - C.set_string(cartists, C.int(len(artists)), nil) - C.gtk_about_dialog_set_artists(v.native(), cartists) - C.destroy_strings(cartists) -} - -// GetDocumenters is a wrapper around gtk_about_dialog_get_documenters(). -func (v *AboutDialog) GetDocumenters() []string { - var documenters []string - cdocumenters := C.gtk_about_dialog_get_documenters(v.native()) - if cdocumenters == nil { - return nil - } - for { - if *cdocumenters == nil { - break - } - documenters = append(documenters, C.GoString((*C.char)(*cdocumenters))) - cdocumenters = C.next_gcharptr(cdocumenters) - } - return documenters -} - -// SetDocumenters is a wrapper around gtk_about_dialog_set_documenters(). -func (v *AboutDialog) SetDocumenters(documenters []string) { - cdocumenters := C.make_strings(C.int(len(documenters) + 1)) - for i, doc := range documenters { - cstr := C.CString(doc) - defer C.free(unsafe.Pointer(cstr)) - C.set_string(cdocumenters, C.int(i), (*C.gchar)(cstr)) - } - - C.set_string(cdocumenters, C.int(len(documenters)), nil) - C.gtk_about_dialog_set_documenters(v.native(), cdocumenters) - C.destroy_strings(cdocumenters) -} - -// GetTranslatorCredits is a wrapper around gtk_about_dialog_get_translator_credits(). -func (v *AboutDialog) GetTranslatorCredits() string { - c := C.gtk_about_dialog_get_translator_credits(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetTranslatorCredits is a wrapper around gtk_about_dialog_set_translator_credits(). -func (v *AboutDialog) SetTranslatorCredits(translatorCredits string) { - cstr := C.CString(translatorCredits) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_about_dialog_set_translator_credits(v.native(), (*C.gchar)(cstr)) -} - -// GetVersion is a wrapper around gtk_about_dialog_get_version(). -func (v *AboutDialog) GetVersion() string { - c := C.gtk_about_dialog_get_version(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetVersion is a wrapper around gtk_about_dialog_set_version(). -func (v *AboutDialog) SetVersion(version string) { - cstr := C.CString(version) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_about_dialog_set_version(v.native(), (*C.gchar)(cstr)) -} - -// GetWebsite is a wrapper around gtk_about_dialog_get_website(). -func (v *AboutDialog) GetWebsite() string { - c := C.gtk_about_dialog_get_website(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetWebsite is a wrapper around gtk_about_dialog_set_website(). -func (v *AboutDialog) SetWebsite(website string) { - cstr := C.CString(website) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_about_dialog_set_website(v.native(), (*C.gchar)(cstr)) -} - -// GetWebsiteLabel is a wrapper around gtk_about_dialog_get_website_label(). -func (v *AboutDialog) GetWebsiteLabel() string { - c := C.gtk_about_dialog_get_website_label(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetWebsiteLabel is a wrapper around gtk_about_dialog_set_website_label(). -func (v *AboutDialog) SetWebsiteLabel(websiteLabel string) { - cstr := C.CString(websiteLabel) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_about_dialog_set_website_label(v.native(), (*C.gchar)(cstr)) -} - -// GetWrapLicense is a wrapper around gtk_about_dialog_get_wrap_license(). -func (v *AboutDialog) GetWrapLicense() bool { - return gobool(C.gtk_about_dialog_get_wrap_license(v.native())) -} - -// SetWrapLicense is a wrapper around gtk_about_dialog_set_wrap_license(). -func (v *AboutDialog) SetWrapLicense(wrapLicense bool) { - C.gtk_about_dialog_set_wrap_license(v.native(), gbool(wrapLicense)) -} - -// AddCreditSection is a wrapper around gtk_about_dialog_add_credit_section(). -func (v *AboutDialog) AddCreditSection(sectionName string, people []string) { - cname := (*C.gchar)(C.CString(sectionName)) - defer C.free(unsafe.Pointer(cname)) - - cpeople := C.make_strings(C.int(len(people)) + 1) - defer C.destroy_strings(cpeople) - for i, p := range people { - cp := (*C.gchar)(C.CString(p)) - defer C.free(unsafe.Pointer(cp)) - C.set_string(cpeople, C.int(i), cp) - } - C.set_string(cpeople, C.int(len(people)), nil) - - C.gtk_about_dialog_add_credit_section(v.native(), cname, cpeople) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/accel.go b/vendor/github.com/gotk3/gotk3.old/gtk/accel.go deleted file mode 100644 index cbd138d..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/accel.go +++ /dev/null @@ -1,435 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains accelerator related functions and structures - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/gdk" - "github.com/gotk3/gotk3/glib" -) - -// AccelFlags is a representation of GTK's GtkAccelFlags -type AccelFlags int - -const ( - ACCEL_VISIBLE AccelFlags = C.GTK_ACCEL_VISIBLE - ACCEL_LOCKED AccelFlags = C.GTK_ACCEL_LOCKED - ACCEL_MASK AccelFlags = C.GTK_ACCEL_MASK -) - -func marshalAccelFlags(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return AccelFlags(c), nil -} - -// AcceleratorName is a wrapper around gtk_accelerator_name(). -func AcceleratorName(key uint, mods gdk.ModifierType) string { - c := C.gtk_accelerator_name(C.guint(key), C.GdkModifierType(mods)) - defer C.free(unsafe.Pointer(c)) - return C.GoString((*C.char)(c)) -} - -// AcceleratorValid is a wrapper around gtk_accelerator_valid(). -func AcceleratorValid(key uint, mods gdk.ModifierType) bool { - return gobool(C.gtk_accelerator_valid(C.guint(key), C.GdkModifierType(mods))) -} - -// AcceleratorGetDefaultModMask is a wrapper around gtk_accelerator_get_default_mod_mask(). -func AcceleratorGetDefaultModMask() gdk.ModifierType { - return gdk.ModifierType(C.gtk_accelerator_get_default_mod_mask()) -} - -// AcceleratorParse is a wrapper around gtk_accelerator_parse(). -func AcceleratorParse(acc string) (key uint, mods gdk.ModifierType) { - cstr := C.CString(acc) - defer C.free(unsafe.Pointer(cstr)) - - k := C.guint(0) - m := C.GdkModifierType(0) - - C.gtk_accelerator_parse((*C.gchar)(cstr), &k, &m) - return uint(k), gdk.ModifierType(m) -} - -// AcceleratorGetLabel is a wrapper around gtk_accelerator_get_label(). -func AcceleratorGetLabel(key uint, mods gdk.ModifierType) string { - c := C.gtk_accelerator_get_label(C.guint(key), C.GdkModifierType(mods)) - defer C.free(unsafe.Pointer(c)) - return C.GoString((*C.char)(c)) -} - -// AcceleratorSetDefaultModMask is a wrapper around gtk_accelerator_set_default_mod_mask(). -func AcceleratorSetDefaultModMask(mods gdk.ModifierType) { - C.gtk_accelerator_set_default_mod_mask(C.GdkModifierType(mods)) -} - -/* - * GtkAccelGroup - */ - -// AccelGroup is a representation of GTK's GtkAccelGroup. -type AccelGroup struct { - *glib.Object -} - -// native returns a pointer to the underlying GtkAccelGroup. -func (v *AccelGroup) native() *C.GtkAccelGroup { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkAccelGroup(p) -} - -func marshalAccelGroup(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapAccelGroup(obj), nil -} - -func wrapAccelGroup(obj *glib.Object) *AccelGroup { - return &AccelGroup{obj} -} - -// AccelGroup is a wrapper around gtk_accel_group_new(). -func AccelGroupNew() (*AccelGroup, error) { - c := C.gtk_accel_group_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapAccelGroup(obj), nil -} - -// Connect is a wrapper around gtk_accel_group_connect(). -func (v *AccelGroup) Connect(key uint, mods gdk.ModifierType, flags AccelFlags, f interface{}) { - closure, _ := glib.ClosureNew(f) - cl := (*C.struct__GClosure)(unsafe.Pointer(closure)) - C.gtk_accel_group_connect( - v.native(), - C.guint(key), - C.GdkModifierType(mods), - C.GtkAccelFlags(flags), - cl) -} - -// ConnectByPath is a wrapper around gtk_accel_group_connect_by_path(). -func (v *AccelGroup) ConnectByPath(path string, f interface{}) { - closure, _ := glib.ClosureNew(f) - cl := (*C.struct__GClosure)(unsafe.Pointer(closure)) - - cstr := C.CString(path) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_accel_group_connect_by_path( - v.native(), - (*C.gchar)(cstr), - cl) -} - -// Disconnect is a wrapper around gtk_accel_group_disconnect(). -func (v *AccelGroup) Disconnect(f interface{}) { - closure, _ := glib.ClosureNew(f) - cl := (*C.struct__GClosure)(unsafe.Pointer(closure)) - C.gtk_accel_group_disconnect(v.native(), cl) -} - -// DisconnectKey is a wrapper around gtk_accel_group_disconnect_key(). -func (v *AccelGroup) DisconnectKey(key uint, mods gdk.ModifierType) { - C.gtk_accel_group_disconnect_key(v.native(), C.guint(key), C.GdkModifierType(mods)) -} - -// Lock is a wrapper around gtk_accel_group_lock(). -func (v *AccelGroup) Lock() { - C.gtk_accel_group_lock(v.native()) -} - -// Unlock is a wrapper around gtk_accel_group_unlock(). -func (v *AccelGroup) Unlock() { - C.gtk_accel_group_unlock(v.native()) -} - -// IsLocked is a wrapper around gtk_accel_group_get_is_locked(). -func (v *AccelGroup) IsLocked() bool { - return gobool(C.gtk_accel_group_get_is_locked(v.native())) -} - -// AccelGroupFromClosure is a wrapper around gtk_accel_group_from_accel_closure(). -func AccelGroupFromClosure(f interface{}) *AccelGroup { - closure, _ := glib.ClosureNew(f) - cl := (*C.struct__GClosure)(unsafe.Pointer(closure)) - c := C.gtk_accel_group_from_accel_closure(cl) - if c == nil { - return nil - } - return wrapAccelGroup(wrapObject(unsafe.Pointer(c))) -} - -// GetModifierMask is a wrapper around gtk_accel_group_get_modifier_mask(). -func (v *AccelGroup) GetModifierMask() gdk.ModifierType { - return gdk.ModifierType(C.gtk_accel_group_get_modifier_mask(v.native())) -} - -// AccelGroupsActivate is a wrapper around gtk_accel_groups_activate(). -func AccelGroupsActivate(obj *glib.Object, key uint, mods gdk.ModifierType) bool { - return gobool(C.gtk_accel_groups_activate((*C.GObject)(unsafe.Pointer(obj.Native())), C.guint(key), C.GdkModifierType(mods))) -} - -// Activate is a wrapper around gtk_accel_group_activate(). -func (v *AccelGroup) Activate(quark glib.Quark, acceleratable *glib.Object, key uint, mods gdk.ModifierType) bool { - return gobool(C.gtk_accel_group_activate(v.native(), C.GQuark(quark), (*C.GObject)(unsafe.Pointer(acceleratable.Native())), C.guint(key), C.GdkModifierType(mods))) -} - -// AccelGroupsFromObject is a wrapper around gtk_accel_groups_from_object(). -func AccelGroupsFromObject(obj *glib.Object) *glib.SList { - res := C.gtk_accel_groups_from_object((*C.GObject)(unsafe.Pointer(obj.Native()))) - if res == nil { - return nil - } - return (*glib.SList)(unsafe.Pointer(res)) -} - -/* - * GtkAccelMap - */ - -// AccelMap is a representation of GTK's GtkAccelMap. -type AccelMap struct { - *glib.Object -} - -// native returns a pointer to the underlying GtkAccelMap. -func (v *AccelMap) native() *C.GtkAccelMap { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkAccelMap(p) -} - -func marshalAccelMap(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapAccelMap(obj), nil -} - -func wrapAccelMap(obj *glib.Object) *AccelMap { - return &AccelMap{obj} -} - -// AccelMapAddEntry is a wrapper around gtk_accel_map_add_entry(). -func AccelMapAddEntry(path string, key uint, mods gdk.ModifierType) { - cstr := C.CString(path) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_accel_map_add_entry((*C.gchar)(cstr), C.guint(key), C.GdkModifierType(mods)) -} - -type AccelKey struct { - key uint - mods gdk.ModifierType - flags uint16 -} - -func (v *AccelKey) native() *C.struct__GtkAccelKey { - if v == nil { - return nil - } - - var val C.struct__GtkAccelKey - val.accel_key = C.guint(v.key) - val.accel_mods = C.GdkModifierType(v.mods) - val.accel_flags = v.flags - return &val -} - -func wrapAccelKey(obj *C.struct__GtkAccelKey) *AccelKey { - var v AccelKey - - v.key = uint(obj.accel_key) - v.mods = gdk.ModifierType(obj.accel_mods) - v.flags = uint16(obj.accel_flags) - - return &v -} - -// AccelMapLookupEntry is a wrapper around gtk_accel_map_lookup_entry(). -func AccelMapLookupEntry(path string) *AccelKey { - cstr := C.CString(path) - defer C.free(unsafe.Pointer(cstr)) - - var v *C.struct__GtkAccelKey - - C.gtk_accel_map_lookup_entry((*C.gchar)(cstr), v) - return wrapAccelKey(v) -} - -// AccelMapChangeEntry is a wrapper around gtk_accel_map_change_entry(). -func AccelMapChangeEntry(path string, key uint, mods gdk.ModifierType, replace bool) bool { - cstr := C.CString(path) - defer C.free(unsafe.Pointer(cstr)) - - return gobool(C.gtk_accel_map_change_entry((*C.gchar)(cstr), C.guint(key), C.GdkModifierType(mods), gbool(replace))) -} - -// AccelMapLoad is a wrapper around gtk_accel_map_load(). -func AccelMapLoad(fileName string) { - cstr := C.CString(fileName) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_accel_map_load((*C.gchar)(cstr)) -} - -// AccelMapSave is a wrapper around gtk_accel_map_save(). -func AccelMapSave(fileName string) { - cstr := C.CString(fileName) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_accel_map_save((*C.gchar)(cstr)) -} - -// AccelMapLoadFD is a wrapper around gtk_accel_map_load_fd(). -func AccelMapLoadFD(fd int) { - C.gtk_accel_map_load_fd(C.gint(fd)) -} - -// AccelMapSaveFD is a wrapper around gtk_accel_map_save_fd(). -func AccelMapSaveFD(fd int) { - C.gtk_accel_map_save_fd(C.gint(fd)) -} - -// AccelMapAddFilter is a wrapper around gtk_accel_map_add_filter(). -func AccelMapAddFilter(filter string) { - cstr := C.CString(filter) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_accel_map_add_filter((*C.gchar)(cstr)) -} - -// AccelMapGet is a wrapper around gtk_accel_map_get(). -func AccelMapGet() *AccelMap { - c := C.gtk_accel_map_get() - if c == nil { - return nil - } - return wrapAccelMap(wrapObject(unsafe.Pointer(c))) -} - -// AccelMapLockPath is a wrapper around gtk_accel_map_lock_path(). -func AccelMapLockPath(path string) { - cstr := C.CString(path) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_accel_map_lock_path((*C.gchar)(cstr)) -} - -// AccelMapUnlockPath is a wrapper around gtk_accel_map_unlock_path(). -func AccelMapUnlockPath(path string) { - cstr := C.CString(path) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_accel_map_unlock_path((*C.gchar)(cstr)) -} - -// SetAccelGroup is a wrapper around gtk_menu_set_accel_group(). -func (v *Menu) SetAccelGroup(accelGroup *AccelGroup) { - C.gtk_menu_set_accel_group(v.native(), accelGroup.native()) -} - -// GetAccelGroup is a wrapper around gtk_menu_get_accel_group(). -func (v *Menu) GetAccelGroup() *AccelGroup { - c := C.gtk_menu_get_accel_group(v.native()) - if c == nil { - return nil - } - return wrapAccelGroup(wrapObject(unsafe.Pointer(c))) -} - -// SetAccelPath is a wrapper around gtk_menu_set_accel_path(). -func (v *Menu) SetAccelPath(path string) { - cstr := C.CString(path) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_menu_set_accel_path(v.native(), (*C.gchar)(cstr)) -} - -// GetAccelPath is a wrapper around gtk_menu_get_accel_path(). -func (v *Menu) GetAccelPath() string { - c := C.gtk_menu_get_accel_path(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetAccelPath is a wrapper around gtk_menu_item_set_accel_path(). -func (v *MenuItem) SetAccelPath(path string) { - cstr := C.CString(path) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_menu_item_set_accel_path(v.native(), (*C.gchar)(cstr)) -} - -// GetAccelPath is a wrapper around gtk_menu_item_get_accel_path(). -func (v *MenuItem) GetAccelPath() string { - c := C.gtk_menu_item_get_accel_path(v.native()) - return C.GoString((*C.char)(c)) -} - -// AddAccelerator is a wrapper around gtk_widget_add_accelerator(). -func (v *Widget) AddAccelerator(signal string, group *AccelGroup, key uint, mods gdk.ModifierType, flags AccelFlags) { - csignal := (*C.gchar)(C.CString(signal)) - defer C.free(unsafe.Pointer(csignal)) - - C.gtk_widget_add_accelerator(v.native(), - csignal, - group.native(), - C.guint(key), - C.GdkModifierType(mods), - C.GtkAccelFlags(flags)) -} - -// RemoveAccelerator is a wrapper around gtk_widget_remove_accelerator(). -func (v *Widget) RemoveAccelerator(group *AccelGroup, key uint, mods gdk.ModifierType) bool { - return gobool(C.gtk_widget_remove_accelerator(v.native(), - group.native(), - C.guint(key), - C.GdkModifierType(mods))) -} - -// SetAccelPath is a wrapper around gtk_widget_set_accel_path(). -func (v *Widget) SetAccelPath(path string, group *AccelGroup) { - cstr := (*C.gchar)(C.CString(path)) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_widget_set_accel_path(v.native(), cstr, group.native()) -} - -// CanActivateAccel is a wrapper around gtk_widget_can_activate_accel(). -func (v *Widget) CanActivateAccel(signalId uint) bool { - return gobool(C.gtk_widget_can_activate_accel(v.native(), C.guint(signalId))) -} - -// AddAccelGroup() is a wrapper around gtk_window_add_accel_group(). -func (v *Window) AddAccelGroup(accelGroup *AccelGroup) { - C.gtk_window_add_accel_group(v.native(), accelGroup.native()) -} - -// RemoveAccelGroup() is a wrapper around gtk_window_add_accel_group(). -func (v *Window) RemoveAccelGroup(accelGroup *AccelGroup) { - C.gtk_window_remove_accel_group(v.native(), accelGroup.native()) -} - -// These three functions are for system level access - thus not as high priority to implement -// TODO: void gtk_accelerator_parse_with_keycode () -// TODO: gchar * gtk_accelerator_name_with_keycode () -// TODO: gchar * gtk_accelerator_get_label_with_keycode () - -// TODO: GtkAccelKey * gtk_accel_group_find () - this function uses a function type - I don't know how to represent it in cgo -// TODO: gtk_accel_map_foreach_unfiltered - can't be done without a function type -// TODO: gtk_accel_map_foreach - can't be done without a function type - -// TODO: gtk_accel_map_load_scanner -// TODO: gtk_widget_list_accel_closures diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/actionbar_since_3_12.go b/vendor/github.com/gotk3/gotk3.old/gtk/actionbar_since_3_12.go deleted file mode 100644 index 4d1a2f2..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/actionbar_since_3_12.go +++ /dev/null @@ -1,106 +0,0 @@ -// +build !gtk_3_6,!gtk_3_8,!gtk_3_10 - -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// This file includes wrapers for symbols included since GTK 3.12, and -// and should not be included in a build intended to target any older GTK -// versions. To target an older build, such as 3.10, use -// 'go build -tags gtk_3_10'. Otherwise, if no build tags are used, GTK 3.12 -// is assumed and this file is built. -// +build !gtk_3_6,!gtk_3_8,!gtk_3_10 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -// #include "actionbar_since_3_12.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - {glib.Type(C.gtk_action_bar_get_type()), marshalActionBar}, - } - - glib.RegisterGValueMarshalers(tm) - - WrapMap["GtkActionBar"] = wrapActionBar -} - -//GtkActionBar -type ActionBar struct { - Bin -} - -func (v *ActionBar) native() *C.GtkActionBar { - if v == nil || v.GObject == nil { - return nil - } - - p := unsafe.Pointer(v.GObject) - return C.toGtkActionBar(p) -} - -func marshalActionBar(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapActionBar(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapActionBar(obj *glib.Object) *ActionBar { - return &ActionBar{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -//gtk_action_bar_new() -func ActionBarNew() (*ActionBar, error) { - c := C.gtk_action_bar_new() - if c == nil { - return nil, nilPtrErr - } - return wrapActionBar(wrapObject(unsafe.Pointer(c))), nil -} - -//gtk_action_bar_pack_start(GtkActionBar *action_bar,GtkWidget *child) -func (a *ActionBar) PackStart(child IWidget) { - C.gtk_action_bar_pack_start(a.native(), child.toWidget()) -} - -//gtk_action_bar_pack_end(GtkActionBar *action_bar,GtkWidget *child) -func (a *ActionBar) PackEnd(child IWidget) { - C.gtk_action_bar_pack_end(a.native(), child.toWidget()) -} - -//gtk_action_bar_set_center_widget(GtkActionBar *action_bar,GtkWidget *center_widget) -func (a *ActionBar) SetCenterWidget(child IWidget) { - if child == nil { - C.gtk_action_bar_set_center_widget(a.native(), nil) - } else { - C.gtk_action_bar_set_center_widget(a.native(), child.toWidget()) - } -} - -//gtk_action_bar_get_center_widget(GtkActionBar *action_bar) -func (a *ActionBar) GetCenterWidget() *Widget { - w := C.gtk_action_bar_get_center_widget(a.native()) - if w == nil { - return nil - } - return &Widget{glib.InitiallyUnowned{wrapObject(unsafe.Pointer(w))}} -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/app_chooser.go b/vendor/github.com/gotk3/gotk3.old/gtk/app_chooser.go deleted file mode 100644 index 3793886..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/app_chooser.go +++ /dev/null @@ -1,378 +0,0 @@ -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - {glib.Type(C.gtk_app_chooser_get_type()), marshalAppChooser}, - {glib.Type(C.gtk_app_chooser_button_get_type()), marshalAppChooserButton}, - {glib.Type(C.gtk_app_chooser_widget_get_type()), marshalAppChooserWidget}, - {glib.Type(C.gtk_app_chooser_dialog_get_type()), marshalAppChooserDialog}, - } - - glib.RegisterGValueMarshalers(tm) - - WrapMap["GtkAppChooser"] = wrapAppChooser - WrapMap["GtkAppChooserButton"] = wrapAppChooserButton - WrapMap["GtkAppChooserWidget"] = wrapAppChooserWidget - WrapMap["GtkAppChooserDialog"] = wrapAppChooserDialog -} - -/* - * GtkAppChooser - */ - -// AppChooser is a representation of GTK's GtkAppChooser GInterface. -type AppChooser struct { - *glib.Object -} - -// IAppChooser is an interface type implemented by all structs -// embedding an AppChooser. It is meant to be used as an argument type -// for wrapper functions that wrap around a C GTK function taking a -// GtkAppChooser. -type IAppChooser interface { - toAppChooser() *C.GtkAppChooser -} - -// native returns a pointer to the underlying GtkAppChooser. -func (v *AppChooser) native() *C.GtkAppChooser { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkAppChooser(p) -} - -func marshalAppChooser(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapAppChooser(obj), nil -} - -func wrapAppChooser(obj *glib.Object) *AppChooser { - return &AppChooser{obj} -} - -func (v *AppChooser) toAppChooser() *C.GtkAppChooser { - if v == nil { - return nil - } - return v.native() -} - -// TODO: Needs gio/GAppInfo implementation first -// gtk_app_chooser_get_app_info () - -// GetContentType is a wrapper around gtk_app_chooser_get_content_type(). -func (v *AppChooser) GetContentType() string { - cstr := C.gtk_app_chooser_get_content_type(v.native()) - defer C.free(unsafe.Pointer(cstr)) - return C.GoString((*C.char)(cstr)) -} - -// Refresh is a wrapper around gtk_app_chooser_refresh(). -func (v *AppChooser) Refresh() { - C.gtk_app_chooser_refresh(v.native()) -} - -/* - * GtkAppChooserButton - */ - -// AppChooserButton is a representation of GTK's GtkAppChooserButton. -type AppChooserButton struct { - ComboBox - - // Interfaces - AppChooser -} - -// native returns a pointer to the underlying GtkAppChooserButton. -func (v *AppChooserButton) native() *C.GtkAppChooserButton { - if v == nil || v.GObject == nil { - return nil - } - - p := unsafe.Pointer(v.GObject) - return C.toGtkAppChooserButton(p) -} - -func marshalAppChooserButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapAppChooserButton(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapAppChooserButton(obj *glib.Object) *AppChooserButton { - cl := wrapCellLayout(obj) - ac := wrapAppChooser(obj) - return &AppChooserButton{ComboBox{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}, *cl}, *ac} -} - -// AppChooserButtonNew() is a wrapper around gtk_app_chooser_button_new(). -func AppChooserButtonNew(content_type string) (*AppChooserButton, error) { - cstr := C.CString(content_type) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_app_chooser_button_new((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapAppChooserButton(wrapObject(unsafe.Pointer(c))), nil -} - -// TODO: Needs gio/GIcon implemented first -// gtk_app_chooser_button_append_custom_item () - -// AppendSeparator() is a wrapper around gtk_app_chooser_button_append_separator(). -func (v *AppChooserButton) AppendSeparator() { - C.gtk_app_chooser_button_append_separator(v.native()) -} - -// SetActiveCustomItem() is a wrapper around gtk_app_chooser_button_set_active_custom_item(). -func (v *AppChooserButton) SetActiveCustomItem(name string) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_app_chooser_button_set_active_custom_item(v.native(), (*C.gchar)(cstr)) -} - -// GetShowDefaultItem() is a wrapper around gtk_app_chooser_button_get_show_default_item(). -func (v *AppChooserButton) GetShowDefaultItem() bool { - return gobool(C.gtk_app_chooser_button_get_show_default_item(v.native())) -} - -// SetShowDefaultItem() is a wrapper around gtk_app_chooser_button_set_show_default_item(). -func (v *AppChooserButton) SetShowDefaultItem(setting bool) { - C.gtk_app_chooser_button_set_show_default_item(v.native(), gbool(setting)) -} - -// GetShowDialogItem() is a wrapper around gtk_app_chooser_button_get_show_dialog_item(). -func (v *AppChooserButton) GetShowDialogItem() bool { - return gobool(C.gtk_app_chooser_button_get_show_dialog_item(v.native())) -} - -// SetShowDialogItem() is a wrapper around gtk_app_chooser_button_set_show_dialog_item(). -func (v *AppChooserButton) SetShowDialogItem(setting bool) { - C.gtk_app_chooser_button_set_show_dialog_item(v.native(), gbool(setting)) -} - -// GetHeading() is a wrapper around gtk_app_chooser_button_get_heading(). -// In case when gtk_app_chooser_button_get_heading() returns a nil string, -// GetHeading() returns a non-nil error. -func (v *AppChooserButton) GetHeading() (string, error) { - cstr := C.gtk_app_chooser_button_get_heading(v.native()) - if cstr == nil { - return "", nilPtrErr - } - defer C.free(unsafe.Pointer(cstr)) - return C.GoString((*C.char)(cstr)), nil -} - -// SetHeading() is a wrapper around gtk_app_chooser_button_set_heading(). -func (v *AppChooserButton) SetHeading(heading string) { - cstr := C.CString(heading) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_app_chooser_button_set_heading(v.native(), (*C.gchar)(cstr)) -} - -/* - * GtkAppChooserWidget - */ - -// AppChooserWidget is a representation of GTK's GtkAppChooserWidget. -type AppChooserWidget struct { - Box - - // Interfaces - AppChooser -} - -// native returns a pointer to the underlying GtkAppChooserWidget. -func (v *AppChooserWidget) native() *C.GtkAppChooserWidget { - if v == nil || v.GObject == nil { - return nil - } - - p := unsafe.Pointer(v.GObject) - return C.toGtkAppChooserWidget(p) -} - -func marshalAppChooserWidget(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapAppChooserWidget(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapAppChooserWidget(obj *glib.Object) *AppChooserWidget { - box := wrapBox(obj) - ac := wrapAppChooser(obj) - return &AppChooserWidget{*box, *ac} -} - -// AppChooserWidgetNew() is a wrapper around gtk_app_chooser_widget_new(). -func AppChooserWidgetNew(content_type string) (*AppChooserWidget, error) { - cstr := C.CString(content_type) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_app_chooser_widget_new((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapAppChooserWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// GetShowDefault() is a wrapper around gtk_app_chooser_widget_get_show_default(). -func (v *AppChooserWidget) GetShowDefault() bool { - return gobool(C.gtk_app_chooser_widget_get_show_default(v.native())) -} - -// SetShowDefault() is a wrapper around gtk_app_chooser_widget_set_show_default(). -func (v *AppChooserWidget) SetShowDefault(setting bool) { - C.gtk_app_chooser_widget_set_show_default(v.native(), gbool(setting)) -} - -// GetShowRecommended() is a wrapper around gtk_app_chooser_widget_get_show_recommended(). -func (v *AppChooserWidget) GetShowRecommended() bool { - return gobool(C.gtk_app_chooser_widget_get_show_recommended(v.native())) -} - -// SetShowRecommended() is a wrapper around gtk_app_chooser_widget_set_show_recommended(). -func (v *AppChooserWidget) SetShowRecommended(setting bool) { - C.gtk_app_chooser_widget_set_show_recommended(v.native(), gbool(setting)) -} - -// GetShowFallback() is a wrapper around gtk_app_chooser_widget_get_show_fallback(). -func (v *AppChooserWidget) GetShowFallback() bool { - return gobool(C.gtk_app_chooser_widget_get_show_fallback(v.native())) -} - -// SetShowFallback() is a wrapper around gtk_app_chooser_widget_set_show_fallback(). -func (v *AppChooserWidget) SetShowFallback(setting bool) { - C.gtk_app_chooser_widget_set_show_fallback(v.native(), gbool(setting)) -} - -// GetShowOther() is a wrapper around gtk_app_chooser_widget_get_show_other(). -func (v *AppChooserWidget) GetShowOther() bool { - return gobool(C.gtk_app_chooser_widget_get_show_other(v.native())) -} - -// SetShowOther() is a wrapper around gtk_app_chooser_widget_set_show_other(). -func (v *AppChooserWidget) SetShowOther(setting bool) { - C.gtk_app_chooser_widget_set_show_other(v.native(), gbool(setting)) -} - -// GetShowAll() is a wrapper around gtk_app_chooser_widget_get_show_all(). -func (v *AppChooserWidget) GetShowAll() bool { - return gobool(C.gtk_app_chooser_widget_get_show_all(v.native())) -} - -// SetShowAll() is a wrapper around gtk_app_chooser_widget_set_show_all(). -func (v *AppChooserWidget) SetShowAll(setting bool) { - C.gtk_app_chooser_widget_set_show_all(v.native(), gbool(setting)) -} - -// GetDefaultText() is a wrapper around gtk_app_chooser_widget_get_default_text(). -// In case when gtk_app_chooser_widget_get_default_text() returns a nil string, -// GetDefaultText() returns a non-nil error. -func (v *AppChooserWidget) GetDefaultText() (string, error) { - cstr := C.gtk_app_chooser_widget_get_default_text(v.native()) - if cstr == nil { - return "", nilPtrErr - } - defer C.free(unsafe.Pointer(cstr)) - return C.GoString((*C.char)(cstr)), nil -} - -// SetDefaultText() is a wrapper around gtk_app_chooser_widget_set_default_text(). -func (v *AppChooserWidget) SetDefaultText(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_app_chooser_widget_set_default_text(v.native(), (*C.gchar)(cstr)) -} - -/* - * GtkAppChooserDialog - */ - -// AppChooserDialog is a representation of GTK's GtkAppChooserDialog. -type AppChooserDialog struct { - Dialog - - // Interfaces - AppChooser -} - -// native returns a pointer to the underlying GtkAppChooserButton. -func (v *AppChooserDialog) native() *C.GtkAppChooserDialog { - if v == nil || v.GObject == nil { - return nil - } - - p := unsafe.Pointer(v.GObject) - return C.toGtkAppChooserDialog(p) -} - -func marshalAppChooserDialog(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapAppChooserDialog(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapAppChooserDialog(obj *glib.Object) *AppChooserDialog { - dialog := wrapDialog(obj) - ac := wrapAppChooser(obj) - return &AppChooserDialog{*dialog, *ac} -} - -// TODO: Uncomment when gio builds successfully -// AppChooserDialogNew() is a wrapper around gtk_app_chooser_dialog_new(). -// func AppChooserDialogNew(parent *Window, flags DialogFlags, file *gio.File) (*AppChooserDialog, error) { -// var gfile *C.GFile -// if file != nil { -// gfile = (*C.GFile)(unsafe.Pointer(file.Native())) -// } -// c := C.gtk_app_chooser_dialog_new(parent.native(), C.GtkDialogFlags(flags), gfile) -// if c == nil { -// return nil, nilPtrErr -// } -// return wrapAppChooserDialog(wrapObject(unsafe.Pointer(c))), nil -// } - -// AppChooserDialogNewForContentType() is a wrapper around gtk_app_chooser_dialog_new_for_content_type(). -func AppChooserDialogNewForContentType(parent *Window, flags DialogFlags, content_type string) (*AppChooserDialog, error) { - cstr := C.CString(content_type) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_app_chooser_dialog_new_for_content_type(parent.native(), C.GtkDialogFlags(flags), (*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapAppChooserDialog(wrapObject(unsafe.Pointer(c))), nil -} - -// GetWidget() is a wrapper around gtk_app_chooser_dialog_get_widget(). -func (v *AppChooserDialog) GetWidget() *AppChooserWidget { - c := C.gtk_app_chooser_dialog_get_widget(v.native()) - return wrapAppChooserWidget(wrapObject(unsafe.Pointer(c))) -} - -// GetHeading() is a wrapper around gtk_app_chooser_dialog_get_heading(). -// In case when gtk_app_chooser_dialog_get_heading() returns a nil string, -// GetHeading() returns a non-nil error. -func (v *AppChooserDialog) GetHeading() (string, error) { - cstr := C.gtk_app_chooser_dialog_get_heading(v.native()) - if cstr == nil { - return "", nilPtrErr - } - defer C.free(unsafe.Pointer(cstr)) - return C.GoString((*C.char)(cstr)), nil -} - -// SetHeading() is a wrapper around gtk_app_chooser_dialog_set_heading(). -func (v *AppChooserDialog) SetHeading(heading string) { - cstr := C.CString(heading) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_app_chooser_dialog_set_heading(v.native(), (*C.gchar)(cstr)) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/application.go b/vendor/github.com/gotk3/gotk3.old/gtk/application.go deleted file mode 100644 index dbdeefe..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/application.go +++ /dev/null @@ -1,156 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains style related functions and structures - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "runtime" - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -// ApplicationInhibitFlags is a representation of GTK's GtkApplicationInhibitFlags. -type ApplicationInhibitFlags int - -const ( - APPLICATION_INHIBIT_LOGOUT ApplicationInhibitFlags = C.GTK_APPLICATION_INHIBIT_LOGOUT - APPLICATION_INHIBIT_SWITCH ApplicationInhibitFlags = C.GTK_APPLICATION_INHIBIT_SWITCH - APPLICATION_INHIBIT_SUSPEND ApplicationInhibitFlags = C.GTK_APPLICATION_INHIBIT_SUSPEND - APPLICATION_INHIBIT_IDLE ApplicationInhibitFlags = C.GTK_APPLICATION_INHIBIT_IDLE -) - -/* - * GtkApplication - */ - -// Application is a representation of GTK's GtkApplication. -type Application struct { - glib.Application -} - -// native returns a pointer to the underlying GtkApplication. -func (v *Application) native() *C.GtkApplication { - if v == nil || v.GObject == nil { - return nil - } - return C.toGtkApplication(unsafe.Pointer(v.GObject)) -} - -func marshalApplication(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapApplication(obj), nil -} - -func wrapApplication(obj *glib.Object) *Application { - return &Application{glib.Application{obj}} -} - -// ApplicationNew is a wrapper around gtk_application_new(). -func ApplicationNew(appId string, flags glib.ApplicationFlags) (*Application, error) { - cstr := (*C.gchar)(C.CString(appId)) - defer C.free(unsafe.Pointer(cstr)) - - c := C.gtk_application_new(cstr, C.GApplicationFlags(flags)) - if c == nil { - return nil, nilPtrErr - } - return wrapApplication(wrapObject(unsafe.Pointer(c))), nil -} - -// AddWindow is a wrapper around gtk_application_add_window(). -func (v *Application) AddWindow(w *Window) { - C.gtk_application_add_window(v.native(), w.native()) -} - -// RemoveWindow is a wrapper around gtk_application_remove_window(). -func (v *Application) RemoveWindow(w *Window) { - C.gtk_application_remove_window(v.native(), w.native()) -} - -// GetWindowByID is a wrapper around gtk_application_get_window_by_id(). -func (v *Application) GetWindowByID(id uint) *Window { - c := C.gtk_application_get_window_by_id(v.native(), C.guint(id)) - if c == nil { - return nil - } - return wrapWindow(wrapObject(unsafe.Pointer(c))) -} - -// GetActiveWindow is a wrapper around gtk_application_get_active_window(). -func (v *Application) GetActiveWindow() *Window { - c := C.gtk_application_get_active_window(v.native()) - if c == nil { - return nil - } - return wrapWindow(wrapObject(unsafe.Pointer(c))) -} - -// Uninhibit is a wrapper around gtk_application_uninhibit(). -func (v *Application) Uninhibit(cookie uint) { - C.gtk_application_uninhibit(v.native(), C.guint(cookie)) -} - -// GetAppMenu is a wrapper around gtk_application_get_app_menu(). -func (v *Application) GetAppMenu() *glib.MenuModel { - c := C.gtk_application_get_app_menu(v.native()) - if c == nil { - return nil - } - return &glib.MenuModel{wrapObject(unsafe.Pointer(c))} -} - -// SetAppMenu is a wrapper around gtk_application_set_app_menu(). -func (v *Application) SetAppMenu(m *glib.MenuModel) { - mptr := (*C.GMenuModel)(unsafe.Pointer(m.Native())) - C.gtk_application_set_app_menu(v.native(), mptr) -} - -// GetMenubar is a wrapper around gtk_application_get_menubar(). -func (v *Application) GetMenubar() *glib.MenuModel { - c := C.gtk_application_get_menubar(v.native()) - if c == nil { - return nil - } - return &glib.MenuModel{wrapObject(unsafe.Pointer(c))} -} - -// SetMenubar is a wrapper around gtk_application_set_menubar(). -func (v *Application) SetMenubar(m *glib.MenuModel) { - mptr := (*C.GMenuModel)(unsafe.Pointer(m.Native())) - C.gtk_application_set_menubar(v.native(), mptr) -} - -// IsInhibited is a wrapper around gtk_application_is_inhibited(). -func (v *Application) IsInhibited(flags ApplicationInhibitFlags) bool { - return gobool(C.gtk_application_is_inhibited(v.native(), C.GtkApplicationInhibitFlags(flags))) -} - -// Inhibited is a wrapper around gtk_application_inhibit(). -func (v *Application) Inhibited(w *Window, flags ApplicationInhibitFlags, reason string) uint { - cstr1 := (*C.gchar)(C.CString(reason)) - defer C.free(unsafe.Pointer(cstr1)) - - return uint(C.gtk_application_inhibit(v.native(), w.native(), C.GtkApplicationInhibitFlags(flags), cstr1)) -} - -// void gtk_application_add_accelerator () // deprecated and uses a gvariant paramater -// void gtk_application_remove_accelerator () // deprecated and uses a gvariant paramater - -// GetWindows is a wrapper around gtk_application_get_windows(). -// Returned list is wrapped to return *gtk.Window elements. -func (v *Application) GetWindows() *glib.List { - glist := C.gtk_application_get_windows(v.native()) - list := glib.WrapList(uintptr(unsafe.Pointer(glist))) - list.DataWrapper(func(ptr unsafe.Pointer) interface{} { - return wrapWindow(wrapObject(ptr)) - }) - runtime.SetFinalizer(list, func(l *glib.List) { - l.Free() - }) - return list -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/application_since_3_12.go b/vendor/github.com/gotk3/gotk3.old/gtk/application_since_3_12.go deleted file mode 100644 index 1fd55fb..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/application_since_3_12.go +++ /dev/null @@ -1,62 +0,0 @@ -// +build !gtk_3_6,!gtk_3_8,!gtk_3_10 - -// See: https://developer.gnome.org/gtk3/3.12/api-index-3-12.html - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import "unsafe" - -// GetAccelsForAction is a wrapper around gtk_application_get_accels_for_action(). -func (v *Application) GetAccelsForAction(act string) []string { - cstr1 := (*C.gchar)(C.CString(act)) - defer C.free(unsafe.Pointer(cstr1)) - - var descs []string - c := C.gtk_application_get_accels_for_action(v.native(), cstr1) - originalc := c - defer C.g_strfreev(originalc) - - for *c != nil { - descs = append(descs, C.GoString((*C.char)(*c))) - c = C.next_gcharptr(c) - } - - return descs -} - -// SetAccelsForAction is a wrapper around gtk_application_set_accels_for_action(). -func (v *Application) SetAccelsForAction(act string, accels []string) { - cstr1 := (*C.gchar)(C.CString(act)) - defer C.free(unsafe.Pointer(cstr1)) - - caccels := C.make_strings(C.int(len(accels) + 1)) - defer C.destroy_strings(caccels) - - for i, accel := range accels { - cstr := C.CString(accel) - defer C.free(unsafe.Pointer(cstr)) - C.set_string(caccels, C.int(i), (*C.gchar)(cstr)) - } - - C.set_string(caccels, C.int(len(accels)), nil) - - C.gtk_application_set_accels_for_action(v.native(), cstr1, caccels) -} - -// ListActionDescriptions is a wrapper around gtk_application_list_action_descriptions(). -func (v *Application) ListActionDescriptions() []string { - var descs []string - c := C.gtk_application_list_action_descriptions(v.native()) - originalc := c - defer C.g_strfreev(originalc) - - for *c != nil { - descs = append(descs, C.GoString((*C.char)(*c))) - c = C.next_gcharptr(c) - } - - return descs -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/application_since_3_14.go b/vendor/github.com/gotk3/gotk3.old/gtk/application_since_3_14.go deleted file mode 100644 index b783911..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/application_since_3_14.go +++ /dev/null @@ -1,49 +0,0 @@ -// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12 - -// See: https://developer.gnome.org/gtk3/3.14/api-index-3-14.html - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -// PrefersAppMenu is a wrapper around gtk_application_prefers_app_menu(). -func (v *Application) PrefersAppMenu() bool { - return gobool(C.gtk_application_prefers_app_menu(v.native())) -} - -// GetActionsForAccel is a wrapper around gtk_application_get_actions_for_accel(). -func (v *Application) GetActionsForAccel(acc string) []string { - cstr1 := (*C.gchar)(C.CString(acc)) - defer C.free(unsafe.Pointer(cstr1)) - - var acts []string - c := C.gtk_application_get_actions_for_accel(v.native(), cstr1) - originalc := c - defer C.g_strfreev(originalc) - - for *c != nil { - acts = append(acts, C.GoString((*C.char)(*c))) - c = C.next_gcharptr(c) - } - - return acts -} - -// GetMenuByID is a wrapper around gtk_application_get_menu_by_id(). -func (v *Application) GetMenuByID(id string) *glib.Menu { - cstr1 := (*C.gchar)(C.CString(id)) - defer C.free(unsafe.Pointer(cstr1)) - - c := C.gtk_application_get_menu_by_id(v.native(), cstr1) - if c == nil { - return nil - } - return &glib.Menu{glib.MenuModel{wrapObject(unsafe.Pointer(c))}} -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/application_window.go b/vendor/github.com/gotk3/gotk3.old/gtk/application_window.go deleted file mode 100644 index da8bca8..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/application_window.go +++ /dev/null @@ -1,65 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains style related functions and structures - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -/* - * GtkApplicationWindow - */ - -// ApplicationWindow is a representation of GTK's GtkApplicationWindow. -type ApplicationWindow struct { - Window -} - -// native returns a pointer to the underlying GtkApplicationWindow. -func (v *ApplicationWindow) native() *C.GtkApplicationWindow { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkApplicationWindow(p) -} - -func marshalApplicationWindow(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapApplicationWindow(obj), nil -} - -func wrapApplicationWindow(obj *glib.Object) *ApplicationWindow { - return &ApplicationWindow{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}} -} - -// ApplicationWindowNew is a wrapper around gtk_application_window_new(). -func ApplicationWindowNew(app *Application) (*ApplicationWindow, error) { - c := C.gtk_application_window_new(app.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapApplicationWindow(wrapObject(unsafe.Pointer(c))), nil -} - -// SetShowMenubar is a wrapper around gtk_application_window_set_show_menubar(). -func (v *ApplicationWindow) SetShowMenubar(b bool) { - C.gtk_application_window_set_show_menubar(v.native(), gbool(b)) -} - -// GetShowMenubar is a wrapper around gtk_application_window_get_show_menubar(). -func (v *ApplicationWindow) GetShowMenubar() bool { - return gobool(C.gtk_application_window_get_show_menubar(v.native())) -} - -// GetID is a wrapper around gtk_application_window_get_id(). -func (v *ApplicationWindow) GetID() uint { - return uint(C.gtk_application_window_get_id(v.native())) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/color_chooser.go b/vendor/github.com/gotk3/gotk3.old/gtk/color_chooser.go deleted file mode 100644 index e649e60..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/color_chooser.go +++ /dev/null @@ -1,148 +0,0 @@ -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/gdk" - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - {glib.Type(C.gtk_color_chooser_get_type()), marshalColorChooser}, - {glib.Type(C.gtk_color_chooser_dialog_get_type()), marshalColorChooserDialog}, - } - - glib.RegisterGValueMarshalers(tm) - - WrapMap["GtkColorChooser"] = wrapColorChooser - WrapMap["GtkColorChooserDialog"] = wrapColorChooserDialog -} - -/* - * GtkColorChooser - */ - -// ColorChooser is a representation of GTK's GtkColorChooser GInterface. -type ColorChooser struct { - *glib.Object -} - -// IColorChooser is an interface type implemented by all structs -// embedding an ColorChooser. It is meant to be used as an argument type -// for wrapper functions that wrap around a C GTK function taking a -// GtkColorChooser. -type IColorChooser interface { - toColorChooser() *C.GtkColorChooser -} - -// native returns a pointer to the underlying GtkAppChooser. -func (v *ColorChooser) native() *C.GtkColorChooser { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkColorChooser(p) -} - -func marshalColorChooser(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapColorChooser(obj), nil -} - -func wrapColorChooser(obj *glib.Object) *ColorChooser { - return &ColorChooser{obj} -} - -func (v *ColorChooser) toColorChooser() *C.GtkColorChooser { - if v == nil { - return nil - } - return v.native() -} - -// GetRGBA() is a wrapper around gtk_color_chooser_get_rgba(). -func (v *ColorChooser) GetRGBA() *gdk.RGBA { - gdkColor := gdk.NewRGBA() - C.gtk_color_chooser_get_rgba(v.native(), (*C.GdkRGBA)(unsafe.Pointer(gdkColor.Native()))) - return gdkColor -} - -// SetRGBA() is a wrapper around gtk_color_chooser_set_rgba(). -func (v *ColorChooser) SetRGBA(gdkColor *gdk.RGBA) { - C.gtk_color_chooser_set_rgba(v.native(), (*C.GdkRGBA)(unsafe.Pointer(gdkColor.Native()))) -} - -// GetUseAlpha() is a wrapper around gtk_color_chooser_get_use_alpha(). -func (v *ColorChooser) GetUseAlpha() bool { - return gobool(C.gtk_color_chooser_get_use_alpha(v.native())) -} - -// SetUseAlpha() is a wrapper around gtk_color_chooser_set_use_alpha(). -func (v *ColorChooser) SetUseAlpha(use_alpha bool) { - C.gtk_color_chooser_set_use_alpha(v.native(), gbool(use_alpha)) -} - -// AddPalette() is a wrapper around gtk_color_chooser_add_palette(). -func (v *ColorChooser) AddPalette(orientation Orientation, colors_per_line int, colors []*gdk.RGBA) { - n_colors := len(colors) - var c_colors []C.GdkRGBA - for _, c := range colors { - c_colors = append(c_colors, *(*C.GdkRGBA)(unsafe.Pointer(c.Native()))) - } - C.gtk_color_chooser_add_palette( - v.native(), - C.GtkOrientation(orientation), - C.gint(colors_per_line), - C.gint(n_colors), - &c_colors[0], - ) -} - -/* - * GtkColorChooserDialog - */ - -// ColorChooserDialog is a representation of GTK's GtkColorChooserDialog. -type ColorChooserDialog struct { - Dialog - - // Interfaces - ColorChooser -} - -// native returns a pointer to the underlying GtkColorChooserButton. -func (v *ColorChooserDialog) native() *C.GtkColorChooserDialog { - if v == nil || v.GObject == nil { - return nil - } - - p := unsafe.Pointer(v.GObject) - return C.toGtkColorChooserDialog(p) -} - -func marshalColorChooserDialog(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapColorChooserDialog(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapColorChooserDialog(obj *glib.Object) *ColorChooserDialog { - dialog := wrapDialog(obj) - cc := wrapColorChooser(obj) - return &ColorChooserDialog{*dialog, *cc} -} - -// ColorChooserDialogNew() is a wrapper around gtk_color_chooser_dialog_new(). -func ColorChooserDialogNew(title string, parent *Window) (*ColorChooserDialog, error) { - cstr := C.CString(title) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_color_chooser_dialog_new((*C.gchar)(cstr), parent.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapColorChooserDialog(wrapObject(unsafe.Pointer(c))), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/combo_box.go b/vendor/github.com/gotk3/gotk3.old/gtk/combo_box.go deleted file mode 100644 index 3438b45..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/combo_box.go +++ /dev/null @@ -1,264 +0,0 @@ -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "errors" - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - {glib.Type(C.gtk_combo_box_get_type()), marshalComboBox}, - {glib.Type(C.gtk_combo_box_text_get_type()), marshalComboBoxText}, - } - - glib.RegisterGValueMarshalers(tm) - - WrapMap["GtkComboBox"] = wrapComboBox - WrapMap["GtkComboBoxText"] = wrapComboBoxText -} - -/* - * GtkComboBox - */ - -// ComboBox is a representation of GTK's GtkComboBox. -type ComboBox struct { - Bin - - // Interfaces - CellLayout -} - -// native returns a pointer to the underlying GtkComboBox. -func (v *ComboBox) native() *C.GtkComboBox { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkComboBox(p) -} - -func (v *ComboBox) toCellLayout() *C.GtkCellLayout { - if v == nil { - return nil - } - return C.toGtkCellLayout(unsafe.Pointer(v.GObject)) -} - -func marshalComboBox(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapComboBox(obj), nil -} - -func wrapComboBox(obj *glib.Object) *ComboBox { - cl := wrapCellLayout(obj) - return &ComboBox{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}, *cl} -} - -// ComboBoxNew() is a wrapper around gtk_combo_box_new(). -func ComboBoxNew() (*ComboBox, error) { - c := C.gtk_combo_box_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapComboBox(obj), nil -} - -// ComboBoxNewWithEntry() is a wrapper around gtk_combo_box_new_with_entry(). -func ComboBoxNewWithEntry() (*ComboBox, error) { - c := C.gtk_combo_box_new_with_entry() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapComboBox(obj), nil -} - -// ComboBoxNewWithModel() is a wrapper around gtk_combo_box_new_with_model(). -func ComboBoxNewWithModel(model ITreeModel) (*ComboBox, error) { - c := C.gtk_combo_box_new_with_model(model.toTreeModel()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapComboBox(obj), nil -} - -// GetActive() is a wrapper around gtk_combo_box_get_active(). -func (v *ComboBox) GetActive() int { - c := C.gtk_combo_box_get_active(v.native()) - return int(c) -} - -// SetActive() is a wrapper around gtk_combo_box_set_active(). -func (v *ComboBox) SetActive(index int) { - C.gtk_combo_box_set_active(v.native(), C.gint(index)) -} - -// GetActiveIter is a wrapper around gtk_combo_box_get_active_iter(). -func (v *ComboBox) GetActiveIter() (*TreeIter, error) { - var cIter C.GtkTreeIter - c := C.gtk_combo_box_get_active_iter(v.native(), &cIter) - if !gobool(c) { - return nil, errors.New("unable to get active iter") - } - return &TreeIter{cIter}, nil -} - -// SetActiveIter is a wrapper around gtk_combo_box_set_active_iter(). -func (v *ComboBox) SetActiveIter(iter *TreeIter) { - var cIter *C.GtkTreeIter - if iter != nil { - cIter = &iter.GtkTreeIter - } - C.gtk_combo_box_set_active_iter(v.native(), cIter) -} - -// GetActiveID is a wrapper around gtk_combo_box_get_active_id(). -func (v *ComboBox) GetActiveID() string { - c := C.gtk_combo_box_get_active_id(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetActiveID is a wrapper around gtk_combo_box_set_active_id(). -func (v *ComboBox) SetActiveID(id string) bool { - cid := C.CString(id) - defer C.free(unsafe.Pointer(cid)) - c := C.gtk_combo_box_set_active_id(v.native(), (*C.gchar)(cid)) - return gobool(c) -} - -// GetModel is a wrapper around gtk_combo_box_get_model(). -func (v *ComboBox) GetModel() (*TreeModel, error) { - c := C.gtk_combo_box_get_model(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapTreeModel(obj), nil -} - -// SetModel is a wrapper around gtk_combo_box_set_model(). -func (v *ComboBox) SetModel(model ITreeModel) { - C.gtk_combo_box_set_model(v.native(), model.toTreeModel()) -} - -/* - * GtkComboBoxText - */ - -// ComboBoxText is a representation of GTK's GtkComboBoxText. -type ComboBoxText struct { - ComboBox -} - -// native returns a pointer to the underlying GtkComboBoxText. -func (v *ComboBoxText) native() *C.GtkComboBoxText { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkComboBoxText(p) -} - -func marshalComboBoxText(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapComboBoxText(obj), nil -} - -func wrapComboBoxText(obj *glib.Object) *ComboBoxText { - return &ComboBoxText{*wrapComboBox(obj)} -} - -// ComboBoxTextNew is a wrapper around gtk_combo_box_text_new(). -func ComboBoxTextNew() (*ComboBoxText, error) { - c := C.gtk_combo_box_text_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapComboBoxText(obj), nil -} - -// ComboBoxTextNewWithEntry is a wrapper around gtk_combo_box_text_new_with_entry(). -func ComboBoxTextNewWithEntry() (*ComboBoxText, error) { - c := C.gtk_combo_box_text_new_with_entry() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapComboBoxText(obj), nil -} - -// Append is a wrapper around gtk_combo_box_text_append(). -func (v *ComboBoxText) Append(id, text string) { - cid := C.CString(id) - ctext := C.CString(text) - defer C.free(unsafe.Pointer(cid)) - defer C.free(unsafe.Pointer(ctext)) - C.gtk_combo_box_text_append(v.native(), (*C.gchar)(cid), (*C.gchar)(ctext)) -} - -// Prepend is a wrapper around gtk_combo_box_text_prepend(). -func (v *ComboBoxText) Prepend(id, text string) { - cid := C.CString(id) - ctext := C.CString(text) - defer C.free(unsafe.Pointer(cid)) - defer C.free(unsafe.Pointer(ctext)) - C.gtk_combo_box_text_prepend(v.native(), (*C.gchar)(cid), (*C.gchar)(ctext)) -} - -// Insert is a wrapper around gtk_combo_box_text_insert(). -func (v *ComboBoxText) Insert(position int, id, text string) { - cid := C.CString(id) - ctext := C.CString(text) - defer C.free(unsafe.Pointer(cid)) - defer C.free(unsafe.Pointer(ctext)) - C.gtk_combo_box_text_insert(v.native(), C.gint(position), (*C.gchar)(cid), (*C.gchar)(ctext)) -} - -// AppendText is a wrapper around gtk_combo_box_text_append_text(). -func (v *ComboBoxText) AppendText(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_combo_box_text_append_text(v.native(), (*C.gchar)(cstr)) -} - -// PrependText is a wrapper around gtk_combo_box_text_prepend_text(). -func (v *ComboBoxText) PrependText(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_combo_box_text_prepend_text(v.native(), (*C.gchar)(cstr)) -} - -// InsertText is a wrapper around gtk_combo_box_text_insert_text(). -func (v *ComboBoxText) InsertText(position int, text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_combo_box_text_insert_text(v.native(), C.gint(position), (*C.gchar)(cstr)) -} - -// Remove is a wrapper around gtk_combo_box_text_remove(). -func (v *ComboBoxText) Remove(position int) { - C.gtk_combo_box_text_remove(v.native(), C.gint(position)) -} - -// RemoveAll is a wrapper around gtk_combo_box_text_remove_all(). -func (v *ComboBoxText) RemoveAll() { - C.gtk_combo_box_text_remove_all(v.native()) -} - -// GetActiveText is a wrapper around gtk_combo_box_text_get_active_text(). -func (v *ComboBoxText) GetActiveText() string { - c := (*C.char)(C.gtk_combo_box_text_get_active_text(v.native())) - defer C.free(unsafe.Pointer(c)) - return C.GoString(c) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/gtk.go b/vendor/github.com/gotk3/gotk3.old/gtk/gtk.go deleted file mode 100644 index 25fad10..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/gtk.go +++ /dev/null @@ -1,8681 +0,0 @@ -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// Go bindings for GTK+ 3. Supports version 3.6 and later. -// -// Functions use the same names as the native C function calls, but use -// CamelCase. In cases where native GTK uses pointers to values to -// simulate multiple return values, Go's native multiple return values -// are used instead. Whenever a native GTK call could return an -// unexpected NULL pointer, an additonal error is returned in the Go -// binding. -// -// GTK's C API documentation can be very useful for understanding how the -// functions in this package work and what each type is for. This -// documentation can be found at https://developer.gnome.org/gtk3/. -// -// In addition to Go versions of the C GTK functions, every struct type -// includes a method named Native (either by direct implementation, or -// by means of struct embedding). These methods return a uintptr of the -// native C object the binding type represents. These pointers may be -// type switched to a native C pointer using unsafe and used with cgo -// function calls outside this package. -// -// Memory management is handled in proper Go fashion, using runtime -// finalizers to properly free memory when it is no longer needed. Each -// time a Go type is created with a pointer to a GObject, a reference is -// added for Go, sinking the floating reference when necessary. After -// going out of scope and the next time Go's garbage collector is run, a -// finalizer is run to remove Go's reference to the GObject. When this -// reference count hits zero (when neither Go nor GTK holds ownership) -// the object will be freed internally by GTK. -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -// #include "gtk.go.h" -import "C" -import ( - "errors" - "fmt" - "reflect" - "runtime" - "sync" - "unsafe" - - "github.com/gotk3/gotk3/cairo" - "github.com/gotk3/gotk3/gdk" - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - // Enums - {glib.Type(C.gtk_align_get_type()), marshalAlign}, - {glib.Type(C.gtk_accel_flags_get_type()), marshalAccelFlags}, - {glib.Type(C.gtk_accel_group_get_type()), marshalAccelGroup}, - {glib.Type(C.gtk_accel_map_get_type()), marshalAccelMap}, - {glib.Type(C.gtk_arrow_placement_get_type()), marshalArrowPlacement}, - {glib.Type(C.gtk_arrow_type_get_type()), marshalArrowType}, - {glib.Type(C.gtk_assistant_page_type_get_type()), marshalAssistantPageType}, - {glib.Type(C.gtk_buttons_type_get_type()), marshalButtonsType}, - {glib.Type(C.gtk_calendar_display_options_get_type()), marshalCalendarDisplayOptions}, - {glib.Type(C.gtk_dest_defaults_get_type()), marshalDestDefaults}, - {glib.Type(C.gtk_dialog_flags_get_type()), marshalDialogFlags}, - {glib.Type(C.gtk_entry_icon_position_get_type()), marshalEntryIconPosition}, - {glib.Type(C.gtk_file_chooser_action_get_type()), marshalFileChooserAction}, - {glib.Type(C.gtk_icon_lookup_flags_get_type()), marshalSortType}, - {glib.Type(C.gtk_icon_size_get_type()), marshalIconSize}, - {glib.Type(C.gtk_image_type_get_type()), marshalImageType}, - {glib.Type(C.gtk_input_hints_get_type()), marshalInputHints}, - {glib.Type(C.gtk_input_purpose_get_type()), marshalInputPurpose}, - {glib.Type(C.gtk_justification_get_type()), marshalJustification}, - {glib.Type(C.gtk_license_get_type()), marshalLicense}, - {glib.Type(C.gtk_message_type_get_type()), marshalMessageType}, - {glib.Type(C.gtk_orientation_get_type()), marshalOrientation}, - {glib.Type(C.gtk_pack_type_get_type()), marshalPackType}, - {glib.Type(C.gtk_path_type_get_type()), marshalPathType}, - {glib.Type(C.gtk_policy_type_get_type()), marshalPolicyType}, - {glib.Type(C.gtk_position_type_get_type()), marshalPositionType}, - {glib.Type(C.gtk_relief_style_get_type()), marshalReliefStyle}, - {glib.Type(C.gtk_response_type_get_type()), marshalResponseType}, - {glib.Type(C.gtk_selection_mode_get_type()), marshalSelectionMode}, - {glib.Type(C.gtk_shadow_type_get_type()), marshalShadowType}, - {glib.Type(C.gtk_sort_type_get_type()), marshalSortType}, - {glib.Type(C.gtk_state_flags_get_type()), marshalStateFlags}, - {glib.Type(C.gtk_target_flags_get_type()), marshalTargetFlags}, - {glib.Type(C.gtk_toolbar_style_get_type()), marshalToolbarStyle}, - {glib.Type(C.gtk_tree_model_flags_get_type()), marshalTreeModelFlags}, - {glib.Type(C.gtk_window_position_get_type()), marshalWindowPosition}, - {glib.Type(C.gtk_window_type_get_type()), marshalWindowType}, - {glib.Type(C.gtk_wrap_mode_get_type()), marshalWrapMode}, - - // Objects/Interfaces - {glib.Type(C.gtk_accel_group_get_type()), marshalAccelGroup}, - {glib.Type(C.gtk_accel_map_get_type()), marshalAccelMap}, - {glib.Type(C.gtk_adjustment_get_type()), marshalAdjustment}, - {glib.Type(C.gtk_application_get_type()), marshalApplication}, - {glib.Type(C.gtk_application_window_get_type()), marshalApplicationWindow}, - {glib.Type(C.gtk_assistant_get_type()), marshalAssistant}, - {glib.Type(C.gtk_bin_get_type()), marshalBin}, - {glib.Type(C.gtk_builder_get_type()), marshalBuilder}, - {glib.Type(C.gtk_button_get_type()), marshalButton}, - {glib.Type(C.gtk_box_get_type()), marshalBox}, - {glib.Type(C.gtk_calendar_get_type()), marshalCalendar}, - {glib.Type(C.gtk_cell_layout_get_type()), marshalCellLayout}, - {glib.Type(C.gtk_cell_renderer_get_type()), marshalCellRenderer}, - {glib.Type(C.gtk_cell_renderer_spinner_get_type()), marshalCellRendererSpinner}, - {glib.Type(C.gtk_cell_renderer_pixbuf_get_type()), marshalCellRendererPixbuf}, - {glib.Type(C.gtk_cell_renderer_text_get_type()), marshalCellRendererText}, - {glib.Type(C.gtk_cell_renderer_toggle_get_type()), marshalCellRendererToggle}, - {glib.Type(C.gtk_check_button_get_type()), marshalCheckButton}, - {glib.Type(C.gtk_check_menu_item_get_type()), marshalCheckMenuItem}, - {glib.Type(C.gtk_clipboard_get_type()), marshalClipboard}, - {glib.Type(C.gtk_container_get_type()), marshalContainer}, - {glib.Type(C.gtk_dialog_get_type()), marshalDialog}, - {glib.Type(C.gtk_drawing_area_get_type()), marshalDrawingArea}, - {glib.Type(C.gtk_editable_get_type()), marshalEditable}, - {glib.Type(C.gtk_entry_get_type()), marshalEntry}, - {glib.Type(C.gtk_entry_buffer_get_type()), marshalEntryBuffer}, - {glib.Type(C.gtk_entry_completion_get_type()), marshalEntryCompletion}, - {glib.Type(C.gtk_event_box_get_type()), marshalEventBox}, - {glib.Type(C.gtk_expander_get_type()), marshalExpander}, - {glib.Type(C.gtk_file_chooser_get_type()), marshalFileChooser}, - {glib.Type(C.gtk_file_chooser_button_get_type()), marshalFileChooserButton}, - {glib.Type(C.gtk_file_chooser_dialog_get_type()), marshalFileChooserDialog}, - {glib.Type(C.gtk_file_chooser_widget_get_type()), marshalFileChooserWidget}, - {glib.Type(C.gtk_font_button_get_type()), marshalFontButton}, - {glib.Type(C.gtk_frame_get_type()), marshalFrame}, - {glib.Type(C.gtk_grid_get_type()), marshalGrid}, - {glib.Type(C.gtk_icon_view_get_type()), marshalIconView}, - {glib.Type(C.gtk_image_get_type()), marshalImage}, - {glib.Type(C.gtk_label_get_type()), marshalLabel}, - {glib.Type(C.gtk_link_button_get_type()), marshalLinkButton}, - {glib.Type(C.gtk_layout_get_type()), marshalLayout}, - {glib.Type(C.gtk_list_store_get_type()), marshalListStore}, - {glib.Type(C.gtk_menu_get_type()), marshalMenu}, - {glib.Type(C.gtk_menu_bar_get_type()), marshalMenuBar}, - {glib.Type(C.gtk_menu_button_get_type()), marshalMenuButton}, - {glib.Type(C.gtk_menu_item_get_type()), marshalMenuItem}, - {glib.Type(C.gtk_menu_shell_get_type()), marshalMenuShell}, - {glib.Type(C.gtk_message_dialog_get_type()), marshalMessageDialog}, - {glib.Type(C.gtk_notebook_get_type()), marshalNotebook}, - {glib.Type(C.gtk_offscreen_window_get_type()), marshalOffscreenWindow}, - {glib.Type(C.gtk_orientable_get_type()), marshalOrientable}, - {glib.Type(C.gtk_paned_get_type()), marshalPaned}, - {glib.Type(C.gtk_progress_bar_get_type()), marshalProgressBar}, - {glib.Type(C.gtk_radio_button_get_type()), marshalRadioButton}, - {glib.Type(C.gtk_radio_menu_item_get_type()), marshalRadioMenuItem}, - {glib.Type(C.gtk_range_get_type()), marshalRange}, - {glib.Type(C.gtk_scale_button_get_type()), marshalScaleButton}, - {glib.Type(C.gtk_scale_get_type()), marshalScale}, - {glib.Type(C.gtk_scrollbar_get_type()), marshalScrollbar}, - {glib.Type(C.gtk_scrolled_window_get_type()), marshalScrolledWindow}, - {glib.Type(C.gtk_search_entry_get_type()), marshalSearchEntry}, - {glib.Type(C.gtk_selection_data_get_type()), marshalSelectionData}, - {glib.Type(C.gtk_separator_get_type()), marshalSeparator}, - {glib.Type(C.gtk_separator_menu_item_get_type()), marshalSeparatorMenuItem}, - {glib.Type(C.gtk_separator_tool_item_get_type()), marshalSeparatorToolItem}, - {glib.Type(C.gtk_spin_button_get_type()), marshalSpinButton}, - {glib.Type(C.gtk_spinner_get_type()), marshalSpinner}, - {glib.Type(C.gtk_statusbar_get_type()), marshalStatusbar}, - {glib.Type(C.gtk_switch_get_type()), marshalSwitch}, - {glib.Type(C.gtk_text_view_get_type()), marshalTextView}, - {glib.Type(C.gtk_text_tag_get_type()), marshalTextTag}, - {glib.Type(C.gtk_text_tag_table_get_type()), marshalTextTagTable}, - {glib.Type(C.gtk_text_buffer_get_type()), marshalTextBuffer}, - {glib.Type(C.gtk_toggle_button_get_type()), marshalToggleButton}, - {glib.Type(C.gtk_toolbar_get_type()), marshalToolbar}, - {glib.Type(C.gtk_tool_button_get_type()), marshalToolButton}, - {glib.Type(C.gtk_tool_item_get_type()), marshalToolItem}, - {glib.Type(C.gtk_tree_model_get_type()), marshalTreeModel}, - {glib.Type(C.gtk_tree_selection_get_type()), marshalTreeSelection}, - {glib.Type(C.gtk_tree_store_get_type()), marshalTreeStore}, - {glib.Type(C.gtk_tree_view_get_type()), marshalTreeView}, - {glib.Type(C.gtk_tree_view_column_get_type()), marshalTreeViewColumn}, - {glib.Type(C.gtk_volume_button_get_type()), marshalVolumeButton}, - {glib.Type(C.gtk_widget_get_type()), marshalWidget}, - {glib.Type(C.gtk_window_get_type()), marshalWindow}, - - // Boxed - {glib.Type(C.gtk_target_entry_get_type()), marshalTargetEntry}, - {glib.Type(C.gtk_text_iter_get_type()), marshalTextIter}, - {glib.Type(C.gtk_text_mark_get_type()), marshalTextMark}, - {glib.Type(C.gtk_tree_iter_get_type()), marshalTreeIter}, - {glib.Type(C.gtk_tree_path_get_type()), marshalTreePath}, - } - glib.RegisterGValueMarshalers(tm) -} - -/* - * Type conversions - */ - -func gbool(b bool) C.gboolean { - if b { - return C.gboolean(1) - } - return C.gboolean(0) -} - -func gobool(b C.gboolean) bool { - return b != C.FALSE -} - -// Wrapper function for new objects with reference management. -func wrapObject(ptr unsafe.Pointer) *glib.Object { - obj := &glib.Object{glib.ToGObject(ptr)} - - if obj.IsFloating() { - obj.RefSink() - } else { - obj.Ref() - } - - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return obj -} - -// Wrapper function for TestBoolConvs since cgo can't be used with -// testing package -func testBoolConvs() error { - b := gobool(gbool(true)) - if b != true { - return errors.New("Unexpected bool conversion result") - } - - cb := gbool(gobool(C.gboolean(0))) - if cb != C.gboolean(0) { - return errors.New("Unexpected bool conversion result") - } - - return nil -} - -/* - * Unexported vars - */ - -var nilPtrErr = errors.New("cgo returned unexpected nil pointer") - -/* - * Constants - */ - -// Align is a representation of GTK's GtkAlign. -type Align int - -const ( - ALIGN_FILL Align = C.GTK_ALIGN_FILL - ALIGN_START Align = C.GTK_ALIGN_START - ALIGN_END Align = C.GTK_ALIGN_END - ALIGN_CENTER Align = C.GTK_ALIGN_CENTER -) - -func marshalAlign(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return Align(c), nil -} - -// ArrowPlacement is a representation of GTK's GtkArrowPlacement. -type ArrowPlacement int - -const ( - ARROWS_BOTH ArrowPlacement = C.GTK_ARROWS_BOTH - ARROWS_START ArrowPlacement = C.GTK_ARROWS_START - ARROWS_END ArrowPlacement = C.GTK_ARROWS_END -) - -func marshalArrowPlacement(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return ArrowPlacement(c), nil -} - -// ArrowType is a representation of GTK's GtkArrowType. -type ArrowType int - -const ( - ARROW_UP ArrowType = C.GTK_ARROW_UP - ARROW_DOWN ArrowType = C.GTK_ARROW_DOWN - ARROW_LEFT ArrowType = C.GTK_ARROW_LEFT - ARROW_RIGHT ArrowType = C.GTK_ARROW_RIGHT - ARROW_NONE ArrowType = C.GTK_ARROW_NONE -) - -func marshalArrowType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return ArrowType(c), nil -} - -// AssistantPageType is a representation of GTK's GtkAssistantPageType. -type AssistantPageType int - -const ( - ASSISTANT_PAGE_CONTENT AssistantPageType = C.GTK_ASSISTANT_PAGE_CONTENT - ASSISTANT_PAGE_INTRO AssistantPageType = C.GTK_ASSISTANT_PAGE_INTRO - ASSISTANT_PAGE_CONFIRM AssistantPageType = C.GTK_ASSISTANT_PAGE_CONFIRM - ASSISTANT_PAGE_SUMMARY AssistantPageType = C.GTK_ASSISTANT_PAGE_SUMMARY - ASSISTANT_PAGE_PROGRESS AssistantPageType = C.GTK_ASSISTANT_PAGE_PROGRESS - ASSISTANT_PAGE_CUSTOM AssistantPageType = C.GTK_ASSISTANT_PAGE_CUSTOM -) - -func marshalAssistantPageType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return AssistantPageType(c), nil -} - -// ButtonsType is a representation of GTK's GtkButtonsType. -type ButtonsType int - -const ( - BUTTONS_NONE ButtonsType = C.GTK_BUTTONS_NONE - BUTTONS_OK ButtonsType = C.GTK_BUTTONS_OK - BUTTONS_CLOSE ButtonsType = C.GTK_BUTTONS_CLOSE - BUTTONS_CANCEL ButtonsType = C.GTK_BUTTONS_CANCEL - BUTTONS_YES_NO ButtonsType = C.GTK_BUTTONS_YES_NO - BUTTONS_OK_CANCEL ButtonsType = C.GTK_BUTTONS_OK_CANCEL -) - -func marshalButtonsType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return ButtonsType(c), nil -} - -// CalendarDisplayOptions is a representation of GTK's GtkCalendarDisplayOptions -type CalendarDisplayOptions int - -const ( - CALENDAR_SHOW_HEADING CalendarDisplayOptions = C.GTK_CALENDAR_SHOW_HEADING - CALENDAR_SHOW_DAY_NAMES CalendarDisplayOptions = C.GTK_CALENDAR_SHOW_DAY_NAMES - CALENDAR_NO_MONTH_CHANGE CalendarDisplayOptions = C.GTK_CALENDAR_NO_MONTH_CHANGE - CALENDAR_SHOW_WEEK_NUMBERS CalendarDisplayOptions = C.GTK_CALENDAR_SHOW_WEEK_NUMBERS - CALENDAR_SHOW_DETAILS CalendarDisplayOptions = C.GTK_CALENDAR_SHOW_DETAILS -) - -func marshalCalendarDisplayOptions(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return CalendarDisplayOptions(c), nil -} - -// DestDefaults is a representation of GTK's GtkDestDefaults. -type DestDefaults int - -const ( - DEST_DEFAULT_MOTION DestDefaults = C.GTK_DEST_DEFAULT_MOTION - DEST_DEFAULT_HIGHLIGHT DestDefaults = C.GTK_DEST_DEFAULT_HIGHLIGHT - DEST_DEFAULT_DROP DestDefaults = C.GTK_DEST_DEFAULT_DROP - DEST_DEFAULT_ALL DestDefaults = C.GTK_DEST_DEFAULT_ALL -) - -func marshalDestDefaults(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return DestDefaults(c), nil -} - -// DialogFlags is a representation of GTK's GtkDialogFlags. -type DialogFlags int - -const ( - DIALOG_MODAL DialogFlags = C.GTK_DIALOG_MODAL - DIALOG_DESTROY_WITH_PARENT DialogFlags = C.GTK_DIALOG_DESTROY_WITH_PARENT -) - -func marshalDialogFlags(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return DialogFlags(c), nil -} - -// EntryIconPosition is a representation of GTK's GtkEntryIconPosition. -type EntryIconPosition int - -const ( - ENTRY_ICON_PRIMARY EntryIconPosition = C.GTK_ENTRY_ICON_PRIMARY - ENTRY_ICON_SECONDARY EntryIconPosition = C.GTK_ENTRY_ICON_SECONDARY -) - -func marshalEntryIconPosition(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return EntryIconPosition(c), nil -} - -// FileChooserAction is a representation of GTK's GtkFileChooserAction. -type FileChooserAction int - -const ( - FILE_CHOOSER_ACTION_OPEN FileChooserAction = C.GTK_FILE_CHOOSER_ACTION_OPEN - FILE_CHOOSER_ACTION_SAVE FileChooserAction = C.GTK_FILE_CHOOSER_ACTION_SAVE - FILE_CHOOSER_ACTION_SELECT_FOLDER FileChooserAction = C.GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER - FILE_CHOOSER_ACTION_CREATE_FOLDER FileChooserAction = C.GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER -) - -func marshalFileChooserAction(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return FileChooserAction(c), nil -} - -// IconLookupFlags is a representation of GTK's GtkIconLookupFlags. -type IconLookupFlags int - -const ( - ICON_LOOKUP_NO_SVG IconLookupFlags = C.GTK_ICON_LOOKUP_NO_SVG - ICON_LOOKUP_FORCE_SVG = C.GTK_ICON_LOOKUP_FORCE_SVG - ICON_LOOKUP_USE_BUILTIN = C.GTK_ICON_LOOKUP_USE_BUILTIN - ICON_LOOKUP_GENERIC_FALLBACK = C.GTK_ICON_LOOKUP_GENERIC_FALLBACK - ICON_LOOKUP_FORCE_SIZE = C.GTK_ICON_LOOKUP_FORCE_SIZE -) - -func marshalIconLookupFlags(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return IconLookupFlags(c), nil -} - -// IconSize is a representation of GTK's GtkIconSize. -type IconSize int - -const ( - ICON_SIZE_INVALID IconSize = C.GTK_ICON_SIZE_INVALID - ICON_SIZE_MENU IconSize = C.GTK_ICON_SIZE_MENU - ICON_SIZE_SMALL_TOOLBAR IconSize = C.GTK_ICON_SIZE_SMALL_TOOLBAR - ICON_SIZE_LARGE_TOOLBAR IconSize = C.GTK_ICON_SIZE_LARGE_TOOLBAR - ICON_SIZE_BUTTON IconSize = C.GTK_ICON_SIZE_BUTTON - ICON_SIZE_DND IconSize = C.GTK_ICON_SIZE_DND - ICON_SIZE_DIALOG IconSize = C.GTK_ICON_SIZE_DIALOG -) - -func marshalIconSize(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return IconSize(c), nil -} - -// ImageType is a representation of GTK's GtkImageType. -type ImageType int - -const ( - IMAGE_EMPTY ImageType = C.GTK_IMAGE_EMPTY - IMAGE_PIXBUF ImageType = C.GTK_IMAGE_PIXBUF - IMAGE_STOCK ImageType = C.GTK_IMAGE_STOCK - IMAGE_ICON_SET ImageType = C.GTK_IMAGE_ICON_SET - IMAGE_ANIMATION ImageType = C.GTK_IMAGE_ANIMATION - IMAGE_ICON_NAME ImageType = C.GTK_IMAGE_ICON_NAME - IMAGE_GICON ImageType = C.GTK_IMAGE_GICON -) - -func marshalImageType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return ImageType(c), nil -} - -// InputHints is a representation of GTK's GtkInputHints. -type InputHints int - -const ( - INPUT_HINT_NONE InputHints = C.GTK_INPUT_HINT_NONE - INPUT_HINT_SPELLCHECK InputHints = C.GTK_INPUT_HINT_SPELLCHECK - INPUT_HINT_NO_SPELLCHECK InputHints = C.GTK_INPUT_HINT_NO_SPELLCHECK - INPUT_HINT_WORD_COMPLETION InputHints = C.GTK_INPUT_HINT_WORD_COMPLETION - INPUT_HINT_LOWERCASE InputHints = C.GTK_INPUT_HINT_LOWERCASE - INPUT_HINT_UPPERCASE_CHARS InputHints = C.GTK_INPUT_HINT_UPPERCASE_CHARS - INPUT_HINT_UPPERCASE_WORDS InputHints = C.GTK_INPUT_HINT_UPPERCASE_WORDS - INPUT_HINT_UPPERCASE_SENTENCES InputHints = C.GTK_INPUT_HINT_UPPERCASE_SENTENCES - INPUT_HINT_INHIBIT_OSK InputHints = C.GTK_INPUT_HINT_INHIBIT_OSK -) - -func marshalInputHints(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return InputHints(c), nil -} - -// InputPurpose is a representation of GTK's GtkInputPurpose. -type InputPurpose int - -const ( - INPUT_PURPOSE_FREE_FORM InputPurpose = C.GTK_INPUT_PURPOSE_FREE_FORM - INPUT_PURPOSE_ALPHA InputPurpose = C.GTK_INPUT_PURPOSE_ALPHA - INPUT_PURPOSE_DIGITS InputPurpose = C.GTK_INPUT_PURPOSE_DIGITS - INPUT_PURPOSE_NUMBER InputPurpose = C.GTK_INPUT_PURPOSE_NUMBER - INPUT_PURPOSE_PHONE InputPurpose = C.GTK_INPUT_PURPOSE_PHONE - INPUT_PURPOSE_URL InputPurpose = C.GTK_INPUT_PURPOSE_URL - INPUT_PURPOSE_EMAIL InputPurpose = C.GTK_INPUT_PURPOSE_EMAIL - INPUT_PURPOSE_NAME InputPurpose = C.GTK_INPUT_PURPOSE_NAME - INPUT_PURPOSE_PASSWORD InputPurpose = C.GTK_INPUT_PURPOSE_PASSWORD - INPUT_PURPOSE_PIN InputPurpose = C.GTK_INPUT_PURPOSE_PIN -) - -func marshalInputPurpose(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return InputPurpose(c), nil -} - -// Justify is a representation of GTK's GtkJustification. -type Justification int - -const ( - JUSTIFY_LEFT Justification = C.GTK_JUSTIFY_LEFT - JUSTIFY_RIGHT Justification = C.GTK_JUSTIFY_RIGHT - JUSTIFY_CENTER Justification = C.GTK_JUSTIFY_CENTER - JUSTIFY_FILL Justification = C.GTK_JUSTIFY_FILL -) - -func marshalJustification(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return Justification(c), nil -} - -// License is a representation of GTK's GtkLicense. -type License int - -const ( - LICENSE_UNKNOWN License = C.GTK_LICENSE_UNKNOWN - LICENSE_CUSTOM License = C.GTK_LICENSE_CUSTOM - LICENSE_GPL_2_0 License = C.GTK_LICENSE_GPL_2_0 - LICENSE_GPL_3_0 License = C.GTK_LICENSE_GPL_3_0 - LICENSE_LGPL_2_1 License = C.GTK_LICENSE_LGPL_2_1 - LICENSE_LGPL_3_0 License = C.GTK_LICENSE_LGPL_3_0 - LICENSE_BSD License = C.GTK_LICENSE_BSD - LICENSE_MIT_X11 License = C.GTK_LICENSE_MIT_X11 - LICENSE_GTK_ARTISTIC License = C.GTK_LICENSE_ARTISTIC -) - -func marshalLicense(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return License(c), nil -} - -// MessageType is a representation of GTK's GtkMessageType. -type MessageType int - -const ( - MESSAGE_INFO MessageType = C.GTK_MESSAGE_INFO - MESSAGE_WARNING MessageType = C.GTK_MESSAGE_WARNING - MESSAGE_QUESTION MessageType = C.GTK_MESSAGE_QUESTION - MESSAGE_ERROR MessageType = C.GTK_MESSAGE_ERROR - MESSAGE_OTHER MessageType = C.GTK_MESSAGE_OTHER -) - -func marshalMessageType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return MessageType(c), nil -} - -// Orientation is a representation of GTK's GtkOrientation. -type Orientation int - -const ( - ORIENTATION_HORIZONTAL Orientation = C.GTK_ORIENTATION_HORIZONTAL - ORIENTATION_VERTICAL Orientation = C.GTK_ORIENTATION_VERTICAL -) - -func marshalOrientation(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return Orientation(c), nil -} - -// PackType is a representation of GTK's GtkPackType. -type PackType int - -const ( - PACK_START PackType = C.GTK_PACK_START - PACK_END PackType = C.GTK_PACK_END -) - -func marshalPackType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return PackType(c), nil -} - -// PathType is a representation of GTK's GtkPathType. -type PathType int - -const ( - PATH_WIDGET PathType = C.GTK_PATH_WIDGET - PATH_WIDGET_CLASS PathType = C.GTK_PATH_WIDGET_CLASS - PATH_CLASS PathType = C.GTK_PATH_CLASS -) - -func marshalPathType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return PathType(c), nil -} - -// PolicyType is a representation of GTK's GtkPolicyType. -type PolicyType int - -const ( - POLICY_ALWAYS PolicyType = C.GTK_POLICY_ALWAYS - POLICY_AUTOMATIC PolicyType = C.GTK_POLICY_AUTOMATIC - POLICY_NEVER PolicyType = C.GTK_POLICY_NEVER -) - -func marshalPolicyType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return PolicyType(c), nil -} - -// PositionType is a representation of GTK's GtkPositionType. -type PositionType int - -const ( - POS_LEFT PositionType = C.GTK_POS_LEFT - POS_RIGHT PositionType = C.GTK_POS_RIGHT - POS_TOP PositionType = C.GTK_POS_TOP - POS_BOTTOM PositionType = C.GTK_POS_BOTTOM -) - -func marshalPositionType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return PositionType(c), nil -} - -// ReliefStyle is a representation of GTK's GtkReliefStyle. -type ReliefStyle int - -const ( - RELIEF_NORMAL ReliefStyle = C.GTK_RELIEF_NORMAL - RELIEF_HALF ReliefStyle = C.GTK_RELIEF_HALF - RELIEF_NONE ReliefStyle = C.GTK_RELIEF_NONE -) - -func marshalReliefStyle(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return ReliefStyle(c), nil -} - -// ResponseType is a representation of GTK's GtkResponseType. -type ResponseType int - -const ( - RESPONSE_NONE ResponseType = C.GTK_RESPONSE_NONE - RESPONSE_REJECT ResponseType = C.GTK_RESPONSE_REJECT - RESPONSE_ACCEPT ResponseType = C.GTK_RESPONSE_ACCEPT - RESPONSE_DELETE_EVENT ResponseType = C.GTK_RESPONSE_DELETE_EVENT - RESPONSE_OK ResponseType = C.GTK_RESPONSE_OK - RESPONSE_CANCEL ResponseType = C.GTK_RESPONSE_CANCEL - RESPONSE_CLOSE ResponseType = C.GTK_RESPONSE_CLOSE - RESPONSE_YES ResponseType = C.GTK_RESPONSE_YES - RESPONSE_NO ResponseType = C.GTK_RESPONSE_NO - RESPONSE_APPLY ResponseType = C.GTK_RESPONSE_APPLY - RESPONSE_HELP ResponseType = C.GTK_RESPONSE_HELP -) - -func marshalResponseType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return ResponseType(c), nil -} - -// SelectionMode is a representation of GTK's GtkSelectionMode. -type SelectionMode int - -const ( - SELECTION_NONE SelectionMode = C.GTK_SELECTION_NONE - SELECTION_SINGLE SelectionMode = C.GTK_SELECTION_SINGLE - SELECTION_BROWSE SelectionMode = C.GTK_SELECTION_BROWSE - SELECTION_MULTIPLE SelectionMode = C.GTK_SELECTION_MULTIPLE -) - -func marshalSelectionMode(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return SelectionMode(c), nil -} - -// ShadowType is a representation of GTK's GtkShadowType. -type ShadowType int - -const ( - SHADOW_NONE ShadowType = C.GTK_SHADOW_NONE - SHADOW_IN ShadowType = C.GTK_SHADOW_IN - SHADOW_OUT ShadowType = C.GTK_SHADOW_OUT - SHADOW_ETCHED_IN ShadowType = C.GTK_SHADOW_ETCHED_IN - SHADOW_ETCHED_OUT ShadowType = C.GTK_SHADOW_ETCHED_OUT -) - -func marshalShadowType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return ShadowType(c), nil -} - -// SizeGroupMode is a representation of GTK's GtkSizeGroupMode -type SizeGroupMode int - -const ( - SIZE_GROUP_NONE SizeGroupMode = C.GTK_SIZE_GROUP_NONE - SIZE_GROUP_HORIZONTAL SizeGroupMode = C.GTK_SIZE_GROUP_HORIZONTAL - SIZE_GROUP_VERTICAL SizeGroupMode = C.GTK_SIZE_GROUP_VERTICAL - SIZE_GROUP_BOTH SizeGroupMode = C.GTK_SIZE_GROUP_BOTH -) - -func marshalSizeGroupMode(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return SizeGroupMode(c), nil -} - -// SortType is a representation of GTK's GtkSortType. -type SortType int - -const ( - SORT_ASCENDING SortType = C.GTK_SORT_ASCENDING - SORT_DESCENDING = C.GTK_SORT_DESCENDING -) - -func marshalSortType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return SortType(c), nil -} - -// StateFlags is a representation of GTK's GtkStateFlags. -type StateFlags int - -const ( - STATE_FLAG_NORMAL StateFlags = C.GTK_STATE_FLAG_NORMAL - STATE_FLAG_ACTIVE StateFlags = C.GTK_STATE_FLAG_ACTIVE - STATE_FLAG_PRELIGHT StateFlags = C.GTK_STATE_FLAG_PRELIGHT - STATE_FLAG_SELECTED StateFlags = C.GTK_STATE_FLAG_SELECTED - STATE_FLAG_INSENSITIVE StateFlags = C.GTK_STATE_FLAG_INSENSITIVE - STATE_FLAG_INCONSISTENT StateFlags = C.GTK_STATE_FLAG_INCONSISTENT - STATE_FLAG_FOCUSED StateFlags = C.GTK_STATE_FLAG_FOCUSED - STATE_FLAG_BACKDROP StateFlags = C.GTK_STATE_FLAG_BACKDROP -) - -func marshalStateFlags(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return StateFlags(c), nil -} - -// TargetFlags is a representation of GTK's GtkTargetFlags. -type TargetFlags int - -const ( - TARGET_SAME_APP TargetFlags = C.GTK_TARGET_SAME_APP - TARGET_SAME_WIDGET TargetFlags = C.GTK_TARGET_SAME_WIDGET - TARGET_OTHER_APP TargetFlags = C.GTK_TARGET_OTHER_APP - TARGET_OTHER_WIDGET TargetFlags = C.GTK_TARGET_OTHER_WIDGET -) - -func marshalTargetFlags(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return TargetFlags(c), nil -} - -// ToolbarStyle is a representation of GTK's GtkToolbarStyle. -type ToolbarStyle int - -const ( - TOOLBAR_ICONS ToolbarStyle = C.GTK_TOOLBAR_ICONS - TOOLBAR_TEXT ToolbarStyle = C.GTK_TOOLBAR_TEXT - TOOLBAR_BOTH ToolbarStyle = C.GTK_TOOLBAR_BOTH - TOOLBAR_BOTH_HORIZ ToolbarStyle = C.GTK_TOOLBAR_BOTH_HORIZ -) - -func marshalToolbarStyle(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return ToolbarStyle(c), nil -} - -// TreeModelFlags is a representation of GTK's GtkTreeModelFlags. -type TreeModelFlags int - -const ( - TREE_MODEL_ITERS_PERSIST TreeModelFlags = C.GTK_TREE_MODEL_ITERS_PERSIST - TREE_MODEL_LIST_ONLY TreeModelFlags = C.GTK_TREE_MODEL_LIST_ONLY -) - -func marshalTreeModelFlags(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return TreeModelFlags(c), nil -} - -// WindowPosition is a representation of GTK's GtkWindowPosition. -type WindowPosition int - -const ( - WIN_POS_NONE WindowPosition = C.GTK_WIN_POS_NONE - WIN_POS_CENTER WindowPosition = C.GTK_WIN_POS_CENTER - WIN_POS_MOUSE WindowPosition = C.GTK_WIN_POS_MOUSE - WIN_POS_CENTER_ALWAYS WindowPosition = C.GTK_WIN_POS_CENTER_ALWAYS - WIN_POS_CENTER_ON_PARENT WindowPosition = C.GTK_WIN_POS_CENTER_ON_PARENT -) - -func marshalWindowPosition(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return WindowPosition(c), nil -} - -// WindowType is a representation of GTK's GtkWindowType. -type WindowType int - -const ( - WINDOW_TOPLEVEL WindowType = C.GTK_WINDOW_TOPLEVEL - WINDOW_POPUP WindowType = C.GTK_WINDOW_POPUP -) - -func marshalWindowType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return WindowType(c), nil -} - -// WrapMode is a representation of GTK's GtkWrapMode. -type WrapMode int - -const ( - WRAP_NONE WrapMode = C.GTK_WRAP_NONE - WRAP_CHAR WrapMode = C.GTK_WRAP_CHAR - WRAP_WORD WrapMode = C.GTK_WRAP_WORD - WRAP_WORD_CHAR WrapMode = C.GTK_WRAP_WORD_CHAR -) - -func marshalWrapMode(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return WrapMode(c), nil -} - -/* - * Init and main event loop - */ - -/* -Init() is a wrapper around gtk_init() and must be called before any -other GTK calls and is used to initialize everything necessary. - -In addition to setting up GTK for usage, a pointer to a slice of -strings may be passed in to parse standard GTK command line arguments. -args will be modified to remove any flags that were handled. -Alternatively, nil may be passed in to not perform any command line -parsing. -*/ -func Init(args *[]string) { - if args != nil { - argc := C.int(len(*args)) - argv := C.make_strings(argc) - defer C.destroy_strings(argv) - - for i, arg := range *args { - cstr := C.CString(arg) - C.set_string(argv, C.int(i), (*C.gchar)(cstr)) - } - - C.gtk_init((*C.int)(unsafe.Pointer(&argc)), - (***C.char)(unsafe.Pointer(&argv))) - - unhandled := make([]string, argc) - for i := 0; i < int(argc); i++ { - cstr := C.get_string(argv, C.int(i)) - unhandled[i] = C.GoString((*C.char)(cstr)) - C.free(unsafe.Pointer(cstr)) - } - *args = unhandled - } else { - C.gtk_init(nil, nil) - } -} - -// Main() is a wrapper around gtk_main() and runs the GTK main loop, -// blocking until MainQuit() is called. -func Main() { - C.gtk_main() -} - -// MainIteration is a wrapper around gtk_main_iteration. -func MainIteration() bool { - return gobool(C.gtk_main_iteration()) -} - -// MainIterationDo is a wrapper around gtk_main_iteration_do. -func MainIterationDo(blocking bool) bool { - return gobool(C.gtk_main_iteration_do(gbool(blocking))) -} - -// EventsPending is a wrapper around gtk_events_pending. -func EventsPending() bool { - return gobool(C.gtk_events_pending()) -} - -// MainQuit() is a wrapper around gtk_main_quit() is used to terminate -// the GTK main loop (started by Main()). -func MainQuit() { - C.gtk_main_quit() -} - -/* - * GtkAdjustment - */ - -// Adjustment is a representation of GTK's GtkAdjustment. -type Adjustment struct { - glib.InitiallyUnowned -} - -// native returns a pointer to the underlying GtkAdjustment. -func (v *Adjustment) native() *C.GtkAdjustment { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkAdjustment(p) -} - -func marshalAdjustment(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapAdjustment(obj), nil -} - -func wrapAdjustment(obj *glib.Object) *Adjustment { - return &Adjustment{glib.InitiallyUnowned{obj}} -} - -// AdjustmentNew is a wrapper around gtk_adjustment_new(). -func AdjustmentNew(value, lower, upper, stepIncrement, pageIncrement, pageSize float64) (*Adjustment, error) { - c := C.gtk_adjustment_new(C.gdouble(value), - C.gdouble(lower), - C.gdouble(upper), - C.gdouble(stepIncrement), - C.gdouble(pageIncrement), - C.gdouble(pageSize)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapAdjustment(obj), nil -} - -// GetValue is a wrapper around gtk_adjustment_get_value(). -func (v *Adjustment) GetValue() float64 { - c := C.gtk_adjustment_get_value(v.native()) - return float64(c) -} - -// SetValue is a wrapper around gtk_adjustment_set_value(). -func (v *Adjustment) SetValue(value float64) { - C.gtk_adjustment_set_value(v.native(), C.gdouble(value)) -} - -// GetLower is a wrapper around gtk_adjustment_get_lower(). -func (v *Adjustment) GetLower() float64 { - c := C.gtk_adjustment_get_lower(v.native()) - return float64(c) -} - -// GetPageSize is a wrapper around gtk_adjustment_get_page_size(). -func (v *Adjustment) GetPageSize() float64 { - return float64(C.gtk_adjustment_get_page_size(v.native())) -} - -// SetPageSize is a wrapper around gtk_adjustment_set_page_size(). -func (v *Adjustment) SetPageSize(value float64) { - C.gtk_adjustment_set_page_size(v.native(), C.gdouble(value)) -} - -// Configure is a wrapper around gtk_adjustment_configure(). -func (v *Adjustment) Configure(value, lower, upper, stepIncrement, pageIncrement, pageSize float64) { - C.gtk_adjustment_configure(v.native(), C.gdouble(value), - C.gdouble(lower), C.gdouble(upper), C.gdouble(stepIncrement), - C.gdouble(pageIncrement), C.gdouble(pageSize)) -} - -// SetLower is a wrapper around gtk_adjustment_set_lower(). -func (v *Adjustment) SetLower(value float64) { - C.gtk_adjustment_set_lower(v.native(), C.gdouble(value)) -} - -// GetUpper is a wrapper around gtk_adjustment_get_upper(). -func (v *Adjustment) GetUpper() float64 { - c := C.gtk_adjustment_get_upper(v.native()) - return float64(c) -} - -// SetUpper is a wrapper around gtk_adjustment_set_upper(). -func (v *Adjustment) SetUpper(value float64) { - C.gtk_adjustment_set_upper(v.native(), C.gdouble(value)) -} - -// GetPageIncrement is a wrapper around gtk_adjustment_get_page_increment(). -func (v *Adjustment) GetPageIncrement() float64 { - c := C.gtk_adjustment_get_page_increment(v.native()) - return float64(c) -} - -// SetPageIncrement is a wrapper around gtk_adjustment_set_page_increment(). -func (v *Adjustment) SetPageIncrement(value float64) { - C.gtk_adjustment_set_page_increment(v.native(), C.gdouble(value)) -} - -// GetStepIncrement is a wrapper around gtk_adjustment_get_step_increment(). -func (v *Adjustment) GetStepIncrement() float64 { - c := C.gtk_adjustment_get_step_increment(v.native()) - return float64(c) -} - -// SetStepIncrement is a wrapper around gtk_adjustment_set_step_increment(). -func (v *Adjustment) SetStepIncrement(value float64) { - C.gtk_adjustment_set_step_increment(v.native(), C.gdouble(value)) -} - -// GetMinimumIncrement is a wrapper around gtk_adjustment_get_minimum_increment(). -func (v *Adjustment) GetMinimumIncrement() float64 { - c := C.gtk_adjustment_get_minimum_increment(v.native()) - return float64(c) -} - -/* -void gtk_adjustment_clamp_page () -void gtk_adjustment_changed () -void gtk_adjustment_value_changed () -void gtk_adjustment_configure () -*/ - -/* - * GtkAssistant - */ - -// Assistant is a representation of GTK's GtkAssistant. -type Assistant struct { - Window -} - -// native returns a pointer to the underlying GtkAssistant. -func (v *Assistant) native() *C.GtkAssistant { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkAssistant(p) -} - -func marshalAssistant(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapAssistant(obj), nil -} - -func wrapAssistant(obj *glib.Object) *Assistant { - return &Assistant{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}} -} - -// AssistantNew is a wrapper around gtk_assistant_new(). -func AssistantNew() (*Assistant, error) { - c := C.gtk_assistant_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapAssistant(obj), nil -} - -// GetCurrentPage is a wrapper around gtk_assistant_get_current_page(). -func (v *Assistant) GetCurrentPage() int { - c := C.gtk_assistant_get_current_page(v.native()) - return int(c) -} - -// SetCurrentPage is a wrapper around gtk_assistant_set_current_page(). -func (v *Assistant) SetCurrentPage(pageNum int) { - C.gtk_assistant_set_current_page(v.native(), C.gint(pageNum)) -} - -// GetNPages is a wrapper around gtk_assistant_get_n_pages(). -func (v *Assistant) GetNPages() int { - c := C.gtk_assistant_get_n_pages(v.native()) - return int(c) -} - -// GetNthPage is a wrapper around gtk_assistant_get_nth_page(). -func (v *Assistant) GetNthPage(pageNum int) (*Widget, error) { - c := C.gtk_assistant_get_nth_page(v.native(), C.gint(pageNum)) - if c == nil { - return nil, fmt.Errorf("page %d is out of bounds", pageNum) - } - - obj := wrapObject(unsafe.Pointer(c)) - return wrapWidget(obj), nil -} - -// PrependPage is a wrapper around gtk_assistant_prepend_page(). -func (v *Assistant) PrependPage(page IWidget) int { - c := C.gtk_assistant_prepend_page(v.native(), page.toWidget()) - return int(c) -} - -// AppendPage is a wrapper around gtk_assistant_append_page(). -func (v *Assistant) AppendPage(page IWidget) int { - c := C.gtk_assistant_append_page(v.native(), page.toWidget()) - return int(c) -} - -// InsertPage is a wrapper around gtk_assistant_insert_page(). -func (v *Assistant) InsertPage(page IWidget, position int) int { - c := C.gtk_assistant_insert_page(v.native(), page.toWidget(), - C.gint(position)) - return int(c) -} - -// RemovePage is a wrapper around gtk_assistant_remove_page(). -func (v *Assistant) RemovePage(pageNum int) { - C.gtk_assistant_remove_page(v.native(), C.gint(pageNum)) -} - -// TODO: gtk_assistant_set_forward_page_func - -// SetPageType is a wrapper around gtk_assistant_set_page_type(). -func (v *Assistant) SetPageType(page IWidget, ptype AssistantPageType) { - C.gtk_assistant_set_page_type(v.native(), page.toWidget(), - C.GtkAssistantPageType(ptype)) -} - -// GetPageType is a wrapper around gtk_assistant_get_page_type(). -func (v *Assistant) GetPageType(page IWidget) AssistantPageType { - c := C.gtk_assistant_get_page_type(v.native(), page.toWidget()) - return AssistantPageType(c) -} - -// SetPageTitle is a wrapper around gtk_assistant_set_page_title(). -func (v *Assistant) SetPageTitle(page IWidget, title string) { - cstr := C.CString(title) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_assistant_set_page_title(v.native(), page.toWidget(), - (*C.gchar)(cstr)) -} - -// GetPageTitle is a wrapper around gtk_assistant_get_page_title(). -func (v *Assistant) GetPageTitle(page IWidget) string { - c := C.gtk_assistant_get_page_title(v.native(), page.toWidget()) - return C.GoString((*C.char)(c)) -} - -// SetPageComplete is a wrapper around gtk_assistant_set_page_complete(). -func (v *Assistant) SetPageComplete(page IWidget, complete bool) { - C.gtk_assistant_set_page_complete(v.native(), page.toWidget(), - gbool(complete)) -} - -// GetPageComplete is a wrapper around gtk_assistant_get_page_complete(). -func (v *Assistant) GetPageComplete(page IWidget) bool { - c := C.gtk_assistant_get_page_complete(v.native(), page.toWidget()) - return gobool(c) -} - -// AddActionWidget is a wrapper around gtk_assistant_add_action_widget(). -func (v *Assistant) AddActionWidget(child IWidget) { - C.gtk_assistant_add_action_widget(v.native(), child.toWidget()) -} - -// RemoveActionWidget is a wrapper around gtk_assistant_remove_action_widget(). -func (v *Assistant) RemoveActionWidget(child IWidget) { - C.gtk_assistant_remove_action_widget(v.native(), child.toWidget()) -} - -// UpdateButtonsState is a wrapper around gtk_assistant_update_buttons_state(). -func (v *Assistant) UpdateButtonsState() { - C.gtk_assistant_update_buttons_state(v.native()) -} - -// Commit is a wrapper around gtk_assistant_commit(). -func (v *Assistant) Commit() { - C.gtk_assistant_commit(v.native()) -} - -// NextPage is a wrapper around gtk_assistant_next_page(). -func (v *Assistant) NextPage() { - C.gtk_assistant_next_page(v.native()) -} - -// PreviousPage is a wrapper around gtk_assistant_previous_page(). -func (v *Assistant) PreviousPage() { - C.gtk_assistant_previous_page(v.native()) -} - -/* - * GtkBin - */ - -// Bin is a representation of GTK's GtkBin. -type Bin struct { - Container -} - -// native returns a pointer to the underlying GtkBin. -func (v *Bin) native() *C.GtkBin { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkBin(p) -} - -func marshalBin(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapBin(obj), nil -} - -func wrapBin(obj *glib.Object) *Bin { - return &Bin{Container{Widget{glib.InitiallyUnowned{obj}}}} -} - -// GetChild is a wrapper around gtk_bin_get_child(). -func (v *Bin) GetChild() (*Widget, error) { - c := C.gtk_bin_get_child(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapWidget(obj), nil -} - -/* - * GtkBuilder - */ - -// Builder is a representation of GTK's GtkBuilder. -type Builder struct { - *glib.Object -} - -// native() returns a pointer to the underlying GtkBuilder. -func (b *Builder) native() *C.GtkBuilder { - if b == nil || b.GObject == nil { - return nil - } - p := unsafe.Pointer(b.GObject) - return C.toGtkBuilder(p) -} - -func marshalBuilder(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return &Builder{obj}, nil -} - -// BuilderNew is a wrapper around gtk_builder_new(). -func BuilderNew() (*Builder, error) { - c := C.gtk_builder_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return &Builder{obj}, nil -} - -// AddFromFile is a wrapper around gtk_builder_add_from_file(). -func (b *Builder) AddFromFile(filename string) error { - cstr := C.CString(filename) - defer C.free(unsafe.Pointer(cstr)) - var err *C.GError = nil - res := C.gtk_builder_add_from_file(b.native(), (*C.gchar)(cstr), &err) - if res == 0 { - defer C.g_error_free(err) - return errors.New(C.GoString((*C.char)(err.message))) - } - return nil -} - -// AddFromResource is a wrapper around gtk_builder_add_from_resource(). -func (b *Builder) AddFromResource(path string) error { - cstr := C.CString(path) - defer C.free(unsafe.Pointer(cstr)) - var err *C.GError = nil - res := C.gtk_builder_add_from_resource(b.native(), (*C.gchar)(cstr), &err) - if res == 0 { - defer C.g_error_free(err) - return errors.New(C.GoString((*C.char)(err.message))) - } - return nil -} - -// AddFromString is a wrapper around gtk_builder_add_from_string(). -func (b *Builder) AddFromString(str string) error { - cstr := C.CString(str) - defer C.free(unsafe.Pointer(cstr)) - length := (C.gsize)(len(str)) - var err *C.GError = nil - res := C.gtk_builder_add_from_string(b.native(), (*C.gchar)(cstr), length, &err) - if res == 0 { - defer C.g_error_free(err) - return errors.New(C.GoString((*C.char)(err.message))) - } - return nil -} - -// GetObject is a wrapper around gtk_builder_get_object(). The returned result -// is an IObject, so it will need to be type-asserted to the appropriate type before -// being used. For example, to get an object and type assert it as a window: -// -// obj, err := builder.GetObject("window") -// if err != nil { -// // object not found -// return -// } -// if w, ok := obj.(*gtk.Window); ok { -// // do stuff with w here -// } else { -// // not a *gtk.Window -// } -// -func (b *Builder) GetObject(name string) (glib.IObject, error) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_builder_get_object(b.native(), (*C.gchar)(cstr)) - if c == nil { - return nil, errors.New("object '" + name + "' not found") - } - obj, err := cast(c) - if err != nil { - return nil, err - } - return obj, nil -} - -var ( - builderSignals = struct { - sync.RWMutex - m map[*C.GtkBuilder]map[string]interface{} - }{ - m: make(map[*C.GtkBuilder]map[string]interface{}), - } -) - -// ConnectSignals is a wrapper around gtk_builder_connect_signals_full(). -func (b *Builder) ConnectSignals(signals map[string]interface{}) { - builderSignals.Lock() - builderSignals.m[b.native()] = signals - builderSignals.Unlock() - - C._gtk_builder_connect_signals_full(b.native()) -} - -/* - * GtkButton - */ - -// Button is a representation of GTK's GtkButton. -type Button struct { - Bin -} - -// native() returns a pointer to the underlying GtkButton. -func (v *Button) native() *C.GtkButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkButton(p) -} - -func marshalButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapButton(obj), nil -} - -func wrapButton(obj *glib.Object) *Button { - return &Button{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// ButtonNew() is a wrapper around gtk_button_new(). -func ButtonNew() (*Button, error) { - c := C.gtk_button_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapButton(obj), nil -} - -// ButtonNewWithLabel() is a wrapper around gtk_button_new_with_label(). -func ButtonNewWithLabel(label string) (*Button, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_button_new_with_label((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapButton(obj), nil -} - -// ButtonNewWithMnemonic() is a wrapper around gtk_button_new_with_mnemonic(). -func ButtonNewWithMnemonic(label string) (*Button, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_button_new_with_mnemonic((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapButton(obj), nil -} - -// Clicked() is a wrapper around gtk_button_clicked(). -func (v *Button) Clicked() { - C.gtk_button_clicked(v.native()) -} - -// SetRelief() is a wrapper around gtk_button_set_relief(). -func (v *Button) SetRelief(newStyle ReliefStyle) { - C.gtk_button_set_relief(v.native(), C.GtkReliefStyle(newStyle)) -} - -// GetRelief() is a wrapper around gtk_button_get_relief(). -func (v *Button) GetRelief() ReliefStyle { - c := C.gtk_button_get_relief(v.native()) - return ReliefStyle(c) -} - -// SetLabel() is a wrapper around gtk_button_set_label(). -func (v *Button) SetLabel(label string) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_button_set_label(v.native(), (*C.gchar)(cstr)) -} - -// GetLabel() is a wrapper around gtk_button_get_label(). -func (v *Button) GetLabel() (string, error) { - c := C.gtk_button_get_label(v.native()) - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// SetUseUnderline() is a wrapper around gtk_button_set_use_underline(). -func (v *Button) SetUseUnderline(useUnderline bool) { - C.gtk_button_set_use_underline(v.native(), gbool(useUnderline)) -} - -// GetUseUnderline() is a wrapper around gtk_button_get_use_underline(). -func (v *Button) GetUseUnderline() bool { - c := C.gtk_button_get_use_underline(v.native()) - return gobool(c) -} - -// SetFocusOnClick() is a wrapper around gtk_button_set_focus_on_click(). -func (v *Button) SetFocusOnClick(focusOnClick bool) { - C.gtk_button_set_focus_on_click(v.native(), gbool(focusOnClick)) -} - -// GetFocusOnClick() is a wrapper around gtk_button_get_focus_on_click(). -func (v *Button) GetFocusOnClick() bool { - c := C.gtk_button_get_focus_on_click(v.native()) - return gobool(c) -} - -// SetImage() is a wrapper around gtk_button_set_image(). -func (v *Button) SetImage(image IWidget) { - C.gtk_button_set_image(v.native(), image.toWidget()) -} - -// GetImage() is a wrapper around gtk_button_get_image(). -func (v *Button) GetImage() (*Widget, error) { - c := C.gtk_button_get_image(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapWidget(obj), nil -} - -// SetImagePosition() is a wrapper around gtk_button_set_image_position(). -func (v *Button) SetImagePosition(position PositionType) { - C.gtk_button_set_image_position(v.native(), C.GtkPositionType(position)) -} - -// GetImagePosition() is a wrapper around gtk_button_get_image_position(). -func (v *Button) GetImagePosition() PositionType { - c := C.gtk_button_get_image_position(v.native()) - return PositionType(c) -} - -// SetAlwaysShowImage() is a wrapper around gtk_button_set_always_show_image(). -func (v *Button) SetAlwaysShowImage(alwaysShow bool) { - C.gtk_button_set_always_show_image(v.native(), gbool(alwaysShow)) -} - -// GetAlwaysShowImage() is a wrapper around gtk_button_get_always_show_image(). -func (v *Button) GetAlwaysShowImage() bool { - c := C.gtk_button_get_always_show_image(v.native()) - return gobool(c) -} - -// GetEventWindow() is a wrapper around gtk_button_get_event_window(). -func (v *Button) GetEventWindow() (*gdk.Window, error) { - c := C.gtk_button_get_event_window(v.native()) - if c == nil { - return nil, nilPtrErr - } - - w := &gdk.Window{wrapObject(unsafe.Pointer(c))} - return w, nil -} - -/* - * GtkColorButton - */ - -// ColorButton is a representation of GTK's GtkColorButton. -type ColorButton struct { - Button - - // Interfaces - ColorChooser -} - -// Native returns a pointer to the underlying GtkColorButton. -func (v *ColorButton) native() *C.GtkColorButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkColorButton(p) -} - -func wrapColorButton(obj *glib.Object) *ColorButton { - cc := wrapColorChooser(obj) - return &ColorButton{Button{Bin{Container{Widget{ - glib.InitiallyUnowned{obj}}}}}, *cc} -} - -// ColorButtonNew is a wrapper around gtk_color_button_new(). -func ColorButtonNew() (*ColorButton, error) { - c := C.gtk_color_button_new() - if c == nil { - return nil, nilPtrErr - } - return wrapColorButton(wrapObject(unsafe.Pointer(c))), nil -} - -// ColorButtonNewWithRGBA is a wrapper around gtk_color_button_new_with_rgba(). -func ColorButtonNewWithRGBA(gdkColor *gdk.RGBA) (*ColorButton, error) { - c := C.gtk_color_button_new_with_rgba((*C.GdkRGBA)(unsafe.Pointer(gdkColor.Native()))) - if c == nil { - return nil, nilPtrErr - } - return wrapColorButton(wrapObject(unsafe.Pointer(c))), nil -} - -/* - * GtkBox - */ - -// Box is a representation of GTK's GtkBox. -type Box struct { - Container -} - -// native() returns a pointer to the underlying GtkBox. -func (v *Box) native() *C.GtkBox { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkBox(p) -} - -func marshalBox(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapBox(obj), nil -} - -func wrapBox(obj *glib.Object) *Box { - return &Box{Container{Widget{glib.InitiallyUnowned{obj}}}} -} - -// BoxNew() is a wrapper around gtk_box_new(). -func BoxNew(orientation Orientation, spacing int) (*Box, error) { - c := C.gtk_box_new(C.GtkOrientation(orientation), C.gint(spacing)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapBox(obj), nil -} - -// PackStart() is a wrapper around gtk_box_pack_start(). -func (v *Box) PackStart(child IWidget, expand, fill bool, padding uint) { - C.gtk_box_pack_start(v.native(), child.toWidget(), gbool(expand), - gbool(fill), C.guint(padding)) -} - -// PackEnd() is a wrapper around gtk_box_pack_end(). -func (v *Box) PackEnd(child IWidget, expand, fill bool, padding uint) { - C.gtk_box_pack_end(v.native(), child.toWidget(), gbool(expand), - gbool(fill), C.guint(padding)) -} - -// GetHomogeneous() is a wrapper around gtk_box_get_homogeneous(). -func (v *Box) GetHomogeneous() bool { - c := C.gtk_box_get_homogeneous(v.native()) - return gobool(c) -} - -// SetHomogeneous() is a wrapper around gtk_box_set_homogeneous(). -func (v *Box) SetHomogeneous(homogeneous bool) { - C.gtk_box_set_homogeneous(v.native(), gbool(homogeneous)) -} - -// GetSpacing() is a wrapper around gtk_box_get_spacing(). -func (v *Box) GetSpacing() int { - c := C.gtk_box_get_spacing(v.native()) - return int(c) -} - -// SetSpacing() is a wrapper around gtk_box_set_spacing() -func (v *Box) SetSpacing(spacing int) { - C.gtk_box_set_spacing(v.native(), C.gint(spacing)) -} - -// ReorderChild() is a wrapper around gtk_box_reorder_child(). -func (v *Box) ReorderChild(child IWidget, position int) { - C.gtk_box_reorder_child(v.native(), child.toWidget(), C.gint(position)) -} - -// QueryChildPacking() is a wrapper around gtk_box_query_child_packing(). -func (v *Box) QueryChildPacking(child IWidget) (expand, fill bool, padding uint, packType PackType) { - var cexpand, cfill C.gboolean - var cpadding C.guint - var cpackType C.GtkPackType - - C.gtk_box_query_child_packing(v.native(), child.toWidget(), &cexpand, - &cfill, &cpadding, &cpackType) - return gobool(cexpand), gobool(cfill), uint(cpadding), PackType(cpackType) -} - -// SetChildPacking() is a wrapper around gtk_box_set_child_packing(). -func (v *Box) SetChildPacking(child IWidget, expand, fill bool, padding uint, packType PackType) { - C.gtk_box_set_child_packing(v.native(), child.toWidget(), gbool(expand), - gbool(fill), C.guint(padding), C.GtkPackType(packType)) -} - -/* - * GtkCalendar - */ - -// Calendar is a representation of GTK's GtkCalendar. -type Calendar struct { - Widget -} - -// native() returns a pointer to the underlying GtkCalendar. -func (v *Calendar) native() *C.GtkCalendar { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkCalendar(p) -} - -func marshalCalendar(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapCalendar(obj), nil -} - -func wrapCalendar(obj *glib.Object) *Calendar { - return &Calendar{Widget{glib.InitiallyUnowned{obj}}} -} - -// CalendarNew is a wrapper around gtk_calendar_new(). -func CalendarNew() (*Calendar, error) { - c := C.gtk_calendar_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapCalendar(obj), nil -} - -// SelectMonth is a wrapper around gtk_calendar_select_month(). -func (v *Calendar) SelectMonth(month, year uint) { - C.gtk_calendar_select_month(v.native(), C.guint(month), C.guint(year)) -} - -// SelectDay is a wrapper around gtk_calendar_select_day(). -func (v *Calendar) SelectDay(day uint) { - C.gtk_calendar_select_day(v.native(), C.guint(day)) -} - -// MarkDay is a wrapper around gtk_calendar_mark_day(). -func (v *Calendar) MarkDay(day uint) { - C.gtk_calendar_mark_day(v.native(), C.guint(day)) -} - -// UnmarkDay is a wrapper around gtk_calendar_unmark_day(). -func (v *Calendar) UnmarkDay(day uint) { - C.gtk_calendar_unmark_day(v.native(), C.guint(day)) -} - -// GetDayIsMarked is a wrapper around gtk_calendar_get_day_is_marked(). -func (v *Calendar) GetDayIsMarked(day uint) bool { - c := C.gtk_calendar_get_day_is_marked(v.native(), C.guint(day)) - return gobool(c) -} - -// ClearMarks is a wrapper around gtk_calendar_clear_marks(). -func (v *Calendar) ClearMarks() { - C.gtk_calendar_clear_marks(v.native()) -} - -// GetDisplayOptions is a wrapper around gtk_calendar_get_display_options(). -func (v *Calendar) GetDisplayOptions() CalendarDisplayOptions { - c := C.gtk_calendar_get_display_options(v.native()) - return CalendarDisplayOptions(c) -} - -// SetDisplayOptions is a wrapper around gtk_calendar_set_display_options(). -func (v *Calendar) SetDisplayOptions(flags CalendarDisplayOptions) { - C.gtk_calendar_set_display_options(v.native(), - C.GtkCalendarDisplayOptions(flags)) -} - -// GetDate is a wrapper around gtk_calendar_get_date(). -func (v *Calendar) GetDate() (year, month, day uint) { - var cyear, cmonth, cday C.guint - C.gtk_calendar_get_date(v.native(), &cyear, &cmonth, &cday) - return uint(cyear), uint(cmonth), uint(cday) -} - -// TODO gtk_calendar_set_detail_func - -// GetDetailWidthChars is a wrapper around gtk_calendar_get_detail_width_chars(). -func (v *Calendar) GetDetailWidthChars() int { - c := C.gtk_calendar_get_detail_width_chars(v.native()) - return int(c) -} - -// SetDetailWidthChars is a wrapper around gtk_calendar_set_detail_width_chars(). -func (v *Calendar) SetDetailWidthChars(chars int) { - C.gtk_calendar_set_detail_width_chars(v.native(), C.gint(chars)) -} - -// GetDetailHeightRows is a wrapper around gtk_calendar_get_detail_height_rows(). -func (v *Calendar) GetDetailHeightRows() int { - c := C.gtk_calendar_get_detail_height_rows(v.native()) - return int(c) -} - -// SetDetailHeightRows is a wrapper around gtk_calendar_set_detail_height_rows(). -func (v *Calendar) SetDetailHeightRows(rows int) { - C.gtk_calendar_set_detail_height_rows(v.native(), C.gint(rows)) -} - -/* - * GtkCellLayout - */ - -// CellLayout is a representation of GTK's GtkCellLayout GInterface. -type CellLayout struct { - *glib.Object -} - -// ICellLayout is an interface type implemented by all structs -// embedding a CellLayout. It is meant to be used as an argument type -// for wrapper functions that wrap around a C GTK function taking a -// GtkCellLayout. -type ICellLayout interface { - toCellLayout() *C.GtkCellLayout -} - -// native() returns a pointer to the underlying GObject as a GtkCellLayout. -func (v *CellLayout) native() *C.GtkCellLayout { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkCellLayout(p) -} - -func marshalCellLayout(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapCellLayout(obj), nil -} - -func wrapCellLayout(obj *glib.Object) *CellLayout { - return &CellLayout{obj} -} - -func (v *CellLayout) toCellLayout() *C.GtkCellLayout { - if v == nil { - return nil - } - return v.native() -} - -// PackStart() is a wrapper around gtk_cell_layout_pack_start(). -func (v *CellLayout) PackStart(cell ICellRenderer, expand bool) { - C.gtk_cell_layout_pack_start(v.native(), cell.toCellRenderer(), - gbool(expand)) -} - -// AddAttribute() is a wrapper around gtk_cell_layout_add_attribute(). -func (v *CellLayout) AddAttribute(cell ICellRenderer, attribute string, column int) { - cstr := C.CString(attribute) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_cell_layout_add_attribute(v.native(), cell.toCellRenderer(), - (*C.gchar)(cstr), C.gint(column)) -} - -/* - * GtkCellRenderer - */ - -// CellRenderer is a representation of GTK's GtkCellRenderer. -type CellRenderer struct { - glib.InitiallyUnowned -} - -// ICellRenderer is an interface type implemented by all structs -// embedding a CellRenderer. It is meant to be used as an argument type -// for wrapper functions that wrap around a C GTK function taking a -// GtkCellRenderer. -type ICellRenderer interface { - toCellRenderer() *C.GtkCellRenderer -} - -// native returns a pointer to the underlying GtkCellRenderer. -func (v *CellRenderer) native() *C.GtkCellRenderer { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkCellRenderer(p) -} - -func (v *CellRenderer) toCellRenderer() *C.GtkCellRenderer { - if v == nil { - return nil - } - return v.native() -} - -func marshalCellRenderer(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapCellRenderer(obj), nil -} - -func wrapCellRenderer(obj *glib.Object) *CellRenderer { - return &CellRenderer{glib.InitiallyUnowned{obj}} -} - -/* - * GtkCellRendererSpinner - */ - -// CellRendererSpinner is a representation of GTK's GtkCellRendererSpinner. -type CellRendererSpinner struct { - CellRenderer -} - -// native returns a pointer to the underlying GtkCellRendererSpinner. -func (v *CellRendererSpinner) native() *C.GtkCellRendererSpinner { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkCellRendererSpinner(p) -} - -func marshalCellRendererSpinner(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapCellRendererSpinner(obj), nil -} - -func wrapCellRendererSpinner(obj *glib.Object) *CellRendererSpinner { - return &CellRendererSpinner{CellRenderer{glib.InitiallyUnowned{obj}}} -} - -// CellRendererSpinnerNew is a wrapper around gtk_cell_renderer_text_new(). -func CellRendererSpinnerNew() (*CellRendererSpinner, error) { - c := C.gtk_cell_renderer_spinner_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapCellRendererSpinner(obj), nil -} - -/* - * GtkCellRendererPixbuf - */ - -// CellRendererPixbuf is a representation of GTK's GtkCellRendererPixbuf. -type CellRendererPixbuf struct { - CellRenderer -} - -// native returns a pointer to the underlying GtkCellRendererPixbuf. -func (v *CellRendererPixbuf) native() *C.GtkCellRendererPixbuf { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkCellRendererPixbuf(p) -} - -func marshalCellRendererPixbuf(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapCellRendererPixbuf(obj), nil -} - -func wrapCellRendererPixbuf(obj *glib.Object) *CellRendererPixbuf { - return &CellRendererPixbuf{CellRenderer{glib.InitiallyUnowned{obj}}} -} - -// CellRendererPixbufNew is a wrapper around gtk_cell_renderer_pixbuf_new(). -func CellRendererPixbufNew() (*CellRendererPixbuf, error) { - c := C.gtk_cell_renderer_pixbuf_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapCellRendererPixbuf(obj), nil -} - -/* - * GtkCellRendererText - */ - -// CellRendererText is a representation of GTK's GtkCellRendererText. -type CellRendererText struct { - CellRenderer -} - -// native returns a pointer to the underlying GtkCellRendererText. -func (v *CellRendererText) native() *C.GtkCellRendererText { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkCellRendererText(p) -} - -func marshalCellRendererText(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapCellRendererText(obj), nil -} - -func wrapCellRendererText(obj *glib.Object) *CellRendererText { - return &CellRendererText{CellRenderer{glib.InitiallyUnowned{obj}}} -} - -// CellRendererTextNew is a wrapper around gtk_cell_renderer_text_new(). -func CellRendererTextNew() (*CellRendererText, error) { - c := C.gtk_cell_renderer_text_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapCellRendererText(obj), nil -} - -/* - * GtkCellRendererToggle - */ - -// CellRendererToggle is a representation of GTK's GtkCellRendererToggle. -type CellRendererToggle struct { - CellRenderer -} - -// native returns a pointer to the underlying GtkCellRendererToggle. -func (v *CellRendererToggle) native() *C.GtkCellRendererToggle { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkCellRendererToggle(p) -} - -func (v *CellRendererToggle) toCellRenderer() *C.GtkCellRenderer { - if v == nil { - return nil - } - return v.CellRenderer.native() -} - -func marshalCellRendererToggle(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapCellRendererToggle(obj), nil -} - -func wrapCellRendererToggle(obj *glib.Object) *CellRendererToggle { - return &CellRendererToggle{CellRenderer{glib.InitiallyUnowned{obj}}} -} - -// CellRendererToggleNew is a wrapper around gtk_cell_renderer_toggle_new(). -func CellRendererToggleNew() (*CellRendererToggle, error) { - c := C.gtk_cell_renderer_toggle_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapCellRendererToggle(obj), nil -} - -// SetRadio is a wrapper around gtk_cell_renderer_toggle_set_radio(). -func (v *CellRendererToggle) SetRadio(set bool) { - C.gtk_cell_renderer_toggle_set_radio(v.native(), gbool(set)) -} - -// GetRadio is a wrapper around gtk_cell_renderer_toggle_get_radio(). -func (v *CellRendererToggle) GetRadio() bool { - c := C.gtk_cell_renderer_toggle_get_radio(v.native()) - return gobool(c) -} - -// SetActive is a wrapper arround gtk_cell_renderer_toggle_set_active(). -func (v *CellRendererToggle) SetActive(active bool) { - C.gtk_cell_renderer_toggle_set_active(v.native(), gbool(active)) -} - -// GetActive is a wrapper around gtk_cell_renderer_toggle_get_active(). -func (v *CellRendererToggle) GetActive() bool { - c := C.gtk_cell_renderer_toggle_get_active(v.native()) - return gobool(c) -} - -// SetActivatable is a wrapper around gtk_cell_renderer_toggle_set_activatable(). -func (v *CellRendererToggle) SetActivatable(activatable bool) { - C.gtk_cell_renderer_toggle_set_activatable(v.native(), - gbool(activatable)) -} - -// GetActivatable is a wrapper around gtk_cell_renderer_toggle_get_activatable(). -func (v *CellRendererToggle) GetActivatable() bool { - c := C.gtk_cell_renderer_toggle_get_activatable(v.native()) - return gobool(c) -} - -/* - * GtkCheckButton - */ - -// CheckButton is a wrapper around GTK's GtkCheckButton. -type CheckButton struct { - ToggleButton -} - -// native returns a pointer to the underlying GtkCheckButton. -func (v *CheckButton) native() *C.GtkCheckButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkCheckButton(p) -} - -func marshalCheckButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapCheckButton(obj), nil -} - -func wrapCheckButton(obj *glib.Object) *CheckButton { - return &CheckButton{ToggleButton{Button{Bin{Container{Widget{ - glib.InitiallyUnowned{obj}}}}}}} -} - -// CheckButtonNew is a wrapper around gtk_check_button_new(). -func CheckButtonNew() (*CheckButton, error) { - c := C.gtk_check_button_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapCheckButton(obj), nil -} - -// CheckButtonNewWithLabel is a wrapper around -// gtk_check_button_new_with_label(). -func CheckButtonNewWithLabel(label string) (*CheckButton, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_check_button_new_with_label((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapCheckButton(wrapObject(unsafe.Pointer(c))), nil -} - -// CheckButtonNewWithMnemonic is a wrapper around -// gtk_check_button_new_with_mnemonic(). -func CheckButtonNewWithMnemonic(label string) (*CheckButton, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_check_button_new_with_mnemonic((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapCheckButton(obj), nil -} - -/* - * GtkCheckMenuItem - */ - -type CheckMenuItem struct { - MenuItem -} - -// native returns a pointer to the underlying GtkCheckMenuItem. -func (v *CheckMenuItem) native() *C.GtkCheckMenuItem { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkCheckMenuItem(p) -} - -func marshalCheckMenuItem(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapCheckMenuItem(obj), nil -} - -func wrapCheckMenuItem(obj *glib.Object) *CheckMenuItem { - return &CheckMenuItem{MenuItem{Bin{Container{Widget{ - glib.InitiallyUnowned{obj}}}}}} -} - -// CheckMenuItemNew is a wrapper around gtk_check_menu_item_new(). -func CheckMenuItemNew() (*CheckMenuItem, error) { - c := C.gtk_check_menu_item_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapCheckMenuItem(obj), nil -} - -// CheckMenuItemNewWithLabel is a wrapper around -// gtk_check_menu_item_new_with_label(). -func CheckMenuItemNewWithLabel(label string) (*CheckMenuItem, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_check_menu_item_new_with_label((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapCheckMenuItem(obj), nil -} - -// CheckMenuItemNewWithMnemonic is a wrapper around -// gtk_check_menu_item_new_with_mnemonic(). -func CheckMenuItemNewWithMnemonic(label string) (*CheckMenuItem, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_check_menu_item_new_with_mnemonic((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapCheckMenuItem(obj), nil -} - -// GetActive is a wrapper around gtk_check_menu_item_get_active(). -func (v *CheckMenuItem) GetActive() bool { - c := C.gtk_check_menu_item_get_active(v.native()) - return gobool(c) -} - -// SetActive is a wrapper around gtk_check_menu_item_set_active(). -func (v *CheckMenuItem) SetActive(isActive bool) { - C.gtk_check_menu_item_set_active(v.native(), gbool(isActive)) -} - -// Toggled is a wrapper around gtk_check_menu_item_toggled(). -func (v *CheckMenuItem) Toggled() { - C.gtk_check_menu_item_toggled(v.native()) -} - -// GetInconsistent is a wrapper around gtk_check_menu_item_get_inconsistent(). -func (v *CheckMenuItem) GetInconsistent() bool { - c := C.gtk_check_menu_item_get_inconsistent(v.native()) - return gobool(c) -} - -// SetInconsistent is a wrapper around gtk_check_menu_item_set_inconsistent(). -func (v *CheckMenuItem) SetInconsistent(setting bool) { - C.gtk_check_menu_item_set_inconsistent(v.native(), gbool(setting)) -} - -// SetDrawAsRadio is a wrapper around gtk_check_menu_item_set_draw_as_radio(). -func (v *CheckMenuItem) SetDrawAsRadio(drawAsRadio bool) { - C.gtk_check_menu_item_set_draw_as_radio(v.native(), gbool(drawAsRadio)) -} - -// GetDrawAsRadio is a wrapper around gtk_check_menu_item_get_draw_as_radio(). -func (v *CheckMenuItem) GetDrawAsRadio() bool { - c := C.gtk_check_menu_item_get_draw_as_radio(v.native()) - return gobool(c) -} - -/* - * GtkClipboard - */ - -// Clipboard is a wrapper around GTK's GtkClipboard. -type Clipboard struct { - *glib.Object -} - -// native returns a pointer to the underlying GtkClipboard. -func (v *Clipboard) native() *C.GtkClipboard { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkClipboard(p) -} - -func marshalClipboard(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapClipboard(obj), nil -} - -func wrapClipboard(obj *glib.Object) *Clipboard { - return &Clipboard{obj} -} - -// Store is a wrapper around gtk_clipboard_store -func (v *Clipboard) Store() { - C.gtk_clipboard_store(v.native()) -} - -// ClipboardGet() is a wrapper around gtk_clipboard_get(). -func ClipboardGet(atom gdk.Atom) (*Clipboard, error) { - c := C.gtk_clipboard_get(C.GdkAtom(unsafe.Pointer(atom))) - if c == nil { - return nil, nilPtrErr - } - - cb := &Clipboard{wrapObject(unsafe.Pointer(c))} - return cb, nil -} - -// ClipboardGetForDisplay() is a wrapper around gtk_clipboard_get_for_display(). -func ClipboardGetForDisplay(display *gdk.Display, atom gdk.Atom) (*Clipboard, error) { - displayPtr := (*C.GdkDisplay)(unsafe.Pointer(display.Native())) - c := C.gtk_clipboard_get_for_display(displayPtr, - C.GdkAtom(unsafe.Pointer(atom))) - if c == nil { - return nil, nilPtrErr - } - - cb := &Clipboard{wrapObject(unsafe.Pointer(c))} - return cb, nil -} - -// WaitIsTextAvailable is a wrapper around gtk_clipboard_wait_is_text_available -func (v *Clipboard) WaitIsTextAvailable() bool { - c := C.gtk_clipboard_wait_is_text_available(v.native()) - return gobool(c) -} - -// WaitForText is a wrapper around gtk_clipboard_wait_for_text -func (v *Clipboard) WaitForText() (string, error) { - c := C.gtk_clipboard_wait_for_text(v.native()) - if c == nil { - return "", nilPtrErr - } - defer C.g_free(C.gpointer(c)) - return C.GoString((*C.char)(c)), nil -} - -// SetText() is a wrapper around gtk_clipboard_set_text(). -func (v *Clipboard) SetText(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_clipboard_set_text(v.native(), (*C.gchar)(cstr), - C.gint(len(text))) -} - -// WaitIsRichTextAvailable is a wrapper around gtk_clipboard_wait_is_rich_text_available -func (v *Clipboard) WaitIsRichTextAvailable(buf *TextBuffer) bool { - c := C.gtk_clipboard_wait_is_rich_text_available(v.native(), buf.native()) - return gobool(c) -} - -// WaitIsUrisAvailable is a wrapper around gtk_clipboard_wait_is_uris_available -func (v *Clipboard) WaitIsUrisAvailable() bool { - c := C.gtk_clipboard_wait_is_uris_available(v.native()) - return gobool(c) -} - -// WaitIsImageAvailable is a wrapper around gtk_clipboard_wait_is_image_available -func (v *Clipboard) WaitIsImageAvailable() bool { - c := C.gtk_clipboard_wait_is_image_available(v.native()) - return gobool(c) -} - -// SetImage is a wrapper around gtk_clipboard_set_image -func (v *Clipboard) SetImage(pixbuf *gdk.Pixbuf) { - C.gtk_clipboard_set_image(v.native(), (*C.GdkPixbuf)(unsafe.Pointer(pixbuf.Native()))) -} - -// WaitForImage is a wrapper around gtk_clipboard_wait_for_image -func (v *Clipboard) WaitForImage() (*gdk.Pixbuf, error) { - c := C.gtk_clipboard_wait_for_image(v.native()) - if c == nil { - return nil, nilPtrErr - } - - p := &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))} - return p, nil -} - -// WaitIsTargetAvailable is a wrapper around gtk_clipboard_wait_is_target_available -func (v *Clipboard) WaitIsTargetAvailable(target gdk.Atom) bool { - c := C.gtk_clipboard_wait_is_target_available(v.native(), C.GdkAtom(unsafe.Pointer(target))) - return gobool(c) -} - -// WaitForContents is a wrapper around gtk_clipboard_wait_for_contents -func (v *Clipboard) WaitForContents(target gdk.Atom) (*SelectionData, error) { - c := C.gtk_clipboard_wait_for_contents(v.native(), C.GdkAtom(unsafe.Pointer(target))) - if c == nil { - return nil, nilPtrErr - } - p := &SelectionData{c} - runtime.SetFinalizer(p, (*SelectionData).free) - return p, nil -} - -/* - * GtkContainer - */ - -// Container is a representation of GTK's GtkContainer. -type Container struct { - Widget -} - -// native returns a pointer to the underlying GtkContainer. -func (v *Container) native() *C.GtkContainer { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkContainer(p) -} - -func marshalContainer(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapContainer(obj), nil -} - -func wrapContainer(obj *glib.Object) *Container { - return &Container{Widget{glib.InitiallyUnowned{obj}}} -} - -// Add is a wrapper around gtk_container_add(). -func (v *Container) Add(w IWidget) { - C.gtk_container_add(v.native(), w.toWidget()) -} - -// Remove is a wrapper around gtk_container_remove(). -func (v *Container) Remove(w IWidget) { - C.gtk_container_remove(v.native(), w.toWidget()) -} - -// TODO: gtk_container_add_with_properties - -// CheckResize is a wrapper around gtk_container_check_resize(). -func (v *Container) CheckResize() { - C.gtk_container_check_resize(v.native()) -} - -// TODO: gtk_container_foreach -// TODO: gtk_container_get_children -// TODO: gtk_container_get_path_for_child - -// GetFocusChild is a wrapper around gtk_container_get_focus_child(). -func (v *Container) GetFocusChild() *Widget { - c := C.gtk_container_get_focus_child(v.native()) - if c == nil { - return nil - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapWidget(obj) -} - -// SetFocusChild is a wrapper around gtk_container_set_focus_child(). -func (v *Container) SetFocusChild(child IWidget) { - C.gtk_container_set_focus_child(v.native(), child.toWidget()) -} - -// GetFocusVAdjustment is a wrapper around -// gtk_container_get_focus_vadjustment(). -func (v *Container) GetFocusVAdjustment() *Adjustment { - c := C.gtk_container_get_focus_vadjustment(v.native()) - if c == nil { - return nil - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapAdjustment(obj) -} - -// SetFocusVAdjustment is a wrapper around -// gtk_container_set_focus_vadjustment(). -func (v *Container) SetFocusVAdjustment(adjustment *Adjustment) { - C.gtk_container_set_focus_vadjustment(v.native(), adjustment.native()) -} - -// GetFocusHAdjustment is a wrapper around -// gtk_container_get_focus_hadjustment(). -func (v *Container) GetFocusHAdjustment() *Adjustment { - c := C.gtk_container_get_focus_hadjustment(v.native()) - if c == nil { - return nil - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapAdjustment(obj) -} - -// SetFocusHAdjustment is a wrapper around -// gtk_container_set_focus_hadjustment(). -func (v *Container) SetFocusHAdjustment(adjustment *Adjustment) { - C.gtk_container_set_focus_hadjustment(v.native(), adjustment.native()) -} - -// ChildType is a wrapper around gtk_container_child_type(). -func (v *Container) ChildType() glib.Type { - c := C.gtk_container_child_type(v.native()) - return glib.Type(c) -} - -// TODO: gtk_container_child_get_valist -// TODO: gtk_container_child_set_valist - -// ChildNotify is a wrapper around gtk_container_child_notify(). -func (v *Container) ChildNotify(child IWidget, childProperty string) { - cstr := C.CString(childProperty) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_container_child_notify(v.native(), child.toWidget(), - (*C.gchar)(cstr)) -} - -// ChildSetProperty is a wrapper around gtk_container_child_set_property(). -func (v *Container) ChildSetProperty(child IWidget, name string, value interface{}) error { - gv, e := glib.GValue(value) - if e != nil { - return e - } - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_container_child_set_property(v.native(), child.toWidget(), (*C.gchar)(cstr), (*C.GValue)(unsafe.Pointer(gv))) - return nil -} - -// TODO: gtk_container_forall - -// GetBorderWidth is a wrapper around gtk_container_get_border_width(). -func (v *Container) GetBorderWidth() uint { - c := C.gtk_container_get_border_width(v.native()) - return uint(c) -} - -// SetBorderWidth is a wrapper around gtk_container_set_border_width(). -func (v *Container) SetBorderWidth(borderWidth uint) { - C.gtk_container_set_border_width(v.native(), C.guint(borderWidth)) -} - -// PropagateDraw is a wrapper around gtk_container_propagate_draw(). -func (v *Container) PropagateDraw(child IWidget, cr *cairo.Context) { - context := (*C.cairo_t)(unsafe.Pointer(cr.Native())) - C.gtk_container_propagate_draw(v.native(), child.toWidget(), context) -} - -// GdkCairoSetSourcePixBuf() is a wrapper around gdk_cairo_set_source_pixbuf(). -func GdkCairoSetSourcePixBuf(cr *cairo.Context, pixbuf *gdk.Pixbuf, pixbufX, pixbufY float64) { - context := (*C.cairo_t)(unsafe.Pointer(cr.Native())) - ptr := (*C.GdkPixbuf)(unsafe.Pointer(pixbuf.Native())) - C.gdk_cairo_set_source_pixbuf(context, ptr, C.gdouble(pixbufX), C.gdouble(pixbufY)) -} - -// GetFocusChain is a wrapper around gtk_container_get_focus_chain(). -func (v *Container) GetFocusChain() ([]*Widget, bool) { - var cwlist *C.GList - c := C.gtk_container_get_focus_chain(v.native(), &cwlist) - - var widgets []*Widget - wlist := glib.WrapList(uintptr(unsafe.Pointer(cwlist))) - for ; wlist.Data() != nil; wlist = wlist.Next() { - widgets = append(widgets, wrapWidget(wrapObject(wlist.Data().(unsafe.Pointer)))) - } - return widgets, gobool(c) -} - -// SetFocusChain is a wrapper around gtk_container_set_focus_chain(). -func (v *Container) SetFocusChain(focusableWidgets []IWidget) { - var list *glib.List - for _, w := range focusableWidgets { - data := uintptr(unsafe.Pointer(w.toWidget())) - list = list.Append(data) - } - glist := (*C.GList)(unsafe.Pointer(list)) - C.gtk_container_set_focus_chain(v.native(), glist) -} - -/* - * GtkCssProvider - */ - -// CssProvider is a representation of GTK's GtkCssProvider. -type CssProvider struct { - *glib.Object -} - -func (v *CssProvider) toStyleProvider() *C.GtkStyleProvider { - if v == nil { - return nil - } - return C.toGtkStyleProvider(unsafe.Pointer(v.native())) -} - -// native returns a pointer to the underlying GtkCssProvider. -func (v *CssProvider) native() *C.GtkCssProvider { - if v == nil || v.Object == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkCssProvider(p) -} - -func wrapCssProvider(obj *glib.Object) *CssProvider { - return &CssProvider{obj} -} - -// CssProviderNew is a wrapper around gtk_css_provider_new(). -func CssProviderNew() (*CssProvider, error) { - c := C.gtk_css_provider_new() - if c == nil { - return nil, nilPtrErr - } - - return wrapCssProvider(wrapObject(unsafe.Pointer(c))), nil -} - -// LoadFromPath is a wrapper around gtk_css_provider_load_from_path(). -func (v *CssProvider) LoadFromPath(path string) error { - cpath := C.CString(path) - defer C.free(unsafe.Pointer(cpath)) - var gerr *C.GError - if C.gtk_css_provider_load_from_path(v.native(), (*C.gchar)(cpath), &gerr) == 0 { - defer C.g_error_free(gerr) - return errors.New(C.GoString((*C.char)(gerr.message))) - } - return nil -} - -// LoadFromData is a wrapper around gtk_css_provider_load_from_data(). -func (v *CssProvider) LoadFromData(data string) error { - cdata := C.CString(data) - defer C.free(unsafe.Pointer(cdata)) - var gerr *C.GError - if C.gtk_css_provider_load_from_data(v.native(), (*C.gchar)(unsafe.Pointer(cdata)), C.gssize(len(data)), &gerr) == 0 { - defer C.g_error_free(gerr) - return errors.New(C.GoString((*C.char)(gerr.message))) - } - return nil -} - -// ToString is a wrapper around gtk_css_provider_to_string(). -func (v *CssProvider) ToString() (string, error) { - c := C.gtk_css_provider_to_string(v.native()) - if c == nil { - return "", nilPtrErr - } - return C.GoString(c), nil -} - -// CssProviderGetDefault is a wrapper around gtk_css_provider_get_default(). -func CssProviderGetDefault() (*CssProvider, error) { - c := C.gtk_css_provider_get_default() - if c == nil { - return nil, nilPtrErr - } - - obj := wrapObject(unsafe.Pointer(c)) - return wrapCssProvider(obj), nil -} - -// GetNamed is a wrapper around gtk_css_provider_get_named(). -func CssProviderGetNamed(name string, variant string) (*CssProvider, error) { - cname := C.CString(name) - defer C.free(unsafe.Pointer(cname)) - cvariant := C.CString(variant) - defer C.free(unsafe.Pointer(cvariant)) - - c := C.gtk_css_provider_get_named((*C.gchar)(cname), (*C.gchar)(cvariant)) - if c == nil { - return nil, nilPtrErr - } - - obj := wrapObject(unsafe.Pointer(c)) - return wrapCssProvider(obj), nil -} - -/* - * GtkDialog - */ - -// Dialog is a representation of GTK's GtkDialog. -type Dialog struct { - Window -} - -// native returns a pointer to the underlying GtkDialog. -func (v *Dialog) native() *C.GtkDialog { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkDialog(p) -} - -func marshalDialog(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapDialog(obj), nil -} - -func wrapDialog(obj *glib.Object) *Dialog { - return &Dialog{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}} -} - -// DialogNew() is a wrapper around gtk_dialog_new(). -func DialogNew() (*Dialog, error) { - c := C.gtk_dialog_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapDialog(obj), nil -} - -// Run() is a wrapper around gtk_dialog_run(). -func (v *Dialog) Run() int { - c := C.gtk_dialog_run(v.native()) - return int(c) -} - -// Response() is a wrapper around gtk_dialog_response(). -func (v *Dialog) Response(response ResponseType) { - C.gtk_dialog_response(v.native(), C.gint(response)) -} - -// AddButton() is a wrapper around gtk_dialog_add_button(). text may -// be either the literal button text, or if using GTK 3.8 or earlier, a -// Stock type converted to a string. -func (v *Dialog) AddButton(text string, id ResponseType) (*Button, error) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_dialog_add_button(v.native(), (*C.gchar)(cstr), C.gint(id)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return &Button{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}, nil -} - -// AddActionWidget() is a wrapper around gtk_dialog_add_action_widget(). -func (v *Dialog) AddActionWidget(child IWidget, id ResponseType) { - C.gtk_dialog_add_action_widget(v.native(), child.toWidget(), C.gint(id)) -} - -// SetDefaultResponse() is a wrapper around gtk_dialog_set_default_response(). -func (v *Dialog) SetDefaultResponse(id ResponseType) { - C.gtk_dialog_set_default_response(v.native(), C.gint(id)) -} - -// SetResponseSensitive() is a wrapper around -// gtk_dialog_set_response_sensitive(). -func (v *Dialog) SetResponseSensitive(id ResponseType, setting bool) { - C.gtk_dialog_set_response_sensitive(v.native(), C.gint(id), - gbool(setting)) -} - -// GetResponseForWidget() is a wrapper around -// gtk_dialog_get_response_for_widget(). -func (v *Dialog) GetResponseForWidget(widget IWidget) ResponseType { - c := C.gtk_dialog_get_response_for_widget(v.native(), widget.toWidget()) - return ResponseType(c) -} - -// GetWidgetForResponse() is a wrapper around -// gtk_dialog_get_widget_for_response(). -func (v *Dialog) GetWidgetForResponse(id ResponseType) (*Widget, error) { - c := C.gtk_dialog_get_widget_for_response(v.native(), C.gint(id)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapWidget(obj), nil -} - -// GetContentArea() is a wrapper around gtk_dialog_get_content_area(). -func (v *Dialog) GetContentArea() (*Box, error) { - c := C.gtk_dialog_get_content_area(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - b := &Box{Container{Widget{glib.InitiallyUnowned{obj}}}} - return b, nil -} - -// TODO(jrick) -/* -func (v *gdk.Screen) AlternativeDialogButtonOrder() bool { - c := C.gtk_alternative_dialog_button_order(v.native()) - return gobool(c) -} -*/ - -// TODO(jrick) -/* -func SetAlternativeButtonOrder(ids ...ResponseType) { -} -*/ - -/* - * GtkDrawingArea - */ - -// DrawingArea is a representation of GTK's GtkDrawingArea. -type DrawingArea struct { - Widget -} - -// native returns a pointer to the underlying GtkDrawingArea. -func (v *DrawingArea) native() *C.GtkDrawingArea { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkDrawingArea(p) -} - -func marshalDrawingArea(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapDrawingArea(obj), nil -} - -func wrapDrawingArea(obj *glib.Object) *DrawingArea { - return &DrawingArea{Widget{glib.InitiallyUnowned{obj}}} -} - -// DrawingAreaNew is a wrapper around gtk_drawing_area_new(). -func DrawingAreaNew() (*DrawingArea, error) { - c := C.gtk_drawing_area_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapDrawingArea(obj), nil -} - -/* - * GtkEditable - */ - -// Editable is a representation of GTK's GtkEditable GInterface. -type Editable struct { - *glib.Object -} - -// IEditable is an interface type implemented by all structs -// embedding an Editable. It is meant to be used as an argument type -// for wrapper functions that wrap around a C GTK function taking a -// GtkEditable. -type IEditable interface { - toEditable() *C.GtkEditable -} - -// native() returns a pointer to the underlying GObject as a GtkEditable. -func (v *Editable) native() *C.GtkEditable { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkEditable(p) -} - -func marshalEditable(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapEditable(obj), nil -} - -func wrapEditable(obj *glib.Object) *Editable { - return &Editable{obj} -} - -func (v *Editable) toEditable() *C.GtkEditable { - if v == nil { - return nil - } - return v.native() -} - -// SelectRegion is a wrapper around gtk_editable_select_region(). -func (v *Editable) SelectRegion(startPos, endPos int) { - C.gtk_editable_select_region(v.native(), C.gint(startPos), - C.gint(endPos)) -} - -// GetSelectionBounds is a wrapper around gtk_editable_get_selection_bounds(). -func (v *Editable) GetSelectionBounds() (start, end int, nonEmpty bool) { - var cstart, cend C.gint - c := C.gtk_editable_get_selection_bounds(v.native(), &cstart, &cend) - return int(cstart), int(cend), gobool(c) -} - -// InsertText is a wrapper around gtk_editable_insert_text(). The returned -// int is the position after the inserted text. -func (v *Editable) InsertText(newText string, position int) int { - cstr := C.CString(newText) - defer C.free(unsafe.Pointer(cstr)) - pos := new(C.gint) - *pos = C.gint(position) - C.gtk_editable_insert_text(v.native(), (*C.gchar)(cstr), - C.gint(len(newText)), pos) - return int(*pos) -} - -// DeleteText is a wrapper around gtk_editable_delete_text(). -func (v *Editable) DeleteText(startPos, endPos int) { - C.gtk_editable_delete_text(v.native(), C.gint(startPos), C.gint(endPos)) -} - -// GetChars is a wrapper around gtk_editable_get_chars(). -func (v *Editable) GetChars(startPos, endPos int) string { - c := C.gtk_editable_get_chars(v.native(), C.gint(startPos), - C.gint(endPos)) - defer C.free(unsafe.Pointer(c)) - return C.GoString((*C.char)(c)) -} - -// CutClipboard is a wrapper around gtk_editable_cut_clipboard(). -func (v *Editable) CutClipboard() { - C.gtk_editable_cut_clipboard(v.native()) -} - -// CopyClipboard is a wrapper around gtk_editable_copy_clipboard(). -func (v *Editable) CopyClipboard() { - C.gtk_editable_copy_clipboard(v.native()) -} - -// PasteClipboard is a wrapper around gtk_editable_paste_clipboard(). -func (v *Editable) PasteClipboard() { - C.gtk_editable_paste_clipboard(v.native()) -} - -// DeleteSelection is a wrapper around gtk_editable_delete_selection(). -func (v *Editable) DeleteSelection() { - C.gtk_editable_delete_selection(v.native()) -} - -// SetPosition is a wrapper around gtk_editable_set_position(). -func (v *Editable) SetPosition(position int) { - C.gtk_editable_set_position(v.native(), C.gint(position)) -} - -// GetPosition is a wrapper around gtk_editable_get_position(). -func (v *Editable) GetPosition() int { - c := C.gtk_editable_get_position(v.native()) - return int(c) -} - -// SetEditable is a wrapper around gtk_editable_set_editable(). -func (v *Editable) SetEditable(isEditable bool) { - C.gtk_editable_set_editable(v.native(), gbool(isEditable)) -} - -// GetEditable is a wrapper around gtk_editable_get_editable(). -func (v *Editable) GetEditable() bool { - c := C.gtk_editable_get_editable(v.native()) - return gobool(c) -} - -/* - * GtkEntry - */ - -// Entry is a representation of GTK's GtkEntry. -type Entry struct { - Widget - - // Interfaces - Editable -} - -type IEntry interface { - toEntry() *C.GtkEntry -} - -func (v *Entry) toEntry() *C.GtkEntry { - return v.native() -} - -// native returns a pointer to the underlying GtkEntry. -func (v *Entry) native() *C.GtkEntry { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkEntry(p) -} - -func marshalEntry(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapEntry(obj), nil -} - -func wrapEntry(obj *glib.Object) *Entry { - e := wrapEditable(obj) - return &Entry{Widget{glib.InitiallyUnowned{obj}}, *e} -} - -// EntryNew() is a wrapper around gtk_entry_new(). -func EntryNew() (*Entry, error) { - c := C.gtk_entry_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapEntry(obj), nil -} - -// EntryNewWithBuffer() is a wrapper around gtk_entry_new_with_buffer(). -func EntryNewWithBuffer(buffer *EntryBuffer) (*Entry, error) { - c := C.gtk_entry_new_with_buffer(buffer.native()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapEntry(obj), nil -} - -// GetBuffer() is a wrapper around gtk_entry_get_buffer(). -func (v *Entry) GetBuffer() (*EntryBuffer, error) { - c := C.gtk_entry_get_buffer(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return &EntryBuffer{obj}, nil -} - -// SetBuffer() is a wrapper around gtk_entry_set_buffer(). -func (v *Entry) SetBuffer(buffer *EntryBuffer) { - C.gtk_entry_set_buffer(v.native(), buffer.native()) -} - -// SetText() is a wrapper around gtk_entry_set_text(). -func (v *Entry) SetText(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_entry_set_text(v.native(), (*C.gchar)(cstr)) -} - -// GetText() is a wrapper around gtk_entry_get_text(). -func (v *Entry) GetText() (string, error) { - c := C.gtk_entry_get_text(v.native()) - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// GetTextLength() is a wrapper around gtk_entry_get_text_length(). -func (v *Entry) GetTextLength() uint16 { - c := C.gtk_entry_get_text_length(v.native()) - return uint16(c) -} - -// TODO(jrick) GdkRectangle -/* -func (v *Entry) GetTextArea() { -} -*/ - -// SetVisibility() is a wrapper around gtk_entry_set_visibility(). -func (v *Entry) SetVisibility(visible bool) { - C.gtk_entry_set_visibility(v.native(), gbool(visible)) -} - -// SetInvisibleChar() is a wrapper around gtk_entry_set_invisible_char(). -func (v *Entry) SetInvisibleChar(ch rune) { - C.gtk_entry_set_invisible_char(v.native(), C.gunichar(ch)) -} - -// UnsetInvisibleChar() is a wrapper around gtk_entry_unset_invisible_char(). -func (v *Entry) UnsetInvisibleChar() { - C.gtk_entry_unset_invisible_char(v.native()) -} - -// SetMaxLength() is a wrapper around gtk_entry_set_max_length(). -func (v *Entry) SetMaxLength(len int) { - C.gtk_entry_set_max_length(v.native(), C.gint(len)) -} - -// GetActivatesDefault() is a wrapper around gtk_entry_get_activates_default(). -func (v *Entry) GetActivatesDefault() bool { - c := C.gtk_entry_get_activates_default(v.native()) - return gobool(c) -} - -// GetHasFrame() is a wrapper around gtk_entry_get_has_frame(). -func (v *Entry) GetHasFrame() bool { - c := C.gtk_entry_get_has_frame(v.native()) - return gobool(c) -} - -// GetWidthChars() is a wrapper around gtk_entry_get_width_chars(). -func (v *Entry) GetWidthChars() int { - c := C.gtk_entry_get_width_chars(v.native()) - return int(c) -} - -// SetActivatesDefault() is a wrapper around gtk_entry_set_activates_default(). -func (v *Entry) SetActivatesDefault(setting bool) { - C.gtk_entry_set_activates_default(v.native(), gbool(setting)) -} - -// SetHasFrame() is a wrapper around gtk_entry_set_has_frame(). -func (v *Entry) SetHasFrame(setting bool) { - C.gtk_entry_set_has_frame(v.native(), gbool(setting)) -} - -// SetWidthChars() is a wrapper around gtk_entry_set_width_chars(). -func (v *Entry) SetWidthChars(nChars int) { - C.gtk_entry_set_width_chars(v.native(), C.gint(nChars)) -} - -// GetInvisibleChar() is a wrapper around gtk_entry_get_invisible_char(). -func (v *Entry) GetInvisibleChar() rune { - c := C.gtk_entry_get_invisible_char(v.native()) - return rune(c) -} - -// SetAlignment() is a wrapper around gtk_entry_set_alignment(). -func (v *Entry) SetAlignment(xalign float32) { - C.gtk_entry_set_alignment(v.native(), C.gfloat(xalign)) -} - -// GetAlignment() is a wrapper around gtk_entry_get_alignment(). -func (v *Entry) GetAlignment() float32 { - c := C.gtk_entry_get_alignment(v.native()) - return float32(c) -} - -// SetPlaceholderText() is a wrapper around gtk_entry_set_placeholder_text(). -func (v *Entry) SetPlaceholderText(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_entry_set_placeholder_text(v.native(), (*C.gchar)(cstr)) -} - -// GetPlaceholderText() is a wrapper around gtk_entry_get_placeholder_text(). -func (v *Entry) GetPlaceholderText() (string, error) { - c := C.gtk_entry_get_placeholder_text(v.native()) - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// SetOverwriteMode() is a wrapper around gtk_entry_set_overwrite_mode(). -func (v *Entry) SetOverwriteMode(overwrite bool) { - C.gtk_entry_set_overwrite_mode(v.native(), gbool(overwrite)) -} - -// GetOverwriteMode() is a wrapper around gtk_entry_get_overwrite_mode(). -func (v *Entry) GetOverwriteMode() bool { - c := C.gtk_entry_get_overwrite_mode(v.native()) - return gobool(c) -} - -// TODO(jrick) Pangolayout -/* -func (v *Entry) GetLayout() { -} -*/ - -// GetLayoutOffsets() is a wrapper around gtk_entry_get_layout_offsets(). -func (v *Entry) GetLayoutOffsets() (x, y int) { - var gx, gy C.gint - C.gtk_entry_get_layout_offsets(v.native(), &gx, &gy) - return int(gx), int(gy) -} - -// LayoutIndexToTextIndex() is a wrapper around -// gtk_entry_layout_index_to_text_index(). -func (v *Entry) LayoutIndexToTextIndex(layoutIndex int) int { - c := C.gtk_entry_layout_index_to_text_index(v.native(), - C.gint(layoutIndex)) - return int(c) -} - -// TextIndexToLayoutIndex() is a wrapper around -// gtk_entry_text_index_to_layout_index(). -func (v *Entry) TextIndexToLayoutIndex(textIndex int) int { - c := C.gtk_entry_text_index_to_layout_index(v.native(), - C.gint(textIndex)) - return int(c) -} - -// TODO(jrick) PandoAttrList -/* -func (v *Entry) SetAttributes() { -} -*/ - -// TODO(jrick) PandoAttrList -/* -func (v *Entry) GetAttributes() { -} -*/ - -// GetMaxLength() is a wrapper around gtk_entry_get_max_length(). -func (v *Entry) GetMaxLength() int { - c := C.gtk_entry_get_max_length(v.native()) - return int(c) -} - -// GetVisibility() is a wrapper around gtk_entry_get_visibility(). -func (v *Entry) GetVisibility() bool { - c := C.gtk_entry_get_visibility(v.native()) - return gobool(c) -} - -// SetCompletion() is a wrapper around gtk_entry_set_completion(). -func (v *Entry) SetCompletion(completion *EntryCompletion) { - C.gtk_entry_set_completion(v.native(), completion.native()) -} - -// GetCompletion() is a wrapper around gtk_entry_get_completion(). -func (v *Entry) GetCompletion() (*EntryCompletion, error) { - c := C.gtk_entry_get_completion(v.native()) - if c == nil { - return nil, nilPtrErr - } - - e := &EntryCompletion{wrapObject(unsafe.Pointer(c))} - return e, nil -} - -// SetCursorHAdjustment() is a wrapper around -// gtk_entry_set_cursor_hadjustment(). -func (v *Entry) SetCursorHAdjustment(adjustment *Adjustment) { - C.gtk_entry_set_cursor_hadjustment(v.native(), adjustment.native()) -} - -// GetCursorHAdjustment() is a wrapper around -// gtk_entry_get_cursor_hadjustment(). -func (v *Entry) GetCursorHAdjustment() (*Adjustment, error) { - c := C.gtk_entry_get_cursor_hadjustment(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return &Adjustment{glib.InitiallyUnowned{obj}}, nil -} - -// SetProgressFraction() is a wrapper around gtk_entry_set_progress_fraction(). -func (v *Entry) SetProgressFraction(fraction float64) { - C.gtk_entry_set_progress_fraction(v.native(), C.gdouble(fraction)) -} - -// GetProgressFraction() is a wrapper around gtk_entry_get_progress_fraction(). -func (v *Entry) GetProgressFraction() float64 { - c := C.gtk_entry_get_progress_fraction(v.native()) - return float64(c) -} - -// SetProgressPulseStep() is a wrapper around -// gtk_entry_set_progress_pulse_step(). -func (v *Entry) SetProgressPulseStep(fraction float64) { - C.gtk_entry_set_progress_pulse_step(v.native(), C.gdouble(fraction)) -} - -// GetProgressPulseStep() is a wrapper around -// gtk_entry_get_progress_pulse_step(). -func (v *Entry) GetProgressPulseStep() float64 { - c := C.gtk_entry_get_progress_pulse_step(v.native()) - return float64(c) -} - -// ProgressPulse() is a wrapper around gtk_entry_progress_pulse(). -func (v *Entry) ProgressPulse() { - C.gtk_entry_progress_pulse(v.native()) -} - -// TODO(jrick) GdkEventKey -/* -func (v *Entry) IMContextFilterKeypress() { -} -*/ - -// ResetIMContext() is a wrapper around gtk_entry_reset_im_context(). -func (v *Entry) ResetIMContext() { - C.gtk_entry_reset_im_context(v.native()) -} - -// TODO(jrick) GdkPixbuf -/* -func (v *Entry) SetIconFromPixbuf() { -} -*/ - -// SetIconFromIconName() is a wrapper around -// gtk_entry_set_icon_from_icon_name(). -func (v *Entry) SetIconFromIconName(iconPos EntryIconPosition, name string) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_entry_set_icon_from_icon_name(v.native(), - C.GtkEntryIconPosition(iconPos), (*C.gchar)(cstr)) -} - -// TODO(jrick) GIcon -/* -func (v *Entry) SetIconFromGIcon() { -} -*/ - -// GetIconStorageType() is a wrapper around gtk_entry_get_icon_storage_type(). -func (v *Entry) GetIconStorageType(iconPos EntryIconPosition) ImageType { - c := C.gtk_entry_get_icon_storage_type(v.native(), - C.GtkEntryIconPosition(iconPos)) - return ImageType(c) -} - -// TODO(jrick) GdkPixbuf -/* -func (v *Entry) GetIconPixbuf() { -} -*/ - -// GetIconName() is a wrapper around gtk_entry_get_icon_name(). -func (v *Entry) GetIconName(iconPos EntryIconPosition) (string, error) { - c := C.gtk_entry_get_icon_name(v.native(), - C.GtkEntryIconPosition(iconPos)) - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// TODO(jrick) GIcon -/* -func (v *Entry) GetIconGIcon() { -} -*/ - -// SetIconActivatable() is a wrapper around gtk_entry_set_icon_activatable(). -func (v *Entry) SetIconActivatable(iconPos EntryIconPosition, activatable bool) { - C.gtk_entry_set_icon_activatable(v.native(), - C.GtkEntryIconPosition(iconPos), gbool(activatable)) -} - -// GetIconActivatable() is a wrapper around gtk_entry_get_icon_activatable(). -func (v *Entry) GetIconActivatable(iconPos EntryIconPosition) bool { - c := C.gtk_entry_get_icon_activatable(v.native(), - C.GtkEntryIconPosition(iconPos)) - return gobool(c) -} - -// SetIconSensitive() is a wrapper around gtk_entry_set_icon_sensitive(). -func (v *Entry) SetIconSensitive(iconPos EntryIconPosition, sensitive bool) { - C.gtk_entry_set_icon_sensitive(v.native(), - C.GtkEntryIconPosition(iconPos), gbool(sensitive)) -} - -// GetIconSensitive() is a wrapper around gtk_entry_get_icon_sensitive(). -func (v *Entry) GetIconSensitive(iconPos EntryIconPosition) bool { - c := C.gtk_entry_get_icon_sensitive(v.native(), - C.GtkEntryIconPosition(iconPos)) - return gobool(c) -} - -// GetIconAtPos() is a wrapper around gtk_entry_get_icon_at_pos(). -func (v *Entry) GetIconAtPos(x, y int) int { - c := C.gtk_entry_get_icon_at_pos(v.native(), C.gint(x), C.gint(y)) - return int(c) -} - -// SetIconTooltipText() is a wrapper around gtk_entry_set_icon_tooltip_text(). -func (v *Entry) SetIconTooltipText(iconPos EntryIconPosition, tooltip string) { - cstr := C.CString(tooltip) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_entry_set_icon_tooltip_text(v.native(), - C.GtkEntryIconPosition(iconPos), (*C.gchar)(cstr)) -} - -// GetIconTooltipText() is a wrapper around gtk_entry_get_icon_tooltip_text(). -func (v *Entry) GetIconTooltipText(iconPos EntryIconPosition) (string, error) { - c := C.gtk_entry_get_icon_tooltip_text(v.native(), - C.GtkEntryIconPosition(iconPos)) - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// SetIconTooltipMarkup() is a wrapper around -// gtk_entry_set_icon_tooltip_markup(). -func (v *Entry) SetIconTooltipMarkup(iconPos EntryIconPosition, tooltip string) { - cstr := C.CString(tooltip) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_entry_set_icon_tooltip_markup(v.native(), - C.GtkEntryIconPosition(iconPos), (*C.gchar)(cstr)) -} - -// GetIconTooltipMarkup() is a wrapper around -// gtk_entry_get_icon_tooltip_markup(). -func (v *Entry) GetIconTooltipMarkup(iconPos EntryIconPosition) (string, error) { - c := C.gtk_entry_get_icon_tooltip_markup(v.native(), - C.GtkEntryIconPosition(iconPos)) - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// TODO(jrick) GdkDragAction -/* -func (v *Entry) SetIconDragSource() { -} -*/ - -// GetCurrentIconDragSource() is a wrapper around -// gtk_entry_get_current_icon_drag_source(). -func (v *Entry) GetCurrentIconDragSource() int { - c := C.gtk_entry_get_current_icon_drag_source(v.native()) - return int(c) -} - -// TODO(jrick) GdkRectangle -/* -func (v *Entry) GetIconArea() { -} -*/ - -// SetInputPurpose() is a wrapper around gtk_entry_set_input_purpose(). -func (v *Entry) SetInputPurpose(purpose InputPurpose) { - C.gtk_entry_set_input_purpose(v.native(), C.GtkInputPurpose(purpose)) -} - -// GetInputPurpose() is a wrapper around gtk_entry_get_input_purpose(). -func (v *Entry) GetInputPurpose() InputPurpose { - c := C.gtk_entry_get_input_purpose(v.native()) - return InputPurpose(c) -} - -// SetInputHints() is a wrapper around gtk_entry_set_input_hints(). -func (v *Entry) SetInputHints(hints InputHints) { - C.gtk_entry_set_input_hints(v.native(), C.GtkInputHints(hints)) -} - -// GetInputHints() is a wrapper around gtk_entry_get_input_hints(). -func (v *Entry) GetInputHints() InputHints { - c := C.gtk_entry_get_input_hints(v.native()) - return InputHints(c) -} - -/* - * GtkEntryBuffer - */ - -// EntryBuffer is a representation of GTK's GtkEntryBuffer. -type EntryBuffer struct { - *glib.Object -} - -// native returns a pointer to the underlying GtkEntryBuffer. -func (v *EntryBuffer) native() *C.GtkEntryBuffer { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkEntryBuffer(p) -} - -func marshalEntryBuffer(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapEntryBuffer(obj), nil -} - -func wrapEntryBuffer(obj *glib.Object) *EntryBuffer { - return &EntryBuffer{obj} -} - -// EntryBufferNew() is a wrapper around gtk_entry_buffer_new(). -func EntryBufferNew(initialChars string, nInitialChars int) (*EntryBuffer, error) { - cstr := C.CString(initialChars) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_entry_buffer_new((*C.gchar)(cstr), C.gint(nInitialChars)) - if c == nil { - return nil, nilPtrErr - } - - e := wrapEntryBuffer(wrapObject(unsafe.Pointer(c))) - return e, nil -} - -// GetText() is a wrapper around gtk_entry_buffer_get_text(). A -// non-nil error is returned in the case that gtk_entry_buffer_get_text -// returns NULL to differentiate between NULL and an empty string. -func (v *EntryBuffer) GetText() (string, error) { - c := C.gtk_entry_buffer_get_text(v.native()) - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// SetText() is a wrapper around gtk_entry_buffer_set_text(). -func (v *EntryBuffer) SetText(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_entry_buffer_set_text(v.native(), (*C.gchar)(cstr), - C.gint(len(text))) -} - -// GetBytes() is a wrapper around gtk_entry_buffer_get_bytes(). -func (v *EntryBuffer) GetBytes() uint { - c := C.gtk_entry_buffer_get_bytes(v.native()) - return uint(c) -} - -// GetLength() is a wrapper around gtk_entry_buffer_get_length(). -func (v *EntryBuffer) GetLength() uint { - c := C.gtk_entry_buffer_get_length(v.native()) - return uint(c) -} - -// GetMaxLength() is a wrapper around gtk_entry_buffer_get_max_length(). -func (v *EntryBuffer) GetMaxLength() int { - c := C.gtk_entry_buffer_get_max_length(v.native()) - return int(c) -} - -// SetMaxLength() is a wrapper around gtk_entry_buffer_set_max_length(). -func (v *EntryBuffer) SetMaxLength(maxLength int) { - C.gtk_entry_buffer_set_max_length(v.native(), C.gint(maxLength)) -} - -// InsertText() is a wrapper around gtk_entry_buffer_insert_text(). -func (v *EntryBuffer) InsertText(position uint, text string) uint { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_entry_buffer_insert_text(v.native(), C.guint(position), - (*C.gchar)(cstr), C.gint(len(text))) - return uint(c) -} - -// DeleteText() is a wrapper around gtk_entry_buffer_delete_text(). -func (v *EntryBuffer) DeleteText(position uint, nChars int) uint { - c := C.gtk_entry_buffer_delete_text(v.native(), C.guint(position), - C.gint(nChars)) - return uint(c) -} - -// EmitDeletedText() is a wrapper around gtk_entry_buffer_emit_deleted_text(). -func (v *EntryBuffer) EmitDeletedText(pos, nChars uint) { - C.gtk_entry_buffer_emit_deleted_text(v.native(), C.guint(pos), - C.guint(nChars)) -} - -// EmitInsertedText() is a wrapper around gtk_entry_buffer_emit_inserted_text(). -func (v *EntryBuffer) EmitInsertedText(pos uint, text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_entry_buffer_emit_inserted_text(v.native(), C.guint(pos), - (*C.gchar)(cstr), C.guint(len(text))) -} - -/* - * GtkEntryCompletion - */ - -// EntryCompletion is a representation of GTK's GtkEntryCompletion. -type EntryCompletion struct { - *glib.Object -} - -// native returns a pointer to the underlying GtkEntryCompletion. -func (v *EntryCompletion) native() *C.GtkEntryCompletion { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkEntryCompletion(p) -} - -func marshalEntryCompletion(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapEntryCompletion(obj), nil -} - -func wrapEntryCompletion(obj *glib.Object) *EntryCompletion { - return &EntryCompletion{obj} -} - -/* - * GtkEventBox - */ - -// EventBox is a representation of GTK's GtkEventBox. -type EventBox struct { - Bin -} - -// native returns a pointer to the underlying GtkEventBox. -func (v *EventBox) native() *C.GtkEventBox { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkEventBox(p) -} - -func marshalEventBox(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapEventBox(obj), nil -} - -func wrapEventBox(obj *glib.Object) *EventBox { - return &EventBox{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// EventBoxNew is a wrapper around gtk_event_box_new(). -func EventBoxNew() (*EventBox, error) { - c := C.gtk_event_box_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapEventBox(obj), nil -} - -// SetAboveChild is a wrapper around gtk_event_box_set_above_child(). -func (v *EventBox) SetAboveChild(aboveChild bool) { - C.gtk_event_box_set_above_child(v.native(), gbool(aboveChild)) -} - -// GetAboveChild is a wrapper around gtk_event_box_get_above_child(). -func (v *EventBox) GetAboveChild() bool { - c := C.gtk_event_box_get_above_child(v.native()) - return gobool(c) -} - -// SetVisibleWindow is a wrapper around gtk_event_box_set_visible_window(). -func (v *EventBox) SetVisibleWindow(visibleWindow bool) { - C.gtk_event_box_set_visible_window(v.native(), gbool(visibleWindow)) -} - -// GetVisibleWindow is a wrapper around gtk_event_box_get_visible_window(). -func (v *EventBox) GetVisibleWindow() bool { - c := C.gtk_event_box_get_visible_window(v.native()) - return gobool(c) -} - -/* - * GtkExpander - */ - -// Expander is a representation of GTK's GtkExpander. -type Expander struct { - Bin -} - -// native returns a pointer to the underlying GtkExpander. -func (v *Expander) native() *C.GtkExpander { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkExpander(p) -} - -func marshalExpander(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapExpander(obj), nil -} - -func wrapExpander(obj *glib.Object) *Expander { - return &Expander{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// ExpanderNew is a wrapper around gtk_expander_new(). -func ExpanderNew(label string) (*Expander, error) { - var cstr *C.gchar - if label != "" { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - } - c := C.gtk_expander_new((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapExpander(obj), nil -} - -// SetExpanded is a wrapper around gtk_expander_set_expanded(). -func (v *Expander) SetExpanded(expanded bool) { - C.gtk_expander_set_expanded(v.native(), gbool(expanded)) -} - -// GetExpanded is a wrapper around gtk_expander_get_expanded(). -func (v *Expander) GetExpanded() bool { - c := C.gtk_expander_get_expanded(v.native()) - return gobool(c) -} - -// SetLabel is a wrapper around gtk_expander_set_label(). -func (v *Expander) SetLabel(label string) { - var cstr *C.char - if label != "" { - cstr = C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - } - C.gtk_expander_set_label(v.native(), (*C.gchar)(cstr)) -} - -// GetLabel is a wrapper around gtk_expander_get_label(). -func (v *Expander) GetLabel() string { - c := C.gtk_expander_get_label(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetLabelWidget is a wrapper around gtk_expander_set_label_widget(). -func (v *Expander) SetLabelWidget(widget IWidget) { - C.gtk_expander_set_label_widget(v.native(), widget.toWidget()) -} - -/* - * GtkFileChooser - */ - -// FileChoser is a representation of GTK's GtkFileChooser GInterface. -type FileChooser struct { - *glib.Object -} - -// native returns a pointer to the underlying GObject as a GtkFileChooser. -func (v *FileChooser) native() *C.GtkFileChooser { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkFileChooser(p) -} - -func marshalFileChooser(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapFileChooser(obj), nil -} - -func wrapFileChooser(obj *glib.Object) *FileChooser { - return &FileChooser{obj} -} - -// GetFilename is a wrapper around gtk_file_chooser_get_filename(). -func (v *FileChooser) GetFilename() string { - c := C.gtk_file_chooser_get_filename(v.native()) - s := C.GoString((*C.char)(c)) - defer C.g_free((C.gpointer)(c)) - return s -} - -// SetCurrentName is a wrapper around gtk_file_chooser_set_current_name(). -func (v *FileChooser) SetCurrentName(name string) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_file_chooser_set_current_name(v.native(), (*C.gchar)(cstr)) - return -} - -// SetCurrentFolder is a wrapper around gtk_file_chooser_set_current_folder(). -func (v *FileChooser) SetCurrentFolder(folder string) bool { - cstr := C.CString(folder) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_file_chooser_set_current_folder(v.native(), (*C.gchar)(cstr)) - return gobool(c) -} - -// GetCurrentFolder is a wrapper around gtk_file_chooser_get_current_folder(). -func (v *FileChooser) GetCurrentFolder() (string, error) { - c := C.gtk_file_chooser_get_current_folder(v.native()) - if c == nil { - return "", nilPtrErr - } - defer C.free(unsafe.Pointer(c)) - return C.GoString((*C.char)(c)), nil -} - -// SetPreviewWidget is a wrapper around gtk_file_chooser_set_preview_widget(). -func (v *FileChooser) SetPreviewWidget(widget IWidget) { - C.gtk_file_chooser_set_preview_widget(v.native(), widget.toWidget()) -} - -// SetPreviewWidgetActive is a wrapper around gtk_file_chooser_set_preview_widget_active(). -func (v *FileChooser) SetPreviewWidgetActive(active bool) { - C.gtk_file_chooser_set_preview_widget_active(v.native(), gbool(active)) -} - -// GetPreviewFilename is a wrapper around gtk_file_chooser_get_preview_filename(). -func (v *FileChooser) GetPreviewFilename() string { - c := C.gtk_file_chooser_get_preview_filename(v.native()) - defer C.free(unsafe.Pointer(c)) - return C.GoString(c) -} - -// AddFilter is a wrapper around gtk_file_chooser_add_filter(). -func (v *FileChooser) AddFilter(filter *FileFilter) { - C.gtk_file_chooser_add_filter(v.native(), filter.native()) -} - -// GetURI is a wrapper around gtk_file_chooser_get_uri(). -func (v *FileChooser) GetURI() string { - c := C.gtk_file_chooser_get_uri(v.native()) - s := C.GoString((*C.char)(c)) - defer C.g_free((C.gpointer)(c)) - return s -} - -// AddShortcutFolder is a wrapper around gtk_file_chooser_add_shortcut_folder(). -func (v *FileChooser) AddShortcutFolder(folder string) bool { - cstr := C.CString(folder) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_file_chooser_add_shortcut_folder(v.native(), cstr, nil) - return gobool(c) -} - -/* - * GtkFileChooserButton - */ - -// FileChooserButton is a representation of GTK's GtkFileChooserButton. -type FileChooserButton struct { - Box - - // Interfaces - FileChooser -} - -// native returns a pointer to the underlying GtkFileChooserButton. -func (v *FileChooserButton) native() *C.GtkFileChooserButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkFileChooserButton(p) -} - -func marshalFileChooserButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapFileChooserButton(obj), nil -} - -func wrapFileChooserButton(obj *glib.Object) *FileChooserButton { - fc := wrapFileChooser(obj) - return &FileChooserButton{Box{Container{Widget{glib.InitiallyUnowned{obj}}}}, *fc} -} - -// FileChooserButtonNew is a wrapper around gtk_file_chooser_button_new(). -func FileChooserButtonNew(title string, action FileChooserAction) (*FileChooserButton, error) { - cstr := C.CString(title) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_file_chooser_button_new((*C.gchar)(cstr), - (C.GtkFileChooserAction)(action)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapFileChooserButton(obj), nil -} - -/* - * GtkFileChooserDialog - */ - -// FileChooserDialog is a representation of GTK's GtkFileChooserDialog. -type FileChooserDialog struct { - Dialog - - // Interfaces - FileChooser -} - -// native returns a pointer to the underlying GtkFileChooserDialog. -func (v *FileChooserDialog) native() *C.GtkFileChooserDialog { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkFileChooserDialog(p) -} - -func marshalFileChooserDialog(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapFileChooserDialog(obj), nil -} - -func wrapFileChooserDialog(obj *glib.Object) *FileChooserDialog { - fc := wrapFileChooser(obj) - return &FileChooserDialog{Dialog{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}}, *fc} -} - -// FileChooserDialogNewWith1Button is a wrapper around gtk_file_chooser_dialog_new() with one button. -func FileChooserDialogNewWith1Button( - title string, - parent *Window, - action FileChooserAction, - first_button_text string, - first_button_id ResponseType) (*FileChooserDialog, error) { - c_title := C.CString(title) - defer C.free(unsafe.Pointer(c_title)) - c_first_button_text := C.CString(first_button_text) - defer C.free(unsafe.Pointer(c_first_button_text)) - c := C.gtk_file_chooser_dialog_new_1( - (*C.gchar)(c_title), parent.native(), C.GtkFileChooserAction(action), - (*C.gchar)(c_first_button_text), C.int(first_button_id)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapFileChooserDialog(obj), nil -} - -// FileChooserDialogNewWith2Buttons is a wrapper around gtk_file_chooser_dialog_new() with two buttons. -func FileChooserDialogNewWith2Buttons( - title string, - parent *Window, - action FileChooserAction, - first_button_text string, - first_button_id ResponseType, - second_button_text string, - second_button_id ResponseType) (*FileChooserDialog, error) { - c_title := C.CString(title) - defer C.free(unsafe.Pointer(c_title)) - c_first_button_text := C.CString(first_button_text) - defer C.free(unsafe.Pointer(c_first_button_text)) - c_second_button_text := C.CString(second_button_text) - defer C.free(unsafe.Pointer(c_second_button_text)) - c := C.gtk_file_chooser_dialog_new_2( - (*C.gchar)(c_title), parent.native(), C.GtkFileChooserAction(action), - (*C.gchar)(c_first_button_text), C.int(first_button_id), - (*C.gchar)(c_second_button_text), C.int(second_button_id)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapFileChooserDialog(obj), nil -} - -/* - * GtkFileChooserWidget - */ - -// FileChooserWidget is a representation of GTK's GtkFileChooserWidget. -type FileChooserWidget struct { - Box - - // Interfaces - FileChooser -} - -// native returns a pointer to the underlying GtkFileChooserWidget. -func (v *FileChooserWidget) native() *C.GtkFileChooserWidget { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkFileChooserWidget(p) -} - -func marshalFileChooserWidget(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapFileChooserWidget(obj), nil -} - -func wrapFileChooserWidget(obj *glib.Object) *FileChooserWidget { - fc := wrapFileChooser(obj) - return &FileChooserWidget{Box{Container{Widget{glib.InitiallyUnowned{obj}}}}, *fc} -} - -// FileChooserWidgetNew is a wrapper around gtk_file_chooser_widget_new(). -func FileChooserWidgetNew(action FileChooserAction) (*FileChooserWidget, error) { - c := C.gtk_file_chooser_widget_new((C.GtkFileChooserAction)(action)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapFileChooserWidget(obj), nil -} - -/* - * GtkFileFilter - */ - -// FileChoser is a representation of GTK's GtkFileFilter GInterface. -type FileFilter struct { - *glib.Object -} - -// native returns a pointer to the underlying GObject as a GtkFileFilter. -func (v *FileFilter) native() *C.GtkFileFilter { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkFileFilter(p) -} - -func marshalFileFilter(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapFileFilter(obj), nil -} - -func wrapFileFilter(obj *glib.Object) *FileFilter { - return &FileFilter{obj} -} - -// FileFilterNew is a wrapper around gtk_file_filter_new(). -func FileFilterNew() (*FileFilter, error) { - c := C.gtk_file_filter_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapFileFilter(obj), nil -} - -// SetName is a wrapper around gtk_file_filter_set_name(). -func (v *FileFilter) SetName(name string) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_file_filter_set_name(v.native(), (*C.gchar)(cstr)) -} - -// AddPattern is a wrapper around gtk_file_filter_add_pattern(). -func (v *FileFilter) AddPattern(pattern string) { - cstr := C.CString(pattern) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_file_filter_add_pattern(v.native(), (*C.gchar)(cstr)) -} - -// AddPixbufFormats is a wrapper around gtk_file_filter_add_pixbuf_formats(). -func (v *FileFilter) AddPixbufFormats() { - C.gtk_file_filter_add_pixbuf_formats(v.native()) -} - -/* - * GtkFontButton - */ - -// FontButton is a representation of GTK's GtkFontButton. -type FontButton struct { - Button -} - -// native returns a pointer to the underlying GtkFontButton. -func (v *FontButton) native() *C.GtkFontButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkFontButton(p) -} - -func marshalFontButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapFontButton(obj), nil -} - -func wrapFontButton(obj *glib.Object) *FontButton { - return &FontButton{Button{Bin{Container{Widget{ - glib.InitiallyUnowned{obj}}}}}} -} - -// FontButtonNew is a wrapper around gtk_font_button_new(). -func FontButtonNew() (*FontButton, error) { - c := C.gtk_font_button_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapFontButton(obj), nil -} - -// FontButtonNewWithFont is a wrapper around gtk_font_button_new_with_font(). -func FontButtonNewWithFont(fontname string) (*FontButton, error) { - cstr := C.CString(fontname) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_font_button_new_with_font((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapFontButton(obj), nil -} - -// GetFontName is a wrapper around gtk_font_button_get_font_name(). -func (v *FontButton) GetFontName() string { - c := C.gtk_font_button_get_font_name(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetFontName is a wrapper around gtk_font_button_set_font_name(). -func (v *FontButton) SetFontName(fontname string) bool { - cstr := C.CString(fontname) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_font_button_set_font_name(v.native(), (*C.gchar)(cstr)) - return gobool(c) -} - -/* - * GtkFrame - */ - -// Frame is a representation of GTK's GtkFrame. -type Frame struct { - Bin -} - -// native returns a pointer to the underlying GtkFrame. -func (v *Frame) native() *C.GtkFrame { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkFrame(p) -} - -func marshalFrame(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapFrame(obj), nil -} - -func wrapFrame(obj *glib.Object) *Frame { - return &Frame{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// FrameNew is a wrapper around gtk_frame_new(). -func FrameNew(label string) (*Frame, error) { - var cstr *C.char - if label != "" { - cstr = C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - } - c := C.gtk_frame_new((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapFrame(obj), nil -} - -// SetLabel is a wrapper around gtk_frame_set_label(). -func (v *Frame) SetLabel(label string) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_frame_set_label(v.native(), (*C.gchar)(cstr)) -} - -// SetLabelWidget is a wrapper around gtk_frame_set_label_widget(). -func (v *Frame) SetLabelWidget(labelWidget IWidget) { - C.gtk_frame_set_label_widget(v.native(), labelWidget.toWidget()) -} - -// SetLabelAlign is a wrapper around gtk_frame_set_label_align(). -func (v *Frame) SetLabelAlign(xAlign, yAlign float32) { - C.gtk_frame_set_label_align(v.native(), C.gfloat(xAlign), - C.gfloat(yAlign)) -} - -// SetShadowType is a wrapper around gtk_frame_set_shadow_type(). -func (v *Frame) SetShadowType(t ShadowType) { - C.gtk_frame_set_shadow_type(v.native(), C.GtkShadowType(t)) -} - -// GetLabel is a wrapper around gtk_frame_get_label(). -func (v *Frame) GetLabel() string { - c := C.gtk_frame_get_label(v.native()) - return C.GoString((*C.char)(c)) -} - -// GetLabelAlign is a wrapper around gtk_frame_get_label_align(). -func (v *Frame) GetLabelAlign() (xAlign, yAlign float32) { - var x, y C.gfloat - C.gtk_frame_get_label_align(v.native(), &x, &y) - return float32(x), float32(y) -} - -// GetLabelWidget is a wrapper around gtk_frame_get_label_widget(). -func (v *Frame) GetLabelWidget() (*Widget, error) { - c := C.gtk_frame_get_label_widget(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapWidget(obj), nil -} - -// GetShadowType is a wrapper around gtk_frame_get_shadow_type(). -func (v *Frame) GetShadowType() ShadowType { - c := C.gtk_frame_get_shadow_type(v.native()) - return ShadowType(c) -} - -/* - * GtkGrid - */ - -// Grid is a representation of GTK's GtkGrid. -type Grid struct { - Container - - // Interfaces - Orientable -} - -// native returns a pointer to the underlying GtkGrid. -func (v *Grid) native() *C.GtkGrid { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkGrid(p) -} - -func (v *Grid) toOrientable() *C.GtkOrientable { - if v == nil { - return nil - } - return C.toGtkOrientable(unsafe.Pointer(v.GObject)) -} - -func marshalGrid(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapGrid(obj), nil -} - -func wrapGrid(obj *glib.Object) *Grid { - o := wrapOrientable(obj) - return &Grid{Container{Widget{glib.InitiallyUnowned{obj}}}, *o} -} - -// GridNew() is a wrapper around gtk_grid_new(). -func GridNew() (*Grid, error) { - c := C.gtk_grid_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapGrid(obj), nil -} - -// Attach() is a wrapper around gtk_grid_attach(). -func (v *Grid) Attach(child IWidget, left, top, width, height int) { - C.gtk_grid_attach(v.native(), child.toWidget(), C.gint(left), - C.gint(top), C.gint(width), C.gint(height)) -} - -// AttachNextTo() is a wrapper around gtk_grid_attach_next_to(). -func (v *Grid) AttachNextTo(child, sibling IWidget, side PositionType, width, height int) { - C.gtk_grid_attach_next_to(v.native(), child.toWidget(), - sibling.toWidget(), C.GtkPositionType(side), C.gint(width), - C.gint(height)) -} - -// GetChildAt() is a wrapper around gtk_grid_get_child_at(). -func (v *Grid) GetChildAt(left, top int) (*Widget, error) { - c := C.gtk_grid_get_child_at(v.native(), C.gint(left), C.gint(top)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapWidget(obj), nil -} - -// InsertRow() is a wrapper around gtk_grid_insert_row(). -func (v *Grid) InsertRow(position int) { - C.gtk_grid_insert_row(v.native(), C.gint(position)) -} - -// InsertColumn() is a wrapper around gtk_grid_insert_column(). -func (v *Grid) InsertColumn(position int) { - C.gtk_grid_insert_column(v.native(), C.gint(position)) -} - -// InsertNextTo() is a wrapper around gtk_grid_insert_next_to() -func (v *Grid) InsertNextTo(sibling IWidget, side PositionType) { - C.gtk_grid_insert_next_to(v.native(), sibling.toWidget(), - C.GtkPositionType(side)) -} - -// SetRowHomogeneous() is a wrapper around gtk_grid_set_row_homogeneous(). -func (v *Grid) SetRowHomogeneous(homogeneous bool) { - C.gtk_grid_set_row_homogeneous(v.native(), gbool(homogeneous)) -} - -// GetRowHomogeneous() is a wrapper around gtk_grid_get_row_homogeneous(). -func (v *Grid) GetRowHomogeneous() bool { - c := C.gtk_grid_get_row_homogeneous(v.native()) - return gobool(c) -} - -// SetRowSpacing() is a wrapper around gtk_grid_set_row_spacing(). -func (v *Grid) SetRowSpacing(spacing uint) { - C.gtk_grid_set_row_spacing(v.native(), C.guint(spacing)) -} - -// GetRowSpacing() is a wrapper around gtk_grid_get_row_spacing(). -func (v *Grid) GetRowSpacing() uint { - c := C.gtk_grid_get_row_spacing(v.native()) - return uint(c) -} - -// SetColumnHomogeneous() is a wrapper around gtk_grid_set_column_homogeneous(). -func (v *Grid) SetColumnHomogeneous(homogeneous bool) { - C.gtk_grid_set_column_homogeneous(v.native(), gbool(homogeneous)) -} - -// GetColumnHomogeneous() is a wrapper around gtk_grid_get_column_homogeneous(). -func (v *Grid) GetColumnHomogeneous() bool { - c := C.gtk_grid_get_column_homogeneous(v.native()) - return gobool(c) -} - -// SetColumnSpacing() is a wrapper around gtk_grid_set_column_spacing(). -func (v *Grid) SetColumnSpacing(spacing uint) { - C.gtk_grid_set_column_spacing(v.native(), C.guint(spacing)) -} - -// GetColumnSpacing() is a wrapper around gtk_grid_get_column_spacing(). -func (v *Grid) GetColumnSpacing() uint { - c := C.gtk_grid_get_column_spacing(v.native()) - return uint(c) -} - -/* - * GtkIconTheme - */ - -// IconTheme is a representation of GTK's GtkIconTheme -type IconTheme struct { - Theme *C.GtkIconTheme -} - -// IconThemeGetDefault is a wrapper around gtk_icon_theme_get_default(). -func IconThemeGetDefault() (*IconTheme, error) { - c := C.gtk_icon_theme_get_default() - if c == nil { - return nil, nilPtrErr - } - return &IconTheme{c}, nil -} - -// IconThemeGetForScreen is a wrapper around gtk_icon_theme_get_for_screen(). -func IconThemeGetForScreen(screen gdk.Screen) (*IconTheme, error) { - cScreen := (*C.GdkScreen)(unsafe.Pointer(screen.Native())) - c := C.gtk_icon_theme_get_for_screen(cScreen) - if c == nil { - return nil, nilPtrErr - } - return &IconTheme{c}, nil -} - -// LoadIcon is a wrapper around gtk_icon_theme_load_icon(). -func (v *IconTheme) LoadIcon(iconName string, size int, flags IconLookupFlags) (*gdk.Pixbuf, error) { - cstr := C.CString(iconName) - defer C.free(unsafe.Pointer(cstr)) - var err *C.GError = nil - c := C.gtk_icon_theme_load_icon(v.Theme, (*C.gchar)(cstr), C.gint(size), C.GtkIconLookupFlags(flags), &err) - if c == nil { - defer C.g_error_free(err) - return nil, errors.New(C.GoString((*C.char)(err.message))) - } - return &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))}, nil -} - -/* - * GtkIconView - */ - -// IconView is a representation of GTK's GtkIconView. -type IconView struct { - Container -} - -// native returns a pointer to the underlying GtkIconView. -func (v *IconView) native() *C.GtkIconView { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkIconView(p) -} - -func marshalIconView(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapIconView(obj), nil -} - -func wrapIconView(obj *glib.Object) *IconView { - return &IconView{Container{Widget{glib.InitiallyUnowned{obj}}}} -} - -// IconViewNew is a wrapper around gtk_icon_view_new(). -func IconViewNew() (*IconView, error) { - c := C.gtk_icon_view_new() - if c == nil { - return nil, nilPtrErr - } - - return wrapIconView(wrapObject(unsafe.Pointer(c))), nil -} - -// IconViewNewWithModel is a wrapper around gtk_icon_view_new_with_model(). -func IconViewNewWithModel(model ITreeModel) (*IconView, error) { - c := C.gtk_icon_view_new_with_model(model.toTreeModel()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapIconView(obj), nil -} - -// GetModel is a wrapper around gtk_icon_view_get_model(). -func (v *IconView) GetModel() (*TreeModel, error) { - c := C.gtk_icon_view_get_model(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapTreeModel(obj), nil -} - -// SetModel is a wrapper around gtk_icon_view_set_model(). -func (v *IconView) SetModel(model ITreeModel) { - C.gtk_icon_view_set_model(v.native(), model.toTreeModel()) -} - -// SelectPath is a wrapper around gtk_icon_view_select_path(). -func (v *IconView) SelectPath(path *TreePath) { - C.gtk_icon_view_select_path(v.native(), path.native()) -} - -// ScrollToPath is a wrapper around gtk_icon_view_scroll_to_path(). -func (v *IconView) ScrollToPath(path *TreePath, useAlign bool, rowAlign, colAlign float64) { - C.gtk_icon_view_scroll_to_path(v.native(), path.native(), gbool(useAlign), - C.gfloat(rowAlign), C.gfloat(colAlign)) -} - -/* - * GtkImage - */ - -// Image is a representation of GTK's GtkImage. -type Image struct { - Widget -} - -// native returns a pointer to the underlying GtkImage. -func (v *Image) native() *C.GtkImage { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkImage(p) -} - -func marshalImage(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapImage(obj), nil -} - -func wrapImage(obj *glib.Object) *Image { - return &Image{Widget{glib.InitiallyUnowned{obj}}} -} - -// ImageNew() is a wrapper around gtk_image_new(). -func ImageNew() (*Image, error) { - c := C.gtk_image_new() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapImage(obj), nil -} - -// ImageNewFromFile() is a wrapper around gtk_image_new_from_file(). -func ImageNewFromFile(filename string) (*Image, error) { - cstr := C.CString(filename) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_image_new_from_file((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapImage(obj), nil -} - -// ImageNewFromResource() is a wrapper around gtk_image_new_from_resource(). -func ImageNewFromResource(resourcePath string) (*Image, error) { - cstr := C.CString(resourcePath) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_image_new_from_resource((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapImage(obj), nil -} - -// ImageNewFromPixbuf is a wrapper around gtk_image_new_from_pixbuf(). -func ImageNewFromPixbuf(pixbuf *gdk.Pixbuf) (*Image, error) { - ptr := (*C.GdkPixbuf)(unsafe.Pointer(pixbuf.Native())) - c := C.gtk_image_new_from_pixbuf(ptr) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapImage(obj), nil -} - -// TODO(jrick) GtkIconSet -/* -func ImageNewFromIconSet() { -} -*/ - -// TODO(jrick) GdkPixbufAnimation -/* -func ImageNewFromAnimation() { -} -*/ - -// ImageNewFromIconName() is a wrapper around gtk_image_new_from_icon_name(). -func ImageNewFromIconName(iconName string, size IconSize) (*Image, error) { - cstr := C.CString(iconName) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_image_new_from_icon_name((*C.gchar)(cstr), - C.GtkIconSize(size)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapImage(obj), nil -} - -// TODO(jrick) GIcon -/* -func ImageNewFromGIcon() { -} -*/ - -// Clear() is a wrapper around gtk_image_clear(). -func (v *Image) Clear() { - C.gtk_image_clear(v.native()) -} - -// SetFromFile() is a wrapper around gtk_image_set_from_file(). -func (v *Image) SetFromFile(filename string) { - cstr := C.CString(filename) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_image_set_from_file(v.native(), (*C.gchar)(cstr)) -} - -// SetFromResource() is a wrapper around gtk_image_set_from_resource(). -func (v *Image) SetFromResource(resourcePath string) { - cstr := C.CString(resourcePath) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_image_set_from_resource(v.native(), (*C.gchar)(cstr)) -} - -// SetFromFixbuf is a wrapper around gtk_image_set_from_pixbuf(). -func (v *Image) SetFromPixbuf(pixbuf *gdk.Pixbuf) { - pbptr := (*C.GdkPixbuf)(unsafe.Pointer(pixbuf.Native())) - C.gtk_image_set_from_pixbuf(v.native(), pbptr) -} - -// TODO(jrick) GtkIconSet -/* -func (v *Image) SetFromIconSet() { -} -*/ - -// TODO(jrick) GdkPixbufAnimation -/* -func (v *Image) SetFromAnimation() { -} -*/ - -// SetFromIconName() is a wrapper around gtk_image_set_from_icon_name(). -func (v *Image) SetFromIconName(iconName string, size IconSize) { - cstr := C.CString(iconName) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_image_set_from_icon_name(v.native(), (*C.gchar)(cstr), - C.GtkIconSize(size)) -} - -// TODO(jrick) GIcon -/* -func (v *Image) SetFromGIcon() { -} -*/ - -// SetPixelSize() is a wrapper around gtk_image_set_pixel_size(). -func (v *Image) SetPixelSize(pixelSize int) { - C.gtk_image_set_pixel_size(v.native(), C.gint(pixelSize)) -} - -// GetStorageType() is a wrapper around gtk_image_get_storage_type(). -func (v *Image) GetStorageType() ImageType { - c := C.gtk_image_get_storage_type(v.native()) - return ImageType(c) -} - -// GetPixbuf() is a wrapper around gtk_image_get_pixbuf(). -func (v *Image) GetPixbuf() *gdk.Pixbuf { - c := C.gtk_image_get_pixbuf(v.native()) - if c == nil { - return nil - } - - pb := &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))} - return pb -} - -// TODO(jrick) GtkIconSet -/* -func (v *Image) GetIconSet() { -} -*/ - -// TODO(jrick) GdkPixbufAnimation -/* -func (v *Image) GetAnimation() { -} -*/ - -// GetIconName() is a wrapper around gtk_image_get_icon_name(). -func (v *Image) GetIconName() (string, IconSize) { - var iconName *C.gchar - var size C.GtkIconSize - C.gtk_image_get_icon_name(v.native(), &iconName, &size) - return C.GoString((*C.char)(iconName)), IconSize(size) -} - -// TODO(jrick) GIcon -/* -func (v *Image) GetGIcon() { -} -*/ - -// GetPixelSize() is a wrapper around gtk_image_get_pixel_size(). -func (v *Image) GetPixelSize() int { - c := C.gtk_image_get_pixel_size(v.native()) - return int(c) -} - -// added by terrak -/* - * GtkLayout - */ - -// Layout is a representation of GTK's GtkLayout. -type Layout struct { - Container -} - -// native returns a pointer to the underlying GtkDrawingArea. -func (v *Layout) native() *C.GtkLayout { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkLayout(p) -} - -func marshalLayout(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapLayout(obj), nil -} - -func wrapLayout(obj *glib.Object) *Layout { - return &Layout{Container{Widget{glib.InitiallyUnowned{obj}}}} -} - -// LayoutNew is a wrapper around gtk_layout_new(). -func LayoutNew(hadjustment, vadjustment *Adjustment) (*Layout, error) { - c := C.gtk_layout_new(hadjustment.native(), vadjustment.native()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapLayout(obj), nil -} - -// Layout.Put is a wrapper around gtk_layout_put(). -func (v *Layout) Put(w IWidget, x, y int) { - C.gtk_layout_put(v.native(), w.toWidget(), C.gint(x), C.gint(y)) -} - -// Layout.Move is a wrapper around gtk_layout_move(). -func (v *Layout) Move(w IWidget, x, y int) { - C.gtk_layout_move(v.native(), w.toWidget(), C.gint(x), C.gint(y)) -} - -// Layout.SetSize is a wrapper around gtk_layout_set_size -func (v *Layout) SetSize(width, height uint) { - C.gtk_layout_set_size(v.native(), C.guint(width), C.guint(height)) -} - -// Layout.GetSize is a wrapper around gtk_layout_get_size -func (v *Layout) GetSize() (width, height uint) { - var w, h C.guint - C.gtk_layout_get_size(v.native(), &w, &h) - return uint(w), uint(h) -} - -/* - * GtkLinkButton - */ - -// LinkButton is a representation of GTK's GtkLinkButton. -type LinkButton struct { - Button -} - -// native returns a pointer to the underlying GtkLinkButton. -func (v *LinkButton) native() *C.GtkLinkButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkLinkButton(p) -} - -func marshalLinkButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapLinkButton(obj), nil -} - -func wrapLinkButton(obj *glib.Object) *LinkButton { - return &LinkButton{Button{Bin{Container{Widget{ - glib.InitiallyUnowned{obj}}}}}} -} - -// LinkButtonNew is a wrapper around gtk_link_button_new(). -func LinkButtonNew(label string) (*LinkButton, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_link_button_new((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapLinkButton(wrapObject(unsafe.Pointer(c))), nil -} - -// LinkButtonNewWithLabel is a wrapper around gtk_link_button_new_with_label(). -func LinkButtonNewWithLabel(uri, label string) (*LinkButton, error) { - curi := C.CString(uri) - defer C.free(unsafe.Pointer(curi)) - clabel := C.CString(label) - defer C.free(unsafe.Pointer(clabel)) - c := C.gtk_link_button_new_with_label((*C.gchar)(curi), (*C.gchar)(clabel)) - if c == nil { - return nil, nilPtrErr - } - return wrapLinkButton(wrapObject(unsafe.Pointer(c))), nil -} - -// GetUri is a wrapper around gtk_link_button_get_uri(). -func (v *LinkButton) GetUri() string { - c := C.gtk_link_button_get_uri(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetUri is a wrapper around gtk_link_button_set_uri(). -func (v *LinkButton) SetUri(uri string) { - cstr := C.CString(uri) - C.gtk_link_button_set_uri(v.native(), (*C.gchar)(cstr)) -} - -/* - * GtkListStore - */ - -// ListStore is a representation of GTK's GtkListStore. -type ListStore struct { - *glib.Object - - // Interfaces - TreeModel -} - -// native returns a pointer to the underlying GtkListStore. -func (v *ListStore) native() *C.GtkListStore { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkListStore(p) -} - -func marshalListStore(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapListStore(obj), nil -} - -func wrapListStore(obj *glib.Object) *ListStore { - tm := wrapTreeModel(obj) - return &ListStore{obj, *tm} -} - -func (v *ListStore) toTreeModel() *C.GtkTreeModel { - if v == nil { - return nil - } - return C.toGtkTreeModel(unsafe.Pointer(v.GObject)) -} - -// ListStoreNew is a wrapper around gtk_list_store_newv(). -func ListStoreNew(types ...glib.Type) (*ListStore, error) { - gtypes := C.alloc_types(C.int(len(types))) - for n, val := range types { - C.set_type(gtypes, C.int(n), C.GType(val)) - } - defer C.g_free(C.gpointer(gtypes)) - c := C.gtk_list_store_newv(C.gint(len(types)), gtypes) - if c == nil { - return nil, nilPtrErr - } - - ls := wrapListStore(wrapObject(unsafe.Pointer(c))) - return ls, nil -} - -// Remove is a wrapper around gtk_list_store_remove(). -func (v *ListStore) Remove(iter *TreeIter) bool { - c := C.gtk_list_store_remove(v.native(), iter.native()) - return gobool(c) -} - -// TODO(jrick) -/* -func (v *ListStore) SetColumnTypes(types ...glib.Type) { -} -*/ - -// Set() is a wrapper around gtk_list_store_set_value() but provides -// a function similar to gtk_list_store_set() in that multiple columns -// may be set by one call. The length of columns and values slices must -// match, or Set() will return a non-nil error. -// -// As an example, a call to: -// store.Set(iter, []int{0, 1}, []interface{}{"Foo", "Bar"}) -// is functionally equivalent to calling the native C GTK function: -// gtk_list_store_set(store, iter, 0, "Foo", 1, "Bar", -1); -func (v *ListStore) Set(iter *TreeIter, columns []int, values []interface{}) error { - if len(columns) != len(values) { - return errors.New("columns and values lengths do not match") - } - for i, val := range values { - v.SetValue(iter, columns[i], val) - } - return nil -} - -// SetValue is a wrapper around gtk_list_store_set_value(). -func (v *ListStore) SetValue(iter *TreeIter, column int, value interface{}) error { - switch value.(type) { - case *gdk.Pixbuf: - pix := value.(*gdk.Pixbuf) - C._gtk_list_store_set(v.native(), iter.native(), C.gint(column), unsafe.Pointer(pix.Native())) - - default: - gv, err := glib.GValue(value) - if err != nil { - return err - } - - C.gtk_list_store_set_value(v.native(), iter.native(), - C.gint(column), - (*C.GValue)(unsafe.Pointer(gv.Native()))) - } - - return nil -} - -// func (v *ListStore) Model(model ITreeModel) { -// obj := &glib.Object{glib.ToGObject(unsafe.Pointer(model.toTreeModel()))} -// v.TreeModel = *wrapTreeModel(obj) -//} - -// SetSortColumnId() is a wrapper around gtk_tree_sortable_set_sort_column_id(). -func (v *ListStore) SetSortColumnId(column int, order SortType) { - sort := C.toGtkTreeSortable(unsafe.Pointer(v.Native())) - C.gtk_tree_sortable_set_sort_column_id(sort, C.gint(column), C.GtkSortType(order)) -} - -func (v *ListStore) SetCols(iter *TreeIter, cols Cols) error { - for key, value := range cols { - err := v.SetValue(iter, key, value) - if err != nil { - return err - } - } - return nil -} - -// Convenient map for Columns and values (See ListStore, TreeStore) -type Cols map[int]interface{} - -// TODO(jrick) -/* -func (v *ListStore) InsertWithValues(iter *TreeIter, position int, columns []int, values []glib.Value) { - var ccolumns *C.gint - var cvalues *C.GValue - - C.gtk_list_store_insert_with_values(v.native(), iter.native(), - C.gint(position), columns, values, C.gint(len(values))) -} -*/ - -// InsertBefore() is a wrapper around gtk_list_store_insert_before(). -func (v *ListStore) InsertBefore(sibling *TreeIter) *TreeIter { - var ti C.GtkTreeIter - C.gtk_list_store_insert_before(v.native(), &ti, sibling.native()) - iter := &TreeIter{ti} - return iter -} - -// InsertAfter() is a wrapper around gtk_list_store_insert_after(). -func (v *ListStore) InsertAfter(sibling *TreeIter) *TreeIter { - var ti C.GtkTreeIter - C.gtk_list_store_insert_after(v.native(), &ti, sibling.native()) - iter := &TreeIter{ti} - return iter -} - -// Prepend() is a wrapper around gtk_list_store_prepend(). -func (v *ListStore) Prepend() *TreeIter { - var ti C.GtkTreeIter - C.gtk_list_store_prepend(v.native(), &ti) - iter := &TreeIter{ti} - return iter -} - -// Append() is a wrapper around gtk_list_store_append(). -func (v *ListStore) Append() *TreeIter { - var ti C.GtkTreeIter - C.gtk_list_store_append(v.native(), &ti) - iter := &TreeIter{ti} - return iter -} - -// Clear() is a wrapper around gtk_list_store_clear(). -func (v *ListStore) Clear() { - C.gtk_list_store_clear(v.native()) -} - -// IterIsValid() is a wrapper around gtk_list_store_iter_is_valid(). -func (v *ListStore) IterIsValid(iter *TreeIter) bool { - c := C.gtk_list_store_iter_is_valid(v.native(), iter.native()) - return gobool(c) -} - -// TODO(jrick) -/* -func (v *ListStore) Reorder(newOrder []int) { -} -*/ - -// Swap() is a wrapper around gtk_list_store_swap(). -func (v *ListStore) Swap(a, b *TreeIter) { - C.gtk_list_store_swap(v.native(), a.native(), b.native()) -} - -// MoveBefore() is a wrapper around gtk_list_store_move_before(). -func (v *ListStore) MoveBefore(iter, position *TreeIter) { - C.gtk_list_store_move_before(v.native(), iter.native(), - position.native()) -} - -// MoveAfter() is a wrapper around gtk_list_store_move_after(). -func (v *ListStore) MoveAfter(iter, position *TreeIter) { - C.gtk_list_store_move_after(v.native(), iter.native(), - position.native()) -} - -/* - * GtkMenu - */ - -// Menu is a representation of GTK's GtkMenu. -type Menu struct { - MenuShell -} - -// IMenu is an interface type implemented by all structs embedding -// a Menu. It is meant to be used as an argument type for wrapper -// functions that wrap around a C GTK function taking a -// GtkMenu. -type IMenu interface { - toMenu() *C.GtkMenu - toWidget() *C.GtkWidget -} - -// native() returns a pointer to the underlying GtkMenu. -func (v *Menu) native() *C.GtkMenu { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkMenu(p) -} - -func (v *Menu) toMenu() *C.GtkMenu { - if v == nil { - return nil - } - return v.native() -} - -func marshalMenu(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapMenu(obj), nil -} - -func wrapMenu(obj *glib.Object) *Menu { - return &Menu{MenuShell{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// MenuNew() is a wrapper around gtk_menu_new(). -func MenuNew() (*Menu, error) { - c := C.gtk_menu_new() - if c == nil { - return nil, nilPtrErr - } - return wrapMenu(wrapObject(unsafe.Pointer(c))), nil -} - -// PopupAtMouse() is a wrapper for gtk_menu_popup(), without the option for a custom positioning function. -func (v *Menu) PopupAtMouseCursor(parentMenuShell IMenu, parentMenuItem IMenuItem, button int, activateTime uint32) { - wshell := nullableWidget(parentMenuShell) - witem := nullableWidget(parentMenuItem) - - C.gtk_menu_popup(v.native(), - wshell, - witem, - nil, - nil, - C.guint(button), - C.guint32(activateTime)) -} - -// Popdown() is a wrapper around gtk_menu_popdown(). -func (v *Menu) Popdown() { - C.gtk_menu_popdown(v.native()) -} - -// ReorderChild() is a wrapper around gtk_menu_reorder_child(). -func (v *Menu) ReorderChild(child IWidget, position int) { - C.gtk_menu_reorder_child(v.native(), child.toWidget(), C.gint(position)) -} - -/* - * GtkMenuBar - */ - -// MenuBar is a representation of GTK's GtkMenuBar. -type MenuBar struct { - MenuShell -} - -// native() returns a pointer to the underlying GtkMenuBar. -func (v *MenuBar) native() *C.GtkMenuBar { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkMenuBar(p) -} - -func marshalMenuBar(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapMenuBar(obj), nil -} - -func wrapMenuBar(obj *glib.Object) *MenuBar { - return &MenuBar{MenuShell{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// MenuBarNew() is a wrapper around gtk_menu_bar_new(). -func MenuBarNew() (*MenuBar, error) { - c := C.gtk_menu_bar_new() - if c == nil { - return nil, nilPtrErr - } - return wrapMenuBar(wrapObject(unsafe.Pointer(c))), nil -} - -/* - * GtkMenuButton - */ - -// MenuButton is a representation of GTK's GtkMenuButton. -type MenuButton struct { - ToggleButton -} - -// native returns a pointer to the underlying GtkMenuButton. -func (v *MenuButton) native() *C.GtkMenuButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkMenuButton(p) -} - -func marshalMenuButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapMenuButton(obj), nil -} - -func wrapMenuButton(obj *glib.Object) *MenuButton { - return &MenuButton{ToggleButton{Button{Bin{Container{Widget{ - glib.InitiallyUnowned{obj}}}}}}} -} - -// MenuButtonNew is a wrapper around gtk_menu_button_new(). -func MenuButtonNew() (*MenuButton, error) { - c := C.gtk_menu_button_new() - if c == nil { - return nil, nilPtrErr - } - return wrapMenuButton(wrapObject(unsafe.Pointer(c))), nil -} - -// SetPopup is a wrapper around gtk_menu_button_set_popup(). -func (v *MenuButton) SetPopup(menu IMenu) { - C.gtk_menu_button_set_popup(v.native(), menu.toWidget()) -} - -// GetPopup is a wrapper around gtk_menu_button_get_popup(). -func (v *MenuButton) GetPopup() *Menu { - c := C.gtk_menu_button_get_popup(v.native()) - if c == nil { - return nil - } - return wrapMenu(wrapObject(unsafe.Pointer(c))) -} - -// TODO: gtk_menu_button_set_menu_model -// TODO: gtk_menu_button_get_menu_model - -// SetDirection is a wrapper around gtk_menu_button_set_direction(). -func (v *MenuButton) SetDirection(direction ArrowType) { - C.gtk_menu_button_set_direction(v.native(), C.GtkArrowType(direction)) -} - -// GetDirection is a wrapper around gtk_menu_button_get_direction(). -func (v *MenuButton) GetDirection() ArrowType { - c := C.gtk_menu_button_get_direction(v.native()) - return ArrowType(c) -} - -// SetAlignWidget is a wrapper around gtk_menu_button_set_align_widget(). -func (v *MenuButton) SetAlignWidget(alignWidget IWidget) { - C.gtk_menu_button_set_align_widget(v.native(), alignWidget.toWidget()) -} - -// GetAlignWidget is a wrapper around gtk_menu_button_get_align_widget(). -func (v *MenuButton) GetAlignWidget() *Widget { - c := C.gtk_menu_button_get_align_widget(v.native()) - if c == nil { - return nil - } - return wrapWidget(wrapObject(unsafe.Pointer(c))) -} - -/* - * GtkMenuItem - */ - -// MenuItem is a representation of GTK's GtkMenuItem. -type MenuItem struct { - Bin -} - -// IMenuItem is an interface type implemented by all structs -// embedding a MenuItem. It is meant to be used as an argument type -// for wrapper functions that wrap around a C GTK function taking a -// GtkMenuItem. -type IMenuItem interface { - toMenuItem() *C.GtkMenuItem - toWidget() *C.GtkWidget -} - -// native returns a pointer to the underlying GtkMenuItem. -func (v *MenuItem) native() *C.GtkMenuItem { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkMenuItem(p) -} - -func (v *MenuItem) toMenuItem() *C.GtkMenuItem { - if v == nil { - return nil - } - return v.native() -} - -func marshalMenuItem(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapMenuItem(obj), nil -} - -func wrapMenuItem(obj *glib.Object) *MenuItem { - return &MenuItem{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// MenuItemNew() is a wrapper around gtk_menu_item_new(). -func MenuItemNew() (*MenuItem, error) { - c := C.gtk_menu_item_new() - if c == nil { - return nil, nilPtrErr - } - return wrapMenuItem(wrapObject(unsafe.Pointer(c))), nil -} - -// MenuItemNewWithLabel() is a wrapper around gtk_menu_item_new_with_label(). -func MenuItemNewWithLabel(label string) (*MenuItem, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_menu_item_new_with_label((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapMenuItem(wrapObject(unsafe.Pointer(c))), nil -} - -// MenuItemNewWithMnemonic() is a wrapper around -// gtk_menu_item_new_with_mnemonic(). -func MenuItemNewWithMnemonic(label string) (*MenuItem, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_menu_item_new_with_mnemonic((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapMenuItem(wrapObject(unsafe.Pointer(c))), nil -} - -// SetSubmenu() is a wrapper around gtk_menu_item_set_submenu(). -func (v *MenuItem) SetSubmenu(submenu IWidget) { - C.gtk_menu_item_set_submenu(v.native(), submenu.toWidget()) -} - -// Sets text on the menu_item label -func (v *MenuItem) SetLabel(label string) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_menu_item_set_label(v.native(), (*C.gchar)(cstr)) -} - -// Gets text on the menu_item label -func (v *MenuItem) GetLabel() string { - l := C.gtk_menu_item_get_label(v.native()) - return C.GoString((*C.char)(l)) -} - -/* - * GtkMessageDialog - */ - -// MessageDialog is a representation of GTK's GtkMessageDialog. -type MessageDialog struct { - Dialog -} - -// native returns a pointer to the underlying GtkMessageDialog. -func (v *MessageDialog) native() *C.GtkMessageDialog { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkMessageDialog(p) -} - -func marshalMessageDialog(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapMessageDialog(obj), nil -} - -func wrapMessageDialog(obj *glib.Object) *MessageDialog { - return &MessageDialog{Dialog{Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}}} -} - -// MessageDialogNew() is a wrapper around gtk_message_dialog_new(). -// The text is created and formatted by the format specifier and any -// additional arguments. -func MessageDialogNew(parent IWindow, flags DialogFlags, mType MessageType, buttons ButtonsType, format string, a ...interface{}) *MessageDialog { - s := fmt.Sprintf(format, a...) - cstr := C.CString(s) - defer C.free(unsafe.Pointer(cstr)) - var w *C.GtkWindow = nil - if parent != nil { - w = parent.toWindow() - } - c := C._gtk_message_dialog_new(w, - C.GtkDialogFlags(flags), C.GtkMessageType(mType), - C.GtkButtonsType(buttons), cstr) - return wrapMessageDialog(wrapObject(unsafe.Pointer(c))) -} - -// MessageDialogNewWithMarkup is a wrapper around -// gtk_message_dialog_new_with_markup(). -func MessageDialogNewWithMarkup(parent IWindow, flags DialogFlags, mType MessageType, buttons ButtonsType, format string, a ...interface{}) *MessageDialog { - s := fmt.Sprintf(format, a...) - cstr := C.CString(s) - defer C.free(unsafe.Pointer(cstr)) - var w *C.GtkWindow = nil - if parent != nil { - w = parent.toWindow() - } - c := C._gtk_message_dialog_new_with_markup(w, - C.GtkDialogFlags(flags), C.GtkMessageType(mType), - C.GtkButtonsType(buttons), cstr) - return wrapMessageDialog(wrapObject(unsafe.Pointer(c))) -} - -// SetMarkup is a wrapper around gtk_message_dialog_set_markup(). -func (v *MessageDialog) SetMarkup(str string) { - cstr := C.CString(str) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_message_dialog_set_markup(v.native(), (*C.gchar)(cstr)) -} - -// FormatSecondaryText is a wrapper around -// gtk_message_dialog_format_secondary_text(). -func (v *MessageDialog) FormatSecondaryText(format string, a ...interface{}) { - s := fmt.Sprintf(format, a...) - cstr := C.CString(s) - defer C.free(unsafe.Pointer(cstr)) - C._gtk_message_dialog_format_secondary_text(v.native(), - (*C.gchar)(cstr)) -} - -// FormatSecondaryMarkup is a wrapper around -// gtk_message_dialog_format_secondary_text(). -func (v *MessageDialog) FormatSecondaryMarkup(format string, a ...interface{}) { - s := fmt.Sprintf(format, a...) - cstr := C.CString(s) - defer C.free(unsafe.Pointer(cstr)) - C._gtk_message_dialog_format_secondary_markup(v.native(), - (*C.gchar)(cstr)) -} - -/* - * GtkNotebook - */ - -// Notebook is a representation of GTK's GtkNotebook. -type Notebook struct { - Container -} - -// native returns a pointer to the underlying GtkNotebook. -func (v *Notebook) native() *C.GtkNotebook { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkNotebook(p) -} - -func marshalNotebook(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapNotebook(obj), nil -} - -func wrapNotebook(obj *glib.Object) *Notebook { - return &Notebook{Container{Widget{glib.InitiallyUnowned{obj}}}} -} - -// NotebookNew() is a wrapper around gtk_notebook_new(). -func NotebookNew() (*Notebook, error) { - c := C.gtk_notebook_new() - if c == nil { - return nil, nilPtrErr - } - return wrapNotebook(wrapObject(unsafe.Pointer(c))), nil -} - -// AppendPage() is a wrapper around gtk_notebook_append_page(). -func (v *Notebook) AppendPage(child IWidget, tabLabel IWidget) int { - cTabLabel := nullableWidget(tabLabel) - c := C.gtk_notebook_append_page(v.native(), child.toWidget(), cTabLabel) - return int(c) -} - -// AppendPageMenu() is a wrapper around gtk_notebook_append_page_menu(). -func (v *Notebook) AppendPageMenu(child IWidget, tabLabel IWidget, menuLabel IWidget) int { - c := C.gtk_notebook_append_page_menu(v.native(), child.toWidget(), - tabLabel.toWidget(), menuLabel.toWidget()) - return int(c) -} - -// PrependPage() is a wrapper around gtk_notebook_prepend_page(). -func (v *Notebook) PrependPage(child IWidget, tabLabel IWidget) int { - cTabLabel := nullableWidget(tabLabel) - c := C.gtk_notebook_prepend_page(v.native(), child.toWidget(), cTabLabel) - return int(c) -} - -// PrependPageMenu() is a wrapper around gtk_notebook_prepend_page_menu(). -func (v *Notebook) PrependPageMenu(child IWidget, tabLabel IWidget, menuLabel IWidget) int { - c := C.gtk_notebook_prepend_page_menu(v.native(), child.toWidget(), - tabLabel.toWidget(), menuLabel.toWidget()) - return int(c) -} - -// InsertPage() is a wrapper around gtk_notebook_insert_page(). -func (v *Notebook) InsertPage(child IWidget, tabLabel IWidget, position int) int { - label := nullableWidget(tabLabel) - c := C.gtk_notebook_insert_page(v.native(), child.toWidget(), label, C.gint(position)) - - return int(c) -} - -// InsertPageMenu() is a wrapper around gtk_notebook_insert_page_menu(). -func (v *Notebook) InsertPageMenu(child IWidget, tabLabel IWidget, menuLabel IWidget, position int) int { - c := C.gtk_notebook_insert_page_menu(v.native(), child.toWidget(), - tabLabel.toWidget(), menuLabel.toWidget(), C.gint(position)) - return int(c) -} - -// RemovePage() is a wrapper around gtk_notebook_remove_page(). -func (v *Notebook) RemovePage(pageNum int) { - C.gtk_notebook_remove_page(v.native(), C.gint(pageNum)) -} - -// PageNum() is a wrapper around gtk_notebook_page_num(). -func (v *Notebook) PageNum(child IWidget) int { - c := C.gtk_notebook_page_num(v.native(), child.toWidget()) - return int(c) -} - -// NextPage() is a wrapper around gtk_notebook_next_page(). -func (v *Notebook) NextPage() { - C.gtk_notebook_next_page(v.native()) -} - -// PrevPage() is a wrapper around gtk_notebook_prev_page(). -func (v *Notebook) PrevPage() { - C.gtk_notebook_prev_page(v.native()) -} - -// ReorderChild() is a wrapper around gtk_notebook_reorder_child(). -func (v *Notebook) ReorderChild(child IWidget, position int) { - C.gtk_notebook_reorder_child(v.native(), child.toWidget(), - C.gint(position)) -} - -// SetTabPos() is a wrapper around gtk_notebook_set_tab_pos(). -func (v *Notebook) SetTabPos(pos PositionType) { - C.gtk_notebook_set_tab_pos(v.native(), C.GtkPositionType(pos)) -} - -// SetShowTabs() is a wrapper around gtk_notebook_set_show_tabs(). -func (v *Notebook) SetShowTabs(showTabs bool) { - C.gtk_notebook_set_show_tabs(v.native(), gbool(showTabs)) -} - -// SetShowBorder() is a wrapper around gtk_notebook_set_show_border(). -func (v *Notebook) SetShowBorder(showBorder bool) { - C.gtk_notebook_set_show_border(v.native(), gbool(showBorder)) -} - -// SetScrollable() is a wrapper around gtk_notebook_set_scrollable(). -func (v *Notebook) SetScrollable(scrollable bool) { - C.gtk_notebook_set_scrollable(v.native(), gbool(scrollable)) -} - -// PopupEnable() is a wrapper around gtk_notebook_popup_enable(). -func (v *Notebook) PopupEnable() { - C.gtk_notebook_popup_enable(v.native()) -} - -// PopupDisable() is a wrapper around gtk_notebook_popup_disable(). -func (v *Notebook) PopupDisable() { - C.gtk_notebook_popup_disable(v.native()) -} - -// GetCurrentPage() is a wrapper around gtk_notebook_get_current_page(). -func (v *Notebook) GetCurrentPage() int { - c := C.gtk_notebook_get_current_page(v.native()) - return int(c) -} - -// GetMenuLabel() is a wrapper around gtk_notebook_get_menu_label(). -func (v *Notebook) GetMenuLabel(child IWidget) (*Widget, error) { - c := C.gtk_notebook_get_menu_label(v.native(), child.toWidget()) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// GetNthPage() is a wrapper around gtk_notebook_get_nth_page(). -func (v *Notebook) GetNthPage(pageNum int) (*Widget, error) { - c := C.gtk_notebook_get_nth_page(v.native(), C.gint(pageNum)) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// GetNPages() is a wrapper around gtk_notebook_get_n_pages(). -func (v *Notebook) GetNPages() int { - c := C.gtk_notebook_get_n_pages(v.native()) - return int(c) -} - -// GetTabLabel() is a wrapper around gtk_notebook_get_tab_label(). -func (v *Notebook) GetTabLabel(child IWidget) (*Widget, error) { - c := C.gtk_notebook_get_tab_label(v.native(), child.toWidget()) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// SetMenuLabel() is a wrapper around gtk_notebook_set_menu_label(). -func (v *Notebook) SetMenuLabel(child, menuLabel IWidget) { - C.gtk_notebook_set_menu_label(v.native(), child.toWidget(), - menuLabel.toWidget()) -} - -// SetMenuLabelText() is a wrapper around gtk_notebook_set_menu_label_text(). -func (v *Notebook) SetMenuLabelText(child IWidget, menuText string) { - cstr := C.CString(menuText) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_notebook_set_menu_label_text(v.native(), child.toWidget(), - (*C.gchar)(cstr)) -} - -// SetTabLabel() is a wrapper around gtk_notebook_set_tab_label(). -func (v *Notebook) SetTabLabel(child, tabLabel IWidget) { - C.gtk_notebook_set_tab_label(v.native(), child.toWidget(), - tabLabel.toWidget()) -} - -// SetTabLabelText() is a wrapper around gtk_notebook_set_tab_label_text(). -func (v *Notebook) SetTabLabelText(child IWidget, tabText string) { - cstr := C.CString(tabText) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_notebook_set_tab_label_text(v.native(), child.toWidget(), - (*C.gchar)(cstr)) -} - -// SetTabReorderable() is a wrapper around gtk_notebook_set_tab_reorderable(). -func (v *Notebook) SetTabReorderable(child IWidget, reorderable bool) { - C.gtk_notebook_set_tab_reorderable(v.native(), child.toWidget(), - gbool(reorderable)) -} - -// SetTabDetachable() is a wrapper around gtk_notebook_set_tab_detachable(). -func (v *Notebook) SetTabDetachable(child IWidget, detachable bool) { - C.gtk_notebook_set_tab_detachable(v.native(), child.toWidget(), - gbool(detachable)) -} - -// GetMenuLabelText() is a wrapper around gtk_notebook_get_menu_label_text(). -func (v *Notebook) GetMenuLabelText(child IWidget) (string, error) { - c := C.gtk_notebook_get_menu_label_text(v.native(), child.toWidget()) - if c == nil { - return "", errors.New("No menu label for widget") - } - return C.GoString((*C.char)(c)), nil -} - -// GetScrollable() is a wrapper around gtk_notebook_get_scrollable(). -func (v *Notebook) GetScrollable() bool { - c := C.gtk_notebook_get_scrollable(v.native()) - return gobool(c) -} - -// GetShowBorder() is a wrapper around gtk_notebook_get_show_border(). -func (v *Notebook) GetShowBorder() bool { - c := C.gtk_notebook_get_show_border(v.native()) - return gobool(c) -} - -// GetShowTabs() is a wrapper around gtk_notebook_get_show_tabs(). -func (v *Notebook) GetShowTabs() bool { - c := C.gtk_notebook_get_show_tabs(v.native()) - return gobool(c) -} - -// GetTabLabelText() is a wrapper around gtk_notebook_get_tab_label_text(). -func (v *Notebook) GetTabLabelText(child IWidget) (string, error) { - c := C.gtk_notebook_get_tab_label_text(v.native(), child.toWidget()) - if c == nil { - return "", errors.New("No tab label for widget") - } - return C.GoString((*C.char)(c)), nil -} - -// GetTabPos() is a wrapper around gtk_notebook_get_tab_pos(). -func (v *Notebook) GetTabPos() PositionType { - c := C.gtk_notebook_get_tab_pos(v.native()) - return PositionType(c) -} - -// GetTabReorderable() is a wrapper around gtk_notebook_get_tab_reorderable(). -func (v *Notebook) GetTabReorderable(child IWidget) bool { - c := C.gtk_notebook_get_tab_reorderable(v.native(), child.toWidget()) - return gobool(c) -} - -// GetTabDetachable() is a wrapper around gtk_notebook_get_tab_detachable(). -func (v *Notebook) GetTabDetachable(child IWidget) bool { - c := C.gtk_notebook_get_tab_detachable(v.native(), child.toWidget()) - return gobool(c) -} - -// SetCurrentPage() is a wrapper around gtk_notebook_set_current_page(). -func (v *Notebook) SetCurrentPage(pageNum int) { - C.gtk_notebook_set_current_page(v.native(), C.gint(pageNum)) -} - -// SetGroupName() is a wrapper around gtk_notebook_set_group_name(). -func (v *Notebook) SetGroupName(groupName string) { - cstr := C.CString(groupName) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_notebook_set_group_name(v.native(), (*C.gchar)(cstr)) -} - -// GetGroupName() is a wrapper around gtk_notebook_get_group_name(). -func (v *Notebook) GetGroupName() (string, error) { - c := C.gtk_notebook_get_group_name(v.native()) - if c == nil { - return "", errors.New("No group name") - } - return C.GoString((*C.char)(c)), nil -} - -// SetActionWidget() is a wrapper around gtk_notebook_set_action_widget(). -func (v *Notebook) SetActionWidget(widget IWidget, packType PackType) { - C.gtk_notebook_set_action_widget(v.native(), widget.toWidget(), - C.GtkPackType(packType)) -} - -// GetActionWidget() is a wrapper around gtk_notebook_get_action_widget(). -func (v *Notebook) GetActionWidget(packType PackType) (*Widget, error) { - c := C.gtk_notebook_get_action_widget(v.native(), - C.GtkPackType(packType)) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -/* - * GtkOffscreenWindow - */ - -// OffscreenWindow is a representation of GTK's GtkOffscreenWindow. -type OffscreenWindow struct { - Window -} - -// native returns a pointer to the underlying GtkOffscreenWindow. -func (v *OffscreenWindow) native() *C.GtkOffscreenWindow { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkOffscreenWindow(p) -} - -func marshalOffscreenWindow(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapOffscreenWindow(obj), nil -} - -func wrapOffscreenWindow(obj *glib.Object) *OffscreenWindow { - return &OffscreenWindow{Window{Bin{Container{Widget{ - glib.InitiallyUnowned{obj}}}}}} -} - -// OffscreenWindowNew is a wrapper around gtk_offscreen_window_new(). -func OffscreenWindowNew() (*OffscreenWindow, error) { - c := C.gtk_offscreen_window_new() - if c == nil { - return nil, nilPtrErr - } - return wrapOffscreenWindow(wrapObject(unsafe.Pointer(c))), nil -} - -// GetSurface is a wrapper around gtk_offscreen_window_get_surface(). -// The returned surface is safe to use over window resizes. -func (v *OffscreenWindow) GetSurface() (*cairo.Surface, error) { - c := C.gtk_offscreen_window_get_surface(v.native()) - if c == nil { - return nil, nilPtrErr - } - cairoPtr := (uintptr)(unsafe.Pointer(c)) - s := cairo.NewSurface(cairoPtr, true) - return s, nil -} - -// GetPixbuf is a wrapper around gtk_offscreen_window_get_pixbuf(). -func (v *OffscreenWindow) GetPixbuf() (*gdk.Pixbuf, error) { - c := C.gtk_offscreen_window_get_pixbuf(v.native()) - if c == nil { - return nil, nilPtrErr - } - - // Pixbuf is returned with ref count of 1, so don't increment. - // Is it a floating reference? - pb := &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))} - return pb, nil -} - -/* - * GtkOrientable - */ - -// Orientable is a representation of GTK's GtkOrientable GInterface. -type Orientable struct { - *glib.Object -} - -// IOrientable is an interface type implemented by all structs -// embedding an Orientable. It is meant to be used as an argument type -// for wrapper functions that wrap around a C GTK function taking a -// GtkOrientable. -type IOrientable interface { - toOrientable() *C.GtkOrientable -} - -// native returns a pointer to the underlying GObject as a GtkOrientable. -func (v *Orientable) native() *C.GtkOrientable { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkOrientable(p) -} - -func marshalOrientable(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapOrientable(obj), nil -} - -func wrapOrientable(obj *glib.Object) *Orientable { - return &Orientable{obj} -} - -// GetOrientation() is a wrapper around gtk_orientable_get_orientation(). -func (v *Orientable) GetOrientation() Orientation { - c := C.gtk_orientable_get_orientation(v.native()) - return Orientation(c) -} - -// SetOrientation() is a wrapper around gtk_orientable_set_orientation(). -func (v *Orientable) SetOrientation(orientation Orientation) { - C.gtk_orientable_set_orientation(v.native(), - C.GtkOrientation(orientation)) -} - -/* - * GtkPaned - */ - -// Paned is a representation of GTK's GtkPaned. -type Paned struct { - Bin -} - -// native returns a pointer to the underlying GtkPaned. -func (v *Paned) native() *C.GtkPaned { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkPaned(p) -} - -func marshalPaned(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapPaned(obj), nil -} - -func wrapPaned(obj *glib.Object) *Paned { - return &Paned{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// PanedNew() is a wrapper around gtk_scrolled_window_new(). -func PanedNew(orientation Orientation) (*Paned, error) { - c := C.gtk_paned_new(C.GtkOrientation(orientation)) - if c == nil { - return nil, nilPtrErr - } - return wrapPaned(wrapObject(unsafe.Pointer(c))), nil -} - -// Add1() is a wrapper around gtk_paned_add1(). -func (v *Paned) Add1(child IWidget) { - C.gtk_paned_add1(v.native(), child.toWidget()) -} - -// Add2() is a wrapper around gtk_paned_add2(). -func (v *Paned) Add2(child IWidget) { - C.gtk_paned_add2(v.native(), child.toWidget()) -} - -// Pack1() is a wrapper around gtk_paned_pack1(). -func (v *Paned) Pack1(child IWidget, resize, shrink bool) { - C.gtk_paned_pack1(v.native(), child.toWidget(), gbool(resize), gbool(shrink)) -} - -// Pack2() is a wrapper around gtk_paned_pack2(). -func (v *Paned) Pack2(child IWidget, resize, shrink bool) { - C.gtk_paned_pack2(v.native(), child.toWidget(), gbool(resize), gbool(shrink)) -} - -// SetPosition() is a wrapper around gtk_paned_set_position(). -func (v *Paned) SetPosition(position int) { - C.gtk_paned_set_position(v.native(), C.gint(position)) -} - -// GetChild1() is a wrapper around gtk_paned_get_child1(). -func (v *Paned) GetChild1() (*Widget, error) { - c := C.gtk_paned_get_child1(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// GetChild2() is a wrapper around gtk_paned_get_child2(). -func (v *Paned) GetChild2() (*Widget, error) { - c := C.gtk_paned_get_child2(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// GetHandleWindow() is a wrapper around gtk_paned_get_handle_window(). -func (v *Paned) GetHandleWindow() (*Window, error) { - c := C.gtk_paned_get_handle_window(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapWindow(wrapObject(unsafe.Pointer(c))), nil -} - -// GetPosition() is a wrapper around gtk_paned_get_position(). -func (v *Paned) GetPosition() int { - return int(C.gtk_paned_get_position(v.native())) -} - -/* - * GtkProgressBar - */ - -// ProgressBar is a representation of GTK's GtkProgressBar. -type ProgressBar struct { - Widget -} - -// native returns a pointer to the underlying GtkProgressBar. -func (v *ProgressBar) native() *C.GtkProgressBar { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkProgressBar(p) -} - -func marshalProgressBar(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapProgressBar(obj), nil -} - -func wrapProgressBar(obj *glib.Object) *ProgressBar { - return &ProgressBar{Widget{glib.InitiallyUnowned{obj}}} -} - -// ProgressBarNew() is a wrapper around gtk_progress_bar_new(). -func ProgressBarNew() (*ProgressBar, error) { - c := C.gtk_progress_bar_new() - if c == nil { - return nil, nilPtrErr - } - return wrapProgressBar(wrapObject(unsafe.Pointer(c))), nil -} - -// SetFraction() is a wrapper around gtk_progress_bar_set_fraction(). -func (v *ProgressBar) SetFraction(fraction float64) { - C.gtk_progress_bar_set_fraction(v.native(), C.gdouble(fraction)) -} - -// GetFraction() is a wrapper around gtk_progress_bar_get_fraction(). -func (v *ProgressBar) GetFraction() float64 { - c := C.gtk_progress_bar_get_fraction(v.native()) - return float64(c) -} - -// SetShowText is a wrapper around gtk_progress_bar_set_show_text(). -func (v *ProgressBar) SetShowText(showText bool) { - C.gtk_progress_bar_set_show_text(v.native(), gbool(showText)) -} - -// GetShowText is a wrapper around gtk_progress_bar_get_show_text(). -func (v *ProgressBar) GetShowText() bool { - c := C.gtk_progress_bar_get_show_text(v.native()) - return gobool(c) -} - -// SetText() is a wrapper around gtk_progress_bar_set_text(). -func (v *ProgressBar) SetText(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_progress_bar_set_text(v.native(), (*C.gchar)(cstr)) -} - -/* - * GtkRadioButton - */ - -// RadioButton is a representation of GTK's GtkRadioButton. -type RadioButton struct { - CheckButton -} - -// native returns a pointer to the underlying GtkRadioButton. -func (v *RadioButton) native() *C.GtkRadioButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkRadioButton(p) -} - -func marshalRadioButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapRadioButton(obj), nil -} - -func wrapRadioButton(obj *glib.Object) *RadioButton { - return &RadioButton{CheckButton{ToggleButton{Button{Bin{Container{ - Widget{glib.InitiallyUnowned{obj}}}}}}}} -} - -// RadioButtonNew is a wrapper around gtk_radio_button_new(). -func RadioButtonNew(group *glib.SList) (*RadioButton, error) { - gslist := (*C.GSList)(unsafe.Pointer(group.Native())) - c := C.gtk_radio_button_new(gslist) - if c == nil { - return nil, nilPtrErr - } - return wrapRadioButton(wrapObject(unsafe.Pointer(c))), nil -} - -// RadioButtonNewFromWidget is a wrapper around -// gtk_radio_button_new_from_widget(). -func RadioButtonNewFromWidget(radioGroupMember *RadioButton) (*RadioButton, error) { - c := C.gtk_radio_button_new_from_widget(radioGroupMember.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapRadioButton(wrapObject(unsafe.Pointer(c))), nil -} - -// RadioButtonNewWithLabel is a wrapper around -// gtk_radio_button_new_with_label(). -func RadioButtonNewWithLabel(group *glib.SList, label string) (*RadioButton, error) { - gslist := (*C.GSList)(unsafe.Pointer(group.Native())) - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_radio_button_new_with_label(gslist, (*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapRadioButton(wrapObject(unsafe.Pointer(c))), nil -} - -// RadioButtonNewWithLabelFromWidget is a wrapper around -// gtk_radio_button_new_with_label_from_widget(). -func RadioButtonNewWithLabelFromWidget(radioGroupMember *RadioButton, label string) (*RadioButton, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_radio_button_new_with_label_from_widget(radioGroupMember.native(), - (*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapRadioButton(wrapObject(unsafe.Pointer(c))), nil -} - -// RadioButtonNewWithMnemonic is a wrapper around -// gtk_radio_button_new_with_mnemonic() -func RadioButtonNewWithMnemonic(group *glib.SList, label string) (*RadioButton, error) { - gslist := (*C.GSList)(unsafe.Pointer(group.Native())) - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_radio_button_new_with_mnemonic(gslist, (*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapRadioButton(wrapObject(unsafe.Pointer(c))), nil -} - -// RadioButtonNewWithMnemonicFromWidget is a wrapper around -// gtk_radio_button_new_with_mnemonic_from_widget(). -func RadioButtonNewWithMnemonicFromWidget(radioGroupMember *RadioButton, label string) (*RadioButton, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_radio_button_new_with_mnemonic_from_widget(radioGroupMember.native(), - (*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapRadioButton(wrapObject(unsafe.Pointer(c))), nil -} - -// SetGroup is a wrapper around gtk_radio_button_set_group(). -func (v *RadioButton) SetGroup(group *glib.SList) { - gslist := (*C.GSList)(unsafe.Pointer(group.Native())) - C.gtk_radio_button_set_group(v.native(), gslist) -} - -// GetGroup is a wrapper around gtk_radio_button_get_group(). -func (v *RadioButton) GetGroup() (*glib.SList, error) { - c := C.gtk_radio_button_get_group(v.native()) - if c == nil { - return nil, nilPtrErr - } - return glib.WrapSList(uintptr(unsafe.Pointer(c))), nil -} - -// JoinGroup is a wrapper around gtk_radio_button_join_group(). -func (v *RadioButton) JoinGroup(groupSource *RadioButton) { - C.gtk_radio_button_join_group(v.native(), groupSource.native()) -} - -/* - * GtkRadioMenuItem - */ - -// RadioMenuItem is a representation of GTK's GtkRadioMenuItem. -type RadioMenuItem struct { - CheckMenuItem -} - -// native returns a pointer to the underlying GtkRadioMenuItem. -func (v *RadioMenuItem) native() *C.GtkRadioMenuItem { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkRadioMenuItem(p) -} - -func marshalRadioMenuItem(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapRadioMenuItem(obj), nil -} - -func wrapRadioMenuItem(obj *glib.Object) *RadioMenuItem { - return &RadioMenuItem{CheckMenuItem{MenuItem{Bin{Container{ - Widget{glib.InitiallyUnowned{obj}}}}}}} -} - -// RadioMenuItemNew is a wrapper around gtk_radio_menu_item_new(). -func RadioMenuItemNew(group *glib.SList) (*RadioMenuItem, error) { - gslist := (*C.GSList)(unsafe.Pointer(group.Native())) - c := C.gtk_radio_menu_item_new(gslist) - if c == nil { - return nil, nilPtrErr - } - return wrapRadioMenuItem(wrapObject(unsafe.Pointer(c))), nil -} - -// RadioMenuItemNewWithLabel is a wrapper around -// gtk_radio_menu_item_new_with_label(). -func RadioMenuItemNewWithLabel(group *glib.SList, label string) (*RadioMenuItem, error) { - gslist := (*C.GSList)(unsafe.Pointer(group.Native())) - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_radio_menu_item_new_with_label(gslist, (*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapRadioMenuItem(wrapObject(unsafe.Pointer(c))), nil -} - -// RadioMenuItemNewWithMnemonic is a wrapper around -// gtk_radio_menu_item_new_with_mnemonic(). -func RadioMenuItemNewWithMnemonic(group *glib.SList, label string) (*RadioMenuItem, error) { - gslist := (*C.GSList)(unsafe.Pointer(group.Native())) - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_radio_menu_item_new_with_mnemonic(gslist, (*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapRadioMenuItem(wrapObject(unsafe.Pointer(c))), nil -} - -// RadioMenuItemNewFromWidget is a wrapper around -// gtk_radio_menu_item_new_from_widget(). -func RadioMenuItemNewFromWidget(group *RadioMenuItem) (*RadioMenuItem, error) { - c := C.gtk_radio_menu_item_new_from_widget(group.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapRadioMenuItem(wrapObject(unsafe.Pointer(c))), nil -} - -// RadioMenuItemNewWithLabelFromWidget is a wrapper around -// gtk_radio_menu_item_new_with_label_from_widget(). -func RadioMenuItemNewWithLabelFromWidget(group *RadioMenuItem, label string) (*RadioMenuItem, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_radio_menu_item_new_with_label_from_widget(group.native(), - (*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapRadioMenuItem(wrapObject(unsafe.Pointer(c))), nil -} - -// RadioMenuItemNewWithMnemonicFromWidget is a wrapper around -// gtk_radio_menu_item_new_with_mnemonic_from_widget(). -func RadioMenuItemNewWithMnemonicFromWidget(group *RadioMenuItem, label string) (*RadioMenuItem, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_radio_menu_item_new_with_mnemonic_from_widget(group.native(), - (*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapRadioMenuItem(wrapObject(unsafe.Pointer(c))), nil -} - -// SetGroup is a wrapper around gtk_radio_menu_item_set_group(). -func (v *RadioMenuItem) SetGroup(group *glib.SList) { - gslist := (*C.GSList)(unsafe.Pointer(group.Native())) - C.gtk_radio_menu_item_set_group(v.native(), gslist) -} - -// GetGroup is a wrapper around gtk_radio_menu_item_get_group(). -func (v *RadioMenuItem) GetGroup() (*glib.SList, error) { - c := C.gtk_radio_menu_item_get_group(v.native()) - if c == nil { - return nil, nilPtrErr - } - return glib.WrapSList(uintptr(unsafe.Pointer(c))), nil -} - -/* - * GtkRange - */ - -// Range is a representation of GTK's GtkRange. -type Range struct { - Widget -} - -// native returns a pointer to the underlying GtkRange. -func (v *Range) native() *C.GtkRange { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkRange(p) -} - -func marshalRange(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapRange(obj), nil -} - -func wrapRange(obj *glib.Object) *Range { - return &Range{Widget{glib.InitiallyUnowned{obj}}} -} - -// GetValue is a wrapper around gtk_range_get_value(). -func (v *Range) GetValue() float64 { - c := C.gtk_range_get_value(v.native()) - return float64(c) -} - -// SetValue is a wrapper around gtk_range_set_value(). -func (v *Range) SetValue(value float64) { - C.gtk_range_set_value(v.native(), C.gdouble(value)) -} - -// SetIncrements() is a wrapper around gtk_range_set_increments(). -func (v *Range) SetIncrements(step, page float64) { - C.gtk_range_set_increments(v.native(), C.gdouble(step), C.gdouble(page)) -} - -// SetRange() is a wrapper around gtk_range_set_range(). -func (v *Range) SetRange(min, max float64) { - C.gtk_range_set_range(v.native(), C.gdouble(min), C.gdouble(max)) -} - -// IRecentChooser is an interface type implemented by all structs -// embedding a RecentChooser. It is meant to be used as an argument type -// for wrapper functions that wrap around a C GTK function taking a -// GtkWidget. -type IRecentChooser interface { - toRecentChooser() *C.GtkRecentChooser -} - -/* - * GtkRecentChooser - */ - -// RecentChooser is a representation of GTK's GtkRecentChooser. -type RecentChooser struct { - *glib.Object -} - -// native returns a pointer to the underlying GtkRecentChooser. -func (v *RecentChooser) native() *C.GtkRecentChooser { - if v == nil || v.Object == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkRecentChooser(p) -} - -func wrapRecentChooser(obj *glib.Object) *RecentChooser { - return &RecentChooser{obj} -} - -func (v *RecentChooser) toRecentChooser() *C.GtkRecentChooser { - return v.native() -} - -func (v *RecentChooser) GetCurrentUri() string { - curi := C.gtk_recent_chooser_get_current_uri(v.native()) - uri := C.GoString((*C.char)(curi)) - return uri -} - -func (v *RecentChooser) AddFilter(filter *RecentFilter) { - C.gtk_recent_chooser_add_filter(v.native(), filter.native()) -} - -func (v *RecentChooser) RemoveFilter(filter *RecentFilter) { - C.gtk_recent_chooser_remove_filter(v.native(), filter.native()) -} - -/* - * GtkRecentChooserMenu - */ - -// RecentChooserMenu is a representation of GTK's GtkRecentChooserMenu. -type RecentChooserMenu struct { - Menu - RecentChooser -} - -// native returns a pointer to the underlying GtkRecentManager. -func (v *RecentChooserMenu) native() *C.GtkRecentChooserMenu { - if v == nil || v.Object == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkRecentChooserMenu(p) -} - -func wrapRecentChooserMenu(obj *glib.Object) *RecentChooserMenu { - return &RecentChooserMenu{ - Menu{MenuShell{Container{Widget{glib.InitiallyUnowned{obj}}}}}, - RecentChooser{obj}, - } -} - -/* - * GtkRecentFilter - */ - -// RecentFilter is a representation of GTK's GtkRecentFilter. -type RecentFilter struct { - glib.InitiallyUnowned -} - -// native returns a pointer to the underlying GtkRecentFilter. -func (v *RecentFilter) native() *C.GtkRecentFilter { - if v == nil || v.Object == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkRecentFilter(p) -} - -func wrapRecentFilter(obj *glib.Object) *RecentFilter { - return &RecentFilter{glib.InitiallyUnowned{obj}} -} - -// RecentFilterNew is a wrapper around gtk_recent_filter_new(). -func RecentFilterNew() (*RecentFilter, error) { - c := C.gtk_recent_filter_new() - if c == nil { - return nil, nilPtrErr - } - return wrapRecentFilter(wrapObject(unsafe.Pointer(c))), nil -} - -/* - * GtkRecentManager - */ - -// RecentManager is a representation of GTK's GtkRecentManager. -type RecentManager struct { - *glib.Object -} - -// native returns a pointer to the underlying GtkRecentManager. -func (v *RecentManager) native() *C.GtkRecentManager { - if v == nil || v.Object == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkRecentManager(p) -} - -func marshalRecentManager(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapRecentManager(obj), nil -} - -func wrapRecentManager(obj *glib.Object) *RecentManager { - return &RecentManager{obj} -} - -// RecentManagerGetDefault is a wrapper around gtk_recent_manager_get_default(). -func RecentManagerGetDefault() (*RecentManager, error) { - c := C.gtk_recent_manager_get_default() - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - v := wrapRecentManager(obj) - return v, nil -} - -// AddItem is a wrapper around gtk_recent_manager_add_item(). -func (v *RecentManager) AddItem(fileURI string) bool { - cstr := C.CString(fileURI) - defer C.free(unsafe.Pointer(cstr)) - cok := C.gtk_recent_manager_add_item(v.native(), (*C.gchar)(cstr)) - return gobool(cok) -} - -/* - * GtkScale - */ - -// Scale is a representation of GTK's GtkScale. -type Scale struct { - Range -} - -// native returns a pointer to the underlying GtkScale. -func (v *Scale) native() *C.GtkScale { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkScale(p) -} - -func marshalScale(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapScale(obj), nil -} - -func wrapScale(obj *glib.Object) *Scale { - return &Scale{Range{Widget{glib.InitiallyUnowned{obj}}}} -} - -// ScaleNew is a wrapper around gtk_scale_new(). -func ScaleNew(orientation Orientation, adjustment *Adjustment) (*Scale, error) { - c := C.gtk_scale_new(C.GtkOrientation(orientation), adjustment.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapScale(wrapObject(unsafe.Pointer(c))), nil -} - -// ScaleNewWithRange is a wrapper around gtk_scale_new_with_range(). -func ScaleNewWithRange(orientation Orientation, min, max, step float64) (*Scale, error) { - c := C.gtk_scale_new_with_range(C.GtkOrientation(orientation), - C.gdouble(min), C.gdouble(max), C.gdouble(step)) - - if c == nil { - return nil, nilPtrErr - } - return wrapScale(wrapObject(unsafe.Pointer(c))), nil -} - -/* - * GtkScaleButton - */ - -// ScaleButton is a representation of GTK's GtkScaleButton. -type ScaleButton struct { - Button -} - -// native() returns a pointer to the underlying GtkScaleButton. -func (v *ScaleButton) native() *C.GtkScaleButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkScaleButton(p) -} - -func marshalScaleButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapScaleButton(obj), nil -} - -func wrapScaleButton(obj *glib.Object) *ScaleButton { - return &ScaleButton{Button{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}} -} - -// ScaleButtonNew() is a wrapper around gtk_scale_button_new(). -func ScaleButtonNew(size IconSize, min, max, step float64, icons []string) (*ScaleButton, error) { - cicons := make([]*C.gchar, len(icons)) - for i, icon := range icons { - cicons[i] = (*C.gchar)(C.CString(icon)) - defer C.free(unsafe.Pointer(cicons[i])) - } - cicons = append(cicons, nil) - - c := C.gtk_scale_button_new(C.GtkIconSize(size), - C.gdouble(min), - C.gdouble(max), - C.gdouble(step), - &cicons[0]) - if c == nil { - return nil, nilPtrErr - } - return wrapScaleButton(wrapObject(unsafe.Pointer(c))), nil -} - -// GetAdjustment() is a wrapper around gtk_scale_button_get_adjustment(). -func (v *ScaleButton) GetAdjustment() *Adjustment { - c := C.gtk_scale_button_get_adjustment(v.native()) - obj := wrapObject(unsafe.Pointer(c)) - return &Adjustment{glib.InitiallyUnowned{obj}} -} - -// GetPopup() is a wrapper around gtk_scale_button_get_popup(). -func (v *ScaleButton) GetPopup() (*Widget, error) { - c := C.gtk_scale_button_get_popup(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// GetValue() is a wrapper around gtk_scale_button_get_value(). -func (v *ScaleButton) GetValue() float64 { - return float64(C.gtk_scale_button_get_value(v.native())) -} - -// SetAdjustment() is a wrapper around gtk_scale_button_set_adjustment(). -func (v *ScaleButton) SetAdjustment(adjustment *Adjustment) { - C.gtk_scale_button_set_adjustment(v.native(), adjustment.native()) -} - -// SetValue() is a wrapper around gtk_scale_button_set_value(). -func (v *ScaleButton) SetValue(value float64) { - C.gtk_scale_button_set_value(v.native(), C.gdouble(value)) -} - -/* - * GtkScrollable - */ - -// IScrollable is an interface type implemented by all structs -// embedding a Scrollable. It is meant to be used as an argument type -// for wrapper functions that wrap around a C GTK function taking a -// GtkScrollable. -type IScrollable interface { - toScrollable() *C.GtkScrollable -} - -// Scrollable is a representation of GTK's GtkScrollable GInterface. -type Scrollable struct { - *glib.Object -} - -// native() returns a pointer to the underlying GObject as a GtkScrollable. -func (v *Scrollable) native() *C.GtkScrollable { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkScrollable(p) -} - -func wrapScrollable(obj *glib.Object) *Scrollable { - return &Scrollable{obj} -} - -func (v *Scrollable) toScrollable() *C.GtkScrollable { - if v == nil { - return nil - } - return v.native() -} - -// SetHAdjustment is a wrapper around gtk_scrollable_set_hadjustment(). -func (v *Scrollable) SetHAdjustment(adjustment *Adjustment) { - C.gtk_scrollable_set_hadjustment(v.native(), adjustment.native()) -} - -// GetHAdjustment is a wrapper around gtk_scrollable_get_hadjustment(). -func (v *Scrollable) GetHAdjustment() (*Adjustment, error) { - c := C.gtk_scrollable_get_hadjustment(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapAdjustment(wrapObject(unsafe.Pointer(c))), nil -} - -// SetVAdjustment is a wrapper around gtk_scrollable_set_vadjustment(). -func (v *Scrollable) SetVAdjustment(adjustment *Adjustment) { - C.gtk_scrollable_set_vadjustment(v.native(), adjustment.native()) -} - -// GetVAdjustment is a wrapper around gtk_scrollable_get_vadjustment(). -func (v *Scrollable) GetVAdjustment() (*Adjustment, error) { - c := C.gtk_scrollable_get_vadjustment(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapAdjustment(wrapObject(unsafe.Pointer(c))), nil -} - -/* - * GtkScrollbar - */ - -// Scrollbar is a representation of GTK's GtkScrollbar. -type Scrollbar struct { - Range -} - -// native returns a pointer to the underlying GtkScrollbar. -func (v *Scrollbar) native() *C.GtkScrollbar { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkScrollbar(p) -} - -func marshalScrollbar(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapScrollbar(obj), nil -} - -func wrapScrollbar(obj *glib.Object) *Scrollbar { - return &Scrollbar{Range{Widget{glib.InitiallyUnowned{obj}}}} -} - -// ScrollbarNew is a wrapper around gtk_scrollbar_new(). -func ScrollbarNew(orientation Orientation, adjustment *Adjustment) (*Scrollbar, error) { - c := C.gtk_scrollbar_new(C.GtkOrientation(orientation), adjustment.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapScrollbar(wrapObject(unsafe.Pointer(c))), nil -} - -/* - * GtkScrolledWindow - */ - -// ScrolledWindow is a representation of GTK's GtkScrolledWindow. -type ScrolledWindow struct { - Bin -} - -// native returns a pointer to the underlying GtkScrolledWindow. -func (v *ScrolledWindow) native() *C.GtkScrolledWindow { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkScrolledWindow(p) -} - -func marshalScrolledWindow(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapScrolledWindow(obj), nil -} - -func wrapScrolledWindow(obj *glib.Object) *ScrolledWindow { - return &ScrolledWindow{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// ScrolledWindowNew() is a wrapper around gtk_scrolled_window_new(). -func ScrolledWindowNew(hadjustment, vadjustment *Adjustment) (*ScrolledWindow, error) { - c := C.gtk_scrolled_window_new(hadjustment.native(), - vadjustment.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapScrolledWindow(wrapObject(unsafe.Pointer(c))), nil -} - -// SetPolicy() is a wrapper around gtk_scrolled_window_set_policy(). -func (v *ScrolledWindow) SetPolicy(hScrollbarPolicy, vScrollbarPolicy PolicyType) { - C.gtk_scrolled_window_set_policy(v.native(), - C.GtkPolicyType(hScrollbarPolicy), - C.GtkPolicyType(vScrollbarPolicy)) -} - -// GetHAdjustment() is a wrapper around gtk_scrolled_window_get_hadjustment(). -func (v *ScrolledWindow) GetHAdjustment() *Adjustment { - c := C.gtk_scrolled_window_get_hadjustment(v.native()) - if c == nil { - return nil - } - return wrapAdjustment(wrapObject(unsafe.Pointer(c))) -} - -// SetHAdjustment is a wrapper around gtk_scrolled_window_set_hadjustment(). -func (v *ScrolledWindow) SetHAdjustment(adjustment *Adjustment) { - C.gtk_scrolled_window_set_hadjustment(v.native(), adjustment.native()) -} - -// GetVAdjustment() is a wrapper around gtk_scrolled_window_get_vadjustment(). -func (v *ScrolledWindow) GetVAdjustment() *Adjustment { - c := C.gtk_scrolled_window_get_vadjustment(v.native()) - if c == nil { - return nil - } - return wrapAdjustment(wrapObject(unsafe.Pointer(c))) -} - -// SetVAdjustment is a wrapper around gtk_scrolled_window_set_vadjustment(). -func (v *ScrolledWindow) SetVAdjustment(adjustment *Adjustment) { - C.gtk_scrolled_window_set_vadjustment(v.native(), adjustment.native()) -} - -/* - * GtkSearchEntry - */ - -// SearchEntry is a reprensentation of GTK's GtkSearchEntry. -type SearchEntry struct { - Entry -} - -// native returns a pointer to the underlying GtkSearchEntry. -func (v *SearchEntry) native() *C.GtkSearchEntry { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkSearchEntry(p) -} - -func marshalSearchEntry(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapSearchEntry(obj), nil -} - -func wrapSearchEntry(obj *glib.Object) *SearchEntry { - e := wrapEditable(obj) - return &SearchEntry{Entry{Widget{glib.InitiallyUnowned{obj}}, *e}} -} - -// SearchEntryNew is a wrapper around gtk_search_entry_new(). -func SearchEntryNew() (*SearchEntry, error) { - c := C.gtk_search_entry_new() - if c == nil { - return nil, nilPtrErr - } - return wrapSearchEntry(wrapObject(unsafe.Pointer(c))), nil -} - -/* -* GtkSelectionData - */ -type SelectionData struct { - GtkSelectionData *C.GtkSelectionData -} - -func marshalSelectionData(p uintptr) (interface{}, error) { - c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) - return (*SelectionData)(unsafe.Pointer(c)), nil -} - -// native returns a pointer to the underlying GtkSelectionData. -func (v *SelectionData) native() *C.GtkSelectionData { - if v == nil { - return nil - } - return v.GtkSelectionData -} - -// GetLength is a wrapper around gtk_selection_data_get_length -func (v *SelectionData) GetLength() int { - return int(C.gtk_selection_data_get_length(v.native())) -} - -// GetData is a wrapper around gtk_selection_data_get_data_with_length. -// It returns a slice of the correct size with the selection's data. -func (v *SelectionData) GetData() (data []byte) { - var length C.gint - c := C.gtk_selection_data_get_data_with_length(v.native(), &length) - sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&data)) - sliceHeader.Data = uintptr(unsafe.Pointer(c)) - sliceHeader.Len = int(length) - sliceHeader.Cap = int(length) - return -} - -func (v *SelectionData) free() { - C.gtk_selection_data_free(v.native()) -} - -/* - * GtkSeparator - */ - -// Separator is a representation of GTK's GtkSeparator. -type Separator struct { - Widget -} - -// native returns a pointer to the underlying GtkSeperator. -func (v *Separator) native() *C.GtkSeparator { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkSeparator(p) -} - -func marshalSeparator(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapSeparator(obj), nil -} - -func wrapSeparator(obj *glib.Object) *Separator { - return &Separator{Widget{glib.InitiallyUnowned{obj}}} -} - -// SeparatorNew is a wrapper around gtk_separator_new(). -func SeparatorNew(orientation Orientation) (*Separator, error) { - c := C.gtk_separator_new(C.GtkOrientation(orientation)) - if c == nil { - return nil, nilPtrErr - } - return wrapSeparator(wrapObject(unsafe.Pointer(c))), nil -} - -/* - * GtkSeparatorMenuItem - */ - -// SeparatorMenuItem is a representation of GTK's GtkSeparatorMenuItem. -type SeparatorMenuItem struct { - MenuItem -} - -// native returns a pointer to the underlying GtkSeparatorMenuItem. -func (v *SeparatorMenuItem) native() *C.GtkSeparatorMenuItem { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkSeparatorMenuItem(p) -} - -func marshalSeparatorMenuItem(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapSeparatorMenuItem(obj), nil -} - -func wrapSeparatorMenuItem(obj *glib.Object) *SeparatorMenuItem { - return &SeparatorMenuItem{MenuItem{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}} -} - -// SeparatorMenuItemNew is a wrapper around gtk_separator_menu_item_new(). -func SeparatorMenuItemNew() (*SeparatorMenuItem, error) { - c := C.gtk_separator_menu_item_new() - if c == nil { - return nil, nilPtrErr - } - return wrapSeparatorMenuItem(wrapObject(unsafe.Pointer(c))), nil -} - -/* - * GtkSeparatorToolItem - */ - -// SeparatorToolItem is a representation of GTK's GtkSeparatorToolItem. -type SeparatorToolItem struct { - ToolItem -} - -// native returns a pointer to the underlying GtkSeparatorToolItem. -func (v *SeparatorToolItem) native() *C.GtkSeparatorToolItem { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkSeparatorToolItem(p) -} - -func marshalSeparatorToolItem(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapSeparatorToolItem(obj), nil -} - -func wrapSeparatorToolItem(obj *glib.Object) *SeparatorToolItem { - return &SeparatorToolItem{ToolItem{Bin{Container{Widget{ - glib.InitiallyUnowned{obj}}}}}} -} - -// SeparatorToolItemNew is a wrapper around gtk_separator_tool_item_new(). -func SeparatorToolItemNew() (*SeparatorToolItem, error) { - c := C.gtk_separator_tool_item_new() - if c == nil { - return nil, nilPtrErr - } - return wrapSeparatorToolItem(wrapObject(unsafe.Pointer(c))), nil -} - -// SetDraw is a wrapper around gtk_separator_tool_item_set_draw(). -func (v *SeparatorToolItem) SetDraw(draw bool) { - C.gtk_separator_tool_item_set_draw(v.native(), gbool(draw)) -} - -// GetDraw is a wrapper around gtk_separator_tool_item_get_draw(). -func (v *SeparatorToolItem) GetDraw() bool { - c := C.gtk_separator_tool_item_get_draw(v.native()) - return gobool(c) -} - -/* - * GtkSizeGroup - */ - -// SizeGroup is a representation of GTK's GtkSizeGroup -type SizeGroup struct { - *glib.Object -} - -// native() returns a pointer to the underlying GtkSizeGroup -func (v *SizeGroup) native() *C.GtkSizeGroup { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkSizeGroup(p) -} - -func marshalSizeGroup(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return &SizeGroup{obj}, nil -} - -func wrapSizeGroup(obj *glib.Object) *SizeGroup { - return &SizeGroup{obj} -} - -// SizeGroupNew is a wrapper around gtk_size_group_new(). -func SizeGroupNew(mode SizeGroupMode) (*SizeGroup, error) { - c := C.gtk_size_group_new(C.GtkSizeGroupMode(mode)) - if c == nil { - return nil, nilPtrErr - } - return wrapSizeGroup(wrapObject(unsafe.Pointer(c))), nil -} - -func (v *SizeGroup) SetMode(mode SizeGroupMode) { - C.gtk_size_group_set_mode(v.native(), C.GtkSizeGroupMode(mode)) -} - -func (v *SizeGroup) GetMode() SizeGroupMode { - return SizeGroupMode(C.gtk_size_group_get_mode(v.native())) -} - -func (v *SizeGroup) SetIgnoreHidden(ignoreHidden bool) { - C.gtk_size_group_set_ignore_hidden(v.native(), gbool(ignoreHidden)) -} - -func (v *SizeGroup) GetIgnoreHidden() bool { - c := C.gtk_size_group_get_ignore_hidden(v.native()) - return gobool(c) -} - -func (v *SizeGroup) AddWidget(widget IWidget) { - C.gtk_size_group_add_widget(v.native(), widget.toWidget()) -} - -func (v *SizeGroup) RemoveWidget(widget IWidget) { - C.gtk_size_group_remove_widget(v.native(), widget.toWidget()) -} - -func (v *SizeGroup) GetWidgets() *glib.SList { - c := C.gtk_size_group_get_widgets(v.native()) - if c == nil { - return nil - } - return glib.WrapSList(uintptr(unsafe.Pointer(c))) -} - -/* - * GtkSpinButton - */ - -// SpinButton is a representation of GTK's GtkSpinButton. -type SpinButton struct { - Entry -} - -// native returns a pointer to the underlying GtkSpinButton. -func (v *SpinButton) native() *C.GtkSpinButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkSpinButton(p) -} - -func marshalSpinButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapSpinButton(obj), nil -} - -func wrapSpinButton(obj *glib.Object) *SpinButton { - e := wrapEditable(obj) - return &SpinButton{Entry{Widget{glib.InitiallyUnowned{obj}}, *e}} -} - -// Configure() is a wrapper around gtk_spin_button_configure(). -func (v *SpinButton) Configure(adjustment *Adjustment, climbRate float64, digits uint) { - C.gtk_spin_button_configure(v.native(), adjustment.native(), - C.gdouble(climbRate), C.guint(digits)) -} - -// SpinButtonNew() is a wrapper around gtk_spin_button_new(). -func SpinButtonNew(adjustment *Adjustment, climbRate float64, digits uint) (*SpinButton, error) { - c := C.gtk_spin_button_new(adjustment.native(), - C.gdouble(climbRate), C.guint(digits)) - if c == nil { - return nil, nilPtrErr - } - return wrapSpinButton(wrapObject(unsafe.Pointer(c))), nil -} - -// SpinButtonNewWithRange() is a wrapper around -// gtk_spin_button_new_with_range(). -func SpinButtonNewWithRange(min, max, step float64) (*SpinButton, error) { - c := C.gtk_spin_button_new_with_range(C.gdouble(min), C.gdouble(max), - C.gdouble(step)) - if c == nil { - return nil, nilPtrErr - } - return wrapSpinButton(wrapObject(unsafe.Pointer(c))), nil -} - -// GetValueAsInt() is a wrapper around gtk_spin_button_get_value_as_int(). -func (v *SpinButton) GetValueAsInt() int { - c := C.gtk_spin_button_get_value_as_int(v.native()) - return int(c) -} - -// SetValue() is a wrapper around gtk_spin_button_set_value(). -func (v *SpinButton) SetValue(value float64) { - C.gtk_spin_button_set_value(v.native(), C.gdouble(value)) -} - -// GetValue() is a wrapper around gtk_spin_button_get_value(). -func (v *SpinButton) GetValue() float64 { - c := C.gtk_spin_button_get_value(v.native()) - return float64(c) -} - -// GetAdjustment() is a wrapper around gtk_spin_button_get_adjustment -func (v *SpinButton) GetAdjustment() *Adjustment { - c := C.gtk_spin_button_get_adjustment(v.native()) - if c == nil { - return nil - } - return wrapAdjustment(wrapObject(unsafe.Pointer(c))) -} - -// SetRange is a wrapper around gtk_spin_button_set_range(). -func (v *SpinButton) SetRange(min, max float64) { - C.gtk_spin_button_set_range(v.native(), C.gdouble(min), C.gdouble(max)) -} - -// SetIncrements() is a wrapper around gtk_spin_button_set_increments(). -func (v *SpinButton) SetIncrements(step, page float64) { - C.gtk_spin_button_set_increments(v.native(), C.gdouble(step), C.gdouble(page)) -} - -/* - * GtkSpinner - */ - -// Spinner is a representation of GTK's GtkSpinner. -type Spinner struct { - Widget -} - -// native returns a pointer to the underlying GtkSpinner. -func (v *Spinner) native() *C.GtkSpinner { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkSpinner(p) -} - -func marshalSpinner(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapSpinner(obj), nil -} - -func wrapSpinner(obj *glib.Object) *Spinner { - return &Spinner{Widget{glib.InitiallyUnowned{obj}}} -} - -// SpinnerNew is a wrapper around gtk_spinner_new(). -func SpinnerNew() (*Spinner, error) { - c := C.gtk_spinner_new() - if c == nil { - return nil, nilPtrErr - } - return wrapSpinner(wrapObject(unsafe.Pointer(c))), nil -} - -// Start is a wrapper around gtk_spinner_start(). -func (v *Spinner) Start() { - C.gtk_spinner_start(v.native()) -} - -// Stop is a wrapper around gtk_spinner_stop(). -func (v *Spinner) Stop() { - C.gtk_spinner_stop(v.native()) -} - -/* - * GtkStatusbar - */ - -// Statusbar is a representation of GTK's GtkStatusbar -type Statusbar struct { - Box -} - -// native returns a pointer to the underlying GtkStatusbar -func (v *Statusbar) native() *C.GtkStatusbar { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkStatusbar(p) -} - -func marshalStatusbar(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapStatusbar(obj), nil -} - -func wrapStatusbar(obj *glib.Object) *Statusbar { - return &Statusbar{Box{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// StatusbarNew() is a wrapper around gtk_statusbar_new(). -func StatusbarNew() (*Statusbar, error) { - c := C.gtk_statusbar_new() - if c == nil { - return nil, nilPtrErr - } - return wrapStatusbar(wrapObject(unsafe.Pointer(c))), nil -} - -// GetContextId() is a wrapper around gtk_statusbar_get_context_id(). -func (v *Statusbar) GetContextId(contextDescription string) uint { - cstr := C.CString(contextDescription) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_statusbar_get_context_id(v.native(), (*C.gchar)(cstr)) - return uint(c) -} - -// Push() is a wrapper around gtk_statusbar_push(). -func (v *Statusbar) Push(contextID uint, text string) uint { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_statusbar_push(v.native(), C.guint(contextID), - (*C.gchar)(cstr)) - return uint(c) -} - -// Pop() is a wrapper around gtk_statusbar_pop(). -func (v *Statusbar) Pop(contextID uint) { - C.gtk_statusbar_pop(v.native(), C.guint(contextID)) -} - -// GetMessageArea() is a wrapper around gtk_statusbar_get_message_area(). -func (v *Statusbar) GetMessageArea() (*Box, error) { - c := C.gtk_statusbar_get_message_area(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return &Box{Container{Widget{glib.InitiallyUnowned{obj}}}}, nil -} - -/* - * GtkSwitch - */ - -// Switch is a representation of GTK's GtkSwitch. -type Switch struct { - Widget -} - -// native returns a pointer to the underlying GtkSwitch. -func (v *Switch) native() *C.GtkSwitch { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkSwitch(p) -} - -func marshalSwitch(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapSwitch(obj), nil -} - -func wrapSwitch(obj *glib.Object) *Switch { - return &Switch{Widget{glib.InitiallyUnowned{obj}}} -} - -// SwitchNew is a wrapper around gtk_switch_new(). -func SwitchNew() (*Switch, error) { - c := C.gtk_switch_new() - if c == nil { - return nil, nilPtrErr - } - return wrapSwitch(wrapObject(unsafe.Pointer(c))), nil -} - -// GetActive is a wrapper around gtk_switch_get_active(). -func (v *Switch) GetActive() bool { - c := C.gtk_switch_get_active(v.native()) - return gobool(c) -} - -// SetActive is a wrapper around gtk_switch_set_active(). -func (v *Switch) SetActive(isActive bool) { - C.gtk_switch_set_active(v.native(), gbool(isActive)) -} - -/* - * GtkTargetEntry - */ - -// TargetEntry is a representation of GTK's GtkTargetEntry -type TargetEntry C.GtkTargetEntry - -func marshalTargetEntry(p uintptr) (interface{}, error) { - c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) - return (*TargetEntry)(unsafe.Pointer(c)), nil -} - -func (v *TargetEntry) native() *C.GtkTargetEntry { - return (*C.GtkTargetEntry)(unsafe.Pointer(v)) -} - -// TargetEntryNew is a wrapper aroud gtk_target_entry_new(). -func TargetEntryNew(target string, flags TargetFlags, info uint) (*TargetEntry, error) { - cstr := C.CString(target) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_target_entry_new((*C.gchar)(cstr), C.guint(flags), C.guint(info)) - if c == nil { - return nil, nilPtrErr - } - t := (*TargetEntry)(unsafe.Pointer(c)) - runtime.SetFinalizer(t, (*TargetEntry).free) - return t, nil -} - -func (v *TargetEntry) free() { - C.gtk_target_entry_free(v.native()) -} - -/* - * GtkTextTag - */ - -type TextTag struct { - *glib.Object -} - -// native returns a pointer to the underlying GObject as a GtkTextTag. -func (v *TextTag) native() *C.GtkTextTag { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkTextTag(p) -} - -func marshalTextTag(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapTextTag(obj), nil -} - -func wrapTextTag(obj *glib.Object) *TextTag { - return &TextTag{obj} -} - -func TextTagNew(name string) (*TextTag, error) { - cname := C.CString(name) - defer C.free(unsafe.Pointer(cname)) - c := C.gtk_text_tag_new((*C.gchar)(cname)) - if c == nil { - return nil, nilPtrErr - } - return wrapTextTag(wrapObject(unsafe.Pointer(c))), nil -} - -// GetPriority() is a wrapper around gtk_text_tag_get_priority(). -func (v *TextTag) GetPriority() int { - return int(C.gtk_text_tag_get_priority(v.native())) -} - -// SetPriority() is a wrapper around gtk_text_tag_set_priority(). -func (v *TextTag) SetPriority(priority int) { - C.gtk_text_tag_set_priority(v.native(), C.gint(priority)) -} - -// Event() is a wrapper around gtk_text_tag_event(). -func (v *TextTag) Event(eventObject *glib.Object, event *gdk.Event, iter *TextIter) bool { - ok := C.gtk_text_tag_event(v.native(), - (*C.GObject)(unsafe.Pointer(eventObject.Native())), - (*C.GdkEvent)(unsafe.Pointer(event.Native())), - (*C.GtkTextIter)(iter), - ) - return gobool(ok) -} - -/* - * GtkTextTagTable - */ - -type TextTagTable struct { - *glib.Object -} - -// native returns a pointer to the underlying GObject as a GtkTextTagTable. -func (v *TextTagTable) native() *C.GtkTextTagTable { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkTextTagTable(p) -} - -func marshalTextTagTable(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapTextTagTable(obj), nil -} - -func wrapTextTagTable(obj *glib.Object) *TextTagTable { - return &TextTagTable{obj} -} - -func TextTagTableNew() (*TextTagTable, error) { - c := C.gtk_text_tag_table_new() - if c == nil { - return nil, nilPtrErr - } - return wrapTextTagTable(wrapObject(unsafe.Pointer(c))), nil -} - -// Add() is a wrapper around gtk_text_tag_table_add(). -func (v *TextTagTable) Add(tag *TextTag) { - C.gtk_text_tag_table_add(v.native(), tag.native()) - //return gobool(c) // TODO version-separate -} - -// Lookup() is a wrapper around gtk_text_tag_table_lookup(). -func (v *TextTagTable) Lookup(name string) (*TextTag, error) { - cname := C.CString(name) - defer C.free(unsafe.Pointer(cname)) - c := C.gtk_text_tag_table_lookup(v.native(), (*C.gchar)(cname)) - if c == nil { - return nil, nilPtrErr - } - return wrapTextTag(wrapObject(unsafe.Pointer(c))), nil -} - -// Remove() is a wrapper around gtk_text_tag_table_remove(). -func (v *TextTagTable) Remove(tag *TextTag) { - C.gtk_text_tag_table_remove(v.native(), tag.native()) -} - -/* - * GtkTextBuffer - */ - -// TextBuffer is a representation of GTK's GtkTextBuffer. -type TextBuffer struct { - *glib.Object -} - -// native returns a pointer to the underlying GtkTextBuffer. -func (v *TextBuffer) native() *C.GtkTextBuffer { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkTextBuffer(p) -} - -func marshalTextBuffer(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapTextBuffer(obj), nil -} - -func wrapTextBuffer(obj *glib.Object) *TextBuffer { - return &TextBuffer{obj} -} - -// TextBufferNew() is a wrapper around gtk_text_buffer_new(). -func TextBufferNew(table *TextTagTable) (*TextBuffer, error) { - c := C.gtk_text_buffer_new(table.native()) - if c == nil { - return nil, nilPtrErr - } - - e := wrapTextBuffer(wrapObject(unsafe.Pointer(c))) - return e, nil -} - -// ApplyTag() is a wrapper around gtk_text_buffer_apply_tag(). -func (v *TextBuffer) ApplyTag(tag *TextTag, start, end *TextIter) { - C.gtk_text_buffer_apply_tag(v.native(), tag.native(), (*C.GtkTextIter)(start), (*C.GtkTextIter)(end)) -} - -// ApplyTagByName() is a wrapper around gtk_text_buffer_apply_tag_by_name(). -func (v *TextBuffer) ApplyTagByName(name string, start, end *TextIter) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_text_buffer_apply_tag_by_name(v.native(), (*C.gchar)(cstr), - (*C.GtkTextIter)(start), (*C.GtkTextIter)(end)) -} - -// Delete() is a wrapper around gtk_text_buffer_delete(). -func (v *TextBuffer) Delete(start, end *TextIter) { - C.gtk_text_buffer_delete(v.native(), (*C.GtkTextIter)(start), (*C.GtkTextIter)(end)) -} - -func (v *TextBuffer) GetBounds() (start, end *TextIter) { - start, end = new(TextIter), new(TextIter) - C.gtk_text_buffer_get_bounds(v.native(), (*C.GtkTextIter)(start), (*C.GtkTextIter)(end)) - return -} - -// GetCharCount() is a wrapper around gtk_text_buffer_get_char_count(). -func (v *TextBuffer) GetCharCount() int { - return int(C.gtk_text_buffer_get_char_count(v.native())) -} - -// GetIterAtOffset() is a wrapper around gtk_text_buffer_get_iter_at_offset(). -func (v *TextBuffer) GetIterAtOffset(charOffset int) *TextIter { - var iter C.GtkTextIter - C.gtk_text_buffer_get_iter_at_offset(v.native(), &iter, C.gint(charOffset)) - return (*TextIter)(&iter) -} - -// GetStartIter() is a wrapper around gtk_text_buffer_get_start_iter(). -func (v *TextBuffer) GetStartIter() *TextIter { - var iter C.GtkTextIter - C.gtk_text_buffer_get_start_iter(v.native(), &iter) - return (*TextIter)(&iter) -} - -// GetEndIter() is a wrapper around gtk_text_buffer_get_end_iter(). -func (v *TextBuffer) GetEndIter() *TextIter { - var iter C.GtkTextIter - C.gtk_text_buffer_get_end_iter(v.native(), &iter) - return (*TextIter)(&iter) -} - -// GetLineCount() is a wrapper around gtk_text_buffer_get_line_count(). -func (v *TextBuffer) GetLineCount() int { - return int(C.gtk_text_buffer_get_line_count(v.native())) -} - -// GetModified() is a wrapper around gtk_text_buffer_get_modified(). -func (v *TextBuffer) GetModified() bool { - return gobool(C.gtk_text_buffer_get_modified(v.native())) -} - -// GetTagTable() is a wrapper around gtk_text_buffer_get_tag_table(). -func (v *TextBuffer) GetTagTable() (*TextTagTable, error) { - c := C.gtk_text_buffer_get_tag_table(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapTextTagTable(obj), nil -} - -func (v *TextBuffer) GetText(start, end *TextIter, includeHiddenChars bool) (string, error) { - c := C.gtk_text_buffer_get_text( - v.native(), (*C.GtkTextIter)(start), (*C.GtkTextIter)(end), gbool(includeHiddenChars), - ) - if c == nil { - return "", nilPtrErr - } - gostr := C.GoString((*C.char)(c)) - C.g_free(C.gpointer(c)) - return gostr, nil -} - -// Insert() is a wrapper around gtk_text_buffer_insert(). -func (v *TextBuffer) Insert(iter *TextIter, text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_text_buffer_insert(v.native(), (*C.GtkTextIter)(iter), (*C.gchar)(cstr), C.gint(len(text))) -} - -// InsertAtCursor() is a wrapper around gtk_text_buffer_insert_at_cursor(). -func (v *TextBuffer) InsertAtCursor(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_text_buffer_insert_at_cursor(v.native(), (*C.gchar)(cstr), C.gint(len(text))) -} - -// RemoveTag() is a wrapper around gtk_text_buffer_remove_tag(). -func (v *TextBuffer) RemoveTag(tag *TextTag, start, end *TextIter) { - C.gtk_text_buffer_remove_tag(v.native(), tag.native(), (*C.GtkTextIter)(start), (*C.GtkTextIter)(end)) -} - -// SetModified() is a wrapper around gtk_text_buffer_set_modified(). -func (v *TextBuffer) SetModified(setting bool) { - C.gtk_text_buffer_set_modified(v.native(), gbool(setting)) -} - -func (v *TextBuffer) SetText(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_text_buffer_set_text(v.native(), (*C.gchar)(cstr), - C.gint(len(text))) -} - -// GetIterAtMark() is a wrapper around gtk_text_buffer_get_iter_at_mark(). -func (v *TextBuffer) GetIterAtMark(mark *TextMark) *TextIter { - var iter C.GtkTextIter - C.gtk_text_buffer_get_iter_at_mark(v.native(), &iter, (*C.GtkTextMark)(mark)) - return (*TextIter)(&iter) -} - -// CreateMark() is a wrapper around gtk_text_buffer_create_mark(). -func (v *TextBuffer) CreateMark(mark_name string, where *TextIter, left_gravity bool) *TextMark { - cstr := C.CString(mark_name) - defer C.free(unsafe.Pointer(cstr)) - ret := C.gtk_text_buffer_create_mark(v.native(), (*C.gchar)(cstr), (*C.GtkTextIter)(where), gbool(left_gravity)) - return (*TextMark)(ret) -} - -/* - * GtkToggleButton - */ - -// ToggleButton is a representation of GTK's GtkToggleButton. -type ToggleButton struct { - Button -} - -// native returns a pointer to the underlying GtkToggleButton. -func (v *ToggleButton) native() *C.GtkToggleButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkToggleButton(p) -} - -func marshalToggleButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapToggleButton(obj), nil -} - -func wrapToggleButton(obj *glib.Object) *ToggleButton { - return &ToggleButton{Button{Bin{Container{Widget{ - glib.InitiallyUnowned{obj}}}}}} -} - -// ToggleButtonNew is a wrapper around gtk_toggle_button_new(). -func ToggleButtonNew() (*ToggleButton, error) { - c := C.gtk_toggle_button_new() - if c == nil { - return nil, nilPtrErr - } - return wrapToggleButton(wrapObject(unsafe.Pointer(c))), nil -} - -// ToggleButtonNewWithLabel is a wrapper around -// gtk_toggle_button_new_with_label(). -func ToggleButtonNewWithLabel(label string) (*ToggleButton, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_toggle_button_new_with_label((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapToggleButton(wrapObject(unsafe.Pointer(c))), nil -} - -// ToggleButtonNewWithMnemonic is a wrapper around -// gtk_toggle_button_new_with_mnemonic(). -func ToggleButtonNewWithMnemonic(label string) (*ToggleButton, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_toggle_button_new_with_mnemonic((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapToggleButton(wrapObject(unsafe.Pointer(c))), nil -} - -// GetActive is a wrapper around gtk_toggle_button_get_active(). -func (v *ToggleButton) GetActive() bool { - c := C.gtk_toggle_button_get_active(v.native()) - return gobool(c) -} - -// SetActive is a wrapper around gtk_toggle_button_set_active(). -func (v *ToggleButton) SetActive(isActive bool) { - C.gtk_toggle_button_set_active(v.native(), gbool(isActive)) -} - -/* - * GtkToolbar - */ - -// Toolbar is a representation of GTK's GtkToolbar. -type Toolbar struct { - Container -} - -// native returns a pointer to the underlying GtkToolbar. -func (v *Toolbar) native() *C.GtkToolbar { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkToolbar(p) -} - -func marshalToolbar(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapToolbar(obj), nil -} - -func wrapToolbar(obj *glib.Object) *Toolbar { - return &Toolbar{Container{Widget{glib.InitiallyUnowned{obj}}}} -} - -// ToolbarNew is a wrapper around gtk_toolbar_new(). -func ToolbarNew() (*Toolbar, error) { - c := C.gtk_toolbar_new() - if c == nil { - return nil, nilPtrErr - } - return wrapToolbar(wrapObject(unsafe.Pointer(c))), nil -} - -// Insert is a wrapper around gtk_toolbar_insert(). -func (v *Toolbar) Insert(item IToolItem, pos int) { - C.gtk_toolbar_insert(v.native(), item.toToolItem(), C.gint(pos)) -} - -// GetItemIndex is a wrapper around gtk_toolbar_get_item_index(). -func (v *Toolbar) GetItemIndex(item IToolItem) int { - c := C.gtk_toolbar_get_item_index(v.native(), item.toToolItem()) - return int(c) -} - -// GetNItems is a wrapper around gtk_toolbar_get_n_items(). -func (v *Toolbar) GetNItems() int { - c := C.gtk_toolbar_get_n_items(v.native()) - return int(c) -} - -// GetNthItem is a wrapper around gtk_toolbar_get_nth_item(). -func (v *Toolbar) GetNthItem(n int) *ToolItem { - c := C.gtk_toolbar_get_nth_item(v.native(), C.gint(n)) - if c == nil { - return nil - } - return wrapToolItem(wrapObject(unsafe.Pointer(c))) -} - -// GetDropIndex is a wrapper around gtk_toolbar_get_drop_index(). -func (v *Toolbar) GetDropIndex(x, y int) int { - c := C.gtk_toolbar_get_drop_index(v.native(), C.gint(x), C.gint(y)) - return int(c) -} - -// SetDropHighlightItem is a wrapper around -// gtk_toolbar_set_drop_highlight_item(). -func (v *Toolbar) SetDropHighlightItem(toolItem IToolItem, index int) { - C.gtk_toolbar_set_drop_highlight_item(v.native(), - toolItem.toToolItem(), C.gint(index)) -} - -// SetShowArrow is a wrapper around gtk_toolbar_set_show_arrow(). -func (v *Toolbar) SetShowArrow(showArrow bool) { - C.gtk_toolbar_set_show_arrow(v.native(), gbool(showArrow)) -} - -// UnsetIconSize is a wrapper around gtk_toolbar_unset_icon_size(). -func (v *Toolbar) UnsetIconSize() { - C.gtk_toolbar_unset_icon_size(v.native()) -} - -// GetShowArrow is a wrapper around gtk_toolbar_get_show_arrow(). -func (v *Toolbar) GetShowArrow() bool { - c := C.gtk_toolbar_get_show_arrow(v.native()) - return gobool(c) -} - -// GetStyle is a wrapper around gtk_toolbar_get_style(). -func (v *Toolbar) GetStyle() ToolbarStyle { - c := C.gtk_toolbar_get_style(v.native()) - return ToolbarStyle(c) -} - -// GetIconSize is a wrapper around gtk_toolbar_get_icon_size(). -func (v *Toolbar) GetIconSize() IconSize { - c := C.gtk_toolbar_get_icon_size(v.native()) - return IconSize(c) -} - -// GetReliefStyle is a wrapper around gtk_toolbar_get_relief_style(). -func (v *Toolbar) GetReliefStyle() ReliefStyle { - c := C.gtk_toolbar_get_relief_style(v.native()) - return ReliefStyle(c) -} - -// SetStyle is a wrapper around gtk_toolbar_set_style(). -func (v *Toolbar) SetStyle(style ToolbarStyle) { - C.gtk_toolbar_set_style(v.native(), C.GtkToolbarStyle(style)) -} - -// SetIconSize is a wrapper around gtk_toolbar_set_icon_size(). -func (v *Toolbar) SetIconSize(iconSize IconSize) { - C.gtk_toolbar_set_icon_size(v.native(), C.GtkIconSize(iconSize)) -} - -// UnsetStyle is a wrapper around gtk_toolbar_unset_style(). -func (v *Toolbar) UnsetStyle() { - C.gtk_toolbar_unset_style(v.native()) -} - -/* - * GtkToolButton - */ - -// ToolButton is a representation of GTK's GtkToolButton. -type ToolButton struct { - ToolItem -} - -// native returns a pointer to the underlying GtkToolButton. -func (v *ToolButton) native() *C.GtkToolButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkToolButton(p) -} - -func marshalToolButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapToolButton(obj), nil -} - -func wrapToolButton(obj *glib.Object) *ToolButton { - return &ToolButton{ToolItem{Bin{Container{Widget{ - glib.InitiallyUnowned{obj}}}}}} -} - -// ToolButtonNew is a wrapper around gtk_tool_button_new(). -func ToolButtonNew(iconWidget IWidget, label string) (*ToolButton, error) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - w := nullableWidget(iconWidget) - c := C.gtk_tool_button_new(w, (*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapToolButton(wrapObject(unsafe.Pointer(c))), nil -} - -// SetLabel is a wrapper around gtk_tool_button_set_label(). -func (v *ToolButton) SetLabel(label string) { - cstr := C.CString(label) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_tool_button_set_label(v.native(), (*C.gchar)(cstr)) -} - -// GetLabel is a wrapper aroud gtk_tool_button_get_label(). -func (v *ToolButton) GetLabel() string { - c := C.gtk_tool_button_get_label(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetUseUnderline is a wrapper around gtk_tool_button_set_use_underline(). -func (v *ToolButton) SetGetUnderline(useUnderline bool) { - C.gtk_tool_button_set_use_underline(v.native(), gbool(useUnderline)) -} - -// GetUseUnderline is a wrapper around gtk_tool_button_get_use_underline(). -func (v *ToolButton) GetuseUnderline() bool { - c := C.gtk_tool_button_get_use_underline(v.native()) - return gobool(c) -} - -// SetIconName is a wrapper around gtk_tool_button_set_icon_name(). -func (v *ToolButton) SetIconName(iconName string) { - cstr := C.CString(iconName) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_tool_button_set_icon_name(v.native(), (*C.gchar)(cstr)) -} - -// GetIconName is a wrapper around gtk_tool_button_get_icon_name(). -func (v *ToolButton) GetIconName() string { - c := C.gtk_tool_button_get_icon_name(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetIconWidget is a wrapper around gtk_tool_button_set_icon_widget(). -func (v *ToolButton) SetIconWidget(iconWidget IWidget) { - C.gtk_tool_button_set_icon_widget(v.native(), iconWidget.toWidget()) -} - -// GetIconWidget is a wrapper around gtk_tool_button_get_icon_widget(). -func (v *ToolButton) GetIconWidget() *Widget { - c := C.gtk_tool_button_get_icon_widget(v.native()) - if c == nil { - return nil - } - return wrapWidget(wrapObject(unsafe.Pointer(c))) -} - -// SetLabelWidget is a wrapper around gtk_tool_button_set_label_widget(). -func (v *ToolButton) SetLabelWidget(labelWidget IWidget) { - C.gtk_tool_button_set_label_widget(v.native(), labelWidget.toWidget()) -} - -// GetLabelWidget is a wrapper around gtk_tool_button_get_label_widget(). -func (v *ToolButton) GetLabelWidget() *Widget { - c := C.gtk_tool_button_get_label_widget(v.native()) - if c == nil { - return nil - } - return wrapWidget(wrapObject(unsafe.Pointer(c))) -} - -/* - * GtkToolItem - */ - -// ToolItem is a representation of GTK's GtkToolItem. -type ToolItem struct { - Bin -} - -// IToolItem is an interface type implemented by all structs embedding -// a ToolItem. It is meant to be used as an argument type for wrapper -// functions that wrap around a C GTK function taking a GtkToolItem. -type IToolItem interface { - toToolItem() *C.GtkToolItem -} - -// native returns a pointer to the underlying GtkToolItem. -func (v *ToolItem) native() *C.GtkToolItem { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkToolItem(p) -} - -func (v *ToolItem) toToolItem() *C.GtkToolItem { - return v.native() -} - -func marshalToolItem(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapToolItem(obj), nil -} - -func wrapToolItem(obj *glib.Object) *ToolItem { - return &ToolItem{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// ToolItemNew is a wrapper around gtk_tool_item_new(). -func ToolItemNew() (*ToolItem, error) { - c := C.gtk_tool_item_new() - if c == nil { - return nil, nilPtrErr - } - return wrapToolItem(wrapObject(unsafe.Pointer(c))), nil -} - -// SetHomogeneous is a wrapper around gtk_tool_item_set_homogeneous(). -func (v *ToolItem) SetHomogeneous(homogeneous bool) { - C.gtk_tool_item_set_homogeneous(v.native(), gbool(homogeneous)) -} - -// GetHomogeneous is a wrapper around gtk_tool_item_get_homogeneous(). -func (v *ToolItem) GetHomogeneous() bool { - c := C.gtk_tool_item_get_homogeneous(v.native()) - return gobool(c) -} - -// SetExpand is a wrapper around gtk_tool_item_set_expand(). -func (v *ToolItem) SetExpand(expand bool) { - C.gtk_tool_item_set_expand(v.native(), gbool(expand)) -} - -// GetExpand is a wrapper around gtk_tool_item_get_expand(). -func (v *ToolItem) GetExpand() bool { - c := C.gtk_tool_item_get_expand(v.native()) - return gobool(c) -} - -// SetTooltipText is a wrapper around gtk_tool_item_set_tooltip_text(). -func (v *ToolItem) SetTooltipText(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_tool_item_set_tooltip_text(v.native(), (*C.gchar)(cstr)) -} - -// SetTooltipMarkup is a wrapper around gtk_tool_item_set_tooltip_markup(). -func (v *ToolItem) SetTooltipMarkup(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_tool_item_set_tooltip_markup(v.native(), (*C.gchar)(cstr)) -} - -// SetUseDragWindow is a wrapper around gtk_tool_item_set_use_drag_window(). -func (v *ToolItem) SetUseDragWindow(useDragWindow bool) { - C.gtk_tool_item_set_use_drag_window(v.native(), gbool(useDragWindow)) -} - -// GetUseDragWindow is a wrapper around gtk_tool_item_get_use_drag_window(). -func (v *ToolItem) GetUseDragWindow() bool { - c := C.gtk_tool_item_get_use_drag_window(v.native()) - return gobool(c) -} - -// SetVisibleHorizontal is a wrapper around -// gtk_tool_item_set_visible_horizontal(). -func (v *ToolItem) SetVisibleHorizontal(visibleHorizontal bool) { - C.gtk_tool_item_set_visible_horizontal(v.native(), - gbool(visibleHorizontal)) -} - -// GetVisibleHorizontal is a wrapper around -// gtk_tool_item_get_visible_horizontal(). -func (v *ToolItem) GetVisibleHorizontal() bool { - c := C.gtk_tool_item_get_visible_horizontal(v.native()) - return gobool(c) -} - -// SetVisibleVertical is a wrapper around gtk_tool_item_set_visible_vertical(). -func (v *ToolItem) SetVisibleVertical(visibleVertical bool) { - C.gtk_tool_item_set_visible_vertical(v.native(), gbool(visibleVertical)) -} - -// GetVisibleVertical is a wrapper around gtk_tool_item_get_visible_vertical(). -func (v *ToolItem) GetVisibleVertical() bool { - c := C.gtk_tool_item_get_visible_vertical(v.native()) - return gobool(c) -} - -// SetIsImportant is a wrapper around gtk_tool_item_set_is_important(). -func (v *ToolItem) SetIsImportant(isImportant bool) { - C.gtk_tool_item_set_is_important(v.native(), gbool(isImportant)) -} - -// GetIsImportant is a wrapper around gtk_tool_item_get_is_important(). -func (v *ToolItem) GetIsImportant() bool { - c := C.gtk_tool_item_get_is_important(v.native()) - return gobool(c) -} - -// TODO: gtk_tool_item_get_ellipsize_mode - -// GetIconSize is a wrapper around gtk_tool_item_get_icon_size(). -func (v *ToolItem) GetIconSize() IconSize { - c := C.gtk_tool_item_get_icon_size(v.native()) - return IconSize(c) -} - -// GetOrientation is a wrapper around gtk_tool_item_get_orientation(). -func (v *ToolItem) GetOrientation() Orientation { - c := C.gtk_tool_item_get_orientation(v.native()) - return Orientation(c) -} - -// GetToolbarStyle is a wrapper around gtk_tool_item_get_toolbar_style(). -func (v *ToolItem) gtk_tool_item_get_toolbar_style() ToolbarStyle { - c := C.gtk_tool_item_get_toolbar_style(v.native()) - return ToolbarStyle(c) -} - -// GetReliefStyle is a wrapper around gtk_tool_item_get_relief_style(). -func (v *ToolItem) GetReliefStyle() ReliefStyle { - c := C.gtk_tool_item_get_relief_style(v.native()) - return ReliefStyle(c) -} - -// GetTextAlignment is a wrapper around gtk_tool_item_get_text_alignment(). -func (v *ToolItem) GetTextAlignment() float32 { - c := C.gtk_tool_item_get_text_alignment(v.native()) - return float32(c) -} - -// GetTextOrientation is a wrapper around gtk_tool_item_get_text_orientation(). -func (v *ToolItem) GetTextOrientation() Orientation { - c := C.gtk_tool_item_get_text_orientation(v.native()) - return Orientation(c) -} - -// RetrieveProxyMenuItem is a wrapper around -// gtk_tool_item_retrieve_proxy_menu_item() -func (v *ToolItem) RetrieveProxyMenuItem() *MenuItem { - c := C.gtk_tool_item_retrieve_proxy_menu_item(v.native()) - if c == nil { - return nil - } - return wrapMenuItem(wrapObject(unsafe.Pointer(c))) -} - -// SetProxyMenuItem is a wrapper around gtk_tool_item_set_proxy_menu_item(). -func (v *ToolItem) SetProxyMenuItem(menuItemId string, menuItem IMenuItem) { - cstr := C.CString(menuItemId) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_tool_item_set_proxy_menu_item(v.native(), (*C.gchar)(cstr), - C.toGtkWidget(unsafe.Pointer(menuItem.toMenuItem()))) -} - -// RebuildMenu is a wrapper around gtk_tool_item_rebuild_menu(). -func (v *ToolItem) RebuildMenu() { - C.gtk_tool_item_rebuild_menu(v.native()) -} - -// ToolbarReconfigured is a wrapper around gtk_tool_item_toolbar_reconfigured(). -func (v *ToolItem) ToolbarReconfigured() { - C.gtk_tool_item_toolbar_reconfigured(v.native()) -} - -// TODO: gtk_tool_item_get_text_size_group - -/* - * GtkTreeIter - */ - -// TreeIter is a representation of GTK's GtkTreeIter. -type TreeIter struct { - GtkTreeIter C.GtkTreeIter -} - -// native returns a pointer to the underlying GtkTreeIter. -func (v *TreeIter) native() *C.GtkTreeIter { - if v == nil { - return nil - } - return &v.GtkTreeIter -} - -func marshalTreeIter(p uintptr) (interface{}, error) { - c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) - return (*TreeIter)(unsafe.Pointer(c)), nil -} - -func (v *TreeIter) free() { - C.gtk_tree_iter_free(v.native()) -} - -// Copy() is a wrapper around gtk_tree_iter_copy(). -func (v *TreeIter) Copy() (*TreeIter, error) { - c := C.gtk_tree_iter_copy(v.native()) - if c == nil { - return nil, nilPtrErr - } - t := &TreeIter{*c} - runtime.SetFinalizer(t, (*TreeIter).free) - return t, nil -} - -/* - * GtkTreeModel - */ - -// TreeModel is a representation of GTK's GtkTreeModel GInterface. -type TreeModel struct { - *glib.Object -} - -// ITreeModel is an interface type implemented by all structs -// embedding a TreeModel. It is meant to be used as an argument type -// for wrapper functions that wrap around a C GTK function taking a -// GtkTreeModel. -type ITreeModel interface { - toTreeModel() *C.GtkTreeModel -} - -// native returns a pointer to the underlying GObject as a GtkTreeModel. -func (v *TreeModel) native() *C.GtkTreeModel { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkTreeModel(p) -} - -func (v *TreeModel) toTreeModel() *C.GtkTreeModel { - if v == nil { - return nil - } - return v.native() -} - -func marshalTreeModel(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapTreeModel(obj), nil -} - -func wrapTreeModel(obj *glib.Object) *TreeModel { - return &TreeModel{obj} -} - -// GetFlags() is a wrapper around gtk_tree_model_get_flags(). -func (v *TreeModel) GetFlags() TreeModelFlags { - c := C.gtk_tree_model_get_flags(v.native()) - return TreeModelFlags(c) -} - -// GetNColumns() is a wrapper around gtk_tree_model_get_n_columns(). -func (v *TreeModel) GetNColumns() int { - c := C.gtk_tree_model_get_n_columns(v.native()) - return int(c) -} - -// GetColumnType() is a wrapper around gtk_tree_model_get_column_type(). -func (v *TreeModel) GetColumnType(index int) glib.Type { - c := C.gtk_tree_model_get_column_type(v.native(), C.gint(index)) - return glib.Type(c) -} - -// GetIter() is a wrapper around gtk_tree_model_get_iter(). -func (v *TreeModel) GetIter(path *TreePath) (*TreeIter, error) { - var iter C.GtkTreeIter - c := C.gtk_tree_model_get_iter(v.native(), &iter, path.native()) - if !gobool(c) { - return nil, errors.New("Unable to set iterator") - } - t := &TreeIter{iter} - return t, nil -} - -// GetIterFromString() is a wrapper around -// gtk_tree_model_get_iter_from_string(). -func (v *TreeModel) GetIterFromString(path string) (*TreeIter, error) { - var iter C.GtkTreeIter - cstr := C.CString(path) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_tree_model_get_iter_from_string(v.native(), &iter, - (*C.gchar)(cstr)) - if !gobool(c) { - return nil, errors.New("Unable to set iterator") - } - t := &TreeIter{iter} - return t, nil -} - -// GetIterFirst() is a wrapper around gtk_tree_model_get_iter_first(). -func (v *TreeModel) GetIterFirst() (*TreeIter, bool) { - var iter C.GtkTreeIter - c := C.gtk_tree_model_get_iter_first(v.native(), &iter) - if !gobool(c) { - return nil, false - } - t := &TreeIter{iter} - return t, true -} - -// GetPath() is a wrapper around gtk_tree_model_get_path(). -func (v *TreeModel) GetPath(iter *TreeIter) (*TreePath, error) { - c := C.gtk_tree_model_get_path(v.native(), iter.native()) - if c == nil { - return nil, nilPtrErr - } - p := &TreePath{c} - runtime.SetFinalizer(p, (*TreePath).free) - return p, nil -} - -// GetValue() is a wrapper around gtk_tree_model_get_value(). -func (v *TreeModel) GetValue(iter *TreeIter, column int) (*glib.Value, error) { - val, err := glib.ValueAlloc() - if err != nil { - return nil, err - } - C.gtk_tree_model_get_value( - (*C.GtkTreeModel)(unsafe.Pointer(v.native())), - iter.native(), - C.gint(column), - (*C.GValue)(unsafe.Pointer(val.Native()))) - return val, nil -} - -// IterNext() is a wrapper around gtk_tree_model_iter_next(). -func (v *TreeModel) IterNext(iter *TreeIter) bool { - c := C.gtk_tree_model_iter_next(v.native(), iter.native()) - return gobool(c) -} - -// IterPrevious is a wrapper around gtk_tree_model_iter_previous(). -func (v *TreeModel) IterPrevious(iter *TreeIter) bool { - c := C.gtk_tree_model_iter_previous(v.native(), iter.native()) - return gobool(c) -} - -// IterNthChild is a wrapper around gtk_tree_model_iter_nth_child(). -func (v *TreeModel) IterNthChild(iter *TreeIter, parent *TreeIter, n int) bool { - c := C.gtk_tree_model_iter_nth_child(v.native(), iter.native(), parent.native(), C.gint(n)) - return gobool(c) -} - -// IterChildren is a wrapper around gtk_tree_model_iter_children(). -func (v *TreeModel) IterChildren(iter, child *TreeIter) bool { - var cIter, cChild *C.GtkTreeIter - if iter != nil { - cIter = iter.native() - } - cChild = child.native() - c := C.gtk_tree_model_iter_children(v.native(), cChild, cIter) - return gobool(c) -} - -// IterNChildren is a wrapper around gtk_tree_model_iter_n_children(). -func (v *TreeModel) IterNChildren(iter *TreeIter) int { - var cIter *C.GtkTreeIter - if iter != nil { - cIter = iter.native() - } - c := C.gtk_tree_model_iter_n_children(v.native(), cIter) - return int(c) -} - -/* - * GtkTreePath - */ - -// TreePath is a representation of GTK's GtkTreePath. -type TreePath struct { - GtkTreePath *C.GtkTreePath -} - -// Return a TreePath from the GList -func TreePathFromList(list *glib.List) *TreePath { - if list == nil { - return nil - } - return &TreePath{(*C.GtkTreePath)(list.Data().(unsafe.Pointer))} -} - -// native returns a pointer to the underlying GtkTreePath. -func (v *TreePath) native() *C.GtkTreePath { - if v == nil { - return nil - } - return v.GtkTreePath -} - -func marshalTreePath(p uintptr) (interface{}, error) { - c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) - return &TreePath{(*C.GtkTreePath)(unsafe.Pointer(c))}, nil -} - -func (v *TreePath) free() { - C.gtk_tree_path_free(v.native()) -} - -// String is a wrapper around gtk_tree_path_to_string(). -func (v *TreePath) String() string { - c := C.gtk_tree_path_to_string(v.native()) - return C.GoString((*C.char)(c)) -} - -// TreePathNewFromString is a wrapper around gtk_tree_path_new_from_string(). -func TreePathNewFromString(path string) (*TreePath, error) { - cstr := C.CString(path) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_tree_path_new_from_string((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - t := &TreePath{c} - runtime.SetFinalizer(t, (*TreePath).free) - return t, nil -} - -/* - * GtkTreeSelection - */ - -// TreeSelection is a representation of GTK's GtkTreeSelection. -type TreeSelection struct { - *glib.Object -} - -// native returns a pointer to the underlying GtkTreeSelection. -func (v *TreeSelection) native() *C.GtkTreeSelection { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkTreeSelection(p) -} - -func marshalTreeSelection(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapTreeSelection(obj), nil -} - -func wrapTreeSelection(obj *glib.Object) *TreeSelection { - return &TreeSelection{obj} -} - -// GetSelected() is a wrapper around gtk_tree_selection_get_selected(). -func (v *TreeSelection) GetSelected() (model ITreeModel, iter *TreeIter, ok bool) { - var cmodel *C.GtkTreeModel - var citer C.GtkTreeIter - c := C.gtk_tree_selection_get_selected(v.native(), - &cmodel, &citer) - model = wrapTreeModel(wrapObject(unsafe.Pointer(cmodel))) - iter = &TreeIter{citer} - ok = gobool(c) - return -} - -// SelectPath is a wrapper around gtk_tree_selection_select_path(). -func (v *TreeSelection) SelectPath(path *TreePath) { - C.gtk_tree_selection_select_path(v.native(), path.native()) -} - -// UnselectPath is a wrapper around gtk_tree_selection_unselect_path(). -func (v *TreeSelection) UnselectPath(path *TreePath) { - C.gtk_tree_selection_unselect_path(v.native(), path.native()) -} - -// GetSelectedRows is a wrapper around gtk_tree_selection_get_selected_rows(). -// All the elements of returned list are wrapped into (*gtk.TreePath) values. -// -// Please note that a runtime finalizer is only set on the head of the linked -// list, and must be kept live while accessing any item in the list, or the -// Go garbage collector will free the whole list. -func (v *TreeSelection) GetSelectedRows(model ITreeModel) *glib.List { - var pcmodel **C.GtkTreeModel - if model != nil { - cmodel := model.toTreeModel() - pcmodel = &cmodel - } - - clist := C.gtk_tree_selection_get_selected_rows(v.native(), pcmodel) - if clist == nil { - return nil - } - - glist := glib.WrapList(uintptr(unsafe.Pointer(clist))) - glist.DataWrapper(func(ptr unsafe.Pointer) interface{} { - return &TreePath{(*C.GtkTreePath)(ptr)} - }) - runtime.SetFinalizer(glist, func(glist *glib.List) { - glist.FreeFull(func(item interface{}) { - path := item.(*TreePath) - C.gtk_tree_path_free(path.GtkTreePath) - }) - }) - - return glist -} - -// CountSelectedRows() is a wrapper around gtk_tree_selection_count_selected_rows(). -func (v *TreeSelection) CountSelectedRows() int { - return int(C.gtk_tree_selection_count_selected_rows(v.native())) -} - -// SelectIter is a wrapper around gtk_tree_selection_select_iter(). -func (v *TreeSelection) SelectIter(iter *TreeIter) { - C.gtk_tree_selection_select_iter(v.native(), iter.native()) -} - -// SetMode() is a wrapper around gtk_tree_selection_set_mode(). -func (v *TreeSelection) SetMode(m SelectionMode) { - C.gtk_tree_selection_set_mode(v.native(), C.GtkSelectionMode(m)) -} - -// GetMode() is a wrapper around gtk_tree_selection_get_mode(). -func (v *TreeSelection) GetMode() SelectionMode { - return SelectionMode(C.gtk_tree_selection_get_mode(v.native())) -} - -/* - * GtkTreeStore - */ - -// TreeStore is a representation of GTK's GtkTreeStore. -type TreeStore struct { - *glib.Object - - // Interfaces - TreeModel -} - -// native returns a pointer to the underlying GtkTreeStore. -func (v *TreeStore) native() *C.GtkTreeStore { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkTreeStore(p) -} - -func marshalTreeStore(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapTreeStore(obj), nil -} - -func wrapTreeStore(obj *glib.Object) *TreeStore { - tm := wrapTreeModel(obj) - return &TreeStore{obj, *tm} -} - -func (v *TreeStore) toTreeModel() *C.GtkTreeModel { - if v == nil { - return nil - } - return C.toGtkTreeModel(unsafe.Pointer(v.GObject)) -} - -// TreeStoreNew is a wrapper around gtk_tree_store_newv(). -func TreeStoreNew(types ...glib.Type) (*TreeStore, error) { - gtypes := C.alloc_types(C.int(len(types))) - for n, val := range types { - C.set_type(gtypes, C.int(n), C.GType(val)) - } - defer C.g_free(C.gpointer(gtypes)) - c := C.gtk_tree_store_newv(C.gint(len(types)), gtypes) - if c == nil { - return nil, nilPtrErr - } - - ts := wrapTreeStore(wrapObject(unsafe.Pointer(c))) - return ts, nil -} - -// Append is a wrapper around gtk_tree_store_append(). -func (v *TreeStore) Append(parent *TreeIter) *TreeIter { - var ti C.GtkTreeIter - var cParent *C.GtkTreeIter - if parent != nil { - cParent = parent.native() - } - C.gtk_tree_store_append(v.native(), &ti, cParent) - iter := &TreeIter{ti} - return iter -} - -// Insert is a wrapper around gtk_tree_store_insert -func (v *TreeStore) Insert(parent *TreeIter, position int) *TreeIter { - var ti C.GtkTreeIter - var cParent *C.GtkTreeIter - if parent != nil { - cParent = parent.native() - } - C.gtk_tree_store_insert(v.native(), &ti, cParent, C.gint(position)) - iter := &TreeIter{ti} - return iter -} - -// SetValue is a wrapper around gtk_tree_store_set_value() -func (v *TreeStore) SetValue(iter *TreeIter, column int, value interface{}) error { - switch value.(type) { - case *gdk.Pixbuf: - pix := value.(*gdk.Pixbuf) - C._gtk_tree_store_set(v.native(), iter.native(), C.gint(column), unsafe.Pointer(pix.Native())) - - default: - gv, err := glib.GValue(value) - if err != nil { - return err - } - C.gtk_tree_store_set_value(v.native(), iter.native(), - C.gint(column), - (*C.GValue)(C.gpointer(gv.Native()))) - } - return nil -} - -// Remove is a wrapper around gtk_tree_store_remove(). -func (v *TreeStore) Remove(iter *TreeIter) bool { - var ti *C.GtkTreeIter - if iter != nil { - ti = iter.native() - } - return 0 != C.gtk_tree_store_remove(v.native(), ti) -} - -// Clear is a wrapper around gtk_tree_store_clear(). -func (v *TreeStore) Clear() { - C.gtk_tree_store_clear(v.native()) -} - -/* - * GtkViewport - */ - -// Viewport is a representation of GTK's GtkViewport GInterface. -type Viewport struct { - Bin - - // Interfaces - Scrollable -} - -// IViewport is an interface type implemented by all structs -// embedding a Viewport. It is meant to be used as an argument type -// for wrapper functions that wrap around a C GTK function taking a -// GtkViewport. -type IViewport interface { - toViewport() *C.GtkViewport -} - -// native() returns a pointer to the underlying GObject as a GtkViewport. -func (v *Viewport) native() *C.GtkViewport { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkViewport(p) -} - -func wrapViewport(obj *glib.Object) *Viewport { - b := wrapBin(obj) - s := wrapScrollable(obj) - return &Viewport{ - Bin: *b, - Scrollable: *s, - } -} - -func (v *Viewport) toViewport() *C.GtkViewport { - if v == nil { - return nil - } - return v.native() -} - -// ViewportNew() is a wrapper around gtk_viewport_new(). -func ViewportNew(hadjustment, vadjustment *Adjustment) (*Viewport, error) { - c := C.gtk_viewport_new(hadjustment.native(), vadjustment.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapViewport(wrapObject(unsafe.Pointer(c))), nil -} - -func (v *Viewport) SetHAdjustment(adjustment *Adjustment) { - wrapScrollable(v.Object).SetHAdjustment(adjustment) -} - -func (v *Viewport) GetHAdjustment() (*Adjustment, error) { - return wrapScrollable(v.Object).GetHAdjustment() -} - -func (v *Viewport) SetVAdjustment(adjustment *Adjustment) { - wrapScrollable(v.Object).SetVAdjustment(adjustment) -} - -func (v *Viewport) GetVAdjustment() (*Adjustment, error) { - return wrapScrollable(v.Object).GetVAdjustment() -} - -/* - * GtkVolumeButton - */ - -// VolumeButton is a representation of GTK's GtkVolumeButton. -type VolumeButton struct { - ScaleButton -} - -// native() returns a pointer to the underlying GtkVolumeButton. -func (v *VolumeButton) native() *C.GtkVolumeButton { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkVolumeButton(p) -} - -func marshalVolumeButton(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapVolumeButton(obj), nil -} - -func wrapVolumeButton(obj *glib.Object) *VolumeButton { - return &VolumeButton{ScaleButton{Button{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}}}} -} - -// VolumeButtonNew() is a wrapper around gtk_button_new(). -func VolumeButtonNew() (*VolumeButton, error) { - c := C.gtk_volume_button_new() - if c == nil { - return nil, nilPtrErr - } - return wrapVolumeButton(wrapObject(unsafe.Pointer(c))), nil -} - -type WrapFn interface{} - -var WrapMap = map[string]WrapFn{ - "GtkAccelGroup": wrapAccelGroup, - "GtkAccelMao": wrapAccelMap, - "GtkAdjustment": wrapAdjustment, - "GtkApplicationWindow": wrapApplicationWindow, - "GtkAssistant": wrapAssistant, - "GtkBin": wrapBin, - "GtkBox": wrapBox, - "GtkButton": wrapButton, - "GtkCalendar": wrapCalendar, - "GtkCellLayout": wrapCellLayout, - "GtkCellRenderer": wrapCellRenderer, - "GtkCellRendererSpinner": wrapCellRendererSpinner, - "GtkCellRendererPixbuf": wrapCellRendererPixbuf, - "GtkCellRendererText": wrapCellRendererText, - "GtkCellRendererToggle": wrapCellRendererToggle, - "GtkCheckButton": wrapCheckButton, - "GtkCheckMenuItem": wrapCheckMenuItem, - "GtkClipboard": wrapClipboard, - "GtkColorButton": wrapColorButton, - "GtkContainer": wrapContainer, - "GtkDialog": wrapDialog, - "GtkDrawingArea": wrapDrawingArea, - "GtkEditable": wrapEditable, - "GtkEntry": wrapEntry, - "GtkEntryBuffer": wrapEntryBuffer, - "GtkEntryCompletion": wrapEntryCompletion, - "GtkEventBox": wrapEventBox, - "GtkExpander": wrapExpander, - "GtkFrame": wrapFrame, - "GtkFileChooser": wrapFileChooser, - "GtkFileChooserButton": wrapFileChooserButton, - "GtkFileChooserDialog": wrapFileChooserDialog, - "GtkFileChooserWidget": wrapFileChooserWidget, - "GtkFontButton": wrapFontButton, - "GtkGrid": wrapGrid, - "GtkIconView": wrapIconView, - "GtkImage": wrapImage, - "GtkLabel": wrapLabel, - "GtkLayout": wrapLayout, - "GtkLinkButton": wrapLinkButton, - "GtkListStore": wrapListStore, - "GtkMenu": wrapMenu, - "GtkMenuBar": wrapMenuBar, - "GtkMenuButton": wrapMenuButton, - "GtkMenuItem": wrapMenuItem, - "GtkMenuShell": wrapMenuShell, - "GtkMessageDialog": wrapMessageDialog, - "GtkNotebook": wrapNotebook, - "GtkOffscreenWindow": wrapOffscreenWindow, - "GtkOrientable": wrapOrientable, - "GtkPaned": wrapPaned, - "GtkProgressBar": wrapProgressBar, - "GtkRadioButton": wrapRadioButton, - "GtkRadioMenuItem": wrapRadioMenuItem, - "GtkRange": wrapRange, - "GtkRecentChooser": wrapRecentChooser, - "GtkRecentChooserMenu": wrapRecentChooserMenu, - "GtkRecentFilter": wrapRecentFilter, - "GtkRecentManager": wrapRecentManager, - "GtkScaleButton": wrapScaleButton, - "GtkScale": wrapScale, - "GtkScrollable": wrapScrollable, - "GtkScrollbar": wrapScrollbar, - "GtkScrolledWindow": wrapScrolledWindow, - "GtkSearchEntry": wrapSearchEntry, - "GtkSeparator": wrapSeparator, - "GtkSeparatorMenuItem": wrapSeparatorMenuItem, - "GtkSeparatorToolItem": wrapSeparatorToolItem, - "GtkSpinButton": wrapSpinButton, - "GtkSpinner": wrapSpinner, - "GtkStatusbar": wrapStatusbar, - "GtkSwitch": wrapSwitch, - "GtkTextView": wrapTextView, - "GtkTextBuffer": wrapTextBuffer, - "GtkTextTag": wrapTextTag, - "GtkTextTagTable": wrapTextTagTable, - "GtkToggleButton": wrapToggleButton, - "GtkToolbar": wrapToolbar, - "GtkToolButton": wrapToolButton, - "GtkToolItem": wrapToolItem, - "GtkTreeModel": wrapTreeModel, - "GtkTreeSelection": wrapTreeSelection, - "GtkTreeStore": wrapTreeStore, - "GtkTreeView": wrapTreeView, - "GtkTreeViewColumn": wrapTreeViewColumn, - "GtkViewport": wrapViewport, - "GtkVolumeButton": wrapVolumeButton, - "GtkWidget": wrapWidget, - "GtkWindow": wrapWindow, -} - -// cast takes a native GObject and casts it to the appropriate Go struct. -//TODO change all wrapFns to return an IObject -func cast(c *C.GObject) (glib.IObject, error) { - var ( - className = C.GoString((*C.char)(C.object_get_class_name(c))) - obj = wrapObject(unsafe.Pointer(c)) - ) - - fn, ok := WrapMap[className] - if !ok { - return nil, errors.New("unrecognized class name '" + className + "'") - } - - rf := reflect.ValueOf(fn) - if rf.Type().Kind() != reflect.Func { - return nil, errors.New("wraper is not a function") - } - - v := reflect.ValueOf(obj) - rv := rf.Call([]reflect.Value{v}) - - if len(rv) != 1 { - return nil, errors.New("wrapper did not return") - } - - if k := rv[0].Kind(); k != reflect.Ptr { - return nil, fmt.Errorf("wrong return type %s", k) - } - - ret, ok := rv[0].Interface().(glib.IObject) - if !ok { - return nil, errors.New("did not return an IObject") - } - - return ret, nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/gtk.go.h b/vendor/github.com/gotk3/gotk3.old/gtk/gtk.go.h deleted file mode 100644 index 25876f0..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/gtk.go.h +++ /dev/null @@ -1,813 +0,0 @@ -/* - * Copyright (c) 2013-2014 Conformal Systems - * - * This file originated from: http://opensource.conformal.com/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef __GTK_GO_H__ -#define __GTK_GO_H__ - -#include -#include -#include - -static GtkAboutDialog * -toGtkAboutDialog(void *p) -{ - return (GTK_ABOUT_DIALOG(p)); -} - -static GtkAppChooser * -toGtkAppChooser(void *p) -{ - return (GTK_APP_CHOOSER(p)); -} - -static GtkAppChooserButton * -toGtkAppChooserButton(void *p) -{ - return (GTK_APP_CHOOSER_BUTTON(p)); -} - -static GtkAppChooserDialog * -toGtkAppChooserDialog(void *p) -{ - return (GTK_APP_CHOOSER_DIALOG(p)); -} - -static GtkAppChooserWidget * -toGtkAppChooserWidget(void *p) -{ - return (GTK_APP_CHOOSER_WIDGET(p)); -} - -static GtkApplication * -toGtkApplication(void *p) -{ - return (GTK_APPLICATION(p)); -} - -static GtkApplicationWindow * -toGtkApplicationWindow(void *p) -{ - return (GTK_APPLICATION_WINDOW(p)); -} - -static GtkAssistant * -toGtkAssistant(void *p) -{ - return (GTK_ASSISTANT(p)); -} - -static GtkCalendar * -toGtkCalendar(void *p) -{ - return (GTK_CALENDAR(p)); -} - -static GtkColorChooserDialog * -toGtkColorChooserDialog(void *p) -{ - return (GTK_COLOR_CHOOSER_DIALOG(p)); -} - -static GtkDrawingArea * -toGtkDrawingArea(void *p) -{ - return (GTK_DRAWING_AREA(p)); -} - -static GtkCellRendererSpinner * -toGtkCellRendererSpinner(void *p) -{ - return (GTK_CELL_RENDERER_SPINNER(p)); -} - -static GtkEventBox * -toGtkEventBox(void *p) -{ - return (GTK_EVENT_BOX(p)); -} - -static GtkGrid * -toGtkGrid(void *p) -{ - return (GTK_GRID(p)); -} - -static GtkWidget * -toGtkWidget(void *p) -{ - return (GTK_WIDGET(p)); -} - -static GtkContainer * -toGtkContainer(void *p) -{ - return (GTK_CONTAINER(p)); -} - -static GtkPaned * -toGtkPaned(void *p) -{ - return (GTK_PANED(p)); -} - -static GtkProgressBar * -toGtkProgressBar(void *p) -{ - return (GTK_PROGRESS_BAR(p)); -} - -static GtkLevelBar * -toGtkLevelBar(void *p) -{ - return (GTK_LEVEL_BAR(p)); -} - -static GtkBin * -toGtkBin(void *p) -{ - return (GTK_BIN(p)); -} - -static GtkWindow * -toGtkWindow(void *p) -{ - return (GTK_WINDOW(p)); -} - -static GtkBox * -toGtkBox(void *p) -{ - return (GTK_BOX(p)); -} - -static GtkStatusbar * -toGtkStatusbar(void *p) -{ - return (GTK_STATUSBAR(p)); -} - -static GtkLabel * -toGtkLabel(void *p) -{ - return (GTK_LABEL(p)); -} - -static GtkNotebook * -toGtkNotebook(void *p) -{ - return (GTK_NOTEBOOK(p)); -} - -static GtkEntry * -toGtkEntry(void *p) -{ - return (GTK_ENTRY(p)); -} - -static GtkEntryBuffer * -toGtkEntryBuffer(void *p) -{ - return (GTK_ENTRY_BUFFER(p)); -} - -static GtkEntryCompletion * -toGtkEntryCompletion(void *p) -{ - return (GTK_ENTRY_COMPLETION(p)); -} - -static GtkAdjustment * -toGtkAdjustment(void *p) -{ - return (GTK_ADJUSTMENT(p)); -} - -static GtkAccelGroup * -toGtkAccelGroup(void *p) -{ - return (GTK_ACCEL_GROUP(p)); -} - -static GtkAccelMap * -toGtkAccelMap(void *p) -{ - return (GTK_ACCEL_MAP(p)); -} - -static GtkTextTag * -toGtkTextTag(void *p) -{ - return (GTK_TEXT_TAG(p)); -} - -static GtkIconView * -toGtkIconView(void *p) -{ - return (GTK_ICON_VIEW(p)); -} - -static GtkImage * -toGtkImage(void *p) -{ - return (GTK_IMAGE(p)); -} - -static GtkButton * -toGtkButton(void *p) -{ - return (GTK_BUTTON(p)); -} - -static GtkScaleButton * -toGtkScaleButton(void *p) -{ - return (GTK_SCALE_BUTTON(p)); -} - -static GtkColorButton * -toGtkColorButton(void *p) -{ - return (GTK_COLOR_BUTTON(p)); -} - -static GtkViewport * -toGtkViewport(void *p) -{ - return (GTK_VIEWPORT(p)); -} - -static GtkVolumeButton * -toGtkVolumeButton(void *p) -{ - return (GTK_VOLUME_BUTTON(p)); -} - -static GtkScrollable * -toGtkScrollable(void *p) -{ - return (GTK_SCROLLABLE(p)); -} - -static GtkScrolledWindow * -toGtkScrolledWindow(void *p) -{ - return (GTK_SCROLLED_WINDOW(p)); -} - -static GtkMenuItem * -toGtkMenuItem(void *p) -{ - return (GTK_MENU_ITEM(p)); -} - -static GtkMenu * -toGtkMenu(void *p) -{ - return (GTK_MENU(p)); -} - -static GtkMenuShell * -toGtkMenuShell(void *p) -{ - return (GTK_MENU_SHELL(p)); -} - -static GtkMenuBar * -toGtkMenuBar(void *p) -{ - return (GTK_MENU_BAR(p)); -} - -static GtkSizeGroup * -toGtkSizeGroup(void *p) -{ - return (GTK_SIZE_GROUP(p)); -} - -static GtkSpinButton * -toGtkSpinButton(void *p) -{ - return (GTK_SPIN_BUTTON(p)); -} - -static GtkSpinner * -toGtkSpinner(void *p) -{ - return (GTK_SPINNER(p)); -} - -static GtkComboBox * -toGtkComboBox(void *p) -{ - return (GTK_COMBO_BOX(p)); -} - -static GtkComboBoxText * -toGtkComboBoxText(void *p) -{ - return (GTK_COMBO_BOX_TEXT(p)); -} - -static GtkLinkButton * -toGtkLinkButton(void *p) -{ - return (GTK_LINK_BUTTON(p)); -} - -static GtkLayout * -toGtkLayout(void *p) -{ - return (GTK_LAYOUT(p)); -} - -static GtkListStore * -toGtkListStore(void *p) -{ - return (GTK_LIST_STORE(p)); -} - -static GtkSwitch * -toGtkSwitch(void *p) -{ - return (GTK_SWITCH(p)); -} - -static GtkTextView * -toGtkTextView(void *p) -{ - return (GTK_TEXT_VIEW(p)); -} - -static GtkTextTagTable * -toGtkTextTagTable(void *p) -{ - return (GTK_TEXT_TAG_TABLE(p)); -} - -static GtkTextBuffer * -toGtkTextBuffer(void *p) -{ - return (GTK_TEXT_BUFFER(p)); -} - -static GtkTreeModel * -toGtkTreeModel(void *p) -{ - return (GTK_TREE_MODEL(p)); -} - -static GtkCellRenderer * -toGtkCellRenderer(void *p) -{ - return (GTK_CELL_RENDERER(p)); -} - -static GtkCellRendererPixbuf * -toGtkCellRendererPixbuf(void *p) -{ - return (GTK_CELL_RENDERER_PIXBUF(p)); -} - -static GtkCellRendererText * -toGtkCellRendererText(void *p) -{ - return (GTK_CELL_RENDERER_TEXT(p)); -} - -static GtkCellRendererToggle * -toGtkCellRendererToggle(void *p) -{ - return (GTK_CELL_RENDERER_TOGGLE(p)); -} - -static GtkCellLayout * -toGtkCellLayout(void *p) -{ - return (GTK_CELL_LAYOUT(p)); -} - -static GtkOrientable * -toGtkOrientable(void *p) -{ - return (GTK_ORIENTABLE(p)); -} - -static GtkTreeStore * -toGtkTreeStore (void *p) -{ - return (GTK_TREE_STORE(p)); -} - -static GtkTreeView * -toGtkTreeView(void *p) -{ - return (GTK_TREE_VIEW(p)); -} - -static GtkTreeViewColumn * -toGtkTreeViewColumn(void *p) -{ - return (GTK_TREE_VIEW_COLUMN(p)); -} - -static GtkTreeSelection * -toGtkTreeSelection(void *p) -{ - return (GTK_TREE_SELECTION(p)); -} - -static GtkTreeSortable * -toGtkTreeSortable(void *p) -{ - return (GTK_TREE_SORTABLE(p)); -} - -static GtkClipboard * -toGtkClipboard(void *p) -{ - return (GTK_CLIPBOARD(p)); -} - -static GtkDialog * -toGtkDialog(void *p) -{ - return (GTK_DIALOG(p)); -} - -static GtkMessageDialog * -toGtkMessageDialog(void *p) -{ - return (GTK_MESSAGE_DIALOG(p)); -} - -static GtkBuilder * -toGtkBuilder(void *p) -{ - return (GTK_BUILDER(p)); -} - -static GtkSeparatorMenuItem * -toGtkSeparatorMenuItem(void *p) -{ - return (GTK_SEPARATOR_MENU_ITEM(p)); -} - -static GtkCheckButton * -toGtkCheckButton(void *p) -{ - return (GTK_CHECK_BUTTON(p)); -} - -static GtkToggleButton * -toGtkToggleButton(void *p) -{ - return (GTK_TOGGLE_BUTTON(p)); -} - -static GtkFontButton * -toGtkFontButton(void *p) -{ - return (GTK_FONT_BUTTON(p)); -} - -static GtkFrame * -toGtkFrame(void *p) -{ - return (GTK_FRAME(p)); -} - -static GtkSeparator * -toGtkSeparator(void *p) -{ - return (GTK_SEPARATOR(p)); -} - -static GtkScale* -toGtkScale(void *p) -{ - return (GTK_SCALE(p)); -} - -static GtkScrollbar * -toGtkScrollbar(void *p) -{ - return (GTK_SCROLLBAR(p)); -} - -static GtkRange * -toGtkRange(void *p) -{ - return (GTK_RANGE(p)); -} - -static GtkSearchEntry * -toGtkSearchEntry(void *p) -{ - return (GTK_SEARCH_ENTRY(p)); -} - -static GtkOffscreenWindow * -toGtkOffscreenWindow(void *p) -{ - return (GTK_OFFSCREEN_WINDOW(p)); -} - -static GtkExpander * -toGtkExpander(void *p) -{ - return (GTK_EXPANDER(p)); -} - -static GtkFileChooser * -toGtkFileChooser(void *p) -{ - return (GTK_FILE_CHOOSER(p)); -} - -static GtkFileChooserButton * -toGtkFileChooserButton(void *p) -{ - return (GTK_FILE_CHOOSER_BUTTON(p)); -} - -static GtkFileChooserDialog * -toGtkFileChooserDialog(void *p) -{ - return (GTK_FILE_CHOOSER_DIALOG(p)); -} - -static GtkFileChooserWidget * -toGtkFileChooserWidget(void *p) -{ - return (GTK_FILE_CHOOSER_WIDGET(p)); -} - -static GtkFileFilter * -toGtkFileFilter(void *p) -{ - return (GTK_FILE_FILTER(p)); -} - -static GtkMenuButton * -toGtkMenuButton(void *p) -{ - return (GTK_MENU_BUTTON(p)); -} - -static GtkRadioButton * -toGtkRadioButton(void *p) -{ - return (GTK_RADIO_BUTTON(p)); -} - -static GtkRecentChooser * -toGtkRecentChooser(void *p) -{ - return (GTK_RECENT_CHOOSER(p)); -} - -static GtkRecentChooserMenu * -toGtkRecentChooserMenu(void *p) -{ - return (GTK_RECENT_CHOOSER_MENU(p)); -} - -static GtkColorChooser * -toGtkColorChooser(void *p) -{ - return (GTK_COLOR_CHOOSER(p)); -} - -static GtkRecentFilter * -toGtkRecentFilter(void *p) -{ - return (GTK_RECENT_FILTER(p)); -} - -static GtkRecentManager * -toGtkRecentManager(void *p) -{ - return (GTK_RECENT_MANAGER(p)); -} - -static GtkCheckMenuItem * -toGtkCheckMenuItem(void *p) -{ - return (GTK_CHECK_MENU_ITEM(p)); -} - -static GtkRadioMenuItem * -toGtkRadioMenuItem(void *p) -{ - return (GTK_RADIO_MENU_ITEM(p)); -} - -static GtkToolItem * -toGtkToolItem(void *p) -{ - return (GTK_TOOL_ITEM(p)); -} - -static GtkToolbar * -toGtkToolbar(void *p) -{ - return (GTK_TOOLBAR(p)); -} - -static GtkEditable * -toGtkEditable(void *p) -{ - return (GTK_EDITABLE(p)); -} - -static GtkToolButton * -toGtkToolButton(void *p) -{ - return (GTK_TOOL_BUTTON(p)); -} - -static GtkSeparatorToolItem * -toGtkSeparatorToolItem(void *p) -{ - return (GTK_SEPARATOR_TOOL_ITEM(p)); -} - -static GtkCssProvider * -toGtkCssProvider(void *p) -{ - return (GTK_CSS_PROVIDER(p)); -} - -static GtkStyleContext * -toGtkStyleContext(void *p) -{ - return (GTK_STYLE_CONTEXT(p)); -} - -static GtkStyleProvider * -toGtkStyleProvider(void *p) -{ - return (GTK_STYLE_PROVIDER(p)); -} - -static GtkInfoBar * -toGtkInfoBar(void *p) -{ - return (GTK_INFO_BAR(p)); -} - -static GType * -alloc_types(int n) { - return ((GType *)g_new0(GType, n)); -} - -static void -set_type(GType *types, int n, GType t) -{ - types[n] = t; -} - -static GtkTreeViewColumn * -_gtk_tree_view_column_new_with_attributes_one(const gchar *title, - GtkCellRenderer *renderer, const gchar *attribute, gint column) -{ - GtkTreeViewColumn *tvc; - - tvc = gtk_tree_view_column_new_with_attributes(title, renderer, - attribute, column, NULL); - return (tvc); -} - -static void -_gtk_list_store_set(GtkListStore *list_store, GtkTreeIter *iter, gint column, - void* value) -{ - gtk_list_store_set(list_store, iter, column, value, -1); -} - -static void -_gtk_tree_store_set(GtkTreeStore *store, GtkTreeIter *iter, gint column, - void* value) -{ - gtk_tree_store_set(store, iter, column, value, -1); -} - -static GtkWidget * -_gtk_message_dialog_new(GtkWindow *parent, GtkDialogFlags flags, - GtkMessageType type, GtkButtonsType buttons, char *msg) -{ - GtkWidget *w; - - w = gtk_message_dialog_new(parent, flags, type, buttons, "%s", msg); - return (w); -} - -static GtkWidget * -_gtk_message_dialog_new_with_markup(GtkWindow *parent, GtkDialogFlags flags, - GtkMessageType type, GtkButtonsType buttons, char *msg) -{ - GtkWidget *w; - - w = gtk_message_dialog_new_with_markup(parent, flags, type, buttons, - "%s", msg); - return (w); -} - -static void -_gtk_message_dialog_format_secondary_text(GtkMessageDialog *message_dialog, - const gchar *msg) -{ - gtk_message_dialog_format_secondary_text(message_dialog, "%s", msg); -} - -static void -_gtk_message_dialog_format_secondary_markup(GtkMessageDialog *message_dialog, - const gchar *msg) -{ - gtk_message_dialog_format_secondary_markup(message_dialog, "%s", msg); -} - -static const gchar * -object_get_class_name(GObject *object) -{ - return G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(object)); -} - -static GtkWidget * -gtk_file_chooser_dialog_new_1( - const gchar *title, - GtkWindow *parent, - GtkFileChooserAction action, - const gchar *first_button_text, int first_button_id -) { - return gtk_file_chooser_dialog_new( - title, parent, action, - first_button_text, first_button_id, - NULL); -} - -static GtkWidget * -gtk_file_chooser_dialog_new_2( - const gchar *title, - GtkWindow *parent, - GtkFileChooserAction action, - const gchar *first_button_text, int first_button_id, - const gchar *second_button_text, int second_button_id -) { - return gtk_file_chooser_dialog_new( - title, parent, action, - first_button_text, first_button_id, - second_button_text, second_button_id, - NULL); -} - -static void _gtk_widget_hide_on_delete(GtkWidget* w) { - g_signal_connect(GTK_WIDGET(w), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL); -} - -static inline gchar** make_strings(int count) { - return (gchar**)malloc(sizeof(gchar*) * count); -} - -static inline void destroy_strings(gchar** strings) { - free(strings); -} - -static inline gchar* get_string(gchar** strings, int n) { - return strings[n]; -} - -static inline void set_string(gchar** strings, int n, gchar* str) { - strings[n] = str; -} - -static inline gchar** next_gcharptr(gchar** s) { return (s+1); } - -extern void goBuilderConnect (GtkBuilder *builder, - GObject *object, - gchar *signal_name, - gchar *handler_name, - GObject *connect_object, - GConnectFlags flags, - gpointer user_data); - -static inline void _gtk_builder_connect_signals_full(GtkBuilder *builder) { - gtk_builder_connect_signals_full(builder, (GtkBuilderConnectFunc)(goBuilderConnect), NULL); -} - -#endif diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_10.go b/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_10.go deleted file mode 100644 index d3477b2..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_10.go +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// This file includes wrapers for symbols deprecated beginning with GTK 3.10, -// and should only be included in a build targeted intended to target GTK -// 3.8 or earlier. To target an earlier build build, use the build tag -// gtk_MAJOR_MINOR. For example, to target GTK 3.8, run -// 'go build -tags gtk_3_8'. -// +build gtk_3_6 gtk_3_8 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -// #include -import "C" -import "unsafe" - -// ButtonNewFromStock is a wrapper around gtk_button_new_from_stock(). -func ButtonNewFromStock(stock Stock) (*Button, error) { - cstr := C.CString(string(stock)) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_button_new_from_stock((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapButton(wrapObject(unsafe.Pointer(c))), nil -} - -// SetUseStock is a wrapper around gtk_button_set_use_stock(). -func (v *Button) SetUseStock(useStock bool) { - C.gtk_button_set_use_stock(v.native(), gbool(useStock)) -} - -// GetUseStock is a wrapper around gtk_button_get_use_stock(). -func (v *Button) GetUseStock() bool { - c := C.gtk_button_get_use_stock(v.native()) - return gobool(c) -} - -// GetIconStock is a wrapper around gtk_entry_get_icon_stock(). -func (v *Entry) GetIconStock(iconPos EntryIconPosition) (string, error) { - c := C.gtk_entry_get_icon_stock(v.native(), - C.GtkEntryIconPosition(iconPos)) - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// SetIconFromStock is a wrapper around gtk_entry_set_icon_from_stock(). -func (v *Entry) SetIconFromStock(iconPos EntryIconPosition, stockID string) { - cstr := C.CString(stockID) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_entry_set_icon_from_stock(v.native(), - C.GtkEntryIconPosition(iconPos), (*C.gchar)(cstr)) -} - -// ImageNewFromStock is a wrapper around gtk_image_new_from_stock(). -func ImageNewFromStock(stock Stock, size IconSize) (*Image, error) { - cstr := C.CString(string(stock)) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_image_new_from_stock((*C.gchar)(cstr), C.GtkIconSize(size)) - if c == nil { - return nil, nilPtrErr - } - return wrapImage(wrapObject(unsafe.Pointer(c))), nil -} - -// SetFromStock is a wrapper around gtk_image_set_from_stock(). -func (v *Image) SetFromStock(stock Stock, size IconSize) { - cstr := C.CString(string(stock)) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_image_set_from_stock(v.native(), (*C.gchar)(cstr), - C.GtkIconSize(size)) -} - -// Stock is a special type that does not have an equivalent type in -// GTK. It is the type used as a parameter anytime an identifier for -// stock icons are needed. A Stock must be type converted to string when -// function parameters may take a Stock, but when other string values are -// valid as well. -type Stock string - -const ( - STOCK_ABOUT Stock = C.GTK_STOCK_ABOUT - STOCK_ADD Stock = C.GTK_STOCK_ADD - STOCK_APPLY Stock = C.GTK_STOCK_APPLY - STOCK_BOLD Stock = C.GTK_STOCK_BOLD - STOCK_CANCEL Stock = C.GTK_STOCK_CANCEL - STOCK_CAPS_LOCK_WARNING Stock = C.GTK_STOCK_CAPS_LOCK_WARNING - STOCK_CDROM Stock = C.GTK_STOCK_CDROM - STOCK_CLEAR Stock = C.GTK_STOCK_CLEAR - STOCK_CLOSE Stock = C.GTK_STOCK_CLOSE - STOCK_COLOR_PICKER Stock = C.GTK_STOCK_COLOR_PICKER - STOCK_CONNECT Stock = C.GTK_STOCK_CONNECT - STOCK_CONVERT Stock = C.GTK_STOCK_CONVERT - STOCK_COPY Stock = C.GTK_STOCK_COPY - STOCK_CUT Stock = C.GTK_STOCK_CUT - STOCK_DELETE Stock = C.GTK_STOCK_DELETE - STOCK_DIALOG_AUTHENTICATION Stock = C.GTK_STOCK_DIALOG_AUTHENTICATION - STOCK_DIALOG_INFO Stock = C.GTK_STOCK_DIALOG_INFO - STOCK_DIALOG_WARNING Stock = C.GTK_STOCK_DIALOG_WARNING - STOCK_DIALOG_ERROR Stock = C.GTK_STOCK_DIALOG_ERROR - STOCK_DIALOG_QUESTION Stock = C.GTK_STOCK_DIALOG_QUESTION - STOCK_DIRECTORY Stock = C.GTK_STOCK_DIRECTORY - STOCK_DISCARD Stock = C.GTK_STOCK_DISCARD - STOCK_DISCONNECT Stock = C.GTK_STOCK_DISCONNECT - STOCK_DND Stock = C.GTK_STOCK_DND - STOCK_DND_MULTIPLE Stock = C.GTK_STOCK_DND_MULTIPLE - STOCK_EDIT Stock = C.GTK_STOCK_EDIT - STOCK_EXECUTE Stock = C.GTK_STOCK_EXECUTE - STOCK_FILE Stock = C.GTK_STOCK_FILE - STOCK_FIND Stock = C.GTK_STOCK_FIND - STOCK_FIND_AND_REPLACE Stock = C.GTK_STOCK_FIND_AND_REPLACE - STOCK_FLOPPY Stock = C.GTK_STOCK_FLOPPY - STOCK_FULLSCREEN Stock = C.GTK_STOCK_FULLSCREEN - STOCK_GOTO_BOTTOM Stock = C.GTK_STOCK_GOTO_BOTTOM - STOCK_GOTO_FIRST Stock = C.GTK_STOCK_GOTO_FIRST - STOCK_GOTO_LAST Stock = C.GTK_STOCK_GOTO_LAST - STOCK_GOTO_TOP Stock = C.GTK_STOCK_GOTO_TOP - STOCK_GO_BACK Stock = C.GTK_STOCK_GO_BACK - STOCK_GO_DOWN Stock = C.GTK_STOCK_GO_DOWN - STOCK_GO_FORWARD Stock = C.GTK_STOCK_GO_FORWARD - STOCK_GO_UP Stock = C.GTK_STOCK_GO_UP - STOCK_HARDDISK Stock = C.GTK_STOCK_HARDDISK - STOCK_HELP Stock = C.GTK_STOCK_HELP - STOCK_HOME Stock = C.GTK_STOCK_HOME - STOCK_INDEX Stock = C.GTK_STOCK_INDEX - STOCK_INDENT Stock = C.GTK_STOCK_INDENT - STOCK_INFO Stock = C.GTK_STOCK_INFO - STOCK_ITALIC Stock = C.GTK_STOCK_ITALIC - STOCK_JUMP_TO Stock = C.GTK_STOCK_JUMP_TO - STOCK_JUSTIFY_CENTER Stock = C.GTK_STOCK_JUSTIFY_CENTER - STOCK_JUSTIFY_FILL Stock = C.GTK_STOCK_JUSTIFY_FILL - STOCK_JUSTIFY_LEFT Stock = C.GTK_STOCK_JUSTIFY_LEFT - STOCK_JUSTIFY_RIGHT Stock = C.GTK_STOCK_JUSTIFY_RIGHT - STOCK_LEAVE_FULLSCREEN Stock = C.GTK_STOCK_LEAVE_FULLSCREEN - STOCK_MISSING_IMAGE Stock = C.GTK_STOCK_MISSING_IMAGE - STOCK_MEDIA_FORWARD Stock = C.GTK_STOCK_MEDIA_FORWARD - STOCK_MEDIA_NEXT Stock = C.GTK_STOCK_MEDIA_NEXT - STOCK_MEDIA_PAUSE Stock = C.GTK_STOCK_MEDIA_PAUSE - STOCK_MEDIA_PLAY Stock = C.GTK_STOCK_MEDIA_PLAY - STOCK_MEDIA_PREVIOUS Stock = C.GTK_STOCK_MEDIA_PREVIOUS - STOCK_MEDIA_RECORD Stock = C.GTK_STOCK_MEDIA_RECORD - STOCK_MEDIA_REWIND Stock = C.GTK_STOCK_MEDIA_REWIND - STOCK_MEDIA_STOP Stock = C.GTK_STOCK_MEDIA_STOP - STOCK_NETWORK Stock = C.GTK_STOCK_NETWORK - STOCK_NEW Stock = C.GTK_STOCK_NEW - STOCK_NO Stock = C.GTK_STOCK_NO - STOCK_OK Stock = C.GTK_STOCK_OK - STOCK_OPEN Stock = C.GTK_STOCK_OPEN - STOCK_ORIENTATION_PORTRAIT Stock = C.GTK_STOCK_ORIENTATION_PORTRAIT - STOCK_ORIENTATION_LANDSCAPE Stock = C.GTK_STOCK_ORIENTATION_LANDSCAPE - STOCK_ORIENTATION_REVERSE_LANDSCAPE Stock = C.GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE - STOCK_ORIENTATION_REVERSE_PORTRAIT Stock = C.GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT - STOCK_PAGE_SETUP Stock = C.GTK_STOCK_PAGE_SETUP - STOCK_PASTE Stock = C.GTK_STOCK_PASTE - STOCK_PREFERENCES Stock = C.GTK_STOCK_PREFERENCES - STOCK_PRINT Stock = C.GTK_STOCK_PRINT - STOCK_PRINT_ERROR Stock = C.GTK_STOCK_PRINT_ERROR - STOCK_PRINT_PAUSED Stock = C.GTK_STOCK_PRINT_PAUSED - STOCK_PRINT_PREVIEW Stock = C.GTK_STOCK_PRINT_PREVIEW - STOCK_PRINT_REPORT Stock = C.GTK_STOCK_PRINT_REPORT - STOCK_PRINT_WARNING Stock = C.GTK_STOCK_PRINT_WARNING - STOCK_PROPERTIES Stock = C.GTK_STOCK_PROPERTIES - STOCK_QUIT Stock = C.GTK_STOCK_QUIT - STOCK_REDO Stock = C.GTK_STOCK_REDO - STOCK_REFRESH Stock = C.GTK_STOCK_REFRESH - STOCK_REMOVE Stock = C.GTK_STOCK_REMOVE - STOCK_REVERT_TO_SAVED Stock = C.GTK_STOCK_REVERT_TO_SAVED - STOCK_SAVE Stock = C.GTK_STOCK_SAVE - STOCK_SAVE_AS Stock = C.GTK_STOCK_SAVE_AS - STOCK_SELECT_ALL Stock = C.GTK_STOCK_SELECT_ALL - STOCK_SELECT_COLOR Stock = C.GTK_STOCK_SELECT_COLOR - STOCK_SELECT_FONT Stock = C.GTK_STOCK_SELECT_FONT - STOCK_SORT_ASCENDING Stock = C.GTK_STOCK_SORT_ASCENDING - STOCK_SORT_DESCENDING Stock = C.GTK_STOCK_SORT_DESCENDING - STOCK_SPELL_CHECK Stock = C.GTK_STOCK_SPELL_CHECK - STOCK_STOP Stock = C.GTK_STOCK_STOP - STOCK_STRIKETHROUGH Stock = C.GTK_STOCK_STRIKETHROUGH - STOCK_UNDELETE Stock = C.GTK_STOCK_UNDELETE - STOCK_UNDERLINE Stock = C.GTK_STOCK_UNDERLINE - STOCK_UNDO Stock = C.GTK_STOCK_UNDO - STOCK_UNINDENT Stock = C.GTK_STOCK_UNINDENT - STOCK_YES Stock = C.GTK_STOCK_YES - STOCK_ZOOM_100 Stock = C.GTK_STOCK_ZOOM_100 - STOCK_ZOOM_FIT Stock = C.GTK_STOCK_ZOOM_FIT - STOCK_ZOOM_IN Stock = C.GTK_STOCK_ZOOM_IN - STOCK_ZOOM_OUT Stock = C.GTK_STOCK_ZOOM_OUT -) - -// ReshowWithInitialSize is a wrapper around -// gtk_window_reshow_with_initial_size(). -func (v *Window) ReshowWithInitialSize() { - C.gtk_window_reshow_with_initial_size(v.native()) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_12.go b/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_12.go deleted file mode 100644 index bebf416..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_12.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// This file includes wrapers for symbols deprecated beginning with GTK 3.12, -// and should only be included in a build targeted intended to target GTK -// 3.10 or earlier. To target an earlier build build, use the build tag -// gtk_MAJOR_MINOR. For example, to target GTK 3.8, run -// 'go build -tags gtk_3_8'. -// +build gtk_3_6 gtk_3_8 gtk_3_10 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -import "C" -import "unsafe" - -/* - * GtkDialog - */ - -// GetActionArea() is a wrapper around gtk_dialog_get_action_area(). -func (v *Dialog) GetActionArea() (*Widget, error) { - c := C.gtk_dialog_get_action_area(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -/* - * GtkMessageDialog - */ - -// GetImage is a wrapper around gtk_message_dialog_get_image(). -func (v *MessageDialog) GetImage() (*Widget, error) { - c := C.gtk_message_dialog_get_image(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// SetImage is a wrapper around gtk_message_dialog_set_image(). -func (v *MessageDialog) SetImage(image IWidget) { - C.gtk_message_dialog_set_image(v.native(), image.toWidget()) -} - -/* - * GtkWidget - */ - -// GetMarginLeft is a wrapper around gtk_widget_get_margin_left(). -func (v *Widget) GetMarginLeft() int { - c := C.gtk_widget_get_margin_left(v.native()) - return int(c) -} - -// SetMarginLeft is a wrapper around gtk_widget_set_margin_left(). -func (v *Widget) SetMarginLeft(margin int) { - C.gtk_widget_set_margin_left(v.native(), C.gint(margin)) -} - -// GetMarginRight is a wrapper around gtk_widget_get_margin_right(). -func (v *Widget) GetMarginRight() int { - c := C.gtk_widget_get_margin_right(v.native()) - return int(c) -} - -// SetMarginRight is a wrapper around gtk_widget_set_margin_right(). -func (v *Widget) SetMarginRight(margin int) { - C.gtk_widget_set_margin_right(v.native(), C.gint(margin)) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_14.go b/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_14.go deleted file mode 100644 index 9d4a4ae..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_14.go +++ /dev/null @@ -1,423 +0,0 @@ -// +build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -// #include -// #include "gtk_deprecated_since_3_14.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - {glib.Type(C.gtk_alignment_get_type()), marshalAlignment}, - {glib.Type(C.gtk_arrow_get_type()), marshalArrow}, - {glib.Type(C.gtk_misc_get_type()), marshalMisc}, - {glib.Type(C.gtk_status_icon_get_type()), marshalStatusIcon}, - } - glib.RegisterGValueMarshalers(tm) - - //Contribute to casting - for k, v := range map[string]WrapFn{ - "GtkAlignment": wrapAlignment, - "GtkArrow": wrapArrow, - "GtkMisc": wrapMisc, - "GtkStatusIcon": wrapStatusIcon, - } { - WrapMap[k] = v - } -} - -/* - * deprecated since version 3.14 and should not be used in newly-written code - */ - -// ResizeGripIsVisible is a wrapper around -// gtk_window_resize_grip_is_visible(). -func (v *Window) ResizeGripIsVisible() bool { - c := C.gtk_window_resize_grip_is_visible(v.native()) - return gobool(c) -} - -// SetHasResizeGrip is a wrapper around gtk_window_set_has_resize_grip(). -func (v *Window) SetHasResizeGrip(setting bool) { - C.gtk_window_set_has_resize_grip(v.native(), gbool(setting)) -} - -// GetHasResizeGrip is a wrapper around gtk_window_get_has_resize_grip(). -func (v *Window) GetHasResizeGrip() bool { - c := C.gtk_window_get_has_resize_grip(v.native()) - return gobool(c) -} - -// Reparent() is a wrapper around gtk_widget_reparent(). -func (v *Widget) Reparent(newParent IWidget) { - C.gtk_widget_reparent(v.native(), newParent.toWidget()) -} - -// GetPadding is a wrapper around gtk_alignment_get_padding(). -func (v *Alignment) GetPadding() (top, bottom, left, right uint) { - var ctop, cbottom, cleft, cright C.guint - C.gtk_alignment_get_padding(v.native(), &ctop, &cbottom, &cleft, - &cright) - return uint(ctop), uint(cbottom), uint(cleft), uint(cright) -} - -// SetPadding is a wrapper around gtk_alignment_set_padding(). -func (v *Alignment) SetPadding(top, bottom, left, right uint) { - C.gtk_alignment_set_padding(v.native(), C.guint(top), C.guint(bottom), - C.guint(left), C.guint(right)) -} - -// AlignmentNew is a wrapper around gtk_alignment_new(). -func AlignmentNew(xalign, yalign, xscale, yscale float32) (*Alignment, error) { - c := C.gtk_alignment_new(C.gfloat(xalign), C.gfloat(yalign), C.gfloat(xscale), - C.gfloat(yscale)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapAlignment(obj), nil -} - -// Set is a wrapper around gtk_alignment_set(). -func (v *Alignment) Set(xalign, yalign, xscale, yscale float32) { - C.gtk_alignment_set(v.native(), C.gfloat(xalign), C.gfloat(yalign), - C.gfloat(xscale), C.gfloat(yscale)) -} - -/* - * GtkArrow - */ - -// Arrow is a representation of GTK's GtkArrow. -type Arrow struct { - Misc -} - -// ArrowNew is a wrapper around gtk_arrow_new(). -func ArrowNew(arrowType ArrowType, shadowType ShadowType) (*Arrow, error) { - c := C.gtk_arrow_new(C.GtkArrowType(arrowType), - C.GtkShadowType(shadowType)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapArrow(obj), nil -} - -// Set is a wrapper around gtk_arrow_set(). -func (v *Arrow) Set(arrowType ArrowType, shadowType ShadowType) { - C.gtk_arrow_set(v.native(), C.GtkArrowType(arrowType), C.GtkShadowType(shadowType)) -} - -// SetAlignment() is a wrapper around gtk_button_set_alignment(). -func (v *Button) SetAlignment(xalign, yalign float32) { - C.gtk_button_set_alignment(v.native(), (C.gfloat)(xalign), - (C.gfloat)(yalign)) -} - -// GetAlignment() is a wrapper around gtk_button_get_alignment(). -func (v *Button) GetAlignment() (xalign, yalign float32) { - var x, y C.gfloat - C.gtk_button_get_alignment(v.native(), &x, &y) - return float32(x), float32(y) -} - -// SetReallocateRedraws is a wrapper around -// gtk_container_set_reallocate_redraws(). -func (v *Container) SetReallocateRedraws(needsRedraws bool) { - C.gtk_container_set_reallocate_redraws(v.native(), gbool(needsRedraws)) -} - -// GetAlignment is a wrapper around gtk_misc_get_alignment(). -func (v *Misc) GetAlignment() (xAlign, yAlign float32) { - var x, y C.gfloat - C.gtk_misc_get_alignment(v.native(), &x, &y) - return float32(x), float32(y) -} - -// SetAlignment is a wrapper around gtk_misc_set_alignment(). -func (v *Misc) SetAlignment(xAlign, yAlign float32) { - C.gtk_misc_set_alignment(v.native(), C.gfloat(xAlign), C.gfloat(yAlign)) -} - -// GetPadding is a wrapper around gtk_misc_get_padding(). -func (v *Misc) GetPadding() (xpad, ypad int) { - var x, y C.gint - C.gtk_misc_get_padding(v.native(), &x, &y) - return int(x), int(y) -} - -// SetPadding is a wrapper around gtk_misc_set_padding(). -func (v *Misc) SetPadding(xPad, yPad int) { - C.gtk_misc_set_padding(v.native(), C.gint(xPad), C.gint(yPad)) -} - -// SetDoubleBuffered is a wrapper around gtk_widget_set_double_buffered(). -func (v *Widget) SetDoubleBuffered(doubleBuffered bool) { - C.gtk_widget_set_double_buffered(v.native(), gbool(doubleBuffered)) -} - -// GetDoubleBuffered is a wrapper around gtk_widget_get_double_buffered(). -func (v *Widget) GetDoubleBuffered() bool { - c := C.gtk_widget_get_double_buffered(v.native()) - return gobool(c) -} - -/* - * GtkArrow - * deprecated since version 3.14 - */ -// native returns a pointer to the underlying GtkButton. -func (v *Arrow) native() *C.GtkArrow { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkArrow(p) -} - -func marshalArrow(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapArrow(obj), nil -} - -func wrapArrow(obj *glib.Object) *Arrow { - return &Arrow{Misc{Widget{glib.InitiallyUnowned{obj}}}} -} - -/* - * GtkAlignment - * deprecated since version 3.14 - */ - -type Alignment struct { - Bin -} - -// native returns a pointer to the underlying GtkAlignment. -func (v *Alignment) native() *C.GtkAlignment { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkAlignment(p) -} - -func marshalAlignment(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapAlignment(obj), nil -} - -func wrapAlignment(obj *glib.Object) *Alignment { - return &Alignment{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -/* - * GtkStatusIcon - * deprecated since version 3.14 - */ - -// StatusIcon is a representation of GTK's GtkStatusIcon -type StatusIcon struct { - *glib.Object -} - -func marshalStatusIcon(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapStatusIcon(obj), nil -} - -func wrapStatusIcon(obj *glib.Object) *StatusIcon { - return &StatusIcon{obj} -} - -func (v *StatusIcon) native() *C.GtkStatusIcon { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkStatusIcon(p) -} - -// StatusIconNew is a wrapper around gtk_status_icon_new() -func StatusIconNew() (*StatusIcon, error) { - c := C.gtk_status_icon_new() - if c == nil { - return nil, nilPtrErr - } - return wrapStatusIcon(wrapObject(unsafe.Pointer(c))), nil -} - -// StatusIconNewFromFile is a wrapper around gtk_status_icon_new_from_file() -func StatusIconNewFromFile(filename string) (*StatusIcon, error) { - cstr := C.CString(filename) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_status_icon_new_from_file((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapStatusIcon(wrapObject(unsafe.Pointer(c))), nil -} - -// StatusIconNewFromIconName is a wrapper around gtk_status_icon_new_from_name() -func StatusIconNewFromIconName(iconName string) (*StatusIcon, error) { - cstr := C.CString(iconName) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_status_icon_new_from_icon_name((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - return wrapStatusIcon(wrapObject(unsafe.Pointer(c))), nil -} - -// SetFromFile is a wrapper around gtk_status_icon_set_from_file() -func (v *StatusIcon) SetFromFile(filename string) { - cstr := C.CString(filename) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_status_icon_set_from_file(v.native(), (*C.gchar)(cstr)) -} - -// SetFromIconName is a wrapper around gtk_status_icon_set_from_icon_name() -func (v *StatusIcon) SetFromIconName(iconName string) { - cstr := C.CString(iconName) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_status_icon_set_from_icon_name(v.native(), (*C.gchar)(cstr)) -} - -// GetStorageType is a wrapper around gtk_status_icon_get_storage_type() -func (v *StatusIcon) GetStorageType() ImageType { - return (ImageType)(C.gtk_status_icon_get_storage_type(v.native())) -} - -// SetTooltipText is a wrapper around gtk_status_icon_set_tooltip_text() -func (v *StatusIcon) SetTooltipText(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_status_icon_set_tooltip_text(v.native(), (*C.gchar)(cstr)) -} - -// GetTooltipText is a wrapper around gtk_status_icon_get_tooltip_text() -func (v *StatusIcon) GetTooltipText() string { - cstr := (*C.char)(C.gtk_status_icon_get_tooltip_text(v.native())) - defer C.free(unsafe.Pointer(cstr)) - return C.GoString(cstr) -} - -// SetTooltipMarkup is a wrapper around gtk_status_icon_set_tooltip_markup() -func (v *StatusIcon) SetTooltipMarkup(markup string) { - cstr := (*C.gchar)(C.CString(markup)) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_status_icon_set_tooltip_markup(v.native(), cstr) -} - -// GetTooltipMarkup is a wrapper around gtk_status_icon_get_tooltip_markup() -func (v *StatusIcon) GetTooltipMarkup() string { - cstr := (*C.char)(C.gtk_status_icon_get_tooltip_markup(v.native())) - defer C.free(unsafe.Pointer(cstr)) - return C.GoString(cstr) -} - -// SetHasTooltip is a wrapper around gtk_status_icon_set_has_tooltip() -func (v *StatusIcon) SetHasTooltip(hasTooltip bool) { - C.gtk_status_icon_set_has_tooltip(v.native(), gbool(hasTooltip)) -} - -// GetTitle is a wrapper around gtk_status_icon_get_title() -func (v *StatusIcon) GetTitle() string { - cstr := (*C.char)(C.gtk_status_icon_get_title(v.native())) - defer C.free(unsafe.Pointer(cstr)) - return C.GoString(cstr) -} - -// SetName is a wrapper around gtk_status_icon_set_name() -func (v *StatusIcon) SetName(name string) { - cstr := (*C.gchar)(C.CString(name)) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_status_icon_set_name(v.native(), cstr) -} - -// SetVisible is a wrapper around gtk_status_icon_set_visible() -func (v *StatusIcon) SetVisible(visible bool) { - C.gtk_status_icon_set_visible(v.native(), gbool(visible)) -} - -// GetVisible is a wrapper around gtk_status_icon_get_visible() -func (v *StatusIcon) GetVisible() bool { - return gobool(C.gtk_status_icon_get_visible(v.native())) -} - -// IsEmbedded is a wrapper around gtk_status_icon_is_embedded() -func (v *StatusIcon) IsEmbedded() bool { - return gobool(C.gtk_status_icon_is_embedded(v.native())) -} - -// GetX11WindowID is a wrapper around gtk_status_icon_get_x11_window_id() -func (v *StatusIcon) GetX11WindowID() int { - return int(C.gtk_status_icon_get_x11_window_id(v.native())) -} - -// GetHasTooltip is a wrapper around gtk_status_icon_get_has_tooltip() -func (v *StatusIcon) GetHasTooltip() bool { - return gobool(C.gtk_status_icon_get_has_tooltip(v.native())) -} - -// SetTitle is a wrapper around gtk_status_icon_set_title() -func (v *StatusIcon) SetTitle(title string) { - cstr := (*C.gchar)(C.CString(title)) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_status_icon_set_title(v.native(), cstr) -} - -// GetIconName is a wrapper around gtk_status_icon_get_icon_name() -func (v *StatusIcon) GetIconName() string { - cstr := (*C.char)(C.gtk_status_icon_get_icon_name(v.native())) - defer C.free(unsafe.Pointer(cstr)) - return C.GoString(cstr) -} - -// GetSize is a wrapper around gtk_status_icon_get_size() -func (v *StatusIcon) GetSize() int { - return int(C.gtk_status_icon_get_size(v.native())) -} - -/* - * GtkMisc - */ - -// Misc is a representation of GTK's GtkMisc. -type Misc struct { - Widget -} - -// native returns a pointer to the underlying GtkMisc. -func (v *Misc) native() *C.GtkMisc { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkMisc(p) -} - -func marshalMisc(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapMisc(obj), nil -} - -func wrapMisc(obj *glib.Object) *Misc { - return &Misc{Widget{glib.InitiallyUnowned{obj}}} -} - -/* - * End deprecated since version 3.14 - */ diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_14.go.h b/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_14.go.h deleted file mode 100644 index fa30e9a..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_14.go.h +++ /dev/null @@ -1,30 +0,0 @@ - -static GtkStatusIcon * -toGtkStatusIcon(void *p) -{ - return (GTK_STATUS_ICON(p)); -} - -/* - * deprecated since version 3.14 - */ -static GtkAlignment * -toGtkAlignment(void *p) -{ - return (GTK_ALIGNMENT(p)); -} - -static GtkArrow * -toGtkArrow(void *p) -{ - return (GTK_ARROW(p)); -} - -static GtkMisc * -toGtkMisc(void *p) -{ - return (GTK_MISC(p)); -} -/* - * End deprecated since version 3.14 - */ diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_16.go b/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_16.go deleted file mode 100644 index 6f4e994..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_deprecated_since_3_16.go +++ /dev/null @@ -1,31 +0,0 @@ -//+build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -// #include -import "C" - -import ( - "unsafe" - - "github.com/gotk3/gotk3/gdk" -) - -// OverrideColor is a wrapper around gtk_widget_override_color(). -func (v *Widget) OverrideColor(state StateFlags, color *gdk.RGBA) { - var cColor *C.GdkRGBA - if color != nil { - cColor = (*C.GdkRGBA)(unsafe.Pointer(color.Native())) - } - C.gtk_widget_override_color(v.native(), C.GtkStateFlags(state), cColor) -} - -// OverrideFont is a wrapper around gtk_widget_override_font(). -func (v *Widget) OverrideFont(description string) { - cstr := C.CString(description) - defer C.free(unsafe.Pointer(cstr)) - c := C.pango_font_description_from_string(cstr) - C.gtk_widget_override_font(v.native(), c) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_export.go b/vendor/github.com/gotk3/gotk3.old/gtk/gtk_export.go deleted file mode 100644 index cf3e3c4..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_export.go +++ /dev/null @@ -1,44 +0,0 @@ -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -//export goBuilderConnect -func goBuilderConnect(builder *C.GtkBuilder, - object *C.GObject, - signal_name *C.gchar, - handler_name *C.gchar, - connect_object *C.GObject, - flags C.GConnectFlags, - user_data C.gpointer) { - - builderSignals.Lock() - signals, ok := builderSignals.m[builder] - builderSignals.Unlock() - - if !ok { - panic("no signal mapping defined for this GtkBuilder") - } - - h := C.GoString((*C.char)(handler_name)) - s := C.GoString((*C.char)(signal_name)) - - handler, ok := signals[h] - if !ok { - return - } - - if object == nil { - panic("unexpected nil object from builder") - } - - //TODO: figure out a better way to get a glib.Object from a *C.GObject - gobj := glib.Object{glib.ToGObject(unsafe.Pointer(object))} - gobj.Connect(s, handler) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_since_3_10.go b/vendor/github.com/gotk3/gotk3.old/gtk/gtk_since_3_10.go deleted file mode 100644 index 99ded8b..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_since_3_10.go +++ /dev/null @@ -1,693 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains accelerator related functions and structures - -// +build !gtk_3_6,!gtk_3_8 -// not use this: go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.10 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -// #include -// #include "gtk_since_3_10.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/gdk" - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - // Enums - {glib.Type(C.gtk_revealer_transition_type_get_type()), marshalRevealerTransitionType}, - {glib.Type(C.gtk_stack_transition_type_get_type()), marshalStackTransitionType}, - - // Objects/Interfaces - {glib.Type(C.gtk_header_bar_get_type()), marshalHeaderBar}, - {glib.Type(C.gtk_list_box_get_type()), marshalListBox}, - {glib.Type(C.gtk_list_box_row_get_type()), marshalListBoxRow}, - {glib.Type(C.gtk_revealer_get_type()), marshalRevealer}, - {glib.Type(C.gtk_search_bar_get_type()), marshalSearchBar}, - {glib.Type(C.gtk_stack_get_type()), marshalStack}, - {glib.Type(C.gtk_stack_switcher_get_type()), marshalStackSwitcher}, - } - glib.RegisterGValueMarshalers(tm) - - //Contribute to casting - for k, v := range map[string]WrapFn{ - "GtkHeaderBar": wrapHeaderBar, - "GtkListBox": wrapListBox, - "GtkListBoxRow": wrapListBoxRow, - "GtkRevealer": wrapRevealer, - "GtkSearchBar": wrapSearchBar, - "GtkStack": wrapStack, - } { - WrapMap[k] = v - } -} - -/* - * Constants - */ - -const ( - ALIGN_BASELINE Align = C.GTK_ALIGN_BASELINE -) - -// RevealerTransitionType is a representation of GTK's GtkRevealerTransitionType. -type RevealerTransitionType int - -const ( - REVEALER_TRANSITION_TYPE_NONE RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_NONE - REVEALER_TRANSITION_TYPE_CROSSFADE RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_CROSSFADE - REVEALER_TRANSITION_TYPE_SLIDE_RIGHT RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT - REVEALER_TRANSITION_TYPE_SLIDE_LEFT RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT - REVEALER_TRANSITION_TYPE_SLIDE_UP RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP - REVEALER_TRANSITION_TYPE_SLIDE_DOWN RevealerTransitionType = C.GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN -) - -func marshalRevealerTransitionType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return RevealerTransitionType(c), nil -} - -// StackTransitionType is a representation of GTK's GtkStackTransitionType. -type StackTransitionType int - -const ( - STACK_TRANSITION_TYPE_NONE StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_NONE - STACK_TRANSITION_TYPE_CROSSFADE StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_CROSSFADE - STACK_TRANSITION_TYPE_SLIDE_RIGHT StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT - STACK_TRANSITION_TYPE_SLIDE_LEFT StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT - STACK_TRANSITION_TYPE_SLIDE_UP StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_UP - STACK_TRANSITION_TYPE_SLIDE_DOWN StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN - STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT - STACK_TRANSITION_TYPE_SLIDE_UP_DOWN StackTransitionType = C.GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN -) - -func marshalStackTransitionType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return StackTransitionType(c), nil -} - -/* - * GtkButton - */ - -// ButtonNewFromIconName is a wrapper around gtk_button_new_from_icon_name(). -func ButtonNewFromIconName(iconName string, size IconSize) (*Button, error) { - cstr := C.CString(iconName) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_button_new_from_icon_name((*C.gchar)(cstr), - C.GtkIconSize(size)) - if c == nil { - return nil, nilPtrErr - } - return wrapButton(wrapObject(unsafe.Pointer(c))), nil -} - -/* - * GtkHeaderBar - */ - -type HeaderBar struct { - Container -} - -// native returns a pointer to the underlying GtkHeaderBar. -func (v *HeaderBar) native() *C.GtkHeaderBar { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkHeaderBar(p) -} - -func marshalHeaderBar(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapHeaderBar(obj), nil -} - -func wrapHeaderBar(obj *glib.Object) *HeaderBar { - return &HeaderBar{Container{Widget{glib.InitiallyUnowned{obj}}}} -} - -// HeaderBarNew is a wrapper around gtk_header_bar_new(). -func HeaderBarNew() (*HeaderBar, error) { - c := C.gtk_header_bar_new() - if c == nil { - return nil, nilPtrErr - } - return wrapHeaderBar(wrapObject(unsafe.Pointer(c))), nil -} - -// SetTitle is a wrapper around gtk_header_bar_set_title(). -func (v *HeaderBar) SetTitle(title string) { - cstr := C.CString(title) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_header_bar_set_title(v.native(), (*C.gchar)(cstr)) -} - -// GetTitle is a wrapper around gtk_header_bar_get_title(). -func (v *HeaderBar) GetTitle() string { - cstr := C.gtk_header_bar_get_title(v.native()) - return C.GoString((*C.char)(cstr)) -} - -// SetSubtitle is a wrapper around gtk_header_bar_set_subtitle(). -func (v *HeaderBar) SetSubtitle(subtitle string) { - cstr := C.CString(subtitle) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_header_bar_set_subtitle(v.native(), (*C.gchar)(cstr)) -} - -// GetSubtitle is a wrapper around gtk_header_bar_get_subtitle(). -func (v *HeaderBar) GetSubtitle() string { - cstr := C.gtk_header_bar_get_subtitle(v.native()) - return C.GoString((*C.char)(cstr)) -} - -// SetCustomTitle is a wrapper around gtk_header_bar_set_custom_title(). -func (v *HeaderBar) SetCustomTitle(titleWidget IWidget) { - C.gtk_header_bar_set_custom_title(v.native(), titleWidget.toWidget()) -} - -// GetCustomTitle is a wrapper around gtk_header_bar_get_custom_title(). -func (v *HeaderBar) GetCustomTitle() (*Widget, error) { - c := C.gtk_header_bar_get_custom_title(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// PackStart is a wrapper around gtk_header_bar_pack_start(). -func (v *HeaderBar) PackStart(child IWidget) { - C.gtk_header_bar_pack_start(v.native(), child.toWidget()) -} - -// PackEnd is a wrapper around gtk_header_bar_pack_end(). -func (v *HeaderBar) PackEnd(child IWidget) { - C.gtk_header_bar_pack_end(v.native(), child.toWidget()) -} - -// SetShowCloseButton is a wrapper around gtk_header_bar_set_show_close_button(). -func (v *HeaderBar) SetShowCloseButton(setting bool) { - C.gtk_header_bar_set_show_close_button(v.native(), gbool(setting)) -} - -// GetShowCloseButton is a wrapper around gtk_header_bar_get_show_close_button(). -func (v *HeaderBar) GetShowCloseButton() bool { - c := C.gtk_header_bar_get_show_close_button(v.native()) - return gobool(c) -} - -/* - * GtkLabel - */ - -// GetLines() is a wrapper around gtk_label_get_lines(). -func (v *Label) GetLines() int { - c := C.gtk_label_get_lines(v.native()) - return int(c) -} - -// SetLines() is a wrapper around gtk_label_set_lines(). -func (v *Label) SetLines(lines int) { - C.gtk_label_set_lines(v.native(), C.gint(lines)) -} - -/* - * GtkListBox - */ - -// ListBox is a representation of GTK's GtkListBox. -type ListBox struct { - Container -} - -// native returns a pointer to the underlying GtkListBox. -func (v *ListBox) native() *C.GtkListBox { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkListBox(p) -} - -func marshalListBox(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapListBox(obj), nil -} - -func wrapListBox(obj *glib.Object) *ListBox { - return &ListBox{Container{Widget{glib.InitiallyUnowned{obj}}}} -} - -// ListBoxNew is a wrapper around gtk_list_box_new(). -func ListBoxNew() (*ListBox, error) { - c := C.gtk_list_box_new() - if c == nil { - return nil, nilPtrErr - } - return wrapListBox(wrapObject(unsafe.Pointer(c))), nil -} - -// Prepend is a wrapper around gtk_list_box_prepend(). -func (v *ListBox) Prepend(child IWidget) { - C.gtk_list_box_prepend(v.native(), child.toWidget()) -} - -// Insert is a wrapper around gtk_list_box_insert(). -func (v *ListBox) Insert(child IWidget, position int) { - C.gtk_list_box_insert(v.native(), child.toWidget(), C.gint(position)) -} - -// SelectRow is a wrapper around gtk_list_box_select_row(). -func (v *ListBox) SelectRow(row *ListBoxRow) { - C.gtk_list_box_select_row(v.native(), row.native()) -} - -// GetSelectedRow is a wrapper around gtk_list_box_get_selected_row(). -func (v *ListBox) GetSelectedRow() *ListBoxRow { - c := C.gtk_list_box_get_selected_row(v.native()) - if c == nil { - return nil - } - return wrapListBoxRow(wrapObject(unsafe.Pointer(c))) -} - -// SetSelectionMode is a wrapper around gtk_list_box_set_selection_mode(). -func (v *ListBox) SetSelectionMode(mode SelectionMode) { - C.gtk_list_box_set_selection_mode(v.native(), C.GtkSelectionMode(mode)) -} - -// GetSelectionMode is a wrapper around gtk_list_box_get_selection_mode() -func (v *ListBox) GetSelectionMode() SelectionMode { - c := C.gtk_list_box_get_selection_mode(v.native()) - return SelectionMode(c) -} - -// SetActivateOnSingleClick is a wrapper around gtk_list_box_set_activate_on_single_click(). -func (v *ListBox) SetActivateOnSingleClick(single bool) { - C.gtk_list_box_set_activate_on_single_click(v.native(), gbool(single)) -} - -// GetActivateOnSingleClick is a wrapper around gtk_list_box_get_activate_on_single_click(). -func (v *ListBox) GetActivateOnSingleClick() bool { - c := C.gtk_list_box_get_activate_on_single_click(v.native()) - return gobool(c) -} - -// GetAdjustment is a wrapper around gtk_list_box_get_adjustment(). -func (v *ListBox) GetAdjustment() *Adjustment { - c := C.gtk_list_box_get_adjustment(v.native()) - obj := wrapObject(unsafe.Pointer(c)) - return &Adjustment{glib.InitiallyUnowned{obj}} -} - -// SetAdjustment is a wrapper around gtk_list_box_set_adjustment(). -func (v *ListBox) SetAdjuctment(adjustment *Adjustment) { - C.gtk_list_box_set_adjustment(v.native(), adjustment.native()) -} - -// SetPlaceholder is a wrapper around gtk_list_box_set_placeholder(). -func (v *ListBox) SetPlaceholder(placeholder IWidget) { - C.gtk_list_box_set_placeholder(v.native(), placeholder.toWidget()) -} - -// GetRowAtIndex is a wrapper around gtk_list_box_get_row_at_index(). -func (v *ListBox) GetRowAtIndex(index int) *ListBoxRow { - c := C.gtk_list_box_get_row_at_index(v.native(), C.gint(index)) - if c == nil { - return nil - } - return wrapListBoxRow(wrapObject(unsafe.Pointer(c))) -} - -// GetRowAtY is a wrapper around gtk_list_box_get_row_at_y(). -func (v *ListBox) GetRowAtY(y int) *ListBoxRow { - c := C.gtk_list_box_get_row_at_y(v.native(), C.gint(y)) - if c == nil { - return nil - } - return wrapListBoxRow(wrapObject(unsafe.Pointer(c))) -} - -// InvalidateFilter is a wrapper around gtk_list_box_invalidate_filter(). -func (v *ListBox) InvalidateFilter() { - C.gtk_list_box_invalidate_filter(v.native()) -} - -// InvalidateHeaders is a wrapper around gtk_list_box_invalidate_headers(). -func (v *ListBox) InvalidateHeaders() { - C.gtk_list_box_invalidate_headers(v.native()) -} - -// InvalidateSort is a wrapper around gtk_list_box_invalidate_sort(). -func (v *ListBox) InvalidateSort() { - C.gtk_list_box_invalidate_sort(v.native()) -} - -// TODO: SetFilterFunc -// TODO: SetHeaderFunc -// TODO: SetSortFunc - -// DragHighlightRow is a wrapper around gtk_list_box_drag_highlight_row() -func (v *ListBox) DragHighlightRow(row *ListBoxRow) { - C.gtk_list_box_drag_highlight_row(v.native(), row.native()) -} - -/* - * GtkListBoxRow - */ - -// ListBoxRow is a representation of GTK's GtkListBoxRow. -type ListBoxRow struct { - Bin -} - -// native returns a pointer to the underlying GtkListBoxRow. -func (v *ListBoxRow) native() *C.GtkListBoxRow { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkListBoxRow(p) -} - -func marshalListBoxRow(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapListBoxRow(obj), nil -} - -func wrapListBoxRow(obj *glib.Object) *ListBoxRow { - return &ListBoxRow{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -func ListBoxRowNew() (*ListBoxRow, error) { - c := C.gtk_list_box_row_new() - if c == nil { - return nil, nilPtrErr - } - return wrapListBoxRow(wrapObject(unsafe.Pointer(c))), nil -} - -// Changed is a wrapper around gtk_list_box_row_changed(). -func (v *ListBoxRow) Changed() { - C.gtk_list_box_row_changed(v.native()) -} - -// GetHeader is a wrapper around gtk_list_box_row_get_header(). -func (v *ListBoxRow) GetHeader() *Widget { - c := C.gtk_list_box_row_get_header(v.native()) - if c == nil { - return nil - } - return wrapWidget(wrapObject(unsafe.Pointer(c))) -} - -// SetHeader is a wrapper around gtk_list_box_row_get_header(). -func (v *ListBoxRow) SetHeader(header IWidget) { - C.gtk_list_box_row_set_header(v.native(), header.toWidget()) -} - -// GetIndex is a wrapper around gtk_list_box_row_get_index() -func (v *ListBoxRow) GetIndex() int { - c := C.gtk_list_box_row_get_index(v.native()) - return int(c) -} - -/* - * GtkRevealer - */ - -// Revealer is a representation of GTK's GtkRevealer -type Revealer struct { - Bin -} - -// native returns a pointer to the underlying GtkRevealer. -func (v *Revealer) native() *C.GtkRevealer { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkRevealer(p) -} - -func marshalRevealer(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapRevealer(obj), nil -} - -func wrapRevealer(obj *glib.Object) *Revealer { - return &Revealer{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// RevealerNew is a wrapper around gtk_revealer_new() -func RevealerNew() (*Revealer, error) { - c := C.gtk_revealer_new() - if c == nil { - return nil, nilPtrErr - } - return wrapRevealer(wrapObject(unsafe.Pointer(c))), nil -} - -// GetRevealChild is a wrapper around gtk_revealer_get_reveal_child(). -func (v *Revealer) GetRevealChild() bool { - c := C.gtk_revealer_get_reveal_child(v.native()) - return gobool(c) -} - -// SetRevealChild is a wrapper around gtk_revealer_set_reveal_child(). -func (v *Revealer) SetRevealChild(revealChild bool) { - C.gtk_revealer_set_reveal_child(v.native(), gbool(revealChild)) -} - -// GetChildRevealed is a wrapper around gtk_revealer_get_child_revealed(). -func (v *Revealer) GetChildRevealed() bool { - c := C.gtk_revealer_get_child_revealed(v.native()) - return gobool(c) -} - -// GetTransitionDuration is a wrapper around gtk_revealer_get_transition_duration() -func (v *Revealer) GetTransitionDuration() uint { - c := C.gtk_revealer_get_transition_duration(v.native()) - return uint(c) -} - -// SetTransitionDuration is a wrapper around gtk_revealer_set_transition_duration(). -func (v *Revealer) SetTransitionDuration(duration uint) { - C.gtk_revealer_set_transition_duration(v.native(), C.guint(duration)) -} - -// GetTransitionType is a wrapper around gtk_revealer_get_transition_type() -func (v *Revealer) GetTransitionType() RevealerTransitionType { - c := C.gtk_revealer_get_transition_type(v.native()) - return RevealerTransitionType(c) -} - -// SetTransitionType is a wrapper around gtk_revealer_set_transition_type() -func (v *Revealer) SetTransitionType(transition RevealerTransitionType) { - t := C.GtkRevealerTransitionType(transition) - C.gtk_revealer_set_transition_type(v.native(), t) -} - -/* - * GtkSearchBar - */ - -// SearchBar is a representation of GTK's GtkSearchBar. -type SearchBar struct { - Bin -} - -// native returns a pointer to the underlying GtkSearchBar. -func (v *SearchBar) native() *C.GtkSearchBar { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkSearchBar(p) -} - -func marshalSearchBar(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapSearchBar(obj), nil -} - -func wrapSearchBar(obj *glib.Object) *SearchBar { - return &SearchBar{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// SearchBarNew is a wrapper around gtk_search_bar_new() -func SearchBarNew() (*SearchBar, error) { - c := C.gtk_search_bar_new() - if c == nil { - return nil, nilPtrErr - } - return wrapSearchBar(wrapObject(unsafe.Pointer(c))), nil -} - -// ConnectEntry is a wrapper around gtk_search_bar_connect_entry(). -func (v *SearchBar) ConnectEntry(entry IEntry) { - C.gtk_search_bar_connect_entry(v.native(), entry.toEntry()) -} - -// GetSearchMode is a wrapper around gtk_search_bar_get_search_mode(). -func (v *SearchBar) GetSearchMode() bool { - c := C.gtk_search_bar_get_search_mode(v.native()) - return gobool(c) -} - -// SetSearchMode is a wrapper around gtk_search_bar_set_search_mode(). -func (v *SearchBar) SetSearchMode(searchMode bool) { - C.gtk_search_bar_set_search_mode(v.native(), gbool(searchMode)) -} - -// GetShowCloseButton is a wrapper arounb gtk_search_bar_get_show_close_button(). -func (v *SearchBar) GetShowCloseButton() bool { - c := C.gtk_search_bar_get_show_close_button(v.native()) - return gobool(c) -} - -// SetShowCloseButton is a wrapper around gtk_search_bar_set_show_close_button() -func (v *SearchBar) SetShowCloseButton(visible bool) { - C.gtk_search_bar_set_show_close_button(v.native(), gbool(visible)) -} - -// HandleEvent is a wrapper around gtk_search_bar_handle_event() -func (v *SearchBar) HandleEvent(event *gdk.Event) { - e := (*C.GdkEvent)(unsafe.Pointer(event.Native())) - C.gtk_search_bar_handle_event(v.native(), e) -} - -/* - * GtkStack - */ - -// Stack is a representation of GTK's GtkStack. -type Stack struct { - Container -} - -// native returns a pointer to the underlying GtkStack. -func (v *Stack) native() *C.GtkStack { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkStack(p) -} - -func marshalStack(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapStack(obj), nil -} - -func wrapStack(obj *glib.Object) *Stack { - return &Stack{Container{Widget{glib.InitiallyUnowned{obj}}}} -} - -// StackNew is a wrapper around gtk_stack_new(). -func StackNew() (*Stack, error) { - c := C.gtk_stack_new() - if c == nil { - return nil, nilPtrErr - } - return wrapStack(wrapObject(unsafe.Pointer(c))), nil -} - -// AddNamed is a wrapper around gtk_stack_add_named(). -func (v *Stack) AddNamed(child IWidget, name string) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_stack_add_named(v.native(), child.toWidget(), (*C.gchar)(cstr)) -} - -// AddTitled is a wrapper around gtk_stack_add_titled(). -func (v *Stack) AddTitled(child IWidget, name, title string) { - cName := C.CString(name) - defer C.free(unsafe.Pointer(cName)) - cTitle := C.CString(title) - defer C.free(unsafe.Pointer(cTitle)) - C.gtk_stack_add_titled(v.native(), child.toWidget(), (*C.gchar)(cName), - (*C.gchar)(cTitle)) -} - -// SetVisibleChild is a wrapper around gtk_stack_set_visible_child(). -func (v *Stack) SetVisibleChild(child IWidget) { - C.gtk_stack_set_visible_child(v.native(), child.toWidget()) -} - -// GetVisibleChild is a wrapper around gtk_stack_get_visible_child(). -func (v *Stack) GetVisibleChild() *Widget { - c := C.gtk_stack_get_visible_child(v.native()) - if c == nil { - return nil - } - return wrapWidget(wrapObject(unsafe.Pointer(c))) -} - -// SetVisibleChildName is a wrapper around gtk_stack_set_visible_child_name(). -func (v *Stack) SetVisibleChildName(name string) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_stack_set_visible_child_name(v.native(), (*C.gchar)(cstr)) -} - -// GetVisibleChildName is a wrapper around gtk_stack_get_visible_child_name(). -func (v *Stack) GetVisibleChildName() string { - c := C.gtk_stack_get_visible_child_name(v.native()) - return C.GoString((*C.char)(c)) -} - -// SetVisibleChildFull is a wrapper around gtk_stack_set_visible_child_full(). -func (v *Stack) SetVisibleChildFull(name string, transaction StackTransitionType) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_stack_set_visible_child_full(v.native(), (*C.gchar)(cstr), - C.GtkStackTransitionType(transaction)) -} - -// SetHomogeneous is a wrapper around gtk_stack_set_homogeneous(). -func (v *Stack) SetHomogeneous(homogeneous bool) { - C.gtk_stack_set_homogeneous(v.native(), gbool(homogeneous)) -} - -// GetHomogeneous is a wrapper around gtk_stack_get_homogeneous(). -func (v *Stack) GetHomogeneous() bool { - c := C.gtk_stack_get_homogeneous(v.native()) - return gobool(c) -} - -// SetTransitionDuration is a wrapper around gtk_stack_set_transition_duration(). -func (v *Stack) SetTransitionDuration(duration uint) { - C.gtk_stack_set_transition_duration(v.native(), C.guint(duration)) -} - -// GetTransitionDuration is a wrapper around gtk_stack_get_transition_duration(). -func (v *Stack) GetTransitionDuration() uint { - c := C.gtk_stack_get_transition_duration(v.native()) - return uint(c) -} - -// SetTransitionType is a wrapper around gtk_stack_set_transition_type(). -func (v *Stack) SetTransitionType(transition StackTransitionType) { - C.gtk_stack_set_transition_type(v.native(), C.GtkStackTransitionType(transition)) -} - -// GetTransitionType is a wrapper around gtk_stack_get_transition_type(). -func (v *Stack) GetTransitionType() StackTransitionType { - c := C.gtk_stack_get_transition_type(v.native()) - return StackTransitionType(c) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_since_3_10.go.h b/vendor/github.com/gotk3/gotk3.old/gtk/gtk_since_3_10.go.h deleted file mode 100644 index 724b223..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_since_3_10.go.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2013-2014 Conformal Systems - * - * This file originated from: http://opensource.conformal.com/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -static GtkHeaderBar * -toGtkHeaderBar(void *p) -{ - return (GTK_HEADER_BAR(p)); -} - -static GtkListBox * -toGtkListBox(void *p) -{ - return (GTK_LIST_BOX(p)); -} - -static GtkListBoxRow * -toGtkListBoxRow(void *p) -{ - return (GTK_LIST_BOX_ROW(p)); -} - -static GtkRevealer * -toGtkRevealer(void *p) -{ - return (GTK_REVEALER(p)); -} - -static GtkSearchBar * -toGtkSearchBar(void *p) -{ - return (GTK_SEARCH_BAR(p)); -} - -static GtkStack * -toGtkStack(void *p) -{ - return (GTK_STACK(p)); -} - -static GtkStackSwitcher * -toGtkStackSwitcher(void *p) -{ - return (GTK_STACK_SWITCHER(p)); -} - - \ No newline at end of file diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_since_3_8.go b/vendor/github.com/gotk3/gotk3.old/gtk/gtk_since_3_8.go deleted file mode 100644 index 1c3d97f..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/gtk_since_3_8.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// This file includes wrapers for symbols included since GTK 3.8, and -// and should not be included in a build intended to target any older GTK -// versions. To target an older build, such as 3.8, use -// 'go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.18 -// is assumed and this file is built. -// +build !gtk_3_6 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -import "C" - -/* - * Constants - */ - -const ( - STATE_FLAG_DIR_LTR StateFlags = C.GTK_STATE_FLAG_DIR_LTR - STATE_FLAG_DIR_RTL StateFlags = C.GTK_STATE_FLAG_DIR_RTL -) diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/info_bar.go b/vendor/github.com/gotk3/gotk3.old/gtk/info_bar.go deleted file mode 100644 index f6aa336..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/info_bar.go +++ /dev/null @@ -1,106 +0,0 @@ -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - {glib.Type(C.gtk_info_bar_get_type()), marshalInfoBar}, - } - - glib.RegisterGValueMarshalers(tm) - - WrapMap["GtkInfoBar"] = wrapInfoBar -} - -type InfoBar struct { - Box -} - -func (v *InfoBar) native() *C.GtkInfoBar { - if v == nil || v.GObject == nil { - return nil - } - - p := unsafe.Pointer(v.GObject) - return C.toGtkInfoBar(p) -} - -func marshalInfoBar(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapInfoBar(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapInfoBar(obj *glib.Object) *InfoBar { - return &InfoBar{Box{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -func InfoBarNew() (*InfoBar, error) { - c := C.gtk_info_bar_new() - if c == nil { - return nil, nilPtrErr - } - - return wrapInfoBar(wrapObject(unsafe.Pointer(c))), nil -} - -func (v *InfoBar) AddActionWidget(w IWidget, responseId ResponseType) { - C.gtk_info_bar_add_action_widget(v.native(), w.toWidget(), C.gint(responseId)) -} - -func (v *InfoBar) AddButton(buttonText string, responseId ResponseType) { - cstr := C.CString(buttonText) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_info_bar_add_button(v.native(), (*C.gchar)(cstr), C.gint(responseId)) -} - -func (v *InfoBar) SetResponseSensitive(responseId ResponseType, setting bool) { - C.gtk_info_bar_set_response_sensitive(v.native(), C.gint(responseId), gbool(setting)) -} - -func (v *InfoBar) SetDefaultResponse(responseId ResponseType) { - C.gtk_info_bar_set_default_response(v.native(), C.gint(responseId)) -} - -func (v *InfoBar) SetMessageType(messageType MessageType) { - C.gtk_info_bar_set_message_type(v.native(), C.GtkMessageType(messageType)) -} - -func (v *InfoBar) GetMessageType() MessageType { - messageType := C.gtk_info_bar_get_message_type(v.native()) - return MessageType(messageType) -} - -func (v *InfoBar) GetActionArea() (*Widget, error) { - c := C.gtk_info_bar_get_action_area(v.native()) - if c == nil { - return nil, nilPtrErr - } - - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -func (v *InfoBar) GetContentArea() (*Box, error) { - c := C.gtk_info_bar_get_content_area(v.native()) - if c == nil { - return nil, nilPtrErr - } - - return wrapBox(wrapObject(unsafe.Pointer(c))), nil -} - -func (v *InfoBar) GetShowCloseButton() bool { - b := C.gtk_info_bar_get_show_close_button(v.native()) - return gobool(b) -} - -func (v *InfoBar) SetShowCloseButton(setting bool) { - C.gtk_info_bar_set_show_close_button(v.native(), gbool(setting)) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/label.go b/vendor/github.com/gotk3/gotk3.old/gtk/label.go deleted file mode 100644 index c89a7a7..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/label.go +++ /dev/null @@ -1,266 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains style related functions and structures - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/pango" - - "github.com/gotk3/gotk3/glib" -) - -/* - * GtkLabel - */ - -// Label is a representation of GTK's GtkLabel. -type Label struct { - Widget -} - -// native returns a pointer to the underlying GtkLabel. -func (v *Label) native() *C.GtkLabel { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkLabel(p) -} - -func marshalLabel(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapLabel(obj), nil -} - -func wrapLabel(obj *glib.Object) *Label { - return &Label{Widget{glib.InitiallyUnowned{obj}}} -} - -// LabelNew is a wrapper around gtk_label_new(). -func LabelNew(str string) (*Label, error) { - cstr := C.CString(str) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_label_new((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapLabel(obj), nil -} - -// SetText is a wrapper around gtk_label_set_text(). -func (v *Label) SetText(str string) { - cstr := C.CString(str) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_label_set_text(v.native(), (*C.gchar)(cstr)) -} - -// SetMarkup is a wrapper around gtk_label_set_markup(). -func (v *Label) SetMarkup(str string) { - cstr := C.CString(str) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_label_set_markup(v.native(), (*C.gchar)(cstr)) -} - -// SetMarkupWithMnemonic is a wrapper around -// gtk_label_set_markup_with_mnemonic(). -func (v *Label) SetMarkupWithMnemonic(str string) { - cstr := C.CString(str) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_label_set_markup_with_mnemonic(v.native(), (*C.gchar)(cstr)) -} - -// SetPattern is a wrapper around gtk_label_set_pattern(). -func (v *Label) SetPattern(patern string) { - cstr := C.CString(patern) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_label_set_pattern(v.native(), (*C.gchar)(cstr)) -} - -// SetJustify is a wrapper around gtk_label_set_justify(). -func (v *Label) SetJustify(jtype Justification) { - C.gtk_label_set_justify(v.native(), C.GtkJustification(jtype)) -} - -// SetEllipsize is a wrapper around gtk_label_set_ellipsize(). -func (v *Label) SetEllipsize(mode pango.EllipsizeMode) { - C.gtk_label_set_ellipsize(v.native(), C.PangoEllipsizeMode(mode)) -} - -// GetWidthChars is a wrapper around gtk_label_get_width_chars(). -func (v *Label) GetWidthChars() int { - c := C.gtk_label_get_width_chars(v.native()) - return int(c) -} - -// SetWidthChars is a wrapper around gtk_label_set_width_chars(). -func (v *Label) SetWidthChars(nChars int) { - C.gtk_label_set_width_chars(v.native(), C.gint(nChars)) -} - -// GetMaxWidthChars is a wrapper around gtk_label_get_max_width_chars(). -func (v *Label) GetMaxWidthChars() int { - c := C.gtk_label_get_max_width_chars(v.native()) - return int(c) -} - -// SetMaxWidthChars is a wrapper around gtk_label_set_max_width_chars(). -func (v *Label) SetMaxWidthChars(nChars int) { - C.gtk_label_set_max_width_chars(v.native(), C.gint(nChars)) -} - -// GetLineWrap is a wrapper around gtk_label_get_line_wrap(). -func (v *Label) GetLineWrap() bool { - c := C.gtk_label_get_line_wrap(v.native()) - return gobool(c) -} - -// SetLineWrap is a wrapper around gtk_label_set_line_wrap(). -func (v *Label) SetLineWrap(wrap bool) { - C.gtk_label_set_line_wrap(v.native(), gbool(wrap)) -} - -// SetLineWrapMode is a wrapper around gtk_label_set_line_wrap_mode(). -func (v *Label) SetLineWrapMode(wrapMode pango.WrapMode) { - C.gtk_label_set_line_wrap_mode(v.native(), C.PangoWrapMode(wrapMode)) -} - -// GetSelectable is a wrapper around gtk_label_get_selectable(). -func (v *Label) GetSelectable() bool { - c := C.gtk_label_get_selectable(v.native()) - return gobool(c) -} - -// GetText is a wrapper around gtk_label_get_text(). -func (v *Label) GetText() (string, error) { - c := C.gtk_label_get_text(v.native()) - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// GetJustify is a wrapper around gtk_label_get_justify(). -func (v *Label) GetJustify() Justification { - c := C.gtk_label_get_justify(v.native()) - return Justification(c) -} - -// GetEllipsize is a wrapper around gtk_label_get_ellipsize(). -func (v *Label) GetEllipsize() pango.EllipsizeMode { - c := C.gtk_label_get_ellipsize(v.native()) - return pango.EllipsizeMode(c) -} - -// GetCurrentUri is a wrapper around gtk_label_get_current_uri(). -func (v *Label) GetCurrentUri() string { - c := C.gtk_label_get_current_uri(v.native()) - return C.GoString((*C.char)(c)) -} - -// GetTrackVisitedLinks is a wrapper around gtk_label_get_track_visited_links(). -func (v *Label) GetTrackVisitedLinks() bool { - c := C.gtk_label_get_track_visited_links(v.native()) - return gobool(c) -} - -// SetTrackVisitedLinks is a wrapper around gtk_label_set_track_visited_links(). -func (v *Label) SetTrackVisitedLinks(trackLinks bool) { - C.gtk_label_set_track_visited_links(v.native(), gbool(trackLinks)) -} - -// GetAngle is a wrapper around gtk_label_get_angle(). -func (v *Label) GetAngle() float64 { - c := C.gtk_label_get_angle(v.native()) - return float64(c) -} - -// SetAngle is a wrapper around gtk_label_set_angle(). -func (v *Label) SetAngle(angle float64) { - C.gtk_label_set_angle(v.native(), C.gdouble(angle)) -} - -// GetSelectionBounds is a wrapper around gtk_label_get_selection_bounds(). -func (v *Label) GetSelectionBounds() (start, end int, nonEmpty bool) { - var cstart, cend C.gint - c := C.gtk_label_get_selection_bounds(v.native(), &cstart, &cend) - return int(cstart), int(cend), gobool(c) -} - -// GetSingleLineMode is a wrapper around gtk_label_get_single_line_mode(). -func (v *Label) GetSingleLineMode() bool { - c := C.gtk_label_get_single_line_mode(v.native()) - return gobool(c) -} - -// SetSingleLineMode is a wrapper around gtk_label_set_single_line_mode(). -func (v *Label) SetSingleLineMode(mode bool) { - C.gtk_label_set_single_line_mode(v.native(), gbool(mode)) -} - -// GetUseMarkup is a wrapper around gtk_label_get_use_markup(). -func (v *Label) GetUseMarkup() bool { - c := C.gtk_label_get_use_markup(v.native()) - return gobool(c) -} - -// SetUseMarkup is a wrapper around gtk_label_set_use_markup(). -func (v *Label) SetUseMarkup(use bool) { - C.gtk_label_set_use_markup(v.native(), gbool(use)) -} - -// GetUseUnderline is a wrapper around gtk_label_get_use_underline(). -func (v *Label) GetUseUnderline() bool { - c := C.gtk_label_get_use_underline(v.native()) - return gobool(c) -} - -// SetUseUnderline is a wrapper around gtk_label_set_use_underline(). -func (v *Label) SetUseUnderline(use bool) { - C.gtk_label_set_use_underline(v.native(), gbool(use)) -} - -// LabelNewWithMnemonic is a wrapper around gtk_label_new_with_mnemonic(). -func LabelNewWithMnemonic(str string) (*Label, error) { - cstr := C.CString(str) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_label_new_with_mnemonic((*C.gchar)(cstr)) - if c == nil { - return nil, nilPtrErr - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapLabel(obj), nil -} - -// SelectRegion is a wrapper around gtk_label_select_region(). -func (v *Label) SelectRegion(startOffset, endOffset int) { - C.gtk_label_select_region(v.native(), C.gint(startOffset), - C.gint(endOffset)) -} - -// SetSelectable is a wrapper around gtk_label_set_selectable(). -func (v *Label) SetSelectable(setting bool) { - C.gtk_label_set_selectable(v.native(), gbool(setting)) -} - -// SetLabel is a wrapper around gtk_label_set_label(). -func (v *Label) SetLabel(str string) { - cstr := C.CString(str) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_label_set_label(v.native(), (*C.gchar)(cstr)) -} - -// GetLabel is a wrapper around gtk_label_get_label(). -func (v *Label) GetLabel() string { - c := C.gtk_label_get_label(v.native()) - if c == nil { - return "" - } - return C.GoString((*C.char)(c)) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/level_bar.go b/vendor/github.com/gotk3/gotk3.old/gtk/level_bar.go deleted file mode 100644 index 74ddcf0..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/level_bar.go +++ /dev/null @@ -1,151 +0,0 @@ -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - {glib.Type(C.gtk_level_bar_mode_get_type()), marshalLevelBarMode}, - - {glib.Type(C.gtk_level_bar_get_type()), marshalLevelBar}, - } - - glib.RegisterGValueMarshalers(tm) - - WrapMap["GtkLevelBar"] = wrapLevelBar -} - -// LevelBarMode is a representation of GTK's GtkLevelBarMode. -type LevelBarMode int - -const ( - LEVEL_BAR_MODE_CONTINUOUS LevelBarMode = C.GTK_LEVEL_BAR_MODE_CONTINUOUS - LEVEL_BAR_MODE_DISCRETE LevelBarMode = C.GTK_LEVEL_BAR_MODE_DISCRETE -) - -func marshalLevelBarMode(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return LevelBarMode(c), nil -} - -/* - * GtkLevelBar - */ - -type LevelBar struct { - Widget -} - -// native returns a pointer to the underlying GtkLevelBar. -func (v *LevelBar) native() *C.GtkLevelBar { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkLevelBar(p) -} - -func marshalLevelBar(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapLevelBar(obj), nil -} - -func wrapLevelBar(obj *glib.Object) *LevelBar { - return &LevelBar{Widget{glib.InitiallyUnowned{obj}}} -} - -// LevelBarNew() is a wrapper around gtk_level_bar_new(). -func LevelBarNew() (*LevelBar, error) { - c := C.gtk_level_bar_new() - if c == nil { - return nil, nilPtrErr - } - return wrapLevelBar(wrapObject(unsafe.Pointer(c))), nil -} - -// LevelBarNewForInterval() is a wrapper around gtk_level_bar_new_for_interval(). -func LevelBarNewForInterval(min_value, max_value float64) (*LevelBar, error) { - c := C.gtk_level_bar_new_for_interval(C.gdouble(min_value), C.gdouble(max_value)) - if c == nil { - return nil, nilPtrErr - } - return wrapLevelBar(wrapObject(unsafe.Pointer(c))), nil -} - -// SetMode() is a wrapper around gtk_level_bar_set_mode(). -func (v *LevelBar) SetMode(m LevelBarMode) { - C.gtk_level_bar_set_mode(v.native(), C.GtkLevelBarMode(m)) -} - -// GetMode() is a wrapper around gtk_level_bar_get_mode(). -func (v *LevelBar) GetMode() LevelBarMode { - return LevelBarMode(C.gtk_level_bar_get_mode(v.native())) -} - -// SetValue() is a wrapper around gtk_level_bar_set_value(). -func (v *LevelBar) SetValue(value float64) { - C.gtk_level_bar_set_value(v.native(), C.gdouble(value)) -} - -// GetValue() is a wrapper around gtk_level_bar_get_value(). -func (v *LevelBar) GetValue() float64 { - c := C.gtk_level_bar_get_value(v.native()) - return float64(c) -} - -// SetMinValue() is a wrapper around gtk_level_bar_set_min_value(). -func (v *LevelBar) SetMinValue(value float64) { - C.gtk_level_bar_set_min_value(v.native(), C.gdouble(value)) -} - -// GetMinValue() is a wrapper around gtk_level_bar_get_min_value(). -func (v *LevelBar) GetMinValue() float64 { - c := C.gtk_level_bar_get_min_value(v.native()) - return float64(c) -} - -// SetMaxValue() is a wrapper around gtk_level_bar_set_max_value(). -func (v *LevelBar) SetMaxValue(value float64) { - C.gtk_level_bar_set_max_value(v.native(), C.gdouble(value)) -} - -// GetMaxValue() is a wrapper around gtk_level_bar_get_max_value(). -func (v *LevelBar) GetMaxValue() float64 { - c := C.gtk_level_bar_get_max_value(v.native()) - return float64(c) -} - -const ( - LEVEL_BAR_OFFSET_LOW string = C.GTK_LEVEL_BAR_OFFSET_LOW - LEVEL_BAR_OFFSET_HIGH string = C.GTK_LEVEL_BAR_OFFSET_HIGH -) - -// AddOffsetValue() is a wrapper around gtk_level_bar_add_offset_value(). -func (v *LevelBar) AddOffsetValue(name string, value float64) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_level_bar_add_offset_value(v.native(), (*C.gchar)(cstr), C.gdouble(value)) -} - -// RemoveOffsetValue() is a wrapper around gtk_level_bar_remove_offset_value(). -func (v *LevelBar) RemoveOffsetValue(name string) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_level_bar_remove_offset_value(v.native(), (*C.gchar)(cstr)) -} - -// GetOffsetValue() is a wrapper around gtk_level_bar_get_offset_value(). -func (v *LevelBar) GetOffsetValue(name string) (float64, bool) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - var value C.gdouble - c := C.gtk_level_bar_get_offset_value(v.native(), (*C.gchar)(cstr), &value) - return float64(value), gobool(c) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/level_bar_since_3_8.go b/vendor/github.com/gotk3/gotk3.old/gtk/level_bar_since_3_8.go deleted file mode 100644 index 8df8f29..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/level_bar_since_3_8.go +++ /dev/null @@ -1,18 +0,0 @@ -// +build !gtk_3_6 - -package gtk - -// #include -// #include "gtk.go.h" -import "C" - -// SetInverted() is a wrapper around gtk_level_bar_set_inverted(). -func (v *LevelBar) SetInverted(inverted bool) { - C.gtk_level_bar_set_inverted(v.native(), gbool(inverted)) -} - -// GetInverted() is a wrapper around gtk_level_bar_get_inverted(). -func (v *LevelBar) GetInverted() bool { - c := C.gtk_level_bar_get_inverted(v.native()) - return gobool(c) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/menu_shell.go b/vendor/github.com/gotk3/gotk3.old/gtk/menu_shell.go deleted file mode 100644 index 295fa34..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/menu_shell.go +++ /dev/null @@ -1,96 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains accelerator related functions and structures - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -/* - * GtkMenuShell - */ - -// MenuShell is a representation of GTK's GtkMenuShell. -type MenuShell struct { - Container -} - -// native returns a pointer to the underlying GtkMenuShell. -func (v *MenuShell) native() *C.GtkMenuShell { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkMenuShell(p) -} - -func marshalMenuShell(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapMenuShell(obj), nil -} - -func wrapMenuShell(obj *glib.Object) *MenuShell { - return &MenuShell{Container{Widget{glib.InitiallyUnowned{obj}}}} -} - -// Append is a wrapper around gtk_menu_shell_append(). -func (v *MenuShell) Append(child IMenuItem) { - C.gtk_menu_shell_append(v.native(), child.toWidget()) -} - -// Prepend is a wrapper around gtk_menu_shell_prepend(). -func (v *MenuShell) Prepend(child IMenuItem) { - C.gtk_menu_shell_prepend(v.native(), child.toWidget()) -} - -// Insert is a wrapper around gtk_menu_shell_insert(). -func (v *MenuShell) Insert(child IMenuItem, position int) { - C.gtk_menu_shell_insert(v.native(), child.toWidget(), C.gint(position)) -} - -// Deactivate is a wrapper around gtk_menu_shell_deactivate(). -func (v *MenuShell) Deactivate() { - C.gtk_menu_shell_deactivate(v.native()) -} - -// SelectItem is a wrapper around gtk_menu_shell_select_item(). -func (v *MenuShell) SelectItem(child IMenuItem) { - C.gtk_menu_shell_select_item(v.native(), child.toWidget()) -} - -// SelectFirst is a wrapper around gtk_menu_shell_select_first(). -func (v *MenuShell) SelectFirst(searchSensitive bool) { - C.gtk_menu_shell_select_first(v.native(), gbool(searchSensitive)) -} - -// Deselect is a wrapper around gtk_menu_shell_deselect(). -func (v *MenuShell) Deselect() { - C.gtk_menu_shell_deselect(v.native()) -} - -// ActivateItem is a wrapper around gtk_menu_shell_activate_item(). -func (v *MenuShell) ActivateItem(child IMenuItem, forceDeactivate bool) { - C.gtk_menu_shell_activate_item(v.native(), child.toWidget(), gbool(forceDeactivate)) -} - -// Cancel is a wrapper around gtk_menu_shell_cancel(). -func (v *MenuShell) Cancel() { - C.gtk_menu_shell_cancel(v.native()) -} - -// SetTakeFocus is a wrapper around gtk_menu_shell_set_take_focus(). -func (v *MenuShell) SetTakeFocus(takeFocus bool) { - C.gtk_menu_shell_set_take_focus(v.native(), gbool(takeFocus)) -} - -// gboolean gtk_menu_shell_get_take_focus () -// GtkWidget * gtk_menu_shell_get_selected_item () -// GtkWidget * gtk_menu_shell_get_parent_shell () -// void gtk_menu_shell_bind_model () diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/popover_since_3_12.go b/vendor/github.com/gotk3/gotk3.old/gtk/popover_since_3_12.go deleted file mode 100644 index 4252ad0..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/popover_since_3_12.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// This file includes wrapers for symbols included since GTK 3.12, and -// and should not be included in a build intended to target any older GTK -// versions. To target an older build, such as 3.10, use -// 'go build -tags gtk_3_10'. Otherwise, if no build tags are used, GTK 3.12 -// is assumed and this file is built. - -// +build !gtk_3_6,!gtk_3_8,!gtk_3_10 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -// #include "popover_since_3_12.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - {glib.Type(C.gtk_popover_get_type()), marshalPopover}, - } - - glib.RegisterGValueMarshalers(tm) - WrapMap["GtkPopover"] = wrapPopover -} - -//TODO(sjon): Implement GtkPopover -//GtkPopover -type Popover struct { - Bin -} - -func (v *Popover) native() *C.GtkPopover { - if v == nil || v.GObject == nil { - return nil - } - - p := unsafe.Pointer(v.GObject) - return C.toGtkPopover(p) -} - -func marshalPopover(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapPopover(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapPopover(obj *glib.Object) *Popover { - return &Popover{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -//gtk_popover_new() -func PopoverNew(relative IWidget) (*Popover, error) { - //Takes relative to widget - var c *C.struct__GtkWidget - if relative == nil { - c = C.gtk_popover_new(nil) - } else { - c = C.gtk_popover_new(relative.toWidget()) - } - if c == nil { - return nil, nilPtrErr - } - return wrapPopover(wrapObject(unsafe.Pointer(c))), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/popover_since_3_18.go b/vendor/github.com/gotk3/gotk3.old/gtk/popover_since_3_18.go deleted file mode 100644 index 71b64da..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/popover_since_3_18.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12,!gtk_3_14,!gtk_3_16,gtk_3_18 - -// See: https://developer.gnome.org/gtk3/3.18/api-index-3-18.html - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -//void -//gtk_popover_set_default_widget (GtkPopover *popover, GtkWidget *widget); -func (p *Popover) SetDefaultWidget(widget IWidget) { - C.gtk_popover_set_default_widget(p.native(), widget.toWidget()) -} - -//GtkWidget * -//gtk_popover_get_default_widget (GtkPopover *popover); -func (p *Popover) GetDefaultWidget() *Widget { - w := C.gtk_popover_get_default_widget(p.native()) - if w == nil { - return nil - } - return &Widget{glib.InitiallyUnowned{wrapObject(unsafe.Pointer(w))}} -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/settings.go b/vendor/github.com/gotk3/gotk3.old/gtk/settings.go deleted file mode 100644 index 15841b7..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/settings.go +++ /dev/null @@ -1,53 +0,0 @@ -package gtk - -// #include -// #include "settings.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - {glib.Type(C.gtk_settings_get_type()), marshalSettings}, - } - - glib.RegisterGValueMarshalers(tm) - - WrapMap["GtkSettings"] = wrapSettings -} - -//GtkSettings -type Settings struct { - *glib.Object -} - -func (v *Settings) native() *C.GtkSettings { - if v == nil || v.GObject == nil { - return nil - } - - p := unsafe.Pointer(v.GObject) - return C.toGtkSettings(p) -} - -func marshalSettings(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - return wrapSettings(wrapObject(unsafe.Pointer(c))), nil -} - -func wrapSettings(obj *glib.Object) *Settings { - return &Settings{obj} -} - -//Get the global non window specific settings -func SettingsGetDefault() (*Settings, error) { - c := C.gtk_settings_get_default() - if c == nil { - return nil, nilPtrErr - } - - return wrapSettings(wrapObject(unsafe.Pointer(c))), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/settings.go.h b/vendor/github.com/gotk3/gotk3.old/gtk/settings.go.h deleted file mode 100644 index 571b91a..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/settings.go.h +++ /dev/null @@ -1,5 +0,0 @@ -static GtkSettings * -toGtkSettings(void *p) -{ - return (GTK_SETTINGS(p)); -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/stack_since_3_12.go b/vendor/github.com/gotk3/gotk3.old/gtk/stack_since_3_12.go deleted file mode 100644 index 42addd5..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/stack_since_3_12.go +++ /dev/null @@ -1,27 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains accelerator related functions and structures - -// +build !gtk_3_6,!gtk_3_8,!gtk_3_10 -// not use this: go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.10 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -// #include -// #include "gtk_since_3_10.go.h" -import "C" -import ( - "unsafe" -) - -// GetChildByName is a wrapper around gtk_stack_get_child_by_name(). -func (v *Stack) GetChildByName(name string) *Widget { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - c := C.gtk_stack_get_child_by_name(v.native(), (*C.gchar)(cstr)) - if c == nil { - return nil - } - return wrapWidget(wrapObject(unsafe.Pointer(c))) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/stackswitcher_since_3_10.go b/vendor/github.com/gotk3/gotk3.old/gtk/stackswitcher_since_3_10.go deleted file mode 100644 index 773b45a..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/stackswitcher_since_3_10.go +++ /dev/null @@ -1,78 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains accelerator related functions and structures - -// +build !gtk_3_6,!gtk_3_8 -// not use this: go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.10 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -// #include -// #include "gtk_since_3_10.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - //Contribute to casting - for k, v := range map[string]WrapFn{ - "GtkStackSwitcher": wrapStackSwitcher, - } { - WrapMap[k] = v - } -} - -/* - * GtkStackSwitcher - */ - -// StackSwitcher is a representation of GTK's GtkStackSwitcher -type StackSwitcher struct { - Box -} - -// native returns a pointer to the underlying GtkStackSwitcher. -func (v *StackSwitcher) native() *C.GtkStackSwitcher { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkStackSwitcher(p) -} - -func marshalStackSwitcher(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapStackSwitcher(obj), nil -} - -func wrapStackSwitcher(obj *glib.Object) *StackSwitcher { - return &StackSwitcher{Box{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// StackSwitcherNew is a wrapper around gtk_stack_switcher_new(). -func StackSwitcherNew() (*StackSwitcher, error) { - c := C.gtk_stack_switcher_new() - if c == nil { - return nil, nilPtrErr - } - return wrapStackSwitcher(wrapObject(unsafe.Pointer(c))), nil -} - -// SetStack is a wrapper around gtk_stack_switcher_set_stack(). -func (v *StackSwitcher) SetStack(stack *Stack) { - C.gtk_stack_switcher_set_stack(v.native(), stack.native()) -} - -// GetStack is a wrapper around gtk_stack_switcher_get_stack(). -func (v *StackSwitcher) GetStack() *Stack { - c := C.gtk_stack_switcher_get_stack(v.native()) - if c == nil { - return nil - } - return wrapStack(wrapObject(unsafe.Pointer(c))) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/style.go b/vendor/github.com/gotk3/gotk3.old/gtk/style.go deleted file mode 100644 index 47fb2da..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/style.go +++ /dev/null @@ -1,232 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains style related functions and structures - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/gdk" - "github.com/gotk3/gotk3/glib" -) - -type StyleProviderPriority int - -const ( - STYLE_PROVIDER_PRIORITY_FALLBACK StyleProviderPriority = C.GTK_STYLE_PROVIDER_PRIORITY_FALLBACK - STYLE_PROVIDER_PRIORITY_THEME = C.GTK_STYLE_PROVIDER_PRIORITY_THEME - STYLE_PROVIDER_PRIORITY_SETTINGS = C.GTK_STYLE_PROVIDER_PRIORITY_SETTINGS - STYLE_PROVIDER_PRIORITY_APPLICATION = C.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION - STYLE_PROVIDER_PRIORITY_USER = C.GTK_STYLE_PROVIDER_PRIORITY_USER -) - -/* - * GtkStyleContext - */ - -// StyleContext is a representation of GTK's GtkStyleContext. -type StyleContext struct { - *glib.Object -} - -// native returns a pointer to the underlying GtkStyleContext. -func (v *StyleContext) native() *C.GtkStyleContext { - if v == nil || v.Object == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkStyleContext(p) -} - -func wrapStyleContext(obj *glib.Object) *StyleContext { - return &StyleContext{obj} -} - -func (v *StyleContext) AddClass(class_name string) { - cstr := C.CString(class_name) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_style_context_add_class(v.native(), (*C.gchar)(cstr)) -} - -func (v *StyleContext) RemoveClass(class_name string) { - cstr := C.CString(class_name) - defer C.free(unsafe.Pointer(cstr)) - - C.gtk_style_context_remove_class(v.native(), (*C.gchar)(cstr)) -} - -func fromNativeStyleContext(c *C.GtkStyleContext) (*StyleContext, error) { - if c == nil { - return nil, nilPtrErr - } - - obj := wrapObject(unsafe.Pointer(c)) - return wrapStyleContext(obj), nil -} - -// GetStyleContext is a wrapper around gtk_widget_get_style_context(). -func (v *Widget) GetStyleContext() (*StyleContext, error) { - return fromNativeStyleContext(C.gtk_widget_get_style_context(v.native())) -} - -// GetParent is a wrapper around gtk_style_context_get_parent(). -func (v *StyleContext) GetParent() (*StyleContext, error) { - return fromNativeStyleContext(C.gtk_style_context_get_parent(v.native())) -} - -// GetProperty is a wrapper around gtk_style_context_get_property(). -func (v *StyleContext) GetProperty(property string, state StateFlags) (interface{}, error) { - cstr := (*C.gchar)(C.CString(property)) - defer C.free(unsafe.Pointer(cstr)) - - var gval C.GValue - C.gtk_style_context_get_property(v.native(), cstr, C.GtkStateFlags(state), &gval) - val := glib.ValueFromNative(unsafe.Pointer(&gval)) - return val.GoValue() -} - -// GetStyleProperty is a wrapper around gtk_style_context_get_style_property(). -func (v *StyleContext) GetStyleProperty(property string) (interface{}, error) { - cstr := (*C.gchar)(C.CString(property)) - defer C.free(unsafe.Pointer(cstr)) - - var gval C.GValue - C.gtk_style_context_get_style_property(v.native(), cstr, &gval) - val := glib.ValueFromNative(unsafe.Pointer(&gval)) - return val.GoValue() -} - -// GetScreen is a wrapper around gtk_style_context_get_screen(). -func (v *StyleContext) GetScreen() (*gdk.Screen, error) { - c := C.gtk_style_context_get_screen(v.native()) - if c == nil { - return nil, nilPtrErr - } - - d := &gdk.Screen{wrapObject(unsafe.Pointer(c))} - return d, nil -} - -// GetState is a wrapper around gtk_style_context_get_state(). -func (v *StyleContext) GetState() StateFlags { - return StateFlags(C.gtk_style_context_get_state(v.native())) -} - -// GetColor is a wrapper around gtk_style_context_get_color(). -func (v *StyleContext) GetColor(state StateFlags) *gdk.RGBA { - gdkColor := gdk.NewRGBA() - C.gtk_style_context_get_color(v.native(), C.GtkStateFlags(state), (*C.GdkRGBA)(unsafe.Pointer(gdkColor.Native()))) - return gdkColor -} - -// LookupColor is a wrapper around gtk_style_context_lookup_color(). -func (v *StyleContext) LookupColor(colorName string) (*gdk.RGBA, bool) { - cstr := (*C.gchar)(C.CString(colorName)) - defer C.free(unsafe.Pointer(cstr)) - gdkColor := gdk.NewRGBA() - ret := C.gtk_style_context_lookup_color(v.native(), cstr, (*C.GdkRGBA)(unsafe.Pointer(gdkColor.Native()))) - return gdkColor, gobool(ret) -} - -// StyleContextResetWidgets is a wrapper around gtk_style_context_reset_widgets(). -func StyleContextResetWidgets(v *gdk.Screen) { - C.gtk_style_context_reset_widgets((*C.GdkScreen)(unsafe.Pointer(v.Native()))) -} - -// Restore is a wrapper around gtk_style_context_restore(). -func (v *StyleContext) Restore() { - C.gtk_style_context_restore(v.native()) -} - -// Save is a wrapper around gtk_style_context_save(). -func (v *StyleContext) Save() { - C.gtk_style_context_save(v.native()) -} - -// SetParent is a wrapper around gtk_style_context_set_parent(). -func (v *StyleContext) SetParent(p *StyleContext) { - C.gtk_style_context_set_parent(v.native(), p.native()) -} - -// HasClass is a wrapper around gtk_style_context_has_class(). -func (v *StyleContext) HasClass(className string) bool { - cstr := C.CString(className) - defer C.free(unsafe.Pointer(cstr)) - - return gobool(C.gtk_style_context_has_class(v.native(), (*C.gchar)(cstr))) -} - -// SetScreen is a wrapper around gtk_style_context_set_screen(). -func (v *StyleContext) SetScreen(s *gdk.Screen) { - C.gtk_style_context_set_screen(v.native(), (*C.GdkScreen)(unsafe.Pointer(s.Native()))) -} - -// SetState is a wrapper around gtk_style_context_set_state(). -func (v *StyleContext) SetState(state StateFlags) { - C.gtk_style_context_set_state(v.native(), C.GtkStateFlags(state)) -} - -type IStyleProvider interface { - toStyleProvider() *C.GtkStyleProvider -} - -// AddProvider is a wrapper around gtk_style_context_add_provider(). -func (v *StyleContext) AddProvider(provider IStyleProvider, prio uint) { - C.gtk_style_context_add_provider(v.native(), provider.toStyleProvider(), C.guint(prio)) -} - -// AddProviderForScreen is a wrapper around gtk_style_context_add_provider_for_screen(). -func AddProviderForScreen(s *gdk.Screen, provider IStyleProvider, prio uint) { - C.gtk_style_context_add_provider_for_screen((*C.GdkScreen)(unsafe.Pointer(s.Native())), provider.toStyleProvider(), C.guint(prio)) -} - -// RemoveProvider is a wrapper around gtk_style_context_remove_provider(). -func (v *StyleContext) RemoveProvider(provider IStyleProvider) { - C.gtk_style_context_remove_provider(v.native(), provider.toStyleProvider()) -} - -// RemoveProviderForScreen is a wrapper around gtk_style_context_remove_provider_for_screen(). -func RemoveProviderForScreen(s *gdk.Screen, provider IStyleProvider) { - C.gtk_style_context_remove_provider_for_screen((*C.GdkScreen)(unsafe.Pointer(s.Native())), provider.toStyleProvider()) -} - -// GtkStyleContext * gtk_style_context_new () -// void gtk_style_context_get () -// GtkTextDirection gtk_style_context_get_direction () -// GtkJunctionSides gtk_style_context_get_junction_sides () -// const GtkWidgetPath * gtk_style_context_get_path () -// GdkFrameClock * gtk_style_context_get_frame_clock () -// void gtk_style_context_get_style () -// void gtk_style_context_get_style_valist () -// void gtk_style_context_get_valist () -// GtkCssSection * gtk_style_context_get_section () -// void gtk_style_context_get_background_color () -// void gtk_style_context_get_border_color () -// void gtk_style_context_get_border () -// void gtk_style_context_get_padding () -// void gtk_style_context_get_margin () -// const PangoFontDescription * gtk_style_context_get_font () -// void gtk_style_context_invalidate () -// gboolean gtk_style_context_state_is_running () -// GtkIconSet * gtk_style_context_lookup_icon_set () -// void gtk_style_context_cancel_animations () -// void gtk_style_context_scroll_animations () -// void gtk_style_context_notify_state_change () -// void gtk_style_context_pop_animatable_region () -// void gtk_style_context_push_animatable_region () -// void gtk_style_context_set_background () -// void gtk_style_context_set_direction () -// void gtk_style_context_set_junction_sides () -// void gtk_style_context_set_path () -// void gtk_style_context_add_region () -// void gtk_style_context_remove_region () -// gboolean gtk_style_context_has_region () -// GList * gtk_style_context_list_regions () -// void gtk_style_context_set_frame_clock () -// void gtk_style_context_set_scale () -// gint gtk_style_context_get_scale () -// GList * gtk_style_context_list_classes () diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/text_iter.go b/vendor/github.com/gotk3/gotk3.old/gtk/text_iter.go deleted file mode 100644 index 3ebabf3..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/text_iter.go +++ /dev/null @@ -1,404 +0,0 @@ -// Same copyright and license as the rest of the files in this project - -package gtk - -// #include -// #include "gtk.go.h" -import "C" - -import "unsafe" - -/* - * GtkTextIter - */ - -// TextIter is a representation of GTK's GtkTextIter -type TextIter C.GtkTextIter - -// native returns a pointer to the underlying GtkTextIter. -func (v *TextIter) native() *C.GtkTextIter { - if v == nil { - return nil - } - return (*C.GtkTextIter)(v) -} - -func marshalTextIter(p uintptr) (interface{}, error) { - c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) - return (*TextIter)(unsafe.Pointer(c)), nil -} - -// GetBuffer is a wrapper around gtk_text_iter_get_buffer(). -func (v *TextIter) GetBuffer() *TextBuffer { - c := C.gtk_text_iter_get_buffer(v.native()) - if c == nil { - return nil - } - return wrapTextBuffer(wrapObject(unsafe.Pointer(c))) -} - -// GetOffset is a wrapper around gtk_text_iter_get_offset(). -func (v *TextIter) GetOffset() int { - return int(C.gtk_text_iter_get_offset(v.native())) -} - -// GetLine is a wrapper around gtk_text_iter_get_line(). -func (v *TextIter) GetLine() int { - return int(C.gtk_text_iter_get_line(v.native())) -} - -// GetLineOffset is a wrapper around gtk_text_iter_get_line_offset(). -func (v *TextIter) GetLineOffset() int { - return int(C.gtk_text_iter_get_line_offset(v.native())) -} - -// GetLineIndex is a wrapper around gtk_text_iter_get_line_index(). -func (v *TextIter) GetLineIndex() int { - return int(C.gtk_text_iter_get_line_index(v.native())) -} - -// GetVisibleLineOffset is a wrapper around gtk_text_iter_get_visible_line_offset(). -func (v *TextIter) GetVisibleLineOffset() int { - return int(C.gtk_text_iter_get_visible_line_offset(v.native())) -} - -// GetVisibleLineIndex is a wrapper around gtk_text_iter_get_visible_line_index(). -func (v *TextIter) GetVisibleLineIndex() int { - return int(C.gtk_text_iter_get_visible_line_index(v.native())) -} - -// GetChar is a wrapper around gtk_text_iter_get_char(). -func (v *TextIter) GetChar() rune { - return rune(C.gtk_text_iter_get_char(v.native())) -} - -// GetSlice is a wrapper around gtk_text_iter_get_slice(). -func (v *TextIter) GetSlice(end *TextIter) string { - c := C.gtk_text_iter_get_slice(v.native(), end.native()) - return C.GoString((*C.char)(c)) -} - -// GetText is a wrapper around gtk_text_iter_get_text(). -func (v *TextIter) GetText(end *TextIter) string { - c := C.gtk_text_iter_get_text(v.native(), end.native()) - return C.GoString((*C.char)(c)) -} - -// GetVisibleSlice is a wrapper around gtk_text_iter_get_visible_slice(). -func (v *TextIter) GetVisibleSlice(end *TextIter) string { - c := C.gtk_text_iter_get_visible_slice(v.native(), end.native()) - return C.GoString((*C.char)(c)) -} - -// GetVisibleText is a wrapper around gtk_text_iter_get_visible_text(). -func (v *TextIter) GetVisibleText(end *TextIter) string { - c := C.gtk_text_iter_get_visible_text(v.native(), end.native()) - return C.GoString((*C.char)(c)) -} - -// BeginsTag is a wrapper around gtk_text_iter_begins_tag(). -func (v *TextIter) BeginsTag(v1 *TextTag) bool { - return gobool(C.gtk_text_iter_begins_tag(v.native(), v1.native())) -} - -// EndsTag is a wrapper around gtk_text_iter_ends_tag(). -func (v *TextIter) EndsTag(v1 *TextTag) bool { - return gobool(C.gtk_text_iter_ends_tag(v.native(), v1.native())) -} - -// TogglesTag is a wrapper around gtk_text_iter_toggles_tag(). -func (v *TextIter) TogglesTag(v1 *TextTag) bool { - return gobool(C.gtk_text_iter_toggles_tag(v.native(), v1.native())) -} - -// HasTag is a wrapper around gtk_text_iter_has_tag(). -func (v *TextIter) HasTag(v1 *TextTag) bool { - return gobool(C.gtk_text_iter_has_tag(v.native(), v1.native())) -} - -// Editable is a wrapper around gtk_text_iter_editable(). -func (v *TextIter) Editable(v1 bool) bool { - return gobool(C.gtk_text_iter_editable(v.native(), gbool(v1))) -} - -// CanInsert is a wrapper around gtk_text_iter_can_insert(). -func (v *TextIter) CanInsert(v1 bool) bool { - return gobool(C.gtk_text_iter_can_insert(v.native(), gbool(v1))) -} - -// StartsWord is a wrapper around gtk_text_iter_starts_word(). -func (v *TextIter) StartsWord() bool { - return gobool(C.gtk_text_iter_starts_word(v.native())) -} - -// EndsWord is a wrapper around gtk_text_iter_ends_word(). -func (v *TextIter) EndsWord() bool { - return gobool(C.gtk_text_iter_ends_word(v.native())) -} - -// InsideWord is a wrapper around gtk_text_iter_inside_word(). -func (v *TextIter) InsideWord() bool { - return gobool(C.gtk_text_iter_inside_word(v.native())) -} - -// StartsLine is a wrapper around gtk_text_iter_starts_line(). -func (v *TextIter) StartsLine() bool { - return gobool(C.gtk_text_iter_starts_line(v.native())) -} - -// EndsLine is a wrapper around gtk_text_iter_ends_line(). -func (v *TextIter) EndsLine() bool { - return gobool(C.gtk_text_iter_ends_line(v.native())) -} - -// StartsSentence is a wrapper around gtk_text_iter_starts_sentence(). -func (v *TextIter) StartsSentence() bool { - return gobool(C.gtk_text_iter_starts_sentence(v.native())) -} - -// EndsSentence is a wrapper around gtk_text_iter_ends_sentence(). -func (v *TextIter) EndsSentence() bool { - return gobool(C.gtk_text_iter_ends_sentence(v.native())) -} - -// InsideSentence is a wrapper around gtk_text_iter_inside_sentence(). -func (v *TextIter) InsideSentence() bool { - return gobool(C.gtk_text_iter_inside_sentence(v.native())) -} - -// IsCursorPosition is a wrapper around gtk_text_iter_is_cursor_position(). -func (v *TextIter) IsCursorPosition() bool { - return gobool(C.gtk_text_iter_is_cursor_position(v.native())) -} - -// GetCharsInLine is a wrapper around gtk_text_iter_get_chars_in_line(). -func (v *TextIter) GetCharsInLine() int { - return int(C.gtk_text_iter_get_chars_in_line(v.native())) -} - -// GetBytesInLine is a wrapper around gtk_text_iter_get_bytes_in_line(). -func (v *TextIter) GetBytesInLine() int { - return int(C.gtk_text_iter_get_bytes_in_line(v.native())) -} - -// IsEnd is a wrapper around gtk_text_iter_is_end(). -func (v *TextIter) IsEnd() bool { - return gobool(C.gtk_text_iter_is_end(v.native())) -} - -// IsStart is a wrapper around gtk_text_iter_is_start(). -func (v *TextIter) IsStart() bool { - return gobool(C.gtk_text_iter_is_start(v.native())) -} - -// ForwardChar is a wrapper around gtk_text_iter_forward_char(). -func (v *TextIter) ForwardChar() bool { - return gobool(C.gtk_text_iter_forward_char(v.native())) -} - -// BackwardChar is a wrapper around gtk_text_iter_backward_char(). -func (v *TextIter) BackwardChar() bool { - return gobool(C.gtk_text_iter_backward_char(v.native())) -} - -// ForwardChars is a wrapper around gtk_text_iter_forward_chars(). -func (v *TextIter) ForwardChars(v1 int) bool { - return gobool(C.gtk_text_iter_forward_chars(v.native(), C.gint(v1))) -} - -// BackwardChars is a wrapper around gtk_text_iter_backward_chars(). -func (v *TextIter) BackwardChars(v1 int) bool { - return gobool(C.gtk_text_iter_backward_chars(v.native(), C.gint(v1))) -} - -// ForwardLine is a wrapper around gtk_text_iter_forward_line(). -func (v *TextIter) ForwardLine() bool { - return gobool(C.gtk_text_iter_forward_line(v.native())) -} - -// BackwardLine is a wrapper around gtk_text_iter_backward_line(). -func (v *TextIter) BackwardLine() bool { - return gobool(C.gtk_text_iter_backward_line(v.native())) -} - -// ForwardLines is a wrapper around gtk_text_iter_forward_lines(). -func (v *TextIter) ForwardLines(v1 int) bool { - return gobool(C.gtk_text_iter_forward_lines(v.native(), C.gint(v1))) -} - -// BackwardLines is a wrapper around gtk_text_iter_backward_lines(). -func (v *TextIter) BackwardLines(v1 int) bool { - return gobool(C.gtk_text_iter_backward_lines(v.native(), C.gint(v1))) -} - -// ForwardWordEnds is a wrapper around gtk_text_iter_forward_word_ends(). -func (v *TextIter) ForwardWordEnds(v1 int) bool { - return gobool(C.gtk_text_iter_forward_word_ends(v.native(), C.gint(v1))) -} - -// ForwardWordEnd is a wrapper around gtk_text_iter_forward_word_end(). -func (v *TextIter) ForwardWordEnd() bool { - return gobool(C.gtk_text_iter_forward_word_end(v.native())) -} - -// ForwardCursorPosition is a wrapper around gtk_text_iter_forward_cursor_position(). -func (v *TextIter) ForwardCursorPosition() bool { - return gobool(C.gtk_text_iter_forward_cursor_position(v.native())) -} - -// BackwardCursorPosition is a wrapper around gtk_text_iter_backward_cursor_position(). -func (v *TextIter) BackwardCursorPosition() bool { - return gobool(C.gtk_text_iter_backward_cursor_position(v.native())) -} - -// ForwardCursorPositions is a wrapper around gtk_text_iter_forward_cursor_positions(). -func (v *TextIter) ForwardCursorPositions(v1 int) bool { - return gobool(C.gtk_text_iter_forward_cursor_positions(v.native(), C.gint(v1))) -} - -// BackwardCursorPositions is a wrapper around gtk_text_iter_backward_cursor_positions(). -func (v *TextIter) BackwardCursorPositions(v1 int) bool { - return gobool(C.gtk_text_iter_backward_cursor_positions(v.native(), C.gint(v1))) -} - -// ForwardSentenceEnds is a wrapper around gtk_text_iter_forward_sentence_ends(). -func (v *TextIter) ForwardSentenceEnds(v1 int) bool { - return gobool(C.gtk_text_iter_forward_sentence_ends(v.native(), C.gint(v1))) -} - -// ForwardSentenceEnd is a wrapper around gtk_text_iter_forward_sentence_end(). -func (v *TextIter) ForwardSentenceEnd() bool { - return gobool(C.gtk_text_iter_forward_sentence_end(v.native())) -} - -// ForwardVisibleWordEnds is a wrapper around gtk_text_iter_forward_word_ends(). -func (v *TextIter) ForwardVisibleWordEnds(v1 int) bool { - return gobool(C.gtk_text_iter_forward_word_ends(v.native(), C.gint(v1))) -} - -// ForwardVisibleWordEnd is a wrapper around gtk_text_iter_forward_visible_word_end(). -func (v *TextIter) ForwardVisibleWordEnd() bool { - return gobool(C.gtk_text_iter_forward_visible_word_end(v.native())) -} - -// ForwardVisibleCursorPosition is a wrapper around gtk_text_iter_forward_visible_cursor_position(). -func (v *TextIter) ForwardVisibleCursorPosition() bool { - return gobool(C.gtk_text_iter_forward_visible_cursor_position(v.native())) -} - -// BackwardVisibleCursorPosition is a wrapper around gtk_text_iter_backward_visible_cursor_position(). -func (v *TextIter) BackwardVisibleCursorPosition() bool { - return gobool(C.gtk_text_iter_backward_visible_cursor_position(v.native())) -} - -// ForwardVisibleCursorPositions is a wrapper around gtk_text_iter_forward_visible_cursor_positions(). -func (v *TextIter) ForwardVisibleCursorPositions(v1 int) bool { - return gobool(C.gtk_text_iter_forward_visible_cursor_positions(v.native(), C.gint(v1))) -} - -// BackwardVisibleCursorPositions is a wrapper around gtk_text_iter_backward_visible_cursor_positions(). -func (v *TextIter) BackwardVisibleCursorPositions(v1 int) bool { - return gobool(C.gtk_text_iter_backward_visible_cursor_positions(v.native(), C.gint(v1))) -} - -// ForwardVisibleLine is a wrapper around gtk_text_iter_forward_visible_line(). -func (v *TextIter) ForwardVisibleLine() bool { - return gobool(C.gtk_text_iter_forward_visible_line(v.native())) -} - -// BackwardVisibleLine is a wrapper around gtk_text_iter_backward_visible_line(). -func (v *TextIter) BackwardVisibleLine() bool { - return gobool(C.gtk_text_iter_backward_visible_line(v.native())) -} - -// ForwardVisibleLines is a wrapper around gtk_text_iter_forward_visible_lines(). -func (v *TextIter) ForwardVisibleLines(v1 int) bool { - return gobool(C.gtk_text_iter_forward_visible_lines(v.native(), C.gint(v1))) -} - -// BackwardVisibleLines is a wrapper around gtk_text_iter_backward_visible_lines(). -func (v *TextIter) BackwardVisibleLines(v1 int) bool { - return gobool(C.gtk_text_iter_backward_visible_lines(v.native(), C.gint(v1))) -} - -// SetOffset is a wrapper around gtk_text_iter_set_offset(). -func (v *TextIter) SetOffset(v1 int) { - C.gtk_text_iter_set_offset(v.native(), C.gint(v1)) -} - -// SetLine is a wrapper around gtk_text_iter_set_line(). -func (v *TextIter) SetLine(v1 int) { - C.gtk_text_iter_set_line(v.native(), C.gint(v1)) -} - -// SetLineOffset is a wrapper around gtk_text_iter_set_line_offset(). -func (v *TextIter) SetLineOffset(v1 int) { - C.gtk_text_iter_set_line_offset(v.native(), C.gint(v1)) -} - -// SetLineIndex is a wrapper around gtk_text_iter_set_line_index(). -func (v *TextIter) SetLineIndex(v1 int) { - C.gtk_text_iter_set_line_index(v.native(), C.gint(v1)) -} - -// SetVisibleLineOffset is a wrapper around gtk_text_iter_set_visible_line_offset(). -func (v *TextIter) SetVisibleLineOffset(v1 int) { - C.gtk_text_iter_set_visible_line_offset(v.native(), C.gint(v1)) -} - -// SetVisibleLineIndex is a wrapper around gtk_text_iter_set_visible_line_index(). -func (v *TextIter) SetVisibleLineIndex(v1 int) { - C.gtk_text_iter_set_visible_line_index(v.native(), C.gint(v1)) -} - -// ForwardToEnd is a wrapper around gtk_text_iter_forward_to_end(). -func (v *TextIter) ForwardToEnd() { - C.gtk_text_iter_forward_to_end(v.native()) -} - -// ForwardToLineEnd is a wrapper around gtk_text_iter_forward_to_line_end(). -func (v *TextIter) ForwardToLineEnd() bool { - return gobool(C.gtk_text_iter_forward_to_line_end(v.native())) -} - -// ForwardToTagToggle is a wrapper around gtk_text_iter_forward_to_tag_toggle(). -func (v *TextIter) ForwardToTagToggle(v1 *TextTag) bool { - return gobool(C.gtk_text_iter_forward_to_tag_toggle(v.native(), v1.native())) -} - -// BackwardToTagToggle is a wrapper around gtk_text_iter_backward_to_tag_toggle(). -func (v *TextIter) BackwardToTagToggle(v1 *TextTag) bool { - return gobool(C.gtk_text_iter_backward_to_tag_toggle(v.native(), v1.native())) -} - -// Equal is a wrapper around gtk_text_iter_equal(). -func (v *TextIter) Equal(v1 *TextIter) bool { - return gobool(C.gtk_text_iter_equal(v.native(), v1.native())) -} - -// Compare is a wrapper around gtk_text_iter_compare(). -func (v *TextIter) Compare(v1 *TextIter) int { - return int(C.gtk_text_iter_compare(v.native(), v1.native())) -} - -// InRange is a wrapper around gtk_text_iter_in_range(). -func (v *TextIter) InRange(v1 *TextIter, v2 *TextIter) bool { - return gobool(C.gtk_text_iter_in_range(v.native(), v1.native(), v2.native())) -} - -// void gtk_text_iter_order () -// gboolean (*GtkTextCharPredicate) () -// gboolean gtk_text_iter_forward_find_char () -// gboolean gtk_text_iter_backward_find_char () -// gboolean gtk_text_iter_forward_search () -// gboolean gtk_text_iter_backward_search () -// gboolean gtk_text_iter_get_attributes () -// GtkTextIter * gtk_text_iter_copy () -// void gtk_text_iter_assign () -// void gtk_text_iter_free () -// GdkPixbuf * gtk_text_iter_get_pixbuf () -// GSList * gtk_text_iter_get_marks () -// GSList * gtk_text_iter_get_toggled_tags () -// GtkTextChildAnchor * gtk_text_iter_get_child_anchor () -// GSList * gtk_text_iter_get_tags () -// PangoLanguage * gtk_text_iter_get_language () diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/text_mark.go b/vendor/github.com/gotk3/gotk3.old/gtk/text_mark.go deleted file mode 100644 index 1a41934..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/text_mark.go +++ /dev/null @@ -1,29 +0,0 @@ -// Same copyright and license as the rest of the files in this project - -package gtk - -// #include -// #include "gtk.go.h" -import "C" - -import "unsafe" - -/* - * GtkTextMark - */ - -// TextMark is a representation of GTK's GtkTextMark -type TextMark C.GtkTextMark - -// native returns a pointer to the underlying GtkTextMark. -func (v *TextMark) native() *C.GtkTextMark { - if v == nil { - return nil - } - return (*C.GtkTextMark)(v) -} - -func marshalTextMark(p uintptr) (interface{}, error) { - c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) - return (*TextMark)(unsafe.Pointer(c)), nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/text_view.go b/vendor/github.com/gotk3/gotk3.old/gtk/text_view.go deleted file mode 100644 index 75d2b9a..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/text_view.go +++ /dev/null @@ -1,420 +0,0 @@ -// Same copyright and license as the rest of the files in this project - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/gdk" - "github.com/gotk3/gotk3/glib" -) - -// TextWindowType is a representation of GTK's GtkTextWindowType. -type TextWindowType int - -const ( - TEXT_WINDOW_WIDGET TextWindowType = C.GTK_TEXT_WINDOW_WIDGET - TEXT_WINDOW_TEXT TextWindowType = C.GTK_TEXT_WINDOW_TEXT - TEXT_WINDOW_LEFT TextWindowType = C.GTK_TEXT_WINDOW_LEFT - TEXT_WINDOW_RIGHT TextWindowType = C.GTK_TEXT_WINDOW_RIGHT - TEXT_WINDOW_TOP TextWindowType = C.GTK_TEXT_WINDOW_TOP - TEXT_WINDOW_BOTTOM TextWindowType = C.GTK_TEXT_WINDOW_BOTTOM -) - -/* - * GtkTextView - */ - -// TextView is a representation of GTK's GtkTextView -type TextView struct { - Container -} - -// native returns a pointer to the underlying GtkTextView. -func (v *TextView) native() *C.GtkTextView { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkTextView(p) -} - -func marshalTextView(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapTextView(obj), nil -} - -func wrapTextView(obj *glib.Object) *TextView { - return &TextView{Container{Widget{glib.InitiallyUnowned{obj}}}} -} - -// TextViewNew is a wrapper around gtk_text_view_new(). -func TextViewNew() (*TextView, error) { - c := C.gtk_text_view_new() - if c == nil { - return nil, nilPtrErr - } - return wrapTextView(wrapObject(unsafe.Pointer(c))), nil -} - -// TextViewNewWithBuffer is a wrapper around gtk_text_view_new_with_buffer(). -func TextViewNewWithBuffer(buf *TextBuffer) (*TextView, error) { - cbuf := buf.native() - c := C.gtk_text_view_new_with_buffer(cbuf) - return wrapTextView(wrapObject(unsafe.Pointer(c))), nil -} - -// GetBuffer is a wrapper around gtk_text_view_get_buffer(). -func (v *TextView) GetBuffer() (*TextBuffer, error) { - c := C.gtk_text_view_get_buffer(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapTextBuffer(wrapObject(unsafe.Pointer(c))), nil -} - -// SetBuffer is a wrapper around gtk_text_view_set_buffer(). -func (v *TextView) SetBuffer(buffer *TextBuffer) { - C.gtk_text_view_set_buffer(v.native(), buffer.native()) -} - -// SetEditable is a wrapper around gtk_text_view_set_editable(). -func (v *TextView) SetEditable(editable bool) { - C.gtk_text_view_set_editable(v.native(), gbool(editable)) -} - -// GetEditable is a wrapper around gtk_text_view_get_editable(). -func (v *TextView) GetEditable() bool { - c := C.gtk_text_view_get_editable(v.native()) - return gobool(c) -} - -// SetWrapMode is a wrapper around gtk_text_view_set_wrap_mode(). -func (v *TextView) SetWrapMode(wrapMode WrapMode) { - C.gtk_text_view_set_wrap_mode(v.native(), C.GtkWrapMode(wrapMode)) -} - -// GetWrapMode is a wrapper around gtk_text_view_get_wrap_mode(). -func (v *TextView) GetWrapMode() WrapMode { - return WrapMode(C.gtk_text_view_get_wrap_mode(v.native())) -} - -// SetCursorVisible is a wrapper around gtk_text_view_set_cursor_visible(). -func (v *TextView) SetCursorVisible(visible bool) { - C.gtk_text_view_set_cursor_visible(v.native(), gbool(visible)) -} - -// GetCursorVisible is a wrapper around gtk_text_view_get_cursor_visible(). -func (v *TextView) GetCursorVisible() bool { - c := C.gtk_text_view_get_cursor_visible(v.native()) - return gobool(c) -} - -// SetOverwrite is a wrapper around gtk_text_view_set_overwrite(). -func (v *TextView) SetOverwrite(overwrite bool) { - C.gtk_text_view_set_overwrite(v.native(), gbool(overwrite)) -} - -// GetOverwrite is a wrapper around gtk_text_view_get_overwrite(). -func (v *TextView) GetOverwrite() bool { - c := C.gtk_text_view_get_overwrite(v.native()) - return gobool(c) -} - -// SetJustification is a wrapper around gtk_text_view_set_justification(). -func (v *TextView) SetJustification(justify Justification) { - C.gtk_text_view_set_justification(v.native(), C.GtkJustification(justify)) -} - -// GetJustification is a wrapper around gtk_text_view_get_justification(). -func (v *TextView) GetJustification() Justification { - c := C.gtk_text_view_get_justification(v.native()) - return Justification(c) -} - -// SetAcceptsTab is a wrapper around gtk_text_view_set_accepts_tab(). -func (v *TextView) SetAcceptsTab(acceptsTab bool) { - C.gtk_text_view_set_accepts_tab(v.native(), gbool(acceptsTab)) -} - -// GetAcceptsTab is a wrapper around gtk_text_view_get_accepts_tab(). -func (v *TextView) GetAcceptsTab() bool { - c := C.gtk_text_view_get_accepts_tab(v.native()) - return gobool(c) -} - -// SetPixelsAboveLines is a wrapper around gtk_text_view_set_pixels_above_lines(). -func (v *TextView) SetPixelsAboveLines(px int) { - C.gtk_text_view_set_pixels_above_lines(v.native(), C.gint(px)) -} - -// GetPixelsAboveLines is a wrapper around gtk_text_view_get_pixels_above_lines(). -func (v *TextView) GetPixelsAboveLines() int { - c := C.gtk_text_view_get_pixels_above_lines(v.native()) - return int(c) -} - -// SetPixelsBelowLines is a wrapper around gtk_text_view_set_pixels_below_lines(). -func (v *TextView) SetPixelsBelowLines(px int) { - C.gtk_text_view_set_pixels_below_lines(v.native(), C.gint(px)) -} - -// GetPixelsBelowLines is a wrapper around gtk_text_view_get_pixels_below_lines(). -func (v *TextView) GetPixelsBelowLines() int { - c := C.gtk_text_view_get_pixels_below_lines(v.native()) - return int(c) -} - -// SetPixelsInsideWrap is a wrapper around gtk_text_view_set_pixels_inside_wrap(). -func (v *TextView) SetPixelsInsideWrap(px int) { - C.gtk_text_view_set_pixels_inside_wrap(v.native(), C.gint(px)) -} - -// GetPixelsInsideWrap is a wrapper around gtk_text_view_get_pixels_inside_wrap(). -func (v *TextView) GetPixelsInsideWrap() int { - c := C.gtk_text_view_get_pixels_inside_wrap(v.native()) - return int(c) -} - -// SetLeftMargin is a wrapper around gtk_text_view_set_left_margin(). -func (v *TextView) SetLeftMargin(margin int) { - C.gtk_text_view_set_left_margin(v.native(), C.gint(margin)) -} - -// GetLeftMargin is a wrapper around gtk_text_view_get_left_margin(). -func (v *TextView) GetLeftMargin() int { - c := C.gtk_text_view_get_left_margin(v.native()) - return int(c) -} - -// SetRightMargin is a wrapper around gtk_text_view_set_right_margin(). -func (v *TextView) SetRightMargin(margin int) { - C.gtk_text_view_set_right_margin(v.native(), C.gint(margin)) -} - -// GetRightMargin is a wrapper around gtk_text_view_get_right_margin(). -func (v *TextView) GetRightMargin() int { - c := C.gtk_text_view_get_right_margin(v.native()) - return int(c) -} - -// SetIndent is a wrapper around gtk_text_view_set_indent(). -func (v *TextView) SetIndent(indent int) { - C.gtk_text_view_set_indent(v.native(), C.gint(indent)) -} - -// GetIndent is a wrapper around gtk_text_view_get_indent(). -func (v *TextView) GetIndent() int { - c := C.gtk_text_view_get_indent(v.native()) - return int(c) -} - -// SetInputHints is a wrapper around gtk_text_view_set_input_hints(). -func (v *TextView) SetInputHints(hints InputHints) { - C.gtk_text_view_set_input_hints(v.native(), C.GtkInputHints(hints)) -} - -// GetInputHints is a wrapper around gtk_text_view_get_input_hints(). -func (v *TextView) GetInputHints() InputHints { - c := C.gtk_text_view_get_input_hints(v.native()) - return InputHints(c) -} - -// SetInputPurpose is a wrapper around gtk_text_view_set_input_purpose(). -func (v *TextView) SetInputPurpose(purpose InputPurpose) { - C.gtk_text_view_set_input_purpose(v.native(), - C.GtkInputPurpose(purpose)) -} - -// GetInputPurpose is a wrapper around gtk_text_view_get_input_purpose(). -func (v *TextView) GetInputPurpose() InputPurpose { - c := C.gtk_text_view_get_input_purpose(v.native()) - return InputPurpose(c) -} - -// ScrollToMark is a wrapper around gtk_text_view_scroll_to_mark(). -func (v *TextView) ScrollToMark(mark *TextMark, within_margin float64, use_align bool, xalign, yalign float64) { - C.gtk_text_view_scroll_to_mark(v.native(), mark.native(), C.gdouble(within_margin), gbool(use_align), C.gdouble(xalign), C.gdouble(yalign)) -} - -// ScrollToIter is a wrapper around gtk_text_view_scroll_to_iter(). -func (v *TextView) ScrollToIter(iter *TextIter, within_margin float64, use_align bool, xalign, yalign float64) bool { - return gobool(C.gtk_text_view_scroll_to_iter(v.native(), iter.native(), C.gdouble(within_margin), gbool(use_align), C.gdouble(xalign), C.gdouble(yalign))) -} - -// ScrollMarkOnscreen is a wrapper around gtk_text_view_scroll_mark_onscreen(). -func (v *TextView) ScrollMarkOnscreen(mark *TextMark) { - C.gtk_text_view_scroll_mark_onscreen(v.native(), mark.native()) -} - -// MoveMarkOnscreen is a wrapper around gtk_text_view_move_mark_onscreen(). -func (v *TextView) MoveMarkOnscreen(mark *TextMark) bool { - return gobool(C.gtk_text_view_move_mark_onscreen(v.native(), mark.native())) -} - -// PlaceCursorOnscreen is a wrapper around gtk_text_view_place_cursor_onscreen(). -func (v *TextView) PlaceCursorOnscreen() bool { - return gobool(C.gtk_text_view_place_cursor_onscreen(v.native())) -} - -// GetVisibleRect is a wrapper around gtk_text_view_get_visible_rect(). -func (v *TextView) GetVisibleRect() *gdk.Rectangle { - var rect C.GdkRectangle - C.gtk_text_view_get_visible_rect(v.native(), &rect) - return gdk.WrapRectangle(uintptr(unsafe.Pointer(&rect))) -} - -// GetIterLocation is a wrapper around gtk_text_view_get_iter_location(). -func (v *TextView) GetIterLocation(iter *TextIter) *gdk.Rectangle { - var rect C.GdkRectangle - C.gtk_text_view_get_iter_location(v.native(), iter.native(), &rect) - return gdk.WrapRectangle(uintptr(unsafe.Pointer(&rect))) -} - -// GetCursorLocations is a wrapper around gtk_text_view_get_cursor_locations(). -func (v *TextView) GetCursorLocations(iter *TextIter) (strong, weak *gdk.Rectangle) { - var strongRect, weakRect C.GdkRectangle - C.gtk_text_view_get_cursor_locations(v.native(), iter.native(), &strongRect, &weakRect) - return gdk.WrapRectangle(uintptr(unsafe.Pointer(&strongRect))), gdk.WrapRectangle(uintptr(unsafe.Pointer(&weakRect))) -} - -// GetLineAtY is a wrapper around gtk_text_view_get_line_at_y(). -func (v *TextView) GetLineAtY(y int) (*TextIter, int) { - var iter TextIter - var line_top C.gint - iiter := (C.GtkTextIter)(iter) - C.gtk_text_view_get_line_at_y(v.native(), &iiter, C.gint(y), &line_top) - return &iter, int(line_top) -} - -// GetLineYrange is a wrapper around gtk_text_view_get_line_yrange(). -func (v *TextView) GetLineYrange(iter *TextIter) (y, height int) { - var yx, heightx C.gint - C.gtk_text_view_get_line_yrange(v.native(), iter.native(), &yx, &heightx) - return int(yx), int(heightx) -} - -// GetIterAtLocation is a wrapper around gtk_text_view_get_iter_at_location(). -func (v *TextView) GetIterAtLocation(x, y int) *TextIter { - var iter TextIter - iiter := (C.GtkTextIter)(iter) - C.gtk_text_view_get_iter_at_location(v.native(), &iiter, C.gint(x), C.gint(y)) - return &iter -} - -// GetIterAtPosition is a wrapper around gtk_text_view_get_iter_at_position(). -func (v *TextView) GetIterAtPosition(x, y int) (*TextIter, int) { - var iter TextIter - var trailing C.gint - iiter := (C.GtkTextIter)(iter) - C.gtk_text_view_get_iter_at_position(v.native(), &iiter, &trailing, C.gint(x), C.gint(y)) - return &iter, int(trailing) -} - -// BufferToWindowCoords is a wrapper around gtk_text_view_buffer_to_window_coords(). -func (v *TextView) BufferToWindowCoords(win TextWindowType, buffer_x, buffer_y int) (window_x, window_y int) { - var wx, wy C.gint - C.gtk_text_view_buffer_to_window_coords(v.native(), C.GtkTextWindowType(win), C.gint(buffer_x), C.gint(buffer_y), &wx, &wy) - return int(wx), int(wy) -} - -// WindowToBufferCoords is a wrapper around gtk_text_view_window_to_buffer_coords(). -func (v *TextView) WindowToBufferCoords(win TextWindowType, window_x, window_y int) (buffer_x, buffer_y int) { - var bx, by C.gint - C.gtk_text_view_window_to_buffer_coords(v.native(), C.GtkTextWindowType(win), C.gint(window_x), C.gint(window_y), &bx, &by) - return int(bx), int(by) -} - -// GetWindow is a wrapper around gtk_text_view_get_window(). -func (v *TextView) GetWindow(win TextWindowType) *gdk.Window { - c := C.gtk_text_view_get_window(v.native(), C.GtkTextWindowType(win)) - if c == nil { - return nil - } - return &gdk.Window{wrapObject(unsafe.Pointer(c))} -} - -// GetWindowType is a wrapper around gtk_text_view_get_window_type(). -func (v *TextView) GetWindowType(w *gdk.Window) TextWindowType { - return TextWindowType(C.gtk_text_view_get_window_type(v.native(), (*C.GdkWindow)(unsafe.Pointer(w.Native())))) -} - -// SetBorderWindowSize is a wrapper around gtk_text_view_set_border_window_size(). -func (v *TextView) SetBorderWindowSize(tp TextWindowType, size int) { - C.gtk_text_view_set_border_window_size(v.native(), C.GtkTextWindowType(tp), C.gint(size)) -} - -// GetBorderWindowSize is a wrapper around gtk_text_view_get_border_window_size(). -func (v *TextView) GetBorderWindowSize(tp TextWindowType) int { - return int(C.gtk_text_view_get_border_window_size(v.native(), C.GtkTextWindowType(tp))) -} - -// ForwardDisplayLine is a wrapper around gtk_text_view_forward_display_line(). -func (v *TextView) ForwardDisplayLine(iter *TextIter) bool { - return gobool(C.gtk_text_view_forward_display_line(v.native(), iter.native())) -} - -// BackwardDisplayLine is a wrapper around gtk_text_view_backward_display_line(). -func (v *TextView) BackwardDisplayLine(iter *TextIter) bool { - return gobool(C.gtk_text_view_backward_display_line(v.native(), iter.native())) -} - -// ForwardDisplayLineEnd is a wrapper around gtk_text_view_forward_display_line_end(). -func (v *TextView) ForwardDisplayLineEnd(iter *TextIter) bool { - return gobool(C.gtk_text_view_forward_display_line_end(v.native(), iter.native())) -} - -// BackwardDisplayLineStart is a wrapper around gtk_text_view_backward_display_line_start(). -func (v *TextView) BackwardDisplayLineStart(iter *TextIter) bool { - return gobool(C.gtk_text_view_backward_display_line_start(v.native(), iter.native())) -} - -// StartsDisplayLine is a wrapper around gtk_text_view_starts_display_line(). -func (v *TextView) StartsDisplayLine(iter *TextIter) bool { - return gobool(C.gtk_text_view_starts_display_line(v.native(), iter.native())) -} - -// MoveVisually is a wrapper around gtk_text_view_move_visually(). -func (v *TextView) MoveVisually(iter *TextIter, count int) bool { - return gobool(C.gtk_text_view_move_visually(v.native(), iter.native(), C.gint(count))) -} - -// AddChildInWindow is a wrapper around gtk_text_view_add_child_in_window(). -func (v *TextView) AddChildInWindow(child IWidget, tp TextWindowType, xpos, ypos int) { - C.gtk_text_view_add_child_in_window(v.native(), child.toWidget(), C.GtkTextWindowType(tp), C.gint(xpos), C.gint(ypos)) -} - -// MoveChild is a wrapper around gtk_text_view_move_child(). -func (v *TextView) MoveChild(child IWidget, xpos, ypos int) { - C.gtk_text_view_move_child(v.native(), child.toWidget(), C.gint(xpos), C.gint(ypos)) -} - -// ImContextFilterKeypress is a wrapper around gtk_text_view_im_context_filter_keypress(). -func (v *TextView) ImContextFilterKeypress(event *gdk.EventKey) bool { - return gobool(C.gtk_text_view_im_context_filter_keypress(v.native(), (*C.GdkEventKey)(unsafe.Pointer(event.Native())))) -} - -// ResetImContext is a wrapper around gtk_text_view_reset_im_context(). -func (v *TextView) ResetImContext() { - C.gtk_text_view_reset_im_context(v.native()) -} - -// GtkAdjustment * gtk_text_view_get_hadjustment () -- DEPRECATED -// GtkAdjustment * gtk_text_view_get_vadjustment () -- DEPRECATED -// void gtk_text_view_add_child_at_anchor () -// GtkTextChildAnchor * gtk_text_child_anchor_new () -// GList * gtk_text_child_anchor_get_widgets () -// gboolean gtk_text_child_anchor_get_deleted () -// void gtk_text_view_set_top_margin () -- SINCE 3.18 -// gint gtk_text_view_get_top_margin () -- SINCE 3.18 -// void gtk_text_view_set_bottom_margin () -- SINCE 3.18 -// gint gtk_text_view_get_bottom_margin () -- SINCE 3.18 -// void gtk_text_view_set_tabs () -- PangoTabArray -// PangoTabArray * gtk_text_view_get_tabs () -- PangoTabArray -// GtkTextAttributes * gtk_text_view_get_default_attributes () -- GtkTextAttributes -// void gtk_text_view_set_monospace () -- SINCE 3.16 -// gboolean gtk_text_view_get_monospace () -- SINCE 3.16 diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/tree_view.go b/vendor/github.com/gotk3/gotk3.old/gtk/tree_view.go deleted file mode 100644 index 17ba324..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/tree_view.go +++ /dev/null @@ -1,445 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains accelerator related functions and structures - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "runtime" - "unsafe" - - "github.com/gotk3/gotk3/gdk" - "github.com/gotk3/gotk3/glib" -) - -/* - * GtkTreeView - */ - -// TreeView is a representation of GTK's GtkTreeView. -type TreeView struct { - Container -} - -// native returns a pointer to the underlying GtkTreeView. -func (v *TreeView) native() *C.GtkTreeView { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkTreeView(p) -} - -func marshalTreeView(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapTreeView(obj), nil -} - -func wrapTreeView(obj *glib.Object) *TreeView { - return &TreeView{Container{Widget{glib.InitiallyUnowned{obj}}}} -} - -func setupTreeView(c unsafe.Pointer) (*TreeView, error) { - if c == nil { - return nil, nilPtrErr - } - - return wrapTreeView(wrapObject(c)), nil -} - -// TreeViewNew() is a wrapper around gtk_tree_view_new(). -func TreeViewNew() (*TreeView, error) { - return setupTreeView(unsafe.Pointer(C.gtk_tree_view_new())) -} - -// TreeViewNewWithModel() is a wrapper around gtk_tree_view_new_with_model(). -func TreeViewNewWithModel(model ITreeModel) (*TreeView, error) { - return setupTreeView(unsafe.Pointer(C.gtk_tree_view_new_with_model(model.toTreeModel()))) -} - -// GetModel() is a wrapper around gtk_tree_view_get_model(). -func (v *TreeView) GetModel() (*TreeModel, error) { - c := C.gtk_tree_view_get_model(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapTreeModel(wrapObject(unsafe.Pointer(c))), nil -} - -// SetModel() is a wrapper around gtk_tree_view_set_model(). -func (v *TreeView) SetModel(model ITreeModel) { - C.gtk_tree_view_set_model(v.native(), model.toTreeModel()) -} - -// GetSelection() is a wrapper around gtk_tree_view_get_selection(). -func (v *TreeView) GetSelection() (*TreeSelection, error) { - c := C.gtk_tree_view_get_selection(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapTreeSelection(wrapObject(unsafe.Pointer(c))), nil -} - -// AppendColumn() is a wrapper around gtk_tree_view_append_column(). -func (v *TreeView) AppendColumn(column *TreeViewColumn) int { - c := C.gtk_tree_view_append_column(v.native(), column.native()) - return int(c) -} - -// GetPathAtPos() is a wrapper around gtk_tree_view_get_path_at_pos(). -func (v *TreeView) GetPathAtPos(x, y int, path *TreePath, column *TreeViewColumn, cellX, cellY *int) bool { - var ctp **C.GtkTreePath - if path != nil { - ctp = (**C.GtkTreePath)(unsafe.Pointer(&path.GtkTreePath)) - } else { - ctp = nil - } - - var pctvcol **C.GtkTreeViewColumn - if column != nil { - ctvcol := column.native() - pctvcol = &ctvcol - } else { - pctvcol = nil - } - - return 0 != C.gtk_tree_view_get_path_at_pos( - v.native(), - (C.gint)(x), - (C.gint)(y), - ctp, - pctvcol, - (*C.gint)(unsafe.Pointer(cellX)), - (*C.gint)(unsafe.Pointer(cellY))) -} - -// GetLevelIndentation is a wrapper around gtk_tree_view_get_level_indentation(). -func (v *TreeView) GetLevelIndentation() int { - return int(C.gtk_tree_view_get_level_indentation(v.native())) -} - -// GetShowExpanders is a wrapper around gtk_tree_view_get_show_expanders(). -func (v *TreeView) GetShowExpanders() bool { - return gobool(C.gtk_tree_view_get_show_expanders(v.native())) -} - -// SetLevelIndentation is a wrapper around gtk_tree_view_set_level_indentation(). -func (v *TreeView) SetLevelIndentation(indent int) { - C.gtk_tree_view_set_level_indentation(v.native(), C.gint(indent)) -} - -// SetShowExpanders is a wrapper around gtk_tree_view_set_show_expanders(). -func (v *TreeView) SetShowExpanders(show bool) { - C.gtk_tree_view_set_show_expanders(v.native(), gbool(show)) -} - -// GetHeadersVisible is a wrapper around gtk_tree_view_get_headers_visible(). -func (v *TreeView) GetHeadersVisible() bool { - return gobool(C.gtk_tree_view_get_headers_visible(v.native())) -} - -// SetHeadersVisible is a wrapper around gtk_tree_view_set_headers_visible(). -func (v *TreeView) SetHeadersVisible(show bool) { - C.gtk_tree_view_set_headers_visible(v.native(), gbool(show)) -} - -// ColumnsAutosize is a wrapper around gtk_tree_view_columns_autosize(). -func (v *TreeView) ColumnsAutosize() { - C.gtk_tree_view_columns_autosize(v.native()) -} - -// GetHeadersClickable is a wrapper around gtk_tree_view_get_headers_clickable(). -func (v *TreeView) GetHeadersClickable() bool { - return gobool(C.gtk_tree_view_get_headers_clickable(v.native())) -} - -// SetHeadersClickable is a wrapper around gtk_tree_view_set_headers_clickable(). -func (v *TreeView) SetHeadersClickable(show bool) { - C.gtk_tree_view_set_headers_clickable(v.native(), gbool(show)) -} - -// GetActivateOnSingleClick is a wrapper around gtk_tree_view_get_activate_on_single_click(). -func (v *TreeView) GetActivateOnSingleClick() bool { - return gobool(C.gtk_tree_view_get_activate_on_single_click(v.native())) -} - -// SetActivateOnSingleClick is a wrapper around gtk_tree_view_set_activate_on_single_click(). -func (v *TreeView) SetActivateOnSingleClick(show bool) { - C.gtk_tree_view_set_activate_on_single_click(v.native(), gbool(show)) -} - -// RemoveColumn() is a wrapper around gtk_tree_view_remove_column(). -func (v *TreeView) RemoveColumn(column *TreeViewColumn) int { - return int(C.gtk_tree_view_remove_column(v.native(), column.native())) -} - -// InsertColumn() is a wrapper around gtk_tree_view_insert_column(). -func (v *TreeView) InsertColumn(column *TreeViewColumn, pos int) int { - return int(C.gtk_tree_view_insert_column(v.native(), column.native(), C.gint(pos))) -} - -// GetNColumns() is a wrapper around gtk_tree_view_get_n_columns(). -func (v *TreeView) GetNColumns() uint { - return uint(C.gtk_tree_view_get_n_columns(v.native())) -} - -// GetColumn() is a wrapper around gtk_tree_view_get_column(). -func (v *TreeView) GetColumn(n int) *TreeViewColumn { - c := C.gtk_tree_view_get_column(v.native(), C.gint(n)) - if c == nil { - return nil - } - return wrapTreeViewColumn(wrapObject(unsafe.Pointer(c))) -} - -// MoveColumnAfter() is a wrapper around gtk_tree_view_move_column_after(). -func (v *TreeView) MoveColumnAfter(column *TreeViewColumn, baseColumn *TreeViewColumn) { - C.gtk_tree_view_move_column_after(v.native(), column.native(), baseColumn.native()) -} - -// SetExpanderColumn() is a wrapper around gtk_tree_view_set_expander_column(). -func (v *TreeView) SetExpanderColumn(column *TreeViewColumn) { - C.gtk_tree_view_set_expander_column(v.native(), column.native()) -} - -// GetExpanderColumn() is a wrapper around gtk_tree_view_get_expander_column(). -func (v *TreeView) GetExpanderColumn() *TreeViewColumn { - c := C.gtk_tree_view_get_expander_column(v.native()) - if c == nil { - return nil - } - return wrapTreeViewColumn(wrapObject(unsafe.Pointer(c))) -} - -// ScrollToPoint() is a wrapper around gtk_tree_view_scroll_to_point(). -func (v *TreeView) ScrollToPoint(treeX, treeY int) { - C.gtk_tree_view_scroll_to_point(v.native(), C.gint(treeX), C.gint(treeY)) -} - -// SetCursor() is a wrapper around gtk_tree_view_set_cursor(). -func (v *TreeView) SetCursor(path *TreePath, focusColumn *TreeViewColumn, startEditing bool) { - C.gtk_tree_view_set_cursor(v.native(), path.native(), focusColumn.native(), gbool(startEditing)) -} - -// SetCursorOnCell() is a wrapper around gtk_tree_view_set_cursor_on_cell(). -func (v *TreeView) SetCursorOnCell(path *TreePath, focusColumn *TreeViewColumn, focusCell *CellRenderer, startEditing bool) { - C.gtk_tree_view_set_cursor_on_cell(v.native(), path.native(), focusColumn.native(), focusCell.native(), gbool(startEditing)) -} - -// GetCursor() is a wrapper around gtk_tree_view_get_cursor(). -func (v *TreeView) GetCursor() (p *TreePath, c *TreeViewColumn) { - var path *C.GtkTreePath - var col *C.GtkTreeViewColumn - - C.gtk_tree_view_get_cursor(v.native(), &path, &col) - - if path != nil { - p = &TreePath{path} - runtime.SetFinalizer(p, (*TreePath).free) - } - - if col != nil { - c = wrapTreeViewColumn(wrapObject(unsafe.Pointer(col))) - } - - return -} - -// RowActivated() is a wrapper around gtk_tree_view_row_activated(). -func (v *TreeView) RowActivated(path *TreePath, column *TreeViewColumn) { - C.gtk_tree_view_row_activated(v.native(), path.native(), column.native()) -} - -// ExpandAll() is a wrapper around gtk_tree_view_expand_all(). -func (v *TreeView) ExpandAll() { - C.gtk_tree_view_expand_all(v.native()) -} - -// CollapseAll() is a wrapper around gtk_tree_view_collapse_all(). -func (v *TreeView) CollapseAll() { - C.gtk_tree_view_collapse_all(v.native()) -} - -// ExpandToPath() is a wrapper around gtk_tree_view_expand_to_path(). -func (v *TreeView) ExpandToPath(path *TreePath) { - C.gtk_tree_view_expand_to_path(v.native(), path.native()) -} - -// ExpandRow() is a wrapper around gtk_tree_view_expand_row(). -func (v *TreeView) ExpandRow(path *TreePath, openAll bool) bool { - return gobool(C.gtk_tree_view_expand_row(v.native(), path.native(), gbool(openAll))) -} - -// CollapseRow() is a wrapper around gtk_tree_view_collapse_row(). -func (v *TreeView) CollapseRow(path *TreePath) bool { - return gobool(C.gtk_tree_view_collapse_row(v.native(), path.native())) -} - -// RowExpanded() is a wrapper around gtk_tree_view_row_expanded(). -func (v *TreeView) RowExpanded(path *TreePath) bool { - return gobool(C.gtk_tree_view_row_expanded(v.native(), path.native())) -} - -// SetReorderable is a wrapper around gtk_tree_view_set_reorderable(). -func (v *TreeView) SetReorderable(b bool) { - C.gtk_tree_view_set_reorderable(v.native(), gbool(b)) -} - -// GetReorderable() is a wrapper around gtk_tree_view_get_reorderable(). -func (v *TreeView) GetReorderable() bool { - return gobool(C.gtk_tree_view_get_reorderable(v.native())) -} - -// GetBinWindow() is a wrapper around gtk_tree_view_get_bin_window(). -func (v *TreeView) GetBinWindow() *gdk.Window { - c := C.gtk_tree_view_get_bin_window(v.native()) - if c == nil { - return nil - } - - w := &gdk.Window{wrapObject(unsafe.Pointer(c))} - return w -} - -// SetEnableSearch is a wrapper around gtk_tree_view_set_enable_search(). -func (v *TreeView) SetEnableSearch(b bool) { - C.gtk_tree_view_set_enable_search(v.native(), gbool(b)) -} - -// GetEnableSearch() is a wrapper around gtk_tree_view_get_enable_search(). -func (v *TreeView) GetEnableSearch() bool { - return gobool(C.gtk_tree_view_get_enable_search(v.native())) -} - -// SetSearchColumn is a wrapper around gtk_tree_view_set_search_column(). -func (v *TreeView) SetSearchColumn(c int) { - C.gtk_tree_view_set_search_column(v.native(), C.gint(c)) -} - -// GetSearchColumn() is a wrapper around gtk_tree_view_get_search_column(). -func (v *TreeView) GetSearchColumn() int { - return int(C.gtk_tree_view_get_search_column(v.native())) -} - -// GetSearchEntry() is a wrapper around gtk_tree_view_get_search_entry(). -func (v *TreeView) GetSearchEntry() *Entry { - c := C.gtk_tree_view_get_search_entry(v.native()) - if c == nil { - return nil - } - return wrapEntry(wrapObject(unsafe.Pointer(c))) -} - -// SetSearchEntry() is a wrapper around gtk_tree_view_set_search_entry(). -func (v *TreeView) SetSearchEntry(e *Entry) { - C.gtk_tree_view_set_search_entry(v.native(), e.native()) -} - -// SetFixedHeightMode is a wrapper around gtk_tree_view_set_fixed_height_mode(). -func (v *TreeView) SetFixedHeightMode(b bool) { - C.gtk_tree_view_set_fixed_height_mode(v.native(), gbool(b)) -} - -// GetFixedHeightMode() is a wrapper around gtk_tree_view_get_fixed_height_mode(). -func (v *TreeView) GetFixedHeightMode() bool { - return gobool(C.gtk_tree_view_get_fixed_height_mode(v.native())) -} - -// SetHoverSelection is a wrapper around gtk_tree_view_set_hover_selection(). -func (v *TreeView) SetHoverSelection(b bool) { - C.gtk_tree_view_set_hover_selection(v.native(), gbool(b)) -} - -// GetHoverSelection() is a wrapper around gtk_tree_view_get_hover_selection(). -func (v *TreeView) GetHoverSelection() bool { - return gobool(C.gtk_tree_view_get_hover_selection(v.native())) -} - -// SetHoverExpand is a wrapper around gtk_tree_view_set_hover_expand(). -func (v *TreeView) SetHoverExpand(b bool) { - C.gtk_tree_view_set_hover_expand(v.native(), gbool(b)) -} - -// GetHoverExpand() is a wrapper around gtk_tree_view_get_hover_expand(). -func (v *TreeView) GetHoverExpand() bool { - return gobool(C.gtk_tree_view_get_hover_expand(v.native())) -} - -// SetRubberBanding is a wrapper around gtk_tree_view_set_rubber_banding(). -func (v *TreeView) SetRubberBanding(b bool) { - C.gtk_tree_view_set_rubber_banding(v.native(), gbool(b)) -} - -// GetRubberBanding() is a wrapper around gtk_tree_view_get_rubber_banding(). -func (v *TreeView) GetRubberBanding() bool { - return gobool(C.gtk_tree_view_get_rubber_banding(v.native())) -} - -// IsRubberBandingActive() is a wrapper around gtk_tree_view_is_rubber_banding_active(). -func (v *TreeView) IsRubberBandingActive() bool { - return gobool(C.gtk_tree_view_is_rubber_banding_active(v.native())) -} - -// SetEnableTreeLines is a wrapper around gtk_tree_view_set_enable_tree_lines(). -func (v *TreeView) SetEnableTreeLines(b bool) { - C.gtk_tree_view_set_enable_tree_lines(v.native(), gbool(b)) -} - -// GetEnableTreeLines() is a wrapper around gtk_tree_view_get_enable_tree_lines(). -func (v *TreeView) GetEnableTreeLines() bool { - return gobool(C.gtk_tree_view_get_enable_tree_lines(v.native())) -} - -// GetTooltipColumn() is a wrapper around gtk_tree_view_get_tooltip_column(). -func (v *TreeView) GetTooltipColumn() int { - return int(C.gtk_tree_view_get_tooltip_column(v.native())) -} - -// SetTooltipColumn() is a wrapper around gtk_tree_view_set_tooltip_column(). -func (v *TreeView) SetTooltipColumn(c int) { - C.gtk_tree_view_set_tooltip_column(v.native(), C.gint(c)) -} - -// void gtk_tree_view_set_tooltip_row () -// void gtk_tree_view_set_tooltip_cell () -// gboolean gtk_tree_view_get_tooltip_context () -// void gtk_tree_view_set_grid_lines () -// GtkTreeViewGridLines gtk_tree_view_get_grid_lines () -// void (*GtkTreeDestroyCountFunc) () -// void gtk_tree_view_set_destroy_count_func () -// gboolean (*GtkTreeViewRowSeparatorFunc) () -// GtkTreeViewRowSeparatorFunc gtk_tree_view_get_row_separator_func () -// void gtk_tree_view_set_row_separator_func () -// void (*GtkTreeViewSearchPositionFunc) () -// GtkTreeViewSearchPositionFunc gtk_tree_view_get_search_position_func () -// void gtk_tree_view_set_search_position_func () -// void gtk_tree_view_set_search_equal_func () -// GtkTreeViewSearchEqualFunc gtk_tree_view_get_search_equal_func () -// void gtk_tree_view_map_expanded_rows () -// GList * gtk_tree_view_get_columns () -// gint gtk_tree_view_insert_column_with_attributes () -// gint gtk_tree_view_insert_column_with_data_func () -// void gtk_tree_view_set_column_drag_function () -// void gtk_tree_view_scroll_to_cell () -// gboolean gtk_tree_view_is_blank_at_pos () -// void gtk_tree_view_get_cell_area () -// void gtk_tree_view_get_background_area () -// void gtk_tree_view_get_visible_rect () -// gboolean gtk_tree_view_get_visible_range () -// void gtk_tree_view_convert_bin_window_to_tree_coords () -// void gtk_tree_view_convert_bin_window_to_widget_coords () -// void gtk_tree_view_convert_tree_to_bin_window_coords () -// void gtk_tree_view_convert_tree_to_widget_coords () -// void gtk_tree_view_convert_widget_to_bin_window_coords () -// void gtk_tree_view_convert_widget_to_tree_coords () -// void gtk_tree_view_enable_model_drag_dest () -// void gtk_tree_view_enable_model_drag_source () -// void gtk_tree_view_unset_rows_drag_source () -// void gtk_tree_view_unset_rows_drag_dest () -// void gtk_tree_view_set_drag_dest_row () -// void gtk_tree_view_get_drag_dest_row () -// gboolean gtk_tree_view_get_dest_row_at_pos () -// cairo_surface_t * gtk_tree_view_create_row_drag_icon () diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/tree_view_column.go b/vendor/github.com/gotk3/gotk3.old/gtk/tree_view_column.go deleted file mode 100644 index 24182e8..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/tree_view_column.go +++ /dev/null @@ -1,265 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains accelerator related functions and structures - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -/* - * GtkTreeViewColumn - */ - -// TreeViewColumns is a representation of GTK's GtkTreeViewColumn. -type TreeViewColumn struct { - glib.InitiallyUnowned -} - -// native returns a pointer to the underlying GtkTreeViewColumn. -func (v *TreeViewColumn) native() *C.GtkTreeViewColumn { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkTreeViewColumn(p) -} - -func marshalTreeViewColumn(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapTreeViewColumn(obj), nil -} - -func wrapTreeViewColumn(obj *glib.Object) *TreeViewColumn { - return &TreeViewColumn{glib.InitiallyUnowned{obj}} -} - -// TreeViewColumnNew() is a wrapper around gtk_tree_view_column_new(). -func TreeViewColumnNew() (*TreeViewColumn, error) { - c := C.gtk_tree_view_column_new() - if c == nil { - return nil, nilPtrErr - } - return wrapTreeViewColumn(wrapObject(unsafe.Pointer(c))), nil -} - -// TreeViewColumnNewWithAttribute() is a wrapper around -// gtk_tree_view_column_new_with_attributes() that only sets one -// attribute for one column. -func TreeViewColumnNewWithAttribute(title string, renderer ICellRenderer, attribute string, column int) (*TreeViewColumn, error) { - t_cstr := C.CString(title) - defer C.free(unsafe.Pointer(t_cstr)) - a_cstr := C.CString(attribute) - defer C.free(unsafe.Pointer(a_cstr)) - c := C._gtk_tree_view_column_new_with_attributes_one((*C.gchar)(t_cstr), - renderer.toCellRenderer(), (*C.gchar)(a_cstr), C.gint(column)) - if c == nil { - return nil, nilPtrErr - } - return wrapTreeViewColumn(wrapObject(unsafe.Pointer(c))), nil -} - -// AddAttribute() is a wrapper around gtk_tree_view_column_add_attribute(). -func (v *TreeViewColumn) AddAttribute(renderer ICellRenderer, attribute string, column int) { - cstr := C.CString(attribute) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_tree_view_column_add_attribute(v.native(), - renderer.toCellRenderer(), (*C.gchar)(cstr), C.gint(column)) -} - -// SetExpand() is a wrapper around gtk_tree_view_column_set_expand(). -func (v *TreeViewColumn) SetExpand(expand bool) { - C.gtk_tree_view_column_set_expand(v.native(), gbool(expand)) -} - -// GetExpand() is a wrapper around gtk_tree_view_column_get_expand(). -func (v *TreeViewColumn) GetExpand() bool { - c := C.gtk_tree_view_column_get_expand(v.native()) - return gobool(c) -} - -// SetMinWidth() is a wrapper around gtk_tree_view_column_set_min_width(). -func (v *TreeViewColumn) SetMinWidth(minWidth int) { - C.gtk_tree_view_column_set_min_width(v.native(), C.gint(minWidth)) -} - -// GetMinWidth() is a wrapper around gtk_tree_view_column_get_min_width(). -func (v *TreeViewColumn) GetMinWidth() int { - c := C.gtk_tree_view_column_get_min_width(v.native()) - return int(c) -} - -// PackStart() is a wrapper around gtk_tree_view_column_pack_start(). -func (v *TreeViewColumn) PackStart(cell *CellRenderer, expand bool) { - C.gtk_tree_view_column_pack_start(v.native(), cell.native(), gbool(expand)) -} - -// PackEnd() is a wrapper around gtk_tree_view_column_pack_end(). -func (v *TreeViewColumn) PackEnd(cell *CellRenderer, expand bool) { - C.gtk_tree_view_column_pack_end(v.native(), cell.native(), gbool(expand)) -} - -// Clear() is a wrapper around gtk_tree_view_column_clear(). -func (v *TreeViewColumn) Clear() { - C.gtk_tree_view_column_clear(v.native()) -} - -// ClearAttributes() is a wrapper around gtk_tree_view_column_clear_attributes(). -func (v *TreeViewColumn) ClearAttributes(cell *CellRenderer) { - C.gtk_tree_view_column_clear_attributes(v.native(), cell.native()) -} - -// SetSpacing() is a wrapper around gtk_tree_view_column_set_spacing(). -func (v *TreeViewColumn) SetSpacing(spacing int) { - C.gtk_tree_view_column_set_spacing(v.native(), C.gint(spacing)) -} - -// GetSpacing() is a wrapper around gtk_tree_view_column_get_spacing(). -func (v *TreeViewColumn) GetSpacing() int { - return int(C.gtk_tree_view_column_get_spacing(v.native())) -} - -// SetVisible() is a wrapper around gtk_tree_view_column_set_visible(). -func (v *TreeViewColumn) SetVisible(visible bool) { - C.gtk_tree_view_column_set_visible(v.native(), gbool(visible)) -} - -// GetVisible() is a wrapper around gtk_tree_view_column_get_visible(). -func (v *TreeViewColumn) GetVisible() bool { - return gobool(C.gtk_tree_view_column_get_visible(v.native())) -} - -// SetResizable() is a wrapper around gtk_tree_view_column_set_resizable(). -func (v *TreeViewColumn) SetResizable(resizable bool) { - C.gtk_tree_view_column_set_resizable(v.native(), gbool(resizable)) -} - -// GetResizable() is a wrapper around gtk_tree_view_column_get_resizable(). -func (v *TreeViewColumn) GetResizable() bool { - return gobool(C.gtk_tree_view_column_get_resizable(v.native())) -} - -// GetWidth() is a wrapper around gtk_tree_view_column_get_width(). -func (v *TreeViewColumn) GetWidth() int { - return int(C.gtk_tree_view_column_get_width(v.native())) -} - -// SetFixedWidth() is a wrapper around gtk_tree_view_column_set_fixed_width(). -func (v *TreeViewColumn) SetFixedWidth(w int) { - C.gtk_tree_view_column_set_fixed_width(v.native(), C.gint(w)) -} - -// GetFixedWidth() is a wrapper around gtk_tree_view_column_get_fixed_width(). -func (v *TreeViewColumn) GetFixedWidth() int { - return int(C.gtk_tree_view_column_get_fixed_width(v.native())) -} - -// SetMaxWidth() is a wrapper around gtk_tree_view_column_set_max_width(). -func (v *TreeViewColumn) SetMaxWidth(w int) { - C.gtk_tree_view_column_set_max_width(v.native(), C.gint(w)) -} - -// GetMaxWidth() is a wrapper around gtk_tree_view_column_get_max_width(). -func (v *TreeViewColumn) GetMaxWidth() int { - return int(C.gtk_tree_view_column_get_max_width(v.native())) -} - -// Clicked() is a wrapper around gtk_tree_view_column_clicked(). -func (v *TreeViewColumn) Clicked() { - C.gtk_tree_view_column_clicked(v.native()) -} - -// SetTitle() is a wrapper around gtk_tree_view_column_set_title(). -func (v *TreeViewColumn) SetTitle(t string) { - cstr := (*C.gchar)(C.CString(t)) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_tree_view_column_set_title(v.native(), cstr) -} - -// GetTitle() is a wrapper around gtk_tree_view_column_get_title(). -func (v *TreeViewColumn) GetTitle() string { - return C.GoString((*C.char)(C.gtk_tree_view_column_get_title(v.native()))) -} - -// SetClickable() is a wrapper around gtk_tree_view_column_set_clickable(). -func (v *TreeViewColumn) SetClickable(clickable bool) { - C.gtk_tree_view_column_set_clickable(v.native(), gbool(clickable)) -} - -// GetClickable() is a wrapper around gtk_tree_view_column_get_clickable(). -func (v *TreeViewColumn) GetClickable() bool { - return gobool(C.gtk_tree_view_column_get_clickable(v.native())) -} - -// SetReorderable() is a wrapper around gtk_tree_view_column_set_reorderable(). -func (v *TreeViewColumn) SetReorderable(reorderable bool) { - C.gtk_tree_view_column_set_reorderable(v.native(), gbool(reorderable)) -} - -// GetReorderable() is a wrapper around gtk_tree_view_column_get_reorderable(). -func (v *TreeViewColumn) GetReorderable() bool { - return gobool(C.gtk_tree_view_column_get_reorderable(v.native())) -} - -// SetSortIndicator() is a wrapper around gtk_tree_view_column_set_sort_indicator(). -func (v *TreeViewColumn) SetSortIndicator(reorderable bool) { - C.gtk_tree_view_column_set_sort_indicator(v.native(), gbool(reorderable)) -} - -// GetSortIndicator() is a wrapper around gtk_tree_view_column_get_sort_indicator(). -func (v *TreeViewColumn) GetSortIndicator() bool { - return gobool(C.gtk_tree_view_column_get_sort_indicator(v.native())) -} - -// SetSortColumnID() is a wrapper around gtk_tree_view_column_set_sort_column_id(). -func (v *TreeViewColumn) SetSortColumnID(w int) { - C.gtk_tree_view_column_set_sort_column_id(v.native(), C.gint(w)) -} - -// GetSortColumnID() is a wrapper around gtk_tree_view_column_get_sort_column_id(). -func (v *TreeViewColumn) GetSortColumnID() int { - return int(C.gtk_tree_view_column_get_sort_column_id(v.native())) -} - -// CellIsVisible() is a wrapper around gtk_tree_view_column_cell_is_visible(). -func (v *TreeViewColumn) CellIsVisible() bool { - return gobool(C.gtk_tree_view_column_cell_is_visible(v.native())) -} - -// FocusCell() is a wrapper around gtk_tree_view_column_focus_cell(). -func (v *TreeViewColumn) FocusCell(cell *CellRenderer) { - C.gtk_tree_view_column_focus_cell(v.native(), cell.native()) -} - -// QueueResize() is a wrapper around gtk_tree_view_column_queue_resize(). -func (v *TreeViewColumn) QueueResize() { - C.gtk_tree_view_column_queue_resize(v.native()) -} - -// GetXOffset() is a wrapper around gtk_tree_view_column_get_x_offset(). -func (v *TreeViewColumn) GetXOffset() int { - return int(C.gtk_tree_view_column_get_x_offset(v.native())) -} - -// GtkTreeViewColumn * gtk_tree_view_column_new_with_area () -// void gtk_tree_view_column_set_attributes () -// void gtk_tree_view_column_set_cell_data_func () -// void gtk_tree_view_column_set_sizing () -// GtkTreeViewColumnSizing gtk_tree_view_column_get_sizing () -// void gtk_tree_view_column_set_widget () -// GtkWidget * gtk_tree_view_column_get_widget () -// GtkWidget * gtk_tree_view_column_get_button () -// void gtk_tree_view_column_set_alignment () -// gfloat gtk_tree_view_column_get_alignment () -// void gtk_tree_view_column_set_sort_order () -// GtkSortType gtk_tree_view_column_get_sort_order () -// void gtk_tree_view_column_cell_set_cell_data () -// void gtk_tree_view_column_cell_get_size () -// gboolean gtk_tree_view_column_cell_get_position () -// GtkWidget * gtk_tree_view_column_get_tree_view () diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/version.go b/vendor/github.com/gotk3/gotk3.old/gtk/version.go deleted file mode 100644 index 07fdbd9..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/version.go +++ /dev/null @@ -1,30 +0,0 @@ -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -import "C" -import "errors" - -func CheckVersion(major, minor, micro uint) error { - errChar := C.gtk_check_version(C.guint(major), C.guint(minor), C.guint(micro)) - if errChar == nil { - return nil - } - - return errors.New(C.GoString((*C.char)(errChar))) -} - -func GetMajorVersion() uint { - v := C.gtk_get_major_version() - return uint(v) -} - -func GetMinorVersion() uint { - v := C.gtk_get_minor_version() - return uint(v) -} - -func GetMicroVersion() uint { - v := C.gtk_get_micro_version() - return uint(v) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/widget.go b/vendor/github.com/gotk3/gotk3.old/gtk/widget.go deleted file mode 100644 index a0108a3..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/widget.go +++ /dev/null @@ -1,612 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains accelerator related functions and structures - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "errors" - "unsafe" - - "github.com/gotk3/gotk3/gdk" - "github.com/gotk3/gotk3/glib" -) - -/* - * GtkWidget - */ - -// Widget is a representation of GTK's GtkWidget. -type Widget struct { - glib.InitiallyUnowned -} - -// IWidget is an interface type implemented by all structs -// embedding a Widget. It is meant to be used as an argument type -// for wrapper functions that wrap around a C GTK function taking a -// GtkWidget. -type IWidget interface { - toWidget() *C.GtkWidget - Set(string, interface{}) error -} - -type IWidgetable interface { - toWidget() *C.GtkWidget -} - -func nullableWidget(v IWidgetable) *C.GtkWidget { - if v == nil { - return nil - } - - return v.toWidget() -} - -// native returns a pointer to the underlying GtkWidget. -func (v *Widget) native() *C.GtkWidget { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkWidget(p) -} - -func (v *Widget) toWidget() *C.GtkWidget { - if v == nil { - return nil - } - return v.native() -} - -func marshalWidget(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapWidget(obj), nil -} - -func wrapWidget(obj *glib.Object) *Widget { - return &Widget{glib.InitiallyUnowned{obj}} -} - -// Destroy is a wrapper around gtk_widget_destroy(). -func (v *Widget) Destroy() { - C.gtk_widget_destroy(v.native()) -} - -func (v *Widget) HideOnDelete() { - C._gtk_widget_hide_on_delete(v.native()) -} - -/* TODO -func (v *Widget) DragDestSet(flags DestDefaults, targets []TargetEntry, actions gdk.DragAction) { - C.gtk_drag_dest_set(v.native(), C.GtkDestDefaults(flags), (*C.GtkTargetEntry)(&targets[0]), - C.gint(len(targets)), C.GdkDragAction(actions)) -} -*/ - -// ResetStyle is a wrapper around gtk_widget_reset_style(). -func (v *Widget) ResetStyle() { - C.gtk_widget_reset_style(v.native()) -} - -// InDestruction is a wrapper around gtk_widget_in_destruction(). -func (v *Widget) InDestruction() bool { - return gobool(C.gtk_widget_in_destruction(v.native())) -} - -// TODO(jrick) this may require some rethinking -/* -func (v *Widget) Destroyed(widgetPointer **Widget) { -} -*/ - -// Unparent is a wrapper around gtk_widget_unparent(). -func (v *Widget) Unparent() { - C.gtk_widget_unparent(v.native()) -} - -// Show is a wrapper around gtk_widget_show(). -func (v *Widget) Show() { - C.gtk_widget_show(v.native()) -} - -// Hide is a wrapper around gtk_widget_hide(). -func (v *Widget) Hide() { - C.gtk_widget_hide(v.native()) -} - -// GetCanFocus is a wrapper around gtk_widget_get_can_focus(). -func (v *Widget) GetCanFocus() bool { - c := C.gtk_widget_get_can_focus(v.native()) - return gobool(c) -} - -// SetCanFocus is a wrapper around gtk_widget_set_can_focus(). -func (v *Widget) SetCanFocus(canFocus bool) { - C.gtk_widget_set_can_focus(v.native(), gbool(canFocus)) -} - -// GetCanDefault is a wrapper around gtk_widget_get_can_default(). -func (v *Widget) GetCanDefault() bool { - c := C.gtk_widget_get_can_default(v.native()) - return gobool(c) -} - -// SetCanDefault is a wrapper around gtk_widget_set_can_default(). -func (v *Widget) SetCanDefault(canDefault bool) { - C.gtk_widget_set_can_default(v.native(), gbool(canDefault)) -} - -// GetMapped is a wrapper around gtk_widget_get_mapped(). -func (v *Widget) GetMapped() bool { - c := C.gtk_widget_get_mapped(v.native()) - return gobool(c) -} - -// SetMapped is a wrapper around gtk_widget_set_mapped(). -func (v *Widget) SetMapped(mapped bool) { - C.gtk_widget_set_can_focus(v.native(), gbool(mapped)) -} - -// GetRealized is a wrapper around gtk_widget_get_realized(). -func (v *Widget) GetRealized() bool { - c := C.gtk_widget_get_realized(v.native()) - return gobool(c) -} - -// SetRealized is a wrapper around gtk_widget_set_realized(). -func (v *Widget) SetRealized(realized bool) { - C.gtk_widget_set_realized(v.native(), gbool(realized)) -} - -// GetHasWindow is a wrapper around gtk_widget_get_has_window(). -func (v *Widget) GetHasWindow() bool { - c := C.gtk_widget_get_has_window(v.native()) - return gobool(c) -} - -// SetHasWindow is a wrapper around gtk_widget_set_has_window(). -func (v *Widget) SetHasWindow(hasWindow bool) { - C.gtk_widget_set_has_window(v.native(), gbool(hasWindow)) -} - -// ShowNow is a wrapper around gtk_widget_show_now(). -func (v *Widget) ShowNow() { - C.gtk_widget_show_now(v.native()) -} - -// ShowAll is a wrapper around gtk_widget_show_all(). -func (v *Widget) ShowAll() { - C.gtk_widget_show_all(v.native()) -} - -// SetNoShowAll is a wrapper around gtk_widget_set_no_show_all(). -func (v *Widget) SetNoShowAll(noShowAll bool) { - C.gtk_widget_set_no_show_all(v.native(), gbool(noShowAll)) -} - -// GetNoShowAll is a wrapper around gtk_widget_get_no_show_all(). -func (v *Widget) GetNoShowAll() bool { - c := C.gtk_widget_get_no_show_all(v.native()) - return gobool(c) -} - -// Map is a wrapper around gtk_widget_map(). -func (v *Widget) Map() { - C.gtk_widget_map(v.native()) -} - -// Unmap is a wrapper around gtk_widget_unmap(). -func (v *Widget) Unmap() { - C.gtk_widget_unmap(v.native()) -} - -// QueueDrawArea is a wrapper aroung gtk_widget_queue_draw_area(). -func (v *Widget) QueueDrawArea(x, y, w, h int) { - C.gtk_widget_queue_draw_area(v.native(), C.gint(x), C.gint(y), C.gint(w), C.gint(h)) -} - -//void gtk_widget_realize(GtkWidget *widget); -//void gtk_widget_unrealize(GtkWidget *widget); -//void gtk_widget_draw(GtkWidget *widget, cairo_t *cr); -//void gtk_widget_queue_resize(GtkWidget *widget); -//void gtk_widget_queue_resize_no_redraw(GtkWidget *widget); -//GdkFrameClock *gtk_widget_get_frame_clock(GtkWidget *widget); -//guint gtk_widget_add_tick_callback (GtkWidget *widget, -// GtkTickCallback callback, -// gpointer user_data, -// GDestroyNotify notify); -//void gtk_widget_remove_tick_callback(GtkWidget *widget, guint id); - -// TODO(jrick) GtkAllocation -/* -func (v *Widget) SizeAllocate() { -} -*/ - -// Allocation is a representation of GTK's GtkAllocation type. -type Allocation struct { - gdk.Rectangle -} - -// Native returns a pointer to the underlying GtkAllocation. -func (v *Allocation) native() *C.GtkAllocation { - return (*C.GtkAllocation)(unsafe.Pointer(&v.GdkRectangle)) -} - -// GetAllocatedWidth() is a wrapper around gtk_widget_get_allocated_width(). -func (v *Widget) GetAllocatedWidth() int { - return int(C.gtk_widget_get_allocated_width(v.native())) -} - -// GetAllocatedHeight() is a wrapper around gtk_widget_get_allocated_height(). -func (v *Widget) GetAllocatedHeight() int { - return int(C.gtk_widget_get_allocated_height(v.native())) -} - -// Event() is a wrapper around gtk_widget_event(). -func (v *Widget) Event(event *gdk.Event) bool { - c := C.gtk_widget_event(v.native(), - (*C.GdkEvent)(unsafe.Pointer(event.Native()))) - return gobool(c) -} - -// Activate() is a wrapper around gtk_widget_activate(). -func (v *Widget) Activate() bool { - return gobool(C.gtk_widget_activate(v.native())) -} - -// TODO(jrick) GdkRectangle -/* -func (v *Widget) Intersect() { -} -*/ - -// IsFocus() is a wrapper around gtk_widget_is_focus(). -func (v *Widget) IsFocus() bool { - return gobool(C.gtk_widget_is_focus(v.native())) -} - -// GrabFocus() is a wrapper around gtk_widget_grab_focus(). -func (v *Widget) GrabFocus() { - C.gtk_widget_grab_focus(v.native()) -} - -// GrabDefault() is a wrapper around gtk_widget_grab_default(). -func (v *Widget) GrabDefault() { - C.gtk_widget_grab_default(v.native()) -} - -// SetName() is a wrapper around gtk_widget_set_name(). -func (v *Widget) SetName(name string) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_widget_set_name(v.native(), (*C.gchar)(cstr)) -} - -// GetName() is a wrapper around gtk_widget_get_name(). A non-nil -// error is returned in the case that gtk_widget_get_name returns NULL to -// differentiate between NULL and an empty string. -func (v *Widget) GetName() (string, error) { - c := C.gtk_widget_get_name(v.native()) - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// GetSensitive is a wrapper around gtk_widget_get_sensitive(). -func (v *Widget) GetSensitive() bool { - c := C.gtk_widget_get_sensitive(v.native()) - return gobool(c) -} - -// IsSensitive is a wrapper around gtk_widget_is_sensitive(). -func (v *Widget) IsSensitive() bool { - c := C.gtk_widget_is_sensitive(v.native()) - return gobool(c) -} - -// SetSensitive is a wrapper around gtk_widget_set_sensitive(). -func (v *Widget) SetSensitive(sensitive bool) { - C.gtk_widget_set_sensitive(v.native(), gbool(sensitive)) -} - -// GetVisible is a wrapper around gtk_widget_get_visible(). -func (v *Widget) GetVisible() bool { - c := C.gtk_widget_get_visible(v.native()) - return gobool(c) -} - -// SetVisible is a wrapper around gtk_widget_set_visible(). -func (v *Widget) SetVisible(visible bool) { - C.gtk_widget_set_visible(v.native(), gbool(visible)) -} - -// SetParent is a wrapper around gtk_widget_set_parent(). -func (v *Widget) SetParent(parent IWidget) { - C.gtk_widget_set_parent(v.native(), parent.toWidget()) -} - -// GetParent is a wrapper around gtk_widget_get_parent(). -func (v *Widget) GetParent() (*Widget, error) { - c := C.gtk_widget_get_parent(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// SetSizeRequest is a wrapper around gtk_widget_set_size_request(). -func (v *Widget) SetSizeRequest(width, height int) { - C.gtk_widget_set_size_request(v.native(), C.gint(width), C.gint(height)) -} - -// GetSizeRequest is a wrapper around gtk_widget_get_size_request(). -func (v *Widget) GetSizeRequest() (width, height int) { - var w, h C.gint - C.gtk_widget_get_size_request(v.native(), &w, &h) - return int(w), int(h) -} - -// SetParentWindow is a wrapper around gtk_widget_set_parent_window(). -func (v *Widget) SetParentWindow(parentWindow *gdk.Window) { - C.gtk_widget_set_parent_window(v.native(), - (*C.GdkWindow)(unsafe.Pointer(parentWindow.Native()))) -} - -// GetParentWindow is a wrapper around gtk_widget_get_parent_window(). -func (v *Widget) GetParentWindow() (*gdk.Window, error) { - c := C.gtk_widget_get_parent_window(v.native()) - if v == nil { - return nil, nilPtrErr - } - - w := &gdk.Window{wrapObject(unsafe.Pointer(c))} - return w, nil -} - -// SetEvents is a wrapper around gtk_widget_set_events(). -func (v *Widget) SetEvents(events int) { - C.gtk_widget_set_events(v.native(), C.gint(events)) -} - -// GetEvents is a wrapper around gtk_widget_get_events(). -func (v *Widget) GetEvents() int { - return int(C.gtk_widget_get_events(v.native())) -} - -// AddEvents is a wrapper around gtk_widget_add_events(). -func (v *Widget) AddEvents(events int) { - C.gtk_widget_add_events(v.native(), C.gint(events)) -} - -// HasDefault is a wrapper around gtk_widget_has_default(). -func (v *Widget) HasDefault() bool { - c := C.gtk_widget_has_default(v.native()) - return gobool(c) -} - -// HasFocus is a wrapper around gtk_widget_has_focus(). -func (v *Widget) HasFocus() bool { - c := C.gtk_widget_has_focus(v.native()) - return gobool(c) -} - -// HasVisibleFocus is a wrapper around gtk_widget_has_visible_focus(). -func (v *Widget) HasVisibleFocus() bool { - c := C.gtk_widget_has_visible_focus(v.native()) - return gobool(c) -} - -// HasGrab is a wrapper around gtk_widget_has_grab(). -func (v *Widget) HasGrab() bool { - c := C.gtk_widget_has_grab(v.native()) - return gobool(c) -} - -// IsDrawable is a wrapper around gtk_widget_is_drawable(). -func (v *Widget) IsDrawable() bool { - c := C.gtk_widget_is_drawable(v.native()) - return gobool(c) -} - -// IsToplevel is a wrapper around gtk_widget_is_toplevel(). -func (v *Widget) IsToplevel() bool { - c := C.gtk_widget_is_toplevel(v.native()) - return gobool(c) -} - -// TODO(jrick) GdkEventMask -/* -func (v *Widget) SetDeviceEvents() { -} -*/ - -// TODO(jrick) GdkEventMask -/* -func (v *Widget) GetDeviceEvents() { -} -*/ - -// TODO(jrick) GdkEventMask -/* -func (v *Widget) AddDeviceEvents() { -} -*/ - -// SetDeviceEnabled is a wrapper around gtk_widget_set_device_enabled(). -func (v *Widget) SetDeviceEnabled(device *gdk.Device, enabled bool) { - C.gtk_widget_set_device_enabled(v.native(), - (*C.GdkDevice)(unsafe.Pointer(device.Native())), gbool(enabled)) -} - -// GetDeviceEnabled is a wrapper around gtk_widget_get_device_enabled(). -func (v *Widget) GetDeviceEnabled(device *gdk.Device) bool { - c := C.gtk_widget_get_device_enabled(v.native(), - (*C.GdkDevice)(unsafe.Pointer(device.Native()))) - return gobool(c) -} - -// GetToplevel is a wrapper around gtk_widget_get_toplevel(). -func (v *Widget) GetToplevel() (*Widget, error) { - c := C.gtk_widget_get_toplevel(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// GetTooltipText is a wrapper around gtk_widget_get_tooltip_text(). -// A non-nil error is returned in the case that -// gtk_widget_get_tooltip_text returns NULL to differentiate between NULL -// and an empty string. -func (v *Widget) GetTooltipText() (string, error) { - c := C.gtk_widget_get_tooltip_text(v.native()) - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// SetTooltipText is a wrapper around gtk_widget_set_tooltip_text(). -func (v *Widget) SetTooltipText(text string) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_widget_set_tooltip_text(v.native(), (*C.gchar)(cstr)) -} - -// GetHAlign is a wrapper around gtk_widget_get_halign(). -func (v *Widget) GetHAlign() Align { - c := C.gtk_widget_get_halign(v.native()) - return Align(c) -} - -// SetHAlign is a wrapper around gtk_widget_set_halign(). -func (v *Widget) SetHAlign(align Align) { - C.gtk_widget_set_halign(v.native(), C.GtkAlign(align)) -} - -// GetVAlign is a wrapper around gtk_widget_get_valign(). -func (v *Widget) GetVAlign() Align { - c := C.gtk_widget_get_valign(v.native()) - return Align(c) -} - -// SetVAlign is a wrapper around gtk_widget_set_valign(). -func (v *Widget) SetVAlign(align Align) { - C.gtk_widget_set_valign(v.native(), C.GtkAlign(align)) -} - -// GetMarginTop is a wrapper around gtk_widget_get_margin_top(). -func (v *Widget) GetMarginTop() int { - c := C.gtk_widget_get_margin_top(v.native()) - return int(c) -} - -// SetMarginTop is a wrapper around gtk_widget_set_margin_top(). -func (v *Widget) SetMarginTop(margin int) { - C.gtk_widget_set_margin_top(v.native(), C.gint(margin)) -} - -// GetMarginBottom is a wrapper around gtk_widget_get_margin_bottom(). -func (v *Widget) GetMarginBottom() int { - c := C.gtk_widget_get_margin_bottom(v.native()) - return int(c) -} - -// SetMarginBottom is a wrapper around gtk_widget_set_margin_bottom(). -func (v *Widget) SetMarginBottom(margin int) { - C.gtk_widget_set_margin_bottom(v.native(), C.gint(margin)) -} - -// GetHExpand is a wrapper around gtk_widget_get_hexpand(). -func (v *Widget) GetHExpand() bool { - c := C.gtk_widget_get_hexpand(v.native()) - return gobool(c) -} - -// SetHExpand is a wrapper around gtk_widget_set_hexpand(). -func (v *Widget) SetHExpand(expand bool) { - C.gtk_widget_set_hexpand(v.native(), gbool(expand)) -} - -// GetVExpand is a wrapper around gtk_widget_get_vexpand(). -func (v *Widget) GetVExpand() bool { - c := C.gtk_widget_get_vexpand(v.native()) - return gobool(c) -} - -// SetVExpand is a wrapper around gtk_widget_set_vexpand(). -func (v *Widget) SetVExpand(expand bool) { - C.gtk_widget_set_vexpand(v.native(), gbool(expand)) -} - -// TranslateCoordinates is a wrapper around gtk_widget_translate_coordinates(). -func (v *Widget) TranslateCoordinates(dest IWidget, srcX, srcY int) (destX, destY int, e error) { - cdest := nullableWidget(dest) - - var cdestX, cdestY C.gint - c := C.gtk_widget_translate_coordinates(v.native(), cdest, C.gint(srcX), C.gint(srcY), &cdestX, &cdestY) - if !gobool(c) { - return 0, 0, errors.New("translate coordinates failed") - } - return int(cdestX), int(cdestY), nil -} - -// SetVisual is a wrapper around gtk_widget_set_visual(). -func (v *Widget) SetVisual(visual *gdk.Visual) { - C.gtk_widget_set_visual(v.native(), - (*C.GdkVisual)(unsafe.Pointer(visual.Native()))) -} - -// SetAppPaintable is a wrapper around gtk_widget_set_app_paintable(). -func (v *Widget) SetAppPaintable(paintable bool) { - C.gtk_widget_set_app_paintable(v.native(), gbool(paintable)) -} - -// GetAppPaintable is a wrapper around gtk_widget_get_app_paintable(). -func (v *Widget) GetAppPaintable() bool { - c := C.gtk_widget_get_app_paintable(v.native()) - return gobool(c) -} - -// QueueDraw is a wrapper around gtk_widget_queue_draw(). -func (v *Widget) QueueDraw() { - C.gtk_widget_queue_draw(v.native()) -} - -// GetAllocation is a wrapper around gtk_widget_get_allocation(). -func (v *Widget) GetAllocation() *Allocation { - var a Allocation - C.gtk_widget_get_allocation(v.native(), a.native()) - return &a -} - -// SetAllocation is a wrapper around gtk_widget_set_allocation(). -func (v *Widget) SetAllocation(allocation *Allocation) { - C.gtk_widget_set_allocation(v.native(), allocation.native()) -} - -// SizeAllocate is a wrapper around gtk_widget_size_allocate(). -func (v *Widget) SizeAllocate(allocation *Allocation) { - C.gtk_widget_size_allocate(v.native(), allocation.native()) -} - -// SetStateFlags is a wrapper around gtk_widget_set_state_flags(). -func (v *Widget) SetStateFlags(stateFlags StateFlags, clear bool) { - C.gtk_widget_set_state_flags(v.native(), C.GtkStateFlags(stateFlags), gbool(clear)) -} - -// GetWindow is a wrapper around gtk_widget_get_window(). -func (v *Widget) GetWindow() (*gdk.Window, error) { - c := C.gtk_widget_get_window(v.native()) - if c == nil { - return nil, nilPtrErr - } - - w := &gdk.Window{wrapObject(unsafe.Pointer(c))} - return w, nil -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/widget_since_3_12.go b/vendor/github.com/gotk3/gotk3.old/gtk/widget_since_3_12.go deleted file mode 100644 index 1bab6a2..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/widget_since_3_12.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// This file includes wrapers for symbols included since GTK 3.12, and -// and should not be included in a build intended to target any older GTK -// versions. To target an older build, such as 3.10, use -// 'go build -tags gtk_3_10'. Otherwise, if no build tags are used, GTK 3.12 -// is assumed and this file is built. -// +build !gtk_3_6,!gtk_3_8,!gtk_3_10 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -import "C" - -func (v *Widget) SetMarginStart(margin int) { - C.gtk_widget_set_margin_start(v.native(), C.gint(margin)) -} - -func (v *Widget) GetMarginStart() int { - c := C.gtk_widget_get_margin_start(v.native()) - return int(c) -} - -func (v *Widget) SetMarginEnd(margin int) { - C.gtk_widget_set_margin_end(v.native(), C.gint(margin)) -} - -func (v *Widget) GetMarginEnd() int { - c := C.gtk_widget_get_margin_end(v.native()) - return int(c) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/widget_since_3_8.go b/vendor/github.com/gotk3/gotk3.old/gtk/widget_since_3_8.go deleted file mode 100644 index c518764..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/widget_since_3_8.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// This file includes wrapers for symbols included since GTK 3.8, and -// and should not be included in a build intended to target any older GTK -// versions. To target an older build, such as 3.8, use -// 'go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.18 -// is assumed and this file is built. -// +build !gtk_3_6 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -import "C" - -/* - * GtkWidget - */ - -// IsVisible is a wrapper around gtk_widget_is_visible(). -func (v *Widget) IsVisible() bool { - c := C.gtk_widget_is_visible(v.native()) - return gobool(c) -} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/window.go b/vendor/github.com/gotk3/gotk3.old/gtk/window.go deleted file mode 100644 index 7b9a5f2..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/window.go +++ /dev/null @@ -1,609 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains accelerator related functions and structures - -package gtk - -// #include -// #include "gtk.go.h" -import "C" -import ( - "errors" - "unsafe" - - "github.com/gotk3/gotk3/gdk" - "github.com/gotk3/gotk3/glib" -) - -/* - * GtkWindow - */ - -// Window is a representation of GTK's GtkWindow. -type Window struct { - Bin -} - -// IWindow is an interface type implemented by all structs embedding a -// Window. It is meant to be used as an argument type for wrapper -// functions that wrap around a C GTK function taking a GtkWindow. -type IWindow interface { - toWindow() *C.GtkWindow -} - -// native returns a pointer to the underlying GtkWindow. -func (v *Window) native() *C.GtkWindow { - if v == nil || v.GObject == nil { - return nil - } - p := unsafe.Pointer(v.GObject) - return C.toGtkWindow(p) -} - -func (v *Window) toWindow() *C.GtkWindow { - if v == nil { - return nil - } - return v.native() -} - -func marshalWindow(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapWindow(obj), nil -} - -func wrapWindow(obj *glib.Object) *Window { - return &Window{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} -} - -// WindowNew is a wrapper around gtk_window_new(). -func WindowNew(t WindowType) (*Window, error) { - c := C.gtk_window_new(C.GtkWindowType(t)) - if c == nil { - return nil, nilPtrErr - } - return wrapWindow(wrapObject(unsafe.Pointer(c))), nil -} - -// SetTitle is a wrapper around gtk_window_set_title(). -func (v *Window) SetTitle(title string) { - cstr := C.CString(title) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_window_set_title(v.native(), (*C.gchar)(cstr)) -} - -// SetResizable is a wrapper around gtk_window_set_resizable(). -func (v *Window) SetResizable(resizable bool) { - C.gtk_window_set_resizable(v.native(), gbool(resizable)) -} - -// GetResizable is a wrapper around gtk_window_get_resizable(). -func (v *Window) GetResizable() bool { - c := C.gtk_window_get_resizable(v.native()) - return gobool(c) -} - -// ActivateFocus is a wrapper around gtk_window_activate_focus(). -func (v *Window) ActivateFocus() bool { - c := C.gtk_window_activate_focus(v.native()) - return gobool(c) -} - -// ActivateDefault is a wrapper around gtk_window_activate_default(). -func (v *Window) ActivateDefault() bool { - c := C.gtk_window_activate_default(v.native()) - return gobool(c) -} - -// SetModal is a wrapper around gtk_window_set_modal(). -func (v *Window) SetModal(modal bool) { - C.gtk_window_set_modal(v.native(), gbool(modal)) -} - -// SetDefaultSize is a wrapper around gtk_window_set_default_size(). -func (v *Window) SetDefaultSize(width, height int) { - C.gtk_window_set_default_size(v.native(), C.gint(width), C.gint(height)) -} - -// SetDefaultGeometry is a wrapper around gtk_window_set_default_geometry(). -func (v *Window) SetDefaultGeometry(width, height int) { - C.gtk_window_set_default_geometry(v.native(), C.gint(width), - C.gint(height)) -} - -// GetScreen is a wrapper around gtk_window_get_screen(). -func (v *Window) GetScreen() (*gdk.Screen, error) { - c := C.gtk_window_get_screen(v.native()) - if c == nil { - return nil, nilPtrErr - } - - s := &gdk.Screen{wrapObject(unsafe.Pointer(c))} - return s, nil -} - -// SetIcon is a wrapper around gtk_window_set_icon(). -func (v *Window) SetIcon(icon *gdk.Pixbuf) { - iconPtr := (*C.GdkPixbuf)(unsafe.Pointer(icon.Native())) - C.gtk_window_set_icon(v.native(), iconPtr) -} - -// WindowSetDefaultIcon is a wrapper around gtk_window_set_default_icon(). -func WindowSetDefaultIcon(icon *gdk.Pixbuf) { - iconPtr := (*C.GdkPixbuf)(unsafe.Pointer(icon.Native())) - C.gtk_window_set_default_icon(iconPtr) -} - -// TODO(jrick) GdkGeometry GdkWindowHints. -/* -func (v *Window) SetGeometryHints() { -} -*/ - -// SetGravity is a wrapper around gtk_window_set_gravity(). -func (v *Window) SetGravity(gravity gdk.GdkGravity) { - C.gtk_window_set_gravity(v.native(), C.GdkGravity(gravity)) -} - -// TODO(jrick) GdkGravity. -/* -func (v *Window) GetGravity() { -} -*/ - -// SetPosition is a wrapper around gtk_window_set_position(). -func (v *Window) SetPosition(position WindowPosition) { - C.gtk_window_set_position(v.native(), C.GtkWindowPosition(position)) -} - -// SetTransientFor is a wrapper around gtk_window_set_transient_for(). -func (v *Window) SetTransientFor(parent IWindow) { - var pw *C.GtkWindow = nil - if parent != nil { - pw = parent.toWindow() - } - C.gtk_window_set_transient_for(v.native(), pw) -} - -// SetDestroyWithParent is a wrapper around -// gtk_window_set_destroy_with_parent(). -func (v *Window) SetDestroyWithParent(setting bool) { - C.gtk_window_set_destroy_with_parent(v.native(), gbool(setting)) -} - -// SetHideTitlebarWhenMaximized is a wrapper around -// gtk_window_set_hide_titlebar_when_maximized(). -func (v *Window) SetHideTitlebarWhenMaximized(setting bool) { - C.gtk_window_set_hide_titlebar_when_maximized(v.native(), - gbool(setting)) -} - -// IsActive is a wrapper around gtk_window_is_active(). -func (v *Window) IsActive() bool { - c := C.gtk_window_is_active(v.native()) - return gobool(c) -} - -// HasToplevelFocus is a wrapper around gtk_window_has_toplevel_focus(). -func (v *Window) HasToplevelFocus() bool { - c := C.gtk_window_has_toplevel_focus(v.native()) - return gobool(c) -} - -// GetFocus is a wrapper around gtk_window_get_focus(). -func (v *Window) GetFocus() (*Widget, error) { - c := C.gtk_window_get_focus(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// SetFocus is a wrapper around gtk_window_set_focus(). -func (v *Window) SetFocus(w *Widget) { - C.gtk_window_set_focus(v.native(), w.native()) -} - -// GetDefaultWidget is a wrapper arround gtk_window_get_default_widget(). -func (v *Window) GetDefaultWidget() *Widget { - c := C.gtk_window_get_default_widget(v.native()) - if c == nil { - return nil - } - obj := wrapObject(unsafe.Pointer(c)) - return wrapWidget(obj) -} - -// SetDefault is a wrapper arround gtk_window_set_default(). -func (v *Window) SetDefault(widget IWidget) { - C.gtk_window_set_default(v.native(), widget.toWidget()) -} - -// Present is a wrapper around gtk_window_present(). -func (v *Window) Present() { - C.gtk_window_present(v.native()) -} - -// PresentWithTime is a wrapper around gtk_window_present_with_time(). -func (v *Window) PresentWithTime(ts uint32) { - C.gtk_window_present_with_time(v.native(), C.guint32(ts)) -} - -// Iconify is a wrapper around gtk_window_iconify(). -func (v *Window) Iconify() { - C.gtk_window_iconify(v.native()) -} - -// Deiconify is a wrapper around gtk_window_deiconify(). -func (v *Window) Deiconify() { - C.gtk_window_deiconify(v.native()) -} - -// Stick is a wrapper around gtk_window_stick(). -func (v *Window) Stick() { - C.gtk_window_stick(v.native()) -} - -// Unstick is a wrapper around gtk_window_unstick(). -func (v *Window) Unstick() { - C.gtk_window_unstick(v.native()) -} - -// Maximize is a wrapper around gtk_window_maximize(). -func (v *Window) Maximize() { - C.gtk_window_maximize(v.native()) -} - -// Unmaximize is a wrapper around gtk_window_unmaximize(). -func (v *Window) Unmaximize() { - C.gtk_window_unmaximize(v.native()) -} - -// Fullscreen is a wrapper around gtk_window_fullscreen(). -func (v *Window) Fullscreen() { - C.gtk_window_fullscreen(v.native()) -} - -// Unfullscreen is a wrapper around gtk_window_unfullscreen(). -func (v *Window) Unfullscreen() { - C.gtk_window_unfullscreen(v.native()) -} - -// SetKeepAbove is a wrapper around gtk_window_set_keep_above(). -func (v *Window) SetKeepAbove(setting bool) { - C.gtk_window_set_keep_above(v.native(), gbool(setting)) -} - -// SetKeepBelow is a wrapper around gtk_window_set_keep_below(). -func (v *Window) SetKeepBelow(setting bool) { - C.gtk_window_set_keep_below(v.native(), gbool(setting)) -} - -// SetDecorated is a wrapper around gtk_window_set_decorated(). -func (v *Window) SetDecorated(setting bool) { - C.gtk_window_set_decorated(v.native(), gbool(setting)) -} - -// SetDeletable is a wrapper around gtk_window_set_deletable(). -func (v *Window) SetDeletable(setting bool) { - C.gtk_window_set_deletable(v.native(), gbool(setting)) -} - -// SetSkipTaskbarHint is a wrapper around gtk_window_set_skip_taskbar_hint(). -func (v *Window) SetSkipTaskbarHint(setting bool) { - C.gtk_window_set_skip_taskbar_hint(v.native(), gbool(setting)) -} - -// SetSkipPagerHint is a wrapper around gtk_window_set_skip_pager_hint(). -func (v *Window) SetSkipPagerHint(setting bool) { - C.gtk_window_set_skip_pager_hint(v.native(), gbool(setting)) -} - -// SetUrgencyHint is a wrapper around gtk_window_set_urgency_hint(). -func (v *Window) SetUrgencyHint(setting bool) { - C.gtk_window_set_urgency_hint(v.native(), gbool(setting)) -} - -// SetAcceptFocus is a wrapper around gtk_window_set_accept_focus(). -func (v *Window) SetAcceptFocus(setting bool) { - C.gtk_window_set_accept_focus(v.native(), gbool(setting)) -} - -// SetFocusOnMap is a wrapper around gtk_window_set_focus_on_map(). -func (v *Window) SetFocusOnMap(setting bool) { - C.gtk_window_set_focus_on_map(v.native(), gbool(setting)) -} - -// SetStartupID is a wrapper around gtk_window_set_startup_id(). -func (v *Window) SetStartupID(sid string) { - cstr := (*C.gchar)(C.CString(sid)) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_window_set_startup_id(v.native(), cstr) -} - -// SetRole is a wrapper around gtk_window_set_role(). -func (v *Window) SetRole(s string) { - cstr := (*C.gchar)(C.CString(s)) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_window_set_role(v.native(), cstr) -} - -// SetWMClass is a wrapper around gtk_window_set_wmclass(). -func (v *Window) SetWMClass(name, class string) { - cName := C.CString(name) - defer C.free(unsafe.Pointer(cName)) - cClass := C.CString(class) - defer C.free(unsafe.Pointer(cClass)) - C.gtk_window_set_wmclass(v.native(), (*C.gchar)(cName), (*C.gchar)(cClass)) -} - -// GetDecorated is a wrapper around gtk_window_get_decorated(). -func (v *Window) GetDecorated() bool { - c := C.gtk_window_get_decorated(v.native()) - return gobool(c) -} - -// GetDeletable is a wrapper around gtk_window_get_deletable(). -func (v *Window) GetDeletable() bool { - c := C.gtk_window_get_deletable(v.native()) - return gobool(c) -} - -// WindowGetDefaultIconName is a wrapper around gtk_window_get_default_icon_name(). -func WindowGetDefaultIconName() (string, error) { - return stringReturn(C.gtk_window_get_default_icon_name()) -} - -// GetDefaultSize is a wrapper around gtk_window_get_default_size(). -func (v *Window) GetDefaultSize() (width, height int) { - var w, h C.gint - C.gtk_window_get_default_size(v.native(), &w, &h) - return int(w), int(h) -} - -// GetDestroyWithParent is a wrapper around -// gtk_window_get_destroy_with_parent(). -func (v *Window) GetDestroyWithParent() bool { - c := C.gtk_window_get_destroy_with_parent(v.native()) - return gobool(c) -} - -// GetHideTitlebarWhenMaximized is a wrapper around -// gtk_window_get_hide_titlebar_when_maximized(). -func (v *Window) GetHideTitlebarWhenMaximized() bool { - c := C.gtk_window_get_hide_titlebar_when_maximized(v.native()) - return gobool(c) -} - -// GetIcon is a wrapper around gtk_window_get_icon(). -func (v *Window) GetIcon() (*gdk.Pixbuf, error) { - c := C.gtk_window_get_icon(v.native()) - if c == nil { - return nil, nilPtrErr - } - - p := &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))} - return p, nil -} - -// GetIconName is a wrapper around gtk_window_get_icon_name(). -func (v *Window) GetIconName() (string, error) { - return stringReturn(C.gtk_window_get_icon_name(v.native())) -} - -// GetModal is a wrapper around gtk_window_get_modal(). -func (v *Window) GetModal() bool { - c := C.gtk_window_get_modal(v.native()) - return gobool(c) -} - -// GetPosition is a wrapper around gtk_window_get_position(). -func (v *Window) GetPosition() (root_x, root_y int) { - var x, y C.gint - C.gtk_window_get_position(v.native(), &x, &y) - return int(x), int(y) -} - -func stringReturn(c *C.gchar) (string, error) { - if c == nil { - return "", nilPtrErr - } - return C.GoString((*C.char)(c)), nil -} - -// GetRole is a wrapper around gtk_window_get_role(). -func (v *Window) GetRole() (string, error) { - return stringReturn(C.gtk_window_get_role(v.native())) -} - -// GetSize is a wrapper around gtk_window_get_size(). -func (v *Window) GetSize() (width, height int) { - var w, h C.gint - C.gtk_window_get_size(v.native(), &w, &h) - return int(w), int(h) -} - -// GetTitle is a wrapper around gtk_window_get_title(). -func (v *Window) GetTitle() (string, error) { - return stringReturn(C.gtk_window_get_title(v.native())) -} - -// GetTransientFor is a wrapper around gtk_window_get_transient_for(). -func (v *Window) GetTransientFor() (*Window, error) { - c := C.gtk_window_get_transient_for(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapWindow(wrapObject(unsafe.Pointer(c))), nil -} - -// GetAttachedTo is a wrapper around gtk_window_get_attached_to(). -func (v *Window) GetAttachedTo() (*Widget, error) { - c := C.gtk_window_get_attached_to(v.native()) - if c == nil { - return nil, nilPtrErr - } - return wrapWidget(wrapObject(unsafe.Pointer(c))), nil -} - -// GetSkipTaskbarHint is a wrapper around gtk_window_get_skip_taskbar_hint(). -func (v *Window) GetSkipTaskbarHint() bool { - c := C.gtk_window_get_skip_taskbar_hint(v.native()) - return gobool(c) -} - -// GetSkipPagerHint is a wrapper around gtk_window_get_skip_pager_hint(). -func (v *Window) GetSkipPagerHint() bool { - c := C.gtk_window_get_skip_taskbar_hint(v.native()) - return gobool(c) -} - -// GetUrgencyHint is a wrapper around gtk_window_get_urgency_hint(). -func (v *Window) GetUrgencyHint() bool { - c := C.gtk_window_get_urgency_hint(v.native()) - return gobool(c) -} - -// GetAcceptFocus is a wrapper around gtk_window_get_accept_focus(). -func (v *Window) GetAcceptFocus() bool { - c := C.gtk_window_get_accept_focus(v.native()) - return gobool(c) -} - -// GetFocusOnMap is a wrapper around gtk_window_get_focus_on_map(). -func (v *Window) GetFocusOnMap() bool { - c := C.gtk_window_get_focus_on_map(v.native()) - return gobool(c) -} - -// HasGroup is a wrapper around gtk_window_has_group(). -func (v *Window) HasGroup() bool { - c := C.gtk_window_has_group(v.native()) - return gobool(c) -} - -// Move is a wrapper around gtk_window_move(). -func (v *Window) Move(x, y int) { - C.gtk_window_move(v.native(), C.gint(x), C.gint(y)) -} - -// Resize is a wrapper around gtk_window_resize(). -func (v *Window) Resize(width, height int) { - C.gtk_window_resize(v.native(), C.gint(width), C.gint(height)) -} - -// ResizeToGeometry is a wrapper around gtk_window_resize_to_geometry(). -func (v *Window) ResizeToGeometry(width, height int) { - C.gtk_window_resize_to_geometry(v.native(), C.gint(width), C.gint(height)) -} - -// WindowSetDefaultIconFromFile is a wrapper around gtk_window_set_default_icon_from_file(). -func WindowSetDefaultIconFromFile(file string) error { - cstr := C.CString(file) - defer C.free(unsafe.Pointer(cstr)) - var err *C.GError = nil - res := C.gtk_window_set_default_icon_from_file((*C.gchar)(cstr), &err) - if res == 0 { - defer C.g_error_free(err) - return errors.New(C.GoString((*C.char)(err.message))) - } - return nil -} - -// WindowSetDefaultIconName is a wrapper around gtk_window_set_default_icon_name(). -func WindowSetDefaultIconName(s string) { - cstr := (*C.gchar)(C.CString(s)) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_window_set_default_icon_name(cstr) -} - -// SetIconFromFile is a wrapper around gtk_window_set_icon_from_file(). -func (v *Window) SetIconFromFile(file string) error { - cstr := C.CString(file) - defer C.free(unsafe.Pointer(cstr)) - var err *C.GError = nil - res := C.gtk_window_set_icon_from_file(v.native(), (*C.gchar)(cstr), &err) - if res == 0 { - defer C.g_error_free(err) - return errors.New(C.GoString((*C.char)(err.message))) - } - return nil -} - -// SetIconName is a wrapper around gtk_window_set_icon_name(). -func (v *Window) SetIconName(name string) { - cstr := C.CString(name) - defer C.free(unsafe.Pointer(cstr)) - C.gtk_window_set_icon_name(v.native(), (*C.gchar)(cstr)) -} - -// SetAutoStartupNotification is a wrapper around -// gtk_window_set_auto_startup_notification(). -// This doesn't seem write. Might need to rethink? -/* -func (v *Window) SetAutoStartupNotification(setting bool) { - C.gtk_window_set_auto_startup_notification(gbool(setting)) -} -*/ - -// GetMnemonicsVisible is a wrapper around -// gtk_window_get_mnemonics_visible(). -func (v *Window) GetMnemonicsVisible() bool { - c := C.gtk_window_get_mnemonics_visible(v.native()) - return gobool(c) -} - -// SetMnemonicsVisible is a wrapper around -// gtk_window_get_mnemonics_visible(). -func (v *Window) SetMnemonicsVisible(setting bool) { - C.gtk_window_set_mnemonics_visible(v.native(), gbool(setting)) -} - -// GetFocusVisible is a wrapper around gtk_window_get_focus_visible(). -func (v *Window) GetFocusVisible() bool { - c := C.gtk_window_get_focus_visible(v.native()) - return gobool(c) -} - -// SetFocusVisible is a wrapper around gtk_window_set_focus_visible(). -func (v *Window) SetFocusVisible(setting bool) { - C.gtk_window_set_focus_visible(v.native(), gbool(setting)) -} - -// GetApplication is a wrapper around gtk_window_get_application(). -func (v *Window) GetApplication() (*Application, error) { - c := C.gtk_window_get_application(v.native()) - if c == nil { - return nil, nilPtrErr - } - - return wrapApplication(wrapObject(unsafe.Pointer(c))), nil -} - -// SetApplication is a wrapper around gtk_window_set_application(). -func (v *Window) SetApplication(a *Application) { - C.gtk_window_set_application(v.native(), a.native()) -} - -// TODO gtk_window_activate_key(). -// TODO gtk_window_add_mnemonic(). -// TODO gtk_window_begin_move_drag(). -// TODO gtk_window_begin_resize_drag(). -// TODO gtk_window_get_default_icon_list(). -// TODO gtk_window_get_group(). -// TODO gtk_window_get_icon_list(). -// TODO gtk_window_get_mnemonic_modifier(). -// TODO gtk_window_get_type_hint(). -// TODO gtk_window_get_window_type(). -// TODO gtk_window_list_toplevels(). -// TODO gtk_window_mnemonic_activate(). -// TODO gtk_window_parse_geometry(). -// TODO gtk_window_propogate_key_event(). -// TODO gtk_window_remove_mnemonic(). -// TODO gtk_window_set_attached_to(). -// TODO gtk_window_set_default_icon_list(). -// TODO gtk_window_set_icon_list(). -// TODO gtk_window_set_mnemonic_modifier(). -// TODO gtk_window_set_screen(). -// TODO gtk_window_set_type_hint(). -// TODO gtk_window_get_resize_grip_area(). diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/window_since_3_10.go b/vendor/github.com/gotk3/gotk3.old/gtk/window_since_3_10.go deleted file mode 100644 index 3ee9255..0000000 --- a/vendor/github.com/gotk3/gotk3.old/gtk/window_since_3_10.go +++ /dev/null @@ -1,27 +0,0 @@ -// Same copyright and license as the rest of the files in this project -// This file contains accelerator related functions and structures - -// +build !gtk_3_6,!gtk_3_8 -// not use this: go build -tags gtk_3_8'. Otherwise, if no build tags are used, GTK 3.10 - -package gtk - -// #cgo pkg-config: gtk+-3.0 -// #include -// #include -// #include "gtk_since_3_10.go.h" -import "C" - -/* - * GtkWindow - */ - -// SetTitlebar is a wrapper around gtk_window_set_titlebar(). -func (v *Window) SetTitlebar(titlebar IWidget) { - C.gtk_window_set_titlebar(v.native(), titlebar.toWidget()) -} - -// Close is a wrapper around gtk_window_close(). -func (v *Window) Close() { - C.gtk_window_close(v.native()) -} diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pango-attributes.go b/vendor/github.com/gotk3/gotk3.old/pango/pango-attributes.go deleted file mode 100644 index fa06356..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pango-attributes.go +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright (c) 2015- terrak - * - * This file originated from: http://www.terrak.net/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package pango - -// #cgo pkg-config: pango -// #include -// #include "pango.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - // Enums - {glib.Type(C.pango_attr_type_get_type()), marshalAttrType}, - {glib.Type(C.pango_underline_get_type()), marshalUnderline}, - } - glib.RegisterGValueMarshalers(tm) -} - -/* PangoColor */ - -// Color is a representation of PangoColor. -type Color struct { - pangoColor *C.PangoColor -} - -// Native returns a pointer to the underlying PangoColor. -func (v *Color) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *Color) native() *C.PangoColor { - return (*C.PangoColor)(unsafe.Pointer(v.pangoColor)) -} - -func (v *Color) Set(red, green, blue uint16) { - v.native().red = C.guint16(red) - v.native().green = C.guint16(green) - v.native().blue = C.guint16(blue) -} - -func (v *Color) Get() (red, green, blue uint16) { - return uint16(v.native().red), uint16(v.native().green), uint16(v.native().blue) -} - -//PangoColor *pango_color_copy (const PangoColor *src); -func (v *Color) Copy(c *Color) *Color { - w := new(Color) - w.pangoColor = C.pango_color_copy(v.native()) - return w -} - -//void pango_color_free (PangoColor *color); -func (v *Color) Free() { - C.pango_color_free(v.native()) -} - -//gboolean pango_color_parse (PangoColor *color, -// const char *spec); -func (v *Color) Parse(spec string) bool { - cstr := C.CString(spec) - defer C.free(unsafe.Pointer(cstr)) - c := C.pango_color_parse(v.native(), (*C.char)(cstr)) - return gobool(c) -} - -//gchar *pango_color_to_string(const PangoColor *color); -func (v *Color) ToString() string { - c := C.pango_color_to_string(v.native()) - return C.GoString((*C.char)(c)) -} - -/* --- --- --- Attributes --- --- --- */ - -// AttrList is a representation of PangoAttrList. -type AttrList struct { - pangoAttrList *C.PangoAttrList -} - -// Native returns a pointer to the underlying PangoLayout. -func (v *AttrList) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *AttrList) native() *C.PangoAttrList { - return (*C.PangoAttrList)(unsafe.Pointer(v.pangoAttrList)) -} - -// AttrType is a representation of Pango's PangoAttrType. -type AttrType int - -const ( - ATTR_INVALID AttrType = C.PANGO_ATTR_INVALID /* 0 is an invalid attribute type */ - ATTR_LANGUAGE AttrType = C.PANGO_ATTR_LANGUAGE /* PangoAttrLanguage */ - ATTR_FAMILY AttrType = C.PANGO_ATTR_FAMILY /* PangoAttrString */ - ATTR_STYLE AttrType = C.PANGO_ATTR_STYLE /* PangoAttrInt */ - ATTR_WEIGHT AttrType = C.PANGO_ATTR_WEIGHT /* PangoAttrInt */ - ATTR_VARIANT AttrType = C.PANGO_ATTR_VARIANT /* PangoAttrInt */ - ATTR_STRETCH AttrType = C.PANGO_ATTR_STRETCH /* PangoAttrInt */ - ATTR_SIZE AttrType = C.PANGO_ATTR_SIZE /* PangoAttrSize */ - ATTR_FONT_DESC AttrType = C.PANGO_ATTR_FONT_DESC /* PangoAttrFontDesc */ - ATTR_FOREGROUND AttrType = C.PANGO_ATTR_FOREGROUND /* PangoAttrColor */ - ATTR_BACKGROUND AttrType = C.PANGO_ATTR_BACKGROUND /* PangoAttrColor */ - ATTR_UNDERLINE AttrType = C.PANGO_ATTR_UNDERLINE /* PangoAttrInt */ - ATTR_STRIKETHROUGH AttrType = C.PANGO_ATTR_STRIKETHROUGH /* PangoAttrInt */ - ATTR_RISE AttrType = C.PANGO_ATTR_RISE /* PangoAttrInt */ - ATTR_SHAPE AttrType = C.PANGO_ATTR_SHAPE /* PangoAttrShape */ - ATTR_SCALE AttrType = C.PANGO_ATTR_SCALE /* PangoAttrFloat */ - ATTR_FALLBACK AttrType = C.PANGO_ATTR_FALLBACK /* PangoAttrInt */ - ATTR_LETTER_SPACING AttrType = C.PANGO_ATTR_LETTER_SPACING /* PangoAttrInt */ - ATTR_UNDERLINE_COLOR AttrType = C.PANGO_ATTR_UNDERLINE_COLOR /* PangoAttrColor */ - ATTR_STRIKETHROUGH_COLOR AttrType = C.PANGO_ATTR_STRIKETHROUGH_COLOR /* PangoAttrColor */ - ATTR_ABSOLUTE_SIZE AttrType = C.PANGO_ATTR_ABSOLUTE_SIZE /* PangoAttrSize */ - ATTR_GRAVITY AttrType = C.PANGO_ATTR_GRAVITY /* PangoAttrInt */ - ATTR_GRAVITY_HINT AttrType = C.PANGO_ATTR_GRAVITY_HINT /* PangoAttrInt */ - -) - -func marshalAttrType(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return AttrType(c), nil -} - -// Underline is a representation of Pango's PangoUnderline. -type Underline int - -const ( - UNDERLINE_NONE Underline = C.PANGO_UNDERLINE_NONE - UNDERLINE_SINGLE Underline = C.PANGO_UNDERLINE_SINGLE - UNDERLINE_DOUBLE Underline = C.PANGO_UNDERLINE_DOUBLE - UNDERLINE_LOW Underline = C.PANGO_UNDERLINE_LOW - UNDERLINE_ERROR Underline = C.PANGO_UNDERLINE_ERROR -) - -func marshalUnderline(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return Underline(c), nil -} - -const ( - ATTR_INDEX_FROM_TEXT_BEGINNING uint = 0 - ATTR_INDEX_TO_TEXT_END uint = C.G_MAXUINT -) - -// Attribute is a representation of Pango's PangoAttribute. -type Attribute struct { - pangoAttribute *C.PangoAttribute - //start_index, end_index uint -} - -// Native returns a pointer to the underlying PangoColor. -func (v *Attribute) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *Attribute) native() *C.PangoAttribute { - return (*C.PangoAttribute)(unsafe.Pointer(v.pangoAttribute)) -} - -/* -//typedef gboolean (*PangoAttrFilterFunc) (PangoAttribute *attribute, -// gpointer user_data); -func (v *Attribute) AttrFilterFunc(user_data uintptr) bool { - c := C.PangoAttrFilterFunc(Attribute.native(), C.gpointer(user_data)) - return gobool(c) -} - -//typedef gpointer (*PangoAttrDataCopyFunc) (gconstpointer user_data); -func AttrDataCopyFunc(user_data uintptr) uintptr { - c := C.PangoAttrDataCopyFunc(C.gpointer(user_data)) - return uintptr(c) -} -*/ - -// AttrClass is a representation of Pango's PangoAttrClass. -type AttrClass struct { - //PangoAttrType type; -} - -// AttrString is a representation of Pango's PangoAttrString. -type AttrString struct { - Attribute - //char *value; -} - -// AttrLanguage is a representation of Pango's PangoAttrLanguage. -type AttrLanguage struct { - Attribute - //PangoLanguage *value; -} - -// AttrInt is a representation of Pango's PangoAttrInt. -type AttrInt struct { - Attribute - //int value; -} - -// AttrFloat is a representation of Pango's PangoAttrFloat. -type AttrFloat struct { - Attribute - //double value; -} - -// AttrColor is a representation of Pango's AttrColor. -type AttrColor struct { - Attribute - Color -} - -// AttrSize is a representation of Pango's PangoAttrSize. -type AttrSize struct { - Attribute - //int size; - //guint absolute : 1; -} - -// AttrShape is a representation of Pango's PangoAttrShape. -type AttrShape struct { - Attribute - //PangoRectangle ink_rect; - //PangoRectangle logical_rect; - - //gpointer data; - //PangoAttrDataCopyFunc copy_func; - //GDestroyNotify destroy_func; -} - -// AttrFontDesc is a representation of Pango's PangoAttrFontDesc. -type AttrFontDesc struct { - Attribute - //PangoFontDescription *desc; -} - -/* -PangoAttrType pango_attr_type_register (const gchar *name); -const char * pango_attr_type_get_name (PangoAttrType type) G_GNUC_CONST; - -void pango_attribute_init (PangoAttribute *attr, - const PangoAttrClass *klass); -PangoAttribute * pango_attribute_copy (const PangoAttribute *attr); -void pango_attribute_destroy (PangoAttribute *attr); -gboolean pango_attribute_equal (const PangoAttribute *attr1, - const PangoAttribute *attr2) G_GNUC_PURE; - -PangoAttribute *pango_attr_language_new (PangoLanguage *language); -PangoAttribute *pango_attr_family_new (const char *family); -PangoAttribute *pango_attr_foreground_new (guint16 red, - guint16 green, - guint16 blue); -PangoAttribute *pango_attr_background_new (guint16 red, - guint16 green, - guint16 blue); -PangoAttribute *pango_attr_size_new (int size); -PangoAttribute *pango_attr_size_new_absolute (int size); -PangoAttribute *pango_attr_style_new (PangoStyle style); -PangoAttribute *pango_attr_weight_new (PangoWeight weight); -PangoAttribute *pango_attr_variant_new (PangoVariant variant); -PangoAttribute *pango_attr_stretch_new (PangoStretch stretch); -PangoAttribute *pango_attr_font_desc_new (const PangoFontDescription *desc); - -PangoAttribute *pango_attr_underline_new (PangoUnderline underline); -PangoAttribute *pango_attr_underline_color_new (guint16 red, - guint16 green, - guint16 blue); -PangoAttribute *pango_attr_strikethrough_new (gboolean strikethrough); -PangoAttribute *pango_attr_strikethrough_color_new (guint16 red, - guint16 green, - guint16 blue); - -PangoAttribute *pango_attr_rise_new (int rise); -PangoAttribute *pango_attr_scale_new (double scale_factor); -PangoAttribute *pango_attr_fallback_new (gboolean enable_fallback); -PangoAttribute *pango_attr_letter_spacing_new (int letter_spacing); - -PangoAttribute *pango_attr_shape_new (const PangoRectangle *ink_rect, - const PangoRectangle *logical_rect); -PangoAttribute *pango_attr_shape_new_with_data (const PangoRectangle *ink_rect, - const PangoRectangle *logical_rect, - gpointer data, - PangoAttrDataCopyFunc copy_func, - GDestroyNotify destroy_func); - -PangoAttribute *pango_attr_gravity_new (PangoGravity gravity); -PangoAttribute *pango_attr_gravity_hint_new (PangoGravityHint hint); - -GType pango_attr_list_get_type (void) G_GNUC_CONST; -PangoAttrList * pango_attr_list_new (void); -PangoAttrList * pango_attr_list_ref (PangoAttrList *list); -void pango_attr_list_unref (PangoAttrList *list); -PangoAttrList * pango_attr_list_copy (PangoAttrList *list); -void pango_attr_list_insert (PangoAttrList *list, - PangoAttribute *attr); -void pango_attr_list_insert_before (PangoAttrList *list, - PangoAttribute *attr); -void pango_attr_list_change (PangoAttrList *list, - PangoAttribute *attr); -void pango_attr_list_splice (PangoAttrList *list, - PangoAttrList *other, - gint pos, - gint len); - -PangoAttrList *pango_attr_list_filter (PangoAttrList *list, - PangoAttrFilterFunc func, - gpointer data); - -PangoAttrIterator *pango_attr_list_get_iterator (PangoAttrList *list); - -void pango_attr_iterator_range (PangoAttrIterator *iterator, - gint *start, - gint *end); -gboolean pango_attr_iterator_next (PangoAttrIterator *iterator); -PangoAttrIterator *pango_attr_iterator_copy (PangoAttrIterator *iterator); -void pango_attr_iterator_destroy (PangoAttrIterator *iterator); -PangoAttribute * pango_attr_iterator_get (PangoAttrIterator *iterator, - PangoAttrType type); -void pango_attr_iterator_get_font (PangoAttrIterator *iterator, - PangoFontDescription *desc, - PangoLanguage **language, - GSList **extra_attrs); -GSList * pango_attr_iterator_get_attrs (PangoAttrIterator *iterator); - - -gboolean pango_parse_markup (const char *markup_text, - int length, - gunichar accel_marker, - PangoAttrList **attr_list, - char **text, - gunichar *accel_char, - GError **error); - -GMarkupParseContext * pango_markup_parser_new (gunichar accel_marker); -gboolean pango_markup_parser_finish (GMarkupParseContext *context, - PangoAttrList **attr_list, - char **text, - gunichar *accel_char, - GError **error); -*/ diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pango-attributes.go.h b/vendor/github.com/gotk3/gotk3.old/pango/pango-attributes.go.h deleted file mode 100644 index d1b2e23..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pango-attributes.go.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2015- terrak - * - * This file originated from: http://www.terrak.net/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -static PangoColor* toPangoColor(void *p) -{ - return ( (PangoColor*) (p) ); -} - diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pango-context.go b/vendor/github.com/gotk3/gotk3.old/pango/pango-context.go deleted file mode 100644 index 51c6db6..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pango-context.go +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2015- terrak - * - * This file originated from: http://www.terrak.net/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package pango - -// #cgo pkg-config: pango -// #include -// #include "pango.go.h" -import "C" -import ( - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - // Enums - // {glib.Type(C.pango_alignment_get_type()), marshalAlignment}, - // {glib.Type(C.pango_ellipsize_mode_get_type()), marshalEllipsizeMode}, - // {glib.Type(C.pango_wrap_mode_get_type()), marshalWrapMode}, - - // Objects/Interfaces - // {glib.Type(C.pango_context_get_type()), marshalContext}, - } - glib.RegisterGValueMarshalers(tm) -} - -// Context is a representation of PangoContext. -type Context struct { - pangoContext *C.PangoContext -} - -// Native returns a pointer to the underlying PangoLayout. -func (v *Context) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *Context) native() *C.PangoContext { - return (*C.PangoContext)(unsafe.Pointer(v.pangoContext)) -} - -/* -func marshalContext(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapContext(obj), nil -} - -func wrapContext(obj *glib.Object) *Context { - return &Context{obj} -} -*/ - -//PangoContext *pango_context_new (void); -func ContextNew() *Context { - c := C.pango_context_new() - - context := new(Context) - context.pangoContext = (*C.PangoContext)(c) - - return context -} - -//void pango_context_changed (PangoContext *context); -//void pango_context_set_font_map (PangoContext *context, -// PangoFontMap *font_map); -//PangoFontMap *pango_context_get_font_map (PangoContext *context); -//guint pango_context_get_serial (PangoContext *context); -//void pango_context_list_families (PangoContext *context, -// PangoFontFamily ***families, -// int *n_families); -//PangoFont * pango_context_load_font (PangoContext *context, -// const PangoFontDescription *desc); -//PangoFontset *pango_context_load_fontset (PangoContext *context, -// const PangoFontDescription *desc, -// PangoLanguage *language); -// -//PangoFontMetrics *pango_context_get_metrics (PangoContext *context, -// const PangoFontDescription *desc, -// PangoLanguage *language); -// -//void pango_context_set_font_description (PangoContext *context, -// const PangoFontDescription *desc); -//PangoFontDescription * pango_context_get_font_description (PangoContext *context); -//PangoLanguage *pango_context_get_language (PangoContext *context); -//void pango_context_set_language (PangoContext *context, -// PangoLanguage *language); -//void pango_context_set_base_dir (PangoContext *context, -// PangoDirection direction); -//PangoDirection pango_context_get_base_dir (PangoContext *context); -//void pango_context_set_base_gravity (PangoContext *context, -// PangoGravity gravity); -//PangoGravity pango_context_get_base_gravity (PangoContext *context); -//PangoGravity pango_context_get_gravity (PangoContext *context); -//void pango_context_set_gravity_hint (PangoContext *context, -// PangoGravityHint hint); -//PangoGravityHint pango_context_get_gravity_hint (PangoContext *context); -// -//void pango_context_set_matrix (PangoContext *context, -// const PangoMatrix *matrix); -//const PangoMatrix * pango_context_get_matrix (PangoContext *context); - -/* Break a string of Unicode characters into segments with - * consistent shaping/language engine and bidrectional level. - * Returns a #GList of #PangoItem's - */ -//GList *pango_itemize (PangoContext *context, -// const char *text, -// int start_index, -// int length, -// PangoAttrList *attrs, -// PangoAttrIterator *cached_iter); -//GList *pango_itemize_with_base_dir (PangoContext *context, -// PangoDirection base_dir, -// const char *text, -// int start_index, -// int length, -// PangoAttrList *attrs, -// PangoAttrIterator *cached_iter); diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pango-font.go b/vendor/github.com/gotk3/gotk3.old/pango/pango-font.go deleted file mode 100644 index 4e4f599..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pango-font.go +++ /dev/null @@ -1,706 +0,0 @@ -/* - * Copyright (c) 2015- terrak - * - * This file originated from: http://www.terrak.net/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package pango - -// #cgo pkg-config: pango -// #include -// #include "pango.go.h" -import "C" -import ( - // "github.com/andre-hub/gotk3/glib" - // "github.com/andre-hub/gotk3/cairo" - "unsafe" - - "github.com/gotk3/gotk3/glib" -) - -func init() { - tm := []glib.TypeMarshaler{ - // Enums - // Objects/Interfaces - {glib.Type(C.pango_font_description_get_type()), marshalFontDescription}, - } - glib.RegisterGValueMarshalers(tm) -} - -// FontDescription is a representation of PangoFontDescription. -type FontDescription struct { - pangoFontDescription *C.PangoFontDescription -} - -// Native returns a pointer to the underlying PangoLayout. -func (v *FontDescription) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *FontDescription) native() *C.PangoFontDescription { - return (*C.PangoFontDescription)(unsafe.Pointer(v.pangoFontDescription)) -} - -// FontMetrics is a representation of PangoFontMetrics. -type FontMetrics struct { - pangoFontMetrics *C.PangoFontMetrics -} - -// Native returns a pointer to the underlying PangoLayout. -func (v *FontMetrics) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *FontMetrics) native() *C.PangoFontMetrics { - return (*C.PangoFontMetrics)(unsafe.Pointer(v.pangoFontMetrics)) -} - -const ( - PANGO_SCALE = C.PANGO_SCALE -) - -type Style int - -const ( - STYLE_NORMAL Style = C.PANGO_STYLE_NORMAL - STYLE_OBLIQUE Style = C.PANGO_STYLE_OBLIQUE - STYLE_ITALIC Style = C.PANGO_STYLE_ITALIC -) - -type Variant int - -const ( - VARIANT_NORMAL Variant = C.PANGO_VARIANT_NORMAL - VARIANT_SMALL_CAPS Variant = C.PANGO_VARIANT_SMALL_CAPS -) - -type Weight int - -const ( - WEIGHT_THIN Weight = C.PANGO_WEIGHT_THIN /* 100 */ - WEIGHT_ULTRALIGHT Weight = C.PANGO_WEIGHT_ULTRALIGHT /* 200 */ - WEIGHT_LIGHT Weight = C.PANGO_WEIGHT_LIGHT /* 300 */ - WEIGHT_SEMILIGHT Weight = 350 /* 350 */ - WEIGHT_BOOK Weight = C.PANGO_WEIGHT_BOOK /* 380 */ - WEIGHT_NORMAL Weight = C.PANGO_WEIGHT_NORMAL /* 400 */ - WEIGHT_MEDIUM Weight = C.PANGO_WEIGHT_MEDIUM /* 500 */ - WEIGHT_SEMIBOLD Weight = C.PANGO_WEIGHT_SEMIBOLD /* 600 */ - WEIGHT_BOLD Weight = C.PANGO_WEIGHT_BOLD /* 700 */ - WEIGHT_ULTRABOLD Weight = C.PANGO_WEIGHT_ULTRABOLD /* 800 */ - WEIGHT_HEAVY Weight = C.PANGO_WEIGHT_HEAVY /* 900 */ - WEIGHT_ULTRAHEAVY Weight = C.PANGO_WEIGHT_ULTRAHEAVY /* 1000 */ - -) - -type Stretch int - -const ( - STRETCH_ULTRA_CONDENSED Stretch = C.PANGO_STRETCH_ULTRA_CONDENSED - STRETCH_EXTRA_CONDENSEDStretch Stretch = C.PANGO_STRETCH_EXTRA_CONDENSED - STRETCH_CONDENSEDStretch Stretch = C.PANGO_STRETCH_CONDENSED - STRETCH_SEMI_CONDENSEDStretch Stretch = C.PANGO_STRETCH_SEMI_CONDENSED - STRETCH_NORMALStretch Stretch = C.PANGO_STRETCH_NORMAL - STRETCH_SEMI_EXPANDEDStretch Stretch = C.PANGO_STRETCH_SEMI_EXPANDED - STRETCH_EXPANDEDStretch Stretch = C.PANGO_STRETCH_EXPANDED - STRETCH_EXTRA_EXPANDEDStretch Stretch = C.PANGO_STRETCH_EXTRA_EXPANDED - STRETCH_ULTRA_EXPANDEDStretch Stretch = C.PANGO_STRETCH_ULTRA_EXPANDED -) - -type FontMask int - -const ( - FONT_MASK_FAMILY FontMask = C.PANGO_FONT_MASK_FAMILY /* 1 << 0 */ - FONT_MASK_STYLEFontMask FontMask = C.PANGO_FONT_MASK_STYLE /* 1 << 1 */ - FONT_MASK_VARIANTFontMask FontMask = C.PANGO_FONT_MASK_VARIANT /* 1 << 2 */ - FONT_MASK_WEIGHTFontMask FontMask = C.PANGO_FONT_MASK_WEIGHT /* 1 << 3 */ - FONT_MASK_STRETCHFontMask FontMask = C.PANGO_FONT_MASK_STRETCH /* 1 << 4 */ - FONT_MASK_SIZEFontMask FontMask = C.PANGO_FONT_MASK_SIZE /* 1 << 5 */ - FONT_MASK_GRAVITYFontMask FontMask = C.PANGO_FONT_MASK_GRAVITY /* 1 << 6 */ -) - -type Scale float64 - -const ( - SCALE_XX_SMALL Scale = /* C.PANGO_SCALE_XX_SMALL */ 0.5787037037037 - SCALE_X_SMALL Scale = /*C.PANGO_SCALE_X_SMALL */ 0.6444444444444 - SCALE_SMALL Scale = /*C.PANGO_SCALE_SMALL */ 0.8333333333333 - SCALE_MEDIUM Scale = /*C.PANGO_SCALE_MEDIUM */ 1.0 - SCALE_LARGE Scale = /*C.PANGO_SCALE_LARGE */ 1.2 - SCALE_X_LARGE Scale = /*C.PANGO_SCALE_X_LARGE */ 1.4399999999999 - SCALE_XX_LARGE Scale = /*C.PANGO_SCALE_XX_LARGE */ 1.728 -) - -/* - * PangoFontDescription - */ - -func marshalFontDescription(p uintptr) (interface{}, error) { - c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) - c2 := (*C.PangoFontDescription)(unsafe.Pointer(c)) - return wrapFontDescription(c2), nil -} - -func wrapFontDescription(obj *C.PangoFontDescription) *FontDescription { - return &FontDescription{obj} -} - -//PangoFontDescription *pango_font_description_new (void); -func FontDescriptionNew() *FontDescription { - c := C.pango_font_description_new() - v := new(FontDescription) - v.pangoFontDescription = c - return v -} - -//PangoFontDescription *pango_font_description_copy (const PangoFontDescription *desc); -func (v *FontDescription) Copy() *FontDescription { - c := C.pango_font_description_copy(v.native()) - v2 := new(FontDescription) - v2.pangoFontDescription = c - return v2 -} - -//PangoFontDescription *pango_font_description_copy_static (const PangoFontDescription *desc); -func (v *FontDescription) CopyStatic() *FontDescription { - c := C.pango_font_description_copy_static(v.native()) - v2 := new(FontDescription) - v2.pangoFontDescription = c - return v2 -} - -//guint pango_font_description_hash (const PangoFontDescription *desc) G_GNUC_PURE; -func (v *FontDescription) Hash() uint { - c := C.pango_font_description_hash(v.native()) - return uint(c) -} - -//gboolean pango_font_description_equal (const PangoFontDescription *desc1, -// const PangoFontDescription *desc2) G_GNUC_PURE; -func (v *FontDescription) Equal(v2 *FontDescription) bool { - c := C.pango_font_description_equal(v.native(), v2.native()) - return gobool(c) -} - -//void pango_font_description_free (PangoFontDescription *desc); -func (v *FontDescription) Free() { - C.pango_font_description_free(v.native()) -} - -//void pango_font_descriptions_free (PangoFontDescription **descs, -// int n_descs); -//func (v *FontDescription) FontDescriptionsFree(n_descs int) { -// C.pango_font_descriptions_free(v.native(), C.int(n_descs)) -//} - -//void pango_font_description_set_family (PangoFontDescription *desc, -// const char *family); -func (v *FontDescription) SetFamily(family string) { - cstr := C.CString(family) - defer C.free(unsafe.Pointer(cstr)) - C.pango_font_description_set_family(v.native(), (*C.char)(cstr)) -} - -//void pango_font_description_set_family_static (PangoFontDescription *desc, -// const char *family); -func (v *FontDescription) SetFamilyStatic(family string) { - cstr := C.CString(family) - defer C.free(unsafe.Pointer(cstr)) - C.pango_font_description_set_family_static(v.native(), (*C.char)(cstr)) -} - -//const char *pango_font_description_get_family (const PangoFontDescription *desc) G_GNUC_PURE; -func (v *FontDescription) GetFamily() string { - c := C.pango_font_description_get_family(v.native()) - return C.GoString((*C.char)(c)) -} - -//void pango_font_description_set_style (PangoFontDescription *desc, -// PangoStyle style); -func (v *FontDescription) SetStyle(style Style) { - C.pango_font_description_set_style(v.native(), (C.PangoStyle)(style)) -} - -//PangoStyle pango_font_description_get_style (const PangoFontDescription *desc) G_GNUC_PURE; -func (v *FontDescription) GetStyle() Style { - c := C.pango_font_description_get_style(v.native()) - return Style(c) -} - -//void pango_font_description_set_variant (PangoFontDescription *desc, -// PangoVariant variant); -//PangoVariant pango_font_description_get_variant (const PangoFontDescription *desc) G_GNUC_PURE; - -//void pango_font_description_set_weight (PangoFontDescription *desc, -// PangoWeight weight); -func (v *FontDescription) SetWeight(weight Weight) { - C.pango_font_description_set_weight(v.native(), (C.PangoWeight)(weight)) -} - -//PangoWeight pango_font_description_get_weight (const PangoFontDescription *desc) G_GNUC_PURE; -func (v *FontDescription) GetWeight() Weight { - c := C.pango_font_description_get_weight(v.native()) - return Weight(c) -} - -//void pango_font_description_set_stretch (PangoFontDescription *desc, -// PangoStretch stretch); -func (v *FontDescription) SetStretch(stretch Stretch) { - C.pango_font_description_set_stretch(v.native(), (C.PangoStretch)(stretch)) -} - -//PangoStretch pango_font_description_get_stretch (const PangoFontDescription *desc) G_GNUC_PURE; -func (v *FontDescription) GetStretch() Stretch { - c := C.pango_font_description_get_stretch(v.native()) - return Stretch(c) -} - -//void pango_font_description_set_size (PangoFontDescription *desc, -// gint size); -func (v *FontDescription) SetSize(size int) { - C.pango_font_description_set_size(v.native(), (C.gint)(size)) -} - -//gint pango_font_description_get_size (const PangoFontDescription *desc) G_GNUC_PURE; -func (v *FontDescription) GetSize() int { - c := C.pango_font_description_get_size(v.native()) - return int(c) -} - -//void pango_font_description_set_absolute_size (PangoFontDescription *desc, -// double size); -func (v *FontDescription) SetAbsoluteSize(size float64) { - C.pango_font_description_set_absolute_size(v.native(), (C.double)(size)) -} - -//gboolean pango_font_description_get_size_is_absolute (const PangoFontDescription *desc) G_GNUC_PURE; -func (v *FontDescription) GetSizeIsAbsolute() bool { - c := C.pango_font_description_get_size_is_absolute(v.native()) - return gobool(c) -} - -//void pango_font_description_set_gravity (PangoFontDescription *desc, -// PangoGravity gravity); -func (v *FontDescription) SetGravity(gravity Gravity) { - C.pango_font_description_set_gravity(v.native(), (C.PangoGravity)(gravity)) -} - -//PangoGravity pango_font_description_get_gravity (const PangoFontDescription *desc) G_GNUC_PURE; -func (v *FontDescription) GetGravity() Gravity { - c := C.pango_font_description_get_gravity(v.native()) - return Gravity(c) -} - -//PangoFontMask pango_font_description_get_set_fields (const PangoFontDescription *desc) G_GNUC_PURE; -func (v *FontDescription) GetSetFields() FontMask { - c := C.pango_font_description_get_set_fields(v.native()) - return FontMask(c) -} - -//void pango_font_description_unset_fields (PangoFontDescription *desc, -// PangoFontMask to_unset); -func (v *FontDescription) GetUnsetFields(to_unset FontMask) { - C.pango_font_description_unset_fields(v.native(), (C.PangoFontMask)(to_unset)) -} - -//void pango_font_description_merge (PangoFontDescription *desc, -// const PangoFontDescription *desc_to_merge, -// gboolean replace_existing); -func (v *FontDescription) Merge(desc_to_merge *FontDescription, replace_existing bool) { - C.pango_font_description_merge(v.native(), desc_to_merge.native(), gbool(replace_existing)) -} - -//void pango_font_description_merge_static (PangoFontDescription *desc, -// const PangoFontDescription *desc_to_merge, -// gboolean replace_existing); -func (v *FontDescription) MergeStatic(desc_to_merge *FontDescription, replace_existing bool) { - C.pango_font_description_merge_static(v.native(), desc_to_merge.native(), gbool(replace_existing)) -} - -//gboolean pango_font_description_better_match (const PangoFontDescription *desc, -// const PangoFontDescription *old_match, -// const PangoFontDescription *new_match) G_GNUC_PURE; -func (v *FontDescription) BetterMatch(old_match, new_match *FontDescription) bool { - c := C.pango_font_description_better_match(v.native(), old_match.native(), new_match.native()) - return gobool(c) -} - -//PangoFontDescription *pango_font_description_from_string (const char *str); -func FontDescriptionFromString(str string) *FontDescription { - cstr := C.CString(str) - defer C.free(unsafe.Pointer(cstr)) - c := C.pango_font_description_from_string((*C.char)(cstr)) - v := new(FontDescription) - v.pangoFontDescription = c - return v -} - -//char * pango_font_description_to_string (const PangoFontDescription *desc); -func (v *FontDescription) ToString() string { - c := C.pango_font_description_to_string(v.native()) - return C.GoString((*C.char)(c)) -} - -//char * pango_font_description_to_filename (const PangoFontDescription *desc); -func (v *FontDescription) ToFilename() string { - c := C.pango_font_description_to_filename(v.native()) - return C.GoString((*C.char)(c)) -} - -///* -// * PangoFontMetrics -// */ -// -///** -// * PANGO_TYPE_FONT_METRICS: -// * -// * The #GObject type for #PangoFontMetrics. -// */ -//#define PANGO_TYPE_FONT_METRICS (pango_font_metrics_get_type ()) -//GType pango_font_metrics_get_type (void) G_GNUC_CONST; -//PangoFontMetrics *pango_font_metrics_ref (PangoFontMetrics *metrics); -//void pango_font_metrics_unref (PangoFontMetrics *metrics); -//int pango_font_metrics_get_ascent (PangoFontMetrics *metrics) G_GNUC_PURE; -//int pango_font_metrics_get_descent (PangoFontMetrics *metrics) G_GNUC_PURE; -//int pango_font_metrics_get_approximate_char_width (PangoFontMetrics *metrics) G_GNUC_PURE; -//int pango_font_metrics_get_approximate_digit_width (PangoFontMetrics *metrics) G_GNUC_PURE; -//int pango_font_metrics_get_underline_position (PangoFontMetrics *metrics) G_GNUC_PURE; -//int pango_font_metrics_get_underline_thickness (PangoFontMetrics *metrics) G_GNUC_PURE; -//int pango_font_metrics_get_strikethrough_position (PangoFontMetrics *metrics) G_GNUC_PURE; -//int pango_font_metrics_get_strikethrough_thickness (PangoFontMetrics *metrics) G_GNUC_PURE; -// -//#ifdef PANGO_ENABLE_BACKEND -// -//PangoFontMetrics *pango_font_metrics_new (void); -// -//struct _PangoFontMetrics -//{ -// guint ref_count; -// -// int ascent; -// int descent; -// int approximate_char_width; -// int approximate_digit_width; -// int underline_position; -// int underline_thickness; -// int strikethrough_position; -// int strikethrough_thickness; -//}; -// -//#endif /* PANGO_ENABLE_BACKEND */ -// -///* -// * PangoFontFamily -// */ -// -///** -// * PANGO_TYPE_FONT_FAMILY: -// * -// * The #GObject type for #PangoFontFamily. -// */ -///** -// * PANGO_FONT_FAMILY: -// * @object: a #GObject. -// * -// * Casts a #GObject to a #PangoFontFamily. -// */ -///** -// * PANGO_IS_FONT_FAMILY: -// * @object: a #GObject. -// * -// * Returns: %TRUE if @object is a #PangoFontFamily. -// */ -//#define PANGO_TYPE_FONT_FAMILY (pango_font_family_get_type ()) -//#define PANGO_FONT_FAMILY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FAMILY, PangoFontFamily)) -//#define PANGO_IS_FONT_FAMILY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FAMILY)) -// -//typedef struct _PangoFontFamily PangoFontFamily; -//typedef struct _PangoFontFace PangoFontFace; -// -//GType pango_font_family_get_type (void) G_GNUC_CONST; -// -//void pango_font_family_list_faces (PangoFontFamily *family, -// PangoFontFace ***faces, -// int *n_faces); -//const char *pango_font_family_get_name (PangoFontFamily *family) G_GNUC_PURE; -//gboolean pango_font_family_is_monospace (PangoFontFamily *family) G_GNUC_PURE; -// -//#ifdef PANGO_ENABLE_BACKEND -// -//#define PANGO_FONT_FAMILY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FAMILY, PangoFontFamilyClass)) -//#define PANGO_IS_FONT_FAMILY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FAMILY)) -//#define PANGO_FONT_FAMILY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FAMILY, PangoFontFamilyClass)) -// -//typedef struct _PangoFontFamilyClass PangoFontFamilyClass; -// -// -///** -// * PangoFontFamily: -// * -// * The #PangoFontFamily structure is used to represent a family of related -// * font faces. The faces in a family share a common design, but differ in -// * slant, weight, width and other aspects. -// */ -//struct _PangoFontFamily -//{ -// GObject parent_instance; -//}; -// -//struct _PangoFontFamilyClass -//{ -// GObjectClass parent_class; -// -// /*< public >*/ -// -// void (*list_faces) (PangoFontFamily *family, -// PangoFontFace ***faces, -// int *n_faces); -// const char * (*get_name) (PangoFontFamily *family); -// gboolean (*is_monospace) (PangoFontFamily *family); -// -// /*< private >*/ -// -// /* Padding for future expansion */ -// void (*_pango_reserved2) (void); -// void (*_pango_reserved3) (void); -// void (*_pango_reserved4) (void); -//}; -// -//#endif /* PANGO_ENABLE_BACKEND */ -// -///* -// * PangoFontFace -// */ -// -///** -// * PANGO_TYPE_FONT_FACE: -// * -// * The #GObject type for #PangoFontFace. -// */ -///** -// * PANGO_FONT_FACE: -// * @object: a #GObject. -// * -// * Casts a #GObject to a #PangoFontFace. -// */ -///** -// * PANGO_IS_FONT_FACE: -// * @object: a #GObject. -// * -// * Returns: %TRUE if @object is a #PangoFontFace. -// */ -//#define PANGO_TYPE_FONT_FACE (pango_font_face_get_type ()) -//#define PANGO_FONT_FACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FACE, PangoFontFace)) -//#define PANGO_IS_FONT_FACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FACE)) -// -//GType pango_font_face_get_type (void) G_GNUC_CONST; -// -//PangoFontDescription *pango_font_face_describe (PangoFontFace *face); -//const char *pango_font_face_get_face_name (PangoFontFace *face) G_GNUC_PURE; -//void pango_font_face_list_sizes (PangoFontFace *face, -// int **sizes, -// int *n_sizes); -//gboolean pango_font_face_is_synthesized (PangoFontFace *face) G_GNUC_PURE; -// -//#ifdef PANGO_ENABLE_BACKEND -// -//#define PANGO_FONT_FACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FACE, PangoFontFaceClass)) -//#define PANGO_IS_FONT_FACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FACE)) -//#define PANGO_FONT_FACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FACE, PangoFontFaceClass)) -// -//typedef struct _PangoFontFaceClass PangoFontFaceClass; -// -///** -// * PangoFontFace: -// * -// * The #PangoFontFace structure is used to represent a group of fonts with -// * the same family, slant, weight, width, but varying sizes. -// */ -//struct _PangoFontFace -//{ -// GObject parent_instance; -//}; -// -//struct _PangoFontFaceClass -//{ -// GObjectClass parent_class; -// -// /*< public >*/ -// -// const char * (*get_face_name) (PangoFontFace *face); -// PangoFontDescription * (*describe) (PangoFontFace *face); -// void (*list_sizes) (PangoFontFace *face, -// int **sizes, -// int *n_sizes); -// gboolean (*is_synthesized) (PangoFontFace *face); -// -// /*< private >*/ -// -// /* Padding for future expansion */ -// void (*_pango_reserved3) (void); -// void (*_pango_reserved4) (void); -//}; -// -//#endif /* PANGO_ENABLE_BACKEND */ -// -///* -// * PangoFont -// */ -// -///** -// * PANGO_TYPE_FONT: -// * -// * The #GObject type for #PangoFont. -// */ -///** -// * PANGO_FONT: -// * @object: a #GObject. -// * -// * Casts a #GObject to a #PangoFont. -// */ -///** -// * PANGO_IS_FONT: -// * @object: a #GObject. -// * -// * Returns: %TRUE if @object is a #PangoFont. -// */ -//#define PANGO_TYPE_FONT (pango_font_get_type ()) -//#define PANGO_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT, PangoFont)) -//#define PANGO_IS_FONT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT)) -// -//GType pango_font_get_type (void) G_GNUC_CONST; -// -//PangoFontDescription *pango_font_describe (PangoFont *font); -//PangoFontDescription *pango_font_describe_with_absolute_size (PangoFont *font); -//PangoCoverage * pango_font_get_coverage (PangoFont *font, -// PangoLanguage *language); -//PangoEngineShape * pango_font_find_shaper (PangoFont *font, -// PangoLanguage *language, -// guint32 ch); -//PangoFontMetrics * pango_font_get_metrics (PangoFont *font, -// PangoLanguage *language); -//void pango_font_get_glyph_extents (PangoFont *font, -// PangoGlyph glyph, -// PangoRectangle *ink_rect, -// PangoRectangle *logical_rect); -//PangoFontMap *pango_font_get_font_map (PangoFont *font); -// -//#ifdef PANGO_ENABLE_BACKEND -// -//#define PANGO_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT, PangoFontClass)) -//#define PANGO_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT)) -//#define PANGO_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT, PangoFontClass)) -// -//typedef struct _PangoFontClass PangoFontClass; -// -///** -// * PangoFont: -// * -// * The #PangoFont structure is used to represent -// * a font in a rendering-system-independent matter. -// * To create an implementation of a #PangoFont, -// * the rendering-system specific code should allocate -// * a larger structure that contains a nested -// * #PangoFont, fill in the klass member of -// * the nested #PangoFont with a pointer to -// * a appropriate #PangoFontClass, then call -// * pango_font_init() on the structure. -// * -// * The #PangoFont structure contains one member -// * which the implementation fills in. -// */ -//struct _PangoFont -//{ -// GObject parent_instance; -//}; -// -//struct _PangoFontClass -//{ -// GObjectClass parent_class; -// -// /*< public >*/ -// -// PangoFontDescription *(*describe) (PangoFont *font); -// PangoCoverage * (*get_coverage) (PangoFont *font, -// PangoLanguage *lang); -// PangoEngineShape * (*find_shaper) (PangoFont *font, -// PangoLanguage *lang, -// guint32 ch); -// void (*get_glyph_extents) (PangoFont *font, -// PangoGlyph glyph, -// PangoRectangle *ink_rect, -// PangoRectangle *logical_rect); -// PangoFontMetrics * (*get_metrics) (PangoFont *font, -// PangoLanguage *language); -// PangoFontMap * (*get_font_map) (PangoFont *font); -// PangoFontDescription *(*describe_absolute) (PangoFont *font); -// /*< private >*/ -// -// /* Padding for future expansion */ -// void (*_pango_reserved1) (void); -// void (*_pango_reserved2) (void); -//}; -// -///* used for very rare and miserable situtations that we cannot even -// * draw a hexbox -// */ -//#define PANGO_UNKNOWN_GLYPH_WIDTH 10 -//#define PANGO_UNKNOWN_GLYPH_HEIGHT 14 -// -//#endif /* PANGO_ENABLE_BACKEND */ -// -///** -// * PANGO_GLYPH_EMPTY: -// * -// * The %PANGO_GLYPH_EMPTY macro represents a #PangoGlyph value that has a -// * special meaning, which is a zero-width empty glyph. This is useful for -// * example in shaper modules, to use as the glyph for various zero-width -// * Unicode characters (those passing pango_is_zero_width()). -// */ -///** -// * PANGO_GLYPH_INVALID_INPUT: -// * -// * The %PANGO_GLYPH_INVALID_INPUT macro represents a #PangoGlyph value that has a -// * special meaning of invalid input. #PangoLayout produces one such glyph -// * per invalid input UTF-8 byte and such a glyph is rendered as a crossed -// * box. -// * -// * Note that this value is defined such that it has the %PANGO_GLYPH_UNKNOWN_FLAG -// * on. -// * -// * Since: 1.20 -// */ -///** -// * PANGO_GLYPH_UNKNOWN_FLAG: -// * -// * The %PANGO_GLYPH_UNKNOWN_FLAG macro is a flag value that can be added to -// * a #gunichar value of a valid Unicode character, to produce a #PangoGlyph -// * value, representing an unknown-character glyph for the respective #gunichar. -// */ -///** -// * PANGO_GET_UNKNOWN_GLYPH: -// * @wc: a Unicode character -// * -// * The way this unknown glyphs are rendered is backend specific. For example, -// * a box with the hexadecimal Unicode code-point of the character written in it -// * is what is done in the most common backends. -// * -// * Returns: a #PangoGlyph value that means no glyph was found for @wc. -// */ -//#define PANGO_GLYPH_EMPTY ((PangoGlyph)0x0FFFFFFF) -//#define PANGO_GLYPH_INVALID_INPUT ((PangoGlyph)0xFFFFFFFF) -//#define PANGO_GLYPH_UNKNOWN_FLAG ((PangoGlyph)0x10000000) -//#define PANGO_GET_UNKNOWN_GLYPH(wc) ((PangoGlyph)(wc)|PANGO_GLYPH_UNKNOWN_FLAG) -// -// diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pango-glyph-item.go b/vendor/github.com/gotk3/gotk3.old/pango/pango-glyph-item.go deleted file mode 100644 index 1ee9016..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pango-glyph-item.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2015- terrak - * - * This file originated from: http://www.terrak.net/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package pango - -// #cgo pkg-config: pango -// #include -// #include "pango.go.h" -// #include -import "C" -import ( - // "github.com/andre-hub/gotk3/glib" - // "github.com/andre-hub/gotk3/cairo" - "unsafe" -) - -// GlyphItem is a representation of PangoGlyphItem. -type GlyphItem struct { - pangoGlyphItem *C.PangoGlyphItem -} - -// Native returns a pointer to the underlying PangoGlyphItem. -func (v *GlyphItem) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *GlyphItem) native() *C.PangoGlyphItem { - return (*C.PangoGlyphItem)(unsafe.Pointer(v.pangoGlyphItem)) -} diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pango-glyph.go b/vendor/github.com/gotk3/gotk3.old/pango/pango-glyph.go deleted file mode 100644 index d41e6da..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pango-glyph.go +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2015- terrak - * - * This file originated from: http://www.terrak.net/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package pango - -// #cgo pkg-config: pango -// #include -// #include "pango.go.h" -// #include -import "C" -import ( - // "github.com/andre-hub/gotk3/glib" - // "github.com/andre-hub/gotk3/cairo" - "unsafe" -) - -// GlyphGeometry is a representation of PangoGlyphGeometry. -type GlyphGeometry struct { - pangoGlyphGeometry *C.PangoGlyphGeometry -} - -// Native returns a pointer to the underlying PangoLayout. -func (v *GlyphGeometry) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *GlyphGeometry) native() *C.PangoGlyphGeometry { - return (*C.PangoGlyphGeometry)(unsafe.Pointer(v.pangoGlyphGeometry)) -} - -// GlyphVisAttr is a representation of PangoGlyphVisAttr. -type GlyphVisAttr struct { - pangoGlyphVisAttr *C.PangoGlyphGeometry -} - -// Native returns a pointer to the underlying PangoGlyphVisAttr. -func (v *GlyphVisAttr) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *GlyphVisAttr) native() *C.PangoGlyphVisAttr { - return (*C.PangoGlyphVisAttr)(unsafe.Pointer(v.pangoGlyphVisAttr)) -} - -// GlyphInfo is a representation of PangoGlyphInfo. -type GlyphInfo struct { - pangoGlyphInfo *C.PangoGlyphInfo -} - -// Native returns a pointer to the underlying PangoGlyphInfo. -func (v *GlyphInfo) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *GlyphInfo) native() *C.PangoGlyphInfo { - return (*C.PangoGlyphInfo)(unsafe.Pointer(v.pangoGlyphInfo)) -} - -// GlyphGeometry is a representation of PangoGlyphString. -type GlyphString struct { - pangoGlyphString *C.PangoGlyphString -} - -// Native returns a pointer to the underlying PangoGlyphString. -func (v *GlyphString) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *GlyphString) native() *C.PangoGlyphString { - return (*C.PangoGlyphString)(unsafe.Pointer(v.pangoGlyphString)) -} diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pango-gravity.go b/vendor/github.com/gotk3/gotk3.old/pango/pango-gravity.go deleted file mode 100644 index 7affb63..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pango-gravity.go +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2015- terrak - * - * This file originated from: http://www.terrak.net/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package pango - -// #cgo pkg-config: pango -// #include -// #include "pango.go.h" -import "C" - -// "github.com/andre-hub/gotk3/glib" -// "github.com/andre-hub/gotk3/cairo" -// "unsafe" - -type Gravity int - -const ( - GRAVITY_SOUTH Gravity = C.PANGO_GRAVITY_SOUTH - GRAVITY_EAST Gravity = C.PANGO_GRAVITY_EAST - GRAVITY_NORTH Gravity = C.PANGO_GRAVITY_NORTH - GRAVITY_WEST Gravity = C.PANGO_GRAVITY_WEST - GRAVITY_AUTO Gravity = C.PANGO_GRAVITY_AUTO -) - -type GravityHint int - -const ( - GRAVITY_HINT_NATURAL GravityHint = C.PANGO_GRAVITY_HINT_NATURAL - GRAVITY_HINT_STRONG GravityHint = C.PANGO_GRAVITY_HINT_STRONG - GRAVITY_HINT_LINE GravityHint = C.PANGO_GRAVITY_HINT_LINE -) - -//double pango_gravity_to_rotation (PangoGravity gravity) G_GNUC_CONST; -func GravityToRotation(gravity Gravity) float64 { - c := C.pango_gravity_to_rotation((C.PangoGravity)(gravity)) - return float64(c) -} - -//PangoGravity pango_gravity_get_for_matrix (const PangoMatrix *matrix) G_GNUC_PURE; - -//PangoGravity pango_gravity_get_for_script (PangoScript script, -// PangoGravity base_gravity, -// PangoGravityHint hint) G_GNUC_CONST; - -//PangoGravity pango_gravity_get_for_script_and_width -// (PangoScript script, -// gboolean wide, -// PangoGravity base_gravity, -// PangoGravityHint hint) G_GNUC_CONST; diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pango-layout.go b/vendor/github.com/gotk3/gotk3.old/pango/pango-layout.go deleted file mode 100644 index e25f2bd..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pango-layout.go +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Copyright (c) 2015- terrak - * - * This file originated from: http://www.terrak.net/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package pango - -// #cgo pkg-config: pango -// #include -// #include "pango.go.h" -import "C" -import ( - "github.com/gotk3/gotk3/glib" - "unsafe" -) - -func init() { - tm := []glib.TypeMarshaler{ - // Enums - {glib.Type(C.pango_alignment_get_type()), marshalAlignment}, - {glib.Type(C.pango_ellipsize_mode_get_type()), marshalEllipsizeMode}, - {glib.Type(C.pango_wrap_mode_get_type()), marshalWrapMode}, - - // Objects/Interfaces - // {glib.Type(C.pango_layout_get_type()), marshalLayout}, - } - glib.RegisterGValueMarshalers(tm) -} - -// Layout is a representation of PangoLayout. -type Layout struct { - pangoLayout *C.PangoLayout -} - -// Native returns a pointer to the underlying PangoLayout. -func (v *Layout) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *Layout) native() *C.PangoLayout { - return (*C.PangoLayout)(unsafe.Pointer(v.pangoLayout)) -} - -// LayoutLine is a representation of PangoLayoutLine. -type LayoutLine struct { - pangoLayoutLine *C.PangoLayout -} - -// Native returns a pointer to the underlying PangoLayoutLine. -func (v *LayoutLine) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *LayoutLine) native() *C.PangoLayoutLine { - return (*C.PangoLayoutLine)(unsafe.Pointer(v.pangoLayoutLine)) -} - -/* - * Constants - */ - -// Alignment is a representation of Pango's PangoAlignment. -type Alignment int - -const ( - ALIGN_LEFT Alignment = C.PANGO_ALIGN_LEFT - ALIGN_CENTER Alignment = C.PANGO_ALIGN_CENTER - ALIGN_RIGHT Alignment = C.PANGO_ALIGN_RIGHT -) - -func marshalAlignment(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return Alignment(c), nil -} - -// WrapMode is a representation of Pango's PangoWrapMode. -type WrapMode int - -const ( - WRAP_WORD WrapMode = C.PANGO_WRAP_WORD - WRAP_CHAR WrapMode = C.PANGO_WRAP_CHAR - WRAP_WORD_CHAR WrapMode = C.PANGO_WRAP_WORD_CHAR -) - -func marshalWrapMode(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return WrapMode(c), nil -} - -// EllipsizeMode is a representation of Pango's PangoEllipsizeMode. -type EllipsizeMode int - -const ( - ELLIPSIZE_NONE EllipsizeMode = C.PANGO_ELLIPSIZE_NONE - ELLIPSIZE_START EllipsizeMode = C.PANGO_ELLIPSIZE_START - ELLIPSIZE_MIDDLE EllipsizeMode = C.PANGO_ELLIPSIZE_MIDDLE - ELLIPSIZE_END EllipsizeMode = C.PANGO_ELLIPSIZE_END -) - -func marshalEllipsizeMode(p uintptr) (interface{}, error) { - c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) - return EllipsizeMode(c), nil -} - -/* -func marshalLayout(p uintptr) (interface{}, error) { - c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) - obj := wrapObject(unsafe.Pointer(c)) - return wrapLayout(obj), nil -} - -func wrapLayout(obj *glib.Object) *Layout { - return &Layout{obj} -} -*/ - -//PangoLayout *pango_layout_new (PangoContext *context); -func LayoutNew(context *Context) *Layout { - c := C.pango_layout_new(context.native()) - - layout := new(Layout) - layout.pangoLayout = (*C.PangoLayout)(c) - return layout -} - -//PangoLayout *pango_layout_copy (PangoLayout *src); -func (v *Layout) Copy() *Layout { - c := C.pango_layout_copy(v.native()) - - layout := new(Layout) - layout.pangoLayout = (*C.PangoLayout)(c) - return layout -} - -//PangoContext *pango_layout_get_context (PangoLayout *layout); -func (v *Layout) GetContext() *Context { - c := C.pango_layout_get_context(v.native()) - - context := new(Context) - context.pangoContext = (*C.PangoContext)(c) - - return context -} - -//void pango_layout_set_attributes (PangoLayout *layout, -// PangoAttrList *attrs); -func (v *Layout) SetAttributes(attrs *AttrList) { - C.pango_layout_set_attributes(v.native(), attrs.native()) -} - -//PangoAttrList *pango_layout_get_attributes (PangoLayout *layout); -func (v *Layout) GetAttributes() *AttrList { - c := C.pango_layout_get_attributes(v.native()) - - attrList := new(AttrList) - attrList.pangoAttrList = (*C.PangoAttrList)(c) - - return attrList -} - -//void pango_layout_set_text (PangoLayout *layout, -// const char *text, -// int length); -func (v *Layout) SetText(text string, length int) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.pango_layout_set_text(v.native(), (*C.char)(cstr), (C.int)(length)) -} - -//const char *pango_layout_get_text (PangoLayout *layout); -func (v *Layout) GetText() string { - c := C.pango_layout_get_text(v.native()) - return C.GoString((*C.char)(c)) -} - -//gint pango_layout_get_character_count (PangoLayout *layout); -func (v *Layout) GetCharacterCount() int { - c := C.pango_layout_get_character_count(v.native()) - return int(c) -} - -//void pango_layout_set_markup (PangoLayout *layout, -// const char *markup, -// int length); -func (v *Layout) SetMarkup(text string, length int) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.pango_layout_set_markup(v.native(), (*C.char)(cstr), (C.int)(length)) -} - -//void pango_layout_set_markup_with_accel (PangoLayout *layout, -// const char *markup, -// int length, -// gunichar accel_marker, -// gunichar *accel_char); - -/* -func (v *Layout)SetMarkupWithAccel (text string, length int, accel_marker, accel_char rune){ - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.pango_layout_set_markup_with_accel (v.native(), (*C.char)(cstr), (C.int)(length), (C.gunichar)(accel_marker), (C.gunichar)(accel_char) ) -} -*/ - -//void pango_layout_set_font_description (PangoLayout *layout, -// const PangoFontDescription *desc); - -func (v *Layout) SetFontDescription(desc *FontDescription) { - C.pango_layout_set_font_description(v.native(), desc.native()) -} - -//const PangoFontDescription *pango_layout_get_font_description (PangoLayout *layout); - -func (v *Layout) GetFontDescription() *FontDescription { - c := C.pango_layout_get_font_description(v.native()) - - desc := new(FontDescription) - desc.pangoFontDescription = (*C.PangoFontDescription)(c) - - return desc -} - -//void pango_layout_set_width (PangoLayout *layout, -// int width); - -func (v *Layout) SetWidth(width int) { - C.pango_layout_set_width(v.native(), C.int(width)) -} - -//int pango_layout_get_width (PangoLayout *layout); - -func (v *Layout) GetWidth() int { - c := C.pango_layout_get_width(v.native()) - return int(c) -} - -//void pango_layout_set_height (PangoLayout *layout, -// int height); - -func (v *Layout) SetHeight(width int) { - C.pango_layout_set_height(v.native(), C.int(width)) -} - -//int pango_layout_get_height (PangoLayout *layout); - -func (v *Layout) GetHeight() int { - c := C.pango_layout_get_height(v.native()) - return int(c) -} - -//void pango_layout_set_wrap (PangoLayout *layout, -// PangoWrapMode wrap); - -func (v *Layout) SetWrap(wrap WrapMode) { - C.pango_layout_set_wrap(v.native(), C.PangoWrapMode(wrap)) -} - -//PangoWrapMode pango_layout_get_wrap (PangoLayout *layout); - -func (v *Layout) GetWrap() WrapMode { - c := C.pango_layout_get_wrap(v.native()) - return WrapMode(c) -} - -//gboolean pango_layout_is_wrapped (PangoLayout *layout); - -func (v *Layout) IsWrapped() bool { - c := C.pango_layout_is_wrapped(v.native()) - return gobool(c) -} - -//void pango_layout_set_indent (PangoLayout *layout, -// int indent); - -func (v *Layout) SetIndent(indent int) { - C.pango_layout_set_indent(v.native(), C.int(indent)) -} - -//int pango_layout_get_indent (PangoLayout *layout); - -func (v *Layout) GetIndent() int { - c := C.pango_layout_get_indent(v.native()) - return int(c) -} - -//void pango_layout_set_spacing (PangoLayout *layout, -// int spacing); -//int pango_layout_get_spacing (PangoLayout *layout); -//void pango_layout_set_justify (PangoLayout *layout, -// gboolean justify); -//gboolean pango_layout_get_justify (PangoLayout *layout); -//void pango_layout_set_auto_dir (PangoLayout *layout, -// gboolean auto_dir); -//gboolean pango_layout_get_auto_dir (PangoLayout *layout); -//void pango_layout_set_alignment (PangoLayout *layout, -// PangoAlignment alignment); -//PangoAlignment pango_layout_get_alignment (PangoLayout *layout); -// -//void pango_layout_set_tabs (PangoLayout *layout, -// PangoTabArray *tabs); -// -//PangoTabArray* pango_layout_get_tabs (PangoLayout *layout); -// -//void pango_layout_set_single_paragraph_mode (PangoLayout *layout, -// gboolean setting); -//gboolean pango_layout_get_single_paragraph_mode (PangoLayout *layout); -// -//void pango_layout_set_ellipsize (PangoLayout *layout, -// PangoEllipsizeMode ellipsize); -//PangoEllipsizeMode pango_layout_get_ellipsize (PangoLayout *layout); -//gboolean pango_layout_is_ellipsized (PangoLayout *layout); -// -//int pango_layout_get_unknown_glyphs_count (PangoLayout *layout); -// -//void pango_layout_context_changed (PangoLayout *layout); -//guint pango_layout_get_serial (PangoLayout *layout); -// -//void pango_layout_get_log_attrs (PangoLayout *layout, -// PangoLogAttr **attrs, -// gint *n_attrs); -// -//const PangoLogAttr *pango_layout_get_log_attrs_readonly (PangoLayout *layout, -// gint *n_attrs); -// -//void pango_layout_index_to_pos (PangoLayout *layout, -// int index_, -// PangoRectangle *pos); -//void pango_layout_index_to_line_x (PangoLayout *layout, -// int index_, -// gboolean trailing, -// int *line, -// int *x_pos); -//void pango_layout_get_cursor_pos (PangoLayout *layout, -// int index_, -// PangoRectangle *strong_pos, -// PangoRectangle *weak_pos); -//void pango_layout_move_cursor_visually (PangoLayout *layout, -// gboolean strong, -// int old_index, -// int old_trailing, -// int direction, -// int *new_index, -// int *new_trailing); -//gboolean pango_layout_xy_to_index (PangoLayout *layout, -// int x, -// int y, -// int *index_, -// int *trailing); -//void pango_layout_get_extents (PangoLayout *layout, -// PangoRectangle *ink_rect, -// PangoRectangle *logical_rect); -//void pango_layout_get_pixel_extents (PangoLayout *layout, -// PangoRectangle *ink_rect, -// PangoRectangle *logical_rect); - -//void pango_layout_get_size (PangoLayout *layout, -// int *width, -// int *height); -func (v *Layout) GetSize() (int, int) { - var w, h C.int - C.pango_layout_get_size(v.native(), &w, &h) - return int(w), int(h) -} - -//void pango_layout_get_pixel_size (PangoLayout *layout, -// int *width, -// int *height); -//int pango_layout_get_baseline (PangoLayout *layout); -// -//int pango_layout_get_line_count (PangoLayout *layout); -//PangoLayoutLine *pango_layout_get_line (PangoLayout *layout, -// int line); -//PangoLayoutLine *pango_layout_get_line_readonly (PangoLayout *layout, -// int line); -//GSList * pango_layout_get_lines (PangoLayout *layout); -//GSList * pango_layout_get_lines_readonly (PangoLayout *layout); -// -// -//#define PANGO_TYPE_LAYOUT_LINE (pango_layout_line_get_type ()) -// -//GType pango_layout_line_get_type (void) G_GNUC_CONST; -// -//PangoLayoutLine *pango_layout_line_ref (PangoLayoutLine *line); -//void pango_layout_line_unref (PangoLayoutLine *line); -// -//gboolean pango_layout_line_x_to_index (PangoLayoutLine *line, -// int x_pos, -// int *index_, -// int *trailing); -//void pango_layout_line_index_to_x (PangoLayoutLine *line, -// int index_, -// gboolean trailing, -// int *x_pos); -//void pango_layout_line_get_x_ranges (PangoLayoutLine *line, -// int start_index, -// int end_index, -// int **ranges, -// int *n_ranges); -//void pango_layout_line_get_extents (PangoLayoutLine *line, -// PangoRectangle *ink_rect, -// PangoRectangle *logical_rect); -//void pango_layout_line_get_pixel_extents (PangoLayoutLine *layout_line, -// PangoRectangle *ink_rect, -// PangoRectangle *logical_rect); -// -//typedef struct _PangoLayoutIter PangoLayoutIter; -// -//#define PANGO_TYPE_LAYOUT_ITER (pango_layout_iter_get_type ()) -// -//GType pango_layout_iter_get_type (void) G_GNUC_CONST; -// -//PangoLayoutIter *pango_layout_get_iter (PangoLayout *layout); -//PangoLayoutIter *pango_layout_iter_copy (PangoLayoutIter *iter); -//void pango_layout_iter_free (PangoLayoutIter *iter); -// -//int pango_layout_iter_get_index (PangoLayoutIter *iter); -//PangoLayoutRun *pango_layout_iter_get_run (PangoLayoutIter *iter); -//PangoLayoutRun *pango_layout_iter_get_run_readonly (PangoLayoutIter *iter); -//PangoLayoutLine *pango_layout_iter_get_line (PangoLayoutIter *iter); -//PangoLayoutLine *pango_layout_iter_get_line_readonly (PangoLayoutIter *iter); -//gboolean pango_layout_iter_at_last_line (PangoLayoutIter *iter); -//PangoLayout *pango_layout_iter_get_layout (PangoLayoutIter *iter); -// -//gboolean pango_layout_iter_next_char (PangoLayoutIter *iter); -//gboolean pango_layout_iter_next_cluster (PangoLayoutIter *iter); -//gboolean pango_layout_iter_next_run (PangoLayoutIter *iter); -//gboolean pango_layout_iter_next_line (PangoLayoutIter *iter); -// -//void pango_layout_iter_get_char_extents (PangoLayoutIter *iter, -// PangoRectangle *logical_rect); -//void pango_layout_iter_get_cluster_extents (PangoLayoutIter *iter, -// PangoRectangle *ink_rect, -// PangoRectangle *logical_rect); -//void pango_layout_iter_get_run_extents (PangoLayoutIter *iter, -// PangoRectangle *ink_rect, -// PangoRectangle *logical_rect); -//void pango_layout_iter_get_line_extents (PangoLayoutIter *iter, -// PangoRectangle *ink_rect, -// PangoRectangle *logical_rect); -/* All the yranges meet, unlike the logical_rect's (i.e. the yranges - * assign between-line spacing to the nearest line) - */ -//void pango_layout_iter_get_line_yrange (PangoLayoutIter *iter, -// int *y0_, -// int *y1_); -//void pango_layout_iter_get_layout_extents (PangoLayoutIter *iter, -// PangoRectangle *ink_rect, -// PangoRectangle *logical_rect); -//int pango_layout_iter_get_baseline (PangoLayoutIter *iter); -// diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pango-layout.go.h b/vendor/github.com/gotk3/gotk3.old/pango/pango-layout.go.h deleted file mode 100644 index 0f4e2fd..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pango-layout.go.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2015- terrak - * - * This file originated from: http://www.terrak.net/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -static PangoLayout* toPangoLayout(void *p) -{ - return ( (PangoLayout*) (p) ); -} - diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pango-types.go b/vendor/github.com/gotk3/gotk3.old/pango/pango-types.go deleted file mode 100644 index bec95ea..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pango-types.go +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2015- terrak - * - * This file originated from: http://www.terrak.net/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package pango - -// #cgo pkg-config: pango -// #include -// #include "pango.go.h" -// #include -import "C" -import ( - "unsafe" -) - -// LogAttr is a representation of PangoLogAttr. -type LogAttr struct { - pangoLogAttr *C.PangoLogAttr -} - -// Native returns a pointer to the underlying PangoLayout. -func (v *LogAttr) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *LogAttr) native() *C.PangoLogAttr { - return (*C.PangoLogAttr)(unsafe.Pointer(v.pangoLogAttr)) -} - -// EngineLang is a representation of PangoEngineLang. -type EngineLang struct { - pangoEngineLang *C.PangoEngineLang -} - -// Native returns a pointer to the underlying PangoLayout. -func (v *EngineLang) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *EngineLang) native() *C.PangoEngineLang { - return (*C.PangoEngineLang)(unsafe.Pointer(v.pangoEngineLang)) -} - -// EngineShape is a representation of PangoEngineShape. -type EngineShape struct { - pangoEngineShape *C.PangoEngineShape -} - -// Native returns a pointer to the underlying PangoLayout. -func (v *EngineShape) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *EngineShape) native() *C.PangoEngineShape { - return (*C.PangoEngineShape)(unsafe.Pointer(v.pangoEngineShape)) -} - -// Font is a representation of PangoFont. -type Font struct { - pangoFont *C.PangoFont -} - -// Native returns a pointer to the underlying PangoLayout. -func (v *Font) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *Font) native() *C.PangoFont { - return (*C.PangoFont)(unsafe.Pointer(v.pangoFont)) -} - -// FontMap is a representation of PangoFontMap. -type FontMap struct { - pangoFontMap *C.PangoFontMap -} - -// Native returns a pointer to the underlying PangoLayout. -func (v *FontMap) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *FontMap) native() *C.PangoFontMap { - return (*C.PangoFontMap)(unsafe.Pointer(v.pangoFontMap)) -} - -// Rectangle is a representation of PangoRectangle. -type Rectangle struct { - pangoRectangle *C.PangoRectangle -} - -// Native returns a pointer to the underlying PangoLayout. -func (v *Rectangle) Native() uintptr { - return uintptr(unsafe.Pointer(v.native())) -} - -func (v *Rectangle) native() *C.PangoRectangle { - return (*C.PangoRectangle)(unsafe.Pointer(v.pangoRectangle)) -} - -// Glyph is a representation of PangoGlyph -type Glyph uint32 - -//void pango_extents_to_pixels (PangoRectangle *inclusive, -// PangoRectangle *nearest); -func (inclusive *Rectangle) ExtentsToPixels(nearest *Rectangle) { - C.pango_extents_to_pixels(inclusive.native(), nearest.native()) -} - -func RectangleNew(x, y, width, height int) *Rectangle { - r := new(Rectangle) - r.pangoRectangle = C.createPangoRectangle((C.int)(x), (C.int)(y), (C.int)(width), (C.int)(height)) - return r -} diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pango.go b/vendor/github.com/gotk3/gotk3.old/pango/pango.go deleted file mode 100644 index b540f73..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pango.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2013-2014 Conformal Systems -// -// This file originated from: http://opensource.conformal.com/ -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// Go bindings for Pango. -package pango - -// #cgo pkg-config: pango -// #include -// #include "pango.go.h" -import "C" -import ( -// "github.com/andre-hub/gotk3/glib" -// "unsafe" -) - -func init() { - -} - -/* - * Type conversions - */ - -func gbool(b bool) C.gboolean { - if b { - return C.gboolean(1) - } - return C.gboolean(0) -} -func gobool(b C.gboolean) bool { - if b != 0 { - return true - } - return false -} - -/* - * Constantes - */ - -const ( - SCALE int = 1024 -) diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pango.go.h b/vendor/github.com/gotk3/gotk3.old/pango/pango.go.h deleted file mode 100644 index 74c81e4..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pango.go.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2015- terrak - * - * This file originated from: http://www.terrak.net/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -#include "pango-attributes.go.h" -#include "pango-layout.go.h" - -#include "pangocairo.go.h" - - - -static PangoRectangle * -createPangoRectangle(int x, int y, int width, int height) -{ - PangoRectangle *r = (PangoRectangle *)malloc(sizeof(PangoRectangle)); - r->x = x; - r->y = y; - r->width = width; - r->height = height; - return r; -} diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pangocairo.go b/vendor/github.com/gotk3/gotk3.old/pango/pangocairo.go deleted file mode 100644 index 3de012a..0000000 --- a/vendor/github.com/gotk3/gotk3.old/pango/pangocairo.go +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2015- terrak - * - * This file originated from: http://www.terrak.net/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package pango - -// #cgo pkg-config: pango pangocairo -// #include -// #include -// #include -// #include "pango.go.h" -import "C" -import ( - // "github.com/gotk3/gotk3/glib" - "unsafe" - - "github.com/gotk3/gotk3/cairo" -) - -func init() { - // tm := []glib.TypeMarshaler{ - // // Enums - // {glib.Type(C.pango_alignement_get_type()), marshalAlignment}, - // {glib.Type(C.pango_ellipsize_mode_get_type()), marshalEllipsizeMode}, - // {glib.Type(C.pango_wrap_mode_get_type()), marshalWrapMode}, - // } - // glib.RegisterGValueMarshalers(tm) -} - -func cairo_context(cr *cairo.Context) *C.cairo_t { - return (*C.cairo_t)(cr.GetCContext()) -} - -/* Convenience - */ -//PangoContext *pango_cairo_create_context (cairo_t *cr); -func CairoCreateContext(cr *cairo.Context) *Context { - c := C.pango_cairo_create_context(cairo_context(cr)) - context := new(Context) - context.pangoContext = (*C.PangoContext)(c) - return context -} - -//PangoLayout *pango_cairo_create_layout (cairo_t *cr); -func CairoCreateLayout(cr *cairo.Context) *Layout { - c := C.pango_cairo_create_layout(cairo_context(cr)) - layout := new(Layout) - layout.pangoLayout = (*C.PangoLayout)(c) - return layout -} - -//void pango_cairo_update_layout (cairo_t *cr, -// PangoLayout *layout); -func CairoUpdateLayout(cr *cairo.Context, v *Layout) { - C.pango_cairo_update_layout(cairo_context(cr), v.native()) -} - -/* - * Rendering - */ -//void pango_cairo_show_glyph_string (cairo_t *cr, -// PangoFont *font, -// PangoGlyphString *glyphs); -func CairoShowGlyphString(cr *cairo.Context, font *Font, glyphs *GlyphString) { - C.pango_cairo_show_glyph_string(cairo_context(cr), font.native(), glyphs.native()) -} - -//void pango_cairo_show_glyph_item (cairo_t *cr, -// const char *text, -// PangoGlyphItem *glyph_item); -func CairoShowGlyphItem(cr *cairo.Context, text string, glyph_item *GlyphItem) { - cstr := C.CString(text) - defer C.free(unsafe.Pointer(cstr)) - C.pango_cairo_show_glyph_item(cairo_context(cr), (*C.char)(cstr), glyph_item.native()) -} - -//void pango_cairo_show_layout_line (cairo_t *cr, -// PangoLayoutLine *line); -func CairoShowLayoutLine(cr *cairo.Context, line *LayoutLine) { - C.pango_cairo_show_layout_line(cairo_context(cr), line.native()) -} - -//void pango_cairo_show_layout (cairo_t *cr, -// PangoLayout *layout); -func CairoShowLayout(cr *cairo.Context, layout *Layout) { - C.pango_cairo_show_layout(cairo_context(cr), layout.native()) -} - -//void pango_cairo_show_error_underline (cairo_t *cr, -// double x, -// double y, -// double width, -// double height); - -/* - * Rendering to a path - */ - -//void pango_cairo_glyph_string_path (cairo_t *cr, -// PangoFont *font, -// PangoGlyphString *glyphs); -func CairoGlyphStringPath(cr *cairo.Context, font *Font, glyphs *GlyphString) { - C.pango_cairo_glyph_string_path(cairo_context(cr), font.native(), glyphs.native()) -} - -//void pango_cairo_layout_line_path (cairo_t *cr, -// PangoLayoutLine *line); -func CairoLayoutLinePath(cr *cairo.Context, line *LayoutLine) { - C.pango_cairo_layout_line_path(cairo_context(cr), line.native()) -} - -//void pango_cairo_layout_path (cairo_t *cr, -// PangoLayout *layout); -func CairoLayoutPath(cr *cairo.Context, layout *Layout) { - C.pango_cairo_layout_path(cairo_context(cr), layout.native()) -} - -//void pango_cairo_error_underline_path (cairo_t *cr, -// double x, -// double y, -// double width, -// double height); -func CairoErrorUnderlinePath(cr *cairo.Context, x, y, width, height float64) { - C.pango_cairo_error_underline_path(cairo_context(cr), C.double(x), C.double(y), C.double(width), C.double(height)) -} diff --git a/vendor/github.com/gotk3/gotk3.old/pango/pangocairo.go.h b/vendor/github.com/gotk3/gotk3.old/pango/pangocairo.go.h deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/github.com/gotk3/gotk3/.travis.yml b/vendor/github.com/gotk3/gotk3/.travis.yml deleted file mode 100644 index 3594215..0000000 --- a/vendor/github.com/gotk3/gotk3/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: go - -go: - - 1.4 - - 1.5 - - 1.6 - - tip - -env: - - GOARCH=amd64 - -sudo: required -dist: trusty - -before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq -y gtk+3.0 libgtk-3-dev - - sudo apt-get install -qq -y xvfb - - "export DISPLAY=:99.0" - - sudo /usr/bin/Xvfb $DISPLAY 2>1 > /dev/null & - - "export GTK_VERSION=$(pkg-config --modversion gtk+-3.0 | tr . _| cut -d '_' -f 1-2)" - - "export Glib_VERSION=$(pkg-config --modversion glib-2.0)" - - "export Cairo_VERSION=$(pkg-config --modversion cairo)" - - "export Pango_VERSION=$(pkg-config --modversion pango)" - - echo "GTK version ${GTK_VERSION} (Glib ${Glib_VERSION}, Cairo ${Cairo_VERSION}, Pango ${Pango_VERSION})" - -install: - - go get -t -tags "gtk_${GTK_VERSION}" github.com/gotk3/gotk3/... - -script: - - go test -tags "gtk_${GTK_VERSION}" ./... \ No newline at end of file diff --git a/vendor/github.com/gotk3/gotk3/README.md b/vendor/github.com/gotk3/gotk3/README.md index 1bbcded..49f102c 100644 --- a/vendor/github.com/gotk3/gotk3/README.md +++ b/vendor/github.com/gotk3/gotk3/README.md @@ -79,6 +79,103 @@ $ go build -tags gtk_3_10 example.go ``` +### examples for gtk3 + +```Go +package main + +import ( + "log" + "os" + + "github.com/gotk3/gotk3/glib" + "github.com/gotk3/gotk3/gtk" +) + +// Simple Gtk3 Application written in go. +// This application creates a window on the application callback activate. +// More GtkApplication info can be found here -> https://wiki.gnome.org/HowDoI/GtkApplication + +func main() { + // Create Gtk Application, change appID to your application domain name reversed. + const appID = "org.gtk.example" + application, err := gtk.ApplicationNew(appID, glib.APPLICATION_FLAGS_NONE) + // Check to make sure no errors when creating Gtk Application + if err != nil { + log.Fatal("Could not create application.", err) + } + // Application signals available + // startup -> sets up the application when it first starts + // activate -> shows the default first window of the application (like a new document). This corresponds to the application being launched by the desktop environment. + // open -> opens files and shows them in a new window. This corresponds to someone trying to open a document (or documents) using the application from the file browser, or similar. + // shutdown -> performs shutdown tasks + // Setup Gtk Application callback signals + application.Connect("activate", func() { onActivate(application) }) + // Run Gtk application + os.Exit(application.Run(os.Args)) +} + +// Callback signal from Gtk Application +func onActivate(application *gtk.Application) { + // Create ApplicationWindow + appWindow, err := gtk.ApplicationWindowNew(application) + if err != nil { + log.Fatal("Could not create application window.", err) + } + // Set ApplicationWindow Properties + appWindow.SetTitle("Basic Application.") + appWindow.SetDefaultSize(400, 400) + appWindow.Show() +} +``` + + +```Go +package main + +import ( + "log" + "os" + + "github.com/gotk3/gotk3/glib" + "github.com/gotk3/gotk3/gtk" +) + +// Simple Gtk3 Application written in go. +// This application creates a window on the application callback activate. +// More GtkApplication info can be found here -> https://wiki.gnome.org/HowDoI/GtkApplication + +func main() { + // Create Gtk Application, change appID to your application domain name reversed. + const appID = "org.gtk.example" + application, err := gtk.ApplicationNew(appID, glib.APPLICATION_FLAGS_NONE) + // Check to make sure no errors when creating Gtk Application + if err != nil { + log.Fatal("Could not create application.", err) + } + + // Application signals available + // startup -> sets up the application when it first starts + // activate -> shows the default first window of the application (like a new document). This corresponds to the application being launched by the desktop environment. + // open -> opens files and shows them in a new window. This corresponds to someone trying to open a document (or documents) using the application from the file browser, or similar. + // shutdown -> performs shutdown tasks + // Setup activate signal with a closure function. + application.Connect("activate", func() { + // Create ApplicationWindow + appWindow, err := gtk.ApplicationWindowNew(application) + if err != nil { + log.Fatal("Could not create application window.", err) + } + // Set ApplicationWindow Properties + appWindow.SetTitle("Basic Application.") + appWindow.SetDefaultSize(400, 400) + appWindow.Show() + }) + // Run Gtk application + application.Run(os.Args) +} +``` + ## Documentation Each package's internal `go doc` style documentation can be viewed diff --git a/vendor/github.com/gotk3/gotk3/cairo/canvas.go b/vendor/github.com/gotk3/gotk3/cairo/canvas.go index 121b59f..59d6e4c 100644 --- a/vendor/github.com/gotk3/gotk3/cairo/canvas.go +++ b/vendor/github.com/gotk3/gotk3/cairo/canvas.go @@ -44,6 +44,11 @@ func wrapContext(context *C.cairo_t) *Context { return &Context{context} } +func WrapContext(p uintptr) *Context { + context := (*C.cairo_t)(unsafe.Pointer(p)) + return wrapContext(context) +} + // Create is a wrapper around cairo_create(). func Create(target *Surface) *Context { c := C.cairo_create(target.native()) diff --git a/vendor/github.com/gotk3/gotk3/cairo/pattern.go b/vendor/github.com/gotk3/gotk3/cairo/pattern.go new file mode 100644 index 0000000..e369f75 --- /dev/null +++ b/vendor/github.com/gotk3/gotk3/cairo/pattern.go @@ -0,0 +1,140 @@ +package cairo + +// #cgo pkg-config: cairo cairo-gobject +// #include +// #include +// #include +import "C" + +import ( + "runtime" + "unsafe" +) + +/* + * cairo_pattern_t + */ + +// Pattern is a representation of Cairo's cairo_pattern_t. +type Pattern struct { + pattern *C.cairo_pattern_t +} + +func NewPatternFromRGB(red, green, blue float64) (*Pattern, error) { + patternNative := C.cairo_pattern_create_rgb(C.double(red), C.double(green), C.double(blue)) + status := Status(C.cairo_pattern_status(patternNative)) + if status != STATUS_SUCCESS { + return nil, ErrorStatus(status) + } + pattern := wrapPattern(patternNative) + runtime.SetFinalizer(pattern, (*Pattern).destroy) + return pattern, nil +} + +func NewPatternFromRGBA(red, green, blue, alpha float64) (*Pattern, error) { + patternNative := C.cairo_pattern_create_rgba(C.double(red), C.double(green), C.double(blue), C.double(alpha)) + status := Status(C.cairo_pattern_status(patternNative)) + if status != STATUS_SUCCESS { + return nil, ErrorStatus(status) + } + pattern := wrapPattern(patternNative) + runtime.SetFinalizer(pattern, (*Pattern).destroy) + return pattern, nil +} + +func NewPatternForSurface(s *Surface) (*Pattern, error) { + patternNative := C.cairo_pattern_create_for_surface(s.native()) + status := Status(C.cairo_pattern_status(patternNative)) + if status != STATUS_SUCCESS { + return nil, ErrorStatus(status) + } + pattern := wrapPattern(patternNative) + runtime.SetFinalizer(pattern, (*Pattern).destroy) + return pattern, nil +} + +func NewPatternLinear(x0, y0, x1, y1 float64) (*Pattern, error) { + patternNative := C.cairo_pattern_create_linear(C.double(x0), C.double(y0), C.double(x1), C.double(y1)) + status := Status(C.cairo_pattern_status(patternNative)) + if status != STATUS_SUCCESS { + return nil, ErrorStatus(status) + } + pattern := wrapPattern(patternNative) + runtime.SetFinalizer(pattern, (*Pattern).destroy) + return pattern, nil +} + +func NewPatternRadial(x0, y0, r0, x1, y1, r1 float64) (*Pattern, error) { + patternNative := C.cairo_pattern_create_radial(C.double(x0), C.double(y0), C.double(r0), + C.double(x1), C.double(y1), C.double(r1)) + status := Status(C.cairo_pattern_status(patternNative)) + if status != STATUS_SUCCESS { + return nil, ErrorStatus(status) + } + pattern := wrapPattern(patternNative) + runtime.SetFinalizer(pattern, (*Pattern).destroy) + return pattern, nil +} + +func (p *Pattern) AddColorStopRGB(offset, red, green, blue float64) error { + C.cairo_pattern_add_color_stop_rgb(p.native(), C.double(offset), + C.double(red), C.double(green), C.double(blue)) + status := Status(C.cairo_pattern_status(p.native())) + if status != STATUS_SUCCESS { + return ErrorStatus(status) + } + return nil +} + +func (p *Pattern) AddColorStopRGBA(offset, red, green, blue, alpha float64) error { + C.cairo_pattern_add_color_stop_rgba(p.native(), C.double(offset), + C.double(red), C.double(green), C.double(blue), C.double(alpha)) + status := Status(C.cairo_pattern_status(p.native())) + if status != STATUS_SUCCESS { + return ErrorStatus(status) + } + return nil +} + +func (v *Context) SetSource(p *Pattern) { + C.cairo_set_source(v.native(), p.native()) +} + +// native returns a pointer to the underlying cairo_pattern_t. +func (v *Pattern) native() *C.cairo_pattern_t { + if v == nil { + return nil + } + return v.pattern +} + +// Native returns a pointer to the underlying cairo_pattern_t. +func (v *Pattern) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func marshalPattern(p uintptr) (interface{}, error) { + c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) + pattern := (*C.cairo_pattern_t)(unsafe.Pointer(c)) + return wrapPattern(pattern), nil +} + +func wrapPattern(pattern *C.cairo_pattern_t) *Pattern { + return &Pattern{pattern} +} + +// reference is a wrapper around cairo_pattern_reference(). +func (v *Pattern) reference() { + v.pattern = C.cairo_pattern_reference(v.native()) +} + +// destroy is a wrapper around cairo_pattern_destroy(). +func (v *Pattern) destroy() { + C.cairo_pattern_destroy(v.native()) +} + +// Status is a wrapper around cairo_pattern_status(). +func (v *Pattern) Status() Status { + c := C.cairo_pattern_status(v.native()) + return Status(c) +} diff --git a/vendor/github.com/gotk3/gotk3/gdk/gdk.go b/vendor/github.com/gotk3/gotk3/gdk/gdk.go index 1135a96..a532dc1 100644 --- a/vendor/github.com/gotk3/gotk3/gdk/gdk.go +++ b/vendor/github.com/gotk3/gotk3/gdk/gdk.go @@ -252,6 +252,21 @@ const ( SCROLL_SMOOTH ScrollDirection = C.GDK_SCROLL_SMOOTH ) +// WindowState is a representation of GDK's GdkWindowState +type WindowState int + +const ( + WINDOW_STATE_WITHDRAWN WindowState = C.GDK_WINDOW_STATE_WITHDRAWN + WINDOW_STATE_ICONIFIED WindowState = C.GDK_WINDOW_STATE_ICONIFIED + WINDOW_STATE_MAXIMIZED WindowState = C.GDK_WINDOW_STATE_MAXIMIZED + WINDOW_STATE_STICKY WindowState = C.GDK_WINDOW_STATE_STICKY + WINDOW_STATE_FULLSCREEN WindowState = C.GDK_WINDOW_STATE_FULLSCREEN + WINDOW_STATE_ABOVE WindowState = C.GDK_WINDOW_STATE_ABOVE + WINDOW_STATE_BELOW WindowState = C.GDK_WINDOW_STATE_BELOW + WINDOW_STATE_FOCUSED WindowState = C.GDK_WINDOW_STATE_FOCUSED + WINDOW_STATE_TILED WindowState = C.GDK_WINDOW_STATE_TILED +) + // CURRENT_TIME is a representation of GDK_CURRENT_TIME const CURRENT_TIME = C.GDK_CURRENT_TIME @@ -352,25 +367,6 @@ func marshalDevice(p uintptr) (interface{}, error) { return &Device{obj}, nil } -// Grab() is a wrapper around gdk_device_grab(). -func (v *Device) Grab(w *Window, ownership GrabOwnership, owner_events bool, event_mask EventMask, cursor *Cursor, time uint32) GrabStatus { - ret := C.gdk_device_grab( - v.native(), - w.native(), - C.GdkGrabOwnership(ownership), - gbool(owner_events), - C.GdkEventMask(event_mask), - cursor.native(), - C.guint32(time), - ) - return GrabStatus(ret) -} - -// Ungrab() is a wrapper around gdk_device_ungrab(). -func (v *Device) Ungrab(time uint32) { - C.gdk_device_ungrab(v.native(), C.guint32(time)) -} - /* * GdkCursor */ @@ -380,6 +376,21 @@ type Cursor struct { *glib.Object } +// CursorNewFromName is a wrapper around gdk_cursor_new_from_name(). +func CursorNewFromName(display *Display, name string) (*Cursor, error) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + c := C.gdk_cursor_new_from_name(display.native(), (*C.gchar)(cstr)) + if c == nil { + return nil, nilPtrErr + } + + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + runtime.SetFinalizer(obj, (*glib.Object).Unref) + + return &Cursor{obj}, nil +} + // native returns a pointer to the underlying GdkCursor. func (v *Cursor) native() *C.GdkCursor { if v == nil || v.GObject == nil { @@ -429,18 +440,6 @@ func marshalDeviceManager(p uintptr) (interface{}, error) { return &DeviceManager{obj}, nil } -// GetClientPointer() is a wrapper around gdk_device_manager_get_client_pointer(). -func (v *DeviceManager) GetClientPointer() (*Device, error) { - c := C.gdk_device_manager_get_client_pointer(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return &Device{obj}, nil -} - // GetDisplay() is a wrapper around gdk_device_manager_get_display(). func (v *DeviceManager) GetDisplay() (*Display, error) { c := C.gdk_device_manager_get_display(v.native()) @@ -453,22 +452,6 @@ func (v *DeviceManager) GetDisplay() (*Display, error) { return &Display{obj}, nil } -// ListDevices() is a wrapper around gdk_device_manager_list_devices(). -func (v *DeviceManager) ListDevices(tp DeviceType) *glib.List { - clist := C.gdk_device_manager_list_devices(v.native(), C.GdkDeviceType(tp)) - if clist == nil { - return nil - } - glist := glib.WrapList(uintptr(unsafe.Pointer(clist))) - glist.DataWrapper(func(ptr unsafe.Pointer) interface{} { - return &Device{&glib.Object{glib.ToGObject(ptr)}} - }) - runtime.SetFinalizer(glist, func(glist *glib.List) { - glist.Free() - }) - return glist -} - /* * GdkDisplay */ @@ -543,19 +526,6 @@ func (v *Display) GetName() (string, error) { return C.GoString((*C.char)(c)), nil } -// GetScreen() is a wrapper around gdk_display_get_screen(). -func (v *Display) GetScreen(screenNum int) (*Screen, error) { - c := C.gdk_display_get_screen(v.native(), C.gint(screenNum)) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - s := &Screen{obj} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return s, nil -} - // GetDefaultScreen() is a wrapper around gdk_display_get_default_screen(). func (v *Display) GetDefaultScreen() (*Screen, error) { c := C.gdk_display_get_default_screen(v.native()) @@ -569,19 +539,6 @@ func (v *Display) GetDefaultScreen() (*Screen, error) { return s, nil } -// GetDeviceManager() is a wrapper around gdk_display_get_device_manager(). -func (v *Display) GetDeviceManager() (*DeviceManager, error) { - c := C.gdk_display_get_device_manager(v.native()) - if c == nil { - return nil, nilPtrErr - } - obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} - d := &DeviceManager{obj} - obj.Ref() - runtime.SetFinalizer(obj, (*glib.Object).Unref) - return d, nil -} - // DeviceIsGrabbed() is a wrapper around gdk_display_device_is_grabbed(). func (v *Display) DeviceIsGrabbed(device *Device) bool { c := C.gdk_display_device_is_grabbed(v.native(), device.native()) @@ -1167,6 +1124,58 @@ func (v *EventScroll) Direction() ScrollDirection { return ScrollDirection(c) } +/* + * GdkEventWindowState + */ + +// EventWindowState is a representation of GDK's GdkEventWindowState. +type EventWindowState struct { + *Event +} + +func EventWindowStateNew() *EventWindowState { + ee := (*C.GdkEvent)(unsafe.Pointer(&C.GdkEventWindowState{})) + ev := Event{ee} + return &EventWindowState{&ev} +} + +// EventWindowStateNewFromEvent returns an EventWindowState from an Event. +// +// Using widget.Connect() for the +// "window-state-event" signal results in a *Event being passed as +// the callback's second argument. The argument is actually a +// *EventWindowState. EventWindowStateNewFromEvent provides a means of creating +// an EventWindowState from the Event. +func EventWindowStateNewFromEvent(event *Event) *EventWindowState { + ee := (*C.GdkEvent)(unsafe.Pointer(event.native())) + ev := Event{ee} + return &EventWindowState{&ev} +} + +// Native returns a pointer to the underlying GdkEventWindowState. +func (v *EventWindowState) Native() uintptr { + return uintptr(unsafe.Pointer(v.native())) +} + +func (v *EventWindowState) native() *C.GdkEventWindowState { + return (*C.GdkEventWindowState)(unsafe.Pointer(v.Event.native())) +} + +func (v *EventWindowState) Type() EventType { + c := v.native()._type + return EventType(c) +} + +func (v *EventWindowState) ChangedMask() WindowState { + c := v.native().changed_mask + return WindowState(c) +} + +func (v *EventWindowState) NewWindowState() WindowState { + c := v.native().new_window_state + return WindowState(c) +} + /* * GdkGravity */ @@ -1724,6 +1733,11 @@ type Window struct { *glib.Object } +// SetCursor is a wrapper around gdk_window_set_cursor(). +func (v *Window) SetCursor(cursor *Cursor) { + C.gdk_window_set_cursor(v.native(), cursor.native()) +} + // native returns a pointer to the underlying GdkWindow. func (v *Window) native() *C.GdkWindow { if v == nil || v.GObject == nil { diff --git a/vendor/github.com/gotk3/gotk3/gdk/gdk_deprecated_since_3_20.go b/vendor/github.com/gotk3/gotk3/gdk/gdk_deprecated_since_3_20.go new file mode 100644 index 0000000..fe4f218 --- /dev/null +++ b/vendor/github.com/gotk3/gotk3/gdk/gdk_deprecated_since_3_20.go @@ -0,0 +1,86 @@ +//+build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14 gtk_3_16 gtk_3_18 + +package gdk + +// #cgo pkg-config: gdk-3.0 +// #include +import "C" +import ( + "runtime" + "unsafe" + + "github.com/gotk3/gotk3/glib" +) + +// Grab() is a wrapper around gdk_device_grab(). +func (v *Device) Grab(w *Window, ownership GrabOwnership, owner_events bool, event_mask EventMask, cursor *Cursor, time uint32) GrabStatus { + ret := C.gdk_device_grab( + v.native(), + w.native(), + C.GdkGrabOwnership(ownership), + gbool(owner_events), + C.GdkEventMask(event_mask), + cursor.native(), + C.guint32(time), + ) + return GrabStatus(ret) +} + +// GetClientPointer() is a wrapper around gdk_device_manager_get_client_pointer(). +func (v *DeviceManager) GetClientPointer() (*Device, error) { + c := C.gdk_device_manager_get_client_pointer(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + obj.Ref() + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return &Device{obj}, nil +} + +// ListDevices() is a wrapper around gdk_device_manager_list_devices(). +func (v *DeviceManager) ListDevices(tp DeviceType) *glib.List { + clist := C.gdk_device_manager_list_devices(v.native(), C.GdkDeviceType(tp)) + if clist == nil { + return nil + } + glist := glib.WrapList(uintptr(unsafe.Pointer(clist))) + glist.DataWrapper(func(ptr unsafe.Pointer) interface{} { + return &Device{&glib.Object{glib.ToGObject(ptr)}} + }) + runtime.SetFinalizer(glist, func(glist *glib.List) { + glist.Free() + }) + return glist +} + +// Ungrab() is a wrapper around gdk_device_ungrab(). +func (v *Device) Ungrab(time uint32) { + C.gdk_device_ungrab(v.native(), C.guint32(time)) +} + +// GetDeviceManager() is a wrapper around gdk_display_get_device_manager(). +func (v *Display) GetDeviceManager() (*DeviceManager, error) { + c := C.gdk_display_get_device_manager(v.native()) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + d := &DeviceManager{obj} + obj.Ref() + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return d, nil +} + +// GetScreen() is a wrapper around gdk_display_get_screen(). +func (v *Display) GetScreen(screenNum int) (*Screen, error) { + c := C.gdk_display_get_screen(v.native(), C.gint(screenNum)) + if c == nil { + return nil, nilPtrErr + } + obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))} + s := &Screen{obj} + obj.Ref() + runtime.SetFinalizer(obj, (*glib.Object).Unref) + return s, nil +} diff --git a/vendor/github.com/gotk3/gotk3/gdk/gdk_deprecated_since_3_22.go b/vendor/github.com/gotk3/gotk3/gdk/gdk_deprecated_since_3_22.go new file mode 100644 index 0000000..58b98d5 --- /dev/null +++ b/vendor/github.com/gotk3/gotk3/gdk/gdk_deprecated_since_3_22.go @@ -0,0 +1,84 @@ +//+build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14 gtk_3_16 gtk_3_18 gtk_3_20 + +package gdk + +// #cgo pkg-config: gdk-3.0 +// #include +import "C" + +// GetActiveWindow is a wrapper around gdk_screen_get_active_window(). +func (v *Screen) GetActiveWindow() (*Window, error) { + return toWindow(C.gdk_screen_get_active_window(v.native())) +} + +// GetHeight is a wrapper around gdk_screen_get_height(). +func (v *Screen) GetHeight() int { + c := C.gdk_screen_get_height(v.native()) + return int(c) +} + +// GetHeightMM is a wrapper around gdk_screen_get_height_mm(). +func (v *Screen) GetHeightMM() int { + return int(C.gdk_screen_get_height_mm(v.native())) +} + +// GetMonitorAtPoint is a wrapper around gdk_screen_get_monitor_at_point(). +func (v *Screen) GetMonitorAtPoint(x, y int) int { + return int(C.gdk_screen_get_monitor_at_point(v.native(), C.gint(x), C.gint(y))) +} + +// GetMonitorAtWindow is a wrapper around gdk_screen_get_monitor_at_window(). +func (v *Screen) GetMonitorAtWindow(w *Window) int { + return int(C.gdk_screen_get_monitor_at_window(v.native(), w.native())) +} + +// GetMonitorHeightMM is a wrapper around gdk_screen_get_monitor_height_mm(). +func (v *Screen) GetMonitorHeightMM(m int) int { + return int(C.gdk_screen_get_monitor_height_mm(v.native(), C.gint(m))) +} + +// GetMonitorPlugName is a wrapper around gdk_screen_get_monitor_plug_name(). +func (v *Screen) GetMonitorPlugName(m int) (string, error) { + return toString(C.gdk_screen_get_monitor_plug_name(v.native(), C.gint(m))) +} + +// GetMonitorScaleFactor is a wrapper around gdk_screen_get_monitor_scale_factor(). +func (v *Screen) GetMonitorScaleFactor(m int) int { + return int(C.gdk_screen_get_monitor_scale_factor(v.native(), C.gint(m))) +} + +// GetMonitorWidthMM is a wrapper around gdk_screen_get_monitor_width_mm(). +func (v *Screen) GetMonitorWidthMM(m int) int { + return int(C.gdk_screen_get_monitor_width_mm(v.native(), C.gint(m))) +} + +// GetNMonitors is a wrapper around gdk_screen_get_n_monitors(). +func (v *Screen) GetNMonitors() int { + return int(C.gdk_screen_get_n_monitors(v.native())) +} + +// GetNumber is a wrapper around gdk_screen_get_number(). +func (v *Screen) GetNumber() int { + return int(C.gdk_screen_get_number(v.native())) +} + +// GetPrimaryMonitor is a wrapper around gdk_screen_get_primary_monitor(). +func (v *Screen) GetPrimaryMonitor() int { + return int(C.gdk_screen_get_primary_monitor(v.native())) +} + +// GetWidth is a wrapper around gdk_screen_get_width(). +func (v *Screen) GetWidth() int { + c := C.gdk_screen_get_width(v.native()) + return int(c) +} + +// GetWidthMM is a wrapper around gdk_screen_get_width_mm(). +func (v *Screen) GetWidthMM() int { + return int(C.gdk_screen_get_width_mm(v.native())) +} + +// MakeDisplayName is a wrapper around gdk_screen_make_display_name(). +func (v *Screen) MakeDisplayName() (string, error) { + return toString(C.gdk_screen_make_display_name(v.native())) +} diff --git a/vendor/github.com/gotk3/gotk3/gdk/screen.go b/vendor/github.com/gotk3/gotk3/gdk/screen.go index 6164731..0947022 100644 --- a/vendor/github.com/gotk3/gotk3/gdk/screen.go +++ b/vendor/github.com/gotk3/gotk3/gdk/screen.go @@ -74,18 +74,6 @@ func (v *Screen) GetSystemVisual() (*Visual, error) { return visual, nil } -// GetWidth is a wrapper around gdk_screen_get_width(). -func (v *Screen) GetWidth() int { - c := C.gdk_screen_get_width(v.native()) - return int(c) -} - -// GetHeight is a wrapper around gdk_screen_get_height(). -func (v *Screen) GetHeight() int { - c := C.gdk_screen_get_height(v.native()) - return int(c) -} - // ScreenGetDefault is a wrapper aroud gdk_screen_get_default(). func ScreenGetDefault() (*Screen, error) { return toScreen(C.gdk_screen_get_default()) @@ -106,21 +94,6 @@ func (v *Screen) GetDisplay() (*Display, error) { return toDisplay(C.gdk_screen_get_display(v.native())) } -// GetNumber is a wrapper around gdk_screen_get_number(). -func (v *Screen) GetNumber() int { - return int(C.gdk_screen_get_number(v.native())) -} - -// GetWidthMM is a wrapper around gdk_screen_get_width_mm(). -func (v *Screen) GetWidthMM() int { - return int(C.gdk_screen_get_width_mm(v.native())) -} - -// GetHeightMM is a wrapper around gdk_screen_get_height_mm(). -func (v *Screen) GetHeightMM() int { - return int(C.gdk_screen_get_height_mm(v.native())) -} - func toString(c *C.gchar) (string, error) { if c == nil { return "", nilPtrErr @@ -128,51 +101,6 @@ func toString(c *C.gchar) (string, error) { return C.GoString((*C.char)(c)), nil } -// MakeDisplayName is a wrapper around gdk_screen_make_display_name(). -func (v *Screen) MakeDisplayName() (string, error) { - return toString(C.gdk_screen_make_display_name(v.native())) -} - -// GetNMonitors is a wrapper around gdk_screen_get_n_monitors(). -func (v *Screen) GetNMonitors() int { - return int(C.gdk_screen_get_n_monitors(v.native())) -} - -// GetPrimaryMonitor is a wrapper around gdk_screen_get_primary_monitor(). -func (v *Screen) GetPrimaryMonitor() int { - return int(C.gdk_screen_get_primary_monitor(v.native())) -} - -// GetMonitorAtPoint is a wrapper around gdk_screen_get_monitor_at_point(). -func (v *Screen) GetMonitorAtPoint(x, y int) int { - return int(C.gdk_screen_get_monitor_at_point(v.native(), C.gint(x), C.gint(y))) -} - -// GetMonitorAtWindow is a wrapper around gdk_screen_get_monitor_at_window(). -func (v *Screen) GetMonitorAtWindow(w *Window) int { - return int(C.gdk_screen_get_monitor_at_window(v.native(), w.native())) -} - -// GetMonitorHeightMM is a wrapper around gdk_screen_get_monitor_height_mm(). -func (v *Screen) GetMonitorHeightMM(m int) int { - return int(C.gdk_screen_get_monitor_height_mm(v.native(), C.gint(m))) -} - -// GetMonitorWidthMM is a wrapper around gdk_screen_get_monitor_width_mm(). -func (v *Screen) GetMonitorWidthMM(m int) int { - return int(C.gdk_screen_get_monitor_width_mm(v.native(), C.gint(m))) -} - -// GetMonitorPlugName is a wrapper around gdk_screen_get_monitor_plug_name(). -func (v *Screen) GetMonitorPlugName(m int) (string, error) { - return toString(C.gdk_screen_get_monitor_plug_name(v.native(), C.gint(m))) -} - -// GetMonitorScaleFactor is a wrapper around gdk_screen_get_monitor_scale_factor(). -func (v *Screen) GetMonitorScaleFactor(m int) int { - return int(C.gdk_screen_get_monitor_scale_factor(v.native(), C.gint(m))) -} - // GetResolution is a wrapper around gdk_screen_get_resolution(). func (v *Screen) GetResolution() float64 { return float64(C.gdk_screen_get_resolution(v.native())) @@ -183,11 +111,6 @@ func (v *Screen) SetResolution(r float64) { C.gdk_screen_set_resolution(v.native(), C.gdouble(r)) } -// GetActiveWindow is a wrapper around gdk_screen_get_active_window(). -func (v *Screen) GetActiveWindow() (*Window, error) { - return toWindow(C.gdk_screen_get_active_window(v.native())) -} - // void gdk_screen_set_font_options () // gboolean gdk_screen_get_setting () // const cairo_font_options_t * gdk_screen_get_font_options () diff --git a/vendor/github.com/gotk3/gotk3/glib/glib.go b/vendor/github.com/gotk3/gotk3/glib/glib.go index 0c6da95..02fefa5 100644 --- a/vendor/github.com/gotk3/gotk3/glib/glib.go +++ b/vendor/github.com/gotk3/gotk3/glib/glib.go @@ -336,6 +336,36 @@ func sourceAttach(src *C.struct__GSource, rf reflect.Value, args ...interface{}) * Miscellaneous Utility Functions */ +// GetHomeDir is a wrapper around g_get_home_dir(). +func GetHomeDir() string { + c := C.g_get_home_dir() + return C.GoString((*C.char)(c)) +} + +// GetUserCacheDir is a wrapper around g_get_user_cache_dir(). +func GetUserCacheDir() string { + c := C.g_get_user_cache_dir() + return C.GoString((*C.char)(c)) +} + +// GetUserDataDir is a wrapper around g_get_user_data_dir(). +func GetUserDataDir() string { + c := C.g_get_user_data_dir() + return C.GoString((*C.char)(c)) +} + +// GetUserConfigDir is a wrapper around g_get_user_config_dir(). +func GetUserConfigDir() string { + c := C.g_get_user_config_dir() + return C.GoString((*C.char)(c)) +} + +// GetUserRuntimeDir is a wrapper around g_get_user_runtime_dir(). +func GetUserRuntimeDir() string { + c := C.g_get_user_runtime_dir() + return C.GoString((*C.char)(c)) +} + // GetUserSpecialDir is a wrapper around g_get_user_special_dir(). A // non-nil error is returned in the case that g_get_user_special_dir() // returns NULL to differentiate between NULL and an empty string. diff --git a/vendor/github.com/gotk3/gotk3/gtk/aboutdialog.go b/vendor/github.com/gotk3/gotk3/gtk/aboutdialog.go index d6163c0..1adef86 100644 --- a/vendor/github.com/gotk3/gotk3/gtk/aboutdialog.go +++ b/vendor/github.com/gotk3/gotk3/gtk/aboutdialog.go @@ -111,7 +111,7 @@ func (v *AboutDialog) SetLicenseType(license License) { // GetLogo is a wrapper around gtk_about_dialog_get_logo(). func (v *AboutDialog) GetLogo() (*gdk.Pixbuf, error) { c := C.gtk_about_dialog_get_logo(v.native()) - if c == nil { + if c == nil { return nil, nilPtrErr } diff --git a/vendor/github.com/gotk3/gotk3/gtk/gtk.go b/vendor/github.com/gotk3/gotk3/gtk/gtk.go index c9b6dac..8ffe76f 100644 --- a/vendor/github.com/gotk3/gotk3/gtk/gtk.go +++ b/vendor/github.com/gotk3/gotk3/gtk/gtk.go @@ -223,6 +223,30 @@ func cGSList(clist *glib.SList) *C.GSList { return (*C.GSList)(unsafe.Pointer(clist.Native())) } +func free(str ...interface{}) { + for _, s := range str { + switch x := s.(type) { + case *C.char: + C.free(unsafe.Pointer(x)) + case []*C.char: + for _, cp := range x { + C.free(unsafe.Pointer(cp)) + } + /* + case C.gpointer: + C.g_free(C.gpointer(c)) + */ + default: + fmt.Printf("utils.go free(): Unknown type: %T\n", x) + } + + } +} + +func goString(cstr *C.gchar) string { + return C.GoString((*C.char)(cstr)) +} + // Wrapper function for new objects with reference management. func wrapObject(ptr unsafe.Pointer) *glib.Object { obj := &glib.Object{glib.ToGObject(ptr)} @@ -859,7 +883,7 @@ func Init(args *[]string) { unhandled := make([]string, argc) for i := 0; i < int(argc); i++ { cstr := C.get_string(argv, C.int(i)) - unhandled[i] = C.GoString((*C.char)(cstr)) + unhandled[i] = goString(cstr) C.free(unsafe.Pointer(cstr)) } *args = unhandled @@ -1137,8 +1161,7 @@ func (v *Assistant) SetPageTitle(page IWidget, title string) { // GetPageTitle is a wrapper around gtk_assistant_get_page_title(). func (v *Assistant) GetPageTitle(page IWidget) string { - c := C.gtk_assistant_get_page_title(v.native(), page.toWidget()) - return C.GoString((*C.char)(c)) + return goString(C.gtk_assistant_get_page_title(v.native(), page.toWidget())) } // SetPageComplete is a wrapper around gtk_assistant_set_page_complete(). @@ -1277,7 +1300,7 @@ func (b *Builder) AddFromFile(filename string) error { res := C.gtk_builder_add_from_file(b.native(), (*C.gchar)(cstr), &err) if res == 0 { defer C.g_error_free(err) - return errors.New(C.GoString((*C.char)(err.message))) + return errors.New(goString(err.message)) } return nil } @@ -1290,7 +1313,7 @@ func (b *Builder) AddFromResource(path string) error { res := C.gtk_builder_add_from_resource(b.native(), (*C.gchar)(cstr), &err) if res == 0 { defer C.g_error_free(err) - return errors.New(C.GoString((*C.char)(err.message))) + return errors.New(goString(err.message)) } return nil } @@ -1304,7 +1327,7 @@ func (b *Builder) AddFromString(str string) error { res := C.gtk_builder_add_from_string(b.native(), (*C.gchar)(cstr), length, &err) if res == 0 { defer C.g_error_free(err) - return errors.New(C.GoString((*C.char)(err.message))) + return errors.New(goString(err.message)) } return nil } @@ -1447,7 +1470,7 @@ func (v *Button) GetLabel() (string, error) { if c == nil { return "", nilPtrErr } - return C.GoString((*C.char)(c)), nil + return goString(c), nil } // SetUseUnderline() is a wrapper around gtk_button_set_use_underline(). @@ -1461,17 +1484,6 @@ func (v *Button) GetUseUnderline() bool { return gobool(c) } -// SetFocusOnClick() is a wrapper around gtk_button_set_focus_on_click(). -func (v *Button) SetFocusOnClick(focusOnClick bool) { - C.gtk_button_set_focus_on_click(v.native(), gbool(focusOnClick)) -} - -// GetFocusOnClick() is a wrapper around gtk_button_get_focus_on_click(). -func (v *Button) GetFocusOnClick() bool { - c := C.gtk_button_get_focus_on_click(v.native()) - return gobool(c) -} - // SetImage() is a wrapper around gtk_button_set_image(). func (v *Button) SetImage(image IWidget) { C.gtk_button_set_image(v.native(), image.toWidget()) @@ -1593,6 +1605,23 @@ func wrapBox(obj *glib.Object) *Box { return &Box{Container{Widget{glib.InitiallyUnowned{obj}}}} } +func (v *Box) toOrientable() *C.GtkOrientable { + if v == nil { + return nil + } + return C.toGtkOrientable(unsafe.Pointer(v.GObject)) +} + +// GetOrientation() is a wrapper around C.gtk_orientable_get_orientation() for a GtkBox +func (v *Box) GetOrientation() Orientation { + return Orientation(C.gtk_orientable_get_orientation(v.toOrientable())) +} + +// SetOrientation() is a wrapper around C.gtk_orientable_set_orientation() for a GtkBox +func (v *Box) SetOrientation(o Orientation) { + C.gtk_orientable_set_orientation(v.toOrientable(), C.GtkOrientation(o)) +} + // BoxNew() is a wrapper around gtk_box_new(). func BoxNew(orientation Orientation, spacing int) (*Box, error) { c := C.gtk_box_new(C.GtkOrientation(orientation), C.gint(spacing)) @@ -2300,7 +2329,7 @@ func (v *Clipboard) WaitForText() (string, error) { return "", nilPtrErr } defer C.g_free(C.gpointer(c)) - return C.GoString((*C.char)(c)), nil + return goString(c), nil } // SetText() is a wrapper around gtk_clipboard_set_text(). @@ -2610,7 +2639,7 @@ func (v *CssProvider) LoadFromPath(path string) error { var gerr *C.GError if C.gtk_css_provider_load_from_path(v.native(), (*C.gchar)(cpath), &gerr) == 0 { defer C.g_error_free(gerr) - return errors.New(C.GoString((*C.char)(gerr.message))) + return errors.New(goString(gerr.message)) } return nil } @@ -2622,7 +2651,7 @@ func (v *CssProvider) LoadFromData(data string) error { var gerr *C.GError if C.gtk_css_provider_load_from_data(v.native(), (*C.gchar)(unsafe.Pointer(cdata)), C.gssize(len(data)), &gerr) == 0 { defer C.g_error_free(gerr) - return errors.New(C.GoString((*C.char)(gerr.message))) + return errors.New(goString(gerr.message)) } return nil } @@ -2902,7 +2931,7 @@ func (v *Editable) GetChars(startPos, endPos int) string { c := C.gtk_editable_get_chars(v.native(), C.gint(startPos), C.gint(endPos)) defer C.free(unsafe.Pointer(c)) - return C.GoString((*C.char)(c)) + return goString(c) } // CutClipboard is a wrapper around gtk_editable_cut_clipboard(). @@ -3035,7 +3064,7 @@ func (v *Entry) GetText() (string, error) { if c == nil { return "", nilPtrErr } - return C.GoString((*C.char)(c)), nil + return goString(c), nil } // GetTextLength() is a wrapper around gtk_entry_get_text_length(). @@ -3133,7 +3162,7 @@ func (v *Entry) GetPlaceholderText() (string, error) { if c == nil { return "", nilPtrErr } - return C.GoString((*C.char)(c)), nil + return goString(c), nil } // SetOverwriteMode() is a wrapper around gtk_entry_set_overwrite_mode(). @@ -3314,7 +3343,7 @@ func (v *Entry) GetIconName(iconPos EntryIconPosition) (string, error) { if c == nil { return "", nilPtrErr } - return C.GoString((*C.char)(c)), nil + return goString(c), nil } // TODO(jrick) GIcon @@ -3370,7 +3399,7 @@ func (v *Entry) GetIconTooltipText(iconPos EntryIconPosition) (string, error) { if c == nil { return "", nilPtrErr } - return C.GoString((*C.char)(c)), nil + return goString(c), nil } // SetIconTooltipMarkup() is a wrapper around @@ -3390,7 +3419,7 @@ func (v *Entry) GetIconTooltipMarkup(iconPos EntryIconPosition) (string, error) if c == nil { return "", nilPtrErr } - return C.GoString((*C.char)(c)), nil + return goString(c), nil } // TODO(jrick) GdkDragAction @@ -3483,7 +3512,7 @@ func (v *EntryBuffer) GetText() (string, error) { if c == nil { return "", nilPtrErr } - return C.GoString((*C.char)(c)), nil + return goString(c), nil } // SetText() is a wrapper around gtk_entry_buffer_set_text(). @@ -3702,7 +3731,7 @@ func (v *Expander) SetLabel(label string) { // GetLabel is a wrapper around gtk_expander_get_label(). func (v *Expander) GetLabel() string { c := C.gtk_expander_get_label(v.native()) - return C.GoString((*C.char)(c)) + return goString(c) } // SetLabelWidget is a wrapper around gtk_expander_set_label_widget(). @@ -3741,7 +3770,7 @@ func wrapFileChooser(obj *glib.Object) *FileChooser { // GetFilename is a wrapper around gtk_file_chooser_get_filename(). func (v *FileChooser) GetFilename() string { c := C.gtk_file_chooser_get_filename(v.native()) - s := C.GoString((*C.char)(c)) + s := goString(c) defer C.g_free((C.gpointer)(c)) return s } @@ -3769,7 +3798,7 @@ func (v *FileChooser) GetCurrentFolder() (string, error) { return "", nilPtrErr } defer C.free(unsafe.Pointer(c)) - return C.GoString((*C.char)(c)), nil + return goString(c), nil } // SetPreviewWidget is a wrapper around gtk_file_chooser_set_preview_widget(). @@ -3797,7 +3826,7 @@ func (v *FileChooser) AddFilter(filter *FileFilter) { // GetURI is a wrapper around gtk_file_chooser_get_uri(). func (v *FileChooser) GetURI() string { c := C.gtk_file_chooser_get_uri(v.native()) - s := C.GoString((*C.char)(c)) + s := goString(c) defer C.g_free((C.gpointer)(c)) return s } @@ -4087,7 +4116,7 @@ func FontButtonNewWithFont(fontname string) (*FontButton, error) { // GetFontName is a wrapper around gtk_font_button_get_font_name(). func (v *FontButton) GetFontName() string { c := C.gtk_font_button_get_font_name(v.native()) - return C.GoString((*C.char)(c)) + return goString(c) } // SetFontName is a wrapper around gtk_font_button_set_font_name(). @@ -4167,7 +4196,7 @@ func (v *Frame) SetShadowType(t ShadowType) { // GetLabel is a wrapper around gtk_frame_get_label(). func (v *Frame) GetLabel() string { c := C.gtk_frame_get_label(v.native()) - return C.GoString((*C.char)(c)) + return goString(c) } // GetLabelAlign is a wrapper around gtk_frame_get_label_align(). @@ -4361,7 +4390,7 @@ func (v *IconTheme) LoadIcon(iconName string, size int, flags IconLookupFlags) ( c := C.gtk_icon_theme_load_icon(v.Theme, (*C.gchar)(cstr), C.gint(size), C.GtkIconLookupFlags(flags), &err) if c == nil { defer C.g_error_free(err) - return nil, errors.New(C.GoString((*C.char)(err.message))) + return nil, errors.New(goString(err.message)) } return &gdk.Pixbuf{wrapObject(unsafe.Pointer(c))}, nil } @@ -4634,7 +4663,7 @@ func (v *Image) GetIconName() (string, IconSize) { var iconName *C.gchar var size C.GtkIconSize C.gtk_image_get_icon_name(v.native(), &iconName, &size) - return C.GoString((*C.char)(iconName)), IconSize(size) + return goString(iconName), IconSize(size) } // TODO(jrick) GIcon @@ -4766,7 +4795,7 @@ func LinkButtonNewWithLabel(uri, label string) (*LinkButton, error) { // GetUri is a wrapper around gtk_link_button_get_uri(). func (v *LinkButton) GetUri() string { c := C.gtk_link_button_get_uri(v.native()) - return C.GoString((*C.char)(c)) + return goString(c) } // SetUri is a wrapper around gtk_link_button_set_uri(). @@ -5036,20 +5065,6 @@ func MenuNew() (*Menu, error) { return wrapMenu(wrapObject(unsafe.Pointer(c))), nil } -// PopupAtMouse() is a wrapper for gtk_menu_popup(), without the option for a custom positioning function. -func (v *Menu) PopupAtMouseCursor(parentMenuShell IMenu, parentMenuItem IMenuItem, button int, activateTime uint32) { - wshell := nullableWidget(parentMenuShell) - witem := nullableWidget(parentMenuItem) - - C.gtk_menu_popup(v.native(), - wshell, - witem, - nil, - nil, - C.guint(button), - C.guint32(activateTime)) -} - // Popdown() is a wrapper around gtk_menu_popdown(). func (v *Menu) Popdown() { C.gtk_menu_popdown(v.native()) @@ -5268,7 +5283,7 @@ func (v *MenuItem) SetLabel(label string) { // Gets text on the menu_item label func (v *MenuItem) GetLabel() string { l := C.gtk_menu_item_get_label(v.native()) - return C.GoString((*C.char)(l)) + return goString(l) } /* @@ -5581,7 +5596,7 @@ func (v *Notebook) GetMenuLabelText(child IWidget) (string, error) { if c == nil { return "", errors.New("No menu label for widget") } - return C.GoString((*C.char)(c)), nil + return goString(c), nil } // GetScrollable() is a wrapper around gtk_notebook_get_scrollable(). @@ -5608,7 +5623,7 @@ func (v *Notebook) GetTabLabelText(child IWidget) (string, error) { if c == nil { return "", errors.New("No tab label for widget") } - return C.GoString((*C.char)(c)), nil + return goString(c), nil } // GetTabPos() is a wrapper around gtk_notebook_get_tab_pos(). @@ -5647,7 +5662,7 @@ func (v *Notebook) GetGroupName() (string, error) { if c == nil { return "", errors.New("No group name") } - return C.GoString((*C.char)(c)), nil + return goString(c), nil } // SetActionWidget() is a wrapper around gtk_notebook_set_action_widget(). @@ -5920,6 +5935,8 @@ func (v *Paned) GetPosition() int { // ProgressBar is a representation of GTK's GtkProgressBar. type ProgressBar struct { Widget + // Interfaces + Orientable } // native returns a pointer to the underlying GtkProgressBar. @@ -5938,7 +5955,8 @@ func marshalProgressBar(p uintptr) (interface{}, error) { } func wrapProgressBar(obj *glib.Object) *ProgressBar { - return &ProgressBar{Widget{glib.InitiallyUnowned{obj}}} + o := wrapOrientable(obj) + return &ProgressBar{Widget{glib.InitiallyUnowned{obj}}, *o} } // ProgressBarNew() is a wrapper around gtk_progress_bar_new(). @@ -5979,6 +5997,32 @@ func (v *ProgressBar) SetText(text string) { C.gtk_progress_bar_set_text(v.native(), (*C.gchar)(cstr)) } +// SetPulseStep is a wrapper around gtk_progress_bar_set_pulse_step(). +func (v *ProgressBar) SetPulseStep(fraction float64) { + C.gtk_progress_bar_set_pulse_step(v.native(), C.gdouble(fraction)) +} + +// GetPulseStep is a wrapper around gtk_progress_bar_get_pulse_step(). +func (v *ProgressBar) GetPulseStep() float64 { + c := C.gtk_progress_bar_get_pulse_step(v.native()) + return float64(c) +} + +// Pulse is a wrapper arountd gtk_progress_bar_pulse(). +func (v *ProgressBar) Pulse() { + C.gtk_progress_bar_pulse(v.native()) +} + +// SetInverted is a wrapper around gtk_progress_bar_set_inverted(). +func (v *ProgressBar) SetInverted(inverted bool) { + C.gtk_progress_bar_set_inverted(v.native(), gbool(inverted)) +} + +// GetInverted is a wrapper around gtk_progress_bar_get_inverted(). +func (v *ProgressBar) GetInverted() bool { + c := C.gtk_progress_bar_get_inverted(v.native()) + return gobool(c) +} /* * GtkRadioButton */ @@ -6304,8 +6348,7 @@ func (v *RecentChooser) toRecentChooser() *C.GtkRecentChooser { func (v *RecentChooser) GetCurrentUri() string { curi := C.gtk_recent_chooser_get_current_uri(v.native()) - uri := C.GoString((*C.char)(curi)) - return uri + return goString(curi) } func (v *RecentChooser) AddFilter(filter *RecentFilter) { @@ -6969,15 +7012,6 @@ func (v *SizeGroup) GetMode() SizeGroupMode { return SizeGroupMode(C.gtk_size_group_get_mode(v.native())) } -func (v *SizeGroup) SetIgnoreHidden(ignoreHidden bool) { - C.gtk_size_group_set_ignore_hidden(v.native(), gbool(ignoreHidden)) -} - -func (v *SizeGroup) GetIgnoreHidden() bool { - c := C.gtk_size_group_get_ignore_hidden(v.native()) - return gobool(c) -} - func (v *SizeGroup) AddWidget(widget IWidget) { C.gtk_size_group_add_widget(v.native(), widget.toWidget()) } @@ -7513,7 +7547,7 @@ func (v *TextBuffer) GetText(start, end *TextIter, includeHiddenChars bool) (str if c == nil { return "", nilPtrErr } - gostr := C.GoString((*C.char)(c)) + gostr := goString(c) C.g_free(C.gpointer(c)) return gostr, nil } @@ -7813,7 +7847,7 @@ func (v *ToolButton) SetLabel(label string) { // GetLabel is a wrapper aroud gtk_tool_button_get_label(). func (v *ToolButton) GetLabel() string { c := C.gtk_tool_button_get_label(v.native()) - return C.GoString((*C.char)(c)) + return goString(c) } // SetUseUnderline is a wrapper around gtk_tool_button_set_use_underline(). @@ -7837,7 +7871,7 @@ func (v *ToolButton) SetIconName(iconName string) { // GetIconName is a wrapper around gtk_tool_button_get_icon_name(). func (v *ToolButton) GetIconName() string { c := C.gtk_tool_button_get_icon_name(v.native()) - return C.GoString((*C.char)(c)) + return goString(c) } // SetIconWidget is a wrapper around gtk_tool_button_set_icon_widget(). @@ -8371,7 +8405,7 @@ func (v *TreePath) GetIndices() []int { // String is a wrapper around gtk_tree_path_to_string(). func (v *TreePath) String() string { c := C.gtk_tree_path_to_string(v.native()) - return C.GoString((*C.char)(c)) + return goString(c) } // TreePathNewFromString is a wrapper around gtk_tree_path_new_from_string(). @@ -8808,7 +8842,7 @@ var WrapMap = map[string]WrapFn{ //TODO change all wrapFns to return an IObject func cast(c *C.GObject) (glib.IObject, error) { var ( - className = C.GoString((*C.char)(C.object_get_class_name(c))) + className = goString(C.object_get_class_name(c)) obj = wrapObject(unsafe.Pointer(c)) ) diff --git a/vendor/github.com/gotk3/gotk3/gtk/gtk.go.h b/vendor/github.com/gotk3/gotk3/gtk/gtk.go.h index d8fcd95..2047716 100644 --- a/vendor/github.com/gotk3/gotk3/gtk/gtk.go.h +++ b/vendor/github.com/gotk3/gotk3/gtk/gtk.go.h @@ -16,8 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef __GTK_GO_H__ -#define __GTK_GO_H__ +#pragma once #include #include @@ -125,12 +124,42 @@ toGtkOverlay(void *p) return (GTK_OVERLAY(p)); } +static GtkPageSetup * +toGtkPageSetup(void *p) +{ + return (GTK_PAGE_SETUP(p)); +} + static GtkPaned * toGtkPaned(void *p) { return (GTK_PANED(p)); } +static GtkPrintContext * +toGtkPrintContext(void *p) +{ + return (GTK_PRINT_CONTEXT(p)); +} + +static GtkPrintOperation * +toGtkPrintOperation(void *p) +{ + return (GTK_PRINT_OPERATION(p)); +} + +static GtkPrintOperationPreview * +toGtkPrintOperationPreview(void *p) +{ + return (GTK_PRINT_OPERATION_PREVIEW(p)); +} + +static GtkPrintSettings * +toGtkPrintSettings(void *p) +{ + return (GTK_PRINT_SETTINGS(p)); +} + static GtkProgressBar * toGtkProgressBar(void *p) { @@ -822,4 +851,19 @@ static inline void _gtk_builder_connect_signals_full(GtkBuilder *builder) { gtk_builder_connect_signals_full(builder, (GtkBuilderConnectFunc)(goBuilderConnect), NULL); } -#endif +extern void goPrintSettings (gchar *key, + gchar *value, + gpointer user_data); + +static inline void _gtk_print_settings_foreach(GtkPrintSettings *ps, gpointer user_data) { + gtk_print_settings_foreach(ps, (GtkPrintSettingsFunc)(goPrintSettings), user_data); +} + +extern void goPageSetupDone (GtkPageSetup *setup, + gpointer data); + +static inline void _gtk_print_run_page_setup_dialog_async(GtkWindow *parent, GtkPageSetup *setup, + GtkPrintSettings *settings, gpointer data) { + gtk_print_run_page_setup_dialog_async(parent, setup, settings, + (GtkPageSetupDoneFunc)(goPageSetupDone), data); +} \ No newline at end of file diff --git a/vendor/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_20.go b/vendor/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_20.go new file mode 100644 index 0000000..4496548 --- /dev/null +++ b/vendor/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_20.go @@ -0,0 +1,35 @@ +//+build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14 gtk_3_16 gtk_3_18 + +package gtk + +// #cgo pkg-config: gtk+-3.0 +// #include +// #include +import "C" + +// GetFocusOnClick() is a wrapper around gtk_button_get_focus_on_click(). +func (v *Button) GetFocusOnClick() bool { + c := C.gtk_button_get_focus_on_click(v.native()) + return gobool(c) +} + +// BeginsTag is a wrapper around gtk_text_iter_begins_tag(). +func (v *TextIter) BeginsTag(v1 *TextTag) bool { + return gobool(C.gtk_text_iter_begins_tag(v.native(), v1.native())) +} + +// ResizeToGeometry is a wrapper around gtk_window_resize_to_geometry(). +func (v *Window) ResizeToGeometry(width, height int) { + C.gtk_window_resize_to_geometry(v.native(), C.gint(width), C.gint(height)) +} + +// SetDefaultGeometry is a wrapper around gtk_window_set_default_geometry(). +func (v *Window) SetDefaultGeometry(width, height int) { + C.gtk_window_set_default_geometry(v.native(), C.gint(width), + C.gint(height)) +} + +// SetFocusOnClick() is a wrapper around gtk_button_set_focus_on_click(). +func (v *Button) SetFocusOnClick(focusOnClick bool) { + C.gtk_button_set_focus_on_click(v.native(), gbool(focusOnClick)) +} diff --git a/vendor/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_22.go b/vendor/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_22.go new file mode 100644 index 0000000..601e884 --- /dev/null +++ b/vendor/github.com/gotk3/gotk3/gtk/gtk_deprecated_since_3_22.go @@ -0,0 +1,44 @@ +//+build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14 gtk_3_16 gtk_3_18 gtk_3_20 + +package gtk + +// #cgo pkg-config: gtk+-3.0 +// #include +// #include +import "C" + +import ( + "unsafe" +) + +// PopupAtMouse() is a wrapper for gtk_menu_popup(), without the option for a custom positioning function. +func (v *Menu) PopupAtMouseCursor(parentMenuShell IMenu, parentMenuItem IMenuItem, button int, activateTime uint32) { + wshell := nullableWidget(parentMenuShell) + witem := nullableWidget(parentMenuItem) + + C.gtk_menu_popup(v.native(), + wshell, + witem, + nil, + nil, + C.guint(button), + C.guint32(activateTime)) +} + +func (v *SizeGroup) GetIgnoreHidden() bool { + c := C.gtk_size_group_get_ignore_hidden(v.native()) + return gobool(c) +} + +// SetWMClass is a wrapper around gtk_window_set_wmclass(). +func (v *Window) SetWMClass(name, class string) { + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) + cClass := C.CString(class) + defer C.free(unsafe.Pointer(cClass)) + C.gtk_window_set_wmclass(v.native(), (*C.gchar)(cName), (*C.gchar)(cClass)) +} + +func (v *SizeGroup) SetIgnoreHidden(ignoreHidden bool) { + C.gtk_size_group_set_ignore_hidden(v.native(), gbool(ignoreHidden)) +} diff --git a/vendor/github.com/gotk3/gotk3/gtk/gtk_export.go b/vendor/github.com/gotk3/gotk3/gtk/gtk_export.go index cf3e3c4..7a870c0 100644 --- a/vendor/github.com/gotk3/gotk3/gtk/gtk_export.go +++ b/vendor/github.com/gotk3/gotk3/gtk/gtk_export.go @@ -42,3 +42,36 @@ func goBuilderConnect(builder *C.GtkBuilder, gobj := glib.Object{glib.ToGObject(unsafe.Pointer(object))} gobj.Connect(s, handler) } + +//export goPageSetupDone +func goPageSetupDone(setup *C.GtkPageSetup, + data C.gpointer) { + + id := int(uintptr(data)) + + pageSetupDoneCallbackRegistry.Lock() + r := pageSetupDoneCallbackRegistry.m[id] + delete(pageSetupDoneCallbackRegistry.m, id) + pageSetupDoneCallbackRegistry.Unlock() + + obj := wrapObject(unsafe.Pointer(setup)) + r.fn(wrapPageSetup(obj), r.data) + +} + +//export goPrintSettings +func goPrintSettings(key *C.gchar, + value *C.gchar, + userData C.gpointer) { + + id := int(uintptr(userData)) + + printSettingsCallbackRegistry.Lock() + r := printSettingsCallbackRegistry.m[id] + // TODO: figure out a way to determine when we can clean up + //delete(printSettingsCallbackRegistry.m, id) + printSettingsCallbackRegistry.Unlock() + + r.fn(C.GoString((*C.char)(key)), C.GoString((*C.char)(value)), r.userData) + +} diff --git a/vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_12.go b/vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_12.go index 8c279ff..c5c7667 100644 --- a/vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_12.go +++ b/vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_12.go @@ -5,9 +5,26 @@ package gtk // #cgo pkg-config: gtk+-3.0 // #include +// #include "gtk_since_3_12.go.h" import "C" -import "unsafe" +import ( + "unsafe" + + "github.com/gotk3/gotk3/glib" +) + +func init() { + tm := []glib.TypeMarshaler{ + // Objects/Interfaces + {glib.Type(C.gtk_flow_box_get_type()), marshalFlowBox}, + {glib.Type(C.gtk_flow_box_child_get_type()), marshalFlowBoxChild}, + } + glib.RegisterGValueMarshalers(tm) + + WrapMap["GtkFlowBox"] = wrapFlowBox + WrapMap["GtkFlowBoxChild"] = wrapFlowBoxChild +} // SetPopover is a wrapper around gtk_menu_button_set_popover(). func (v *MenuButton) SetPopover(popover *Popover) { @@ -22,3 +39,236 @@ func (v *MenuButton) GetPopover() *Popover { } return wrapPopover(wrapObject(unsafe.Pointer(c))) } + +/* + * FlowBox + */ +type FlowBox struct { + Container +} + +func (fb *FlowBox) native() *C.GtkFlowBox { + if fb == nil || fb.GObject == nil { + return nil + } + p := unsafe.Pointer(fb.GObject) + return C.toGtkFlowBox(p) +} + +func marshalFlowBox(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapFlowBox(obj), nil +} + +func wrapFlowBox(obj *glib.Object) *FlowBox { + return &FlowBox{Container{Widget{glib.InitiallyUnowned{obj}}}} +} + +// FlowBoxNew is a wrapper around gtk_flow_box_new() +func FlowBoxNew() (*FlowBox, error) { + c := C.gtk_flow_box_new() + if c == nil { + return nil, nilPtrErr + } + return wrapFlowBox(wrapObject(unsafe.Pointer(c))), nil +} + +// Insert is a wrapper around gtk_flow_box_insert() +func (fb *FlowBox) Insert(widget IWidget, position int) { + C.gtk_flow_box_insert(fb.native(), widget.toWidget(), C.gint(position)) +} + +// GetChildAtIndex is a wrapper around gtk_flow_box_get_child_at_index() +func (fb *FlowBox) GetChildAtIndex(idx int) *FlowBoxChild { + c := C.gtk_flow_box_get_child_at_index(fb.native(), C.gint(idx)) + if c == nil { + return nil + } + return wrapFlowBoxChild(wrapObject(unsafe.Pointer(c))) +} + +// TODO 3.22.6 gtk_flow_box_get_child_at_pos() + +// SetHAdjustment is a wrapper around gtk_flow_box_set_hadjustment() +func (fb *FlowBox) SetHAdjustment(adjustment *Adjustment) { + C.gtk_flow_box_set_hadjustment(fb.native(), adjustment.native()) +} + +// SetVAdjustment is a wrapper around gtk_flow_box_set_vadjustment() +func (fb *FlowBox) SetVAdjustment(adjustment *Adjustment) { + C.gtk_flow_box_set_vadjustment(fb.native(), adjustment.native()) +} + +// SetHomogeneous is a wrapper around gtk_flow_box_set_homogeneous() +func (fb *FlowBox) SetHomogeneous(homogeneous bool) { + C.gtk_flow_box_set_homogeneous(fb.native(), gbool(homogeneous)) +} + +// GetHomogeneous is a wrapper around gtk_flow_box_get_homogeneous() +func (fb *FlowBox) GetHomogeneous() bool { + c := C.gtk_flow_box_get_homogeneous(fb.native()) + return gobool(c) +} + +// SetRowSpacing is a wrapper around gtk_flow_box_set_row_spacing() +func (fb *FlowBox) SetRowSpacing(spacing uint) { + C.gtk_flow_box_set_row_spacing(fb.native(), C.guint(spacing)) +} + +// GetRowSpacing is a wrapper around gtk_flow_box_get_row_spacing() +func (fb *FlowBox) GetRowSpacing() uint { + c := C.gtk_flow_box_get_row_spacing(fb.native()) + return uint(c) +} + +// SetColumnSpacing is a wrapper around gtk_flow_box_set_column_spacing() +func (fb *FlowBox) SetColumnSpacing(spacing uint) { + C.gtk_flow_box_set_column_spacing(fb.native(), C.guint(spacing)) +} + +// GetColumnSpacing is a wrapper around gtk_flow_box_get_column_spacing() +func (fb *FlowBox) GetColumnSpacing() uint { + c := C.gtk_flow_box_get_column_spacing(fb.native()) + return uint(c) +} + +// SetMinChildrenPerLine is a wrapper around gtk_flow_box_set_min_children_per_line() +func (fb *FlowBox) SetMinChildrenPerLine(n_children uint) { + C.gtk_flow_box_set_min_children_per_line(fb.native(), C.guint(n_children)) +} + +// GetMinChildrenPerLine is a wrapper around gtk_flow_box_get_min_children_per_line() +func (fb *FlowBox) GetMinChildrenPerLine() uint { + c := C.gtk_flow_box_get_min_children_per_line(fb.native()) + return uint(c) +} + +// SetMaxChildrenPerLine is a wrapper around gtk_flow_box_set_max_children_per_line() +func (fb *FlowBox) SetMaxChildrenPerLine(n_children uint) { + C.gtk_flow_box_set_max_children_per_line(fb.native(), C.guint(n_children)) +} + +// GetMaxChildrenPerLine is a wrapper around gtk_flow_box_get_max_children_per_line() +func (fb *FlowBox) GetMaxChildrenPerLine() uint { + c := C.gtk_flow_box_get_max_children_per_line(fb.native()) + return uint(c) +} + +// SetActivateOnSingleClick is a wrapper around gtk_flow_box_set_activate_on_single_click() +func (fb *FlowBox) SetActivateOnSingleClick(single bool) { + C.gtk_flow_box_set_activate_on_single_click(fb.native(), gbool(single)) +} + +// GetActivateOnSingleClick gtk_flow_box_get_activate_on_single_click() +func (fb *FlowBox) GetActivateOnSingleClick() bool { + c := C.gtk_flow_box_get_activate_on_single_click(fb.native()) + return gobool(c) +} + +// TODO: gtk_flow_box_selected_foreach() + +// GetSelectedChildren is a wrapper around gtk_flow_box_get_selected_children() +func (fb *FlowBox) GetSelectedChildren() (rv []*FlowBoxChild) { + c := C.gtk_flow_box_get_selected_children(fb.native()) + if c == nil { + return + } + list := glib.WrapList(uintptr(unsafe.Pointer(c))) + for l := list; l != nil; l = l.Next() { + o := wrapFlowBoxChild(wrapObject(l.Data().(unsafe.Pointer))) + rv = append(rv, o) + } + // We got a transfer container, so we must free the list. + list.Free() + + return +} + +// SelectChild is a wrapper around gtk_flow_box_select_child() +func (fb *FlowBox) SelectChild(child *FlowBoxChild) { + C.gtk_flow_box_select_child(fb.native(), child.native()) +} + +// UnselectChild is a wrapper around gtk_flow_box_unselect_child() +func (fb *FlowBox) UnselectChild(child *FlowBoxChild) { + C.gtk_flow_box_unselect_child(fb.native(), child.native()) +} + +// SelectAll is a wrapper around gtk_flow_box_select_all() +func (fb *FlowBox) SelectAll() { + C.gtk_flow_box_select_all(fb.native()) +} + +// UnselectAll is a wrapper around gtk_flow_box_unselect_all() +func (fb *FlowBox) UnselectAll() { + C.gtk_flow_box_unselect_all(fb.native()) +} + +// SetSelectionMode is a wrapper around gtk_flow_box_set_selection_mode() +func (fb *FlowBox) SetSelectionMode(mode SelectionMode) { + C.gtk_flow_box_set_selection_mode(fb.native(), C.GtkSelectionMode(mode)) +} + +// GetSelectionMode is a wrapper around gtk_flow_box_get_selection_mode() +func (fb *FlowBox) GetSelectionMode() SelectionMode { + c := C.gtk_flow_box_get_selection_mode(fb.native()) + return SelectionMode(c) +} + +// TODO gtk_flow_box_set_filter_func() +// TODO gtk_flow_box_invalidate_filter() +// TODO gtk_flow_box_set_sort_func() +// TODO gtk_flow_box_invalidate_sort() +// TODO 3.18 gtk_flow_box_bind_model() + +/* + * FlowBoxChild + */ +type FlowBoxChild struct { + Bin +} + +func (fbc *FlowBoxChild) native() *C.GtkFlowBoxChild { + if fbc == nil || fbc.GObject == nil { + return nil + } + p := unsafe.Pointer(fbc.GObject) + return C.toGtkFlowBoxChild(p) +} + +func marshalFlowBoxChild(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapFlowBoxChild(obj), nil +} + +func wrapFlowBoxChild(obj *glib.Object) *FlowBoxChild { + return &FlowBoxChild{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// FlowBoxChildNew is a wrapper around gtk_flow_box_child_new() +func FlowBoxChildNew() (*FlowBoxChild, error) { + c := C.gtk_flow_box_child_new() + if c == nil { + return nil, nilPtrErr + } + return wrapFlowBoxChild(wrapObject(unsafe.Pointer(c))), nil +} + +// GetIndex is a wrapper around gtk_flow_box_child_get_index() +func (fbc *FlowBoxChild) GetIndex() int { + c := C.gtk_flow_box_child_get_index(fbc.native()) + return int(c) +} + +// IsSelected is a wrapper around gtk_flow_box_child_is_selected() +func (fbc *FlowBoxChild) IsSelected() bool { + c := C.gtk_flow_box_child_is_selected(fbc.native()) + return gobool(c) +} + +// Changed is a wrapper around gtk_flow_box_child_changed() +func (fbc *FlowBoxChild) Changed() { + C.gtk_flow_box_child_changed(fbc.native()) +} diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/actionbar_since_3_12.go.h b/vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_12.go.h similarity index 84% rename from vendor/github.com/gotk3/gotk3.old/gtk/actionbar_since_3_12.go.h rename to vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_12.go.h index d58e36a..92992fe 100644 --- a/vendor/github.com/gotk3/gotk3.old/gtk/actionbar_since_3_12.go.h +++ b/vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_12.go.h @@ -1,25 +1,29 @@ -// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12 - -/* - * Copyright (c) 2013-2014 Conformal Systems - * - * This file originated from: http://opensource.conformal.com/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -static GtkActionBar * -toGtkActionBar(void *p) -{ - return (GTK_ACTION_BAR(p)); -} +/* + * Copyright (c) 2013-2014 Conformal Systems + * + * This file originated from: http://opensource.conformal.com/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +static GtkFlowBox * +toGtkFlowBox(void *p) +{ + return (GTK_FLOW_BOX(p)); +} + +static GtkFlowBoxChild * +toGtkFlowBoxChild(void *p) +{ + return (GTK_FLOW_BOX_CHILD(p)); +} \ No newline at end of file diff --git a/vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_16.go b/vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_16.go index 87e4c52..4d92369 100644 --- a/vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_16.go +++ b/vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_16.go @@ -6,24 +6,116 @@ package gtk // #cgo pkg-config: gtk+-3.0 // #include +// #include "gtk_since_3_16.go.h" import "C" +import ( + "unsafe" + "github.com/gotk3/gotk3/glib" +) + +func init() { + tm := []glib.TypeMarshaler{ + + // Objects/Interfaces + {glib.Type(C.gtk_stack_sidebar_get_type()), marshalStackSidebar}, + } + glib.RegisterGValueMarshalers(tm) + + //Contribute to casting + for k, v := range map[string]WrapFn{ + "GtkStackSidebar": wrapStackSidebar, + } { + WrapMap[k] = v + } +} // SetOverlayScrolling is a wrapper around gtk_scrolled_window_set_overlay_scrolling(). func (v *ScrolledWindow) SetOverlayScrolling(scrolling bool) { - C.gtk_scrolled_window_set_overlay_scrolling(v.native(), gbool(scrolling)) + C.gtk_scrolled_window_set_overlay_scrolling(v.native(), gbool(scrolling)) } // GetOverlayScrolling is a wrapper around gtk_scrolled_window_get_overlay_scrolling(). func (v *ScrolledWindow) GetOverlayScrolling() bool { - return gobool(C.gtk_scrolled_window_get_overlay_scrolling(v.native())) + return gobool(C.gtk_scrolled_window_get_overlay_scrolling(v.native())) } // SetWideHandle is a wrapper around gtk_paned_set_wide_handle(). func (v *Paned) SetWideHandle(wide bool) { - C.gtk_paned_set_wide_handle(v.native(), gbool(wide)) + C.gtk_paned_set_wide_handle(v.native(), gbool(wide)) } // GetWideHandle is a wrapper around gtk_paned_get_wide_handle(). func (v *Paned) GetWideHandle() bool { - return gobool(C.gtk_paned_get_wide_handle(v.native())) + return gobool(C.gtk_paned_get_wide_handle(v.native())) +} + +// GetXAlign is a wrapper around gtk_label_get_xalign(). +func (v *Label) GetXAlign() float64 { + c := C.gtk_label_get_xalign(v.native()) + return float64(c) +} + +// GetYAlign is a wrapper around gtk_label_get_yalign(). +func (v *Label) GetYAlign() float64 { + c := C.gtk_label_get_yalign(v.native()) + return float64(c) +} + +// SetXAlign is a wrapper around gtk_label_set_xalign(). +func (v *Label) SetXAlign(n float64) { + C.gtk_label_set_xalign(v.native(), C.gfloat(n)) +} + +// SetYAlign is a wrapper around gtk_label_set_yalign(). +func (v *Label) SetYAlign(n float64) { + C.gtk_label_set_yalign(v.native(), C.gfloat(n)) +} + +/* + * GtkStackSidebar + */ + +// StackSidebar is a representation of GTK's GtkStackSidebar. +type StackSidebar struct { + Bin +} + +// native returns a pointer to the underlying GtkStack. +func (v *StackSidebar) native() *C.GtkStackSidebar { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkStackSidebar(p) +} + +func marshalStackSidebar(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapStackSidebar(obj), nil +} + +func wrapStackSidebar(obj *glib.Object) *StackSidebar { + return &StackSidebar{Bin{Container{Widget{glib.InitiallyUnowned{obj}}}}} +} + +// StackSidebarNew is a wrapper around gtk_stack_sidebar_new(). +func StackSidebarNew() (*StackSidebar, error) { + c := C.gtk_stack_sidebar_new() + if c == nil { + return nil, nilPtrErr + } + return wrapStackSidebar(wrapObject(unsafe.Pointer(c))), nil +} + +func (v *StackSidebar) SetStack(stack *Stack) { + C.gtk_stack_sidebar_set_stack(v.native(), stack.native()) +} + +func (v *StackSidebar) GetStack() *Stack { + c := C.gtk_stack_sidebar_get_stack(v.native()) + if c == nil { + return nil + } + return wrapStack(wrapObject(unsafe.Pointer(c))) } diff --git a/vendor/github.com/gotk3/gotk3.old/gtk/popover_since_3_12.go.h b/vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_16.go.h similarity index 85% rename from vendor/github.com/gotk3/gotk3.old/gtk/popover_since_3_12.go.h rename to vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_16.go.h index 3cc5564..c2e0222 100644 --- a/vendor/github.com/gotk3/gotk3.old/gtk/popover_since_3_12.go.h +++ b/vendor/github.com/gotk3/gotk3/gtk/gtk_since_3_16.go.h @@ -1,25 +1,23 @@ -// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12 - -/* - * Copyright (c) 2013-2014 Conformal Systems - * - * This file originated from: http://opensource.conformal.com/ - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -static GtkPopover * -toGtkPopover(void *p) -{ - return (GTK_POPOVER(p)); -} \ No newline at end of file +/* + * Copyright (c) 2013-2014 Conformal Systems + * + * This file originated from: http://opensource.conformal.com/ + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +static GtkStackSidebar * +toGtkStackSidebar(void *p) +{ + return (GTK_STACK_SIDEBAR(p)); +} diff --git a/vendor/github.com/gotk3/gotk3/gtk/label.go b/vendor/github.com/gotk3/gotk3/gtk/label.go index c89a7a7..1b0effa 100644 --- a/vendor/github.com/gotk3/gotk3/gtk/label.go +++ b/vendor/github.com/gotk3/gotk3/gtk/label.go @@ -264,3 +264,8 @@ func (v *Label) GetLabel() string { } return C.GoString((*C.char)(c)) } + +// GetMnemonicKeyval is a wrapper around gtk_label_get_mnemonic_keyval(). +func (v *Label) GetMnemonicKeyval() uint { + return uint(C.gtk_label_get_mnemonic_keyval(v.native())) +} diff --git a/vendor/github.com/gotk3/gotk3/gtk/print.go b/vendor/github.com/gotk3/gotk3/gtk/print.go new file mode 100644 index 0000000..90d2dca --- /dev/null +++ b/vendor/github.com/gotk3/gotk3/gtk/print.go @@ -0,0 +1,1632 @@ +package gtk + +// #include +// #include "gtk.go.h" +import "C" +import ( + "errors" + "runtime" + "sync" + "unsafe" + + "github.com/gotk3/gotk3/cairo" + "github.com/gotk3/gotk3/glib" + "github.com/gotk3/gotk3/pango" +) + +func init() { + tm := []glib.TypeMarshaler{ + // Enums + {glib.Type(C.gtk_page_orientation_get_type()), marshalPageOrientation}, + {glib.Type(C.gtk_print_error_get_type()), marshalPrintError}, + {glib.Type(C.gtk_print_operation_action_get_type()), marshalPrintOperationAction}, + {glib.Type(C.gtk_print_operation_result_get_type()), marshalPrintOperationResult}, + {glib.Type(C.gtk_print_status_get_type()), marshalPrintStatus}, + {glib.Type(C.gtk_unit_get_type()), marshalUnit}, + + // Objects/Interfaces + {glib.Type(C.gtk_number_up_layout_get_type()), marshalNumberUpLayout}, + {glib.Type(C.gtk_page_orientation_get_type()), marshalPageOrientation}, + {glib.Type(C.gtk_page_set_get_type()), marshalPageSet}, + {glib.Type(C.gtk_page_setup_get_type()), marshalPageSetup}, + {glib.Type(C.gtk_print_context_get_type()), marshalPrintContext}, + {glib.Type(C.gtk_print_duplex_get_type()), marshalPrintDuplex}, + {glib.Type(C.gtk_print_operation_get_type()), marshalPrintOperation}, + {glib.Type(C.gtk_print_operation_preview_get_type()), marshalPrintOperationPreview}, + {glib.Type(C.gtk_print_pages_get_type()), marshalPrintPages}, + {glib.Type(C.gtk_print_quality_get_type()), marshalPrintQuality}, + {glib.Type(C.gtk_print_settings_get_type()), marshalPrintSettings}, + + // Boxed + {glib.Type(C.gtk_paper_size_get_type()), marshalPaperSize}, + } + + glib.RegisterGValueMarshalers(tm) + + WrapMap["GtkPageSetup"] = wrapPageSetup + WrapMap["GtkPrintContext"] = wrapPrintContext + WrapMap["GtkPrintOperation"] = wrapPrintOperation + WrapMap["GtkPrintOperationPreview"] = wrapPrintOperationPreview + WrapMap["GtkPrintSettings"] = wrapPrintSettings +} + +/* + * Constants + */ + +// NumberUpLayout is a representation of GTK's GtkNumberUpLayout. +type NumberUpLayout int + +const ( + NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM NumberUpLayout = C.GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM + NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP NumberUpLayout = C.GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP + NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM NumberUpLayout = C.GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM + NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP NumberUpLayout = C.GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP + NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_LEFT_TO_RIGHT NumberUpLayout = C.GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_LEFT_TO_RIGHT + NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_RIGHT_TO_LEFT NumberUpLayout = C.GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_RIGHT_TO_LEFT + NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_LEFT_TO_RIGHT NumberUpLayout = C.GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_LEFT_TO_RIGHT + NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_RIGHT_TO_LEFT NumberUpLayout = C.GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_RIGHT_TO_LEFT +) + +func marshalNumberUpLayout(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return NumberUpLayout(c), nil +} + +// PageOrientation is a representation of GTK's GtkPageOrientation. +type PageOrientation int + +const ( + PAGE_ORIENTATION_PORTRAIT PageOrientation = C.GTK_PAGE_ORIENTATION_PORTRAIT + PAGE_ORIENTATION_LANDSCAPE PageOrientation = C.GTK_PAGE_ORIENTATION_LANDSCAPE + PAGE_ORIENTATION_REVERSE_PORTRAIT PageOrientation = C.GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT + PAGE_ORIENTATION_REVERSE_LANDSCAPE PageOrientation = C.GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE +) + +func marshalPageOrientation(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PageOrientation(c), nil +} + +// PrintDuplex is a representation of GTK's GtkPrintDuplex. +type PrintDuplex int + +const ( + PRINT_DUPLEX_SIMPLEX PrintDuplex = C.GTK_PRINT_DUPLEX_SIMPLEX + PRINT_DUPLEX_HORIZONTAL PrintDuplex = C.GTK_PRINT_DUPLEX_HORIZONTAL + PRINT_DUPLEX_VERTICAL PrintDuplex = C.GTK_PRINT_DUPLEX_VERTICAL +) + +func marshalPrintDuplex(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PrintDuplex(c), nil +} + +// PrintPages is a representation of GTK's GtkPrintPages. +type PrintPages int + +const ( + PRINT_PAGES_ALL PrintPages = C.GTK_PRINT_PAGES_ALL + PRINT_PAGES_CURRENT PrintPages = C.GTK_PRINT_PAGES_CURRENT + PRINT_PAGES_RANGES PrintPages = C.GTK_PRINT_PAGES_RANGES + PRINT_PAGES_SELECTION PrintPages = C.GTK_PRINT_PAGES_SELECTION +) + +func marshalPrintPages(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PrintPages(c), nil +} + +// PageSet is a representation of GTK's GtkPageSet. +type PageSet int + +const ( + PAGE_SET_ALL PageSet = C.GTK_PAGE_SET_ALL + PAGE_SET_EVEN PageSet = C.GTK_PAGE_SET_EVEN + PAGE_SET_ODD PageSet = C.GTK_PAGE_SET_ODD +) + +func marshalPageSet(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PageSet(c), nil +} + +// PrintOperationAction is a representation of GTK's GtkPrintError. +type PrintError int + +const ( + PRINT_ERROR_GENERAL PrintError = C.GTK_PRINT_ERROR_GENERAL + PRINT_ERROR_INTERNAL_ERROR PrintError = C.GTK_PRINT_ERROR_INTERNAL_ERROR + PRINT_ERROR_NOMEM PrintError = C.GTK_PRINT_ERROR_NOMEM + PRINT_ERROR_INVALID_FILE PrintError = C.GTK_PRINT_ERROR_INVALID_FILE +) + +func marshalPrintError(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PrintError(c), nil +} + +// PrintOperationAction is a representation of GTK's GtkPrintOperationAction. +type PrintOperationAction int + +const ( + PRINT_OPERATION_ACTION_PRINT_DIALOG PrintOperationAction = C.GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG + PRINT_OPERATION_ACTION_PRINT PrintOperationAction = C.GTK_PRINT_OPERATION_ACTION_PRINT + PRINT_OPERATION_ACTION_PREVIEW PrintOperationAction = C.GTK_PRINT_OPERATION_ACTION_PREVIEW + PRINT_OPERATION_ACTION_EXPORT PrintOperationAction = C.GTK_PRINT_OPERATION_ACTION_EXPORT +) + +func marshalPrintOperationAction(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PrintOperationAction(c), nil +} + +// PrintOperationResult is a representation of GTK's GtkPrintOperationResult. +type PrintOperationResult int + +const ( + PRINT_OPERATION_RESULT_ERROR PrintOperationResult = C.GTK_PRINT_OPERATION_RESULT_ERROR + PRINT_OPERATION_RESULT_APPLY PrintOperationResult = C.GTK_PRINT_OPERATION_RESULT_APPLY + PRINT_OPERATION_RESULT_CANCEL PrintOperationResult = C.GTK_PRINT_OPERATION_RESULT_CANCEL + PRINT_OPERATION_RESULT_IN_PROGRESS PrintOperationResult = C.GTK_PRINT_OPERATION_RESULT_IN_PROGRESS +) + +func marshalPrintOperationResult(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PrintOperationResult(c), nil +} + +// PrintStatus is a representation of GTK's GtkPrintStatus. +type PrintStatus int + +const ( + PRINT_STATUS_INITIAL PrintStatus = C.GTK_PRINT_STATUS_INITIAL + PRINT_STATUS_PREPARING PrintStatus = C.GTK_PRINT_STATUS_PREPARING + PRINT_STATUS_GENERATING_DATA PrintStatus = C.GTK_PRINT_STATUS_GENERATING_DATA + PRINT_STATUS_SENDING_DATA PrintStatus = C.GTK_PRINT_STATUS_SENDING_DATA + PRINT_STATUS_PENDING PrintStatus = C.GTK_PRINT_STATUS_PENDING + PRINT_STATUS_PENDING_ISSUE PrintStatus = C.GTK_PRINT_STATUS_PENDING_ISSUE + PRINT_STATUS_PRINTING PrintStatus = C.GTK_PRINT_STATUS_PRINTING + PRINT_STATUS_FINISHED PrintStatus = C.GTK_PRINT_STATUS_FINISHED + PRINT_STATUS_FINISHED_ABORTED PrintStatus = C.GTK_PRINT_STATUS_FINISHED_ABORTED +) + +func marshalPrintStatus(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PrintStatus(c), nil +} + +// PrintQuality is a representation of GTK's GtkPrintQuality. +type PrintQuality int + +const ( + PRINT_QUALITY_LOW PrintQuality = C.GTK_PRINT_QUALITY_LOW + PRINT_QUALITY_NORMAL PrintQuality = C.GTK_PRINT_QUALITY_NORMAL + PRINT_QUALITY_HIGH PrintQuality = C.GTK_PRINT_QUALITY_HIGH + PRINT_QUALITY_DRAFT PrintQuality = C.GTK_PRINT_QUALITY_DRAFT +) + +func marshalPrintQuality(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return PrintQuality(c), nil +} + +// Unit is a representation of GTK's GtkUnit. +type Unit int + +const ( + GTK_UNIT_NONE Unit = C.GTK_UNIT_NONE + GTK_UNIT_POINTS Unit = C.GTK_UNIT_POINTS + GTK_UNIT_INCH Unit = C.GTK_UNIT_INCH + GTK_UNIT_MM Unit = C.GTK_UNIT_MM +) + +func marshalUnit(p uintptr) (interface{}, error) { + c := C.g_value_get_enum((*C.GValue)(unsafe.Pointer(p))) + return Unit(c), nil +} + +/* + * GtkPageRanges + */ +type PageRanges struct { + ranges []C.GtkPageRange +} + +// free() is a wrapper around g_free. +func (pr *PageRanges) free() { + C.g_free((C.gpointer)(unsafe.Pointer(&pr.ranges[0]))) +} + +/* + * GtkPageSetup + */ +type PageSetup struct { + *glib.Object +} + +func (ps *PageSetup) native() *C.GtkPageSetup { + if ps == nil || ps.GObject == nil { + return nil + } + p := unsafe.Pointer(ps.GObject) + return C.toGtkPageSetup(p) +} + +func marshalPageSetup(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapPageSetup(obj), nil +} + +func wrapPageSetup(obj *glib.Object) *PageSetup { + return &PageSetup{obj} +} + +// PageSetupNew() is a wrapper around gtk_page_setup_new(). +func PageSetupNew() (*PageSetup, error) { + c := C.gtk_page_setup_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapPageSetup(obj), nil +} + +// Copy() is a wrapper around gtk_page_setup_copy(). +func (ps *PageSetup) Copy() (*PageSetup, error) { + c := C.gtk_page_setup_copy(ps.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapPageSetup(obj), nil +} + +// GetOrientation() is a wrapper around gtk_page_setup_get_orientation(). +func (ps *PageSetup) GetOrientation() PageOrientation { + c := C.gtk_page_setup_get_orientation(ps.native()) + return PageOrientation(c) +} + +// SetOrientation() is a wrapper around gtk_page_setup_set_orientation(). +func (ps *PageSetup) SetOrientation(orientation PageOrientation) { + C.gtk_page_setup_set_orientation(ps.native(), C.GtkPageOrientation(orientation)) +} + +// GetPaperSize() is a wrapper around gtk_page_setup_get_paper_size(). +func (ps *PageSetup) GetPaperSize() *PaperSize { + c := C.gtk_page_setup_get_paper_size(ps.native()) + p := &PaperSize{c} + runtime.SetFinalizer(p, (*PaperSize).free) + return p +} + +// SetPaperSize() is a wrapper around gtk_page_setup_set_paper_size(). +func (ps *PageSetup) SetPaperSize(size *PaperSize) { + C.gtk_page_setup_set_paper_size(ps.native(), size.native()) +} + +// GetTopMargin() is a wrapper around gtk_page_setup_get_top_margin(). +func (ps *PageSetup) GetTopMargin(unit Unit) float64 { + c := C.gtk_page_setup_get_top_margin(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// SetTopMargin() is a wrapper around gtk_page_setup_set_top_margin(). +func (ps *PageSetup) SetTopMargin(margin float64, unit Unit) { + C.gtk_page_setup_set_top_margin(ps.native(), C.gdouble(margin), C.GtkUnit(unit)) +} + +// GetBottomMargin() is a wrapper around gtk_page_setup_get_bottom_margin(). +func (ps *PageSetup) GetBottomMargin(unit Unit) float64 { + c := C.gtk_page_setup_get_bottom_margin(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// SetBottomMargin() is a wrapper around gtk_page_setup_set_bottom_margin(). +func (ps *PageSetup) SetBottomMargin(margin float64, unit Unit) { + C.gtk_page_setup_set_bottom_margin(ps.native(), C.gdouble(margin), C.GtkUnit(unit)) +} + +// GetLeftMargin() is a wrapper around gtk_page_setup_get_left_margin(). +func (ps *PageSetup) GetLeftMargin(unit Unit) float64 { + c := C.gtk_page_setup_get_left_margin(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// SetLeftMargin() is a wrapper around gtk_page_setup_set_left_margin(). +func (ps *PageSetup) SetLeftMargin(margin float64, unit Unit) { + C.gtk_page_setup_set_left_margin(ps.native(), C.gdouble(margin), C.GtkUnit(unit)) +} + +// GetRightMargin() is a wrapper around gtk_page_setup_get_right_margin(). +func (ps *PageSetup) GetRightMargin(unit Unit) float64 { + c := C.gtk_page_setup_get_right_margin(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// SetRightMargin() is a wrapper around gtk_page_setup_set_right_margin(). +func (ps *PageSetup) SetRightMargin(margin float64, unit Unit) { + C.gtk_page_setup_set_right_margin(ps.native(), C.gdouble(margin), C.GtkUnit(unit)) +} + +// SetPaperSizeAndDefaultMargins() is a wrapper around gtk_page_setup_set_paper_size_and_default_margins(). +func (ps *PageSetup) SetPaperSizeAndDefaultMargins(size *PaperSize) { + C.gtk_page_setup_set_paper_size_and_default_margins(ps.native(), size.native()) +} + +// GetPaperWidth() is a wrapper around gtk_page_setup_get_paper_width(). +func (ps *PageSetup) GetPaperWidth(unit Unit) float64 { + c := C.gtk_page_setup_get_paper_width(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// GetPaperHeight() is a wrapper around gtk_page_setup_get_paper_height(). +func (ps *PageSetup) GetPaperHeight(unit Unit) float64 { + c := C.gtk_page_setup_get_paper_height(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// GetPageWidth() is a wrapper around gtk_page_setup_get_page_width(). +func (ps *PageSetup) GetPageWidth(unit Unit) float64 { + c := C.gtk_page_setup_get_page_width(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// GetPageHeight() is a wrapper around gtk_page_setup_get_page_height(). +func (ps *PageSetup) GetPageHeight(unit Unit) float64 { + c := C.gtk_page_setup_get_page_height(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// PageSetupNewFromFile() is a wrapper around gtk_page_setup_new_from_file(). +func PageSetupNewFromFile(fileName string) (*PageSetup, error) { + cstr := C.CString(fileName) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + c := C.gtk_page_setup_new_from_file((*C.gchar)(cstr), &err) + if c == nil { + defer C.g_error_free(err) + return nil, errors.New(C.GoString((*C.char)(err.message))) + } + obj := wrapObject(unsafe.Pointer(c)) + return &PageSetup{obj}, nil + +} + +// PageSetupNewFromKeyFile() is a wrapper around gtk_page_setup_new_from_key_file(). + +// PageSetupLoadFile() is a wrapper around gtk_page_setup_load_file(). +func (ps *PageSetup) PageSetupLoadFile(name string) error { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + res := C.gtk_page_setup_load_file(ps.native(), cstr, &err) + if !gobool(res) { + defer C.g_error_free(err) + return errors.New(C.GoString((*C.char)(err.message))) + } + return nil +} + +// PageSetupLoadKeyFile() is a wrapper around gtk_page_setup_load_key_file(). + +// PageSetupToFile() is a wrapper around gtk_page_setup_to_file(). +func (ps *PageSetup) PageSetupToFile(name string) error { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + res := C.gtk_page_setup_to_file(ps.native(), cstr, &err) + if !gobool(res) { + defer C.g_error_free(err) + return errors.New(C.GoString((*C.char)(err.message))) + } + return nil +} + +// PageSetupToKeyFile() is a wrapper around gtk_page_setup_to_key_file(). + +/* + * GtkPaperSize + */ + +// PaperSize is a representation of GTK's GtkPaperSize +type PaperSize struct { + GtkPaperSize *C.GtkPaperSize +} + +// native returns a pointer to the underlying GtkPaperSize. +func (ps *PaperSize) native() *C.GtkPaperSize { + if ps == nil { + return nil + } + return ps.GtkPaperSize +} + +func marshalPaperSize(p uintptr) (interface{}, error) { + c := C.g_value_get_boxed((*C.GValue)(unsafe.Pointer(p))) + return &PaperSize{(*C.GtkPaperSize)(unsafe.Pointer(c))}, nil +} + +const ( + UNIT_PIXEL int = C.GTK_UNIT_PIXEL + PAPER_NAME_A3 string = C.GTK_PAPER_NAME_A3 + PAPER_NAME_A4 string = C.GTK_PAPER_NAME_A4 + PAPER_NAME_A5 string = C.GTK_PAPER_NAME_A5 + PAPER_NAME_B5 string = C.GTK_PAPER_NAME_B5 + PAPER_NAME_LETTER string = C.GTK_PAPER_NAME_LETTER + PAPER_NAME_EXECUTIVE string = C.GTK_PAPER_NAME_EXECUTIVE + PAPER_NAME_LEGAL string = C.GTK_PAPER_NAME_LEGAL +) + +// PaperSizeNew() is a wrapper around gtk_paper_size_new(). +func PaperSizeNew(name string) (*PaperSize, error) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + var gName *C.gchar + + if name == "" { + gName = nil + } else { + gName = (*C.gchar)(cstr) + } + + c := C.gtk_paper_size_new(gName) + if c == nil { + return nil, nilPtrErr + } + + t := &PaperSize{c} + runtime.SetFinalizer(t, (*PaperSize).free) + return t, nil +} + +// PaperSizeNewFromPPD() is a wrapper around gtk_paper_size_new_from_ppd(). +func PaperSizeNewFromPPD(name, displayName string, width, height float64) (*PaperSize, error) { + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) + cDisplayName := C.CString(displayName) + defer C.free(unsafe.Pointer(cDisplayName)) + c := C.gtk_paper_size_new_from_ppd((*C.gchar)(cName), (*C.gchar)(cDisplayName), + C.gdouble(width), C.gdouble(height)) + if c == nil { + return nil, nilPtrErr + } + t := &PaperSize{c} + runtime.SetFinalizer(t, (*PaperSize).free) + return t, nil +} + +// PaperSizeNewCustom() is a wrapper around gtk_paper_size_new_custom(). +func PaperSizeNewCustom(name, displayName string, width, height float64, unit Unit) (*PaperSize, error) { + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) + cDisplayName := C.CString(displayName) + defer C.free(unsafe.Pointer(cDisplayName)) + c := C.gtk_paper_size_new_custom((*C.gchar)(cName), (*C.gchar)(cDisplayName), + C.gdouble(width), C.gdouble(height), C.GtkUnit(unit)) + if c == nil { + return nil, nilPtrErr + } + t := &PaperSize{c} + runtime.SetFinalizer(t, (*PaperSize).free) + return t, nil +} + +// Copy() is a wrapper around gtk_paper_size_copy(). +func (ps *PaperSize) Copy() (*PaperSize, error) { + c := C.gtk_paper_size_copy(ps.native()) + if c == nil { + return nil, nilPtrErr + } + t := &PaperSize{c} + runtime.SetFinalizer(t, (*PaperSize).free) + return t, nil +} + +// free() is a wrapper around gtk_paper_size_free(). +func (ps *PaperSize) free() { + C.gtk_paper_size_free(ps.native()) +} + +// IsEqual() is a wrapper around gtk_paper_size_is_equal(). +func (ps *PaperSize) IsEqual(other *PaperSize) bool { + c := C.gtk_paper_size_is_equal(ps.native(), other.native()) + return gobool(c) +} + +// PaperSizeGetPaperSizes() is a wrapper around gtk_paper_size_get_paper_sizes(). +func PaperSizeGetPaperSizes(includeCustom bool) *glib.List { + clist := C.gtk_paper_size_get_paper_sizes(gbool(includeCustom)) + if clist == nil { + return nil + } + + glist := glib.WrapList(uintptr(unsafe.Pointer(clist))) + glist.DataWrapper(func(ptr unsafe.Pointer) interface{} { + return &PaperSize{(*C.GtkPaperSize)(ptr)} + }) + + runtime.SetFinalizer(glist, func(glist *glib.List) { + glist.FreeFull(func(item interface{}) { + ps := item.(*PaperSize) + C.gtk_paper_size_free(ps.GtkPaperSize) + }) + }) + + return glist +} + +// GetName() is a wrapper around gtk_paper_size_get_name(). +func (ps *PaperSize) GetName() string { + c := C.gtk_paper_size_get_name(ps.native()) + return C.GoString((*C.char)(c)) +} + +// GetDisplayName() is a wrapper around gtk_paper_size_get_display_name(). +func (ps *PaperSize) GetDisplayName() string { + c := C.gtk_paper_size_get_display_name(ps.native()) + return C.GoString((*C.char)(c)) +} + +// GetPPDName() is a wrapper around gtk_paper_size_get_ppd_name(). +func (ps *PaperSize) GetPPDName() (string, error) { + c := C.gtk_paper_size_get_ppd_name(ps.native()) + if c == nil { + return "", nilPtrErr + } + return C.GoString((*C.char)(c)), nil +} + +// GetWidth() is a wrapper around gtk_paper_size_get_width(). +func (ps *PaperSize) GetWidth(unit Unit) float64 { + c := C.gtk_paper_size_get_width(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// GetHeight() is a wrapper around gtk_paper_size_get_height(). +func (ps *PaperSize) GetHeight(unit Unit) float64 { + c := C.gtk_paper_size_get_width(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// IsCustom() is a wrapper around gtk_paper_size_is_custom(). +func (ps *PaperSize) IsCustom() bool { + c := C.gtk_paper_size_is_custom(ps.native()) + return gobool(c) +} + +// SetSize() is a wrapper around gtk_paper_size_set_size(). +func (ps *PaperSize) SetSize(width, height float64, unit Unit) { + C.gtk_paper_size_set_size(ps.native(), C.gdouble(width), C.gdouble(height), C.GtkUnit(unit)) +} + +// GetDefaultTopMargin() is a wrapper around gtk_paper_size_get_default_top_margin(). +func (ps *PaperSize) GetDefaultTopMargin(unit Unit) float64 { + c := C.gtk_paper_size_get_default_top_margin(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// GetDefaultBottomMargin() is a wrapper around gtk_paper_size_get_default_bottom_margin(). +func (ps *PaperSize) GetDefaultBottomMargin(unit Unit) float64 { + c := C.gtk_paper_size_get_default_bottom_margin(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// GetDefaultLeftMargin() is a wrapper around gtk_paper_size_get_default_left_margin(). +func (ps *PaperSize) GetDefaultLeftMargin(unit Unit) float64 { + c := C.gtk_paper_size_get_default_left_margin(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// GetDefaultRightMargin() is a wrapper around gtk_paper_size_get_default_right_margin(). +func (ps *PaperSize) GetDefaultRightMargin(unit Unit) float64 { + c := C.gtk_paper_size_get_default_right_margin(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// PaperSizeGetDefault() is a wrapper around gtk_paper_size_get_default(). +func PaperSizeGetDefaultRightMargin(unit Unit) string { + c := C.gtk_paper_size_get_default() + return C.GoString((*C.char)(c)) +} + +// PaperSizeNewFromKeyFile() is a wrapper around gtk_paper_size_new_from_key_file(). +// PaperSizeToKeyFile() is a wrapper around gtk_paper_size_to_key_file(). + +/* + * GtkPrintContext + */ + +// PrintContext is a representation of GTK's GtkPrintContext. +type PrintContext struct { + *glib.Object +} + +// native() returns a pointer to the underlying GtkPrintContext. +func (pc *PrintContext) native() *C.GtkPrintContext { + if pc == nil || pc.GObject == nil { + return nil + } + p := unsafe.Pointer(pc.GObject) + return C.toGtkPrintContext(p) +} + +func marshalPrintContext(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapPrintContext(obj), nil +} + +func wrapPrintContext(obj *glib.Object) *PrintContext { + return &PrintContext{obj} +} + +// GetCairoContext() is a wrapper around gtk_print_context_get_cairo_context(). +func (pc *PrintContext) GetCairoContext() *cairo.Context { + c := C.gtk_print_context_get_cairo_context(pc.native()) + return cairo.WrapContext(uintptr(unsafe.Pointer(c))) +} + +// SetCairoContext() is a wrapper around gtk_print_context_set_cairo_context(). +func (pc *PrintContext) SetCairoContext(cr *cairo.Context, dpiX, dpiY float64) { + C.gtk_print_context_set_cairo_context(pc.native(), + (*C.cairo_t)(unsafe.Pointer(cr.Native())), + C.double(dpiX), C.double(dpiY)) +} + +// GetPageSetup() is a wrapper around gtk_print_context_get_page_setup(). +func (pc *PrintContext) GetPageSetup() *PageSetup { + c := C.gtk_print_context_get_page_setup(pc.native()) + obj := wrapObject(unsafe.Pointer(c)) + return wrapPageSetup(obj) +} + +// GetWidth() is a wrapper around gtk_print_context_get_width(). +func (pc *PrintContext) GetWidth() float64 { + c := C.gtk_print_context_get_width(pc.native()) + return float64(c) +} + +// GetHeight() is a wrapper around gtk_print_context_get_height(). +func (pc *PrintContext) GetHeight() float64 { + c := C.gtk_print_context_get_height(pc.native()) + return float64(c) +} + +// GetDpiX() is a wrapper around gtk_print_context_get_dpi_x(). +func (pc *PrintContext) GetDpiX() float64 { + c := C.gtk_print_context_get_dpi_x(pc.native()) + return float64(c) +} + +// GetDpiY() is a wrapper around gtk_print_context_get_dpi_y(). +func (pc *PrintContext) GetDpiY() float64 { + c := C.gtk_print_context_get_dpi_y(pc.native()) + return float64(c) +} + +// GetPangoFontMap() is a wrapper around gtk_print_context_get_pango_fontmap(). +func (pc *PrintContext) GetPangoFontMap() *pango.FontMap { + c := C.gtk_print_context_get_pango_fontmap(pc.native()) + return pango.WrapFontMap(uintptr(unsafe.Pointer(c))) +} + +// CreatePangoContext() is a wrapper around gtk_print_context_create_pango_context(). +func (pc *PrintContext) CreatePangoContext() *pango.Context { + c := C.gtk_print_context_create_pango_context(pc.native()) + return pango.WrapContext(uintptr(unsafe.Pointer(c))) +} + +// CreatePangoLayout() is a wrapper around gtk_print_context_create_pango_layout(). +func (pc *PrintContext) CreatePangoLayout() *pango.Layout { + c := C.gtk_print_context_create_pango_layout(pc.native()) + return pango.WrapLayout(uintptr(unsafe.Pointer(c))) +} + +// GetHardMargins() is a wrapper around gtk_print_context_get_hard_margins(). +func (pc *PrintContext) GetHardMargins() (float64, float64, float64, float64, error) { + var top, bottom, left, right C.gdouble + c := C.gtk_print_context_get_hard_margins(pc.native(), &top, &bottom, &left, &right) + if gobool(c) == false { + return 0.0, 0.0, 0.0, 0.0, errors.New("unable to retrieve hard margins") + } + return float64(top), float64(bottom), float64(left), float64(right), nil +} + +/* + * GtkPrintOperation + */ +type PrintOperation struct { + *glib.Object + + // Interfaces + PrintOperationPreview +} + +func (po *PrintOperation) native() *C.GtkPrintOperation { + if po == nil || po.GObject == nil { + return nil + } + p := unsafe.Pointer(po.GObject) + return C.toGtkPrintOperation(p) +} + +func (v *PrintOperation) toPrintOperationPreview() *C.GtkPrintOperationPreview { + if v == nil { + return nil + } + return C.toGtkPrintOperationPreview(unsafe.Pointer(v.GObject)) +} + +func marshalPrintOperation(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapPrintOperation(obj), nil +} + +func wrapPrintOperation(obj *glib.Object) *PrintOperation { + pop := wrapPrintOperationPreview(obj) + return &PrintOperation{obj, *pop} +} + +// PrintOperationNew() is a wrapper around gtk_print_operation_new(). +func PrintOperationNew() (*PrintOperation, error) { + c := C.gtk_print_operation_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapPrintOperation(obj), nil +} + +// SetAllowAsync() is a wrapper around gtk_print_operation_set_allow_async(). +func (po *PrintOperation) PrintOperationSetAllowAsync(allowSync bool) { + C.gtk_print_operation_set_allow_async(po.native(), gbool(allowSync)) +} + +// GetError() is a wrapper around gtk_print_operation_get_error(). +func (po *PrintOperation) PrintOperationGetError() error { + var err *C.GError = nil + C.gtk_print_operation_get_error(po.native(), &err) + defer C.g_error_free(err) + return errors.New(C.GoString((*C.char)(err.message))) +} + +// SetDefaultPageSetup() is a wrapper around gtk_print_operation_set_default_page_setup(). +func (po *PrintOperation) SetDefaultPageSetup(ps *PageSetup) { + C.gtk_print_operation_set_default_page_setup(po.native(), ps.native()) +} + +// GetDefaultPageSetup() is a wrapper around gtk_print_operation_get_default_page_setup(). +func (po *PrintOperation) GetDefaultPageSetup() (*PageSetup, error) { + c := C.gtk_print_operation_get_default_page_setup(po.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapPageSetup(obj), nil +} + +// SetPrintSettings() is a wrapper around gtk_print_operation_set_print_settings(). +func (po *PrintOperation) SetPrintSettings(ps *PrintSettings) { + C.gtk_print_operation_set_print_settings(po.native(), ps.native()) +} + +// GetPrintSettings() is a wrapper around gtk_print_operation_get_print_settings(). +func (po *PrintOperation) GetPrintSettings(ps *PageSetup) (*PrintSettings, error) { + c := C.gtk_print_operation_get_print_settings(po.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapPrintSettings(obj), nil +} + +// SetJobName() is a wrapper around gtk_print_operation_set_job_name(). +func (po *PrintOperation) SetJobName(name string) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_operation_set_job_name(po.native(), (*C.gchar)(cstr)) +} + +// SetNPages() is a wrapper around gtk_print_operation_set_n_pages(). +func (po *PrintOperation) SetNPages(pages int) { + C.gtk_print_operation_set_n_pages(po.native(), C.gint(pages)) +} + +// GetNPagesToPrint() is a wrapper around gtk_print_operation_get_n_pages_to_print(). +func (po *PrintOperation) GetNPagesToPrint() int { + c := C.gtk_print_operation_get_n_pages_to_print(po.native()) + return int(c) +} + +// SetCurrentPage() is a wrapper around gtk_print_operation_set_current_page(). +func (po *PrintOperation) SetCurrentPage(page int) { + C.gtk_print_operation_set_current_page(po.native(), C.gint(page)) +} + +// SetUseFullPage() is a wrapper around gtk_print_operation_set_use_full_page(). +func (po *PrintOperation) SetUseFullPage(full bool) { + C.gtk_print_operation_set_use_full_page(po.native(), gbool(full)) +} + +// SetUnit() is a wrapper around gtk_print_operation_set_unit(). +func (po *PrintOperation) SetUnit(unit Unit) { + C.gtk_print_operation_set_unit(po.native(), C.GtkUnit(unit)) +} + +// SetExportFilename() is a wrapper around gtk_print_operation_set_export_filename(). +func (po *PrintOperation) SetExportFilename(name string) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_operation_set_export_filename(po.native(), (*C.gchar)(cstr)) +} + +// SetShowProgress() is a wrapper around gtk_print_operation_set_show_progress(). +func (po *PrintOperation) SetShowProgress(show bool) { + C.gtk_print_operation_set_show_progress(po.native(), gbool(show)) +} + +// SetTrackPrintStatus() is a wrapper around gtk_print_operation_set_track_print_status(). +func (po *PrintOperation) SetTrackPrintStatus(progress bool) { + C.gtk_print_operation_set_track_print_status(po.native(), gbool(progress)) +} + +// SetCustomTabLabel() is a wrapper around gtk_print_operation_set_custom_tab_label(). +func (po *PrintOperation) SetCustomTabLabel(label string) { + cstr := C.CString(label) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_operation_set_custom_tab_label(po.native(), (*C.gchar)(cstr)) +} + +// Run() is a wrapper around gtk_print_operation_run(). +func (po *PrintOperation) Run(action PrintOperationAction, parent *Window) (PrintOperationResult, error) { + var err *C.GError = nil + c := C.gtk_print_operation_run(po.native(), C.GtkPrintOperationAction(action), parent.native(), &err) + res := PrintOperationResult(c) + if res == PRINT_OPERATION_RESULT_ERROR { + defer C.g_error_free(err) + return res, errors.New(C.GoString((*C.char)(err.message))) + } + return res, nil +} + +// Cancel() is a wrapper around gtk_print_operation_cancel(). +func (po *PrintOperation) Cancel() { + C.gtk_print_operation_cancel(po.native()) +} + +// DrawPageFinish() is a wrapper around gtk_print_operation_draw_page_finish(). +func (po *PrintOperation) DrawPageFinish() { + C.gtk_print_operation_draw_page_finish(po.native()) +} + +// SetDeferDrawing() is a wrapper around gtk_print_operation_set_defer_drawing(). +func (po *PrintOperation) SetDeferDrawing() { + C.gtk_print_operation_set_defer_drawing(po.native()) +} + +// GetStatus() is a wrapper around gtk_print_operation_get_status(). +func (po *PrintOperation) GetStatus() PrintStatus { + c := C.gtk_print_operation_get_status(po.native()) + return PrintStatus(c) +} + +// GetStatusString() is a wrapper around gtk_print_operation_get_status_string(). +func (po *PrintOperation) GetStatusString() string { + c := C.gtk_print_operation_get_status_string(po.native()) + return C.GoString((*C.char)(c)) +} + +// IsFinished() is a wrapper around gtk_print_operation_is_finished(). +func (po *PrintOperation) IsFinished() bool { + c := C.gtk_print_operation_is_finished(po.native()) + return gobool(c) +} + +// SetSupportSelection() is a wrapper around gtk_print_operation_set_support_selection(). +func (po *PrintOperation) SetSupportSelection(selection bool) { + C.gtk_print_operation_set_support_selection(po.native(), gbool(selection)) +} + +// GetSupportSelection() is a wrapper around gtk_print_operation_get_support_selection(). +func (po *PrintOperation) GetSupportSelection() bool { + c := C.gtk_print_operation_get_support_selection(po.native()) + return gobool(c) +} + +// SetHasSelection() is a wrapper around gtk_print_operation_set_has_selection(). +func (po *PrintOperation) SetHasSelection(selection bool) { + C.gtk_print_operation_set_has_selection(po.native(), gbool(selection)) +} + +// GetHasSelection() is a wrapper around gtk_print_operation_get_has_selection(). +func (po *PrintOperation) GetHasSelection() bool { + c := C.gtk_print_operation_get_has_selection(po.native()) + return gobool(c) +} + +// SetEmbedPageSetup() is a wrapper around gtk_print_operation_set_embed_page_setup(). +func (po *PrintOperation) SetEmbedPageSetup(embed bool) { + C.gtk_print_operation_set_embed_page_setup(po.native(), gbool(embed)) +} + +// GetEmbedPageSetup() is a wrapper around gtk_print_operation_get_embed_page_setup(). +func (po *PrintOperation) GetEmbedPageSetup() bool { + c := C.gtk_print_operation_get_embed_page_setup(po.native()) + return gobool(c) +} + +// PrintRunPageSetupDialog() is a wrapper around gtk_print_run_page_setup_dialog(). +func PrintRunPageSetupDialog(parent *Window, pageSetup *PageSetup, settings *PrintSettings) *PageSetup { + c := C.gtk_print_run_page_setup_dialog(parent.native(), pageSetup.native(), settings.native()) + obj := wrapObject(unsafe.Pointer(c)) + return wrapPageSetup(obj) +} + +type PageSetupDoneCallback func(setup *PageSetup, userData uintptr) + +type pageSetupDoneCallbackData struct { + fn PageSetupDoneCallback + data uintptr +} + +var ( + pageSetupDoneCallbackRegistry = struct { + sync.RWMutex + next int + m map[int]pageSetupDoneCallbackData + }{ + next: 1, + m: make(map[int]pageSetupDoneCallbackData), + } +) + +// PrintRunPageSetupDialogAsync() is a wrapper around gtk_print_run_page_setup_dialog_async(). +func PrintRunPageSetupDialogAsync(parent *Window, setup *PageSetup, + settings *PrintSettings, cb PageSetupDoneCallback, data uintptr) { + + pageSetupDoneCallbackRegistry.Lock() + id := pageSetupDoneCallbackRegistry.next + pageSetupDoneCallbackRegistry.next++ + pageSetupDoneCallbackRegistry.m[id] = + pageSetupDoneCallbackData{fn: cb, data: data} + pageSetupDoneCallbackRegistry.Unlock() + + C._gtk_print_run_page_setup_dialog_async(parent.native(), setup.native(), + settings.native(), C.gpointer(uintptr(id))) +} + +/* + * GtkPrintOperationPreview + */ + +// PrintOperationPreview is a representation of GTK's GtkPrintOperationPreview GInterface. +type PrintOperationPreview struct { + *glib.Object +} + +// IPrintOperationPreview is an interface type implemented by all structs +// embedding a PrintOperationPreview. It is meant to be used as an argument type +// for wrapper functions that wrap around a C GTK function taking a +// GtkPrintOperationPreview. +type IPrintOperationPreview interface { + toPrintOperationPreview() *C.GtkPrintOperationPreview +} + +// native() returns a pointer to the underlying GObject as a GtkPrintOperationPreview. +func (v *PrintOperationPreview) native() *C.GtkPrintOperationPreview { + if v == nil || v.GObject == nil { + return nil + } + p := unsafe.Pointer(v.GObject) + return C.toGtkPrintOperationPreview(p) +} + +func marshalPrintOperationPreview(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + obj := wrapObject(unsafe.Pointer(c)) + return wrapPrintOperationPreview(obj), nil +} + +func wrapPrintOperationPreview(obj *glib.Object) *PrintOperationPreview { + return &PrintOperationPreview{obj} +} + +func (v *PrintOperationPreview) toPrintOperationPreview() *C.GtkPrintOperationPreview { + if v == nil { + return nil + } + return v.native() +} + +// RenderPage()() is a wrapper around gtk_print_operation_preview_render_page(). +func (pop *PrintOperationPreview) RenderPage(page int) { + C.gtk_print_operation_preview_render_page(pop.native(), C.gint(page)) +} + +// EndPreview()() is a wrapper around gtk_print_operation_preview_end_preview(). +func (pop *PrintOperationPreview) EndPreview() { + C.gtk_print_operation_preview_end_preview(pop.native()) +} + +// IsSelected()() is a wrapper around gtk_print_operation_preview_is_selected(). +func (pop *PrintOperationPreview) IsSelected(page int) bool { + c := C.gtk_print_operation_preview_is_selected(pop.native(), C.gint(page)) + return gobool(c) +} + +/* + * GtkPrintSettings + */ + +type PrintSettings struct { + *glib.Object +} + +func (ps *PrintSettings) native() *C.GtkPrintSettings { + if ps == nil || ps.GObject == nil { + return nil + } + + p := unsafe.Pointer(ps.GObject) + return C.toGtkPrintSettings(p) +} + +func marshalPrintSettings(p uintptr) (interface{}, error) { + c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p))) + return wrapPrintSettings(wrapObject(unsafe.Pointer(c))), nil +} + +func wrapPrintSettings(obj *glib.Object) *PrintSettings { + return &PrintSettings{obj} +} + +const ( + PRINT_SETTINGS_PRINTER string = C.GTK_PRINT_SETTINGS_PRINTER + PRINT_SETTINGS_ORIENTATION string = C.GTK_PRINT_SETTINGS_ORIENTATION + PRINT_SETTINGS_PAPER_FORMAT string = C.GTK_PRINT_SETTINGS_PAPER_FORMAT + PRINT_SETTINGS_PAPER_WIDTH string = C.GTK_PRINT_SETTINGS_PAPER_WIDTH + PRINT_SETTINGS_PAPER_HEIGHT string = C.GTK_PRINT_SETTINGS_PAPER_HEIGHT + PRINT_SETTINGS_USE_COLOR string = C.GTK_PRINT_SETTINGS_USE_COLOR + PRINT_SETTINGS_COLLATE string = C.GTK_PRINT_SETTINGS_COLLATE + PRINT_SETTINGS_REVERSE string = C.GTK_PRINT_SETTINGS_REVERSE + PRINT_SETTINGS_DUPLEX string = C.GTK_PRINT_SETTINGS_DUPLEX + PRINT_SETTINGS_QUALITY string = C.GTK_PRINT_SETTINGS_QUALITY + PRINT_SETTINGS_N_COPIES string = C.GTK_PRINT_SETTINGS_N_COPIES + PRINT_SETTINGS_NUMBER_UP string = C.GTK_PRINT_SETTINGS_NUMBER_UP + PRINT_SETTINGS_NUMBER_UP_LAYOUT string = C.GTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT + PRINT_SETTINGS_RESOLUTION string = C.GTK_PRINT_SETTINGS_RESOLUTION + PRINT_SETTINGS_RESOLUTION_X string = C.GTK_PRINT_SETTINGS_RESOLUTION_X + PRINT_SETTINGS_RESOLUTION_Y string = C.GTK_PRINT_SETTINGS_RESOLUTION_Y + PRINT_SETTINGS_PRINTER_LPI string = C.GTK_PRINT_SETTINGS_PRINTER_LPI + PRINT_SETTINGS_SCALE string = C.GTK_PRINT_SETTINGS_SCALE + PRINT_SETTINGS_PRINT_PAGES string = C.GTK_PRINT_SETTINGS_PRINT_PAGES + PRINT_SETTINGS_PAGE_RANGES string = C.GTK_PRINT_SETTINGS_PAGE_RANGES + PRINT_SETTINGS_PAGE_SET string = C.GTK_PRINT_SETTINGS_PAGE_SET + PRINT_SETTINGS_DEFAULT_SOURCE string = C.GTK_PRINT_SETTINGS_DEFAULT_SOURCE + PRINT_SETTINGS_MEDIA_TYPE string = C.GTK_PRINT_SETTINGS_MEDIA_TYPE + PRINT_SETTINGS_DITHER string = C.GTK_PRINT_SETTINGS_DITHER + PRINT_SETTINGS_FINISHINGS string = C.GTK_PRINT_SETTINGS_FINISHINGS + PRINT_SETTINGS_OUTPUT_BIN string = C.GTK_PRINT_SETTINGS_OUTPUT_BIN + PRINT_SETTINGS_OUTPUT_DIR string = C.GTK_PRINT_SETTINGS_OUTPUT_DIR + PRINT_SETTINGS_OUTPUT_BASENAME string = C.GTK_PRINT_SETTINGS_OUTPUT_BASENAME + PRINT_SETTINGS_OUTPUT_FILE_FORMAT string = C.GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT + PRINT_SETTINGS_OUTPUT_URI string = C.GTK_PRINT_SETTINGS_OUTPUT_URI + PRINT_SETTINGS_WIN32_DRIVER_EXTRA string = C.GTK_PRINT_SETTINGS_WIN32_DRIVER_EXTRA + PRINT_SETTINGS_WIN32_DRIVER_VERSION string = C.GTK_PRINT_SETTINGS_WIN32_DRIVER_VERSION +) + +// PrintSettingsNew() is a wrapper around gtk_print_settings_new(). +func PrintSettingsNew() (*PrintSettings, error) { + c := C.gtk_print_settings_new() + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapPrintSettings(obj), nil +} + +// Copy() is a wrapper around gtk_print_settings_copy(). +func (ps *PrintSettings) Copy() (*PrintSettings, error) { + c := C.gtk_print_settings_copy(ps.native()) + if c == nil { + return nil, nilPtrErr + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapPrintSettings(obj), nil +} + +// HasKey() is a wrapper around gtk_print_settings_has_key(). +func (ps *PrintSettings) HasKey(key string) bool { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_print_settings_has_key(ps.native(), (*C.gchar)(cstr)) + return gobool(c) +} + +// Get() is a wrapper around gtk_print_settings_get(). +func (ps *PrintSettings) Get(key string) string { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_print_settings_get(ps.native(), (*C.gchar)(cstr)) + return C.GoString((*C.char)(c)) +} + +// Set() is a wrapper around gtk_print_settings_set(). +// TODO: Since value can't be nil, we can't unset values here. +func (ps *PrintSettings) Set(key, value string) { + cKey := C.CString(key) + defer C.free(unsafe.Pointer(cKey)) + cValue := C.CString(value) + defer C.free(unsafe.Pointer(cValue)) + C.gtk_print_settings_set(ps.native(), (*C.gchar)(cKey), (*C.gchar)(cValue)) +} + +// Unset() is a wrapper around gtk_print_settings_unset(). +func (ps *PrintSettings) Unset(key string) { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_settings_unset(ps.native(), (*C.gchar)(cstr)) +} + +type PrintSettingsCallback func(key, value string, userData uintptr) + +type printSettingsCallbackData struct { + fn PrintSettingsCallback + userData uintptr +} + +var ( + printSettingsCallbackRegistry = struct { + sync.RWMutex + next int + m map[int]printSettingsCallbackData + }{ + next: 1, + m: make(map[int]printSettingsCallbackData), + } +) + +// Foreach() is a wrapper around gtk_print_settings_foreach(). +func (ps *PrintSettings) ForEach(cb PrintSettingsCallback, userData uintptr) { + printSettingsCallbackRegistry.Lock() + id := printSettingsCallbackRegistry.next + printSettingsCallbackRegistry.next++ + printSettingsCallbackRegistry.m[id] = + printSettingsCallbackData{fn: cb, userData: userData} + printSettingsCallbackRegistry.Unlock() + + C._gtk_print_settings_foreach(ps.native(), C.gpointer(uintptr(id))) +} + +// GetBool() is a wrapper around gtk_print_settings_get_bool(). +func (ps *PrintSettings) GetBool(key string) bool { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_print_settings_get_bool(ps.native(), (*C.gchar)(cstr)) + return gobool(c) +} + +// SetBool() is a wrapper around gtk_print_settings_set_bool(). +func (ps *PrintSettings) SetBool(key string, value bool) { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_settings_set_bool(ps.native(), (*C.gchar)(cstr), gbool(value)) +} + +// GetDouble() is a wrapper around gtk_print_settings_get_double(). +func (ps *PrintSettings) GetDouble(key string) float64 { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_print_settings_get_double(ps.native(), (*C.gchar)(cstr)) + return float64(c) +} + +// GetDoubleWithDefault() is a wrapper around gtk_print_settings_get_double_with_default(). +func (ps *PrintSettings) GetDoubleWithDefault(key string, def float64) float64 { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_print_settings_get_double_with_default(ps.native(), + (*C.gchar)(cstr), C.gdouble(def)) + return float64(c) +} + +// SetDouble() is a wrapper around gtk_print_settings_set_double(). +func (ps *PrintSettings) SetDouble(key string, value float64) { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_settings_set_double(ps.native(), (*C.gchar)(cstr), C.gdouble(value)) +} + +// GetLength() is a wrapper around gtk_print_settings_get_length(). +func (ps *PrintSettings) GetLength(key string, unit Unit) float64 { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_print_settings_get_length(ps.native(), (*C.gchar)(cstr), C.GtkUnit(unit)) + return float64(c) +} + +// SetLength() is a wrapper around gtk_print_settings_set_length(). +func (ps *PrintSettings) SetLength(key string, value float64, unit Unit) { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_settings_set_length(ps.native(), (*C.gchar)(cstr), C.gdouble(value), C.GtkUnit(unit)) +} + +// GetInt() is a wrapper around gtk_print_settings_get_int(). +func (ps *PrintSettings) GetInt(key string) int { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_print_settings_get_int(ps.native(), (*C.gchar)(cstr)) + return int(c) +} + +// GetIntWithDefault() is a wrapper around gtk_print_settings_get_int_with_default(). +func (ps *PrintSettings) GetIntWithDefault(key string, def int) int { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + c := C.gtk_print_settings_get_int_with_default(ps.native(), (*C.gchar)(cstr), C.gint(def)) + return int(c) +} + +// SetInt() is a wrapper around gtk_print_settings_set_int(). +func (ps *PrintSettings) SetInt(key string, value int) { + cstr := C.CString(key) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_settings_set_int(ps.native(), (*C.gchar)(cstr), C.gint(value)) +} + +// GetPrinter() is a wrapper around gtk_print_settings_get_printer(). +func (ps *PrintSettings) GetPrinter() string { + c := C.gtk_print_settings_get_printer(ps.native()) + return C.GoString((*C.char)(c)) +} + +// SetPrinter() is a wrapper around gtk_print_settings_set_printer(). +func (ps *PrintSettings) SetPrinter(printer string) { + cstr := C.CString(printer) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_settings_set_printer(ps.native(), (*C.gchar)(cstr)) +} + +// GetOrientation() is a wrapper around gtk_print_settings_get_orientation(). +func (ps *PrintSettings) GetOrientation() PageOrientation { + c := C.gtk_print_settings_get_orientation(ps.native()) + return PageOrientation(c) +} + +// SetOrientation() is a wrapper around gtk_print_settings_set_orientation(). +func (ps *PrintSettings) SetOrientation(orientation PageOrientation) { + C.gtk_print_settings_set_orientation(ps.native(), C.GtkPageOrientation(orientation)) +} + +// GetPaperSize() is a wrapper around gtk_print_settings_get_paper_size(). +func (ps *PrintSettings) GetPaperSize() (*PaperSize, error) { + c := C.gtk_print_settings_get_paper_size(ps.native()) + if c == nil { + return nil, nilPtrErr + } + p := &PaperSize{c} + runtime.SetFinalizer(p, (*PaperSize).free) + return p, nil +} + +// SetPaperSize() is a wrapper around gtk_print_settings_set_paper_size(). +func (ps *PrintSettings) SetPaperSize(size *PaperSize) { + C.gtk_print_settings_set_paper_size(ps.native(), size.native()) +} + +// GetPaperWidth() is a wrapper around gtk_print_settings_get_paper_width(). +func (ps *PrintSettings) GetPaperWidth(unit Unit) float64 { + c := C.gtk_print_settings_get_paper_width(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// SetPaperWidth() is a wrapper around gtk_print_settings_set_paper_width(). +func (ps *PrintSettings) SetPaperWidth(width float64, unit Unit) { + C.gtk_print_settings_set_paper_width(ps.native(), C.gdouble(width), C.GtkUnit(unit)) +} + +// GetPaperHeight() is a wrapper around gtk_print_settings_get_paper_height(). +func (ps *PrintSettings) GetPaperHeight(unit Unit) float64 { + c := C.gtk_print_settings_get_paper_height(ps.native(), C.GtkUnit(unit)) + return float64(c) +} + +// SetPaperHeight() is a wrapper around gtk_print_settings_set_paper_height(). +func (ps *PrintSettings) SetPaperHeight(width float64, unit Unit) { + C.gtk_print_settings_set_paper_height(ps.native(), C.gdouble(width), C.GtkUnit(unit)) +} + +// GetUseColor() is a wrapper around gtk_print_settings_get_use_color(). +func (ps *PrintSettings) GetUseColor() bool { + c := C.gtk_print_settings_get_use_color(ps.native()) + return gobool(c) +} + +// SetUseColor() is a wrapper around gtk_print_settings_set_use_color(). +func (ps *PrintSettings) SetUseColor(color bool) { + C.gtk_print_settings_set_use_color(ps.native(), gbool(color)) +} + +// GetCollate() is a wrapper around gtk_print_settings_get_collate(). +func (ps *PrintSettings) GetCollate() bool { + c := C.gtk_print_settings_get_collate(ps.native()) + return gobool(c) +} + +// SetCollate() is a wrapper around gtk_print_settings_set_collate(). +func (ps *PrintSettings) SetCollate(collate bool) { + C.gtk_print_settings_set_collate(ps.native(), gbool(collate)) +} + +// GetReverse() is a wrapper around gtk_print_settings_get_reverse(). +func (ps *PrintSettings) GetReverse() bool { + c := C.gtk_print_settings_get_reverse(ps.native()) + return gobool(c) +} + +// SetReverse() is a wrapper around gtk_print_settings_set_reverse(). +func (ps *PrintSettings) SetReverse(reverse bool) { + C.gtk_print_settings_set_reverse(ps.native(), gbool(reverse)) +} + +// GetDuplex() is a wrapper around gtk_print_settings_get_duplex(). +func (ps *PrintSettings) GetDuplex() PrintDuplex { + c := C.gtk_print_settings_get_duplex(ps.native()) + return PrintDuplex(c) +} + +// SetDuplex() is a wrapper around gtk_print_settings_set_duplex(). +func (ps *PrintSettings) SetDuplex(duplex PrintDuplex) { + C.gtk_print_settings_set_duplex(ps.native(), C.GtkPrintDuplex(duplex)) +} + +// GetQuality() is a wrapper around gtk_print_settings_get_quality(). +func (ps *PrintSettings) GetQuality() PrintQuality { + c := C.gtk_print_settings_get_quality(ps.native()) + return PrintQuality(c) +} + +// SetQuality() is a wrapper around gtk_print_settings_set_quality(). +func (ps *PrintSettings) SetQuality(quality PrintQuality) { + C.gtk_print_settings_set_quality(ps.native(), C.GtkPrintQuality(quality)) +} + +// GetNCopies() is a wrapper around gtk_print_settings_get_n_copies(). +func (ps *PrintSettings) GetNCopies() int { + c := C.gtk_print_settings_get_n_copies(ps.native()) + return int(c) +} + +// SetNCopies() is a wrapper around gtk_print_settings_set_n_copies(). +func (ps *PrintSettings) SetNCopies(copies int) { + C.gtk_print_settings_set_n_copies(ps.native(), C.gint(copies)) +} + +// GetNmberUp() is a wrapper around gtk_print_settings_get_number_up(). +func (ps *PrintSettings) GetNmberUp() int { + c := C.gtk_print_settings_get_number_up(ps.native()) + return int(c) +} + +// SetNumberUp() is a wrapper around gtk_print_settings_set_number_up(). +func (ps *PrintSettings) SetNumberUp(numberUp int) { + C.gtk_print_settings_set_number_up(ps.native(), C.gint(numberUp)) +} + +// GetNumberUpLayout() is a wrapper around gtk_print_settings_get_number_up_layout(). +func (ps *PrintSettings) GetNumberUpLayout() NumberUpLayout { + c := C.gtk_print_settings_get_number_up_layout(ps.native()) + return NumberUpLayout(c) +} + +// SetNumberUpLayout() is a wrapper around gtk_print_settings_set_number_up_layout(). +func (ps *PrintSettings) SetNumberUpLayout(numberUpLayout NumberUpLayout) { + C.gtk_print_settings_set_number_up_layout(ps.native(), C.GtkNumberUpLayout(numberUpLayout)) +} + +// GetResolution() is a wrapper around gtk_print_settings_get_resolution(). +func (ps *PrintSettings) GetResolution() int { + c := C.gtk_print_settings_get_resolution(ps.native()) + return int(c) +} + +// SetResolution() is a wrapper around gtk_print_settings_set_resolution(). +func (ps *PrintSettings) SetResolution(resolution int) { + C.gtk_print_settings_set_resolution(ps.native(), C.gint(resolution)) +} + +// SetResolutionXY() is a wrapper around gtk_print_settings_set_resolution_xy(). +func (ps *PrintSettings) SetResolutionXY(resolutionX, resolutionY int) { + C.gtk_print_settings_set_resolution_xy(ps.native(), C.gint(resolutionX), C.gint(resolutionY)) +} + +// GetResolutionX() is a wrapper around gtk_print_settings_get_resolution_x(). +func (ps *PrintSettings) GetResolutionX() int { + c := C.gtk_print_settings_get_resolution_x(ps.native()) + return int(c) +} + +// GetResolutionY() is a wrapper around gtk_print_settings_get_resolution_y(). +func (ps *PrintSettings) GetResolutionY() int { + c := C.gtk_print_settings_get_resolution_y(ps.native()) + return int(c) +} + +// GetPrinterLpi() is a wrapper around gtk_print_settings_get_printer_lpi(). +func (ps *PrintSettings) GetPrinterLpi() float64 { + c := C.gtk_print_settings_get_printer_lpi(ps.native()) + return float64(c) +} + +// SetPrinterLpi() is a wrapper around gtk_print_settings_set_printer_lpi(). +func (ps *PrintSettings) SetPrinterLpi(lpi float64) { + C.gtk_print_settings_set_printer_lpi(ps.native(), C.gdouble(lpi)) +} + +// GetScale() is a wrapper around gtk_print_settings_get_scale(). +func (ps *PrintSettings) GetScale() float64 { + c := C.gtk_print_settings_get_scale(ps.native()) + return float64(c) +} + +// SetScale() is a wrapper around gtk_print_settings_set_scale(). +func (ps *PrintSettings) SetScale(scale float64) { + C.gtk_print_settings_set_scale(ps.native(), C.gdouble(scale)) +} + +// GetPrintPages() is a wrapper around gtk_print_settings_get_print_pages(). +func (ps *PrintSettings) GetPrintPages() PrintPages { + c := C.gtk_print_settings_get_print_pages(ps.native()) + return PrintPages(c) +} + +// SetPrintPages() is a wrapper around gtk_print_settings_set_print_pages(). +func (ps *PrintSettings) SetPrintPages(pages PrintPages) { + C.gtk_print_settings_set_print_pages(ps.native(), C.GtkPrintPages(pages)) +} + +// GetPageRanges() is a wrapper around gtk_print_settings_get_page_ranges(). +func (ps *PrintSettings) GetPageRanges() (int, *PageRanges) { + var ranges *C.GtkPageRange + var num C.gint + ranges = C.gtk_print_settings_get_page_ranges(ps.native(), &num) + length := int(num) + if length == 0 { + return 0, &PageRanges{nil} + } + slice := (*[1 << 30]C.GtkPageRange)(unsafe.Pointer(ranges))[:length:length] + t := &PageRanges{slice} + runtime.SetFinalizer(t, (*PageRanges).free) + return length, t +} + +// SetPageRanges() is a wrapper around gtk_print_settings_set_page_ranges(). +func (ps *PrintSettings) SetPageRanges(ranges *PageRanges, num int) { + C.gtk_print_settings_set_page_ranges(ps.native(), &ranges.ranges[0], C.gint(num)) +} + +// GetPageSet() is a wrapper around gtk_print_settings_get_page_set(). +func (ps *PrintSettings) GetPageSet(pages PrintPages) PageSet { + c := C.gtk_print_settings_get_page_set(ps.native()) + return PageSet(c) +} + +// SetPageSet() is a wrapper around gtk_print_settings_set_page_set(). +func (ps *PrintSettings) SetPageSet(pageSet PageSet) { + C.gtk_print_settings_set_page_set(ps.native(), C.GtkPageSet(pageSet)) +} + +// GetDefaultSource() is a wrapper around gtk_print_settings_get_default_source(). +func (ps *PrintSettings) GetDefaultSource() string { + c := C.gtk_print_settings_get_default_source(ps.native()) + return C.GoString((*C.char)(c)) +} + +// SetSefaultSource() is a wrapper around gtk_print_settings_set_default_source(). +func (ps *PrintSettings) SetSefaultSource(defaultSource string) { + cstr := C.CString(defaultSource) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_settings_set_default_source(ps.native(), (*C.gchar)(cstr)) +} + +// GetMediaType() is a wrapper around gtk_print_settings_get_media_type(). +func (ps *PrintSettings) GetMediaType() string { + c := C.gtk_print_settings_get_media_type(ps.native()) + return C.GoString((*C.char)(c)) +} + +// SetMediaType() is a wrapper around gtk_print_settings_set_media_type(). +func (ps *PrintSettings) SetMediaType(mediaType string) { + cstr := C.CString(mediaType) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_settings_set_media_type(ps.native(), (*C.gchar)(cstr)) +} + +// GetDither() is a wrapper around gtk_print_settings_get_dither(). +func (ps *PrintSettings) GetDither() string { + c := C.gtk_print_settings_get_dither(ps.native()) + return C.GoString((*C.char)(c)) +} + +// SetDither() is a wrapper around gtk_print_settings_set_dither(). +func (ps *PrintSettings) SetDither(dither string) { + cstr := C.CString(dither) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_settings_set_dither(ps.native(), (*C.gchar)(cstr)) +} + +// GetFinishings() is a wrapper around gtk_print_settings_get_finishings(). +func (ps *PrintSettings) GetFinishings() string { + c := C.gtk_print_settings_get_finishings(ps.native()) + return C.GoString((*C.char)(c)) +} + +// SetFinishings() is a wrapper around gtk_print_settings_set_finishings(). +func (ps *PrintSettings) SetFinishings(dither string) { + cstr := C.CString(dither) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_settings_set_finishings(ps.native(), (*C.gchar)(cstr)) +} + +// GetOutputBin() is a wrapper around gtk_print_settings_get_output_bin(). +func (ps *PrintSettings) GetOutputBin() string { + c := C.gtk_print_settings_get_output_bin(ps.native()) + return C.GoString((*C.char)(c)) +} + +// SetOutputBin() is a wrapper around gtk_print_settings_set_output_bin(). +func (ps *PrintSettings) SetOutputBin(bin string) { + cstr := C.CString(bin) + defer C.free(unsafe.Pointer(cstr)) + C.gtk_print_settings_set_output_bin(ps.native(), (*C.gchar)(cstr)) +} + +// PrintSettingsNewFromFile() is a wrapper around gtk_print_settings_new_from_file(). +func PrintSettingsNewFromFile(name string) (*PrintSettings, error) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + c := C.gtk_print_settings_new_from_file((*C.gchar)(cstr), &err) + if c == nil { + defer C.g_error_free(err) + return nil, errors.New(C.GoString((*C.char)(err.message))) + } + obj := wrapObject(unsafe.Pointer(c)) + return wrapPrintSettings(obj), nil +} + +// PrintSettingsNewFromKeyFile() is a wrapper around gtk_print_settings_new_from_key_file(). + +// LoadFile() is a wrapper around gtk_print_settings_load_file(). +func (ps *PrintSettings) LoadFile(name string) error { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + c := C.gtk_print_settings_load_file(ps.native(), (*C.gchar)(cstr), &err) + if gobool(c) == false { + defer C.g_error_free(err) + return errors.New(C.GoString((*C.char)(err.message))) + } + return nil +} + +// LoadKeyFile() is a wrapper around gtk_print_settings_load_key_file(). + +// ToFile() is a wrapper around gtk_print_settings_to_file(). +func (ps *PrintSettings) ToFile(name string) error { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + var err *C.GError = nil + c := C.gtk_print_settings_to_file(ps.native(), (*C.gchar)(cstr), &err) + if gobool(c) == false { + return errors.New(C.GoString((*C.char)(err.message))) + } + return nil +} + +// ToKeyFile() is a wrapper around gtk_print_settings_to_key_file(). diff --git a/vendor/github.com/gotk3/gotk3/gtk/print_since_3_16.go b/vendor/github.com/gotk3/gotk3/gtk/print_since_3_16.go new file mode 100644 index 0000000..86b8f0b --- /dev/null +++ b/vendor/github.com/gotk3/gotk3/gtk/print_since_3_16.go @@ -0,0 +1,35 @@ +// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12,!gtk_3_14 + +// See: https://developer.gnome.org/gtk3/3.16/api-index-3-16.html + +package gtk + +// #cgo pkg-config: gtk+-3.0 +// #include +// #include "gtk.go.h" +import "C" +import ( + "runtime" + "unsafe" +) + +// PaperSizeNewFromIpp is a wrapper around gtk_paper_size_new_from_ipp(). +func PaperSizeNewFromIPP(name string, width, height float64) (*PaperSize, error) { + cstr := C.CString(name) + defer C.free(unsafe.Pointer(cstr)) + + c := C.gtk_paper_size_new_from_ipp((*C.gchar)(cstr), C.gdouble(width), C.gdouble(height)) + if c == nil { + return nil, nilPtrErr + } + + t := &PaperSize{c} + runtime.SetFinalizer(t, (*PaperSize).free) + return t, nil +} + +// IsIPP() is a wrapper around gtk_paper_size_is_ipp(). +func (ps *PaperSize) IsIPP() bool { + c := C.gtk_paper_size_is_ipp(ps.native()) + return gobool(c) +} diff --git a/vendor/github.com/gotk3/gotk3/gtk/print_test.go b/vendor/github.com/gotk3/gotk3/gtk/print_test.go new file mode 100644 index 0000000..ccd9a2c --- /dev/null +++ b/vendor/github.com/gotk3/gotk3/gtk/print_test.go @@ -0,0 +1,55 @@ +package gtk + +import ( + "testing" +) + +func init() { + Init(nil) +} + +// TestPageSetup tests creating and manipulating PageSetup +func TestPageSetup(t *testing.T) { + _, err := PageSetupNew() + if err != nil { + t.Error(err) + } +} + +// TestPaperSize tests creating and manipulating PaperSize +func TestPaperSize(t *testing.T) { + _, err := PaperSizeNew(PAPER_NAME_A4) + if err != nil { + t.Error(err) + } +} + +// TestPrintContext tests creating and manipulating PrintContext + +// TestPrintOperation tests creating and manipulating PrintOperation +func TestPrintOperation(t *testing.T) { + _, err := PrintOperationNew() + if err != nil { + t.Error(err) + } +} + +// TestPrintOperationPreview tests creating and manipulating PrintOperationPreview + +// TestPrintSettings tests creating and manipulating PrintSettings +func TestPrintSettings(t *testing.T) { + settings, err := PrintSettingsNew() + if err != nil { + t.Error(err) + } + + settings.Set("Key1", "String1") + settings.SetBool("Key2", true) + settings.Set("Key3", "String2") + settings.SetInt("Key4", 2) + + settings.ForEach(func(key, value string, ptr uintptr) { + }, 0) +} + +// TestPrintContext tests creating and manipulating PrintContext diff --git a/vendor/github.com/gotk3/gotk3/gtk/text_iter.go b/vendor/github.com/gotk3/gotk3/gtk/text_iter.go index 3ebabf3..92189c7 100644 --- a/vendor/github.com/gotk3/gotk3/gtk/text_iter.go +++ b/vendor/github.com/gotk3/gotk3/gtk/text_iter.go @@ -96,11 +96,6 @@ func (v *TextIter) GetVisibleText(end *TextIter) string { return C.GoString((*C.char)(c)) } -// BeginsTag is a wrapper around gtk_text_iter_begins_tag(). -func (v *TextIter) BeginsTag(v1 *TextTag) bool { - return gobool(C.gtk_text_iter_begins_tag(v.native(), v1.native())) -} - // EndsTag is a wrapper around gtk_text_iter_ends_tag(). func (v *TextIter) EndsTag(v1 *TextTag) bool { return gobool(C.gtk_text_iter_ends_tag(v.native(), v1.native())) diff --git a/vendor/github.com/gotk3/gotk3/gtk/widget_since_3_14.go b/vendor/github.com/gotk3/gotk3/gtk/widget_since_3_14.go index d8eb00d..b4c2a47 100644 --- a/vendor/github.com/gotk3/gotk3/gtk/widget_since_3_14.go +++ b/vendor/github.com/gotk3/gotk3/gtk/widget_since_3_14.go @@ -9,7 +9,7 @@ package gtk import "C" // GetClip is a wrapper around gtk_widget_get_clip(). -func (v *Widget) GetClip() *Allocation{ +func (v *Widget) GetClip() *Allocation { var clip Allocation C.gtk_widget_get_clip(v.native(), clip.native()) return &clip diff --git a/vendor/github.com/gotk3/gotk3/gtk/window.go b/vendor/github.com/gotk3/gotk3/gtk/window.go index b214032..8833228 100644 --- a/vendor/github.com/gotk3/gotk3/gtk/window.go +++ b/vendor/github.com/gotk3/gotk3/gtk/window.go @@ -105,12 +105,6 @@ func (v *Window) SetDefaultSize(width, height int) { C.gtk_window_set_default_size(v.native(), C.gint(width), C.gint(height)) } -// SetDefaultGeometry is a wrapper around gtk_window_set_default_geometry(). -func (v *Window) SetDefaultGeometry(width, height int) { - C.gtk_window_set_default_geometry(v.native(), C.gint(width), - C.gint(height)) -} - // GetScreen is a wrapper around gtk_window_get_screen(). func (v *Window) GetScreen() (*gdk.Screen, error) { c := C.gtk_window_get_screen(v.native()) @@ -328,15 +322,6 @@ func (v *Window) SetRole(s string) { C.gtk_window_set_role(v.native(), cstr) } -// SetWMClass is a wrapper around gtk_window_set_wmclass(). -func (v *Window) SetWMClass(name, class string) { - cName := C.CString(name) - defer C.free(unsafe.Pointer(cName)) - cClass := C.CString(class) - defer C.free(unsafe.Pointer(cClass)) - C.gtk_window_set_wmclass(v.native(), (*C.gchar)(cName), (*C.gchar)(cClass)) -} - // GetDecorated is a wrapper around gtk_window_get_decorated(). func (v *Window) GetDecorated() bool { c := C.gtk_window_get_decorated(v.native()) @@ -492,11 +477,6 @@ func (v *Window) Resize(width, height int) { C.gtk_window_resize(v.native(), C.gint(width), C.gint(height)) } -// ResizeToGeometry is a wrapper around gtk_window_resize_to_geometry(). -func (v *Window) ResizeToGeometry(width, height int) { - C.gtk_window_resize_to_geometry(v.native(), C.gint(width), C.gint(height)) -} - // WindowSetDefaultIconFromFile is a wrapper around gtk_window_set_default_icon_from_file(). func WindowSetDefaultIconFromFile(file string) error { cstr := C.CString(file) @@ -596,23 +576,41 @@ func (v *Window) AddMnemonic(keyval uint, target *Widget) { C.gtk_window_add_mnemonic(v.native(), C.guint(keyval), target.native()) } +// RemoveMnemonic is a wrapper around gtk_window_remove_mnemonic(). +func (v *Window) RemoveMnemonic(keyval uint, target *Widget) { + C.gtk_window_remove_mnemonic(v.native(), C.guint(keyval), target.native()) +} + +// ActivateMnemonic is a wrapper around gtk_window_mnemonic_activate(). +func (v *Window) ActivateMnemonic(keyval uint, mods gdk.ModifierType) bool { + c := C.gtk_window_mnemonic_activate(v.native(), C.guint(keyval), C.GdkModifierType(mods)) + return gobool(c) +} + +// GetMnemonicModifier is a wrapper around gtk_window_get_mnemonic_modifier(). +func (v *Window) GetMnemonicModifier() gdk.ModifierType { + c := C.gtk_window_get_mnemonic_modifier(v.native()) + return gdk.ModifierType(c) +} + +// SetMnemonicModifier is a wrapper around gtk_window_set_mnemonic_modifier(). +func (v *Window) SetMnemonicModifier(mods gdk.ModifierType) { + C.gtk_window_set_mnemonic_modifier(v.native(), C.GdkModifierType(mods)) +} + // TODO gtk_window_begin_move_drag(). // TODO gtk_window_begin_resize_drag(). // TODO gtk_window_get_default_icon_list(). // TODO gtk_window_get_group(). // TODO gtk_window_get_icon_list(). -// TODO gtk_window_get_mnemonic_modifier(). // TODO gtk_window_get_type_hint(). // TODO gtk_window_get_window_type(). // TODO gtk_window_list_toplevels(). -// TODO gtk_window_mnemonic_activate(). // TODO gtk_window_parse_geometry(). // TODO gtk_window_propogate_key_event(). -// TODO gtk_window_remove_mnemonic(). // TODO gtk_window_set_attached_to(). // TODO gtk_window_set_default_icon_list(). // TODO gtk_window_set_icon_list(). -// TODO gtk_window_set_mnemonic_modifier(). // TODO gtk_window_set_screen(). // TODO gtk_window_set_type_hint(). // TODO gtk_window_get_resize_grip_area(). diff --git a/vendor/github.com/gotk3/gotk3/gtk/window_since_3_12.go b/vendor/github.com/gotk3/gotk3/gtk/window_since_3_12.go new file mode 100644 index 0000000..f57af53 --- /dev/null +++ b/vendor/github.com/gotk3/gotk3/gtk/window_since_3_12.go @@ -0,0 +1,13 @@ +// +build !gtk_3_6,!gtk_3_8,!gtk_3_10 + +package gtk + +// #cgo pkg-config: gtk+-3.0 +// #include +import "C" + +// IsMaximized is a wrapper around gtk_window_is_maximized(). +func (v *Window) IsMaximized() bool { + c := C.gtk_window_is_maximized(v.native()) + return gobool(c) +} diff --git a/vendor/github.com/gotk3/gotk3/pango/pango-context.go b/vendor/github.com/gotk3/gotk3/pango/pango-context.go index 51c6db6..930ea98 100644 --- a/vendor/github.com/gotk3/gotk3/pango/pango-context.go +++ b/vendor/github.com/gotk3/gotk3/pango/pango-context.go @@ -36,7 +36,7 @@ func init() { // {glib.Type(C.pango_wrap_mode_get_type()), marshalWrapMode}, // Objects/Interfaces - // {glib.Type(C.pango_context_get_type()), marshalContext}, + // {glib.Type(C.pango_context_get_type()), marshalContext}, } glib.RegisterGValueMarshalers(tm) } @@ -66,6 +66,11 @@ func wrapContext(obj *glib.Object) *Context { return &Context{obj} } */ +func WrapContext(p uintptr) *Context { + context := new(Context) + context.pangoContext = (*C.PangoContext)(unsafe.Pointer(p)) + return context +} //PangoContext *pango_context_new (void); func ContextNew() *Context { diff --git a/vendor/github.com/gotk3/gotk3/pango/pango-layout.go b/vendor/github.com/gotk3/gotk3/pango/pango-layout.go index e25f2bd..0f1b6a9 100644 --- a/vendor/github.com/gotk3/gotk3/pango/pango-layout.go +++ b/vendor/github.com/gotk3/gotk3/pango/pango-layout.go @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - + package pango // #cgo pkg-config: pango @@ -54,6 +54,12 @@ func (v *Layout) native() *C.PangoLayout { return (*C.PangoLayout)(unsafe.Pointer(v.pangoLayout)) } +func WrapLayout(p uintptr) *Layout { + layout := new(Layout) + layout.pangoLayout = (*C.PangoLayout)(unsafe.Pointer(p)) + return layout +} + // LayoutLine is a representation of PangoLayoutLine. type LayoutLine struct { pangoLayoutLine *C.PangoLayout diff --git a/vendor/github.com/gotk3/gotk3/pango/pango-types.go b/vendor/github.com/gotk3/gotk3/pango/pango-types.go index bec95ea..d5c8947 100644 --- a/vendor/github.com/gotk3/gotk3/pango/pango-types.go +++ b/vendor/github.com/gotk3/gotk3/pango/pango-types.go @@ -97,6 +97,15 @@ func (v *FontMap) native() *C.PangoFontMap { return (*C.PangoFontMap)(unsafe.Pointer(v.pangoFontMap)) } +func wrapFontMap(fontMap *C.PangoFontMap) *FontMap { + return &FontMap{fontMap} +} + +func WrapFontMap(p uintptr) *FontMap { + fontMap := (*C.PangoFontMap)(unsafe.Pointer(p)) + return wrapFontMap(fontMap) +} + // Rectangle is a representation of PangoRectangle. type Rectangle struct { pangoRectangle *C.PangoRectangle diff --git a/vendor/github.com/gotk3/gotk3/shippable.yml b/vendor/github.com/gotk3/gotk3/shippable.yml deleted file mode 100644 index b3c2955..0000000 --- a/vendor/github.com/gotk3/gotk3/shippable.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: go - -build_image: shippableimages/ubuntu1404_go - -go: - - tip - -before_install: - - sudo apt-get update -y - - sudo apt-get install -y libglib2.0-dev libcairo2-dev libgtk-3-dev xvfb - - source $HOME/.gvm/scripts/gvm; - - if [[ $SHIPPABLE_GO_VERSION == "tip" ]]; then gvm install tip; gvm use tip; fi - - if [[ $SHIPPABLE_GO_VERSION == *release* ]]; then gvm install release; gvm use release; fi - - if [[ $SHIPPABLE_GO_VERSION =~ [0-9].[0-9] ]]; then gvm install go$SHIPPABLE_GO_VERSION; gvm use go$SHIPPABLE_GO_VERSION; fi - - export GOPATH=$SHIPPABLE_GOPATH - - go get github.com/t-yuki/gocover-cobertura - - go get github.com/onsi/gomega - - go get github.com/onsi/ginkgo - - go get code.google.com/p/go.tools/cmd/cover - - "export DISPLAY=:99.0" - - /usr/bin/Xvfb :99 & - -install: - - go build -tags gtk_3_10 -v ./... - -script: - - go test -tags gtk_3_10 -coverprofile=coverage_gtk.txt -covermode count ./gtk - - go test -tags gtk_3_10 ./glib - - $GOPATH/bin/gocover-cobertura < coverage_gtk.txt > shippable/codecoverage/coverage_gtk.xml diff --git a/vendor/github.com/subgraph/go-nfnetlink/.gitignore b/vendor/github.com/subgraph/go-nfnetlink/.gitignore new file mode 100644 index 0000000..0cc2124 --- /dev/null +++ b/vendor/github.com/subgraph/go-nfnetlink/.gitignore @@ -0,0 +1,2 @@ +*.iml +.idea/ diff --git a/vendor/github.com/subgraph/go-nfnetlink/LICENSE b/vendor/github.com/subgraph/go-nfnetlink/LICENSE new file mode 100644 index 0000000..a434339 --- /dev/null +++ b/vendor/github.com/subgraph/go-nfnetlink/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2016, Subgraph +https://subgraph.com +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/subgraph/go-nfnetlink/README.md b/vendor/github.com/subgraph/go-nfnetlink/README.md new file mode 100644 index 0000000..64696a4 --- /dev/null +++ b/vendor/github.com/subgraph/go-nfnetlink/README.md @@ -0,0 +1,52 @@ +# go-nfnetlink - A native Go library for interacting with netfilter subsystems + +A library for communicating with Linux netfilter subsystems over netlink sockets. + +## What is 'netfilter netlink'? + +Linux/net/netfilter/nfnetlink.c: + + Netfilter messages via netlink sockets. Allows for user space protocol helpers and general + trouble making from userspace. + +Netfilter is composed of several subsystems in the Linux kernel, some of which provide access from userland +over a netlink socket interface. The protocol API for accessing these subsystems share a common set of protocol conventions +called nfnetlink (netfilter netlink). + +## What is the nfqueue package? + +A library for the netfilter queue subsystem built on top of the nfnetlink layer. + +Here is a basic example of how to use it: + +Set up IPTables + + # iptables -A OUTPUT -p icmp -j NFQUEUE --queue-num 1 --queue-bypass + +Read ICMP packets from queue number 1 + + q := nfqueue.NewNFQueue(1) + + ps, err := q.Open() + if err != nil { + fmt.Printf("Error opening NFQueue: %v\n", err) + os.Exit(1) + } + defer q.Close() + + for p := range ps { + fmt.Printf("Packet: %v\n", p.Packet) + p.Accept() + } + + +## How can I implement support for other netfilter subsystems? + +You'll probably have to read the C library code or the Linux kernel source to learn about the protocol as there +is usually no documentation at all. Look at nfqueue for an example of how to implement the protocol using +the nfnetlink layer. + +We plan to add some basic support for conntrack in the near future. Pull requests welcome for new features and +subsystems. + + diff --git a/vendor/github.com/subgraph/go-nfnetlink/nfnl.go b/vendor/github.com/subgraph/go-nfnetlink/nfnl.go new file mode 100644 index 0000000..e7316ce --- /dev/null +++ b/vendor/github.com/subgraph/go-nfnetlink/nfnl.go @@ -0,0 +1,138 @@ +package nfnetlink + +import ( + "bytes" + "encoding/binary" + "fmt" + "syscall" + "unsafe" +) + +// The native or local byte order +var native = nativeByteOrder() + +func nativeByteOrder() binary.ByteOrder { + var x uint32 = 0x01020304 + if *(*byte)(unsafe.Pointer(&x)) == 0x01 { + return binary.BigEndian + } else { + return binary.LittleEndian + } +} + +const NFNETLINK_V0 = 0 + +// Length in bytes of NfGenHdr structure +const NFGEN_HDRLEN = 4 + +// General address family dependent message header +type NfGenHdr struct { + Family uint8 // AF_XXX + Version uint8 // nfnetlink version + ResID uint16 // resource id +} + +// Netfilter netlink message +type NfNlMessage struct { + syscall.NlMsghdr // Netlink message header + NfGenHdr // nfnetlink general header + + attrs *NLAttrSet + nls *NetlinkSocket // Socket this message will be transmitted on +} + +// NewNfNlMsg create and return a new NfNlMessage associated with socket s +func (s *NetlinkSocket) NewNfNlMsg() *NfNlMessage { + return &NfNlMessage{ + nls: s, + attrs: NewNLAttrSet(), + } +} + +// Send transmits the message on the associated netlink socket +func (m *NfNlMessage) Send() error { + return m.nls.Send(m) +} + +func (m *NfNlMessage) String() string { + bb := new(bytes.Buffer) + fmt.Fprintf(bb, "[L: %d T: %04x F: %04x S: %d P: %d | ", m.Len, m.Type, m.Flags, m.Seq, m.Pid) + fmt.Fprintf(bb, "F: %d V: %d R: %d |", m.Family, m.Version, m.ResID) + fmt.Fprintf(bb, " %v]", m.attrs) + return bb.String() +} + +// Serialize the message and return the raw bytes +func (m *NfNlMessage) Serialize() []byte { + m.updateLen() + bb := new(bytes.Buffer) + binary.Write(bb, native, &m.NlMsghdr) + bb.WriteByte(m.Family) + bb.WriteByte(m.Version) + binary.Write(bb, binary.BigEndian, m.ResID) + m.attrs.WriteTo(bb) + return bb.Bytes() +} + +// updateLen sets the header Len value to the correct value for the current content +func (m *NfNlMessage) updateLen() { + m.Len = syscall.NLMSG_HDRLEN + NFGEN_HDRLEN + uint32(m.attrs.Size()) +} + +// Round the length of a netlink message up to align it properly. +func nlmAlignOf(msglen int) int { + return (msglen + syscall.NLMSG_ALIGNTO - 1) & ^(syscall.NLMSG_ALIGNTO - 1) +} + +// AddAttributeData creates and appends a new NLAttr from the provided type and payload data +func (m *NfNlMessage) AddAttributeData(atype uint16, data []byte) { + m.AddAttribute(NewAttr(atype, data)) +} + +// AddAttributeFields creates and appends a new NLAttr by serializing the provided fields +// as the payload data for the new attribute +func (m *NfNlMessage) AddAttributeFields(atype uint16, fields ...interface{}) error { + attr, err := NewAttrFromFields(atype, fields...) + if err != nil { + return err + } + m.AddAttribute(attr) + return nil +} + +// AddAttribute appends the provided NLAttr attribute to this message +func (m *NfNlMessage) AddAttribute(attr *NLAttr) { + m.attrs.Add(attr) +} + +// AttrByType returns an attribute of the given type if this message contains one, or nil otherwise. +//func (m *NfNlMessage) AttrByType(atype uint16) *NLAttr { +// return m.attrs.Get(atype) +//} + +func (m *NfNlMessage) Attr(atypes ...uint16) *NLAttr { + return m.attrs.Get(atypes...) +} + +// parse reads serialized bytes from r and parses a netlink message starting at the NfGenHdr and +// stores it in the current message m. +func (m *NfNlMessage) parse(r *bytes.Reader, hdr syscall.NlMsghdr) error { + m.NlMsghdr = hdr + if err := binary.Read(r, binary.BigEndian, &m.NfGenHdr); err != nil { + return err + } + return m.parseAttributes(r) +} + +// parseAttributes reads serialized attributes from r and parses each one into an NLAttr instance which is +// appended to this message. +func (m *NfNlMessage) parseAttributes(r *bytes.Reader) error { + for r.Len() >= syscall.NLA_HDRLEN { + attr, err := ParseAttr(r) + if err != nil { + return err + } + m.AddAttribute(attr) + } + return nil +} diff --git a/vendor/github.com/subgraph/go-nfnetlink/nfnl_attr.go b/vendor/github.com/subgraph/go-nfnetlink/nfnl_attr.go new file mode 100644 index 0000000..836c427 --- /dev/null +++ b/vendor/github.com/subgraph/go-nfnetlink/nfnl_attr.go @@ -0,0 +1,257 @@ +package nfnetlink + +import ( + "bytes" + "encoding/binary" + "encoding/hex" + "errors" + "fmt" + "syscall" + "net" +) + +// NLAttr represents a single netlink attribute. +type NLAttr struct { + Type uint16 + Data []byte + nested *NLAttrSet + Nested bool + Len uint16 +} + +type NLAttrSet struct { + attrList []*NLAttr // list of attributes + attrMap map[uint16]*NLAttr // mapping of attributes by type +} + +func NewNLAttrSet() *NLAttrSet { + return &NLAttrSet{ + attrMap: make(map[uint16]*NLAttr), + } +} + +func (as *NLAttrSet) String() string { + bb := new(bytes.Buffer) + for i,a := range as.attrList { + if i != 0 { + bb.WriteString(" ") + } + bb.WriteString(a.String()) + } + return bb.String() +} + +func (as *NLAttrSet) Add(a *NLAttr) { + as.attrList = append(as.attrList, a) + t := a.Type & ^uint16(syscall.NLA_F_NESTED) + as.attrMap[t] = a +} + +func (as *NLAttrSet) Get(atypes ...uint16) *NLAttr { + if len(atypes) == 0 { + return nil + } + attr := as.attrMap[atypes[0]] + return attr.Get(atypes[1:]...) +} + +func (as *NLAttrSet) WriteTo(bb *bytes.Buffer) { + for _,a := range as.attrList { + a.WriteTo(bb) + } +} + +func (as *NLAttrSet) Size() int { + var sz int + for _,a := range as.attrList { + if !a.Nested { + sz += a.Size() + } else { + sz += 4 + } + } + return sz +} + +// nlaAlignOf returns attrlen aligned to a 4 byte boundary +func nlaAlignOf(attrlen int) int { + return (attrlen + syscall.NLA_ALIGNTO - 1) & ^(syscall.NLA_ALIGNTO - 1) +} + +// NewAttrFromFields creates and returns a new NLAttr instance by serializing the provided +// fields into a slice of bytes which is stored as the Data element of the attribute. +func NewAttrFromFields(atype uint16, fields ...interface{}) (*NLAttr, error) { + b := new(bytes.Buffer) + for _, f := range fields { + if err := binary.Write(b, binary.BigEndian, f); err != nil { + return nil, err + } + } + return NewAttr(atype, b.Bytes()), nil +} + +// NewAttr creates and returns a new NLAttr instance from the provided type and data payload +func NewAttr(atype uint16, data []byte) *NLAttr { + return &NLAttr{ + Type: atype, + Data: data, + Nested: false, + } +} + +func NewAttrNested(atype uint16, alen uint16) *NLAttr { + return &NLAttr{ + Type: atype, + Len: alen, + Data: nil, + Nested: true, + } +} + +func (a *NLAttr) String() string { + if a.Type & syscall.NLA_F_NESTED != 0 { + t := a.Type & ^uint16(syscall.NLA_F_NESTED) + return fmt.Sprintf("(%d %v)", t, a.nested) + } + return fmt.Sprintf("(%d %s)", a.Type, hex.EncodeToString(a.Data)) +} + +// ParseAttr reads a serialized attribute from r and parses it into an NLAttr instance. +func ParseAttr(r *bytes.Reader) (*NLAttr, error) { + attr := &NLAttr{} + if err := attr.parse(r); err != nil { + return nil, err + } + if attr.Type & syscall.NLA_F_NESTED != 0 { + if err := attr.parseNested(); err != nil { + return nil, err + } + } + + return attr, nil +} + +// parse reads a serialized attribute from r and parses it into this NLAttr instance. +func (a *NLAttr) parse(r *bytes.Reader) error { + if r.Len() < syscall.NLA_HDRLEN { + return errors.New("Truncated attribute") + } + var alen uint16 + binary.Read(r, native, &alen) + binary.Read(r, native, &a.Type) + + if alen < syscall.NLA_HDRLEN || int(alen - syscall.NLA_HDRLEN) > r.Len() { + return errors.New("Truncated attribute") + } + alen -= syscall.NLA_HDRLEN + if alen == 0 { + a.Data = nil + return nil + } + + a.Data = make([]byte, alen) + r.Read(a.Data) + padlen := nlaAlignOf(int(alen)) - int(alen) + for i := 0; i < padlen; i++ { + r.ReadByte() + } + return nil +} + +// Size returns the size in bytes of this attribute when serialized +func (a *NLAttr) Size() int { + if a.Nested { + return syscall.NLA_HDRLEN + nlaAlignOf(int(a.Len)) + } + return syscall.NLA_HDRLEN + nlaAlignOf(len(a.Data)) +} + +// serialize the attribute and return the raw bytes +func (a *NLAttr) serialize() []byte { + bs := new(bytes.Buffer) + a.WriteTo(bs) + return bs.Bytes() +} + +// WriteTo serializes the attribute instance into the provided bytes.Buffer +func (a *NLAttr) WriteTo(b *bytes.Buffer) { + + if a.Nested { + binary.Write(b, native, uint16(a.Len)) + binary.Write(b, native, uint16(a.Type)) + return + } + + alen := syscall.NLA_HDRLEN + len(a.Data) + binary.Write(b, native, uint16(alen)) + binary.Write(b, native, a.Type) + b.Write(a.Data) + a.writePadding(b) +} + +// ReadFields parses the attribute data into the provided array of +// fields using binary.Read() to parse each individual field. +func (a *NLAttr) ReadFields(fields ...interface{}) error { + if a == nil { + return nil + } + r := bytes.NewReader(a.Data) + for _, f := range fields { + if err := binary.Read(r, binary.BigEndian, f); err != nil { + return err + } + } + return nil +} + +func (a *NLAttr) Get(atypes ...uint16) *NLAttr { + if len(atypes) == 0 { + return a + } + if a == nil || a.nested == nil { + return nil + } + head := atypes[0] + tail := atypes[1:] + return a.nested.attrMap[head].Get(tail...) +} + +func (a *NLAttr) AsIPv4(ip *net.IP) bool { + if a == nil { + return false + } + var n uint32 + if err := a.ReadFields(&n); err != nil { + return false + } + *ip = net.IPv4(byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + return true +} + +func (a *NLAttr) parseNested() error { + as := NewNLAttrSet() + r := bytes.NewReader(a.Data) + for r.Len() >= syscall.NLA_HDRLEN { + attr, err := ParseAttr(r) + if err != nil { + return err + } + as.Add(attr) + } + a.nested = as + return nil +} + +// writePadding is called while serializing the attribute instance to write +// an appropriate number of '0' bytes to the buffer b so that the length of +// data in the buffer is 4 byte aligned +func (a *NLAttr) writePadding(b *bytes.Buffer) { + padlen := a.Size() - (syscall.NLA_HDRLEN + len(a.Data)) +/* if a.Nested { + padlen = a.Size() - (syscall.NLA_HDRLEN + int(a.Len)) + } */ + + for i := 0; i < padlen; i++ { + b.WriteByte(0) + } +} diff --git a/vendor/github.com/subgraph/go-nfnetlink/nfnl_sock.go b/vendor/github.com/subgraph/go-nfnetlink/nfnl_sock.go new file mode 100644 index 0000000..b817358 --- /dev/null +++ b/vendor/github.com/subgraph/go-nfnetlink/nfnl_sock.go @@ -0,0 +1,376 @@ +package nfnetlink + +import ( + "bytes" + "encoding/hex" + "errors" + "fmt" + "log" + "sync" + "syscall" + "time" +) + +var ErrShortResponse = errors.New("Got short response from netlink") + +const recvBufferSize = 8192 + +var readResponseTimeout = 250 * time.Millisecond + +type SockFlags int + +const ( + FlagDebug SockFlags = 1 << iota + FlagAckRequests + FlagLogWarnings +) + +func (sf SockFlags) isSet(f SockFlags) bool { + return sf & f == f + +} + +func (sf *SockFlags) set(f SockFlags) { + *sf |= f +} + +func (sf *SockFlags) clear(f SockFlags) { + *sf &= ^f +} + +type nlResponseType int + +const ( + responseAck nlResponseType = iota + responseErr + responseMsg +) + +type netlinkResponse struct { + rtype nlResponseType + errno uint32 + msg *NfNlMessage +} + +type NetlinkSocket struct { + fd int // Socket file descriptor + peer *syscall.SockaddrNetlink // Destination address for sendto() + pid uint32 + recvChan chan *NfNlMessage // Channel for transmitting received messages + recvError error // If an error interrupts reception of messages store it here + recvBuffer []byte // Buffer for storing bytes read from socket + seq uint32 // next sequence number to use + subscriptions uint32 + flags SockFlags + responseMap map[uint32]chan *netlinkResponse // maps sequence numbers to channels to deliver response message on + lock sync.Mutex // protects responseMap and recvChan +} + +// NewNetlinkSocket creates a new NetlinkSocket +func NewNetlinkSocket(bus int) (*NetlinkSocket, error) { + fd, err := syscall.Socket(syscall.AF_NETLINK, syscall.SOCK_RAW, bus) + if err != nil { + return nil, err + } + + lsa := &syscall.SockaddrNetlink{Family: syscall.AF_NETLINK} + if err := syscall.Bind(fd, lsa); err != nil { + syscall.Close(fd) + return nil, err + } + sa, err := syscall.Getsockname(fd) + if err != nil { + syscall.Close(fd) + return nil, err + } + ssa, ok := sa.(*syscall.SockaddrNetlink) + if !ok { + syscall.Close(fd) + return nil, fmt.Errorf("Getsockname() returned %T, SockaddrNetlink expected", sa) + } + + s := &NetlinkSocket{ + fd: fd, + flags: FlagAckRequests, + peer: &syscall.SockaddrNetlink{Family: syscall.AF_NETLINK}, + pid: ssa.Pid, + recvBuffer: make([]byte, recvBufferSize), + responseMap: make(map[uint32]chan *netlinkResponse), + } + + go s.runReceiveLoop() + + return s, nil +} + +func (s *NetlinkSocket) Subscribe(subscriptions uint32) error { + s.subscriptions |= subscriptions + lsa := &syscall.SockaddrNetlink{Family: syscall.AF_NETLINK, Pid: s.pid, Groups: s.subscriptions} + return syscall.Bind(s.fd, lsa) +} + +// SetFlag adds the flag f to the set of enabled flags for this socket +func (s *NetlinkSocket) SetFlag(f SockFlags) { + s.flags.set(f) +} + +// ClearFlag removes the flag f from the set of enabled flags for this socket +func (s *NetlinkSocket) ClearFlag(f SockFlags) { + s.flags.clear(f) +} + +// Close the socket +func (s *NetlinkSocket) Close() { + syscall.Close(s.fd) +} + +// nextSeq returns a new sequence number to use when building a message +func (s *NetlinkSocket) nextSeq() uint32 { + s.seq += 1 + if s.seq == 0 { + s.seq = 1 + } + return s.seq +} + +// Send serializes msg and transmits in on the socket. +func (s *NetlinkSocket) Send(msg *NfNlMessage) error { + msg.Seq = s.nextSeq() + if s.flags.isSet(FlagAckRequests) { + return s.sendWithAck(msg) + } + return s.sendMessage(msg) +} + +// sendWithAck is called to send messages when FlagAckRequests is set to handle delivery +// and processing of reponse messages. +func (s *NetlinkSocket) sendWithAck(msg *NfNlMessage) error { + msg.Flags |= syscall.NLM_F_ACK + ch := s.createResponseChannel(msg.Seq) + if err := s.sendMessage(msg); err != nil { + s.removeResponseChannel(msg.Seq, true) + return err + } + return s.readResponse(ch, msg) +} + +// readResponse message from the provided channel and convert it into an error return value or +// return nil if the response was an ack +func (s *NetlinkSocket) readResponse(ch chan *netlinkResponse, msg *NfNlMessage) error { + select { + case resp := <-ch: + switch resp.rtype { + case responseAck: + return nil + case responseErr: + return syscall.Errno(resp.errno) + default: + return fmt.Errorf("unexpected response type: %v to message (seq=%d)", resp.rtype, msg.Seq) + } + case <-time.After(readResponseTimeout): + s.removeResponseChannel(msg.Seq, true) + return fmt.Errorf("timeout waiting for expected response to message (seq=%d)", msg.Seq) + } +} + +func (s *NetlinkSocket) sendMessage(msg *NfNlMessage) error { + bs := msg.Serialize() + if s.flags.isSet(FlagDebug) { + log.Printf("Send: %v '%s'", msg, hex.EncodeToString(bs)) + } + return syscall.Sendto(s.fd, bs, 0, s.peer) +} + +// Receive returns a channel to read incoming event messages from. +func (s *NetlinkSocket) Receive() <-chan *NfNlMessage { + s.lock.Lock() + defer s.lock.Unlock() + if s.recvChan != nil { + return s.recvChan + } + s.recvChan = make(chan *NfNlMessage) + return s.recvChan +} + +func (s *NetlinkSocket) runReceiveLoop() { + if err := s.receive(); err != nil { + s.recvError = err + if s.recvChan != nil { + close(s.recvChan) + } + } +} + +// RecvErr returns an error value if reception of messages ended with +// an error. When the channel returned by Receive() is closed this +// function should be called to determine the error, if any, that occurred. +func (s *NetlinkSocket) RecvErr() error { + return s.recvError +} + +// receive reads from the socket, parses messages, and writes each parsed message +// to the recvChan channel. It will loop reading and processing messages until an +// error occurs and then return the error. +func (s *NetlinkSocket) receive() error { + for { + n, err := s.fillRecvBuffer() + if err != nil { + return err + } +// msgs, err := syscall.ParseNetlinkMessage(s.recvBuffer[:n]) + msgs, err := syscall.ParseNetlinkMessage(s.recvBuffer[:nlmAlignOf(n)]) + if err != nil { + return err + } + for _, msg := range msgs { + if err := s.processMessage(msg); err != nil { + return err + } + } + } +} + +func (s *NetlinkSocket) processMessage(msg syscall.NetlinkMessage) error { + if msg.Header.Type == syscall.NLMSG_ERROR { + s.processErrorMsg(msg) + return nil + } + nlm, err := s.parseMessage(msg) + if err != nil { + return err + } + s.deliverMessage(nlm) + return nil +} + +// deliverMessage sends the message out on the recvChan channel. If the user +// has not called Receive() this channel will not have been created yet and +// the message will be dropped to avoid deadlocking. +func (s *NetlinkSocket) deliverMessage(nlm *NfNlMessage) { + s.lock.Lock() + if s.recvChan == nil { + s.warn("Dropping message because nobody is listening for received messages") + return + } + s.lock.Unlock() + s.recvChan <- nlm +} + +func (s *NetlinkSocket) warn(format string, v ...interface{}) { + if s.flags.isSet(FlagLogWarnings) { + log.Println(fmt.Sprintf(format, v...)) + } +} + +func (s *NetlinkSocket) processErrorMsg(msg syscall.NetlinkMessage) { + if len(msg.Data) < 4 { + s.warn("Netlink error message received with short (%d byte) body", len(msg.Data)) + return + } + errno := readErrno(msg.Data) + rtype := responseAck + if errno != 0 { + rtype = responseErr + } + m := s.parseMessageFromBytes(msg.Data[4:]) + s.sendResponse(msg.Header.Seq, rtype, errno, m) +} + +func (s *NetlinkSocket) parseMessageFromBytes(data []byte) *NfNlMessage { + if len(data) < syscall.NLMSG_HDRLEN + NFGEN_HDRLEN { + return nil + } + msgs, err := syscall.ParseNetlinkMessage(data) + if err != nil { + s.warn("Error parsing netlink message inside error message: %v", err) + return nil + } + if len(msgs) != 1 { + s.warn("Expected 1 message got %d", len(msgs)) + return nil + } + m := s.NewNfNlMsg() + if err := m.parse(bytes.NewReader(msgs[0].Data), msgs[0].Header); err != nil { + s.warn("Error parsing message %v", err) + return nil + } + return m +} + +func (s *NetlinkSocket) sendResponse(seq uint32, rtype nlResponseType, errno uint32, msg *NfNlMessage) { + ch := s.removeResponseChannel(seq, false) + if ch == nil { + s.warn("No response channel found for seq %d", seq) + return + } + ch <- &netlinkResponse{ + rtype: rtype, + errno: errno, + msg: msg, + } + close(ch) +} + +func (s *NetlinkSocket) removeResponseChannel(seq uint32, closeChan bool) chan *netlinkResponse { + s.lock.Lock() + defer s.lock.Unlock() + ch, ok := s.responseMap[seq] + if !ok { + return nil + } + delete(s.responseMap, seq) + if closeChan { + close(ch) + return nil + } + return ch +} + +func (s *NetlinkSocket) createResponseChannel(seq uint32) chan *netlinkResponse { + ch := make(chan *netlinkResponse) + s.lock.Lock() + defer s.lock.Unlock() + if s.responseMap[seq] != nil { + close(s.responseMap[seq]) + } + s.responseMap[seq] = ch + return ch +} + +func readErrno(data []byte) uint32 { + errno := int32(native.Uint32(data)) + return uint32(-errno) +} + +// fillRecvBuffer reads from the socket into recvBuffer and returns the number +// of bytes read. If less than NLMSG_HDRLEN bytes are read, ErrShortResponse +// is returned as an error. +func (s *NetlinkSocket) fillRecvBuffer() (int, error) { + n, from, err := syscall.Recvfrom(s.fd, s.recvBuffer, 0) + if err != nil { + return 0, err + } + sa := from.(*syscall.SockaddrNetlink) + if s.flags.isSet(FlagDebug) { + fmt.Printf("from: %d\n", sa.Groups) + } + if n < syscall.NLMSG_HDRLEN { + return 0, ErrShortResponse + } + return n, nil +} + +// parseMessage converts a syscall.NetlinkMessage into a NfNlMessage by +// parsing the Data byte slice into a NfGenHdr and zero or more attribute +// instances. +func (s *NetlinkSocket) parseMessage(msg syscall.NetlinkMessage) (*NfNlMessage, error) { + m := s.NewNfNlMsg() + r := bytes.NewReader(msg.Data) + if err := m.parse(r, msg.Header); err != nil { + return nil, err + } + if s.flags.isSet(FlagDebug) { + log.Printf("Recv: %v\n", m) + } + return m, nil +} diff --git a/vendor/github.com/subgraph/go-nfnetlink/nfqueue/nfqueue.go b/vendor/github.com/subgraph/go-nfnetlink/nfqueue/nfqueue.go new file mode 100644 index 0000000..f42047a --- /dev/null +++ b/vendor/github.com/subgraph/go-nfnetlink/nfqueue/nfqueue.go @@ -0,0 +1,260 @@ +package nfqueue + +import ( + "fmt" + "errors" + "encoding/binary" + "github.com/google/gopacket" + "github.com/google/gopacket/layers" + "github.com/subgraph/go-nfnetlink" + "syscall" +) + +const ( + NFQNL_CFG_CMD_BIND = 1 + NFQNL_CFG_CMD_UNBIND = 2 + + NFQNL_COPY_META = 1 + NFQNL_COPY_PACKET = 2 + + NFNL_SUBSYS_QUEUE = 3 + + NFQNL_MSG_PACKET = 0 + NFQNL_MSG_VERDICT = 1 + NFQNL_MSG_CONFIG = 2 + + NFQA_CFG_COMMAND = 1 + NFQA_CFG_PARAMS = 2 + + NFQA_PACKET_HDR = 1 + NFQA_VERDICT_HDR = 2 + NFQA_MARK = 3 + NFQA_HWADDR = 9 + NFQA_PAYLOAD = 10 + + NF_DROP = 0 + NF_ACCEPT = 1 +) + +type NFQPacket struct { + id uint32 // packet id + HwProto uint16 // hardware protocol + Packet gopacket.Packet // packet data + q *NFQueue // queue instance + hMark bool // whether mark should be set + mark uint32 // optional mark for verdict + hwAddr []byte // (optional) hardware address +} + +type NFQueue struct { + queue uint16 // queue number + packets chan *NFQPacket // channel for delivering packets + copySize uint32 // configured copy size + pendingErr error // error which occured while receiving packet messages + nls *nfnetlink.NetlinkSocket // netlink socket to netfilter queue subsystem + debug bool // set to true if debugging enabled + hwtrace bool // set to true if hardware addresses are to be captured +} + +const defaultCopySize = 0xFFFF + +// NewNFQueue creates and returns a new NFQueue instance. +func NewNFQueue(queue uint16) *NFQueue { + return &NFQueue{ + queue: queue, + copySize: defaultCopySize, + packets: make(chan *NFQPacket), + } +} + +// EnableDebug sets a flag on the associated NetlinkSocket causing it to dump information +// about each received and transmitted message. +func (q *NFQueue) EnableDebug() { + if q.nls != nil { + q.nls.SetFlag(nfnetlink.FlagDebug) + } + q.debug = true + +} + +func (q *NFQueue) EnableHWTrace() { + q.hwtrace = true +} + +// SetCopySize can be called before Open to set the packet capture size +func (q *NFQueue) SetCopySize(sz uint32) { + q.copySize = sz +} + +// open creates a netlink socket connection to the netfilter subsystem and +// configures the connection to receive packets from netfilter queue +func (q *NFQueue) open() error { + nls, err := nfnetlink.NewNetlinkSocket(syscall.NETLINK_NETFILTER) + if err != nil { + return err + } + q.nls = nls + if q.debug { + q.nls.SetFlag(nfnetlink.FlagDebug) + } + + err = q.sendAll( + q.nfqRequestConfigCmd(NFQNL_CFG_CMD_BIND, q.queue, 0), + q.nfqRequestConfigParams(q.copySize, NFQNL_COPY_PACKET), + ) + if err != nil { + q.Close() + return err + } + return nil +} + +// Close this queue instance +func (q *NFQueue) Close() { + q.sendAll( + q.nfqRequestConfigCmd(NFQNL_CFG_CMD_UNBIND, q.queue, 0), + ) + q.nls.Close() +} + +// sendAll sends a series of messages, returning the first error encountered if any. +func (q *NFQueue) sendAll(msgs ...*nfnetlink.NfNlMessage) error { + for _, m := range msgs { + if err := m.Send(); err != nil { + return err + } + } + return nil +} + +// Open this queue instance. Returns a channel for reading received packets. +func (q *NFQueue) Open() (<-chan *NFQPacket, error) { + if err := q.open(); err != nil { + return nil, err + } + go q.receivePackets() + return q.packets, nil +} + +// receivePackets reads messages from the channel returned by NetlinkSocket.Receive and +// processes them until the channel is closed. If an error occurs, this error is assigned to +// q.pendingError +func (q *NFQueue) receivePackets() { + for m := range q.nls.Receive() { + if err := q.processPacket(m); err != nil { + q.pendingErr = err + close(q.packets) + return + } + } + if q.nls.RecvErr() != nil { + q.pendingErr = q.nls.RecvErr() + } + close(q.packets) +} + +// PendingError returns the error that was encountered while receiving packets if any. +func (q *NFQueue) PendingError() error { + return q.pendingErr +} + +// processPacket handles an incoming NfNlMessage which is assumed to contain a received packet. +func (q *NFQueue) processPacket(m *nfnetlink.NfNlMessage) error { + hdr := m.Attr(NFQA_PACKET_HDR) + if hdr == nil { + return fmt.Errorf("No NFQA_PACKET_HDR\n") + } + p := &NFQPacket{q: q} + p.hMark = false + hdr.ReadFields(&p.id, &p.HwProto) + payload := m.Attr(NFQA_PAYLOAD) + if payload != nil { + p.Packet = gopacket.NewPacket(payload.Data, layers.LayerTypeIPv4, + gopacket.DecodeOptions{Lazy: true, NoCopy: true}) + } + if q.hwtrace { +// fmt.Println("XXX: Hardware tracing on") + hwpkt := m.Attr(NFQA_HWADDR) + if hwpkt != nil { + //fmt.Println("XXX: HW TRACE DATA: %v / %p", hwpkt.Data, p.hwAddr) + p.hwAddr = hwpkt.Data + } + }// else { fmt.Println("XXX: NO HWTRACING ON") } + q.packets <- p + return nil +} + +// nfqRequestConfigCmd creates an NFQNL_MSG_CONFIG message with a NFQA_CFG_COMMAND attribute for +// the provided cmd, queue number, and protocol family. +func (q *NFQueue) nfqRequestConfigCmd(cmd uint8, queue uint16, pf uint16) *nfnetlink.NfNlMessage { + nr := q.nfqNewRequest(NFQNL_MSG_CONFIG, queue) + nr.AddAttributeFields(NFQA_CFG_COMMAND, cmd, uint8(0), pf) + return nr +} + +// nfqRequestConfigParams creates an NFQNL_MSG_CONFIG message with a NFQA_CFG_PARAMS attribute for +// the provided copyRange and copyMode values. +func (q *NFQueue) nfqRequestConfigParams(copyRange uint32, copyMode uint8) *nfnetlink.NfNlMessage { + nr := q.nfqNewRequest(NFQNL_MSG_CONFIG, q.queue) + nr.AddAttributeFields(NFQA_CFG_PARAMS, copyRange, copyMode) + return nr +} + +// nfqRequestVerdictMark creates an NFQNL_MSG_VERDICT with the provided id and verdict values. If hasMark is set +// an optional NFQA_MARK attribute will be included to set a mark on the packet with value mark +func (q *NFQueue) nfqRequestVerdictMark(verdict uint32, id uint32, hasMark bool, mark uint32) *nfnetlink.NfNlMessage { + nr := q.nfqNewRequest(NFQNL_MSG_VERDICT, q.queue) + nr.AddAttributeFields(NFQA_VERDICT_HDR, verdict, id) + if hasMark { + nr.AddAttributeFields(NFQA_MARK, mark) + } + return nr +} + +// nfqNewRequest creates a new message to the queue subsystem with the given type and queue number +func (q *NFQueue) nfqNewRequest(mtype uint8, queue uint16) *nfnetlink.NfNlMessage { + nlm := q.nls.NewNfNlMsg() + nlm.Type = uint16((NFNL_SUBSYS_QUEUE << 8) | uint16(mtype)) + nlm.Flags = syscall.NLM_F_REQUEST + nlm.Family = syscall.AF_UNSPEC + nlm.Version = nfnetlink.NFNETLINK_V0 + nlm.ResID = queue + return nlm +} + +// Drop sets the NF_DROP verdict on this packet +func (p *NFQPacket) Drop() error { + return p.verdict(NF_DROP) +} + +// Accept sets the NF_ACCEPT verdict on this packet +func (p *NFQPacket) Accept() error { + return p.verdict(NF_ACCEPT) +} + +// Set an optional mark to be set with the next verdict +func (p *NFQPacket) SetMark(mark uint32) { + p.mark = mark + p.hMark = true +} + +// verdict sends a NFQNL_MSG_VERDICT message for the packet id with the verdict value v +func (p *NFQPacket) verdict(v uint32) error { + return p.q.nfqRequestVerdictMark(v, p.id, p.hMark, p.mark).Send() +} + +func (p *NFQPacket) GetHWAddr() ([]byte, error) { +//fmt.Printf("XXX: hwaddr address = %p\n", p.hwAddr) + if len(p.hwAddr) != 12 { +//fmt.Println("XXX: length was: ", len(p.hwAddr)) + return nil, errors.New("Hardware data was unexpected length") + } + + addrlen := int(binary.BigEndian.Uint16(p.hwAddr[0:2])) + + if len(p.hwAddr) < 4 + addrlen { + return nil, errors.New("Hardware address overflow") + } + + return p.hwAddr[addrlen:addrlen+4], nil +} diff --git a/vendor/github.com/subgraph/oz/LICENSE b/vendor/github.com/subgraph/oz/LICENSE new file mode 100644 index 0000000..a434339 --- /dev/null +++ b/vendor/github.com/subgraph/oz/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2016, Subgraph +https://subgraph.com +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/subgraph/oz/ipc/handlers.go b/vendor/github.com/subgraph/oz/ipc/handlers.go new file mode 100644 index 0000000..2ed39b8 --- /dev/null +++ b/vendor/github.com/subgraph/oz/ipc/handlers.go @@ -0,0 +1,128 @@ +package ipc + +import ( + "errors" + "fmt" + "github.com/op/go-logging" + "reflect" +) + +type handlerMap map[string]reflect.Value + +var defaultLog = logging.MustGetLogger("ipc") + +type msgDispatcher struct { + log *logging.Logger + msgs chan *Message + hmap handlerMap +} + +func createDispatcher(log *logging.Logger, handlers ...interface{}) (*msgDispatcher, error) { + md := &msgDispatcher{ + log: log, + msgs: make(chan *Message), + hmap: make(map[string]reflect.Value), + } + for _, h := range handlers { + if err := md.hmap.addHandler(h); err != nil { + return nil, err + } + } + go md.runDispatcher() + return md, nil +} + +func (md *msgDispatcher) close() { + close(md.msgs) +} + +func (md *msgDispatcher) dispatch(m *Message) { + md.msgs <- m +} + +func (md *msgDispatcher) logger() *logging.Logger { + if md.log != nil { + return md.log + } + return defaultLog +} + +func (md *msgDispatcher) runDispatcher() { + for m := range md.msgs { + if err := md.hmap.dispatch(m); err != nil { + md.logger().Warning("error dispatching message: %v", err) + } + } +} + +func (handlers handlerMap) dispatch(m *Message) error { + h, ok := handlers[m.Type] + if !ok { + return errors.New("no handler found for message type:" + m.Type) + } + return executeHandler(h, m) +} + +func executeHandler(h reflect.Value, m *Message) error { + var args [2]reflect.Value + args[0] = reflect.ValueOf(m.Body) + args[1] = reflect.ValueOf(m) + + rs := h.Call(args[:]) + if len(rs) != 1 { + return errors.New("handler function did not return expected single result value") + } + if rs[0].IsNil() { + return nil + } + return rs[0].Interface().(error) +} + +func (handlers handlerMap) addHandler(h interface{}) error { + msgType, err := typeCheckHandler(h) + if err != nil { + return err + } + if _, ok := handlers[msgType]; ok { + return fmt.Errorf("duplicate handler registered for message type '%s'", msgType) + } + handlers[msgType] = reflect.ValueOf(h) + return nil +} + +var errType = reflect.TypeOf((*error)(nil)).Elem() +var messageType = reflect.TypeOf((*Message)(nil)) + +func typeCheckHandler(h interface{}) (string, error) { + t := reflect.TypeOf(h) + if t.Kind() != reflect.Func { + return "", fmt.Errorf("handler %v is not a function", t) + } + if t.NumIn() != 2 { + return "", fmt.Errorf("handler %v has incorrect number of input arguments, got %d", t, t.NumIn()) + } + if t.NumOut() != 1 { + return "", fmt.Errorf("handler %v has incorrect number of return values %d", t, t.NumOut()) + } + if t.In(0).Kind() != reflect.Ptr { + return "", errors.New("first argument of handler is not a pointer") + } + in0 := t.In(0).Elem() + if in0.Kind() != reflect.Struct { + return "", fmt.Errorf("first argument of handler is not a pointer to struct") + } + if in1 := t.In(1); !in1.AssignableTo(messageType) { + return "", fmt.Errorf("second argument of handler must have type *Message") + } + if out := t.Out(0); !out.AssignableTo(errType) { + return "", fmt.Errorf("return type of handler must be error") + } + + if in0.NumField() == 0 { + return "", fmt.Errorf("first argument structure has no fields") + } + if len(in0.Field(0).Tag) == 0 { + return "", fmt.Errorf("first argument structure, first field has no tag") + } + return string(in0.Field(0).Tag), nil +} diff --git a/vendor/github.com/subgraph/oz/ipc/ipc.go b/vendor/github.com/subgraph/oz/ipc/ipc.go new file mode 100644 index 0000000..311af60 --- /dev/null +++ b/vendor/github.com/subgraph/oz/ipc/ipc.go @@ -0,0 +1,344 @@ +package ipc + +import ( + "encoding/json" + "errors" + "net" + "syscall" + + "encoding/binary" + "fmt" + "github.com/op/go-logging" + "io" + "reflect" +) + +const maxFdCount = 3 +const maxMessageSz = 128 * 1024 +const bufferSz = 1024 + +type MsgConn struct { + log *logging.Logger + conn *net.UnixConn + buf []byte + oob []byte + disp *msgDispatcher + factory MsgFactory + isClosed bool + idGen <-chan int + respMan *responseManager + onClose func() +} + +type MsgServer struct { + isClosed bool + log *logging.Logger + disp *msgDispatcher + factory MsgFactory + listener *net.UnixListener + done chan bool + idGen <-chan int +} + +func NewServer(address string, factory MsgFactory, log *logging.Logger, handlers ...interface{}) (*MsgServer, error) { + md, err := createDispatcher(log, handlers...) + if err != nil { + return nil, err + } + + listener, err := net.ListenUnix("unix", &net.UnixAddr{address, "unix"}) + if err != nil { + md.close() + return nil, err + } + if err := setPassCred(listener); err != nil { + return nil, errors.New("Failed to set SO_PASSCRED on listening socket: " + err.Error()) + } + done := make(chan bool) + idGen := newIdGen(done) + return &MsgServer{ + log: log, + disp: md, + factory: factory, + listener: listener, + done: done, + idGen: idGen, + }, nil +} + +func (s *MsgServer) Run() error { + for !s.isClosed { + conn, err := s.listener.AcceptUnix() + if err != nil { + if s.isClosed { + return nil + } + return err + } + if err := setPassCred(conn); err != nil { + return errors.New("Failed to set SO_PASSCRED on accepted socket connection:" + err.Error()) + } + mc := &MsgConn{ + log: s.log, + conn: conn, + disp: s.disp, + buf: make([]byte, bufferSz), + oob: createOobBuffer(), + factory: s.factory, + idGen: s.idGen, + respMan: newResponseManager(), + } + go mc.readLoop() + } + return nil +} + +func (s *MsgServer) Close() error { + if s.isClosed { + return nil + } + s.isClosed = true + s.disp.close() + close(s.done) + return s.listener.Close() +} + +func Connect(address string, factory MsgFactory, log *logging.Logger, handlers ...interface{}) (*MsgConn, error) { + md, err := createDispatcher(log, handlers...) + if err != nil { + return nil, err + } + conn, err := net.DialUnix("unix", nil, &net.UnixAddr{address, "unix"}) + if err != nil { + return nil, err + } + done := make(chan bool) + idGen := newIdGen(done) + mc := &MsgConn{ + log: log, + conn: conn, + disp: md, + oob: createOobBuffer(), + factory: factory, + idGen: idGen, + respMan: newResponseManager(), + onClose: func() { + md.close() + close(done) + }, + } + go mc.readLoop() + return mc, nil +} + +func newIdGen(done <-chan bool) <-chan int { + ch := make(chan int) + go idGenLoop(done, ch) + return ch +} + +func idGenLoop(done <-chan bool, out chan<- int) { + current := int(1) + for { + select { + case out <- current: + current += 1 + case <-done: + return + } + } +} + +func (mc *MsgConn) readLoop() { + for { + if mc.processOneMessage() { + return + } + } +} + +func (mc *MsgConn) logger() *logging.Logger { + if mc.log != nil { + return mc.log + } + return defaultLog +} + +func (mc *MsgConn) processOneMessage() bool { + m, err := mc.readMessage() + if err != nil { + if err == io.EOF { + mc.Close() + return true + } + // Fix for bug in 1.5.1 wrapping EOF in OpError + switch t := err.(type) { + case *net.OpError: + if t.Err == io.EOF { + mc.Close() + return true + } + } + if !mc.isClosed { + mc.logger().Warning("error on MsgConn.readMessage(): %v, %s", err) + } + return true + } + if !mc.respMan.handle(m) { + mc.disp.dispatch(m) + } + return false +} + +func (mc *MsgConn) Close() error { + mc.isClosed = true + if mc.onClose != nil { + mc.onClose() + } + return mc.conn.Close() +} + +func createOobBuffer() []byte { + oobSize := syscall.CmsgSpace(syscall.SizeofUcred) + syscall.CmsgSpace(4*maxFdCount) + return make([]byte, oobSize) +} + +func (mc *MsgConn) readMessage() (*Message, error) { + var szbuf [4]byte + n, oobn, _, _, err := mc.conn.ReadMsgUnix(szbuf[:], mc.oob) + if err != nil { + return nil, err + } + sz := binary.BigEndian.Uint32(szbuf[:]) + if sz > maxMessageSz { + return nil, fmt.Errorf("message size of (%d) exceeds maximum message size (%d)", sz, maxMessageSz) + } + if sz > uint32(len(mc.buf)) { + mc.buf = make([]byte, sz) + } + n, _, _, _, err = mc.conn.ReadMsgUnix(mc.buf[:sz], nil) + if err != nil { + return nil, err + } + m, err := mc.parseMessage(mc.buf[:n]) + if err != nil { + return nil, err + } + m.mconn = mc + + if oobn > 0 { + err := m.parseControlData(mc.oob[:oobn]) + if err != nil { + } + } + return m, nil +} + +// AddHandlers registers a list of message handling functions with a MsgConn instance. +// Each handler function must have two arguments and return a single error value. The +// first argument must be pointer to a message structure type. A message structure type +// is a structure that must have a struct tag on the first field: +// +// type FooMsg struct { +// Stuff string "Foo" // <------ struct tag +// // etc... +// } +// +// type SimpleMsg struct { +// dummy int "Simple" // struct has no fields, so add an unexported dummy field just for the tag +// } +// +// The second argument to a handler function must have type *ipc.Message. After a handler function +// has been registered, received messages matching the first argument will be dispatched to the corresponding +// handler function. +// +// func fooHandler(foo *FooMsg, msg *ipc.Message) error { /* ... */ } +// func simpleHandler(simple *SimpleMsg, msg *ipc.Message) error { /* ... */ } +// +// /* register fooHandler() to handle incoming FooMsg and SimpleHandler to handle SimpleMsg */ +// conn.AddHandlers(fooHandler, simpleHandler) +// + +func (mc *MsgConn) AddHandlers(args ...interface{}) error { + for len(args) > 0 { + if err := mc.disp.hmap.addHandler(args[0]); err != nil { + return err + } + args = args[1:] + } + return nil +} + +func (mc *MsgConn) SendMsg(msg interface{}, fds ...int) error { + return mc.sendMessage(msg, <-mc.idGen, fds...) +} + +func (mc *MsgConn) ExchangeMsg(msg interface{}, fds ...int) (ResponseReader, error) { + id := <-mc.idGen + rr := mc.respMan.register(id) + + if err := mc.sendMessage(msg, id, fds...); err != nil { + rr.Done() + return nil, err + } + return rr, nil +} + +func (mc *MsgConn) sendMessage(msg interface{}, msgID int, fds ...int) error { + msgType, err := getMessageType(msg) + if err != nil { + return err + } + base, err := mc.newBaseMessage(msgType, msgID, msg) + if err != nil { + return err + } + raw, err := json.Marshal(base) + if err != nil { + return err + } + buf := make([]byte, len(raw)+4) + binary.BigEndian.PutUint32(buf, uint32(len(raw))) + copy(buf[4:], raw) + return mc.sendRaw(buf, fds...) +} + +func getMessageType(msg interface{}) (string, error) { + t := reflect.TypeOf(msg) + if t.Kind() == reflect.Ptr { + t = t.Elem() + } + if t.Kind() != reflect.Struct { + return "", fmt.Errorf("sendMessage() msg (%T) is not a struct", msg) + } + if t.NumField() == 0 || len(t.Field(0).Tag) == 0 { + return "", fmt.Errorf("sendMessage() msg struct (%T) does not have tag on first field") + } + return string(t.Field(0).Tag), nil +} + +func (mc *MsgConn) newBaseMessage(msgType string, msgID int, body interface{}) (*BaseMsg, error) { + bodyBytes, err := json.Marshal(body) + if err != nil { + return nil, err + } + base := new(BaseMsg) + base.Type = msgType + base.MsgID = msgID + base.Body = bodyBytes + return base, nil +} + +func (mc *MsgConn) sendRaw(data []byte, fds ...int) error { + if len(fds) > 0 { + return mc.sendWithFds(data, fds) + } + _, err := mc.conn.Write(data) + return err +} + +func (mc *MsgConn) sendWithFds(data []byte, fds []int) error { + oob := syscall.UnixRights(fds...) + _, _, err := mc.conn.WriteMsgUnix(data, oob, nil) + return err +} diff --git a/vendor/github.com/subgraph/oz/ipc/message.go b/vendor/github.com/subgraph/oz/ipc/message.go new file mode 100644 index 0000000..f6f5b7e --- /dev/null +++ b/vendor/github.com/subgraph/oz/ipc/message.go @@ -0,0 +1,120 @@ +package ipc + +import ( + "encoding/json" + "errors" + "fmt" + "reflect" + "syscall" +) + +func NewMsgFactory(msgTypes ...interface{}) MsgFactory { + mf := (MsgFactory)(make(map[string]func() interface{})) + for _, mt := range msgTypes { + if err := mf.register(mt); err != nil { + defaultLog.Fatalf("failed adding (%T) in NewMsgFactory: %v", mt, err) + return nil + } + } + return mf +} + +type MsgFactory map[string](func() interface{}) + +func (mf MsgFactory) create(msgType string) (interface{}, error) { + f, ok := mf[msgType] + if !ok { + return nil, fmt.Errorf("cannot create msg type: %s %v", msgType, ok) + } + return f(), nil +} + +func (mf MsgFactory) register(mt interface{}) error { + t := reflect.TypeOf(mt) + if t.Kind() == reflect.Ptr { + t = t.Elem() + } + if t.Kind() != reflect.Struct { + return errors.New("not a structure") + } + if t.NumField() == 0 || len(t.Field(0).Tag) == 0 { + return errors.New("no tag on first field of structure") + } + tag := string(t.Field(0).Tag) + + mf[tag] = func() interface{} { + v := reflect.New(t) + return v.Interface() + } + return nil +} + +type Message struct { + Type string + MsgID int + Body interface{} + Ucred *syscall.Ucred + Fds []int + mconn *MsgConn +} + +type BaseMsg struct { + Type string + MsgID int + IsResponse bool + Body json.RawMessage +} + +func (mc *MsgConn) parseMessage(data []byte) (*Message, error) { + var base BaseMsg + if err := json.Unmarshal(data, &base); err != nil { + return nil, err + } + body, err := mc.factory.create(base.Type) + if err != nil { + return nil, err + } + if err := json.Unmarshal(base.Body, body); err != nil { + return nil, err + } + m := new(Message) + m.Type = base.Type + m.MsgID = base.MsgID + m.Body = body + return m, nil +} + +func (m *Message) Free() { + for _, fd := range m.Fds { + syscall.Close(fd) + } + m.Fds = nil +} + +func (m *Message) parseControlData(data []byte) error { + cmsgs, err := syscall.ParseSocketControlMessage(data) + if err != nil { + return err + } + for _, cmsg := range cmsgs { + switch cmsg.Header.Type { + case syscall.SCM_CREDENTIALS: + cred, err := syscall.ParseUnixCredentials(&cmsg) + if err != nil { + return err + } + m.Ucred = cred + case syscall.SCM_RIGHTS: + fds, err := syscall.ParseUnixRights(&cmsg) + if err != nil { + return err + } + m.Fds = fds + } + } + return nil +} + +func (m *Message) Respond(msg interface{}, fds ...int) error { + return m.mconn.sendMessage(msg, m.MsgID, fds...) +} diff --git a/vendor/github.com/subgraph/oz/ipc/response.go b/vendor/github.com/subgraph/oz/ipc/response.go new file mode 100644 index 0000000..31e69fa --- /dev/null +++ b/vendor/github.com/subgraph/oz/ipc/response.go @@ -0,0 +1,78 @@ +package ipc + +import ( + "sync" + "time" +) + +type ResponseReader interface { + Chan() <-chan *Message + Done() +} + +type responseWaiter struct { + rm *responseManager + id int + timeout time.Time + ch chan *Message +} + +func (rw *responseWaiter) Chan() <-chan *Message { + return rw.ch +} + +func (rw *responseWaiter) Done() { + rw.rm.lock.Lock() + defer rw.rm.lock.Unlock() + close(rw.ch) + delete(rw.rm.responseMap, rw.id) +} + +type responseManager struct { + lock sync.Locker + responseMap map[int]*responseWaiter +} + +func newResponseManager() *responseManager { + rm := new(responseManager) + rm.lock = new(sync.Mutex) + rm.responseMap = make(map[int]*responseWaiter) + return rm +} + +func (rm *responseManager) register(id int) ResponseReader { + ch := make(chan *Message) + rm.lock.Lock() + defer rm.lock.Unlock() + rm.removeById(id, true) + rw := &responseWaiter{ + rm: rm, + id: id, + ch: ch, + } + rm.responseMap[id] = rw + return rw +} + +func (rm *responseManager) handle(m *Message) bool { + rm.lock.Lock() + defer rm.lock.Unlock() + rw := rm.responseMap[m.MsgID] + if rw == nil { + return false + } + rw.ch <- m + return true +} + +func (rm *responseManager) removeById(id int, klose bool) *responseWaiter { + rw := rm.responseMap[id] + if rw == nil { + return nil + } + delete(rm.responseMap, id) + if klose { + close(rw.ch) + } + return rw +} diff --git a/vendor/github.com/subgraph/oz/ipc/util.go b/vendor/github.com/subgraph/oz/ipc/util.go new file mode 100644 index 0000000..4873649 --- /dev/null +++ b/vendor/github.com/subgraph/oz/ipc/util.go @@ -0,0 +1,25 @@ +package ipc + +import ( + "reflect" + "syscall" +) + +func setPassCred(c interface{}) error { + fd := reflectFD(c) + return syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_PASSCRED, 1) +} + +func reflectFD(c interface{}) int { + sysfd := extractField(c, "fd", "sysfd") + return int(sysfd.Int()) +} + +func extractField(ob interface{}, fieldNames ...string) reflect.Value { + v := reflect.Indirect(reflect.ValueOf(ob)) + for _, fn := range fieldNames { + field := v.FieldByName(fn) + v = reflect.Indirect(field) + } + return v +} diff --git a/vendor/github.com/subgraph/ozipc/handlers.go b/vendor/github.com/subgraph/ozipc/handlers.go new file mode 100644 index 0000000..2ed39b8 --- /dev/null +++ b/vendor/github.com/subgraph/ozipc/handlers.go @@ -0,0 +1,128 @@ +package ipc + +import ( + "errors" + "fmt" + "github.com/op/go-logging" + "reflect" +) + +type handlerMap map[string]reflect.Value + +var defaultLog = logging.MustGetLogger("ipc") + +type msgDispatcher struct { + log *logging.Logger + msgs chan *Message + hmap handlerMap +} + +func createDispatcher(log *logging.Logger, handlers ...interface{}) (*msgDispatcher, error) { + md := &msgDispatcher{ + log: log, + msgs: make(chan *Message), + hmap: make(map[string]reflect.Value), + } + for _, h := range handlers { + if err := md.hmap.addHandler(h); err != nil { + return nil, err + } + } + go md.runDispatcher() + return md, nil +} + +func (md *msgDispatcher) close() { + close(md.msgs) +} + +func (md *msgDispatcher) dispatch(m *Message) { + md.msgs <- m +} + +func (md *msgDispatcher) logger() *logging.Logger { + if md.log != nil { + return md.log + } + return defaultLog +} + +func (md *msgDispatcher) runDispatcher() { + for m := range md.msgs { + if err := md.hmap.dispatch(m); err != nil { + md.logger().Warning("error dispatching message: %v", err) + } + } +} + +func (handlers handlerMap) dispatch(m *Message) error { + h, ok := handlers[m.Type] + if !ok { + return errors.New("no handler found for message type:" + m.Type) + } + return executeHandler(h, m) +} + +func executeHandler(h reflect.Value, m *Message) error { + var args [2]reflect.Value + args[0] = reflect.ValueOf(m.Body) + args[1] = reflect.ValueOf(m) + + rs := h.Call(args[:]) + if len(rs) != 1 { + return errors.New("handler function did not return expected single result value") + } + if rs[0].IsNil() { + return nil + } + return rs[0].Interface().(error) +} + +func (handlers handlerMap) addHandler(h interface{}) error { + msgType, err := typeCheckHandler(h) + if err != nil { + return err + } + if _, ok := handlers[msgType]; ok { + return fmt.Errorf("duplicate handler registered for message type '%s'", msgType) + } + handlers[msgType] = reflect.ValueOf(h) + return nil +} + +var errType = reflect.TypeOf((*error)(nil)).Elem() +var messageType = reflect.TypeOf((*Message)(nil)) + +func typeCheckHandler(h interface{}) (string, error) { + t := reflect.TypeOf(h) + if t.Kind() != reflect.Func { + return "", fmt.Errorf("handler %v is not a function", t) + } + if t.NumIn() != 2 { + return "", fmt.Errorf("handler %v has incorrect number of input arguments, got %d", t, t.NumIn()) + } + if t.NumOut() != 1 { + return "", fmt.Errorf("handler %v has incorrect number of return values %d", t, t.NumOut()) + } + if t.In(0).Kind() != reflect.Ptr { + return "", errors.New("first argument of handler is not a pointer") + } + in0 := t.In(0).Elem() + if in0.Kind() != reflect.Struct { + return "", fmt.Errorf("first argument of handler is not a pointer to struct") + } + if in1 := t.In(1); !in1.AssignableTo(messageType) { + return "", fmt.Errorf("second argument of handler must have type *Message") + } + if out := t.Out(0); !out.AssignableTo(errType) { + return "", fmt.Errorf("return type of handler must be error") + } + + if in0.NumField() == 0 { + return "", fmt.Errorf("first argument structure has no fields") + } + if len(in0.Field(0).Tag) == 0 { + return "", fmt.Errorf("first argument structure, first field has no tag") + } + return string(in0.Field(0).Tag), nil +} diff --git a/vendor/github.com/subgraph/ozipc/ipc.go b/vendor/github.com/subgraph/ozipc/ipc.go new file mode 100644 index 0000000..311af60 --- /dev/null +++ b/vendor/github.com/subgraph/ozipc/ipc.go @@ -0,0 +1,344 @@ +package ipc + +import ( + "encoding/json" + "errors" + "net" + "syscall" + + "encoding/binary" + "fmt" + "github.com/op/go-logging" + "io" + "reflect" +) + +const maxFdCount = 3 +const maxMessageSz = 128 * 1024 +const bufferSz = 1024 + +type MsgConn struct { + log *logging.Logger + conn *net.UnixConn + buf []byte + oob []byte + disp *msgDispatcher + factory MsgFactory + isClosed bool + idGen <-chan int + respMan *responseManager + onClose func() +} + +type MsgServer struct { + isClosed bool + log *logging.Logger + disp *msgDispatcher + factory MsgFactory + listener *net.UnixListener + done chan bool + idGen <-chan int +} + +func NewServer(address string, factory MsgFactory, log *logging.Logger, handlers ...interface{}) (*MsgServer, error) { + md, err := createDispatcher(log, handlers...) + if err != nil { + return nil, err + } + + listener, err := net.ListenUnix("unix", &net.UnixAddr{address, "unix"}) + if err != nil { + md.close() + return nil, err + } + if err := setPassCred(listener); err != nil { + return nil, errors.New("Failed to set SO_PASSCRED on listening socket: " + err.Error()) + } + done := make(chan bool) + idGen := newIdGen(done) + return &MsgServer{ + log: log, + disp: md, + factory: factory, + listener: listener, + done: done, + idGen: idGen, + }, nil +} + +func (s *MsgServer) Run() error { + for !s.isClosed { + conn, err := s.listener.AcceptUnix() + if err != nil { + if s.isClosed { + return nil + } + return err + } + if err := setPassCred(conn); err != nil { + return errors.New("Failed to set SO_PASSCRED on accepted socket connection:" + err.Error()) + } + mc := &MsgConn{ + log: s.log, + conn: conn, + disp: s.disp, + buf: make([]byte, bufferSz), + oob: createOobBuffer(), + factory: s.factory, + idGen: s.idGen, + respMan: newResponseManager(), + } + go mc.readLoop() + } + return nil +} + +func (s *MsgServer) Close() error { + if s.isClosed { + return nil + } + s.isClosed = true + s.disp.close() + close(s.done) + return s.listener.Close() +} + +func Connect(address string, factory MsgFactory, log *logging.Logger, handlers ...interface{}) (*MsgConn, error) { + md, err := createDispatcher(log, handlers...) + if err != nil { + return nil, err + } + conn, err := net.DialUnix("unix", nil, &net.UnixAddr{address, "unix"}) + if err != nil { + return nil, err + } + done := make(chan bool) + idGen := newIdGen(done) + mc := &MsgConn{ + log: log, + conn: conn, + disp: md, + oob: createOobBuffer(), + factory: factory, + idGen: idGen, + respMan: newResponseManager(), + onClose: func() { + md.close() + close(done) + }, + } + go mc.readLoop() + return mc, nil +} + +func newIdGen(done <-chan bool) <-chan int { + ch := make(chan int) + go idGenLoop(done, ch) + return ch +} + +func idGenLoop(done <-chan bool, out chan<- int) { + current := int(1) + for { + select { + case out <- current: + current += 1 + case <-done: + return + } + } +} + +func (mc *MsgConn) readLoop() { + for { + if mc.processOneMessage() { + return + } + } +} + +func (mc *MsgConn) logger() *logging.Logger { + if mc.log != nil { + return mc.log + } + return defaultLog +} + +func (mc *MsgConn) processOneMessage() bool { + m, err := mc.readMessage() + if err != nil { + if err == io.EOF { + mc.Close() + return true + } + // Fix for bug in 1.5.1 wrapping EOF in OpError + switch t := err.(type) { + case *net.OpError: + if t.Err == io.EOF { + mc.Close() + return true + } + } + if !mc.isClosed { + mc.logger().Warning("error on MsgConn.readMessage(): %v, %s", err) + } + return true + } + if !mc.respMan.handle(m) { + mc.disp.dispatch(m) + } + return false +} + +func (mc *MsgConn) Close() error { + mc.isClosed = true + if mc.onClose != nil { + mc.onClose() + } + return mc.conn.Close() +} + +func createOobBuffer() []byte { + oobSize := syscall.CmsgSpace(syscall.SizeofUcred) + syscall.CmsgSpace(4*maxFdCount) + return make([]byte, oobSize) +} + +func (mc *MsgConn) readMessage() (*Message, error) { + var szbuf [4]byte + n, oobn, _, _, err := mc.conn.ReadMsgUnix(szbuf[:], mc.oob) + if err != nil { + return nil, err + } + sz := binary.BigEndian.Uint32(szbuf[:]) + if sz > maxMessageSz { + return nil, fmt.Errorf("message size of (%d) exceeds maximum message size (%d)", sz, maxMessageSz) + } + if sz > uint32(len(mc.buf)) { + mc.buf = make([]byte, sz) + } + n, _, _, _, err = mc.conn.ReadMsgUnix(mc.buf[:sz], nil) + if err != nil { + return nil, err + } + m, err := mc.parseMessage(mc.buf[:n]) + if err != nil { + return nil, err + } + m.mconn = mc + + if oobn > 0 { + err := m.parseControlData(mc.oob[:oobn]) + if err != nil { + } + } + return m, nil +} + +// AddHandlers registers a list of message handling functions with a MsgConn instance. +// Each handler function must have two arguments and return a single error value. The +// first argument must be pointer to a message structure type. A message structure type +// is a structure that must have a struct tag on the first field: +// +// type FooMsg struct { +// Stuff string "Foo" // <------ struct tag +// // etc... +// } +// +// type SimpleMsg struct { +// dummy int "Simple" // struct has no fields, so add an unexported dummy field just for the tag +// } +// +// The second argument to a handler function must have type *ipc.Message. After a handler function +// has been registered, received messages matching the first argument will be dispatched to the corresponding +// handler function. +// +// func fooHandler(foo *FooMsg, msg *ipc.Message) error { /* ... */ } +// func simpleHandler(simple *SimpleMsg, msg *ipc.Message) error { /* ... */ } +// +// /* register fooHandler() to handle incoming FooMsg and SimpleHandler to handle SimpleMsg */ +// conn.AddHandlers(fooHandler, simpleHandler) +// + +func (mc *MsgConn) AddHandlers(args ...interface{}) error { + for len(args) > 0 { + if err := mc.disp.hmap.addHandler(args[0]); err != nil { + return err + } + args = args[1:] + } + return nil +} + +func (mc *MsgConn) SendMsg(msg interface{}, fds ...int) error { + return mc.sendMessage(msg, <-mc.idGen, fds...) +} + +func (mc *MsgConn) ExchangeMsg(msg interface{}, fds ...int) (ResponseReader, error) { + id := <-mc.idGen + rr := mc.respMan.register(id) + + if err := mc.sendMessage(msg, id, fds...); err != nil { + rr.Done() + return nil, err + } + return rr, nil +} + +func (mc *MsgConn) sendMessage(msg interface{}, msgID int, fds ...int) error { + msgType, err := getMessageType(msg) + if err != nil { + return err + } + base, err := mc.newBaseMessage(msgType, msgID, msg) + if err != nil { + return err + } + raw, err := json.Marshal(base) + if err != nil { + return err + } + buf := make([]byte, len(raw)+4) + binary.BigEndian.PutUint32(buf, uint32(len(raw))) + copy(buf[4:], raw) + return mc.sendRaw(buf, fds...) +} + +func getMessageType(msg interface{}) (string, error) { + t := reflect.TypeOf(msg) + if t.Kind() == reflect.Ptr { + t = t.Elem() + } + if t.Kind() != reflect.Struct { + return "", fmt.Errorf("sendMessage() msg (%T) is not a struct", msg) + } + if t.NumField() == 0 || len(t.Field(0).Tag) == 0 { + return "", fmt.Errorf("sendMessage() msg struct (%T) does not have tag on first field") + } + return string(t.Field(0).Tag), nil +} + +func (mc *MsgConn) newBaseMessage(msgType string, msgID int, body interface{}) (*BaseMsg, error) { + bodyBytes, err := json.Marshal(body) + if err != nil { + return nil, err + } + base := new(BaseMsg) + base.Type = msgType + base.MsgID = msgID + base.Body = bodyBytes + return base, nil +} + +func (mc *MsgConn) sendRaw(data []byte, fds ...int) error { + if len(fds) > 0 { + return mc.sendWithFds(data, fds) + } + _, err := mc.conn.Write(data) + return err +} + +func (mc *MsgConn) sendWithFds(data []byte, fds []int) error { + oob := syscall.UnixRights(fds...) + _, _, err := mc.conn.WriteMsgUnix(data, oob, nil) + return err +} diff --git a/vendor/github.com/subgraph/ozipc/message.go b/vendor/github.com/subgraph/ozipc/message.go new file mode 100644 index 0000000..f6f5b7e --- /dev/null +++ b/vendor/github.com/subgraph/ozipc/message.go @@ -0,0 +1,120 @@ +package ipc + +import ( + "encoding/json" + "errors" + "fmt" + "reflect" + "syscall" +) + +func NewMsgFactory(msgTypes ...interface{}) MsgFactory { + mf := (MsgFactory)(make(map[string]func() interface{})) + for _, mt := range msgTypes { + if err := mf.register(mt); err != nil { + defaultLog.Fatalf("failed adding (%T) in NewMsgFactory: %v", mt, err) + return nil + } + } + return mf +} + +type MsgFactory map[string](func() interface{}) + +func (mf MsgFactory) create(msgType string) (interface{}, error) { + f, ok := mf[msgType] + if !ok { + return nil, fmt.Errorf("cannot create msg type: %s %v", msgType, ok) + } + return f(), nil +} + +func (mf MsgFactory) register(mt interface{}) error { + t := reflect.TypeOf(mt) + if t.Kind() == reflect.Ptr { + t = t.Elem() + } + if t.Kind() != reflect.Struct { + return errors.New("not a structure") + } + if t.NumField() == 0 || len(t.Field(0).Tag) == 0 { + return errors.New("no tag on first field of structure") + } + tag := string(t.Field(0).Tag) + + mf[tag] = func() interface{} { + v := reflect.New(t) + return v.Interface() + } + return nil +} + +type Message struct { + Type string + MsgID int + Body interface{} + Ucred *syscall.Ucred + Fds []int + mconn *MsgConn +} + +type BaseMsg struct { + Type string + MsgID int + IsResponse bool + Body json.RawMessage +} + +func (mc *MsgConn) parseMessage(data []byte) (*Message, error) { + var base BaseMsg + if err := json.Unmarshal(data, &base); err != nil { + return nil, err + } + body, err := mc.factory.create(base.Type) + if err != nil { + return nil, err + } + if err := json.Unmarshal(base.Body, body); err != nil { + return nil, err + } + m := new(Message) + m.Type = base.Type + m.MsgID = base.MsgID + m.Body = body + return m, nil +} + +func (m *Message) Free() { + for _, fd := range m.Fds { + syscall.Close(fd) + } + m.Fds = nil +} + +func (m *Message) parseControlData(data []byte) error { + cmsgs, err := syscall.ParseSocketControlMessage(data) + if err != nil { + return err + } + for _, cmsg := range cmsgs { + switch cmsg.Header.Type { + case syscall.SCM_CREDENTIALS: + cred, err := syscall.ParseUnixCredentials(&cmsg) + if err != nil { + return err + } + m.Ucred = cred + case syscall.SCM_RIGHTS: + fds, err := syscall.ParseUnixRights(&cmsg) + if err != nil { + return err + } + m.Fds = fds + } + } + return nil +} + +func (m *Message) Respond(msg interface{}, fds ...int) error { + return m.mconn.sendMessage(msg, m.MsgID, fds...) +} diff --git a/vendor/github.com/subgraph/ozipc/response.go b/vendor/github.com/subgraph/ozipc/response.go new file mode 100644 index 0000000..31e69fa --- /dev/null +++ b/vendor/github.com/subgraph/ozipc/response.go @@ -0,0 +1,78 @@ +package ipc + +import ( + "sync" + "time" +) + +type ResponseReader interface { + Chan() <-chan *Message + Done() +} + +type responseWaiter struct { + rm *responseManager + id int + timeout time.Time + ch chan *Message +} + +func (rw *responseWaiter) Chan() <-chan *Message { + return rw.ch +} + +func (rw *responseWaiter) Done() { + rw.rm.lock.Lock() + defer rw.rm.lock.Unlock() + close(rw.ch) + delete(rw.rm.responseMap, rw.id) +} + +type responseManager struct { + lock sync.Locker + responseMap map[int]*responseWaiter +} + +func newResponseManager() *responseManager { + rm := new(responseManager) + rm.lock = new(sync.Mutex) + rm.responseMap = make(map[int]*responseWaiter) + return rm +} + +func (rm *responseManager) register(id int) ResponseReader { + ch := make(chan *Message) + rm.lock.Lock() + defer rm.lock.Unlock() + rm.removeById(id, true) + rw := &responseWaiter{ + rm: rm, + id: id, + ch: ch, + } + rm.responseMap[id] = rw + return rw +} + +func (rm *responseManager) handle(m *Message) bool { + rm.lock.Lock() + defer rm.lock.Unlock() + rw := rm.responseMap[m.MsgID] + if rw == nil { + return false + } + rw.ch <- m + return true +} + +func (rm *responseManager) removeById(id int, klose bool) *responseWaiter { + rw := rm.responseMap[id] + if rw == nil { + return nil + } + delete(rm.responseMap, id) + if klose { + close(rw.ch) + } + return rw +} diff --git a/vendor/github.com/subgraph/ozipc/util.go b/vendor/github.com/subgraph/ozipc/util.go new file mode 100644 index 0000000..4873649 --- /dev/null +++ b/vendor/github.com/subgraph/ozipc/util.go @@ -0,0 +1,25 @@ +package ipc + +import ( + "reflect" + "syscall" +) + +func setPassCred(c interface{}) error { + fd := reflectFD(c) + return syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_PASSCRED, 1) +} + +func reflectFD(c interface{}) int { + sysfd := extractField(c, "fd", "sysfd") + return int(sysfd.Int()) +} + +func extractField(ob interface{}, fieldNames ...string) reflect.Value { + v := reflect.Indirect(reflect.ValueOf(ob)) + for _, fn := range fieldNames { + field := v.FieldByName(fn) + v = reflect.Indirect(field) + } + return v +} diff --git a/vendor/golang.org/x/net/proxy/direct.go b/vendor/golang.org/x/net/proxy/direct.go deleted file mode 100644 index 4c5ad88..0000000 --- a/vendor/golang.org/x/net/proxy/direct.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "net" -) - -type direct struct{} - -// Direct is a direct proxy: one that makes network connections directly. -var Direct = direct{} - -func (direct) Dial(network, addr string) (net.Conn, error) { - return net.Dial(network, addr) -} diff --git a/vendor/golang.org/x/net/proxy/per_host.go b/vendor/golang.org/x/net/proxy/per_host.go deleted file mode 100644 index f540b19..0000000 --- a/vendor/golang.org/x/net/proxy/per_host.go +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "net" - "strings" -) - -// A PerHost directs connections to a default Dialer unless the hostname -// requested matches one of a number of exceptions. -type PerHost struct { - def, bypass Dialer - - bypassNetworks []*net.IPNet - bypassIPs []net.IP - bypassZones []string - bypassHosts []string -} - -// NewPerHost returns a PerHost Dialer that directs connections to either -// defaultDialer or bypass, depending on whether the connection matches one of -// the configured rules. -func NewPerHost(defaultDialer, bypass Dialer) *PerHost { - return &PerHost{ - def: defaultDialer, - bypass: bypass, - } -} - -// Dial connects to the address addr on the given network through either -// defaultDialer or bypass. -func (p *PerHost) Dial(network, addr string) (c net.Conn, err error) { - host, _, err := net.SplitHostPort(addr) - if err != nil { - return nil, err - } - - return p.dialerForRequest(host).Dial(network, addr) -} - -func (p *PerHost) dialerForRequest(host string) Dialer { - if ip := net.ParseIP(host); ip != nil { - for _, net := range p.bypassNetworks { - if net.Contains(ip) { - return p.bypass - } - } - for _, bypassIP := range p.bypassIPs { - if bypassIP.Equal(ip) { - return p.bypass - } - } - return p.def - } - - for _, zone := range p.bypassZones { - if strings.HasSuffix(host, zone) { - return p.bypass - } - if host == zone[1:] { - // For a zone "example.com", we match "example.com" - // too. - return p.bypass - } - } - for _, bypassHost := range p.bypassHosts { - if bypassHost == host { - return p.bypass - } - } - return p.def -} - -// AddFromString parses a string that contains comma-separated values -// specifying hosts that should use the bypass proxy. Each value is either an -// IP address, a CIDR range, a zone (*.example.com) or a hostname -// (localhost). A best effort is made to parse the string and errors are -// ignored. -func (p *PerHost) AddFromString(s string) { - hosts := strings.Split(s, ",") - for _, host := range hosts { - host = strings.TrimSpace(host) - if len(host) == 0 { - continue - } - if strings.Contains(host, "/") { - // We assume that it's a CIDR address like 127.0.0.0/8 - if _, net, err := net.ParseCIDR(host); err == nil { - p.AddNetwork(net) - } - continue - } - if ip := net.ParseIP(host); ip != nil { - p.AddIP(ip) - continue - } - if strings.HasPrefix(host, "*.") { - p.AddZone(host[1:]) - continue - } - p.AddHost(host) - } -} - -// AddIP specifies an IP address that will use the bypass proxy. Note that -// this will only take effect if a literal IP address is dialed. A connection -// to a named host will never match an IP. -func (p *PerHost) AddIP(ip net.IP) { - p.bypassIPs = append(p.bypassIPs, ip) -} - -// AddNetwork specifies an IP range that will use the bypass proxy. Note that -// this will only take effect if a literal IP address is dialed. A connection -// to a named host will never match. -func (p *PerHost) AddNetwork(net *net.IPNet) { - p.bypassNetworks = append(p.bypassNetworks, net) -} - -// AddZone specifies a DNS suffix that will use the bypass proxy. A zone of -// "example.com" matches "example.com" and all of its subdomains. -func (p *PerHost) AddZone(zone string) { - if strings.HasSuffix(zone, ".") { - zone = zone[:len(zone)-1] - } - if !strings.HasPrefix(zone, ".") { - zone = "." + zone - } - p.bypassZones = append(p.bypassZones, zone) -} - -// AddHost specifies a hostname that will use the bypass proxy. -func (p *PerHost) AddHost(host string) { - if strings.HasSuffix(host, ".") { - host = host[:len(host)-1] - } - p.bypassHosts = append(p.bypassHosts, host) -} diff --git a/vendor/golang.org/x/net/proxy/proxy.go b/vendor/golang.org/x/net/proxy/proxy.go deleted file mode 100644 index 8ccb0c5..0000000 --- a/vendor/golang.org/x/net/proxy/proxy.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package proxy provides support for a variety of protocols to proxy network -// data. -package proxy - -import ( - "errors" - "net" - "net/url" - "os" -) - -// A Dialer is a means to establish a connection. -type Dialer interface { - // Dial connects to the given address via the proxy. - Dial(network, addr string) (c net.Conn, err error) -} - -// Auth contains authentication parameters that specific Dialers may require. -type Auth struct { - User, Password string -} - -// FromEnvironment returns the dialer specified by the proxy related variables in -// the environment. -func FromEnvironment() Dialer { - allProxy := os.Getenv("all_proxy") - if len(allProxy) == 0 { - return Direct - } - - proxyURL, err := url.Parse(allProxy) - if err != nil { - return Direct - } - proxy, err := FromURL(proxyURL, Direct) - if err != nil { - return Direct - } - - noProxy := os.Getenv("no_proxy") - if len(noProxy) == 0 { - return proxy - } - - perHost := NewPerHost(proxy, Direct) - perHost.AddFromString(noProxy) - return perHost -} - -// proxySchemes is a map from URL schemes to a function that creates a Dialer -// from a URL with such a scheme. -var proxySchemes map[string]func(*url.URL, Dialer) (Dialer, error) - -// RegisterDialerType takes a URL scheme and a function to generate Dialers from -// a URL with that scheme and a forwarding Dialer. Registered schemes are used -// by FromURL. -func RegisterDialerType(scheme string, f func(*url.URL, Dialer) (Dialer, error)) { - if proxySchemes == nil { - proxySchemes = make(map[string]func(*url.URL, Dialer) (Dialer, error)) - } - proxySchemes[scheme] = f -} - -// FromURL returns a Dialer given a URL specification and an underlying -// Dialer for it to make network requests. -func FromURL(u *url.URL, forward Dialer) (Dialer, error) { - var auth *Auth - if u.User != nil { - auth = new(Auth) - auth.User = u.User.Username() - if p, ok := u.User.Password(); ok { - auth.Password = p - } - } - - switch u.Scheme { - case "socks5": - return SOCKS5("tcp", u.Host, auth, forward) - } - - // If the scheme doesn't match any of the built-in schemes, see if it - // was registered by another package. - if proxySchemes != nil { - if f, ok := proxySchemes[u.Scheme]; ok { - return f(u, forward) - } - } - - return nil, errors.New("proxy: unknown scheme: " + u.Scheme) -} diff --git a/vendor/golang.org/x/net/proxy/socks5.go b/vendor/golang.org/x/net/proxy/socks5.go deleted file mode 100644 index 9b96282..0000000 --- a/vendor/golang.org/x/net/proxy/socks5.go +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "errors" - "io" - "net" - "strconv" -) - -// SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given address -// with an optional username and password. See RFC 1928. -func SOCKS5(network, addr string, auth *Auth, forward Dialer) (Dialer, error) { - s := &socks5{ - network: network, - addr: addr, - forward: forward, - } - if auth != nil { - s.user = auth.User - s.password = auth.Password - } - - return s, nil -} - -type socks5 struct { - user, password string - network, addr string - forward Dialer -} - -const socks5Version = 5 - -const ( - socks5AuthNone = 0 - socks5AuthPassword = 2 -) - -const socks5Connect = 1 - -const ( - socks5IP4 = 1 - socks5Domain = 3 - socks5IP6 = 4 -) - -var socks5Errors = []string{ - "", - "general failure", - "connection forbidden", - "network unreachable", - "host unreachable", - "connection refused", - "TTL expired", - "command not supported", - "address type not supported", -} - -// Dial connects to the address addr on the network net via the SOCKS5 proxy. -func (s *socks5) Dial(network, addr string) (net.Conn, error) { - switch network { - case "tcp", "tcp6", "tcp4": - default: - return nil, errors.New("proxy: no support for SOCKS5 proxy connections of type " + network) - } - - conn, err := s.forward.Dial(s.network, s.addr) - if err != nil { - return nil, err - } - closeConn := &conn - defer func() { - if closeConn != nil { - (*closeConn).Close() - } - }() - - host, portStr, err := net.SplitHostPort(addr) - if err != nil { - return nil, err - } - - port, err := strconv.Atoi(portStr) - if err != nil { - return nil, errors.New("proxy: failed to parse port number: " + portStr) - } - if port < 1 || port > 0xffff { - return nil, errors.New("proxy: port number out of range: " + portStr) - } - - // the size here is just an estimate - buf := make([]byte, 0, 6+len(host)) - - buf = append(buf, socks5Version) - if len(s.user) > 0 && len(s.user) < 256 && len(s.password) < 256 { - buf = append(buf, 2 /* num auth methods */, socks5AuthNone, socks5AuthPassword) - } else { - buf = append(buf, 1 /* num auth methods */, socks5AuthNone) - } - - if _, err := conn.Write(buf); err != nil { - return nil, errors.New("proxy: failed to write greeting to SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if _, err := io.ReadFull(conn, buf[:2]); err != nil { - return nil, errors.New("proxy: failed to read greeting from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - if buf[0] != 5 { - return nil, errors.New("proxy: SOCKS5 proxy at " + s.addr + " has unexpected version " + strconv.Itoa(int(buf[0]))) - } - if buf[1] == 0xff { - return nil, errors.New("proxy: SOCKS5 proxy at " + s.addr + " requires authentication") - } - - if buf[1] == socks5AuthPassword { - buf = buf[:0] - buf = append(buf, 1 /* password protocol version */) - buf = append(buf, uint8(len(s.user))) - buf = append(buf, s.user...) - buf = append(buf, uint8(len(s.password))) - buf = append(buf, s.password...) - - if _, err := conn.Write(buf); err != nil { - return nil, errors.New("proxy: failed to write authentication request to SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if _, err := io.ReadFull(conn, buf[:2]); err != nil { - return nil, errors.New("proxy: failed to read authentication reply from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if buf[1] != 0 { - return nil, errors.New("proxy: SOCKS5 proxy at " + s.addr + " rejected username/password") - } - } - - buf = buf[:0] - buf = append(buf, socks5Version, socks5Connect, 0 /* reserved */) - - if ip := net.ParseIP(host); ip != nil { - if ip4 := ip.To4(); ip4 != nil { - buf = append(buf, socks5IP4) - ip = ip4 - } else { - buf = append(buf, socks5IP6) - } - buf = append(buf, ip...) - } else { - if len(host) > 255 { - return nil, errors.New("proxy: destination hostname too long: " + host) - } - buf = append(buf, socks5Domain) - buf = append(buf, byte(len(host))) - buf = append(buf, host...) - } - buf = append(buf, byte(port>>8), byte(port)) - - if _, err := conn.Write(buf); err != nil { - return nil, errors.New("proxy: failed to write connect request to SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if _, err := io.ReadFull(conn, buf[:4]); err != nil { - return nil, errors.New("proxy: failed to read connect reply from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - failure := "unknown error" - if int(buf[1]) < len(socks5Errors) { - failure = socks5Errors[buf[1]] - } - - if len(failure) > 0 { - return nil, errors.New("proxy: SOCKS5 proxy at " + s.addr + " failed to connect: " + failure) - } - - bytesToDiscard := 0 - switch buf[3] { - case socks5IP4: - bytesToDiscard = net.IPv4len - case socks5IP6: - bytesToDiscard = net.IPv6len - case socks5Domain: - _, err := io.ReadFull(conn, buf[:1]) - if err != nil { - return nil, errors.New("proxy: failed to read domain length from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - bytesToDiscard = int(buf[0]) - default: - return nil, errors.New("proxy: got unknown address type " + strconv.Itoa(int(buf[3])) + " from SOCKS5 proxy at " + s.addr) - } - - if cap(buf) < bytesToDiscard { - buf = make([]byte, bytesToDiscard) - } else { - buf = buf[:bytesToDiscard] - } - if _, err := io.ReadFull(conn, buf); err != nil { - return nil, errors.New("proxy: failed to read address from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - // Also need to discard the port number - if _, err := io.ReadFull(conn, buf[:2]); err != nil { - return nil, errors.New("proxy: failed to read port from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - closeConn = nil - return conn, nil -}