]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
cdp: allow reception of native vlan
authorVincent Bernat <bernat@luffy.cx>
Sat, 17 Dec 2011 16:09:43 +0000 (17:09 +0100)
committerVincent Bernat <bernat@luffy.cx>
Sat, 17 Dec 2011 16:09:43 +0000 (17:09 +0100)
CHANGELOG
src/cdp.c
src/cdp.h

index 1a1e9d017f9fd64c08d963decfb91147ca62bcb7..a6816e3b1250be34af01a1684c49e4b8e1579095 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+lldpd (0.5.6)
+  * Features:
+    + Parse CDP native VLAN TLV.
+
 lldpd (0.5.5)
   * Features:
     + Support for PPVID and PI Dot1 TLV, thanks to Shuah Khan.
index af4e552cc5d2f52eab78cd5ddbd64c04e4f3f577..f71a36f3bb30bf6589a8ae85f10e64e83d0fe340 100644 (file)
--- a/src/cdp.c
+++ b/src/cdp.c
@@ -20,6 +20,7 @@
 
 #if defined (ENABLE_CDP) || defined (ENABLE_FDP)
 
+#include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
 #include <arpa/inet.h>
@@ -209,6 +210,9 @@ cdp_decode(struct lldpd *cfg, char *frame, int s,
 #endif
        u_int8_t *pos, *tlv, *pos_address, *pos_next_address;
        int length, len_eth, tlv_type, tlv_len, addresses_len, address_len;
+#ifdef ENABLE_DOT1
+       struct lldpd_vlan *vlan;
+#endif
 
        if ((chassis = calloc(1, sizeof(struct lldpd_chassis))) == NULL) {
                LLOG_WARN("failed to allocate remote chassis");
@@ -418,6 +422,29 @@ cdp_decode(struct lldpd *cfg, char *frame, int s,
                        platform_len = tlv_len;
                        PEEK_SAVE(platform);
                        break;
+#ifdef ENABLE_DOT1
+               case CDP_TLV_NATIVEVLAN:
+                       CHECK_TLV_SIZE(2, "Native VLAN");
+                       if ((vlan = (struct lldpd_vlan *)calloc(1,
+                               sizeof(struct lldpd_vlan))) == NULL) {
+                               LLOG_WARN("unable to alloc vlan "
+                                         "structure for "
+                                         "tlv received on %s",
+                                         hardware->h_ifname);
+                               goto malformed;
+                       }
+                       vlan->v_vid = port->p_pvid = PEEK_UINT16;
+                       if (asprintf(&vlan->v_name, "VLAN #%d", vlan->v_vid) == -1) {
+                               LLOG_WARN("unable to alloc VLAN name for "
+                                         "TLV received on %s",
+                                         hardware->h_ifname);
+                               free(vlan);
+                               goto malformed;
+                       }
+                       TAILQ_INSERT_TAIL(&port->p_vlans,
+                                         vlan, v_entries);
+                       break;
+#endif
                default:
                        LLOG_DEBUG("unknown CDP/FDP TLV type (%d) received on %s",
                            ntohs(tlv_type), hardware->h_ifname);
index 1fe72c22555aadcd0078ef5eb38b96115b245576..bae7f5e2ba22e95e5a38f47c068090b2c462236b 100644 (file)
--- a/src/cdp.h
+++ b/src/cdp.h
@@ -41,7 +41,8 @@ enum {
        CDP_TLV_PORT                    = 3,
        CDP_TLV_CAPABILITIES            = 4,
        CDP_TLV_SOFTWARE                = 5,
-       CDP_TLV_PLATFORM                = 6
+       CDP_TLV_PLATFORM                = 6,
+       CDP_TLV_NATIVEVLAN              = 10
 };
 
 #define CDP_ADDRESS_PROTO_IP 0xcc