
    Ϫf	                         d Z ddlZddlZddlmZ ddlmZ ddlmZ  G d d      Z	dZ
 eej                         G d	 d
ej                               Zy)z,Support for working directly with IP packets    N)implementer)protocol)rawc                       e Zd Zd Zy)IPHeaderc           
      l   t        j                  d|d d       \
  }| _        | _        | _        }| _        | _        | _        }}t        j                  |      | _
        t        j                  |      | _        |dz  | _        |dz  dz	  dz  | _        |dz  | _        |dz  d	k7  | _        |d
z  d	k7  | _        y )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         1/usr/lib/python3/dist-packages/twisted/pair/ip.py__init__zIPHeader.__init__   s     MM/495	
HLHMJ%%e,
%%e,
!D($&1,2'&0%.!3&/14    N)__name__
__module____qualname__r#    r$   r"   r   r      s    5r$   r   l        c                       e Zd Zd Zd Zd Zy)
IPProtocolc                     i | _         y )N)ipProtos)r   s    r"   r#   zIPProtocol.__init__/   s	    r$   c                     t        j                  |      }|dk  rt        d      |t        k\  rt        d      || j                  vrg | j                  |<   | j                  |   j                  |       y )Nr   z'Added protocol must be positive or zeroz"Added protocol must fit in 32 bits)r   IRawDatagramProtocol	TypeErrorMAX_SIZEr,   append)r   numprotos      r"   addProtozIPProtocol.addProto2   si    ((/7EFF(?@AAdmm#!#DMM#c!!%(r$   c                    t        |      }| j                  j                  |j                  d      D ]  }|j	                  |dd  ||j
                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  |j                          y )Nr(   r	   )r   partialsourcedestr   r   r   r   r   r   r   r   r   r   )r   r,   getr   datagramReceivedr   r   r   r   r   r   r   r   r   r   r   )r   r   r6   r8   r7   r   headerr3   s           r"   r:   zIPProtocol.datagramReceived<   s    $]]&&v; 	E"""#Y||\\JJJJ".. & 6 6$22%44JJ # 	r$   N)r%   r&   r'   r#   r4   r:   r(   r$   r"   r*   r*   -   s    )r$   r*   )__doc__r   r   zope.interfacer   twisted.internetr   twisted.pairr   r   r0   IRawPacketProtocolAbstractDatagramProtocolr*   r(   r$   r"   <module>rB      sV    3   & % 5 5.  S##$ 22   % r$   