89#define O2L_VERSION 0x020000
92#if (!defined(O2LDEBUG))
101#define O2LDB if (O2LDEBUG)
103#define O2LDBV if (O2LDEBUG && verbose)
105#if defined(O2_NO_O2DISCOVERY) && !defined(O2L_NO_BROADCAST)
106#define O2L_NO_BROADCAST 1
108#if defined(O2_NO_O2DISCOVERY) && defined(O2_NO_ZEROCONF)
109#error O2_NO_O2DISCOVERY and O2_NO_ZEROCONF are both defined - no discovery
113#if !defined(O2_NO_O2DISCOVERY) && !defined(O2_NO_ZEROCONF)
114#define O2_NO_O2DISCOVERY
115#if !defined(O2L_NO_BROADCAST)
116#define O2L_NO_BROADCAST
120#define O2_MALLOC malloc
121#define O2_CALLOC calloc
127#define MAX_MSG_LEN 256
137#define O2L_ALREADY_RUNNING -5
139typedef float o2l_time;
153typedef void (*o2l_handler)(
o2l_msg_ptr msg,
const char *types,
154 void *data,
void *info);
160extern o2l_time o2l_local_now;
178void o2l_send_start(
const char *address, o2l_time time,
179 const char *types,
bool tcp);
220void o2l_method_new(
const char *path,
const char *typespec,
221 bool full, o2l_handler h,
void *info);
224o2l_time o2l_local_time();
230o2l_time o2l_time_get();
240void connect_to_wifi(
const char *hostname,
const char *ssid,
const char *pwd);
262int o2l_initialize(
const char *ensemble);
268void o2l_add_string(
const char *s);
271void o2l_add_time(
double time);
274#define o2l_add_double(x) o2l_add_time(x)
277void o2l_add_float(
float x);
280#define o2l_add_int(i) o2l_add_int32(i)
283void o2l_add_int32(int32_t i);
299double o2l_get_timestamp();
302double o2l_get_time();
305#define o2l_get_double() o2l_get_time()
308float o2l_get_float();
311int32_t o2l_get_int32();
314#define o2l_get_int(i) o2l_get_int32(i)
320char *o2l_get_string();
339void o2l_set_services(
const char *services);
355extern char o2l_remote_ip_port[16];
365extern int o2l_bridge_id;
372#define IS_BIG_ENDIAN (BYTE_ORDER != LITTLE_ENDIAN)
377 #include "machine/endian.h"
378 #define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
381 #define LITTLE_ENDIAN __LITTLE_ENDIAN
382 #define BYTE_ORDER __BYTE_ORDER
384 #define IS_BIG_ENDIAN (BYTE_ORDER != LITTLE_ENDIAN)
386#define IS_LITTLE_ENDIAN (!(IS_BIG_ENDIAN))
388#define o2lswap16(i) ((((i) >> 8) & 0xff) | (((i) & 0xff) << 8))
389#define o2lswap32(i) ((((i) >> 24) & 0xff) | (((i) & 0xff0000) >> 8) | \
390 (((i) & 0xff00) << 8) | (((i) & 0xff) << 24))
391#define o2lswap64(i) ((((uint64_t) o2lswap32(i)) << 32) | o2lswap32((i) >> 32))
393#define o2lswap16(i) (i)
394#define o2lswap32(i) (i)
395#define o2lswap64(i) (i)
406#include <sys/select.h>
423int o2ldisc_init(
const char *ensemble);
431void o2ldisc_events(fd_set *readset);
437#define INVALID_SOCKET -1
438#define SOCKET_ERROR -1
442extern SOCKET tcp_sock;
443extern const char *o2l_ensemble;
444extern struct sockaddr_in udp_server_sa;
445extern int udp_recv_port;
446extern SOCKET udp_recv_sock;
448bool o2l_is_valid_proc_name(
const char *name,
int port,
449 char *internal_ip,
int *udp_port);
451int o2l_parse_version(
const char *vers,
int vers_len);
453int o2l_address_init(
struct sockaddr_in *sa,
const char *ip,
int port_num,
456void o2l_network_connect(
const char *ip,
int port);
458void o2l_add_socket(SOCKET s);
460int o2l_bind_recv_socket(SOCKET sock,
int *port);