3 #include <sys/socket.h>
5 #include <netinet/in.h>
7 #include "../src/lldpd.h"
10 char filenameprefix
[] = "cdp_send";
14 START_TEST (test_send_cdpv1
)
17 /* Packet we should build:
19 Destination: CDP/VTP/DTP/PAgP/UDLD (01:00:0c:cc:cc:cc)
20 Source: 5e:10:8e:e7:84:ad (5e:10:8e:e7:84:ad)
27 Control field: U, func=UI (0x03)
28 000. 00.. = Command: Unnumbered Information (0x00)
29 .... ..11 = Frame type: Unnumbered frame (0x03)
30 Organization Code: Cisco (0x00000c)
32 Cisco Discovery Protocol
35 Checksum: 0x3af7 [correct]
38 Device ID: First chassis
39 Type: Device ID (0x0001)
41 Device ID: First chassis
43 Type: Addresses (0x0002)
45 Number of addresses: 1
46 IP address: 172.17.142.37
51 IP address: 172.17.142.37
52 Port ID: FastEthernet 1/5
53 Type: Port ID (0x0003)
55 Sent through Interface: FastEthernet 1/5
57 Type: Capabilities (0x0004)
59 Capabilities: 0x00000011
60 .... .... .... .... .... .... .... ...1 = Is a Router
61 .... .... .... .... .... .... .... ..0. = Not a Transparent Bridge
62 .... .... .... .... .... .... .... .0.. = Not a Source Route Bridge
63 .... .... .... .... .... .... .... 0... = Not a Switch
64 .... .... .... .... .... .... ...1 .... = Is a Host
65 .... .... .... .... .... .... ..0. .... = Not IGMP capable
66 .... .... .... .... .... .... .0.. .... = Not a Repeater
68 Type: Software version (0x0005)
70 Software Version: Chassis description
72 Type: Platform (0x0006)
77 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc, 0x5e, 0x10,
78 0x8e, 0xe7, 0x84, 0xad, 0x00, 0x6a, 0xaa, 0xaa,
79 0x03, 0x00, 0x00, 0x0c, 0x20, 0x00, 0x01, 0xb4,
80 0x3a, 0xf7, 0x00, 0x01, 0x00, 0x11, 0x46, 0x69,
81 0x72, 0x73, 0x74, 0x20, 0x63, 0x68, 0x61, 0x73,
82 0x73, 0x69, 0x73, 0x00, 0x02, 0x00, 0x11, 0x00,
83 0x00, 0x00, 0x01, 0x01, 0x01, 0xcc, 0x00, 0x04,
84 0xac, 0x11, 0x8e, 0x25, 0x00, 0x03, 0x00, 0x14,
85 0x46, 0x61, 0x73, 0x74, 0x45, 0x74, 0x68, 0x65,
86 0x72, 0x6e, 0x65, 0x74, 0x20, 0x31, 0x2f, 0x35,
87 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x11,
88 0x00, 0x05, 0x00, 0x17, 0x43, 0x68, 0x61, 0x73,
89 0x73, 0x69, 0x73, 0x20, 0x64, 0x65, 0x73, 0x63,
90 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x00,
91 0x06, 0x00, 0x09, 0x4c, 0x69, 0x6e, 0x75, 0x78 };
94 /* Populate port and chassis */
95 hardware
.h_lport
.p_id_subtype
= LLDP_PORTID_SUBTYPE_IFNAME
;
96 hardware
.h_lport
.p_id
= "Not used";
97 hardware
.h_lport
.p_id_len
= strlen(hardware
.h_lport
.p_id
);
98 hardware
.h_lport
.p_descr
= "FastEthernet 1/5";
99 chassis
.c_id_subtype
= LLDP_CHASSISID_SUBTYPE_LLADDR
;
100 chassis
.c_id
= macaddress
;
101 chassis
.c_id_len
= ETH_ALEN
;
102 chassis
.c_name
= "First chassis";
103 chassis
.c_descr
= "Chassis description";
104 chassis
.c_cap_available
= chassis
.c_cap_enabled
= LLDP_CAP_ROUTER
;
105 TAILQ_INIT(&chassis
.c_mgmt
);
106 in_addr_t addr
= inet_addr("172.17.142.37");
107 struct lldpd_mgmt
*mgmt
= lldpd_alloc_mgmt(LLDPD_AF_IPV4
,
108 &addr
, sizeof(in_addr_t
), 0);
111 TAILQ_INSERT_TAIL(&chassis
.c_mgmt
, mgmt
, m_entries
);
114 n
= cdpv1_send(NULL
, &hardware
);
116 fail("unable to build packet");
119 if (TAILQ_EMPTY(&pkts
)) {
120 fail("no packets sent");
123 pkt
= TAILQ_FIRST(&pkts
);
124 ck_assert_int_eq(pkt
->size
, sizeof(pkt1
));
125 fail_unless(memcmp(pkt
->data
, pkt1
, sizeof(pkt1
)) == 0);
126 fail_unless(TAILQ_NEXT(pkt
, next
) == NULL
, "more than one packet sent");
130 START_TEST (test_send_cdpv2
)
133 /* Packet we should build:
135 Destination: CDP/VTP/DTP/PAgP/UDLD (01:00:0c:cc:cc:cc)
136 Source: 5e:10:8e:e7:84:ad (5e:10:8e:e7:84:ad)
144 Control field: U, func=UI (0x03)
145 000. 00.. = Command: Unnumbered Information (0x00)
146 .... ..11 = Frame type: Unnumbered frame (0x03)
147 Organization Code: Cisco (0x00000c)
149 Cisco Discovery Protocol
152 Checksum: 0x5926 [correct]
155 Device ID: Second chassis
156 Type: Device ID (0x0001)
158 Device ID: Second chassis
160 Type: Addresses (0x0002)
162 Number of addresses: 1
163 IP address: 172.17.142.36
168 IP address: 172.17.142.36
169 Port ID: Gigabit Ethernet 5/8
170 Type: Port ID (0x0003)
172 Sent through Interface: Gigabit Ethernet 5/8
174 Type: Capabilities (0x0004)
176 Capabilities: 0x00000019
177 .... .... .... .... .... .... .... ...1 = Is a Router
178 .... .... .... .... .... .... .... ..0. = Not a Transparent Bridge
179 .... .... .... .... .... .... .... .0.. = Not a Source Route Bridge
180 .... .... .... .... .... .... .... 1... = Is a Switch
181 .... .... .... .... .... .... ...1 .... = Is a Host
182 .... .... .... .... .... .... ..0. .... = Not IGMP capable
183 .... .... .... .... .... .... .0.. .... = Not a Repeater
185 Type: Software version (0x0005)
187 Software Version: Chassis description
189 Type: Platform (0x0006)
194 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc, 0x5e, 0x10,
195 0x8e, 0xe7, 0x84, 0xad, 0x00, 0x6f, 0xaa, 0xaa,
196 0x03, 0x00, 0x00, 0x0c, 0x20, 0x00, 0x02, 0xb4,
197 0x59, 0x26, 0x00, 0x01, 0x00, 0x12, 0x53, 0x65,
198 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x63, 0x68, 0x61,
199 0x73, 0x73, 0x69, 0x73, 0x00, 0x02, 0x00, 0x11,
200 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0xcc, 0x00,
201 0x04, 0xac, 0x11, 0x8e, 0x24, 0x00, 0x03, 0x00,
202 0x18, 0x47, 0x69, 0x67, 0x61, 0x62, 0x69, 0x74,
203 0x20, 0x45, 0x74, 0x68, 0x65, 0x72, 0x6e, 0x65,
204 0x74, 0x20, 0x35, 0x2f, 0x38, 0x00, 0x04, 0x00,
205 0x08, 0x00, 0x00, 0x00, 0x19, 0x00, 0x05, 0x00,
206 0x17, 0x43, 0x68, 0x61, 0x73, 0x73, 0x69, 0x73,
207 0x20, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70,
208 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x09,
209 0x4c, 0x69, 0x6e, 0x75, 0x78 };
212 /* Populate port and chassis */
213 hardware
.h_lport
.p_id_subtype
= LLDP_PORTID_SUBTYPE_LLADDR
;
214 hardware
.h_lport
.p_id
= macaddress
;
215 hardware
.h_lport
.p_id_len
= ETH_ALEN
;
216 hardware
.h_lport
.p_descr
= "Gigabit Ethernet 5/8";
217 chassis
.c_id_subtype
= LLDP_CHASSISID_SUBTYPE_LLADDR
;
218 chassis
.c_id
= macaddress
;
219 chassis
.c_id_len
= ETH_ALEN
;
220 chassis
.c_name
= "Second chassis";
221 chassis
.c_descr
= "Chassis description";
222 chassis
.c_cap_available
= chassis
.c_cap_enabled
=
223 LLDP_CAP_ROUTER
| LLDP_CAP_BRIDGE
;
224 TAILQ_INIT(&chassis
.c_mgmt
);
225 in_addr_t addr
= inet_addr("172.17.142.36");
226 struct lldpd_mgmt
*mgmt
= lldpd_alloc_mgmt(LLDPD_AF_IPV4
,
227 &addr
, sizeof(in_addr_t
), 0);
230 TAILQ_INSERT_TAIL(&chassis
.c_mgmt
, mgmt
, m_entries
);
233 n
= cdpv2_send(NULL
, &hardware
);
235 fail("unable to build packet");
238 if (TAILQ_EMPTY(&pkts
)) {
239 fail("no packets sent");
242 pkt
= TAILQ_FIRST(&pkts
);
243 ck_assert_int_eq(pkt
->size
, sizeof(pkt1
));
244 fail_unless(memcmp(pkt
->data
, pkt1
, sizeof(pkt1
)) == 0);
245 fail_unless(TAILQ_NEXT(pkt
, next
) == NULL
, "more than one packet sent");
249 START_TEST (test_recv_cdpv1
)
252 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc, 0x00, 0xe0,
253 0x1e, 0xd5, 0xd5, 0x15, 0x01, 0x1e, 0xaa, 0xaa,
254 0x03, 0x00, 0x00, 0x0c, 0x20, 0x00, 0x01, 0xb4,
255 0xdf, 0xf0, 0x00, 0x01, 0x00, 0x06, 0x52, 0x31,
256 0x00, 0x02, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01,
257 0x01, 0x01, 0xcc, 0x00, 0x04, 0xc0, 0xa8, 0x0a,
258 0x01, 0x00, 0x03, 0x00, 0x0d, 0x45, 0x74, 0x68,
259 0x65, 0x72, 0x6e, 0x65, 0x74, 0x30, 0x00, 0x04,
260 0x00, 0x08, 0x00, 0x00, 0x00, 0x11, 0x00, 0x05,
261 0x00, 0xd8, 0x43, 0x69, 0x73, 0x63, 0x6f, 0x20,
262 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74,
263 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x4f, 0x70, 0x65,
264 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x53,
265 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x53, 0x6f,
266 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x20, 0x0a,
267 0x49, 0x4f, 0x53, 0x20, 0x28, 0x74, 0x6d, 0x29,
268 0x20, 0x31, 0x36, 0x30, 0x30, 0x20, 0x53, 0x6f,
269 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x20, 0x28,
270 0x43, 0x31, 0x36, 0x30, 0x30, 0x2d, 0x4e, 0x59,
271 0x2d, 0x4c, 0x29, 0x2c, 0x20, 0x56, 0x65, 0x72,
272 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x31, 0x2e,
273 0x32, 0x28, 0x31, 0x32, 0x29, 0x50, 0x2c, 0x20,
274 0x52, 0x45, 0x4c, 0x45, 0x41, 0x53, 0x45, 0x20,
275 0x53, 0x4f, 0x46, 0x54, 0x57, 0x41, 0x52, 0x45,
276 0x20, 0x28, 0x66, 0x63, 0x31, 0x29, 0x0a, 0x43,
277 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74,
278 0x20, 0x28, 0x63, 0x29, 0x20, 0x31, 0x39, 0x38,
279 0x36, 0x2d, 0x31, 0x39, 0x39, 0x38, 0x20, 0x62,
280 0x79, 0x20, 0x63, 0x69, 0x73, 0x63, 0x6f, 0x20,
281 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2c,
282 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x0a, 0x43, 0x6f,
283 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x64, 0x20, 0x54,
284 0x75, 0x65, 0x20, 0x30, 0x33, 0x2d, 0x4d, 0x61,
285 0x72, 0x2d, 0x39, 0x38, 0x20, 0x30, 0x36, 0x3a,
286 0x33, 0x33, 0x20, 0x62, 0x79, 0x20, 0x64, 0x73,
287 0x63, 0x68, 0x77, 0x61, 0x72, 0x74, 0x00, 0x06,
288 0x00, 0x0e, 0x63, 0x69, 0x73, 0x63, 0x6f, 0x20,
289 0x31, 0x36, 0x30, 0x31 };
292 Destination: CDP/VTP/DTP/PAgP/UDLD (01:00:0c:cc:cc:cc)
293 Source: Cisco_d5:d5:15 (00:e0:1e:d5:d5:15)
300 Control field: U, func=UI (0x03)
301 000. 00.. = Command: Unnumbered Information (0x00)
302 .... ..11 = Frame type: Unnumbered frame (0x03)
303 Organization Code: Cisco (0x00000c)
305 Cisco Discovery Protocol
308 Checksum: 0xdff0 [correct]
312 Type: Device ID (0x0001)
316 Type: Addresses (0x0002)
318 Number of addresses: 1
319 IP address: 192.168.10.1
324 IP address: 192.168.10.1
326 Type: Port ID (0x0003)
328 Sent through Interface: Ethernet0
330 Type: Capabilities (0x0004)
332 Capabilities: 0x00000011
333 .... .... .... .... .... .... .... ...1 = Is a Router
334 .... .... .... .... .... .... .... ..0. = Not a Transparent Bridge
335 .... .... .... .... .... .... .... .0.. = Not a Source Route Bridge
336 .... .... .... .... .... .... .... 0... = Not a Switch
337 .... .... .... .... .... .... ...1 .... = Is a Host
338 .... .... .... .... .... .... ..0. .... = Not IGMP capable
339 .... .... .... .... .... .... .0.. .... = Not a Repeater
341 Type: Software version (0x0005)
343 Software Version: Cisco Internetwork Operating System Software
344 IOS (tm) 1600 Software (C1600-NY-L), Version 11.2(12)P, RELEASE SOFTWARE (fc1)
345 Copyright (c) 1986-1998 by cisco Systems, Inc.
346 Compiled Tue 03-Mar-98 06:33 by dschwart
348 Type: Platform (0x0006)
352 struct lldpd_chassis
*nchassis
= NULL
;
353 struct lldpd_port
*nport
= NULL
;
355 fail_unless(cdpv1_guess(pkt1
, sizeof(pkt1
)));
356 fail_unless(cdp_decode(NULL
, pkt1
, sizeof(pkt1
), &hardware
,
357 &nchassis
, &nport
) != -1);
358 if (!nchassis
|| !nport
) {
359 fail("unable to decode packet");
362 ck_assert_int_eq(nchassis
->c_id_subtype
,
363 LLDP_CHASSISID_SUBTYPE_LOCAL
);
364 ck_assert_int_eq(nchassis
->c_id_len
, 2);
365 fail_unless(memcmp(nchassis
->c_id
, "R1", 2) == 0);
366 ck_assert_str_eq(nchassis
->c_name
, "R1");
367 ck_assert_int_eq(nchassis
->c_mgmt
.tqh_first
->m_addr
.inet
.s_addr
,
368 (u_int32_t
)inet_addr("192.168.10.1"));
369 ck_assert_int_eq(nchassis
->c_mgmt
.tqh_first
->m_iface
, 0);
370 ck_assert_int_eq(nport
->p_id_subtype
,
371 LLDP_PORTID_SUBTYPE_IFNAME
);
372 ck_assert_int_eq(nport
->p_id_len
, strlen("Ethernet0"));
373 fail_unless(memcmp(nport
->p_id
,
374 "Ethernet0", strlen("Ethernet0")) == 0);
375 ck_assert_str_eq(nport
->p_descr
, "Ethernet0");
376 ck_assert_int_eq(nchassis
->c_cap_enabled
, LLDP_CAP_ROUTER
);
377 ck_assert_str_eq(nchassis
->c_descr
,
378 "cisco 1601 running on\n"
379 "Cisco Internetwork Operating System Software \n"
380 "IOS (tm) 1600 Software (C1600-NY-L), Version 11.2(12)P, RELEASE SOFTWARE (fc1)\n"
381 "Copyright (c) 1986-1998 by cisco Systems, Inc.\n"
382 "Compiled Tue 03-Mar-98 06:33 by dschwart");
386 START_TEST (test_recv_cdpv2
)
389 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc, 0xca, 0x00,
390 0x68, 0x46, 0x00, 0x00, 0x01, 0x30, 0xaa, 0xaa,
391 0x03, 0x00, 0x00, 0x0c, 0x20, 0x00, 0x02, 0xb4,
392 0x54, 0x27, 0x00, 0x01, 0x00, 0x0f, 0x72, 0x74,
393 0x62, 0x67, 0x36, 0x74, 0x65, 0x73, 0x74, 0x30,
394 0x31, 0x00, 0x05, 0x00, 0xd3, 0x43, 0x69, 0x73,
395 0x63, 0x6f, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72,
396 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x20,
397 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6e,
398 0x67, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d,
399 0x20, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72,
400 0x65, 0x20, 0x0a, 0x49, 0x4f, 0x53, 0x20, 0x28,
401 0x74, 0x6d, 0x29, 0x20, 0x37, 0x32, 0x30, 0x30,
402 0x20, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72,
403 0x65, 0x20, 0x28, 0x43, 0x37, 0x32, 0x30, 0x30,
404 0x2d, 0x50, 0x2d, 0x4d, 0x29, 0x2c, 0x20, 0x56,
405 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31,
406 0x32, 0x2e, 0x32, 0x28, 0x34, 0x36, 0x29, 0x2c,
407 0x20, 0x52, 0x45, 0x4c, 0x45, 0x41, 0x53, 0x45,
408 0x20, 0x53, 0x4f, 0x46, 0x54, 0x57, 0x41, 0x52,
409 0x45, 0x20, 0x28, 0x66, 0x63, 0x31, 0x29, 0x0a,
410 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68,
411 0x74, 0x20, 0x28, 0x63, 0x29, 0x20, 0x31, 0x39,
412 0x38, 0x36, 0x2d, 0x32, 0x30, 0x30, 0x37, 0x20,
413 0x62, 0x79, 0x20, 0x63, 0x69, 0x73, 0x63, 0x6f,
414 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73,
415 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x0a, 0x43,
416 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x64, 0x20,
417 0x54, 0x68, 0x75, 0x20, 0x32, 0x36, 0x2d, 0x41,
418 0x70, 0x72, 0x2d, 0x30, 0x37, 0x20, 0x32, 0x31,
419 0x3a, 0x35, 0x36, 0x20, 0x62, 0x79, 0x20, 0x70,
420 0x77, 0x61, 0x64, 0x65, 0x00, 0x06, 0x00, 0x11,
421 0x63, 0x69, 0x73, 0x63, 0x6f, 0x20, 0x37, 0x32,
422 0x30, 0x36, 0x56, 0x58, 0x52, 0x00, 0x02, 0x00,
423 0x11, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0xcc,
424 0x00, 0x04, 0xac, 0x42, 0x37, 0x03, 0x00, 0x03,
425 0x00, 0x13, 0x46, 0x61, 0x73, 0x74, 0x45, 0x74,
426 0x68, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x30, 0x2f,
427 0x30, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00,
428 0x00, 0x00, 0x0b, 0x00, 0x05, 0x00 };
431 Destination: CDP/VTP/DTP/PAgP/UDLD (01:00:0c:cc:cc:cc)
432 Source: ca:00:68:46:00:00 (ca:00:68:46:00:00)
439 Control field: U, func=UI (0x03)
440 000. 00.. = Command: Unnumbered Information (0x00)
441 .... ..11 = Frame type: Unnumbered frame (0x03)
442 Organization Code: Cisco (0x00000c)
444 Cisco Discovery Protocol
447 Checksum: 0x5427 [correct]
450 Device ID: rtbg6test01
451 Type: Device ID (0x0001)
453 Device ID: rtbg6test01
455 Type: Software version (0x0005)
457 Software Version: Cisco Internetwork Operating System Software
458 IOS (tm) 7200 Software (C7200-P-M), Version 12.2(46), RELEASE SOFTWARE (fc1)
459 Copyright (c) 1986-2007 by cisco Systems, Inc.
460 Compiled Thu 26-Apr-07 21:56 by pwade
461 Platform: cisco 7206VXR
462 Type: Platform (0x0006)
464 Platform: cisco 7206VXR
466 Type: Addresses (0x0002)
468 Number of addresses: 1
469 IP address: 172.66.55.3
474 IP address: 172.66.55.3
475 Port ID: FastEthernet0/0
476 Type: Port ID (0x0003)
478 Sent through Interface: FastEthernet0/0
480 Type: Capabilities (0x0004)
482 Capabilities: 0x00000000
483 .... .... .... .... .... .... .... ...0 = Not a Router
484 .... .... .... .... .... .... .... ..0. = Not a Transparent Bridge
485 .... .... .... .... .... .... .... .0.. = Not a Source Route Bridge
486 .... .... .... .... .... .... .... 0... = Not a Switch
487 .... .... .... .... .... .... ...0 .... = Not a Host
488 .... .... .... .... .... .... ..0. .... = Not IGMP capable
489 .... .... .... .... .... .... .0.. .... = Not a Repeater
491 Type: Duplex (0x000b)
495 struct lldpd_chassis
*nchassis
= NULL
;
496 struct lldpd_port
*nport
= NULL
;
498 fail_unless(cdpv2_guess(pkt1
, sizeof(pkt1
)));
499 fail_unless(cdp_decode(NULL
, pkt1
, sizeof(pkt1
), &hardware
,
500 &nchassis
, &nport
) != -1);
501 if (!nchassis
|| !nport
) {
502 fail("unable to decode packet");
505 ck_assert_int_eq(nchassis
->c_id_subtype
,
506 LLDP_CHASSISID_SUBTYPE_LOCAL
);
507 ck_assert_int_eq(nchassis
->c_id_len
, strlen("rtbg6test01"));
508 fail_unless(memcmp(nchassis
->c_id
,
509 "rtbg6test01", strlen("rtbg6test01")) == 0);
510 ck_assert_str_eq(nchassis
->c_name
, "rtbg6test01");
511 ck_assert_int_eq(TAILQ_FIRST(&nchassis
->c_mgmt
)->m_addr
.inet
.s_addr
,
512 (u_int32_t
)inet_addr("172.66.55.3"));
513 ck_assert_int_eq(TAILQ_FIRST(&nchassis
->c_mgmt
)->m_iface
, 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("FastEthernet0/0"));
517 fail_unless(memcmp(nport
->p_id
,
518 "FastEthernet0/0", strlen("FastEthernet0/0")) == 0);
519 ck_assert_str_eq(nport
->p_descr
, "FastEthernet0/0");
520 ck_assert_int_eq(nchassis
->c_cap_enabled
, LLDP_CAP_STATION
);
521 ck_assert_str_eq(nchassis
->c_descr
,
522 "cisco 7206VXR running on\n"
523 "Cisco Internetwork Operating System Software \n"
524 "IOS (tm) 7200 Software (C7200-P-M), Version 12.2(46), RELEASE SOFTWARE (fc1)\n"
525 "Copyright (c) 1986-2007 by cisco Systems, Inc.\n"
526 "Compiled Thu 26-Apr-07 21:56 by pwade");
535 Suite
*s
= suite_create("CDP");
538 TCase
*tc_send
= tcase_create("Send CDP packets");
539 tcase_add_checked_fixture(tc_send
, pcap_setup
, pcap_teardown
);
540 tcase_add_test(tc_send
, test_send_cdpv1
);
541 tcase_add_test(tc_send
, test_send_cdpv2
);
542 suite_add_tcase(s
, tc_send
);
544 TCase
*tc_receive
= tcase_create("Receive CDP packets");
545 tcase_add_test(tc_receive
, test_recv_cdpv1
);
546 tcase_add_test(tc_receive
, test_recv_cdpv2
);
547 suite_add_tcase(s
, tc_receive
);
557 Suite
*s
= cdp_suite ();
558 SRunner
*sr
= srunner_create (s
);
559 srunner_set_fork_status (sr
, CK_NOFORK
); /* Can't fork because
562 srunner_run_all (sr
, CK_ENV
);
563 number_failed
= srunner_ntests_failed (sr
);
565 return (number_failed
== 0) ? EXIT_SUCCESS
: EXIT_FAILURE
;