libe3 0.6.1
C++ library for E3AP RAN vendor integration
Loading...
Searching...
No Matches
c_api.h
Go to the documentation of this file.
1/*
2 * C API for libe3
3 * Minimal C-compatible wrappers to create an E3Agent and ServiceModel from C
4 *
5 * SPDX-FileCopyrightText: Copyright (c) 2026 Northeastern University
6 * SPDX-License-Identifier: Apache-2.0
7 */
8#ifndef LIBE3_C_API_H
9#define LIBE3_C_API_H
10
11#include <stdint.h>
12#include <stddef.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18#include "libe3/error_codes.h"
19
20/* Opaque handles */
23
24
25/* Callback prototypes for a C-backed ServiceModel */
27typedef void (*e3_sm_destroy_cb)(void* sm_context);
29typedef void (*e3_sm_stop_cb)(void* sm_context);
30typedef int (*e3_sm_is_running_cb)(void* sm_context); /* returns 0/1 */
31/**
32 * @brief Interval a C Service Model keeps between two indications of a subscription.
33 *
34 * Called when the RAN answers a subscription request, with the periodicity the
35 * subscription holds. Return the least time, in microseconds, the SM keeps between
36 * two indications. Return 0 when the SM keeps no interval or does not say: the
37 * response then carries no periodicity. A value above 60000000, the most the
38 * grammar carries, is treated as 0.
39 *
40 * The value is a floor taken when the response is built; the response is not
41 * sent again if the SM later speeds up.
42 *
43 * @param sm_context The `sm_context` of the descriptor
44 * @param requested_us Periodicity of the subscription in microseconds; 0 when
45 * the dApp asked for none or for one indication per event
46 * @return Microseconds between two indications, or 0 for "not reported"
47 */
48typedef uint32_t (*e3_sm_granted_periodicity_cb)(void* sm_context, uint32_t requested_us);
49
52 void* sm_context,
53 uint32_t request_message_id,
54 uint32_t dapp_id,
55 uint32_t ran_function_id,
56 uint32_t control_id,
57 const uint8_t* data,
58 size_t data_len,
59 /* Correlation id of the xApp procedure this control re-issues; 0 when the
60 dApp decided on its own and there is no procedure to report back to. */
61 uint32_t sequence_id
62);
63
64/* Callback for incoming dApp reports (dApp -> RAN). */
65typedef void (*e3_dapp_report_cb)(
66 uint32_t dapp_id,
67 uint32_t ran_function_id,
68 const uint8_t* report_data,
69 size_t report_data_len,
70 /* Correlation id the dApp assigned to this detection; 0 when unset. */
71 uint32_t sequence_id
72);
73
74/* Callback for incoming control responses (dApp -> RAN). Pointers are valid only
75 during the call. */
76typedef void (*e3_control_response_cb)(
77 uint32_t dapp_id,
78 uint32_t request_id, /* message id of the xApp control this answers */
79 uint32_t ran_function_id,
80 uint32_t control_id,
81 int response_code, /* 0 = positive, 1 = negative */
82 int cause, /* libe3's Cause value, 0 to 14, or -1 for none */
83 const char* detail, /* NUL-terminated UTF-8, or NULL for none */
84 const uint8_t* outcome, /* service-model content, or NULL for none */
85 size_t outcome_len
86);
87
88/** Callback when dApp status changes (connect, disconnect, subscribe, unsubscribe). */
89typedef void (*e3_dapp_status_changed_cb)(void);
90
91/**
92 * @brief Set callback for dApp status changes.
93 *
94 * Called when a dApp connects, disconnects, subscribes, or unsubscribes.
95 * Pass NULL as \p handler to clear the callback.
96 *
97 * @param agent Agent handle
98 * @param handler Callback invoked on each dApp status change
99 * @return \ref e3_error_t (see \ref libe3::ErrorCode; 0 == SUCCESS)
100 */
102 e3_agent_handle_t* agent,
104);
105
106/**
107 * @brief Descriptor describing a ServiceModel implemented in C.
108 *
109 * - `name`, `version` and `ran_function_id` identify the SM.
110 * - `telemetry_ids` and `control_ids` point to arrays that will be copied
111 * by the implementation; the caller may free them after creating the SM.
112 * - `ran_function_data` is required and is copied by the implementation.
113 * - Callbacks are invoked by the C++ adapter and receive `user_data`.
114 */
115typedef struct {
116 const char* name; ///< Service Model name (null-terminated string)
117 uint32_t version; ///< Service Model version
118 uint32_t ran_function_id; ///< RAN function ID for this SM
119
120 const uint32_t* telemetry_ids; ///< Array of supported telemetry IDs (copied by library)
121 size_t telemetry_ids_len; ///< Number of telemetry IDs
122
123 const uint32_t* control_ids; ///< Array of supported control IDs (copied by library)
124 size_t control_ids_len; ///< Number of control IDs
125
126 /* Opaque RAN function data (E3SM-encoded, advertised in the setup response).
127 * Required, not optional: E3AP declares ranFunctionData as a mandatory
128 * OCTET STRING (SIZE (1..262144)), limited to 32768 bytes, so registration is rejected if these
129 * fields describe an empty or oversized buffer. */
130 const uint8_t* ran_function_data; ///< Opaque RAN function data (must be non-NULL)
131 size_t ran_function_data_len; ///< Length in bytes; must be 1..32768
132
133 /* Callbacks */
134 e3_sm_init_cb sm_init; ///< Called on SM registration
135 e3_sm_destroy_cb sm_destroy; ///< Called on SM destruction
136 e3_sm_start_cb sm_start; ///< Called when SM should start
137 e3_sm_stop_cb sm_stop; ///< Called when SM should stop
138 e3_sm_is_running_cb sm_is_running; ///< Called to query running state
139 e3_sm_process_control_cb sm_process_control; ///< Called to process control actions
140
141 void* sm_context; ///< Opaque pointer passed to all callbacks
143
144/* Create/destroy a C-backed ServiceModel */
145/**
146 * @brief Create a ServiceModel implementation backed by C callbacks.
147 *
148 * The returned pointer owns a C++ `ServiceModel` instance. The caller
149 * retains ownership until the model is registered with an agent via
150 * `e3_agent_register_sm`, at which point ownership is transferred to the
151 * agent and `e3_service_model_destroy` will no longer free the object.
152 *
153 * @param desc Descriptor containing metadata and callback function pointers
154 * @return e3_service_model_handle_t* on success, NULL on allocation error
155 */
157 const e3_c_service_model_desc_t* desc
158);
159
160/**
161 * @brief Let a C-backed ServiceModel report the interval it keeps between indications.
162 *
163 * Without it the subscription response carries no periodicity ("not reported").
164 * Call it between e3_service_model_create_from_c() and e3_agent_register_sm();
165 * once the model is registered the agent owns it and this fails.
166 *
167 * @param sm Handle returned by e3_service_model_create_from_c()
168 * @param cb Callback, or NULL to clear it
169 * @return ErrorCode::SUCCESS (0), or ErrorCode::INVALID_PARAM if \p sm is NULL
170 * or already registered
171 */
175);
176
177/**
178 * @brief Destroy a C-backed ServiceModel handle.
179 *
180 * If the model has been registered with an agent (ownership transferred),
181 * this function is a no-op and the agent takes responsibility for cleanup.
182 */
184
185/**
186 * @brief Emit an indication message from a ServiceModel to the outbound queue.
187 *
188 * This is intended for C-backed ServiceModels. The message is forwarded by
189 * the internal publisher path.
190 */
193 uint32_t dapp_id,
194 uint32_t ran_function_id,
195 const uint8_t* data,
196 size_t data_len
197);
198
199/**
200 * @brief Emit a message acknowledgment from a ServiceModel.
201 *
202 * DEPRECATED TO BE REMOVED. Answer a control with e3_service_model_emit_control_response.
203 */
206 uint32_t request_id,
207 int response_code
208);
209
210/**
211 * @brief Answer a dApp control from a ServiceModel.
212 *
213 * Call it once per control, when the outcome is known: from the process-control
214 * callback or later, from any thread. A ControlResponse goes out only when the dApp
215 * asked for one; the RAN function and the control identifier come from the control.
216 *
217 * @param sm Service Model handle
218 * @param dapp_id dApp that sent the control (the `dapp_id` the process-control callback received)
219 * @param request_id Message id of the control (the callback's `request_message_id`)
220 * @param response_code 0 = positive (applied), 1 = negative
221 * @param cause Why the control was refused (negative only): the value of libe3's Cause, 0 to 14, or -1 for none
222 * @param detail UTF-8 text for the cause, up to 512 bytes, or NULL for none
223 * @param outcome What the Service Model reports about the control, or NULL for none
224 * @param outcome_len Length of \p outcome in bytes, at most 32768
225 * @return \ref e3_error_t (0 == SUCCESS). NOT_FOUND when no answer is owed: the dApp did not ask for one, or
226 * the control was answered already. INVALID_PARAM for a NULL handle or an outcome that is too long
227 */
230 uint32_t dapp_id,
231 uint32_t request_id,
232 int response_code,
233 int cause,
234 const char* detail,
235 const uint8_t* outcome,
236 size_t outcome_len
237);
238
239/**
240 * @brief Configuration for creating an E3Agent from C.
241 *
242 * All string pointers are copied by the library; the caller may free them
243 * after the call. Use NULL for optional strings to keep library defaults.
244 *
245 * Enum values: link_layer: 0=ZMQ, 1=POSIX. transport_layer: 0=SCTP, 1=TCP, 2=IPC.
246 * encoding: 0=ASN1, 1=JSON. Use -1 for link_layer, transport_layer, encoding, log_level
247 * to keep defaults. Use 0 for setup_port, subscriber_port, publisher_port to keep defaults.
248 * Set `set_dapp_idle_timeout` to apply `dapp_idle_timeout_s`; a zeroed struct keeps the default.
249 */
250typedef struct {
251 const char* ran_identifier; ///< RAN identifier; NULL keeps the default
252 int link_layer; ///< 0=ZMQ, 1=POSIX, -1=default
253 int transport_layer; ///< 0=SCTP, 1=TCP, 2=IPC, -1=default
254 uint16_t setup_port; ///< Port of the setup channel (SCTP and TCP); 0 keeps the default
255 uint16_t subscriber_port; ///< Port of the subscriber channel (SCTP and TCP); 0 keeps the default
256 uint16_t publisher_port; ///< Port of the publisher channel (SCTP and TCP); 0 keeps the default
257 const char* setup_endpoint; ///< Endpoint of the setup channel; NULL keeps the default
258 const char* subscriber_endpoint; ///< Endpoint of the subscriber channel; NULL keeps the default
259 const char* publisher_endpoint; ///< Endpoint of the publisher channel; NULL keeps the default
260 int encoding; ///< 0=ASN1, 1=JSON, 2=PROTOBUF, -1=default
261 size_t io_threads; ///< Number of I/O threads; 0=default
262 int log_level; ///< Logging level; -1=default
263 const char* log_path; ///< Log file; NULL=auto (`/tmp/e3_ROLE[_ID]_EUID.log`)
264 /* A flag rather than a sentinel: core 0 is a legitimate target. */
265 int pin_io_threads; ///< Pin the I/O threads when non-zero; 0=no pinning
266 int io_thread_affinity; ///< Logical core to pin to; Linux only, best-effort
267 /* A flag too, because 0 is a legitimate timeout: it never removes a dApp. */
268 int set_dapp_idle_timeout; ///< Apply `dapp_idle_timeout_s` when non-zero; 0=keep the library default (1800 s)
269 uint32_t dapp_idle_timeout_s; ///< Seconds without a message from a dApp before the RAN releases and removes it; 0=never
271
272/**
273 * @brief Create/destroy an `E3Agent` handle
274 */
275/**
276 * @brief Create a new `E3Agent` with a default configuration.
277 *
278 * The returned handle must be destroyed with `e3_agent_destroy` when no
279 * longer needed.
280 *
281 * @return e3_agent_handle_t* on success, NULL on allocation error
282 */
284
285/**
286 * @brief Create a new `E3Agent` with the given configuration.
287 *
288 * If \p config is NULL, behaves like \ref e3_agent_create_default.
289 * String fields in \p config are copied; the caller may free them after the call.
290 * Use 0 or NULL for fields to keep library defaults (e.g. setup_port 0 → 9990).
291 *
292 * @param config Configuration (ports, endpoints, link/transport layer, etc.)
293 * @return e3_agent_handle_t* on success, NULL on allocation error
294 */
296
297/**
298 * @brief Destroy an `E3Agent` handle.
299 *
300 * This will free the underlying resources. If the agent is currently
301 * running, callers should stop it with `e3_agent_stop` first.
302 */
304
305/* Agent operations */
306/**
307 * @brief Initialize the agent.
308 *
309 * Prepares internal resources; must be called before \ref e3_agent_start.
310 * Returns a \ref e3_error_t (see \ref libe3::ErrorCode; 0 == SUCCESS).
311 */
313
314/**
315 * @brief Start the agent processing threads and accept dApp connections.
316 *
317 * Returns a \ref e3_error_t (see \ref libe3::ErrorCode; 0 == SUCCESS).
318 */
320
321/**
322 * @brief Stop the agent and release runtime resources.
323 *
324 * Safe to call even if the agent is not running.
325 * Returns nothing; errors are ignored.
326 */
328
329/* Query agent state */
330/**
331 * @brief Get the agent state as an integer matching `libe3::AgentState`.
332 *
333 * Useful for callers in C to inspect agent status. Returns an `int` with
334 * the enum value; `AgentState::ERROR` is returned on invalid handle.
335 */
337
338/**
339 * @brief Query whether the agent is currently running.
340 *
341 * @return 1 if running, 0 otherwise (or on invalid handle)
342 */
344
345/**
346 * @brief Set callback for incoming dApp reports (dApp -> RAN).
347 *
348 * Pass NULL as \p handler to clear the callback.
349 *
350 * @param agent Agent handle
351 * @param handler Callback invoked for each incoming dApp report
352 * @return \ref e3_error_t (see \ref libe3::ErrorCode; 0 == SUCCESS)
353 */
355 e3_agent_handle_t* agent,
356 e3_dapp_report_cb handler
357);
358
359/**
360 * @brief Send a message acknowledgment (e.g. ack a control/request from dApp).
361 *
362 * DEPRECATED TO BE REMOVED. A libe3 RAN does not read it, and a dApp does not need it.
363 *
364 * @param agent Agent handle
365 * @param request_id ID of the request being acknowledged
366 * @param response_code 0 = positive (success), 1 = negative (failure)
367 * @return \ref e3_error_t (see \ref libe3::ErrorCode; 0 == SUCCESS)
368 */
370 e3_agent_handle_t* agent,
371 uint32_t request_id,
372 int response_code
373);
374
375/**
376 * @brief Set callback for incoming control responses (dApp -> RAN): a dApp's answer
377 * to an xApp control that asked for one.
378 *
379 * Pass NULL as \p handler to clear the callback.
380 *
381 * @param agent Agent handle
382 * @param handler Callback invoked for each incoming response
383 * @return \ref e3_error_t (see \ref libe3::ErrorCode; 0 == SUCCESS)
384 */
386 e3_agent_handle_t* agent,
388);
389
390/* Helpers to return arrays allocated by the library. Caller must free with
391 * `e3_agent_free_uint32_array` when finished.
392 */
393/**
394 * @brief Return a newly-allocated array of available RAN function IDs.
395 *
396 * The returned array is allocated with `malloc` and the caller must free
397 * it with `e3_agent_free_uint32_array`. The number of elements is written
398 * to `out_len` if non-NULL. Returns NULL and sets `out_len` to 0 if there
399 * are no entries or the handle is invalid.
400 */
401uint32_t* e3_agent_get_available_ran_functions(e3_agent_handle_t* agent, size_t* out_len);
402
403/**
404 * @brief Return a newly-allocated array of registered dApp IDs.
405 *
406 * See `e3_agent_get_available_ran_functions` for ownership semantics.
407 */
408uint32_t* e3_agent_get_registered_dapps(e3_agent_handle_t* agent, size_t* out_len);
409
410/**
411 * @brief Return a newly-allocated array of RAN function IDs subscribed by a dApp.
412 *
413 * @param agent Agent handle
414 * @param dapp_id dApp identifier to query
415 * @param out_len receives the number of elements (set to 0 on error/empty)
416 */
417uint32_t* e3_agent_get_dapp_subscriptions(e3_agent_handle_t* agent, uint32_t dapp_id, size_t* out_len);
418
419/**
420 * @brief Return a newly-allocated array of dApp IDs subscribed to a RAN function.
421 *
422 * @param agent Agent handle
423 * @param ran_function_id RAN function identifier to query
424 * @param out_len receives the number of elements (set to 0 on error/empty)
425 */
426uint32_t* e3_agent_get_ran_function_subscribers(e3_agent_handle_t* agent, uint32_t ran_function_id, size_t* out_len);
427
428/**
429 * @brief Return a newly-allocated array of RAN function IDs that currently have
430 * at least one subscriber (RAN role).
431 *
432 * See `e3_agent_get_available_ran_functions` for ownership semantics.
433 */
434uint32_t* e3_agent_get_active_ran_functions(e3_agent_handle_t* agent, size_t* out_len);
435
436/**
437 * @brief Get the reporting periodicity a dApp requested for a RAN function.
438 *
439 * @return periodicity in microseconds, 0 if not set or subscription not found
440 */
442 e3_agent_handle_t* agent,
443 uint32_t dapp_id,
444 uint32_t ran_function_id
445);
446
447/**
448 * @brief Get the telemetry IDs a dApp requested for a RAN function.
449 *
450 * Caller must free the returned array with e3_agent_free_uint32_array().
451 *
452 * @param agent Agent handle
453 * @param dapp_id dApp identifier to query
454 * @param ran_function_id RAN function identifier to query
455 * @param out_len receives the number of elements (set to 0 on error/empty)
456 * @return newly-allocated array, or NULL if empty/error
457 */
459 e3_agent_handle_t* agent,
460 uint32_t dapp_id,
461 uint32_t ran_function_id,
462 size_t* out_len
463);
464
465/**
466 * @brief Get the control IDs a dApp requested for a RAN function.
467 *
468 * Caller must free the returned array with e3_agent_free_uint32_array().
469 *
470 * @param agent Agent handle
471 * @param dapp_id dApp identifier to query
472 * @param ran_function_id RAN function identifier to query
473 * @param out_len receives the number of elements (set to 0 on error/empty)
474 * @return newly-allocated array, or NULL if empty/error
475 */
477 e3_agent_handle_t* agent,
478 uint32_t dapp_id,
479 uint32_t ran_function_id,
480 size_t* out_len
481);
482
483/**
484 * @brief Free an array previously returned by the e3_agent_get_* helpers.
485 */
486void e3_agent_free_uint32_array(uint32_t* arr);
487
488/**
489 * @brief Send an indication message to a specific dApp.
490 *
491 * @param agent Agent handle
492 * @param dapp_id Target dApp identifier
493 * @param ran_function_id RAN function identifier
494 * @param data Pointer to E3SM-encoded payload (may be NULL)
495 * @param data_len Length of payload in bytes
496 * @return \ref e3_error_t (see \ref libe3::ErrorCode; 0 == SUCCESS)
497 */
499 e3_agent_handle_t* agent,
500 uint32_t dapp_id,
501 uint32_t ran_function_id,
502 const uint8_t* data,
503 size_t data_len
504);
505
506/**
507 * @brief Send an xApp control action to a specific dApp (e.g. from E2/SM).
508 *
509 * @param agent Agent handle
510 * @param dapp_id Target dApp identifier
511 * @param ran_function_id RAN function identifier
512 * @param control_data Pointer to E3SM-encoded control payload (may be NULL if data_len is 0)
513 * @param control_data_len Length of payload in bytes
514 * @param sequence_id Correlation id from the E2SM-DAPP control header; the dApp
515 * carries it back on the control it re-issues, which is how the RAN
516 * matches the applied control to the xApp procedure that asked for it.
517 * @param out_message_id When non-NULL, receives the message id of the control on success:
518 * the `request_id` of the ControlResponse that answers it.
519 * @param request_ack Non-zero to ask the dApp for a ControlResponse; it reaches the
520 * callback of \ref e3_agent_set_control_response_handler.
521 * @return \ref e3_error_t (see \ref libe3::ErrorCode; 0 == SUCCESS)
522 */
524 e3_agent_handle_t* agent,
525 uint32_t dapp_id,
526 uint32_t ran_function_id,
527 const uint8_t* control_data,
528 size_t control_data_len,
529 uint32_t sequence_id,
530 uint32_t* out_message_id,
531 int request_ack
532);
533
534/* Simple stats */
535/**
536 * @brief Number of registered dApps known to the agent.
537 */
539
540/**
541 * @brief Total number of active subscriptions tracked by the agent.
542 */
544
545/**
546 * @brief Register a `ServiceModel` implementation with the agent.
547 *
548 * Ownership of `sm` is transferred to the agent on success and callers
549 * must not free the handle after a successful call. On failure the caller
550 * retains ownership and should call `e3_service_model_destroy`.
551 *
552 * Fails with `E3_INVALID_PARAM` if the descriptor the handle was built
553 * from carried no `ran_function_data`, or more than 32768 bytes of it, and with
554 * `E3_SM_ALREADY_REGISTERED` if another SM already holds the same RAN
555 * function id. It also fails with `E3_INVALID_PARAM` if the SM lists more than
556 * 256 telemetry or control ids, or 64 RAN functions are already registered.
557 *
558 * @return e3_error_t ErrorCode value (0 == success)
559 */
561 e3_agent_handle_t* agent,
563);
564
565#ifdef __cplusplus
566}
567#endif
568
569#endif // LIBE3_C_API_H
void(* e3_dapp_status_changed_cb)(void)
Definition c_api.h:89
void e3_agent_free_uint32_array(uint32_t *arr)
Free an array previously returned by the e3_agent_get_* helpers.
Definition c_api.cpp:439
e3_error_t e3_agent_register_sm(e3_agent_handle_t *agent, e3_service_model_handle_t *sm)
Register a ServiceModel implementation with the agent.
Definition c_api.cpp:305
struct e3_agent_handle_s e3_agent_handle_t
Definition c_api.h:21
e3_error_t e3_service_model_set_granted_periodicity_cb(e3_service_model_handle_t *sm, e3_sm_granted_periodicity_cb cb)
Let a C-backed ServiceModel report the interval it keeps between indications.
Definition c_api.cpp:164
e3_service_model_handle_t * e3_service_model_create_from_c(const e3_c_service_model_desc_t *desc)
Create a ServiceModel implementation backed by C callbacks.
Definition c_api.cpp:155
void(* e3_dapp_report_cb)(uint32_t dapp_id, uint32_t ran_function_id, const uint8_t *report_data, size_t report_data_len, uint32_t sequence_id)
Definition c_api.h:65
uint32_t e3_agent_get_subscription_periodicity(e3_agent_handle_t *agent, uint32_t dapp_id, uint32_t ran_function_id)
Get the reporting periodicity a dApp requested for a RAN function.
Definition c_api.cpp:408
e3_error_t e3_agent_set_control_response_handler(e3_agent_handle_t *agent, e3_control_response_cb handler)
Set callback for incoming control responses (dApp -> RAN): a dApp's answer to an xApp control that as...
Definition c_api.cpp:484
uint32_t * e3_agent_get_ran_function_subscribers(e3_agent_handle_t *agent, uint32_t ran_function_id, size_t *out_len)
Return a newly-allocated array of dApp IDs subscribed to a RAN function.
Definition c_api.cpp:396
void e3_agent_destroy(e3_agent_handle_t *agent)
Destroy an E3Agent handle.
Definition c_api.cpp:285
e3_error_t(* e3_sm_process_control_cb)(e3_service_model_handle_t *sm_handle, void *sm_context, uint32_t request_message_id, uint32_t dapp_id, uint32_t ran_function_id, uint32_t control_id, const uint8_t *data, size_t data_len, uint32_t sequence_id)
Definition c_api.h:50
void(* e3_sm_destroy_cb)(void *sm_context)
Definition c_api.h:27
void e3_agent_stop(e3_agent_handle_t *agent)
Stop the agent and release runtime resources.
Definition c_api.cpp:300
size_t e3_agent_subscription_count(e3_agent_handle_t *agent)
Total number of active subscriptions tracked by the agent.
Definition c_api.cpp:522
e3_error_t e3_agent_set_dapp_report_handler(e3_agent_handle_t *agent, e3_dapp_report_cb handler)
Set callback for incoming dApp reports (dApp -> RAN).
Definition c_api.cpp:341
e3_error_t(* e3_sm_start_cb)(void *sm_context)
Definition c_api.h:28
void(* e3_sm_stop_cb)(void *sm_context)
Definition c_api.h:29
e3_agent_handle_t * e3_agent_create_default()
Create/destroy an E3Agent handle.
Definition c_api.cpp:246
e3_error_t e3_agent_send_message_ack(e3_agent_handle_t *agent, uint32_t request_id, int response_code)
Send a message acknowledgment (e.g. ack a control/request from dApp).
Definition c_api.cpp:474
int e3_agent_is_running(e3_agent_handle_t *agent)
Query whether the agent is currently running.
Definition c_api.cpp:336
uint32_t * e3_agent_get_registered_dapps(e3_agent_handle_t *agent, size_t *out_len)
Return a newly-allocated array of registered dApp IDs.
Definition c_api.cpp:384
e3_error_t e3_service_model_emit_control_response(e3_service_model_handle_t *sm, uint32_t dapp_id, uint32_t request_id, int response_code, int cause, const char *detail, const uint8_t *outcome, size_t outcome_len)
Answer a dApp control from a ServiceModel.
Definition c_api.cpp:224
e3_error_t e3_agent_send_xapp_control(e3_agent_handle_t *agent, uint32_t dapp_id, uint32_t ran_function_id, const uint8_t *control_data, size_t control_data_len, uint32_t sequence_id, uint32_t *out_message_id, int request_ack)
Send an xApp control action to a specific dApp (e.g. from E2/SM).
Definition c_api.cpp:456
e3_error_t e3_service_model_emit_message_ack(e3_service_model_handle_t *sm, uint32_t request_id, int response_code)
Emit a message acknowledgment from a ServiceModel.
Definition c_api.cpp:208
int(* e3_sm_is_running_cb)(void *sm_context)
Definition c_api.h:30
int e3_agent_get_state(e3_agent_handle_t *agent)
Get the agent state as an integer matching libe3::AgentState.
Definition c_api.cpp:331
e3_error_t e3_agent_start(e3_agent_handle_t *agent)
Start the agent processing threads and accept dApp connections.
Definition c_api.cpp:295
void e3_service_model_destroy(e3_service_model_handle_t *sm)
Destroy a C-backed ServiceModel handle.
Definition c_api.cpp:174
e3_agent_handle_t * e3_agent_create_with_config(const e3_config_t *config)
Create a new E3Agent with the given configuration.
Definition c_api.cpp:250
uint32_t(* e3_sm_granted_periodicity_cb)(void *sm_context, uint32_t requested_us)
Interval a C Service Model keeps between two indications of a subscription.
Definition c_api.h:48
e3_error_t e3_agent_send_indication(e3_agent_handle_t *agent, uint32_t dapp_id, uint32_t ran_function_id, const uint8_t *data, size_t data_len)
Send an indication message to a specific dApp.
Definition c_api.cpp:443
e3_error_t e3_agent_init(e3_agent_handle_t *agent)
Initialize the agent.
Definition c_api.cpp:290
uint32_t * e3_agent_get_active_ran_functions(e3_agent_handle_t *agent, size_t *out_len)
Return a newly-allocated array of RAN function IDs that currently have at least one subscriber (RAN r...
Definition c_api.cpp:402
uint32_t * e3_agent_get_dapp_subscriptions(e3_agent_handle_t *agent, uint32_t dapp_id, size_t *out_len)
Return a newly-allocated array of RAN function IDs subscribed by a dApp.
Definition c_api.cpp:390
struct e3_service_model_handle_s e3_service_model_handle_t
Definition c_api.h:22
e3_error_t(* e3_sm_init_cb)(void *sm_context)
Definition c_api.h:26
uint32_t * e3_agent_get_subscription_control_ids(e3_agent_handle_t *agent, uint32_t dapp_id, uint32_t ran_function_id, size_t *out_len)
Get the control IDs a dApp requested for a RAN function.
Definition c_api.cpp:428
e3_error_t e3_service_model_emit_indication(e3_service_model_handle_t *sm, uint32_t dapp_id, uint32_t ran_function_id, const uint8_t *data, size_t data_len)
Emit an indication message from a ServiceModel to the outbound queue.
Definition c_api.cpp:181
void(* e3_control_response_cb)(uint32_t dapp_id, uint32_t request_id, uint32_t ran_function_id, uint32_t control_id, int response_code, int cause, const char *detail, const uint8_t *outcome, size_t outcome_len)
Definition c_api.h:76
size_t e3_agent_dapp_count(e3_agent_handle_t *agent)
Number of registered dApps known to the agent.
Definition c_api.cpp:517
uint32_t * e3_agent_get_subscription_telemetry_ids(e3_agent_handle_t *agent, uint32_t dapp_id, uint32_t ran_function_id, size_t *out_len)
Get the telemetry IDs a dApp requested for a RAN function.
Definition c_api.cpp:417
uint32_t * e3_agent_get_available_ran_functions(e3_agent_handle_t *agent, size_t *out_len)
Return a newly-allocated array of available RAN function IDs.
Definition c_api.cpp:378
e3_error_t e3_agent_set_dapp_status_changed_handler(e3_agent_handle_t *agent, e3_dapp_status_changed_cb handler)
Set callback for dApp status changes.
Definition c_api.cpp:536
libe3 error codes - shared C/C++ definitions
int e3_error_t
C error type alias.
What e3_agent_handle_t points to: the agent a C caller holds.
Definition c_api.cpp:27
Descriptor describing a ServiceModel implemented in C.
Definition c_api.h:115
const uint32_t * control_ids
Array of supported control IDs (copied by library).
Definition c_api.h:123
uint32_t version
Service Model version.
Definition c_api.h:117
e3_sm_stop_cb sm_stop
Called when SM should stop.
Definition c_api.h:137
const uint8_t * ran_function_data
Opaque RAN function data (must be non-NULL).
Definition c_api.h:130
const uint32_t * telemetry_ids
Array of supported telemetry IDs (copied by library).
Definition c_api.h:120
size_t control_ids_len
Number of control IDs.
Definition c_api.h:124
const char * name
Service Model name (null-terminated string).
Definition c_api.h:116
size_t telemetry_ids_len
Number of telemetry IDs.
Definition c_api.h:121
e3_sm_start_cb sm_start
Called when SM should start.
Definition c_api.h:136
e3_sm_init_cb sm_init
Called on SM registration.
Definition c_api.h:134
e3_sm_is_running_cb sm_is_running
Called to query running state.
Definition c_api.h:138
void * sm_context
Opaque pointer passed to all callbacks.
Definition c_api.h:141
size_t ran_function_data_len
Length in bytes; must be 1..32768.
Definition c_api.h:131
e3_sm_process_control_cb sm_process_control
Called to process control actions.
Definition c_api.h:139
uint32_t ran_function_id
RAN function ID for this SM.
Definition c_api.h:118
e3_sm_destroy_cb sm_destroy
Called on SM destruction.
Definition c_api.h:135
Configuration for creating an E3Agent from C.
Definition c_api.h:250
int encoding
0=ASN1, 1=JSON, 2=PROTOBUF, -1=default
Definition c_api.h:260
int log_level
Logging level; -1=default.
Definition c_api.h:262
uint16_t subscriber_port
Port of the subscriber channel (SCTP and TCP); 0 keeps the default.
Definition c_api.h:255
int pin_io_threads
Pin the I/O threads when non-zero; 0=no pinning.
Definition c_api.h:265
const char * setup_endpoint
Endpoint of the setup channel; NULL keeps the default.
Definition c_api.h:257
int link_layer
0=ZMQ, 1=POSIX, -1=default
Definition c_api.h:252
const char * log_path
Log file; NULL=auto (/tmp/e3_ROLE[_ID]_EUID.log).
Definition c_api.h:263
size_t io_threads
Number of I/O threads; 0=default.
Definition c_api.h:261
uint16_t setup_port
Port of the setup channel (SCTP and TCP); 0 keeps the default.
Definition c_api.h:254
uint16_t publisher_port
Port of the publisher channel (SCTP and TCP); 0 keeps the default.
Definition c_api.h:256
int io_thread_affinity
Logical core to pin to; Linux only, best-effort.
Definition c_api.h:266
const char * ran_identifier
RAN identifier; NULL keeps the default.
Definition c_api.h:251
const char * subscriber_endpoint
Endpoint of the subscriber channel; NULL keeps the default.
Definition c_api.h:258
int transport_layer
0=SCTP, 1=TCP, 2=IPC, -1=default
Definition c_api.h:253
uint32_t dapp_idle_timeout_s
Seconds without a message from a dApp before the RAN releases and removes it; 0=never.
Definition c_api.h:269
const char * publisher_endpoint
Endpoint of the publisher channel; NULL keeps the default.
Definition c_api.h:259
int set_dapp_idle_timeout
Apply dapp_idle_timeout_s when non-zero; 0=keep the library default (1800 s).
Definition c_api.h:268
What e3_service_model_handle_t points to: a ServiceModel that calls back into C.
Definition c_api.cpp:32
void * sm_context
Passed to every callback.
Definition c_api.cpp:49
uint32_t ran_function_id() const override
Get RAN function ID for this SM.
Definition c_api.cpp:84