FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
wireguard_send.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Doc.ai and/or its affiliates.
3  * Copyright (c) 2020 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __included_wg_send_h__
18 #define __included_wg_send_h__
19 
21 
23 bool wg_send_handshake (vlib_main_t * vm, wg_peer_t * peer, bool is_retry);
24 void wg_send_handshake_from_mt (u32 peer_index, bool is_retry);
26 
27 always_inline void
29 {
30  ip_csum_t sum = ip4->checksum;
31  u16 old = ip4->length;
32  u16 new = len;
33 
34  sum = ip_csum_update (sum, old, new, ip4_header_t, length);
35  ip4->checksum = ip_csum_fold (sum);
36  ip4->length = new;
37 }
38 
39 #endif /* __included_wg_send_h__ */
40 
41 /*
42  * fd.io coding-style-patch-verification: ON
43  *
44  * Local Variables:
45  * eval: (c-set-style "gnu")
46  * End:
47  */
ip4
vl_api_ip4_address_t ip4
Definition: one.api:376
ip4_header_set_len_w_chksum
static void ip4_header_set_len_w_chksum(ip4_header_t *ip4, u16 len)
Definition: wireguard_send.h:28
wg_send_handshake_from_mt
void wg_send_handshake_from_mt(u32 peer_index, bool is_retry)
Definition: wireguard_send.c:143
u16
unsigned short u16
Definition: types.h:57
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
ip4_header_t
Definition: ip4_packet.h:87
wg_send_handshake_response
bool wg_send_handshake_response(vlib_main_t *vm, wg_peer_t *peer)
Definition: wireguard_send.c:206
wireguard_peer.h
len
u8 len
Definition: ip_types.api:103
peer
vl_api_address_t peer
Definition: teib.api:28
wg_peer
Definition: wireguard_peer.h:48
wg_send_handshake
bool wg_send_handshake(vlib_main_t *vm, wg_peer_t *peer, bool is_retry)
Definition: wireguard_send.c:84
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
u32
unsigned int u32
Definition: types.h:88
wg_send_keepalive
bool wg_send_keepalive(vlib_main_t *vm, wg_peer_t *peer)
Definition: wireguard_send.c:155
length
char const int length
Definition: cJSON.h:163
vlib_main_t
Definition: main.h:102
ip_csum_update
#define ip_csum_update(sum, old, new, type, field)
Definition: ip_packet.h:295
ip_csum_t
uword ip_csum_t
Definition: ip_packet.h:245
ip_csum_fold
static u16 ip_csum_fold(ip_csum_t c)
Definition: ip_packet.h:301