|
Hybrid ICN (hICN) plugin
v21.06-rc0-4-g18fa668
|
Go to the documentation of this file.
71 #include <hicn/util/ip_address.h>
72 #include <hicn/ctrl/commands.h>
75 #define HICN_DEFAULT_PORT 9695
77 #define HOTFIXMARGIN 0
87 #define DEFAULT_SIZE_LOG 3
91 #define UNION_CAST(x, destType) \
102 #define foreach_command \
112 #define _(x) ACTION_##x,
127 typedef int (*data_callback_t)(
struct hc_data_s *,
void *);
136 size_t in_element_size;
137 size_t out_element_size;
143 data_callback_t complete_cb;
144 void *complete_cb_data;
217 #define GENERATE_FIND_HEADER(TYPE) \
219 hc_ ## TYPE ## _find(hc_data_t * data, const hc_ ## TYPE ## _t * element, \
220 hc_ ## TYPE ## _t **found)
222 #define GENERATE_FIND(TYPE) \
224 hc_ ## TYPE ## _find(hc_data_t * data, const hc_ ## TYPE ## _t * element, \
225 hc_ ## TYPE ## _t **found) \
227 foreach_type(hc_ ## TYPE ## _t, x, data) { \
228 if (hc_ ## TYPE ## _cmp(x, element) == 0) { \
242 #define RECV_BUFLEN 8192
404 #define SPACE SPACES(1)
410 #define INTERFACE_LEN 16
412 #define MAXSZ_HC_NAME_ SYMBOLIC_NAME_LEN
413 #define MAXSZ_HC_NAME MAXSZ_HC_NAME_ + NULLTERM
415 #define MAXSZ_HC_ID_ 10
416 #define MAXSZ_HC_ID MAXSZ_HC_ID_ + NULLTERM
418 #define foreach_type(TYPE, VAR, data) \
419 for (TYPE *VAR = (TYPE *)data->buffer; \
420 VAR < (TYPE *)(data->buffer + data->size * data->out_element_size); \
427 #define foreach_connection_type \
435 #define _(x) CONNECTION_TYPE_##x,
438 } hc_connection_type_t;
440 #define MAXSZ_HC_CONNECTION_TYPE_ 9
441 #define MAXSZ_HC_CONNECTION_TYPE MAXSZ_HC_CONNECTION_TYPE_ + NULLTERM + HOTFIXMARGIN
443 extern const char *connection_type_str[];
445 hc_connection_type_t connection_type_from_str(
const char *str);
448 #define foreach_connection_state \
455 #define _(x) HC_CONNECTION_STATE_##x,
456 foreach_connection_state
458 } hc_connection_state_t;
460 #define MAXSZ_HC_CONNECTION_STATE_ 9
461 #define MAXSZ_HC_CONNECTION_STATE MAXSZ_HC_CONNECTION_STATE_ + NULLTERM
463 extern const char *connection_state_str[];
465 typedef int (*HC_PARSE)(
const u8 *, u8 *);
473 char name[SYMBOLIC_NAME_LEN];
474 char interface_name[INTERFACE_LEN];
476 hc_connection_type_t type;
493 #define foreach_listener(VAR, data) foreach_type(hc_listener_t, VAR, data)
495 #define MAXSZ_HC_LISTENER_ \
496 INTERFACE_LEN + SPACE + MAXSZ_URL_ + SPACE + MAXSZ_HC_CONNECTION_TYPE_
497 #define MAXSZ_HC_LISTENER MAXSZ_HC_LISTENER_ + NULLTERM
501 int hc_listener_snprintf(
char *s,
size_t size,
hc_listener_t *listener);
514 char name[SYMBOLIC_NAME_LEN];
515 char interface_name[INTERFACE_LEN];
516 hc_connection_type_t type;
522 hc_connection_state_t admin_state;
527 hc_connection_state_t state;
534 int hc_connection_update_by_id(
hc_sock_t *s,
int hc_connection_id,
549 int hc_connection_set_admin_state(
hc_sock_t * s,
const char * conn_id_or_name, face_state_t state);
551 int hc_connection_set_priority(
hc_sock_t * s,
const char * conn_id_or_name, uint32_t priority);
552 int hc_connection_set_tags(
hc_sock_t * s,
const char * conn_id_or_name, policy_tags_t tags);
555 #define foreach_connection(VAR, data) foreach_type(hc_connection_t, VAR, data)
557 #define MAXSZ_HC_CONNECTION_ \
558 MAXSZ_HC_CONNECTION_STATE_ + INTERFACE_LEN + SPACE + 2 * MAXSZ_URL_ + \
559 MAXSZ_HC_CONNECTION_TYPE_ + SPACES(3)
560 #define MAXSZ_HC_CONNECTION MAXSZ_HC_CONNECTION_ + NULLTERM
564 int hc_connection_snprintf(
char *s,
size_t size,
579 char name[SYMBOLIC_NAME_LEN];
598 int hc_face_set_admin_state(
hc_sock_t * s,
const char * conn_id_or_name, face_state_t state);
600 int hc_face_set_priority(
hc_sock_t * s,
const char * conn_id_or_name, uint32_t priority);
601 int hc_face_set_tags(
hc_sock_t * s,
const char * conn_id_or_name, policy_tags_t tags);
604 #define foreach_face(VAR, data) foreach_type(hc_face_t, VAR, data)
606 #define MAX_FACE_ID 255
607 #define MAXSZ_FACE_ID_ 3
608 #define MAXSZ_FACE_ID MAXSZ_FACE_ID_ + NULLTERM
609 #define MAXSZ_FACE_NAME_ SYMBOLIC_NAME_LEN
610 #define MAXSZ_FACE_NAME MAXSZ_FACE_NAME_ + NULLTERM
612 #define MAXSZ_HC_FACE_ MAXSZ_FACE_ID_ + MAXSZ_FACE_NAME_ + MAXSZ_FACE_ + 5 + HOTFIXMARGIN
613 #define MAXSZ_HC_FACE MAXSZ_HC_FACE_ + NULLTERM
615 int hc_face_snprintf(
char *s,
size_t size,
hc_face_t *face);
630 int hc_route_parse(
void *in,
hc_route_t *route);
637 #define foreach_route(VAR, data) foreach_type(hc_route_t, VAR, data)
639 #define MAX_COST 65535
644 #define MAXSZ_HC_ROUTE_ \
645 MAXSZ_FACE_ID + 1 + MAXSZ_COST + 1 + MAXSZ_IP_ADDRESS + 1 + MAXSZ_LEN
646 #define MAXSZ_HC_ROUTE MAXSZ_HC_ROUTE_ + NULLTERM
648 int hc_route_snprintf(
char *s,
size_t size,
hc_route_t *route);
671 #define foreach_punting(VAR, data) foreach_type(hc_punting_t, VAR, data)
673 #define MAXSZ_HC_PUNTING_ 0
674 #define MAXSZ_HC_PUNTING MAXSZ_HC_PUNTING_ + NULLTERM
678 int hc_punting_snprintf(
char *s,
size_t size,
hc_punting_t *punting);
684 int hc_cache_set_store(
hc_sock_t *s,
int enabled);
685 int hc_cache_set_serve(
hc_sock_t *s,
int enabled);
691 #define MAXSZ_STRATEGY_NAME 255
694 char name[MAXSZ_STRATEGY_NAME];
699 #define foreach_strategy(VAR, data) foreach_type(hc_strategy_t, VAR, data)
701 #define MAXSZ_HC_STRATEGY_ MAXSZ_STRATEGY_NAME
702 #define MAXSZ_HC_STRATEGY MAXSZ_HC_STRATEGY_ + NULLTERM
704 int hc_strategy_snprintf(
char *s,
size_t size,
hc_strategy_t *strategy);
720 int hc_mapme_set(
hc_sock_t *s,
int enabled);
721 int hc_mapme_set_discovery(
hc_sock_t *s,
int enabled);
722 int hc_mapme_set_timescale(
hc_sock_t *s,
double timescale);
723 int hc_mapme_set_retx(
hc_sock_t *s,
double timescale);
738 int hc_policy_parse(
void *in, hc_policy_t *policy);
740 int hc_policy_create(
hc_sock_t *s, hc_policy_t *policy);
741 int hc_policy_delete(
hc_sock_t *s, hc_policy_t *policy);
744 #define foreach_policy(VAR, data) foreach_type(hc_policy_t, VAR, data)
747 #define MAXSZ_HC_POLICY_ 0
748 #define MAXSZ_HC_POLICY MAXSZ_HC_POLICY_ + NULLTERM
750 int hc_policy_snprintf(
char *s,
size_t size, hc_policy_t *policy);
Holds the results of an hICN control request.
Definition: api.h:132
struct hc_data_s hc_data_t
Holds the results of an hICN control request.
int hc_sock_callback(hc_sock_t *s, hc_data_t **data)
Callback used in async mode when data is available on the socket.
int hc_sock_get_next_seq(hc_sock_t *s)
Returns the next available sequence number to use for requests to the API.
int hc_data_reset(hc_data_t *data)
Reset the data structure holding control data.
Definition: ip_address.h:68
void hc_data_free(hc_data_t *data)
int hc_sock_recv(hc_sock_t *s)
Helper for reading socket contents.
hc_data_t * hc_data_create(size_t in_element_size, size_t out_element_size, data_callback_t complete_cb)
int hc_face_create(hc_sock_t *s, hc_face_t *face)
Create a face.
int hc_sock_set_nonblocking(hc_sock_t *s)
Sets the socket as non-blocking.
int hc_data_set_callback(hc_data_t *data, data_callback_t cb, void *cb_data)
Configure a callback (along with private data) to be called upon completion of a request.
int hc_sock_send(hc_sock_t *s, hc_msg_t *msg, size_t msglen, int seq)
Write/read iexchance on the control socket (internal helper function)
#define GENERATE_FIND_HEADER(TYPE)
Find en element in the data structure.
Definition: api.h:217
int hc_data_set_complete(hc_data_t *data)
Mark the data structure as complete.
hc_sock_t * hc_sock_create(void)
Create an hICN control socket using the default connection type.
int hc_sock_get_available(hc_sock_t *s, u8 **buffer, size_t *size)
Return the offset and size of available buffer space.
int hc_sock_reset(hc_sock_t *s)
Reset the state of the sock (eg. to handle a reconnecton)
#define foreach_connection_type
Definition: api.h:427
int hc_data_push_many(hc_data_t *data, const void *elements, size_t count)
Adds many new results at the end of the data structure, eventually allocating buffer space for it.
hc_sock_t * hc_sock_create_forwarder(forwarder_t forwarder)
Create an hICN control socket using the provided forwarder.
u8 command_id
Definition: api.h:138
void hc_sock_free(hc_sock_t *s)
Frees an hICN control socket.
hc_sock_t * hc_sock_create_url(const char *url)
Create an hICN control socket using the specified URL.
int hc_sock_get_fd(hc_sock_t *s)
Return the file descriptor associated to the hICN contorl sock.
Definition: api_private.h:89
struct hc_msg_s hc_msg_t
hICN control message header
Definition: api.h:120
int hc_sock_connect(hc_sock_t *s)
Connect the socket.
int hc_data_push(hc_data_t *data, const void *element)
Adds a new result at the end of the data structure, eventually allocating buffer space for it.
int hc_sock_process(hc_sock_t *s, hc_data_t **data)
Processing data received by socket.