diff options
| author | Roy Marples <roy@marples.name> | 2015-04-24 09:18:42 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2015-04-24 09:18:42 +0000 |
| commit | 2d64035ea0c06e890f97027b3d68a319a8e1d35f (patch) | |
| tree | f13071c91e500dba98427a1254cfb1cebdf07f18 /dhcpcd.c | |
| parent | b628521165b1f987c9eb40f105b9285c76827190 (diff) | |
| download | dhcpcd-2d64035ea0c06e890f97027b3d68a319a8e1d35f.tar.xz | |
Add dhcpcd_drop function to reduce code complexity.
Diffstat (limited to 'dhcpcd.c')
| -rw-r--r-- | dhcpcd.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -313,6 +313,17 @@ dhcpcd_daemonise(struct dhcpcd_ctx *ctx) } static void +dhcpcd_drop(struct interface *ifp, int stop) +{ + + dhcp6_drop(ifp, stop ? NULL : "EXPIRE6"); + ipv6nd_drop(ifp); + ipv6_drop(ifp); + dhcp_drop(ifp, stop ? "STOP" : "EXPIRE"); + arp_close(ifp); +} + +static void stop_interface(struct interface *ifp) { struct dhcpcd_ctx *ctx; @@ -321,11 +332,7 @@ stop_interface(struct interface *ifp) logger(ctx, LOG_INFO, "%s: removing interface", ifp->name); ifp->options->options |= DHCPCD_STOPPING; - dhcp6_drop(ifp, NULL); - ipv6nd_drop(ifp); - ipv6_drop(ifp); - dhcp_drop(ifp, "STOP"); - arp_close(ifp); + dhcpcd_drop(ifp, 1); if (ifp->options->options & DHCPCD_DEPARTED) script_runreason(ifp, "DEPARTED"); else @@ -620,11 +627,7 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags, logger(ctx, LOG_INFO, "%s: carrier lost", ifp->name); ifp->carrier = LINK_DOWN; script_runreason(ifp, "NOCARRIER"); - dhcp6_drop(ifp, "EXPIRE6"); - ipv6nd_drop(ifp); - ipv6_drop(ifp); - dhcp_drop(ifp, "EXPIRE"); - arp_close(ifp); + dhcpcd_drop(ifp, 0); } } else if (carrier == LINK_UP && ifp->flags & IFF_UP) { if (ifp->carrier != LINK_UP) { |
