treewide: replace RELAYD prefix naming in macros
authorHans Dedecker <dedeckeh@gmail.com>
Wed, 6 Sep 2017 12:51:09 +0000 (14:51 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Wed, 6 Sep 2017 12:51:59 +0000 (14:51 +0200)
Remove the unfortunate RELAYD naming in the different macros

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/config.c
src/dhcpv6-ia.c
src/dhcpv6.c
src/ndp.c
src/odhcpd.c
src/odhcpd.h
src/router.c
src/ubus.c

index 8bf2011cabff707919a30d0d815f2559632ebd8c..fd8f32e6975a0a1c8b9c0cbab2b1331cfb13ac38 100644 (file)
@@ -249,13 +249,13 @@ static void close_interface(struct interface *iface)
 static int parse_mode(const char *mode)
 {
        if (!strcmp(mode, "disabled"))
-               return RELAYD_DISABLED;
+               return MODE_DISABLED;
        else if (!strcmp(mode, "server"))
-               return RELAYD_SERVER;
+               return MODE_SERVER;
        else if (!strcmp(mode, "relay"))
-               return RELAYD_RELAY;
+               return MODE_RELAY;
        else if (!strcmp(mode, "hybrid"))
-               return RELAYD_HYBRID;
+               return MODE_HYBRID;
        else
                return -1;
 }
@@ -478,7 +478,7 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
                iface->dhcpv4_start.s_addr = htonl(blobmsg_get_u32(c));
 
                if (config.main_dhcpv4 && config.legacy)
-                       iface->dhcpv4 = RELAYD_SERVER;
+                       iface->dhcpv4 = MODE_SERVER;
        }
 
        if ((c = tb[IFACE_ATTR_LIMIT]))
@@ -778,13 +778,13 @@ void odhcpd_reload(void)
                if (i->master)
                        continue;
 
-               if (i->dhcpv6 == RELAYD_HYBRID || i->dhcpv6 == RELAYD_RELAY)
+               if (i->dhcpv6 == MODE_HYBRID || i->dhcpv6 == MODE_RELAY)
                        any_dhcpv6_slave = true;
 
-               if (i->ra == RELAYD_HYBRID || i->ra == RELAYD_RELAY)
+               if (i->ra == MODE_HYBRID || i->ra == MODE_RELAY)
                        any_ra_slave = true;
 
-               if (i->ndp == RELAYD_HYBRID || i->ndp == RELAYD_RELAY)
+               if (i->ndp == MODE_HYBRID || i->ndp == MODE_RELAY)
                        any_ndp_slave = true;
        }
 
@@ -793,31 +793,31 @@ void odhcpd_reload(void)
                if (!i->master)
                        continue;
 
-               enum odhcpd_mode hybrid_mode = RELAYD_DISABLED;
+               enum odhcpd_mode hybrid_mode = MODE_DISABLED;
 #ifdef WITH_UBUS
                if (!ubus_has_prefix(i->name, i->ifname))
-                       hybrid_mode = RELAYD_RELAY;
+                       hybrid_mode = MODE_RELAY;
 #endif
 
-               if (i->dhcpv6 == RELAYD_HYBRID)
+               if (i->dhcpv6 == MODE_HYBRID)
                        i->dhcpv6 = hybrid_mode;
 
-               if (i->dhcpv6 == RELAYD_RELAY && !any_dhcpv6_slave)
-                       i->dhcpv6 = RELAYD_DISABLED;
+               if (i->dhcpv6 == MODE_RELAY && !any_dhcpv6_slave)
+                       i->dhcpv6 = MODE_DISABLED;
 
-               if (i->ra == RELAYD_HYBRID)
+               if (i->ra == MODE_HYBRID)
                        i->ra = hybrid_mode;
 
-               if (i->ra == RELAYD_RELAY && !any_ra_slave)
-                       i->ra = RELAYD_DISABLED;
+               if (i->ra == MODE_RELAY && !any_ra_slave)
+                       i->ra = MODE_DISABLED;
 
-               if (i->ndp == RELAYD_HYBRID)
+               if (i->ndp == MODE_HYBRID)
                        i->ndp = hybrid_mode;
 
-               if (i->ndp == RELAYD_RELAY && !any_ndp_slave)
-                       i->ndp = RELAYD_DISABLED;
+               if (i->ndp == MODE_RELAY && !any_ndp_slave)
+                       i->ndp = MODE_DISABLED;
 
-               if (i->dhcpv6 == RELAYD_RELAY || i->ra == RELAYD_RELAY || i->ndp == RELAYD_RELAY)
+               if (i->dhcpv6 == MODE_RELAY || i->ra == MODE_RELAY || i->ndp == MODE_RELAY)
                        master = i;
        }
 
@@ -825,22 +825,22 @@ void odhcpd_reload(void)
        list_for_each_entry_safe(i, n, &interfaces, head) {
                if (i->inuse) {
                        /* Resolve hybrid mode */
-                       if (i->dhcpv6 == RELAYD_HYBRID)
-                               i->dhcpv6 = (master && master->dhcpv6 == RELAYD_RELAY) ?
-                                               RELAYD_RELAY : RELAYD_SERVER;
-
-                       if (i->ra == RELAYD_HYBRID)
-                               i->ra = (master && master->ra == RELAYD_RELAY) ?
-                                               RELAYD_RELAY : RELAYD_SERVER;
-
-                       if (i->ndp == RELAYD_HYBRID)
-                               i->ndp = (master && master->ndp == RELAYD_RELAY) ?
-                                               RELAYD_RELAY : RELAYD_DISABLED;
-
-                       setup_router_interface(i, !i->ignore || i->ra != RELAYD_DISABLED);
-                       setup_dhcpv6_interface(i, !i->ignore || i->dhcpv6 != RELAYD_DISABLED);
-                       setup_ndp_interface(i, !i->ignore || i->ndp != RELAYD_DISABLED);
-                       setup_dhcpv4_interface(i, !i->ignore || i->dhcpv4 != RELAYD_DISABLED);
+                       if (i->dhcpv6 == MODE_HYBRID)
+                               i->dhcpv6 = (master && master->dhcpv6 == MODE_RELAY) ?
+                                               MODE_RELAY : MODE_SERVER;
+
+                       if (i->ra == MODE_HYBRID)
+                               i->ra = (master && master->ra == MODE_RELAY) ?
+                                               MODE_RELAY : MODE_SERVER;
+
+                       if (i->ndp == MODE_HYBRID)
+                               i->ndp = (master && master->ndp == MODE_RELAY) ?
+                                               MODE_RELAY : MODE_DISABLED;
+
+                       setup_router_interface(i, !i->ignore || i->ra != MODE_DISABLED);
+                       setup_dhcpv6_interface(i, !i->ignore || i->dhcpv6 != MODE_DISABLED);
+                       setup_ndp_interface(i, !i->ignore || i->ndp != MODE_DISABLED);
+                       setup_dhcpv4_interface(i, !i->ignore || i->dhcpv4 != MODE_DISABLED);
                } else
                        close_interface(i);
        }
index 04d92fe918524be0199782cff16b581a3ee11509..bd4342b7cae710c6929b24d3b948ec7feacf1f95 100644 (file)
@@ -64,7 +64,7 @@ int setup_dhcpv6_ia_interface(struct interface *iface, bool enable)
                }
        }
 
-       if (enable && iface->dhcpv6 == RELAYD_SERVER) {
+       if (enable && iface->dhcpv6 == MODE_SERVER) {
                if (!iface->ia_assignments.next)
                        INIT_LIST_HEAD(&iface->ia_assignments);
 
@@ -347,11 +347,11 @@ void dhcpv6_write_statefile(void)
                ctxt.buf_len = sizeof(leasebuf);
 
                list_for_each_entry(ctxt.iface, &interfaces, head) {
-                       if (ctxt.iface->dhcpv6 != RELAYD_SERVER &&
-                                       ctxt.iface->dhcpv4 != RELAYD_SERVER)
+                       if (ctxt.iface->dhcpv6 != MODE_SERVER &&
+                                       ctxt.iface->dhcpv4 != MODE_SERVER)
                                continue;
 
-                       if (ctxt.iface->dhcpv6 == RELAYD_SERVER &&
+                       if (ctxt.iface->dhcpv6 == MODE_SERVER &&
                                        ctxt.iface->ia_assignments.next) {
                                list_for_each_entry(ctxt.c, &ctxt.iface->ia_assignments, head) {
                                        if (!(ctxt.c->flags & OAF_BOUND) || ctxt.c->managed_size < 0)
@@ -379,7 +379,7 @@ void dhcpv6_write_statefile(void)
                                }
                        }
 
-                       if (ctxt.iface->dhcpv4 == RELAYD_SERVER &&
+                       if (ctxt.iface->dhcpv4 == MODE_SERVER &&
                                        ctxt.iface->dhcpv4_assignments.next) {
                                struct dhcpv4_assignment *c;
                                list_for_each_entry(c, &ctxt.iface->dhcpv4_assignments, head) {
@@ -657,7 +657,7 @@ static bool assign_na(struct interface *iface, struct dhcpv6_assignment *assign)
 
 void dhcpv6_ia_preupdate(struct interface *iface)
 {
-       if (iface->dhcpv6 != RELAYD_SERVER)
+       if (iface->dhcpv6 != MODE_SERVER)
                return;
 
        struct dhcpv6_assignment *c, *border = list_last_entry(
@@ -701,7 +701,7 @@ static void stop_reconf(struct dhcpv6_assignment *a)
 
 void dhcpv6_ia_postupdate(struct interface *iface)
 {
-       if (iface->dhcpv6 != RELAYD_SERVER)
+       if (iface->dhcpv6 != MODE_SERVER)
                return;
 
        time_t now = odhcpd_time();
@@ -762,7 +762,7 @@ static void valid_until_cb(struct uloop_timeout *event)
        time_t now = odhcpd_time();
        struct interface *iface;
        list_for_each_entry(iface, &interfaces, head) {
-               if (iface->dhcpv6 != RELAYD_SERVER || iface->ia_assignments.next == NULL)
+               if (iface->dhcpv6 != MODE_SERVER || iface->ia_assignments.next == NULL)
                        continue;
 
                struct dhcpv6_assignment *a, *n;
index 4ecb54ab35c441de190b55792dfe8e9272c65bea..902bdbf6b501bc59ea40a7964407f011a2fe9a29 100644 (file)
@@ -87,7 +87,7 @@ int setup_dhcpv6_interface(struct interface *iface, bool enable)
                struct ipv6_mreq server = {ALL_DHCPV6_SERVERS, iface->ifindex};
                setsockopt(sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &relay, sizeof(relay));
 
-               if (iface->dhcpv6 == RELAYD_SERVER)
+               if (iface->dhcpv6 == MODE_SERVER)
                        setsockopt(sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &server, sizeof(server));
 
                iface->dhcpv6_event.uloop.fd = sock;
@@ -381,9 +381,9 @@ static void handle_client_request(void *addr, void *data, size_t len,
 static void handle_dhcpv6(void *addr, void *data, size_t len,
                struct interface *iface, void *dest_addr)
 {
-       if (iface->dhcpv6 == RELAYD_SERVER) {
+       if (iface->dhcpv6 == MODE_SERVER) {
                handle_client_request(addr, data, len, iface, dest_addr);
-       } else if (iface->dhcpv6 == RELAYD_RELAY) {
+       } else if (iface->dhcpv6 == MODE_RELAY) {
                if (iface->master)
                        relay_server_response(data, len);
                else
@@ -507,7 +507,7 @@ static void relay_client_request(struct sockaddr_in6 *source,
 {
        struct interface *master = odhcpd_get_master_interface();
        const struct dhcpv6_relay_header *h = data;
-       if (!master || master->dhcpv6 != RELAYD_RELAY ||
+       if (!master || master->dhcpv6 != MODE_RELAY ||
                        h->msg_type == DHCPV6_MSG_RELAY_REPL ||
                        h->msg_type == DHCPV6_MSG_RECONFIGURE ||
                        h->msg_type == DHCPV6_MSG_REPLY ||
index 33dde872f73e801ac8db8a1255aa186136fa02df..e0e865fc55814d73e136b34e99238100c18c8a67 100644 (file)
--- a/src/ndp.c
+++ b/src/ndp.c
@@ -187,13 +187,13 @@ int setup_ndp_interface(struct interface *iface, bool enable)
                close(iface->ndp_event.uloop.fd);
                iface->ndp_event.uloop.fd = -1;
 
-               if (!enable || iface->ndp != RELAYD_RELAY)
+               if (!enable || iface->ndp != MODE_RELAY)
                        if (write(procfd, "0\n", 2) < 0) {}
 
                dump_neigh = true;
        }
 
-       if (enable && iface->ndp == RELAYD_RELAY) {
+       if (enable && iface->ndp == MODE_RELAY) {
                if (write(procfd, "1\n", 2) < 0) {}
 
                int sock = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, htons(ETH_P_IPV6));
@@ -286,7 +286,7 @@ static void handle_solicit(void *addr, void *data, size_t len,
        // Don't process solicit messages on non relay interfaces
        // Don't forward any non-DAD solicitation for external ifaces
        // TODO: check if we should even forward DADs for them
-       if (iface->ndp != RELAYD_RELAY || (iface->external && !ns_is_dad))
+       if (iface->ndp != MODE_RELAY || (iface->external && !ns_is_dad))
                return;
 
        if (len < sizeof(*ip6) + sizeof(*req))
@@ -306,7 +306,7 @@ static void handle_solicit(void *addr, void *data, size_t len,
 
        struct interface *c;
        list_for_each_entry(c, &interfaces, head)
-               if (iface != c && c->ndp == RELAYD_RELAY &&
+               if (iface != c && c->ndp == MODE_RELAY &&
                                (ns_is_dad || !c->external))
                        ping6(&req->nd_ns_target, c);
 }
@@ -382,10 +382,10 @@ static void setup_addr_for_relaying(struct in6_addr *addr, struct interface *ifa
        inet_ntop(AF_INET6, addr, ipbuf, sizeof(ipbuf));
 
        list_for_each_entry(c, &interfaces, head) {
-               if (iface == c || (c->ndp != RELAYD_RELAY && !add))
+               if (iface == c || (c->ndp != MODE_RELAY && !add))
                        continue;
 
-               bool neigh_add = (c->ndp == RELAYD_RELAY ? add : false);
+               bool neigh_add = (c->ndp == MODE_RELAY ? add : false);
 
                if (odhcpd_setup_proxy_neigh(addr, c, neigh_add))
                        syslog(LOG_DEBUG, "Failed to %s proxy neighbour entry %s%%%s",
@@ -463,7 +463,7 @@ static int cb_rtnl_valid(struct nl_msg *msg, _unused void *arg)
 
                        check_addr6_updates(iface);
 
-                       if (iface->ndp != RELAYD_RELAY)
+                       if (iface->ndp != MODE_RELAY)
                                break;
 
                        /* handle the relay logic below */
@@ -498,7 +498,7 @@ static int cb_rtnl_valid(struct nl_msg *msg, _unused void *arg)
                        return NL_SKIP;
 
                iface = odhcpd_get_interface_by_index(ndm->ndm_ifindex);
-               if (!iface || iface->ndp != RELAYD_RELAY)
+               if (!iface || iface->ndp != MODE_RELAY)
                        return (iface ? NL_OK : NL_SKIP);
 
                nlmsg_parse(hdr, sizeof(*ndm), nla, __NDA_MAX - 1, NULL);
index 5b739d0f427b3201815058b0207cd5e6c31060c4..837004b0be95eed67bef9769522d4e6ce4455869 100644 (file)
@@ -566,7 +566,7 @@ static void odhcpd_receive_packets(struct uloop_fd *u, _unused unsigned int even
 {
        struct odhcpd_event *e = container_of(u, struct odhcpd_event, uloop);
 
-       uint8_t data_buf[RELAYD_BUFFER_SIZE], cmsg_buf[128];
+       uint8_t data_buf[8192], cmsg_buf[128];
        union {
                struct sockaddr_in6 in6;
                struct sockaddr_in in;
index b0801a44b27285a7a48e6f9c8017b10d1d4ac458..a240aa163b9ea18a0541d52af6f0a37f5e482a07 100644 (file)
@@ -40,8 +40,6 @@
 #define ND_OPT_RECURSIVE_DNS 25
 #define ND_OPT_DNS_SEARCH 31
 
-#define RELAYD_BUFFER_SIZE 8192
-
 #define INFINITE_VALID(x) ((x) == 0)
 
 #define _unused __attribute__((unused))
@@ -87,10 +85,10 @@ struct odhcpd_ipaddr {
 };
 
 enum odhcpd_mode {
-       RELAYD_DISABLED,
-       RELAYD_SERVER,
-       RELAYD_RELAY,
-       RELAYD_HYBRID
+       MODE_DISABLED,
+       MODE_SERVER,
+       MODE_RELAY,
+       MODE_HYBRID
 };
 
 
index cb2afc962b9f7aee14ab275b477b0ed7a799be1f..30f1609b2a315514b492b4e34767ab24d3d7d9ec 100644 (file)
@@ -113,15 +113,15 @@ int setup_router_interface(struct interface *iface, bool enable)
        } else {
                void *mreq = &all_routers;
 
-               if (iface->ra == RELAYD_RELAY && iface->master) {
+               if (iface->ra == MODE_RELAY && iface->master) {
                        mreq = &all_nodes;
                        forward_router_solicitation(iface);
-               } else if (iface->ra == RELAYD_SERVER && !iface->master) {
+               } else if (iface->ra == MODE_SERVER && !iface->master) {
                        iface->timer_rs.cb = trigger_router_advert;
                        uloop_timeout_set(&iface->timer_rs, 1000);
                }
 
-               if (iface->ra == RELAYD_RELAY || (iface->ra == RELAYD_SERVER && !iface->master))
+               if (iface->ra == MODE_RELAY || (iface->ra == MODE_SERVER && !iface->master))
                        setsockopt(router_event.uloop.fd, IPPROTO_IPV6,
                                        IPV6_ADD_MEMBERSHIP, mreq, sizeof(all_nodes));
        }
@@ -134,7 +134,7 @@ static void sigusr1_refresh(_unused int signal)
 {
        struct interface *iface;
        list_for_each_entry(iface, &interfaces, head)
-               if (iface->ra == RELAYD_SERVER && !iface->master)
+               if (iface->ra == MODE_SERVER && !iface->master)
                        uloop_timeout_set(&iface->timer_rs, 1000);
 }
 
@@ -584,10 +584,10 @@ static void handle_icmpv6(void *addr, void *data, size_t len,
        if (!router_icmpv6_valid(addr, data, len))
                return;
 
-       if ((iface->ra == RELAYD_SERVER && !iface->master)) { // Server mode
+       if ((iface->ra == MODE_SERVER && !iface->master)) { // Server mode
                if (hdr->icmp6_type == ND_ROUTER_SOLICIT)
                        send_router_advert(iface, &from->sin6_addr);
-       } else if (iface->ra == RELAYD_RELAY) { // Relay mode
+       } else if (iface->ra == MODE_RELAY) { // Relay mode
                if (hdr->icmp6_type == ND_ROUTER_ADVERT && iface->master)
                        forward_router_advertisement(data, len);
                else if (hdr->icmp6_type == ND_ROUTER_SOLICIT && !iface->master)
@@ -646,7 +646,7 @@ static void forward_router_advertisement(uint8_t *data, size_t len)
 
        struct interface *iface;
        list_for_each_entry(iface, &interfaces, head) {
-               if (iface->ra != RELAYD_RELAY || iface->master)
+               if (iface->ra != MODE_RELAY || iface->master)
                        continue;
 
                // Fixup source hardware address option
index 30f7e935fd2bf6c52331f5ecc26fa46fdaf5e96e..14d0c42504823f014f781f3e27e0f0c92c9ca949 100644 (file)
@@ -27,7 +27,7 @@ static int handle_dhcpv4_leases(struct ubus_context *ctx, _unused struct ubus_ob
        a = blobmsg_open_table(&b, "device");
 
        list_for_each_entry(iface, &interfaces, head) {
-               if (iface->dhcpv4 != RELAYD_SERVER || iface->dhcpv4_assignments.next == NULL)
+               if (iface->dhcpv4 != MODE_SERVER || iface->dhcpv4_assignments.next == NULL)
                        continue;
 
                void *i = blobmsg_open_table(&b, iface->ifname);
@@ -106,7 +106,7 @@ static int handle_dhcpv6_leases(_unused struct ubus_context *ctx, _unused struct
        a = blobmsg_open_table(&b, "device");
 
        list_for_each_entry(iface, &interfaces, head) {
-               if (iface->dhcpv6 != RELAYD_SERVER || iface->ia_assignments.next == NULL)
+               if (iface->dhcpv6 != MODE_SERVER || iface->ia_assignments.next == NULL)
                        continue;
 
                void *i = blobmsg_open_table(&b, iface->ifname);