Ϫf% UdZddlZddlZddlmZmZmZmZmZm Z m Z m Z m Z m Z mZmZddlmZddlmZmZmZddlmZmZmZddlmZeedxsd Zej8j;d sej8d k(rd e fd e fgZeeeefe d<nd e fgZeeeefe d<GddeZ!GddeZ"GddeZ#GddeZ$GddeZ%GddeZ&ee&Z'de'fdefde fdee#fdee#fd ee#fd!e fge&_(ejRZ)ee'ge)_*ee)_+ejXZ,e'ge,_*d"Z-d#Z.d$Z/y)%z> POSIX implementation of local network interface enumeration. N) CDLLPOINTER Structurec_char_pc_intc_ubytec_uint8c_uint32c_ushortc_void_pcastpointer) find_library)AF_INETAF_INET6 inet_ntop)AnyListTuple) nativeStringcfreebsddarwinsin_len sin_family_sockaddrCommonceZdZdedzfgZy)in_addrN__name__ __module__ __qualname__r_fields_D/usr/lib/python3/dist-packages/twisted/internet/test/_posixifaces.pyrr,s GaK Hr'rceZdZdedzfgZy)in6_addrrNr!r&r'r(r*r*2s GbL!Hr'r*ceZdZedefgzZy)sockaddrsin_portN)r"r#r$rr r%r&r'r(r-r-8s X"Hr'r-c"eZdZedefdefgzZy) sockaddr_inr.sin_addrN)r"r#r$rr rr%r&r'r(r0r0>s! X W"Hr'r0c(eZdZedefdefdefgzZy) sockaddr_in6r. sin_flowinfor1N)r"r#r$rr r r*r%r&r'r(r3r3Es) X " X"Hr'r3c eZdZy)ifaddrsN)r"r#r$r&r'r(r6r6Msr'r6ifa_nextifa_name ifa_flagsifa_addr ifa_netmask ifa_dstaddrifa_datacptjjdr|dddk(r|dddz|ddzS|S)a On FreeBSD, kill the embedded interface indices in link-local scoped addresses. @param family: The address family of the packed address - one of the I{socket.AF_*} constants. @param packed: The packed representation of the address (ie, the bytes of a I{in_addr} field). @type packed: L{bytes} @return: The packed address with any FreeBSD-specific extra bits cleared. @rtype: L{bytes} @see: U{https://twistedmatrix.com/trac/ticket/6843} @see: U{http://www.freebsd.org/doc/en/books/developers-handbook/ipv6.html#ipv6-scope-index} @note: Indications are that the need for this will be gone in FreeBSD >=10. rNssr )sysplatform startswith)familypackeds r(_maybeCleanupScopeIndexrEdsD( ||y)fRajK.GbqzK'&*44 Mr'ct}tt|dkr tg} |r|djr|djdj }|t k(r't|djtt}n2|tk(r't|djtt}nd}|r\t|djjdd}t||}|j!|dj"|t%||f|dj&}|rt)||S#t)|wxYw)z Call C{getifaddrs(3)} and return a list of tuples of interface name, address family, and human-readable address representing its results. rN) ifaddrs_p getifaddrsrOSErrorr:rrr rr0rr3bytesr1rrEappendr8rr7 freeifaddrs)r6resultsrCaddrrDs r( _interfacesrO}s) kG''"#a'iGqz"" ,,Q/::W$ 3 3W[5IJDx' 3 3W\5JKDD"47#3#3#;#;A#>?F4VVDFNN ,,fi6OPaj))G#& G N Gs C>D;; Ecg}tD]X\}}}t|}t|}|tjk(s1|j dsC|j |d|Z|S)z Return a list of strings in colon-hex format representing all the link local IPv6 addresses available on the system, as reported by I{getifaddrs(3)}. zfe80:%)rOrsocketrrBrK)retList interfacerCaddresss r(posixGetLinkLocalIPv6AddressesrVsl G&1m5" 67 + w' V__ $););G)D NNgYa {3 4 5 Nr')0__doc__rRr@ctypesrrrrrrr r r r r r ctypes.utilrrrrtypingrrrtwisted.python.compatrlibcrArBrstr__annotations__rr*r-r0r3r6rGr%rHargtypesrestyperLrErOrVr&r'r(ras      %//##. L  #$<<9%)A G w.OT%S/* x .OT%S/* i y y )9 i  G  ("#GH%&GH%&__ y)*   !{ 2B r'