1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/* SPDX-License-Identifier: Apache-2.0
* Copyright(c) 2022 Cisco Systems, Inc.
*/
#include <vppinfra/format.h>
#include <vlibapi/api.h>
u8 *
format_vl_api_msg_text (u8 *s, va_list *args)
{
api_main_t *am = va_arg (*args, api_main_t *);
u32 msg_id = va_arg (*args, u32);
void *msg = va_arg (*args, void *);
vl_api_msg_data_t *m = vl_api_get_msg_data (am, msg_id);
if (m->format_fn)
s = format (s, "%U", m->format_fn, msg);
else
s = format (s, "[format handler missing for `%s`]", m->name);
return s;
}
u8 *
format_vl_api_msg_json (u8 *s, va_list *args)
{
api_main_t *am = va_arg (*args, api_main_t *);
u32 msg_id = va_arg (*args, u32);
void *msg = va_arg (*args, void *);
vl_api_msg_data_t *m = vl_api_get_msg_data (am, msg_id);
cJSON *o = m->tojson_handler (msg);
char *out = cJSON_Print (o);
s = format (s, "%s", out);
cJSON_Delete (o);
cJSON_free (out);
return s;
}
|