ϪfdZddlZddlmZmZddlmZddlmZGddeZ Gdd Z ee Gd d ejZ y) z1Support for working directly with ethernet framesN) Interface implementer)protocol)rawceZdZdZdZdZy)IEthernetProtocolz6An interface for protocols that handle Ethernet framescy)z"Add an IRawPacketProtocol protocolN)numprotos 7/usr/lib/python3/dist-packages/twisted/pair/ethernet.pyaddProtozIEthernetProtocol.addProtocy)z#An Ethernet frame has been receivedNr )datapartials r datagramReceivedz"IEthernetProtocol.datagramReceivedrrN)__name__ __module__ __qualname____doc__rrr rr rrs@12rrceZdZdZy)EthernetHeaderc\tjd|dd\|_|_|_y)Nz!6s6sH)structunpackdestsourcer )selfrs r __init__zEthernetHeader.__init__s)/5}} d;Y'0 ,DKrN)rrrr"r rr rrs rrc eZdZdZdZddZy)EthernetProtocolci|_y)N) etherProtos)r!s r r"zEthernetProtocol.__init__%s rctj|}|dkr td|dk\r td||jvrg|j|<|j|j |y)Nrz'Added protocol must be positive or zeroiz"Added protocol must fit in 16 bits)rIRawPacketProtocol TypeErrorr&append)r!r r s r rzEthernetProtocol.addProto(so&&u- 7EF F %<@A A d&& &$&D  S ! $$U+rct|dd}|jj|jdD]9}|j |dd||j |j |j;y)Nrr )rrrr r)rr&getr rrr )r!rrheaderr s r rz!EthernetProtocol.datagramReceived2slSb *%%))&,,; E  " ""#Y[[}} #  rN)r)rrrr"rrr rr r$r$#s, rr$) rrzope.interfacerrtwisted.internetr twisted.pairrrrAbstractDatagramProtocolr$r rr r2sS8 1%2 2   x88 r