wireguard: initial implementation of wireguard protocol
[vpp.git] / src / plugins / wireguard / wireguard_send.h
1 /*
2  * Copyright (c) 2020 Doc.ai 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 __included_wg_send_h__
17 #define __included_wg_send_h__
18
19 #include <wireguard/wireguard_peer.h>
20
21 bool wg_send_keepalive (vlib_main_t * vm, wg_peer_t * peer);
22 bool wg_send_handshake (vlib_main_t * vm, wg_peer_t * peer, bool is_retry);
23 bool wg_send_handshake_response (vlib_main_t * vm, wg_peer_t * peer);
24
25 always_inline void
26 ip4_header_set_len_w_chksum (ip4_header_t * ip4, u16 len)
27 {
28   ip_csum_t sum = ip4->checksum;
29   u8 old = ip4->length;
30   u8 new = len;
31
32   sum = ip_csum_update (sum, old, new, ip4_header_t, length);
33   ip4->checksum = ip_csum_fold (sum);
34   ip4->length = new;
35 }
36
37 #endif /* __included_wg_send_h__ */
38
39 /*
40  * fd.io coding-style-patch-verification: ON
41  *
42  * Local Variables:
43  * eval: (c-set-style "gnu")
44  * End:
45  */