diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-25 15:13:51 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-25 15:13:51 +0000 |
commit | 17892fbd48343a33097737881b871dad3b03d934 (patch) | |
tree | 71b0828c896bbb461ef87e83b55e82f28b3c2786 | |
parent | 5a439d906a25ef93a6928917b3aed80dfff2352f (diff) |
only open one bpf per interface; netbsd pr#2106; codewarrior@daemon.org
-rw-r--r-- | usr.sbin/rarpd/rarpd.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/usr.sbin/rarpd/rarpd.c b/usr.sbin/rarpd/rarpd.c index fc875e0cd45..de637b13cc9 100644 --- a/usr.sbin/rarpd/rarpd.c +++ b/usr.sbin/rarpd/rarpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rarpd.c,v 1.3 1996/04/21 23:41:38 deraadt Exp $ */ +/* $OpenBSD: rarpd.c,v 1.4 1996/06/25 15:13:50 deraadt Exp $ */ /* $NetBSD: rarpd.c,v 1.12 1996/03/21 18:28:23 jtc Exp $ */ /* @@ -28,7 +28,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char rcsid[] = "$OpenBSD: rarpd.c,v 1.3 1996/04/21 23:41:38 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: rarpd.c,v 1.4 1996/06/25 15:13:50 deraadt Exp $"; #endif @@ -68,10 +68,11 @@ static char rcsid[] = "$OpenBSD: rarpd.c,v 1.3 1996/04/21 23:41:38 deraadt Exp $ * The structure for each interface. */ struct if_info { - int ii_fd; /* BPF file descriptor */ - u_char ii_eaddr[6]; /* Ethernet address of this interface */ - u_long ii_ipaddr; /* IP address of this interface */ - u_long ii_netmask; /* subnet or net mask */ + int ii_fd; /* BPF file descriptor */ + char ii_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + u_char ii_eaddr[6]; /* Ethernet address of this interface */ + u_long ii_ipaddr; /* IP address of this interface */ + u_long ii_netmask; /* subnet or net mask */ struct if_info *ii_next; }; /* @@ -195,6 +196,11 @@ init_one(ifname) { struct if_info *p; + /* first check to see if this "if" was already opened? */ + for(p = iflist; p; p = p->ii_next) + if (!strncmp(p->ii_name, ifname, IFNAMSIZ)) + return; + p = (struct if_info *)malloc(sizeof(*p)); if (p == 0) { err(FATAL, "malloc: %s", strerror(errno)); @@ -204,6 +210,7 @@ init_one(ifname) iflist = p; p->ii_fd = rarp_open(ifname); + strncpy(p->ii_name, ifname, IFNAMSIZ); lookup_eaddr(ifname, p->ii_eaddr); lookup_ipaddr(ifname, &p->ii_ipaddr, &p->ii_netmask); } |