datapath-windows: Allow NdisSwitchPortTypeSynthetic to be updated
[cascardo/ovs.git] / lib / ovs-lldp.c
index 3359a94..db97648 100644 (file)
@@ -179,7 +179,7 @@ aa_print_lldp_and_aa_stats(struct ds *ds, struct lldp *lldp)
         return;
     }
 
-    LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+    LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
         ds_put_format(ds, "\ttx cnt: %"PRIu64"\n", hw->h_tx_cnt);
         ds_put_format(ds, "\trx cnt: %"PRIu64"\n", hw->h_rx_cnt);
         ds_put_format(ds, "\trx discarded cnt: %"PRIu64"\n",
@@ -244,7 +244,7 @@ aa_print_element_status(struct ds *ds, struct lldp *lldp) OVS_REQUIRES(mutex)
         return;
     }
 
-    LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+    LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
         aa_print_element_status_port(ds, hw);
     }
 }
@@ -305,7 +305,7 @@ aa_print_isid_status(struct ds *ds, struct lldp *lldp) OVS_REQUIRES(mutex)
 
     ds_put_format(ds, "LLDP: %s\n", lldp->name);
 
-    LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+    LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
         aa_print_isid_status_port(lldp, hw);
     }
 
@@ -480,18 +480,14 @@ aa_configure(const struct aa_settings *s)
     HMAP_FOR_EACH (lldp, hmap_node, all_lldps) {
         struct lldpd_chassis *chassis;
 
-        LIST_FOR_EACH (chassis, list, &lldp->lldpd->g_chassis.list) {
+        LIST_FOR_EACH (chassis, list, &lldp->lldpd->g_chassis) {
             /* System Description */
-            if (chassis->c_descr) {
-                free(chassis->c_descr);
-            }
+            free(chassis->c_descr);
             chassis->c_descr = s->system_description[0] ?
                 xstrdup(s->system_description) : xstrdup(PACKAGE_STRING);
 
             /* System Name */
-            if (chassis->c_name) {
-                free(chassis->c_name);
-            }
+            free(chassis->c_name);
             chassis->c_name = xstrdup(s->system_name);
         }
     }
@@ -550,7 +546,7 @@ aa_mapping_register(void *aux, const struct aa_mapping_settings *s)
                     hash_pointer(m->aux, 0));
 
         /* Configure the mapping on each port of the LLDP stack. */
-        LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+        LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
             update_mapping_on_lldp(lldp, hw, m);
         }
     }
@@ -626,7 +622,7 @@ aa_mapping_unregister(void *aux)
             free(m);
 
             /* Remove from all the lldp instances */
-            LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+            LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
                 if (hw->h_ifname) {
                     VLOG_INFO("\t\t hardware->h_ifname=%s", hw->h_ifname);
                 }
@@ -676,11 +672,8 @@ void
 lldp_process_packet(struct lldp *lldp, const struct dp_packet *p)
 {
     if (lldp) {
-        lldpd_recv(lldp->lldpd,
-                   (struct lldpd_hardware *)
-                       lldp->lldpd->g_hardware.h_entries.next,
-                   (char *) p->data_,
-                   p->size_);
+        lldpd_recv(lldp->lldpd, lldpd_first_hardware(lldp->lldpd),
+                   (char *) dp_packet_data(p), dp_packet_size(p));
     }
 }
 
@@ -734,8 +727,7 @@ lldp_put_packet(struct lldp *lldp, struct dp_packet *packet,
                 uint8_t eth_src[ETH_ADDR_LEN]) OVS_EXCLUDED(mutex)
 {
     struct lldpd *mylldpd = lldp->lldpd;
-    struct lldpd_hardware *hw = (struct lldpd_hardware *)
-        mylldpd->g_hardware.h_entries.next;
+    struct lldpd_hardware *hw = lldpd_first_hardware(mylldpd);
     uint32_t lldp_size = 0;
     static const uint8_t eth_addr_lldp[6] =
         {0x01, 0x80, 0xC2, 0x00, 0x00, 0x0e};
@@ -807,8 +799,8 @@ lldp_create(const struct netdev *netdev,
                       lldp->lldpd->g_config.c_tx_hold;
     lchassis->c_ttl = LLDP_CHASSIS_TTL;
     lldpd_assign_cfg_to_protocols(lldp->lldpd);
-    list_init(&lldp->lldpd->g_chassis.list);
-    list_push_back(&lldp->lldpd->g_chassis.list, &lchassis->list);
+    list_init(&lldp->lldpd->g_chassis);
+    list_push_back(&lldp->lldpd->g_chassis, &lchassis->list);
 
     if ((hw = lldpd_alloc_hardware(lldp->lldpd,
                                    (char *) netdev_get_name(netdev),
@@ -830,20 +822,19 @@ lldp_create(const struct netdev *netdev,
     hw->h_lport.p_id_len = strlen(netdev_get_name(netdev));
 
     /* Auto Attach element tlv */
-    hw->h_lport.p_element.type = LLDP_TLV_AA_ELEM_TYPE_TAG_CLIENT;
+    hw->h_lport.p_element.type = LLDP_TLV_AA_ELEM_TYPE_CLIENT_VIRTUAL_SWITCH;
     hw->h_lport.p_element.mgmt_vlan = 0;
     memcpy(&hw->h_lport.p_element.system_id.system_mac,
            lchassis->c_id, lchassis->c_id_len);
     hw->h_lport.p_element.system_id.conn_type =
         LLDP_TLV_AA_ELEM_CONN_TYPE_SINGLE;
-
-    hw->h_lport.p_element.system_id.smlt_id = 0;
-    hw->h_lport.p_element.system_id.mlt_id[0] = 0;
-    hw->h_lport.p_element.system_id.mlt_id[1] = 0;
+    hw->h_lport.p_element.system_id.rsvd = 0;
+    hw->h_lport.p_element.system_id.rsvd2[0] = 0;
+    hw->h_lport.p_element.system_id.rsvd2[1] = 0;
 
     list_init(&hw->h_lport.p_isid_vlan_maps);
-    list_init(&lldp->lldpd->g_hardware.h_entries);
-    list_push_back(&lldp->lldpd->g_hardware.h_entries, &hw->h_entries);
+    list_init(&lldp->lldpd->g_hardware);
+    list_push_back(&lldp->lldpd->g_hardware, &hw->h_entries);
 
     ovs_mutex_lock(&mutex);
 
@@ -899,8 +890,8 @@ lldp_create_dummy(void)
     list_init(&lchassis->c_mgmt);
     lchassis->c_ttl = LLDP_CHASSIS_TTL;
     lldpd_assign_cfg_to_protocols(lldp->lldpd);
-    list_init(&lldp->lldpd->g_chassis.list);
-    list_push_back(&lldp->lldpd->g_chassis.list, &lchassis->list);
+    list_init(&lldp->lldpd->g_chassis);
+    list_push_back(&lldp->lldpd->g_chassis, &lchassis->list);
 
     hw = lldpd_alloc_hardware(lldp->lldpd, "dummy-hw", 0);
 
@@ -916,19 +907,19 @@ lldp_create_dummy(void)
     hw->h_lport.p_id_len = strlen(hw->h_lport.p_id);
 
     /* Auto Attach element tlv */
-    hw->h_lport.p_element.type = LLDP_TLV_AA_ELEM_TYPE_TAG_CLIENT;
+    hw->h_lport.p_element.type = LLDP_TLV_AA_ELEM_TYPE_CLIENT_VIRTUAL_SWITCH;
     hw->h_lport.p_element.mgmt_vlan = 0;
     memcpy(&hw->h_lport.p_element.system_id.system_mac,
            lchassis->c_id, lchassis->c_id_len);
     hw->h_lport.p_element.system_id.conn_type =
         LLDP_TLV_AA_ELEM_CONN_TYPE_SINGLE;
-    hw->h_lport.p_element.system_id.smlt_id = 0;
-    hw->h_lport.p_element.system_id.mlt_id[0] = 0;
-    hw->h_lport.p_element.system_id.mlt_id[1] = 0;
+    hw->h_lport.p_element.system_id.rsvd = 0;
+    hw->h_lport.p_element.system_id.rsvd2[0] = 0;
+    hw->h_lport.p_element.system_id.rsvd2[1] = 0;
 
     list_init(&hw->h_lport.p_isid_vlan_maps);
-    list_init(&lldp->lldpd->g_hardware.h_entries);
-    list_push_back(&lldp->lldpd->g_hardware.h_entries, &hw->h_entries);
+    list_init(&lldp->lldpd->g_hardware);
+    list_push_back(&lldp->lldpd->g_hardware, &hw->h_entries);
 
     return lldp;
 }