lldp: support multiple PPVIDs
As done for VLANs, add a new 'ppvids' attribute that reports all 'port and protocol VLAN ID' TLVs for the neighbor.
This commit is contained in:
@@ -838,16 +838,21 @@ typedef enum /*< flags >*/ {
|
||||
#define NM_LLDP_ATTR_SYSTEM_DESCRIPTION "system-description"
|
||||
#define NM_LLDP_ATTR_SYSTEM_CAPABILITIES "system-capabilities"
|
||||
#define NM_LLDP_ATTR_MANAGEMENT_ADDRESSES "management-addresses"
|
||||
|
||||
#define NM_LLDP_ATTR_IEEE_802_1_PVID "ieee-802-1-pvid"
|
||||
#define NM_LLDP_ATTR_IEEE_802_1_PPVID "ieee-802-1-ppvid"
|
||||
#define NM_LLDP_ATTR_IEEE_802_1_PPVID_FLAGS "ieee-802-1-ppvid-flags"
|
||||
#define NM_LLDP_ATTR_IEEE_802_1_VLANS "ieee-802-1-vlans"
|
||||
#define NM_LLDP_ATTR_IEEE_802_1_PPVIDS "ieee-802-1-ppvids"
|
||||
|
||||
/* These are deprecated in favor of NM_LLDP_ATTR_IEEE_802_1_VLANS,
|
||||
* which can report multiple VLANs */
|
||||
#define NM_LLDP_ATTR_IEEE_802_1_VID "ieee-802-1-vid"
|
||||
#define NM_LLDP_ATTR_IEEE_802_1_VLAN_NAME "ieee-802-1-vlan-name"
|
||||
|
||||
/* These are deprecated in favor of NM_LLDP_ATTR_IEEE_802_1_PPVIDS,
|
||||
* which can report multiple PPVIDs */
|
||||
#define NM_LLDP_ATTR_IEEE_802_1_PPVID "ieee-802-1-ppvid"
|
||||
#define NM_LLDP_ATTR_IEEE_802_1_PPVID_FLAGS "ieee-802-1-ppvid-flags"
|
||||
|
||||
#define NM_LLDP_DEST_NEAREST_BRIDGE "nearest-bridge"
|
||||
#define NM_LLDP_DEST_NEAREST_NON_TPMR_BRIDGE "nearest-non-tpmr-bridge"
|
||||
#define NM_LLDP_DEST_NEAREST_CUSTOMER_BRIDGE "nearest-customer-bridge"
|
||||
|
@@ -56,6 +56,7 @@ typedef enum {
|
||||
LLDP_ATTR_ID_IEEE_802_1_PVID,
|
||||
LLDP_ATTR_ID_IEEE_802_1_PPVID,
|
||||
LLDP_ATTR_ID_IEEE_802_1_PPVID_FLAGS,
|
||||
LLDP_ATTR_ID_IEEE_802_1_PPVIDS,
|
||||
LLDP_ATTR_ID_IEEE_802_1_VID,
|
||||
LLDP_ATTR_ID_IEEE_802_1_VLAN_NAME,
|
||||
LLDP_ATTR_ID_IEEE_802_1_VLANS,
|
||||
@@ -173,6 +174,7 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_lldp_attr_id_to_name, LldpAttrId,
|
||||
NM_UTILS_LOOKUP_STR_ITEM (LLDP_ATTR_ID_IEEE_802_1_PVID, NM_LLDP_ATTR_IEEE_802_1_PVID),
|
||||
NM_UTILS_LOOKUP_STR_ITEM (LLDP_ATTR_ID_IEEE_802_1_PPVID, NM_LLDP_ATTR_IEEE_802_1_PPVID),
|
||||
NM_UTILS_LOOKUP_STR_ITEM (LLDP_ATTR_ID_IEEE_802_1_PPVID_FLAGS, NM_LLDP_ATTR_IEEE_802_1_PPVID_FLAGS),
|
||||
NM_UTILS_LOOKUP_STR_ITEM (LLDP_ATTR_ID_IEEE_802_1_PPVIDS, NM_LLDP_ATTR_IEEE_802_1_PPVIDS),
|
||||
NM_UTILS_LOOKUP_STR_ITEM (LLDP_ATTR_ID_IEEE_802_1_VID, NM_LLDP_ATTR_IEEE_802_1_VID),
|
||||
NM_UTILS_LOOKUP_STR_ITEM (LLDP_ATTR_ID_IEEE_802_1_VLAN_NAME, NM_LLDP_ATTR_IEEE_802_1_VLAN_NAME),
|
||||
NM_UTILS_LOOKUP_STR_ITEM (LLDP_ATTR_ID_IEEE_802_1_VLANS, NM_LLDP_ATTR_IEEE_802_1_VLANS),
|
||||
@@ -189,6 +191,7 @@ _NM_UTILS_LOOKUP_DEFINE (static, _lldp_attr_id_to_type, LldpAttrId, LldpAttrType
|
||||
NM_UTILS_LOOKUP_ITEM (LLDP_ATTR_ID_IEEE_802_1_PVID, LLDP_ATTR_TYPE_UINT32),
|
||||
NM_UTILS_LOOKUP_ITEM (LLDP_ATTR_ID_IEEE_802_1_PPVID, LLDP_ATTR_TYPE_UINT32),
|
||||
NM_UTILS_LOOKUP_ITEM (LLDP_ATTR_ID_IEEE_802_1_PPVID_FLAGS, LLDP_ATTR_TYPE_UINT32),
|
||||
NM_UTILS_LOOKUP_ITEM (LLDP_ATTR_ID_IEEE_802_1_PPVIDS, LLDP_ATTR_TYPE_ARRAY_OF_VARDICTS),
|
||||
NM_UTILS_LOOKUP_ITEM (LLDP_ATTR_ID_IEEE_802_1_VID, LLDP_ATTR_TYPE_UINT32),
|
||||
NM_UTILS_LOOKUP_ITEM (LLDP_ATTR_ID_IEEE_802_1_VLAN_NAME, LLDP_ATTR_TYPE_STRING),
|
||||
NM_UTILS_LOOKUP_ITEM (LLDP_ATTR_ID_IEEE_802_1_VLANS, LLDP_ATTR_TYPE_ARRAY_OF_VARDICTS),
|
||||
@@ -602,6 +605,8 @@ lldp_neighbor_new (sd_lldp_neighbor *neighbor_sd, GError **error)
|
||||
|
||||
/*if (memcmp (oui, SD_LLDP_OUI_802_1, sizeof (oui)) == 0)*/
|
||||
{
|
||||
GVariantDict dict;
|
||||
|
||||
switch (subtype) {
|
||||
case SD_LLDP_OUI_802_1_SUBTYPE_PORT_VLAN_ID:
|
||||
if (len != 2)
|
||||
@@ -616,10 +621,17 @@ lldp_neighbor_new (sd_lldp_neighbor *neighbor_sd, GError **error)
|
||||
data8[0]);
|
||||
_lldp_attr_set_uint32 (neigh->attrs, LLDP_ATTR_ID_IEEE_802_1_PPVID,
|
||||
unaligned_read_be16 (&data8[1]));
|
||||
|
||||
g_variant_dict_init (&dict, NULL);
|
||||
g_variant_dict_insert (&dict, "ppvid", "u", (guint32) unaligned_read_be16 (&data8[1]));
|
||||
g_variant_dict_insert (&dict, "flags", "u", (guint32) data8[0]);
|
||||
|
||||
_lldp_attr_add_vardict (neigh->attrs,
|
||||
LLDP_ATTR_ID_IEEE_802_1_PPVIDS,
|
||||
g_variant_dict_end (&dict));
|
||||
break;
|
||||
case SD_LLDP_OUI_802_1_SUBTYPE_VLAN_NAME: {
|
||||
int l;
|
||||
GVariantDict dict;
|
||||
guint32 vid;
|
||||
const char *name;
|
||||
char *name_to_free;
|
||||
|
@@ -244,7 +244,7 @@ _test_recv_data1_check (GMainLoop *loop, NMLldpListener *listener)
|
||||
SD_LLDP_CHASSIS_SUBTYPE_MAC_ADDRESS, "00:01:30:F9:AD:A0",
|
||||
SD_LLDP_PORT_SUBTYPE_INTERFACE_NAME, "1/1");
|
||||
g_assert (neighbor);
|
||||
g_assert_cmpint (g_variant_n_children (neighbor), ==, 4 + 12);
|
||||
g_assert_cmpint (g_variant_n_children (neighbor), ==, 4 + 13);
|
||||
|
||||
attr = g_variant_lookup_value (neighbor, NM_LLDP_ATTR_DESTINATION, G_VARIANT_TYPE_STRING);
|
||||
nmtst_assert_variant_string (attr, NM_LLDP_DEST_NEAREST_BRIDGE);
|
||||
@@ -305,6 +305,18 @@ _test_recv_data1_check (GMainLoop *loop, NMLldpListener *listener)
|
||||
nmtst_assert_variant_uint32 (attr, 1);
|
||||
nm_clear_g_variant (&attr);
|
||||
|
||||
/* new PPVID attributes */
|
||||
attr = g_variant_lookup_value (neighbor, NM_LLDP_ATTR_IEEE_802_1_PPVIDS, G_VARIANT_TYPE ("aa{sv}"));
|
||||
g_assert_cmpuint (g_variant_n_children (attr), ==, 1);
|
||||
child = g_variant_get_child_value (attr, 0);
|
||||
g_assert (child);
|
||||
g_variant_lookup (child, "ppvid", "u", &v_uint);
|
||||
g_assert_cmpint (v_uint, ==, 0);
|
||||
g_variant_lookup (child, "flags", "u", &v_uint);
|
||||
g_assert_cmpint (v_uint, ==, 1);
|
||||
nm_clear_g_variant (&child);
|
||||
nm_clear_g_variant (&attr);
|
||||
|
||||
/* IEEE 802.1 - VLAN Name */
|
||||
attr = g_variant_lookup_value (neighbor, NM_LLDP_ATTR_IEEE_802_1_VLAN_NAME, G_VARIANT_TYPE_STRING);
|
||||
nmtst_assert_variant_string (attr, "v2-0488-03-0505");
|
||||
|
@@ -752,6 +752,16 @@ class Device(ExportedObj):
|
||||
'name': dbus.String('My VLAN'),
|
||||
}, signature = 'sv'),
|
||||
]),
|
||||
'ieee-802-1-ppvids': dbus.Array([
|
||||
dbus.Dictionary({
|
||||
'ppvid': dbus.UInt32(4),
|
||||
'flags': dbus.UInt32(0x12),
|
||||
}, signature = 'sv'),
|
||||
dbus.Dictionary({
|
||||
'ppvid': dbus.UInt32(10),
|
||||
'flags': dbus.UInt32(0x31),
|
||||
}, signature = 'sv'),
|
||||
]),
|
||||
}),
|
||||
dbus.Dictionary({
|
||||
'chassis-id-type': dbus.UInt32(6),
|
||||
|
Reference in New Issue
Block a user