From 1048fa73010ca9dfb0cfba83b166fcfa2ef994be Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 19 Jun 1999 18:42:31 +0000 Subject: 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 --- sys/net/if_tun.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'sys/net/if_tun.c') 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", -- cgit v1.1