diff options
| author | Roy Marples <roy@marples.name> | 2009-01-27 18:09:02 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2009-01-27 18:09:02 +0000 |
| commit | fa344ba2b1dcf002f348b7fa69ef422585b4b438 (patch) | |
| tree | 0a20b9e8aeec52fcec0f5c30a669cb8b444b35ec /dhcpcd.c | |
| parent | 16687a3be1f8c1e6d55cdd691e947e5760eef30c (diff) | |
| download | dhcpcd-fa344ba2b1dcf002f348b7fa69ef422585b4b438.tar.xz | |
Add route removal detection to Linux.
This involved a rejig of the socket code so we can detect
if we removed the route or not.
Diffstat (limited to 'dhcpcd.c')
| -rw-r--r-- | dhcpcd.c | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -78,9 +78,9 @@ static char **margv; static int margc; static char **ifv; static int ifc; -static int linkfd = -1; static char *cffile; static char *pidfile; +static int linkfd = -1; struct dhcp_op { uint8_t value; @@ -214,6 +214,16 @@ close_sockets(struct interface *iface) } } +struct interface * +find_interface(const char *ifname) +{ + struct interface *ifp; + + for (ifp = ifaces; ifp; ifp = ifp->next) + if (strcmp(ifp->name, ifname) == 0) + return ifp; + return NULL; +} static void stop_interface(struct interface *iface) @@ -1024,11 +1034,11 @@ handle_new_interface(const char *ifname) if (ifn) continue; init_state(ifp, 2, UNCONST(argv)); - start_interface(ifp); if (ifl) ifl->next = ifp; else ifaces = ifp; + start_interface(ifp); } } } @@ -1038,11 +1048,9 @@ handle_remove_interface(const char *ifname) { struct interface *iface; - for (iface = ifaces; iface; iface = iface->next) - if (strcmp(iface->name, ifname) == 0) { - stop_interface(iface); - break; - } + iface = find_interface(ifname); + if (iface != NULL) + stop_interface(iface); } /* ARGSUSED */ @@ -1395,7 +1403,7 @@ main(int argc, char **argv) syslog(LOG_INFO, "version " VERSION " starting"); - if ((signal_fd =signal_init()) == -1) + if ((signal_fd = signal_init()) == -1) exit(EXIT_FAILURE); if (signal_setup() == -1) exit(EXIT_FAILURE); @@ -1408,6 +1416,7 @@ main(int argc, char **argv) } } + init_socket(); if (ifo->options & DHCPCD_LINK) { linkfd = open_link_socket(); if (linkfd == -1) |
