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

£¼¢iЋã@s dZddlmZddlmZddlmZddlmZm	Z	ddl
mZddlm
Z
mZmZmZddlmZmZmZmZmZmZGd	d
„d
ƒZeƒe_ej ¡dS)z-
Routing and handling of network interfaces.
é)Úabsolute_import)Ú	plain_str)Úconf)ÚScapy_ExceptionÚwarning)Ú
resolve_iface)ÚatolÚltoaÚitomÚpretty_list)ÚAnyÚDictÚListÚOptionalÚTupleÚUnionc@sveZdZdd„Zdd„Zdd„Zdd„Zddd„Zd
d„Zdd„Z	dd„Z
dd„Zdd„Zd	e
jfdd„Zdd„Zd	S)ÚRoutecCsg|_| ¡dS)N)ÚroutesÚresync)Úself©rú‰/build/wlanpi-profiler-SHjkbd/wlanpi-profiler-1.0.8/debian/wlanpi-profiler/opt/wlanpi-profiler/lib/python3.7/site-packages/scapy/route.pyÚ__init__"szRoute.__init__cCs
i|_dS)N)Úcache)rrrrÚinvalidate_cache'szRoute.invalidate_cachecCs ddlm}| ¡|ƒ|_dS)Nr)Úread_routes)Ú
scapy.archrrr)rrrrrr+szRoute.resyncc	
CsXg}xF|jD]<\}}}}}}t|ƒj}| t|ƒt|ƒ|||t|ƒf¡qWt|dgƒS)N)ZNetworkZNetmaskZGatewayZIfacez	Output IPZMetric)rrÚdescriptionÚappendr	Ústrr)	rZrtlstÚnetÚmskÚgwÚifaceÚaddrÚmetricZif_reprrrrÚ__repr__1s

zRoute.__repr__Néc
Csœddlm}|dk	r |d}}n(|dk	r@| d¡\}}	t|	ƒ}ntdƒ‚|dkrTd}|dkr||rf|}
n|}
| |
¡\}}}n||ƒ}t|ƒt|ƒ||||fS)Nr)Úget_if_addré ú/zDmake_route: Incorrect parameters. You should specify a host or a netz0.0.0.0)rr(ÚsplitÚintrÚrouterr
)
rÚhostr r"Údevr%r(Zthenetr!Zmsk_bZnhopZifaddrÚ_rrrÚ
make_route@s 
zRoute.make_routecOs | ¡|j |j||Ž¡dS)z;Ex:
        add(net="192.168.1.0/24",gw="1.2.3.4")
        N)rrrr1)rÚargsÚkargsrrrÚadd\sz	Route.addcOsN| ¡|j||Ž}y|j |¡}|j|=Wntk
rHtdƒ‚YnXdS)zdelt(host|net, gw|dev)zNo matching route found!N)rr1rÚindexÚ
ValueError)rr2r3r-ÚirrrÚdeltdsz
Route.deltcCs¶| ¡| d¡dgdd…\}}tt|ƒƒ}t|ƒ}||@}xft|jƒD]X\}}	|	\}
}}}
}}||
krnqL|dkrŽ||||
||f|j|<qL|
|||
||f|j|<qLWtj 	¡dS)Nr*Ú32éz0.0.0.0)
rr+r
r,rÚ	enumeraterrZnetcacheÚflush)rÚiffr$Úthe_addrÚ	the_msk_bÚthe_mskÚthe_rawaddrÚthe_netr7r-r r!r"r#r%rrrÚifchangeoszRoute.ifchangecCs>| ¡g}x&|jD]}||dkr&q| |¡qW||_dS)Né)rrr)rr=Z
new_routesÚrtrrrÚifdelszRoute.ifdelcCs\| ¡| d¡dgdd…\}}tt|ƒƒ}t|ƒ}||@}|j ||d||df¡dS)Nr*r9r:z0.0.0.0r')rr+r
r,rrr)rr=r$r>r?r@rArBrrrÚifadd‹szRoute.ifaddcCsz|pd}t|tƒr<yt|ƒ}Wntk
r:tdƒ‚YnX||jkrP|j|S| d¡d dd¡}xJ| d¡}|dkr|P||d…d	 d	¡}|d|…|||d…}qhWt	|ƒ}g}xp|j
D]f\}}}	}
}}|sÜqÆt	|ƒ}
|
|kr| d
dtj
|dff¡||@||@krÆ| |||
||	ff¡qÆW|sP|rDtdƒtj
ddfS|jd
d„d|dd}||j|<|S)aMReturns the IPv4 routes to a host.
        parameters:
         - dst: the IPv4 of the destination host

        returns: (iface, output_ip, gateway_ip)
         - iface: the interface used to connect to the host
         - output_ip: the outgoing IP that will be used
         - gateway_ip: the gateway IP that will be used
        z0.0.0.0z Unknown IP address input (bytes)r*rÚ*Ú0ú-NÚ.lÿÿr'z"No route found (no default route?)cSs|d|dfS)Nrr'r)ÚxrrrÚ<lambda>ÃózRoute.route.<locals>.<lambda>)Úkeyr:)Ú
isinstanceÚbytesrÚUnicodeDecodeErrorÚ	TypeErrorrr+ÚreplaceÚfindrrrrZ
loopback_namerÚsort)rÚdstÚverboseZ_dstÚidxÚmZatol_dstÚpathsÚdr"r7ÚaÚmeZaaÚretrrrr-”sD



 

zRoute.routec
Csng}xV|jD]L\}}}}}}|dkr(qn
|dkr2q||kr<q||d@B}	| t|	ƒ¡qW|sjtd|ƒ|S)Nrlÿÿz(No broadcast address found for iface %s
)rrr	r)
rr=Z
bcast_listr r!r"r#r$r%ZbcastrrrÚget_if_bcastÉs
zRoute.get_if_bcast)NNNNr')Ú__name__Ú
__module__Ú__qualname__rrrr&r1r4r8rCrFrGrÚverbr-r`rrrrr!s 

	5rN)Ú__doc__Ú
__future__rZscapy.compatrZscapy.configrZscapy.errorrrZscapy.interfacesrZscapy.utilsrr	r
rrr
rrrrrr-ZifacesÚreloadrrrrÚ<module>s :