3 #include <sys/socket.h>
5 #include <netinet/in.h>
7 #include "../src/lldpd.h"
10 char filenameprefix
[] = "edp_send";
14 START_TEST (test_send_basic
)
17 /* Packet we should build:
18 Extreme Discovery Protocol
22 Checksum: 0xde22 [correct]
26 Machine ID type: MAC (0)
27 Machine MAC: 5e:10:8e:e7:84:ad (5e:10:8e:e7:84:ad)
28 Display: "First chassis"
29 Marker 0x99, length 18, type 1 = Display
34 Info: Slot/Port: 1/4, Version: 7.6.4.99
35 Marker 0x99, length 36, type 2 = Info
42 Reserved: 000000000000
43 Version: 7.6.4 Internal: 99
47 Version (sustaining): 4
48 Version (internal): 99
49 Connections: FFFFFFFF000000000000000000000000
51 Marker 0x99, length 4, type 0 = Null
57 0x00, 0xe0, 0x2b, 0x00, 0x00, 0x00, 0x5e, 0x10,
58 0x8e, 0xe7, 0x84, 0xad, 0x00, 0x52, 0xaa, 0xaa,
59 0x03, 0x00, 0xe0, 0x2b, 0x00, 0xbb, 0x01, 0x00,
60 0x00, 0x4a, 0xde, 0x22, 0x00, 0x00, 0x00, 0x00,
61 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad, 0x99, 0x01,
62 0x00, 0x12, 0x46, 0x69, 0x72, 0x73, 0x74, 0x20,
63 0x63, 0x68, 0x61, 0x73, 0x73, 0x69, 0x73, 0x00,
64 0x99, 0x02, 0x00, 0x24, 0x00, 0x00, 0x00, 0x03,
65 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
66 0x07, 0x06, 0x04, 0x63, 0xff, 0xff, 0xff, 0xff,
67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68 0x00, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x04 };
71 /* Populate port and chassis */
72 hardware
.h_lport
.p_id_subtype
= LLDP_PORTID_SUBTYPE_IFNAME
;
73 hardware
.h_lport
.p_id
= "Not used";
74 hardware
.h_lport
.p_id_len
= strlen(hardware
.h_lport
.p_id
);
75 hardware
.h_lport
.p_descr
= "Not used";
76 strcpy(hardware
.h_ifname
, "eth3");
77 hardware
.h_ifindex
= 4;
78 chassis
.c_id_subtype
= LLDP_CHASSISID_SUBTYPE_LLADDR
;
79 chassis
.c_id
= macaddress
;
80 chassis
.c_id_len
= ETH_ALEN
;
81 chassis
.c_name
= "First chassis";
83 n
= edp_send(NULL
, &hardware
);
85 fail("unable to build packet");
88 if (TAILQ_EMPTY(&pkts
)) {
89 fail("no packets sent");
92 pkt
= TAILQ_FIRST(&pkts
);
93 ck_assert_int_eq(pkt
->size
, sizeof(pkt1
));
94 fail_unless(memcmp(pkt
->data
, pkt1
, sizeof(pkt1
)) == 0);
95 fail_unless(TAILQ_NEXT(pkt
, next
) == NULL
, "more than one packet sent");
100 START_TEST (test_send_vlans
)
103 /* Packets we should build:
104 Extreme Discovery Protocol
108 Checksum: 0xde20 [correct]
112 Machine ID type: MAC (0)
113 Machine MAC: 5e:10:8e:e7:84:ad (5e:10:8e:e7:84:ad)
114 Display: "First chassis"
115 Marker 0x99, length 18, type 1 = Display
117 TLV type: Display (1)
120 Info: Slot/Port: 1/4, Version: 7.6.4.99
121 Marker 0x99, length 36, type 2 = Info
128 Reserved: 000000000000
129 Version: 7.6.4 Internal: 99
133 Version (sustaining): 4
134 Version (internal): 99
135 Connections: FFFFFFFF000000000000000000000000
137 Marker 0x99, length 4, type 0 = Null
142 Extreme Discovery Protocol
146 Checksum: 0x28c4 [correct]
150 Machine ID type: MAC (0)
151 Machine MAC: 5e:10:8e:e7:84:ad (5e:10:8e:e7:84:ad)
152 Vlan: ID 157, Name "First VLAN"
153 Marker 0x99, length 27, type 5 = VL
158 0... .... = Flags-IP: Not set
159 .000 000. = Flags-reserved: 0x00
160 .... ...0 = Flags-Unknown: Not set
164 IP addr: 0.0.0.0 (0.0.0.0)
166 Vlan: ID 1247, Name "Second VLAN"
167 Marker 0x99, length 28, type 5 = VL
172 0... .... = Flags-IP: Not set
173 .000 000. = Flags-reserved: 0x00
174 .... ...0 = Flags-Unknown: Not set
178 IP addr: 0.0.0.0 (0.0.0.0)
180 Vlan: ID 741, Name "Third VLAN"
181 Marker 0x99, length 27, type 5 = VL
186 0... .... = Flags-IP: Not set
187 .000 000. = Flags-reserved: 0x00
188 .... ...0 = Flags-Unknown: Not set
192 IP addr: 0.0.0.0 (0.0.0.0)
195 Marker 0x99, length 4, type 0 = Null
201 0x00, 0xe0, 0x2b, 0x00, 0x00, 0x00, 0x5e, 0x10,
202 0x8e, 0xe7, 0x84, 0xad, 0x00, 0x52, 0xaa, 0xaa,
203 0x03, 0x00, 0xe0, 0x2b, 0x00, 0xbb, 0x01, 0x00,
204 0x00, 0x4a, 0xde, 0x20, 0x00, 0x02, 0x00, 0x00,
205 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad, 0x99, 0x01,
206 0x00, 0x12, 0x46, 0x69, 0x72, 0x73, 0x74, 0x20,
207 0x63, 0x68, 0x61, 0x73, 0x73, 0x69, 0x73, 0x00,
208 0x99, 0x02, 0x00, 0x24, 0x00, 0x00, 0x00, 0x03,
209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
210 0x07, 0x06, 0x04, 0x63, 0xff, 0xff, 0xff, 0xff,
211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
212 0x00, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x04 };
215 0x00, 0xe0, 0x2b, 0x00, 0x00, 0x00, 0x5e, 0x10,
216 0x8e, 0xe7, 0x84, 0xad, 0x00, 0x6e, 0xaa, 0xaa,
217 0x03, 0x00, 0xe0, 0x2b, 0x00, 0xbb, 0x01, 0x00,
218 0x00, 0x66, 0x28, 0xc4, 0x00, 0x03, 0x00, 0x00,
219 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad, 0x99, 0x05,
220 0x00, 0x1b, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00,
221 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x69,
222 0x72, 0x73, 0x74, 0x20, 0x56, 0x4c, 0x41, 0x4e,
223 0x00, 0x99, 0x05, 0x00, 0x1c, 0x00, 0x00, 0x04,
224 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
225 0x00, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20,
226 0x56, 0x4c, 0x41, 0x4e, 0x00, 0x99, 0x05, 0x00,
227 0x1b, 0x00, 0x00, 0x02, 0xe5, 0x00, 0x00, 0x00,
228 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x68, 0x69,
229 0x72, 0x64, 0x20, 0x56, 0x4c, 0x41, 0x4e, 0x00,
230 0x99, 0x00, 0x00, 0x04 };
233 struct lldpd_vlan vlan1
, vlan2
, vlan3
;
235 /* Populate port and chassis */
236 hardware
.h_lport
.p_id_subtype
= LLDP_PORTID_SUBTYPE_IFNAME
;
237 hardware
.h_lport
.p_id
= "Not used";
238 hardware
.h_lport
.p_id_len
= strlen(hardware
.h_lport
.p_id
);
239 hardware
.h_lport
.p_descr
= "Not used";
240 strcpy(hardware
.h_ifname
, "eth3");
241 hardware
.h_ifindex
= 4;
242 chassis
.c_id_subtype
= LLDP_CHASSISID_SUBTYPE_LLADDR
;
243 chassis
.c_id
= macaddress
;
244 chassis
.c_id_len
= ETH_ALEN
;
245 chassis
.c_name
= "First chassis";
246 vlan1
.v_name
= "First VLAN"; vlan1
.v_vid
= 157;
247 vlan2
.v_name
= "Second VLAN"; vlan2
.v_vid
= 1247;
248 vlan3
.v_name
= "Third VLAN"; vlan3
.v_vid
= 741;
249 TAILQ_INSERT_TAIL(&hardware
.h_lport
.p_vlans
, &vlan1
, v_entries
);
250 TAILQ_INSERT_TAIL(&hardware
.h_lport
.p_vlans
, &vlan2
, v_entries
);
251 TAILQ_INSERT_TAIL(&hardware
.h_lport
.p_vlans
, &vlan3
, v_entries
);
254 n
= edp_send(NULL
, &hardware
);
256 fail("unable to build packet");
259 if (TAILQ_EMPTY(&pkts
)) {
260 fail("no packets sent");
263 pkt
= TAILQ_FIRST(&pkts
);
264 ck_assert_int_eq(pkt
->size
, sizeof(pkt1
));
265 fail_unless(memcmp(pkt
->data
, pkt1
, sizeof(pkt1
)) == 0);
266 pkt
= TAILQ_NEXT(pkt
, next
);
268 fail("need one more packet");
271 ck_assert_int_eq(pkt
->size
, sizeof(pkt2
));
272 fail_unless(memcmp(pkt
->data
, pkt2
, sizeof(pkt2
)) == 0);
273 fail_unless(TAILQ_NEXT(pkt
, next
) == NULL
, "more than two packets sent");
278 START_TEST (test_recv_edp
)
281 0x00, 0xe0, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x04,
282 0x96, 0x05, 0x44, 0x6f, 0x01, 0x44, 0xaa, 0xaa,
283 0x03, 0x00, 0xe0, 0x2b, 0x00, 0xbb, 0x01, 0x00,
284 0x01, 0x3c, 0x05, 0xdf, 0x03, 0x0f, 0x00, 0x00,
285 0x00, 0x04, 0x96, 0x05, 0x44, 0x6f, 0x99, 0x02,
286 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
287 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x06,
288 0x04, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
289 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
290 0x00, 0x00, 0x99, 0x01, 0x01, 0x04, 0x6e, 0x65,
291 0x30, 0x35, 0x30, 0x31, 0x73, 0x77, 0x2e, 0x58,
292 0x58, 0x58, 0x58, 0x58, 0x58, 0x00, 0x00, 0x00,
293 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
294 0x00, 0x00, 0x00, 0x03, 0x7b, 0x00, 0x00, 0x00,
295 0x00, 0x00, 0x80, 0x79, 0x0d, 0xec, 0xff, 0xff,
296 0xff, 0xff, 0x80, 0xa7, 0x8b, 0x24, 0x00, 0x00,
297 0x00, 0x00, 0x00, 0x17, 0x08, 0x7e, 0xe5, 0xe2,
298 0x00, 0x00, 0xee, 0xee, 0xee, 0xee, 0x00, 0x00,
299 0x00, 0x02, 0x81, 0xb2, 0x19, 0xf0, 0x00, 0x00,
300 0x00, 0x02, 0x80, 0xa5, 0x67, 0x20, 0xee, 0xee,
301 0xee, 0xee, 0x80, 0xea, 0x8c, 0xac, 0x00, 0x00,
302 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
303 0x00, 0x00, 0x00, 0xe0, 0x2b, 0x00, 0x00, 0x00,
304 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
305 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
306 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
307 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
308 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
309 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
310 0x00, 0x00, 0x00, 0xe0, 0x2b, 0x00, 0x00, 0x00,
311 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
312 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
313 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
314 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
315 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
316 0x00, 0x00, 0x80, 0xa4, 0x86, 0x2c, 0xee, 0xee,
317 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee,
318 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0x00, 0x00,
319 0x00, 0x00, 0xee, 0xee, 0xee, 0xee, 0x00, 0xe0,
320 0x2b, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
321 0x00, 0x00, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee,
322 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0x99, 0x00,
326 Destination: Extreme-EDP (00:e0:2b:00:00:00)
327 Source: ExtremeN_05:44:6f (00:04:96:05:44:6f)
334 Control field: U, func=UI (0x03)
335 000. 00.. = Command: Unnumbered Information (0x00)
336 .... ..11 = Frame type: Unnumbered frame (0x03)
337 Organization Code: Extreme Networks (0x00e02b)
339 Extreme Discovery Protocol
343 Checksum: 0xdf05 [correct]
347 Machine ID type: MAC (0)
348 Machine MAC: ExtremeN_05:44:6f (00:04:96:05:44:6f)
349 Info: Slot/Port: 1/1, Version: 7.6.4.0
350 Marker 0x99, length 36, type 2 = Info
357 Reserved: 000000000000
358 Version: 7.6.4 Internal: 0
362 Version (sustaining): 4
363 Version (internal): 0
364 Connections: FFFF0000000000000000000000000000
365 Display: "ne0501sw.XXXXXX"
366 Marker 0x99, length 260, type 1 = Display
368 TLV type: Display (1)
370 Name: ne0501sw.XXXXXX
372 Marker 0x99, length 4, type 0 = Null
380 0x00, 0xe0, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x04,
381 0x96, 0x05, 0x44, 0x6f, 0x01, 0x48, 0xaa, 0xaa,
382 0x03, 0x00, 0xe0, 0x2b, 0x00, 0xbb, 0x01, 0x00,
383 0x01, 0x40, 0x73, 0x04, 0x03, 0x10, 0x00, 0x00,
384 0x00, 0x04, 0x96, 0x05, 0x44, 0x6f, 0x99, 0x05,
385 0x00, 0x64, 0x80, 0x00, 0x00, 0x01, 0x00, 0x00,
386 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x65,
387 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x43, 0x61,
388 0x6e, 0x6e, 0x6f, 0x74, 0x20, 0x73, 0x61, 0x76,
389 0x65, 0x20, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65,
390 0x20, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74,
391 0x20, 0x74, 0x6f, 0x20, 0x6e, 0x76, 0x20, 0x28,
392 0x25, 0x64, 0x29, 0x0a, 0x00, 0x00, 0x4e, 0x6f,
393 0x20, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x20,
394 0x66, 0x6f, 0x72, 0x20, 0x73, 0x75, 0x70, 0x65,
395 0x72, 0x42, 0x72, 0x69, 0x64, 0x67, 0x65, 0x49,
396 0x6e, 0x73, 0x74, 0x20, 0x25, 0x64, 0x00, 0x00,
397 0x00, 0x00, 0x99, 0x05, 0x00, 0x64, 0x00, 0x00,
398 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
399 0x00, 0x00, 0x4d, 0x61, 0x63, 0x56, 0x6c, 0x61,
400 0x6e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65,
401 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
402 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
403 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
404 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
405 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
406 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
407 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
408 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
409 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99, 0x05,
410 0x00, 0x64, 0x80, 0x00, 0x00, 0x32, 0x00, 0x00,
411 0x00, 0x00, 0x0a, 0x32, 0x00, 0x3f, 0x41, 0x64,
412 0x6d, 0x69, 0x6e, 0x42, 0x32, 0x00, 0x00, 0x00,
413 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
414 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
415 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
416 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
417 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
418 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
419 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
420 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
421 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
422 0x00, 0x00, 0x99, 0x00, 0x00, 0x04 };
425 Destination: Extreme-EDP (00:e0:2b:00:00:00)
426 Source: ExtremeN_05:44:6f (00:04:96:05:44:6f)
433 Control field: U, func=UI (0x03)
434 000. 00.. = Command: Unnumbered Information (0x00)
435 .... ..11 = Frame type: Unnumbered frame (0x03)
436 Organization Code: Extreme Networks (0x00e02b)
438 Extreme Discovery Protocol
442 Checksum: 0x7304 [correct]
446 Machine ID type: MAC (0)
447 Machine MAC: ExtremeN_05:44:6f (00:04:96:05:44:6f)
448 Vlan: ID 1, Name "Default"
449 Marker 0x99, length 100, type 5 = VL
454 1... .... = Flags-IP: Set
455 .000 000. = Flags-reserved: 0x00
456 .... ...0 = Flags-Unknown: Not set
460 IP addr: 0.0.0.0 (0.0.0.0)
462 Vlan: ID 0, Name "MacVlanDiscover"
463 Marker 0x99, length 100, type 5 = VL
468 0... .... = Flags-IP: Not set
469 .000 000. = Flags-reserved: 0x00
470 .... ...0 = Flags-Unknown: Not set
474 IP addr: 0.0.0.0 (0.0.0.0)
475 Name: MacVlanDiscover
476 Vlan: ID 50, Name "AdminB2"
477 Marker 0x99, length 100, type 5 = VL
482 1... .... = Flags-IP: Set
483 .000 000. = Flags-reserved: 0x00
484 .... ...0 = Flags-Unknown: Not set
488 IP addr: 10.50.0.63 (10.50.0.63)
491 Marker 0x99, length 4, type 0 = Null
496 struct lldpd_vlan
*vlan
;
498 struct lldpd_chassis
*nchassis
= NULL
;
499 struct lldpd_port
*nport
= NULL
;
501 char mac1
[] = { 0x00, 0x04, 0x96, 0x05, 0x44, 0x6f };
503 cfg
.g_mgmt_pattern
= NULL
;
504 fail_unless(edp_decode(&cfg
, pkt1
, sizeof(pkt1
), &hardware
,
505 &nchassis
, &nport
) != -1);
506 if (!nchassis
|| !nport
) {
507 fail("unable to decode packet");
510 ck_assert_int_eq(nchassis
->c_id_subtype
,
511 LLDP_CHASSISID_SUBTYPE_LLADDR
);
512 ck_assert_int_eq(nchassis
->c_id_len
, ETH_ALEN
);
513 fail_unless(memcmp(nchassis
->c_id
, mac1
, ETH_ALEN
) == 0);
514 ck_assert_int_eq(nport
->p_id_subtype
,
515 LLDP_PORTID_SUBTYPE_IFNAME
);
516 ck_assert_int_eq(nport
->p_id_len
, strlen("1/1"));
517 fail_unless(memcmp(nport
->p_id
,
518 "1/1", strlen("1/1")) == 0);
519 ck_assert_str_eq(nport
->p_descr
, "Slot 1 / Port 1");
520 ck_assert_str_eq(nchassis
->c_name
, "ne0501sw.XXXXXX");
521 ck_assert_str_eq(nchassis
->c_descr
, "EDP enabled device, version 7.6.4.0");
522 ck_assert_int_eq(nchassis
->c_cap_enabled
, 0);
525 /* Add this port to list of remote port for hardware port */
526 TAILQ_INSERT_TAIL(&hardware
.h_rports
, nport
, p_entries
);
527 nport
->p_chassis
= nchassis
;
528 nport
->p_protocol
= LLDPD_MODE_EDP
;
530 /* Recept second packet */
531 nchassis
= NULL
; nport
= NULL
;
532 fail_unless(edp_decode(&cfg
, pkt2
, sizeof(pkt2
), &hardware
,
533 &nchassis
, &nport
) == -1);
534 nport
= TAILQ_FIRST(&hardware
.h_rports
);
536 fail("unable to find our previous port?");
539 ck_assert_int_eq(TAILQ_FIRST(&nport
->p_chassis
->c_mgmt
)->m_addr
.inet
.s_addr
,
540 (u_int32_t
)inet_addr("10.50.0.63"));
541 if (TAILQ_EMPTY(&nport
->p_vlans
)) {
545 vlan
= TAILQ_FIRST(&nport
->p_vlans
);
546 ck_assert_int_eq(vlan
->v_vid
, 1);
547 ck_assert_str_eq(vlan
->v_name
, "Default");
548 vlan
= TAILQ_NEXT(vlan
, v_entries
);
550 fail("no more VLAN");
553 ck_assert_int_eq(vlan
->v_vid
, 0);
554 ck_assert_str_eq(vlan
->v_name
, "MacVlanDiscover");
555 vlan
= TAILQ_NEXT(vlan
, v_entries
);
557 fail("no more VLAN");
560 ck_assert_int_eq(vlan
->v_vid
, 50);
561 ck_assert_str_eq(vlan
->v_name
, "AdminB2");
562 vlan
= TAILQ_NEXT(vlan
, v_entries
);
563 fail_unless(vlan
== NULL
);
573 Suite
*s
= suite_create("EDP");
576 TCase
*tc_send
= tcase_create("Send EDP packets");
577 tcase_add_checked_fixture(tc_send
, pcap_setup
, pcap_teardown
);
578 tcase_add_test(tc_send
, test_send_basic
);
580 tcase_add_test(tc_send
, test_send_vlans
);
582 suite_add_tcase(s
, tc_send
);
584 TCase
*tc_receive
= tcase_create("Receive EDP packets");
585 tcase_add_test(tc_receive
, test_recv_edp
);
586 suite_add_tcase(s
, tc_receive
);
596 Suite
*s
= edp_suite ();
597 SRunner
*sr
= srunner_create (s
);
598 srunner_set_fork_status (sr
, CK_NOFORK
); /* Can't fork because
601 srunner_run_all (sr
, CK_ENV
);
602 number_failed
= srunner_ntests_failed (sr
);
604 return (number_failed
== 0) ? EXIT_SUCCESS
: EXIT_FAILURE
;