24#define O2TAG_HANDLER 4
25#define O2TAG_SERVICES 8
26#define O2TAG_PROC_TCP_SERVER 0x10
27#define O2TAG_PROC_NOMSGYET 0x20
28#define O2TAG_PROC 0x40
29#define O2TAG_PROC_TEMP 0x80
30#define O2TAG_MQTT 0x100
31#define O2TAG_OSC_UDP_SERVER 0x200
32#define O2TAG_OSC_TCP_SERVER 0x400
33#define O2TAG_OSC_UDP_CLIENT 0x800
34#define O2TAG_OSC_TCP_CLIENT 0x1000
35#define O2TAG_OSC_TCP_CONNECTION 0x2000
36#define O2TAG_HTTP_SERVER 0x4000
37#define O2TAG_HTTP_READER 0x8000
43#define O2TAG_BRIDGE 0x10000
45#define O2TAG_STUN 0x20000
46#define O2TAG_ZC 0x40000
47#define O2TAG_TYPE_BITS ((O2TAG_ZC << 1) - 1)
52#define O2TAG_SYNCED 0x80000
57#define O2TAG_OWNED_BY_TREE 0x100000
59#define O2TAG_HIGH O2TAG_OWNED_BY_TREE
62#define ISA_HANDLER(x) ((x)->tag & O2TAG_HANDLER)
63#define ISA_HASH(x) ((x)->tag & O2TAG_HASH)
64#define ISA_SERVICES(x) ((x)->tag & O2TAG_SERVICES)
65#define ISA_PROC(x) ((x)->tag & O2TAG_PROC)
66#define ISA_PROC_TCP_SERVER(x) ((x)->tag & O2TAG_PROC_TCP_SERVER)
67#define ISA_MQTT(x) ((x)->tag & O2TAG_MQTT)
68#define ISA_OSC_UDP_CLIENT(x) ((x)->tag & O2TAG_OSC_UDP_CLIENT)
69#define ISA_OSC_TCP_CLIENT(x) ((x)->tag & O2TAG_OSC_TCP_CLIENT)
70#define ISA_BRIDGE(x) ((x)->tag & O2TAG_BRIDGE)
71#define ISA_HTTP_SERVER(x) ((x)->tag & O2TAG_HTTP_SERVER)
72#define ISA_STUN_CONN(x) ((x)->tag == O2TAG_STUN)
80 ((x)->tag & (O2TAG_PROC | O2TAG_MQTT | O2TAG_OSC_UDP_CLIENT | \
81 O2TAG_OSC_TCP_CLIENT | O2TAG_BRIDGE))
87#define ISA_REMOTE_PROC(x) ((x)->tag & (O2TAG_PROC | O2TAG_MQTT))
94#define HANDLER_IS_LOCAL(x) \
95 ((x)->tag & (O2TAG_EMPTY | O2TAG_HASH | O2TAG_HANDLER))
102#define ISA_LOCAL_SERVICE(x) \
103 ((x)->tag & (O2TAG_EMPTY | O2TAG_HASH | O2TAG_HANDLER | \
104 O2TAG_OSC_UDP_CLIENT | O2TAG_OSC_TCP_CLIENT | O2TAG_BRIDGE))
108#define IS_SYNCED(x) ((x)->tag & O2TAG_SYNCED)
112int o2_strsize(
const char *s);
114void o2_string_pad(
char *dst,
const char *src);
116O2string o2_heapify(
const char *path);
137 O2node(
const char *key_,
int tag_) {
139 key = (key_ ? o2_heapify(key_) : NULL);
142 virtual ~O2node() {
if (key) O2_FREE((
char *) key); }
147 virtual const char *get_proc_name() {
return "_o2"; }
149 virtual O2status status(
const char **process) {
150 assert(HANDLER_IS_LOCAL(
this));
152 *process = get_proc_name();
158 virtual void show(
int indent);
172 O2node(key_, O2TAG_HASH | O2TAG_OWNED_BY_TREE) {
184 bool empty() {
return num_children == 0; }
186 void show(
int indent);
188 O2node **lookup(O2string key);
196 Hash_node *tree_insert_node(O2string key);
197 O2err entry_remove_by_name(O2string key);
200 void table_init(
int locations) {
201 children.init(locations,
true);
202 children.append_space(children.get_allocated());
204 O2err table_resize(
int new_locs);
208#define TO_HASH_NODE(node) ((Hash_node *) node)
210#define TO_HASH_NODE(node) (assert(ISA_HASH(node)), \
211 (Hash_node *) (node))
249 const void *user_data;
265 O2string full_path_, O2string type_string_,
int types_len_,
266 bool coerce_flag_,
bool parse_args_) :
267 O2node(key, O2TAG_HANDLER | O2TAG_OWNED_BY_TREE) {
268 handler = h; user_data = user_data_; full_path = full_path_;
275 handler = src->handler; user_data = src->user_data;
284 void show(
int indent);
293 Proxy_info(
const char *key,
int tag) :
O2node(key, tag) { fds_info = NULL; }
296 virtual void remove() { fds_info = NULL;
delete this; }
298 void delete_fds_info() {
300 fds_info->owner = NULL;
303 fds_info->close_socket(
false);
319 virtual bool local_is_synchronized() {
return false; }
327 virtual bool schedule_before_send() {
return false; };
328 virtual O2err send(
bool block) {
336 void co_info(
Fds_info *fds_info,
const char *msg) {
337 if (!fds_info)
return;
338 printf(
"%s %s (%s)\n socket %ld index %d tags %s, %s\n",
339 o2_debug_prefix, msg, key ? key :
"noname",
340 (
long) fds_info->get_socket(), fds_info->fds_index,
341 o2_tag_to_string(fds_info->net_tag), o2_tag_to_string(tag));
351#define TO_HANDLER_ENTRY(node) ((Handler_entry *) node)
353#define TO_HANDLER_ENTRY(node) (assert(ISA_HANDLER(node)), \
354 (Handler_entry *) node)
358void o2_fds_info_debug_predelete(
Fds_info *info);
Definition: o2network.h:147
int coerce_flag
Definition: o2node.h:258
int types_len
the length of type_string
Definition: o2node.h:257
O2string type_string
types expected by handler, or NULL to ignore
Definition: o2node.h:256
int parse_args
boolean - send argc and argv to handler?
Definition: o2node.h:262
O2err insert(O2node *entry)
add an entry to a hash table
Definition: hashnode.cpp:45
Definition: o2network.h:121
void o2_drop_message(const char *warn, bool free_the_msg)
Tell world that a message was dropped.
Definition: msgsend.cpp:209
bool o2_clock_is_synchronized
A variable indicating that the clock is the reference or is synchronized to the reference.
Definition: clock.cpp:26
void(* O2method_handler)(const o2_msg_data_ptr msg, const char *types, O2arg_ptr *argv, int argc, const void *user_data)
callback function to receive an O2 message
Definition: o2.h:880
O2status
Status return codes for the o2_status function.
Definition: o2.h:435
O2err
return values used generally by O2 functions
Definition: o2.h:329
@ O2_LOCAL
local service with clock sync.
Definition: o2.h:496
@ O2_LOCAL_NOTIME
local service, no clock sync yet.
Definition: o2.h:445
@ O2_FAIL
a non-specific error occurred.
Definition: o2.h:339
an O2 message container
Definition: o2.h:690
data part of an O2 message
Definition: o2.h:638
Definition: o2network.h:57