Skip to content

Commit f7b9253

Browse files
route: Test trimmed netmask parsing on Darwin
1 parent 61924c1 commit f7b9253

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

route/address_darwin_test.go

+54
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,60 @@ var parseAddrsOnDarwinLittleEndianTests = []parseAddrsOnDarwinTest{
4242
nil,
4343
},
4444
},
45+
{
46+
syscall.RTA_DST | syscall.RTA_GATEWAY | syscall.RTA_NETMASK,
47+
parseKernelInetAddr,
48+
[]byte{
49+
0x10, 0x02, 0x00, 0x00, 0x64, 0x71, 0x00, 0x00,
50+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51+
52+
0x14, 0x12, 0x21, 0x00, 0x01, 0x08, 0x00, 0x00,
53+
0x75, 0x74, 0x75, 0x6e, 0x34, 0x33, 0x31, 0x39,
54+
0x00, 0x00, 0x00, 0x00,
55+
56+
0x06, 0x02, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
57+
},
58+
[]Addr{
59+
&Inet4Addr{IP: [4]byte{100, 113, 0, 0}},
60+
&LinkAddr{Index: 33, Name: "utun4319"},
61+
&Inet4Addr{IP: [4]byte{255, 255, 0, 0}},
62+
nil,
63+
nil,
64+
nil,
65+
nil,
66+
nil,
67+
},
68+
},
69+
// route -n add -inet6 fd84:1b4e:6281:: -prefixlen 48 fe80::f22f:4bff:fe09:3bff%utun4319
70+
// gw fe80:0000:0000:0000:f22f:4bff:fe09:3bff
71+
{
72+
syscall.RTA_DST | syscall.RTA_GATEWAY | syscall.RTA_NETMASK,
73+
parseKernelInetAddr,
74+
[]byte{
75+
0x1c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76+
0xfd, 0x84, 0x1b, 0x4e, 0x62, 0x81, 0x00, 0x00,
77+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78+
0x00, 0x00, 0x00, 0x00,
79+
80+
0x1c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
81+
0xfe, 0x80, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00,
82+
0xf2, 0x2f, 0x4b, 0xff, 0xfe, 0x09, 0x3b, 0xff,
83+
0x00, 0x00, 0x00, 0x00,
84+
85+
0x0e, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
86+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
87+
},
88+
[]Addr{
89+
&Inet6Addr{IP: [16]byte{ 0xfd, 0x84, 0x1b, 0x4e, 0x62, 0x81 }},
90+
&Inet6Addr{IP: [16]byte{ 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x2f, 0x4b, 0xff, 0xfe, 0x09, 0x3b, 0xff }, ZoneID: 33},
91+
&Inet6Addr{IP: [16]byte{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,}},
92+
nil,
93+
nil,
94+
nil,
95+
nil,
96+
nil,
97+
},
98+
},
4599
}
46100

47101
func TestParseAddrsOnDarwin(t *testing.T) {

0 commit comments

Comments
 (0)