
    h	                         S r SSKrSSKrSSKJr  SSKJr  SSKJr   " S S5      r	Sr
\" \R                  5       " S	 S
\R                  5      5       rg)z,Support for working directly with IP packets    N)implementer)protocol)rawc                       \ rS rSrS rSrg)IPHeader   c           
      r   [         R                  " SUS S 5      u
  nU l        U l        U l        nU l        U l        U l        nn[        R                  " U5      U l
        [        R                  " U5      U l        US-  U l        US-  S-	  S-  U l        US-  U l        US-  S	:g  U l        US
-  S	:g  U l        g )Nz!BBHHHBBH4s4s               i  i @  r   i    )structunpacktostot_lenfragment_idttlr   checksocket	inet_ntoasaddrdaddrversionihlfragment_offsetdont_fragmentmore_fragments)selfdata
ihlversionfrag_offr   r   s         V/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/pair/ip.py__init__IPHeader.__init__   s     MM/495	
HLHMJ%%e,
%%e,
!D($&1,2'&0%.!3&/14    )r   r   r   r   r   r   r   r   r   r   r   r   r   N)__name__
__module____qualname____firstlineno__r$   __static_attributes__ r&   r#   r   r      s    5r&   r   l        c                   &    \ rS rSrS rS rS rSrg)
IPProtocol-   c                     0 U l         g )NipProtos)r   s    r#   r$   IPProtocol.__init__/   s	    r&   c                     [         R                  " U5      nUS:  a  [        S5      eU[        :  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 zeroz"Added protocol must fit in 32 bits)r   IRawDatagramProtocol	TypeErrorMAX_SIZEr2   append)r   numprotos      r#   addProtoIPProtocol.addProto2   sg    ((/7EFF(?@AAmm#!#DMM#c!!%(r&   c                    [        U5      nU R                  R                  UR                  S5       H  nUR	                  USS  UUR
                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  UR                  S9  M     g )Nr,   r
   )r    partialsourcedestr   r   r   r   r   r   r   r   r   r   )r   r2   getr   datagramReceivedr   r   r   r   r   r   r   r   r   r   r   )r   r    r>   r@   r?   r   headerr:   s           r#   rB   IPProtocol.datagramReceived<   s    $]]&&v;E"""#Y||\\JJJJ".. & 6 6$22%44JJ #  <r&   r1   N)r'   r(   r)   r*   r$   r;   rB   r+   r,   r&   r#   r.   r.   -   s    )r&   r.   )__doc__r   r   zope.interfacer   twisted.internetr   twisted.pairr   r   r7   IRawPacketProtocolAbstractDatagramProtocolr.   r,   r&   r#   <module>rK      sV    3   & % 5 5.  S##$ 22   % r&   