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
--- 17 unchanged lines hidden (view full) ---
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 * @(#)in.c 8.4 (Berkeley) 1/9/95
34 * $FreeBSD: head/sys/netinet/in.c 50477 1999-08-28 01:08:13Z peter $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/sockio.h>
40#include <sys/malloc.h>
41#include <sys/proc.h>
42#include <sys/socket.h>
43#include <sys/kernel.h>
44#include <sys/sysctl.h>
45
46#include <net/if.h>
47#include <net/route.h>
48
49#include <netinet/in.h>
50#include <netinet/in_var.h>
51
52#include <netinet/igmp_var.h>
53
54static MALLOC_DEFINE(M_IPMADDR, "in_multi", "internet multicast address");
55
56static void in_socktrim __P((struct sockaddr_in *));
57static int in_ifinit __P((struct ifnet *,
58 struct in_ifaddr *, struct sockaddr_in *, int));
59
60static int subnetsarelocal = 0;
61SYSCTL_INT(_net_inet_ip, OID_AUTO, subnets_are_local, CTLFLAG_RW,
62 &subnetsarelocal, 0, "");
63
--- 61 unchanged lines hidden (view full) ---
125 ap->sin_len = 0;
126 while (--cp >= cplim)
127 if (*cp) {
128 (ap)->sin_len = cp - (char *) (ap) + 1;
129 break;
130 }
131}
132
133static int in_interfaces; /* number of external internet interfaces */
134
135/*
136 * Generic internet control operations (ioctl's).
137 * Ifp is 0 if not an interface-specific ioctl.
138 */
139/* ARGSUSED */
140int
--- 8 unchanged lines hidden (view full) ---
149 register struct in_ifaddr *ia = 0, *iap;
150 register struct ifaddr *ifa;
151 struct in_ifaddr *oia;
152 struct in_aliasreq *ifra = (struct in_aliasreq *)data;
153 struct sockaddr_in oldaddr;
154 int error, hostIsNew, maskIsNew, s;
155 u_long i;
156
157 /*
158 * Find address for this interface, if it exists.
159 *
160 * If an alias address was specified, find that one instead of
161 * the first one on the interface.
162 */
163 if (ifp)
164 for (iap = in_ifaddrhead.tqh_first; iap;
--- 194 unchanged lines hidden (view full) ---
359 if (ifp == 0 || ifp->if_ioctl == 0)
360 return (EOPNOTSUPP);
361 return ((*ifp->if_ioctl)(ifp, cmd, data));
362 }
363 return (0);
364}
365
366/*
367 * Delete any existing route for an interface.
368 */
369void
370in_ifscrub(ifp, ia)
371 register struct ifnet *ifp;
372 register struct in_ifaddr *ia;
373{
374
--- 226 unchanged lines hidden ---
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
--- 17 unchanged lines hidden (view full) ---
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 * @(#)in.c 8.4 (Berkeley) 1/9/95
34 * $FreeBSD: head/sys/netinet/in.c 50477 1999-08-28 01:08:13Z peter $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/sockio.h>
40#include <sys/malloc.h>
41#include <sys/proc.h>
42#include <sys/socket.h>
43#include <sys/kernel.h>
44#include <sys/sysctl.h>
45
46#include <net/if.h>
47#include <net/route.h>
48
49#include <netinet/in.h>
50#include <netinet/in_var.h>
51
52#include <netinet/igmp_var.h>
53
54static MALLOC_DEFINE(M_IPMADDR, "in_multi", "internet multicast address");
55
56static void in_socktrim __P((struct sockaddr_in *));
57static int in_ifinit __P((struct ifnet *,
58 struct in_ifaddr *, struct sockaddr_in *, int));
59
60static int subnetsarelocal = 0;
61SYSCTL_INT(_net_inet_ip, OID_AUTO, subnets_are_local, CTLFLAG_RW,
62 &subnetsarelocal, 0, "");
63
--- 61 unchanged lines hidden (view full) ---
125 ap->sin_len = 0;
126 while (--cp >= cplim)
127 if (*cp) {
128 (ap)->sin_len = cp - (char *) (ap) + 1;
129 break;
130 }
131}
132
133static int in_interfaces; /* number of external internet interfaces */
134
135/*
136 * Generic internet control operations (ioctl's).
137 * Ifp is 0 if not an interface-specific ioctl.
138 */
139/* ARGSUSED */
140int
--- 8 unchanged lines hidden (view full) ---
149 register struct in_ifaddr *ia = 0, *iap;
150 register struct ifaddr *ifa;
151 struct in_ifaddr *oia;
152 struct in_aliasreq *ifra = (struct in_aliasreq *)data;
153 struct sockaddr_in oldaddr;
154 int error, hostIsNew, maskIsNew, s;
155 u_long i;
156
157 /*
158 * Find address for this interface, if it exists.
159 *
160 * If an alias address was specified, find that one instead of
161 * the first one on the interface.
162 */
163 if (ifp)
164 for (iap = in_ifaddrhead.tqh_first; iap;
--- 194 unchanged lines hidden (view full) ---
359 if (ifp == 0 || ifp->if_ioctl == 0)
360 return (EOPNOTSUPP);
361 return ((*ifp->if_ioctl)(ifp, cmd, data));
362 }
363 return (0);
364}
365
366/*
367 * Delete any existing route for an interface.
368 */
369void
370in_ifscrub(ifp, ia)
371 register struct ifnet *ifp;
372 register struct in_ifaddr *ia;
373{
374
--- 226 unchanged lines hidden ---