From 4e5f34c5231abb2be8884df6db06483b38b0eb70 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 27 Dec 2012 22:04:28 +0100 Subject: [PATCH] freebsd: make it compile and work on real FreeBSD systems lldpd now also runs on FreeBSD. Tested on FreeBSD 8.3. --- m4/os.m4 | 3 +-- src/client/display.c | 1 + src/client/lldpctl.c | 1 + src/ctl.c | 1 + src/daemon/cdp.c | 10 +++++----- src/daemon/edp.c | 16 ++++++++-------- src/daemon/interfaces-freebsd.c | 4 ++-- src/daemon/interfaces-linux.c | 12 ++++++------ src/daemon/interfaces.c | 2 +- src/daemon/lldp.c | 6 +++--- src/daemon/lldpd.c | 13 +++++++------ src/daemon/lldpd.h | 2 +- src/daemon/priv.c | 9 +++++---- src/daemon/sonmp.c | 4 ++-- src/daemon/sonmp.h | 2 +- src/lib/connection.c | 1 + tests/check_cdp.c | 6 +++--- tests/check_edp.c | 8 ++++---- tests/check_lldp.c | 24 ++++++++++++------------ tests/check_sonmp.c | 2 +- tests/common.c | 4 ++-- 21 files changed, 68 insertions(+), 63 deletions(-) diff --git a/m4/os.m4 b/m4/os.m4 index e7d2fd25..dfb69650 100644 --- a/m4/os.m4 +++ b/m4/os.m4 @@ -18,8 +18,7 @@ AC_DEFUN([lldp_CHECK_OS], [ AC_MSG_CHECKING([if host OS is supported]) lldp_DEFINE_OS(linux*, Linux, LINUX) - lldp_DEFINE_OS(freebsd*, FreeBSD, FREEBSD) - lldp_DEFINE_OS(kfreebsd*, kFreeBSD, FREEBSD) + lldp_DEFINE_OS(freebsd*|kfreebsd*, FreeBSD, FREEBSD) if test x$os = x; then AC_MSG_RESULT(no) diff --git a/src/client/display.c b/src/client/display.c index b60ebf0a..6ba10819 100644 --- a/src/client/display.c +++ b/src/client/display.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "../log.h" #include "client.h" diff --git a/src/client/lldpctl.c b/src/client/lldpctl.c index a00b0a58..db7c0a39 100644 --- a/src/client/lldpctl.c +++ b/src/client/lldpctl.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/src/ctl.c b/src/ctl.c index 12b35af8..8562720b 100644 --- a/src/ctl.c +++ b/src/ctl.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "ctl.h" #include "marshal.h" diff --git a/src/daemon/cdp.c b/src/daemon/cdp.c index 29f0a587..0df5e6db 100644 --- a/src/daemon/cdp.c +++ b/src/daemon/cdp.c @@ -275,7 +275,7 @@ cdp_decode(struct lldpd *cfg, char *frame, int s, length = s; pos = (u_int8_t*)frame; - if (length < 2*ETH_ALEN + sizeof(u_int16_t) /* Ethernet */ + + if (length < 2*ETHER_ADDR_LEN + sizeof(u_int16_t) /* Ethernet */ + 8 /* LLC */ + 4 /* CDP header */) { log_warn("cdp", "too short CDP/FDP frame received on %s", hardware->h_ifname); goto malformed; @@ -295,7 +295,7 @@ cdp_decode(struct lldpd *cfg, char *frame, int s, } #endif } - PEEK_DISCARD(ETH_ALEN); /* Don't care of source address */ + PEEK_DISCARD(ETHER_ADDR_LEN); /* Don't care of source address */ len_eth = PEEK_UINT16; if (len_eth > length) { log_warnx("cdp", "incorrect 802.3 frame size reported on %s", @@ -584,12 +584,12 @@ static int cdp_guess(char *pos, int length, int version) { const u_int8_t mcastaddr[] = CDP_MULTICAST_ADDR; - if (length < 2*ETH_ALEN + sizeof(u_int16_t) /* Ethernet */ + + if (length < 2*ETHER_ADDR_LEN + sizeof(u_int16_t) /* Ethernet */ + 8 /* LLC */ + 4 /* CDP header */) return 0; - if (PEEK_CMP(mcastaddr, ETH_ALEN) != 0) + if (PEEK_CMP(mcastaddr, ETHER_ADDR_LEN) != 0) return 0; - PEEK_DISCARD(ETH_ALEN); PEEK_DISCARD_UINT16; /* Ethernet */ + PEEK_DISCARD(ETHER_ADDR_LEN); PEEK_DISCARD_UINT16; /* Ethernet */ PEEK_DISCARD(8); /* LLC */ return (PEEK_UINT8 == version); } diff --git a/src/daemon/edp.c b/src/daemon/edp.c index e28eef28..69b5cb4c 100644 --- a/src/daemon/edp.c +++ b/src/daemon/edp.c @@ -85,7 +85,7 @@ edp_send(struct lldpd *global, goto toobig; /* EDP header */ - if ((chassis->c_id_len != ETH_ALEN) || + if ((chassis->c_id_len != ETHER_ADDR_LEN) || (chassis->c_id_subtype != LLDP_CHASSISID_SUBTYPE_LLADDR)) { log_warnx("edp", "local chassis does not use MAC address as chassis ID!?"); free(packet); @@ -100,7 +100,7 @@ edp_send(struct lldpd *global, POKE_UINT32(0) && /* Len + Checksum */ POKE_UINT16(seq) && POKE_UINT16(0) && - POKE_BYTES(chassis->c_id, ETH_ALEN))) + POKE_BYTES(chassis->c_id, ETHER_ADDR_LEN))) goto toobig; seq++; @@ -267,8 +267,8 @@ edp_decode(struct lldpd *cfg, char *frame, int s, length = s; pos = (u_int8_t*)frame; - if (length < 2*ETH_ALEN + sizeof(u_int16_t) + 8 /* LLC */ + - 10 + ETH_ALEN /* EDP header */) { + if (length < 2*ETHER_ADDR_LEN + sizeof(u_int16_t) + 8 /* LLC */ + + 10 + ETHER_ADDR_LEN /* EDP header */) { log_warnx("edp", "too short EDP frame received on %s", hardware->h_ifname); goto malformed; } @@ -278,7 +278,7 @@ edp_decode(struct lldpd *cfg, char *frame, int s, hardware->h_ifname); goto malformed; } - PEEK_DISCARD(ETH_ALEN); PEEK_DISCARD_UINT16; + PEEK_DISCARD(ETHER_ADDR_LEN); PEEK_DISCARD_UINT16; PEEK_DISCARD(6); /* LLC: DSAP + SSAP + control + org */ if (PEEK_UINT16 != LLC_PID_EDP) { log_debug("edp", "incorrect LLC protocol ID received on %s", @@ -308,12 +308,12 @@ edp_decode(struct lldpd *cfg, char *frame, int s, } chassis->c_ttl = LLDPD_TTL; chassis->c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR; - chassis->c_id_len = ETH_ALEN; - if ((chassis->c_id = (char *)malloc(ETH_ALEN)) == NULL) { + chassis->c_id_len = ETHER_ADDR_LEN; + if ((chassis->c_id = (char *)malloc(ETHER_ADDR_LEN)) == NULL) { log_warn("edp", "unable to allocate memory for chassis ID"); goto malformed; } - PEEK_BYTES(chassis->c_id, ETH_ALEN); + PEEK_BYTES(chassis->c_id, ETHER_ADDR_LEN); /* Let's check checksum */ if (frame_checksum(pos_edp, edp_len, 0) != 0) { diff --git a/src/daemon/interfaces-freebsd.c b/src/daemon/interfaces-freebsd.c index 46214e8c..0d4cb117 100644 --- a/src/daemon/interfaces-freebsd.c +++ b/src/daemon/interfaces-freebsd.c @@ -239,9 +239,9 @@ ifbsd_extract_device(struct lldpd *cfg, iface->flags = ifaddr->ifa_flags; /* MAC address */ - iface->address = malloc(ETH_ALEN); + iface->address = malloc(ETHER_ADDR_LEN); if (iface->address) - memcpy(iface->address, LLADDR(saddrdl), ETH_ALEN); + memcpy(iface->address, LLADDR(saddrdl), ETHER_ADDR_LEN); /* Grab description */ iface->alias = malloc(IFDESCRSIZE); diff --git a/src/daemon/interfaces-linux.c b/src/daemon/interfaces-linux.c index d143501d..8d3b710d 100644 --- a/src/daemon/interfaces-linux.c +++ b/src/daemon/interfaces-linux.c @@ -297,7 +297,7 @@ iflinux_get_permanent_mac(struct lldpd *cfg, FILE *netbond; const char const *slaveif = "Slave Interface: "; const char const *hwaddr = "Permanent HW addr: "; - u_int8_t mac[ETH_ALEN]; + u_int8_t mac[ETHER_ADDR_LEN]; char path[SYSFS_PATH_MAX]; char line[100]; @@ -358,14 +358,14 @@ iflinux_get_permanent_mac(struct lldpd *cfg, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]) != - ETH_ALEN) { + ETHER_ADDR_LEN) { log_warn("interfaces", "unable to parse %s", line + strlen(hwaddr)); fclose(netbond); return; } memcpy(iface->address, mac, - ETH_ALEN); + ETHER_ADDR_LEN); fclose(netbond); return; } @@ -512,13 +512,13 @@ iface_bond_send(struct lldpd *cfg, struct lldpd_hardware *hardware, * source MAC address to 0. */ log_debug("interfaces", "send PDU to bonded device %s", hardware->h_ifname); - if (size < 2 * ETH_ALEN) { + if (size < 2 * ETHER_ADDR_LEN) { log_warnx("interfaces", "packet to send on %s is too small!", hardware->h_ifname); return 0; } - memset(buffer + ETH_ALEN, 0, ETH_ALEN); + memset(buffer + ETHER_ADDR_LEN, 0, ETHER_ADDR_LEN); return write(hardware->h_sendfd, buffer, size); } @@ -630,7 +630,7 @@ iflinux_handle_bond(struct lldpd *cfg, struct interfaces_device_list *interfaces iface->flags = 0; /* Get local address */ - memcpy(&hardware->h_lladdr, iface->address, ETH_ALEN); + memcpy(&hardware->h_lladdr, iface->address, ETHER_ADDR_LEN); /* Fill information about port */ interfaces_helper_port_name_desc(hardware, iface); diff --git a/src/daemon/interfaces.c b/src/daemon/interfaces.c index 5142ca5f..c2c75cb6 100644 --- a/src/daemon/interfaces.c +++ b/src/daemon/interfaces.c @@ -539,7 +539,7 @@ interfaces_helper_physical(struct lldpd *cfg, interface. */ /* Get local address */ - memcpy(&hardware->h_lladdr, iface->address, ETH_ALEN); + memcpy(&hardware->h_lladdr, iface->address, ETHER_ADDR_LEN); /* Fill information about port */ interfaces_helper_port_name_desc(hardware, iface); diff --git a/src/daemon/lldp.c b/src/daemon/lldp.c index 0c992d39..39ce8bd2 100644 --- a/src/daemon/lldp.c +++ b/src/daemon/lldp.c @@ -516,16 +516,16 @@ lldp_decode(struct lldpd *cfg, char *frame, int s, length = s; pos = (u_int8_t*)frame; - if (length < 2*ETH_ALEN + sizeof(u_int16_t)) { + if (length < 2*ETHER_ADDR_LEN + sizeof(u_int16_t)) { log_warnx("lldp", "too short frame received on %s", hardware->h_ifname); goto malformed; } - if (PEEK_CMP(lldpaddr, ETH_ALEN) != 0) { + if (PEEK_CMP(lldpaddr, ETHER_ADDR_LEN) != 0) { log_info("lldp", "frame not targeted at LLDP multicast address received on %s", hardware->h_ifname); goto malformed; } - PEEK_DISCARD(ETH_ALEN); /* Skip source address */ + PEEK_DISCARD(ETHER_ADDR_LEN); /* Skip source address */ if (PEEK_UINT16 != ETHERTYPE_LLDP) { log_info("lldp", "non LLDP frame received on %s", hardware->h_ifname); diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c index b9c97502..b52eceda 100644 --- a/src/daemon/lldpd.c +++ b/src/daemon/lldpd.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #ifdef HOST_OS_FREEBSD @@ -300,13 +301,13 @@ static int lldpd_guess_type(struct lldpd *cfg, char *frame, int s) { int i; - if (s < ETH_ALEN) + if (s < ETHER_ADDR_LEN) return -1; for (i=0; cfg->g_protocols[i].mode != 0; i++) { if (!cfg->g_protocols[i].enabled) continue; if (cfg->g_protocols[i].guess == NULL) { - if (memcmp(frame, cfg->g_protocols[i].mac, ETH_ALEN) == 0) { + if (memcmp(frame, cfg->g_protocols[i].mac, ETHER_ADDR_LEN) == 0) { log_debug("decode", "guessed protocol is %s (from MAC address)", cfg->g_protocols[i].name); return cfg->g_protocols[i].mode; @@ -334,14 +335,14 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s, log_debug("decode", "decode a received frame on %s", hardware->h_ifname); - if (s < sizeof(struct ethhdr) + 4) + if (s < sizeof(struct ether_header) + 4) /* Too short, just discard it */ return; /* Decapsulate VLAN frames */ - if (((struct ethhdr*)frame)->h_proto == htons(ETHERTYPE_VLAN)) { + if (((struct ether_header*)frame)->ether_type == htons(ETHERTYPE_VLAN)) { /* VLAN decapsulation means to shift 4 bytes left the frame from - * offset 2*ETH_ALEN */ - memmove(frame + 2*ETH_ALEN, frame + 2*ETH_ALEN + 4, s - 2*ETH_ALEN); + * offset 2*ETHER_ADDR_LEN */ + memmove(frame + 2*ETHER_ADDR_LEN, frame + 2*ETHER_ADDR_LEN + 4, s - 2*ETHER_ADDR_LEN); s -= 4; } diff --git a/src/daemon/lldpd.h b/src/daemon/lldpd.h index 69006553..baf8d28b 100644 --- a/src/daemon/lldpd.h +++ b/src/daemon/lldpd.h @@ -81,7 +81,7 @@ struct protocol { int(*send)(PROTO_SEND_SIG); /* How to send a frame */ int(*decode)(PROTO_DECODE_SIG); /* How to decode a frame */ int(*guess)(PROTO_GUESS_SIG); /* Can be NULL, use MAC address in this case */ - u_int8_t mac[ETH_ALEN]; /* Destination MAC address used by this protocol */ + u_int8_t mac[ETHER_ADDR_LEN]; /* Destination MAC address used by this protocol */ }; #define SMART_HIDDEN(port) (port->p_hidden_in) diff --git a/src/daemon/priv.c b/src/daemon/priv.c index e9ab45d0..65a60637 100644 --- a/src/daemon/priv.c +++ b/src/daemon/priv.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -168,7 +169,7 @@ priv_iface_multicast(const char *name, u_int8_t *mac, int add) cmd = PRIV_IFACE_MULTICAST; must_write(remote, &cmd, sizeof(int)); must_write(remote, name, IFNAMSIZ); - must_write(remote, mac, ETH_ALEN); + must_write(remote, mac, ETHER_ADDR_LEN); must_write(remote, &add, sizeof(int)); must_read(remote, &rc, sizeof(int)); return rc; @@ -379,7 +380,7 @@ asroot_iface_multicast() struct ifreq ifr = {}; must_read(remote, ifr.ifr_name, IFNAMSIZ); #if defined HOST_OS_LINUX - must_read(remote, ifr.ifr_hwaddr.sa_data, ETH_ALEN); + must_read(remote, ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN); #elif defined HOST_OS_FREEBSD /* Black magic from mtest.c */ struct sockaddr_dl *dlp = (struct sockaddr_dl *)&ifr.ifr_addr; @@ -387,9 +388,9 @@ asroot_iface_multicast() dlp->sdl_family = AF_LINK; dlp->sdl_index = 0; dlp->sdl_nlen = 0; - dlp->sdl_alen = ETH_ALEN; + dlp->sdl_alen = ETHER_ADDR_LEN; dlp->sdl_slen = 0; - must_read(remote, LLADDR(&dlp), ETH_ALEN); + must_read(remote, LLADDR(dlp), ETHER_ADDR_LEN); #else #error Unsupported OS #endif diff --git a/src/daemon/sonmp.c b/src/daemon/sonmp.c index 9eb5e060..c756ced1 100644 --- a/src/daemon/sonmp.c +++ b/src/daemon/sonmp.c @@ -261,7 +261,7 @@ sonmp_send(struct lldpd *global, POKE_RESTORE(pos_pid); /* Modify LLC PID */ (void)POKE_UINT16(LLC_PID_SONMP_FLATNET); POKE_RESTORE(packet); /* Go to the beginning */ - PEEK_DISCARD(ETH_ALEN - 1); /* Modify the last byte of the MAC address */ + PEEK_DISCARD(ETHER_ADDR_LEN - 1); /* Modify the last byte of the MAC address */ (void)POKE_UINT8(1); if (hardware->h_ops->send(global, hardware, @@ -322,7 +322,7 @@ sonmp_decode(struct lldpd *cfg, char *frame, int s, * them. */ goto malformed; /* We skip to LLC PID */ - PEEK_DISCARD(ETH_ALEN); PEEK_DISCARD_UINT16; + PEEK_DISCARD(ETHER_ADDR_LEN); PEEK_DISCARD_UINT16; PEEK_DISCARD(6); if (PEEK_UINT16 != LLC_PID_SONMP_HELLO) { log_debug("sonmp", "incorrect LLC protocol ID received for SONMP on %s", diff --git a/src/daemon/sonmp.h b/src/daemon/sonmp.h index d2b1541f..0e60106d 100644 --- a/src/daemon/sonmp.h +++ b/src/daemon/sonmp.h @@ -24,7 +24,7 @@ #define LLC_ORG_NORTEL { 0x00, 0x00, 0x81 } #define LLC_PID_SONMP_HELLO 0x01a2 #define LLC_PID_SONMP_FLATNET 0x01a1 -#define SONMP_SIZE (2*ETH_ALEN + sizeof(u_int16_t) + 8) +#define SONMP_SIZE (2*ETHER_ADDR_LEN + sizeof(u_int16_t) + 8) struct sonmp_chassis { int type; diff --git a/src/lib/connection.c b/src/lib/connection.c index 405cce18..729ee092 100644 --- a/src/lib/connection.c +++ b/src/lib/connection.c @@ -17,6 +17,7 @@ #include #include +#include #include #include diff --git a/tests/check_cdp.c b/tests/check_cdp.c index a5b25092..cf6ce13f 100644 --- a/tests/check_cdp.c +++ b/tests/check_cdp.c @@ -99,7 +99,7 @@ Cisco Discovery Protocol hardware.h_lport.p_descr = "FastEthernet 1/5"; chassis.c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR; chassis.c_id = macaddress; - chassis.c_id_len = ETH_ALEN; + chassis.c_id_len = ETHER_ADDR_LEN; chassis.c_name = "First chassis"; chassis.c_descr = "Chassis description"; chassis.c_cap_available = chassis.c_cap_enabled = LLDP_CAP_ROUTER; @@ -224,11 +224,11 @@ Cisco Discovery Protocol /* Populate port and chassis */ hardware.h_lport.p_id_subtype = LLDP_PORTID_SUBTYPE_LLADDR; hardware.h_lport.p_id = macaddress; - hardware.h_lport.p_id_len = ETH_ALEN; + hardware.h_lport.p_id_len = ETHER_ADDR_LEN; hardware.h_lport.p_descr = "Gigabit Ethernet 5/8"; chassis.c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR; chassis.c_id = macaddress; - chassis.c_id_len = ETH_ALEN; + chassis.c_id_len = ETHER_ADDR_LEN; chassis.c_name = "Second chassis"; chassis.c_descr = "Chassis description"; chassis.c_cap_available = chassis.c_cap_enabled = diff --git a/tests/check_edp.c b/tests/check_edp.c index e30c2732..e3e54ef1 100644 --- a/tests/check_edp.c +++ b/tests/check_edp.c @@ -76,7 +76,7 @@ Extreme Discovery Protocol hardware.h_ifindex = 4; chassis.c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR; chassis.c_id = macaddress; - chassis.c_id_len = ETH_ALEN; + chassis.c_id_len = ETHER_ADDR_LEN; chassis.c_name = "First chassis"; /* Build packet */ n = edp_send(NULL, &hardware); @@ -240,7 +240,7 @@ Extreme Discovery Protocol hardware.h_ifindex = 4; chassis.c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR; chassis.c_id = macaddress; - chassis.c_id_len = ETH_ALEN; + chassis.c_id_len = ETHER_ADDR_LEN; chassis.c_name = "First chassis"; vlan1.v_name = "First VLAN"; vlan1.v_vid = 157; vlan2.v_name = "Second VLAN"; vlan2.v_vid = 1247; @@ -508,8 +508,8 @@ Extreme Discovery Protocol } ck_assert_int_eq(nchassis->c_id_subtype, LLDP_CHASSISID_SUBTYPE_LLADDR); - ck_assert_int_eq(nchassis->c_id_len, ETH_ALEN); - fail_unless(memcmp(nchassis->c_id, mac1, ETH_ALEN) == 0); + ck_assert_int_eq(nchassis->c_id_len, ETHER_ADDR_LEN); + fail_unless(memcmp(nchassis->c_id, mac1, ETHER_ADDR_LEN) == 0); ck_assert_int_eq(nport->p_id_subtype, LLDP_PORTID_SUBTYPE_IFNAME); ck_assert_int_eq(nport->p_id_len, strlen("1/1")); diff --git a/tests/check_lldp.c b/tests/check_lldp.c index 5cebdaa5..02a20dc9 100644 --- a/tests/check_lldp.c +++ b/tests/check_lldp.c @@ -132,7 +132,7 @@ START_TEST (test_send_rcv_basic) hardware.h_lport.p_mfs = 1516; chassis.c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR; chassis.c_id = macaddress; - chassis.c_id_len = ETH_ALEN; + chassis.c_id_len = ETHER_ADDR_LEN; chassis.c_name = "First chassis"; chassis.c_descr = "Chassis description"; chassis.c_cap_available = chassis.c_cap_enabled = LLDP_CAP_ROUTER; @@ -181,7 +181,7 @@ START_TEST (test_send_rcv_dot1_tlvs) /* Populate port and chassis */ hardware.h_lport.p_id_subtype = LLDP_PORTID_SUBTYPE_LLADDR; hardware.h_lport.p_id = macaddress; - hardware.h_lport.p_id_len = ETH_ALEN; + hardware.h_lport.p_id_len = ETHER_ADDR_LEN; hardware.h_lport.p_descr = "Fake port description"; hardware.h_lport.p_mfs = 1516; hardware.h_lport.p_pvid = 1500; @@ -307,7 +307,7 @@ START_TEST (test_send_rcv_med) /* Populate port and chassis */ hardware.h_lport.p_id_subtype = LLDP_PORTID_SUBTYPE_LLADDR; hardware.h_lport.p_id = macaddress; - hardware.h_lport.p_id_len = ETH_ALEN; + hardware.h_lport.p_id_len = ETHER_ADDR_LEN; hardware.h_lport.p_descr = "Fake port description"; hardware.h_lport.p_mfs = 1516; chassis.c_id_subtype = LLDP_CHASSISID_SUBTYPE_LOCAL; @@ -401,7 +401,7 @@ START_TEST (test_send_rcv_dot3) hardware.h_lport.p_macphy.mau_type = LLDP_DOT3_MAU_100BASETXFD; chassis.c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR; chassis.c_id = macaddress; - chassis.c_id_len = ETH_ALEN; + chassis.c_id_len = ETHER_ADDR_LEN; chassis.c_name = "Fourth chassis"; chassis.c_descr = "Long chassis description"; chassis.c_cap_available = chassis.c_cap_enabled = LLDP_CAP_ROUTER | LLDP_CAP_WLAN; @@ -484,12 +484,12 @@ Link Layer Discovery Protocol } ck_assert_int_eq(nchassis->c_id_subtype, LLDP_CHASSISID_SUBTYPE_LLADDR); - ck_assert_int_eq(nchassis->c_id_len, ETH_ALEN); - fail_unless(memcmp(mac1, nchassis->c_id, ETH_ALEN) == 0); + ck_assert_int_eq(nchassis->c_id_len, ETHER_ADDR_LEN); + fail_unless(memcmp(mac1, nchassis->c_id, ETHER_ADDR_LEN) == 0); ck_assert_int_eq(nport->p_id_subtype, LLDP_PORTID_SUBTYPE_LLADDR); - ck_assert_int_eq(nport->p_id_len, ETH_ALEN); - fail_unless(memcmp(mac2, nport->p_id, ETH_ALEN) == 0); + ck_assert_int_eq(nport->p_id_len, ETHER_ADDR_LEN); + fail_unless(memcmp(mac2, nport->p_id, ETHER_ADDR_LEN) == 0); ck_assert_int_eq(nchassis->c_ttl, 120); ck_assert_str_eq(nchassis->c_name, "Not received"); ck_assert_str_eq(nchassis->c_descr, "Not received"); @@ -689,12 +689,12 @@ Link Layer Discovery Protocol } ck_assert_int_eq(nchassis->c_id_subtype, LLDP_CHASSISID_SUBTYPE_LLADDR); - ck_assert_int_eq(nchassis->c_id_len, ETH_ALEN); - fail_unless(memcmp(mac1, nchassis->c_id, ETH_ALEN) == 0); + ck_assert_int_eq(nchassis->c_id_len, ETHER_ADDR_LEN); + fail_unless(memcmp(mac1, nchassis->c_id, ETHER_ADDR_LEN) == 0); ck_assert_int_eq(nport->p_id_subtype, LLDP_PORTID_SUBTYPE_LLADDR); - ck_assert_int_eq(nport->p_id_len, ETH_ALEN); - fail_unless(memcmp(mac1, nport->p_id, ETH_ALEN) == 0); + ck_assert_int_eq(nport->p_id_len, ETHER_ADDR_LEN); + fail_unless(memcmp(mac1, nport->p_id, ETHER_ADDR_LEN) == 0); ck_assert_int_eq(nchassis->c_ttl, 120); ck_assert_str_eq(nchassis->c_name, "naruto.XXXXXXXXXXXXXXXXXXX"); ck_assert_str_eq(nchassis->c_descr, diff --git a/tests/check_sonmp.c b/tests/check_sonmp.c index d82ae05e..596618d3 100644 --- a/tests/check_sonmp.c +++ b/tests/check_sonmp.c @@ -80,7 +80,7 @@ Nortel Networks / SynOptics Network Management Protocol hardware.h_lport.p_id_len = strlen(hardware.h_lport.p_id); chassis.c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR; chassis.c_id = macaddress; - chassis.c_id_len = ETH_ALEN; + chassis.c_id_len = ETHER_ADDR_LEN; TAILQ_INIT(&chassis.c_mgmt); addr = inet_addr("172.17.142.37"); mgmt = lldpd_alloc_mgmt(LLDPD_AF_IPV4, diff --git a/tests/common.c b/tests/common.c index f7e3d545..380ecdfb 100644 --- a/tests/common.c +++ b/tests/common.c @@ -12,7 +12,7 @@ int dump = -1; char *filename = NULL; struct pkts_t pkts; -char macaddress[ETH_ALEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad }; +char macaddress[ETHER_ADDR_LEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad }; struct lldpd_hardware hardware; struct lldpd_chassis chassis; @@ -103,7 +103,7 @@ pcap_setup() hardware.h_mtu = 1500; hardware.h_ifindex = 4; strcpy(hardware.h_ifname, "test"); - memcpy(hardware.h_lladdr, macaddress, ETH_ALEN); + memcpy(hardware.h_lladdr, macaddress, ETHER_ADDR_LEN); hardware.h_ops = &pcap_ops; /* Prepare chassis */ memset(&chassis, 0, sizeof(struct lldpd_chassis)); -- 2.39.5