Lines 105-110
Link Here
|
105 |
int nprobes = 0; |
105 |
int nprobes = 0; |
106 |
int nclaims = 0; |
106 |
int nclaims = 0; |
107 |
struct in_addr null_address; |
107 |
struct in_addr null_address; |
|
|
108 |
struct timeval stopat; |
109 |
struct timeval now; |
108 |
|
110 |
|
109 |
if (! iface->arpable) { |
111 |
if (! iface->arpable) { |
110 |
logger (LOG_DEBUG, "interface `%s' is not ARPable", iface->name); |
112 |
logger (LOG_DEBUG, "interface `%s' is not ARPable", iface->name); |
Lines 130-149
Link Here
|
130 |
int buflen = sizeof (char *) * iface->buffer_length; |
132 |
int buflen = sizeof (char *) * iface->buffer_length; |
131 |
fd_set rset; |
133 |
fd_set rset; |
132 |
int bytes; |
134 |
int bytes; |
133 |
int s; |
135 |
int s = 0; |
134 |
|
136 |
|
135 |
tv.tv_sec = 0; |
137 |
/* Only select if we have a timeout */ |
136 |
tv.tv_usec = timeout; |
138 |
if (timeout > 0) { |
|
|
139 |
tv.tv_sec = 0; |
140 |
tv.tv_usec = timeout; |
137 |
|
141 |
|
138 |
FD_ZERO (&rset); |
142 |
FD_ZERO (&rset); |
139 |
FD_SET (iface->fd, &rset); |
143 |
FD_SET (iface->fd, &rset); |
140 |
errno = 0; |
144 |
|
141 |
if ((s = select (FD_SETSIZE, &rset, NULL, NULL, &tv)) == -1) { |
145 |
errno = 0; |
142 |
if (errno != EINTR) |
146 |
if ((s = select (FD_SETSIZE, &rset, NULL, NULL, &tv)) == -1) { |
143 |
logger (LOG_ERR, "select: `%s'", strerror (errno)); |
147 |
if (errno != EINTR) |
144 |
break; |
148 |
logger (LOG_ERR, "select: `%s'", strerror (errno)); |
145 |
} else if (s == 0) { |
149 |
break; |
146 |
/* Timed out */ |
150 |
} |
|
|
151 |
} |
152 |
|
153 |
/* Timed out */ |
154 |
if (s == 0) { |
147 |
if (nprobes < NPROBES) { |
155 |
if (nprobes < NPROBES) { |
148 |
nprobes ++; |
156 |
nprobes ++; |
149 |
timeout = PROBE_INTERVAL; |
157 |
timeout = PROBE_INTERVAL; |
Lines 159-166
Link Here
|
159 |
retval = 0; |
167 |
retval = 0; |
160 |
break; |
168 |
break; |
161 |
} |
169 |
} |
|
|
170 |
|
171 |
/* Setup our stop time */ |
172 |
if (get_time (&stopat) != 0) |
173 |
break; |
174 |
stopat.tv_usec += timeout; |
175 |
|
176 |
continue; |
162 |
} |
177 |
} |
163 |
|
178 |
|
|
|
179 |
/* We maybe ARP flooded, so check our time */ |
180 |
if (get_time (&now) != 0) |
181 |
break; |
182 |
if (timercmp (&now, &stopat, >)) { |
183 |
timeout = 0; |
184 |
continue; |
185 |
} |
186 |
|
164 |
if (! FD_ISSET (iface->fd, &rset)) |
187 |
if (! FD_ISSET (iface->fd, &rset)) |
165 |
continue; |
188 |
continue; |
166 |
|
189 |
|