Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] LLDP Remote Management Address #16

Open
mtannous opened this issue Jun 7, 2016 · 1 comment
Open

[Question] LLDP Remote Management Address #16

mtannous opened this issue Jun 7, 2016 · 1 comment

Comments

@mtannous
Copy link

mtannous commented Jun 7, 2016

I'm using the LLDP handler and manger. I'm getting random/weird characters when I output the address in the lldp_management_address_t. Is there something im doing wrong? Or it is an actual issue? Everything else works fine

def on_lldp_management_address(self, lldp_neighbor , list_mgmt):
print "mgmt address"
print list_mgmt[0].to_string()
print list_mgmt[0].oid()
print list_mgmt[0].address()

Output:
mgmt address
lldp_management_address_t(address_family=1, address='▒▒-', snmp_ifindex=2, oid='')

▒▒-

Show lldp neighbor output:
leaf-51(config-if-Et5,12)#show lldp neighbors ethernet 3 detail
Interface Ethernet3 detected 1 LLDP neighbors:

Neighbor 90e2.ba82.635c/90e2.ba82.635c, age 9 seconds
Discovered 0:13:39 ago; Last changed 0:13:39 ago

  • Chassis ID type: MAC address (4)
    Chassis ID : 90e2.ba82.635c
  • Port ID type: MAC address (3)
    Port ID : 90e2.ba82.635c
  • Time To Live: 120 seconds
  • Port Description: "eth0"
  • System Name: "monorail-micro"
  • System Description: "Ubuntu 14.04 LTS Linux 3.16.0-25-generic Compiling SDK 1.12.3 outputs 1.10 version information (Makefile) #33-Ubuntu SMP Fri Nov 7 01:53:40 UTC 2014 x86_64"
  • System Capabilities : Bridge, WLAN Access Point, Router
    Enabled Capabilities: None
  • Management Address Subtype: IPv4
    Management Address : 172.31.128.45
    Interface Number Subtype : ifIndex (2)
    Interface Number : 2
    OID String :
  • IEEE802.1/IEEE802.3 Link Aggregation
    Link Aggregation Status: Capable, Disabled (0x01)
    Port ID : 0
  • IEEE802.3 MAC/PHY Configuration/Status
    Auto-negotiation : Supported, Enabled
    Other
    Operational MAU Type : 10GBASE-X
@ruferp
Copy link
Contributor

ruferp commented Jun 8, 2016

Depending on the address family (in your case "1" is IPv4), the management address could be binary data, in which case displaying it without precaution could look "funny" (for address family encodings, check http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml).
To get around that, and make the data more visible, just print the "repr" of the data (see example below).

~/t31/src @dhcp-2018-38.sjc+rtr1% /usr/lib/python2.7/site-packages/illdp.py
Welcome to 'interactive lldp'
Use h() for help, ex() for examples.
tab-completion is enabled; tab-tab (or ?) adds the doc string
... 
... et1rs=m.lldp_remote_system_iter(eossdk.IntfId("Ethernet1")).next()
... et1nei=eossdk.LldpNeighbor(eossdk.IntfId("Ethernet1"),et1rs)
... mana=m.management_address(et1nei)[0]
...
... mana.to_string()
"lldp_management_address_t(address_family=6, **address='\x00\x00\x01\x02\x00\x00'**, snmp_ifindex=0, oid='')"
... print mana.to_string()
lldp_management_address_t(address_family=6, **address=''**, snmp_ifindex=0, oid='')
... print **repr**(mana.to_string())
"lldp_management_address_t(address_family=6, **address='\x00\x00\x01\x02\x00\x00'**, snmp_ifindex=0, oid='')"
... print repr(mana.address())
'\x00\x00\x01\x02\x00\x00'
...

Unfortunately, the management address type, unlike the other complex data types of lldp, do not have a pretty printer that prints the string representation of the most common encodings. We should definitely add that. Here is an example of such a pretty printer in action (using an lldp neighbor identified by mac address, in which case we print 11:22:33:44:55:66 instead of \x11\x22....) and also uses a more compact notation

... et1nei.to_string()
"lldp_neighbor_t(intf=Ethernet1, remote_system=lldp_remote_system_t(chassis=lldp_chassis_id_t(encoding=LLDP_CHASSIS_MAC_ADDR, value='\x00\x00\x01\x02\x00\x00'), port=lldp_intf_id_t(encoding=LLDP_INTF_NAME, value='Ethernet1')))"
... et1nei.**repr()**
'Ethernet1;MAC:0:0:1:2:0:0;Ethernet1'
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants