57433acb72e8f36924e1e745c30924f5ec63f4cd
[vpp.git] / vnet / vnet / ip / ip6_hop_by_hop_packet.h
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_packet_h__
16 #define __included_ip6_hop_by_hop_packet_h__
17
18 typedef struct {
19   /* Protocol for next header */
20   u8 protocol;
21   /*
22    * Length of hop_by_hop header in 8 octet units, 
23    * not including the first 8 octets
24    */
25   u8 length;
26 } ip6_hop_by_hop_header_t;
27
28 typedef struct {
29   /* Option Type */
30 #define HBH_OPTION_TYPE_SKIP_UNKNOWN (0x0 << 6)
31 #define HBH_OPTION_TYPE_DISCARD_UNKNOWN (0x1 << 6)
32 #define HBH_OPTION_TYPE_DISCARD_UNKNOWN_ICMP (0x2 << 6)
33 #define HBH_OPTION_TYPE_DISCARD_UNKNOWN_ICMP_NOT_MCAST (0x3 << 6)
34 #define HBH_OPTION_TYPE_DATA_CHANGE_ENROUTE (1<<5)
35 #define HBH_OPTION_TYPE_MASK (0x1F)
36   u8 type;
37   /* Length in octets of the option data field */
38   u8 length;
39 } ip6_hop_by_hop_option_t;
40
41 /* $$$$ IANA banana constants */
42 #define HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST 27
43 #define HBH_OPTION_TYPE_IOAM_PROOF_OF_WORK 28
44 #define HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE 29
45
46 /*
47 typedef struct {
48   u32 ttl_node_id;
49   u16 ingress_if;
50   u16 egress_if;
51   u32 timestamp;
52   u32 app_data;
53 } ioam_trace_data_list_element_t;
54 */
55
56 #define    BIT_TTL_NODEID       (1<<0)
57 #define    BIT_ING_INTERFACE    (1<<1) 
58 #define    BIT_EGR_INTERFACE    (1<<2) 
59 #define    BIT_TIMESTAMP        (1<<3) 
60 #define    BIT_APPDATA          (1<<4) 
61 #define    TRACE_TYPE_MASK      0x1F /* Mask of all above bits */
62
63 /*
64      0x00011111  iOAM-trace-type is 0x00011111 then the format of node
65         data is:
66   
67           0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
68          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
69          |   Hop_Lim     |              node_id                          |
70          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
71          |     ingress_if_id             |         egress_if_id          |
72          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73          +                           timestamp                           +
74          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
75          |                            app_data                           |
76          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77   
78 */
79 #define   TRACE_TYPE_IF_TS_APP   0x1f
80 typedef struct {
81   u32 ttl_node_id;
82   u16 ingress_if;
83   u16 egress_if;
84   u32 timestamp;
85   u32 app_data;
86 } ioam_trace_if_ts_app_t;
87
88 /*
89      0x00000111  iOAM-trace-type is 0x00000111 then the format is:
90   
91           0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
92          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
93          |   Hop_Lim     |              node_id                          |
94          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95          |     ingress_if_id             |         egress_if_id          |
96          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
97   
98 */
99
100 #define   TRACE_TYPE_IF   0x03
101 typedef struct {
102   u32 ttl_node_id;
103   u16 ingress_if;
104   u16 egress_if;
105 } ioam_trace_if_t;
106
107 /*
108      0x00001001  iOAM-trace-type is 0x00001001 then the format is:
109   
110           0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
111          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
112          |   Hop_Lim     |              node_id                          |
113          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
114          +                           timestamp                           +
115          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
116   
117 */
118
119 #define   TRACE_TYPE_TS   0x09
120 typedef struct {
121   u32 ttl_node_id;
122   u32 timestamp;
123 } ioam_trace_ts_t;
124
125 /*
126      0x00010001  iOAM-trace-type is 0x00010001 then the format is:
127   
128   
129           0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
130          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
131          |   Hop_Lim     |              node_id                          |
132          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
133          |                            app_data                           |
134          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
135   
136 */
137
138
139 #define   TRACE_TYPE_APP   0x11
140 typedef struct {
141   u32 ttl_node_id;
142   u32 app_data;
143 } ioam_trace_app_t;
144
145 /*
146   
147      0x00011001  iOAM-trace-type is 0x00011001 then the format is:
148   
149           0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
150          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
151          |   Hop_Lim     |              node_id                          |
152          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
153          +                           timestamp                           +
154          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
155          |                            app_data                           |
156          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
157 */
158
159 #define   TRACE_TYPE_TS_APP   0x19
160 typedef struct {
161   u32 ttl_node_id;
162   u32 timestamp;
163   u32 app_data;
164 } ioam_trace_ts_app_t;
165
166
167 typedef CLIB_PACKED(struct {
168   ip6_hop_by_hop_option_t hdr;
169   u8 ioam_trace_type;
170   u8 data_list_elts_left;
171   u32 elts[0]; /* Variable type. So keep it generic */
172 }) ioam_trace_option_t;
173
174 typedef CLIB_PACKED(struct {
175   ip6_hop_by_hop_option_t hdr;
176   u8 pow_type;
177 #define PROFILE_ID_MASK 0xF
178   u8 reserved_profile_id; /* 4 bits reserved, 4 bits to carry profile id */
179   u64 random;
180   u64 cumulative;
181 }) ioam_pow_option_t;
182
183 typedef CLIB_PACKED(struct {
184   ip6_hop_by_hop_option_t hdr;
185   u8 e2e_type;
186   u8 reserved;
187   u32 e2e_data;
188 }) ioam_e2e_option_t;
189
190 #endif /* __included_ip6_hop_by_hop_packet_h__ */