Deleted Added
sdiff udiff text old ( 130585 ) new ( 130933 )
full compact
1/*
2 * Copyright (c) 1980, 1986, 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

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

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)if.c 8.5 (Berkeley) 1/9/95
30 * $FreeBSD: head/sys/net/if.c 130933 2004-06-22 20:13:25Z brooks $
31 */
32
33#include "opt_compat.h"
34#include "opt_inet6.h"
35#include "opt_inet.h"
36#include "opt_mac.h"
37
38#include <sys/param.h>

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

51#include <sys/syslog.h>
52#include <sys/sysctl.h>
53#include <sys/domain.h>
54#include <sys/jail.h>
55#include <machine/stdarg.h>
56
57#include <net/if.h>
58#include <net/if_arp.h>
59#include <net/if_clone.h>
60#include <net/if_dl.h>
61#include <net/if_types.h>
62#include <net/if_var.h>
63#include <net/radix.h>
64#include <net/route.h>
65
66#if defined(INET) || defined(INET6)
67/*XXX*/

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

86static void if_check(void *);
87static int if_findindex(struct ifnet *);
88static void if_qflush(struct ifaltq *);
89static void if_route(struct ifnet *, int flag, int fam);
90static void if_slowtimo(void *);
91static void if_unroute(struct ifnet *, int flag, int fam);
92static void link_rtrequest(int, struct rtentry *, struct rt_addrinfo *);
93static int if_rtdel(struct radix_node *, void *);
94static int ifhwioctl(u_long, struct ifnet *, caddr_t, struct thread *);
95#ifdef INET6
96/*
97 * XXX: declare here to avoid to include many inet6 related files..
98 * should be more generalized?
99 */
100extern void nd6_setmtu(struct ifnet *);
101#endif
102
103int if_index = 0;
104struct ifindex_entry *ifindex_table = NULL;
105int ifqmaxlen = IFQ_MAXLEN;
106struct ifnethead ifnet; /* depend on static init XXX */
107struct mtx ifnet_lock;
108
109static int if_indexlim = 8;
110static struct klist ifklist;
111
112static void filt_netdetach(struct knote *kn);
113static int filt_netdev(struct knote *kn, long hint);
114
115static struct filterops netdev_filtops =
116 { 1, NULL, filt_netdetach, filt_netdev };
117
118/*
119 * System initialization
120 */
121SYSINIT(interfaces, SI_SUB_INIT_IF, SI_ORDER_FIRST, if_init, NULL)
122SYSINIT(interface_check, SI_SUB_PROTO_IF, SI_ORDER_FIRST, if_check, NULL)
123
124MALLOC_DEFINE(M_IFADDR, "ifaddr", "interface address");
125MALLOC_DEFINE(M_IFMADDR, "ether_multi", "link-level multicast address");
126
127static d_open_t netopen;
128static d_close_t netclose;
129static d_ioctl_t netioctl;
130static d_kqfilter_t netkqfilter;
131
132static struct cdevsw net_cdevsw = {
133 .d_version = D_VERSION,

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

254{
255
256 IFNET_LOCK_INIT();
257 TAILQ_INIT(&ifnet);
258 SLIST_INIT(&ifklist);
259 if_grow(); /* create initial table */
260 ifdev_byindex(0) = make_dev(&net_cdevsw, 0,
261 UID_ROOT, GID_WHEEL, 0600, "network");
262 if_clone_init();
263}
264
265static void
266if_grow(void)
267{
268 u_int n;
269 struct ifindex_entry *e;
270

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

660 if (err) {
661 log(LOG_WARNING, "if_rtdel: error %d\n", err);
662 }
663 }
664
665 return (0);
666}
667
668#define equal(a1, a2) (bcmp((a1), (a2), ((a1))->sa_len) == 0)
669
670/*
671 * Locate an interface based on a complete address.
672 */
673/*ARGSUSED*/
674struct ifaddr *
675ifa_ifwithaddr(struct sockaddr *addr)

--- 1169 unchanged lines hidden ---