Deleted Added
full compact
rarpd.c (1.22) rarpd.c (1.23)
1/* $NetBSD: rarpd.c,v 1.22 1997/11/24 18:43:16 is Exp $ */
1/* $NetBSD: rarpd.c,v 1.23 1998/03/23 08:44:07 fair Exp $ */
2
3/*
4 * Copyright (c) 1990 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)

--- 13 unchanged lines hidden (view full) ---

23#include <sys/cdefs.h>
24#ifndef lint
25__COPYRIGHT(
26 "@(#) Copyright (c) 1990 The Regents of the University of California.\n\
27 All rights reserved.\n");
28#endif /* not lint */
29
30#ifndef lint
2
3/*
4 * Copyright (c) 1990 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)

--- 13 unchanged lines hidden (view full) ---

23#include <sys/cdefs.h>
24#ifndef lint
25__COPYRIGHT(
26 "@(#) Copyright (c) 1990 The Regents of the University of California.\n\
27 All rights reserved.\n");
28#endif /* not lint */
29
30#ifndef lint
31__RCSID("$NetBSD: rarpd.c,v 1.22 1997/11/24 18:43:16 is Exp $");
31__RCSID("$NetBSD: rarpd.c,v 1.23 1998/03/23 08:44:07 fair Exp $");
32#endif
33
34
35/*
36 * rarpd - Reverse ARP Daemon
37 *
38 * Usage: rarpd -a [ -d -f ]
39 * rarpd [ -d -f ] interface

--- 165 unchanged lines hidden (view full) ---

205 * Add 'ifname' to the interface list. Lookup its IP address and network
206 * mask and Ethernet address, and open a BPF file for it.
207 */
208void
209init_one(ifname)
210 char *ifname;
211{
212 struct if_info *p;
32#endif
33
34
35/*
36 * rarpd - Reverse ARP Daemon
37 *
38 * Usage: rarpd -a [ -d -f ]
39 * rarpd [ -d -f ] interface

--- 165 unchanged lines hidden (view full) ---

205 * Add 'ifname' to the interface list. Lookup its IP address and network
206 * mask and Ethernet address, and open a BPF file for it.
207 */
208void
209init_one(ifname)
210 char *ifname;
211{
212 struct if_info *p;
213 int fd;
213
214
215 fd = rarp_open(ifname);
216 if (fd < 0)
217 return;
218
214 p = (struct if_info *)malloc(sizeof(*p));
215 if (p == 0) {
216 rarperr(FATAL, "malloc: %s", strerror(errno));
217 /* NOTREACHED */
218 }
219 p->ii_next = iflist;
220 iflist = p;
221
219 p = (struct if_info *)malloc(sizeof(*p));
220 if (p == 0) {
221 rarperr(FATAL, "malloc: %s", strerror(errno));
222 /* NOTREACHED */
223 }
224 p->ii_next = iflist;
225 iflist = p;
226
222 p->ii_fd = rarp_open(ifname);
227 p->ii_fd = fd;
223 lookup_eaddr(ifname, p->ii_eaddr);
224 lookup_ipaddr(ifname, &p->ii_ipaddr, &p->ii_netmask);
225}
226
227/*
228 * Initialize all "candidate" interfaces that are in the system
229 * configuration list. A "candidate" is up, not loopback and not
230 * point to point.

--- 101 unchanged lines hidden (view full) ---

332 /* Set immediate mode so packets are processed as they arrive. */
333 immediate = 1;
334 if (ioctl(fd, BIOCIMMEDIATE, &immediate) < 0) {
335 rarperr(FATAL, "BIOCIMMEDIATE: %s", strerror(errno));
336 /* NOTREACHED */
337 }
338 (void) strncpy(ifr.ifr_name, device, sizeof ifr.ifr_name);
339 if (ioctl(fd, BIOCSETIF, (caddr_t) & ifr) < 0) {
228 lookup_eaddr(ifname, p->ii_eaddr);
229 lookup_ipaddr(ifname, &p->ii_ipaddr, &p->ii_netmask);
230}
231
232/*
233 * Initialize all "candidate" interfaces that are in the system
234 * configuration list. A "candidate" is up, not loopback and not
235 * point to point.

--- 101 unchanged lines hidden (view full) ---

337 /* Set immediate mode so packets are processed as they arrive. */
338 immediate = 1;
339 if (ioctl(fd, BIOCIMMEDIATE, &immediate) < 0) {
340 rarperr(FATAL, "BIOCIMMEDIATE: %s", strerror(errno));
341 /* NOTREACHED */
342 }
343 (void) strncpy(ifr.ifr_name, device, sizeof ifr.ifr_name);
344 if (ioctl(fd, BIOCSETIF, (caddr_t) & ifr) < 0) {
345 if (aflag) { /* for -a skip non-ethernet interfaces */
346 close(fd);
347 return(-1);
348 }
340 rarperr(FATAL, "BIOCSETIF: %s", strerror(errno));
341 /* NOTREACHED */
342 }
343 /* Check that the data link layer is an Ethernet; this code won't work
344 * with anything else. */
345 if (ioctl(fd, BIOCGDLT, (caddr_t) & dlt) < 0) {
346 rarperr(FATAL, "BIOCGDLT: %s", strerror(errno));
347 /* NOTREACHED */
348 }
349 if (dlt != DLT_EN10MB) {
349 rarperr(FATAL, "BIOCSETIF: %s", strerror(errno));
350 /* NOTREACHED */
351 }
352 /* Check that the data link layer is an Ethernet; this code won't work
353 * with anything else. */
354 if (ioctl(fd, BIOCGDLT, (caddr_t) & dlt) < 0) {
355 rarperr(FATAL, "BIOCGDLT: %s", strerror(errno));
356 /* NOTREACHED */
357 }
358 if (dlt != DLT_EN10MB) {
359 if (aflag) { /* for -a skip non-ethernet interfaces */
360 close(fd);
361 return(-1);
362 }
350 rarperr(FATAL, "%s is not an ethernet", device);
351 /* NOTREACHED */
352 }
353 /* Set filter program. */
354 if (ioctl(fd, BIOCSETF, (caddr_t) & filter) < 0) {
355 rarperr(FATAL, "BIOCSETF: %s", strerror(errno));
356 /* NOTREACHED */
357 }

--- 566 unchanged lines hidden ---
363 rarperr(FATAL, "%s is not an ethernet", device);
364 /* NOTREACHED */
365 }
366 /* Set filter program. */
367 if (ioctl(fd, BIOCSETF, (caddr_t) & filter) < 0) {
368 rarperr(FATAL, "BIOCSETF: %s", strerror(errno));
369 /* NOTREACHED */
370 }

--- 566 unchanged lines hidden ---