Esempio n. 1
0
//--------------------------------------------------------------------------------------------------
static void SetSimCardInfo
(
    void
)
{
    pa_simSimu_SetPin(Pin);
    pa_simSimu_SetPuk(Puk);
    pa_simSimu_SetIMSI(Imsi);
    pa_simSimu_SetCardIdentification(Iccid);
    pa_simSimu_SetSubscriberPhoneNumber(PhoneNum);
    pa_simSimu_SetHomeNetworkMccMnc(Mcc, Mnc);
    pa_simSimu_SetHomeNetworkOperator(Operator);
}
Esempio n. 2
0
//--------------------------------------------------------------------------------------------------
static void TestMdc_Configuration( void )
{
    pa_mrcSimu_SetRadioAccessTechInUse(LE_MRC_RAT_GSM);

    pa_mdc_ProfileData_t profileData;
    char newAPN[] = "NewAPN";
    int i;

    /* Configure the pa_mdcSimu */
    for (i = 0; i < NB_PROFILE; i++)
    {
        char tstAPN[10];
        snprintf(tstAPN,10,"TstAPN%d", i);
        memset(&profileData,0,sizeof(pa_mdc_ProfileData_t));
        strcpy( &profileData.apn[0], tstAPN);
        profileData.authentication.type = LE_MDC_AUTH_NONE;
        profileData.pdp = LE_MDC_PDP_IPV4;
        pa_mdcSimu_SetProfile(i+1, &profileData);
    }

    /* Allocate profiles: use le_mdc_GetProfileFromApn or le_mdc_GetProfile */
    for (i = 0; i < NB_PROFILE; i++)
    {
        char tstAPN[10];
        snprintf(tstAPN,10,"TstAPN%d", i);

        if ( (i/2)*2 == i )
        {
            LE_ASSERT_OK(le_mdc_GetProfileFromApn(tstAPN, &ProfileRef[i]));
        }
        else
        {
            ProfileRef[i] = le_mdc_GetProfile(i+1);
        }

        /* expected value: ProfileRef not null */
        LE_ASSERT(ProfileRef[i] != NULL);

        /* Check the index*/
        LE_ASSERT((i+1) == le_mdc_GetProfileIndex(ProfileRef[i]));
    }

    /* Map profile on network interface */
    LE_ASSERT(le_mdc_MapProfileOnNetworkInterface(ProfileRef[0], "rmnet_data0") == LE_OK);

    /* Get and change APN of 1st profile */
    char apn[30];
    LE_ASSERT_OK(le_mdc_GetAPN(ProfileRef[0], apn, sizeof(apn)));
    LE_ASSERT(0 == strcmp("TstAPN0", apn));
    LE_ASSERT_OK(le_mdc_SetAPN(ProfileRef[0], newAPN));
    LE_ASSERT_OK(le_mdc_GetAPN(ProfileRef[0], apn, sizeof(apn)));
    LE_ASSERT(0 == strcmp(newAPN, apn));

    /* Check to get a profile thanks to its APN */
    le_mdc_ProfileRef_t profile;
    LE_ASSERT(LE_NOT_FOUND == le_mdc_GetProfileFromApn("TstAPN0", &profile));
    LE_ASSERT_OK(le_mdc_GetProfileFromApn(newAPN, &profile));
    LE_ASSERT(profile == ProfileRef[0]);

    /* Get and change authentication */
    le_mdc_Auth_t auth;
    char userName[10];
    char password[10];
    char myUserName[]="myName";
    char myPassword[]="myPwd";
    LE_ASSERT_OK(le_mdc_GetAuthentication(ProfileRef[0], &auth, userName, sizeof(userName),
                                          password, sizeof(password)));
    LE_ASSERT(LE_MDC_AUTH_NONE == auth);
    LE_ASSERT_OK(le_mdc_SetAuthentication(ProfileRef[0], LE_MDC_AUTH_PAP,
                                          myUserName, myPassword));
    LE_ASSERT_OK(le_mdc_GetAuthentication(ProfileRef[0], &auth, userName, sizeof(userName),
                                          password, sizeof(password)));
    LE_ASSERT(LE_MDC_AUTH_PAP == auth);
    LE_ASSERT(0 == strcmp(userName, myUserName));
    LE_ASSERT(0 == strcmp(password, myPassword));

    /* Get PDP type and change it */
    LE_ASSERT(LE_MDC_PDP_IPV4 == le_mdc_GetPDP(ProfileRef[0]));
    LE_ASSERT_OK(le_mdc_SetPDP(ProfileRef[0], LE_MDC_PDP_IPV6));
    LE_ASSERT(LE_MDC_PDP_IPV6 == le_mdc_GetPDP(ProfileRef[0]));

    /* start a session: profile can't be modified when a session is activated */
    LE_ASSERT_OK(le_mdc_StartSession(ProfileRef[0]));

    /* Try to set APN (error is expected as a connection is in progress) */
    LE_ASSERT(LE_FAULT == le_mdc_SetAPN(ProfileRef[0], "TstAPN0"));
    /* Get is possible */
    LE_ASSERT_OK(le_mdc_GetAPN(ProfileRef[0], apn, sizeof(apn)));
    LE_ASSERT(0 == strcmp(newAPN, apn));

    /* Try to set authentication (error is expected as a connection is in progress) */
    LE_ASSERT(LE_FAULT == le_mdc_SetAuthentication(ProfileRef[0], LE_MDC_AUTH_CHAP,
                                                   myUserName, myPassword));
    /* Get is possible */
    LE_ASSERT_OK(le_mdc_GetAuthentication(ProfileRef[0], &auth, userName, sizeof(userName),
                                          password, sizeof(password)));
    LE_ASSERT(LE_MDC_AUTH_PAP == auth);
    LE_ASSERT(0 == strcmp(userName, myUserName));
    LE_ASSERT(0 == strcmp(password, myPassword));

    /* Try to set PDP type (error is expected as a connection is in progress) */
    LE_ASSERT(LE_FAULT == le_mdc_SetPDP(ProfileRef[0], LE_MDC_PDP_IPV4V6));
    /* Get is possible */
    LE_ASSERT(LE_MDC_PDP_IPV6 == le_mdc_GetPDP(ProfileRef[0]));

    /* Check that other profiles didn't change */
    for (i = 1; i < NB_PROFILE; i++)
    {
        char tstAPN[10];
        snprintf(tstAPN,10,"TstAPN%d", i);

        /* Check APN */
        LE_ASSERT_OK(le_mdc_GetAPN(ProfileRef[i], apn, sizeof(apn)));
        LE_ASSERT(0 == strcmp(tstAPN, apn));

        /* Check auth */
        LE_ASSERT_OK(le_mdc_GetAuthentication(ProfileRef[i], &auth, userName, sizeof(userName),
                                              password, sizeof(password)));
        LE_ASSERT(LE_MDC_AUTH_NONE == auth);

        /* Check PDP type */
        LE_ASSERT(LE_MDC_PDP_IPV4 == le_mdc_GetPDP(ProfileRef[i]));

        /* Check to get a profile thanks to its APN */
        LE_ASSERT_OK(le_mdc_GetProfileFromApn(tstAPN, &profile));
        LE_ASSERT(profile == ProfileRef[i]);
    }

    /* stop the session */
    LE_ASSERT_OK(le_mdc_StopSession(ProfileRef[0]));

    /* Test default APNs */
    char homeMcc[] = "000";
    char homeMnc[] = "00";
    pa_simSimu_ReportSIMState(LE_SIM_READY);
    pa_simSimu_SetHomeNetworkMccMnc(homeMcc, homeMnc);
    pa_simSimu_SetCardIdentification("");
    TriggerSimRefresh();

    LE_ASSERT(LE_FAULT == le_mdc_SetDefaultAPN(ProfileRef[2]));

    /* Set default APN based on MCC and MNC */
    strcpy(homeMcc, "208");
    strcpy(homeMnc, "01");
    pa_simSimu_SetHomeNetworkMccMnc(homeMcc, homeMnc);
    LE_ASSERT_OK(le_mdc_SetDefaultAPN(ProfileRef[2]));
    /* Check APN */
    LE_ASSERT_OK(le_mdc_GetAPN(ProfileRef[2], apn, sizeof(apn)));
    LE_ASSERT(0 == strcmp("orange", apn));

    /* Set default APN based on ICCID, MCC and MNC */
    char iccid[] = "89332422217010081060";

    pa_simSimu_SetCardIdentification(iccid);
    TriggerSimRefresh();

    LE_ASSERT_OK(le_mdc_SetDefaultAPN(ProfileRef[2]));
    /* Check APN */
    LE_ASSERT_OK(le_mdc_GetAPN(ProfileRef[2], apn, sizeof(apn)));
    LE_ASSERT(0 == strcmp("internet.sierrawireless.com", apn));
}