1 // Copyright 2017 Google, Inc. All rights reserved.
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
10 "github.com/google/gopacket"
15 // testPacketOSPF3Hello is the packet:
16 // 14:43:11.663317 IP6 fe80::1 > ff02::5: OSPFv3, Hello, length 36
17 // 0x0000: 3333 0000 0005 c200 1ffa 0001 86dd 6e00 33............n.
18 // 0x0010: 0000 0024 5901 fe80 0000 0000 0000 0000 ...$Y...........
19 // 0x0020: 0000 0000 0001 ff02 0000 0000 0000 0000 ................
20 // 0x0030: 0000 0000 0005 0301 0024 0101 0101 0000 .........$......
21 // 0x0040: 0001 fb86 0000 0000 0005 0100 0013 000a ................
22 // 0x0050: 0028 0000 0000 0000 0000 .(........
23 var testPacketOSPF3Hello = []byte{
24 0x33, 0x33, 0x00, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x1f, 0xfa, 0x00, 0x01, 0x86, 0xdd, 0x6e, 0x00,
25 0x00, 0x00, 0x00, 0x24, 0x59, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x03, 0x01, 0x00, 0x24, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
28 0x00, 0x01, 0xfb, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x13, 0x00, 0x0a,
29 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32 func TestPacketOSPF3Hello(t *testing.T) {
33 p := gopacket.NewPacket(testPacketOSPF3Hello, LinkTypeEthernet, gopacket.Default)
34 if p.ErrorLayer() != nil {
35 t.Error("Failed to decode packet:", p.ErrorLayer().Error())
37 checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeOSPF}, t)
39 ospf := p.Layer(LayerTypeOSPF).(*OSPFv3)
40 if ospf.Version != 3 {
41 t.Fatal("Invalid OSPF version")
43 if got, ok := p.Layer(LayerTypeOSPF).(*OSPFv3); ok {
57 RouterDeadInterval: 40,
58 DesignatedRouterID: 0,
59 BackupDesignatedRouterID: 0,
65 if !reflect.DeepEqual(got, want) {
66 t.Errorf("OSPF packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
69 t.Error("No OSPF layer type found in packet")
72 func BenchmarkDecodePacketPacket0(b *testing.B) {
73 for i := 0; i < b.N; i++ {
74 gopacket.NewPacket(testPacketOSPF3Hello, LinkTypeEthernet, gopacket.NoCopy)
78 // testPacketOSPF3DBDesc is the packet:
79 // 14:43:51.657571 IP6 fe80::2 > fe80::1: OSPFv3, Database Description, length 28
80 // 0x0000: c200 1ffa 0001 c201 1ffa 0001 86dd 6e00 ..............n.
81 // 0x0010: 0000 001c 5901 fe80 0000 0000 0000 0000 ....Y...........
82 // 0x0020: 0000 0000 0002 fe80 0000 0000 0000 0000 ................
83 // 0x0030: 0000 0000 0001 0302 001c 0202 0202 0000 ................
84 // 0x0040: 0001 d826 0000 0000 0013 05dc 0007 0000 ...&............
86 var testPacketOSPF3DBDesc = []byte{
87 0xc2, 0x00, 0x1f, 0xfa, 0x00, 0x01, 0xc2, 0x01, 0x1f, 0xfa, 0x00, 0x01, 0x86, 0xdd, 0x6e, 0x00,
88 0x00, 0x00, 0x00, 0x1c, 0x59, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
89 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
90 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x02, 0x00, 0x1c, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00,
91 0x00, 0x01, 0xd8, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x05, 0xdc, 0x00, 0x07, 0x00, 0x00,
95 func TestPacketOSPF3DBDesc(t *testing.T) {
96 p := gopacket.NewPacket(testPacketOSPF3DBDesc, LinkTypeEthernet, gopacket.Default)
97 if p.ErrorLayer() != nil {
98 t.Error("Failed to decode packet:", p.ErrorLayer().Error())
100 checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeOSPF}, t)
101 if got, ok := p.Layer(LayerTypeOSPF).(*OSPFv3); ok {
105 Type: OSPFDatabaseDescription,
120 if !reflect.DeepEqual(got, want) {
121 t.Errorf("OSPF packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
124 t.Error("No OSPF layer type found in packet")
127 func BenchmarkDecodePacketPacket1(b *testing.B) {
128 for i := 0; i < b.N; i++ {
129 gopacket.NewPacket(testPacketOSPF3DBDesc, LinkTypeEthernet, gopacket.NoCopy)
133 // testPacketOSPF3LSRequest is the packet:
134 // 14:43:51.673584 IP6 fe80::2 > fe80::1: OSPFv3, LS-Request, length 100
135 // 0x0000: c200 1ffa 0001 c201 1ffa 0001 86dd 6e00 ..............n.
136 // 0x0010: 0000 0064 5901 fe80 0000 0000 0000 0000 ...dY...........
137 // 0x0020: 0000 0000 0002 fe80 0000 0000 0000 0000 ................
138 // 0x0030: 0000 0000 0001 0303 0064 0202 0202 0000 .........d......
139 // 0x0040: 0001 2c9a 0000 0000 2001 0000 0000 0101 ..,.............
140 // 0x0050: 0101 0000 2003 0000 0003 0101 0101 0000 ................
141 // 0x0060: 2003 0000 0002 0101 0101 0000 2003 0000 ................
142 // 0x0070: 0001 0101 0101 0000 2003 0000 0000 0101 ................
143 // 0x0080: 0101 0000 0008 0000 0005 0101 0101 0000 ................
144 // 0x0090: 2009 0000 0000 0101 0101 ..........
145 var testPacketOSPF3LSRequest = []byte{
146 0xc2, 0x00, 0x1f, 0xfa, 0x00, 0x01, 0xc2, 0x01, 0x1f, 0xfa, 0x00, 0x01, 0x86, 0xdd, 0x6e, 0x00,
147 0x00, 0x00, 0x00, 0x64, 0x59, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
148 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
149 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x00, 0x64, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00,
150 0x00, 0x01, 0x2c, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
151 0x01, 0x01, 0x00, 0x00, 0x20, 0x03, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
152 0x20, 0x03, 0x00, 0x00, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x20, 0x03, 0x00, 0x00,
153 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
154 0x01, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x05, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
155 0x20, 0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
158 func TestPacketOSPF3LSRequest(t *testing.T) {
159 p := gopacket.NewPacket(testPacketOSPF3LSRequest, LinkTypeEthernet, gopacket.Default)
160 if p.ErrorLayer() != nil {
161 t.Error("Failed to decode packet:", p.ErrorLayer().Error())
163 checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeOSPF}, t)
164 if got, ok := p.Layer(LayerTypeOSPF).(*OSPFv3); ok {
168 Type: OSPFLinkStateRequest,
177 AdvRouter: 0x01010101,
182 AdvRouter: 0x01010101,
187 AdvRouter: 0x01010101,
192 AdvRouter: 0x01010101,
197 AdvRouter: 0x01010101,
202 AdvRouter: 0x01010101,
207 AdvRouter: 0x01010101,
214 if !reflect.DeepEqual(got, want) {
215 t.Errorf("OSPF packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
218 t.Error("No OSPF layer type found in packet")
221 func BenchmarkDecodePacketPacket2(b *testing.B) {
222 for i := 0; i < b.N; i++ {
223 gopacket.NewPacket(testPacketOSPF3LSRequest, LinkTypeEthernet, gopacket.NoCopy)
227 // testPacketOSPF3LSUpdate is the packet:
228 // 14:43:51.681554 IP6 fe80::1 > fe80::2: OSPFv3, LS-Update, length 288
229 // 0x0000: c201 1ffa 0001 c200 1ffa 0001 86dd 6e00 ..............n.
230 // 0x0010: 0000 0120 5901 fe80 0000 0000 0000 0000 ....Y...........
231 // 0x0020: 0000 0000 0001 fe80 0000 0000 0000 0000 ................
232 // 0x0030: 0000 0000 0002 0304 0120 0101 0101 0000 ................
233 // 0x0040: 0001 e556 0000 0000 0007 0028 2001 0000 ...V.......(....
234 // 0x0050: 0000 0101 0101 8000 0002 d13a 0018 0100 ...........:....
235 // 0x0060: 0033 0029 2003 0000 0003 0101 0101 8000 .3.)............
236 // 0x0070: 0001 6259 0024 0000 004a 4000 0000 2001 ..bY.$...J@.....
237 // 0x0080: 0db8 0000 0003 0029 2003 0000 0002 0101 .......)........
238 // 0x0090: 0101 8000 0001 baf6 0024 0000 0054 4000 .........$...T@.
239 // 0x00a0: 0000 2001 0db8 0000 0004 0029 2003 0000 ...........)....
240 // 0x00b0: 0001 0101 0101 8000 0001 eba0 0024 0000 .............$..
241 // 0x00c0: 004a 4000 0000 2001 0db8 0000 0034 0029 .J@..........4.)
242 // 0x00d0: 2003 0000 0000 0101 0101 8000 0001 0ebd ................
243 // 0x00e0: 0024 0000 0040 4000 0000 2001 0db8 0000 .$...@@.........
244 // 0x00f0: 0000 0023 0008 0000 0005 0101 0101 8000 ...#............
245 // 0x0100: 0002 3d08 0038 0100 0033 fe80 0000 0000 ..=..8...3......
246 // 0x0110: 0000 0000 0000 0000 0001 0000 0001 4000 ..............@.
247 // 0x0120: 0000 2001 0db8 0000 0012 0023 2009 0000 ...........#....
248 // 0x0130: 0000 0101 0101 8000 0001 e8d2 002c 0001 .............,..
249 // 0x0140: 2001 0000 0000 0101 0101 4000 000a 2001 ..........@.....
250 // 0x0150: 0db8 0000 0012 ......
251 var testPacketOSPF3LSUpdate = []byte{
252 0xc2, 0x01, 0x1f, 0xfa, 0x00, 0x01, 0xc2, 0x00, 0x1f, 0xfa, 0x00, 0x01, 0x86, 0xdd, 0x6e, 0x00,
253 0x00, 0x00, 0x01, 0x20, 0x59, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
254 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
255 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x04, 0x01, 0x20, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
256 0x00, 0x01, 0xe5, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x28, 0x20, 0x01, 0x00, 0x00,
257 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x80, 0x00, 0x00, 0x02, 0xd1, 0x3a, 0x00, 0x18, 0x01, 0x00,
258 0x00, 0x33, 0x00, 0x29, 0x20, 0x03, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x80, 0x00,
259 0x00, 0x01, 0x62, 0x59, 0x00, 0x24, 0x00, 0x00, 0x00, 0x4a, 0x40, 0x00, 0x00, 0x00, 0x20, 0x01,
260 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x03, 0x00, 0x29, 0x20, 0x03, 0x00, 0x00, 0x00, 0x02, 0x01, 0x01,
261 0x01, 0x01, 0x80, 0x00, 0x00, 0x01, 0xba, 0xf6, 0x00, 0x24, 0x00, 0x00, 0x00, 0x54, 0x40, 0x00,
262 0x00, 0x00, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x04, 0x00, 0x29, 0x20, 0x03, 0x00, 0x00,
263 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80, 0x00, 0x00, 0x01, 0xeb, 0xa0, 0x00, 0x24, 0x00, 0x00,
264 0x00, 0x4a, 0x40, 0x00, 0x00, 0x00, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x34, 0x00, 0x29,
265 0x20, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x80, 0x00, 0x00, 0x01, 0x0e, 0xbd,
266 0x00, 0x24, 0x00, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00,
267 0x00, 0x00, 0x00, 0x23, 0x00, 0x08, 0x00, 0x00, 0x00, 0x05, 0x01, 0x01, 0x01, 0x01, 0x80, 0x00,
268 0x00, 0x02, 0x3d, 0x08, 0x00, 0x38, 0x01, 0x00, 0x00, 0x33, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00,
269 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00,
270 0x00, 0x00, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x12, 0x00, 0x23, 0x20, 0x09, 0x00, 0x00,
271 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x80, 0x00, 0x00, 0x01, 0xe8, 0xd2, 0x00, 0x2c, 0x00, 0x01,
272 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x40, 0x00, 0x00, 0x0a, 0x20, 0x01,
273 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x12,
276 func TestPacketOSPF3LSUpdate(t *testing.T) {
277 p := gopacket.NewPacket(testPacketOSPF3LSUpdate, LinkTypeEthernet, gopacket.Default)
278 if p.ErrorLayer() != nil {
279 t.Error("Failed to decode packet:", p.ErrorLayer().Error())
281 checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeOSPF}, t)
282 if got, ok := p.Layer(LayerTypeOSPF).(*OSPFv3); ok {
286 Type: OSPFLinkStateUpdate,
295 LSAheader: LSAheader{
298 LinkStateID: 0x00000000,
299 AdvRouter: 0x01010101,
300 LSSeqNumber: 0x80000002,
310 LSAheader: LSAheader{
313 LinkStateID: 0x00000003,
314 AdvRouter: 0x01010101,
315 LSSeqNumber: 0x80000001,
319 Content: InterAreaPrefixLSA{
323 AddressPrefix: []byte{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x03},
327 LSAheader: LSAheader{
330 LinkStateID: 0x00000002,
331 AdvRouter: 0x01010101,
332 LSSeqNumber: 0x80000001,
336 Content: InterAreaPrefixLSA{
340 AddressPrefix: []byte{0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x4},
344 LSAheader: LSAheader{
347 LinkStateID: 0x00000001,
348 AdvRouter: 0x01010101,
349 LSSeqNumber: 0x80000001,
353 Content: InterAreaPrefixLSA{
357 AddressPrefix: []byte{0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x34},
361 LSAheader: LSAheader{
364 LinkStateID: 0x00000000,
365 AdvRouter: 0x01010101,
366 LSSeqNumber: 0x80000001,
370 Content: InterAreaPrefixLSA{
374 AddressPrefix: []byte{0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0},
378 LSAheader: LSAheader{
381 LinkStateID: 0x00000005,
382 AdvRouter: 0x01010101,
383 LSSeqNumber: 0x80000002,
390 LinkLocalAddress: []byte{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
396 AddressPrefix: []byte{0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x12},
402 LSAheader: LSAheader{
405 LinkStateID: 0x00000000,
406 AdvRouter: 0x01010101,
407 LSSeqNumber: 0x80000001,
411 Content: IntraAreaPrefixLSA{
414 RefAdvRouter: 0x01010101,
420 AddressPrefix: []byte{0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x12},
431 if !reflect.DeepEqual(got, want) {
432 t.Errorf("OSPF packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
435 t.Error("No OSPF layer type found in packet")
438 func BenchmarkDecodePacketPacket3(b *testing.B) {
439 for i := 0; i < b.N; i++ {
440 gopacket.NewPacket(testPacketOSPF3LSUpdate, LinkTypeEthernet, gopacket.NoCopy)
444 // testPacketOSPF3LSAck is the packet:
445 // 14:43:54.185384 IP6 fe80::1 > ff02::5: OSPFv3, LS-Ack, length 136
446 // 0x0000: 3333 0000 0005 c200 1ffa 0001 86dd 6e00 33............n.
447 // 0x0010: 0000 0088 5901 fe80 0000 0000 0000 0000 ....Y...........
448 // 0x0020: 0000 0000 0001 ff02 0000 0000 0000 0000 ................
449 // 0x0030: 0000 0000 0005 0305 0088 0101 0101 0000 ................
450 // 0x0040: 0001 9d2c 0000 0005 2001 0000 0000 0202 ...,............
451 // 0x0050: 0202 8000 0002 b354 0018 0006 2003 0000 .......T........
452 // 0x0060: 0003 0202 0202 8000 0001 4473 0024 0006 ..........Ds.$..
453 // 0x0070: 2003 0000 0002 0202 0202 8000 0001 9c11 ................
454 // 0x0080: 0024 0006 2003 0000 0001 0202 0202 8000 .$..............
455 // 0x0090: 0001 cdba 0024 0006 2003 0000 0000 0202 .....$..........
456 // 0x00a0: 0202 8000 0001 efd7 0024 0005 0008 0000 .........$......
457 // 0x00b0: 0005 0202 0202 8000 0001 5433 002c ..........T3.,
458 var testPacketOSPF3LSAck = []byte{
459 0x33, 0x33, 0x00, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x1f, 0xfa, 0x00, 0x01, 0x86, 0xdd, 0x6e, 0x00,
460 0x00, 0x00, 0x00, 0x88, 0x59, 0x01, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
461 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
462 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x03, 0x05, 0x00, 0x88, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
463 0x00, 0x01, 0x9d, 0x2c, 0x00, 0x00, 0x00, 0x05, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
464 0x02, 0x02, 0x80, 0x00, 0x00, 0x02, 0xb3, 0x54, 0x00, 0x18, 0x00, 0x06, 0x20, 0x03, 0x00, 0x00,
465 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x80, 0x00, 0x00, 0x01, 0x44, 0x73, 0x00, 0x24, 0x00, 0x06,
466 0x20, 0x03, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x80, 0x00, 0x00, 0x01, 0x9c, 0x11,
467 0x00, 0x24, 0x00, 0x06, 0x20, 0x03, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x80, 0x00,
468 0x00, 0x01, 0xcd, 0xba, 0x00, 0x24, 0x00, 0x06, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
469 0x02, 0x02, 0x80, 0x00, 0x00, 0x01, 0xef, 0xd7, 0x00, 0x24, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00,
470 0x00, 0x05, 0x02, 0x02, 0x02, 0x02, 0x80, 0x00, 0x00, 0x01, 0x54, 0x33, 0x00, 0x2c,
473 func TestPacketOSPF3LSAck(t *testing.T) {
474 p := gopacket.NewPacket(testPacketOSPF3LSAck, LinkTypeEthernet, gopacket.Default)
475 if p.ErrorLayer() != nil {
476 t.Error("Failed to decode packet:", p.ErrorLayer().Error())
478 checkLayers(p, []gopacket.LayerType{LayerTypeEthernet, LayerTypeIPv6, LayerTypeOSPF}, t)
479 if got, ok := p.Layer(LayerTypeOSPF).(*OSPFv3); ok {
483 Type: OSPFLinkStateAcknowledgment,
488 Content: []LSAheader{
492 LinkStateID: 0x00000000,
493 AdvRouter: 0x02020202,
494 LSSeqNumber: 0x80000002,
501 LinkStateID: 0x00000003,
502 AdvRouter: 0x02020202,
503 LSSeqNumber: 0x80000001,
510 LinkStateID: 0x00000002,
511 AdvRouter: 0x02020202,
512 LSSeqNumber: 0x80000001,
519 LinkStateID: 0x00000001,
520 AdvRouter: 0x02020202,
521 LSSeqNumber: 0x80000001,
528 LinkStateID: 0x00000000,
529 AdvRouter: 0x02020202,
530 LSSeqNumber: 0x80000001,
537 LinkStateID: 0x00000005,
538 AdvRouter: 0x02020202,
539 LSSeqNumber: 0x80000001,
548 if !reflect.DeepEqual(got, want) {
549 t.Errorf("OSPF packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\n\n", got, want)
552 t.Error("No OSPF layer type found in packet")
555 func BenchmarkDecodePacketPacket4(b *testing.B) {
556 for i := 0; i < b.N; i++ {
557 gopacket.NewPacket(testPacketOSPF3LSAck, LinkTypeEthernet, gopacket.NoCopy)