
    di                        d Z ddlZddlmZmZmZmZmZ ddlT ddl	T ddl
T ddlmZmZ ddlmZ ddlmZmZ ddlmZ i d	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*i d+d,d-d.d/d0d1d2d3d4d5d6d7d6d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdGdIdGdGdGdGdJdKdLdMdNdOdPdQdRdSdTZ G dU dVe          Z G dW dXe          Z G dY dZe          Z G d[ d\e          Z G d] d^e          Z G d_ d`e          ZdS )aa  R-UIM (Removable User Identity Module) card profile (see 3GPP2 C.S0023-D)

(C) 2023 by Vadim Yanitskiy <fixeria@osmocom.org>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
    N)Bytewise	BitStructBitsIntegerStruct	FlagsEnum)*)CardProfileCardProfileAddon)CardProfileSIM)
DF_TELECOMDF_GSM)EF_ServiceTable   zCHV disable function   z!Abbreviated Dialing Numbers (ADN)   zFixed Dialing Numbers (FDN)   zShort Message Storage (SMS)   HRPD   zEnhanced Phone Book   zMulti Media Domain (MMD)   zSF_EUIMID-based EUIMID	   zMEID Support
   
Extension1   
Extension2   zSMS Parameters   zLast Number Dialled (LND)   z#Service Category Program for BC-SMS   zMessaging and 3GPD Extensions   zRoot Certificates   zCDMA Home Service Provider Name   zService Dialing Numbers (SDN)   
Extension3   z3GPD-SIP   zWAP Browser   Java   zReserved for CDG      zData Download via SMS Broadcast   zData Download via SMS-PP   zMenu Selection   zCall Control   zProactive R-UIM   AKA   IPv6    RFU!   "   z3GPD-MIPBCMCSz"Multimedia Messaging Service (MMS)zExtension 8z MMS User Connectivity ParameterszApplication AuthenticationzGroup Identifier Level 1zGroup Identifier Level 2zDe-Personalization Control KeyszCooperative Network List)#   $   %   &   '   (   )   *   +   ,   -   .   /   c                   @     e Zd ZdZddddddddfgZ	 	 d fd	Z xZS )EF_SPNz&3.4.31 CDMA Home Service Provider NameF010801536b796c696e6b204e57ffffffffffffffffffffffffffffffffffffffffffffr   Tr   r   z
Skylink NW)rfu1show_in_hsarfu2char_encodinglang_indspn6f41NEF.SPNService Provider Namer:   r:   c                 B    t                      j        |f||||d| t          dt          d          z  dt          z  dt          d          z  dt          d          z  d	t          d
          z  dt          t          d                    z            | _        d S )NsfidnamedescsizerJ   r   rK   rL   r   rM   r   rN   r   rO   r5   )	super__init__r   BitsRFUFlagr   r   	GsmString
_constructselffidrV   rW   rX   rY   kwargs	__class__s          =/home/jenkins/workspace/simtester-sanitize/pySim/cdma_ruim.pyr[   zEF_SPN.__init__b   s    S4dDSSFSSS#71::$71::KNN*{1~~%(9R==)))
 
    )rP   NrQ   rR   rS   )__name__
__module____qualname____doc___test_de_encoder[   __classcell__rd   s   @re   rH   rH   Y   sx        00 SqaH H	JO 4<4<
 
 
 
 
 
 
 
 
 
rf   rH   c                   d     e Zd ZdZdddddfgZdZ G d d	ej                  Z	 	 d fd	Z	 xZ
S )EF_ADz3.4.33 Administrative Data000000normals     rf   )ms_operation_modeadditional_inforfuTc                   &    e Zd ZdZdZdZdZdZdZdS )EF_AD.OP_MODEr      r      r   r   N)	rg   rh   ri   rq   type_approvalnormal_and_specific_facilities%type_approval_and_specific_facilitiesmaintenance_off_line	cell_test rf   re   OP_MODErv   z   s/        )-&04-#			rf   r   6f43NEF.ADAdministrative Datar   Nc                      t                      j        |f||||d| t          dt          t          | j                  z  dt          d          z  dt          z            | _        d S )NrU   rr   rs   r   rt   )	rZ   r[   r   EnumByter   BytesGreedyBytesRFUr_   r`   s          re   r[   zEF_AD.__init__   sl    S4dDSSFSSS T4< 8 88eAhh&. 
 
rf   )r   Nr   r   r   )rg   rh   ri   rj   rk   _test_no_padenumIntEnumr   r[   rl   rm   s   @re   ro   ro   r   s        $$ H+_bddfO L    $,    4;2;

 

 

 

 

 

 

 

 

 

rf   ro   c                   $     e Zd ZdZd fd	Z xZS )EF_SMSz3.4.27 Short Messages6f3cNEF.SMSShort messagesc                 p    t                      j        |f|||dd| t          dt          dt	          d          z  dt
          z  dt	          d          z  dt          t          d          dd	dd
          z  dt
          z            z  dt          z  dt          d           z            | _
        d S )N)r      )rV   rW   rX   rec_lenstatusrfu87r   
protectionrfu54r   r   r   )read
to_be_readsent
to_be_sentusedlengthtpduc                 ,    | j         j        r| j        ndS Nr   )r   r   r   )ctxs    re   <lambda>z!EF_SMS.__init__.<locals>.<lambda>   s    3:?%ISZZ rf   )rZ   r[   r   r   r\   r]   r   r   Int8ubr   r_   )ra   rb   rV   rW   rX   rc   rd   s         re   r[   zEF_SMS.__init__   s    Z4dxZZSYZZZ Y

"T!

";q>>aa\]^^^^t   VO5IIJJJ
 
rf   )r   Nr   r   )rg   rh   ri   rj   r[   rl   rm   s   @re   r   r      sC        
 
 
 
 
 
 
 
 
 
rf   r   c                        e Zd Z fdZ xZS )DF_CDMAc                     t                                          ddd           t          dd ddt          d	          t	                      t                      t                      g}|                     |           d S )
N7f25zDF.CDMAz$CDMA related files (3GPP2 C.S0023-D))rb   rW   rX   6f32zEF.CSTzCDMA Service Table)r   r!   )tablerY   )rZ   r[   r   
EF_CST_maprH   ro   r   	add_filesra   filesrd   s     re   r[   zDF_CDMA.__init__   s    V)D 	 	F 	F 	F FD(0
R R RHHGGHH
 	urf   )rg   rh   ri   r[   rl   rm   s   @re   r   r      s8                rf   r   c                   f     e Zd ZdZdZ fdZededefd            Z	e
deddfd	            Z xZS )
CardProfileRUIMz)R-UIM card profile as per 3GPP2 C.S0023-Dr&   c           
          t                                          ddddt                      t                      t	                      g           d S )NzR-UIMzCDMA R-UIM Carda00000)rX   clasel_ctrlfiles_in_mf)rZ   r[   r   r   r   )ra   rd   s    re   r[   zCardProfileRUIM.__init__   sR    '8d"(z||VXXwyy6Y 	 	[ 	[ 	[ 	[ 	[rf   data_hexreturnc                 *    t          j        |           S )N)r   decode_select_response)r   s    re   r   z&CardProfileRUIM.decode_select_response   s     4X>>>rf   sccNc                 :    |                      |ddddg           dS )z} Try to access MF/DF.CDMA via 2G APDUs (3GPP TS 11.11), if this works,
        the card is considered an R-UIM card for CDMA.r   r   3f00r   N)_mf_select_test)clsr   s     re   _try_match_cardzCardProfileRUIM._try_match_card   s)     	Cv/?@@@@@rf   )rg   rh   ri   rj   ORDERr[   staticmethodstrobjectr   classmethodSimCardCommandsr   rl   rm   s   @re   r   r      s        33E[ [ [ [ [ ? ? ? ? ? \? A/ Ad A A A [A A A A Arf   r   c                   2     e Zd ZdZ fdZdddefdZ xZS )	AddonRUIMzVAn Addon that can be found on on a combined SIM + RUIM or UICC + RUIM to support CDMA.c                 n    t                      g}t                                          dd|           d S )NRUIMz	CDMA RUIM)rX   r   )r   rZ   r[   r   s     re   r[   zAddonRUIM.__init__   s8    II
 	kuEEEEErf   cardCardBaser   c                 L    |                     | j        d         j                  S r   )file_existsr   rb   )ra   r   s     re   probezAddonRUIM.probe   s!     0 3 7888rf   )rg   rh   ri   rj   r[   boolr   rl   rm   s   @re   r   r      se        ``F F F F F9* 9 9 9 9 9 9 9 9 9rf   r   )rj   r   	constructr   r   r   r   r   osmocom.utilsosmocom.constructpySim.filesystempySim.profiler	   r
   pySim.ts_51_011r   r   r   r   r   TransparentEFrH   ro   
LinFixedEFr   CardDFr   r   r   r~   rf   re   <module>r      s   $  I I I I I I I I I I I I I I             7 7 7 7 7 7 7 7 * * * * * * . . . . . . . . + + + + + +00+0 %0 %	0
 0 0 "0  0 0 0 0 	0 	$0 	.0 	(0  	!0" 	*#0 0$ 	(%0& '0( )0* +0, -0. 	/00 	102 	*304 	#506 	708 90: 	;0< =0> ?0@ A0B C0D E0 0F 
					-		+	%	#	#	*	#_0 0 0
n
 
 
 
 
] 
 
 
2
 
 
 
 
M 
 
 
:
 
 
 
 
Z 
 
 
(    f   A A A A Ak A A A*	9 	9 	9 	9 	9  	9 	9 	9 	9 	9rf   