FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
api_helper_macros.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vpe_client_registration_t
 
struct  vpe_api_main_t
 

Macros

#define f64_endian(a)
 
#define f64_print(a, b)
 
#define REPLY_MACRO(t)
 
#define REPLY_MACRO2(t, body)
 
#define REPLY_MACRO3(t, n, body)
 
#define REPLY_MACRO4(t, n, body)
 
#define VALIDATE_SW_IF_INDEX(mp)
 
#define BAD_SW_IF_INDEX_LABEL
 
#define VALIDATE_RX_SW_IF_INDEX(mp)
 
#define BAD_RX_SW_IF_INDEX_LABEL
 
#define VALIDATE_TX_SW_IF_INDEX(mp)
 
#define BAD_TX_SW_IF_INDEX_LABEL
 
#define pub_sub_handler(lca, UCA)
 
#define foreach_registration_hash
 

Variables

vpe_api_main_t vpe_api_main
 

Macro Definition Documentation

#define BAD_RX_SW_IF_INDEX_LABEL
Value:
do { \
bad_rx_sw_if_index: \
; \
} while (0);

Definition at line 133 of file api_helper_macros.h.

#define BAD_SW_IF_INDEX_LABEL
Value:
do { \
bad_sw_if_index: \
; \
} while (0);

Definition at line 117 of file api_helper_macros.h.

#define BAD_TX_SW_IF_INDEX_LABEL
Value:
do { \
bad_tx_sw_if_index: \
; \
} while (0);

Definition at line 149 of file api_helper_macros.h.

#define f64_endian (   a)

Definition at line 24 of file api_helper_macros.h.

#define f64_print (   a,
 
)

Definition at line 25 of file api_helper_macros.h.

#define foreach_registration_hash
Value:
_(interface_events) \
_(to_netconf_server) \
_(from_netconf_server) \
_(to_netconf_client) \
_(from_netconf_client) \
_(oam_events) \
_(bfd_events)

Definition at line 194 of file api_helper_macros.h.

#define pub_sub_handler (   lca,
  UCA 
)
Value:
static void vl_api_want_##lca##_t_handler ( \
vl_api_want_##lca##_t *mp) \
{ \
vpe_api_main_t *vam = &vpe_api_main; \
vpe_client_registration_t *rp; \
vl_api_want_##lca##_reply_t *rmp; \
uword *p; \
i32 rv = 0; \
\
p = hash_get (vam->lca##_registration_hash, mp->client_index); \
if (p) { \
if (mp->enable_disable) { \
clib_warning ("pid %d: already enabled...", mp->pid); \
rv = VNET_API_ERROR_INVALID_REGISTRATION; \
goto reply; \
} else { \
rp = pool_elt_at_index (vam->lca##_registrations, p[0]); \
pool_put (vam->lca##_registrations, rp); \
hash_unset (vam->lca##_registration_hash, \
mp->client_index); \
goto reply; \
} \
} \
if (mp->enable_disable == 0) { \
clib_warning ("pid %d: already disabled...", mp->pid); \
rv = VNET_API_ERROR_INVALID_REGISTRATION; \
goto reply; \
} \
pool_get (vam->lca##_registrations, rp); \
rp->client_index = mp->client_index; \
rp->client_pid = mp->pid; \
hash_set (vam->lca##_registration_hash, rp->client_index, \
rp - vam->lca##_registrations); \
\
reply: \
REPLY_MACRO (VL_API_WANT_##UCA##_REPLY); \
}
#define hash_set(h, key, value)
Definition: hash.h:254
#define hash_unset(h, key)
Definition: hash.h:260
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:200
int i32
Definition: types.h:81
#define clib_warning(format, args...)
Definition: error.h:59
#define hash_get(h, key)
Definition: hash.h:248
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:214
#define REPLY_MACRO(t)
u64 uword
Definition: types.h:112
vpe_api_main_t vpe_api_main
Definition: api.c:324

Definition at line 155 of file api_helper_macros.h.

#define REPLY_MACRO (   t)
Value:
do { \
rv = vl_msg_api_pd_handler (mp, rv); \
q = vl_api_client_index_to_input_queue (mp->client_index); \
if (!q) \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
rmp->_vl_msg_id = ntohs((t)); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
vl_msg_api_send_shmem (q, (u8 *)&rmp); \
} while(0);
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
void * vl_msg_api_alloc(int nbytes)
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1280
unsigned char u8
Definition: types.h:56
struct _unix_shared_memory_queue unix_shared_memory_queue_t

Definition at line 27 of file api_helper_macros.h.

#define REPLY_MACRO2 (   t,
  body 
)
Value:
do { \
rv = vl_msg_api_pd_handler (mp, rv); \
q = vl_api_client_index_to_input_queue (mp->client_index); \
if (!q) \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
rmp->_vl_msg_id = ntohs((t)); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
do {body;} while (0); \
vl_msg_api_send_shmem (q, (u8 *)&rmp); \
} while(0);
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
void * vl_msg_api_alloc(int nbytes)
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1280
unsigned char u8
Definition: types.h:56
struct _unix_shared_memory_queue unix_shared_memory_queue_t

Definition at line 43 of file api_helper_macros.h.

#define REPLY_MACRO3 (   t,
  n,
  body 
)
Value:
do { \
rv = vl_msg_api_pd_handler (mp, rv); \
q = vl_api_client_index_to_input_queue (mp->client_index); \
if (!q) \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp) + n); \
rmp->_vl_msg_id = ntohs((t)); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
do {body;} while (0); \
vl_msg_api_send_shmem (q, (u8 *)&rmp); \
} while(0);
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
void * vl_msg_api_alloc(int nbytes)
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1280
unsigned char u8
Definition: types.h:56
struct _unix_shared_memory_queue unix_shared_memory_queue_t

Definition at line 59 of file api_helper_macros.h.

#define REPLY_MACRO4 (   t,
  n,
  body 
)
Value:
do { \
u8 is_error = 0; \
rv = vl_msg_api_pd_handler (mp, rv); \
q = vl_api_client_index_to_input_queue (mp->client_index); \
if (!q) \
return; \
\
rmp = vl_msg_api_alloc_or_null (sizeof (*rmp) + n); \
if (!rmp) \
{ \
/* if there isn't enough memory, try to allocate */ \
/* some at least for returning an error */ \
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
if (!rmp) \
return; \
\
memset (rmp, 0, sizeof (*rmp)); \
rv = VNET_API_ERROR_TABLE_TOO_BIG; \
is_error = 1; \
} \
rmp->_vl_msg_id = ntohs((t)); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
if (!is_error) \
do {body;} while (0); \
vl_msg_api_send_shmem (q, (u8 *)&rmp); \
} while(0);
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
void * vl_msg_api_alloc(int nbytes)
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1280
unsigned char u8
Definition: types.h:56
void * vl_msg_api_alloc_or_null(int nbytes)
struct _unix_shared_memory_queue unix_shared_memory_queue_t

Definition at line 75 of file api_helper_macros.h.

#define VALIDATE_RX_SW_IF_INDEX (   mp)
Value:
do { u32 __rx_sw_if_index = ntohl(mp->rx_sw_if_index); \
if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
__rx_sw_if_index)) { \
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
goto bad_rx_sw_if_index; \
} \
} while(0);
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:211
unsigned int u32
Definition: types.h:88
struct vnet_main_t vnet_main_t

Definition at line 123 of file api_helper_macros.h.

#define VALIDATE_SW_IF_INDEX (   mp)
Value:
do { u32 __sw_if_index = ntohl(mp->sw_if_index); \
if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
__sw_if_index)) { \
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
goto bad_sw_if_index; \
} \
} while(0);
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:211
unsigned int u32
Definition: types.h:88
struct vnet_main_t vnet_main_t

Definition at line 107 of file api_helper_macros.h.

#define VALIDATE_TX_SW_IF_INDEX (   mp)
Value:
do { u32 __tx_sw_if_index = ntohl(mp->tx_sw_if_index); \
if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
__tx_sw_if_index)) { \
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
goto bad_tx_sw_if_index; \
} \
} while(0);
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:211
unsigned int u32
Definition: types.h:88
struct vnet_main_t vnet_main_t

Definition at line 139 of file api_helper_macros.h.

Variable Documentation

vpe_api_main_t vpe_api_main

Definition at line 324 of file api.c.