
    \d	                         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dS )z,Support for working directly with IP packets    N)implementer)protocol)rawc                       e Zd Zd ZdS )IPHeaderc           
      v   t          j        d|d d                   \
  }| _        | _        | _        }| _        | _        | _        }}t          j	        |          | _
        t          j	        |          | _        |dz  | _        |dz  dz	  dz  | _        |dz  | _        |dz  d	k    | _        |d
z  d	k    | _        d S )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         /lib/python3.11/site-packages/twisted/pair/ip.py__init__zIPHeader.__init__   s     M/495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#        5 5 5 5 5r$   r   l        c                        e Zd Zd Zd Zd ZdS )
IPProtocolc                     i | _         d S )N)ipProtos)r   s    r"   r#   zIPProtocol.__init__0   s    r$   c                     t          j        |          }|dk     rt          d          |t          k    rt          d          || j        vr
g | j        |<   | j        |                             |           d S )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.addProto3   s|    (//77EFFF(??@AAAdm##!#DM#c!!%(((((r$   c                 8   t          |          }| j                            |j        d          D ]i}|                    |dd          ||j        |j        |j        |j        |j        |j	        |j
        |j        |j        |j        |j        |j                   jd S )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|\JJ". & 6$2%4J #    	 	r$   N)r%   r&   r'   r#   r4   r:   r(   r$   r"   r*   r*   .   sA          ) ) )    r$   r*   )__doc__r   r   zope.interfacer   twisted.internetr   twisted.pairr   r   r0   IRawPacketProtocolAbstractDatagramProtocolr*   r(   r$   r"   <module>rB      s    3 2   & & & & & & % % % % % %      5 5 5 5 5 5 5 50  S#$$         2     %$     r$   