
    h#
                         d Z ddlmZmZmZ ddlmZ  G d de          Z G d d          Z	 e	            Z
 G d d	e          Z G d
 dee          Z G d dee          ZdS )ag  
.. centered::
    NOTICE
    This software/technical data was produced for the U.S. Government
    under Prime Contract No. NASA-03001 and JPL Contract No. 1295026
    and is subject to FAR 52.227-14 (6/87) Rights in Data General,
    and Article GP-51, Rights in Data  General, respectively.
    This software is publicly released under MITRE case #12-3054
    )FieldFieldLenFieldLenField)rawc                       e Zd Zd ZdS )SDNVValueErrorc                     || _         d S NmaxValueselfr   s     V/mounts/lovelace/software/anaconda3/lib/python3.11/site-packages/scapy/contrib/sdnv.py__init__zSDNVValueError.__init__            N)__name__
__module____qualname__r    r   r   r   r      s#        ! ! ! ! !r   r   c                   .    e Zd ZddZd Zd Zd Zd ZdS )	SDNV    c                     || _         d S r
   r   r   s     r   r   zSDNV.__init__   s     r   c                     || _         d S r
   r   r   s     r   setMaxzSDNV.setMax#   r   r   c                     | j         S r
   r   )r   s    r   getMaxzSDNV.getMax&   s
    }r   c                     || j         k    rt          | j                   t                      }|                    |dz             |dz	  }|dk    r=|dz  }|dz  }|dz	  }t                      }|                    |           ||z   }|dk    =|S )N      r      )r   r   	bytearrayappend)r   numberfoothisBytetemps        r   encodezSDNV.encode)   s    DM!! ///kk

6D=!!!1zz}HHq[F;;DKK!!!*C zz 
r   c                    d}d}||         }|dz  }|dz  dk    rE|dz  }|| j         k    rt          | j                   |||z            }||dz  z  }|dz  }|dz  dk    E|| j         k    rt          | j                   ||fS )Nr      r    r"   r!   )r   r   )r   baoffsetr%   numBytesbs         r   decodezSDNV.decode;   s    vJd(4x4q[F&&$T]3336H$%Aq4x FMH 4x4 T]"" ///xr   N)r   )r   r   r   r   r   r   r)   r0   r   r   r   r   r      sd           ! ! !    $         r   r   c                       e Zd ZdZd Zd ZdS )SDNV2z SDNV2 field c                 V    |t          t                              |                    z   S r
   )r   SDNVUtilr)   r   pktsvals       r   addfieldzSDNV2.addfieldS   s!    3xs++,,,,r   c                 t    t          |          }t                              |d          \  }}||d          |fS )Nr   )r#   r4   r0   )r   r6   r7   r/   r8   lens         r   getfieldzSDNV2.getfieldV   s6    aLL??1a((Sw|r   N)r   r   r   __doc__r9   r<   r   r   r   r2   r2   P   s8        - - -    r   r2   c                       e Zd Zd ZdS )SDNV2FieldLenFieldc           
      ~    |t          t                              t          j        | ||                              z   S r
   )r   r4   r)   r   i2mr5   s       r   r9   zSDNV2FieldLenField.addfield]   s0    3x}'8sC'H'HIIJJJJr   Nr   r   r   r9   r   r   r   r?   r?   \   s(        K K K K Kr   r?   c                       e Zd Zd ZdS )SDNV2LenFieldc           
      ~    |t          t                              t          j        | ||                              z   S r
   )r   r4   r)   r   rA   r5   s       r   r9   zSDNV2LenField.addfieldb   s/    3xx|D#s'C'CDDEEEEr   NrB   r   r   r   rD   rD   a   s(        F F F F Fr   rD   N)r=   scapy.fieldsr   r   r   scapy.compatr   	Exceptionr   r   r4   r2   r?   rD   r   r   r   <module>rI      s?    8 7 7 7 7 7 7 7 7 7      
! ! ! ! !Y ! ! !
,  ,  ,  ,  ,  ,  ,  , ^ 466	 	 	 	 	E 	 	 	K K K K K K K K
F F F F FHe F F F F Fr   