diff --git a/Gopkg.lock b/Gopkg.lock index 46ff3f37..de540d56 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -52,15 +52,29 @@ [[projects]] branch = "master" - digest = "1:2b7b174ae68705866555b73fd848de0749b93b1f99e3295e27f89bebe8702203" + digest = "1:7dc5d77e0d21759f0ba62f928f15519c961eee6a4ada94558d94094ccd792faa" name = "github.com/elazarl/goproxy" packages = ["."] pruneopts = "UT" - revision = "947c36da3153ff334e74d9d980de341d25f358ba" + revision = "f58a169a71a51037728990b2d3597a14f56b525b" [[projects]] branch = "master" - digest = "1:f46dd7c5783c6caa5ea1072eb4165446c58651ff0849c9d366ac318f140661fa" + digest = "1:09a1322d2fc6f021b23d389c045479cf4fe94fca0f504c61bb0ca2c67e244506" + name = "github.com/evilsocket/islazy" + packages = [ + "fs", + "log", + "str", + "tui", + "zip", + ] + pruneopts = "UT" + revision = "acbee79ddc39664d9a6ef5b2c4306dd470a58b2b" + +[[projects]] + branch = "master" + digest = "1:e5e45557e1871c967a6ccaa5b95d1233a2c01ab00615621825d1aca7383dc022" name = "github.com/gobwas/glob" packages = [ ".", @@ -73,7 +87,7 @@ "util/strings", ] pruneopts = "UT" - revision = "f756513aec94125582ee6c0dc94179251ef87370" + revision = "e7a84e9525fe90abcda167b604e483cc959ad4aa" [[projects]] digest = "1:51bee9f1987dcdb9f9a1b4c20745d78f6bf6f5f14ad4e64ca883eb64df4c0045" @@ -84,15 +98,15 @@ version = "v15.0.0" [[projects]] - branch = "master" digest = "1:a63cff6b5d8b95638bfe300385d93b2a6d9d687734b863da8e09dc834510a690" name = "github.com/google/go-querystring" packages = ["query"] pruneopts = "UT" - revision = "53e6ce116135b80d037921a7fdd5138cf32d7a8a" + revision = "44c6ddd0a2342c386950e880b658017258da92fc" + version = "v1.0.0" [[projects]] - digest = "1:a1b2a09d080e0229db471efc7f030b6d3931cd54989f6a1a4d676e085139cc2d" + digest = "1:eebcd2c096c6e4dada58e468e794146753d035fed7150cc0e2ff79ef28650709" name = "github.com/google/gopacket" packages = [ ".", @@ -101,8 +115,8 @@ "pcapgo", ] pruneopts = "UT" - revision = "11c65f1ca9081dfea43b4f9643f5c155583b73ba" - version = "v1.1.14" + revision = "a6b099ece4680a8bdea84fa78166d0712108a95c" + version = "v1.1.15" [[projects]] digest = "1:c79fb010be38a59d657c48c6ba1d003a8aa651fa56b579d959d74573b7dff8e1" @@ -180,6 +194,14 @@ pruneopts = "UT" revision = "e26af0688e455a82b14ebdbecf43f87ead3c4624" +[[projects]] + branch = "master" + digest = "1:6569c2877d56f921a8a459d182af16b700c0e588c94b9938aef0d15d13d596db" + name = "github.com/mdlayher/raw" + packages = ["."] + pruneopts = "UT" + revision = "67a536258490ec29bca6d465b51dea32c0db3623" + [[projects]] branch = "master" digest = "1:2b32af4d2a529083275afc192d1067d8126b578c7a9613b26600e4df9c735155" @@ -230,11 +252,19 @@ [[projects]] branch = "master" - digest = "1:6eb2645d74b43d9c87b51947df39f7c668a4f422cd512053f7f6f75bfaad0197" + digest = "1:ed32e5b8c2cb13ea42eaca9f9dda1233ee78e9e5aa9a9839afd7911c52f121fa" + name = "golang.org/x/net" + packages = ["bpf"] + pruneopts = "UT" + revision = "146acd28ed5894421fb5aac80ca93bc1b1f46f87" + +[[projects]] + branch = "master" + digest = "1:c2789211d4035eb0843b85958ecf7cb4a5ea91c2d4decee652c94ce898e433cb" name = "golang.org/x/sys" packages = ["unix"] pruneopts = "UT" - revision = "d0be0721c37eeb5299f245a996a483160fc36940" + revision = "4497e2df6f9e69048a54498c7affbbec3294ad47" [[projects]] digest = "1:9935525a8c49b8434a0b0a54e1980e94a6fae73aaff45c5d33ba8dff69de123e" @@ -257,6 +287,11 @@ "github.com/chifflier/nfqueue-go/nfqueue", "github.com/dustin/go-humanize", "github.com/elazarl/goproxy", + "github.com/evilsocket/islazy/fs", + "github.com/evilsocket/islazy/log", + "github.com/evilsocket/islazy/str", + "github.com/evilsocket/islazy/tui", + "github.com/evilsocket/islazy/zip", "github.com/gobwas/glob", "github.com/google/go-github/github", "github.com/google/gopacket", @@ -268,7 +303,6 @@ "github.com/inconshreveable/go-vhost", "github.com/jpillora/go-tld", "github.com/malfunkt/iprange", - "github.com/mattn/go-isatty", "github.com/mdlayher/dhcp6", "github.com/mdlayher/dhcp6/dhcp6opts", "github.com/robertkrimen/otto", diff --git a/Gopkg.toml b/Gopkg.toml index c3721b51..cc6fcb65 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -77,10 +77,6 @@ name = "github.com/malfunkt/iprange" version = "0.9.0" -[[constraint]] - name = "github.com/mattn/go-isatty" - version = "0.0.3" - [[constraint]] branch = "master" name = "github.com/mdlayher/dhcp6" diff --git a/caplets/env.go b/caplets/env.go index 58597eb2..4c803b6e 100644 --- a/caplets/env.go +++ b/caplets/env.go @@ -4,7 +4,7 @@ import ( "os" "path/filepath" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/str" ) const ( @@ -26,8 +26,8 @@ var ( ) func init() { - for _, path := range core.SepSplit(core.Trim(os.Getenv(EnvVarName)), ":") { - if path = core.Trim(path); len(path) > 0 { + for _, path := range str.SplitBy(str.Trim(os.Getenv(EnvVarName)), ":") { + if path = str.Trim(path); len(path) > 0 { LoadPaths = append(LoadPaths, path) } } diff --git a/caplets/manager.go b/caplets/manager.go index b2864ece..042d95bd 100644 --- a/caplets/manager.go +++ b/caplets/manager.go @@ -9,7 +9,8 @@ import ( "strings" "sync" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/fs" + "github.com/evilsocket/islazy/str" ) var ( @@ -62,7 +63,7 @@ func Load(name string) (error, *Caplet) { } for _, filename := range names { - if core.Exists(filename) { + if fs.Exists(filename) { cap := &Caplet{ Path: filename, Code: make([]string, 0), @@ -77,7 +78,7 @@ func Load(name string) (error, *Caplet) { scanner := bufio.NewScanner(input) scanner.Split(bufio.ScanLines) for scanner.Scan() { - line := core.Trim(scanner.Text()) + line := str.Trim(scanner.Text()) if line == "" || line[0] == '#' { continue } diff --git a/core/core.go b/core/core.go index 891e2099..b3b6436d 100644 --- a/core/core.go +++ b/core/core.go @@ -1,29 +1,13 @@ package core import ( - "archive/zip" "fmt" - "io" - "os" "os/exec" - "os/user" - "path/filepath" "sort" - "strings" + + "github.com/evilsocket/islazy/str" ) -const ( - defaultTrimSet = "\r\n\t " -) - -func Trim(s string) string { - return strings.Trim(s, defaultTrimSet) -} - -func TrimRight(s string) string { - return strings.TrimRight(s, defaultTrimSet) -} - func UniqueInts(a []int, sorted bool) []int { tmp := make(map[int]bool) uniq := make([]int, 0) @@ -43,22 +27,6 @@ func UniqueInts(a []int, sorted bool) []int { return uniq } -func SepSplit(sv string, sep string) []string { - filtered := make([]string, 0) - for _, part := range strings.Split(sv, sep) { - part = Trim(part) - if part != "" { - filtered = append(filtered, part) - } - } - return filtered - -} - -func CommaSplit(csv string) []string { - return SepSplit(csv, ",") -} - func ExecSilent(executable string, args []string) (string, error) { path, err := exec.LookPath(executable) if err != nil { @@ -69,7 +37,7 @@ func ExecSilent(executable string, args []string) (string, error) { if err != nil { return "", err } else { - return Trim(string(raw)), nil + return str.Trim(string(raw)), nil } } @@ -80,72 +48,3 @@ func Exec(executable string, args []string) (string, error) { } return out, err } - -func Exists(path string) bool { - if _, err := os.Stat(path); os.IsNotExist(err) { - return false - } - return true -} - -func ExpandPath(path string) (string, error) { - // Check if path is empty - if path != "" { - if strings.HasPrefix(path, "~") { - usr, err := user.Current() - if err != nil { - return "", err - } else { - // Replace only the first occurrence of ~ - path = strings.Replace(path, "~", usr.HomeDir, 1) - } - } - return filepath.Abs(path) - } - return "", nil -} - -// Unzip will decompress a zip archive, moving all files and folders -// within the zip file (parameter 1) to an output directory (parameter 2). -// Credits to https://golangcode.com/unzip-files-in-go/ -func Unzip(src string, dest string) ([]string, error) { - var filenames []string - - r, err := zip.OpenReader(src) - if err != nil { - return filenames, err - } - defer r.Close() - - for _, f := range r.File { - rc, err := f.Open() - if err != nil { - return filenames, err - } - defer rc.Close() - - // Store filename/path for returning and using later on - fpath := filepath.Join(dest, f.Name) - - // Check for ZipSlip. More Info: https://snyk.io/research/zip-slip-vulnerability#go - if !strings.HasPrefix(fpath, filepath.Clean(dest)+string(os.PathSeparator)) { - return filenames, fmt.Errorf("%s: illegal file path", fpath) - } - - filenames = append(filenames, fpath) - if f.FileInfo().IsDir() { - os.MkdirAll(fpath, os.ModePerm) - } else if err = os.MkdirAll(filepath.Dir(fpath), os.ModePerm); err != nil { - return filenames, err - } else if outFile, err := os.OpenFile(fpath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode()); err != nil { - return filenames, err - } else { - defer outFile.Close() - if _, err = io.Copy(outFile, rc); err != nil { - return filenames, err - } - } - } - - return filenames, nil -} diff --git a/core/swag.go b/core/swag.go deleted file mode 100644 index 1de2733c..00000000 --- a/core/swag.go +++ /dev/null @@ -1,122 +0,0 @@ -package core - -import ( - "github.com/mattn/go-isatty" - "os" -) - -const ( - DEBUG = iota - INFO - IMPORTANT - WARNING - ERROR - FATAL -) - -// https://misc.flogisoft.com/bash/tip_colors_and_formatting -var ( - BOLD = "\033[1m" - DIM = "\033[2m" - - RED = "\033[31m" - GREEN = "\033[32m" - BLUE = "\033[34m" - YELLOW = "\033[33m" - - FG_BLACK = "\033[30m" - FG_WHITE = "\033[97m" - - BG_DGRAY = "\033[100m" - BG_RED = "\033[41m" - BG_GREEN = "\033[42m" - BG_YELLOW = "\033[43m" - BG_LBLUE = "\033[104m" - - RESET = "\033[0m" - - LogLabels = map[int]string{ - DEBUG: "dbg", - INFO: "inf", - IMPORTANT: "imp", - WARNING: "war", - ERROR: "err", - FATAL: "!!!", - } - - LogColors = map[int]string{ - DEBUG: DIM + FG_BLACK + BG_DGRAY, - INFO: FG_WHITE + BG_GREEN, - IMPORTANT: FG_WHITE + BG_LBLUE, - WARNING: FG_WHITE + BG_YELLOW, - ERROR: FG_WHITE + BG_RED, - FATAL: FG_WHITE + BG_RED + BOLD, - } - - HasColors = true -) - -func isDumbTerminal() bool { - return os.Getenv("TERM") == "dumb" || - os.Getenv("TERM") == "" || - (!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd())) -} - -func InitSwag(disableColors bool) { - if disableColors || isDumbTerminal() { - BOLD = "" - DIM = "" - RED = "" - GREEN = "" - BLUE = "" - YELLOW = "" - FG_BLACK = "" - FG_WHITE = "" - BG_DGRAY = "" - BG_RED = "" - BG_GREEN = "" - BG_YELLOW = "" - BG_LBLUE = "" - RESET = "" - - LogColors = map[int]string{ - DEBUG: "", - INFO: "", - IMPORTANT: "", - WARNING: "", - ERROR: "", - FATAL: "", - } - - HasColors = false - } -} - -// W for Wrap -func W(e, s string) string { - return e + s + RESET -} - -func Bold(s string) string { - return W(BOLD, s) -} - -func Dim(s string) string { - return W(DIM, s) -} - -func Red(s string) string { - return W(RED, s) -} - -func Green(s string) string { - return W(GREEN, s) -} - -func Blue(s string) string { - return W(BLUE, s) -} - -func Yellow(s string) string { - return W(YELLOW, s) -} diff --git a/core/swag_test.go b/core/swag_test.go deleted file mode 100644 index 3d1d99e2..00000000 --- a/core/swag_test.go +++ /dev/null @@ -1,95 +0,0 @@ -package core - -import ( - "os" - "testing" -) - -func TestIsDumbTerminal(t *testing.T) { - term := os.Getenv("TERM") - os.Setenv("TERM", "dumb") - if !isDumbTerminal() { - t.Fatal("Expected false when TERM==dumb") - } - os.Setenv("TERM", "") - if !isDumbTerminal() { - t.Fatal("Expected false when TERM empty") - } - os.Setenv("TERM", term) -} - -func TestW(t *testing.T) { - exp := "<3\033[0m" - got := W("<", "3") - if got != exp { - t.Fatalf("expected '%s', got '%s'", exp, got) - } -} - -func TestBold(t *testing.T) { - exp := "\033[1mgohpers\033[0m" - got := Bold("gohpers") - if got != exp { - t.Fatalf("expected path '%s', got '%s'", exp, got) - } -} - -func TestDim(t *testing.T) { - exp := "\033[2mgohpers\033[0m" - got := Dim("gohpers") - if got != exp { - t.Fatalf("expected path '%s', got '%s'", exp, got) - } -} - -func TestRed(t *testing.T) { - exp := "\033[31mgohpers\033[0m" - got := Red("gohpers") - if got != exp { - t.Fatalf("expected path '%s', got '%s'", exp, got) - } -} - -func TestGreen(t *testing.T) { - exp := "\033[32mgohpers\033[0m" - got := Green("gohpers") - if got != exp { - t.Fatalf("expected path '%s', got '%s'", exp, got) - } -} - -func TestBlue(t *testing.T) { - exp := "\033[34mgohpers\033[0m" - got := Blue("gohpers") - if got != exp { - t.Fatalf("expected path '%s', got '%s'", exp, got) - } -} - -func TestYellow(t *testing.T) { - exp := "\033[33mgohpers\033[0m" - got := Yellow("gohpers") - if got != exp { - t.Fatalf("expected path '%s', got '%s'", exp, got) - } -} - -func TestInitSwag(t *testing.T) { - // Run after other tests to avoid breaking globals - // Test InitSwag unsets globals when set - BOLD = "\033[1m" - InitSwag(true) - if BOLD != "" { - t.Fatal("expected BOLD to be empty string") - } - term := os.Getenv("TERM") - os.Setenv("TERM", "dumb") - BOLD = "\033[1m" - InitSwag(false) - if BOLD != "" { - t.Fatal("expected BOLD to be empty string") - } - os.Setenv("TERM", term) - // Would be good to test BOLD *isn't* unset when we have a TTY - // but less trivial to stub os.File.Fd() without complicating architecture -} diff --git a/core/table_test.go b/core/table_test.go deleted file mode 100644 index 8b9d8fee..00000000 --- a/core/table_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package core - -import ( - "bytes" - "regexp" - "testing" -) - -func TestViewLen(t *testing.T) { - exp := 2 - got := viewLen("<3") - if got != exp { - t.Fatalf("expected '%d', got '%d'", exp, got) - } -} - -func TestMaxLen(t *testing.T) { - exp := 7 - got := maxLen([]string{"go", "python", "ruby", "crystal"}) - if got != exp { - t.Fatalf("expected '%d', got '%d'", exp, got) - } -} - -func TestAlignLeft(t *testing.T) { - exp := Alignment(0) - got := AlignLeft - if got != exp { - t.Fatalf("expected '%d', got '%d'", exp, got) - } -} - -func TestAlignCenter(t *testing.T) { - exp := Alignment(1) - got := AlignCenter - if got != exp { - t.Fatalf("expected '%d', got '%d'", exp, got) - } -} - -func TestAlignRight(t *testing.T) { - exp := Alignment(2) - got := AlignRight - if got != exp { - t.Fatalf("expected '%d', got '%d'", exp, got) - } -} - -func TestGetPads(t *testing.T) { - lPadExp := -9 - rPadExp := -8 - lPadGot, rPadGot := getPads("Pikachu, thunderbolt!", 3, AlignCenter) - if rPadGot != rPadExp { - t.Fatalf("expected '%d', got '%d'", rPadExp, rPadGot) - } - if lPadGot != lPadExp { - t.Fatalf("expected '%d', got '%d'", lPadExp, lPadGot) - } -} - -func TestPadded(t *testing.T) { - exp := "<3" - got := padded("<3", 1, AlignLeft) - if got != exp { - t.Fatalf("expected '%s', got '%s'", exp, got) - } -} - -func TestAsTable(t *testing.T) { - var b bytes.Buffer - - AsTable(&b, []string{"top"}, [][]string{[]string{"bottom"}}) - - // look for "+-------+" table style for whichever size - match, err := regexp.MatchString(`\++-+\+`, b.String()) - if err != nil { - t.Fatalf("unable to perform regex on table output") - } - if !match { - t.Fatalf("expected table in format not found") - } -} diff --git a/firewall/firewall_darwin.go b/firewall/firewall_darwin.go index fd165b60..bafde0ff 100644 --- a/firewall/firewall_darwin.go +++ b/firewall/firewall_darwin.go @@ -148,13 +148,13 @@ func (f PfFirewall) EnableRedirection(r *Redirection, enabled bool) error { lines := "" scanner := bufio.NewScanner(fd) for scanner.Scan() { - line := core.Trim(scanner.Text()) + line := str.Trim(scanner.Text()) if line != rule { lines += line + "\n" } } - if core.Trim(lines) == "" { + if str.Trim(lines) == "" { os.Remove(f.filename) f.enable(false) } else { diff --git a/firewall/firewall_linux.go b/firewall/firewall_linux.go index cd192870..b5772a87 100644 --- a/firewall/firewall_linux.go +++ b/firewall/firewall_linux.go @@ -7,6 +7,8 @@ import ( "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/network" + + "github.com/evilsocket/islazy/str" ) type LinuxFirewall struct { @@ -54,7 +56,7 @@ func (f LinuxFirewall) IsForwardingEnabled() bool { if out, err := ioutil.ReadFile(IPV4ForwardingFile); err != nil { return false } else { - return core.Trim(string(out)) == "1" + return str.Trim(string(out)) == "1" } } diff --git a/log/log.go b/log/log.go index f60d9cb8..a4ab7ba9 100644 --- a/log/log.go +++ b/log/log.go @@ -1,26 +1,27 @@ package log import ( - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/session" + + ll "github.com/evilsocket/islazy/log" ) func Debug(format string, args ...interface{}) { - session.I.Events.Log(core.DEBUG, format, args...) + session.I.Events.Log(ll.DEBUG, format, args...) } func Info(format string, args ...interface{}) { - session.I.Events.Log(core.INFO, format, args...) + session.I.Events.Log(ll.INFO, format, args...) } func Warning(format string, args ...interface{}) { - session.I.Events.Log(core.WARNING, format, args...) + session.I.Events.Log(ll.WARNING, format, args...) } func Error(format string, args ...interface{}) { - session.I.Events.Log(core.ERROR, format, args...) + session.I.Events.Log(ll.ERROR, format, args...) } func Fatal(format string, args ...interface{}) { - session.I.Events.Log(core.FATAL, format, args...) + session.I.Events.Log(ll.FATAL, format, args...) } diff --git a/main.go b/main.go index 622d3dc6..2f9e9f05 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,9 @@ import ( "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/modules" "github.com/bettercap/bettercap/session" + + "github.com/evilsocket/islazy/str" + "github.com/evilsocket/islazy/tui" ) func main() { @@ -20,7 +23,7 @@ func main() { } defer sess.Close() - if !core.HasColors { + if !tui.Effects() { if *sess.Options.NoColors { fmt.Printf("\n\nWARNING: Terminal colors have been disabled, view will be very limited.\n\n") } else { @@ -30,7 +33,7 @@ func main() { appName := fmt.Sprintf("%s v%s", core.Name, core.Version) - fmt.Printf("%s (type '%s' for a list of commands)\n\n", core.Bold(appName), core.Bold("help")) + fmt.Printf("%s (type '%s' for a list of commands)\n\n", tui.Bold(appName), tui.Bold("help")) sess.Register(modules.NewEventsStream(sess)) sess.Register(modules.NewTicker(sess)) @@ -67,13 +70,13 @@ func main() { // modules might already be started. for _, cmd := range session.ParseCommands(*sess.Options.Commands) { if err = sess.Run(cmd); err != nil { - log.Error("Error while running '%s': %s", core.Bold(cmd), core.Red(err.Error())) + log.Error("Error while running '%s': %s", tui.Bold(cmd), tui.Red(err.Error())) } } // Some modules are enabled by default in order // to make the interactive session useful. - for _, modName := range core.CommaSplit(*sess.Options.AutoStart) { + for _, modName := range str.Comma(*sess.Options.AutoStart) { if err = sess.Run(modName + " on"); err != nil { log.Fatal("Error while starting module %s: %s", modName, err) } @@ -82,7 +85,7 @@ func main() { // Then run the caplet if specified. if *sess.Options.Caplet != "" { if err = sess.RunCaplet(*sess.Options.Caplet); err != nil { - log.Error("Error while running caplet %s: %s", core.Bold(*sess.Options.Caplet), core.Red(err.Error())) + log.Error("Error while running caplet %s: %s", tui.Bold(*sess.Options.Caplet), tui.Red(err.Error())) } } diff --git a/modules/api_rest.go b/modules/api_rest.go index 39ca3461..7a87e503 100644 --- a/modules/api_rest.go +++ b/modules/api_rest.go @@ -6,13 +6,14 @@ import ( "net/http" "time" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/tls" "github.com/gorilla/mux" "github.com/gorilla/websocket" + + "github.com/evilsocket/islazy/fs" ) type RestAPI struct { @@ -135,11 +136,11 @@ func (api *RestAPI) Configure() error { return err } else if err, api.certFile = api.StringParam("api.rest.certificate"); err != nil { return err - } else if api.certFile, err = core.ExpandPath(api.certFile); err != nil { + } else if api.certFile, err = fs.Expand(api.certFile); err != nil { return err } else if err, api.keyFile = api.StringParam("api.rest.key"); err != nil { return err - } else if api.keyFile, err = core.ExpandPath(api.keyFile); err != nil { + } else if api.keyFile, err = fs.Expand(api.keyFile); err != nil { return err } else if err, api.username = api.StringParam("api.rest.username"); err != nil { return err @@ -150,7 +151,7 @@ func (api *RestAPI) Configure() error { } if api.isTLS() { - if !core.Exists(api.certFile) || !core.Exists(api.keyFile) { + if !fs.Exists(api.certFile) || !fs.Exists(api.keyFile) { err, cfg := tls.CertConfigFromModule("api.rest", api.SessionModule) if err != nil { return err diff --git a/modules/ble_recon_view.go b/modules/ble_recon_view.go index 50bdccc8..13740f90 100644 --- a/modules/ble_recon_view.go +++ b/modules/ble_recon_view.go @@ -11,11 +11,12 @@ import ( "strings" "time" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/network" "github.com/bettercap/gatt" + + "github.com/evilsocket/islazy/tui" ) var ( @@ -30,15 +31,15 @@ func (d *BLERecon) getRow(dev *network.BLEDevice) []string { lastSeen := dev.LastSeen.Format("15:04:05") if sinceSeen <= bleAliveInterval { - lastSeen = core.Bold(lastSeen) + lastSeen = tui.Bold(lastSeen) } else if sinceSeen > blePresentInterval { - lastSeen = core.Dim(lastSeen) - address = core.Dim(address) + lastSeen = tui.Dim(lastSeen) + address = tui.Dim(address) } - isConnectable := core.Red("no") + isConnectable := tui.Red("no") if dev.Advertisement.Connectable { - isConnectable = core.Green("yes") + isConnectable = tui.Green("yes") } return []string{ @@ -65,7 +66,7 @@ func (d *BLERecon) Show() error { columns := []string{"RSSI", "Address", "Name", "Vendor", "Connectable", "Last Seen"} if nrows > 0 { - core.AsTable(os.Stdout, columns, rows) + tui.Table(os.Stdout, columns, rows) } d.Session.Refresh() @@ -87,7 +88,7 @@ func parseProperties(ch *gatt.Characteristic) (props []string, isReadable bool, props = append(props, "read") } if (mask&gatt.CharWriteNR) != 0 || (mask&gatt.CharWrite) != 0 { - props = append(props, core.Bold("write")) + props = append(props, tui.Bold("write")) isWritable = true withResponse = (mask & gatt.CharWriteNR) == 0 } @@ -98,7 +99,7 @@ func parseProperties(ch *gatt.Characteristic) (props []string, isReadable bool, props = append(props, "indicate") } if (mask & gatt.CharSignedWrite) != 0 { - props = append(props, core.Yellow("*write")) + props = append(props, tui.Yellow("*write")) isWritable = true withResponse = true } @@ -121,7 +122,7 @@ func parseRawData(raw []byte) string { } } - return core.Yellow(s) + return tui.Yellow(s) } func (d *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) { @@ -138,7 +139,7 @@ func (d *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) { if name == "" { name = svc.UUID().String() } else { - name = fmt.Sprintf("%s (%s)", core.Green(name), core.Dim(svc.UUID().String())) + name = fmt.Sprintf("%s (%s)", tui.Green(name), tui.Dim(svc.UUID().String())) } row := []string{ @@ -163,7 +164,7 @@ func (d *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) { if name == "" { name = " " + ch.UUID().String() } else { - name = fmt.Sprintf(" %s (%s)", core.Green(name), core.Dim(ch.UUID().String())) + name = fmt.Sprintf(" %s (%s)", tui.Green(name), tui.Dim(ch.UUID().String())) } props, isReadable, isWritable, withResponse := parseProperties(ch) @@ -186,7 +187,7 @@ func (d *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) { if isReadable { raw, err := p.ReadCharacteristic(ch) if err != nil { - data = core.Red(err.Error()) + data = tui.Red(err.Error()) } else { data = parseRawData(raw) } @@ -206,7 +207,7 @@ func (d *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) { if wantsToWrite && !foundToWrite { log.Error("Writable characteristics %s not found.", d.writeUUID) } else { - core.AsTable(os.Stdout, columns, rows) + tui.Table(os.Stdout, columns, rows) d.Session.Refresh() } } diff --git a/modules/caplets.go b/modules/caplets.go index af14ccb0..98a1ecd2 100644 --- a/modules/caplets.go +++ b/modules/caplets.go @@ -7,11 +7,14 @@ import ( "os" "github.com/bettercap/bettercap/caplets" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/session" "github.com/dustin/go-humanize" + + "github.com/evilsocket/islazy/fs" + "github.com/evilsocket/islazy/tui" + "github.com/evilsocket/islazy/zip" ) type CapletsModule struct { @@ -83,13 +86,13 @@ func (c *CapletsModule) Show() error { for _, caplet := range caplets { rows = append(rows, []string{ - core.Bold(caplet.Name), + tui.Bold(caplet.Name), caplet.Path, - core.Dim(humanize.Bytes(uint64(caplet.Size))), + tui.Dim(humanize.Bytes(uint64(caplet.Size))), }) } - core.AsTable(os.Stdout, colNames, rows) + tui.Table(os.Stdout, colNames, rows) return nil } @@ -104,14 +107,14 @@ func (c *CapletsModule) Paths() error { rows = append(rows, []string{path}) } - core.AsTable(os.Stdout, colNames, rows) - fmt.Printf("(paths can be customized by defining the %s environment variable)\n", core.Bold(caplets.EnvVarName)) + tui.Table(os.Stdout, colNames, rows) + fmt.Printf("(paths can be customized by defining the %s environment variable)\n", tui.Bold(caplets.EnvVarName)) return nil } func (c *CapletsModule) Update() error { - if !core.Exists(caplets.InstallBase) { + if !fs.Exists(caplets.InstallBase) { log.Info("creating caplets install path %s ...", caplets.InstallBase) if err := os.MkdirAll(caplets.InstallBase, os.ModePerm); err != nil { return err @@ -138,7 +141,7 @@ func (c *CapletsModule) Update() error { log.Info("installing caplets to %s ...", caplets.InstallPath) - if _, err = core.Unzip("/tmp/caplets.zip", caplets.InstallBase); err != nil { + if _, err = zip.Unzip("/tmp/caplets.zip", caplets.InstallBase); err != nil { return err } diff --git a/modules/dhcp6_spoof.go b/modules/dhcp6_spoof.go index 8f767a4d..2a068ad0 100644 --- a/modules/dhcp6_spoof.go +++ b/modules/dhcp6_spoof.go @@ -9,7 +9,6 @@ import ( "sync" "time" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" @@ -22,6 +21,8 @@ import ( // will fix this > https://github.com/google/gopacket/issues/334 "github.com/mdlayher/dhcp6" "github.com/mdlayher/dhcp6/dhcp6opts" + + "github.com/evilsocket/islazy/tui" ) type DHCP6Spoofer struct { @@ -130,7 +131,7 @@ func (s *DHCP6Spoofer) dhcpAdvertise(pkt gopacket.Packet, solicit dhcp6.Packet, fqdn = string(raw[0]) } - log.Info("[%s] Got DHCPv6 Solicit request from %s (%s), sending spoofed advertisement for %d domains.", core.Green("dhcp6"), core.Bold(fqdn), target, len(s.Domains)) + log.Info("[%s] Got DHCPv6 Solicit request from %s (%s), sending spoofed advertisement for %d domains.", tui.Green("dhcp6"), tui.Bold(fqdn), target, len(s.Domains)) err, adv := s.dhcp6For(dhcp6.MessageTypeAdvertise, solicit) if err != nil { @@ -224,7 +225,7 @@ func (s *DHCP6Spoofer) dhcpAdvertise(pkt gopacket.Packet, solicit dhcp6.Packet, } func (s *DHCP6Spoofer) dhcpReply(toType string, pkt gopacket.Packet, req dhcp6.Packet, target net.HardwareAddr) { - log.Debug("Sending spoofed DHCPv6 reply to %s after its %s packet.", core.Bold(target.String()), toType) + log.Debug("Sending spoofed DHCPv6 reply to %s after its %s packet.", tui.Bold(target.String()), toType) err, reply := s.dhcp6For(dhcp6.MessageTypeReply, req) if err != nil { @@ -308,9 +309,9 @@ func (s *DHCP6Spoofer) dhcpReply(toType string, pkt gopacket.Packet, req dhcp6.P } if h, found := s.Session.Lan.Get(target.String()); found { - log.Info("[%s] IPv6 address %s is now assigned to %s", core.Green("dhcp6"), addr.String(), h) + log.Info("[%s] IPv6 address %s is now assigned to %s", tui.Green("dhcp6"), addr.String(), h) } else { - log.Info("[%s] IPv6 address %s is now assigned to %s", core.Green("dhcp6"), addr.String(), target) + log.Info("[%s] IPv6 address %s is now assigned to %s", tui.Green("dhcp6"), addr.String(), target) } } else { log.Debug("DHCPv6 renew sent to %s", target) diff --git a/modules/dns_spoof.go b/modules/dns_spoof.go index c70def22..ea95cc3d 100644 --- a/modules/dns_spoof.go +++ b/modules/dns_spoof.go @@ -6,7 +6,6 @@ import ( "net" "sync" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" @@ -14,6 +13,8 @@ import ( "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/google/gopacket/pcap" + + "github.com/evilsocket/islazy/tui" ) type DNSSpoofer struct { @@ -120,7 +121,7 @@ func (s *DNSSpoofer) Configure() error { } for _, entry := range s.Hosts { - log.Info("[%s] %s -> %s", core.Green("dns.spoof"), entry.Host, entry.Address) + log.Info("[%s] %s -> %s", tui.Green("dns.spoof"), entry.Host, entry.Address) } if !s.Session.Firewall.IsForwardingEnabled() { @@ -139,7 +140,7 @@ func (s *DNSSpoofer) dnsReply(pkt gopacket.Packet, peth *layers.Ethernet, pudp * who = t.String() } - log.Info("[%s] sending spoofed DNS reply for %s %s to %s.", core.Green("dns"), core.Red(domain), core.Dim(redir), core.Bold(who)) + log.Info("[%s] sending spoofed DNS reply for %s %s to %s.", tui.Green("dns"), tui.Red(domain), tui.Dim(redir), tui.Bold(who)) var err error var src, dst net.IP diff --git a/modules/dns_spoof_hosts.go b/modules/dns_spoof_hosts.go index 8e8ac198..c4cbe3f0 100644 --- a/modules/dns_spoof_hosts.go +++ b/modules/dns_spoof_hosts.go @@ -8,9 +8,9 @@ import ( "regexp" "strings" - "github.com/bettercap/bettercap/core" - "github.com/gobwas/glob" + + "github.com/evilsocket/islazy/str" ) var hostsSplitter = regexp.MustCompile(`\s+`) @@ -57,7 +57,7 @@ func HostsFromFile(filename string) (err error, entries []HostEntry) { scanner := bufio.NewScanner(input) scanner.Split(bufio.ScanLines) for scanner.Scan() { - line := core.Trim(scanner.Text()) + line := str.Trim(scanner.Text()) if line == "" || line[0] == '#' { continue } diff --git a/modules/events_ignore_list.go b/modules/events_ignore_list.go index 6b70de42..c66845d3 100644 --- a/modules/events_ignore_list.go +++ b/modules/events_ignore_list.go @@ -6,8 +6,9 @@ import ( "strings" "sync" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/session" + + "github.com/evilsocket/islazy/str" ) var ( @@ -32,7 +33,7 @@ func NewIgnoreList() *IgnoreList { } func (l *IgnoreList) checkExpression(expr string) (string, error) { - expr = core.Trim(expr) + expr = str.Trim(expr) if expr == "" { return "", ErrEmptyExpression } diff --git a/modules/events_stream.go b/modules/events_stream.go index 0eea2ad9..1e7a682e 100644 --- a/modules/events_stream.go +++ b/modules/events_stream.go @@ -6,9 +6,12 @@ import ( "strconv" "time" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/session" + + "github.com/evilsocket/islazy/fs" + "github.com/evilsocket/islazy/str" + "github.com/evilsocket/islazy/tui" ) type EventsStream struct { @@ -50,7 +53,7 @@ func NewEventsStream(s *session.Session) *EventsStream { func(args []string) error { limit := -1 if len(args) == 1 { - arg := core.Trim(args[0]) + arg := str.Trim(args[0]) limit, _ = strconv.Atoi(arg) } return stream.Show(limit) @@ -62,7 +65,7 @@ func NewEventsStream(s *session.Session) *EventsStream { tag := args[0] timeout := 0 if len(args) == 2 { - t := core.Trim(args[1]) + t := str.Trim(args[1]) if t != "" { n, err := strconv.Atoi(t) if err != nil { @@ -143,7 +146,7 @@ func (s *EventsStream) Configure() (err error) { if err, output = s.StringParam("events.stream.output"); err == nil { if output == "" { s.output = os.Stdout - } else if output, err = core.ExpandPath(output); err == nil { + } else if output, err = fs.Expand(output); err == nil { s.output, err = os.OpenFile(output, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) } } else if err, s.dumpHttpReqs = s.BoolParam("events.stream.http.request.dump"); err != nil { @@ -211,9 +214,9 @@ func (s *EventsStream) Show(limit int) error { func (s *EventsStream) startWaitingFor(tag string, timeout int) error { if timeout == 0 { - log.Info("waiting for event %s ...", core.Green(tag)) + log.Info("waiting for event %s ...", tui.Green(tag)) } else { - log.Info("waiting for event %s for %d seconds ...", core.Green(tag), timeout) + log.Info("waiting for event %s for %d seconds ...", tui.Green(tag), timeout) go func() { time.Sleep(time.Duration(timeout) * time.Second) s.waitFor = "" diff --git a/modules/events_view.go b/modules/events_view.go index 8a82f4d2..71a22784 100644 --- a/modules/events_view.go +++ b/modules/events_view.go @@ -5,11 +5,12 @@ import ( "os" "strings" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" "github.com/google/go-github/github" + + "github.com/evilsocket/islazy/tui" ) const eventTimeFormat = "15:04:05" @@ -17,7 +18,7 @@ const eventTimeFormat = "15:04:05" func (s *EventsStream) viewLogEvent(e session.Event) { fmt.Fprintf(s.output, "[%s] [%s] [%s] %s\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), + tui.Green(e.Tag), e.Label(), e.Data.(session.LogMessage).Message) } @@ -37,21 +38,21 @@ func (s *EventsStream) viewWiFiEvent(e session.Event) { if e.Tag == "wifi.ap.new" { fmt.Fprintf(s.output, "[%s] [%s] wifi access point %s%s detected as %s%s.\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), - core.Bold(ap.ESSID()), - core.Dim(core.Yellow(rssi)), - core.Green(ap.BSSID()), - core.Dim(vend)) + tui.Green(e.Tag), + tui.Bold(ap.ESSID()), + tui.Dim(tui.Yellow(rssi)), + tui.Green(ap.BSSID()), + tui.Dim(vend)) } else if e.Tag == "wifi.ap.lost" { fmt.Fprintf(s.output, "[%s] [%s] wifi access point %s (%s) lost.\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), - core.Red(ap.ESSID()), + tui.Green(e.Tag), + tui.Red(ap.ESSID()), ap.BSSID()) } else { fmt.Fprintf(s.output, "[%s] [%s] %s\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), + tui.Green(e.Tag), ap.String()) } } else if e.Tag == "wifi.client.probe" { @@ -69,11 +70,11 @@ func (s *EventsStream) viewWiFiEvent(e session.Event) { fmt.Fprintf(s.output, "[%s] [%s] station %s%s is probing for SSID %s%s\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), + tui.Green(e.Tag), probe.FromAddr.String(), - core.Dim(desc), - core.Bold(probe.SSID), - core.Yellow(rssi)) + tui.Dim(desc), + tui.Bold(probe.SSID), + tui.Yellow(rssi)) } } @@ -95,21 +96,21 @@ func (s *EventsStream) viewendpointEvent(e session.Event) { if e.Tag == "endpoint.new" { fmt.Fprintf(s.output, "[%s] [%s] endpoint %s%s detected as %s%s.\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), - core.Bold(t.IpAddress), - core.Dim(name), - core.Green(t.HwAddress), - core.Dim(vend)) + tui.Green(e.Tag), + tui.Bold(t.IpAddress), + tui.Dim(name), + tui.Green(t.HwAddress), + tui.Dim(vend)) } else if e.Tag == "endpoint.lost" { fmt.Fprintf(s.output, "[%s] [%s] endpoint %s%s lost.\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), - core.Red(t.IpAddress), - core.Dim(vend)) + tui.Green(e.Tag), + tui.Red(t.IpAddress), + tui.Dim(vend)) } else { fmt.Fprintf(s.output, "[%s] [%s] %s\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), + tui.Green(e.Tag), t.String()) } } @@ -117,7 +118,7 @@ func (s *EventsStream) viewendpointEvent(e session.Event) { func (s *EventsStream) viewModuleEvent(e session.Event) { fmt.Fprintf(s.output, "[%s] [%s] %s\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), + tui.Green(e.Tag), e.Data) } @@ -127,7 +128,7 @@ func (s *EventsStream) viewSnifferEvent(e session.Event) { } else { fmt.Fprintf(s.output, "[%s] [%s] %s\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), + tui.Green(e.Tag), e.Data.(SnifferEvent).Message) } } @@ -136,9 +137,9 @@ func (s *EventsStream) viewSynScanEvent(e session.Event) { se := e.Data.(SynScanEvent) fmt.Fprintf(s.output, "[%s] [%s] found open port %d for %s\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), + tui.Green(e.Tag), se.Port, - core.Bold(se.Address)) + tui.Bold(se.Address)) } func (s *EventsStream) viewUpdateEvent(e session.Event) { @@ -146,8 +147,8 @@ func (s *EventsStream) viewUpdateEvent(e session.Event) { fmt.Fprintf(s.output, "[%s] [%s] an update to version %s is available at %s\n", e.Time.Format(eventTimeFormat), - core.Bold(core.Yellow(e.Tag)), - core.Bold(*update.TagName), + tui.Bold(tui.Yellow(e.Tag)), + tui.Bold(*update.TagName), *update.HTMLURL) } @@ -169,7 +170,7 @@ func (s *EventsStream) View(e session.Event, refresh bool) { } else if e.Tag == "update.available" { s.viewUpdateEvent(e) } else { - fmt.Fprintf(s.output, "[%s] [%s] %v\n", e.Time.Format(eventTimeFormat), core.Green(e.Tag), e) + fmt.Fprintf(s.output, "[%s] [%s] %v\n", e.Time.Format(eventTimeFormat), tui.Green(e.Tag), e) } if refresh && s.output == os.Stdout { diff --git a/modules/events_view_ble.go b/modules/events_view_ble.go index 4d65d05b..0bea77a2 100644 --- a/modules/events_view_ble.go +++ b/modules/events_view_ble.go @@ -6,9 +6,10 @@ package modules import ( "fmt" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" + + "github.com/evilsocket/islazy/tui" ) func (s *EventsStream) viewBLEEvent(e session.Event) { @@ -16,40 +17,40 @@ func (s *EventsStream) viewBLEEvent(e session.Event) { dev := e.Data.(*network.BLEDevice) name := dev.Device.Name() if name != "" { - name = " " + core.Bold(name) + name = " " + tui.Bold(name) } vend := dev.Vendor if vend != "" { - vend = fmt.Sprintf(" (%s)", core.Yellow(vend)) + vend = fmt.Sprintf(" (%s)", tui.Yellow(vend)) } fmt.Fprintf(s.output, "[%s] [%s] new BLE device%s detected as %s%s %s.\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), + tui.Green(e.Tag), name, dev.Device.ID(), vend, - core.Dim(fmt.Sprintf("%d dBm", dev.RSSI))) + tui.Dim(fmt.Sprintf("%d dBm", dev.RSSI))) } else if e.Tag == "ble.device.lost" { dev := e.Data.(*network.BLEDevice) name := dev.Device.Name() if name != "" { - name = " " + core.Bold(name) + name = " " + tui.Bold(name) } vend := dev.Vendor if vend != "" { - vend = fmt.Sprintf(" (%s)", core.Yellow(vend)) + vend = fmt.Sprintf(" (%s)", tui.Yellow(vend)) } fmt.Fprintf(s.output, "[%s] [%s] BLE device%s %s%s lost.\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), + tui.Green(e.Tag), name, dev.Device.ID(), vend) } /* else { fmt.Fprintf(s.output,"[%s] [%s]\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag)) + tui.Green(e.Tag)) } */ } diff --git a/modules/events_view_http.go b/modules/events_view_http.go index e1374dbc..51bfcaeb 100644 --- a/modules/events_view_http.go +++ b/modules/events_view_http.go @@ -10,8 +10,9 @@ import ( "regexp" "strings" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/session" + + "github.com/evilsocket/islazy/tui" ) var ( @@ -67,20 +68,20 @@ func (s *EventsStream) dumpForm(body []byte) string { value = parts[1] } - form = append(form, fmt.Sprintf("%s=%s", core.Green(name), core.Bold(core.Red(value)))) + form = append(form, fmt.Sprintf("%s=%s", tui.Green(name), tui.Bold(tui.Red(value)))) } else { value, err := url.QueryUnescape(v) if err != nil { value = v } - form = append(form, fmt.Sprintf("%s", core.Bold(core.Red(value)))) + form = append(form, fmt.Sprintf("%s", tui.Bold(tui.Red(value)))) } } return "\n" + strings.Join(form, "&") + "\n" } func (s *EventsStream) dumpText(body []byte) string { - return "\n" + core.Bold(core.Red(string(body))) + "\n" + return "\n" + tui.Bold(tui.Red(string(body))) + "\n" } func (s *EventsStream) dumpGZIP(body []byte) string { @@ -105,7 +106,7 @@ func (s *EventsStream) dumpJSON(body []byte) string { pretty = string(buf.Bytes()) } - return "\n" + reJsonKey.ReplaceAllString(pretty, core.W(core.GREEN, `$1:`)) + "\n" + return "\n" + reJsonKey.ReplaceAllString(pretty, tui.Green(`$1:`)) + "\n" } func (s *EventsStream) dumpXML(body []byte) string { @@ -123,15 +124,15 @@ func (s *EventsStream) viewHttpRequest(e session.Event) { fmt.Fprintf(s.output, "[%s] [%s] %s\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), + tui.Green(e.Tag), se.Message) if s.shouldDumpHttpRequest(req) { - dump := fmt.Sprintf("%s %s %s\n", core.Bold(req.Method), req.URL, core.Dim(req.Proto)) - dump += fmt.Sprintf("%s: %s\n", core.Blue("Host"), core.Yellow(req.Host)) + dump := fmt.Sprintf("%s %s %s\n", tui.Bold(req.Method), req.URL, tui.Dim(req.Proto)) + dump += fmt.Sprintf("%s: %s\n", tui.Blue("Host"), tui.Yellow(req.Host)) for name, values := range req.Headers { for _, value := range values { - dump += fmt.Sprintf("%s: %s\n", core.Blue(name), core.Yellow(value)) + dump += fmt.Sprintf("%s: %s\n", tui.Blue(name), tui.Yellow(value)) } } @@ -161,14 +162,14 @@ func (s *EventsStream) viewHttpResponse(e session.Event) { fmt.Fprintf(s.output, "[%s] [%s] %s\n", e.Time.Format(eventTimeFormat), - core.Green(e.Tag), + tui.Green(e.Tag), se.Message) if s.shouldDumpHttpResponse(res) { - dump := fmt.Sprintf("%s %s\n", core.Dim(res.Protocol), res.Status) + dump := fmt.Sprintf("%s %s\n", tui.Dim(res.Protocol), res.Status) for name, values := range res.Headers { for _, value := range values { - dump += fmt.Sprintf("%s: %s\n", core.Blue(name), core.Yellow(value)) + dump += fmt.Sprintf("%s: %s\n", tui.Blue(name), tui.Yellow(value)) } } diff --git a/modules/gps.go b/modules/gps.go index 88ecd305..9ed030da 100644 --- a/modules/gps.go +++ b/modules/gps.go @@ -5,12 +5,13 @@ import ( "io" "time" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/session" "github.com/adrianmo/go-nmea" "github.com/tarm/serial" + + "github.com/evilsocket/islazy/str" ) type GPS struct { @@ -97,7 +98,7 @@ func (gps *GPS) readLine() (line string, err error) { return } else if n == 1 { if b[0] == '\n' { - return core.Trim(line), nil + return str.Trim(line), nil } else { line += string(b[0]) } diff --git a/modules/http_proxy_base.go b/modules/http_proxy_base.go index 4b32bed5..a1c91120 100644 --- a/modules/http_proxy_base.go +++ b/modules/http_proxy_base.go @@ -15,7 +15,6 @@ import ( "strings" "time" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/firewall" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/session" @@ -23,6 +22,9 @@ import ( "github.com/elazarl/goproxy" "github.com/inconshreveable/go-vhost" + + "github.com/evilsocket/islazy/fs" + "github.com/evilsocket/islazy/tui" ) const ( @@ -116,7 +118,7 @@ func (p *HTTPProxy) Configure(address string, proxyPort int, httpPort int, scrip if strings.HasPrefix(jsToInject, "http://") || strings.HasPrefix(jsToInject, "https://") { p.jsHook = fmt.Sprintf("", jsToInject) - } else if core.Exists(jsToInject) { + } else if fs.Exists(jsToInject) { if data, err := ioutil.ReadFile(jsToInject); err != nil { return err } else { @@ -187,7 +189,7 @@ func TLSConfigFromCA(ca *tls.Certificate) func(host string, ctx *goproxy.ProxyCt cert := getCachedCert(hostname, port) if cert == nil { - log.Debug("Creating spoofed certificate for %s:%d", core.Yellow(hostname), port) + log.Debug("Creating spoofed certificate for %s:%d", tui.Yellow(hostname), port) cert, err = btls.SignCertificateForHost(ca, hostname, port) if err != nil { log.Warning("Cannot sign host certificate with provided CA: %s", err) @@ -298,7 +300,7 @@ func (p *HTTPProxy) httpsWorker() error { return } - log.Debug("[%s] proxying connection from %s to %s", core.Green("https.proxy"), core.Bold(stripPort(c.RemoteAddr().String())), core.Yellow(hostname)) + log.Debug("[%s] proxying connection from %s to %s", tui.Green("https.proxy"), tui.Bold(stripPort(c.RemoteAddr().String())), tui.Yellow(hostname)) req := &http.Request{ Method: "CONNECT", @@ -320,12 +322,12 @@ func (p *HTTPProxy) Start() { go func() { var err error - strip := core.Yellow("enabled") + strip := tui.Yellow("enabled") if !p.stripper.Enabled() { - strip = core.Dim("disabled") + strip = tui.Dim("disabled") } - log.Info("%s started on %s (sslstrip %s)", core.Green(p.Name), p.Server.Addr, strip) + log.Info("%s started on %s (sslstrip %s)", tui.Green(p.Name), p.Server.Addr, strip) if p.isTLS { err = p.httpsWorker() diff --git a/modules/http_proxy_base_filters.go b/modules/http_proxy_base_filters.go index 686e9773..de7110fa 100644 --- a/modules/http_proxy_base_filters.go +++ b/modules/http_proxy_base_filters.go @@ -5,10 +5,11 @@ import ( "net/http" "strings" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/elazarl/goproxy" + + "github.com/evilsocket/islazy/tui" ) func (p *HTTPProxy) fixRequestHeaders(req *http.Request) { @@ -20,7 +21,7 @@ func (p *HTTPProxy) fixRequestHeaders(req *http.Request) { } func (p *HTTPProxy) onRequestFilter(req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) { - log.Debug("(%s) < %s %s %s%s", core.Green(p.Name), req.RemoteAddr, req.Method, req.Host, req.URL.Path) + log.Debug("(%s) < %s %s %s%s", tui.Green(p.Name), req.RemoteAddr, req.Method, req.Host, req.URL.Path) p.fixRequestHeaders(req) @@ -99,11 +100,11 @@ func (p *HTTPProxy) doScriptInjection(res *http.Response, cType string) (error, return err, nil } else if html := string(raw); strings.Contains(html, "") { log.Info("(%s) > injecting javascript (%d bytes) into %s (%d bytes) for %s", - core.Green(p.Name), + tui.Green(p.Name), len(p.jsHook), - core.Yellow(res.Request.Host+res.Request.URL.Path), + tui.Yellow(res.Request.Host+res.Request.URL.Path), len(raw), - core.Bold(strings.Split(res.Request.RemoteAddr, ":")[0])) + tui.Bold(strings.Split(res.Request.RemoteAddr, ":")[0])) html = strings.Replace(html, "", p.jsHook, -1) newResp := goproxy.NewResponse(res.Request, cType, res.StatusCode, html) @@ -125,7 +126,7 @@ func (p *HTTPProxy) onResponseFilter(res *http.Response, ctx *goproxy.ProxyCtx) return nil } - log.Debug("(%s) > %s %s %s%s", core.Green(p.Name), res.Request.RemoteAddr, res.Request.Method, res.Request.Host, res.Request.URL.Path) + log.Debug("(%s) > %s %s %s%s", tui.Green(p.Name), res.Request.RemoteAddr, res.Request.Method, res.Request.Host, res.Request.URL.Path) p.fixResponseHeaders(res) diff --git a/modules/http_proxy_base_sslstriper.go b/modules/http_proxy_base_sslstriper.go index 9bc79004..77bea60f 100644 --- a/modules/http_proxy_base_sslstriper.go +++ b/modules/http_proxy_base_sslstriper.go @@ -9,7 +9,6 @@ import ( "regexp" "strings" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" @@ -18,6 +17,8 @@ import ( "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/google/gopacket/pcap" + + "github.com/evilsocket/islazy/tui" ) var ( @@ -66,7 +67,7 @@ func (s *SSLStripper) dnsReply(pkt gopacket.Packet, peth *layers.Ethernet, pudp who = t.String() } - log.Debug("[%s] Sending spoofed DNS reply for %s %s to %s.", core.Green("dns"), core.Red(domain), core.Dim(redir), core.Bold(who)) + log.Debug("[%s] Sending spoofed DNS reply for %s %s to %s.", tui.Green("dns"), tui.Red(domain), tui.Dim(redir), tui.Bold(who)) var err error var src, dst net.IP @@ -245,7 +246,7 @@ func (s *SSLStripper) Preprocess(req *http.Request, ctx *goproxy.ProxyCtx) (redi // handle stripped domains original := s.hosts.Unstrip(req.Host) if original != nil { - log.Info("[%s] Replacing host %s with %s in request from %s", core.Green("sslstrip"), core.Bold(req.Host), core.Yellow(original.Hostname), req.RemoteAddr) + log.Info("[%s] Replacing host %s with %s in request from %s", tui.Green("sslstrip"), tui.Bold(req.Host), tui.Yellow(original.Hostname), req.RemoteAddr) req.Host = original.Hostname req.URL.Host = original.Hostname req.Header.Set("Host", original.Hostname) @@ -254,7 +255,7 @@ func (s *SSLStripper) Preprocess(req *http.Request, ctx *goproxy.ProxyCtx) (redi if !s.cookies.IsClean(req) { // check if we need to redirect the user in order // to make unknown session cookies expire - log.Info("[%s] Sending expired cookies for %s to %s", core.Green("sslstrip"), core.Yellow(req.Host), req.RemoteAddr) + log.Info("[%s] Sending expired cookies for %s to %s", tui.Green("sslstrip"), tui.Yellow(req.Host), req.RemoteAddr) s.cookies.Track(req) redir = s.cookies.Expire(req) } @@ -267,7 +268,7 @@ func (s *SSLStripper) isMaxRedirs(hostname string) bool { if nredirs, found := s.redirs[hostname]; found { // reached the threshold? if nredirs >= maxRedirs { - log.Warning("[%s] Hit max redirections for %s, serving HTTPS.", core.Green("sslstrip"), hostname) + log.Warning("[%s] Hit max redirections for %s, serving HTTPS.", tui.Green("sslstrip"), hostname) // reset delete(s.redirs, hostname) return true @@ -299,7 +300,7 @@ func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) { // are we getting redirected from http to https? if orig.Scheme == "http" && location.Scheme == "https" { - log.Info("[%s] Got redirection from HTTPS to HTTP: %s -> %s", core.Green("sslstrip"), core.Yellow("http://"+origHost), core.Bold("https://"+newHost)) + log.Info("[%s] Got redirection from HTTPS to HTTP: %s -> %s", tui.Green("sslstrip"), tui.Yellow("http://"+origHost), tui.Bold("https://"+newHost)) // if we still did not reach max redirections, strip the URL down to // an alternative HTTP version @@ -342,11 +343,11 @@ func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) { if nurls == 1 { plural = "" } - log.Info("[%s] Stripping %d SSL link%s from %s", core.Green("sslstrip"), nurls, plural, core.Bold(res.Request.Host)) + log.Info("[%s] Stripping %d SSL link%s from %s", tui.Green("sslstrip"), nurls, plural, tui.Bold(res.Request.Host)) } for url, stripped := range urls { - log.Debug("Stripping url %s to %s", core.Bold(url), core.Yellow(stripped)) + log.Debug("Stripping url %s to %s", tui.Bold(url), tui.Yellow(stripped)) body = strings.Replace(body, url, stripped, -1) diff --git a/modules/http_server.go b/modules/http_server.go index 18de47c9..fba366cb 100644 --- a/modules/http_server.go +++ b/modules/http_server.go @@ -7,10 +7,12 @@ import ( "strings" "time" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/tls" + + "github.com/evilsocket/islazy/fs" + "github.com/evilsocket/islazy/tui" ) type HttpServer struct { @@ -103,7 +105,7 @@ func (httpd *HttpServer) Configure() error { fileServer := http.FileServer(http.Dir(path)) router.HandleFunc("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - log.Info("(%s) %s %s %s%s", core.Green("httpd"), core.Bold(strings.Split(r.RemoteAddr, ":")[0]), r.Method, r.Host, r.URL.Path) + log.Info("(%s) %s %s %s%s", tui.Green("httpd"), tui.Bold(strings.Split(r.RemoteAddr, ":")[0]), r.Method, r.Host, r.URL.Path) fileServer.ServeHTTP(w, r) })) @@ -121,18 +123,18 @@ func (httpd *HttpServer) Configure() error { if err, certFile = httpd.StringParam("http.server.certificate"); err != nil { return err - } else if certFile, err = core.ExpandPath(certFile); err != nil { + } else if certFile, err = fs.Expand(certFile); err != nil { return err } if err, keyFile = httpd.StringParam("http.server.key"); err != nil { return err - } else if keyFile, err = core.ExpandPath(keyFile); err != nil { + } else if keyFile, err = fs.Expand(keyFile); err != nil { return err } if certFile != "" && keyFile != "" { - if !core.Exists(certFile) || !core.Exists(keyFile) { + if !fs.Exists(certFile) || !fs.Exists(keyFile) { err, cfg := tls.CertConfigFromModule("http.server", httpd.SessionModule) if err != nil { return err diff --git a/modules/https_proxy.go b/modules/https_proxy.go index c9e17dc8..ee32b2a5 100644 --- a/modules/https_proxy.go +++ b/modules/https_proxy.go @@ -1,10 +1,11 @@ package modules import ( - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/tls" + + "github.com/evilsocket/islazy/fs" ) type HttpsProxy struct { @@ -107,11 +108,11 @@ func (p *HttpsProxy) Configure() error { return err } else if err, certFile = p.StringParam("https.proxy.certificate"); err != nil { return err - } else if certFile, err = core.ExpandPath(certFile); err != nil { + } else if certFile, err = fs.Expand(certFile); err != nil { return err } else if err, keyFile = p.StringParam("https.proxy.key"); err != nil { return err - } else if keyFile, err = core.ExpandPath(keyFile); err != nil { + } else if keyFile, err = fs.Expand(keyFile); err != nil { return err } else if err, scriptPath = p.StringParam("https.proxy.script"); err != nil { return err @@ -119,7 +120,7 @@ func (p *HttpsProxy) Configure() error { return err } - if !core.Exists(certFile) || !core.Exists(keyFile) { + if !fs.Exists(certFile) || !fs.Exists(keyFile) { err, cfg := tls.CertConfigFromModule("https.proxy", p.SessionModule) if err != nil { return err diff --git a/modules/mac_changer.go b/modules/mac_changer.go index efc1c366..ccab733c 100644 --- a/modules/mac_changer.go +++ b/modules/mac_changer.go @@ -10,6 +10,8 @@ import ( "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" + + "github.com/evilsocket/islazy/tui" ) type MacChanger struct { @@ -110,14 +112,14 @@ func (mc *MacChanger) Start() error { } return mc.SetRunning(true, func() { - log.Info("Interface mac address set to %s", core.Bold(mc.fakeMac.String())) + log.Info("Interface mac address set to %s", tui.Bold(mc.fakeMac.String())) }) } func (mc *MacChanger) Stop() error { return mc.SetRunning(false, func() { if err := mc.setMac(mc.originalMac); err == nil { - log.Info("Interface mac address restored to %s", core.Bold(mc.originalMac.String())) + log.Info("Interface mac address restored to %s", tui.Bold(mc.originalMac.String())) } else { log.Error("Error while restoring mac address: %s", err) } diff --git a/modules/mysql_server.go b/modules/mysql_server.go index 373992de..96a34b5e 100644 --- a/modules/mysql_server.go +++ b/modules/mysql_server.go @@ -8,10 +8,11 @@ import ( "net" "strings" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" + + "github.com/evilsocket/islazy/tui" ) type MySQLServer struct { @@ -103,10 +104,10 @@ func (mysql *MySQLServer) Start() error { } return mysql.SetRunning(true, func() { - log.Info("[%s] server starting on address %s", core.Green("mysql.server"), mysql.address) + log.Info("[%s] server starting on address %s", tui.Green("mysql.server"), mysql.address) for mysql.Running() { if conn, err := mysql.listener.AcceptTCP(); err != nil { - log.Warning("[%s] error while accepting tcp connection: %s", core.Green("mysql.server"), err) + log.Warning("[%s] error while accepting tcp connection: %s", tui.Green("mysql.server"), err) continue } else { defer conn.Close() @@ -117,13 +118,13 @@ func (mysql *MySQLServer) Start() error { reader := bufio.NewReader(conn) read := 0 - log.Info("[%s] connection from %s", core.Green("mysql.server"), clientAddress) + log.Info("[%s] connection from %s", tui.Green("mysql.server"), clientAddress) if _, err := conn.Write(packets.MySQLGreeting); err != nil { - log.Warning("[%s] error while writing server greeting: %s", core.Green("mysql.server"), err) + log.Warning("[%s] error while writing server greeting: %s", tui.Green("mysql.server"), err) continue } else if read, err = reader.Read(readBuffer); err != nil { - log.Warning("[%s] error while reading client message: %s", core.Green("mysql.server"), err) + log.Warning("[%s] error while reading client message: %s", tui.Green("mysql.server"), err) continue } @@ -134,38 +135,38 @@ func (mysql *MySQLServer) Start() error { loadData := string(capabilities[8]) username := string(bytes.Split(readBuffer[36:], []byte{0})[0]) - log.Info("[%s] can use LOAD DATA LOCAL: %s", core.Green("mysql.server"), loadData) - log.Info("[%s] login request username: %s", core.Green("mysql.server"), core.Bold(username)) + log.Info("[%s] can use LOAD DATA LOCAL: %s", tui.Green("mysql.server"), loadData) + log.Info("[%s] login request username: %s", tui.Green("mysql.server"), tui.Bold(username)) if _, err := conn.Write(packets.MySQLFirstResponseOK); err != nil { - log.Warning("[%s] error while writing server first response ok: %s", core.Green("mysql.server"), err) + log.Warning("[%s] error while writing server first response ok: %s", tui.Green("mysql.server"), err) continue } else if _, err := reader.Read(readBuffer); err != nil { - log.Warning("[%s] error while reading client message: %s", core.Green("mysql.server"), err) + log.Warning("[%s] error while reading client message: %s", tui.Green("mysql.server"), err) continue } else if _, err := conn.Write(packets.MySQLGetFile(mysql.infile)); err != nil { - log.Warning("[%s] error while writing server get file request: %s", core.Green("mysql.server"), err) + log.Warning("[%s] error while writing server get file request: %s", tui.Green("mysql.server"), err) continue } else if read, err = reader.Read(readBuffer); err != nil { - log.Warning("[%s] error while readind buffer: %s", core.Green("mysql.server"), err) + log.Warning("[%s] error while readind buffer: %s", tui.Green("mysql.server"), err) continue } if strings.HasPrefix(mysql.infile, "\\") { - log.Info("[%s] NTLM from '%s' relayed to %s", core.Green("mysql.server"), clientAddress, mysql.infile) + log.Info("[%s] NTLM from '%s' relayed to %s", tui.Green("mysql.server"), clientAddress, mysql.infile) } else if fileSize := read - 9; fileSize < 4 { - log.Warning("[%s] unpexpected buffer size %d", core.Green("mysql.server"), read) + log.Warning("[%s] unpexpected buffer size %d", tui.Green("mysql.server"), read) } else { - log.Info("[%s] read file ( %s ) is %d bytes", core.Green("mysql.server"), mysql.infile, fileSize) + log.Info("[%s] read file ( %s ) is %d bytes", tui.Green("mysql.server"), mysql.infile, fileSize) fileData := readBuffer[4 : read-4] if mysql.outfile == "" { log.Info("\n%s", string(fileData)) } else { - log.Info("[%s] saving to %s ...", core.Green("mysql.server"), mysql.outfile) + log.Info("[%s] saving to %s ...", tui.Green("mysql.server"), mysql.outfile) if err := ioutil.WriteFile(mysql.outfile, fileData, 0755); err != nil { - log.Warning("[%s] error while saving the file: %s", core.Green("mysql.server"), err) + log.Warning("[%s] error while saving the file: %s", tui.Green("mysql.server"), err) } } } diff --git a/modules/net_recon_show.go b/modules/net_recon_show.go index e73b2e82..f44e027c 100644 --- a/modules/net_recon_show.go +++ b/modules/net_recon_show.go @@ -6,11 +6,12 @@ import ( "sort" "time" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/packets" "github.com/dustin/go-humanize" + + "github.com/evilsocket/islazy/tui" ) var ( @@ -38,12 +39,12 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string { mac := e.HwAddress if d.Session.Lan.WasMissed(e.HwAddress) { // if endpoint was not found in ARP at least once - addr = core.Dim(addr) - mac = core.Dim(mac) + addr = tui.Dim(addr) + mac = tui.Dim(mac) } else if sinceStarted > (justJoinedTimeInterval*2) && sinceFirstSeen <= justJoinedTimeInterval { // if endpoint was first seen in the last 10 seconds - addr = core.Bold(addr) - mac = core.Bold(mac) + addr = tui.Bold(addr) + mac = tui.Bold(mac) } name := "" @@ -52,9 +53,9 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string { } else if e == d.Session.Gateway { name = "gateway" } else if e.Alias != "" { - name = core.Green(e.Alias) + name = tui.Green(e.Alias) } else if e.Hostname != "" { - name = core.Yellow(e.Hostname) + name = tui.Yellow(e.Hostname) } var traffic *packets.Traffic @@ -67,19 +68,19 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string { sinceLastSeen := time.Since(e.LastSeen) if sinceStarted > aliveTimeInterval && sinceLastSeen <= aliveTimeInterval { // if endpoint seen in the last 10 seconds - seen = core.Bold(seen) + seen = tui.Bold(seen) } else if sinceLastSeen <= presentTimeInterval { // if endpoint seen in the last 60 seconds } else { // not seen in a while - seen = core.Dim(seen) + seen = tui.Dim(seen) } row := []string{ addr, mac, name, - core.Dim(e.Vendor), + tui.Dim(e.Vendor), humanize.Bytes(traffic.Sent), humanize.Bytes(traffic.Received), seen, @@ -88,12 +89,12 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string { if !withMeta { return [][]string{row} } else if e.Meta.Empty() { - return [][]string{append(row, core.Dim("-"))} + return [][]string{append(row, tui.Dim("-"))} } metas := []string{} e.Meta.Each(func(name string, value interface{}) { - metas = append(metas, fmt.Sprintf("%s:%s", core.Green(name), core.Yellow(value.(string)))) + metas = append(metas, fmt.Sprintf("%s:%s", tui.Green(name), tui.Yellow(value.(string)))) }) sort.Strings(metas) @@ -164,13 +165,13 @@ func (d *Discovery) Show(by string, expr string) (err error) { } } - core.AsTable(os.Stdout, colNames, rows) + tui.Table(os.Stdout, colNames, rows) d.Session.Queue.Stats.RLock() fmt.Printf("\n%s %s / %s %s / %d pkts / %d errs\n\n", - core.Red("↑"), + tui.Red("↑"), humanize.Bytes(d.Session.Queue.Stats.Sent), - core.Green("↓"), + tui.Green("↓"), humanize.Bytes(d.Session.Queue.Stats.Received), d.Session.Queue.Stats.PktReceived, d.Session.Queue.Stats.Errors) diff --git a/modules/net_sniff_context.go b/modules/net_sniff_context.go index 4d9bfc23..df943c2a 100644 --- a/modules/net_sniff_context.go +++ b/modules/net_sniff_context.go @@ -4,12 +4,13 @@ import ( "os" "regexp" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/session" "github.com/google/gopacket/pcap" "github.com/google/gopacket/pcapgo" + + "github.com/evilsocket/islazy/tui" ) type SnifferContext struct { @@ -98,8 +99,8 @@ func NewSnifferContext() *SnifferContext { } var ( - no = core.Red("no") - yes = core.Green("yes") + no = tui.Red("no") + yes = tui.Green("yes") yn = map[bool]string{ true: yes, false: no, @@ -109,9 +110,9 @@ var ( func (c *SnifferContext) Log(sess *session.Session) { log.Info("Skip local packets : %s", yn[c.DumpLocal]) log.Info("Verbose : %s", yn[c.Verbose]) - log.Info("BPF Filter : '%s'", core.Yellow(c.Filter)) - log.Info("Regular expression : '%s'", core.Yellow(c.Expression)) - log.Info("File output : '%s'", core.Yellow(c.Output)) + log.Info("BPF Filter : '%s'", tui.Yellow(c.Filter)) + log.Info("Regular expression : '%s'", tui.Yellow(c.Expression)) + log.Info("File output : '%s'", tui.Yellow(c.Output)) } func (c *SnifferContext) Close() { diff --git a/modules/net_sniff_dns.go b/modules/net_sniff_dns.go index 02ff99f0..7e251b9e 100644 --- a/modules/net_sniff_dns.go +++ b/modules/net_sniff_dns.go @@ -3,10 +3,10 @@ package modules import ( "strings" - "github.com/bettercap/bettercap/core" - "github.com/google/gopacket" "github.com/google/gopacket/layers" + + "github.com/evilsocket/islazy/tui" ) func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool { @@ -41,11 +41,11 @@ func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool { ip.DstIP.String(), nil, "%s %s > %s : %s is %s", - core.W(core.BG_DGRAY+core.FG_WHITE, "dns"), + tui.Wrap(tui.BACKDARKGRAY+tui.FOREWHITE, "dns"), vIP(ip.SrcIP), vIP(ip.DstIP), - core.Yellow(hostname), - core.Dim(strings.Join(ips, ", ")), + tui.Yellow(hostname), + tui.Dim(strings.Join(ips, ", ")), ).Push() } diff --git a/modules/net_sniff_http.go b/modules/net_sniff_http.go index 3a75b96f..ba92bb5f 100644 --- a/modules/net_sniff_http.go +++ b/modules/net_sniff_http.go @@ -8,12 +8,12 @@ import ( "net/http" "strings" - "github.com/bettercap/bettercap/core" - "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/dustin/go-humanize" + + "github.com/evilsocket/islazy/tui" ) type HTTPRequest struct { @@ -126,10 +126,10 @@ func httpParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool { req.Host, toSerializableRequest(req), "%s %s %s %s%s", - core.W(core.BG_RED+core.FG_BLACK, "http"), + tui.Wrap(tui.BACKRED+tui.FOREBLACK, "http"), vIP(ip.SrcIP), - core.W(core.BG_LBLUE+core.FG_BLACK, req.Method), - core.Yellow(req.Host), + tui.Wrap(tui.BACKLIGHTBLUE+tui.FOREBLACK, req.Method), + tui.Yellow(req.Host), vURL(req.URL.String()), ).Push() @@ -143,13 +143,13 @@ func httpParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool { ip.DstIP.String(), sres, "%s %s:%d %s -> %s (%s %s)", - core.W(core.BG_RED+core.FG_BLACK, "http"), + tui.Wrap(tui.BACKRED+tui.FOREBLACK, "http"), vIP(ip.SrcIP), tcp.SrcPort, - core.Bold(res.Status), + tui.Bold(res.Status), vIP(ip.DstIP), - core.Dim(humanize.Bytes(uint64(len(sres.Body)))), - core.Yellow(sres.ContentType), + tui.Dim(humanize.Bytes(uint64(len(sres.Body)))), + tui.Yellow(sres.ContentType), ).Push() return true diff --git a/modules/net_sniff_krb5.go b/modules/net_sniff_krb5.go index 1a7df42b..aaac6ea5 100644 --- a/modules/net_sniff_krb5.go +++ b/modules/net_sniff_krb5.go @@ -3,11 +3,12 @@ package modules import ( "encoding/asn1" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/packets" "github.com/google/gopacket" "github.com/google/gopacket/layers" + + "github.com/evilsocket/islazy/tui" ) func krb5Parser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool { @@ -29,7 +30,7 @@ func krb5Parser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool { ip.DstIP.String(), nil, "%s %s -> %s : %s", - core.W(core.BG_RED+core.FG_BLACK, "krb-as-req"), + tui.Wrap(tui.BACKRED+tui.FOREBLACK, "krb-as-req"), vIP(ip.SrcIP), vIP(ip.DstIP), s, diff --git a/modules/net_sniff_mdns.go b/modules/net_sniff_mdns.go index bda764de..50f510a6 100644 --- a/modules/net_sniff_mdns.go +++ b/modules/net_sniff_mdns.go @@ -3,11 +3,12 @@ package modules import ( "strings" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/packets" "github.com/google/gopacket" "github.com/google/gopacket/layers" + + "github.com/evilsocket/islazy/tui" ) func mdnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool { @@ -22,10 +23,10 @@ func mdnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool { ip.DstIP.String(), nil, "%s %s : %s query for %s", - core.W(core.BG_DGRAY+core.FG_WHITE, "mdns"), + tui.Wrap(tui.BACKDARKGRAY+tui.FOREWHITE, "mdns"), vIP(ip.SrcIP), - core.Dim(q.Type.String()), - core.Yellow(string(q.Name)), + tui.Dim(q.Type.String()), + tui.Yellow(string(q.Name)), ).Push() } @@ -50,10 +51,10 @@ func mdnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool { ip.DstIP.String(), nil, "%s %s : %s is %s", - core.W(core.BG_DGRAY+core.FG_WHITE, "mdns"), + tui.Wrap(tui.BACKDARKGRAY+tui.FOREWHITE, "mdns"), vIP(ip.SrcIP), - core.Yellow(hostname), - core.Dim(strings.Join(ips, ", ")), + tui.Yellow(hostname), + tui.Dim(strings.Join(ips, ", ")), ).Push() } diff --git a/modules/net_sniff_ntlm.go b/modules/net_sniff_ntlm.go index 66441af0..95e572b1 100644 --- a/modules/net_sniff_ntlm.go +++ b/modules/net_sniff_ntlm.go @@ -4,11 +4,12 @@ import ( "regexp" "strings" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/packets" "github.com/google/gopacket" "github.com/google/gopacket/layers" + + "github.com/evilsocket/islazy/tui" ) var ( @@ -53,7 +54,7 @@ func ntlmParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool { ip.DstIP.String(), nil, "%s %s > %s | %s", - core.W(core.BG_DGRAY+core.FG_WHITE, "ntlm.response"), + tui.Wrap(tui.BACKDARKGRAY+tui.FOREWHITE, "ntlm.response"), vIP(ip.SrcIP), vIP(ip.DstIP), data.LcString(), diff --git a/modules/net_sniff_parsers.go b/modules/net_sniff_parsers.go index 347a96d4..086efc1e 100644 --- a/modules/net_sniff_parsers.go +++ b/modules/net_sniff_parsers.go @@ -3,12 +3,13 @@ package modules import ( "fmt" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/packets" "github.com/google/gopacket" "github.com/google/gopacket/layers" + + "github.com/evilsocket/islazy/tui" ) func tcpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) { @@ -30,12 +31,12 @@ func tcpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) { "Size": len(ip.Payload), }, "%s %s:%s > %s:%s %s", - core.W(core.BG_LBLUE+core.FG_BLACK, "tcp"), + tui.Wrap(tui.BACKLIGHTBLUE+tui.FOREBLACK, "tcp"), vIP(ip.SrcIP), vPort(tcp.SrcPort), vIP(ip.DstIP), vPort(tcp.DstPort), - core.Dim(fmt.Sprintf("%d bytes", len(ip.Payload))), + tui.Dim(fmt.Sprintf("%d bytes", len(ip.Payload))), ).Push() } } @@ -61,12 +62,12 @@ func udpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) { "Size": len(ip.Payload), }, "%s %s:%s > %s:%s %s", - core.W(core.BG_DGRAY+core.FG_WHITE, "udp"), + tui.Wrap(tui.BACKDARKGRAY+tui.FOREWHITE, "udp"), vIP(ip.SrcIP), vPort(udp.SrcPort), vIP(ip.DstIP), vPort(udp.DstPort), - core.Dim(fmt.Sprintf("%d bytes", len(ip.Payload))), + tui.Dim(fmt.Sprintf("%d bytes", len(ip.Payload))), ).Push() } } @@ -82,10 +83,10 @@ func unkParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) { "Size": len(ip.Payload), }, "%s %s > %s %s", - core.W(core.BG_DGRAY+core.FG_WHITE, pkt.TransportLayer().LayerType().String()), + tui.Wrap(tui.BACKDARKGRAY+tui.FOREWHITE, pkt.TransportLayer().LayerType().String()), vIP(ip.SrcIP), vIP(ip.DstIP), - core.Dim(fmt.Sprintf("%d bytes", len(ip.Payload))), + tui.Dim(fmt.Sprintf("%d bytes", len(ip.Payload))), ).Push() } } diff --git a/modules/net_sniff_sni.go b/modules/net_sniff_sni.go index 07a78e65..10b165d3 100644 --- a/modules/net_sniff_sni.go +++ b/modules/net_sniff_sni.go @@ -3,11 +3,12 @@ package modules import ( "fmt" - "github.com/bettercap/bettercap/core" "regexp" "github.com/google/gopacket" "github.com/google/gopacket/layers" + + "github.com/evilsocket/islazy/tui" ) // poor man's TLS Client Hello with SNI extension parser :P @@ -38,9 +39,9 @@ func sniParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool { domain, nil, "%s %s > %s", - core.W(core.BG_YELLOW+core.FG_WHITE, "sni"), + tui.Wrap(tui.BACKYELLOW+tui.FOREWHITE, "sni"), vIP(ip.SrcIP), - core.Yellow("https://"+domain), + tui.Yellow("https://"+domain), ).Push() return true diff --git a/modules/net_sniff_upnp.go b/modules/net_sniff_upnp.go index 9dc243fb..7474fb5b 100644 --- a/modules/net_sniff_upnp.go +++ b/modules/net_sniff_upnp.go @@ -3,18 +3,20 @@ package modules import ( "fmt" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/packets" "github.com/google/gopacket" "github.com/google/gopacket/layers" + + "github.com/evilsocket/islazy/str" + "github.com/evilsocket/islazy/tui" ) func upnpParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool { if data := packets.UPNPGetMeta(pkt); data != nil && len(data) > 0 { s := "" for name, value := range data { - s += fmt.Sprintf("%s:%s ", core.Blue(name), core.Yellow(value)) + s += fmt.Sprintf("%s:%s ", tui.Blue(name), tui.Yellow(value)) } NewSnifferEvent( @@ -24,10 +26,10 @@ func upnpParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool { ip.DstIP.String(), nil, "%s %s -> %s : %s", - core.W(core.BG_RED+core.FG_BLACK, "upnp"), + tui.Wrap(tui.BACKRED+tui.FOREBLACK, "upnp"), vIP(ip.SrcIP), vIP(ip.DstIP), - core.Trim(s), + str.Trim(s), ).Push() return true diff --git a/modules/net_sniff_views.go b/modules/net_sniff_views.go index b0579867..2a0239df 100644 --- a/modules/net_sniff_views.go +++ b/modules/net_sniff_views.go @@ -4,15 +4,15 @@ import ( "fmt" "net" - "github.com/google/gopacket/layers" - - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/session" + + "github.com/evilsocket/islazy/tui" + "github.com/google/gopacket/layers" ) func vIP(ip net.IP) string { if session.I.Interface.IP.Equal(ip) { - return core.Dim("local") + return tui.Dim("local") } else if session.I.Gateway.IP.Equal(ip) { return "gateway" } @@ -32,11 +32,11 @@ func vPort(p interface{}) string { sp := fmt.Sprintf("%d", p) if tcp, ok := p.(layers.TCPPort); ok { if name, found := layers.TCPPortNames[tcp]; found { - sp = core.Yellow(name) + sp = tui.Yellow(name) } } else if udp, ok := p.(layers.UDPPort); ok { if name, found := layers.UDPPortNames[udp]; found { - sp = core.Yellow(name) + sp = tui.Yellow(name) } } diff --git a/modules/packet_proxy_linux_amd64.go b/modules/packet_proxy_linux_amd64.go index a67cf8f1..c3ee0fb2 100644 --- a/modules/packet_proxy_linux_amd64.go +++ b/modules/packet_proxy_linux_amd64.go @@ -13,6 +13,9 @@ import ( "github.com/bettercap/bettercap/session" "github.com/chifflier/nfqueue-go/nfqueue" + + "github.com/evilsocket/islazy/fs" + "github.com/evilsocket/islazy/tui" ) type PacketProxy struct { @@ -141,8 +144,8 @@ func (pp *PacketProxy) Configure() (err error) { } if pp.pluginPath == "" { - return fmt.Errorf("The parameter %s can not be empty.", core.Bold("packet.proxy.plugin")) - } else if !core.Exists(pp.pluginPath) { + return fmt.Errorf("The parameter %s can not be empty.", tui.Bold("packet.proxy.plugin")) + } else if !fs.Exists(pp.pluginPath) { return fmt.Errorf("%s does not exist.", pp.pluginPath) } @@ -194,7 +197,7 @@ func (pp *PacketProxy) Start() error { } return pp.SetRunning(true, func() { - log.Info("%s started on queue number %d", core.Green("packet.proxy"), pp.queueNum) + log.Info("%s started on queue number %d", tui.Green("packet.proxy"), pp.queueNum) defer pp.destroyQueue() diff --git a/modules/syn_scan.go b/modules/syn_scan.go index a202c103..8b39e38a 100644 --- a/modules/syn_scan.go +++ b/modules/syn_scan.go @@ -7,7 +7,6 @@ import ( "sync" "time" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/packets" @@ -17,6 +16,8 @@ import ( "github.com/google/gopacket/layers" "github.com/malfunkt/iprange" + + "github.com/evilsocket/islazy/str" ) const synSourcePort = 666 @@ -55,8 +56,8 @@ func NewSynScanner(s *session.Session) *SynScanner { ss.startPort = 1 ss.endPort = 65535 - if argc > 1 && core.Trim(args[1]) != "" { - if ss.startPort, err = strconv.Atoi(core.Trim(args[1])); err != nil { + if argc > 1 && str.Trim(args[1]) != "" { + if ss.startPort, err = strconv.Atoi(str.Trim(args[1])); err != nil { return fmt.Errorf("Invalid START-PORT: %s", err) } @@ -66,8 +67,8 @@ func NewSynScanner(s *session.Session) *SynScanner { ss.endPort = ss.startPort } - if argc > 2 && core.Trim(args[2]) != "" { - if ss.endPort, err = strconv.Atoi(core.Trim(args[2])); err != nil { + if argc > 2 && str.Trim(args[2]) != "" { + if ss.endPort, err = strconv.Atoi(str.Trim(args[2])); err != nil { return fmt.Errorf("Invalid END-PORT: %s", err) } } diff --git a/modules/update.go b/modules/update.go index 814f234b..ee46cd16 100644 --- a/modules/update.go +++ b/modules/update.go @@ -11,6 +11,8 @@ import ( "github.com/bettercap/bettercap/session" "github.com/google/go-github/github" + + "github.com/evilsocket/islazy/tui" ) type UpdateModule struct { @@ -87,7 +89,7 @@ func (u *UpdateModule) Start() error { if u.versionToNum(core.Version) < u.versionToNum(*latest.TagName) { u.Session.Events.Add("update.available", latest) } else { - log.Info("you are running %s which is the latest stable version.", core.Bold(core.Version)) + log.Info("you are running %s which is the latest stable version.", tui.Bold(core.Version)) } } else { log.Error("error while fetching latest release info from GitHub: %s", err) diff --git a/modules/wifi.go b/modules/wifi.go index 65dda502..7facf0a4 100644 --- a/modules/wifi.go +++ b/modules/wifi.go @@ -8,7 +8,6 @@ import ( "sync" "time" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/packets" @@ -17,6 +16,8 @@ import ( "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/google/gopacket/pcap" + + "github.com/evilsocket/islazy/tui" ) type WiFiModule struct { @@ -209,7 +210,7 @@ func (w *WiFiModule) Configure() error { defer ihandle.CleanUp() if err = ihandle.SetRFMon(true); err != nil { - return fmt.Errorf("Error while setting interface %s in monitor mode: %s", core.Bold(w.Session.Interface.Name()), err) + return fmt.Errorf("Error while setting interface %s in monitor mode: %s", tui.Bold(w.Session.Interface.Name()), err) } else if err = ihandle.SetSnapLen(65536); err != nil { return err } else if err = ihandle.SetTimeout(pcap.BlockForever); err != nil { diff --git a/modules/wifi_ap.go b/modules/wifi_ap.go index e2b54193..68556128 100644 --- a/modules/wifi_ap.go +++ b/modules/wifi_ap.go @@ -5,11 +5,12 @@ import ( "net" "time" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" + + "github.com/evilsocket/islazy/tui" ) var errNoRecon = errors.New("Module wifi.ap requires module wifi.recon to be activated.") @@ -44,12 +45,12 @@ func (w *WiFiModule) startAp() error { w.apRunning = false }() - enc := core.Yellow("WPA2") + enc := tui.Yellow("WPA2") if !w.apConfig.Encryption { - enc = core.Green("Open") + enc = tui.Green("Open") } log.Info("Sending beacons as SSID %s (%s) on channel %d (%s).", - core.Bold(w.apConfig.SSID), + tui.Bold(w.apConfig.SSID), w.apConfig.BSSID.String(), w.apConfig.Channel, enc) diff --git a/modules/wifi_show.go b/modules/wifi_show.go index e74f76aa..74783b0b 100644 --- a/modules/wifi_show.go +++ b/modules/wifi_show.go @@ -7,10 +7,11 @@ import ( "strconv" "time" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/network" "github.com/dustin/go-humanize" + + "github.com/evilsocket/islazy/tui" ) func (w *WiFiModule) isApSelected() bool { @@ -25,22 +26,22 @@ func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) { bssid := station.HwAddress if sinceStarted > (justJoinedTimeInterval*2) && sinceFirstSeen <= justJoinedTimeInterval { // if endpoint was first seen in the last 10 seconds - bssid = core.Bold(bssid) + bssid = tui.Bold(bssid) } seen := station.LastSeen.Format("15:04:05") sinceLastSeen := time.Since(station.LastSeen) if sinceStarted > aliveTimeInterval && sinceLastSeen <= aliveTimeInterval { // if endpoint seen in the last 10 seconds - seen = core.Bold(seen) + seen = tui.Bold(seen) } else if sinceLastSeen > presentTimeInterval { // if endpoint not seen in the last 60 seconds - seen = core.Dim(seen) + seen = tui.Dim(seen) } ssid := station.ESSID() if ssid == "" { - ssid = core.Dim(ssid) + ssid = tui.Dim(ssid) } encryption := station.Encryption @@ -48,9 +49,9 @@ func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) { encryption = fmt.Sprintf("%s (%s, %s)", station.Encryption, station.Cipher, station.Authentication) } if encryption == "OPEN" || encryption == "" { - encryption = core.Green("OPEN") - ssid = core.Green(ssid) - bssid = core.Green(bssid) + encryption = tui.Green("OPEN") + ssid = tui.Green(ssid) + bssid = tui.Green(bssid) } sent := "" if station.Sent > 0 { @@ -154,7 +155,7 @@ func (w *WiFiModule) Show(by string) error { } if nrows > 0 { - core.AsTable(os.Stdout, columns, rows) + tui.Table(os.Stdout, columns, rows) } w.Session.Refresh() diff --git a/modules/wol.go b/modules/wol.go index 54be2419..8476b32e 100644 --- a/modules/wol.go +++ b/modules/wol.go @@ -5,12 +5,14 @@ import ( "net" "regexp" - "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" "github.com/google/gopacket/layers" + + "github.com/evilsocket/islazy/str" + "github.com/evilsocket/islazy/tui" ) var ( @@ -52,7 +54,7 @@ func NewWOL(s *session.Session) *WOL { func parseMAC(args []string) (string, error) { mac := "ff:ff:ff:ff:ff:ff" if len(args) == 1 { - tmp := core.Trim(args[0]) + tmp := str.Trim(args[0]) if tmp != "" { if !reMAC.MatchString(tmp) { return "", fmt.Errorf("%s is not a valid MAC address.", tmp) @@ -103,7 +105,7 @@ func (w *WOL) wolETH(mac string) error { defer w.SetRunning(false, nil) payload := buildPayload(mac) - log.Info("Sending %d bytes of ethernet WOL packet to %s", len(payload), core.Bold(mac)) + log.Info("Sending %d bytes of ethernet WOL packet to %s", len(payload), tui.Bold(mac)) eth := layers.Ethernet{ SrcMAC: w.Session.Interface.HW, DstMAC: layers.EthernetBroadcast, @@ -124,7 +126,7 @@ func (w *WOL) wolUDP(mac string) error { defer w.SetRunning(false, nil) payload := buildPayload(mac) - log.Info("Sending %d bytes of UDP WOL packet to %s", len(payload), core.Bold(mac)) + log.Info("Sending %d bytes of UDP WOL packet to %s", len(payload), tui.Bold(mac)) eth := layers.Ethernet{ SrcMAC: w.Session.Interface.HW, diff --git a/network/aliases.go b/network/aliases.go index 84e238f4..931e08fe 100644 --- a/network/aliases.go +++ b/network/aliases.go @@ -8,10 +8,11 @@ import ( "strings" "sync" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/fs" + "github.com/evilsocket/islazy/str" ) -var fileName, _ = core.ExpandPath("~/bettercap.aliases") +var fileName, _ = fs.Expand("~/bettercap.aliases") type Aliases struct { sync.Mutex @@ -24,7 +25,7 @@ func LoadAliases() (err error, aliases *Aliases) { data: make(map[string]string), } - if core.Exists(fileName) { + if fs.Exists(fileName) { var file *os.File file, err = os.Open(fileName) @@ -37,8 +38,8 @@ func LoadAliases() (err error, aliases *Aliases) { for scanner.Scan() { line := scanner.Text() parts := strings.SplitN(line, " ", 2) - mac := core.Trim(parts[0]) - alias := core.Trim(parts[1]) + mac := str.Trim(parts[0]) + alias := str.Trim(parts[1]) aliases.data[mac] = alias } } diff --git a/network/lan_endpoint.go b/network/lan_endpoint.go index 5d3638cc..025995cb 100644 --- a/network/lan_endpoint.go +++ b/network/lan_endpoint.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/tui" ) type OnHostResolvedCallback func(e *Endpoint) @@ -152,7 +152,7 @@ func (t *Endpoint) String() string { } else if t.Hostname == "" { return fmt.Sprintf("%s%s ( %s )", ipPart, t.HwAddress, t.Vendor) } - return fmt.Sprintf("%s%s ( %s ) - %s", ipPart, t.HwAddress, t.Vendor, core.Bold(t.Hostname)) + return fmt.Sprintf("%s%s ( %s ) - %s", ipPart, t.HwAddress, t.Vendor, tui.Bold(t.Hostname)) } func (t *Endpoint) OnMeta(meta map[string]string) { diff --git a/network/net.go b/network/net.go index a69a6bde..9deea45b 100644 --- a/network/net.go +++ b/network/net.go @@ -7,7 +7,7 @@ import ( "regexp" "strings" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/str" "github.com/malfunkt/iprange" ) @@ -71,7 +71,7 @@ func ParseTargets(targets string, aliasMap *Aliases) (ips []net.IP, macs []net.H ips = make([]net.IP, 0) macs = make([]net.HardwareAddr, 0) - if targets = core.Trim(targets); targets == "" { + if targets = str.Trim(targets); targets == "" { return } @@ -210,7 +210,7 @@ func FindInterface(name string) (*Endpoint, error) { if err != nil { return nil, err } - name = core.Trim(name) + name = str.Trim(name) if name != "" { return findInterfaceByName(name, ifaces) } diff --git a/network/net_gateway_android.go b/network/net_gateway_android.go index d24e2d43..76ba57f9 100644 --- a/network/net_gateway_android.go +++ b/network/net_gateway_android.go @@ -11,7 +11,7 @@ func FindGateway(iface *Endpoint) (*Endpoint, error) { return nil, err } - gw := core.Trim(output) + gw := str.Trim(output) if IPv4Validator.MatchString(gw) { // we have the address, now we need its mac mac, err := ArpLookup(iface.Name(), gw, false) diff --git a/packets/mdns.go b/packets/mdns.go index 85246247..5d931181 100644 --- a/packets/mdns.go +++ b/packets/mdns.go @@ -4,7 +4,7 @@ import ( "net" "strings" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/str" "github.com/google/gopacket" "github.com/google/gopacket/layers" @@ -44,7 +44,7 @@ func MDNSGetMeta(pkt gopacket.Packet) map[string]string { for _, raw := range answer.TXTs { if value := string(raw); strings.Contains(value, "=") { parts := strings.SplitN(value, "=", 2) - meta["mdns:"+core.Trim(parts[0])] = core.Trim(parts[1]) + meta["mdns:"+str.Trim(parts[0])] = str.Trim(parts[1]) } } } diff --git a/packets/nbns.go b/packets/nbns.go index 677e83e3..7b2721a6 100644 --- a/packets/nbns.go +++ b/packets/nbns.go @@ -1,7 +1,7 @@ package packets import ( - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/str" "github.com/google/gopacket" "github.com/google/gopacket/layers" @@ -28,7 +28,7 @@ func NBNSGetMeta(pkt gopacket.Packet) map[string]string { if ludp := pkt.Layer(layers.LayerTypeUDP); ludp != nil { if udp := ludp.(*layers.UDP); udp != nil && udp.SrcPort == NBNSPort && len(udp.Payload) >= NBNSMinRespSize { return map[string]string{ - "nbns:hostname": core.Trim(string(udp.Payload[57:72])), + "nbns:hostname": str.Trim(string(udp.Payload[57:72])), } } } diff --git a/packets/upnp.go b/packets/upnp.go index 6dc39d86..fb9aae86 100644 --- a/packets/upnp.go +++ b/packets/upnp.go @@ -9,7 +9,7 @@ import ( // "net/url" "strings" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/str" "github.com/google/gopacket" "github.com/google/gopacket/layers" @@ -39,7 +39,7 @@ func UPNPGetMeta(pkt gopacket.Packet) map[string]string { meta := make(map[string]string) for name, values := range response.Header { if name != "Cache-Control" && len(values) > 0 { - if data := core.Trim(strings.Join(values, ", ")); data != "" { + if data := str.Trim(strings.Join(values, ", ")); data != "" { meta["upnp:"+name] = data } diff --git a/session/environment.go b/session/environment.go index a47496bd..7f8d48b0 100644 --- a/session/environment.go +++ b/session/environment.go @@ -8,7 +8,7 @@ import ( "strconv" "sync" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/fs" ) type EnvironmentChangedCallback func(newValue string) @@ -26,8 +26,8 @@ func NewEnvironment(envFile string) (*Environment, error) { } if envFile != "" { - envFile, _ := core.ExpandPath(envFile) - if core.Exists(envFile) { + envFile, _ := fs.Expand(envFile) + if fs.Exists(envFile) { if err := env.Load(envFile); err != nil { return nil, err } diff --git a/session/events.go b/session/events.go index 5c986073..5d05c1b2 100644 --- a/session/events.go +++ b/session/events.go @@ -7,7 +7,8 @@ import ( "sync" "time" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/log" + "github.com/evilsocket/islazy/tui" ) type Event struct { @@ -17,7 +18,7 @@ type Event struct { } type LogMessage struct { - Level int + Level log.Verbosity Message string } @@ -30,10 +31,10 @@ func NewEvent(tag string, data interface{}) Event { } func (e Event) Label() string { - log := e.Data.(LogMessage) - label := core.LogLabels[log.Level] - color := core.LogColors[log.Level] - return color + label + core.RESET + m := e.Data.(LogMessage) + label := log.LevelNames[m.Level] + color := log.LevelColors[m.Level] + return color + label + tui.RESET } type EventPool struct { @@ -114,10 +115,10 @@ func (p *EventPool) Add(tag string, data interface{}) { } } -func (p *EventPool) Log(level int, format string, args ...interface{}) { - if level == core.DEBUG && !p.debug { +func (p *EventPool) Log(level log.Verbosity, format string, args ...interface{}) { + if level == log.DEBUG && !p.debug { return - } else if level < core.ERROR && p.silent { + } else if level < log.ERROR && p.silent { return } @@ -128,7 +129,7 @@ func (p *EventPool) Log(level int, format string, args ...interface{}) { message, }) - if level == core.FATAL { + if level == log.FATAL { fmt.Fprintf(os.Stderr, "%s\n", message) os.Exit(1) } diff --git a/session/module.go b/session/module.go index b57b7b59..f0c877bd 100644 --- a/session/module.go +++ b/session/module.go @@ -7,7 +7,8 @@ import ( "sync" "time" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/str" + "github.com/evilsocket/islazy/tui" ) type Module interface { @@ -66,7 +67,7 @@ func (m SessionModule) ListParam(name string) (err error, values []string) { } else { parts := strings.Split(list, ",") for _, part := range parts { - part = core.Trim(part) + part = str.Trim(part) if part != "" { values = append(values, part) } @@ -169,7 +170,7 @@ func (m *SessionModule) SetRunning(running bool, cb func()) error { case <-done: return nil case <-time.After(10 * time.Second): - fmt.Printf("%s: Stopping module %s timed out.\n", core.Yellow(core.Bold("WARNING")), m.Name) + fmt.Printf("%s: Stopping module %s timed out.\n", tui.Yellow(tui.Bold("WARNING")), m.Name) } } } diff --git a/session/module_handler.go b/session/module_handler.go index 1544c182..422963a6 100644 --- a/session/module_handler.go +++ b/session/module_handler.go @@ -6,7 +6,7 @@ import ( "regexp" "strconv" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/tui" ) const IPv4Validator = `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$` @@ -34,7 +34,7 @@ func NewModuleHandler(name string, expr string, desc string, exec func(args []st } func (h *ModuleHandler) Help(padding int) string { - return fmt.Sprintf(" "+core.Bold("%"+strconv.Itoa(padding)+"s")+" : %s\n", h.Name, h.Description) + return fmt.Sprintf(" "+tui.Bold("%"+strconv.Itoa(padding)+"s")+" : %s\n", h.Name, h.Description) } func (h *ModuleHandler) Parse(line string) (bool, []string) { diff --git a/session/module_param.go b/session/module_param.go index 51ebbee7..dd38fc95 100644 --- a/session/module_param.go +++ b/session/module_param.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/tui" ) type ParamType int @@ -60,7 +60,7 @@ func NewIntParameter(name string, def_value string, desc string) *ModuleParam { func (p ModuleParam) Validate(value string) (error, interface{}) { if p.Validator != nil { if !p.Validator.MatchString(value) { - return fmt.Errorf("Parameter %s not valid: '%s' does not match rule '%s'.", core.Bold(p.Name), value, p.Validator.String()), nil + return fmt.Errorf("Parameter %s not valid: '%s' does not match rule '%s'.", tui.Bold(p.Name), value, p.Validator.String()), nil } } @@ -105,14 +105,14 @@ func (p ModuleParam) Get(s *Session) (error, interface{}) { } func (p ModuleParam) Dump(padding int) string { - return fmt.Sprintf(" "+core.YELLOW+"%"+strconv.Itoa(padding)+"s"+core.RESET+ + return fmt.Sprintf(" "+tui.YELLOW+"%"+strconv.Itoa(padding)+"s"+tui.RESET+ " : %s\n", p.Name, p.Value) } func (p ModuleParam) Help(padding int) string { - return fmt.Sprintf(" "+core.YELLOW+"%"+strconv.Itoa(padding)+"s"+core.RESET+ + return fmt.Sprintf(" "+tui.YELLOW+"%"+strconv.Itoa(padding)+"s"+tui.RESET+ " : "+ - "%s "+core.DIM+"(default=%s"+core.RESET+")\n", p.Name, p.Description, p.Value) + "%s "+tui.DIM+"(default=%s"+tui.RESET+")\n", p.Name, p.Description, p.Value) } func (p ModuleParam) Register(s *Session) { diff --git a/session/prompt.go b/session/prompt.go index 9c619440..936cd7c8 100644 --- a/session/prompt.go +++ b/session/prompt.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/tui" "github.com/dustin/go-humanize" ) @@ -16,22 +16,22 @@ const ( var ( // these are here because if colors are disabled, - // we need the updated core.* variables + // we need the updated tui.* variables effects = map[string]string{ - "{bold}": core.BOLD, - "{dim}": core.DIM, - "{r}": core.RED, - "{g}": core.GREEN, - "{b}": core.BLUE, - "{y}": core.YELLOW, - "{fb}": core.FG_BLACK, - "{fw}": core.FG_WHITE, - "{bdg}": core.BG_DGRAY, - "{br}": core.BG_RED, - "{bg}": core.BG_GREEN, - "{by}": core.BG_YELLOW, - "{blb}": core.BG_LBLUE, // Ziggy this is for you <3 - "{reset}": core.RESET, + "{bold}": tui.BOLD, + "{dim}": tui.DIM, + "{r}": tui.RED, + "{g}": tui.GREEN, + "{b}": tui.BLUE, + "{y}": tui.YELLOW, + "{fb}": tui.FOREBLACK, + "{fw}": tui.FOREWHITE, + "{bdg}": tui.BACKDARKGRAY, + "{br}": tui.BACKRED, + "{bg}": tui.BACKGREEN, + "{by}": tui.BACKYELLOW, + "{blb}": tui.BACKLIGHTBLUE, // Ziggy this is for you <3 + "{reset}": tui.RESET, } PromptCallbacks = map[string]func(s *Session) string{ "{cidr}": func(s *Session) string { @@ -80,8 +80,8 @@ func (p Prompt) Render(s *Session) string { } // make sure an user error does not screw all terminal - if !strings.HasPrefix(prompt, core.RESET) { - prompt += core.RESET + if !strings.HasPrefix(prompt, tui.RESET) { + prompt += tui.RESET } return prompt diff --git a/session/session.go b/session/session.go index 20366c0b..a372688e 100644 --- a/session/session.go +++ b/session/session.go @@ -22,6 +22,11 @@ import ( "github.com/bettercap/bettercap/packets" "github.com/adrianmo/go-nmea" + + "github.com/evilsocket/islazy/fs" + "github.com/evilsocket/islazy/log" + "github.com/evilsocket/islazy/str" + "github.com/evilsocket/islazy/tui" ) const ( @@ -108,7 +113,10 @@ func New() (*Session, error) { return nil, err } - core.InitSwag(*s.Options.NoColors) + if *s.Options.NoColors || !tui.Effects() { + tui.Disable() + log.NoEffects = true + } if *s.Options.CpuProfile != "" { if f, err := os.Create(*s.Options.CpuProfile); err != nil { @@ -169,7 +177,7 @@ func (s *Session) Close() { s.Firewall.Restore() if *s.Options.EnvFile != "" { - envFile, _ := core.ExpandPath(*s.Options.EnvFile) + envFile, _ := fs.Expand(*s.Options.EnvFile) if err := s.Env.Save(envFile); err != nil { fmt.Printf("error while storing the environment to %s: %s", envFile, err) } @@ -215,7 +223,7 @@ func (s *Session) Start() error { } if s.Gateway, err = network.FindGateway(s.Interface); err != nil { - s.Events.Log(core.WARNING, "%s", err.Error()) + s.Events.Log(log.WARNING, "%s", err.Error()) } if s.Gateway == nil || s.Gateway.IpAddress == s.Interface.IpAddress { @@ -305,13 +313,13 @@ func (s *Session) RunCaplet(filename string) error { } func parseCapletCommand(line string) (is bool, caplet *caplets.Caplet, argv []string) { - file := core.Trim(line) + file := str.Trim(line) parts := strings.Split(file, " ") argc := len(parts) argv = make([]string, 0) // check for any arguments if argc > 1 { - file = core.Trim(parts[0]) + file = str.Trim(parts[0]) if argc >= 2 { argv = parts[1:] } @@ -325,7 +333,7 @@ func parseCapletCommand(line string) (is bool, caplet *caplets.Caplet, argv []st } func (s *Session) Run(line string) error { - line = core.TrimRight(line) + line = str.TrimRight(line) // remove extra spaces after the first command // so that 'arp.spoof on' is normalized // to 'arp.spoof on' (fixes #178) @@ -365,5 +373,5 @@ func (s *Session) Run(line string) error { return nil } - return fmt.Errorf("unknown or invalid syntax \"%s%s%s\", type %shelp%s for the help menu.", core.BOLD, line, core.RESET, core.BOLD, core.RESET) + return fmt.Errorf("unknown or invalid syntax \"%s%s%s\", type %shelp%s for the help menu.", tui.BOLD, line, tui.RESET, tui.BOLD, tui.RESET) } diff --git a/session/session_core_handlers.go b/session/session_core_handlers.go index b5143431..c2317d49 100644 --- a/session/session_core_handlers.go +++ b/session/session_core_handlers.go @@ -14,6 +14,8 @@ import ( "github.com/bettercap/bettercap/network" "github.com/bettercap/readline" + "github.com/evilsocket/islazy/str" + "github.com/evilsocket/islazy/tui" ) func (s *Session) generalHelp() { @@ -29,10 +31,10 @@ func (s *Session) generalHelp() { pad := "%" + strconv.Itoa(maxLen) + "s" for _, h := range s.CoreHandlers { - fmt.Printf(" "+core.Yellow(pad)+" : %s\n", h.Name, h.Description) + fmt.Printf(" "+tui.Yellow(pad)+" : %s\n", h.Name, h.Description) } - fmt.Println(core.Bold("\nModules\n")) + fmt.Println(tui.Bold("\nModules\n")) maxLen = 0 for _, m := range s.Modules { @@ -46,11 +48,11 @@ func (s *Session) generalHelp() { for _, m := range s.Modules { status := "" if m.Running() { - status = core.Green("running") + status = tui.Green("running") } else { - status = core.Red("not running") + status = tui.Red("not running") } - fmt.Printf(" "+core.Yellow(pad)+" > %s\n", m.Name(), status) + fmt.Printf(" "+tui.Yellow(pad)+" > %s\n", m.Name(), status) } fmt.Println() @@ -65,11 +67,11 @@ func (s *Session) moduleHelp(filter string) error { fmt.Println() status := "" if m.Running() { - status = core.Green("running") + status = tui.Green("running") } else { - status = core.Red("not running") + status = tui.Red("not running") } - fmt.Printf("%s (%s): %s\n\n", core.Yellow(m.Name()), status, core.Dim(m.Description())) + fmt.Printf("%s (%s): %s\n\n", tui.Yellow(m.Name()), status, tui.Dim(m.Description())) maxLen := 0 handlers := m.Handlers() @@ -114,7 +116,7 @@ func (s *Session) moduleHelp(filter string) error { func (s *Session) helpHandler(args []string, sess *Session) error { filter := "" if len(args) == 2 { - filter = core.Trim(args[1]) + filter = str.Trim(args[1]) } if filter == "" { @@ -134,13 +136,13 @@ func (s *Session) activeHandler(args []string, sess *Session) error { continue } - fmt.Printf("%s (%s)\n", core.Bold(m.Name()), core.Dim(m.Description())) + fmt.Printf("%s (%s)\n", tui.Bold(m.Name()), tui.Dim(m.Description())) params := m.Parameters() if len(params) > 0 { fmt.Println() for _, p := range params { _, val := s.Env.Get(p.Name) - fmt.Printf(" %s : %s\n", core.Yellow(p.Name), val) + fmt.Printf(" %s : %s\n", tui.Yellow(p.Name), val) } } @@ -237,7 +239,7 @@ func (s *Session) readHandler(args []string, sess *Session) error { fmt.Printf("%s ", prompt) value, _ := reader.ReadString('\n') - value = core.Trim(value) + value = str.Trim(value) if value == "\"\"" { value = "" } @@ -271,7 +273,7 @@ func (s *Session) shHandler(args []string, sess *Session) error { func (s *Session) aliasHandler(args []string, sess *Session) error { mac := args[0] - alias := core.Trim(args[1]) + alias := str.Trim(args[1]) if s.Lan.SetAliasFor(mac, alias) { return nil @@ -291,7 +293,7 @@ func (s *Session) registerCoreHandlers() { "List available commands or show module specific help if no module name is provided.", s.helpHandler), readline.PcItem("help", readline.PcItemDynamic(func(prefix string) []string { - prefix = core.Trim(prefix[4:]) + prefix = str.Trim(prefix[4:]) modNames := []string{""} for _, m := range s.Modules { if prefix == "" || strings.HasPrefix(m.Name(), prefix) { @@ -324,7 +326,7 @@ func (s *Session) registerCoreHandlers() { "Get the value of variable NAME, use * alone for all, or NAME* as a wildcard.", s.getHandler), readline.PcItem("get", readline.PcItemDynamic(func(prefix string) []string { - prefix = core.Trim(prefix[3:]) + prefix = str.Trim(prefix[3:]) varNames := []string{""} for key := range s.Env.Data { if prefix == "" || strings.HasPrefix(key, prefix) { @@ -339,7 +341,7 @@ func (s *Session) registerCoreHandlers() { "Set the VALUE of variable NAME.", s.setHandler), readline.PcItem("set", readline.PcItemDynamic(func(prefix string) []string { - prefix = core.Trim(prefix[3:]) + prefix = str.Trim(prefix[3:]) varNames := []string{""} for key := range s.Env.Data { if prefix == "" || strings.HasPrefix(key, prefix) { @@ -366,7 +368,7 @@ func (s *Session) registerCoreHandlers() { "Load and run this caplet in the current session.", s.includeHandler), readline.PcItem("include", readline.PcItemDynamic(func(prefix string) []string { - prefix = core.Trim(prefix[8:]) + prefix = str.Trim(prefix[8:]) if prefix == "" { prefix = "." } @@ -386,7 +388,7 @@ func (s *Session) registerCoreHandlers() { "Assign an alias to a given endpoint given its MAC address.", s.aliasHandler), readline.PcItem("alias", readline.PcItemDynamic(func(prefix string) []string { - prefix = core.Trim(prefix[5:]) + prefix = str.Trim(prefix[5:]) macs := []string{""} s.Lan.EachHost(func(mac string, e *network.Endpoint) { if prefix == "" || strings.HasPrefix(mac, prefix) { diff --git a/session/session_parse.go b/session/session_parse.go index f3f05f3d..98c43b24 100644 --- a/session/session_parse.go +++ b/session/session_parse.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/bettercap/bettercap/core" + "github.com/evilsocket/islazy/str" ) func ParseCommands(line string) []string { @@ -62,7 +62,7 @@ func ParseCommands(line string) []string { cmds := make([]string, 0) for _, cmd := range args { - cmd = core.Trim(cmd) + cmd = str.Trim(cmd) if cmd != "" || (len(cmd) > 0 && cmd[0] != '#') { cmds = append(cmds, cmd) } diff --git a/session/session_setup.go b/session/session_setup.go index cec63684..3992c8e7 100644 --- a/session/session_setup.go +++ b/session/session_setup.go @@ -9,9 +9,11 @@ import ( "time" "github.com/bettercap/bettercap/caplets" - "github.com/bettercap/bettercap/core" "github.com/bettercap/readline" + + "github.com/evilsocket/islazy/fs" + "github.com/evilsocket/islazy/log" ) func containsCapitals(s string) bool { @@ -66,7 +68,7 @@ func (s *Session) setupReadline() (err error) { history := "" if !*s.Options.NoHistory { - history, _ = core.ExpandPath(HistoryFile) + history, _ = fs.Expand(HistoryFile) } cfg := readline.Config{ @@ -113,7 +115,7 @@ func (s *Session) setupSignals() { go func() { <-c fmt.Println() - s.Events.Log(core.WARNING, "Got SIGTERM") + s.Events.Log(log.WARNING, "Got SIGTERM") s.Close() os.Exit(0) }() diff --git a/vendor/github.com/elazarl/goproxy/README.md b/vendor/github.com/elazarl/goproxy/README.md index 50d91efe..19ffe05b 100644 --- a/vendor/github.com/elazarl/goproxy/README.md +++ b/vendor/github.com/elazarl/goproxy/README.md @@ -8,8 +8,8 @@ Package goproxy provides a customizable HTTP proxy library for Go (golang), It supports regular HTTP proxy, HTTPS through CONNECT, and "hijacking" HTTPS connection using "Man in the Middle" style attack. -The intent of the proxy, is to be usable with reasonable amount of traffic -yet, customizable and programmable. +The intent of the proxy is to be usable with reasonable amount of traffic, +yet customizable and programmable. The proxy itself is simply a `net/http` handler. @@ -22,7 +22,7 @@ For example, the URL you should use as proxy when running `./bin/basic` is ## Mailing List -New features would be discussed on the [mailing list](https://groups.google.com/forum/#!forum/goproxy-dev) +New features will be discussed on the [mailing list](https://groups.google.com/forum/#!forum/goproxy-dev) before their development. ## Latest Stable Release @@ -32,13 +32,13 @@ Get the latest goproxy from `gopkg.in/elazarl/goproxy.v1`. # Why not Fiddler2? Fiddler is an excellent software with similar intent. However, Fiddler is not -as customizable as goproxy intend to be. The main difference is, Fiddler is not +as customizable as goproxy intends to be. The main difference is, Fiddler is not intended to be used as a real proxy. A possible use case that suits goproxy but -not Fiddler, is, gathering statistics on page load times for a certain website over a week. +not Fiddler, is gathering statistics on page load times for a certain website over a week. With goproxy you could ask all your users to set their proxy to a dedicated machine running a -goproxy server. Fiddler is a GUI app not designed to be ran like a server for multiple users. +goproxy server. Fiddler is a GUI app not designed to be run like a server for multiple users. # A taste of goproxy @@ -90,12 +90,12 @@ proxy.OnRequest(goproxy.DstHostIs("www.reddit.com")).DoFunc( }) ``` -`DstHostIs` returns a `ReqCondition`, that is a function receiving a `Request` and returning a boolean -we will only process requests that matches the condition. `DstHostIs("www.reddit.com")` will return +`DstHostIs` returns a `ReqCondition`, that is a function receiving a `Request` and returning a boolean. +We will only process requests that match the condition. `DstHostIs("www.reddit.com")` will return a `ReqCondition` accepting only requests directed to "www.reddit.com". `DoFunc` will receive a function that will preprocess the request. We can change the request, or -return a response. If the time is between 8:00am and 17:00pm, we will neglect the request, and +return a response. If the time is between 8:00am and 17:00pm, we will reject the request, and return a precanned text response saying "do not waste your time". See additional examples in the examples directory. @@ -108,14 +108,14 @@ See additional examples in the examples directory. # License -I put the software temporarily under the Go-compatible BSD license, -if this prevents someone from using the software, do let me know and I'll consider changing it. +I put the software temporarily under the Go-compatible BSD license. +If this prevents someone from using the software, do let me know and I'll consider changing it. At any rate, user feedback is very important for me, so I'll be delighted to know if you're using this package. # Beta Software -I've received a positive feedback from a few people who use goproxy in production settings. +I've received positive feedback from a few people who use goproxy in production settings. I believe it is good enough for usage. I'll try to keep reasonable backwards compatibility. In case of a major API change, diff --git a/vendor/github.com/evilsocket/islazy/LICENSE.md b/vendor/github.com/evilsocket/islazy/LICENSE.md new file mode 100644 index 00000000..54c62964 --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/LICENSE.md @@ -0,0 +1,596 @@ +GNU GENERAL PUBLIC LICENSE +========================== + +Version 3, 29 June 2007 + +Copyright © 2007 Free Software Foundation, Inc. <> + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +## Preamble + +The GNU General Public License is a free, copyleft license for software and other +kinds of works. + +The licenses for most software and other practical works are designed to take away +your freedom to share and change the works. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change all versions of a +program--to make sure it remains free software for all its users. We, the Free +Software Foundation, use the GNU General Public License for most of our software; it +applies also to any other work released this way by its authors. You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General +Public Licenses are designed to make sure that you have the freedom to distribute +copies of free software (and charge for them if you wish), that you receive source +code or can get it if you want it, that you can change the software or use pieces of +it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or +asking you to surrender the rights. Therefore, you have certain responsibilities if +you distribute copies of the software, or if you modify it: responsibilities to +respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, +you must pass on to the recipients the same freedoms that you received. You must make +sure that they, too, receive or can get the source code. And you must show them these +terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: (1) assert +copyright on the software, and (2) offer you this License giving you legal permission +to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is +no warranty for this free software. For both users' and authors' sake, the GPL +requires that modified versions be marked as changed, so that their problems will not +be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of +the software inside them, although the manufacturer can do so. This is fundamentally +incompatible with the aim of protecting users' freedom to change the software. The +systematic pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we have designed +this version of the GPL to prohibit the practice for those products. If such problems +arise substantially in other domains, we stand ready to extend this provision to +those domains in future versions of the GPL, as needed to protect the freedom of +users. + +Finally, every program is threatened constantly by software patents. States should +not allow patents to restrict development and use of software on general-purpose +computers, but in those that do, we wish to avoid the special danger that patents +applied to a free program could make it effectively proprietary. To prevent this, the +GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. + +## TERMS AND CONDITIONS + +### 0. Definitions. + +“This License” refers to version 3 of the GNU General Public License. + +“Copyright” also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + +“The Program” refers to any copyrightable work licensed under this +License. Each licensee is addressed as “you”. “Licensees” and +“recipients” may be individuals or organizations. + +To “modify” a work means to copy from or adapt all or part of the work in +a fashion requiring copyright permission, other than the making of an exact copy. The +resulting work is called a “modified version” of the earlier work or a +work “based on” the earlier work. + +A “covered work” means either the unmodified Program or a work based on +the Program. + +To “propagate” a work means to do anything with it that, without +permission, would make you directly or secondarily liable for infringement under +applicable copyright law, except executing it on a computer or modifying a private +copy. Propagation includes copying, distribution (with or without modification), +making available to the public, and in some countries other activities as well. + +To “convey” a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through a computer +network, with no transfer of a copy, is not conveying. + +An interactive user interface displays “Appropriate Legal Notices” to the +extent that it includes a convenient and prominently visible feature that (1) +displays an appropriate copyright notice, and (2) tells the user that there is no +warranty for the work (except to the extent that warranties are provided), that +licensees may convey the work under this License, and how to view a copy of this +License. If the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + +### 1. Source Code. + +The “source code” for a work means the preferred form of the work for +making modifications to it. “Object code” means any non-source form of a +work. + +A “Standard Interface” means an interface that either is an official +standard defined by a recognized standards body, or, in the case of interfaces +specified for a particular programming language, one that is widely used among +developers working in that language. + +The “System Libraries” of an executable work include anything, other than +the work as a whole, that (a) is included in the normal form of packaging a Major +Component, but which is not part of that Major Component, and (b) serves only to +enable use of the work with that Major Component, or to implement a Standard +Interface for which an implementation is available to the public in source code form. +A “Major Component”, in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system (if any) on which +the executable work runs, or a compiler used to produce the work, or an object code +interpreter used to run it. + +The “Corresponding Source” for a work in object code form means all the +source code needed to generate, install, and (for an executable work) run the object +code and to modify the work, including scripts to control those activities. However, +it does not include the work's System Libraries, or general-purpose tools or +generally available free programs which are used unmodified in performing those +activities but which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for the work, and +the source code for shared libraries and dynamically linked subprograms that the work +is specifically designed to require, such as by intimate data communication or +control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate +automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. + +### 2. Basic Permissions. + +All rights granted under this License are granted for the term of copyright on the +Program, and are irrevocable provided the stated conditions are met. This License +explicitly affirms your unlimited permission to run the unmodified Program. The +output from running a covered work is covered by this License only if the output, +given its content, constitutes a covered work. This License acknowledges your rights +of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without +conditions so long as your license otherwise remains in force. You may convey covered +works to others for the sole purpose of having them make modifications exclusively +for you, or provide you with facilities for running those works, provided that you +comply with the terms of this License in conveying all material for which you do not +control copyright. Those thus making or running the covered works for you must do so +exclusively on your behalf, under your direction and control, on terms that prohibit +them from making any copies of your copyrighted material outside their relationship +with you. + +Conveying under any other circumstances is permitted solely under the conditions +stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological measure under any +applicable law fulfilling obligations under article 11 of the WIPO copyright treaty +adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention +of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of +technological measures to the extent such circumvention is effected by exercising +rights under this License with respect to the covered work, and you disclaim any +intention to limit operation or modification of the work as a means of enforcing, +against the work's users, your or third parties' legal rights to forbid circumvention +of technological measures. + +### 4. Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you receive it, in any +medium, provided that you conspicuously and appropriately publish on each copy an +appropriate copyright notice; keep intact all notices stating that this License and +any non-permissive terms added in accord with section 7 apply to the code; keep +intact all notices of the absence of any warranty; and give all recipients a copy of +this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer +support or warranty protection for a fee. + +### 5. Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to produce it from +the Program, in the form of source code under the terms of section 4, provided that +you also meet all of these conditions: + +* **a)** The work must carry prominent notices stating that you modified it, and giving a +relevant date. +* **b)** The work must carry prominent notices stating that it is released under this +License and any conditions added under section 7. This requirement modifies the +requirement in section 4 to “keep intact all notices”. +* **c)** You must license the entire work, as a whole, under this License to anyone who +comes into possession of a copy. This License will therefore apply, along with any +applicable section 7 additional terms, to the whole of the work, and all its parts, +regardless of how they are packaged. This License gives no permission to license the +work in any other way, but it does not invalidate such permission if you have +separately received it. +* **d)** If the work has interactive user interfaces, each must display Appropriate Legal +Notices; however, if the Program has interactive interfaces that do not display +Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are +not by their nature extensions of the covered work, and which are not combined with +it such as to form a larger program, in or on a volume of a storage or distribution +medium, is called an “aggregate” if the compilation and its resulting +copyright are not used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work in an aggregate +does not cause this License to apply to the other parts of the aggregate. + +### 6. Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms of sections 4 and +5, provided that you also convey the machine-readable Corresponding Source under the +terms of this License, in one of these ways: + +* **a)** Convey the object code in, or embodied in, a physical product (including a +physical distribution medium), accompanied by the Corresponding Source fixed on a +durable physical medium customarily used for software interchange. +* **b)** Convey the object code in, or embodied in, a physical product (including a +physical distribution medium), accompanied by a written offer, valid for at least +three years and valid for as long as you offer spare parts or customer support for +that product model, to give anyone who possesses the object code either (1) a copy of +the Corresponding Source for all the software in the product that is covered by this +License, on a durable physical medium customarily used for software interchange, for +a price no more than your reasonable cost of physically performing this conveying of +source, or (2) access to copy the Corresponding Source from a network server at no +charge. +* **c)** Convey individual copies of the object code with a copy of the written offer to +provide the Corresponding Source. This alternative is allowed only occasionally and +noncommercially, and only if you received the object code with such an offer, in +accord with subsection 6b. +* **d)** Convey the object code by offering access from a designated place (gratis or for +a charge), and offer equivalent access to the Corresponding Source in the same way +through the same place at no further charge. You need not require recipients to copy +the Corresponding Source along with the object code. If the place to copy the object +code is a network server, the Corresponding Source may be on a different server +(operated by you or a third party) that supports equivalent copying facilities, +provided you maintain clear directions next to the object code saying where to find +the Corresponding Source. Regardless of what server hosts the Corresponding Source, +you remain obligated to ensure that it is available for as long as needed to satisfy +these requirements. +* **e)** Convey the object code using peer-to-peer transmission, provided you inform +other peers where the object code and Corresponding Source of the work are being +offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the +Corresponding Source as a System Library, need not be included in conveying the +object code work. + +A “User Product” is either (1) a “consumer product”, which +means any tangible personal property which is normally used for personal, family, or +household purposes, or (2) anything designed or sold for incorporation into a +dwelling. In determining whether a product is a consumer product, doubtful cases +shall be resolved in favor of coverage. For a particular product received by a +particular user, “normally used” refers to a typical or common use of +that class of product, regardless of the status of the particular user or of the way +in which the particular user actually uses, or expects or is expected to use, the +product. A product is a consumer product regardless of whether the product has +substantial commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + +“Installation Information” for a User Product means any methods, +procedures, authorization keys, or other information required to install and execute +modified versions of a covered work in that User Product from a modified version of +its Corresponding Source. The information must suffice to ensure that the continued +functioning of the modified object code is in no case prevented or interfered with +solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for +use in, a User Product, and the conveying occurs as part of a transaction in which +the right of possession and use of the User Product is transferred to the recipient +in perpetuity or for a fixed term (regardless of how the transaction is +characterized), the Corresponding Source conveyed under this section must be +accompanied by the Installation Information. But this requirement does not apply if +neither you nor any third party retains the ability to install modified object code +on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to +continue to provide support service, warranty, or updates for a work that has been +modified or installed by the recipient, or for the User Product in which it has been +modified or installed. Access to a network may be denied when the modification itself +materially and adversely affects the operation of the network or violates the rules +and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with +this section must be in a format that is publicly documented (and with an +implementation available to the public in source code form), and must require no +special password or key for unpacking, reading or copying. + +### 7. Additional Terms. + +“Additional permissions” are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. Additional +permissions that are applicable to the entire Program shall be treated as though they +were included in this License, to the extent that they are valid under applicable +law. If additional permissions apply only to part of the Program, that part may be +used separately under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any +additional permissions from that copy, or from any part of it. (Additional +permissions may be written to require their own removal in certain cases when you +modify the work.) You may place additional permissions on material, added by you to a +covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a +covered work, you may (if authorized by the copyright holders of that material) +supplement the terms of this License with terms: + +* **a)** Disclaiming warranty or limiting liability differently from the terms of +sections 15 and 16 of this License; or +* **b)** Requiring preservation of specified reasonable legal notices or author +attributions in that material or in the Appropriate Legal Notices displayed by works +containing it; or +* **c)** Prohibiting misrepresentation of the origin of that material, or requiring that +modified versions of such material be marked in reasonable ways as different from the +original version; or +* **d)** Limiting the use for publicity purposes of names of licensors or authors of the +material; or +* **e)** Declining to grant rights under trademark law for use of some trade names, +trademarks, or service marks; or +* **f)** Requiring indemnification of licensors and authors of that material by anyone +who conveys the material (or modified versions of it) with contractual assumptions of +liability to the recipient, for any liability that these contractual assumptions +directly impose on those licensors and authors. + +All other non-permissive additional terms are considered “further +restrictions” within the meaning of section 10. If the Program as you received +it, or any part of it, contains a notice stating that it is governed by this License +along with a term that is a further restriction, you may remove that term. If a +license document contains a further restriction but permits relicensing or conveying +under this License, you may add to a covered work material governed by the terms of +that license document, provided that the further restriction does not survive such +relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in +the relevant source files, a statement of the additional terms that apply to those +files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a +separately written license, or stated as exceptions; the above requirements apply +either way. + +### 8. Termination. + +You may not propagate or modify a covered work except as expressly provided under +this License. Any attempt otherwise to propagate or modify it is void, and will +automatically terminate your rights under this License (including any patent licenses +granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a +particular copyright holder is reinstated (a) provisionally, unless and until the +copyright holder explicitly and finally terminates your license, and (b) permanently, +if the copyright holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently +if the copyright holder notifies you of the violation by some reasonable means, this +is the first time you have received notice of violation of this License (for any +work) from that copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of +parties who have received copies or rights from you under this License. If your +rights have been terminated and not permanently reinstated, you do not qualify to +receive new licenses for the same material under section 10. + +### 9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run a copy of the +Program. Ancillary propagation of a covered work occurring solely as a consequence of +using peer-to-peer transmission to receive a copy likewise does not require +acceptance. However, nothing other than this License grants you permission to +propagate or modify any covered work. These actions infringe copyright if you do not +accept this License. Therefore, by modifying or propagating a covered work, you +indicate your acceptance of this License to do so. + +### 10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically receives a license +from the original licensors, to run, modify and propagate that work, subject to this +License. You are not responsible for enforcing compliance by third parties with this +License. + +An “entity transaction” is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an organization, or +merging organizations. If propagation of a covered work results from an entity +transaction, each party to that transaction who receives a copy of the work also +receives whatever licenses to the work the party's predecessor in interest had or +could give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if the predecessor +has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or +affirmed under this License. For example, you may not impose a license fee, royalty, +or other charge for exercise of rights granted under this License, and you may not +initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging +that any patent claim is infringed by making, using, selling, offering for sale, or +importing the Program or any portion of it. + +### 11. Patents. + +A “contributor” is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The work thus +licensed is called the contributor's “contributor version”. + +A contributor's “essential patent claims” are all patent claims owned or +controlled by the contributor, whether already acquired or hereafter acquired, that +would be infringed by some manner, permitted by this License, of making, using, or +selling its contributor version, but do not include claims that would be infringed +only as a consequence of further modification of the contributor version. For +purposes of this definition, “control” includes the right to grant patent +sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license +under the contributor's essential patent claims, to make, use, sell, offer for sale, +import and otherwise run, modify and propagate the contents of its contributor +version. + +In the following three paragraphs, a “patent license” is any express +agreement or commitment, however denominated, not to enforce a patent (such as an +express permission to practice a patent or covenant not to sue for patent +infringement). To “grant” such a patent license to a party means to make +such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the +Corresponding Source of the work is not available for anyone to copy, free of charge +and under the terms of this License, through a publicly available network server or +other readily accessible means, then you must either (1) cause the Corresponding +Source to be so available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner consistent with +the requirements of this License, to extend the patent license to downstream +recipients. “Knowingly relying” means you have actual knowledge that, but +for the patent license, your conveying the covered work in a country, or your +recipient's use of the covered work in a country, would infringe one or more +identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you +convey, or propagate by procuring conveyance of, a covered work, and grant a patent +license to some of the parties receiving the covered work authorizing them to use, +propagate, modify or convey a specific copy of the covered work, then the patent +license you grant is automatically extended to all recipients of the covered work and +works based on it. + +A patent license is “discriminatory” if it does not include within the +scope of its coverage, prohibits the exercise of, or is conditioned on the +non-exercise of one or more of the rights that are specifically granted under this +License. You may not convey a covered work if you are a party to an arrangement with +a third party that is in the business of distributing software, under which you make +payment to the third party based on the extent of your activity of conveying the +work, and under which the third party grants, to any of the parties who would receive +the covered work from you, a discriminatory patent license (a) in connection with +copies of the covered work conveyed by you (or copies made from those copies), or (b) +primarily for and in connection with specific products or compilations that contain +the covered work, unless you entered into that arrangement, or that patent license +was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied +license or other defenses to infringement that may otherwise be available to you +under applicable patent law. + +### 12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or otherwise) +that contradict the conditions of this License, they do not excuse you from the +conditions of this License. If you cannot convey a covered work so as to satisfy +simultaneously your obligations under this License and any other pertinent +obligations, then as a consequence you may not convey it at all. For example, if you +agree to terms that obligate you to collect a royalty for further conveying from +those to whom you convey the Program, the only way you could satisfy both those terms +and this License would be to refrain entirely from conveying the Program. + +### 13. Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have permission to link or +combine any covered work with a work licensed under version 3 of the GNU Affero +General Public License into a single combined work, and to convey the resulting work. +The terms of this License will continue to apply to the part which is the covered +work, but the special requirements of the GNU Affero General Public License, section +13, concerning interaction through a network will apply to the combination as such. + +### 14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions of the GNU +General Public License from time to time. Such new versions will be similar in spirit +to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that +a certain numbered version of the GNU General Public License “or any later +version” applies to it, you have the option of following the terms and +conditions either of that numbered version or of any later version published by the +Free Software Foundation. If the Program does not specify a version number of the GNU +General Public License, you may choose any version ever published by the Free +Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU +General Public License can be used, that proxy's public statement of acceptance of a +version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no +additional obligations are imposed on any author or copyright holder as a result of +your choosing to follow a later version. + +### 15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE +QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE +DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +### 16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY +COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS +PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, +INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE +OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE +WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +### 17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided above cannot be +given local legal effect according to their terms, reviewing courts shall apply local +law that most closely approximates an absolute waiver of all civil liability in +connection with the Program, unless a warranty or assumption of liability accompanies +a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + +## How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to +the public, the best way to achieve this is to make it free software which everyone +can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them +to the start of each source file to most effectively state the exclusion of warranty; +and each file should have at least the “copyright” line and a pointer to +where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice like this +when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type 'show c' for details. + +The hypothetical commands 'show w' and 'show c' should show the appropriate parts of +the General Public License. Of course, your program's commands might be different; +for a GUI interface, you would use an “about box”. + +You should also get your employer (if you work as a programmer) or school, if any, to +sign a “copyright disclaimer” for the program, if necessary. For more +information on this, and how to apply and follow the GNU GPL, see +<>. + +The GNU General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may consider it +more useful to permit linking proprietary applications with the library. If this is +what you want to do, use the GNU Lesser General Public License instead of this +License. But first, please read +<>. diff --git a/vendor/github.com/evilsocket/islazy/fs/doc.go b/vendor/github.com/evilsocket/islazy/fs/doc.go new file mode 100644 index 00000000..9313dcff --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/fs/doc.go @@ -0,0 +1,2 @@ +// Package fs contains helper functions for file system access and enumeration. +package fs diff --git a/vendor/github.com/evilsocket/islazy/fs/glob.go b/vendor/github.com/evilsocket/islazy/fs/glob.go new file mode 100644 index 00000000..1f2b014f --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/fs/glob.go @@ -0,0 +1,20 @@ +package fs + +import ( + "path/filepath" +) + +// Glob enumerates files on a given path using a globbing expression and +// execute a callback for each of the files. The callback can interrupt +// the loop by returning an error other than nil. +func Glob(path string, expr string, cb func(fileName string) error) (err error) { + var files []string + if files, err = filepath.Glob(filepath.Join(path, expr)); err == nil { + for _, fileName := range files { + if err = cb(fileName); err != nil { + return + } + } + } + return +} diff --git a/vendor/github.com/evilsocket/islazy/fs/line_reader.go b/vendor/github.com/evilsocket/islazy/fs/line_reader.go new file mode 100644 index 00000000..c523e4c9 --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/fs/line_reader.go @@ -0,0 +1,31 @@ +package fs + +import ( + "bufio" + "os" +) + +// LineReader accepts the name of a file and offset as argument +// and will return a channel from which lines can be read +// one at a time. +func LineReader(filename string) (chan string, error) { + fp, err := os.Open(filename) + if err != nil { + return nil, err + } + + out := make(chan string) + go func() { + defer fp.Close() + // we need to close the out channel in order + // to signal the end-of-data condition + defer close(out) + scanner := bufio.NewScanner(fp) + scanner.Split(bufio.ScanLines) + for scanner.Scan() { + out <- scanner.Text() + } + }() + + return out, nil +} diff --git a/vendor/github.com/evilsocket/islazy/fs/misc.go b/vendor/github.com/evilsocket/islazy/fs/misc.go new file mode 100644 index 00000000..cff81304 --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/fs/misc.go @@ -0,0 +1,25 @@ +package fs + +import ( + "os" + "os/user" + "path/filepath" + "strings" +) + +// Expand will expand a path with ~ to a full path of the current user. +func Expand(path string) (string, error) { + usr, err := user.Current() + if err != nil { + return "", err + } + return filepath.Abs(strings.Replace(path, "~", usr.HomeDir, 1)) +} + +// Exists returns true if the path exists. +func Exists(path string) bool { + if _, err := os.Stat(path); os.IsNotExist(err) { + return false + } + return true +} diff --git a/vendor/github.com/evilsocket/islazy/log/doc.go b/vendor/github.com/evilsocket/islazy/log/doc.go new file mode 100644 index 00000000..7e602115 --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/log/doc.go @@ -0,0 +1,2 @@ +// Package log provides access to log functions. +package log diff --git a/vendor/github.com/evilsocket/islazy/log/format.go b/vendor/github.com/evilsocket/islazy/log/format.go new file mode 100644 index 00000000..8d54cb9a --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/log/format.go @@ -0,0 +1,62 @@ +package log + +import ( + "strconv" + "time" + + "github.com/evilsocket/islazy/tui" +) + +var ( + // Tokens is a map of the tokens that can be used in Format + // to insert values returned by the execution of a callback. + Tokens = map[string]func() string{ + "{date}": func() string { + return time.Now().Format(DateFormat) + }, + "{time}": func() string { + return time.Now().Format(TimeFormat) + }, + "{datetime}": func() string { + return time.Now().Format(DateTimeFormat) + }, + "{level:value}": func() string { + return strconv.Itoa(int(currLevel)) + }, + "{level:name}": func() string { + return LevelNames[currLevel] + }, + "{level:color}": func() string { + return LevelColors[currLevel] + }, + "{message}": func() string { + return currMessage + }, + } + // Effects is a map of the tokens that can be used in Format to + // change the properties of the text. + Effects = map[string]string{ + "{bold}": tui.BOLD, + "{dim}": tui.DIM, + "{red}": tui.RED, + "{green}": tui.GREEN, + "{blue}": tui.BLUE, + "{yellow}": tui.YELLOW, + "{f:black}": tui.FOREBLACK, + "{f:white}": tui.FOREWHITE, + "{b:darkgray}": tui.BACKDARKGRAY, + "{b:red}": tui.BACKRED, + "{b:green}": tui.BACKGREEN, + "{b:yellow}": tui.BACKYELLOW, + "{b:lightblue}": tui.BACKLIGHTBLUE, + "{reset}": tui.RESET, + } + // DateFormat is the default date format being used when filling the {date} log token. + DateFormat = "06-Jan-02" + // TimeFormat is the default time format being used when filling the {time} or {datetime} log tokens. + TimeFormat = "15:04:05" + // DateTimeFormat is the default date and time format being used when filling the {datetime} log token. + DateTimeFormat = "2006-01-02 15:04:05" + // Format is the default format being used when logging. + Format = "{datetime} {level:color}{level:name}{reset} {message}" +) diff --git a/vendor/github.com/evilsocket/islazy/log/level.go b/vendor/github.com/evilsocket/islazy/log/level.go new file mode 100644 index 00000000..10fda7fc --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/log/level.go @@ -0,0 +1,44 @@ +package log + +import ( + "github.com/evilsocket/islazy/tui" +) + +// Verbosity represents the verbosity level of the logger. +type Verbosity int + +const ( + // Debug messages. + DEBUG Verbosity = iota + // Informative messages. + INFO + // Informative messages that are important. + IMPORTANT + // Warning messages. + WARNING + // Recoverable error conditions. + ERROR + // Fatal error conditions. + FATAL +) + +var ( + // LevelNames is a map of the names ( {level:name} ) of each verbosity level. + LevelNames = map[Verbosity]string{ + DEBUG: "dbg", + INFO: "inf", + IMPORTANT: "imp", + WARNING: "war", + ERROR: "err", + FATAL: "!!!", + } + // LevelColors is a map of the colors ( {level:color} ) of each verbosity level. + LevelColors = map[Verbosity]string{ + DEBUG: tui.DIM + tui.FOREBLACK + tui.BACKDARKGRAY, + INFO: tui.FOREWHITE + tui.BACKGREEN, + IMPORTANT: tui.FOREWHITE + tui.BACKLIGHTBLUE, + WARNING: tui.FOREWHITE + tui.BACKYELLOW, + ERROR: tui.FOREWHITE + tui.BACKRED, + FATAL: tui.FOREWHITE + tui.BACKRED + tui.BOLD, + } +) diff --git a/vendor/github.com/evilsocket/islazy/log/log.go b/vendor/github.com/evilsocket/islazy/log/log.go new file mode 100644 index 00000000..eac0dd3f --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/log/log.go @@ -0,0 +1,127 @@ +package log + +import ( + "fmt" + "os" + "regexp" + "strings" + "sync" + + "github.com/evilsocket/islazy/tui" +) + +var ( + // Level represents the current verbosity level of the logging system. + Level = INFO + // Output represents the log output file path if filled or, if empty, stdout. + Output = "" + // NoEffects disables all effects and colors if set to true. + NoEffects = false + // OnFatal represents the callback/action to execute on Fatal messages. + OnFatal = ExitOnFatal + + lock = &sync.Mutex{} + currMessage = "" + currLevel = INFO + writer = os.Stdout + + reEffects = []*regexp.Regexp{ + regexp.MustCompile("\x033\\[\\d+m"), + regexp.MustCompile("\\\\e\\[\\d+m"), + regexp.MustCompile("\x1b\\[\\d+m"), + } +) + +// Open initializes the logging system. +func Open() (err error) { + if Output != "" { + writer, err = os.OpenFile(Output, os.O_APPEND|os.O_RDWR|os.O_CREATE, 0644) + } + return +} + +// Close finalizes the logging system. +func Close() { + if writer != os.Stdout { + writer.Close() + } +} + +func emit(s string) { + // remove all effects if found + if NoEffects { + for _, re := range reEffects { + s = re.ReplaceAllString(s, "") + } + } + + fmt.Fprintf(writer, s) + fmt.Fprintf(writer, "\n") +} + +func do(v Verbosity, format string, args ...interface{}) { + lock.Lock() + defer lock.Unlock() + + if Level > v { + return + } + + logLine := Format + currLevel = v + currMessage = fmt.Sprintf(format, args...) + // process token -> callback + for token, cb := range Tokens { + logLine = strings.Replace(logLine, token, cb(), -1) + } + // process token -> effect + for token, effect := range Effects { + logLine = strings.Replace(logLine, token, effect, -1) + } + // make sure an user error does not screw the log + if tui.HasEffect(logLine) && !strings.HasSuffix(logLine, tui.RESET) { + logLine += tui.RESET + } + + emit(logLine) +} + +// Raw emits a message without format to the logs. +func Raw(format string, args ...interface{}) { + lock.Lock() + defer lock.Unlock() + + currMessage = fmt.Sprintf(format, args...) + emit(currMessage) +} + +// Debug emits a debug message. +func Debug(format string, args ...interface{}) { + do(DEBUG, format, args...) +} + +// Info emits an informative message. +func Info(format string, args ...interface{}) { + do(INFO, format, args...) +} + +// Important emits an important informative message. +func Important(format string, args ...interface{}) { + do(IMPORTANT, format, args...) +} + +// Warning emits a warning message. +func Warning(format string, args ...interface{}) { + do(WARNING, format, args...) +} + +// Error emits an error message. +func Error(format string, args ...interface{}) { + do(ERROR, format, args...) +} + +// Fata emits a fatal error message and calls the log.OnFatal callback. +func Fatal(format string, args ...interface{}) { + do(FATAL, format, args...) + OnFatal() +} diff --git a/vendor/github.com/evilsocket/islazy/log/policy.go b/vendor/github.com/evilsocket/islazy/log/policy.go new file mode 100644 index 00000000..e42e5ae1 --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/log/policy.go @@ -0,0 +1,23 @@ +package log + +import ( + "os" +) + +// FatalPolicy represents a callback to be executed on Fatal messages. +type FatalPolicy func() + +// os.Exit(1) on Fatal messages. +func ExitOnFatal() { + os.Exit(1) +} + +// os.Exit(0) on Fatal messages. +func ExitCleanOnFatal() { + os.Exit(0) +} + +// Do nothing on Fatal messages. +func NoneOnFatal() { + +} diff --git a/vendor/github.com/evilsocket/islazy/str/doc.go b/vendor/github.com/evilsocket/islazy/str/doc.go new file mode 100644 index 00000000..211fd57c --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/str/doc.go @@ -0,0 +1,2 @@ +// Package str contains utilities for string manipulation. +package str diff --git a/vendor/github.com/evilsocket/islazy/str/split.go b/vendor/github.com/evilsocket/islazy/str/split.go new file mode 100644 index 00000000..e0f4d1ff --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/str/split.go @@ -0,0 +1,24 @@ +package str + +import ( + "strings" +) + +// SplitBy splits by a separator a string and returns a +// list of the non empty parts. +func SplitBy(sv string, sep string) []string { + filtered := make([]string, 0) + for _, part := range strings.Split(sv, sep) { + part = Trim(part) + if part != "" { + filtered = append(filtered, part) + } + } + return filtered +} + +// Comma splits by comma a string and returns a +// list of the non empty parts. +func Comma(csv string) []string { + return SplitBy(csv, ",") +} diff --git a/vendor/github.com/evilsocket/islazy/str/trim.go b/vendor/github.com/evilsocket/islazy/str/trim.go new file mode 100644 index 00000000..b2491459 --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/str/trim.go @@ -0,0 +1,24 @@ +package str + +import ( + "strings" +) + +const ( + whiteSpaceTrimSet = "\r\n\t " +) + +// Trim trims a string from white spaces. +func Trim(s string) string { + return strings.Trim(s, whiteSpaceTrimSet) +} + +// TrimRight trims the right part of a string from white spaces. +func TrimRight(s string) string { + return strings.TrimRight(s, whiteSpaceTrimSet) +} + +// TrimLeft trims the left part of a string from white spaces. +func TrimLeft(s string) string { + return strings.TrimLeft(s, whiteSpaceTrimSet) +} diff --git a/vendor/github.com/evilsocket/islazy/tui/colors.go b/vendor/github.com/evilsocket/islazy/tui/colors.go new file mode 100644 index 00000000..725fa742 --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/tui/colors.go @@ -0,0 +1,104 @@ +package tui + +import ( + "os" + "strings" +) + +// https://misc.flogisoft.com/bash/tip_colors_and_formatting +var ( + // effects + BOLD = "\033[1m" + DIM = "\033[2m" + RESET = "\033[0m" + // colors + RED = "\033[31m" + GREEN = "\033[32m" + BLUE = "\033[34m" + YELLOW = "\033[33m" + // foreground colors + FOREBLACK = "\033[30m" + FOREWHITE = "\033[97m" + // background colors + BACKDARKGRAY = "\033[100m" + BACKRED = "\033[41m" + BACKGREEN = "\033[42m" + BACKYELLOW = "\033[43m" + BACKLIGHTBLUE = "\033[104m" + + ctrl = []string{"\x033", "\\e", "\x1b"} +) + +// Effects returns true if colors and effects are supported +// on the current terminal. +func Effects() bool { + if term := os.Getenv("TERM"); term == "" { + return false + } else if term == "dumb" { + return false + } + return true +} + +// Disable will disable all colors and effects. +func Disable() { + BOLD = "" + DIM = "" + RESET = "" + RED = "" + GREEN = "" + BLUE = "" + YELLOW = "" + FOREBLACK = "" + FOREWHITE = "" + BACKDARKGRAY = "" + BACKRED = "" + BACKGREEN = "" + BACKYELLOW = "" + BACKLIGHTBLUE = "" +} + +// HasEffect returns true if the string has any shell control codes in it. +func HasEffect(s string) bool { + for _, ch := range ctrl { + if strings.Contains(s, ch) { + return true + } + } + return false +} + +// Wrap wraps a string with an effect or color and appends a reset control code. +func Wrap(e, s string) string { + return e + s + RESET +} + +// Bold makes the string Bold. +func Bold(s string) string { + return Wrap(BOLD, s) +} + +// Dim makes the string Diminished. +func Dim(s string) string { + return Wrap(DIM, s) +} + +// Red makes the string Red. +func Red(s string) string { + return Wrap(RED, s) +} + +// Green makes the string Green. +func Green(s string) string { + return Wrap(GREEN, s) +} + +// Blue makes the string Green. +func Blue(s string) string { + return Wrap(BLUE, s) +} + +// Yellow makes the string Green. +func Yellow(s string) string { + return Wrap(YELLOW, s) +} diff --git a/vendor/github.com/evilsocket/islazy/tui/doc.go b/vendor/github.com/evilsocket/islazy/tui/doc.go new file mode 100644 index 00000000..d940d68a --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/tui/doc.go @@ -0,0 +1,3 @@ +// Package tui contains a set of helper objects and functions for terminal +// based user interfaces. +package tui diff --git a/core/table.go b/vendor/github.com/evilsocket/islazy/tui/table.go similarity index 77% rename from core/table.go rename to vendor/github.com/evilsocket/islazy/tui/table.go index 63f8def6..20274d94 100644 --- a/core/table.go +++ b/vendor/github.com/evilsocket/islazy/tui/table.go @@ -1,4 +1,4 @@ -package core +package tui import ( "fmt" @@ -28,22 +28,22 @@ func maxLen(strings []string) int { return maxLen } -type Alignment int +type alignment int const ( - AlignLeft = Alignment(0) - AlignCenter = Alignment(1) - AlignRight = Alignment(2) + alignLeft = alignment(0) + alignCenter = alignment(1) + alignRight = alignment(2) ) -func getPads(s string, maxLen int, align Alignment) (lPad int, rPad int) { +func getPads(s string, maxLen int, align alignment) (lPad int, rPad int) { len := viewLen(s) diff := maxLen - len - if align == AlignLeft { + if align == alignLeft { lPad = 0 rPad = diff - lPad + 1 - } else if align == AlignCenter { + } else if align == alignCenter { lPad = diff / 2 rPad = diff - lPad + 1 } /* else { @@ -53,12 +53,15 @@ func getPads(s string, maxLen int, align Alignment) (lPad int, rPad int) { return } -func padded(s string, maxLen int, align Alignment) string { +func padded(s string, maxLen int, align alignment) string { lPad, rPad := getPads(s, maxLen, align) return fmt.Sprintf("%s%s%s", strings.Repeat(" ", lPad), s, strings.Repeat(" ", rPad)) } -func AsTable(w io.Writer, columns []string, rows [][]string) { +// Table accepts a slice of column labels and a 2d slice of rows +// and prints on the writer an ASCII based datagrid of such +// data. +func Table(w io.Writer, columns []string, rows [][]string) { for i, col := range columns { columns[i] = fmt.Sprintf(" %s ", col) } @@ -87,7 +90,7 @@ func AsTable(w io.Writer, columns []string, rows [][]string) { // header table += fmt.Sprintf("%s\n", lineSep) for colIndex, colHeader := range columns { - table += fmt.Sprintf("|%s", padded(colHeader, colPaddings[colIndex], AlignCenter)) + table += fmt.Sprintf("|%s", padded(colHeader, colPaddings[colIndex], alignCenter)) } table += fmt.Sprintf("|\n") table += fmt.Sprintf("%s\n", lineSep) @@ -95,7 +98,7 @@ func AsTable(w io.Writer, columns []string, rows [][]string) { // rows for _, row := range rows { for colIndex, cell := range row { - table += fmt.Sprintf("|%s", padded(cell, colPaddings[colIndex], AlignLeft)) + table += fmt.Sprintf("|%s", padded(cell, colPaddings[colIndex], alignLeft)) } table += fmt.Sprintf("|\n") } diff --git a/vendor/github.com/evilsocket/islazy/zip/doc.go b/vendor/github.com/evilsocket/islazy/zip/doc.go new file mode 100644 index 00000000..97bbc8c8 --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/zip/doc.go @@ -0,0 +1,2 @@ +// Package zip contains zip and unzip utilities. +package zip diff --git a/vendor/github.com/evilsocket/islazy/zip/unzip.go b/vendor/github.com/evilsocket/islazy/zip/unzip.go new file mode 100644 index 00000000..79ec84b3 --- /dev/null +++ b/vendor/github.com/evilsocket/islazy/zip/unzip.go @@ -0,0 +1,55 @@ +package zip + +import ( + "archive/zip" + "fmt" + "io" + "os" + "path/filepath" + "strings" +) + +// Unzip will decompress a zip archive, moving all files and folders +// within the zip file (parameter 1) to an output directory (parameter 2). +// Credits to https://golangcode.com/unzip-files-in-go/ +func Unzip(src string, dest string) ([]string, error) { + var filenames []string + + r, err := zip.OpenReader(src) + if err != nil { + return filenames, err + } + defer r.Close() + + for _, f := range r.File { + rc, err := f.Open() + if err != nil { + return filenames, err + } + defer rc.Close() + + // Store filename/path for returning and using later on + fpath := filepath.Join(dest, f.Name) + + // Check for ZipSlip. More Info: https://snyk.io/research/zip-slip-vulnerability#go + if !strings.HasPrefix(fpath, filepath.Clean(dest)+string(os.PathSeparator)) { + return filenames, fmt.Errorf("%s: illegal file path", fpath) + } + + filenames = append(filenames, fpath) + if f.FileInfo().IsDir() { + os.MkdirAll(fpath, os.ModePerm) + } else if err = os.MkdirAll(filepath.Dir(fpath), os.ModePerm); err != nil { + return filenames, err + } else if outFile, err := os.OpenFile(fpath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode()); err != nil { + return filenames, err + } else { + defer outFile.Close() + if _, err = io.Copy(outFile, rc); err != nil { + return filenames, err + } + } + } + + return filenames, nil +} diff --git a/vendor/github.com/gobwas/glob/readme.md b/vendor/github.com/gobwas/glob/readme.md index f58144e7..682f0d69 100644 --- a/vendor/github.com/gobwas/glob/readme.md +++ b/vendor/github.com/gobwas/glob/readme.md @@ -126,10 +126,10 @@ Pattern | Fixture | Match | Speed (ns/op) `^[a-z][^a-x].*cat.*[h][^b].*eyes.*$` | `my dog has very bright eyes` | `false` | 1383 `^https:\/\/.*\.google\..*$` | `https://account.google.com` | `true` | 1205 `^https:\/\/.*\.google\..*$` | `https://google.com` | `false` | 767 -`^(https:\/\/.*\.google\..*|.*yandex\..*|.*yahoo\..*|.*mail\.ru)$` | `http://yahoo.com` | `true` | 1435 -`^(https:\/\/.*\.google\..*|.*yandex\..*|.*yahoo\..*|.*mail\.ru)$` | `http://google.com` | `false` | 1674 -`^(https:\/\/.*gobwas\.com|http://exclude.gobwas.com)$` | `https://safe.gobwas.com` | `true` | 1039 -`^(https:\/\/.*gobwas\.com|http://exclude.gobwas.com)$` | `http://safe.gobwas.com` | `false` | 272 +`^(https:\/\/.*\.google\..*\|.*yandex\..*\|.*yahoo\..*\|.*mail\.ru)$` | `http://yahoo.com` | `true` | 1435 +`^(https:\/\/.*\.google\..*\|.*yandex\..*\|.*yahoo\..*\|.*mail\.ru)$` | `http://google.com` | `false` | 1674 +`^(https:\/\/.*gobwas\.com\|http://exclude.gobwas.com)$` | `https://safe.gobwas.com` | `true` | 1039 +`^(https:\/\/.*gobwas\.com\|http://exclude.gobwas.com)$` | `http://safe.gobwas.com` | `false` | 272 `^abc.*$` | `abcdef` | `true` | 237 `^abc.*$` | `af` | `false` | 100 `^.*def$` | `abcdef` | `true` | 464 @@ -145,4 +145,4 @@ Pattern | Fixture | Match | Speed (ns/op) ## Syntax Syntax is inspired by [standard wildcards](http://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm), -except that `**` is aka super-asterisk, that do not sensitive for separators. \ No newline at end of file +except that `**` is aka super-asterisk, that do not sensitive for separators. diff --git a/vendor/github.com/google/gopacket/.travis.golint.sh b/vendor/github.com/google/gopacket/.travis.golint.sh index ed74c65a..9f653bc5 100755 --- a/vendor/github.com/google/gopacket/.travis.golint.sh +++ b/vendor/github.com/google/gopacket/.travis.golint.sh @@ -3,7 +3,7 @@ cd "$(dirname $0)" go get github.com/golang/lint/golint -DIRS=". tcpassembly tcpassembly/tcpreader ip4defrag reassembly macs pcapgo pcap afpacket pfring routing" +DIRS=". tcpassembly tcpassembly/tcpreader ip4defrag reassembly macs pcapgo pcap afpacket pfring routing defrag/lcmdefrag" # Add subdirectories here as we clean up golint on each. for subdir in $DIRS; do pushd $subdir @@ -17,8 +17,11 @@ for subdir in $DIRS; do done pushd layers -for file in $(cat .linted); do - if golint $file | grep .; then +for file in *.go; do + if cat .lint_blacklist | grep -q $file; then + echo "Skipping lint of $file due to .lint_blacklist" + elif golint $file | grep .; then + echo "Lint error in file $file" exit 1 fi done diff --git a/vendor/github.com/google/gopacket/.travis.govet.sh b/vendor/github.com/google/gopacket/.travis.govet.sh index 52ad0841..a5c13544 100755 --- a/vendor/github.com/google/gopacket/.travis.govet.sh +++ b/vendor/github.com/google/gopacket/.travis.govet.sh @@ -1,7 +1,7 @@ #!/bin/bash cd "$(dirname $0)" -DIRS=". layers pcap pcapgo pfring tcpassembly tcpassembly/tcpreader routing ip4defrag bytediff macs" +DIRS=". layers pcap pcapgo tcpassembly tcpassembly/tcpreader routing ip4defrag bytediff macs defrag/lcmdefrag" set -e for subdir in $DIRS; do pushd $subdir diff --git a/vendor/github.com/google/gopacket/.travis.yml b/vendor/github.com/google/gopacket/.travis.yml index 7d731262..ceb1c7e6 100644 --- a/vendor/github.com/google/gopacket/.travis.yml +++ b/vendor/github.com/google/gopacket/.travis.yml @@ -1,12 +1,16 @@ language: go +before_install: + - sudo apt-get install libpcap-dev install: - go get github.com/google/gopacket - go get github.com/google/gopacket/layers + - go get github.com/google/gopacket/pcapgo - 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/pcapgo - go test github.com/google/gopacket/tcpassembly - go test github.com/google/gopacket/reassembly - ./.travis.gofmt.sh diff --git a/vendor/github.com/google/gopacket/doc.go b/vendor/github.com/google/gopacket/doc.go index 61989407..40d86d1b 100644 --- a/vendor/github.com/google/gopacket/doc.go +++ b/vendor/github.com/google/gopacket/doc.go @@ -329,7 +329,7 @@ the following manner: } buf := gopacket.NewSerializeBuffer() opts := gopacket.SerializeOptions{} // See SerializeOptions for more details. - err := ip.SerializeTo(&buf, opts) + err := ip.SerializeTo(buf, opts) if err != nil { panic(err) } fmt.Println(buf.Bytes()) // prints out a byte slice containing the serialized IPv4 layer. diff --git a/vendor/github.com/google/gopacket/gc b/vendor/github.com/google/gopacket/gc index 57bcdee2..b1d8d2e1 100755 --- a/vendor/github.com/google/gopacket/gc +++ b/vendor/github.com/google/gopacket/gc @@ -106,6 +106,7 @@ if [ ! -z "$GEN" ]; then popd pushd layers go run gen.go | gofmt > iana_ports.go + go run gen2.go | gofmt > enums_generated.go popd fi @@ -126,6 +127,9 @@ if [ -f /usr/include/pcap.h ]; then Root pcap_tester --mode=filtered Root pcap_tester --mode=timestamp || echo "You might not support timestamp sources" popd + pushd examples/afpacket + go build + popd pushd examples/pcapdump go build popd @@ -182,6 +186,12 @@ if [ -f /usr/include/pfring.h ]; then go build popd fi +pushd ip4defrag +go test ./... +popd +pushd defrag +go test ./... +popd for travis_script in `ls .travis.*.sh`; do ./$travis_script diff --git a/vendor/github.com/google/gopacket/layers/.lint_blacklist b/vendor/github.com/google/gopacket/layers/.lint_blacklist new file mode 100644 index 00000000..f2af3807 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/.lint_blacklist @@ -0,0 +1,33 @@ +dot11.go +eap.go +endpoints.go +enums_generated.go +enums.go +ethernet.go +geneve.go +icmp4.go +icmp6.go +igmp.go +ip4.go +ip6.go +layertypes.go +linux_sll.go +llc.go +lldp.go +mpls.go +ndp.go +ntp.go +ospf.go +pflog.go +pppoe.go +prism.go +radiotap.go +rudp.go +sctp.go +sflow.go +tcp.go +tcpip.go +udp.go +udplite.go +usb.go +vrrp.go diff --git a/vendor/github.com/google/gopacket/layers/.linted b/vendor/github.com/google/gopacket/layers/.linted deleted file mode 100644 index b2b29722..00000000 --- a/vendor/github.com/google/gopacket/layers/.linted +++ /dev/null @@ -1,40 +0,0 @@ -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/bfd.go b/vendor/github.com/google/gopacket/layers/bfd.go new file mode 100644 index 00000000..43030fb6 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/bfd.go @@ -0,0 +1,481 @@ +// Copyright 2017 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" +) + +// BFD Control Packet Format +// ------------------------- +// The current version of BFD's RFC (RFC 5880) contains the following +// diagram for the BFD Control packet 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 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// |Vers | Diag |Sta|P|F|C|A|D|M| Detect Mult | Length | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | My Discriminator | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Your Discriminator | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Desired Min TX Interval | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Required Min RX Interval | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Required Min Echo RX Interval | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// +// An optional Authentication Section MAY be present: +// +// 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 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Auth Type | Auth Len | Authentication Data... | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// +// +// Simple Password Authentication Section 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 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Auth Type | Auth Len | Auth Key ID | Password... | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | ... | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// +// +// Keyed MD5 and Meticulous Keyed MD5 Authentication Section 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 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Auth Type | Auth Len | Auth Key ID | Reserved | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Sequence Number | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Auth Key/Digest... | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | ... | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// +// +// Keyed SHA1 and Meticulous Keyed SHA1 Authentication Section 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 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Auth Type | Auth Len | Auth Key ID | Reserved | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Sequence Number | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Auth Key/Hash... | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | ... | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// +// From https://tools.ietf.org/rfc/rfc5880.txt +const bfdMinimumRecordSizeInBytes int = 24 + +// BFDVersion represents the version as decoded from the BFD control message +type BFDVersion uint8 + +// BFDDiagnostic represents diagnostic infomation about a BFD session +type BFDDiagnostic uint8 + +// constants that define BFDDiagnostic flags +const ( + BFDDiagnosticNone BFDDiagnostic = 0 // No Diagnostic + BFDDiagnosticTimeExpired BFDDiagnostic = 1 // Control Detection Time Expired + BFDDiagnosticEchoFailed BFDDiagnostic = 2 // Echo Function Failed + BFDDiagnosticNeighborSignalDown BFDDiagnostic = 3 // Neighbor Signaled Session Down + BFDDiagnosticForwardPlaneReset BFDDiagnostic = 4 // Forwarding Plane Reset + BFDDiagnosticPathDown BFDDiagnostic = 5 // Path Down + BFDDiagnosticConcatPathDown BFDDiagnostic = 6 // Concatenated Path Down + BFDDiagnosticAdminDown BFDDiagnostic = 7 // Administratively Down + BFDDiagnosticRevConcatPathDown BFDDiagnostic = 8 // Reverse Concatenated Path Dow +) + +// String returns a string version of BFDDiagnostic +func (bd BFDDiagnostic) String() string { + switch bd { + default: + return "Unknown" + case BFDDiagnosticNone: + return "None" + case BFDDiagnosticTimeExpired: + return "Control Detection Time Expired" + case BFDDiagnosticEchoFailed: + return "Echo Function Failed" + case BFDDiagnosticNeighborSignalDown: + return "Neighbor Signaled Session Down" + case BFDDiagnosticForwardPlaneReset: + return "Forwarding Plane Reset" + case BFDDiagnosticPathDown: + return "Path Down" + case BFDDiagnosticConcatPathDown: + return "Concatenated Path Down" + case BFDDiagnosticAdminDown: + return "Administratively Down" + case BFDDiagnosticRevConcatPathDown: + return "Reverse Concatenated Path Down" + } +} + +// BFDState represents the state of a BFD session +type BFDState uint8 + +// constants that define BFDState +const ( + BFDStateAdminDown BFDState = 0 + BFDStateDown BFDState = 1 + BFDStateInit BFDState = 2 + BFDStateUp BFDState = 3 +) + +// String returns a string version of BFDState +func (s BFDState) String() string { + switch s { + default: + return "Unknown" + case BFDStateAdminDown: + return "Admin Down" + case BFDStateDown: + return "Down" + case BFDStateInit: + return "Init" + case BFDStateUp: + return "Up" + } +} + +// BFDDetectMultiplier represents the negotiated transmit interval, +// multiplied by this value, provides the Detection Time for the +// receiving system in Asynchronous mode. +type BFDDetectMultiplier uint8 + +// BFDDiscriminator is a unique, nonzero discriminator value used +// to demultiplex multiple BFD sessions between the same pair of systems. +type BFDDiscriminator uint32 + +// BFDTimeInterval represents a time interval in microseconds +type BFDTimeInterval uint32 + +// BFDAuthType represents the authentication used in the BFD session +type BFDAuthType uint8 + +// constants that define the BFDAuthType +const ( + BFDAuthTypeNone BFDAuthType = 0 // No Auth + BFDAuthTypePassword BFDAuthType = 1 // Simple Password + BFDAuthTypeKeyedMD5 BFDAuthType = 2 // Keyed MD5 + BFDAuthTypeMeticulousKeyedMD5 BFDAuthType = 3 // Meticulous Keyed MD5 + BFDAuthTypeKeyedSHA1 BFDAuthType = 4 // Keyed SHA1 + BFDAuthTypeMeticulousKeyedSHA1 BFDAuthType = 5 // Meticulous Keyed SHA1 +) + +// String returns a string version of BFDAuthType +func (at BFDAuthType) String() string { + switch at { + default: + return "Unknown" + case BFDAuthTypeNone: + return "No Authentication" + case BFDAuthTypePassword: + return "Simple Password" + case BFDAuthTypeKeyedMD5: + return "Keyed MD5" + case BFDAuthTypeMeticulousKeyedMD5: + return "Meticulous Keyed MD5" + case BFDAuthTypeKeyedSHA1: + return "Keyed SHA1" + case BFDAuthTypeMeticulousKeyedSHA1: + return "Meticulous Keyed SHA1" + } +} + +// BFDAuthKeyID represents the authentication key ID in use for +// this packet. This allows multiple keys to be active simultaneously. +type BFDAuthKeyID uint8 + +// BFDAuthSequenceNumber represents the sequence number for this packet. +// For Keyed Authentication, this value is incremented occasionally. For +// Meticulous Keyed Authentication, this value is incremented for each +// successive packet transmitted for a session. This provides protection +// against replay attacks. +type BFDAuthSequenceNumber uint32 + +// BFDAuthData represents the authentication key or digest +type BFDAuthData []byte + +// BFDAuthHeader represents authentication data used in the BFD session +type BFDAuthHeader struct { + AuthType BFDAuthType + KeyID BFDAuthKeyID + SequenceNumber BFDAuthSequenceNumber + Data BFDAuthData +} + +// Length returns the data length of the BFDAuthHeader based on the +// authentication type +func (h *BFDAuthHeader) Length() int { + switch h.AuthType { + case BFDAuthTypePassword: + return 3 + len(h.Data) + case BFDAuthTypeKeyedMD5, BFDAuthTypeMeticulousKeyedMD5: + return 8 + len(h.Data) + case BFDAuthTypeKeyedSHA1, BFDAuthTypeMeticulousKeyedSHA1: + return 8 + len(h.Data) + default: + return 0 + } +} + +// BFD represents a BFD control message packet whose payload contains +// the control information required to for a BFD session. +// +// References +// ---------- +// +// Wikipedia's BFD entry: +// https://en.wikipedia.org/wiki/Bidirectional_Forwarding_Detection +// This is the best place to get an overview of BFD. +// +// RFC 5880 "Bidirectional Forwarding Detection (BFD)" (2010) +// https://tools.ietf.org/html/rfc5880 +// This is the original BFD specification. +// +// RFC 5881 "Bidirectional Forwarding Detection (BFD) for IPv4 and IPv6 (Single Hop)" (2010) +// https://tools.ietf.org/html/rfc5881 +// Describes the use of the Bidirectional Forwarding Detection (BFD) +// protocol over IPv4 and IPv6 for single IP hops. +type BFD struct { + BaseLayer // Stores the packet bytes and payload bytes. + + Version BFDVersion // Version of the BFD protocol. + Diagnostic BFDDiagnostic // Diagnostic code for last state change + State BFDState // Current state + Poll bool // Requesting verification + Final bool // Responding to a received BFD Control packet that had the Poll (P) bit set. + ControlPlaneIndependent bool // BFD implementation does not share fate with its control plane + AuthPresent bool // Authentication Section is present and the session is to be authenticated + Demand bool // Demand mode is active + Multipoint bool // For future point-to-multipoint extensions. Must always be zero + DetectMultiplier BFDDetectMultiplier // Detection time multiplier + MyDiscriminator BFDDiscriminator // A unique, nonzero discriminator value + YourDiscriminator BFDDiscriminator // discriminator received from the remote system. + DesiredMinTxInterval BFDTimeInterval // Minimum interval, in microseconds, the local system would like to use when transmitting BFD Control packets + RequiredMinRxInterval BFDTimeInterval // Minimum interval, in microseconds, between received BFD Control packets that this system is capable of supporting + RequiredMinEchoRxInterval BFDTimeInterval // Minimum interval, in microseconds, between received BFD Echo packets that this system is capable of supporting + AuthHeader *BFDAuthHeader // Authentication data, variable length. +} + +// Length returns the data length of a BFD Control message which +// changes based on the presence and type of authentication +// contained in the message +func (d *BFD) Length() int { + if d.AuthPresent && (d.AuthHeader != nil) { + return bfdMinimumRecordSizeInBytes + d.AuthHeader.Length() + } + + return bfdMinimumRecordSizeInBytes +} + +// LayerType returns the layer type of the BFD object, which is LayerTypeBFD. +func (d *BFD) LayerType() gopacket.LayerType { + return LayerTypeBFD +} + +// decodeBFD analyses a byte slice and attempts to decode it as a BFD +// control 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 BFD layer. +func decodeBFD(data []byte, p gopacket.PacketBuilder) error { + + // Attempt to decode the byte slice. + d := &BFD{} + 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 a BFD +// control packet. +// +// Upon succeeds, it loads the BFD object with information about the packet +// and returns nil. +// Upon failure, it returns an error (non nil). +func (d *BFD) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + + // If the data block is too short to be a BFD record, then return an error. + if len(data) < bfdMinimumRecordSizeInBytes { + df.SetTruncated() + return errors.New("BFD packet too short") + } + + pLen := uint8(data[3]) + if len(data) != int(pLen) { + return errors.New("BFD packet length does not match") + } + + // BFD 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 BFD 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. + d.Version = BFDVersion(((data[0] & 0xE0) >> 5)) + d.Diagnostic = BFDDiagnostic(data[0] & 0x1F) + data = data[1:] + + d.State = BFDState((data[0] & 0xC0) >> 6) + d.Poll = data[0]&0x20 != 0 + d.Final = data[0]&0x10 != 0 + d.ControlPlaneIndependent = data[0]&0x08 != 0 + d.AuthPresent = data[0]&0x04 != 0 + d.Demand = data[0]&0x02 != 0 + d.Multipoint = data[0]&0x01 != 0 + data = data[1:] + + data, d.DetectMultiplier = data[1:], BFDDetectMultiplier(data[0]) + data, _ = data[1:], uint8(data[0]) // Consume length + + // The remaining fields can just be copied in big endian order. + data, d.MyDiscriminator = data[4:], BFDDiscriminator(binary.BigEndian.Uint32(data[:4])) + data, d.YourDiscriminator = data[4:], BFDDiscriminator(binary.BigEndian.Uint32(data[:4])) + data, d.DesiredMinTxInterval = data[4:], BFDTimeInterval(binary.BigEndian.Uint32(data[:4])) + data, d.RequiredMinRxInterval = data[4:], BFDTimeInterval(binary.BigEndian.Uint32(data[:4])) + data, d.RequiredMinEchoRxInterval = data[4:], BFDTimeInterval(binary.BigEndian.Uint32(data[:4])) + + if d.AuthPresent && (len(data) > 2) { + d.AuthHeader = &BFDAuthHeader{} + data, d.AuthHeader.AuthType = data[1:], BFDAuthType(data[0]) + data, _ = data[1:], uint8(data[0]) // Consume length + data, d.AuthHeader.KeyID = data[1:], BFDAuthKeyID(data[0]) + + switch d.AuthHeader.AuthType { + case BFDAuthTypePassword: + d.AuthHeader.Data = BFDAuthData(data) + case BFDAuthTypeKeyedMD5, BFDAuthTypeMeticulousKeyedMD5: + // Skipped reserved byte + data, d.AuthHeader.SequenceNumber = data[5:], BFDAuthSequenceNumber(binary.BigEndian.Uint32(data[1:5])) + d.AuthHeader.Data = BFDAuthData(data) + case BFDAuthTypeKeyedSHA1, BFDAuthTypeMeticulousKeyedSHA1: + // Skipped reserved byte + data, d.AuthHeader.SequenceNumber = data[5:], BFDAuthSequenceNumber(binary.BigEndian.Uint32(data[1:5])) + d.AuthHeader.Data = BFDAuthData(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 (d *BFD) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + data, err := b.PrependBytes(bfdMinimumRecordSizeInBytes) + if err != nil { + return err + } + + // Pack the first few fields into the first 32 bits. + data[0] = byte(byte(d.Version<<5) | byte(d.Diagnostic)) + h := uint8(0) + h |= (uint8(d.State) << 6) + h |= (uint8(bool2uint8(d.Poll)) << 5) + h |= (uint8(bool2uint8(d.Final)) << 4) + h |= (uint8(bool2uint8(d.ControlPlaneIndependent)) << 3) + h |= (uint8(bool2uint8(d.AuthPresent)) << 2) + h |= (uint8(bool2uint8(d.Demand)) << 1) + h |= uint8(bool2uint8(d.Multipoint)) + data[1] = byte(h) + data[2] = byte(d.DetectMultiplier) + data[3] = byte(d.Length()) + + // The remaining fields can just be copied in big endian order. + binary.BigEndian.PutUint32(data[4:], uint32(d.MyDiscriminator)) + binary.BigEndian.PutUint32(data[8:], uint32(d.YourDiscriminator)) + binary.BigEndian.PutUint32(data[12:], uint32(d.DesiredMinTxInterval)) + binary.BigEndian.PutUint32(data[16:], uint32(d.RequiredMinRxInterval)) + binary.BigEndian.PutUint32(data[20:], uint32(d.RequiredMinEchoRxInterval)) + + if d.AuthPresent && (d.AuthHeader != nil) { + auth, err := b.AppendBytes(int(d.AuthHeader.Length())) + if err != nil { + return err + } + + auth[0] = byte(d.AuthHeader.AuthType) + auth[1] = byte(d.AuthHeader.Length()) + auth[2] = byte(d.AuthHeader.KeyID) + + switch d.AuthHeader.AuthType { + case BFDAuthTypePassword: + copy(auth[3:], d.AuthHeader.Data) + case BFDAuthTypeKeyedMD5, BFDAuthTypeMeticulousKeyedMD5: + auth[3] = byte(0) + binary.BigEndian.PutUint32(auth[4:], uint32(d.AuthHeader.SequenceNumber)) + copy(auth[8:], d.AuthHeader.Data) + case BFDAuthTypeKeyedSHA1, BFDAuthTypeMeticulousKeyedSHA1: + auth[3] = byte(0) + binary.BigEndian.PutUint32(auth[4:], uint32(d.AuthHeader.SequenceNumber)) + copy(auth[8:], d.AuthHeader.Data) + } + } + + return nil +} + +// CanDecode returns a set of layers that BFD objects can decode. +// As BFD objects can only decide the BFD layer, we can return just that layer. +// Apparently a single layer type implements LayerClass. +func (d *BFD) CanDecode() gopacket.LayerClass { + return LayerTypeBFD +} + +// NextLayerType specifies the next layer that GoPacket should attempt to +// analyse after this (BFD) layer. As BFD packets do not contain any payload +// bytes, there are no further layers to analyse. +func (d *BFD) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypeZero +} + +// Payload returns an empty byte slice as BFD packets do not carry a payload +func (d *BFD) Payload() []byte { + return nil +} + +// bool2uint8 converts a bool to uint8 +func bool2uint8(b bool) uint8 { + if b { + return 1 + } + return 0 +} diff --git a/vendor/github.com/google/gopacket/layers/dhcpv4.go b/vendor/github.com/google/gopacket/layers/dhcpv4.go index 761b201a..3bbd036e 100644 --- a/vendor/github.com/google/gopacket/layers/dhcpv4.go +++ b/vendor/github.com/google/gopacket/layers/dhcpv4.go @@ -9,7 +9,6 @@ package layers import ( "bytes" "encoding/binary" - "errors" "fmt" "net" @@ -125,6 +124,7 @@ 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.Options = d.Options[:0] d.Operation = DHCPOp(data[0]) d.HardwareType = LinkType(data[1]) d.HardwareLen = data[2] @@ -140,7 +140,7 @@ func (d *DHCPv4) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error d.ServerName = data[44:108] d.File = data[108:236] if binary.BigEndian.Uint32(data[236:240]) != DHCPMagic { - return errors.New("Bad DHCP header") + return InvalidMagicCookie } if len(data) <= 240 { @@ -538,9 +538,6 @@ func (o *DHCPOption) encode(b []byte) error { 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) @@ -551,21 +548,38 @@ func (o *DHCPOption) encode(b []byte) error { 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") + return DecOptionNotEnoughData } 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") + if len(data) < 2 { + return DecOptionNotEnoughData } o.Length = data[1] - if o.Length > 253 { - return errors.New("data too long to decode") + if int(o.Length) > len(data[2:]) { + return DecOptionMalformed } - o.Data = data[2 : 2+o.Length] + o.Data = data[2 : 2+int(o.Length)] } return nil } + +// DHCPv4Error is used for constant errors for DHCPv4. It is needed for test asserts. +type DHCPv4Error string + +// DHCPv4Error implements error interface. +func (d DHCPv4Error) Error() string { + return string(d) +} + +const ( + // DecOptionNotEnoughData is returned when there is not enough data during option's decode process + DecOptionNotEnoughData = DHCPv4Error("Not enough data to decode") + // DecOptionMalformed is returned when the option is malformed + DecOptionMalformed = DHCPv4Error("Option is malformed") + // InvalidMagicCookie is returned when Magic cookie is missing into BOOTP header + InvalidMagicCookie = DHCPv4Error("Bad DHCP header") +) diff --git a/vendor/github.com/google/gopacket/layers/dhcpv6.go b/vendor/github.com/google/gopacket/layers/dhcpv6.go new file mode 100644 index 00000000..170f6ca5 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/dhcpv6.go @@ -0,0 +1,495 @@ +// Copyright 2018 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" +) + +// DHCPv6MsgType represents a DHCPv6 operation +type DHCPv6MsgType byte + +// Constants that represent DHCP operations +const ( + DHCPv6MsgTypeUnspecified DHCPv6MsgType = iota + DHCPv6MsgTypeSolicit + DHCPv6MsgTypeAdverstise + DHCPv6MsgTypeRequest + DHCPv6MsgTypeConfirm + DHCPv6MsgTypeRenew + DHCPv6MsgTypeRebind + DHCPv6MsgTypeReply + DHCPv6MsgTypeRelease + DHCPv6MsgTypeDecline + DHCPv6MsgTypeReconfigure + DHCPv6MsgTypeInformationRequest + DHCPv6MsgTypeRelayForward + DHCPv6MsgTypeRelayReply +) + +// String returns a string version of a DHCPv6MsgType. +func (o DHCPv6MsgType) String() string { + switch o { + case DHCPv6MsgTypeUnspecified: + return "Unspecified" + case DHCPv6MsgTypeSolicit: + return "Solicit" + case DHCPv6MsgTypeAdverstise: + return "Adverstise" + case DHCPv6MsgTypeRequest: + return "Request" + case DHCPv6MsgTypeConfirm: + return "Confirm" + case DHCPv6MsgTypeRenew: + return "Renew" + case DHCPv6MsgTypeRebind: + return "Rebind" + case DHCPv6MsgTypeReply: + return "Reply" + case DHCPv6MsgTypeRelease: + return "Release" + case DHCPv6MsgTypeDecline: + return "Decline" + case DHCPv6MsgTypeReconfigure: + return "Reconfigure" + case DHCPv6MsgTypeInformationRequest: + return "InformationRequest" + case DHCPv6MsgTypeRelayForward: + return "RelayForward" + case DHCPv6MsgTypeRelayReply: + return "RelayReply" + default: + return "Unknown" + } +} + +// DHCPv6 contains data for a single DHCP packet. +type DHCPv6 struct { + BaseLayer + MsgType DHCPv6MsgType + HopCount uint8 + LinkAddr net.IP + PeerAddr net.IP + TransactionID []byte + Options DHCPv6Options +} + +// LayerType returns gopacket.LayerTypeDHCPv6 +func (d *DHCPv6) LayerType() gopacket.LayerType { return LayerTypeDHCPv6 } + +// DecodeFromBytes decodes the given bytes into this layer. +func (d *DHCPv6) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + d.BaseLayer = BaseLayer{Contents: data} + d.Options = d.Options[:0] + d.MsgType = DHCPv6MsgType(data[0]) + + offset := 0 + if d.MsgType == DHCPv6MsgTypeRelayForward || d.MsgType == DHCPv6MsgTypeRelayReply { + d.HopCount = data[1] + d.LinkAddr = net.IP(data[2:18]) + d.PeerAddr = net.IP(data[18:34]) + offset = 34 + } else { + d.TransactionID = data[1:4] + offset = 4 + } + + stop := len(data) + for offset < stop { + o := DHCPv6Option{} + if err := o.decode(data[offset:]); err != nil { + return err + } + d.Options = append(d.Options, o) + offset += int(o.Length) + 4 // 2 from option code, 2 from option length + } + + return nil +} + +// Len returns the length of a DHCPv6 packet. +func (d *DHCPv6) Len() int { + n := 1 + if d.MsgType == DHCPv6MsgTypeRelayForward || d.MsgType == DHCPv6MsgTypeRelayReply { + n += 33 + } else { + n += 3 + } + + for _, o := range d.Options { + n += int(o.Length) + 4 // 2 from option code, 2 from option length + } + + 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 *DHCPv6) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + plen := int(d.Len()) + + data, err := b.PrependBytes(plen) + if err != nil { + return err + } + + offset := 0 + data[0] = byte(d.MsgType) + if d.MsgType == DHCPv6MsgTypeRelayForward || d.MsgType == DHCPv6MsgTypeRelayReply { + data[1] = byte(d.HopCount) + copy(data[2:18], d.LinkAddr.To16()) + copy(data[18:34], d.PeerAddr.To16()) + offset = 34 + } else { + copy(data[1:4], d.TransactionID) + offset = 4 + } + + if len(d.Options) > 0 { + for _, o := range d.Options { + if err := o.encode(data[offset:]); err != nil { + return err + } + offset += int(o.Length) + 4 // 2 from option code, 2 from option length + } + } + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (d *DHCPv6) CanDecode() gopacket.LayerClass { + return LayerTypeDHCPv6 +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (d *DHCPv6) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +func decodeDHCPv6(data []byte, p gopacket.PacketBuilder) error { + dhcp := &DHCPv6{} + err := dhcp.DecodeFromBytes(data, p) + if err != nil { + return err + } + p.AddLayer(dhcp) + return p.NextDecoder(gopacket.LayerTypePayload) +} + +// DHCPv6StatusCode represents a DHCP status code - RFC-3315 +type DHCPv6StatusCode byte + +// Constants for the DHCPv6StatusCode. +const ( + DHCPv6StatusCodeSuccess DHCPv6StatusCode = iota + DHCPv6StatusCodeUnspecFail + DHCPv6StatusCodeNoAddrsAvail + DHCPv6StatusCodeNoBinding + DHCPv6StatusCodeNotOnLink + DHCPv6StatusCodeUseMulticast +) + +// String returns a string version of a DHCPv6StatusCode. +func (o DHCPv6StatusCode) String() string { + switch o { + case DHCPv6StatusCodeSuccess: + return "Success" + case DHCPv6StatusCodeUnspecFail: + return "UnspecifiedFailure" + case DHCPv6StatusCodeNoAddrsAvail: + return "NoAddressAvailable" + case DHCPv6StatusCodeNoBinding: + return "NoBinding" + case DHCPv6StatusCodeNotOnLink: + return "NotOnLink" + case DHCPv6StatusCodeUseMulticast: + return "UseMulticast" + default: + return "Unknown" + } +} + +// DHCPv6Opt represents a DHCP option or parameter from RFC-3315 +type DHCPv6Opt uint16 + +// Constants for the DHCPv6Opt options. +const ( + DHCPv6OptClientID DHCPv6Opt = 1 + DHCPv6OptServerID DHCPv6Opt = 2 + DHCPv6OptIANA DHCPv6Opt = 3 + DHCPv6OptIATA DHCPv6Opt = 4 + DHCPv6OptIAAddr DHCPv6Opt = 5 + DHCPv6OptOro DHCPv6Opt = 6 + DHCPv6OptPreference DHCPv6Opt = 7 + DHCPv6OptElapsedTime DHCPv6Opt = 8 + DHCPv6OptRelayMessage DHCPv6Opt = 9 + DHCPv6OptAuth DHCPv6Opt = 11 + DHCPv6OptUnicast DHCPv6Opt = 12 + DHCPv6OptStatusCode DHCPv6Opt = 13 + DHCPv6OptRapidCommit DHCPv6Opt = 14 + DHCPv6OptUserClass DHCPv6Opt = 15 + DHCPv6OptVendorClass DHCPv6Opt = 16 + DHCPv6OptVendorOpts DHCPv6Opt = 17 + DHCPv6OptInterfaceID DHCPv6Opt = 18 + DHCPv6OptReconfigureMessage DHCPv6Opt = 19 + DHCPv6OptReconfigureAccept DHCPv6Opt = 20 +) + +// String returns a string version of a DHCPv6Opt. +func (o DHCPv6Opt) String() string { + switch o { + case DHCPv6OptClientID: + return "ClientID" + case DHCPv6OptServerID: + return "ServerID" + case DHCPv6OptIANA: + return "IA_NA" + case DHCPv6OptIATA: + return "IA_TA" + case DHCPv6OptIAAddr: + return "IAAddr" + case DHCPv6OptOro: + return "Oro" + case DHCPv6OptPreference: + return "Preference" + case DHCPv6OptElapsedTime: + return "ElapsedTime" + case DHCPv6OptRelayMessage: + return "RelayMessage" + case DHCPv6OptAuth: + return "Auth" + case DHCPv6OptUnicast: + return "Unicast" + case DHCPv6OptStatusCode: + return "StatusCode" + case DHCPv6OptRapidCommit: + return "RapidCommit" + case DHCPv6OptUserClass: + return "UserClass" + case DHCPv6OptVendorClass: + return "VendorClass" + case DHCPv6OptVendorOpts: + return "VendorOpts" + case DHCPv6OptInterfaceID: + return "InterfaceID" + case DHCPv6OptReconfigureMessage: + return "ReconfigureMessage" + case DHCPv6OptReconfigureAccept: + return "ReconfigureAccept" + default: + return "Unknown" + } +} + +// DHCPv6Options is used to get nicely printed option lists which would normally +// be cut off after 5 options. +type DHCPv6Options []DHCPv6Option + +// String returns a string version of the options list. +func (o DHCPv6Options) 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() +} + +// DHCPv6Option rerpresents a DHCP option. +type DHCPv6Option struct { + Code DHCPv6Opt + Length uint16 + Data []byte +} + +// String returns a string version of a DHCP Option. +func (o DHCPv6Option) String() string { + switch o.Code { + case DHCPv6OptClientID, DHCPv6OptServerID: + duid, err := decodeDHCPv6DUID(o.Data) + if err != nil { + return fmt.Sprintf("Option(%s:INVALID)", o.Code) + } + return fmt.Sprintf("Option(%s:[%s])", o.Code, duid.String()) + case DHCPv6OptOro: + options := "" + for i := 0; i < int(o.Length); i += 2 { + if options != "" { + options += "," + } + option := DHCPv6Opt(binary.BigEndian.Uint16(o.Data[i : i+2])) + options += option.String() + } + return fmt.Sprintf("Option(%s:[%s])", o.Code, options) + default: + return fmt.Sprintf("Option(%s:%v)", o.Code, o.Data) + } +} + +// NewDHCPv6Option constructs a new DHCPv6Option with a given type and data. +func NewDHCPv6Option(code DHCPv6Opt, data []byte) DHCPv6Option { + o := DHCPv6Option{Code: code} + if data != nil { + o.Data = data + o.Length = uint16(len(data)) + } + + return o +} + +func (o *DHCPv6Option) encode(b []byte) error { + binary.BigEndian.PutUint16(b[0:2], uint16(o.Code)) + binary.BigEndian.PutUint16(b[2:4], o.Length) + copy(b[4:], o.Data) + + return nil +} + +func (o *DHCPv6Option) decode(data []byte) error { + if len(data) < 2 { + return errors.New("Not enough data to decode") + } + o.Code = DHCPv6Opt(binary.BigEndian.Uint16(data[0:2])) + if len(data) < 3 { + return errors.New("Not enough data to decode") + } + o.Length = binary.BigEndian.Uint16(data[2:4]) + o.Data = data[4 : 4+o.Length] + return nil +} + +// DHCPv6DUIDType represents a DHCP DUID - RFC-3315 +type DHCPv6DUIDType uint16 + +// Constants for the DHCPv6DUIDType. +const ( + DHCPv6DUIDTypeLLT DHCPv6DUIDType = iota + 1 + DHCPv6DUIDTypeEN + DHCPv6DUIDTypeLL +) + +// String returns a string version of a DHCPv6DUIDType. +func (o DHCPv6DUIDType) String() string { + switch o { + case DHCPv6DUIDTypeLLT: + return "LLT" + case DHCPv6DUIDTypeEN: + return "EN" + case DHCPv6DUIDTypeLL: + return "LL" + default: + return "Unknown" + } +} + +// DHCPv6DUID means DHCP Unique Identifier as stated in RFC 3315, section 9 (https://tools.ietf.org/html/rfc3315#page-19) +type DHCPv6DUID struct { + Type DHCPv6DUIDType + // LLT, LL + HardwareType []byte + // EN + EnterpriseNumber []byte + // LLT + Time []byte + // LLT, LL + LinkLayerAddress net.HardwareAddr + // EN + Identifier []byte +} + +// DecodeFromBytes decodes the given bytes into a DHCPv6DUID +func (d *DHCPv6DUID) DecodeFromBytes(data []byte) error { + if len(data) < 2 { + return errors.New("Not enough bytes to decode: " + string(len(data))) + } + + d.Type = DHCPv6DUIDType(binary.BigEndian.Uint16(data[:2])) + if d.Type == DHCPv6DUIDTypeLLT || d.Type == DHCPv6DUIDTypeLL { + d.HardwareType = data[2:4] + } + + if d.Type == DHCPv6DUIDTypeLLT { + d.Time = data[4:8] + d.LinkLayerAddress = net.HardwareAddr(data[8:]) + } else if d.Type == DHCPv6DUIDTypeEN { + d.EnterpriseNumber = data[2:6] + d.Identifier = data[6:] + } else { // DHCPv6DUIDTypeLL + d.LinkLayerAddress = net.HardwareAddr(data[4:]) + } + + return nil +} + +// Encode encodes the DHCPv6DUID in a slice of bytes +func (d *DHCPv6DUID) Encode() []byte { + length := d.Len() + data := make([]byte, length) + binary.BigEndian.PutUint16(data[0:2], uint16(d.Type)) + + if d.Type == DHCPv6DUIDTypeLLT || d.Type == DHCPv6DUIDTypeLL { + copy(data[2:4], d.HardwareType) + } + + if d.Type == DHCPv6DUIDTypeLLT { + copy(data[4:8], d.Time) + copy(data[8:], d.LinkLayerAddress) + } else if d.Type == DHCPv6DUIDTypeEN { + copy(data[2:6], d.EnterpriseNumber) + copy(data[6:], d.Identifier) + } else { + copy(data[4:], d.LinkLayerAddress) + } + + return data +} + +// Len returns the length of the DHCPv6DUID, respecting the type +func (d *DHCPv6DUID) Len() int { + length := 2 // d.Type + if d.Type == DHCPv6DUIDTypeLLT { + length += 2 /*HardwareType*/ + 4 /*d.Time*/ + len(d.LinkLayerAddress) + } else if d.Type == DHCPv6DUIDTypeEN { + length += 4 /*d.EnterpriseNumber*/ + len(d.Identifier) + } else { // LL + length += 2 /*d.HardwareType*/ + len(d.LinkLayerAddress) + } + + return length +} + +func (d *DHCPv6DUID) String() string { + duid := "Type: " + d.Type.String() + ", " + if d.Type == DHCPv6DUIDTypeLLT { + duid += fmt.Sprintf("HardwareType: %v, Time: %v, LinkLayerAddress: %v", d.HardwareType, d.Time, d.LinkLayerAddress) + } else if d.Type == DHCPv6DUIDTypeEN { + duid += fmt.Sprintf("EnterpriseNumber: %v, Identifier: %v", d.EnterpriseNumber, d.Identifier) + } else { // DHCPv6DUIDTypeLL + duid += fmt.Sprintf("HardwareType: %v, LinkLayerAddress: %v", d.HardwareType, d.LinkLayerAddress) + } + return duid +} + +func decodeDHCPv6DUID(data []byte) (*DHCPv6DUID, error) { + duid := &DHCPv6DUID{} + err := duid.DecodeFromBytes(data) + if err != nil { + return nil, err + } + return duid, nil +} diff --git a/vendor/github.com/google/gopacket/layers/dns.go b/vendor/github.com/google/gopacket/layers/dns.go index 2368a28c..f3e4b08f 100644 --- a/vendor/github.com/google/gopacket/layers/dns.go +++ b/vendor/github.com/google/gopacket/layers/dns.go @@ -254,7 +254,7 @@ type DNS struct { TC bool // Truncated RD bool // Recursion desired RA bool // Recursion available - Z uint8 // Resrved for future use + Z uint8 // Reserved for future use ResponseCode DNSResponseCode QDCount uint16 // Number of questions to expect @@ -431,7 +431,7 @@ func recSize(rr *DNSResourceRecord) int { func computeSize(recs []DNSResourceRecord) int { sz := 0 for _, rr := range recs { - sz += len(rr.Name) + 14 + sz += len(rr.Name) + 12 sz += recSize(&rr) } return sz diff --git a/vendor/github.com/google/gopacket/layers/dot11.go b/vendor/github.com/google/gopacket/layers/dot11.go index 1b53026f..6a02ed3a 100644 --- a/vendor/github.com/google/gopacket/layers/dot11.go +++ b/vendor/github.com/google/gopacket/layers/dot11.go @@ -240,24 +240,172 @@ func (a Dot11Algorithm) String() string { 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 + Dot11InformationElementIDSSID Dot11InformationElementID = 0 + Dot11InformationElementIDRates Dot11InformationElementID = 1 + Dot11InformationElementIDFHSet Dot11InformationElementID = 2 + Dot11InformationElementIDDSSet Dot11InformationElementID = 3 + Dot11InformationElementIDCFSet Dot11InformationElementID = 4 + Dot11InformationElementIDTIM Dot11InformationElementID = 5 + Dot11InformationElementIDIBSSSet Dot11InformationElementID = 6 + Dot11InformationElementIDCountryInfo Dot11InformationElementID = 7 + Dot11InformationElementIDHoppingPatternParam Dot11InformationElementID = 8 + Dot11InformationElementIDHoppingPatternTable Dot11InformationElementID = 9 + Dot11InformationElementIDRequest Dot11InformationElementID = 10 + Dot11InformationElementIDQBSSLoadElem Dot11InformationElementID = 11 + Dot11InformationElementIDEDCAParamSet Dot11InformationElementID = 12 + Dot11InformationElementIDTrafficSpec Dot11InformationElementID = 13 + Dot11InformationElementIDTrafficClass Dot11InformationElementID = 14 + Dot11InformationElementIDSchedule Dot11InformationElementID = 15 + Dot11InformationElementIDChallenge Dot11InformationElementID = 16 + Dot11InformationElementIDPowerConst Dot11InformationElementID = 32 + Dot11InformationElementIDPowerCapability Dot11InformationElementID = 33 + Dot11InformationElementIDTPCRequest Dot11InformationElementID = 34 + Dot11InformationElementIDTPCReport Dot11InformationElementID = 35 + Dot11InformationElementIDSupportedChannels Dot11InformationElementID = 36 + Dot11InformationElementIDSwitchChannelAnnounce Dot11InformationElementID = 37 + Dot11InformationElementIDMeasureRequest Dot11InformationElementID = 38 + Dot11InformationElementIDMeasureReport Dot11InformationElementID = 39 + Dot11InformationElementIDQuiet Dot11InformationElementID = 40 + Dot11InformationElementIDIBSSDFS Dot11InformationElementID = 41 + Dot11InformationElementIDERPInfo Dot11InformationElementID = 42 + Dot11InformationElementIDTSDelay Dot11InformationElementID = 43 + Dot11InformationElementIDTCLASProcessing Dot11InformationElementID = 44 + Dot11InformationElementIDHTCapabilities Dot11InformationElementID = 45 + Dot11InformationElementIDQOSCapability Dot11InformationElementID = 46 + Dot11InformationElementIDERPInfo2 Dot11InformationElementID = 47 + Dot11InformationElementIDRSNInfo Dot11InformationElementID = 48 + Dot11InformationElementIDESRates Dot11InformationElementID = 50 + Dot11InformationElementIDAPChannelReport Dot11InformationElementID = 51 + Dot11InformationElementIDNeighborReport Dot11InformationElementID = 52 + Dot11InformationElementIDRCPI Dot11InformationElementID = 53 + Dot11InformationElementIDMobilityDomain Dot11InformationElementID = 54 + Dot11InformationElementIDFastBSSTrans Dot11InformationElementID = 55 + Dot11InformationElementIDTimeoutInt Dot11InformationElementID = 56 + Dot11InformationElementIDRICData Dot11InformationElementID = 57 + Dot11InformationElementIDDSERegisteredLoc Dot11InformationElementID = 58 + Dot11InformationElementIDSuppOperatingClass Dot11InformationElementID = 59 + Dot11InformationElementIDExtChanSwitchAnnounce Dot11InformationElementID = 60 + Dot11InformationElementIDHTInfo Dot11InformationElementID = 61 + Dot11InformationElementIDSecChanOffset Dot11InformationElementID = 62 + Dot11InformationElementIDBSSAverageAccessDelay Dot11InformationElementID = 63 + Dot11InformationElementIDAntenna Dot11InformationElementID = 64 + Dot11InformationElementIDRSNI Dot11InformationElementID = 65 + Dot11InformationElementIDMeasurePilotTrans Dot11InformationElementID = 66 + Dot11InformationElementIDBSSAvailAdmCapacity Dot11InformationElementID = 67 + Dot11InformationElementIDBSSACAccDelayWAPIParam Dot11InformationElementID = 68 + Dot11InformationElementIDTimeAdvertisement Dot11InformationElementID = 69 + Dot11InformationElementIDRMEnabledCapabilities Dot11InformationElementID = 70 + Dot11InformationElementIDMultipleBSSID Dot11InformationElementID = 71 + Dot11InformationElementID2040BSSCoExist Dot11InformationElementID = 72 + Dot11InformationElementID2040BSSIntChanReport Dot11InformationElementID = 73 + Dot11InformationElementIDOverlapBSSScanParam Dot11InformationElementID = 74 + Dot11InformationElementIDRICDescriptor Dot11InformationElementID = 75 + Dot11InformationElementIDManagementMIC Dot11InformationElementID = 76 + Dot11InformationElementIDEventRequest Dot11InformationElementID = 78 + Dot11InformationElementIDEventReport Dot11InformationElementID = 79 + Dot11InformationElementIDDiagnosticRequest Dot11InformationElementID = 80 + Dot11InformationElementIDDiagnosticReport Dot11InformationElementID = 81 + Dot11InformationElementIDLocationParam Dot11InformationElementID = 82 + Dot11InformationElementIDNonTransBSSIDCapability Dot11InformationElementID = 83 + Dot11InformationElementIDSSIDList Dot11InformationElementID = 84 + Dot11InformationElementIDMultipleBSSIDIndex Dot11InformationElementID = 85 + Dot11InformationElementIDFMSDescriptor Dot11InformationElementID = 86 + Dot11InformationElementIDFMSRequest Dot11InformationElementID = 87 + Dot11InformationElementIDFMSResponse Dot11InformationElementID = 88 + Dot11InformationElementIDQOSTrafficCapability Dot11InformationElementID = 89 + Dot11InformationElementIDBSSMaxIdlePeriod Dot11InformationElementID = 90 + Dot11InformationElementIDTFSRequest Dot11InformationElementID = 91 + Dot11InformationElementIDTFSResponse Dot11InformationElementID = 92 + Dot11InformationElementIDWNMSleepMode Dot11InformationElementID = 93 + Dot11InformationElementIDTIMBroadcastRequest Dot11InformationElementID = 94 + Dot11InformationElementIDTIMBroadcastResponse Dot11InformationElementID = 95 + Dot11InformationElementIDCollInterferenceReport Dot11InformationElementID = 96 + Dot11InformationElementIDChannelUsage Dot11InformationElementID = 97 + Dot11InformationElementIDTimeZone Dot11InformationElementID = 98 + Dot11InformationElementIDDMSRequest Dot11InformationElementID = 99 + Dot11InformationElementIDDMSResponse Dot11InformationElementID = 100 + Dot11InformationElementIDLinkIdentifier Dot11InformationElementID = 101 + Dot11InformationElementIDWakeupSchedule Dot11InformationElementID = 102 + Dot11InformationElementIDChannelSwitchTiming Dot11InformationElementID = 104 + Dot11InformationElementIDPTIControl Dot11InformationElementID = 105 + Dot11InformationElementIDPUBufferStatus Dot11InformationElementID = 106 + Dot11InformationElementIDInterworking Dot11InformationElementID = 107 + Dot11InformationElementIDAdvertisementProtocol Dot11InformationElementID = 108 + Dot11InformationElementIDExpBWRequest Dot11InformationElementID = 109 + Dot11InformationElementIDQOSMapSet Dot11InformationElementID = 110 + Dot11InformationElementIDRoamingConsortium Dot11InformationElementID = 111 + Dot11InformationElementIDEmergencyAlertIdentifier Dot11InformationElementID = 112 + Dot11InformationElementIDMeshConfiguration Dot11InformationElementID = 113 + Dot11InformationElementIDMeshID Dot11InformationElementID = 114 + Dot11InformationElementIDMeshLinkMetricReport Dot11InformationElementID = 115 + Dot11InformationElementIDCongestionNotification Dot11InformationElementID = 116 + Dot11InformationElementIDMeshPeeringManagement Dot11InformationElementID = 117 + Dot11InformationElementIDMeshChannelSwitchParam Dot11InformationElementID = 118 + Dot11InformationElementIDMeshAwakeWindows Dot11InformationElementID = 119 + Dot11InformationElementIDBeaconTiming Dot11InformationElementID = 120 + Dot11InformationElementIDMCCAOPSetupRequest Dot11InformationElementID = 121 + Dot11InformationElementIDMCCAOPSetupReply Dot11InformationElementID = 122 + Dot11InformationElementIDMCCAOPAdvertisement Dot11InformationElementID = 123 + Dot11InformationElementIDMCCAOPTeardown Dot11InformationElementID = 124 + Dot11InformationElementIDGateAnnouncement Dot11InformationElementID = 125 + Dot11InformationElementIDRootAnnouncement Dot11InformationElementID = 126 + Dot11InformationElementIDExtCapability Dot11InformationElementID = 127 + Dot11InformationElementIDAgereProprietary Dot11InformationElementID = 128 + Dot11InformationElementIDPathRequest Dot11InformationElementID = 130 + Dot11InformationElementIDPathReply Dot11InformationElementID = 131 + Dot11InformationElementIDPathError Dot11InformationElementID = 132 + Dot11InformationElementIDCiscoCCX1CKIPDeviceName Dot11InformationElementID = 133 + Dot11InformationElementIDCiscoCCX2 Dot11InformationElementID = 136 + Dot11InformationElementIDProxyUpdate Dot11InformationElementID = 137 + Dot11InformationElementIDProxyUpdateConfirmation Dot11InformationElementID = 138 + Dot11InformationElementIDAuthMeshPerringExch Dot11InformationElementID = 139 + Dot11InformationElementIDMIC Dot11InformationElementID = 140 + Dot11InformationElementIDDestinationURI Dot11InformationElementID = 141 + Dot11InformationElementIDUAPSDCoexistence Dot11InformationElementID = 142 + Dot11InformationElementIDWakeupSchedule80211ad Dot11InformationElementID = 143 + Dot11InformationElementIDExtendedSchedule Dot11InformationElementID = 144 + Dot11InformationElementIDSTAAvailability Dot11InformationElementID = 145 + Dot11InformationElementIDDMGTSPEC Dot11InformationElementID = 146 + Dot11InformationElementIDNextDMGATI Dot11InformationElementID = 147 + Dot11InformationElementIDDMSCapabilities Dot11InformationElementID = 148 + Dot11InformationElementIDCiscoUnknown95 Dot11InformationElementID = 149 + Dot11InformationElementIDVendor2 Dot11InformationElementID = 150 + Dot11InformationElementIDDMGOperating Dot11InformationElementID = 151 + Dot11InformationElementIDDMGBSSParamChange Dot11InformationElementID = 152 + Dot11InformationElementIDDMGBeamRefinement Dot11InformationElementID = 153 + Dot11InformationElementIDChannelMeasFeedback Dot11InformationElementID = 154 + Dot11InformationElementIDAwakeWindow Dot11InformationElementID = 157 + Dot11InformationElementIDMultiBand Dot11InformationElementID = 158 + Dot11InformationElementIDADDBAExtension Dot11InformationElementID = 159 + Dot11InformationElementIDNEXTPCPList Dot11InformationElementID = 160 + Dot11InformationElementIDPCPHandover Dot11InformationElementID = 161 + Dot11InformationElementIDDMGLinkMargin Dot11InformationElementID = 162 + Dot11InformationElementIDSwitchingStream Dot11InformationElementID = 163 + Dot11InformationElementIDSessionTransmission Dot11InformationElementID = 164 + Dot11InformationElementIDDynamicTonePairReport Dot11InformationElementID = 165 + Dot11InformationElementIDClusterReport Dot11InformationElementID = 166 + Dot11InformationElementIDRelayCapabilities Dot11InformationElementID = 167 + Dot11InformationElementIDRelayTransferParameter Dot11InformationElementID = 168 + Dot11InformationElementIDBeamlinkMaintenance Dot11InformationElementID = 169 + Dot11InformationElementIDMultipleMacSublayers Dot11InformationElementID = 170 + Dot11InformationElementIDUPID Dot11InformationElementID = 171 + Dot11InformationElementIDDMGLinkAdaptionAck Dot11InformationElementID = 172 + Dot11InformationElementIDSymbolProprietary Dot11InformationElementID = 173 + Dot11InformationElementIDMCCAOPAdvertOverview Dot11InformationElementID = 174 + Dot11InformationElementIDQuietPeriodRequest Dot11InformationElementID = 175 + Dot11InformationElementIDQuietPeriodResponse Dot11InformationElementID = 177 + Dot11InformationElementIDECPACPolicy Dot11InformationElementID = 182 + Dot11InformationElementIDClusterTimeOffset Dot11InformationElementID = 183 + Dot11InformationElementIDAntennaSectorID Dot11InformationElementID = 190 + Dot11InformationElementIDVHTCapabilities Dot11InformationElementID = 191 + Dot11InformationElementIDVHTOperation Dot11InformationElementID = 192 + Dot11InformationElementIDExtendedBSSLoad Dot11InformationElementID = 193 + Dot11InformationElementIDWideBWChannelSwitch Dot11InformationElementID = 194 + Dot11InformationElementIDVHTTxPowerEnvelope Dot11InformationElementID = 195 + Dot11InformationElementIDChannelSwitchWrapper Dot11InformationElementID = 196 + Dot11InformationElementIDOperatingModeNotification Dot11InformationElementID = 199 + Dot11InformationElementIDVendor Dot11InformationElementID = 221 ) // String provides a human readable string for Dot11InformationElementID. @@ -267,35 +415,335 @@ const ( func (a Dot11InformationElementID) String() string { switch a { case Dot11InformationElementIDSSID: - return "SSID" + return "SSID parameter set" case Dot11InformationElementIDRates: - return "Rates" + return "Supported Rates" case Dot11InformationElementIDFHSet: - return "FHset" + return "FH Parameter set" case Dot11InformationElementIDDSSet: - return "DSset" + return "DS Parameter set" case Dot11InformationElementIDCFSet: - return "CFset" + return "CF Parameter set" case Dot11InformationElementIDTIM: - return "TIM" + return "Traffic Indication Map (TIM)" case Dot11InformationElementIDIBSSSet: - return "IBSSset" + return "IBSS Parameter set" + case Dot11InformationElementIDCountryInfo: + return "Country Information" + case Dot11InformationElementIDHoppingPatternParam: + return "Hopping Pattern Parameters" + case Dot11InformationElementIDHoppingPatternTable: + return "Hopping Pattern Table" + case Dot11InformationElementIDRequest: + return "Request" + case Dot11InformationElementIDQBSSLoadElem: + return "QBSS Load Element" + case Dot11InformationElementIDEDCAParamSet: + return "EDCA Parameter Set" + case Dot11InformationElementIDTrafficSpec: + return "Traffic Specification" + case Dot11InformationElementIDTrafficClass: + return "Traffic Classification" + case Dot11InformationElementIDSchedule: + return "Schedule" case Dot11InformationElementIDChallenge: - return "Challenge" + return "Challenge text" + case Dot11InformationElementIDPowerConst: + return "Power Constraint" + case Dot11InformationElementIDPowerCapability: + return "Power Capability" + case Dot11InformationElementIDTPCRequest: + return "TPC Request" + case Dot11InformationElementIDTPCReport: + return "TPC Report" + case Dot11InformationElementIDSupportedChannels: + return "Supported Channels" + case Dot11InformationElementIDSwitchChannelAnnounce: + return "Channel Switch Announcement" + case Dot11InformationElementIDMeasureRequest: + return "Measurement Request" + case Dot11InformationElementIDMeasureReport: + return "Measurement Report" + case Dot11InformationElementIDQuiet: + return "Quiet" + case Dot11InformationElementIDIBSSDFS: + return "IBSS DFS" case Dot11InformationElementIDERPInfo: - return "ERPinfo" + return "ERP Information" + case Dot11InformationElementIDTSDelay: + return "TS Delay" + case Dot11InformationElementIDTCLASProcessing: + return "TCLAS Processing" + case Dot11InformationElementIDHTCapabilities: + return "HT Capabilities (802.11n D1.10)" case Dot11InformationElementIDQOSCapability: - return "QOS capability" + return "QOS Capability" case Dot11InformationElementIDERPInfo2: - return "ERPinfo2" + return "ERP Information-2" case Dot11InformationElementIDRSNInfo: - return "RSNinfo" + return "RSN Information" case Dot11InformationElementIDESRates: - return "ESrates" + return "Extended Supported Rates" + case Dot11InformationElementIDAPChannelReport: + return "AP Channel Report" + case Dot11InformationElementIDNeighborReport: + return "Neighbor Report" + case Dot11InformationElementIDRCPI: + return "RCPI" + case Dot11InformationElementIDMobilityDomain: + return "Mobility Domain" + case Dot11InformationElementIDFastBSSTrans: + return "Fast BSS Transition" + case Dot11InformationElementIDTimeoutInt: + return "Timeout Interval" + case Dot11InformationElementIDRICData: + return "RIC Data" + case Dot11InformationElementIDDSERegisteredLoc: + return "DSE Registered Location" + case Dot11InformationElementIDSuppOperatingClass: + return "Supported Operating Classes" + case Dot11InformationElementIDExtChanSwitchAnnounce: + return "Extended Channel Switch Announcement" + case Dot11InformationElementIDHTInfo: + return "HT Information (802.11n D1.10)" + case Dot11InformationElementIDSecChanOffset: + return "Secondary Channel Offset (802.11n D1.10)" + case Dot11InformationElementIDBSSAverageAccessDelay: + return "BSS Average Access Delay" + case Dot11InformationElementIDAntenna: + return "Antenna" + case Dot11InformationElementIDRSNI: + return "RSNI" + case Dot11InformationElementIDMeasurePilotTrans: + return "Measurement Pilot Transmission" + case Dot11InformationElementIDBSSAvailAdmCapacity: + return "BSS Available Admission Capacity" + case Dot11InformationElementIDBSSACAccDelayWAPIParam: + return "BSS AC Access Delay/WAPI Parameter Set" + case Dot11InformationElementIDTimeAdvertisement: + return "Time Advertisement" + case Dot11InformationElementIDRMEnabledCapabilities: + return "RM Enabled Capabilities" + case Dot11InformationElementIDMultipleBSSID: + return "Multiple BSSID" + case Dot11InformationElementID2040BSSCoExist: + return "20/40 BSS Coexistence" + case Dot11InformationElementID2040BSSIntChanReport: + return "20/40 BSS Intolerant Channel Report" + case Dot11InformationElementIDOverlapBSSScanParam: + return "Overlapping BSS Scan Parameters" + case Dot11InformationElementIDRICDescriptor: + return "RIC Descriptor" + case Dot11InformationElementIDManagementMIC: + return "Management MIC" + case Dot11InformationElementIDEventRequest: + return "Event Request" + case Dot11InformationElementIDEventReport: + return "Event Report" + case Dot11InformationElementIDDiagnosticRequest: + return "Diagnostic Request" + case Dot11InformationElementIDDiagnosticReport: + return "Diagnostic Report" + case Dot11InformationElementIDLocationParam: + return "Location Parameters" + case Dot11InformationElementIDNonTransBSSIDCapability: + return "Non Transmitted BSSID Capability" + case Dot11InformationElementIDSSIDList: + return "SSID List" + case Dot11InformationElementIDMultipleBSSIDIndex: + return "Multiple BSSID Index" + case Dot11InformationElementIDFMSDescriptor: + return "FMS Descriptor" + case Dot11InformationElementIDFMSRequest: + return "FMS Request" + case Dot11InformationElementIDFMSResponse: + return "FMS Response" + case Dot11InformationElementIDQOSTrafficCapability: + return "QoS Traffic Capability" + case Dot11InformationElementIDBSSMaxIdlePeriod: + return "BSS Max Idle Period" + case Dot11InformationElementIDTFSRequest: + return "TFS Request" + case Dot11InformationElementIDTFSResponse: + return "TFS Response" + case Dot11InformationElementIDWNMSleepMode: + return "WNM-Sleep Mode" + case Dot11InformationElementIDTIMBroadcastRequest: + return "TIM Broadcast Request" + case Dot11InformationElementIDTIMBroadcastResponse: + return "TIM Broadcast Response" + case Dot11InformationElementIDCollInterferenceReport: + return "Collocated Interference Report" + case Dot11InformationElementIDChannelUsage: + return "Channel Usage" + case Dot11InformationElementIDTimeZone: + return "Time Zone" + case Dot11InformationElementIDDMSRequest: + return "DMS Request" + case Dot11InformationElementIDDMSResponse: + return "DMS Response" + case Dot11InformationElementIDLinkIdentifier: + return "Link Identifier" + case Dot11InformationElementIDWakeupSchedule: + return "Wakeup Schedule" + case Dot11InformationElementIDChannelSwitchTiming: + return "Channel Switch Timing" + case Dot11InformationElementIDPTIControl: + return "PTI Control" + case Dot11InformationElementIDPUBufferStatus: + return "PU Buffer Status" + case Dot11InformationElementIDInterworking: + return "Interworking" + case Dot11InformationElementIDAdvertisementProtocol: + return "Advertisement Protocol" + case Dot11InformationElementIDExpBWRequest: + return "Expedited Bandwidth Request" + case Dot11InformationElementIDQOSMapSet: + return "QoS Map Set" + case Dot11InformationElementIDRoamingConsortium: + return "Roaming Consortium" + case Dot11InformationElementIDEmergencyAlertIdentifier: + return "Emergency Alert Identifier" + case Dot11InformationElementIDMeshConfiguration: + return "Mesh Configuration" + case Dot11InformationElementIDMeshID: + return "Mesh ID" + case Dot11InformationElementIDMeshLinkMetricReport: + return "Mesh Link Metric Report" + case Dot11InformationElementIDCongestionNotification: + return "Congestion Notification" + case Dot11InformationElementIDMeshPeeringManagement: + return "Mesh Peering Management" + case Dot11InformationElementIDMeshChannelSwitchParam: + return "Mesh Channel Switch Parameters" + case Dot11InformationElementIDMeshAwakeWindows: + return "Mesh Awake Windows" + case Dot11InformationElementIDBeaconTiming: + return "Beacon Timing" + case Dot11InformationElementIDMCCAOPSetupRequest: + return "MCCAOP Setup Request" + case Dot11InformationElementIDMCCAOPSetupReply: + return "MCCAOP SETUP Reply" + case Dot11InformationElementIDMCCAOPAdvertisement: + return "MCCAOP Advertisement" + case Dot11InformationElementIDMCCAOPTeardown: + return "MCCAOP Teardown" + case Dot11InformationElementIDGateAnnouncement: + return "Gate Announcement" + case Dot11InformationElementIDRootAnnouncement: + return "Root Announcement" + case Dot11InformationElementIDExtCapability: + return "Extended Capabilities" + case Dot11InformationElementIDAgereProprietary: + return "Agere Proprietary" + case Dot11InformationElementIDPathRequest: + return "Path Request" + case Dot11InformationElementIDPathReply: + return "Path Reply" + case Dot11InformationElementIDPathError: + return "Path Error" + case Dot11InformationElementIDCiscoCCX1CKIPDeviceName: + return "Cisco CCX1 CKIP + Device Name" + case Dot11InformationElementIDCiscoCCX2: + return "Cisco CCX2" + case Dot11InformationElementIDProxyUpdate: + return "Proxy Update" + case Dot11InformationElementIDProxyUpdateConfirmation: + return "Proxy Update Confirmation" + case Dot11InformationElementIDAuthMeshPerringExch: + return "Auhenticated Mesh Perring Exchange" + case Dot11InformationElementIDMIC: + return "MIC (Message Integrity Code)" + case Dot11InformationElementIDDestinationURI: + return "Destination URI" + case Dot11InformationElementIDUAPSDCoexistence: + return "U-APSD Coexistence" + case Dot11InformationElementIDWakeupSchedule80211ad: + return "Wakeup Schedule 802.11ad" + case Dot11InformationElementIDExtendedSchedule: + return "Extended Schedule" + case Dot11InformationElementIDSTAAvailability: + return "STA Availability" + case Dot11InformationElementIDDMGTSPEC: + return "DMG TSPEC" + case Dot11InformationElementIDNextDMGATI: + return "Next DMG ATI" + case Dot11InformationElementIDDMSCapabilities: + return "DMG Capabilities" + case Dot11InformationElementIDCiscoUnknown95: + return "Cisco Unknown 95" + case Dot11InformationElementIDVendor2: + return "Vendor Specific" + case Dot11InformationElementIDDMGOperating: + return "DMG Operating" + case Dot11InformationElementIDDMGBSSParamChange: + return "DMG BSS Parameter Change" + case Dot11InformationElementIDDMGBeamRefinement: + return "DMG Beam Refinement" + case Dot11InformationElementIDChannelMeasFeedback: + return "Channel Measurement Feedback" + case Dot11InformationElementIDAwakeWindow: + return "Awake Window" + case Dot11InformationElementIDMultiBand: + return "Multi Band" + case Dot11InformationElementIDADDBAExtension: + return "ADDBA Extension" + case Dot11InformationElementIDNEXTPCPList: + return "NEXTPCP List" + case Dot11InformationElementIDPCPHandover: + return "PCP Handover" + case Dot11InformationElementIDDMGLinkMargin: + return "DMG Link Margin" + case Dot11InformationElementIDSwitchingStream: + return "Switching Stream" + case Dot11InformationElementIDSessionTransmission: + return "Session Transmission" + case Dot11InformationElementIDDynamicTonePairReport: + return "Dynamic Tone Pairing Report" + case Dot11InformationElementIDClusterReport: + return "Cluster Report" + case Dot11InformationElementIDRelayCapabilities: + return "Relay Capabilities" + case Dot11InformationElementIDRelayTransferParameter: + return "Relay Transfer Parameter" + case Dot11InformationElementIDBeamlinkMaintenance: + return "Beamlink Maintenance" + case Dot11InformationElementIDMultipleMacSublayers: + return "Multiple MAC Sublayers" + case Dot11InformationElementIDUPID: + return "U-PID" + case Dot11InformationElementIDDMGLinkAdaptionAck: + return "DMG Link Adaption Acknowledgment" + case Dot11InformationElementIDSymbolProprietary: + return "Symbol Proprietary" + case Dot11InformationElementIDMCCAOPAdvertOverview: + return "MCCAOP Advertisement Overview" + case Dot11InformationElementIDQuietPeriodRequest: + return "Quiet Period Request" + case Dot11InformationElementIDQuietPeriodResponse: + return "Quiet Period Response" + case Dot11InformationElementIDECPACPolicy: + return "ECPAC Policy" + case Dot11InformationElementIDClusterTimeOffset: + return "Cluster Time Offset" + case Dot11InformationElementIDAntennaSectorID: + return "Antenna Sector ID" + case Dot11InformationElementIDVHTCapabilities: + return "VHT Capabilities (IEEE Std 802.11ac/D3.1)" + case Dot11InformationElementIDVHTOperation: + return "VHT Operation (IEEE Std 802.11ac/D3.1)" + case Dot11InformationElementIDExtendedBSSLoad: + return "Extended BSS Load" + case Dot11InformationElementIDWideBWChannelSwitch: + return "Wide Bandwidth Channel Switch" + case Dot11InformationElementIDVHTTxPowerEnvelope: + return "VHT Tx Power Envelope (IEEE Std 802.11ac/D5.0)" + case Dot11InformationElementIDChannelSwitchWrapper: + return "Channel Switch Wrapper" + case Dot11InformationElementIDOperatingModeNotification: + return "Operating Mode Notification" case Dot11InformationElementIDVendor: return "Vendor" - case Dot11InformationElementIDReserved: - return "Reserved" default: return "Unknown information element id" } @@ -303,7 +751,7 @@ func (a Dot11InformationElementID) String() string { // Dot11 provides an IEEE 802.11 base packet header. // See http://standards.ieee.org/findstds/standard/802.11-2012.html -// for excrutiating detail. +// for excruciating detail. type Dot11 struct { BaseLayer Type Dot11Type @@ -317,23 +765,138 @@ type Dot11 struct { SequenceNumber uint16 FragmentNumber uint16 Checksum uint32 + QOS *Dot11QOS + HTControl *Dot11HTControl + DataLayer gopacket.Layer +} + +type Dot11QOS struct { + TID uint8 /* Traffic IDentifier */ + EOSP bool /* End of service period */ + AckPolicy Dot11AckPolicy + TXOP uint8 +} + +type Dot11HTControl struct { + ACConstraint bool + RDGMorePPDU bool + + VHT *Dot11HTControlVHT + HT *Dot11HTControlHT +} + +type Dot11HTControlHT struct { + LinkAdapationControl *Dot11LinkAdapationControl + CalibrationPosition uint8 + CalibrationSequence uint8 + CSISteering uint8 + NDPAnnouncement bool + DEI bool +} + +type Dot11HTControlVHT struct { + MRQ bool + UnsolicitedMFB bool + MSI *uint8 + MFB Dot11HTControlMFB + CompressedMSI *uint8 + STBCIndication bool + MFSI *uint8 + GID *uint8 + CodingType *Dot11CodingType + FbTXBeamformed bool +} + +type Dot11HTControlMFB struct { + NumSTS uint8 + VHTMCS uint8 + BW uint8 + SNR int8 +} + +type Dot11LinkAdapationControl struct { + TRQ bool + MRQ bool + MSI uint8 + MFSI uint8 + ASEL *Dot11ASEL + MFB *uint8 +} + +type Dot11ASEL struct { + Command uint8 + Data uint8 +} + +type Dot11CodingType uint8 + +const ( + Dot11CodingTypeBCC = 0 + Dot11CodingTypeLDPC = 1 +) + +func (a Dot11CodingType) String() string { + switch a { + case Dot11CodingTypeBCC: + return "BCC" + case Dot11CodingTypeLDPC: + return "LDPC" + default: + return "Unknown coding type" + } +} + +func (m *Dot11HTControlMFB) NoFeedBackPresent() bool { + return m.VHTMCS == 15 && m.NumSTS == 7 } func decodeDot11(data []byte, p gopacket.PacketBuilder) error { d := &Dot11{} - return decodingLayerDecoder(d, data, p) + err := d.DecodeFromBytes(data, p) + if err != nil { + return err + } + p.AddLayer(d) + if d.DataLayer != nil { + p.AddLayer(d.DataLayer) + } + return p.NextDecoder(d.NextLayerType()) } 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) + if m.DataLayer != nil { + if m.Flags.WEP() { + return LayerTypeDot11WEP + } + return m.DataLayer.(gopacket.DecodingLayer).NextLayerType() } - return m.Type.LayerType() } +func createU8(x uint8) *uint8 { + return &x +} + +var dataDecodeMap = map[Dot11Type]func() gopacket.DecodingLayer{ + Dot11TypeData: func() gopacket.DecodingLayer { return &Dot11Data{} }, + Dot11TypeDataCFAck: func() gopacket.DecodingLayer { return &Dot11DataCFAck{} }, + Dot11TypeDataCFPoll: func() gopacket.DecodingLayer { return &Dot11DataCFPoll{} }, + Dot11TypeDataCFAckPoll: func() gopacket.DecodingLayer { return &Dot11DataCFAckPoll{} }, + Dot11TypeDataNull: func() gopacket.DecodingLayer { return &Dot11DataNull{} }, + Dot11TypeDataCFAckNoData: func() gopacket.DecodingLayer { return &Dot11DataCFAckNoData{} }, + Dot11TypeDataCFPollNoData: func() gopacket.DecodingLayer { return &Dot11DataCFPollNoData{} }, + Dot11TypeDataCFAckPollNoData: func() gopacket.DecodingLayer { return &Dot11DataCFAckPollNoData{} }, + Dot11TypeDataQOSData: func() gopacket.DecodingLayer { return &Dot11DataQOSData{} }, + Dot11TypeDataQOSDataCFAck: func() gopacket.DecodingLayer { return &Dot11DataQOSDataCFAck{} }, + Dot11TypeDataQOSDataCFPoll: func() gopacket.DecodingLayer { return &Dot11DataQOSDataCFPoll{} }, + Dot11TypeDataQOSDataCFAckPoll: func() gopacket.DecodingLayer { return &Dot11DataQOSDataCFAckPoll{} }, + Dot11TypeDataQOSNull: func() gopacket.DecodingLayer { return &Dot11DataQOSNull{} }, + Dot11TypeDataQOSCFPollNoData: func() gopacket.DecodingLayer { return &Dot11DataQOSCFPollNoData{} }, + Dot11TypeDataQOSCFAckPollNoData: func() gopacket.DecodingLayer { return &Dot11DataQOSCFAckPollNoData{} }, +} + func (m *Dot11) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { if len(data) < 10 { df.SetTruncated() @@ -385,7 +948,112 @@ func (m *Dot11) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { offset += 6 } - m.BaseLayer = BaseLayer{Contents: data[0:offset], Payload: data[offset : len(data)-4]} + if m.Type.QOS() { + if len(data) < offset+2 { + df.SetTruncated() + return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+6) + } + m.QOS = &Dot11QOS{ + TID: (uint8(data[offset]) & 0x0F), + EOSP: (uint8(data[offset]) & 0x10) == 0x10, + AckPolicy: Dot11AckPolicy((uint8(data[offset]) & 0x60) >> 5), + TXOP: uint8(data[offset+1]), + } + offset += 2 + } + if m.Flags.Order() && (m.Type.QOS() || mainType == Dot11TypeMgmt) { + if len(data) < offset+4 { + df.SetTruncated() + return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+6) + } + + htc := &Dot11HTControl{ + ACConstraint: data[offset+3]&0x40 != 0, + RDGMorePPDU: data[offset+3]&0x80 != 0, + } + m.HTControl = htc + + if data[offset]&0x1 != 0 { // VHT Variant + vht := &Dot11HTControlVHT{} + htc.VHT = vht + vht.MRQ = data[offset]&0x4 != 0 + vht.UnsolicitedMFB = data[offset+3]&0x20 != 0 + vht.MFB = Dot11HTControlMFB{ + NumSTS: uint8(data[offset+1] >> 1 & 0x7), + VHTMCS: uint8(data[offset+1] >> 4 & 0xF), + BW: uint8(data[offset+2] & 0x3), + SNR: int8((-(data[offset+2] >> 2 & 0x20))+data[offset+2]>>2&0x1F) + 22, + } + + if vht.UnsolicitedMFB { + if !vht.MFB.NoFeedBackPresent() { + vht.CompressedMSI = createU8(data[offset] >> 3 & 0x3) + vht.STBCIndication = data[offset]&0x20 != 0 + vht.CodingType = (*Dot11CodingType)(createU8(data[offset+3] >> 3 & 0x1)) + vht.FbTXBeamformed = data[offset+3]&0x10 != 0 + vht.GID = createU8( + data[offset]>>6 + + (data[offset+1] & 0x1 << 2) + + data[offset+3]&0x7<<3) + } + } else { + if vht.MRQ { + vht.MSI = createU8((data[offset] >> 3) & 0x07) + } + vht.MFSI = createU8(data[offset]>>6 + (data[offset+1] & 0x1 << 2)) + } + + } else { // HT Variant + ht := &Dot11HTControlHT{} + htc.HT = ht + + lac := &Dot11LinkAdapationControl{} + ht.LinkAdapationControl = lac + lac.TRQ = data[offset]&0x2 != 0 + lac.MFSI = data[offset]>>6&0x3 + data[offset+1]&0x1<<3 + if data[offset]&0x3C == 0x38 { // ASEL + lac.ASEL = &Dot11ASEL{ + Command: data[offset+1] >> 1 & 0x7, + Data: data[offset+1] >> 4 & 0xF, + } + } else { + lac.MRQ = data[offset]&0x4 != 0 + if lac.MRQ { + lac.MSI = data[offset] >> 3 & 0x7 + } + lac.MFB = createU8(data[offset+1] >> 1) + } + ht.CalibrationPosition = data[offset+2] & 0x3 + ht.CalibrationSequence = data[offset+2] >> 2 & 0x3 + ht.CSISteering = data[offset+2] >> 6 & 0x3 + ht.NDPAnnouncement = data[offset+3]&0x1 != 0 + if mainType != Dot11TypeMgmt { + ht.DEI = data[offset+3]&0x20 != 0 + } + } + + offset += 4 + } + + if len(data) < offset+4 { + df.SetTruncated() + return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+4) + } + + m.BaseLayer = BaseLayer{ + Contents: data[0:offset], + Payload: data[offset : len(data)-4], + } + + if mainType == Dot11TypeData { + l := dataDecodeMap[m.Type]() + err := l.DecodeFromBytes(m.BaseLayer.Payload, df) + if err != nil { + return err + } + m.DataLayer = l.(gopacket.Layer) + } + m.Checksum = binary.LittleEndian.Uint32(data[len(data)-4 : len(data)]) return nil } @@ -474,7 +1142,7 @@ type Dot11WEP struct { BaseLayer } -func (m *Dot11WEP) NextLayerType() gopacket.LayerType { return LayerTypeLLC } +func (m *Dot11WEP) NextLayerType() gopacket.LayerType { return gopacket.LayerTypePayload } func (m *Dot11WEP) LayerType() gopacket.LayerType { return LayerTypeDot11WEP } func (m *Dot11WEP) CanDecode() gopacket.LayerClass { return LayerTypeDot11WEP } @@ -493,7 +1161,9 @@ type Dot11Data struct { BaseLayer } -func (m *Dot11Data) NextLayerType() gopacket.LayerType { return LayerTypeLLC } +func (m *Dot11Data) NextLayerType() gopacket.LayerType { + return LayerTypeLLC +} func (m *Dot11Data) LayerType() gopacket.LayerType { return LayerTypeDot11Data } func (m *Dot11Data) CanDecode() gopacket.LayerClass { return LayerTypeDot11Data } @@ -618,23 +1288,10 @@ func (m *Dot11DataCFAckPollNoData) DecodeFromBytes(data []byte, df gopacket.Deco 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:]} + m.BaseLayer = BaseLayer{Payload: data} return nil } @@ -802,7 +1459,7 @@ func (m *Dot11InformationElement) DecodeFromBytes(data []byte, df gopacket.Decod func (d *Dot11InformationElement) String() string { if d.ID == 0 { - return fmt.Sprintf("802.11 Information Element (SSID: %v)", string(d.Info)) + return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, SSID: %v)", d.ID, d.Length, string(d.Info)) } else if d.ID == 1 { rates := "" for i := 0; i < len(d.Info); i++ { @@ -812,9 +1469,9 @@ func (d *Dot11InformationElement) String() string { rates += fmt.Sprintf("%.1f* ", float32(d.Info[i]&0x7F)*0.5) } } - return fmt.Sprintf("802.11 Information Element (Rates: %s Mbit)", rates) + return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, Rates: %s Mbit)", d.ID, d.Length, 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) + return fmt.Sprintf("802.11 Information Element (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) } diff --git a/vendor/github.com/google/gopacket/layers/eapol.go b/vendor/github.com/google/gopacket/layers/eapol.go index 041cd594..a2d47986 100644 --- a/vendor/github.com/google/gopacket/layers/eapol.go +++ b/vendor/github.com/google/gopacket/layers/eapol.go @@ -8,6 +8,7 @@ package layers import ( "encoding/binary" + "fmt" "github.com/google/gopacket" ) @@ -55,3 +56,238 @@ func decodeEAPOL(data []byte, p gopacket.PacketBuilder) error { e := &EAPOL{} return decodingLayerDecoder(e, data, p) } + +// EAPOLKeyDescriptorType is an enumeration of key descriptor types +// as specified by 802.1x in the EAPOL-Key frame +type EAPOLKeyDescriptorType uint8 + +// Enumeration of EAPOLKeyDescriptorType +const ( + EAPOLKeyDescriptorTypeRC4 EAPOLKeyDescriptorType = 1 + EAPOLKeyDescriptorTypeDot11 EAPOLKeyDescriptorType = 2 + EAPOLKeyDescriptorTypeWPA EAPOLKeyDescriptorType = 254 +) + +func (kdt EAPOLKeyDescriptorType) String() string { + switch kdt { + case EAPOLKeyDescriptorTypeRC4: + return "RC4" + case EAPOLKeyDescriptorTypeDot11: + return "802.11" + case EAPOLKeyDescriptorTypeWPA: + return "WPA" + default: + return fmt.Sprintf("unknown descriptor type %d", kdt) + } +} + +// EAPOLKeyDescriptorVersion is an enumeration of versions specifying the +// encryption algorithm for the key data and the authentication for the +// message integrity code (MIC) +type EAPOLKeyDescriptorVersion uint8 + +// Enumeration of EAPOLKeyDescriptorVersion +const ( + EAPOLKeyDescriptorVersionOther EAPOLKeyDescriptorVersion = 0 + EAPOLKeyDescriptorVersionRC4HMACMD5 EAPOLKeyDescriptorVersion = 1 + EAPOLKeyDescriptorVersionAESHMACSHA1 EAPOLKeyDescriptorVersion = 2 + EAPOLKeyDescriptorVersionAES128CMAC EAPOLKeyDescriptorVersion = 3 +) + +func (v EAPOLKeyDescriptorVersion) String() string { + switch v { + case EAPOLKeyDescriptorVersionOther: + return "Other" + case EAPOLKeyDescriptorVersionRC4HMACMD5: + return "RC4-HMAC-MD5" + case EAPOLKeyDescriptorVersionAESHMACSHA1: + return "AES-HMAC-SHA1-128" + case EAPOLKeyDescriptorVersionAES128CMAC: + return "AES-128-CMAC" + default: + return fmt.Sprintf("unknown version %d", v) + } +} + +// EAPOLKeyType is an enumeration of key derivation types describing +// the purpose of the keys being derived. +type EAPOLKeyType uint8 + +// Enumeration of EAPOLKeyType +const ( + EAPOLKeyTypeGroupSMK EAPOLKeyType = 0 + EAPOLKeyTypePairwise EAPOLKeyType = 1 +) + +func (kt EAPOLKeyType) String() string { + switch kt { + case EAPOLKeyTypeGroupSMK: + return "Group/SMK" + case EAPOLKeyTypePairwise: + return "Pairwise" + default: + return fmt.Sprintf("unknown key type %d", kt) + } +} + +// EAPOLKey defines an EAPOL-Key frame for 802.1x authentication +type EAPOLKey struct { + BaseLayer + KeyDescriptorType EAPOLKeyDescriptorType + KeyDescriptorVersion EAPOLKeyDescriptorVersion + KeyType EAPOLKeyType + KeyIndex uint8 + Install bool + KeyACK bool + KeyMIC bool + Secure bool + MICError bool + Request bool + HasEncryptedKeyData bool + SMKMessage bool + KeyLength uint16 + ReplayCounter uint64 + Nonce []byte + IV []byte + RSC uint64 + ID uint64 + MIC []byte + KeyDataLength uint16 + EncryptedKeyData []byte +} + +// LayerType returns LayerTypeEAPOLKey. +func (ek *EAPOLKey) LayerType() gopacket.LayerType { + return LayerTypeEAPOLKey +} + +// NextLayerType returns layers.LayerTypeDot11InformationElement if the key +// data exists and is unencrypted, otherwise it does not expect a next layer. +func (ek *EAPOLKey) NextLayerType() gopacket.LayerType { + if !ek.HasEncryptedKeyData && ek.KeyDataLength > 0 { + return LayerTypeDot11InformationElement + } + return gopacket.LayerTypePayload +} + +const eapolKeyFrameLen = 95 + +// DecodeFromBytes decodes the given bytes into this layer. +func (ek *EAPOLKey) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < eapolKeyFrameLen { + df.SetTruncated() + return fmt.Errorf("EAPOLKey length %v too short, %v required", + len(data), eapolKeyFrameLen) + } + + ek.KeyDescriptorType = EAPOLKeyDescriptorType(data[0]) + + info := binary.BigEndian.Uint16(data[1:3]) + ek.KeyDescriptorVersion = EAPOLKeyDescriptorVersion(info & 0x0007) + ek.KeyType = EAPOLKeyType((info & 0x0008) >> 3) + ek.KeyIndex = uint8((info & 0x0030) >> 4) + ek.Install = (info & 0x0040) != 0 + ek.KeyACK = (info & 0x0080) != 0 + ek.KeyMIC = (info & 0x0100) != 0 + ek.Secure = (info & 0x0200) != 0 + ek.MICError = (info & 0x0400) != 0 + ek.Request = (info & 0x0800) != 0 + ek.HasEncryptedKeyData = (info & 0x1000) != 0 + ek.SMKMessage = (info & 0x2000) != 0 + + ek.KeyLength = binary.BigEndian.Uint16(data[3:5]) + ek.ReplayCounter = binary.BigEndian.Uint64(data[5:13]) + + ek.Nonce = data[13:45] + ek.IV = data[45:61] + ek.RSC = binary.BigEndian.Uint64(data[61:69]) + ek.ID = binary.BigEndian.Uint64(data[69:77]) + ek.MIC = data[77:93] + + ek.KeyDataLength = binary.BigEndian.Uint16(data[93:95]) + + totalLength := eapolKeyFrameLen + int(ek.KeyDataLength) + if len(data) < totalLength { + df.SetTruncated() + return fmt.Errorf("EAPOLKey data length %d too short, %d required", + len(data)-eapolKeyFrameLen, ek.KeyDataLength) + } + + if ek.HasEncryptedKeyData { + ek.EncryptedKeyData = data[eapolKeyFrameLen:totalLength] + ek.BaseLayer = BaseLayer{ + Contents: data[:totalLength], + Payload: data[totalLength:], + } + } else { + ek.BaseLayer = BaseLayer{ + Contents: data[:eapolKeyFrameLen], + Payload: data[eapolKeyFrameLen:], + } + } + + 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 (ek *EAPOLKey) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + buf, err := b.PrependBytes(eapolKeyFrameLen + len(ek.EncryptedKeyData)) + if err != nil { + return err + } + + buf[0] = byte(ek.KeyDescriptorType) + + var info uint16 + info |= uint16(ek.KeyDescriptorVersion) + info |= uint16(ek.KeyType) << 3 + info |= uint16(ek.KeyIndex) << 4 + if ek.Install { + info |= 0x0040 + } + if ek.KeyACK { + info |= 0x0080 + } + if ek.KeyMIC { + info |= 0x0100 + } + if ek.Secure { + info |= 0x0200 + } + if ek.MICError { + info |= 0x0400 + } + if ek.Request { + info |= 0x0800 + } + if ek.HasEncryptedKeyData { + info |= 0x1000 + } + if ek.SMKMessage { + info |= 0x2000 + } + binary.BigEndian.PutUint16(buf[1:3], info) + + binary.BigEndian.PutUint16(buf[3:5], ek.KeyLength) + binary.BigEndian.PutUint64(buf[5:13], ek.ReplayCounter) + + copy(buf[13:45], ek.Nonce) + copy(buf[45:61], ek.IV) + binary.BigEndian.PutUint64(buf[61:69], ek.RSC) + binary.BigEndian.PutUint64(buf[69:77], ek.ID) + copy(buf[77:93], ek.MIC) + + binary.BigEndian.PutUint16(buf[93:95], ek.KeyDataLength) + if len(ek.EncryptedKeyData) > 0 { + copy(buf[95:95+len(ek.EncryptedKeyData)], ek.EncryptedKeyData) + } + + return nil +} + +func decodeEAPOLKey(data []byte, p gopacket.PacketBuilder) error { + ek := &EAPOLKey{} + return decodingLayerDecoder(ek, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/enums.go b/vendor/github.com/google/gopacket/layers/enums.go index f28bcbd6..2ac1598c 100644 --- a/vendor/github.com/google/gopacket/layers/enums.go +++ b/vendor/github.com/google/gopacket/layers/enums.go @@ -80,6 +80,7 @@ const ( IPProtocolICMPv6 IPProtocol = 58 IPProtocolNoNextHeader IPProtocol = 59 IPProtocolIPv6Destination IPProtocol = 60 + IPProtocolOSPF IPProtocol = 89 IPProtocolIPIP IPProtocol = 94 IPProtocolEtherIP IPProtocol = 97 IPProtocolVRRP IPProtocol = 112 @@ -218,12 +219,17 @@ func (d Dot11Type) MainType() Dot11Type { return d & dot11TypeMask } +func (d Dot11Type) QOS() bool { + return d&dot11QOSMask == Dot11TypeDataQOSData +} + const ( Dot11TypeMgmt Dot11Type = 0x00 Dot11TypeCtrl Dot11Type = 0x01 Dot11TypeData Dot11Type = 0x02 Dot11TypeReserved Dot11Type = 0x03 dot11TypeMask = 0x03 + dot11QOSMask = 0x23 // The following are type/subtype conglomerations. @@ -271,107 +277,6 @@ const ( 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 @@ -384,53 +289,22 @@ func decodeIPv4or6(data []byte, p gopacket.PacketBuilder) error { 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), - } - } +func initActualTypeData() { + // Each of the XXXTypeMetadata arrays contains mappings of how to handle enum + // values for various enum types in gopacket/layers. + // These arrays are actually created by gen2.go and stored in + // enums_generated.go. + // + // 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. + // Here we link up all enumerations with their respective names and decoders. 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} @@ -463,6 +337,7 @@ func init() { 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[IPProtocolOSPF] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeOSPF), Name: "OSPF", LayerType: LayerTypeOSPF} 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} @@ -509,6 +384,7 @@ func init() { FDDIFrameControlMetadata[FDDIFrameControlLLC] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLLC), Name: "LLC"} EAPOLTypeMetadata[EAPOLTypeEAP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEAP), Name: "EAP", LayerType: LayerTypeEAP} + EAPOLTypeMetadata[EAPOLTypeKey] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEAPOLKey), Name: "EAPOLKey", LayerType: LayerTypeEAPOLKey} ProtocolFamilyMetadata[ProtocolFamilyIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4} ProtocolFamilyMetadata[ProtocolFamilyIPv6BSD] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} @@ -556,7 +432,7 @@ func init() { 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} + USBTransportTypeMetadata[USBTransportTypeInterrupt] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBInterrupt), Name: "Interrupt", LayerType: LayerTypeUSBInterrupt} + USBTransportTypeMetadata[USBTransportTypeControl] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBControl), Name: "Control", LayerType: LayerTypeUSBControl} + USBTransportTypeMetadata[USBTransportTypeBulk] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBBulk), Name: "Bulk", LayerType: LayerTypeUSBBulk} } diff --git a/vendor/github.com/google/gopacket/layers/enums_generated.go b/vendor/github.com/google/gopacket/layers/enums_generated.go new file mode 100644 index 00000000..bf77aac5 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/enums_generated.go @@ -0,0 +1,434 @@ +// Copyright 2012 Google, Inc. All rights reserved. + +package layers + +// Created by gen2.go, don't edit manually +// Generated at 2017-10-23 10:20:24.458771856 -0600 MDT m=+0.001159033 + +import ( + "fmt" + + "github.com/google/gopacket" +) + +func init() { + initUnknownTypesForLinkType() + initUnknownTypesForEthernetType() + initUnknownTypesForPPPType() + initUnknownTypesForIPProtocol() + initUnknownTypesForSCTPChunkType() + initUnknownTypesForPPPoECode() + initUnknownTypesForFDDIFrameControl() + initUnknownTypesForEAPOLType() + initUnknownTypesForProtocolFamily() + initUnknownTypesForDot11Type() + initUnknownTypesForUSBTransportType() + initActualTypeData() +} + +// Decoder calls LinkTypeMetadata.DecodeWith's decoder. +func (a LinkType) Decode(data []byte, p gopacket.PacketBuilder) error { + return LinkTypeMetadata[a].DecodeWith.Decode(data, p) +} + +// String returns LinkTypeMetadata.Name. +func (a LinkType) String() string { + return LinkTypeMetadata[a].Name +} + +// LayerType returns LinkTypeMetadata.LayerType. +func (a LinkType) LayerType() gopacket.LayerType { + return LinkTypeMetadata[a].LayerType +} + +type errorDecoderForLinkType int + +func (a *errorDecoderForLinkType) Decode(data []byte, p gopacket.PacketBuilder) error { + return a +} +func (a *errorDecoderForLinkType) Error() string { + return fmt.Sprintf("Unable to decode LinkType %d", int(*a)) +} + +var errorDecodersForLinkType [256]errorDecoderForLinkType +var LinkTypeMetadata [256]EnumMetadata + +func initUnknownTypesForLinkType() { + for i := 0; i < 256; i++ { + errorDecodersForLinkType[i] = errorDecoderForLinkType(i) + LinkTypeMetadata[i] = EnumMetadata{ + DecodeWith: &errorDecodersForLinkType[i], + Name: "UnknownLinkType", + } + } +} + +// Decoder calls EthernetTypeMetadata.DecodeWith's decoder. +func (a EthernetType) Decode(data []byte, p gopacket.PacketBuilder) error { + return EthernetTypeMetadata[a].DecodeWith.Decode(data, p) +} + +// String returns EthernetTypeMetadata.Name. +func (a EthernetType) String() string { + return EthernetTypeMetadata[a].Name +} + +// LayerType returns EthernetTypeMetadata.LayerType. +func (a EthernetType) LayerType() gopacket.LayerType { + return EthernetTypeMetadata[a].LayerType +} + +type errorDecoderForEthernetType int + +func (a *errorDecoderForEthernetType) Decode(data []byte, p gopacket.PacketBuilder) error { + return a +} +func (a *errorDecoderForEthernetType) Error() string { + return fmt.Sprintf("Unable to decode EthernetType %d", int(*a)) +} + +var errorDecodersForEthernetType [65536]errorDecoderForEthernetType +var EthernetTypeMetadata [65536]EnumMetadata + +func initUnknownTypesForEthernetType() { + for i := 0; i < 65536; i++ { + errorDecodersForEthernetType[i] = errorDecoderForEthernetType(i) + EthernetTypeMetadata[i] = EnumMetadata{ + DecodeWith: &errorDecodersForEthernetType[i], + Name: "UnknownEthernetType", + } + } +} + +// Decoder calls PPPTypeMetadata.DecodeWith's decoder. +func (a PPPType) Decode(data []byte, p gopacket.PacketBuilder) error { + return PPPTypeMetadata[a].DecodeWith.Decode(data, p) +} + +// String returns PPPTypeMetadata.Name. +func (a PPPType) String() string { + return PPPTypeMetadata[a].Name +} + +// LayerType returns PPPTypeMetadata.LayerType. +func (a PPPType) LayerType() gopacket.LayerType { + return PPPTypeMetadata[a].LayerType +} + +type errorDecoderForPPPType int + +func (a *errorDecoderForPPPType) Decode(data []byte, p gopacket.PacketBuilder) error { + return a +} +func (a *errorDecoderForPPPType) Error() string { + return fmt.Sprintf("Unable to decode PPPType %d", int(*a)) +} + +var errorDecodersForPPPType [65536]errorDecoderForPPPType +var PPPTypeMetadata [65536]EnumMetadata + +func initUnknownTypesForPPPType() { + for i := 0; i < 65536; i++ { + errorDecodersForPPPType[i] = errorDecoderForPPPType(i) + PPPTypeMetadata[i] = EnumMetadata{ + DecodeWith: &errorDecodersForPPPType[i], + Name: "UnknownPPPType", + } + } +} + +// Decoder calls IPProtocolMetadata.DecodeWith's decoder. +func (a IPProtocol) Decode(data []byte, p gopacket.PacketBuilder) error { + return IPProtocolMetadata[a].DecodeWith.Decode(data, p) +} + +// String returns IPProtocolMetadata.Name. +func (a IPProtocol) String() string { + return IPProtocolMetadata[a].Name +} + +// LayerType returns IPProtocolMetadata.LayerType. +func (a IPProtocol) LayerType() gopacket.LayerType { + return IPProtocolMetadata[a].LayerType +} + +type errorDecoderForIPProtocol int + +func (a *errorDecoderForIPProtocol) Decode(data []byte, p gopacket.PacketBuilder) error { + return a +} +func (a *errorDecoderForIPProtocol) Error() string { + return fmt.Sprintf("Unable to decode IPProtocol %d", int(*a)) +} + +var errorDecodersForIPProtocol [256]errorDecoderForIPProtocol +var IPProtocolMetadata [256]EnumMetadata + +func initUnknownTypesForIPProtocol() { + for i := 0; i < 256; i++ { + errorDecodersForIPProtocol[i] = errorDecoderForIPProtocol(i) + IPProtocolMetadata[i] = EnumMetadata{ + DecodeWith: &errorDecodersForIPProtocol[i], + Name: "UnknownIPProtocol", + } + } +} + +// Decoder calls SCTPChunkTypeMetadata.DecodeWith's decoder. +func (a SCTPChunkType) Decode(data []byte, p gopacket.PacketBuilder) error { + return SCTPChunkTypeMetadata[a].DecodeWith.Decode(data, p) +} + +// String returns SCTPChunkTypeMetadata.Name. +func (a SCTPChunkType) String() string { + return SCTPChunkTypeMetadata[a].Name +} + +// LayerType returns SCTPChunkTypeMetadata.LayerType. +func (a SCTPChunkType) LayerType() gopacket.LayerType { + return SCTPChunkTypeMetadata[a].LayerType +} + +type errorDecoderForSCTPChunkType int + +func (a *errorDecoderForSCTPChunkType) Decode(data []byte, p gopacket.PacketBuilder) error { + return a +} +func (a *errorDecoderForSCTPChunkType) Error() string { + return fmt.Sprintf("Unable to decode SCTPChunkType %d", int(*a)) +} + +var errorDecodersForSCTPChunkType [256]errorDecoderForSCTPChunkType +var SCTPChunkTypeMetadata [256]EnumMetadata + +func initUnknownTypesForSCTPChunkType() { + for i := 0; i < 256; i++ { + errorDecodersForSCTPChunkType[i] = errorDecoderForSCTPChunkType(i) + SCTPChunkTypeMetadata[i] = EnumMetadata{ + DecodeWith: &errorDecodersForSCTPChunkType[i], + Name: "UnknownSCTPChunkType", + } + } +} + +// Decoder calls PPPoECodeMetadata.DecodeWith's decoder. +func (a PPPoECode) Decode(data []byte, p gopacket.PacketBuilder) error { + return PPPoECodeMetadata[a].DecodeWith.Decode(data, p) +} + +// String returns PPPoECodeMetadata.Name. +func (a PPPoECode) String() string { + return PPPoECodeMetadata[a].Name +} + +// LayerType returns PPPoECodeMetadata.LayerType. +func (a PPPoECode) LayerType() gopacket.LayerType { + return PPPoECodeMetadata[a].LayerType +} + +type errorDecoderForPPPoECode int + +func (a *errorDecoderForPPPoECode) Decode(data []byte, p gopacket.PacketBuilder) error { + return a +} +func (a *errorDecoderForPPPoECode) Error() string { + return fmt.Sprintf("Unable to decode PPPoECode %d", int(*a)) +} + +var errorDecodersForPPPoECode [256]errorDecoderForPPPoECode +var PPPoECodeMetadata [256]EnumMetadata + +func initUnknownTypesForPPPoECode() { + for i := 0; i < 256; i++ { + errorDecodersForPPPoECode[i] = errorDecoderForPPPoECode(i) + PPPoECodeMetadata[i] = EnumMetadata{ + DecodeWith: &errorDecodersForPPPoECode[i], + Name: "UnknownPPPoECode", + } + } +} + +// Decoder calls FDDIFrameControlMetadata.DecodeWith's decoder. +func (a FDDIFrameControl) Decode(data []byte, p gopacket.PacketBuilder) error { + return FDDIFrameControlMetadata[a].DecodeWith.Decode(data, p) +} + +// String returns FDDIFrameControlMetadata.Name. +func (a FDDIFrameControl) String() string { + return FDDIFrameControlMetadata[a].Name +} + +// LayerType returns FDDIFrameControlMetadata.LayerType. +func (a FDDIFrameControl) LayerType() gopacket.LayerType { + return FDDIFrameControlMetadata[a].LayerType +} + +type errorDecoderForFDDIFrameControl int + +func (a *errorDecoderForFDDIFrameControl) Decode(data []byte, p gopacket.PacketBuilder) error { + return a +} +func (a *errorDecoderForFDDIFrameControl) Error() string { + return fmt.Sprintf("Unable to decode FDDIFrameControl %d", int(*a)) +} + +var errorDecodersForFDDIFrameControl [256]errorDecoderForFDDIFrameControl +var FDDIFrameControlMetadata [256]EnumMetadata + +func initUnknownTypesForFDDIFrameControl() { + for i := 0; i < 256; i++ { + errorDecodersForFDDIFrameControl[i] = errorDecoderForFDDIFrameControl(i) + FDDIFrameControlMetadata[i] = EnumMetadata{ + DecodeWith: &errorDecodersForFDDIFrameControl[i], + Name: "UnknownFDDIFrameControl", + } + } +} + +// Decoder calls EAPOLTypeMetadata.DecodeWith's decoder. +func (a EAPOLType) Decode(data []byte, p gopacket.PacketBuilder) error { + return EAPOLTypeMetadata[a].DecodeWith.Decode(data, p) +} + +// String returns EAPOLTypeMetadata.Name. +func (a EAPOLType) String() string { + return EAPOLTypeMetadata[a].Name +} + +// LayerType returns EAPOLTypeMetadata.LayerType. +func (a EAPOLType) LayerType() gopacket.LayerType { + return EAPOLTypeMetadata[a].LayerType +} + +type errorDecoderForEAPOLType int + +func (a *errorDecoderForEAPOLType) Decode(data []byte, p gopacket.PacketBuilder) error { + return a +} +func (a *errorDecoderForEAPOLType) Error() string { + return fmt.Sprintf("Unable to decode EAPOLType %d", int(*a)) +} + +var errorDecodersForEAPOLType [256]errorDecoderForEAPOLType +var EAPOLTypeMetadata [256]EnumMetadata + +func initUnknownTypesForEAPOLType() { + for i := 0; i < 256; i++ { + errorDecodersForEAPOLType[i] = errorDecoderForEAPOLType(i) + EAPOLTypeMetadata[i] = EnumMetadata{ + DecodeWith: &errorDecodersForEAPOLType[i], + Name: "UnknownEAPOLType", + } + } +} + +// Decoder calls ProtocolFamilyMetadata.DecodeWith's decoder. +func (a ProtocolFamily) Decode(data []byte, p gopacket.PacketBuilder) error { + return ProtocolFamilyMetadata[a].DecodeWith.Decode(data, p) +} + +// String returns ProtocolFamilyMetadata.Name. +func (a ProtocolFamily) String() string { + return ProtocolFamilyMetadata[a].Name +} + +// LayerType returns ProtocolFamilyMetadata.LayerType. +func (a ProtocolFamily) LayerType() gopacket.LayerType { + return ProtocolFamilyMetadata[a].LayerType +} + +type errorDecoderForProtocolFamily int + +func (a *errorDecoderForProtocolFamily) Decode(data []byte, p gopacket.PacketBuilder) error { + return a +} +func (a *errorDecoderForProtocolFamily) Error() string { + return fmt.Sprintf("Unable to decode ProtocolFamily %d", int(*a)) +} + +var errorDecodersForProtocolFamily [256]errorDecoderForProtocolFamily +var ProtocolFamilyMetadata [256]EnumMetadata + +func initUnknownTypesForProtocolFamily() { + for i := 0; i < 256; i++ { + errorDecodersForProtocolFamily[i] = errorDecoderForProtocolFamily(i) + ProtocolFamilyMetadata[i] = EnumMetadata{ + DecodeWith: &errorDecodersForProtocolFamily[i], + Name: "UnknownProtocolFamily", + } + } +} + +// Decoder calls Dot11TypeMetadata.DecodeWith's decoder. +func (a Dot11Type) Decode(data []byte, p gopacket.PacketBuilder) error { + return Dot11TypeMetadata[a].DecodeWith.Decode(data, p) +} + +// String returns Dot11TypeMetadata.Name. +func (a Dot11Type) String() string { + return Dot11TypeMetadata[a].Name +} + +// LayerType returns Dot11TypeMetadata.LayerType. +func (a Dot11Type) LayerType() gopacket.LayerType { + return Dot11TypeMetadata[a].LayerType +} + +type errorDecoderForDot11Type int + +func (a *errorDecoderForDot11Type) Decode(data []byte, p gopacket.PacketBuilder) error { + return a +} +func (a *errorDecoderForDot11Type) Error() string { + return fmt.Sprintf("Unable to decode Dot11Type %d", int(*a)) +} + +var errorDecodersForDot11Type [256]errorDecoderForDot11Type +var Dot11TypeMetadata [256]EnumMetadata + +func initUnknownTypesForDot11Type() { + for i := 0; i < 256; i++ { + errorDecodersForDot11Type[i] = errorDecoderForDot11Type(i) + Dot11TypeMetadata[i] = EnumMetadata{ + DecodeWith: &errorDecodersForDot11Type[i], + Name: "UnknownDot11Type", + } + } +} + +// Decoder calls USBTransportTypeMetadata.DecodeWith's decoder. +func (a USBTransportType) Decode(data []byte, p gopacket.PacketBuilder) error { + return USBTransportTypeMetadata[a].DecodeWith.Decode(data, p) +} + +// String returns USBTransportTypeMetadata.Name. +func (a USBTransportType) String() string { + return USBTransportTypeMetadata[a].Name +} + +// LayerType returns USBTransportTypeMetadata.LayerType. +func (a USBTransportType) LayerType() gopacket.LayerType { + return USBTransportTypeMetadata[a].LayerType +} + +type errorDecoderForUSBTransportType int + +func (a *errorDecoderForUSBTransportType) Decode(data []byte, p gopacket.PacketBuilder) error { + return a +} +func (a *errorDecoderForUSBTransportType) Error() string { + return fmt.Sprintf("Unable to decode USBTransportType %d", int(*a)) +} + +var errorDecodersForUSBTransportType [256]errorDecoderForUSBTransportType +var USBTransportTypeMetadata [256]EnumMetadata + +func initUnknownTypesForUSBTransportType() { + for i := 0; i < 256; i++ { + errorDecodersForUSBTransportType[i] = errorDecoderForUSBTransportType(i) + USBTransportTypeMetadata[i] = EnumMetadata{ + DecodeWith: &errorDecodersForUSBTransportType[i], + Name: "UnknownUSBTransportType", + } + } +} diff --git a/vendor/github.com/google/gopacket/layers/ethernet.go b/vendor/github.com/google/gopacket/layers/ethernet.go index 4eebf8c6..b73748f2 100644 --- a/vendor/github.com/google/gopacket/layers/ethernet.go +++ b/vendor/github.com/google/gopacket/layers/ethernet.go @@ -46,6 +46,7 @@ func (eth *Ethernet) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) er eth.SrcMAC = net.HardwareAddr(data[6:12]) eth.EthernetType = EthernetType(binary.BigEndian.Uint16(data[12:14])) eth.BaseLayer = BaseLayer{data[:14], data[14:]} + eth.Length = 0 if eth.EthernetType < 0x0600 { eth.Length = uint16(eth.EthernetType) eth.EthernetType = EthernetTypeLLC diff --git a/vendor/github.com/google/gopacket/layers/gen2.go b/vendor/github.com/google/gopacket/layers/gen2.go new file mode 100644 index 00000000..150cad77 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/gen2.go @@ -0,0 +1,104 @@ +// 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 handles creating string constants and function templates for enums. +// +// go run gen.go | gofmt > enums_generated.go +package main + +import ( + "fmt" + "log" + "os" + "text/template" + "time" +) + +const fmtString = `// Copyright 2012 Google, Inc. All rights reserved. + +package layers + +// Created by gen2.go, don't edit manually +// Generated at %s + +import ( + "fmt" + + "github.com/google/gopacket" +) + +` + +var funcsTmpl = template.Must(template.New("foo").Parse(` +// Decoder calls {{.Name}}Metadata.DecodeWith's decoder. +func (a {{.Name}}) Decode(data []byte, p gopacket.PacketBuilder) error { + return {{.Name}}Metadata[a].DecodeWith.Decode(data, p) +} +// String returns {{.Name}}Metadata.Name. +func (a {{.Name}}) String() string { + return {{.Name}}Metadata[a].Name +} +// LayerType returns {{.Name}}Metadata.LayerType. +func (a {{.Name}}) LayerType() gopacket.LayerType { + return {{.Name}}Metadata[a].LayerType +} + +type errorDecoderFor{{.Name}} int +func (a *errorDecoderFor{{.Name}}) Decode(data []byte, p gopacket.PacketBuilder) error { + return a +} +func (a *errorDecoderFor{{.Name}}) Error() string { + return fmt.Sprintf("Unable to decode {{.Name}} %d", int(*a)) +} + +var errorDecodersFor{{.Name}} [{{.Num}}]errorDecoderFor{{.Name}} +var {{.Name}}Metadata [{{.Num}}]EnumMetadata + +func initUnknownTypesFor{{.Name}}() { + for i := 0; i < {{.Num}}; i++ { + errorDecodersFor{{.Name}}[i] = errorDecoderFor{{.Name}}(i) + {{.Name}}Metadata[i] = EnumMetadata{ + DecodeWith: &errorDecodersFor{{.Name}}[i], + Name: "Unknown{{.Name}}", + } + } +} +`)) + +func main() { + fmt.Fprintf(os.Stderr, "Writing results to stdout\n") + fmt.Printf(fmtString, time.Now()) + types := []struct { + Name string + Num int + }{ + {"LinkType", 256}, + {"EthernetType", 65536}, + {"PPPType", 65536}, + {"IPProtocol", 256}, + {"SCTPChunkType", 256}, + {"PPPoECode", 256}, + {"FDDIFrameControl", 256}, + {"EAPOLType", 256}, + {"ProtocolFamily", 256}, + {"Dot11Type", 256}, + {"USBTransportType", 256}, + } + + fmt.Println("func init() {") + for _, t := range types { + fmt.Printf("initUnknownTypesFor%s()\n", t.Name) + } + fmt.Println("initActualTypeData()") + fmt.Println("}") + for _, t := range types { + if err := funcsTmpl.Execute(os.Stdout, t); err != nil { + log.Fatalf("Failed to execute template %s: %v", t.Name, err) + } + } +} diff --git a/vendor/github.com/google/gopacket/layers/gtp.go b/vendor/github.com/google/gopacket/layers/gtp.go new file mode 100644 index 00000000..0ec8a6a0 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/gtp.go @@ -0,0 +1,181 @@ +// Copyright 2017 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" +) + +const gtpMinimumSizeInBytes int = 8 + +// GTPExtensionHeader is used to carry extra data and enable future extensions of the GTP without the need to use another version number. +type GTPExtensionHeader struct { + Type uint8 + Content []byte +} + +// GTPv1U protocol is used to exchange user data over GTP tunnels across the Sx interfaces. +// Defined in https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1595 +type GTPv1U struct { + BaseLayer + Version uint8 + ProtocolType uint8 + Reserved uint8 + ExtensionHeaderFlag bool + SequenceNumberFlag bool + NPDUFlag bool + MessageType uint8 + MessageLength uint16 + TEID uint32 + SequenceNumber uint16 + NPDU uint8 + GTPExtensionHeaders []GTPExtensionHeader +} + +// LayerType returns LayerTypeGTPV1U +func (g *GTPv1U) LayerType() gopacket.LayerType { return LayerTypeGTPv1U } + +// DecodeFromBytes analyses a byte slice and attempts to decode it as a GTPv1U packet +func (g *GTPv1U) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + hLen := gtpMinimumSizeInBytes + dLen := len(data) + if dLen < hLen { + return fmt.Errorf("GTP packet too small: %d bytes", dLen) + } + g.Version = (data[0] >> 5) & 0x07 + g.ProtocolType = (data[0] >> 4) & 0x01 + g.Reserved = (data[0] >> 3) & 0x01 + g.SequenceNumberFlag = ((data[0] >> 1) & 0x01) == 1 + g.NPDUFlag = (data[0] & 0x01) == 1 + g.ExtensionHeaderFlag = ((data[0] >> 2) & 0x01) == 1 + g.MessageType = data[1] + g.MessageLength = binary.BigEndian.Uint16(data[2:4]) + pLen := 8 + g.MessageLength + if uint16(dLen) < pLen { + return fmt.Errorf("GTP packet too small: %d bytes", dLen) + } + // Field used to multiplex different connections in the same GTP tunnel. + g.TEID = binary.BigEndian.Uint32(data[4:8]) + cIndex := uint16(hLen) + if g.SequenceNumberFlag || g.NPDUFlag || g.ExtensionHeaderFlag { + hLen += 4 + cIndex += 4 + if dLen < hLen { + return fmt.Errorf("GTP packet too small: %d bytes", dLen) + } + if g.SequenceNumberFlag { + g.SequenceNumber = binary.BigEndian.Uint16(data[8:10]) + } + if g.NPDUFlag { + g.NPDU = data[10] + } + if g.ExtensionHeaderFlag { + extensionFlag := true + for extensionFlag { + extensionType := uint8(data[cIndex-1]) + extensionLength := uint(data[cIndex]) + if extensionLength == 0 { + return fmt.Errorf("GTP packet with invalid extension header") + } + // extensionLength is in 4-octet units + lIndex := cIndex + (uint16(extensionLength) * 4) + if uint16(dLen) < lIndex { + fmt.Println(dLen, lIndex) + return fmt.Errorf("GTP packet with small extension header: %d bytes", dLen) + } + content := data[cIndex+1 : lIndex-1] + eh := GTPExtensionHeader{Type: extensionType, Content: content} + g.GTPExtensionHeaders = append(g.GTPExtensionHeaders, eh) + cIndex = lIndex + // Check if coming bytes are from an extension header + extensionFlag = data[cIndex-1] != 0 + + } + } + } + g.BaseLayer = BaseLayer{Contents: data[:cIndex], Payload: data[cIndex:]} + 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 *GTPv1U) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + data, err := b.PrependBytes(gtpMinimumSizeInBytes) + if err != nil { + return err + } + data[0] |= (g.Version << 5) + data[0] |= (1 << 4) + if len(g.GTPExtensionHeaders) > 0 { + data[0] |= 0x04 + g.ExtensionHeaderFlag = true + } + if g.SequenceNumberFlag { + data[0] |= 0x02 + } + if g.NPDUFlag { + data[0] |= 0x01 + } + data[1] = g.MessageType + binary.BigEndian.PutUint16(data[2:4], g.MessageLength) + binary.BigEndian.PutUint32(data[4:8], g.TEID) + if g.ExtensionHeaderFlag || g.SequenceNumberFlag || g.NPDUFlag { + data, err := b.AppendBytes(4) + if err != nil { + return err + } + binary.BigEndian.PutUint16(data[:2], g.SequenceNumber) + data[2] = g.NPDU + for _, eh := range g.GTPExtensionHeaders { + data[len(data)-1] = eh.Type + lContent := len(eh.Content) + // extensionLength is in 4-octet units + extensionLength := (lContent + 2) / 4 + // Get two extra byte for the next extension header type and length + data, err = b.AppendBytes(lContent + 2) + if err != nil { + return err + } + data[0] = byte(extensionLength) + copy(data[1:lContent+1], eh.Content) + } + } + return nil + +} + +// CanDecode returns a set of layers that GTP objects can decode. +func (g *GTPv1U) CanDecode() gopacket.LayerClass { + return LayerTypeGTPv1U +} + +// NextLayerType specifies the next layer that GoPacket should attempt to +func (g *GTPv1U) NextLayerType() gopacket.LayerType { + version := uint8(g.LayerPayload()[0]) >> 4 + if version == 4 { + return LayerTypeIPv4 + } else if version == 6 { + return LayerTypeIPv6 + } else { + return LayerTypePPP + } +} + +func decodeGTPv1u(data []byte, p gopacket.PacketBuilder) error { + gtp := >Pv1U{} + err := gtp.DecodeFromBytes(data, p) + if err != nil { + return err + } + p.AddLayer(gtp) + return p.NextDecoder(gtp.NextLayerType()) +} diff --git a/vendor/github.com/google/gopacket/layers/iana_ports.go b/vendor/github.com/google/gopacket/layers/iana_ports.go index 54406359..ddcf3ecd 100644 --- a/vendor/github.com/google/gopacket/layers/iana_ports.go +++ b/vendor/github.com/google/gopacket/layers/iana_ports.go @@ -3,7 +3,7 @@ package layers // Created by gen.go, don't edit manually -// Generated at 2017-01-04 15:05:26.649794815 -0700 MST +// Generated at 2017-10-23 09:57:28.214859163 -0600 MDT m=+1.011679290 // 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. @@ -45,7 +45,6 @@ var tcpPortNames = map[TCPPort]string{ 44: "mpm-flags", 45: "mpm", 46: "mpm-snd", - 47: "ni-ftp", 48: "auditd", 49: "tacacs", 50: "re-mail-ck", @@ -55,7 +54,6 @@ var tcpPortNames = map[TCPPort]string{ 55: "isi-gl", 56: "xns-auth", 58: "xns-mail", - 61: "ni-mail", 62: "acas", 63: "whoispp", 64: "covia", @@ -673,6 +671,7 @@ var tcpPortNames = map[TCPPort]string{ 847: "dhcp-failover2", 848: "gdoi", 853: "domain-s", + 854: "dlep", 860: "iscsi", 861: "owamp-control", 862: "twamp-control", @@ -688,6 +687,7 @@ var tcpPortNames = map[TCPPort]string{ 911: "xact-backup", 912: "apex-mesh", 913: "apex-edge", + 953: "rndc", 989: "ftps-data", 990: "ftps", 991: "nas", @@ -2726,7 +2726,7 @@ var tcpPortNames = map[TCPPort]string{ 3068: "ls3bcast", 3069: "ls3", 3070: "mgxswitch", - 3071: "csd-mgmt-port", + 3071: "xplat-replicate", 3072: "csd-monitor", 3073: "vcrp", 3074: "xbox", @@ -3753,6 +3753,7 @@ var tcpPortNames = map[TCPPort]string{ 4117: "hillrserv", 4118: "netscript", 4119: "assuria-slm", + 4120: "minirem", 4121: "e-builder", 4122: "fprams", 4123: "z-wave", @@ -3823,6 +3824,7 @@ var tcpPortNames = map[TCPPort]string{ 4190: "sieve", 4192: "azeti", 4193: "pvxplusio", + 4197: "hctl", 4199: "eims-admin", 4300: "corelccam", 4301: "d-data", @@ -3831,7 +3833,7 @@ var tcpPortNames = map[TCPPort]string{ 4304: "owserver", 4305: "batman", 4306: "pinghgl", - 4307: "visicron-vs", + 4307: "trueconf", 4308: "compx-lockview", 4309: "dserver", 4310: "mirrtex", @@ -4028,6 +4030,7 @@ var tcpPortNames = map[TCPPort]string{ 4702: "netxms-sync", 4703: "npqes-test", 4704: "assuria-ins", + 4711: "trinity-dist", 4725: "truckstar", 4727: "fcis", 4728: "capmux", @@ -4105,6 +4108,7 @@ var tcpPortNames = map[TCPPort]string{ 4953: "dbsyncarbiter", 4969: "ccss-qmm", 4970: "ccss-qsm", + 4971: "burp", 4984: "webyast", 4985: "gerhcs", 4986: "mrip", @@ -4415,6 +4419,7 @@ var tcpPortNames = map[TCPPort]string{ 5638: "flcrs", 5639: "ics", 5646: "vfmobile", + 5666: "nrpe", 5670: "filemq", 5671: "amqps", 5672: "amqp", @@ -4432,6 +4437,7 @@ var tcpPortNames = map[TCPPort]string{ 5693: "rbsystem", 5696: "kmip", 5700: "supportassist", + 5705: "storageos", 5713: "proshareaudio", 5714: "prosharevideo", 5715: "prosharedata", @@ -4609,6 +4615,7 @@ var tcpPortNames = map[TCPPort]string{ 6446: "mysql-proxy", 6455: "skip-cert-recv", 6456: "skip-cert-send", + 6464: "ieee11073-20701", 6471: "lvision-lm", 6480: "sun-sr-http", 6481: "servicetags", @@ -4739,6 +4746,8 @@ var tcpPortNames = map[TCPPort]string{ 7013: "microtalon-dis", 7014: "microtalon-com", 7015: "talon-webserver", + 7016: "spg", + 7017: "grasp", 7018: "fisa-svc", 7019: "doceri-ctl", 7020: "dpserve", @@ -4776,6 +4785,7 @@ var tcpPortNames = map[TCPPort]string{ 7174: "clutild", 7200: "fodms", 7201: "dlip", + 7202: "pon-ictp", 7215: "PS-Server", 7216: "PS-Capture-Pro", 7227: "ramp", @@ -4926,6 +4936,8 @@ var tcpPortNames = map[TCPPort]string{ 8002: "teradataordbms", 8003: "mcreport", 8005: "mxi", + 8006: "wpl-analytics", + 8007: "warppipe", 8008: "http-alt", 8019: "qbdb", 8020: "intu-ec-svcdisc", @@ -4937,6 +4949,7 @@ var tcpPortNames = map[TCPPort]string{ 8033: "mindprint", 8034: "vantronix-mgmt", 8040: "ampify", + 8041: "enguity-xccetp", 8042: "fs-agent", 8043: "fs-server", 8044: "fs-mgmt", @@ -4951,7 +4964,9 @@ var tcpPortNames = map[TCPPort]string{ 8059: "senomix08", 8066: "toad-bi-appsrvr", 8067: "infi-async", + 8070: "ucs-isc", 8074: "gadugadu", + 8077: "mles", 8080: "http-alt", 8081: "sunproxyadmin", 8082: "us-cli", @@ -4959,6 +4974,7 @@ var tcpPortNames = map[TCPPort]string{ 8086: "d-s-n", 8087: "simplifymedia", 8088: "radan-http", + 8090: "opsmessaging", 8091: "jamlink", 8097: "sac", 8100: "xprint-server", @@ -5000,6 +5016,7 @@ var tcpPortNames = map[TCPPort]string{ 8208: "lm-webwatcher", 8230: "rexecj", 8243: "synapse-nhttps", + 8270: "robot-remote", 8276: "pando-sec", 8280: "synapse-nhttp", 8282: "libelle", @@ -5028,6 +5045,7 @@ var tcpPortNames = map[TCPPort]string{ 8415: "dlpx-sp", 8416: "espeech", 8417: "espeech-rtp", + 8423: "aritts", 8442: "cybro-a-bus", 8443: "pcsync-https", 8444: "pcsync-http", @@ -5258,6 +5276,8 @@ var tcpPortNames = map[TCPPort]string{ 9955: "alljoyn-stm", 9966: "odnsp", 9978: "xybrid-rt", + 9979: "visweather", + 9981: "pumpkindb", 9987: "dsm-scm-target", 9988: "nsesrvr", 9990: "osm-appsrvr", @@ -5281,6 +5301,7 @@ var tcpPortNames = map[TCPPort]string{ 10008: "octopus", 10009: "swdtp-sv", 10010: "rxapi", + 10020: "abb-hw", 10050: "zabbix-agent", 10051: "zabbix-trapper", 10055: "qptlmd", @@ -5535,6 +5556,7 @@ var tcpPortNames = map[TCPPort]string{ 20999: "athand-mmp", 21000: "irtrans", 21010: "notezilla-lan", + 21221: "aigairserver", 21553: "rdm-tfs", 21554: "dfserver", 21590: "vofr-gateway", @@ -5648,6 +5670,7 @@ var tcpPortNames = map[TCPPort]string{ 30003: "amicon-fpsu-ra", 30100: "rwp", 30260: "kingdomsonline", + 30400: "gs-realtime", 30999: "ovobs", 31016: "ka-sddp", 31020: "autotrac-acp", @@ -5789,6 +5812,7 @@ var tcpPortNames = map[TCPPort]string{ 48619: "iqobject", 48653: "robotraconteur", 49000: "matahari", + 49001: "nusrp", } var udpPortNames = map[UDPPort]string{ 1: "tcpmux", @@ -5820,7 +5844,6 @@ var udpPortNames = map[UDPPort]string{ 44: "mpm-flags", 45: "mpm", 46: "mpm-snd", - 47: "ni-ftp", 48: "auditd", 49: "tacacs", 50: "re-mail-ck", @@ -5830,7 +5853,6 @@ var udpPortNames = map[UDPPort]string{ 55: "isi-gl", 56: "xns-auth", 58: "xns-mail", - 61: "ni-mail", 62: "acas", 63: "whoispp", 64: "covia", @@ -6447,6 +6469,7 @@ var udpPortNames = map[UDPPort]string{ 847: "dhcp-failover2", 848: "gdoi", 853: "domain-s", + 854: "dlep", 860: "iscsi", 861: "owamp-control", 862: "twamp-control", @@ -8483,7 +8506,6 @@ var udpPortNames = map[UDPPort]string{ 3068: "ls3bcast", 3069: "ls3", 3070: "mgxswitch", - 3071: "csd-mgmt-port", 3072: "csd-monitor", 3073: "vcrp", 3074: "xbox", @@ -9562,6 +9584,7 @@ var udpPortNames = map[UDPPort]string{ 4188: "vatata", 4191: "dsmipv6", 4192: "azeti-bd", + 4197: "hctl", 4199: "eims-admin", 4300: "corelccam", 4301: "d-data", @@ -9570,7 +9593,7 @@ var udpPortNames = map[UDPPort]string{ 4304: "owserver", 4305: "batman", 4306: "pinghgl", - 4307: "visicron-vs", + 4307: "trueconf", 4308: "compx-lockview", 4309: "dserver", 4310: "mirrtex", @@ -9732,6 +9755,7 @@ var udpPortNames = map[UDPPort]string{ 4700: "netxms-agent", 4701: "netxms-mgmt", 4702: "netxms-sync", + 4711: "trinity-dist", 4725: "truckstar", 4726: "a26-fap-fgw", 4727: "fcis-disc", @@ -10239,6 +10263,7 @@ var udpPortNames = map[UDPPort]string{ 6446: "mysql-proxy", 6455: "skip-cert-recv", 6456: "skip-cert-send", + 6464: "ieee11073-20701", 6471: "lvision-lm", 6480: "sun-sr-http", 6481: "servicetags", @@ -10355,6 +10380,8 @@ var udpPortNames = map[UDPPort]string{ 7013: "microtalon-dis", 7014: "microtalon-com", 7015: "talon-webserver", + 7016: "spg", + 7017: "grasp", 7019: "doceri-view", 7020: "dpserve", 7021: "dpserveadmin", @@ -10513,6 +10540,8 @@ var udpPortNames = map[UDPPort]string{ 8002: "teradataordbms", 8003: "mcreport", 8005: "mxi", + 8006: "wpl-disc", + 8007: "warppipe", 8008: "http-alt", 8019: "qbdb", 8020: "intu-ec-svcdisc", @@ -10524,6 +10553,7 @@ var udpPortNames = map[UDPPort]string{ 8033: "mindprint", 8034: "vantronix-mgmt", 8040: "ampify", + 8041: "enguity-xccetp", 8052: "senomix01", 8053: "senomix02", 8054: "senomix03", @@ -10634,6 +10664,7 @@ var udpPortNames = map[UDPPort]string{ 8793: "acd-pm", 8800: "sunwebadmin", 8804: "truecm", + 8805: "pfcp", 8808: "ssports-bcast", 8873: "dxspider", 8880: "cddbp-alt", @@ -11241,6 +11272,7 @@ var udpPortNames = map[UDPPort]string{ 48556: "com-bardac-dw", 48619: "iqobject", 48653: "robotraconteur", + 49001: "nusdp-disc", } var sctpPortNames = map[SCTPPort]string{ 9: "discard", @@ -11267,6 +11299,7 @@ var sctpPortNames = map[SCTPPort]string{ 3868: "diameter", 4333: "ahsp", 4502: "a25-fap-fgw", + 4711: "trinity-dist", 4739: "ipfix", 4740: "ipfixs", 5060: "sip", @@ -11287,6 +11320,7 @@ var sctpPortNames = map[SCTPPort]string{ 6706: "frc-lp", 6970: "conductor-mpx", 7626: "simco", + 7701: "nfapi", 7728: "osvr", 8471: "pim-port", 9082: "lcs-ap", @@ -11311,4 +11345,7 @@ var sctpPortNames = map[SCTPPort]string{ 36443: "m2ap", 36444: "m3ap", 36462: "xw-control", + 38412: "ng-control", + 38422: "xn-control", + 38472: "f1-control", } diff --git a/vendor/github.com/google/gopacket/layers/icmp6.go b/vendor/github.com/google/gopacket/layers/icmp6.go index 03a32131..5354a169 100644 --- a/vendor/github.com/google/gopacket/layers/icmp6.go +++ b/vendor/github.com/google/gopacket/layers/icmp6.go @@ -165,8 +165,10 @@ func CreateICMPv6TypeCode(typ uint8, code uint8) ICMPv6TypeCode { // ICMPv6 is the layer for IPv6 ICMP packet data type ICMPv6 struct { BaseLayer - TypeCode ICMPv6TypeCode - Checksum uint16 + TypeCode ICMPv6TypeCode + Checksum uint16 + // TypeBytes is deprecated and always nil. See the different ICMPv6 message types + // instead (e.g. ICMPv6TypeRouterSolicitation). TypeBytes []byte tcpipchecksum } @@ -176,14 +178,13 @@ 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 { + if len(data) < 4 { df.SetTruncated() - return errors.New("ICMP layer less then 8 bytes for ICMPv6 packet") + return errors.New("ICMP layer less then 4 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:]} + i.BaseLayer = BaseLayer{data[:4], data[4:]} return nil } @@ -191,17 +192,12 @@ func (i *ICMPv6) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error // 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) + bytes, err := b.PrependBytes(4) if err != nil { return err } i.TypeCode.SerializeTo(bytes) - copy(bytes[4:8], i.TypeBytes) + if opts.ComputeChecksums { bytes[2] = 0 bytes[3] = 0 @@ -212,6 +208,7 @@ func (i *ICMPv6) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.Serialize i.Checksum = csum } binary.BigEndian.PutUint16(bytes[2:], i.Checksum) + return nil } @@ -222,6 +219,23 @@ func (i *ICMPv6) CanDecode() gopacket.LayerClass { // NextLayerType returns the layer type contained by this DecodingLayer. func (i *ICMPv6) NextLayerType() gopacket.LayerType { + switch i.TypeCode.Type() { + case ICMPv6TypeEchoRequest: + return LayerTypeICMPv6Echo + case ICMPv6TypeEchoReply: + return LayerTypeICMPv6Echo + case ICMPv6TypeRouterSolicitation: + return LayerTypeICMPv6RouterSolicitation + case ICMPv6TypeRouterAdvertisement: + return LayerTypeICMPv6RouterAdvertisement + case ICMPv6TypeNeighborSolicitation: + return LayerTypeICMPv6NeighborSolicitation + case ICMPv6TypeNeighborAdvertisement: + return LayerTypeICMPv6NeighborAdvertisement + case ICMPv6TypeRedirect: + return LayerTypeICMPv6Redirect + } + return gopacket.LayerTypePayload } diff --git a/vendor/github.com/google/gopacket/layers/icmp6msg.go b/vendor/github.com/google/gopacket/layers/icmp6msg.go new file mode 100644 index 00000000..b790a40a --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/icmp6msg.go @@ -0,0 +1,573 @@ +// 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" + "net" + "time" + + "github.com/google/gopacket" +) + +// Based on RFC 4861 + +// ICMPv6Opt indicate how to decode the data associated with each ICMPv6Option. +type ICMPv6Opt uint8 + +const ( + _ ICMPv6Opt = iota + + // ICMPv6OptSourceAddress contains the link-layer address of the sender of + // the packet. It is used in the Neighbor Solicitation, Router + // Solicitation, and Router Advertisement packets. Must be ignored for other + // Neighbor discovery messages. + ICMPv6OptSourceAddress + + // ICMPv6OptTargetAddress contains the link-layer address of the target. It + // is used in Neighbor Advertisement and Redirect packets. Must be ignored + // for other Neighbor discovery messages. + ICMPv6OptTargetAddress + + // ICMPv6OptPrefixInfo provides hosts with on-link prefixes and prefixes + // for Address Autoconfiguration. The Prefix Information option appears in + // Router Advertisement packets and MUST be silently ignored for other + // messages. + ICMPv6OptPrefixInfo + + // ICMPv6OptRedirectedHeader is used in Redirect messages and contains all + // or part of the packet that is being redirected. + ICMPv6OptRedirectedHeader + + // ICMPv6OptMTU is used in Router Advertisement messages to ensure that all + // nodes on a link use the same MTU value in those cases where the link MTU + // is not well known. This option MUST be silently ignored for other + // Neighbor Discovery messages. + ICMPv6OptMTU +) + +// ICMPv6Echo represents the structure of a ping. +type ICMPv6Echo struct { + BaseLayer + Identifier uint16 + SeqNumber uint16 +} + +// ICMPv6RouterSolicitation is sent by hosts to find routers. +type ICMPv6RouterSolicitation struct { + BaseLayer + Options ICMPv6Options +} + +// ICMPv6RouterAdvertisement is sent by routers in response to Solicitation. +type ICMPv6RouterAdvertisement struct { + BaseLayer + HopLimit uint8 + Flags uint8 + RouterLifetime uint16 + ReachableTime uint32 + RetransTimer uint32 + Options ICMPv6Options +} + +// ICMPv6NeighborSolicitation is sent to request the link-layer address of a +// target node. +type ICMPv6NeighborSolicitation struct { + BaseLayer + TargetAddress net.IP + Options ICMPv6Options +} + +// ICMPv6NeighborAdvertisement is sent by nodes in response to Solicitation. +type ICMPv6NeighborAdvertisement struct { + BaseLayer + Flags uint8 + TargetAddress net.IP + Options ICMPv6Options +} + +// ICMPv6Redirect is sent by routers to inform hosts of a better first-hop node +// on the path to a destination. +type ICMPv6Redirect struct { + BaseLayer + TargetAddress net.IP + DestinationAddress net.IP + Options ICMPv6Options +} + +// ICMPv6Option contains the type and data for a single option. +type ICMPv6Option struct { + Type ICMPv6Opt + Data []byte +} + +// ICMPv6Options is a slice of ICMPv6Option. +type ICMPv6Options []ICMPv6Option + +func (i ICMPv6Opt) String() string { + switch i { + case ICMPv6OptSourceAddress: + return "SourceAddress" + case ICMPv6OptTargetAddress: + return "TargetAddress" + case ICMPv6OptPrefixInfo: + return "PrefixInfo" + case ICMPv6OptRedirectedHeader: + return "RedirectedHeader" + case ICMPv6OptMTU: + return "MTU" + default: + return fmt.Sprintf("Unknown(%d)", i) + } +} + +// LayerType returns LayerTypeICMPv6Echo. +func (i *ICMPv6Echo) LayerType() gopacket.LayerType { + return LayerTypeICMPv6Echo +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (i *ICMPv6Echo) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +// DecodeFromBytes decodes the given bytes into this layer. +func (i *ICMPv6Echo) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 4 { + df.SetTruncated() + return errors.New("ICMP layer less then 4 bytes for ICMPv6 Echo") + } + i.Identifier = binary.BigEndian.Uint16(data[0:2]) + i.SeqNumber = binary.BigEndian.Uint16(data[2:4]) + + 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 *ICMPv6Echo) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + buf, err := b.PrependBytes(4) + if err != nil { + return err + } + + binary.BigEndian.PutUint16(buf, i.Identifier) + binary.BigEndian.PutUint16(buf[2:], i.SeqNumber) + return nil +} + +// LayerType returns LayerTypeICMPv6. +func (i *ICMPv6RouterSolicitation) LayerType() gopacket.LayerType { + return LayerTypeICMPv6RouterSolicitation +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (i *ICMPv6RouterSolicitation) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +// DecodeFromBytes decodes the given bytes into this layer. +func (i *ICMPv6RouterSolicitation) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + // first 4 bytes are reserved followed by options + if len(data) < 4 { + df.SetTruncated() + return errors.New("ICMP layer less then 4 bytes for ICMPv6 router solicitation") + } + + // truncate old options + i.Options = i.Options[:0] + + return i.Options.DecodeFromBytes(data[4:], df) +} + +// 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 *ICMPv6RouterSolicitation) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + if err := i.Options.SerializeTo(b, opts); err != nil { + return err + } + + buf, err := b.PrependBytes(4) + if err != nil { + return err + } + + copy(buf, lotsOfZeros[:4]) + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (i *ICMPv6RouterSolicitation) CanDecode() gopacket.LayerClass { + return LayerTypeICMPv6RouterSolicitation +} + +// LayerType returns LayerTypeICMPv6RouterAdvertisement. +func (i *ICMPv6RouterAdvertisement) LayerType() gopacket.LayerType { + return LayerTypeICMPv6RouterAdvertisement +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (i *ICMPv6RouterAdvertisement) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +// DecodeFromBytes decodes the given bytes into this layer. +func (i *ICMPv6RouterAdvertisement) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 12 { + df.SetTruncated() + return errors.New("ICMP layer less then 12 bytes for ICMPv6 router advertisement") + } + + i.HopLimit = uint8(data[0]) + // M, O bit followed by 6 reserved bits + i.Flags = uint8(data[1]) + i.RouterLifetime = binary.BigEndian.Uint16(data[2:4]) + i.ReachableTime = binary.BigEndian.Uint32(data[4:8]) + i.RetransTimer = binary.BigEndian.Uint32(data[8:12]) + i.BaseLayer = BaseLayer{data, nil} // assume no payload + + // truncate old options + i.Options = i.Options[:0] + + return i.Options.DecodeFromBytes(data[12:], df) +} + +// 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 *ICMPv6RouterAdvertisement) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + if err := i.Options.SerializeTo(b, opts); err != nil { + return err + } + + buf, err := b.PrependBytes(12) + if err != nil { + return err + } + + buf[0] = byte(i.HopLimit) + buf[1] = byte(i.Flags) + binary.BigEndian.PutUint16(buf[2:], i.RouterLifetime) + binary.BigEndian.PutUint32(buf[4:], i.ReachableTime) + binary.BigEndian.PutUint32(buf[8:], i.RetransTimer) + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (i *ICMPv6RouterAdvertisement) CanDecode() gopacket.LayerClass { + return LayerTypeICMPv6RouterAdvertisement +} + +// ManagedAddressConfig is true when addresses are available via DHCPv6. If +// set, the OtherConfig flag is redundant. +func (i *ICMPv6RouterAdvertisement) ManagedAddressConfig() bool { + return i.Flags&0x80 != 0 +} + +// OtherConfig is true when there is other configuration information available +// via DHCPv6. For example, DNS-related information. +func (i *ICMPv6RouterAdvertisement) OtherConfig() bool { + return i.Flags&0x40 != 0 +} + +// LayerType returns LayerTypeICMPv6NeighborSolicitation. +func (i *ICMPv6NeighborSolicitation) LayerType() gopacket.LayerType { + return LayerTypeICMPv6NeighborSolicitation +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (i *ICMPv6NeighborSolicitation) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +// DecodeFromBytes decodes the given bytes into this layer. +func (i *ICMPv6NeighborSolicitation) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 20 { + df.SetTruncated() + return errors.New("ICMP layer less then 20 bytes for ICMPv6 neighbor solicitation") + } + + i.TargetAddress = net.IP(data[4:20]) + i.BaseLayer = BaseLayer{data, nil} // assume no payload + + // truncate old options + i.Options = i.Options[:0] + + return i.Options.DecodeFromBytes(data[20:], df) +} + +// 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 *ICMPv6NeighborSolicitation) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + if err := i.Options.SerializeTo(b, opts); err != nil { + return err + } + + buf, err := b.PrependBytes(20) + if err != nil { + return err + } + + copy(buf, lotsOfZeros[:4]) + copy(buf[4:], i.TargetAddress) + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (i *ICMPv6NeighborSolicitation) CanDecode() gopacket.LayerClass { + return LayerTypeICMPv6NeighborSolicitation +} + +// LayerType returns LayerTypeICMPv6NeighborAdvertisement. +func (i *ICMPv6NeighborAdvertisement) LayerType() gopacket.LayerType { + return LayerTypeICMPv6NeighborAdvertisement +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (i *ICMPv6NeighborAdvertisement) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +// DecodeFromBytes decodes the given bytes into this layer. +func (i *ICMPv6NeighborAdvertisement) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 20 { + df.SetTruncated() + return errors.New("ICMP layer less then 20 bytes for ICMPv6 neighbor advertisement") + } + + i.Flags = uint8(data[0]) + i.TargetAddress = net.IP(data[4:20]) + i.BaseLayer = BaseLayer{data, nil} // assume no payload + + // truncate old options + i.Options = i.Options[:0] + + return i.Options.DecodeFromBytes(data[20:], df) +} + +// 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 *ICMPv6NeighborAdvertisement) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + if err := i.Options.SerializeTo(b, opts); err != nil { + return err + } + + buf, err := b.PrependBytes(20) + if err != nil { + return err + } + + buf[0] = byte(i.Flags) + copy(buf[1:], lotsOfZeros[:3]) + copy(buf[4:], i.TargetAddress) + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (i *ICMPv6NeighborAdvertisement) CanDecode() gopacket.LayerClass { + return LayerTypeICMPv6NeighborAdvertisement +} + +// Router indicates whether the sender is a router or not. +func (i *ICMPv6NeighborAdvertisement) Router() bool { + return i.Flags&0x80 != 0 +} + +// Solicited indicates whether the advertisement was solicited or not. +func (i *ICMPv6NeighborAdvertisement) Solicited() bool { + return i.Flags&0x40 != 0 +} + +// Override indicates whether the advertisement should Override an existing +// cache entry. +func (i *ICMPv6NeighborAdvertisement) Override() bool { + return i.Flags&0x20 != 0 +} + +// LayerType returns LayerTypeICMPv6Redirect. +func (i *ICMPv6Redirect) LayerType() gopacket.LayerType { + return LayerTypeICMPv6Redirect +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (i *ICMPv6Redirect) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypePayload +} + +// DecodeFromBytes decodes the given bytes into this layer. +func (i *ICMPv6Redirect) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 36 { + df.SetTruncated() + return errors.New("ICMP layer less then 36 bytes for ICMPv6 redirect") + } + + i.TargetAddress = net.IP(data[4:20]) + i.DestinationAddress = net.IP(data[20:36]) + i.BaseLayer = BaseLayer{data, nil} // assume no payload + + // truncate old options + i.Options = i.Options[:0] + + return i.Options.DecodeFromBytes(data[36:], df) +} + +// 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 *ICMPv6Redirect) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + if err := i.Options.SerializeTo(b, opts); err != nil { + return err + } + + buf, err := b.PrependBytes(36) + if err != nil { + return err + } + + copy(buf, lotsOfZeros[:4]) + copy(buf[4:], i.TargetAddress) + copy(buf[20:], i.DestinationAddress) + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (i *ICMPv6Redirect) CanDecode() gopacket.LayerClass { + return LayerTypeICMPv6Redirect +} + +func (i ICMPv6Option) String() string { + hd := hex.EncodeToString(i.Data) + if len(hd) > 0 { + hd = " 0x" + hd + } + + switch i.Type { + case ICMPv6OptSourceAddress, ICMPv6OptTargetAddress: + return fmt.Sprintf("ICMPv6Option(%s:%v)", + i.Type, + net.HardwareAddr(i.Data)) + case ICMPv6OptPrefixInfo: + if len(i.Data) == 30 { + prefixLen := uint8(i.Data[0]) + onLink := (i.Data[1]&0x80 != 0) + autonomous := (i.Data[1]&0x40 != 0) + validLifetime := time.Duration(binary.BigEndian.Uint32(i.Data[2:6])) * time.Second + preferredLifetime := time.Duration(binary.BigEndian.Uint32(i.Data[6:10])) * time.Second + + prefix := net.IP(i.Data[14:]) + + return fmt.Sprintf("ICMPv6Option(%s:%v/%v:%t:%t:%v:%v)", + i.Type, + prefix, prefixLen, + onLink, autonomous, + validLifetime, preferredLifetime) + } + case ICMPv6OptRedirectedHeader: + // could invoke IP decoder on data... probably best not to + break + case ICMPv6OptMTU: + if len(i.Data) == 6 { + return fmt.Sprintf("ICMPv6Option(%s:%v)", + i.Type, + binary.BigEndian.Uint32(i.Data[2:])) + } + + } + return fmt.Sprintf("ICMPv6Option(%s:%s)", i.Type, hd) +} + +// DecodeFromBytes decodes the given bytes into this layer. +func (i *ICMPv6Options) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + for len(data) > 0 { + if len(data) < 2 { + df.SetTruncated() + return errors.New("ICMP layer less then 2 bytes for ICMPv6 message option") + } + + // unit is 8 octets, convert to bytes + length := int(data[1]) * 8 + + if length == 0 { + df.SetTruncated() + return errors.New("ICMPv6 message option with length 0") + } + + if len(data) < length { + df.SetTruncated() + return fmt.Errorf("ICMP layer only %v bytes for ICMPv6 message option with length %v", len(data), length) + } + + o := ICMPv6Option{ + Type: ICMPv6Opt(data[0]), + Data: data[2:length], + } + + // chop off option we just consumed + data = data[length:] + + *i = append(*i, o) + } + + 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 *ICMPv6Options) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + for _, opt := range []ICMPv6Option(*i) { + length := len(opt.Data) + 2 + buf, err := b.PrependBytes(length) + if err != nil { + return err + } + + buf[0] = byte(opt.Type) + buf[1] = byte(length / 8) + copy(buf[2:], opt.Data) + } + + return nil +} + +func decodeICMPv6Echo(data []byte, p gopacket.PacketBuilder) error { + i := &ICMPv6Echo{} + return decodingLayerDecoder(i, data, p) +} + +func decodeICMPv6RouterSolicitation(data []byte, p gopacket.PacketBuilder) error { + i := &ICMPv6RouterSolicitation{} + return decodingLayerDecoder(i, data, p) +} + +func decodeICMPv6RouterAdvertisement(data []byte, p gopacket.PacketBuilder) error { + i := &ICMPv6RouterAdvertisement{} + return decodingLayerDecoder(i, data, p) +} + +func decodeICMPv6NeighborSolicitation(data []byte, p gopacket.PacketBuilder) error { + i := &ICMPv6NeighborSolicitation{} + return decodingLayerDecoder(i, data, p) +} + +func decodeICMPv6NeighborAdvertisement(data []byte, p gopacket.PacketBuilder) error { + i := &ICMPv6NeighborAdvertisement{} + return decodingLayerDecoder(i, data, p) +} + +func decodeICMPv6Redirect(data []byte, p gopacket.PacketBuilder) error { + i := &ICMPv6Redirect{} + return decodingLayerDecoder(i, data, p) +} diff --git a/vendor/github.com/google/gopacket/layers/ip6.go b/vendor/github.com/google/gopacket/layers/ip6.go index b5befe9c..9463e71a 100644 --- a/vendor/github.com/google/gopacket/layers/ip6.go +++ b/vendor/github.com/google/gopacket/layers/ip6.go @@ -240,6 +240,8 @@ func (ip6 *IPv6) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error 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") + } else { + ip6.Payload = ip6.Payload[ip6.hbh.ActualLength:] } } diff --git a/vendor/github.com/google/gopacket/layers/layertypes.go b/vendor/github.com/google/gopacket/layers/layertypes.go index bc3b9d59..a6070c43 100644 --- a/vendor/github.com/google/gopacket/layers/layertypes.go +++ b/vendor/github.com/google/gopacket/layers/layertypes.go @@ -123,6 +123,19 @@ var ( LayerTypeVRRP = gopacket.RegisterLayerType(119, gopacket.LayerTypeMetadata{Name: "VRRP", Decoder: gopacket.DecodeFunc(decodeVRRP)}) LayerTypeGeneve = gopacket.RegisterLayerType(120, gopacket.LayerTypeMetadata{Name: "Geneve", Decoder: gopacket.DecodeFunc(decodeGeneve)}) LayerTypeSTP = gopacket.RegisterLayerType(121, gopacket.LayerTypeMetadata{Name: "STP", Decoder: gopacket.DecodeFunc(decodeSTP)}) + LayerTypeBFD = gopacket.RegisterLayerType(122, gopacket.LayerTypeMetadata{Name: "BFD", Decoder: gopacket.DecodeFunc(decodeBFD)}) + LayerTypeOSPF = gopacket.RegisterLayerType(123, gopacket.LayerTypeMetadata{Name: "OSPF", Decoder: gopacket.DecodeFunc(decodeOSPF)}) + LayerTypeICMPv6RouterSolicitation = gopacket.RegisterLayerType(124, gopacket.LayerTypeMetadata{Name: "ICMPv6RouterSolicitation", Decoder: gopacket.DecodeFunc(decodeICMPv6RouterSolicitation)}) + LayerTypeICMPv6RouterAdvertisement = gopacket.RegisterLayerType(125, gopacket.LayerTypeMetadata{Name: "ICMPv6RouterAdvertisement", Decoder: gopacket.DecodeFunc(decodeICMPv6RouterAdvertisement)}) + LayerTypeICMPv6NeighborSolicitation = gopacket.RegisterLayerType(126, gopacket.LayerTypeMetadata{Name: "ICMPv6NeighborSolicitation", Decoder: gopacket.DecodeFunc(decodeICMPv6NeighborSolicitation)}) + LayerTypeICMPv6NeighborAdvertisement = gopacket.RegisterLayerType(127, gopacket.LayerTypeMetadata{Name: "ICMPv6NeighborAdvertisement", Decoder: gopacket.DecodeFunc(decodeICMPv6NeighborAdvertisement)}) + LayerTypeICMPv6Redirect = gopacket.RegisterLayerType(128, gopacket.LayerTypeMetadata{Name: "ICMPv6Redirect", Decoder: gopacket.DecodeFunc(decodeICMPv6Redirect)}) + LayerTypeGTPv1U = gopacket.RegisterLayerType(129, gopacket.LayerTypeMetadata{Name: "GTPv1U", Decoder: gopacket.DecodeFunc(decodeGTPv1u)}) + LayerTypeEAPOLKey = gopacket.RegisterLayerType(130, gopacket.LayerTypeMetadata{Name: "EAPOLKey", Decoder: gopacket.DecodeFunc(decodeEAPOLKey)}) + LayerTypeLCM = gopacket.RegisterLayerType(131, gopacket.LayerTypeMetadata{Name: "LCM", Decoder: gopacket.DecodeFunc(decodeLCM)}) + LayerTypeICMPv6Echo = gopacket.RegisterLayerType(132, gopacket.LayerTypeMetadata{Name: "ICMPv6Echo", Decoder: gopacket.DecodeFunc(decodeICMPv6Echo)}) + LayerTypeSIP = gopacket.RegisterLayerType(133, gopacket.LayerTypeMetadata{Name: "SIP", Decoder: gopacket.DecodeFunc(decodeSIP)}) + LayerTypeDHCPv6 = gopacket.RegisterLayerType(134, gopacket.LayerTypeMetadata{Name: "DHCPv6", Decoder: gopacket.DecodeFunc(decodeDHCPv6)}) ) var ( @@ -172,4 +185,13 @@ var ( LayerTypeIPSecAH, LayerTypeIPSecESP, }) + // LayerClassICMPv6NDP contains ICMPv6 neighbor discovery protocol + // messages. + LayerClassICMPv6NDP = gopacket.NewLayerClass([]gopacket.LayerType{ + LayerTypeICMPv6RouterSolicitation, + LayerTypeICMPv6RouterAdvertisement, + LayerTypeICMPv6NeighborSolicitation, + LayerTypeICMPv6NeighborAdvertisement, + LayerTypeICMPv6Redirect, + }) ) diff --git a/vendor/github.com/google/gopacket/layers/lcm.go b/vendor/github.com/google/gopacket/layers/lcm.go new file mode 100644 index 00000000..5fe9fa54 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/lcm.go @@ -0,0 +1,213 @@ +// Copyright 2018 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" +) + +const ( + // LCMShortHeaderMagic is the LCM small message header magic number + LCMShortHeaderMagic uint32 = 0x4c433032 + // LCMFragmentedHeaderMagic is the LCM fragmented message header magic number + LCMFragmentedHeaderMagic uint32 = 0x4c433033 +) + +// LCM (Lightweight Communications and Marshalling) is a set of libraries and +// tools for message passing and data marshalling, targeted at real-time systems +// where high-bandwidth and low latency are critical. It provides a +// publish/subscribe message passing model and automatic +// marshalling/unmarshalling code generation with bindings for applications in a +// variety of programming languages. +// +// References +// https://lcm-proj.github.io/ +// https://github.com/lcm-proj/lcm +type LCM struct { + // Common (short & fragmented header) fields + Magic uint32 + SequenceNumber uint32 + // Fragmented header only fields + PayloadSize uint32 + FragmentOffset uint32 + FragmentNumber uint16 + TotalFragments uint16 + // Common field + ChannelName string + // Gopacket helper fields + Fragmented bool + fingerprint LCMFingerprint + contents []byte + payload []byte +} + +// LCMFingerprint is the type of a LCM fingerprint. +type LCMFingerprint uint64 + +var ( + // lcmLayerTypes contains a map of all LCM fingerprints that we support and + // their LayerType + lcmLayerTypes = map[LCMFingerprint]gopacket.LayerType{} + layerTypeIndex = 1001 +) + +// RegisterLCMLayerType allows users to register decoders for the underlying +// LCM payload. This is done based on the fingerprint that every LCM message +// contains and which identifies it uniquely. If num is not the zero value it +// will be used when registering with RegisterLayerType towards gopacket, +// otherwise an incremental value starting from 1001 will be used. +func RegisterLCMLayerType(num int, name string, fingerprint LCMFingerprint, + decoder gopacket.Decoder) gopacket.LayerType { + metadata := gopacket.LayerTypeMetadata{Name: name, Decoder: decoder} + + if num == 0 { + num = layerTypeIndex + layerTypeIndex++ + } + + lcmLayerTypes[fingerprint] = gopacket.RegisterLayerType(num, metadata) + + return lcmLayerTypes[fingerprint] +} + +// SupportedLCMFingerprints returns a slice of all LCM fingerprints that has +// been registered so far. +func SupportedLCMFingerprints() []LCMFingerprint { + fingerprints := make([]LCMFingerprint, 0, len(lcmLayerTypes)) + for fp := range lcmLayerTypes { + fingerprints = append(fingerprints, fp) + } + return fingerprints +} + +// GetLCMLayerType returns the underlying LCM message's LayerType. +// This LayerType has to be registered by using RegisterLCMLayerType. +func GetLCMLayerType(fingerprint LCMFingerprint) gopacket.LayerType { + layerType, ok := lcmLayerTypes[fingerprint] + if !ok { + return gopacket.LayerTypePayload + } + + return layerType +} + +func decodeLCM(data []byte, p gopacket.PacketBuilder) error { + lcm := &LCM{} + + err := lcm.DecodeFromBytes(data, p) + if err != nil { + return err + } + + p.AddLayer(lcm) + p.SetApplicationLayer(lcm) + + return p.NextDecoder(lcm.NextLayerType()) +} + +// DecodeFromBytes decodes the given bytes into this layer. +func (lcm *LCM) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + offset := 0 + + lcm.Magic = binary.BigEndian.Uint32(data[offset:4]) + offset += 4 + + if lcm.Magic != LCMShortHeaderMagic && lcm.Magic != LCMFragmentedHeaderMagic { + return fmt.Errorf("Received LCM header magic %v does not match know "+ + "LCM magic numbers. Dropping packet.", lcm.Magic) + } + + lcm.SequenceNumber = binary.BigEndian.Uint32(data[offset:8]) + offset += 4 + + if lcm.Magic == LCMFragmentedHeaderMagic { + lcm.Fragmented = true + + lcm.PayloadSize = binary.BigEndian.Uint32(data[offset : offset+4]) + offset += 4 + + lcm.FragmentOffset = binary.BigEndian.Uint32(data[offset : offset+4]) + offset += 4 + + lcm.FragmentNumber = binary.BigEndian.Uint16(data[offset : offset+2]) + offset += 2 + + lcm.TotalFragments = binary.BigEndian.Uint16(data[offset : offset+2]) + offset += 2 + } else { + lcm.Fragmented = false + } + + if !lcm.Fragmented || (lcm.Fragmented && lcm.FragmentNumber == 0) { + buffer := make([]byte, 0) + for _, b := range data[offset:] { + offset++ + + if b == 0 { + break + } + + buffer = append(buffer, b) + } + + lcm.ChannelName = string(buffer) + } + + lcm.fingerprint = LCMFingerprint( + binary.BigEndian.Uint64(data[offset : offset+8])) + + lcm.contents = data[:offset] + lcm.payload = data[offset:] + + return nil +} + +// CanDecode returns a set of layers that LCM objects can decode. +// As LCM objects can only decode the LCM layer, we just return that layer. +func (lcm LCM) CanDecode() gopacket.LayerClass { + return LayerTypeLCM +} + +// NextLayerType specifies the LCM payload layer type following this header. +// As LCM packets are serialized structs with uniq fingerprints for each uniq +// combination of data types, lookup of correct layer type is based on that +// fingerprint. +func (lcm LCM) NextLayerType() gopacket.LayerType { + if !lcm.Fragmented || (lcm.Fragmented && lcm.FragmentNumber == 0) { + return GetLCMLayerType(lcm.fingerprint) + } + + return gopacket.LayerTypeFragment +} + +// LayerType returns LayerTypeLCM +func (lcm LCM) LayerType() gopacket.LayerType { + return LayerTypeLCM +} + +// LayerContents returns the contents of the LCM header. +func (lcm LCM) LayerContents() []byte { + return lcm.contents +} + +// LayerPayload returns the payload following this LCM header. +func (lcm LCM) LayerPayload() []byte { + return lcm.payload +} + +// Payload returns the payload following this LCM header. +func (lcm LCM) Payload() []byte { + return lcm.LayerPayload() +} + +// Fingerprint returns the LCM fingerprint of the underlying message. +func (lcm LCM) Fingerprint() LCMFingerprint { + return lcm.fingerprint +} diff --git a/vendor/github.com/google/gopacket/layers/llc.go b/vendor/github.com/google/gopacket/layers/llc.go index 59453fee..2f2e4a52 100644 --- a/vendor/github.com/google/gopacket/layers/llc.go +++ b/vendor/github.com/google/gopacket/layers/llc.go @@ -27,6 +27,47 @@ type LLC struct { // LayerType returns gopacket.LayerTypeLLC. func (l *LLC) LayerType() gopacket.LayerType { return LayerTypeLLC } +// DecodeFromBytes decodes the given bytes into this layer. +func (l *LLC) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 3 { + return errors.New("LLC header too small") + } + l.DSAP = data[0] & 0xFE + l.IG = data[0]&0x1 != 0 + l.SSAP = data[1] & 0xFE + l.CR = data[1]&0x1 != 0 + l.Control = uint16(data[2]) + + if l.Control&0x1 == 0 || l.Control&0x3 == 0x1 { + if len(data) < 4 { + return errors.New("LLC header too small") + } + 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:] + } + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (l *LLC) CanDecode() gopacket.LayerClass { + return LayerTypeLLC +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (l *LLC) NextLayerType() gopacket.LayerType { + switch { + case l.DSAP == 0xAA && l.SSAP == 0xAA: + return LayerTypeSNAP + case l.DSAP == 0x42 && l.SSAP == 0x42: + return LayerTypeSTP + } + return gopacket.LayerTypeZero // Not implemented +} + // SNAP is used inside LLC. See // http://standards.ieee.org/getieee802/download/802-2001.pdf. // From http://en.wikipedia.org/wiki/Subnetwork_Access_Protocol: @@ -42,37 +83,43 @@ type SNAP struct { // 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]), +// DecodeFromBytes decodes the given bytes into this layer. +func (s *SNAP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 5 { + return errors.New("SNAP header too small") } - 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:] + s.OrganizationalCode = data[:3] + s.Type = EthernetType(binary.BigEndian.Uint16(data[3:5])) + s.BaseLayer = BaseLayer{data[:5], data[5:]} + return nil +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (s *SNAP) CanDecode() gopacket.LayerClass { + return LayerTypeLLC +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (s *SNAP) NextLayerType() gopacket.LayerType { + // See BUG(gconnel) in decodeSNAP + return s.Type.LayerType() +} + +func decodeLLC(data []byte, p gopacket.PacketBuilder) error { + l := &LLC{} + err := l.DecodeFromBytes(data, p) + if err != nil { + return err } p.AddLayer(l) - switch { - case l.DSAP == 0xAA && l.SSAP == 0xAA: - return p.NextDecoder(LayerTypeSNAP) - case l.DSAP == 0x42 && l.SSAP == 0x42: - return p.NextDecoder(LayerTypeSTP) - } - return p.NextDecoder(gopacket.DecodeUnknown) + return p.NextDecoder(l.NextLayerType()) } 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:]}, + s := &SNAP{} + err := s.DecodeFromBytes(data, p) + if err != nil { + return err } p.AddLayer(s) // BUG(gconnell): When decoding SNAP, we treat the SNAP type as an Ethernet @@ -85,7 +132,7 @@ func decodeSNAP(data []byte, p gopacket.PacketBuilder) error { // 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 igFlag, crFlag byte var length int if l.Control&0xFF00 != 0 { @@ -105,18 +152,18 @@ func (l *LLC) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOpt if buf, err := b.PrependBytes(length); err != nil { return err } else { - ig_flag = 0 + igFlag = 0 if l.IG { - ig_flag = 0x1 + igFlag = 0x1 } - cr_flag = 0 + crFlag = 0 if l.CR { - cr_flag = 0x1 + crFlag = 0x1 } - buf[0] = l.DSAP + ig_flag - buf[1] = l.SSAP + cr_flag + buf[0] = l.DSAP + igFlag + buf[1] = l.SSAP + crFlag if length == 4 { buf[2] = uint8(l.Control >> 8) diff --git a/vendor/github.com/google/gopacket/layers/lldp.go b/vendor/github.com/google/gopacket/layers/lldp.go index 92ec7daf..e1282603 100644 --- a/vendor/github.com/google/gopacket/layers/lldp.go +++ b/vendor/github.com/google/gopacket/layers/lldp.go @@ -37,6 +37,10 @@ type LinkLayerDiscoveryValue struct { Value []byte } +func (c *LinkLayerDiscoveryValue) len() int { + return 0 +} + // LLDPChassisIDSubType specifies the value type for a single LLDPChassisID.ID type LLDPChassisIDSubType byte @@ -57,6 +61,20 @@ type LLDPChassisID struct { ID []byte } +func (c *LLDPChassisID) serialize() []byte { + + var buf = make([]byte, c.serializedLen()) + idLen := uint16(LLDPTLVChassisID)<<9 | uint16(len(c.ID)+1) //id should take 7 bits, length should take 9 bits, +1 for subtype + binary.BigEndian.PutUint16(buf[0:2], idLen) + buf[2] = byte(c.Subtype) + copy(buf[3:], c.ID) + return buf +} + +func (c *LLDPChassisID) serializedLen() int { + return len(c.ID) + 3 // +2 for id and length, +1 for subtype +} + // LLDPPortIDSubType specifies the value type for a single LLDPPortID.ID type LLDPPortIDSubType byte @@ -77,6 +95,20 @@ type LLDPPortID struct { ID []byte } +func (c *LLDPPortID) serialize() []byte { + + var buf = make([]byte, c.serializedLen()) + idLen := uint16(LLDPTLVPortID)<<9 | uint16(len(c.ID)+1) //id should take 7 bits, length should take 9 bits, +1 for subtype + binary.BigEndian.PutUint16(buf[0:2], idLen) + buf[2] = byte(c.Subtype) + copy(buf[3:], c.ID) + return buf +} + +func (c *LLDPPortID) serializedLen() int { + return len(c.ID) + 3 // +2 for id and length, +1 for subtype +} + // 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 @@ -733,6 +765,29 @@ func (c *LinkLayerDiscovery) LayerType() gopacket.LayerType { return LayerTypeLinkLayerDiscovery } +// SerializeTo serializes LLDP packet to bytes and writes on SerializeBuffer. +func (c *LinkLayerDiscovery) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error { + chassIDLen := c.ChassisID.serializedLen() + portIDLen := c.PortID.serializedLen() + vb, err := b.AppendBytes(chassIDLen + portIDLen + 4) // +4 for TTL + if err != nil { + return err + } + copy(vb[:chassIDLen], c.ChassisID.serialize()) + copy(vb[chassIDLen:], c.PortID.serialize()) + ttlIDLen := uint16(LLDPTLVTTL)<<9 | uint16(2) + binary.BigEndian.PutUint16(vb[chassIDLen+portIDLen:], ttlIDLen) + binary.BigEndian.PutUint16(vb[chassIDLen+portIDLen+2:], c.TTL) + + vb, err = b.AppendBytes(2) // End Tlv, 2 bytes + if err != nil { + return err + } + binary.BigEndian.PutUint16(vb[len(vb)-2:], uint16(0)) //End tlv, 2 bytes, all zero + return nil + +} + func decodeLinkLayerDiscovery(data []byte, p gopacket.PacketBuilder) error { var vals []LinkLayerDiscoveryValue vData := data[0:] diff --git a/vendor/github.com/google/gopacket/layers/ospf.go b/vendor/github.com/google/gopacket/layers/ospf.go new file mode 100644 index 00000000..f3f2ca9a --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/ospf.go @@ -0,0 +1,680 @@ +// Copyright 2017 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" +) + +// OSPFType denotes what kind of OSPF type it is +type OSPFType uint8 + +// Potential values for OSPF.Type. +const ( + OSPFHello OSPFType = 1 + OSPFDatabaseDescription OSPFType = 2 + OSPFLinkStateRequest OSPFType = 3 + OSPFLinkStateUpdate OSPFType = 4 + OSPFLinkStateAcknowledgment OSPFType = 5 +) + +// LSA Function Codes for LSAheader.LSType +const ( + RouterLSAtypeV2 = 0x1 + RouterLSAtype = 0x2001 + NetworkLSAtypeV2 = 0x2 + NetworkLSAtype = 0x2002 + SummaryLSANetworktypeV2 = 0x3 + InterAreaPrefixLSAtype = 0x2003 + SummaryLSAASBRtypeV2 = 0x4 + InterAreaRouterLSAtype = 0x2004 + ASExternalLSAtypeV2 = 0x5 + ASExternalLSAtype = 0x4005 + NSSALSAtype = 0x2007 + LinkLSAtype = 0x0008 + IntraAreaPrefixLSAtype = 0x2009 +) + +// String conversions for OSPFType +func (i OSPFType) String() string { + switch i { + case OSPFHello: + return "Hello" + case OSPFDatabaseDescription: + return "Database Description" + case OSPFLinkStateRequest: + return "Link State Request" + case OSPFLinkStateUpdate: + return "Link State Update" + case OSPFLinkStateAcknowledgment: + return "Link State Acknowledgment" + default: + return "" + } +} + +// Prefix extends IntraAreaPrefixLSA +type Prefix struct { + PrefixLength uint8 + PrefixOptions uint8 + Metric uint16 + AddressPrefix []byte +} + +// IntraAreaPrefixLSA is the struct from RFC 5340 A.4.10. +type IntraAreaPrefixLSA struct { + NumOfPrefixes uint16 + RefLSType uint16 + RefLinkStateID uint32 + RefAdvRouter uint32 + Prefixes []Prefix +} + +// LinkLSA is the struct from RFC 5340 A.4.9. +type LinkLSA struct { + RtrPriority uint8 + Options uint32 + LinkLocalAddress []byte + NumOfPrefixes uint32 + Prefixes []Prefix +} + +// ASExternalLSAV2 is the struct from RFC 2328 A.4.5. +type ASExternalLSAV2 struct { + NetworkMask uint32 + ExternalBit uint8 + Metric uint32 + ForwardingAddress uint32 + ExternalRouteTag uint32 +} + +// ASExternalLSA is the struct from RFC 5340 A.4.7. +type ASExternalLSA struct { + Flags uint8 + Metric uint32 + PrefixLength uint8 + PrefixOptions uint8 + RefLSType uint16 + AddressPrefix []byte + ForwardingAddress []byte + ExternalRouteTag uint32 + RefLinkStateID uint32 +} + +// InterAreaRouterLSA is the struct from RFC 5340 A.4.6. +type InterAreaRouterLSA struct { + Options uint32 + Metric uint32 + DestinationRouterID uint32 +} + +// InterAreaPrefixLSA is the struct from RFC 5340 A.4.5. +type InterAreaPrefixLSA struct { + Metric uint32 + PrefixLength uint8 + PrefixOptions uint8 + AddressPrefix []byte +} + +// NetworkLSA is the struct from RFC 5340 A.4.4. +type NetworkLSA struct { + Options uint32 + AttachedRouter []uint32 +} + +// RouterV2 extends RouterLSAV2 +type RouterV2 struct { + Type uint8 + LinkID uint32 + LinkData uint32 + Metric uint16 +} + +// RouterLSAV2 is the struct from RFC 2328 A.4.2. +type RouterLSAV2 struct { + Flags uint8 + Links uint16 + Routers []RouterV2 +} + +// Router extends RouterLSA +type Router struct { + Type uint8 + Metric uint16 + InterfaceID uint32 + NeighborInterfaceID uint32 + NeighborRouterID uint32 +} + +// RouterLSA is the struct from RFC 5340 A.4.3. +type RouterLSA struct { + Flags uint8 + Options uint32 + Routers []Router +} + +// LSAheader is the struct from RFC 5340 A.4.2 and RFC 2328 A.4.1. +type LSAheader struct { + LSAge uint16 + LSType uint16 + LinkStateID uint32 + AdvRouter uint32 + LSSeqNumber uint32 + LSChecksum uint16 + Length uint16 + LSOptions uint8 +} + +// LSA links LSAheader with the structs from RFC 5340 A.4. +type LSA struct { + LSAheader + Content interface{} +} + +// LSUpdate is the struct from RFC 5340 A.3.5. +type LSUpdate struct { + NumOfLSAs uint32 + LSAs []LSA +} + +// LSReq is the struct from RFC 5340 A.3.4. +type LSReq struct { + LSType uint16 + LSID uint32 + AdvRouter uint32 +} + +// DbDescPkg is the struct from RFC 5340 A.3.3. +type DbDescPkg struct { + Options uint32 + InterfaceMTU uint16 + Flags uint16 + DDSeqNumber uint32 + LSAinfo []LSAheader +} + +// HelloPkg is the struct from RFC 5340 A.3.2. +type HelloPkg struct { + InterfaceID uint32 + RtrPriority uint8 + Options uint32 + HelloInterval uint16 + RouterDeadInterval uint32 + DesignatedRouterID uint32 + BackupDesignatedRouterID uint32 + NeighborID []uint32 +} + +// HelloPkgV2 extends the HelloPkg struct with OSPFv2 information +type HelloPkgV2 struct { + HelloPkg + NetworkMask uint32 +} + +// OSPF is a basic OSPF packet header with common fields of Version 2 and Version 3. +type OSPF struct { + Version uint8 + Type OSPFType + PacketLength uint16 + RouterID uint32 + AreaID uint32 + Checksum uint16 + Content interface{} +} + +//OSPFv2 extend the OSPF head with version 2 specific fields +type OSPFv2 struct { + BaseLayer + OSPF + AuType uint16 + Authentication uint64 +} + +// OSPFv3 extend the OSPF head with version 3 specific fields +type OSPFv3 struct { + BaseLayer + OSPF + Instance uint8 + Reserved uint8 +} + +// getLSAsv2 parses the LSA information from the packet for OSPFv2 +func getLSAsv2(num uint32, data []byte) ([]LSA, error) { + var lsas []LSA + var i uint32 = 0 + var offset uint32 = 0 + for ; i < num; i++ { + lstype := uint16(data[offset+3]) + lsalength := binary.BigEndian.Uint16(data[offset+18 : offset+20]) + content, err := extractLSAInformation(lstype, lsalength, data[offset:]) + if err != nil { + return nil, fmt.Errorf("Could not extract Link State type.") + } + lsa := LSA{ + LSAheader: LSAheader{ + LSAge: binary.BigEndian.Uint16(data[offset : offset+2]), + LSOptions: data[offset+2], + LSType: lstype, + LinkStateID: binary.BigEndian.Uint32(data[offset+4 : offset+8]), + AdvRouter: binary.BigEndian.Uint32(data[offset+8 : offset+12]), + LSSeqNumber: binary.BigEndian.Uint32(data[offset+12 : offset+16]), + LSChecksum: binary.BigEndian.Uint16(data[offset+16 : offset+18]), + Length: lsalength, + }, + Content: content, + } + lsas = append(lsas, lsa) + offset += uint32(lsalength) + } + return lsas, nil +} + +// extractLSAInformation extracts all the LSA information +func extractLSAInformation(lstype, lsalength uint16, data []byte) (interface{}, error) { + if lsalength < 20 { + return nil, fmt.Errorf("Link State header length %v too short, %v required", lsalength, 20) + } + if len(data) < int(lsalength) { + return nil, fmt.Errorf("Link State header length %v too short, %v required", len(data), lsalength) + } + var content interface{} + switch lstype { + case RouterLSAtypeV2: + var routers []RouterV2 + links := binary.BigEndian.Uint16(data[22:24]) + content = RouterLSAV2{ + Flags: data[20], + Links: links, + Routers: routers, + } + case ASExternalLSAtypeV2: + content = ASExternalLSAV2{ + NetworkMask: binary.BigEndian.Uint32(data[20:24]), + ExternalBit: data[24] & 0x80, + Metric: binary.BigEndian.Uint32(data[24:28]) & 0x00FFFFFF, + ForwardingAddress: binary.BigEndian.Uint32(data[28:32]), + ExternalRouteTag: binary.BigEndian.Uint32(data[32:36]), + } + case RouterLSAtype: + var routers []Router + var j uint32 + for j = 24; j < uint32(lsalength); j += 16 { + router := Router{ + Type: uint8(data[j]), + Metric: binary.BigEndian.Uint16(data[j+2 : j+4]), + InterfaceID: binary.BigEndian.Uint32(data[j+4 : j+8]), + NeighborInterfaceID: binary.BigEndian.Uint32(data[j+8 : j+12]), + NeighborRouterID: binary.BigEndian.Uint32(data[j+12 : j+16]), + } + routers = append(routers, router) + } + content = RouterLSA{ + Flags: uint8(data[20]), + Options: binary.BigEndian.Uint32(data[20:24]) & 0x00FFFFFF, + Routers: routers, + } + case NetworkLSAtype: + var routers []uint32 + var j uint32 + for j = 24; j < uint32(lsalength); j += 4 { + routers = append(routers, binary.BigEndian.Uint32(data[j:j+4])) + } + content = NetworkLSA{ + Options: binary.BigEndian.Uint32(data[20:24]) & 0x00FFFFFF, + AttachedRouter: routers, + } + case InterAreaPrefixLSAtype: + content = InterAreaPrefixLSA{ + Metric: binary.BigEndian.Uint32(data[20:24]) & 0x00FFFFFF, + PrefixLength: uint8(data[24]), + PrefixOptions: uint8(data[25]), + AddressPrefix: data[28:uint32(lsalength)], + } + case InterAreaRouterLSAtype: + content = InterAreaRouterLSA{ + Options: binary.BigEndian.Uint32(data[20:24]) & 0x00FFFFFF, + Metric: binary.BigEndian.Uint32(data[24:28]) & 0x00FFFFFF, + DestinationRouterID: binary.BigEndian.Uint32(data[28:32]), + } + case ASExternalLSAtype: + fallthrough + case NSSALSAtype: + + flags := uint8(data[20]) + prefixLen := uint8(data[24]) / 8 + var forwardingAddress []byte + if (flags & 0x02) == 0x02 { + forwardingAddress = data[28+uint32(prefixLen) : 28+uint32(prefixLen)+16] + } + content = ASExternalLSA{ + Flags: flags, + Metric: binary.BigEndian.Uint32(data[20:24]) & 0x00FFFFFF, + PrefixLength: prefixLen, + PrefixOptions: uint8(data[25]), + RefLSType: binary.BigEndian.Uint16(data[26:28]), + AddressPrefix: data[28 : 28+uint32(prefixLen)], + ForwardingAddress: forwardingAddress, + } + case LinkLSAtype: + var prefixes []Prefix + var prefixOffset uint32 = 44 + var j uint32 + numOfPrefixes := binary.BigEndian.Uint32(data[40:44]) + for j = 0; j < numOfPrefixes; j++ { + prefixLen := uint8(data[prefixOffset]) + prefix := Prefix{ + PrefixLength: prefixLen, + PrefixOptions: uint8(data[prefixOffset+1]), + AddressPrefix: data[prefixOffset+4 : prefixOffset+4+uint32(prefixLen)/8], + } + prefixes = append(prefixes, prefix) + prefixOffset = prefixOffset + 4 + uint32(prefixLen)/8 + } + content = LinkLSA{ + RtrPriority: uint8(data[20]), + Options: binary.BigEndian.Uint32(data[20:24]) & 0x00FFFFFF, + LinkLocalAddress: data[24:40], + NumOfPrefixes: numOfPrefixes, + Prefixes: prefixes, + } + case IntraAreaPrefixLSAtype: + var prefixes []Prefix + var prefixOffset uint32 = 32 + var j uint16 + numOfPrefixes := binary.BigEndian.Uint16(data[20:22]) + for j = 0; j < numOfPrefixes; j++ { + prefixLen := uint8(data[prefixOffset]) + prefix := Prefix{ + PrefixLength: prefixLen, + PrefixOptions: uint8(data[prefixOffset+1]), + Metric: binary.BigEndian.Uint16(data[prefixOffset+2 : prefixOffset+4]), + AddressPrefix: data[prefixOffset+4 : prefixOffset+4+uint32(prefixLen)/8], + } + prefixes = append(prefixes, prefix) + prefixOffset = prefixOffset + 4 + uint32(prefixLen) + } + content = IntraAreaPrefixLSA{ + NumOfPrefixes: numOfPrefixes, + RefLSType: binary.BigEndian.Uint16(data[22:24]), + RefLinkStateID: binary.BigEndian.Uint32(data[24:28]), + RefAdvRouter: binary.BigEndian.Uint32(data[28:32]), + Prefixes: prefixes, + } + default: + return nil, fmt.Errorf("Unknown Link State type.") + } + return content, nil +} + +// getLSAs parses the LSA information from the packet for OSPFv3 +func getLSAs(num uint32, data []byte) ([]LSA, error) { + var lsas []LSA + var i uint32 = 0 + var offset uint32 = 0 + for ; i < num; i++ { + var content interface{} + lstype := binary.BigEndian.Uint16(data[offset+2 : offset+4]) + lsalength := binary.BigEndian.Uint16(data[offset+18 : offset+20]) + + content, err := extractLSAInformation(lstype, lsalength, data[offset:]) + if err != nil { + return nil, fmt.Errorf("Could not extract Link State type.") + } + lsa := LSA{ + LSAheader: LSAheader{ + LSAge: binary.BigEndian.Uint16(data[offset : offset+2]), + LSType: lstype, + LinkStateID: binary.BigEndian.Uint32(data[offset+4 : offset+8]), + AdvRouter: binary.BigEndian.Uint32(data[offset+8 : offset+12]), + LSSeqNumber: binary.BigEndian.Uint32(data[offset+12 : offset+16]), + LSChecksum: binary.BigEndian.Uint16(data[offset+16 : offset+18]), + Length: lsalength, + }, + Content: content, + } + lsas = append(lsas, lsa) + offset += uint32(lsalength) + } + return lsas, nil +} + +// DecodeFromBytes decodes the given bytes into the OSPF layer. +func (ospf *OSPFv2) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + if len(data) < 24 { + return fmt.Errorf("Packet too smal for OSPF Version 2") + } + + ospf.Version = uint8(data[0]) + ospf.Type = OSPFType(data[1]) + ospf.PacketLength = binary.BigEndian.Uint16(data[2:4]) + ospf.RouterID = binary.BigEndian.Uint32(data[4:8]) + ospf.AreaID = binary.BigEndian.Uint32(data[8:12]) + ospf.Checksum = binary.BigEndian.Uint16(data[12:14]) + ospf.AuType = binary.BigEndian.Uint16(data[14:16]) + ospf.Authentication = binary.BigEndian.Uint64(data[16:24]) + + switch ospf.Type { + case OSPFHello: + var neighbors []uint32 + for i := 44; uint16(i+4) <= ospf.PacketLength; i += 4 { + neighbors = append(neighbors, binary.BigEndian.Uint32(data[i:i+4])) + } + ospf.Content = HelloPkgV2{ + NetworkMask: binary.BigEndian.Uint32(data[24:28]), + HelloPkg: HelloPkg{ + HelloInterval: binary.BigEndian.Uint16(data[28:30]), + Options: uint32(data[30]), + RtrPriority: uint8(data[31]), + RouterDeadInterval: binary.BigEndian.Uint32(data[32:36]), + DesignatedRouterID: binary.BigEndian.Uint32(data[36:40]), + BackupDesignatedRouterID: binary.BigEndian.Uint32(data[40:44]), + NeighborID: neighbors, + }, + } + case OSPFDatabaseDescription: + var lsas []LSAheader + for i := 32; uint16(i+20) <= ospf.PacketLength; i += 20 { + lsa := LSAheader{ + LSAge: binary.BigEndian.Uint16(data[i : i+2]), + LSType: binary.BigEndian.Uint16(data[i+2 : i+4]), + LinkStateID: binary.BigEndian.Uint32(data[i+4 : i+8]), + AdvRouter: binary.BigEndian.Uint32(data[i+8 : i+12]), + LSSeqNumber: binary.BigEndian.Uint32(data[i+12 : i+16]), + LSChecksum: binary.BigEndian.Uint16(data[i+16 : i+18]), + Length: binary.BigEndian.Uint16(data[i+18 : i+20]), + } + lsas = append(lsas, lsa) + } + ospf.Content = DbDescPkg{ + InterfaceMTU: binary.BigEndian.Uint16(data[24:26]), + Options: uint32(data[26]), + Flags: uint16(data[27]), + DDSeqNumber: binary.BigEndian.Uint32(data[28:32]), + LSAinfo: lsas, + } + case OSPFLinkStateRequest: + var lsrs []LSReq + for i := 24; uint16(i+12) <= ospf.PacketLength; i += 12 { + lsr := LSReq{ + LSType: binary.BigEndian.Uint16(data[i+2 : i+4]), + LSID: binary.BigEndian.Uint32(data[i+4 : i+8]), + AdvRouter: binary.BigEndian.Uint32(data[i+8 : i+12]), + } + lsrs = append(lsrs, lsr) + } + ospf.Content = lsrs + case OSPFLinkStateUpdate: + num := binary.BigEndian.Uint32(data[24:28]) + + lsas, err := getLSAsv2(num, data[28:]) + if err != nil { + return fmt.Errorf("Cannot parse Link State Update packet: %v", err) + } + ospf.Content = LSUpdate{ + NumOfLSAs: num, + LSAs: lsas, + } + case OSPFLinkStateAcknowledgment: + var lsas []LSAheader + for i := 24; uint16(i+20) <= ospf.PacketLength; i += 20 { + lsa := LSAheader{ + LSAge: binary.BigEndian.Uint16(data[i : i+2]), + LSOptions: data[i+2], + LSType: uint16(data[i+3]), + LinkStateID: binary.BigEndian.Uint32(data[i+4 : i+8]), + AdvRouter: binary.BigEndian.Uint32(data[i+8 : i+12]), + LSSeqNumber: binary.BigEndian.Uint32(data[i+12 : i+16]), + LSChecksum: binary.BigEndian.Uint16(data[i+16 : i+18]), + Length: binary.BigEndian.Uint16(data[i+18 : i+20]), + } + lsas = append(lsas, lsa) + } + ospf.Content = lsas + } + return nil +} + +// DecodeFromBytes decodes the given bytes into the OSPF layer. +func (ospf *OSPFv3) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + + if len(data) < 16 { + return fmt.Errorf("Packet too smal for OSPF Version 3") + } + + ospf.Version = uint8(data[0]) + ospf.Type = OSPFType(data[1]) + ospf.PacketLength = binary.BigEndian.Uint16(data[2:4]) + ospf.RouterID = binary.BigEndian.Uint32(data[4:8]) + ospf.AreaID = binary.BigEndian.Uint32(data[8:12]) + ospf.Checksum = binary.BigEndian.Uint16(data[12:14]) + ospf.Instance = uint8(data[14]) + ospf.Reserved = uint8(data[15]) + + switch ospf.Type { + case OSPFHello: + var neighbors []uint32 + for i := 36; uint16(i+4) <= ospf.PacketLength; i += 4 { + neighbors = append(neighbors, binary.BigEndian.Uint32(data[i:i+4])) + } + ospf.Content = HelloPkg{ + InterfaceID: binary.BigEndian.Uint32(data[16:20]), + RtrPriority: uint8(data[20]), + Options: binary.BigEndian.Uint32(data[21:25]) >> 8, + HelloInterval: binary.BigEndian.Uint16(data[24:26]), + RouterDeadInterval: uint32(binary.BigEndian.Uint16(data[26:28])), + DesignatedRouterID: binary.BigEndian.Uint32(data[28:32]), + BackupDesignatedRouterID: binary.BigEndian.Uint32(data[32:36]), + NeighborID: neighbors, + } + case OSPFDatabaseDescription: + var lsas []LSAheader + for i := 28; uint16(i+20) <= ospf.PacketLength; i += 20 { + lsa := LSAheader{ + LSAge: binary.BigEndian.Uint16(data[i : i+2]), + LSType: binary.BigEndian.Uint16(data[i+2 : i+4]), + LinkStateID: binary.BigEndian.Uint32(data[i+4 : i+8]), + AdvRouter: binary.BigEndian.Uint32(data[i+8 : i+12]), + LSSeqNumber: binary.BigEndian.Uint32(data[i+12 : i+16]), + LSChecksum: binary.BigEndian.Uint16(data[i+16 : i+18]), + Length: binary.BigEndian.Uint16(data[i+18 : i+20]), + } + lsas = append(lsas, lsa) + } + ospf.Content = DbDescPkg{ + Options: binary.BigEndian.Uint32(data[16:20]) & 0x00FFFFFF, + InterfaceMTU: binary.BigEndian.Uint16(data[20:22]), + Flags: binary.BigEndian.Uint16(data[22:24]), + DDSeqNumber: binary.BigEndian.Uint32(data[24:28]), + LSAinfo: lsas, + } + case OSPFLinkStateRequest: + var lsrs []LSReq + for i := 16; uint16(i+12) <= ospf.PacketLength; i += 12 { + lsr := LSReq{ + LSType: binary.BigEndian.Uint16(data[i+2 : i+4]), + LSID: binary.BigEndian.Uint32(data[i+4 : i+8]), + AdvRouter: binary.BigEndian.Uint32(data[i+8 : i+12]), + } + lsrs = append(lsrs, lsr) + } + ospf.Content = lsrs + case OSPFLinkStateUpdate: + num := binary.BigEndian.Uint32(data[16:20]) + lsas, err := getLSAs(num, data[20:]) + if err != nil { + return fmt.Errorf("Cannot parse Link State Update packet: %v", err) + } + ospf.Content = LSUpdate{ + NumOfLSAs: num, + LSAs: lsas, + } + + case OSPFLinkStateAcknowledgment: + var lsas []LSAheader + for i := 16; uint16(i+20) <= ospf.PacketLength; i += 20 { + lsa := LSAheader{ + LSAge: binary.BigEndian.Uint16(data[i : i+2]), + LSType: binary.BigEndian.Uint16(data[i+2 : i+4]), + LinkStateID: binary.BigEndian.Uint32(data[i+4 : i+8]), + AdvRouter: binary.BigEndian.Uint32(data[i+8 : i+12]), + LSSeqNumber: binary.BigEndian.Uint32(data[i+12 : i+16]), + LSChecksum: binary.BigEndian.Uint16(data[i+16 : i+18]), + Length: binary.BigEndian.Uint16(data[i+18 : i+20]), + } + lsas = append(lsas, lsa) + } + ospf.Content = lsas + default: + } + + return nil +} + +// LayerType returns LayerTypeOSPF +func (ospf *OSPFv2) LayerType() gopacket.LayerType { + return LayerTypeOSPF +} +func (ospf *OSPFv3) LayerType() gopacket.LayerType { + return LayerTypeOSPF +} + +// NextLayerType returns the layer type contained by this DecodingLayer. +func (ospf *OSPFv2) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypeZero +} +func (ospf *OSPFv3) NextLayerType() gopacket.LayerType { + return gopacket.LayerTypeZero +} + +// CanDecode returns the set of layer types that this DecodingLayer can decode. +func (ospf *OSPFv2) CanDecode() gopacket.LayerClass { + return LayerTypeOSPF +} +func (ospf *OSPFv3) CanDecode() gopacket.LayerClass { + return LayerTypeOSPF +} + +func decodeOSPF(data []byte, p gopacket.PacketBuilder) error { + if len(data) < 14 { + return fmt.Errorf("Packet too smal for OSPF") + } + + switch uint8(data[0]) { + case 2: + ospf := &OSPFv2{} + return decodingLayerDecoder(ospf, data, p) + case 3: + ospf := &OSPFv3{} + return decodingLayerDecoder(ospf, data, p) + default: + } + + return fmt.Errorf("Unable to determine OSPF type.") +} diff --git a/vendor/github.com/google/gopacket/layers/ports.go b/vendor/github.com/google/gopacket/layers/ports.go index e9dd5e1e..71dce7a7 100644 --- a/vendor/github.com/google/gopacket/layers/ports.go +++ b/vendor/github.com/google/gopacket/layers/ports.go @@ -98,8 +98,13 @@ var udpPortLayerType = [65536]gopacket.LayerType{ 4789: LayerTypeVXLAN, 67: LayerTypeDHCPv4, 68: LayerTypeDHCPv4, + 546: LayerTypeDHCPv6, + 547: LayerTypeDHCPv6, + 5060: LayerTypeSIP, 6343: LayerTypeSFlow, 6081: LayerTypeGeneve, + 3784: LayerTypeBFD, + 2152: LayerTypeGTPv1U, } // RegisterUDPPortLayerType creates a new mapping between a UDPPort diff --git a/vendor/github.com/google/gopacket/layers/radiotap.go b/vendor/github.com/google/gopacket/layers/radiotap.go index 4304e753..17c61335 100644 --- a/vendor/github.com/google/gopacket/layers/radiotap.go +++ b/vendor/github.com/google/gopacket/layers/radiotap.go @@ -859,12 +859,36 @@ func (m *RadioTap) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) erro } payload := data[m.Length:] - if !m.Flags.FCS() { // Dot11.DecodeFromBytes() expects FCS present - fcs := make([]byte, 4) + + // Remove non standard padding used by some Wi-Fi drivers + if m.Flags.Datapad() && + payload[0]&0xC == 0x8 { //&& // Data frame + headlen := 24 + if payload[0]&0x8C == 0x88 { // QoS + headlen += 2 + } + if payload[1]&0x3 == 0x3 { // 4 addresses + headlen += 2 + } + if headlen%4 == 2 { + payload = append(payload[:headlen], payload[headlen+2:len(payload)]...) + } + } + + if !m.Flags.FCS() { + // Dot11.DecodeFromBytes() expects FCS present and performs a hard chop on the checksum + // If a user is handing in subslices or packets from a buffered stream, the capacity of the slice + // may extend beyond the len, rather than expecting callers to enforce cap==len on every packet + // we take the hit in this one case and do a reallocation. If the user DOES enforce cap==len + // then the reallocation will happen anyway on the append. This is requried because the append + // write to the memory directly after the payload if there is sufficient capacity, which callers + // may not expect. + reallocPayload := make([]byte, len(payload)+4) + copy(reallocPayload[0:len(payload)], payload) h := crc32.NewIEEE() h.Write(payload) - binary.LittleEndian.PutUint32(fcs, h.Sum32()) - payload = append(payload, fcs...) + binary.LittleEndian.PutUint32(reallocPayload[len(payload):], h.Sum32()) + payload = reallocPayload } m.BaseLayer = BaseLayer{Contents: data[:m.Length], Payload: payload} diff --git a/vendor/github.com/google/gopacket/layers/sip.go b/vendor/github.com/google/gopacket/layers/sip.go new file mode 100644 index 00000000..abe2de03 --- /dev/null +++ b/vendor/github.com/google/gopacket/layers/sip.go @@ -0,0 +1,531 @@ +// Copyright 2017 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" + "fmt" + "io" + "strconv" + "strings" + + "github.com/google/gopacket" +) + +// SIPVersion defines the different versions of the SIP Protocol +type SIPVersion uint8 + +// Represents all the versions of SIP protocol +const ( + SIPVersion1 SIPVersion = 1 + SIPVersion2 SIPVersion = 2 +) + +func (sv SIPVersion) String() string { + switch sv { + default: + // Defaulting to SIP/2.0 + return "SIP/2.0" + case SIPVersion1: + return "SIP/1.0" + case SIPVersion2: + return "SIP/2.0" + } +} + +// GetSIPVersion is used to get SIP version constant +func GetSIPVersion(version string) (SIPVersion, error) { + switch strings.ToUpper(version) { + case "SIP/1.0": + return SIPVersion1, nil + case "SIP/2.0": + return SIPVersion2, nil + default: + return 0, fmt.Errorf("Unknown SIP version: '%s'", version) + + } +} + +// SIPMethod defines the different methods of the SIP Protocol +// defined in the different RFC's +type SIPMethod uint16 + +// Here are all the SIP methods +const ( + SIPMethodInvite SIPMethod = 1 // INVITE [RFC3261] + SIPMethodAck SIPMethod = 2 // ACK [RFC3261] + SIPMethodBye SIPMethod = 3 // BYE [RFC3261] + SIPMethodCancel SIPMethod = 4 // CANCEL [RFC3261] + SIPMethodOptions SIPMethod = 5 // OPTIONS [RFC3261] + SIPMethodRegister SIPMethod = 6 // REGISTER [RFC3261] + SIPMethodPrack SIPMethod = 7 // PRACK [RFC3262] + SIPMethodSubscribe SIPMethod = 8 // SUBSCRIBE [RFC6665] + SIPMethodNotify SIPMethod = 9 // NOTIFY [RFC6665] + SIPMethodPublish SIPMethod = 10 // PUBLISH [RFC3903] + SIPMethodInfo SIPMethod = 11 // INFO [RFC6086] + SIPMethodRefer SIPMethod = 12 // REFER [RFC3515] + SIPMethodMessage SIPMethod = 13 // MESSAGE [RFC3428] + SIPMethodUpdate SIPMethod = 14 // UPDATE [RFC3311] + SIPMethodPing SIPMethod = 15 // PING [https://tools.ietf.org/html/draft-fwmiller-ping-03] +) + +func (sm SIPMethod) String() string { + switch sm { + default: + return "Unknown method" + case SIPMethodInvite: + return "INVITE" + case SIPMethodAck: + return "ACK" + case SIPMethodBye: + return "BYE" + case SIPMethodCancel: + return "CANCEL" + case SIPMethodOptions: + return "OPTIONS" + case SIPMethodRegister: + return "REGISTER" + case SIPMethodPrack: + return "PRACK" + case SIPMethodSubscribe: + return "SUBSCRIBE" + case SIPMethodNotify: + return "NOTIFY" + case SIPMethodPublish: + return "PUBLISH" + case SIPMethodInfo: + return "INFO" + case SIPMethodRefer: + return "REFER" + case SIPMethodMessage: + return "MESSAGE" + case SIPMethodUpdate: + return "UPDATE" + case SIPMethodPing: + return "PING" + } +} + +// GetSIPMethod returns the constant of a SIP method +// from its string +func GetSIPMethod(method string) (SIPMethod, error) { + switch strings.ToUpper(method) { + case "INVITE": + return SIPMethodInvite, nil + case "ACK": + return SIPMethodAck, nil + case "BYE": + return SIPMethodBye, nil + case "CANCEL": + return SIPMethodCancel, nil + case "OPTIONS": + return SIPMethodOptions, nil + case "REGISTER": + return SIPMethodRegister, nil + case "PRACK": + return SIPMethodPrack, nil + case "SUBSCRIBE": + return SIPMethodSubscribe, nil + case "NOTIFY": + return SIPMethodNotify, nil + case "PUBLISH": + return SIPMethodPublish, nil + case "INFO": + return SIPMethodInfo, nil + case "REFER": + return SIPMethodRefer, nil + case "MESSAGE": + return SIPMethodMessage, nil + case "UPDATE": + return SIPMethodUpdate, nil + case "PING": + return SIPMethodPing, nil + default: + return 0, fmt.Errorf("Unknown SIP method: '%s'", method) + } +} + +// Here is a correspondance between long header names and short +// as defined in rfc3261 in section 20 +var compactSipHeadersCorrespondance = map[string]string{ + "accept-contact": "a", + "allow-events": "u", + "call-id": "i", + "contact": "m", + "content-encoding": "e", + "content-length": "l", + "content-type": "c", + "event": "o", + "from": "f", + "identity": "y", + "refer-to": "r", + "referred-by": "b", + "reject-contact": "j", + "request-disposition": "d", + "session-expires": "x", + "subject": "s", + "supported": "k", + "to": "t", + "via": "v", +} + +// SIP object will contains information about decoded SIP packet. +// -> The SIP Version +// -> The SIP Headers (in a map[string][]string because of multiple headers with the same name +// -> The SIP Method +// -> The SIP Response code (if it's a response) +// -> The SIP Status line (if it's a response) +// You can easily know the type of the packet with the IsResponse boolean +// +type SIP struct { + BaseLayer + + // Base information + Version SIPVersion + Method SIPMethod + Headers map[string][]string + + // Response + IsResponse bool + ResponseCode int + ResponseStatus string + + // Private fields + cseq int64 + contentLength int64 + lastHeaderParsed string +} + +// decodeSIP decodes the byte slice into a SIP type. It also +// setups the application Layer in PacketBuilder. +func decodeSIP(data []byte, p gopacket.PacketBuilder) error { + s := NewSIP() + err := s.DecodeFromBytes(data, p) + if err != nil { + return err + } + p.AddLayer(s) + p.SetApplicationLayer(s) + return nil +} + +// NewSIP instantiates a new empty SIP object +func NewSIP() *SIP { + s := new(SIP) + s.Headers = make(map[string][]string) + return s +} + +// LayerType returns gopacket.LayerTypeSIP. +func (s *SIP) LayerType() gopacket.LayerType { + return LayerTypeSIP +} + +// Payload returns the base layer payload +func (s *SIP) Payload() []byte { + return s.BaseLayer.Payload +} + +// DecodeFromBytes decodes the slice into the SIP struct. +func (s *SIP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { + + // Init some vars for parsing follow-up + var countLines int + var line []byte + var err error + + // Clean leading new line + data = bytes.Trim(data, "\n") + + // Iterate on all lines of the SIP Headers + // and stop when we reach the SDP (aka when the new line + // is at index 0 of the remaining packet) + buffer := bytes.NewBuffer(data) + + for { + + // Read next line + line, err = buffer.ReadBytes(byte('\n')) + if err != nil { + if err == io.EOF { + break + } else { + return err + } + } + + // Trim the new line delimiters + line = bytes.Trim(line, "\r\n") + + // Empty line, we hit Body + // Putting packet remain in Paypload + if len(line) == 0 { + s.BaseLayer.Payload = buffer.Bytes() + break + } + + // First line is the SIP request/response line + // Other lines are headers + if countLines == 0 { + err = s.ParseFirstLine(line) + if err != nil { + return err + } + + } else { + err = s.ParseHeader(line) + if err != nil { + return err + } + } + + countLines++ + } + + return nil +} + +// ParseFirstLine will compute the first line of a SIP packet. +// The first line will tell us if it's a request or a response. +// +// Examples of first line of SIP Prococol : +// +// Request : INVITE bob@example.com SIP/2.0 +// Response : SIP/2.0 200 OK +// Response : SIP/2.0 501 Not Implemented +// +func (s *SIP) ParseFirstLine(firstLine []byte) error { + + var err error + + // Splits line by space + splits := strings.SplitN(string(firstLine), " ", 3) + + // We must have at least 3 parts + if len(splits) < 3 { + return fmt.Errorf("invalid first SIP line: '%s'", string(firstLine)) + } + + // Determine the SIP packet type + if strings.HasPrefix(splits[0], "SIP") { + + // --> Response + s.IsResponse = true + + // Validate SIP Version + s.Version, err = GetSIPVersion(splits[0]) + if err != nil { + return err + } + + // Compute code + s.ResponseCode, err = strconv.Atoi(splits[1]) + if err != nil { + return err + } + + // Compute status line + s.ResponseStatus = splits[2] + + } else { + + // --> Request + + // Validate method + s.Method, err = GetSIPMethod(splits[0]) + if err != nil { + return err + } + + // Validate SIP Version + s.Version, err = GetSIPVersion(splits[2]) + if err != nil { + return err + } + } + + return nil +} + +// ParseHeader will parse a SIP Header +// SIP Headers are quite simple, there are colon separated name and value +// Headers can be spread over multiple lines +// +// Examples of header : +// +// CSeq: 1 REGISTER +// Via: SIP/2.0/UDP there.com:5060 +// Authorization:Digest username="UserB", +// realm="MCI WorldCom SIP", +// nonce="1cec4341ae6cbe5a359ea9c8e88df84f", opaque="", +// uri="sip:ss2.wcom.com", response="71ba27c64bd01de719686aa4590d5824" +// +func (s *SIP) ParseHeader(header []byte) (err error) { + + // Ignore empty headers + if len(header) == 0 { + return + } + + // Check if this is the following of last header + // RFC 3261 - 7.3.1 - Header Field Format specify that following lines of + // multiline headers must begin by SP or TAB + if header[0] == '\t' || header[0] == ' ' { + + header = bytes.TrimSpace(header) + s.Headers[s.lastHeaderParsed][len(s.Headers[s.lastHeaderParsed])-1] += fmt.Sprintf(" %s", string(header)) + return + } + + // Find the ':' to separate header name and value + index := bytes.Index(header, []byte(":")) + if index >= 0 { + + headerName := strings.ToLower(string(bytes.Trim(header[:index], " "))) + headerValue := string(bytes.Trim(header[index+1:], " ")) + + // Add header to object + s.Headers[headerName] = append(s.Headers[headerName], headerValue) + s.lastHeaderParsed = headerName + + // Compute specific headers + err = s.ParseSpecificHeaders(headerName, headerValue) + if err != nil { + return err + } + } + + return nil +} + +// ParseSpecificHeaders will parse some specific key values from +// specific headers like CSeq or Content-Length integer values +func (s *SIP) ParseSpecificHeaders(headerName string, headerValue string) (err error) { + + switch headerName { + case "cseq": + + // CSeq header value is formatted like that : + // CSeq: 123 INVITE + // We split the value to parse Cseq integer value, and method + splits := strings.Split(headerValue, " ") + if len(splits) > 1 { + + // Parse Cseq + s.cseq, err = strconv.ParseInt(splits[0], 10, 64) + if err != nil { + return err + } + + // Validate method + if s.IsResponse { + s.Method, err = GetSIPMethod(splits[1]) + if err != nil { + return err + } + } + } + + case "content-length": + + // Parse Content-Length + s.contentLength, err = strconv.ParseInt(headerValue, 10, 64) + if err != nil { + return err + } + } + + return nil +} + +// GetAllHeaders will return the full headers of the +// current SIP packets in a map[string][]string +func (s *SIP) GetAllHeaders() map[string][]string { + return s.Headers +} + +// GetHeader will return all the headers with +// the specified name. +func (s *SIP) GetHeader(headerName string) []string { + headerName = strings.ToLower(headerName) + h := make([]string, 0) + if _, ok := s.Headers[headerName]; ok { + if len(s.Headers[headerName]) > 0 { + return s.Headers[headerName] + } else if len(s.Headers[compactSipHeadersCorrespondance[headerName]]) > 0 { + return s.Headers[compactSipHeadersCorrespondance[headerName]] + } + } + return h +} + +// GetFirstHeader will return the first header with +// the specified name. If the current SIP packet has multiple +// headers with the same name, it returns the first. +func (s *SIP) GetFirstHeader(headerName string) string { + headerName = strings.ToLower(headerName) + if _, ok := s.Headers[headerName]; ok { + if len(s.Headers[headerName]) > 0 { + return s.Headers[headerName][0] + } else if len(s.Headers[compactSipHeadersCorrespondance[headerName]]) > 0 { + return s.Headers[compactSipHeadersCorrespondance[headerName]][0] + } + } + return "" +} + +// +// Some handy getters for most used SIP headers +// + +// GetAuthorization will return the Authorization +// header of the current SIP packet +func (s *SIP) GetAuthorization() string { + return s.GetFirstHeader("Authorization") +} + +// GetFrom will return the From +// header of the current SIP packet +func (s *SIP) GetFrom() string { + return s.GetFirstHeader("From") +} + +// GetTo will return the To +// header of the current SIP packet +func (s *SIP) GetTo() string { + return s.GetFirstHeader("To") +} + +// GetContact will return the Contact +// header of the current SIP packet +func (s *SIP) GetContact() string { + return s.GetFirstHeader("Contact") +} + +// GetCallID will return the Call-ID +// header of the current SIP packet +func (s *SIP) GetCallID() string { + return s.GetFirstHeader("Call-ID") +} + +// GetUserAgent will return the User-Agent +// header of the current SIP packet +func (s *SIP) GetUserAgent() string { + return s.GetFirstHeader("User-Agent") +} + +// GetContentLength will return the parsed integer +// Content-Length header of the current SIP packet +func (s *SIP) GetContentLength() int64 { + return s.contentLength +} + +// GetCSeq will return the parsed integer CSeq header +// header of the current SIP packet +func (s *SIP) GetCSeq() int64 { + return s.cseq +} diff --git a/vendor/github.com/google/gopacket/layers/tcp.go b/vendor/github.com/google/gopacket/layers/tcp.go index fb731da1..797e517a 100644 --- a/vendor/github.com/google/gopacket/layers/tcp.go +++ b/vendor/github.com/google/gopacket/layers/tcp.go @@ -244,7 +244,12 @@ func (tcp *TCP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { 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.Options == nil { + // Pre-allocate to avoid allocating a slice. + tcp.Options = tcp.opts[:0] + } else { + tcp.Options = tcp.Options[:0] + } if tcp.DataOffset < 5 { return fmt.Errorf("Invalid TCP data offset %d < 5", tcp.DataOffset) } @@ -260,10 +265,6 @@ func (tcp *TCP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { // 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 { diff --git a/vendor/github.com/google/gopacket/layers/udp.go b/vendor/github.com/google/gopacket/layers/udp.go index 20f8c50f..4c88ecbc 100644 --- a/vendor/github.com/google/gopacket/layers/udp.go +++ b/vendor/github.com/google/gopacket/layers/udp.go @@ -118,3 +118,11 @@ func decodeUDP(data []byte, p gopacket.PacketBuilder) error { func (u *UDP) TransportFlow() gopacket.Flow { return gopacket.NewFlow(EndpointUDPPort, u.sPort, u.dPort) } + +// For testing only +func (u *UDP) SetInternalPortsForTesting() { + u.sPort = make([]byte, 2) + u.dPort = make([]byte, 2) + binary.BigEndian.PutUint16(u.sPort, uint16(u.SrcPort)) + binary.BigEndian.PutUint16(u.dPort, uint16(u.DstPort)) +} diff --git a/vendor/github.com/google/gopacket/layers/usb.go b/vendor/github.com/google/gopacket/layers/usb.go index d4f483cf..0b4d4af0 100644 --- a/vendor/github.com/google/gopacket/layers/usb.go +++ b/vendor/github.com/google/gopacket/layers/usb.go @@ -81,27 +81,6 @@ const ( 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 ( diff --git a/vendor/github.com/google/gopacket/layers/vxlan.go b/vendor/github.com/google/gopacket/layers/vxlan.go index 08f1ecb4..4f79ea4e 100644 --- a/vendor/github.com/google/gopacket/layers/vxlan.go +++ b/vendor/github.com/google/gopacket/layers/vxlan.go @@ -72,6 +72,10 @@ func (vx *VXLAN) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.Serialize return err } + // PrependBytes does not guarantee that bytes are zeroed. Setting flags via OR requires that they start off at zero + bytes[0] = 0 + bytes[1] = 0 + if vx.ValidIDFlag { bytes[0] |= 0x08 } diff --git a/vendor/github.com/google/gopacket/packet.go b/vendor/github.com/google/gopacket/packet.go index 76b62d8a..08bd9137 100644 --- a/vendor/github.com/google/gopacket/packet.go +++ b/vendor/github.com/google/gopacket/packet.go @@ -31,6 +31,10 @@ type CaptureInfo struct { Length int // InterfaceIndex InterfaceIndex int + // The packet source can place ancillary data of various types here. + // For example, the afpacket source can report the VLAN of captured + // packets this way. + AncillaryData []interface{} } // PacketMetadata contains metadata for a packet. diff --git a/vendor/github.com/google/gopacket/parser.go b/vendor/github.com/google/gopacket/parser.go index f786834e..760613fa 100644 --- a/vendor/github.com/google/gopacket/parser.go +++ b/vendor/github.com/google/gopacket/parser.go @@ -158,6 +158,9 @@ func (l *DecodingLayerParser) DecodeLayers(data []byte, decoded *[]LayerType) (e for len(data) > 0 { decoder, ok := l.decoders[typ] if !ok { + if l.IgnoreUnsupported { + return nil + } return UnsupportedLayerType(typ) } else if err = decoder.DecodeFromBytes(data, l.df); err != nil { return err @@ -195,4 +198,10 @@ type DecodingLayerParserOptions struct { // callers. IgnorePanic defaults to false, thus if the caller does // nothing decode panics will be returned as errors. IgnorePanic bool + // IgnoreUnsupported will stop parsing and return a nil error when it + // encounters a layer it doesn't have a parser for, instead of returning an + // UnsupportedLayerType error. If this is true, it's up to the caller to make + // sure that all expected layers have been parsed (by checking the decoded + // slice). + IgnoreUnsupported bool } diff --git a/vendor/github.com/google/gopacket/pcap/pcap.go b/vendor/github.com/google/gopacket/pcap/pcap.go index 1ecdf035..f6202fe5 100644 --- a/vendor/github.com/google/gopacket/pcap/pcap.go +++ b/vendor/github.com/google/gopacket/pcap/pcap.go @@ -20,6 +20,7 @@ package pcap #cgo windows,amd64 LDFLAGS: -L C:/WpdPack/Lib/x64 -lwpcap #include #include +#include // Some old versions of pcap don't define this constant. #ifndef PCAP_NETMASK_UNKNOWN @@ -83,6 +84,9 @@ int pcap_set_rfmon(pcap_t *p, int rfmon) { #elif __APPLE__ #define gopacket_time_secs_t __darwin_time_t #define gopacket_time_usecs_t __darwin_suseconds_t +#elif __ANDROID__ +#define gopacket_time_secs_t __kernel_time_t +#define gopacket_time_usecs_t __kernel_suseconds_t #elif __GLIBC__ #define gopacket_time_secs_t __time_t #define gopacket_time_usecs_t __suseconds_t @@ -96,6 +100,18 @@ int pcap_set_rfmon(pcap_t *p, int rfmon) { #define gopacket_time_usecs_t suseconds_t #endif #endif + +// The things we do to avoid pointers escaping to the heap... +// According to https://github.com/the-tcpdump-group/libpcap/blob/1131a7c26c6f4d4772e4a2beeaf7212f4dea74ac/pcap.c#L398-L406 , +// the return value of pcap_next_ex could be greater than 1 for success. +// Let's just make it 1 if it comes bigger than 1. +int pcap_next_ex_escaping(pcap_t *p, uintptr_t pkt_hdr, uintptr_t pkt_data) { + int ex = pcap_next_ex(p, (struct pcap_pkthdr**)(pkt_hdr), (const u_char**)(pkt_data)); + if (ex > 1) { + ex = 1; + } + return ex; +} */ import "C" @@ -104,6 +120,7 @@ import ( "fmt" "io" "net" + "os" "reflect" "runtime" "strconv" @@ -119,6 +136,9 @@ import ( const errorBufferSize = 256 +// ErrNotActive is returned if handle is not activated +const ErrNotActive = int(C.PCAP_ERROR_NOT_ACTIVATED) + // MaxBpfInstructions is the maximum number of BPF instructions supported (BPF_MAXINSNS), // taken from Linux kernel: include/uapi/linux/bpf_common.h // @@ -165,8 +185,8 @@ type Stats struct { type Interface struct { Name string Description string + Flags uint32 Addresses []InterfaceAddress - // TODO: add more elements } // Datalink describes the datalink @@ -178,9 +198,10 @@ type Datalink struct { // InterfaceAddress describes an address associated with an Interface. // Currently, it's IPv4/6 specific. type InterfaceAddress struct { - IP net.IP - Netmask net.IPMask // Netmask may be nil if we were unable to retrieve it. - // TODO: add broadcast + PtP dst ? + IP net.IP + Netmask net.IPMask // Netmask may be nil if we were unable to retrieve it. + Broadaddr net.IP // Broadcast address for this IP may be nil + P2P net.IP // P2P destination address for this IP may be nil } // BPF is a compiled filter program, useful for offline packet matching. @@ -247,9 +268,14 @@ func OpenLive(device string, snaplen int32, promisc bool, timeout time.Duration) return nil, errors.New(C.GoString(buf)) } - if err := p.openLive(); err != nil { - C.pcap_close(p.cptr) - return nil, err + // Only set the PCAP handle into non-blocking mode if we have a timeout + // greater than zero. If the user wants to block forever, we'll let libpcap + // handle that. + if p.timeout > 0 { + if err := p.setNonBlocking(); err != nil { + C.pcap_close(p.cptr) + return nil, err + } } return p, nil @@ -266,7 +292,13 @@ func OpenOffline(file string) (handle *Handle, err error) { if cptr == nil { return nil, errors.New(C.GoString(buf)) } - return &Handle{cptr: cptr}, nil + h := &Handle{cptr: cptr} + return h, nil +} + +// OpenOfflineFile returns contents of input file as a *Handle. +func OpenOfflineFile(file *os.File) (handle *Handle, err error) { + return openOfflineFile(file) } // NextError is the return code from a call to Next. @@ -325,6 +357,7 @@ const ( aeNoSuchDevice = C.PCAP_ERROR_NO_SUCH_DEVICE aeDenied = C.PCAP_ERROR_PERM_DENIED aeNotUp = C.PCAP_ERROR_IFACE_NOT_UP + aeWarning = C.PCAP_WARNING ) func (a activateError) Error() string { @@ -341,6 +374,8 @@ func (a activateError) Error() string { return "Permission Denied" case aeNotUp: return "Interface Not Up" + case aeWarning: + return fmt.Sprintf("Warning: %v", activateErrMsg.Error()) default: return fmt.Sprintf("unknown activated error: %d", a) } @@ -353,9 +388,19 @@ func (p *Handle) getNextBufPtrLocked(ci *gopacket.CaptureInfo) error { return io.EOF } + // This horrible magic allows us to pass a ptr-to-ptr to pcap_next_ex + // without causing that ptr-to-ptr to itself be allocated on the heap. + // Since Handle itself survives through the duration of the pcap_next_ex + // call, this should be perfectly safe for GC stuff, etc. + pp := C.uintptr_t(uintptr(unsafe.Pointer(&p.pkthdr))) + bp := C.uintptr_t(uintptr(unsafe.Pointer(&p.bufptr))) + + // set after we have call waitForPacket for the first time + var waited bool + for atomic.LoadUint64(&p.stop) == 0 { // try to read a packet if one is immediately available - result := NextError(C.pcap_next_ex(p.cptr, &p.pkthdr, &p.bufptr)) + result := NextError(C.pcap_next_ex_escaping(p.cptr, pp, bp)) switch result { case NextErrorOk: @@ -374,13 +419,18 @@ func (p *Handle) getNextBufPtrLocked(ci *gopacket.CaptureInfo) error { // no more packets, return EOF rather than libpcap-specific error return io.EOF case NextErrorTimeoutExpired: - // Negative timeout means to loop forever, instead of actually returning - // the timeout error. - if p.timeout < 0 { - // must have had a timeout... wait before trying again - p.waitForPacket() - continue + // we've already waited for a packet and we're supposed to time out + // + // we should never actually hit this if we were passed BlockForever + // since we should block on C.pcap_next_ex until there's a packet + // to read. + if waited && p.timeout > 0 { + return result } + + // wait for packet before trying again + p.waitForPacket() + waited = true default: return result } @@ -652,6 +702,28 @@ func (p *Handle) NewBPF(expr string) (*BPF, error) { return bpf, nil } +// NewBPF allows to create a BPF without requiring an existing handle. +// This allows to match packets obtained from a-non GoPacket capture source +// to be matched. +// +// buf := make([]byte, MaxFrameSize) +// bpfi, _ := pcap.NewBPF(layers.LinkTypeEthernet, MaxFrameSize, "icmp") +// n, _ := someIO.Read(buf) +// ci := gopacket.CaptureInfo{CaptureLength: n, Length: n} +// if bpfi.Matches(ci, buf) { +// doSomething() +// } +func NewBPF(linkType layers.LinkType, captureLength int, expr string) (*BPF, error) { + cptr := C.pcap_open_dead(C.int(linkType), C.int(captureLength)) + if cptr == nil { + return nil, errors.New("error opening dead capture") + } + + h := Handle{cptr: cptr} + defer h.Close() + return h.NewBPF(expr) +} + // NewBPFInstructionFilter sets the given BPFInstructions as new filter program. // // More details see func SetBPFInstructionFilter @@ -708,6 +780,23 @@ func (p *Handle) SetLinkType(dlt layers.LinkType) error { return nil } +// DatalinkValToName returns pcap_datalink_val_to_name as string +func DatalinkValToName(dlt int) string { + return C.GoString(C.pcap_datalink_val_to_name(C.int(dlt))) +} + +// DatalinkValToDescription returns pcap_datalink_val_to_description as string +func DatalinkValToDescription(dlt int) string { + return C.GoString(C.pcap_datalink_val_to_description(C.int(dlt))) +} + +// DatalinkNameToVal returns pcap_datalink_name_to_val as int +func DatalinkNameToVal(name string) C.int { + cptr := C.CString(name) + defer C.free(unsafe.Pointer(cptr)) + return C.int(C.pcap_datalink_name_to_val(cptr)) +} + // FindAllDevs attempts to enumerate all interfaces on the current machine. func FindAllDevs() (ifs []Interface, err error) { var buf *C.char @@ -731,7 +820,7 @@ func FindAllDevs() (ifs []Interface, err error) { iface.Name = C.GoString(dev.name) iface.Description = C.GoString(dev.description) iface.Addresses = findalladdresses(dev.addresses) - // TODO: add more elements + iface.Flags = uint32(dev.flags) ifs[j] = iface j++ } @@ -762,12 +851,22 @@ func findalladdresses(addresses *_Ctype_struct_pcap_addr) (retval []InterfaceAdd // address. a.Netmask = nil } + if a.Broadaddr, err = sockaddrToIP((*syscall.RawSockaddr)(unsafe.Pointer(curaddr.broadaddr))); err != nil { + a.Broadaddr = nil + } + if a.P2P, err = sockaddrToIP((*syscall.RawSockaddr)(unsafe.Pointer(curaddr.dstaddr))); err != nil { + a.P2P = nil + } retval = append(retval, a) } return } func sockaddrToIP(rsa *syscall.RawSockaddr) (IP []byte, err error) { + if unsafe.Pointer(rsa) == nil { + err = errors.New("Value not set") + return + } switch rsa.Family { case syscall.AF_INET: pp := (*syscall.RawSockaddrInet4)(unsafe.Pointer(rsa)) @@ -817,6 +916,12 @@ func (p *Handle) SetDirection(direction Direction) error { return nil } +// SnapLen returns the snapshot length +func (p *Handle) SnapLen() int { + len := C.pcap_snapshot(p.cptr) + return int(len) +} + // TimestampSource tells PCAP which type of timestamp to use for packets. type TimestampSource C.int @@ -851,11 +956,22 @@ type InactiveHandle struct { timeout time.Duration } +// holds the err messoge in case activation returned a Warning +var activateErrMsg error + +// Error returns the current error associated with a pcap handle (pcap_geterr). +func (p *InactiveHandle) Error() error { + return errors.New(C.GoString(C.pcap_geterr(p.cptr))) +} + // Activate activates the handle. The current InactiveHandle becomes invalid // and all future function calls on it will fail. func (p *InactiveHandle) Activate() (*Handle, error) { err := activateError(C.pcap_activate(p.cptr)) if err != aeNoError { + if err == aeWarning { + activateErrMsg = p.Error() + } return nil, err } h := &Handle{ diff --git a/vendor/github.com/google/gopacket/pcap/pcap_unix.go b/vendor/github.com/google/gopacket/pcap/pcap_unix.go index b2a6dcd6..7aa35cae 100644 --- a/vendor/github.com/google/gopacket/pcap/pcap_unix.go +++ b/vendor/github.com/google/gopacket/pcap/pcap_unix.go @@ -43,10 +43,11 @@ import "C" import ( "errors" + "os" "unsafe" ) -func (p *Handle) openLive() error { +func (p *Handle) setNonBlocking() error { buf := (*C.char)(C.calloc(errorBufferSize, 1)) defer C.free(unsafe.Pointer(buf)) @@ -69,3 +70,18 @@ func (p *Handle) waitForPacket() { C.pcap_wait(p.cptr, usec) } + +// openOfflineFile returns contents of input file as a *Handle. +func openOfflineFile(file *os.File) (handle *Handle, err error) { + buf := (*C.char)(C.calloc(errorBufferSize, 1)) + defer C.free(unsafe.Pointer(buf)) + cmode := C.CString("rb") + defer C.free(unsafe.Pointer(cmode)) + cf := C.fdopen(C.int(file.Fd()), cmode) + + cptr := C.pcap_fopen_offline(cf, buf) + if cptr == nil { + return nil, errors.New(C.GoString(buf)) + } + return &Handle{cptr: cptr}, nil +} diff --git a/vendor/github.com/google/gopacket/pcap/pcap_windows.go b/vendor/github.com/google/gopacket/pcap/pcap_windows.go index e3df1239..ffb01a97 100644 --- a/vendor/github.com/google/gopacket/pcap/pcap_windows.go +++ b/vendor/github.com/google/gopacket/pcap/pcap_windows.go @@ -7,11 +7,19 @@ package pcap +/* +#include +*/ +import "C" + import ( + "errors" + "os" "runtime" + "unsafe" ) -func (p *Handle) openLive() error { +func (p *Handle) setNonBlocking() error { // do nothing return nil } @@ -21,3 +29,16 @@ func (p *Handle) waitForPacket() { // can't use select() so instead just switch goroutines runtime.Gosched() } + +// openOfflineFile returns contents of input file as a *Handle. +func openOfflineFile(file *os.File) (handle *Handle, err error) { + buf := (*C.char)(C.calloc(errorBufferSize, 1)) + defer C.free(unsafe.Pointer(buf)) + cf := C.intptr_t(file.Fd()) + + cptr := C.pcap_hopen_offline(cf, buf) + if cptr == nil { + return nil, errors.New(C.GoString(buf)) + } + return &Handle{cptr: cptr}, nil +} diff --git a/vendor/github.com/google/gopacket/pcap/test_ethernet.pcap b/vendor/github.com/google/gopacket/pcap/test_ethernet.pcap index 1f8a87c3..1d01bd91 100644 Binary files a/vendor/github.com/google/gopacket/pcap/test_ethernet.pcap and b/vendor/github.com/google/gopacket/pcap/test_ethernet.pcap differ diff --git a/vendor/github.com/google/gopacket/pcapgo/capture.go b/vendor/github.com/google/gopacket/pcapgo/capture.go new file mode 100644 index 00000000..870de2c2 --- /dev/null +++ b/vendor/github.com/google/gopacket/pcapgo/capture.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 pcapgo + +import ( + "net" + "syscall" + "time" + + "github.com/google/gopacket" + "github.com/mdlayher/raw" +) + +// EthernetHandle wraps a raw.Conn, implementing gopacket.PacketDataSource so +// that the handle can be used with gopacket.NewPacketSource. +type EthernetHandle struct { + *raw.Conn +} + +// ReadPacketData implements gopacket.PacketDataSource. +func (h *EthernetHandle) ReadPacketData() ([]byte, gopacket.CaptureInfo, error) { + b := make([]byte, 4096) // TODO(correctness): how much space do we need? + n, _, err := h.ReadFrom(b) + if err != nil { + return nil, gopacket.CaptureInfo{}, err + } + data := b[:n] + return data, gopacket.CaptureInfo{ + CaptureLength: len(data), + Length: len(data), + Timestamp: time.Now(), + }, nil +} + +// NewEthernetHandle implements pcap.OpenLive for ethernet interfaces only. +func NewEthernetHandle(ifname string) (*EthernetHandle, error) { + intf, err := net.InterfaceByName(ifname) + if err != nil { + return nil, err + } + + conn, err := raw.ListenPacket(intf, syscall.ETH_P_ALL, nil) + if err != nil { + return nil, err + } + + return &EthernetHandle{conn}, nil +} diff --git a/vendor/github.com/google/gopacket/pcapgo/read.go b/vendor/github.com/google/gopacket/pcapgo/read.go index 5acd06f3..98148b01 100644 --- a/vendor/github.com/google/gopacket/pcapgo/read.go +++ b/vendor/github.com/google/gopacket/pcapgo/read.go @@ -149,6 +149,37 @@ func (r *Reader) Snaplen() uint32 { return r.snaplen } +// SetSnaplen sets the snapshot length of the capture file. +// +// This is useful when a pcap file contains packets bigger than then snaplen. +// Pcapgo will error when reading packets bigger than snaplen, then it dumps those +// packets and reads the next 16 bytes, which are part of the "faulty" packet's payload, but pcapgo +// thinks it's the next header, which is probably also faulty because it's not really a packet header. +// This can lead to a lot of faulty reads. +// +// The SetSnaplen function can be used to set a bigger snaplen to prevent those read errors. +// +// This snaplen situation can happen when a pcap writer doesn't truncate packets to the snaplen size while writing packets to file. +// E.g. In Python, dpkt.pcap.Writer sets snaplen by default to 1500 (https://dpkt.readthedocs.io/en/latest/api/api_auto.html#dpkt.pcap.Writer) +// but doesn't enforce this when writing packets (https://dpkt.readthedocs.io/en/latest/_modules/dpkt/pcap.html#Writer.writepkt). +// When reading, tools like tcpdump, tcpslice, mergecap and wireshark ignore the snaplen and use +// their own defined snaplen. +// E.g. When reading packets, tcpdump defines MAXIMUM_SNAPLEN (https://github.com/the-tcpdump-group/tcpdump/blob/6e80fcdbe9c41366df3fa244ffe4ac8cce2ab597/netdissect.h#L290) +// and uses it (https://github.com/the-tcpdump-group/tcpdump/blob/66384fa15b04b47ad08c063d4728df3b9c1c0677/print.c#L343-L358). +// +// For further reading: +// - https://github.com/the-tcpdump-group/tcpdump/issues/389 +// - https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8808 +// - https://www.wireshark.org/lists/wireshark-dev/201307/msg00061.html +// - https://github.com/wireshark/wireshark/blob/bfd51199e707c1d5c28732be34b44a9ee8a91cd8/wiretap/pcap-common.c#L723-L742 +// - https://github.com/wireshark/wireshark/blob/f07fb6cdfc0904905627707b88450054e921f092/wiretap/libpcap.c#L592-L598 +// - https://github.com/wireshark/wireshark/blob/f07fb6cdfc0904905627707b88450054e921f092/wiretap/libpcap.c#L714-L727 +// - https://github.com/the-tcpdump-group/tcpdump/commit/d033c1bc381c76d13e4aface97a4f4ec8c3beca2 +// - https://github.com/the-tcpdump-group/tcpdump/blob/88e87cb2cb74c5f939792171379acd9e0efd8b9a/netdissect.h#L263-L290 +func (r *Reader) SetSnaplen(newSnaplen uint32) { + r.snaplen = newSnaplen +} + // Reader formater func (r *Reader) String() string { return fmt.Sprintf("PcapFile maj: %x min: %x snaplen: %d linktype: %s", r.versionMajor, r.versionMinor, r.snaplen, r.linkType) diff --git a/vendor/github.com/google/gopacket/pcapgo/write.go b/vendor/github.com/google/gopacket/pcapgo/write.go index bfc312fd..4f9e42ab 100644 --- a/vendor/github.com/google/gopacket/pcapgo/write.go +++ b/vendor/github.com/google/gopacket/pcapgo/write.go @@ -26,6 +26,9 @@ import ( // timestamp resolution and little-endian encoding. type Writer struct { w io.Writer + + // Moving this into the struct seems to save an allocation for each call to writePacketHeader + buf [16]byte } const magicMicroseconds = 0xA1B2C3D4 @@ -71,19 +74,17 @@ func (w *Writer) WriteFileHeader(snaplen uint32, linktype layers.LinkType) error const nanosPerMicro = 1000 func (w *Writer) writePacketHeader(ci gopacket.CaptureInfo) error { - var buf [16]byte - t := ci.Timestamp if t.IsZero() { t = time.Now() } secs := t.Unix() usecs := t.Nanosecond() / nanosPerMicro - binary.LittleEndian.PutUint32(buf[0:4], uint32(secs)) - binary.LittleEndian.PutUint32(buf[4:8], uint32(usecs)) - binary.LittleEndian.PutUint32(buf[8:12], uint32(ci.CaptureLength)) - binary.LittleEndian.PutUint32(buf[12:16], uint32(ci.Length)) - _, err := w.w.Write(buf[:]) + binary.LittleEndian.PutUint32(w.buf[0:4], uint32(secs)) + binary.LittleEndian.PutUint32(w.buf[4:8], uint32(usecs)) + binary.LittleEndian.PutUint32(w.buf[8:12], uint32(ci.CaptureLength)) + binary.LittleEndian.PutUint32(w.buf[12:16], uint32(ci.Length)) + _, err := w.w.Write(w.buf[:]) return err } diff --git a/vendor/github.com/mdlayher/raw/.travis.yml b/vendor/github.com/mdlayher/raw/.travis.yml new file mode 100644 index 00000000..87d017d2 --- /dev/null +++ b/vendor/github.com/mdlayher/raw/.travis.yml @@ -0,0 +1,16 @@ +language: go +go: + - "1.x" +os: + - linux + - osx +before_install: + - go get github.com/golang/lint/golint + - go get honnef.co/go/tools/cmd/staticcheck + - go get -d -t ./... +script: + - go build -tags=gofuzz ./... + - go vet ./... + - staticcheck -ignore 'github.com/mdlayher/raw/raw_bsd.go:SA1019' ./... + - golint -set_exit_status ./... + - go test -v -race ./... diff --git a/vendor/github.com/mdlayher/raw/LICENSE.md b/vendor/github.com/mdlayher/raw/LICENSE.md new file mode 100644 index 00000000..75ed9de1 --- /dev/null +++ b/vendor/github.com/mdlayher/raw/LICENSE.md @@ -0,0 +1,10 @@ +MIT License +=========== + +Copyright (C) 2015 Matt Layher + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/mdlayher/raw/README.md b/vendor/github.com/mdlayher/raw/README.md new file mode 100644 index 00000000..fb6725f7 --- /dev/null +++ b/vendor/github.com/mdlayher/raw/README.md @@ -0,0 +1,12 @@ +raw [![Build Status](https://travis-ci.org/mdlayher/raw.svg?branch=master)](https://travis-ci.org/mdlayher/raw) [![GoDoc](https://godoc.org/github.com/mdlayher/raw?status.svg)](https://godoc.org/github.com/mdlayher/raw) [![Go Report Card](https://goreportcard.com/badge/github.com/mdlayher/raw)](https://goreportcard.com/report/github.com/mdlayher/raw) +=== + +Package `raw` enables reading and writing data at the device driver level for +a network interface. MIT Licensed. + +For more information about using raw sockets with Ethernet frames in Go, check +out my blog post: [Network Protocol Breakdown: Ethernet and Go](https://medium.com/@mdlayher/network-protocol-breakdown-ethernet-and-go-de985d726cc1). + +Portions of this code are taken from the Go standard library. The Go +standard library is Copyright (c) 2012 The Go Authors. All rights reserved. +The Go license can be found at https://golang.org/LICENSE. \ No newline at end of file diff --git a/vendor/github.com/mdlayher/raw/raw.go b/vendor/github.com/mdlayher/raw/raw.go new file mode 100644 index 00000000..fff8e354 --- /dev/null +++ b/vendor/github.com/mdlayher/raw/raw.go @@ -0,0 +1,189 @@ +// Package raw enables reading and writing data at the device driver level for +// a network interface. +package raw + +import ( + "errors" + "net" + "time" + + "golang.org/x/net/bpf" +) + +const ( + // Maximum read timeout per syscall. + // It is required because read/recvfrom won't be interrupted on closing of the file descriptor. + readTimeout = 200 * time.Millisecond +) + +var ( + // ErrNotImplemented is returned when certain functionality is not yet + // implemented for the host operating system. + ErrNotImplemented = errors.New("raw: not implemented") +) + +var _ net.Addr = &Addr{} + +// Addr is a network address which can be used to contact other machines, using +// their hardware addresses. +type Addr struct { + HardwareAddr net.HardwareAddr +} + +// Network returns the address's network name, "raw". +func (a *Addr) Network() string { + return "raw" +} + +// String returns the address's hardware address. +func (a *Addr) String() string { + return a.HardwareAddr.String() +} + +var _ net.PacketConn = &Conn{} + +// Conn is an implementation of the net.PacketConn interface which can send +// and receive data at the network interface device driver level. +type Conn struct { + // packetConn is the operating system-specific implementation of + // a raw connection. + p *packetConn +} + +// ReadFrom implements the net.PacketConn ReadFrom method. +func (c *Conn) ReadFrom(b []byte) (int, net.Addr, error) { + return c.p.ReadFrom(b) +} + +// WriteTo implements the net.PacketConn WriteTo method. +func (c *Conn) WriteTo(b []byte, addr net.Addr) (int, error) { + return c.p.WriteTo(b, addr) +} + +// Close closes the connection. +func (c *Conn) Close() error { + return c.p.Close() +} + +// LocalAddr returns the local network address. +func (c *Conn) LocalAddr() net.Addr { + return c.p.LocalAddr() +} + +// SetDeadline implements the net.PacketConn SetDeadline method. +func (c *Conn) SetDeadline(t time.Time) error { + return c.p.SetDeadline(t) +} + +// SetReadDeadline implements the net.PacketConn SetReadDeadline method. +func (c *Conn) SetReadDeadline(t time.Time) error { + return c.p.SetReadDeadline(t) +} + +// SetWriteDeadline implements the net.PacketConn SetWriteDeadline method. +func (c *Conn) SetWriteDeadline(t time.Time) error { + return c.p.SetWriteDeadline(t) +} + +var _ bpf.Setter = &Conn{} + +// SetBPF attaches an assembled BPF program to the connection. +func (c *Conn) SetBPF(filter []bpf.RawInstruction) error { + return c.p.SetBPF(filter) +} + +// SetPromiscuous enables or disables promiscuous mode on the interface, allowing it +// to receive traffic that is not addressed to the interface. +func (c *Conn) SetPromiscuous(b bool) error { + return c.p.SetPromiscuous(b) +} + +// Stats contains statistics about a Conn. +type Stats struct { + // The total number of packets received. + Packets uint64 + + // The number of packets dropped. + Drops uint64 +} + +// Stats retrieves statistics from the Conn. +// +// Only supported on Linux at this time. +func (c *Conn) Stats() (*Stats, error) { + return c.p.Stats() +} + +// ListenPacket creates a net.PacketConn which can be used to send and receive +// data at the network interface device driver level. +// +// ifi specifies the network interface which will be used to send and receive +// data. +// +// proto specifies the protocol (usually the EtherType) which should be +// captured and transmitted. proto, if needed, is automatically converted to +// network byte order (big endian), akin to the htons() function in C. +// +// cfg specifies optional configuration which may be operating system-specific. +// A nil Config is equivalent to the default configuration: send and receive +// data at the network interface device driver level (usually raw Ethernet frames). +func ListenPacket(ifi *net.Interface, proto uint16, cfg *Config) (*Conn, error) { + // A nil config is an empty Config. + if cfg == nil { + cfg = &Config{} + } + + p, err := listenPacket(ifi, proto, *cfg) + if err != nil { + return nil, err + } + + return &Conn{ + p: p, + }, nil +} + +// A Config can be used to specify additional options for a Conn. +type Config struct { + // Linux only: call socket(7) with SOCK_DGRAM instead of SOCK_RAW. + // Has no effect on other operating systems. + LinuxSockDGRAM bool + + // Experimental: Linux only (for now, but can be ported to BSD): + // disables repeated socket reads due to internal timeouts, at the expense + // of losing the ability to cancel a ReadFrom operation by calling the Close + // method of the net.PacketConn. + // + // Not recommended for programs which may need to open and close multiple + // sockets during program runs. This may save some CPU time by avoiding a + // busy loop for programs which do not need timeouts, or programs which keep + // a single socket open for the entire duration of the program. + NoTimeouts bool + + // Linux only: do not accumulate packet socket statistic counters. Packet + // socket statistics are reset on each call to retrieve them via getsockopt, + // but this package's default behavior is to continue accumulating the + // statistics internally per Conn. To use the Linux default behavior of + // resetting statistics on each call to Stats, set this value to true. + NoCumulativeStats bool +} + +// htons converts a short (uint16) from host-to-network byte order. +// Thanks to mikioh for this neat trick: +// https://github.com/mikioh/-stdyng/blob/master/afpacket.go +func htons(i uint16) uint16 { + return (i<<8)&0xff00 | i>>8 +} + +// Copyright (c) 2012 The Go Authors. All rights reserved. +// Source code in this file is based on src/net/interface_linux.go, +// from the Go standard library. The Go license can be found here: +// https://golang.org/LICENSE. + +// Taken from: +// https://github.com/golang/go/blob/master/src/net/net.go#L417-L421. +type timeoutError struct{} + +func (e *timeoutError) Error() string { return "i/o timeout" } +func (e *timeoutError) Timeout() bool { return true } +func (e *timeoutError) Temporary() bool { return true } diff --git a/vendor/github.com/mdlayher/raw/raw_bsd.go b/vendor/github.com/mdlayher/raw/raw_bsd.go new file mode 100644 index 00000000..cdde0f26 --- /dev/null +++ b/vendor/github.com/mdlayher/raw/raw_bsd.go @@ -0,0 +1,366 @@ +// +build darwin dragonfly freebsd netbsd openbsd + +package raw + +import ( + "errors" + "fmt" + "net" + "os" + "runtime" + "sync" + "syscall" + "time" + "unsafe" + + "golang.org/x/net/bpf" +) + +const ( + // bpfDIn tells BPF to pass through only incoming packets, so we do not + // receive the packets we send using BPF. + bpfDIn = 0 + + // osFreeBSD is the GOOS name for FreeBSD. + osFreeBSD = "freebsd" +) + +// bpfLen returns the length of the BPF header prepended to each incoming ethernet +// frame. FreeBSD uses a slightly modified header from other BSD variants. +func bpfLen() int { + // Majority of BSD family systems use the bpf_hdr struct, but FreeBSD + // has replaced this with bpf_xhdr, which is longer. + const ( + bpfHeaderLen = 18 + bpfXHeaderLen = 26 + ) + + if runtime.GOOS == osFreeBSD { + return bpfXHeaderLen + } + + return bpfHeaderLen +} + +var ( + // Must implement net.PacketConn at compile-time. + _ net.PacketConn = &packetConn{} +) + +// packetConn is the Linux-specific implementation of net.PacketConn for this +// package. +type packetConn struct { + proto uint16 + ifi *net.Interface + f *os.File + fd int + buflen int + + // Timeouts set via Set{Read,}Deadline, guarded by mutex + timeoutMu sync.RWMutex + rtimeout time.Time +} + +// listenPacket creates a net.PacketConn which can be used to send and receive +// data at the device driver level. +func listenPacket(ifi *net.Interface, proto uint16, _ Config) (*packetConn, error) { + // Config is, as of now, unused on BSD. + // TODO(mdlayher): consider porting NoTimeouts option to BSD if it pans out. + + var f *os.File + var err error + + // Try to find an available BPF device + for i := 0; i <= 10; i++ { + bpfPath := fmt.Sprintf("/dev/bpf%d", i) + f, err = os.OpenFile(bpfPath, os.O_RDWR, 0666) + if err == nil { + // Found a usable device + break + } + + // Device is busy, try the next one + if perr, ok := err.(*os.PathError); ok { + if perr.Err.(syscall.Errno) == syscall.EBUSY { + continue + } + } + + return nil, err + } + + if f == nil { + return nil, errors.New("unable to open BPF device") + } + + fd := int(f.Fd()) + if fd == -1 { + return nil, errors.New("unable to open BPF device") + } + + // Configure BPF device to send and receive data + buflen, err := configureBPF(fd, ifi, proto) + if err != nil { + return nil, err + } + + return &packetConn{ + proto: proto, + ifi: ifi, + f: f, + fd: fd, + buflen: buflen, + }, nil +} + +// ReadFrom implements the net.PacketConn.ReadFrom method. +func (p *packetConn) ReadFrom(b []byte) (int, net.Addr, error) { + p.timeoutMu.Lock() + deadline := p.rtimeout + p.timeoutMu.Unlock() + + buf := make([]byte, p.buflen) + var n int + + for { + var timeout time.Duration + + if deadline.IsZero() { + timeout = readTimeout + } else { + timeout = deadline.Sub(time.Now()) + if timeout > readTimeout { + timeout = readTimeout + } + } + + tv, err := newTimeval(timeout) + if err != nil { + return 0, nil, err + } + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(p.fd), syscall.BIOCSRTIMEOUT, uintptr(unsafe.Pointer(tv))); err != 0 { + return 0, nil, syscall.Errno(err) + } + + // Attempt to receive on socket + // The read sycall will NOT be interrupted by closing of the socket + n, err = syscall.Read(p.fd, buf) + if err != nil { + return n, nil, err + } + if n > 0 { + break + } + } + + // TODO(mdlayher): consider parsing BPF header if it proves useful. + // BPF header length depends on the platform this code is running on + bpfl := bpfLen() + + // Retrieve source MAC address of ethernet header + mac := make(net.HardwareAddr, 6) + copy(mac, buf[bpfl+6:bpfl+12]) + + // Skip past BPF header to retrieve ethernet frame + out := copy(b, buf[bpfl:bpfl+n]) + + return out, &Addr{ + HardwareAddr: mac, + }, nil +} + +// WriteTo implements the net.PacketConn.WriteTo method. +func (p *packetConn) WriteTo(b []byte, _ net.Addr) (int, error) { + return syscall.Write(p.fd, b) +} + +// Close closes the connection. +func (p *packetConn) Close() error { + return p.f.Close() +} + +// LocalAddr returns the local network address. +func (p *packetConn) LocalAddr() net.Addr { + return &Addr{ + HardwareAddr: p.ifi.HardwareAddr, + } +} + +// SetDeadline implements the net.PacketConn.SetDeadline method. +func (p *packetConn) SetDeadline(t time.Time) error { + return p.SetReadDeadline(t) +} + +// SetReadDeadline implements the net.PacketConn.SetReadDeadline method. +func (p *packetConn) SetReadDeadline(t time.Time) error { + p.timeoutMu.Lock() + p.rtimeout = t + p.timeoutMu.Unlock() + return nil +} + +// SetWriteDeadline implements the net.PacketConn.SetWriteDeadline method. +func (p *packetConn) SetWriteDeadline(t time.Time) error { + return ErrNotImplemented +} + +// SetBPF attaches an assembled BPF program to a raw net.PacketConn. +func (p *packetConn) SetBPF(filter []bpf.RawInstruction) error { + // Base filter filters traffic based on EtherType + base, err := bpf.Assemble(baseFilter(p.proto)) + if err != nil { + return err + } + + // Append user filter to base filter, translate to raw format, + // and apply to BPF device + return syscall.SetBpf(p.fd, assembleBpfInsn(append(base, filter...))) +} + +// SetPromiscuous enables or disables promiscuous mode on the interface, allowing it +// to receive traffic that is not addressed to the interface. +func (p *packetConn) SetPromiscuous(b bool) error { + m := 1 + if !b { + m = 0 + } + + return syscall.SetBpfPromisc(p.fd, m) +} + +// Stats retrieves statistics from the Conn. +func (p *packetConn) Stats() (*Stats, error) { + return nil, ErrNotImplemented +} + +// configureBPF configures a BPF device with the specified file descriptor to +// use the specified network and interface and protocol. +func configureBPF(fd int, ifi *net.Interface, proto uint16) (int, error) { + // Use specified interface with BPF device + if err := syscall.SetBpfInterface(fd, ifi.Name); err != nil { + return 0, err + } + + // Inform BPF to send us its data immediately + if err := syscall.SetBpfImmediate(fd, 1); err != nil { + return 0, err + } + + // Check buffer size of BPF device + buflen, err := syscall.BpfBuflen(fd) + if err != nil { + return 0, err + } + + // Do not automatically complete source address in ethernet headers + if err := syscall.SetBpfHeadercmpl(fd, 1); err != nil { + return 0, err + } + + // Only retrieve incoming traffic using BPF device + if err := setBPFDirection(fd, bpfDIn); err != nil { + return 0, err + } + + // Build and apply base BPF filter which checks for correct EtherType + // on incoming packets + prog, err := bpf.Assemble(baseInterfaceFilter(proto, ifi.MTU)) + if err != nil { + return 0, err + } + if err := syscall.SetBpf(fd, assembleBpfInsn(prog)); err != nil { + return 0, err + } + + // Flush any packets currently in the BPF device's buffer + if err := syscall.FlushBpf(fd); err != nil { + return 0, err + } + + return buflen, nil +} + +// setBPFDirection enables filtering traffic traveling in a specific direction +// using BPF, so that traffic sent by this package is not captured when reading +// using this package. +func setBPFDirection(fd int, direction int) error { + _, _, err := syscall.Syscall( + syscall.SYS_IOCTL, + uintptr(fd), + // Even though BIOCSDIRECTION is preferred on FreeBSD, BIOCSSEESENT continues + // to work, and is required for other BSD platforms + syscall.BIOCSSEESENT, + uintptr(unsafe.Pointer(&direction)), + ) + if err != 0 { + return syscall.Errno(err) + } + + return nil +} + +// assembleBpfInsn assembles a slice of bpf.RawInstructions to the format required by +// package syscall. +func assembleBpfInsn(filter []bpf.RawInstruction) []syscall.BpfInsn { + // Copy each bpf.RawInstruction into syscall.BpfInsn. If needed, + // the structures have the same memory layout and could probably be + // unsafely cast to each other for speed. + insns := make([]syscall.BpfInsn, 0, len(filter)) + for _, ins := range filter { + insns = append(insns, syscall.BpfInsn{ + Code: ins.Op, + Jt: ins.Jt, + Jf: ins.Jf, + K: ins.K, + }) + } + + return insns +} + +// baseInterfaceFilter creates a base BPF filter which filters traffic based +// on its EtherType and returns up to "mtu" bytes of data for processing. +func baseInterfaceFilter(proto uint16, mtu int) []bpf.Instruction { + return append( + // Filter traffic based on EtherType + baseFilter(proto), + // Accept the packet bytes up to the interface's MTU + bpf.RetConstant{ + Val: uint32(mtu), + }, + ) +} + +// baseFilter creates a base BPF filter which filters traffic based on its +// EtherType. baseFilter can be prepended to other filters to handle common +// filtering tasks. +func baseFilter(proto uint16) []bpf.Instruction { + // Offset | Length | Comment + // ------------------------- + // 00 | 06 | Ethernet destination MAC address + // 06 | 06 | Ethernet source MAC address + // 12 | 02 | Ethernet EtherType + const ( + etherTypeOffset = 12 + etherTypeLength = 2 + ) + + return []bpf.Instruction{ + // Load EtherType value from Ethernet header + bpf.LoadAbsolute{ + Off: etherTypeOffset, + Size: etherTypeLength, + }, + // If EtherType is equal to the protocol we are using, jump to instructions + // added outside of this function. + bpf.JumpIf{ + Cond: bpf.JumpEqual, + Val: uint32(proto), + SkipTrue: 1, + }, + // EtherType does not match our protocol + bpf.RetConstant{ + Val: 0, + }, + } +} diff --git a/vendor/github.com/mdlayher/raw/raw_linux.go b/vendor/github.com/mdlayher/raw/raw_linux.go new file mode 100644 index 00000000..6bcc1ebe --- /dev/null +++ b/vendor/github.com/mdlayher/raw/raw_linux.go @@ -0,0 +1,341 @@ +// +build linux + +package raw + +import ( + "net" + "os" + "sync" + "sync/atomic" + "syscall" + "time" + "unsafe" + + "golang.org/x/net/bpf" + "golang.org/x/sys/unix" +) + +var ( + // Must implement net.PacketConn at compile-time. + _ net.PacketConn = &packetConn{} +) + +// packetConn is the Linux-specific implementation of net.PacketConn for this +// package. +type packetConn struct { + ifi *net.Interface + s socket + pbe uint16 + + // Should timeouts be set at all? + noTimeouts bool + + // Should stats be accumulated instead of reset on each call? + noCumulativeStats bool + + // Internal storage for cumulative stats. + stats Stats + + // Timeouts set via Set{Read,}Deadline, guarded by mutex. + timeoutMu sync.RWMutex + rtimeout time.Time +} + +// socket is an interface which enables swapping out socket syscalls for +// testing. +type socket interface { + Bind(syscall.Sockaddr) error + Close() error + FD() int + GetSockopt(level, name int, v unsafe.Pointer, l uintptr) error + Recvfrom([]byte, int) (int, syscall.Sockaddr, error) + Sendto([]byte, int, syscall.Sockaddr) error + SetSockopt(level, name int, v unsafe.Pointer, l uint32) error + SetTimeout(time.Duration) error +} + +// listenPacket creates a net.PacketConn which can be used to send and receive +// data at the device driver level. +func listenPacket(ifi *net.Interface, proto uint16, cfg Config) (*packetConn, error) { + // Convert proto to big endian. + pbe := htons(proto) + + // Enabling overriding the socket type via config. + typ := syscall.SOCK_RAW + if cfg.LinuxSockDGRAM { + typ = syscall.SOCK_DGRAM + } + + // Open a packet socket using specified socket and protocol types. + sock, err := syscall.Socket(syscall.AF_PACKET, typ, int(pbe)) + if err != nil { + return nil, err + } + + // Wrap raw socket in socket interface. + pc, err := newPacketConn(ifi, &sysSocket{fd: sock}, pbe) + if err != nil { + return nil, err + } + + pc.noTimeouts = cfg.NoTimeouts + pc.noCumulativeStats = cfg.NoCumulativeStats + return pc, nil +} + +// newPacketConn creates a net.PacketConn using the specified network +// interface, wrapped socket and big endian protocol number. +// +// It is the entry point for tests in this package. +func newPacketConn(ifi *net.Interface, s socket, pbe uint16) (*packetConn, error) { + // Bind the packet socket to the interface specified by ifi + // packet(7): + // Only the sll_protocol and the sll_ifindex address fields are used for + // purposes of binding. + err := s.Bind(&syscall.SockaddrLinklayer{ + Protocol: pbe, + Ifindex: ifi.Index, + }) + if err != nil { + return nil, err + } + + return &packetConn{ + ifi: ifi, + s: s, + pbe: pbe, + }, nil +} + +// ReadFrom implements the net.PacketConn.ReadFrom method. +func (p *packetConn) ReadFrom(b []byte) (int, net.Addr, error) { + p.timeoutMu.Lock() + deadline := p.rtimeout + p.timeoutMu.Unlock() + + var ( + // Information returned by syscall.Recvfrom. + n int + addr syscall.Sockaddr + err error + + // Timeout for a single loop iteration. + timeout = readTimeout + ) + + for { + if !deadline.IsZero() { + timeout = deadline.Sub(time.Now()) + if timeout > readTimeout { + timeout = readTimeout + } + } + + // Set a timeout for this iteration if configured to do so. + if !p.noTimeouts { + if err := p.s.SetTimeout(timeout); err != nil { + return 0, nil, err + } + } + + // Attempt to receive on socket + // The recvfrom sycall will NOT be interrupted by closing of the socket + n, addr, err = p.s.Recvfrom(b, 0) + switch err { + case nil: + // Got data, break this loop shortly. + case syscall.EAGAIN: + // Hit a timeout, keep looping. + continue + default: + // Return on any other error. + return n, nil, err + } + + // Got data, exit the loop. + break + } + + // Retrieve hardware address and other information from addr. + sa, ok := addr.(*syscall.SockaddrLinklayer) + if !ok || sa.Halen < 6 { + return n, nil, syscall.EINVAL + } + + // Use length specified to convert byte array into a hardware address slice. + mac := make(net.HardwareAddr, sa.Halen) + copy(mac, sa.Addr[:]) + + // packet(7): + // sll_hatype and sll_pkttype are set on received packets for your + // information. + // TODO(mdlayher): determine if similar fields exist and are useful on + // non-Linux platforms + return n, &Addr{ + HardwareAddr: mac, + }, nil +} + +// WriteTo implements the net.PacketConn.WriteTo method. +func (p *packetConn) WriteTo(b []byte, addr net.Addr) (int, error) { + // Ensure correct Addr type. + a, ok := addr.(*Addr) + if !ok || a.HardwareAddr == nil || len(a.HardwareAddr) < 6 { + return 0, syscall.EINVAL + } + + // Convert hardware address back to byte array form. + var baddr [8]byte + copy(baddr[:], a.HardwareAddr) + + // Send message on socket to the specified hardware address from addr + // packet(7): + // When you send packets it is enough to specify sll_family, sll_addr, + // sll_halen, sll_ifindex, and sll_protocol. The other fields should + // be 0. + // In this case, sll_family is taken care of automatically by syscall. + err := p.s.Sendto(b, 0, &syscall.SockaddrLinklayer{ + Ifindex: p.ifi.Index, + Halen: uint8(len(a.HardwareAddr)), + Addr: baddr, + Protocol: p.pbe, + }) + return len(b), err +} + +// Close closes the connection. +func (p *packetConn) Close() error { + return p.s.Close() +} + +// LocalAddr returns the local network address. +func (p *packetConn) LocalAddr() net.Addr { + return &Addr{ + HardwareAddr: p.ifi.HardwareAddr, + } +} + +// SetDeadline implements the net.PacketConn.SetDeadline method. +func (p *packetConn) SetDeadline(t time.Time) error { + return p.SetReadDeadline(t) +} + +// SetReadDeadline implements the net.PacketConn.SetReadDeadline method. +func (p *packetConn) SetReadDeadline(t time.Time) error { + p.timeoutMu.Lock() + p.rtimeout = t + p.timeoutMu.Unlock() + return nil +} + +// SetWriteDeadline implements the net.PacketConn.SetWriteDeadline method. +func (p *packetConn) SetWriteDeadline(t time.Time) error { + return nil +} + +// SetBPF attaches an assembled BPF program to a raw net.PacketConn. +func (p *packetConn) SetBPF(filter []bpf.RawInstruction) error { + prog := syscall.SockFprog{ + Len: uint16(len(filter)), + Filter: (*syscall.SockFilter)(unsafe.Pointer(&filter[0])), + } + + err := p.s.SetSockopt( + syscall.SOL_SOCKET, + syscall.SO_ATTACH_FILTER, + unsafe.Pointer(&prog), + uint32(unsafe.Sizeof(prog)), + ) + if err != nil { + return os.NewSyscallError("setsockopt", err) + } + + return nil +} + +// SetPromiscuous enables or disables promiscuous mode on the interface, allowing it +// to receive traffic that is not addressed to the interface. +func (p *packetConn) SetPromiscuous(b bool) error { + mreq := unix.PacketMreq{ + Ifindex: int32(p.ifi.Index), + Type: unix.PACKET_MR_PROMISC, + } + + membership := unix.PACKET_ADD_MEMBERSHIP + if !b { + membership = unix.PACKET_DROP_MEMBERSHIP + } + + return p.s.SetSockopt(unix.SOL_PACKET, membership, unsafe.Pointer(&mreq), unix.SizeofPacketMreq) +} + +// Stats retrieves statistics from the Conn. +func (p *packetConn) Stats() (*Stats, error) { + var s unix.TpacketStats + if err := p.s.GetSockopt(unix.SOL_PACKET, unix.PACKET_STATISTICS, unsafe.Pointer(&s), unsafe.Sizeof(s)); err != nil { + return nil, err + } + + return p.handleStats(s), nil +} + +// handleStats handles creation of Stats structures from raw packet socket stats. +func (p *packetConn) handleStats(s unix.TpacketStats) *Stats { + // Does the caller want instantaneous stats as provided by Linux? If so, + // return the structure directly. + if p.noCumulativeStats { + return &Stats{ + Packets: uint64(s.Packets), + Drops: uint64(s.Drops), + } + } + + // The caller wants cumulative stats. Add stats with the internal stats + // structure and return a copy of the resulting stats. + packets := atomic.AddUint64(&p.stats.Packets, uint64(s.Packets)) + drops := atomic.AddUint64(&p.stats.Drops, uint64(s.Drops)) + + return &Stats{ + Packets: packets, + Drops: drops, + } +} + +// sysSocket is the default socket implementation. It makes use of +// Linux-specific system calls to handle raw socket functionality. +type sysSocket struct { + fd int +} + +// Method implementations simply invoke the syscall of the same name, but pass +// the file descriptor stored in the sysSocket as the socket to use. +func (s *sysSocket) Bind(sa syscall.Sockaddr) error { return syscall.Bind(s.fd, sa) } +func (s *sysSocket) Close() error { return syscall.Close(s.fd) } +func (s *sysSocket) FD() int { return s.fd } +func (s *sysSocket) GetSockopt(level, name int, v unsafe.Pointer, l uintptr) error { + _, _, err := syscall.Syscall6(syscall.SYS_GETSOCKOPT, uintptr(s.fd), uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(&l)), 0) + if err != 0 { + return syscall.Errno(err) + } + return nil +} +func (s *sysSocket) Recvfrom(p []byte, flags int) (int, syscall.Sockaddr, error) { + return syscall.Recvfrom(s.fd, p, flags) +} +func (s *sysSocket) Sendto(p []byte, flags int, to syscall.Sockaddr) error { + return syscall.Sendto(s.fd, p, flags, to) +} +func (s *sysSocket) SetSockopt(level, name int, v unsafe.Pointer, l uint32) error { + _, _, err := syscall.Syscall6(syscall.SYS_SETSOCKOPT, uintptr(s.fd), uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0) + if err != 0 { + return syscall.Errno(err) + } + return nil +} +func (s *sysSocket) SetTimeout(timeout time.Duration) error { + tv, err := newTimeval(timeout) + if err != nil { + return err + } + return syscall.SetsockoptTimeval(s.fd, syscall.SOL_SOCKET, syscall.SO_RCVTIMEO, tv) +} diff --git a/vendor/github.com/mdlayher/raw/raw_others.go b/vendor/github.com/mdlayher/raw/raw_others.go new file mode 100644 index 00000000..9511b658 --- /dev/null +++ b/vendor/github.com/mdlayher/raw/raw_others.go @@ -0,0 +1,73 @@ +// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd + +package raw + +import ( + "net" + "time" + + "golang.org/x/net/bpf" +) + +var ( + // Must implement net.PacketConn at compile-time. + _ net.PacketConn = &packetConn{} +) + +// packetConn is the generic implementation of net.PacketConn for this package. +type packetConn struct{} + +// listenPacket is not currently implemented on this platform. +func listenPacket(ifi *net.Interface, proto uint16, cfg Config) (*packetConn, error) { + return nil, ErrNotImplemented +} + +// ReadFrom is not currently implemented on this platform. +func (p *packetConn) ReadFrom(b []byte) (int, net.Addr, error) { + return 0, nil, ErrNotImplemented +} + +// WriteTo is not currently implemented on this platform. +func (p *packetConn) WriteTo(b []byte, addr net.Addr) (int, error) { + return 0, ErrNotImplemented +} + +// Close is not currently implemented on this platform. +func (p *packetConn) Close() error { + return ErrNotImplemented +} + +// LocalAddr is not currently implemented on this platform. +func (p *packetConn) LocalAddr() net.Addr { + return nil +} + +// SetDeadline is not currently implemented on this platform. +func (p *packetConn) SetDeadline(t time.Time) error { + return ErrNotImplemented +} + +// SetReadDeadline is not currently implemented on this platform. +func (p *packetConn) SetReadDeadline(t time.Time) error { + return ErrNotImplemented +} + +// SetWriteDeadline is not currently implemented on this platform. +func (p *packetConn) SetWriteDeadline(t time.Time) error { + return ErrNotImplemented +} + +// SetBPF is not currently implemented on this platform. +func (p *packetConn) SetBPF(filter []bpf.RawInstruction) error { + return ErrNotImplemented +} + +// SetPromisc is not currently implemented on this platform. +func (p *packetConn) SetPromiscuous(b bool) error { + return ErrNotImplemented +} + +// Stats is not currently implemented on this platform. +func (p *packetConn) Stats() (*Stats, error) { + return nil, ErrNotImplemented +} diff --git a/vendor/github.com/mdlayher/raw/timeval.go b/vendor/github.com/mdlayher/raw/timeval.go new file mode 100644 index 00000000..4af1efb1 --- /dev/null +++ b/vendor/github.com/mdlayher/raw/timeval.go @@ -0,0 +1,20 @@ +// +build !darwin,!arm,!windows,!mipsle,!mips + +package raw + +import ( + "syscall" + "time" +) + +// newTimeval transforms a duration into a syscall.Timeval struct. +// An error is returned in case of zero time value. +func newTimeval(timeout time.Duration) (*syscall.Timeval, error) { + if timeout < time.Microsecond { + return nil, &timeoutError{} + } + return &syscall.Timeval{ + Sec: int64(timeout / time.Second), + Usec: int64(timeout % time.Second / time.Microsecond), + }, nil +} diff --git a/vendor/github.com/mdlayher/raw/timeval32.go b/vendor/github.com/mdlayher/raw/timeval32.go new file mode 100644 index 00000000..0ea9f0cc --- /dev/null +++ b/vendor/github.com/mdlayher/raw/timeval32.go @@ -0,0 +1,20 @@ +// +build arm mipsle mips + +package raw + +import ( + "syscall" + "time" +) + +// newTimeval transforms a duration into a syscall.Timeval struct. +// An error is returned in case of zero time value. +func newTimeval(timeout time.Duration) (*syscall.Timeval, error) { + if timeout < time.Microsecond { + return nil, &timeoutError{} + } + return &syscall.Timeval{ + Sec: int32(timeout / time.Second), + Usec: int32(timeout % time.Second / time.Microsecond), + }, nil +} diff --git a/vendor/github.com/mdlayher/raw/timeval_darwin.go b/vendor/github.com/mdlayher/raw/timeval_darwin.go new file mode 100644 index 00000000..41a30b72 --- /dev/null +++ b/vendor/github.com/mdlayher/raw/timeval_darwin.go @@ -0,0 +1,20 @@ +// +build darwin + +package raw + +import ( + "syscall" + "time" +) + +// newTimeval transforms a duration into a syscall.Timeval struct. +// An error is returned in case of zero time value. +func newTimeval(timeout time.Duration) (*syscall.Timeval, error) { + if timeout < time.Microsecond { + return nil, &timeoutError{} + } + return &syscall.Timeval{ + Sec: int64(timeout / time.Second), + Usec: int32(timeout % time.Second / time.Microsecond), + }, nil +} diff --git a/vendor/golang.org/x/net/AUTHORS b/vendor/golang.org/x/net/AUTHORS new file mode 100644 index 00000000..15167cd7 --- /dev/null +++ b/vendor/golang.org/x/net/AUTHORS @@ -0,0 +1,3 @@ +# This source code refers to The Go Authors for copyright purposes. +# The master list of authors is in the main Go distribution, +# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/net/CONTRIBUTORS b/vendor/golang.org/x/net/CONTRIBUTORS new file mode 100644 index 00000000..1c4577e9 --- /dev/null +++ b/vendor/golang.org/x/net/CONTRIBUTORS @@ -0,0 +1,3 @@ +# This source code was written by the Go contributors. +# The master list of contributors is in the main Go distribution, +# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/net/LICENSE b/vendor/golang.org/x/net/LICENSE new file mode 100644 index 00000000..6a66aea5 --- /dev/null +++ b/vendor/golang.org/x/net/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. 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 Google Inc. 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/golang.org/x/net/PATENTS b/vendor/golang.org/x/net/PATENTS new file mode 100644 index 00000000..73309904 --- /dev/null +++ b/vendor/golang.org/x/net/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Go project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of Go, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of Go. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of Go or any code incorporated within this +implementation of Go constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of Go +shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/net/bpf/asm.go b/vendor/golang.org/x/net/bpf/asm.go new file mode 100644 index 00000000..15e21b18 --- /dev/null +++ b/vendor/golang.org/x/net/bpf/asm.go @@ -0,0 +1,41 @@ +// Copyright 2016 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 bpf + +import "fmt" + +// Assemble converts insts into raw instructions suitable for loading +// into a BPF virtual machine. +// +// Currently, no optimization is attempted, the assembled program flow +// is exactly as provided. +func Assemble(insts []Instruction) ([]RawInstruction, error) { + ret := make([]RawInstruction, len(insts)) + var err error + for i, inst := range insts { + ret[i], err = inst.Assemble() + if err != nil { + return nil, fmt.Errorf("assembling instruction %d: %s", i+1, err) + } + } + return ret, nil +} + +// Disassemble attempts to parse raw back into +// Instructions. Unrecognized RawInstructions are assumed to be an +// extension not implemented by this package, and are passed through +// unchanged to the output. The allDecoded value reports whether insts +// contains no RawInstructions. +func Disassemble(raw []RawInstruction) (insts []Instruction, allDecoded bool) { + insts = make([]Instruction, len(raw)) + allDecoded = true + for i, r := range raw { + insts[i] = r.Disassemble() + if _, ok := insts[i].(RawInstruction); ok { + allDecoded = false + } + } + return insts, allDecoded +} diff --git a/vendor/golang.org/x/net/bpf/constants.go b/vendor/golang.org/x/net/bpf/constants.go new file mode 100644 index 00000000..b89ca352 --- /dev/null +++ b/vendor/golang.org/x/net/bpf/constants.go @@ -0,0 +1,218 @@ +// Copyright 2016 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 bpf + +// A Register is a register of the BPF virtual machine. +type Register uint16 + +const ( + // RegA is the accumulator register. RegA is always the + // destination register of ALU operations. + RegA Register = iota + // RegX is the indirection register, used by LoadIndirect + // operations. + RegX +) + +// An ALUOp is an arithmetic or logic operation. +type ALUOp uint16 + +// ALU binary operation types. +const ( + ALUOpAdd ALUOp = iota << 4 + ALUOpSub + ALUOpMul + ALUOpDiv + ALUOpOr + ALUOpAnd + ALUOpShiftLeft + ALUOpShiftRight + aluOpNeg // Not exported because it's the only unary ALU operation, and gets its own instruction type. + ALUOpMod + ALUOpXor +) + +// A JumpTest is a comparison operator used in conditional jumps. +type JumpTest uint16 + +// Supported operators for conditional jumps. +const ( + // K == A + JumpEqual JumpTest = iota + // K != A + JumpNotEqual + // K > A + JumpGreaterThan + // K < A + JumpLessThan + // K >= A + JumpGreaterOrEqual + // K <= A + JumpLessOrEqual + // K & A != 0 + JumpBitsSet + // K & A == 0 + JumpBitsNotSet +) + +// An Extension is a function call provided by the kernel that +// performs advanced operations that are expensive or impossible +// within the BPF virtual machine. +// +// Extensions are only implemented by the Linux kernel. +// +// TODO: should we prune this list? Some of these extensions seem +// either broken or near-impossible to use correctly, whereas other +// (len, random, ifindex) are quite useful. +type Extension int + +// Extension functions available in the Linux kernel. +const ( + // extOffset is the negative maximum number of instructions used + // to load instructions by overloading the K argument. + extOffset = -0x1000 + // ExtLen returns the length of the packet. + ExtLen Extension = 1 + // ExtProto returns the packet's L3 protocol type. + ExtProto Extension = 0 + // ExtType returns the packet's type (skb->pkt_type in the kernel) + // + // TODO: better documentation. How nice an API do we want to + // provide for these esoteric extensions? + ExtType Extension = 4 + // ExtPayloadOffset returns the offset of the packet payload, or + // the first protocol header that the kernel does not know how to + // parse. + ExtPayloadOffset Extension = 52 + // ExtInterfaceIndex returns the index of the interface on which + // the packet was received. + ExtInterfaceIndex Extension = 8 + // ExtNetlinkAttr returns the netlink attribute of type X at + // offset A. + ExtNetlinkAttr Extension = 12 + // ExtNetlinkAttrNested returns the nested netlink attribute of + // type X at offset A. + ExtNetlinkAttrNested Extension = 16 + // ExtMark returns the packet's mark value. + ExtMark Extension = 20 + // ExtQueue returns the packet's assigned hardware queue. + ExtQueue Extension = 24 + // ExtLinkLayerType returns the packet's hardware address type + // (e.g. Ethernet, Infiniband). + ExtLinkLayerType Extension = 28 + // ExtRXHash returns the packets receive hash. + // + // TODO: figure out what this rxhash actually is. + ExtRXHash Extension = 32 + // ExtCPUID returns the ID of the CPU processing the current + // packet. + ExtCPUID Extension = 36 + // ExtVLANTag returns the packet's VLAN tag. + ExtVLANTag Extension = 44 + // ExtVLANTagPresent returns non-zero if the packet has a VLAN + // tag. + // + // TODO: I think this might be a lie: it reads bit 0x1000 of the + // VLAN header, which changed meaning in recent revisions of the + // spec - this extension may now return meaningless information. + ExtVLANTagPresent Extension = 48 + // ExtVLANProto returns 0x8100 if the frame has a VLAN header, + // 0x88a8 if the frame has a "Q-in-Q" double VLAN header, or some + // other value if no VLAN information is present. + ExtVLANProto Extension = 60 + // ExtRand returns a uniformly random uint32. + ExtRand Extension = 56 +) + +// The following gives names to various bit patterns used in opcode construction. + +const ( + opMaskCls uint16 = 0x7 + // opClsLoad masks + opMaskLoadDest = 0x01 + opMaskLoadWidth = 0x18 + opMaskLoadMode = 0xe0 + // opClsALU + opMaskOperandSrc = 0x08 + opMaskOperator = 0xf0 + // opClsJump + opMaskJumpConst = 0x0f + opMaskJumpCond = 0xf0 +) + +const ( + // +---------------+-----------------+---+---+---+ + // | AddrMode (3b) | LoadWidth (2b) | 0 | 0 | 0 | + // +---------------+-----------------+---+---+---+ + opClsLoadA uint16 = iota + // +---------------+-----------------+---+---+---+ + // | AddrMode (3b) | LoadWidth (2b) | 0 | 0 | 1 | + // +---------------+-----------------+---+---+---+ + opClsLoadX + // +---+---+---+---+---+---+---+---+ + // | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | + // +---+---+---+---+---+---+---+---+ + opClsStoreA + // +---+---+---+---+---+---+---+---+ + // | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | + // +---+---+---+---+---+---+---+---+ + opClsStoreX + // +---------------+-----------------+---+---+---+ + // | Operator (4b) | OperandSrc (1b) | 1 | 0 | 0 | + // +---------------+-----------------+---+---+---+ + opClsALU + // +-----------------------------+---+---+---+---+ + // | TestOperator (4b) | 0 | 1 | 0 | 1 | + // +-----------------------------+---+---+---+---+ + opClsJump + // +---+-------------------------+---+---+---+---+ + // | 0 | 0 | 0 | RetSrc (1b) | 0 | 1 | 1 | 0 | + // +---+-------------------------+---+---+---+---+ + opClsReturn + // +---+-------------------------+---+---+---+---+ + // | 0 | 0 | 0 | TXAorTAX (1b) | 0 | 1 | 1 | 1 | + // +---+-------------------------+---+---+---+---+ + opClsMisc +) + +const ( + opAddrModeImmediate uint16 = iota << 5 + opAddrModeAbsolute + opAddrModeIndirect + opAddrModeScratch + opAddrModePacketLen // actually an extension, not an addressing mode. + opAddrModeMemShift +) + +const ( + opLoadWidth4 uint16 = iota << 3 + opLoadWidth2 + opLoadWidth1 +) + +// Operator defined by ALUOp* + +const ( + opALUSrcConstant uint16 = iota << 3 + opALUSrcX +) + +const ( + opJumpAlways = iota << 4 + opJumpEqual + opJumpGT + opJumpGE + opJumpSet +) + +const ( + opRetSrcConstant uint16 = iota << 4 + opRetSrcA +) + +const ( + opMiscTAX = 0x00 + opMiscTXA = 0x80 +) diff --git a/vendor/golang.org/x/net/bpf/doc.go b/vendor/golang.org/x/net/bpf/doc.go new file mode 100644 index 00000000..ae62feb5 --- /dev/null +++ b/vendor/golang.org/x/net/bpf/doc.go @@ -0,0 +1,82 @@ +// Copyright 2016 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 bpf implements marshaling and unmarshaling of programs for the +Berkeley Packet Filter virtual machine, and provides a Go implementation +of the virtual machine. + +BPF's main use is to specify a packet filter for network taps, so that +the kernel doesn't have to expensively copy every packet it sees to +userspace. However, it's been repurposed to other areas where running +user code in-kernel is needed. For example, Linux's seccomp uses BPF +to apply security policies to system calls. For simplicity, this +documentation refers only to packets, but other uses of BPF have their +own data payloads. + +BPF programs run in a restricted virtual machine. It has almost no +access to kernel functions, and while conditional branches are +allowed, they can only jump forwards, to guarantee that there are no +infinite loops. + +The virtual machine + +The BPF VM is an accumulator machine. Its main register, called +register A, is an implicit source and destination in all arithmetic +and logic operations. The machine also has 16 scratch registers for +temporary storage, and an indirection register (register X) for +indirect memory access. All registers are 32 bits wide. + +Each run of a BPF program is given one packet, which is placed in the +VM's read-only "main memory". LoadAbsolute and LoadIndirect +instructions can fetch up to 32 bits at a time into register A for +examination. + +The goal of a BPF program is to produce and return a verdict (uint32), +which tells the kernel what to do with the packet. In the context of +packet filtering, the returned value is the number of bytes of the +packet to forward to userspace, or 0 to ignore the packet. Other +contexts like seccomp define their own return values. + +In order to simplify programs, attempts to read past the end of the +packet terminate the program execution with a verdict of 0 (ignore +packet). This means that the vast majority of BPF programs don't need +to do any explicit bounds checking. + +In addition to the bytes of the packet, some BPF programs have access +to extensions, which are essentially calls to kernel utility +functions. Currently, the only extensions supported by this package +are the Linux packet filter extensions. + +Examples + +This packet filter selects all ARP packets. + + bpf.Assemble([]bpf.Instruction{ + // Load "EtherType" field from the ethernet header. + bpf.LoadAbsolute{Off: 12, Size: 2}, + // Skip over the next instruction if EtherType is not ARP. + bpf.JumpIf{Cond: bpf.JumpNotEqual, Val: 0x0806, SkipTrue: 1}, + // Verdict is "send up to 4k of the packet to userspace." + bpf.RetConstant{Val: 4096}, + // Verdict is "ignore packet." + bpf.RetConstant{Val: 0}, + }) + +This packet filter captures a random 1% sample of traffic. + + bpf.Assemble([]bpf.Instruction{ + // Get a 32-bit random number from the Linux kernel. + bpf.LoadExtension{Num: bpf.ExtRand}, + // 1% dice roll? + bpf.JumpIf{Cond: bpf.JumpLessThan, Val: 2^32/100, SkipFalse: 1}, + // Capture. + bpf.RetConstant{Val: 4096}, + // Ignore. + bpf.RetConstant{Val: 0}, + }) + +*/ +package bpf // import "golang.org/x/net/bpf" diff --git a/vendor/golang.org/x/net/bpf/instructions.go b/vendor/golang.org/x/net/bpf/instructions.go new file mode 100644 index 00000000..f9dc0e8e --- /dev/null +++ b/vendor/golang.org/x/net/bpf/instructions.go @@ -0,0 +1,704 @@ +// Copyright 2016 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 bpf + +import "fmt" + +// An Instruction is one instruction executed by the BPF virtual +// machine. +type Instruction interface { + // Assemble assembles the Instruction into a RawInstruction. + Assemble() (RawInstruction, error) +} + +// A RawInstruction is a raw BPF virtual machine instruction. +type RawInstruction struct { + // Operation to execute. + Op uint16 + // For conditional jump instructions, the number of instructions + // to skip if the condition is true/false. + Jt uint8 + Jf uint8 + // Constant parameter. The meaning depends on the Op. + K uint32 +} + +// Assemble implements the Instruction Assemble method. +func (ri RawInstruction) Assemble() (RawInstruction, error) { return ri, nil } + +// Disassemble parses ri into an Instruction and returns it. If ri is +// not recognized by this package, ri itself is returned. +func (ri RawInstruction) Disassemble() Instruction { + switch ri.Op & opMaskCls { + case opClsLoadA, opClsLoadX: + reg := Register(ri.Op & opMaskLoadDest) + sz := 0 + switch ri.Op & opMaskLoadWidth { + case opLoadWidth4: + sz = 4 + case opLoadWidth2: + sz = 2 + case opLoadWidth1: + sz = 1 + default: + return ri + } + switch ri.Op & opMaskLoadMode { + case opAddrModeImmediate: + if sz != 4 { + return ri + } + return LoadConstant{Dst: reg, Val: ri.K} + case opAddrModeScratch: + if sz != 4 || ri.K > 15 { + return ri + } + return LoadScratch{Dst: reg, N: int(ri.K)} + case opAddrModeAbsolute: + if ri.K > extOffset+0xffffffff { + return LoadExtension{Num: Extension(-extOffset + ri.K)} + } + return LoadAbsolute{Size: sz, Off: ri.K} + case opAddrModeIndirect: + return LoadIndirect{Size: sz, Off: ri.K} + case opAddrModePacketLen: + if sz != 4 { + return ri + } + return LoadExtension{Num: ExtLen} + case opAddrModeMemShift: + return LoadMemShift{Off: ri.K} + default: + return ri + } + + case opClsStoreA: + if ri.Op != opClsStoreA || ri.K > 15 { + return ri + } + return StoreScratch{Src: RegA, N: int(ri.K)} + + case opClsStoreX: + if ri.Op != opClsStoreX || ri.K > 15 { + return ri + } + return StoreScratch{Src: RegX, N: int(ri.K)} + + case opClsALU: + switch op := ALUOp(ri.Op & opMaskOperator); op { + case ALUOpAdd, ALUOpSub, ALUOpMul, ALUOpDiv, ALUOpOr, ALUOpAnd, ALUOpShiftLeft, ALUOpShiftRight, ALUOpMod, ALUOpXor: + if ri.Op&opMaskOperandSrc != 0 { + return ALUOpX{Op: op} + } + return ALUOpConstant{Op: op, Val: ri.K} + case aluOpNeg: + return NegateA{} + default: + return ri + } + + case opClsJump: + if ri.Op&opMaskJumpConst != opClsJump { + return ri + } + switch ri.Op & opMaskJumpCond { + case opJumpAlways: + return Jump{Skip: ri.K} + case opJumpEqual: + if ri.Jt == 0 { + return JumpIf{ + Cond: JumpNotEqual, + Val: ri.K, + SkipTrue: ri.Jf, + SkipFalse: 0, + } + } + return JumpIf{ + Cond: JumpEqual, + Val: ri.K, + SkipTrue: ri.Jt, + SkipFalse: ri.Jf, + } + case opJumpGT: + if ri.Jt == 0 { + return JumpIf{ + Cond: JumpLessOrEqual, + Val: ri.K, + SkipTrue: ri.Jf, + SkipFalse: 0, + } + } + return JumpIf{ + Cond: JumpGreaterThan, + Val: ri.K, + SkipTrue: ri.Jt, + SkipFalse: ri.Jf, + } + case opJumpGE: + if ri.Jt == 0 { + return JumpIf{ + Cond: JumpLessThan, + Val: ri.K, + SkipTrue: ri.Jf, + SkipFalse: 0, + } + } + return JumpIf{ + Cond: JumpGreaterOrEqual, + Val: ri.K, + SkipTrue: ri.Jt, + SkipFalse: ri.Jf, + } + case opJumpSet: + return JumpIf{ + Cond: JumpBitsSet, + Val: ri.K, + SkipTrue: ri.Jt, + SkipFalse: ri.Jf, + } + default: + return ri + } + + case opClsReturn: + switch ri.Op { + case opClsReturn | opRetSrcA: + return RetA{} + case opClsReturn | opRetSrcConstant: + return RetConstant{Val: ri.K} + default: + return ri + } + + case opClsMisc: + switch ri.Op { + case opClsMisc | opMiscTAX: + return TAX{} + case opClsMisc | opMiscTXA: + return TXA{} + default: + return ri + } + + default: + panic("unreachable") // switch is exhaustive on the bit pattern + } +} + +// LoadConstant loads Val into register Dst. +type LoadConstant struct { + Dst Register + Val uint32 +} + +// Assemble implements the Instruction Assemble method. +func (a LoadConstant) Assemble() (RawInstruction, error) { + return assembleLoad(a.Dst, 4, opAddrModeImmediate, a.Val) +} + +// String returns the instruction in assembler notation. +func (a LoadConstant) String() string { + switch a.Dst { + case RegA: + return fmt.Sprintf("ld #%d", a.Val) + case RegX: + return fmt.Sprintf("ldx #%d", a.Val) + default: + return fmt.Sprintf("unknown instruction: %#v", a) + } +} + +// LoadScratch loads scratch[N] into register Dst. +type LoadScratch struct { + Dst Register + N int // 0-15 +} + +// Assemble implements the Instruction Assemble method. +func (a LoadScratch) Assemble() (RawInstruction, error) { + if a.N < 0 || a.N > 15 { + return RawInstruction{}, fmt.Errorf("invalid scratch slot %d", a.N) + } + return assembleLoad(a.Dst, 4, opAddrModeScratch, uint32(a.N)) +} + +// String returns the instruction in assembler notation. +func (a LoadScratch) String() string { + switch a.Dst { + case RegA: + return fmt.Sprintf("ld M[%d]", a.N) + case RegX: + return fmt.Sprintf("ldx M[%d]", a.N) + default: + return fmt.Sprintf("unknown instruction: %#v", a) + } +} + +// LoadAbsolute loads packet[Off:Off+Size] as an integer value into +// register A. +type LoadAbsolute struct { + Off uint32 + Size int // 1, 2 or 4 +} + +// Assemble implements the Instruction Assemble method. +func (a LoadAbsolute) Assemble() (RawInstruction, error) { + return assembleLoad(RegA, a.Size, opAddrModeAbsolute, a.Off) +} + +// String returns the instruction in assembler notation. +func (a LoadAbsolute) String() string { + switch a.Size { + case 1: // byte + return fmt.Sprintf("ldb [%d]", a.Off) + case 2: // half word + return fmt.Sprintf("ldh [%d]", a.Off) + case 4: // word + if a.Off > extOffset+0xffffffff { + return LoadExtension{Num: Extension(a.Off + 0x1000)}.String() + } + return fmt.Sprintf("ld [%d]", a.Off) + default: + return fmt.Sprintf("unknown instruction: %#v", a) + } +} + +// LoadIndirect loads packet[X+Off:X+Off+Size] as an integer value +// into register A. +type LoadIndirect struct { + Off uint32 + Size int // 1, 2 or 4 +} + +// Assemble implements the Instruction Assemble method. +func (a LoadIndirect) Assemble() (RawInstruction, error) { + return assembleLoad(RegA, a.Size, opAddrModeIndirect, a.Off) +} + +// String returns the instruction in assembler notation. +func (a LoadIndirect) String() string { + switch a.Size { + case 1: // byte + return fmt.Sprintf("ldb [x + %d]", a.Off) + case 2: // half word + return fmt.Sprintf("ldh [x + %d]", a.Off) + case 4: // word + return fmt.Sprintf("ld [x + %d]", a.Off) + default: + return fmt.Sprintf("unknown instruction: %#v", a) + } +} + +// LoadMemShift multiplies the first 4 bits of the byte at packet[Off] +// by 4 and stores the result in register X. +// +// This instruction is mainly useful to load into X the length of an +// IPv4 packet header in a single instruction, rather than have to do +// the arithmetic on the header's first byte by hand. +type LoadMemShift struct { + Off uint32 +} + +// Assemble implements the Instruction Assemble method. +func (a LoadMemShift) Assemble() (RawInstruction, error) { + return assembleLoad(RegX, 1, opAddrModeMemShift, a.Off) +} + +// String returns the instruction in assembler notation. +func (a LoadMemShift) String() string { + return fmt.Sprintf("ldx 4*([%d]&0xf)", a.Off) +} + +// LoadExtension invokes a linux-specific extension and stores the +// result in register A. +type LoadExtension struct { + Num Extension +} + +// Assemble implements the Instruction Assemble method. +func (a LoadExtension) Assemble() (RawInstruction, error) { + if a.Num == ExtLen { + return assembleLoad(RegA, 4, opAddrModePacketLen, 0) + } + return assembleLoad(RegA, 4, opAddrModeAbsolute, uint32(extOffset+a.Num)) +} + +// String returns the instruction in assembler notation. +func (a LoadExtension) String() string { + switch a.Num { + case ExtLen: + return "ld #len" + case ExtProto: + return "ld #proto" + case ExtType: + return "ld #type" + case ExtPayloadOffset: + return "ld #poff" + case ExtInterfaceIndex: + return "ld #ifidx" + case ExtNetlinkAttr: + return "ld #nla" + case ExtNetlinkAttrNested: + return "ld #nlan" + case ExtMark: + return "ld #mark" + case ExtQueue: + return "ld #queue" + case ExtLinkLayerType: + return "ld #hatype" + case ExtRXHash: + return "ld #rxhash" + case ExtCPUID: + return "ld #cpu" + case ExtVLANTag: + return "ld #vlan_tci" + case ExtVLANTagPresent: + return "ld #vlan_avail" + case ExtVLANProto: + return "ld #vlan_tpid" + case ExtRand: + return "ld #rand" + default: + return fmt.Sprintf("unknown instruction: %#v", a) + } +} + +// StoreScratch stores register Src into scratch[N]. +type StoreScratch struct { + Src Register + N int // 0-15 +} + +// Assemble implements the Instruction Assemble method. +func (a StoreScratch) Assemble() (RawInstruction, error) { + if a.N < 0 || a.N > 15 { + return RawInstruction{}, fmt.Errorf("invalid scratch slot %d", a.N) + } + var op uint16 + switch a.Src { + case RegA: + op = opClsStoreA + case RegX: + op = opClsStoreX + default: + return RawInstruction{}, fmt.Errorf("invalid source register %v", a.Src) + } + + return RawInstruction{ + Op: op, + K: uint32(a.N), + }, nil +} + +// String returns the instruction in assembler notation. +func (a StoreScratch) String() string { + switch a.Src { + case RegA: + return fmt.Sprintf("st M[%d]", a.N) + case RegX: + return fmt.Sprintf("stx M[%d]", a.N) + default: + return fmt.Sprintf("unknown instruction: %#v", a) + } +} + +// ALUOpConstant executes A = A Val. +type ALUOpConstant struct { + Op ALUOp + Val uint32 +} + +// Assemble implements the Instruction Assemble method. +func (a ALUOpConstant) Assemble() (RawInstruction, error) { + return RawInstruction{ + Op: opClsALU | opALUSrcConstant | uint16(a.Op), + K: a.Val, + }, nil +} + +// String returns the instruction in assembler notation. +func (a ALUOpConstant) String() string { + switch a.Op { + case ALUOpAdd: + return fmt.Sprintf("add #%d", a.Val) + case ALUOpSub: + return fmt.Sprintf("sub #%d", a.Val) + case ALUOpMul: + return fmt.Sprintf("mul #%d", a.Val) + case ALUOpDiv: + return fmt.Sprintf("div #%d", a.Val) + case ALUOpMod: + return fmt.Sprintf("mod #%d", a.Val) + case ALUOpAnd: + return fmt.Sprintf("and #%d", a.Val) + case ALUOpOr: + return fmt.Sprintf("or #%d", a.Val) + case ALUOpXor: + return fmt.Sprintf("xor #%d", a.Val) + case ALUOpShiftLeft: + return fmt.Sprintf("lsh #%d", a.Val) + case ALUOpShiftRight: + return fmt.Sprintf("rsh #%d", a.Val) + default: + return fmt.Sprintf("unknown instruction: %#v", a) + } +} + +// ALUOpX executes A = A X +type ALUOpX struct { + Op ALUOp +} + +// Assemble implements the Instruction Assemble method. +func (a ALUOpX) Assemble() (RawInstruction, error) { + return RawInstruction{ + Op: opClsALU | opALUSrcX | uint16(a.Op), + }, nil +} + +// String returns the instruction in assembler notation. +func (a ALUOpX) String() string { + switch a.Op { + case ALUOpAdd: + return "add x" + case ALUOpSub: + return "sub x" + case ALUOpMul: + return "mul x" + case ALUOpDiv: + return "div x" + case ALUOpMod: + return "mod x" + case ALUOpAnd: + return "and x" + case ALUOpOr: + return "or x" + case ALUOpXor: + return "xor x" + case ALUOpShiftLeft: + return "lsh x" + case ALUOpShiftRight: + return "rsh x" + default: + return fmt.Sprintf("unknown instruction: %#v", a) + } +} + +// NegateA executes A = -A. +type NegateA struct{} + +// Assemble implements the Instruction Assemble method. +func (a NegateA) Assemble() (RawInstruction, error) { + return RawInstruction{ + Op: opClsALU | uint16(aluOpNeg), + }, nil +} + +// String returns the instruction in assembler notation. +func (a NegateA) String() string { + return fmt.Sprintf("neg") +} + +// Jump skips the following Skip instructions in the program. +type Jump struct { + Skip uint32 +} + +// Assemble implements the Instruction Assemble method. +func (a Jump) Assemble() (RawInstruction, error) { + return RawInstruction{ + Op: opClsJump | opJumpAlways, + K: a.Skip, + }, nil +} + +// String returns the instruction in assembler notation. +func (a Jump) String() string { + return fmt.Sprintf("ja %d", a.Skip) +} + +// JumpIf skips the following Skip instructions in the program if A +// Val is true. +type JumpIf struct { + Cond JumpTest + Val uint32 + SkipTrue uint8 + SkipFalse uint8 +} + +// Assemble implements the Instruction Assemble method. +func (a JumpIf) Assemble() (RawInstruction, error) { + var ( + cond uint16 + flip bool + ) + switch a.Cond { + case JumpEqual: + cond = opJumpEqual + case JumpNotEqual: + cond, flip = opJumpEqual, true + case JumpGreaterThan: + cond = opJumpGT + case JumpLessThan: + cond, flip = opJumpGE, true + case JumpGreaterOrEqual: + cond = opJumpGE + case JumpLessOrEqual: + cond, flip = opJumpGT, true + case JumpBitsSet: + cond = opJumpSet + case JumpBitsNotSet: + cond, flip = opJumpSet, true + default: + return RawInstruction{}, fmt.Errorf("unknown JumpTest %v", a.Cond) + } + jt, jf := a.SkipTrue, a.SkipFalse + if flip { + jt, jf = jf, jt + } + return RawInstruction{ + Op: opClsJump | cond, + Jt: jt, + Jf: jf, + K: a.Val, + }, nil +} + +// String returns the instruction in assembler notation. +func (a JumpIf) String() string { + switch a.Cond { + // K == A + case JumpEqual: + return conditionalJump(a, "jeq", "jneq") + // K != A + case JumpNotEqual: + return fmt.Sprintf("jneq #%d,%d", a.Val, a.SkipTrue) + // K > A + case JumpGreaterThan: + return conditionalJump(a, "jgt", "jle") + // K < A + case JumpLessThan: + return fmt.Sprintf("jlt #%d,%d", a.Val, a.SkipTrue) + // K >= A + case JumpGreaterOrEqual: + return conditionalJump(a, "jge", "jlt") + // K <= A + case JumpLessOrEqual: + return fmt.Sprintf("jle #%d,%d", a.Val, a.SkipTrue) + // K & A != 0 + case JumpBitsSet: + if a.SkipFalse > 0 { + return fmt.Sprintf("jset #%d,%d,%d", a.Val, a.SkipTrue, a.SkipFalse) + } + return fmt.Sprintf("jset #%d,%d", a.Val, a.SkipTrue) + // K & A == 0, there is no assembler instruction for JumpBitNotSet, use JumpBitSet and invert skips + case JumpBitsNotSet: + return JumpIf{Cond: JumpBitsSet, SkipTrue: a.SkipFalse, SkipFalse: a.SkipTrue, Val: a.Val}.String() + default: + return fmt.Sprintf("unknown instruction: %#v", a) + } +} + +func conditionalJump(inst JumpIf, positiveJump, negativeJump string) string { + if inst.SkipTrue > 0 { + if inst.SkipFalse > 0 { + return fmt.Sprintf("%s #%d,%d,%d", positiveJump, inst.Val, inst.SkipTrue, inst.SkipFalse) + } + return fmt.Sprintf("%s #%d,%d", positiveJump, inst.Val, inst.SkipTrue) + } + return fmt.Sprintf("%s #%d,%d", negativeJump, inst.Val, inst.SkipFalse) +} + +// RetA exits the BPF program, returning the value of register A. +type RetA struct{} + +// Assemble implements the Instruction Assemble method. +func (a RetA) Assemble() (RawInstruction, error) { + return RawInstruction{ + Op: opClsReturn | opRetSrcA, + }, nil +} + +// String returns the instruction in assembler notation. +func (a RetA) String() string { + return fmt.Sprintf("ret a") +} + +// RetConstant exits the BPF program, returning a constant value. +type RetConstant struct { + Val uint32 +} + +// Assemble implements the Instruction Assemble method. +func (a RetConstant) Assemble() (RawInstruction, error) { + return RawInstruction{ + Op: opClsReturn | opRetSrcConstant, + K: a.Val, + }, nil +} + +// String returns the instruction in assembler notation. +func (a RetConstant) String() string { + return fmt.Sprintf("ret #%d", a.Val) +} + +// TXA copies the value of register X to register A. +type TXA struct{} + +// Assemble implements the Instruction Assemble method. +func (a TXA) Assemble() (RawInstruction, error) { + return RawInstruction{ + Op: opClsMisc | opMiscTXA, + }, nil +} + +// String returns the instruction in assembler notation. +func (a TXA) String() string { + return fmt.Sprintf("txa") +} + +// TAX copies the value of register A to register X. +type TAX struct{} + +// Assemble implements the Instruction Assemble method. +func (a TAX) Assemble() (RawInstruction, error) { + return RawInstruction{ + Op: opClsMisc | opMiscTAX, + }, nil +} + +// String returns the instruction in assembler notation. +func (a TAX) String() string { + return fmt.Sprintf("tax") +} + +func assembleLoad(dst Register, loadSize int, mode uint16, k uint32) (RawInstruction, error) { + var ( + cls uint16 + sz uint16 + ) + switch dst { + case RegA: + cls = opClsLoadA + case RegX: + cls = opClsLoadX + default: + return RawInstruction{}, fmt.Errorf("invalid target register %v", dst) + } + switch loadSize { + case 1: + sz = opLoadWidth1 + case 2: + sz = opLoadWidth2 + case 4: + sz = opLoadWidth4 + default: + return RawInstruction{}, fmt.Errorf("invalid load byte length %d", sz) + } + return RawInstruction{ + Op: cls | sz | mode, + K: k, + }, nil +} diff --git a/vendor/golang.org/x/net/bpf/setter.go b/vendor/golang.org/x/net/bpf/setter.go new file mode 100644 index 00000000..43e35f0a --- /dev/null +++ b/vendor/golang.org/x/net/bpf/setter.go @@ -0,0 +1,10 @@ +// Copyright 2017 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 bpf + +// A Setter is a type which can attach a compiled BPF filter to itself. +type Setter interface { + SetBPF(filter []RawInstruction) error +} diff --git a/vendor/golang.org/x/net/bpf/vm.go b/vendor/golang.org/x/net/bpf/vm.go new file mode 100644 index 00000000..4c656f1e --- /dev/null +++ b/vendor/golang.org/x/net/bpf/vm.go @@ -0,0 +1,140 @@ +// Copyright 2016 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 bpf + +import ( + "errors" + "fmt" +) + +// A VM is an emulated BPF virtual machine. +type VM struct { + filter []Instruction +} + +// NewVM returns a new VM using the input BPF program. +func NewVM(filter []Instruction) (*VM, error) { + if len(filter) == 0 { + return nil, errors.New("one or more Instructions must be specified") + } + + for i, ins := range filter { + check := len(filter) - (i + 1) + switch ins := ins.(type) { + // Check for out-of-bounds jumps in instructions + case Jump: + if check <= int(ins.Skip) { + return nil, fmt.Errorf("cannot jump %d instructions; jumping past program bounds", ins.Skip) + } + case JumpIf: + if check <= int(ins.SkipTrue) { + return nil, fmt.Errorf("cannot jump %d instructions in true case; jumping past program bounds", ins.SkipTrue) + } + if check <= int(ins.SkipFalse) { + return nil, fmt.Errorf("cannot jump %d instructions in false case; jumping past program bounds", ins.SkipFalse) + } + // Check for division or modulus by zero + case ALUOpConstant: + if ins.Val != 0 { + break + } + + switch ins.Op { + case ALUOpDiv, ALUOpMod: + return nil, errors.New("cannot divide by zero using ALUOpConstant") + } + // Check for unknown extensions + case LoadExtension: + switch ins.Num { + case ExtLen: + default: + return nil, fmt.Errorf("extension %d not implemented", ins.Num) + } + } + } + + // Make sure last instruction is a return instruction + switch filter[len(filter)-1].(type) { + case RetA, RetConstant: + default: + return nil, errors.New("BPF program must end with RetA or RetConstant") + } + + // Though our VM works using disassembled instructions, we + // attempt to assemble the input filter anyway to ensure it is compatible + // with an operating system VM. + _, err := Assemble(filter) + + return &VM{ + filter: filter, + }, err +} + +// Run runs the VM's BPF program against the input bytes. +// Run returns the number of bytes accepted by the BPF program, and any errors +// which occurred while processing the program. +func (v *VM) Run(in []byte) (int, error) { + var ( + // Registers of the virtual machine + regA uint32 + regX uint32 + regScratch [16]uint32 + + // OK is true if the program should continue processing the next + // instruction, or false if not, causing the loop to break + ok = true + ) + + // TODO(mdlayher): implement: + // - NegateA: + // - would require a change from uint32 registers to int32 + // registers + + // TODO(mdlayher): add interop tests that check signedness of ALU + // operations against kernel implementation, and make sure Go + // implementation matches behavior + + for i := 0; i < len(v.filter) && ok; i++ { + ins := v.filter[i] + + switch ins := ins.(type) { + case ALUOpConstant: + regA = aluOpConstant(ins, regA) + case ALUOpX: + regA, ok = aluOpX(ins, regA, regX) + case Jump: + i += int(ins.Skip) + case JumpIf: + jump := jumpIf(ins, regA) + i += jump + case LoadAbsolute: + regA, ok = loadAbsolute(ins, in) + case LoadConstant: + regA, regX = loadConstant(ins, regA, regX) + case LoadExtension: + regA = loadExtension(ins, in) + case LoadIndirect: + regA, ok = loadIndirect(ins, in, regX) + case LoadMemShift: + regX, ok = loadMemShift(ins, in) + case LoadScratch: + regA, regX = loadScratch(ins, regScratch, regA, regX) + case RetA: + return int(regA), nil + case RetConstant: + return int(ins.Val), nil + case StoreScratch: + regScratch = storeScratch(ins, regScratch, regA, regX) + case TAX: + regX = regA + case TXA: + regA = regX + default: + return 0, fmt.Errorf("unknown Instruction at index %d: %T", i, ins) + } + } + + return 0, nil +} diff --git a/vendor/golang.org/x/net/bpf/vm_instructions.go b/vendor/golang.org/x/net/bpf/vm_instructions.go new file mode 100644 index 00000000..516f9462 --- /dev/null +++ b/vendor/golang.org/x/net/bpf/vm_instructions.go @@ -0,0 +1,174 @@ +// Copyright 2016 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 bpf + +import ( + "encoding/binary" + "fmt" +) + +func aluOpConstant(ins ALUOpConstant, regA uint32) uint32 { + return aluOpCommon(ins.Op, regA, ins.Val) +} + +func aluOpX(ins ALUOpX, regA uint32, regX uint32) (uint32, bool) { + // Guard against division or modulus by zero by terminating + // the program, as the OS BPF VM does + if regX == 0 { + switch ins.Op { + case ALUOpDiv, ALUOpMod: + return 0, false + } + } + + return aluOpCommon(ins.Op, regA, regX), true +} + +func aluOpCommon(op ALUOp, regA uint32, value uint32) uint32 { + switch op { + case ALUOpAdd: + return regA + value + case ALUOpSub: + return regA - value + case ALUOpMul: + return regA * value + case ALUOpDiv: + // Division by zero not permitted by NewVM and aluOpX checks + return regA / value + case ALUOpOr: + return regA | value + case ALUOpAnd: + return regA & value + case ALUOpShiftLeft: + return regA << value + case ALUOpShiftRight: + return regA >> value + case ALUOpMod: + // Modulus by zero not permitted by NewVM and aluOpX checks + return regA % value + case ALUOpXor: + return regA ^ value + default: + return regA + } +} + +func jumpIf(ins JumpIf, value uint32) int { + var ok bool + inV := uint32(ins.Val) + + switch ins.Cond { + case JumpEqual: + ok = value == inV + case JumpNotEqual: + ok = value != inV + case JumpGreaterThan: + ok = value > inV + case JumpLessThan: + ok = value < inV + case JumpGreaterOrEqual: + ok = value >= inV + case JumpLessOrEqual: + ok = value <= inV + case JumpBitsSet: + ok = (value & inV) != 0 + case JumpBitsNotSet: + ok = (value & inV) == 0 + } + + if ok { + return int(ins.SkipTrue) + } + + return int(ins.SkipFalse) +} + +func loadAbsolute(ins LoadAbsolute, in []byte) (uint32, bool) { + offset := int(ins.Off) + size := int(ins.Size) + + return loadCommon(in, offset, size) +} + +func loadConstant(ins LoadConstant, regA uint32, regX uint32) (uint32, uint32) { + switch ins.Dst { + case RegA: + regA = ins.Val + case RegX: + regX = ins.Val + } + + return regA, regX +} + +func loadExtension(ins LoadExtension, in []byte) uint32 { + switch ins.Num { + case ExtLen: + return uint32(len(in)) + default: + panic(fmt.Sprintf("unimplemented extension: %d", ins.Num)) + } +} + +func loadIndirect(ins LoadIndirect, in []byte, regX uint32) (uint32, bool) { + offset := int(ins.Off) + int(regX) + size := int(ins.Size) + + return loadCommon(in, offset, size) +} + +func loadMemShift(ins LoadMemShift, in []byte) (uint32, bool) { + offset := int(ins.Off) + + if !inBounds(len(in), offset, 0) { + return 0, false + } + + // Mask off high 4 bits and multiply low 4 bits by 4 + return uint32(in[offset]&0x0f) * 4, true +} + +func inBounds(inLen int, offset int, size int) bool { + return offset+size <= inLen +} + +func loadCommon(in []byte, offset int, size int) (uint32, bool) { + if !inBounds(len(in), offset, size) { + return 0, false + } + + switch size { + case 1: + return uint32(in[offset]), true + case 2: + return uint32(binary.BigEndian.Uint16(in[offset : offset+size])), true + case 4: + return uint32(binary.BigEndian.Uint32(in[offset : offset+size])), true + default: + panic(fmt.Sprintf("invalid load size: %d", size)) + } +} + +func loadScratch(ins LoadScratch, regScratch [16]uint32, regA uint32, regX uint32) (uint32, uint32) { + switch ins.Dst { + case RegA: + regA = regScratch[ins.N] + case RegX: + regX = regScratch[ins.N] + } + + return regA, regX +} + +func storeScratch(ins StoreScratch, regScratch [16]uint32, regA uint32, regX uint32) [16]uint32 { + switch ins.Src { + case RegA: + regScratch[ins.N] = regA + case RegX: + regScratch[ins.N] = regX + } + + return regScratch +} diff --git a/vendor/golang.org/x/sys/unix/dev_aix_ppc.go b/vendor/golang.org/x/sys/unix/dev_aix_ppc.go index 27f92c99..5e5fb451 100644 --- a/vendor/golang.org/x/sys/unix/dev_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/dev_aix_ppc.go @@ -6,17 +6,7 @@ // +build ppc // Functions to access/create device major and minor numbers matching the -// encoding used by the Linux kernel and glibc. -// -// The information below is extracted and adapted from bits/sysmacros.h in the -// glibc sources: -// -// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's -// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major -// number and m is a hex digit of the minor number. This is backward compatible -// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also -// backward compatible with the Linux kernel, which for some architectures uses -// 32-bit dev_t, encoded as mmmM MMmm. +// encoding used by AIX. package unix diff --git a/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go b/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go index 65d93a68..8b401244 100644 --- a/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go @@ -6,17 +6,7 @@ // +build ppc64 // Functions to access/create device major and minor numbers matching the -// encoding used by the Linux kernel and glibc. -// -// The information below is extracted and adapted from bits/sysmacros.h in the -// glibc sources: -// -// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's -// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major -// number and m is a hex digit of the minor number. This is backward compatible -// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also -// backward compatible with the Linux kernel, which for some architectures uses -// 32-bit dev_t, encoded as mmmM MMmm. +// encoding used AIX. package unix diff --git a/vendor/golang.org/x/sys/unix/ioctl.go b/vendor/golang.org/x/sys/unix/ioctl.go index 8c9aaeb2..f121a8d6 100644 --- a/vendor/golang.org/x/sys/unix/ioctl.go +++ b/vendor/golang.org/x/sys/unix/ioctl.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package unix diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index a2baa818..7943853f 100755 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -46,6 +46,7 @@ includes_AIX=' #include #include #include +#include #include #include @@ -86,6 +87,7 @@ includes_DragonFly=' #include #include #include +#include #include #include #include @@ -191,8 +193,10 @@ struct ltchars { #include #include #include +#include #include #include +#include #include #include #include @@ -214,6 +218,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -244,6 +249,16 @@ struct ltchars { #define FS_KEY_DESC_PREFIX "fscrypt:" #define FS_KEY_DESC_PREFIX_SIZE 8 #define FS_MAX_KEY_SIZE 64 + +// XDP socket constants do not appear to be picked up otherwise. +// Copied from samples/bpf/xdpsock_user.c. +#ifndef SOL_XDP +#define SOL_XDP 283 +#endif + +#ifndef AF_XDP +#define AF_XDP 44 +#endif ' includes_NetBSD=' @@ -252,6 +267,7 @@ includes_NetBSD=' #include #include #include +#include #include #include #include @@ -277,6 +293,7 @@ includes_OpenBSD=' #include #include #include +#include #include #include #include @@ -378,6 +395,7 @@ ccflags="$@" $2 ~ /^EXTATTR_NAMESPACE_NAMES/ || $2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next} + $2 !~ /^ECCAPBITS/ && $2 !~ /^ETH_/ && $2 !~ /^EPROC_/ && $2 !~ /^EQUIV_/ && @@ -413,7 +431,7 @@ ccflags="$@" $2 ~ /^TC[IO](ON|OFF)$/ || $2 ~ /^IN_/ || $2 ~ /^LOCK_(SH|EX|NB|UN)$/ || - $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|T?PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ || + $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ || $2 ~ /^TP_STATUS_/ || $2 ~ /^FALLOC_/ || $2 == "ICMPV6_FILTER" || @@ -424,9 +442,11 @@ ccflags="$@" $2 ~ /^KERN_(HOSTNAME|OS(RELEASE|TYPE)|VERSION)$/ || $2 ~ /^HW_MACHINE$/ || $2 ~ /^SYSCTL_VERS/ || + $2 !~ "MNT_BITS" && $2 ~ /^(MS|MNT|UMOUNT)_/ || $2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ || $2 ~ /^(O|F|E?FD|NAME|S|PTRACE|PT)_/ || + $2 ~ /^KEXEC_/ || $2 ~ /^LINUX_REBOOT_CMD_/ || $2 ~ /^LINUX_REBOOT_MAGIC[12]$/ || $2 !~ "NLA_TYPE_MASK" && @@ -474,6 +494,7 @@ ccflags="$@" $2 ~ /^FSOPT_/ || $2 ~ /^WDIOC_/ || $2 ~ /^NFN/ || + $2 ~ /^XDP_/ || $2 ~ /^(HDIO|WIN|SMART)_/ || $2 !~ "WMESGLEN" && $2 ~ /^W[A-Z0-9]+$/ || diff --git a/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl b/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl index 49f186f8..20632e14 100755 --- a/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl +++ b/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl @@ -32,6 +32,7 @@ my @headers = qw ( sys/sem.h sys/shm.h sys/vmmeter.h + uvm/uvmexp.h uvm/uvm_param.h uvm/uvm_swap_encrypt.h ddb/db_var.h diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go index f153c067..9dd2f32f 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go @@ -12,7 +12,7 @@ import "unsafe" // Round the length of a raw sockaddr up to align it properly. func cmsgAlignOf(salen int) int { - salign := sizeofPtr + salign := SizeofPtr // NOTE: It seems like 64-bit Darwin, DragonFly BSD and // Solaris kernels still require 32-bit aligned access to // network subsystem. diff --git a/vendor/golang.org/x/sys/unix/syscall_aix.go b/vendor/golang.org/x/sys/unix/syscall_aix.go index 86d7c7bd..df1f9ea3 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix.go @@ -345,11 +345,11 @@ func IoctlSetInt(fd int, req uint, value int) error { return ioctl(fd, req, uintptr(value)) } -func IoctlSetWinsize(fd int, req uint, value *Winsize) error { +func ioctlSetWinsize(fd int, req uint, value *Winsize) error { return ioctl(fd, req, uintptr(unsafe.Pointer(value))) } -func IoctlSetTermios(fd int, req uint, value *Termios) error { +func ioctlSetTermios(fd int, req uint, value *Termios) error { return ioctl(fd, req, uintptr(unsafe.Pointer(value))) } @@ -419,8 +419,10 @@ func Flock(fd int, how int) (err error) { //sysnb Getsid(pid int) (sid int, err error) //sysnb Kill(pid int, sig syscall.Signal) (err error) //sys Klogctl(typ int, buf []byte) (n int, err error) = syslog +//sys Mkdir(dirfd int, path string, mode uint32) (err error) //sys Mkdirat(dirfd int, path string, mode uint32) (err error) //sys Mkfifo(path string, mode uint32) (err error) +//sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) = open64 diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index eb633540..bfa20a97 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -692,6 +692,24 @@ func (sa *SockaddrVM) sockaddr() (unsafe.Pointer, _Socklen, error) { return unsafe.Pointer(&sa.raw), SizeofSockaddrVM, nil } +type SockaddrXDP struct { + Flags uint16 + Ifindex uint32 + QueueID uint32 + SharedUmemFD uint32 + raw RawSockaddrXDP +} + +func (sa *SockaddrXDP) sockaddr() (unsafe.Pointer, _Socklen, error) { + sa.raw.Family = AF_XDP + sa.raw.Flags = sa.Flags + sa.raw.Ifindex = sa.Ifindex + sa.raw.Queue_id = sa.QueueID + sa.raw.Shared_umem_fd = sa.SharedUmemFD + + return unsafe.Pointer(&sa.raw), SizeofSockaddrXDP, nil +} + func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { switch rsa.Addr.Family { case AF_NETLINK: @@ -793,6 +811,15 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { } return sa, nil } + case AF_XDP: + pp := (*RawSockaddrXDP)(unsafe.Pointer(rsa)) + sa := &SockaddrXDP{ + Flags: pp.Flags, + Ifindex: pp.Ifindex, + QueueID: pp.Queue_id, + SharedUmemFD: pp.Shared_umem_fd, + } + return sa, nil } return nil, EAFNOSUPPORT } @@ -1095,7 +1122,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err erro // The ptrace syscall differs from glibc's ptrace. // Peeks returns the word in *data, not as the return value. - var buf [sizeofPtr]byte + var buf [SizeofPtr]byte // Leading edge. PEEKTEXT/PEEKDATA don't require aligned // access (PEEKUSER warns that it might), but if we don't @@ -1103,12 +1130,12 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err erro // boundary and not get the bytes leading up to the page // boundary. n := 0 - if addr%sizeofPtr != 0 { - err = ptrace(req, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) + if addr%SizeofPtr != 0 { + err = ptrace(req, pid, addr-addr%SizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) if err != nil { return 0, err } - n += copy(out, buf[addr%sizeofPtr:]) + n += copy(out, buf[addr%SizeofPtr:]) out = out[n:] } @@ -1146,15 +1173,15 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c // Leading edge. n := 0 - if addr%sizeofPtr != 0 { - var buf [sizeofPtr]byte - err = ptrace(peekReq, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) + if addr%SizeofPtr != 0 { + var buf [SizeofPtr]byte + err = ptrace(peekReq, pid, addr-addr%SizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) if err != nil { return 0, err } - n += copy(buf[addr%sizeofPtr:], data) + n += copy(buf[addr%SizeofPtr:], data) word := *((*uintptr)(unsafe.Pointer(&buf[0]))) - err = ptrace(pokeReq, pid, addr-addr%sizeofPtr, word) + err = ptrace(pokeReq, pid, addr-addr%SizeofPtr, word) if err != nil { return 0, err } @@ -1162,19 +1189,19 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c } // Interior. - for len(data) > sizeofPtr { + for len(data) > SizeofPtr { word := *((*uintptr)(unsafe.Pointer(&data[0]))) err = ptrace(pokeReq, pid, addr+uintptr(n), word) if err != nil { return n, err } - n += sizeofPtr - data = data[sizeofPtr:] + n += SizeofPtr + data = data[SizeofPtr:] } // Trailing edge. if len(data) > 0 { - var buf [sizeofPtr]byte + var buf [SizeofPtr]byte err = ptrace(peekReq, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0]))) if err != nil { return n, err @@ -1273,6 +1300,7 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri //sys Adjtimex(buf *Timex) (state int, err error) //sys Chdir(path string) (err error) //sys Chroot(path string) (err error) +//sys ClockGetres(clockid int32, res *Timespec) (err error) //sys ClockGettime(clockid int32, time *Timespec) (err error) //sys Close(fd int) (err error) //sys CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) @@ -1320,6 +1348,7 @@ func Getpgrp() (pid int) { //sys Llistxattr(path string, dest []byte) (sz int, err error) //sys Lremovexattr(path string, attr string) (err error) //sys Lsetxattr(path string, attr string, data []byte, flags int) (err error) +//sys MemfdCreate(name string, flags int) (fd int, err error) //sys Mkdirat(dirfd int, path string, mode uint32) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) @@ -1495,7 +1524,6 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { // Brk // Capget // Capset -// ClockGetres // ClockNanosleep // ClockSettime // Clone diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go index 5f9b2454..5247d9f9 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -160,3 +160,16 @@ func Poll(fds []PollFd, timeout int) (n int, err error) { } return poll(&fds[0], len(fds), timeout) } + +//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) + +func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { + cmdlineLen := len(cmdline) + if cmdlineLen > 0 { + // Account for the additional NULL byte added by + // BytePtrFromString in kexecFileLoad. The kexec_file_load + // syscall expects a NULL-terminated string. + cmdlineLen++ + } + return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go index 6a38dfd5..41451854 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -136,3 +136,16 @@ func SyncFileRange(fd int, off int64, n int64, flags int) error { // order of their arguments. return syncFileRange2(fd, flags, off, n) } + +//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) + +func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { + cmdlineLen := len(cmdline) + if cmdlineLen > 0 { + // Account for the additional NULL byte added by + // BytePtrFromString in kexecFileLoad. The kexec_file_load + // syscall expects a NULL-terminated string. + cmdlineLen++ + } + return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go index 6e4ee0cf..f52f148f 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -322,3 +322,16 @@ func Poll(fds []PollFd, timeout int) (n int, err error) { } return poll(&fds[0], len(fds), timeout) } + +//sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) + +func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { + cmdlineLen := len(cmdline) + if cmdlineLen > 0 { + // Account for the additional NULL byte added by + // BytePtrFromString in kexecFileLoad. The kexec_file_load + // syscall expects a NULL-terminated string. + cmdlineLen++ + } + return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/vendor/golang.org/x/sys/unix/syscall_netbsd.go index 6f8ebde3..206ce2af 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd.go @@ -93,6 +93,23 @@ func nametomib(name string) (mib []_C_int, err error) { return mib, nil } +func SysctlClockinfo(name string) (*Clockinfo, error) { + mib, err := sysctlmib(name) + if err != nil { + return nil, err + } + + n := uintptr(SizeofClockinfo) + var ci Clockinfo + if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil { + return nil, err + } + if n != SizeofClockinfo { + return nil, EIO + } + return &ci, nil +} + //sysnb pipe() (fd1 int, fd2 int, err error) func Pipe(p []int) (err error) { if len(p) != 2 { diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go index 07e6669c..2c674a5c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -43,6 +43,23 @@ func nametomib(name string) (mib []_C_int, err error) { return nil, EINVAL } +func SysctlUvmexp(name string) (*Uvmexp, error) { + mib, err := sysctlmib(name) + if err != nil { + return nil, err + } + + n := uintptr(SizeofUvmexp) + var u Uvmexp + if err := sysctl(mib, (*byte)(unsafe.Pointer(&u)), &n, nil, 0); err != nil { + return nil, err + } + if n != SizeofUvmexp { + return nil, EIO + } + return &u, nil +} + //sysnb pipe(p *[2]_C_int) (err error) func Pipe(p []int) (err error) { if len(p) != 2 { diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go index 13956b79..64fcda4a 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -22,10 +22,10 @@ var ( ) const ( - darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8 - dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8 - netbsd32Bit = runtime.GOOS == "netbsd" && sizeofPtr == 4 - solaris64Bit = runtime.GOOS == "solaris" && sizeofPtr == 8 + darwin64Bit = runtime.GOOS == "darwin" && SizeofPtr == 8 + dragonfly64Bit = runtime.GOOS == "dragonfly" && SizeofPtr == 8 + netbsd32Bit = runtime.GOOS == "netbsd" && SizeofPtr == 4 + solaris64Bit = runtime.GOOS == "solaris" && SizeofPtr == 8 ) // Do the interface allocations only once for common diff --git a/vendor/golang.org/x/sys/unix/types_aix.go b/vendor/golang.org/x/sys/unix/types_aix.go index 355ad6cf..25e83494 100644 --- a/vendor/golang.org/x/sys/unix/types_aix.go +++ b/vendor/golang.org/x/sys/unix/types_aix.go @@ -22,6 +22,11 @@ package unix #include #include #include +#include +#include +#include +#include +#include #include @@ -33,7 +38,6 @@ package unix #include #include -#include enum { sizeofPtr = sizeof(void*), @@ -55,14 +59,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong PathMax = C.PATH_MAX ) @@ -224,6 +228,9 @@ type Flock_t C.struct_flock64 // Statfs +type Fsid_t C.struct_fsid_t +type Fsid64_t C.struct_fsid64_t + type Statfs_t C.struct_statfs const RNDGETENTCNT = 0x80045200 diff --git a/vendor/golang.org/x/sys/unix/types_darwin.go b/vendor/golang.org/x/sys/unix/types_darwin.go index 46b9908e..9fd2aaa6 100644 --- a/vendor/golang.org/x/sys/unix/types_darwin.go +++ b/vendor/golang.org/x/sys/unix/types_darwin.go @@ -70,14 +70,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong ) // Basic types diff --git a/vendor/golang.org/x/sys/unix/types_dragonfly.go b/vendor/golang.org/x/sys/unix/types_dragonfly.go index 386d5f89..3365dd79 100644 --- a/vendor/golang.org/x/sys/unix/types_dragonfly.go +++ b/vendor/golang.org/x/sys/unix/types_dragonfly.go @@ -65,14 +65,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong ) // Basic types diff --git a/vendor/golang.org/x/sys/unix/types_freebsd.go b/vendor/golang.org/x/sys/unix/types_freebsd.go index e84a892d..a0a5843b 100644 --- a/vendor/golang.org/x/sys/unix/types_freebsd.go +++ b/vendor/golang.org/x/sys/unix/types_freebsd.go @@ -154,14 +154,14 @@ struct if_msghdr8 { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong ) // Basic types diff --git a/vendor/golang.org/x/sys/unix/types_netbsd.go b/vendor/golang.org/x/sys/unix/types_netbsd.go index 1494aafc..1edbf1ba 100644 --- a/vendor/golang.org/x/sys/unix/types_netbsd.go +++ b/vendor/golang.org/x/sys/unix/types_netbsd.go @@ -67,14 +67,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong ) // Basic types @@ -279,3 +279,9 @@ type Sysctlnode C.struct_sysctlnode // Uname type Utsname C.struct_utsname + +// Clockinfo + +const SizeofClockinfo = C.sizeof_struct_clockinfo + +type Clockinfo C.struct_clockinfo diff --git a/vendor/golang.org/x/sys/unix/types_openbsd.go b/vendor/golang.org/x/sys/unix/types_openbsd.go index 8f2fe704..297e40d3 100644 --- a/vendor/golang.org/x/sys/unix/types_openbsd.go +++ b/vendor/golang.org/x/sys/unix/types_openbsd.go @@ -38,6 +38,7 @@ package unix #include #include #include +#include #include #include #include @@ -66,14 +67,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong ) // Basic types @@ -263,3 +264,9 @@ const ( // Uname type Utsname C.struct_utsname + +// Uvmexp + +const SizeofUvmexp = C.sizeof_struct_uvmexp + +type Uvmexp C.struct_uvmexp diff --git a/vendor/golang.org/x/sys/unix/types_solaris.go b/vendor/golang.org/x/sys/unix/types_solaris.go index 8cef71bd..2b716f93 100644 --- a/vendor/golang.org/x/sys/unix/types_solaris.go +++ b/vendor/golang.org/x/sys/unix/types_solaris.go @@ -75,14 +75,14 @@ struct sockaddr_any { */ import "C" -// Machine characteristics; for internal use. +// Machine characteristics const ( - sizeofPtr = C.sizeofPtr - sizeofShort = C.sizeof_short - sizeofInt = C.sizeof_int - sizeofLong = C.sizeof_long - sizeofLongLong = C.sizeof_longlong + SizeofPtr = C.sizeofPtr + SizeofShort = C.sizeof_short + SizeofInt = C.sizeof_int + SizeofLong = C.sizeof_long + SizeofLongLong = C.sizeof_longlong PathMax = C.PATH_MAX MaxHostNameLen = C.MAXHOSTNAMELEN ) diff --git a/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go index 17c1537f..4b7b9650 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go @@ -867,6 +867,9 @@ const ( TAB2 = 0x800 TAB3 = 0xc00 TABDLY = 0xc00 + TCFLSH = 0x540c + TCGETA = 0x5405 + TCGETS = 0x5401 TCIFLUSH = 0x0 TCIOFF = 0x2 TCIOFLUSH = 0x2 @@ -915,6 +918,15 @@ const ( TCP_TIMESTAMP_OPTLEN = 0xc TCP_UNSETPRIV = 0x28 TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETSF = 0x5404 + TCSETSW = 0x5403 + TCXONC = 0x540b + TIOC = 0x5400 TIOCCBRK = 0x2000747a TIOCCDTR = 0x20007478 TIOCCONS = 0x80047462 diff --git a/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go index fdfd25cc..ed04fd1b 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go @@ -867,6 +867,9 @@ const ( TAB2 = 0x800 TAB3 = 0xc00 TABDLY = 0xc00 + TCFLSH = 0x540c + TCGETA = 0x5405 + TCGETS = 0x5401 TCIFLUSH = 0x0 TCIOFF = 0x2 TCIOFLUSH = 0x2 @@ -915,6 +918,15 @@ const ( TCP_TIMESTAMP_OPTLEN = 0xc TCP_UNSETPRIV = 0x28 TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETSF = 0x5404 + TCSETSW = 0x5403 + TCXONC = 0x540b + TIOC = 0x5400 TIOCCBRK = 0x2000747a TIOCCDTR = 0x20007478 TIOCCONS = 0xffffffff80047462 diff --git a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go index 1de69989..bbe6089b 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go @@ -880,6 +880,40 @@ const ( MAP_VPAGETABLE = 0x2000 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_AUTOMOUNTED = 0x20 + MNT_CMDFLAGS = 0xf0000 + MNT_DEFEXPORTED = 0x200 + MNT_DELEXPORT = 0x20000 + MNT_EXKERB = 0x800 + MNT_EXPORTANON = 0x400 + MNT_EXPORTED = 0x100 + MNT_EXPUBLIC = 0x20000000 + MNT_EXRDONLY = 0x80 + MNT_FORCE = 0x80000 + MNT_IGNORE = 0x800000 + MNT_LAZY = 0x4 + MNT_LOCAL = 0x1000 + MNT_NOATIME = 0x10000000 + MNT_NOCLUSTERR = 0x40000000 + MNT_NOCLUSTERW = 0x80000000 + MNT_NODEV = 0x10 + MNT_NOEXEC = 0x4 + MNT_NOSUID = 0x8 + MNT_NOSYMFOLLOW = 0x400000 + MNT_NOWAIT = 0x2 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SOFTDEP = 0x200000 + MNT_SUIDDIR = 0x100000 + MNT_SYNCHRONOUS = 0x2 + MNT_TRIM = 0x1000000 + MNT_UPDATE = 0x10000 + MNT_USER = 0x8000 + MNT_VISFLAGMASK = 0xf1f0ffff + MNT_WAIT = 0x1 MSG_CMSG_CLOEXEC = 0x1000 MSG_CTRUNC = 0x20 MSG_DONTROUTE = 0x4 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index f33613ee..86b980a5 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -64,6 +64,7 @@ const ( AF_VSOCK = 0x28 AF_WANPIPE = 0x19 AF_X25 = 0x9 + AF_XDP = 0x2c ALG_OP_DECRYPT = 0x0 ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 @@ -878,6 +879,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 @@ -977,6 +998,21 @@ const ( MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MCL_ONFAULT = 0x4 + MFD_ALLOW_SEALING = 0x2 + MFD_CLOEXEC = 0x1 + MFD_HUGETLB = 0x4 + MFD_HUGE_16GB = -0x78000000 + MFD_HUGE_16MB = 0x60000000 + MFD_HUGE_1GB = 0x78000000 + MFD_HUGE_1MB = 0x50000000 + MFD_HUGE_256MB = 0x70000000 + MFD_HUGE_2GB = 0x7c000000 + MFD_HUGE_2MB = 0x54000000 + MFD_HUGE_512KB = 0x4c000000 + MFD_HUGE_64KB = 0x40000000 + MFD_HUGE_8MB = 0x5c000000 + MFD_HUGE_MASK = 0x3f + MFD_HUGE_SHIFT = 0x1a MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -1796,6 +1832,7 @@ const ( SOL_TIPC = 0x10f SOL_TLS = 0x11a SOL_X25 = 0x106 + SOL_XDP = 0x11b SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x1e SO_ATTACH_BPF = 0x32 @@ -2278,6 +2315,26 @@ const ( XATTR_CREATE = 0x1 XATTR_REPLACE = 0x2 XCASE = 0x4 + XDP_COPY = 0x2 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MASK = 0xf + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + XDP_MMAP_OFFSETS = 0x1 + XDP_PGOFF_RX_RING = 0x0 + XDP_PGOFF_TX_RING = 0x80000000 + XDP_RX_RING = 0x2 + XDP_SHARED_UMEM = 0x1 + XDP_STATISTICS = 0x7 + XDP_TX_RING = 0x3 + XDP_UMEM_COMPLETION_RING = 0x6 + XDP_UMEM_FILL_RING = 0x5 + XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 + XDP_UMEM_PGOFF_FILL_RING = 0x100000000 + XDP_UMEM_REG = 0x4 + XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XTABS = 0x1800 ZSMALLOC_MAGIC = 0x58295829 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index ccdbebf6..28631157 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -64,6 +64,7 @@ const ( AF_VSOCK = 0x28 AF_WANPIPE = 0x19 AF_X25 = 0x9 + AF_XDP = 0x2c ALG_OP_DECRYPT = 0x0 ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 @@ -878,6 +879,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 @@ -977,6 +998,21 @@ const ( MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MCL_ONFAULT = 0x4 + MFD_ALLOW_SEALING = 0x2 + MFD_CLOEXEC = 0x1 + MFD_HUGETLB = 0x4 + MFD_HUGE_16GB = -0x78000000 + MFD_HUGE_16MB = 0x60000000 + MFD_HUGE_1GB = 0x78000000 + MFD_HUGE_1MB = 0x50000000 + MFD_HUGE_256MB = 0x70000000 + MFD_HUGE_2GB = 0x7c000000 + MFD_HUGE_2MB = 0x54000000 + MFD_HUGE_512KB = 0x4c000000 + MFD_HUGE_64KB = 0x40000000 + MFD_HUGE_8MB = 0x5c000000 + MFD_HUGE_MASK = 0x3f + MFD_HUGE_SHIFT = 0x1a MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -1797,6 +1833,7 @@ const ( SOL_TIPC = 0x10f SOL_TLS = 0x11a SOL_X25 = 0x106 + SOL_XDP = 0x11b SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x1e SO_ATTACH_BPF = 0x32 @@ -2278,6 +2315,26 @@ const ( XATTR_CREATE = 0x1 XATTR_REPLACE = 0x2 XCASE = 0x4 + XDP_COPY = 0x2 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MASK = 0xf + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + XDP_MMAP_OFFSETS = 0x1 + XDP_PGOFF_RX_RING = 0x0 + XDP_PGOFF_TX_RING = 0x80000000 + XDP_RX_RING = 0x2 + XDP_SHARED_UMEM = 0x1 + XDP_STATISTICS = 0x7 + XDP_TX_RING = 0x3 + XDP_UMEM_COMPLETION_RING = 0x6 + XDP_UMEM_FILL_RING = 0x5 + XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 + XDP_UMEM_PGOFF_FILL_RING = 0x100000000 + XDP_UMEM_REG = 0x4 + XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XTABS = 0x1800 ZSMALLOC_MAGIC = 0x58295829 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 770d4c73..1b58da1e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -64,6 +64,7 @@ const ( AF_VSOCK = 0x28 AF_WANPIPE = 0x19 AF_X25 = 0x9 + AF_XDP = 0x2c ALG_OP_DECRYPT = 0x0 ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 @@ -877,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 @@ -975,6 +996,21 @@ const ( MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MCL_ONFAULT = 0x4 + MFD_ALLOW_SEALING = 0x2 + MFD_CLOEXEC = 0x1 + MFD_HUGETLB = 0x4 + MFD_HUGE_16GB = -0x78000000 + MFD_HUGE_16MB = 0x60000000 + MFD_HUGE_1GB = 0x78000000 + MFD_HUGE_1MB = 0x50000000 + MFD_HUGE_256MB = 0x70000000 + MFD_HUGE_2GB = 0x7c000000 + MFD_HUGE_2MB = 0x54000000 + MFD_HUGE_512KB = 0x4c000000 + MFD_HUGE_64KB = 0x40000000 + MFD_HUGE_8MB = 0x5c000000 + MFD_HUGE_MASK = 0x3f + MFD_HUGE_SHIFT = 0x1a MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -1803,6 +1839,7 @@ const ( SOL_TIPC = 0x10f SOL_TLS = 0x11a SOL_X25 = 0x106 + SOL_XDP = 0x11b SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x1e SO_ATTACH_BPF = 0x32 @@ -2284,6 +2321,26 @@ const ( XATTR_CREATE = 0x1 XATTR_REPLACE = 0x2 XCASE = 0x4 + XDP_COPY = 0x2 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MASK = 0xf + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + XDP_MMAP_OFFSETS = 0x1 + XDP_PGOFF_RX_RING = 0x0 + XDP_PGOFF_TX_RING = 0x80000000 + XDP_RX_RING = 0x2 + XDP_SHARED_UMEM = 0x1 + XDP_STATISTICS = 0x7 + XDP_TX_RING = 0x3 + XDP_UMEM_COMPLETION_RING = 0x6 + XDP_UMEM_FILL_RING = 0x5 + XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 + XDP_UMEM_PGOFF_FILL_RING = 0x100000000 + XDP_UMEM_REG = 0x4 + XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XTABS = 0x1800 ZSMALLOC_MAGIC = 0x58295829 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index c3e311db..08377eb4 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -64,6 +64,7 @@ const ( AF_VSOCK = 0x28 AF_WANPIPE = 0x19 AF_X25 = 0x9 + AF_XDP = 0x2c ALG_OP_DECRYPT = 0x0 ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 @@ -880,6 +881,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 @@ -978,6 +999,21 @@ const ( MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MCL_ONFAULT = 0x4 + MFD_ALLOW_SEALING = 0x2 + MFD_CLOEXEC = 0x1 + MFD_HUGETLB = 0x4 + MFD_HUGE_16GB = -0x78000000 + MFD_HUGE_16MB = 0x60000000 + MFD_HUGE_1GB = 0x78000000 + MFD_HUGE_1MB = 0x50000000 + MFD_HUGE_256MB = 0x70000000 + MFD_HUGE_2GB = 0x7c000000 + MFD_HUGE_2MB = 0x54000000 + MFD_HUGE_512KB = 0x4c000000 + MFD_HUGE_64KB = 0x40000000 + MFD_HUGE_8MB = 0x5c000000 + MFD_HUGE_MASK = 0x3f + MFD_HUGE_SHIFT = 0x1a MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -1787,6 +1823,7 @@ const ( SOL_TIPC = 0x10f SOL_TLS = 0x11a SOL_X25 = 0x106 + SOL_XDP = 0x11b SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x1e SO_ATTACH_BPF = 0x32 @@ -2269,6 +2306,26 @@ const ( XATTR_CREATE = 0x1 XATTR_REPLACE = 0x2 XCASE = 0x4 + XDP_COPY = 0x2 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MASK = 0xf + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + XDP_MMAP_OFFSETS = 0x1 + XDP_PGOFF_RX_RING = 0x0 + XDP_PGOFF_TX_RING = 0x80000000 + XDP_RX_RING = 0x2 + XDP_SHARED_UMEM = 0x1 + XDP_STATISTICS = 0x7 + XDP_TX_RING = 0x3 + XDP_UMEM_COMPLETION_RING = 0x6 + XDP_UMEM_FILL_RING = 0x5 + XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 + XDP_UMEM_PGOFF_FILL_RING = 0x100000000 + XDP_UMEM_REG = 0x4 + XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XTABS = 0x1800 ZSMALLOC_MAGIC = 0x58295829 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index 9fee271d..5de2c7aa 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -64,6 +64,7 @@ const ( AF_VSOCK = 0x28 AF_WANPIPE = 0x19 AF_X25 = 0x9 + AF_XDP = 0x2c ALG_OP_DECRYPT = 0x0 ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 @@ -877,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 @@ -975,6 +996,21 @@ const ( MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MCL_ONFAULT = 0x4 + MFD_ALLOW_SEALING = 0x2 + MFD_CLOEXEC = 0x1 + MFD_HUGETLB = 0x4 + MFD_HUGE_16GB = -0x78000000 + MFD_HUGE_16MB = 0x60000000 + MFD_HUGE_1GB = 0x78000000 + MFD_HUGE_1MB = 0x50000000 + MFD_HUGE_256MB = 0x70000000 + MFD_HUGE_2GB = 0x7c000000 + MFD_HUGE_2MB = 0x54000000 + MFD_HUGE_512KB = 0x4c000000 + MFD_HUGE_64KB = 0x40000000 + MFD_HUGE_8MB = 0x5c000000 + MFD_HUGE_MASK = 0x3f + MFD_HUGE_SHIFT = 0x1a MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -1796,6 +1832,7 @@ const ( SOL_TIPC = 0x10f SOL_TLS = 0x11a SOL_X25 = 0x106 + SOL_XDP = 0x11b SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x1009 SO_ATTACH_BPF = 0x32 @@ -2280,6 +2317,26 @@ const ( XATTR_CREATE = 0x1 XATTR_REPLACE = 0x2 XCASE = 0x4 + XDP_COPY = 0x2 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MASK = 0xf + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + XDP_MMAP_OFFSETS = 0x1 + XDP_PGOFF_RX_RING = 0x0 + XDP_PGOFF_TX_RING = 0x80000000 + XDP_RX_RING = 0x2 + XDP_SHARED_UMEM = 0x1 + XDP_STATISTICS = 0x7 + XDP_TX_RING = 0x3 + XDP_UMEM_COMPLETION_RING = 0x6 + XDP_UMEM_FILL_RING = 0x5 + XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 + XDP_UMEM_PGOFF_FILL_RING = 0x100000000 + XDP_UMEM_REG = 0x4 + XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XTABS = 0x1800 ZSMALLOC_MAGIC = 0x58295829 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index d022427b..51015f35 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -64,6 +64,7 @@ const ( AF_VSOCK = 0x28 AF_WANPIPE = 0x19 AF_X25 = 0x9 + AF_XDP = 0x2c ALG_OP_DECRYPT = 0x0 ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 @@ -877,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 @@ -975,6 +996,21 @@ const ( MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MCL_ONFAULT = 0x4 + MFD_ALLOW_SEALING = 0x2 + MFD_CLOEXEC = 0x1 + MFD_HUGETLB = 0x4 + MFD_HUGE_16GB = -0x78000000 + MFD_HUGE_16MB = 0x60000000 + MFD_HUGE_1GB = 0x78000000 + MFD_HUGE_1MB = 0x50000000 + MFD_HUGE_256MB = 0x70000000 + MFD_HUGE_2GB = 0x7c000000 + MFD_HUGE_2MB = 0x54000000 + MFD_HUGE_512KB = 0x4c000000 + MFD_HUGE_64KB = 0x40000000 + MFD_HUGE_8MB = 0x5c000000 + MFD_HUGE_MASK = 0x3f + MFD_HUGE_SHIFT = 0x1a MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -1796,6 +1832,7 @@ const ( SOL_TIPC = 0x10f SOL_TLS = 0x11a SOL_X25 = 0x106 + SOL_XDP = 0x11b SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x1009 SO_ATTACH_BPF = 0x32 @@ -2280,6 +2317,26 @@ const ( XATTR_CREATE = 0x1 XATTR_REPLACE = 0x2 XCASE = 0x4 + XDP_COPY = 0x2 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MASK = 0xf + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + XDP_MMAP_OFFSETS = 0x1 + XDP_PGOFF_RX_RING = 0x0 + XDP_PGOFF_TX_RING = 0x80000000 + XDP_RX_RING = 0x2 + XDP_SHARED_UMEM = 0x1 + XDP_STATISTICS = 0x7 + XDP_TX_RING = 0x3 + XDP_UMEM_COMPLETION_RING = 0x6 + XDP_UMEM_FILL_RING = 0x5 + XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 + XDP_UMEM_PGOFF_FILL_RING = 0x100000000 + XDP_UMEM_REG = 0x4 + XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XTABS = 0x1800 ZSMALLOC_MAGIC = 0x58295829 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index 509faae7..fdd388de 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -64,6 +64,7 @@ const ( AF_VSOCK = 0x28 AF_WANPIPE = 0x19 AF_X25 = 0x9 + AF_XDP = 0x2c ALG_OP_DECRYPT = 0x0 ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 @@ -877,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 @@ -975,6 +996,21 @@ const ( MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MCL_ONFAULT = 0x4 + MFD_ALLOW_SEALING = 0x2 + MFD_CLOEXEC = 0x1 + MFD_HUGETLB = 0x4 + MFD_HUGE_16GB = -0x78000000 + MFD_HUGE_16MB = 0x60000000 + MFD_HUGE_1GB = 0x78000000 + MFD_HUGE_1MB = 0x50000000 + MFD_HUGE_256MB = 0x70000000 + MFD_HUGE_2GB = 0x7c000000 + MFD_HUGE_2MB = 0x54000000 + MFD_HUGE_512KB = 0x4c000000 + MFD_HUGE_64KB = 0x40000000 + MFD_HUGE_8MB = 0x5c000000 + MFD_HUGE_MASK = 0x3f + MFD_HUGE_SHIFT = 0x1a MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -1796,6 +1832,7 @@ const ( SOL_TIPC = 0x10f SOL_TLS = 0x11a SOL_X25 = 0x106 + SOL_XDP = 0x11b SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x1009 SO_ATTACH_BPF = 0x32 @@ -2280,6 +2317,26 @@ const ( XATTR_CREATE = 0x1 XATTR_REPLACE = 0x2 XCASE = 0x4 + XDP_COPY = 0x2 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MASK = 0xf + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + XDP_MMAP_OFFSETS = 0x1 + XDP_PGOFF_RX_RING = 0x0 + XDP_PGOFF_TX_RING = 0x80000000 + XDP_RX_RING = 0x2 + XDP_SHARED_UMEM = 0x1 + XDP_STATISTICS = 0x7 + XDP_TX_RING = 0x3 + XDP_UMEM_COMPLETION_RING = 0x6 + XDP_UMEM_FILL_RING = 0x5 + XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 + XDP_UMEM_PGOFF_FILL_RING = 0x100000000 + XDP_UMEM_REG = 0x4 + XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XTABS = 0x1800 ZSMALLOC_MAGIC = 0x58295829 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 340f78af..2d150461 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -64,6 +64,7 @@ const ( AF_VSOCK = 0x28 AF_WANPIPE = 0x19 AF_X25 = 0x9 + AF_XDP = 0x2c ALG_OP_DECRYPT = 0x0 ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 @@ -877,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 @@ -975,6 +996,21 @@ const ( MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MCL_ONFAULT = 0x4 + MFD_ALLOW_SEALING = 0x2 + MFD_CLOEXEC = 0x1 + MFD_HUGETLB = 0x4 + MFD_HUGE_16GB = -0x78000000 + MFD_HUGE_16MB = 0x60000000 + MFD_HUGE_1GB = 0x78000000 + MFD_HUGE_1MB = 0x50000000 + MFD_HUGE_256MB = 0x70000000 + MFD_HUGE_2GB = 0x7c000000 + MFD_HUGE_2MB = 0x54000000 + MFD_HUGE_512KB = 0x4c000000 + MFD_HUGE_64KB = 0x40000000 + MFD_HUGE_8MB = 0x5c000000 + MFD_HUGE_MASK = 0x3f + MFD_HUGE_SHIFT = 0x1a MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -1796,6 +1832,7 @@ const ( SOL_TIPC = 0x10f SOL_TLS = 0x11a SOL_X25 = 0x106 + SOL_XDP = 0x11b SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x1009 SO_ATTACH_BPF = 0x32 @@ -2280,6 +2317,26 @@ const ( XATTR_CREATE = 0x1 XATTR_REPLACE = 0x2 XCASE = 0x4 + XDP_COPY = 0x2 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MASK = 0xf + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + XDP_MMAP_OFFSETS = 0x1 + XDP_PGOFF_RX_RING = 0x0 + XDP_PGOFF_TX_RING = 0x80000000 + XDP_RX_RING = 0x2 + XDP_SHARED_UMEM = 0x1 + XDP_STATISTICS = 0x7 + XDP_TX_RING = 0x3 + XDP_UMEM_COMPLETION_RING = 0x6 + XDP_UMEM_FILL_RING = 0x5 + XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 + XDP_UMEM_PGOFF_FILL_RING = 0x100000000 + XDP_UMEM_REG = 0x4 + XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XTABS = 0x1800 ZSMALLOC_MAGIC = 0x58295829 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index 4e80d6aa..cd8fcd35 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -64,6 +64,7 @@ const ( AF_VSOCK = 0x28 AF_WANPIPE = 0x19 AF_X25 = 0x9 + AF_XDP = 0x2c ALG_OP_DECRYPT = 0x0 ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 @@ -877,6 +878,26 @@ const ( IXOFF = 0x400 IXON = 0x200 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 @@ -974,6 +995,21 @@ const ( MCL_CURRENT = 0x2000 MCL_FUTURE = 0x4000 MCL_ONFAULT = 0x8000 + MFD_ALLOW_SEALING = 0x2 + MFD_CLOEXEC = 0x1 + MFD_HUGETLB = 0x4 + MFD_HUGE_16GB = -0x78000000 + MFD_HUGE_16MB = 0x60000000 + MFD_HUGE_1GB = 0x78000000 + MFD_HUGE_1MB = 0x50000000 + MFD_HUGE_256MB = 0x70000000 + MFD_HUGE_2GB = 0x7c000000 + MFD_HUGE_2MB = 0x54000000 + MFD_HUGE_512KB = 0x4c000000 + MFD_HUGE_64KB = 0x40000000 + MFD_HUGE_8MB = 0x5c000000 + MFD_HUGE_MASK = 0x3f + MFD_HUGE_SHIFT = 0x1a MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -1852,6 +1888,7 @@ const ( SOL_TIPC = 0x10f SOL_TLS = 0x11a SOL_X25 = 0x106 + SOL_XDP = 0x11b SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x1e SO_ATTACH_BPF = 0x32 @@ -2337,6 +2374,26 @@ const ( XATTR_CREATE = 0x1 XATTR_REPLACE = 0x2 XCASE = 0x4000 + XDP_COPY = 0x2 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MASK = 0xf + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + XDP_MMAP_OFFSETS = 0x1 + XDP_PGOFF_RX_RING = 0x0 + XDP_PGOFF_TX_RING = 0x80000000 + XDP_RX_RING = 0x2 + XDP_SHARED_UMEM = 0x1 + XDP_STATISTICS = 0x7 + XDP_TX_RING = 0x3 + XDP_UMEM_COMPLETION_RING = 0x6 + XDP_UMEM_FILL_RING = 0x5 + XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 + XDP_UMEM_PGOFF_FILL_RING = 0x100000000 + XDP_UMEM_REG = 0x4 + XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XTABS = 0xc00 ZSMALLOC_MAGIC = 0x58295829 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index f22c0d68..cdb60887 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -64,6 +64,7 @@ const ( AF_VSOCK = 0x28 AF_WANPIPE = 0x19 AF_X25 = 0x9 + AF_XDP = 0x2c ALG_OP_DECRYPT = 0x0 ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 @@ -877,6 +878,26 @@ const ( IXOFF = 0x400 IXON = 0x200 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 @@ -974,6 +995,21 @@ const ( MCL_CURRENT = 0x2000 MCL_FUTURE = 0x4000 MCL_ONFAULT = 0x8000 + MFD_ALLOW_SEALING = 0x2 + MFD_CLOEXEC = 0x1 + MFD_HUGETLB = 0x4 + MFD_HUGE_16GB = -0x78000000 + MFD_HUGE_16MB = 0x60000000 + MFD_HUGE_1GB = 0x78000000 + MFD_HUGE_1MB = 0x50000000 + MFD_HUGE_256MB = 0x70000000 + MFD_HUGE_2GB = 0x7c000000 + MFD_HUGE_2MB = 0x54000000 + MFD_HUGE_512KB = 0x4c000000 + MFD_HUGE_64KB = 0x40000000 + MFD_HUGE_8MB = 0x5c000000 + MFD_HUGE_MASK = 0x3f + MFD_HUGE_SHIFT = 0x1a MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -1852,6 +1888,7 @@ const ( SOL_TIPC = 0x10f SOL_TLS = 0x11a SOL_X25 = 0x106 + SOL_XDP = 0x11b SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x1e SO_ATTACH_BPF = 0x32 @@ -2337,6 +2374,26 @@ const ( XATTR_CREATE = 0x1 XATTR_REPLACE = 0x2 XCASE = 0x4000 + XDP_COPY = 0x2 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MASK = 0xf + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + XDP_MMAP_OFFSETS = 0x1 + XDP_PGOFF_RX_RING = 0x0 + XDP_PGOFF_TX_RING = 0x80000000 + XDP_RX_RING = 0x2 + XDP_SHARED_UMEM = 0x1 + XDP_STATISTICS = 0x7 + XDP_TX_RING = 0x3 + XDP_UMEM_COMPLETION_RING = 0x6 + XDP_UMEM_FILL_RING = 0x5 + XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 + XDP_UMEM_PGOFF_FILL_RING = 0x100000000 + XDP_UMEM_REG = 0x4 + XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XTABS = 0xc00 ZSMALLOC_MAGIC = 0x58295829 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 0978dba1..9e9472be 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -64,6 +64,7 @@ const ( AF_VSOCK = 0x28 AF_WANPIPE = 0x19 AF_X25 = 0x9 + AF_XDP = 0x2c ALG_OP_DECRYPT = 0x0 ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 @@ -877,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 @@ -975,6 +996,21 @@ const ( MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MCL_ONFAULT = 0x4 + MFD_ALLOW_SEALING = 0x2 + MFD_CLOEXEC = 0x1 + MFD_HUGETLB = 0x4 + MFD_HUGE_16GB = -0x78000000 + MFD_HUGE_16MB = 0x60000000 + MFD_HUGE_1GB = 0x78000000 + MFD_HUGE_1MB = 0x50000000 + MFD_HUGE_256MB = 0x70000000 + MFD_HUGE_2GB = 0x7c000000 + MFD_HUGE_2MB = 0x54000000 + MFD_HUGE_512KB = 0x4c000000 + MFD_HUGE_64KB = 0x40000000 + MFD_HUGE_8MB = 0x5c000000 + MFD_HUGE_MASK = 0x3f + MFD_HUGE_SHIFT = 0x1a MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -1784,6 +1820,7 @@ const ( SOL_TIPC = 0x10f SOL_TLS = 0x11a SOL_X25 = 0x106 + SOL_XDP = 0x11b SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x1e SO_ATTACH_BPF = 0x32 @@ -2265,6 +2302,26 @@ const ( XATTR_CREATE = 0x1 XATTR_REPLACE = 0x2 XCASE = 0x4 + XDP_COPY = 0x2 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MASK = 0xf + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + XDP_MMAP_OFFSETS = 0x1 + XDP_PGOFF_RX_RING = 0x0 + XDP_PGOFF_TX_RING = 0x80000000 + XDP_RX_RING = 0x2 + XDP_SHARED_UMEM = 0x1 + XDP_STATISTICS = 0x7 + XDP_TX_RING = 0x3 + XDP_UMEM_COMPLETION_RING = 0x6 + XDP_UMEM_FILL_RING = 0x5 + XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 + XDP_UMEM_PGOFF_FILL_RING = 0x100000000 + XDP_UMEM_REG = 0x4 + XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XTABS = 0x1800 ZSMALLOC_MAGIC = 0x58295829 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 5a057da4..f33d031a 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -64,6 +64,7 @@ const ( AF_VSOCK = 0x28 AF_WANPIPE = 0x19 AF_X25 = 0x9 + AF_XDP = 0x2c ALG_OP_DECRYPT = 0x0 ALG_OP_ENCRYPT = 0x1 ALG_SET_AEAD_ASSOCLEN = 0x4 @@ -877,6 +878,26 @@ const ( IXOFF = 0x1000 IXON = 0x400 JFFS2_SUPER_MAGIC = 0x72b6 + KEXEC_ARCH_386 = 0x30000 + KEXEC_ARCH_68K = 0x40000 + KEXEC_ARCH_AARCH64 = 0xb70000 + KEXEC_ARCH_ARM = 0x280000 + KEXEC_ARCH_DEFAULT = 0x0 + KEXEC_ARCH_IA_64 = 0x320000 + KEXEC_ARCH_MASK = 0xffff0000 + KEXEC_ARCH_MIPS = 0x80000 + KEXEC_ARCH_MIPS_LE = 0xa0000 + KEXEC_ARCH_PPC = 0x140000 + KEXEC_ARCH_PPC64 = 0x150000 + KEXEC_ARCH_S390 = 0x160000 + KEXEC_ARCH_SH = 0x2a0000 + KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_FILE_NO_INITRAMFS = 0x4 + KEXEC_FILE_ON_CRASH = 0x2 + KEXEC_FILE_UNLOAD = 0x1 + KEXEC_ON_CRASH = 0x1 + KEXEC_PRESERVE_CONTEXT = 0x2 + KEXEC_SEGMENT_MAX = 0x10 KEYCTL_ASSUME_AUTHORITY = 0x10 KEYCTL_CHOWN = 0x4 KEYCTL_CLEAR = 0x7 @@ -975,6 +996,21 @@ const ( MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MCL_ONFAULT = 0x4 + MFD_ALLOW_SEALING = 0x2 + MFD_CLOEXEC = 0x1 + MFD_HUGETLB = 0x4 + MFD_HUGE_16GB = -0x78000000 + MFD_HUGE_16MB = 0x60000000 + MFD_HUGE_1GB = 0x78000000 + MFD_HUGE_1MB = 0x50000000 + MFD_HUGE_256MB = 0x70000000 + MFD_HUGE_2GB = 0x7c000000 + MFD_HUGE_2MB = 0x54000000 + MFD_HUGE_512KB = 0x4c000000 + MFD_HUGE_64KB = 0x40000000 + MFD_HUGE_8MB = 0x5c000000 + MFD_HUGE_MASK = 0x3f + MFD_HUGE_SHIFT = 0x1a MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -1857,6 +1893,7 @@ const ( SOL_TIPC = 0x10f SOL_TLS = 0x11a SOL_X25 = 0x106 + SOL_XDP = 0x11b SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x1e SO_ATTACH_BPF = 0x32 @@ -2338,6 +2375,26 @@ const ( XATTR_CREATE = 0x1 XATTR_REPLACE = 0x2 XCASE = 0x4 + XDP_COPY = 0x2 + XDP_FLAGS_DRV_MODE = 0x4 + XDP_FLAGS_HW_MODE = 0x8 + XDP_FLAGS_MASK = 0xf + XDP_FLAGS_MODES = 0xe + XDP_FLAGS_SKB_MODE = 0x2 + XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1 + XDP_MMAP_OFFSETS = 0x1 + XDP_PGOFF_RX_RING = 0x0 + XDP_PGOFF_TX_RING = 0x80000000 + XDP_RX_RING = 0x2 + XDP_SHARED_UMEM = 0x1 + XDP_STATISTICS = 0x7 + XDP_TX_RING = 0x3 + XDP_UMEM_COMPLETION_RING = 0x6 + XDP_UMEM_FILL_RING = 0x5 + XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 + XDP_UMEM_PGOFF_FILL_RING = 0x100000000 + XDP_UMEM_REG = 0x4 + XDP_ZEROCOPY = 0x4 XENFS_SUPER_MAGIC = 0xabba1974 XTABS = 0x1800 ZSMALLOC_MAGIC = 0x58295829 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index 7fdc85b1..ba93f3e5 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -1,10 +1,10 @@ -// mkerrors.sh -m64 -// Code generated by the command above; DO NOT EDIT. +// mkerrors.sh -Wall -Werror -static -I/tmp/include +// Code generated by the command above; see README.md. DO NOT EDIT. // +build sparc64,linux -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs -- -m64 _const.go +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs -- -Wall -Werror -static -I/tmp/include _const.go package unix @@ -1969,174 +1969,182 @@ const ( ) // Error table -var errors = [...]string{ - 1: "operation not permitted", - 2: "no such file or directory", - 3: "no such process", - 4: "interrupted system call", - 5: "input/output error", - 6: "no such device or address", - 7: "argument list too long", - 8: "exec format error", - 9: "bad file descriptor", - 10: "no child processes", - 11: "resource temporarily unavailable", - 12: "cannot allocate memory", - 13: "permission denied", - 14: "bad address", - 15: "block device required", - 16: "device or resource busy", - 17: "file exists", - 18: "invalid cross-device link", - 19: "no such device", - 20: "not a directory", - 21: "is a directory", - 22: "invalid argument", - 23: "too many open files in system", - 24: "too many open files", - 25: "inappropriate ioctl for device", - 26: "text file busy", - 27: "file too large", - 28: "no space left on device", - 29: "illegal seek", - 30: "read-only file system", - 31: "too many links", - 32: "broken pipe", - 33: "numerical argument out of domain", - 34: "numerical result out of range", - 36: "operation now in progress", - 37: "operation already in progress", - 38: "socket operation on non-socket", - 39: "destination address required", - 40: "message too long", - 41: "protocol wrong type for socket", - 42: "protocol not available", - 43: "protocol not supported", - 44: "socket type not supported", - 45: "operation not supported", - 46: "protocol family not supported", - 47: "address family not supported by protocol", - 48: "address already in use", - 49: "cannot assign requested address", - 50: "network is down", - 51: "network is unreachable", - 52: "network dropped connection on reset", - 53: "software caused connection abort", - 54: "connection reset by peer", - 55: "no buffer space available", - 56: "transport endpoint is already connected", - 57: "transport endpoint is not connected", - 58: "cannot send after transport endpoint shutdown", - 59: "too many references: cannot splice", - 60: "connection timed out", - 61: "connection refused", - 62: "too many levels of symbolic links", - 63: "file name too long", - 64: "host is down", - 65: "no route to host", - 66: "directory not empty", - 67: "too many processes", - 68: "too many users", - 69: "disk quota exceeded", - 70: "stale file handle", - 71: "object is remote", - 72: "device not a stream", - 73: "timer expired", - 74: "out of streams resources", - 75: "no message of desired type", - 76: "bad message", - 77: "identifier removed", - 78: "resource deadlock avoided", - 79: "no locks available", - 80: "machine is not on the network", - 81: "unknown error 81", - 82: "link has been severed", - 83: "advertise error", - 84: "srmount error", - 85: "communication error on send", - 86: "protocol error", - 87: "multihop attempted", - 88: "RFS specific error", - 89: "remote address changed", - 90: "function not implemented", - 91: "streams pipe error", - 92: "value too large for defined data type", - 93: "file descriptor in bad state", - 94: "channel number out of range", - 95: "level 2 not synchronized", - 96: "level 3 halted", - 97: "level 3 reset", - 98: "link number out of range", - 99: "protocol driver not attached", - 100: "no CSI structure available", - 101: "level 2 halted", - 102: "invalid exchange", - 103: "invalid request descriptor", - 104: "exchange full", - 105: "no anode", - 106: "invalid request code", - 107: "invalid slot", - 108: "file locking deadlock error", - 109: "bad font file format", - 110: "cannot exec a shared library directly", - 111: "no data available", - 112: "accessing a corrupted shared library", - 113: "package not installed", - 114: "can not access a needed shared library", - 115: "name not unique on network", - 116: "interrupted system call should be restarted", - 117: "structure needs cleaning", - 118: "not a XENIX named type file", - 119: "no XENIX semaphores available", - 120: "is a named type file", - 121: "remote I/O error", - 122: "invalid or incomplete multibyte or wide character", - 123: "attempting to link in too many shared libraries", - 124: ".lib section in a.out corrupted", - 125: "no medium found", - 126: "wrong medium type", - 127: "operation canceled", - 128: "required key not available", - 129: "key has expired", - 130: "key has been revoked", - 131: "key was rejected by service", - 132: "owner died", - 133: "state not recoverable", - 134: "operation not possible due to RF-kill", - 135: "memory page has hardware error", +var errorList = [...]struct { + num syscall.Errno + name string + desc string +}{ + {1, "EPERM", "operation not permitted"}, + {2, "ENOENT", "no such file or directory"}, + {3, "ESRCH", "no such process"}, + {4, "EINTR", "interrupted system call"}, + {5, "EIO", "input/output error"}, + {6, "ENXIO", "no such device or address"}, + {7, "E2BIG", "argument list too long"}, + {8, "ENOEXEC", "exec format error"}, + {9, "EBADF", "bad file descriptor"}, + {10, "ECHILD", "no child processes"}, + {11, "EAGAIN", "resource temporarily unavailable"}, + {12, "ENOMEM", "cannot allocate memory"}, + {13, "EACCES", "permission denied"}, + {14, "EFAULT", "bad address"}, + {15, "ENOTBLK", "block device required"}, + {16, "EBUSY", "device or resource busy"}, + {17, "EEXIST", "file exists"}, + {18, "EXDEV", "invalid cross-device link"}, + {19, "ENODEV", "no such device"}, + {20, "ENOTDIR", "not a directory"}, + {21, "EISDIR", "is a directory"}, + {22, "EINVAL", "invalid argument"}, + {23, "ENFILE", "too many open files in system"}, + {24, "EMFILE", "too many open files"}, + {25, "ENOTTY", "inappropriate ioctl for device"}, + {26, "ETXTBSY", "text file busy"}, + {27, "EFBIG", "file too large"}, + {28, "ENOSPC", "no space left on device"}, + {29, "ESPIPE", "illegal seek"}, + {30, "EROFS", "read-only file system"}, + {31, "EMLINK", "too many links"}, + {32, "EPIPE", "broken pipe"}, + {33, "EDOM", "numerical argument out of domain"}, + {34, "ERANGE", "numerical result out of range"}, + {36, "EINPROGRESS", "operation now in progress"}, + {37, "EALREADY", "operation already in progress"}, + {38, "ENOTSOCK", "socket operation on non-socket"}, + {39, "EDESTADDRREQ", "destination address required"}, + {40, "EMSGSIZE", "message too long"}, + {41, "EPROTOTYPE", "protocol wrong type for socket"}, + {42, "ENOPROTOOPT", "protocol not available"}, + {43, "EPROTONOSUPPORT", "protocol not supported"}, + {44, "ESOCKTNOSUPPORT", "socket type not supported"}, + {45, "ENOTSUP", "operation not supported"}, + {46, "EPFNOSUPPORT", "protocol family not supported"}, + {47, "EAFNOSUPPORT", "address family not supported by protocol"}, + {48, "EADDRINUSE", "address already in use"}, + {49, "EADDRNOTAVAIL", "cannot assign requested address"}, + {50, "ENETDOWN", "network is down"}, + {51, "ENETUNREACH", "network is unreachable"}, + {52, "ENETRESET", "network dropped connection on reset"}, + {53, "ECONNABORTED", "software caused connection abort"}, + {54, "ECONNRESET", "connection reset by peer"}, + {55, "ENOBUFS", "no buffer space available"}, + {56, "EISCONN", "transport endpoint is already connected"}, + {57, "ENOTCONN", "transport endpoint is not connected"}, + {58, "ESHUTDOWN", "cannot send after transport endpoint shutdown"}, + {59, "ETOOMANYREFS", "too many references: cannot splice"}, + {60, "ETIMEDOUT", "connection timed out"}, + {61, "ECONNREFUSED", "connection refused"}, + {62, "ELOOP", "too many levels of symbolic links"}, + {63, "ENAMETOOLONG", "file name too long"}, + {64, "EHOSTDOWN", "host is down"}, + {65, "EHOSTUNREACH", "no route to host"}, + {66, "ENOTEMPTY", "directory not empty"}, + {67, "EPROCLIM", "too many processes"}, + {68, "EUSERS", "too many users"}, + {69, "EDQUOT", "disk quota exceeded"}, + {70, "ESTALE", "stale file handle"}, + {71, "EREMOTE", "object is remote"}, + {72, "ENOSTR", "device not a stream"}, + {73, "ETIME", "timer expired"}, + {74, "ENOSR", "out of streams resources"}, + {75, "ENOMSG", "no message of desired type"}, + {76, "EBADMSG", "bad message"}, + {77, "EIDRM", "identifier removed"}, + {78, "EDEADLK", "resource deadlock avoided"}, + {79, "ENOLCK", "no locks available"}, + {80, "ENONET", "machine is not on the network"}, + {81, "ERREMOTE", "unknown error 81"}, + {82, "ENOLINK", "link has been severed"}, + {83, "EADV", "advertise error"}, + {84, "ESRMNT", "srmount error"}, + {85, "ECOMM", "communication error on send"}, + {86, "EPROTO", "protocol error"}, + {87, "EMULTIHOP", "multihop attempted"}, + {88, "EDOTDOT", "RFS specific error"}, + {89, "EREMCHG", "remote address changed"}, + {90, "ENOSYS", "function not implemented"}, + {91, "ESTRPIPE", "streams pipe error"}, + {92, "EOVERFLOW", "value too large for defined data type"}, + {93, "EBADFD", "file descriptor in bad state"}, + {94, "ECHRNG", "channel number out of range"}, + {95, "EL2NSYNC", "level 2 not synchronized"}, + {96, "EL3HLT", "level 3 halted"}, + {97, "EL3RST", "level 3 reset"}, + {98, "ELNRNG", "link number out of range"}, + {99, "EUNATCH", "protocol driver not attached"}, + {100, "ENOCSI", "no CSI structure available"}, + {101, "EL2HLT", "level 2 halted"}, + {102, "EBADE", "invalid exchange"}, + {103, "EBADR", "invalid request descriptor"}, + {104, "EXFULL", "exchange full"}, + {105, "ENOANO", "no anode"}, + {106, "EBADRQC", "invalid request code"}, + {107, "EBADSLT", "invalid slot"}, + {108, "EDEADLOCK", "file locking deadlock error"}, + {109, "EBFONT", "bad font file format"}, + {110, "ELIBEXEC", "cannot exec a shared library directly"}, + {111, "ENODATA", "no data available"}, + {112, "ELIBBAD", "accessing a corrupted shared library"}, + {113, "ENOPKG", "package not installed"}, + {114, "ELIBACC", "can not access a needed shared library"}, + {115, "ENOTUNIQ", "name not unique on network"}, + {116, "ERESTART", "interrupted system call should be restarted"}, + {117, "EUCLEAN", "structure needs cleaning"}, + {118, "ENOTNAM", "not a XENIX named type file"}, + {119, "ENAVAIL", "no XENIX semaphores available"}, + {120, "EISNAM", "is a named type file"}, + {121, "EREMOTEIO", "remote I/O error"}, + {122, "EILSEQ", "invalid or incomplete multibyte or wide character"}, + {123, "ELIBMAX", "attempting to link in too many shared libraries"}, + {124, "ELIBSCN", ".lib section in a.out corrupted"}, + {125, "ENOMEDIUM", "no medium found"}, + {126, "EMEDIUMTYPE", "wrong medium type"}, + {127, "ECANCELED", "operation canceled"}, + {128, "ENOKEY", "required key not available"}, + {129, "EKEYEXPIRED", "key has expired"}, + {130, "EKEYREVOKED", "key has been revoked"}, + {131, "EKEYREJECTED", "key was rejected by service"}, + {132, "EOWNERDEAD", "owner died"}, + {133, "ENOTRECOVERABLE", "state not recoverable"}, + {134, "ERFKILL", "operation not possible due to RF-kill"}, + {135, "EHWPOISON", "memory page has hardware error"}, } // Signal table -var signals = [...]string{ - 1: "hangup", - 2: "interrupt", - 3: "quit", - 4: "illegal instruction", - 5: "trace/breakpoint trap", - 6: "aborted", - 7: "EMT trap", - 8: "floating point exception", - 9: "killed", - 10: "bus error", - 11: "segmentation fault", - 12: "bad system call", - 13: "broken pipe", - 14: "alarm clock", - 15: "terminated", - 16: "urgent I/O condition", - 17: "stopped (signal)", - 18: "stopped", - 19: "continued", - 20: "child exited", - 21: "stopped (tty input)", - 22: "stopped (tty output)", - 23: "I/O possible", - 24: "CPU time limit exceeded", - 25: "file size limit exceeded", - 26: "virtual timer expired", - 27: "profiling timer expired", - 28: "window changed", - 29: "resource lost", - 30: "user defined signal 1", - 31: "user defined signal 2", +var signalList = [...]struct { + num syscall.Signal + name string + desc string +}{ + {1, "SIGHUP", "hangup"}, + {2, "SIGINT", "interrupt"}, + {3, "SIGQUIT", "quit"}, + {4, "SIGILL", "illegal instruction"}, + {5, "SIGTRAP", "trace/breakpoint trap"}, + {6, "SIGABRT", "aborted"}, + {7, "SIGEMT", "EMT trap"}, + {8, "SIGFPE", "floating point exception"}, + {9, "SIGKILL", "killed"}, + {10, "SIGBUS", "bus error"}, + {11, "SIGSEGV", "segmentation fault"}, + {12, "SIGSYS", "bad system call"}, + {13, "SIGPIPE", "broken pipe"}, + {14, "SIGALRM", "alarm clock"}, + {15, "SIGTERM", "terminated"}, + {16, "SIGURG", "urgent I/O condition"}, + {17, "SIGSTOP", "stopped (signal)"}, + {18, "SIGTSTP", "stopped"}, + {19, "SIGCONT", "continued"}, + {20, "SIGCHLD", "child exited"}, + {21, "SIGTTIN", "stopped (tty input)"}, + {22, "SIGTTOU", "stopped (tty output)"}, + {23, "SIGIO", "I/O possible"}, + {24, "SIGXCPU", "CPU time limit exceeded"}, + {25, "SIGXFSZ", "file size limit exceeded"}, + {26, "SIGVTALRM", "virtual timer expired"}, + {27, "SIGPROF", "profiling timer expired"}, + {28, "SIGWINCH", "window changed"}, + {29, "SIGLOST", "power failure"}, + {30, "SIGUSR1", "user defined signal 1"}, + {31, "SIGUSR2", "user defined signal 2"}, } diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go index 19316b1d..78cc04ea 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go @@ -1020,6 +1020,43 @@ const ( MAP_WIRED = 0x800 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_BASIC_FLAGS = 0xe782807f + MNT_DEFEXPORTED = 0x200 + MNT_DISCARD = 0x800000 + MNT_EXKERB = 0x800 + MNT_EXNORESPORT = 0x8000000 + MNT_EXPORTANON = 0x400 + MNT_EXPORTED = 0x100 + MNT_EXPUBLIC = 0x10000000 + MNT_EXRDONLY = 0x80 + MNT_EXTATTR = 0x1000000 + MNT_FORCE = 0x80000 + MNT_GETARGS = 0x400000 + MNT_IGNORE = 0x100000 + MNT_LAZY = 0x3 + MNT_LOCAL = 0x1000 + MNT_LOG = 0x2000000 + MNT_NOATIME = 0x4000000 + MNT_NOCOREDUMP = 0x8000 + MNT_NODEV = 0x10 + MNT_NODEVMTIME = 0x40000000 + MNT_NOEXEC = 0x4 + MNT_NOSUID = 0x8 + MNT_NOWAIT = 0x2 + MNT_OP_FLAGS = 0x4d0000 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELATIME = 0x20000 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SOFTDEP = 0x80000000 + MNT_SYMPERM = 0x20000000 + MNT_SYNCHRONOUS = 0x2 + MNT_UNION = 0x20 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0xff90ffff + MNT_WAIT = 0x1 MSG_BCAST = 0x100 MSG_CMSG_CLOEXEC = 0x800 MSG_CONTROLMBUF = 0x2000000 @@ -1113,7 +1150,10 @@ const ( RLIMIT_CPU = 0x0 RLIMIT_DATA = 0x2 RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 RLIMIT_STACK = 0x3 RLIM_INFINITY = 0x7fffffffffffffff RTAX_AUTHOR = 0x6 diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go index f2cf500f..92185e69 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go @@ -1010,6 +1010,43 @@ const ( MAP_WIRED = 0x800 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_BASIC_FLAGS = 0xe782807f + MNT_DEFEXPORTED = 0x200 + MNT_DISCARD = 0x800000 + MNT_EXKERB = 0x800 + MNT_EXNORESPORT = 0x8000000 + MNT_EXPORTANON = 0x400 + MNT_EXPORTED = 0x100 + MNT_EXPUBLIC = 0x10000000 + MNT_EXRDONLY = 0x80 + MNT_EXTATTR = 0x1000000 + MNT_FORCE = 0x80000 + MNT_GETARGS = 0x400000 + MNT_IGNORE = 0x100000 + MNT_LAZY = 0x3 + MNT_LOCAL = 0x1000 + MNT_LOG = 0x2000000 + MNT_NOATIME = 0x4000000 + MNT_NOCOREDUMP = 0x8000 + MNT_NODEV = 0x10 + MNT_NODEVMTIME = 0x40000000 + MNT_NOEXEC = 0x4 + MNT_NOSUID = 0x8 + MNT_NOWAIT = 0x2 + MNT_OP_FLAGS = 0x4d0000 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELATIME = 0x20000 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SOFTDEP = 0x80000000 + MNT_SYMPERM = 0x20000000 + MNT_SYNCHRONOUS = 0x2 + MNT_UNION = 0x20 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0xff90ffff + MNT_WAIT = 0x1 MSG_BCAST = 0x100 MSG_CMSG_CLOEXEC = 0x800 MSG_CONTROLMBUF = 0x2000000 @@ -1103,7 +1140,10 @@ const ( RLIMIT_CPU = 0x0 RLIMIT_DATA = 0x2 RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 RLIMIT_STACK = 0x3 RLIM_INFINITY = 0x7fffffffffffffff RTAX_AUTHOR = 0x6 diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go index 858e2999..373ad454 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go @@ -1000,6 +1000,43 @@ const ( MAP_STACK = 0x2000 MAP_TRYFIXED = 0x400 MAP_WIRED = 0x800 + MNT_ASYNC = 0x40 + MNT_BASIC_FLAGS = 0xe782807f + MNT_DEFEXPORTED = 0x200 + MNT_DISCARD = 0x800000 + MNT_EXKERB = 0x800 + MNT_EXNORESPORT = 0x8000000 + MNT_EXPORTANON = 0x400 + MNT_EXPORTED = 0x100 + MNT_EXPUBLIC = 0x10000000 + MNT_EXRDONLY = 0x80 + MNT_EXTATTR = 0x1000000 + MNT_FORCE = 0x80000 + MNT_GETARGS = 0x400000 + MNT_IGNORE = 0x100000 + MNT_LAZY = 0x3 + MNT_LOCAL = 0x1000 + MNT_LOG = 0x2000000 + MNT_NOATIME = 0x4000000 + MNT_NOCOREDUMP = 0x8000 + MNT_NODEV = 0x10 + MNT_NODEVMTIME = 0x40000000 + MNT_NOEXEC = 0x4 + MNT_NOSUID = 0x8 + MNT_NOWAIT = 0x2 + MNT_OP_FLAGS = 0x4d0000 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELATIME = 0x20000 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SOFTDEP = 0x80000000 + MNT_SYMPERM = 0x20000000 + MNT_SYNCHRONOUS = 0x2 + MNT_UNION = 0x20 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0xff90ffff + MNT_WAIT = 0x1 MSG_BCAST = 0x100 MSG_CMSG_CLOEXEC = 0x800 MSG_CONTROLMBUF = 0x2000000 @@ -1093,7 +1130,10 @@ const ( RLIMIT_CPU = 0x0 RLIMIT_DATA = 0x2 RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 RLIMIT_STACK = 0x3 RLIM_INFINITY = 0x7fffffffffffffff RTAX_AUTHOR = 0x6 diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go index 7d92f2c5..d8be0451 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go @@ -899,6 +899,32 @@ const ( MAP_TRYFIXED = 0x400 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_DEFEXPORTED = 0x200 + MNT_DELEXPORT = 0x20000 + MNT_DOOMED = 0x8000000 + MNT_EXPORTANON = 0x400 + MNT_EXPORTED = 0x100 + MNT_EXRDONLY = 0x80 + MNT_FORCE = 0x80000 + MNT_LAZY = 0x3 + MNT_LOCAL = 0x1000 + MNT_NOATIME = 0x8000 + MNT_NODEV = 0x10 + MNT_NOEXEC = 0x4 + MNT_NOSUID = 0x8 + MNT_NOWAIT = 0x2 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SOFTDEP = 0x4000000 + MNT_SYNCHRONOUS = 0x2 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0x400ffff + MNT_WAIT = 0x1 + MNT_WANTRDWR = 0x2000000 + MNT_WXALLOWED = 0x800 MSG_BCAST = 0x100 MSG_CTRUNC = 0x20 MSG_DONTROUTE = 0x4 diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go index b0a7ebaf..1f9e8a29 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go @@ -939,6 +939,34 @@ const ( MAP_TRYFIXED = 0x0 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_DEFEXPORTED = 0x200 + MNT_DELEXPORT = 0x20000 + MNT_DOOMED = 0x8000000 + MNT_EXPORTANON = 0x400 + MNT_EXPORTED = 0x100 + MNT_EXRDONLY = 0x80 + MNT_FORCE = 0x80000 + MNT_LAZY = 0x3 + MNT_LOCAL = 0x1000 + MNT_NOATIME = 0x8000 + MNT_NODEV = 0x10 + MNT_NOEXEC = 0x4 + MNT_NOPERM = 0x20 + MNT_NOSUID = 0x8 + MNT_NOWAIT = 0x2 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SOFTDEP = 0x4000000 + MNT_STALLED = 0x100000 + MNT_SYNCHRONOUS = 0x2 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0x400ffff + MNT_WAIT = 0x1 + MNT_WANTRDWR = 0x2000000 + MNT_WXALLOWED = 0x800 MSG_BCAST = 0x100 MSG_CMSG_CLOEXEC = 0x800 MSG_CTRUNC = 0x20 @@ -1415,6 +1443,8 @@ const ( TIOCUCNTL_CBRK = 0x7a TIOCUCNTL_SBRK = 0x7b TOSTOP = 0x400000 + UTIME_NOW = -0x2 + UTIME_OMIT = -0x1 VDISCARD = 0xf VDSUSP = 0xb VEOF = 0x0 diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go index 50c1d9f3..79d5695c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go @@ -899,6 +899,32 @@ const ( MAP_TRYFIXED = 0x0 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_DEFEXPORTED = 0x200 + MNT_DELEXPORT = 0x20000 + MNT_DOOMED = 0x8000000 + MNT_EXPORTANON = 0x400 + MNT_EXPORTED = 0x100 + MNT_EXRDONLY = 0x80 + MNT_FORCE = 0x80000 + MNT_LAZY = 0x3 + MNT_LOCAL = 0x1000 + MNT_NOATIME = 0x8000 + MNT_NODEV = 0x10 + MNT_NOEXEC = 0x4 + MNT_NOSUID = 0x8 + MNT_NOWAIT = 0x2 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SOFTDEP = 0x4000000 + MNT_SYNCHRONOUS = 0x2 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0x400ffff + MNT_WAIT = 0x1 + MNT_WANTRDWR = 0x2000000 + MNT_WXALLOWED = 0x800 MSG_BCAST = 0x100 MSG_CMSG_CLOEXEC = 0x800 MSG_CTRUNC = 0x20 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go index 46d0652f..ab2f7612 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go @@ -39,8 +39,10 @@ int getrusage(int, uintptr_t); int getsid(int); int kill(int, int); int syslog(int, uintptr_t, size_t); +int mkdir(int, uintptr_t, unsigned int); int mkdirat(int, uintptr_t, unsigned int); int mkfifo(uintptr_t, unsigned int); +int mknod(uintptr_t, unsigned int, int); int mknodat(int, uintptr_t, unsigned int, int); int nanosleep(uintptr_t, uintptr_t); int open64(uintptr_t, int, unsigned int); @@ -502,6 +504,17 @@ func Klogctl(typ int, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mkdir(dirfd int, path string, mode uint32) (err error) { + _p0 := uintptr(unsafe.Pointer(C.CString(path))) + r0, er := C.mkdir(C.int(dirfd), C.uintptr_t(_p0), C.uint(mode)) + if r0 == -1 && er != nil { + err = er + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { _p0 := uintptr(unsafe.Pointer(C.CString(path))) r0, er := C.mkdirat(C.int(dirfd), C.uintptr_t(_p0), C.uint(mode)) @@ -524,6 +537,17 @@ func Mkfifo(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mknod(path string, mode uint32, dev int) (err error) { + _p0 := uintptr(unsafe.Pointer(C.CString(path))) + r0, er := C.mknod(C.uintptr_t(_p0), C.uint(mode), C.int(dev)) + if r0 == -1 && er != nil { + err = er + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { _p0 := uintptr(unsafe.Pointer(C.CString(path))) r0, er := C.mknodat(C.int(dirfd), C.uintptr_t(_p0), C.uint(mode), C.int(dev)) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go index b33f9ecc..2e4f93fb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go @@ -39,8 +39,10 @@ int getrusage(int, uintptr_t); int getsid(int); int kill(int, int); int syslog(int, uintptr_t, size_t); +int mkdir(int, uintptr_t, unsigned int); int mkdirat(int, uintptr_t, unsigned int); int mkfifo(uintptr_t, unsigned int); +int mknod(uintptr_t, unsigned int, int); int mknodat(int, uintptr_t, unsigned int, int); int nanosleep(uintptr_t, uintptr_t); int open64(uintptr_t, int, unsigned int); @@ -502,6 +504,17 @@ func Klogctl(typ int, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mkdir(dirfd int, path string, mode uint32) (err error) { + _p0 := uintptr(unsafe.Pointer(C.CString(path))) + r0, er := C.mkdir(C.int(dirfd), C.uintptr_t(_p0), C.uint(mode)) + if r0 == -1 && er != nil { + err = er + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { _p0 := uintptr(unsafe.Pointer(C.CString(path))) r0, er := C.mkdirat(C.int(dirfd), C.uintptr_t(_p0), C.uint(mode)) @@ -524,6 +537,17 @@ func Mkfifo(path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mknod(path string, mode uint32, dev int) (err error) { + _p0 := uintptr(unsafe.Pointer(C.CString(path))) + r0, er := C.mknod(C.uintptr_t(_p0), C.uint(mode), C.int(dev)) + if r0 == -1 && er != nil { + err = er + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { _p0 := uintptr(unsafe.Pointer(C.CString(path))) r0, er := C.mknodat(C.int(dirfd), C.uintptr_t(_p0), C.uint(mode), C.int(dev)) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go index 8e8d427d..35b155a0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -417,6 +417,16 @@ func Chroot(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockGetres(clockid int32, res *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockGettime(clockid int32, time *Timespec) (err error) { _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) if e1 != 0 { @@ -979,6 +989,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdCreate(name string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index 2f60780c..46e9ddfb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -417,6 +417,16 @@ func Chroot(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockGetres(clockid int32, res *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockGettime(clockid int32, time *Timespec) (err error) { _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) if e1 != 0 { @@ -979,6 +989,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdCreate(name string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -2270,3 +2296,18 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(cmdline) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go index d29a11c9..914f25f0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -417,6 +417,16 @@ func Chroot(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockGetres(clockid int32, res *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockGettime(clockid int32, time *Timespec) (err error) { _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) if e1 != 0 { @@ -979,6 +989,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdCreate(name string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go index d03eb296..1d6c5562 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -417,6 +417,16 @@ func Chroot(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockGetres(clockid int32, res *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockGettime(clockid int32, time *Timespec) (err error) { _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) if e1 != 0 { @@ -979,6 +989,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdCreate(name string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go index dea09328..260631d1 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go @@ -417,6 +417,16 @@ func Chroot(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockGetres(clockid int32, res *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockGettime(clockid int32, time *Timespec) (err error) { _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) if e1 != 0 { @@ -979,6 +989,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdCreate(name string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go index 31bbcff4..ff2d84fb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -417,6 +417,16 @@ func Chroot(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockGetres(clockid int32, res *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockGettime(clockid int32, time *Timespec) (err error) { _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) if e1 != 0 { @@ -979,6 +989,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdCreate(name string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go index e025a33a..48d14e60 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -417,6 +417,16 @@ func Chroot(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockGetres(clockid int32, res *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockGettime(clockid int32, time *Timespec) (err error) { _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) if e1 != 0 { @@ -979,6 +989,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdCreate(name string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go index 57d7d931..12c17a92 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go @@ -417,6 +417,16 @@ func Chroot(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockGetres(clockid int32, res *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockGettime(clockid int32, time *Timespec) (err error) { _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) if e1 != 0 { @@ -979,6 +989,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdCreate(name string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index f3fae1d1..c8ca4279 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -417,6 +417,16 @@ func Chroot(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockGetres(clockid int32, res *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockGettime(clockid int32, time *Timespec) (err error) { _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) if e1 != 0 { @@ -979,6 +989,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdCreate(name string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -2317,3 +2343,18 @@ func syncFileRange2(fd int, flags int, off int64, n int64) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(cmdline) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index 011b0a53..870c8f6d 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -417,6 +417,16 @@ func Chroot(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockGetres(clockid int32, res *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockGettime(clockid int32, time *Timespec) (err error) { _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) if e1 != 0 { @@ -979,6 +989,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdCreate(name string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -2317,3 +2343,18 @@ func syncFileRange2(fd int, flags int, off int64, n int64) (err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(cmdline) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go index b086f7ed..542f3a3a 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go @@ -417,6 +417,16 @@ func Chroot(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockGetres(clockid int32, res *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockGettime(clockid int32, time *Timespec) (err error) { _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) if e1 != 0 { @@ -979,6 +989,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdCreate(name string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index c637da95..55e79d64 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -417,6 +417,16 @@ func Chroot(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ClockGetres(clockid int32, res *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ClockGettime(clockid int32, time *Timespec) (err error) { _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) if e1 != 0 { @@ -979,6 +989,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func MemfdCreate(name string, flags int) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -2087,3 +2113,18 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(cmdline) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go index 90c95c2c..d014451c 100644 --- a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_amd64.go @@ -254,4 +254,17 @@ var sysctlMib = []mibentry{ {"net.mpls.ttl", []_C_int{4, 33, 2}}, {"net.pflow.stats", []_C_int{4, 34, 1}}, {"net.pipex.enable", []_C_int{4, 35, 1}}, + {"vm.anonmin", []_C_int{2, 7}}, + {"vm.loadavg", []_C_int{2, 2}}, + {"vm.maxslp", []_C_int{2, 10}}, + {"vm.nkmempages", []_C_int{2, 6}}, + {"vm.psstrings", []_C_int{2, 3}}, + {"vm.swapencrypt.enable", []_C_int{2, 5, 0}}, + {"vm.swapencrypt.keyscreated", []_C_int{2, 5, 1}}, + {"vm.swapencrypt.keysdeleted", []_C_int{2, 5, 2}}, + {"vm.uspace", []_C_int{2, 11}}, + {"vm.uvmexp", []_C_int{2, 4}}, + {"vm.vmmeter", []_C_int{2, 1}}, + {"vm.vnodemin", []_C_int{2, 9}}, + {"vm.vtextmin", []_C_int{2, 8}}, } diff --git a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go index ee455365..cedc9b0f 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go +++ b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 PathMax = 0x3ff ) @@ -268,9 +268,22 @@ type Termios struct { Cc [16]uint8 } -type Termio struct{} +type Termio struct { + Iflag uint16 + Oflag uint16 + Cflag uint16 + Lflag uint16 + Line uint8 + Cc [8]uint8 + _ [1]byte +} -type Winsize struct{} +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} type PollFd struct { Fd int32 @@ -301,6 +314,32 @@ type Flock_t struct { Len int64 } -type Statfs_t struct{} +type Fsid_t struct { + Val [2]uint32 +} +type Fsid64_t struct { + Val [2]uint64 +} + +type Statfs_t struct { + Version int32 + Type int32 + Bsize uint32 + Blocks uint32 + Bfree uint32 + Bavail uint32 + Files uint32 + Ffree uint32 + Fsid Fsid_t + Vfstype int32 + Fsize uint32 + Vfsnumber int32 + Vfsoff int32 + Vfslen int32 + Vfsvers int32 + Fname [32]uint8 + Fpack [32]uint8 + Name_max int32 +} const RNDGETENTCNT = 0x80045200 diff --git a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go index cdb1699d..f46482d2 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x3ff ) @@ -275,9 +275,22 @@ type Termios struct { Cc [16]uint8 } -type Termio struct{} +type Termio struct { + Iflag uint16 + Oflag uint16 + Cflag uint16 + Lflag uint16 + Line uint8 + Cc [8]uint8 + _ [1]byte +} -type Winsize struct{} +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} type PollFd struct { Fd int32 @@ -308,6 +321,34 @@ type Flock_t struct { Len int64 } -type Statfs_t struct{} +type Fsid_t struct { + Val [2]uint32 +} +type Fsid64_t struct { + Val [2]uint64 +} + +type Statfs_t struct { + Version int32 + Type int32 + Bsize uint64 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid64_t + Vfstype int32 + _ [4]byte + Fsize uint64 + Vfsnumber int32 + Vfsoff int32 + Vfslen int32 + Vfsvers int32 + Fname [32]uint8 + Fpack [32]uint8 + Name_max int32 + _ [4]byte +} const RNDGETENTCNT = 0x80045200 diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go index 327af5fb..2aeb52a8 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index 116e6e07..0d0d9f2c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go index 2750ad76..04e344b7 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go @@ -7,11 +7,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index 8cead099..9fec185c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go index c01ae670..7b34e2e2 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go index 8006c563..11380294 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index 716774de..a6fc1271 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go index 92e07b00..6b3006d6 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index 1944dfb1..3879002a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -278,6 +278,14 @@ type RawSockaddrVM struct { Zero [4]uint8 } +type RawSockaddrXDP struct { + Family uint16 + Flags uint16 + Ifindex uint32 + Queue_id uint32 + Shared_umem_fd uint32 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -412,6 +420,7 @@ const ( SizeofSockaddrCAN = 0x10 SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 + SizeofSockaddrXDP = 0x10 SizeofLinger = 0x8 SizeofIovec = 0x8 SizeofIPMreq = 0x8 @@ -517,6 +526,13 @@ const ( RTA_PREF = 0x14 RTA_ENCAP_TYPE = 0x15 RTA_ENCAP = 0x16 + RTA_EXPIRES = 0x17 + RTA_PAD = 0x18 + RTA_UID = 0x19 + RTA_TTL_PROPAGATE = 0x1a + RTA_IP_PROTO = 0x1b + RTA_SPORT = 0x1c + RTA_DPORT = 0x1d RTN_UNSPEC = 0x0 RTN_UNICAST = 0x1 RTN_LOCAL = 0x2 @@ -1889,3 +1905,63 @@ const ( NETNSA_PID = 0x2 NETNSA_FD = 0x3 ) + +type XDPRingOffset struct { + Producer uint64 + Consumer uint64 + Desc uint64 +} + +type XDPMmapOffsets struct { + Rx XDPRingOffset + Tx XDPRingOffset + Fr XDPRingOffset + Cr XDPRingOffset +} + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 +} + +type XDPStatistics struct { + Rx_dropped uint64 + Rx_invalid_descs uint64 + Tx_invalid_descs uint64 +} + +type XDPDesc struct { + Addr uint64 + Len uint32 + Options uint32 +} + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index dd09289d..cbc2c7d0 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -280,6 +280,14 @@ type RawSockaddrVM struct { Zero [4]uint8 } +type RawSockaddrXDP struct { + Family uint16 + Flags uint16 + Ifindex uint32 + Queue_id uint32 + Shared_umem_fd uint32 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -416,6 +424,7 @@ const ( SizeofSockaddrCAN = 0x10 SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 + SizeofSockaddrXDP = 0x10 SizeofLinger = 0x8 SizeofIovec = 0x10 SizeofIPMreq = 0x8 @@ -521,6 +530,13 @@ const ( RTA_PREF = 0x14 RTA_ENCAP_TYPE = 0x15 RTA_ENCAP = 0x16 + RTA_EXPIRES = 0x17 + RTA_PAD = 0x18 + RTA_UID = 0x19 + RTA_TTL_PROPAGATE = 0x1a + RTA_IP_PROTO = 0x1b + RTA_SPORT = 0x1c + RTA_DPORT = 0x1d RTN_UNSPEC = 0x0 RTN_UNICAST = 0x1 RTN_LOCAL = 0x2 @@ -1911,3 +1927,63 @@ const ( NETNSA_PID = 0x2 NETNSA_FD = 0x3 ) + +type XDPRingOffset struct { + Producer uint64 + Consumer uint64 + Desc uint64 +} + +type XDPMmapOffsets struct { + Rx XDPRingOffset + Tx XDPRingOffset + Fr XDPRingOffset + Cr XDPRingOffset +} + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 +} + +type XDPStatistics struct { + Rx_dropped uint64 + Rx_invalid_descs uint64 + Tx_invalid_descs uint64 +} + +type XDPDesc struct { + Addr uint64 + Len uint32 + Options uint32 +} + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index d9e844d8..6ed804fa 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -281,6 +281,14 @@ type RawSockaddrVM struct { Zero [4]uint8 } +type RawSockaddrXDP struct { + Family uint16 + Flags uint16 + Ifindex uint32 + Queue_id uint32 + Shared_umem_fd uint32 +} + type RawSockaddr struct { Family uint16 Data [14]uint8 @@ -415,6 +423,7 @@ const ( SizeofSockaddrCAN = 0x10 SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 + SizeofSockaddrXDP = 0x10 SizeofLinger = 0x8 SizeofIovec = 0x8 SizeofIPMreq = 0x8 @@ -520,6 +529,13 @@ const ( RTA_PREF = 0x14 RTA_ENCAP_TYPE = 0x15 RTA_ENCAP = 0x16 + RTA_EXPIRES = 0x17 + RTA_PAD = 0x18 + RTA_UID = 0x19 + RTA_TTL_PROPAGATE = 0x1a + RTA_IP_PROTO = 0x1b + RTA_SPORT = 0x1c + RTA_DPORT = 0x1d RTN_UNSPEC = 0x0 RTN_UNICAST = 0x1 RTN_LOCAL = 0x2 @@ -1879,3 +1895,63 @@ const ( NETNSA_PID = 0x2 NETNSA_FD = 0x3 ) + +type XDPRingOffset struct { + Producer uint64 + Consumer uint64 + Desc uint64 +} + +type XDPMmapOffsets struct { + Rx XDPRingOffset + Tx XDPRingOffset + Fr XDPRingOffset + Cr XDPRingOffset +} + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 +} + +type XDPStatistics struct { + Rx_dropped uint64 + Rx_invalid_descs uint64 + Tx_invalid_descs uint64 +} + +type XDPDesc struct { + Addr uint64 + Len uint32 + Options uint32 +} + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index fd2471a3..b5fe7ddf 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -281,6 +281,14 @@ type RawSockaddrVM struct { Zero [4]uint8 } +type RawSockaddrXDP struct { + Family uint16 + Flags uint16 + Ifindex uint32 + Queue_id uint32 + Shared_umem_fd uint32 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -417,6 +425,7 @@ const ( SizeofSockaddrCAN = 0x10 SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 + SizeofSockaddrXDP = 0x10 SizeofLinger = 0x8 SizeofIovec = 0x10 SizeofIPMreq = 0x8 @@ -522,6 +531,13 @@ const ( RTA_PREF = 0x14 RTA_ENCAP_TYPE = 0x15 RTA_ENCAP = 0x16 + RTA_EXPIRES = 0x17 + RTA_PAD = 0x18 + RTA_UID = 0x19 + RTA_TTL_PROPAGATE = 0x1a + RTA_IP_PROTO = 0x1b + RTA_SPORT = 0x1c + RTA_DPORT = 0x1d RTN_UNSPEC = 0x0 RTN_UNICAST = 0x1 RTN_LOCAL = 0x2 @@ -1890,3 +1906,63 @@ const ( NETNSA_PID = 0x2 NETNSA_FD = 0x3 ) + +type XDPRingOffset struct { + Producer uint64 + Consumer uint64 + Desc uint64 +} + +type XDPMmapOffsets struct { + Rx XDPRingOffset + Tx XDPRingOffset + Fr XDPRingOffset + Cr XDPRingOffset +} + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 +} + +type XDPStatistics struct { + Rx_dropped uint64 + Rx_invalid_descs uint64 + Tx_invalid_descs uint64 +} + +type XDPDesc struct { + Addr uint64 + Len uint32 + Options uint32 +} + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index 89218d9d..7379ad2d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -279,6 +279,14 @@ type RawSockaddrVM struct { Zero [4]uint8 } +type RawSockaddrXDP struct { + Family uint16 + Flags uint16 + Ifindex uint32 + Queue_id uint32 + Shared_umem_fd uint32 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -413,6 +421,7 @@ const ( SizeofSockaddrCAN = 0x10 SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 + SizeofSockaddrXDP = 0x10 SizeofLinger = 0x8 SizeofIovec = 0x8 SizeofIPMreq = 0x8 @@ -518,6 +527,13 @@ const ( RTA_PREF = 0x14 RTA_ENCAP_TYPE = 0x15 RTA_ENCAP = 0x16 + RTA_EXPIRES = 0x17 + RTA_PAD = 0x18 + RTA_UID = 0x19 + RTA_TTL_PROPAGATE = 0x1a + RTA_IP_PROTO = 0x1b + RTA_SPORT = 0x1c + RTA_DPORT = 0x1d RTN_UNSPEC = 0x0 RTN_UNICAST = 0x1 RTN_LOCAL = 0x2 @@ -1884,3 +1900,63 @@ const ( NETNSA_PID = 0x2 NETNSA_FD = 0x3 ) + +type XDPRingOffset struct { + Producer uint64 + Consumer uint64 + Desc uint64 +} + +type XDPMmapOffsets struct { + Rx XDPRingOffset + Tx XDPRingOffset + Fr XDPRingOffset + Cr XDPRingOffset +} + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 +} + +type XDPStatistics struct { + Rx_dropped uint64 + Rx_invalid_descs uint64 + Tx_invalid_descs uint64 +} + +type XDPDesc struct { + Addr uint64 + Len uint32 + Options uint32 +} + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index 05990397..0b131a24 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -281,6 +281,14 @@ type RawSockaddrVM struct { Zero [4]uint8 } +type RawSockaddrXDP struct { + Family uint16 + Flags uint16 + Ifindex uint32 + Queue_id uint32 + Shared_umem_fd uint32 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -417,6 +425,7 @@ const ( SizeofSockaddrCAN = 0x10 SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 + SizeofSockaddrXDP = 0x10 SizeofLinger = 0x8 SizeofIovec = 0x10 SizeofIPMreq = 0x8 @@ -522,6 +531,13 @@ const ( RTA_PREF = 0x14 RTA_ENCAP_TYPE = 0x15 RTA_ENCAP = 0x16 + RTA_EXPIRES = 0x17 + RTA_PAD = 0x18 + RTA_UID = 0x19 + RTA_TTL_PROPAGATE = 0x1a + RTA_IP_PROTO = 0x1b + RTA_SPORT = 0x1c + RTA_DPORT = 0x1d RTN_UNSPEC = 0x0 RTN_UNICAST = 0x1 RTN_LOCAL = 0x2 @@ -1892,3 +1908,63 @@ const ( NETNSA_PID = 0x2 NETNSA_FD = 0x3 ) + +type XDPRingOffset struct { + Producer uint64 + Consumer uint64 + Desc uint64 +} + +type XDPMmapOffsets struct { + Rx XDPRingOffset + Tx XDPRingOffset + Fr XDPRingOffset + Cr XDPRingOffset +} + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 +} + +type XDPStatistics struct { + Rx_dropped uint64 + Rx_invalid_descs uint64 + Tx_invalid_descs uint64 +} + +type XDPDesc struct { + Addr uint64 + Len uint32 + Options uint32 +} + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index c933cea6..9191020c 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -281,6 +281,14 @@ type RawSockaddrVM struct { Zero [4]uint8 } +type RawSockaddrXDP struct { + Family uint16 + Flags uint16 + Ifindex uint32 + Queue_id uint32 + Shared_umem_fd uint32 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -417,6 +425,7 @@ const ( SizeofSockaddrCAN = 0x10 SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 + SizeofSockaddrXDP = 0x10 SizeofLinger = 0x8 SizeofIovec = 0x10 SizeofIPMreq = 0x8 @@ -522,6 +531,13 @@ const ( RTA_PREF = 0x14 RTA_ENCAP_TYPE = 0x15 RTA_ENCAP = 0x16 + RTA_EXPIRES = 0x17 + RTA_PAD = 0x18 + RTA_UID = 0x19 + RTA_TTL_PROPAGATE = 0x1a + RTA_IP_PROTO = 0x1b + RTA_SPORT = 0x1c + RTA_DPORT = 0x1d RTN_UNSPEC = 0x0 RTN_UNICAST = 0x1 RTN_LOCAL = 0x2 @@ -1892,3 +1908,63 @@ const ( NETNSA_PID = 0x2 NETNSA_FD = 0x3 ) + +type XDPRingOffset struct { + Producer uint64 + Consumer uint64 + Desc uint64 +} + +type XDPMmapOffsets struct { + Rx XDPRingOffset + Tx XDPRingOffset + Fr XDPRingOffset + Cr XDPRingOffset +} + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 +} + +type XDPStatistics struct { + Rx_dropped uint64 + Rx_invalid_descs uint64 + Tx_invalid_descs uint64 +} + +type XDPDesc struct { + Addr uint64 + Len uint32 + Options uint32 +} + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index 92d358ae..8fcad32b 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -279,6 +279,14 @@ type RawSockaddrVM struct { Zero [4]uint8 } +type RawSockaddrXDP struct { + Family uint16 + Flags uint16 + Ifindex uint32 + Queue_id uint32 + Shared_umem_fd uint32 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -413,6 +421,7 @@ const ( SizeofSockaddrCAN = 0x10 SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 + SizeofSockaddrXDP = 0x10 SizeofLinger = 0x8 SizeofIovec = 0x8 SizeofIPMreq = 0x8 @@ -518,6 +527,13 @@ const ( RTA_PREF = 0x14 RTA_ENCAP_TYPE = 0x15 RTA_ENCAP = 0x16 + RTA_EXPIRES = 0x17 + RTA_PAD = 0x18 + RTA_UID = 0x19 + RTA_TTL_PROPAGATE = 0x1a + RTA_IP_PROTO = 0x1b + RTA_SPORT = 0x1c + RTA_DPORT = 0x1d RTN_UNSPEC = 0x0 RTN_UNICAST = 0x1 RTN_LOCAL = 0x2 @@ -1884,3 +1900,63 @@ const ( NETNSA_PID = 0x2 NETNSA_FD = 0x3 ) + +type XDPRingOffset struct { + Producer uint64 + Consumer uint64 + Desc uint64 +} + +type XDPMmapOffsets struct { + Rx XDPRingOffset + Tx XDPRingOffset + Fr XDPRingOffset + Cr XDPRingOffset +} + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 +} + +type XDPStatistics struct { + Rx_dropped uint64 + Rx_invalid_descs uint64 + Tx_invalid_descs uint64 +} + +type XDPDesc struct { + Addr uint64 + Len uint32 + Options uint32 +} + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index 2dbda843..a9d1b6c9 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -282,6 +282,14 @@ type RawSockaddrVM struct { Zero [4]uint8 } +type RawSockaddrXDP struct { + Family uint16 + Flags uint16 + Ifindex uint32 + Queue_id uint32 + Shared_umem_fd uint32 +} + type RawSockaddr struct { Family uint16 Data [14]uint8 @@ -418,6 +426,7 @@ const ( SizeofSockaddrCAN = 0x10 SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 + SizeofSockaddrXDP = 0x10 SizeofLinger = 0x8 SizeofIovec = 0x10 SizeofIPMreq = 0x8 @@ -523,6 +532,13 @@ const ( RTA_PREF = 0x14 RTA_ENCAP_TYPE = 0x15 RTA_ENCAP = 0x16 + RTA_EXPIRES = 0x17 + RTA_PAD = 0x18 + RTA_UID = 0x19 + RTA_TTL_PROPAGATE = 0x1a + RTA_IP_PROTO = 0x1b + RTA_SPORT = 0x1c + RTA_DPORT = 0x1d RTN_UNSPEC = 0x0 RTN_UNICAST = 0x1 RTN_LOCAL = 0x2 @@ -1900,3 +1916,63 @@ const ( NETNSA_PID = 0x2 NETNSA_FD = 0x3 ) + +type XDPRingOffset struct { + Producer uint64 + Consumer uint64 + Desc uint64 +} + +type XDPMmapOffsets struct { + Rx XDPRingOffset + Tx XDPRingOffset + Fr XDPRingOffset + Cr XDPRingOffset +} + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 +} + +type XDPStatistics struct { + Rx_dropped uint64 + Rx_invalid_descs uint64 + Tx_invalid_descs uint64 +} + +type XDPDesc struct { + Addr uint64 + Len uint32 + Options uint32 +} + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index b1d23570..f0f5214a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -282,6 +282,14 @@ type RawSockaddrVM struct { Zero [4]uint8 } +type RawSockaddrXDP struct { + Family uint16 + Flags uint16 + Ifindex uint32 + Queue_id uint32 + Shared_umem_fd uint32 +} + type RawSockaddr struct { Family uint16 Data [14]uint8 @@ -418,6 +426,7 @@ const ( SizeofSockaddrCAN = 0x10 SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 + SizeofSockaddrXDP = 0x10 SizeofLinger = 0x8 SizeofIovec = 0x10 SizeofIPMreq = 0x8 @@ -523,6 +532,13 @@ const ( RTA_PREF = 0x14 RTA_ENCAP_TYPE = 0x15 RTA_ENCAP = 0x16 + RTA_EXPIRES = 0x17 + RTA_PAD = 0x18 + RTA_UID = 0x19 + RTA_TTL_PROPAGATE = 0x1a + RTA_IP_PROTO = 0x1b + RTA_SPORT = 0x1c + RTA_DPORT = 0x1d RTN_UNSPEC = 0x0 RTN_UNICAST = 0x1 RTN_LOCAL = 0x2 @@ -1900,3 +1916,63 @@ const ( NETNSA_PID = 0x2 NETNSA_FD = 0x3 ) + +type XDPRingOffset struct { + Producer uint64 + Consumer uint64 + Desc uint64 +} + +type XDPMmapOffsets struct { + Rx XDPRingOffset + Tx XDPRingOffset + Fr XDPRingOffset + Cr XDPRingOffset +} + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 +} + +type XDPStatistics struct { + Rx_dropped uint64 + Rx_invalid_descs uint64 + Tx_invalid_descs uint64 +} + +type XDPDesc struct { + Addr uint64 + Len uint32 + Options uint32 +} + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index 0a34ccdd..09c90586 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -281,6 +281,14 @@ type RawSockaddrVM struct { Zero [4]uint8 } +type RawSockaddrXDP struct { + Family uint16 + Flags uint16 + Ifindex uint32 + Queue_id uint32 + Shared_umem_fd uint32 +} + type RawSockaddr struct { Family uint16 Data [14]uint8 @@ -417,6 +425,7 @@ const ( SizeofSockaddrCAN = 0x10 SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 + SizeofSockaddrXDP = 0x10 SizeofLinger = 0x8 SizeofIovec = 0x10 SizeofIPMreq = 0x8 @@ -522,6 +531,13 @@ const ( RTA_PREF = 0x14 RTA_ENCAP_TYPE = 0x15 RTA_ENCAP = 0x16 + RTA_EXPIRES = 0x17 + RTA_PAD = 0x18 + RTA_UID = 0x19 + RTA_TTL_PROPAGATE = 0x1a + RTA_IP_PROTO = 0x1b + RTA_SPORT = 0x1c + RTA_DPORT = 0x1d RTN_UNSPEC = 0x0 RTN_UNICAST = 0x1 RTN_LOCAL = 0x2 @@ -1917,3 +1933,63 @@ const ( NETNSA_PID = 0x2 NETNSA_FD = 0x3 ) + +type XDPRingOffset struct { + Producer uint64 + Consumer uint64 + Desc uint64 +} + +type XDPMmapOffsets struct { + Rx XDPRingOffset + Tx XDPRingOffset + Fr XDPRingOffset + Cr XDPRingOffset +} + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 +} + +type XDPStatistics struct { + Rx_dropped uint64 + Rx_invalid_descs uint64 + Tx_invalid_descs uint64 +} + +type XDPDesc struct { + Addr uint64 + Len uint32 + Options uint32 +} + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index 0c790546..5e86e496 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) @@ -280,6 +280,14 @@ type RawSockaddrVM struct { Zero [4]uint8 } +type RawSockaddrXDP struct { + Family uint16 + Flags uint16 + Ifindex uint32 + Queue_id uint32 + Shared_umem_fd uint32 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -416,6 +424,7 @@ const ( SizeofSockaddrCAN = 0x10 SizeofSockaddrALG = 0x58 SizeofSockaddrVM = 0x10 + SizeofSockaddrXDP = 0x10 SizeofLinger = 0x8 SizeofIovec = 0x10 SizeofIPMreq = 0x8 @@ -521,6 +530,13 @@ const ( RTA_PREF = 0x14 RTA_ENCAP_TYPE = 0x15 RTA_ENCAP = 0x16 + RTA_EXPIRES = 0x17 + RTA_PAD = 0x18 + RTA_UID = 0x19 + RTA_TTL_PROPAGATE = 0x1a + RTA_IP_PROTO = 0x1b + RTA_SPORT = 0x1c + RTA_DPORT = 0x1d RTN_UNSPEC = 0x0 RTN_UNICAST = 0x1 RTN_LOCAL = 0x2 @@ -1917,3 +1933,63 @@ const ( NETNSA_PID = 0x2 NETNSA_FD = 0x3 ) + +type XDPRingOffset struct { + Producer uint64 + Consumer uint64 + Desc uint64 +} + +type XDPMmapOffsets struct { + Rx XDPRingOffset + Tx XDPRingOffset + Fr XDPRingOffset + Cr XDPRingOffset +} + +type XDPUmemReg struct { + Addr uint64 + Len uint64 + Size uint32 + Headroom uint32 +} + +type XDPStatistics struct { + Rx_dropped uint64 + Rx_invalid_descs uint64 + Tx_invalid_descs uint64 +} + +type XDPDesc struct { + Addr uint64 + Len uint32 + Options uint32 +} + +const ( + NCSI_CMD_UNSPEC = 0x0 + NCSI_CMD_PKG_INFO = 0x1 + NCSI_CMD_SET_INTERFACE = 0x2 + NCSI_CMD_CLEAR_INTERFACE = 0x3 + NCSI_ATTR_UNSPEC = 0x0 + NCSI_ATTR_IFINDEX = 0x1 + NCSI_ATTR_PACKAGE_LIST = 0x2 + NCSI_ATTR_PACKAGE_ID = 0x3 + NCSI_ATTR_CHANNEL_ID = 0x4 + NCSI_PKG_ATTR_UNSPEC = 0x0 + NCSI_PKG_ATTR = 0x1 + NCSI_PKG_ATTR_ID = 0x2 + NCSI_PKG_ATTR_FORCED = 0x3 + NCSI_PKG_ATTR_CHANNEL_LIST = 0x4 + NCSI_CHANNEL_ATTR_UNSPEC = 0x0 + NCSI_CHANNEL_ATTR = 0x1 + NCSI_CHANNEL_ATTR_ID = 0x2 + NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3 + NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4 + NCSI_CHANNEL_ATTR_VERSION_STR = 0x5 + NCSI_CHANNEL_ATTR_LINK_STATE = 0x6 + NCSI_CHANNEL_ATTR_ACTIVE = 0x7 + NCSI_CHANNEL_ATTR_FORCED = 0x8 + NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9 + NCSI_CHANNEL_ATTR_VLAN_ID = 0xa +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go index 8e7384b8..1fc7f7de 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go @@ -5,11 +5,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x1000 ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go index 4b86fb2b..1fdc5fd2 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( @@ -446,3 +446,13 @@ type Utsname struct { Version [256]byte Machine [256]byte } + +const SizeofClockinfo = 0x14 + +type Clockinfo struct { + Hz int32 + Tick int32 + Tickadj int32 + Stathz int32 + Profhz int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go index 9048a509..711f7806 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 ) type ( @@ -453,3 +453,13 @@ type Utsname struct { Version [256]byte Machine [256]byte } + +const SizeofClockinfo = 0x14 + +type Clockinfo struct { + Hz int32 + Tick int32 + Tickadj int32 + Stathz int32 + Profhz int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go index 00525e7b..fa1a16ba 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( @@ -451,3 +451,13 @@ type Utsname struct { Version [256]byte Machine [256]byte } + +const SizeofClockinfo = 0x14 + +type Clockinfo struct { + Hz int32 + Tick int32 + Tickadj int32 + Stathz int32 + Profhz int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go index 231f4e8e..c8509bf0 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( @@ -465,3 +465,94 @@ type Utsname struct { Version [256]byte Machine [256]byte } + +const SizeofUvmexp = 0x158 + +type Uvmexp struct { + Pagesize int32 + Pagemask int32 + Pageshift int32 + Npages int32 + Free int32 + Active int32 + Inactive int32 + Paging int32 + Wired int32 + Zeropages int32 + Reserve_pagedaemon int32 + Reserve_kernel int32 + Anonpages int32 + Vnodepages int32 + Vtextpages int32 + Freemin int32 + Freetarg int32 + Inactarg int32 + Wiredmax int32 + Anonmin int32 + Vtextmin int32 + Vnodemin int32 + Anonminpct int32 + Vtextminpct int32 + Vnodeminpct int32 + Nswapdev int32 + Swpages int32 + Swpginuse int32 + Swpgonly int32 + Nswget int32 + Nanon int32 + Nanonneeded int32 + Nfreeanon int32 + Faults int32 + Traps int32 + Intrs int32 + Swtch int32 + Softs int32 + Syscalls int32 + Pageins int32 + Obsolete_swapins int32 + Obsolete_swapouts int32 + Pgswapin int32 + Pgswapout int32 + Forks int32 + Forks_ppwait int32 + Forks_sharevm int32 + Pga_zerohit int32 + Pga_zeromiss int32 + Zeroaborts int32 + Fltnoram int32 + Fltnoanon int32 + Fltnoamap int32 + Fltpgwait int32 + Fltpgrele int32 + Fltrelck int32 + Fltrelckok int32 + Fltanget int32 + Fltanretry int32 + Fltamcopy int32 + Fltnamap int32 + Fltnomap int32 + Fltlget int32 + Fltget int32 + Flt_anon int32 + Flt_acow int32 + Flt_obj int32 + Flt_prcopy int32 + Flt_przero int32 + Pdwoke int32 + Pdrevs int32 + Pdswout int32 + Pdfreed int32 + Pdscans int32 + Pdanscan int32 + Pdobscan int32 + Pdreact int32 + Pdbusy int32 + Pdpageouts int32 + Pdpending int32 + Pddeact int32 + Pdreanon int32 + Pdrevnode int32 + Pdrevtext int32 + Fpswtch int32 + Kmapent int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go index bb2c4488..200575d9 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 ) type ( @@ -465,3 +465,94 @@ type Utsname struct { Version [256]byte Machine [256]byte } + +const SizeofUvmexp = 0x158 + +type Uvmexp struct { + Pagesize int32 + Pagemask int32 + Pageshift int32 + Npages int32 + Free int32 + Active int32 + Inactive int32 + Paging int32 + Wired int32 + Zeropages int32 + Reserve_pagedaemon int32 + Reserve_kernel int32 + Anonpages int32 + Vnodepages int32 + Vtextpages int32 + Freemin int32 + Freetarg int32 + Inactarg int32 + Wiredmax int32 + Anonmin int32 + Vtextmin int32 + Vnodemin int32 + Anonminpct int32 + Vtextminpct int32 + Vnodeminpct int32 + Nswapdev int32 + Swpages int32 + Swpginuse int32 + Swpgonly int32 + Nswget int32 + Nanon int32 + Nanonneeded int32 + Nfreeanon int32 + Faults int32 + Traps int32 + Intrs int32 + Swtch int32 + Softs int32 + Syscalls int32 + Pageins int32 + Obsolete_swapins int32 + Obsolete_swapouts int32 + Pgswapin int32 + Pgswapout int32 + Forks int32 + Forks_ppwait int32 + Forks_sharevm int32 + Pga_zerohit int32 + Pga_zeromiss int32 + Zeroaborts int32 + Fltnoram int32 + Fltnoanon int32 + Fltnoamap int32 + Fltpgwait int32 + Fltpgrele int32 + Fltrelck int32 + Fltrelckok int32 + Fltanget int32 + Fltanretry int32 + Fltamcopy int32 + Fltnamap int32 + Fltnomap int32 + Fltlget int32 + Fltget int32 + Flt_anon int32 + Flt_acow int32 + Flt_obj int32 + Flt_prcopy int32 + Flt_przero int32 + Pdwoke int32 + Pdrevs int32 + Pdswout int32 + Pdfreed int32 + Pdscans int32 + Pdanscan int32 + Pdobscan int32 + Pdreact int32 + Pdbusy int32 + Pdpageouts int32 + Pdpending int32 + Pddeact int32 + Pdreanon int32 + Pdrevnode int32 + Pdrevtext int32 + Fpswtch int32 + Kmapent int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go index 941367ca..3e20cdf0 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x4 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x4 - sizeofLongLong = 0x8 + SizeofPtr = 0x4 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x4 + SizeofLongLong = 0x8 ) type ( @@ -458,3 +458,94 @@ type Utsname struct { Version [256]byte Machine [256]byte } + +const SizeofUvmexp = 0x158 + +type Uvmexp struct { + Pagesize int32 + Pagemask int32 + Pageshift int32 + Npages int32 + Free int32 + Active int32 + Inactive int32 + Paging int32 + Wired int32 + Zeropages int32 + Reserve_pagedaemon int32 + Reserve_kernel int32 + Anonpages int32 + Vnodepages int32 + Vtextpages int32 + Freemin int32 + Freetarg int32 + Inactarg int32 + Wiredmax int32 + Anonmin int32 + Vtextmin int32 + Vnodemin int32 + Anonminpct int32 + Vtextminpct int32 + Vnodeminpct int32 + Nswapdev int32 + Swpages int32 + Swpginuse int32 + Swpgonly int32 + Nswget int32 + Nanon int32 + Nanonneeded int32 + Nfreeanon int32 + Faults int32 + Traps int32 + Intrs int32 + Swtch int32 + Softs int32 + Syscalls int32 + Pageins int32 + Obsolete_swapins int32 + Obsolete_swapouts int32 + Pgswapin int32 + Pgswapout int32 + Forks int32 + Forks_ppwait int32 + Forks_sharevm int32 + Pga_zerohit int32 + Pga_zeromiss int32 + Zeroaborts int32 + Fltnoram int32 + Fltnoanon int32 + Fltnoamap int32 + Fltpgwait int32 + Fltpgrele int32 + Fltrelck int32 + Fltrelckok int32 + Fltanget int32 + Fltanretry int32 + Fltamcopy int32 + Fltnamap int32 + Fltnomap int32 + Fltlget int32 + Fltget int32 + Flt_anon int32 + Flt_acow int32 + Flt_obj int32 + Flt_prcopy int32 + Flt_przero int32 + Pdwoke int32 + Pdrevs int32 + Pdswout int32 + Pdfreed int32 + Pdscans int32 + Pdanscan int32 + Pdobscan int32 + Pdreact int32 + Pdbusy int32 + Pdpageouts int32 + Pdpending int32 + Pddeact int32 + Pdreanon int32 + Pdrevnode int32 + Pdrevtext int32 + Fpswtch int32 + Kmapent int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go index 0543e1a4..8531a190 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go @@ -6,11 +6,11 @@ package unix const ( - sizeofPtr = 0x8 - sizeofShort = 0x2 - sizeofInt = 0x4 - sizeofLong = 0x8 - sizeofLongLong = 0x8 + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 PathMax = 0x400 MaxHostNameLen = 0x100 )