]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Handle reception and display of PVID
authorVincent Bernat <bernat@luffy.cx>
Tue, 16 Dec 2008 16:34:02 +0000 (17:34 +0100)
committerVincent Bernat <bernat@luffy.cx>
Tue, 16 Dec 2008 16:34:02 +0000 (17:34 +0100)
src/agent.c
src/lldp.c
src/lldpctl.c
src/lldpd.h

index 6a77970070413bcb56af80489ce7c822bd72982a..86e425b877f34c204a032cc798ba9f9712666356 100644 (file)
@@ -326,6 +326,7 @@ header_tprvindexed_table(struct variable *vp, oid *name, size_t *length,
 #define LLDP_SNMP_LOCAL_DOT3_AGG_STATUS 9
 #define LLDP_SNMP_LOCAL_DOT3_AGG_ID 10
 #define LLDP_SNMP_LOCAL_DOT3_MFS 11
+#define LLDP_SNMP_LOCAL_DOT1_PVID 12
 /* Remote ports */
 #define LLDP_SNMP_REMOTE_CIDSUBTYPE 1
 #define LLDP_SNMP_REMOTE_CID 2
@@ -343,6 +344,7 @@ header_tprvindexed_table(struct variable *vp, oid *name, size_t *length,
 #define LLDP_SNMP_REMOTE_DOT3_AGG_STATUS 14
 #define LLDP_SNMP_REMOTE_DOT3_AGG_ID 15
 #define LLDP_SNMP_REMOTE_DOT3_MFS 16
+#define LLDP_SNMP_REMOTE_DOT1_PVID 17
 /* Local vlans */
 #define LLDP_SNMP_LOCAL_DOT1_VLANNAME 1
 /* Remote vlans */
@@ -862,6 +864,11 @@ agent_h_local_port(struct variable *vp, oid *name, size_t *length,
        case LLDP_SNMP_LOCAL_DOT3_MFS:
                long_ret = hardware->h_lport.p_mfs;
                return (u_char *)&long_ret;
+#endif
+#ifdef ENABLE_DOT1
+       case LLDP_SNMP_LOCAL_DOT1_PVID:
+               long_ret = hardware->h_lport.p_pvid; /* Should always be 0 */
+               return (u_char *)&long_ret;
 #endif
        default:
                break;
@@ -976,6 +983,11 @@ agent_h_remote_port(struct variable *vp, oid *name, size_t *length,
         case LLDP_SNMP_REMOTE_DOT3_MFS:
                 long_ret = hardware->h_rport->p_mfs;
                 return (u_char *)&long_ret;
+#endif
+#ifdef ENABLE_DOT1
+        case LLDP_SNMP_REMOTE_DOT1_PVID:
+                long_ret = hardware->h_rport->p_pvid;
+                return (u_char *)&long_ret;
 #endif
        default:
                break;
@@ -1114,6 +1126,10 @@ static struct variable8 lldp_vars[] = {
          {1, 5, 4623, 1, 2, 3, 1, 2}},
         {LLDP_SNMP_LOCAL_DOT3_MFS, ASN_INTEGER, RONLY, agent_h_local_port, 8,
          {1, 5, 4623, 1, 2, 4, 1, 1}},
+#endif
+#ifdef ENABLE_DOT1
+        {LLDP_SNMP_LOCAL_DOT1_PVID, ASN_INTEGER, RONLY, agent_h_local_port, 8,
+         {1, 5, 32962, 1, 2, 1, 1, 1}},
 #endif
         /* Remote ports */
         {LLDP_SNMP_REMOTE_CIDSUBTYPE, ASN_INTEGER, RONLY, agent_h_remote_port, 5, {1, 4, 1, 1, 4}},
@@ -1142,6 +1158,8 @@ static struct variable8 lldp_vars[] = {
          {1, 5, 4623, 1, 3, 4, 1, 1}},
 #endif
 #ifdef ENABLE_DOT1
+        {LLDP_SNMP_REMOTE_DOT1_PVID, ASN_INTEGER, RONLY, agent_h_remote_port, 8,
+         {1, 5, 32962, 1, 3, 1, 1, 1}},
         /* Local vlans */
         {LLDP_SNMP_LOCAL_DOT1_VLANNAME, ASN_OCTET_STR, RONLY, agent_h_local_vlan, 8,
          {1, 5, 32962, 1, 2, 3, 1, 2}},
index 5d406ca68f4eedcf8d763cd056db0943a4bd9b73..d47d489b61107143281d692e02109f88bfa6325d 100644 (file)
@@ -410,6 +410,8 @@ lldp_decode(struct lldpd *cfg, char *frame, int s,
        int size, type, subtype; /* TLV header */
        char *b;
        int gotend = 0;
+       struct lldpd_vlan *vlan;
+       int vlan_len;
 
        if ((chassis = calloc(1, sizeof(struct lldpd_chassis))) == NULL) {
                LLOG_WARN("failed to allocate remote chassis");
@@ -572,11 +574,8 @@ lldp_decode(struct lldpd *cfg, char *frame, int s,
                                hardware->h_rx_unrecognized_cnt++;
 #else
                                /* Dot1 */
-                               if ((*(u_int8_t*)(frame + f + 3)) ==
-                                   LLDP_TLV_DOT1_VLANNAME) {
-                                       struct lldpd_vlan *vlan;
-                                       int vlan_len;
-
+                               switch (*(u_int8_t*)(frame + f + 3)) {
+                               case LLDP_TLV_DOT1_VLANNAME:
                                        if ((size < 7) ||
                                            (size < 7 + *(u_int8_t*)(frame + f + 6))) {
                                                LLOG_WARNX("too short vlan tlv "
@@ -609,7 +608,19 @@ lldp_decode(struct lldpd *cfg, char *frame, int s,
                                        TAILQ_INSERT_TAIL(&port->p_vlans,
                                            vlan, v_entries);
                                        f += size - 7;
-                               } else {
+                                       break;
+                               case LLDP_TLV_DOT1_PVID:
+                                       if (size < 6) {
+                                               LLOG_WARNX("too short pvid tlv "
+                                                   "received on %s",
+                                                   hardware->h_ifname);
+                                               goto malformed;
+                                       }
+                                       port->p_pvid =
+                                           ntohs(*(u_int16_t*)(frame + f + 4));
+                                       f += size;
+                                       break;
+                               default:
                                        /* Unknown Dot1 TLV, ignore it */
                                        f += size;
                                        hardware->h_rx_unrecognized_cnt++;
index 608637a6a9ee2153dea65429cf121e734e98688a..5ce767102ad63a219d2bc120c1c2ef3d16b429cc 100644 (file)
@@ -756,7 +756,9 @@ display_vlans(struct lldpd_port *port)
        int i = 0;
        struct lldpd_vlan *vlan;
        TAILQ_FOREACH(vlan, &port->p_vlans, v_entries)
-               printf("   VLAN %4d: %-20s%c", vlan->v_vid, vlan->v_name,
+               printf("  %cVLAN %4d: %-20s%c",
+                   (port->p_pvid == vlan->v_vid)?'*':' ',
+                   vlan->v_vid, vlan->v_name,
                    (i++ % 2) ? '\n' : ' ');
        if (i % 2)
                printf("\n");
index 3e437a55286da6aba64ab2fd87a378133b5829c5..36bc0b5aae99ed6b058150ac514659370dffda8f 100644 (file)
@@ -160,7 +160,8 @@ struct lldpd_port {
 #endif
 
 #ifdef ENABLE_DOT1
-#define STRUCT_LLDPD_PORT_DOT1 "PP"
+#define STRUCT_LLDPD_PORT_DOT1 "wPP"
+       u_int16_t                p_pvid;
        TAILQ_HEAD(, lldpd_vlan) p_vlans;
 #else
 #define STRUCT_LLDPD_PORT_DOT1 ""