2 * Copyright (c) 2016 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.
16 *------------------------------------------------------------------
17 * trace_api.c - iOAM Trace related APIs to create
18 * and maintain profiles
19 *------------------------------------------------------------------
22 #include <vnet/vnet.h>
23 #include <vnet/plugin/plugin.h>
24 #include <ioam/lib-trace/trace_util.h>
25 #include <ioam/lib-trace/trace_config.h>
26 #include <vlibapi/api_helper_macros.h>
27 #include <vlibapi/api.h>
28 #include <vlibmemory/api.h>
30 /* define message IDs */
31 #include <ioam/lib-trace/trace.api_enum.h>
32 #include <ioam/lib-trace/trace.api_types.h>
34 static void vl_api_trace_profile_add_t_handler
35 (vl_api_trace_profile_add_t * mp)
38 vl_api_trace_profile_add_reply_t *rmp;
39 trace_profile *profile = NULL;
41 profile = trace_profile_find ();
45 trace_profile_create (profile, mp->trace_type, mp->num_elts,
46 mp->trace_tsp, ntohl (mp->node_id),
47 ntohl (mp->app_data));
56 REPLY_MACRO (VL_API_TRACE_PROFILE_ADD_REPLY);
60 static void vl_api_trace_profile_del_t_handler
61 (vl_api_trace_profile_del_t * mp)
64 vl_api_trace_profile_del_reply_t *rmp;
66 clear_trace_profiles ();
68 REPLY_MACRO (VL_API_TRACE_PROFILE_DEL_REPLY);
71 static void vl_api_trace_profile_show_config_t_handler
72 (vl_api_trace_profile_show_config_t * mp)
74 vl_api_trace_profile_show_config_reply_t *rmp;
76 trace_profile *profile = trace_profile_find ();
79 REPLY_MACRO2 (VL_API_TRACE_PROFILE_SHOW_CONFIG_REPLY,
80 rmp->trace_type = profile->trace_type;
81 rmp->num_elts = profile->num_elts;
82 rmp->trace_tsp = profile->trace_tsp;
83 rmp->node_id = htonl (profile->node_id);
84 rmp->app_data = htonl (profile->app_data);
89 REPLY_MACRO2 (VL_API_TRACE_PROFILE_SHOW_CONFIG_REPLY,
91 rmp->num_elts = 0; rmp->trace_tsp = 0;
92 rmp->node_id = 0; rmp->app_data = 0;
97 #include <ioam/lib-trace/trace.api.c>
99 trace_init (vlib_main_t * vm)
101 trace_main_t *sm = &trace_main;
103 bzero (sm, sizeof (trace_main));
104 (void) trace_util_init ();
107 sm->vnet_main = vnet_get_main ();
109 /* Ask for a correctly-sized block of API message decode slots */
110 sm->msg_id_base = setup_message_id_table ();
115 VLIB_INIT_FUNCTION (trace_init);
118 * fd.io coding-style-patch-verification: ON
121 * eval: (c-set-style "gnu")