bpf.c (27077) | bpf.c (27079) |
---|---|
1/* 2 * Copyright (c) 1988, 1992 The University of Utah and the Center 3 * for Software Science (CSS). 4 * Copyright (c) 1992, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * the Center for Software Science of the University of Utah Computer --- 25 unchanged lines hidden (view full) --- 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * from: @(#)bpf.c 8.1 (Berkeley) 6/4/93 | 1/* 2 * Copyright (c) 1988, 1992 The University of Utah and the Center 3 * for Software Science (CSS). 4 * Copyright (c) 1992, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * the Center for Software Science of the University of Utah Computer --- 25 unchanged lines hidden (view full) --- 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * from: @(#)bpf.c 8.1 (Berkeley) 6/4/93 |
42 * $Id: bpf.c,v 1.6 1997/02/22 14:21:57 peter Exp $ | 42 * $Id: bpf.c,v 1.7 1997/06/29 19:00:01 steve Exp $ |
43 * 44 * From: Utah Hdr: bpf.c 3.1 92/07/06 45 * Author: Jeff Forys, University of Utah CSS 46 */ 47 48#ifndef lint 49static const char sccsid[] = "@(#)bpf.c 8.1 (Berkeley) 6/4/93"; 50#endif /* not lint */ --- 90 unchanged lines hidden (view full) --- 141 * grab our RMP address. If this fails, try promiscuous mode. 142 * If this fails, there's no way we are going to get any RMP 143 * packets so just exit here. 144 */ 145#ifdef MSG_EOR 146 ifr.ifr_addr.sa_len = RMP_ADDRLEN + 2; 147#endif 148 ifr.ifr_addr.sa_family = AF_UNSPEC; | 43 * 44 * From: Utah Hdr: bpf.c 3.1 92/07/06 45 * Author: Jeff Forys, University of Utah CSS 46 */ 47 48#ifndef lint 49static const char sccsid[] = "@(#)bpf.c 8.1 (Berkeley) 6/4/93"; 50#endif /* not lint */ --- 90 unchanged lines hidden (view full) --- 141 * grab our RMP address. If this fails, try promiscuous mode. 142 * If this fails, there's no way we are going to get any RMP 143 * packets so just exit here. 144 */ 145#ifdef MSG_EOR 146 ifr.ifr_addr.sa_len = RMP_ADDRLEN + 2; 147#endif 148 ifr.ifr_addr.sa_family = AF_UNSPEC; |
149 bcopy(&RmpMcastAddr[0], (char *)&ifr.ifr_addr.sa_data[0], RMP_ADDRLEN); | 149 memmove((char *)&ifr.ifr_addr.sa_data[0], &RmpMcastAddr[0], RMP_ADDRLEN); |
150 if (ioctl(BpfFd, BIOCPROMISC, (caddr_t)0) < 0) { 151 syslog(LOG_ERR, "bpf: can't set promiscuous mode: %m"); 152 Exit(0); 153 } 154 155 /* 156 * Ask BPF how much buffer space it requires and allocate one. 157 */ --- 145 unchanged lines hidden (view full) --- 303** Side Effects: 304** None. 305*/ 306int 307BpfRead(rconn, doread) 308 RMPCONN *rconn; 309 int doread; 310{ | 150 if (ioctl(BpfFd, BIOCPROMISC, (caddr_t)0) < 0) { 151 syslog(LOG_ERR, "bpf: can't set promiscuous mode: %m"); 152 Exit(0); 153 } 154 155 /* 156 * Ask BPF how much buffer space it requires and allocate one. 157 */ --- 145 unchanged lines hidden (view full) --- 303** Side Effects: 304** None. 305*/ 306int 307BpfRead(rconn, doread) 308 RMPCONN *rconn; 309 int doread; 310{ |
311 register int datlen, caplen, hdrlen; | 311 int datlen, caplen, hdrlen; |
312 static u_int8_t *bp = NULL, *ep = NULL; 313 int cc; 314 315 /* 316 * The read() may block, or it may return one or more packets. 317 * We let the caller decide whether or not we can issue a read(). 318 */ 319 if (doread) { --- 20 unchanged lines hidden (view full) --- 340 syslog(LOG_ERR, 341 "bpf: short packet dropped (%d of %d bytes)", 342 caplen, datlen); 343 else if (caplen > sizeof(struct rmp_packet)) 344 syslog(LOG_ERR, "bpf: large packet dropped (%d bytes)", 345 caplen); 346 else { 347 rconn->rmplen = caplen; | 312 static u_int8_t *bp = NULL, *ep = NULL; 313 int cc; 314 315 /* 316 * The read() may block, or it may return one or more packets. 317 * We let the caller decide whether or not we can issue a read(). 318 */ 319 if (doread) { --- 20 unchanged lines hidden (view full) --- 340 syslog(LOG_ERR, 341 "bpf: short packet dropped (%d of %d bytes)", 342 caplen, datlen); 343 else if (caplen > sizeof(struct rmp_packet)) 344 syslog(LOG_ERR, "bpf: large packet dropped (%d bytes)", 345 caplen); 346 else { 347 rconn->rmplen = caplen; |
348 bcopy((char *)&bhp->bh_tstamp, (char *)&rconn->tstamp, | 348 memmove((char *)&rconn->tstamp, (char *)&bhp->bh_tstamp, |
349 sizeof(struct timeval)); | 349 sizeof(struct timeval)); |
350 bcopy((char *)bp + hdrlen, (char *)&rconn->rmp, caplen); | 350 memmove((char *)&rconn->rmp, (char *)bp + hdrlen, caplen); |
351 } 352 bp += BPF_WORDALIGN(caplen + hdrlen); 353 return(1); 354 } 355#undef bhp 356 357 return(0); 358} --- 46 unchanged lines hidden (view full) --- 405 406 if (BpfFd == -1) 407 return; 408 409#ifdef MSG_EOR 410 ifr.ifr_addr.sa_len = RMP_ADDRLEN + 2; 411#endif 412 ifr.ifr_addr.sa_family = AF_UNSPEC; | 351 } 352 bp += BPF_WORDALIGN(caplen + hdrlen); 353 return(1); 354 } 355#undef bhp 356 357 return(0); 358} --- 46 unchanged lines hidden (view full) --- 405 406 if (BpfFd == -1) 407 return; 408 409#ifdef MSG_EOR 410 ifr.ifr_addr.sa_len = RMP_ADDRLEN + 2; 411#endif 412 ifr.ifr_addr.sa_family = AF_UNSPEC; |
413 bcopy(&RmpMcastAddr[0], (char *)&ifr.ifr_addr.sa_data[0], RMP_ADDRLEN); | 413 memmove((char *)&ifr.ifr_addr.sa_data[0], &RmpMcastAddr[0], RMP_ADDRLEN); |
414 if (ioctl(BpfFd, SIOCDELMULTI, (caddr_t)&ifr) < 0) 415 (void) ioctl(BpfFd, BIOCPROMISC, (caddr_t)0); 416 417 (void) close(BpfFd); 418 BpfFd = -1; 419} | 414 if (ioctl(BpfFd, SIOCDELMULTI, (caddr_t)&ifr) < 0) 415 (void) ioctl(BpfFd, BIOCPROMISC, (caddr_t)0); 416 417 (void) close(BpfFd); 418 BpfFd = -1; 419} |