�
Ϫ�fhC � �0 � d Z ddlZddlZddlmZ ddlmZmZmZm Z m
Z
mZmZm
Z
ddlmZ ddlmZ ddlmZ ddlmZ dd lmZ dd
lmZ ddlmZmZmZmZ ddlm Z d
Z!d� Z"dZ#d� Z$d� Z%d� Z& G d� d� Z'd� Z( ee� G d� d� � Z) G d� d� Z*y)zD
Tools for automated testing of L{twisted.pair}-based applications.
� N)�deque)�EAGAIN�EBADF�EINTR�EINVAL�ENOBUFS�ENOSYS�EPERM�EWOULDBLOCK��wraps)�implementer)�DatagramProtocol)�EthernetProtocol)�
IPProtocol)�RawUDPProtocol)� _IFNAMSIZ�
_TUNSETIFF�TunnelFlags�_IInputOutputSystem)�nativeString� c �. � t j d| � S )z�
Pack an integer into a network-order two-byte string.
@param n: The integer to pack. Only values that fit into 16 bits are
supported.
@return: The packed representation of the integer.
@rtype: L{bytes}
z>H)�struct�pack)�ns �6/usr/lib/python3/dist-packages/twisted/pair/testing.py�_Hr s � � �;�;�t�Q��� � c �* � || z t |� z |z S )a�
Construct an ethernet frame.
@param src: The source ethernet address, encoded.
@type src: L{bytes}
@param dst: The destination ethernet address, encoded.
@type dst: L{bytes}
@param protocol: The protocol number of the payload of this datagram.
@type protocol: L{int}
@param payload: The content of the ethernet frame (such as an IP datagram).
@type payload: L{bytes}
@return: The full ethernet frame.
@rtype: L{bytes}
)r ��src�dst�protocol�payloads r � _ethernetr' |