[LPA]1.add lpa code
This commit is contained in:
parent
840aa17540
commit
e21020dbac
|
@ -486,6 +486,13 @@ typedef struct _UIMenuUIMenuStoreInfo {
|
|||
CHAR PicUpDailyReport;
|
||||
///////////////////////
|
||||
#endif
|
||||
|
||||
CHAR ProfileSwitchFlg;
|
||||
CHAR ProfileEnableCmdVal;
|
||||
CHAR UpdateFlg;
|
||||
CHAR PreActiveProfileIccid[22];
|
||||
CHAR EsimEid[40];
|
||||
|
||||
|
||||
CHAR CamNameStr[13];
|
||||
CHAR PwdStr[7];
|
||||
|
|
3
code/application/source/sf_app/code/include/sf_commu_mcu_reg.h
Normal file → Executable file
3
code/application/source/sf_app/code/include/sf_commu_mcu_reg.h
Normal file → Executable file
|
@ -375,6 +375,9 @@ void sf_set_gprs_errno(SINT32 value);
|
|||
SINT32 sf_get_gprs_errno(void);
|
||||
BOOL sf_get_signal_ready_flag(void);
|
||||
void sf_set_signal_ready_flag(BOOL Flag);
|
||||
S32 sf_mcu_rebootall(U8 McuPoweroffVal);
|
||||
|
||||
|
||||
extern unsigned short TrigType;
|
||||
|
||||
|
||||
|
|
23
code/application/source/sf_app/code/include/sf_eg91_sim.h
Normal file → Executable file
23
code/application/source/sf_app/code/include/sf_eg91_sim.h
Normal file → Executable file
|
@ -16,6 +16,8 @@ extern "C" {
|
|||
#define MODULE_ICCID_LEN 20
|
||||
//500ms * 480 = 240s = 4min
|
||||
#define SF_QUECTEL_NET_REG_CALLTIME_MAX 480
|
||||
#define SF_MODULE_RESET_WAIT_TIME 30
|
||||
|
||||
|
||||
#define SF_NTP_SITE1 "time.windows.com"
|
||||
#define SF_NTP_SITE2 "time.nist.gov"
|
||||
|
@ -34,6 +36,7 @@ extern "C" {
|
|||
#define APNGPRSTEMP "CTNET"
|
||||
#define APNGPRSTEMP2 "3gnet"
|
||||
#define APNGPRSTEMP3 "CMNET"
|
||||
|
||||
typedef enum SIM_SLEEP_E
|
||||
{
|
||||
SIM_SLEEP_FIRST = (unsigned char)0x01,
|
||||
|
@ -167,7 +170,13 @@ typedef enum SF_QUECTEL_NETREG
|
|||
typedef enum _GPRS_MODULE_ERR_CODE_E{
|
||||
GPRS_MODULE_ERROR_OPEN = 1,
|
||||
GPRS_MODULE_ERROR_WRITE = 2,
|
||||
GPRS_MODULE_ERROR_READ = 3,
|
||||
GPRS_MODULE_ERROR_READ = 3,
|
||||
SIM_ERROR_SWITCH_PROFILE = 11,
|
||||
SIM_SWITCH_ATT_PROFILE = 12,
|
||||
SIM_SWITCH_VERIZON_PROFILE = 13,
|
||||
SIM_ERROR_REG_NET_TIMEOUT = 14,
|
||||
SIM_ERROR_REG_NET_REFUSE = 15,
|
||||
SIM_SWITCH_OTHER_PROFILE = 16,
|
||||
GPRS_MODULE_ERROR_BUTT,
|
||||
}GPRS_MODULE_ERR_CODE_e;
|
||||
|
||||
|
@ -175,6 +184,15 @@ typedef enum _GPRS_MODULE_ERR_CODE_E{
|
|||
#define SF_GPRS_MODULE_ERROR_WRITE SF_ERR_ID(SF_MOD_4G, GPRS_MODULE_ERROR_WRITE)
|
||||
#define SF_GPRS_MODULE_ERROR_READ SF_ERR_ID(SF_MOD_4G, GPRS_MODULE_ERROR_READ)
|
||||
|
||||
#define SF_SIM_ERROR_SWITCH_PROFILE SF_ERR_ID(SF_MOD_SIM, SIM_ERROR_SWITCH_PROFILE)
|
||||
#define SF_SIM_SWITCH_ATT_PROFILE SF_ERR_ID(SF_MOD_SIM, SIM_SWITCH_ATT_PROFILE)
|
||||
#define SF_SIM_SWITCH_VERIZON_PROFILE SF_ERR_ID(SF_MOD_SIM, SIM_SWITCH_VERIZON_PROFILE)
|
||||
#define SF_SIM_SWITCH_OTHER_PROFILE SF_ERR_ID(SF_MOD_SIM, SIM_SWITCH_OTHER_PROFILE)
|
||||
|
||||
#define SF_SIM_ERROR_REG_NET_TIMEOUT SF_ERR_ID(SF_MOD_SIM, SIM_ERROR_REG_NET_TIMEOUT)
|
||||
#define SF_SIM_ERROR_REG_NET_REFUSE SF_ERR_ID(SF_MOD_SIM, SIM_ERROR_REG_NET_REFUSE)
|
||||
|
||||
|
||||
typedef enum _SIM_ERR_CODE_E{
|
||||
SIM_COM_SUCCEED = 0,
|
||||
SIM_ERROR_NO_SIGNAL = 1,
|
||||
|
@ -306,6 +324,9 @@ SINT32 sf_net_regist_manual(void);
|
|||
|
||||
SINT32 sf_auto_net_reg(void);
|
||||
|
||||
int sf_get_operatorname(char *strname);
|
||||
|
||||
|
||||
SINT32 eg915q_set_usbnet(SF_FN_PARAM_S *pfnParam);
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -16,6 +16,29 @@ extern "C" {
|
|||
#define SF_APP_ERROR_WRITE SF_ERR_ID(SF_MOD_APP, ERROR_WRITE)
|
||||
#define SF_APP_ERROR_FILE_SEND SF_ERR_ID(SF_MOD_APP, ERROR_FILE_SEND)
|
||||
|
||||
#define SF_STRLEN(a) (UINT32)strlen((char *)a)
|
||||
#define SF_STRCPY(a, b) strcpy((char *)a, (char *)b)
|
||||
#define SF_STRNCPY(a, b, c) strncpy((char *)a, (char *)b, c)
|
||||
#define SF_STRCMP(a, b) strcmp((char *)a, (char *)b)
|
||||
#define SF_STRNCMP(a, b, c) strncmp((char *)a, (char *)b, c)
|
||||
#define SF_STRSTR(a, b) (UINT8 *)strstr((char *)a, (char *)b)
|
||||
#define SF_STRTOK(a, b) (UINT8 *)strtok((char *)a, (char *)b)
|
||||
#define SF_SPRINTF(a, ...) sprintf((char *)a, __VA_ARGS__)
|
||||
#define SF_STRCASECMP(a, b) strcasecmp((char *)a, (char *)b)
|
||||
#define SF_STRSEP(a, b) strsep((char **)a, (char *)b)
|
||||
#define SF_STRCAT(a, b) strcat((char *)a, (char *)b)
|
||||
#define SF_STRTOLL(a, b, c) strtoll((char *)a, (char **)b, c)
|
||||
#define SF_MEMSET(a, b, c) memset((void *) a, (char) b, (int) c)
|
||||
|
||||
#define SF_OPEN(a, b, c) open((void *) a, (int) b, (int) c)
|
||||
#define SF_CLOSE(a) close((int) a)
|
||||
#define SF_READ(a, b, c) read((int) a, (char *)b, (int) c)
|
||||
#define SF_WRITE(a, b, c) write((int) a, (char *)b, (int) c)
|
||||
#define SF_SEEK(a, b, c) lseek((int) a, (int) b, (int) c)
|
||||
#define SF_SYNC() sync()
|
||||
#define SF_DELETE(a) remove((char *)a)
|
||||
#define SF_RENAME(a, b) rename((char *)a, (char *)b)
|
||||
|
||||
#define SF_APP_CHECK_RANGE(cmd, min,max) \
|
||||
do { \
|
||||
if(cmd < min || cmd > max)\
|
||||
|
@ -39,6 +62,19 @@ typedef enum SF_CMD_TYPE_E {
|
|||
SF_CMD_SYNC_CFG,
|
||||
SF_CMD_BUTT
|
||||
} SF_CMD_TYPE_E;
|
||||
|
||||
typedef struct SF_OPERATORS_LIST_S
|
||||
{
|
||||
UINT8 OperatorNameLong[20];
|
||||
UINT8 OperatorNameShort[10];
|
||||
UINT8 OperatorNum[10];
|
||||
UINT8 SignalVal;
|
||||
UINT8 NetType;
|
||||
UINT8 Index;
|
||||
struct SF_OPERATORS_LIST_S *pPre;
|
||||
struct SF_OPERATORS_LIST_S *pNext;
|
||||
} SF_OPERATORS_LIST_T;
|
||||
|
||||
typedef struct sf_gps_param {
|
||||
int timeout_ms;
|
||||
int period_ms;
|
||||
|
@ -63,6 +99,7 @@ SINT32 open_gps(const SINT32 utc);
|
|||
int get_gps_location(void);
|
||||
void keep_get_gps_location(const SF_GPS_PARAM param);
|
||||
void keep_seraching_gps_location(const int timeout_ms);
|
||||
void app_RegisterNet_stop();
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
2
code/application/source/sf_app/code/include/sf_wifi_svr.h
Normal file → Executable file
2
code/application/source/sf_app/code/include/sf_wifi_svr.h
Normal file → Executable file
|
@ -17,7 +17,7 @@
|
|||
#define LISTEN_PARAM 5
|
||||
#endif
|
||||
|
||||
#define SF_LPA_SDK 0
|
||||
#define SF_LPA_SDK 1
|
||||
#define DEBUG_INFO_ON_LCD 0
|
||||
#define DBG_LOG 0
|
||||
|
||||
|
|
2060
code/application/source/sf_app/code/source/4gMng/sf_4G_sms_lpa_cmd.c
Executable file
2060
code/application/source/sf_app/code/source/4gMng/sf_4G_sms_lpa_cmd.c
Executable file
File diff suppressed because it is too large
Load Diff
3395
code/application/source/sf_app/code/source/4gMng/sf_4g_lpa.c
Executable file
3395
code/application/source/sf_app/code/source/4gMng/sf_4g_lpa.c
Executable file
File diff suppressed because it is too large
Load Diff
|
@ -14,7 +14,7 @@ extern "C" {
|
|||
|
||||
#include "sf_hal_ttyusb.h"
|
||||
#include "sf_systemMng.h"
|
||||
|
||||
#include "sf_commu_mcu_reg.h"
|
||||
#include "sf_opera_adapt.h"
|
||||
#include "sf_eg91_sim.h"
|
||||
#include "sf_param_common.h"
|
||||
|
@ -94,6 +94,85 @@ void eg91_mark_time_set(unsigned long int MarkTime)
|
|||
LocateTime = MarkTime;
|
||||
}
|
||||
|
||||
static UINT8 gSIMCardReady = 0; /*0: Init Status, 1: Ready, 2: No SIM Card*/
|
||||
void sf_set_simcard_ready(UINT8 readyFlag)
|
||||
{
|
||||
gSIMCardReady = readyFlag;
|
||||
}
|
||||
|
||||
UINT8 sf_get_simcard_ready()
|
||||
{
|
||||
return gSIMCardReady;
|
||||
}
|
||||
|
||||
static int gModuleResetFlag = 0;
|
||||
|
||||
int sf_get_module_reset_flag()
|
||||
{
|
||||
return gModuleResetFlag;
|
||||
}
|
||||
|
||||
void sf_set_module_reset_flag(int flag)
|
||||
{
|
||||
gModuleResetFlag= flag;
|
||||
}
|
||||
|
||||
|
||||
void sf_module_reset()
|
||||
{
|
||||
gModuleResetFlag = 1;
|
||||
sf_hal_ttyusb2_deinit();
|
||||
sf_mcu_reg_set(SF_MCU_RESET_MODULE, 0);
|
||||
sleep(SF_MODULE_RESET_WAIT_TIME);
|
||||
gModuleResetFlag = 0;
|
||||
}
|
||||
|
||||
|
||||
#define SF_OPERATORS_NAME_LEN 20
|
||||
|
||||
static UINT8 g_OperatorNameL[SF_OPERATORS_NAME_LEN] = {0};
|
||||
void sf_set_operatorname( const char *src)
|
||||
{
|
||||
|
||||
if(NULL != src)
|
||||
{
|
||||
if(strlen(src) < SF_OPERATORS_NAME_LEN)
|
||||
{
|
||||
strcpy(g_OperatorNameL, src);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int sf_get_operatorname(char *strname)
|
||||
{
|
||||
if(NULL != strname)
|
||||
{
|
||||
strncpy(strname, g_OperatorNameL, SF_OPERATORS_NAME_LEN - 1);
|
||||
strname[SF_OPERATORS_NAME_LEN - 1] = '\0';
|
||||
return strlen(g_OperatorNameL);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
void sf_clear_operatorname()
|
||||
{
|
||||
memset(g_OperatorNameL, 0, sizeof(g_OperatorNameL));
|
||||
}
|
||||
|
||||
static int gLpaSwitchFlag=0;
|
||||
int sf_get_lpa_switch_flag()
|
||||
{
|
||||
return gLpaSwitchFlag;
|
||||
}
|
||||
|
||||
void sf_set_lpa_switch_flag(int flag)
|
||||
{
|
||||
gLpaSwitchFlag= flag;
|
||||
}
|
||||
|
||||
|
||||
static void eg91_parse_module_version_detail(SF_CHAR* pTemp, SF_CHAR *pT1, SF_CHAR *pT2, SF_CHAR *pT4, SF_CHAR *version)
|
||||
{
|
||||
UIMenuStoreInfo *sim_info_t = sf_app_ui_para_get();
|
||||
|
@ -2037,6 +2116,7 @@ SINT32 eg91_register_net_manual(SF_FN_PARAM_S *pfnParam)
|
|||
pStr = strtok(NULL, "\"");
|
||||
if(pStr != NULL)
|
||||
{
|
||||
sf_set_operatorname(pStr);
|
||||
strcpy(pStaticParam->ServiceProvider, pStr);
|
||||
printf("cops1 is %s\r\n", pStr);
|
||||
printf("cops2 is %s\r\n", pStaticParam->ServiceProvider);
|
||||
|
@ -5155,7 +5235,6 @@ SINT32 sf_add_cimi_id(char *cimi)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
|
|
@ -411,6 +411,10 @@ static SINT32 process_cmd_longclick(SF_MESSAGE_BUF_S *pMessageBuf)
|
|||
break;
|
||||
case SF_KEY_PIN_SYNC:
|
||||
|
||||
#if SF_LPA_SDK
|
||||
SLOGD("[Long]KEY_TEST.\n");
|
||||
sf_network_switch();
|
||||
#endif
|
||||
// if(upgrade_ota_file_IsExsit(SF_OTA_UPGRADE_FILE_PATH) == SF_FALSE)
|
||||
// break;
|
||||
//
|
||||
|
|
|
@ -119,12 +119,16 @@ SINT32 app_ttyusb_IsOpen(void) {
|
|||
return s32ret;
|
||||
}
|
||||
|
||||
SINT32 sf_ttyusb_restart(void) {
|
||||
SINT32 sf_ttyusb_restart(void)
|
||||
{
|
||||
SINT32 ret = 0;
|
||||
ret = sf_hal_ttyusb2_deinit();
|
||||
if (ret != 0) {
|
||||
if (ret != 0)
|
||||
{
|
||||
MLOGE("-------ttyUSB deinit fail!\n");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
sf_mcu_reg_set(SF_MCU_RESET_MODULE, 0);
|
||||
sleep(5);
|
||||
ret = app_ttyusb_IsOpen();
|
||||
|
@ -163,43 +167,53 @@ static SINT16 app_Qlog_procress(void) {
|
|||
return s32ret;
|
||||
}
|
||||
#endif
|
||||
SINT32 sf_USB_net_init(void) {
|
||||
SINT32 sf_USB_net_init(void)
|
||||
{
|
||||
//SF_CHAR cmdStr[128] = {0};
|
||||
//char cmdtmp[20] = {0};
|
||||
UINT8 i = 0;
|
||||
int ret = SF_SUCCESS;
|
||||
static U16 flag = 0;
|
||||
UIMenuStoreInfo *puiPara = sf_app_ui_para_get();
|
||||
|
||||
if (ret == SF_SUCCESS) {
|
||||
if(AT_MANAGER_SUCCEED != at_usbnet_init()){
|
||||
if (flag == 0)
|
||||
{
|
||||
flag = 1;
|
||||
if(AT_MANAGER_SUCCEED != at_usbnet_init())
|
||||
{
|
||||
MLOGE("usb net err %d\n", AT_MANAGER_SUCCEED);
|
||||
}else {
|
||||
for (i = 0; i < 20; i++) {
|
||||
if(strncmp(puiPara->ModuleVer, GPRS_MODULE_TYPE_EG915Q, 6) == 0){
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
if(strncmp(puiPara->ModuleVer, GPRS_MODULE_TYPE_EG915Q, 6) == 0)
|
||||
{
|
||||
ret = sf_check_usb0();
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = sf_check_eth0();
|
||||
}
|
||||
if (SUCCESS == ret) {
|
||||
if (SUCCESS == ret)
|
||||
{
|
||||
ret = SF_SUCCESS;
|
||||
MLOGI("usb net ip up\r\n");
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*if (sf_poweron_type_get() == SF_MCU_STARTUP_RING) {
|
||||
sleep(2);
|
||||
} else {
|
||||
sleep(5);
|
||||
}*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
printf("usb net ko no exist!\r\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
SINT32 app_gps_map_update(SF_FN_PARAM_S *pfnParam) {
|
||||
SINT16 ret = SF_SUCCESS;
|
||||
|
@ -1239,327 +1253,461 @@ static SINT32 app_Register_Net_Error_return_server(SF_FN_PARAM_S *pfnParam,
|
|||
sf_4G_status_set(SF_4G_FREE);
|
||||
return SF_SUCCESS;
|
||||
}
|
||||
static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) {
|
||||
SINT32 s32ret = 0;
|
||||
// UINT8 timeCnt = 0;
|
||||
// UINT8 bIsKeepConnect = 0;
|
||||
// SF_CHAR version[12] = {0};
|
||||
// SF_MESSAGE_BUF_S stMessageBuf = {0};
|
||||
// SF_PDT_PARAM_CFG_S *pCustomerParam = pfnParam->pstParam;
|
||||
// SF_PDT_PARAM_STATISTICS_S *pStaticParam = pfnParam->pstaticParam;
|
||||
UIMenuStoreInfo *pCustomerParam = sf_app_ui_para_get();
|
||||
sf_log_Level_set(SF_LOG_LEVEL_DEBUG);
|
||||
static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam)
|
||||
{
|
||||
SINT32 s32ret = 0;
|
||||
SF_CHAR simICCID[24] = { 0 };
|
||||
SF_CHAR eid[40] = {0};
|
||||
SF_CHAR sim4gApn[40] = {0};
|
||||
UIMenuStoreInfo *pCustomerParam = sf_app_ui_para_get();
|
||||
|
||||
if (sf_usb_IsInsert())
|
||||
return SF_SUCCESS;
|
||||
sf_log_Level_set(SF_LOG_LEVEL_DEBUG);
|
||||
|
||||
sf_4G_status_set(SF_4G_SEARCHING);
|
||||
if (sf_usb_IsInsert())
|
||||
return SF_SUCCESS;
|
||||
|
||||
switch (sf_poweron_type_get()) {
|
||||
case SF_MCU_STARTUP_OFF:
|
||||
break;
|
||||
sf_4G_status_set(SF_4G_SEARCHING);
|
||||
|
||||
case SF_MCU_STARTUP_ONKEY:
|
||||
switch (sf_poweron_type_get()) {
|
||||
case SF_MCU_STARTUP_OFF:
|
||||
break;
|
||||
|
||||
case SF_MCU_STARTUP_ONKEY:
|
||||
|
||||
#ifdef SF_HARDWARE_TEST
|
||||
break;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef SF_GPS_TEST
|
||||
sf_commu_set_mcu(19, 1);
|
||||
sf_commu_set_mcu(20, 1);
|
||||
sf_commu_set_mcu(84, 1);
|
||||
sf_commu_set_mcu(19, 1);
|
||||
sf_commu_set_mcu(20, 1);
|
||||
sf_commu_set_mcu(84, 1);
|
||||
#endif
|
||||
app_led_net_reg_start();
|
||||
app_led_net_reg_start();
|
||||
|
||||
s32ret = app_ttyusb_IsOpen();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, s32ret);
|
||||
s32ret = app_ttyusb_IsOpen();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, s32ret);
|
||||
|
||||
#if SF_QLOG_ENABLE
|
||||
if (pCustomerParam->QLogSwitch == 1)
|
||||
app_Qlog_procress();
|
||||
if (pCustomerParam->QLogSwitch == 1)
|
||||
app_Qlog_procress();
|
||||
#endif
|
||||
|
||||
s32ret = sf_4G_sim_init(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, s32ret);
|
||||
s32ret = sf_4G_sim_init(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, s32ret);
|
||||
|
||||
// sf_sys_software_version_get(version);
|
||||
// s32ret = sf_qrcode_create(pStaticParam->IMEI,pStaticParam->SimID
|
||||
//,version);
|
||||
#if SF_LPA_SDK
|
||||
|
||||
s32ret = sf_4G_register_net_manual(pfnParam);
|
||||
//sf_share_mem_customer_down(1);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, s32ret);
|
||||
sf_sample_lpa_init();
|
||||
|
||||
while(!sf_is_esim_init_finish())
|
||||
{
|
||||
usleep(100*1000);
|
||||
}
|
||||
|
||||
if(!sf_is_esim_card() || pCustomerParam->UpdateFlg)
|
||||
{
|
||||
if(pCustomerParam->UpdateFlg)
|
||||
{
|
||||
pCustomerParam->UpdateFlg = 0;
|
||||
//sf_set_param_save_flag();
|
||||
}
|
||||
|
||||
sf_sms_lpa_delete_lpa_log();
|
||||
}
|
||||
|
||||
if(sf_is_esim_card())
|
||||
{
|
||||
sf_get_eid(eid);
|
||||
printf("pPara->EsimEid=%s\n", pCustomerParam->EsimEid);
|
||||
printf("pPara->eid=%s\n", eid);
|
||||
if((pCustomerParam->EsimEid[0] != '\0') && (SF_STRCMP(pCustomerParam->EsimEid, eid) != 0))
|
||||
{
|
||||
sf_sms_lpa_delete_lpa_log();
|
||||
}
|
||||
|
||||
SF_STRCPY(pCustomerParam->EsimEid, eid);
|
||||
sf_sms_lpa_load_profile_apn((const SINT8 *)simICCID, (SINT8 *)sim4gApn);
|
||||
if(sim4gApn[0] != '\0')
|
||||
{
|
||||
SF_STRCPY(pCustomerParam->Sim4gApn, sim4gApn);
|
||||
SF_STRCPY(pCustomerParam->Sim4gPwd, "\0");
|
||||
SF_STRCPY(pCustomerParam->Sim4gUsr, "\0");
|
||||
#if 0
|
||||
SF_STRCPY(sim_info_t->MmsMmsc, "\0");
|
||||
SF_STRCPY(sim_info_t->MmsApn, "\0");
|
||||
SF_STRCPY(sim_info_t->MmsProxy, "\0");
|
||||
SF_STRCPY(sim_info_t->MmsPort, "\0");
|
||||
SF_STRCPY(sim_info_t->MmsUserName, "\0");
|
||||
SF_STRCPY(sim_info_t->MmsPassword, "\0");
|
||||
#endif
|
||||
printf("set profile Sim4gApn=%s\n", pCustomerParam->Sim4gApn);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
s32ret = sf_4G_register_net_manual(pfnParam);
|
||||
//sf_share_mem_customer_down(1);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, s32ret);
|
||||
#ifdef SF_GPS_TEST
|
||||
s32ret = app_gps_map_update(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_NO_SUPPOET);
|
||||
s32ret = app_gps_map_update(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_NO_SUPPOET);
|
||||
|
||||
s32ret = app_gps_info_get(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_NO_SUPPOET);
|
||||
s32ret = app_gps_info_get(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_NO_SUPPOET);
|
||||
|
||||
break;
|
||||
break;
|
||||
#endif
|
||||
s32ret = sf_get_utc();
|
||||
if ((s32ret == SF_SIM_ERROR_UTC) && (SF_ON != pCustomerParam->GpsSwitch)) {
|
||||
SF_PARA_TIME_S current_time = { 0, 0, 0, 0, 0, 0};
|
||||
s32ret = sf_get_ntp(s32ret, ¤t_time);
|
||||
}
|
||||
sf_4G_usb_net_apn_cfg(pfnParam);
|
||||
sf_USB_net_init();
|
||||
if ((SF_ON == pCustomerParam->GpsSwitch)) {
|
||||
s32ret = open_gps(s32ret);
|
||||
serach_gps_onkey_start();
|
||||
}
|
||||
s32ret = sf_get_utc();
|
||||
if ((s32ret == SF_SIM_ERROR_UTC) && (SF_ON != pCustomerParam->GpsSwitch)) {
|
||||
SF_PARA_TIME_S current_time = { 0, 0, 0, 0, 0, 0};
|
||||
s32ret = sf_get_ntp(s32ret, ¤t_time);
|
||||
}
|
||||
sf_4G_usb_net_apn_cfg(pfnParam);
|
||||
sf_USB_net_init();
|
||||
if ((SF_ON == pCustomerParam->GpsSwitch)) {
|
||||
s32ret = open_gps(s32ret);
|
||||
serach_gps_onkey_start();
|
||||
}
|
||||
|
||||
if(sf_get_signal_ready()){
|
||||
if(SUCCESS != sf_connect_ftps_server()){
|
||||
printf("[%s:%d]open ftps fail, reconnect\n", __FUNCTION__, __LINE__);
|
||||
if(SUCCESS != sf_connect_ftps_server()){
|
||||
printf("[%s:%d]re open ftps fail, reconnect\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, s32ret);
|
||||
if(sf_get_signal_ready()){
|
||||
if(SUCCESS != sf_connect_ftps_server()){
|
||||
printf("[%s:%d]open ftps fail, reconnect\n", __FUNCTION__, __LINE__);
|
||||
if(SUCCESS != sf_connect_ftps_server()){
|
||||
printf("[%s:%d]re open ftps fail, reconnect\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, s32ret);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case SF_MCU_STARTUP_NORMAL:
|
||||
break;
|
||||
case SF_MCU_STARTUP_NORMAL:
|
||||
break;
|
||||
|
||||
case SF_MCU_STARTUP_RING:
|
||||
case SF_MCU_STARTUP_RING:
|
||||
|
||||
s32ret = sf_4G_sim_IsInsert();
|
||||
if (!s32ret) {
|
||||
SF_APPCOMM_CHECK_RETURN(SF_FAILURE, SF_APP_ERROR_REQUEST);
|
||||
}
|
||||
s32ret = sf_4G_sim_IsInsert();
|
||||
if (!s32ret) {
|
||||
SF_APPCOMM_CHECK_RETURN(SF_FAILURE, SF_APP_ERROR_REQUEST);
|
||||
}
|
||||
|
||||
s32ret = app_ttyusb_IsOpen();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
s32ret = app_ttyusb_IsOpen();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
|
||||
#if SF_QLOG_ENABLE
|
||||
if (pCustomerParam->QLogSwitch == 1)
|
||||
app_Qlog_procress();
|
||||
if (pCustomerParam->QLogSwitch == 1)
|
||||
app_Qlog_procress();
|
||||
#endif
|
||||
|
||||
s32ret = sf_4G_sim_init(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
s32ret = sf_4G_sim_init(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
|
||||
s32ret = sf_4G_register_net_auto(pfnParam);
|
||||
//sf_share_mem_customer_down(1);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
sf_4G_usb_net_apn_cfg(pfnParam);
|
||||
sf_USB_net_init();
|
||||
s32ret = sf_4G_register_net_auto(pfnParam);
|
||||
//sf_share_mem_customer_down(1);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
sf_4G_usb_net_apn_cfg(pfnParam);
|
||||
sf_USB_net_init();
|
||||
|
||||
s32ret = sf_read_message();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
if (sf_get_pic()) {
|
||||
s32ret = sf_app_to_cardv_capture();
|
||||
}
|
||||
else if(sf_get_send_hd()){
|
||||
s32ret = sf_app_to_cardv_hd_ture();
|
||||
}
|
||||
else if(sf_get_send_video()){
|
||||
s32ret = sf_video_ftp_send();
|
||||
}
|
||||
break;
|
||||
s32ret = sf_read_message();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
if (sf_get_pic()) {
|
||||
s32ret = sf_app_to_cardv_capture();
|
||||
}
|
||||
else if(sf_get_send_hd()){
|
||||
s32ret = sf_app_to_cardv_hd_ture();
|
||||
}
|
||||
else if(sf_get_send_video()){
|
||||
s32ret = sf_video_ftp_send();
|
||||
}
|
||||
break;
|
||||
|
||||
case SF_MCU_STARTUP_TIMELAPSE:
|
||||
case SF_MCU_STARTUP_PIR:
|
||||
if (pCustomerParam->SendType != 0) {
|
||||
break;
|
||||
}
|
||||
case SF_MCU_STARTUP_TIMELAPSE:
|
||||
case SF_MCU_STARTUP_PIR:
|
||||
if (pCustomerParam->SendType != 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
case SF_MCU_STARTUP_BATCH_SEND:
|
||||
case SF_MCU_STARTUP_BATCH_SEND:
|
||||
#ifdef SF_HARDWARE_TEST
|
||||
app_system_poweroff(SF_POWEROFF_NOT);
|
||||
break;
|
||||
app_system_poweroff(SF_POWEROFF_NOT);
|
||||
break;
|
||||
#endif
|
||||
|
||||
s32ret = sf_4G_sim_IsInsert();
|
||||
if (!s32ret) {
|
||||
SF_APPCOMM_CHECK_RETURN(SF_FAILURE, SF_APP_ERROR_REQUEST);
|
||||
}
|
||||
s32ret = sf_4G_sim_IsInsert();
|
||||
if (!s32ret) {
|
||||
SF_APPCOMM_CHECK_RETURN(SF_FAILURE, SF_APP_ERROR_REQUEST);
|
||||
}
|
||||
|
||||
s32ret = app_ttyusb_IsOpen();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
s32ret = app_ttyusb_IsOpen();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
|
||||
#if SF_QLOG_ENABLE
|
||||
if (pCustomerParam->QLogSwitch == 1)
|
||||
app_Qlog_procress();
|
||||
if (pCustomerParam->QLogSwitch == 1)
|
||||
app_Qlog_procress();
|
||||
#endif
|
||||
|
||||
s32ret = sf_4G_sim_init(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
s32ret = sf_4G_sim_init(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
|
||||
s32ret = sf_4G_register_net_auto(pfnParam);
|
||||
if (s32ret != SF_SUCCESS) {
|
||||
sf_set_signal_ready_flag(TRUE);
|
||||
}
|
||||
//sf_share_mem_customer_down(1);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
sf_4G_usb_net_apn_cfg(pfnParam);
|
||||
sf_USB_net_init();
|
||||
s32ret = sf_4G_register_net_auto(pfnParam);
|
||||
if (s32ret != SF_SUCCESS) {
|
||||
sf_set_signal_ready_flag(TRUE);
|
||||
}
|
||||
//sf_share_mem_customer_down(1);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
sf_4G_usb_net_apn_cfg(pfnParam);
|
||||
sf_USB_net_init();
|
||||
|
||||
s32ret = sf_file_send_auto();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
s32ret = sf_file_send_auto();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
|
||||
break;
|
||||
case SF_MCU_STARTUP_WARNING:
|
||||
break;
|
||||
case SF_MCU_STARTUP_WARNING:
|
||||
|
||||
break;
|
||||
case SF_MCU_STARTUP_SERVER:
|
||||
break;
|
||||
case SF_MCU_STARTUP_SERVER:
|
||||
|
||||
break;
|
||||
case SF_MCU_STARTUP_DP:
|
||||
break;
|
||||
case SF_MCU_STARTUP_DP:
|
||||
|
||||
s32ret = app_ttyusb_IsOpen();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
s32ret = app_ttyusb_IsOpen();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
|
||||
#if SF_QLOG_ENABLE
|
||||
if (pCustomerParam->QLogSwitch == 1)
|
||||
app_Qlog_procress();
|
||||
if (pCustomerParam->QLogSwitch == 1)
|
||||
app_Qlog_procress();
|
||||
#endif
|
||||
s32ret = sf_4G_sim_init(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
s32ret = sf_4G_sim_init(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
|
||||
s32ret = sf_4G_register_net_manual(pfnParam);
|
||||
if (s32ret != SF_SUCCESS) {
|
||||
sf_set_signal_ready_flag(TRUE);
|
||||
}
|
||||
|
||||
if (0 != sf_get_cq_signal()) {
|
||||
pCustomerParam->NeedTimeSyncStartUp = 1;
|
||||
}
|
||||
if (pCustomerParam->DailyReportSwitch) {
|
||||
pCustomerParam->GpsSendFlag = 1; // indicate need send dp file in b power on.
|
||||
}
|
||||
s32ret = sf_4G_register_net_manual(pfnParam);
|
||||
if (s32ret != SF_SUCCESS) {
|
||||
sf_set_signal_ready_flag(TRUE);
|
||||
}
|
||||
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
sf_4G_usb_net_apn_cfg(pfnParam);
|
||||
sf_USB_net_init();
|
||||
if (0 != sf_get_cq_signal()) {
|
||||
pCustomerParam->NeedTimeSyncStartUp = 1;
|
||||
}
|
||||
if (pCustomerParam->DailyReportSwitch) {
|
||||
pCustomerParam->GpsSendFlag = 1; // indicate need send dp file in b power on.
|
||||
}
|
||||
|
||||
s32ret = sf_get_utc();
|
||||
if ((s32ret == SF_SIM_ERROR_UTC) && (SF_ON != pCustomerParam->GpsSwitch)) {
|
||||
SF_PARA_TIME_S current_time = { 0, 0, 0, 0, 0, 0};
|
||||
s32ret = sf_get_ntp(s32ret, ¤t_time);
|
||||
}
|
||||
if ((SF_ON == pCustomerParam->GpsSwitch)) {
|
||||
s32ret = open_gps(s32ret);
|
||||
}
|
||||
if (1 == pCustomerParam->NeedTimeSyncStartUp) {
|
||||
printf("[%s:%d]8 between A and B,no reg net again,no reset time sync.\n",
|
||||
__FUNCTION__, __LINE__);
|
||||
sf_set_dr_reset_time_sys_flag(1);
|
||||
}
|
||||
//sf_dailyReport_set();
|
||||
//sf_share_mem_customer_down(1);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
sf_4G_usb_net_apn_cfg(pfnParam);
|
||||
sf_USB_net_init();
|
||||
|
||||
break;
|
||||
case SF_MCU_STARTUP_USB:
|
||||
s32ret = sf_get_utc();
|
||||
if ((s32ret == SF_SIM_ERROR_UTC) && (SF_ON != pCustomerParam->GpsSwitch)) {
|
||||
SF_PARA_TIME_S current_time = { 0, 0, 0, 0, 0, 0};
|
||||
s32ret = sf_get_ntp(s32ret, ¤t_time);
|
||||
}
|
||||
if ((SF_ON == pCustomerParam->GpsSwitch)) {
|
||||
s32ret = open_gps(s32ret);
|
||||
}
|
||||
if (1 == pCustomerParam->NeedTimeSyncStartUp) {
|
||||
printf("[%s:%d]8 between A and B,no reg net again,no reset time sync.\n",
|
||||
__FUNCTION__, __LINE__);
|
||||
sf_set_dr_reset_time_sys_flag(1);
|
||||
}
|
||||
//sf_dailyReport_set();
|
||||
//sf_share_mem_customer_down(1);
|
||||
|
||||
break;
|
||||
case SF_MCU_STARTUP_RESET:
|
||||
break;
|
||||
case SF_MCU_STARTUP_USB:
|
||||
|
||||
s32ret = app_ttyusb_IsOpen();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
break;
|
||||
case SF_MCU_STARTUP_RESET:
|
||||
|
||||
s32ret = app_ttyusb_IsOpen();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
#if SF_QLOG_ENABLE
|
||||
if (pCustomerParam->QLogSwitch == 1)
|
||||
app_Qlog_procress();
|
||||
if (pCustomerParam->QLogSwitch == 1)
|
||||
app_Qlog_procress();
|
||||
#endif
|
||||
|
||||
s32ret = sf_4G_sim_init(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
s32ret = sf_4G_sim_init(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
|
||||
s32ret = sf_4G_register_net_manual(pfnParam);
|
||||
if (s32ret != SF_SUCCESS) {
|
||||
sf_set_signal_ready_flag(TRUE);
|
||||
}
|
||||
if (0 != sf_get_cq_signal()) {
|
||||
pCustomerParam->GpsSendFlag = 1;
|
||||
pCustomerParam->NeedTimeSyncStartUp = 1;
|
||||
// avoid always A mode power on
|
||||
pCustomerParam->NetWorkNeedSearch = 0;
|
||||
}
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
sf_4G_usb_net_apn_cfg(pfnParam);
|
||||
sf_USB_net_init();
|
||||
#if SF_LPA_SDK
|
||||
|
||||
s32ret = sf_get_utc();
|
||||
if ((s32ret == SF_SIM_ERROR_UTC) && (SF_ON != pCustomerParam->GpsSwitch)) {
|
||||
SF_PARA_TIME_S current_time = { 0, 0, 0, 0, 0, 0};
|
||||
s32ret = sf_get_ntp(s32ret, ¤t_time);
|
||||
}
|
||||
if ((SF_ON == pCustomerParam->GpsSwitch)) {
|
||||
s32ret = open_gps(s32ret);
|
||||
}
|
||||
if (0 != sf_get_cq_signal()) {
|
||||
sf_sample_lpa_init();
|
||||
|
||||
if(SUCCESS != sf_connect_ftps_server()){
|
||||
printf("[%s:%d]open ftps fail, reconnect\n", __FUNCTION__, __LINE__);
|
||||
if(SUCCESS != sf_connect_ftps_server()){
|
||||
printf("[%s:%d]re open ftps fail, reconnect\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
//sf_share_mem_customer_down(1);
|
||||
break;
|
||||
case SF_MCU_STARTUP_SYN_PARAM:
|
||||
while(!sf_is_esim_init_finish())
|
||||
{
|
||||
usleep(100*1000);
|
||||
}
|
||||
|
||||
s32ret = app_ttyusb_IsOpen();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
if(!sf_is_esim_card() || pCustomerParam->UpdateFlg)
|
||||
{
|
||||
if(pCustomerParam->UpdateFlg)
|
||||
{
|
||||
pCustomerParam->UpdateFlg = 0;
|
||||
//sf_set_param_save_flag();
|
||||
}
|
||||
|
||||
sf_sms_lpa_delete_lpa_log();
|
||||
}
|
||||
|
||||
if(sf_is_esim_card())
|
||||
{
|
||||
sf_get_eid(eid);
|
||||
printf("pPara->EsimEid=%s\n", pCustomerParam->EsimEid);
|
||||
printf("pPara->eid=%s\n", eid);
|
||||
if((pCustomerParam->EsimEid[0] != '\0') && (SF_STRCMP(pCustomerParam->EsimEid, eid) != 0))
|
||||
{
|
||||
sf_sms_lpa_delete_lpa_log();
|
||||
}
|
||||
|
||||
SF_STRCPY(pCustomerParam->EsimEid, eid);
|
||||
sf_sms_lpa_load_profile_apn((const SINT8 *)simICCID, (SINT8 *)sim4gApn);
|
||||
if(sim4gApn[0] != '\0')
|
||||
{
|
||||
SF_STRCPY(pCustomerParam->Sim4gApn, sim4gApn);
|
||||
SF_STRCPY(pCustomerParam->Sim4gPwd, "\0");
|
||||
SF_STRCPY(pCustomerParam->Sim4gUsr, "\0");
|
||||
#if 0
|
||||
SF_STRCPY(sim_info_t->MmsMmsc, "\0");
|
||||
SF_STRCPY(sim_info_t->MmsApn, "\0");
|
||||
SF_STRCPY(sim_info_t->MmsProxy, "\0");
|
||||
SF_STRCPY(sim_info_t->MmsPort, "\0");
|
||||
SF_STRCPY(sim_info_t->MmsUserName, "\0");
|
||||
SF_STRCPY(sim_info_t->MmsPassword, "\0");
|
||||
#endif
|
||||
printf("set profile Sim4gApn=%s\n", pCustomerParam->Sim4gApn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(pCustomerParam->ProfileSwitchFlg)
|
||||
{
|
||||
pCustomerParam->ProfileSwitchFlg = 0;
|
||||
|
||||
if(ret == SF_SIM_ERROR_REG_NET_REFUSE)
|
||||
{
|
||||
sf_sms_lpa_command_recombination_log(SF_SMS_LPA_CMD_FAIL, SF_LPA_CUSTOM_ERROR_NETWORK_REJECTED);
|
||||
|
||||
if(pCustomerParam->PreActiveProfileIccid != '\0')
|
||||
{
|
||||
sf_sms_lpa_profile_rool_back((const SINT8 *)pCustomerParam->PreActiveProfileIccid);
|
||||
memset(pCustomerParam->PreActiveProfileIccid, '\0', sizeof(pCustomerParam->PreActiveProfileIccid));
|
||||
if(sf_sms_lpa_is_need_profile_switch_reboot())
|
||||
pCustomerParam->NetWorkNeedSearch = 1;
|
||||
else
|
||||
pCustomerParam->NetWorkNeedSearch = 0; //rool back fail, not need reboot
|
||||
}
|
||||
else
|
||||
{
|
||||
// switch prlfile reboot in A reg net, reg 0,3 reboot in A again
|
||||
// when reboot in a, reg still reg 0,3; not need reboot again
|
||||
pCustomerParam->NetWorkNeedSearch = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sf_sms_lpa_command_recombination_log(SF_SMS_LPA_CMD_SUCCESS, LPA_NO_ERROR);
|
||||
memset(pCustomerParam->PreActiveProfileIccid, '\0', sizeof(pCustomerParam->PreActiveProfileIccid));
|
||||
if(ret == SF_SUCCESS)
|
||||
sf_sms_lpa_set_send_lpa_log_flg(1);
|
||||
|
||||
// switch prlfile reboot in A reg net, reg 0,1 or reg 0,2, not need reboot again
|
||||
pCustomerParam->NetWorkNeedSearch = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
s32ret = sf_4G_register_net_manual(pfnParam);
|
||||
if (s32ret != SF_SUCCESS) {
|
||||
sf_set_signal_ready_flag(TRUE);
|
||||
}
|
||||
if (0 != sf_get_cq_signal()) {
|
||||
pCustomerParam->GpsSendFlag = 1;
|
||||
pCustomerParam->NeedTimeSyncStartUp = 1;
|
||||
// avoid always A mode power on
|
||||
pCustomerParam->NetWorkNeedSearch = 0;
|
||||
}
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
sf_4G_usb_net_apn_cfg(pfnParam);
|
||||
sf_USB_net_init();
|
||||
|
||||
s32ret = sf_get_utc();
|
||||
if ((s32ret == SF_SIM_ERROR_UTC) && (SF_ON != pCustomerParam->GpsSwitch)) {
|
||||
SF_PARA_TIME_S current_time = { 0, 0, 0, 0, 0, 0};
|
||||
s32ret = sf_get_ntp(s32ret, ¤t_time);
|
||||
}
|
||||
if ((SF_ON == pCustomerParam->GpsSwitch)) {
|
||||
s32ret = open_gps(s32ret);
|
||||
}
|
||||
if (0 != sf_get_cq_signal()) {
|
||||
|
||||
if(SUCCESS != sf_connect_ftps_server()){
|
||||
printf("[%s:%d]open ftps fail, reconnect\n", __FUNCTION__, __LINE__);
|
||||
if(SUCCESS != sf_connect_ftps_server()){
|
||||
printf("[%s:%d]re open ftps fail, reconnect\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
//sf_share_mem_customer_down(1);
|
||||
break;
|
||||
case SF_MCU_STARTUP_SYN_PARAM:
|
||||
|
||||
s32ret = app_ttyusb_IsOpen();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
|
||||
#if SF_QLOG_ENABLE
|
||||
if (pCustomerParam->QLogSwitch == 1)
|
||||
app_Qlog_procress();
|
||||
if (pCustomerParam->QLogSwitch == 1)
|
||||
app_Qlog_procress();
|
||||
#endif
|
||||
s32ret = sf_4G_sim_init(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
s32ret = sf_4G_sim_init(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
|
||||
s32ret = sf_4G_register_net_auto(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
sf_4G_usb_net_apn_cfg(pfnParam);
|
||||
sf_USB_net_init();
|
||||
s32ret = sf_4G_register_net_auto(pfnParam);
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
sf_4G_usb_net_apn_cfg(pfnParam);
|
||||
sf_USB_net_init();
|
||||
|
||||
if ((SF_ON == pCustomerParam->GpsSwitch)) {
|
||||
const int KEEP_SERACHING_TIMEOUT_MS = 2000;
|
||||
const int KEEP_SERACHING_PERIOD_MS = 200;
|
||||
// keep_seraching_gps_location(KEEP_SERACHING_TIMEOUT_S);
|
||||
SF_GPS_PARAM gps_param = {
|
||||
.timeout_ms = KEEP_SERACHING_TIMEOUT_MS,
|
||||
.period_ms = KEEP_SERACHING_PERIOD_MS,
|
||||
};
|
||||
keep_get_gps_location(gps_param);
|
||||
gps_close();
|
||||
}
|
||||
if ((SF_ON == pCustomerParam->GpsSwitch)) {
|
||||
const int KEEP_SERACHING_TIMEOUT_MS = 2000;
|
||||
const int KEEP_SERACHING_PERIOD_MS = 200;
|
||||
// keep_seraching_gps_location(KEEP_SERACHING_TIMEOUT_S);
|
||||
SF_GPS_PARAM gps_param = {
|
||||
.timeout_ms = KEEP_SERACHING_TIMEOUT_MS,
|
||||
.period_ms = KEEP_SERACHING_PERIOD_MS,
|
||||
};
|
||||
keep_get_gps_location(gps_param);
|
||||
gps_close();
|
||||
}
|
||||
|
||||
s32ret = sf_read_message();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
s32ret = sf_read_message();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
|
||||
pCustomerParam->NetWorkNeedSearch = 0;
|
||||
pCustomerParam->NeedTimeSyncStartUp = 0;
|
||||
pCustomerParam->NetWorkNeedSearch = 0;
|
||||
pCustomerParam->NeedTimeSyncStartUp = 0;
|
||||
|
||||
s32ret = sf_file_send_auto();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
s32ret = sf_file_send_auto();
|
||||
SF_APPCOMM_CHECK_RETURN(s32ret, SF_APP_ERROR_REQUEST);
|
||||
|
||||
|
||||
if (sf_get_pic()) {
|
||||
s32ret = sf_app_to_cardv_capture();
|
||||
}
|
||||
else if(sf_get_send_hd()){
|
||||
s32ret = sf_app_to_cardv_hd_ture();
|
||||
}
|
||||
else if(sf_get_send_video()){
|
||||
s32ret = sf_video_ftp_send();
|
||||
}
|
||||
//sf_share_mem_customer_down(1);
|
||||
break;
|
||||
if (sf_get_pic()) {
|
||||
s32ret = sf_app_to_cardv_capture();
|
||||
}
|
||||
else if(sf_get_send_hd()){
|
||||
s32ret = sf_app_to_cardv_hd_ture();
|
||||
}
|
||||
else if(sf_get_send_video()){
|
||||
s32ret = sf_video_ftp_send();
|
||||
}
|
||||
//sf_share_mem_customer_down(1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return s32ret;
|
||||
return s32ret;
|
||||
}
|
||||
|
||||
void app_Register_Net_thread(void) {
|
||||
SINT32 s32ret = 0;
|
||||
SF_FN_PARAM_S stpfncallback = {0};
|
||||
|
@ -1600,10 +1748,21 @@ SINT32 app_RegisterNet_start(void) {
|
|||
pthread_create(&RegisterNetTskParam.TskId, NULL,
|
||||
(void *)app_Register_Net_thread, NULL);
|
||||
RegisterNetTskParam.IsRun = 1;
|
||||
SF_MUTEX_INIT_LOCK(RegisterNetTskParam.mutexLock);
|
||||
//SF_MUTEX_INIT_LOCK(RegisterNetTskParam.mutexLock);
|
||||
}
|
||||
return SF_SUCCESS;
|
||||
}
|
||||
|
||||
void app_RegisterNet_stop()
|
||||
{
|
||||
printf("RegisterNetTskParam.IsRun:%d\n", RegisterNetTskParam.IsRun);
|
||||
if(RegisterNetTskParam.IsRun)
|
||||
{
|
||||
pthread_cancel(RegisterNetTskParam.TskId);
|
||||
RegisterNetTskParam.IsRun = 0;
|
||||
}
|
||||
}
|
||||
|
||||
SINT32 app_t110(void) {
|
||||
|
||||
SINT8 halvalue = 0;
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "sf_hal_ttyusb.h"
|
||||
#include "sf_common.h"
|
||||
#include "sf_device.h"
|
||||
#include "sf_eg91_sim.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
|
@ -899,6 +901,27 @@ void sf_sys_status_led_set(LedSysState_t ledSysStateId)
|
|||
sf_led_set(SF_LED_BAT4, SF_LED_STATE_OFF);
|
||||
break;
|
||||
|
||||
case SF_SIM_ERROR_SWITCH_PROFILE:
|
||||
//sf_set_4g_status(SF_4G_FAIL);
|
||||
sf_led_set(SF_LED_SIG1_R, SF_LED_STATE_ON);
|
||||
sf_led_set(SF_LED_SIG1_G, SF_LED_STATE_ON);
|
||||
break;
|
||||
|
||||
case SF_SIM_SWITCH_ATT_PROFILE:
|
||||
//sf_set_4g_status(SF_4G_FAIL);
|
||||
sf_led_set(SF_LED_SIG2, SF_LED_STATE_SLOW_FLASHING);
|
||||
break;
|
||||
|
||||
case SF_SIM_SWITCH_VERIZON_PROFILE:
|
||||
//sf_set_4g_status(SF_4G_FAIL);
|
||||
sf_led_set(SF_LED_SIG3, SF_LED_STATE_SLOW_FLASHING);
|
||||
break;
|
||||
|
||||
case SF_SIM_SWITCH_OTHER_PROFILE:
|
||||
//sf_set_4g_status(SF_4G_FAIL);
|
||||
sf_led_set(SF_LED_SIG4, SF_LED_STATE_SLOW_FLASHING);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
21
code/application/source/sf_app/code/source/sf_lpa/Extra/base64/LICENSE.txt
Executable file
21
code/application/source/sf_app/code/source/sf_lpa/Extra/base64/LICENSE.txt
Executable file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2016 Joe DF (joedf@ahkscript.org)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
204
code/application/source/sf_app/code/source/sf_lpa/Extra/base64/base64.c
Executable file
204
code/application/source/sf_app/code/source/sf_lpa/Extra/base64/base64.c
Executable file
|
@ -0,0 +1,204 @@
|
|||
/*
|
||||
base64.c - by Joe DF (joedf@ahkscript.org)
|
||||
Released under the MIT License
|
||||
|
||||
See "base64.h", for more information.
|
||||
|
||||
Thank you for inspiration:
|
||||
http://www.codeproject.com/Tips/813146/Fast-base-functions-for-encode-decode
|
||||
*/
|
||||
|
||||
#include "base64.h"
|
||||
|
||||
//Base64 char table - used internally for encoding
|
||||
unsigned char b64_chr[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
unsigned int b64_int(unsigned int ch) {
|
||||
|
||||
// ASCII to base64_int
|
||||
// 65-90 Upper Case >> 0-25
|
||||
// 97-122 Lower Case >> 26-51
|
||||
// 48-57 Numbers >> 52-61
|
||||
// 43 Plus (+) >> 62
|
||||
// 47 Slash (/) >> 63
|
||||
// 61 Equal (=) >> 64~
|
||||
if (ch==43)
|
||||
return 62;
|
||||
if (ch==47)
|
||||
return 63;
|
||||
if (ch==61)
|
||||
return 64;
|
||||
if ((ch>47) && (ch<58))
|
||||
return ch + 4;
|
||||
if ((ch>64) && (ch<91))
|
||||
return ch - 'A';
|
||||
if ((ch>96) && (ch<123))
|
||||
return (ch - 'a') + 26;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int b64e_size(unsigned int in_size) {
|
||||
|
||||
// size equals 4*floor((1/3)*(in_size+2));
|
||||
int i, j = 0;
|
||||
for (i=0;i<in_size;i++) {
|
||||
if (i % 3 == 0)
|
||||
j += 1;
|
||||
}
|
||||
return (4*j);
|
||||
}
|
||||
|
||||
unsigned int b64d_size(unsigned int in_size) {
|
||||
|
||||
return ((3*in_size)/4);
|
||||
}
|
||||
|
||||
unsigned int b64_encode(const unsigned char* in, unsigned int in_len, unsigned char* out) {
|
||||
|
||||
unsigned int i=0, j=0, k=0, s[3];
|
||||
|
||||
for (i=0;i<in_len;i++) {
|
||||
s[j++]=*(in+i);
|
||||
if (j==3) {
|
||||
out[k+0] = b64_chr[ (s[0]&255)>>2 ];
|
||||
out[k+1] = b64_chr[ ((s[0]&0x03)<<4)+((s[1]&0xF0)>>4) ];
|
||||
out[k+2] = b64_chr[ ((s[1]&0x0F)<<2)+((s[2]&0xC0)>>6) ];
|
||||
out[k+3] = b64_chr[ s[2]&0x3F ];
|
||||
j=0; k+=4;
|
||||
}
|
||||
}
|
||||
|
||||
if (j) {
|
||||
if (j==1)
|
||||
s[1] = 0;
|
||||
out[k+0] = b64_chr[ (s[0]&255)>>2 ];
|
||||
out[k+1] = b64_chr[ ((s[0]&0x03)<<4)+((s[1]&0xF0)>>4) ];
|
||||
if (j==2)
|
||||
out[k+2] = b64_chr[ ((s[1]&0x0F)<<2) ];
|
||||
else
|
||||
out[k+2] = '=';
|
||||
out[k+3] = '=';
|
||||
k+=4;
|
||||
}
|
||||
|
||||
out[k] = '\0';
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
unsigned int b64_decode(const unsigned char* in, unsigned int in_len, unsigned char* out) {
|
||||
|
||||
unsigned int i=0, j=0, k=0, s[4];
|
||||
|
||||
for (i=0;i<in_len;i++) {
|
||||
s[j++]=b64_int(*(in+i));
|
||||
if (j==4) {
|
||||
out[k+0] = ((s[0]&255)<<2)+((s[1]&0x30)>>4);
|
||||
if (s[2]!=64) {
|
||||
out[k+1] = ((s[1]&0x0F)<<4)+((s[2]&0x3C)>>2);
|
||||
if ((s[3]!=64)) {
|
||||
out[k+2] = ((s[2]&0x03)<<6)+(s[3]); k+=3;
|
||||
} else {
|
||||
k+=2;
|
||||
}
|
||||
} else {
|
||||
k+=1;
|
||||
}
|
||||
j=0;
|
||||
}
|
||||
}
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
unsigned int b64_encodef(char *InFile, char *OutFile) {
|
||||
|
||||
FILE *pInFile = fopen(InFile,"rb");
|
||||
FILE *pOutFile = fopen(OutFile,"wb");
|
||||
|
||||
unsigned int i=0;
|
||||
unsigned int j=0;
|
||||
unsigned int c=0;
|
||||
unsigned int s[4];
|
||||
|
||||
if ((pInFile==NULL) || (pOutFile==NULL) ) {
|
||||
if (pInFile!=NULL){fclose(pInFile);}
|
||||
if (pOutFile!=NULL){fclose(pOutFile);}
|
||||
return 0;
|
||||
}
|
||||
|
||||
while(c!=EOF) {
|
||||
c=fgetc(pInFile);
|
||||
if (c==EOF)
|
||||
break;
|
||||
s[j++]=c;
|
||||
if (j==3) {
|
||||
fputc(b64_chr[ (s[0]&255)>>2 ],pOutFile);
|
||||
fputc(b64_chr[ ((s[0]&0x03)<<4)+((s[1]&0xF0)>>4) ],pOutFile);
|
||||
fputc(b64_chr[ ((s[1]&0x0F)<<2)+((s[2]&0xC0)>>6) ],pOutFile);
|
||||
fputc(b64_chr[ s[2]&0x3F ],pOutFile);
|
||||
j=0; i+=4;
|
||||
}
|
||||
}
|
||||
|
||||
if (j) {
|
||||
if (j==1)
|
||||
s[1] = 0;
|
||||
fputc(b64_chr[ (s[0]&255)>>2 ],pOutFile);
|
||||
fputc(b64_chr[ ((s[0]&0x03)<<4)+((s[1]&0xF0)>>4) ],pOutFile);
|
||||
if (j==2)
|
||||
fputc(b64_chr[ ((s[1]&0x0F)<<2) ],pOutFile);
|
||||
else
|
||||
fputc('=',pOutFile);
|
||||
fputc('=',pOutFile);
|
||||
i+=4;
|
||||
}
|
||||
|
||||
fclose(pInFile);
|
||||
fclose(pOutFile);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
unsigned int b64_decodef(char *InFile, char *OutFile) {
|
||||
|
||||
FILE *pInFile = fopen(InFile,"rb");
|
||||
FILE *pOutFile = fopen(OutFile,"wb");
|
||||
|
||||
unsigned int c=0;
|
||||
unsigned int j=0;
|
||||
unsigned int k=0;
|
||||
unsigned int s[4];
|
||||
|
||||
if ((pInFile==NULL) || (pOutFile==NULL) ) {
|
||||
if (pInFile!=NULL){fclose(pInFile);}
|
||||
if (pOutFile!=NULL){fclose(pOutFile);}
|
||||
return 0;
|
||||
}
|
||||
|
||||
while(c!=EOF) {
|
||||
c=fgetc(pInFile);
|
||||
if (c==EOF)
|
||||
break;
|
||||
s[j++]=b64_int(c);
|
||||
if (j==4) {
|
||||
fputc(((s[0]&255)<<2)+((s[1]&0x30)>>4),pOutFile);
|
||||
if (s[2]!=64) {
|
||||
fputc(((s[1]&0x0F)<<4)+((s[2]&0x3C)>>2),pOutFile);
|
||||
if ((s[3]!=64)) {
|
||||
fputc(((s[2]&0x03)<<6)+(s[3]),pOutFile); k+=3;
|
||||
} else {
|
||||
k+=2;
|
||||
}
|
||||
} else {
|
||||
k+=1;
|
||||
}
|
||||
j=0;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(pInFile);
|
||||
fclose(pOutFile);
|
||||
|
||||
return k;
|
||||
}
|
44
code/application/source/sf_app/code/source/sf_lpa/Extra/base64/base64.h
Executable file
44
code/application/source/sf_app/code/source/sf_lpa/Extra/base64/base64.h
Executable file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
base64.c - by Joe DF (joedf@ahkscript.org)
|
||||
Released under the MIT License
|
||||
|
||||
Revision: 2015-06-12 01:26:51
|
||||
|
||||
Thank you for inspiration:
|
||||
http://www.codeproject.com/Tips/813146/Fast-base-functions-for-encode-decode
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//Base64 char table function - used internally for decoding
|
||||
unsigned int b64_int(unsigned int ch);
|
||||
|
||||
// in_size : the number bytes to be encoded.
|
||||
// Returns the recommended memory size to be allocated for the output buffer excluding the null byte
|
||||
unsigned int b64e_size(unsigned int in_size);
|
||||
|
||||
// in_size : the number bytes to be decoded.
|
||||
// Returns the recommended memory size to be allocated for the output buffer
|
||||
unsigned int b64d_size(unsigned int in_size);
|
||||
|
||||
// in : buffer of "raw" binary to be encoded.
|
||||
// in_len : number of bytes to be encoded.
|
||||
// out : pointer to buffer with enough memory, user is responsible for memory allocation, receives null-terminated string
|
||||
// returns size of output including null byte
|
||||
unsigned int b64_encode(const unsigned char* in, unsigned int in_len, unsigned char* out);
|
||||
|
||||
// in : buffer of base64 string to be decoded.
|
||||
// in_len : number of bytes to be decoded.
|
||||
// out : pointer to buffer with enough memory, user is responsible for memory allocation, receives "raw" binary
|
||||
// returns size of output excluding null byte
|
||||
unsigned int b64_decode(const unsigned char* in, unsigned int in_len, unsigned char* out);
|
||||
|
||||
// file-version b64_encode
|
||||
// Input : filenames
|
||||
// returns size of output
|
||||
unsigned int b64_encodef(char *InFile, char *OutFile);
|
||||
|
||||
// file-version b64_decode
|
||||
// Input : filenames
|
||||
// returns size of output
|
||||
unsigned int b64_decodef(char *InFile, char *OutFile);
|
2934
code/application/source/sf_app/code/source/sf_lpa/Extra/cJSON/cJSON.c
Executable file
2934
code/application/source/sf_app/code/source/sf_lpa/Extra/cJSON/cJSON.c
Executable file
File diff suppressed because it is too large
Load Diff
285
code/application/source/sf_app/code/source/sf_lpa/Extra/cJSON/cJSON.h
Executable file
285
code/application/source/sf_app/code/source/sf_lpa/Extra/cJSON/cJSON.h
Executable file
|
@ -0,0 +1,285 @@
|
|||
/*
|
||||
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef cJSON__h
|
||||
#define cJSON__h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||
#define __WINDOWS__
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
|
||||
|
||||
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
|
||||
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
|
||||
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
|
||||
|
||||
For *nix builds that support visibility attribute, you can define similar behavior by
|
||||
|
||||
setting default visibility to hidden by adding
|
||||
-fvisibility=hidden (for gcc)
|
||||
or
|
||||
-xldscope=hidden (for sun cc)
|
||||
to CFLAGS
|
||||
|
||||
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
|
||||
|
||||
*/
|
||||
|
||||
#define CJSON_CDECL __cdecl
|
||||
#define CJSON_STDCALL __stdcall
|
||||
|
||||
/* export symbols by default, this is necessary for copy pasting the C and header file */
|
||||
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_EXPORT_SYMBOLS
|
||||
#endif
|
||||
|
||||
#if defined(CJSON_HIDE_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) type CJSON_STDCALL
|
||||
#elif defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
|
||||
#elif defined(CJSON_IMPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
|
||||
#endif
|
||||
#else /* !__WINDOWS__ */
|
||||
#define CJSON_CDECL
|
||||
#define CJSON_STDCALL
|
||||
|
||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||
#else
|
||||
#define CJSON_PUBLIC(type) type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* project version */
|
||||
#define CJSON_VERSION_MAJOR 1
|
||||
#define CJSON_VERSION_MINOR 7
|
||||
#define CJSON_VERSION_PATCH 10
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* cJSON Types: */
|
||||
#define cJSON_Invalid (0)
|
||||
#define cJSON_False (1 << 0)
|
||||
#define cJSON_True (1 << 1)
|
||||
#define cJSON_NULL (1 << 2)
|
||||
#define cJSON_Number (1 << 3)
|
||||
#define cJSON_String (1 << 4)
|
||||
#define cJSON_Array (1 << 5)
|
||||
#define cJSON_Object (1 << 6)
|
||||
#define cJSON_Raw (1 << 7) /* raw json */
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_StringIsConst 512
|
||||
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON
|
||||
{
|
||||
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *next;
|
||||
struct cJSON *prev;
|
||||
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
struct cJSON *child;
|
||||
|
||||
/* The type of the item, as above. */
|
||||
int type;
|
||||
|
||||
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
|
||||
char *valuestring;
|
||||
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
|
||||
int valueint;
|
||||
/* The item's number, if type==cJSON_Number */
|
||||
double valuedouble;
|
||||
|
||||
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
char *string;
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks
|
||||
{
|
||||
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
|
||||
void *(CJSON_CDECL *malloc_fn)(size_t sz);
|
||||
void (CJSON_CDECL *free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
typedef int cJSON_bool;
|
||||
|
||||
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
|
||||
* This is to prevent stack overflows. */
|
||||
#ifndef CJSON_NESTING_LIMIT
|
||||
#define CJSON_NESTING_LIMIT 1000
|
||||
#endif
|
||||
|
||||
/* returns the version of cJSON as a string */
|
||||
CJSON_PUBLIC(const char*) cJSON_Version(void);
|
||||
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
|
||||
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
|
||||
/* Render a cJSON entity to text for transfer/storage. */
|
||||
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
||||
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
|
||||
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
|
||||
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
CJSON_PUBLIC(void) cJSON_Delete(cJSON *c);
|
||||
|
||||
/* Returns the number of items in an array (or object). */
|
||||
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
||||
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||
|
||||
/* Check if the item is a string and return its valuestring */
|
||||
CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item);
|
||||
|
||||
/* These functions check the type of an item */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
|
||||
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
|
||||
/* raw json */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
|
||||
|
||||
/* Create a string where valuestring references a string so
|
||||
* it will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
|
||||
/* Create an object/arrray that only references it's elements so
|
||||
* they will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
|
||||
|
||||
/* These utilities create an Array of count items. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count);
|
||||
|
||||
/* Append item to the specified array/object. */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
|
||||
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
|
||||
* writing to `item->string` */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||
|
||||
/* Remove/Detatch items from Arrays/Objects. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
|
||||
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem);
|
||||
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem);
|
||||
|
||||
/* Duplicate a cJSON item */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||
need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||
The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
|
||||
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
|
||||
|
||||
|
||||
CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
||||
|
||||
/* Helper functions for creating and adding items to an object at the same time.
|
||||
* They return the added item or NULL on failure. */
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
|
||||
|
||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
||||
/* helper for the cJSON_SetNumberValue macro */
|
||||
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
||||
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||
|
||||
/* Macro for iterating over an array or object */
|
||||
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||
|
||||
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
|
||||
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
|
||||
CJSON_PUBLIC(void) cJSON_free(void *object);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
242
code/application/source/sf_app/code/source/sf_lpa/Extra/sha256/sha-256.c
Executable file
242
code/application/source/sf_app/code/source/sf_lpa/Extra/sha256/sha-256.c
Executable file
|
@ -0,0 +1,242 @@
|
|||
|
||||
// Source code from https://github.com/amosnier/sha-2
|
||||
// License : https://github.com/amosnier/sha-2/blob/master/LICENSE
|
||||
|
||||
/*
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org>
|
||||
*/
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sha-256.h"
|
||||
|
||||
#define CHUNK_SIZE 64
|
||||
#define TOTAL_LEN_LEN 8
|
||||
|
||||
/*
|
||||
* ABOUT bool: this file does not use bool in order to be as pre-C99 compatible as possible.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Comments from pseudo-code at https://en.wikipedia.org/wiki/SHA-2 are reproduced here.
|
||||
* When useful for clarification, portions of the pseudo-code are reproduced here too.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Initialize array of round constants:
|
||||
* (first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311):
|
||||
*/
|
||||
static const uint32_t k[] = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
||||
};
|
||||
|
||||
struct buffer_state {
|
||||
const uint8_t * p;
|
||||
size_t len;
|
||||
size_t total_len;
|
||||
int single_one_delivered; /* bool */
|
||||
int total_len_delivered; /* bool */
|
||||
};
|
||||
|
||||
static /*inline*/ uint32_t right_rot(uint32_t value, unsigned int count)
|
||||
{
|
||||
/*
|
||||
* Defined behaviour in standard C for all count where 0 < count < 32,
|
||||
* which is what we need here.
|
||||
*/
|
||||
return value >> count | value << (32 - count);
|
||||
}
|
||||
|
||||
static void init_buf_state(struct buffer_state * state, const void * input, size_t len)
|
||||
{
|
||||
state->p = input;
|
||||
state->len = len;
|
||||
state->total_len = len;
|
||||
state->single_one_delivered = 0;
|
||||
state->total_len_delivered = 0;
|
||||
}
|
||||
|
||||
/* Return value: bool */
|
||||
static int calc_chunk(uint8_t chunk[CHUNK_SIZE], struct buffer_state * state)
|
||||
{
|
||||
size_t space_in_chunk;
|
||||
|
||||
if (state->total_len_delivered) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (state->len >= CHUNK_SIZE) {
|
||||
memcpy(chunk, state->p, CHUNK_SIZE);
|
||||
state->p += CHUNK_SIZE;
|
||||
state->len -= CHUNK_SIZE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
memcpy(chunk, state->p, state->len);
|
||||
chunk += state->len;
|
||||
space_in_chunk = CHUNK_SIZE - state->len;
|
||||
state->p += state->len;
|
||||
state->len = 0;
|
||||
|
||||
/* If we are here, space_in_chunk is one at minimum. */
|
||||
if (!state->single_one_delivered) {
|
||||
*chunk++ = 0x80;
|
||||
space_in_chunk -= 1;
|
||||
state->single_one_delivered = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now:
|
||||
* - either there is enough space left for the total length, and we can conclude,
|
||||
* - or there is too little space left, and we have to pad the rest of this chunk with zeroes.
|
||||
* In the latter case, we will conclude at the next invokation of this function.
|
||||
*/
|
||||
if (space_in_chunk >= TOTAL_LEN_LEN) {
|
||||
const size_t left = space_in_chunk - TOTAL_LEN_LEN;
|
||||
size_t len = state->total_len;
|
||||
int i;
|
||||
memset(chunk, 0x00, left);
|
||||
chunk += left;
|
||||
|
||||
/* Storing of len * 8 as a big endian 64-bit without overflow. */
|
||||
chunk[7] = (uint8_t) (len << 3);
|
||||
len >>= 5;
|
||||
for (i = 6; i >= 0; i--) {
|
||||
chunk[i] = (uint8_t) len;
|
||||
len >>= 8;
|
||||
}
|
||||
state->total_len_delivered = 1;
|
||||
} else {
|
||||
memset(chunk, 0x00, space_in_chunk);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Limitations:
|
||||
* - Since input is a pointer in RAM, the data to hash should be in RAM, which could be a problem
|
||||
* for large data sizes.
|
||||
* - SHA algorithms theoretically operate on bit strings. However, this implementation has no support
|
||||
* for bit string lengths that are not multiples of eight, and it really operates on arrays of bytes.
|
||||
* In particular, the len parameter is a number of bytes.
|
||||
*/
|
||||
void calc_sha_256(uint8_t hash[32], const void * input, size_t len)
|
||||
{
|
||||
/*
|
||||
* Note 1: All integers (expect indexes) are 32-bit unsigned integers and addition is calculated modulo 2^32.
|
||||
* Note 2: For each round, there is one round constant k[i] and one entry in the message schedule array w[i], 0 = i = 63
|
||||
* Note 3: The compression function uses 8 working variables, a through h
|
||||
* Note 4: Big-endian convention is used when expressing the constants in this pseudocode,
|
||||
* and when parsing message block data from bytes to words, for example,
|
||||
* the first word of the input message "abc" after padding is 0x61626380
|
||||
*/
|
||||
|
||||
/*
|
||||
* Initialize hash values:
|
||||
* (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
|
||||
*/
|
||||
uint32_t h[] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
|
||||
int i, j;
|
||||
|
||||
/* 512-bit chunks is what we will operate on. */
|
||||
uint8_t chunk[64];
|
||||
|
||||
struct buffer_state state;
|
||||
|
||||
init_buf_state(&state, input, len);
|
||||
|
||||
while (calc_chunk(chunk, &state)) {
|
||||
uint32_t ah[8];
|
||||
|
||||
/*
|
||||
* create a 64-entry message schedule array w[0..63] of 32-bit words
|
||||
* (The initial values in w[0..63] don't matter, so many implementations zero them here)
|
||||
* copy chunk into first 16 words w[0..15] of the message schedule array
|
||||
*/
|
||||
uint32_t w[64];
|
||||
const uint8_t *p = chunk;
|
||||
|
||||
memset(w, 0x00, sizeof w);
|
||||
for (i = 0; i < 16; i++) {
|
||||
w[i] = (uint32_t) p[0] << 24 | (uint32_t) p[1] << 16 |
|
||||
(uint32_t) p[2] << 8 | (uint32_t) p[3];
|
||||
p += 4;
|
||||
}
|
||||
|
||||
/* Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array: */
|
||||
for (i = 16; i < 64; i++) {
|
||||
const uint32_t s0 = right_rot(w[i - 15], 7) ^ right_rot(w[i - 15], 18) ^ (w[i - 15] >> 3);
|
||||
const uint32_t s1 = right_rot(w[i - 2], 17) ^ right_rot(w[i - 2], 19) ^ (w[i - 2] >> 10);
|
||||
w[i] = w[i - 16] + s0 + w[i - 7] + s1;
|
||||
}
|
||||
|
||||
/* Initialize working variables to current hash value: */
|
||||
for (i = 0; i < 8; i++)
|
||||
ah[i] = h[i];
|
||||
|
||||
/* Compression function main loop: */
|
||||
for (i = 0; i < 64; i++) {
|
||||
const uint32_t s1 = right_rot(ah[4], 6) ^ right_rot(ah[4], 11) ^ right_rot(ah[4], 25);
|
||||
const uint32_t ch = (ah[4] & ah[5]) ^ (~ah[4] & ah[6]);
|
||||
const uint32_t temp1 = ah[7] + s1 + ch + k[i] + w[i];
|
||||
const uint32_t s0 = right_rot(ah[0], 2) ^ right_rot(ah[0], 13) ^ right_rot(ah[0], 22);
|
||||
const uint32_t maj = (ah[0] & ah[1]) ^ (ah[0] & ah[2]) ^ (ah[1] & ah[2]);
|
||||
const uint32_t temp2 = s0 + maj;
|
||||
|
||||
ah[7] = ah[6];
|
||||
ah[6] = ah[5];
|
||||
ah[5] = ah[4];
|
||||
ah[4] = ah[3] + temp1;
|
||||
ah[3] = ah[2];
|
||||
ah[2] = ah[1];
|
||||
ah[1] = ah[0];
|
||||
ah[0] = temp1 + temp2;
|
||||
}
|
||||
|
||||
/* Add the compressed chunk to the current hash value: */
|
||||
for (i = 0; i < 8; i++)
|
||||
h[i] += ah[i];
|
||||
}
|
||||
|
||||
/* Produce the final hash value (big-endian): */
|
||||
for (i = 0, j = 0; i < 8; i++)
|
||||
{
|
||||
hash[j++] = (uint8_t) (h[i] >> 24);
|
||||
hash[j++] = (uint8_t) (h[i] >> 16);
|
||||
hash[j++] = (uint8_t) (h[i] >> 8);
|
||||
hash[j++] = (uint8_t) h[i];
|
||||
}
|
||||
}
|
31
code/application/source/sf_app/code/source/sf_lpa/Extra/sha256/sha-256.h
Executable file
31
code/application/source/sf_app/code/source/sf_lpa/Extra/sha256/sha-256.h
Executable file
|
@ -0,0 +1,31 @@
|
|||
// Source code from https://github.com/amosnier/sha-2
|
||||
// License : https://github.com/amosnier/sha-2/blob/master/LICENSE
|
||||
|
||||
/*
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org>
|
||||
*/
|
||||
|
||||
void calc_sha_256(uint8_t hash[32], const void *input, size_t len);
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
base64.c - by Joe DF (joedf@ahkscript.org)
|
||||
Released under the MIT License
|
||||
|
||||
Revision: 2015-06-12 01:26:51
|
||||
|
||||
Thank you for inspiration:
|
||||
http://www.codeproject.com/Tips/813146/Fast-base-functions-for-encode-decode
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//Base64 char table function - used internally for decoding
|
||||
unsigned int b64_int(unsigned int ch);
|
||||
|
||||
// in_size : the number bytes to be encoded.
|
||||
// Returns the recommended memory size to be allocated for the output buffer excluding the null byte
|
||||
unsigned int b64e_size(unsigned int in_size);
|
||||
|
||||
// in_size : the number bytes to be decoded.
|
||||
// Returns the recommended memory size to be allocated for the output buffer
|
||||
unsigned int b64d_size(unsigned int in_size);
|
||||
|
||||
// in : buffer of "raw" binary to be encoded.
|
||||
// in_len : number of bytes to be encoded.
|
||||
// out : pointer to buffer with enough memory, user is responsible for memory allocation, receives null-terminated string
|
||||
// returns size of output including null byte
|
||||
unsigned int b64_encode(const unsigned char* in, unsigned int in_len, unsigned char* out);
|
||||
|
||||
// in : buffer of base64 string to be decoded.
|
||||
// in_len : number of bytes to be decoded.
|
||||
// out : pointer to buffer with enough memory, user is responsible for memory allocation, receives "raw" binary
|
||||
// returns size of output excluding null byte
|
||||
unsigned int b64_decode(const unsigned char* in, unsigned int in_len, unsigned char* out);
|
||||
|
||||
// file-version b64_encode
|
||||
// Input : filenames
|
||||
// returns size of output
|
||||
unsigned int b64_encodef(char *InFile, char *OutFile);
|
||||
|
||||
// file-version b64_decode
|
||||
// Input : filenames
|
||||
// returns size of output
|
||||
unsigned int b64_decodef(char *InFile, char *OutFile);
|
285
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/include/cJSON/cJSON.h
Executable file
285
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/include/cJSON/cJSON.h
Executable file
|
@ -0,0 +1,285 @@
|
|||
/*
|
||||
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef cJSON__h
|
||||
#define cJSON__h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||
#define __WINDOWS__
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
|
||||
|
||||
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
|
||||
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
|
||||
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
|
||||
|
||||
For *nix builds that support visibility attribute, you can define similar behavior by
|
||||
|
||||
setting default visibility to hidden by adding
|
||||
-fvisibility=hidden (for gcc)
|
||||
or
|
||||
-xldscope=hidden (for sun cc)
|
||||
to CFLAGS
|
||||
|
||||
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
|
||||
|
||||
*/
|
||||
|
||||
#define CJSON_CDECL __cdecl
|
||||
#define CJSON_STDCALL __stdcall
|
||||
|
||||
/* export symbols by default, this is necessary for copy pasting the C and header file */
|
||||
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_EXPORT_SYMBOLS
|
||||
#endif
|
||||
|
||||
#if defined(CJSON_HIDE_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) type CJSON_STDCALL
|
||||
#elif defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
|
||||
#elif defined(CJSON_IMPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
|
||||
#endif
|
||||
#else /* !__WINDOWS__ */
|
||||
#define CJSON_CDECL
|
||||
#define CJSON_STDCALL
|
||||
|
||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||
#else
|
||||
#define CJSON_PUBLIC(type) type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* project version */
|
||||
#define CJSON_VERSION_MAJOR 1
|
||||
#define CJSON_VERSION_MINOR 7
|
||||
#define CJSON_VERSION_PATCH 10
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* cJSON Types: */
|
||||
#define cJSON_Invalid (0)
|
||||
#define cJSON_False (1 << 0)
|
||||
#define cJSON_True (1 << 1)
|
||||
#define cJSON_NULL (1 << 2)
|
||||
#define cJSON_Number (1 << 3)
|
||||
#define cJSON_String (1 << 4)
|
||||
#define cJSON_Array (1 << 5)
|
||||
#define cJSON_Object (1 << 6)
|
||||
#define cJSON_Raw (1 << 7) /* raw json */
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_StringIsConst 512
|
||||
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON
|
||||
{
|
||||
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *next;
|
||||
struct cJSON *prev;
|
||||
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
struct cJSON *child;
|
||||
|
||||
/* The type of the item, as above. */
|
||||
int type;
|
||||
|
||||
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
|
||||
char *valuestring;
|
||||
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
|
||||
int valueint;
|
||||
/* The item's number, if type==cJSON_Number */
|
||||
double valuedouble;
|
||||
|
||||
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
char *string;
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks
|
||||
{
|
||||
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
|
||||
void *(CJSON_CDECL *malloc_fn)(size_t sz);
|
||||
void (CJSON_CDECL *free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
typedef int cJSON_bool;
|
||||
|
||||
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
|
||||
* This is to prevent stack overflows. */
|
||||
#ifndef CJSON_NESTING_LIMIT
|
||||
#define CJSON_NESTING_LIMIT 1000
|
||||
#endif
|
||||
|
||||
/* returns the version of cJSON as a string */
|
||||
CJSON_PUBLIC(const char*) cJSON_Version(void);
|
||||
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
|
||||
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
|
||||
/* Render a cJSON entity to text for transfer/storage. */
|
||||
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
||||
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
|
||||
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
|
||||
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
CJSON_PUBLIC(void) cJSON_Delete(cJSON *c);
|
||||
|
||||
/* Returns the number of items in an array (or object). */
|
||||
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
||||
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||
|
||||
/* Check if the item is a string and return its valuestring */
|
||||
CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item);
|
||||
|
||||
/* These functions check the type of an item */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
|
||||
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
|
||||
/* raw json */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
|
||||
|
||||
/* Create a string where valuestring references a string so
|
||||
* it will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
|
||||
/* Create an object/arrray that only references it's elements so
|
||||
* they will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
|
||||
|
||||
/* These utilities create an Array of count items. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count);
|
||||
|
||||
/* Append item to the specified array/object. */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
|
||||
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
|
||||
* writing to `item->string` */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||
|
||||
/* Remove/Detatch items from Arrays/Objects. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
|
||||
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem);
|
||||
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem);
|
||||
|
||||
/* Duplicate a cJSON item */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||
need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||
The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
|
||||
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
|
||||
|
||||
|
||||
CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
||||
|
||||
/* Helper functions for creating and adding items to an object at the same time.
|
||||
* They return the added item or NULL on failure. */
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
|
||||
|
||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
||||
/* helper for the cJSON_SetNumberValue macro */
|
||||
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
||||
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||
|
||||
/* Macro for iterating over an array or object */
|
||||
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||
|
||||
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
|
||||
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
|
||||
CJSON_PUBLIC(void) cJSON_free(void *object);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
2839
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/include/curl/curl.h
Executable file
2839
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/include/curl/curl.h
Executable file
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,77 @@
|
|||
#ifndef __CURL_CURLVER_H
|
||||
#define __CURL_CURLVER_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* This header file contains nothing but libcurl version info, generated by
|
||||
a script at release-time. This was made its own header file in 7.11.2 */
|
||||
|
||||
/* This is the global package copyright */
|
||||
#define LIBCURL_COPYRIGHT "1996 - 2018 Daniel Stenberg, <daniel@haxx.se>."
|
||||
|
||||
/* This is the version number of the libcurl package from which this header
|
||||
file origins: */
|
||||
#define LIBCURL_VERSION "7.64.0"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBCURL_VERSION_MAJOR 7
|
||||
#define LIBCURL_VERSION_MINOR 64
|
||||
#define LIBCURL_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libcurl version number, meant for easier
|
||||
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
|
||||
always follow this syntax:
|
||||
|
||||
0xXXYYZZ
|
||||
|
||||
Where XX, YY and ZZ are the main version, release and patch numbers in
|
||||
hexadecimal (using 8 bits each). All three numbers are always represented
|
||||
using two digits. 1.2 would appear as "0x010200" while version 9.11.7
|
||||
appears as "0x090b07".
|
||||
|
||||
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
|
||||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
|
||||
Note: This define is the full hex number and _does not_ use the
|
||||
CURL_VERSION_BITS() macro since curl's own configure script greps for it
|
||||
and needs it to contain the full number.
|
||||
*/
|
||||
#define LIBCURL_VERSION_NUM 0x074000
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
* timestamp is not stored in git, as the timestamp is properly set in the
|
||||
* tarballs by the maketgz script.
|
||||
*
|
||||
* The format of the date follows this template:
|
||||
*
|
||||
* "2007-11-23"
|
||||
*/
|
||||
#define LIBCURL_TIMESTAMP "2019-02-06"
|
||||
|
||||
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z)
|
||||
#define CURL_AT_LEAST_VERSION(x,y,z) \
|
||||
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
|
||||
|
||||
#endif /* __CURL_CURLVER_H */
|
112
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/include/curl/easy.h
Executable file
112
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/include/curl/easy.h
Executable file
|
@ -0,0 +1,112 @@
|
|||
#ifndef __CURL_EASY_H
|
||||
#define __CURL_EASY_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
CURL_EXTERN CURL *curl_easy_init(void);
|
||||
CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
|
||||
CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
|
||||
CURL_EXTERN void curl_easy_cleanup(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_getinfo()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Request internal information from the curl session with this function. The
|
||||
* third argument MUST be a pointer to a long, a pointer to a char * or a
|
||||
* pointer to a double (as the documentation describes elsewhere). The data
|
||||
* pointed to will be filled in accordingly and can be relied upon only if the
|
||||
* function returns CURLE_OK. This function is intended to get used *AFTER* a
|
||||
* performed transfer, all results from this function are undefined until the
|
||||
* transfer is completed.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
|
||||
|
||||
|
||||
/*
|
||||
* NAME curl_easy_duphandle()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Creates a new curl session handle with the same options set for the handle
|
||||
* passed in. Duplicating a handle could only be a matter of cloning data and
|
||||
* options, internal state info and things like persistent connections cannot
|
||||
* be transferred. It is useful in multithreaded applications when you can run
|
||||
* curl_easy_duphandle() for each new thread to avoid a series of identical
|
||||
* curl_easy_setopt() invokes in every thread.
|
||||
*/
|
||||
CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_reset()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Re-initializes a CURL handle to the default values. This puts back the
|
||||
* handle to the same state as it was in when it was just created.
|
||||
*
|
||||
* It does keep: live connections, the Session ID cache, the DNS cache and the
|
||||
* cookies.
|
||||
*/
|
||||
CURL_EXTERN void curl_easy_reset(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_recv()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Receives data from the connected socket. Use after successful
|
||||
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
|
||||
size_t *n);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_send()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Sends data over the connected socket. Use after successful
|
||||
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
|
||||
size_t buflen, size_t *n);
|
||||
|
||||
|
||||
/*
|
||||
* NAME curl_easy_upkeep()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Performs connection upkeep for the given session handle.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,50 @@
|
|||
#ifndef __CURL_MPRINTF_H
|
||||
#define __CURL_MPRINTF_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h> /* needed for FILE */
|
||||
#include "curl.h" /* for CURL_EXTERN */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
CURL_EXTERN int curl_mprintf(const char *format, ...);
|
||||
CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...);
|
||||
CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...);
|
||||
CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength,
|
||||
const char *format, ...);
|
||||
CURL_EXTERN int curl_mvprintf(const char *format, va_list args);
|
||||
CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args);
|
||||
CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args);
|
||||
CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
|
||||
const char *format, va_list args);
|
||||
CURL_EXTERN char *curl_maprintf(const char *format, ...);
|
||||
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CURL_MPRINTF_H */
|
441
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/include/curl/multi.h
Executable file
441
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/include/curl/multi.h
Executable file
|
@ -0,0 +1,441 @@
|
|||
#ifndef __CURL_MULTI_H
|
||||
#define __CURL_MULTI_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/*
|
||||
This is an "external" header file. Don't give away any internals here!
|
||||
|
||||
GOALS
|
||||
|
||||
o Enable a "pull" interface. The application that uses libcurl decides where
|
||||
and when to ask libcurl to get/send data.
|
||||
|
||||
o Enable multiple simultaneous transfers in the same thread without making it
|
||||
complicated for the application.
|
||||
|
||||
o Enable the application to select() on its own file descriptors and curl's
|
||||
file descriptors simultaneous easily.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This header file should not really need to include "curl.h" since curl.h
|
||||
* itself includes this file and we expect user applications to do #include
|
||||
* <curl/curl.h> without the need for especially including multi.h.
|
||||
*
|
||||
* For some reason we added this include here at one point, and rather than to
|
||||
* break existing (wrongly written) libcurl applications, we leave it as-is
|
||||
* but with this warning attached.
|
||||
*/
|
||||
#include "curl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
|
||||
typedef struct Curl_multi CURLM;
|
||||
#else
|
||||
typedef void CURLM;
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
|
||||
curl_multi_socket*() soon */
|
||||
CURLM_OK,
|
||||
CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
|
||||
CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
|
||||
CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
|
||||
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
|
||||
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
|
||||
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
|
||||
CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
|
||||
attempted to get added - again */
|
||||
CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
|
||||
callback */
|
||||
CURLM_LAST
|
||||
} CURLMcode;
|
||||
|
||||
/* just to make code nicer when using curl_multi_socket() you can now check
|
||||
for CURLM_CALL_MULTI_SOCKET too in the same style it works for
|
||||
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
|
||||
#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
|
||||
|
||||
/* bitmask bits for CURLMOPT_PIPELINING */
|
||||
#define CURLPIPE_NOTHING 0L
|
||||
#define CURLPIPE_HTTP1 1L
|
||||
#define CURLPIPE_MULTIPLEX 2L
|
||||
|
||||
typedef enum {
|
||||
CURLMSG_NONE, /* first, not used */
|
||||
CURLMSG_DONE, /* This easy handle has completed. 'result' contains
|
||||
the CURLcode of the transfer */
|
||||
CURLMSG_LAST /* last, not used */
|
||||
} CURLMSG;
|
||||
|
||||
struct CURLMsg {
|
||||
CURLMSG msg; /* what this message means */
|
||||
CURL *easy_handle; /* the handle it concerns */
|
||||
union {
|
||||
void *whatever; /* message-specific data */
|
||||
CURLcode result; /* return code for transfer */
|
||||
} data;
|
||||
};
|
||||
typedef struct CURLMsg CURLMsg;
|
||||
|
||||
/* Based on poll(2) structure and values.
|
||||
* We don't use pollfd and POLL* constants explicitly
|
||||
* to cover platforms without poll(). */
|
||||
#define CURL_WAIT_POLLIN 0x0001
|
||||
#define CURL_WAIT_POLLPRI 0x0002
|
||||
#define CURL_WAIT_POLLOUT 0x0004
|
||||
|
||||
struct curl_waitfd {
|
||||
curl_socket_t fd;
|
||||
short events;
|
||||
short revents; /* not supported yet */
|
||||
};
|
||||
|
||||
/*
|
||||
* Name: curl_multi_init()
|
||||
*
|
||||
* Desc: inititalize multi-style curl usage
|
||||
*
|
||||
* Returns: a new CURLM handle to use in all 'curl_multi' functions.
|
||||
*/
|
||||
CURL_EXTERN CURLM *curl_multi_init(void);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_add_handle()
|
||||
*
|
||||
* Desc: add a standard curl handle to the multi stack
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_remove_handle()
|
||||
*
|
||||
* Desc: removes a curl handle from the multi stack again
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_fdset()
|
||||
*
|
||||
* Desc: Ask curl for its fd_set sets. The app can use these to select() or
|
||||
* poll() on. We want curl_multi_perform() called as soon as one of
|
||||
* them are ready.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
|
||||
fd_set *read_fd_set,
|
||||
fd_set *write_fd_set,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_wait()
|
||||
*
|
||||
* Desc: Poll on all fds within a CURLM set as well as any
|
||||
* additional fds passed to the function.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
|
||||
struct curl_waitfd extra_fds[],
|
||||
unsigned int extra_nfds,
|
||||
int timeout_ms,
|
||||
int *ret);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_perform()
|
||||
*
|
||||
* Desc: When the app thinks there's data available for curl it calls this
|
||||
* function to read/write whatever there is right now. This returns
|
||||
* as soon as the reads and writes are done. This function does not
|
||||
* require that there actually is data available for reading or that
|
||||
* data can be written, it can be called just in case. It returns
|
||||
* the number of handles that still transfer data in the second
|
||||
* argument's integer-pointer.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
|
||||
* returns errors etc regarding the whole multi stack. There might
|
||||
* still have occurred problems on individual transfers even when
|
||||
* this returns OK.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_cleanup()
|
||||
*
|
||||
* Desc: Cleans up and removes a whole multi stack. It does not free or
|
||||
* touch any individual easy handles in any way. We need to define
|
||||
* in what state those handles will be if this function is called
|
||||
* in the middle of a transfer.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_info_read()
|
||||
*
|
||||
* Desc: Ask the multi handle if there's any messages/informationals from
|
||||
* the individual transfers. Messages include informationals such as
|
||||
* error code from the transfer or just the fact that a transfer is
|
||||
* completed. More details on these should be written down as well.
|
||||
*
|
||||
* Repeated calls to this function will return a new struct each
|
||||
* time, until a special "end of msgs" struct is returned as a signal
|
||||
* that there is no more to get at this point.
|
||||
*
|
||||
* The data the returned pointer points to will not survive calling
|
||||
* curl_multi_cleanup().
|
||||
*
|
||||
* The 'CURLMsg' struct is meant to be very simple and only contain
|
||||
* very basic information. If more involved information is wanted,
|
||||
* we will provide the particular "transfer handle" in that struct
|
||||
* and that should/could/would be used in subsequent
|
||||
* curl_easy_getinfo() calls (or similar). The point being that we
|
||||
* must never expose complex structs to applications, as then we'll
|
||||
* undoubtably get backwards compatibility problems in the future.
|
||||
*
|
||||
* Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
|
||||
* of structs. It also writes the number of messages left in the
|
||||
* queue (after this read) in the integer the second argument points
|
||||
* to.
|
||||
*/
|
||||
CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
|
||||
int *msgs_in_queue);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_strerror()
|
||||
*
|
||||
* Desc: The curl_multi_strerror function may be used to turn a CURLMcode
|
||||
* value into the equivalent human readable error string. This is
|
||||
* useful for printing meaningful error messages.
|
||||
*
|
||||
* Returns: A pointer to a zero-terminated error message.
|
||||
*/
|
||||
CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_socket() and
|
||||
* curl_multi_socket_all()
|
||||
*
|
||||
* Desc: An alternative version of curl_multi_perform() that allows the
|
||||
* application to pass in one of the file descriptors that have been
|
||||
* detected to have "action" on them and let libcurl perform.
|
||||
* See man page for details.
|
||||
*/
|
||||
#define CURL_POLL_NONE 0
|
||||
#define CURL_POLL_IN 1
|
||||
#define CURL_POLL_OUT 2
|
||||
#define CURL_POLL_INOUT 3
|
||||
#define CURL_POLL_REMOVE 4
|
||||
|
||||
#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD
|
||||
|
||||
#define CURL_CSELECT_IN 0x01
|
||||
#define CURL_CSELECT_OUT 0x02
|
||||
#define CURL_CSELECT_ERR 0x04
|
||||
|
||||
typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */
|
||||
curl_socket_t s, /* socket */
|
||||
int what, /* see above */
|
||||
void *userp, /* private callback
|
||||
pointer */
|
||||
void *socketp); /* private socket
|
||||
pointer */
|
||||
/*
|
||||
* Name: curl_multi_timer_callback
|
||||
*
|
||||
* Desc: Called by libcurl whenever the library detects a change in the
|
||||
* maximum number of milliseconds the app is allowed to wait before
|
||||
* curl_multi_socket() or curl_multi_perform() must be called
|
||||
* (to allow libcurl's timed events to take place).
|
||||
*
|
||||
* Returns: The callback should return zero.
|
||||
*/
|
||||
typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
|
||||
long timeout_ms, /* see above */
|
||||
void *userp); /* private callback
|
||||
pointer */
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
|
||||
int *running_handles);
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
|
||||
curl_socket_t s,
|
||||
int ev_bitmask,
|
||||
int *running_handles);
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
|
||||
#ifndef CURL_ALLOW_OLD_MULTI_SOCKET
|
||||
/* This macro below was added in 7.16.3 to push users who recompile to use
|
||||
the new curl_multi_socket_action() instead of the old curl_multi_socket()
|
||||
*/
|
||||
#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Name: curl_multi_timeout()
|
||||
*
|
||||
* Desc: Returns the maximum number of milliseconds the app is allowed to
|
||||
* wait before curl_multi_socket() or curl_multi_perform() must be
|
||||
* called (to allow libcurl's timed events to take place).
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
|
||||
long *milliseconds);
|
||||
|
||||
#undef CINIT /* re-using the same name as in curl.h */
|
||||
|
||||
#ifdef CURL_ISOCPP
|
||||
#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
|
||||
#else
|
||||
/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
|
||||
#define LONG CURLOPTTYPE_LONG
|
||||
#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
|
||||
#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
|
||||
#define OFF_T CURLOPTTYPE_OFF_T
|
||||
#define CINIT(name,type,number) CURLMOPT_/**/name = type + number
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
/* This is the socket callback function pointer */
|
||||
CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),
|
||||
|
||||
/* This is the argument passed to the socket callback */
|
||||
CINIT(SOCKETDATA, OBJECTPOINT, 2),
|
||||
|
||||
/* set to 1 to enable pipelining for this multi handle */
|
||||
CINIT(PIPELINING, LONG, 3),
|
||||
|
||||
/* This is the timer callback function pointer */
|
||||
CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),
|
||||
|
||||
/* This is the argument passed to the timer callback */
|
||||
CINIT(TIMERDATA, OBJECTPOINT, 5),
|
||||
|
||||
/* maximum number of entries in the connection cache */
|
||||
CINIT(MAXCONNECTS, LONG, 6),
|
||||
|
||||
/* maximum number of (pipelining) connections to one host */
|
||||
CINIT(MAX_HOST_CONNECTIONS, LONG, 7),
|
||||
|
||||
/* maximum number of requests in a pipeline */
|
||||
CINIT(MAX_PIPELINE_LENGTH, LONG, 8),
|
||||
|
||||
/* a connection with a content-length longer than this
|
||||
will not be considered for pipelining */
|
||||
CINIT(CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9),
|
||||
|
||||
/* a connection with a chunk length longer than this
|
||||
will not be considered for pipelining */
|
||||
CINIT(CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10),
|
||||
|
||||
/* a list of site names(+port) that are blacklisted from
|
||||
pipelining */
|
||||
CINIT(PIPELINING_SITE_BL, OBJECTPOINT, 11),
|
||||
|
||||
/* a list of server types that are blacklisted from
|
||||
pipelining */
|
||||
CINIT(PIPELINING_SERVER_BL, OBJECTPOINT, 12),
|
||||
|
||||
/* maximum number of open connections in total */
|
||||
CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13),
|
||||
|
||||
/* This is the server push callback function pointer */
|
||||
CINIT(PUSHFUNCTION, FUNCTIONPOINT, 14),
|
||||
|
||||
/* This is the argument passed to the server push callback */
|
||||
CINIT(PUSHDATA, OBJECTPOINT, 15),
|
||||
|
||||
CURLMOPT_LASTENTRY /* the last unused */
|
||||
} CURLMoption;
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_multi_setopt()
|
||||
*
|
||||
* Desc: Sets options for the multi handle.
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
|
||||
CURLMoption option, ...);
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_multi_assign()
|
||||
*
|
||||
* Desc: This function sets an association in the multi handle between the
|
||||
* given socket and a private pointer of the application. This is
|
||||
* (only) useful for curl_multi_socket uses.
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
|
||||
curl_socket_t sockfd, void *sockp);
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_push_callback
|
||||
*
|
||||
* Desc: This callback gets called when a new stream is being pushed by the
|
||||
* server. It approves or denies the new stream.
|
||||
*
|
||||
* Returns: CURL_PUSH_OK or CURL_PUSH_DENY.
|
||||
*/
|
||||
#define CURL_PUSH_OK 0
|
||||
#define CURL_PUSH_DENY 1
|
||||
|
||||
struct curl_pushheaders; /* forward declaration only */
|
||||
|
||||
CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
|
||||
size_t num);
|
||||
CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
|
||||
const char *name);
|
||||
|
||||
typedef int (*curl_push_callback)(CURL *parent,
|
||||
CURL *easy,
|
||||
size_t num_headers,
|
||||
struct curl_pushheaders *headers,
|
||||
void *userp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef __STDC_HEADERS_H
|
||||
#define __STDC_HEADERS_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
size_t fread(void *, size_t, size_t, FILE *);
|
||||
size_t fwrite(const void *, size_t, size_t, FILE *);
|
||||
|
||||
int strcasecmp(const char *, const char *);
|
||||
int strncasecmp(const char *, const char *, size_t);
|
||||
|
||||
#endif /* __STDC_HEADERS_H */
|
493
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/include/curl/system.h
Executable file
493
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/include/curl/system.h
Executable file
|
@ -0,0 +1,493 @@
|
|||
#ifndef __CURL_SYSTEM_H
|
||||
#define __CURL_SYSTEM_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* Try to keep one section per platform, compiler and architecture, otherwise,
|
||||
* if an existing section is reused for a different one and later on the
|
||||
* original is adjusted, probably the piggybacking one can be adversely
|
||||
* changed.
|
||||
*
|
||||
* In order to differentiate between platforms/compilers/architectures use
|
||||
* only compiler built in predefined preprocessor symbols.
|
||||
*
|
||||
* curl_off_t
|
||||
* ----------
|
||||
*
|
||||
* For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
|
||||
* wide signed integral data type. The width of this data type must remain
|
||||
* constant and independent of any possible large file support settings.
|
||||
*
|
||||
* As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit
|
||||
* wide signed integral data type if there is no 64-bit type.
|
||||
*
|
||||
* As a general rule, curl_off_t shall not be mapped to off_t. This rule shall
|
||||
* only be violated if off_t is the only 64-bit data type available and the
|
||||
* size of off_t is independent of large file support settings. Keep your
|
||||
* build on the safe side avoiding an off_t gating. If you have a 64-bit
|
||||
* off_t then take for sure that another 64-bit data type exists, dig deeper
|
||||
* and you will find it.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(__DJGPP__) || defined(__GO32__)
|
||||
# if defined(__DJGPP__) && (__DJGPP__ > 1)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__SALFORDC__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__BORLANDC__)
|
||||
# if (__BORLANDC__ < 0x520)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__TURBOC__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(__386__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__POCC__)
|
||||
# if (__POCC__ < 280)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# elif defined(_MSC_VER)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__LCC__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__SYMBIAN32__)
|
||||
# if defined(__EABI__) /* Treat all ARM compilers equally */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__CW32__)
|
||||
# pragma longlong on
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__VC32__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||
|
||||
#elif defined(__MWERKS__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(_WIN32_WCE)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_WS2TCPIP_H 1
|
||||
|
||||
#elif defined(__VMS)
|
||||
# if defined(__VAX)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||
|
||||
#elif defined(__OS400__)
|
||||
# if defined(__ILEC400__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(__MVS__)
|
||||
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||
# if defined(_ILP32)
|
||||
# elif defined(_LP64)
|
||||
# endif
|
||||
# if defined(_LONG_LONG)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(__370__)
|
||||
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||
# if defined(_ILP32)
|
||||
# elif defined(_LP64)
|
||||
# endif
|
||||
# if defined(_LONG_LONG)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(TPF)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__TINYC__) /* also known as tcc */
|
||||
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */
|
||||
# if !defined(__LP64) && (defined(__ILP32) || \
|
||||
defined(__i386) || \
|
||||
defined(__sparcv8) || \
|
||||
defined(__sparcv8plus))
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__LP64) || \
|
||||
defined(__amd64) || defined(__sparcv9)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__xlc__) /* IBM xlc compiler */
|
||||
# if !defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
/* ===================================== */
|
||||
/* KEEP MSVC THE PENULTIMATE ENTRY */
|
||||
/* ===================================== */
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
/* ===================================== */
|
||||
/* KEEP GENERIC GCC THE LAST ENTRY */
|
||||
/* ===================================== */
|
||||
|
||||
#elif defined(__GNUC__) && !defined(_SCO_DS)
|
||||
# if !defined(__LP64__) && \
|
||||
(defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
|
||||
defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
|
||||
defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
|
||||
defined(__XTENSA__) || \
|
||||
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
|
||||
(defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L))
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__LP64__) || \
|
||||
defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
|
||||
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
|
||||
(defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#else
|
||||
/* generic "safe guess" on old 32 bit style */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
#endif
|
||||
|
||||
#ifdef _AIX
|
||||
/* AIX needs <sys/poll.h> */
|
||||
#define CURL_PULL_SYS_POLL_H
|
||||
#endif
|
||||
|
||||
|
||||
/* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */
|
||||
/* ws2tcpip.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_WS2TCPIP_H
|
||||
# include <winsock2.h>
|
||||
# include <windows.h>
|
||||
# include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
|
||||
/* sys/types.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
|
||||
/* sys/socket.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
|
||||
/* sys/poll.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_POLL_H
|
||||
# include <sys/poll.h>
|
||||
#endif
|
||||
|
||||
/* Data type definition of curl_socklen_t. */
|
||||
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
|
||||
typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
|
||||
#endif
|
||||
|
||||
/* Data type definition of curl_off_t. */
|
||||
|
||||
#ifdef CURL_TYPEOF_CURL_OFF_T
|
||||
typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
|
||||
* these to be visible and exported by the external libcurl interface API,
|
||||
* while also making them visible to the library internals, simply including
|
||||
* curl_setup.h, without actually needing to include curl.h internally.
|
||||
* If some day this section would grow big enough, all this should be moved
|
||||
* to its own header file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Figure out if we can use the ## preprocessor operator, which is supported
|
||||
* by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
|
||||
* or __cplusplus so we need to carefully check for them too.
|
||||
*/
|
||||
|
||||
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
|
||||
defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
|
||||
defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
|
||||
defined(__ILEC400__)
|
||||
/* This compiler is believed to have an ISO compatible preprocessor */
|
||||
#define CURL_ISOCPP
|
||||
#else
|
||||
/* This compiler is believed NOT to have an ISO compatible preprocessor */
|
||||
#undef CURL_ISOCPP
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
|
||||
*/
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
|
||||
# define __CURL_OFF_T_C_HLPR2(x) x
|
||||
# define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x)
|
||||
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
|
||||
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
|
||||
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
|
||||
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
|
||||
#else
|
||||
# ifdef CURL_ISOCPP
|
||||
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
|
||||
# else
|
||||
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
|
||||
# endif
|
||||
# define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix)
|
||||
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
|
||||
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
|
||||
#endif
|
||||
|
||||
#endif /* __CURL_SYSTEM_H */
|
|
@ -0,0 +1,699 @@
|
|||
#ifndef __CURL_TYPECHECK_GCC_H
|
||||
#define __CURL_TYPECHECK_GCC_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* wraps curl_easy_setopt() with typechecking */
|
||||
|
||||
/* To add a new kind of warning, add an
|
||||
* if(_curl_is_sometype_option(_curl_opt))
|
||||
* if(!_curl_is_sometype(value))
|
||||
* _curl_easy_setopt_err_sometype();
|
||||
* block and define _curl_is_sometype_option, _curl_is_sometype and
|
||||
* _curl_easy_setopt_err_sometype below
|
||||
*
|
||||
* NOTE: We use two nested 'if' statements here instead of the && operator, in
|
||||
* order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x
|
||||
* when compiling with -Wlogical-op.
|
||||
*
|
||||
* To add an option that uses the same type as an existing option, you'll just
|
||||
* need to extend the appropriate _curl_*_option macro
|
||||
*/
|
||||
#define curl_easy_setopt(handle, option, value) \
|
||||
__extension__ ({ \
|
||||
__typeof__(option) _curl_opt = option; \
|
||||
if(__builtin_constant_p(_curl_opt)) { \
|
||||
if(_curl_is_long_option(_curl_opt)) \
|
||||
if(!_curl_is_long(value)) \
|
||||
_curl_easy_setopt_err_long(); \
|
||||
if(_curl_is_off_t_option(_curl_opt)) \
|
||||
if(!_curl_is_off_t(value)) \
|
||||
_curl_easy_setopt_err_curl_off_t(); \
|
||||
if(_curl_is_string_option(_curl_opt)) \
|
||||
if(!_curl_is_string(value)) \
|
||||
_curl_easy_setopt_err_string(); \
|
||||
if(_curl_is_write_cb_option(_curl_opt)) \
|
||||
if(!_curl_is_write_cb(value)) \
|
||||
_curl_easy_setopt_err_write_callback(); \
|
||||
if((_curl_opt) == CURLOPT_RESOLVER_START_FUNCTION) \
|
||||
if(!_curl_is_resolver_start_callback(value)) \
|
||||
_curl_easy_setopt_err_resolver_start_callback(); \
|
||||
if((_curl_opt) == CURLOPT_READFUNCTION) \
|
||||
if(!_curl_is_read_cb(value)) \
|
||||
_curl_easy_setopt_err_read_cb(); \
|
||||
if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \
|
||||
if(!_curl_is_ioctl_cb(value)) \
|
||||
_curl_easy_setopt_err_ioctl_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \
|
||||
if(!_curl_is_sockopt_cb(value)) \
|
||||
_curl_easy_setopt_err_sockopt_cb(); \
|
||||
if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \
|
||||
if(!_curl_is_opensocket_cb(value)) \
|
||||
_curl_easy_setopt_err_opensocket_cb(); \
|
||||
if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \
|
||||
if(!_curl_is_progress_cb(value)) \
|
||||
_curl_easy_setopt_err_progress_cb(); \
|
||||
if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \
|
||||
if(!_curl_is_debug_cb(value)) \
|
||||
_curl_easy_setopt_err_debug_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \
|
||||
if(!_curl_is_ssl_ctx_cb(value)) \
|
||||
_curl_easy_setopt_err_ssl_ctx_cb(); \
|
||||
if(_curl_is_conv_cb_option(_curl_opt)) \
|
||||
if(!_curl_is_conv_cb(value)) \
|
||||
_curl_easy_setopt_err_conv_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SEEKFUNCTION) \
|
||||
if(!_curl_is_seek_cb(value)) \
|
||||
_curl_easy_setopt_err_seek_cb(); \
|
||||
if(_curl_is_cb_data_option(_curl_opt)) \
|
||||
if(!_curl_is_cb_data(value)) \
|
||||
_curl_easy_setopt_err_cb_data(); \
|
||||
if((_curl_opt) == CURLOPT_ERRORBUFFER) \
|
||||
if(!_curl_is_error_buffer(value)) \
|
||||
_curl_easy_setopt_err_error_buffer(); \
|
||||
if((_curl_opt) == CURLOPT_STDERR) \
|
||||
if(!_curl_is_FILE(value)) \
|
||||
_curl_easy_setopt_err_FILE(); \
|
||||
if(_curl_is_postfields_option(_curl_opt)) \
|
||||
if(!_curl_is_postfields(value)) \
|
||||
_curl_easy_setopt_err_postfields(); \
|
||||
if((_curl_opt) == CURLOPT_HTTPPOST) \
|
||||
if(!_curl_is_arr((value), struct curl_httppost)) \
|
||||
_curl_easy_setopt_err_curl_httpost(); \
|
||||
if((_curl_opt) == CURLOPT_MIMEPOST) \
|
||||
if(!_curl_is_ptr((value), curl_mime)) \
|
||||
_curl_easy_setopt_err_curl_mimepost(); \
|
||||
if(_curl_is_slist_option(_curl_opt)) \
|
||||
if(!_curl_is_arr((value), struct curl_slist)) \
|
||||
_curl_easy_setopt_err_curl_slist(); \
|
||||
if((_curl_opt) == CURLOPT_SHARE) \
|
||||
if(!_curl_is_ptr((value), CURLSH)) \
|
||||
_curl_easy_setopt_err_CURLSH(); \
|
||||
} \
|
||||
curl_easy_setopt(handle, _curl_opt, value); \
|
||||
})
|
||||
|
||||
/* wraps curl_easy_getinfo() with typechecking */
|
||||
/* FIXME: don't allow const pointers */
|
||||
#define curl_easy_getinfo(handle, info, arg) \
|
||||
__extension__ ({ \
|
||||
__typeof__(info) _curl_info = info; \
|
||||
if(__builtin_constant_p(_curl_info)) { \
|
||||
if(_curl_is_string_info(_curl_info)) \
|
||||
if(!_curl_is_arr((arg), char *)) \
|
||||
_curl_easy_getinfo_err_string(); \
|
||||
if(_curl_is_long_info(_curl_info)) \
|
||||
if(!_curl_is_arr((arg), long)) \
|
||||
_curl_easy_getinfo_err_long(); \
|
||||
if(_curl_is_double_info(_curl_info)) \
|
||||
if(!_curl_is_arr((arg), double)) \
|
||||
_curl_easy_getinfo_err_double(); \
|
||||
if(_curl_is_slist_info(_curl_info)) \
|
||||
if(!_curl_is_arr((arg), struct curl_slist *)) \
|
||||
_curl_easy_getinfo_err_curl_slist(); \
|
||||
if(_curl_is_tlssessioninfo_info(_curl_info)) \
|
||||
if(!_curl_is_arr((arg), struct curl_tlssessioninfo *)) \
|
||||
_curl_easy_getinfo_err_curl_tlssesssioninfo(); \
|
||||
if(_curl_is_certinfo_info(_curl_info)) \
|
||||
if(!_curl_is_arr((arg), struct curl_certinfo *)) \
|
||||
_curl_easy_getinfo_err_curl_certinfo(); \
|
||||
if(_curl_is_socket_info(_curl_info)) \
|
||||
if(!_curl_is_arr((arg), curl_socket_t)) \
|
||||
_curl_easy_getinfo_err_curl_socket(); \
|
||||
if(_curl_is_off_t_info(_curl_info)) \
|
||||
if(!_curl_is_arr((arg), curl_off_t)) \
|
||||
_curl_easy_getinfo_err_curl_off_t(); \
|
||||
} \
|
||||
curl_easy_getinfo(handle, _curl_info, arg); \
|
||||
})
|
||||
|
||||
/* TODO: typechecking for curl_share_setopt() and curl_multi_setopt(),
|
||||
* for now just make sure that the functions are called with three
|
||||
* arguments
|
||||
*/
|
||||
#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
|
||||
#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
|
||||
|
||||
|
||||
/* the actual warnings, triggered by calling the _curl_easy_setopt_err*
|
||||
* functions */
|
||||
|
||||
/* To define a new warning, use _CURL_WARNING(identifier, "message") */
|
||||
#define _CURL_WARNING(id, message) \
|
||||
static void __attribute__((__warning__(message))) \
|
||||
__attribute__((__unused__)) __attribute__((__noinline__)) \
|
||||
id(void) { __asm__(""); }
|
||||
|
||||
_CURL_WARNING(_curl_easy_setopt_err_long,
|
||||
"curl_easy_setopt expects a long argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_curl_off_t,
|
||||
"curl_easy_setopt expects a curl_off_t argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_string,
|
||||
"curl_easy_setopt expects a "
|
||||
"string ('char *' or char[]) argument for this option"
|
||||
)
|
||||
_CURL_WARNING(_curl_easy_setopt_err_write_callback,
|
||||
"curl_easy_setopt expects a curl_write_callback argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_resolver_start_callback,
|
||||
"curl_easy_setopt expects a "
|
||||
"curl_resolver_start_callback argument for this option"
|
||||
)
|
||||
_CURL_WARNING(_curl_easy_setopt_err_read_cb,
|
||||
"curl_easy_setopt expects a curl_read_callback argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_ioctl_cb,
|
||||
"curl_easy_setopt expects a curl_ioctl_callback argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_sockopt_cb,
|
||||
"curl_easy_setopt expects a curl_sockopt_callback argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_opensocket_cb,
|
||||
"curl_easy_setopt expects a "
|
||||
"curl_opensocket_callback argument for this option"
|
||||
)
|
||||
_CURL_WARNING(_curl_easy_setopt_err_progress_cb,
|
||||
"curl_easy_setopt expects a curl_progress_callback argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_debug_cb,
|
||||
"curl_easy_setopt expects a curl_debug_callback argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb,
|
||||
"curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_conv_cb,
|
||||
"curl_easy_setopt expects a curl_conv_callback argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_seek_cb,
|
||||
"curl_easy_setopt expects a curl_seek_callback argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_cb_data,
|
||||
"curl_easy_setopt expects a "
|
||||
"private data pointer as argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_error_buffer,
|
||||
"curl_easy_setopt expects a "
|
||||
"char buffer of CURL_ERROR_SIZE as argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_FILE,
|
||||
"curl_easy_setopt expects a 'FILE *' argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_postfields,
|
||||
"curl_easy_setopt expects a 'void *' or 'char *' argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_curl_httpost,
|
||||
"curl_easy_setopt expects a 'struct curl_httppost *' "
|
||||
"argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_curl_mimepost,
|
||||
"curl_easy_setopt expects a 'curl_mime *' "
|
||||
"argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_curl_slist,
|
||||
"curl_easy_setopt expects a 'struct curl_slist *' argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_CURLSH,
|
||||
"curl_easy_setopt expects a CURLSH* argument for this option")
|
||||
|
||||
_CURL_WARNING(_curl_easy_getinfo_err_string,
|
||||
"curl_easy_getinfo expects a pointer to 'char *' for this info")
|
||||
_CURL_WARNING(_curl_easy_getinfo_err_long,
|
||||
"curl_easy_getinfo expects a pointer to long for this info")
|
||||
_CURL_WARNING(_curl_easy_getinfo_err_double,
|
||||
"curl_easy_getinfo expects a pointer to double for this info")
|
||||
_CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
|
||||
"curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info")
|
||||
_CURL_WARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo,
|
||||
"curl_easy_getinfo expects a pointer to "
|
||||
"'struct curl_tlssessioninfo *' for this info")
|
||||
_CURL_WARNING(_curl_easy_getinfo_err_curl_certinfo,
|
||||
"curl_easy_getinfo expects a pointer to "
|
||||
"'struct curl_certinfo *' for this info")
|
||||
_CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
|
||||
"curl_easy_getinfo expects a pointer to curl_socket_t for this info")
|
||||
_CURL_WARNING(_curl_easy_getinfo_err_curl_off_t,
|
||||
"curl_easy_getinfo expects a pointer to curl_off_t for this info")
|
||||
|
||||
/* groups of curl_easy_setops options that take the same type of argument */
|
||||
|
||||
/* To add a new option to one of the groups, just add
|
||||
* (option) == CURLOPT_SOMETHING
|
||||
* to the or-expression. If the option takes a long or curl_off_t, you don't
|
||||
* have to do anything
|
||||
*/
|
||||
|
||||
/* evaluates to true if option takes a long argument */
|
||||
#define _curl_is_long_option(option) \
|
||||
(0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
|
||||
|
||||
#define _curl_is_off_t_option(option) \
|
||||
((option) > CURLOPTTYPE_OFF_T)
|
||||
|
||||
/* evaluates to true if option takes a char* argument */
|
||||
#define _curl_is_string_option(option) \
|
||||
((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \
|
||||
(option) == CURLOPT_ACCEPT_ENCODING || \
|
||||
(option) == CURLOPT_CAINFO || \
|
||||
(option) == CURLOPT_CAPATH || \
|
||||
(option) == CURLOPT_COOKIE || \
|
||||
(option) == CURLOPT_COOKIEFILE || \
|
||||
(option) == CURLOPT_COOKIEJAR || \
|
||||
(option) == CURLOPT_COOKIELIST || \
|
||||
(option) == CURLOPT_CRLFILE || \
|
||||
(option) == CURLOPT_CUSTOMREQUEST || \
|
||||
(option) == CURLOPT_DEFAULT_PROTOCOL || \
|
||||
(option) == CURLOPT_DNS_INTERFACE || \
|
||||
(option) == CURLOPT_DNS_LOCAL_IP4 || \
|
||||
(option) == CURLOPT_DNS_LOCAL_IP6 || \
|
||||
(option) == CURLOPT_DNS_SERVERS || \
|
||||
(option) == CURLOPT_DOH_URL || \
|
||||
(option) == CURLOPT_EGDSOCKET || \
|
||||
(option) == CURLOPT_FTPPORT || \
|
||||
(option) == CURLOPT_FTP_ACCOUNT || \
|
||||
(option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
|
||||
(option) == CURLOPT_INTERFACE || \
|
||||
(option) == CURLOPT_ISSUERCERT || \
|
||||
(option) == CURLOPT_KEYPASSWD || \
|
||||
(option) == CURLOPT_KRBLEVEL || \
|
||||
(option) == CURLOPT_LOGIN_OPTIONS || \
|
||||
(option) == CURLOPT_MAIL_AUTH || \
|
||||
(option) == CURLOPT_MAIL_FROM || \
|
||||
(option) == CURLOPT_NETRC_FILE || \
|
||||
(option) == CURLOPT_NOPROXY || \
|
||||
(option) == CURLOPT_PASSWORD || \
|
||||
(option) == CURLOPT_PINNEDPUBLICKEY || \
|
||||
(option) == CURLOPT_PRE_PROXY || \
|
||||
(option) == CURLOPT_PROXY || \
|
||||
(option) == CURLOPT_PROXYPASSWORD || \
|
||||
(option) == CURLOPT_PROXYUSERNAME || \
|
||||
(option) == CURLOPT_PROXYUSERPWD || \
|
||||
(option) == CURLOPT_PROXY_CAINFO || \
|
||||
(option) == CURLOPT_PROXY_CAPATH || \
|
||||
(option) == CURLOPT_PROXY_CRLFILE || \
|
||||
(option) == CURLOPT_PROXY_KEYPASSWD || \
|
||||
(option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \
|
||||
(option) == CURLOPT_PROXY_SERVICE_NAME || \
|
||||
(option) == CURLOPT_PROXY_SSLCERT || \
|
||||
(option) == CURLOPT_PROXY_SSLCERTTYPE || \
|
||||
(option) == CURLOPT_PROXY_SSLKEY || \
|
||||
(option) == CURLOPT_PROXY_SSLKEYTYPE || \
|
||||
(option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \
|
||||
(option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \
|
||||
(option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \
|
||||
(option) == CURLOPT_PROXY_TLSAUTH_TYPE || \
|
||||
(option) == CURLOPT_RANDOM_FILE || \
|
||||
(option) == CURLOPT_RANGE || \
|
||||
(option) == CURLOPT_REFERER || \
|
||||
(option) == CURLOPT_RTSP_SESSION_ID || \
|
||||
(option) == CURLOPT_RTSP_STREAM_URI || \
|
||||
(option) == CURLOPT_RTSP_TRANSPORT || \
|
||||
(option) == CURLOPT_SERVICE_NAME || \
|
||||
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
|
||||
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
|
||||
(option) == CURLOPT_SSH_KNOWNHOSTS || \
|
||||
(option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
|
||||
(option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
|
||||
(option) == CURLOPT_SSLCERT || \
|
||||
(option) == CURLOPT_SSLCERTTYPE || \
|
||||
(option) == CURLOPT_SSLENGINE || \
|
||||
(option) == CURLOPT_SSLKEY || \
|
||||
(option) == CURLOPT_SSLKEYTYPE || \
|
||||
(option) == CURLOPT_SSL_CIPHER_LIST || \
|
||||
(option) == CURLOPT_TLSAUTH_PASSWORD || \
|
||||
(option) == CURLOPT_TLSAUTH_TYPE || \
|
||||
(option) == CURLOPT_TLSAUTH_USERNAME || \
|
||||
(option) == CURLOPT_UNIX_SOCKET_PATH || \
|
||||
(option) == CURLOPT_URL || \
|
||||
(option) == CURLOPT_USERAGENT || \
|
||||
(option) == CURLOPT_USERNAME || \
|
||||
(option) == CURLOPT_USERPWD || \
|
||||
(option) == CURLOPT_XOAUTH2_BEARER || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a curl_write_callback argument */
|
||||
#define _curl_is_write_cb_option(option) \
|
||||
((option) == CURLOPT_HEADERFUNCTION || \
|
||||
(option) == CURLOPT_WRITEFUNCTION)
|
||||
|
||||
/* evaluates to true if option takes a curl_conv_callback argument */
|
||||
#define _curl_is_conv_cb_option(option) \
|
||||
((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
|
||||
(option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
|
||||
(option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
|
||||
|
||||
/* evaluates to true if option takes a data argument to pass to a callback */
|
||||
#define _curl_is_cb_data_option(option) \
|
||||
((option) == CURLOPT_CHUNK_DATA || \
|
||||
(option) == CURLOPT_CLOSESOCKETDATA || \
|
||||
(option) == CURLOPT_DEBUGDATA || \
|
||||
(option) == CURLOPT_FNMATCH_DATA || \
|
||||
(option) == CURLOPT_HEADERDATA || \
|
||||
(option) == CURLOPT_INTERLEAVEDATA || \
|
||||
(option) == CURLOPT_IOCTLDATA || \
|
||||
(option) == CURLOPT_OPENSOCKETDATA || \
|
||||
(option) == CURLOPT_PRIVATE || \
|
||||
(option) == CURLOPT_PROGRESSDATA || \
|
||||
(option) == CURLOPT_READDATA || \
|
||||
(option) == CURLOPT_SEEKDATA || \
|
||||
(option) == CURLOPT_SOCKOPTDATA || \
|
||||
(option) == CURLOPT_SSH_KEYDATA || \
|
||||
(option) == CURLOPT_SSL_CTX_DATA || \
|
||||
(option) == CURLOPT_WRITEDATA || \
|
||||
(option) == CURLOPT_RESOLVER_START_DATA || \
|
||||
(option) == CURLOPT_CURLU || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a POST data argument (void* or char*) */
|
||||
#define _curl_is_postfields_option(option) \
|
||||
((option) == CURLOPT_POSTFIELDS || \
|
||||
(option) == CURLOPT_COPYPOSTFIELDS || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a struct curl_slist * argument */
|
||||
#define _curl_is_slist_option(option) \
|
||||
((option) == CURLOPT_HTTP200ALIASES || \
|
||||
(option) == CURLOPT_HTTPHEADER || \
|
||||
(option) == CURLOPT_MAIL_RCPT || \
|
||||
(option) == CURLOPT_POSTQUOTE || \
|
||||
(option) == CURLOPT_PREQUOTE || \
|
||||
(option) == CURLOPT_PROXYHEADER || \
|
||||
(option) == CURLOPT_QUOTE || \
|
||||
(option) == CURLOPT_RESOLVE || \
|
||||
(option) == CURLOPT_TELNETOPTIONS || \
|
||||
0)
|
||||
|
||||
/* groups of curl_easy_getinfo infos that take the same type of argument */
|
||||
|
||||
/* evaluates to true if info expects a pointer to char * argument */
|
||||
#define _curl_is_string_info(info) \
|
||||
(CURLINFO_STRING < (info) && (info) < CURLINFO_LONG)
|
||||
|
||||
/* evaluates to true if info expects a pointer to long argument */
|
||||
#define _curl_is_long_info(info) \
|
||||
(CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
|
||||
|
||||
/* evaluates to true if info expects a pointer to double argument */
|
||||
#define _curl_is_double_info(info) \
|
||||
(CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
|
||||
|
||||
/* true if info expects a pointer to struct curl_slist * argument */
|
||||
#define _curl_is_slist_info(info) \
|
||||
(((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST))
|
||||
|
||||
/* true if info expects a pointer to struct curl_tlssessioninfo * argument */
|
||||
#define _curl_is_tlssessioninfo_info(info) \
|
||||
(((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION))
|
||||
|
||||
/* true if info expects a pointer to struct curl_certinfo * argument */
|
||||
#define _curl_is_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
|
||||
|
||||
/* true if info expects a pointer to struct curl_socket_t argument */
|
||||
#define _curl_is_socket_info(info) \
|
||||
(CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
|
||||
|
||||
/* true if info expects a pointer to curl_off_t argument */
|
||||
#define _curl_is_off_t_info(info) \
|
||||
(CURLINFO_OFF_T < (info))
|
||||
|
||||
|
||||
/* typecheck helpers -- check whether given expression has requested type*/
|
||||
|
||||
/* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros,
|
||||
* otherwise define a new macro. Search for __builtin_types_compatible_p
|
||||
* in the GCC manual.
|
||||
* NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
|
||||
* the actual expression passed to the curl_easy_setopt macro. This
|
||||
* means that you can only apply the sizeof and __typeof__ operators, no
|
||||
* == or whatsoever.
|
||||
*/
|
||||
|
||||
/* XXX: should evaluate to true if expr is a pointer */
|
||||
#define _curl_is_any_ptr(expr) \
|
||||
(sizeof(expr) == sizeof(void *))
|
||||
|
||||
/* evaluates to true if expr is NULL */
|
||||
/* XXX: must not evaluate expr, so this check is not accurate */
|
||||
#define _curl_is_NULL(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
|
||||
|
||||
/* evaluates to true if expr is type*, const type* or NULL */
|
||||
#define _curl_is_ptr(expr, type) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), type *) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), const type *))
|
||||
|
||||
/* evaluates to true if expr is one of type[], type*, NULL or const type* */
|
||||
#define _curl_is_arr(expr, type) \
|
||||
(_curl_is_ptr((expr), type) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), type []))
|
||||
|
||||
/* evaluates to true if expr is a string */
|
||||
#define _curl_is_string(expr) \
|
||||
(_curl_is_arr((expr), char) || \
|
||||
_curl_is_arr((expr), signed char) || \
|
||||
_curl_is_arr((expr), unsigned char))
|
||||
|
||||
/* evaluates to true if expr is a long (no matter the signedness)
|
||||
* XXX: for now, int is also accepted (and therefore short and char, which
|
||||
* are promoted to int when passed to a variadic function) */
|
||||
#define _curl_is_long(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), long) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed long) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), int) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed int) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned int) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), short) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed short) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned short) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed char) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned char))
|
||||
|
||||
/* evaluates to true if expr is of type curl_off_t */
|
||||
#define _curl_is_off_t(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
|
||||
|
||||
/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
|
||||
/* XXX: also check size of an char[] array? */
|
||||
#define _curl_is_error_buffer(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char *) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char[]))
|
||||
|
||||
/* evaluates to true if expr is of type (const) void* or (const) FILE* */
|
||||
#if 0
|
||||
#define _curl_is_cb_data(expr) \
|
||||
(_curl_is_ptr((expr), void) || \
|
||||
_curl_is_ptr((expr), FILE))
|
||||
#else /* be less strict */
|
||||
#define _curl_is_cb_data(expr) \
|
||||
_curl_is_any_ptr(expr)
|
||||
#endif
|
||||
|
||||
/* evaluates to true if expr is of type FILE* */
|
||||
#define _curl_is_FILE(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), FILE *)))
|
||||
|
||||
/* evaluates to true if expr can be passed as POST data (void* or char*) */
|
||||
#define _curl_is_postfields(expr) \
|
||||
(_curl_is_ptr((expr), void) || \
|
||||
_curl_is_arr((expr), char) || \
|
||||
_curl_is_arr((expr), unsigned char))
|
||||
|
||||
/* FIXME: the whole callback checking is messy...
|
||||
* The idea is to tolerate char vs. void and const vs. not const
|
||||
* pointers in arguments at least
|
||||
*/
|
||||
/* helper: __builtin_types_compatible_p distinguishes between functions and
|
||||
* function pointers, hide it */
|
||||
#define _curl_callback_compatible(func, type) \
|
||||
(__builtin_types_compatible_p(__typeof__(func), type) || \
|
||||
__builtin_types_compatible_p(__typeof__(func) *, type))
|
||||
|
||||
/* evaluates to true if expr is of type curl_resolver_start_callback */
|
||||
#define _curl_is_resolver_start_callback(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
_curl_callback_compatible((expr), curl_resolver_start_callback))
|
||||
|
||||
/* evaluates to true if expr is of type curl_read_callback or "similar" */
|
||||
#define _curl_is_read_cb(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
_curl_callback_compatible((expr), __typeof__(fread) *) || \
|
||||
_curl_callback_compatible((expr), curl_read_callback) || \
|
||||
_curl_callback_compatible((expr), _curl_read_callback1) || \
|
||||
_curl_callback_compatible((expr), _curl_read_callback2) || \
|
||||
_curl_callback_compatible((expr), _curl_read_callback3) || \
|
||||
_curl_callback_compatible((expr), _curl_read_callback4) || \
|
||||
_curl_callback_compatible((expr), _curl_read_callback5) || \
|
||||
_curl_callback_compatible((expr), _curl_read_callback6))
|
||||
typedef size_t (*_curl_read_callback1)(char *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_read_callback2)(char *, size_t, size_t, const void *);
|
||||
typedef size_t (*_curl_read_callback3)(char *, size_t, size_t, FILE *);
|
||||
typedef size_t (*_curl_read_callback4)(void *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_read_callback5)(void *, size_t, size_t, const void *);
|
||||
typedef size_t (*_curl_read_callback6)(void *, size_t, size_t, FILE *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_write_callback or "similar" */
|
||||
#define _curl_is_write_cb(expr) \
|
||||
(_curl_is_read_cb(expr) || \
|
||||
_curl_callback_compatible((expr), __typeof__(fwrite) *) || \
|
||||
_curl_callback_compatible((expr), curl_write_callback) || \
|
||||
_curl_callback_compatible((expr), _curl_write_callback1) || \
|
||||
_curl_callback_compatible((expr), _curl_write_callback2) || \
|
||||
_curl_callback_compatible((expr), _curl_write_callback3) || \
|
||||
_curl_callback_compatible((expr), _curl_write_callback4) || \
|
||||
_curl_callback_compatible((expr), _curl_write_callback5) || \
|
||||
_curl_callback_compatible((expr), _curl_write_callback6))
|
||||
typedef size_t (*_curl_write_callback1)(const char *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_write_callback2)(const char *, size_t, size_t,
|
||||
const void *);
|
||||
typedef size_t (*_curl_write_callback3)(const char *, size_t, size_t, FILE *);
|
||||
typedef size_t (*_curl_write_callback4)(const void *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_write_callback5)(const void *, size_t, size_t,
|
||||
const void *);
|
||||
typedef size_t (*_curl_write_callback6)(const void *, size_t, size_t, FILE *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
|
||||
#define _curl_is_ioctl_cb(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
_curl_callback_compatible((expr), curl_ioctl_callback) || \
|
||||
_curl_callback_compatible((expr), _curl_ioctl_callback1) || \
|
||||
_curl_callback_compatible((expr), _curl_ioctl_callback2) || \
|
||||
_curl_callback_compatible((expr), _curl_ioctl_callback3) || \
|
||||
_curl_callback_compatible((expr), _curl_ioctl_callback4))
|
||||
typedef curlioerr (*_curl_ioctl_callback1)(CURL *, int, void *);
|
||||
typedef curlioerr (*_curl_ioctl_callback2)(CURL *, int, const void *);
|
||||
typedef curlioerr (*_curl_ioctl_callback3)(CURL *, curliocmd, void *);
|
||||
typedef curlioerr (*_curl_ioctl_callback4)(CURL *, curliocmd, const void *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
|
||||
#define _curl_is_sockopt_cb(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
_curl_callback_compatible((expr), curl_sockopt_callback) || \
|
||||
_curl_callback_compatible((expr), _curl_sockopt_callback1) || \
|
||||
_curl_callback_compatible((expr), _curl_sockopt_callback2))
|
||||
typedef int (*_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
|
||||
typedef int (*_curl_sockopt_callback2)(const void *, curl_socket_t,
|
||||
curlsocktype);
|
||||
|
||||
/* evaluates to true if expr is of type curl_opensocket_callback or
|
||||
"similar" */
|
||||
#define _curl_is_opensocket_cb(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
_curl_callback_compatible((expr), curl_opensocket_callback) || \
|
||||
_curl_callback_compatible((expr), _curl_opensocket_callback1) || \
|
||||
_curl_callback_compatible((expr), _curl_opensocket_callback2) || \
|
||||
_curl_callback_compatible((expr), _curl_opensocket_callback3) || \
|
||||
_curl_callback_compatible((expr), _curl_opensocket_callback4))
|
||||
typedef curl_socket_t (*_curl_opensocket_callback1)
|
||||
(void *, curlsocktype, struct curl_sockaddr *);
|
||||
typedef curl_socket_t (*_curl_opensocket_callback2)
|
||||
(void *, curlsocktype, const struct curl_sockaddr *);
|
||||
typedef curl_socket_t (*_curl_opensocket_callback3)
|
||||
(const void *, curlsocktype, struct curl_sockaddr *);
|
||||
typedef curl_socket_t (*_curl_opensocket_callback4)
|
||||
(const void *, curlsocktype, const struct curl_sockaddr *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_progress_callback or "similar" */
|
||||
#define _curl_is_progress_cb(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
_curl_callback_compatible((expr), curl_progress_callback) || \
|
||||
_curl_callback_compatible((expr), _curl_progress_callback1) || \
|
||||
_curl_callback_compatible((expr), _curl_progress_callback2))
|
||||
typedef int (*_curl_progress_callback1)(void *,
|
||||
double, double, double, double);
|
||||
typedef int (*_curl_progress_callback2)(const void *,
|
||||
double, double, double, double);
|
||||
|
||||
/* evaluates to true if expr is of type curl_debug_callback or "similar" */
|
||||
#define _curl_is_debug_cb(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
_curl_callback_compatible((expr), curl_debug_callback) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback1) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback2) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback3) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback4) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback5) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback6) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback7) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback8))
|
||||
typedef int (*_curl_debug_callback1) (CURL *,
|
||||
curl_infotype, char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback2) (CURL *,
|
||||
curl_infotype, char *, size_t, const void *);
|
||||
typedef int (*_curl_debug_callback3) (CURL *,
|
||||
curl_infotype, const char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback4) (CURL *,
|
||||
curl_infotype, const char *, size_t, const void *);
|
||||
typedef int (*_curl_debug_callback5) (CURL *,
|
||||
curl_infotype, unsigned char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback6) (CURL *,
|
||||
curl_infotype, unsigned char *, size_t, const void *);
|
||||
typedef int (*_curl_debug_callback7) (CURL *,
|
||||
curl_infotype, const unsigned char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback8) (CURL *,
|
||||
curl_infotype, const unsigned char *, size_t, const void *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
|
||||
/* this is getting even messier... */
|
||||
#define _curl_is_ssl_ctx_cb(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
_curl_callback_compatible((expr), curl_ssl_ctx_callback) || \
|
||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback1) || \
|
||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback2) || \
|
||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback3) || \
|
||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback4) || \
|
||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback5) || \
|
||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback6) || \
|
||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback7) || \
|
||||
_curl_callback_compatible((expr), _curl_ssl_ctx_callback8))
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback1)(CURL *, void *, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback4)(CURL *, const void *,
|
||||
const void *);
|
||||
#ifdef HEADER_SSL_H
|
||||
/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
|
||||
* this will of course break if we're included before OpenSSL headers...
|
||||
*/
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX,
|
||||
const void *);
|
||||
#else
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8;
|
||||
#endif
|
||||
|
||||
/* evaluates to true if expr is of type curl_conv_callback or "similar" */
|
||||
#define _curl_is_conv_cb(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
_curl_callback_compatible((expr), curl_conv_callback) || \
|
||||
_curl_callback_compatible((expr), _curl_conv_callback1) || \
|
||||
_curl_callback_compatible((expr), _curl_conv_callback2) || \
|
||||
_curl_callback_compatible((expr), _curl_conv_callback3) || \
|
||||
_curl_callback_compatible((expr), _curl_conv_callback4))
|
||||
typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
|
||||
typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
|
||||
typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
|
||||
typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
|
||||
|
||||
/* evaluates to true if expr is of type curl_seek_callback or "similar" */
|
||||
#define _curl_is_seek_cb(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
_curl_callback_compatible((expr), curl_seek_callback) || \
|
||||
_curl_callback_compatible((expr), _curl_seek_callback1) || \
|
||||
_curl_callback_compatible((expr), _curl_seek_callback2))
|
||||
typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);
|
||||
typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
|
||||
|
||||
|
||||
#endif /* __CURL_TYPECHECK_GCC_H */
|
122
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/include/curl/urlapi.h
Executable file
122
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/include/curl/urlapi.h
Executable file
|
@ -0,0 +1,122 @@
|
|||
#ifndef __CURL_URLAPI_H
|
||||
#define __CURL_URLAPI_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2018 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "curl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* the error codes for the URL API */
|
||||
typedef enum {
|
||||
CURLUE_OK,
|
||||
CURLUE_BAD_HANDLE, /* 1 */
|
||||
CURLUE_BAD_PARTPOINTER, /* 2 */
|
||||
CURLUE_MALFORMED_INPUT, /* 3 */
|
||||
CURLUE_BAD_PORT_NUMBER, /* 4 */
|
||||
CURLUE_UNSUPPORTED_SCHEME, /* 5 */
|
||||
CURLUE_URLDECODE, /* 6 */
|
||||
CURLUE_OUT_OF_MEMORY, /* 7 */
|
||||
CURLUE_USER_NOT_ALLOWED, /* 8 */
|
||||
CURLUE_UNKNOWN_PART, /* 9 */
|
||||
CURLUE_NO_SCHEME, /* 10 */
|
||||
CURLUE_NO_USER, /* 11 */
|
||||
CURLUE_NO_PASSWORD, /* 12 */
|
||||
CURLUE_NO_OPTIONS, /* 13 */
|
||||
CURLUE_NO_HOST, /* 14 */
|
||||
CURLUE_NO_PORT, /* 15 */
|
||||
CURLUE_NO_QUERY, /* 16 */
|
||||
CURLUE_NO_FRAGMENT /* 17 */
|
||||
} CURLUcode;
|
||||
|
||||
typedef enum {
|
||||
CURLUPART_URL,
|
||||
CURLUPART_SCHEME,
|
||||
CURLUPART_USER,
|
||||
CURLUPART_PASSWORD,
|
||||
CURLUPART_OPTIONS,
|
||||
CURLUPART_HOST,
|
||||
CURLUPART_PORT,
|
||||
CURLUPART_PATH,
|
||||
CURLUPART_QUERY,
|
||||
CURLUPART_FRAGMENT
|
||||
} CURLUPart;
|
||||
|
||||
#define CURLU_DEFAULT_PORT (1<<0) /* return default port number */
|
||||
#define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,
|
||||
if the port number matches the
|
||||
default for the scheme */
|
||||
#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if
|
||||
missing */
|
||||
#define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */
|
||||
#define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */
|
||||
#define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */
|
||||
#define CURLU_URLDECODE (1<<6) /* URL decode on get */
|
||||
#define CURLU_URLENCODE (1<<7) /* URL encode on set */
|
||||
#define CURLU_APPENDQUERY (1<<8) /* append a form style part */
|
||||
#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
|
||||
|
||||
typedef struct Curl_URL CURLU;
|
||||
|
||||
/*
|
||||
* curl_url() creates a new CURLU handle and returns a pointer to it.
|
||||
* Must be freed with curl_url_cleanup().
|
||||
*/
|
||||
CURL_EXTERN CURLU *curl_url(void);
|
||||
|
||||
/*
|
||||
* curl_url_cleanup() frees the CURLU handle and related resources used for
|
||||
* the URL parsing. It will not free strings previously returned with the URL
|
||||
* API.
|
||||
*/
|
||||
CURL_EXTERN void curl_url_cleanup(CURLU *handle);
|
||||
|
||||
/*
|
||||
* curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
|
||||
* handle must also be freed with curl_url_cleanup().
|
||||
*/
|
||||
CURL_EXTERN CURLU *curl_url_dup(CURLU *in);
|
||||
|
||||
/*
|
||||
* curl_url_get() extracts a specific part of the URL from a CURLU
|
||||
* handle. Returns error code. The returned pointer MUST be freed with
|
||||
* curl_free() afterwards.
|
||||
*/
|
||||
CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what,
|
||||
char **part, unsigned int flags);
|
||||
|
||||
/*
|
||||
* curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
|
||||
* error code. The passed in string will be copied. Passing a NULL instead of
|
||||
* a part string, clears that part.
|
||||
*/
|
||||
CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
|
||||
const char *part, unsigned int flags);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,758 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LPA_SDK__CORE_API_H
|
||||
#define LPA_SDK__CORE_API_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "lpasdk/api/semedia/semedia.h"
|
||||
|
||||
/////////////////////////////////
|
||||
// API versionning
|
||||
/////////////////////////////////
|
||||
|
||||
#define LPA_API_MAJOR_VERSION 1
|
||||
#define LPA_API_MINOR_VERSION 9
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int major; // Update it when API compatibility is not "supported"
|
||||
int minor; // Update it when function added without impact on API compatibility
|
||||
}LPA_API_VERSION;
|
||||
|
||||
/////////////////////////////////
|
||||
// LPA Type
|
||||
/////////////////////////////////
|
||||
|
||||
typedef int16_t LPA_Integer;
|
||||
typedef char* LPA_StringPtr;
|
||||
|
||||
/////////////////////////////////
|
||||
// API definition
|
||||
/////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#define LPA_CFG_DEVICE_INFO_TLV_MAX_SIZE 385 // 384 + CR
|
||||
#define LPA_CFG_DEVICE_INFO_TLV_BYTE_ARRAY_MAX_SIZE ((LPA_CFG_DEVICE_INFO_TLV_MAX_SIZE >> 1) + 1)
|
||||
|
||||
#define LPA_CFG_CERT_PATH_MAX_SIZE LPA_MAX_PATH
|
||||
|
||||
#define LPA_CFG_LINE_ENTRY_MAX_SIZE 1024
|
||||
|
||||
/*
|
||||
Maximum profile info size retrieved from eUICC (Max length used):
|
||||
Tag/size bytes + max data lengths
|
||||
Header tag E3 5 bytes
|
||||
iccid tag 5A 2 + 10 = 12 bytes
|
||||
profileState tag 9F70 3 + 1 = 4 bytes
|
||||
profileNickName tag 90 2 + 64 = 66 bytes
|
||||
serviceProviderName tag 91 2 + 32 = 34 bytes
|
||||
profileName tag 92 2 + 64 = 66 bytes
|
||||
iconType tag 93 2 + 1 = 3 bytes
|
||||
icon tag 94 4 + 1024 = 1028 bytes
|
||||
profileClass tag 95 2 + 1 = 3 bytes
|
||||
profilePolicyRules tag 99 2 + 2 = 4 bytes
|
||||
|
||||
TOTAL -------------------------------------- 1225 bytes - Set at 1300 for rounding / security
|
||||
Note: Other tags (4F, B6, B7 & B8) not requested in current request, so not taken in account
|
||||
*/
|
||||
#define LPA_PROFILE_INFO_BUFFER_MAX_SIZE 1300 // Size of profile raw data
|
||||
#define LPA_MAX_EVENT_RECORD 16
|
||||
|
||||
// All profile fields limits match maximum defined in SGP.22
|
||||
// LPA_PROFILE_STATE_MAX_SIZE, LPA_PROFILE_CLASS_MAX_SIZE, LPA_PROFILE_ICON_TYPE_MAX_SIZE defined as ASN1 'INTEGER'
|
||||
#define LPA_ASN1_INTEGER_MAX_SIZE 2
|
||||
#define LPA_PROFILE_ICCID_BUFFER_MAX_SIZE 10
|
||||
#define LPA_PROFILE_STATE_MAX_SIZE LPA_ASN1_INTEGER_MAX_SIZE
|
||||
#define LPA_PROFILE_SERVICE_PROVIDER_NAME_MAX_SIZE 32
|
||||
#define LPA_PROFILE_NAME_MAX_SIZE 64
|
||||
#define LPA_PROFILE_CLASS_MAX_SIZE LPA_ASN1_INTEGER_MAX_SIZE
|
||||
#define LPA_PROFILE_ICON_MAX_SIZE 1024
|
||||
#define LPA_PROFILE_ICON_TYPE_MAX_SIZE LPA_ASN1_INTEGER_MAX_SIZE
|
||||
#define LPA_PROFILE_NICKNAME_MAX_SIZE 64
|
||||
#define LPA_PROFILE_POLICY_RULES_MAX_SIZE 2
|
||||
|
||||
#define LPA_GET_EID_BUFFER_SIZE 20 // Previously 64, 16 is the typical size, set 20 to keep a security
|
||||
#define LPA_GET_EUICC_BUFFER_MAX_SIZE 900 //255 then 384 previously
|
||||
|
||||
/* Size calculation to evaluate EUICCInfo2. Some fields of list size have no limit defined, so decisions have been taken here:
|
||||
Note: TL = Tag Length
|
||||
Size ASN1 object + Explanation
|
||||
5 EUICCInfo2 Main Tag BF22, length coded on 3 bytes considering total data size => 5 bytes
|
||||
5 profileVersion [1] "VersionType" object, 3 bytes value, 5 with TL
|
||||
5 svn [2] "VersionType" object, 3 bytes value, 5 with TL
|
||||
5 euiccFirmwareVer [3] "VersionType" object, 3 bytes value, 5 with TL
|
||||
16 extCardResource [4] "Extended Card Resource Information according to ETSI TS 102 226" (Chapter 8.2.1.7.2) - 3 concatenated TLV, first refer "application number", typical 1 byte, 2 others are free memory status, typically coded on 4 bytes. Total typical size = 16
|
||||
6 uiccCapability [5] BITSTRING object, max 6 bytes with TL
|
||||
5 ts102241Version [6] "VersionType" object, 3 bytes value, 5 with TL
|
||||
5 globalplatformVersion [7] "VersionType" object, 3 bytes value, 5 with TL
|
||||
4 rspCapability [8] BITSTRING object, 4 bytes with TL
|
||||
3 euiccCiPKIdListForVerification [9] List of "SubjectKeyIdentifier", fixed to up to 6 elements (Typical use in Asia 5 elements): TL + Size coded on 2 bytes (132 bytes data) => 3 bytes
|
||||
132 6x > SubjectKeyIdentifier "CI Public Key Identifier" => 20 bytes + 2 bytes TL => 22 bytes
|
||||
3 euiccCiPKIdListForSigning [10] List of "SubjectKeyIdentifier", fixed to up to 6 elements (Typical use in Asia 5 elements): TL + Size coded on 2 bytes (132 bytes data) => 3 bytes
|
||||
132 6x > SubjectKeyIdentifier "CI Public Key Identifier" => 20 bytes + 2 bytes TL => 22 bytes
|
||||
3 euiccCategory [11] Integer, typically 1 byte value, 3 with TL
|
||||
4 forbiddenProfilePolicyRules [25] BITSTRING object, 4 bytes with TL
|
||||
5 ppVersion "VersionType" object, 3 bytes value, 5 with TL
|
||||
66 sasAcreditationNumber String, limited to 64 characters max, 66 with TL
|
||||
4 certificationDataObject [12] List of 2 strings, length coded on 3 bytes considering data size => 4 bytes
|
||||
102 > platformLabel Coded on form "<OID platform manufacturer>/<Unique Identifier of the platform>", example "1.2.840.114283/My_Platform_Label_1a" - Considering real label size, set at 100 characters max + 2 bytes TL => 102 bytes
|
||||
258 > discoveryBaseURL Based on the fact that some URL like Activation Code SM-DP address are limited to 255 characters, we will use the same limit => 258 bytes with TL
|
||||
4 treProperties [13] BITSTRING object, 4 bytes with TL
|
||||
52 treProductReference [14] String, "unique reference of the Integrated TRE product that the eUICC is based upon" - Set at 50 characters considering references actually used => 52 bytes with TL
|
||||
2 additionalEuiccProfilePackageVersions [15] List of "VersionType" fixed to up to 12 elements: TL + Size coded on 1 byte (60 bytes data) => 2 bytes - "List higher major versions including associated highest minor version number of additional eUICC Profile Package specification(s) supported by eUICC
|
||||
60 12x > VersionType "VersionType" object, 3 bytes value, 5 with TL
|
||||
TOTAL 886 bytes
|
||||
|
||||
*/
|
||||
|
||||
#define LPA_CANCEL_SESSION_RESPONSE_BUFFER_SIZE 160
|
||||
|
||||
// For memory: Full Activation Code is 1$lpa_SM-Dx_address$matchingId$oid_object$ccRequiredFlag
|
||||
#define LPA_ACTIVATION_CODE_MAX_SIZE (2 + LPA_SMDP_ADDRESS_SIZE + 1 + LPA_MATCHING_ID_SIZE + 1 + LPA_OID_SIZE + 1 + LPA_CC_REQUIRED_FLAG_SIZE)
|
||||
#define LPA_ACTIVATION_CODE_MAX_STRING_BUFFER_SIZE ( LPA_ACTIVATION_CODE_MAX_SIZE + 1 ) // Adding 1 bytes to End of String
|
||||
|
||||
#define LPA_SMDP_ADDRESS_SIZE 128 // Max 127 characters with End Of String
|
||||
#define LPA_SMDS_ADDRESS_SIZE LPA_SMDP_ADDRESS_SIZE
|
||||
#define LPA_ADDRESS_MAX_SIZE 255
|
||||
#define LPA_MATCHING_ID_SIZE 255
|
||||
#define LPA_OID_SIZE 128
|
||||
#define LPA_CC_REQUIRED_FLAG_SIZE 2 // Include end of string
|
||||
|
||||
#define LPA_MAX_PROFILE_NOTIFICATION_LIST_ELEMENT 16
|
||||
#define LPA_MAX_NOTIFICATION_ADDRESS_RAW_DATA_SIZE 128
|
||||
|
||||
// Managing Confirmation Code during downloadProfile
|
||||
#define LPA_CONFIRMATION_CODE_MAX_SIZE 50
|
||||
|
||||
// Maximum number of parameters for parameter list generation
|
||||
// ! CAUTION: Have to take care that list is long enough to store all parameters and element size long enough to fit longest parameters names
|
||||
#define LPA_MAX_PARAMETERS_LIST 25
|
||||
#define LPA_MAX_PARAMETERS_LIST_ELEMENT_SIZE 40
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int major;
|
||||
int minor;
|
||||
int patch;
|
||||
int build;
|
||||
}LPA_VERSION;
|
||||
|
||||
|
||||
// Support of Notification Error during a download profile
|
||||
// Application owner should manage LPA_EVENT_REQUEST_CONFIRMATION_CODE callback
|
||||
typedef enum
|
||||
{
|
||||
LPA_EVENT_EXECUTION_SERVER_ERROR_TYPE = 1, // Error send by server
|
||||
LPA_EVENT_EXECUTION_HTTP_ERROR_TYPE = 2, // HTTP error during communication with server
|
||||
LPA_EVENT_EXECUTION_CURL_ERROR_TYPE = 3, // Curl error
|
||||
LPA_EVENT_EXECUTION_SEMEDIA_DRIVER_ERROR_TYPE = 4 // SEMEDIA_DRIVER error
|
||||
}LPA_EVENT_EXECUTION_ERROR_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LPA_EVENT_EXECUTION_ERROR_NO_DETAIL_MASK = 0x0000, // 0b00000000
|
||||
|
||||
LPA_EVENT_EXECUTION_ERROR_SUBJECT_CODE_MASK = 0x0001, // 0b00000001
|
||||
LPA_EVENT_EXECUTION_ERROR_REASON_CODE_MASK = 0x0002, // 0b00000010
|
||||
LPA_EVENT_EXECUTION_ERROR_EXTRA_INFO_MASK = 0x0004, // 0b00000100
|
||||
}LPA_EVENT_EXECUTION_ERROR_DETAIL_MASK;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LPA_EVENT_EXECUTION_ERROR_TYPE executionErrorType;
|
||||
LPA_EVENT_EXECUTION_ERROR_DETAIL_MASK detailErrorMask;
|
||||
const char* ptrErrorSubjectCode;
|
||||
const char* ptrErrorReasonCode;
|
||||
const char* ptrErrorExtraInfo;
|
||||
} LPA_EVENT_EXECUTION_ERROR_INFO;
|
||||
|
||||
|
||||
// Support of Confirmation Code requested by LPA SDK
|
||||
// Application owner should manage LPA_EVENT_EXECUTION_ERROR callback
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Confirmation code value updated by application
|
||||
char confirmationCode[LPA_CONFIRMATION_CODE_MAX_SIZE];
|
||||
|
||||
// Size of CC buffer (with final '\0')
|
||||
size_t confirmationCodeMaxBufferSize;
|
||||
|
||||
// Updated by LPA Application
|
||||
unsigned int reasonCodeNoCC; // used if no Confirmation Code
|
||||
} LPA_REQUEST_CONFIRMATION_CODE;
|
||||
|
||||
// @Since LPASDK API 1.6
|
||||
typedef struct
|
||||
{
|
||||
unsigned char userCallBackType; // Set information(s) to display. Values masks defined in LPA_USER_CONSENT_TYPES enum. Each bit set an info to display.
|
||||
char profileName[LPA_PROFILE_NAME_MAX_SIZE + 2]; // Profile name that may be displayed. String coded. +1 byte for EOS, +1 byte for security
|
||||
bool downloadAllowed; // Confirm user accepted download (True) or refused (False)
|
||||
unsigned int cancelSessionReason; // Values defined in LPA_CANCEL_SESSION_REASON enum. Value has no importance if downloadAllowed returned "true"
|
||||
}LPA_REQUEST_USER_CONSENT_FOR_LOADING_PROFILE;
|
||||
|
||||
// Since LPASDK API 1.8
|
||||
typedef struct
|
||||
{
|
||||
bool profileMetadataAvailable; // Set to true if SM-DP server returned profile Metadata, else false
|
||||
unsigned char iccid[LPA_PROFILE_ICCID_BUFFER_MAX_SIZE]; // ICCID. Raw bytes
|
||||
size_t iccidSize; // ICCID size. Given as confirmation but shall be always equal to 0x0A
|
||||
char profileName[LPA_PROFILE_NAME_MAX_SIZE + 2]; // Profile name. String coded. +1 byte for EOS, +1 byte for security
|
||||
char serviceProviderName[LPA_PROFILE_SERVICE_PROVIDER_NAME_MAX_SIZE + 2]; // Service provider name. String coded. +1 byte for EOS, +1 byte for security
|
||||
unsigned char profileIcon[LPA_PROFILE_ICON_MAX_SIZE]; // Icon. Raw bytes
|
||||
size_t profileIconSize; // Icon size. If equal 0 the 2 other icon fields have no meaning
|
||||
unsigned char profileIconType; // Icon type value
|
||||
unsigned int profilePPR; // PPR value (ASN1 bitstring value). If equal 0 the PPR is not defined (Or empty or set to 0 but this shall not happen)
|
||||
}LPA_EVENT_INCOMING_PROFILE_INFORMATION;
|
||||
|
||||
// LPA Event mechanism
|
||||
// eventType is dependant of LPA SDK API used. Mainly give equivalent of progression order
|
||||
// Zero, some or all LPA Event functions can be registered
|
||||
|
||||
// Function <lpaEventProgessValue> is used to manage a Progress Value
|
||||
typedef void (*LPA_EVENT_PROGRESS_VALUE) (const void* ptrAppParameter, size_t eventType, size_t valueMin, size_t currentValue, size_t valueMax);
|
||||
|
||||
// Function <lpaEventProgressText> is used to communicate a text message to the application
|
||||
typedef void(*LPA_EVENT_PROGRESS_TEXT) (const void* ptrAppParameter, size_t eventType, const char* ptrText);
|
||||
|
||||
// Function <lpaEventRequestConfirmationCode> is used to communicate a text message to the application
|
||||
// Return true if CC entered correctly, otherwise return false and update reasonCodeNoCC field
|
||||
typedef bool(*LPA_EVENT_REQUEST_CONFIRMATION_CODE) (const void* ptrAppParameter, LPA_REQUEST_CONFIRMATION_CODE* ptrRequestConfirmationCode);
|
||||
|
||||
// Function <lpaEventExecutionError> is used to communicate some execution error information (subjectCode, reasonCode...) to the application
|
||||
typedef void(*LPA_EVENT_EXECUTION_ERROR) (const void* ptrAppParameter, const LPA_EVENT_EXECUTION_ERROR_INFO* ptrEventExecutionErrorInfo);
|
||||
|
||||
// Function <lpaEventRequestUserConsentForLoadingProfile> is used to request a User Consent before loading a profile by Activation Code
|
||||
// Since LPASDK API 1.6
|
||||
// Since LPASDK API 1.9, systematically called on each download
|
||||
typedef bool(*LPA_EVENT_REQUEST_USER_CONSENT_FOR_LOADING_PROFILE) (const void* ptrAppParameter, LPA_REQUEST_USER_CONSENT_FOR_LOADING_PROFILE* ptrRequestUserConsentForLoadingProfile);
|
||||
|
||||
// Function <lpaEventDisplayIncomingProfileInformation> is used to display informations about profile currently downloaded
|
||||
// Since LPASDK API 1.8
|
||||
typedef void(*LPA_EVENT_DISPLAY_INCOMING_PROFILE_INFORMATION) (const void* ptrAppParameter, size_t eventType, LPA_EVENT_INCOMING_PROFILE_INFORMATION* ptrIncomingProfileInformation);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// LPA SDK event parameter
|
||||
void* _appParameter; // NULL if not used, otherwise specific application parameter (using it at first parameter value of event function
|
||||
// In C++ application, could be instance of a class
|
||||
|
||||
// LPA SDK Event callback functions - Must be initialized to NULL if not used.
|
||||
LPA_EVENT_PROGRESS_VALUE _lpaEventProgressValue;
|
||||
LPA_EVENT_PROGRESS_TEXT _lpaEventProgressText;
|
||||
LPA_EVENT_EXECUTION_ERROR _lpaEventExecutionError;
|
||||
|
||||
// When LPA SDK request a Confirmation Code during a DownloadProfile
|
||||
LPA_EVENT_REQUEST_CONFIRMATION_CODE _lpaEventRequestConfirmationCode;
|
||||
|
||||
// Event for managing User Consent before loading profile
|
||||
LPA_EVENT_REQUEST_USER_CONSENT_FOR_LOADING_PROFILE _lpaEventRequestUserConsentForLoadingProfile;
|
||||
|
||||
// Displaying of incoming profile information during download
|
||||
LPA_EVENT_DISPLAY_INCOMING_PROFILE_INFORMATION _lpaEventDisplayIncomingProfileInformation;
|
||||
}LPA_EventCallback;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Profile Info Record
|
||||
unsigned char rawData[LPA_PROFILE_INFO_BUFFER_MAX_SIZE];
|
||||
size_t rawDataSize;
|
||||
|
||||
unsigned char iccid[LPA_PROFILE_ICCID_BUFFER_MAX_SIZE];
|
||||
size_t iccidSize;
|
||||
|
||||
unsigned char profileState[LPA_PROFILE_STATE_MAX_SIZE];
|
||||
size_t profileStateSize;
|
||||
|
||||
unsigned char serviceProviderName[LPA_PROFILE_SERVICE_PROVIDER_NAME_MAX_SIZE];
|
||||
size_t serviceProviderNameSize;
|
||||
|
||||
unsigned char profileName[LPA_PROFILE_NAME_MAX_SIZE];
|
||||
size_t profileNameSize;
|
||||
|
||||
unsigned char profileClass[LPA_PROFILE_CLASS_MAX_SIZE];
|
||||
size_t profileClassSize;
|
||||
|
||||
unsigned char profileNickname[LPA_PROFILE_NICKNAME_MAX_SIZE];
|
||||
size_t profileNicknameSize;
|
||||
|
||||
unsigned char profileIcon[LPA_PROFILE_ICON_MAX_SIZE];
|
||||
size_t profileIconSize;
|
||||
|
||||
unsigned char profileIconType[LPA_PROFILE_ICON_TYPE_MAX_SIZE];
|
||||
size_t profileIconTypeSize;
|
||||
|
||||
unsigned char profilePolicyRules[LPA_PROFILE_POLICY_RULES_MAX_SIZE];
|
||||
size_t profilePolicyRulesSize;
|
||||
}LPA_PROFILE_INFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Get Profile Info All
|
||||
size_t countProfileInfo; // Number of profiles effectively retrieved and available in profileInfoList
|
||||
size_t numberProfileInfoFound; // Number of profiles found in eUICC. Can be higher than value returned in "countProfileInfo"
|
||||
size_t maxNumberProfileInfo; // Maximum number of profiles that can be stored in profileInfoList
|
||||
unsigned char * profileInfoList; // Data area storing profiles information list. Must be allocated with (maxNumberProfileInfo * sizeof(LPA_PROFILE_INFO)) size.
|
||||
}LPA_GET_PROFILES_INFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// EID
|
||||
unsigned char EID_Data[LPA_GET_EID_BUFFER_SIZE];
|
||||
size_t EID_DataSize;
|
||||
}LPA_GET_EID;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// EUICC Info
|
||||
unsigned char EUICC_Info_Data[LPA_GET_EUICC_BUFFER_MAX_SIZE];
|
||||
size_t EUICC_Info_DataSize;
|
||||
}LPA_GET_EUICC_INFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t countProfileInstalled;
|
||||
size_t countProfileTotal;
|
||||
} LPA_DOWNLOAD_PROFILE_RESULT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t countNotificationDetected; // Before sending
|
||||
size_t countNotificationSend; // really send
|
||||
} LPA_SENDING_NOTIFICATION_RESULT;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LPA_NOTIFICATION_INSTALL = 0,
|
||||
LPA_NOTIFICATION_ENABLE = 1,
|
||||
LPA_NOTIFICATION_DISABLE = 2,
|
||||
LPA_NOTIFICATION_DELETE = 3,
|
||||
LPA_NOTIFICATION_UNKNOWN = 0xFF
|
||||
} LPA_NOTIFICATION_EVENT;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
bool resultOK;
|
||||
unsigned char cancelSessionResponse_RawData[LPA_CANCEL_SESSION_RESPONSE_BUFFER_SIZE];
|
||||
size_t cancelSessionResponse_RawDataSize;
|
||||
}CANCEL_SESSION_RESPONSE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// SMDP Address
|
||||
char smdxAddr[LPA_SMDP_ADDRESS_SIZE];
|
||||
// activation code
|
||||
char matchingId[LPA_MATCHING_ID_SIZE];
|
||||
// OID
|
||||
char oid[LPA_OID_SIZE];
|
||||
// Confirmation Code Required Flag
|
||||
char ccRequiredFlag[LPA_CC_REQUIRED_FLAG_SIZE];
|
||||
} ACTIVATION_CODE;
|
||||
|
||||
typedef struct {
|
||||
char eventId[LPA_MATCHING_ID_SIZE];
|
||||
char rspServerAddress[LPA_SMDP_ADDRESS_SIZE];
|
||||
unsigned char EID_RawData[LPA_GET_EID_BUFFER_SIZE];
|
||||
bool forwardingIndicator;
|
||||
}LPA_EVENT_RECORD;
|
||||
|
||||
typedef struct {
|
||||
size_t countEvent;
|
||||
LPA_EVENT_RECORD eventRecordList[LPA_MAX_EVENT_RECORD];
|
||||
}EVENT_RECORD_LIST;
|
||||
|
||||
typedef struct {
|
||||
char address_Data[LPA_SMDP_ADDRESS_SIZE];
|
||||
size_t address_DataSize;
|
||||
}ADDRESS_DATA;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LPA_DELETE_NOTIFICATION_OK = 0,
|
||||
LPA_DELETE_NOTIFICATION_NOTHING_TO_DELETE = 1,
|
||||
LPA_DELETE_NOTIFICATION_UNDEFINED_ERROR = 127,
|
||||
LPA_DELETE_NOTIFICATION_UNKNOWN = 0xFF
|
||||
}LPA_DELETE_NOTIFICATION_STATUS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t seqNumber;
|
||||
LPA_NOTIFICATION_EVENT profileManagementOperation;
|
||||
unsigned char notificationAddressRawData[LPA_MAX_NOTIFICATION_ADDRESS_RAW_DATA_SIZE];
|
||||
size_t notificationAddressRawDataSize;
|
||||
}LPA_PROFILE_NOTIFICATION_METADATA;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t countNotification;
|
||||
LPA_PROFILE_NOTIFICATION_METADATA notificationMetadataList[LPA_MAX_PROFILE_NOTIFICATION_LIST_ELEMENT];
|
||||
} LPA_PROFILE_NOTIFICATION_LIST;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LPA_MEMORY_RESET_OK = 0,
|
||||
LPA_MEMORY_RESET_NOTHING_TO_DELETE = 1,
|
||||
LPA_MEMORY_RESET_CAT_BUSY = 5,
|
||||
LPA_MEMORY_RESET_UNDEFINED_ERROR = 127,
|
||||
LPA_MEMORY_RESET_UNKNOWN = 0xFF
|
||||
}LPA_MEMORY_RESET_STATUS;
|
||||
|
||||
// Cancel Session codes
|
||||
typedef enum
|
||||
{
|
||||
LPA_CANCEL_SESSION_END_USER_REJECTION = 0,
|
||||
LPA_CANCEL_SESSION_POSTPONED = 1,
|
||||
LPA_CANCEL_SESSION_TIME_OUT = 2,
|
||||
LPA_CANCEL_SESSION_PPR_NOT_ALLOWED = 3,
|
||||
LPA_CANCEL_SESSION_METADATA_MISMATCH = 4,
|
||||
LPA_CANCEL_SESSION_LOAD_BPP_EXECUTION_ERROR = 5,
|
||||
LPA_CANCEL_SESSION_UNDEFINED_REASON = 127
|
||||
}LPA_CANCEL_SESSION_REASON;
|
||||
|
||||
static const unsigned int LPA_ALLOWED_CANCEL_SESSION_CODE_LIST[] = {0, 1, 2, 3, 4, 5, 127};
|
||||
#define LPA_ALLOWED_CANCEL_SESSION_CODE_LIST_SIZE 7
|
||||
|
||||
// User consent type for Callback. These are binary mask, they can be mixed together or checked individually.
|
||||
typedef enum
|
||||
{
|
||||
LPA_USR_CONSENT_NO_PPR = 0x00,
|
||||
LPA_USR_CONSENT_PPR1 = 0x01,
|
||||
LPA_USR_CONSENT_PPR2 = 0x02,
|
||||
LPA_USR_CONSENT_PROFILE_WITH_PPR1_ENABLED_PRESENT = 0x04
|
||||
}LPA_USER_CONSENT_TYPES;
|
||||
|
||||
// Management of retry for chained GetResponse issue with modems (0x6D00 issue, other SW may be discovered) through LPA_SDK__NUMBER_OF_RETRY_FOR_CHAINED_GET_RESPONSE
|
||||
// If not defined or minus than 1 retry mechanism will be disabled
|
||||
#ifndef LPA_SDK__NUMBER_OF_RETRY_FOR_CHAINED_GET_RESPONSE
|
||||
#define LPA_RETRY_CHAINED_GET_RESPONSE_MGT false // Do not modify this value!
|
||||
#define LPA_LOOP_NUMBER_FOR_CHAINED_GET_RESPONSE 1 // Do not modify this value ! Must be AT LEAST value "1" else commands will be NOT played.
|
||||
#elif LPA_SDK__NUMBER_OF_RETRY_FOR_CHAINED_GET_RESPONSE < 1
|
||||
#define LPA_RETRY_CHAINED_GET_RESPONSE_MGT false // Do not modify this value!
|
||||
#define LPA_LOOP_NUMBER_FOR_CHAINED_GET_RESPONSE 1 // Do not modify this value! Must be AT LEAST value "1" else commands will be NOT played.
|
||||
#else
|
||||
#define LPA_RETRY_CHAINED_GET_RESPONSE_MGT true // Do not modify this value!
|
||||
#define LPA_LOOP_NUMBER_FOR_CHAINED_GET_RESPONSE LPA_SDK__NUMBER_OF_RETRY_FOR_CHAINED_GET_RESPONSE + 1 // Do not modify this expression ! Must be +1 to include initial command run to retries.
|
||||
#endif // defined LPA_SDK__NUMBER_OF_RETRY_FOR_CHAINED_GET_RESPONSE
|
||||
|
||||
|
||||
// Management of maximum size of data send through APDU. Need to limit size due to some modems not supporting 261 bytes (So 522 characters) in case 4 APDU
|
||||
// If not defined default value of 0xFF will be used.
|
||||
// If out of bounds will issue an error and stop compilation. If #error ignored by compiler used, value will be set to 0xFF to show that something is wrong.
|
||||
// Boundaries for usable limits shall not be changed.
|
||||
// Minimum size is fixed to 0x52 (82) due to eUICC limitations that does not support chained Store Data for some commands. 1 byte has been reserved for security.
|
||||
// - Set Nickname: 0x51 (81) bytes minimum needed
|
||||
// - Enable / Disable / Delete profile: 0x14 (20) bytes minimum needed
|
||||
// - Any download command, Set default DP, Send Notification: Tested OK with 10 bytes size limitation
|
||||
#ifndef LPA_SDK__MAX_SIZE_OF_DATA_IN_STORE_DATA_APDU
|
||||
#define LPA_STORE_DATA_APDU_DATA_SIZE_MAX 0xFF
|
||||
#elif LPA_SDK__MAX_SIZE_OF_DATA_IN_STORE_DATA_APDU < 0x52 // Lower limit given by Set Nickname
|
||||
#define LPA_STORE_DATA_APDU_DATA_SIZE_MAX 0xFF
|
||||
#error LPA_SDK__MAX_SIZE_OF_DATA_IN_STORE_DATA_APDU is out of authorized range ( decimal: [82,255 ] , hexa: [0x52,0xFF] ).
|
||||
#elif LPA_SDK__MAX_SIZE_OF_DATA_IN_STORE_DATA_APDU > 0xFF // Upper limit, max possible in an APDU
|
||||
#define LPA_STORE_DATA_APDU_DATA_SIZE_MAX 0xFF
|
||||
#error LPA_SDK__MAX_SIZE_OF_DATA_IN_STORE_DATA_APDU is out of authorized range ( decimal: [82,255 ] , hexa: [0x52,0xFF] ).
|
||||
#else
|
||||
#define LPA_STORE_DATA_APDU_DATA_SIZE_MAX LPA_SDK__MAX_SIZE_OF_DATA_IN_STORE_DATA_APDU
|
||||
#endif
|
||||
|
||||
// List of tags allowed in deviceCapabilities object when extensibility is not supported
|
||||
static const unsigned char LPA_LIST_ALLOWED_DEVICE_TAGS_NO_EXTENSIBILITY_SUPPORT[] = {0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87};
|
||||
#define LPA_LIST_ALLOWED_DEVICE_TAGS_NO_EXTENSIBILITY_SUPPORT_SIZE 8
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// API ERROR
|
||||
/////////////////////////////////
|
||||
|
||||
typedef enum {
|
||||
LPA_NO_ERROR = 0,
|
||||
|
||||
// 0x0001 - 0x0999 => Sifar custom error
|
||||
SF_LPA_CUSTOM_ERROR_CMD_UNKNOWN = 0x0001, //Unknow command
|
||||
SF_LPA_CUSTOM_ERROR_MEMORY, //Memory error
|
||||
SF_LPA_CUSTOM_ERROR_USBNET, //Network error
|
||||
SF_LPA_CUSTOM_ERROR_LPA_ERROR, //LPA initialization failed
|
||||
SF_LPA_CUSTOM_ERROR_SIM_NOT_SUPPORTED, //SIM not supported
|
||||
SF_LPA_CUSTOM_ERROR_SIM_EID, //SIM EID error
|
||||
SF_LPA_CUSTOM_ERROR_HASH, //LPA command hash error
|
||||
SF_LPA_CUSTOM_ERROR_ACTIVATION_CODE, //LPA sms command activation code error
|
||||
SF_LPA_CUSTOM_ERROR_INVALID_ICCID, //LPA sms command invalid ICCID
|
||||
SF_LPA_CUSTOM_ERROR_PROFILE_ENABLED, //The profile has been enabled
|
||||
SF_LPA_CUSTOM_ERROR_NETWORK_REJECTED, //Network rejected
|
||||
|
||||
|
||||
// 0x1001 - 0x1999 => Configuration error
|
||||
LPA_NOT_INITIALIZED = 0x1001,
|
||||
|
||||
// 0x2001 - 0x2FFF => Common error
|
||||
LPA_ERROR_INVALID_PARAMETER = 0x2001,
|
||||
LPA_ERROR_INSUFFICIENT_BUFFER,
|
||||
LPA_ERROR_INVALID_SW,
|
||||
LPA_ERROR_ISDR_NOT_SELECTED,
|
||||
LPA_ERROR_ISDR_ALREADY_SELECTED,
|
||||
LPA_ERROR_SE_MEDIA_NOT_INITIALIZED,
|
||||
LPA_ERROR_SE_MEDIA_CONTEXT_NOT_ESTABLISHED,
|
||||
LPA_ERROR_SE_MEDIA_READER_CONNECTION,
|
||||
LPA_ERROR_SE_MEDIA_CONTEXT_NOT_RELEASED,
|
||||
LPA_ERROR_SE_MEDIA_READER_NOT_DISCONNECTED,
|
||||
LPA_ERROR_SE_MEDIA_UNABLE_TO_SELECT_ISDR,
|
||||
LPA_ERROR_INVALID_GET_PROFILES_INFO_EXCHANGE,
|
||||
LPA_ERROR_INVALID_GET_EID_EXCHANGE,
|
||||
LPA_ERROR_INVALID_GET_EUICC_ADDRESS,
|
||||
LPA_ERROR_INVALID_MEMORY_RESET_EXCHANGE,
|
||||
LPA_ERROR_INVALID_SET_DEFAULT_SMDP_ADDRESS,
|
||||
LPA_ERROR_INVALID_GET_SMDP_ADDRESS,
|
||||
LPA_ERROR_INVALID_GET_SMDS_ADDRESS,
|
||||
LPA_ERROR_PARAMETER_NOT_AUTHORIZED,
|
||||
LPA_ERROR_UNKNOWN_PARAMETER,
|
||||
LPA_ERROR_INVALID_PARAMETER_TYPE,
|
||||
LPA_ERROR_INCORRECT_PARAMETER_TYPE,
|
||||
LPA_ERROR_PARAMETER_INTERNAL_ERROR,
|
||||
LPA_ERROR_UNABLE_TO_INIT_LOG,
|
||||
LPA_ERROR_MISSING_CONFIG_FILE, // 23/12/2019 No longer used
|
||||
LPA_ERROR_UNABLE_TO_LOAD_CONFIG_FILE, // 23/12/2019 No longer used
|
||||
LPA_ERROR_CONFIG_FILE_MISSING_MANDATORY_KEY, // 06/06/2019 No longer used
|
||||
LPA_ERROR_CONFIG_FILE_INCORRECT_KEY_VALUE,
|
||||
LPA_ERROR_UNABLE_TO_INITIALIZE_LPA_MANAGER,
|
||||
LPA_ERROR_UNABLE_TO_INITIALIZE_HTTP_MEDIA,
|
||||
LPA_ERROR_EXTENDED_API_UNAVAILABLE,
|
||||
LPA_ERROR_PROCESSING_ERROR,
|
||||
|
||||
// Local Profile Management
|
||||
LPA_ERROR_LOCAL_PROFILE_NOT_FOUND = 0x2101,
|
||||
LPA_ERROR_LOCAL_PROFILE_INCORRECT_STATE,
|
||||
LPA_ERROR_LOCAL_PROFILE_CAT_BUSY,
|
||||
LPA_ERROR_LOCAL_PROFILE_INCORRECT_CARD_RESPONSE,
|
||||
LPA_ERROR_LOCAL_PROFILE_UNKNOWN_ERROR,
|
||||
LPA_ERROR_LOCAL_PROFILE_NOTHING_TO_DELETE,
|
||||
LPA_ERROR_LOCAL_PROFILE_UNDEFINED_ERROR,
|
||||
LPA_ERROR_LOCAL_PROFILE_UNABLE_TO_EXTRACT_DATA,
|
||||
|
||||
LPA_ERROR_LOCAL_PROFILE_ICCID_OR_AID_NOT_FOUND, // enableResult => iccidOrAidNotFound
|
||||
LPA_ERROR_LOCAL_PROFILE_NOT_IN_DISABLE_STATE, // enableResult => profileNotInDisabledState
|
||||
LPA_ERROR_LOCAL_PROFILE_DISALLOWED_BY_POLICY, // enableResult => disallowedByPolicy
|
||||
LPA_ERROR_LOCAL_PROFILE_WRONG_PROFILE_REENABLING, // enableResult => wrongProfileReenabling
|
||||
LPA_ERROR_LOCAL_PROFILE_NOT_IN_ENABLE_STATE, // disableResult => profileNotInEnabledState
|
||||
|
||||
LPA_ERROR_LOCAL_PROFILE_INVALID_DATA_EXCHANGE,
|
||||
|
||||
// Notification management
|
||||
LPA_ERROR_NOTIFICATION_INCORRECT_CARD_RESPONSE = 0x2201,
|
||||
LPA_ERROR_NOTIFICATION_NOTHING_TO_DELETE,
|
||||
LPA_ERROR_NOTIFICATION_UNDEFINED_ERROR,
|
||||
LPA_ERROR_NOTIFICATION_UNKNOWN_ERROR,
|
||||
LPA_ERROR_NOTIFICATION_INVALID_CARD_DATA,
|
||||
|
||||
// Download Profile management
|
||||
LPA_ERROR_DOWNLOAD_PROFILE_PARAMETER_ERROR = 0x2301,
|
||||
LPA_ERROR_INVALID_GET_EUICC_INFO,
|
||||
LPA_ERROR_INVALID_GET_UICC_CHALLENGE,
|
||||
LPA_ERROR_INVALID_SERVER_ADDRESS,
|
||||
LPA_ERROR_FAILED_INITIAL_AUTHENTICATION,
|
||||
LPA_ERROR_FAILED_AUTHENTICATE_SERVER,
|
||||
LPA_ERROR_FAILED_AUTHENTICATE_CLIENT,
|
||||
LPA_ERROR_AUTHENTICATE_CLIENT_EXCHANGE,
|
||||
LPA_ERROR_FAILED_PREPARE_DOWNLOAD,
|
||||
LPA_ERROR_INVALID_ACTIVATION_CODE,
|
||||
LPA_ERROR_INVALID_CTX_PARAM,
|
||||
LPA_ERROR_INVALID_TRANSACTIONID,
|
||||
LPA_ERROR_INVALID_AUTHENTICATE_SERVER_RESPONSE,
|
||||
LPA_ERROR_INVALID_PREPARE_DOWNLOAD_RESPONSE,
|
||||
LPA_ERROR_INVALID_MATCHINGID_OR_DEVICE_INFO_TLV, // 03/09/2020 Confirmed not used anymore
|
||||
LPA_ERROR_INVALID_DEVICE_INFO_TLV,
|
||||
LPA_ERROR_FAILED_GET_BOUND_PROFILE_PACKAGE,
|
||||
LPA_ERROR_FAILED_LOAD_BPP,
|
||||
LPA_ERROR_FAILED_INITIAL_SECURITY_CHANNEL,
|
||||
LPA_ERROR_FAILED_CONFIGURE_ISDP,
|
||||
LPA_ERROR_FAILED_STORE_META_DATA,
|
||||
LPA_ERROR_FAILED_REPLACE_SESSION_KEY,
|
||||
LPA_ERROR_FAILED_LOAD_PROFILE_ELEMENTS,
|
||||
LPA_ERROR_FAILED_GET_DATA_FROM_ACTIVATION_CODE,
|
||||
LPA_ERROR_INVALID_PIR_RESPONSE,
|
||||
LPA_ERROR_GET_INTERNAL_SERVER_ERROR,
|
||||
LPA_ERROR_CJSON_PARSE_FAILURE,
|
||||
LPA_ERROR_FAILED_SEND_NOTIFICATION_OR_NOT_GET_STATUS_CODE,
|
||||
LPA_ERROR_SERVER_COMMUNICATION_ISSUE,
|
||||
LPA_ERROR_INVALID_EVENT_ID,
|
||||
LPA_ERROR_INVALID_RSP_SERVER_ADDRESS,
|
||||
LPA_ERROR_INVALID_EVENT_ENTRIES,
|
||||
LPA_ERROR_NO_EVENT_RECORD_FOUND, // This error code is now obsolete since V1.6
|
||||
LPA_ERROR_CONFIRMATION_CODE_MISSING_OR_EMPTY,
|
||||
LPA_ERROR_SERVER_RETURN_404_STATUS_CODE,
|
||||
LPA_ERROR_SERVER_RETURN_500_STATUS_CODE,
|
||||
LPA_ERROR_SE_MEDIA_UNABLE_TO_UNSELECT_ISDR,
|
||||
LPA_ERROR_INVALID_SERVERSIGNED1,
|
||||
LPA_ERROR_INVALID_SERVERSIGNATURE1,
|
||||
LPA_ERROR_INVALID_EUICCCIPKIDTOBEUSED,
|
||||
LPA_ERROR_INVALID_SERVERCERTIFICATE,
|
||||
LPA_ERROR_INVALID_SERVER_RESPONSE,
|
||||
LPA_ERROR_FAILED_CANCEL_SESSION,
|
||||
LPA_ERROR_INVALID_PROFILE_METADATA,
|
||||
LPA_ERROR_INVALID_GET_RAT,
|
||||
LPA_ERROR_PPR_NOT_ALLOWED,
|
||||
LPA_ERROR_DOWNLOAD_SESSION_CANCELED_BY_USER,
|
||||
LPA_ERROR_OID_MISMATCH,
|
||||
LPA_ERROR_INVALID_BPP_DATA,
|
||||
LPA_ERROR_SERVER_RETURN_ERROR_STATUS, // This apply when server return an error, in JSON code for example
|
||||
|
||||
// 0x8000 - 0x9999 => SE Media error
|
||||
SE_MEDIA_ERROR_BROKEN_PIPE = 0x8000,
|
||||
SE_MEDIA_E_CANCELLED,
|
||||
SE_MEDIA_E_CANT_DISPOSE,
|
||||
SE_MEDIA_E_CARD_UNSUPPORTED,
|
||||
SE_MEDIA_E_DUPLICATE_READER,
|
||||
SE_MEDIA_E_FILE_NOT_FOUND,
|
||||
SE_MEDIA_E_INSUFFICIENT_BUFFER,
|
||||
SE_MEDIA_E_INVALID_ATR,
|
||||
SE_MEDIA_E_INVALID_HANDLE,
|
||||
SE_MEDIA_E_INVALID_PARAMETER,
|
||||
SE_MEDIA_E_INVALID_TARGET,
|
||||
SE_MEDIA_E_INVALID_VALUE,
|
||||
SE_MEDIA_E_NO_MEMORY,
|
||||
SE_MEDIA_E_NO_READERS_AVAILABLE,
|
||||
SE_MEDIA_E_NO_SMARTCARD,
|
||||
SE_MEDIA_E_NOT_READY,
|
||||
SE_MEDIA_E_PROTO_MISMATCH,
|
||||
SE_MEDIA_E_READER_UNAVAILABLE,
|
||||
SE_MEDIA_E_READER_UNSUPPORTED,
|
||||
SE_MEDIA_E_SERVER_TOO_BUSY,
|
||||
SE_MEDIA_E_SERVICE_STOPPED,
|
||||
SE_MEDIA_E_SHARING_VIOLATION,
|
||||
SE_MEDIA_E_SYSTEM_CANCELLED,
|
||||
SE_MEDIA_E_TIMEOUT,
|
||||
SE_MEDIA_E_UNEXPECTED,
|
||||
SE_MEDIA_E_UNKNOWN_CARD,
|
||||
SE_MEDIA_E_UNKNOWN_READER,
|
||||
SE_MEDIA_W_REMOVED_CARD,
|
||||
SE_MEDIA_W_RESET_CARD,
|
||||
SE_MEDIA_W_UNSUPPORTED_CARD,
|
||||
SE_MEDIA_E_CHAINING_GET_RESPONSE, // Can be issued only if LPA_SDK__DEACTIVATE_RETRY_FOR_CHAINED_GET_RESPONSE is not defined
|
||||
|
||||
} LPA_API_ERROR;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LPA_PARAMETER_TYPE_BOOL, // bool
|
||||
LPA_PARAMETER_TYPE_LONG, // long
|
||||
LPA_PARAMETER_TYPE_STRING, // char*
|
||||
|
||||
LPA_PARAMETER_TYPE_UNKNOWN = 1664, // Unknown type; Must be the latest on the enum
|
||||
} LPA_PARAMETER_TYPE;
|
||||
|
||||
// List of settable parameters. Memory contain initialization is done by lpaManagerGetFullParametersList()
|
||||
// Size constants are fixed in lpasdk_api.h, shall fit all available parameters.
|
||||
typedef struct
|
||||
{
|
||||
size_t parametersCount;
|
||||
char parametersList[LPA_MAX_PARAMETERS_LIST][LPA_MAX_PARAMETERS_LIST_ELEMENT_SIZE];
|
||||
LPA_PARAMETER_TYPE parametersTypeList[LPA_MAX_PARAMETERS_LIST];
|
||||
}LPA_PARAMETERS_LIST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LPA_API_ERROR apiErrorCode;
|
||||
char* ptrApiErrorDescription;
|
||||
} LPA_API_ERROR_DESCRIPTION;
|
||||
|
||||
#if defined (LPA_SDK__PLATFORM_WIN) || defined (LPA_SDK__PLATFORM_CYGWIN)
|
||||
#define EXPORT_DLL __declspec(dllexport)
|
||||
#else
|
||||
// to add default visibility on LINUX
|
||||
//#define EXPORT_DLL __attribute__ ((visibility ("default") ))
|
||||
#define EXPORT_DLL
|
||||
|
||||
#endif
|
||||
|
||||
// LPA SDK API versionning
|
||||
EXPORT_DLL const LPA_API_VERSION* lpaGetApiVersion();
|
||||
|
||||
// LPA SDK Initialization
|
||||
EXPORT_DLL bool lpaInitialize(const char* ptrLpaFolder);
|
||||
// @Since: API 1.6
|
||||
EXPORT_DLL bool lpaInitializeWithInputOutputFolder(const char* ptrLpaInputFolder, const char* ptrLpaOutputFolder);
|
||||
|
||||
// Manage LPA SDK versionning
|
||||
EXPORT_DLL bool lpaGetVersion(LPA_VERSION* ptrLpaVersion);
|
||||
|
||||
// LPA SDK Uninitialization
|
||||
EXPORT_DLL bool lpaUninitialize();
|
||||
|
||||
// LPA SDK IS initialized
|
||||
EXPORT_DLL bool lpaIsInitialized();
|
||||
|
||||
// LPA SDK => GetErrorCode
|
||||
EXPORT_DLL LPA_API_ERROR lpaGetErrorCode();
|
||||
EXPORT_DLL const char* lpaGetErrorCodeDescription(LPA_API_ERROR apiError);
|
||||
|
||||
// LPA SDK Configuration
|
||||
EXPORT_DLL bool lpaSetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, const void* ptrParameterValue);
|
||||
EXPORT_DLL bool lpaGetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, void* ptrParameterValue, size_t parameterValueMaxSize);
|
||||
EXPORT_DLL bool lpaIsConfigParameterExist(const char* ptrParameterName, LPA_PARAMETER_TYPE* ptrParameterType, bool* ptrIsExist);
|
||||
|
||||
// LPA SDK Reader
|
||||
EXPORT_DLL bool lpaGetReaderList(LPA_SE_MEDIA_READER_NAME_INFO * readerNameInfoList, size_t readerNameInfoMax, size_t* countReader);
|
||||
|
||||
|
||||
EXPORT_DLL bool lpaGetProfilesInfo(LPA_GET_PROFILES_INFO*);
|
||||
EXPORT_DLL bool lpaGetProfilesNumber(size_t*);
|
||||
EXPORT_DLL bool lpaGetEID(LPA_GET_EID*);
|
||||
EXPORT_DLL bool lpaGetEUICCInfo(LPA_GET_EUICC_INFO* ptrGetEUICCInfo);
|
||||
EXPORT_DLL bool lpaMemoryReset(const unsigned char* memoryResetOptionParameter, const size_t memoryResetOptionSize);
|
||||
EXPORT_DLL bool lpaSendPendingNotification(LPA_EventCallback* ptrLpaEventCallback, LPA_SENDING_NOTIFICATION_RESULT* ptrSendingNotificationResult);
|
||||
|
||||
EXPORT_DLL bool lpaEnableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
|
||||
EXPORT_DLL bool lpaDisableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
|
||||
EXPORT_DLL bool lpaDeleteProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
|
||||
|
||||
EXPORT_DLL bool lpaSetDefaultSMDPAddress(const char* ptrSMDPAddr);
|
||||
EXPORT_DLL bool lpaGetSMDPAddress(ADDRESS_DATA* ptrAddressData);
|
||||
EXPORT_DLL bool lpaGetSMDSAddress(ADDRESS_DATA* ptrAddressData);
|
||||
|
||||
EXPORT_DLL bool lpaDownloadProfile(const char * ptrActivationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
|
||||
EXPORT_DLL bool lpaDownloadProfileWithConfirmationCode(const char * ptrActivationCodeStr, const char * ptrConfirmationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
|
||||
EXPORT_DLL bool lpaDownloadProfileWithDefaultSMDPAddress(const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
|
||||
EXPORT_DLL bool lpaDownloadProfileWithSMDSAddress( const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
|
||||
|
||||
EXPORT_DLL bool lpaSetNicknameByIccid(const unsigned char* ptrProfileId, size_t profileIdSize, const unsigned char* ptrNickname, size_t nickNameSize);
|
||||
|
||||
EXPORT_DLL void lpaSetLogLevel(unsigned char logLevel);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif // LPA_SDK__CORE_API_H
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LPA_SDK__CORE_EX_API_H
|
||||
#define LPA_SDK__CORE_EX_API_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long countMemoryAllocCall;
|
||||
long countMemoryFreeCall;
|
||||
long currentMemoryBlockAllocated;
|
||||
|
||||
long currentMemoryAllocated;
|
||||
long totalMemoryAllocated;
|
||||
|
||||
long maxMemoryAllocated;
|
||||
long maxMemoryBlockAllocated;
|
||||
}LPA_MEMORY_STATUS;
|
||||
|
||||
// Extented API
|
||||
/////////////////////////////////////////////
|
||||
|
||||
EXPORT_DLL bool lpaExGetExtraVersion(char* ptrVersionBuffer, size_t versionBufferMaxSize);
|
||||
|
||||
// Since LPASDK 1.5, moved on Extended API
|
||||
EXPORT_DLL bool lpaExGetFullParametersList(LPA_PARAMETERS_LIST * ptrLpaParametersList);
|
||||
|
||||
// LPA SDK SE Media Card Reset
|
||||
EXPORT_DLL bool lpaExCardReset();
|
||||
|
||||
EXPORT_DLL bool lpaExGetProfileNotificationList(LPA_PROFILE_NOTIFICATION_LIST* ptrProfileNotificationList);
|
||||
EXPORT_DLL bool lpaExClearProfileNotification(uint16_t sequenceNumber);
|
||||
|
||||
EXPORT_DLL bool lpaExWriteMemoryStatusDumpToLog();
|
||||
EXPORT_DLL bool lpaExGetMemoryStatus(LPA_MEMORY_STATUS* prtMemoryStatus);
|
||||
EXPORT_DLL bool lpaExCheckMemoryAllocated();
|
||||
|
||||
EXPORT_DLL LPA_API_ERROR_DESCRIPTION* lpaExGetListErrorCodeDescription();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // LPA_SDK__CORE_EX_API_H
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__API_SE_MEDIA_H
|
||||
#define LPA_SDK__API_SE_MEDIA_H
|
||||
|
||||
// Increase size of Reader Name buffer in Debug mode to allow more space for test command when Windows test driver DLL is used
|
||||
#if defined(_DEBUG) && defined(LPA_SDK__PLATFORM_WIN) && defined(LPA_SDK__SEMEDIA_DRIVER_EXTERNAL)
|
||||
#define LPA_CFG_READER_NAME_MAX_SIZE 255
|
||||
#else
|
||||
#define LPA_CFG_READER_NAME_MAX_SIZE 100
|
||||
#endif // _DEBUG & LPA_SDK__PLATFORM_WIN & LPA_SDK__SEMEDIA_DRIVER_EXTERNAL
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char readerName[LPA_CFG_READER_NAME_MAX_SIZE];
|
||||
} LPA_SE_MEDIA_READER_NAME_INFO;
|
||||
|
||||
typedef enum seMediaCardStatus
|
||||
{
|
||||
SE_MEDIA_STATUS_SCARD_UNKNOWN = 0x0001,
|
||||
SE_MEDIA_STATUS_SCARD_ABSENT = 0x0002, // There is no card in the reader.
|
||||
SE_MEDIA_STATUS_SCARD_PRESENT = 0x0004, // There is a card in the reader, but it has not been moved into position for use.
|
||||
SE_MEDIA_STATUS_SCARD_SWALLOWED = 0x0008, // There is a card in the reader in position for use.The card is not powered.
|
||||
SE_MEDIA_STATUS_SCARD_POWERED = 0x0010, // Power is being provided to the card, but the reader driver is unaware of the mode of the card.
|
||||
SE_MEDIA_STATUS_SCARD_NEGOTIABLE = 0x0020, // The card has been reset and is awaiting PTS negotiation.
|
||||
SE_MEDIA_STATUS_SCARD_SPECIFIC = 0x0040, // The card has been reset and specific communication protocols have been established.
|
||||
|
||||
|
||||
SE_MEDIA_STATUS_REMOVED_CARD = 0x80001, // The smart card has been removed(SCARD_W_REMOVED_CARD)
|
||||
SE_MEDIA_RESET_CARD, // The smart card has been reset(SCARD_W_RESET_CARD)
|
||||
}SE_MEDIA_CARD_STATUS;
|
||||
|
||||
typedef enum seMediaDisconnectCardParam
|
||||
{
|
||||
SE_MEDIA_DISCONNECT_LEAVE_CARD = 0, // Don't do anything special on close
|
||||
SE_MEDIA_DISCONNECT_RESET_CARD, // Reset the card on close
|
||||
SE_MEDIA_DISCONNECT_UNPOWER_CARD, // Power down the card on close
|
||||
}SE_MEDIA_DISCONNECT_CARD_PARAM;
|
||||
|
||||
#endif // LPA_SDK__API_SE_MEDIA_H
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__CORE_BERTLV_H
|
||||
#define LPA_SDK__CORE_BERTLV_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "lpasdk/core/lpa_core.h"
|
||||
#include "lpasdk/core/rawdata_object.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t tag;
|
||||
uint32_t length;
|
||||
unsigned char* value;
|
||||
}BeerTLV, *PtrBeerTLV;
|
||||
|
||||
//typedef struct BerTLVList BerTLVList;
|
||||
typedef struct BerTLVList
|
||||
{
|
||||
uint16_t index;
|
||||
BeerTLV* berTLV;
|
||||
struct BerTLVList* ptrNext;
|
||||
} BerTLVList;
|
||||
|
||||
UT_EXPORT_DLL BeerTLV* berTLV_create(uint16_t tag, uint32_t length, const unsigned char* ptrValue);
|
||||
UT_EXPORT_DLL BeerTLV* berTLV_extractTagUInt8(uint8_t tag, const unsigned char* ptrRawData, uint32_t rawDataSize, bool* ptrIsTagFound);
|
||||
UT_EXPORT_DLL BeerTLV* berTLV_extractTagUInt16(uint16_t tag, const unsigned char* ptrRawData, uint32_t rawDataSize, bool* ptrIsTagFound);
|
||||
UT_EXPORT_DLL BerTLVList* berTLV_extractList(const unsigned char* ptrRawData, uint32_t rawDataSize, uint8_t* ptrCountTLVFound);
|
||||
|
||||
UT_EXPORT_DLL RawDataObject* berTLV_buildRawDataObject(const BeerTLV* ptrBerTlv);
|
||||
UT_EXPORT_DLL RawDataObject* berTLV_createAndBuildRawDataObject(uint16_t tag, uint32_t length, const unsigned char* ptrValue);
|
||||
|
||||
UT_EXPORT_DLL bool berTLV_freeBerTLV(BeerTLV* ptrBerTLV);
|
||||
UT_EXPORT_DLL bool berTLV_freeBerTLVList(BerTLVList* ptrBerTLVList);
|
||||
|
||||
|
||||
// Some macro to help memory cleanup
|
||||
#define ERASE_BERTLV(_ptr) if ((_ptr) != NULL) { berTLV_freeBerTLV( (_ptr) ); (_ptr) = NULL;}
|
||||
#define ERASE_BERTLV_LIST(_ptr) if ((_ptr) != NULL) { berTLV_freeBerTLVList( (_ptr) ); (_ptr) = NULL;}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // LPA_SDK__CORE_BERTLV_H
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HTTPMEDIA_BASE_H
|
||||
#define HTTPMEDIA_BASE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "lpasdk/core/httpmedia_option_type.h"
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
|
||||
typedef struct THTTPMedia {
|
||||
void* _childStruct;
|
||||
bool (*httpMediaHttpExecuteInit) (const struct THTTPMedia*);
|
||||
bool (*httpMediaPost) (const struct THTTPMedia*, const char* ptrCertificatePath, const char* ptrTargetURL, const char* ptrPostdata, long* ptrHttpCode);
|
||||
|
||||
void (*httpMediaHttpExecuteCleanup) (const struct THTTPMedia*);
|
||||
char* (*httpMediaGetBufferResponse) (const struct THTTPMedia*);
|
||||
bool (*httpMediaSetBooleanOption) (const struct THTTPMedia*, HttpMediaOptionType optionType, bool enabled);
|
||||
bool (*httpMediaGetBooleanOption) (const struct THTTPMedia*, HttpMediaOptionType optionType, bool* ptrEnabled);
|
||||
|
||||
bool (*httpMediaSetLongOption) (const struct THTTPMedia*, HttpMediaOptionType optionType, long value);
|
||||
bool (*httpMediaGetLongOption) (const struct THTTPMedia*, HttpMediaOptionType optionType, long* ptrValue);
|
||||
|
||||
// EventErrorCallback support
|
||||
bool(*httpMediaSetCallbackEventExecutionError) (const struct THTTPMedia*, LPA_EVENT_EXECUTION_ERROR lpaEventExecutionErrorCallback);
|
||||
} THTTPMedia;
|
||||
|
||||
THTTPMedia* New_HTTPMediaBase();
|
||||
|
||||
|
||||
|
||||
#endif /* HTTPMEDIA_BASE_H */
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HTTPMEDIAMANAGER_H
|
||||
#define HTTPMEDIAMANAGER_H
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lpasdk/core/httpmedia_option_type.h"
|
||||
#include "lpasdk/core/lpa_core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
UT_EXPORT_DLL bool httpMediaManagerInitialize();
|
||||
UT_EXPORT_DLL bool httpMediaManagerIsInitialized();
|
||||
UT_EXPORT_DLL bool httpMediaManagerDelete();
|
||||
|
||||
bool httpMediaManagerConfigure();
|
||||
|
||||
bool httpMediaManagerSetBooleanOption(HttpMediaOptionType optionType, bool enabled);
|
||||
bool httpMediaManagerGetBooleanOption(HttpMediaOptionType optionType, bool* ptrEnabled);
|
||||
|
||||
bool httpMediaManagerSetLongOption(HttpMediaOptionType optionType, long value);
|
||||
bool httpMediaManagerGetLongOption(HttpMediaOptionType optionType, long* ptrValue);
|
||||
|
||||
bool httpMediaManagerSetCallbackEventExecutionError(LPA_EVENT_EXECUTION_ERROR lpaEventExecutionErrorCallback);
|
||||
|
||||
char* httpMediaManagerPost(const char* ptrCertificatePath, const char* ptrTargetURL, const char* ptrPostdata, bool* ptrIsSuccess, long* ptrHttpCode);
|
||||
char* httpMediaManagerHTTPExecutePost(bool* ptrIsSuccess, long* ptrHttpCode);
|
||||
|
||||
bool httpMediaManagerSetTargetUrl( char* ptrTargetURL);
|
||||
bool httpMediaManagerSetCertificatePath( char* ptrCertificatePath);
|
||||
|
||||
bool httpMediaManagerSetPostData( char* ptrPostdata);
|
||||
bool httpMediaManagerSetHeaders();
|
||||
|
||||
bool httpMediaManagerSetCallback();
|
||||
bool httpMediaManagerSetWriteData();
|
||||
bool httpMediaManagerHttpExecuteInit();
|
||||
bool httpMediaManagerHttpExecuteCleanup();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* HTTPMEDIAMANAGER_H */
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__HTTP_MEDIA_OPTION_TYPE_H
|
||||
#define LPA_SDK__HTTP_MEDIA_OPTION_TYPE_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
// CURL option
|
||||
HTTP_MEDIA_OPTION_TYPE_CURL_SSL_VERIFYPEER,
|
||||
HTTP_MEDIA_OPTION_TYPE_CURL_SSL_VERIFYHOST,
|
||||
HTTP_MEDIA_OPTION_TYPE_CURL_VERBOSE,
|
||||
HTTP_MEDIA_OPTION_TYPE_CURL_CONNECT_TIMEOUT,
|
||||
HTTP_MEDIA_OPTION_TYPE_CURL_TIMEOUT
|
||||
} HttpMediaOptionType;
|
||||
|
||||
#endif // LPA_SDK__HTTP_MEDIA_OPTION_TYPE_H
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__ISDR_APPLET_MANAGER_H
|
||||
#define LPA_SDK__ISDR_APPLET_MANAGER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool selectISDRApplet();
|
||||
bool isISDRAppletSelected();
|
||||
bool unselectISDRApplet();
|
||||
|
||||
#endif // LPA_SDK__ISDR_APPLET_MANAGER_H
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__CONFIG_FILE_H
|
||||
#define LPA_SDK__CONFIG_FILE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lpasdk/core/lpa_core.h"
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "lpasdk/core/lpa_config_interface.h"
|
||||
|
||||
bool lpaConfigFileLoad(const char* ptrConfigFileName, bool* ptrConfigFilePresent);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // LPA_SDK__CONFIG_H
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__CONFIG_INTERFACE_H
|
||||
#define LPA_SDK__CONFIG_INTERFACE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lpasdk/core/lpa_log_interface.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
typedef struct LPA_CONFIG_INTERFACE LPA_CONFIG_INTERFACE;
|
||||
struct LPA_CONFIG_INTERFACE
|
||||
{
|
||||
bool (*setLog)(const LPA_LOG_INTERFACE* ptrLogInterface);
|
||||
bool (*setConfigFileName)(const char*ptrConfigFileName);
|
||||
bool (*load) ();
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // LPA_SDK__CONFIG_INTERFACE_H
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__LPA_CORE_H
|
||||
#define LPA_SDK__LPA_CORE_H
|
||||
|
||||
#define LPA_SDK__PLATFORM_RASPBIAN
|
||||
|
||||
#ifdef LPA_SDK__PLATFORM_WIN
|
||||
#include "lpasdk/core/win/lpa_core.h"
|
||||
#endif //
|
||||
|
||||
#ifdef LPA_SDK__PLATFORM_CYGWIN
|
||||
#include "lpasdk/core/cygwin/lpa_core.h"
|
||||
#endif //LPA_SDK__PLATFORM_CYGWIN
|
||||
|
||||
#ifdef LPA_SDK__PLATFORM_RASPBIAN
|
||||
#include "lpasdk/core/raspbian/lpa_core.h"
|
||||
#endif //LPA_SDK__PLATFORM_RASPBIAN
|
||||
|
||||
// Define generic MACRO & Constant
|
||||
///////////////////////////////////////
|
||||
|
||||
#define LPA_RES_TRUE_STRING "true"
|
||||
#define LPA_RES_FALSE_STRING "false"
|
||||
|
||||
// Check that macro exits for specific platform
|
||||
///////////////////////////////////////
|
||||
|
||||
#ifndef UT_EXPORT_DLL
|
||||
#error "UT_EXPORT_DLL not defined for current platform"
|
||||
//#define UT_EXPORT_DLL // Nothing specific for this platform
|
||||
|
||||
#endif // UT_EXPORT_DLL
|
||||
|
||||
#ifndef LPA_SDK_INLINE_FUNCTION
|
||||
#error "LPA_SDK_INLINE_FUNCTION not defined for current platform"
|
||||
//#define LPA_SDK_INLINE_FUNCTION // Nothing specific for this platform
|
||||
|
||||
#endif // LPA_SDK_INLINE_FUNCTION
|
||||
|
||||
|
||||
|
||||
#endif // LPA_SDK__LPA_CORE_H
|
||||
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__CORE_LOG_H
|
||||
#define LPA_SDK__CORE_LOG_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lpasdk/core/lpa_core.h"
|
||||
#include "lpasdk/core/lpa_log_interface.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
UT_EXPORT_DLL bool lpaCoreLogInit();
|
||||
UT_EXPORT_DLL bool lpaCoreLogInitEx(LPA_LOG_INTERFACE* lpaLogInterface);
|
||||
UT_EXPORT_DLL bool lpaCoreLogIsInitialized();
|
||||
UT_EXPORT_DLL bool lpaCoreLogRelease();
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreLogOpen(const char* ptrFileName, const char* prtBackupFileName);
|
||||
UT_EXPORT_DLL void lpaCoreLogFlush();
|
||||
UT_EXPORT_DLL void lpaCoreLogClose();
|
||||
UT_EXPORT_DLL bool lpaCoreLogIsOpen();
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreActivateLogLimitation(bool activated);
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreSetLogLevel(LpaLogLevel logLevel);
|
||||
UT_EXPORT_DLL LpaLogLevel lpaCoreGetLogLevel(void);
|
||||
|
||||
UT_EXPORT_DLL bool lpaCoreSetLogMaxSize(long logMaxSize);
|
||||
UT_EXPORT_DLL long lpaCoreGetLogMaxSize();
|
||||
|
||||
UT_EXPORT_DLL const char* lpaCoreGetLogLevelName(LpaLogLevel logLevel, bool* ptrIsFound);
|
||||
|
||||
UT_EXPORT_DLL bool lpaCoreSetLogLevelString(const char* logLevelString);
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreLogAppend(LpaLogLevel logLevel, const char* ptrMessage, ...);
|
||||
UT_EXPORT_DLL void lpaCoreLogAppendLongText(LpaLogLevel logLevel, const char* ptrHeaderMessage, const char* ptrLongTextToLog, const size_t LongTextToLogSize);
|
||||
UT_EXPORT_DLL void lpaCoreLogAppendByteArray(LpaLogLevel logLevel, const char* ptrMessage, const char* ptrByteArrayName, unsigned char* ptrByteArray, size_t byteArraySize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // LPA_SDK__CORE_LOG_H
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__CORE_LOG_INTERFACE_H
|
||||
#define LPA_SDK__CORE_LOG_INTERFACE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDK_LOG_LEVEL_UNKNOWN,
|
||||
|
||||
SDK_LOG_LEVEL_VERBOSE,
|
||||
SDK_LOG_LEVEL_DEBUG,
|
||||
SDK_LOG_LEVEL_INFO,
|
||||
SDK_LOG_LEVEL_WARNING,
|
||||
SDK_LOG_LEVEL_ERROR,
|
||||
SDK_LOG_LEVEL_SYSTEM // Use only internally
|
||||
} LpaLogLevel;
|
||||
|
||||
typedef struct LPA_LOG_INTERFACE LPA_LOG_INTERFACE;
|
||||
struct LPA_LOG_INTERFACE
|
||||
{
|
||||
void (*openLog) (const char* ptrFileName, const char* prtBackupFileName);
|
||||
void (*flushLog)();
|
||||
bool (*isLogOpened)();
|
||||
void(*closeLog)();
|
||||
|
||||
void (*activateLogLimitation) (bool activated);
|
||||
|
||||
void (*setLogLevel) (LpaLogLevel logLevel);
|
||||
LpaLogLevel (*getLogLevel)(void);
|
||||
|
||||
bool (*setLogMaxSize)(long logMaxSize);
|
||||
long (*getLogMaxSize)();
|
||||
|
||||
void (*appendToLog)(LpaLogLevel logLevel, const char* ptrMessage, va_list argptr);
|
||||
void (*appendLongTextToLog)(LpaLogLevel logLevel, const char* ptrHeaderMessage, const char* ptrLongTextToLog, const size_t LongTextToLogSize);
|
||||
void (*appendByteArrayToLog)(LpaLogLevel logLevel, const char* ptrMessage, const char* ptrByteArrayName, unsigned char* ptrByteArray, size_t byteArraySize);
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // LPA_SDK__CORE_LOG_INTERFACE_H
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__LPA_MANAGER_H
|
||||
#define LPA_SDK__LPA_MANAGER_H
|
||||
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
#include "lpasdk/lpasdk_internal_api.h"
|
||||
|
||||
#ifdef LPA_SDK__USING_EX_API
|
||||
//#include "lpasdk/lpasdk_ex_api.h"
|
||||
#endif // LPA_SDK__USING_EX_API
|
||||
|
||||
#include "lpasdk/core/lpa_core.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define MAX_LPA_MANAGER_APDU_BUFFER_SIZE 8192
|
||||
|
||||
bool lpaManagerInitialize(const char* ptrLpaFolder);
|
||||
bool lpaManagerInitializeSEMedia();
|
||||
bool lpaManagerInitializeHttpMedia();
|
||||
|
||||
bool lpaManagerSetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, const void* ptrParameterValue, bool internalCall);
|
||||
bool lpaManagerGetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, void* ptrParameterValue, size_t parameterValueMaxSize);
|
||||
bool lpaManagerIsConfigParameterExist(const char* ptrParameterName, LPA_PARAMETER_TYPE* ptrParameterType, bool* ptrIsExist, bool* ptrAccessGranted);
|
||||
bool lpaManagerGetFullParametersList(LPA_PARAMETERS_LIST * ptrLpaParametersList);
|
||||
|
||||
// SEMedia manager redirections through lpa_manager.c
|
||||
bool lpaManagerSEMediaManagerIsInitialized();
|
||||
bool lpaManagerSEMediaManagerUninitialize();
|
||||
// Reconnect SEMedia
|
||||
bool lpaManagerSEMediaCardReset();
|
||||
|
||||
// httpMedia manager redirections through lpa_manager.c
|
||||
bool lpaManagerHttpMediaManagerIsInitialized();
|
||||
bool lpaManagerHttpMediaManagerDelete();
|
||||
|
||||
|
||||
// Exchange with ISDR applet
|
||||
bool lpaManagerGetReaderList(LPA_SE_MEDIA_READER_NAME_INFO * ptrReaderNameInfoList, size_t readerNameInfoMax, size_t* ptrCountReader);
|
||||
bool lpaManagerGetProfilesInfo(LPA_GET_PROFILES_INFO* );
|
||||
bool lpaManagerGetProfilesNumber(size_t* );
|
||||
bool lpaManagerGetEID(LPA_GET_EID* );
|
||||
bool lpaManagerGetEUICCInfo2(LPA_GET_EUICC_INFO* ptrGetEUICCInfo);
|
||||
bool lpaManagerMemoryReset(const unsigned char* memoryResetOptionParameter, const size_t memoryResetOptionSize);
|
||||
bool lpaManagerSendPendingNotification(LPA_EventCallback* ptrLpaEventCallback, LPA_SENDING_NOTIFICATION_RESULT* ptrSendingNotificationResult);
|
||||
|
||||
|
||||
// Manage Enable/Disable/Delete Profile
|
||||
bool lpaManagerEnableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
|
||||
bool lpaManagerDisableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
|
||||
bool lpaManagerDeleteProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
|
||||
|
||||
// Manage notification list
|
||||
bool lpaManagerGetProfileNotificationList(LPA_PROFILE_NOTIFICATION_LIST* ptrProfileNotificationList);
|
||||
bool lpaManagerClearProfileNotification(uint16_t sequenceNumber);
|
||||
|
||||
bool lpaManagerSetDefaultSMDPAddress(const char* ptrSMDPAddr);
|
||||
bool lpaManagerGetSMDPAddress(ADDRESS_DATA* ptrAddressData);
|
||||
bool lpaManagerGetSMDSAddress(ADDRESS_DATA* ptrAddressData);
|
||||
|
||||
bool lpaManagerDownloadProfile(const char * ptrActivationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
|
||||
bool lpaManagerDownloadProfileWithConfirmationCode(const char * ptrActivationCodeStr, const char * ptrConfirmationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
|
||||
bool lpaManagerDownloadProfileWithDefaultSMDPAddress(const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
|
||||
bool lpaManagerDownloadProfileWithSMDSAddress( const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
|
||||
|
||||
bool lpaManagerGetProfileNotificationList(LPA_PROFILE_NOTIFICATION_LIST* ptrProfileNotificationList);
|
||||
bool lpaManagerClearProfileNotification(uint16_t sequenceNumber);
|
||||
|
||||
// Nickname management
|
||||
bool lpaManagerSetNickname(const unsigned char* ptrProfileId, size_t profileIdSize, const unsigned char* ptrNickname, size_t nickNameSize);
|
||||
|
||||
bool lpaManagerConnectReaderAndSelectISDR();
|
||||
bool lpaManagerUnselectISDRAndDisconnectReader();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif // LPA_SDK__LPA_MANAGER_H
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__LPA_MANAGER_API_H
|
||||
#define LPA_SDK__LPA_MANAGER_API_H
|
||||
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
#include "lpasdk/lpasdk_internal_api.h"
|
||||
|
||||
#ifdef LPA_SDK__USING_EX_API
|
||||
#include "lpasdk/api/lpasdk_ex_api.h"
|
||||
#endif // LPA_SDK__USING_EX_API
|
||||
|
||||
#include "lpasdk/core/lpa_core.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
// PARAMETER KEY NAMES
|
||||
// Parameter list itself is defined in lpa_manager.c
|
||||
|
||||
#define LPA_SDK_CONFIG_PARAM_READER_NAME "readerName"
|
||||
#define LPA_SDK_CONFIG_PARAM_DEVICE_INFO_TLV "deviceInfoTlv"
|
||||
#define LPA_SDK_CONFIG_PARAM_CERT_PATH "certPath"
|
||||
|
||||
|
||||
#define LPA_SDK_CONFIG_PARAM_SEND_PIR_DURING_DOWNLOAD_PROFILE "sendPIRDuringDownloadProfile"
|
||||
#define LPA_SDK_CONFIG_PARAM_USING_HTTPS_REQUEST "usingHTTPSRequest"
|
||||
#define LPA_SDK_CONFIG_PARAM_ACTIVATE_CURL_DEBUG_MODE "activateCURLDebugMode"
|
||||
#define LPA_SDK_CONFIG_PARAM_ADD_LE_TO_APDU_CASE_4 "addLeToApduCase4"
|
||||
#define LPA_SDK_CONFIG_PARAM_LOG_LEVEL "logLevel"
|
||||
#define LPA_SDK_CONFIG_PARAM_LOG_MAX_SIZE "logMaxSize"
|
||||
#define LPA_SDK_CONFIG_PARAM_PROFILE_REFRESH_FLAG "profileRefreshFlag"
|
||||
|
||||
#define LPA_SDK_CONFIG_PARAM_CURL_SSL_SSL_VERIFYPEER "CURL_SSL_VERIFYPEER"
|
||||
#define LPA_SDK_CONFIG_PARAM_CURL_SSL_SSL_VERIFYHOST "CURL_SSL_VERIFYHOST"
|
||||
|
||||
#define LPA_SDK_CONFIG_PARAM_CURL_CONNECT_TIMEOUT "CURL_CONNECT_TIMEOUT"
|
||||
#define LPA_SDK_CONFIG_PARAM_CURL_TIMEOUT "CURL_TIMEOUT"
|
||||
|
||||
#define LPA_SDK_CONFIG_PARAM_DEVICE_CAPABILITIES_FILTERING "deviceCapabilitiesFiltering"
|
||||
|
||||
#define LPA_SDK_CONFIG_PARAM_DEVICE_SMDS_ADDRESS "deviceSMDSAddress"
|
||||
#define LPA_SDK_CONFIG_PARAM_DEVICE_DEFAULT_SMDP_ADDRESS "deviceDefaultSMDPAddress"
|
||||
|
||||
#define LPA_SDK_CONFIG_PARAM_BYPASS_DEFAULT_USER_CONSENT_WITH_NO_PPR "bypassDefaultUserConsentWithNoPPR"
|
||||
#define LPA_SDK_CONFIG_PARAM_SUPPORT_DOWLOAD_PROFILES_WITH_PPR "supportDownloadOfProfilesWithPPR"
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiInitialize(const char* ptrLpaFolder);
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiSetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, const void* ptrParameterValue, bool internalCall);
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, void* ptrParameterValue, size_t parameterValueMaxSize);
|
||||
UT_EXPORT_DLL bool lpaManagerApiIsConfigParameterExist(const char* ptrParameterName, LPA_PARAMETER_TYPE* ptrParameterType, bool* ptrIsExist);
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetFullParametersList(LPA_PARAMETERS_LIST * ptrLpaParametersList);
|
||||
|
||||
// Reconnect SEMedia
|
||||
UT_EXPORT_DLL bool lpaManagerApiSEMediaCardReset();
|
||||
|
||||
|
||||
// Exchange with ISDR applet
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetReaderList(LPA_SE_MEDIA_READER_NAME_INFO * ptrReaderNameInfoList, size_t readerNameInfoMax, size_t* ptrCountReader);
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetProfilesInfo(LPA_GET_PROFILES_INFO*);
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetProfilesNumber(size_t*);
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetEID(LPA_GET_EID*);
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetEUICCInfo(LPA_GET_EUICC_INFO* ptrGetEUICCInfo);
|
||||
UT_EXPORT_DLL bool lpaManagerApiMemoryReset(const unsigned char* memoryResetOptionParameter, const size_t memoryResetOptionSize);
|
||||
UT_EXPORT_DLL bool lpaManagerApiSendPendingNotification(LPA_EventCallback* ptrLpaEventCallback, LPA_SENDING_NOTIFICATION_RESULT* ptrSendingNotificationResult);
|
||||
|
||||
|
||||
// Manage Enable/Disable/Delete Profile
|
||||
UT_EXPORT_DLL bool lpaManagerApiEnableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
|
||||
UT_EXPORT_DLL bool lpaManagerApiDisableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
|
||||
UT_EXPORT_DLL bool lpaManagerApiDeleteProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
|
||||
|
||||
// Manage notification list
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetProfileNotificationList(LPA_PROFILE_NOTIFICATION_LIST* ptrProfileNotificationList);
|
||||
UT_EXPORT_DLL bool lpaManagerApiClearProfileNotification(uint16_t sequenceNumber);
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiSetDefaultSMDPAddress(const char* ptrSMDPAddr);
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetSMDPAddress(ADDRESS_DATA* ptrAddressData);
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetSMDSAddress(ADDRESS_DATA* ptrAddressData);
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiDownloadProfile(const char * ptrActivationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
|
||||
UT_EXPORT_DLL bool lpaManagerApiDownloadProfileWithConfirmationCode(const char * ptrActivationCodeStr, const char * ptrConfirmationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
|
||||
UT_EXPORT_DLL bool lpaManagerApiDownloadProfileWithDefaultSMDPAddress(const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
|
||||
UT_EXPORT_DLL bool lpaManagerApiDownloadProfileWithSMDSAddress(const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiSetNickname(const unsigned char* ptrProfileId, size_t profileIdSize, const unsigned char* ptrNickname, size_t nickNameSize);
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiSEMediaManagerIsInitialized();
|
||||
UT_EXPORT_DLL bool lpaManagerApiSEMediaManagerUninitialize();
|
||||
UT_EXPORT_DLL bool lpaManagerApiHttpMediaManagerIsInitialized();
|
||||
UT_EXPORT_DLL bool lpaManagerApiHttpMediaManagerDelete();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif // LPA_SDK__LPA_MANAGER_API_H
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__LPA_MANAGER_ES10B_H
|
||||
#define LPA_SDK__LPA_MANAGER_ES10B_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
#include "lpasdk/lpasdk_internal_api.h"
|
||||
|
||||
#include "lpasdk/core/rawdata_object.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
RawDataObject* ptrRawDataObjectTLV_transactionId;
|
||||
RawDataObject* ptrRawDataObjectTLV_ccRequiredFlag;
|
||||
RawDataObject* ptrRawDataObjectTLV_bppEuiccOtpk;
|
||||
} SMDP_SIGNED2_DATA;
|
||||
|
||||
|
||||
bool lpaManagerES10b_PrepareDownload(ptr_serverData, const LPA_EventCallback* ptrLpaEventCallback, const char * ptrStringHashCC, PREPARE_DOWNLOAD_RESPONSE*);
|
||||
bool lpaManagerES10b_LoadBoundProfilePackage(ptr_serverData p_serverData, PROFILE_INSTALLATION_RESULT *pir, bool * cancelForBPPerrors);
|
||||
bool lpaManagerES10b_GetEuiccChallenge(LPA_GET_EUICC* ptrGetEUICC);
|
||||
bool lpaManagerES10b_GetEuiccInfo(const unsigned short eUICCinfoTag, LPA_GET_EUICC* ptrGetEUICC);
|
||||
bool lpaManagerES10b_AuthenticateServer(ptr_serverData p_serverData, const LPA_EventCallback* ptrLpaEventCallback, RawDataObject * ptrCtxParam, AUTHENTICATE_SERVER_RESPONSE* ptrAnthServerResp);
|
||||
bool lpaManagerES10b_CancelSession(const char * transactionID, const unsigned int p_reasonCode, CANCEL_SESSION_RESPONSE * ptrCancelSessionResp);
|
||||
bool lpaManagerES10b_GetRAT(RawDataObject ** ptrGetRAT);
|
||||
|
||||
#endif // LPA_SDK__LPA_MANAGER_ES10C_H
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__LPA_MANAGER_ES10C_H
|
||||
#define LPA_SDK__LPA_MANAGER_ES10C_H
|
||||
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void lpaManagerES10c_SetRefreshFlag(bool refreshFlagActivated);
|
||||
bool lpaManagerES10c_IsRefreshFlag();
|
||||
|
||||
bool lpaManagerES10c_GetProfilesInfo(LPA_GET_PROFILES_INFO* ptrLpaGetProfilesInfo, bool * continueRetry, bool requestForPPRmanagement);
|
||||
bool lpaManagerES10c_GetProfilesNumber(size_t*);
|
||||
bool lpaManagerES10c_EnableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
|
||||
bool lpaManagerES10c_DisableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
|
||||
bool lpaManagerES10c_DeleteProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
|
||||
bool lpaManagerES10c_MemoryReset(const unsigned char* memoryResetOptionParameter, const size_t memoryResetOptionSize);
|
||||
bool lpaManagerES10c_GetEID(LPA_GET_EID*);
|
||||
bool lpaManagerES10c_SetNickname(const unsigned char* ptrProfileId, size_t profileIdSize, const unsigned char* ptrNickname, size_t nickNameSize);
|
||||
|
||||
#endif // LPA_SDK__LPA_MANAGER_ES10C_H
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__LPA_MANAGER_ES9_PLUS_H
|
||||
#define LPA_SDK__LPA_MANAGER_ES9_PLUS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
#include "lpasdk/lpasdk_internal_api.h"
|
||||
|
||||
bool lpaManagerES9Plus_InitiateAuthentication(ptr_serverData p_serverData, const LPA_EventCallback* ptrLpaEventCallback, const char * ptrEuiccChallenge, const char * ptrEuiccInfo1, const char* ptrSmdpAddress);
|
||||
bool lpaManagerES9Plus_GetBoundProfilePackage(ptr_serverData p_serverData, const LPA_EventCallback* ptrLpaEventCallback, const char* ptrSmdpAddress, const unsigned char* ptrPrepareDownloadResponse, bool * cancelForBPPerrors);
|
||||
bool lpaManagerES9Plus_AuthenticateClient(ptr_serverData p_serverData, const LPA_EventCallback* ptrLpaEventCallback, const char* ptrSmdpAddress, const unsigned char* ptrAuthenticateServerResponse);
|
||||
|
||||
bool lpaManagerES9Plus_HandleNotification(const char* ptrSmdpAddr, size_t smdpAddrSize, const unsigned char* ptrPendingNotification, const LPA_EventCallback* ptrLpaEventCallback, bool * ptrNormalAcknowledge);
|
||||
bool lpaManagerES9Plus_EventRetrieval(const char* ptrTransactionId, const LPA_EventCallback* ptrLpaEventCallback, const char* ptrSmdsAddress, const unsigned char* ptrAuthenticateServerResponse, EVENT_RECORD_LIST* ptrEventRecordList);
|
||||
|
||||
bool lpaManagerES9plus_CancelSession(const char * transactionID, CANCEL_SESSION_RESPONSE * ptrCancelSessionResp, const char* ptrSmdpAddress, const LPA_EventCallback* ptrLpaEventCallback);
|
||||
|
||||
// From lpa_manager.c
|
||||
char* lpaManagerES9Plus_ExecutePost(const char * ptrTargetURL, const char * ptrJsonRequest, bool* ptrIsSuccess, long *ptrHttpCode, const LPA_EventCallback* ptrLpaEventCallback);
|
||||
|
||||
// certPath support
|
||||
void lpaManagerES9Plus_Init(const char * defaultCertPath);
|
||||
bool lpaManagerES9Plus_setCertPath(const char* ptrCertPath);
|
||||
size_t lpaManagerES9Plus_getCertPathSize();
|
||||
bool lpaManagerES9Plus_getCertPath(char*ptrCertPath, size_t ptrCertPathMaxSize);
|
||||
|
||||
#endif // LPA_SDK__LPA_MANAGER_ES9_PLUS_H
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__LPA_MANAGER_HELPER_H
|
||||
#define LPA_SDK__LPA_MANAGER_HELPER_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lpasdk/core/bertlv_object.h"
|
||||
|
||||
void lpaManagerHelperSetLeToAddApduCase4(bool enable);
|
||||
bool lpaManagerHelperIsLeAddedToApduCase4();
|
||||
|
||||
bool buildAndSendStoreDataCase3WithoutResponseData(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW);
|
||||
bool buildAndSendStoreDataCase3(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize);
|
||||
|
||||
bool buildAndSendStoreDataCase4WithoutResponseData(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW);
|
||||
bool buildAndSendStoreDataCase4(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize);
|
||||
bool buildAndSendApduCase4(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize);
|
||||
bool buildAndSendApduCase4Ex(const unsigned char* ptrApduC, uint16_t apduCSize, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize);
|
||||
|
||||
#endif // LPA_SDK__LPA_MANAGER_HELPER_H
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__CORE_MEMORY_H
|
||||
#define LPA_SDK__CORE_MEMORY_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef LPA_SDK__USING_EX_API
|
||||
#include "lpasdk/api/lpasdk_ex_api.h"
|
||||
#endif // LPA_SDK__USING_EX_API
|
||||
|
||||
#include "lpasdk/core/lpa_core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreMemoryInitialize();
|
||||
|
||||
#ifdef LPA_SDK__MEMORY
|
||||
|
||||
#define LPA_CORE_MEMORY_GENERATE_ERR_IF_MEMORY_COUNTER_EQ 1
|
||||
#define LPA_CORE_MEMORY_GENERATE_ERR_IF_MEMORY_COUNTER_GT 2
|
||||
#define LPA_CORE_MEMORY_GENERATE_ERR_IF_MEMORY_COUNTER_GE 3
|
||||
|
||||
#define LPA_CORE_MEMORY_GENERATE_ERR_IF_MEMORY_SIZE_REQUESTED_EQ 4
|
||||
#define LPA_CORE_MEMORY_GENERATE_ERR_IF_MEMORY_SIZE_REQUESTED_GT 5
|
||||
#define LPA_CORE_MEMORY_GENERATE_ERR_IF_MEMORY_SIZE_REQUESTED_GE 6
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreMemoryResetParamGenerateErr();
|
||||
UT_EXPORT_DLL bool lpaCoreMemorySetParamGenerateErr(uint8_t param, long value);
|
||||
UT_EXPORT_DLL bool lpaCoreMemoryGetParamGenerateErr(uint8_t param, long* ptrValue);
|
||||
|
||||
|
||||
#ifndef LPA_SDK__MEMORY_MONITORING
|
||||
|
||||
// Allocate memory
|
||||
void* lpaCoreMemoryAlloc(size_t size);
|
||||
void* lpaCoreMemoryCalloc(size_t count, size_t size);
|
||||
void* lpaCoreMemoryRealloc(void* ptrMemoryBlock, size_t newSize);
|
||||
|
||||
// free memory
|
||||
void lpaCoreMemoryFree(void* ptrMemoryBlock);
|
||||
|
||||
#else // LPA_SDK__MEMORY_MONITORING
|
||||
|
||||
UT_EXPORT_DLL void* lpaCoreMemoryMonitorAlloc(char* ptrFilename, int line, size_t size);
|
||||
UT_EXPORT_DLL void* lpaCoreMemoryMonitorCalloc(char* ptrFilename, int line, size_t count, size_t size);
|
||||
UT_EXPORT_DLL void* lpaCoreMemoryMonitorRealloc(char* ptrFilename, int line, void* ptrMemoryBlock, size_t newSize);
|
||||
UT_EXPORT_DLL void lpaCoreMemoryMonitorFree(char* ptrFilename, int line, void* mem);
|
||||
|
||||
// Wrapper to monitor memory API call
|
||||
#define lpaCoreMemoryAlloc(size) lpaCoreMemoryMonitorAlloc(__FILE__, __LINE__, size)
|
||||
#define lpaCoreMemoryCalloc(count, size) lpaCoreMemoryMonitorCalloc(__FILE__, __LINE__,count,size)
|
||||
#define lpaCoreMemoryRealloc(ptrMemoryBlock, newSize) lpaCoreMemoryMonitorRealloc(__FILE__, __LINE__,ptrMemoryBlock,newSize)
|
||||
#define lpaCoreMemoryFree(mem) lpaCoreMemoryMonitorFree(__FILE__, __LINE__, mem)
|
||||
|
||||
#endif // LPA_SDK__MEMORY_MONITORING
|
||||
#else // LPA_SDK__MEMORY
|
||||
|
||||
//Not using owner memory mecanism
|
||||
#define lpaCoreMemoryAlloc(size) malloc(size)
|
||||
#define lpaCoreMemoryCalloc(count, size) calloc(count,size)
|
||||
#define lpaCoreMemoryRealloc(ptrMemoryBlock, newSize) realloc(ptrMemoryBlock,newSize)
|
||||
#define lpaCoreMemoryFree(mem) free(mem)
|
||||
|
||||
#endif // LPA_SDK__MEMORY
|
||||
|
||||
#ifdef LPA_SDK__USING_EX_API
|
||||
UT_EXPORT_DLL bool lpaCoreGetMemoryStatus(LPA_MEMORY_STATUS* prtMemoryStatus);
|
||||
#endif // LPA_SDK__USING_EX_API
|
||||
|
||||
void lpaCoreMemoryDumpStatusIntoLog();
|
||||
void lpaCoreMemoryCheckMemoryAllocated();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // LPA_SDK__CORE_MEMORY_H
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__CORE_RASPBIAN__LPA_CORE_H
|
||||
#define LPA_SDK__CORE_RASPBIAN__LPA_CORE_H
|
||||
|
||||
#ifndef LPA_SDK__PLATFORM_RASPBIAN
|
||||
#error "Incorrect usage of lpasdk/core/raspbian/lpa_core.h (PLATFORM_RASPBIAN not defined)"
|
||||
#endif
|
||||
|
||||
|
||||
#define LPA_MAX_PATH 260 //MAX_PATH
|
||||
#define LPA_PATH_SEPARATOR "/"
|
||||
|
||||
// Declare LPA MACRO & Constant (platform)
|
||||
#define LPA_SDK_INLINE_FUNCTION static inline
|
||||
#define UT_EXPORT_DLL // Nothing specific for this platform
|
||||
|
||||
|
||||
#endif // LPA_SDK__CORE_RASPBIAN__LPA_CORE_H
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__CORE_RAW_DATA_OBJECT_H
|
||||
#define LPA_SDK__CORE_RAW_DATA_OBJECT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lpasdk/core/lpa_core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char* rawData;
|
||||
size_t rawDataSize;
|
||||
}RawDataObject, *PtrRawDataObject;
|
||||
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_allocate();
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_create(const unsigned char* ptrRawData, size_t rawDataSize);
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_createAsLV(const unsigned char* ptrRawData, size_t rawDataSize);
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_createFromBase64(const char* ptrBase64Data, const size_t base64DataSize, const size_t maximumRawdataSize);
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_concat(const RawDataObject* ptrRawDataObject1, const RawDataObject*ptrRawDataObject2);
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_concatRawDataArray(const RawDataObject* ptrRawDataObject1, const unsigned char* ptrRawData2, size_t rawDataSize2);
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_concatPartially(const RawDataObject* ptrRawDataObject1, const RawDataObject*ptrRawDataObject2, size_t offset, size_t length);
|
||||
UT_EXPORT_DLL bool rawDataObject_appendRawDataArray(RawDataObject* ptrRawDataObjectSource, const unsigned char* ptrRawDataAppend, size_t rawDataSizeAppend);
|
||||
|
||||
UT_EXPORT_DLL bool rawDataObject_update(RawDataObject* ptrRawDataObject, const unsigned char* ptrRawData, size_t rawDataSize);
|
||||
UT_EXPORT_DLL void rawDataObject_clear(RawDataObject* ptrRawDataObject);
|
||||
UT_EXPORT_DLL void rawDataObject_free(RawDataObject* ptrRawDataObject);
|
||||
|
||||
// Some macro to help memory cleanup
|
||||
#define ERASE_RAWDATAOBJECT(_ptr) if ((_ptr) != NULL) { rawDataObject_free( (_ptr) ); (_ptr) = NULL;}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // LPA_SDK__CORE_RAW_DATA_OBJECT_H
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__CORE_SEMEDIA_BASE_H
|
||||
#define LPA_SDK__CORE_SEMEDIA_BASE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
#include "lpasdk/api/semedia/semedia.h"
|
||||
|
||||
|
||||
typedef struct TSEMedia
|
||||
{
|
||||
// parameter part
|
||||
/////////////////////////
|
||||
|
||||
void* _childStruct;
|
||||
|
||||
// function part
|
||||
/////////////////////////
|
||||
|
||||
bool (*seMediaEstablishContext) (const struct TSEMedia*);
|
||||
bool (*seMediaReleaseContext) (const struct TSEMedia*);
|
||||
bool (*seMediaIsValidContext) (const struct TSEMedia*);
|
||||
bool (*seMediaIsContextEstablished) (const struct TSEMedia*);
|
||||
|
||||
bool (*seMediaSetCallbackEventExecutionError) (const struct TSEMedia*, LPA_EVENT_EXECUTION_ERROR lpaEventExecutionErrorCallback);
|
||||
|
||||
bool (*seMediaListReader) (const struct TSEMedia*, LPA_SE_MEDIA_READER_NAME_INFO * ptrReaderNameInfoList, size_t readerNameInfoMax, size_t* ptrCountReader);
|
||||
bool (*seMediaConnect) (const struct TSEMedia*, const char *ptrReaderName);
|
||||
bool (*seMediaIsConnected) (const struct TSEMedia*);
|
||||
bool (*seMediaTransmitApdu) (const struct TSEMedia*, const unsigned char* ptrApduCommandBytes, size_t apduCommandSize, unsigned char* ptrApduResponseBytes, size_t* ptrApduResponseMaxSize);
|
||||
bool (*seMediaDisconnect) (const struct TSEMedia*);
|
||||
bool (*seMediaDisconnectWithReset) (const struct TSEMedia*);
|
||||
|
||||
bool (*seMediaGetStatus) (const struct TSEMedia*, SE_MEDIA_CARD_STATUS* ptrStatus);
|
||||
|
||||
} TSEMedia;
|
||||
|
||||
TSEMedia* New_SEMediaBase();
|
||||
|
||||
#endif // LPA_SDK__CORE_SEMEDIA_BASE_H
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__CORE_SEMEDIA_MANAGER_H
|
||||
#define LPA_SDK__CORE_SEMEDIA_MANAGER_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
#include "lpasdk/core/lpa_core.h"
|
||||
#include "lpasdk/core/semedia_base.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
UT_EXPORT_DLL bool seMediaManagerInitialize();
|
||||
UT_EXPORT_DLL bool seMediaManagerIsInitialized();
|
||||
UT_EXPORT_DLL bool seMediaManagerUninitialize();
|
||||
|
||||
UT_EXPORT_DLL bool seMediaManagerSetCallbackEventExecutionError(LPA_EVENT_EXECUTION_ERROR lpaEventExecutionErrorCallback);
|
||||
|
||||
bool seMediaManagerEstablishContext();
|
||||
bool seMediaManagerReleaseContext();
|
||||
|
||||
bool seMediaManagerIsContextEstablished();
|
||||
bool seMediaManagerIsValidContext();
|
||||
|
||||
bool seMediaManagerListReader(LPA_SE_MEDIA_READER_NAME_INFO * readerNameInfoList, size_t readerNameInfoMax, size_t* countReader);
|
||||
bool seMediaManagerIsConnected();
|
||||
bool seMediaManagerConnect(const char* readerName);
|
||||
bool seMediaManagerTransmitApdu(const unsigned char* apduCommandBytes, size_t apduCommandSize, unsigned char* apduResponseBytes, size_t* apduResponseMaxSize);
|
||||
|
||||
bool seMediaManagerDisconnect();
|
||||
bool seMediaManagerDisconnectWithReset();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // LPA_SDK__CORE_SEMEDIA_MANAGER_H
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__CORE_UTIL_H
|
||||
#define LPA_SDK__CORE_UTIL_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int formatBytesToHexaString(const unsigned char *ptrDataBytes, size_t dataSize, char* ptrBuffer, size_t bufferMaxSize);
|
||||
bool writeIntegerValueToByteArray(uint16_t integerValue, unsigned char *ptrByteArray, size_t byteArrayMaxSize, size_t* byteArraySize );
|
||||
bool extractIntegerFromByteArray(const unsigned char *ptrByteArray, size_t byteArraySize, uint16_t* ptrIntegerValue);
|
||||
bool hexStr2ByteArray(const unsigned char * inHexString,int inLen, unsigned char * outHex, int* outLen);
|
||||
bool encodeLength(int length, unsigned char* lengthTLV, const size_t lengthTLVsize, size_t * attributeLength);
|
||||
bool generateLength(int length, unsigned char* lengthHex, const size_t lengthHexsize, size_t * attributeLength);
|
||||
int oneHexCharToHex(char h);
|
||||
bool split(char *src,const char *separator,char **dest,int *num);
|
||||
bool findSubstr(char* source, char* target);
|
||||
int countCharOccurencesInString(const char * pString, const char c);
|
||||
bool isElementPresentInArrayUInt(const unsigned int *pReferenceArray, const size_t pArraySize, const unsigned int pValue);
|
||||
bool isElementPresentInArrayByte(const unsigned char *pReferenceArray, const size_t pArraySize, const unsigned char pValue);
|
||||
bool compareEqualStringIgnoringCase(const char * pString1, const char * pString2);
|
||||
bool convertStringToBoolean(const char* ptrParameterValue, bool *ptrBooleanValue);
|
||||
bool convertStringToLong(const char* ptrParameterValue, long *ptrLongValue);
|
||||
bool convertStringToLower(const char * ptrSourceString, char * ptrDestString, size_t ptrDestStringSize);
|
||||
bool extractOIDfromCertificate(const unsigned char * ptrCertificate, const size_t certificateLength, unsigned char * ptrOID, size_t * ptrOIDsize, const size_t oidSizeMax);
|
||||
bool convertASN1_OIDtoText(const unsigned char * ptrOID, const size_t OIDsize, char * OIDtext, const size_t OIDtextMaxSize);
|
||||
bool parseDataWithVLQnodes(const unsigned char * ptrSource, const size_t sourceLength, unsigned char * ptrExtractData, size_t * ptrExtractDatalength, const size_t extractDataMaxSize);
|
||||
bool decodeVLQvalue(const unsigned char * ptrVLQvalue, const size_t VLQvalueSize, unsigned long long * ptrOutputValue);
|
||||
bool base64_encode(const unsigned char *indata, size_t inlen, char *outdata, size_t *outlen, size_t maxSize);
|
||||
bool base64_decode(const char *indata, size_t inlen, unsigned char *outdata, size_t *outlen, size_t destSize);
|
||||
bool extractBitsSetListInStaticASN1BitString(const unsigned char * ptrASN1BitString, const size_t ASN1BitStringLength, unsigned char * ptrBitsSetList, const size_t maxBitsSetListSize, size_t * ptrNbBitsSetFound);
|
||||
bool checkBitSetInStaticASN1BitString(const unsigned char * ptrASN1BitString, const size_t ASN1BitStringLength, const unsigned char bitToCheck, bool * ptrIsPresent);
|
||||
|
||||
#endif // LPA_SDK__CORE_UTIL_H
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <curl/curl.h>
|
||||
#ifndef HTTPMEDIA_CURL_H
|
||||
#define HTTPMEDIA_CURL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct RespStruct {
|
||||
char *resp;
|
||||
size_t size;
|
||||
} RespStruct;
|
||||
|
||||
typedef struct {
|
||||
// Base part
|
||||
/////////////////////////
|
||||
THTTPMedia* _base;
|
||||
|
||||
// Specific part
|
||||
/////////////////////////
|
||||
CURL *_curl;
|
||||
struct curl_slist *_headers;
|
||||
struct RespStruct _respdata;
|
||||
} THTTPMediaCURL;
|
||||
|
||||
THTTPMedia* New_HTTPMediaCurl();
|
||||
void Delete_HTTPMediaCurl(THTTPMedia* httpMedia);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HTTPMEDIA_CURL_H */
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__DRIVER_SEMEDIA_GENERIC_MODEM_H
|
||||
#define LPA_SDK__DRIVER_SEMEDIA_GENERIC_MODEM_H
|
||||
|
||||
// This driver is compiled only if LPA_SDK__SEMEDIA_DRIVER_GENERIC_MODEM build option exist
|
||||
#ifdef LPA_SDK__SEMEDIA_DRIVER_GENERIC_MODEM
|
||||
|
||||
#if defined(LPA_SDK__PLATFORM_WIN) || defined(LPA_SDK__PLATFORM_CYGWIN) || defined(LPA_SDK__PLATFORM_RASPBIAN)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lpasdk/core/semedia_manager.h"
|
||||
#include "lpasdk/core/semedia_base.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Base part
|
||||
/////////////////////////
|
||||
TSEMedia* _ptrBase;
|
||||
|
||||
// Specific part
|
||||
/////////////////////////
|
||||
#ifdef LPA_SDK__PLATFORM_WIN
|
||||
HANDLE _modemHandle;
|
||||
#else
|
||||
int _modemFD;
|
||||
#endif // LPA_SDK__PLATFORM_WIN
|
||||
|
||||
uint8_t _apduChannel;
|
||||
char _apduChannelString[3];
|
||||
bool _contextEstablished;
|
||||
} TSEMediaGenericModem;
|
||||
|
||||
// Simulate object constructor
|
||||
TSEMedia* New_SEMediaGenericModem();
|
||||
|
||||
// Simulate object destructor
|
||||
void Delete_SEMediaGenericModem(TSEMedia* ptrTSEMedia);
|
||||
|
||||
#endif //def LPA_SDK__PLATFORM_WIN || LPA_SDK__PLATFORM_CYGWIN ||LPA_SDK__PLATFORM_RASPBIAN
|
||||
|
||||
#endif // LPA_SDK__SEMEDIA_DRIVER_GENERIC_MODEM
|
||||
|
||||
#endif // LPA_SDK__DRIVER_SEMEDIA_GENERIC_MODEM_H
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__DRIVER_SEMEDIA_WINSCARD_H
|
||||
#define LPA_SDK__DRIVER_SEMEDIA_WINSCARD_H
|
||||
|
||||
#ifdef LPA_SDK__SEMEDIA_DRIVER_WINSCARD
|
||||
|
||||
#if defined(LPA_SDK__PLATFORM_WIN) || defined(LPA_SDK__PLATFORM_CYGWIN) || defined(LPA_SDK__PLATFORM_RASPBIAN)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef LPA_SDK__PLATFORM_WIN
|
||||
// Only available under Windows platform
|
||||
#include <winscard.h>
|
||||
#else
|
||||
#ifdef LPA_SDK__PLATFORM_CYGWIN
|
||||
// Only available under Cygwin platform
|
||||
#include <w32api/winscard.h>
|
||||
#else // LPA_SDK__PLATFORM_RASPBIAN
|
||||
// Raspbian
|
||||
|
||||
#define TEXT(quote) __TEXT(quote) // r_winnt
|
||||
#define __TEXT(quote) quote // r_winnt
|
||||
// MessageId: ERROR_BROKEN_PIPE
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// The pipe has been ended.
|
||||
//
|
||||
#define ERROR_BROKEN_PIPE 109L
|
||||
#define SCARD_AUTOALLOCATE (DWORD)(-1)
|
||||
#define SCARD_SCOPE_USER 0 // The context is a user context, and any
|
||||
// database operations are performed within the
|
||||
// domain of the user.
|
||||
#define SCARD_SCOPE_TERMINAL 1 // The context is that of the current terminal,
|
||||
// and any database operations are performed
|
||||
// within the domain of that terminal. (The
|
||||
// calling application must have appropriate
|
||||
// access permissions for any database actions.)
|
||||
#define SCARD_SCOPE_SYSTEM 2 // The context is the system context, and any
|
||||
// database operations are performed within the
|
||||
// domain of the system. (The calling
|
||||
// application must have appropriate access
|
||||
// permissions for any database actions.)
|
||||
#define SCARD_ALL_READERS TEXT("SCard$AllReaders\000")
|
||||
#define SCARD_DEFAULT_READERS TEXT("SCard$DefaultReaders\000")
|
||||
#define SCARD_LOCAL_READERS TEXT("SCard$LocalReaders\000")
|
||||
#define SCARD_SYSTEM_READERS TEXT("SCard$SystemReaders\000")
|
||||
|
||||
#include <PCSC/wintypes.h>
|
||||
#include <PCSC/winscard.h>
|
||||
#endif // LPA_SDK__PLATFORM_CYGWIN
|
||||
#endif //LPA_SDK__PLATFORM_WIN
|
||||
|
||||
#include "lpasdk/core/semedia_manager.h"
|
||||
#include "lpasdk/core/semedia_base.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Base part
|
||||
/////////////////////////
|
||||
TSEMedia* _ptrBase;
|
||||
|
||||
// Specific part
|
||||
/////////////////////////
|
||||
SCARDCONTEXT _scardContext;
|
||||
SCARDHANDLE _scardHandle;
|
||||
bool _contextEstablished;
|
||||
uint8_t _apduChannel;
|
||||
|
||||
SE_MEDIA_DISCONNECT_CARD_PARAM _disconnectParam;
|
||||
DWORD _connectSharedMode;
|
||||
|
||||
} TSEMediaWinSCard;
|
||||
|
||||
// Simulate object constructor
|
||||
TSEMedia* New_SEMediaWinSCard();
|
||||
|
||||
// Simulate object destructor
|
||||
void Delete_SEMediaWinSCard(TSEMedia* ptrTSEMedia);
|
||||
|
||||
#endif //def LPA_SDK__PLATFORM_WIN || LPA_SDK__PLATFORM_CYGWIN
|
||||
|
||||
#endif // LPA_SDK__SEMEDIA_DRIVER_WINSCARD
|
||||
|
||||
#endif // LPA_SDK__DRIVER_SEMEDIA_WINSCARD_H
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LPA_SDK__CORE_INTERNAL_API_H
|
||||
#define LPA_SDK__CORE_INTERNAL_API_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
#include "lpasdk/core/rawdata_object.h"
|
||||
#include "lpasdk/core/bertlv_object.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
///////////////////////////////////
|
||||
// MACRO PART
|
||||
///////////////////////////////////
|
||||
|
||||
// Actually not used but can be still useful to free memory not reserved by lpaCoreMemoryAlloc()
|
||||
#define FREEIF(ptr) do{\
|
||||
if(ptr) free(ptr);\
|
||||
ptr=NULL;\
|
||||
}while(0)
|
||||
|
||||
///////////////////////////////////
|
||||
// DEFINE PART
|
||||
///////////////////////////////////
|
||||
|
||||
#define LPA_GET_EUICC_CHALLENGE_MAX_SIZE 30 // Shall not be grater than 23 bytes (Including SW), but keep some margin
|
||||
#define LPA_AUTHENTICATE_SERVER_MAX_SIZE 4500
|
||||
#define LPA_PIR_BUFFER_MAX_SIZE 400
|
||||
|
||||
//max size for the server data
|
||||
#define LPA_TRANSACTION_ID_MAX_SIZE 40 // For both binary and string format
|
||||
#define LPA_INITIAL_AUTHENTICATE_SERVER_SIGNED1_MAX_SIZE 350
|
||||
#define LPA_INITIAL_AUTHENTICATE_SERVER_SIGNATURE1_MAX_SIZE 100
|
||||
#define LPA_INITIAL_AUTHENTICATE_EUICC_CIPKID_TO_BE_USED_MAX_SIZE 40
|
||||
#define LPA_INITIAL_AUTHENTICATE_SERVER_CERTIFICATE_MAX_SIZE 1536
|
||||
#define LPA_AUTHENTICATE_CLIENT_SMDP_CERTIFICATE_MAX_SIZE 1536
|
||||
#define LPA_AUTHENTICATE_CLIENT_SMDP_SIGNATURE2_MAX_SIZE 100
|
||||
#define LPA_AUTHENTICATE_CLIENT_SMDP_SIGNED2_MAX_SIZE 350
|
||||
#define LPA_AUTHENTICATE_CLIENT_PROFILE_METADATA_MAX_SIZE 2048
|
||||
#define LPA_GET_BOUND_PROFILE_MAX_SIZE 135168 // 132 Kb
|
||||
|
||||
#define GET_EUICC_INFO1_DGI_TAG 0xBF20
|
||||
#define GET_EUICC_INFO2_DGI_TAG 0xBF22
|
||||
|
||||
///////////////////////////////////
|
||||
// STRUCTURE PART
|
||||
///////////////////////////////////
|
||||
|
||||
typedef struct LPA_SERVER_DATA {
|
||||
RawDataObject * _transactionId;
|
||||
|
||||
// Initiate Authentication objects
|
||||
RawDataObject * _serverSigned1;
|
||||
RawDataObject * _serverSignature1;
|
||||
RawDataObject * _euiccCiPKIdToBeUsed;
|
||||
RawDataObject * _serverCertificate;
|
||||
|
||||
// Authenticate Client objects
|
||||
RawDataObject * _smdpCertificate;
|
||||
RawDataObject * _smdpSignature2;
|
||||
RawDataObject * _smdpSigned2;
|
||||
RawDataObject * _profileMetadata;
|
||||
|
||||
BerTLVList * _boundProfilePackage;
|
||||
size_t _boundProfilePackageLength;
|
||||
uint8_t _boundProfilePackageContainerCount;
|
||||
} LPA_SERVER_DATA, *ptr_serverData;
|
||||
|
||||
typedef struct {
|
||||
// MatchingId + deviceInfoTLV
|
||||
RawDataObject * ptrAuthenticateServerResponse;
|
||||
RawDataObject * ptrAuthenticateServerResponse_Base64;
|
||||
} AUTHENTICATE_SERVER_RESPONSE;
|
||||
|
||||
typedef struct {
|
||||
// UICC challenge or UICC info
|
||||
RawDataObject * ptrEUICC;
|
||||
RawDataObject * prtEUICC_Base64;
|
||||
} LPA_GET_EUICC;
|
||||
|
||||
typedef struct {
|
||||
RawDataObject * ptrPrepareDownloadResponse;
|
||||
RawDataObject * ptrPrepareDownloadResponse_Base64;
|
||||
} PREPARE_DOWNLOAD_RESPONSE;
|
||||
|
||||
typedef struct {
|
||||
bool hasResult;
|
||||
RawDataObject * ptrProfileInstallationResultTlv;
|
||||
RawDataObject * ptrProfileInstallationResultTlv_Base64;
|
||||
} PROFILE_INSTALLATION_RESULT;
|
||||
|
||||
// PPR ASN1 bitstring values (PprIds object)
|
||||
// Note: PPRUC means PprUpdateControl bit defined in PprIds ASN1 object and related to ES6 features
|
||||
typedef enum
|
||||
{
|
||||
LPA_PPRDEF_PPR2 = 0x0520,
|
||||
LPA_PPRDEF_PPR1_PPR2 = 0x0560,
|
||||
LPA_PPRDEF_PPRUC_PPR2 = 0x05A0,
|
||||
LPA_PPRDEF_PPRUC_PPR1_PPR2 = 0x05E0,
|
||||
LPA_PPRDEF_PPR1 = 0x0640,
|
||||
LPA_PPRDEF_PPRUC_PPR1 = 0x06C0,
|
||||
LPA_PPRDEF_PPRUC = 0x0780
|
||||
}LPA_PPR_ASN1_BIT_STRING_VALUES;
|
||||
|
||||
// Fields extracted from profile Metadata for PPR check
|
||||
#define LPA_GID_MAX_SIZE 10 // TBC if bigger size can be encountered. Not fixed in 31.102. Saw at 4 bytes in SGP.23 examples.
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int profilePPR; // Will store ASN1 coding of profile PPR. If value = 0 No PPR in profile
|
||||
bool hasPPR1; // True if PPR1 is enabled
|
||||
bool hasPPR2; // True if PPR2 is enabled
|
||||
unsigned char mccMnc[3];
|
||||
unsigned char gid1[LPA_GID_MAX_SIZE];
|
||||
size_t gid1Size;
|
||||
bool gid1Defined; // Allow to know if field exists, even if length = 0 (Used in PPR conditions)
|
||||
unsigned char gid2[LPA_GID_MAX_SIZE];
|
||||
size_t gid2Size;
|
||||
bool gid2Defined; // Allow to know if field exists, even if length = 0 (Used in PPR conditions)
|
||||
char profileName[LPA_PROFILE_NAME_MAX_SIZE + 2]; // Profile name that may be displayed to user. String coded. +1 byte for EOS, +1 byte for security
|
||||
unsigned char userCallBackType; // Set information(s) to display to user. Values masks defined in LPA_USER_CONSENT_TYPES enum. Each bit set an info.
|
||||
bool performCancelSession; // If true download is not allowed (PPR1 vs profile, RAT...) and Cancel Session will be performed
|
||||
unsigned int cancelSessionReason; // Values defined in LPA_CANCEL_SESSION_REASON enum. Value has no importance while performCancelSession is not set
|
||||
}LPA_DOWNLOADED_PROFILE_DATA_FOR_PPR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char iccid[LPA_PROFILE_ICCID_BUFFER_MAX_SIZE];
|
||||
size_t iccidSize;
|
||||
|
||||
unsigned char profileState[LPA_PROFILE_STATE_MAX_SIZE];
|
||||
size_t profileStateSize;
|
||||
|
||||
unsigned char profileClass[LPA_PROFILE_CLASS_MAX_SIZE];
|
||||
size_t profileClassSize;
|
||||
|
||||
unsigned char profilePolicyRules[LPA_PROFILE_POLICY_RULES_MAX_SIZE];
|
||||
size_t profilePolicyRulesSize;
|
||||
}LPA_PROFILE_INFO_FOR_PPR;
|
||||
|
||||
/*
|
||||
Maximum profile info size retrieved from eUICC for PPR (Max length used):
|
||||
Tag/size bytes + max data lengths
|
||||
Header tag E3 5 bytes
|
||||
iccid tag 5A 2 + 10 = 12 bytes
|
||||
profileState tag 9F70 3 + 1 = 4 bytes
|
||||
profileClass tag 95 2 + 1 = 3 bytes
|
||||
profilePolicyRules tag 99 2 + 2 = 4 bytes
|
||||
|
||||
TOTAL -------------------------------------- 28 bytes - Set at 30 for rounding / security
|
||||
*/
|
||||
#define LPA_PROFILE_INFO_BUFFER_MAX_SIZE_FOR_PPR 30 // Size of profile raw data for PPR request
|
||||
|
||||
#define LPA_RAT_MAXIMUM_SIZE 1024 // Arbitrary fixed to 1024 bytes
|
||||
|
||||
// Structure used for PPR analysis, one for each PPR
|
||||
typedef struct
|
||||
{
|
||||
bool pprValidated; // If true, means this PPR has been validated one time
|
||||
int matchLevelMCC_MNC; // Match level for MCC / MNC digits: From 0 (Most generic) to 6 (Most accurate). Most accurate = Highest priority
|
||||
bool matchedGID1; // If true an exact matching has been found for GID1 (Same or not defined). Has most priority than wildcard (Defined in rule with L = 0).
|
||||
bool matchedGID2; // If true an exact matching has been found for GID2 (Same or not defined). Has most priority than wildcard (Defined in rule with L = 0).
|
||||
int matchLevelGID; // Match level for GID: From 0 (No match, both accepted in rule with L = 0) to 2 (Both same value or not defined).
|
||||
bool userConsentRequired; // If true user consent is required. Has most priority than no consent required
|
||||
}LPA_PPR_RAT_ANALYSIS_FLAGS;
|
||||
|
||||
///////////////////////////////////
|
||||
// FUNCTION PART
|
||||
///////////////////////////////////
|
||||
void lpaResetErrorCode();
|
||||
LPA_API_ERROR lpaGetErrorCodeNoClear();
|
||||
bool lpaIsError();
|
||||
void lpaSetErrorCode(LPA_API_ERROR errorCode);
|
||||
void lpaWriteErrorMessageOnLog(LPA_API_ERROR errorCode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif // LPA_SDK__CORE_API_H
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LPA_SDK__VERSION_H
|
||||
#define LPA_SDK__VERSION_H
|
||||
|
||||
#define LPA_SDK_VERSION_MAJOR 1
|
||||
#define LPA_SDK_VERSION_MINOR 8
|
||||
#define LPA_SDK_VERSION_PATCH 0
|
||||
#define LPA_SDK_VERSION_BUILD 1 // 0 For a dev version (dev branch)
|
||||
|
||||
// Must be lower than 64 bytes
|
||||
#define LPA_SDK_EXTRA_VERSION "1.8.0-Build01"
|
||||
|
||||
#endif // LPA_SDK__VERSION_H
|
|
@ -0,0 +1,31 @@
|
|||
// Source code from https://github.com/amosnier/sha-2
|
||||
// License : https://github.com/amosnier/sha-2/blob/master/LICENSE
|
||||
|
||||
/*
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org>
|
||||
*/
|
||||
|
||||
void calc_sha_256(uint8_t hash[32], const void *input, size_t len);
|
|
@ -0,0 +1,693 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lpasdk/core/bertlv_object.h"
|
||||
#include "lpasdk/core/lpa_memory.h"
|
||||
#include "lpasdk/core/lpa_log.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
//#include <memory.h>
|
||||
|
||||
void _berTLV_freeRawDataBuffer(unsigned char* ptrRawData);
|
||||
unsigned char* _berTLV_createRawDataBuffer(const BeerTLV* ptrBerTlv, size_t* ptrRawDataSize);
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Build BERTLV object (BeerTLV type) from raw data field, but only if specified Tag is found and its structure seems correct
|
||||
* @param tag TLV tag to be found, uint8_t format
|
||||
* @param ptrRawData Raw data field to analyze, bytes format
|
||||
* @param rawDataSize Size of given raw data field
|
||||
* @param ptrIsTagFound Boolean flag address, will be set to True if tag found and object has correct structure. If address = NULL will be ignored / not updated
|
||||
* @return Pointer on BERTLV object (BeerTLV type) extracted from raw data bytes field.
|
||||
*/
|
||||
UT_EXPORT_DLL BeerTLV* berTLV_extractTagUInt8(uint8_t tag, const unsigned char* ptrRawData, uint32_t rawDataSize, bool* ptrIsTagFound)
|
||||
{
|
||||
BeerTLV* berTLV = NULL;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "berTLV_extractTagUInt8(0x%02X,...)", tag);
|
||||
|
||||
if (ptrRawData != NULL && rawDataSize >= 2)
|
||||
{
|
||||
uint16_t tag16 = (uint16_t)tag & 0x00FF;
|
||||
berTLV = berTLV_extractTagUInt16(tag16, ptrRawData, rawDataSize, ptrIsTagFound);
|
||||
}
|
||||
|
||||
return berTLV;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Build BERTLV object (BeerTLV type) from raw data field, but only if specified Tag is found and its structure seems correct
|
||||
* @param tag TLV tag to be found, uint16_t format
|
||||
* @param ptrRawData Raw data field to analyze, bytes format
|
||||
* @param rawDataSize Size of given raw data field
|
||||
* @param ptrIsTagFound Boolean flag address, will be set to True if tag found and object has correct structure. If address = NULL will be ignored / not updated
|
||||
* @return Pointer on BERTLV object (BeerTLV type) extracted from raw data bytes field.
|
||||
*/
|
||||
UT_EXPORT_DLL BeerTLV* berTLV_extractTagUInt16(uint16_t tag, const unsigned char* ptrRawData, uint32_t rawDataSize, bool* ptrIsTagFound)
|
||||
{
|
||||
BeerTLV* berTLV = NULL;
|
||||
bool isTagFound = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "berTLV_extractTagUInt16(0x%04X,...)", tag);
|
||||
|
||||
// ptrIsTagFound is now optionnal
|
||||
if (ptrRawData != NULL && rawDataSize >= 2)
|
||||
{
|
||||
size_t offsetRawData = 0;
|
||||
uint16_t currentTag = 0x00;
|
||||
uint32_t currentLength = 0x00;
|
||||
bool invalidRawData = false;
|
||||
|
||||
while ((isTagFound == false) && (!invalidRawData) && (offsetRawData < rawDataSize))
|
||||
{
|
||||
currentTag = 0x00;
|
||||
currentLength = 0x00;
|
||||
|
||||
// Read Tag
|
||||
////////////////////
|
||||
|
||||
currentTag = ptrRawData[offsetRawData];
|
||||
if (currentTag == 0xFF || currentTag == 0x9F || currentTag == 0xdf || currentTag == 0x5f || currentTag == 0xbf)
|
||||
{
|
||||
// Tag size: 2 bytes
|
||||
if ((offsetRawData + 1) < rawDataSize)
|
||||
{
|
||||
currentTag <<= 8;
|
||||
currentTag |= ptrRawData[offsetRawData + 1];
|
||||
|
||||
offsetRawData += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
invalidRawData = true;
|
||||
break; // Incorrect <Tag> size
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Tag size: 1 byte
|
||||
offsetRawData += 1;
|
||||
}
|
||||
|
||||
if (invalidRawData)
|
||||
break;
|
||||
|
||||
// Read <Length>
|
||||
////////////////////
|
||||
if (offsetRawData < rawDataSize)
|
||||
{
|
||||
if (ptrRawData[offsetRawData] <= 0x7F)
|
||||
{
|
||||
currentLength = ptrRawData[offsetRawData];
|
||||
offsetRawData++;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (ptrRawData[offsetRawData])
|
||||
{
|
||||
case 0x81:
|
||||
{
|
||||
if (offsetRawData + 1 < rawDataSize)
|
||||
{
|
||||
currentLength = ptrRawData[offsetRawData + 1];
|
||||
offsetRawData += 2;
|
||||
}
|
||||
else
|
||||
invalidRawData = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x82:
|
||||
{
|
||||
if (offsetRawData + 2 < rawDataSize)
|
||||
{
|
||||
currentLength = (ptrRawData[offsetRawData+1] << 8) | ptrRawData[offsetRawData + 2];
|
||||
offsetRawData += 3;
|
||||
}
|
||||
else
|
||||
invalidRawData = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x83:
|
||||
{
|
||||
if (offsetRawData + 3 < rawDataSize)
|
||||
{
|
||||
currentLength = (ptrRawData[offsetRawData + 1] << 16) | (ptrRawData[offsetRawData + 2] << 8) | ptrRawData[offsetRawData + 3] ;
|
||||
offsetRawData += 4;
|
||||
}
|
||||
else
|
||||
invalidRawData = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
invalidRawData = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
invalidRawData = true;
|
||||
break; // Incorrect <Length> size
|
||||
}
|
||||
|
||||
if (invalidRawData)
|
||||
break;
|
||||
|
||||
// check if Tag expected
|
||||
if (currentTag == tag)
|
||||
{
|
||||
// Tag is found
|
||||
isTagFound = true;
|
||||
|
||||
if (offsetRawData + currentLength <= rawDataSize)
|
||||
berTLV = berTLV_create(tag, currentLength, &ptrRawData[offsetRawData]);
|
||||
else
|
||||
invalidRawData = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No correct tag => go to next tag
|
||||
offsetRawData += currentLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update ptrIsTagFound if defined
|
||||
if (ptrIsTagFound != NULL)
|
||||
(*ptrIsTagFound) = isTagFound;
|
||||
|
||||
return berTLV;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Extract BERTLV objects list (At same encapsulation level) from raw bytes field.
|
||||
* This list is a chained list, next list element is another BerTLVList object that can be reached by "ptrNext" attribute
|
||||
* Warning: Keep pointer of first element to be able to free generated list from memory
|
||||
* @param ptrRawData Raw data field to analyze, bytes format
|
||||
* @param rawDataSize Size of given raw data field
|
||||
* @param ptrCountTLVFound Return number of TLV objects found at this level
|
||||
* @return First element of BERTLV objects list, BerTLVList format
|
||||
*/
|
||||
UT_EXPORT_DLL BerTLVList* berTLV_extractList(const unsigned char* ptrRawData, uint32_t rawDataSize, uint8_t* ptrCountTLVFound)
|
||||
{
|
||||
BerTLVList* berTLVFirstElement = NULL;
|
||||
BerTLVList* berTLVLastElement = NULL;
|
||||
uint8_t countTLVFound = 0;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "berTLV_extractList(...)");
|
||||
|
||||
if (ptrRawData != NULL && rawDataSize >= 2)
|
||||
{
|
||||
size_t offsetRawData = 0;
|
||||
uint16_t currentTag = 0x00;
|
||||
uint32_t currentLength = 0x00;
|
||||
bool invalidRawData = false;
|
||||
|
||||
while ( (!invalidRawData) && (offsetRawData < rawDataSize))
|
||||
{
|
||||
currentTag = 0x00;
|
||||
currentLength = 0x00;
|
||||
|
||||
// Read Tag
|
||||
////////////////////
|
||||
|
||||
currentTag = ptrRawData[offsetRawData];
|
||||
if (currentTag == 0xFF || currentTag == 0x9F || currentTag == 0xdf || currentTag == 0x5f || currentTag == 0xbf)
|
||||
{
|
||||
// Tag size: 2 bytes
|
||||
if ((offsetRawData + 1) < rawDataSize)
|
||||
{
|
||||
currentTag <<= 8;
|
||||
currentTag |= ptrRawData[offsetRawData + 1];
|
||||
|
||||
offsetRawData += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
invalidRawData = true;
|
||||
break; // Incorrect <Tag> size
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Tag size: 1 byte
|
||||
offsetRawData += 1;
|
||||
}
|
||||
|
||||
if (invalidRawData)
|
||||
break;
|
||||
|
||||
// Read <Length>
|
||||
////////////////////
|
||||
if (offsetRawData < rawDataSize)
|
||||
{
|
||||
if (ptrRawData[offsetRawData] <= 0x7F)
|
||||
{
|
||||
currentLength = ptrRawData[offsetRawData];
|
||||
offsetRawData++;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (ptrRawData[offsetRawData])
|
||||
{
|
||||
case 0x81:
|
||||
if (offsetRawData + 1 < rawDataSize)
|
||||
{
|
||||
currentLength = ptrRawData[offsetRawData+1];
|
||||
offsetRawData += 2;
|
||||
}
|
||||
else
|
||||
invalidRawData = true;
|
||||
break;
|
||||
|
||||
case 0x82:
|
||||
if (offsetRawData + 2 < rawDataSize)
|
||||
{
|
||||
currentLength = (ptrRawData[offsetRawData+1] << 8) | ptrRawData[offsetRawData+2];
|
||||
offsetRawData += 3;
|
||||
}
|
||||
else
|
||||
invalidRawData = true;
|
||||
break;
|
||||
|
||||
case 0x83:
|
||||
{
|
||||
if (offsetRawData + 3 < rawDataSize)
|
||||
{
|
||||
currentLength = (ptrRawData[offsetRawData + 1] << 16) | (ptrRawData[offsetRawData + 2] << 8) | ptrRawData[offsetRawData + 3];
|
||||
offsetRawData += 4;
|
||||
}
|
||||
else
|
||||
invalidRawData = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
invalidRawData = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
invalidRawData = true;
|
||||
break; // Incorrect <Length> size
|
||||
}
|
||||
|
||||
if (invalidRawData)
|
||||
break;
|
||||
|
||||
// create TLV item
|
||||
BerTLVList* ptrBerTLVList = lpaCoreMemoryAlloc(sizeof(BerTLVList));
|
||||
if (ptrBerTLVList != NULL)
|
||||
{
|
||||
memset(ptrBerTLVList, 0x00, sizeof(BerTLVList));
|
||||
|
||||
ptrBerTLVList->index = countTLVFound;
|
||||
ptrBerTLVList->berTLV = berTLV_create(currentTag, currentLength, &ptrRawData[offsetRawData]);
|
||||
ptrBerTLVList->ptrNext = NULL;
|
||||
|
||||
if (ptrBerTLVList->berTLV != NULL)
|
||||
{
|
||||
// Add it to the list
|
||||
if (berTLVFirstElement == NULL)
|
||||
berTLVFirstElement = berTLVLastElement = ptrBerTLVList;
|
||||
else
|
||||
{
|
||||
berTLVLastElement->ptrNext = ptrBerTLVList;
|
||||
berTLVLastElement = ptrBerTLVList;
|
||||
}
|
||||
|
||||
countTLVFound++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Memory issue => release list created, release new item and return NULL
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "berTLV_extractList(...) => memory issue!");
|
||||
if (berTLVFirstElement != NULL)
|
||||
{
|
||||
berTLV_freeBerTLVList(berTLVFirstElement);
|
||||
berTLVFirstElement = NULL;
|
||||
}
|
||||
|
||||
lpaCoreMemoryFree(ptrBerTLVList);
|
||||
ptrBerTLVList = NULL;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Memory issue => clear list created and return NULL
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "berTLV_extractList(...) => memory issue!");
|
||||
if (berTLVFirstElement != NULL)
|
||||
{
|
||||
berTLV_freeBerTLVList(berTLVFirstElement);
|
||||
berTLVFirstElement = NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// go to next tag
|
||||
offsetRawData += currentLength;
|
||||
}
|
||||
}
|
||||
|
||||
if (ptrCountTLVFound != NULL)
|
||||
*ptrCountTLVFound = countTLVFound;
|
||||
|
||||
return berTLVFirstElement;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Free BERTLV object (BeerTLV) from memory
|
||||
* @param ptrBerTLV Pointer on BeerTLV object to free
|
||||
* @return
|
||||
*/
|
||||
UT_EXPORT_DLL bool berTLV_freeBerTLV(BeerTLV* ptrBerTLV)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "berTLV_freeBerTLV(...)" );
|
||||
|
||||
if (ptrBerTLV != NULL)
|
||||
{
|
||||
if (ptrBerTLV->value != NULL)
|
||||
{
|
||||
lpaCoreMemoryFree(ptrBerTLV->value);
|
||||
}
|
||||
lpaCoreMemoryFree(ptrBerTLV);
|
||||
ptrBerTLV = NULL;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Free BERTLV list object (BerTLVList) from memory
|
||||
* @param ptrBerTLVList Pointer on first element of the BERTLV list to free
|
||||
* @return
|
||||
*/
|
||||
UT_EXPORT_DLL bool berTLV_freeBerTLVList(BerTLVList* ptrBerTLVList)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "berTLV_freeBerTLVList(...)");
|
||||
|
||||
if (ptrBerTLVList != NULL)
|
||||
{
|
||||
BerTLVList* ptrCurrentBerTLVList = ptrBerTLVList;
|
||||
while (ptrCurrentBerTLVList != NULL)
|
||||
{
|
||||
BerTLVList* ptrNextBertTLVList = ptrCurrentBerTLVList->ptrNext;
|
||||
if (ptrCurrentBerTLVList->berTLV != NULL)
|
||||
{
|
||||
berTLV_freeBerTLV(ptrCurrentBerTLVList->berTLV);
|
||||
ptrCurrentBerTLVList->berTLV = NULL;
|
||||
}
|
||||
lpaCoreMemoryFree(ptrCurrentBerTLVList);
|
||||
ptrCurrentBerTLVList = ptrNextBertTLVList;
|
||||
}
|
||||
|
||||
ptrBerTLVList = NULL;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Create BERTLV object from separate elements (Tag, size and data)
|
||||
* @param tag Tag of BERTLV object, uint16_t format
|
||||
* @param length Length of BERTLV, uint32_t format
|
||||
* @param ptrValue Data to be stored in BERTLV object, char array
|
||||
* @return Pointer on created BERTLV object, else NULL if failed
|
||||
*/
|
||||
UT_EXPORT_DLL BeerTLV* berTLV_create(uint16_t tag, uint32_t length, const unsigned char* ptrValue)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "berTLV_create(tag:0x%04X)", tag);
|
||||
|
||||
BeerTLV* ptrBerTLV = lpaCoreMemoryAlloc(sizeof(BeerTLV));
|
||||
if (ptrBerTLV != NULL)
|
||||
{
|
||||
memset(ptrBerTLV, 0x00, sizeof(BeerTLV));
|
||||
|
||||
ptrBerTLV->tag = tag;
|
||||
ptrBerTLV->length = 0;
|
||||
ptrBerTLV->value = NULL;
|
||||
|
||||
if (length > 0 && ptrValue != NULL )
|
||||
{
|
||||
ptrBerTLV->value = lpaCoreMemoryAlloc(length);
|
||||
if (ptrBerTLV->value != NULL)
|
||||
{
|
||||
memcpy(ptrBerTLV->value, ptrValue, length);
|
||||
ptrBerTLV->length = length;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If no memory for data, ptrBerTLV must be NULL (and release allocated memory)
|
||||
lpaCoreMemoryFree(ptrBerTLV);
|
||||
ptrBerTLV = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ptrBerTLV;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Will create a raw data array storing image (Tag, encoded length and data) of BERTLV object stored in a BeerTLV variable / object
|
||||
* @param ptrBerTlv Pointer on BERTLV variable / object to store, BeerTLV type
|
||||
* @param ptrRawDataSize Will store size of array storing BERTLV object image, size_t type
|
||||
* @return Pointer on raw data array storing BERTLV image, else NULL if failed
|
||||
*/
|
||||
unsigned char* _berTLV_createRawDataBuffer(const BeerTLV* ptrBerTlv, size_t* ptrRawDataSize)
|
||||
{
|
||||
unsigned char* ptrRawData = NULL;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "_berTLV_createRawDataBuffer(...)");
|
||||
|
||||
if (ptrRawDataSize != NULL && ptrBerTlv != NULL)
|
||||
{
|
||||
*ptrRawDataSize = 0; // default raw data size
|
||||
|
||||
uint32_t tlvTagSize = 0;
|
||||
uint32_t tlvLengthSize = 0;
|
||||
uint32_t tlvDataSize = 0;
|
||||
uint32_t tlvTotalSize = 0;
|
||||
|
||||
// detect tag size
|
||||
tlvTagSize = ((ptrBerTlv->tag & 0xFF00) != 0x00) ? 2 : 1;
|
||||
tlvLengthSize = ptrBerTlv->length <= 0x7F ? 1 : (ptrBerTlv->length <= 0xFF ? 2 : (ptrBerTlv->length <= 0xFFFF ? 3 : 4 ) );
|
||||
tlvDataSize = ptrBerTlv->length;
|
||||
|
||||
tlvTotalSize = tlvTagSize + tlvLengthSize + tlvDataSize;
|
||||
|
||||
// Allocate buffer
|
||||
if (tlvTotalSize > 0)
|
||||
{
|
||||
size_t offestRawData = 0;
|
||||
ptrRawData = lpaCoreMemoryAlloc(tlvTotalSize);
|
||||
if (ptrRawData != NULL)
|
||||
{
|
||||
switch (tlvTagSize)
|
||||
{
|
||||
case 1:
|
||||
ptrRawData[offestRawData] = ptrBerTlv->tag & 0xFF;
|
||||
offestRawData++;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
ptrRawData[offestRawData] = (ptrBerTlv->tag >> 8) & 0xFF;
|
||||
offestRawData++;
|
||||
|
||||
ptrRawData[offestRawData] = ptrBerTlv->tag & 0x00FF;
|
||||
offestRawData++;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (tlvLengthSize)
|
||||
{
|
||||
case 1:
|
||||
ptrRawData[offestRawData] = (unsigned char) ptrBerTlv->length;
|
||||
offestRawData++;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
ptrRawData[offestRawData] = 0x81;
|
||||
offestRawData++;
|
||||
|
||||
ptrRawData[offestRawData] = (unsigned char) ptrBerTlv->length;
|
||||
offestRawData++;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
ptrRawData[offestRawData] = 0x82;
|
||||
offestRawData++;
|
||||
|
||||
ptrRawData[offestRawData] = (ptrBerTlv->length >> 8) & 0xFF;
|
||||
offestRawData++;
|
||||
|
||||
ptrRawData[offestRawData] = ptrBerTlv->length & 0x00FF;
|
||||
offestRawData++;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
ptrRawData[offestRawData] = 0x83;
|
||||
offestRawData++;
|
||||
|
||||
ptrRawData[offestRawData] = (ptrBerTlv->length >> 16) & 0xFF;
|
||||
offestRawData++;
|
||||
|
||||
ptrRawData[offestRawData] = (ptrBerTlv->length >> 8) & 0xFF;
|
||||
offestRawData++;
|
||||
|
||||
ptrRawData[offestRawData] = ptrBerTlv->length & 0x00FF;
|
||||
offestRawData++;
|
||||
break;
|
||||
}
|
||||
|
||||
// And now, add TLV Value part
|
||||
if (tlvDataSize > 0)
|
||||
memcpy(&ptrRawData[offestRawData], ptrBerTlv->value, tlvDataSize);
|
||||
|
||||
*ptrRawDataSize = tlvTotalSize;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ptrRawData;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Free BERTLV raw data array image created by _berTLV_createRawDataBuffer()
|
||||
* @param ptrRawData
|
||||
*/
|
||||
void _berTLV_freeRawDataBuffer(unsigned char* ptrRawData)
|
||||
{
|
||||
if (ptrRawData != NULL)
|
||||
{
|
||||
lpaCoreMemoryFree(ptrRawData);
|
||||
ptrRawData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Build a TLV object in a raw data data chain (RawDataObject type)
|
||||
* @param tag Tag of TLV object
|
||||
* @param length Length of TLV object
|
||||
* @param ptrValue Value of TLV object
|
||||
* @return TLV object raw data in RawDataObject type
|
||||
*/
|
||||
RawDataObject* berTLV_createAndBuildRawDataObject(uint16_t tag, uint32_t length, const unsigned char* ptrValue)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "berTLV_createAndBuildRawDataObject(...)");
|
||||
|
||||
RawDataObject* ptrRawDataObject = NULL;
|
||||
BeerTLV* ptrBerTLV = berTLV_create(tag, length, ptrValue);
|
||||
if (ptrBerTLV != NULL)
|
||||
{
|
||||
ptrRawDataObject = berTLV_buildRawDataObject(ptrBerTLV);
|
||||
berTLV_freeBerTLV(ptrBerTLV);
|
||||
ptrBerTLV = NULL;
|
||||
}
|
||||
|
||||
return ptrRawDataObject;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Create raw data image of BERTLV object (BeerTLV type) and store it in a RawDataObject object
|
||||
* @param ptrBerTlv Pointer on BERTLV variable / object to store, BeerTLV type
|
||||
* @return Pointer on RawDataObject storing raw data image of BeerTLV object, else NULL if failed
|
||||
*/
|
||||
UT_EXPORT_DLL RawDataObject* berTLV_buildRawDataObject(const BeerTLV* ptrBerTlv)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "berTLV_buildRawDataObject(...)");
|
||||
|
||||
RawDataObject* ptrRawDataObject = NULL;
|
||||
if (ptrBerTlv != NULL)
|
||||
{
|
||||
ptrRawDataObject = rawDataObject_allocate();
|
||||
if (ptrRawDataObject != NULL)
|
||||
{
|
||||
size_t rawDataSize = 0;
|
||||
ptrRawDataObject->rawData = _berTLV_createRawDataBuffer(ptrBerTlv, &rawDataSize);
|
||||
if (ptrRawDataObject->rawData != NULL)
|
||||
{
|
||||
ptrRawDataObject->rawDataSize = rawDataSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Memory allocation issue => release ptrRawDataObject and return NULL
|
||||
rawDataObject_free(ptrRawDataObject);
|
||||
ptrRawDataObject = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ptrRawDataObject;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lpasdk/core/lpa_memory.h"
|
||||
#include "lpasdk/core/httpmedia_base.h"
|
||||
#include "lpasdk/core/lpa_log.h"
|
||||
|
||||
THTTPMedia* New_HTTPMediaBase()
|
||||
{
|
||||
THTTPMedia* ptrHttpMediaBase = NULL;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "++New_HTTPMediaBase");
|
||||
|
||||
ptrHttpMediaBase = lpaCoreMemoryAlloc(sizeof(THTTPMedia));
|
||||
|
||||
if(ptrHttpMediaBase != NULL)
|
||||
memset(ptrHttpMediaBase, 0, sizeof(THTTPMedia));
|
||||
|
||||
return ptrHttpMediaBase;
|
||||
}
|
|
@ -0,0 +1,244 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "curl/curl.h"
|
||||
|
||||
#include "lpasdk/core/httpmedia_base.h"
|
||||
#include "lpasdk/core/httpmedia_manager.h"
|
||||
#include "lpasdk/driver/httpmedia_curl.h"
|
||||
#include "lpasdk/core/lpa_log.h"
|
||||
#include "lpasdk/core/lpa_memory.h"
|
||||
|
||||
|
||||
static THTTPMedia* _httpMedia = NULL;
|
||||
|
||||
UT_EXPORT_DLL bool httpMediaManagerInitialize()
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpMediaManagerInitialize()");
|
||||
|
||||
if (_httpMedia == NULL)
|
||||
{
|
||||
_httpMedia = New_HTTPMediaCurl();
|
||||
if (_httpMedia != NULL )
|
||||
res = true;
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "httpMediaManagerInitialize(): Unable to create _httpMedia!");
|
||||
}
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "-httpMediaManagerInitialize()");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool httpMediaManagerIsInitialized()
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpMediaManagerIsInitialized()");
|
||||
|
||||
return (_httpMedia != NULL);
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool httpMediaManagerDelete()
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpMediaManagerDelete()");
|
||||
|
||||
if (_httpMedia != NULL)
|
||||
{
|
||||
Delete_HTTPMediaCurl(_httpMedia);
|
||||
_httpMedia = NULL;
|
||||
res = true;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool httpMediaManagerSetBooleanOption(HttpMediaOptionType optionType, bool enabled)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpMediaManagerSetBooleanOption()");
|
||||
|
||||
if (_httpMedia != NULL) {
|
||||
res = _httpMedia->httpMediaSetBooleanOption(_httpMedia, optionType, enabled);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "_httpMedia is not created!");
|
||||
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "-- httpMediaManagerSetBooleanOption() return %s", (res ? "true" : "false"));
|
||||
return res;
|
||||
}
|
||||
|
||||
bool httpMediaManagerGetBooleanOption(HttpMediaOptionType optionType, bool* ptrEnabled)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpMediaManagerGetBooleanOption()");
|
||||
|
||||
if (_httpMedia != NULL && ptrEnabled != NULL) {
|
||||
res = _httpMedia->httpMediaGetBooleanOption(_httpMedia, optionType, ptrEnabled);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "_httpMedia is not created!");
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "-- httpMediaManagerGetBooleanOption() return %s", (res ? "true" : "false"));
|
||||
return res;
|
||||
}
|
||||
|
||||
bool httpMediaManagerSetLongOption(HttpMediaOptionType optionType, long value)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpMediaManagerSetLongOption()");
|
||||
|
||||
if (_httpMedia != NULL)
|
||||
{
|
||||
res = _httpMedia->httpMediaSetLongOption(_httpMedia, optionType, value);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "_httpMedia is not created!");
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "-- httpMediaManagerSetLongOption() return %s", (res ? "true" : "false"));
|
||||
return res;
|
||||
}
|
||||
|
||||
bool httpMediaManagerGetLongOption(HttpMediaOptionType optionType, long* ptrValue)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpMediaManagerGetLongOption()");
|
||||
|
||||
if (_httpMedia != NULL) {
|
||||
|
||||
if(ptrValue != NULL )
|
||||
res = _httpMedia->httpMediaGetLongOption(_httpMedia, optionType, ptrValue);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "_httpMedia is not created!");
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "-- httpMediaManagerGetLongOption() return %s", (res ? "true" : "false"));
|
||||
return res;
|
||||
}
|
||||
|
||||
bool httpMediaManagerSetCallbackEventExecutionError(LPA_EVENT_EXECUTION_ERROR lpaEventExecutionErrorCallback)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpMediaManagerSetCallbackEventExecutionError()");
|
||||
|
||||
if (_httpMedia != NULL )
|
||||
res = _httpMedia->httpMediaSetCallbackEventExecutionError(_httpMedia, lpaEventExecutionErrorCallback);
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "_httpMedia is not created!");
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "-- httpMediaManagerSetCallbackEventExecutionError() return %s", (res ? "true" : "false"));
|
||||
return res;
|
||||
}
|
||||
|
||||
char* httpMediaManagerPost(const char* ptrCertificatePath, const char* ptrTargetURL, const char* ptrPostdata, bool* ptrIsSuccess, long* ptrHttpCode)
|
||||
{
|
||||
char* resp = NULL;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpMediaManagerPost()");
|
||||
if (_httpMedia != NULL )
|
||||
{
|
||||
if( ptrIsSuccess != NULL && ptrCertificatePath != NULL && ptrTargetURL != NULL && ptrPostdata != NULL && ptrHttpCode != NULL)
|
||||
{
|
||||
*ptrIsSuccess = false;
|
||||
|
||||
bool res = _httpMedia->httpMediaPost(_httpMedia, ptrCertificatePath, ptrTargetURL, ptrPostdata, ptrHttpCode);
|
||||
if (res)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "httpMediaPost() execute success");
|
||||
|
||||
// Check Http Code
|
||||
int httpCode = *ptrHttpCode;
|
||||
|
||||
if (httpCode >= 200 && httpCode < 300)
|
||||
{
|
||||
if (httpCode == 204)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "HTTP Code 204 => no data expected (calling httpMediaGetBufferResponse() is ignored)");
|
||||
*ptrIsSuccess = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
resp = _httpMedia->httpMediaGetBufferResponse(_httpMedia);
|
||||
if (resp != NULL)
|
||||
*ptrIsSuccess = true;
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "httpMediaGetBufferResponse() return NULL");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not a 2XX code , normally no data available
|
||||
*ptrIsSuccess = true;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "Not HTTP Code 2xx => data not managed (if present)");
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "httpMediaPost() failed");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Invalid parameter");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "_httpMedia is not created!");
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "-- httpMediaManagerHTTPExecutePost() return res %s", (resp != NULL ? "not NULL" : "NULL"));
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool httpMediaManagerHttpExecuteInit() {
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpMediaManagerHttpExecuteInit()");
|
||||
|
||||
if (_httpMedia != NULL) {
|
||||
res = _httpMedia->httpMediaHttpExecuteInit(_httpMedia);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "_httpMedia is not created!");
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "-- httpMediaManagerHttpExecuteInit() return %s", (res ? "true" : "false"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool httpMediaManagerHttpExecuteCleanup()
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpMediaHttpExecuteCleanup()");
|
||||
bool res = false;
|
||||
|
||||
if (_httpMedia != NULL) {
|
||||
_httpMedia->httpMediaHttpExecuteCleanup(_httpMedia);
|
||||
res = true;
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "_httpMedia is not created!");
|
||||
|
||||
return res;
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lpasdk/lpasdk_internal_api.h"
|
||||
|
||||
#include "lpasdk/core/isdr_applet_manager.h"
|
||||
#include "lpasdk/core/lpa_log.h"
|
||||
#include "lpasdk/core/lpa_manager_helper.h"
|
||||
|
||||
static bool _isSelectedISDR = false;
|
||||
static unsigned char _apduCommandSelectISDR[] = { 0x00, 0xA4, 0x04, 0x00, 0x10, 0xA0, 0x00, 0x00, 0x05, 0x59, 0x10, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x89, 0x00, 0x00, 0x01, 0x00 };
|
||||
|
||||
bool selectISDRApplet()
|
||||
{
|
||||
if (!_isSelectedISDR)
|
||||
{
|
||||
unsigned char apduResponseBytes[256]; // Max APDU response size when Selecting ISDR
|
||||
size_t apduResponseSize = 0;
|
||||
uint16_t sw = 0x00;
|
||||
|
||||
if (buildAndSendApduCase4Ex(_apduCommandSelectISDR, sizeof(_apduCommandSelectISDR), &sw, apduResponseBytes, sizeof(apduResponseBytes), &apduResponseSize))
|
||||
{
|
||||
if (apduResponseSize >= 2)
|
||||
{
|
||||
if (sw == (uint16_t)0x9000 || ((sw & (uint16_t)0x9100) == (uint16_t)0x9100) || ((sw & (uint16_t)0x6100) == (uint16_t)0x6100) )
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "ISDR applet selected successfully");
|
||||
_isSelectedISDR = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Incorrect SW received!");
|
||||
lpaSetErrorCode(LPA_ERROR_SE_MEDIA_UNABLE_TO_SELECT_ISDR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// SW is empty / incomplete or incorrect data (Too short to be a SW, can be data corruption or error detected at lower layer)
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Incorrect data or invalid SW or error! (Too short response < 2)");
|
||||
lpaSetErrorCode(LPA_ERROR_SE_MEDIA_UNABLE_TO_SELECT_ISDR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Unable to send successfully APDU command!");
|
||||
lpaSetErrorCode(LPA_ERROR_SE_MEDIA_UNABLE_TO_SELECT_ISDR);
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "ISDR applet already selected");
|
||||
|
||||
return _isSelectedISDR;
|
||||
}
|
||||
|
||||
bool isISDRAppletSelected()
|
||||
{
|
||||
return _isSelectedISDR;
|
||||
}
|
||||
|
||||
bool unselectISDRApplet()
|
||||
{
|
||||
_isSelectedISDR = false;
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,244 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lpasdk/core/lpa_config_file.h"
|
||||
#include "lpasdk/core/lpa_manager.h"
|
||||
|
||||
#include "lpasdk/core/lpa_log.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
static bool _isLoaded = false;
|
||||
|
||||
void _trimString(char* ptrString);
|
||||
void _removeQuotes(char* ptrString);
|
||||
bool _manageConfigLineEntry(char* ptrString);
|
||||
bool _isEmptyOrCommentedLine(const char* ptrString);
|
||||
|
||||
bool lpaConfigFileLoad(const char* ptrConfigFileName, bool* ptrConfigFileOpened)
|
||||
{
|
||||
FILE *ptrFileConfig = NULL;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "lpaConfigFileLoad()...");
|
||||
|
||||
if (!_isLoaded)
|
||||
{
|
||||
if (ptrConfigFileName != NULL && ptrConfigFileOpened != NULL)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "Opening '%s' configuration file...", ptrConfigFileName);
|
||||
|
||||
ptrFileConfig = fopen(ptrConfigFileName, "r");
|
||||
if (ptrFileConfig != NULL)
|
||||
{
|
||||
char bufferReadFile[LPA_CFG_LINE_ENTRY_MAX_SIZE];
|
||||
int16_t lineCounter = 0;
|
||||
|
||||
*ptrConfigFileOpened = true;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "Loading '%s' configuration file...", ptrConfigFileName);
|
||||
|
||||
|
||||
// Read line by line (parsing error on one line do not stop parsing loop)
|
||||
while ( !feof(ptrFileConfig))
|
||||
{
|
||||
if (fgets(bufferReadFile, 1024, ptrFileConfig) == NULL)
|
||||
break;
|
||||
lineCounter++;
|
||||
|
||||
_trimString(bufferReadFile);
|
||||
if (!_isEmptyOrCommentedLine(bufferReadFile))
|
||||
{
|
||||
if (!_manageConfigLineEntry(bufferReadFile))
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "Unable to parse successfully line number %d!", lineCounter);
|
||||
}
|
||||
}
|
||||
|
||||
if(lineCounter == 0)
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "No line processed, configuration file seems empty");
|
||||
|
||||
_isLoaded = true;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "Closing configuration file..." );
|
||||
|
||||
fclose(ptrFileConfig);
|
||||
ptrFileConfig = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
int save_errno = errno; // Immediately save errno macro value else can be affected by other operations
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "Unable to open configuration file, errno = %d \"%s\"", save_errno, strerror(save_errno));
|
||||
*ptrConfigFileOpened = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Configuration file already loaded
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "Configuration file already loaded");
|
||||
|
||||
if ( ptrConfigFileOpened != NULL)
|
||||
*ptrConfigFileOpened = true;
|
||||
}
|
||||
|
||||
return _isLoaded;
|
||||
}
|
||||
|
||||
bool _isEmptyOrCommentedLine(const char* ptrLine)
|
||||
{
|
||||
bool isEmptyOrCommentedLine = false;
|
||||
|
||||
if (NULL == ptrLine || strlen(ptrLine) == 0)
|
||||
isEmptyOrCommentedLine = true;
|
||||
else
|
||||
{
|
||||
if (ptrLine[0] == '#' || ptrLine[0] == '/' || ptrLine[0] == ';')
|
||||
isEmptyOrCommentedLine = true;
|
||||
}
|
||||
|
||||
return isEmptyOrCommentedLine;
|
||||
}
|
||||
|
||||
bool _manageConfigLineEntry(char* ptrLine)
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
if (NULL != ptrLine && strlen(ptrLine) > 0)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "Parsing configuration entry '%s'...", ptrLine);
|
||||
size_t posEqual = strcspn(ptrLine, "=");
|
||||
if (posEqual < strlen(ptrLine))
|
||||
{
|
||||
// Split the line into 2 parts : Key <-> Value
|
||||
ptrLine[posEqual] = 0x00;
|
||||
|
||||
char* ptrParameterKeyName = ptrLine;
|
||||
char* ptrParameterKeyValue = &ptrLine[posEqual + 1];
|
||||
|
||||
_trimString(ptrParameterKeyName);
|
||||
_trimString(ptrParameterKeyValue);
|
||||
_removeQuotes(ptrParameterKeyName);
|
||||
_removeQuotes(ptrParameterKeyValue);
|
||||
|
||||
// Note: Empty ptrParameterKeyValue is now accepted, allow to replace a default string parameter value by an empty string if needed
|
||||
// Value data compatibility checking for other types of parameters will be done by parameter setter.
|
||||
if (strlen(ptrParameterKeyName) > 0)
|
||||
{
|
||||
LPA_PARAMETER_TYPE parameterType = LPA_PARAMETER_TYPE_UNKNOWN;
|
||||
bool isParameterExist = false;
|
||||
bool isAccessGranted = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "managing LPA parameter: '%s'='%s'", ptrParameterKeyName, ptrParameterKeyValue);
|
||||
|
||||
if (lpaManagerIsConfigParameterExist(ptrParameterKeyName, ¶meterType, &isParameterExist, &isAccessGranted) && isParameterExist )
|
||||
{
|
||||
if(isAccessGranted)
|
||||
{
|
||||
// Internal call to lpaManagerSetConfigParameter() function
|
||||
if (lpaManagerSetConfigParameter(ptrParameterKeyName, LPA_PARAMETER_TYPE_STRING, ptrParameterKeyValue, true))
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "LPA parameter '%s' configured successfully with value '%s'", ptrParameterKeyName, ptrParameterKeyValue);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Unable to set LPA parameter '%s' with value '%s'!", ptrParameterKeyName, ptrParameterKeyValue);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "No access right to update LPA parameter '%s' with value '%s'!", ptrParameterKeyName, ptrParameterKeyValue);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "parameter '%s' not exit or not supported", ptrParameterKeyName);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Invalid configuration entry!");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Separator not found on Configuration entry!");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void _trimString(char* ptrString)
|
||||
{
|
||||
if (ptrString != NULL && strlen(ptrString) > 0 )
|
||||
{
|
||||
char* ptrBeginString = ptrString;
|
||||
|
||||
size_t posSlash = strcspn(ptrBeginString, "\r\n");
|
||||
if (posSlash != strlen(ptrBeginString))
|
||||
ptrBeginString[posSlash] = 0x00;
|
||||
|
||||
if (strlen(ptrString) > 0)
|
||||
{
|
||||
// Step1: Remove all space before first digit
|
||||
if (isspace((unsigned char)(ptrBeginString[0])))
|
||||
{
|
||||
// One or more space at begin
|
||||
size_t countSpace = 0;
|
||||
while (isspace( (unsigned char) (ptrBeginString[countSpace])))
|
||||
countSpace++;
|
||||
|
||||
// Now remove it (or them)
|
||||
size_t remainingString = strlen(ptrBeginString) - countSpace;
|
||||
if (remainingString > 0)
|
||||
{
|
||||
for (size_t idx = 0; idx < remainingString; idx++)
|
||||
ptrBeginString[idx] = ptrBeginString[idx + countSpace];
|
||||
ptrBeginString[remainingString] = 0x0;
|
||||
}
|
||||
else
|
||||
ptrBeginString[0] = 0x0;
|
||||
}
|
||||
|
||||
// Step2: Remove all spaces after last digit
|
||||
while((isspace( (unsigned char) (ptrString[strlen(ptrString) - 1]))) && (strlen(ptrString) > 0))
|
||||
ptrString[strlen(ptrString) - 1] = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove quotes '"' or ''' from parameter string only if it begin and ends by these characters
|
||||
* Note: The parameter string has already been cleaned from extra spaces before and after by _trimString()
|
||||
* @param ptrString
|
||||
*/
|
||||
void _removeQuotes(char* ptrString)
|
||||
{
|
||||
size_t strLengthMinus1 = 0;
|
||||
size_t idx = 0;
|
||||
|
||||
// At least 2 characters must be present, minimum is "" that defines an empty string
|
||||
if (ptrString != NULL && strlen(ptrString) > 1 )
|
||||
{
|
||||
strLengthMinus1 = strlen(ptrString) - 1;
|
||||
|
||||
if((ptrString[0] == '"' && ptrString[strLengthMinus1] == '"') || (ptrString[0] == '\'' && ptrString[strLengthMinus1] == '\''))
|
||||
{
|
||||
// Remove first and last character
|
||||
// Note: If 2 characters long it is an empty string, so copy loop will not start, and strlen -1 -1 will equal 0, so OK for end of string
|
||||
for(idx = 0; idx < (strLengthMinus1 - 1); idx++)
|
||||
{
|
||||
ptrString[idx] = ptrString[idx + 1];
|
||||
}
|
||||
// Set new end of string
|
||||
ptrString[strLengthMinus1 - 1] = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
774
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/src/core/lpa_log.c
Executable file
774
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/src/core/lpa_log.c
Executable file
|
@ -0,0 +1,774 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lpasdk/core/lpa_log.h"
|
||||
#include "lpasdk/core/lpa_memory.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static LpaLogLevel _logLevel = SDK_LOG_LEVEL_DEBUG;
|
||||
|
||||
static LPA_LOG_INTERFACE _lpaLogInterface;
|
||||
static bool _lpaLogInitialized = false;
|
||||
static bool _logLimitationActivated = false;
|
||||
|
||||
#define LOG_NORMAL_MESSAGE_LINE_SIZE 1024
|
||||
#define LOG_MAXIMUM_MESSAGE_LINE_SIZE 8192
|
||||
|
||||
static char _bufferTimeFormatting[96];
|
||||
static char _bufferMessageFormatting[LOG_NORMAL_MESSAGE_LINE_SIZE]; // No static buffer > 1024 bytes (except if allocated dynamically)
|
||||
|
||||
// Managing log max size
|
||||
#define MIN_LOG_MAX_SIZE 64 * 1024 // 64 Ko
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define LOG_FILE_MAX_SIZE_DEFAULT 16*1024*1024 // 16 Mo
|
||||
#else
|
||||
#define LOG_FILE_MAX_SIZE_DEFAULT 1024 * 1024 // 1 Mo
|
||||
#endif //
|
||||
|
||||
#ifdef LPA_SDK__LOG_MAX_SIZE
|
||||
#undef LOG_FILE_MAX_SIZE_DEFAULT
|
||||
#define LOG_FILE_MAX_SIZE_DEFAULT LPA_SDK__LOG_MAX_SIZE
|
||||
#endif
|
||||
|
||||
static long _lpaLogFileMaxSize = LOG_FILE_MAX_SIZE_DEFAULT;
|
||||
|
||||
#define LOG_LEVEL_VERBOSE_STRING "VER"
|
||||
#define LOG_LEVEL_DEBUG_STRING "DEB"
|
||||
#define LOG_LEVEL_INFO_STRING "INF"
|
||||
#define LOG_LEVEL_WARNING_STRING "WAR"
|
||||
#define LOG_LEVEL_ERROR_STRING "ERR"
|
||||
#define LOG_LEVEL_SYSTEM_STRING "SYS"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LpaLogLevel logLevel;
|
||||
char* logLevelName;
|
||||
bool selectable;
|
||||
}LOG_LEVEL_INFO;
|
||||
|
||||
static LOG_LEVEL_INFO _logLevelInfoList [] =
|
||||
{
|
||||
{ SDK_LOG_LEVEL_VERBOSE, LOG_LEVEL_VERBOSE_STRING, true },
|
||||
{ SDK_LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_STRING, true },
|
||||
{ SDK_LOG_LEVEL_INFO, LOG_LEVEL_INFO_STRING, true },
|
||||
{ SDK_LOG_LEVEL_WARNING, LOG_LEVEL_WARNING_STRING, true },
|
||||
{ SDK_LOG_LEVEL_ERROR, LOG_LEVEL_ERROR_STRING, true },
|
||||
|
||||
{ SDK_LOG_LEVEL_SYSTEM, LOG_LEVEL_SYSTEM_STRING, false },
|
||||
// Latest entry: do not remove/update
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static FILE* _logFile = NULL;
|
||||
static char _logFileName[LPA_MAX_PATH];
|
||||
static char _backupLogFileName[LPA_MAX_PATH];
|
||||
|
||||
// Default implementation definition
|
||||
///////////////////////////////////////////
|
||||
void _lpaCoreSetLogLevel(LpaLogLevel logLevel);
|
||||
LpaLogLevel _lpaCoreGetLogLevel(void);
|
||||
|
||||
bool _lpaCoreSetLogMaxSize(long logMaxSize);
|
||||
long _lpaCoreGetLogMaxSize();
|
||||
|
||||
void _lpaCoreLogOpen(const char* ptrFileName, const char* prtBackupFileName);
|
||||
void _lpaCoreLogFlush();
|
||||
bool _lpaCoreLogIsOpened();
|
||||
void _lpaCoreLogClose();
|
||||
|
||||
void _lpaCoreLogAppend(LpaLogLevel logLevel, const char* ptrMessage, va_list argptr);
|
||||
void _lpaCoreLogAppendLongText(LpaLogLevel logLevel, const char* ptrHeaderMessage, const char* ptrLongTextToLog, const size_t LongTextToLogSize);
|
||||
void _lpaCoreLogAppendByteArray(LpaLogLevel logLevel, const char* ptrMessage, const char* ptrByteArrayName, unsigned char* ptrByteArray, size_t byteArraySize);
|
||||
|
||||
void _lpaCoreActivateLogLimitation(bool activated);
|
||||
|
||||
// Internal functions
|
||||
///////////////////////////////////////////
|
||||
|
||||
bool _isLogLevelMatching(const char* ptrLogLevel, const char* ptrLogLevelRef);
|
||||
const char* _lpaCoreGetLogLevelName(LpaLogLevel logLevel, bool* ptrIsFound);
|
||||
|
||||
/**
|
||||
* Initialize log component with default implementation.
|
||||
* @return True if log component successfully initialized, otherwise return false
|
||||
*/
|
||||
|
||||
bool lpaCoreLogInit()
|
||||
{
|
||||
bool initDoneSuccessfully = false;
|
||||
|
||||
if (!_lpaLogInitialized)
|
||||
{
|
||||
memset(&_lpaLogInterface, 0x00, sizeof(LPA_LOG_INTERFACE));
|
||||
|
||||
_lpaLogInterface.openLog = _lpaCoreLogOpen;
|
||||
_lpaLogInterface.flushLog = _lpaCoreLogFlush;
|
||||
_lpaLogInterface.isLogOpened = _lpaCoreLogIsOpened;
|
||||
_lpaLogInterface.closeLog = _lpaCoreLogClose;
|
||||
|
||||
_lpaLogInterface.appendToLog = _lpaCoreLogAppend;
|
||||
_lpaLogInterface.appendLongTextToLog = _lpaCoreLogAppendLongText;
|
||||
_lpaLogInterface.appendByteArrayToLog = _lpaCoreLogAppendByteArray;
|
||||
|
||||
_lpaLogInterface.activateLogLimitation = _lpaCoreActivateLogLimitation;
|
||||
|
||||
_lpaLogInterface.setLogLevel = _lpaCoreSetLogLevel;
|
||||
_lpaLogInterface.getLogLevel = _lpaCoreGetLogLevel;
|
||||
|
||||
_lpaLogInterface.setLogMaxSize = _lpaCoreSetLogMaxSize;
|
||||
_lpaLogInterface.getLogMaxSize = _lpaCoreGetLogMaxSize;
|
||||
|
||||
_lpaLogInitialized = true;
|
||||
initDoneSuccessfully = true;
|
||||
|
||||
// Log limitation mecanism deactivated at startup
|
||||
_lpaLogInterface.activateLogLimitation(false);
|
||||
}
|
||||
|
||||
return initDoneSuccessfully;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaCoreLogInitEx(LPA_LOG_INTERFACE* ptrLpaLogInterface)
|
||||
{
|
||||
bool initDoneSuccessfully = false;
|
||||
|
||||
if (!_lpaLogInitialized && ptrLpaLogInterface != NULL )
|
||||
{
|
||||
memset( &_lpaLogInterface, 0x00, sizeof(LPA_LOG_INTERFACE));
|
||||
|
||||
_lpaLogInterface.openLog = ptrLpaLogInterface->openLog;
|
||||
_lpaLogInterface.flushLog = ptrLpaLogInterface->flushLog;
|
||||
_lpaLogInterface.closeLog = ptrLpaLogInterface->closeLog;
|
||||
|
||||
_lpaLogInterface.activateLogLimitation = ptrLpaLogInterface->activateLogLimitation;
|
||||
|
||||
_lpaLogInterface.setLogLevel = ptrLpaLogInterface->setLogLevel;
|
||||
_lpaLogInterface.getLogLevel = ptrLpaLogInterface->getLogLevel;
|
||||
|
||||
_lpaLogInterface.setLogMaxSize = ptrLpaLogInterface->setLogMaxSize;
|
||||
_lpaLogInterface.getLogMaxSize = ptrLpaLogInterface->getLogMaxSize;
|
||||
|
||||
_lpaLogInterface.appendToLog = ptrLpaLogInterface->appendToLog;
|
||||
_lpaLogInterface.appendLongTextToLog = ptrLpaLogInterface->appendLongTextToLog;
|
||||
_lpaLogInterface.appendByteArrayToLog = ptrLpaLogInterface->appendByteArrayToLog;
|
||||
|
||||
_lpaLogInitialized = true;
|
||||
initDoneSuccessfully = true;
|
||||
|
||||
// Log limitation mecanism deactivated at startup
|
||||
if(_lpaLogInterface.activateLogLimitation != NULL )
|
||||
_lpaLogInterface.activateLogLimitation(false);
|
||||
}
|
||||
|
||||
return initDoneSuccessfully;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaCoreLogIsInitialized()
|
||||
{
|
||||
return _lpaLogInitialized;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaCoreLogRelease()
|
||||
{
|
||||
bool releaseDoneSuccessfully = false;
|
||||
|
||||
if (_lpaLogInitialized)
|
||||
{
|
||||
memset(&_lpaLogInterface, 0x00, sizeof(LPA_LOG_INTERFACE));
|
||||
|
||||
_lpaLogInitialized = false;
|
||||
releaseDoneSuccessfully = false;
|
||||
}
|
||||
return releaseDoneSuccessfully;
|
||||
}
|
||||
|
||||
const LPA_LOG_INTERFACE* getLpaLogObject()
|
||||
{
|
||||
return (_lpaLogInitialized ? &_lpaLogInterface : NULL);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Log Manager part
|
||||
//////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreSetLogLevel(LpaLogLevel logLevel)
|
||||
{
|
||||
if (_lpaLogInitialized && _lpaLogInterface.setLogLevel != NULL)
|
||||
{
|
||||
_lpaLogInterface.setLogLevel(logLevel);
|
||||
}
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL LpaLogLevel lpaCoreGetLogLevel(void)
|
||||
{
|
||||
LpaLogLevel logLevel = SDK_LOG_LEVEL_UNKNOWN;
|
||||
|
||||
if (_lpaLogInitialized && _lpaLogInterface.setLogLevel != NULL)
|
||||
logLevel = _lpaLogInterface.getLogLevel();
|
||||
|
||||
return logLevel;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaCoreSetLogMaxSize(long logMaxSize)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
if (_lpaLogInitialized && _lpaLogInterface.setLogMaxSize != NULL)
|
||||
res = _lpaLogInterface.setLogMaxSize(logMaxSize);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL long lpaCoreGetLogMaxSize()
|
||||
{
|
||||
long logMaxSize = 0L;
|
||||
|
||||
if (_lpaLogInitialized && _lpaLogInterface.getLogMaxSize != NULL)
|
||||
logMaxSize = _lpaLogInterface.getLogMaxSize();
|
||||
|
||||
return logMaxSize;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreActivateLogLimitation(bool activated)
|
||||
{
|
||||
if (_lpaLogInitialized && _lpaLogInterface.activateLogLimitation != NULL)
|
||||
_lpaLogInterface.activateLogLimitation(activated);
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreLogOpen(const char* ptrFileName, const char* prtBackupFileName)
|
||||
{
|
||||
if (_lpaLogInitialized && _lpaLogInterface.openLog != NULL)
|
||||
_lpaLogInterface.openLog(ptrFileName, prtBackupFileName);
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreLogFlush()
|
||||
{
|
||||
if (_lpaLogInitialized && _lpaLogInterface.flushLog != NULL)
|
||||
_lpaLogInterface.flushLog();
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreLogClose()
|
||||
{
|
||||
if (_lpaLogInitialized && _lpaLogInterface.closeLog != NULL)
|
||||
_lpaLogInterface.closeLog();
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaCoreLogIsOpen()
|
||||
{
|
||||
bool isOpened = false;
|
||||
|
||||
if (_lpaLogInitialized && _lpaLogInterface.isLogOpened != NULL)
|
||||
isOpened = _lpaLogInterface.isLogOpened();
|
||||
|
||||
return isOpened;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreLogAppend(LpaLogLevel logLevel, const char* ptrMessage, ...)
|
||||
{
|
||||
if (_lpaLogInitialized && _lpaLogInterface.appendToLog != NULL)
|
||||
{
|
||||
va_list argptr;
|
||||
va_start(argptr, ptrMessage);
|
||||
|
||||
_lpaLogInterface.appendToLog(logLevel, ptrMessage, argptr);
|
||||
|
||||
va_end(argptr);
|
||||
}
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreLogAppendLongText(LpaLogLevel logLevel, const char* ptrHeaderMessage, const char* ptrLongTextToLog, const size_t LongTextToLogSize)
|
||||
{
|
||||
if (_lpaLogInitialized && _lpaLogInterface.appendLongTextToLog != NULL)
|
||||
{
|
||||
_lpaLogInterface.appendLongTextToLog(logLevel, ptrHeaderMessage, ptrLongTextToLog,LongTextToLogSize);
|
||||
}
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL void lpaCoreLogAppendByteArray(LpaLogLevel logLevel, const char* ptrMessage, const char* ptrByteArrayName, unsigned char* ptrByteArray, size_t byteArraySize)
|
||||
{
|
||||
if (_lpaLogInitialized && _lpaLogInterface.appendByteArrayToLog != NULL)
|
||||
{
|
||||
_lpaLogInterface.appendByteArrayToLog(logLevel, ptrMessage, ptrByteArrayName, ptrByteArray, byteArraySize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UT_EXPORT_DLL const char* lpaCoreGetLogLevelName(LpaLogLevel logLevel, bool* ptrIsFound)
|
||||
{
|
||||
return _lpaCoreGetLogLevelName(logLevel, ptrIsFound);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Default implementation
|
||||
//////////////////////////////////////////////
|
||||
|
||||
void _lpaCoreSetLogLevel(LpaLogLevel logLevel)
|
||||
{
|
||||
_logLevel = logLevel;
|
||||
}
|
||||
|
||||
LpaLogLevel _lpaCoreGetLogLevel(void)
|
||||
{
|
||||
return _logLevel;
|
||||
}
|
||||
|
||||
bool _lpaCoreSetLogMaxSize(long logMaxSize)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
if (logMaxSize > MIN_LOG_MAX_SIZE)
|
||||
{
|
||||
_lpaLogFileMaxSize = logMaxSize;
|
||||
res = true;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
long _lpaCoreGetLogMaxSize()
|
||||
{
|
||||
return _lpaLogFileMaxSize;
|
||||
}
|
||||
|
||||
void _lpaCoreActivateLogLimitation(bool activated)
|
||||
{
|
||||
_logLimitationActivated = activated;
|
||||
}
|
||||
|
||||
void _lpaCoreManageLogFileSize()
|
||||
{
|
||||
if (_logFile != NULL && _logLimitationActivated)
|
||||
{
|
||||
static size_t checkCounter = 0;
|
||||
|
||||
checkCounter++;
|
||||
if (checkCounter > 5)
|
||||
{
|
||||
// do check all 5 call
|
||||
checkCounter = 0;
|
||||
|
||||
// Check file size
|
||||
struct stat statLogFile;
|
||||
memset(&statLogFile, 0x00, sizeof(struct stat));
|
||||
|
||||
bool getFileSize = false;
|
||||
|
||||
#ifdef LPA_SDK__PLATFORM_WIN
|
||||
|
||||
int descriptorFile = _fileno(_logFile);
|
||||
|
||||
if (descriptorFile != -1 && fstat(descriptorFile, &statLogFile) >= 0)
|
||||
getFileSize = true;
|
||||
#else
|
||||
// Special code for Linux (Warning: fileno() is POSIX, not C99!!
|
||||
#if defined(__POSIX_VISIBLE) && (__POSIX_VISIBLE > 0)
|
||||
if (fstat(fileno(_logFile), &statLogFile) >= 0)
|
||||
getFileSize = true;
|
||||
#else
|
||||
// Works fine under Cygwin, TBV for other platforms
|
||||
if (stat(_logFileName, &statLogFile) >= 0)
|
||||
getFileSize = true;
|
||||
|
||||
#endif // __POSIX_VISIBLE
|
||||
#endif // LPA_SDK__PLATFORM_WIN
|
||||
|
||||
if (getFileSize)
|
||||
{
|
||||
// File exist => check size
|
||||
if (statLogFile.st_size > _lpaLogFileMaxSize)
|
||||
{
|
||||
fclose(_logFile);
|
||||
_logFile = NULL;
|
||||
|
||||
if (stat(_backupLogFileName, &statLogFile) >= 0)
|
||||
{
|
||||
remove(_backupLogFileName);
|
||||
}
|
||||
|
||||
if (rename(_logFileName, _backupLogFileName) != 0)
|
||||
{
|
||||
fprintf(stderr, "Unable to rename log file (errno=%d)!", errno);
|
||||
|
||||
// Unable to rename file => reopen it but content is lost
|
||||
_logFile = fopen(_logFileName, "wt");
|
||||
}
|
||||
else
|
||||
{
|
||||
// log file renamed successfully
|
||||
_logFile = fopen(_logFileName, "at");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _lpaCoreLogOpen( const char* ptrFileName, const char* prtBackupFileName)
|
||||
{
|
||||
if( _logFile == NULL )
|
||||
{
|
||||
if (ptrFileName != NULL && prtBackupFileName != NULL && strlen(ptrFileName) < LPA_MAX_PATH && strlen(ptrFileName) < LPA_MAX_PATH)
|
||||
{
|
||||
// Save log file name & backup log file name
|
||||
snprintf(_logFileName, LPA_MAX_PATH, "%s", ptrFileName);
|
||||
snprintf(_backupLogFileName, LPA_MAX_PATH, "%s", prtBackupFileName);
|
||||
|
||||
// Check file size
|
||||
struct stat statLogFile;
|
||||
|
||||
if (_logLimitationActivated && stat(ptrFileName, &statLogFile) >= 0)
|
||||
{
|
||||
// File exist => check size
|
||||
if (statLogFile.st_size > _lpaLogFileMaxSize)
|
||||
{
|
||||
if (stat(prtBackupFileName, &statLogFile) >= 0)
|
||||
{
|
||||
remove(prtBackupFileName);
|
||||
}
|
||||
|
||||
if (rename(ptrFileName, prtBackupFileName) != 0)
|
||||
fprintf(stderr, "Unable to rename log file (errno=%d)!", errno);
|
||||
}
|
||||
}
|
||||
|
||||
_logFile = fopen(ptrFileName, "at");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Log file already opened
|
||||
}
|
||||
}
|
||||
|
||||
bool _lpaCoreLogIsOpened()
|
||||
{
|
||||
return (_logFile != NULL);
|
||||
}
|
||||
|
||||
void _lpaCoreLogFlush()
|
||||
{
|
||||
if( _logFile != NULL )
|
||||
fflush(_logFile);
|
||||
}
|
||||
|
||||
void _lpaCoreLogAppend(LpaLogLevel logLevel, const char* ptrMessage, va_list argptr)
|
||||
{
|
||||
bool not_big_logging = true;
|
||||
|
||||
if (_logFile != NULL && logLevel >= _logLevel && ptrMessage != NULL)
|
||||
{
|
||||
time_t rawTime;
|
||||
struct tm *infoTime = NULL;
|
||||
int formattedStringSize = 0;
|
||||
va_list argptrClone;
|
||||
|
||||
// Buffers reset
|
||||
memset(_bufferTimeFormatting, 0, sizeof(_bufferTimeFormatting));
|
||||
memset(_bufferMessageFormatting, 0, sizeof(_bufferMessageFormatting));
|
||||
|
||||
// Manage header message
|
||||
/////////////////////////////
|
||||
|
||||
// manage time formatting
|
||||
time(&rawTime);
|
||||
infoTime = localtime(&rawTime);
|
||||
strftime(_bufferTimeFormatting, sizeof(_bufferTimeFormatting), "%d/%m/%Y %H:%M:%S", infoTime);
|
||||
|
||||
// Manage message formatting
|
||||
/////////////////////////////
|
||||
|
||||
va_copy(argptrClone, argptr);
|
||||
formattedStringSize = vsnprintf(_bufferMessageFormatting, sizeof(_bufferMessageFormatting) - 1, ptrMessage, argptrClone);
|
||||
va_end(argptrClone);
|
||||
|
||||
// Check if line to log exceeds normal buffer. If yes try to allocate a bigger buffer and retrieve log inside
|
||||
if(formattedStringSize > (LOG_NORMAL_MESSAGE_LINE_SIZE - 1))
|
||||
{
|
||||
int bigFormattedStringSize = formattedStringSize + 1; // + End of string
|
||||
|
||||
// Check not exceed maximum allowed
|
||||
if(bigFormattedStringSize > LOG_MAXIMUM_MESSAGE_LINE_SIZE)
|
||||
bigFormattedStringSize = LOG_MAXIMUM_MESSAGE_LINE_SIZE;
|
||||
|
||||
char * bigBufferMessageFormatting = lpaCoreMemoryAlloc(bigFormattedStringSize);
|
||||
|
||||
// If data buffer cannot be allocated, will return to log on one truncated line, size limited to LOG_NORMAL_MESSAGE_LINE_SIZE
|
||||
if(bigBufferMessageFormatting != NULL)
|
||||
{
|
||||
not_big_logging = false;
|
||||
|
||||
// Write header part - Done here to avoid log interleave with Memory allocation log
|
||||
fprintf(_logFile, "%s | %s", _bufferTimeFormatting, _lpaCoreGetLogLevelName(logLevel, NULL));
|
||||
|
||||
// Manage message formatting
|
||||
formattedStringSize = vsnprintf(bigBufferMessageFormatting, bigFormattedStringSize, ptrMessage, argptr);
|
||||
|
||||
if (formattedStringSize > 0 )
|
||||
fprintf(_logFile, " | %s\n", bigBufferMessageFormatting);
|
||||
else
|
||||
fprintf(_logFile, " | ---Unable to format message --- \n");
|
||||
|
||||
// Big buffer cleanup
|
||||
lpaCoreMemoryFree(bigBufferMessageFormatting);
|
||||
bigBufferMessageFormatting = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Perform logging of normal buffer if not been done by big one due to memory problem
|
||||
if(not_big_logging)
|
||||
{
|
||||
// Write header part - Done here to avoid log interleave with Memory allocation log
|
||||
fprintf(_logFile, "%s | %s", _bufferTimeFormatting, _lpaCoreGetLogLevelName(logLevel, NULL));
|
||||
|
||||
if (formattedStringSize > 0 )
|
||||
fprintf(_logFile, " | %s\n", _bufferMessageFormatting);
|
||||
else
|
||||
fprintf(_logFile, " | ---Unable to format message --- \n");
|
||||
}
|
||||
|
||||
// In first release, flush automatically each log entry
|
||||
fflush(_logFile);
|
||||
|
||||
_lpaCoreManageLogFileSize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log text in log file, in multiple lines - This functions does not support formatting characters
|
||||
* @param logLevel Log level to apply on log item
|
||||
* @param ptrHeaderMessage Message header to write in log
|
||||
* @param ptrLongTextToLog Pointer on long text to log in log file
|
||||
* @param LongTextToLogSize Long text to log size
|
||||
*/
|
||||
|
||||
void _lpaCoreLogAppendLongText(LpaLogLevel logLevel, const char* ptrHeaderMessage, const char* ptrLongTextToLog, const size_t LongTextToLogSize)
|
||||
{
|
||||
if (_logFile != NULL && logLevel >= _logLevel && ptrHeaderMessage != NULL && ptrLongTextToLog != NULL && LongTextToLogSize > 0)
|
||||
{
|
||||
const char* logLevelName = _lpaCoreGetLogLevelName(logLevel, NULL);
|
||||
|
||||
time_t rawTime;
|
||||
struct tm *infoTime = NULL;
|
||||
|
||||
// manage time formatting
|
||||
time(&rawTime);
|
||||
infoTime = localtime(&rawTime);
|
||||
strftime(_bufferTimeFormatting, sizeof(_bufferTimeFormatting), "%d/%m/%Y %H:%M:%S", infoTime);
|
||||
|
||||
// Log Header
|
||||
fprintf(_logFile, "%s | %s | %s\n", _bufferTimeFormatting, logLevelName, ptrHeaderMessage);
|
||||
|
||||
size_t currentPositionInText = 0;
|
||||
size_t currentPositionInLine = 0;
|
||||
|
||||
while(currentPositionInText < LongTextToLogSize)
|
||||
{
|
||||
// Start a new line, print new line header
|
||||
if(currentPositionInLine == 0)
|
||||
{
|
||||
fprintf(_logFile, "%s | %s | ", _bufferTimeFormatting, logLevelName);
|
||||
}
|
||||
|
||||
// Print text character in current log line
|
||||
fprintf(_logFile, "%c", *(ptrLongTextToLog + currentPositionInText));
|
||||
|
||||
currentPositionInText++;
|
||||
currentPositionInLine++;
|
||||
|
||||
// Check end of log line reached, if yes go to the next line and flush current line
|
||||
if(currentPositionInLine > LOG_NORMAL_MESSAGE_LINE_SIZE)
|
||||
{
|
||||
fprintf(_logFile, "\n");
|
||||
currentPositionInLine = 0;
|
||||
|
||||
fflush(_logFile);
|
||||
}
|
||||
}
|
||||
|
||||
// Terminate last line, only if not already done
|
||||
if(currentPositionInLine > 0)
|
||||
fprintf(_logFile, "\n");
|
||||
|
||||
fflush(_logFile);
|
||||
_lpaCoreManageLogFileSize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void _lpaCoreLogAppendByteArray(LpaLogLevel logLevel, const char* ptrMessage, const char* ptrByteArrayName, unsigned char* ptrByteArray, size_t byteArraySize)
|
||||
{
|
||||
if (_logFile != NULL && logLevel >= _logLevel)
|
||||
{
|
||||
if (ptrMessage != NULL)
|
||||
{
|
||||
// Write message in first
|
||||
lpaCoreLogAppend(logLevel, ptrMessage);
|
||||
}
|
||||
|
||||
if (ptrByteArray != NULL && byteArraySize > 0 && ptrByteArrayName != NULL )
|
||||
{
|
||||
|
||||
// Write Byte array (one or more bloc)
|
||||
size_t maxBytesByBlocK = sizeof(_bufferMessageFormatting) / 4;
|
||||
size_t offsetByteArray = 0;
|
||||
|
||||
time_t rawTime;
|
||||
struct tm *infoTime = NULL;
|
||||
const char* logLevelName = _lpaCoreGetLogLevelName(logLevel, NULL);
|
||||
|
||||
while (offsetByteArray < byteArraySize)
|
||||
{
|
||||
size_t currentBlockSize = ((offsetByteArray + maxBytesByBlocK) < byteArraySize ? maxBytesByBlocK : (byteArraySize - offsetByteArray));
|
||||
|
||||
// manage time formatting
|
||||
time(&rawTime);
|
||||
infoTime = localtime(&rawTime);
|
||||
strftime(_bufferTimeFormatting, sizeof(_bufferTimeFormatting), "%d/%m/%Y %H:%M:%S", infoTime);
|
||||
|
||||
if (currentBlockSize > 1)
|
||||
{
|
||||
snprintf(_bufferMessageFormatting, sizeof(_bufferMessageFormatting), "%s [%llu-%llu]: ", ptrByteArrayName, (long long unsigned)offsetByteArray, (long long unsigned)(offsetByteArray + currentBlockSize - 1));
|
||||
fprintf(_logFile, "%s | %s | %s", _bufferTimeFormatting, logLevelName, _bufferMessageFormatting);
|
||||
|
||||
|
||||
// Manage data
|
||||
for (size_t offset = 0; offset < currentBlockSize; offset++)
|
||||
fprintf(_logFile, " %02X", ptrByteArray[offsetByteArray + offset]);
|
||||
|
||||
fprintf(_logFile, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(_bufferMessageFormatting, sizeof(_bufferMessageFormatting), "%s [%llu]: %02X", ptrByteArrayName, (long long unsigned)offsetByteArray, ptrByteArray[offsetByteArray]);
|
||||
fprintf(_logFile, "%s | %s | %s \n", _bufferTimeFormatting, logLevelName, _bufferMessageFormatting);
|
||||
}
|
||||
|
||||
fflush(_logFile);
|
||||
|
||||
offsetByteArray += currentBlockSize;
|
||||
}
|
||||
|
||||
_lpaCoreManageLogFileSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _lpaCoreLogClose()
|
||||
{
|
||||
if( _logFile != NULL )
|
||||
{
|
||||
fclose(_logFile);
|
||||
_logFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool lpaCoreSetLogLevelString(const char* logLevelString)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
if (logLevelString != NULL)
|
||||
{
|
||||
size_t index = 0;
|
||||
|
||||
while ( !res && _logLevelInfoList[index].logLevelName != NULL)
|
||||
{
|
||||
if ( _isLogLevelMatching(logLevelString, _logLevelInfoList[index].logLevelName))
|
||||
{
|
||||
if (_logLevelInfoList[index].selectable)
|
||||
{
|
||||
if (_logLevel != _logLevelInfoList[index].logLevel)
|
||||
{
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_SYSTEM, "Updating log level to '%s' ( '%s' previously)",
|
||||
_lpaCoreGetLogLevelName(_logLevelInfoList[index].logLevel, NULL),
|
||||
_lpaCoreGetLogLevelName(_logLevel, NULL));
|
||||
_logLevel = _logLevelInfoList[index].logLevel;
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_SYSTEM, "Log level already to '%s'", _lpaCoreGetLogLevelName(_logLevel, NULL));
|
||||
|
||||
res = true;
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_SYSTEM, "Unable to select '%s' log level (internal usage only)",
|
||||
_lpaCoreGetLogLevelName(_logLevelInfoList[index].logLevel, NULL));
|
||||
break;
|
||||
}
|
||||
else
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
const char* _lpaCoreGetLogLevelName(LpaLogLevel logLevel, bool* ptrIsFound)
|
||||
{
|
||||
char* ptrLogLevelName = "??";
|
||||
bool isFound = false;
|
||||
size_t index = 0;
|
||||
|
||||
while (!isFound && _logLevelInfoList[index].logLevelName != NULL)
|
||||
{
|
||||
if (logLevel == _logLevelInfoList[index].logLevel)
|
||||
{
|
||||
ptrLogLevelName = _logLevelInfoList[index].logLevelName;
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
index++;
|
||||
}
|
||||
|
||||
if (ptrIsFound != NULL)
|
||||
*ptrIsFound = isFound;
|
||||
|
||||
return ptrLogLevelName;
|
||||
}
|
||||
|
||||
bool _isLogLevelMatching(const char* ptrLogLevel, const char* ptrLogLevelRef )
|
||||
{
|
||||
if (ptrLogLevel == NULL || ptrLogLevelRef == NULL || strlen(ptrLogLevel) < strlen(ptrLogLevelRef))
|
||||
return false;
|
||||
|
||||
size_t stringSize = strlen(ptrLogLevelRef);
|
||||
for (size_t index = 0; index < stringSize; index++)
|
||||
{
|
||||
if (tolower(ptrLogLevel[index]) != tolower(ptrLogLevelRef[index]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
8064
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/src/core/lpa_manager.c
Executable file
8064
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/src/core/lpa_manager.c
Executable file
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,678 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "lpasdk/core/lpa_manager_api.h" // For main API
|
||||
#include "lpasdk/core/lpa_manager.h" // For main API
|
||||
|
||||
#include "lpasdk/core/lpa_log.h"
|
||||
#include "lpasdk/core/semedia_manager.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
// Monitor LPA MANAGER API usage
|
||||
static size_t _apiUsage = 0;
|
||||
|
||||
#define LPA_MANAGER_API_BEGIN(apiName) { _apiUsage ++ ; assert( _apiUsage == 1); }
|
||||
#define LPA_MANAGER_API_END() { _apiUsage --; assert( _apiUsage == 0); }
|
||||
|
||||
|
||||
// Manage automatic connect/disconnect with reader + select/unselectISDR
|
||||
bool _lpaManagerApiConnectReaderAndSelectISDR();
|
||||
bool _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiInitialize(const char* ptrLpaFolder)
|
||||
{
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiInitialize");
|
||||
bool res = lpaManagerInitialize(ptrLpaFolder);
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiSetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, const void* ptrParameterValue, bool internalCall)
|
||||
{
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiSetConfigParameter");
|
||||
bool res = lpaManagerSetConfigParameter(ptrParameterName, parameterType, ptrParameterValue, internalCall);
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, void* ptrParameterValue, size_t parameterValueMaxSize)
|
||||
{
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiGetConfigParameter");
|
||||
bool res = lpaManagerGetConfigParameter(ptrParameterName, parameterType, ptrParameterValue, parameterValueMaxSize);
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Check if parameter exists in parameter list, if yes return parameter type.
|
||||
* If not in Extended Mode and parameter use is restricted, function will return that parameter does not exist.
|
||||
*
|
||||
* @param ptrParameterName Pointer on parameter name to check, string type
|
||||
* @param ptrParameterType Pointer on parameter type to return, LPA_PARAMETER_TYPE type
|
||||
* @param ptrIsExist Pointer on boolean flag returning if parameter exists, if yes return true
|
||||
* @return True if no error occurred during check
|
||||
*/
|
||||
UT_EXPORT_DLL bool lpaManagerApiIsConfigParameterExist(const char* ptrParameterName, LPA_PARAMETER_TYPE* ptrParameterType, bool* ptrIsExist)
|
||||
{
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiIsConfigParameterExist");
|
||||
|
||||
bool accessRight = false;
|
||||
bool res = lpaManagerIsConfigParameterExist(ptrParameterName, ptrParameterType, ptrIsExist, &accessRight);
|
||||
|
||||
// Manage AccessRight use case: Extended parameter not authorized in Normal Mode, so invalid parameter existence status
|
||||
// Note: Do not check ptrParameterType because already done in lpaManagerIsConfigParameterExist()
|
||||
if (res && (NULL != ptrIsExist) && (true == *ptrIsExist) && (!accessRight))
|
||||
{
|
||||
*ptrIsExist = false;
|
||||
*ptrParameterType = LPA_PARAMETER_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Redirection
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetFullParametersList(LPA_PARAMETERS_LIST * ptrLpaParametersList)
|
||||
{
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiGetFullParametersList");
|
||||
bool res = lpaManagerGetFullParametersList(ptrLpaParametersList);
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// Reconnect SEMedia
|
||||
UT_EXPORT_DLL bool lpaManagerApiSEMediaCardReset()
|
||||
{
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiSEMediaCardReset");
|
||||
bool res = lpaManagerSEMediaCardReset();
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// Exchange with ISDR applet
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetReaderList(LPA_SE_MEDIA_READER_NAME_INFO * ptrReaderNameInfoList, size_t readerNameInfoMax, size_t* ptrCountReader)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiGetReaderList");
|
||||
// In first, establish SEMedia
|
||||
if (seMediaManagerIsContextEstablished() || seMediaManagerEstablishContext())
|
||||
{
|
||||
res = lpaManagerGetReaderList(ptrReaderNameInfoList, readerNameInfoMax, ptrCountReader);
|
||||
}
|
||||
// At the end, do cleanup
|
||||
bool resCleanup = seMediaManagerReleaseContext();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetProfilesInfo(LPA_GET_PROFILES_INFO* ptrGetProfilesInfo)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiGetProfilesInfo");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerGetProfilesInfo(ptrGetProfilesInfo);
|
||||
}
|
||||
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetProfilesNumber(size_t * ptrNumberOfProfiles)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiGetProfilesNumber");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerGetProfilesNumber(ptrNumberOfProfiles);
|
||||
}
|
||||
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetEID(LPA_GET_EID* ptrGetEID)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiGetEID");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerGetEID(ptrGetEID);
|
||||
}
|
||||
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetEUICCInfo(LPA_GET_EUICC_INFO* ptrGetEUICCInfo)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiGetEUICCInfo");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerGetEUICCInfo2(ptrGetEUICCInfo);
|
||||
}
|
||||
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiMemoryReset(const unsigned char* ptrMemoryResetOptionParameter, const size_t memoryResetOptionSize)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiMemoryReset");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerMemoryReset(ptrMemoryResetOptionParameter, memoryResetOptionSize);
|
||||
}
|
||||
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiSendPendingNotification(LPA_EventCallback* ptrLpaEventCallback, LPA_SENDING_NOTIFICATION_RESULT* ptrSendingNotificationResult)
|
||||
{
|
||||
bool res = false;
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiSendPendingNotification");
|
||||
|
||||
// Initialize values in case not already done in calling application, avoid return random values if cannot connect to reader / ISDR and main result not checked
|
||||
if(ptrSendingNotificationResult != NULL)
|
||||
{
|
||||
ptrSendingNotificationResult->countNotificationDetected = 0;
|
||||
ptrSendingNotificationResult->countNotificationSend = 0;
|
||||
}
|
||||
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerSendPendingNotification(ptrLpaEventCallback, ptrSendingNotificationResult);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// Manage Enable/Disable/Delete Profile
|
||||
UT_EXPORT_DLL bool lpaManagerApiEnableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiEnableProfileByIccid");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerEnableProfileByIccid(ptrProfileId, profileIdSize);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiDisableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiDisableProfileByIccid");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerDisableProfileByIccid(ptrProfileId, profileIdSize);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiDeleteProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiDeleteProfileByIccid");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerDeleteProfileByIccid(ptrProfileId, profileIdSize);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// Manage notification list
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetProfileNotificationList(LPA_PROFILE_NOTIFICATION_LIST* ptrProfileNotificationList)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiGetProfileNotificationList");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerGetProfileNotificationList(ptrProfileNotificationList);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
LPA_MANAGER_API_END();
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiClearProfileNotification(uint16_t sequenceNumber)
|
||||
{
|
||||
bool res = false;
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiClearProfileNotification");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerClearProfileNotification(sequenceNumber);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
LPA_MANAGER_API_END();
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiSetDefaultSMDPAddress(const char* ptrSMDPAddr)
|
||||
{
|
||||
bool res = false;
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiSetDefaultSMDPAddress");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerSetDefaultSMDPAddress(ptrSMDPAddr);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
LPA_MANAGER_API_END();
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetSMDPAddress(ADDRESS_DATA* ptrAddressData)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiGetSMDPAddress");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerGetSMDPAddress(ptrAddressData);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
LPA_MANAGER_API_END();
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
|
||||
return res;
|
||||
}
|
||||
UT_EXPORT_DLL bool lpaManagerApiGetSMDSAddress(ADDRESS_DATA* ptrAddressData)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiGetSMDSAddress");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerGetSMDSAddress(ptrAddressData);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
LPA_MANAGER_API_END();
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiDownloadProfile(const char * ptrActivationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiDownloadProfile");
|
||||
|
||||
// Reset DownloadProfileResult if defined
|
||||
if (ptrDownloadProfileResult != NULL)
|
||||
{
|
||||
ptrDownloadProfileResult->countProfileInstalled = 0;
|
||||
ptrDownloadProfileResult->countProfileTotal = 0;
|
||||
}
|
||||
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerDownloadProfile(ptrActivationCodeStr, ptrLpaEventCallback, ptrDownloadProfileResult);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiDownloadProfileWithConfirmationCode(const char * ptrActivationCodeStr, const char * ptrConfirmationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiDownloadProfileWithConfirmationCode");
|
||||
|
||||
// Reset DownloadProfileResult if defined
|
||||
if (ptrDownloadProfileResult != NULL)
|
||||
{
|
||||
ptrDownloadProfileResult->countProfileInstalled = 0;
|
||||
ptrDownloadProfileResult->countProfileTotal = 0;
|
||||
}
|
||||
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerDownloadProfileWithConfirmationCode(ptrActivationCodeStr, ptrConfirmationCodeStr, ptrLpaEventCallback, ptrDownloadProfileResult);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiDownloadProfileWithDefaultSMDPAddress(const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiDownloadProfileWithDefaultSMDPAddress");
|
||||
|
||||
// Reset DownloadProfileResult if defined
|
||||
if (ptrDownloadProfileResult != NULL)
|
||||
{
|
||||
ptrDownloadProfileResult->countProfileInstalled = 0;
|
||||
ptrDownloadProfileResult->countProfileTotal = 0;
|
||||
}
|
||||
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerDownloadProfileWithDefaultSMDPAddress(ptrLpaEventCallback, ptrDownloadProfileResult);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiDownloadProfileWithSMDSAddress(const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiDownloadProfileWithSMDSAddress");
|
||||
|
||||
// Reset DownloadProfileResult if defined
|
||||
if (ptrDownloadProfileResult != NULL)
|
||||
{
|
||||
ptrDownloadProfileResult->countProfileInstalled = 0;
|
||||
ptrDownloadProfileResult->countProfileTotal = 0;
|
||||
}
|
||||
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerDownloadProfileWithSMDSAddress(ptrLpaEventCallback, ptrDownloadProfileResult);
|
||||
}
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
if (res) // manage error during cleanup
|
||||
res = resCleanup;
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Redirection
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Set new Nickname field in profile identified by ICCID.
|
||||
* @param ptrProfileID Profile ICCI size, raw format
|
||||
* @param profileIdSize Profile ICCID size, size_t
|
||||
* @param ptrNickname New Nickname to set, raw hex format
|
||||
* @param nickNameSize New Nickname size, size_t
|
||||
* @return true is nickname change operation successful
|
||||
*/
|
||||
UT_EXPORT_DLL bool lpaManagerApiSetNickname(const unsigned char* ptrProfileId, size_t profileIdSize, const unsigned char* ptrNickname, size_t nickNameSize)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiSetNickname");
|
||||
// In first, connect reader (if not yet connected) and select ISDR (if not yet selected)
|
||||
if (_lpaManagerApiConnectReaderAndSelectISDR())
|
||||
{
|
||||
res = lpaManagerSetNickname(ptrProfileId, profileIdSize, ptrNickname, nickNameSize);
|
||||
}
|
||||
|
||||
// At the end, unselect ISDR (if selected) and disconnect reader (if connected)
|
||||
bool resCleanup = _lpaManagerApiUnselectISDRAndDisconnectReader();
|
||||
|
||||
// manage error during cleanup
|
||||
if (res)
|
||||
res = resCleanup;
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Redirection
|
||||
/////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiSEMediaManagerIsInitialized()
|
||||
{
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiSEMediaManagerIsInitialized");
|
||||
|
||||
bool res = lpaManagerSEMediaManagerIsInitialized();
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Redirection
|
||||
/////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiSEMediaManagerUninitialize()
|
||||
{
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiSEMediaManagerUninitialize");
|
||||
|
||||
bool res = lpaManagerSEMediaManagerUninitialize();
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Redirection
|
||||
/////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiHttpMediaManagerIsInitialized()
|
||||
{
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiHttpMediaManagerIsInitialized");
|
||||
|
||||
bool res = lpaManagerHttpMediaManagerIsInitialized();
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Redirection
|
||||
/////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL bool lpaManagerApiHttpMediaManagerDelete()
|
||||
{
|
||||
LPA_MANAGER_API_BEGIN("lpaManagerApiHttpMediaManagerDelete");
|
||||
|
||||
bool res = lpaManagerHttpMediaManagerDelete();
|
||||
|
||||
LPA_MANAGER_API_END();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
bool _lpaManagerApiConnectReaderAndSelectISDR()
|
||||
{
|
||||
return lpaManagerConnectReaderAndSelectISDR();
|
||||
}
|
||||
|
||||
bool _lpaManagerApiUnselectISDRAndDisconnectReader()
|
||||
{
|
||||
return lpaManagerUnselectISDRAndDisconnectReader();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,422 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lpasdk/core/lpa_manager_helper.h"
|
||||
#include "lpasdk/core/lpa_manager.h"
|
||||
#include "lpasdk/core/semedia_manager.h"
|
||||
|
||||
#include "lpasdk/core/lpa_log.h"
|
||||
#include "lpasdk/core/lpa_memory.h"
|
||||
#include "lpasdk/core/util.h"
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
|
||||
static const unsigned char APDU_COMMAND_STORE_DATA_PROFILE_CASE3_HEADER[] = { 0x80, 0xE2, 0x90, 0x00, 0x00 };
|
||||
static const unsigned char APDU_COMMAND_STORE_DATA_PROFILE_CASE4_HEADER[] = { 0x80, 0xE2, 0x91, 0x00, 0x00 };
|
||||
|
||||
static unsigned char _apduResponseBytes[MAX_LPA_MANAGER_APDU_BUFFER_SIZE];
|
||||
|
||||
static char _bufferFormatLogMessage[2018];
|
||||
|
||||
static bool _addLeToApuCase4 = true;
|
||||
|
||||
bool _buildAndSendApduCase4(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void lpaManagerHelperSetLeToAddApduCase4(bool enable)
|
||||
{
|
||||
_addLeToApuCase4 = enable;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool lpaManagerHelperIsLeAddedToApduCase4()
|
||||
{
|
||||
return _addLeToApuCase4;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool buildAndSendStoreDataCase3WithoutResponseData(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "buildAndSendStoreDataCase3WithoutResponseData(...)");
|
||||
return buildAndSendStoreDataCase3(ptrRawDataObject, ptrSW, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
bool buildAndSendStoreDataCase3(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "buildAndSendStoreDataCase3(...)");
|
||||
if (ptrRawDataObject != NULL && ptrSW != NULL)
|
||||
{
|
||||
if (ptrRawDataObject->rawDataSize <= LPA_STORE_DATA_APDU_DATA_SIZE_MAX)
|
||||
{
|
||||
RawDataObject* apduStoreDataHeader = rawDataObject_create(APDU_COMMAND_STORE_DATA_PROFILE_CASE3_HEADER, sizeof(APDU_COMMAND_STORE_DATA_PROFILE_CASE3_HEADER));
|
||||
if (apduStoreDataHeader != NULL)
|
||||
{
|
||||
// Add data
|
||||
RawDataObject* apduStoreData = rawDataObject_concat(apduStoreDataHeader, ptrRawDataObject);
|
||||
if (apduStoreData != NULL)
|
||||
{
|
||||
size_t apduResponseMaxSize = MAX_LPA_MANAGER_APDU_BUFFER_SIZE;
|
||||
|
||||
if (apduStoreData->rawDataSize > 4)
|
||||
{
|
||||
// Update LE
|
||||
apduStoreData->rawData[4] = (unsigned char) ptrRawDataObject->rawDataSize;
|
||||
|
||||
if (formatBytesToHexaString(apduStoreData->rawData, apduStoreData->rawDataSize, _bufferFormatLogMessage, sizeof(_bufferFormatLogMessage)) > 0)
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "StoreData APDU (case 3): %s", _bufferFormatLogMessage);
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "StoreData APDU (case 3): ...");
|
||||
|
||||
// Send APDU
|
||||
if (seMediaManagerTransmitApdu(apduStoreData->rawData, apduStoreData->rawDataSize, _apduResponseBytes, &apduResponseMaxSize))
|
||||
{
|
||||
if (apduResponseMaxSize >= 2)
|
||||
{
|
||||
// APDU successfully sent
|
||||
*ptrSW = _apduResponseBytes[apduResponseMaxSize - 2] << 8 | _apduResponseBytes[apduResponseMaxSize - 1];
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "StoreData APDU SW: %04lX", *ptrSW);
|
||||
res = true;
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "APDU response too short!");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "APDU sending through seMedia Manager failed!");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "apduStoreData object too small: APDU not send!");
|
||||
|
||||
ERASE_RAWDATAOBJECT(apduStoreData);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "buildAndSendStoreDataCase3() - apduStoreData NULL!");
|
||||
|
||||
// Do cleanup
|
||||
ERASE_RAWDATAOBJECT(apduStoreDataHeader);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "buildAndSendStoreDataCase3() - apduStoreDataHeader NULL!");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Need to split APDU on many APDU - To be developed if needed
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Sending more than one APDU for StoreDataCase3 not yet implemented");
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "buildAndSendStoreDataCase3() - Invalid NULL parameter!");
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "buildAndSendStoreDataCase3(...) => return %s", (res ? "true" : "false"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool buildAndSendStoreDataCase4WithoutResponseData(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "buildAndSendStoreDataCase4WithoutResponseData(...)");
|
||||
res = buildAndSendStoreDataCase4(ptrRawDataObject, ptrSW, NULL, 0, NULL);
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "buildAndSendStoreDataCase4WithoutResponseData(...) => return %s", (res ? "true" : "false"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool buildAndSendStoreDataCase4(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "buildAndSendStoreDataCase4(...)");
|
||||
|
||||
// ptrResponseApduData & ptrResponseApduDataSize NULL checking is managed in buildAndSendApduCase4()
|
||||
if (ptrRawDataObject != NULL && ptrSW != NULL)
|
||||
{
|
||||
if (ptrRawDataObject->rawDataSize > 0 && ptrRawDataObject->rawData != NULL)
|
||||
{
|
||||
RawDataObject* apduStoreDataHeader = rawDataObject_create(APDU_COMMAND_STORE_DATA_PROFILE_CASE4_HEADER, sizeof(APDU_COMMAND_STORE_DATA_PROFILE_CASE4_HEADER));
|
||||
if (apduStoreDataHeader != NULL)
|
||||
{
|
||||
if (ptrRawDataObject->rawDataSize <= LPA_STORE_DATA_APDU_DATA_SIZE_MAX)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "Sending StoreData in one APDU...");
|
||||
|
||||
// add data
|
||||
RawDataObject* ptrApduStoreData = rawDataObject_concat(apduStoreDataHeader, ptrRawDataObject);
|
||||
if (ptrApduStoreData != NULL)
|
||||
{
|
||||
if (ptrApduStoreData->rawDataSize > 4)
|
||||
{
|
||||
// Update Lc
|
||||
ptrApduStoreData->rawData[4] = (unsigned char) ptrRawDataObject->rawDataSize;
|
||||
res = buildAndSendApduCase4(ptrApduStoreData, ptrSW, ptrResponseApduData, responseApduDataMaxSize, ptrResponseApduDataSize);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "buildAndSendStoreDataCase4() - apduStoreData object too small: APDU not send!");
|
||||
|
||||
// Do memory cleanup
|
||||
ERASE_RAWDATAOBJECT(ptrApduStoreData);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "buildAndSendStoreDataCase4() - apduStoreData object NULL: APDU not send!");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isLastBlock = false;
|
||||
uint8_t blockNumber = 0;
|
||||
size_t dataSizeAlreadySend = 0;
|
||||
size_t blockSize = 0;
|
||||
bool isErrorDetected = false;
|
||||
|
||||
// Need to split Data on many APDU
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "Sending StoreData with more than one APDU...");
|
||||
|
||||
while (!isLastBlock)
|
||||
{
|
||||
|
||||
size_t remainingSize = ptrRawDataObject->rawDataSize - dataSizeAlreadySend;
|
||||
if (remainingSize <= LPA_STORE_DATA_APDU_DATA_SIZE_MAX)
|
||||
{
|
||||
isLastBlock = true;
|
||||
blockSize = remainingSize;
|
||||
}
|
||||
else
|
||||
blockSize = LPA_STORE_DATA_APDU_DATA_SIZE_MAX;
|
||||
|
||||
// add data
|
||||
RawDataObject* apduStoreData = rawDataObject_concatPartially(apduStoreDataHeader, ptrRawDataObject, dataSizeAlreadySend, blockSize);
|
||||
if (apduStoreData == NULL)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "buildAndSendStoreDataCase4() - Insufficient memory resources!");
|
||||
break; // Memory allocation error
|
||||
}
|
||||
|
||||
if (apduStoreData->rawDataSize > 4)
|
||||
{
|
||||
// Update P1
|
||||
if (isLastBlock)
|
||||
apduStoreData->rawData[2] = 0x91; // Last block
|
||||
else
|
||||
apduStoreData->rawData[2] = 0x11; //Not the last block
|
||||
|
||||
// Update P2
|
||||
apduStoreData->rawData[3] = blockNumber;
|
||||
|
||||
// Update Lc
|
||||
apduStoreData->rawData[4] = (unsigned char) blockSize;
|
||||
res = buildAndSendApduCase4(apduStoreData, ptrSW, ptrResponseApduData, responseApduDataMaxSize, ptrResponseApduDataSize);
|
||||
if (!res)
|
||||
isErrorDetected = true; // Error when sending APDU
|
||||
|
||||
dataSizeAlreadySend += blockSize;
|
||||
blockNumber++;
|
||||
}
|
||||
else
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "buildAndSendStoreDataCase4() - apduStoreData object too small: APDU not send!");
|
||||
isErrorDetected = true;
|
||||
}
|
||||
|
||||
// Do memory cleanup
|
||||
ERASE_RAWDATAOBJECT(apduStoreData);
|
||||
|
||||
if (isErrorDetected)
|
||||
{
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do memory cleanup
|
||||
ERASE_RAWDATAOBJECT(apduStoreDataHeader);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "buildAndSendStoreDataCase4() - Invalid NULL APDU header!");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "buildAndSendStoreDataCase4() - Invalid NULL or zero length parameter!");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "buildAndSendStoreDataCase4() - Invalid NULL parameter!");
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "buildAndSendStoreDataCase4(...) => return %s", (res ? "true" : "false"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool buildAndSendApduCase4(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "buildAndSendApduCase4(...)");
|
||||
|
||||
res = _buildAndSendApduCase4(ptrRawDataObject, ptrSW, ptrResponseApduData, responseApduDataMaxSize, ptrResponseApduDataSize);
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "buildAndSendApduCase4(...) => return %s", (res ? "true" : "false"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool buildAndSendApduCase4Ex(const unsigned char* ptrApduC, uint16_t apduCSize, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "buildAndSendApduCase4Ex(...)");
|
||||
|
||||
// create temporary RawDataObject without dynamic allocation
|
||||
RawDataObject rawDataObjectApduC;
|
||||
rawDataObjectApduC.rawData = (unsigned char*) ptrApduC;
|
||||
rawDataObjectApduC.rawDataSize = apduCSize;
|
||||
|
||||
res = _buildAndSendApduCase4(&rawDataObjectApduC, ptrSW, ptrResponseApduData, responseApduDataMaxSize, ptrResponseApduDataSize);
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "buildAndSendApduCase4Ex(...) => return %s", (res ? "true" : "false"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _buildAndSendApduCase4(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "_buildAndSendApduCase4(...)");
|
||||
|
||||
if (ptrRawDataObject != NULL && ptrSW != NULL && ptrResponseApduDataSize != NULL)
|
||||
{
|
||||
bool apduSend = false;
|
||||
size_t apduResponseMaxSize = MAX_LPA_MANAGER_APDU_BUFFER_SIZE;
|
||||
|
||||
if (!_addLeToApuCase4)
|
||||
{
|
||||
if (formatBytesToHexaString(ptrRawDataObject->rawData, ptrRawDataObject->rawDataSize, _bufferFormatLogMessage, sizeof(_bufferFormatLogMessage)) > 0)
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "APDU (without adding Le): %s", _bufferFormatLogMessage);
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "APDU (without adding Le): ...");
|
||||
|
||||
apduSend = seMediaManagerTransmitApdu(ptrRawDataObject->rawData, ptrRawDataObject->rawDataSize, _apduResponseBytes, &apduResponseMaxSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
RawDataObject* rawDataObjectWithZeroFinal = NULL;
|
||||
RawDataObject* apduCase4WithLe = NULL;
|
||||
|
||||
// Add '00' at the end (for case 4)
|
||||
unsigned char byteZero = 0x00;
|
||||
|
||||
rawDataObjectWithZeroFinal = rawDataObject_create(&byteZero, 1);
|
||||
if (rawDataObjectWithZeroFinal != NULL)
|
||||
apduCase4WithLe = rawDataObject_concat(ptrRawDataObject, rawDataObjectWithZeroFinal);
|
||||
|
||||
if (apduCase4WithLe != NULL)
|
||||
{
|
||||
if (formatBytesToHexaString(apduCase4WithLe->rawData, apduCase4WithLe->rawDataSize, _bufferFormatLogMessage, sizeof(_bufferFormatLogMessage)) > 0)
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "APDU (case 4 with Le added): %s", _bufferFormatLogMessage);
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "APDU (case 4 with Le added): ...");
|
||||
|
||||
apduSend = seMediaManagerTransmitApdu(apduCase4WithLe->rawData, apduCase4WithLe->rawDataSize, _apduResponseBytes, &apduResponseMaxSize);
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Failed to build apduCase4WithLe object!");
|
||||
|
||||
// Do memory cleanup
|
||||
ERASE_RAWDATAOBJECT(rawDataObjectWithZeroFinal);
|
||||
ERASE_RAWDATAOBJECT(apduCase4WithLe);
|
||||
}
|
||||
|
||||
if (apduSend)
|
||||
{
|
||||
if (apduResponseMaxSize >= 2)
|
||||
{
|
||||
// APDU successfully sent
|
||||
*ptrSW = _apduResponseBytes[apduResponseMaxSize - 2] << 8 | _apduResponseBytes[apduResponseMaxSize - 1];
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "APDU SW: %04lX", *ptrSW);
|
||||
|
||||
if ((ptrResponseApduData != NULL) && (responseApduDataMaxSize > 0) && (ptrResponseApduDataSize != NULL))
|
||||
{
|
||||
size_t dataSize = apduResponseMaxSize - 2;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "Managing data response...");
|
||||
|
||||
// Managing data response => copy data from APDU Response
|
||||
*ptrResponseApduDataSize = 0;
|
||||
|
||||
if (dataSize > 0)
|
||||
{
|
||||
// Data available
|
||||
if (dataSize <= responseApduDataMaxSize)
|
||||
{
|
||||
memcpy(ptrResponseApduData, _apduResponseBytes, dataSize);
|
||||
*ptrResponseApduDataSize = dataSize;
|
||||
res = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Data buffer size to small (Maximum allowed:%llu bytes - needed:%llu bytes)", (long long unsigned)responseApduDataMaxSize, (long long unsigned)dataSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No data
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "No data available from R-APDU");
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not managing data response
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
apduSend = false; // SW is empty / incomplete or incorrect data (Too short to be a SW, can be data corruption or error detected at lower layer)
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Incorrect data or invalid SW or error! (Too short response < 2)");
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "APDU sending operation through seMedia failed!");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_buildAndSendApduCase4() - Invalid NULL parameter!");
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "_buildAndSendApduCase4(...) => return %s", (res ? "true" : "false"));
|
||||
|
||||
return res;
|
||||
}
|
1194
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/src/core/lpa_memory.c
Executable file
1194
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/src/core/lpa_memory.c
Executable file
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,534 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lpasdk/core/rawdata_object.h"
|
||||
#include "lpasdk/core/lpa_memory.h"
|
||||
#include "lpasdk/core/lpa_log.h"
|
||||
#include "lpasdk/core/util.h"
|
||||
#include <memory.h>
|
||||
|
||||
//RawDataObject* rawDataObject_allocate();
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Create RawDataObject object structure in memory, and initializes its internal structure (Data points to NULL, size = 0)
|
||||
* @return Pointer on newly created RawDataObject object, else NULL if failed
|
||||
*/
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_allocate()
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "rawDataObject_allocate()");
|
||||
|
||||
RawDataObject* ptrRawDataObject = lpaCoreMemoryAlloc(sizeof(RawDataObject));
|
||||
if (ptrRawDataObject != NULL)
|
||||
{
|
||||
ptrRawDataObject->rawData = NULL;
|
||||
ptrRawDataObject->rawDataSize = 0;
|
||||
}
|
||||
|
||||
return ptrRawDataObject;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Create RawDataObject object from bytes field and size
|
||||
* @param ptrRawData Pointer on data bytes field to store
|
||||
* @param rawDataSize Size of data bytes field, size_t format
|
||||
* @return Pointer on newly created RawDataObject object, else NULL if failed
|
||||
*/
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_create(const unsigned char* ptrRawData, size_t rawDataSize)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "rawDataObject_create()");
|
||||
|
||||
RawDataObject* ptrRawDataObject = rawDataObject_allocate();
|
||||
if (ptrRawDataObject != NULL)
|
||||
{
|
||||
if (ptrRawData != NULL && rawDataSize > 0)
|
||||
{
|
||||
ptrRawDataObject->rawData = lpaCoreMemoryAlloc(rawDataSize);
|
||||
if (ptrRawDataObject->rawData != NULL)
|
||||
{
|
||||
memcpy(ptrRawDataObject->rawData, ptrRawData, rawDataSize);
|
||||
ptrRawDataObject->rawDataSize = rawDataSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Memory allocation error: Release allocated memory
|
||||
lpaCoreMemoryFree(ptrRawDataObject);
|
||||
ptrRawDataObject = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ptrRawDataObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create RawDataObject object from bytes field and size, but store data with header including size, as LV coded object
|
||||
* @param ptrRawData Pointer on data bytes field to store
|
||||
* @param rawDataSize Size of data bytes field, size_t format
|
||||
* @return Pointer on newly created RawDataObject object, else NULL if failed
|
||||
*/
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_createAsLV(const unsigned char* ptrRawData, size_t rawDataSize)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "rawDataObject_createAsLV()");
|
||||
|
||||
RawDataObject* ptrRawDataObject = NULL;
|
||||
if (ptrRawData != NULL && rawDataSize > 0)
|
||||
{
|
||||
ptrRawDataObject = rawDataObject_allocate();
|
||||
if (ptrRawDataObject != NULL)
|
||||
{
|
||||
size_t nbBytesLength = rawDataSize <= 0x7F ? 1 : (rawDataSize <= 0xFF ? 2 : (rawDataSize <= 0xFFFF ? 3 : 4));
|
||||
size_t totalRawDataObjectSize = nbBytesLength + rawDataSize;
|
||||
|
||||
ptrRawDataObject->rawData = lpaCoreMemoryAlloc(totalRawDataObjectSize);
|
||||
if (ptrRawDataObject->rawData != NULL)
|
||||
{
|
||||
switch (nbBytesLength)
|
||||
{
|
||||
case 1:
|
||||
ptrRawDataObject->rawData[0] = (unsigned char)rawDataSize;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
ptrRawDataObject->rawData[0] = 0x81;
|
||||
ptrRawDataObject->rawData[1] = (unsigned char)rawDataSize;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
ptrRawDataObject->rawData[0] = 0x82;
|
||||
ptrRawDataObject->rawData[1] = (rawDataSize >> 8) & 0xFF;
|
||||
ptrRawDataObject->rawData[2] = rawDataSize & 0x00FF;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
ptrRawDataObject->rawData[0] = 0x83;
|
||||
ptrRawDataObject->rawData[1] = (rawDataSize >> 16) & 0xFF;
|
||||
ptrRawDataObject->rawData[2] = (rawDataSize >> 8) & 0xFF;
|
||||
ptrRawDataObject->rawData[3] = rawDataSize & 0x00FF;
|
||||
break;
|
||||
}
|
||||
|
||||
memcpy(&ptrRawDataObject->rawData[nbBytesLength], ptrRawData, rawDataSize);
|
||||
ptrRawDataObject->rawDataSize = totalRawDataObjectSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Memory allocation error: Release allocated memory
|
||||
lpaCoreMemoryFree(ptrRawDataObject);
|
||||
ptrRawDataObject = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ptrRawDataObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create RawDataObject object from Base64 encoded data. Output RawDataObjet will be stored in hex format, decoded from Base64
|
||||
* @param ptrBase64Data Pointer on Base64 data to decode and store
|
||||
* @param base64DataSize Size of Base64 data
|
||||
* @param maximumRawdataSize Maximum size allowed for Output RawDataObjet. If size = 0, no limit will be applied
|
||||
* @return Pointer on newly created RawDataObject object, else NULL if failed or empty data given
|
||||
*/
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_createFromBase64(const char* ptrBase64Data, const size_t base64DataSize, const size_t maximumRawdataSize)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "rawDataObject_createFromBase64()");
|
||||
|
||||
RawDataObject* ptrRawDataObject = NULL;
|
||||
|
||||
size_t rawDataObjectSize = 0; // For RawDataObjet payload allocation in advance
|
||||
|
||||
if(ptrBase64Data != NULL && base64DataSize > 0)
|
||||
{
|
||||
// Calculate decoded size from Base64. Normally "/ 4 * 3" shall be enough but add 1 by security
|
||||
rawDataObjectSize = base64DataSize / 4 * 3 + 1;
|
||||
|
||||
// Check maximum size specified. If equal 0 no limitation will be applied
|
||||
if(maximumRawdataSize == 0 || rawDataObjectSize < maximumRawdataSize)
|
||||
{
|
||||
// Create RawDataObject. Done by advance to avoid creation of intermediate buffer and save memory
|
||||
ptrRawDataObject = rawDataObject_allocate();
|
||||
if(ptrRawDataObject != NULL)
|
||||
{
|
||||
// Reserve memory buffer for raw data object payload
|
||||
ptrRawDataObject->rawData = lpaCoreMemoryAlloc(rawDataObjectSize);
|
||||
if(ptrRawDataObject->rawData != NULL)
|
||||
{
|
||||
// Convert Base64 object in raw hex and store it directly in rawDataObject. In case of failure, destroy created RawDataObject
|
||||
if(! base64_decode(ptrBase64Data, base64DataSize, ptrRawDataObject->rawData, &ptrRawDataObject->rawDataSize, rawDataObjectSize))
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "rawDataObject_createFromBase64: Failed to decode Base64 data!");
|
||||
lpaCoreMemoryFree(ptrRawDataObject->rawData);
|
||||
lpaCoreMemoryFree(ptrRawDataObject);
|
||||
ptrRawDataObject = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "rawDataObject_createFromBase64: Failed to allocate memory for RawDataObject data area!");
|
||||
lpaCoreMemoryFree(ptrRawDataObject);
|
||||
ptrRawDataObject = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "rawDataObject_createFromBase64: Failed to create RawDataObject!");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "rawDataObject_createFromBase64: Decoded data size (%llu bytes) exceed maximum allowed (%llu bytes)!",
|
||||
(long long unsigned)rawDataObjectSize, (long long unsigned)maximumRawdataSize);
|
||||
}
|
||||
|
||||
return ptrRawDataObject;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Concatenates 2 RawDataObject objects in an unique RawDataObject object, first Object 1 then Object 2
|
||||
* @param ptrRawDataObject1 Pointer on Object 1 to concatenate, RawDataObject type
|
||||
* @param ptrRawDataObject2 Pointer on Object 2 to concatenate, RawDataObject type
|
||||
* @return Pointer on newly created RawDataObject object storing both concatenated input objects, else NULL if failed
|
||||
*/
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_concat(const RawDataObject* ptrRawDataObject1, const RawDataObject*ptrRawDataObject2)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "rawDataObject_concat()");
|
||||
|
||||
RawDataObject* ptrRawDataObject = rawDataObject_allocate();
|
||||
if (ptrRawDataObject != NULL)
|
||||
{
|
||||
size_t rawDataSize1 = ((ptrRawDataObject1 != NULL && ptrRawDataObject1->rawData != NULL) ? ptrRawDataObject1->rawDataSize : 0);
|
||||
size_t rawDataSize2 = ((ptrRawDataObject2 != NULL && ptrRawDataObject2->rawData != NULL) ? ptrRawDataObject2->rawDataSize : 0);
|
||||
size_t rawDataSize = rawDataSize1 + rawDataSize2;
|
||||
|
||||
if ((rawDataSize1 + rawDataSize2) > 0)
|
||||
{
|
||||
ptrRawDataObject->rawData = lpaCoreMemoryAlloc(rawDataSize);
|
||||
if (ptrRawDataObject->rawData != NULL)
|
||||
{
|
||||
if (rawDataSize1 > 0)
|
||||
memcpy(ptrRawDataObject->rawData, ptrRawDataObject1->rawData, rawDataSize1);
|
||||
|
||||
if (rawDataSize2 > 0)
|
||||
memcpy(&ptrRawDataObject->rawData[rawDataSize1], ptrRawDataObject2->rawData, rawDataSize2);
|
||||
|
||||
ptrRawDataObject->rawDataSize = rawDataSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Memory allocation error: Release allocated memory
|
||||
lpaCoreMemoryFree(ptrRawDataObject);
|
||||
ptrRawDataObject = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ptrRawDataObject;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Concatenates a RawDataObject object and a raw data array in an unique RawDataObject object, first RawDataObject object then raw data array.
|
||||
* Note 1: If one object is NULL (Including data of RawDataObject object) or empty, output RawDataObject object will only store other not NULL / empty object.
|
||||
* Note 2: If both objects are NULL / empty, output RawDataObject object will be empty.
|
||||
* @param ptrRawDataObjectInput1 Pointer on RawDataObject object to concatenate
|
||||
* @param ptrRawDataInput2 Pointer on raw data array to concatenate
|
||||
* @param rawDataSizeInput2 Size of raw data array to concatenate
|
||||
* @return Pointer on newly created RawDataObject object storing both concatenated input objects, else NULL if failed
|
||||
*/
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_concatRawDataArray(const RawDataObject* ptrRawDataObjectInput1, const unsigned char* ptrRawDataInput2, size_t rawDataSizeInput2)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "rawDataObject_concatRawDataArray()");
|
||||
|
||||
RawDataObject* ptrRawDataObjectOutput = rawDataObject_allocate();
|
||||
if (ptrRawDataObjectOutput != NULL)
|
||||
{
|
||||
size_t rawDataSize1 = ((ptrRawDataObjectInput1 != NULL && ptrRawDataObjectInput1->rawData != NULL) ? ptrRawDataObjectInput1->rawDataSize : 0);
|
||||
size_t rawDataSize2 = (ptrRawDataInput2 != NULL ? rawDataSizeInput2 : 0);
|
||||
size_t rawDataSize = rawDataSize1 + rawDataSize2;
|
||||
|
||||
if ((rawDataSize1 + rawDataSize2) > 0)
|
||||
{
|
||||
ptrRawDataObjectOutput->rawData = lpaCoreMemoryAlloc(rawDataSize);
|
||||
if (ptrRawDataObjectOutput->rawData != NULL)
|
||||
{
|
||||
if (rawDataSize1 > 0)
|
||||
memcpy(ptrRawDataObjectOutput->rawData, ptrRawDataObjectInput1->rawData, rawDataSize1);
|
||||
|
||||
if (rawDataSize2 > 0)
|
||||
memcpy(&ptrRawDataObjectOutput->rawData[rawDataSize1], ptrRawDataInput2, rawDataSize2);
|
||||
|
||||
ptrRawDataObjectOutput->rawDataSize = rawDataSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Memory allocation error: Release allocated memory
|
||||
lpaCoreMemoryFree(ptrRawDataObjectOutput);
|
||||
ptrRawDataObjectOutput = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ptrRawDataObjectOutput;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Append raw data array to an existing RawDataObject object. If data array pointer is NULL AND its size = 0 operation will still be considered as successful
|
||||
* @param ptrRawDataObjectSource Pointer on RawDataObject object. If NULL operation will be canceled / failed.
|
||||
* @param ptrRawDataAppend Pointer on raw data array to append.
|
||||
* @param rawDataSizeAppend Size of raw data to append, size_t format.
|
||||
* @return true if operation is successful, else false
|
||||
*/
|
||||
UT_EXPORT_DLL bool rawDataObject_appendRawDataArray(RawDataObject* ptrRawDataObjectSource, const unsigned char* ptrRawDataAppend, size_t rawDataSizeAppend)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "rawDataObject_appendRawDataArray()");
|
||||
if (ptrRawDataObjectSource != NULL && ptrRawDataAppend != NULL && rawDataSizeAppend > 0 )
|
||||
{
|
||||
size_t rawDataSize1 = (ptrRawDataObjectSource->rawData != NULL ? ptrRawDataObjectSource->rawDataSize : 0);
|
||||
size_t rawDataSize2 = (ptrRawDataAppend != NULL ? rawDataSizeAppend : 0);
|
||||
size_t rawDataSize = rawDataSize1 + rawDataSize2;
|
||||
|
||||
if ((rawDataSize1 + rawDataSize2) > 0)
|
||||
{
|
||||
// 1) create new buffer with all data
|
||||
unsigned char* ptrNewRawData = lpaCoreMemoryAlloc(rawDataSize);
|
||||
if (ptrNewRawData != NULL)
|
||||
{
|
||||
if (rawDataSize1 > 0)
|
||||
memcpy(ptrNewRawData, ptrRawDataObjectSource->rawData, rawDataSize1);
|
||||
|
||||
if (rawDataSize2 > 0)
|
||||
memcpy(&ptrNewRawData[rawDataSize1], ptrRawDataAppend, rawDataSizeAppend);
|
||||
|
||||
// Free old buffer
|
||||
if (ptrRawDataObjectSource->rawData != NULL)
|
||||
lpaCoreMemoryFree(ptrRawDataObjectSource->rawData);
|
||||
|
||||
// Update RawData object source
|
||||
ptrRawDataObjectSource->rawData = ptrNewRawData;
|
||||
ptrRawDataObjectSource->rawDataSize = rawDataSize;
|
||||
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If Raw Data to happen is completely void, we consider result successful
|
||||
if (ptrRawDataAppend == NULL && rawDataSizeAppend == 0)
|
||||
res = true; // No data to append
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Concatenate data of RawDataObject object 1 and a selected area of data in RawDataObject object 2
|
||||
* Note 1: If one object is NULL (Including data of RawDataObject object) or empty, output RawDataObject object will only store target data of other not NULL / empty object.
|
||||
* Note 2: If both objects are NULL / empty, output RawDataObject object will be empty.
|
||||
* @param ptrRawDataObject1 Pointer on Object 1 to concatenate, RawDataObject type.
|
||||
* @param ptrRawDataObject2 Pointer on Object 2 to concatenate partially, RawDataObject type.
|
||||
* @param offset Starting offset for data concatenation from object 2, size_t format. If greater that size of Object 2, output RawDataObject object will only contain object 1.
|
||||
* @param length Length of data to concatenate from object 2, size_t format. If offset + length exceeds object 2 data length, length will be adjusted to max available in object 2.
|
||||
* @return Pointer on newly created RawDataObject object storing both concatenated input objects, else NULL if failed
|
||||
*/
|
||||
UT_EXPORT_DLL RawDataObject* rawDataObject_concatPartially(const RawDataObject* ptrRawDataObject1, const RawDataObject*ptrRawDataObject2, size_t offset, size_t length)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "rawDataObject_concatPartially()");
|
||||
|
||||
RawDataObject* ptrRawDataObject = rawDataObject_allocate();
|
||||
if (ptrRawDataObject != NULL)
|
||||
{
|
||||
size_t rawDataSize1 = ((ptrRawDataObject1 != NULL && ptrRawDataObject1->rawData != NULL) ? ptrRawDataObject1->rawDataSize : 0);
|
||||
size_t rawDataSize2 = ((ptrRawDataObject2 != NULL && ptrRawDataObject2->rawData != NULL) ? ptrRawDataObject2->rawDataSize : 0);
|
||||
size_t rawPartialSize2 = 0;
|
||||
|
||||
if (offset < rawDataSize2)
|
||||
{
|
||||
if (offset + length <= rawDataSize2)
|
||||
rawPartialSize2 = length;
|
||||
else
|
||||
rawPartialSize2 = rawDataSize2 - offset;
|
||||
}
|
||||
size_t rawDataSize = rawDataSize1 + rawPartialSize2;
|
||||
|
||||
if (rawDataSize > 0)
|
||||
{
|
||||
ptrRawDataObject->rawData = lpaCoreMemoryAlloc(rawDataSize);
|
||||
if (ptrRawDataObject->rawData != NULL)
|
||||
{
|
||||
if (rawDataSize1 > 0)
|
||||
memcpy(ptrRawDataObject->rawData, ptrRawDataObject1->rawData, rawDataSize1);
|
||||
|
||||
if (rawPartialSize2 > 0)
|
||||
memcpy(&ptrRawDataObject->rawData[rawDataSize1], &ptrRawDataObject2->rawData[offset], rawPartialSize2);
|
||||
|
||||
ptrRawDataObject->rawDataSize = rawDataSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Memory allocation error: Release allocated memory
|
||||
lpaCoreMemoryFree(ptrRawDataObject);
|
||||
ptrRawDataObject = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ptrRawDataObject;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Update RawDataObject object with new data content
|
||||
* @param ptrRawDataObject pointer on RawDataObject object to update. If NULL operation is failed.
|
||||
* @param ptrRawData Pointer on new data to store in RawDataObject object. If NULL operation is failed, except if rawDataSize = 0
|
||||
* @param rawDataSize New size of data to store, size_t type. If < 1 RawDataObject object will be empty or leaved as it if new size = previous size.
|
||||
* @return true if RawDataObject object updated successfully, else false
|
||||
*/
|
||||
UT_EXPORT_DLL bool rawDataObject_update(RawDataObject* ptrRawDataObject, const unsigned char* ptrRawData, size_t rawDataSize)
|
||||
{
|
||||
bool doUpdate = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "rawDataObject_update()");
|
||||
|
||||
if (ptrRawDataObject != NULL)
|
||||
{
|
||||
// If old and new data have same size, do not allocate/free memory
|
||||
if (ptrRawDataObject->rawDataSize == rawDataSize)
|
||||
{
|
||||
doUpdate = true;
|
||||
if (rawDataSize > 0)
|
||||
{
|
||||
if(ptrRawData != NULL)
|
||||
memcpy(ptrRawDataObject->rawData, ptrRawData, rawDataSize);
|
||||
else
|
||||
doUpdate = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Old and new data have not same size => allocate new buffer before release old buffer
|
||||
if (rawDataSize > 0)
|
||||
{
|
||||
if (ptrRawData != NULL)
|
||||
{
|
||||
unsigned char* ptrNewRawData = lpaCoreMemoryAlloc(rawDataSize);
|
||||
if (ptrNewRawData != NULL)
|
||||
{
|
||||
memcpy(ptrNewRawData, ptrRawData, rawDataSize);
|
||||
|
||||
// Now release old buffer
|
||||
if (ptrRawDataObject->rawData != NULL)
|
||||
lpaCoreMemoryFree(ptrRawDataObject->rawData);
|
||||
|
||||
ptrRawDataObject->rawData = ptrNewRawData;
|
||||
ptrRawDataObject->rawDataSize = rawDataSize;
|
||||
|
||||
doUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No data => Clear memory if needed
|
||||
if (ptrRawDataObject->rawData != NULL)
|
||||
{
|
||||
lpaCoreMemoryFree(ptrRawDataObject->rawData);
|
||||
ptrRawDataObject->rawData = NULL;
|
||||
}
|
||||
|
||||
ptrRawDataObject->rawDataSize = 0;
|
||||
doUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return doUpdate;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Remove content of a RawDataObject object
|
||||
* @param ptrRawDataObject Pointer on RawDataObject object to clear
|
||||
*/
|
||||
|
||||
UT_EXPORT_DLL void rawDataObject_clear(RawDataObject* ptrRawDataObject)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "rawDataObject_clear()");
|
||||
|
||||
if (ptrRawDataObject != NULL)
|
||||
{
|
||||
if (ptrRawDataObject->rawData != NULL)
|
||||
{
|
||||
lpaCoreMemoryFree(ptrRawDataObject->rawData);
|
||||
ptrRawDataObject->rawData = NULL;
|
||||
}
|
||||
|
||||
ptrRawDataObject->rawDataSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Free memory used by RawDataObject object and affect object pointer to NULL
|
||||
* @param ptrRawDataObject Pointer on RawDataObject object to free
|
||||
*/
|
||||
UT_EXPORT_DLL void rawDataObject_free(RawDataObject* ptrRawDataObject)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "rawDataObject_free()");
|
||||
|
||||
if (ptrRawDataObject != NULL)
|
||||
{
|
||||
if (ptrRawDataObject->rawData != NULL )
|
||||
lpaCoreMemoryFree(ptrRawDataObject->rawData);
|
||||
lpaCoreMemoryFree(ptrRawDataObject);
|
||||
ptrRawDataObject = NULL;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "lpasdk/core/semedia_base.h"
|
||||
#include "lpasdk/core/lpa_log.h"
|
||||
#include "lpasdk/core/lpa_memory.h"
|
||||
|
||||
TSEMedia* New_SEMediaBase()
|
||||
{
|
||||
TSEMedia* ptrSEmediaBase = NULL;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "++New_SEMediaBase");
|
||||
|
||||
ptrSEmediaBase = lpaCoreMemoryAlloc(sizeof(TSEMedia));
|
||||
|
||||
if(ptrSEmediaBase != NULL)
|
||||
memset(ptrSEmediaBase, 0, sizeof(TSEMedia));
|
||||
|
||||
return ptrSEmediaBase;
|
||||
}
|
|
@ -0,0 +1,455 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "lpasdk/core/semedia_manager.h"
|
||||
#include "lpasdk/core/lpa_log.h"
|
||||
#include "lpasdk/lpasdk_internal_api.h"
|
||||
|
||||
#ifdef LPA_SDK__SEMEDIA_DRIVER_EXTERNAL
|
||||
#if defined(LPA_SDK__PLATFORM_WIN)
|
||||
#include "lpasdk/driver/semedia_external.h" // External (dynamic) driver
|
||||
#else
|
||||
#error "SE Media external driver only supported on WIN platform"
|
||||
#endif // LPA_SDK__PLATFORM_WIN
|
||||
#elif LPA_SDK__SEMEDIA_DRIVER_GENERIC_MODEM
|
||||
#include "lpasdk/driver/semedia_genericmodem.h" // Generic Modem driver
|
||||
#elif LPA_SDK__SEMEDIA_DRIVER_WINSCARD
|
||||
#if defined(LPA_SDK__PLATFORM_WIN) || defined(LPA_SDK__PLATFORM_CYGWIN) || defined(LPA_SDK__PLATFORM_RASPBIAN)
|
||||
#include "lpasdk/driver/semedia_winscard.h" // SE driver for Windows (using Winscard API) or Cygwin (using also Winscard API)
|
||||
#endif // LPA_SDK__PLATFORM_WIN || LPA_SDK__PLATFORM_CYGWIN || defined(LPA_SDK__PLATFORM_RASPBIAN)
|
||||
#else
|
||||
//#error "No SEMedia compilation option defined"
|
||||
#include "lpasdk/driver/semedia_winscard.h"
|
||||
#endif // LPA_SDK__SEMEDIA_DRIVER_EXTERNAL
|
||||
|
||||
|
||||
static TSEMedia* _seMedia = NULL;
|
||||
static bool _manageAutomatically61XX = true;
|
||||
static bool _manageAutomatically6CXX = false;
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL bool seMediaManagerInitialize()
|
||||
{
|
||||
bool initOk = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerInitialize()");
|
||||
|
||||
if (_seMedia == NULL)
|
||||
{
|
||||
#ifdef LPA_SDK__SEMEDIA_DRIVER_EXTERNAL
|
||||
_seMedia = New_SEMediaExternal();
|
||||
#elif LPA_SDK__SEMEDIA_DRIVER_GENERIC_MODEM
|
||||
_seMedia = New_SEMediaGenericModem();
|
||||
#elif LPA_SDK__SEMEDIA_DRIVER_WINSCARD
|
||||
#if defined(LPA_SDK__PLATFORM_WIN) || defined(LPA_SDK__PLATFORM_CYGWIN) || defined(LPA_SDK__PLATFORM_RASPBIAN)
|
||||
_seMedia = New_SEMediaWinSCard();
|
||||
#endif // LPA_SDK__PLATFORM_WIN || LPA_SDK__PLATFORM_CYGWIN
|
||||
#endif // LPA_SDK__SEMEDIA_DRIVER_GENERIC_MODEM
|
||||
|
||||
initOk = _seMedia != NULL;
|
||||
|
||||
if(! initOk)
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "seMediaManagerInitialize(): Unable to create _seMedia!");
|
||||
}
|
||||
|
||||
return initOk;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL bool seMediaManagerSetCallbackEventExecutionError(LPA_EVENT_EXECUTION_ERROR lpaEventExecutionErrorCallback)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerSetCallbackEventExecutionError()");
|
||||
|
||||
if (_seMedia != NULL)
|
||||
res = _seMedia->seMediaSetCallbackEventExecutionError(_seMedia, lpaEventExecutionErrorCallback);
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "-- seMediaManagerSetCallbackEventExecutionError() return %s", (res ? "true" : "false"));
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL bool seMediaManagerIsInitialized()
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerIsInitialized()");
|
||||
|
||||
return (_seMedia != NULL);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
UT_EXPORT_DLL bool seMediaManagerUninitialize()
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerUninitialize()");
|
||||
|
||||
if (_seMedia != NULL)
|
||||
{
|
||||
#ifdef LPA_SDK__SEMEDIA_DRIVER_EXTERNAL
|
||||
Delete_SEMediaExternal(_seMedia);
|
||||
#elif LPA_SDK__SEMEDIA_DRIVER_GENERIC_MODEM
|
||||
Delete_SEMediaGenericModem(_seMedia);
|
||||
#elif LPA_SDK__SEMEDIA_DRIVER_WINSCARD
|
||||
#if defined(LPA_SDK__PLATFORM_WIN) || defined(LPA_SDK__PLATFORM_CYGWIN)|| defined(LPA_SDK__PLATFORM_RASPBIAN)
|
||||
Delete_SEMediaWinSCard(_seMedia);
|
||||
#endif // LPA_SDK__PLATFORM_WIN || LPA_SDK__PLATFORM_CYGWIN
|
||||
#endif // LPA_SDK__SEMEDIA_DRIVER_GENERIC_MODEM
|
||||
_seMedia = NULL;
|
||||
res = true;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
bool seMediaManagerEstablishContext()
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerEstablishContext()");
|
||||
bool res = false;
|
||||
|
||||
if (_seMedia != NULL)
|
||||
{
|
||||
if( _seMedia->seMediaEstablishContext != NULL )
|
||||
res = _seMedia->seMediaEstablishContext(_seMedia);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
bool seMediaManagerReleaseContext()
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerReleaseContext()");
|
||||
bool res = false;
|
||||
|
||||
if (_seMedia != NULL)
|
||||
{
|
||||
if( _seMedia->seMediaReleaseContext != NULL )
|
||||
res = _seMedia->seMediaReleaseContext(_seMedia);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
bool seMediaManagerIsContextEstablished()
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerIsContextEstablished()");
|
||||
bool res = false;
|
||||
|
||||
if (_seMedia != NULL)
|
||||
{
|
||||
if( _seMedia->seMediaIsContextEstablished != NULL )
|
||||
res = _seMedia->seMediaIsContextEstablished(_seMedia);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
bool seMediaManagerIsValidContext()
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerIsValidContext()");
|
||||
bool res = false;
|
||||
|
||||
if (_seMedia != NULL)
|
||||
{
|
||||
if( _seMedia->seMediaIsValidContext != NULL )
|
||||
res = _seMedia->seMediaIsValidContext(_seMedia);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
bool seMediaManagerListReader(LPA_SE_MEDIA_READER_NAME_INFO * readerNameInfoList, size_t readerNameInfoMax, size_t* countReader)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerListReader()");
|
||||
bool res = false;
|
||||
|
||||
if (_seMedia != NULL && readerNameInfoList != NULL && countReader != NULL)
|
||||
{
|
||||
if( _seMedia->seMediaListReader != NULL )
|
||||
res = _seMedia->seMediaListReader(_seMedia, readerNameInfoList, readerNameInfoMax, countReader);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
bool seMediaManagerConnect(const char *readerName)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerConnect()");
|
||||
bool res = false;
|
||||
|
||||
if (_seMedia != NULL && readerName != NULL)
|
||||
{
|
||||
if( _seMedia->seMediaConnect != NULL )
|
||||
res = _seMedia->seMediaConnect(_seMedia, readerName);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
bool seMediaManagerIsConnected()
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerIsConnected()");
|
||||
bool res = false;
|
||||
|
||||
if (_seMedia != NULL)
|
||||
{
|
||||
if( _seMedia->seMediaIsConnected != NULL )
|
||||
res = _seMedia->seMediaIsConnected(_seMedia);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
bool seMediaManagerTransmitApdu(const unsigned char* apduCommandBytes, size_t apduCommandSize, unsigned char* apduResponseBytes, size_t* apduResponseMaxSize)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerTransmitApdu()");
|
||||
bool res = false;
|
||||
|
||||
if (_seMedia != NULL && apduCommandBytes != NULL && apduResponseBytes != NULL && apduResponseMaxSize != NULL)
|
||||
{
|
||||
size_t apduResponseSize = *apduResponseMaxSize;
|
||||
|
||||
if (_seMedia->seMediaTransmitApdu != NULL && seMediaManagerIsConnected() )
|
||||
{
|
||||
res = _seMedia->seMediaTransmitApdu(_seMedia, apduCommandBytes, apduCommandSize, apduResponseBytes, &apduResponseSize);
|
||||
|
||||
if (res)
|
||||
{
|
||||
if (apduResponseSize >= 2)
|
||||
{
|
||||
if (apduResponseBytes[apduResponseSize - 2] == 0x61)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "APDU R - SW is 61.XX type");
|
||||
|
||||
// Manage 61.XX
|
||||
if (_manageAutomatically61XX)
|
||||
{
|
||||
bool errorManaging61XX = false;
|
||||
bool endOfData = false;
|
||||
size_t totalDataSize = 0;
|
||||
size_t partialApduResponseSize = *apduResponseMaxSize;
|
||||
|
||||
unsigned char dataSizeRequested = apduResponseBytes[apduResponseSize - 1];
|
||||
unsigned char apduGetResponse[] = { 0x00, 0xC0, 0x00, 0x00, 0x00 };
|
||||
|
||||
// Manage data available on first APDU
|
||||
if (apduResponseSize > 2)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "Data available on first 61.XX APDU");
|
||||
totalDataSize += apduResponseSize - 2;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "Partial data size: %llu", (long long unsigned)totalDataSize);
|
||||
}
|
||||
|
||||
// Management of chained 61XX begin here
|
||||
while (!errorManaging61XX && !endOfData)
|
||||
{
|
||||
apduGetResponse[4] = dataSizeRequested;
|
||||
partialApduResponseSize = (*apduResponseMaxSize - totalDataSize);
|
||||
|
||||
res = _seMedia->seMediaTransmitApdu(_seMedia, apduGetResponse, sizeof(apduGetResponse), &apduResponseBytes[totalDataSize], &partialApduResponseSize);
|
||||
if (res && partialApduResponseSize >= 2)
|
||||
{
|
||||
// check if another SW=61.XX
|
||||
if (apduResponseBytes[totalDataSize + partialApduResponseSize - 2] == 0x61)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "APDU R - SW is again 61.XX type");
|
||||
dataSizeRequested = apduResponseBytes[totalDataSize + partialApduResponseSize - 1];
|
||||
totalDataSize += (partialApduResponseSize - 2); // No SW included
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "Partial data size: %llu bytes", (long long unsigned)totalDataSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Accept responses 0x90 00 or 0x91 xx
|
||||
if ((apduResponseBytes[totalDataSize + partialApduResponseSize - 2] == 0x90 &&
|
||||
apduResponseBytes[totalDataSize + partialApduResponseSize - 1] == 0x00) ||
|
||||
(apduResponseBytes[totalDataSize + partialApduResponseSize - 2] == 0x91))
|
||||
{
|
||||
totalDataSize += partialApduResponseSize;
|
||||
apduResponseSize = totalDataSize;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "Final data size: %llu bytes", (long long unsigned)totalDataSize);
|
||||
endOfData = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Detection of 0x6D00 in chained response loop, if detection is enabled
|
||||
if(LPA_RETRY_CHAINED_GET_RESPONSE_MGT &&
|
||||
(apduResponseBytes[totalDataSize + partialApduResponseSize - 2] == 0x6D) &&
|
||||
(apduResponseBytes[totalDataSize + partialApduResponseSize - 1] == 0x00))
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "SW 0x6D00 detected in chained GetResponse()!");
|
||||
errorManaging61XX = true;
|
||||
apduResponseSize = 0; // With length=0 will be see as "Incorrect data / Invalid SW / error" on lpa_manager_helper layer
|
||||
lpaSetErrorCode(SE_MEDIA_E_CHAINING_GET_RESPONSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Other error cases will produce an error
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "90.00 or 91.xx or 61.XX Status Word expected!");
|
||||
errorManaging61XX = true;
|
||||
apduResponseSize = 0; // With length=0 will be see as "Incorrect data / Invalid SW / error" on lpa_manager_helper layer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errorManaging61XX = true;
|
||||
apduResponseSize = 0; // With length=0 will be see as "Incorrect data / Invalid SW / error" on lpa_manager_helper layer
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "Automatic GetResponse for 61.XX not activated => do nothing");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (apduResponseBytes[apduResponseSize - 2] == 0x6C)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "APDU R - SW is 6C.XX type");
|
||||
|
||||
// Manage 6C.XX
|
||||
if (_manageAutomatically6CXX)
|
||||
{
|
||||
// Implement 6C.XX if needed
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "6C.XX not yet implemented => do nothing");
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "Automatic GetResponse for 6C.XX not activated => do nothing");
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Apdu response size < 2 bytes!");
|
||||
}
|
||||
else
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_seMedia->seMediaTransmitApdu return false!");
|
||||
apduResponseSize = 0; // With length=0 will be see as "Incorrect data / Invalid SW / error" on lpa_manager_helper layer
|
||||
}
|
||||
|
||||
if (!res)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "Problem during transmitAPDU process => Check Status...");
|
||||
if (_seMedia->seMediaGetStatus != NULL)
|
||||
{
|
||||
// try to get SCard Status
|
||||
SE_MEDIA_CARD_STATUS cardStatus = SE_MEDIA_STATUS_SCARD_UNKNOWN;
|
||||
if (_seMedia->seMediaGetStatus(_seMedia, &cardStatus))
|
||||
{
|
||||
if (cardStatus == SE_MEDIA_STATUS_REMOVED_CARD)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Card removed -> do disconnect!");
|
||||
seMediaManagerDisconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_seMedia->seMediaTransmitApdu NULL or failed at seMediaManagerIsConnected()!");
|
||||
|
||||
*apduResponseMaxSize = apduResponseSize;
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Invalid parameter NULL!");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
bool seMediaManagerDisconnect()
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerDisconnect()");
|
||||
bool res = false;
|
||||
|
||||
if (_seMedia != NULL)
|
||||
{
|
||||
if( _seMedia->seMediaDisconnect != NULL )
|
||||
res = _seMedia->seMediaDisconnect(_seMedia);
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "_seMedia->seMediaDisconnect is NULL!");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
bool seMediaManagerDisconnectWithReset()
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+seMediaManagerDisconnectWithReset()");
|
||||
bool res = false;
|
||||
|
||||
if (_seMedia != NULL)
|
||||
{
|
||||
if (_seMedia->seMediaDisconnect != NULL)
|
||||
res = _seMedia->seMediaDisconnectWithReset(_seMedia);
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "_seMedia->seMediaDisconnectWithReset is NULL!");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
1334
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/src/core/util.c
Executable file
1334
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/src/core/util.c
Executable file
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,925 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "curl/curl.h"
|
||||
|
||||
#include "lpasdk/core/lpa_log.h"
|
||||
#include "lpasdk/core/lpa_memory.h"
|
||||
#include "lpasdk/core/httpmedia_base.h"
|
||||
#include "lpasdk/driver/httpmedia_curl.h"
|
||||
|
||||
|
||||
THTTPMedia* New_HTTPMediaCurl();
|
||||
void Delete_HTTPMediaCurl(THTTPMedia* httpMedia);
|
||||
|
||||
static size_t _WriteRespCallback(void *contents, size_t size, size_t nmemb, void *userp);
|
||||
|
||||
bool _httpMediaConfigure(const THTTPMedia* httpMedia);
|
||||
bool _httpMediaSetTargetUrl(const THTTPMedia* httpMedia, const char* ptrTargetURL);
|
||||
bool _httpMediaSetCertificatePath(const THTTPMedia* httpMedia, const char* ptrCertificatePath);
|
||||
bool _httpMediaSetPostData(const THTTPMedia* httpMedia, const char* ptrPostdata);
|
||||
bool _httpMediaSetHeaders(const THTTPMedia* httpMedia);
|
||||
|
||||
bool _httpMediaSetBooleanOption(const THTTPMedia* ptrHttpMedia, HttpMediaOptionType optionType, bool enabled);
|
||||
bool _httpMediaGetBooleanOption(const THTTPMedia* ptrHttpMedia, HttpMediaOptionType optionType, bool* ptrEnabled);
|
||||
|
||||
bool _httpMediaSetLongOption(const THTTPMedia* ptrHttpMedia, HttpMediaOptionType optionType, long value);
|
||||
bool _httpMediaGetLongOption(const THTTPMedia* ptrHttpMedia, HttpMediaOptionType optionType, long* ptrValue);
|
||||
|
||||
bool _httpMediaSetCallbackEventExecutionError(const THTTPMedia* httpMedia, LPA_EVENT_EXECUTION_ERROR lpaEventExecutionErrorCallback);
|
||||
|
||||
bool _httpMediaSetCallback(const THTTPMedia* httpMedia);
|
||||
bool _httpMediaSetWriteData(const THTTPMedia* httpMedia);
|
||||
char* _httpMediaGetBufferResponse(const THTTPMedia* httpMedia);
|
||||
|
||||
bool _httpMediaHttpExecutePost(const THTTPMedia* httpMedia, long *ptrHttpCode);
|
||||
|
||||
bool _httpMediaPost(const THTTPMedia* httpMedia, const char* ptrCertificatePath, const char* ptrTargetURL, const char* ptrPostdata, long* ptrHttpCode);
|
||||
|
||||
void _httpMediaHttpExecuteCleanup(const THTTPMedia* httpMedia);
|
||||
bool _httpMediaHttpExecuteInit(const THTTPMedia* httpMedia);
|
||||
|
||||
static bool _curlOptionSSLVerifyPeer = true;
|
||||
static bool _curlOptionSSLVerifyHost = true;
|
||||
static bool _curlOptionVerbose = false;
|
||||
|
||||
static long _curlOptionTimeOut = 30; // seconds
|
||||
static long _curlOptionConnectTimeOut = 30; // seconds
|
||||
|
||||
static unsigned int _curlVersion = 0;
|
||||
|
||||
// Event execution error callback
|
||||
static LPA_EVENT_EXECUTION_ERROR _lpaEventExecutionErrorCallback = NULL;
|
||||
|
||||
#ifdef LPA_SDK__CURL_MEMORY
|
||||
void *_httpMediaMallocCallback(size_t size);
|
||||
void _httpMediaFreeCallback(void *ptr);
|
||||
void *_httpMediaReallocCallback(void *ptr, size_t size);
|
||||
char *_httpMediaStrdupCallback(const char *str);
|
||||
void *_httpMediaCallocCallback(size_t nmemb, size_t size);
|
||||
#endif // LPA_SDK__CURL_MEMORY
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
static size_t _WriteRespCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _WriteRespCallback()");
|
||||
|
||||
if (NULL == contents || NULL == userp)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Invalid NULL parameter!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct RespStruct *respStr = (struct RespStruct *) userp;
|
||||
|
||||
void* ptrRealloc = lpaCoreMemoryRealloc(respStr->resp, respStr->size + realsize + 1);
|
||||
if (NULL == ptrRealloc)
|
||||
{
|
||||
// out of memory!
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Not enough memory (realloc returned NULL)");
|
||||
return 0;
|
||||
}
|
||||
respStr->resp = ptrRealloc;
|
||||
memcpy(&(respStr->resp[respStr->size]), contents, realsize);
|
||||
respStr->size += realsize;
|
||||
respStr->resp[respStr->size] = 0;
|
||||
|
||||
return realsize;
|
||||
}
|
||||
|
||||
THTTPMedia* New_HTTPMediaCurl()
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> New_HTTPMediaCurl()");
|
||||
|
||||
THTTPMedia* ptrHTTPMedia = NULL;
|
||||
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*) lpaCoreMemoryAlloc(sizeof (THTTPMediaCURL));
|
||||
if (httpMediaCurl != NULL)
|
||||
{
|
||||
httpMediaCurl->_base = New_HTTPMediaBase();
|
||||
if (httpMediaCurl->_base != NULL)
|
||||
{
|
||||
httpMediaCurl->_base->_childStruct = httpMediaCurl;
|
||||
|
||||
httpMediaCurl->_base->httpMediaPost = _httpMediaPost;
|
||||
httpMediaCurl->_base->httpMediaSetBooleanOption = _httpMediaSetBooleanOption;
|
||||
httpMediaCurl->_base->httpMediaGetBooleanOption = _httpMediaGetBooleanOption;
|
||||
|
||||
httpMediaCurl->_base->httpMediaGetBufferResponse = _httpMediaGetBufferResponse;
|
||||
|
||||
httpMediaCurl->_base->httpMediaSetLongOption = _httpMediaSetLongOption;
|
||||
httpMediaCurl->_base->httpMediaGetLongOption = _httpMediaGetLongOption;
|
||||
|
||||
httpMediaCurl->_base->httpMediaHttpExecuteCleanup = _httpMediaHttpExecuteCleanup;
|
||||
httpMediaCurl->_base->httpMediaHttpExecuteInit = _httpMediaHttpExecuteInit;
|
||||
|
||||
httpMediaCurl->_base->httpMediaSetCallbackEventExecutionError = _httpMediaSetCallbackEventExecutionError;
|
||||
|
||||
memset(&httpMediaCurl->_respdata, 0, sizeof(struct RespStruct));
|
||||
httpMediaCurl->_headers = NULL;
|
||||
httpMediaCurl->_curl = NULL;
|
||||
|
||||
_curlVersion = 0; // CURL Version not yet retrieved
|
||||
|
||||
#ifdef LPA_SDK__CURL_MEMORY
|
||||
CURLcode curlCode = curl_global_init_mem(CURL_GLOBAL_DEFAULT, _httpMediaMallocCallback, _httpMediaFreeCallback, _httpMediaReallocCallback, _httpMediaStrdupCallback, _httpMediaCallocCallback);
|
||||
if(curlCode == CURLE_OK)
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "CURL global memory initialization done successfully");
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Error during curl_global_init_mem()!");
|
||||
#endif // LPA_SDK__CURL_MEMORY
|
||||
|
||||
ptrHTTPMedia = (THTTPMedia*)httpMediaCurl->_base;
|
||||
}
|
||||
else
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "New_HTTPMediaCurl(): Cannot allocate memory for _base object!!");
|
||||
lpaCoreMemoryFree(httpMediaCurl);
|
||||
httpMediaCurl = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "New_HTTPMediaCurl(): Cannot allocate memory for THTTPMediaCURL object!");
|
||||
|
||||
// By default, No callback available for LPA Event Execution error
|
||||
_lpaEventExecutionErrorCallback = NULL;
|
||||
|
||||
return ptrHTTPMedia;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
void Delete_HTTPMediaCurl(THTTPMedia* httpMedia)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> Delete_HTTPMediaCurl()");
|
||||
|
||||
if (httpMedia != NULL)
|
||||
{
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*)httpMedia->_childStruct;
|
||||
if (httpMediaCurl != NULL)
|
||||
{
|
||||
#ifdef LPA_SDK__CURL_MEMORY
|
||||
curl_global_cleanup();
|
||||
#endif // LPA_SDK__CURL_MEMORY
|
||||
|
||||
lpaCoreMemoryFree(httpMediaCurl);
|
||||
}
|
||||
lpaCoreMemoryFree(httpMedia);
|
||||
httpMedia = NULL;
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Delete_HTTPMediaCurl() => Invalid parameter: httpMedia is NULL!");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
bool _httpMediaConfigure(const THTTPMedia* httpMedia)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaConfigure()");
|
||||
|
||||
if (httpMedia != NULL)
|
||||
{
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*)httpMedia->_childStruct;
|
||||
|
||||
if (httpMediaCurl != NULL && httpMediaCurl->_curl != NULL)
|
||||
{
|
||||
CURLcode curlCodeSSL_VERIFYPEER = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_SSL_VERIFYPEER, (_curlOptionSSLVerifyPeer ? 1 : 0));
|
||||
CURLcode curlCodeSSL_VERIFYHOST = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_SSL_VERIFYHOST, (_curlOptionSSLVerifyHost ? 2 : 0));
|
||||
CURLcode curlCodeVERBOSE = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_VERBOSE, (_curlOptionVerbose ? 1 : 0));
|
||||
|
||||
res = ((curlCodeSSL_VERIFYPEER == CURLE_OK) && (curlCodeSSL_VERIFYHOST == CURLE_OK) && (curlCodeVERBOSE == CURLE_OK));
|
||||
|
||||
#if defined(LPA_SDK__PLATFORM_WIN) && defined(LPA_SDK__CURLSSLOPT_NO_REVOKE)
|
||||
if (res)
|
||||
{
|
||||
if (_curlVersion >= 0x072C00) // CURLSSLOPT_NO_REVOKE present since CURL 7.44.0
|
||||
{
|
||||
if (curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE) != CURLE_OK)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaConfigure() => Unable to do CURLSSLOPT_NO_REVOKE");
|
||||
res = false;
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "_httpMediaConfigure() => CURLSSLOPT_NO_REVOKE done successfully");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaConfigure() => Unable to do CURLSSLOPT_NO_REVOKE (option not supported by current CURL library)");
|
||||
}
|
||||
#endif // LPA_SDK__PLATFORM_WIN && LPA_SDK__CURLSSLOPT_NO_REVOKE
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaConfigure() => Invalid parameter: httpMedia is NULL!");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
bool _httpMediaSetTargetUrl(const THTTPMedia* httpMedia, const char* ptrTargetURL)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaSetTargetUrl()");
|
||||
|
||||
if (httpMedia != NULL && ptrTargetURL != NULL)
|
||||
{
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*)httpMedia->_childStruct;
|
||||
|
||||
if (httpMediaCurl != NULL && httpMediaCurl->_curl != NULL)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, "* _httpMediaSetTargetUrl: %s", ptrTargetURL);
|
||||
CURLcode curlCode = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_URL, ptrTargetURL);
|
||||
if( curlCode == CURLE_OK )
|
||||
res = true;
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaSetTargetUrl failed (curl error code: %d) => %s", curlCode, curl_easy_strerror(curlCode));
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_VERBOSE, " _httpMediaSetTargetUrl failed");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaSetTargetUrl() => Invalid parameter NULL detected!");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _httpMediaHttpExecuteInit(const THTTPMedia* httpMedia)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaHttpExecuteInit()");
|
||||
if (httpMedia != NULL)
|
||||
{
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*)httpMedia->_childStruct;
|
||||
if (httpMediaCurl != NULL)
|
||||
{
|
||||
httpMediaCurl->_curl = curl_easy_init();
|
||||
if (httpMediaCurl->_curl != NULL)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "_httpMediaHttpExecuteInit() Init Success");
|
||||
|
||||
|
||||
curl_version_info_data * ptrData = curl_version_info(CURLVERSION_NOW);
|
||||
if (ptrData != NULL)
|
||||
{
|
||||
if (ptrData->age >= 0)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "curl version: %s", (ptrData->version ? ptrData->version : "N/A"));
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "curl host : %s", (ptrData->host != NULL ? ptrData->host : "N/A"));
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "curl feature: 0x%lx", ptrData->features);
|
||||
|
||||
_curlVersion = ptrData->version_num;
|
||||
|
||||
// Check Minimal CURL version required
|
||||
if (_curlVersion > 0x072200) // Minimal release required: 7.34.0
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "curl version supported");
|
||||
|
||||
CURLcode curlCode = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
|
||||
if (curlCode == CURLE_OK)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_INFO, "CURL using TLS v1.2 or later");
|
||||
res = true;
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Unable to use TLS v1.2 or later! (CURL configuration)");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "curl version not supported (require 7.34 or more)");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaHttpExecuteInit() Initialization Failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Invalid parameter: httpMedia is NULL!");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _httpMediaSetCertificatePath(const THTTPMedia* httpMedia, const char* ptrCertificatePath)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaSetCertificatePath()");
|
||||
|
||||
if (httpMedia != NULL && ptrCertificatePath != NULL)
|
||||
{
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*)httpMedia->_childStruct;
|
||||
if (httpMediaCurl->_curl)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "_httpMediaSetCertificatePath...");
|
||||
CURLcode curlCode = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_CAINFO, ptrCertificatePath);
|
||||
if (curlCode == CURLE_OK)
|
||||
res = true;
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaSetCertificatePath failed (curl error code: %d) => %s", curlCode, curl_easy_strerror(curlCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaSetCertificatePath() => Invalid parameter NULL detected!");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _httpMediaSetPostData(const THTTPMedia* httpMedia, const char* ptrPostdata)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaSetPostData()");
|
||||
if (httpMedia != NULL && ptrPostdata != NULL)
|
||||
{
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*)httpMedia->_childStruct;
|
||||
if (httpMediaCurl != NULL)
|
||||
{
|
||||
if (httpMediaCurl->_curl != NULL )
|
||||
{
|
||||
CURLcode curlCode = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_POST, 1);
|
||||
|
||||
if( curlCode == CURLE_OK)
|
||||
curlCode = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_POSTFIELDS, ptrPostdata);
|
||||
|
||||
if (curlCode == CURLE_OK)
|
||||
curlCode = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_NOSIGNAL, 1);
|
||||
|
||||
if (curlCode == CURLE_OK)
|
||||
curlCode = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_CONNECTTIMEOUT, _curlOptionConnectTimeOut);
|
||||
|
||||
if (curlCode == CURLE_OK)
|
||||
curlCode = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_TIMEOUT, _curlOptionTimeOut);
|
||||
|
||||
if (curlCode == CURLE_OK)
|
||||
res = true;
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "setPostData failed (curl error code: %d) => %s", curlCode, curl_easy_strerror(curlCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaSetPostData => httpMediaCurl is NULL!");
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaSetPostData => Invalid parameter NULL detected!");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _httpMediaSetHeaders(const THTTPMedia* httpMedia)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
if (httpMedia != NULL)
|
||||
{
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*)httpMedia->_childStruct;
|
||||
if (httpMediaCurl != NULL)
|
||||
{
|
||||
if (httpMediaCurl->_curl != NULL)
|
||||
{
|
||||
struct curl_slist *headers = NULL;
|
||||
|
||||
headers = curl_slist_append(headers, "X-Admin-Protocol:gsma/rsp/v2.3");
|
||||
headers = curl_slist_append(headers, "content-type:application/json");
|
||||
headers = curl_slist_append(headers, "charset:utf-8");
|
||||
headers = curl_slist_append(headers, "User-Agent: gsma-rsp-lpad");
|
||||
headers = curl_slist_append(headers, "Expect:");
|
||||
|
||||
httpMediaCurl->_headers = headers;
|
||||
|
||||
CURLcode curlCode = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_HTTPHEADER, httpMediaCurl->_headers);
|
||||
|
||||
if (curlCode == CURLE_OK)
|
||||
res = true;
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaSetHeaders failed (curl error code: %d) => %s", curlCode, curl_easy_strerror(curlCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaSetHeaders() => Invalid parameter: httpMedia is NULL!");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _httpMediaSetBooleanOption(const THTTPMedia* ptrHttpMedia, HttpMediaOptionType optionType, bool enabled)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaSetBooleanOption()");
|
||||
|
||||
bool isOptionIgnored = false;
|
||||
|
||||
switch (optionType)
|
||||
{
|
||||
case HTTP_MEDIA_OPTION_TYPE_CURL_SSL_VERIFYPEER:
|
||||
_curlOptionSSLVerifyPeer = enabled;
|
||||
break;
|
||||
|
||||
case HTTP_MEDIA_OPTION_TYPE_CURL_SSL_VERIFYHOST:
|
||||
_curlOptionSSLVerifyHost = enabled;
|
||||
break;
|
||||
|
||||
case HTTP_MEDIA_OPTION_TYPE_CURL_VERBOSE:
|
||||
_curlOptionVerbose = enabled;
|
||||
break;
|
||||
|
||||
default:
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "HttpMediaOptionType '%d' not supported", optionType);
|
||||
isOptionIgnored = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isOptionIgnored)
|
||||
res = true;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _httpMediaGetBooleanOption(const THTTPMedia* ptrHttpMedia, HttpMediaOptionType optionType, bool* ptrEnabled)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaGetBooleanOption()");
|
||||
|
||||
if ( ptrEnabled != NULL)
|
||||
{
|
||||
bool isOptionIgnored = false;
|
||||
switch (optionType)
|
||||
{
|
||||
case HTTP_MEDIA_OPTION_TYPE_CURL_SSL_VERIFYPEER:
|
||||
*ptrEnabled = _curlOptionSSLVerifyPeer;
|
||||
break;
|
||||
|
||||
case HTTP_MEDIA_OPTION_TYPE_CURL_SSL_VERIFYHOST:
|
||||
*ptrEnabled = _curlOptionSSLVerifyHost;
|
||||
break;
|
||||
|
||||
case HTTP_MEDIA_OPTION_TYPE_CURL_VERBOSE:
|
||||
*ptrEnabled = _curlOptionVerbose;
|
||||
break;
|
||||
|
||||
default:
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "HttpMediaOptionType '%d' not supported", optionType);
|
||||
isOptionIgnored = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isOptionIgnored)
|
||||
res = true;
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaGetBooleanOption() => Invalid parameter: ptrEnabled is NULL!");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _httpMediaSetLongOption(const THTTPMedia* ptrHttpMedia, HttpMediaOptionType optionType, long value)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaSetBooleanOption()");
|
||||
|
||||
bool isOptionIgnored = false;
|
||||
|
||||
switch (optionType)
|
||||
{
|
||||
case HTTP_MEDIA_OPTION_TYPE_CURL_CONNECT_TIMEOUT:
|
||||
_curlOptionConnectTimeOut = value;
|
||||
break;
|
||||
|
||||
case HTTP_MEDIA_OPTION_TYPE_CURL_TIMEOUT:
|
||||
_curlOptionTimeOut = value;
|
||||
break;
|
||||
|
||||
default:
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "HttpMediaOptionType '%d' not supported", optionType);
|
||||
isOptionIgnored = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isOptionIgnored)
|
||||
res = true;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _httpMediaGetLongOption(const THTTPMedia* ptrHttpMedia, HttpMediaOptionType optionType, long* ptrValue)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaGetLongOption()");
|
||||
|
||||
if (ptrValue != NULL)
|
||||
{
|
||||
bool isOptionIgnored = false;
|
||||
switch (optionType)
|
||||
{
|
||||
case HTTP_MEDIA_OPTION_TYPE_CURL_CONNECT_TIMEOUT:
|
||||
*ptrValue = _curlOptionConnectTimeOut;
|
||||
break;
|
||||
|
||||
case HTTP_MEDIA_OPTION_TYPE_CURL_TIMEOUT:
|
||||
*ptrValue = _curlOptionTimeOut;
|
||||
break;
|
||||
|
||||
default:
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "HttpMediaOptionType '%d' not supported", optionType);
|
||||
isOptionIgnored = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isOptionIgnored)
|
||||
res = true;
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaGetLongOption() => Invalid parameter: ptrValue is NULL!");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _httpMediaSetCallbackEventExecutionError(const THTTPMedia* httpMedia, LPA_EVENT_EXECUTION_ERROR lpaEventExecutionErrorCallback)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "++ httpmedia_curl :> _httpMediaSetCallbackEventExecutionError()");
|
||||
|
||||
bool res = false;
|
||||
|
||||
if (lpaEventExecutionErrorCallback != NULL)
|
||||
{
|
||||
if (_lpaEventExecutionErrorCallback != lpaEventExecutionErrorCallback)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, " registering lpaEventExecutionErrorCallback...");
|
||||
_lpaEventExecutionErrorCallback = lpaEventExecutionErrorCallback;
|
||||
res = true;
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, " LpaEventExecutionErrorCallback already registered!");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_lpaEventExecutionErrorCallback != NULL)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, " unregistering lpaEventExecutionErrorCallback...");
|
||||
_lpaEventExecutionErrorCallback = NULL;
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "-- httpmedia_curl :> _httpMediaSetCallbackEventExecutionError() return res=%s", (res ? "true" : "false"));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _httpMediaSetCallback(const THTTPMedia* httpMedia)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaSetCallback()");
|
||||
|
||||
if (httpMedia != NULL)
|
||||
{
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*)httpMedia->_childStruct;
|
||||
if (httpMediaCurl != NULL)
|
||||
{
|
||||
if (httpMediaCurl->_curl != NULL)
|
||||
{
|
||||
CURLcode curlCode = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_WRITEFUNCTION, _WriteRespCallback);
|
||||
if (curlCode == CURLE_OK)
|
||||
res = true;
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaSetCallback failed (curl error code: %d) => %s", curlCode, curl_easy_strerror(curlCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_WARNING, "_httpMediaSetCallback() => httpMedia is NULL!"); // For the moment I think it shall stay to WARNING in case callback not defined
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _httpMediaSetWriteData(const THTTPMedia* httpMedia)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaSetWriteData()");
|
||||
|
||||
if (httpMedia != NULL)
|
||||
{
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*)httpMedia->_childStruct;
|
||||
if (httpMediaCurl != NULL)
|
||||
{
|
||||
if (httpMediaCurl->_curl != NULL)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "start to do http easy perform");
|
||||
CURLcode curlCode = curl_easy_setopt(httpMediaCurl->_curl, CURLOPT_WRITEDATA, (void *)&httpMediaCurl->_respdata);
|
||||
if (curlCode == CURLE_OK)
|
||||
res = true;
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaSetWriteData failed (curl error code: %d) => %s", curlCode, curl_easy_strerror(curlCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaSetWriteData() => Invalid parameter: httpMedia is NULL!");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool _httpMediaHttpExecutePost(const THTTPMedia* httpMedia, long *ptrHttpCode)
|
||||
{
|
||||
bool res = false;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaHttpExecutePost()");
|
||||
|
||||
if (httpMedia == NULL || ptrHttpCode == NULL)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Invalid parameter NULL detected!");
|
||||
return res;
|
||||
}
|
||||
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*) httpMedia->_childStruct;
|
||||
*ptrHttpCode = 0; // By default
|
||||
|
||||
CURLcode ret;
|
||||
ret = curl_easy_perform(httpMediaCurl->_curl);
|
||||
if (CURLE_OK == ret)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "the http execution result: >> CURLE_OK :)");
|
||||
|
||||
if (curl_easy_getinfo(httpMediaCurl->_curl, CURLINFO_RESPONSE_CODE, ptrHttpCode) == CURLE_OK )
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "curl => HTTP code: %ld ", *ptrHttpCode);
|
||||
else
|
||||
{
|
||||
*ptrHttpCode = 0;
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "curl => Unable to get HTTP code!");
|
||||
}
|
||||
|
||||
res = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* curlStrError = curl_easy_strerror(ret);
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "Http execution failed (curl error code: %d) => %s", ret, (curlStrError != NULL ? curlStrError : "N/A"));
|
||||
|
||||
if (_lpaEventExecutionErrorCallback != NULL)
|
||||
{
|
||||
LPA_EVENT_EXECUTION_ERROR_INFO eventExecutionErrorInfo;
|
||||
char errorSubjectCode[16];
|
||||
snprintf(errorSubjectCode, sizeof(errorSubjectCode), "%d", ret);
|
||||
|
||||
eventExecutionErrorInfo.executionErrorType = LPA_EVENT_EXECUTION_CURL_ERROR_TYPE;
|
||||
eventExecutionErrorInfo.detailErrorMask = LPA_EVENT_EXECUTION_ERROR_SUBJECT_CODE_MASK;
|
||||
eventExecutionErrorInfo.ptrErrorReasonCode = NULL;
|
||||
eventExecutionErrorInfo.ptrErrorSubjectCode = errorSubjectCode;
|
||||
|
||||
if (curlStrError != NULL)
|
||||
{
|
||||
eventExecutionErrorInfo.detailErrorMask |= LPA_EVENT_EXECUTION_ERROR_EXTRA_INFO_MASK;
|
||||
eventExecutionErrorInfo.ptrErrorExtraInfo = curl_easy_strerror(ret);
|
||||
}
|
||||
|
||||
_lpaEventExecutionErrorCallback(NULL, &eventExecutionErrorInfo);
|
||||
}
|
||||
|
||||
res = false;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
char* _httpMediaGetBufferResponse(const THTTPMedia* httpMedia)
|
||||
{
|
||||
if(httpMedia != NULL)
|
||||
{
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*)httpMedia->_childStruct;
|
||||
return ( httpMediaCurl != NULL ? httpMediaCurl->_respdata.resp : NULL);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool _httpMediaPost(const THTTPMedia* httpMedia, const char* ptrCertificatePath, const char* ptrTargetURL, const char* ptrPostdata, long* ptrHttpCode)
|
||||
{
|
||||
bool resHttpMediaCall = false;
|
||||
|
||||
if(httpMedia != NULL && ptrCertificatePath != NULL && ptrTargetURL != NULL && ptrPostdata != NULL && ptrHttpCode != NULL)
|
||||
{
|
||||
resHttpMediaCall = _httpMediaConfigure(httpMedia);
|
||||
if (resHttpMediaCall)
|
||||
resHttpMediaCall = _httpMediaSetTargetUrl(httpMedia,ptrTargetURL);
|
||||
|
||||
if (resHttpMediaCall)
|
||||
resHttpMediaCall = _httpMediaSetPostData(httpMedia,ptrPostdata);
|
||||
|
||||
if (resHttpMediaCall)
|
||||
resHttpMediaCall = _httpMediaSetHeaders(httpMedia);
|
||||
|
||||
if(ptrCertificatePath != NULL)
|
||||
{
|
||||
if (resHttpMediaCall && strlen(ptrCertificatePath) > 0)
|
||||
{
|
||||
resHttpMediaCall = _httpMediaSetCertificatePath(httpMedia,ptrCertificatePath);
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "Certificate path is: %s", ptrCertificatePath);
|
||||
}
|
||||
}
|
||||
else
|
||||
resHttpMediaCall = false;
|
||||
|
||||
if (resHttpMediaCall)
|
||||
resHttpMediaCall = _httpMediaSetCallback(httpMedia);
|
||||
|
||||
if (resHttpMediaCall)
|
||||
resHttpMediaCall = _httpMediaSetWriteData(httpMedia);
|
||||
|
||||
//start to execute post
|
||||
if (resHttpMediaCall)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "HTTP execute post...");
|
||||
resHttpMediaCall = _httpMediaHttpExecutePost(httpMedia, ptrHttpCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaGetBufferResponse() => Invalid parameter NULL detected!");
|
||||
|
||||
return resHttpMediaCall;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _httpMediaHttpExecuteCleanup(const THTTPMedia* httpMedia)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "+httpmedia_curl :> _httpMediaHttpExecuteCleanup()");
|
||||
|
||||
if (httpMedia != NULL)
|
||||
{
|
||||
THTTPMediaCURL* httpMediaCurl = (THTTPMediaCURL*)httpMedia->_childStruct;
|
||||
|
||||
if (httpMediaCurl->_headers != NULL)
|
||||
{
|
||||
curl_slist_free_all(httpMediaCurl->_headers);
|
||||
httpMediaCurl->_headers = NULL;
|
||||
}
|
||||
|
||||
if (httpMediaCurl->_respdata.resp != NULL )
|
||||
{
|
||||
lpaCoreMemoryFree(httpMediaCurl->_respdata.resp);
|
||||
httpMediaCurl->_respdata.resp = NULL;
|
||||
}
|
||||
|
||||
httpMediaCurl->_respdata.size = 0;
|
||||
|
||||
if (httpMediaCurl->_curl != NULL)
|
||||
{
|
||||
curl_easy_cleanup(httpMediaCurl->_curl);
|
||||
httpMediaCurl->_curl = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_ERROR, "_httpMediaHttpExecuteCleanup() => Invalid parameter: httpMedia is NULL!");
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// Memory Callback
|
||||
/////////////////////////
|
||||
|
||||
#ifdef LPA_SDK__CURL_MEMORY
|
||||
|
||||
void *_httpMediaMallocCallback(size_t size)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] + httpmedia_curl:>_httpMediaMallocCallback()");
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] malloc(%llu bytes)...", (long long unsigned)size);
|
||||
|
||||
void* ptrMalloc = NULL;
|
||||
|
||||
#if defined(LPA_SDK__CURL_MEMORY_MONITORING) && defined(LPA_SDK__MEMORY)
|
||||
ptrMalloc = lpaCoreMemoryAlloc(size);
|
||||
#else
|
||||
ptrMalloc = malloc(size);
|
||||
#endif // LPA_SDK__CURL_MEMORY_MONITORING && LPA_SDK__MEMORY
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] allocated memory: 0x%lx", ptrMalloc);
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] - httpmedia_curl:>_httpMediaMallocCallback()");
|
||||
|
||||
return ptrMalloc;
|
||||
}
|
||||
|
||||
void _httpMediaFreeCallback(void *ptr)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] + httpmedia_curl:>_httpMediaFreeCallback()");
|
||||
|
||||
if(ptr != NULL )
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] Free (0x%lx)...", ptr);
|
||||
|
||||
#if defined(LPA_SDK__CURL_MEMORY_MONITORING) && defined(LPA_SDK__MEMORY)
|
||||
lpaCoreMemoryFree(ptr);
|
||||
#else
|
||||
free(ptr);
|
||||
#endif // LPA_SDK__CURL_MEMORY_MONITORING && LPA_SDK__MEMORY
|
||||
}
|
||||
else
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] Free (NULL) => Do nothing");
|
||||
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] - httpmedia_curl:>_httpMediaFreeCallback()");
|
||||
}
|
||||
|
||||
void *_httpMediaReallocCallback(void *ptr, size_t size)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] + httpmedia_curl:>_httpMediaReallocCallback()");
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] Realloc (0x%lx,%llu bytes)...", ptr, (long long unsigned)size);
|
||||
|
||||
void* ptrRealloc = NULL;
|
||||
|
||||
#if defined(LPA_SDK__CURL_MEMORY_MONITORING) && defined(LPA_SDK__MEMORY)
|
||||
ptrRealloc = lpaCoreMemoryRealloc(ptr, size);
|
||||
#else
|
||||
ptrRealloc = realloc(ptr, size);
|
||||
#endif // LPA_SDK__CURL_MEMORY_MONITORING && LPA_SDK__MEMORY
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] reallocated memory: 0x%lx", ptrRealloc);
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] - httpmedia_curl:>_httpMediaReallocCallback()");
|
||||
return ptrRealloc;
|
||||
}
|
||||
|
||||
char *_httpMediaStrdupCallback(const char *str)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] + httpmedia_curl:>_httpMediaStrdupCallback()");
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] Strdup (0x%lx)...", str);
|
||||
|
||||
char* ptrStrdup = NULL;
|
||||
|
||||
if (str != NULL)
|
||||
{
|
||||
size_t strSize = strlen(str) + 1;
|
||||
#if defined(LPA_SDK__CURL_MEMORY_MONITORING) && defined(LPA_SDK__MEMORY)
|
||||
ptrStrdup = lpaCoreMemoryAlloc(strSize);
|
||||
#else
|
||||
ptrStrdup = malloc(strSize);
|
||||
#endif // LPA_SDK__CURL_MEMORY_MONITORING && LPA_SDK__MEMORY
|
||||
if (ptrStrdup != NULL)
|
||||
{
|
||||
memcpy(ptrStrdup, str, strSize);
|
||||
ptrStrdup[strSize] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] ptrStrdup => 0x%lx", ptrStrdup);
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] - httpmedia_curl:>_httpMediaStrdupCallback()");
|
||||
|
||||
return ptrStrdup;
|
||||
}
|
||||
|
||||
void *_httpMediaCallocCallback(size_t nmemb, size_t size)
|
||||
{
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] + httpmedia_curl:>_httpMediaCallocCallback()");
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] Calloc %llu,%llu...", (long long unsigned)nmemb, (long long unsigned)size);
|
||||
|
||||
void* ptrCalloc = NULL;
|
||||
|
||||
#if defined(LPA_SDK__CURL_MEMORY_MONITORING) && defined(LPA_SDK__MEMORY)
|
||||
ptrCalloc = lpaCoreMemoryCalloc(nmemb, size);
|
||||
#else
|
||||
ptrCalloc = calloc(nmemb, size);
|
||||
#endif // LPA_SDK__CURL_MEMORY_MONITORING && LPA_SDK__MEMORY
|
||||
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] Calloc=> 0x%lx ", ptrCalloc);
|
||||
lpaCoreLogAppend(SDK_LOG_LEVEL_DEBUG, "[CURL_MEM] - httpmedia_curl:>_httpMediaCallocCallback()");
|
||||
|
||||
return ptrCalloc;
|
||||
}
|
||||
|
||||
#endif // LPA_SDK__CURL_MEMORY
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1000
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/src/lpasdk_api.c
Executable file
1000
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/src/lpasdk_api.c
Executable file
File diff suppressed because it is too large
Load Diff
203
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/src/lpasdk_api_error.c
Executable file
203
code/application/source/sf_app/code/source/sf_lpa/LPA_SDK/src/lpasdk_api_error.c
Executable file
|
@ -0,0 +1,203 @@
|
|||
/*
|
||||
* Copyright 2018-2021 THALES group. All Rights Reserved.
|
||||
*
|
||||
* Project name: LPASDK.
|
||||
* Platform: Windows, Linux.
|
||||
* Language: C/C++
|
||||
*
|
||||
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
|
||||
*
|
||||
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
|
||||
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
|
||||
*
|
||||
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
|
||||
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
|
||||
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
|
||||
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
|
||||
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
|
||||
* will be uninterrupted or error-free.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "lpasdk/api/lpasdk_api.h"
|
||||
|
||||
static LPA_API_ERROR_DESCRIPTION _apiErrorDescriptionList[] =
|
||||
{
|
||||
{ LPA_NO_ERROR, "LPA_NO_ERROR" },
|
||||
|
||||
// { LPA_ERROR_CFG_SE_MEDIA_INCORRECT_READER_NAME_SIZE, "LPA_ERROR_CFG_SE_MEDIA_INCORRECT_READER_NAME_SIZE" },
|
||||
// { LPA_ERROR_CFG_SE_MEDIA_READER_NAME_IS_NULL, "LPA_ERROR_CFG_SE_MEDIA_READER_NAME_IS_NULL" },
|
||||
{ LPA_NOT_INITIALIZED, "LPA_NOT_INITIALIZED" },
|
||||
|
||||
{ LPA_ERROR_INVALID_PARAMETER, "LPA_ERROR_INVALID_PARAMETER" },
|
||||
{ LPA_ERROR_INSUFFICIENT_BUFFER, "LPA_ERROR_INSUFFICIENT_BUFFER" },
|
||||
{ LPA_ERROR_INVALID_SW, "LPA_ERROR_INVALID_SW" },
|
||||
{ LPA_ERROR_ISDR_NOT_SELECTED, "LPA_ERROR_ISDR_NOT_SELECTED" },
|
||||
{ LPA_ERROR_SE_MEDIA_NOT_INITIALIZED, "LPA_ERROR_SE_MEDIA_NOT_INITIALIZED" },
|
||||
{ LPA_ERROR_SE_MEDIA_CONTEXT_NOT_ESTABLISHED, "LPA_ERROR_SE_MEDIA_CONTEXT_NOT_ESTABLISHED" },
|
||||
{ LPA_ERROR_SE_MEDIA_READER_CONNECTION, "LPA_ERROR_SE_MEDIA_READER_CONNECTION" },
|
||||
{ LPA_ERROR_SE_MEDIA_CONTEXT_NOT_RELEASED, "LPA_ERROR_SE_MEDIA_CONTEXT_NOT_RELEASED" },
|
||||
{ LPA_ERROR_SE_MEDIA_READER_NOT_DISCONNECTED, "LPA_ERROR_SE_MEDIA_READER_NOT_DISCONNECTED" },
|
||||
{ LPA_ERROR_SE_MEDIA_UNABLE_TO_SELECT_ISDR, "LPA_ERROR_SE_MEDIA_UNABLE_TO_SELECT_ISDR" },
|
||||
{ LPA_ERROR_INVALID_GET_PROFILES_INFO_EXCHANGE, "LPA_ERROR_INVALID_GET_PROFILES_INFO_EXCHANGE" },
|
||||
{ LPA_ERROR_INVALID_GET_EID_EXCHANGE, "LPA_ERROR_INVALID_GET_EID_EXCHANGE" },
|
||||
{ LPA_ERROR_INVALID_MEMORY_RESET_EXCHANGE, "LPA_ERROR_INVALID_MEMORY_RESET_EXCHANGE" },
|
||||
{ LPA_ERROR_INVALID_SET_DEFAULT_SMDP_ADDRESS, "LPA_ERROR_INVALID_SET_DEFAULT_SMDP_ADDRESS" },
|
||||
{ LPA_ERROR_PARAMETER_NOT_AUTHORIZED, "LPA_ERROR_PARAMETER_NOT_AUTHORIZED" },
|
||||
{ LPA_ERROR_UNKNOWN_PARAMETER, "LPA_ERROR_UNKNOWN_PARAMETER" },
|
||||
{ LPA_ERROR_INVALID_PARAMETER_TYPE, "LPA_ERROR_INVALID_PARAMETER_TYPE" },
|
||||
{ LPA_ERROR_INCORRECT_PARAMETER_TYPE, "LPA_ERROR_INCORRECT_PARAMETER_TYPE" },
|
||||
{ LPA_ERROR_PARAMETER_INTERNAL_ERROR, "LPA_ERROR_PARAMETER_INTERNAL_ERROR" },
|
||||
{ LPA_ERROR_UNABLE_TO_INIT_LOG, "LPA_ERROR_UNABLE_TO_INIT_LOG" },
|
||||
{ LPA_ERROR_MISSING_CONFIG_FILE, "LPA_ERROR_MISSING_CONFIG_FILE" },
|
||||
{ LPA_ERROR_UNABLE_TO_LOAD_CONFIG_FILE, "LPA_ERROR_UNABLE_TO_LOAD_CONFIG_FILE" },
|
||||
{ LPA_ERROR_CONFIG_FILE_MISSING_MANDATORY_KEY, "LPA_ERROR_CONFIG_FILE_MISSING_MANDATORY_KEY" },
|
||||
{ LPA_ERROR_CONFIG_FILE_INCORRECT_KEY_VALUE, "LPA_ERROR_CONFIG_FILE_INCORRECT_KEY_VALUE" },
|
||||
{ LPA_ERROR_UNABLE_TO_INITIALIZE_LPA_MANAGER, "LPA_ERROR_UNABLE_TO_INITIALIZE_LPA_MANAGER" },
|
||||
{ LPA_ERROR_UNABLE_TO_INITIALIZE_HTTP_MEDIA , "LPA_ERROR_UNABLE_TO_INITIALIZE_HTTP_MEDIA" },
|
||||
{ LPA_ERROR_EXTENDED_API_UNAVAILABLE, "LPA_ERROR_EXTENDED_API_UNAVAILABLE" },
|
||||
{ LPA_ERROR_PROCESSING_ERROR, "LPA_ERROR_PROCESSING_ERROR" },
|
||||
|
||||
// Local Profile Management
|
||||
{ LPA_ERROR_LOCAL_PROFILE_NOT_FOUND, "LPA_ERROR_LOCAL_PROFILE_NOT_FOUND" },
|
||||
{ LPA_ERROR_LOCAL_PROFILE_INCORRECT_STATE, "LPA_ERROR_LOCAL_PROFILE_INCORRECT_STATE" },
|
||||
{ LPA_ERROR_LOCAL_PROFILE_CAT_BUSY, "LPA_ERROR_LOCAL_PROFILE_CAT_BUSY" },
|
||||
{ LPA_ERROR_LOCAL_PROFILE_UNKNOWN_ERROR, "LPA_ERROR_LOCAL_PROFILE_UNKNOWN_ERROR" },
|
||||
{ LPA_ERROR_LOCAL_PROFILE_INCORRECT_CARD_RESPONSE, "LPA_ERROR_LOCAL_PROFILE_INCORRECT_CARD_RESPONSE" },
|
||||
{ LPA_ERROR_LOCAL_PROFILE_NOTHING_TO_DELETE, "LPA_ERROR_LOCAL_PROFILE_NOTHING_TO_DELETE" },
|
||||
{ LPA_ERROR_LOCAL_PROFILE_UNDEFINED_ERROR, "LPA_ERROR_LOCAL_PROFILE_UNDEFINED_ERROR" },
|
||||
{ LPA_ERROR_LOCAL_PROFILE_UNABLE_TO_EXTRACT_DATA, "LPA_ERROR_LOCAL_PROFILE_UNABLE_TO_EXTRACT_DATA" },
|
||||
|
||||
{ LPA_ERROR_LOCAL_PROFILE_ICCID_OR_AID_NOT_FOUND, "LPA_ERROR_LOCAL_PROFILE_ICCID_OR_AID_NOT_FOUND" },
|
||||
{ LPA_ERROR_LOCAL_PROFILE_NOT_IN_DISABLE_STATE, "LPA_ERROR_LOCAL_PROFILE_NOT_IN_DISABLE_STATE" },
|
||||
{ LPA_ERROR_LOCAL_PROFILE_DISALLOWED_BY_POLICY, "LPA_ERROR_LOCAL_PROFILE_DISALLOWED_BY_POLICY" },
|
||||
{ LPA_ERROR_LOCAL_PROFILE_WRONG_PROFILE_REENABLING, "LPA_ERROR_LOCAL_PROFILE_WRONG_PROFILE_REENABLING" },
|
||||
{ LPA_ERROR_LOCAL_PROFILE_NOT_IN_ENABLE_STATE, "LPA_ERROR_LOCAL_PROFILE_NOT_IN_ENABLE_STATE" },
|
||||
|
||||
{ LPA_ERROR_LOCAL_PROFILE_INVALID_DATA_EXCHANGE, "LPA_ERROR_LOCAL_PROFILE_INVALID_DATA_EXCHANGE" },
|
||||
|
||||
// Notification Management
|
||||
{ LPA_ERROR_NOTIFICATION_INCORRECT_CARD_RESPONSE, "LPA_ERROR_NOTIFICATION_INCORRECT_CARD_RESPONSE" },
|
||||
{ LPA_ERROR_NOTIFICATION_NOTHING_TO_DELETE, "LPA_ERROR_NOTIFICATION_NOTHING_TO_DELETE" },
|
||||
{ LPA_ERROR_NOTIFICATION_UNDEFINED_ERROR, "LPA_ERROR_NOTIFICATION_UNDEFINED_ERROR" },
|
||||
{ LPA_ERROR_NOTIFICATION_UNKNOWN_ERROR, "LPA_ERROR_NOTIFICATION_UNKNOWN_ERROR" },
|
||||
{ LPA_ERROR_NOTIFICATION_INVALID_CARD_DATA, "LPA_ERROR_NOTIFICATION_INVALID_CARD_DATA" },
|
||||
|
||||
|
||||
{ LPA_ERROR_DOWNLOAD_PROFILE_PARAMETER_ERROR, "LPA_ERROR_DOWNLOAD_PROFILE_PARAMETER_ERROR" },
|
||||
{ LPA_ERROR_INVALID_GET_EUICC_INFO, "LPA_ERROR_INVALID_GET_EUICC_INFO" },
|
||||
{ LPA_ERROR_INVALID_GET_UICC_CHALLENGE, "LPA_ERROR_INVALID_GET_UICC_CHALLENGE" },
|
||||
{ LPA_ERROR_FAILED_INITIAL_AUTHENTICATION, "LPA_ERROR_FAILED_INITIAL_AUTHENTICATION" },
|
||||
{ LPA_ERROR_FAILED_AUTHENTICATE_SERVER, "LPA_ERROR_FAILED_AUTHENTICATE_SERVER" },
|
||||
{ LPA_ERROR_FAILED_AUTHENTICATE_CLIENT, "LPA_ERROR_FAILED_AUTHENTICATE_CLIENT" },
|
||||
{ LPA_ERROR_AUTHENTICATE_CLIENT_EXCHANGE, "LPA_ERROR_AUTHENTICATE_CLIENT_EXCHANGE" },
|
||||
{ LPA_ERROR_FAILED_PREPARE_DOWNLOAD, "LPA_ERROR_FAILED_PREPARE_DOWNLOAD" },
|
||||
{ LPA_ERROR_INVALID_CTX_PARAM, "LPA_ERROR_INVALID_CTX_PARAM" },
|
||||
{ LPA_ERROR_INVALID_AUTHENTICATE_SERVER_RESPONSE, "LPA_ERROR_INVALID_AUTHENTICATE_SERVER_RESPONSE" },
|
||||
{ LPA_ERROR_INVALID_PREPARE_DOWNLOAD_RESPONSE, "LPA_ERROR_INVALID_PREPARE_DOWNLOAD_RESPONSE" },
|
||||
{ LPA_ERROR_FAILED_LOAD_BPP, "LPA_ERROR_FAILED_LOAD_BPP" },
|
||||
{ LPA_ERROR_INVALID_PIR_RESPONSE, "LPA_ERROR_INVALID_PIR_RESPONSE" },
|
||||
{ LPA_ERROR_CJSON_PARSE_FAILURE, "LPA_ERROR_CJSON_PARSE_FAILURE" },
|
||||
{ LPA_ERROR_FAILED_INITIAL_SECURITY_CHANNEL, "LPA_ERROR_FAILED_INITIAL_SECURITY_CHANNEL" },
|
||||
{ LPA_ERROR_FAILED_CONFIGURE_ISDP, "LPA_ERROR_FAILED_CONFIGURE_ISDP" },
|
||||
{ LPA_ERROR_FAILED_STORE_META_DATA, "LPA_ERROR_FAILED_STORE_META_DATA" },
|
||||
{ LPA_ERROR_FAILED_REPLACE_SESSION_KEY, "LPA_ERROR_FAILED_REPLACE_SESSION_KEY" },
|
||||
{ LPA_ERROR_FAILED_LOAD_PROFILE_ELEMENTS, "LPA_ERROR_FAILED_LOAD_PROFILE_ELEMENTS" },
|
||||
{ LPA_ERROR_FAILED_GET_BOUND_PROFILE_PACKAGE, "LPA_ERROR_FAILED_GET_BOUND_PROFILE_PACKAGE" },
|
||||
{ LPA_ERROR_FAILED_SEND_NOTIFICATION_OR_NOT_GET_STATUS_CODE, "LPA_ERROR_FAILED_SEND_NOTIFICATION_OR_NOT_GET_STATUS_CODE" },
|
||||
{ LPA_ERROR_FAILED_GET_DATA_FROM_ACTIVATION_CODE, "LPA_ERROR_FAILED_GET_DATA_FROM_ACTIVATION_CODE" },
|
||||
{ LPA_ERROR_GET_INTERNAL_SERVER_ERROR, "LPA_ERROR_GET_INTERNAL_SERVER_ERROR" },
|
||||
{ LPA_ERROR_INVALID_TRANSACTIONID, "LPA_ERROR_INVALID_TRANSACTIONID" },
|
||||
{ LPA_ERROR_INVALID_SERVERSIGNED1, "LPA_ERROR_INVALID_SERVERSIGNED1" },
|
||||
{ LPA_ERROR_INVALID_SERVERSIGNATURE1, "LPA_ERROR_INVALID_SERVERSIGNATURE1" },
|
||||
{ LPA_ERROR_INVALID_EUICCCIPKIDTOBEUSED, "LPA_ERROR_INVALID_EUICCCIPKIDTOBEUSED" },
|
||||
{ LPA_ERROR_INVALID_SERVERCERTIFICATE, "LPA_ERROR_INVALID_SERVERCERTIFICATE" },
|
||||
{ LPA_ERROR_INVALID_SERVER_RESPONSE, "LPA_ERROR_INVALID_SERVER_RESPONSE" },
|
||||
{ LPA_ERROR_FAILED_CANCEL_SESSION, "LPA_ERROR_FAILED_CANCEL_SESSION" },
|
||||
{ LPA_ERROR_INVALID_PROFILE_METADATA, "LPA_ERROR_INVALID_PROFILE_METADATA" },
|
||||
{ LPA_ERROR_INVALID_GET_RAT, "LPA_ERROR_INVALID_GET_RAT" },
|
||||
{ LPA_ERROR_PPR_NOT_ALLOWED, "LPA_ERROR_PPR_NOT_ALLOWED" },
|
||||
{ LPA_ERROR_DOWNLOAD_SESSION_CANCELED_BY_USER, "LPA_ERROR_DOWNLOAD_SESSION_CANCELED_BY_USER" },
|
||||
{ LPA_ERROR_OID_MISMATCH, "LPA_ERROR_OID_MISMATCH" },
|
||||
{ LPA_ERROR_INVALID_BPP_DATA, "LPA_ERROR_INVALID_BPP_DATA" },
|
||||
|
||||
|
||||
{ LPA_ERROR_SERVER_COMMUNICATION_ISSUE,"LPA_ERROR_SERVER_COMMUNICATION_ISSUE"},
|
||||
{ LPA_ERROR_INVALID_ACTIVATION_CODE,"LPA_ERROR_INVALID_ACTIVATION_CODE"},
|
||||
{ LPA_ERROR_INVALID_MATCHINGID_OR_DEVICE_INFO_TLV,"LPA_ERROR_INVALID_MATCHINGID_OR_DEVICE_INFO_TLV" },
|
||||
{ LPA_ERROR_INVALID_DEVICE_INFO_TLV,"LPA_ERROR_INVALID_DEVICE_INFO_TLV" },
|
||||
{ LPA_ERROR_INVALID_GET_EUICC_ADDRESS,"LPA_ERROR_INVALID_GET_EUICC_ADDRESS" },
|
||||
{ LPA_ERROR_INVALID_GET_SMDP_ADDRESS,"LPA_ERROR_INVALID_GET_SMDP_ADDRESS" },
|
||||
{ LPA_ERROR_INVALID_SERVER_ADDRESS,"LPA_ERROR_INVALID_SERVER_ADDRESS" },
|
||||
{ LPA_ERROR_INVALID_GET_SMDS_ADDRESS,"LPA_ERROR_INVALID_GET_SMDS_ADDRESS" },
|
||||
{ LPA_ERROR_INVALID_EVENT_ID,"LPA_ERROR_INVALID_EVENT_ID" },
|
||||
{ LPA_ERROR_INVALID_RSP_SERVER_ADDRESS,"LPA_ERROR_INVALID_RSP_SERVER_ADDRESS" },
|
||||
{ LPA_ERROR_INVALID_EVENT_ENTRIES,"LPA_ERROR_INVALID_EVENT_ENTRIES" },
|
||||
{ LPA_ERROR_NO_EVENT_RECORD_FOUND,"LPA_ERROR_NO_EVENT_RECORD_FOUND" }, // This error code is now obsolete since V1.6
|
||||
{ LPA_ERROR_CONFIRMATION_CODE_MISSING_OR_EMPTY,"LPA_ERROR_CONFIRMATION_CODE_MISSING_OR_EMPTY" },
|
||||
{ LPA_ERROR_SERVER_RETURN_404_STATUS_CODE, "LPA_ERROR_SERVER_RETURN_404_STATUS_CODE" },
|
||||
{ LPA_ERROR_SERVER_RETURN_500_STATUS_CODE, "LPA_ERROR_SERVER_RETURN_500_STATUS_CODE" },
|
||||
{ LPA_ERROR_SERVER_RETURN_ERROR_STATUS, "LPA_ERROR_SERVER_RETURN_ERROR_STATUS" },
|
||||
|
||||
|
||||
{ SE_MEDIA_ERROR_BROKEN_PIPE, "SE_MEDIA_ERROR_BROKEN_PIPE" },
|
||||
{ SE_MEDIA_E_CANCELLED, "SE_MEDIA_E_CANCELLED" },
|
||||
{ SE_MEDIA_E_CANT_DISPOSE, "SE_MEDIA_E_CANT_DISPOSE" },
|
||||
{ SE_MEDIA_E_CARD_UNSUPPORTED, "SE_MEDIA_E_CARD_UNSUPPORTED" },
|
||||
{ SE_MEDIA_E_DUPLICATE_READER, "SE_MEDIA_E_DUPLICATE_READER" },
|
||||
{ SE_MEDIA_E_FILE_NOT_FOUND, "SE_MEDIA_E_FILE_NOT_FOUND" },
|
||||
{ SE_MEDIA_E_INSUFFICIENT_BUFFER, "SE_MEDIA_E_INSUFFICIENT_BUFFER" },
|
||||
{ SE_MEDIA_E_INVALID_ATR, "SE_MEDIA_E_INVALID_ATR" },
|
||||
{ SE_MEDIA_E_INVALID_HANDLE, "SE_MEDIA_E_INVALID_HANDLE" },
|
||||
{ SE_MEDIA_E_INVALID_PARAMETER, "SE_MEDIA_E_INVALID_PARAMETER" },
|
||||
{ SE_MEDIA_E_INVALID_TARGET, "SE_MEDIA_E_INVALID_TARGET" },
|
||||
{ SE_MEDIA_E_INVALID_VALUE, "SE_MEDIA_E_INVALID_VALUE" },
|
||||
{ SE_MEDIA_E_NO_MEMORY, "SE_MEDIA_E_NO_MEMORY" },
|
||||
{ SE_MEDIA_E_NO_READERS_AVAILABLE, "SE_MEDIA_E_NO_READERS_AVAILABLE" },
|
||||
{ SE_MEDIA_E_NO_SMARTCARD, "SE_MEDIA_E_NO_SMARTCARD" },
|
||||
{ SE_MEDIA_E_NOT_READY, "SE_MEDIA_E_NOT_READY" },
|
||||
{ SE_MEDIA_E_PROTO_MISMATCH, "SE_MEDIA_E_PROTO_MISMATCH" },
|
||||
{ SE_MEDIA_E_READER_UNAVAILABLE, "SE_MEDIA_E_READER_UNAVAILABLE" },
|
||||
{ SE_MEDIA_E_READER_UNSUPPORTED, "SE_MEDIA_E_READER_UNSUPPORTED" },
|
||||
{ SE_MEDIA_E_SERVER_TOO_BUSY, "SE_MEDIA_E_SERVER_TOO_BUSY" },
|
||||
{ SE_MEDIA_E_SERVICE_STOPPED, "SE_MEDIA_E_SERVICE_STOPPED" },
|
||||
{ SE_MEDIA_E_SHARING_VIOLATION, "SE_MEDIA_E_SHARING_VIOLATION" },
|
||||
{ SE_MEDIA_E_SYSTEM_CANCELLED, "SE_MEDIA_E_SYSTEM_CANCELLED" },
|
||||
{ SE_MEDIA_E_TIMEOUT, "SE_MEDIA_E_TIMEOUT" },
|
||||
{ SE_MEDIA_E_UNEXPECTED, "SE_MEDIA_E_UNEXPECTED" },
|
||||
{ SE_MEDIA_E_UNKNOWN_CARD, "SE_MEDIA_E_UNKNOWN_CARD" },
|
||||
{ SE_MEDIA_E_UNKNOWN_READER, "SE_MEDIA_E_UNKNOWN_READER" },
|
||||
{ SE_MEDIA_W_REMOVED_CARD, "SE_MEDIA_W_REMOVED_CARD" },
|
||||
{ SE_MEDIA_W_RESET_CARD, "SE_MEDIA_W_RESET_CARD" },
|
||||
{ SE_MEDIA_W_UNSUPPORTED_CARD, "SE_MEDIA_W_UNSUPPORTED_CARD" },
|
||||
{ SE_MEDIA_E_CHAINING_GET_RESPONSE, "SE_MEDIA_E_CHAINING_GET_RESPONSE" },
|
||||
|
||||
|
||||
// Latest entry
|
||||
{ 0, NULL} // Must be NULL
|
||||
};
|
||||
|
||||
EXPORT_DLL LPA_API_ERROR_DESCRIPTION* lpaExGetListErrorCodeDescription()
|
||||
{
|
||||
return _apiErrorDescriptionList;
|
||||
}
|
||||
|
||||
const char* lpaGetErrorCodeDescription(LPA_API_ERROR apiErrorcode)
|
||||
{
|
||||
char* errorCodeDescription = "Unknown LPA API Error Code";
|
||||
size_t index = 0;
|
||||
|
||||
while (_apiErrorDescriptionList[index].ptrApiErrorDescription != NULL)
|
||||
{
|
||||
if (_apiErrorDescriptionList[index].apiErrorCode == apiErrorcode )
|
||||
{
|
||||
errorCodeDescription = _apiErrorDescriptionList[index].ptrApiErrorDescription;
|
||||
break;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
return errorCodeDescription;
|
||||
}
|
|
@ -343,6 +343,49 @@ unsigned char sf_mcu_analog_pir_sen_convert(unsigned char pirs)
|
|||
return pirlevel;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: sf_McuResetPir
|
||||
Description: When DailyRerpot ,Reset the Pir hardware
|
||||
Input: attrId:which kind of para want to get
|
||||
Output: N/A
|
||||
Return: N/A
|
||||
Others: N/A
|
||||
*************************************************/
|
||||
S32 sf_mcu_rebootall(U8 McuPoweroffVal)
|
||||
{
|
||||
U8 i=0;
|
||||
U8 regsize =0;
|
||||
U8 Mcuset[4];
|
||||
U8 Mcupara[4];
|
||||
U8 val=0;
|
||||
|
||||
|
||||
/*Parameter Setting.*/
|
||||
val = McuPoweroffVal;
|
||||
val |= 0x20;
|
||||
|
||||
Mcupara[i] = SYS_STATUS;
|
||||
Mcuset[i++] =val;
|
||||
|
||||
Mcupara[i] = DSP_WRITE_FLG;
|
||||
Mcuset[i++]=1;
|
||||
|
||||
regsize=i;
|
||||
|
||||
for(i=0; i<regsize; i++)
|
||||
{
|
||||
printf("add=%d--- data=%x\n",Mcupara[i],Mcuset[i]);
|
||||
|
||||
}
|
||||
|
||||
for(i=0; i<regsize; i++)
|
||||
{
|
||||
sf_commu_set_mcu(Mcupara[i],Mcuset[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char sf_mcu_reg_set(MCUParam_t attrId, unsigned char val)
|
||||
{
|
||||
unsigned char mcuReg[REG_SIZE] = {0};
|
||||
|
|
|
@ -486,7 +486,13 @@ typedef struct _UIMenuUIMenuStoreInfo {
|
|||
CHAR PicUpDailyReport;
|
||||
///////////////////////
|
||||
#endif
|
||||
|
||||
|
||||
CHAR ProfileSwitchFlg;
|
||||
CHAR ProfileEnableCmdVal;
|
||||
CHAR UpdateFlg;
|
||||
CHAR PreActiveProfileIccid[22];
|
||||
CHAR EsimEid[40];
|
||||
|
||||
CHAR CamNameStr[13];
|
||||
CHAR PwdStr[7];
|
||||
CHAR Latitude[16];
|
||||
|
|
Loading…
Reference in New Issue
Block a user