
    h                         S r SSKrSSKJrJr  SSKJr  SSKJr   " S S\5      r	 " S S	5      r
\" \	5       " S
 S\R                  5      5       rg)z1Support for working directly with ethernet frames    N)	Interfaceimplementer)protocol)rawc                   $    \ rS rSrSrS rS rSrg)IEthernetProtocol   z6An interface for protocols that handle Ethernet framesc                     g)z"Add an IRawPacketProtocol protocolN )numprotos     \/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/pair/ethernet.pyaddProtoIEthernetProtocol.addProto           c                     g)z#An Ethernet frame has been receivedNr   )datapartials     r   datagramReceived"IEthernetProtocol.datagramReceived   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__r   r   r   r   r      s    @12r   r   c                       \ rS rSrS rSrg)EthernetHeader   c                 ^    [         R                  " SUS S 5      u  U l        U l        U l        g )Nz!6s6sH   )structunpackdestsourcer   )selfr   s     r   __init__EthernetHeader.__init__   s)    /5}}d;Y'0
,DKr   )r%   r   r&   N)r   r   r   r   r(   r   r   r   r   r   r      s    
r   r   c                   *    \ rS rSrS rS rSS jrSrg)EthernetProtocol#   c                     0 U l         g )NetherProtos)r'   s    r   r(   EthernetProtocol.__init__%   s
    r   c                     [         R                  " U5      nUS:  a  [        S5      eUS:  a  [        S5      eXR                  ;  a  / U R                  U'   U R                  U   R	                  U5        g )Nr   z'Added protocol must be positive or zeroi   z"Added protocol must fit in 16 bits)r   IRawPacketProtocol	TypeErrorr/   append)r'   r   r   s      r   r   EthernetProtocol.addProto(   sm    &&u-7EFF%<@AA&&&$&DS!$$U+r   c           	          [        US S 5      nU R                  R                  UR                  S5       H7  nUR	                  USS  UUR
                  UR                  UR                  S9  M9     g )Nr"   r   )r   r   r%   r&   r   )r   r/   getr   r   r%   r&   )r'   r   r   headerr   s        r   r   !EthernetProtocol.datagramReceived2   sg    Sb	*%%))&,,;E"""#Y[[}} #  <r   r.   N)r   )r   r   r   r   r(   r   r   r   r   r   r   r+   r+   #   s    ,	r   r+   )r   r#   zope.interfacer   r   twisted.internetr   twisted.pairr   r   r   AbstractDatagramProtocolr+   r   r   r   <module>r>      sS    8  1 % 2	 2
 
 x88   r   