diff --git a/route_test.go b/route_test.go index 06f2e7c..2ed217e 100644 --- a/route_test.go +++ b/route_test.go @@ -117,15 +117,70 @@ func TestRouteMessageUnmarshalBinary(t *testing.T) { err: errInvalidRouteMessageAttr, }, { - name: "data", + name: "full", b: []byte{ - 0x02, 0x08, 0x00, 0x00, 0xfe, 0x04, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x07, 0x00, - 0x0a, 0x64, 0x0a, 0x01, 0x08, 0x00, 0x04, 0x00, - 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x17, 0x00, - 0xe8, 0x03, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x80, - 0x08, 0x00, 0x02, 0x00, 0xdc, 0x05, 0x00, 0x00, + // RouteMessage struct literal + // + // Family + 0x02, + // DstLength + 0x08, + // SrcLength + 0x00, + // Tos + 0x00, + // Table + 0xfe, + // Protocol + 0x04, + // Scope + 0x00, + // Type + 0x01, + // Flags + 0x00, 0x00, 0x00, 0x00, + // RouteAttributes + // 2 bytes length, 2 bytes type, N bytes value + // + // Dst + 0x08, 0x00, 0x01, 0x00, + 0x0a, 0x00, 0x00, 0x00, + // Src + 0x08, 0x00, 0x07, 0x00, + 0x0a, 0x64, 0x0a, 0x01, + // Gateway + 0x08, 0x00, 0x05, 0x00, + 0x0a, 0x00, 0x00, 0x01, + // OutIface + 0x08, 0x00, 0x04, 0x00, + 0x05, 0x00, 0x00, 0x00, + // Priority + 0x08, 0x00, 0x06, 0x00, + 0x01, 0x00, 0x00, 0x00, + // Table + 0x08, 0x00, 0x0f, 0x00, + 0x02, 0x00, 0x00, 0x00, + // Mark + 0x08, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, + // Expires + 0x08, 0x00, 0x17, 0x00, + 0xe8, 0x03, 0x00, 0x00, + // RouteMetrics + // Length must be manually adjusted as more fields are added. + 0x24, 0x00, 0x08, 0x80, + // AdvMSS + 0x08, 0x00, 0x08, 0x00, + 0x01, 0x00, 0x00, 0x00, + // Features + 0x08, 0x00, 0x0c, 0x00, + 0xff, 0xff, 0xff, 0xff, + // InitCwnd + 0x08, 0x00, 0x0b, 0x00, + 0x02, 0x00, 0x00, 0x00, + // MTU + 0x08, 0x00, 0x02, 0x00, + 0xdc, 0x05, 0x00, 0x00, }, m: &RouteMessage{ Family: 2, @@ -135,12 +190,19 @@ func TestRouteMessageUnmarshalBinary(t *testing.T) { Scope: unix.RT_SCOPE_UNIVERSE, Type: unix.RTN_UNICAST, Attributes: RouteAttributes{ - Dst: net.IP{0x0a, 0x00, 0x00, 0x00}, - Src: net.IP{0x0a, 0x64, 0x0a, 0x01}, + Dst: net.IPv4(10, 0, 0, 0), + Src: net.IPv4(10, 100, 10, 1), + Gateway: net.IPv4(10, 0, 0, 1), OutIface: 5, + Priority: 1, + Table: 2, + Mark: 3, Expires: &timeout, Metrics: &RouteMetrics{ - MTU: 1500, + AdvMSS: 1, + Features: 0xffffffff, + InitCwnd: 2, + MTU: 1500, }, }, },