blob: c699d4925f34d7f8d16382bf1639d5432db64634 [file] [log] [blame]
Gabriel Oginski4e88e042022-06-29 12:54:30 +00001#ifndef KERNEL_VPP_SHARED_H_
2#define KERNEL_VPP_SHARED_H_
3/*
4 * Copyright (c) 2022 Intel and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18typedef struct vac_t vac_t;
19
20/**
21 * Callback function invoked for received event messages.
22 *
23 * @param data associated event message, destroyed by VPP API wrapper
24 * @param data_len length of the event message
25 * @param ctx user data, as passed to register_event
26 */
27typedef void (*event_cb_t) (char *data, int data_len, void *ctx);
28
29/**
30 * Wrapper around VPP binary API client.
31 */
32struct vac_t
33{
34
35 /**
36 * Destroy the VPP API client.
37 */
38 void (*destroy) (vac_t *this);
39
40 /**
41 * Send VPP API message and wait for a reply
42 *
43 * @param in VPP API message to send
44 * @param in_len length of the message to send
45 * @param out received VPP API message
46 * @param out_len length of the received message
47 */
48 status_t (*send) (vac_t *this, char *in, int in_len, char **out,
49 int *out_len);
50
51 /**
52 * Send VPP API dump message and wait for a reply.
53 *
54 * @param in VPP API message to send
55 * @param in_len length of the message to send
56 * @param out received VPP API message
57 * @param out_len length of the received message
58 */
59 status_t (*send_dump) (vac_t *this, char *in, int in_len, char **out,
60 int *out_len);
61
62 /**
63 * Register for VPP API event of a given kind.
64 *
65 * @param in VPP API event message to register
66 * @param in_len length of the event message to register
67 * @param cb callback function to register
68 * @param event_id event ID
69 * @param ctx user data passed to callback invocations
70 */
71 status_t (*register_event) (vac_t *this, char *in, int in_len, event_cb_t cb,
72 uint16_t event_id, void *ctx);
73};
74
75extern vac_t *vac;
76
77/**
78 * Establishing a binary API connection to VPP.
79 *
80 * @param name client name
81 * @return vac_t instance
82 */
83vac_t *vac_create (char *name);
84
85#endif /* KERNEL_VPP_SHARED_H_ */