/* Prepare hardware */
memset(&hardware, 0, sizeof(struct lldpd_hardware));
TAILQ_INIT(&hardware.h_rports);
+#ifdef ENABLE_DOT1
TAILQ_INIT(&hardware.h_lport.p_vlans);
+#endif
hardware.h_mtu = 1500;
hardware.h_ifindex = 1;
strcpy(hardware.h_ifname, "test");
0x6f, 0x6e, 0x0e, 0x04, 0x00, 0x10, 0x00, 0x10,
0x08, 0x15, 0x46, 0x61, 0x6b, 0x65, 0x20, 0x70,
0x6f, 0x72, 0x74, 0x20, 0x64, 0x65, 0x73, 0x63,
- 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0xfe,
- 0x09, 0x00, 0x12, 0x0f, 0x03, 0x01, 0x00, 0x00,
+ 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
+#ifdef ENABLE_DOT3
+ 0xfe, 0x09,
+ 0x00, 0x12, 0x0f, 0x03, 0x01, 0x00, 0x00,
0x00, 0x00, 0xfe, 0x09, 0x00, 0x12, 0x0f, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x00,
- 0x12, 0x0f, 0x04, 0x05, 0xec, 0x00, 0x00 };
+ 0x12, 0x0f, 0x04, 0x05, 0xec,
+#endif
+ 0x00, 0x00 };
struct packet *pkt;
/* Populate port and chassis */
}
END_TEST
+#ifdef ENABLE_DOT1
START_TEST (test_send_vlan)
{
int n;
0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x56,
0x4c, 0x41, 0x4e, 0xfe, 0x11, 0x00, 0x80, 0xc2,
0x03, 0x02, 0xe5, 0x0a, 0x54, 0x68, 0x69, 0x72,
- 0x64, 0x20, 0x56, 0x4c, 0x41, 0x4e, 0xfe, 0x09,
+ 0x64, 0x20, 0x56, 0x4c, 0x41, 0x4e,
+#ifdef ENABLE_DOT3
+ 0xfe, 0x09,
0x00, 0x12, 0x0f, 0x03, 0x01, 0x00, 0x00, 0x00,
0x00, 0xfe, 0x09, 0x00, 0x12, 0x0f, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x00, 0x12,
- 0x0f, 0x04, 0x05, 0xec, 0x00, 0x00 };
+ 0x0f, 0x04, 0x05, 0xec,
+#endif
+ 0x00, 0x00 };
struct packet *pkt;
/* Populate port and chassis */
fail_unless(TAILQ_NEXT(pkt, next) == NULL, "more than one packet sent");
}
END_TEST
+#endif
+#ifdef ENABLE_LLDPMED
START_TEST (test_send_med)
{
int n;
0x00, 0x14, 0x00, 0x10, 0x08, 0x15, 0x46, 0x61,
0x6b, 0x65, 0x20, 0x70, 0x6f, 0x72, 0x74, 0x20,
0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
- 0x69, 0x6f, 0x6e, 0xfe, 0x09, 0x00, 0x12, 0x0f,
+ 0x69, 0x6f, 0x6e,
+#ifdef ENABLE_DOT3
+ 0xfe, 0x09, 0x00, 0x12, 0x0f,
0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x09,
0x00, 0x12, 0x0f, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0xfe, 0x06, 0x00, 0x12, 0x0f, 0x04, 0x05,
- 0xec, 0xfe, 0x07, 0x00, 0x12, 0xbb, 0x01, 0x00,
+ 0xec,
+#endif
+ 0xfe, 0x07, 0x00, 0x12, 0xbb, 0x01, 0x00,
0x2f, 0x03, 0xfe, 0x12, 0x00, 0x12, 0xbb, 0x05,
0x68, 0x61, 0x72, 0x64, 0x77, 0x61, 0x72, 0x65,
0x20, 0x72, 0x65, 0x76, 0x20, 0x35, 0xfe, 0x08,
fail_unless(TAILQ_NEXT(pkt, next) == NULL, "more than one packet sent");
}
END_TEST
+#endif
+#ifdef ENABLE_DOT3
START_TEST (test_send_dot3)
{
int n;
fail_unless(TAILQ_NEXT(pkt, next) == NULL, "more than one packet sent");
}
END_TEST
+#endif
START_TEST (test_recv_min)
{
ck_assert_int_eq(nchassis->c_mgmt.s_addr,
(u_int32_t)inet_addr("10.238.80.75"));
ck_assert_int_eq(nchassis->c_mgmt_if, 3);
+#ifdef ENABLE_DOT3
ck_assert_int_eq(nport->p_aggregid, 0);
ck_assert_int_eq(nport->p_autoneg_enabled, 1);
ck_assert_int_eq(nport->p_autoneg_support, 1);
ck_assert_int_eq(nport->p_mau_type,
LLDP_DOT3_MAU_100BASETXFD);
ck_assert_int_eq(nport->p_mfs, 1500);
+#endif
+#ifdef ENABLE_LLDPMED
ck_assert_int_eq(nchassis->c_med_type, 0);
ck_assert_str_eq(nchassis->c_med_hw, "ND991789702");
ck_assert_str_eq(nchassis->c_med_fw, "080012 "); /* Extra space */
ck_assert_str_eq(nchassis->c_med_manuf, "NEC Computers SAS");
ck_assert_str_eq(nchassis->c_med_model, "POWERMATE VL350");
ck_assert_str_eq(nchassis->c_med_asset, "100207120");
+#endif
}
END_TEST
+#ifdef ENABLE_DOT1
START_TEST (test_recv_vlans)
{
char pkt1[] = {
fail_unless(vlan == NULL);
}
END_TEST
+#endif
+#ifdef ENABLE_LLDPMED
START_TEST (test_recv_med)
{
char pkt1[] = {
0x5f, 0x30, 0x38, 0x5f, 0x35, 0x29, 0x29, 0x0e,
0x04, 0x00, 0x14, 0x00, 0x04, 0x10, 0x0c, 0x05,
0x01, 0x0f, 0xff, 0x7a, 0x94, 0x02, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xfe, 0x09, 0x00, 0x12, 0x0f,
- 0x01, 0x03, 0x6c, 0x00, 0x00, 0x10, 0xfe, 0x07,
+ 0x00, 0x00, 0x00,
+#ifdef ENABLE_DOT3
+ 0xfe, 0x09, 0x00, 0x12, 0x0f,
+ 0x01, 0x03, 0x6c, 0x00, 0x00, 0x10,
+#endif
+ 0xfe, 0x07,
0x00, 0x12, 0xbb, 0x01, 0x00, 0x0f, 0x04, 0xfe,
0x08, 0x00, 0x12, 0xbb, 0x02, 0x01, 0x40, 0x65,
0xae, 0xfe, 0x2e, 0x00, 0x12, 0xbb, 0x03, 0x02,
ck_assert_int_eq(nchassis->c_mgmt.s_addr,
(u_int32_t)inet_addr("15.255.122.148"));
ck_assert_int_eq(nchassis->c_mgmt_if, 0);
+#ifdef ENABLE_DOT3
ck_assert_int_eq(nport->p_autoneg_enabled, 1);
ck_assert_int_eq(nport->p_autoneg_support, 1);
ck_assert_int_eq(nport->p_autoneg_advertised,
LLDP_DOT3_LINK_AUTONEG_10BASE_T);
ck_assert_int_eq(nport->p_mau_type,
LLDP_DOT3_MAU_100BASETXFD);
+#endif
ck_assert_int_eq(nchassis->c_med_cap_available,
LLDPMED_CAP_CAP | LLDPMED_CAP_POLICY |
LLDPMED_CAP_LOCATION | LLDPMED_CAP_MDI_PSE);
ck_assert_int_eq(nport->p_med_pow_devicetype, LLDPMED_POW_TYPE_PSE);
}
END_TEST
+#endif
Suite *
lldp_suite(void)
TCase *tc_send = tcase_create("Send LLDP packets");
tcase_add_checked_fixture(tc_send, setup, teardown);
tcase_add_test(tc_send, test_send_basic);
+#ifdef ENABLE_DOT1
tcase_add_test(tc_send, test_send_vlan);
+#endif
+#ifdef ENABLE_LLDPMED
tcase_add_test(tc_send, test_send_med);
+#endif
+#ifdef ENABLE_DOT3
tcase_add_test(tc_send, test_send_dot3);
+#endif
suite_add_tcase(s, tc_send);
TCase *tc_receive = tcase_create("Receive LLDP packets");
tcase_add_test(tc_receive, test_recv_min);
tcase_add_test(tc_receive, test_recv_lldpd);
+#ifdef ENABLE_DOT1
tcase_add_test(tc_receive, test_recv_vlans);
+#endif
+#ifdef ENABLE_LLDPMED
tcase_add_test(tc_receive, test_recv_med);
+#endif
suite_add_tcase(s, tc_receive);
return s;