diff options
author | Linus Nordberg <linus@nordberg.se> | 2019-03-21 13:41:13 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2019-03-21 13:41:13 +0100 |
commit | ec0f5a398f7e441c70d7d973a49025a660b6f761 (patch) | |
tree | 72bcc56a048f179fb892261c18740fa8f249b462 | |
parent | Merge branch 'ln/send' into ln/send2 (diff) | |
download | wg-dynamic-ec0f5a398f7e441c70d7d973a49025a660b6f761.tar.xz wg-dynamic-ec0f5a398f7e441c70d7d973a49025a660b6f761.zip |
formatting
-rw-r--r-- | common.c | 7 | ||||
-rw-r--r-- | wg-dynamic-client.c | 4 | ||||
-rw-r--r-- | wg-dynamic-server.c | 30 |
3 files changed, 19 insertions, 22 deletions
@@ -268,8 +268,8 @@ bool handle_request(int fd, struct wg_dynamic_request *req, // TODO: handle EINTR - debug("Reading from socket %d failed: %s\n", - fd, strerror(errno)); + debug("Reading from socket %d failed: %s\n", fd, + strerror(errno)); return true; } else if (bytes == 0) { debug("Client disconnected unexpectedly\n"); @@ -312,8 +312,7 @@ size_t send_message(int fd, unsigned char *buf, size_t *len) return offset; } -size_t printf_to_buf(char *buf, size_t bufsize, size_t offset, - char *fmt, ...) +size_t printf_to_buf(char *buf, size_t bufsize, size_t offset, char *fmt, ...) { va_list ap; va_start(ap, fmt); diff --git a/wg-dynamic-client.c b/wg-dynamic-client.c index 8554269..a4015e8 100644 --- a/wg-dynamic-client.c +++ b/wg-dynamic-client.c @@ -18,7 +18,7 @@ int main(int argc __attribute__((unused)), char *argv[] __attribute__((unused))) perror("Unable to get device names"); return 1; } - wg_for_each_device_name(device_names, device_name, len) { + wg_for_each_device_name (device_names, device_name, len) { wg_device *device; wg_peer *peer; wg_key_b64_string key; @@ -29,7 +29,7 @@ int main(int argc __attribute__((unused)), char *argv[] __attribute__((unused))) } wg_key_to_base64(key, device->public_key); printf("%s has public key %s\n", device_name, key); - wg_for_each_peer(device, peer) { + wg_for_each_peer (device, peer) { wg_key_to_base64(key, peer->public_key); printf(" - peer %s\n", key); } diff --git a/wg-dynamic-server.c b/wg-dynamic-server.c index 861c8f3..2a8d6a3 100644 --- a/wg-dynamic-server.c +++ b/wg-dynamic-server.c @@ -115,8 +115,7 @@ static bool validate_link_local_ip(uint32_t ifindex) int ret; unsigned int seq, portid; struct mnl_cb_data cb_data = { - .ifindex = ifindex, - .valid_ip_found = false, + .ifindex = ifindex, .valid_ip_found = false, }; nl = mnl_socket_open(NETLINK_ROUTE); @@ -306,7 +305,7 @@ static void close_connection(int *fd, struct wg_dynamic_request *req) free_wg_dynamic_request(req); } -static int allocate_from_pool(struct wg_dynamic_request * const req, +static int allocate_from_pool(struct wg_dynamic_request *const req, struct wg_combined_ip addrs[2], uint32_t *expires) { struct wg_dynamic_attr *attr; @@ -326,7 +325,7 @@ static int allocate_from_pool(struct wg_dynamic_request * const req, while (attr) { switch (attr->key) { case WGKEY_IPV4: - /* fall through */ + /* fall through */ case WGKEY_IPV6: if (i > 1) break; @@ -353,8 +352,8 @@ static bool send_error(int fd, int ret) return true; } -static void send_later(struct wg_dynamic_request *req, - unsigned char * const buf, size_t msglen) +static void send_later(struct wg_dynamic_request *req, unsigned char *const buf, + size_t msglen) { unsigned char *newbuf = malloc(msglen); if (!newbuf) @@ -403,7 +402,7 @@ static size_t serialise_lease(char *buf, size_t bufsize, size_t offset, static bool send_response(int fd, struct wg_dynamic_request *req) { int ret; - unsigned char buf[MAX_RESPONSE_SIZE+1]; + unsigned char buf[MAX_RESPONSE_SIZE + 1]; size_t msglen; size_t written; struct wg_combined_ip addrs[2] = { 0 }; @@ -420,14 +419,14 @@ static bool send_response(int fd, struct wg_dynamic_request *req) msglen = 0; switch (req->cmd) { case WGKEY_REQUEST_IP: - msglen = printf_to_buf((char *) buf, sizeof buf, 0, "%s=%d\n", - WG_DYNAMIC_KEY[req->cmd], - WG_DYNAMIC_PROTOCOL_VERSION); + msglen = printf_to_buf((char *)buf, sizeof buf, 0, "%s=%d\n", + WG_DYNAMIC_KEY[req->cmd], + WG_DYNAMIC_PROTOCOL_VERSION); ret = allocate_from_pool(req, addrs, &expires); if (ret) break; - msglen += serialise_lease((char *) buf, sizeof buf, msglen, - addrs, expires); + msglen += serialise_lease((char *)buf, sizeof buf, msglen, + addrs, expires); /* TODO: inform wg about the new address (or maybe if (send_rather wait until after we've closed this tcp if (send_connection?) */ @@ -437,8 +436,8 @@ static bool send_response(int fd, struct wg_dynamic_request *req) return true; } - msglen += printf_to_buf((char *) buf, sizeof buf, msglen, - "errno=%d\n\n", ret); + msglen += printf_to_buf((char *)buf, sizeof buf, msglen, "errno=%d\n\n", + ret); written = send_message(fd, buf, &msglen); if (!msglen) return true; @@ -499,8 +498,7 @@ int main(int argc, char *argv[]) for (int i = 0; i < MAX_CONNECTIONS + 1; ++i) { pollfds[i] = (struct pollfd){ - .fd = -1, - .events = POLLIN, + .fd = -1, .events = POLLIN, }; } |