lldpctl_atom_foreach(mgmts, mgmt) {
tag_datatag(w, "mgmt-ip", "MgmtIP",
lldpctl_atom_get_str(mgmt, lldpctl_k_mgmt_ip));
+ tag_datatag(w, "mgmt-iface", "MgmtIface",
+ lldpctl_atom_get_str(mgmt, lldpctl_k_mgmt_iface_index));
}
lldpctl_atom_dec_ref(mgmts);
lldpctl_atom_dec_ref(mgmt->parent);
}
+static long int
+_lldpctl_atom_get_int_mgmt(lldpctl_atom_t *atom, lldpctl_key_t key)
+{
+ struct _lldpctl_atom_mgmt_t *m =
+ (struct _lldpctl_atom_mgmt_t *)atom;
+
+ /* Local and remote port */
+ switch (key) {
+ case lldpctl_k_mgmt_iface_index:
+ return m->mgmt->m_iface;
+ default:
+ return SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST);
+ }
+}
+
static const char*
_lldpctl_atom_get_str_mgmt(lldpctl_atom_t *atom, lldpctl_key_t key)
{
{ atom_mgmt, sizeof(struct _lldpctl_atom_mgmt_t),
.init = _lldpctl_atom_new_mgmt,
.free = _lldpctl_atom_free_mgmt,
+ .get_int = _lldpctl_atom_get_int_mgmt,
.get_str = _lldpctl_atom_get_str_mgmt };
ATOM_BUILDER_REGISTER(mgmts_list, 6);
lldpctl_k_med_power_val, /**< `(I,W)` LLDP MED power value */
lldpctl_k_mgmt_ip = 3000, /**< `(S)` IP address */
+ lldpctl_k_mgmt_iface_index = 30001, /**< `(I)` Interface index */
lldpctl_k_tx_cnt = 4000, /**< `(I)` tx cnt. Only works for a local port. */
lldpctl_k_rx_cnt, /**< `(I)` rx cnt. Only works for a local port. */
"lldp.eth0.chassis.mac": "00:00:00:00:00:02",
"lldp.eth0.chassis.name": "ns-2.example.com",
"lldp.eth0.chassis.mgmt-ip": "fe80::200:ff:fe00:2",
+ "lldp.eth0.chassis.mgmt-iface": "2",
"lldp.eth0.chassis.Bridge.enabled": "off",
"lldp.eth0.chassis.Wlan.enabled": "off",
"lldp.eth0.port.mac": "00:00:00:00:00:02",
"lldp.eth0.chassis.mac": "00:00:00:00:00:01",
"lldp.eth0.chassis.name": "ns-1.example.com",
"lldp.eth0.chassis.mgmt-ip": "fe80::200:ff:fe00:1",
+ "lldp.eth0.chassis.mgmt-iface": "3",
"lldp.eth0.chassis.Bridge.enabled": "off",
"lldp.eth0.chassis.Wlan.enabled": "off",
"lldp.eth0.port.mac": "00:00:00:00:00:01",
with namespaces(1):
out = lldpcli("-f", "keyvalue", "show", "neighbors")
assert out["lldp.eth0.chassis.mgmt-ip"] == "2001:db8::47"
+ assert out["lldp.eth0.chassis.mgmt-iface"] == "0"
def test_management_address(lldpd1, lldpd, lldpcli, links, namespaces):
with namespaces(1):
out = lldpcli("-f", "keyvalue", "show", "neighbors")
assert out["lldp.eth0.chassis.mgmt-ip"] == "172.25.21.47"
+ assert out["lldp.eth0.chassis.mgmt-iface"] == "2"
def test_change_management_address(lldpd1, lldpd, lldpcli, links, namespaces):
with namespaces(1):
out = lldpcli("-f", "keyvalue", "show", "neighbors")
assert out["lldp.eth0.chassis.mgmt-ip"] == "192.168.14.2"
+ assert out["lldp.eth0.chassis.mgmt-iface"] == "2"
with namespaces(2):
ipr.addr('del', index=idx, address="192.168.14.2", mask=24)
ipr.addr('add', index=idx, address="192.168.14.5", mask=24)
with namespaces(1):
out = lldpcli("-f", "keyvalue", "show", "neighbors")
assert out["lldp.eth0.chassis.mgmt-ip"] == "192.168.14.5"
+ assert out["lldp.eth0.chassis.mgmt-iface"] == "2"
def test_portid_subtype_ifname(lldpd1, lldpd, lldpcli, namespaces):
SysName: ns-2.example.com
SysDescr: Spectacular GNU/Linux 2016 {uname}
MgmtIP: fe80::200:ff:fe00:2
+ MgmtIface: 2
Capability: Bridge, off
Capability: Router, {router}
Capability: Wlan, off
SysName: ns-1.example.com
SysDescr: Spectacular GNU/Linux 2016 {uname}
MgmtIP: fe80::200:ff:fe00:1
+ MgmtIface: 3
Capability: Bridge, off
Capability: Router, {router}
Capability: Wlan, off
"value": "00:00:00:00:00:02"},
"descr": "Spectacular GNU/Linux 2016 {}".format(uname),
"mgmt-ip": "fe80::200:ff:fe00:2",
+ "mgmt-iface": "2",
"capability": [
{"type": "Bridge", "enabled": False},
{"type": "Wlan", "enabled": False},]}},
"value": "00:00:00:00:00:01"},
"descr": "Spectacular GNU/Linux 2016 {}".format(uname),
"mgmt-ip": "fe80::200:ff:fe00:1",
+ "mgmt-iface": "3",
"capability": [
{"type": "Bridge", "enabled": False},
{"type": "Wlan", "enabled": False},]}},
"name": [{"value": "ns-2.example.com"}],
"descr": [{"value": "Spectacular GNU/Linux 2016 {}".format(uname)}],
"mgmt-ip": [{"value": "fe80::200:ff:fe00:2"}],
+ "mgmt-iface": [{"value": "2"}],
"capability": [
{"type": "Bridge", "enabled": False},
{"type": "Wlan", "enabled": False},
"name": [{"value": "ns-1.example.com"}],
"descr": [{"value": "Spectacular GNU/Linux 2016 {}".format(uname)}],
"mgmt-ip": [{"value": "fe80::200:ff:fe00:1"}],
+ "mgmt-iface": [{"value": "3"}],
"capability": [
{"type": "Bridge", "enabled": False},
{"type": "Wlan", "enabled": False},
<name label="SysName">ns-2.example.com</name>
<descr label="SysDescr">Spectacular GNU/Linux 2016 {uname}</descr>
<mgmt-ip label="MgmtIP">fe80::200:ff:fe00:2</mgmt-ip>
+ <mgmt-iface label="MgmtIface">2</mgmt-iface>
<capability label="Capability" type="Bridge" enabled="off"/>
<capability label="Capability" type="Router" enabled="{router}"/>
<capability label="Capability" type="Wlan" enabled="off"/>
<name label="SysName">ns-1.example.com</name>
<descr label="SysDescr">Spectacular GNU/Linux 2016 {uname}</descr>
<mgmt-ip label="MgmtIP">fe80::200:ff:fe00:1</mgmt-ip>
+ <mgmt-iface label="MgmtIface">3</mgmt-iface>
<capability label="Capability" type="Bridge" enabled="off"/>
<capability label="Capability" type="Router" enabled="{router}"/>
<capability label="Capability" type="Wlan" enabled="off"/>