FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
vapi_internal.h
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2017 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17 
18 #ifndef VAPI_INTERNAL_H
19 #define VAPI_INTERNAL_H
20 
21 #include <endian.h>
22 #include <string.h>
23 #include <vppinfra/types.h>
24 
25 /**
26  * @file vapi_internal.h
27  *
28  * internal vpp api C declarations
29  *
30  * This file contains internal vpp api C declarations. It's not intended to be
31  * used by the client programmer and the API defined here might change at any
32  * time..
33  */
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 struct vapi_ctx_s;
40 
41 typedef struct __attribute__ ((__packed__))
42 {
43  u16 _vl_msg_id;
46 
47 typedef struct __attribute__ ((__packed__))
48 {
49  u16 _vl_msg_id;
53 
54 static inline void
56 {
57  h->_vl_msg_id = htobe16 (h->_vl_msg_id);
58 }
59 
60 static inline void
62 {
63  h->_vl_msg_id = be16toh (h->_vl_msg_id);
64 }
65 
66 static inline void
68 {
69  h->_vl_msg_id = htobe16 (h->_vl_msg_id);
70 }
71 
72 static inline void
74 {
75  h->_vl_msg_id = be16toh (h->_vl_msg_id);
76 }
77 
78 
79 #include <vapi/vapi.h>
80 
81 typedef vapi_error_e (*vapi_cb_t) (struct vapi_ctx_s *, void *, vapi_error_e,
82  bool, void *);
83 
84 typedef void (*generic_swap_fn_t) (void *payload);
85 
86 typedef struct
87 {
88  const char *name;
89  size_t name_len;
90  const char *name_with_crc;
93  unsigned int context_offset;
94  unsigned int payload_offset;
95  size_t size;
98  vapi_msg_id_t id; /* assigned at run-time */
100 
101 typedef struct
102 {
103  const char *name;
105  size_t size;
106  void (*swap_to_be) (void *payload);
107  void (*swap_to_host) (void *payload);
109 
120 void vapi_store_request (vapi_ctx_t ctx, u32 context, bool is_dump,
121  vapi_cb_t callback, void *callback_ctx);
123 void (*vapi_get_swap_to_host_func (vapi_msg_id_t id)) (void *payload);
124 void (*vapi_get_swap_to_be_func (vapi_msg_id_t id)) (void *payload);
128 size_t vapi_get_message_count();
129 const char *vapi_get_msg_name(vapi_msg_id_t id);
130 
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif
vapi_error_e
vapi_error_e
Definition: vapi_common.h:25
vapi_requests_empty
bool vapi_requests_empty(vapi_ctx_t ctx)
Definition: vapi.c:114
vapi_get_client_index
int vapi_get_client_index(vapi_ctx_t ctx)
Definition: vapi.c:865
vapi_ctx_s
Definition: vapi.c:75
vapi_message_desc_t::name
const char * name
Definition: vapi_internal.h:88
vapi_get_message_count
size_t vapi_get_message_count()
Definition: vapi.c:974
vapi_producer_unlock
vapi_error_e vapi_producer_unlock(vapi_ctx_t ctx)
Definition: vapi.c:960
vapi_is_nonblocking
bool vapi_is_nonblocking(vapi_ctx_t ctx)
Definition: vapi.c:871
vapi_type_msg_header1_t_ntoh
static void vapi_type_msg_header1_t_ntoh(vapi_type_msg_header1_t *h)
Definition: vapi_internal.h:61
types.h
vapi_gen_req_context
u32 vapi_gen_req_context(vapi_ctx_t ctx)
Definition: vapi.c:94
string.h
vapi_get_payload_offset
int vapi_get_payload_offset(vapi_msg_id_t id)
Definition: vapi.c:883
vapi_message_desc_t::id
vapi_msg_id_t id
Definition: vapi_internal.h:98
u16
unsigned short u16
Definition: types.h:57
vapi_event_desc_t::payload_offset
int payload_offset
Definition: vapi_internal.h:104
vapi_message_desc_t::context_offset
unsigned int context_offset
Definition: vapi_internal.h:93
vapi_lookup_vapi_msg_id_t
vapi_msg_id_t vapi_lookup_vapi_msg_id_t(vapi_ctx_t ctx, u16 vl_msg_id)
Definition: vapi.c:245
vapi_get_swap_to_be_func
void(*)(void *payload) vapi_get_swap_to_be_func(vapi_msg_id_t id)
Definition: vapi_internal.h:124
h
h
Definition: flowhash_template.h:372
vapi_type_msg_header2_t::context
u32 context
Definition: vapi_internal.h:51
vapi_type_msg_header1_t::context
u32 context
Definition: vapi_internal.h:44
vapi_requests_full
bool vapi_requests_full(vapi_ctx_t ctx)
Definition: vapi.c:108
vapi_msg_is_with_context
bool vapi_msg_is_with_context(vapi_msg_id_t id)
Definition: vapi.c:749
vapi_store_request
void vapi_store_request(vapi_ctx_t ctx, u32 context, bool is_dump, vapi_cb_t callback, void *callback_ctx)
Definition: vapi.c:126
vapi_producer_lock
vapi_error_e vapi_producer_lock(vapi_ctx_t ctx)
Definition: vapi.c:947
vapi_get_max_request_count
size_t vapi_get_max_request_count(vapi_ctx_t ctx)
Definition: vapi.c:877
vapi_get_message_size
size_t vapi_get_message_size(vapi_msg_id_t id)
Definition: vapi.c:902
vapi_get_msg_name
const char * vapi_get_msg_name(vapi_msg_id_t id)
Definition: vapi.c:980
vapi_message_desc_t::has_context
bool has_context
Definition: vapi_internal.h:92
generic_swap_fn_t
void(* generic_swap_fn_t)(void *payload)
Definition: vapi_internal.h:84
vapi_msg_id_t
unsigned int vapi_msg_id_t
Definition: vapi_common.h:55
vapi_message_desc_t::name_with_crc_len
size_t name_with_crc_len
Definition: vapi_internal.h:91
vapi_type_msg_header2_t_hton
static void vapi_type_msg_header2_t_hton(vapi_type_msg_header2_t *h)
Definition: vapi_internal.h:67
vapi_message_desc_t::size
size_t size
Definition: vapi_internal.h:95
vapi_message_desc_t::name_with_crc
const char * name_with_crc
Definition: vapi_internal.h:90
vapi_message_desc_t::payload_offset
unsigned int payload_offset
Definition: vapi_internal.h:94
vl_msg_id
#define vl_msg_id(n, h)
Definition: vl_memory_msg_enum.h:26
vapi_cb_t
vapi_error_e(* vapi_cb_t)(struct vapi_ctx_s *, void *, vapi_error_e, bool, void *)
Definition: vapi_internal.h:81
u32
unsigned int u32
Definition: types.h:88
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
bool
#define bool
Definition: radix.c:95
vapi_register_msg
vapi_msg_id_t vapi_register_msg(vapi_message_desc_t *msg)
Definition: vapi.c:916
vapi_message_desc_t
Definition: vapi_internal.h:86
vapi_type_msg_header2_t::client_index
u32 client_index
Definition: vapi_internal.h:50
vapi_type_msg_header1_t_hton
static void vapi_type_msg_header1_t_hton(vapi_type_msg_header1_t *h)
Definition: vapi_internal.h:55
vapi_event_desc_t
Definition: vapi_internal.h:101
vapi_type_msg_header1_t
Definition: vapi_internal.h:41
vapi.h
context
u32 context
Definition: ip.api:852
vapi_type_msg_header2_t_ntoh
static void vapi_type_msg_header2_t_ntoh(vapi_type_msg_header2_t *h)
Definition: vapi_internal.h:73
vapi_message_desc_t::swap_to_host
generic_swap_fn_t swap_to_host
Definition: vapi_internal.h:97
vapi_get_context_offset
size_t vapi_get_context_offset(vapi_msg_id_t id)
Definition: vapi.c:909
vapi_message_desc_t::swap_to_be
generic_swap_fn_t swap_to_be
Definition: vapi_internal.h:96
vapi_type_msg_header2_t
Definition: vapi_internal.h:47
vapi_lookup_vl_msg_id
u16 vapi_lookup_vl_msg_id(vapi_ctx_t ctx, vapi_msg_id_t id)
Definition: vapi.c:858
vapi_message_desc_t::name_len
size_t name_len
Definition: vapi_internal.h:89
vapi_get_request_count
size_t vapi_get_request_count(vapi_ctx_t ctx)
Definition: vapi.c:102
vapi_event_desc_t::name
const char * name
Definition: vapi_internal.h:103
vapi_get_swap_to_host_func
void(*)(void *payload) vapi_get_swap_to_host_func(vapi_msg_id_t id)
Definition: vapi_internal.h:123
vapi_event_desc_t::size
size_t size
Definition: vapi_internal.h:105