summaryrefslogtreecommitdiffstats
path: root/sys/net/if_tun.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1999-06-19 18:42:31 +0000
committerphk <phk@FreeBSD.org>1999-06-19 18:42:31 +0000
commit1048fa73010ca9dfb0cfba83b166fcfa2ef994be (patch)
tree32836c1e0c0e6d5d181e3dd1260ec5097dfa0a32 /sys/net/if_tun.c
parentd99f3d7a9346a2099e09e6afbacee7bffacdbdaa (diff)
downloadFreeBSD-src-1048fa73010ca9dfb0cfba83b166fcfa2ef994be.zip
FreeBSD-src-1048fa73010ca9dfb0cfba83b166fcfa2ef994be.tar.gz
Add a new interface ioctl, to return "aux status".
This is inteded for to allow ifconfig to print various unstructured information from an interface. The data is returned from the kernel in ASCII form, see the comment in if.h for some technicalities. Canonical cut&paste example to be found in if_tun.c Initial use: Now tun* interfaces tell the PID of the process which opened them. Future uses could be (volounteers welcome!): Have ppp/slip interfaces tell which tty they use. Make sync interfaces return their media state: red/yellow/blue alarm, timeslot assignment and so on. Make ethernets warn about missing heartbeats and/or cables
Diffstat (limited to 'sys/net/if_tun.c')
-rw-r--r--sys/net/if_tun.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index caff2d4..8d16b7d 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -173,6 +173,7 @@ tunopen(dev, flag, mode, p)
tp = &tunctl[unit];
if (tp->tun_flags & TUN_OPEN)
return EBUSY;
+ tp->tun_pid = p->p_pid;
ifp = &tp->tun_if;
tp->tun_flags |= TUN_OPEN;
TUNDEBUG("%s%d: open\n", ifp->if_name, ifp->if_unit);
@@ -196,6 +197,7 @@ tunclose(dev, foo, bar, p)
struct mbuf *m;
tp->tun_flags &= ~TUN_OPEN;
+ tp->tun_pid = 0;
/*
* junk all pending output
@@ -276,11 +278,19 @@ tunifioctl(ifp, cmd, data)
u_long cmd;
caddr_t data;
{
- register struct ifreq *ifr = (struct ifreq *)data;
+ struct ifreq *ifr = (struct ifreq *)data;
+ struct tun_softc *tp = &tunctl[ifp->if_unit];
+ struct ifstat *ifs;
int error = 0, s;
s = splimp();
switch(cmd) {
+ case SIOCGIFSTATUS:
+ ifs = (struct ifstat *)data;
+ if (tp->tun_pid)
+ sprintf(ifs->ascii + strlen(ifs->ascii),
+ "\tOpened by PID %d\n", tp->tun_pid);
+ return(0);
case SIOCSIFADDR:
tuninit(ifp->if_unit);
TUNDEBUG("%s%d: address set\n",
OpenPOWER on IntegriCloud