Flow: Rename IPFIX exporter.
[vpp.git] / src / plugins / ioam / udp-ping / udp_ping_util.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_UTIL_H_
17 #define PLUGINS_IOAM_PLUGIN_IOAM_UDP_PING_UDP_PING_UTIL_H_
18
19 int udp_ping_create_ip6_pak (u8 * buf,  /*u16 len, */
20                              ip6_address_t src, ip6_address_t dst,
21                              u16 src_port, u16 dst_port,
22                              u8 msg_type, u16 ctx);
23
24 int
25 udp_ping_compare_flow (ip46_address_t src, ip46_address_t dst,
26                        u16 start_src_port, u16 end_src_port,
27                        u16 start_dst_port, u16 end_dst_port,
28                        ip46_udp_ping_flow * flow);
29
30 void
31 udp_ping_populate_flow (ip46_address_t src, ip46_address_t dst,
32                         u16 start_src_port, u16 end_src_port,
33                         u16 start_dst_port, u16 end_dst_port,
34                         u16 interval, u8 fault_det,
35                         ip46_udp_ping_flow * flow);
36
37 void udp_ping_free_flow_data (ip46_udp_ping_flow * flow);
38
39 void udp_ping_create_rewrite (ip46_udp_ping_flow * flow, u16 ctx);
40
41 void udp_ping_send_ip6_pak (vlib_main_t * vm, ip46_udp_ping_flow * flow);
42
43 /**
44  * @brief Create and send ipv6 udp-ping response packet.
45  *
46  */
47 always_inline void
48 udp_ping_create_reply_from_probe_ip6 (ip6_header_t * ip,
49                                       ip6_hop_by_hop_header_t * hbh,
50                                       udp_ping_t * udp)
51 {
52   ip6_address_t src;
53   u16 src_port;
54   ioam_trace_option_t *trace;
55
56   src = ip->src_address;
57
58   ip->src_address = ip->dst_address;
59   ip->dst_address = src;
60
61   trace = (ioam_trace_option_t *)
62     ip6_hbh_get_option (hbh, HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST);
63   ip6_hbh_ioam_trace_reset_bit (trace, BIT_LOOPBACK);
64
65   /* No need of endian transform */
66   src_port = udp->udp.src_port;
67
68   udp->udp.src_port = udp->udp.dst_port;
69   udp->udp.dst_port = src_port;
70   udp->udp.checksum = 0;        //FIXME
71
72   udp->ping_data.msg_type = UDP_PING_REPLY;
73 }
74
75 #endif /* PLUGINS_IOAM_PLUGIN_IOAM_UDP_PING_UDP_PING_UTIL_H_ */
76
77 /*
78  * fd.io coding-style-patch-verification: ON
79  *
80  * Local Variables:
81  * eval: (c-set-style "gnu")
82  * End:
83  */