Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 15 | #ifndef __included_ip6_hop_by_hop_h__ |
| 16 | #define __included_ip6_hop_by_hop_h__ |
| 17 | |
| 18 | #include <vnet/ip/ip6_hop_by_hop_packet.h> |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 19 | #include <vnet/ip/ip.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 20 | |
| 21 | typedef struct { |
| 22 | /* The current rewrite we're using */ |
| 23 | u8 * rewrite; |
| 24 | |
| 25 | /* Trace data processing callback */ |
| 26 | void *ioam_end_of_path_cb; |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 27 | /* Configuration data */ |
| 28 | /* Adjacency */ |
| 29 | ip6_address_t adj; |
| 30 | #define IOAM_HBYH_ADD 0 |
| 31 | #define IOAM_HBYH_MOD 1 |
| 32 | #define IOAM_HBYH_POP 2 |
| 33 | u8 ioam_flag; |
| 34 | /* time scale transform. Joy. */ |
| 35 | u32 unix_time_0; |
| 36 | f64 vlib_time_0; |
| 37 | |
| 38 | |
| 39 | /* Trace option */ |
| 40 | u8 trace_type; |
| 41 | u8 trace_option_elts; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 42 | |
| 43 | /* Configured node-id */ |
| 44 | u32 node_id; |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 45 | u32 app_data; |
| 46 | |
| 47 | /* PoW option */ |
| 48 | u8 has_pow_option; |
| 49 | |
| 50 | #define PPC_NONE 0 |
| 51 | #define PPC_ENCAP 1 |
| 52 | #define PPC_DECAP 2 |
| 53 | u8 has_ppc_option; |
| 54 | |
| 55 | #define TSP_SECONDS 0 |
| 56 | #define TSP_MILLISECONDS 1 |
| 57 | #define TSP_MICROSECONDS 2 |
| 58 | #define TSP_NANOSECONDS 3 |
| 59 | /* Time stamp precision. This is enumerated to above four options */ |
| 60 | u32 trace_tsp; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 61 | |
| 62 | /* convenience */ |
| 63 | vlib_main_t * vlib_main; |
| 64 | vnet_main_t * vnet_main; |
| 65 | } ip6_hop_by_hop_main_t; |
| 66 | |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 67 | extern ip6_hop_by_hop_main_t ip6_hop_by_hop_main; |
| 68 | |
| 69 | extern u8 * format_path_map(u8 * s, va_list * args); |
| 70 | extern clib_error_t * |
| 71 | ip6_ioam_trace_profile_set(u32 trace_option_elts, u32 trace_type, u32 node_id, |
| 72 | u32 app_data, int has_pow_option, u32 trace_tsp, |
| 73 | int has_e2e_option); |
| 74 | extern int ip6_ioam_set_destination (ip6_address_t *addr, u32 mask_width, |
| 75 | u32 vrf_id, int is_add, int is_pop, int is_none); |
| 76 | |
Shwetha | 20a64f5 | 2016-03-25 10:55:01 +0000 | [diff] [blame] | 77 | extern clib_error_t * clear_ioam_rewrite_fn(void); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 78 | |
| 79 | static inline u8 is_zero_ip4_address (ip4_address_t *a) |
| 80 | { |
| 81 | return (a->as_u32 == 0); |
| 82 | } |
| 83 | |
| 84 | static inline void copy_ip6_address (ip6_address_t *dst, ip6_address_t *src) |
| 85 | { |
| 86 | dst->as_u64[0] = src->as_u64[0]; |
| 87 | dst->as_u64[1] = src->as_u64[1]; |
| 88 | } |
| 89 | |
| 90 | static inline void set_zero_ip6_address (ip6_address_t *a) |
| 91 | { |
| 92 | a->as_u64[0] = 0; |
| 93 | a->as_u64[1] = 0; |
| 94 | } |
| 95 | |
| 96 | static inline u8 cmp_ip6_address (ip6_address_t *a1, ip6_address_t *a2) |
| 97 | { |
| 98 | return ((a1->as_u64[0] == a2->as_u64[0]) && (a1->as_u64[1] == a2->as_u64[1])); |
| 99 | } |
| 100 | static inline u8 is_zero_ip6_address (ip6_address_t *a) |
| 101 | { |
| 102 | return ((a->as_u64[0] == 0) && (a->as_u64[1] == 0)); |
| 103 | } |
| 104 | |
| 105 | extern ip6_hop_by_hop_main_t * hm; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 106 | #endif /* __included_ip6_hop_by_hop_h__ */ |