]> git.ipfire.org Git - thirdparty/lldpd.git/blobdiff - tests/check_snmp.c
tests: display tests/test-suite.log on errors
[thirdparty/lldpd.git] / tests / check_snmp.c
index c986f29abdd3062535a899c3d0677175abf8ece9..3836ae5dc39324d9a27d3edcf0ad21d623a7e7fa 100644 (file)
@@ -1,7 +1,24 @@
+/* -*- mode: c; c-file-style: "openbsd" -*- */
+/*
+ * Copyright (c) 2015 Vincent Bernat <bernat@luffy.cx>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
 #include <check.h>
 
-#include "../src/lldpd.h"
-#include "../src/agent.h"
+#include "../src/daemon/lldpd.h"
+#include "../src/daemon/agent.h"
 
 #include <net-snmp/net-snmp-config.h>
 #include <net-snmp/net-snmp-includes.h>
 extern struct lldpd *agent_scfg;
 extern struct timeval starttime;
 extern struct variable8 agent_lldp_vars[];
-extern int asprintf (char **, char *, ...);
 
 /* Our test config */
 struct lldpd test_cfg = {
-       .g_delay = 30,
-       .g_smart = 0,
+       .g_config = {
+               .c_tx_interval = 30000,
+               .c_tx_hold = 2,
+               .c_ttl = 60,
+               .c_smart = 0
+       }
 };
 struct timeval test_starttime = { .tv_sec = 100, .tv_usec = 0 };
 
 /* First chassis */
 struct lldpd_mgmt mgmt1 = {
                .m_family = LLDPD_AF_IPV4,
-               .m_addr = { .inet = { 251789504 } }, /* 192.0.2.15 */
+               .m_addr = { .octets = { 0xc0, 0, 0x2, 0xf } }, /* 192.0.2.15 */
                .m_addrsize = sizeof(struct in_addr),
                .m_iface = 3
 };
@@ -37,12 +57,11 @@ struct lldpd_chassis chassis1 = {
        .c_descr         = "First chassis",
        .c_cap_available = LLDP_CAP_BRIDGE | LLDP_CAP_WLAN | LLDP_CAP_ROUTER,
        .c_cap_enabled   = LLDP_CAP_ROUTER,
-       .c_ttl           = 60,
 #ifdef ENABLE_LLDPMED
-       .c_med_cap_available = LLDPMED_CAP_CAP | LLDPMED_CAP_IV | \
-               LLDPMED_CAP_LOCATION |  LLDPMED_CAP_POLICY | \
-               LLDPMED_CAP_MDI_PSE | LLDPMED_CAP_MDI_PD,
-       .c_med_type   = LLDPMED_CLASS_II,
+       .c_med_cap_available = LLDP_MED_CAP_CAP | LLDP_MED_CAP_IV | \
+               LLDP_MED_CAP_LOCATION | LLDP_MED_CAP_POLICY | \
+               LLDP_MED_CAP_MDI_PSE | LLDP_MED_CAP_MDI_PD,
+       .c_med_type   = LLDP_MED_CLASS_II,
        .c_med_hw     = "Hardware 1",
        /* We skip c_med_fw */
        .c_med_sw     = "Software 1",
@@ -55,7 +74,7 @@ struct lldpd_chassis chassis1 = {
 /* Second chassis */
 struct lldpd_mgmt mgmt2 = {
                .m_family = LLDPD_AF_IPV4,
-               .m_addr = { .inet = { 285343936 } }, /* 192.0.2.17 */
+               .m_addr = { .octets = { 0xc0, 0, 0x2, 0x11 } }, /* 192.0.2.17 */
                .m_addrsize = sizeof(struct in_addr),
                .m_iface = 5
 };
@@ -78,7 +97,6 @@ struct lldpd_chassis chassis2 = {
        .c_descr         = "Second chassis",
        .c_cap_available = LLDP_CAP_ROUTER,
        .c_cap_enabled   = LLDP_CAP_ROUTER,
-       .c_ttl           = 60,
 #ifdef ENABLE_LLDPMED
        .c_med_hw     = "Hardware 2",
        /* We skip c_med_fw */
@@ -96,8 +114,11 @@ struct lldpd_hardware hardware1 = {
        .h_tx_cnt = 1352,
        .h_rx_cnt = 1458,
        .h_rx_discarded_cnt = 5,
-       .h_rx_ageout_cnt = 1455,
        .h_rx_unrecognized_cnt = 4,
+       .h_insert_cnt = 100,
+       .h_delete_cnt = 5,
+       .h_ageout_cnt = 20,
+       .h_drop_cnt = 1,
        .h_lport = {
                .p_chassis    = &chassis1,
                .p_lastchange = 200,
@@ -130,18 +151,18 @@ struct lldpd_hardware hardware1 = {
                },
 #endif
 #ifdef ENABLE_LLDPMED
-               .p_med_cap_enabled = LLDPMED_CAP_CAP | LLDPMED_CAP_IV | LLDPMED_CAP_MDI_PD |
-                       LLDPMED_CAP_POLICY | LLDPMED_CAP_LOCATION,
+               .p_med_cap_enabled = LLDP_MED_CAP_CAP | LLDP_MED_CAP_IV | LLDP_MED_CAP_MDI_PD |
+                       LLDP_MED_CAP_POLICY | LLDP_MED_CAP_LOCATION,
                .p_med_policy = {
                        { .type = 0 }, { .type = 0 }, {
-                               .type = LLDPMED_APPTYPE_GUESTVOICE,
+                               .type = LLDP_MED_APPTYPE_GUESTVOICE,
                                .unknown = 1,
                                .tagged = 1,
                                .vid = 475,
                                .priority = 3,
                                .dscp = 62
                        }, { .type = 0 }, { .type = 0 }, { .type = 0 }, {
-                               .type = LLDPMED_APPTYPE_VIDEOSTREAM,
+                               .type = LLDP_MED_APPTYPE_VIDEOSTREAM,
                                .unknown = 0,
                                .tagged = 1,
                                .vid = 472,
@@ -151,16 +172,16 @@ struct lldpd_hardware hardware1 = {
                },
                .p_med_location = {
                        { .format = 0 }, {
-                               .format = LLDPMED_LOCFORMAT_CIVIC,
+                               .format = LLDP_MED_LOCFORMAT_CIVIC,
                                /* 2:FR:6:Commercial Rd:19:4 */
-                               .data = "\x15\x02FR\x06\x0dCommercial Rd\x13\x014",
+                               .data = "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4",
                                .data_len = 22,
                        }, { .format = 0 }
                },
                .p_med_power = {
-                       .devicetype = LLDPMED_POW_TYPE_PD,
-                       .source = LLDPMED_POW_SOURCE_LOCAL,
-                       .priority = LLDPMED_POW_PRIO_HIGH,
+                       .devicetype = LLDP_MED_POW_TYPE_PD,
+                       .source = LLDP_MED_POW_SOURCE_LOCAL,
+                       .priority = LLDP_MED_POW_PRIO_HIGH,
                        .val = 100
                },
 #endif         
@@ -176,8 +197,11 @@ struct lldpd_hardware hardware2 = {
        .h_tx_cnt = 11352,
        .h_rx_cnt = 11458,
        .h_rx_discarded_cnt = 55,
-       .h_rx_ageout_cnt = 21455,
        .h_rx_unrecognized_cnt = 14,
+       .h_insert_cnt = 1000,
+       .h_delete_cnt = 51,
+       .h_ageout_cnt = 210,
+       .h_drop_cnt = 1,
        .h_lport = {
                .p_chassis    = &chassis1,
                .p_lastchange = 50,
@@ -197,18 +221,18 @@ struct lldpd_hardware hardware2 = {
                },
 #endif
 #ifdef ENABLE_LLDPMED
-               .p_med_cap_enabled = LLDPMED_CAP_CAP | LLDPMED_CAP_IV | LLDPMED_CAP_MDI_PD |
-                       LLDPMED_CAP_MDI_PSE | LLDPMED_CAP_POLICY | LLDPMED_CAP_LOCATION,
+               .p_med_cap_enabled = LLDP_MED_CAP_CAP | LLDP_MED_CAP_IV | LLDP_MED_CAP_MDI_PD |
+                       LLDP_MED_CAP_MDI_PSE | LLDP_MED_CAP_POLICY | LLDP_MED_CAP_LOCATION,
                .p_med_policy = {
                        { .type = 0 }, { .type = 0 }, {
-                               .type = LLDPMED_APPTYPE_GUESTVOICE,
+                               .type = LLDP_MED_APPTYPE_GUESTVOICE,
                                .unknown = 1,
                                .tagged = 1,
                                .vid = 475,
                                .priority = 3,
                                .dscp = 62
                        }, { .type = 0 }, { .type = 0 }, {
-                               .type = LLDPMED_APPTYPE_VIDEOCONFERENCE,
+                               .type = LLDP_MED_APPTYPE_VIDEOCONFERENCE,
                                .unknown = 0,
                                .tagged = 0,
                                .vid = 1007,
@@ -218,15 +242,43 @@ struct lldpd_hardware hardware2 = {
                },
                .p_med_location = {
                        {
-                               .format = LLDPMED_LOCFORMAT_COORD,
+                               .format = LLDP_MED_LOCFORMAT_COORD,
                                .data = "Not interpreted",
                                .data_len = 15,
                        }, { .format = 0 }, { .format = 0 },
                },
-#endif         
+#endif
        }
 };
 
+#ifdef ENABLE_CUSTOM
+struct lldpd_custom custom1 = {
+       .oui = { 33, 44, 55 },
+       .subtype = 44,
+       .oui_info = (u_int8_t*)"OUI content",
+};
+struct lldpd_custom custom2 = {
+       .oui = { 33, 44, 55 },
+       .subtype = 44,
+       .oui_info = (u_int8_t*)"More content",
+};
+struct lldpd_custom custom3 = {
+       .oui = { 33, 44, 55 },
+       .subtype = 45,
+       .oui_info = (u_int8_t*)"More more content",
+};
+struct lldpd_custom custom4 = {
+       .oui = { 33, 44, 56 },
+       .subtype = 44,
+       .oui_info = (u_int8_t*)"Even more content",
+};
+struct lldpd_custom custom5 = {
+       .oui = { 33, 44, 55 },
+       .subtype = 44,
+       .oui_info = (u_int8_t*)"Still more content",
+};
+#endif
+
 #ifdef ENABLE_DOT1
 struct lldpd_vlan vlan47 = {
        .v_name = "VLAN #47",
@@ -241,11 +293,11 @@ struct lldpd_vlan vlan1449 = {
        .v_vid = 1449,
 };
 struct lldpd_ppvid ppvid47 = {
-       .p_cap_status = LLDPD_PPVID_CAP_SUPPORTED | LLDPD_PPVID_CAP_ENABLED,
+       .p_cap_status = LLDP_PPVID_CAP_SUPPORTED | LLDP_PPVID_CAP_ENABLED,
        .p_ppvid = 47,
 };
 struct lldpd_ppvid ppvid118 = {
-       .p_cap_status = LLDPD_PPVID_CAP_SUPPORTED | LLDPD_PPVID_CAP_ENABLED,
+       .p_cap_status = LLDP_PPVID_CAP_SUPPORTED | LLDP_PPVID_CAP_ENABLED,
        .p_ppvid = 118,
 };
 struct lldpd_pi pi88cc = {
@@ -253,7 +305,7 @@ struct lldpd_pi pi88cc = {
        .p_pi_len = 2,
 };
 struct lldpd_pi pi888e01 = {
-       .p_pi = "\x88\x8e\e01",
+       .p_pi = "\x88\x8e\x01",
        .p_pi_len = 3,
 };
 #endif
@@ -272,7 +324,6 @@ struct lldpd_port port2 = {
 void
 snmp_config()
 {
-       
        starttime = test_starttime;
        agent_scfg = &test_cfg;
        TAILQ_INIT(&test_cfg.g_chassis);
@@ -286,6 +337,21 @@ snmp_config()
        TAILQ_INIT(&test_cfg.g_hardware);
        TAILQ_INSERT_TAIL(&test_cfg.g_hardware, &hardware1, h_entries);
        TAILQ_INSERT_TAIL(&test_cfg.g_hardware, &hardware2, h_entries);
+#ifdef ENABLE_CUSTOM
+       custom1.oui_info_len = strlen((char*)custom1.oui_info);
+       custom2.oui_info_len = strlen((char*)custom2.oui_info);
+       custom3.oui_info_len = strlen((char*)custom3.oui_info);
+       custom4.oui_info_len = strlen((char*)custom4.oui_info);
+       custom5.oui_info_len = strlen((char*)custom5.oui_info);
+       TAILQ_INIT(&hardware1.h_lport.p_custom_list);
+       TAILQ_INIT(&hardware2.h_lport.p_custom_list);
+       TAILQ_INIT(&port2.p_custom_list);
+       TAILQ_INSERT_TAIL(&hardware2.h_lport.p_custom_list, &custom1, next);
+       TAILQ_INSERT_TAIL(&hardware2.h_lport.p_custom_list, &custom2, next);
+       TAILQ_INSERT_TAIL(&hardware2.h_lport.p_custom_list, &custom3, next);
+       TAILQ_INSERT_TAIL(&hardware2.h_lport.p_custom_list, &custom4, next);
+       TAILQ_INSERT_TAIL(&hardware1.h_lport.p_custom_list, &custom5, next);
+#endif
 #ifdef ENABLE_DOT1
        TAILQ_INIT(&hardware1.h_lport.p_vlans);
        TAILQ_INSERT_TAIL(&hardware1.h_lport.p_vlans, &vlan47, v_entries);
@@ -309,7 +375,6 @@ snmp_config()
        TAILQ_INSERT_TAIL(&hardware1.h_rports, &hardware2.h_lport, p_entries);
        TAILQ_INIT(&hardware2.h_rports);
        TAILQ_INSERT_TAIL(&hardware2.h_rports, &hardware1.h_lport, p_entries);
-       
 }
 
 /* Convert OID to a string. Static buffer. */
@@ -318,15 +383,21 @@ snmp_oidrepr(oid *name, size_t namelen)
 {
        static char *buffer[4] = {NULL, NULL, NULL, NULL};
        static int current = 0;
+       size_t i;
+
        current = (current + 1)%4;
-       if (buffer[current]) free(buffer[current]); buffer[current] = NULL;
+       free(buffer[current]); buffer[current] = NULL;
 
-       int i;
        for (i = 0; i < namelen; i++) {
                /* Not very efficient... */
                char *newbuffer = NULL;
-               asprintf(&newbuffer, "%s.%u", buffer[current]?buffer[current]:"", name[i]);
-               if (buffer[current]) free(buffer[current]);
+               if (asprintf(&newbuffer, "%s.%lu", buffer[current]?buffer[current]:"",
+                       (unsigned long)name[i]) == -1) {
+                       free(buffer[current]);
+                       buffer[current] = NULL;
+                       return NULL;
+               }
+               free(buffer[current]);
                buffer[current] = newbuffer;
        }
        return buffer[current++];
@@ -353,10 +424,10 @@ struct tree_node snmp_tree[] = {
        { {1, 1, 4, 0}, 4, ASN_INTEGER,   { .integer = 1 } },  /* lldpTxDelay */
        { {1, 1, 5, 0}, 4, ASN_INTEGER,   { .integer = 5 } },  /* lldpNotificationInterval */
        { {1, 2, 1, 0}, 4, ASN_TIMETICKS, { .integer = 10000 } },/* lldpStatsRemTablesLastChangeTime */
-       { {1, 2, 2, 0}, 4, ASN_GAUGE,     { .integer = 12916 } }, /* lldpStatsRemTablesInserts */
-       { {1, 2, 3, 0}, 4, ASN_GAUGE,     { .integer = 12914 } }, /* lldpStatsRemTablesDeletes */
-       { {1, 2, 4, 0}, 4, ASN_GAUGE,     { .integer = 0 } }, /* lldpStatsRemTablesDrops */
-       { {1, 2, 5, 0}, 4, ASN_GAUGE,     { .integer = 22910 } }, /* lldpStatsRemTablesAgeouts */
+       { {1, 2, 2, 0}, 4, ASN_GAUGE,     { .integer = 1100 } }, /* lldpStatsRemTablesInserts */
+       { {1, 2, 3, 0}, 4, ASN_GAUGE,     { .integer = 56 } }, /* lldpStatsRemTablesDeletes */
+       { {1, 2, 4, 0}, 4, ASN_GAUGE,     { .integer = 2 } }, /* lldpStatsRemTablesDrops */
+       { {1, 2, 5, 0}, 4, ASN_GAUGE,     { .integer = 230 } }, /* lldpStatsRemTablesAgeouts */
 
        { {1, 2, 6, 1, 2, 3}, 6, ASN_COUNTER, { .integer = 1352 } }, /* lldpStatsTxPortFramesTotal.3 */
        { {1, 2, 6, 1, 2, 4}, 6, ASN_COUNTER, { .integer = 11352 } }, /* lldpStatsTxPortFramesTotal.4 */
@@ -370,8 +441,8 @@ struct tree_node snmp_tree[] = {
        { {1, 2, 7, 1, 5, 4}, 6, ASN_COUNTER, { .integer = 14 } }, /* lldpStatsRxPortTLVsDiscardedTotal.4 */
        { {1, 2, 7, 1, 6, 3}, 6, ASN_COUNTER, { .integer = 4 } }, /* lldpStatsRxPortTLVsUnrecognizedTotal.3 */
        { {1, 2, 7, 1, 6, 4}, 6, ASN_COUNTER, { .integer = 14 } }, /* lldpStatsRxPortTLVsUnrecognizedTotal.4 */
-       { {1, 2, 7, 1, 7, 3}, 6, ASN_GAUGE,   { .integer = 1455 } }, /* lldpStatsRxPortAgeoutsTotal.3 */
-       { {1, 2, 7, 1, 7, 4}, 6, ASN_GAUGE,   { .integer = 21455 } }, /* lldpStatsRxPortAgeoutsTotal.4 */
+       { {1, 2, 7, 1, 7, 3}, 6, ASN_GAUGE,   { .integer = 20 } }, /* lldpStatsRxPortAgeoutsTotal.3 */
+       { {1, 2, 7, 1, 7, 4}, 6, ASN_GAUGE,   { .integer = 210 } }, /* lldpStatsRxPortAgeoutsTotal.4 */
 
        { {1, 3, 1, 0}, 4, ASN_INTEGER,   { .integer = 4 } }, /* lldpLocChassisIdSubtype */
        /* lldpLocChassisId */
@@ -498,6 +569,20 @@ struct tree_node snmp_tree[] = {
          { .string = { .octet = (char *)zeroDotZero,
                        .len = sizeof(zeroDotZero) }} },
 
+#ifdef ENABLE_CUSTOM
+       /* lldpRemOrgDefInfo */
+       { {1, 4, 4, 1, 4, 0, 3, 1, 33, 44, 55, 44, 1 }, 13, ASN_OCTET_STR,
+         { .string = { .octet = "OUI content", .len = 11 }} },
+       { {1, 4, 4, 1, 4, 0, 3, 1, 33, 44, 55, 44, 2 }, 13, ASN_OCTET_STR,
+         { .string = { .octet = "More content", .len = 12 }} },
+       { {1, 4, 4, 1, 4, 0, 3, 1, 33, 44, 55, 45, 3 }, 13, ASN_OCTET_STR,
+         { .string = { .octet = "More more content", .len = 17 }} },
+       { {1, 4, 4, 1, 4, 0, 3, 1, 33, 44, 56, 44, 4 }, 13, ASN_OCTET_STR,
+         { .string = { .octet = "Even more content", .len = 17 }} },
+       { {1, 4, 4, 1, 4, 10000, 4, 1, 33, 44, 55, 44, 1 }, 13, ASN_OCTET_STR,
+         { .string = { .octet = "Still more content", .len = 18 }} },
+#endif
+
 #ifdef ENABLE_DOT3
        /* lldpXdot3LocPortAutoNegSupported */
        { {1, 5, 4623, 1, 2, 1, 1, 1, 3 }, 9, ASN_INTEGER, { .integer = 1 }},
@@ -666,7 +751,7 @@ struct tree_node snmp_tree[] = {
 
        /* lldpXMedLocLocationInfo */
        { {1, 5, 4795, 1, 2, 9, 1, 2, 3, 3}, 10, ASN_OCTET_STR,
-         { .string = { .octet = "\x15\x02FR\x06\x0dCommercial Rd\x13\x014", .len = 22 }} },
+         { .string = { .octet = "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4", .len = 22 }} },
        { {1, 5, 4795, 1, 2, 9, 1, 2, 4, 2}, 10, ASN_OCTET_STR,
          { .string = { .octet = "Not interpreted", .len = 15 }} },
 
@@ -754,7 +839,7 @@ struct tree_node snmp_tree[] = {
        { {1, 5, 4795, 1, 3, 4, 1, 2, 0, 3, 1, 2}, 12, ASN_OCTET_STR,
          { .string = { .octet = "Not interpreted", .len = 15 }} },
        { {1, 5, 4795, 1, 3, 4, 1, 2, 10000, 4, 1, 3}, 12, ASN_OCTET_STR,
-         { .string = { .octet = "\x15\x02FR\x06\x0dCommercial Rd\x13\x014", .len = 22 }} },
+         { .string = { .octet = "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4", .len = 22 }} },
 
        /* lldpXMedRemXPoEDeviceType */
        { {1, 5, 4795, 1, 3, 5, 1, 1, 0, 3, 1}, 11, ASN_INTEGER, { .integer = 4 }},
@@ -786,10 +871,10 @@ struct tree_node snmp_tree[] = {
        { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 1449}, 10, ASN_OCTET_STR,
          { .string = { .octet = "VLAN #1449", .len = 10 }} },
        /* lldpXdot1LocProtocolId */
-       { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 13175}, 10, ASN_OCTET_STR,
+       { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 30321}, 10, ASN_OCTET_STR,
+         { .string = { .octet = "\x88\x8e\x01", .len = 3 } }},
+       { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 30515}, 10, ASN_OCTET_STR,
          { .string = { .octet = "\x88\xcc", .len = 2 } }},
-       { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 29020}, 10, ASN_OCTET_STR,
-         { .string = { .octet = "\x88\x8e\e01", .len = 3 } }},
 
        /* lldpXdot1RemPortVlanId */
        { { 1, 5, 32962, 1, 3, 1, 1, 1, 0, 3, 1}, 11, ASN_INTEGER, { .integer = 0 }},
@@ -809,10 +894,10 @@ struct tree_node snmp_tree[] = {
        { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 1449}, 12, ASN_OCTET_STR,
          { .string = { .octet = "VLAN #1449", .len = 10 }} },
        /* lldpXdot1RemProtocolId */
-       { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 13175}, 12, ASN_OCTET_STR,
-         { .string = { .octet = "\x88\xcc", .len = 2 } }},
-       { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 29020}, 12, ASN_OCTET_STR,
-         { .string = { .octet = "\x88\x8e\e01", .len = 3 } }},
+       { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 30321}, 12, ASN_OCTET_STR,
+         { .string = { .octet = "\x88\x8e\x01", .len = 3 } }},
+       { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 30515}, 12, ASN_OCTET_STR,
+         { .string = { .octet = "\x88\xcc", .len = 2 } }}
 #endif
 };
 
@@ -821,10 +906,10 @@ tohex(char *str, size_t len)
 {
        static char *hex[] = { NULL, NULL };
        static int which = 0;
-       if (hex[which]) free(hex[which]); hex[which] = NULL;
+       free(hex[which]); hex[which] = NULL;
        hex[which] = malloc(len * 3 + 1);
        fail_unless(hex[which] != NULL, "Not enough memory?");
-       for (int i = 0; i < len; i++)
+       for (size_t i = 0; i < len; i++)
                snprintf(hex[which] + 3*i, 4, "%02X ", (unsigned char)str[i]);
        which = 1 - which;
        return hex[1 - which];
@@ -850,7 +935,7 @@ snmp_merge(struct variable8 *v1, struct tree_node *n, struct variable *vp,
        vp->type = v1->type;
        vp->acl = v1->acl;
        vp->findVar = v1->findVar;
-       vp->namelen = v1->namelen + 
+       vp->namelen = v1->namelen +
                sizeof(lldp_oid)/sizeof(oid);
        memcpy(vp->name, lldp_oid, sizeof(lldp_oid));
        memcpy(vp->name + sizeof(lldp_oid)/sizeof(oid),
@@ -869,6 +954,7 @@ snmp_compare(struct tree_node *n,
             u_char *result, size_t varlen,
             oid *target, size_t targetlen, char *repr)
 {
+       unsigned long int value;
        fail_unless((targetlen == sizeof(lldp_oid)/sizeof(oid) + n->namelen) &&
                    !memcmp(target, lldp_oid, sizeof(lldp_oid)) &&
                    !memcmp(target + sizeof(lldp_oid)/sizeof(oid),
@@ -884,12 +970,12 @@ snmp_compare(struct tree_node *n,
                fail_unless(varlen == sizeof(unsigned long int),
                            "Inappropriate length for integer type for OID %s",
                            repr);
-               fail_unless(n->value.integer ==
-                           *(unsigned long int *)result,
+               memcpy(&value, result, sizeof(value));
+               fail_unless(n->value.integer == value,
                            "For OID %s, expected value %u but got %u instead",
                            repr,
                            n->value.integer,
-                           *(unsigned long int *)result);
+                           value);
                break;
        default:
                fail_unless(((n->value.string.len == varlen) &&
@@ -904,7 +990,7 @@ snmp_compare(struct tree_node *n,
 
 START_TEST (test_variable_order)
 {
-       int i;
+       size_t i;
        for (i = 0; i < agent_lldp_vars_size() - 1; i++) {
                fail_unless(snmp_oid_compare(agent_lldp_vars[i].name,
                                             agent_lldp_vars[i].namelen,
@@ -919,11 +1005,11 @@ END_TEST
 
 START_TEST (test_get)
 {
-       int j;
+       size_t j;
        for (j = 0;
             j < sizeof(snmp_tree)/sizeof(struct tree_node);
             j++) {
-               int             i;
+               size_t          i;
                int             found = 0;
                struct variable vp;
                oid             target[MAX_OID_LEN];
@@ -946,7 +1032,7 @@ START_TEST (test_get)
 
                        /* Invoke the function */
                        result = vp.findVar(&vp, target, &targetlen, 1, &varlen, &wmethod);
-                       
+
                        /* Check the result */
                        fail_unless(result != NULL,
                                    "No result when querying %s", repr);
@@ -963,12 +1049,12 @@ END_TEST
 
 START_TEST (test_getnext)
 {
-       int j;
-       int end = sizeof(snmp_tree)/sizeof(struct tree_node);
+       size_t j;
+       size_t end = sizeof(snmp_tree)/sizeof(struct tree_node);
        for (j = 0;
             j < end;
             j++) {
-               int             i;
+               size_t          i;
                struct variable vp;
                oid             target[MAX_OID_LEN];
                size_t          targetlen;