summaryrefslogtreecommitdiffstats
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorjlemon <jlemon@FreeBSD.org>2001-10-17 18:58:14 +0000
committerjlemon <jlemon@FreeBSD.org>2001-10-17 18:58:14 +0000
commitae7cec463fe49996e919eb79d6b94c2ececcb688 (patch)
treeafda1d073645086135f608da82f73cb11cb921da /sys/net/if.c
parenta0ff75973c6961105f5efc4c48f67476ffc51e32 (diff)
downloadFreeBSD-src-ae7cec463fe49996e919eb79d6b94c2ececcb688.zip
FreeBSD-src-ae7cec463fe49996e919eb79d6b94c2ececcb688.tar.gz
Cleanup ifunit(), so it uses the dev_named() function to map an interface
name into a device.
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c40
1 files changed, 11 insertions, 29 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 1e3dfac..2728141 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1084,46 +1084,28 @@ struct ifnet *
ifunit(const char *name)
{
char namebuf[IFNAMSIZ + 1];
- const char *cp;
struct ifnet *ifp;
- int unit;
- unsigned len, m;
- char c;
+ dev_t dev;
- len = strlen(name);
- if (len < 2 || len > IFNAMSIZ)
- return NULL;
- cp = name + len - 1;
- c = *cp;
- if (c < '0' || c > '9')
- return NULL; /* trailing garbage */
- unit = 0;
- m = 1;
- do {
- if (cp == name)
- return NULL; /* no interface name */
- unit += (c - '0') * m;
- if (unit > 1000000)
- return NULL; /* number is unreasonable */
- m *= 10;
- c = *--cp;
- } while (c >= '0' && c <= '9');
- len = cp - name + 1;
- bcopy(name, namebuf, len);
- namebuf[len] = '\0';
/*
* Now search all the interfaces for this name/number
*/
+
+ /*
+ * XXX
+ * Devices should really be known as /dev/fooN, not /dev/net/fooN.
+ */
+ snprintf(namebuf, IFNAMSIZ, "%s/%s", net_cdevsw.d_name, name);
TAILQ_FOREACH(ifp, &ifnet, if_link) {
- if (strcmp(ifp->if_name, namebuf))
- continue;
- if (unit == ifp->if_unit)
+ dev = ifdev_byindex(ifp->if_index);
+ if (strcmp(devtoname(dev), namebuf) == 0)
+ break;
+ if (dev_named(dev, name))
break;
}
return (ifp);
}
-
/*
* Map interface name in a sockaddr_dl to
* interface structure pointer.
OpenPOWER on IntegriCloud