Finally rid of capital Sirupsen??

This commit is contained in:
Travis Reeder
2017-09-18 23:33:47 -07:00
parent f335d34636
commit 3aecebdf48
1127 changed files with 41199 additions and 41383 deletions

View File

@@ -69,6 +69,9 @@ const (
sysRTM_IFINFO = C.RTM_IFINFO
sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE
sysRTM_DESYNC = C.RTM_DESYNC
sysRTM_INVALIDATE = C.RTM_INVALIDATE
sysRTM_BFD = C.RTM_BFD
sysRTM_PROPOSAL = C.RTM_PROPOSAL
sysRTA_DST = C.RTA_DST
sysRTA_GATEWAY = C.RTA_GATEWAY
@@ -81,6 +84,10 @@ const (
sysRTA_SRC = C.RTA_SRC
sysRTA_SRCMASK = C.RTA_SRCMASK
sysRTA_LABEL = C.RTA_LABEL
sysRTA_BFD = C.RTA_BFD
sysRTA_DNS = C.RTA_DNS
sysRTA_STATIC = C.RTA_STATIC
sysRTA_SEARCH = C.RTA_SEARCH
sysRTAX_DST = C.RTAX_DST
sysRTAX_GATEWAY = C.RTAX_GATEWAY
@@ -93,6 +100,10 @@ const (
sysRTAX_SRC = C.RTAX_SRC
sysRTAX_SRCMASK = C.RTAX_SRCMASK
sysRTAX_LABEL = C.RTAX_LABEL
sysRTAX_BFD = C.RTAX_BFD
sysRTAX_DNS = C.RTAX_DNS
sysRTAX_STATIC = C.RTAX_STATIC
sysRTAX_SEARCH = C.RTAX_SEARCH
sysRTAX_MAX = C.RTAX_MAX
)

View File

@@ -7,21 +7,28 @@ package route
import "testing"
func TestFetchAndParseRIBOnDarwin(t *testing.T) {
for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
for _, typ := range []RIBType{sysNET_RT_FLAGS, sysNET_RT_DUMP2, sysNET_RT_IFLIST2} {
ms, err := fetchAndParseRIB(af, typ)
for _, typ := range []RIBType{sysNET_RT_FLAGS, sysNET_RT_DUMP2, sysNET_RT_IFLIST2} {
var lastErr error
var ms []Message
for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
rs, err := fetchAndParseRIB(af, typ)
if err != nil {
t.Error(err)
lastErr = err
continue
}
ss, err := msgs(ms).validate()
if err != nil {
t.Errorf("%v %d %v", addrFamily(af), typ, err)
continue
}
for _, s := range ss {
t.Log(s)
}
ms = append(ms, rs...)
}
if len(ms) == 0 && lastErr != nil {
t.Error(typ, lastErr)
continue
}
ss, err := msgs(ms).validate()
if err != nil {
t.Error(typ, err)
continue
}
for _, s := range ss {
t.Log(s)
}
}
}

View File

@@ -6,26 +6,32 @@ package route
import (
"testing"
"time"
"unsafe"
)
func TestFetchAndParseRIBOnFreeBSD(t *testing.T) {
for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
for _, typ := range []RIBType{sysNET_RT_IFMALIST} {
ms, err := fetchAndParseRIB(af, typ)
for _, typ := range []RIBType{sysNET_RT_IFMALIST} {
var lastErr error
var ms []Message
for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
rs, err := fetchAndParseRIB(af, typ)
if err != nil {
t.Error(err)
lastErr = err
continue
}
ss, err := msgs(ms).validate()
if err != nil {
t.Errorf("%v %d %v", addrFamily(af), typ, err)
continue
}
for _, s := range ss {
t.Log(s)
}
ms = append(ms, rs...)
}
if len(ms) == 0 && lastErr != nil {
t.Error(typ, lastErr)
continue
}
ss, err := msgs(ms).validate()
if err != nil {
t.Error(typ, err)
continue
}
for _, s := range ss {
t.Log(s)
}
}
}
@@ -48,58 +54,38 @@ func TestFetchAndParseRIBOnFreeBSD10AndAbove(t *testing.T) {
{typ: sysNET_RT_IFLIST},
{typ: sysNET_RT_IFLISTL},
}
for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
for i := range tests {
var lastErr error
for i := 0; i < 3; i++ {
for j := range tests {
var err error
if tests[j].b, err = FetchRIB(af, tests[j].typ, 0); err != nil {
lastErr = err
time.Sleep(10 * time.Millisecond)
}
}
if lastErr == nil {
break
}
}
if lastErr != nil {
t.Error(af, lastErr)
continue
}
for i := range tests {
var err error
if tests[i].msgs, err = ParseRIB(tests[i].typ, tests[i].b); err != nil {
lastErr = err
t.Error(af, err)
}
}
if lastErr != nil {
continue
}
for i := range tests {
var err error
tests[i].ss, err = msgs(tests[i].msgs).validate()
for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
rs, err := fetchAndParseRIB(af, tests[i].typ)
if err != nil {
lastErr = err
t.Error(af, err)
}
for _, s := range tests[i].ss {
t.Log(s)
}
}
if lastErr != nil {
continue
}
for i := len(tests) - 1; i > 0; i-- {
if len(tests[i].ss) != len(tests[i-1].ss) {
t.Errorf("got %v; want %v", tests[i].ss, tests[i-1].ss)
continue
}
for j, s1 := range tests[i].ss {
s0 := tests[i-1].ss[j]
if s1 != s0 {
t.Errorf("got %s; want %s", s1, s0)
}
tests[i].msgs = append(tests[i].msgs, rs...)
}
if len(tests[i].msgs) == 0 && lastErr != nil {
t.Error(tests[i].typ, lastErr)
continue
}
tests[i].ss, lastErr = msgs(tests[i].msgs).validate()
if lastErr != nil {
t.Error(tests[i].typ, lastErr)
continue
}
for _, s := range tests[i].ss {
t.Log(s)
}
}
for i := len(tests) - 1; i > 0; i-- {
if len(tests[i].ss) != len(tests[i-1].ss) {
t.Errorf("got %v; want %v", tests[i].ss, tests[i-1].ss)
continue
}
for j, s1 := range tests[i].ss {
s0 := tests[i-1].ss[j]
if s1 != s0 {
t.Errorf("got %s; want %s", s1, s0)
}
}
}

View File

@@ -14,21 +14,28 @@ import (
)
func TestFetchAndParseRIB(t *testing.T) {
for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
for _, typ := range []RIBType{sysNET_RT_DUMP, sysNET_RT_IFLIST} {
ms, err := fetchAndParseRIB(af, typ)
for _, typ := range []RIBType{sysNET_RT_DUMP, sysNET_RT_IFLIST} {
var lastErr error
var ms []Message
for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
rs, err := fetchAndParseRIB(af, typ)
if err != nil {
t.Error(err)
lastErr = err
continue
}
ss, err := msgs(ms).validate()
if err != nil {
t.Errorf("%v %d %v", addrFamily(af), typ, err)
continue
}
for _, s := range ss {
t.Log(s)
}
ms = append(ms, rs...)
}
if len(ms) == 0 && lastErr != nil {
t.Error(typ, lastErr)
continue
}
ss, err := msgs(ms).validate()
if err != nil {
t.Error(typ, err)
continue
}
for _, s := range ss {
t.Log(typ, s)
}
}
}
@@ -145,8 +152,8 @@ func TestRouteMessage(t *testing.T) {
var ms []RouteMessage
for _, af := range []int{sysAF_INET, sysAF_INET6} {
rs, err := fetchAndParseRIB(af, sysNET_RT_DUMP)
if err != nil || len(rs) == 0 {
if _, err := fetchAndParseRIB(af, sysNET_RT_DUMP); err != nil {
t.Log(err)
continue
}
switch af {
@@ -228,6 +235,5 @@ func TestRouteMessage(t *testing.T) {
for _, s := range ss {
t.Log(s)
}
}
}

View File

@@ -74,6 +74,10 @@ var addrAttrNames = [...]string{
"df:mpls1-n:tag-o:src", // mpls1 for dragonfly, tag for netbsd, src for openbsd
"df:mpls2-o:srcmask", // mpls2 for dragonfly, srcmask for openbsd
"df:mpls3-o:label", // mpls3 for dragonfly, label for openbsd
"o:bfd", // bfd for openbsd
"o:dns", // dns for openbsd
"o:static", // static for openbsd
"o:search", // search for openbsd
}
func (attrs addrAttrs) String() string {

View File

@@ -13,7 +13,7 @@ func (typ RIBType) parseable() bool {
}
}
// A RouteMetrics represents route metrics.
// RouteMetrics represents route metrics.
type RouteMetrics struct {
PathMTU int // path maximum transmission unit
}
@@ -30,7 +30,7 @@ func (m *RouteMessage) Sys() []Sys {
}
}
// A InterfaceMetrics represents interface metrics.
// InterfaceMetrics represents interface metrics.
type InterfaceMetrics struct {
Type int // interface type
MTU int // maximum transmission unit

View File

@@ -8,7 +8,7 @@ import "unsafe"
func (typ RIBType) parseable() bool { return true }
// A RouteMetrics represents route metrics.
// RouteMetrics represents route metrics.
type RouteMetrics struct {
PathMTU int // path maximum transmission unit
}
@@ -25,7 +25,7 @@ func (m *RouteMessage) Sys() []Sys {
}
}
// A InterfaceMetrics represents interface metrics.
// InterfaceMetrics represents interface metrics.
type InterfaceMetrics struct {
Type int // interface type
MTU int // maximum transmission unit

View File

@@ -11,7 +11,7 @@ import (
func (typ RIBType) parseable() bool { return true }
// A RouteMetrics represents route metrics.
// RouteMetrics represents route metrics.
type RouteMetrics struct {
PathMTU int // path maximum transmission unit
}
@@ -35,7 +35,7 @@ func (m *RouteMessage) Sys() []Sys {
}
}
// A InterfaceMetrics represents interface metrics.
// InterfaceMetrics represents interface metrics.
type InterfaceMetrics struct {
Type int // interface type
MTU int // maximum transmission unit

View File

@@ -6,7 +6,7 @@ package route
func (typ RIBType) parseable() bool { return true }
// A RouteMetrics represents route metrics.
// RouteMetrics represents route metrics.
type RouteMetrics struct {
PathMTU int // path maximum transmission unit
}
@@ -23,7 +23,7 @@ func (m *RouteMessage) Sys() []Sys {
}
}
// A InterfaceMetrics represents interface metrics.
// RouteMetrics represents route metrics.
type InterfaceMetrics struct {
Type int // interface type
MTU int // maximum transmission unit

View File

@@ -15,7 +15,7 @@ func (typ RIBType) parseable() bool {
}
}
// A RouteMetrics represents route metrics.
// RouteMetrics represents route metrics.
type RouteMetrics struct {
PathMTU int // path maximum transmission unit
}
@@ -32,7 +32,7 @@ func (m *RouteMessage) Sys() []Sys {
}
}
// A InterfaceMetrics represents interface metrics.
// InterfaceMetrics represents interface metrics.
type InterfaceMetrics struct {
Type int // interface type
MTU int // maximum transmission unit
@@ -75,5 +75,6 @@ func probeRoutingStack() (int, map[int]*wireFormat) {
sysRTM_DELADDR: ifam,
sysRTM_IFINFO: ifm,
sysRTM_IFANNOUNCE: ifanm,
sysRTM_DESYNC: rtm,
}
}

View File

@@ -54,6 +54,9 @@ const (
sysRTM_IFINFO = 0xe
sysRTM_IFANNOUNCE = 0xf
sysRTM_DESYNC = 0x10
sysRTM_INVALIDATE = 0x11
sysRTM_BFD = 0x12
sysRTM_PROPOSAL = 0x13
sysRTA_DST = 0x1
sysRTA_GATEWAY = 0x2
@@ -66,6 +69,10 @@ const (
sysRTA_SRC = 0x100
sysRTA_SRCMASK = 0x200
sysRTA_LABEL = 0x400
sysRTA_BFD = 0x800
sysRTA_DNS = 0x1000
sysRTA_STATIC = 0x2000
sysRTA_SEARCH = 0x4000
sysRTAX_DST = 0x0
sysRTAX_GATEWAY = 0x1
@@ -78,7 +85,11 @@ const (
sysRTAX_SRC = 0x8
sysRTAX_SRCMASK = 0x9
sysRTAX_LABEL = 0xa
sysRTAX_MAX = 0xb
sysRTAX_BFD = 0xb
sysRTAX_DNS = 0xc
sysRTAX_STATIC = 0xd
sysRTAX_SEARCH = 0xe
sysRTAX_MAX = 0xf
)
const (