FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
wireguard_if.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Cisco and/or its affiliates.
3  * Copyright (c) 2020 Doc.ai 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 __WG_ITF_H__
18 #define __WG_ITF_H__
19 
22 
23 typedef struct wg_if_t_
24 {
27 
28  // Interface params
29  /* noise_local_pool elt index */
33 
35 
36  /* Source IP address for originated packets */
38 
39  /* hash table of peers on this link */
41 } wg_if_t;
42 
43 
44 int wg_if_create (u32 user_instance,
45  const u8 private_key_64[NOISE_PUBLIC_KEY_LEN],
46  u16 port, const ip_address_t * src_ip, u32 * sw_if_indexp);
49 
50 u8 *format_wg_if (u8 * s, va_list * va);
51 
52 typedef walk_rc_t (*wg_if_walk_cb_t) (index_t wgi, void *data);
53 void wg_if_walk (wg_if_walk_cb_t fn, void *data);
54 
55 typedef walk_rc_t (*wg_if_peer_walk_cb_t) (wg_if_t * wgi, index_t peeri,
56  void *data);
58 
59 void wg_if_peer_add (wg_if_t * wgi, index_t peeri);
60 void wg_if_peer_remove (wg_if_t * wgi, index_t peeri);
61 
62 /**
63  * Data-plane exposed functions
64  */
65 extern wg_if_t *wg_if_pool;
66 
69 {
70  if (INDEX_INVALID == wgii)
71  return (NULL);
72  return (pool_elt_at_index (wg_if_pool, wgii));
73 }
74 
76 
79 {
81  return (NULL);
83  return (NULL);
85 }
86 
87 
88 #endif
89 
90 /*
91  * fd.io coding-style-patch-verification: ON
92  *
93  * Local Variables:
94  * eval: (c-set-style "gnu")
95  * End:
96  */
ip_address
Definition: ip_types.h:79
wireguard_index_table.h
wg_if_get
static_always_inline wg_if_t * wg_if_get(index_t wgii)
Definition: wireguard_if.h:68
wg_if_t_::src_ip
ip_address_t src_ip
Definition: wireguard_if.h:37
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
wg_if_peer_remove
void wg_if_peer_remove(wg_if_t *wgi, index_t peeri)
Definition: wireguard_if.c:361
cookie_checker
Definition: wireguard_cookie.h:73
wg_if_t_::peers
uword * peers
Definition: wireguard_if.h:40
u16
unsigned short u16
Definition: types.h:57
wg_if_walk_cb_t
walk_rc_t(* wg_if_walk_cb_t)(index_t wgi, void *data)
Definition: wireguard_if.h:52
port
u16 port
Definition: lb_types.api:73
wg_if_t_::index_table
wg_index_table_t index_table
Definition: wireguard_if.h:34
wg_if_t_::port
u16 port
Definition: wireguard_if.h:32
wg_if_peer_walk
index_t wg_if_peer_walk(wg_if_t *wgi, wg_if_peer_walk_cb_t fn, void *data)
Definition: wireguard_if.c:385
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
wg_if_find_by_sw_if_index
index_t wg_if_find_by_sw_if_index(u32 sw_if_index)
Definition: wireguard_if.c:80
wg_if_t_::cookie_checker
cookie_checker_t cookie_checker
Definition: wireguard_if.h:31
wg_if_create
int wg_if_create(u32 user_instance, const u8 private_key_64[NOISE_PUBLIC_KEY_LEN], u16 port, const ip_address_t *src_ip, u32 *sw_if_indexp)
Definition: wireguard_if.c:239
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
static_always_inline
#define static_always_inline
Definition: clib.h:112
uword
u64 uword
Definition: types.h:112
wg_index_table_t
Definition: wireguard_index_table.h:21
wg_if_delete
int wg_if_delete(u32 sw_if_index)
Definition: wireguard_if.c:322
wg_if_peer_walk_cb_t
walk_rc_t(* wg_if_peer_walk_cb_t)(wg_if_t *wgi, index_t peeri, void *data)
Definition: wireguard_if.h:55
wg_if_t_
Definition: wireguard_if.h:23
format_wg_if
u8 * format_wg_if(u8 *s, va_list *va)
Definition: wireguard_if.c:45
wg_if_index_by_port
index_t * wg_if_index_by_port
Definition: wireguard_if.c:35
wireguard_messages.h
data
u8 data[128]
Definition: ipsec_types.api:95
wg_if_t_::user_instance
int user_instance
Definition: wireguard_if.h:25
wg_if_walk
void wg_if_walk(wg_if_walk_cb_t fn, void *data)
Definition: wireguard_if.c:371
NOISE_PUBLIC_KEY_LEN
#define NOISE_PUBLIC_KEY_LEN
Definition: wireguard_noise.h:26
u32
unsigned int u32
Definition: types.h:88
src_ip
vl_api_address_t src_ip
Definition: wireguard.api:38
wg_if_peer_add
void wg_if_peer_add(wg_if_t *wgi, index_t peeri)
Definition: wireguard_if.c:351
u8
unsigned char u8
Definition: types.h:56
wg_if_t
struct wg_if_t_ wg_if_t
wg_if_t_::sw_if_index
u32 sw_if_index
Definition: wireguard_if.h:26
INDEX_INVALID
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:49
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
walk_rc_t
enum walk_rc_t_ walk_rc_t
Walk return code.
wg_if_t_::local_idx
u32 local_idx
Definition: wireguard_if.h:30
wg_if_get_by_port
static_always_inline wg_if_t * wg_if_get_by_port(u16 port)
Definition: wireguard_if.h:78
wg_if_pool
wg_if_t * wg_if_pool
Data-plane exposed functions.
Definition: wireguard_if.c:26