Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
B

áÓ%ÂñވªãU@s"dZddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZmZmZddlmZddlmZmZdd	lmZmZdd
lmZmZddlmZm Z ddl!m"Z"m#Z#dd
lm$Z$m%Z%m&Z&m'Z'm(Z(m)Z)dd„Z*dd„Z+dd„Z,dÂdd„Z-dd„Z.dd„Z/dd„Z0dÃdd„Z1dd „Z2d!d"„Z3d#d$„Z4dÄd%d&„Z5d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{gUZ6d|d}„Z7d~d„Z8d€d„Z9d‚e_:dƒe_;d„d…„Z<d†d‡„Z=dˆd‰„Z>dŠd‹„Z?dÅdŒd„Z@dŽd„ZAdd‘„ZBd’d“„ZCd”d•„ZDd–d—„ZEd˜d™„ZFdšd›„ZGdœd„ZHdždŸ„ZId d¡„ZJd¢d£„ZKd¤d¥„ZLd¦d§„ZMd¨d©„ZNdªd«„ZOd¬d­„ZPd®d¯„ZQd°d±„ZRd²d³„ZSd´dµ„ZTd¶d·„ZUd¸d¹„ZVdºd»„ZWd¼d½„ZXd¾d¿„ZYGdÀdDdÁe	ƒZZdS)Æz
Utility functions for IPv6.
é)Úabsolute_importN)Úconf)ÚNet)ÚIPV6_ADDR_GLOBALÚIPV6_ADDR_LINKLOCALÚIPV6_ADDR_SITELOCALÚIPV6_ADDR_LOOPBACKÚIPV6_ADDR_UNICASTÚIPV6_ADDR_MULTICASTÚIPV6_ADDR_6TO4ÚIPV6_ADDR_UNSPECIFIED)Ústrxor)ÚorbÚchb)Ú	inet_ptonÚ	inet_ntop)ÚRandMACÚRandBin)ÚwarningÚScapy_Exception)ÚreduceÚ
cmp_to_key)ÚIteratorÚListÚOptionalÚTupleÚUnionÚcastcCsdd„}tgƒ}t|ƒs t|ƒr0dd„|Dƒ}nÀt|ƒrHdd„|Dƒ}n¨t|ƒr`dd„|Dƒ}nt|ƒrÒt|ƒrŠdd„dd	tjfgDƒ}qðt	|ƒr¢d
d„|Dƒ}qðt
|ƒrºdd„|Dƒ}qðt|ƒrðdd„|Dƒ}n|d
krð|dkrðdd„|Dƒ}dd„|Dƒ}|jt
|ƒd|S)aì
    Given all addresses assigned to a specific interface ('laddr' parameter),
    this function returns the "candidate set" associated with 'addr/plen'.

    Basically, the function filters all interface addresses to keep only those
    that have the same scope as provided prefix.

    This is on this list of addresses that the source selection mechanism
    will then be performed to select the best source address associated
    with some specific destination that uses this prefix.
    cSsNd}t|ƒrd}d}t|ƒr d}||}|dks8|dkr<|St|ƒsHdS|S)Nrééÿÿÿÿ)Úin6_isgladdrÚin6_isaddr6to4)ÚxÚyZx_globalZy_globalÚres©r%ú‹/build/wlanpi-profiler-7At3M6/wlanpi-profiler-1.0.10/debian/wlanpi-profiler/opt/wlanpi-profiler/lib/python3.7/site-packages/scapy/utils6.pyÚ	cset_sort8sz1construct_source_candidate_set.<locals>.cset_sortcss|]}|dtkr|VqdS)rN)r)Ú.0r"r%r%r&ú	<genexpr>Jsz1construct_source_candidate_set.<locals>.<genexpr>css|]}|dtkr|VqdS)rN)r)r(r"r%r%r&r)Lscss|]}|dtkr|VqdS)rN)r)r(r"r%r%r&r)Nscss|]
}|VqdS)Nr%)r(r"r%r%r&r)Qsz::1écss|]}|dtkr|VqdS)rN)r)r(r"r%r%r&r)Sscss|]}|dtkr|VqdS)rN)r)r(r"r%r%r&r)Uscss|]}|dtkr|VqdS)rN)r)r(r"r%r%r&r)Wsz::rcss|]}|dtkr|VqdS)rN)r)r(r"r%r%r&r)YscSsg|]}|d‘qS)rr%)r(r"r%r%r&ú
<listcomp>Zsz2construct_source_candidate_set.<locals>.<listcomp>)Úkey)Úiterr Úin6_isuladdrÚin6_islladdrÚin6_issladdrÚin6_ismaddrÚ
in6_ismnladdrrZ
loopback_nameÚ
in6_ismgladdrÚ
in6_ismlladdrÚ
in6_ismsladdrÚsortr)ÚaddrÚplenÚladdrr'ZcsetÚaddrsr%r%r&Úconstruct_source_candidate_set's,r;cs8dd„‰‡‡fdd„}|sdS|jt|ƒdd|dS)	a
    This function implement a limited version of source address selection
    algorithm defined in section 5 of RFC 3484. The format is very different
    from that described in the document because it operates on a set
    of candidate source address for some specific route.
    cSshtdtdtdtdi}t|ƒ}|dkr(t}t|ƒ}|dkr<t}||}||}||krXdS||krddSdS)zd
        Given two addresses, returns -1, 0 or 1 based on comparison of
        their scope
        ééérrr)rrrrÚin6_getscope)ÚaÚbZscope_mapperÚsaZsbr%r%r&Ú	scope_cmpis"z5get_source_addr_from_candidate_set.<locals>.scope_cmpcs|ˆkrdS|ˆkrdSˆ||ƒ}|dkrBˆ|ˆƒdkr<dSdSn|dkr`ˆ|ˆƒdkr\dSdSt|ˆƒ}t|ˆƒ}||kr€dS||krŒdSdS)z•
        The function implements a limited version of the rules from Source
        Address selection algorithm defined section of RFC 3484.
        rrr)Úin6_get_common_plen)Zsource_aZsource_bÚtmpZtmp1Ztmp2)ÚdstrCr%r&Úrfc3484_cmpƒs(
	

z7get_source_addr_from_candidate_set.<locals>.rfc3484_cmpÚT)r,Úreverser)r6r)rFZ
candidate_setrGr%)rFrCr&Ú"get_source_addr_from_candidate_set`s	)rJcCsðttj|ƒ}ttj|ƒ}d}t|dƒd@dkrRttB}|dd…dkrì|tO}nšt|dƒdkr˜|d}|dkr|tt	B}qì|d	krŽtt	B}qìtt	B}nTt|dƒd
krÈt
|ddƒd@d
krÈttB}n$|dkrÖt}n|dkrät}nttB}|S)Nréàé r>s éÿr=Ú2Úeéþr*ééz::1z::)
rÚsocketÚAF_INET6rrr	rrrr
Úintrr)r7ZnaddrZpaddrZaddrTypeZ	addrScoper%r%r&Úin6_getAddrType¸s,



&
rVcCsÔt|ƒdkrtdƒ‚d | d¡¡}t|ƒdkr8tdƒ‚t|dd…dƒ}|d	ksb|dkst|d
kstd
ddg|d@}|d9}d|d@|B}||dd
…d|d
d…d|dd…d|dd…}| ¡S)a<
    Compute the interface ID in modified EUI-64 format associated
    to the Ethernet address provided as input.
    value taken by U/L bit in the interface identifier is basically
    the reversed value of that in given MAC address it can be forced
    to a specific value by using optional 'ulbit' parameter.
    ézInvalid MACrHú:rQrr>r*Nrz%.02xéýr<ézFF:FErR)ÚlenÚ
ValueErrorÚjoinÚsplitrUÚupper)ÚmacÚulbitÚmÚfirstZfirst_bÚeui64r%r%r&Úin6_mactoifaceidÙs	@recCsÄyttjd|ƒdd…}Wntk
r0dSX|dd…dkrFdSt d|dd	…¡d
}dd	dd
g|d@}t d|d
@|B¡}||d	d…}|dd…}dd„t||ƒDƒ}d |¡S)zµ
    Extract the mac address from provided iface ID. Iface ID is provided
    in printable format ("XXXX:XXFF:FEXX:XXXX", eventually compressed). None
    is returned on error.
    z::rRr*Nr=ésÿþÚBrrr>ú-rYcSsg|]}dt|ƒ‘qS)z%.02x)r)r(r"r%r%r&r+sz$in6_ifaceidtomac.<locals>.<listcomp>rX)	rrSrTÚ	ExceptionÚstructÚunpackÚpackÚlistr])Z	ifaceid_sÚifaceidrcraZouiÚendZ	mac_bytesr%r%r&Úin6_ifaceidtomacðsrpcCs:ttjdƒ}t|ttj|ƒƒ}ttj|ƒdd…}t|ƒS)zW
    Extract the mac address from provided address. None is returned
    on error.
    z::ffff:ffff:ffff:ffffr>N)rrSrTÚin6_andrrp)r7Úmaskr"rnr%r%r&Ú
in6_addrtomacsrscCsHt|ƒ}|dkstjsdStj |¡}t|ƒdkrD| d¡dkrDd}|S)ad
    Extract the MAC address from a modified EUI-64 constructed IPv6
    address provided and use the IANA oui.txt file to get the vendor.
    The database used for the conversion is the one loaded by Scapy
    from a Wireshark installation if discovered in a well-known
    location. None is returned on error, "UNKNOWN" if the vendor is
    unknown.
    NrWrXrfÚUNKNOWN)rsrZmanufdbZ
_get_manufr[Úcount)r7r`r$r%r%r&Úin6_addrtovendors
rvr>cCsR|dkrdSyt|ƒsdSttj|ƒ}Wntk
rDtdƒdSX|dd…}|dkr`d}n²d}t|ttfƒrèyVt|tƒršt	|ƒdkršt
|dƒd@}n,t|tƒrÂt	|ƒd	krÂt d
|¡d}nt
‚Wntk
rätdƒdSXnt|t
ƒrú|}ntdƒdSt d
|¡}t d
dd|B@¡}d}d}	d||	|||}
ttj|
ƒS)a²
    Generate a Link-Scoped Multicast Address as described in RFC 4489.
    Returned value is in printable notation.

    'addr' parameter specifies the link-local address to use for generating
    Link-scoped multicast address IID.

    By default, the function returns a ::/96 prefix (aka last 32 bits of
    returned address are null). If a group id is provided through 'grpid'
    parameter, last 32 bits of the address are set to that value (accepted
    formats : b'4Vx' or '12345678' or 0x12345678 or 305419896).

    By default, generated address scope is Link-Local (2). That value can
    be modified by passing a specific 'scope' value as an argument of the
    function. RFC 4489 only authorizes scope values <= 2. Enforcement
    is performed by the function (None will be returned).

    If no link-local address can be used to generate the Link-Scoped IPv6
    Multicast address, or if another error occurs, None is returned.
    )rrr>Nz8in6_getLinkScopedMcastPrefix(): Invalid address providedrRsór*lÿÿr<z!Irz9in6_getLinkScopedMcastPrefix(): Invalid group id providedrgrMé0óÿó)r/rrSrTrirÚ
isinstanceÚstrÚbytesr[rUrjrkr\rlr)r7ZgrpidÚscopeÚbaddrZiidZb_grpidZi_grpidZflgscoper8r$r@r%r%r&Úin6_getLinkScopedMcastAddr-sFr€cCs:y ttj|ƒ}ttjd|dƒStk
r4dSXdS)z­
    Returns the /48 6to4 prefix associated with provided IPv4 address
    On error, None is returned. No check is performed on public/private
    status of the address
    s s
N)rrSÚAF_INETrrTri)r7rr%r%r&Úin6_get6to4Prefixts
r‚cCsNyttj|ƒ}Wntk
r$dSX|dd…dkr:dSttj|dd…ƒS)z~
    Extract IPv4 address embedded in 6to4 address. Passed address must be
    a 6to4 address. None is returned on error.
    Nr>s rZ)rrSrTrirr)r7rr%r%r&Úin6_6to4ExtractAddr‚srƒcCs†t ¡}t|ƒ}t||dƒ}t d||¡}tƒ}ttjdt|ƒƒdd…}ddl	}| 
||¡ ¡dd…}ttjd|d	ƒS)
zž
    Returns a pseudo-randomly generated Local Unique prefix. Function
    follows recommendation of Section 3.2.2 of RFC 4193 for prefix
    generation.
    lz!IIz::rRNrrfóýs
)
ÚtimerUrjrlrrrSrTreÚhashlibÚsha1Údigestr)ZtodÚiÚjZbtodr`rdr†Zglobalidr%r%r&Úin6_getLocalUniquePrefix‘sr‹c	CsÖd}|dkrttdƒƒ}nttjd|ƒdd…}ttjd|ƒdd…|}ddl}| |¡ ¡}|dd…|dd…}}tt	|dƒd@ƒ|dd…}t
tjd|ƒd	d…}t
tjd|ƒd	d…}||fS)
ap
    Implements the interface ID generation algorithm described in RFC 3041.
    The function takes the Modified EUI-64 interface identifier generated
    as described in RFC 4291 and an optional previous history value (the
    first element of the output of this function). If no previous interface
    identifier is provided, a random one is generated. The function returns
    a tuple containing the randomized interface identifier and the history
    value (for possible future use). Input and output values are provided in
    a "printable" format as depicted below.

    ex::
        >>> in6_getRandomizedIfaceId('20b:93ff:feeb:2d3')
        ('4c61:76ff:f46a:a5f3', 'd006:d540:db11:b092')
        >>> in6_getRandomizedIfaceId('20b:93ff:feeb:2d3',
                                     previous='d006:d540:db11:b092')
        ('fe97:46fe:9871:bd38', 'eeed:d79c:2e3f:62e')
    rwNrRz::réûÿÿÿrsÿÿÿÿÿÿÿÿé)r}rrrSrTr†Úmd5rˆrrr)	rnÚpreviousÚsZ
b_previousr†Ús1Ús2Zbs1Zbs2r%r%r&Úin6_getRandomizedIfaceId¯s r“Ú0Ú1rNÚ3Ú4Ú5Ú6Ú7Ú8Ú9ÚArgÚCÚDÚEÚFÚGÚHÚIÚJÚKÚLÚMÚNÚOÚPÚQÚRÚSÚTÚUÚVÚWÚXÚYÚZr@rAÚcÚdrOÚfÚgÚhr‰rŠÚkÚlrbÚnÚoÚpÚqÚrrÚtÚuÚvÚwr"r#Úzú!ú#ú$ú%ú&ú(ú)Ú*ú+rhú;ú<ú=ú>ú?ú@ú^Ú_ú`Ú{ú|Ú}ú~cCsžt|ƒdks$tdd„dd„|Dƒƒs(dSd}x"|D]}t |¡}d||}q2Wg}x.td	ƒD]"}| t d
|d¡¡|d}q^W| ¡t	t
jd |¡ƒS)
zŽ
    Convert an IPv6 address in Compact Representation Notation
    (RFC 1924) to printable representation ;-)
    Returns None on error.
    rcSs|o|S)Nr%)r"r#r%r%r&Ú<lambda>árwzin6_ctop.<locals>.<lambda>cSsg|]}|tk‘qSr%)Ú_rfc1924map)r(r"r%r%r&r+âszin6_ctop.<locals>.<listcomp>NréUr<z!Ilrw)
r[rrÞÚindexÚrangeÚappendrjrlrIrrSrTr])r7r‰r¶rŠr$r%r%r&Úin6_ctopÚs

rãcCs¢yt dttj|ƒ¡}Wntk
r,dSXd}dddddg}x$td	ƒD]}|||||7}qLWg}x"|rŽ| t|d
¡|d
}qnW| 	¡d 
|¡S)z„
    Converts an IPv6 address in printable representation to RFC
    1924 Compact Representation ;-)
    Returns None on error.
    z!IIIINrr>é`llrr<rßrH)rjrkrrSrTrirárârÞrIr])r7r·Úremrbr‰r$r%r%r&Úin6_ptocðsræcCsttj|ƒ}|dd…dkS)zk
    Return True if provided address (in printable format) is a 6to4
    address (being in 2002::/16).
    Nr>s )rrSrT)r"Úbxr%r%r&r!sr!z2001::iØ
cCs2ttj|ƒdd…}ttjtjƒdd…}||kS)zÝ
    Return True if provided address is a Teredo, meaning it is under
    the /32 conf.teredoPrefix prefix value (by default, 2001::).
    Otherwise, False is returned. Address must be passed in printable
    format.
    rr<)rrSrTrÚteredoPrefix)r"Zourrèr%r%r&Úin6_isaddrTeredosrécCs|ttj|ƒ}ttj|dd…ƒ}t d|dd…¡d}t dt|dd…dƒ¡d}ttjt|dd…d	ƒƒ}||||fS)
a	
    Extract information from a Teredo address. Return value is
    a 4-tuple made of IPv4 address of Teredo server, flag value (int),
    mapped address (non obfuscated) and mapped port (non obfuscated).
    No specific checks are performed on passed address.
    r<rRz!Hé
rrQsÿÿr*sÿÿÿÿ)rrSrTrrrjrkr
)r"r7ÚserverÚflagZ
mappedportZ
mappedaddrr%r%r&ÚteredoAddrExtractInfo"srícCs&ttjdƒ}tttj|ƒ|ƒ}||kS)zë
    Return True if provided address has an interface identifier part
    created in modified EUI-64 format (meaning it matches ``*::*:*ff:fe*:*``).
    Otherwise, False is returned. Address must be passed in printable
    format.
    z::ff:fe00:0)rrSrTrq)r"rdrçr%r%r&Úin6_iseui642srîcCsFt|ƒr6d}ttj|ƒ}ttj|ƒ}t||ƒ}||kStdƒdSdS)Nz::fdff:ffff:ffff:ff80z in6_isanycast(): TODO not EUI-64F)rîrrSrTrqr)r"rZpacked_xZpacked_sZx_and_sr%r%r&Ú
in6_isanycast?s
rïcCsZt d|¡}t d|¡}dd„dd„dd„g}t||t|ƒ||ƒ}d dd„|Dƒ¡S)	NZ4IcSs||BS)Nr%)r"r#r%r%r&rÝVrwz_in6_bitops.<locals>.<lambda>cSs||@S)Nr%)r"r#r%r%r&rÝWrwcSs||AS)Nr%)r"r#r%r%r&rÝXrwrwcss|]}t d|¡VqdS)r¤N)rjrl)r(r"r%r%r&r)[sz_in6_bitops.<locals>.<genexpr>)rjrkÚmapr[r])Zxa1Zxa2ÚoperatorÚa1Úa2ZfopÚretr%r%r&Ú_in6_bitopsRs
rõcCst||dƒS)z 
    Provides a bit to bit OR of provided addresses. They must be
    passed in network format. Return value is also an IPv6 address
    in network format.
    r)rõ)ròrór%r%r&Úin6_or^sröcCst||dƒS)z¡
    Provides a bit to bit AND of provided addresses. They must be
    passed in network format. Return value is also an IPv6 address
    in network format.
    r)rõ)ròrór%r%r&rqhsrqcCst||dƒS)z¡
    Provides a bit to bit XOR of provided addresses. They must be
    passed in network format. Return value is also an IPv6 address
    in network format.
    r>)rõ)ròrór%r%r&Úin6_xorrsr÷cCsr|dks|dkrtd|ƒ‚g}x<tddƒD].}| tddddtd|ƒƒ¡|d8}q,Wd d	d
„|Dƒ¡S)uª
    Return the mask (bitstring) associated with provided length
    value. For instance if function is called on 48, return value is
    b'ÿÿÿÿÿÿ'.

    é€rz<value provided to in6_cidr2mask outside [0, 128] domain (%d)r<lr>rLrwcss|]}t d|¡VqdS)z!IN)rjrl)r(r"r%r%r&r)Œsz in6_cidr2mask.<locals>.<genexpr>)rrárâÚmaxÚminr])rbrÂr‰r%r%r&Ú
in6_cidr2mask|s"rûcCs(t|ttjdƒƒ}tttjdƒ|ƒ}|S)z´
    Return link-local solicited-node multicast address for given
    address. Passed address must be provided in network format.
    Returned value is also in network format.
    z	::ff:ffffzff02::1:ff00:0)rqrrSrTrö)r@rÁr%r%r&Úin6_getnsmasrücCs4t d|¡dd…}d}|d dd„|Dƒ¡7}|S)z
    Return the multicast mac address associated with provided
    IPv6 address. Passed address must be in network format.
    Ú16BéüÿÿÿNz33:33:rXcss|]}d|VqdS)z%.2xNr%)r(r"r%r%r&r)¥szin6_getnsmac.<locals>.<genexpr>)rjrkr])r@Úbar`r%r%r&Úin6_getnsmacœsrcCs4tttj|ƒtdƒƒ}t|ttjdƒƒ}ttj|ƒS)z[
    Return the anycast address associated with all home agents on a given
    subnet.
    é@z::fdff:ffff:ffff:fffe)rqrrSrTrûrör)ÚprefixrÁr%r%r&Ú	in6_getha©srcCsttjttj|ƒƒS)z—
    Normalizes IPv6 addresses provided in printable format, returning the
    same address in printable format. (2001:0db8:0:0::1 -> 2001:db8::1)
    )rrSrTr)r|r%r%r&Úin6_ptop´srcCs.ttj|ƒ}t|ƒ}ttj|ƒ}|t||ƒkS)zK
    Returns True when 'addr' belongs to prefix/plen. False otherwise.
    )rrSrTrûrq)r7rr8ÚtempZprefZzeror%r%r&Úin6_isincluded½srcCstdttj|ƒƒ}d}||kS)z¤
    Return True if provided address is a link-local solicited node
    multicast address, i.e. belongs to ff02::1:ff00:0/104. False is
    returned otherwise.
    sÿÿÿÿÿÿÿÿÿÿÿÿÿsÿÿ)rqrrSrT)r|rZtemp2r%r%r&Úin6_isllsnmaddrÈsrcCst|ddƒS)z¢
    Returns True if provided address in printable format belongs to
    2001:db8::/32 address space reserved for documentation (as defined
    in RFC 3849).
    z
2001:db8::rL)r)r|r%r%r&Ú
in6_isdocaddrÔsrcCst|ddƒS)z†
    Returns True if provided address in printable format belongs to
    _allocated_ link-local unicast address space (fe80::/10)
    zfe80::rê)r)r|r%r%r&r/Þsr/cCst|ddƒS)z÷
    Returns True if provided address in printable format belongs to
    _allocated_ site-local address space (fec0::/10). This prefix has
    been deprecated, address being now reserved by IANA. Function
    will remain for historic reasons.
    zfec0::rê)r)r|r%r%r&r0çsr0cCst|ddƒS)zt
    Returns True if provided address in printable format belongs to
    Unique local address space (fc00::/7).
    zfc00::é)r)r|r%r%r&r.òsr.cCst|ddƒS)zí
    Returns True if provided address in printable format belongs to
    _allocated_ global address space (2000::/3). Please note that,
    Unique Local addresses (FC00::/7) are not part of global address
    space, and won't match.
    z2000::r=)r)r|r%r%r&r sr cCst|ddƒS)z{
    Returns True if provided address in printable format belongs to
    allocated Multicast address space (ff00::/8).
    zff00::rR)r)r|r%r%r&r1sr1cCst|ddƒS)zq
    Returns True if address belongs to node-local multicast address
    space (ff01::/16) as defined in RFC
    zff01::r*)r)r|r%r%r&r2sr2cCst|ddƒS)z\
    Returns True if address belongs to global multicast address
    space (ff0e::/16).
    zff0e::r*)r)r|r%r%r&r3sr3cCst|ddƒS)z_
    Returns True if address belongs to link-local multicast address
    space (ff02::/16)
    zff02::r*)r)r|r%r%r&r4&sr4cCst|ddƒS)z¹
    Returns True if address belongs to site-local multicast address
    space (ff05::/16). Site local address space has been deprecated.
    Function remains for historic reasons.
    zff05::r*)r)r|r%r%r&r5/sr5cCsttjdƒttj|ƒkS)z^
    Returns True if address is the link-local all-nodes multicast
    address (ff02::1).
    zff02::1)rrSrT)r|r%r%r&Úin6_isaddrllallnodes9s
r
cCsttjdƒttj|ƒkS)z`
    Returns True if address is the link-local all-servers multicast
    address (ff02::2).
    zff02::2)rrSrT)r|r%r%r&Úin6_isaddrllallserversCs
rcCsŽt|ƒst|ƒrt}ntt|ƒr$t}nft|ƒr2t}nXt|ƒrxt|ƒrHt}qŠt	|ƒrVt}qŠt
|ƒrdt}qŠt|ƒrrt}qŠd}n|dkr†t}nd}|S)z+
    Returns the scope of the address.
    rz::1)
r r.rr/rr0rr1r3r4r5r2r)r7r~r%r%r&r?Ms(r?cCsddd„}ttj|ƒ}ttj|ƒ}x>tdƒD]2}|t||ƒt||ƒƒ}|dkr*d||Sq*WdS)z@
    Return common prefix length of IPv6 addresses a and b.
    cSs2x,tdƒD] }d|?}||@||@kr
|Sq
WdS)NrRrø)rá)Zbyte1Zbyte2r‰Zcur_maskr%r%r&Ú
matching_bitsos
z*in6_get_common_plen.<locals>.matching_bitsr*rRrø)rrSrTrár)r@rArZtmpAZtmpBr‰Zmbitsr%r%r&rDjsrDcCs*yttj|ƒdStk
r$dSXdS)zPReturn True if 'address' is a valid IPv6 address string, False
       otherwise.TFN)rrSrTri)Úaddressr%r%r&Úin6_isvalid€s
rc@s6eZdZdZdZejZdZe	dd„ƒZ
edd„ƒZdS)ÚNet6z6Network object from an IP address or hostname and maskrøcCs0t dttj| |¡ƒ¡\}}tt|d>|ƒS)Nz!QQr)rjrkrrSrTZ	name2addrrrU)Úclsr7Zval1Zval2r%r%r&Úip2int’szNet6.ip2intcCsttjt d|d?|d@¡ƒS)Nz!QQrlÿÿÿÿ)rrSrTrjrl)Úvalr%r%r&Úint2ipšszNet6.int2ipN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnamerSrTÚfamilyZmax_maskÚclassmethodrÚstaticmethodrr%r%r%r&rŒsr)N)Nr>)N)r)[rÚ
__future__rrSrjr…Zscapy.configrZscapy.base_classesrZ
scapy.datarrrrr	r
rrZscapy.utilsr
Zscapy.compatrrZscapy.pton_ntoprrZscapy.volatilerrZscapy.errorrrÚ	functoolsrrrrrrrrr;rJrVrerprsrvr€r‚rƒr‹r“rÞrãrær!rèZteredoServerPortrérírîrïrõrörqr÷rûrürrrrrrr/r0r.r r1r2r3r4r5r
rr?rDrrr%r%r%r&Ú<module>sˆ( 
9X!

G
#