Ejemplo n.º 1
0
int CRANAPptl::parseCommonID(struct CommonID* pCommonID)
{
    if(NULL == pCommonID) return -1;
    for(int ii = 0; ii < pCommonID->protocolIEs.size; ++ii)
    {
        switch(pCommonID->protocolIEs.elements[ii].id)
        {
            case RANAP_PARAM_PermanentNAS_UE_ID:// 23 id-PermanentNAS-UE-ID
            {
                struct PermanentNAS_UE_ID* pPermanentNAS_UE_ID =  &pCommonID->protocolIEs.elements[ii].value.permanentNAS_UE_ID;
                if(pPermanentNAS_UE_ID->choice == PermanentNAS_UE_ID_iMSI_chosen)
                {
                    unsigned char decodedIMSI[15] = {0};
                    unsigned int decodedLen = sizeof(decodedIMSI);
                    decodeBCD((unsigned char*)(&pPermanentNAS_UE_ID->value.iMSI.bytes[0]), pPermanentNAS_UE_ID->value.iMSI.length, decodedIMSI, decodedLen);
                    //@zh just for test
                    //printf("parseCommonID:IMSI: %s\n", (char*)&decodedIMSI[0]);
                    //
                    PutIE(RANAP_IE_P_UE_ID, decodedLen, decodedIMSI);
                }
            }
            default:
                break;
        }
    }
    return 0;
}
Ejemplo n.º 2
0
int CRANAPptl::parsePermanentNAS_UE_ID(asnContext* context, asnOpenType* pdu)
{
    PermanentNAS_UE_ID imsi;
    asnMAXUINT iDecoded = imsi.PERdecode(context, pdu);
    if(imsi.value->alternative == asn_iMSI)
    {
        asnciMSI* pimsi = (asnciMSI*)(imsi.value);
        asnbytep bcdbuf = NULL;
        asnMAXUINT bcdlen = 0;
        pimsi->iMSI.readOctetString(&bcdlen, &bcdbuf);
        if(bcdbuf)
        {
            unsigned char decodedIMSI[15] = {0};
            unsigned int decodedLen = sizeof(decodedIMSI);
            decodeBCD(bcdbuf, bcdlen, decodedIMSI, decodedLen);
            //@zh just for test
            //printf("PAGING:IMSI: %s\n", (char*)&decodedIMSI[0]);
            PutIE(RANAP_IE_P_UE_ID, decodedLen, decodedIMSI);
        }
    }
    return 0;
}
Ejemplo n.º 3
0
void MSFTime::doDecode()
{

    if( mBitIndex != 60 ) // there are always 59 bits, barring leap-seconds
    {
      #ifdef DEBUG
        Serial.println("Wrong number of bits ");
      #endif
      return;
    }

    if( ! checkValid())
    {
      #ifdef DEBUG
        Serial.println("Not valid");
      #endif
      return;
    }



    mFixMillis = millis() - 500L;

    mFixYear = decodeBCD( mABits, 24, 17 );    // 0-99
    mFixMonth = decodeBCD( mABits, 29, 25 );   // 1-12
    mFixDayOfMonth = decodeBCD( mABits, 35, 30 );  // 1-31
    mFixDayOfWeek = decodeBCD( mABits, 38, 36 );
    mFixHour = decodeBCD( mABits, 44, 39 );  // 0-23
    mFixMinute = decodeBCD( mABits, 51, 45 );  // 0-59

    #ifdef DEBUG
    Serial.println("Decoded");
    Serial.print(2000+(int)mFixYear);
    Serial.print("/");

    Serial.print((int)mFixMonth);

    Serial.print("/");
    Serial.println((int)mFixDayOfMonth);
    //Serial.println((int)mFixDayOfWeek);
    Serial.print((int)mFixHour);
    Serial.print(":");
    Serial.println((int)mFixMinute);
    #endif
}
Ejemplo n.º 4
0
int CRANAPptl::parsePaging(struct Paging* pPaging)
{
    if(NULL == pPaging) return -1;
    for(int ii = 0; ii < pPaging->protocolIEs.size; ++ii)
    {
        switch(pPaging->protocolIEs.elements[ii].id)
        {
            case RANAP_PARAM_CN_DomainIndicator:// 3 id-CN-DomainIndicator
                break;
            case RANAP_PARAM_PermanentNAS_UE_ID:// 23 id-PermanentNAS-UE-ID
            {
                struct PermanentNAS_UE_ID* pPermanentNAS_UE_ID = &pPaging->protocolIEs.elements[ii].value.permanentNAS_UE_ID;
                if(pPermanentNAS_UE_ID->choice == PermanentNAS_UE_ID_iMSI_chosen)
                {
                    unsigned char decodedIMSI[15] = {0};
                    unsigned int decodedLen = sizeof(decodedIMSI);
                    decodeBCD((unsigned char*)(&pPermanentNAS_UE_ID->value.iMSI.bytes[0]), pPermanentNAS_UE_ID->value.iMSI.length, decodedIMSI, decodedLen);
                    //@zh just for test
                    //printf("parsePaging:IMSI: %s\n", (char*)&decodedIMSI[0]);
                    //
                    PutIE(RANAP_IE_P_UE_ID, decodedLen, decodedIMSI);
                }
            }
                break;
            case RANAP_PARAM_TemporaryUE_ID:// 64 id-TemporaryUE-ID
            {
                struct TemporaryUE_ID* pTemporaryUE_ID = &pPaging->protocolIEs.elements[ii].value.temporaryUE_ID;
                if(pTemporaryUE_ID->choice == TemporaryUE_ID_tMSI_chosen)
                {
                    //@zh just for test
                    //printf("parsePaging:TMSI: 0x");
                    //for(int ij = 0; ij < pTemporaryUE_ID->value.tMSI.length; ++ij)
                    //{
                    //    printf("%02hhx", pTemporaryUE_ID->value.tMSI.bytes[ij]);
                    //}
                    //printf("\n");
                    //
                    PutIE(RANAP_IE_T_UE_IE, pTemporaryUE_ID->value.tMSI.length, (unsigned char*)(&pTemporaryUE_ID->value.tMSI.bytes[0]));
                }
            }
                break;
            case RANAP_PARAM_PagingAreaID:// 21 id-PagingAreaID
            {
                struct PagingAreaID* pPagingAreaID = &pPaging->protocolIEs.elements[ii].value.pagingAreaID;
                if(pPagingAreaID->choice == PagingAreaID_lAI_chosen)
                {
                    struct LAI* pLAI = &pPagingAreaID->value.lAI;
                }
                else if(pPagingAreaID->choice == PagingAreaID_rAI_chosen)
                {
                    struct RAI* pRAI = &pPagingAreaID->value.rAI;
                }
            }
                break;
            case RANAP_PARAM_PagingCause:// 22 id-PagingCause
            {
                enum PagingCause pcs = pPaging->protocolIEs.elements[ii].value.pagingCause;
            }
                break;
            default:
                break;

        }
    }
    return 0;
}