blob: 50a14a9b6a8d656d9a01dc600b5868315f8a9cc8 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
2 * Copyright (c) 2015 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 */
Ole Troan944f5482016-05-24 11:56:58 +020015#ifndef __included_ip6_hop_by_hop_ioam_h__
16#define __included_ip6_hop_by_hop_ioam_h__
Ed Warnickecb9cada2015-12-08 15:45:58 -070017
Ole Troan944f5482016-05-24 11:56:58 +020018#include <vnet/ip/ip6_hop_by_hop.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070019#include <vnet/ip/ip6_hop_by_hop_packet.h>
Shwetha Bhandari05866a12016-05-04 08:12:57 +020020#include <vnet/ip/ip.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070021
22typedef struct {
23 /* The current rewrite we're using */
24 u8 * rewrite;
25
26 /* Trace data processing callback */
27 void *ioam_end_of_path_cb;
rangan4f810852016-03-18 03:31:17 +053028 /* Configuration data */
29 /* Adjacency */
30 ip6_address_t adj;
31#define IOAM_HBYH_ADD 0
32#define IOAM_HBYH_MOD 1
33#define IOAM_HBYH_POP 2
34 u8 ioam_flag;
35 /* time scale transform. Joy. */
36 u32 unix_time_0;
37 f64 vlib_time_0;
38
39
40 /* Trace option */
41 u8 trace_type;
42 u8 trace_option_elts;
Ed Warnickecb9cada2015-12-08 15:45:58 -070043
44 /* Configured node-id */
45 u32 node_id;
rangan4f810852016-03-18 03:31:17 +053046 u32 app_data;
47
48 /* PoW option */
49 u8 has_pow_option;
50
51#define PPC_NONE 0
52#define PPC_ENCAP 1
53#define PPC_DECAP 2
54 u8 has_ppc_option;
55
56#define TSP_SECONDS 0
57#define TSP_MILLISECONDS 1
58#define TSP_MICROSECONDS 2
59#define TSP_NANOSECONDS 3
60 /* Time stamp precision. This is enumerated to above four options */
61 u32 trace_tsp;
Ed Warnickecb9cada2015-12-08 15:45:58 -070062
63 /* convenience */
64 vlib_main_t * vlib_main;
65 vnet_main_t * vnet_main;
Ole Troan944f5482016-05-24 11:56:58 +020066} ip6_hop_by_hop_ioam_main_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -070067
Ole Troan944f5482016-05-24 11:56:58 +020068extern ip6_hop_by_hop_ioam_main_t ip6_hop_by_hop_ioam_main;
rangan4f810852016-03-18 03:31:17 +053069
70extern u8 * format_path_map(u8 * s, va_list * args);
71extern clib_error_t *
72ip6_ioam_trace_profile_set(u32 trace_option_elts, u32 trace_type, u32 node_id,
73 u32 app_data, int has_pow_option, u32 trace_tsp,
74 int has_e2e_option);
75extern int ip6_ioam_set_destination (ip6_address_t *addr, u32 mask_width,
76 u32 vrf_id, int is_add, int is_pop, int is_none);
77
Shwetha20a64f52016-03-25 10:55:01 +000078extern clib_error_t * clear_ioam_rewrite_fn(void);
rangan4f810852016-03-18 03:31:17 +053079
80static inline u8 is_zero_ip4_address (ip4_address_t *a)
81{
82 return (a->as_u32 == 0);
83}
84
85static inline void copy_ip6_address (ip6_address_t *dst, ip6_address_t *src)
86{
87 dst->as_u64[0] = src->as_u64[0];
88 dst->as_u64[1] = src->as_u64[1];
89}
90
91static inline void set_zero_ip6_address (ip6_address_t *a)
92{
93 a->as_u64[0] = 0;
94 a->as_u64[1] = 0;
95}
96
97static inline u8 cmp_ip6_address (ip6_address_t *a1, ip6_address_t *a2)
98{
99 return ((a1->as_u64[0] == a2->as_u64[0]) && (a1->as_u64[1] == a2->as_u64[1]));
100}
101static inline u8 is_zero_ip6_address (ip6_address_t *a)
102{
103 return ((a->as_u64[0] == 0) && (a->as_u64[1] == 0));
104}
105
Ole Troan944f5482016-05-24 11:56:58 +0200106extern ip6_hop_by_hop_ioam_main_t * hm;
107#endif /* __included_ip6_hop_by_hop_ioam_h__ */