1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

nlmanager: nlpacket: update AttributeMACAddress decode comments

this commit adds some explanation/comments in the decode function of the
AttributeMACAddress class. Some comments are moved around and placed
in the right location.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
Julien Fortin
2018-06-27 21:46:38 +03:00
parent 730834002a
commit 53747c55ab

View File

@ -534,13 +534,16 @@ class AttributeMACAddress(Attribute):
def decode(self, parent_msg, data):
self.decode_length_type(data)
# IFLA_ADDRESS and IFLA_BROADCAST attributes for all interfaces has been a
# 6-byte MAC address. But the GRE interface uses a 4-byte IP address and
# GREv6 uses a 16-byte IPv6 address for this attribute.
try:
# MAC Address
# GRE interface uses a 4-byte IP address for this attribute
if self.length == 8:
self.value = IPv4Address(unpack('>L', self.data[4:])[0])
self.value_int = int(self.value)
self.value_int_str = str(self.value_int)
# GRE interface uses a 4-byte IP address for this attribute
# MAC Address
elif self.length == 10:
(data1, data2) = unpack(self.PACK, self.data[4:])
self.value = mac_int_to_str(data1 << 16 | data2)