Implement ipNetToMediaPhysAddress (ARP table)#19
Implement ipNetToMediaPhysAddress (ARP table)#19qiluo-msft merged 6 commits intosonic-net:masterfrom
Conversation
src/ax_interface/encodings.py
Outdated
|
|
||
| def __str__(self): | ||
| return self.string.decode('ascii') | ||
| return self.string.decode('utf-8') |
There was a problem hiding this comment.
Why do we need this? #Resolved
There was a problem hiding this comment.
src/ax_interface/util.py
Outdated
| """ | ||
| return tuple(int(h, 16) for h in mac.split(":")) | ||
|
|
||
| def ip2tuple(ip): |
There was a problem hiding this comment.
ipv4 only? probably it's better to use ip2tuple_v4 #Resolved
| OIDs are 1-based, interfaces are 0-based, return the 1-based index | ||
| Ethernet N = N + 1 | ||
| """ | ||
| match = re.match(SONIC_ETHERNET_RE_PATTERN, if_name) |
There was a problem hiding this comment.
Probably it's better to compile this regexp in init?
Also is it possible to extract this value from string using something like
if_name.replace('Ethernet', '') ? #Resolved
There was a problem hiding this comment.
Let's keep it for readability and optimize if we find it on critical path. re library has the opportunity to hide the optimization without users changing code.
In reply to: 108313222 [](ancestors = 108313222)
| if if_index is None: continue | ||
|
|
||
| mactuple = mac_decimals(mac) | ||
| machex = ''.join([chr(b) for b in mactuple]) |
There was a problem hiding this comment.
machex = ''.join(chr(b) for b in mactuple) should work for you #Resolved
| mactuple = mac_decimals(mac) | ||
| machex = ''.join(chr(b) for b in mactuple) | ||
| # if MAC is all zero | ||
| #if not any(mac): continue |
There was a problem hiding this comment.
Should we remove this line? What to do if the mac is 0? #Resolved
There was a problem hiding this comment.
The correct behavior of incomplete ARP entry (an IP without MAC) is not clear in the protocol. ref: http://cric.grenoble.cnrs.fr/Administrateurs/Outils/MIBS/?oid=1.3.6.1.2.1.4.22.1.2
Just keep the code here for further refinement, if needed.
In reply to: 108499363 [](ancestors = 108499363)
| self.arp_dest_map[subid] = machex | ||
| self.arp_dest_list.append(subid) | ||
|
|
||
| # print(subid, dev, mac, ip) |
There was a problem hiding this comment.
Should we remove it? #Resolved
There was a problem hiding this comment.
* Implement ipNetToMediaPhysAddress (ARP table) * Fix: use latin-1 as OctetString encoding * Add test data, mock function * Rename ip2tuple_v4 function * Refine list comprehension * (comment)
No description provided.