summaryrefslogtreecommitdiffstats
path: root/if.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2014-09-18 00:35:03 +0000
committerRoy Marples <roy@marples.name>2014-09-18 00:35:03 +0000
commit08af3cf1ed0f33db7c40bcbd76f3283b377435f1 (patch)
tree510762d3276ecd5651bf702073db2e5bfad563c2 /if.c
parent00601c4ae92fe16890b142311e05889e29e0ec45 (diff)
downloaddhcpcd-08af3cf1ed0f33db7c40bcbd76f3283b377435f1.tar.xz
Remove all instances of if_indextoname and add a replacement
if_findindex as we should already have the interface at this point.
Diffstat (limited to 'if.c')
-rw-r--r--if.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/if.c b/if.c
index 7057419a..59d2010d 100644
--- a/if.c
+++ b/if.c
@@ -479,7 +479,7 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
}
struct interface *
-if_find(struct dhcpcd_ctx *ctx, const char *ifname)
+if_findindexname(struct dhcpcd_ctx *ctx, unsigned int idx, const char *name)
{
struct interface *ifp;
@@ -487,13 +487,28 @@ if_find(struct dhcpcd_ctx *ctx, const char *ifname)
TAILQ_FOREACH(ifp, ctx->ifaces, next) {
if ((ifp->options == NULL ||
!(ifp->options->options & DHCPCD_PFXDLGONLY)) &&
- strcmp(ifp->name, ifname) == 0)
+ ((name && strcmp(ifp->name, name) == 0) ||
+ (!name && ifp->index == idx)))
return ifp;
}
}
return NULL;
}
+struct interface *
+if_find(struct dhcpcd_ctx *ctx, const char *name)
+{
+
+ return if_findindexname(ctx, 0, name);
+}
+
+struct interface *
+if_findindex(struct dhcpcd_ctx *ctx, unsigned int idx)
+{
+
+ return if_findindexname(ctx, idx, NULL);
+}
+
int
if_domtu(const char *ifname, short int mtu)
{