Update to latest code from CSRG.
This commit is contained in:
parent
4fec83b441
commit
9ee311ead5
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rtsock.c,v 1.15 1995/08/17 02:57:23 mycroft Exp $ */
|
||||
/* $NetBSD: rtsock.c,v 1.16 1995/08/19 07:48:14 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1991, 1993
|
||||
@ -32,7 +32,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)rtsock.c 8.3 (Berkeley) 1/4/94
|
||||
* @(#)rtsock.c 8.6 (Berkeley) 2/11/95
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -133,6 +133,7 @@ route_output(m, so)
|
||||
register struct rt_msghdr *rtm = 0;
|
||||
register struct rtentry *rt = 0;
|
||||
struct rtentry *saved_nrt = 0;
|
||||
struct radix_node_head *rnh;
|
||||
struct rt_addrinfo info;
|
||||
int len, error = 0;
|
||||
struct ifnet *ifp = 0;
|
||||
@ -167,7 +168,7 @@ route_output(m, so)
|
||||
senderr(EINVAL);
|
||||
if (genmask) {
|
||||
struct radix_node *t;
|
||||
t = rn_addmask((caddr_t)genmask, 1, 2);
|
||||
t = rn_addmask((caddr_t)genmask, 0, 1);
|
||||
if (t && Bcmp(genmask, t->rn_key, *(u_char *)genmask) == 0)
|
||||
genmask = (struct sockaddr *)(t->rn_key);
|
||||
else
|
||||
@ -190,34 +191,27 @@ route_output(m, so)
|
||||
|
||||
case RTM_DELETE:
|
||||
error = rtrequest(RTM_DELETE, dst, gate, netmask,
|
||||
rtm->rtm_flags, (struct rtentry **)0);
|
||||
rtm->rtm_flags, &saved_nrt);
|
||||
if (error == 0) {
|
||||
(rt = saved_nrt)->rt_refcnt++;
|
||||
goto report;
|
||||
}
|
||||
break;
|
||||
|
||||
case RTM_GET:
|
||||
case RTM_CHANGE:
|
||||
case RTM_LOCK:
|
||||
rt = rtalloc1(dst, 0);
|
||||
if (rt == 0)
|
||||
if ((rnh = rt_tables[dst->sa_family]) == 0) {
|
||||
senderr(EAFNOSUPPORT);
|
||||
} else if (rt = (struct rtentry *)
|
||||
rnh->rnh_lookup(dst, netmask, rnh))
|
||||
rt->rt_refcnt++;
|
||||
else
|
||||
senderr(ESRCH);
|
||||
if (rtm->rtm_type != RTM_GET) {/* XXX: too grotty */
|
||||
struct radix_node *rn;
|
||||
extern struct radix_node_head *mask_rnhead;
|
||||
|
||||
if (Bcmp(dst, rt_key(rt), dst->sa_len) != 0)
|
||||
senderr(ESRCH);
|
||||
if (netmask && (rn = rn_search(netmask,
|
||||
mask_rnhead->rnh_treetop)))
|
||||
netmask = (struct sockaddr *)rn->rn_key;
|
||||
for (rn = rt->rt_nodes; rn; rn = rn->rn_dupedkey)
|
||||
if (netmask == (struct sockaddr *)rn->rn_mask)
|
||||
break;
|
||||
if (rn == 0)
|
||||
senderr(ETOOMANYREFS);
|
||||
rt = (struct rtentry *)rn;
|
||||
}
|
||||
switch(rtm->rtm_type) {
|
||||
|
||||
case RTM_GET:
|
||||
report:
|
||||
dst = rt_key(rt);
|
||||
gate = rt->rt_gateway;
|
||||
netmask = rt_mask(rt);
|
||||
@ -226,13 +220,17 @@ route_output(m, so)
|
||||
if (ifp = rt->rt_ifp) {
|
||||
ifpaddr = ifp->if_addrlist.tqh_first->ifa_addr;
|
||||
ifaaddr = rt->rt_ifa->ifa_addr;
|
||||
if (ifp->if_flags & IFF_POINTOPOINT)
|
||||
brdaddr = rt->rt_ifa->ifa_dstaddr;
|
||||
else
|
||||
brdaddr = 0;
|
||||
rtm->rtm_index = ifp->if_index;
|
||||
} else {
|
||||
ifpaddr = 0;
|
||||
ifaaddr = 0;
|
||||
}
|
||||
}
|
||||
len = rt_msg2(RTM_GET, &info, (caddr_t)0,
|
||||
len = rt_msg2(rtm->rtm_type, &info, (caddr_t)0,
|
||||
(struct walkarg *)0);
|
||||
if (len > rtm->rtm_msglen) {
|
||||
struct rt_msghdr *new_rtm;
|
||||
@ -242,7 +240,7 @@ route_output(m, so)
|
||||
Bcopy(rtm, new_rtm, rtm->rtm_msglen);
|
||||
Free(rtm); rtm = new_rtm;
|
||||
}
|
||||
(void)rt_msg2(RTM_GET, &info, (caddr_t)rtm,
|
||||
(void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm,
|
||||
(struct walkarg *)0);
|
||||
rtm->rtm_flags = rt->rt_flags;
|
||||
rtm->rtm_rmx = rt->rt_rmx;
|
||||
@ -353,7 +351,7 @@ rt_setmetrics(which, in, out)
|
||||
}
|
||||
|
||||
#define ROUNDUP(a) \
|
||||
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
|
||||
((a) > 0 ? (1 + (((a) - 1) | (sizeof(int32_t) - 1))) : sizeof(int32_t))
|
||||
#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
|
||||
|
||||
static void
|
||||
@ -687,6 +685,12 @@ sysctl_dumpentry(rn, w)
|
||||
gate = rt->rt_gateway;
|
||||
netmask = rt_mask(rt);
|
||||
genmask = rt->rt_genmask;
|
||||
if (rt->rt_ifp) {
|
||||
ifpaddr = rt->rt_ifp->if_addrlist.tqh_first->ifa_addr;
|
||||
ifaaddr = rt->rt_ifa->ifa_addr;
|
||||
if (rt->rt_ifp->if_flags & IFF_POINTOPOINT)
|
||||
brdaddr = rt->rt_ifa->ifa_dstaddr;
|
||||
}
|
||||
size = rt_msg2(RTM_GET, &info, 0, w);
|
||||
if (w->w_where && w->w_tmem) {
|
||||
register struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem;
|
||||
|
Loading…
Reference in New Issue
Block a user