FD.io VPP  v21.01
Vector Packet Processing
api_helper_macros.h File Reference

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_MSG_ID_BASE   0
 
#define REPLY_MACRO(t)
 
#define REPLY_MACRO_END(t)
 
#define REPLY_MACRO2(t, body)
 
#define REPLY_MACRO2_END(t, body)
 
#define REPLY_MACRO2_ZERO(t, body)
 
#define REPLY_MACRO_DETAILS2(t, body)
 
#define REPLY_MACRO_DETAILS4(t, rp, context, body)
 
#define REPLY_MACRO3(t, n, body)
 
#define REPLY_MACRO3_ZERO(t, n, body)
 
#define REPLY_MACRO4(t, n, body)
 
#define REPLY_AND_DETAILS_MACRO(t, p, body)
 
#define REPLY_AND_DETAILS_VEC_MACRO(t, v, mp, rmp, rv, 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 VALIDATE_BD_ID(mp)
 
#define BAD_BD_ID_LABEL
 
#define pub_sub_handler(lca, UCA)
 
#define foreach_registration_hash
 

Functions

static uword vnet_sw_if_index_is_api_valid (u32 sw_if_index)
 

Variables

vpe_api_main_t vpe_api_main
 

Macro Definition Documentation

◆ BAD_BD_ID_LABEL

#define BAD_BD_ID_LABEL
Value:
do { \
bad_bd_id: \
; \
} while (0);

Definition at line 319 of file api_helper_macros.h.

◆ BAD_RX_SW_IF_INDEX_LABEL

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

Definition at line 291 of file api_helper_macros.h.

◆ BAD_SW_IF_INDEX_LABEL

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

Definition at line 277 of file api_helper_macros.h.

◆ BAD_TX_SW_IF_INDEX_LABEL

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

Definition at line 305 of file api_helper_macros.h.

◆ f64_endian

#define f64_endian (   a)

Definition at line 23 of file api_helper_macros.h.

◆ f64_print

#define f64_print (   a,
  b 
)

Definition at line 24 of file api_helper_macros.h.

◆ foreach_registration_hash

#define foreach_registration_hash
Value:
_(interface_events) \
_(to_netconf_server) \
_(from_netconf_server) \
_(to_netconf_client) \
_(from_netconf_client) \
_(oam_events) \
_(bfd_events) \
_(l2_arp_term_events) \
_(ip6_ra_events) \
_(dhcp6_pd_reply_events) \
_(dhcp6_reply_events) \
_(vrrp_vr_events)

Definition at line 382 of file api_helper_macros.h.

◆ pub_sub_handler

#define pub_sub_handler (   lca,
  UCA 
)

Definition at line 325 of file api_helper_macros.h.

◆ REPLY_AND_DETAILS_MACRO

#define REPLY_AND_DETAILS_MACRO (   t,
  p,
  body 
)
Value:
do { \
vl_api_registration_t *rp; \
rp = vl_api_client_index_to_registration (mp->client_index); \
if (rp == 0) \
return; \
u32 cursor = clib_net_to_host_u32 (mp->cursor); \
vlib_main_t *vm = vlib_get_main (); \
f64 start = vlib_time_now (vm); \
if (pool_is_free_index (p, cursor)) { \
cursor = pool_next_index (p, cursor); \
if (cursor == ~0) \
rv = VNET_API_ERROR_INVALID_VALUE; \
} \
while (cursor != ~0) { \
do {body;} while (0); \
cursor = pool_next_index (p, cursor); \
if (vl_api_process_may_suspend (vm, rp, start)) { \
if (cursor != ~0) \
rv = VNET_API_ERROR_EAGAIN; \
break; \
} \
} \
REPLY_MACRO2 (t, ({ \
rmp->cursor = clib_host_to_net_u32 (cursor); \
})); \
} while(0);
#define pool_next_index(P, I)
Return next occupied pool index after i, useful for safe iteration.
Definition: pool.h:554
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:334
vlib_main_t * vm
Definition: in2out_ed.c:1578
static int vl_api_process_may_suspend(vlib_main_t *vm, vl_api_registration_t *rp, f64 start)
Definition: api.h:66
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:298
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23

Definition at line 204 of file api_helper_macros.h.

◆ REPLY_AND_DETAILS_VEC_MACRO

#define REPLY_AND_DETAILS_VEC_MACRO (   t,
  v,
  mp,
  rmp,
  rv,
  body 
)
Value:
do { \
vl_api_registration_t *rp; \
rp = vl_api_client_index_to_registration (mp->client_index); \
if (rp == 0) \
return; \
u32 cursor = clib_net_to_host_u32 (mp->cursor); \
vlib_main_t *vm = vlib_get_main (); \
f64 start = vlib_time_now (vm); \
if (!v || vec_len (v) == 0) { \
cursor = ~0; \
rv = VNET_API_ERROR_INVALID_VALUE; \
} else if (cursor == ~0) \
cursor = 0; \
while (cursor != ~0 && cursor < vec_len (v)) { \
do {body;} while (0); \
++cursor; \
if (vl_api_process_may_suspend (vm, rp, start)) { \
if (cursor < vec_len (v)) \
rv = VNET_API_ERROR_EAGAIN; \
break; \
} \
} \
REPLY_MACRO2 (t, ({ \
rmp->cursor = clib_host_to_net_u32 (cursor); \
})); \
} while(0);
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:334
vlib_main_t * vm
Definition: in2out_ed.c:1578
static int vl_api_process_may_suspend(vlib_main_t *vm, vl_api_registration_t *rp, f64 start)
Definition: api.h:66
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)

Definition at line 232 of file api_helper_macros.h.

◆ REPLY_MACRO

#define REPLY_MACRO (   t)
Value:
do { \
vl_api_registration_t *rp; \
rv = vl_msg_api_pd_handler (mp, rv); \
rp = vl_api_client_index_to_registration (mp->client_index); \
if (rp == 0) \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE)); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
vl_api_send_msg (rp, (u8 *)rmp); \
} while(0);
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1004
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
#define REPLY_MSG_ID_BASE
void * vl_msg_api_alloc(int nbytes)
unsigned char u8
Definition: types.h:56
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79

Definition at line 30 of file api_helper_macros.h.

◆ REPLY_MACRO2

#define REPLY_MACRO2 (   t,
  body 
)
Value:
do { \
vl_api_registration_t *rp; \
rv = vl_msg_api_pd_handler (mp, rv); \
rp = vl_api_client_index_to_registration (mp->client_index); \
if (rp == 0) \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE)); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
do {body;} while (0); \
vl_api_send_msg (rp, (u8 *)rmp); \
} while(0);
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1004
#define REPLY_MSG_ID_BASE
void * vl_msg_api_alloc(int nbytes)
unsigned char u8
Definition: types.h:56
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79

Definition at line 65 of file api_helper_macros.h.

◆ REPLY_MACRO2_END

#define REPLY_MACRO2_END (   t,
  body 
)
Value:
do { \
vl_api_registration_t *rp; \
rv = vl_msg_api_pd_handler (mp, rv); \
rp = vl_api_client_index_to_registration (mp->client_index); \
if (rp == 0) \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
rmp->_vl_msg_id = t+(REPLY_MSG_ID_BASE); \
rmp->context = mp->context; \
rmp->retval = rv; \
do {body;} while (0); \
api_main_t *am = vlibapi_get_main (); \
void (*endian_fp) (void *); \
endian_fp = am->msg_endian_handlers[t+(REPLY_MSG_ID_BASE)]; \
(*endian_fp) (rmp); \
vl_api_send_msg (rp, (u8 *)rmp); \
} while(0);
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1004
#define REPLY_MSG_ID_BASE
void * vl_msg_api_alloc(int nbytes)
unsigned char u8
Definition: types.h:56
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:389

Definition at line 81 of file api_helper_macros.h.

◆ REPLY_MACRO2_ZERO

#define REPLY_MACRO2_ZERO (   t,
  body 
)
Value:
do { \
vl_api_registration_t *rp; \
rv = vl_msg_api_pd_handler (mp, rv); \
rp = vl_api_client_index_to_registration (mp->client_index); \
if (rp == 0) \
return; \
\
rmp = vl_msg_api_alloc_zero (sizeof (*rmp)); \
rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE)); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
do {body;} while (0); \
vl_api_send_msg (rp, (u8 *)rmp); \
} while(0);
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1004
#define REPLY_MSG_ID_BASE
void * vl_msg_api_alloc_zero(int nbytes)
unsigned char u8
Definition: types.h:56
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79

Definition at line 101 of file api_helper_macros.h.

◆ REPLY_MACRO3

#define REPLY_MACRO3 (   t,
  n,
  body 
)
Value:
do { \
vl_api_registration_t *rp; \
rv = vl_msg_api_pd_handler (mp, rv); \
rp = vl_api_client_index_to_registration (mp->client_index); \
if (rp == 0) \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp) + n); \
rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE)); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
do {body;} while (0); \
vl_api_send_msg (rp, (u8 *)rmp); \
} while(0);
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1004
#define REPLY_MSG_ID_BASE
void * vl_msg_api_alloc(int nbytes)
unsigned char u8
Definition: types.h:56
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79

Definition at line 141 of file api_helper_macros.h.

◆ REPLY_MACRO3_ZERO

#define REPLY_MACRO3_ZERO (   t,
  n,
  body 
)
Value:
do { \
vl_api_registration_t *rp; \
rv = vl_msg_api_pd_handler (mp, rv); \
rp = vl_api_client_index_to_registration (mp->client_index); \
if (rp == 0) \
return; \
\
rmp = vl_msg_api_alloc_zero (sizeof (*rmp) + n); \
rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE)); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
do {body;} while (0); \
vl_api_send_msg (rp, (u8 *)rmp); \
} while(0);
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1004
#define REPLY_MSG_ID_BASE
void * vl_msg_api_alloc_zero(int nbytes)
unsigned char u8
Definition: types.h:56
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79

Definition at line 157 of file api_helper_macros.h.

◆ REPLY_MACRO4

#define REPLY_MACRO4 (   t,
  n,
  body 
)
Value:
do { \
vl_api_registration_t *rp; \
u8 is_error = 0; \
rv = vl_msg_api_pd_handler (mp, rv); \
\
rp = vl_api_client_index_to_registration (mp->client_index); \
if (rp == 0) \
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; \
clib_memset (rmp, 0, sizeof (*rmp)); \
rv = VNET_API_ERROR_TABLE_TOO_BIG; \
is_error = 1; \
} \
rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE)); \
rmp->context = mp->context; \
rmp->retval = ntohl(rv); \
if (!is_error) \
do {body;} while (0); \
vl_api_send_msg (rp, (u8 *)rmp); \
} while(0);
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1004
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define REPLY_MSG_ID_BASE
void * vl_msg_api_alloc(int nbytes)
unsigned char u8
Definition: types.h:56
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
void * vl_msg_api_alloc_or_null(int nbytes)

Definition at line 173 of file api_helper_macros.h.

◆ REPLY_MACRO_DETAILS2

#define REPLY_MACRO_DETAILS2 (   t,
  body 
)
Value:
do { \
vl_api_registration_t *rp; \
rv = vl_msg_api_pd_handler (mp, rv); \
rp = vl_api_client_index_to_registration (mp->client_index); \
if (rp == 0) \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE)); \
rmp->context = mp->context; \
do {body;} while (0); \
vl_api_send_msg (rp, (u8 *)rmp); \
} while(0);
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1004
#define REPLY_MSG_ID_BASE
void * vl_msg_api_alloc(int nbytes)
unsigned char u8
Definition: types.h:56
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79

Definition at line 117 of file api_helper_macros.h.

◆ REPLY_MACRO_DETAILS4

#define REPLY_MACRO_DETAILS4 (   t,
  rp,
  context,
  body 
)
Value:
do { \
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
rmp->_vl_msg_id = htons((t)+(REPLY_MSG_ID_BASE)); \
rmp->context = context; \
do {body;} while (0); \
vl_api_send_msg (rp, (u8 *)rmp); \
} while(0);
#define REPLY_MSG_ID_BASE
void * vl_msg_api_alloc(int nbytes)
unsigned char u8
Definition: types.h:56

Definition at line 132 of file api_helper_macros.h.

◆ REPLY_MACRO_END

#define REPLY_MACRO_END (   t)
Value:
do { \
vl_api_registration_t *rp; \
rv = vl_msg_api_pd_handler (mp, rv); \
rp = vl_api_client_index_to_registration (mp->client_index); \
if (rp == 0) \
return; \
\
rmp = vl_msg_api_alloc (sizeof (*rmp)); \
rmp->_vl_msg_id = t+(REPLY_MSG_ID_BASE); \
rmp->context = mp->context; \
rmp->retval = rv; \
api_main_t *am = vlibapi_get_main (); \
void (*endian_fp) (void *); \
endian_fp = am->msg_endian_handlers[t+(REPLY_MSG_ID_BASE)]; \
(*endian_fp) (rmp); \
vl_api_send_msg (rp, (u8 *)rmp); \
} while(0);
int vl_msg_api_pd_handler(void *mp, int rv)
Definition: api_shared.c:1004
#define REPLY_MSG_ID_BASE
void * vl_msg_api_alloc(int nbytes)
unsigned char u8
Definition: types.h:56
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:389

Definition at line 46 of file api_helper_macros.h.

◆ REPLY_MSG_ID_BASE

#define REPLY_MSG_ID_BASE   0

Definition at line 27 of file api_helper_macros.h.

◆ VALIDATE_BD_ID

#define VALIDATE_BD_ID (   mp)
Value:
do { u32 __rx_bd_id = ntohl(mp->bd_id); \
if (__rx_bd_id > L2_BD_ID_MAX) { \
rv = VNET_API_ERROR_BD_ID_EXCEED_MAX; \
goto bad_bd_id; \
} \
} while(0);
unsigned int u32
Definition: types.h:88
#define L2_BD_ID_MAX
Definition: l2_bd.h:116

Definition at line 311 of file api_helper_macros.h.

◆ VALIDATE_RX_SW_IF_INDEX

#define VALIDATE_RX_SW_IF_INDEX (   mp)
Value:
do { u32 __rx_sw_if_index = ntohl((mp)->rx_sw_if_index); \
if (!vnet_sw_if_index_is_api_valid(__rx_sw_if_index)) { \
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
goto bad_rx_sw_if_index; \
} \
} while(0);
unsigned int u32
Definition: types.h:88
static uword vnet_sw_if_index_is_api_valid(u32 sw_if_index)

Definition at line 283 of file api_helper_macros.h.

◆ VALIDATE_SW_IF_INDEX

#define VALIDATE_SW_IF_INDEX (   mp)
Value:
do { u32 __sw_if_index = ntohl((mp)->sw_if_index); \
if (!vnet_sw_if_index_is_api_valid(__sw_if_index)) { \
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
goto bad_sw_if_index; \
} \
} while(0);
unsigned int u32
Definition: types.h:88
static uword vnet_sw_if_index_is_api_valid(u32 sw_if_index)
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34

Definition at line 269 of file api_helper_macros.h.

◆ VALIDATE_TX_SW_IF_INDEX

#define VALIDATE_TX_SW_IF_INDEX (   mp)
Value:
do { u32 __tx_sw_if_index = ntohl(mp->tx_sw_if_index); \
if (!vnet_sw_if_index_is_api_valid(__tx_sw_if_index)) { \
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
goto bad_tx_sw_if_index; \
} \
} while(0);
unsigned int u32
Definition: types.h:88
static uword vnet_sw_if_index_is_api_valid(u32 sw_if_index)

Definition at line 297 of file api_helper_macros.h.

Function Documentation

◆ vnet_sw_if_index_is_api_valid()

static uword vnet_sw_if_index_is_api_valid ( u32  sw_if_index)
inlinestatic

Definition at line 264 of file api_helper_macros.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ vpe_api_main

vpe_api_main_t vpe_api_main

Definition at line 54 of file interface_api.c.