1998-03-01 05:20:01 +03:00
|
|
|
/* $NetBSD: esis.c,v 1.19 1998/03/01 02:24:45 fvdl 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.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* 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
|
|
|
* @(#)esis.c 8.3 (Berkeley) 3/20/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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef ISO
|
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#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/kernel.h>
|
1996-05-22 17:54:55 +04:00
|
|
|
#include <sys/proc.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>
|
|
|
|
#include <net/raw_cb.h>
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <netiso/iso.h>
|
|
|
|
#include <netiso/iso_pcb.h>
|
|
|
|
#include <netiso/iso_var.h>
|
|
|
|
#include <netiso/iso_snpac.h>
|
|
|
|
#include <netiso/clnl.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
|
|
|
#include <machine/stdarg.h>
|
1996-09-08 18:28:08 +04:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
|
|
|
* Global variables to esis implementation
|
|
|
|
*
|
|
|
|
* esis_holding_time - the holding time (sec) parameter for outgoing pdus
|
|
|
|
* esis_config_time - the frequency (sec) that hellos are generated
|
1996-02-14 01:07:57 +03:00
|
|
|
* esis_esconfig_time - suggested es configuration time placed in the ish.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
|
|
|
*/
|
1995-06-13 11:58:10 +04:00
|
|
|
LIST_HEAD(, rawcb) esis_pcb;
|
1996-02-14 01:07:57 +03:00
|
|
|
int esis_sendspace = 2048;
|
|
|
|
int esis_recvspace = 2048;
|
|
|
|
short esis_holding_time = ESIS_HT;
|
|
|
|
short esis_config_time = ESIS_CONFIG;
|
|
|
|
short esis_esconfig_time = ESIS_CONFIG;
|
|
|
|
extern int iso_systype;
|
|
|
|
struct sockaddr_dl esis_dl = {sizeof(esis_dl), AF_LINK};
|
|
|
|
extern char all_es_snpa[], all_is_snpa[];
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
#define EXTEND_PACKET(m, mhdr, cp)\
|
|
|
|
if (((m)->m_next = m_getclr(M_DONTWAIT, MT_HEADER)) == NULL) {\
|
|
|
|
esis_stat.es_nomem++;\
|
|
|
|
m_freem(mhdr);\
|
|
|
|
return;\
|
|
|
|
} else {\
|
|
|
|
(m) = (m)->m_next;\
|
|
|
|
(cp) = mtod((m), caddr_t);\
|
1998-03-01 05:20:01 +03:00
|
|
|
(m)->m_len = 0;\
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1994-05-13 10:08:03 +04:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
|
|
|
* FUNCTION: esis_init
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Initialize the kernel portion of esis protocol
|
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
|
|
|
*/
|
1994-05-13 10:08:03 +04:00
|
|
|
void
|
1993-04-09 16:00:07 +04:00
|
|
|
esis_init()
|
|
|
|
{
|
|
|
|
extern struct clnl_protosw clnl_protox[256];
|
|
|
|
|
1995-06-13 11:58:10 +04:00
|
|
|
LIST_INIT(&esis_pcb);
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
timeout(snpac_age, (caddr_t) 0, hz);
|
|
|
|
timeout(esis_config, (caddr_t) 0, hz);
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
clnl_protox[ISO9542_ESIS].clnl_input = esis_input;
|
|
|
|
clnl_protox[ISO10589_ISIS].clnl_input = isis_input;
|
|
|
|
#ifdef ISO_X25ESIS
|
|
|
|
clnl_protox[ISO9542X25_ESIS].clnl_input = x25esis_input;
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* ISO_X25ESIS */
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: esis_usrreq
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Handle user level esis requests
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: 0 or appropriate errno
|
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
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
1996-05-22 17:54:55 +04:00
|
|
|
esis_usrreq(so, req, m, nam, control, p)
|
|
|
|
struct socket *so;
|
|
|
|
int req;
|
|
|
|
struct mbuf *m, *nam, *control;
|
|
|
|
struct proc *p;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-09-08 18:28:08 +04:00
|
|
|
struct rawcb *rp;
|
|
|
|
int error = 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-09-08 18:28:08 +04:00
|
|
|
if (req == PRU_CONTROL)
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
|
|
|
|
rp = sotorawcb(so);
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (req != PRU_SEND && req != PRU_SENDOOB && control)
|
|
|
|
panic("esis_usrreq: unexpected control mbuf");
|
|
|
|
#endif
|
|
|
|
if (rp == 0 && req != PRU_ATTACH) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EINVAL;
|
|
|
|
goto release;
|
|
|
|
}
|
1996-09-08 18:28:08 +04:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
switch (req) {
|
1996-09-08 18:28:08 +04:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
case PRU_ATTACH:
|
1996-09-08 18:28:08 +04:00
|
|
|
if (rp != 0) {
|
|
|
|
error = EISCONN;
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
}
|
1996-09-08 18:28:08 +04:00
|
|
|
if (p == 0 || (error = suser(p->p_ucred, &p->p_acflag))) {
|
|
|
|
error = EACCES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = soreserve(so, esis_sendspace, esis_recvspace);
|
1996-09-08 18:28:08 +04:00
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
MALLOC(rp, struct rawcb *, sizeof(*rp), M_PCB, M_WAITOK);
|
|
|
|
if (rp == 0) {
|
1993-04-09 16:00:07 +04:00
|
|
|
error = ENOBUFS;
|
1996-09-08 18:28:08 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
bzero(rp, sizeof(*rp));
|
|
|
|
rp->rcb_socket = so;
|
|
|
|
LIST_INSERT_HEAD(&esis_pcb, rp, rcb_list);
|
|
|
|
so->so_pcb = rp;
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_SEND:
|
1996-09-08 18:28:08 +04:00
|
|
|
if (control && control->m_len) {
|
|
|
|
m_freem(control);
|
|
|
|
m_freem(m);
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
if (nam == NULL) {
|
1996-09-08 18:28:08 +04:00
|
|
|
m_freem(m);
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* error checking here */
|
1996-02-14 01:07:57 +03:00
|
|
|
error = isis_output(m, mtod(nam, struct sockaddr_dl *));
|
1996-09-08 18:28:08 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_SENDOOB:
|
|
|
|
m_freem(control);
|
|
|
|
m_freem(m);
|
|
|
|
error = EOPNOTSUPP;
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_DETACH:
|
|
|
|
raw_detach(rp);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_SHUTDOWN:
|
|
|
|
socantsendmore(so);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PRU_SENSE:
|
1996-09-08 18:28:08 +04:00
|
|
|
/*
|
|
|
|
* stat: don't bother with a blocksize.
|
|
|
|
*/
|
1993-04-09 16:00:07 +04:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
default:
|
1996-09-08 18:28:08 +04:00
|
|
|
error = EOPNOTSUPP;
|
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
1996-09-08 18:28:08 +04:00
|
|
|
release:
|
1993-04-09 16:00:07 +04:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: esis_input
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Process an incoming esis packet
|
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
|
|
|
*/
|
1994-05-13 10:08:03 +04:00
|
|
|
void
|
1996-02-14 01:07:57 +03:00
|
|
|
#if __STDC__
|
|
|
|
esis_input(struct mbuf *m0, ...)
|
|
|
|
#else
|
|
|
|
esis_input(m0, va_alist)
|
|
|
|
struct mbuf *m0;
|
|
|
|
va_dcl
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
struct snpa_hdr *shp; /* subnetwork header */
|
|
|
|
register struct esis_fixed *pdu = mtod(m0, struct esis_fixed *);
|
|
|
|
register int type;
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, m0);
|
|
|
|
shp = va_arg(ap, struct snpa_hdr *);
|
|
|
|
va_end(ap);
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* check checksum if necessary
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
if (ESIS_CKSUM_REQUIRED(pdu) &&
|
|
|
|
iso_check_csum(m0, (int) pdu->esis_hdr_len)) {
|
1993-04-09 16:00:07 +04:00
|
|
|
esis_stat.es_badcsum++;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
/* check version */
|
|
|
|
if (pdu->esis_vers != ESIS_VERSION) {
|
|
|
|
esis_stat.es_badvers++;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
type = pdu->esis_type & 0x1f;
|
|
|
|
switch (type) {
|
1996-02-14 01:07:57 +03:00
|
|
|
case ESIS_ESH:
|
|
|
|
esis_eshinput(m0, shp);
|
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
case ESIS_ISH:
|
|
|
|
esis_ishinput(m0, shp);
|
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
case ESIS_RD:
|
|
|
|
esis_rdinput(m0, shp);
|
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
default:
|
|
|
|
esis_stat.es_badtype++;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bad:
|
1995-06-13 11:58:10 +04:00
|
|
|
if (esis_pcb.lh_first != 0)
|
1993-04-09 16:00:07 +04:00
|
|
|
isis_input(m0, shp);
|
|
|
|
else
|
|
|
|
m_freem(m0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: esis_rdoutput
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Transmit a redirect pdu
|
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: Assumes there is enough space for fixed part of header,
|
|
|
|
* DA, BSNPA and NET in first mbuf.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
1993-04-09 16:00:07 +04:00
|
|
|
esis_rdoutput(inbound_shp, inbound_m, inbound_oidx, rd_dstnsap, rt)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct snpa_hdr *inbound_shp; /* snpa hdr from incoming packet */
|
|
|
|
struct mbuf *inbound_m; /* incoming pkt itself */
|
|
|
|
struct clnp_optidx *inbound_oidx; /* clnp options assoc with
|
|
|
|
* incoming pkt */
|
|
|
|
struct iso_addr *rd_dstnsap; /* ultimate destination of pkt */
|
|
|
|
struct rtentry *rt; /* snpa cache info regarding next hop of pkt */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
struct mbuf *m, *m0;
|
|
|
|
caddr_t cp;
|
|
|
|
struct esis_fixed *pdu;
|
|
|
|
int len;
|
|
|
|
struct sockaddr_iso siso;
|
|
|
|
struct ifnet *ifp = inbound_shp->snh_ifp;
|
1993-04-09 16:00:07 +04:00
|
|
|
struct sockaddr_dl *sdl;
|
|
|
|
struct iso_addr *rd_gwnsap;
|
|
|
|
|
|
|
|
if (rt->rt_flags & RTF_GATEWAY) {
|
1995-06-13 11:13:14 +04:00
|
|
|
rd_gwnsap = &satosiso(rt->rt_gateway)->siso_addr;
|
1993-04-09 16:00:07 +04:00
|
|
|
rt = rtalloc1(rt->rt_gateway, 0);
|
|
|
|
} else
|
1995-06-13 11:13:14 +04:00
|
|
|
rd_gwnsap = &satosiso(rt_key(rt))->siso_addr;
|
1996-02-14 01:07:57 +03:00
|
|
|
if (rt == 0 || (sdl = (struct sockaddr_dl *) rt->rt_gateway) == 0 ||
|
|
|
|
sdl->sdl_family != AF_LINK) {
|
|
|
|
/*
|
|
|
|
* maybe we should have a function that you could put in the
|
|
|
|
* iso_ifaddr structure which could translate iso_addrs into
|
|
|
|
* snpa's where there is a known mapping for that address
|
|
|
|
* type
|
|
|
|
*/
|
1993-04-09 16:00:07 +04:00
|
|
|
esis_stat.es_badtype++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
esis_stat.es_rdsent++;
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ESISOUTPUT]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf(
|
1996-10-11 03:12:43 +04:00
|
|
|
"esis_rdoutput: ifp %p (%s), ht %d, m %p, oidx %p\n",
|
|
|
|
ifp, ifp->if_xname, esis_holding_time,
|
|
|
|
inbound_m, inbound_oidx);
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("\tdestination: %s\n", clnp_iso_addrp(rd_dstnsap));
|
|
|
|
printf("\tredirected toward:%s\n", clnp_iso_addrp(rd_gwnsap));
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if ((m0 = m = m_gethdr(M_DONTWAIT, MT_HEADER)) == NULL) {
|
|
|
|
esis_stat.es_nomem++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bzero(mtod(m, caddr_t), MHLEN);
|
|
|
|
|
|
|
|
pdu = mtod(m, struct esis_fixed *);
|
1996-02-14 01:07:57 +03:00
|
|
|
cp = (caddr_t) (pdu + 1); /* pointer arith.; 1st byte after
|
|
|
|
* header */
|
1993-04-09 16:00:07 +04:00
|
|
|
len = sizeof(struct esis_fixed);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build fixed part of header
|
|
|
|
*/
|
|
|
|
pdu->esis_proto_id = ISO9542_ESIS;
|
|
|
|
pdu->esis_vers = ESIS_VERSION;
|
|
|
|
pdu->esis_type = ESIS_RD;
|
|
|
|
HTOC(pdu->esis_ht_msb, pdu->esis_ht_lsb, esis_holding_time);
|
|
|
|
|
|
|
|
/* Insert destination address */
|
|
|
|
(void) esis_insert_addr(&cp, &len, rd_dstnsap, m, 0);
|
|
|
|
|
|
|
|
/* Insert the snpa of better next hop */
|
|
|
|
*cp++ = sdl->sdl_alen;
|
|
|
|
bcopy(LLADDR(sdl), cp, sdl->sdl_alen);
|
|
|
|
cp += sdl->sdl_alen;
|
|
|
|
len += (sdl->sdl_alen + 1);
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* If the next hop is not the destination, then it ought to be an IS
|
|
|
|
* and it should be inserted next. Else, set the NETL to 0
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
/* PHASE2 use mask from ifp of outgoing interface */
|
|
|
|
if (!iso_addrmatch1(rd_dstnsap, rd_gwnsap)) {
|
1996-02-14 01:07:57 +03:00
|
|
|
#if 0
|
|
|
|
/* this should not happen: */
|
1993-04-09 16:00:07 +04:00
|
|
|
if ((nhop_sc->sc_flags & SNPA_IS) == 0) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf(
|
1996-02-14 01:07:57 +03:00
|
|
|
"esis_rdoutput: next hop is not dst and not an IS\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
m_freem(m0);
|
|
|
|
return;
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
(void) esis_insert_addr(&cp, &len, rd_gwnsap, m, 0);
|
|
|
|
} else {
|
|
|
|
*cp++ = 0; /* NETL */
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
m->m_len = len;
|
|
|
|
|
|
|
|
/*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PHASE2
|
|
|
|
* If redirect is to an IS, add an address mask. The mask to be
|
|
|
|
* used should be the mask present in the routing entry used to
|
|
|
|
* forward the original data packet.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
1996-02-14 01:07:57 +03:00
|
|
|
* Copy Qos, priority, or security options present in original npdu
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
if (inbound_oidx) {
|
|
|
|
/* THIS CODE IS CURRENTLY (mostly) UNTESTED */
|
1996-02-14 01:07:57 +03:00
|
|
|
int optlen = 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
if (inbound_oidx->cni_qos_formatp)
|
|
|
|
optlen += (inbound_oidx->cni_qos_len + 2);
|
1996-02-14 01:07:57 +03:00
|
|
|
if (inbound_oidx->cni_priorp) /* priority option is 1 byte
|
|
|
|
* long */
|
1993-04-09 16:00:07 +04:00
|
|
|
optlen += 3;
|
|
|
|
if (inbound_oidx->cni_securep)
|
|
|
|
optlen += (inbound_oidx->cni_secure_len + 2);
|
|
|
|
if (M_TRAILINGSPACE(m) < optlen) {
|
|
|
|
EXTEND_PACKET(m, m0, cp);
|
|
|
|
m->m_len = 0;
|
|
|
|
/* assumes MLEN > optlen */
|
|
|
|
}
|
|
|
|
/* assume MLEN-len > optlen */
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* When copying options, copy from ptr - 2 in order to grab
|
|
|
|
* the option code and length
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
if (inbound_oidx->cni_qos_formatp) {
|
1996-02-14 01:07:57 +03:00
|
|
|
bcopy(mtod(inbound_m, caddr_t) +
|
|
|
|
inbound_oidx->cni_qos_formatp - 2,
|
|
|
|
cp, (unsigned) (inbound_oidx->cni_qos_len + 2));
|
1993-04-09 16:00:07 +04:00
|
|
|
cp += inbound_oidx->cni_qos_len + 2;
|
|
|
|
}
|
|
|
|
if (inbound_oidx->cni_priorp) {
|
1996-02-14 01:07:57 +03:00
|
|
|
bcopy(mtod(inbound_m, caddr_t) +
|
|
|
|
inbound_oidx->cni_priorp - 2, cp, 3);
|
1993-04-09 16:00:07 +04:00
|
|
|
cp += 3;
|
|
|
|
}
|
|
|
|
if (inbound_oidx->cni_securep) {
|
1996-02-14 01:07:57 +03:00
|
|
|
bcopy(mtod(inbound_m, caddr_t) +
|
|
|
|
inbound_oidx->cni_securep - 2, cp,
|
|
|
|
(unsigned) (inbound_oidx->cni_secure_len + 2));
|
1993-04-09 16:00:07 +04:00
|
|
|
cp += inbound_oidx->cni_secure_len + 2;
|
|
|
|
}
|
|
|
|
m->m_len += optlen;
|
|
|
|
len += optlen;
|
|
|
|
}
|
|
|
|
pdu->esis_hdr_len = m0->m_pkthdr.len = len;
|
1996-02-14 01:07:57 +03:00
|
|
|
iso_gen_csum(m0, ESIS_CKSUM_OFF, (int) pdu->esis_hdr_len);
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
bzero((caddr_t) & siso, sizeof(siso));
|
1993-04-09 16:00:07 +04:00
|
|
|
siso.siso_family = AF_ISO;
|
|
|
|
siso.siso_data[0] = AFI_SNA;
|
|
|
|
siso.siso_nlen = 6 + 1; /* should be taken from snpa_hdr */
|
1996-02-14 01:07:57 +03:00
|
|
|
/* +1 is for AFI */
|
1993-04-09 16:00:07 +04:00
|
|
|
bcopy(inbound_shp->snh_shost, siso.siso_data + 1, 6);
|
1996-02-14 01:07:57 +03:00
|
|
|
(ifp->if_output) (ifp, m0, sisotosa(&siso), 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: esis_insert_addr
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Insert an iso_addr into a buffer
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: true if buffer was big enough, else false
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
|
|
|
* SIDE EFFECTS: Increment buf & len according to size of iso_addr
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES: Plus 1 here is for length byte
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
1993-04-09 16:00:07 +04:00
|
|
|
esis_insert_addr(buf, len, isoa, m, nsellen)
|
1996-02-14 01:07:57 +03:00
|
|
|
register caddr_t *buf; /* ptr to buffer to put address into */
|
|
|
|
int *len; /* ptr to length of buffer so far */
|
|
|
|
register struct iso_addr *isoa; /* ptr to address */
|
|
|
|
register struct mbuf *m;/* determine if there remains space */
|
|
|
|
int nsellen;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
register int newlen, result = 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
isoa->isoa_len -= nsellen;
|
|
|
|
newlen = isoa->isoa_len + 1;
|
1996-02-14 01:07:57 +03:00
|
|
|
if (newlen <= M_TRAILINGSPACE(m)) {
|
|
|
|
bcopy((caddr_t) isoa, *buf, newlen);
|
1993-04-09 16:00:07 +04:00
|
|
|
*len += newlen;
|
|
|
|
*buf += newlen;
|
|
|
|
m->m_len += newlen;
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
isoa->isoa_len += nsellen;
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ESIS_EXTRACT_ADDR(d, b) { d = (struct iso_addr *)(b); b += (1 + *b); \
|
|
|
|
if (b > buflim) {esis_stat.es_toosmall++; goto bad;}}
|
|
|
|
#define ESIS_NEXT_OPTION(b) { b += (2 + b[1]); \
|
|
|
|
if (b > buflim) {esis_stat.es_toosmall++; goto bad;}}
|
1996-02-14 01:07:57 +03:00
|
|
|
int ESHonly = 0;
|
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
|
|
|
* FUNCTION: esis_eshinput
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Process an incoming ESH pdu
|
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
|
1993-04-09 16:00:07 +04:00
|
|
|
esis_eshinput(m, shp)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct mbuf *m; /* esh pdu */
|
|
|
|
struct snpa_hdr *shp; /* subnetwork header */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
struct esis_fixed *pdu = mtod(m, struct esis_fixed *);
|
|
|
|
u_short ht; /* holding time */
|
|
|
|
struct iso_addr *nsap = NULL;
|
|
|
|
int naddr;
|
|
|
|
u_char *buf = (u_char *) (pdu + 1);
|
|
|
|
u_char *buflim = pdu->esis_hdr_len + (u_char *) pdu;
|
|
|
|
int new_entry = 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
esis_stat.es_eshrcvd++;
|
|
|
|
|
|
|
|
CTOH(pdu->esis_ht_msb, pdu->esis_ht_lsb, ht);
|
|
|
|
|
|
|
|
naddr = *buf++;
|
|
|
|
if (buf >= buflim)
|
|
|
|
goto bad;
|
|
|
|
if (naddr == 1) {
|
|
|
|
ESIS_EXTRACT_ADDR(nsap, buf);
|
|
|
|
new_entry = snpac_add(shp->snh_ifp,
|
1996-02-14 01:07:57 +03:00
|
|
|
nsap, shp->snh_shost, SNPA_ES, ht, 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
} else {
|
1996-02-14 01:07:57 +03:00
|
|
|
int nsellength = 0, nlen = 0;
|
|
|
|
struct ifaddr *ifa;
|
|
|
|
/*
|
|
|
|
* See if we want to compress out multiple nsaps
|
|
|
|
* differing only by nsel
|
|
|
|
*/
|
|
|
|
for (ifa = shp->snh_ifp->if_addrlist.tqh_first; ifa != 0;
|
|
|
|
ifa = ifa->ifa_list.tqe_next)
|
|
|
|
if (ifa->ifa_addr->sa_family == AF_ISO) {
|
|
|
|
nsellength =
|
|
|
|
((struct iso_ifaddr *) ifa)->ia_addr.siso_tlen;
|
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ESISINPUT]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf(
|
1996-02-14 01:07:57 +03:00
|
|
|
"esis_eshinput: esh: ht %d, naddr %d nsellength %d\n",
|
|
|
|
ht, naddr, nsellength);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
while (naddr-- > 0) {
|
1996-02-14 01:07:57 +03:00
|
|
|
struct iso_addr *nsap2;
|
|
|
|
u_char *buf2;
|
1993-04-09 16:00:07 +04:00
|
|
|
ESIS_EXTRACT_ADDR(nsap, buf);
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* see if there is at least one more nsap in ESH
|
|
|
|
* differing only by nsel
|
|
|
|
*/
|
|
|
|
if (nsellength != 0)
|
|
|
|
for (buf2 = buf; buf2 < buflim;) {
|
|
|
|
ESIS_EXTRACT_ADDR(nsap2, buf2);
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ESISINPUT]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf(
|
1996-02-14 01:07:57 +03:00
|
|
|
"esis_eshinput: comparing %s ",
|
|
|
|
clnp_iso_addrp(nsap));
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("and %s\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
clnp_iso_addrp(nsap2));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (Bcmp(nsap->isoa_genaddr,
|
|
|
|
nsap2->isoa_genaddr,
|
|
|
|
nsap->isoa_len - nsellength)
|
|
|
|
== 0) {
|
|
|
|
nlen = nsellength;
|
|
|
|
break;
|
|
|
|
}
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
new_entry |= snpac_add(shp->snh_ifp,
|
1996-02-14 01:07:57 +03:00
|
|
|
nsap, shp->snh_shost, SNPA_ES, ht, nlen);
|
1993-04-09 16:00:07 +04:00
|
|
|
nlen = 0;
|
|
|
|
}
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ESISINPUT]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("esis_eshinput: nsap %s is %s\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
clnp_iso_addrp(nsap), new_entry ? "new" : "old");
|
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
if (new_entry && (iso_systype & SNPA_IS))
|
|
|
|
esis_shoutput(shp->snh_ifp, ESIS_ISH, esis_holding_time,
|
1996-02-14 01:07:57 +03:00
|
|
|
shp->snh_shost, 6, (struct iso_addr *) 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
bad:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: esis_ishinput
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: process an incoming ISH pdu
|
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:
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
1993-04-09 16:00:07 +04:00
|
|
|
esis_ishinput(m, shp)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct mbuf *m; /* esh pdu */
|
|
|
|
struct snpa_hdr *shp; /* subnetwork header */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
struct esis_fixed *pdu = mtod(m, struct esis_fixed *);
|
|
|
|
u_short ht, newct; /* holding time */
|
|
|
|
struct iso_addr *nsap; /* Network Entity Title */
|
|
|
|
register u_char *buf = (u_char *) (pdu + 1);
|
|
|
|
register u_char *buflim = pdu->esis_hdr_len + (u_char *) pdu;
|
|
|
|
int new_entry;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
esis_stat.es_ishrcvd++;
|
|
|
|
CTOH(pdu->esis_ht_msb, pdu->esis_ht_lsb, ht);
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ESISINPUT]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("esis_ishinput: ish: ht %d\n", ht);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
if (ESHonly)
|
|
|
|
goto bad;
|
|
|
|
|
|
|
|
ESIS_EXTRACT_ADDR(nsap, buf);
|
|
|
|
|
|
|
|
while (buf < buflim) {
|
|
|
|
switch (*buf) {
|
|
|
|
case ESISOVAL_ESCT:
|
|
|
|
if (iso_systype & SNPA_IS)
|
|
|
|
break;
|
|
|
|
if (buf[1] != 2)
|
|
|
|
goto bad;
|
|
|
|
CTOH(buf[2], buf[3], newct);
|
1996-02-14 01:07:57 +03:00
|
|
|
if ((u_short) esis_config_time != newct) {
|
|
|
|
untimeout(esis_config, 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
esis_config_time = newct;
|
1996-02-14 01:07:57 +03:00
|
|
|
esis_config(NULL);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
break;
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
default:
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("Unknown ISH option: %x\n", *buf);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
ESIS_NEXT_OPTION(buf);
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
new_entry = snpac_add(shp->snh_ifp, nsap, shp->snh_shost, SNPA_IS,
|
|
|
|
ht, 0);
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ESISINPUT]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("esis_ishinput: nsap %s is %s\n",
|
1996-10-11 03:12:43 +04:00
|
|
|
clnp_iso_addrp(nsap), new_entry ? "new" : "old");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if (new_entry)
|
1996-02-14 01:07:57 +03:00
|
|
|
esis_shoutput(shp->snh_ifp,
|
|
|
|
iso_systype & SNPA_ES ? ESIS_ESH : ESIS_ISH,
|
|
|
|
esis_holding_time, shp->snh_shost, 6, (struct iso_addr *) 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
bad:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: esis_rdinput
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Process an incoming RD pdu
|
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:
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
1993-04-09 16:00:07 +04:00
|
|
|
esis_rdinput(m0, shp)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct mbuf *m0; /* esh pdu */
|
|
|
|
struct snpa_hdr *shp; /* subnetwork header */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
struct esis_fixed *pdu = mtod(m0, struct esis_fixed *);
|
|
|
|
u_short ht; /* holding time */
|
|
|
|
struct iso_addr *da, *net = 0, *netmask = 0, *snpamask = 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
register struct iso_addr *bsnpa;
|
1996-02-14 01:07:57 +03:00
|
|
|
register u_char *buf = (u_char *) (pdu + 1);
|
|
|
|
register u_char *buflim = pdu->esis_hdr_len + (u_char *) pdu;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
esis_stat.es_rdrcvd++;
|
|
|
|
|
|
|
|
/* intermediate systems ignore redirects */
|
|
|
|
if (iso_systype & SNPA_IS)
|
|
|
|
return;
|
|
|
|
if (ESHonly)
|
|
|
|
return;
|
|
|
|
|
|
|
|
CTOH(pdu->esis_ht_msb, pdu->esis_ht_lsb, ht);
|
|
|
|
if (buf >= buflim)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Extract DA */
|
|
|
|
ESIS_EXTRACT_ADDR(da, buf);
|
|
|
|
|
|
|
|
/* Extract better snpa */
|
|
|
|
ESIS_EXTRACT_ADDR(bsnpa, buf);
|
|
|
|
|
|
|
|
/* Extract NET if present */
|
|
|
|
if (buf < buflim) {
|
|
|
|
if (*buf == 0)
|
1996-02-14 01:07:57 +03:00
|
|
|
buf++; /* no NET present, skip NETL anyway */
|
1993-04-09 16:00:07 +04:00
|
|
|
else
|
|
|
|
ESIS_EXTRACT_ADDR(net, buf);
|
|
|
|
}
|
|
|
|
/* process options */
|
|
|
|
while (buf < buflim) {
|
|
|
|
switch (*buf) {
|
|
|
|
case ESISOVAL_SNPAMASK:
|
1996-02-14 01:07:57 +03:00
|
|
|
if (snpamask) /* duplicate */
|
1993-04-09 16:00:07 +04:00
|
|
|
return;
|
1996-02-14 01:07:57 +03:00
|
|
|
snpamask = (struct iso_addr *) (buf + 1);
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ESISOVAL_NETMASK:
|
1996-02-14 01:07:57 +03:00
|
|
|
if (netmask) /* duplicate */
|
1993-04-09 16:00:07 +04:00
|
|
|
return;
|
1996-02-14 01:07:57 +03:00
|
|
|
netmask = (struct iso_addr *) (buf + 1);
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("Unknown option in ESIS RD (0x%x)\n", buf[-1]);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
ESIS_NEXT_OPTION(buf);
|
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ESISINPUT]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("esis_rdinput: rd: ht %d, da %s\n", ht,
|
1996-10-11 03:12:43 +04:00
|
|
|
clnp_iso_addrp(da));
|
1993-04-09 16:00:07 +04:00
|
|
|
if (net)
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("\t: net %s\n", clnp_iso_addrp(net));
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
1996-02-14 01:07:57 +03:00
|
|
|
* If netl is zero, then redirect is to an ES. We need to add an entry
|
|
|
|
* to the snpa cache for (destination, better snpa).
|
|
|
|
* If netl is not zero, then the redirect is to an IS. In this
|
|
|
|
* case, add an snpa cache entry for (net, better snpa).
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* If the redirect is to an IS, add a route entry towards that
|
|
|
|
* IS.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
if (net == 0 || net->isoa_len == 0 || snpamask) {
|
|
|
|
/* redirect to an ES */
|
|
|
|
snpac_add(shp->snh_ifp, da,
|
1996-02-14 01:07:57 +03:00
|
|
|
bsnpa->isoa_genaddr, SNPA_ES, ht, 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
} else {
|
|
|
|
snpac_add(shp->snh_ifp, net,
|
1996-02-14 01:07:57 +03:00
|
|
|
bsnpa->isoa_genaddr, SNPA_IS, ht, 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
snpac_addrt(shp->snh_ifp, da, net, netmask);
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
bad: ; /* Needed by ESIS_NEXT_OPTION */
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: esis_config
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Report configuration
|
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: Called every esis_config_time seconds
|
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
|
1996-02-14 01:07:57 +03:00
|
|
|
esis_config(v)
|
|
|
|
void *v;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
register struct ifnet *ifp;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
timeout(esis_config, (caddr_t) 0, hz * esis_config_time);
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* Report configuration for each interface that - is UP - has
|
|
|
|
* BROADCAST capability - has an ISO address
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* Todo: a better way would be to construct the esh or ish once and
|
|
|
|
* copy it out for all devices, possibly calling a method in the
|
|
|
|
* iso_ifaddr structure to encapsulate and transmit it. This could
|
|
|
|
* work to advantage for non-broadcast media
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1995-06-13 09:52:42 +04:00
|
|
|
for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) {
|
1993-04-09 16:00:07 +04:00
|
|
|
if ((ifp->if_flags & IFF_UP) &&
|
|
|
|
(ifp->if_flags & IFF_BROADCAST)) {
|
|
|
|
/* search for an ISO address family */
|
1996-02-14 01:07:57 +03:00
|
|
|
struct ifaddr *ifa;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1995-06-13 09:52:42 +04:00
|
|
|
for (ifa = ifp->if_addrlist.tqh_first; ifa != 0;
|
1996-02-14 01:07:57 +03:00
|
|
|
ifa = ifa->ifa_list.tqe_next) {
|
1995-06-13 09:52:42 +04:00
|
|
|
if (ifa->ifa_addr->sa_family == AF_ISO) {
|
1996-02-14 01:07:57 +03:00
|
|
|
esis_shoutput(ifp,
|
|
|
|
iso_systype & SNPA_ES ? ESIS_ESH : ESIS_ISH,
|
|
|
|
esis_holding_time,
|
|
|
|
(caddr_t) (iso_systype & SNPA_ES ? all_is_snpa :
|
|
|
|
all_es_snpa), 6, (struct iso_addr *) 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: esis_shoutput
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Transmit an esh or ish pdu
|
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
|
1993-04-09 16:00:07 +04:00
|
|
|
esis_shoutput(ifp, type, ht, sn_addr, sn_len, isoa)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct ifnet *ifp;
|
|
|
|
int type;
|
|
|
|
short ht;
|
|
|
|
caddr_t sn_addr;
|
|
|
|
int sn_len;
|
|
|
|
struct iso_addr *isoa;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
struct mbuf *m, *m0;
|
|
|
|
caddr_t cp, naddrp;
|
|
|
|
int naddr = 0;
|
|
|
|
struct esis_fixed *pdu;
|
|
|
|
struct iso_ifaddr *ia;
|
|
|
|
int len;
|
|
|
|
struct sockaddr_iso siso;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if (type == ESIS_ESH)
|
|
|
|
esis_stat.es_eshsent++;
|
1996-02-14 01:07:57 +03:00
|
|
|
else if (type == ESIS_ISH)
|
1993-04-09 16:00:07 +04:00
|
|
|
esis_stat.es_ishsent++;
|
|
|
|
else {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("esis_shoutput: bad pdu type\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ESISOUTPUT]) {
|
|
|
|
int i;
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("esis_shoutput: ifp %p (%s), %s, ht %d, to: [%d] ",
|
1996-10-11 03:12:43 +04:00
|
|
|
ifp, ifp->if_xname,
|
|
|
|
type == ESIS_ESH ? "esh" : "ish",
|
|
|
|
ht, sn_len);
|
1996-02-14 01:07:57 +03:00
|
|
|
for (i = 0; i < sn_len; i++)
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("%x%c", *(sn_addr + i),
|
1996-10-11 03:12:43 +04:00
|
|
|
i < (sn_len - 1) ? ':' : ' ');
|
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
|
|
|
|
|
|
|
if ((m0 = m = m_gethdr(M_DONTWAIT, MT_HEADER)) == NULL) {
|
|
|
|
esis_stat.es_nomem++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bzero(mtod(m, caddr_t), MHLEN);
|
|
|
|
|
|
|
|
pdu = mtod(m, struct esis_fixed *);
|
1996-02-14 01:07:57 +03:00
|
|
|
naddrp = cp = (caddr_t) (pdu + 1);
|
1993-04-09 16:00:07 +04:00
|
|
|
len = sizeof(struct esis_fixed);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build fixed part of header
|
|
|
|
*/
|
|
|
|
pdu->esis_proto_id = ISO9542_ESIS;
|
|
|
|
pdu->esis_vers = ESIS_VERSION;
|
|
|
|
pdu->esis_type = type;
|
|
|
|
HTOC(pdu->esis_ht_msb, pdu->esis_ht_lsb, ht);
|
|
|
|
|
|
|
|
if (type == ESIS_ESH) {
|
|
|
|
cp++;
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
m->m_len = len;
|
|
|
|
if (isoa) {
|
|
|
|
/*
|
|
|
|
* Here we are responding to a clnp packet sent to an NSAP
|
|
|
|
* that is ours which was sent to the MAC addr all_es's.
|
|
|
|
* It is possible that we did not specifically advertise this
|
|
|
|
* NSAP, even though it is ours, so we will respond
|
|
|
|
* directly to the sender that we are here. If we do have
|
1996-02-14 01:07:57 +03:00
|
|
|
* multiple NSEL's we'll tack them on so he can compress
|
|
|
|
* them out.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
(void) esis_insert_addr(&cp, &len, isoa, m, 0);
|
|
|
|
naddr = 1;
|
|
|
|
}
|
1995-06-13 11:13:14 +04:00
|
|
|
for (ia = iso_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) {
|
1996-02-14 01:07:57 +03:00
|
|
|
int nsellen = (type == ESIS_ISH ? ia->ia_addr.siso_tlen : 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
int n = ia->ia_addr.siso_nlen;
|
|
|
|
register struct iso_ifaddr *ia2;
|
|
|
|
|
|
|
|
if (type == ESIS_ISH && naddr > 0)
|
|
|
|
break;
|
1996-02-14 01:07:57 +03:00
|
|
|
for (ia2 = iso_ifaddr.tqh_first; ia2 != ia;
|
|
|
|
ia2 = ia2->ia_list.tqe_next)
|
|
|
|
if (Bcmp(ia->ia_addr.siso_data,
|
|
|
|
ia2->ia_addr.siso_data, n) == 0)
|
1995-06-13 11:13:14 +04:00
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
if (ia2 != ia)
|
1996-02-14 01:07:57 +03:00
|
|
|
continue; /* Means we have previously copied
|
|
|
|
* this nsap */
|
|
|
|
if (isoa && Bcmp(ia->ia_addr.siso_data,
|
|
|
|
isoa->isoa_genaddr, n) == 0) {
|
1993-04-09 16:00:07 +04:00
|
|
|
isoa = 0;
|
|
|
|
continue; /* Ditto */
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ESISOUTPUT]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("esis_shoutput: adding NSAP %s\n",
|
1996-10-11 03:12:43 +04:00
|
|
|
clnp_iso_addrp(&ia->ia_addr.siso_addr));
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
if (!esis_insert_addr(&cp, &len,
|
1996-02-14 01:07:57 +03:00
|
|
|
&ia->ia_addr.siso_addr, m, nsellen)) {
|
1993-04-09 16:00:07 +04:00
|
|
|
EXTEND_PACKET(m, m0, cp);
|
1996-02-14 01:07:57 +03:00
|
|
|
(void) esis_insert_addr(&cp, &len,
|
|
|
|
&ia->ia_addr.siso_addr, m,
|
|
|
|
nsellen);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
naddr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == ESIS_ESH)
|
|
|
|
*naddrp = naddr;
|
|
|
|
else {
|
|
|
|
/* add suggested es config timer option to ISH */
|
|
|
|
if (M_TRAILINGSPACE(m) < 4) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("esis_shoutput: extending packet\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
EXTEND_PACKET(m, m0, cp);
|
|
|
|
}
|
|
|
|
*cp++ = ESISOVAL_ESCT;
|
|
|
|
*cp++ = 2;
|
1996-02-14 01:07:57 +03:00
|
|
|
HTOC(*cp, *(cp + 1), esis_esconfig_time);
|
1993-04-09 16:00:07 +04:00
|
|
|
len += 4;
|
|
|
|
m->m_len += 4;
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ESISOUTPUT]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("m0 %p, m %p, data %p, len %d, cp %p\n",
|
1996-10-11 03:12:43 +04:00
|
|
|
m0, m, m->m_data, m->m_len, cp);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
m0->m_pkthdr.len = len;
|
|
|
|
pdu->esis_hdr_len = len;
|
1996-02-14 01:07:57 +03:00
|
|
|
iso_gen_csum(m0, ESIS_CKSUM_OFF, (int) pdu->esis_hdr_len);
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
bzero((caddr_t) & siso, sizeof(siso));
|
1993-04-09 16:00:07 +04:00
|
|
|
siso.siso_family = AF_ISO;
|
|
|
|
siso.siso_data[0] = AFI_SNA;
|
|
|
|
siso.siso_nlen = sn_len + 1;
|
1996-02-14 01:07:57 +03:00
|
|
|
bcopy(sn_addr, siso.siso_data + 1, (unsigned) sn_len);
|
|
|
|
(ifp->if_output) (ifp, m0, sisotosa(&siso), 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: isis_input
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Process an incoming isis packet
|
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
|
|
|
*/
|
1994-05-13 10:08:03 +04:00
|
|
|
void
|
1996-02-14 01:07:57 +03:00
|
|
|
#if __STDC__
|
|
|
|
isis_input(struct mbuf *m0, ...)
|
|
|
|
#else
|
|
|
|
isis_input(m0, va_alist)
|
|
|
|
struct mbuf *m0;
|
|
|
|
va_dcl
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
struct snpa_hdr *shp; /* subnetwork header */
|
1993-04-09 16:00:07 +04:00
|
|
|
register struct rawcb *rp, *first_rp = 0;
|
1996-02-14 01:07:57 +03:00
|
|
|
struct ifnet *ifp;
|
|
|
|
struct mbuf *mm;
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, m0);
|
|
|
|
shp = va_arg(ap, struct snpa_hdr *);
|
|
|
|
va_end(ap);
|
|
|
|
ifp = shp->snh_ifp;
|
|
|
|
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ISISINPUT]) {
|
|
|
|
int i;
|
|
|
|
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("isis_input: pkt on ifp %p (%s): from:",
|
1996-10-11 03:12:43 +04:00
|
|
|
ifp, ifp->if_xname);
|
1996-02-14 01:07:57 +03:00
|
|
|
for (i = 0; i < 6; i++)
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("%x%c", shp->snh_shost[i] & 0xff,
|
1996-10-11 03:12:43 +04:00
|
|
|
(i < 5) ? ':' : ' ');
|
1996-10-13 06:03:00 +04:00
|
|
|
printf(" to:");
|
1996-02-14 01:07:57 +03:00
|
|
|
for (i = 0; i < 6; i++)
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("%x%c", shp->snh_dhost[i] & 0xff,
|
1996-10-11 03:12:43 +04:00
|
|
|
(i < 5) ? ':' : ' ');
|
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
|
|
|
esis_dl.sdl_alen = ifp->if_addrlen;
|
|
|
|
esis_dl.sdl_index = ifp->if_index;
|
1996-02-14 01:07:57 +03:00
|
|
|
bcopy(shp->snh_shost, (caddr_t) esis_dl.sdl_data, esis_dl.sdl_alen);
|
1995-06-13 11:58:10 +04:00
|
|
|
for (rp = esis_pcb.lh_first; rp != 0; rp = rp->rcb_list.le_next) {
|
1993-04-09 16:00:07 +04:00
|
|
|
if (first_rp == 0) {
|
|
|
|
first_rp = rp;
|
|
|
|
continue;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
/* can't block at interrupt level */
|
|
|
|
if ((mm = m_copy(m0, 0, M_COPYALL)) != NULL) {
|
1993-04-09 16:00:07 +04:00
|
|
|
if (sbappendaddr(&rp->rcb_socket->so_rcv,
|
1998-03-01 05:20:01 +03:00
|
|
|
(struct sockaddr *) &esis_dl, mm,
|
1996-02-14 01:07:57 +03:00
|
|
|
(struct mbuf *) 0) != 0) {
|
1993-04-09 16:00:07 +04:00
|
|
|
sorwakeup(rp->rcb_socket);
|
1996-02-14 01:07:57 +03:00
|
|
|
} else {
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ISISINPUT]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf(
|
1996-04-13 05:34:06 +04:00
|
|
|
"Error in sbappenaddr, mm = %p\n", mm);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
m_freem(mm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (first_rp && sbappendaddr(&first_rp->rcb_socket->so_rcv,
|
1998-03-01 05:20:01 +03:00
|
|
|
(struct sockaddr *) &esis_dl, m0, (struct mbuf *) 0) != 0) {
|
1993-04-09 16:00:07 +04:00
|
|
|
sorwakeup(first_rp->rcb_socket);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_freem(m0);
|
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
|
|
|
#if __STDC__
|
|
|
|
isis_output(struct mbuf *m, ...)
|
|
|
|
#else
|
|
|
|
isis_output(m, va_alist)
|
|
|
|
struct mbuf *m;
|
|
|
|
va_dcl
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
register struct sockaddr_dl *sdl;
|
1993-04-09 16:00:07 +04:00
|
|
|
register struct ifnet *ifp;
|
1996-02-14 01:07:57 +03:00
|
|
|
struct ifaddr *ifa;
|
1993-04-09 16:00:07 +04:00
|
|
|
struct sockaddr_iso siso;
|
1996-02-14 01:07:57 +03:00
|
|
|
int error = 0;
|
|
|
|
unsigned sn_len;
|
|
|
|
va_list ap;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
va_start(ap, m);
|
|
|
|
sdl = va_arg(ap, struct sockaddr_dl *);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
ifa = ifa_ifwithnet((struct sockaddr *) sdl); /* get ifp from sdl */
|
1993-04-09 16:00:07 +04:00
|
|
|
if (ifa == 0) {
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ISISOUTPUT]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("isis_output: interface not found\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
error = EINVAL;
|
|
|
|
goto release;
|
|
|
|
}
|
|
|
|
ifp = ifa->ifa_ifp;
|
|
|
|
sn_len = sdl->sdl_alen;
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ISISOUTPUT]) {
|
|
|
|
u_char *cp = (u_char *) LLADDR(sdl), *cplim = cp + sn_len;
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("isis_output: ifp %p (%s), to: ",
|
1996-10-11 03:12:43 +04:00
|
|
|
ifp, ifp->if_xname);
|
1993-04-09 16:00:07 +04:00
|
|
|
while (cp < cplim) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("%x", *cp++);
|
|
|
|
printf("%c", (cp < cplim) ? ':' : ' ');
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
bzero((caddr_t) & siso, sizeof(siso));
|
|
|
|
siso.siso_family = AF_ISO; /* This convention may be useful for
|
|
|
|
* X.25 */
|
1993-04-09 16:00:07 +04:00
|
|
|
siso.siso_data[0] = AFI_SNA;
|
|
|
|
siso.siso_nlen = sn_len + 1;
|
|
|
|
bcopy(LLADDR(sdl), siso.siso_data + 1, sn_len);
|
1996-02-14 01:07:57 +03:00
|
|
|
error = (ifp->if_output) (ifp, m, sisotosa(&siso), 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
if (error) {
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ISISOUTPUT]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("isis_output: error from ether_output is %d\n",
|
1996-10-11 03:12:43 +04:00
|
|
|
error);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
release:
|
|
|
|
if (m != NULL)
|
|
|
|
m_freem(m);
|
1996-02-14 01:07:57 +03:00
|
|
|
return (error);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: esis_ctlinput
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Handle the PRC_IFDOWN transition
|
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: Calls snpac_flush for interface specified.
|
|
|
|
* The loop through iso_ifaddr is stupid because
|
|
|
|
* back in if_down, we knew the ifp...
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void *
|
|
|
|
esis_ctlinput(req, siso, dummy)
|
|
|
|
int req; /* request: we handle only PRC_IFDOWN */
|
|
|
|
struct sockaddr *siso; /* address of ifp */
|
|
|
|
void *dummy;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
|
|
|
register struct iso_ifaddr *ia; /* scan through interface addresses */
|
|
|
|
|
|
|
|
if (req == PRC_IFDOWN)
|
1996-02-14 01:07:57 +03:00
|
|
|
for (ia = iso_ifaddr.tqh_first; ia != 0;
|
|
|
|
ia = ia->ia_list.tqe_next) {
|
|
|
|
if (iso_addrmatch(IA_SIS(ia),
|
|
|
|
(struct sockaddr_iso *) siso))
|
1993-04-09 16:00:07 +04:00
|
|
|
snpac_flushifp(ia->ia_ifp);
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
return NULL;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* ISO */
|