2007-03-04 08:59:00 +03:00
|
|
|
/* $NetBSD: if_eon.c,v 1.57 2007/03/04 06:03:32 christos 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
|
|
|
* @(#)if_eon.c 8.2 (Berkeley) 1/9/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
|
|
|
|
*/
|
|
|
|
/*
|
1996-02-14 01:07:57 +03:00
|
|
|
* EON rfc
|
1993-04-09 16:00:07 +04:00
|
|
|
* Layer between IP and CLNL
|
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* Put together a current rfc986 address format and get the right offset
|
|
|
|
* for the nsel
|
|
|
|
*/
|
|
|
|
|
2001-11-13 03:56:55 +03:00
|
|
|
#include <sys/cdefs.h>
|
2007-03-04 08:59:00 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: if_eon.c,v 1.57 2007/03/04 06:03:32 christos Exp $");
|
2001-11-13 03:56:55 +03:00
|
|
|
|
1998-07-05 05:06:49 +04:00
|
|
|
#include "opt_eon.h"
|
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
#ifdef EON
|
|
|
|
#define NEON 1
|
|
|
|
|
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/protosw.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
|
1996-05-10 02:29:25 +04:00
|
|
|
#include <machine/cpu.h> /* XXX for setsoftnet(). This must die. */
|
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_types.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/netisr.h>
|
|
|
|
#include <net/route.h>
|
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
#include <net/if_ether.h>
|
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/ip_var.h>
|
|
|
|
|
|
|
|
#include <netiso/iso.h>
|
|
|
|
#include <netiso/iso_var.h>
|
|
|
|
#include <netiso/iso_snpac.h>
|
|
|
|
#include <netiso/argo_debug.h>
|
|
|
|
#include <netiso/iso_errno.h>
|
|
|
|
#include <netiso/eonvar.h>
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#include <machine/stdarg.h>
|
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
#define EOK 0
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
struct ifnet eonif[1];
|
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
|
|
|
eonprotoinit(void)
|
1996-02-14 01:07:57 +03:00
|
|
|
{
|
1993-04-09 16:00:07 +04:00
|
|
|
(void) eonattach();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct eon_llinfo eon_llinfo;
|
|
|
|
#define PROBE_OK 0;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: eonattach
|
|
|
|
*
|
|
|
|
* PURPOSE: autoconf attach routine
|
|
|
|
*
|
|
|
|
* RETURNS: void
|
|
|
|
*/
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
2004-04-19 09:16:45 +04:00
|
|
|
eonattach(void)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct ifnet *ifp = eonif;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_EON]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("eonattach()\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
2004-04-21 22:40:37 +04:00
|
|
|
snprintf(ifp->if_xname, sizeof(ifp->if_xname), "eon%d", 0);
|
1996-02-14 01:07:57 +03:00
|
|
|
ifp->if_mtu = ETHERMTU;
|
1996-05-07 06:40:22 +04:00
|
|
|
ifp->if_softc = NULL;
|
1996-02-14 01:07:57 +03:00
|
|
|
/* since everything will go out over ether or token ring */
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
ifp->if_ioctl = eonioctl;
|
|
|
|
ifp->if_output = eonoutput;
|
|
|
|
ifp->if_type = IFT_EON;
|
|
|
|
ifp->if_addrlen = 5;
|
|
|
|
ifp->if_hdrlen = EONIPLEN;
|
|
|
|
ifp->if_flags = IFF_BROADCAST;
|
|
|
|
if_attach(ifp);
|
2001-01-17 03:30:49 +03:00
|
|
|
if_alloc_sadl(ifp);
|
2007-03-04 08:59:00 +03:00
|
|
|
eonioctl(ifp, SIOCSIFADDR, (void *) ifp->if_addrlist.tqh_first);
|
1996-02-14 01:07:57 +03:00
|
|
|
eon_llinfo.el_qhdr.link =
|
1993-04-09 16:00:07 +04:00
|
|
|
eon_llinfo.el_qhdr.rlink = &(eon_llinfo.el_qhdr);
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_EON]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("eonattach()\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: eonioctl
|
|
|
|
*
|
|
|
|
* PURPOSE: io controls - ifconfig
|
1996-02-14 01:07:57 +03:00
|
|
|
* need commands to
|
1993-04-09 16:00:07 +04:00
|
|
|
* link-UP (core addr) (flags: ES, IS)
|
|
|
|
* link-DOWN (core addr) (flags: ES, IS)
|
|
|
|
* must be callable from kernel or user
|
|
|
|
*
|
|
|
|
* RETURNS: nothing
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
2007-03-04 08:59:00 +03:00
|
|
|
eonioctl(struct ifnet *ifp, u_long cmd, void *data)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2004-04-19 09:16:45 +04:00
|
|
|
int s = splnet();
|
2000-03-30 16:51:13 +04:00
|
|
|
int error = 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_EON]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("eonioctl (cmd 0x%lx) \n", cmd);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
switch (cmd) {
|
2000-03-30 16:51:13 +04:00
|
|
|
struct ifaddr *ifa;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
case SIOCSIFADDR:
|
1996-02-14 01:07:57 +03:00
|
|
|
if ((ifa = (struct ifaddr *) data) != NULL) {
|
1993-04-09 16:00:07 +04:00
|
|
|
ifp->if_flags |= IFF_UP;
|
|
|
|
if (ifa->ifa_addr->sa_family != AF_LINK)
|
|
|
|
ifa->ifa_rtrequest = eonrtrequest;
|
|
|
|
}
|
|
|
|
break;
|
1998-01-16 21:54:10 +03:00
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
splx(s);
|
1996-02-14 01:07:57 +03:00
|
|
|
return (error);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
2005-05-31 02:14:52 +04:00
|
|
|
eoniphdr(struct eon_iphdr *hdr, const void *loc, struct route *ro,
|
|
|
|
int class, int zero)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
struct mbuf mhead;
|
2000-03-30 16:51:13 +04:00
|
|
|
struct sockaddr_in *sin = satosin(&ro->ro_dst);
|
1993-04-09 16:00:07 +04:00
|
|
|
if (zero) {
|
2007-01-29 09:55:41 +03:00
|
|
|
memset(hdr, 0, sizeof(*hdr));
|
|
|
|
memset(ro, 0, sizeof(*ro));
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
sin->sin_family = AF_INET;
|
1996-02-14 01:07:57 +03:00
|
|
|
sin->sin_len = sizeof(*sin);
|
2005-05-31 02:14:52 +04:00
|
|
|
(void)memcpy(&sin->sin_addr, loc, sizeof(struct in_addr));
|
2006-12-16 00:18:52 +03:00
|
|
|
/* XXX Does this check make any sense? */
|
|
|
|
rtcache_check(ro);
|
Here are various changes designed to protect against bad IPv4
routing caused by stale route caches (struct route). Route caches
are sprinkled throughout PCBs, the IP fast-forwarding table, and
IP tunnel interfaces (gre, gif, stf).
Stale IPv6 and ISO route caches will be treated by separate patches.
Thank you to Christoph Badura for suggesting the general approach
to invalidating route caches that I take here.
Here are the details:
Add hooks to struct domain for tracking and for invalidating each
domain's route caches: dom_rtcache, dom_rtflush, and dom_rtflushall.
Introduce helper subroutines, rtflush(ro) for invalidating a route
cache, rtflushall(family) for invalidating all route caches in a
routing domain, and rtcache(ro) for notifying the domain of a new
cached route.
Chain together all IPv4 route caches where ro_rt != NULL. Provide
in_rtcache() for adding a route to the chain. Provide in_rtflush()
and in_rtflushall() for invalidating IPv4 route caches. In
in_rtflush(), set ro_rt to NULL, and remove the route from the
chain. In in_rtflushall(), walk the chain and remove every route
cache.
In rtrequest1(), call rtflushall() to invalidate route caches when
a route is added.
In gif(4), discard the workaround for stale caches that involves
expiring them every so often.
Replace the pattern 'RTFREE(ro->ro_rt); ro->ro_rt = NULL;' with a
call to rtflush(ro).
Update ipflow_fastforward() and all other users of route caches so
that they expect a cached route, ro->ro_rt, to turn to NULL.
Take care when moving a 'struct route' to rtflush() the source and
to rtcache() the destination.
In domain initializers, use .dom_xxx tags.
KNF here and there.
2006-12-09 08:33:04 +03:00
|
|
|
if (ro->ro_rt != NULL) {
|
1995-06-13 11:13:14 +04:00
|
|
|
struct sockaddr_in *dst = satosin(rt_key(ro->ro_rt));
|
2006-12-16 00:18:52 +03:00
|
|
|
if (sin->sin_addr.s_addr != dst->sin_addr.s_addr)
|
|
|
|
rtcache_free(ro);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
2006-12-16 00:18:52 +03:00
|
|
|
if (ro->ro_rt == NULL)
|
|
|
|
rtcache_init(ro);
|
Here are various changes designed to protect against bad IPv4
routing caused by stale route caches (struct route). Route caches
are sprinkled throughout PCBs, the IP fast-forwarding table, and
IP tunnel interfaces (gre, gif, stf).
Stale IPv6 and ISO route caches will be treated by separate patches.
Thank you to Christoph Badura for suggesting the general approach
to invalidating route caches that I take here.
Here are the details:
Add hooks to struct domain for tracking and for invalidating each
domain's route caches: dom_rtcache, dom_rtflush, and dom_rtflushall.
Introduce helper subroutines, rtflush(ro) for invalidating a route
cache, rtflushall(family) for invalidating all route caches in a
routing domain, and rtcache(ro) for notifying the domain of a new
cached route.
Chain together all IPv4 route caches where ro_rt != NULL. Provide
in_rtcache() for adding a route to the chain. Provide in_rtflush()
and in_rtflushall() for invalidating IPv4 route caches. In
in_rtflush(), set ro_rt to NULL, and remove the route from the
chain. In in_rtflushall(), walk the chain and remove every route
cache.
In rtrequest1(), call rtflushall() to invalidate route caches when
a route is added.
In gif(4), discard the workaround for stale caches that involves
expiring them every so often.
Replace the pattern 'RTFREE(ro->ro_rt); ro->ro_rt = NULL;' with a
call to rtflush(ro).
Update ipflow_fastforward() and all other users of route caches so
that they expect a cached route, ro->ro_rt, to turn to NULL.
Take care when moving a 'struct route' to rtflush() the source and
to rtcache() the destination.
In domain initializers, use .dom_xxx tags.
KNF here and there.
2006-12-09 08:33:04 +03:00
|
|
|
if (ro->ro_rt != NULL)
|
1993-04-09 16:00:07 +04:00
|
|
|
ro->ro_rt->rt_use++;
|
|
|
|
hdr->ei_ip.ip_dst = sin->sin_addr;
|
|
|
|
hdr->ei_ip.ip_p = IPPROTO_EON;
|
1996-02-14 01:07:57 +03:00
|
|
|
hdr->ei_ip.ip_ttl = MAXTTL;
|
1993-04-09 16:00:07 +04:00
|
|
|
hdr->ei_eh.eonh_class = class;
|
|
|
|
hdr->ei_eh.eonh_vers = EON_VERSION;
|
|
|
|
hdr->ei_eh.eonh_csum = 0;
|
2007-03-04 08:59:00 +03:00
|
|
|
mhead.m_data = (void *)&hdr->ei_eh;
|
1993-04-09 16:00:07 +04:00
|
|
|
mhead.m_len = sizeof(struct eon_hdr);
|
2007-01-29 09:55:41 +03:00
|
|
|
mhead.m_next = NULL;
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_EON]) {
|
1999-03-04 05:38:31 +03:00
|
|
|
printf("eonoutput : gen csum (%p, offset %lu, datalen %ld)\n",
|
|
|
|
&mhead, (unsigned long)offsetof(struct eon_hdr, eonh_csum),
|
1996-11-24 00:13:18 +03:00
|
|
|
(long)sizeof(struct eon_hdr));
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
iso_gen_csum(&mhead,
|
1998-01-28 05:35:10 +03:00
|
|
|
offsetof(struct eon_hdr, eonh_csum), sizeof(struct eon_hdr));
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* FUNCTION: eonrtrequest
|
|
|
|
*
|
|
|
|
* PURPOSE: maintains list of direct eon recipients.
|
|
|
|
* sets up IP route for rest.
|
|
|
|
*
|
|
|
|
* RETURNS: nothing
|
|
|
|
*/
|
1994-05-13 10:08:03 +04:00
|
|
|
void
|
2004-04-19 09:16:45 +04:00
|
|
|
eonrtrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
unsigned long zerodst = 0;
|
2005-05-31 02:14:52 +04:00
|
|
|
const void *ipaddrloc = &zerodst;
|
2000-03-30 16:51:13 +04:00
|
|
|
struct eon_llinfo *el = (struct eon_llinfo *) rt->rt_llinfo;
|
2004-04-21 08:17:28 +04:00
|
|
|
const struct sockaddr *gate;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Common Housekeeping
|
|
|
|
*/
|
|
|
|
switch (cmd) {
|
|
|
|
case RTM_DELETE:
|
|
|
|
if (el) {
|
2007-01-29 09:55:41 +03:00
|
|
|
remque(&el->el_qhdr);
|
2006-12-16 00:18:52 +03:00
|
|
|
rtcache_free(&el->el_iproute);
|
1993-04-09 16:00:07 +04:00
|
|
|
Free(el);
|
2007-01-29 09:55:41 +03:00
|
|
|
rt->rt_llinfo = NULL;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
case RTM_ADD:
|
|
|
|
case RTM_RESOLVE:
|
2004-12-04 19:10:25 +03:00
|
|
|
rt->rt_rmx.rmx_mtu = lo0ifp->if_mtu; /* unless better below */
|
1993-04-09 16:00:07 +04:00
|
|
|
R_Malloc(el, struct eon_llinfo *, sizeof(*el));
|
2007-03-04 08:59:00 +03:00
|
|
|
rt->rt_llinfo = (void *) el;
|
2007-01-29 09:55:41 +03:00
|
|
|
if (el == NULL)
|
1993-04-09 16:00:07 +04:00
|
|
|
return;
|
2007-01-29 09:55:41 +03:00
|
|
|
memset(el, 0, sizeof(*el));
|
|
|
|
insque(&el->el_qhdr, &eon_llinfo.el_qhdr);
|
1993-04-09 16:00:07 +04:00
|
|
|
el->el_rt = rt;
|
|
|
|
break;
|
|
|
|
}
|
2007-01-29 09:55:41 +03:00
|
|
|
if (info != NULL &&
|
|
|
|
(gate = info->rti_info[RTAX_GATEWAY]) != NULL) { /*XXX*/
|
1996-02-14 01:07:57 +03:00
|
|
|
switch (gate->sa_family) {
|
1993-04-09 16:00:07 +04:00
|
|
|
case AF_LINK:
|
2005-05-31 02:14:52 +04:00
|
|
|
#define SDL(x) ((const struct sockaddr_dl *)x)
|
|
|
|
#define SIN(x) ((const struct sockaddr_in *)x)
|
1994-05-13 10:08:03 +04:00
|
|
|
if (SDL(gate)->sdl_alen == 1)
|
2005-05-31 02:14:52 +04:00
|
|
|
el->el_snpaoffset = *(const u_char *)CLLADDR(SDL(gate));
|
1993-04-09 16:00:07 +04:00
|
|
|
else
|
2005-05-31 02:14:52 +04:00
|
|
|
ipaddrloc = CLLADDR(SDL(gate));
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
case AF_INET:
|
2005-05-31 02:14:52 +04:00
|
|
|
ipaddrloc = &SIN(gate)->sin_addr;
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
2007-01-29 09:55:41 +03:00
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
el->el_flags |= RTF_UP;
|
|
|
|
eoniphdr(&el->el_ei, ipaddrloc, &el->el_iproute, EON_NORMAL_ADDR, 0);
|
2006-12-06 03:50:34 +03:00
|
|
|
if (el->el_iproute.ro_rt != NULL)
|
1993-04-09 16:00:07 +04:00
|
|
|
rt->rt_rmx.rmx_mtu = el->el_iproute.ro_rt->rt_rmx.rmx_mtu
|
1996-02-14 01:07:57 +03:00
|
|
|
- sizeof(el->el_ei);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: eonoutput
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: prepend an eon header and hand to IP
|
|
|
|
* ARGUMENTS: (ifp) is points to the ifnet structure for this
|
|
|
|
* unit/device (m) is an mbuf *, *m is a CLNL packet
|
|
|
|
* (dst) is a destination address - have to interp. as
|
|
|
|
* multicast or broadcast or real address.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: unix error code
|
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
|
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
|
|
|
eonoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *sdst,
|
2004-04-19 09:16:45 +04:00
|
|
|
struct rtentry *rt)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
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 *dst = (const struct sockaddr_iso *)sdst;
|
2000-03-30 16:51:13 +04:00
|
|
|
struct eon_llinfo *el;
|
|
|
|
struct eon_iphdr *ei;
|
1996-02-14 01:07:57 +03:00
|
|
|
struct route *ro;
|
|
|
|
int datalen;
|
|
|
|
struct mbuf *mh;
|
|
|
|
int error = 0, class = 0, alen = 0;
|
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 u_char *ipaddrloc = NULL;
|
1993-04-09 16:00:07 +04:00
|
|
|
static struct eon_iphdr eon_iphdr;
|
|
|
|
static struct route route;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_EON]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("eonoutput \n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
ifp->if_opackets++;
|
2007-01-29 09:55:41 +03:00
|
|
|
if (rt == NULL || (el = (struct eon_llinfo *)rt->rt_llinfo) == NULL) {
|
1993-04-09 16:00:07 +04:00
|
|
|
if (dst->siso_family == AF_LINK) {
|
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_dl *sdl =
|
|
|
|
(const struct sockaddr_dl *)dst;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
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
|
|
|
ipaddrloc = CLLADDR(sdl);
|
1993-04-09 16:00:07 +04:00
|
|
|
alen = sdl->sdl_alen;
|
1996-02-14 01:07:57 +03:00
|
|
|
} else if (dst->siso_family == AF_ISO &&
|
|
|
|
dst->siso_data[0] == AFI_SNA) {
|
1993-04-09 16:00:07 +04:00
|
|
|
alen = dst->siso_nlen - 1;
|
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
|
|
|
ipaddrloc = (const char *)dst->siso_data + 1;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
switch (alen) {
|
|
|
|
case 5:
|
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
|
|
|
class = ipaddrloc[4];
|
1993-04-09 16:00:07 +04:00
|
|
|
case 4:
|
|
|
|
ro = &route;
|
|
|
|
ei = &eon_iphdr;
|
|
|
|
eoniphdr(ei, ipaddrloc, ro, class, 1);
|
|
|
|
goto send;
|
|
|
|
}
|
|
|
|
einval:
|
1996-02-14 01:07:57 +03:00
|
|
|
error = EINVAL;
|
1993-04-09 16:00:07 +04:00
|
|
|
goto flush;
|
|
|
|
}
|
|
|
|
if ((el->el_flags & RTF_UP) == 0) {
|
2001-01-17 18:13:37 +03:00
|
|
|
eonrtrequest(RTM_CHANGE, rt, (struct rt_addrinfo *) 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
if ((el->el_flags & RTF_UP) == 0) {
|
|
|
|
error = EHOSTUNREACH;
|
|
|
|
goto flush;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((m->m_flags & M_PKTHDR) == 0) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("eon: got non headered packet\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
goto einval;
|
|
|
|
}
|
|
|
|
ei = &el->el_ei;
|
|
|
|
ro = &el->el_iproute;
|
2007-01-29 09:55:41 +03:00
|
|
|
if (el->el_snpaoffset == 0)
|
|
|
|
;
|
|
|
|
else if (dst->siso_family == AF_ISO) {
|
|
|
|
memcpy(&ei->ei_ip.ip_dst, &dst->siso_data[el->el_snpaoffset],
|
|
|
|
sizeof(ei->ei_ip.ip_dst));
|
|
|
|
} else
|
|
|
|
goto einval;
|
1993-04-09 16:00:07 +04:00
|
|
|
send:
|
|
|
|
/* put an eon_hdr in the buffer, prepended by an ip header */
|
|
|
|
datalen = m->m_pkthdr.len + EONIPLEN;
|
2002-08-14 04:23:27 +04:00
|
|
|
if (datalen > IP_MAXPACKET) {
|
|
|
|
error = EMSGSIZE;
|
|
|
|
goto flush;
|
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
MGETHDR(mh, M_DONTWAIT, MT_HEADER);
|
2007-01-29 09:55:41 +03:00
|
|
|
if (mh == NULL) {
|
2002-08-14 04:23:27 +04:00
|
|
|
error = ENOBUFS;
|
1993-04-09 16:00:07 +04:00
|
|
|
goto flush;
|
2002-08-14 04:23:27 +04:00
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
mh->m_next = m;
|
|
|
|
m = mh;
|
|
|
|
MH_ALIGN(m, sizeof(struct eon_iphdr));
|
|
|
|
m->m_len = sizeof(struct eon_iphdr);
|
2002-08-14 04:23:27 +04:00
|
|
|
m->m_pkthdr.len = datalen;
|
|
|
|
ei->ei_ip.ip_len = htons(datalen);
|
|
|
|
ifp->if_obytes += datalen;
|
1993-04-09 16:00:07 +04:00
|
|
|
*mtod(m, struct eon_iphdr *) = *ei;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_EON]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("eonoutput dst ip addr : %x\n", ei->ei_ip.ip_dst.s_addr);
|
|
|
|
printf("eonoutput ip_output : eonip header:\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_buf(ei, sizeof(struct eon_iphdr));
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
2007-01-29 09:55:41 +03:00
|
|
|
error = ip_output(m, NULL, ro, 0, NULL, NULL);
|
|
|
|
m = NULL;
|
1993-04-09 16:00:07 +04:00
|
|
|
if (error) {
|
|
|
|
ifp->if_oerrors++;
|
|
|
|
ifp->if_opackets--;
|
|
|
|
ifp->if_obytes -= datalen;
|
|
|
|
}
|
|
|
|
flush:
|
2007-01-29 09:55:41 +03:00
|
|
|
if (m != NULL)
|
1993-04-09 16:00:07 +04:00
|
|
|
m_freem(m);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
|
|
|
eoninput(struct mbuf *m, ...)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
int iphlen;
|
2000-03-30 16:51:13 +04:00
|
|
|
struct eon_hdr *eonhdr;
|
|
|
|
struct ip *iphdr;
|
1996-02-14 01:07:57 +03:00
|
|
|
struct ifnet *eonifp;
|
|
|
|
int s;
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, m);
|
|
|
|
iphlen = va_arg(ap, int);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
eonifp = &eonif[0]; /* kludge - really want to give CLNP the ifp
|
|
|
|
* for eon, not for the real device */
|
|
|
|
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_EON]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("eoninput() %p m_data %p m_len 0x%x dequeued\n",
|
1996-10-11 03:12:43 +04:00
|
|
|
m, (m ? m->m_data : 0), m ? m->m_len : 0);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
2007-01-29 09:55:41 +03:00
|
|
|
if (m == NULL)
|
1993-04-09 16:00:07 +04:00
|
|
|
return;
|
1996-02-14 01:07:57 +03:00
|
|
|
if (iphlen > sizeof(struct ip))
|
2007-01-29 09:55:41 +03:00
|
|
|
ip_stripoptions(m, NULL);
|
1993-04-09 16:00:07 +04:00
|
|
|
if (m->m_len < EONIPLEN) {
|
2007-01-29 09:55:41 +03:00
|
|
|
if ((m = m_pullup(m, EONIPLEN)) == NULL) {
|
1993-04-09 16:00:07 +04:00
|
|
|
IncStat(es_badhdr);
|
1996-02-14 01:07:57 +03:00
|
|
|
drop:
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_EON]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("eoninput: DROP \n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
eonifp->if_ierrors++;
|
1993-04-09 16:00:07 +04:00
|
|
|
m_freem(m);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eonif->if_ibytes += m->m_pkthdr.len;
|
|
|
|
iphdr = mtod(m, struct ip *);
|
|
|
|
/* do a few checks for debugging */
|
1996-02-14 01:07:57 +03:00
|
|
|
if (iphdr->ip_p != IPPROTO_EON) {
|
1993-04-09 16:00:07 +04:00
|
|
|
IncStat(es_badhdr);
|
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
/* temporarily drop ip header from the mbuf */
|
|
|
|
m->m_data += sizeof(struct ip);
|
|
|
|
eonhdr = mtod(m, struct eon_hdr *);
|
1996-02-14 01:07:57 +03:00
|
|
|
if (iso_check_csum(m, sizeof(struct eon_hdr)) != EOK) {
|
1993-04-09 16:00:07 +04:00
|
|
|
IncStat(es_badcsum);
|
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
m->m_data -= sizeof(struct ip);
|
1996-02-14 01:07:57 +03:00
|
|
|
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_EON]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("eoninput csum ok class 0x%x\n", eonhdr->eonh_class);
|
|
|
|
printf("eoninput: eon header:\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_buf(eonhdr, sizeof(struct eon_hdr));
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
/* checks for debugging */
|
1996-02-14 01:07:57 +03:00
|
|
|
if (eonhdr->eonh_vers != EON_VERSION) {
|
1993-04-09 16:00:07 +04:00
|
|
|
IncStat(es_badhdr);
|
|
|
|
goto drop;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
m->m_flags &= ~(M_BCAST | M_MCAST);
|
|
|
|
switch (eonhdr->eonh_class) {
|
|
|
|
case EON_BROADCAST:
|
|
|
|
IncStat(es_in_broad);
|
|
|
|
m->m_flags |= M_BCAST;
|
|
|
|
break;
|
|
|
|
case EON_NORMAL_ADDR:
|
|
|
|
IncStat(es_in_normal);
|
|
|
|
break;
|
|
|
|
case EON_MULTICAST_ES:
|
|
|
|
IncStat(es_in_multi_es);
|
|
|
|
m->m_flags |= M_MCAST;
|
|
|
|
break;
|
|
|
|
case EON_MULTICAST_IS:
|
|
|
|
IncStat(es_in_multi_is);
|
|
|
|
m->m_flags |= M_MCAST;
|
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
eonifp->if_ipackets++;
|
|
|
|
|
|
|
|
{
|
|
|
|
/* put it on the CLNP queue and set soft interrupt */
|
1996-02-14 01:07:57 +03:00
|
|
|
struct ifqueue *ifq;
|
|
|
|
extern struct ifqueue clnlintrq;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
m->m_pkthdr.rcvif = eonifp; /* KLUDGE */
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_EON]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("eoninput to clnl IFQ\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
ifq = &clnlintrq;
|
2001-04-14 03:29:55 +04:00
|
|
|
s = splnet();
|
1993-04-09 16:00:07 +04:00
|
|
|
if (IF_QFULL(ifq)) {
|
|
|
|
IF_DROP(ifq);
|
|
|
|
m_freem(m);
|
|
|
|
eonifp->if_iqdrops++;
|
|
|
|
eonifp->if_ipackets--;
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
IF_ENQUEUE(ifq, m);
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_EON]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf(
|
1996-10-11 03:12:43 +04:00
|
|
|
"%p enqueued on clnp Q: m_len 0x%x m_type 0x%x m_data %p\n",
|
|
|
|
m, m->m_len, m->m_type, m->m_data);
|
2007-03-04 08:59:00 +03:00
|
|
|
dump_buf(mtod(m, void *), m->m_len);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
schednetisr(NETISR_ISO);
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
void *
|
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
|
|
|
eonctlinput(int cmd, const struct sockaddr *sa, void *dummy)
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
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_in *sin = (const struct sockaddr_in *)sa;
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_EON]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("eonctlinput: cmd 0x%x addr: ", cmd);
|
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
|
|
|
dump_isoaddr((const struct sockaddr_iso *)sin);
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
2003-09-30 04:01:18 +04:00
|
|
|
if ((unsigned)cmd >= PRC_NCMDS)
|
1996-02-14 01:07:57 +03:00
|
|
|
return NULL;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
IncStat(es_icmp[cmd]);
|
|
|
|
switch (cmd) {
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
case PRC_QUENCH:
|
|
|
|
case PRC_QUENCH2:
|
|
|
|
/* TODO: set the dec bit */
|
|
|
|
break;
|
|
|
|
case PRC_TIMXCEED_REASS:
|
|
|
|
case PRC_ROUTEDEAD:
|
|
|
|
case PRC_HOSTUNREACH:
|
|
|
|
case PRC_UNREACH_NET:
|
|
|
|
case PRC_IFDOWN:
|
|
|
|
case PRC_UNREACH_HOST:
|
|
|
|
case PRC_HOSTDEAD:
|
|
|
|
case PRC_TIMXCEED_INTRANS:
|
|
|
|
/* TODO: mark the link down */
|
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
case PRC_UNREACH_PROTOCOL:
|
|
|
|
case PRC_UNREACH_PORT:
|
|
|
|
case PRC_UNREACH_SRCFAIL:
|
|
|
|
case PRC_REDIRECT_NET:
|
|
|
|
case PRC_REDIRECT_HOST:
|
|
|
|
case PRC_REDIRECT_TOSNET:
|
|
|
|
case PRC_REDIRECT_TOSHOST:
|
|
|
|
case PRC_MSGSIZE:
|
|
|
|
case PRC_PARAMPROB:
|
1996-10-11 03:12:43 +04:00
|
|
|
#if 0
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("eonctlinput: ICMP cmd 0x%x\n", cmd );
|
1996-10-11 03:12:43 +04:00
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
return NULL;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|