in.c (1542) | in.c (1549) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1991, 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 --- 20 unchanged lines hidden (view full) --- 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 * @(#)in.c 8.2 (Berkeley) 11/15/93 34 */ 35 36#include <sys/param.h> | 1/* 2 * Copyright (c) 1982, 1986, 1991, 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 --- 20 unchanged lines hidden (view full) --- 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 * @(#)in.c 8.2 (Berkeley) 11/15/93 34 */ 35 36#include <sys/param.h> |
37#include <sys/systm.h> |
|
37#include <sys/ioctl.h> 38#include <sys/errno.h> 39#include <sys/malloc.h> 40#include <sys/socket.h> 41#include <sys/socketvar.h> 42 43#include <net/if.h> 44#include <net/route.h> --- 41 unchanged lines hidden (view full) --- 86#endif 87int subnetsarelocal = SUBNETSARELOCAL; 88/* 89 * Return 1 if an internet address is for a ``local'' host 90 * (one to which we have a connection). If subnetsarelocal 91 * is true, this includes other subnets of the local net. 92 * Otherwise, it includes only the directly-connected (sub)nets. 93 */ | 38#include <sys/ioctl.h> 39#include <sys/errno.h> 40#include <sys/malloc.h> 41#include <sys/socket.h> 42#include <sys/socketvar.h> 43 44#include <net/if.h> 45#include <net/route.h> --- 41 unchanged lines hidden (view full) --- 87#endif 88int subnetsarelocal = SUBNETSARELOCAL; 89/* 90 * Return 1 if an internet address is for a ``local'' host 91 * (one to which we have a connection). If subnetsarelocal 92 * is true, this includes other subnets of the local net. 93 * Otherwise, it includes only the directly-connected (sub)nets. 94 */ |
95int |
|
94in_localaddr(in) 95 struct in_addr in; 96{ 97 register u_long i = ntohl(in.s_addr); 98 register struct in_ifaddr *ia; 99 100 if (subnetsarelocal) { 101 for (ia = in_ifaddr; ia; ia = ia->ia_next) --- 7 unchanged lines hidden (view full) --- 109 return (0); 110} 111 112/* 113 * Determine whether an IP address is in a reserved set of addresses 114 * that may not be forwarded, or whether datagrams to that destination 115 * may be forwarded. 116 */ | 96in_localaddr(in) 97 struct in_addr in; 98{ 99 register u_long i = ntohl(in.s_addr); 100 register struct in_ifaddr *ia; 101 102 if (subnetsarelocal) { 103 for (ia = in_ifaddr; ia; ia = ia->ia_next) --- 7 unchanged lines hidden (view full) --- 111 return (0); 112} 113 114/* 115 * Determine whether an IP address is in a reserved set of addresses 116 * that may not be forwarded, or whether datagrams to that destination 117 * may be forwarded. 118 */ |
119int |
|
117in_canforward(in) 118 struct in_addr in; 119{ 120 register u_long i = ntohl(in.s_addr); 121 register u_long net; 122 123 if (IN_EXPERIMENTAL(i) || IN_MULTICAST(i)) 124 return (0); --- 26 unchanged lines hidden (view full) --- 151int in_interfaces; /* number of external internet interfaces */ 152extern struct ifnet loif; 153 154/* 155 * Generic internet control operations (ioctl's). 156 * Ifp is 0 if not an interface-specific ioctl. 157 */ 158/* ARGSUSED */ | 120in_canforward(in) 121 struct in_addr in; 122{ 123 register u_long i = ntohl(in.s_addr); 124 register u_long net; 125 126 if (IN_EXPERIMENTAL(i) || IN_MULTICAST(i)) 127 return (0); --- 26 unchanged lines hidden (view full) --- 154int in_interfaces; /* number of external internet interfaces */ 155extern struct ifnet loif; 156 157/* 158 * Generic internet control operations (ioctl's). 159 * Ifp is 0 if not an interface-specific ioctl. 160 */ 161/* ARGSUSED */ |
162int |
|
159in_control(so, cmd, data, ifp) 160 struct socket *so; 161 int cmd; 162 caddr_t data; 163 register struct ifnet *ifp; 164{ 165 register struct ifreq *ifr = (struct ifreq *)data; 166 register struct in_ifaddr *ia = 0; --- 223 unchanged lines hidden (view full) --- 390 rtinit(&(ia->ia_ifa), (int)RTM_DELETE, 0); 391 ia->ia_flags &= ~IFA_ROUTE; 392} 393 394/* 395 * Initialize an interface's internet address 396 * and routing table entry. 397 */ | 163in_control(so, cmd, data, ifp) 164 struct socket *so; 165 int cmd; 166 caddr_t data; 167 register struct ifnet *ifp; 168{ 169 register struct ifreq *ifr = (struct ifreq *)data; 170 register struct in_ifaddr *ia = 0; --- 223 unchanged lines hidden (view full) --- 394 rtinit(&(ia->ia_ifa), (int)RTM_DELETE, 0); 395 ia->ia_flags &= ~IFA_ROUTE; 396} 397 398/* 399 * Initialize an interface's internet address 400 * and routing table entry. 401 */ |
402int |
|
398in_ifinit(ifp, ia, sin, scrub) 399 register struct ifnet *ifp; 400 register struct in_ifaddr *ia; 401 struct sockaddr_in *sin; 402 int scrub; 403{ 404 register u_long i = ntohl(sin->sin_addr.s_addr); 405 struct sockaddr_in oldaddr; --- 72 unchanged lines hidden (view full) --- 478 } 479 return (error); 480} 481 482 483/* 484 * Return 1 if the address might be a local broadcast address. 485 */ | 403in_ifinit(ifp, ia, sin, scrub) 404 register struct ifnet *ifp; 405 register struct in_ifaddr *ia; 406 struct sockaddr_in *sin; 407 int scrub; 408{ 409 register u_long i = ntohl(sin->sin_addr.s_addr); 410 struct sockaddr_in oldaddr; --- 72 unchanged lines hidden (view full) --- 483 } 484 return (error); 485} 486 487 488/* 489 * Return 1 if the address might be a local broadcast address. 490 */ |
491int |
|
486in_broadcast(in, ifp) 487 struct in_addr in; 488 struct ifnet *ifp; 489{ 490 register struct ifaddr *ifa; 491 u_long t; 492 493 if (in.s_addr == INADDR_BROADCAST || --- 85 unchanged lines hidden (view full) --- 579 } 580 splx(s); 581 return (inm); 582} 583 584/* 585 * Delete a multicast address record. 586 */ | 492in_broadcast(in, ifp) 493 struct in_addr in; 494 struct ifnet *ifp; 495{ 496 register struct ifaddr *ifa; 497 u_long t; 498 499 if (in.s_addr == INADDR_BROADCAST || --- 85 unchanged lines hidden (view full) --- 585 } 586 splx(s); 587 return (inm); 588} 589 590/* 591 * Delete a multicast address record. 592 */ |
587int | 593void |
588in_delmulti(inm) 589 register struct in_multi *inm; 590{ 591 register struct in_multi **p; 592 struct ifreq ifr; 593 int s = splnet(); 594 595 if (--inm->inm_refcount == 0) { --- 27 unchanged lines hidden --- | 594in_delmulti(inm) 595 register struct in_multi *inm; 596{ 597 register struct in_multi **p; 598 struct ifreq ifr; 599 int s = splnet(); 600 601 if (--inm->inm_refcount == 0) { --- 27 unchanged lines hidden --- |