16 #ifndef HICN_API_PRIVATE_H
17 #define HICN_API_PRIVATE_H
20 #include <hicn/ctrl/commands.h>
21 #include <hicn/util/token.h>
22 #include <hicn/util/log.h>
23 #include <hicn/util/map.h>
25 #define INT_CMP(x, y) ((x > y) ? 1 : (x < y) ? -1 : 0)
26 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(*array))
30 #define RANDBYTE() (u8)(arc4random() & 0xFF)
32 #define RANDBYTE() (u8)(random() & 0xFF)
35 #define RANDBYTE() (u8)(rand() & 0xFF)
38 connection_type_from_str(
const char * str);
40 extern const hc_connection_type_t map_from_list_connections_type[];
41 extern const hc_connection_type_t map_from_encap_type[];
42 extern const connection_type map_to_connection_type[];
43 extern const listener_mode map_to_listener_mode[];
44 extern const hc_connection_state_t map_from_list_connections_state[];
45 extern const int map_from_addr_type[];
46 extern const address_type map_to_addr_type[];
47 extern const char * connection_state_str[];
48 extern const char * connection_type_str[];
58 #define connection_state_to_face_state(x) ((face_state_t)(x))
59 #define face_state_to_connection_state(x) ((hc_connection_state_t)(x))
61 #define IS_VALID_ADDR_TYPE(x) ((x >= ADDR_INET) && (x <= ADDR_UNIX))
63 #define IS_VALID_CONNECTION_TYPE(x) IS_VALID_ENUM_TYPE(CONNECTION_TYPE, x)
65 typedef struct hc_sock_impl_s hc_sock_impl_t;
67 int hc_data_ensure_available(
hc_data_t * data,
size_t count);
72 hc_connection_parse_to_face(
void * in,
hc_face_t * face);
90 int (*hc_sock_get_next_seq)(
hc_sock_t *s);
91 int (*hc_sock_set_nonblocking)(
hc_sock_t *s);
94 int (*hc_sock_get_available)(
hc_sock_t *s, u8 **buffer,
size_t *size);
118 int (*hc_connection_update_by_id)(
hc_sock_t *s,
int hc_connection_id,
129 int (*hc_connection_set_admin_state)(
hc_sock_t * s,
const char * conn_id_or_name, face_state_t state);
130 int (*hc_connection_set_admin_state_async)(
hc_sock_t * s,
const char * conn_id_or_name, face_state_t state);
133 int (*hc_connection_set_priority)(
hc_sock_t * s,
const char * conn_id_or_name, uint32_t priority);
134 int (*hc_connection_set_priority_async)(
hc_sock_t * s,
const char * conn_id_or_name, uint32_t priority);
135 int (*hc_connection_set_tags)(
hc_sock_t * s,
const char * conn_id_or_name, policy_tags_t tags);
136 int (*hc_connection_set_tags_async)(
hc_sock_t * s,
const char * conn_id_or_name, policy_tags_t tags);
137 #endif // WITH_POLICY
139 int (*hc_connection_snprintf)(
char *s,
size_t size,
147 int (*hc_face_set_admin_state)(
hc_sock_t * s,
const char * conn_id_or_name, face_state_t state);
148 int (*hc_face_set_admin_state_async)(
hc_sock_t * s,
const char * conn_id_or_name, face_state_t state);
151 int (*hc_face_set_priority)(
hc_sock_t * s,
const char * conn_id_or_name, uint32_t priority);
152 int (*hc_face_set_priority_async)(
hc_sock_t * s,
const char * conn_id_or_name, uint32_t priority);
153 int (*hc_face_set_tags)(
hc_sock_t * s,
const char * conn_id_or_name, policy_tags_t tags);
154 int (*hc_face_set_tags_async)(
hc_sock_t * s,
const char * conn_id_or_name, policy_tags_t tags);
155 #endif // WITH_POLICY
157 int (*hc_face_snprintf)(
char *s,
size_t size,
hc_face_t *face);
159 int (*hc_route_parse)(
void *in,
hc_route_t *route);
165 int (*hc_route_list_async)(
hc_sock_t * s);
173 int (*hc_punting_validate)(
const hc_punting_t *punting);
175 int (*hc_punting_parse)(
void *in,
hc_punting_t *punting);
177 int (*hc_cache_set_store)(
hc_sock_t *s,
int enabled);
178 int (*hc_cache_set_serve)(
hc_sock_t *s,
int enabled);
179 int (*hc_cache_set_store_async)(
hc_sock_t *s,
int enabled);
180 int (*hc_cache_set_serve_async)(
hc_sock_t *s,
int enabled);
183 int (*hc_strategy_snprintf)(
char *s,
size_t size,
hc_strategy_t *strategy);
188 int (*hc_mapme_set)(
hc_sock_t *s,
int enabled);
189 int (*hc_mapme_set_discovery)(
hc_sock_t *s,
int enabled);
190 int (*hc_mapme_set_timescale)(
hc_sock_t *s,
double timescale);
191 int (*hc_mapme_set_retx)(
hc_sock_t *s,
double timescale);
194 int (*hc_policy_parse)(
void *in, hc_policy_t *policy);
195 int (*hc_policy_create)(
hc_sock_t *s, hc_policy_t *policy);
196 int (*hc_policy_create_async)(
hc_sock_t *s, hc_policy_t *policy);
197 int (*hc_policy_delete)(
hc_sock_t *s, hc_policy_t *policy);
198 int (*hc_policy_delete_async)(
hc_sock_t *s, hc_policy_t *policy);
201 int (*hc_policy_snprintf)(
char *s,
size_t size, hc_policy_t *policy);
202 #endif // WITH_POLICY
208 #endif // HICN_API_PRIVATE_H