📄 smi_sec.c
字号:
/*
+-----------------------------------------------------------------------------
| Project : GSM-F&D (8411)
| Modul : SMI_SEC
+-----------------------------------------------------------------------------
| Copyright 2002 Texas Instruments Berlin, AG
| All rights reserved.
|
| This file is confidential and a trade secret of Texas
| Instruments Berlin, AG
| The receipt of or possession of this file does not convey
| any rights to reproduce or disclose its contents or to
| manufacture, use, or sell anything it may describe, in
| whole, or in part, without the specific written consent of
| Texas Instruments Berlin, AG.
+-----------------------------------------------------------------------------
| Purpose : This Modul defines the security and SIM handling for
| the component SMI of the mobile station
+-----------------------------------------------------------------------------
*/
#ifndef SMI_SEC_C
#define SMI_SEC_C
#endif
#define ENTITY_SMI
/*==== INCLUDES ===================================================*/
#include <string.h>
#include "typedefs.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "tok.h"
#include "message.h"
#include "aci_cmh.h"
#include "ksd.h"
#include "aca.h"
#include "smi.h"
/*==== CONSTANTS ==================================================*/
/*==== EXPORT =====================================================*/
/*==== TYPES ======================================================*/
typedef enum
{
SEC_RSLT_FAIL = 0, /* security request failed with unspecific */
/* error */
SEC_RSLT_REG = 1 /* password registration passed */
}
T_SEC_ACA_RSLT;
/*==== VARIABLES ==================================================*/
LOCAL T_ACI_AT_CMD currSecCmd = AT_CMD_NONE;
/*==== FUNCTIONS ==================================================*/
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SEC |
| STATE : code ROUTINE : sec_initialize |
+--------------------------------------------------------------------+
PURPOSE : This function is used to initialize this modul.
*/
GLOBAL void sec_initialize (BOOL isStartup)
{
currSecCmd = AT_CMD_NONE;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SEC |
| STATE : code ROUTINE : sec_pinEntered |
+--------------------------------------------------------------------+
PURPOSE : This function will be called after a couple of keypad
indications leads to the end of the user input for the
PIN.
<input>: entered PIN
*/
GLOBAL void sec_pinEntered (CHAR *input)
{
T_ACI_RETURN ret; /* holds status information */
TRACE_FUNCTION ("sec_pinEntered ()");
/*
*-----------------------------------------------------------------
* call to ACI function when no answer on a further ACI function
* call is expected
*-----------------------------------------------------------------
* if no PIN is entered do not try to evaluate
*-----------------------------------------------------------------
*/
if (strlen (input) AND currSecCmd EQ AT_CMD_NONE)
{
ret = sAT_PlusCPIN(CMD_SRC_LCL, input, NULL);
currSecCmd = AT_CMD_CPIN;
/*
*---------------------------------------------------------------
* process result code of ACI function call
*---------------------------------------------------------------
*/
switch (ret)
{
case (AT_CMPL):
rAT_OK (currSecCmd);
break;
case (AT_EXCT):
break;
default:
rAT_PlusCME (currSecCmd, CME_ERR_Unknown);
break;
}
}
else
ui_signal (UI_SIG_ENTER_PIN);
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SEC |
| STATE : code ROUTINE : sec_pukEntered |
+--------------------------------------------------------------------+
PURPOSE : This function will be called after a couple of keypad
indications leads to the end of the user input for the
PUK.
<puk>: entered PUK
<npin1>: entered new PIN first time
<npin2>: entered new PIN second time
*/
GLOBAL void sec_pukEntered (CHAR* puk, CHAR* npin1, CHAR* npin2)
{
T_ACI_RETURN ret; /* holds status information */
TRACE_FUNCTION ("sec_pukEntered ()");
/*
*-----------------------------------------------------------------
* call to ACI function when no answer on a further ACI function
* call is expected
*-----------------------------------------------------------------
* try to evaluate only if the PUK and both PINs are entered and
* both PINs have the same content
*-----------------------------------------------------------------
*/
if (strlen (puk) > 0 AND
strlen (npin1) > 0 AND
strlen (npin2) > 0 AND
strcmp (npin1, npin2) EQ 0 AND
currSecCmd EQ AT_CMD_NONE)
{
ret = sAT_PlusCPIN(CMD_SRC_LCL, puk, npin1);
currSecCmd = AT_CMD_CPIN;
/*
*---------------------------------------------------------------
* process result code of ACI function call
*---------------------------------------------------------------
*/
switch (ret)
{
case (AT_CMPL):
rAT_OK (currSecCmd);
break;
case (AT_EXCT):
break;
default:
rAT_PlusCME (currSecCmd, CME_ERR_Unknown);
break;
}
}
else
ui_signal (UI_SIG_ENTER_PUK);
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SEC |
| STATE : code ROUTINE : sec_CpinCnf |
+--------------------------------------------------------------------+
PURPOSE : This funciton is called when PIN or PUK is confirmed.
*/
GLOBAL void sec_CpinCnf (T_ACI_AT_CMD cmdId)
{
TRACE_FUNCTION ("sec_CpinCnf ()");
if (cmdId EQ currSecCmd)
currSecCmd = AT_CMD_NONE;
else
return;
/*
if (mmi_data->state EQ MMI_WAIT_FOR_PIN OR
mmi_data->state EQ MMI_WAIT_FOR_PUK)
*/
{
if ( reg_startReg () EQ AT_EXCT )
reg_pinState (TRUE, FALSE);
else
reg_pinState (TRUE, TRUE);
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SEC |
| STATE : code ROUTINE : sec_CpinRej |
+--------------------------------------------------------------------+
PURPOSE : This function is called when PIN or PUK is not
confirmed.
<err>: error code
*/
GLOBAL void sec_CpinRej (T_ACI_AT_CMD cmdId, T_ACI_CME_ERR err)
{
TRACE_FUNCTION ("sec_CpinRej ()");
if (cmdId EQ currSecCmd)
currSecCmd = AT_CMD_NONE;
switch (err)
{
case (CME_ERR_WrongPasswd):
if (mmi_data->state EQ MMI_WAIT_FOR_PIN)
ui_signal (UI_SIG_ENTER_PIN);
else if (mmi_data->state EQ MMI_WAIT_FOR_PUK)
ui_signal (UI_SIG_ENTER_PUK);
else
ui_signal (UI_SIG_UNHND_CME_ERR, err);
break;
case (CME_ERR_SimPukReq):
if (mmi_data->state EQ MMI_WAIT_FOR_PIN)
{
mmi_data->state = MMI_WAIT_FOR_PUK;
ui_signal (UI_SIG_ENTER_PUK);
}
else
ui_signal (UI_SIG_UNHND_CME_ERR, err);
break;
case (CME_ERR_SimFail):
case (CME_ERR_SimWrong):
if (mmi_data->state EQ MMI_WAIT_FOR_PUK)
ui_signal (UI_SIG_SIM_WRONG);
else
ui_signal (UI_SIG_UNHND_CME_ERR, err);
break;
default:
if (mmi_data->state EQ MMI_WAIT_FOR_PIN)
ui_signal (UI_SIG_ENTER_PIN);
else if (mmi_data->state EQ MMI_WAIT_FOR_PUK)
ui_signal (UI_SIG_ENTER_PUK);
else
ui_signal (UI_SIG_UNHND_CME_ERR, err);
break;
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SEC |
| STATE : code ROUTINE : sec_sigCpwd |
+--------------------------------------------------------------------+
PURPOSE : This function is used to signal the result of a change of
facility passwords to the user interface.
<rslt>: result code
*/
LOCAL void sec_sigCpwd (T_SEC_ACA_RSLT rslt)
{
TRACE_FUNCTION ("sec_sigCpwd ()");
ui_signal (UI_SIG_SEC, rslt);
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SEC |
| STATE : code ROUTINE : sec_regPasswd |
+--------------------------------------------------------------------+
PURPOSE : This function is used to register a new facility password.
<cpwd>: holds old / new passord and facility information
returns: status information concerning the register
progress
*/
GLOBAL T_ACI_RETURN sec_regPasswd (CHAR* seq, T_ACI_KSD_PWD_PRM* prm)
{
T_ACI_RETURN ret = AT_FAIL;
TRACE_FUNCTION ("sec_regPasswd ()");
/*
*-----------------------------------------------------------------
* call to ACI function when no answer on a further ACI function
* call is expected
*-----------------------------------------------------------------
*/
if (currSecCmd EQ AT_CMD_NONE)
{
ret = sAT_Dn (CMD_SRC_LCL,
seq,
D_CLIR_OVRD_Default,
D_CUG_CTRL_NotPresent,
D_TOC_Voice);
currSecCmd = KSD_CMD_PWD;
/*
*---------------------------------------------------------------
* process result code of ACI function call
*---------------------------------------------------------------
*/
switch (ret)
{
case (AT_CMPL):
rAT_OK (currSecCmd);
break;
case (AT_EXCT):
break;
default:
rAT_PlusCME (currSecCmd, CME_ERR_Unknown);
break;
}
}
else
{
/*
*---------------------------------------------------------------
* error handling while waiting for answer on further ACI
* function call
*---------------------------------------------------------------
*/
ui_signal (UI_SIG_UNHND_CME_ERR, CME_ERR_Unknown);
ret = AT_CMPL;
}
return ret;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SEC |
| STATE : code ROUTINE : sec_CpwdCnf |
+--------------------------------------------------------------------+
PURPOSE : This function is called to confirm password registration.
*/
GLOBAL void sec_CpwdCnf (T_ACI_AT_CMD cmdId)
{
TRACE_FUNCTION ("sec_CpwdCnf ()");
if (cmdId EQ currSecCmd)
{
currSecCmd = AT_CMD_NONE;
sec_sigCpwd (SEC_RSLT_REG);
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SEC |
| STATE : code ROUTINE : sec_CpwdRej |
+--------------------------------------------------------------------+
PURPOSE : This function is called to reject password registration.
*/
GLOBAL void sec_CpwdRej (T_ACI_AT_CMD cmdId, T_ACI_CME_ERR err)
{
TRACE_FUNCTION ("sec_CpwdRej ()");
if (cmdId EQ currSecCmd)
currSecCmd = AT_CMD_NONE;
switch (err)
{
case (CME_ERR_WrongPasswd):
sec_sigCpwd (SEC_RSLT_FAIL);
break;
default:
ui_signal (UI_SIG_UNHND_CME_ERR, err);
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -