Skip to content

Commit f41e680

Browse files
pietrbraferaudo
andauthored
ccc: add the cell-level O-RRMPolicyRatio control (#49)
* ccc: add the cell-level O-RRMPolicyRatio control xDevSM had E2SM-CCC only for REPORT. CccRrmPolicyRatioControl sends the CONTROL Style 2 message (Header Format 1, Message Format 2) that sets the min, max, and dedicated PRB ratios of a slice in one cell. It needs no UE ID, unlike the RC slice-level PRB quota, which OCUDU accepts only with the gnb_du_ue_id of a connected UE on that slice. - find_ccc_function_id() takes the RAN function ID from the e2mgr info, because gNBs assign it at E2 Setup. It accepts the xDevSM CCC OID and the OID that OCUDU announces (1.3.6.1.4.1.53148.1.6.2.4). - send_policies() checks every slice before it sends the first control, so an invalid slice cannot leave a policy half applied. - One slice per message, because OCUDU checks only the first structure. - The dedicated ratio is at least 1, because OCUDU reads 0 as a missing field and fails the control. Tested on OCUDU release_26_10 with RU05 and three UEs on three slices: the gNB acknowledged every control, and a 10% max ratio on one slice cut that UE from 74 to 16 Mbit/s downlink. Assisted-by: Claude:claude-opus-5-5 * ccc: decode the control outcome of an acknowledge as E2SM-CCC JSON CccRrmPolicyRatioControl inherited the acknowledge handling of xAppControlService. With a registered callback, that handling gives the outcome octets of each RIC Control Acknowledge to decode_control_ack(), which runs the native E2SM-DAPP decoder dapp_dec_ctrl_out_asn on them. OCUDU sends a JSON E2SM-CCC Control Outcome, so the ASN.1 decoder got JSON. - xAppControlService._decode_ack() is now the decode step of both acknowledge handlers. It still calls decode_control_ack(), so the E2SM-DAPP services do not change. The hook is the one of the develop-ccc-ca branch. - CccRrmPolicyRatioControl overrides it with decode_ccc_control_ack(), which returns a CccControlAck with a CccControlOutcome. The names and the shape come from develop-ccc-ca. - CccControlOutcome reads the fields that OCUDU sends: Format 2 listOfCellsForControlOutcome, with or without the controlOutcomeFormat wrapper, accepted structures with their currentValuesOfAttributes, and failed structures with their cause. - nr_cell_id_of(), with the name and signature of develop-ccc-ca. The tests use the outcome that convert_to_e2sm_response() and pack_ric_control_response() of OCUDU build (feature/e2sm_ccc_report). Assisted-by: Claude:claude-opus-5-5 * ccc: follow E2SM-CCC v08 in the RRMPolicyRatio control, decode failures Review of the O-RRMPolicyRatio control against O-RAN.WG3.TS.E2SM-CCC-R005-v08.00 and TS 28.541: - Old Values carry the resource type and member of each slice: the E2 node finds the instance to change from them (§8.1.5), and the member list has at least one entry (§9.3.17). The old ratios are still left out, because the xApp does not read them. - dedicated_ratio defaults to 0 and is sent as given; the 0 -> 1 clamp is gone. Each slice needs dedicated <= min <= max, and the min ratios of one call sum to at most 100 (TS 28.541). - sst must be 0..255, mcc 3 digits and mnc 2 or 3 digits, as in the E2SM-CCC JSON schema. - send_policies() sends all slices in one control, so the cell applies them together and a failing slice cannot leave half a policy behind. - xAppControlService._decode_ack() decodes nothing by default and each Service Model overrides it. DAppPrbMaskControl keeps the E2SM-DAPP decoder; the RC controls give their callbacks the RMR summary again instead of a DAppControlAck. - ricxappframe patch 003 adds ControlFailureMsg, the RICControlFailure counterpart of the ControlAckMsg of patch 002. decode_ccc_control_ack() reads both, so a failed control reaches the fail callback as a CccControlAck with its outcome and its E2AP cause. It needs riclibe2ap with the fixed failure decoder (aferaudo/libe2ap_package a10875d on dev). - The README keeps the OCUDU limits in one bullet. Assisted-by: Claude:claude-opus-5-5 * ricxappframe: size the control request buffer to the message (patch 004) ControlRequestMsg.encode() encoded into a fixed 1024-byte buffer, so an E2SM-CCC control for two or more slices failed with 'Could not create payload.', and it returned the whole buffer, so every control went out as 1024 bytes. The buffer now fits the message and encode() returns only the PDU, with its length in bytes (riclibe2ap returns bits). Reported on PR 49. Assisted-by: Claude:claude-opus-5-5 --------- Co-authored-by: Feraudo <aferaudo34@gmail.com> Co-authored-by: Angelo Feraudo <33128793+aferaudo@users.noreply.github.com>
1 parent 5cacc5a commit f41e680

14 files changed

Lines changed: 833 additions & 6 deletions

File tree

‎README.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The architecture separates three main layers:
2424
| **KPM (Key Performance Measurement)** | Measurement Actions | • Common Condition-based Measurement, UE-level Measurement |
2525
| **RC (RAN Control)** | Control Actions | • QoS Flow Mapping Configuration<br>• Slice-level PRB Quota Action (only monolithic gNBs)<br>• Connected Mode Mobility Control |
2626
| **CCC (Cell Configuration and Control)** | Report Actions | • Cell-level RAN Configuration Reporting (REPORT Style 2, periodic event trigger) — e.g. `O-NRCellDU` attributes |
27+
| **CCC (Cell Configuration and Control)** | Control Actions | • Cell-level `O-RRMPolicyRatio` control (CONTROL Style 2): per-slice min, max, and dedicated PRB ratios, tested on OCUDU |
2728
---
2829

2930
## Installation
@@ -234,6 +235,41 @@ ccc_xapp.subscribe_arfcn_bw_bwps(gnb=selected_gnb, ran_period_ms=1000)
234235

235236
> ℹ️ The indication callback signature is `handler(ind_hdr, ind_msg, meid, sub_id)`. Iterate the reported cells/structures with `ind_msg.cells()` / `ind_msg.iter_structures()`.
236237
238+
### CccRrmPolicyRatioControl
239+
240+
`CccRrmPolicyRatioControl` sends the E2SM-CCC cell-level control (CONTROL Style 2, Header Format 1, Message Format 2) for the `O-RRMPolicyRatio` structure. It sets the PRB share of a slice in one cell, so it needs no UE ID. It extends `xAppControlService` and uses `send_policies()` instead of `send()`, because the JSON encoding has no ASN.1 function definition.
241+
242+
* `find_ccc_function_id(json_ran_info)` returns the CCC RAN function ID from the e2mgr information of the E2 node. It accepts the OID `1.3.6.1.4.1.53148.1.1.2.4` and the OID `1.3.6.1.4.1.53148.1.6.2.4` that OCUDU announces.
243+
* `send_policies()` checks every slice, then sends all slices in one control, so the cell applies them together. A control for two or more slices is larger than 1 KB and needs the xDevSM ricxappframe patches (patch 004).
244+
* Each slice needs `dedicated_ratio <= min_ratio <= max_ratio`, and the `min_ratio` of the slices in one call must sum to at most 100 (TS 28.541). `dedicated_ratio` defaults to 0.
245+
* The Old Values of each slice carry its resource type and member, so the E2 node can find the policy to change. They leave out the old ratios, which the xApp does not read.
246+
* Known OCUDU limits: it reads `rRMPolicyDedicatedRatio` 0 as missing and fails the control (pass `dedicated_ratio=1` or more), and it applies only the min and max ratios, only to slices in `cell_cfg: slicing`.
247+
* The callbacks of `register_control_ack_suc_callback()` and `register_control_ack_fail_callback()` receive a `CccControlAck` for a RIC Control Acknowledge or Failure. Its `outcome` is a `CccControlOutcome`, the JSON E2SM-CCC Control Outcome of the message. `outcome.structures()` lists each structure with `applied`, its `applied_values` (the currentValuesOfAttributes) or its `failure_reason`. A failure also carries `cause`, the E2AP Cause as (choice, value). A message that does not decode reaches the callback as the RMR summary. Decoding needs the xDevSM ricxappframe patches (`python -m xdevsm.ricxappframe_patches`).
248+
249+
```python
250+
from xdevsm import CccRrmPolicyRatioControl
251+
from xdevsm.sm_framework.py_oran.ccc.ccc_decoder import find_ccc_function_id
252+
from xdevsm.sm_framework.py_oran.ccc.ccc_encoder import RrmPolicySlice
253+
254+
gnb, gnb_info = xapp_gen.get_selected_e2node_info(None)
255+
ctrl = CccRrmPolicyRatioControl(xapp_gen,
256+
logger=xapp_gen.logger,
257+
server=xapp_gen.server,
258+
xapp_name=xapp_gen.get_xapp_name(),
259+
rmr_port=xapp_gen.rmr_port,
260+
http_port=xapp_gen.http_port,
261+
mrc=xapp_gen._mrc,
262+
pltnamespace=xapp_gen.get_pltnamespace(),
263+
app_namespace=xapp_gen.get_app_namespace(),
264+
mcc="001", mnc="01",
265+
nci=0x3954000, # 36-bit NR Cell Identity
266+
function_id=find_ccc_function_id(gnb_info))
267+
xapp_gen.register_handler(ctrl.handle)
268+
ctrl.send_policies(gnb.inventory_name,
269+
[RrmPolicySlice(sst=1, sd="000001", min_ratio=1, max_ratio=10, dedicated_ratio=1)],
270+
resource_type="PRB_DL")
271+
```
272+
237273
---
238274
## 7. xAppReportService
239275

‎VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.7
1+
0.1.8

‎src/xdevsm/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"BaseXDevSMWrapper": "xdevsm.decorators.base:BaseXDevSMWrapper",
2424
"XappKpmFrame": "xdevsm.decorators.kpm.kpm_frame:XappKpmFrame",
2525
"XappCccFrame": "xdevsm.decorators.ccc.ccc_frame:XappCccFrame",
26+
"CccRrmPolicyRatioControl": "xdevsm.decorators.ccc.ccc_rrm_policy_control:CccRrmPolicyRatioControl",
2627
"XappRcReportFrame": "xdevsm.decorators.rc.rc_report_frame:XappRcReportFrame",
2728
"RadioBearerControl": "xdevsm.decorators.rc.rc_radio_bearer_control:RadioBearerControl",
2829
"RadioResourceAllocationControl": "xdevsm.decorators.rc.rc_radio_resource_alloc_control:RadioResourceAllocationControl",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from typing import Optional
2+
3+
from xdevsm.sm_framework.py_oran.ccc.ccc_decoder import CccControlOutcome
4+
5+
try:
6+
from ricxappframe.e2ap.asn1 import ControlAckMsg
7+
except ImportError: # pragma: no cover - unpatched ricxappframe: acknowledges without outcome
8+
ControlAckMsg = None
9+
try:
10+
from ricxappframe.e2ap.asn1 import ControlFailureMsg
11+
except ImportError: # pragma: no cover - ricxappframe without patch 003: failures reach the callback as the RMR summary
12+
ControlFailureMsg = None
13+
14+
15+
class CccControlAck:
16+
"""What a RIC Control Acknowledge or Failure of a CCC control says: ``outcome`` is the decoded JSON outcome (None
17+
if the message carried none, or the installed ricxappframe cannot decode it). ``cause`` is the E2AP Cause of a
18+
failure as (choice, value), None for an acknowledge."""
19+
20+
__slots__ = ("ric_requestor_id", "ran_function_id", "outcome", "cause", "meid")
21+
22+
def __init__(self, ric_requestor_id, ran_function_id, outcome: Optional[CccControlOutcome], cause=None):
23+
self.ric_requestor_id = ric_requestor_id
24+
self.ran_function_id = ran_function_id
25+
self.outcome = outcome
26+
self.cause = cause
27+
self.meid = None
28+
29+
def __repr__(self):
30+
return "CccControlAck(meid={}, outcome={}, cause={})".format(self.meid, self.outcome, self.cause)
31+
32+
33+
def decode_ccc_control_ack(pdu) -> Optional[CccControlAck]:
34+
"""Decode one E2AP RIC Control Acknowledge or Failure with a CCC outcome, None if it is neither"""
35+
if not pdu:
36+
return None
37+
for msg_type in (ControlAckMsg, ControlFailureMsg):
38+
if msg_type is None:
39+
continue
40+
msg = msg_type()
41+
try:
42+
msg.decode(pdu)
43+
except Exception: # not this message, or malformed
44+
continue
45+
raw = msg.control_outcome
46+
cause = (msg.cause_type, msg.cause_value) if msg_type is ControlFailureMsg else None
47+
return CccControlAck(msg.request_id, msg.function_id, CccControlOutcome(bytes(raw)) if raw else None, cause)
48+
return None
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from typing import Sequence, Union
2+
3+
from xdevsm.decorators.ccc.ccc_control import decode_ccc_control_ack
4+
from xdevsm.decorators.control import xAppControlService
5+
from xdevsm.sm_framework.py_oran.ccc.constants import RESOURCE_TYPE_PRB_DL
6+
from xdevsm.sm_framework.py_oran.ccc.ccc_encoder import (
7+
RrmPolicySlice,
8+
encode_control_header,
9+
encode_rrm_policy_ratio_control,
10+
validate_slices,
11+
)
12+
from xdevsm._latrec.writer import tls_ring, seq_next, ctx_set
13+
from xdevsm._latrec import stages
14+
from xdevsm._latrec.stages import LATREC_ROLE as _LATREC_ROLE
15+
16+
17+
class CccRrmPolicyRatioControl(xAppControlService):
18+
"""
19+
E2SM-CCC RIC Control (style 2, cell level) for the O-RRMPolicyRatio structure.
20+
Call `send_policies()`, not `send()`. Take `function_id` from
21+
`ccc_decoder.find_ccc_function_id()`: the gNB assigns it at E2 Setup.
22+
The acknowledge callbacks receive a `CccControlAck` with the JSON outcome.
23+
"""
24+
25+
def __init__(self,
26+
xapp_handler,
27+
logger,
28+
server,
29+
xapp_name,
30+
rmr_port,
31+
http_port,
32+
mrc,
33+
pltnamespace,
34+
app_namespace,
35+
mcc,
36+
mnc,
37+
nci,
38+
function_id):
39+
super().__init__(xapp_handler, logger, server, xapp_name, rmr_port, http_port, mrc, pltnamespace, app_namespace)
40+
self.service_style_name = "Cell Configuration and Control"
41+
self.function_id = function_id
42+
self.mcc = mcc
43+
self.mnc = mnc
44+
self.nci = nci
45+
46+
def _decode_ack(self, pdu):
47+
return decode_ccc_control_ack(pdu)
48+
49+
def send_policies(self,
50+
e2_node_id,
51+
slices: Sequence[Union[RrmPolicySlice, dict]],
52+
resource_type=RESOURCE_TYPE_PRB_DL):
53+
"""Send all slices in one control, so the cell applies them together and never holds half a policy.
54+
Raises before sending if any slice is invalid."""
55+
parsed = validate_slices(slices)
56+
header = encode_control_header().to_bytes()
57+
lr = tls_ring(_LATREC_ROLE)
58+
seq = seq_next()
59+
ctx_set(seq)
60+
lr.stamp(seq, stages.ENCODE_E2SM_BEGIN)
61+
message = encode_rrm_policy_ratio_control(self.mcc, self.mnc, self.nci, parsed, resource_type).to_bytes()
62+
lr.stamp(seq, stages.ENCODE_E2SM_DONE, aux=len(header) + len(message))
63+
self.logger.debug("[CccRrmPolicyRatioControl] control message: {}".format(message))
64+
self.send_control_request_rmr(e2_node_id=e2_node_id,
65+
control_header=header,
66+
control_message=message,
67+
seq=seq)

‎src/xdevsm/decorators/control.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from xdevsm.sm_framework.py_oran.ByteArray import free as free_byte_array
1515

1616
# utility
17-
from xdevsm.sm_framework.py_oran.dapp.control.DAppControlAck import decode_control_ack
1817
from xdevsm.utils.constants import Values
1918
from xdevsm.utils.ack_route import AckRoute
2019
from xdevsm._latrec.writer import tls_ring, seq_next, ctx_set, ctx_get
@@ -273,6 +272,12 @@ def _with_meid(self, ack, summary):
273272
% type(ack).__name__)
274273
return ack
275274

275+
def _decode_ack(self, pdu):
276+
"""Decode an acknowledge PDU into the Service Model's own type for the callbacks, None if it does not decode.
277+
Each Service Model overrides this with its own outcome decoder (DAppPrbMaskControl, CccRrmPolicyRatioControl).
278+
The default decodes nothing, so the callbacks receive the RMR summary."""
279+
return None
280+
276281
def _handle_control_ack_suc(self, xapp, summary, sbuf):
277282
self.logger.debug("[xAppControlService] Handling control ack - default implementation")
278283
if not self.__control_ack_handler_suc:
@@ -282,15 +287,15 @@ def _handle_control_ack_suc(self, xapp, summary, sbuf):
282287
# not decode falls back to the raw RMR summary, so a handler written
283288
# before this existed keeps working; check `is not None` rather than
284289
# assuming a type.
285-
ack = decode_control_ack(summary.get(rmr.RMR_MS_PAYLOAD))
290+
ack = self._decode_ack(summary.get(rmr.RMR_MS_PAYLOAD))
286291
ack = self._with_meid(ack, summary)
287292
self.__control_ack_handler_suc(ack if ack is not None else summary)
288293

289294
def _handle_control_ack_fail(self, xapp, summary, sbuf):
290295
self.logger.debug("[xAppControlService] Handling control failure ack - default implementation")
291296
if not self.__control_ack_handler_fail:
292297
return
293-
ack = decode_control_ack(summary.get(rmr.RMR_MS_PAYLOAD))
298+
ack = self._decode_ack(summary.get(rmr.RMR_MS_PAYLOAD))
294299
ack = self._with_meid(ack, summary)
295300
self.__control_ack_handler_fail(ack if ack is not None else summary)
296301

‎src/xdevsm/decorators/dApp/control/dapp_prb_mask_control.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# xDevSM sm framework
55
from xdevsm.sm_framework.py_oran.ByteArray import ByteArray
66
from xdevsm.sm_framework.py_oran.dapp.control.DAppControlReq import DAppControlReqWrapper
7+
from xdevsm.sm_framework.py_oran.dapp.control.DAppControlAck import decode_control_ack
78
from xdevsm.sm_framework.py_oran.dapp.e3.DAppE3CtrlPayload import DAppE3CtrlPayloadWrapper
89
import xdevsm.sm_framework.py_oran.dapp.report.DAppFunctionDef as dappfuncdef
910
from xdevsm.sm_framework.py_oran.dapp.enums import dapp_e3_sm_type_e
@@ -64,6 +65,8 @@ def handle(self, xapp, summary, sbuf):
6465
# handle should be done based on the control message type, not supported for dApps
6566
super().handle(xapp, summary, sbuf)
6667

68+
def _decode_ack(self, pdu):
69+
return decode_control_ack(pdu)
6770

6871
def generate_control_request(self, ue_id_struct=None, control_action_id=1):
6972
# TODO do we need any check on the action id?
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
--- a/ricxappframe/e2ap/asn1.py
2+
+++ b/ricxappframe/e2ap/asn1.py
3+
@@ -404,6 +404,59 @@
4+
return size, bytes(buf)
5+
6+
7+
+# Imported here, not in the import block at the top: patch 002 edits that line.
8+
+from ricxappframe.e2ap.asn1clib.types import control_failure_msg_t # noqa: E402
9+
+
10+
+_asn1_decode_controlFailureMsg = _wrap_asn1_function(
11+
+ 'e2ap_decode_ric_control_failure_message', POINTER(control_failure_msg_t), [c_void_p, c_ulong])
12+
+_asn1_free_controlFailureMsg = _wrap_asn1_function(
13+
+ 'e2ap_free_decoded_ric_control_failure', c_void_p, [POINTER(control_failure_msg_t)])
14+
+
15+
+
16+
+class ControlFailureMsg:
17+
+ """
18+
+ A class that parses the payload of an e2ap RICControlFailure message.
19+
+
20+
+ `cause_type` and `cause_value` are the E2AP Cause choice and its value.
21+
+ As in ControlAckMsg, `control_outcome` is opaque here and is decoded by
22+
+ whichever Service Model issued the control request.
23+
+ """
24+
+
25+
+ __slots__ = ('request_id', 'instance_id', 'function_id', 'call_process_id',
26+
+ 'control_outcome', 'cause_type', 'cause_value')
27+
+
28+
+ def __init__(self):
29+
+ self.request_id = -1
30+
+ self.instance_id = -1
31+
+ self.function_id = -1
32+
+ self.call_process_id = b''
33+
+ self.control_outcome = b''
34+
+ self.cause_type = 0
35+
+ self.cause_value = -1
36+
+
37+
+ def decode(self, payload: bytes):
38+
+ """
39+
+ Set the fields from the bytes of a RICControlFailure received via rmr.
40+
+
41+
+ Raise Exception when payload is not RICControlFailure.
42+
+ """
43+
+ # len, not getsizeof: getsizeof also counts the bytes object header
44+
+ failure = _asn1_decode_controlFailureMsg(payload, len(payload))
45+
+ if not failure:
46+
+ raise Exception("Payload is not matched with RICControlFailure")
47+
+ msg = failure.contents
48+
+ self.request_id = msg.request_id
49+
+ self.instance_id = msg.instance_id
50+
+ self.function_id = msg.function_id
51+
+ if msg.call_process_id and msg.call_process_id_length:
52+
+ self.call_process_id = bytes(msg.call_process_id[:msg.call_process_id_length])
53+
+ if msg.control_outcome and msg.control_outcome_length:
54+
+ self.control_outcome = bytes(msg.control_outcome[:msg.control_outcome_length])
55+
+ self.cause_type = msg.cause_type
56+
+ self.cause_value = msg.cause_value
57+
+ _asn1_free_controlFailureMsg(failure)
58+
+
59+
+
60+
_asn1_encode_controlReqMsg = _wrap_asn1_function('e2ap_encode_ric_control_request_message', c_ssize_t, [
61+
c_void_p, c_size_t, c_long, c_long, c_long, c_void_p, c_size_t, c_void_p, c_size_t, c_void_p, c_size_t, c_long])
62+
63+
--- a/ricxappframe/e2ap/asn1clib/types.py
64+
+++ b/ricxappframe/e2ap/asn1clib/types.py
65+
@@ -136,6 +136,38 @@
66+
]
67+
68+
69+
+class control_failure_msg_t(Structure):
70+
+ """
71+
+ A class that mirrored E2AP's RICControlFailure with python
72+
+
73+
+ c-type struct of RICControlFailure
74+
+ ---------------------------------------
75+
+ typedef struct RICControlFailureMsg {
76+
+ long requestorID;
77+
+ long instanceID;
78+
+ long ranfunctionID;
79+
+ uint8_t *callProcessID;
80+
+ size_t callProcessIDSize;
81+
+ uint8_t *ricControlOutCome;
82+
+ size_t ricControlOutComeSize;
83+
+ int causeType;
84+
+ long causeValue;
85+
+ } RICControlFailure;
86+
+ ---------------------------------------
87+
+ """
88+
+ _fields_ = [
89+
+ ("request_id", c_long),
90+
+ ("instance_id", c_long),
91+
+ ("function_id", c_long),
92+
+ ("call_process_id", POINTER(c_uint8)),
93+
+ ("call_process_id_length", c_size_t),
94+
+ ("control_outcome", POINTER(c_uint8)),
95+
+ ("control_outcome_length", c_size_t),
96+
+ ("cause_type", c_int),
97+
+ ("cause_value", c_long),
98+
+ ]
99+
+
100+
+
101+
class ric_action_definition_t(Structure):
102+
"""
103+
A class that mirrored E2AP's RICactionDefinition with python
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--- a/ricxappframe/e2ap/asn1.py
2+
+++ b/ricxappframe/e2ap/asn1.py
3+
@@ -509,9 +509,13 @@
4+
for idx in range(len(control_message)):
5+
call_message_buffer[idx] = c_uint8(control_message[idx])
6+
7+
- buf = ARRAY(c_uint8, 1024)()
8+
- size: int = _asn1_encode_controlReqMsg(buf, c_size_t(1024), c_long(requestor_id), c_long(request_sequence_number), c_long(ran_function_id), call_process_id_buffer, c_size_t(
9+
+ # The octet strings plus 1024 bytes (the whole buffer upstream) for the E2AP framing.
10+
+ buf = ARRAY(c_uint8, len(call_process_id) + len(control_header) + len(control_message) + 1024)()
11+
+ size: int = _asn1_encode_controlReqMsg(buf, c_size_t(len(buf)), c_long(requestor_id), c_long(request_sequence_number), c_long(ran_function_id), call_process_id_buffer, c_size_t(
12+
len(call_process_id_buffer)), call_header_buffer, c_size_t(len(call_header_buffer)), call_message_buffer, c_size_t(len(call_message_buffer)), c_long(control_ack_request))
13+
+ if size >= 0: # the encoder returns bits: keep the bytes of the PDU, not the whole buffer
14+
+ size = (size + 7) // 8
15+
+ buf = buf[:size]
16+
if size < 0:
17+
raise Exception("Could not create payload.")
18+

‎src/xdevsm/ricxappframe_patches/README.md‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,36 @@ No new shared library is involved: `libriclibe2ap.so` is the same object
5757
`ricxappframe` already loads in `asn1clib.py`, and these symbols resolve
5858
through its existing handle.
5959

60+
### 003-add-control-failure-decode.patch
61+
62+
Adds `ControlFailureMsg` to `ricxappframe.e2ap.asn1` and
63+
`control_failure_msg_t` to `ricxappframe.e2ap.asn1clib.types`, the
64+
RICControlFailure counterpart of 002, binding:
65+
66+
- `e2ap_decode_ric_control_failure_message`
67+
- `e2ap_free_decoded_ric_control_failure`
68+
69+
Besides the fields of `ControlAckMsg` it has `cause_type` and `cause_value`,
70+
the E2AP Cause choice and its value. Its hunks stay clear of 002's, so the
71+
already-applied check of each patch still works on a rerun.
72+
73+
Needs riclibe2ap with the fixed failure decoder: an older one returns no
74+
`control_outcome` and a wrong cause.
75+
76+
### 004-size-control-request-buffer.patch
77+
78+
`ControlRequestMsg.encode()` encoded into a fixed 1024-byte buffer, so a
79+
larger control failed with "Could not create payload." (an E2SM-CCC control
80+
for two or more slices), and it returned the whole buffer, so every control
81+
went out as 1024 bytes with zeros after the PDU. E2AP sets no size limit on
82+
the RIC Control Message.
83+
84+
The buffer now holds the call process ID, header and message plus 1024 bytes
85+
for the E2AP framing, and `encode()` returns the PDU only, with its length in
86+
bytes. The encoder in riclibe2ap returns a bit count, which upstream passed
87+
on as the length. The `return` line stays as it is, because 002 uses it as
88+
context.
89+
6090
## Regenerating a patch
6191

6292
```sh

0 commit comments

Comments
 (0)