1 // Copyright (c) 2018 Cisco and/or its affiliates.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at:
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #ifndef included_vppapiclient_wrapper_h
16 #define included_vppapiclient_wrapper_h
21 #include <arpa/inet.h>
23 #include <vpp-api/client/vppapiclient.h> // VPP has to be installed!
25 // function go_msg_callback is defined in vppapiclient.go
26 extern void go_msg_callback(uint16_t msg_id, void* data, size_t size);
28 typedef struct __attribute__((__packed__)) _req_header {
30 uint32_t client_index;
34 typedef struct __attribute__((__packed__)) _reply_header {
39 govpp_msg_callback(unsigned char *data, int size)
41 reply_header_t *header = ((reply_header_t *)data);
42 go_msg_callback(ntohs(header->msg_id), data, size);
46 govpp_send(uint32_t context, void *data, size_t size)
48 req_header_t *header = ((req_header_t *)data);
49 header->context = htonl(context);
50 return vac_write(data, size);
54 govpp_connect(char *shm, int rx_qlen)
56 return vac_connect("govpp", shm, govpp_msg_callback, rx_qlen);
62 return vac_disconnect();
66 govpp_get_msg_index(char *name_and_crc)
68 return vac_get_msg_index(name_and_crc);
71 #endif /* included_vppapiclient_wrapper_h */