if (strcmp(sla->ifname, ia->sla[j].ifname) == 0)
break;
if (j >= i &&
- if_find(ifp->ctx, sla->ifname) == NULL)
+ if_find(ifp->ctx->ifaces, sla->ifname) == NULL)
{
logger(ifp->ctx, LOG_INFO,
"%s: loading for delegation", sla->ifname);
{
struct interface *ifp;
- ifp = if_find(ctx, ifname);
+ ifp = if_find(ctx->ifaces, ifname);
if (ifp == NULL || !(ifp->options->options & DHCPCD_LINK))
return;
ctx = arg;
if (action == -1) {
- ifp = if_find(ctx, ifname);
+ ifp = if_find(ctx->ifaces, ifname);
if (ifp == NULL) {
errno = ESRCH;
return -1;
continue;
i = 0;
/* Check if we already have the interface */
- iff = if_find(ctx, ifp->name);
+ iff = if_find(ctx->ifaces, ifp->name);
if (iff) {
logger(ctx, LOG_DEBUG, "%s: interface updated", iff->name);
/* The flags and hwaddr could have changed */
struct interface *ifp;
char buf[sizeof(ifp->hwaddr) * 3];
- ifp = if_find(ctx, ifname);
+ ifp = if_find(ctx->ifaces, ifname);
if (ifp == NULL)
return;
while ((ifp = TAILQ_FIRST(ifs))) {
TAILQ_REMOVE(ifs, ifp, next);
- ifn = if_find(ctx, ifp->name);
+ ifn = if_find(ctx->ifaces, ifp->name);
if (ifn) {
if (action)
if_reboot(ifn, argc, argv);
return 0;
}
for (oi = optind; oi < argc; oi++) {
- if ((ifp = if_find(ctx, argv[oi])) == NULL)
+ if ((ifp = if_find(ctx->ifaces, argv[oi])) == NULL)
continue;
if (do_release) {
ifp->options->options |= DHCPCD_RELEASE;
goto exit_failure;
}
for (i = 0; i < ctx.ifc; i++) {
- if (if_find(&ctx, ctx.ifv[i]) == NULL)
+ if (if_find(ctx.ifaces, ctx.ifv[i]) == NULL)
logger(&ctx, LOG_ERR,
"%s: interface not found or invalid",
ctx.ifv[i]);
char ifname[IF_NAMESIZE];
memcpy(ifname, sdl->sdl_data, sdl->sdl_nlen);
ifname[sdl->sdl_nlen] = '\0';
- return if_find(ctx, ifname);
+ return if_find(ctx->ifaces, ifname);
}
return NULL;
}
COPYOUT(rt->gate, rti_info[RTAX_GATEWAY]);
if (rtm->rtm_index)
- rt->iface = if_findindex(ctx, rtm->rtm_index);
+ rt->iface = if_findindex(ctx->ifaces, rtm->rtm_index);
else if (rtm->rtm_addrs & RTA_IFP) {
struct sockaddr_dl *sdl;
COPYOUT6(rt->gate, rti_info[RTAX_GATEWAY]);
if (rtm->rtm_index)
- rt->iface = if_findindex(ctx, rtm->rtm_index);
+ rt->iface = if_findindex(ctx->ifaces, rtm->rtm_index);
else if (rtm->rtm_addrs & RTA_IFP) {
struct sockaddr_dl *sdl;
#endif
case RTM_IFINFO:
ifm = (struct if_msghdr *)(void *)p;
- if ((ifp = if_findindex(ctx, ifm->ifm_index)) == NULL)
+ ifp = if_findindex(ctx->ifaces, ifm->ifm_index);
+ if (ifp == NULL)
break;
switch (ifm->ifm_data.ifi_link_state) {
case LINK_STATE_DOWN:
case RTM_DELADDR: /* FALLTHROUGH */
case RTM_NEWADDR:
ifam = (struct ifa_msghdr *)(void *)p;
- if ((ifp = if_findindex(ctx, ifam->ifam_index)) == NULL)
+ ifp = if_findindex(ctx->ifaces, ifam->ifam_index);
+ if (ifp == NULL)
break;
cp = (char *)(void *)(ifam + 1);
get_addrs(ifam->ifam_addrs, cp, rti_info);
sizeof(prefsrc.s_addr));
break;
case RTA_OIF:
- rt->iface = if_findindex(ctx,
+ rt->iface = if_findindex(ctx->ifaces,
*(unsigned int *)RTA_DATA(rta));
break;
case RTA_PRIORITY:
sizeof(rt->gate.s6_addr));
break;
case RTA_OIF:
- rt->iface = if_findindex(ctx,
+ rt->iface = if_findindex(ctx->ifaces,
*(unsigned int *)RTA_DATA(rta));
break;
case RTA_PRIORITY:
return -1;
}
ifa = NLMSG_DATA(nlm);
- if ((ifp = if_findindex(ctx, ifa->ifa_index)) == NULL) {
+ if ((ifp = if_findindex(ctx->ifaces, ifa->ifa_index)) == NULL) {
/* We don't know about the interface the address is for
* so it's not really an error */
return 1;
return 0;
/* Check for a new interface */
- ifp = if_find(ctx, ifn);
- if (ifp == NULL) {
+ if ((ifp = if_find(ctx->ifaces, ifn)) == NULL) {
/* If are listening to a dev manager, let that announce
* the interface rather than the kernel. */
if (dev_listening(ctx) < 1)
}
static struct interface *
-if_findindexname(struct dhcpcd_ctx *ctx, unsigned int idx, const char *name)
+if_findindexname(struct if_head *ifaces, unsigned int idx, const char *name)
{
struct interface *ifp;
- if (ctx != NULL && ctx->ifaces != NULL) {
- TAILQ_FOREACH(ifp, ctx->ifaces, next) {
+ if (ifaces != NULL) {
+ TAILQ_FOREACH(ifp, ifaces, next) {
if ((ifp->options == NULL ||
!(ifp->options->options & DHCPCD_PFXDLGONLY)) &&
((name && strcmp(ifp->name, name) == 0) ||
}
struct interface *
-if_find(struct dhcpcd_ctx *ctx, const char *name)
+if_find(struct if_head *ifaces, const char *name)
{
- return if_findindexname(ctx, 0, name);
+ return if_findindexname(ifaces, 0, name);
}
struct interface *
-if_findindex(struct dhcpcd_ctx *ctx, unsigned int idx)
+if_findindex(struct if_head *ifaces, unsigned int idx)
{
- return if_findindexname(ctx, idx, NULL);
+ return if_findindexname(ifaces, idx, NULL);
}
int
int if_setflag(struct interface *ifp, short flag);
#define if_up(ifp) if_setflag((ifp), (IFF_UP | IFF_RUNNING))
struct if_head *if_discover(struct dhcpcd_ctx *, int, char * const *);
-struct interface *if_find(struct dhcpcd_ctx *, const char *);
-struct interface *if_findindex(struct dhcpcd_ctx *, unsigned int);
+struct interface *if_find(struct if_head *, const char *);
+struct interface *if_findindex(struct if_head *, unsigned int);
void if_sortinterfaces(struct dhcpcd_ctx *);
void if_free(struct interface *);
int if_domtu(const char *, short int);