1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 typedef struct Wireguard Wireguard
;
7 #include <netinet/in.h>
8 #include <linux/wireguard.h>
10 #include "in-addr-util.h"
12 #include "socket-util.h"
14 typedef struct WireguardIPmask
{
16 union in_addr_union ip
;
19 LIST_FIELDS(struct WireguardIPmask
, ipmasks
);
22 typedef struct WireguardPeer
{
24 NetworkConfigSection
*section
;
26 uint8_t public_key
[WG_KEY_LEN
];
27 uint8_t preshared_key
[WG_KEY_LEN
];
28 char *preshared_key_file
;
30 uint16_t persistent_keepalive_interval
;
32 union sockaddr_union endpoint
;
36 LIST_HEAD(WireguardIPmask
, ipmasks
);
37 LIST_FIELDS(struct WireguardPeer
, peers
);
42 unsigned last_peer_section
;
45 uint8_t private_key
[WG_KEY_LEN
];
46 char *private_key_file
;
50 Hashmap
*peers_by_section
;
51 Set
*peers_with_unresolved_endpoint
;
52 Set
*peers_with_failed_endpoint
;
54 LIST_HEAD(WireguardPeer
, peers
);
57 sd_event_source
*resolve_retry_event_source
;
60 DEFINE_NETDEV_CAST(WIREGUARD
, Wireguard
);
61 extern const NetDevVTable wireguard_vtable
;
63 CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_allowed_ips
);
64 CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_endpoint
);
65 CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_listen_port
);
66 CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_peer_key
);
67 CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_private_key
);
68 CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_private_key_file
);
69 CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_preshared_key_file
);
70 CONFIG_PARSER_PROTOTYPE(config_parse_wireguard_keepalive
);