static const char DefaultCid[] = "default";
static const char automaticApn[] = "auto";
static const char PdpIpv4[] = "ipv4";
static const char PdpIpv6[] = "ipv6";
static const char PdpIpv4v6[] = "ipv4v6";
static const char AuthPap[] = "pap";
static const char AuthChap[] = "chap";
static const char AuthPapChap[] = "pap-chap";
static const char Map[] = "map";
static const char Cid[] = "cid";
static const char Rmnet[] = "rmnet";
typedef struct
{
char cid[10];
char pdp[10];
char apn[LE_MDC_APN_NAME_MAX_LEN];
char auth[10];
char userName[LE_MDC_USER_NAME_MAX_LEN];
char password[LE_MDC_PASSWORD_NAME_MAX_LEN];
}
Configuration_t;
typedef enum
{
TEST_SYNC,
TEST_ASYNC,
TEST_MAX
} Testcase_t;
struct
{
char testName[20];
Testcase_t testCase;
} testsDef[] = {
TEST_DEF(TEST_SYNC),
TEST_DEF(TEST_ASYNC),
TEST_DEF(TEST_MAX)
};
static void SessionHandlerFunc
(
le_mdc_ProfileRef_t profileRef,
void* contextPtr
)
{
*activationPtr = result;
}
static void SessionStartAsync
(
void* param1Ptr,
void* param2Ptr
)
{
le_mdc_ProfileRef_t profileRef = param1Ptr;
}
static void SessionStopAsync
(
void* param1Ptr,
void* param2Ptr
)
{
le_mdc_ProfileRef_t profileRef = param1Ptr;
}
static void SetConfiguration
(
le_mdc_ProfileRef_t* profileRefPtr
)
{
FILE* configFilePtr = fopen("/tmp/config.txt","r");
Configuration_t configuration;
memset(&configuration, 0, sizeof(Configuration_t));
if (NULL == configFilePtr)
{
le_utf8_Copy(configuration.cid, DefaultCid,
sizeof(configuration.cid), NULL);
le_utf8_Copy(configuration.pdp, PdpIpv4,
sizeof(configuration.pdp), NULL);
le_utf8_Copy(configuration.apn, automaticApn,
sizeof(configuration.apn), NULL);
}
else
{
fseek(configFilePtr, 0, SEEK_END);
uint32_t len = ftell(configFilePtr);
char cmdLine[ len + 1 ];
char* saveLinePtr;
char* saveParamPtr;
char* cmdLinePtr;
memset(cmdLine,0,len+1);
fseek(configFilePtr, 0, SEEK_SET);
fread(cmdLine, 1, len, configFilePtr);
fclose(configFilePtr);
cmdLinePtr = strtok_r(cmdLine, "\r\n", &saveLinePtr);
char* cidPtr = strtok_r(cmdLinePtr, " ", &saveParamPtr);
le_utf8_Copy(configuration.cid, cidPtr,
sizeof(configuration.cid), NULL);
char* pdpPtr = strtok_r(NULL, " ", &saveParamPtr);
le_utf8_Copy(configuration.pdp, pdpPtr,
sizeof(configuration.pdp), NULL);
char* apnPtr = strtok_r(NULL, " ", &saveParamPtr);
le_utf8_Copy(configuration.apn, apnPtr,
sizeof(configuration.apn), NULL);
char* authPtr = strtok_r(NULL, " ", &saveParamPtr);
if (NULL != authPtr)
{
le_utf8_Copy(configuration.auth, authPtr,
sizeof(configuration.auth), NULL);
}
char* userNamePtr = strtok_r(NULL, " ", &saveParamPtr);
if (NULL != userNamePtr)
{
le_utf8_Copy(configuration.userName, userNamePtr,
sizeof(configuration.userName), NULL);
}
char* passwordPtr = strtok_r(NULL, " ", &saveParamPtr);
if (NULL != passwordPtr)
{
le_utf8_Copy(configuration.password, passwordPtr,
sizeof(configuration.password), NULL);
}
cmdLinePtr = strtok_r(NULL, "\r\n", &saveLinePtr);
while (cmdLinePtr)
{
char* optionPtr = strtok_r(cmdLinePtr, " ", &saveParamPtr);
if (strncmp(optionPtr, Map, strlen(Map)) == 0)
{
char* cidPtr = strtok_r(NULL, " ", &saveParamPtr);
if (strncmp(cidPtr, Cid, strlen(Cid)) == 0)
{
int cid = strtol((const char*) cidPtr+strlen(Cid), NULL, 10);
if (0 != errno)
{
exit(EXIT_FAILURE);
}
char* rmnetPtr = strtok_r(NULL, " ", &saveParamPtr);
if (0 == strncmp(rmnetPtr, Rmnet, strlen(Rmnet)))
{
int rmnet = strtol(rmnetPtr+strlen(Rmnet), NULL, 10);
if (0 != errno)
{
exit(EXIT_FAILURE);
}
char string[20];
memset(string,0,sizeof(string));
snprintf(string,sizeof(string),"rmnet_data%d", rmnet);
LE_INFO(
"cid %d rmnet: %s", cid,
string);
}
}
}
cmdLinePtr = strtok_r(NULL, "\r\n", &saveLinePtr);
}
}
uint32_t profile;
if ( strncmp(configuration.cid, DefaultCid, sizeof(DefaultCid)) == 0 )
{
profile = LE_MDC_DEFAULT_PROFILE;
}
else
{
profile = strtol(configuration.cid, NULL, 10);
if (errno != 0)
{
exit(EXIT_FAILURE);
}
}
le_mdc_ConState_t state = LE_MDC_DISCONNECTED;
if (LE_MDC_CONNECTED == state)
{
}
le_mdc_Pdp_t pdp = LE_MDC_PDP_UNKNOWN;
if (0 == strncmp(configuration.pdp, PdpIpv4, sizeof(PdpIpv4)))
{
pdp = LE_MDC_PDP_IPV4;
}
else if (0 == strncmp(configuration.pdp, PdpIpv6, sizeof(PdpIpv6)))
{
pdp = LE_MDC_PDP_IPV6;
}
else if (0 == strncmp(configuration.pdp, PdpIpv4v6, sizeof(PdpIpv4v6)))
{
pdp = LE_MDC_PDP_IPV4V6;
}
if (0 == strncmp(configuration.apn, automaticApn, sizeof(automaticApn)))
{
}
else
{
}
le_mdc_Auth_t auth = LE_MDC_AUTH_NONE;
if ('\0' != configuration.auth[0])
{
if (0 == strncmp(configuration.auth, AuthPapChap, sizeof(AuthPapChap)))
{
auth = LE_MDC_AUTH_PAP | LE_MDC_AUTH_CHAP;
}
else if (0 == strncmp(configuration.auth, AuthPap, sizeof(AuthPap)))
{
auth = LE_MDC_AUTH_PAP;
}
else if (0 == strncmp(configuration.auth, AuthChap, sizeof(AuthChap)))
{
auth = LE_MDC_AUTH_CHAP;
}
if (LE_MDC_AUTH_NONE != auth)
{
auth,
configuration.userName,
configuration.password));
}
}
LE_INFO(
"cid: %d pdp: %d apn: %s auth: %d username: %s password: %s",
configuration.userName, configuration.password);
}