]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
freebsd: make it compile and work on real FreeBSD systems
authorVincent Bernat <bernat@luffy.cx>
Thu, 27 Dec 2012 21:04:28 +0000 (22:04 +0100)
committerVincent Bernat <bernat@luffy.cx>
Thu, 27 Dec 2012 21:04:28 +0000 (22:04 +0100)
lldpd now also runs on FreeBSD. Tested on FreeBSD 8.3.

21 files changed:
m4/os.m4
src/client/display.c
src/client/lldpctl.c
src/ctl.c
src/daemon/cdp.c
src/daemon/edp.c
src/daemon/interfaces-freebsd.c
src/daemon/interfaces-linux.c
src/daemon/interfaces.c
src/daemon/lldp.c
src/daemon/lldpd.c
src/daemon/lldpd.h
src/daemon/priv.c
src/daemon/sonmp.c
src/daemon/sonmp.h
src/lib/connection.c
tests/check_cdp.c
tests/check_edp.c
tests/check_lldp.c
tests/check_sonmp.c
tests/common.c

index e7d2fd254b291e4c3b0005a144196719470b2f8c..dfb69650df283f0c5192315dfb97ec35d373a2f7 100644 (file)
--- 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)
index b60ebf0a3f32667a219a1d5b846e804b0864fc70..6ba108192bc3dc49bdb24545e7766021fe176957 100644 (file)
@@ -25,6 +25,7 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <arpa/inet.h>
+#include <string.h>
 
 #include "../log.h"
 #include "client.h"
index a00b0a58768ea29d284176629f8d0f79b7fe0a9f..db7c0a391aaf4a9bc6c7b7a3298df04b43b02b4a 100644 (file)
@@ -20,6 +20,7 @@
 #include <unistd.h>
 #include <time.h>
 #include <errno.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
index 12b35af81171bdc1649a9ad67ab75faad7bd0e04..8562720b35266b4818bf18b46907380c06c6a87c 100644 (file)
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -22,6 +22,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <string.h>
 
 #include "ctl.h"
 #include "marshal.h"
index 29f0a5876beaec9209fcdc75f1bf28bcc87f65ff..0df5e6dbe4a93c651ec6e208519adbbfe2d91d16 100644 (file)
@@ -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);
 }
index e28eef28a4033a4d19fcf5823c3928a9fd4dc1f8..69b5cb4c7238bf64e8c409cf5da6d1107129ed0f 100644 (file)
@@ -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) {
index 46214e8c7fd7ba19e2f185f19da7011408c778fe..0d4cb117f4f4c2fde8ef6835b381d5f448c32b29 100644 (file)
@@ -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);
index d143501d752ab5bea5d70598a06b9e6306277eec..8d3b710d8af6feed4ca023b401b0a4dd3419f85b 100644 (file)
@@ -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);
index 5142ca5fe56af684ef3e86d79acbd5e3adcde34e..c2c75cb6946321ddf3131670b29a4cadec31485b 100644 (file)
@@ -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);
index 0c992d391cca0a1cb2828a524be99231975b125a..39ce8bd20dc605b0c276b55be3cee94f32a64786 100644 (file)
@@ -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);
index b9c97502fee73ab7a4e7862085fbf6d4a2108ca8..b52ecedab38565c126dc7714f1e25ccd9b70795d 100644 (file)
@@ -34,6 +34,7 @@
 #include <sys/time.h>
 #include <sys/ioctl.h>
 #include <arpa/inet.h>
+#include <net/ethernet.h>
 #include <pwd.h>
 #include <grp.h>
 #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;
        }
 
index 690065537b7ed5572549aab303503ee0d3445024..baf8d28b3c383b4f62c917b6562c1ce598f09a12 100644 (file)
@@ -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)
index e9ab45d08bcee32abfafa4148dd7e8efe17351e1..65a60637d4909321faea973fb0d0d8365cf5f232 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <stdio.h>
 #include <unistd.h>
+#include <signal.h>
 #include <errno.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
@@ -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
index 9eb5e0609faf9c2d69eeb4f1f3e2c0e5adf23cc6..c756ced1bb04e026dfcdf8d9e6ad8219afb13003 100644 (file)
@@ -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",
index d2b1541fe644e08cb845cc4762f08d8c027ad517..0e60106dae63ed96c3c749da763389ed99e3f56e 100644 (file)
@@ -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;
index 405cce18b1f7243ff5af503644153285887c39ff..729ee092b339fa6dcf48728b1fa05b17369e6422 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <unistd.h>
 #include <errno.h>
+#include <string.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 
index a5b2509250d6c6bcdfb5d30ae9f3d9ee0a165de9..cf6ce13fb18a93a4c89393c50da1be6370cc361b 100644 (file)
@@ -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 =
index e30c27326a47393b43379d097d0bd7e86f5619fe..e3e54ef109f7a22e5a32e466a732a7d0a422dbbb 100644 (file)
@@ -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"));
index 5cebdaa5e739a476fa65bacd6d8341186c12e7af..02a20dc9070328848598fe7a34e69f076ea2c26b 100644 (file)
@@ -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,
index d82ae05e9bf6182679cb8b5d45b6f440c520ae43..596618d375833e7d57c0b49512ad36bb81a67793 100644 (file)
@@ -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, 
index f7e3d5454eabdbedf2bd4ae055d8b938ed66eac1..380ecdfb742768ea54d41db0121d376dd4a596ca 100644 (file)
@@ -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));