nsh_md2_ioam_api.c revision f126e1c3
1/*
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:
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
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.
14 */
15/*
16 *-----------------------------------------------------------------------
17 * nsh_md2_ioam_api.c - iOAM for NSH/LISP-GPE related APIs to create
18 *               and maintain profiles
19 *-----------------------------------------------------------------------
20 */
21
22#include <vnet/vnet.h>
23#include <vlib/unix/plugin.h>
24#include <vnet/plugin/plugin.h>
25#include <nsh-md2-ioam/nsh_md2_ioam.h>
26
27#include <vlibapi/api.h>
28#include <vlibmemory/api.h>
29#include <vlibsocket/api.h>
30
31/* define message IDs */
32#include <vpp-api/nsh_msg_enum.h>
33
34/* define message structures */
35#define vl_typedefs
36#include <vpp-api/nsh_all_api_h.h>
37#undef vl_typedefs
38
39/* define generated endian-swappers */
40#define vl_endianfun
41#include <vpp-api/nsh_all_api_h.h>
42#undef vl_endianfun
43
44/* instantiate all the print functions we know about */
45#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
46#define vl_printfun
47#include <vpp-api/nsh_all_api_h.h>
48#undef vl_printfun
49
50/* Get the API version number */
51#if 0
52#define vl_api_version(n,v) static u32 api_version=(v);
53#include <vpp-api/nsh_all_api_h.h>
54#undef vl_api_version
55#endif
56
57u8 *nsh_trace_main = NULL;
58static clib_error_t *
59nsh_md2_ioam_init (vlib_main_t * vm)
60{
61  nsh_md2_ioam_main_t *sm = &nsh_md2_ioam_main;
62  clib_error_t *error = 0;
63
64  nsh_trace_main =
65    (u8 *) vlib_get_plugin_symbol ("ioam_plugin.so", "trace_main");
66
67  if (!nsh_trace_main)
68    return error;
69
70  vec_new (nsh_md2_ioam_sw_interface_t, pool_elts (sm->sw_interfaces));
71  sm->dst_by_ip4 = hash_create_mem (0, sizeof (fib_prefix_t), sizeof (uword));
72
73  sm->dst_by_ip6 = hash_create_mem (0, sizeof (fib_prefix_t), sizeof (uword));
74
75  nsh_md2_ioam_interface_init ();
76
77  return error;
78}
79
80VLIB_INIT_FUNCTION (nsh_md2_ioam_init);
81
82/*
83 * fd.io coding-style-patch-verification: ON
84 *
85 * Local Variables:
86 * eval: (c-set-style "gnu")
87 * End:
88 */
89