コード例 #1
0
ファイル: GenBufs.cpp プロジェクト: d-chugunov/asn1cpp
std::vector<uint8_t> Buf4() {
  std::vector<uint8_t> buf(DEFAULT_BUF_SIZE);
  long oneT1;
  oneT1 = 123;
  long twoT1;
  twoT1 = 456;
  long threeT1;
  threeT1 = 789;
  SetOfT2setof rec;
  memset(&rec, 0, sizeof(rec));
  
  SetOfT1_t one;
  memset(&one, 0, sizeof(one));
  ASN_SEQUENCE_ADD(&one, &oneT1);
  ASN_SEQUENCE_ADD(&one, &twoT1);
  SetOfT1_t two;
  memset(&two, 0, sizeof(two));
  ASN_SEQUENCE_ADD(&two, &threeT1);
  
  ASN_SET_ADD(&rec, &one);
  ASN_SET_ADD(&rec, &two);
  
  asn_enc_rval_t rval;
  rval = der_encode_to_buffer(&asn_DEF_SetOfT2setof, &rec, (void*)buf.data(), buf.size());
  if (rval.encoded >= 0) {
    buf.resize(rval.encoded);
  } else {
    printf("cannot encode record in Buf3");
    exit(0);
  }
  return std::move(buf);
}
コード例 #2
0
ファイル: GenBufs.cpp プロジェクト: d-chugunov/asn1cpp
std::vector<uint8_t> Buf1() {
  std::vector<uint8_t> buf(DEFAULT_BUF_SIZE);
  long oneT1;
  oneT1 = 123;
  long twoT1;
  twoT1 = 456;
  long threeT1;
  threeT1 = 789;
  SequenceT2setof rec;
  memset(&rec, 0, sizeof(rec));
  ASN_SEQUENCE_ADD(&rec.one, &oneT1);
  ASN_SEQUENCE_ADD(&rec.one, &twoT1);
  rec.two = (struct SetOfT1*)malloc(sizeof(*rec.two));
  memset(rec.two, 0, sizeof(*rec.two));
  ASN_SEQUENCE_ADD(rec.two, &threeT1);
  asn_enc_rval_t rval;
  rval = der_encode_to_buffer(&asn_DEF_SequenceT2setof, &rec, (void*)buf.data(), buf.size());
  if (rval.encoded >= 0) {
    buf.resize(rval.encoded);
  } else {
    printf("cannot encode record in Buf1");
    exit(0);
  }
  return std::move(buf);
}
コード例 #3
0
ファイル: GenBufs.cpp プロジェクト: d-chugunov/asn1cpp
std::vector<uint8_t> Buf3() {
  std::vector<uint8_t> buf(DEFAULT_BUF_SIZE);
  SequenceOfT2seq rec;
  memset(&rec, 0, sizeof(rec));
  
  SeqT1_t one;
  memset(&one, 0, sizeof(one));
  one.first = 123;
  one.second = 321;
  SeqT1_t two;
  memset(&two, 0, sizeof(two));
  two.first = 654;
  two.second = 456;
  
  ASN_SEQUENCE_ADD(&rec, &one);
  ASN_SEQUENCE_ADD(&rec, &two);
  
  asn_enc_rval_t rval;
  rval = der_encode_to_buffer(&asn_DEF_SequenceOfT2seq, &rec, (void*)buf.data(), buf.size());
  if (rval.encoded >= 0) {
    buf.resize(rval.encoded);
  } else {
    printf("cannot encode record in Buf3");
    exit(0);
  }
  return std::move(buf);
}
コード例 #4
0
static LDAPMessage_t *search_result_entry(int messageId, char *name, char *email, char *jpegFilename) {
    LDAPMessage_t *msg = calloc(1, sizeof *msg);
    SearchResultEntry_t *entry;

    msg->messageID = messageId;
    msg->protocolOp.present = LDAPMessage__protocolOp_PR_searchResEntry;
    entry = &msg->protocolOp.choice.searchResEntry;
    OCTET_STRING_fromString(&entry->objectName, name);

    ASN_SEQUENCE_ADD(&entry->attributes, make_partial_attribute("cn", name));
    ASN_SEQUENCE_ADD(&entry->attributes, make_partial_attribute("mail", email));
    if(jpegFilename)
        ASN_SEQUENCE_ADD(&entry->attributes,
            make_partial_attribute_from_file("jpegPhoto", jpegFilename));

    return msg;
}
コード例 #5
0
ファイル: UMTSPhCh.cpp プロジェクト: 57-Wolve/OpenBTS-UMTS
// 25.331 10.3.6.21 Downlink DPCH for each Radio Link.
ASN::DL_DPCH_InfoPerRL *PhCh::toAsnDL_DPCH_InfoPerRL()
{
	ASN::DL_DPCH_InfoPerRL *result = RN_CALLOC(ASN::DL_DPCH_InfoPerRL); 
	result->present = ASN::DL_DPCH_InfoPerRL_PR_fdd;

	// This is a boolean value:
	// PCPICH_UsageForChannelEst_t  pCPICH_UsageForChannelEst;
	int cpichUsage = gConfig.getNum("UMTS.PCPICHUsageForChannelEst");
	assert(cpichUsage == 0 || cpichUsage == 1);	// kinda harsh
	int asncuval = cpichUsage ?
		ASN::PCPICH_UsageForChannelEst_mayBeUsed : 
		ASN::PCPICH_UsageForChannelEst_shallNotBeUsed;
	result->choice.fdd.pCPICH_UsageForChannelEst = toAsnEnumerated(asncuval);

	// "Offset in number of chips between the beginning of the P-CCPCH frame
	// and the beginning of the DPCH frame" aka Tau(DPCH,n)
	// DPCH_FrameOffset_t   dpch_FrameOffset;
	int dpchFrameOffset = gConfig.getNum("UMTS.DPCHFrameOffset");
	assert(dpchFrameOffset >= 0 && dpchFrameOffset <= 38144);	// harsh
	assert(dpchFrameOffset % 256 == 0);
	result->choice.fdd.dpch_FrameOffset = dpchFrameOffset;


	// struct SecondaryCPICH_Info  *secondaryCPICH_Info    /* OPTIONAL */;

	// Eventually we are going to find the darned Channelization code in here.
	// DL_ChannelisationCodeList_t  dl_ChannelisationCodeList;
	ASN::DL_ChannelisationCode *one = RN_CALLOC(ASN::DL_ChannelisationCode); 

#define DORKINESS(spf) \
	case spf: \
		one->sf_AndCodeNumber.present = ASN::SF512_AndCodeNumber_PR_sf##spf; \
		one->sf_AndCodeNumber.choice.sf##spf = SpCode(); \
		break;

	switch (this->mDlSF) {
		DORKINESS(4)
		DORKINESS(8)
		DORKINESS(16)
		DORKINESS(32)
		DORKINESS(64)
		DORKINESS(128)
		DORKINESS(256)
		DORKINESS(512)
		default:assert(0);
	}
	ASN_SEQUENCE_ADD(&result->choice.fdd.dl_ChannelisationCodeList,one);

	// This is for multiple radio links, and we will never use it, so just default it:
	// TPC_CombinationIndex_t   tpc_CombinationIndex;
	result->choice.fdd.tpc_CombinationIndex = 0;	// a fine wonderful tpc index.

	// SSDT_CellIdentity_t *dummy  /* OPTIONAL */;
	// ClosedLoopTimingAdjMode_t   *closedLoopTimingAdjMode    /* OPTIONAL */;

	return result;
}
コード例 #6
0
static PartialAttribute_t *make_partial_attribute(char *key, char *value) {
    PartialAttribute_t *pa = calloc(1, sizeof *pa);

    OCTET_STRING_fromString(&pa->type, key);
    ASN_SEQUENCE_ADD(&pa->vals,
        OCTET_STRING_new_fromBuf(&asn_DEF_AttributeValue, value, -1));

    return pa;
}
コード例 #7
0
//-----------------------------------------------------------------
RadioResourceConfigDedicated_t* Mobile::GetASN1RadioResourceConfigDedicated(transaction_id_t transaction_idP)
//-----------------------------------------------------------------
{
    RadioResourceConfigDedicated_t* config = static_cast<RadioResourceConfigDedicated_t*>(CALLOC(1,sizeof(RadioResourceConfigDedicated_t)));

    config->srb_ToAddModList = NULL;
    config->drb_ToReleaseList = NULL;
    config->drb_ToAddModList  = NULL;

    for (int i = 0 ; i < MAX_DRB; i++) {
        for (int j = 0 ; j < MAX_ENODE_B_PER_MOBILE; j++) {
            // Look if there is a transaction for removing a DRB
            if (m_tx_id_pending_drb_to_release[i][j] == transaction_idP) {
                if (config->drb_ToReleaseList == NULL) {
                    config->drb_ToReleaseList = static_cast<DRB_ToReleaseList_t*>(CALLOC(1,sizeof(DRB_ToReleaseList_t)));
                }
                cerr << "[RRM] Mobile::GetASN1RadioResourceConfigDedicated(" << transaction_idP << ") Releasing DRB "<< m_pending_drb_to_release[i][j] << endl;
                ASN_SEQUENCE_ADD(&config->drb_ToReleaseList->list,Asn1Utils::Clone(&m_pending_drb_to_release[i][j]));
            }
            if (m_tx_id_pending_drb_to_add_mod[i][j] == transaction_idP) {
                if (config->drb_ToAddModList == NULL) {
                    config->drb_ToAddModList = static_cast<DRB_ToAddModList_t*>(CALLOC(1,sizeof(DRB_ToAddModList_t)));
                }
                cerr << "[RRM] Mobile::GetASN1RadioResourceConfigDedicated(" << transaction_idP << ") Adding DRB "<< m_pending_drb_to_add_mod[i][j] << endl;
                ASN_SEQUENCE_ADD(&config->drb_ToAddModList->list, Asn1Utils::Clone(m_pending_drb_to_add_mod[i][j]));
            }
        }
    }
    for (int i = 0 ; i < MAX_SRB; i++) {
        for (int j = 0 ; j < MAX_ENODE_B_PER_MOBILE; j++) {
            if (m_tx_id_pending_srb_to_add_mod[i][j] == transaction_idP) {
                if (config->srb_ToAddModList == NULL) {
                    config->srb_ToAddModList = static_cast<SRB_ToAddModList_t*>(CALLOC(1,sizeof(SRB_ToAddModList_t)));
                }
                cerr << "[RRM] Mobile::GetASN1RadioResourceConfigDedicated(" << transaction_idP << ") Adding SRB "<< m_pending_srb_to_add_mod[i][j] << endl;
                ASN_SEQUENCE_ADD(&config->srb_ToAddModList->list, Asn1Utils::Clone(m_pending_srb_to_add_mod[i][j]));
            }
        }
    }

    config->mac_MainConfig                = static_cast<RadioResourceConfigDedicated::RadioResourceConfigDedicated__mac_MainConfig*>(CALLOC(1,sizeof(RadioResourceConfigDedicated::RadioResourceConfigDedicated__mac_MainConfig)));
    config->mac_MainConfig->present       = RadioResourceConfigDedicated__mac_MainConfig_PR_defaultValue;
    return config;
}
コード例 #8
0
int s1ap_eNB_generate_s1_setup_request(struct s1ap_eNB_description_s* eNB_ref) {

    SupportedTAs_Item_t ta;
    PLMNidentity_t plmnIdentity;
    S1SetupRequestIEs_t s1SetupRequest;

    char tac[] = { 0x00, 0x01 };
    char identity[] = { 0x02, 0x08, 0x34 };
    char eNBname[150];
    int eNBnameLength = 0;
    uint8_t *buffer;
    uint32_t len;

    if (eNB_ref == NULL) return -1;

    memset((void *)&s1SetupRequest, 0, sizeof(S1SetupRequestIEs_t));
    s1SetupRequest.global_ENB_ID.eNB_ID.present = ENB_ID_PR_macroENB_ID;
    s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.buf = calloc(1,3);
    s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.buf[0] = eNB_ref->eNB_id;
    s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.size = 3;
    s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.bits_unused = 4;
    OCTET_STRING_fromBuf(&s1SetupRequest.global_ENB_ID.pLMNidentity, identity, 3);

    eNBnameLength = sprintf(eNBname, "eNB %d Eurecom", eNB_ref->eNB_id);
    if (eNBnameLength > 0) {
        s1SetupRequest.presenceMask |= S1SETUPREQUESTIES_ENBNAME_PRESENT;
        OCTET_STRING_fromBuf(&s1SetupRequest.eNBname, eNBname, eNBnameLength);
    }

    memset((void *)&ta, 0, sizeof(SupportedTAs_Item_t));
    memset((void *)&plmnIdentity, 0, sizeof(PLMNidentity_t));
    OCTET_STRING_fromBuf(&ta.tAC, tac, 2);
    OCTET_STRING_fromBuf(&plmnIdentity, identity, 3);
    ASN_SEQUENCE_ADD(&ta.broadcastPLMNs, &plmnIdentity);
    ASN_SEQUENCE_ADD(&s1SetupRequest.supportedTAs, &ta);

    s1SetupRequest.defaultPagingDRX = PagingDRX_v64;

    if (s1ap_eNB_encode_s1_setup_request(&s1SetupRequest, &buffer, &len) < 0)
        return -1;
    eNB_ref->state |= S1AP_ENB_STATE_WAITING;
    return sctp_send_msg(eNB_ref->assocId, 0, buffer, len);
}
コード例 #9
0
int
main (
  int argc,
  char *argv[])
{
  asn_enc_rval_t                          retVal;
  uint8_t                                *buffer;
  uint32_t                                len;
  SupportedTAs_Item_t                     ta;
  PLMNidentity_t                          plmnIdentity;

  asn_debug = 0;
  asn1_xer_print = 0;
  S1SetupRequestIEs                       s1SetupRequest;

  memset (&s1SetupRequest, 0, sizeof (S1SetupRequestIEs));
  s1SetupRequest.global_ENB_ID.eNB_ID.present = ENB_ID_PR_macroENB_ID;
  s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.buf = id;
  s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.size = 3;
  s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.bits_unused = 4;
  OCTET_STRING_fromBuf (&s1SetupRequest.global_ENB_ID.pLMNidentity, identity, 3);
  s1SetupRequest.presenceMask |= S1SETUPREQUESTIES_ENBNAME_PRESENT;
  OCTET_STRING_fromBuf (&s1SetupRequest.eNBname, "ENB 1 eurecom", strlen ("ENB 1 eurecom"));
  memset (&ta, 0, sizeof (SupportedTAs_Item_t));
  memset (&plmnIdentity, 0, sizeof (PLMNidentity_t));
  OCTET_STRING_fromBuf (&ta.tAC, tac, 2);
  OCTET_STRING_fromBuf (&plmnIdentity, identity, 3);
  ASN_SEQUENCE_ADD (&ta.broadcastPLMNs, &plmnIdentity);
  ASN_SEQUENCE_ADD (&s1SetupRequest.supportedTAs, &ta);
  s1SetupRequest.defaultPagingDRX = PagingDRX_v64;
  s1ap_eNB_encode_s1setuprequest (&s1SetupRequest, &buffer, &len);
  assoc[0] = sctp_connect_to_remote_host (ip_addr, 36412, &recv_callback);
  sctp_send_msg (0, 0, buffer, len);
  free (buffer);
  //     generateUplinkNASTransport(&buffer, &len);
  //     sctp_send_msg(assoc[0], 0, buffer, len);
  //     s1ap_mme_decode_pdu(buffer, len);
  pthread_join (sctp_get_receiver_thread (assoc[0]), NULL);
  return (0);
}
コード例 #10
0
static void
check_serialize() {
	LogLine_t ll;
	VariablePartSet_t vps;
	VariablePart_t vp;
	VisibleString_t vpart;
	asn_enc_rval_t erval;
	int i;

	memset(&ll, 0, sizeof(ll));
	memset(&vps, 0, sizeof(vps));
	memset(&vp, 0, sizeof(vp));
	memset(&vpart, 0, sizeof(vpart));
	vpart.buf = "123";
	vpart.size = 3;

	vp.present = VariablePart_PR_vset;
	ASN_SET_ADD(&vp.choice.vset, &vpart);
	vps.resolution.accept_as = accept_as_unknown;
	ASN_SEQUENCE_ADD(&vps.vparts, &vp);
	ASN_SEQUENCE_ADD(&ll.varsets, &vps);
	ll.line_digest.buf = "zzz\007";
	ll.line_digest.size = 4;

	asn_fprint(stderr, &asn_DEF_LogLine, &ll);
	buf_size = 128;
	buf = alloca(buf_size);
	erval = der_encode(&asn_DEF_LogLine, &ll, buf_fill, 0);
	assert(erval.encoded > 1);
	fprintf(stderr, "Encoded in %d bytes\n", erval.encoded);
	fprintf(stderr, "\n");
	for(i = 0; i < buf_pos; i++) {
		fprintf(stderr, "%d ", buf[i]);
	}
	fprintf(stderr, "\n\n");
	assert(erval.encoded == sizeof(buf0));
	assert(memcmp(buf0, buf, sizeof(buf0)) == 0);
}
コード例 #11
0
ファイル: check-42.c プロジェクト: Kampbell/asn1c
static void
check_serialize() {
	LogLine_t ll;
	VariablePartSet_t *vps;
	VariablePart_t *vp;
	VisibleString_t *vpart;
	asn_enc_rval_t erval;
	int i;

	memset(&ll, 0, sizeof(ll));
	vps = calloc(1, sizeof(*vps));
	vp = calloc(1, sizeof(*vp));
	vpart = OCTET_STRING_new_fromBuf(&asn_DEF_VisibleString, "123", 3);

	vp->present = VariablePart_PR_vset;
	ASN_SET_ADD(&vp->choice.vset, vpart);
	vps->resolution.accept_as = accept_as_unknown;
	ASN_SEQUENCE_ADD(&vps->vparts, vp);
	ASN_SEQUENCE_ADD(&ll.varsets, vps);
	OCTET_STRING_fromBuf(&ll.line_digest, "zzz\007", 4);

	asn_fprint(stderr, &asn_DEF_LogLine, &ll);
	buf_size = 128;
	uint8_t scratch[buf_size];
	buf = scratch;
	erval = der_encode(&asn_DEF_LogLine, &ll, buf_fill, 0);
	assert(erval.encoded > 1);
	fprintf(stderr, "Encoded in %zd bytes\n", erval.encoded);
	fprintf(stderr, "\n");
	for(i = 0; i < buf_pos; i++) {
		fprintf(stderr, "%d ", buf[i]);
	}
	fprintf(stderr, "\n\n");
	assert(erval.encoded == sizeof(buf0));
	assert(memcmp(buf0, buf, sizeof(buf0)) == 0);
	ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_LogLine, &ll);
	return;
}
コード例 #12
0
ファイル: GenBufs.cpp プロジェクト: d-chugunov/asn1cpp
std::vector<uint8_t> Buf5() {
  std::vector<uint8_t> buf(DEFAULT_BUF_SIZE);
  long oneT1;
  oneT1 = 123;
  long twoT1;
  twoT1 = 456;
  long threeT1;
  threeT1 = 789;
  ChoiceT2setof rec;
  memset(&rec, 0, sizeof(rec));
  rec.present = ChoiceT2setof_PR::ChoiceT2setof_PR_one;
  ASN_SEQUENCE_ADD(&rec.choice.one, &oneT1);
  ASN_SEQUENCE_ADD(&rec.choice.one, &twoT1);
  ASN_SEQUENCE_ADD(&rec.choice.one, &threeT1);
  asn_enc_rval_t rval;
  rval = der_encode_to_buffer(&asn_DEF_ChoiceT2setof, &rec, (void*)buf.data(), buf.size());
  if (rval.encoded >= 0) {
    buf.resize(rval.encoded);
  } else {
    printf("cannot encode record in Buf5");
    exit(0);
  }
  return std::move(buf);
}
コード例 #13
0
ファイル: GenBufs.cpp プロジェクト: d-chugunov/asn1cpp
std::vector<uint8_t> Buf1() {
  std::vector<uint8_t> buf(DEFAULT_BUF_SIZE);
  SequenceRecord_I_IO_I_t rec1;
  memset(&rec1, 0, sizeof(rec1));
  rec1.type = 1;
  rec1.type3 = 10;
  SequenceRecord_I_IO_I_t rec2;
  memset(&rec2, 0, sizeof(rec2));
  rec2.type = 2;
  rec2.type3 = 20;
  SequenceRecord_SeqOfSeqRec_SeqRec_I_IO_I_t rec;
  memset(&rec, 0, sizeof(rec));
  ASN_SEQUENCE_ADD(&rec.sequenceRecord_I_IO_I.list, &rec1);
  ASN_SEQUENCE_ADD(&rec.sequenceRecord_I_IO_I.list, &rec2);
  asn_enc_rval_t rval;
  rval = der_encode_to_buffer(&asn_DEF_SequenceRecord_SeqOfSeqRec_SeqRec_I_IO_I, &rec, (void*)buf.data(), buf.size());
  if (rval.encoded >= 0) {
    buf.resize(rval.encoded);
  } else {
    printf("cannot encode record in Buf1");
    exit(0);
  }
  return std::move(buf);
}
コード例 #14
0
static PartialAttribute_t *make_partial_attribute_from_file(char *key, char *filename) {
    PartialAttribute_t *pa = calloc(1, sizeof *pa);
    char buffer[4096];
    size_t buflen;

    FILE *f = fopen(filename, "rb");
    assert(f);
    buflen = fread(buffer, 1, sizeof buffer, f);
    fclose(f);

    OCTET_STRING_fromString(&pa->type, key);
    ASN_SEQUENCE_ADD(&pa->vals,
        OCTET_STRING_new_fromBuf(&asn_DEF_AttributeValue, buffer, buflen));

    return pa;
}
コード例 #15
0
ファイル: UMTSPhCh.cpp プロジェクト: 57-Wolve/OpenBTS-UMTS
// 25.331 10.3.6.27 Downlink information for each radio link
ASN::DL_InformationPerRL_List * PhCh::toAsnDL_InformationPerRL_List()
{
	ASN::DL_InformationPerRL_List *result = RN_CALLOC(ASN::DL_InformationPerRL_List); 

	ASN::DL_InformationPerRL *one = RN_CALLOC(ASN::DL_InformationPerRL);

	one->modeSpecificInfo.present = ASN::DL_InformationPerRL__modeSpecificInfo_PR_fdd;
	// 10.3.6.60 Primary Scrambling Code (CPICH) in the range 0..511
	int primarySC = gConfig.getNum("UMTS.Downlink.ScramblingCode");
	assert(primarySC >= 0 && primarySC < 512);	// kinda harsh.
	one->modeSpecificInfo.choice.fdd.primaryCPICH_Info.primaryScramblingCode = primarySC;

	// struct DL_DPCH_InfoPerRL    *dl_DPCH_InfoPerRL  /* OPTIONAL */;
	one->dl_DPCH_InfoPerRL = toAsnDL_DPCH_InfoPerRL();

	// struct SCCPCH_InfoForFACH   *dummy  /* OPTIONAL */;

	ASN_SEQUENCE_ADD(&result->list,one);
	return result;
}
コード例 #16
0
ファイル: my-program.c プロジェクト: tonches/libadsb
u8
Encode_DER_Packet(MyPacket * Pkt, u8 * buf)
{
 
        u8              oid[] = { 1, 3, 6, 1, 5, 9, 0, 0, 0, 0 };
 
        /*
         * MyPacket_t and MyInt_t declared in MyPacket.h and MyInt.h
         */
 
        MyPacket_t     *myPacket;
 
        MyInt_t        *myInt;
        asn_enc_rval_t  er;     /* Encoder return value */
 
        u8              ret, i;
 
        myPacket = calloc(1, sizeof *myPacket);
 
        /*
         * Fill in myObjectId so that the other end knows which
         * protocol is this
         */
 
        ret = OBJECT_IDENTIFIER_set_arcs(&myPacket->myObjectId, oid,
                                         sizeof(oid[0]),
                                         sizeof(oid) / sizeof(oid[0]));
 
        if (ret != 0)
                goto fail;
 
        /*
         * Fill in myInts
         */
 
 
        for (i = 0; i < INTARRAYSIZE; i++)
          {
                  myInt = calloc(1, sizeof *myInt);
                  *myInt = Pkt->myInts[i];
                  ret = ASN_SEQUENCE_ADD(&myPacket->myInts, myInt);
                  if (ret != 0)
                          goto fail;
          }
 
        /*
         * Fill in myName
         */
 
        myPacket->myName.buf = calloc(1, strlen(Pkt->myName) + 1);
        strcpy(myPacket->myName.buf, Pkt->myName);
        myPacket->myName.size = strlen(Pkt->myName);
 
        /*
         * Fill in myFlags
         */
 
        myPacket->myFlags.buf = calloc(1, 1);
        myPacket->myFlags.size = 1 /* 1 byte */ ;
 
        for (i = 0; i < 8; i++)
                if (Pkt->myFlags & (1 << i))
                        myPacket->myFlags.buf[0] |= (1 << (7 - i));
 
        /*
         * Encode to DER and place result in buf
         */
 
        er = der_encode_to_buffer(&asn_DEF_MyPacket, myPacket, buf,
                                  MAXPKTSIZE);
        if (er.encoded == -1)
          {
                  fprintf(stderr, "Cannot encode %s: %s\n",
                          er.failed_type->name, strerror(errno));
                  goto fail;
          }
        else
          {
                  printf("Structure successfully encoded\n");
                  /*xer_fprint(stdout, &asn_DEF_MyPacket, myPacket);*/
 
                  asn_DEF_MyPacket.free_struct (&asn_DEF_MyPacket, myPacket, 0);
                  return er.encoded;
          }
 
      fail:
        fprintf(stderr, "Cannot encode %s: %s\n", er.failed_type->name, strerror(errno));
        asn_DEF_MyPacket.free_struct(&asn_DEF_MyPacket, myPacket, 0);
        return -1;
 
}
コード例 #17
0
//------------------------------------------------------------------------------
int s1ap_eNB_initial_ctxt_resp(
  instance_t instance, s1ap_initial_context_setup_resp_t *initial_ctxt_resp_p)
//------------------------------------------------------------------------------
{
  s1ap_eNB_instance_t          *s1ap_eNB_instance_p = NULL;
  struct s1ap_eNB_ue_context_s *ue_context_p        = NULL;

  S1ap_InitialContextSetupResponseIEs_t *initial_ies_p  = NULL;

  s1ap_message  message;

  uint8_t  *buffer  = NULL;
  uint32_t length;
  int      ret = -1;
  int      i;

  /* Retrieve the S1AP eNB instance associated with Mod_id */
  s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance);

  DevAssert(initial_ctxt_resp_p != NULL);
  DevAssert(s1ap_eNB_instance_p != NULL);

  if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p,
                      initial_ctxt_resp_p->eNB_ue_s1ap_id)) == NULL) {
    /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */
    S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: 0x%06x\n",
              initial_ctxt_resp_p->eNB_ue_s1ap_id);
    return -1;
  }

  /* Uplink NAS transport can occur either during an s1ap connected state
   * or during initial attach (for example: NAS authentication).
   */
  if (!(ue_context_p->ue_state == S1AP_UE_CONNECTED ||
        ue_context_p->ue_state == S1AP_UE_WAITING_CSR)) {
    S1AP_WARN("You are attempting to send NAS data over non-connected "
              "eNB ue s1ap id: %06x, current state: %d\n",
              initial_ctxt_resp_p->eNB_ue_s1ap_id, ue_context_p->ue_state);
    return -1;
  }

  /* Prepare the S1AP message to encode */
  memset(&message, 0, sizeof(s1ap_message));

  message.direction     = S1AP_PDU_PR_successfulOutcome;
  message.procedureCode = S1ap_ProcedureCode_id_InitialContextSetup;

  initial_ies_p = &message.msg.s1ap_InitialContextSetupResponseIEs;

  initial_ies_p->eNB_UE_S1AP_ID = initial_ctxt_resp_p->eNB_ue_s1ap_id;
  initial_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;

  for (i = 0; i < initial_ctxt_resp_p->nb_of_e_rabs; i++) {
    S1ap_E_RABSetupItemCtxtSURes_t *new_item;

    new_item = calloc(1, sizeof(S1ap_E_RABSetupItemCtxtSURes_t));

    new_item->e_RAB_ID = initial_ctxt_resp_p->e_rabs[i].e_rab_id;
    GTP_TEID_TO_ASN1(initial_ctxt_resp_p->e_rabs[i].gtp_teid, &new_item->gTP_TEID);
    new_item->transportLayerAddress.buf = initial_ctxt_resp_p->e_rabs[i].eNB_addr.buffer;
    new_item->transportLayerAddress.size = initial_ctxt_resp_p->e_rabs[i].eNB_addr.length;
    new_item->transportLayerAddress.bits_unused = 0;

    ASN_SEQUENCE_ADD(&initial_ies_p->e_RABSetupListCtxtSURes.s1ap_E_RABSetupItemCtxtSURes,
                     new_item);
  }

  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
    S1AP_ERROR("Failed to encode uplink NAS transport\n");
    /* Encode procedure has failed... */
    return -1;
  }

  MSC_LOG_TX_MESSAGE(
    MSC_S1AP_ENB,
    MSC_S1AP_MME,
    (const char *)buffer,
    length,
    MSC_AS_TIME_FMT" InitialContextSetup successfulOutcome eNB_ue_s1ap_id %u mme_ue_s1ap_id %u",
    0,0,//MSC_AS_TIME_ARGS(ctxt_pP),
    initial_ies_p->eNB_UE_S1AP_ID,
    initial_ies_p->mme_ue_s1ap_id);

  /* UE associated signalling -> use the allocated stream */
  s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance,
                                   ue_context_p->mme_ref->assoc_id, buffer,
                                   length, ue_context_p->tx_stream);

  return ret;
}
コード例 #18
0
ファイル: s1ap_eNB.c プロジェクト: ShibinMathew36/OAI-step
static int s1ap_eNB_generate_s1_setup_request(
  s1ap_eNB_instance_t *instance_p, s1ap_eNB_mme_data_t *s1ap_mme_data_p)
{
  s1ap_message               message;

  S1ap_S1SetupRequestIEs_t *s1SetupRequest_p;
  S1ap_PLMNidentity_t       plmnIdentity;
  S1ap_SupportedTAs_Item_t  ta;

  uint8_t  *buffer;
  uint32_t  len;
  int       ret = 0;

  DevAssert(instance_p != NULL);
  DevAssert(s1ap_mme_data_p != NULL);

  memset(&message, 0, sizeof(s1ap_message));

  message.direction     = S1AP_PDU_PR_initiatingMessage;
  message.procedureCode = S1ap_ProcedureCode_id_S1Setup;
  message.criticality   = S1ap_Criticality_reject;

  s1SetupRequest_p = &message.msg.s1ap_S1SetupRequestIEs;
  memset((void *)&plmnIdentity, 0, sizeof(S1ap_PLMNidentity_t));

  memset((void *)&ta, 0, sizeof(S1ap_SupportedTAs_Item_t));

  s1ap_mme_data_p->state = S1AP_ENB_STATE_WAITING;

  s1SetupRequest_p->global_ENB_ID.eNB_ID.present = S1ap_ENB_ID_PR_macroENB_ID;
  MACRO_ENB_ID_TO_BIT_STRING(instance_p->eNB_id,
                             &s1SetupRequest_p->global_ENB_ID.eNB_ID.choice.macroENB_ID);
  MCC_MNC_TO_PLMNID(instance_p->mcc, instance_p->mnc, instance_p->mnc_digit_length,
                    &s1SetupRequest_p->global_ENB_ID.pLMNidentity);

  S1AP_INFO("%d -> %02x%02x%02x\n", instance_p->eNB_id, s1SetupRequest_p->global_ENB_ID.eNB_ID.choice.macroENB_ID.buf[0], s1SetupRequest_p->global_ENB_ID.eNB_ID.choice.macroENB_ID.buf[1],
            s1SetupRequest_p->global_ENB_ID.eNB_ID.choice.macroENB_ID.buf[2]);

  INT16_TO_OCTET_STRING(instance_p->tac, &ta.tAC);
  MCC_MNC_TO_TBCD(instance_p->mcc, instance_p->mnc, instance_p->mnc_digit_length, &plmnIdentity);

  ASN_SEQUENCE_ADD(&ta.broadcastPLMNs.list, &plmnIdentity);
  ASN_SEQUENCE_ADD(&s1SetupRequest_p->supportedTAs.list, &ta);

  s1SetupRequest_p->defaultPagingDRX = instance_p->default_drx;

  if (instance_p->eNB_name != NULL) {
    s1SetupRequest_p->presenceMask |= S1AP_S1SETUPREQUESTIES_ENBNAME_PRESENT;
    OCTET_STRING_fromBuf(&s1SetupRequest_p->eNBname, instance_p->eNB_name,
                         strlen(instance_p->eNB_name));
  }

  if (s1ap_eNB_encode_pdu(&message, &buffer, &len) < 0) {
    S1AP_ERROR("Failed to encode S1 setup request\n");
    return -1;
  }

  /* Non UE-Associated signalling -> stream = 0 */
  s1ap_eNB_itti_send_sctp_data_req(instance_p->instance, s1ap_mme_data_p->assoc_id, buffer, len, 0);

  return ret;
}
コード例 #19
0
ファイル: my-program.c プロジェクト: tonches/libadsb
int main() { /* Define an OBJECT IDENTIFIER value */ int oid[] = { 1, 3, 6, 1, 4, 1, 9363, 1, 5, 0 }; /* or whatever */ /* Declare a pointer to a new instance of MyTypes type */ MyTypes_t *myType; /* Declare a pointer to a MyInt type */ MyInt_t *myInt; /* Temporary return value */ int ret; /* Allocate an instance of MyTypes */ myType = calloc(1, sizeof *myType); assert(myType); /* Assume infinite memory */ /* * Fill in myObjectId */ ret = OBJECT_IDENTIFIER_set_arcs(&myType->myObjectId, oid, sizeof(oid[0]), sizeof(oid) / sizeof(oid[0])); assert(ret == 0); /* * Fill in mySeqOf with a couple of integers. */ /* Prepare a certain INTEGER */ myInt = calloc(1, sizeof *myInt); assert(myInt); *myInt = 123; /* Set integer value */ /* Fill in mySeqOf with the prepared INTEGER */ ret = ASN_SEQUENCE_ADD(&myType->mySeqOf, myInt); assert(ret == 0); /* Prepare another integer */ myInt = calloc(1, sizeof *myInt); assert(myInt); *myInt = 111222333; /* Set integer value */ /* Append another INTEGER into mySeqOf */ ret = ASN_SEQUENCE_ADD(&myType->mySeqOf, myInt); assert(ret == 0); /* * Fill in myBitString */ /* Allocate some space for bitmask */ myType->myBitString.buf = calloc(1, 1); assert(myType->myBitString.buf); myType->myBitString.size = 1; /* 1 byte */ /* Set the value of muxToken */ myType->myBitString.buf[0] |= 1 << (7 - myBitString_muxToken); /* Also set the value of modemToken */ myType->myBitString.buf[0] |= 1 << (7 - myBitString_modemToken); /* Trim unused bits (optional) */ myType->myBitString.bits_unused = 6; /* * Print the resulting structure as XER (XML) */ xer_fprint(stdout, &asn_DEF_MyTypes, myType); return 0; }
コード例 #20
0
PKIError GenerateCertificate (const UTF8String_t *subjectName, const UTF8String_t *issuerName,
                        const UTCTime_t *notBefore, const UTCTime_t *notAfter,
                        const BIT_STRING_t *subjectPublicKey, const BIT_STRING_t *issuerPrivateKey,
                        ByteArray *encodedCertificate)
{
    FUNCTION_INIT();
    asn_enc_rval_t ec; /* Encoder return value */
    Certificate_t *certificate                  = NULL; /* Type to encode */
    AttributeTypeAndValue_t *issuerTypeAndValue    = NULL;
    AttributeTypeAndValue_t *subjectTypeAndValue   = NULL;
    RelativeDistinguishedName_t *issuerRDN         = NULL;
    RelativeDistinguishedName_t *subjectRDN        = NULL;
    uint8_t *uint8Pointer                       = NULL;
    ByteArray tbs                               = BYTE_ARRAY_INITIALIZER;
    uint8_t signature[SIGN_FULL_SIZE];
    uint8_t sha256[SHA_256_HASH_LEN];
    uint8_t tbsDer[ISSUER_MAX_CERT_SIZE];
    long serialNumber = 0;

    CHECK_NULL(subjectName, ISSUER_X509_NULL_PASSED);
    CHECK_NULL(issuerName, ISSUER_X509_NULL_PASSED);
    CHECK_NULL(notBefore, ISSUER_X509_NULL_PASSED);
    CHECK_NULL(notAfter, ISSUER_X509_NULL_PASSED);
    CHECK_NULL(subjectPublicKey, ISSUER_X509_NULL_PASSED);
    CHECK_NULL(issuerPrivateKey, ISSUER_X509_NULL_PASSED);
    CHECK_NULL_BYTE_ARRAY_PTR(encodedCertificate, ISSUER_X509_NULL_PASSED);
    CHECK_LESS_EQUAL(ISSUER_MAX_CERT_SIZE, encodedCertificate->len,
                     ISSUER_X509_WRONG_BYTE_ARRAY_LEN);

    /* Allocate the memory */
    certificate      = OICCalloc(1, sizeof(Certificate_t)); // not malloc!
    CHECK_NULL(certificate, ISSUER_X509_MEMORY_ALLOC_FAILED);

    issuerTypeAndValue  = OICCalloc(1, sizeof(AttributeTypeAndValue_t));
    CHECK_NULL(issuerTypeAndValue, ISSUER_X509_MEMORY_ALLOC_FAILED);

    issuerRDN           = OICCalloc(1, sizeof(RelativeDistinguishedName_t));
    CHECK_NULL(issuerRDN, ISSUER_X509_MEMORY_ALLOC_FAILED);

    subjectTypeAndValue = OICCalloc(1, sizeof(AttributeTypeAndValue_t));
    CHECK_NULL(subjectTypeAndValue, ISSUER_X509_MEMORY_ALLOC_FAILED);

    subjectRDN          = OICCalloc(1, sizeof(RelativeDistinguishedName_t));
    CHECK_NULL(subjectRDN, ISSUER_X509_MEMORY_ALLOC_FAILED);

    //set issuer name
    issuerTypeAndValue->value = *issuerName;
    issuerTypeAndValue->type.buf = (uint8_t *)g_COMMON_NAME_OID;   //2.5.4.3
    issuerTypeAndValue->type.size = sizeof(g_COMMON_NAME_OID) / sizeof(g_COMMON_NAME_OID[0]);
    ASN_SET_ADD(issuerRDN, issuerTypeAndValue);
    ASN_SEQUENCE_ADD(&(certificate->tbsCertificate.issuer), issuerRDN);

    //set subject name
    subjectTypeAndValue->value = *subjectName;
    subjectTypeAndValue->type.buf = (uint8_t *)g_COMMON_NAME_OID;  //2.5.4.3
    subjectTypeAndValue->type.size = sizeof(g_COMMON_NAME_OID) / sizeof(g_COMMON_NAME_OID[0]);
    ASN_SET_ADD(subjectRDN, subjectTypeAndValue);
    ASN_SEQUENCE_ADD(&(certificate->tbsCertificate.subject), subjectRDN);

    //set validity
    certificate->tbsCertificate.validity.notBefore = *notBefore;
    certificate->tbsCertificate.validity.notAfter  = *notAfter;

    //set X.509 certificate version
    certificate->tbsCertificate.version = X509_V2;

    //set serial number
    certificate->tbsCertificate.serialNumber = 0;

    CHECK_CALL(InitCKMInfo);
    CHECK_CALL(GetNextSerialNumber, &serialNumber);
    certificate->tbsCertificate.serialNumber = serialNumber;
    serialNumber++;
    CHECK_CALL(SetNextSerialNumber, serialNumber);
    CHECK_CALL(SaveCKMInfo);

    //set signature algorithm in TBS
    certificate->tbsCertificate.signature.algorithm.buf =
        (uint8_t *)g_ECDSA_WITH_SHA256_OID;    //1.2.840.10045.4.3.2
    certificate->tbsCertificate.signature.algorithm.size =
        sizeof(g_ECDSA_WITH_SHA256_OID) / sizeof(g_ECDSA_WITH_SHA256_OID[0]);
    certificate->tbsCertificate.signature.nul = OICCalloc(1, sizeof(NULL_t));
    CHECK_NULL(certificate->tbsCertificate.signature.nul, ISSUER_X509_MEMORY_ALLOC_FAILED);

    //set subject Public Key algorithm
    certificate->tbsCertificate.subjectPublicKeyInfo.algorithm.algorithm.buf =
        (uint8_t *)g_EC_PUBLIC_KEY_OID;   //1.2.840.10045.2.1
    certificate->tbsCertificate.subjectPublicKeyInfo.algorithm.algorithm.size =
        sizeof(g_EC_PUBLIC_KEY_OID) / sizeof(g_EC_PUBLIC_KEY_OID[0]);

    //set subject Public Key curve
    certificate->tbsCertificate.subjectPublicKeyInfo.algorithm.id_ecPublicKey =
        OICCalloc(1, sizeof(OBJECT_IDENTIFIER_t));
    CHECK_NULL(certificate->tbsCertificate.subjectPublicKeyInfo.algorithm.id_ecPublicKey,
               ISSUER_X509_MEMORY_ALLOC_FAILED);
    certificate->tbsCertificate.subjectPublicKeyInfo.algorithm.id_ecPublicKey->buf =
        (uint8_t *)g_PRIME_256_V1_OID;  //1.2.840.10045.3.1.7
    certificate->tbsCertificate.subjectPublicKeyInfo.algorithm.id_ecPublicKey->size =
        sizeof(g_PRIME_256_V1_OID) / sizeof(g_PRIME_256_V1_OID[0]);

    //set subject Public Key
    certificate->tbsCertificate.subjectPublicKeyInfo.subjectPublicKey = *subjectPublicKey;

    //set signature algorithm
    certificate->signatureAlgorithm.algorithm.buf = (uint8_t *)g_ECDSA_WITH_SHA256_OID;
    certificate->signatureAlgorithm.algorithm.size =
        sizeof(g_ECDSA_WITH_SHA256_OID) / sizeof(g_ECDSA_WITH_SHA256_OID[0]);
    certificate->signatureAlgorithm.nul = OICCalloc(1, sizeof(NULL_t));
    CHECK_NULL(certificate->signatureAlgorithm.nul, ISSUER_X509_MEMORY_ALLOC_FAILED);

    //encode TBS to DER
    ec = der_encode_to_buffer(&asn_DEF_TBSCertificate, &(certificate->tbsCertificate),
                              tbsDer, ISSUER_MAX_CERT_SIZE);
    CHECK_COND(ec.encoded > 0, ISSUER_X509_DER_ENCODE_FAIL);
    tbs.len = ec.encoded;
    tbs.data = tbsDer;
    GET_SHA_256(tbs, sha256);
    CHECK_COND(uECC_sign((issuerPrivateKey->buf) + 1, sha256, signature),
               ISSUER_X509_SIGNATURE_FAIL);
            //additional byte for ASN1_UNCOMPRESSED_KEY_ID

    // ECDSA-Sig-Value ::= SEQUENCE { r INTEGER, s INTEGER } (RFC 5480)
    certificate->signatureValue.size = SIGN_FULL_SIZE + 6;// size for SEQUENCE ID + 2 * INTEGER ID

    // if first byte of positive INTEGER exceed 127 add 0 byte before
    if (signature[0] > 127)
    {
        certificate->signatureValue.size ++;
    }

    // if first byte of positive INTEGER exceed 127 add 0 byte before
    if (signature[SIGN_R_LEN] > 127)
    {
        certificate->signatureValue.size ++;
    }
    certificate->signatureValue.buf = OICCalloc(certificate->signatureValue.size, sizeof(uint8_t));
    CHECK_NULL(certificate->signatureValue.buf, ISSUER_X509_MEMORY_ALLOC_FAILED);
    *(certificate->signatureValue.buf) = (12 << 2); //ASN.1 SEQUENCE ID
    *(certificate->signatureValue.buf + 1) = certificate->signatureValue.size - 2;
    //ASN.1 SEQUENCE size

    uint8Pointer = certificate->signatureValue.buf + 2; //skip SEQUENCE ID and size
    *uint8Pointer = (2 << 0); //ASN.1 INTEGER ID

    // if first byte of positive INTEGER exceed 127 add 0 byte before
    if (signature[0] > 127)
    {
        *(uint8Pointer + 1) = SIGN_R_LEN + 1; //ASN.1 INTEGER size
        uint8Pointer += 3; //skip INTEGER ID and size
    }
    else
    {
        *(uint8Pointer + 1) = SIGN_R_LEN; //ASN.1 INTEGER SIZE
        uint8Pointer += 2; //skip INTEGER ID and size
    }
    memcpy(uint8Pointer, signature, SIGN_R_LEN);

    uint8Pointer += SIGN_R_LEN; //skip first part of signature
    *uint8Pointer = (2 << 0);   //ASN.1 INTEGER ID

    // if first byte of positive INTEGER exceed 127 add 0 byte before
    if (signature [SIGN_R_LEN] > 127)
    {
        *(uint8Pointer + 1) = SIGN_S_LEN + 1; //ASN.1 INTEGER size
        uint8Pointer += 3; //skip INTEGER ID and size
    }
    else
    {
        *(uint8Pointer + 1) = SIGN_S_LEN; //ASN.1 INTEGER size
        uint8Pointer += 2; //skip INTEGER ID and size
    }
    memcpy(uint8Pointer, signature + SIGN_R_LEN, SIGN_S_LEN);

    ec = der_encode_to_buffer(&asn_DEF_Certificate, certificate,
                              encodedCertificate->data, ISSUER_MAX_CERT_SIZE);
    CHECK_COND(ec.encoded > 0, ISSUER_X509_DER_ENCODE_FAIL);
    encodedCertificate->len = ec.encoded;

    FUNCTION_CLEAR(
        if (issuerTypeAndValue)
        {
            issuerTypeAndValue->value.buf = NULL;
            issuerTypeAndValue->type.buf  = NULL;
        }
        if (subjectTypeAndValue)
        {
            subjectTypeAndValue->value.buf = NULL;
            subjectTypeAndValue->type.buf  = NULL;
        }
        if (certificate)
        {
            certificate->tbsCertificate.validity.notBefore.buf                             = NULL;
            certificate->tbsCertificate.validity.notAfter.buf                              = NULL;
            certificate->tbsCertificate.subjectPublicKeyInfo.subjectPublicKey.buf          = NULL;
            certificate->tbsCertificate.signature.algorithm.buf                            = NULL;
            certificate->tbsCertificate.subjectPublicKeyInfo.algorithm.algorithm.buf       = NULL;
            certificate->tbsCertificate.subjectPublicKeyInfo.algorithm.id_ecPublicKey->buf = NULL;
            certificate->signatureAlgorithm.algorithm.buf                                  = NULL;
        }
        ASN_STRUCT_FREE(asn_DEF_Certificate, certificate);
        certificate = NULL;
    );
コード例 #21
0
ファイル: sib1.c プロジェクト: borisov-r/libLTE
void bcch_dlsch_sib1(BCCH_DL_SCH_Message_t *msg, 
                     MCC_MNC_Digit_t mcc_val[3], 
                     MCC_MNC_Digit_t mnc_val[2], 
                     uint8_t tac_val[2], 
                     uint8_t cid_val[4], 
                     int freq_band) 
{

  bzero(msg, sizeof(BCCH_DL_SCH_Message_t));

  msg->message.present = BCCH_DL_SCH_MessageType_PR_c1;
  msg->message.choice.c1.present = BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1;
  SystemInformationBlockType1_t *sib1 = &(msg->message.choice.c1.choice.systemInformationBlockType1);
  
  PLMN_IdentityInfo_t *PLMN_identity_info = calloc(1, sizeof(PLMN_IdentityInfo_t));
  MCC_t *mcc = calloc(1, sizeof(MCC_t));
  PLMN_identity_info->plmn_Identity.mcc = mcc;
  asn_set_empty(&mcc->list);
  for (int i=0;i<3;i++) {
    ASN_SEQUENCE_ADD(&mcc->list,dup_digit(mcc_val[i]));    
  }
  asn_set_empty(&PLMN_identity_info->plmn_Identity.mnc.list);
  for (int i=0;i<2;i++) {
    ASN_SEQUENCE_ADD(&PLMN_identity_info->plmn_Identity.mnc.list,dup_digit(mnc_val[i]));    
  }
  PLMN_identity_info->cellReservedForOperatorUse=PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;

  ASN_SEQUENCE_ADD(&sib1->cellAccessRelatedInfo.plmn_IdentityList.list,PLMN_identity_info);

  sib1->cellAccessRelatedInfo.trackingAreaCode.buf=malloc(2); 
  for (int i=0;i<2;i++) {
    sib1->cellAccessRelatedInfo.trackingAreaCode.buf[i] = tac_val[i];    
  }
  sib1->cellAccessRelatedInfo.trackingAreaCode.size=2;
  sib1->cellAccessRelatedInfo.trackingAreaCode.bits_unused=0;

  sib1->cellAccessRelatedInfo.cellIdentity.buf=malloc(4); 
  for (int i=0;i<4;i++) {
    sib1->cellAccessRelatedInfo.cellIdentity.buf[i] = cid_val[i];
  }
  sib1->cellAccessRelatedInfo.cellIdentity.size=4;
  sib1->cellAccessRelatedInfo.cellIdentity.bits_unused=4;

  sib1->cellAccessRelatedInfo.cellBarred=SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_barred;  

  sib1->cellAccessRelatedInfo.intraFreqReselection=SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_allowed;
  sib1->cellAccessRelatedInfo.csg_Indication=0;

  sib1->cellSelectionInfo.q_RxLevMin=-60;
  sib1->cellSelectionInfo.q_RxLevMinOffset=NULL;

  sib1->freqBandIndicator = (long int) freq_band;


  SchedulingInfo_t *schedulingInfo_3 = calloc(2, sizeof(SchedulingInfo_t));
  SchedulingInfo_t *schedulingInfo_6 = calloc(2, sizeof(SchedulingInfo_t));
  SIB_Type_t *sib_type_3 = calloc(1, sizeof(SIB_Type_t));
  SIB_Type_t *sib_type_6 = calloc(1, sizeof(SIB_Type_t));

  schedulingInfo_3->si_Periodicity=SchedulingInfo__si_Periodicity_rf16;
  *sib_type_3=SIB_Type_sibType3;
  ASN_SEQUENCE_ADD(&schedulingInfo_3->sib_MappingInfo.list,sib_type_3);
  ASN_SEQUENCE_ADD(&sib1->schedulingInfoList.list,schedulingInfo_3);    
  
  schedulingInfo_6->si_Periodicity=SchedulingInfo__si_Periodicity_rf64;
  *sib_type_6=SIB_Type_sibType6;
  ASN_SEQUENCE_ADD(&schedulingInfo_6->sib_MappingInfo.list,sib_type_6);
  ASN_SEQUENCE_ADD(&sib1->schedulingInfoList.list,schedulingInfo_6);    
    
  sib1->si_WindowLength=SystemInformationBlockType1__si_WindowLength_ms40;
  sib1->systemInfoValueTag=8;  
}