+
    Dfj              
         a  RQ tn0 t R t^ RIt^ RIt^ RIt^ RIHt ^ RIHtH	t	H
t
HtHtHtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHtHt ] ^ k  ]! R	4       Rt^ RIHtHt ^ RIH t  ^ RI!H"t" ^ RI#H$t$H%t%H&t& ^ RI'H(t(H)t)H*t* ^ RI+H,t, ^ RI-H.t. ^ RI/H0t0 ^ RI1H2t2 ^ RI3H4t4 ^ RI5H6t6 ^ RI7H8t8H9t9H:t: ^ RIH;t; ^ RI<H=t=H>t> ]?t@]tA]'       g(   ^ RIBHCtCHDtDHEtEHFtFHGtGHHtHHItIHJtJ ^ RIKHLtLHMtMHNtNHOtOHPtPHAtAH@t@ M]tQ]! ]&4       ! R R4      4       tR] ! ]&]R! 4       4        ! R R],]R4      tS ! R R 4      tT ! R! R"4      tU ! R# R$]>4      tV ! R% R&4      tW ! R' R(4      tX ! R) R*]X]W]>4      tY]Z! ]YR+]U! ]YP                  ]YP                  R,R-7      4        ! R. R/]X]W]>4      t]]Z! ]]R+]U! ]YP                  ]YP                  R0R-7      4        ! R1 R2]X]W]>4      t^]Z! ]^R+]T! ]^P                  ]^P                  4      4       ]! ]A4       ! R3 R4]@4      4       t_ ! R5 R64      t` ! R7 R8]`]W]>4      ta ! R9 R:]`]W]>4      tb ! R; R<]>4      tc ! R= R>4      td ! R? R@]>4      te ! RA RB]>4      tf]! ]24       ! RC RD](4      4       tg ! RE RF]d]>4      th ! RG RH].4      ti ! RI RJ]d]>4      tj ! RK RL4      tk ! RM RN]k]>]X4      tl ! RO RP]k]>]`4      tmR#   ]]3 d    R
t ELgi ; i)Rz#
Tests for L{twisted.pair.tuntap}.
N)deque)EAGAINEBADFEINVALENODEVENOENTEPERMEWOULDBLOCK)cycle)	randrange)SIGINT)Optional)ObjectNotFoundnamedAnyzfcntl.ioctlz'Platform is missing fcntl/ioctl support)	Interfaceimplementer)verifyObject)CannotListenError)IAddressIListeningPortIReactorFDSet)AbstractDatagramProtocolDatagramProtocolFactory)Clock)EthernetProtocol)
IPProtocol)IRawPacketProtocol)RawUDPProtocol)	iterbytes)addObserverremoveObservertextFromEventDict)fullyQualifiedName)SkipTestSynchronousTestCase)_H_PI_SIZEMemoryIOSystemTunnel	_ethernet_ip_IPv4_udp)	_IFNAMSIZ
_TUNSETIFFTunnelAddressTunnelFlags
TuntapPort_IInputOutputSystem_RealSystemc                   H   a  ] tR t^Rt o RtR tR tR tR tR t	R t
RtV tR	# )
ReactorFDSeta  
An implementation of L{IReactorFDSet} which only keeps track of which
descriptors have been registered for reading and writing.

This implementation isn't actually capable of determining readability or
writeability and generates no events for the descriptors registered with
it.

@ivar _readers: A L{set} of L{IReadDescriptor} providers which the reactor
    is supposedly monitoring for read events.

@ivar _writers: A L{set} of L{IWriteDescriptor} providers which the reactor
    is supposedly monitoring for write events.
c                    \        4       V n        \        4       V n        V P                  P                  V n        V P                  P                  V n        R # N)set_readers_writersadd	addReader	addWriterselfs   &?/usr/lib/python3/dist-packages/twisted/pair/test/test_tuntap.py__init__ReactorFDSet.__init__c   s6    ****    c                <    V P                   P                  V4       R # r8   )r:   discard)r@   readers   &&rA   removeReaderReactorFDSet.removeReaderi       f%rD   c                <    V P                   P                  V4       R # r8   )r;   rF   )r@   writers   &&rA   removeWriterReactorFDSet.removeWriterl   rJ   rD   c                ,    \        V P                  4      # r8   )iterr:   r?   s   &rA   
getReadersReactorFDSet.getReaderso       DMM""rD   c                ,    \        V P                  4      # r8   )rP   r;   r?   s   &rA   
getWritersReactorFDSet.getWritersr   rS   rD   c                     \        V P                  V P                  ,          4      \        4       V n        \        4       V n        #   \        4       T n        \        4       T n        i ; ir8   )listr:   r;   r9   r?   s   &rA   	removeAllReactorFDSet.removeAllu   sD    	"56EDMEDM  EDMEDMs   %A  A&)r:   r;   r=   r>   N)__name__
__module____qualname____firstlineno____doc__rB   rH   rM   rQ   rU   rY   __static_attributes____classdictcell____classdict__s   @rA   r6   r6   R   s-     +&&##" "rD   r6   c                   *   a  ] tR t^t o RtR tRtV tR# )
FSSetClockzA
An L{FSSetClock} is a L{IReactorFDSet} and an L{IReactorClock}.
c                \    \         P                  ! V 4       \        P                  V 4       R # r8   )r   rB   r6   r?   s   &rA   rB   FSSetClock.__init__   s    td#rD    N)r[   r\   r]   r^   r_   rB   r`   ra   rb   s   @rA   re   re      s     $ $rD   re   c                   F   a  ] tR t^t o Rt]R 4       tR tR tR t	Rt
V tR# )	TunHelperzE
A helper for tests of tun-related functionality (ip-level tunnels).
c                L    \         P                  \         P                  ,          # r8   )r1   IFF_TUN	IFF_NO_PIr?   s   &rA   TUNNEL_TYPETunHelper.TUNNEL_TYPE   s     ""[%:%:::rD   c                    Wn         W n        R# )a?  
@param tunnelRemote: The source address for UDP datagrams originated
    from this helper.  This is an IPv4 dotted-quad string.
@type tunnelRemote: L{bytes}

@param tunnelLocal: The destination address for UDP datagrams
    originated from this helper.  This is an IPv4 dotted-quad string.
@type tunnelLocal: L{bytes}
N)tunnelRemotetunnelLocal)r@   rq   rr   s   &&&rA   rB   TunHelper.__init__   s     )&rD   c           
     \    \        V P                  V P                  \        WVR7      R7      # )a  
Construct an ip datagram containing a udp datagram containing the given
application-level payload.

@param source: The source port for the UDP datagram being encapsulated.
@type source: L{int}

@param destination: The destination port for the UDP datagram being
    encapsulated.
@type destination: L{int}

@param payload: The application data to include in the udp datagram.
@type payload: L{bytes}

@return: An ethernet frame.
@rtype: L{bytes}
)srcdstpayload)r+   rq   rr   r-   )r@   sourcedestinationrw   s   &&&&rA   encapsulateTunHelper.encapsulate   s-    $ !!  VgF
 	
rD   c                   aa . o\        4       pV3R lpW!n        \        4       pVP                  RV4       \	        4       oSP                  ^V4       VV3R lpV# )a  
Get a function for parsing a datagram read from a I{tun} device.

@return: A function which accepts a datagram exactly as might be read
    from a I{tun} device.  The datagram is expected to ultimately carry
    a UDP datagram.  When called, it returns a L{list} of L{tuple}s.
    Each tuple has the UDP application data as the first element and
    the sender address as the second element.
c                  *   < SP                  V 4       R # r8   appendargs	datagramss   *rA   capture!TunHelper.parser.<locals>.capture       T"rD   90  c                 2   < SP                  V R RRR4       S# )FN)datagramReceived)datar   ips   &rA   parseTunHelper.parser.<locals>.parse   s!     eT4>rD   )r   r   r   addProtor   )r@   receiverr   udpr   r   r   s   &    @@rA   parserTunHelper.parser   sV     	#%	# %,!UH%\
B	 rD   )rr   rq   Nr[   r\   r]   r^   r_   propertyrn   rB   rz   r   r`   ra   rb   s   @rA   rj   rj      s2      ; ;'
0 rD   rj   c                   F   a  ] tR t^t o Rt]R 4       tR tR tR t	Rt
V tR# )	TapHelperzK
A helper for tests of tap-related functionality (ethernet-level tunnels).
c                x    \         P                  pV P                  '       g   V\         P                  ,          pV# r8   )r1   IFF_TAPpirm   )r@   flags   & rA   rn   TapHelper.TUNNEL_TYPE   s+    ""wwwK)))DrD   c                *    Wn         W n        W0n        R# )a  
@param tunnelRemote: The source address for UDP datagrams originated
    from this helper.  This is an IPv4 dotted-quad string.
@type tunnelRemote: L{bytes}

@param tunnelLocal: The destination address for UDP datagrams
    originated from this helper.  This is an IPv4 dotted-quad string.
@type tunnelLocal: L{bytes}

@param pi: A flag indicating whether this helper will generate and
    consume a protocol information (PI) header.
@type pi: L{bool}
N)rq   rr   r   )r@   rq   rr   r   s   &&&&rA   rB   TapHelper.__init__   s     )&rD   c                   \        V P                  V P                  4      pVP                  WV4      p\	        RR\
        VR7      pV P                  '       d+   \
        p^ p\        V4      \        V4      ,           V,           pV# )a  
Construct an ethernet frame containing an ip datagram containing a udp
datagram containing the given application-level payload.

@param source: The source port for the UDP datagram being encapsulated.
@type source: L{int}

@param destination: The destination port for the UDP datagram being
    encapsulated.
@type destination: L{int}

@param payload: The application data to include in the udp datagram.
@type payload: L{bytes}

@return: An ethernet frame.
@rtype: L{bytes}
s         s   )ru   rv   protocolrw   )rj   rq   rr   rz   r*   r,   r   r&   )	r@   rx   ry   rw   tunr   framer   flagss	   &&&&     rA   rz   TapHelper.encapsulate   ss    $ ))4+;+;<__V':++	
 777HEuI8,u4ErD   c                   a aa . o\        4       pV3R lpW!n        \        4       pVP                  RV4       \	        4       pVP                  ^V4       \        4       oSP                  RV4       VVV 3R lpV# )a  
Get a function for parsing a datagram read from a I{tap} device.

@return: A function which accepts a datagram exactly as might be read
    from a I{tap} device.  The datagram is expected to ultimately carry
    a UDP datagram.  When called, it returns a L{list} of L{tuple}s.
    Each tuple has the UDP application data as the first element and
    the sender address as the second element.
c                  *   < SP                  V 4       R # r8   r~   r   s   *rA   r   !TapHelper.parser.<locals>.capture'  r   rD   r   i   c                 `   < SP                   '       d
   V \        R  p SP                  V 4       S# r8   )r   r'   r   )datagramr   etherr@   s   &rA   r    TapHelper.parser.<locals>.parser5  s0     www#HI. ""8,rD   )r   r   r   r   r   r   )r@   r   r   r   r   r   r   r   s   f     @@rA   r   TapHelper.parser  sl     	#%	# %,!UH%\
B "ub!		 rD   )r   rr   rq   Nr   rb   s   @rA   r   r      s3       $ D& &rD   r   c                   *   a  ] tR tRt o RtR tRtV tR# )TunnelTestsiC  zg
L{Tunnel} is mostly tested by other test cases but some tests don't fit
there.  Those tests are here.
c                    \        \        4       \        P                  R4      pV P	                  \
        VP                  R4       R# )zw
Blocking reads are not implemented by L{Tunnel.read}.  Attempting one
results in L{NotImplementedError} being raised.
N   )r)   r(   osO_RDONLYassertRaisesNotImplementedErrorreadr@   tunnels   & rA   test_blockingReadTunnelTests.test_blockingReadI  s0    
 ("++t<-v{{DArD   rh   N)r[   r\   r]   r^   r_   r   r`   ra   rb   s   @rA   r   r   C  s     
B BrD   r   c                   `   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tRtV tR# )TunnelDeviceTestsMixiniR  zN
A mixin defining tests that apply to L{_IInputOutputSystem}
implementations.
c                
   V P                  4       V n        V P                  P                  R\        P                  \        P
                  ,          4      V n        V P                  V P                  P                  V P                  4       V P                  P                  p\        P                  ! R\        3,          V P                  VP                  4      pV P                  P!                  V P                  \"        V4       R# )zS
Create the L{_IInputOutputSystem} provider under test and open a tunnel
using it.
   /dev/net/tunz%dsHN)createSystemsystemopenr   O_RDWR
O_NONBLOCKfileno
addCleanupclosehelperrn   structpackr.   _TUNNEL_DEVICEvalueioctlr/   )r@   modeconfigs   &  rA   setUpTunnelDeviceTestsMixin.setUpX  s    
 '')kk&&		BMM8QR))4;;7{{&&Vyl2D4G4GT$++z6:rD   c                X    V P                  \        \        V P                  4      4       R# )z8
The object under test provides L{_IInputOutputSystem}.
N)
assertTruer   r3   r   r?   s   &rA   test_interface%TunnelDeviceTestsMixin.test_interfacee  s     	%8$++FGrD   c                    V P                   P                  R\        P                  4      pV P                   P	                  V4       V# )a  
Get an invalid file descriptor.

@return: An integer which is not a valid file descriptor at the time of
    this call.  After any future system call which allocates a new file
    descriptor, there is no guarantee the returned file descriptor will
    still be invalid.
r   )r   r   r   r   r   )r@   fds   & rA   _invalidFileDescriptor-TunnelDeviceTestsMixin._invalidFileDescriptork  s5     [[oryy9"	rD   c                    V P                  4       pV P                  \        V P                  P                  VR4      pV P                  \        VP                  4       R# )z
The device's C{read} implementation raises L{OSError} with an errno of
C{EBADF} when called on a file descriptor which is not valid (ie, which
has no associated file description).
r   N)r   r   OSErrorr   r   assertEqualr   errnor@   r   excs   &  rA   test_readEBADF%TunnelDeviceTestsMixin.test_readEBADFx  sF     ((*)9)92tD		*rD   c                    V P                  4       pV P                  \        V P                  P                  VR4      pV P                  \        VP                  4       R# )z
The device's C{write} implementation raises L{OSError} with an errno of
C{EBADF} when called on a file descriptor which is not valid (ie, which
has no associated file description).
s   bytesN)r   r   r   r   writer   r   r   r   s   &  rA   test_writeEBADF&TunnelDeviceTestsMixin.test_writeEBADF  sF     ((*):):BI		*rD   c                    V P                  4       pV P                  \        V P                  P                  V4      pV P                  \        VP                  4       R# )z
The device's C{close} implementation raises L{OSError} with an errno of
C{EBADF} when called on a file descriptor which is not valid (ie, which
has no associated file description).
N)r   r   r   r   r   r   r   r   r   s   &  rA   test_closeEBADF&TunnelDeviceTestsMixin.test_closeEBADF  sD     ((*):):B?		*rD   c                    V P                  4       pV P                  \        V P                  P                  V\
        R4      pV P                  \        VP                  4       R# )z
The device's C{ioctl} implementation raises L{OSError} with an errno of
C{EBADF} when called on a file descriptor which is not valid (ie, which
has no associated file description).
s   tap0N)	r   r   IOErrorr   r   r/   r   r   r   r   s   &  rA   test_ioctlEBADF&TunnelDeviceTestsMixin.test_ioctlEBADF  sH     ((*):):B
GT		*rD   c                    RpV P                  \        V P                  P                  V P                  VR4      pV P                  \        VP                  4       R# )z
The device's C{ioctl} implementation raises L{IOError} with an errno of
C{EINVAL} when called with a request (second argument) which is not a
supported operation.
l   >[= s   garbageN)r   r   r   r   r   r   r   r   )r@   requestr   s   &  rA   test_ioctlEINVAL'TunnelDeviceTestsMixin.test_ioctlEINVAL  sH     T[[&&Wj
 	+rD   c                0   V P                   P                  4       pRp\        ^d4       F  p\        R	4      pRV3,          pV P                  P                  WPP                  R34      p\        ^d4       FA  p V P                  P                  V P                  R4      pV! V4      p	WV3V	9   d   Rp MV	R KC  	  V'       g   K   M	  V'       g   V P                  R4       R# R#   \         d)   p
T
P                  \        \        39   d    Rp
?
 KX  h Rp
?
ii ; i)
zv
If a UDP datagram is sent to an address reachable by the tunnel device
then it can be read out of the tunnel device.
F   hello world:%dr   r   T:NNNNz$Never saw probe UDP packet on tunnel            )r   r   ranger   r   sendUDP_TUNNEL_REMOTEr   r   r   r   r   r	   fail)r@   r   foundikeymessagerx   jpacketr   es   &          rA   test_receive#TunnelDeviceTestsMixin.test_receive  s    
 ""$ sAE"C'3&0G[[((3F3F2NOF
 3Z%![[--dkk4@F !&fI(I5 $!!   u- 0 II<=   ww6;"77s   6&C""D-DDDc                   \        R4      pRV3,          pV P                  \        P                  \        P                  ! 4       4       \        P                  ! ^x4       V P
                  P                  V P                  V P                  R4      pV P                  P                  RRV4      pV P
                  P                  V P                  V4       VP                  R4      pV P                  W$4       R# )zm
If a UDP datagram is written the tunnel device then it is received by
the network to which it is addressed.
r   r   iP  r   Nr   )r   r   socketsetdefaulttimeoutgetdefaulttimeoutr   
receiveUDPr   _TUNNEL_LOCALr   rz   r   recvr   )r@   r   r   portr   s   &    rA   	test_send TunnelDeviceTestsMixin.test_send  s     #sf, 	00&2J2J2LM  % {{%%dkk43E3EuM ((w? 	$++v. 4)rD   )r   r   N)r[   r\   r]   r^   r_   r   r   r   r   r   r   r   r   r   r  r`   ra   rb   s   @rA   r   r   R  sC     
;H++++,$>L$* $*rD   r   c                   6   a  ] tR tRt o RtRtRtRtR tRt	V t
R# )	FakeDeviceTestsMixini  z
Define a mixin for use with test cases that require an
L{_IInputOutputSystem} provider.  This mixin hands out L{MemoryIOSystem}
instances as the provider of that interface.
s   tap-twistedtests
   172.16.2.1s
   172.16.2.2c                b    \        4       pVP                  \        P                  \        4       V# )z
Create and return a brand new L{MemoryIOSystem}.

The L{MemoryIOSystem} knows how to open new tunnel devices.

@return: The newly created I/O system object.
@rtype: L{MemoryIOSystem}
)r(   registerSpecialDevicer)   _DEVICE_NAMEr@   r   s   & rA   r   !FakeDeviceTestsMixin.createSystem  s'      !$$V%8%8&ArD   rh   N)r[   r\   r]   r^   r_   r   r  r   r   r`   ra   rb   s   @rA   r  r    s%      (N!M"N rD   r  c                       ] tR tRtRtRtR# )FakeTapDeviceTestsi  zI
Run various tap-type tunnel unit tests against an in-memory I/O system.
rh   Nr[   r\   r]   r^   r_   r`   rh   rD   rA   r  r        rD   r  r   Fr   c                       ] tR tRtRtRtR# )FakeTapDeviceWithPITestsi%  zd
Run various tap-type tunnel unit tests against an in-memory I/O system with
the PI header enabled.
rh   Nr  rh   rD   rA   r  r  %  s    rD   r  Tc                       ] tR tRtRtRtR# )FakeTunDeviceTestsi7  zI
Run various tun-type tunnel unit tests against an in-memory I/O system.
rh   Nr  rh   rD   rA   r  r  7  r  rD   r  c                   N   a a ] tR tRt oRtV 3R ltV 3R ltR tR tRt	Vt
V ;t# )TestRealSystemiF  z
Add extra skipping logic so tests that try to create real tunnel devices on
platforms where those are not supported automatically get skipped.
c                   <  \         SV `  ! V.VO5/ VB #   \         d4   pTP                  \        \
        39   d   TR8X  d   \        R4      hh Rp?ii ; i)z
Attempt an open, but if the file is /dev/net/tun and it does not exist,
translate the error into L{SkipTest} so that tests that require
platform support for tuntap devices are skipped instead of failed.
r   zPlatform lacks /dev/net/tunN)superr   r   r   r   r   r$   )r@   filenamer   kwargsr   	__class__s   &&*, rA   r   TestRealSystem.openM  sZ    	7<:4:6:: 	 ww66**x?/J<==	s    A.AAc                   <  \         SV `  ! V/ VB #   \         d'   p\        TP                  8X  d   \        R4      hh Rp?ii ; i)z
Attempt an ioctl, but translate permission denied errors into
L{SkipTest} so that tests that require elevated system privileges and
do not have them are skipped instead of failed.
z%Permission to configure device deniedN)r  r   r   r   r   r$   )r@   r   r  r   r  s   &*, rA   r   TestRealSystem.ioctl\  sG    	7=$1&11 	FGG	s    A!?Ac                    \         P                   ! \         P                  \         P                  4      pVP                  R4       VP	                  W4       VP                  4       # )ae  
Use the platform network stack to send a datagram to the given address.

@param datagram: A UDP datagram payload to send.
@type datagram: L{bytes}

@param address: The destination to which to send the datagram.
@type address: L{tuple} of (L{bytes}, L{int})

@return: The address from which the UDP datagram was sent.
@rtype: L{tuple} of (L{bytes}, L{int})
)z
172.16.0.1    )r   AF_INET
SOCK_DGRAMbindsendtogetsockname)r@   r   addressss   &&& rA   r   TestRealSystem.sendUDPi  sC     MM&..&*;*;<	 !	#}}rD   c                    \         P                   ! \         P                  \         P                  4      pVP                  W#34       V# )a  
Use the platform network stack to receive a datagram sent to the given
address.

@param fileno: The file descriptor of the tunnel used to send the
    datagram.  This is ignored because a real socket is used to receive
    the datagram.
@type fileno: L{int}

@param host: The IPv4 address at which the datagram will be received.
@type host: L{bytes}

@param port: The UDP port number at which the datagram will be
    received.
@type port: L{int}

@return: A L{socket.socket} which can be used to receive the specified
    datagram.
)r   r#  r$  r%  )r@   r   hostr  r)  s   &&&& rA   r  TestRealSystem.receiveUDP{  s1    ( MM&..&*;*;<	|rD   rh   )r[   r\   r]   r^   r_   r   r   r   r  r`   ra   __classcell__)r  rc   s   @@rA   r  r  F  s#     
$ rD   r  c                   .   a  ] tR tRt o Rt]tR tRtV t	R# )RealDeviceTestsMixini  z
Define a mixin for use with test cases that require an
L{_IInputOutputSystem} provider.  This mixin hands out L{TestRealSystem}
instances as the provider of that interface.
c                    \        4       # )z
Create a real I/O system that can be used to open real tunnel device
provided by the underlying system and previously configured.

@return: The newly created I/O system object.
@rtype: L{TestRealSystem}
)r  r?   s   &rA   r   !RealDeviceTestsMixin.createSystem  s     rD   rh   N)
r[   r\   r]   r^   r_   platformSkipskipr   r`   ra   rb   s   @rA   r0  r0    s      D   rD   r0  c                   <    ] tR tRtRtRtRtRt]! ]]RR7      t	Rt
R	# )
&RealDeviceWithProtocolInformationTestsi  zp
Run various tap-type tunnel unit tests, with "protocol information" (PI)
turned on, against a real I/O system.
s   tap-twtest-pis
   172.16.1.1s
   172.16.1.2Tr  rh   Nr[   r\   r]   r^   r_   r   r  r   r   r   r`   rh   rD   rA   r6  r6    s(    
 &N!M"N ~}>FrD   r6  c                   <    ] tR tRtRtRtRtRt]! ]]RR7      t	Rt
R	# )
)RealDeviceWithoutProtocolInformationTestsi  zq
Run various tap-type tunnel unit tests, with "protocol information" (PI)
turned off, against a real I/O system.
s
   tap-twtests
   172.16.0.1s
   172.16.0.2Fr  rh   Nr7  rh   rD   rA   r9  r9    s&    
 #N!M"N~}?FrD   r9  c                   0   a  ] tR tRt o RtR tR tRtV tR# )TuntapPortTestsi  zJ
Tests for L{TuntapPort} behavior that is independent of the tunnel type.
c                l    \        R\        4       4      pV P                  \        \        V4      4       R# )z6
A L{TuntapPort} instance provides L{IListeningPort}.
   deviceN)r2   r   r   r   r   r@   r  s   & rA   r   TuntapPortTests.test_interface  s'     )%5%78^T:;rD   c                n    \        R\        4       4      pV P                  VP                  \        4       R# )zO
When not initialized with an I/O system, L{TuntapPort} uses a
L{_RealSystem}.
r=  N)r2   r   assertIsInstance_systemr4   r>  s   & rA   test_realSystemTuntapPortTests.test_realSystem  s(    
 )%5%78dllK8rD   rh   N)	r[   r\   r]   r^   r_   r   rC  r`   ra   rb   s   @rA   r;  r;    s     <9 9rD   r;  c                      a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!R  t"R! t#R" t$R# t%R$ t&R% t'R&t(V t)R'# )(TunnelTestsMixini  z
A mixin defining tests for L{TuntapPort}.

These tests run against L{MemoryIOSystem} (proven equivalent to the real
thing by the tests above) to avoid performing any real I/O.
c                   RV n         \        4       V n        V P                  P                  \        P
                  \        4       V P                  P                  \        V P                  P                  V P                   4      4      V n        \        4       V n        \        V P                   V P                  V P                  V P                  R7      V n        R# )zG
Create an in-memory I/O system and set up a L{TuntapPort} against it.
   tun0)reactorr   N)namer(   r   r
  r)   r  factorybuildProtocolr0   r   rn   r   re   rI  r2   r  r?   s   &rA   r   TunnelTestsMixin.setUp  s     	$&))&*=*=vF22$++11499=
 "|IIt}}dll4;;
	rD   c                Z    V\         P                  \         P                  ,          ,          # )z
Mask off any flags except for L{TunnelType.IFF_TUN} and
L{TunnelType.IFF_TAP}.

@param flags: Flags from L{TunnelType} to mask.
@type flags: L{FlagConstant}

@return: The flags given by C{flags} except the two type flags.
@rtype: L{FlagConstant}
)r1   rl   r   )r@   r   s   &&rA   _tunnelTypeOnly TunnelTestsMixin._tunnelTypeOnly  s      ++k.A.AABBrD   c                   V P                   pV P                  P                  4        V P                   P                  V P                  4      pVP                  VP
                  ,          VP                  ,          RR\        \        R4      ,
          ,          ,           V P                  P                  RR3pVP                  VP                  VP                  VP                  VP                  3pV P                  W44       R# )z
L{TuntapPort.startListening} opens the tunnel factory character special
device C{"/dev/net/tun"} and configures it as a I{tun} tunnel.
rH      FTN)r   r  startListening	getTunnelr   	O_CLOEXECr   r.   len	interface	openFlagsrequestedNamerJ  blockingcloseOnExecr   )r@   r   r   expectedactuals   &    rA   test_startListeningOpensDevice/TunnelTestsMixin.test_startListeningOpensDevice  s    
 		  "&&tyy1 MMF,,,v/@/@@gS\!9::II
   KKOO
 	*rD   c                    V P                   P                  4        V P                  V P                   P                  4       R# )zO
L{TuntapPort.startListening} sets C{connected} on the port object to
C{True}.
N)r  rS  r   	connectedr?   s   &rA    test_startListeningSetsConnected1TunnelTestsMixin.test_startListeningSetsConnected  s*    
 			  "		++,rD   c                    V P                   P                  4        V P                  V P                   V P                  P                  4       R# )z
L{TuntapPort.startListening} calls C{makeConnection} on the protocol
the port was initialized with, passing the port as an argument.
N)r  rS  assertIsr   	transportr?   s   &rA   #test_startListeningConnectsProtocol4TunnelTestsMixin.test_startListeningConnectsProtocol%  s0    
 			  "dii!8!89rD   c                    V P                   P                  4        V P                  V P                   V P                  P	                  4       4       R# )z
L{TuntapPort.startListening} passes the port instance to the reactor's
C{addReader} method to begin watching the port's file descriptor for
data to read.
N)r  rS  assertInrI  rQ   r?   s   &rA    test_startListeningStartsReading1TunnelTestsMixin.test_startListeningStartsReading-  s3     			  "dii!8!8!:;rD   c                    V P                   P                  P                  R4       V P                  \        V P
                  P                  4       R# )zx
L{TuntapPort.startListening} raises L{CannotListenError} if opening the
tunnel factory character special device fails.
r   Nr   permissionsremover   r   r  rS  r?   s   &rA   %test_startListeningHandlesOpenFailure6TunnelTestsMixin.test_startListeningHandlesOpenFailure6  s7    
 	&&v.+TYY-E-EFrD   c                    V P                   P                  P                  R4       V P                  \        V P
                  P                  4       R# )zu
L{TuntapPort.startListening} raises L{CannotListenError} if the
C{ioctl} call to configure the tunnel device fails.
r   Nrn  r?   s   &rA   *test_startListeningHandlesConfigureFailure;TunnelTestsMixin.test_startListeningHandlesConfigureFailure>  s7    
 	&&w/+TYY-E-EFrD   c                    VP                  4       pV P                  WP                  P                  4       4       V P                  P	                  ^ 4       V P                  V P                  V4      4       R# )a  
Verify that the C{stopListening} method of an L{IListeningPort} removes
that port from the reactor's "readers" set and also that the
L{Deferred} returned by that method fires with L{None}.

@param port: The port object to stop.
@type port: L{IListeningPort} provider
N)stopListeningassertNotInrI  rQ   advanceassertIsNonesuccessResultOf)r@   r  stoppeds   && rA   	_stopPortTunnelTestsMixin._stopPortF  sX     $$&||6689Q$..w78rD   c                    V P                   P                  4        V P                   P                  4       pV P                  V P                   4       V P	                  WP
                  P                  4       R# )z
L{TuntapPort.stopListening} returns a L{Deferred} which fires after the
port has been removed from the reactor's reader list by passing it to
the reactor's C{removeReader} method.
N)r  rS  r   r}  rx  r   
_openFiles)r@   r   s   & rA   test_stopListeningStopsReading/TunnelTestsMixin.test_stopListeningStopsReadingU  sN     			  "!!#tyy!!7!78rD   c                    V P                   P                  4        V P                  V P                   4       V P                  V P                   P                  4       R# )z
After the L{Deferred} returned by L{TuntapPort.stopListening} fires,
the C{connected} attribute of the port object is set to C{False}.
N)r  rS  r}  assertFalsera  r?   s   &rA   !test_stopListeningUnsetsConnected2TunnelTestsMixin.test_stopListeningUnsetsConnecteda  s<    
 			  "tyy!,,-rD   c                    V P                   P                  4        V P                  V P                   4       V P                  V P                  P
                  4       R# )z\
L{TuntapPort.stopListening} calls C{doStop} on the protocol the port
was initialized with.
N)r  rS  r}  rz  r   rf  r?   s   &rA   test_stopListeningStopsProtocol0TunnelTestsMixin.test_stopListeningStopsProtocolj  s<    
 			  "tyy!$--112rD   c                z    V P                   P                  4       pV P                  V P                  V4      4       R# )z~
L{TuntapPort.stopListening} returns a L{Deferred} which succeeds
immediately if it is called when the port is not listening.
N)r  rw  rz  r{  )r@   r|  s   & rA   test_stopListeningWhenStopped.TunnelTestsMixin.test_stopListeningWhenStoppeds  s/    
 ))))+$..w78rD   c                   V P                   P                  4        V P                   P                  4        V P                   P                  4       pV P                  P	                  ^ 4       V P                  V P                  V4      4       R# )z
It is safe and a no-op to call L{TuntapPort.stopListening} more than
once with no intervening L{TuntapPort.startListening} call.
N)r  rS  rw  rI  ry  rz  r{  )r@   seconds   & rA   test_multipleStopListening+TunnelTestsMixin.test_multipleStopListening{  sa    
 			  "		!((*Q$..v67rD   c                   V P                   P                  4        V P                   P                  4        V P                  P	                  ^ 4       V P                  V P                   P                  4       V P                  V P                  .4      pV P                  \        V^ ,          R,          4       V P                  RV^ ,          R,          4       V P                  ^\        V4      4       R# )z@
L{TuntapPort.loseConnection} stops the port and is deprecated.
categoryztwisted.pair.tuntap.TuntapPort.loseConnection was deprecated in Twisted 14.0.0; please use twisted.pair.tuntap.TuntapPort.stopListening insteadr   N)r  rS  loseConnectionrI  ry  r  ra  flushWarningstest_loseConnectionr   DeprecationWarningrV  )r@   warningss   & rA   r  $TunnelTestsMixin.test_loseConnection  s     			  "		  "Q,,-%%t'?'?&@A+Xa[-DE$ QK	"		
 	CM*rD   c                   V P                   P                  4        V P                  P                  V P                   4      pWn        V P                   P                  4        V P                  . V P                  P                  4       R# )a0  
Test that L{TuntapPort.doRead} has no side-effects under a certain
exception condition.

@param style: An exception instance to arrange for the (python wrapper
    around the) underlying platform I{read} call to fail with.

@raise C{self.failureException}: If there are any observable
    side-effects.
N)	r  rS  r   rT  nonBlockingExceptionStyledoReadr   r   received)r@   styler   s   && rA   _stopsReadingTest"TunnelTestsMixin._stopsReadingTest  s\     			  "&&tyy1+0(		T]]334rD   c                D    V P                  \        P                  4       R# )zZ
Once L{TuntapPort.doRead} encounters an I{EAGAIN} errno from a C{read}
call, it returns.
N)r  r)   EAGAIN_STYLEr?   s   &rA   test_eagainStopsReading(TunnelTestsMixin.test_eagainStopsReading  s    
 	v223rD   c                D    V P                  \        P                  4       R# )z_
Once L{TuntapPort.doRead} encounters an I{EWOULDBLOCK} errno from a
C{read} call, it returns.
N)r  r)   EWOULDBLOCK_STYLEr?   s   &rA   test_ewouldblockStopsReading-TunnelTestsMixin.test_ewouldblockStopsReading  s    
 	v778rD   c                D    V P                  \        P                  4       R# )zY
Once L{TuntapPort.doRead} encounters an I{EINTR} errno from a C{read}
call, it returns.
N)r  r)   EINTR_STYLEr?   s   &rA   test_eintrblockStopsReading,TunnelTestsMixin.test_eintrblockStopsReading  s    
 	v112rD   c                f     ! R R\         4      pV P                  WP                  V! 4       4       R# )z
If L{Tuntap.doRead} encounters any exception other than one explicitly
handled by the code, the exception propagates to the caller.
c                       ] tR tRtRtR# )ETunnelTestsMixin.test_unhandledReadError.<locals>.UnexpectedExceptioni  rh   N)r[   r\   r]   r^   r`   rh   rD   rA   UnexpectedExceptionr    s    rD   r  N)	Exceptionr   r  )r@   r  s   & rA   test_unhandledReadError(TunnelTestsMixin.test_unhandledReadError  s-    	) 	 	!7!79L9N	
rD   c                d    V P                  \        V P                  \        \        R4      4       R# )z
Just like C{test_unhandledReadError}, but for the case where the
exception that is not explicitly handled happens to be of type
C{EnvironmentError} (C{OSError} or C{IOError}).
zOperation not permittedN)r   r   r  r   r?   s   &rA   "test_unhandledEnvironmentReadError3TunnelTestsMixin.test_unhandledEnvironmentReadError  s'     	T++WU<U-V	
rD   c                   RV P                   P                  ^,
          ,          pV P                   P                  4        V P                  P	                  V P                   4      pVP
                  P                  V4       V P                   P                  4        V P                  V.V P                  P                  4       R# )z
L{TuntapPort.doRead} reads a datagram of fewer than
C{TuntapPort.maxPacketSize} from the port's file descriptor and passes
it to its protocol's C{datagramReceived} method.
   xNr  maxPacketSizerS  r   rT  
readBufferr   r  r   r   r  r@   r   r   s   &  rA   test_doReadSmallDatagram)TunnelTestsMixin.test_doReadSmallDatagram  s     49922Q67		  "&&tyy1  *		(T]]%;%;<rD   c                   RV P                   P                  ,          pV P                   P                  4        V P                  P	                  V P                   4      pVP
                  P                  VR,           4       V P                   P                  4        V P                  V.V P                  P                  4       R# )z
L{TuntapPort.doRead} reads the first part of a datagram of more than
C{TuntapPort.maxPacketSize} from the port's file descriptor and passes
the truncated data to its protocol's C{datagramReceived} method.
r     yNr  r  s   &  rA   test_doReadLargeDatagram)TunnelTestsMixin.test_doReadLargeDatagram  s     $))111		  "&&tyy1  D1		(T]]%;%;<rD   c                x   \        \        R4      4      p^ p. pW P                  P                  8  dT   VP	                  \        V4      V P                  P                  ,          4       W P                  P                  ,          pKm  V P                  P                  4        V P                  P                  V P                  4      pVP                  P                  V4       VP                  P	                  R4       V P                  P                  4        V P                  W0P                  P                  4       R# )zs
L{TuntapPort.doRead} reads several datagrams, of up to
C{TuntapPort.maxThroughput} bytes total, before returning.
s   abcdefghijklmnopqrstuvwxyzs"   excessive datagram, not to be readN)r
   r   r  maxThroughputr   nextr  rS  r   rT  r  extendr  r   r   r  )r@   valuestotalr   r   s   &    rA   test_doReadSeveralDatagrams,TunnelTestsMixin.test_doReadSeveralDatagrams  s    
 y!>?@	ii---T&\DII,C,CCDYY,,,E		  "&&tyy1  +  !FG		MM$:$:;rD   c                2   V P                   P                  4        V P                  P                  V P                   4      P                  P                  R4       RV P                  n        V P                   P                  4        V P                  \        4      # )z
Deliver some data to a L{TuntapPort} hooked up to an application
protocol that raises an exception from its C{datagramReceived} method.

@return: Whatever L{AttributeError} exceptions are logged.
s   pingN)r  rS  r   rT  r  r   r   r  r  flushLoggedErrorsAttributeErrorr?   s   &rA   _datagramReceivedException+TunnelTestsMixin._datagramReceivedException  sj     			  "dii(33::7C "&		%%n55rD   c                \    V P                  4       pV P                  ^\        V4      4       R# )z\
If the protocol's C{datagramReceived} method raises an exception, the
exception is logged.
N)r  r   rV  )r@   errorss   & rA   test_datagramReceivedException/TunnelTestsMixin.test_datagramReceivedException  s&    
 002CK(rD   c                `   . p\        VP                  4       V P                  \        VP                  4       V P	                  4        \        R V 4       4      p\        V4      pV P                  R\        V P                  P                  4      : R2VP                  4       ^ ,          4       R# )zj
The exception raised by C{datagramReceived} is logged with a message
identifying the offending protocol.
c              3   F   "   T F  qR ,          '       g   K  Vx  K  	  R# 5i)isErrorNrh   ).0ms   & rA   	<genexpr>TTunnelTestsMixin.test_datagramReceivedExceptionIdentifiesProtocol.<locals>.<genexpr>'  s     91iLLQQs   !
!zUnhandled exception from z.datagramReceivedN)r    r   r   r!   r  r  r"   r   r#   r   r  
splitlines)r@   messageserrorr   s   &   rA   0test_datagramReceivedExceptionIdentifiesProtocolATunnelTestsMixin.test_datagramReceivedExceptionIdentifiesProtocol  s    
 HOO$8'')999#E*!$--"9"9:= #	
rD   c                   RpV P                   P                  4        V P                   P                  V4       V P                  V P                  P                  V P                   4      P                  \        V.4      4       R# )z7
L{TuntapPort.write} sends a datagram into the tunnel.
s   a b c d e f gN)r  rS  r   r   r   rT  writeBufferr   r@   r   s   & rA   
test_writeTunnelTestsMixin.test_write/  s\     $		  "		!KK!!$)),88%
:K	
rD   c                D   V P                   P                  4        V P                  P                  V P                   4      pVP                  P                  \        4       V P                   P                  R4       V P                  \        R.4      VP                  4       R# )z
If the platform write call is interrupted (causing the Python wrapper
to raise C{IOError} with errno set to C{EINTR}), the write is re-tried.
s   hello, worldN)r  rS  r   rT  pendingSignalsr   r   r   r   r   r  r   s   & rA   test_interruptedWrite&TunnelTestsMixin.test_interruptedWrite:  sn    
 			  "&&tyy1$$V,		(0163E3EFrD   c                
   V P                   P                  4        V P                  P                  V P                   4      pV P	                  \
        V P                   P                  RVP                  ,          R,           4       R# )zc
Any exception raised by the underlying write call, except for EINTR, is
propagated to the caller.
r  r  N)r  rS  r   rT  r   r   r   SEND_BUFFER_SIZEr   s   & rA   test_unhandledWriteError)TunnelTestsMixin.test_unhandledWriteErrorE  sY    
 			  "&&tyy1TYY__dV-D-D&Dt&K	
rD   c                (   . ROpV P                   P                  4        V P                   P                  V4       V P                  V P                  P                  V P                   4      P                  \        RP                  V4      .4      4       R# )zz
L{TuntapPort.writeSequence} sends a datagram into the tunnel by
concatenating the byte strings in the list passed to it.
rD   N)   a   b   c   d)	r  rS  writeSequencer   r   rT  r  r   joinr  s   & rA   test_writeSequence#TunnelTestsMixin.test_writeSequenceP  sh    
 ,		  "		)KK!!$)),88%(AS@T:U	
rD   c                F   V P                   P                  4        V P                   P                  4       pV P                  \	        V P                  V P                  P                  4      V P                  P                  V P                   4      P                  4      V4       R# )zX
L{TuntapPort.getHost} returns a L{TunnelAddress} including the tunnel's
type and name.
N)r  rS  getHostr   r0   rO  r   rn   r   rT  rJ  )r@   r(  s   & rA   test_getHostTunnelTestsMixin.test_getHost\  su    
 			  "))##%$$T[[%<%<=%%dii055 	
rD   c                   V P                   P                  4        V P                  \        V P                   4      \	        V P
                  P                  4      4       RP                  V P                  V P                  P                  4      P                  V P                  P                  V P                   4      P                  4      pV P                  \        V P                   4      P                  V4      R8g  4       R# )
The string representation of a L{TuntapPort} instance includes the
tunnel type and interface and the protocol associated with the port.
z listening on {}/{}>N)r  rS  assertRegexstrr#   r   r  formatrO  r   rn   rJ  r   rT  r   findr@   r\  s   & rA   test_listeningString%TunnelTestsMixin.test_listeningStringk  s    
 			  "TYY);DMM<S<S)TU)00  !8!89>>KK!!$)),11
 	DII++H5;<rD   c                   V P                  \        V P                  4      \        V P                  P
                  4      4       RP                  V P                  V P                  P                  4      P                  V P                  4      pV P                  \        V P                  4      P                  V4      R8g  4       R# )r  z not listening on {}/{}>Nr  )r  r  r  r#   r   r  r  rO  r   rn   rJ  r   r  r   s   & rA   test_unlisteningString'TunnelTestsMixin.test_unlisteningStringy  s    
 	TYY);DMM<S<S)TU-44  !8!89>>II
 	DII++H5;<rD   c                    V P                  V P                  P                  P                  : RV P	                  V P
                  P                  4      P                  : R2V P                  P                  4       4       R# )zg
L{TuntapPort.logPrefix} returns a string identifying the application
protocol and the type of tunnel.
z ()N)
r   r   r  r[   rO  r   rn   rJ  r  	logPrefixr?   s   &rA   test_logPrefixTunnelTestsMixin.test_logPrefix  s\    
 	 ''00$$T[[%<%<=BB
 II!	
rD   )rJ  r  r   rI  r   N)*r[   r\   r]   r^   r_   r   rO  r^  rb  rg  rk  rq  rt  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r`   ra   rb   s   @rA   rF  rF    s     
C+2-:<GG9
9.39	8+*5"493

==<(6 )
"	
	G	



==
 
rD   rF  c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )TunnelAddressTestsi  z
Tests for L{TunnelAddress}.
c           	     t    V P                  \        \        \        \        P
                  R4      4      4       R# )z4
A L{TunnelAddress} instances provides L{IAddress}.
tap0N)r   r   r   r0   r1   r   r?   s   &rA   test_interfaces"TunnelAddressTests.test_interfaces  s'     	=1D1Df#MN	
rD   c                   \        \        P                  R4      pV P                  RV^ ,          4       V P                  RV^,          4       V P	                  V P
                  .4      pRpV P                  \        V^ ,          R,          4       V P                  W2^ ,          R,          4       V P                  \        V^,          R,          4       V P                  W2^,          R,          4       V P                  ^\        V4      4       R# )z
A L{TunnelAddress} instance can be indexed to retrieve either the byte
string C{"TUNTAP"} or the name of the tunnel interface, while
triggering a deprecation warning.
r  TUNTAPzUTunnelAddress.__getitem__ is deprecated since Twisted 14.0.0  Use attributes instead.r  r   N)r0   r1   r   r   r  test_indexingr  rV  )r@   r(  r  r   s   &   rA   r   TunnelAddressTests.test_indexing  s       3 3V<71:.,%%t'9'9&:;& 	 	+Xa[-DE1+i"89+Xa[-DE1+i"89CM*rD   c           	     n    V P                  \        \        \        P                  RR7      4      R4       R# )z
The string representation of a L{TunnelAddress} instance includes the
class name and the values of the C{type} and C{name} attributes.
r=  )rJ  z*TunnelAddress type=IFF_TUN name=b'device'>N)r  reprr0   r1   rl   r?   s   &rA   	test_reprTunnelAddressTests.test_repr  s*    
 	{22CD8	
rD   rh   N)
r[   r\   r]   r^   r_   r  r  r  r`   ra   rb   s   @rA   r  r    s     
+(
 
rD   r  c                   f   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tRtV tR# )TunnelAddressEqualityTestsi  zR
Tests for the implementation of equality (C{==} and C{!=}) for
L{TunnelAddress}.
c                (   \        \        P                  R 4      V n        \        \        P                  \        P                  ,          R 4      V n        \        \        P
                  R4      V n        \        \        P                  R4      V n        R# )r=  s   tap1s   tun1N)r0   r1   rl   firstr  r   
variedType
variedNamer?   s   &rA   r    TunnelAddressEqualityTests.setUp  sd    ";#6#6	B
 $+"5"55y
 ((;(;WE'(;(;WErD   c                V    V P                  V P                  V P                  8H  4       R# )z.
A L{TunnelAddress} compares equal to itself.
Nr   r  r?   s   &rA   test_selfComparesEqual1TunnelAddressEqualityTests.test_selfComparesEqual  s     	

djj01rD   c                V    V P                  V P                  V P                  8g  4       R# )z9
A L{TunnelAddress} doesn't compare not equal to itself.
Nr  r  r?   s   &rA   test_selfNotComparesNotEqual7TunnelAddressEqualityTests.test_selfNotComparesNotEqual  s     	tzz12rD   c                V    V P                  V P                  V P                  8H  4       R# )zx
Two L{TunnelAddress} instances with the same value for the C{type} and
C{name} attributes compare equal to each other.
N)r   r  r  r?   s   &rA    test_sameAttributesComparesEqual;TunnelAddressEqualityTests.test_sameAttributesComparesEqual  s    
 	

dkk12rD   c                V    V P                  V P                  V P                  8g  4       R# )z
Two L{TunnelAddress} instances with the same value for the C{type} and
C{name} attributes don't compare not equal to each other.
N)r  r  r  r?   s   &rA   &test_sameAttributesNotComparesNotEqualATunnelAddressEqualityTests.test_sameAttributesNotComparesNotEqual  s    
 	t{{23rD   c                V    V P                  V P                  V P                  8H  4       R# )zo
Two L{TunnelAddress} instances that differ only by the value of their
type don't compare equal to each other.
N)r  r  r  r?   s   &rA   "test_differentTypeComparesNotEqual=TunnelAddressEqualityTests.test_differentTypeComparesNotEqual      
 	t67rD   c                V    V P                  V P                  V P                  8g  4       R# )zm
Two L{TunnelAddress} instances that differ only by the value of their
type compare not equal to each other.
N)r   r  r  r?   s   &rA   "test_differentTypeNotComparesEqual=TunnelAddressEqualityTests.test_differentTypeNotComparesEqual      
 	

doo56rD   c                V    V P                  V P                  V P                  8H  4       R# )zo
Two L{TunnelAddress} instances that differ only by the value of their
name don't compare equal to each other.
N)r  r  r  r?   s   &rA   "test_differentNameComparesNotEqual=TunnelAddressEqualityTests.test_differentNameComparesNotEqual  r1  rD   c                V    V P                  V P                  V P                  8g  4       R# )zm
Two L{TunnelAddress} instances that differ only by the value of their
name compare not equal to each other.
N)r   r  r  r?   s   &rA   "test_differentNameNotComparesEqual=TunnelAddressEqualityTests.test_differentNameNotComparesEqual  r5  rD   c                B    V P                  V P                  V 8H  4       R# )zK
A L{TunnelAddress} doesn't compare equal to an instance of another
class.
Nr%  r?   s   &rA   #test_differentClassNotComparesEqual>TunnelAddressEqualityTests.test_differentClassNotComparesEqual  s    
 	t+,rD   c                B    V P                  V P                  V 8g  4       R# )zH
A L{TunnelAddress} compares not equal to an instance of another class.
Nr!  r?   s   &rA   #test_differentClassComparesNotEqual>TunnelAddressEqualityTests.test_differentClassComparesNotEqual  s     	

d*+rD   )r  r  r  r  N)r[   r\   r]   r^   r_   r   r"  r&  r)  r,  r/  r3  r7  r:  r=  r@  r`   ra   rb   s   @rA   r  r    sG     
F 23348787-, ,rD   r  c                   :   a  ] tR tRt o RtR tRR ltR tRtV t	R# )	IPRecordingProtocoli  @
A protocol which merely records the datagrams delivered to it.
c                    . V n         R # r8   r  r?   s   &rA   startProtocol!IPRecordingProtocol.startProtocol!  	    rD   Nc                <    V P                   P                  V4       R # r8   r  r   )r@   r   partialdestrx   r   s   &&&&&&rA   r   $IPRecordingProtocol.datagramReceived$  s     	X&rD   c                    R # r8   rh   )r@   numprotos   &&&rA   r   IPRecordingProtocol.addProto)  s    rD   rF  )FNNN)
r[   r\   r]   r^   r_   rG  r   r   r`   ra   rb   s   @rA   rC  rC    s     '
 rD   rC  c                   H    ] tR tRtRt]! 4       t]]n        ]	! RR4      t
RtR# )TunTestsi.  zB
Tests for L{TuntapPort} when used to open a Linux I{tun} tunnel.
Nrh   )r[   r\   r]   r^   r_   r   rK  rC  r   rj   r   r`   rh   rD   rA   rT  rT  .  s$     iG*GtT"FrD   rT  c                   4   a  ] tR tRt o RtR tRR ltRtV tR# )EthernetRecordingProtocoli9  rD  c                    . V n         R # r8   rF  r?   s   &rA   rG  'EthernetRecordingProtocol.startProtocol>  rI  rD   c                <    V P                   P                  V4       R # r8   rK  )r@   r   rL  s   &&&rA   r   *EthernetRecordingProtocol.datagramReceivedA  s    X&rD   rF  N)F)	r[   r\   r]   r^   r_   rG  r   r`   ra   rb   s   @rA   rV  rV  9  s     ' 'rD   rV  c                   L    ] tR tRtRt]! 4       t]]n        ]	! RRRR7      t
RtR# )TapTestsiE  zB
Tests for L{TuntapPort} when used to open a Linux I{tap} tunnel.
NFr  rh   )r[   r\   r]   r^   r_   r   rK  rV  r   r   r   r`   rh   rD   rA   r\  r\  E  s&     iG0GtTe,FrD   r\  c                   *   a  ] tR tRt o RtR tRtV tR# )IOSystemTestsMixiniP  z@
Tests that apply to any L{_IInputOutputSystem} implementation.
c                    V P                  4       pV P                  \        VP                  R\        P
                  4       R# )z\
L{_IInputOutputSystem.open} raises L{OSError} when called with a
non-existent device path.
s!   /dev/there-is-no-such-device-everN)r   r   r   r   r   r   r  s   & rA   test_noSuchDevice$IOSystemTestsMixin.test_noSuchDeviceU  s2    
 ""$V[["F			
rD   rh   N)r[   r\   r]   r^   r_   r`  r`   ra   rb   s   @rA   r^  r^  P  s     
 
rD   r^  c                       ] tR tRtRtRtR# )MemoryIOSystemTestsi`  zD
General L{_IInputOutputSystem} tests applied to L{MemoryIOSystem}.
rh   Nr  rh   rD   rA   rc  rc  `  r  rD   rc  c                       ] tR tRtRtRtR# )RealIOSystemTestsih  zA
General L{_IInputOutputSystem} tests applied to L{_RealSystem}.
rh   Nr  rh   rD   rA   re  re  h  s    rD   re  c                V    V ^8  d   Qh/ ^ \         9   d   \        \        ,          ;R&   # )   r3  )__conditional_annotations__r   r  )r  s   "rA   __annotate__ri     s"      "  hsm #rD   )orh  r_   r   r   r   collectionsr   r   r   r   r   r   r   r   r	   	itertoolsr
   randomr   signalr   typingr   twisted.python.reflectr   r   r3  r  zope.interfacer   r   zope.interface.verifyr   twisted.internet.errorr   twisted.internet.interfacesr   r   r   twisted.internet.protocolr   r   r   twisted.internet.taskr   twisted.pair.ethernetr   twisted.pair.ipr   twisted.pair.rawr   twisted.pair.rawudpr   twisted.python.compatr   twisted.python.logr    r!   r"   r#   twisted.trial.unittestr$   r%   objectr4   r3   twisted.pair.testingr&   r'   r(   r)   r*   r+   r,   r-   twisted.pair.tuntapr.   r/   r0   r1   r2   r4  r6   re   rj   r   r   r   r  r  setattrr   r  r  r  r  r0  r6  r9  r;  rF  r  r  rC  rT  rV  r\  r^  rc  re  ri  )rh  s   @rA   <module>r     s  
 
    K K K     ; ] L 1 . 4 O O 
 ( 2 & / . + M M 5 @
     	 	 	   D ]'" '" '"T ]LN +$ $M M`f fRB% Bf* f*R 202E ))+=+K+KPU02E ))+=+K+KPT02E  //1C1Q1QR  !J[ J "JZ   (?02E?&@02E@ 9) 9*r
 r
j)
, )
XW,!4 W,t  2  !$#!4 #	' 0 	'-!4 -
 
 +-A*,?AU a* 	' =<L=s   J5 5KK