Flow: Rename IPFIX exporter.
[vpp.git] / src / plugins / ioam / udp-ping / udp_ping_packet.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
16 #ifndef PLUGINS_IOAM_PLUGIN_IOAM_UDP_PING_UDP_PING_PACKET_H_
17 #define PLUGINS_IOAM_PLUGIN_IOAM_UDP_PING_UDP_PING_PACKET_H_
18
19 #include <vppinfra/clib.h>
20 #include <vnet/ip/ip6_hop_by_hop_packet.h>
21 #include <vnet/udp/udp_packet.h>
22
23 #define UDP_PING_PROBE 1
24 #define UDP_PING_REPLY 2
25
26 #define UDP_PING_PROBE_MARKER1          0xDEAD
27 #define UDP_PING_PROBE_MARKER2          0xBEEF
28
29 /*
30  * Refer to:
31  * https://tools.ietf.org/html/draft-lapukhov-dataplane-probe-01
32  *  0                   1                   2                   3
33     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
34    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35    |                         Probe Marker (1)                      |
36    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37    |                         Probe Marker (2)                      |
38    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39    |   Version     | Message Type  |             Flags             |
40    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41    |                     Telemetry Request Vector                  |
42    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43    |   Hop Limit   |   Hop Count   |         Must Be Zero          |
44    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45    |         Maximum Length        |        Current Length         |
46    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47    |        Sender's Handle        |        Sequence Number        |
48    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49  *
50  * (1)   The "Probe Marker" fields are arbitrary 32-bit values generally
51          used by the network elements to identify the packet as a probe
52          packet.  These fields should be interpreted as unsigned integer
53          values, stored in network byte order.  For example, a network
54          element may be configured to recognize a UDP packet destined to
55          port 31337 and having 0xDEAD 0xBEEF as the values in "Probe
56          Marker" field as an active probe, and treat it respectively.
57
58    (2)   "Version Number" is currently set to 1.
59
60    (3)   The "Message Type" field value could be either "1" - "Probe" or
61          "2" - "Probe Reply"
62
63    (4)   The "Flags" field is 8 bits, and defines the following flags:
64
65    (5)
66          (1)  "Overflow" (O-bit) (least significant bit).  This bit is
67               set by the network element if the number of records on the
68               packet is at the maximum limit as specified by the packet:
69               i.e. the packet is already "full" of telemetry
70               information.
71
72    (6)   "Telemetry Request Vector" is a 32-bit long field that requests
73          well-known inband telemetry information from the network
74          elements on the path.  A bit set in this vector translates to a
75          request of a particular type of information.  The following
76          types/bits are currently defined, starting with the least
77          significant bit first:
78
79          (1)  Bit 0: Device identifier.
80
81          (2)  Bit 1: Timestamp.
82
83          (3)  Bit 2: Queueing delay.
84
85          (4)  Bit 3: Ingress/Egress port identifiers.
86
87          (5)  Bit 31: Opaque state snapshot request.
88
89    (7)   "Hop Limit" is defined only for "Message Type" of "1"
90          ("Probe").  For "Probe Reply" the "Hop Limit" field must be set
91          to zero.  This field is treated as an integer value
92          representing the number of network elements.  See the Section 4
93          section on the intended use of the field.
94
95    (8)   The "Hop Count" field specifies the current number of hops of
96          capable network elements the packet has transit through.  It
97          begins with zero and must be incremented by one for every
98          network element that adds a telemetry record.  Combined with a
99          push mechanism, this simplifies the work for the subsequent
100          network element and the packet receiver.  The subsequent
101          network element just needs to parse the template and then
102          insert new record(s) immediately after the template.
103
104    (9)   The "Max Length" field specifies the maximum length of the
105          telemetry payload in bytes.  Given that the sender knows the
106          minimum path MTU, the sender can set the maximum of payload
107          bytes allowed before exceeding the MTU.  Thus, a simple
108          comparison between "Current Length" and "Max Length" allows to
109          decide whether or not data could be added.
110
111    (10)  The "Current Length" field specifies the current length of data
112          stored in the probe.  This field is incremented by eacn network
113          element by the number of bytes it has added with the telemetry
114          data frame.
115
116    (11)  The "Sender's Handle" field is set by the sender to allow the
117          receiver to identify a particular originator of probe packets.
118          Along with "Sequence Number" it allows for tracking of packet
119          order and loss within the network.
120
121  *
122  */
123 typedef struct
124 {
125   u32 probe_marker1;
126   u32 probe_marker2;
127   u8 version;
128   u8 msg_type;
129   u16 flags;
130   u32 tel_req_vec;
131   u8 hop_limit;
132   u8 hop_count;
133   u16 reserve;
134   u16 max_len;
135   u16 cur_len;
136   u16 sender_handle;
137   u16 seq_no;
138 } udp_ping_data;
139
140 typedef struct
141 {
142   udp_header_t udp;
143   udp_ping_data ping_data;
144 } udp_ping_t;
145
146 #endif /* PLUGINS_IOAM_PLUGIN_IOAM_UDP_PING_UDP_PING_PACKET_H_ */
147
148 /*
149  * fd.io coding-style-patch-verification: ON
150  *
151  * Local Variables:
152  * eval: (c-set-style "gnu")
153  * End:
154  */