-
Notifications
You must be signed in to change notification settings - Fork 55
/
zenoh_commons.h
4018 lines (4018 loc) · 146 KB
/
zenoh_commons.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Copyright (c) 2024 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//
// clang-format off
#ifdef DOCS
#define ALIGN(n)
#define ZENOHC_API
#endif
/**
* Allocation errors
*
* - **NEED_DEFRAGMENT**: defragmentation needed
* - **OUT_OF_MEMORY**: the provider is out of memory
* - **OTHER**: other error
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef enum z_alloc_error_t {
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
Z_ALLOC_ERROR_NEED_DEFRAGMENT,
#endif
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
Z_ALLOC_ERROR_OUT_OF_MEMORY,
#endif
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
Z_ALLOC_ERROR_OTHER,
#endif
} z_alloc_error_t;
#endif
typedef enum z_congestion_control_t {
/**
* Messages are not dropped in case of congestion.
*/
Z_CONGESTION_CONTROL_BLOCK,
/**
* Messages are dropped in case of congestion.
*/
Z_CONGESTION_CONTROL_DROP,
} z_congestion_control_t;
/**
* Consolidation mode values.
*/
typedef enum z_consolidation_mode_t {
/**
* Let Zenoh decide the best consolidation mode depending on the query selector.
* If the selector contains time range properties, consolidation mode `NONE` is used.
* Otherwise the `LATEST` consolidation mode is used.
*/
Z_CONSOLIDATION_MODE_AUTO = -1,
/**
* No consolidation is applied. Replies may come in any order and any number.
*/
Z_CONSOLIDATION_MODE_NONE = 0,
/**
* It guarantees that any reply for a given key expression will be monotonic in time
* w.r.t. the previous received replies for the same key expression. I.e., for the same key expression multiple
* replies may be received. It is guaranteed that two replies received at t1 and t2 will have timestamp
* ts2 > ts1. It optimizes latency.
*/
Z_CONSOLIDATION_MODE_MONOTONIC = 1,
/**
* It guarantees unicity of replies for the same key expression.
* It optimizes bandwidth.
*/
Z_CONSOLIDATION_MODE_LATEST = 2,
} z_consolidation_mode_t;
/**
* Intersection level of 2 key expressions.
*/
typedef enum z_keyexpr_intersection_level_t {
/**
* 2 key expressions do not intersect.
*/
Z_KEYEXPR_INTERSECTION_LEVEL_DISJOINT = 0,
/**
* 2 key expressions intersect, i.e. there exists at least one key expression that is included by both.
*/
Z_KEYEXPR_INTERSECTION_LEVEL_INTERSECTS = 1,
/**
* First key expression is the superset of second one.
*/
Z_KEYEXPR_INTERSECTION_LEVEL_INCLUDES = 2,
/**
* 2 key expressions are equal.
*/
Z_KEYEXPR_INTERSECTION_LEVEL_EQUALS = 3,
} z_keyexpr_intersection_level_t;
/**
* The priority of zenoh messages.
*/
typedef enum z_priority_t {
/**
* Priority for ``RealTime`` messages.
*/
Z_PRIORITY_REAL_TIME = 1,
/**
* Highest priority for ``Interactive`` messages.
*/
Z_PRIORITY_INTERACTIVE_HIGH = 2,
/**
* Lowest priority for ``Interactive`` messages.
*/
Z_PRIORITY_INTERACTIVE_LOW = 3,
/**
* Highest priority for ``Data`` messages.
*/
Z_PRIORITY_DATA_HIGH = 4,
/**
* Default priority for ``Data`` messages.
*/
Z_PRIORITY_DATA = 5,
/**
* Lowest priority for ``Data`` messages.
*/
Z_PRIORITY_DATA_LOW = 6,
/**
* Priority for ``Background traffic`` messages.
*/
Z_PRIORITY_BACKGROUND = 7,
} z_priority_t;
/**
* The Queryables that should be target of a `z_get()`.
*/
typedef enum z_query_target_t {
/**
* The nearest complete queryable if any else all matching queryables.
*/
Z_QUERY_TARGET_BEST_MATCHING,
/**
* All matching queryables.
*/
Z_QUERY_TARGET_ALL,
/**
* All complete queryables.
*/
Z_QUERY_TARGET_ALL_COMPLETE,
} z_query_target_t;
/**
* The subscription reliability.
*/
typedef enum z_reliability_t {
/**
* Defines reliability as ``BEST_EFFORT``
*/
Z_RELIABILITY_BEST_EFFORT,
/**
* Defines reliability as ``RELIABLE``
*/
Z_RELIABILITY_RELIABLE,
} z_reliability_t;
typedef enum z_sample_kind_t {
/**
* The Sample was issued by a ``put`` operation.
*/
Z_SAMPLE_KIND_PUT = 0,
/**
* The Sample was issued by a ``delete`` operation.
*/
Z_SAMPLE_KIND_DELETE = 1,
} z_sample_kind_t;
typedef enum z_whatami_t {
Z_WHATAMI_ROUTER = 1,
Z_WHATAMI_PEER = 2,
Z_WHATAMI_CLIENT = 4,
Z_WHATAMI_ROUTER_PEER = (1 | 2),
Z_WHATAMI_ROUTER_CLIENT = (1 | 4),
Z_WHATAMI_PEER_CLIENT = (2 | 4),
Z_WHATAMI_ROUTER_PEER_CLIENT = ((1 | 2) | 4),
} z_whatami_t;
/**
* The locality of samples to be received by subscribers or targeted by publishers.
*/
typedef enum zcu_locality_t {
/**
* Any
*/
ZCU_LOCALITY_ANY = 0,
/**
* Only from local sessions.
*/
ZCU_LOCALITY_SESSION_LOCAL = 1,
/**
* Only from remote sessions.
*/
ZCU_LOCALITY_REMOTE = 2,
} zcu_locality_t;
/**
* Key expressions types to which Queryable should reply to.
*/
typedef enum zcu_reply_keyexpr_t {
/**
* Replies to any key expression queries.
*/
ZCU_REPLY_KEYEXPR_ANY = 0,
/**
* Replies only to queries with intersecting key expressions.
*/
ZCU_REPLY_KEYEXPR_MATCHING_QUERY = 1,
} zcu_reply_keyexpr_t;
typedef int8_t z_error_t;
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef struct z_alloc_alignment_t {
uint8_t pow;
} z_alloc_alignment_t;
#endif
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef struct zc_threadsafe_context_data_t {
void *ptr;
} zc_threadsafe_context_data_t;
#endif
/**
* A tread-safe droppable context.
* Contexts are idiomatically used in C together with callback interfaces to deliver associated state
* information to each callback.
*
* This is a thread-safe context - the associated callbacks may be executed concurrently with the same
* zc_context_t instance. In other words, all the callbacks associated with this context data MUST be
* thread-safe.
*
* Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted.The
* delete_fn is guaranteed to be executed only once at some point of time after the last associated
* callback call returns.
* NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't
* be executed.
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef struct zc_threadsafe_context_t {
struct zc_threadsafe_context_data_t context;
void (*delete_fn)(void*);
} zc_threadsafe_context_t;
#endif
/**
* Unique segment identifier
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef uint32_t z_segment_id_t;
#endif
/**
* Chunk id within it's segment
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef uint32_t z_chunk_id_t;
#endif
/**
* A ChunkDescriptor
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef struct z_chunk_descriptor_t {
z_segment_id_t segment;
z_chunk_id_t chunk;
size_t len;
} z_chunk_descriptor_t;
#endif
/**
* An AllocatedChunk
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef struct z_allocated_chunk_t {
struct z_chunk_descriptor_t descriptpr;
void *data;
} z_allocated_chunk_t;
#endif
/**
* Monotonic clock
*/
typedef struct z_clock_t {
uint64_t t;
const void *t_base;
} z_clock_t;
/**
* A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks:
*
* Closures are not guaranteed not to be called concurrently.
*
* It is guaranteed that:
*
* - `call` will never be called once `drop` has started.
* - `drop` will only be called **once**, and **after every** `call` has ended.
* - The two previous guarantees imply that `call` and `drop` are never called concurrently.
*/
typedef struct z_owned_closure_hello_t {
/**
* An optional pointer to a closure state.
*/
void *context;
/**
* A closure body.
*/
void (*call)(const struct z_loaned_hello_t *hello, void *context);
/**
* An optional drop function that will be called when the closure is dropped.
*/
void (*drop)(void *context);
} z_owned_closure_hello_t;
/**
* A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks:
*
* Members:
* void *context: a pointer to an arbitrary state.
* void *call(const struct z_loaned_query_t*, const void *context): the typical callback function. `context` will be passed as its last argument.
* void *drop(void*): allows the callback's state to be freed.
*
* Closures are not guaranteed not to be called concurrently.
*
* It is guaranteed that:
*
* - `call` will never be called once `drop` has started.
* - `drop` will only be called **once**, and **after every** `call` has ended.
* - The two previous guarantees imply that `call` and `drop` are never called concurrently.
*/
typedef struct z_owned_closure_owned_query_t {
void *context;
void (*call)(struct z_owned_query_t*, void *context);
void (*drop)(void*);
} z_owned_closure_owned_query_t;
/**
* A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks:
*
* Closures are not guaranteed not to be called concurrently.
*
* It is guaranteed that:
* - `call` will never be called once `drop` has started.
* - `drop` will only be called **once**, and **after every** `call` has ended.
* - The two previous guarantees imply that `call` and `drop` are never called concurrently.
*/
typedef struct z_owned_closure_query_t {
/**
* An optional pointer to a context representing a closure state.
*/
void *context;
/**
* A closure body.
*/
void (*call)(const struct z_loaned_query_t *reply, void *context);
/**
* An optional drop function that will be called when the closure is dropped.
*/
void (*drop)(void *context);
} z_owned_closure_query_t;
/**
* A structure that contains all the elements for stateful, memory-leak-free callbacks.
*
* Closures are not guaranteed not to be called concurrently.
*
* It is guaranteed that:
* - `call` will never be called once `drop` has started.
* - `drop` will only be called **once**, and **after every** `call` has ended.
* - The two previous guarantees imply that `call` and `drop` are never called concurrently.
*/
typedef struct z_owned_closure_reply_t {
/**
* An optional pointer to a context representing a closure state.
*/
void *context;
/**
* A closure body.
*/
void (*call)(const struct z_loaned_reply_t *reply, void *context);
/**
* An optional drop function that will be called when the closure is dropped.
*/
void (*drop)(void *context);
} z_owned_closure_reply_t;
/**
* A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks.
*
* Closures are not guaranteed not to be called concurrently.
*
* It is guaranteed that:
* - `call` will never be called once `drop` has started.
* - `drop` will only be called **once**, and **after every** `call` has ended.
* - The two previous guarantees imply that `call` and `drop` are never called concurrently.
*/
typedef struct z_owned_closure_sample_t {
/**
* An optional pointer to a context representing a closure state.
*/
void *context;
/**
* A closure body.
*/
void (*call)(const struct z_loaned_sample_t *sample, void *context);
/**
* An optional drop function that will be called when the closure is dropped.
*/
void (*drop)(void *context);
} z_owned_closure_sample_t;
/**
* A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks:
*
* Closures are not guaranteed not to be called concurrently.
*
* It is guaranteed that:
* - `call` will never be called once `drop` has started.
* - `drop` will only be called **once**, and **after every** `call` has ended.
* - The two previous guarantees imply that `call` and `drop` are never called concurrently.
*/
typedef struct z_owned_closure_zid_t {
/**
* An optional pointer to a closure state.
*/
void *context;
/**
* A callback function.
*/
void (*call)(const struct z_id_t *z_id, void *context);
/**
* An optional function that will be called upon closure drop.
*/
void (*drop)(void *context);
} z_owned_closure_zid_t;
/**
* Options passed to the `z_declare_publisher()` function.
*/
typedef struct z_publisher_options_t {
/**
* The congestion control to apply when routing messages from this publisher.
*/
enum z_congestion_control_t congestion_control;
/**
* The priority of messages from this publisher.
*/
enum z_priority_t priority;
/**
* If true, Zenoh will not wait to batch this message with others to reduce the bandwith
*/
bool is_express;
/**
* The allowed destination for this publisher.
*/
enum zcu_locality_t allowed_destination;
} z_publisher_options_t;
/**
* Options passed to the `z_declare_queryable()` function.
*/
typedef struct z_queryable_options_t {
/**
* The completeness of the Queryable.
*/
bool complete;
} z_queryable_options_t;
/**
* Options passed to the `z_declare_subscriber()` function.
*/
typedef struct z_subscriber_options_t {
/**
* The subscription reliability.
*/
enum z_reliability_t reliability;
} z_subscriber_options_t;
/**
* Options passed to the `z_delete()` function.
*/
typedef struct z_delete_options_t {
/**
* The congestion control to apply when routing this delete message.
*/
enum z_congestion_control_t congestion_control;
/**
* The priority of the delete message.
*/
enum z_priority_t priority;
/**
* If true, Zenoh will not wait to batch this operation with others to reduce the bandwith.
*/
bool is_express;
/**
* The timestamp of this message.
*/
struct z_timestamp_t *timestamp;
/**
* The allowed destination of this message.
*/
enum zcu_locality_t allowed_destination;
} z_delete_options_t;
/**
* The replies consolidation strategy to apply on replies to a `z_get()`.
*/
typedef struct z_query_consolidation_t {
enum z_consolidation_mode_t mode;
} z_query_consolidation_t;
/**
* Options passed to the `z_get()` function.
*/
typedef struct z_get_options_t {
/**
* The Queryables that should be target of the query.
*/
enum z_query_target_t target;
/**
* The replies consolidation strategy to apply on replies to the query.
*/
struct z_query_consolidation_t consolidation;
/**
* An optional payload to attach to the query.
*/
struct z_owned_bytes_t *payload;
/**
* An optional encoding of the query payload and or attachment.
*/
struct z_owned_encoding_t *encoding;
/**
* The congestion control to apply when routing the query.
*/
enum z_congestion_control_t congestion_control;
/**
* The allowed destination for the query.
*/
enum zcu_locality_t allowed_destination;
/**
* The accepted replies for the query.
*/
enum zcu_reply_keyexpr_t accept_replies;
/**
* The priority of the query.
*/
enum z_priority_t priority;
/**
* The source info for the query.
*/
struct z_owned_source_info_t *source_info;
/**
* An optional attachment to attach to the query.
*/
struct z_owned_bytes_t *attachment;
/**
* The timeout for the query in milliseconds. 0 means default query timeout from zenoh configuration.
*/
uint64_t timeout_ms;
} z_get_options_t;
/**
* Represents the set of options that can be applied to the delete operation by a previously declared publisher,
* whenever issued via `z_publisher_delete()`.
*/
typedef struct z_publisher_delete_options_t {
/**
* The timestamp of this message.
*/
struct z_timestamp_t *timestamp;
} z_publisher_delete_options_t;
/**
* Options passed to the `z_publisher_put()` function.
*/
typedef struct z_publisher_put_options_t {
/**
* The encoding of the data to publish.
*/
struct z_owned_encoding_t *encoding;
/**
* The timestamp of the publication.
*/
struct z_timestamp_t *timestamp;
/**
* The source info for the publication.
*/
struct z_owned_source_info_t *source_info;
/**
* The attachment to attach to the publication.
*/
struct z_owned_bytes_t *attachment;
} z_publisher_put_options_t;
/**
* Options passed to the `z_put()` function.
*/
typedef struct z_put_options_t {
/**
* The encoding of the message.
*/
struct z_owned_encoding_t *encoding;
/**
* The congestion control to apply when routing this message.
*/
enum z_congestion_control_t congestion_control;
/**
* The priority of this message.
*/
enum z_priority_t priority;
/**
* If true, Zenoh will not wait to batch this operation with others to reduce the bandwith.
*/
bool is_express;
/**
* The timestamp of this message.
*/
struct z_timestamp_t *timestamp;
/**
* The allowed destination of this message.
*/
enum zcu_locality_t allowed_destination;
/**
* The source info for the message.
*/
struct z_owned_source_info_t *source_info;
/**
* The attachment to this message.
*/
struct z_owned_bytes_t *attachment;
} z_put_options_t;
/**
* Represents the set of options that can be applied to a query reply,
* sent via `z_query_reply()`.
*/
typedef struct z_query_reply_options_t {
/**
* The encoding of the reply payload.
*/
struct z_owned_encoding_t *encoding;
/**
* The congestion control to apply when routing the reply.
*/
enum z_congestion_control_t congestion_control;
/**
* The priority of the reply.
*/
enum z_priority_t priority;
/**
* If true, Zenoh will not wait to batch this operation with others to reduce the bandwith.
*/
bool is_express;
/**
* The timestamp of the reply.
*/
struct z_timestamp_t *timestamp;
/**
* The source info for the reply.
*/
struct z_owned_source_info_t *source_info;
/**
* The attachment to this reply.
*/
struct z_owned_bytes_t *attachment;
} z_query_reply_options_t;
/**
* Represents the set of options that can be applied to a query delete reply,
* sent via `z_query_reply_del()`.
*/
typedef struct z_query_reply_del_options_t {
/**
* The congestion control to apply when routing the reply.
*/
enum z_congestion_control_t congestion_control;
/**
* The priority of the reply.
*/
enum z_priority_t priority;
/**
* If true, Zenoh will not wait to batch this operation with others to reduce the bandwith.
*/
bool is_express;
/**
* The timestamp of the reply.
*/
struct z_timestamp_t *timestamp;
/**
* The source info for the reply.
*/
struct z_owned_source_info_t *source_info;
/**
* The attachment to this reply.
*/
struct z_owned_bytes_t *attachment;
} z_query_reply_del_options_t;
/**
* Represents the set of options that can be applied to a query reply error,
* sent via `z_query_reply_err()`.
*/
typedef struct z_query_reply_err_options_t {
/**
* The encoding of the error payload.
*/
struct z_owned_encoding_t *encoding;
} z_query_reply_err_options_t;
/**
* Options to pass to `z_scout()`.
*/
typedef struct z_scout_options_t {
/**
* The maximum duration in ms the scouting can take.
*/
unsigned long zc_timeout_ms;
/**
* Type of entities to scout for.
*/
enum z_whatami_t zc_what;
} z_scout_options_t;
/**
* A callbacks for ShmSegment
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef struct zc_shm_segment_callbacks_t {
uint8_t *(*map_fn)(z_chunk_id_t chunk_id, void *context);
} zc_shm_segment_callbacks_t;
#endif
/**
* A ShmSegment
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef struct z_shm_segment_t {
struct zc_threadsafe_context_t context;
struct zc_shm_segment_callbacks_t callbacks;
} z_shm_segment_t;
#endif
/**
* A callbacks for ShmClient
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef struct zc_shm_client_callbacks_t {
bool (*attach_fn)(struct z_shm_segment_t *out_segment, z_segment_id_t segment_id, void *context);
} zc_shm_client_callbacks_t;
#endif
/**
* Unique protocol identifier.
* Here is a contract: it is up to user to make sure that incompatible ShmClient
* and ShmProviderBackend implementations will never use the same ProtocolID
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef uint32_t z_protocol_id_t;
#endif
/**
* A non-tread-safe droppable context.
* Contexts are idiomatically used in C together with callback interfaces to deliver associated state
* information to each callback.
*
* This is a non-thread-safe context - zenoh-c guarantees that associated callbacks that share the same
* zc_context_t instance will never be executed concurrently. In other words, all the callbacks associated
* with this context data are not required to be thread-safe.
*
* NOTE: Remember that the same callback interfaces associated with different zc_context_t instances can
* still be executed concurrently. The exact behavior depends on user's application, but we strongly
* discourage our users from pinning to some specific behavior unless they _really_ understand what they
* are doing.
*
* Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted. The
* delete_fn is guaranteed to be executed only once at some point of time after the last associated
* callback call returns.
* NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't
* be executed.
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef struct zc_context_t {
void *context;
void (*delete_fn)(void*);
} zc_context_t;
#endif
/**
* A callbacks for ShmProviderBackend
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
typedef struct zc_shm_provider_backend_callbacks_t {
void (*alloc_fn)(z_owned_chunk_alloc_result_t *out_result,
const z_loaned_memory_layout_t *layout,
void *context);
void (*free_fn)(const struct z_chunk_descriptor_t *chunk, void *context);
size_t (*defragment_fn)(void *context);
size_t (*available_fn)(void *context);
void (*layout_for_fn)(z_owned_memory_layout_t *layout, void *context);
} zc_shm_provider_backend_callbacks_t;
#endif
typedef struct z_task_attr_t {
size_t _0;
} z_task_attr_t;
/**
* Returns system clock time point corresponding to the current time instant.
*/
typedef struct z_time_t {
uint64_t t;
} z_time_t;
/**
* The options for `zc_liveliness_declare_token()`.
*/
typedef struct zc_liveliness_declaration_options_t {
uint8_t _dummy;
} zc_liveliness_declaration_options_t;
/**
* The options for `zc_liveliness_declare_subscriber()`
*/
typedef struct zc_liveliness_subscriber_options_t {
uint8_t _dummy;
} zc_liveliness_subscriber_options_t;
/**
* The options for `zc_liveliness_get()`
*/
typedef struct zc_liveliness_get_options_t {
uint32_t timeout_ms;
} zc_liveliness_get_options_t;
/**
* A struct that indicates if there exist Subscribers matching the Publisher's key expression.
*/
typedef struct zcu_matching_status_t {
/**
* True if there exist Subscribers matching the Publisher's key expression, false otherwise.
*/
bool matching;
} zcu_matching_status_t;
/**
* A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks:
*
* Closures are not guaranteed not to be called concurrently.
*
* It is guaranteed that:
* - `call` will never be called once `drop` has started.
* - `drop` will only be called **once**, and **after every** `call` has ended.
* - The two previous guarantees imply that `call` and `drop` are never called concurrently.
*/
typedef struct zcu_owned_closure_matching_status_t {
/**
* An optional pointer to a closure state.
*/
void *context;
/**
* A closure body.
*/
void (*call)(const struct zcu_matching_status_t *matching_status, void *context);
/**
* An optional drop function that will be called when the closure is dropped.
*/
void (*drop)(void *context);
} zcu_owned_closure_matching_status_t;
/**
* Options passed to the `ze_declare_publication_cache()` function.
*/
typedef struct ze_publication_cache_options_t {
/**
* The prefix used for queryable.
*/
const struct z_loaned_keyexpr_t *queryable_prefix;
#if defined(UNSTABLE)
/**
* The restriction for the matching queries that will be receive by this publication cache.
*/
enum zcu_locality_t queryable_origin;
#endif
/**
* The `complete` option for the queryable.
*/
bool queryable_complete;
/**
* The the history size (i.e. maximum number of messages to store).
*/
size_t history;
/**
* The limit number of cached resources.
*/
size_t resources_limit;
} ze_publication_cache_options_t;
/**
* A set of options that can be applied to a querying subscriber,
* upon its declaration via `ze_declare_querying_subscriber()`.
*
*/
typedef struct ze_querying_subscriber_options_t {
/**
* The subscription reliability.
*/
enum z_reliability_t reliability;
#if defined(UNSTABLE)
/**
* The restriction for the matching publications that will be receive by this subscriber.
*/
enum zcu_locality_t allowed_origin;
#endif
/**
* The selector to be used for queries.
*/
const struct z_loaned_keyexpr_t *query_selector;
/**
* The target to be used for queries.
*/
enum z_query_target_t query_target;
/**
* The consolidation mode to be used for queries.
*/
struct z_query_consolidation_t query_consolidation;
/**
* The accepted replies for queries.
*/
enum zcu_reply_keyexpr_t query_accept_replies;
/**
* The timeout to be used for queries.
*/
uint64_t query_timeout_ms;
} ze_querying_subscriber_options_t;
ZENOHC_API extern const unsigned int Z_ROUTER;
ZENOHC_API extern const unsigned int Z_PEER;
ZENOHC_API extern const unsigned int Z_CLIENT;
ZENOHC_API extern const char *Z_CONFIG_MODE_KEY;
ZENOHC_API extern const char *Z_CONFIG_CONNECT_KEY;
ZENOHC_API extern const char *Z_CONFIG_LISTEN_KEY;
ZENOHC_API extern const char *Z_CONFIG_USER_KEY;
ZENOHC_API extern const char *Z_CONFIG_PASSWORD_KEY;
ZENOHC_API extern const char *Z_CONFIG_MULTICAST_SCOUTING_KEY;
ZENOHC_API extern const char *Z_CONFIG_MULTICAST_INTERFACE_KEY;
ZENOHC_API extern const char *Z_CONFIG_MULTICAST_IPV4_ADDRESS_KEY;
ZENOHC_API extern const char *Z_CONFIG_SCOUTING_TIMEOUT_KEY;
ZENOHC_API extern const char *Z_CONFIG_SCOUTING_DELAY_KEY;
ZENOHC_API extern const char *Z_CONFIG_ADD_TIMESTAMP_KEY;
ZENOHC_API extern const unsigned int Z_SHM_POSIX_PROTOCOL_ID;
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API
void z_alloc_layout_alloc(z_owned_buf_alloc_result_t *out_result,
const z_loaned_alloc_layout_t *layout);
#endif
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API
void z_alloc_layout_alloc_gc(z_owned_buf_alloc_result_t *out_result,
const z_loaned_alloc_layout_t *layout);
#endif
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API
void z_alloc_layout_alloc_gc_defrag(z_owned_buf_alloc_result_t *out_result,
const z_loaned_alloc_layout_t *layout);
#endif
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API
void z_alloc_layout_alloc_gc_defrag_blocking(z_owned_buf_alloc_result_t *out_result,
const z_loaned_alloc_layout_t *layout);
#endif
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API
void z_alloc_layout_alloc_gc_defrag_dealloc(z_owned_buf_alloc_result_t *out_result,
const z_loaned_alloc_layout_t *layout);
#endif
/**
* Returns ``true`` if `this` is valid.
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API bool z_alloc_layout_check(const z_owned_alloc_layout_t *this_);
#endif
/**
* Deletes Alloc Layout
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API void z_alloc_layout_drop(z_owned_alloc_layout_t *this_);
#endif
/**
* Borrows Alloc Layout
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API const z_loaned_alloc_layout_t *z_alloc_layout_loan(const z_owned_alloc_layout_t *this_);
#endif
/**
* Creates a new Alloc Layout for SHM Provider
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API
z_error_t z_alloc_layout_new(z_owned_alloc_layout_t *this_,
const z_loaned_shm_provider_t *provider,
size_t size,
struct z_alloc_alignment_t alignment);
#endif
/**
* Constructs Alloc Layout in its gravestone value.
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API void z_alloc_layout_null(z_owned_alloc_layout_t *this_);
#endif
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API
z_error_t z_alloc_layout_threadsafe_alloc_gc_defrag_async(z_owned_buf_alloc_result_t *out_result,
const z_loaned_alloc_layout_t *layout,
struct zc_threadsafe_context_t result_context,
void (*result_callback)(void*,
z_owned_buf_alloc_result_t*));
#endif
/**
* Returns ``true`` if `this` is valid.
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API bool z_buf_alloc_result_check(const z_owned_buf_alloc_result_t *this_);
#endif
/**
* Deletes Buf Alloc Result
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API void z_buf_alloc_result_drop(z_owned_buf_alloc_result_t *this_);
#endif
/**
* Borrows Buf Alloc Result
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API
const z_loaned_buf_alloc_result_t *z_buf_alloc_result_loan(const z_owned_buf_alloc_result_t *this_);
#endif
/**
* Constructs Buf Alloc Result in its gravestone value.
*/
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API void z_buf_alloc_result_null(z_owned_buf_alloc_result_t *this_);
#endif
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
ZENOHC_API