2 * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. All advertising materials mentioning features or use of this software
13 * must display the following acknowledgement:
14 * This product includes software developed by Mats O Jansson.
15 * 4. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 static char rcsid
[] = "$Id: loop-linux2.c,v 1.1.1.1 2001/06/24 19:33:53 atp Exp $";
37 #if defined(__bsdi__) || defined(__FreeBSD__)
40 #include <sys/ioctl.h>
41 #include <sys/errno.h>
53 return (*(p
->iopen
))(p
->if_name
,
68 return (*(p
->iopen
))(p
->if_name
,
88 * The list of all interfaces that are being listened to. loop()
89 * "selects" on the descriptors in this list.
91 struct if_info
*iflist
;
93 void mopProcess
__P((struct if_info
*, u_char
*));
96 * Loop indefinitely listening for MOP requests on the
97 * interfaces in 'iflist'.
102 u_char
*buf
, *bp
, *ep
;
104 fd_set fds
, listeners
;
105 int bufsize
= 1100, maxfd
=0;
110 syslog(LOG_ERR
, "no interfaces");
114 buf
= (u_char
*) malloc((unsigned) bufsize
);
117 syslog(LOG_ERR
, "malloc: %m");
121 * Find the highest numbered file descriptor for select().
122 * Initialize the set of descriptors to listen to.
125 for (ii
= iflist
; ii
; ii
= ii
->next
) {
127 FD_SET(ii
->fd
, &fds
);
134 if (select(maxfd
+ 1, &listeners
, (fd_set
*) 0,
135 (fd_set
*) 0, (struct timeval
*) 0) < 0) {
136 syslog(LOG_ERR
, "select: %m");
139 for (ii
= iflist
; ii
; ii
= ii
->next
) {
141 if (!FD_ISSET(ii
->fd
, &listeners
))
145 cc
= read(ii
->fd
, (char *) buf
, bufsize
);
146 /* Don't choke when we get ptraced */
147 if (cc
< 0 && errno
== EINTR
)