File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -774,18 +774,23 @@ def _get_ips(af_family=socket.AF_UNSPEC):
774774 ifindex = msg .ifa_index
775775 address = None
776776 family = msg .ifa_family
777+ local = None
777778 for attr in msg .data :
778779 if attr .rta_type == 0x01 : # IFA_ADDRESS
779780 address = attr .rta_data
780- break
781- if address is not None :
781+ elif attr .rta_type == 0x02 : # IFA_LOCAL
782+ local = attr .rta_data
783+ # include/uapi/linux/if_addr.h: for point-to-point links, IFA_LOCAL is the local
784+ # interface address and IFA_ADDRESS is the peer address
785+ local_address = local if local is not None else address
786+ if local_address is not None :
782787 data = {
783788 "af_family" : family ,
784789 "index" : ifindex ,
785- "address" : address ,
790+ "address" : local_address ,
786791 }
787792 if family == 10 : # ipv6
788- data ["scope" ] = scapy .utils6 .in6_getscope (address )
793+ data ["scope" ] = scapy .utils6 .in6_getscope (local_address )
789794 ips .setdefault (ifindex , list ()).append (data )
790795 return ips
791796
You can’t perform that action at this time.
0 commit comments