]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Enforce NetBSD KNF style more
authorRoy Marples <roy@marples.name>
Wed, 11 Feb 2009 17:56:22 +0000 (17:56 +0000)
committerRoy Marples <roy@marples.name>
Wed, 11 Feb 2009 17:56:22 +0000 (17:56 +0000)
16 files changed:
arp.c
bind.c
bpf.c
common.c
configure.c
control.c
dhcp.c
dhcpcd.c
eloop.c
if-bsd.c
if-linux.c
if-options.c
ipv4ll.c
lpf.c
net.c
signals.c

diff --git a/arp.c b/arp.c
index 17a3d9ad3a97600d11ce8893d1e39b70b77ae2ac..f3a8246d9cbc0fd8d48a2751f7eca9f56cba5f94 100644 (file)
--- a/arp.c
+++ b/arp.c
@@ -40,7 +40,7 @@
 #include "ipv4ll.h"
 #include "net.h"
 
-#define ARP_LEN \
+#define ARP_LEN                                                                \
        (sizeof(struct arphdr) + (2 * sizeof(uint32_t)) + (2 * HWADDR_LEN))
 
 static int
@@ -108,7 +108,7 @@ handle_arp_packet(void *arg)
        state->fail.s_addr = 0;
        for(;;) {
                bytes = get_raw_packet(iface, ETHERTYPE_ARP,
-                                      arp_buffer, sizeof(arp_buffer));
+                   arp_buffer, sizeof(arp_buffer));
                if (bytes == 0 || bytes == -1)
                        return;
                /* We must have a full ARP header */
@@ -142,21 +142,21 @@ handle_arp_packet(void *arg)
                /* Check for conflict */
                if (state->offer && 
                    (reply_s == state->offer->yiaddr ||
-                    (reply_s == 0 && reply_t == state->offer->yiaddr)))
+                       (reply_s == 0 && reply_t == state->offer->yiaddr)))
                        state->fail.s_addr = state->offer->yiaddr;
 
                /* Handle IPv4LL conflicts */
                if (IN_LINKLOCAL(htonl(iface->addr.s_addr)) &&
                    (reply_s == iface->addr.s_addr ||
-                    (reply_s == 0 && reply_t == iface->addr.s_addr)))
+                       (reply_s == 0 && reply_t == iface->addr.s_addr)))
                        state->fail.s_addr = iface->addr.s_addr;
 
                if (state->fail.s_addr) {
                        syslog(LOG_ERR, "%s: hardware address %s claims %s",
-                              iface->name,
-                              hwaddr_ntoa((unsigned char *)hw_s,
-                                          (size_t)ar.ar_hln),
-                              inet_ntoa(state->fail));
+                           iface->name,
+                           hwaddr_ntoa((unsigned char *)hw_s,
+                               (size_t)ar.ar_hln),
+                           inet_ntoa(state->fail));
                        errno = EEXIST;
                        handle_arp_failure(iface);
                        return;
@@ -177,15 +177,15 @@ send_arp_announce(void *arg)
        }
        if (++state->claims < ANNOUNCE_NUM)     
                syslog(LOG_DEBUG,
-                      "%s: sending ARP announce (%d of %d), "
-                      "next in %d.00 seconds",
-                      iface->name, state->claims, ANNOUNCE_NUM, ANNOUNCE_WAIT);
+                   "%s: sending ARP announce (%d of %d), "
+                   "next in %d.00 seconds",
+                   iface->name, state->claims, ANNOUNCE_NUM, ANNOUNCE_WAIT);
        else
                syslog(LOG_DEBUG,
-                      "%s: sending ARP announce (%d of %d)",
-                      iface->name, state->claims, ANNOUNCE_NUM);
+                   "%s: sending ARP announce (%d of %d)",
+                   iface->name, state->claims, ANNOUNCE_NUM);
        if (send_arp(iface, ARPOP_REQUEST,
-                    state->new->yiaddr, state->new->yiaddr) == -1)
+               state->new->yiaddr, state->new->yiaddr) == -1)
                syslog(LOG_ERR, "send_arp: %m");
        if (state->claims < ANNOUNCE_NUM) {
                add_timeout_sec(ANNOUNCE_WAIT, send_arp_announce, iface);
@@ -231,8 +231,8 @@ send_arp_probe(void *arg)
        }
        if (state->probes == 0) {
                syslog(LOG_INFO, "%s: checking %s is available"
-                      " on attached networks",
-                      iface->name, inet_ntoa(addr));
+                   " on attached networks",
+                   iface->name, inet_ntoa(addr));
        }
        if (++state->probes < PROBE_NUM) {
                tv.tv_sec = PROBE_MIN;
@@ -245,8 +245,8 @@ send_arp_probe(void *arg)
                add_timeout_tv(&tv, bind_interface, iface);
        }
        syslog(LOG_DEBUG,
-              "%s: sending ARP probe (%d of %d), next in %0.2f seconds",
-              iface->name, state->probes, PROBE_NUM,  timeval_to_double(&tv));
+           "%s: sending ARP probe (%d of %d), next in %0.2f seconds",
+           iface->name, state->probes, PROBE_NUM,  timeval_to_double(&tv));
        if (send_arp(iface, ARPOP_REQUEST, 0, addr.s_addr) == -1)
                syslog(LOG_ERR, "send_arp: %m");
 }
diff --git a/bind.c b/bind.c
index 483c74626b12ffc33ce63c1099d13fbfcd87c57e..f671a4ac0c268415ee149c4b45eedd7b8aa9a17e 100644 (file)
--- a/bind.c
+++ b/bind.c
@@ -71,33 +71,33 @@ daemonise(void)
        }
        syslog(LOG_INFO, "forking to background");
        switch (pid = fork()) {
-               case -1:
-                       syslog(LOG_ERR, "fork: %m");
-                       exit(EXIT_FAILURE);
-                       /* NOTREACHED */
-               case 0:
-                       setsid();
-                       /* Notify parent it's safe to exit as we've detached. */
-                       close(sidpipe[0]);
-                       if (write(sidpipe[1], &buf, 1) == -1)
-                               syslog(LOG_ERR, "failed to notify parent: %m");
-                       close(sidpipe[1]);
-                       if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
-                               dup2(fd, STDIN_FILENO);
-                               dup2(fd, STDOUT_FILENO);
-                               dup2(fd, STDERR_FILENO);
-                               if (fd > STDERR_FILENO)
-                                       close(fd);
-                       }
-                       break;
-               default:
-                       signal_reset();
-                       /* Wait for child to detach */
-                       close(sidpipe[1]);
-                       if (read(sidpipe[0], &buf, 1) == -1)
-                               syslog(LOG_ERR, "failed to read child: %m");
-                       close(sidpipe[0]);
-                       break;
+       case -1:
+               syslog(LOG_ERR, "fork: %m");
+               exit(EXIT_FAILURE);
+               /* NOTREACHED */
+       case 0:
+               setsid();
+               /* Notify parent it's safe to exit as we've detached. */
+               close(sidpipe[0]);
+               if (write(sidpipe[1], &buf, 1) == -1)
+                       syslog(LOG_ERR, "failed to notify parent: %m");
+               close(sidpipe[1]);
+               if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
+                       dup2(fd, STDIN_FILENO);
+                       dup2(fd, STDOUT_FILENO);
+                       dup2(fd, STDERR_FILENO);
+                       if (fd > STDERR_FILENO)
+                               close(fd);
+               }
+               break;
+       default:
+               signal_reset();
+               /* Wait for child to detach */
+               close(sidpipe[1]);
+               if (read(sidpipe[0], &buf, 1) == -1)
+                       syslog(LOG_ERR, "failed to read child: %m");
+               close(sidpipe[0]);
+               break;
        }
        /* Done with the fd now */
        if (pid != 0) {
@@ -133,13 +133,13 @@ bind_interface(void *arg)
        get_lease(lease, state->new);
        if (ifo->options & DHCPCD_STATIC) {
                syslog(LOG_INFO, "%s: using static address %s",
-                      iface->name, inet_ntoa(lease->addr));
+                   iface->name, inet_ntoa(lease->addr));
                lease->leasetime = ~0U;
                lease->net.s_addr = ifo->request_netmask.s_addr;
                state->reason = "STATIC";
        } else if (IN_LINKLOCAL(htonl(state->new->yiaddr))) {
                syslog(LOG_INFO, "%s: using IPv4LL address %s",
-                      iface->name, inet_ntoa(lease->addr));
+                   iface->name, inet_ntoa(lease->addr));
                lease->leasetime = ~0U;
                state->reason = "IPV4LL";
        } else if (ifo->options & DHCPCD_INFORM) {
@@ -148,7 +148,7 @@ bind_interface(void *arg)
                else
                        lease->addr.s_addr = iface->addr.s_addr;
                syslog(LOG_INFO, "%s: received approval for %s", iface->name,
-                      inet_ntoa(lease->addr));
+                   inet_ntoa(lease->addr));
                lease->leasetime = ~0U;
                state->reason = "INFORM";
        } else {
@@ -157,31 +157,33 @@ bind_interface(void *arg)
                else if (lease->frominfo)
                        state->reason = "TIMEOUT";
                if (lease->leasetime == ~0U) {
-                       lease->renewaltime = lease->rebindtime = lease->leasetime;
+                       lease->renewaltime =
+                           lease->rebindtime =
+                           lease->leasetime;
                        syslog(LOG_INFO, "%s: leased %s for infinity",
-                              iface->name, inet_ntoa(lease->addr));
+                           iface->name, inet_ntoa(lease->addr));
                } else {
                        if (lease->rebindtime == 0)
                                lease->rebindtime = lease->leasetime * T2;
                        else if (lease->rebindtime >= lease->leasetime) {
                                lease->rebindtime = lease->leasetime * T2;
                                syslog(LOG_ERR,
-                                      "%s: rebind time greater than lease "
-                                      "time, forcing to %u seconds",
-                                      iface->name, lease->rebindtime);
+                                   "%s: rebind time greater than lease "
+                                   "time, forcing to %u seconds",
+                                   iface->name, lease->rebindtime);
                        }
                        if (lease->renewaltime == 0)
                                lease->renewaltime = lease->leasetime * T1;
                        else if (lease->renewaltime > lease->rebindtime) {
                                lease->renewaltime = lease->leasetime * T1;
                                syslog(LOG_ERR,
-                                      "%s: renewal time greater than rebind "
-                                      "time, forcing to %u seconds",
-                                      iface->name, lease->renewaltime);
+                                   "%s: renewal time greater than rebind "
+                                   "time, forcing to %u seconds",
+                                   iface->name, lease->renewaltime);
                        }
                        syslog(LOG_INFO,
-                              "%s: leased %s for %u seconds", iface->name,
-                              inet_ntoa(lease->addr), lease->leasetime);
+                           "%s: leased %s for %u seconds", iface->name,
+                           inet_ntoa(lease->addr), lease->leasetime);
                }
        }
        if (options & DHCPCD_TEST) {
diff --git a/bpf.c b/bpf.c
index 948a72ca82f866825fe3c455a2d4af4cc83906f3..cf1e3d905a59a5021d5594e64c87b91d6c0cbff6 100644 (file)
--- a/bpf.c
+++ b/bpf.c
@@ -136,7 +136,7 @@ eexit:
 
 ssize_t
 send_raw_packet(const struct interface *iface, int protocol,
-               const void *data, ssize_t len)
+    const void *data, ssize_t len)
 {
        struct iovec iov[2];
        struct ether_header hw;
@@ -160,7 +160,7 @@ send_raw_packet(const struct interface *iface, int protocol,
  * So we pass the buffer in the API so we can loop on >1 packet. */
 ssize_t
 get_raw_packet(struct interface *iface, int protocol,
-              void *data, ssize_t len)
+    void *data, ssize_t len)
 {
        int fd = -1;
        struct bpf_hdr packet;
@@ -184,7 +184,7 @@ get_raw_packet(struct interface *iface, int protocol,
                }
                bytes = -1;
                memcpy(&packet, iface->buffer + iface->buffer_pos,
-                      sizeof(packet));
+                   sizeof(packet));
                if (packet.bh_caplen != packet.bh_datalen)
                        goto next; /* Incomplete packet, drop. */
                if (iface->buffer_pos + packet.bh_caplen + packet.bh_hdrlen >
@@ -197,7 +197,7 @@ get_raw_packet(struct interface *iface, int protocol,
                memcpy(data, payload, bytes);
 next:
                iface->buffer_pos += BPF_WORDALIGN(packet.bh_hdrlen +
-                                                  packet.bh_caplen);
+                   packet.bh_caplen);
                if (iface->buffer_pos >= iface->buffer_len)
                        iface->buffer_len = iface->buffer_pos = 0;
                if (bytes != -1)
index 48f51a4eef6f6cc2670ee334d93cac7ef37d7892..98fd7ba9914367d4e131a925fdc17d161848b645 100644 (file)
--- a/common.c
+++ b/common.c
@@ -180,8 +180,8 @@ set_cloexec(int fd)
 {
        int flags;
 
-       if ((flags = fcntl(fd, F_GETFD, 0)) == -1
-           || fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
+       if ((flags = fcntl(fd, F_GETFD, 0)) == -1 ||
+           fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
        {
                syslog(LOG_ERR, "fcntl: %m");
                return -1;
@@ -194,8 +194,8 @@ set_nonblock(int fd)
 {
        int flags;
 
-       if ((flags = fcntl(fd, F_GETFL, 0)) == -1
-           || fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1)
+       if ((flags = fcntl(fd, F_GETFL, 0)) == -1 ||
+           fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1)
        {
                syslog(LOG_ERR, "fcntl: %m");
                return -1;
index b336dcba4b060dd518c438f40eb42040ab2dd769..e2e6a272501c38e0ef33874bb06a2297828989b5 100644 (file)
@@ -108,7 +108,7 @@ make_var(const char *prefix, const char *var)
 
 static void
 append_config(char ***env, ssize_t *len,
-             const char *prefix, const char *const *config)
+    const char *prefix, const char *const *config)
 {
        ssize_t i, j, e1;
        char **ne, *eq;
@@ -121,7 +121,9 @@ append_config(char ***env, ssize_t *len,
                eq = strchr(config[i], '=');
                e1 = eq - config[i] + 1;
                for (j = 0; j < *len; j++) {
-                       if (strncmp(ne[j] + strlen(prefix) + 1, config[i], e1) == 0) {
+                       if (strncmp(ne[j] + strlen(prefix) + 1,
+                               config[i], e1) == 0)
+                       {
                                free(ne[j]);
                                ne[j] = make_var(prefix, config[i]);
                                break;
@@ -220,20 +222,20 @@ make_env(const struct interface *iface, char ***argv)
                if (e > 0) {
                        env = xrealloc(env, sizeof(char *) * (elen + e + 1));
                        elen += configure_env(env + elen, "old",
-                                       iface->state->old, ifo);
+                           iface->state->old, ifo);
                }
                append_config(&env, &elen, "old",
-                             (const char *const *)ifo->config);
+                   (const char *const *)ifo->config);
        }
        if (iface->state->new) {
                e = configure_env(NULL, NULL, iface->state->new, ifo);
                if (e > 0) {
                        env = xrealloc(env, sizeof(char *) * (elen + e + 1));
                        elen += configure_env(env + elen, "new",
-                                       iface->state->new, ifo);
+                           iface->state->new, ifo);
                }
                append_config(&env, &elen, "new",
-                             (const char *const *)ifo->config);
+                   (const char *const *)ifo->config);
        }
 
        /* Add our base environment */
@@ -292,7 +294,7 @@ run_script(const struct interface *iface)
        struct iovec iov[2];
 
        syslog(LOG_DEBUG, "%s: executing `%s', reason %s",
-              iface->name, argv[0], iface->state->reason);
+           iface->name, argv[0], iface->state->reason);
 
        /* Make our env */
        elen = make_env(iface, &env);
@@ -327,7 +329,7 @@ run_script(const struct interface *iface)
                if (fd->listener) {
                        if (bigenv == NULL) {
                                elen = arraytostr((const char *const *)env,
-                                               &bigenv);
+                                   &bigenv);
                                iov[0].iov_base = &elen;
                                iov[0].iov_len = sizeof(ssize_t);
                                iov[1].iov_base = bigenv;
@@ -348,7 +350,7 @@ run_script(const struct interface *iface)
 
 static struct rt *
 find_route(struct rt *rts, const struct rt *r, struct rt **lrt,
-          const struct rt *srt)
+    const struct rt *srt)
 {
        struct rt *rt;
 
@@ -357,7 +359,8 @@ find_route(struct rt *rts, const struct rt *r, struct rt **lrt,
        for (rt = rts; rt; rt = rt->next) {
                if (rt->dest.s_addr == r->dest.s_addr &&
 #if HAVE_ROUTE_METRIC
-                   (srt || (!rt->iface || rt->iface->metric == r->iface->metric)) &&
+                   (srt || (!rt->iface ||
+                       rt->iface->metric == r->iface->metric)) &&
 #endif
                     (!srt || srt != rt) &&
                    rt->net.s_addr == r->net.s_addr)
@@ -376,17 +379,17 @@ desc_route(const char *cmd, const struct rt *rt, const char *ifname)
        strlcpy(addr, inet_ntoa(rt->dest), sizeof(addr));
        if (rt->gate.s_addr == INADDR_ANY)
                syslog(LOG_DEBUG, "%s: %s route to %s/%d", ifname, cmd,
-                      addr, inet_ntocidr(rt->net));
+                   addr, inet_ntocidr(rt->net));
        else if (rt->gate.s_addr == rt->dest.s_addr &&
-                rt->net.s_addr == INADDR_BROADCAST)
+           rt->net.s_addr == INADDR_BROADCAST)
                syslog(LOG_DEBUG, "%s: %s host route to %s", ifname, cmd,
-                      addr);
+                   addr);
        else if (rt->dest.s_addr == INADDR_ANY && rt->net.s_addr == INADDR_ANY)
                syslog(LOG_DEBUG, "%s: %s default route via %s", ifname, cmd,
-                      inet_ntoa(rt->gate));
+                   inet_ntoa(rt->gate));
        else
                syslog(LOG_DEBUG, "%s: %s route to %s/%d via %s", ifname, cmd,
-                      addr, inet_ntocidr(rt->net), inet_ntoa(rt->gate));
+                   addr, inet_ntocidr(rt->net), inet_ntoa(rt->gate));
 }
 
 /* If something other than dhcpcd removes a route,
@@ -445,8 +448,10 @@ c_route(struct rt *ort, struct rt *nrt, const struct interface *iface)
        desc_route("changing", nrt, iface->name);
        /* We don't call change_route because it doesn't work when something
         * has already used it. */
-       del_route(ort->iface, &ort->dest, &ort->net, &ort->gate, ort->iface->metric);
-       if (!add_route(iface, &nrt->dest, &nrt->net, &nrt->gate, iface->metric))
+       del_route(ort->iface, &ort->dest, &ort->net, &ort->gate,
+           ort->iface->metric);
+       if (!add_route(iface, &nrt->dest, &nrt->net, &nrt->gate,
+               iface->metric))
                return 0;
        syslog(LOG_ERR, "%s: add_route: %m", iface->name);
        return -1;
@@ -585,9 +590,9 @@ delete_address(struct interface *iface)
        int retval;
 
        syslog(LOG_DEBUG, "%s: deleting IP address %s/%d",
-              iface->name,
-              inet_ntoa(iface->addr),
-              inet_ntocidr(iface->net));
+           iface->name,
+           inet_ntoa(iface->addr),
+           inet_ntocidr(iface->net));
        retval = del_address(iface, &iface->addr, &iface->net);
        if (retval == -1 && errno != EADDRNOTAVAIL) 
                syslog(LOG_ERR, "del_address: %m");
@@ -621,10 +626,10 @@ configure(struct interface *iface)
            !has_address(iface->name, &lease->addr, &lease->net))
        {
                syslog(LOG_DEBUG, "%s: adding IP address %s/%d",
-                      iface->name, inet_ntoa(lease->addr),
-                      inet_ntocidr(lease->net));
+                   iface->name, inet_ntoa(lease->addr),
+                   inet_ntocidr(lease->net));
                if (add_address(iface,
-                               &lease->addr, &lease->net, &lease->brd) == -1 &&
+                       &lease->addr, &lease->net, &lease->brd) == -1 &&
                    errno != EEXIST)
                {
                        syslog(LOG_ERR, "add_address: %m");
index 2786b23af11bcb1acc7d118dcb9396c365257137..65a9896331d7ec88a734cf65cf74198daea4596d 100644 (file)
--- a/control.c
+++ b/control.c
 #include "eloop.h"
 
 static int fd = -1;
-struct sockaddr_un sun;
 static char buffer[1024];
 static char *argvp[255];
 
+struct sockaddr_un sun;
 struct fd_list *fds = NULL;
 
 static void
@@ -134,7 +134,8 @@ start_control(void)
                return -1;
        unlink(CONTROLSOCKET);
        if (bind(fd, (struct sockaddr *)&sun, len) == -1 ||
-           chmod(CONTROLSOCKET, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) == -1 ||
+           chmod(CONTROLSOCKET,
+               S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) == -1 ||
            set_cloexec(fd) == -1 ||
            set_nonblock(fd) == -1 ||
            listen(fd, sizeof(fds)) == -1)
diff --git a/dhcp.c b/dhcp.c
index e53d27c8864fb7a37000a785c4d54d9688600b89..2689b734cd6d55c2bada5629c81a645f92349a08 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -58,7 +58,7 @@
 /* Our aggregate option buffer.
  * We ONLY use this when options are split, which for most purposes is
  * practically never. See RFC3396 for details. */
-static uint8_t *dhcp_opt_buffer;
+static uint8_t *opt_buffer;
 
 struct dhcp_opt {
        uint8_t option;
@@ -68,8 +68,9 @@ struct dhcp_opt {
 
 static const struct dhcp_opt const dhcp_opts[] = {
        { 1,    IPV4 | REQUEST, "subnet_mask" },
-       /* RFC 3442 states that the CSR has to come before all other routes.
-        * For completeness, we also specify static routes, then routers. */
+               /* RFC 3442 states that the CSR has to come before all other
+                * routes. For completeness, we also specify static routes,
+                * then routers. */
        { 121,  RFC3442 | REQUEST,      "classless_static_routes" },
        { 249,  RFC3442,        "ms_classless_static_routes" },
        { 33,   IPV4 | ARRAY | REQUEST, "static_routes" },
@@ -197,10 +198,10 @@ int make_option_mask(uint8_t *mask, const char *opts, int add)
                        if (match) {    
                                if (add == 1)
                                        add_option_mask(mask,
-                                                       opt->option);
+                                           opt->option);
                                else
                                        del_option_mask(mask,
-                                                       opt->option);
+                                           opt->option);
                                break;
                        }
                }
@@ -230,7 +231,9 @@ valid_length(uint8_t option, int dl, int *type)
                if (type)
                        *type = opt->type;
 
-               if (opt->type == 0 || opt->type & STRING || opt->type & RFC3442)
+               if (opt->type == 0 ||
+                   opt->type & STRING ||
+                   opt->type & RFC3442)
                        return 0;
 
                sz = 0;
@@ -253,7 +256,7 @@ valid_length(uint8_t option, int dl, int *type)
 static void
 free_option_buffer(void)
 {
-       free(dhcp_opt_buffer);
+       free(opt_buffer);
 }
 #endif
 
@@ -274,14 +277,14 @@ get_option(const struct dhcp_message *dhcp, uint8_t opt, int *len, int *type)
                o = *p++;
                if (o == opt) {
                        if (op) {
-                               if (!dhcp_opt_buffer) {
-                                       dhcp_opt_buffer = xmalloc(sizeof(struct dhcp_message));
+                               if (!opt_buffer) {
+                                       opt_buffer = xmalloc(sizeof(*dhcp));
 #ifdef DEBUG_MEMORY
                                        atexit(free_option_buffer);
 #endif
                                }
                                if (!bp) 
-                                       bp = dhcp_opt_buffer;
+                                       bp = opt_buffer;
                                memcpy(bp, op, ol);
                                bp += ol;
                        }
@@ -325,7 +328,7 @@ exit:
                *len = bl;
        if (bp) {
                memcpy(bp, op, ol);
-               return (const uint8_t *)&dhcp_opt_buffer;
+               return (const uint8_t *)&opt_buffer;
        }
        if (op)
                return op;
@@ -745,17 +748,17 @@ encode_rfc1035(const char *src, uint8_t *dst)
        return p - dst;
 }
 
-#define PUTADDR(_type, _val) \
-{ \
-       *p++ = _type; \
-       *p++ = 4; \
-       memcpy(p, &_val.s_addr, 4); \
-       p += 4; \
-}
+#define PUTADDR(_type, _val)                                           \
+       {                                                               \
+               *p++ = _type;                                           \
+               *p++ = 4;                                               \
+               memcpy(p, &_val.s_addr, 4);                             \
+               p += 4;                                                 \
+       }
 ssize_t
 make_message(struct dhcp_message **message,
-            const struct interface *iface,
-            uint8_t type)
+    const struct interface *iface,
+    uint8_t type)
 {
        struct dhcp_message *dhcp;
        uint8_t *m, *lp, *p;
@@ -774,12 +777,12 @@ make_message(struct dhcp_message **message,
        p = dhcp->options;
 
        if ((type == DHCP_INFORM ||
-            type == DHCP_RELEASE ||
-            type == DHCP_REQUEST) &&
+               type == DHCP_RELEASE ||
+               type == DHCP_REQUEST) &&
            !IN_LINKLOCAL(ntohl(iface->addr.s_addr)))
        {
                dhcp->ciaddr = iface->addr.s_addr;
-               /* Just incase we haven't actually configured the address yet */
+               /* In-case we haven't actually configured the address yet */
                if (type == DHCP_INFORM && iface->addr.s_addr == 0)
                        dhcp->ciaddr = lease->addr.s_addr;
                /* Zero the address if we're currently on a different subnet */
@@ -828,7 +831,7 @@ make_message(struct dhcp_message **message,
                if (type == DHCP_DECLINE ||
                    type == DHCP_DISCOVER ||
                    (type == DHCP_REQUEST &&
-                    lease->addr.s_addr != iface->addr.s_addr))
+                       lease->addr.s_addr != iface->addr.s_addr))
                {
                        PUTADDR(DHO_IPADDRESS, lease->addr);
                        if (lease->server.s_addr)
@@ -836,8 +839,8 @@ make_message(struct dhcp_message **message,
                }
 
                if (type == DHCP_RELEASE) {
-                   if (lease->server.s_addr)
-                       PUTADDR(DHO_SERVERID, lease->server);
+                       if (lease->server.s_addr)
+                               PUTADDR(DHO_SERVERID, lease->server);
                }
        }
 
@@ -873,7 +876,7 @@ make_message(struct dhcp_message **message,
                if (ifo->vendorclassid[0]) {
                        *p++ = DHO_VENDORCLASSID;
                        memcpy(p, ifo->vendorclassid,
-                              ifo->vendorclassid[0] + 1);
+                           ifo->vendorclassid[0] + 1);
                        p += ifo->vendorclassid[0] + 1;
                }
 
@@ -938,11 +941,11 @@ make_message(struct dhcp_message **message,
                *p++ = 0;
                for (opt = dhcp_opts; opt->option; opt++) {
                        if (!(opt->type & REQUEST || 
-                             has_option_mask(ifo->requestmask, opt->option)))
+                               has_option_mask(ifo->requestmask, opt->option)))
                                continue;
                        if (type == DHCP_INFORM &&
                            (opt->option == DHO_RENEWALTIME ||
-                            opt->option == DHO_REBINDTIME))
+                               opt->option == DHO_REBINDTIME))
                                continue;
                        *p++ = opt->option;
                }
@@ -1055,21 +1058,21 @@ print_string(char *s, ssize_t len, int dl, const uint8_t *data)
                        continue;
                }
                switch (c) {
-                       case '"':  /* FALLTHROUGH */
-                       case '\'': /* FALLTHROUGH */
-                       case '$':  /* FALLTHROUGH */
-                       case '`':  /* FALLTHROUGH */
-                       case '\\': /* FALLTHROUGH */
-                               if (s) {
-                                       if (len < 3) {
-                                               errno = ENOBUFS;
-                                               return -1;
-                                       }
-                                       *s++ = '\\';
-                                       len--;
+               case '"':  /* FALLTHROUGH */
+               case '\'': /* FALLTHROUGH */
+               case '$':  /* FALLTHROUGH */
+               case '`':  /* FALLTHROUGH */
+               case '\\': /* FALLTHROUGH */
+                       if (s) {
+                               if (len < 3) {
+                                       errno = ENOBUFS;
+                                       return -1;
                                }
-                               bytes++;
-                               break;
+                               *s++ = '\\';
+                               len--;
+                       }
+                       bytes++;
+                       break;
                }
                if (s) {
                        *s++ = c;
@@ -1201,7 +1204,7 @@ setvar(char ***e, const char *prefix, const char *var, const char *value)
 
 ssize_t
 configure_env(char **env, const char *prefix, const struct dhcp_message *dhcp,
-             const struct if_options *ifo)
+    const struct if_options *ifo)
 {
        unsigned int i;
        const uint8_t *p;
index 39f849f832923f8fe122271bf24c93582b2be1dc..4d9daa2dd3a5581a2978411d6e35718906825ebc 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -131,10 +131,14 @@ read_pid(void)
 static void
 usage(void)
 {
-       printf("usage: "PACKAGE" [-dknpqxyADEGHKLOTV] [-c script] [-f file ] [-h hostname]\n"
-              "              [-i classID ] [-l leasetime] [-m metric] [-o option] [-r ipaddr]\n"
-              "              [-s ipaddr] [-t timeout] [-u userclass] [-F none|ptr|both]\n"
-              "              [-I clientID] [-C hookscript] [-Q option] [-X ipaddr] <interface>\n");
+       printf("usage: "PACKAGE" [-dknpqxyADEGHKLOTV] [-c script] [-f file ]"
+           " [-h hostname]\n"
+           "              [-i classID ] [-l leasetime] [-m metric]"
+           " [-o option] [-r ipaddr]\n"
+           "              [-s ipaddr] [-t timeout] [-u userclass]"
+           " [-F none|ptr|both]\n"
+           "              [-I clientID] [-C hookscript] [-Q option]"
+           " [-X ipaddr] <interface>\n");
 }
 
 static void
@@ -250,7 +254,7 @@ stop_interface(struct interface *iface)
 
 static void
 send_message(struct interface *iface, int type,
-            void (*callback)(void *))
+    void (*callback)(void *))
 {
        struct if_state *state = iface->state;
        struct dhcp_message *dhcp;
@@ -262,7 +266,7 @@ send_message(struct interface *iface, int type,
 
        if (!callback)
                syslog(LOG_DEBUG, "%s: sending %s with xid 0x%x",
-                      iface->name, get_dhcp_op(type), state->xid);
+                   iface->name, get_dhcp_op(type), state->xid);
        else {
                if (state->interval == 0)
                        state->interval = 4;
@@ -274,9 +278,9 @@ send_message(struct interface *iface, int type,
                tv.tv_sec = state->interval + DHCP_RAND_MIN;
                tv.tv_usec = arc4random() % (DHCP_RAND_MAX_U - DHCP_RAND_MIN_U);
                syslog(LOG_DEBUG,
-                      "%s: sending %s (xid 0x%x), next in %0.2f seconds",
-                      iface->name, get_dhcp_op(type), state->xid,
-                      timeval_to_double(&tv));
+                   "%s: sending %s (xid 0x%x), next in %0.2f seconds",
+                   iface->name, get_dhcp_op(type), state->xid,
+                   timeval_to_double(&tv));
        }
        /* If we couldn't open a UDP port for our IP address
         * then we cannot renew.
@@ -350,7 +354,7 @@ start_rebind(void *arg)
        struct interface *iface = arg;
 
        syslog(LOG_ERR, "%s: failed to renew, attmepting to rebind",
-              iface->name);
+           iface->name);
        iface->state->state = DHS_REBIND;
        delete_timeout(send_renew, iface);
        iface->state->lease.server.s_addr = 0;
@@ -386,7 +390,7 @@ send_decline(struct interface *iface)
 
 static void
 log_dhcp(int lvl, const char *msg,
-        const struct interface *iface, const struct dhcp_message *dhcp)
+    const struct interface *iface, const struct dhcp_message *dhcp)
 {
        char *a;
        struct in_addr addr;
@@ -401,10 +405,10 @@ log_dhcp(int lvl, const char *msg,
        r = get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID);
        if (dhcp->servername[0] && r == 0)
                syslog(lvl, "%s: %s %s from %s `%s'", iface->name, msg, a,
-                      inet_ntoa(addr), dhcp->servername);
+                   inet_ntoa(addr), dhcp->servername);
        else if (r == 0)
                syslog(lvl, "%s: %s %s from %s",
-                      iface->name, msg, a, inet_ntoa(addr));
+                   iface->name, msg, a, inet_ntoa(addr));
        else
                syslog(lvl, "%s: %s %s", iface->name, msg, a);
        free(a);
@@ -439,13 +443,13 @@ handle_dhcp(struct interface *iface, struct dhcp_message **dhcpp)
                                continue;
                        if (dhcp->servername[0])
                                syslog(LOG_WARNING,
-                                      "%s: ignoring blacklisted server %s `%s'",
-                                      iface->name,
-                                      inet_ntoa(addr), dhcp->servername);
+                                   "%s: ignoring blacklisted server %s `%s'",
+                                   iface->name,
+                                   inet_ntoa(addr), dhcp->servername);
                        else
                                syslog(LOG_WARNING,
-                                      "%s: ignoring blacklisted server %s",
-                                      iface->name, inet_ntoa(addr));
+                                   "%s: ignoring blacklisted server %s",
+                                   iface->name, inet_ntoa(addr));
                        return;
                }
        }
@@ -577,7 +581,7 @@ handle_dhcp_packet(void *arg)
        packet = xmalloc(udp_dhcp_len);
        for(;;) {
                bytes = get_raw_packet(iface, ETHERTYPE_IP,
-                                      packet, udp_dhcp_len);
+                   packet, udp_dhcp_len);
                if (bytes == 0 || bytes == -1)
                        break;
                if (valid_udp_packet(packet) == -1)
@@ -585,7 +589,7 @@ handle_dhcp_packet(void *arg)
                bytes = get_udp_data(&pp, packet);
                if ((size_t)bytes > sizeof(*dhcp)) {
                        syslog(LOG_ERR, "%s: packet greater than DHCP size",
-                              iface->name);
+                           iface->name);
                        continue;
                }
                if (!dhcp)
@@ -593,15 +597,15 @@ handle_dhcp_packet(void *arg)
                memcpy(dhcp, pp, bytes);
                if (dhcp->cookie != htonl(MAGIC_COOKIE)) {
                        syslog(LOG_DEBUG, "%s: bogus cookie, ignoring",
-                              iface->name);
+                           iface->name);
                        continue;
                }
                /* Ensure it's the right transaction */
                if (iface->state->xid != dhcp->xid) {
                        syslog(LOG_DEBUG,
-                              "%s: ignoring packet with xid 0x%x as"
-                              " it's not ours (0x%x)",
-                              iface->name, dhcp->xid, iface->state->xid);
+                           "%s: ignoring packet with xid 0x%x as"
+                           " it's not ours (0x%x)",
+                           iface->name, dhcp->xid, iface->state->xid);
                        continue;
                }
                /* Ensure packet is for us */
@@ -609,8 +613,8 @@ handle_dhcp_packet(void *arg)
                    memcmp(dhcp->chaddr, iface->hwaddr, iface->hwlen))
                {
                        syslog(LOG_DEBUG, "%s: xid 0x%x is not for our hwaddr %s",
-                              iface->name, dhcp->xid,
-                              hwaddr_ntoa(dhcp->chaddr, sizeof(dhcp->chaddr)));
+                           iface->name, dhcp->xid,
+                           hwaddr_ntoa(dhcp->chaddr, sizeof(dhcp->chaddr)));
                        continue;
                }
                handle_dhcp(iface, &dhcp);
@@ -644,7 +648,7 @@ send_release(struct interface *iface)
            !IN_LINKLOCAL(htonl(iface->state->lease.addr.s_addr)))
        {
                syslog(LOG_INFO, "%s: releasing lease of %s",
-                      iface->name, inet_ntoa(iface->state->lease.addr));
+                   iface->name, inet_ntoa(iface->state->lease.addr));
                open_sockets(iface);
                send_message(iface, DHCP_RELEASE, NULL);
                drop_config(iface, "RELEASE");
@@ -691,7 +695,7 @@ configure_interface(struct interface *iface, int argc, char **argv)
                                memcpy(iface->clientid + 2, iface->name, ifl);
                                if (ifl < 4)
                                        memset(iface->clientid + 2 + ifl,
-                                              0, 4 - ifl);
+                                           0, 4 - ifl);
                        } else {
                                ifl = htonl(if_nametoindex(iface->name));
                                memcpy(iface->clientid + 2, &ifl, 4);
@@ -702,7 +706,7 @@ configure_interface(struct interface *iface, int argc, char **argv)
                        iface->clientid[0] = len;
                        iface->clientid[1] = iface->family;
                        memcpy(iface->clientid + 2, iface->hwaddr,
-                              iface->hwlen);
+                           iface->hwlen);
                }
        }
 }
@@ -789,7 +793,7 @@ start_renew(void *arg)
        struct interface *iface = arg;
 
        syslog(LOG_INFO, "%s: renewing lease of %s",
-              iface->name, inet_ntoa(iface->state->lease.addr));
+           iface->name, inet_ntoa(iface->state->lease.addr));
        iface->state->state = DHS_RENEW;
        iface->state->xid = arc4random();
        open_sockets(iface);
@@ -829,10 +833,10 @@ start_reboot(struct interface *iface)
        }
        if (ifo->options & DHCPCD_INFORM) {
                syslog(LOG_INFO, "%s: informing address of %s",
-                      iface->name, inet_ntoa(iface->state->lease.addr));
+                   iface->name, inet_ntoa(iface->state->lease.addr));
        } else {
                syslog(LOG_INFO, "%s: rebinding lease of %s",
-                      iface->name, inet_ntoa(iface->state->lease.addr));
+                   iface->name, inet_ntoa(iface->state->lease.addr));
        }
        iface->state->state = DHS_REBOOT;
        iface->state->xid = arc4random();
@@ -901,14 +905,14 @@ start_interface(void *arg)
        if (ifo->request_address.s_addr) {
                /* This also changes netmask */
                if (iface->state->options->options & DHCPCD_INFORM &&
-                  !has_address(iface->name, &ifo->request_address,
-                               &ifo->request_netmask))
+                   !has_address(iface->name, &ifo->request_address,
+                       &ifo->request_netmask))
                {
                        syslog(LOG_DEBUG, "%s: adding IP address %s/%d",
-                              iface->name, inet_ntoa(ifo->request_address),
-                              inet_ntocidr(ifo->request_netmask));
+                           iface->name, inet_ntoa(ifo->request_address),
+                           inet_ntocidr(ifo->request_netmask));
                        if (add_address(iface, &ifo->request_address,
-                                       &ifo->request_netmask, NULL) == -1 &&
+                               &ifo->request_netmask, NULL) == -1 &&
                            errno != EEXIST)
                        {
                                syslog(LOG_ERR, "add_address: %m");
@@ -921,23 +925,19 @@ start_interface(void *arg)
                        ifo->request_address.s_addr = 0;
        } else
                iface->state->offer = read_lease(iface);
-/*     if (iface->state->offer) {
-               if (IN_LINKLOCAL(htonl(iface->state->offer->yiaddr))) {
-                       free(iface->state->offer);
-                       iface->state->offer = NULL;
-               }
-       } */
        if (iface->state->offer) {
                get_lease(&iface->state->lease, iface->state->offer);
                iface->state->lease.frominfo = 1;
                if (IN_LINKLOCAL(htonl(iface->state->offer->yiaddr))) {
-                       if (iface->state->offer->yiaddr == iface->addr.s_addr) {
+                       if (iface->state->offer->yiaddr ==
+                           iface->addr.s_addr)
+                       {
                                free(iface->state->offer);
                                iface->state->offer = NULL;
                        }
                } else if (stat(iface->leasefile, &st) == 0 &&
-                          get_option_uint32(&l, iface->state->offer,
-                                            DHO_LEASETIME) == 0)
+                   get_option_uint32(&l, iface->state->offer,
+                       DHO_LEASETIME) == 0)
                {
                        /* Offset lease times and check expiry */
                        gettimeofday(&now, NULL);
@@ -955,7 +955,7 @@ start_interface(void *arg)
        if (!iface->state->offer)
                start_discover(iface);
        else if (IN_LINKLOCAL(htonl(iface->state->lease.addr.s_addr)) &&
-                iface->state->options->options & DHCPCD_IPV4LL)
+           iface->state->options->options & DHCPCD_IPV4LL)
                start_ipv4ll(iface);
        else
                start_reboot(iface);
@@ -966,9 +966,9 @@ init_state(struct interface *iface, int argc, char **argv)
 {
        struct if_state *ifs;
 
-       if (iface->state) {
+       if (iface->state)
                ifs = iface->state;
-       else
+       else
                ifs = iface->state = xzalloc(sizeof(*ifs));
 
        ifs->state = DHS_INIT;
@@ -1049,9 +1049,9 @@ static void
 handle_link(_unused void *arg)
 {
        if (manage_link(linkfd,
-                       handle_carrier,
-                       handle_new_interface,
-                       handle_remove_interface) == -1)
+               handle_carrier,
+               handle_new_interface,
+               handle_remove_interface) == -1)
                syslog(LOG_ERR, "manage_link: %m");
 }
 
@@ -1084,8 +1084,8 @@ handle_signal(_unused void *arg)
                return;
        default:
                syslog(LOG_ERR,
-                      "received signal %d, but don't know what to do with it",
-                      sig);
+                   "received signal %d, but don't know what to do with it",
+                   sig);
                return;
        }
 
@@ -1102,7 +1102,7 @@ handle_signal(_unused void *arg)
                        break;
                if (iface->carrier != LINK_DOWN &&
                    (do_release ||
-                    iface->state->options->options & DHCPCD_RELEASE))
+                       iface->state->options->options & DHCPCD_RELEASE))
                        send_release(iface);
                stop_interface(iface);
        }
@@ -1341,7 +1341,8 @@ main(int argc, char **argv)
        if (!(options & DHCPCD_MASTER)) {
                control_fd = open_control();
                if (control_fd != -1) {
-                       syslog(LOG_INFO, "sending commands to master dhcpcd process");
+                       syslog(LOG_INFO,
+                           "sending commands to master dhcpcd process");
                        i = send_control(argc, argv);
                        if (i > 0) {
                                syslog(LOG_DEBUG, "send OK");
@@ -1357,15 +1358,15 @@ main(int argc, char **argv)
        }
 
        if (geteuid())
-               syslog(LOG_WARNING, PACKAGE " will not work correctly unless"
-                      " run as root");
+               syslog(LOG_WARNING,
+                   PACKAGE " will not work correctly unless run as root");
 
        if (sig != 0) {
                i = -1;
                pid = read_pid();
                if (pid != 0)
                        syslog(LOG_INFO, "sending signal %d to pid %d",
-                              sig, pid);
+                           sig, pid);
 
                if (!pid || (i = kill(pid, sig))) {
                        if (sig != SIGALRM)
@@ -1393,8 +1394,8 @@ main(int argc, char **argv)
                    kill(pid, 0) == 0)
                {
                        syslog(LOG_ERR, ""PACKAGE
-                              " already running on pid %d (%s)",
-                              pid, pidfile);
+                           " already running on pid %d (%s)",
+                           pid, pidfile);
                        exit(EXIT_FAILURE);
                }
 
@@ -1458,7 +1459,7 @@ main(int argc, char **argv)
                                break;
                if (!iface)
                        syslog(LOG_ERR, "%s: interface not found or invalid",
-                              ifv[i]);
+                           ifv[i]);
        }
        if (!ifaces) {
                if (ifc == 0)
@@ -1467,7 +1468,7 @@ main(int argc, char **argv)
                    !(options & DHCPCD_LINK))
                {
                        syslog(LOG_ERR, "aborting as we're not backgrounding"
-                              " with link detection");
+                           " with link detection");
                        exit(EXIT_FAILURE);
                }
        }
diff --git a/eloop.c b/eloop.c
index a2432cd3c9226e9cb686d17f9fb588ad9620a277..d03641ca2ac5e7fa5ce5c55c413935ec7e8d2146 100644 (file)
--- a/eloop.c
+++ b/eloop.c
@@ -109,8 +109,7 @@ delete_event(int fd)
 }
 
 void
-add_timeout_tv(const struct timeval *when,
-              void (*callback)(void *), void *arg)
+add_timeout_tv(const struct timeval *when, void (*callback)(void *), void *arg)
 {
        struct timeval w;
        struct timeout *t, *tt = NULL;
@@ -169,8 +168,7 @@ add_timeout_tv(const struct timeval *when,
 }
 
 void
-add_timeout_sec(time_t when,
-               void (*callback)(void *), void *arg)
+add_timeout_sec(time_t when, void (*callback)(void *), void *arg)
 {
        struct timeval tv;
 
@@ -183,8 +181,7 @@ add_timeout_sec(time_t when,
  * callbacks given. Handy for deleting everything apart from the expire
  * timeout. */
 void
-delete_timeouts(void *arg,
-               void (*callback)(void *), ...)
+delete_timeouts(void *arg, void (*callback)(void *), ...)
 {
        struct timeout *t, *tt, *last = NULL;
        va_list va;
@@ -295,11 +292,11 @@ start_eloop(void)
                        timersub(&timeouts->when, &now, &tv);
                        if (tv.tv_sec > INT_MAX / 1000 ||
                            (tv.tv_sec == INT_MAX / 1000 &&
-                            (tv.tv_usec + 999) / 1000 > INT_MAX % 1000))
+                               (tv.tv_usec + 999) / 1000 > INT_MAX % 1000))
                                msecs = INT_MAX;
                        else
                                msecs = tv.tv_sec * 1000 +
-                                       (tv.tv_usec + 999) / 1000;
+                                   (tv.tv_usec + 999) / 1000;
                } else
                        /* No timeouts, so wait forever. */
                        msecs = -1;
index 1ac15a4ddd0443217ff7990afe0c0561b0f74ed6..c93d879e4d15c363a0ef5a235d6508a615041acb 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
 #include "if-options.h"
 #include "net.h"
 
-#define ROUNDUP(a) \
+#define ROUNDUP(a)                                                     \
        ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
 
 /* Darwin doesn't define this for some very odd reason */
 #ifndef SA_SIZE
-# define SA_SIZE(sa)                                           \
-       (  (!(sa) || ((struct sockaddr *)(sa))->sa_len == 0) ?  \
-          sizeof(long)         :                               \
-          1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(long) - 1) ) )
+# define SA_SIZE(sa)                                                   \
+       (  (!(sa) || ((struct sockaddr *)(sa))->sa_len == 0) ?          \
+           sizeof(long)                :                               \
+           1 + ( (((struct sockaddr *)(sa))->sa_len - 1) |             \
+               (sizeof(long) - 1) ) )
 #endif
 
 static int a_fd = -1;
@@ -121,8 +122,8 @@ getifssid(const char *ifname, char *ssid)
 
 int
 if_address(const struct interface *iface, const struct in_addr *address,
-          const struct in_addr *netmask, const struct in_addr *broadcast,
-          int action)
+    const struct in_addr *netmask, const struct in_addr *broadcast,
+    int action)
 {
        int retval;
        struct ifaliasreq ifa;
@@ -134,12 +135,12 @@ if_address(const struct interface *iface, const struct in_addr *address,
        memset(&ifa, 0, sizeof(ifa));
        strlcpy(ifa.ifra_name, iface->name, sizeof(ifa.ifra_name));
 
-#define ADDADDR(_var, _addr) { \
-       _s.sa = &_var; \
-       _s.sin->sin_family = AF_INET; \
-       _s.sin->sin_len = sizeof(*_s.sin); \
-       memcpy(&_s.sin->sin_addr, _addr, sizeof(_s.sin->sin_addr)); \
-}
+#define ADDADDR(_var, _addr) {                                         \
+               _s.sa = &_var;                                          \
+               _s.sin->sin_family = AF_INET;                           \
+               _s.sin->sin_len = sizeof(*_s.sin);                      \
+               memcpy(&_s.sin->sin_addr, _addr, sizeof(_s.sin->sin_addr)); \
+       }
 
        ADDADDR(ifa.ifra_addr, address);
        ADDADDR(ifa.ifra_mask, netmask);
@@ -158,8 +159,8 @@ if_address(const struct interface *iface, const struct in_addr *address,
 /* ARGSUSED4 */
 int
 if_route(const struct interface *iface, const struct in_addr *dest,
-        const struct in_addr *net, const struct in_addr *gate,
-        _unused int metric, int action)
+    const struct in_addr *net, const struct in_addr *gate,
+    _unused int metric, int action)
 {
        union sockunion {
                struct sockaddr sa;
@@ -179,18 +180,18 @@ if_route(const struct interface *iface, const struct in_addr *dest,
        size_t l;
        int retval = 0;
 
-#define ADDSU(_su) { \
-       l = SA_SIZE(&(_su.sa)); \
-       memcpy(bp, &(_su), l); \
-       bp += l; \
-} 
-#define ADDADDR(_addr) { \
-       memset (&su, 0, sizeof(su)); \
-       su.sin.sin_family = AF_INET; \
-       su.sin.sin_len = sizeof(su.sin); \
-       memcpy (&su.sin.sin_addr, _addr, sizeof(su.sin.sin_addr)); \
-       ADDSU(su); \
-}
+#define ADDSU(_su) {                                                   \
+               l = SA_SIZE(&(_su.sa));                                 \
+               memcpy(bp, &(_su), l);                                  \
+               bp += l;                                                \
+       
+#define ADDADDR(_addr) {                                               \
+               memset (&su, 0, sizeof(su));                            \
+               su.sin.sin_family = AF_INET;                            \
+               su.sin.sin_len = sizeof(su.sin);                        \
+               memcpy (&su.sin.sin_addr, _addr, sizeof(su.sin.sin_addr)); \
+               ADDSU(su);                                              \
+       }
 
        memset(&rtm, 0, sizeof(rtm));
        rtm.hdr.rtm_version = RTM_VERSION;
@@ -219,7 +220,9 @@ if_route(const struct interface *iface, const struct in_addr *dest,
        }
 
        ADDADDR(dest);
-       if (rtm.hdr.rtm_flags & RTF_HOST || !(rtm.hdr.rtm_flags & RTF_STATIC)) {
+       if (rtm.hdr.rtm_flags & RTF_HOST ||
+           !(rtm.hdr.rtm_flags & RTF_STATIC))
+       {
                /* Make us a link layer socket for the host gateway */
                memset(&su, 0, sizeof(su));
                su.sdl.sdl_len = sizeof(struct sockaddr_dl);
@@ -305,9 +308,9 @@ open_link_socket(void)
 #define BUFFER_LEN     2048
 int
 manage_link(int fd,
-           void (*if_carrier)(const char *),
-           void (*if_add)(const char *),
-           void (*if_remove)(const char *))
+    void (*if_carrier)(const char *),
+    void (*if_add)(const char *),
+    void (*if_remove)(const char *))
 {
        char buffer[2048], *p, *e;
        char ifname[IF_NAMESIZE];
@@ -363,17 +366,17 @@ manage_link(int fd,
                                rt.iface = NULL;
                                sin = (struct sockaddr_in *)sa;
                                memcpy(&rt.dest.s_addr, &sin->sin_addr.s_addr,
-                                       sizeof(rt.dest.s_addr));
+                                   sizeof(rt.dest.s_addr));
                                sa = (struct sockaddr *)
                                    (ROUNDUP(sa->sa_len) + (char *)sa);
                                sin = (struct sockaddr_in *)sa;
                                memcpy(&rt.gate.s_addr, &sin->sin_addr.s_addr,
-                                       sizeof(rt.gate.s_addr));
+                                   sizeof(rt.gate.s_addr));
                                sa = (struct sockaddr *)
                                    (ROUNDUP(sa->sa_len) + (char *)sa);
                                sin = (struct sockaddr_in *)sa;
                                memcpy(&rt.net.s_addr, &sin->sin_addr.s_addr,
-                                       sizeof(rt.net.s_addr));
+                                   sizeof(rt.net.s_addr));
                                route_deleted(&rt);
                                break;
                        }
@@ -383,7 +386,7 @@ manage_link(int fd,
 
 static void
 discover_link(struct interface **ifs, int argc, char * const *argv,
-             struct ifreq *ifr)
+    struct ifreq *ifr)
 {
        struct interface *ifp, *ifl = NULL;
        struct sockaddr_dl *sdl;
@@ -424,10 +427,10 @@ discover_link(struct interface **ifs, int argc, char * const *argv,
        default:
                /* Don't needlessly spam console on startup */
                if (!(options & DHCPCD_MASTER &&
-                   !(options & DHCPCD_DAEMONISED) &&
-                   options & DHCPCD_QUIET))
+                       !(options & DHCPCD_DAEMONISED) &&
+                       options & DHCPCD_QUIET))
                        syslog(LOG_ERR, "%s: unsupported interface type",
-                              ifr->ifr_name);
+                           ifr->ifr_name);
                free(ifp);
                ifp = NULL;
                break;
index ce2f92e344c9f05d8ee3e7e53923445b8faf810d..3e2f9077687088bfc5a909c403c213e535f96dbe 100644 (file)
@@ -134,7 +134,7 @@ open_link_socket(void)
 
 static int
 get_netlink(int fd, int flags,
-           int (*callback)(struct nlmsghdr *))
+    int (*callback)(struct nlmsghdr *))
 {
        char *buffer = NULL;
        ssize_t bytes;
@@ -217,11 +217,11 @@ link_delroute(struct nlmsghdr *nlm)
                switch (rta->rta_type) {
                case RTA_DST:
                        memcpy(&rt.dest.s_addr, RTA_DATA(rta),
-                              sizeof(rt.dest.s_addr));
+                           sizeof(rt.dest.s_addr));
                        break;
                case RTA_GATEWAY:
                        memcpy(&rt.gate.s_addr, RTA_DATA(rta),
-                              sizeof(rt.gate.s_addr));
+                           sizeof(rt.gate.s_addr));
                        break;
                case RTA_OIF:
                        idx = *(int *)RTA_DATA(rta);
@@ -300,9 +300,9 @@ link_netlink(struct nlmsghdr *nlm)
 
 int
 manage_link(int fd,
-           void (*if_carrier)(const char *),
-           void (*if_add)(const char *),
-           void (*if_remove)(const char *))
+    void (*if_carrier)(const char *),
+    void (*if_add)(const char *),
+    void (*if_remove)(const char *))
 {
        nl_carrier = if_carrier;
        nl_add = if_add;
@@ -337,12 +337,12 @@ send_netlink(struct nlmsghdr *hdr)
        return r;
 }
 
-#define NLMSG_TAIL(nmsg) \
+#define NLMSG_TAIL(nmsg)                                               \
        ((struct rtattr *)(((ptrdiff_t)(nmsg))+NLMSG_ALIGN((nmsg)->nlmsg_len)))
 
 static int
 add_attr_l(struct nlmsghdr *n, unsigned int maxlen, int type,
-          const void *data, int alen)
+    const void *data, int alen)
 {
        int len = RTA_LENGTH(alen);
        struct rtattr *rta;
@@ -397,8 +397,8 @@ struct nlmr
 
 int
 if_address(const struct interface *iface,
-          const struct in_addr *address, const struct in_addr *netmask,
-          const struct in_addr *broadcast, int action)
+    const struct in_addr *address, const struct in_addr *netmask,
+    const struct in_addr *broadcast, int action)
 {
        struct nlma *nlm;
        int retval = 0;
@@ -420,12 +420,12 @@ if_address(const struct interface *iface,
        nlm->ifa.ifa_prefixlen = inet_ntocidr(*netmask);
        /* This creates the aliased interface */
        add_attr_l(&nlm->hdr, sizeof(*nlm), IFA_LABEL,
-                  iface->name, strlen(iface->name) + 1);
+           iface->name, strlen(iface->name) + 1);
        add_attr_l(&nlm->hdr, sizeof(*nlm), IFA_LOCAL,
-                  &address->s_addr, sizeof(address->s_addr));
+           &address->s_addr, sizeof(address->s_addr));
        if (action >= 0 && broadcast)
                add_attr_l(&nlm->hdr, sizeof(*nlm), IFA_BROADCAST,
-                          &broadcast->s_addr, sizeof(broadcast->s_addr));
+                   &broadcast->s_addr, sizeof(broadcast->s_addr));
 
        if (send_netlink(&nlm->hdr) == -1)
                retval = -1;
@@ -435,8 +435,8 @@ if_address(const struct interface *iface,
 
 int
 if_route(const struct interface *iface,
-        const struct in_addr *destination, const struct in_addr *netmask,
-        const struct in_addr *gateway, int metric, int action)
+    const struct in_addr *destination, const struct in_addr *netmask,
+    const struct in_addr *gateway, int metric, int action)
 {
        struct nlmr *nlm;
        unsigned int ifindex;
@@ -473,7 +473,7 @@ if_route(const struct interface *iface,
                        nlm->rt.rtm_protocol = RTPROT_BOOT;
                if (gateway->s_addr == INADDR_ANY ||
                    (gateway->s_addr == destination->s_addr &&
-                    netmask->s_addr == INADDR_BROADCAST))
+                       netmask->s_addr == INADDR_BROADCAST))
                        nlm->rt.rtm_scope = RT_SCOPE_LINK;
                else
                        nlm->rt.rtm_scope = RT_SCOPE_UNIVERSE;
@@ -482,16 +482,16 @@ if_route(const struct interface *iface,
 
        nlm->rt.rtm_dst_len = inet_ntocidr(*netmask);
        add_attr_l(&nlm->hdr, sizeof(*nlm), RTA_DST,
-                  &destination->s_addr, sizeof(destination->s_addr));
+           &destination->s_addr, sizeof(destination->s_addr));
        if (nlm->rt.rtm_protocol == RTPROT_KERNEL) {
                add_attr_l(&nlm->hdr, sizeof(*nlm), RTA_PREFSRC,
-                          &iface->addr.s_addr, sizeof(iface->addr.s_addr));
+                   &iface->addr.s_addr, sizeof(iface->addr.s_addr));
        }
        /* If destination == gateway then don't add the gateway */
        if (destination->s_addr != gateway->s_addr ||
            netmask->s_addr != INADDR_BROADCAST)
                add_attr_l(&nlm->hdr, sizeof(*nlm), RTA_GATEWAY,
-                          &gateway->s_addr, sizeof(gateway->s_addr));
+                   &gateway->s_addr, sizeof(gateway->s_addr));
 
        add_attr_32(&nlm->hdr, sizeof(*nlm), RTA_OIF, ifindex);
        add_attr_32(&nlm->hdr, sizeof(*nlm), RTA_PRIORITY, metric);
index decc960409e2c541b8403031e33d6279d88e7ec8..da6f820858ce4db197f8aa54b8771f75e629d4b7 100644 (file)
@@ -277,7 +277,7 @@ parse_addr(struct in_addr *addr, struct in_addr *net, const char *arg)
                *p++ = '\0';
                if (net != NULL &&
                    (sscanf(p, "%d", &i) != 1 ||
-                    inet_cidrtoaddr(i, net) != 0))
+                       inet_cidrtoaddr(i, net) != 0))
                {
                        syslog(LOG_ERR, "`%s' is not a valid CIDR", p);
                        return -1;
@@ -314,13 +314,14 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
        case 'h':
                if (arg) {
                        s = parse_string(ifo->hostname,
-                                        HOSTNAME_MAX_LEN, arg);
+                           HOSTNAME_MAX_LEN, arg);
                        if (s == -1) {
                                syslog(LOG_ERR, "hostname: %m");
                                return -1;
                        }
                        if (s != 0 && ifo->hostname[0] == '.') {
-                               syslog(LOG_ERR, "hostname cannot begin with .");
+                               syslog(LOG_ERR,
+                                   "hostname cannot begin with .");
                                return -1;
                        }
                        ifo->hostname[s] = '\0';
@@ -333,7 +334,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
        case 'i':
                if (arg)
                        s = parse_string((char *)ifo->vendorclassid + 1,
-                                        VENDORCLASSID_MAX_LEN, arg);
+                           VENDORCLASSID_MAX_LEN, arg);
                else
                        s = 0;
                if (s == -1) {
@@ -348,7 +349,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
        case 'l':
                if (*arg == '-') {
                        syslog(LOG_ERR,
-                              "leasetime must be a positive value");
+                           "leasetime must be a positive value");
                        return -1;
                }
                errno = 0;
@@ -384,8 +385,8 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
                        ifo->request_address.s_addr = 0;
                } else {
                        if (parse_addr(&ifo->request_address,
-                                      &ifo->request_netmask,
-                                      arg) != 0)
+                               &ifo->request_netmask,
+                               arg) != 0)
                                return -1;
                }
                break;
@@ -403,8 +404,9 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
                break;
        case 'u':
                s = USERCLASS_MAX_LEN - ifo->userclass[0] - 1;
-               s = parse_string((char *)ifo->userclass + ifo->userclass[0] + 2,
-                                s, arg);
+               s = parse_string((char *)ifo->userclass +
+                   ifo->userclass[0] + 2,
+                   s, arg);
                if (s == -1) {
                        syslog(LOG_ERR, "userclass: %m");
                        return -1;
@@ -425,7 +427,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
                arg = p + 1;
                if (i < 1 || i > 254) {
                        syslog(LOG_ERR, "vendor option should be between"
-                                       " 1 and 254 inclusive");
+                           " 1 and 254 inclusive");
                        return -1;
                }
                s = VENDOR_MAX_LEN - ifo->vendor[0] - 2;
@@ -435,10 +437,10 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
                                errno = ENOBUFS;
                        } else
                                memcpy(ifo->vendor + ifo->vendor[0] + 3,
-                                      &addr.s_addr, sizeof(addr.s_addr));
+                                   &addr.s_addr, sizeof(addr.s_addr));
                } else {
-                       s = parse_string((char *)ifo->vendor + ifo->vendor[0] + 3,
-                                        s, arg);
+                       s = parse_string((char *)ifo->vendor +
+                           ifo->vendor[0] + 3, s, arg);
                }
                if (s == -1) {
                        syslog(LOG_ERR, "vendor: %m");
@@ -512,7 +514,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
                ifo->clientid[1] = 0;
                if (arg)
                        s = parse_string_hwaddr((char *)ifo->clientid + 1,
-                                               CLIENTID_MAX_LEN, arg, 1);
+                           CLIENTID_MAX_LEN, arg, 1);
                else
                        s = 0;
                if (s == -1) {
@@ -554,14 +556,14 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
                p++;
                if (strncmp(arg, "ip_address=", strlen("ip_address=")) == 0) {
                        if (parse_addr(&ifo->request_address,
-                                      &ifo->request_netmask, p) != 0)
+                               &ifo->request_netmask, p) != 0)
                                return -1;
 
                        ifo->options |= DHCPCD_STATIC;
                } else if (strncmp(arg, "routes=", strlen("routes=")) == 0 ||
-                          strncmp(arg, "static_routes=", strlen("static_routes=")) == 0 ||
-                          strncmp(arg, "classless_static_routes=", strlen("classless_static_routes=")) == 0 ||
-                          strncmp(arg, "ms_classless_static_routes=", strlen("ms_classless_static_routes=")) == 0)
+                   strncmp(arg, "static_routes=", strlen("static_routes=")) == 0 ||
+                   strncmp(arg, "classless_static_routes=", strlen("classless_static_routes=")) == 0 ||
+                   strncmp(arg, "ms_classless_static_routes=", strlen("ms_classless_static_routes=")) == 0)
                {
                        np = strchr(p, ' ');
                        if (np == NULL) {
@@ -603,8 +605,9 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
                        s = 0;
                        if (ifo->config != NULL) {
                                while (ifo->config[s] != NULL) {
-                                       if (strncmp(ifo->config[s], arg, p - arg) == 0) {
-                                               printf("match\n");
+                                       if (strncmp(ifo->config[s], arg,
+                                               p - arg) == 0)
+                                       {
                                                free(ifo->config[s]);
                                                ifo->config[s] = xstrdup(arg);
                                                return 1;
@@ -612,7 +615,8 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
                                        s++;
                                }
                        }
-                       ifo->config = xrealloc(ifo->config, sizeof(char *) * (s + 2));
+                       ifo->config = xrealloc(ifo->config,
+                           sizeof(char *) * (s + 2));
                        ifo->config[s] = xstrdup(arg);
                        ifo->config[s + 1] = NULL;
                }
@@ -620,7 +624,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
        case 'X':
                if (!inet_aton(arg, &addr)) {
                        syslog(LOG_ERR, "`%s' is not a valid IP address",
-                              arg);
+                           arg);
                        return -1;
                }
                ifo->blacklist = xrealloc(ifo->blacklist,
@@ -652,8 +656,8 @@ parse_config_line(struct if_options *ifo, const char *opt, char *line)
 
                if (cf_options[i].has_arg == required_argument && !line) {
                        fprintf(stderr,
-                               PACKAGE ": option requires an argument -- %s\n",
-                               opt);
+                           PACKAGE ": option requires an argument -- %s\n",
+                           opt);
                        return -1;
                }
 
@@ -687,8 +691,8 @@ read_config(const char *file, const char *ifname, const char *ssid)
            strcmp(ifo->hostname, "localhost") == 0)
                ifo->hostname[0] = '\0';
        ifo->vendorclassid[0] = snprintf((char *)ifo->vendorclassid + 1,
-                                        VENDORCLASSID_MAX_LEN,
-                                        "%s %s", PACKAGE, VERSION);
+           VENDORCLASSID_MAX_LEN,
+           "%s %s", PACKAGE, VERSION);
 
        /* Parse our options file */
        f = fopen(file ? file : CONFIG, "r");
@@ -701,8 +705,8 @@ read_config(const char *file, const char *ifname, const char *ssid)
                if (line && *line) {
                        p = line + strlen(line) - 1;
                        while (p != line &&
-                              (*p == ' ' || *p == '\t') &&
-                              *(p - 1) != '\\')
+                           (*p == ' ' || *p == '\t') &&
+                           *(p - 1) != '\\')
                                *p-- = '\0';
                }
                /* Start of an interface block, skip if not ours */
index 810b26208977f68ca41a3bdfe919f12b09cd4a1f..ecb9e26c6d68a5bcb0dc87e75163000a88558e17 100644 (file)
--- a/ipv4ll.c
+++ b/ipv4ll.c
@@ -63,8 +63,8 @@ make_ipv4ll_lease(uint32_t old_addr)
 
        for (;;) {
                dhcp->yiaddr = htonl(LINKLOCAL_ADDR |
-                                    (((uint32_t)abs((int)arc4random())
-                                      % 0xFD00) + 0x0100));
+                   (((uint32_t)abs((int)arc4random())
+                       % 0xFD00) + 0x0100));
                if (dhcp->yiaddr != old_addr &&
                    IN_LINKLOCAL(ntohl(dhcp->yiaddr)))
                        break;
@@ -91,7 +91,8 @@ start_ipv4ll(void *arg)
        if (!iface->state->offer ||
            !IN_LINKLOCAL(htonl(iface->state->offer->yiaddr)))
        {
-               syslog(LOG_INFO, "%s: probing for an IPv4LL address", iface->name);
+               syslog(LOG_INFO, "%s: probing for an IPv4LL address",
+                   iface->name);
                delete_timeout(NULL, iface);
                free(iface->state->offer);
                iface->state->offer = make_ipv4ll_lease(0);
@@ -122,7 +123,7 @@ handle_ipv4ll_failure(void *arg)
        iface->state->offer = NULL;
        if (++iface->state->conflicts > MAX_CONFLICTS) {
                syslog(LOG_ERR, "%s: failed to acquire an IPv4LL address",
-                               iface->name);
+                   iface->name);
                iface->state->interval = RATE_LIMIT_INTERVAL / 2;
                start_discover(iface);
        } else {
diff --git a/lpf.c b/lpf.c
index ae5dd036cbc343cacd18de339754816f579cd478..674d9767a2dba13044293d781462dfd8152e489e 100644 (file)
--- a/lpf.c
+++ b/lpf.c
@@ -60,8 +60,8 @@
 /* Broadcast address for IPoIB */
 static const uint8_t ipv4_bcast_addr[] = {
        0x00, 0xff, 0xff, 0xff,
-       0xff, 0x12, 0x40, 0x1b, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
+               0xff, 0x12, 0x40, 0x1b, 0x00, 0x00, 0x00, 0x00,
+               0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
 };
 
 int
@@ -120,7 +120,7 @@ eexit:
 
 ssize_t
 send_raw_packet(const struct interface *iface, int protocol,
-               const void *data, ssize_t len)
+    const void *data, ssize_t len)
 {
        union sockunion {
                struct sockaddr sa;
@@ -140,7 +140,7 @@ send_raw_packet(const struct interface *iface, int protocol,
        su.sll.sll_halen = iface->hwlen;
        if (iface->family == ARPHRD_INFINIBAND)
                memcpy(&su.sll.sll_addr,
-                      &ipv4_bcast_addr, sizeof(ipv4_bcast_addr));
+                   &ipv4_bcast_addr, sizeof(ipv4_bcast_addr));
        else
                memset(&su.sll.sll_addr, 0xff, iface->hwlen);
        if (protocol == ETHERTYPE_ARP)
diff --git a/net.c b/net.c
index 18cf53bbf373915e687a4d9d4e15b24d6664dc07..0db55c0fb2f9f0179dc05fa00c836fc55f22a400 100644 (file)
--- a/net.c
+++ b/net.c
@@ -72,7 +72,6 @@ inet_ntocidr(struct in_addr address)
                cidr++;
                mask <<= 1;
        }
-
        return cidr;
 }
 
@@ -90,8 +89,9 @@ inet_cidrtoaddr(int cidr, struct in_addr *addr)
        addr->s_addr = 0;
        if (ocets > 0) {
                memset(&addr->s_addr, 255, (size_t)ocets - 1);
-               memset((unsigned char *)&addr->s_addr + (ocets - 1),
-                      (256 - (1 << (32 - cidr) % 8)), 1);
+       
+       memset((unsigned char *)&addr->s_addr + (ocets - 1),
+                   (256 - (1 << (32 - cidr) % 8)), 1);
        }
 
        return 0;
@@ -219,10 +219,10 @@ init_interface(const char *ifname)
        default:
                /* Don't needlessly spam console on startup */
                if (!(options & DHCPCD_MASTER &&
-                   !(options & DHCPCD_DAEMONISED) &&
-                   options & DHCPCD_QUIET))
+                       !(options & DHCPCD_DAEMONISED) &&
+                       options & DHCPCD_QUIET))
                        syslog(LOG_ERR, "%s: unsupported media family",
-                              iface->name);
+                           iface->name);
                goto eexit;
        }
        memcpy(iface->hwaddr, ifr.ifr_hwaddr.sa_data, iface->hwlen);
@@ -242,7 +242,7 @@ init_interface(const char *ifname)
        if (up_interface(ifname) != 0)
                goto eexit;
        snprintf(iface->leasefile, sizeof(iface->leasefile),
-                LEASEFILE, ifname);
+           LEASEFILE, ifname);
        iface->arpable = arpable;
        /* 0 is a valid fd, so init to -1 */
        iface->raw_fd = -1;
@@ -275,9 +275,9 @@ free_interface(struct interface *iface)
 
 int
 do_interface(const char *ifname,
-            void (*do_link)(struct interface **, int, char * const *, struct ifreq *),
-            struct interface **ifs, int argc, char * const *argv,
-            struct in_addr *addr, struct in_addr *net, int act)
+    void (*do_link)(struct interface **, int, char * const *, struct ifreq *),
+    struct interface **ifs, int argc, char * const *argv,
+    struct in_addr *addr, struct in_addr *net, int act)
 {
        int s;
        struct ifconf ifc;
@@ -322,7 +322,7 @@ do_interface(const char *ifname,
 #ifndef __linux__
                if (ifr->ifr_addr.sa_len > sizeof(ifr->ifr_ifru))
                        p += offsetof(struct ifreq, ifr_ifru) +
-                               ifr->ifr_addr.sa_len;
+                           ifr->ifr_addr.sa_len;
                else
 #endif
                        p += sizeof(*ifr);
@@ -505,7 +505,8 @@ open_udp_socket(struct interface *iface)
        p = strchr(ifr.ifr_name, ':');
        if (p)
                *p = '\0';
-       if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)) == -1)
+       if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, &ifr,
+               sizeof(ifr)) == -1)
                goto eexit;
 #endif
        /* As we don't use this socket for receiving, set the
@@ -531,7 +532,7 @@ eexit:
 
 ssize_t
 send_packet(const struct interface *iface, struct in_addr to,
-           const uint8_t *data, ssize_t len)
+    const uint8_t *data, ssize_t len)
 {
        struct sockaddr_in sin;
 
@@ -540,7 +541,7 @@ send_packet(const struct interface *iface, struct in_addr to,
        sin.sin_addr.s_addr = to.s_addr;
        sin.sin_port = htons(DHCP_SERVER_PORT);
        return sendto(iface->udp_fd, data, len, 0,
-                     (struct sockaddr *)&sin, sizeof(sin));
+           (struct sockaddr *)&sin, sizeof(sin));
 }
 
 struct udp_dhcp_packet
@@ -576,7 +577,7 @@ checksum(const void *data, uint16_t len)
 
 ssize_t
 make_udp_packet(uint8_t **packet, const uint8_t *data, size_t length,
-               struct in_addr source, struct in_addr dest)
+    struct in_addr source, struct in_addr dest)
 {
        struct udp_dhcp_packet *udpp;
        struct ip *ip;
@@ -632,7 +633,9 @@ get_udp_data(const uint8_t **data, const uint8_t *udp)
 
        memcpy(&packet, udp, sizeof(packet));
        *data = udp + offsetof(struct udp_dhcp_packet, dhcp);
-       return ntohs(packet.ip.ip_len) - sizeof(packet.ip) - sizeof(packet.udp);
+       return ntohs(packet.ip.ip_len) -
+           sizeof(packet.ip) -
+           sizeof(packet.udp);
 }
 
 int
index 0007b5d25c3f5f8142dfa2e807bb9b7daf6f57b7..f96a25ac17c3fb38d0b30a85c4bf8cfcc5cfef30 100644 (file)
--- a/signals.c
+++ b/signals.c
@@ -41,10 +41,10 @@ static int signal_pipe[2];
 
 static const int handle_sigs[] = {
        SIGALRM,
-       SIGHUP,
-       SIGINT,
-       SIGPIPE,
-       SIGTERM
+               SIGHUP,
+               SIGINT,
+               SIGPIPE,
+               SIGTERM
 };
 
 static void