Deleted Added
sdiff udiff text old ( 108533 ) new ( 126250 )
full compact
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $FreeBSD: head/sbin/routed/if.c 108533 2003-01-01 18:49:04Z schweikh $
34 */
35
36#include "defs.h"
37#include "pathnames.h"
38
39#if !defined(sgi) && !defined(__NetBSD__)
40static char sccsid[] __attribute__((unused)) = "@(#)if.c 8.1 (Berkeley) 6/5/93";
41#elif defined(__NetBSD__)
42#include <sys/cdefs.h>
43__RCSID("$NetBSD$");
44#endif
45#ident "$FreeBSD: head/sbin/routed/if.c 108533 2003-01-01 18:49:04Z schweikh $"
46
47struct interface *ifnet; /* all interfaces */
48
49/* hash table for all interfaces, big enough to tolerate ridiculous
50 * numbers of IP aliases. Crazy numbers of aliases such as 7000
51 * still will not do well, but not just in looking up interfaces
52 * by name or address.
53 */
54#define AHASH_LEN 211 /* must be prime */

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

209 if (IF_RESCAN_DELAY())
210 return 0;
211 ifinit();
212 }
213}
214
215
216struct interface *
217ifwithindex(u_short index,
218 int rescan_ok)
219{
220 struct interface *ifp;
221
222 for (;;) {
223 for (ifp = ifnet; 0 != ifp; ifp = ifp->int_next) {
224 if (ifp->int_index == index)
225 return ifp;
226 }
227
228 /* If there is no known interface, maybe there is a
229 * new interface. So just once look for new interfaces.
230 */
231 if (!rescan_ok
232 || IF_RESCAN_DELAY())

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

239/* Find an interface from which the specified address
240 * should have come from. Used for figuring out which
241 * interface a packet came in on.
242 */
243struct interface *
244iflookup(naddr addr)
245{
246 struct interface *ifp, *maybe;
247
248 maybe = 0;
249 for (;;) {
250 for (ifp = ifnet; ifp; ifp = ifp->int_next) {
251 if (ifp->int_if_flags & IFF_POINTOPOINT) {
252 /* finished with a match */
253 if (ifp->int_dstaddr == addr)
254 return ifp;

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

262 */
263 if (on_net(addr, ifp->int_net, ifp->int_mask)
264 && (maybe == 0
265 || ifp->int_mask > maybe->int_mask))
266 maybe = ifp;
267 }
268 }
269
270 if (maybe != 0
271 || IF_RESCAN_DELAY())
272 return maybe;
273
274 /* If there is no known interface, maybe there is a
275 * new interface. So just once look for new interfaces.
276 */
277 ifinit();
278 }
279}
280

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

401 continue;
402
403 if (!iff_up(ifp->int_if_flags))
404 continue;
405
406 /* The local address can only be shared with a point-to-point
407 * link.
408 */
409 if (ifp->int_addr == addr
410 && (((if_flags|ifp->int_if_flags) & IFF_POINTOPOINT) == 0))
411 return ifp;
412
413 if (on_net(ifp->int_dstaddr, ntohl(dstaddr),mask))
414 return ifp;
415 }
416 return 0;
417}

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

493 }
494
495 if ((ifp->int_if_flags & IFF_MULTICAST)
496#ifdef MCAST_PPP_BUG
497 && !(ifp->int_if_flags & IFF_POINTOPOINT)
498#endif
499 && rip_sock >= 0) {
500 m.imr_multiaddr.s_addr = htonl(INADDR_RIP_GROUP);
501 m.imr_interface.s_addr = ((ifp->int_if_flags
502 & IFF_POINTOPOINT)
503 ? ifp->int_dstaddr
504 : ifp->int_addr);
505 if (setsockopt(rip_sock,IPPROTO_IP,IP_DROP_MEMBERSHIP,
506 &m, sizeof(m)) < 0
507 && errno != EADDRNOTAVAIL
508 && !TRACEACTIONS)
509 LOGERR("setsockopt(IP_DROP_MEMBERSHIP RIP)");
510 if (rip_sock_mcast == ifp)
511 rip_sock_mcast = 0;
512 }

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

732
733 ifam_lim = (struct ifa_msghdr *)(sysctl_buf + needed);
734 for (ifam = (struct ifa_msghdr *)sysctl_buf;
735 ifam < ifam_lim;
736 ifam = ifam2) {
737
738 ifam2 = (struct ifa_msghdr*)((char*)ifam + ifam->ifam_msglen);
739
740 if (ifam->ifam_type == RTM_IFINFO) {
741 struct sockaddr_dl *sdl;
742
743 ifm = (struct if_msghdr *)ifam;
744 /* make prototype structure for the IP aliases
745 */
746 memset(&ifs0, 0, sizeof(ifs0));
747 ifs0.int_rip_sock = -1;

--- 658 unchanged lines hidden ---