dhcpv4: make DHCPv4 support compiletime configurable
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 9 Nov 2017 15:09:51 +0000 (16:09 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Thu, 9 Nov 2017 15:09:51 +0000 (16:09 +0100)
Make DHCPv4 support compile time configurable; avoids DHCPv4 functionality
overlap with other packages.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
CMakeLists.txt
src/config.c
src/odhcpd.c
src/odhcpd.h

index 839f47fcf406a5f9d497153fda4b3655b346c587..380d633967715666d5ac2c66f61960aa25c5fcff 100644 (file)
@@ -25,7 +25,12 @@ if(${UBUS})
        set(EXT_LINK ${EXT_LINK} ubus)
 endif(${UBUS})
 
-add_executable(odhcpd src/odhcpd.c src/config.c src/router.c src/dhcpv6.c src/ndp.c src/dhcpv6-ia.c src/dhcpv4.c src/netlink.c ${EXT_SRC})
+if(${DHCPV4_SUPPORT})
+       add_definitions(-DDHCPV4_SUPPORT)
+       set(EXT_SRC ${EXT_SRC} src/dhcpv4.c)
+endif(${DHCPV4_SUPPORT})
+
+add_executable(odhcpd src/odhcpd.c src/config.c src/router.c src/dhcpv6.c src/ndp.c src/dhcpv6-ia.c src/netlink.c ${EXT_SRC})
 target_link_libraries(odhcpd resolv ubox uci ${libnl} ${EXT_LINK})
 
 # Installation
index 7e23eb28893ed8e1c9af4656261f539ff5e4592e..bb885d078824ca7e024508b0d3284f0b0e52ea24 100644 (file)
@@ -239,7 +239,9 @@ static void close_interface(struct interface *iface)
        router_setup_interface(iface, false);
        dhcpv6_setup_interface(iface, false);
        ndp_setup_interface(iface, false);
+#ifdef DHCPV4_SUPPORT
        dhcpv4_setup_interface(iface, false);
+#endif
 
        clean_interface(iface);
        free(iface->addr4);
@@ -846,7 +848,9 @@ void odhcpd_reload(void)
                        router_setup_interface(i, !i->ignore || i->ra != MODE_DISABLED);
                        dhcpv6_setup_interface(i, !i->ignore || i->dhcpv6 != MODE_DISABLED);
                        ndp_setup_interface(i, !i->ignore || i->ndp != MODE_DISABLED);
+#ifdef DHCPV4_SUPPORT
                        dhcpv4_setup_interface(i, !i->ignore || i->dhcpv4 != MODE_DISABLED);
+#endif
                } else
                        close_interface(i);
        }
index 4972aa2b44c1054f6348f11b4eb035d025c4a6d3..13697b77ba879429e5e1a0776ab6e02a53735d2f 100644 (file)
@@ -110,8 +110,10 @@ int main(int argc, char **argv)
        if (ndp_init())
                return 4;
 
+#ifdef DHCPV4_SUPPORT
        if (dhcpv4_init())
                return 4;
+#endif
 
        odhcpd_run();
        return 0;
index a49ab57986b31b8a632b50c9a1b4b46385afb9e8..45badd3c012acbf553f773ce536e342132ca5117 100644 (file)
@@ -315,12 +315,14 @@ void netlink_dump_addr_table(const bool v6);
 int netlink_init(void);
 int router_init(void);
 int dhcpv6_init(void);
-int dhcpv4_init(void);
 int ndp_init(void);
+#ifdef DHCPV4_SUPPORT
+int dhcpv4_init(void);
 
+int dhcpv4_setup_interface(struct interface *iface, bool enable);
+#endif
 int router_setup_interface(struct interface *iface, bool enable);
 int dhcpv6_setup_interface(struct interface *iface, bool enable);
 int ndp_setup_interface(struct interface *iface, bool enable);
-int dhcpv4_setup_interface(struct interface *iface, bool enable);
 
 void odhcpd_reload(void);