2009-04-17 01:37:17 +04:00
|
|
|
/* $NetBSD: iso_snpac.c,v 1.53 2009/04/16 21:37:17 elad Exp $ */
|
1994-06-29 10:39:25 +04:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
/*-
|
1994-05-13 10:08:03 +04:00
|
|
|
* Copyright (c) 1991, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-04-09 16:00:07 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1998-03-01 05:20:01 +03:00
|
|
|
* @(#)iso_snpac.c 8.4 (Berkeley) 5/2/95
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/***********************************************************
|
|
|
|
Copyright IBM Corporation 1987
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
1993-04-09 16:00:07 +04:00
|
|
|
provided that the above copyright notice appear in all copies and that
|
1996-02-14 01:07:57 +03:00
|
|
|
both that copyright notice and this permission notice appear in
|
1993-04-09 16:00:07 +04:00
|
|
|
supporting documentation, and that the name of IBM not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
1996-02-14 01:07:57 +03:00
|
|
|
software without specific, written prior permission.
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
|
|
|
|
*/
|
|
|
|
|
2001-11-13 03:56:55 +03:00
|
|
|
#include <sys/cdefs.h>
|
2009-04-17 01:37:17 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: iso_snpac.c,v 1.53 2009/04/16 21:37:17 elad Exp $");
|
2001-11-13 03:56:55 +03:00
|
|
|
|
1998-07-05 08:37:35 +04:00
|
|
|
#include "opt_iso.h"
|
1993-04-09 16:00:07 +04:00
|
|
|
#ifdef ISO
|
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2002-05-13 01:30:35 +04:00
|
|
|
#include <sys/kernel.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/domain.h>
|
|
|
|
#include <sys/protosw.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/syslog.h>
|
1996-05-22 17:54:55 +04:00
|
|
|
#include <sys/proc.h>
|
2006-05-15 01:19:33 +04:00
|
|
|
#include <sys/kauth.h>
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/route.h>
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
#include <net/if_ether.h>
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <netiso/iso.h>
|
|
|
|
#include <netiso/iso_var.h>
|
|
|
|
#include <netiso/iso_snpac.h>
|
|
|
|
#include <netiso/clnp.h>
|
|
|
|
#include <netiso/clnp_stat.h>
|
|
|
|
#include <netiso/esis.h>
|
|
|
|
#include <netiso/argo_debug.h>
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
int iso_systype = SNPA_ES; /* default to be an ES */
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1995-06-13 12:12:33 +04:00
|
|
|
LIST_HEAD(, llinfo_llc) llinfo_llc;
|
|
|
|
|
2000-03-23 10:01:25 +03:00
|
|
|
struct callout snpac_age_ch;
|
|
|
|
|
2006-08-30 23:20:48 +04:00
|
|
|
struct sockaddr_iso blank_siso = {
|
|
|
|
.siso_len = sizeof(blank_siso),
|
|
|
|
.siso_family = AF_ISO,
|
|
|
|
};
|
1993-04-09 16:00:07 +04:00
|
|
|
static struct sockaddr_iso
|
2006-08-30 23:20:48 +04:00
|
|
|
dst = {
|
|
|
|
.siso_len = sizeof(dst),
|
|
|
|
.siso_family = AF_ISO,
|
|
|
|
},
|
|
|
|
gte = {
|
|
|
|
.siso_len = sizeof(gte),
|
|
|
|
.siso_family = AF_ISO,
|
|
|
|
},
|
1996-02-14 01:07:57 +03:00
|
|
|
#if 0
|
2006-08-30 23:20:48 +04:00
|
|
|
src = {
|
|
|
|
.siso_len = sizeof(src),
|
|
|
|
.siso_family = AF_ISO,
|
|
|
|
},
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif
|
2006-08-30 23:20:48 +04:00
|
|
|
msk = {
|
|
|
|
.siso_len = sizeof(msk),
|
|
|
|
.siso_family = AF_ISO,
|
|
|
|
},
|
|
|
|
zmk = {
|
|
|
|
.siso_len = 0,
|
|
|
|
};
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
#define zsi blank_siso
|
|
|
|
#define zero_isoa zsi.siso_addr
|
2008-05-12 00:20:27 +04:00
|
|
|
#define zap_isoaddr(a, b) {memset(&a.siso_addr, 0, sizeof(*r)); r = b; \
|
|
|
|
memmove(&a.siso_addr, r, 1 + (r)->isoa_len);}
|
1993-04-09 16:00:07 +04:00
|
|
|
#define S(x) ((struct sockaddr *)&(x))
|
|
|
|
|
|
|
|
static struct sockaddr_dl gte_dl;
|
|
|
|
|
2004-04-19 09:16:45 +04:00
|
|
|
static void snpac_fixdstandmask (int);
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
|
|
|
* We only keep track of a single IS at a time.
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
struct rtentry *known_is;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Addresses taken from NBS agreements, December 1987.
|
|
|
|
*
|
|
|
|
* These addresses assume on-the-wire transmission of least significant
|
|
|
|
* bit first. This is the method used by 802.3. When these
|
|
|
|
* addresses are passed to the token ring driver, (802.5), they
|
1995-03-06 22:06:05 +03:00
|
|
|
* must be bit-swapped because 802.5 transmission order is MSb first.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
|
|
|
* Furthermore, according to IBM Austin, these addresses are not
|
|
|
|
* true token ring multicast addresses. More work is necessary
|
|
|
|
* to get multicast to work right on token ring.
|
|
|
|
*
|
|
|
|
* Currently, the token ring driver does not handle multicast, so
|
|
|
|
* these addresses are converted into the broadcast address in
|
|
|
|
* lan_output() That means that if these multicast addresses change
|
|
|
|
* the token ring driver must be altered.
|
|
|
|
*/
|
2004-04-19 09:16:45 +04:00
|
|
|
const char all_es_snpa[] = {0x09, 0x00, 0x2b, 0x00, 0x00, 0x04};
|
|
|
|
const char all_is_snpa[] = {0x09, 0x00, 0x2b, 0x00, 0x00, 0x05};
|
|
|
|
const char all_l1is_snpa[] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x14};
|
|
|
|
const char all_l2is_snpa[] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x15};
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
union sockunion {
|
|
|
|
struct sockaddr_iso siso;
|
1996-02-14 01:07:57 +03:00
|
|
|
struct sockaddr_dl sdl;
|
|
|
|
struct sockaddr sa;
|
1993-04-09 16:00:07 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: llc_rtrequest
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Manage routing table entries specific to LLC for ISO.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES: This does a lot of obscure magic;
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
2008-10-24 21:07:33 +04:00
|
|
|
llc_rtrequest(int req, struct rtentry *rt, const struct rt_addrinfo *info)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
union sockunion *gate = (union sockunion *) rt->rt_gateway;
|
|
|
|
struct llinfo_llc *lc = (struct llinfo_llc *) rt->rt_llinfo;
|
1996-02-14 01:07:57 +03:00
|
|
|
struct ifnet *ifp = rt->rt_ifp;
|
|
|
|
int addrlen = ifp->if_addrlen;
|
|
|
|
#define LLC_SIZE 3 /* XXXXXX do this right later */
|
|
|
|
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SNPA]) {
|
2001-01-17 07:05:41 +03:00
|
|
|
printf("llc_rtrequest(%d, %p, %p)\n", req, rt, info);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
if (rt->rt_flags & RTF_GATEWAY)
|
|
|
|
return;
|
1996-02-14 01:07:57 +03:00
|
|
|
else
|
|
|
|
switch (req) {
|
|
|
|
case RTM_ADD:
|
|
|
|
/*
|
|
|
|
* Case 1: This route may come from a route to iface with mask
|
|
|
|
* or from a default route.
|
|
|
|
*/
|
|
|
|
if (rt->rt_flags & RTF_CLONING) {
|
2007-09-02 23:42:21 +04:00
|
|
|
union {
|
|
|
|
struct sockaddr sa;
|
|
|
|
struct sockaddr_dl sdl;
|
|
|
|
struct sockaddr_storage ss;
|
|
|
|
} u;
|
Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.
Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.
Avoid using sizeof(struct sockaddr_dl) in the kernel.
Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.
Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().
Constify: LLADDR() -> CLLADDR().
Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.
2007-08-30 06:17:34 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
iso_setmcasts(ifp, req);
|
2007-09-02 23:42:21 +04:00
|
|
|
sockaddr_dl_init(&u.sdl, sizeof(u.ss),
|
|
|
|
ifp->if_index, ifp->if_type,
|
|
|
|
NULL, strlen(ifp->if_xname),
|
|
|
|
NULL, ifp->if_addrlen);
|
|
|
|
rt_setgate(rt, &u.sa);
|
1996-02-14 01:07:57 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (lc != 0)
|
|
|
|
return; /* happens on a route change */
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case RTM_RESOLVE:
|
|
|
|
/*
|
|
|
|
* Case 2: This route may come from cloning, or a manual route
|
|
|
|
* add with a LL address.
|
|
|
|
*/
|
|
|
|
if (gate->sdl.sdl_family != AF_LINK) {
|
|
|
|
log(LOG_DEBUG, "llc_rtrequest: got non-link non-gateway route\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
R_Malloc(lc, struct llinfo_llc *, sizeof(*lc));
|
2007-03-04 08:59:00 +03:00
|
|
|
rt->rt_llinfo = (void *) lc;
|
1996-02-14 01:07:57 +03:00
|
|
|
if (lc == 0) {
|
|
|
|
log(LOG_DEBUG, "llc_rtrequest: malloc failed\n");
|
|
|
|
break;
|
|
|
|
}
|
2008-05-12 00:20:27 +04:00
|
|
|
memset(lc, 0, sizeof(*lc));
|
1996-02-14 01:07:57 +03:00
|
|
|
lc->lc_rt = rt;
|
|
|
|
rt->rt_flags |= RTF_LLINFO;
|
|
|
|
LIST_INSERT_HEAD(&llinfo_llc, lc, lc_list);
|
2005-05-31 05:37:06 +04:00
|
|
|
if (gate->sdl.sdl_alen == sizeof(struct esis_req)
|
|
|
|
+ addrlen) {
|
1996-02-14 01:07:57 +03:00
|
|
|
gate->sdl.sdl_alen -= sizeof(struct esis_req);
|
2005-05-31 05:37:06 +04:00
|
|
|
(void)memcpy(&lc->lc_er,
|
|
|
|
(const char *)CLLADDR(&gate->sdl) +
|
|
|
|
addrlen, sizeof(lc->lc_er));
|
1996-02-14 01:07:57 +03:00
|
|
|
} else if (gate->sdl.sdl_alen == addrlen)
|
|
|
|
lc->lc_flags = (SNPA_ES | SNPA_VALID | SNPA_PERM);
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
1996-02-14 01:07:57 +03:00
|
|
|
case RTM_DELETE:
|
|
|
|
if (rt->rt_flags & RTF_CLONING)
|
|
|
|
iso_setmcasts(ifp, req);
|
|
|
|
if (lc == 0)
|
|
|
|
return;
|
|
|
|
LIST_REMOVE(lc, lc_list);
|
|
|
|
Free(lc);
|
|
|
|
rt->rt_llinfo = 0;
|
|
|
|
rt->rt_flags &= ~RTF_LLINFO;
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (rt->rt_rmx.rmx_mtu == 0) {
|
1996-02-14 01:07:57 +03:00
|
|
|
rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu - LLC_SIZE;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1994-05-13 10:08:03 +04:00
|
|
|
/*
|
|
|
|
* FUNCTION: iso_setmcasts
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Enable/Disable ESIS/ISIS multicast reception on
|
|
|
|
* interfaces.
|
1994-05-13 10:08:03 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES: This also does a lot of obscure magic;
|
1994-05-13 10:08:03 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
2004-04-19 09:16:45 +04:00
|
|
|
iso_setmcasts(struct ifnet *ifp, int req)
|
1994-05-13 10:08:03 +04:00
|
|
|
{
|
2004-04-19 09:16:45 +04:00
|
|
|
static const char * const addrlist[] =
|
1996-02-14 01:07:57 +03:00
|
|
|
{all_es_snpa, all_is_snpa, all_l1is_snpa, all_l2is_snpa, 0};
|
2004-04-19 09:16:45 +04:00
|
|
|
struct ifreq ifr;
|
2005-05-30 01:27:45 +04:00
|
|
|
const char *const *cpp;
|
1994-05-13 10:08:03 +04:00
|
|
|
|
2005-05-30 01:27:45 +04:00
|
|
|
(void)memset(&ifr, 0, sizeof(ifr));
|
|
|
|
for (cpp = addrlist; *cpp; cpp++) {
|
|
|
|
(void)memcpy(ifr.ifr_addr.sa_data, *cpp, 6);
|
*** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.
Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)
Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.
Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.
Return consistent, appropriate error codes from network drivers.
Improve readability. KNF.
*** Details ***
In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.
In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.
Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.
In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.
Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:
switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}
Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,
switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}
unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).
In ipw(4), remove an if_set_sadl() call that is out of place.
In nfe(4), reuse the jumbo MTU logic in ether_ioctl().
Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.
Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.
Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.
Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.
In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.
Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.
In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.
Let ifioctl_common() handle SIOCGIFADDR.
Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.
In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.
bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 03:20:01 +03:00
|
|
|
if (req == RTM_ADD &&
|
|
|
|
(*ifp->if_ioctl)(ifp, SIOCADDMULTI, &ifr) != 0)
|
1999-06-30 07:32:40 +04:00
|
|
|
printf("iso_setmcasts: %s unable to add mcast\n",
|
|
|
|
ifp->if_xname);
|
*** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.
Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)
Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.
Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.
Return consistent, appropriate error codes from network drivers.
Improve readability. KNF.
*** Details ***
In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.
In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.
Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.
In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.
Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:
switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}
Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,
switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}
unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).
In ipw(4), remove an if_set_sadl() call that is out of place.
In nfe(4), reuse the jumbo MTU logic in ether_ioctl().
Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.
Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.
Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.
Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.
In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.
Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.
In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.
Let ifioctl_common() handle SIOCGIFADDR.
Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.
In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.
bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 03:20:01 +03:00
|
|
|
else if (req == RTM_DELETE &&
|
|
|
|
(*ifp->if_ioctl)(ifp, SIOCDELMULTI, &ifr) != 0)
|
1999-06-30 07:32:40 +04:00
|
|
|
printf("iso_setmcasts: %s unable to delete mcast\n",
|
1996-10-11 03:12:43 +04:00
|
|
|
ifp->if_xname);
|
1994-05-13 10:08:03 +04:00
|
|
|
}
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
|
|
|
* FUNCTION: iso_snparesolve
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Resolve an iso address into snpa address
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: 0 if addr is resolved
|
|
|
|
* errno if addr is unknown
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES: Now that we have folded the snpa cache into the routing
|
|
|
|
* table, we know there is no snpa address known for this
|
|
|
|
* destination. If we know of a default IS, then the
|
|
|
|
* address of the IS is returned. If no IS is known,
|
|
|
|
* then return the multi-cast address for "all ES" for
|
|
|
|
* this interface.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NB: the last case described above constitutes the
|
|
|
|
* query configuration function 9542, sec 6.5
|
|
|
|
* A mechanism is needed to prevent this function from
|
|
|
|
* being invoked if the system is an IS.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
2004-04-19 09:16:45 +04:00
|
|
|
iso_snparesolve(
|
|
|
|
struct ifnet *ifp, /* outgoing interface */
|
KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.
Cosmetic: don't open-code TAILQ_FOREACH().
Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.
Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.
Constify:
1 Introduce const accessor for route->ro_dst, rtcache_getdst().
2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.
3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.
4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
2007-02-18 01:34:07 +03:00
|
|
|
const struct sockaddr_iso *dest, /* destination */
|
2007-03-04 08:59:00 +03:00
|
|
|
void * snpa, /* RESULT: snpa to be used */
|
2004-04-19 09:16:45 +04:00
|
|
|
int *snpa_len) /* RESULT: length of snpa */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
struct llinfo_llc *sc; /* ptr to snpa table entry */
|
2005-05-30 01:27:45 +04:00
|
|
|
const char *found_snpa;
|
1996-02-14 01:07:57 +03:00
|
|
|
int addrlen;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
/*
|
1996-02-14 01:07:57 +03:00
|
|
|
* This hack allows us to send esis packets that have the destination
|
|
|
|
* snpa addresss embedded in the destination nsap address
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
if (dest->siso_data[0] == AFI_SNA) {
|
|
|
|
/*
|
|
|
|
* This is a subnetwork address. Return it immediately
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SNPA]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_snparesolve: return SN address\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
addrlen = dest->siso_nlen - 1; /* subtract size of AFI */
|
2005-05-30 01:27:45 +04:00
|
|
|
found_snpa = (const char *)dest->siso_data + 1;
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* If we are an IS, we can't do much with the packet; Check
|
|
|
|
* if we know about an IS.
|
|
|
|
*/
|
1993-04-09 16:00:07 +04:00
|
|
|
} else if (iso_systype != SNPA_IS && known_is != 0 &&
|
1996-02-14 01:07:57 +03:00
|
|
|
(sc = (struct llinfo_llc *) known_is->rt_llinfo) &&
|
|
|
|
(sc->lc_flags & SNPA_VALID)) {
|
2007-08-11 03:55:54 +04:00
|
|
|
const struct sockaddr_dl *sdl = satocsdl(known_is->rt_gateway);
|
|
|
|
found_snpa = CLLADDR(sdl);
|
1993-04-09 16:00:07 +04:00
|
|
|
addrlen = sdl->sdl_alen;
|
|
|
|
} else if (ifp->if_flags & IFF_BROADCAST) {
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* no IS, no match. Return "all es" multicast address for
|
|
|
|
* this interface, as per Query Configuration Function (9542
|
|
|
|
* sec 6.5)
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* Note: there is a potential problem here. If the destination
|
|
|
|
* is on the subnet and it does not respond with a ESH, but
|
|
|
|
* does send back a TP CC, a connection could be established
|
|
|
|
* where we always transmit the CLNP packet to "all es"
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
addrlen = ifp->if_addrlen;
|
2005-05-30 01:27:45 +04:00
|
|
|
found_snpa = (const char *) all_es_snpa;
|
1993-04-09 16:00:07 +04:00
|
|
|
} else
|
|
|
|
return (ENETUNREACH);
|
2005-05-30 01:27:45 +04:00
|
|
|
memcpy(snpa, found_snpa, *snpa_len = addrlen);
|
1993-04-09 16:00:07 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: snpac_free
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: free an entry in the iso address map table
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: nothing
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES: If there is a route entry associated with cache
|
|
|
|
* entry, then delete that as well
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
2004-04-19 09:16:45 +04:00
|
|
|
snpac_free(
|
|
|
|
struct llinfo_llc *lc) /* entry to free */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct rtentry *rt = lc->lc_rt;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if (known_is == rt)
|
|
|
|
known_is = 0;
|
|
|
|
if (rt && (rt->rt_flags & RTF_UP) &&
|
1996-02-14 01:07:57 +03:00
|
|
|
(rt->rt_flags & (RTF_DYNAMIC | RTF_MODIFIED))) {
|
|
|
|
RTFREE(rt);
|
Take steps to hide the radix_node implementation of the forwarding table
from the forwarding table's users:
Introduce rt_walktree() for walking the routing table and
applying a function to each rtentry. Replace most
rn_walktree() calls with it.
Use rt_getkey()/rt_setkey() to get/set a route's destination.
Keep a pointer to the sockaddr key in the rtentry, so that
rtentry users do not have to grovel in the radix_node for
the key.
Add a RTM_GET method to rtrequest. Use that instead of
radix_node lookups in, e.g., carp(4).
Add sys/net/link_proto.c, which supplies sockaddr routines for
link-layer socket addresses (sockaddr_dl).
Cosmetic:
Constify. KNF. Stop open-coding LIST_FOREACH, TAILQ_FOREACH,
et cetera. Use NULL instead of 0 for null pointers. Use
__arraycount(). Reduce gratuitous parenthesization.
Stop using variadic arguments for rip6_output(), it is
unnecessary.
Remove the unnecessary rtentry member rt_genmask and the
code to maintain it, since nothing actually used it.
Make rt_maskedcopy() easier to read by using meaningful variable
names.
Extract a subroutine intern_netmask() for looking up a netmask in
the masks table.
Start converting backslash-ridden IPv6 macros in
sys/netinet6/in6_var.h into inline subroutines that one
can read without special eyeglasses.
One functional change: when the kernel serves an RTM_GET, RTM_LOCK,
or RTM_CHANGE request, it applies the netmask (if supplied) to a
destination before searching for it in the forwarding table.
I have changed sys/netinet/ip_carp.c, carp_setroute(), to remove
the unlawful radix_node knowledge.
Apart from the changes to carp(4), netiso, ATM, and strip(4), I
have run the changes on three nodes in my wireless routing testbed,
which involves IPv4 + IPv6 dynamic routing acrobatics, and it's
working beautifully so far.
2007-07-20 00:48:52 +04:00
|
|
|
rtrequest(RTM_DELETE, rt_getkey(rt), rt->rt_gateway,
|
|
|
|
rt_mask(rt), rt->rt_flags, NULL);
|
1993-04-09 16:00:07 +04:00
|
|
|
RTFREE(rt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: snpac_add
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Add an entry to the snpa cache
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES: If entry already exists, then update holding time.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
2004-04-19 09:16:45 +04:00
|
|
|
snpac_add(
|
|
|
|
struct ifnet *ifp, /* interface info is related to */
|
|
|
|
struct iso_addr *nsap, /* nsap to add */
|
2007-03-04 08:59:00 +03:00
|
|
|
void * snpa, /* translation */
|
2004-04-19 09:16:45 +04:00
|
|
|
int type, /* SNPA_IS or SNPA_ES */
|
|
|
|
u_short ht, /* holding time (in seconds) */
|
|
|
|
int nsellength) /* nsaps may differ only in trailing
|
1996-02-14 01:07:57 +03:00
|
|
|
* bytes */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct llinfo_llc *lc;
|
|
|
|
struct rtentry *rt;
|
1996-02-14 01:07:57 +03:00
|
|
|
struct rtentry *mrt = 0;
|
2000-03-30 16:51:13 +04:00
|
|
|
struct iso_addr *r; /* for zap_isoaddr macro */
|
1996-02-14 01:07:57 +03:00
|
|
|
int snpalen = min(ifp->if_addrlen, MAX_SNPALEN);
|
|
|
|
int new_entry = 0, index = ifp->if_index, iftype = ifp->if_type;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SNPA]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("snpac_add(%p, %p, %p, %x, %x, %x)\n",
|
1996-10-11 03:12:43 +04:00
|
|
|
ifp, nsap, snpa, type, ht, nsellength);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
zap_isoaddr(dst, nsap);
|
1995-06-13 11:13:14 +04:00
|
|
|
rt = rtalloc1(sisotosa(&dst), 0);
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SNPA]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("snpac_add: rtalloc1 returns %p\n", rt);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
if (rt == 0) {
|
|
|
|
struct sockaddr *netmask;
|
1996-02-14 01:07:57 +03:00
|
|
|
int flags;
|
|
|
|
add:
|
1993-04-09 16:00:07 +04:00
|
|
|
if (nsellength) {
|
1996-02-14 01:07:57 +03:00
|
|
|
netmask = sisotosa(&msk);
|
|
|
|
flags = RTF_UP;
|
1993-04-09 16:00:07 +04:00
|
|
|
snpac_fixdstandmask(nsellength);
|
|
|
|
} else {
|
1996-02-14 01:07:57 +03:00
|
|
|
netmask = 0;
|
|
|
|
flags = RTF_UP | RTF_HOST;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
new_entry = 1;
|
Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.
Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.
Avoid using sizeof(struct sockaddr_dl) in the kernel.
Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.
Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().
Constify: LLADDR() -> CLLADDR().
Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.
2007-08-30 06:17:34 +04:00
|
|
|
sockaddr_dl_init(>e_dl, sizeof(gte_dl), index, iftype,
|
|
|
|
NULL, 0, snpa, snpalen);
|
|
|
|
|
1995-06-13 11:13:14 +04:00
|
|
|
if (rtrequest(RTM_ADD, sisotosa(&dst), S(gte_dl), netmask,
|
1996-02-14 01:07:57 +03:00
|
|
|
flags, &mrt) || mrt == 0)
|
1993-04-09 16:00:07 +04:00
|
|
|
return (0);
|
|
|
|
rt = mrt;
|
|
|
|
rt->rt_refcnt--;
|
|
|
|
} else {
|
2007-08-11 03:55:54 +04:00
|
|
|
struct sockaddr_dl *sdl = satosdl(rt->rt_gateway);
|
1993-04-09 16:00:07 +04:00
|
|
|
rt->rt_refcnt--;
|
|
|
|
if ((rt->rt_flags & RTF_LLINFO) == 0)
|
|
|
|
goto add;
|
|
|
|
if (nsellength && (rt->rt_flags & RTF_HOST)) {
|
|
|
|
if (rt->rt_refcnt == 0) {
|
1995-06-13 11:13:14 +04:00
|
|
|
rtrequest(RTM_DELETE, sisotosa(&dst),
|
2008-10-25 01:50:08 +04:00
|
|
|
NULL, NULL, 0, NULL);
|
1993-04-09 16:00:07 +04:00
|
|
|
rt = 0;
|
|
|
|
goto add;
|
|
|
|
} else {
|
1996-02-14 01:07:57 +03:00
|
|
|
static struct iso_addr nsap2;
|
2000-03-30 16:51:13 +04:00
|
|
|
char *cp;
|
1993-04-09 16:00:07 +04:00
|
|
|
nsap2 = *nsap;
|
|
|
|
cp = nsap2.isoa_genaddr + nsap->isoa_len - nsellength;
|
1996-02-14 01:07:57 +03:00
|
|
|
while (cp < (char *) (1 + &nsap2))
|
1993-04-09 16:00:07 +04:00
|
|
|
*cp++ = 0;
|
|
|
|
(void) snpac_add(ifp, &nsap2, snpa, type, ht, nsellength);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sdl->sdl_family != AF_LINK || sdl->sdl_alen == 0) {
|
1996-02-14 01:07:57 +03:00
|
|
|
int old_sdl_len = sdl->sdl_len;
|
1993-04-09 16:00:07 +04:00
|
|
|
if (old_sdl_len < sizeof(*sdl)) {
|
|
|
|
log(LOG_DEBUG, "snpac_add: cant make room for lladdr\n");
|
|
|
|
return (0);
|
|
|
|
}
|
Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.
Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.
Avoid using sizeof(struct sockaddr_dl) in the kernel.
Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.
Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().
Constify: LLADDR() -> CLLADDR().
Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.
2007-08-30 06:17:34 +04:00
|
|
|
sockaddr_dl_init(sdl, sdl->sdl_len, index, iftype,
|
|
|
|
NULL, 0, snpa, snpalen);
|
1993-04-09 16:00:07 +04:00
|
|
|
new_entry = 1;
|
|
|
|
}
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
if ((lc = (struct llinfo_llc *) rt->rt_llinfo) == 0)
|
1993-04-09 16:00:07 +04:00
|
|
|
panic("snpac_rtrequest");
|
2006-06-08 02:33:33 +04:00
|
|
|
rt->rt_rmx.rmx_expire = ht + time_second;
|
1993-04-09 16:00:07 +04:00
|
|
|
lc->lc_flags = SNPA_VALID | type;
|
1994-05-13 10:08:03 +04:00
|
|
|
if ((type & SNPA_IS) && !(iso_systype & SNPA_IS))
|
1993-04-09 16:00:07 +04:00
|
|
|
snpac_logdefis(rt);
|
|
|
|
return (new_entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-04-19 09:16:45 +04:00
|
|
|
snpac_fixdstandmask(int nsellength)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
char *cp = msk.siso_data, *cplim;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
cplim = cp + (dst.siso_nlen -= nsellength);
|
1996-02-14 01:07:57 +03:00
|
|
|
msk.siso_len = cplim - (char *) &msk;
|
1993-04-09 16:00:07 +04:00
|
|
|
msk.siso_nlen = 0;
|
|
|
|
while (cp < cplim)
|
|
|
|
*cp++ = -1;
|
1996-02-14 01:07:57 +03:00
|
|
|
while (cp < (char *) msk.siso_pad)
|
1993-04-09 16:00:07 +04:00
|
|
|
*cp++ = 0;
|
1996-02-14 01:07:57 +03:00
|
|
|
for (cp = dst.siso_data + dst.siso_nlen; cp < (char *) dst.siso_pad;)
|
1993-04-09 16:00:07 +04:00
|
|
|
*cp++ = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: snpac_ioctl
|
|
|
|
*
|
|
|
|
* PURPOSE: Set/Get the system type and esis parameters
|
|
|
|
*
|
|
|
|
* RETURNS: 0 on success, or unix error code
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES:
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
2004-04-19 09:16:45 +04:00
|
|
|
snpac_ioctl(
|
2006-11-16 04:32:37 +03:00
|
|
|
struct socket *so,
|
2004-04-19 09:16:45 +04:00
|
|
|
u_long cmd, /* ioctl to process */
|
2007-03-04 08:59:00 +03:00
|
|
|
void *data, /* data for the cmd */
|
2005-12-11 15:16:03 +03:00
|
|
|
struct lwp *l)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct systype_req *rq = (struct systype_req *) data;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_IOCTL]) {
|
1993-04-09 16:00:07 +04:00
|
|
|
if (cmd == SIOCSSTYPE)
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("snpac_ioctl: cmd set, type x%x, ht %d, ct %d\n",
|
1996-10-11 03:12:43 +04:00
|
|
|
rq->sr_type, rq->sr_holdt, rq->sr_configt);
|
1993-04-09 16:00:07 +04:00
|
|
|
else
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("snpac_ioctl: cmd get\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if (cmd == SIOCSSTYPE) {
|
2009-04-17 01:37:17 +04:00
|
|
|
int error;
|
|
|
|
|
|
|
|
if (l == NULL)
|
|
|
|
error = EACCES;
|
|
|
|
else
|
|
|
|
error = kauth_authorize_network(l->l_cred,
|
|
|
|
KAUTH_NETWORK_SOCKET,
|
|
|
|
KAUTH_REQ_NETWORK_SOCKET_SETPRIV, so,
|
|
|
|
KAUTH_ARG(cmd), NULL);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1996-02-14 01:07:57 +03:00
|
|
|
if ((rq->sr_type & (SNPA_ES | SNPA_IS)) == (SNPA_ES | SNPA_IS))
|
|
|
|
return (EINVAL);
|
1993-04-09 16:00:07 +04:00
|
|
|
if (rq->sr_type & SNPA_ES) {
|
|
|
|
iso_systype = SNPA_ES;
|
|
|
|
} else if (rq->sr_type & SNPA_IS) {
|
|
|
|
iso_systype = SNPA_IS;
|
|
|
|
} else {
|
1996-02-14 01:07:57 +03:00
|
|
|
return (EINVAL);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
esis_holding_time = rq->sr_holdt;
|
|
|
|
esis_config_time = rq->sr_configt;
|
|
|
|
if (esis_esconfig_time != rq->sr_esconfigt) {
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_stop(&esis_config_ch);
|
1993-04-09 16:00:07 +04:00
|
|
|
esis_esconfig_time = rq->sr_esconfigt;
|
1996-02-14 01:07:57 +03:00
|
|
|
esis_config(NULL);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
} else if (cmd == SIOCGSTYPE) {
|
|
|
|
rq->sr_type = iso_systype;
|
|
|
|
rq->sr_holdt = esis_holding_time;
|
|
|
|
rq->sr_configt = esis_config_time;
|
|
|
|
rq->sr_esconfigt = esis_esconfig_time;
|
|
|
|
} else {
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: snpac_logdefis
|
|
|
|
*
|
|
|
|
* PURPOSE: Mark the IS passed as the default IS
|
|
|
|
*
|
|
|
|
* RETURNS: nothing
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES:
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
2004-04-19 09:16:45 +04:00
|
|
|
snpac_logdefis(struct rtentry *sc)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct rtentry *rt;
|
1994-05-13 10:08:03 +04:00
|
|
|
|
|
|
|
if (known_is == sc || !(sc->rt_flags & RTF_HOST))
|
1993-04-09 16:00:07 +04:00
|
|
|
return;
|
1994-05-13 10:08:03 +04:00
|
|
|
if (known_is) {
|
|
|
|
RTFREE(known_is);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1994-05-13 10:08:03 +04:00
|
|
|
known_is = sc;
|
|
|
|
sc->rt_refcnt++;
|
1996-02-14 01:07:57 +03:00
|
|
|
rt = rtalloc1((struct sockaddr *) & zsi, 0);
|
Take steps to hide the radix_node implementation of the forwarding table
from the forwarding table's users:
Introduce rt_walktree() for walking the routing table and
applying a function to each rtentry. Replace most
rn_walktree() calls with it.
Use rt_getkey()/rt_setkey() to get/set a route's destination.
Keep a pointer to the sockaddr key in the rtentry, so that
rtentry users do not have to grovel in the radix_node for
the key.
Add a RTM_GET method to rtrequest. Use that instead of
radix_node lookups in, e.g., carp(4).
Add sys/net/link_proto.c, which supplies sockaddr routines for
link-layer socket addresses (sockaddr_dl).
Cosmetic:
Constify. KNF. Stop open-coding LIST_FOREACH, TAILQ_FOREACH,
et cetera. Use NULL instead of 0 for null pointers. Use
__arraycount(). Reduce gratuitous parenthesization.
Stop using variadic arguments for rip6_output(), it is
unnecessary.
Remove the unnecessary rtentry member rt_genmask and the
code to maintain it, since nothing actually used it.
Make rt_maskedcopy() easier to read by using meaningful variable
names.
Extract a subroutine intern_netmask() for looking up a netmask in
the masks table.
Start converting backslash-ridden IPv6 macros in
sys/netinet6/in6_var.h into inline subroutines that one
can read without special eyeglasses.
One functional change: when the kernel serves an RTM_GET, RTM_LOCK,
or RTM_CHANGE request, it applies the netmask (if supplied) to a
destination before searching for it in the forwarding table.
I have changed sys/netinet/ip_carp.c, carp_setroute(), to remove
the unlawful radix_node knowledge.
Apart from the changes to carp(4), netiso, ATM, and strip(4), I
have run the changes on three nodes in my wireless routing testbed,
which involves IPv4 + IPv6 dynamic routing acrobatics, and it's
working beautifully so far.
2007-07-20 00:48:52 +04:00
|
|
|
if (rt == 0) {
|
|
|
|
rtrequest(RTM_ADD, sisotosa(&zsi), rt_getkey(sc),
|
2008-10-25 01:50:08 +04:00
|
|
|
sisotosa(&zmk), RTF_DYNAMIC | RTF_GATEWAY, NULL);
|
Take steps to hide the radix_node implementation of the forwarding table
from the forwarding table's users:
Introduce rt_walktree() for walking the routing table and
applying a function to each rtentry. Replace most
rn_walktree() calls with it.
Use rt_getkey()/rt_setkey() to get/set a route's destination.
Keep a pointer to the sockaddr key in the rtentry, so that
rtentry users do not have to grovel in the radix_node for
the key.
Add a RTM_GET method to rtrequest. Use that instead of
radix_node lookups in, e.g., carp(4).
Add sys/net/link_proto.c, which supplies sockaddr routines for
link-layer socket addresses (sockaddr_dl).
Cosmetic:
Constify. KNF. Stop open-coding LIST_FOREACH, TAILQ_FOREACH,
et cetera. Use NULL instead of 0 for null pointers. Use
__arraycount(). Reduce gratuitous parenthesization.
Stop using variadic arguments for rip6_output(), it is
unnecessary.
Remove the unnecessary rtentry member rt_genmask and the
code to maintain it, since nothing actually used it.
Make rt_maskedcopy() easier to read by using meaningful variable
names.
Extract a subroutine intern_netmask() for looking up a netmask in
the masks table.
Start converting backslash-ridden IPv6 macros in
sys/netinet6/in6_var.h into inline subroutines that one
can read without special eyeglasses.
One functional change: when the kernel serves an RTM_GET, RTM_LOCK,
or RTM_CHANGE request, it applies the netmask (if supplied) to a
destination before searching for it in the forwarding table.
I have changed sys/netinet/ip_carp.c, carp_setroute(), to remove
the unlawful radix_node knowledge.
Apart from the changes to carp(4), netiso, ATM, and strip(4), I
have run the changes on three nodes in my wireless routing testbed,
which involves IPv4 + IPv6 dynamic routing acrobatics, and it's
working beautifully so far.
2007-07-20 00:48:52 +04:00
|
|
|
} else {
|
1996-02-14 01:07:57 +03:00
|
|
|
if ((rt->rt_flags & RTF_DYNAMIC) &&
|
1994-05-13 10:08:03 +04:00
|
|
|
(rt->rt_flags & RTF_GATEWAY) && rt_mask(rt)->sa_len == 0)
|
Take steps to hide the radix_node implementation of the forwarding table
from the forwarding table's users:
Introduce rt_walktree() for walking the routing table and
applying a function to each rtentry. Replace most
rn_walktree() calls with it.
Use rt_getkey()/rt_setkey() to get/set a route's destination.
Keep a pointer to the sockaddr key in the rtentry, so that
rtentry users do not have to grovel in the radix_node for
the key.
Add a RTM_GET method to rtrequest. Use that instead of
radix_node lookups in, e.g., carp(4).
Add sys/net/link_proto.c, which supplies sockaddr routines for
link-layer socket addresses (sockaddr_dl).
Cosmetic:
Constify. KNF. Stop open-coding LIST_FOREACH, TAILQ_FOREACH,
et cetera. Use NULL instead of 0 for null pointers. Use
__arraycount(). Reduce gratuitous parenthesization.
Stop using variadic arguments for rip6_output(), it is
unnecessary.
Remove the unnecessary rtentry member rt_genmask and the
code to maintain it, since nothing actually used it.
Make rt_maskedcopy() easier to read by using meaningful variable
names.
Extract a subroutine intern_netmask() for looking up a netmask in
the masks table.
Start converting backslash-ridden IPv6 macros in
sys/netinet6/in6_var.h into inline subroutines that one
can read without special eyeglasses.
One functional change: when the kernel serves an RTM_GET, RTM_LOCK,
or RTM_CHANGE request, it applies the netmask (if supplied) to a
destination before searching for it in the forwarding table.
I have changed sys/netinet/ip_carp.c, carp_setroute(), to remove
the unlawful radix_node knowledge.
Apart from the changes to carp(4), netiso, ATM, and strip(4), I
have run the changes on three nodes in my wireless routing testbed,
which involves IPv4 + IPv6 dynamic routing acrobatics, and it's
working beautifully so far.
2007-07-20 00:48:52 +04:00
|
|
|
rt_setgate(rt, rt_getkey(sc));
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: snpac_age
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Time out snpac entries
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES: When encountering an entry for the first time, snpac_age
|
|
|
|
* may delete up to SNPAC_AGE too many seconds. Ie.
|
|
|
|
* if the entry is added a moment before snpac_age is
|
|
|
|
* called, the entry will immediately have SNPAC_AGE
|
|
|
|
* seconds taken off the holding time, even though
|
|
|
|
* it has only been held a brief moment.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* The proper way to do this is set an expiry timeval
|
|
|
|
* equal to current time + holding time. Then snpac_age
|
|
|
|
* would time out entries where expiry date is older
|
|
|
|
* than the current time.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
/*ARGSUSED*/
|
1993-09-06 22:02:44 +04:00
|
|
|
void
|
2006-11-16 04:32:37 +03:00
|
|
|
snpac_age(void *v)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct llinfo_llc *lc, *nlc;
|
|
|
|
struct rtentry *rt;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&snpac_age_ch, SNPAC_AGE * hz, snpac_age, NULL);
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1995-06-13 12:12:33 +04:00
|
|
|
for (lc = llinfo_llc.lh_first; lc != 0; lc = nlc) {
|
|
|
|
nlc = lc->lc_list.le_next;
|
1994-05-13 10:08:03 +04:00
|
|
|
if (lc->lc_flags & SNPA_VALID) {
|
1993-04-09 16:00:07 +04:00
|
|
|
rt = lc->lc_rt;
|
2006-06-08 02:33:33 +04:00
|
|
|
if (rt->rt_rmx.rmx_expire &&
|
|
|
|
rt->rt_rmx.rmx_expire < time_second)
|
1993-04-09 16:00:07 +04:00
|
|
|
snpac_free(lc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: snpac_ownmulti
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Determine if the snpa address is a multicast address
|
|
|
|
* of the same type as the system.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: true or false
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES: Used by interface drivers when not in eavesdrop mode
|
|
|
|
* as interm kludge until
|
|
|
|
* real multicast addresses can be configured
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
2007-03-04 08:59:00 +03:00
|
|
|
snpac_ownmulti(void *snpa, u_int len)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
|
|
|
return (((iso_systype & SNPA_ES) &&
|
2005-05-30 01:27:45 +04:00
|
|
|
(!memcmp(snpa, all_es_snpa, len))) ||
|
1996-02-14 01:07:57 +03:00
|
|
|
((iso_systype & SNPA_IS) &&
|
2005-05-30 01:27:45 +04:00
|
|
|
(!memcmp(snpa, all_is_snpa, len))));
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: snpac_flushifp
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Flush entries associated with specific ifp
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: nothing
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES:
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
2004-04-19 09:16:45 +04:00
|
|
|
snpac_flushifp(struct ifnet *ifp)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct llinfo_llc *lc;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1995-06-13 12:12:33 +04:00
|
|
|
for (lc = llinfo_llc.lh_first; lc != 0; lc = lc->lc_list.le_next) {
|
1993-04-09 16:00:07 +04:00
|
|
|
if (lc->lc_rt->rt_ifp == ifp && (lc->lc_flags & SNPA_VALID))
|
|
|
|
snpac_free(lc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: snpac_rtrequest
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Make a routing request
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: nothing
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES: In the future, this should make a request of a user
|
|
|
|
* level routing daemon.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
2004-04-19 09:16:45 +04:00
|
|
|
snpac_rtrequest(int req, struct iso_addr *host, struct iso_addr *gateway,
|
|
|
|
struct iso_addr *netmask, int flags, struct rtentry **ret_nrt)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct iso_addr *r;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_SNPA]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("snpac_rtrequest: ");
|
1993-04-09 16:00:07 +04:00
|
|
|
if (req == RTM_ADD)
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("add");
|
1993-04-09 16:00:07 +04:00
|
|
|
else if (req == RTM_DELETE)
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("delete");
|
1996-02-14 01:07:57 +03:00
|
|
|
else
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("unknown command");
|
|
|
|
printf(" dst: %s\n", clnp_iso_addrp(host));
|
|
|
|
printf("\tgateway: %s\n", clnp_iso_addrp(gateway));
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
|
|
|
|
zap_isoaddr(dst, host);
|
|
|
|
zap_isoaddr(gte, gateway);
|
|
|
|
if (netmask) {
|
|
|
|
zap_isoaddr(msk, netmask);
|
|
|
|
msk.siso_nlen = 0;
|
1996-02-14 01:07:57 +03:00
|
|
|
msk.siso_len = msk.siso_pad - (u_char *) & msk;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1995-06-13 11:13:14 +04:00
|
|
|
rtrequest(req, sisotosa(&dst), sisotosa(>e),
|
1996-02-14 01:07:57 +03:00
|
|
|
(netmask ? sisotosa(&msk) : (struct sockaddr *) 0), flags, ret_nrt);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: snpac_addrt
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Associate a routing entry with an snpac entry
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: nothing
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES: If a cache entry exists for gateway, then
|
|
|
|
* make a routing entry (host, gateway) and associate
|
|
|
|
* with gateway.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* If a route already exists and is different, first delete
|
|
|
|
* it.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* This could be made more efficient by checking
|
|
|
|
* the existing route before adding a new one.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
2006-11-16 04:32:37 +03:00
|
|
|
snpac_addrt(struct ifnet *ifp, struct iso_addr *host,
|
2006-10-12 05:30:41 +04:00
|
|
|
struct iso_addr *gateway, struct iso_addr *netmask)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct iso_addr *r;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
zap_isoaddr(dst, host);
|
|
|
|
zap_isoaddr(gte, gateway);
|
|
|
|
if (netmask) {
|
|
|
|
zap_isoaddr(msk, netmask);
|
|
|
|
msk.siso_nlen = 0;
|
1996-02-14 01:07:57 +03:00
|
|
|
msk.siso_len = msk.siso_pad - (u_char *) & msk;
|
1995-06-13 11:13:14 +04:00
|
|
|
rtredirect(sisotosa(&dst), sisotosa(>e), sisotosa(&msk),
|
1996-02-14 01:07:57 +03:00
|
|
|
RTF_DONE, sisotosa(>e), 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
} else
|
1996-02-14 01:07:57 +03:00
|
|
|
rtredirect(sisotosa(&dst), sisotosa(>e), (struct sockaddr *) 0,
|
|
|
|
RTF_DONE | RTF_HOST, sisotosa(>e), 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* ISO */
|