blob: b28e1b113b1072425a013ab0c2625d880c32c3d6 [file] [log] [blame]
rajalakshmisv21b61dd2021-12-07 04:53:03 +00001#include <errno.h>
2#include "wrapper.h"
3#include "OCTET_STRING.h"
4
rajalakshmisv960885a2022-05-31 14:59:10 +00005ssize_t e2sm_encode_ric_control_header(void *buffer, size_t buf_size,struct uEID *inUEID,long f1AP[],size_t f1AP_len,long e1AP[],size_t e1Ap_len,long ricControlStyleType, long ricControlActionID, void* plmnId, size_t plmnIdSize)
6{
7 fprintf(stderr,"e2SM wrapper function Entered\n");
8 fprintf(stderr,"plmn Size = %ld and aMFRegionID Size = %ld and aMFSetID_size = %ld and aMFPointer_size = %ld \n", inUEID->pLMNIdentity_size,inUEID->aMFRegionID_size,inUEID->aMFSetID_size,inUEID->aMFPointer_size);
rajalakshmisv21b61dd2021-12-07 04:53:03 +00009
rajalakshmisv21b61dd2021-12-07 04:53:03 +000010 E2SM_RC_ControlHeader_t *controlHeaderIE = (E2SM_RC_ControlHeader_t *)calloc(1, sizeof(E2SM_RC_ControlHeader_t));
11 if(!controlHeaderIE)
12 {
13 fprintf(stderr, "alloc E2SM_RC_ControlHeader failed\n");
14 return -1;
15 }
16
rajalakshmisv960885a2022-05-31 14:59:10 +000017 controlHeaderIE->ric_controlHeader_formats.present = E2SM_RC_ControlHeader__ric_controlHeader_formats_PR_controlHeader_Format1;
rajalakshmisva4420872022-11-10 11:08:11 +000018 //E2SM_RC_ControlHeader_Format1_t *controlHeader_Fmt1 = (E2SM_RC_ControlHeader_Format1_t *)calloc(1, sizeof(E2SM_RC_ControlHeader_Format1_t));
19 E2SM_RC_ControlHeader_Format1_t *controlHeader_Fmt1 = NULL;
20 controlHeaderIE->ric_controlHeader_formats.choice.controlHeader_Format1 = (E2SM_RC_ControlHeader_Format1_t *)calloc(1, sizeof(E2SM_RC_ControlHeader_Format1_t));
21 controlHeader_Fmt1 = controlHeaderIE->ric_controlHeader_formats.choice.controlHeader_Format1;
rajalakshmisv21b61dd2021-12-07 04:53:03 +000022 if(!controlHeader_Fmt1)
23 {
24 fprintf(stderr, "alloc E2SM_RC_ControlHeader failed\n");
rajalakshmisva4420872022-11-10 11:08:11 +000025 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE);
rajalakshmisv21b61dd2021-12-07 04:53:03 +000026 return -1;
27 }
rajalakshmisv960885a2022-05-31 14:59:10 +000028
29 controlHeader_Fmt1->ueID.present = UEID_PR_gNB_UEID;
30 controlHeader_Fmt1->ueID.choice.gNB_UEID = (UEID_GNB_t *)calloc(1,sizeof(UEID_GNB_t));
31 if(! controlHeader_Fmt1->ueID.choice.gNB_UEID)
32 {
33 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE);
34 fprintf(stderr, "alloc gNB_UEID failed\n");
35 return -1;
36 }
rajalakshmisv21b61dd2021-12-07 04:53:03 +000037
rajalakshmisv960885a2022-05-31 14:59:10 +000038 asn_long2INTEGER(&controlHeader_Fmt1->ueID.choice.gNB_UEID->amf_UE_NGAP_ID,inUEID->amf_UE_NGAP_Id);
39
40 fprintf(stderr, "e2sm_encode_ric_control_header amf_UE_NGAP_ID encoded \n");
41
42 //OCTET_STRING_fromBuf(&controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.pLMNIdentity,inUEID->pLMNIdentity, inUEID->pLMNIdentity_size);
43
44 OCTET_STRING_fromBuf(&controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.pLMNIdentity, plmnId,plmnIdSize);
45 fprintf(stderr, "e2smrc_encode_ric_control_header pLMNIdentity encoded \n");
46
47 controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFRegionID.buf = (uint8_t*)calloc(1,inUEID->aMFRegionID_size);
48 if(!controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFRegionID.buf)
49 {
50 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE);
51 fprintf(stderr, "alloc aMFRegionID Value failed\n");
52 return -1;
53 }
sandeepindiac588f662022-12-01 22:00:11 +053054 controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFRegionID.size = 1;//inUEID->aMFRegionID_size;
55 int decimal_num= (int)strtol(inUEID->aMFRegionID, NULL, 2);
56 memcpy(controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFRegionID.buf, (char*)&decimal_num,sizeof(unsigned int));
57 //AMFR->size=1;
58 controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFRegionID.bits_unused=0;
rajalakshmisv960885a2022-05-31 14:59:10 +000059 //controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFRegionID.buf[0] = inUEID->aMFRegionID && 0XFF;
60 //controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFRegionID.buf[0] = *(inUEID->aMFRegionID ) & 0XFF;
sandeepindiac588f662022-12-01 22:00:11 +053061 //memcpy(controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFRegionID.buf,inUEID->aMFRegionID,inUEID->aMFRegionID_size);
rajalakshmisv960885a2022-05-31 14:59:10 +000062
63 controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFSetID.buf = (uint8_t*)calloc(1, inUEID->aMFSetID_size);
64 if(!controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFSetID.buf)
65 {
66 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE);
67 fprintf(stderr, "alloc aMFSetID Value failed\n");
68 return -1;
69 }
70 controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFSetID.size = inUEID->aMFSetID_size;
71 //controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFSetID.buf[0] = (inUEID->aMFSetID && 0xFF00) >> 8;
72 //controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFSetID.buf[1] = inUEID->aMFSetID && 0XFF00 && 0X00FF;
73 controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFSetID.buf[0] = (*(inUEID->aMFSetID) & 0xFFC0) >> 8;
74 controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFSetID.bits_unused = 6;
75
76
77 controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFPointer.buf = (uint8_t*)calloc(1, inUEID->aMFPointer_size);
78 if(!controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFPointer.buf)
79 {
80 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE);
81 fprintf(stderr, "alloc aMFPointer Value failed\n");
82 return -1;
83 }
84
sandeepindiac588f662022-12-01 22:00:11 +053085 controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFPointer.size = 1;//inUEID->aMFPointer_size;
rajalakshmisv960885a2022-05-31 14:59:10 +000086 //controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFPointer.buf[0] = inUEID->aMFPointer && 0XFF;
sandeepindiac588f662022-12-01 22:00:11 +053087 //controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFPointer.buf[0] = (*(inUEID->aMFPointer) & 0xFC) >> 2;
88 int decimal_num3= (int)strtol(inUEID->aMFPointer, NULL, 2);
89 decimal_num3=decimal_num3<<2;
90 memcpy(controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFPointer.buf, (char*)&decimal_num3,sizeof(unsigned int));
91
rajalakshmisv960885a2022-05-31 14:59:10 +000092 controlHeader_Fmt1->ueID.choice.gNB_UEID->guami.aMFPointer.bits_unused = 2;
93
94
95 controlHeader_Fmt1->ueID.choice.gNB_UEID->gNB_CU_UE_F1AP_ID_List = (UEID_GNB_CU_F1AP_ID_List_t *)calloc(1,sizeof(UEID_GNB_CU_F1AP_ID_List_t));
96 if(! controlHeader_Fmt1->ueID.choice.gNB_UEID->gNB_CU_UE_F1AP_ID_List)
97 {
98 fprintf(stderr, "alloc gNB_CU_CP_UE_E1AP_ID_list failed\n");
99 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE);
100 return -1;
101 }
rajalakshmisv960885a2022-05-31 14:59:10 +0000102 //f1AP is an array of data
103 //int n = sizeof(f1AP)/sizeof(long int);
rajalakshmisva4420872022-11-10 11:08:11 +0000104
rajalakshmisv960885a2022-05-31 14:59:10 +0000105 for(int i =0; i < f1AP_len; i++)
106 {
107 UEID_GNB_CU_CP_F1AP_ID_Item_t *F1AP_ID_Item = (UEID_GNB_CU_CP_F1AP_ID_Item_t *)calloc (1, sizeof(UEID_GNB_CU_CP_F1AP_ID_Item_t ));
108 if(! F1AP_ID_Item)
109 {
110 fprintf(stderr, "alloc UEID_GNB_CU_CP_F1AP_ID_Item failed\n");
111 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE);
112 return -1;
113 }
114 F1AP_ID_Item->gNB_CU_UE_F1AP_ID = f1AP[i];
115 fprintf(stderr, "F1AP_id %d =%lu\n",i,*((unsigned long *) F1AP_id +i ));
116 ASN_SEQUENCE_ADD(&controlHeader_Fmt1->ueID.choice.gNB_UEID->gNB_CU_UE_F1AP_ID_List->list,F1AP_ID_Item);
117 }
118 //F1AP_ID_Item->gNB_CU_UE_F1AP_ID = f1AP[0];
119 //ASN_SEQUENCE_ADD(&controlHeader_Fmt1->ueID.choice.gNB_UEID->gNB_CU_UE_F1AP_ID_List->list,F1AP_ID_Item);
120
rajalakshmisv960885a2022-05-31 14:59:10 +0000121
122 controlHeader_Fmt1->ueID.choice.gNB_UEID->gNB_CU_CP_UE_E1AP_ID_List = (UEID_GNB_CU_CP_E1AP_ID_List_t *)calloc(1,sizeof(UEID_GNB_CU_CP_E1AP_ID_List_t));
123
124 if(! controlHeader_Fmt1->ueID.choice.gNB_UEID->gNB_CU_CP_UE_E1AP_ID_List)
125 {
126 fprintf(stderr, "alloc gNB_CU_CP_UE_E1AP_ID_list failed\n");
127 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE);
128 return -1;
129 }
130
131
132 //n = sizeof(e1AP)/sizeof(long int);
133 for(int i =0; i < e1Ap_len; i++)
134 {
135 UEID_GNB_CU_CP_E1AP_ID_Item_t *E1AP_ID_Item = (UEID_GNB_CU_CP_E1AP_ID_Item_t *)calloc (1, sizeof(UEID_GNB_CU_CP_E1AP_ID_Item_t ));
136 if(! E1AP_ID_Item)
137 {
138 fprintf(stderr, "alloc UEID_GNB_CU_CP_E1AP_ID_Item failed\n");
139 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE);
140 return -1;
141
142 }
143 E1AP_ID_Item->gNB_CU_CP_UE_E1AP_ID = e1AP[i];
144 ASN_SEQUENCE_ADD(&controlHeader_Fmt1->ueID.choice.gNB_UEID->gNB_CU_CP_UE_E1AP_ID_List->list,E1AP_ID_Item);
145 //E1AP_ID_Item->gNB_CU_CP_UE_E1AP_ID = (*(unsigned long *) E1AP_id) ;
146 //ASN_SEQUENCE_ADD(&controlHeader_Fmt1->ueID.choice.gNB_UEID->gNB_CU_CP_UE_E1AP_ID_List->list,E1AP_ID_Item);
147 }
148
149
rajalakshmisv960885a2022-05-31 14:59:10 +0000150 controlHeader_Fmt1->ric_Style_Type = ricControlStyleType;
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000151 controlHeader_Fmt1->ric_ControlAction_ID = ricControlActionID;
152
rajalakshmisv960885a2022-05-31 14:59:10 +0000153 controlHeaderIE->ric_controlHeader_formats.choice.controlHeader_Format1 = controlHeader_Fmt1;
154
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000155
156 fprintf(stderr, "showing xer of asn_DEF_E2SM_RC_ControlHeader data\n");
157 xer_fprint(stderr, &asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE);
158 fprintf(stderr, "\n");
159 fprintf(stderr, "After xer of asn_DEF_E2SM_RC_ControlHeader data\n");
160
161 asn_enc_rval_t encode_result;
162 encode_result = aper_encode_to_buffer(&asn_DEF_E2SM_RC_ControlHeader, NULL, controlHeaderIE, buffer, buf_size);
rajalakshmisv960885a2022-05-31 14:59:10 +0000163
164
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000165 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlHeader, controlHeaderIE);
166 if(encode_result.encoded == -1)
167 {
168 fprintf(stderr, "Cannot encode %s: %s\n", encode_result.failed_type->name, strerror(errno));
rajalakshmisv960885a2022-05-31 14:59:10 +0000169 return -1;
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000170 }
171 else
172 {
173 return encode_result.encoded;
174 }
175}
176
rajalakshmisv960885a2022-05-31 14:59:10 +0000177ssize_t e2sm_encode_nrcgi(NR_CGI_t *nr_cgi, void* plmnIdValue, size_t plmnId_size,ulong lNRCellId, uint8_t* buffer, size_t buf_size)
178{
179 nr_cgi = (NR_CGI_t*)calloc(1, sizeof(NR_CGI_t));
180 if(!nr_cgi) {
181 fprintf(stderr, "e2src_encode_nrcgi alloc nr_cgi failed \n");
182 return -1;
183 }
184 OCTET_STRING_fromBuf(&nr_cgi->pLMNIdentity,plmnIdValue, plmnId_size);
185 //fprintf(stderr, "encodec Plmn Id = %s plmnIdValue %s and lNRCellId = %lu \n", nr_cgi->pLMNIdentity, plmnIdValue,lNRCellId);
186 //fprintf(stderr, "encodec Plmn Id = %s and lNRCellId = %d \n", nr_cgi->pLMNIdentity,plmnIdValue,lNRCellId);
rajalakshmisva4420872022-11-10 11:08:11 +0000187 BIT_STRING_t *nr_cell_id = &nr_cgi->nRCellIdentity ;
rajalakshmisv960885a2022-05-31 14:59:10 +0000188 nr_cell_id->buf = (uint8_t*)calloc(1,5);
189 if(nr_cell_id->buf)
190 {
191 nr_cell_id->size = 5;
192 nr_cell_id->buf[0] = ((lNRCellId & 0X0FF0000000) >> 28);
193 nr_cell_id->buf[1] = ((lNRCellId & 0X000FF00000) >> 20);
194 nr_cell_id->buf[2] = ((lNRCellId & 0X00000FF000) >> 12);
195 nr_cell_id->buf[3] = ((lNRCellId & 0X0000000FF0) >> 4);
196 nr_cell_id->buf[4] = (lNRCellId & 0X000000000F) << 4;
197 nr_cell_id->bits_unused = 4;
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000198
rajalakshmisv960885a2022-05-31 14:59:10 +0000199 }
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000200
rajalakshmisv960885a2022-05-31 14:59:10 +0000201 fprintf(stderr, "showing xer of asn_DEF_NR_CGI NR_CGI_t data\n");
202 xer_fprint(stderr, &asn_DEF_NR_CGI, nr_cgi);
203
204 asn_enc_rval_t encode_result = aper_encode_to_buffer(&asn_DEF_NR_CGI, NULL, nr_cgi, buffer, buf_size);
205
206 if(encode_result.encoded != -1)
207 {
208 fprintf(stderr, "nr_cgi encodedi length = %zd \n", encode_result.encoded) ;
209 return encode_result.encoded;
210 }
211 else
212 {
213 fprintf(stderr, "nr_cgi encode failed =%zd \n", encode_result.encoded) ;
214 return -1 ;
215 }
216}
217
218ssize_t e2sm_encode_ric_control_message(void *buffer, size_t buf_size, long targetPrimaryCell,
sandeepindiac588f662022-12-01 22:00:11 +0530219 long targetCell, long nrOrEUtraCell, long nrCGIOrECGI, void* ranParameterValue,size_t ranParameterValue_size){
220
221 E2SM_RC_ControlMessage_t *e2smrcRcControlMsg = (E2SM_RC_ControlMessage_t*)calloc(1, sizeof(E2SM_RC_ControlMessage_t));
222 if(!e2smrcRcControlMsg) {
223 fprintf(stderr, "alloc E2SM_ControlMessage_t failed\n");
224 return -1;
225 }
226 e2smrcRcControlMsg->ric_controlMessage_formats.present = E2SM_RC_ControlMessage__ric_controlMessage_formats_PR_controlMessage_Format1;
227 E2SM_RC_ControlMessage_Format1_t *e2smrcRcControlFormat1 = (E2SM_RC_ControlMessage_Format1_t*)calloc(1, sizeof(E2SM_RC_ControlMessage_Format1_t));
228 if(!e2smrcRcControlFormat1) {
229 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
230 fprintf(stderr, "alloc E2SM_ControlMessage_Format1_t failed\n");
231 return -1;
232 }
233 RANParameter_ValueType_Choice_Structure_t *ranParameter_choice_Structure4 = (struct RANParameter_ValueType_Choice_Structure*)calloc(2, sizeof(struct RANParameter_ValueType_Choice_Structure));
234 //RANParameter_STRUCTURE_t* RPS4=(RANParameter_STRUCTURE_t*)calloc(1,sizeof(RANParameter_STRUCTURE_t));
235 //ranParameter_choice_Structure4[0]=(RANParameter_ValueType_Choice_Structure_t*)calloc(1,sizeof(RANParameter_ValueType_Choice_Structure_t));
236 //ranParameter_choice_Structure4[1]=(RANParameter_ValueType_Choice_Structure_t*)calloc(1,sizeof(RANParameter_ValueType_Choice_Structure_t));
237 //PLMN ################################
238 //void *p={"001F01"};
239 //void *nR={"12345C0010"};
240// void *z={"00"};
241/*
242 int newSize = strlen((char*)ranParameterValue1) + strlen((char*)ranParameterValue2) + 2;
243
244 // Allocate new buffer
245 char * newBuffer = (char *)malloc(newSize);
246 //strcpy(newBuffer,z);
247 strcat(newBuffer,(char *)ranParameterValue1); // or strncat
248 strcat(newBuffer,(char *)ranParameterValue2);
249
250 //newBuffer=00001F0112345C0010;
251 printf("%s\n",newBuffer);
252 u_int64_t lol3 = (u_int64_t)strtoll(newBuffer, NULL, 16);
253
254 int c0=lol3 & 0X0000000000000000FF;
255 int c1=(lol3>>8) & 0X0000000000000000FF;
256 int c2=(lol3>>16) & 0X0000000000000000FF;
257 int c3=(lol3>>24) & 0X0000000000000000FF;
258 int c4=(lol3>>32) & 0X0000000000000000FF;
259 int c5=(lol3>>40) & 0X0000000000000000FF;
260 int c6=(lol3>>48) & 0X0000000000000000FF;
261 int c7=(lol3>>56) & 0X0000000000000000FF;
262 int c8=lol3 & 0X000000000000000000;
263*/
264 RANParameter_STRUCTURE_Item_t *ranParameter_structure_Item_nrcgi = (RANParameter_STRUCTURE_Item_t *)calloc(1,sizeof(RANParameter_STRUCTURE_Item_t));
265 ranParameter_structure_Item_nrcgi->ranParameter_ID=4;
266 RANParameter_ValueType_t* RPV_t_nrcgi=(RANParameter_ValueType_t*)calloc(1,sizeof(RANParameter_ValueType_t));
267 RPV_t_nrcgi->present=RANParameter_ValueType_PR_ranP_Choice_ElementFalse;
268 RANParameter_ValueType_Choice_ElementFalse_t * RPVCEF_nrcgi=(RANParameter_ValueType_Choice_ElementFalse_t *)calloc(1, sizeof(RANParameter_ValueType_Choice_ElementFalse_t));
269 RANParameter_Value_t *RPV_nrcgi=(RANParameter_Value_t *)calloc(1, sizeof(RANParameter_Value_t));
270 RPV_nrcgi->present= RANParameter_Value_PR_valueOctS;
271
272
273
274 OCTET_STRING_t *NRCGI=(OCTET_STRING_t *)calloc(1,sizeof(OCTET_STRING_t));
275 OCTET_STRING_fromBuf(NRCGI, ranParameterValue,ranParameterValue_size);
276 RPV_nrcgi->choice.valueOctS=*NRCGI;
277 RPVCEF_nrcgi->ranParameter_value=RPV_nrcgi;
278 RPV_t_nrcgi->choice.ranP_Choice_ElementFalse=RPVCEF_nrcgi;
279 ranParameter_structure_Item_nrcgi->ranParameter_valueType=RPV_t_nrcgi;
280 ranParameter_choice_Structure4->ranParameter_Structure = (RANParameter_STRUCTURE_t*)calloc(1,sizeof(RANParameter_STRUCTURE_t));
281 ranParameter_choice_Structure4->ranParameter_Structure->sequence_of_ranParameters = (struct RANParameter_STRUCTURE__sequence_of_ranParameters*)calloc(1,sizeof(struct RANParameter_STRUCTURE__sequence_of_ranParameters));
282 int result1 = ASN_SEQUENCE_ADD(&ranParameter_choice_Structure4->ranParameter_Structure->sequence_of_ranParameters->list, ranParameter_structure_Item_nrcgi);
283 if (result1==-1)
284 {
285 fprintf(stderr,"Unable to assign memory to add PLMN %s",strerror(errno));
286 return -1;
287 }
288
289
290 RANParameter_STRUCTURE_Item_t* ranParameter_structure_Item3= (RANParameter_STRUCTURE_Item_t *)calloc(1,sizeof(RANParameter_STRUCTURE_Item_t));
291 ranParameter_structure_Item3->ranParameter_ID=3;
292 RANParameter_ValueType_t* RPV_t3=(RANParameter_ValueType_t*)calloc(1,sizeof(RANParameter_ValueType_t));
293 RPV_t3->present=RANParameter_ValueType_PR_ranP_Choice_Structure;
294 RPV_t3->choice.ranP_Choice_Structure=ranParameter_choice_Structure4;
295 ranParameter_structure_Item3->ranParameter_valueType=RPV_t3;
296 RANParameter_ValueType_Choice_Structure_t *ranParameter_choice_Structure3 = (struct RANParameter_ValueType_Choice_Structure*)calloc(2, sizeof(struct RANParameter_ValueType_Choice_Structure));
297 ranParameter_choice_Structure3->ranParameter_Structure = (RANParameter_STRUCTURE_t*)calloc(1,sizeof(RANParameter_STRUCTURE_t));
298 ranParameter_choice_Structure3->ranParameter_Structure->sequence_of_ranParameters= (struct RANParameter_STRUCTURE__sequence_of_ranParameters*)calloc(1,sizeof(struct RANParameter_STRUCTURE__sequence_of_ranParameters));
299 int result3 = ASN_SEQUENCE_ADD(&ranParameter_choice_Structure3->ranParameter_Structure->sequence_of_ranParameters->list, ranParameter_structure_Item3);
300 if (result3==-1)
301 {
302 fprintf(stderr,"Unable to assign memory to add ranParameter_structure_Item3 %s",strerror(errno));
303 return -1;
304 }
305 RANParameter_STRUCTURE_Item_t * ranParameter_structure_Item2= (RANParameter_STRUCTURE_Item_t *)calloc(1,sizeof(RANParameter_STRUCTURE_Item_t));
306 ranParameter_structure_Item2->ranParameter_ID=2;
307 RANParameter_ValueType_t* RPV_t2=(RANParameter_ValueType_t*)calloc(1,sizeof(RANParameter_ValueType_t));
308 RPV_t2->present=RANParameter_ValueType_PR_ranP_Choice_Structure;
309 RPV_t2->choice.ranP_Choice_Structure=ranParameter_choice_Structure3;
310 ranParameter_structure_Item2->ranParameter_valueType=RPV_t2;
311 RANParameter_ValueType_Choice_Structure_t *ranParameter_choice_Structure2 = (struct RANParameter_ValueType_Choice_Structure*)calloc(2, sizeof(struct RANParameter_ValueType_Choice_Structure));
312 ranParameter_choice_Structure2->ranParameter_Structure = (RANParameter_STRUCTURE_t*)calloc(1,sizeof(RANParameter_STRUCTURE_t));
313 ranParameter_choice_Structure2->ranParameter_Structure->sequence_of_ranParameters= (struct RANParameter_STRUCTURE__sequence_of_ranParameters*)calloc(1,sizeof(struct RANParameter_STRUCTURE__sequence_of_ranParameters));
314 int result4 = ASN_SEQUENCE_ADD(&ranParameter_choice_Structure2->ranParameter_Structure->sequence_of_ranParameters->list, ranParameter_structure_Item2);
315 if (result4==-1)
316 {
317 fprintf(stderr,"Unable to assign memory to add ranParameter_structure_Item2 %s",strerror(errno));
318 return -1;
319 }
320 RANParameter_ValueType_t* RPV_t1=(RANParameter_ValueType_t*)calloc(1,sizeof(RANParameter_ValueType_t));
321 RPV_t1->present=RANParameter_ValueType_PR_ranP_Choice_Structure;
322 RPV_t1->choice.ranP_Choice_Structure=ranParameter_choice_Structure2;
323 E2SM_RC_ControlMessage_Format1_Item_t *format1item = (E2SM_RC_ControlMessage_Format1_Item_t *) calloc(1,sizeof(
324 E2SM_RC_ControlMessage_Format1_Item_t));
325 if(!format1item) {
326 fprintf(stderr, "alloc format1item failed\n");
327 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
328 return -1;
329 }
330 format1item->ranParameter_ID=1;
331 format1item->ranParameter_valueType.present = RANParameter_ValueType_PR_ranP_Choice_Structure;
332 format1item->ranParameter_valueType=*RPV_t1;
333 int result5 = ASN_SEQUENCE_ADD(&e2smrcRcControlFormat1->ranP_List.list, format1item);
334 if (result5==-1)
335 {
336 fprintf(stderr,"Unable to assign memory to add format1item %s",strerror(errno));
337 return -1;
338 }
339 e2smrcRcControlMsg->ric_controlMessage_formats.choice.controlMessage_Format1=e2smrcRcControlFormat1;
340 asn_enc_rval_t encode_result;
341 encode_result = aper_encode_to_buffer(&asn_DEF_E2SM_RC_ControlMessage, NULL, e2smrcRcControlMsg, buffer,buf_size );
342 fprintf(stderr, "encoded length = %ld \n", encode_result.encoded);
343 if(encode_result.encoded == -1)
344 {
345 fprintf(stderr, "Cannot encode %s: %s\n", encode_result.failed_type->name, strerror(errno));
346 return -1;
347 }
348 else
349 {
350 xer_fprint(stderr, &asn_DEF_E2SM_RC_ControlMessage,e2smrcRcControlMsg);
351 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
352 return encode_result.encoded;
353 }
354
355
356}
357/*
358ssize_t e2sm_encode_ric_control_message(void *buffer, size_t buf_size, long targetPrimaryCell,
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000359 long targetCell, long nrOrEUtraCell, long nrCGIOrECGI, void* ranParameterValue, size_t ranParameterValue_size)
360{
rajalakshmisv960885a2022-05-31 14:59:10 +0000361 fprintf(stderr, "e2sm_encode_ric_control_message \n") ;
362 //NR_CGI_t *nr_cgi = NULL;
363 //uint8_t nrcgiBuf[buf_size];
364 //ssize_t nrcgiBuf_size,nrcgiLen;
365
366
367 E2SM_RC_ControlMessage_t *e2smrcRcControlMsg = (E2SM_RC_ControlMessage_t*)calloc(1, sizeof(E2SM_RC_ControlMessage_t));
368 if(!e2smrcRcControlMsg) {
369 fprintf(stderr, "alloc E2SM_ControlMessage_t failed\n");
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000370 return -1;
371 }
rajalakshmisv960885a2022-05-31 14:59:10 +0000372 e2smrcRcControlMsg->ric_controlMessage_formats.present = E2SM_RC_ControlMessage__ric_controlMessage_formats_PR_controlMessage_Format1;
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000373
rajalakshmisv960885a2022-05-31 14:59:10 +0000374 E2SM_RC_ControlMessage_Format1_t *e2smrcRcControlFormat1 = (E2SM_RC_ControlMessage_Format1_t*)calloc(1, sizeof(E2SM_RC_ControlMessage_Format1_t));
375 if(!e2smrcRcControlFormat1) {
376 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
377 fprintf(stderr, "alloc E2SM_ControlMessage_Format1_t failed\n");
378 return -1;
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000379 }
rajalakshmisv960885a2022-05-31 14:59:10 +0000380 // Start Target Primary Cell
381 E2SM_RC_ControlMessage_Format1_Item_t *ranParameterItem1 = (E2SM_RC_ControlMessage_Format1_Item_t *) calloc(1,sizeof(
382 E2SM_RC_ControlMessage_Format1_Item_t));
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000383 if(!ranParameterItem1) {
384 fprintf(stderr, "alloc RANParameter_Item_t1 failed\n");
rajalakshmisv960885a2022-05-31 14:59:10 +0000385 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000386 return -1;
387 }
388
rajalakshmisv960885a2022-05-31 14:59:10 +0000389 ranParameterItem1->ranParameter_ID = targetPrimaryCell; // Target Primary Cell ID value = 1
390 ranParameterItem1->ranParameter_valueType.present = RANParameter_ValueType_PR_ranP_Choice_Structure;
391
392 RANParameter_ValueType_Choice_Structure_t *ranParameterStructure1 = (RANParameter_ValueType_Choice_Structure_t*)calloc(1, sizeof(RANParameter_ValueType_Choice_Structure_t));
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000393 if(!ranParameterStructure1)
394 {
395 fprintf(stderr, "alloc RANParameter_STRUCTURE_t1 failed\n");
rajalakshmisv960885a2022-05-31 14:59:10 +0000396 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000397 return -1;
398 }
399
rajalakshmisv960885a2022-05-31 14:59:10 +0000400 fprintf(stderr, "targetPrimaryCell encoded \n");
401
402 // Start Target Cell
403 RANParameter_STRUCTURE_Item_t *ranParameterItem2 = (RANParameter_STRUCTURE_Item_t *)calloc(1,sizeof(RANParameter_STRUCTURE_Item_t));
404
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000405 if(!ranParameterItem2)
406 {
407
rajalakshmisv960885a2022-05-31 14:59:10 +0000408 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000409 fprintf(stderr, "alloc RANParameter_Item_t2 failed\n");
410 return -1;
411 }
412
rajalakshmisv960885a2022-05-31 14:59:10 +0000413 ranParameterItem2->ranParameter_ID = targetCell; // Target Cell ID value = 2
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000414
rajalakshmisv960885a2022-05-31 14:59:10 +0000415 RANParameter_ValueType_Choice_Structure_t *ranParameterStructure2 = (RANParameter_ValueType_Choice_Structure_t*)calloc(1, sizeof(struct RANParameter_ValueType_Choice_Structure));
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000416 if(!ranParameterStructure2)
417 {
rajalakshmisv960885a2022-05-31 14:59:10 +0000418 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000419 fprintf(stderr, "alloc RANParameter_STRUCTURE_t2 failed\n");
420 return -1;
421 }
422
rajalakshmisv960885a2022-05-31 14:59:10 +0000423 fprintf(stderr, "targetPrimaryCellId Value encoded \n");
424
425 // Start NR Cell (or E-UTRA Cell)
426 RANParameter_STRUCTURE_Item_t *ranParameterItem3 = (RANParameter_STRUCTURE_Item_t*)calloc(1,sizeof(RANParameter_STRUCTURE_Item_t));
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000427 if(!ranParameterItem3)
428 {
rajalakshmisv960885a2022-05-31 14:59:10 +0000429 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000430 fprintf(stderr, "alloc RANParameter_Item_t3 failed\n");
431 return -1;
432 }
433
rajalakshmisv960885a2022-05-31 14:59:10 +0000434 ranParameterItem3->ranParameter_ID = nrOrEUtraCell; // NR Cell ID (or E-UTRA Cell ID) value =
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000435
rajalakshmisv960885a2022-05-31 14:59:10 +0000436 RANParameter_ValueType_Choice_Structure_t *ranParameterStructure3 = (struct RANParameter_ValueType_Choice_Structure*)calloc(1, sizeof(struct RANParameter_ValueType_Choice_Structure));
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000437 if(!ranParameterStructure3)
438 {
rajalakshmisv960885a2022-05-31 14:59:10 +0000439 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000440 fprintf(stderr, "alloc RANParameter_Item_t3 failed\n");
441 return -1;
442 }
rajalakshmisv960885a2022-05-31 14:59:10 +0000443 fprintf(stderr, " NR Cell ID Value encoded \n");
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000444
rajalakshmisv960885a2022-05-31 14:59:10 +0000445 // Start NR CGI (or ECGI)
446 RANParameter_STRUCTURE_Item_t *ranParameterItem4 = (RANParameter_STRUCTURE_Item_t *) calloc(1,sizeof(
447 RANParameter_STRUCTURE_Item_t));
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000448 if(!ranParameterItem4)
449 {
rajalakshmisv960885a2022-05-31 14:59:10 +0000450 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000451 fprintf(stderr, "alloc RANParameter_Item_t4 failed\n");
452 return -1;
453 }
rajalakshmisv960885a2022-05-31 14:59:10 +0000454
455 ranParameterItem4->ranParameter_ID = nrCGIOrECGI; // NR CGI ID (or ECGI ID) value =
456
457 ranParameterItem4->ranParameter_valueType = (RANParameter_ValueType_t*)calloc(1,sizeof(RANParameter_ValueType_t));
458 if(!ranParameterItem4->ranParameter_valueType)
459 {
460 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
461 fprintf(stderr, "alloc ranParameterItem4->ranParameter_valueType failed\n");
462 return -1;
463 }
464
465 ranParameterItem4->ranParameter_valueType->present = RANParameter_ValueType_PR_ranP_Choice_ElementFalse;
466 ranParameterItem4->ranParameter_valueType->choice.ranP_Choice_ElementFalse = (RANParameter_ValueType_Choice_ElementFalse_t *)calloc(1, sizeof(RANParameter_ValueType_Choice_ElementFalse_t));
467 if(!ranParameterItem4->ranParameter_valueType->choice.ranP_Choice_ElementFalse)
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000468 {
rajalakshmisv960885a2022-05-31 14:59:10 +0000469 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000470 fprintf(stderr, "alloc RANParameter_Item_t4 failed\n");
471 return -1;
472 }
rajalakshmisv960885a2022-05-31 14:59:10 +0000473
474 ranParameterItem4->ranParameter_valueType->choice.ranP_Choice_ElementFalse->ranParameter_value = (RANParameter_Value_t *)calloc(1, sizeof(RANParameter_Value_t));
475 if(!ranParameterItem4->ranParameter_valueType->choice.ranP_Choice_ElementFalse->ranParameter_value)
476 {
477 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
478 fprintf(stderr, "alloc ranParameter_value failed\n");
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000479 return -1;
rajalakshmisv960885a2022-05-31 14:59:10 +0000480 }
481 ranParameterItem4->ranParameter_valueType->choice.ranP_Choice_ElementFalse->ranParameter_value->present = RANParameter_Value_PR_valueOctS;
482 OCTET_STRING_fromBuf(&ranParameterItem4->ranParameter_valueType->choice.ranP_Choice_ElementFalse->ranParameter_value->choice.valueOctS,ranParameterValue, ranParameterValue_size);
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000483
sandeepindiac588f662022-12-01 22:00:11 +0530484
rajalakshmisv960885a2022-05-31 14:59:10 +0000485 fprintf(stderr, "Target Plmn Id = %s ranParameterValue and lNRCellId = %lu \n", ranParameterValue,lNRCellId);
486 nrcgiLen = e2sm_encode_nrcgi(nr_cgi, ranParameterValue, ranParameterValue_size, lNRCellId,nrcgiBuf,nrcgiBuf_size);
487 if(nrcgiLen == -1 )
488 {
489 fprintf(stderr,"e2srmc_encode_nrcgi failed \n");
490 return nrcgiLen;
491 }
492 OCTET_STRING_fromBuf(&ranParameterItem4->ranParameter_valueType->choice.ranP_Choice_ElementFalse->ranParameter_value->choice.valueOctS,nrcgiBuf,nrcgiLen);
sandeepindiac588f662022-12-01 22:00:11 +0530493
rajalakshmisv960885a2022-05-31 14:59:10 +0000494 fprintf(stderr, " NR CGI encoded \n");
495
496 ranParameterStructure3->ranParameter_Structure = (RANParameter_STRUCTURE_t*)calloc(1,sizeof(RANParameter_STRUCTURE_t));
497 if(!ranParameterStructure3->ranParameter_Structure)
498 {
499 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
500 fprintf(stderr, "alloc ranParameterStructure3->ranParameter_Structure failed\n");
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000501 return -1;
rajalakshmisv960885a2022-05-31 14:59:10 +0000502 }
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000503
rajalakshmisv960885a2022-05-31 14:59:10 +0000504 ranParameterStructure3->ranParameter_Structure->sequence_of_ranParameters = (struct RANParameter_STRUCTURE__sequence_of_ranParameters*)calloc(1,sizeof(struct RANParameter_STRUCTURE__sequence_of_ranParameters));
505 if(!ranParameterStructure3->ranParameter_Structure->sequence_of_ranParameters)
506 {
507 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
508 fprintf(stderr, "alloc ranParameterStructure3->ranParameter_Structure->sequence_of_ranParameters failed\n");
509 return -1;
510 }
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000511
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000512
rajalakshmisv960885a2022-05-31 14:59:10 +0000513
514 ASN_SEQUENCE_ADD(&ranParameterStructure3->ranParameter_Structure->sequence_of_ranParameters->list, ranParameterItem4); // NR CGI (or ECGI)
515 ranParameterItem3->ranParameter_valueType = (RANParameter_ValueType_t*)calloc(1,sizeof(RANParameter_ValueType_t));
516 if(!ranParameterItem3->ranParameter_valueType)
517 {
518 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
519 fprintf(stderr, "alloc ranParameterItem3->ranParameter_valueType failed\n");
520 return -1;
521 }
522 ranParameterItem3->ranParameter_valueType->present = RANParameter_ValueType_PR_ranP_Choice_Structure;
523 ranParameterItem3->ranParameter_valueType->choice.ranP_Choice_Structure = ranParameterStructure3; // NR Cell (or E-UTRA Cell)
524 fprintf(stderr, " ranParameterStructure3 encoded \n");
525
526 ranParameterStructure2->ranParameter_Structure = (RANParameter_STRUCTURE_t*)calloc(1,sizeof(RANParameter_STRUCTURE_t));
527 if(!ranParameterStructure2->ranParameter_Structure)
528 {
529 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
530 fprintf(stderr, "alloc ranParameterStructure2->ranParameter_Structure failed\n");
531 return -1;
532 }
533
534 ranParameterStructure2->ranParameter_Structure->sequence_of_ranParameters = (struct RANParameter_STRUCTURE__sequence_of_ranParameters*)calloc(1,sizeof(struct RANParameter_STRUCTURE__sequence_of_ranParameters));
535 if(!ranParameterStructure2->ranParameter_Structure->sequence_of_ranParameters)
536 {
537 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
538 fprintf(stderr, "alloc ranParameterStructure3->ranParameter_Structure->sequence_of_ranParameters failed\n");
539 return -1;
540 }
541
542 ASN_SEQUENCE_ADD(&ranParameterStructure2->ranParameter_Structure->sequence_of_ranParameters->list, ranParameterItem3); // NR Cell (or E-UTRA Cell)
543 ranParameterItem2->ranParameter_valueType = (RANParameter_ValueType_t*)calloc(1,sizeof(RANParameter_ValueType_t));
544 if(!ranParameterItem2->ranParameter_valueType)
545 {
546 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
547 fprintf(stderr, "alloc ranParameterItem2->ranParameter_valueType failed\n");
548 return -1;
549 }
550 ranParameterItem2->ranParameter_valueType->present = RANParameter_ValueType_PR_ranP_Choice_Structure;
551 ranParameterItem2->ranParameter_valueType->choice.ranP_Choice_Structure = ranParameterStructure2; // Target Cell
552 fprintf(stderr, " ranParameterStructure2 encoded \n");
553
554 ranParameterStructure1->ranParameter_Structure = (RANParameter_STRUCTURE_t*)calloc(1,sizeof(RANParameter_STRUCTURE_t));
555 if(!ranParameterStructure1->ranParameter_Structure)
556 {
557 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
558 fprintf(stderr, "alloc ranParameterStructure1->ranParameter_Structure failed\n");
559 return -1;
560 }
561
562 ranParameterStructure1->ranParameter_Structure->sequence_of_ranParameters = (struct RANParameter_STRUCTURE__sequence_of_ranParameters*)calloc(1,sizeof(struct RANParameter_STRUCTURE__sequence_of_ranParameters));
563 if(!ranParameterStructure1->ranParameter_Structure->sequence_of_ranParameters)
564 {
565 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
566 fprintf(stderr, "alloc ranParameterStructure1->ranParameter_Structure->sequence_of_ranParameters failed\n");
567 return -1;
568 }
569 fprintf(stderr, " ranParameterStructure1 encoded \n");
570
571 ASN_SEQUENCE_ADD(&ranParameterStructure1->ranParameter_Structure->sequence_of_ranParameters->list, ranParameterItem2); // Target Cell
572 ranParameterItem1->ranParameter_valueType.choice.ranP_Choice_Structure = ranParameterStructure1; // Target Primary Cell
573
574 ASN_SEQUENCE_ADD(&e2smrcRcControlFormat1->ranP_List.list, ranParameterItem1); // Target Primary Cell
575 e2smrcRcControlMsg->ric_controlMessage_formats.choice.controlMessage_Format1 = e2smrcRcControlFormat1;
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000576
577
578 fprintf(stderr, "showing xer of asn_DEF_E2SM_RC_ControlMessage data\n");
rajalakshmisv960885a2022-05-31 14:59:10 +0000579 xer_fprint(stderr, &asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000580 fprintf(stderr, "\n");
581 fprintf(stderr, "After xer of asn_DEF_E2SM_RC_ControlMessage data\n");
582
583 asn_enc_rval_t encode_result;
rajalakshmisv960885a2022-05-31 14:59:10 +0000584 encode_result = aper_encode_to_buffer(&asn_DEF_E2SM_RC_ControlMessage, NULL, e2smrcRcControlMsg, buffer, buf_size);
585 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlMessage, e2smrcRcControlMsg);
586 fprintf(stderr, "encoded length = %ld \n", encode_result.encoded);
rajalakshmisv21b61dd2021-12-07 04:53:03 +0000587 if(encode_result.encoded == -1)
588 {
589 fprintf(stderr, "Cannot encode %s: %s\n", encode_result.failed_type->name, strerror(errno));
590 return -1;
591 }
592 else
593 {
594 return encode_result.encoded;
595 }
596}
sandeepindiac588f662022-12-01 22:00:11 +0530597*/
rajalakshmisv960885a2022-05-31 14:59:10 +0000598
599E2SM_RC_ControlOutcome_t* e2sm_decode_ric_call_process_outcome(void *buffer, size_t buf_size)
600{
601 fprintf(stderr, "e2sm_decode_ric_call_process_outcome Enter \n");
602 asn_dec_rval_t decode_result;
603 E2SM_RC_ControlOutcome_t* controlOutcome = NULL;
604 decode_result = aper_decode_complete(NULL, &asn_DEF_E2SM_RC_ControlOutcome, (void **)&controlOutcome, buffer, buf_size);
605 if(decode_result.code == RC_OK) {
606 xer_fprint(stdout, &asn_DEF_E2SM_RC_ControlOutcome, controlOutcome);
607 return controlOutcome;
608 }
609 else {
610 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlOutcome, controlOutcome);
611 return NULL;
612 }
613}
614
615void e2sm_free_ric_call_process_outcome(E2SM_RC_ControlOutcome_t* controlOutcome) {
616 ASN_STRUCT_FREE(asn_DEF_E2SM_RC_ControlOutcome, controlOutcome);
617}