
    㢛iY                     l    d Z ddlZddlmZmZ ddlmZ d Z G d de          Z	 G d d	e          Z
dS )
z
PDU module    N)command_codesconsts)SMPP_ESME_ROKc                 p    t          j        d| dd                   d         }t          j        |          S )zExtract command from a PDUz>L      r   )structunpackr   get_command_name)pducodes     [/home/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/smpplib/pdu.pyextract_commandr      s3     =s1Q3x((+D)$///    c                       e Zd ZdZdZdS )default_clientzDummy clientr   N)__name__
__module____qualname____doc__sequence r   r   r   r   #   s        HHHr   r   c                       e Zd ZdZdZdZdZdZ e            fdZ	d Z
d Z ee
e          Zd Zd Zd	 Zd
 Zd ZddZd Zd ZdS )PDUz	PDU classr   Nc                 B    |t                      | _        dS || _        dS )z.Singleton dummy client will be used if omittedN)r   _client)selfclientkwargss      r   __init__zPDU.__init__0   s#    >)++DLLL!DLLLr   c                 6    | j         | j         n| j        j        S )zReturn global sequence number)	_sequencer   r   r   s    r   _get_sequencezPDU._get_sequence7   s    !%!;t~~L!	"r   c                     || _         dS )zSetter for sequenceN)r"   )r   r   s     r   _set_sequencezPDU._set_sequence<   s    !r   c                 4    | j                                         S )zReturn next sequence number)r   next_sequencer#   s    r   	_next_seqzPDU._next_seqB   s    |))+++r   c                 "    t          | d          S )z4Return True if this is a vendor PDU, False otherwisevendor)hasattrr#   s    r   	is_vendorzPDU.is_vendorF   s    tX&&&r   c                 ,    |                                   S )z5Return True if this is a request PDU, False otherwise)is_responser#   s    r   
is_requestzPDU.is_requestJ   s    ##%%%%r   c                 B    t          j        | j                  dz  rdS dS )z6Return True if this is a response PDU, False otherwisel        TF)r   get_command_codecommandr#   s    r   r/   zPDU.is_responseN   s&    )$,77*D 	4ur   c                 *    | j         t          k    rdS dS )z9Return True if this is an error response, False otherwiseTF)statusr   r#   s    r   is_errorzPDU.is_errorT   s    ;-''4ur   c                 j    || j         }	 t          j        |         }n# t          $ r d|z  cY S w xY w|S )zReturn status descriptionNz&Description for status 0x%x not found!)r5   r   DESCRIPTIONSKeyError)r   r5   descs      r   get_status_desczPDU.get_status_descZ   s\     >[F	E&v.DD 	E 	E 	E;fDDDD	E s    00c                    |dd         }t          j        d|          }|d         | _        t          |          | _        |d         | _        |d         | _        t          |          dk    r|                     |dd                    dS dS )zParse raw PDUr      >LLLL      N)	r	   r
   lengthr   r3   r5   r   lenparse_params)r   dataheaderchunkss       r   parsez	PDU.parseg   s      adw//Qi&t,,Qiq	t99r>>d233i((((( >r   c                     |                                  }t          |          dz   | _        t          j        | j                  }t          j        d| j        || j        | j	                  }||z   S )zGenerate raw PDUr=   r>   )
generate_paramsrB   _lengthr   r2   r3   r	   packr5   r   )r   bodycommand_coderE   s       r   generatezPDU.generate   s_     ##%%4yy2~$5dlCCWdlL$+t}]]}r   )N)r   r   r   r   rA   r3   r5   r"   r   r    r$   r&   propertyr   r)   r-   r0   r/   r6   r;   rG   rN   r   r   r   r   r   (   s        OFGFI,n.. " " " "" " "
" " " x}55H, , ,' ' '& & &       ) ) )4    r   r   )r   r	   smpplibr   r   smpplib.constsr   r   objectr   r   r   r   r   <module>rS      s   &    ) ) ) ) ) ) ) ) ( ( ( ( ( (0 0 0    V   
d d d d d& d d d d dr   