o b@spdZddlZddlmZmZddlmZddlmZGdddeZ Gdd d Z ee Gd d d ej Z dS) z1Support for working directly with ethernet framesN) Interface implementer)protocol)rawc@s eZdZdZddZddZdS)IEthernetProtocolz6An interface for protocols that handle Ethernet framescCdS)z"Add an IRawPacketProtocol protocolN)numprotorr7/usr/lib/python3/dist-packages/twisted/pair/ethernet.pyaddProtozIEthernetProtocol.addProtocCr)z#An Ethernet frame has been receivedNr)datapartialrrr datagramReceivedr z"IEthernetProtocol.datagramReceivedN)__name__ __module__ __qualname____doc__r rrrrr rs rc@seZdZddZdS)EthernetHeadercCs$td|dd\|_|_|_dS)Nz!6s6sH)structunpackdestsourcer )selfrrrr __init__s zEthernetHeader.__init__N)rrrrrrrr rs rc@s&eZdZddZddZd ddZdS) EthernetProtocolcCs i|_dS)N) etherProtos)rrrr r&s zEthernetProtocol.__init__cCsRt|}|dkr td|dkrtd||jvrg|j|<|j||dS)Nrz'Added protocol must be positive or zeroiz"Added protocol must fit in 16 bits)rIRawPacketProtocol TypeErrorrappend)rr r rrr r )s   zEthernetProtocol.addProtorcCsLt|dd}|j|jdD]}|j|dd||j|j|jdqdS)Nrr)rrrrr)rrgetr rrr)rrrheaderr rrr r3s z!EthernetProtocol.datagramReceivedN)r)rrrrr rrrrr r$s r) rrzope.interfacerrtwisted.internetr twisted.pairrrrAbstractDatagramProtocolrrrrr s