]>
Commit | Line | Data |
---|---|---|
e5719363 JT |
1 | #pragma once |
2 | ||
e5719363 JT |
3 | typedef struct Wireguard Wireguard; |
4 | ||
01234e1f YW |
5 | #include <linux/wireguard.h> |
6 | ||
a7cc45ca | 7 | #include "in-addr-util.h" |
e5719363 | 8 | #include "netdev.h" |
e5719363 | 9 | #include "socket-util.h" |
e5719363 | 10 | |
e5719363 JT |
11 | typedef struct WireguardIPmask { |
12 | uint16_t family; | |
13 | union in_addr_union ip; | |
14 | uint8_t cidr; | |
15 | ||
16 | LIST_FIELDS(struct WireguardIPmask, ipmasks); | |
17 | } WireguardIPmask; | |
18 | ||
19 | typedef struct WireguardPeer { | |
f1368a33 YW |
20 | Wireguard *wireguard; |
21 | NetworkConfigSection *section; | |
22 | ||
e5719363 JT |
23 | uint8_t public_key[WG_KEY_LEN]; |
24 | uint8_t preshared_key[WG_KEY_LEN]; | |
a3945c63 | 25 | char *preshared_key_file; |
e5719363 | 26 | uint32_t flags; |
f1368a33 | 27 | uint16_t persistent_keepalive_interval; |
e5719363 JT |
28 | |
29 | union sockaddr_union endpoint; | |
f1368a33 YW |
30 | char *endpoint_host; |
31 | char *endpoint_port; | |
e5719363 JT |
32 | |
33 | LIST_HEAD(WireguardIPmask, ipmasks); | |
34 | LIST_FIELDS(struct WireguardPeer, peers); | |
35 | } WireguardPeer; | |
36 | ||
e5719363 JT |
37 | struct Wireguard { |
38 | NetDev meta; | |
39 | unsigned last_peer_section; | |
40 | ||
e5719363 | 41 | uint32_t flags; |
e5719363 | 42 | uint8_t private_key[WG_KEY_LEN]; |
76df7779 | 43 | char *private_key_file; |
f1368a33 | 44 | uint16_t port; |
e5719363 JT |
45 | uint32_t fwmark; |
46 | ||
f1368a33 YW |
47 | Hashmap *peers_by_section; |
48 | Set *peers_with_unresolved_endpoint; | |
49 | Set *peers_with_failed_endpoint; | |
e5719363 JT |
50 | |
51 | LIST_HEAD(WireguardPeer, peers); | |
e5719363 | 52 | |
e5719363 | 53 | unsigned n_retries; |
85c987a8 | 54 | sd_event_source *resolve_retry_event_source; |
e5719363 JT |
55 | }; |
56 | ||
57 | DEFINE_NETDEV_CAST(WIREGUARD, Wireguard); | |
58 | extern const NetDevVTable wireguard_vtable; | |
59 | ||
538f15cf YW |
60 | CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_allowed_ips); |
61 | CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_endpoint); | |
62 | CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_listen_port); | |
63 | ||
64 | CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_public_key); | |
65 | CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_private_key); | |
76df7779 | 66 | CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_private_key_file); |
538f15cf | 67 | CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_preshared_key); |
a3945c63 | 68 | CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_preshared_key_file); |
538f15cf | 69 | CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_keepalive); |