summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-04-05 17:24:50 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-04-08 00:52:34 +0900
commit03fec543966ca5595c6d5518af759d5bccd376c1 (patch)
treee43069f9ea09b698abfa909c509b72a7ad9a83d3
parent1eacc47062eecd1dda0fe5ba3f797bbd81988f37 (diff)
downloadsystemd-03fec543966ca5595c6d5518af759d5bccd376c1.tar.gz
network: re-indent conf parsers in wireguard.c
-rw-r--r--src/network/netdev/wireguard.c162
1 files changed, 80 insertions, 82 deletions
diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c
index 5d9df16349..61fbc24cfb 100644
--- a/src/network/netdev/wireguard.c
+++ b/src/network/netdev/wireguard.c
@@ -438,16 +438,18 @@ static int netdev_wireguard_post_create(NetDev *netdev, Link *link, sd_netlink_m
return 0;
}
-int config_parse_wireguard_listen_port(const char *unit,
- const char *filename,
- unsigned line,
- const char *section,
- unsigned section_line,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
+int config_parse_wireguard_listen_port(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
uint16_t *s = data;
uint16_t port = 0;
int r;
@@ -465,7 +467,6 @@ int config_parse_wireguard_listen_port(const char *unit,
}
*s = port;
-
return 0;
}
@@ -476,6 +477,7 @@ static int wireguard_decode_key_and_warn(
const char *filename,
unsigned line,
const char *lvalue) {
+
_cleanup_free_ void *key = NULL;
size_t len;
int r;
@@ -507,22 +509,22 @@ static int wireguard_decode_key_and_warn(
return true;
}
-int config_parse_wireguard_private_key(const char *unit,
- const char *filename,
- unsigned line,
- const char *section,
- unsigned section_line,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
+int config_parse_wireguard_private_key(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
Wireguard *w;
assert(data);
-
w = WIREGUARD(data);
-
assert(w);
return wireguard_decode_key_and_warn(rvalue, w->private_key, unit, filename, line, lvalue);
@@ -563,25 +565,24 @@ int config_parse_wireguard_private_key_file(
return free_and_replace(w->private_key_file, path);
}
-int config_parse_wireguard_preshared_key(const char *unit,
- const char *filename,
- unsigned line,
- const char *section,
- unsigned section_line,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
+int config_parse_wireguard_preshared_key(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
_cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL;
Wireguard *w;
int r;
assert(data);
-
w = WIREGUARD(data);
-
assert(w);
r = wireguard_peer_new_static(w, filename, section_line, &peer);
@@ -596,25 +597,24 @@ int config_parse_wireguard_preshared_key(const char *unit,
return 0;
}
-int config_parse_wireguard_public_key(const char *unit,
- const char *filename,
- unsigned line,
- const char *section,
- unsigned section_line,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
+int config_parse_wireguard_public_key(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
_cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL;
Wireguard *w;
int r;
assert(data);
-
w = WIREGUARD(data);
-
assert(w);
r = wireguard_peer_new_static(w, filename, section_line, &peer);
@@ -629,16 +629,17 @@ int config_parse_wireguard_public_key(const char *unit,
return 0;
}
-int config_parse_wireguard_allowed_ips(const char *unit,
- const char *filename,
- unsigned line,
- const char *section,
- unsigned section_line,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
+int config_parse_wireguard_allowed_ips(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
_cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL;
union in_addr_union addr;
@@ -651,7 +652,6 @@ int config_parse_wireguard_allowed_ips(const char *unit,
assert(data);
w = WIREGUARD(data);
-
assert(w);
r = wireguard_peer_new_static(w, filename, section_line, &peer);
@@ -696,16 +696,17 @@ int config_parse_wireguard_allowed_ips(const char *unit,
return 0;
}
-int config_parse_wireguard_endpoint(const char *unit,
- const char *filename,
- unsigned line,
- const char *section,
- unsigned section_line,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
+int config_parse_wireguard_endpoint(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
_cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL;
const char *begin, *end;
@@ -717,7 +718,6 @@ int config_parse_wireguard_endpoint(const char *unit,
assert(rvalue);
w = WIREGUARD(data);
-
assert(w);
r = wireguard_peer_new_static(w, filename, section_line, &peer);
@@ -775,16 +775,17 @@ int config_parse_wireguard_endpoint(const char *unit,
return 0;
}
-int config_parse_wireguard_keepalive(const char *unit,
- const char *filename,
- unsigned line,
- const char *section,
- unsigned section_line,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
+int config_parse_wireguard_keepalive(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
_cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL;
uint16_t keepalive = 0;
@@ -795,7 +796,6 @@ int config_parse_wireguard_keepalive(const char *unit,
assert(data);
w = WIREGUARD(data);
-
assert(w);
r = wireguard_peer_new_static(w, filename, section_line, &peer);
@@ -824,9 +824,7 @@ static void wireguard_init(NetDev *netdev) {
Wireguard *w;
assert(netdev);
-
w = WIREGUARD(netdev);
-
assert(w);
w->flags = WGDEVICE_F_REPLACE_PEERS;