From: Roy Marples Date: Fri, 25 Apr 2014 10:42:37 +0000 (+0000) Subject: Move net.c to if.c. X-Git-Tag: v6.4.0~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a7ff10050590206a169186071ddfaa969f8fd79;p=thirdparty%2Fdhcpcd.git Move net.c to if.c. Ensure that if.c and if-KERNEL.c are namespaced correctly. --- diff --git a/Makefile b/Makefile index 0e018f57..f9dadfe2 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ PROG= dhcpcd SRCS= common.c control.c dhcpcd.c duid.c eloop.c -SRCS+= if-options.c if-pref.c net.c script.c +SRCS+= if.c if-options.c if-pref.c script.c SRCS+= dhcp-common.c CFLAGS?= -O2 diff --git a/arp.c b/arp.c index 656dbbea..83745f46 100644 --- a/arp.c +++ b/arp.c @@ -25,6 +25,8 @@ * SUCH DAMAGE. */ +#include + #include #include #include @@ -39,9 +41,9 @@ #include "dhcp.h" #include "dhcpcd.h" #include "eloop.h" +#include "if.h" #include "if-options.h" #include "ipv4ll.h" -#include "net.h" #define ARP_LEN \ (sizeof(struct arphdr) + (2 * sizeof(uint32_t)) + (2 * HWADDR_LEN)) @@ -79,7 +81,7 @@ arp_send(const struct interface *ifp, int op, in_addr_t sip, in_addr_t tip) APPEND(&sip, sizeof(sip)); ZERO(ifp->hwlen); APPEND(&tip, sizeof(tip)); - return ipv4_sendrawpacket(ifp, ETHERTYPE_ARP, arp_buffer, len); + return if_sendrawpacket(ifp, ETHERTYPE_ARP, arp_buffer, len); eexit: errno = ENOBUFS; @@ -132,7 +134,7 @@ arp_packet(void *arg) state = D_STATE(ifp); state->fail.s_addr = 0; for(;;) { - bytes = ipv4_getrawpacket(ifp, ETHERTYPE_ARP, + bytes = if_readrawpacket(ifp, ETHERTYPE_ARP, arp_buffer, sizeof(arp_buffer), NULL); if (bytes == 0 || bytes == -1) return; @@ -232,7 +234,7 @@ arp_announce(void *arg) if (state->new == NULL) return; if (state->arp_fd == -1) { - state->arp_fd = ipv4_opensocket(ifp, ETHERTYPE_ARP); + state->arp_fd = if_openrawsocket(ifp, ETHERTYPE_ARP); if (state->arp_fd == -1) { syslog(LOG_ERR, "%s: %s: %m", __func__, ifp->name); return; @@ -288,7 +290,7 @@ arp_probe(void *arg) int arping = 0; if (state->arp_fd == -1) { - state->arp_fd = ipv4_opensocket(ifp, ETHERTYPE_ARP); + state->arp_fd = if_openrawsocket(ifp, ETHERTYPE_ARP); if (state->arp_fd == -1) { syslog(LOG_ERR, "%s: %s: %m", __func__, ifp->name); return; diff --git a/common.c b/common.c index a4a6a8bb..dfb4f697 100644 --- a/common.c +++ b/common.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -180,3 +181,65 @@ uptime(void) return tv.tv_sec; } +char * +hwaddr_ntoa(const unsigned char *hwaddr, size_t hwlen, char *buf, size_t buflen) +{ + char *p; + size_t i; + + if (buf == NULL) { + return NULL; + } + + if (hwlen * 3 > buflen) { + errno = ENOBUFS; + return 0; + } + + p = buf; + for (i = 0; i < hwlen; i++) { + if (i > 0) + *p ++= ':'; + p += snprintf(p, 3, "%.2x", hwaddr[i]); + } + *p ++= '\0'; + return buf; +} + +size_t +hwaddr_aton(unsigned char *buffer, const char *addr) +{ + char c[3]; + const char *p = addr; + unsigned char *bp = buffer; + size_t len = 0; + + c[2] = '\0'; + while (*p) { + c[0] = *p++; + c[1] = *p++; + /* Ensure that digits are hex */ + if (isxdigit((unsigned char)c[0]) == 0 || + isxdigit((unsigned char)c[1]) == 0) + { + errno = EINVAL; + return 0; + } + /* We should have at least two entries 00:01 */ + if (len == 0 && *p == '\0') { + errno = EINVAL; + return 0; + } + /* Ensure that next data is EOL or a seperator with data */ + if (!(*p == '\0' || (*p == ':' && *(p + 1) != '\0'))) { + errno = EINVAL; + return 0; + } + if (*p) + p++; + if (bp) + *bp++ = (unsigned char)strtol(c, NULL, 16); + len++; + } + return len; +} diff --git a/common.h b/common.h index 823a1124..59473fa2 100644 --- a/common.h +++ b/common.h @@ -108,4 +108,6 @@ ssize_t setvar(char ***, const char *, const char *, const char *); ssize_t setvard(char ***, const char *, const char *, size_t); time_t uptime(void); +char *hwaddr_ntoa(const unsigned char *, size_t, char *, size_t); +size_t hwaddr_aton(unsigned char *, const char *); #endif diff --git a/dhcp-common.c b/dhcp-common.c index bb27028b..5b8d15f4 100644 --- a/dhcp-common.c +++ b/dhcp-common.c @@ -39,7 +39,8 @@ #include "common.h" #include "dhcp-common.h" #include "dhcp.h" -#include "platform.h" +#include "if.h" +#include "ipv6.h" struct dhcp_opt * vivso_find(uint32_t iana_en, const void *arg) @@ -78,7 +79,7 @@ dhcp_vendor(char *str, size_t len) utn.sysname, utn.release, utn.machine); p += l; len -= (size_t)l; - l = hardware_platform(p, len); + l = if_machinearch(p, len); return (size_t)(p - str); } diff --git a/dhcp.c b/dhcp.c index 2480b815..b5524000 100644 --- a/dhcp.c +++ b/dhcp.c @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -62,6 +63,7 @@ #include "dhcp-common.h" #include "duid.h" #include "eloop.h" +#include "if.h" #include "ipv4.h" #include "ipv4ll.h" #include "script.h" @@ -783,9 +785,9 @@ make_message(struct dhcp_message **message, *p++ = DHO_MAXMESSAGESIZE; *p++ = 2; - mtu = get_mtu(iface->name); + mtu = if_getmtu(iface->name); if (mtu < MTU_MIN) { - if (set_mtu(iface->name, MTU_MIN) == 0) + if (if_setmtu(iface->name, MTU_MIN) == 0) sz = MTU_MIN; } else if (mtu > MTU_MAX) { /* Even though our MTU could be greater than @@ -1590,7 +1592,7 @@ send_message(struct interface *iface, uint8_t type, if (udp == NULL) { syslog(LOG_ERR, "dhcp_makeudppacket: %m"); } else { - r = ipv4_sendrawpacket(iface, ETHERTYPE_IP, + r = if_sendrawpacket(iface, ETHERTYPE_IP, (uint8_t *)udp, ulen); free(udp); } @@ -1600,7 +1602,7 @@ send_message(struct interface *iface, uint8_t type, * As such we remove it from consideration without actually * stopping the interface. */ if (r == -1) { - syslog(LOG_ERR, "%s: ipv4_sendrawpacket: %m", + syslog(LOG_ERR, "%s: if_sendrawpacket: %m", iface->name); if (!(iface->ctx->options & DHCPCD_TEST)) dhcp_drop(iface, "FAIL"); @@ -2558,7 +2560,7 @@ dhcp_handlepacket(void *arg) * The benefit is that if we get >1 DHCP packet in our buffer and * the first one fails for any reason, we can use the next. */ for(;;) { - bytes = (size_t)ipv4_getrawpacket(iface, ETHERTYPE_IP, + bytes = (size_t)if_readrawpacket(iface, ETHERTYPE_IP, iface->ctx->packet, udp_dhcp_len, &partialcsum); if (bytes == 0 || (ssize_t)bytes == -1) break; @@ -2679,7 +2681,7 @@ dhcp_open(struct interface *ifp) state = D_STATE(ifp); if (state->raw_fd == -1) { - state->raw_fd = ipv4_opensocket(ifp, ETHERTYPE_IP); + state->raw_fd = if_openrawsocket(ifp, ETHERTYPE_IP); if (state->raw_fd == -1) { syslog(LOG_ERR, "%s: %s: %m", __func__, ifp->name); return -1; diff --git a/dhcp.h b/dhcp.h index 365daeff..7ff8f9f8 100644 --- a/dhcp.h +++ b/dhcp.h @@ -243,7 +243,6 @@ struct dhcp_state { #include "dhcpcd.h" #include "if-options.h" -#include "net.h" #ifdef INET char *decode_rfc3361(const uint8_t *, size_t); diff --git a/dhcp6.c b/dhcp6.c index e2f47301..ebc3c6a7 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -54,7 +54,6 @@ #include "duid.h" #include "eloop.h" #include "ipv6nd.h" -#include "platform.h" #include "script.h" #ifndef __UNCONST diff --git a/dhcpcd.c b/dhcpcd.c index 8c673997..9415331e 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -60,13 +60,12 @@ const char dhcpcd_copyright[] = "Copyright (c) 2006-2014 Roy Marples"; #include "dhcp6.h" #include "duid.h" #include "eloop.h" +#include "if.h" #include "if-options.h" #include "if-pref.h" #include "ipv4.h" #include "ipv6.h" #include "ipv6nd.h" -#include "net.h" -#include "platform.h" #include "script.h" #ifdef USE_SIGNALS @@ -325,7 +324,7 @@ stop_interface(struct interface *ifp) eloop_timeout_delete(ctx->eloop, NULL, ifp); if (ifp->options->options & DHCPCD_DEPARTED) script_runreason(ifp, "DEPARTED"); - free_interface(ifp); + if_free(ifp); if (!(ctx->options & (DHCPCD_MASTER | DHCPCD_TEST))) eloop_exit(ctx->eloop, EXIT_FAILURE); } @@ -351,7 +350,7 @@ configure_interface1(struct interface *ifp) ifo->options &= ~(DHCPCD_ARP | DHCPCD_IPV4LL); if (!(ifp->flags & (IFF_POINTOPOINT | IFF_LOOPBACK | IFF_MULTICAST))) ifo->options &= ~DHCPCD_IPV6RS; - if (ifo->options & DHCPCD_LINK && carrier_status(ifp) == LINK_UNKNOWN) + if (ifo->options & DHCPCD_LINK && if_carrier(ifp) == LINK_UNKNOWN) ifo->options &= ~DHCPCD_LINK; if (ifo->metric != -1) @@ -362,9 +361,9 @@ configure_interface1(struct interface *ifp) /* We want to disable kernel interface RA as early as possible. */ if (ifo->options & DHCPCD_IPV6RS) { - ra_global = check_ipv6(ifp->ctx, NULL, + ra_global = if_checkipv6(ifp->ctx, NULL, ifp->ctx->options & DHCPCD_IPV6RA_OWN ? 1 : 0); - ra_iface = check_ipv6(ifp->ctx, ifp->name, + ra_iface = if_checkipv6(ifp->ctx, ifp->name, ifp->options->options & DHCPCD_IPV6RA_OWN ? 1 : 0); if (ra_global == -1 || ra_iface == -1) ifo->options &= ~DHCPCD_IPV6RS; @@ -504,7 +503,7 @@ handle_carrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags, return; if (carrier == LINK_UNKNOWN) - carrier = carrier_status(ifp); /* will set ifp->flags */ + carrier = if_carrier(ifp); /* will set ifp->flags */ else ifp->flags = flags; @@ -537,7 +536,7 @@ handle_carrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags, handle_interface(ctx, 0, ifp->name); #endif if (ifp->wireless) - getifssid(ifp->name, ifp->ssid); + if_getssid(ifp->name, ifp->ssid); configure_interface(ifp, ctx->argc, ctx->argv); script_runreason(ifp, "CARRIER"); start_interface(ifp); @@ -657,8 +656,8 @@ handle_link(void *arg) struct dhcpcd_ctx *ctx; ctx = arg; - if (manage_link(ctx) == -1 && errno != ENXIO && errno != ENODEV) - syslog(LOG_ERR, "manage_link: %m"); + if (if_managelink(ctx) == -1 && errno != ENXIO && errno != ENODEV) + syslog(LOG_ERR, "if_managelink: %m"); } static void @@ -681,7 +680,7 @@ init_state(struct interface *ifp, int argc, char **argv) reason = NULL; /* appease gcc */ if (ifo->options & DHCPCD_LINK) { - switch (carrier_status(ifp)) { + switch (if_carrier(ifp)) { case LINK_DOWN: ifp->carrier = LINK_DOWN; reason = "NOCARRIER"; @@ -732,7 +731,7 @@ handle_interface(void *arg, int action, const char *ifname) return; } - ifs = discover_interfaces(ctx, -1, UNCONST(argv)); + ifs = if_discover(ctx, -1, UNCONST(argv)); TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) { if (strcmp(ifp->name, ifname) != 0) continue; @@ -757,7 +756,7 @@ handle_interface(void *arg, int action, const char *ifname) /* Free our discovered list */ while ((ifp = TAILQ_FIRST(ifs))) { TAILQ_REMOVE(ifs, ifp, next); - free_interface(ifp); + if_free(ifp); } free(ifs); } @@ -807,7 +806,7 @@ reconf_reboot(struct dhcpcd_ctx *ctx, int action, int argc, char **argv, int oi) struct if_head *ifs; struct interface *ifn, *ifp; - ifs = discover_interfaces(ctx, argc - oi, argv + oi); + ifs = if_discover(ctx, argc - oi, argv + oi); if (ifs == NULL) return; @@ -819,7 +818,7 @@ reconf_reboot(struct dhcpcd_ctx *ctx, int action, int argc, char **argv, int oi) if_reboot(ifn, argc, argv); else ipv4_applyaddr(ifn); - free_interface(ifp); + if_free(ifp); } else { init_state(ifp, argc, argv); TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next); @@ -1442,7 +1441,7 @@ main(int argc, char **argv) * instead. * We also need to open this before checking for interfaces below * so that we pickup any new addresses during the discover phase. */ - ctx.link_fd = open_link_socket(); + ctx.link_fd = if_openlinksocket(); if (ctx.link_fd == -1) syslog(LOG_ERR, "open_link_socket: %m"); else @@ -1454,7 +1453,7 @@ main(int argc, char **argv) (DHCPCD_MASTER | DHCPCD_DEV)) dev_start(&ctx); - ctx.ifaces = discover_interfaces(&ctx, ctx.ifc, ctx.ifv); + ctx.ifaces = if_discover(&ctx, ctx.ifc, ctx.ifv); for (i = 0; i < ctx.ifc; i++) { if (find_interface(&ctx, ctx.ifv[i]) == NULL) syslog(LOG_ERR, "%s: interface not found or invalid", @@ -1545,7 +1544,7 @@ exit1: if (ctx.ifaces) { while ((ifp = TAILQ_FIRST(ctx.ifaces))) { TAILQ_REMOVE(ctx.ifaces, ifp, next); - free_interface(ifp); + if_free(ifp); } free(ctx.ifaces); } @@ -1557,7 +1556,7 @@ exit1: free_options(ifo); free_globals(&ctx); - restore_kernel_ra(&ctx); + if_rarestore(&ctx); ipv4_ctxfree(&ctx); ipv6_ctxfree(&ctx); dev_stop(&ctx, !(ctx.options & DHCPCD_FORKED)); diff --git a/duid.c b/duid.c index 8f99617d..fa607bc1 100644 --- a/duid.c +++ b/duid.c @@ -48,8 +48,8 @@ #endif #include "common.h" +#include "dhcpcd.h" #include "duid.h" -#include "net.h" static size_t duid_make(unsigned char *d, const struct interface *ifp, uint16_t type) diff --git a/duid.h b/duid.h index b2f5eed4..139ce421 100644 --- a/duid.h +++ b/duid.h @@ -28,11 +28,7 @@ #ifndef DUID_H #define DUID_H -#include "net.h" - -#ifndef DUID_LEN -# define DUID_LEN 128 + 2 -#endif +#define DUID_LEN 128 + 2 size_t duid_init(const struct interface *); diff --git a/if-bsd.c b/if-bsd.c index 0c5686d7..50001adc 100644 --- a/if-bsd.c +++ b/if-bsd.c @@ -42,6 +42,7 @@ #ifdef __FreeBSD__ /* Needed so that including netinet6/in6_var.h works */ # include #endif +#include #include #include #include @@ -69,10 +70,10 @@ #include "config.h" #include "common.h" #include "dhcp.h" +#include "if.h" #include "if-options.h" #include "ipv4.h" #include "ipv6.h" -#include "platform.h" #include "bpf-filter.h" @@ -109,7 +110,7 @@ if_conf(__unused struct interface *iface) } int -open_link_socket(void) +if_openlinksocket(void) { #ifdef SOCK_CLOEXEC @@ -136,7 +137,7 @@ open_link_socket(void) } int -getifssid(const char *ifname, char *ssid) +if_getssid(const char *ifname, char *ssid) { int s, retval = -1; #if defined(SIOCG80211NWID) @@ -206,7 +207,7 @@ if_vimaster(const char *ifname) if (ifmr.ifm_status & IFM_AVALID && IFM_TYPE(ifmr.ifm_active) == IFM_IEEE80211) { - if (getifssid(ifname, NULL) == -1) + if (if_getssid(ifname, NULL) == -1) return 1; } return 0; @@ -214,7 +215,7 @@ if_vimaster(const char *ifname) #ifdef INET int -ipv4_opensocket(struct interface *ifp, int protocol) +if_openrawsocket(struct interface *ifp, int protocol) { struct dhcp_state *state; int fd = -1; @@ -303,7 +304,7 @@ eexit: } ssize_t -ipv4_sendrawpacket(const struct interface *ifp, int protocol, +if_sendrawpacket(const struct interface *ifp, int protocol, const void *data, size_t len) { struct iovec iov[2]; @@ -329,7 +330,7 @@ ipv4_sendrawpacket(const struct interface *ifp, int protocol, /* BPF requires that we read the entire buffer. * So we pass the buffer in the API so we can loop on >1 packet. */ ssize_t -ipv4_getrawpacket(struct interface *ifp, int protocol, +if_readrawpacket(struct interface *ifp, int protocol, void *data, size_t len, int *partialcsum) { int fd = -1; @@ -380,6 +381,7 @@ next: return bytes; } } + int if_address(const struct interface *iface, const struct in_addr *address, const struct in_addr *netmask, const struct in_addr *broadcast, @@ -728,7 +730,7 @@ get_addrs(int type, char *cp, struct sockaddr **sa) #ifdef INET6 int -in6_addr_flags(const char *ifname, const struct in6_addr *addr) +if_addrflags6(const char *ifname, const struct in6_addr *addr) { int s, flags; struct in6_ifreq ifr6; @@ -749,7 +751,7 @@ in6_addr_flags(const char *ifname, const struct in6_addr *addr) #endif int -manage_link(struct dhcpcd_ctx *ctx) +if_managelink(struct dhcpcd_ctx *ctx) { /* route and ifwatchd like a msg buf size of 2048 */ char msg[2048], *p, *e, *cp, ifname[IF_NAMESIZE]; @@ -891,7 +893,7 @@ manage_link(struct dhcpcd_ctx *ctx) sin6->sin6_addr.s6_addr, sizeof(ia6.s6_addr)); if (rtm->rtm_type == RTM_NEWADDR) { - ifa_flags = in6_addr_flags( + ifa_flags = if_addrflags6( ifname, &ia6); if (ifa_flags == -1) @@ -918,7 +920,7 @@ manage_link(struct dhcpcd_ctx *ctx) # endif #endif int -hardware_platform(char *str, size_t len) +if_machinearch(char *str, size_t len) { int mib[2] = { CTL_HW, HW_MACHINE_ARCH }; char march[SYS_NMLN]; @@ -989,7 +991,7 @@ eexit: } void -restore_kernel_ra(struct dhcpcd_ctx *ctx) +if_rarestore(struct dhcpcd_ctx *ctx) { if (ctx->options & DHCPCD_FORKED) @@ -1018,7 +1020,7 @@ restore_kernel_ra(struct dhcpcd_ctx *ctx) } static int -ipv6_ra_flush(void) +if_raflush(void) { int s; char dummy[IFNAMSIZ + 8]; @@ -1036,7 +1038,7 @@ ipv6_ra_flush(void) } int -check_ipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) +if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) { int ra; @@ -1120,19 +1122,10 @@ check_ipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) /* Flush the kernel knowledge of advertised routers * and prefixes so the kernel does not expire prefixes * and default routes we are trying to own. */ - ipv6_ra_flush(); + if_raflush(); } ctx->ra_global = ra; return ra; } - -int -ipv6_dadtransmits(__unused const char *ifname) -{ - int r; - - r = get_inet6_sysctl(IPV6CTL_DAD_COUNT); - return r < 0 ? 0 : r; -} #endif diff --git a/if-linux-wireless.c b/if-linux-wireless.c index 2d9519e2..9733517d 100644 --- a/if-linux-wireless.c +++ b/if-linux-wireless.c @@ -1,6 +1,6 @@ /* * dhcpcd - DHCP client daemon - * Copyright (c) 2009-2013 Roy Marples + * Copyright (c) 2009-2014 Roy Marples * All rights reserved * Redistribution and use in source and binary forms, with or without @@ -57,13 +57,13 @@ #include "common.h" #include "config.h" -/* We can't include net.h or dhcpcd.h because +/* We can't include if.h or dhcpcd.h because * they would pull in net/if.h, which defeats the purpose of this hack. */ #define IF_SSIDSIZE 33 -int getifssid(const char *ifname, char *ssid); +int if_getssid(const char *ifname, char *ssid); int -getifssid(const char *ifname, char *ssid) +if_getssid(const char *ifname, char *ssid) { #ifdef SIOCGIWESSID int s, retval; diff --git a/if-linux.c b/if-linux.c index 9690ea88..178f6cc6 100644 --- a/if-linux.c +++ b/if-linux.c @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -70,20 +71,15 @@ #include "common.h" #include "dev.h" #include "dhcp.h" +#include "if.h" #include "ipv4.h" #include "ipv6.h" -#include "net.h" -#include "platform.h" #define bpf_insn sock_filter #define BPF_SKIPTYPE #define BPF_ETHCOOK -ETH_HLEN #define BPF_WHOLEPACKET 0x0fffffff /* work around buggy LPF filters */ -#include "config.h" -#include "common.h" -#include "dhcp.h" -#include "ipv4.h" #include "bpf-filter.h" /* Broadcast address for IPoIB */ @@ -136,7 +132,7 @@ static const char *mproc = ; int -hardware_platform(char *str, size_t len) +if_machinearch(char *str, size_t len) { FILE *fp; char buf[256]; @@ -241,7 +237,7 @@ _open_link_socket(struct sockaddr_nl *nl) } int -open_link_socket(void) +if_openlinksocket(void) { struct sockaddr_nl snl; @@ -640,7 +636,7 @@ link_netlink(struct dhcpcd_ctx *ctx, struct nlmsghdr *nlm) } int -manage_link(struct dhcpcd_ctx *ctx) +if_managelink(struct dhcpcd_ctx *ctx) { return get_netlink(ctx, ctx->link_fd, MSG_DONTWAIT, &link_netlink); @@ -739,7 +735,7 @@ struct nlmr #ifdef INET int -ipv4_opensocket(struct interface *ifp, int protocol) +if_openrawsocket(struct interface *ifp, int protocol) { int s; union sockunion { @@ -806,7 +802,7 @@ eexit: } ssize_t -ipv4_sendrawpacket(const struct interface *ifp, int protocol, +if_sendrawpacket(const struct interface *ifp, int protocol, const void *data, size_t len) { const struct dhcp_state *state; @@ -838,7 +834,7 @@ ipv4_sendrawpacket(const struct interface *ifp, int protocol, } ssize_t -ipv4_getrawpacket(struct interface *ifp, int protocol, +if_readrawpacket(struct interface *ifp, int protocol, void *data, size_t len, int *partialcsum) { struct iovec iov = { @@ -1110,7 +1106,7 @@ if_route6(const struct rt6 *rt, int action) } int -in6_addr_flags(const char *ifname, const struct in6_addr *addr) +if_addrflags6(const char *ifname, const struct in6_addr *addr) { FILE *fp; char *p, ifaddress[33], address[33], name[IF_NAMESIZE + 1]; @@ -1180,7 +1176,7 @@ write_path(const char *path, const char *val) static const char *prefix = "/proc/sys/net/ipv6/conf"; void -restore_kernel_ra(struct dhcpcd_ctx *ctx) +if_rarestore(struct dhcpcd_ctx *ctx) { char path[256]; @@ -1200,7 +1196,7 @@ restore_kernel_ra(struct dhcpcd_ctx *ctx) } int -check_ipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) +if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) { int ra; size_t i; @@ -1255,18 +1251,4 @@ check_ipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) return ra; } - -int -ipv6_dadtransmits(const char *ifname) -{ - char path[256]; - int r; - - if (ifname == NULL) - ifname = "default"; - - snprintf(path, sizeof(path), "%s/%s/dad_transmits", prefix, ifname); - r = check_proc_int(path); - return r < 0 ? 0 : r; -} #endif diff --git a/if-options.c b/if-options.c index 3ff8cdcb..69fcf3b4 100644 --- a/if-options.c +++ b/if-options.c @@ -52,7 +52,6 @@ #include "dhcpcd-embedded.h" #include "if-options.h" #include "ipv4.h" -#include "platform.h" /* These options only make sense in the config file, so don't use any valid short options for them */ @@ -1861,7 +1860,6 @@ read_config(struct dhcpcd_ctx *ctx, #ifdef INET6 ifo->options |= DHCPCD_IPV6 | DHCPCD_IPV6RS | DHCPCD_IPV6RA_REQRDNSS; ifo->options |= DHCPCD_DHCP6; - ifo->dadtransmits = ipv6_dadtransmits(ifname); #endif ifo->timeout = DEFAULT_TIMEOUT; ifo->reboot = DEFAULT_REBOOT; diff --git a/if-options.h b/if-options.h index 9624fd2d..abab3f2e 100644 --- a/if-options.h +++ b/if-options.h @@ -166,9 +166,6 @@ struct if_options { uint16_t ia_type; struct if_ia *ia; size_t ia_len; -#ifdef INET6 - int dadtransmits; -#endif struct dhcp_opt *dhcp_override; size_t dhcp_override_len; diff --git a/if-pref.c b/if-pref.c index 47694457..ce0752ff 100644 --- a/if-pref.c +++ b/if-pref.c @@ -29,8 +29,8 @@ #include "config.h" #include "dhcp.h" +#include "dhcpcd.h" #include "if-pref.h" -#include "net.h" /* Interface comparer for working out ordering. */ static int diff --git a/net.c b/if.c similarity index 87% rename from net.c rename to if.c index 96f1b0bd..3ea370b7 100644 --- a/net.c +++ b/if.c @@ -70,76 +70,13 @@ #include "dev.h" #include "dhcp.h" #include "dhcp6.h" +#include "if.h" #include "if-options.h" #include "ipv4.h" #include "ipv6nd.h" -#include "net.h" - -char * -hwaddr_ntoa(const unsigned char *hwaddr, size_t hwlen, char *buf, size_t buflen) -{ - char *p; - size_t i; - - if (buf == NULL) { - return NULL; - } - - if (hwlen * 3 > buflen) { - errno = ENOBUFS; - return 0; - } - - p = buf; - for (i = 0; i < hwlen; i++) { - if (i > 0) - *p ++= ':'; - p += snprintf(p, 3, "%.2x", hwaddr[i]); - } - *p ++= '\0'; - return buf; -} - -size_t -hwaddr_aton(unsigned char *buffer, const char *addr) -{ - char c[3]; - const char *p = addr; - unsigned char *bp = buffer; - size_t len = 0; - - c[2] = '\0'; - while (*p) { - c[0] = *p++; - c[1] = *p++; - /* Ensure that digits are hex */ - if (isxdigit((unsigned char)c[0]) == 0 || - isxdigit((unsigned char)c[1]) == 0) - { - errno = EINVAL; - return 0; - } - /* We should have at least two entries 00:01 */ - if (len == 0 && *p == '\0') { - errno = EINVAL; - return 0; - } - /* Ensure that next data is EOL or a seperator with data */ - if (!(*p == '\0' || (*p == ':' && *(p + 1) != '\0'))) { - errno = EINVAL; - return 0; - } - if (*p) - p++; - if (bp) - *bp++ = (unsigned char)strtol(c, NULL, 16); - len++; - } - return len; -} void -free_interface(struct interface *ifp) +if_free(struct interface *ifp) { if (ifp == NULL) @@ -154,7 +91,7 @@ free_interface(struct interface *ifp) } int -carrier_status(struct interface *iface) +if_carrier(struct interface *iface) { int s, r; struct ifreq ifr; @@ -229,7 +166,7 @@ up_interface(struct interface *iface) } struct if_head * -discover_interfaces(struct dhcpcd_ctx *ctx, int argc, char * const *argv) +if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv) { struct ifaddrs *ifaddrs, *ifa; char *p; @@ -363,7 +300,7 @@ discover_interfaces(struct dhcpcd_ctx *ctx, int argc, char * const *argv) /* Bring the interface up if not already */ if (!(ifp->flags & IFF_UP) #ifdef SIOCGIFMEDIA - && carrier_status(ifp) != LINK_UNKNOWN + && if_carrier(ifp) != LINK_UNKNOWN #endif ) { @@ -378,7 +315,7 @@ discover_interfaces(struct dhcpcd_ctx *ctx, int argc, char * const *argv) /* Don't allow loopback unless explicit */ if (ifp->flags & IFF_LOOPBACK) { if (argc == 0 && ctx->ifac == 0) { - free_interface(ifp); + if_free(ifp); continue; } } else if (ifa->ifa_addr != NULL) { @@ -396,7 +333,7 @@ discover_interfaces(struct dhcpcd_ctx *ctx, int argc, char * const *argv) if (ioctl(s_link, SIOCGLIFADDR, &iflr) == -1 || !(iflr.flags & IFLR_ACTIVE)) { - free_interface(ifp); + if_free(ifp); continue; } #endif @@ -444,7 +381,7 @@ discover_interfaces(struct dhcpcd_ctx *ctx, int argc, char * const *argv) ifp->family != ARPHRD_ETHER) { if (argc == 0 && ctx->ifac == 0) { - free_interface(ifp); + if_free(ifp); continue; } switch (ifp->family) { @@ -465,16 +402,16 @@ discover_interfaces(struct dhcpcd_ctx *ctx, int argc, char * const *argv) /* Handle any platform init for the interface */ if (if_init(ifp) == -1) { syslog(LOG_ERR, "%s: if_init: %m", p); - free_interface(ifp); + if_free(ifp); continue; } /* Ensure that the MTU is big enough for DHCP */ - if (get_mtu(ifp->name) < MTU_MIN && - set_mtu(ifp->name, MTU_MIN) == -1) + if (if_getmtu(ifp->name) < MTU_MIN && + if_setmtu(ifp->name, MTU_MIN) == -1) { syslog(LOG_ERR, "%s: set_mtu: %m", p); - free_interface(ifp); + if_free(ifp); continue; } @@ -488,7 +425,7 @@ discover_interfaces(struct dhcpcd_ctx *ctx, int argc, char * const *argv) /* We reserve the 100 range for virtual interfaces, if and when * we can work them out. */ ifp->metric = 200 + ifp->index; - if (getifssid(ifp->name, ifp->ssid) != -1) { + if (if_getssid(ifp->name, ifp->ssid) != -1) { ifp->wireless = 1; ifp->metric += 100; } @@ -522,7 +459,7 @@ discover_interfaces(struct dhcpcd_ctx *ctx, int argc, char * const *argv) case AF_INET6: sin6 = (const struct sockaddr_in6 *) (void *)ifa->ifa_addr; - ifa_flags = in6_addr_flags(ifa->ifa_name, + ifa_flags = if_addrflags6(ifa->ifa_name, &sin6->sin6_addr); if (ifa_flags != -1) ipv6_handleifa(ctx, RTM_NEWADDR, ifs, @@ -546,7 +483,7 @@ discover_interfaces(struct dhcpcd_ctx *ctx, int argc, char * const *argv) } int -do_mtu(const char *ifname, short int mtu) +if_domtu(const char *ifname, short int mtu) { int s, r; struct ifreq ifr; diff --git a/net.h b/if.h similarity index 59% rename from net.h rename to if.h index 087e28d7..6c777233 100644 --- a/net.h +++ b/if.h @@ -32,11 +32,10 @@ #include #include -#include #include "config.h" -#include "dhcp.h" #include "dhcpcd.h" +#include "ipv4.h" #include "ipv6.h" /* Some systems have route metrics */ @@ -81,21 +80,60 @@ # define IN_LINKLOCAL(addr) ((addr & IN_CLASSB_NET) == LINKLOCAL_ADDR) #endif -char *hwaddr_ntoa(const unsigned char *, size_t, char *, size_t); -size_t hwaddr_aton(unsigned char *, const char *); - -int getifssid(const char *, char *); -int if_vimaster(const char *); -struct if_head *discover_interfaces(struct dhcpcd_ctx *, int, char * const *); -void free_interface(struct interface *); -int do_mtu(const char *, short int); -#define get_mtu(iface) do_mtu(iface, 0) -#define set_mtu(iface, mtu) do_mtu(iface, mtu) +struct if_head *if_discover(struct dhcpcd_ctx *, int, char * const *); +void if_free(struct interface *); +int if_domtu(const char *, short int); +#define if_getmtu(iface) if_domtu(iface, 0) +#define if_setmtu(iface, mtu) if_domtu(iface, mtu) +int if_carrier(struct interface *); +/* The below functions are provided by if-KERNEL.c */ int if_conf(struct interface *); int if_init(struct interface *); +int if_getssid(const char *, char *); +int if_vimaster(const char *); +int if_openlinksocket(void); +int if_managelink(struct dhcpcd_ctx *); + +#ifdef INET +int if_openrawsocket(struct interface *, int); +ssize_t if_sendrawpacket(const struct interface *, + int, const void *, size_t); +ssize_t if_readrawpacket(struct interface *, int, void *, size_t, int *); + +int if_address(const struct interface *, + const struct in_addr *, const struct in_addr *, + const struct in_addr *, int); +#define if_addaddress(iface, addr, net, brd) \ + if_address(iface, addr, net, brd, 1) +#define if_setaddress(iface, addr, net, brd) \ + if_address(iface, addr, net, brd, 2) +#define if_deladdress(iface, addr, net) \ + if_address(iface, addr, net, NULL, -1) + +int if_route(const struct rt *rt, int); +#define if_addroute(rt) if_route(rt, 1) +#define if_chgroute(rt) if_route(rt, 0) +#define if_delroute(rt) if_route(rt, -1) +#endif + +#ifdef INET6 +int if_checkipv6(struct dhcpcd_ctx *ctx, const char *, int); +void if_rarestore(struct dhcpcd_ctx *); + +int if_address6(const struct ipv6_addr *, int); +#define if_addaddress6(a) if_address6(a, 1) +#define if_deladdress6(a) if_address6(a, -1) +int if_addrflags6(const char *, const struct in6_addr *); + +int if_route6(const struct rt6 *rt, int); +#define if_addroute6(rt) if_route6(rt, 1) +#define if_chgroute6(rt) if_route6(rt, 0) +#define if_delroute6(rt) if_route6(rt, -1) +#else +#define if_checkipv6(a, b, c) (-1) +#define if_rarestore(a) +#endif -int open_link_socket(void); -int manage_link(struct dhcpcd_ctx *); -int carrier_status(struct interface *); +int if_machinearch(char *, size_t); #endif diff --git a/ipv4.c b/ipv4.c index 317cfff9..7e8f5eaa 100644 --- a/ipv4.c +++ b/ipv4.c @@ -49,10 +49,10 @@ #include "common.h" #include "dhcpcd.h" #include "dhcp.h" +#include "if.h" #include "if-options.h" #include "if-pref.h" #include "ipv4.h" -#include "net.h" #include "script.h" #define IPV4_LOOPBACK_ROUTE @@ -259,11 +259,11 @@ nc_route(int add, struct rt *ort, struct rt *nrt) * prefer the interface. * This also has the nice side effect of flushing ARP entries so * we don't have to do that manually. */ - if (ipv4_deleteroute(ort) == -1 && errno != ESRCH) - syslog(LOG_ERR, "%s: ipv4_deleteroute: %m", ort->iface->name); - if (!ipv4_addroute(nrt)) + if (if_delroute(ort) == -1 && errno != ESRCH) + syslog(LOG_ERR, "%s: ipv4_delroute: %m", ort->iface->name); + if (!if_addroute(nrt)) return 0; - syslog(LOG_ERR, "%s: ipv4_addroute: %m", nrt->iface->name); + syslog(LOG_ERR, "%s: if_addroute: %m", nrt->iface->name); return -1; } @@ -273,9 +273,9 @@ d_route(struct rt *rt) int retval; desc_route("deleting", rt); - retval = ipv4_deleteroute(rt); + retval = if_delroute(rt); if (retval != 0 && errno != ENOENT && errno != ESRCH) - syslog(LOG_ERR,"%s: ipv4_deleteroute: %m", rt->iface->name); + syslog(LOG_ERR,"%s: if_delroute: %m", rt->iface->name); return retval; } @@ -564,7 +564,7 @@ delete_address1(struct interface *ifp, syslog(LOG_DEBUG, "%s: deleting IP address %s/%d", ifp->name, inet_ntoa(*addr), inet_ntocidr(*net)); - r = ipv4_deleteaddress(ifp, addr, net); + r = if_deladdress(ifp, addr, net); if (r == -1 && errno != EADDRNOTAVAIL && errno != ENXIO && errno != ENODEV) syslog(LOG_ERR, "%s: %s: %m", ifp->name, __func__); @@ -666,13 +666,13 @@ ipv4_applyaddr(void *arg) ifp->name, inet_ntoa(lease->addr), inet_ntocidr(lease->net)); if (ifo->options & DHCPCD_NOALIAS) - r = ipv4_setaddress(ifp, + r = if_setaddress(ifp, &lease->addr, &lease->net, &lease->brd); else - r = ipv4_addaddress(ifp, + r = if_addaddress(ifp, &lease->addr, &lease->net, &lease->brd); if (r == -1 && errno != EEXIST) { - syslog(LOG_ERR, "%s: ipv4_addaddress: %m", __func__); + syslog(LOG_ERR, "%s: if_addaddress: %m", __func__); return; } istate = ipv4_getstate(ifp); @@ -698,7 +698,7 @@ ipv4_applyaddr(void *arg) rt->iface = ifp; rt->metric = 0; if (!find_route(ifp->ctx->ipv4_routes, rt, NULL)) - ipv4_deleteroute(rt); + if_delroute(rt); free(rt); } diff --git a/ipv4.h b/ipv4.h index c048cb6d..12f47c68 100644 --- a/ipv4.h +++ b/ipv4.h @@ -74,27 +74,8 @@ struct ipv4_addr *ipv4_findaddr(struct interface *, void ipv4_handleifa(struct dhcpcd_ctx *, int, struct if_head *, const char *, const struct in_addr *, const struct in_addr *, const struct in_addr *); -int if_address(const struct interface *, - const struct in_addr *, const struct in_addr *, - const struct in_addr *, int); -#define ipv4_addaddress(iface, addr, net, brd) \ - if_address(iface, addr, net, brd, 1) -#define ipv4_setaddress(iface, addr, net, brd) \ - if_address(iface, addr, net, brd, 2) -#define ipv4_deleteaddress(iface, addr, net) \ - if_address(iface, addr, net, NULL, -1) - -int if_route(const struct rt *rt, int); -#define ipv4_addroute(rt) if_route(rt, 1) -#define ipv4_changeroute(rt) if_route(rt, 0) -#define ipv4_deleteroute(rt) if_route(rt, -1) -#define del_src_route(rt) i_route(rt, -2); void ipv4_freeroutes(struct rt_head *); -int ipv4_opensocket(struct interface *, int); -ssize_t ipv4_sendrawpacket(const struct interface *, - int, const void *, size_t); -ssize_t ipv4_getrawpacket(struct interface *, int, void *, size_t, int *); void ipv4_free(struct interface *); void ipv4_ctxfree(struct dhcpcd_ctx *); #else diff --git a/ipv4ll.c b/ipv4ll.c index 83d96cb9..645f0aa3 100644 --- a/ipv4ll.c +++ b/ipv4ll.c @@ -37,9 +37,9 @@ #include "common.h" #include "dhcp.h" #include "eloop.h" +#include "if.h" #include "if-options.h" #include "ipv4ll.h" -#include "net.h" static struct dhcp_message * ipv4ll_make_lease(uint32_t addr) diff --git a/ipv6.c b/ipv6.c index 9002d0c3..0c5f9b35 100644 --- a/ipv6.c +++ b/ipv6.c @@ -67,6 +67,7 @@ #include "dhcpcd.h" #include "dhcp6.h" #include "eloop.h" +#include "if.h" #include "ipv6.h" #include "ipv6nd.h" @@ -406,8 +407,8 @@ ipv6_addaddr(struct ipv6_addr *ap) if (!(ap->flags & IPV6_AF_DADCOMPLETED) && ipv6_findaddr(ap->iface, &ap->addr)) ap->flags |= IPV6_AF_DADCOMPLETED; - if (add_address6(ap) == -1) { - syslog(LOG_ERR, "add_address6 %m"); + if (if_addaddress6(ap) == -1) { + syslog(LOG_ERR, "if_addaddress6: %m"); return -1; } ap->flags &= ~IPV6_AF_NEW; @@ -416,7 +417,7 @@ ipv6_addaddr(struct ipv6_addr *ap) ap->flags |= IPV6_AF_DELEGATED; if (ap->iface->options->options & DHCPCD_IPV6RA_OWN && ipv6_removesubnet(ap->iface, ap) == -1) - syslog(LOG_ERR,"ipv6_removesubnet %m"); + syslog(LOG_ERR,"ipv6_removesubnet: %m"); if (ap->prefix_pltime == ND6_INFINITE_LIFETIME && ap->prefix_vltime == ND6_INFINITE_LIFETIME) syslog(LOG_DEBUG, @@ -465,9 +466,9 @@ ipv6_addaddrs(struct ipv6_addrhead *addrs) ap->iface->name, ap->saddr); i++; if (!IN6_IS_ADDR_UNSPECIFIED(&ap->addr) && - del_address6(ap) == -1 && + if_deladdress6(ap) == -1 && errno != EADDRNOTAVAIL && errno != ENXIO) - syslog(LOG_ERR, "del_address6 %m"); + syslog(LOG_ERR, "if_deladdress6: %m"); } eloop_q_timeout_delete(ap->iface->ctx->eloop, 0, NULL, ap); @@ -506,9 +507,9 @@ ipv6_freedrop_addrs(struct ipv6_addrhead *addrs, int drop, { syslog(LOG_INFO, "%s: deleting address %s", ap->iface->name, ap->saddr); - if (del_address6(ap) == -1 && + if (if_deladdress6(ap) == -1 && errno != EADDRNOTAVAIL && errno != ENXIO) - syslog(LOG_ERR, "del_address6 %m"); + syslog(LOG_ERR, "if_deladdress6: :%m"); } free(ap); } @@ -820,11 +821,11 @@ nc_route(int add, struct rt6 *ort, struct rt6 *nrt) desc_route(add ? "adding" : "changing", nrt); /* We delete and add the route so that we can change metric and * prefer the interface. */ - if (del_route6(ort) == -1 && errno != ESRCH) - syslog(LOG_ERR, "%s: del_route6: %m", ort->iface->name); - if (add_route6(nrt) == 0) + if (if_delroute6(ort) == -1 && errno != ESRCH) + syslog(LOG_ERR, "%s: if_delroute6: %m", ort->iface->name); + if (if_addroute6(nrt) == 0) return 0; - syslog(LOG_ERR, "%s: add_route6: %m", nrt->iface->name); + syslog(LOG_ERR, "%s: if_addroute6: %m", nrt->iface->name); return -1; } @@ -834,9 +835,9 @@ d_route(struct rt6 *rt) int retval; desc_route("deleting", rt); - retval = del_route6(rt); + retval = if_delroute6(rt); if (retval != 0 && errno != ENOENT && errno != ESRCH) - syslog(LOG_ERR,"%s: del_route6: %m", rt->iface->name); + syslog(LOG_ERR,"%s: if_delroute6: %m", rt->iface->name); return retval; } @@ -938,7 +939,7 @@ ipv6_removesubnet(struct interface *ifp, struct ipv6_addr *addr) if (!find_route6(ifp->ctx->ipv6->routes, rt)) #endif { - r = del_route6(rt); + r = if_delroute6(rt); if (r == -1 && errno == ESRCH) r = 0; } diff --git a/ipv6.h b/ipv6.h index e2d4183b..3c234557 100644 --- a/ipv6.h +++ b/ipv6.h @@ -186,17 +186,6 @@ void ipv6_ctxfree(struct dhcpcd_ctx *); int ipv6_removesubnet(struct interface *, struct ipv6_addr *); void ipv6_buildroutes(struct dhcpcd_ctx *); -int if_address6(const struct ipv6_addr *, int); -#define add_address6(a) if_address6(a, 1) -#define del_address6(a) if_address6(a, -1) -int in6_addr_flags(const char *, const struct in6_addr *); - -int if_route6(const struct rt6 *rt, int); -#define add_route6(rt) if_route6(rt, 1) -#define change_route6(rt) if_route6(rt, 0) -#define del_route6(rt) if_route6(rt, -1) -#define del_src_route6(rt) if_route6(rt, -2); - #else #define ipv6_init(a) NULL #define ipv6_free_ll_callbacks(a) diff --git a/platform.h b/platform.h deleted file mode 100644 index 8011b1be..00000000 --- a/platform.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * dhcpcd - DHCP client daemon - * Copyright (c) 2006-2014 Roy Marples - * All rights reserved - - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef PLATFORM_H -#define PLATFORM_H - -int hardware_platform(char *, size_t); -#ifdef INET6 -int check_ipv6(struct dhcpcd_ctx *ctx, const char *, int); -int ipv6_dadtransmits(const char *); -void restore_kernel_ra(struct dhcpcd_ctx *); -#else -#define check_ipv6(a, b,c ) -1 -#define restore_kernel_ra(a) -#endif - -#endif diff --git a/script.c b/script.c index cbcf68c7..d5afb65e 100644 --- a/script.c +++ b/script.c @@ -46,10 +46,10 @@ #include "common.h" #include "dhcp.h" #include "dhcp6.h" +#include "if.h" #include "if-options.h" #include "if-pref.h" #include "ipv6nd.h" -#include "net.h" #include "script.h" #ifdef HAVE_SPAWN_H @@ -303,7 +303,7 @@ make_env(const struct interface *ifp, const char *reason, char ***argv) EMALLOC(6, e); snprintf(env[6], e, "ifflags=%u", ifp->flags); EMALLOC(7, e); - snprintf(env[7], e, "ifmtu=%d", get_mtu(ifp->name)); + snprintf(env[7], e, "ifmtu=%d", if_getmtu(ifp->name)); l = e = strlen("interface_order="); TAILQ_FOREACH(ifp2, ifp->ctx->ifaces, next) { e += strlen(ifp2->name) + 1; diff --git a/script.h b/script.h index 4f9a085a..e1862e83 100644 --- a/script.h +++ b/script.h @@ -28,8 +28,6 @@ #ifndef SCRIPT_H #define SCRIPT_H -#include "net.h" - void if_printoptions(void); int send_interface(int, const struct interface *); int script_runreason(const struct interface *, const char *);