nros rmw-cffi
C vtable for plugging a third-party RMW backend into nros
Loading...
Searching...
No Matches
rmw_entity.h
Go to the documentation of this file.
1#ifndef NROS_RMW_ENTITY_H
2#define NROS_RMW_ENTITY_H
3
4#include <stdbool.h>
5#include <stdint.h>
6#include <stddef.h>
7#include "nros/rmw_ret.h" /* the two pure functions below return rmw_ret_t */
8
39/* ------------------------------------------------------------------ */
40/* QoS profile — full DDS shape (matches `rmw_qos_profile_t`) */
41/* ------------------------------------------------------------------ */
42
43/* Policy values carry UPSTREAM's numbering — phase-376 W5/B2.
44 *
45 * They did not until 2026-08-24, and the disagreement was not academic. Ours
46 * were a dense 0/1 pair per policy, which put a DIFFERENT meaning on the same
47 * integer:
48 *
49 * value | upstream | ours (before)
50 * ------|-----------------------------------|-------------------
51 * 0 | *_SYSTEM_DEFAULT | BEST_EFFORT / VOLATILE / KEEP_LAST
52 * 1 | RELIABLE / TRANSIENT_LOCAL / KEEP_LAST | RELIABLE / TRANSIENT_LOCAL / KEEP_ALL
53 *
54 * so `HISTORY == 1` meant KEEP_LAST to upstream and KEEP_ALL to us — the two
55 * opposite answers to the question. Liveliness was worse: MANUAL_BY_NODE and
56 * MANUAL_BY_TOPIC were SWAPPED (2 and 3).
57 *
58 * These values cross the ABI. `rmw_qos_profile_check_compatible` is a name
59 * upstream owns and we export, and the cyclonedds backend translates this
60 * struct into real DDS QoS that a ROS peer matches against. A caller reasoning
61 * in upstream's vocabulary got silently wrong policies. Same argument as W3.d
62 * step B for the return codes: where a value crosses the boundary, upstream's
63 * numbering is the only one that cannot be wrong.
64 *
65 * The names keep the `NROS_RMW_` prefix — as the return codes do — because the
66 * set is ours to extend, not upstream's to define.
67 */
68
70#define NROS_RMW_RELIABILITY_SYSTEM_DEFAULT 0
71#define NROS_RMW_RELIABILITY_RELIABLE 1
72#define NROS_RMW_RELIABILITY_BEST_EFFORT 2
75#define NROS_RMW_RELIABILITY_UNKNOWN 3
76
78#define NROS_RMW_DURABILITY_SYSTEM_DEFAULT 0
79#define NROS_RMW_DURABILITY_TRANSIENT_LOCAL 1
80#define NROS_RMW_DURABILITY_VOLATILE 2
81#define NROS_RMW_DURABILITY_UNKNOWN 3
82
84#define NROS_RMW_HISTORY_SYSTEM_DEFAULT 0
85#define NROS_RMW_HISTORY_KEEP_LAST 1
86#define NROS_RMW_HISTORY_KEEP_ALL 2
87#define NROS_RMW_HISTORY_UNKNOWN 3
88
96
98typedef int64_t rmw_time_point_value_t;
99
102#define RMW_MESSAGE_INFO_SEQUENCE_NUMBER_UNSUPPORTED UINT64_MAX
103
105#define RMW_GID_STORAGE_SIZE 24u
106
133typedef struct rmw_byte_span_t {
134 const uint8_t *data;
135 size_t len;
137
155typedef struct rmw_mut_byte_span_t {
156 uint8_t *data;
158 size_t capacity;
160 size_t len;
162
198
211
219
220
255
276
318typedef struct rmw_qos_profile_t {
319 /* ---- 8-byte core, layout-equivalent to the original subset ---- */
320 uint8_t reliability;
321 uint8_t durability;
322 uint8_t history;
324 uint16_t depth;
325 uint16_t _reserved0;
327 /* ---- 16-byte extension (Phase 109) ---- */
331 uint32_t deadline_ms;
332
335 uint32_t lifespan_ms;
336
340
348 uint8_t _reserved1[3];
350
351
352/* ====================================================================
353 * Phase 376 W4 — the two PURE functions.
354 *
355 * Plain exported C functions, deliberately NOT vtable slots, and the reason is
356 * the campaign's own rule read the other way round: a vtable slot is the
357 * mechanism for letting backends DIFFER, and these two must not. Both compute
358 * over types this header defines; if two backends disagreed about whether a QoS
359 * pair is compatible, or whether two gids name the same entity, that is a
360 * DEFECT with as many places to fix it as there are backends.
361 *
362 * Three supporting reasons:
363 *
364 * - The useful call sites have no vtable to dispatch through. QoS
365 * compatibility is wanted at `create_*` time (that is what produces
366 * `NROS_RMW_RET_INCOMPATIBLE_QOS`), in codegen'd validation, and in host
367 * tooling with no session. Neither function takes an entity, so a slot would
368 * force a caller to invent a session — and neither could be called BEFORE a
369 * backend registers, which is exactly when create-time validation runs.
370 *
371 * - Upstream is not evidence for a slot. `rmw_qos_profile_check_compatible`
372 * lives in `rmw/qos_profiles.h` and is defined by librmw ITSELF; it appears
373 * in the implementation contract only because each `librmw_*_cpp.so`
374 * statically links librmw and re-exports it. That is plugin packaging, not
375 * semantics, and we load no plugin.
376 *
377 * - Precedent: `nros_rmw_cffi_register_named` and friends are declared here
378 * and defined once in Rust with `#[no_mangle]`, so `nros-rmw-abi` stays a
379 * header-only INTERFACE target — no new compiled TU, no new link edge.
380 * (`static inline` was the alternative and is worse: bindgen does not emit
381 * it, so RFC-0054 would force a SECOND Rust implementation, which is the
382 * first reason again.)
383 * ==================================================================== */
384
402
413
423 rmw_qos_profile_t offered, rmw_qos_profile_t requested,
424 rmw_qos_compatibility_type_t *compatibility, uint32_t *clash_mask);
425
440 rmw_qos_profile_t publisher_profile, rmw_qos_profile_t subscription_profile,
441 rmw_qos_compatibility_type_t *compatibility, char *reason, size_t reason_size);
442
453 bool *result);
454
472
479
502 /* 24 bytes */
503
512
520
523#define RMW_INET_ADDRSTRLEN 48
524
538
545typedef bool (*rmw_network_flow_endpoint_visit_fn)(void *ctx,
546 const rmw_network_flow_endpoint_t *endpoint);
547
555typedef void (*rmw_content_filter_visit_fn)(void *ctx,
556 const char *expression, const char *const *parameters, size_t parameter_count);
557
561#define NROS_RMW_DURATION_INFINITE_MS UINT32_MAX
562
563/* ------------------------------------------------------------------ */
564/* Entity options — transport hints (phase-301, issue 0240) */
565/* ------------------------------------------------------------------ */
566
613 const char *key;
614 const char *value;
616
625#define RMW_SESSION_MAX_PROPERTIES 16
626
653
662
715
716/* ---- Standard QoS profile constants ---- */
717/* Defined as static const initialisers at the bottom of this
718 * header so they're available in every compilation unit that
719 * includes it. Match the field set of upstream
720 * `rmw_qos_profile_default` etc. */
721
724#define NROS_RMW_QOS_PROFILE_DEFAULT \
725 ((rmw_qos_profile_t){ \
726 .reliability = NROS_RMW_RELIABILITY_RELIABLE, \
727 .durability = NROS_RMW_DURABILITY_VOLATILE, \
728 .history = NROS_RMW_HISTORY_KEEP_LAST, \
729 .liveliness_kind = NROS_RMW_LIVELINESS_AUTOMATIC, \
730 .depth = 10, \
731 ._reserved0 = 0, \
732 .deadline_ms = 0, \
733 .lifespan_ms = 0, \
734 .liveliness_lease_ms = 0, \
735 .avoid_ros_namespace_conventions = 0, \
736 ._reserved1 = {0, 0, 0}, \
737 })
738
741#define NROS_RMW_QOS_PROFILE_SENSOR_DATA \
742 ((rmw_qos_profile_t){ \
743 .reliability = NROS_RMW_RELIABILITY_BEST_EFFORT, \
744 .durability = NROS_RMW_DURABILITY_VOLATILE, \
745 .history = NROS_RMW_HISTORY_KEEP_LAST, \
746 .liveliness_kind = NROS_RMW_LIVELINESS_AUTOMATIC, \
747 .depth = 5, \
748 ._reserved0 = 0, \
749 .deadline_ms = 0, \
750 .lifespan_ms = 0, \
751 .liveliness_lease_ms = 0, \
752 .avoid_ros_namespace_conventions = 0, \
753 ._reserved1 = {0, 0, 0}, \
754 })
755
758#define NROS_RMW_QOS_PROFILE_SERVICES_DEFAULT NROS_RMW_QOS_PROFILE_DEFAULT
759
762#define NROS_RMW_QOS_PROFILE_PARAMETERS \
763 ((rmw_qos_profile_t){ \
764 .reliability = NROS_RMW_RELIABILITY_RELIABLE, \
765 .durability = NROS_RMW_DURABILITY_VOLATILE, \
766 .history = NROS_RMW_HISTORY_KEEP_LAST, \
767 .liveliness_kind = NROS_RMW_LIVELINESS_AUTOMATIC, \
768 .depth = 1000, \
769 ._reserved0 = 0, \
770 .deadline_ms = 0, \
771 .lifespan_ms = 0, \
772 .liveliness_lease_ms = 0, \
773 .avoid_ros_namespace_conventions = 0, \
774 ._reserved1 = {0, 0, 0}, \
775 })
776
802#define NROS_RMW_QOS_PROFILE_SYSTEM_DEFAULT \
803 ((rmw_qos_profile_t){ \
804 .reliability = NROS_RMW_RELIABILITY_SYSTEM_DEFAULT, \
805 .durability = NROS_RMW_DURABILITY_SYSTEM_DEFAULT, \
806 .history = NROS_RMW_HISTORY_SYSTEM_DEFAULT, \
807 .liveliness_kind = NROS_RMW_LIVELINESS_SYSTEM_DEFAULT, \
808 .depth = 0, \
809 ._reserved0 = 0, \
810 .deadline_ms = 0, \
811 .lifespan_ms = 0, \
812 .liveliness_lease_ms = 0, \
813 .avoid_ros_namespace_conventions = 0, \
814 ._reserved1 = {0, 0, 0}, \
815 })
816
817/* ------------------------------------------------------------------ */
818/* Entity structs */
819/* ------------------------------------------------------------------ */
820
833typedef struct rmw_session_t {
835 const char *node_name;
837 const char *namespace_;
840 uint8_t _reserved[8];
844
884typedef struct rmw_node_t {
886 const char *name;
888 const char *namespace_;
895 uint8_t _reserved[8];
898} rmw_node_t;
899
945
966
980typedef struct rmw_service_t {
982 const char *service_name;
985 const char *type_name;
987 uint8_t _reserved[8];
991
995typedef struct rmw_client_t {
997 const char *service_name;
999 const char *type_name;
1001 uint8_t _reserved[8];
1004} rmw_client_t;
1005
1006#endif /* NROS_RMW_ENTITY_H */
nros_rmw_qos_clash_t
Definition rmw_entity.h:405
@ NROS_RMW_QOS_CLASH_DEADLINE
Definition rmw_entity.h:409
@ NROS_RMW_QOS_CLASH_LIVELINESS_KIND
Definition rmw_entity.h:410
@ NROS_RMW_QOS_CLASH_RELIABILITY
Definition rmw_entity.h:407
@ NROS_RMW_QOS_CLASH_DURABILITY
Definition rmw_entity.h:408
@ NROS_RMW_QOS_CLASH_NONE
Definition rmw_entity.h:406
@ NROS_RMW_QOS_CLASH_LIVELINESS_LEASE
Definition rmw_entity.h:411
rmw_ret_t rmw_compare_gids_equal(const rmw_gid_t *gid1, const rmw_gid_t *gid2, bool *result)
rmw_liveliness_kind_t
Definition rmw_entity.h:262
@ NROS_RMW_LIVELINESS_MANUAL_BY_TOPIC
Definition rmw_entity.h:272
@ NROS_RMW_LIVELINESS_UNKNOWN
Definition rmw_entity.h:274
@ NROS_RMW_LIVELINESS_SYSTEM_DEFAULT
Definition rmw_entity.h:266
@ NROS_RMW_LIVELINESS_MANUAL_BY_NODE
Definition rmw_entity.h:270
@ NROS_RMW_LIVELINESS_AUTOMATIC
Definition rmw_entity.h:268
rmw_transport_protocol_t
Definition rmw_entity.h:506
@ RMW_TRANSPORT_PROTOCOL_UNKNOWN
Definition rmw_entity.h:507
@ RMW_TRANSPORT_PROTOCOL_COUNT
Definition rmw_entity.h:510
@ RMW_TRANSPORT_PROTOCOL_TCP
Definition rmw_entity.h:509
@ RMW_TRANSPORT_PROTOCOL_UDP
Definition rmw_entity.h:508
rmw_endpoint_type_t
Definition rmw_entity.h:474
@ RMW_ENDPOINT_SUBSCRIPTION
Definition rmw_entity.h:477
@ RMW_ENDPOINT_INVALID
Definition rmw_entity.h:475
@ RMW_ENDPOINT_PUBLISHER
Definition rmw_entity.h:476
int64_t rmw_time_point_value_t
Definition rmw_entity.h:98
void(* rmw_content_filter_visit_fn)(void *ctx, const char *expression, const char *const *parameters, size_t parameter_count)
Definition rmw_entity.h:555
rmw_log_severity_t
Definition rmw_entity.h:464
@ RMW_LOG_SEVERITY_WARN
Definition rmw_entity.h:468
@ RMW_LOG_SEVERITY_ERROR
Definition rmw_entity.h:469
@ RMW_LOG_SEVERITY_INFO
Definition rmw_entity.h:467
@ RMW_LOG_SEVERITY_FATAL
Definition rmw_entity.h:470
@ RMW_LOG_SEVERITY_DEBUG
Definition rmw_entity.h:466
@ RMW_LOG_SEVERITY_UNSET
Definition rmw_entity.h:465
rmw_feature_t
Definition rmw_entity.h:92
@ RMW_FEATURE_MESSAGE_INFO_RECEPTION_SEQUENCE_NUMBER
Definition rmw_entity.h:94
@ RMW_FEATURE_MESSAGE_INFO_PUBLICATION_SEQUENCE_NUMBER
Definition rmw_entity.h:93
#define RMW_GID_STORAGE_SIZE
Definition rmw_entity.h:105
rmw_ret_t nros_rmw_qos_incompatibility_mask(rmw_qos_profile_t offered, rmw_qos_profile_t requested, rmw_qos_compatibility_type_t *compatibility, uint32_t *clash_mask)
rmw_ret_t rmw_qos_profile_check_compatible(rmw_qos_profile_t publisher_profile, rmw_qos_profile_t subscription_profile, rmw_qos_compatibility_type_t *compatibility, char *reason, size_t reason_size)
#define RMW_INET_ADDRSTRLEN
Definition rmw_entity.h:523
rmw_internet_protocol_t
Definition rmw_entity.h:514
@ RMW_INTERNET_PROTOCOL_COUNT
Definition rmw_entity.h:518
@ RMW_INTERNET_PROTOCOL_UNKNOWN
Definition rmw_entity.h:515
@ RMW_INTERNET_PROTOCOL_IPV6
Definition rmw_entity.h:517
@ RMW_INTERNET_PROTOCOL_IPV4
Definition rmw_entity.h:516
rmw_qos_compatibility_type_t
Definition rmw_entity.h:397
@ RMW_QOS_COMPATIBILITY_ERROR
Definition rmw_entity.h:400
@ RMW_QOS_COMPATIBILITY_WARNING
Definition rmw_entity.h:399
@ RMW_QOS_COMPATIBILITY_OK
Definition rmw_entity.h:398
bool(* rmw_network_flow_endpoint_visit_fn)(void *ctx, const rmw_network_flow_endpoint_t *endpoint)
Definition rmw_entity.h:545
Return-code constants for the nros RMW C vtable.
int32_t rmw_ret_t
Definition rmw_ret.h:58
Definition rmw_entity.h:133
size_t len
Definition rmw_entity.h:135
const uint8_t * data
Definition rmw_entity.h:134
Definition rmw_entity.h:995
uint8_t _reserved[8]
Definition rmw_entity.h:1001
void * backend_data
Definition rmw_entity.h:1003
const char * service_name
Definition rmw_entity.h:997
const char * type_name
Definition rmw_entity.h:999
Definition rmw_entity.h:212
uint8_t data[24u]
Definition rmw_entity.h:217
const char * implementation_identifier
Definition rmw_entity.h:215
Definition rmw_entity.h:238
rmw_gid_t publisher_gid
Definition rmw_entity.h:250
uint64_t reception_sequence_number
Definition rmw_entity.h:248
rmw_time_point_value_t source_timestamp
Definition rmw_entity.h:240
bool from_intra_process
Definition rmw_entity.h:253
uint64_t publication_sequence_number
Definition rmw_entity.h:246
rmw_time_point_value_t received_timestamp
Definition rmw_entity.h:242
Definition rmw_entity.h:189
const char * type_name
Definition rmw_entity.h:193
const char * type_hash
Definition rmw_entity.h:196
Definition rmw_entity.h:155
uint8_t * data
Definition rmw_entity.h:156
size_t len
Definition rmw_entity.h:160
size_t capacity
Definition rmw_entity.h:158
Definition rmw_entity.h:528
uint8_t dscp
Definition rmw_entity.h:535
rmw_transport_protocol_t transport_protocol
Definition rmw_entity.h:529
rmw_internet_protocol_t internet_protocol
Definition rmw_entity.h:530
char internet_address[48]
Definition rmw_entity.h:536
uint16_t transport_port
Definition rmw_entity.h:531
uint32_t flow_label
Definition rmw_entity.h:533
Definition rmw_entity.h:884
uint8_t _reserved[8]
Definition rmw_entity.h:895
const char * namespace_
Definition rmw_entity.h:888
rmw_session_t * session
Definition rmw_entity.h:893
const char * name
Definition rmw_entity.h:886
void * backend_data
Definition rmw_entity.h:897
Definition rmw_entity.h:654
uint8_t _reserved[7]
Definition rmw_entity.h:660
uint8_t tx_express
Definition rmw_entity.h:659
Definition rmw_entity.h:928
const char * type_name
Definition rmw_entity.h:933
uint8_t _reserved[7]
Definition rmw_entity.h:941
bool can_loan_messages
Definition rmw_entity.h:939
const char * topic_name
Definition rmw_entity.h:930
void * backend_data
Definition rmw_entity.h:943
rmw_qos_profile_t qos
Definition rmw_entity.h:935
Definition rmw_entity.h:318
uint8_t avoid_ros_namespace_conventions
Definition rmw_entity.h:347
uint8_t reliability
Definition rmw_entity.h:320
uint8_t durability
Definition rmw_entity.h:321
uint16_t depth
Definition rmw_entity.h:324
uint32_t lifespan_ms
Definition rmw_entity.h:335
uint8_t _reserved1[3]
Definition rmw_entity.h:348
uint8_t liveliness_kind
Definition rmw_entity.h:323
uint16_t _reserved0
Definition rmw_entity.h:325
uint32_t deadline_ms
Definition rmw_entity.h:331
uint8_t history
Definition rmw_entity.h:322
uint32_t liveliness_lease_ms
Definition rmw_entity.h:339
Definition rmw_entity.h:980
uint8_t _reserved[8]
Definition rmw_entity.h:987
void * backend_data
Definition rmw_entity.h:989
const char * service_name
Definition rmw_entity.h:982
const char * type_name
Definition rmw_entity.h:985
Definition rmw_entity.h:205
const char * type_name
Definition rmw_entity.h:207
const char * type_hash
Definition rmw_entity.h:209
Definition rmw_entity.h:627
uint8_t _reserved[7]
Definition rmw_entity.h:634
size_t property_count
Definition rmw_entity.h:651
uint8_t localhost_only
Definition rmw_entity.h:633
const char * enclave
Definition rmw_entity.h:643
const rmw_session_property_t * properties
Definition rmw_entity.h:650
Definition rmw_entity.h:612
const char * value
Definition rmw_entity.h:614
const char * key
Definition rmw_entity.h:613
Definition rmw_entity.h:833
const char * node_name
Definition rmw_entity.h:835
const char * namespace_
Definition rmw_entity.h:837
void * backend_data
Definition rmw_entity.h:842
uint8_t _reserved[8]
Definition rmw_entity.h:840
Definition rmw_entity.h:668
uint8_t _reserved[4]
Definition rmw_entity.h:713
uint32_t rx_buffer_hint
Definition rmw_entity.h:712
Definition rmw_entity.h:950
uint8_t _reserved[7]
Definition rmw_entity.h:962
void * backend_data
Definition rmw_entity.h:964
bool can_loan_messages
Definition rmw_entity.h:960
const char * type_name
Definition rmw_entity.h:954
const char * topic_name
Definition rmw_entity.h:952
rmw_qos_profile_t qos
Definition rmw_entity.h:956
Definition rmw_entity.h:485
const char * node_name
Definition rmw_entity.h:487
rmw_endpoint_type_t endpoint_type
Definition rmw_entity.h:493
rmw_gid_t endpoint_gid
Definition rmw_entity.h:495
rmw_qos_profile_t qos_profile
Definition rmw_entity.h:500
const char * topic_type
Definition rmw_entity.h:491
const char * node_namespace
Definition rmw_entity.h:489