summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sbin/ifconfig/ifconfig.c7
-rw-r--r--sys/net/if.c7
-rw-r--r--sys/net/if.h16
-rw-r--r--sys/net/if_tun.c12
-rw-r--r--sys/net/if_tunvar.h3
-rw-r--r--sys/sys/sockio.h4
6 files changed, 43 insertions, 6 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 57ffbdc..f2ab7de 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
#endif
static const char rcsid[] =
- "$Id: ifconfig.c,v 1.39 1999/03/15 01:22:01 wpaul Exp $";
+ "$Id: ifconfig.c,v 1.40 1999/06/06 09:17:30 phk Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -720,6 +720,7 @@ status(afp, addrcount, sdl, ifm, ifam)
const struct afswtch *p = NULL;
struct rt_addrinfo info;
int allfamilies, s;
+ struct ifstat ifs;
if (afp == NULL) {
allfamilies = 1;
@@ -757,6 +758,10 @@ status(afp, addrcount, sdl, ifm, ifam)
printf(" mtu %d", mtu);
putchar('\n');
+ strncpy(ifs.ifs_name, name, sizeof ifs.ifs_name);
+ if (ioctl(s, SIOCGIFSTATUS, &ifs) == 0)
+ printf("%s", ifs.ascii);
+
while (addrcount > 0) {
info.rti_addrs = ifam->ifam_addrs;
diff --git a/sys/net/if.c b/sys/net/if.c
index d51afcd..c6f5c5e 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if.c 8.3 (Berkeley) 1/4/94
- * $Id: if.c,v 1.71 1999/06/06 09:17:49 phk Exp $
+ * $Id: if.c,v 1.72 1999/06/06 09:28:01 phk Exp $
*/
#include "opt_compat.h"
@@ -604,6 +604,7 @@ ifioctl(so, cmd, data, p)
{
register struct ifnet *ifp;
register struct ifreq *ifr;
+ struct ifstat *ifs;
int error;
switch (cmd) {
@@ -731,6 +732,10 @@ ifioctl(so, cmd, data, p)
getmicrotime(&ifp->if_lastchange);
return error;
+ case SIOCGIFSTATUS:
+ ifs = (struct ifstat *)data;
+ ifs->ascii[0] = '\0';
+
case SIOCGIFMEDIA:
case SIOCGIFGENERIC:
if (ifp->if_ioctl == 0)
diff --git a/sys/net/if.h b/sys/net/if.h
index a639bc2..13048b0 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if.h 8.1 (Berkeley) 6/10/93
- * $Id: if.h,v 1.52 1999/05/08 07:00:04 phk Exp $
+ * $Id: if.h,v 1.53 1999/06/06 09:17:51 phk Exp $
*/
#ifndef _NET_IF_H_
@@ -197,6 +197,20 @@ struct ifmediareq {
int ifm_count; /* # entries in ifm_ulist array */
int *ifm_ulist; /* media words */
};
+
+/*
+ * Structure used to retrieve aux status data from interfaces.
+ * kernel suppliers to this interface should respect the formatting
+ * needed by ifconfig(8): each line starts with a TAB and ends with
+ * a newline. The canonical example to copy&past is in if_tun.c
+ */
+
+#define IFSTATMAX 800 /* 10 lines of text */
+struct ifstat {
+ char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */
+ char ascii[IFSTATMAX+1];
+};
+
/*
* Structure used in SIOCGIFCONF request.
* Used to retrieve interface configuration
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",
diff --git a/sys/net/if_tunvar.h b/sys/net/if_tunvar.h
index 496c4fb..8a0e9b5 100644
--- a/sys/net/if_tunvar.h
+++ b/sys/net/if_tunvar.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: if_tunvar.h,v 1.3 1998/11/11 10:56:05 truckman Exp $
+ * $Id: if_tunvar.h,v 1.4 1999/03/24 21:20:12 des Exp $
*/
#ifndef _NET_IF_TUNVAR_H_
@@ -42,6 +42,7 @@ struct tun_softc {
#define TUN_READY (TUN_OPEN | TUN_INITED)
+ pid_t tun_pid; /* PID of process to open */
struct ifnet tun_if; /* the interface */
struct sigio *tun_sigio; /* information for async I/O */
struct selinfo tun_rsel; /* read select */
diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h
index 24ce7f6..36f0c2e 100644
--- a/sys/sys/sockio.h
+++ b/sys/sys/sockio.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)sockio.h 8.1 (Berkeley) 3/28/94
- * $Id: sockio.h,v 1.10 1997/05/03 21:05:03 peter Exp $
+ * $Id: sockio.h,v 1.11 1997/10/07 07:39:40 joerg Exp $
*/
#ifndef _SYS_SOCKIO_H_
@@ -85,4 +85,6 @@
#define SIOCSIFGENERIC _IOW('i', 57, struct ifreq) /* generic IF set op */
#define SIOCGIFGENERIC _IOWR('i', 58, struct ifreq) /* generic IF get op */
+#define SIOCGIFSTATUS _IOWR('i', 59, struct ifstat) /* get IF status */
+
#endif /* !_SYS_SOCKIO_H_ */
OpenPOWER on IntegriCloud