API: Change ip4_address and ip6_address to use type alias.
[vpp.git] / src / plugins / nsh / nsh-md2-ioam / nsh_md2_ioam.h
1 /*
2  * Copyright (c) 2017 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 #ifndef __included_nsh_md2_ioam_h__
16 #define __included_nsh_md2_ioam_h__
17
18 #include <nsh/nsh.h>
19 #include <nsh/nsh_packet.h>
20 #include <vnet/ip/ip.h>
21 #include <vnet/ip/ip4_packet.h>
22 #include <vnet/ip/ip6_packet.h>
23
24
25 typedef struct nsh_md2_ioam_sw_interface_
26 {
27   u32 sw_if_index;
28 } nsh_md2_ioam_sw_interface_t;
29
30 typedef struct nsh_md2_ioam_dest_tunnels_
31 {
32   ip46_address_t dst_addr;
33   u32 fp_proto;
34   u32 sibling_index;
35   fib_node_index_t fib_entry_index;
36   u32 outer_fib_index;
37 } nsh_md2_ioam_dest_tunnels_t;
38
39 typedef struct nsh_md2_ioam_main_
40 {
41   /**
42    * Linkage into the FIB object graph
43    */
44   fib_node_t node;
45
46   /* time scale transform. Joy. */
47   u32 unix_time_0;
48   f64 vlib_time_0;
49
50
51   /* Trace option */
52   u8 has_trace_option;
53
54   /* Pot option */
55   u8 has_pot_option;
56
57 #define PPC_NONE  0
58 #define PPC_ENCAP 1
59 #define PPC_DECAP 2
60   u8 has_ppc_option;
61
62 #define TSP_SECONDS              0
63 #define TSP_MILLISECONDS         1
64 #define TSP_MICROSECONDS         2
65 #define TSP_NANOSECONDS          3
66
67
68   /* API message ID base */
69   u16 msg_id_base;
70
71   /* Override to export for iOAM */
72   uword decap_v4_next_override;
73   uword decap_v6_next_override;
74
75   /* sequence of node graph for encap */
76   uword encap_v4_next_node;
77   uword encap_v6_next_node;
78
79   /* Software interfaces. */
80   nsh_md2_ioam_sw_interface_t *sw_interfaces;
81
82   /* hash ip4/ip6 -> list of destinations for doing transit iOAM operation */
83   nsh_md2_ioam_dest_tunnels_t *dst_tunnels;
84   uword *dst_by_ip4;
85   uword *dst_by_ip6;
86
87   /** per sw_if_index, to maintain bitmap */
88   u8 *bool_ref_by_sw_if_index;
89   fib_node_type_t fib_entry_type;
90
91
92 } nsh_md2_ioam_main_t;
93 extern nsh_md2_ioam_main_t nsh_md2_ioam_main;
94
95 /*
96  * Primary h-b-h handler trace support
97  */
98 typedef struct
99 {
100   u32 next_index;
101   u32 trace_len;
102   u8 option_data[256];
103 } ioam_trace_t;
104
105
106 clib_error_t *nsh_md2_ioam_enable_disable (int has_trace_option,
107                                                 int has_pot_option,
108                                                 int has_ppc_option);
109
110
111
112 int nsh_md2_ioam_trace_profile_setup (void);
113
114 int nsh_md2_ioam_trace_profile_cleanup (void);
115 extern void nsh_md2_ioam_interface_init (void);
116
117
118
119 #endif