21constexpr const char* LOG_TAG =
"JsonEnc";
23std::string to_camel_case(
const char* pascal) {
24 std::string s(pascal);
25 if (!s.empty()) s[0] =
static_cast<char>(std::tolower(
static_cast<unsigned char>(s[0])));
29bool is_json_ws(
char c) {
30 return c ==
' ' || c ==
'\t' || c ==
'\n' || c ==
'\r';
33size_t skip_ws(
const std::string& text,
size_t pos) {
34 while (pos < text.size() && is_json_ws(text[pos])) {
42std::optional<size_t> skip_json_string(
const std::string& text,
size_t pos) {
43 const size_t n = text.size();
44 if (pos >= n || text[pos] !=
'"')
return std::nullopt;
49 if (pos + 1 >= n)
return std::nullopt;
50 if (text[pos + 1] ==
'u') {
51 if (pos + 6 > n)
return std::nullopt;
73std::optional<size_t> skip_json_value(
const std::string& text,
size_t pos) {
74 const size_t n = text.size();
75 if (pos >= n)
return std::nullopt;
78 return skip_json_string(text, pos);
80 if (c ==
'{' || c ==
'[') {
82 char close = (open ==
'{') ?
'}' :
']';
85 while (pos < n && depth > 0) {
88 auto after = skip_json_string(text, pos);
89 if (!after)
return std::nullopt;
95 }
else if (cc == close) {
100 if (depth != 0)
return std::nullopt;
106 if (cc ==
',' || cc ==
'}' || cc ==
']' || is_json_ws(cc)) {
126std::optional<std::pair<size_t, size_t>> find_top_level_member_span(
127 const std::string& text,
size_t obj_start,
const std::string& key) {
128 const size_t n = text.size();
129 if (obj_start >= n || text[obj_start] !=
'{') {
133 size_t pos = obj_start + 1;
135 pos = skip_ws(text, pos);
136 if (pos >= n)
return std::nullopt;
137 if (text[pos] ==
'}') {
140 if (text[pos] !=
'"')
return std::nullopt;
142 size_t key_start = pos + 1;
143 auto after_key = skip_json_string(text, pos);
144 if (!after_key)
return std::nullopt;
145 size_t key_end = *after_key - 1;
147 pos = skip_ws(text, *after_key);
148 if (pos >= n || text[pos] !=
':')
return std::nullopt;
149 pos = skip_ws(text, pos + 1);
151 size_t value_start = pos;
152 auto after_value = skip_json_value(text, pos);
153 if (!after_value)
return std::nullopt;
155 bool key_matches = (key_end - key_start == key.size()) &&
156 text.compare(key_start, key.size(), key) == 0;
158 return std::make_pair(value_start, *after_value);
161 pos = skip_ws(text, *after_value);
162 if (pos < n && text[pos] ==
',') {
171bool is_json_container(
const std::vector<uint8_t>& bytes) {
173 while (i < bytes.size() && is_json_ws(
static_cast<char>(bytes[i]))) ++i;
174 if (i == bytes.size() || (bytes[i] !=
'{' && bytes[i] !=
'['))
return false;
175 return nlohmann::json::accept(bytes);
179void require_json_container(
const std::vector<uint8_t>& bytes,
const char* field) {
180 if (!is_json_container(bytes)) {
181 throw std::invalid_argument(std::string(field) +
" is not a JSON object or array ("
182 + std::to_string(bytes.size()) +
" bytes)");
193std::optional<PduType> JsonE3Encoder::string_to_pdu_type(
const std::string& s)
const {
209ErrorCode JsonE3Encoder::string_to_error_code(
const std::string& s)
const {
210 if (s ==
"SUCCESS")
return ErrorCode::SUCCESS;
211 if (s ==
"INVALID_PARAM")
return ErrorCode::INVALID_PARAM;
212 if (s ==
"TIMEOUT")
return ErrorCode::TIMEOUT;
213 if (s ==
"NOT_FOUND")
return ErrorCode::NOT_FOUND;
214 return ErrorCode::GENERIC_ERROR;
221std::vector<uint8_t> JsonE3Encoder::payload_from_json(
const nlohmann::json& value) {
222 if (value.is_object() || value.is_array()) {
223 std::string text = value.dump();
224 return std::vector<uint8_t>(text.begin(), text.end());
226 throw std::invalid_argument(
"payload is not a JSON object or array");
229std::vector<uint8_t> JsonE3Encoder::payload_member(
const nlohmann::json& j,
230 const std::string& raw_json,
232 auto it = j.find(key);
233 if (it == j.end())
return {};
234 if (it->is_object() || it->is_array()) {
235 size_t obj_start = raw_json.find_first_not_of(
" \t\r\n");
236 auto span = (obj_start == std::string::npos)
238 : find_top_level_member_span(raw_json, obj_start, key);
241 return std::vector<uint8_t>(raw_json.begin() +
static_cast<long>(span->first),
242 raw_json.begin() +
static_cast<long>(span->second));
245 return payload_from_json(*it);
252nlohmann::json JsonE3Encoder::encode_setup_request(
const SetupRequest& req)
const {
254 j[
"e3apProtocolVersion"] = req.e3ap_protocol_version;
255 j[
"dAppName"] = req.dapp_name;
256 j[
"dAppVersion"] = req.dapp_version;
257 j[
"vendor"] = req.vendor;
265template <
typename Resp>
266void write_reason(nlohmann::json& j,
const Resp& resp) {
268 if (resp.detail) j[
"detail"] = *resp.detail;
272template <
typename Resp>
273void read_reason(
const nlohmann::json& j, Resp& resp) {
274 if (
auto it = j.find(
"cause"); it != j.end() && it->is_string()) {
277 for (
const char* key : {
"detail",
"message"}) {
278 if (
auto it = j.find(key); it != j.end() && it->is_string()) {
279 resp.detail = it->get<std::string>();
287nlohmann::json JsonE3Encoder::encode_setup_response(
const SetupResponse& resp)
const {
289 j[
"requestId"] = resp.request_id;
291 if (resp.e3ap_protocol_version.has_value()) {
292 j[
"e3apProtocolVersion"] = resp.e3ap_protocol_version.value();
294 if (resp.dapp_identifier.has_value()) {
295 j[
"dAppIdentifier"] = resp.dapp_identifier.value();
297 j[
"ranIdentifier"] = resp.ran_identifier;
298 if (!resp.ran_function_list.empty()) {
299 nlohmann::json ran_funcs = nlohmann::json::array();
300 for (
const auto& func : resp.ran_function_list) {
301 nlohmann::json func_obj;
302 func_obj[
"ranFunctionIdentifier"] = func.ran_function_identifier;
303 func_obj[
"telemetryIdentifierList"] = func.telemetry_identifier_list;
304 func_obj[
"controlIdentifierList"] = func.control_identifier_list;
305 require_json_container(func.ran_function_data,
"ranFunctionData");
306 func_obj[
"ranFunctionData"] = nlohmann::json::parse(func.ran_function_data);
307 ran_funcs.push_back(func_obj);
309 j[
"ranFunctionList"] = ran_funcs;
311 write_reason(j, resp);
315nlohmann::json JsonE3Encoder::encode_subscription_request(
const SubscriptionRequest& req)
const {
317 j[
"dAppIdentifier"] = req.dapp_identifier;
318 j[
"ranFunctionIdentifier"] = req.ran_function_identifier;
319 j[
"telemetryIdentifierList"] = req.telemetry_identifier_list;
320 j[
"controlIdentifierList"] = req.control_identifier_list;
321 if (req.subscription_time.has_value()) {
322 j[
"subscriptionTime"] = req.subscription_time.value();
324 if (req.periodicity.has_value()) {
325 j[
"periodicity"] = req.periodicity.value();
330nlohmann::json JsonE3Encoder::encode_subscription_delete(
const SubscriptionDelete& del)
const {
332 j[
"dAppIdentifier"] = del.dapp_identifier;
333 j[
"subscriptionId"] = del.subscription_id;
337nlohmann::json JsonE3Encoder::encode_subscription_response(
const SubscriptionResponse& resp)
const {
339 j[
"requestId"] = resp.request_id;
340 j[
"dAppIdentifier"] = resp.dapp_identifier;
342 if (resp.subscription_id.has_value()) {
343 j[
"subscriptionId"] = resp.subscription_id.value();
345 if (resp.telemetry_identifier_list.has_value()) {
346 j[
"telemetryIdentifierList"] = *resp.telemetry_identifier_list;
348 if (resp.control_identifier_list.has_value()) {
349 j[
"controlIdentifierList"] = *resp.control_identifier_list;
351 if (resp.ran_function_identifier.has_value()) {
352 j[
"ranFunctionIdentifier"] = *resp.ran_function_identifier;
354 if (resp.periodicity.has_value()) {
355 j[
"periodicity"] = *resp.periodicity;
357 write_reason(j, resp);
361std::optional<nlohmann::json> JsonE3Encoder::encode_indication_message(
const IndicationMessage& msg)
const {
362 if (!nlohmann::json::accept(msg.protocol_data)) {
363 E3_LOG_ERROR(LOG_TAG) <<
"Malformed protocolData for indication message "
364 <<
"(ranFunctionIdentifier=" << msg.ran_function_identifier
365 <<
", payload size=" << msg.protocol_data.size() <<
" bytes)";
369 j[
"dAppIdentifier"] = msg.dapp_identifier;
370 j[
"ranFunctionIdentifier"] = msg.ran_function_identifier;
377nlohmann::json JsonE3Encoder::encode_dapp_control_action(
const DAppControlAction& action)
const {
379 j[
"dAppIdentifier"] = action.dapp_identifier;
380 j[
"ranFunctionIdentifier"] = action.ran_function_identifier;
381 j[
"controlIdentifier"] = action.control_identifier;
383 if (action.sequence_id != 0) j[
"sequenceId"] = action.sequence_id;
385 if (action.request_ack) j[
"requestAck"] =
true;
389nlohmann::json JsonE3Encoder::encode_dapp_report(
const DAppReport& report)
const {
391 j[
"dAppIdentifier"] = report.dapp_identifier;
392 j[
"ranFunctionIdentifier"] = report.ran_function_identifier;
393 j[
"sequenceId"] = report.sequence_id;
397nlohmann::json JsonE3Encoder::encode_xapp_control_action(
const XAppControlAction& action)
const {
399 j[
"dAppIdentifier"] = action.dapp_identifier;
400 j[
"ranFunctionIdentifier"] = action.ran_function_identifier;
401 j[
"sequenceId"] = action.sequence_id;
402 if (action.request_ack) j[
"requestAck"] =
true;
407nlohmann::json JsonE3Encoder::encode_message_ack(
const MessageAck& ack)
const {
409 j[
"requestId"] = ack.request_id;
411 write_reason(j, ack);
415nlohmann::json JsonE3Encoder::encode_control_response(
const ControlResponse& resp)
const {
417 j[
"requestId"] = resp.request_id;
418 j[
"dAppIdentifier"] = resp.dapp_identifier;
419 j[
"ranFunctionIdentifier"] = resp.ran_function_identifier;
420 j[
"controlIdentifier"] = resp.control_identifier;
422 write_reason(j, resp);
431SetupRequest JsonE3Encoder::decode_setup_request(
const nlohmann::json& j)
const {
434 req.dapp_name = j.value(
"dAppName",
"");
435 req.dapp_version = j.value(
"dAppVersion",
"");
436 req.vendor = j.value(
"vendor",
"");
441SetupResponse JsonE3Encoder::decode_setup_response(
const nlohmann::json& j)
const {
445 std::string response_code_str = j.value(
"responseCode",
"negative");
448 if (j.contains(
"e3apProtocolVersion")) {
449 resp.e3ap_protocol_version = j[
"e3apProtocolVersion"].get<std::string>();
451 if (j.contains(
"dAppIdentifier")) {
452 resp.dapp_identifier = j[
"dAppIdentifier"].get<uint32_t>();
454 resp.ran_identifier = j.value(
"ranIdentifier",
"");
455 if (j.contains(
"ranFunctionList")) {
456 for (
const auto& func_obj : j[
"ranFunctionList"]) {
458 func.ran_function_identifier = func_obj.value(
"ranFunctionIdentifier", 0u);
459 func.telemetry_identifier_list = func_obj.value(
"telemetryIdentifierList", std::vector<uint32_t>{});
460 func.control_identifier_list = func_obj.value(
"controlIdentifierList", std::vector<uint32_t>{});
461 if (
auto it = func_obj.find(
"ranFunctionData"); it != func_obj.end()) {
462 func.ran_function_data = payload_from_json(*it);
464 resp.ran_function_list.push_back(func);
467 read_reason(j, resp);
471SubscriptionRequest JsonE3Encoder::decode_subscription_request(
const nlohmann::json& j)
const {
472 SubscriptionRequest req;
474 req.ran_function_identifier = j.value(
"ranFunctionIdentifier", 0u);
475 req.telemetry_identifier_list = j.value(
"telemetryIdentifierList", std::vector<uint32_t>{});
476 req.control_identifier_list = j.value(
"controlIdentifierList", std::vector<uint32_t>{});
477 if (j.contains(
"subscriptionTime")) {
478 req.subscription_time = j[
"subscriptionTime"].get<uint32_t>();
480 if (j.contains(
"periodicity")) {
481 req.periodicity = j[
"periodicity"].get<uint32_t>();
486SubscriptionDelete JsonE3Encoder::decode_subscription_delete(
const nlohmann::json& j)
const {
487 SubscriptionDelete del;
489 del.subscription_id = j.value(
"subscriptionId", 0u);
493SubscriptionResponse JsonE3Encoder::decode_subscription_response(
const nlohmann::json& j)
const {
494 SubscriptionResponse resp;
496 resp.dapp_identifier = j.value(
"dAppIdentifier", 0u);
497 std::string response_code_str = j.value(
"responseCode",
"negative");
499 if (j.contains(
"subscriptionId")) {
500 resp.subscription_id = j[
"subscriptionId"].get<uint32_t>();
503 auto read_ids = [&j](
const char* name,
const char* alias) -> std::optional<std::vector<uint32_t>> {
504 auto it = j.find(name);
505 if (it == j.end()) it = j.find(alias);
506 if (it == j.end())
return std::nullopt;
507 return it->get<std::vector<uint32_t>>();
509 resp.telemetry_identifier_list = read_ids(
"telemetryIdentifierList",
"telemetryGrantedList");
510 resp.control_identifier_list = read_ids(
"controlIdentifierList",
"controlGrantedList");
511 if (j.contains(
"ranFunctionIdentifier")) {
512 resp.ran_function_identifier = j[
"ranFunctionIdentifier"].get<uint32_t>();
514 if (j.contains(
"periodicity")) {
515 resp.periodicity = j[
"periodicity"].get<uint32_t>();
517 read_reason(j, resp);
521IndicationMessage JsonE3Encoder::decode_indication_message(
const nlohmann::json& j,
522 const std::string& raw_json)
const {
523 IndicationMessage msg;
525 msg.ran_function_identifier = j.value(
"ranFunctionIdentifier", 0u);
527 size_t obj_start = raw_json.find_first_not_of(
" \t\r\n");
528 auto span = (obj_start == std::string::npos)
530 : find_top_level_member_span(raw_json, obj_start,
"protocolData");
536 msg.protocol_data.assign(raw_json.begin() +
static_cast<long>(span->first),
537 raw_json.begin() +
static_cast<long>(span->second));
539 E3_LOG_DEBUG(LOG_TAG) <<
"protocolData byte-range scan missed; falling back to DOM dump "
540 "(ranFunctionIdentifier=" << msg.ran_function_identifier <<
")";
541 std::string dumped = j[
"protocolData"].dump();
542 msg.protocol_data.assign(dumped.begin(), dumped.end());
547DAppControlAction JsonE3Encoder::decode_dapp_control_action(
const nlohmann::json& j,
548 const std::string& raw_json)
const {
549 DAppControlAction action;
551 action.ran_function_identifier = j.value(
"ranFunctionIdentifier", 0u);
552 action.control_identifier = j.value(
"controlIdentifier", 0u);
553 action.sequence_id = j.value(
"sequenceId", 0u);
554 action.request_ack = j.value(
"requestAck",
false);
555 action.action_data = payload_member(j, raw_json,
"actionData");
559DAppReport JsonE3Encoder::decode_dapp_report(
const nlohmann::json& j,
560 const std::string& raw_json)
const {
563 report.ran_function_identifier = j.value(
"ranFunctionIdentifier", 0u);
564 report.sequence_id = j.value(
"sequenceId", 0u);
565 report.report_data = payload_member(j, raw_json,
"reportData");
569XAppControlAction JsonE3Encoder::decode_xapp_control_action(
const nlohmann::json& j,
570 const std::string& raw_json)
const {
571 XAppControlAction action;
573 action.ran_function_identifier = j.value(
"ranFunctionIdentifier", 0u);
574 action.sequence_id = j.value(
"sequenceId", 0u);
575 action.request_ack = j.value(
"requestAck",
false);
576 action.xapp_control_data = payload_member(j, raw_json,
"xAppControlData");
581MessageAck JsonE3Encoder::decode_message_ack(
const nlohmann::json& j)
const {
584 std::string response_code_str = j.value(
"responseCode",
"negative");
590ControlResponse JsonE3Encoder::decode_control_response(
const nlohmann::json& j,
591 const std::string& raw_json)
const {
592 ControlResponse resp;
594 resp.dapp_identifier = j.value(
"dAppIdentifier", 0u);
595 resp.ran_function_identifier = j.value(
"ranFunctionIdentifier", 0u);
596 resp.control_identifier = j.value(
"controlIdentifier", 0u);
597 std::string response_code_str = j.value(
"responseCode",
"negative");
599 read_reason(j, resp);
600 if (j.contains(
"controlOutcome")) {
601 std::vector<uint8_t> outcome = payload_member(j, raw_json,
"controlOutcome");
602 if (!outcome.empty()) resp.control_outcome = std::move(outcome);
608nlohmann::json JsonE3Encoder::encode_release_message(
const ReleaseMessage& msg)
const {
610 j[
"dAppIdentifier"] = msg.dapp_identifier;
614ReleaseMessage JsonE3Encoder::decode_release_message(
const nlohmann::json& j)
const {
634 std::optional<std::string> raw_protocol_data;
635 bool indication_payload_invalid =
false;
638 std::vector<std::pair<const char*, std::string>> raw_members;
641 std::visit([
this, &root, &raw_protocol_data, &indication_payload_invalid, &raw_members](
auto&& arg) {
642 using T = std::decay_t<
decltype(arg)>;
644 nlohmann::json fields;
645 if constexpr (std::is_same_v<T, SetupRequest>) {
646 fields = encode_setup_request(arg);
648 else if constexpr (std::is_same_v<T, SetupResponse>) {
649 fields = encode_setup_response(arg);
651 else if constexpr (std::is_same_v<T, SubscriptionRequest>) {
652 fields = encode_subscription_request(arg);
654 else if constexpr (std::is_same_v<T, SubscriptionDelete>) {
655 fields = encode_subscription_delete(arg);
657 else if constexpr (std::is_same_v<T, SubscriptionResponse>) {
658 fields = encode_subscription_response(arg);
660 else if constexpr (std::is_same_v<T, IndicationMessage>) {
661 auto encoded_fields = encode_indication_message(arg);
662 if (!encoded_fields) {
663 indication_payload_invalid =
true;
666 fields = *encoded_fields;
667 raw_protocol_data.emplace(arg.protocol_data.begin(), arg.protocol_data.end());
669 else if constexpr (std::is_same_v<T, DAppControlAction>) {
670 fields = encode_dapp_control_action(arg);
671 require_json_container(arg.action_data,
"actionData");
672 raw_members.emplace_back(
"actionData",
673 std::string(arg.action_data.begin(), arg.action_data.end()));
675 else if constexpr (std::is_same_v<T, DAppReport>) {
676 fields = encode_dapp_report(arg);
677 require_json_container(arg.report_data,
"reportData");
678 raw_members.emplace_back(
"reportData",
679 std::string(arg.report_data.begin(), arg.report_data.end()));
681 else if constexpr (std::is_same_v<T, XAppControlAction>) {
682 fields = encode_xapp_control_action(arg);
683 require_json_container(arg.xapp_control_data,
"xAppControlData");
684 raw_members.emplace_back(
"xAppControlData",
685 std::string(arg.xapp_control_data.begin(),
686 arg.xapp_control_data.end()));
688 else if constexpr (std::is_same_v<T, ReleaseMessage>) {
689 fields = encode_release_message(arg);
691 else if constexpr (std::is_same_v<T, MessageAck>) {
692 fields = encode_message_ack(arg);
694 else if constexpr (std::is_same_v<T, ControlResponse>) {
695 fields = encode_control_response(arg);
696 if (arg.control_outcome && !arg.control_outcome->empty()) {
697 require_json_container(*arg.control_outcome,
"controlOutcome");
698 raw_members.emplace_back(
"controlOutcome",
699 std::string(arg.control_outcome->begin(),
700 arg.control_outcome->end()));
706 if (indication_payload_invalid) {
707 return tl::unexpected(ErrorCode::ENCODE_FAILED);
710 std::string json_str = root.dump();
712 if (raw_protocol_data) {
719 size_t pos = json_str.find(
"\"ranFunctionIdentifier\"");
720 if (pos == std::string::npos) {
721 E3_LOG_ERROR(LOG_TAG) <<
"Internal error: indication envelope missing "
722 "ranFunctionIdentifier; cannot splice protocolData";
723 return tl::unexpected(ErrorCode::ENCODE_FAILED);
725 json_str.insert(pos,
"\"protocolData\":" + *raw_protocol_data +
",");
729 for (
const auto& [key, raw] : raw_members) {
733 json_str +=
"\":" + raw +
"}";
737 msg.
buffer.assign(json_str.begin(), json_str.end());
741 <<
" (" << msg.
size() <<
" bytes)";
745 catch (
const std::exception& e) {
746 E3_LOG_ERROR(LOG_TAG) <<
"JSON encode error: " << e.what();
747 return tl::unexpected(ErrorCode::ENCODE_FAILED);
756 if (data ==
nullptr || size == 0) {
758 return tl::unexpected(ErrorCode::DECODE_FAILED);
762 std::string json_str(
reinterpret_cast<const char*
>(data), size);
764 E3_LOG_TRACE(LOG_TAG) <<
"Decoding JSON (" << size <<
" bytes)";
766 nlohmann::json root = nlohmann::json::parse(json_str);
771 std::string pdu_type_str = root.value(
"type",
"");
772 auto pdu_type = string_to_pdu_type(pdu_type_str);
774 E3_LOG_ERROR(LOG_TAG) <<
"Unrecognized PDU type: " << pdu_type_str;
775 return tl::unexpected(ErrorCode::DECODE_FAILED);
777 pdu.
type = *pdu_type;
779 pdu.
timestamp = root.value(
"timestamp", 0ull);
781 if (root.contains(
"data")) {
782 E3_LOG_ERROR(LOG_TAG) <<
"Nested \"data\" wrapper is not supported; use flat format";
783 return tl::unexpected(ErrorCode::DECODE_FAILED);
789 pdu.
choice = decode_setup_request(root);
792 pdu.
choice = decode_setup_response(root);
795 pdu.
choice = decode_subscription_request(root);
798 pdu.
choice = decode_subscription_delete(root);
801 pdu.
choice = decode_subscription_response(root);
804 pdu.
choice = decode_indication_message(root, json_str);
807 pdu.
choice = decode_dapp_control_action(root, json_str);
810 pdu.
choice = decode_dapp_report(root, json_str);
813 pdu.
choice = decode_xapp_control_action(root, json_str);
816 pdu.
choice = decode_release_message(root);
819 pdu.
choice = decode_message_ack(root);
822 pdu.
choice = decode_control_response(root, json_str);
825 E3_LOG_ERROR(LOG_TAG) <<
"Unknown PDU type: " << pdu_type_str;
826 return tl::unexpected(ErrorCode::DECODE_FAILED);
832 catch (
const nlohmann::json::parse_error& e) {
833 E3_LOG_ERROR(LOG_TAG) <<
"JSON parse error: " << e.what();
834 return tl::unexpected(ErrorCode::DECODE_FAILED);
836 catch (
const std::exception& e) {
837 E3_LOG_ERROR(LOG_TAG) <<
"JSON decode error: " << e.what();
838 return tl::unexpected(ErrorCode::DECODE_FAILED);
EncodeResult< Pdu > decode(const EncodedMessage &encoded) override
Decode bytes to a PDU.
EncodeResult< EncodedMessage > encode(const Pdu &pdu) override
Encode a PDU to bytes.
JSON Encoder for E3AP PDUs.
Logging facility for libe3.
#define E3_LOG_TRACE(component)
#define E3_LOG_DEBUG(component)
#define E3_LOG_ERROR(component)
ErrorCode
Error codes returned by libe3 operations Use shared error-code list (see libe3/error_codes....
const char * cause_to_string(Cause cause) noexcept
Convert Cause to the name E3AP gives it in JSON and in logs.
ResponseCode
E3AP response codes.
@ NEGATIVE
Request rejected.
@ POSITIVE
Request accepted.
const char * pdu_type_to_string(PduType type) noexcept
Convert PduType to string representation.
@ MESSAGE_ACK
DEPRECATED TO BE REMOVED: libe3 no longer sends it, see CONTROL_RESPONSE.
@ JSON
JSON encoding (for development/debugging).
tl::expected< T, ErrorCode > EncodeResult
Result type for encoding/decoding operations.
Cause cause_from_string(const std::string &name) noexcept
Read a Cause from its E3AP name.
E3AP Control Response structure.
uint32_t request_id
Message id of the control this answers.
E3AP dApp Control Action structure.
uint32_t dapp_identifier
dApp that sends the control
E3AP dApp Report structure.
uint32_t dapp_identifier
dApp that sends the report
std::vector< uint8_t > buffer
Encoded data buffer.
const uint8_t * data() const noexcept
EncodingFormat format
Format used for encoding.
size_t size() const noexcept
E3AP Indication Message structure.
uint32_t dapp_identifier
dApp the indication is for
E3AP Message Acknowledgment structure.
uint32_t request_id
ID of the request being acknowledged.
Generic E3AP PDU structure.
PduType type
Which alternative of choice is set.
PduChoice choice
The message itself.
uint64_t timestamp
Producer timestamp, in nanoseconds since the Unix epoch.
uint32_t message_id
Unique message identifier.
E3AP Release Message structure.
uint32_t dapp_identifier
dApp identifier
E3AP Setup Request structure.
std::string e3ap_protocol_version
E3AP protocol version (e.g., "0.0.0"); 1..32 bytes over ASN.1.
E3AP Setup Response structure.
uint32_t request_id
ID of the corresponding SetupRequest.
E3AP Subscription Delete structure.
uint32_t dapp_identifier
dApp identifier
E3AP Subscription Request structure.
uint32_t dapp_identifier
dApp identifier
E3AP Subscription Response structure.
uint32_t request_id
ID of the corresponding SubscriptionRequest.
E3AP xApp Control Action structure.
uint32_t dapp_identifier
dApp the control is for