1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2022 Northeastern University
4 * Copyright (c) 2022 Sapienza, University of Rome
5 * Copyright (c) 2022 University of Padova
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation;
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * Author: Andrea Lacava <thecave003@gmail.com>
21 * Tommaso Zugno <tommasozugno@gmail.com>
22 * Michele Polese <michele.polese@gmail.com>
25 #include <ns3/ric-control-function-description.h>
26 #include <ns3/asn1c-types.h>
30 #include "RIC-ControlStyle-Item.h"
31 #include "RIC-ControlAction-Item.h"
32 #include "RAN-ControlParameter-Item.h"
37 NS_LOG_COMPONENT_DEFINE ("RicControlFunctionDescription");
39 RicControlFunctionDescription::RicControlFunctionDescription ()
41 E2SM_RC_RANFunctionDefinition_t *descriptor = new E2SM_RC_RANFunctionDefinition_t ();
42 FillAndEncodeRCFunctionDescription (descriptor);
43 ASN_STRUCT_FREE_CONTENTS_ONLY (asn_DEF_E2SM_RC_RANFunctionDefinition, descriptor);
47 RicControlFunctionDescription::~RicControlFunctionDescription ()
53 RicControlFunctionDescription::Encode (E2SM_RC_RANFunctionDefinition_t *descriptor)
55 asn_codec_ctx_t *opt_cod = 0; // disable stack bounds checking
56 // encode the structure into the e2smbuffer
57 asn_encode_to_new_buffer_result_s encodedMsg = asn_encode_to_new_buffer (
58 opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_RC_RANFunctionDefinition, descriptor);
60 if (encodedMsg.result.encoded < 0)
62 NS_FATAL_ERROR ("Error during the encoding of the RIC Indication Header, errno: "
63 << strerror (errno) << ", failed_type " << encodedMsg.result.failed_type->name
64 << ", structure_ptr " << encodedMsg.result.structure_ptr);
67 m_buffer = encodedMsg.buffer;
68 m_size = encodedMsg.result.encoded;
72 RicControlFunctionDescription::FillAndEncodeRCFunctionDescription (
73 E2SM_RC_RANFunctionDefinition_t *ranfunc_desc)
76 std::string shortNameBuffer = "ORAN-WG3-RC";
78 Ptr<OctetString> shortName = Create<OctetString> (shortNameBuffer, shortNameBuffer.size ());
80 ranfunc_desc->ranFunction_Name.ranFunction_ShortName = shortName->GetValue ();
82 // This part is not in the specs, maybe it can be removed?
84 uint8_t *descriptionBuffer = (uint8_t *) "RIC Control Definitions";
85 uint8_t *oidBuffer = (uint8_t *) "OID123"; // this is optional, dummy value
87 long *inst = (long *) calloc (1, sizeof (long));
89 ranfunc_desc->ranFunction_Name.ranFunction_Description.buf =
90 (uint8_t *) calloc (1, strlen ((char *) descriptionBuffer));
91 memcpy (ranfunc_desc->ranFunction_Name.ranFunction_Description.buf, descriptionBuffer,
92 strlen ((char *) descriptionBuffer));
93 ranfunc_desc->ranFunction_Name.ranFunction_Description.size = strlen ((char *) descriptionBuffer);
94 ranfunc_desc->ranFunction_Name.ranFunction_Instance = inst;
95 ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf =
96 (uint8_t *) calloc (1, strlen ((char *) oidBuffer));
97 memcpy (ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf, oidBuffer,
98 strlen ((char *) oidBuffer));
99 ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.size = strlen ((char *) oidBuffer);
101 // End part of of specs
103 RIC_ControlStyle_Item_t *control_style0 =
104 (RIC_ControlStyle_Item_t *) calloc (1, sizeof (RIC_ControlStyle_Item_t));
105 control_style0->ric_ControlStyle_Type = 1;
107 uint8_t *controlStyleName0Buffer = (uint8_t *) "Radio Bearer Control";
108 size_t controlStyleName0BufferSize = strlen ((char *) controlStyleName0Buffer);
109 control_style0->ric_ControlStyle_Name.buf = (uint8_t *) calloc (1, controlStyleName0BufferSize);
110 memcpy (control_style0->ric_ControlStyle_Name.buf, controlStyleName0Buffer,
111 controlStyleName0BufferSize);
112 control_style0->ric_ControlStyle_Name.size = controlStyleName0BufferSize;
114 // these two were not present in the spec in this control style but just in the second, remove if they lead to crash
115 control_style0->ric_ControlMessageFormat_Type = 1;
116 control_style0->ric_ControlHeaderFormat_Type = 1;
118 control_style0->ric_ControlAction_List =
119 (RIC_ControlStyle_Item::RIC_ControlStyle_Item__ric_ControlAction_List *) calloc (
120 1, sizeof (RIC_ControlStyle_Item::RIC_ControlStyle_Item__ric_ControlAction_List));
122 RIC_ControlAction_Item_t *control_action0 =
123 (RIC_ControlAction_Item_t *) calloc (1, sizeof (RIC_ControlAction_Item_t));
125 control_action0->ric_ControlAction_ID = 6;
126 uint8_t *controlActionName0Buffer = (uint8_t *) "DRB split ratio control";
127 size_t controlActionName0BufferSize = strlen ((char *) controlActionName0Buffer);
128 control_action0->ric_ControlAction_Name.buf =
129 (uint8_t *) calloc (1, controlActionName0BufferSize);
130 memcpy (control_action0->ric_ControlAction_Name.buf, controlActionName0Buffer,
131 controlActionName0BufferSize);
132 control_action0->ric_ControlAction_Name.size = controlActionName0BufferSize;
133 control_action0->ran_ControlParameters_List =
134 (RIC_ControlAction_Item::RIC_ControlAction_Item__ran_ControlParameters_List *) calloc (
135 1, sizeof (RIC_ControlAction_Item::RIC_ControlAction_Item__ran_ControlParameters_List));
137 RAN_ControlParameter_Item_t *ranParameter0 =
138 (RAN_ControlParameter_Item_t *) calloc (1, sizeof (RAN_ControlParameter_Item_t));
139 uint8_t *ranParameter0NameBuffer = (uint8_t *) "Downlink PDCP Data Split";
140 size_t ranParameter0NameBufferSize = strlen ((char *) ranParameter0NameBuffer);
141 ranParameter0->ranParameter_Name.buf = (uint8_t *) calloc (1, ranParameter0NameBufferSize);
142 memcpy (ranParameter0->ranParameter_Name.buf, ranParameter0NameBuffer,
143 ranParameter0NameBufferSize);
144 ranParameter0->ranParameter_Name.size = ranParameter0NameBufferSize;
145 ranParameter0->ranParameter_ID = 3;
147 RAN_ControlParameter_Item_t *ranParameter1 =
148 (RAN_ControlParameter_Item_t *) calloc (1, sizeof (RAN_ControlParameter_Item_t));
149 uint8_t *ranParameter1NameBuffer = (uint8_t *) "Uplink PDCP Data Split Threshold";
150 size_t ranParameter1NameBufferSize = strlen ((char *) ranParameter1NameBuffer);
151 ranParameter1->ranParameter_Name.buf = (uint8_t *) calloc (1, ranParameter1NameBufferSize);
152 memcpy (ranParameter1->ranParameter_Name.buf, ranParameter1NameBuffer,
153 ranParameter1NameBufferSize);
154 ranParameter1->ranParameter_ID = 2;
156 ASN_SEQUENCE_ADD (&control_action0->ran_ControlParameters_List->list, ranParameter0);
157 ASN_SEQUENCE_ADD (&control_action0->ran_ControlParameters_List->list, ranParameter1);
159 ASN_SEQUENCE_ADD (&control_style0->ric_ControlAction_List->list, control_action0);
161 RIC_ControlStyle_Item_t *control_style1 =
162 (RIC_ControlStyle_Item_t *) calloc (1, sizeof (RIC_ControlStyle_Item_t));
163 control_style1->ric_ControlStyle_Type = 3;
165 uint8_t *controlStyleName1Buffer = (uint8_t *) "Radio Bearer Control";
166 size_t controlStyleName1BufferSize = strlen ((char *) controlStyleName1Buffer);
167 control_style1->ric_ControlStyle_Name.buf = (uint8_t *) calloc (1, controlStyleName1BufferSize);
168 memcpy (control_style1->ric_ControlStyle_Name.buf, controlStyleName1Buffer,
169 controlStyleName1BufferSize);
170 control_style1->ric_ControlStyle_Name.size = controlStyleName1BufferSize;
172 control_style1->ric_ControlMessageFormat_Type = 1;
173 control_style1->ric_ControlHeaderFormat_Type = 1;
175 control_style1->ric_ControlAction_List =
176 (RIC_ControlStyle_Item::RIC_ControlStyle_Item__ric_ControlAction_List *) calloc (
177 1, sizeof (RIC_ControlStyle_Item::RIC_ControlStyle_Item__ric_ControlAction_List));
179 RIC_ControlAction_Item_t *control_action1 =
180 (RIC_ControlAction_Item_t *) calloc (1, sizeof (RIC_ControlAction_Item_t));
182 control_action1->ric_ControlAction_ID = 1;
183 uint8_t *controlActionName1Buffer = (uint8_t *) "Handover control";
184 size_t controlActionName1BufferSize = strlen ((char *) controlActionName1Buffer);
185 control_action1->ric_ControlAction_Name.buf =
186 (uint8_t *) calloc (1, controlActionName1BufferSize);
187 memcpy (control_action1->ric_ControlAction_Name.buf, controlActionName1Buffer,
188 controlActionName1BufferSize);
189 control_action1->ric_ControlAction_Name.size = controlActionName1BufferSize;
190 control_action1->ran_ControlParameters_List =
191 (RIC_ControlAction_Item::RIC_ControlAction_Item__ran_ControlParameters_List *) calloc (
192 1, sizeof (RIC_ControlAction_Item::RIC_ControlAction_Item__ran_ControlParameters_List));
194 RAN_ControlParameter_Item_t *ranParameter2 =
195 (RAN_ControlParameter_Item_t *) calloc (1, sizeof (RAN_ControlParameter_Item_t));
196 uint8_t *ranParameter2NameBuffer = (uint8_t *) "NR CGI";
197 size_t ranParameter2NameBufferSize = strlen ((char *) ranParameter2NameBuffer);
198 ranParameter2->ranParameter_Name.buf = (uint8_t *) calloc (1, ranParameter2NameBufferSize);
199 memcpy (ranParameter2->ranParameter_Name.buf, ranParameter2NameBuffer,
200 ranParameter2NameBufferSize);
201 ranParameter2->ranParameter_Name.size = ranParameter2NameBufferSize;
202 ranParameter2->ranParameter_ID = 4;
204 RAN_ControlParameter_Item_t *ranParameter3 =
205 (RAN_ControlParameter_Item_t *) calloc (1, sizeof (RAN_ControlParameter_Item_t));
206 uint8_t *ranParameter3NameBuffer = (uint8_t *) "E-UTRA CGI";
207 size_t ranParameter3NameBufferSize = strlen ((char *) ranParameter3NameBuffer);
208 ranParameter3->ranParameter_Name.buf = (uint8_t *) calloc (1, ranParameter3NameBufferSize);
209 memcpy (ranParameter3->ranParameter_Name.buf, ranParameter3NameBuffer,
210 ranParameter3NameBufferSize);
211 ranParameter3->ranParameter_Name.size = ranParameter3NameBufferSize;
212 ranParameter3->ranParameter_ID = 6;
214 ASN_SEQUENCE_ADD (&control_action1->ran_ControlParameters_List->list, ranParameter2);
215 ASN_SEQUENCE_ADD (&control_action1->ran_ControlParameters_List->list, ranParameter3);
217 ASN_SEQUENCE_ADD (&control_style1->ric_ControlAction_List->list, control_action1);
219 ranfunc_desc->ric_ControlStyle_List =
220 (E2SM_RC_RANFunctionDefinition::E2SM_RC_RANFunctionDefinition__ric_ControlStyle_List *)
221 calloc (1, sizeof (E2SM_RC_RANFunctionDefinition::
222 E2SM_RC_RANFunctionDefinition__ric_ControlStyle_List));
224 ASN_SEQUENCE_ADD (&ranfunc_desc->ric_ControlStyle_List->list, control_style0);
225 ASN_SEQUENCE_ADD (&ranfunc_desc->ric_ControlStyle_List->list, control_style1);
227 Encode (ranfunc_desc);
229 NS_LOG_INFO (xer_fprint (stderr, &asn_DEF_E2SM_RC_RANFunctionDefinition, ranfunc_desc));