]> git.ipfire.org Git - thirdparty/lldpd.git/blobdiff - tests/check_cdp.c
tests: display tests/test-suite.log on errors
[thirdparty/lldpd.git] / tests / check_cdp.c
index 7ad844f089e9490b19704b139377aebfac89a3c6..dddd063cbae9fa531c766ca8373e357a280cd7b0 100644 (file)
@@ -1,10 +1,25 @@
-#define _GNU_SOURCE 1
+/* -*- 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 <stdlib.h>
 #include <sys/socket.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <check.h>
-#include "../src/lldpd.h"
 #include "common.h"
 
 char filenameprefix[] = "cdp_send";
@@ -92,6 +107,12 @@ Cisco Discovery Protocol
        struct packet *pkt;
        in_addr_t addr;
        struct lldpd_mgmt *mgmt;
+       struct lldpd cfg = {
+               .g_config = {
+                       .c_ttl = 180,
+                       .c_platform = "Linux"
+               }
+       };
 
        /* Populate port and chassis */
        hardware.h_lport.p_id_subtype = LLDP_PORTID_SUBTYPE_IFNAME;
@@ -100,7 +121,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;
@@ -113,7 +134,7 @@ Cisco Discovery Protocol
        TAILQ_INSERT_TAIL(&chassis.c_mgmt, mgmt, m_entries);
 
        /* Build packet */
-       n = cdpv1_send(NULL, &hardware);
+       n = cdpv1_send(&cfg, &hardware);
        if (n != 0) {
                fail("unable to build packet");
                return;
@@ -221,15 +242,21 @@ Cisco Discovery Protocol
        in_addr_t addr2;
        struct lldpd_mgmt *mgmt1;
        struct lldpd_mgmt *mgmt2;
+       struct lldpd cfg = {
+               .g_config = {
+                       .c_ttl = 180,
+                       .c_platform = "Linux"
+               }
+       };
 
        /* 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 =
@@ -247,7 +274,7 @@ Cisco Discovery Protocol
        TAILQ_INSERT_TAIL(&chassis.c_mgmt, mgmt2, m_entries);
 
        /* Build packet */
-       n = cdpv2_send(NULL, &hardware);
+       n = cdpv2_send(&cfg, &hardware);
        if (n != 0) {
                fail("unable to build packet");
                return;