diff options
Diffstat (limited to 'psutil/__init__.py')
-rw-r--r-- | psutil/__init__.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/psutil/__init__.py b/psutil/__init__.py index 79b369c9..385b80a4 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -1749,17 +1749,22 @@ def net_if_addrs(): """Return the addresses associated to each NIC (network interface card) installed on the system as a dictionary whose keys are the NIC names and value is a list of namedtuples for each address - assigned to the NIC. Each namedtuple includes 4 fields: + assigned to the NIC. Each namedtuple includes 5 fields: - family - address - netmask - broadcast + - ptp 'family' can be either socket.AF_INET, socket.AF_INET6 or psutil.AF_LINK, which refers to a MAC address. - 'address' is the primary address, 'netmask' and 'broadcast' - may be None. + 'address' is the primary address and it is always set. + 'netmask' and 'broadcast' and 'ptp' may be None. + 'ptp' stands for "point to point" and references the destination + address on a point to point interface (tipically a VPN). + 'broadcast' and 'ptp' are mutually exclusive. + Note: you can have more than one address of the same family associated with each interface. """ @@ -1769,7 +1774,7 @@ def net_if_addrs(): rawlist = _psplatform.net_if_addrs() rawlist.sort(key=lambda x: x[1]) # sort by family ret = collections.defaultdict(list) - for name, fam, addr, mask, broadcast in rawlist: + for name, fam, addr, mask, broadcast, ptp in rawlist: if has_enums: try: fam = socket.AddressFamily(fam) @@ -1782,7 +1787,7 @@ def net_if_addrs(): # We re-set the family here so that repr(family) # will show AF_LINK rather than AF_PACKET fam = _psplatform.AF_LINK - ret[name].append(_common.snic(fam, addr, mask, broadcast)) + ret[name].append(_common.snic(fam, addr, mask, broadcast, ptp)) return dict(ret) |