From fa6e63bb8200146ee986054bccaf936b132c9c11 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Mon, 10 Nov 2025 13:36:33 +0100 Subject: [PATCH] src: fix whitespace issues MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - Remove double whitespaces. - Convert whitespace alignments to tabs. - Fix code comments using whitespaces. Signed-off-by: Álvaro Fernández Rojas --- src/config.c | 4 +-- src/dhcpv4.c | 15 +++++---- src/dhcpv4.h | 20 ++++++------ src/dhcpv6-ia.c | 35 +++++++++++---------- src/dhcpv6-ia.h | 7 +++-- src/dhcpv6-pxe.c | 4 +-- src/dhcpv6.c | 7 ++--- src/dhcpv6.h | 18 +++++------ src/ndp.c | 4 +-- src/netlink.c | 2 +- src/odhcpd.c | 18 +++++------ src/odhcpd.h | 18 +++++------ src/router.c | 19 ++++++------ src/router.h | 80 ++++++++++++++++++++++++------------------------ src/ubus.c | 15 ++++----- 15 files changed, 133 insertions(+), 133 deletions(-) diff --git a/src/config.c b/src/config.c index 6130b5f..055cd5d 100644 --- a/src/config.c +++ b/src/config.c @@ -49,7 +49,7 @@ struct config config = { .log_level_cmdline = false, .log_syslog = true, .default_duid = { 0 }, - .default_duid_len = 0, + .default_duid_len = 0, }; struct sys_conf sys_conf = { @@ -1179,7 +1179,6 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr else error("Invalid %s value configured for interface '%s'", iface_attrs[IFACE_ATTR_LEASETIME].name, iface->name); - } if ((c = tb[IFACE_ATTR_MAX_PREFERRED_LIFETIME])) { @@ -1470,7 +1469,6 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if(ra_hoplimit > AdvCurHopLimit) warn("Clamped invalid %s value configured for interface '%s' to %d", iface_attrs[IFACE_ATTR_RA_HOPLIMIT].name, iface->name, iface->ra_hoplimit); - } iface->if_mtu = odhcpd_get_interface_config(iface->ifname, "mtu"); diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 49fc76c..4c574af 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -8,10 +8,9 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * */ #include @@ -564,9 +563,9 @@ dhcpv4_lease(struct interface *iface, enum dhcpv4_msg req_msg, const uint8_t *re ubus_bcast_dhcp_event("dhcp.release", req_mac, (struct in_addr *)&lease->addr, - lease->hostname, iface->ifname); - dhcpv4_free_lease(lease); - lease = NULL; + lease->hostname, iface->ifname); + dhcpv4_free_lease(lease); + lease = NULL; break; case DHCPV4_MSG_DECLINE: @@ -1395,13 +1394,13 @@ static int dhcpv4_setup_addresses(struct interface *iface) if (ntohl(iface->dhcpv4_mask.s_addr) <= 0xffffff00) { /* /24, 150 of 256, [100..249] */ iface->dhcpv4_start_ip.s_addr = start | htonl(100); iface->dhcpv4_end_ip.s_addr = end | htonl(100 + 150 - 1); - } else if (ntohl(iface->dhcpv4_mask.s_addr) <= 0xffffff80) { /* /25, 100 of 128, [20..119] */ + } else if (ntohl(iface->dhcpv4_mask.s_addr) <= 0xffffff80) { /* /25, 100 of 128, [20..119] */ iface->dhcpv4_start_ip.s_addr = start | htonl(20); iface->dhcpv4_end_ip.s_addr = end | htonl(20 + 100 - 1); - } else if (ntohl(iface->dhcpv4_mask.s_addr) <= 0xffffffc0) { /* /26, 50 of 64, [10..59] */ + } else if (ntohl(iface->dhcpv4_mask.s_addr) <= 0xffffffc0) { /* /26, 50 of 64, [10..59] */ iface->dhcpv4_start_ip.s_addr = start | htonl(10); iface->dhcpv4_end_ip.s_addr = end | htonl(10 + 50 - 1); - } else if (ntohl(iface->dhcpv4_mask.s_addr) <= 0xffffffe0) { /* /27, 20 of 32, [10..29] */ + } else if (ntohl(iface->dhcpv4_mask.s_addr) <= 0xffffffe0) { /* /27, 20 of 32, [10..29] */ iface->dhcpv4_start_ip.s_addr = start | htonl(10); iface->dhcpv4_end_ip.s_addr = end | htonl(10 + 20 - 1); } else { /* /28, 10 of 16, [3..12] */ diff --git a/src/dhcpv4.h b/src/dhcpv4.h index 6599acf..c120f7f 100644 --- a/src/dhcpv4.h +++ b/src/dhcpv4.h @@ -1,15 +1,15 @@ /** - * Copyright (C) 2012 Steven Barth - * Copyright (C) 2016 Hans Dedecker + * Copyright (C) 2012 Steven Barth + * Copyright (C) 2016 Hans Dedecker * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2 for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License version 2 for more details. * */ @@ -19,7 +19,7 @@ #define DHCPV4_CLIENT_PORT 68 #define DHCPV4_SERVER_PORT 67 -#define DHCPV4_FLAG_BROADCAST 0x8000 +#define DHCPV4_FLAG_BROADCAST 0x8000 // RFC951, §3; RFC1542, §2.1; RFC2131, §2 #define DHCPV4_MIN_PACKET_SIZE 300 diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index de9abd9..3af3e42 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -8,7 +8,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ @@ -188,7 +188,7 @@ static int send_reconf(struct dhcpv6_lease *assign) .len = htons(1), .id = DHCPV6_MSG_RENEW, }; - struct dhcpv6_auth_reconfigure auth = { + struct dhcpv6_auth_reconfigure auth = { .type = htons(DHCPV6_OPT_AUTH), .len = htons(sizeof(struct dhcpv6_auth_reconfigure)), .protocol = 3, @@ -383,8 +383,8 @@ static bool assign_pd(struct interface *iface, struct dhcpv6_lease *assign) } /* Check iid against reserved IPv6 interface identifiers. - Refer to: - http://www.iana.org/assignments/ipv6-interface-ids */ + * Refer to: http://www.iana.org/assignments/ipv6-interface-ids + */ static bool is_reserved_ipv6_iid(uint64_t iid) { if (iid == 0x0000000000000000) @@ -393,7 +393,8 @@ static bool is_reserved_ipv6_iid(uint64_t iid) if ((iid & 0xFFFFFFFFFF000000) == 0x02005EFFFE000000) /* Reserved IPv6 Interface Identifiers corresponding - to the IANA Ethernet Block [RFC4291] */ + * to the IANA Ethernet Block [RFC4291] + */ return true; if ((iid & 0xFFFFFFFFFFFFFF80) == 0xFDFFFFFFFFFFFF80) @@ -473,7 +474,7 @@ static void handle_addrlist_change(struct netevent_handler_info *info) list_for_each_entry_safe(c, d, &iface->ia_assignments, head) { if (c->clid_len == 0 || - !(c->flags & OAF_DHCPV6_PD) || + !(c->flags & OAF_DHCPV6_PD) || (!INFINITE_VALID(c->valid_until) && c->valid_until < now)) continue; @@ -1018,7 +1019,7 @@ ssize_t dhcpv6_ia_handle_IAs(uint8_t *buf, size_t buflen, struct interface *ifac /* * A requesting router can include a desired prefix length for its - * delegation. The delegating router (us) is not required to honor + * delegation. The delegating router (us) is not required to honor * the hint (RFC3633, section 11.2, we MAY choose to use the * information in the option; RFC8168, section 3.2 has several SHOULDs * about desired choices for selecting a prefix to delegate). @@ -1028,17 +1029,17 @@ ssize_t dhcpv6_ia_handle_IAs(uint8_t *buf, size_t buflen, struct interface *ifac * * If the minimum prefix length is set in this interface's * configuration, we use it as a floor for the requested (hinted) - * prefix length. This allows us to conserve prefix space so that - * any single router can't grab too much of it. Consider if we have - * an interface with a /56 prefix. A requesting router could ask for - * a /58 and take 1/4 of our total address space. But if we set a + * prefix length. This allows us to conserve prefix space so that + * any single router can't grab too much of it. Consider if we have + * an interface with a /56 prefix. A requesting router could ask for + * a /58 and take 1/4 of our total address space. But if we set a * minimum of /60, we can limit each requesting router to get only * 1/16 of our total address space. */ if (iface->dhcpv6_pd_min_len && reqlen < iface->dhcpv6_pd_min_len) { - info("clamping requested PD from %d to %d", reqlen, - iface->dhcpv6_pd_min_len); - reqlen = iface->dhcpv6_pd_min_len; + info("clamping requested PD from %d to %d", reqlen, + iface->dhcpv6_pd_min_len); + reqlen = iface->dhcpv6_pd_min_len; } } else if (is_na) { uint8_t *sdata; @@ -1068,7 +1069,7 @@ ssize_t dhcpv6_ia_handle_IAs(uint8_t *buf, size_t buflen, struct interface *ifac /* Does the DUID match? */ if (c->clid_len != clid_len || memcmp(c->clid_data, clid_data, clid_len)) - continue; + continue; /* Does the IAID match? */ if (c->iaid != ia->iaid) { @@ -1149,8 +1150,8 @@ proceed: a->assigned_host_id = lease_cfg ? lease_cfg->hostid : 0; else a->assigned_subnet_id = reqhint; - a->valid_until = now; - a->preferred_until = now; + a->valid_until = now; + a->preferred_until = now; a->iface = iface; a->flags = (is_pd ? OAF_DHCPV6_PD : OAF_DHCPV6_NA); diff --git a/src/dhcpv6-ia.h b/src/dhcpv6-ia.h index e061804..c75195b 100644 --- a/src/dhcpv6-ia.h +++ b/src/dhcpv6-ia.h @@ -8,7 +8,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ @@ -17,8 +17,9 @@ #define _DHCPV6_IA_H_ #define ADDR_ENTRY_VALID_IA_ADDR(iface, i, m, addrs) \ - ((iface)->dhcpv6_assignall || (i) == (m) || \ - (addrs)[(i)].prefix > 64) + ((iface)->dhcpv6_assignall || \ + (i) == (m) || \ + (addrs)[(i)].prefix > 64) size_t get_preferred_addr(const struct odhcpd_ipaddr *addrs, const size_t addrlen); diff --git a/src/dhcpv6-pxe.c b/src/dhcpv6-pxe.c index e72a317..10f82dc 100644 --- a/src/dhcpv6-pxe.c +++ b/src/dhcpv6-pxe.c @@ -82,10 +82,10 @@ void ipv6_pxe_dump(void) { info("IPv6 PxE URLs:\n"); list_for_each_entry(entry, &ipv6_pxe_list, list) - info(" arch %04d = %s\n", entry->arch, entry->bootfile_url.payload); + info("\tarch %04d = %s\n", entry->arch, entry->bootfile_url.payload); if (ipv6_pxe_default) - info(" Default = %s\n", ipv6_pxe_default->bootfile_url.payload); + info("\tDefault = %s\n", ipv6_pxe_default->bootfile_url.payload); } } diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 2cbcbbc..223c8a3 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -8,10 +8,9 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * */ #include @@ -525,13 +524,13 @@ static void handle_client_request(void *addr, void *data, size_t len, case DHCPV6_OPT_NEW_POSIX_TIMEZONE: posix_want = true; posix_tz.type = htons(DHCPV6_OPT_NEW_POSIX_TIMEZONE); - posix_tz.len = htons(posix_len); + posix_tz.len = htons(posix_len); break; case DHCPV6_OPT_NEW_TZDB_TIMEZONE: tzdb_want = true; tzdb_tz.type = htons(DHCPV6_OPT_NEW_TZDB_TIMEZONE); - tzdb_tz.len = htons(tzdb_len); + tzdb_tz.len = htons(tzdb_len); break; case DHCPV6_OPT_DNR: diff --git a/src/dhcpv6.h b/src/dhcpv6.h index de0362f..af175c9 100644 --- a/src/dhcpv6.h +++ b/src/dhcpv6.h @@ -1,14 +1,14 @@ /** - * Copyright (C) 2012 Steven Barth + * Copyright (C) 2012 Steven Barth * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License version 2 for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License version 2 for more details. * */ @@ -86,7 +86,7 @@ #define DHCPV6_STATUS_NOPREFIXAVAIL 6 // I just remembered I have an old one lying around... -#define DHCPV6_ENT_NO 30462 +#define DHCPV6_ENT_NO 30462 #define DHCPV6_ENT_TYPE 1 diff --git a/src/ndp.c b/src/ndp.c index 25cc831..58ed5f4 100644 --- a/src/ndp.c +++ b/src/ndp.c @@ -7,7 +7,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ @@ -121,7 +121,7 @@ int ndp_setup_interface(struct interface *iface, bool enable) } if (setsockopt(iface->ndp_ping_fd, IPPROTO_RAW, IPV6_CHECKSUM, - &val, sizeof(val)) < 0) { + &val, sizeof(val)) < 0) { error("setsockopt(IPV6_CHECKSUM): %m"); ret = -1; goto out; diff --git a/src/netlink.c b/src/netlink.c index 6de9ae7..393678d 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -7,7 +7,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ diff --git a/src/odhcpd.c b/src/odhcpd.c index 49912ed..d41e4cd 100644 --- a/src/odhcpd.c +++ b/src/odhcpd.c @@ -7,7 +7,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ @@ -587,14 +587,14 @@ time_t odhcpd_time(void) static const char hexdigits[] = "0123456789abcdef"; static const int8_t hexvals[] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -1, -1, -2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -1, -1, -2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; ssize_t odhcpd_unhexlify(uint8_t *dst, size_t len, const char *src) diff --git a/src/odhcpd.h b/src/odhcpd.h index 04aa7ce..520c27f 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -7,7 +7,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ @@ -69,7 +69,7 @@ #define ADDR_MATCH_PIO_FILTER(_addr, iface) (odhcpd_bmemcmp(&(_addr)->addr, \ &(iface)->pio_filter_addr, \ (iface)->pio_filter_length) != 0 || \ - (_addr)->prefix < (iface)->pio_filter_length) + (_addr)->prefix < (iface)->pio_filter_length) struct interface; struct nl_sock; @@ -77,13 +77,13 @@ extern struct config config; extern struct sys_conf sys_conf; void __iflog(int lvl, const char *fmt, ...); -#define debug(fmt, ...) __iflog(LOG_DEBUG, fmt __VA_OPT__(, ) __VA_ARGS__) -#define info(fmt, ...) __iflog(LOG_INFO, fmt __VA_OPT__(, ) __VA_ARGS__) -#define notice(fmt, ...) __iflog(LOG_NOTICE, fmt __VA_OPT__(, ) __VA_ARGS__) -#define warn(fmt, ...) __iflog(LOG_WARNING, fmt __VA_OPT__(, ) __VA_ARGS__) -#define error(fmt, ...) __iflog(LOG_ERR, fmt __VA_OPT__(, ) __VA_ARGS__) -#define critical(fmt, ...) __iflog(LOG_CRIT, fmt __VA_OPT__(, ) __VA_ARGS__) -#define alert(fmt, ...) __iflog(LOG_ALERT, fmt __VA_OPT__(, ) __VA_ARGS__) +#define debug(fmt, ...) __iflog(LOG_DEBUG, fmt __VA_OPT__(, ) __VA_ARGS__) +#define info(fmt, ...) __iflog(LOG_INFO, fmt __VA_OPT__(, ) __VA_ARGS__) +#define notice(fmt, ...) __iflog(LOG_NOTICE, fmt __VA_OPT__(, ) __VA_ARGS__) +#define warn(fmt, ...) __iflog(LOG_WARNING, fmt __VA_OPT__(, ) __VA_ARGS__) +#define error(fmt, ...) __iflog(LOG_ERR, fmt __VA_OPT__(, ) __VA_ARGS__) +#define critical(fmt, ...) __iflog(LOG_CRIT, fmt __VA_OPT__(, ) __VA_ARGS__) +#define alert(fmt, ...) __iflog(LOG_ALERT, fmt __VA_OPT__(, ) __VA_ARGS__) #define emergency(fmt, ...) __iflog(LOG_EMERG, fmt __VA_OPT__(, ) __VA_ARGS__) diff --git a/src/router.c b/src/router.c index a2e95a5..621a0cd 100644 --- a/src/router.c +++ b/src/router.c @@ -8,7 +8,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ @@ -349,10 +349,11 @@ static int calc_adv_interval(struct interface *iface, uint32_t lowest_found_life msecs = (labs(msecs) % ((*maxival != minival) ? (*maxival - minival)*1000 : 500)) + minival*1000; - /* RFC 2461 6.2.4 For the first MAX_INITIAL_RTR_ADVERTISEMENTS advertisements */ - /* if the timer is bigger than MAX_INITIAL_RTR_ADVERT_INTERVAL it should be */ - /* set to MAX_INITIAL_RTR_ADVERT_INTERVAL */ - /* Off by one as an initial interval timer has already expired */ + /* RFC 2461 6.2.4 For the first MAX_INITIAL_RTR_ADVERTISEMENTS advertisements + * if the timer is bigger than MAX_INITIAL_RTR_ADVERT_INTERVAL it should be + * set to MAX_INITIAL_RTR_ADVERT_INTERVAL + * Off by one as an initial interval timer has already expired + */ if ((iface->ra_sent + 1) < MaxInitialRtAdvs && msecs > MaxInitialRtrAdvInterval*1000) msecs = MaxInitialRtrAdvInterval*1000; @@ -474,7 +475,7 @@ static void router_add_ra_pio(struct interface *iface, new_pios = realloc(iface->pios, sizeof(struct ra_pio) * (iface->pio_cnt + 1)); if (!new_pios) - return; + return; iface->pios = new_pios; pio = &iface->pios[iface->pio_cnt]; @@ -882,7 +883,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr pref64->type = ND_OPT_PREF64; pref64->len = 2; pref64->lifetime_plc = htons((0xfff8 & pref64_lifetime) | - (0x7 & iface->pref64_plc)); + (0x7 & iface->pref64_plc)); memcpy(pref64->prefix, iface->pref64_prefix, sizeof(pref64->prefix)); } iov[IOV_RA_PREF64].iov_base = (char *)pref64; @@ -941,7 +942,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr * L-3: An IPv6 CE router MUST advertise itself as a router for the * delegated prefix(es) (and ULA prefix if configured to provide * ULA addressing) using the "Route Information Option" specified - * in Section 2.3 of [RFC4191]. This advertisement is + * in Section 2.3 of [RFC4191]. This advertisement is * independent of having or not having IPv6 connectivity on the * WAN interface. */ @@ -1181,7 +1182,7 @@ static void forward_router_advertisement(const struct interface *iface, uint8_t if (c->ra_mtu && mtu_opt) { if (ingress_mtu_val != c->ra_mtu) { debug("Rewriting RA MTU from %u to %u on %s", - ingress_mtu_val, c->ra_mtu, c->name); + ingress_mtu_val, c->ra_mtu, c->name); mtu_opt->nd_opt_mtu_mtu = htonl(c->ra_mtu); } } diff --git a/src/router.h b/src/router.h index 5502a0d..6577667 100644 --- a/src/router.h +++ b/src/router.h @@ -7,7 +7,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ @@ -35,60 +35,60 @@ struct icmpv6_opt { #define MaxInitialRtrAdvInterval 16 #define MaxInitialRtAdvs 3 /* RFC8319 §4 - This document updates §4.2 and 6.2.1 of [RFC4861] to change - the following router configuration variables. - - In §6.2.1, inside the paragraph that defines - MaxRtrAdvInterval, change 1800 to 65535 seconds. - - In §6.2.1, inside the paragraph that defines - AdvDefaultLifetime, change 9000 to 65535 seconds. -*/ + * This document updates §4.2 and 6.2.1 of [RFC4861] to change + * the following router configuration variables. + * + * In §6.2.1, inside the paragraph that defines + * MaxRtrAdvInterval, change 1800 to 65535 seconds. + * + * In §6.2.1, inside the paragraph that defines + * AdvDefaultLifetime, change 9000 to 65535 seconds. + */ #define MaxRtrAdvInterval 65535 #define MinRtrAdvInterval 3 #define AdvDefaultLifetime 65535 /* RFC8319 §4 - This document updates §4.2 and 6.2.1 of [RFC4861] to change - the following router configuration variables. - - In §4.2, inside the paragraph that defines Router Lifetime, - change 9000 to 65535 seconds. - - Note: this is 16 bit Router Lifetime field in RA packets -*/ + * This document updates §4.2 and 6.2.1 of [RFC4861] to change + * the following router configuration variables. + * + * In §4.2, inside the paragraph that defines Router Lifetime, + * change 9000 to 65535 seconds. + * + * Note: this is 16 bit Router Lifetime field in RA packets + */ /* RFC9096 defines recommended option lifetimes configuration values - ND_PREFERRED_LIMIT 2700 - ND_VALID_LIMIT 5400 - - RFC9096 §3.4 - CE routers SHOULD set the "Router Lifetime" of Router Advertisement - (RA) messages to ND_PREFERRED_LIMIT. - - Note: while the RFC recommends SHOULD of ND_PREFERRED_LIMIT, this - define is used to cap values to a sane ceiling, i.e. ND_VALID_LIMIT. -*/ + * ND_PREFERRED_LIMIT 2700 + * ND_VALID_LIMIT 5400 + * + * RFC9096 §3.4 + * CE routers SHOULD set the "Router Lifetime" of Router Advertisement + * (RA) messages to ND_PREFERRED_LIMIT. + * + * Note: while the RFC recommends SHOULD of ND_PREFERRED_LIMIT, this + * define is used to cap values to a sane ceiling, i.e. ND_VALID_LIMIT. + */ #define RouterLifetime 5400 /* RFC4861 §6.2.1 : AdvReachableTime : * MUST be no greater than 3,600,000 msec */ #define AdvReachableTime 3600000 /* RFC4861 §6.2.1 : AdvCurHopLimit - The value should be set to the current - diameter of the Internet. The value zero means - unspecified (by this router). - - Note: this value is an 8 bit int, so max 255. -*/ + * The value should be set to the current + * diameter of the Internet. The value zero means + * unspecified (by this router). + * + * Note: this value is an 8 bit int, so max 255. + */ #define AdvCurHopLimit 255 /* RFC4861 §10 - constants - Node constants: - RETRANS_TIMER 1,000 milliseconds -*/ + * Node constants: + * RETRANS_TIMER 1,000 milliseconds + */ #define RETRANS_TIMER_MAX 60000 /* RFC2460 §5 - IPv6 requires that every link in the internet have an MTU of 1280 - octets or greater. -*/ + * IPv6 requires that every link in the internet have an MTU of 1280 + * octets or greater. + */ #define RA_MTU_MIN 1280 #define RA_MTU_MAX 65535 diff --git a/src/ubus.c b/src/ubus.c index e589d4e..7378f0a 100644 --- a/src/ubus.c +++ b/src/ubus.c @@ -247,13 +247,13 @@ static struct ubus_method main_object_methods[] = { }; static struct ubus_object_type main_object_type = - UBUS_OBJECT_TYPE("dhcp", main_object_methods); + UBUS_OBJECT_TYPE("dhcp", main_object_methods); static struct ubus_object main_object = { - .name = "dhcp", - .type = &main_object_type, - .methods = main_object_methods, - .n_methods = ARRAY_SIZE(main_object_methods), + .name = "dhcp", + .type = &main_object_type, + .methods = main_object_methods, + .n_methods = ARRAY_SIZE(main_object_methods), }; @@ -413,8 +413,9 @@ void ubus_bcast_dhcp_event(const char *type, const uint8_t *mac, ubus_notify(ubus, &main_object, type, b.head, -1); } -static void handle_event(_unused struct ubus_context *ctx, _unused struct ubus_event_handler *ev, - _unused const char *type, struct blob_attr *msg) +static void handle_event(_unused struct ubus_context *ctx, + _unused struct ubus_event_handler *ev, + _unused const char *type, struct blob_attr *msg) { struct blob_attr *tb[OBJ_ATTR_MAX]; blobmsg_parse(obj_attrs, OBJ_ATTR_MAX, tb, blob_data(msg), blob_len(msg)); -- 2.30.2