2001-04-14 03:29:55 +04:00
|
|
|
/* $NetBSD: iso.c,v 1.29 2001/04/13 23:30:28 thorpej 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
|
|
|
* @(#)iso.c 8.3 (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
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* iso.c: miscellaneous routines to support the iso address family
|
|
|
|
*/
|
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <sys/param.h>
|
1994-05-13 10:08:03 +04:00
|
|
|
#include <sys/systm.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <sys/ioctl.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>
|
1996-05-22 17:54:55 +04:00
|
|
|
#include <sys/proc.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
|
|
|
|
#include <net/if.h>
|
1999-04-14 20:26:42 +04:00
|
|
|
#include <net/if_types.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <net/route.h>
|
|
|
|
|
|
|
|
#include <netiso/iso.h>
|
|
|
|
#include <netiso/iso_var.h>
|
|
|
|
#include <netiso/iso_snpac.h>
|
|
|
|
#include <netiso/iso_pcb.h>
|
|
|
|
#include <netiso/clnp.h>
|
|
|
|
#include <netiso/argo_debug.h>
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1998-07-05 08:37:35 +04:00
|
|
|
#include "opt_iso.h"
|
1993-04-09 16:00:07 +04:00
|
|
|
#ifdef ISO
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
int iso_interfaces = 0; /* number of external interfaces */
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: iso_addrmatch1
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: decide if the two iso_addrs passed are equal
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: true if the addrs match, false if they do not
|
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
|
|
|
int
|
1993-04-09 16:00:07 +04:00
|
|
|
iso_addrmatch1(isoaa, isoab)
|
2000-03-30 16:51:13 +04:00
|
|
|
struct iso_addr *isoaa, *isoab; /* addresses to check */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
u_int compare_len;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_addrmatch1: comparing lengths: %d to %d\n", isoaa->isoa_len,
|
1996-10-11 03:12:43 +04:00
|
|
|
isoab->isoa_len);
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("a:\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_buf(isoaa->isoa_genaddr, isoaa->isoa_len);
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("b:\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_buf(isoab->isoa_genaddr, isoab->isoa_len);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if ((compare_len = isoaa->isoa_len) != isoab->isoa_len) {
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_addrmatch1: returning false because of lengths\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#ifdef notdef
|
|
|
|
/* TODO : generalize this to all afis with masks */
|
1996-02-14 01:07:57 +03:00
|
|
|
if (isoaa->isoa_afi == AFI_37) {
|
|
|
|
/*
|
|
|
|
* must not compare 2 least significant digits, or for that
|
|
|
|
* matter, the DSP
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
compare_len = ADDR37_IDI_LEN - 1;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
|
|
|
int i;
|
|
|
|
char *a, *b;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
a = isoaa->isoa_genaddr;
|
|
|
|
b = isoab->isoa_genaddr;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
for (i = 0; i < compare_len; i++) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("<%x=%x>", a[i] & 0xff, b[i] & 0xff);
|
1993-04-09 16:00:07 +04:00
|
|
|
if (a[i] != b[i]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("\naddrs are not equal at byte %d\n", i);
|
1996-02-14 01:07:57 +03:00
|
|
|
return (0);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
}
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("\n");
|
|
|
|
printf("addrs are equal\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
return (1);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
return (!bcmp(isoaa->isoa_genaddr, isoab->isoa_genaddr, compare_len));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: iso_addrmatch
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: decide if the two sockadrr_isos passed are equal
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: true if the addrs match, false if they do not
|
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
|
|
|
int
|
1993-04-09 16:00:07 +04:00
|
|
|
iso_addrmatch(sisoa, sisob)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct sockaddr_iso *sisoa, *sisob; /* addresses to check */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
return (iso_addrmatch1(&sisoa->siso_addr, &sisob->siso_addr));
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
#ifdef notdef
|
|
|
|
/*
|
|
|
|
* FUNCTION: iso_netmatch
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: similar to iso_addrmatch but takes sockaddr_iso
|
|
|
|
* as argument.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: true if same net, false if not
|
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
|
|
|
int
|
1993-04-09 16:00:07 +04:00
|
|
|
iso_netmatch(sisoa, sisob)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct sockaddr_iso *sisoa, *sisob;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
u_char bufa[sizeof(struct sockaddr_iso)];
|
|
|
|
u_char bufb[sizeof(struct sockaddr_iso)];
|
2000-03-30 16:51:13 +04:00
|
|
|
int lena, lenb;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
lena = iso_netof(&sisoa->siso_addr, bufa);
|
|
|
|
lenb = iso_netof(&sisob->siso_addr, bufb);
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_netmatch: comparing lengths: %d to %d\n", lena, lenb);
|
|
|
|
printf("a:\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_buf(bufa, lena);
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("b:\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_buf(bufb, lenb);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
return ((lena == lenb) && (!bcmp(bufa, bufb, lena)));
|
|
|
|
}
|
1994-05-13 10:08:03 +04:00
|
|
|
#endif /* notdef */
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: iso_hashchar
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Hash all character in the buffer specified into
|
|
|
|
* a long. Return the long.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: The hash value.
|
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: The hash is achieved by exclusive ORing 4 byte
|
|
|
|
* quantities.
|
1993-04-09 16:00:07 +04:00
|
|
|
*/
|
|
|
|
u_long
|
|
|
|
iso_hashchar(buf, len)
|
2000-03-30 16:51:13 +04:00
|
|
|
caddr_t buf; /* buffer to pack from */
|
|
|
|
int len; /* length of buffer */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
u_long h = 0;
|
|
|
|
int i;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
for (i = 0; i < len; i += 4) {
|
2000-03-30 16:51:13 +04:00
|
|
|
u_long l = 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if ((len - i) < 4) {
|
|
|
|
/* buffer not multiple of 4 */
|
|
|
|
switch (len - i) {
|
1996-02-14 01:07:57 +03:00
|
|
|
case 3:
|
|
|
|
l |= buf[i + 2] << 8;
|
|
|
|
case 2:
|
|
|
|
l |= buf[i + 1] << 16;
|
|
|
|
case 1:
|
|
|
|
l |= buf[i] << 24;
|
|
|
|
break;
|
|
|
|
default:
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_hashchar: unexpected value x%x\n", len - i);
|
1996-02-14 01:07:57 +03:00
|
|
|
break;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
l |= buf[i] << 24;
|
1996-02-14 01:07:57 +03:00
|
|
|
l |= buf[i + 1] << 16;
|
|
|
|
l |= buf[i + 2] << 8;
|
|
|
|
l |= buf[i + 3];
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
h ^= l;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
h ^= (u_long) (len % 4);
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
return (h);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
|
1994-05-13 10:08:03 +04:00
|
|
|
#ifdef notdef
|
|
|
|
/*
|
|
|
|
* FUNCTION: iso_hash
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Fill in fields of afhash structure based upon addr
|
|
|
|
* passed.
|
1994-05-13 10:08:03 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: none
|
1994-05-13 10:08:03 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1994-05-13 10:08:03 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES:
|
1994-05-13 10:08:03 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
1994-05-13 10:08:03 +04:00
|
|
|
iso_hash(siso, hp)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct sockaddr_iso *siso; /* address to perform hash on */
|
|
|
|
struct afhash *hp; /* RETURN: hash info here */
|
1994-05-13 10:08:03 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
u_long buf[sizeof(struct sockaddr_iso) + 1 / 4];
|
2000-03-30 16:51:13 +04:00
|
|
|
int bufsize;
|
1994-05-13 10:08:03 +04:00
|
|
|
|
|
|
|
|
|
|
|
bzero(buf, sizeof(buf));
|
|
|
|
|
|
|
|
bufsize = iso_netof(&siso->siso_addr, buf);
|
1996-02-14 01:07:57 +03:00
|
|
|
hp->afh_nethash = iso_hashchar((caddr_t) buf, bufsize);
|
1994-05-13 10:08:03 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_hash: iso_netof: bufsize = %d\n", bufsize);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
hp->afh_hosthash = iso_hashchar((caddr_t) & siso->siso_addr,
|
|
|
|
siso->siso_addr.isoa_len);
|
1994-05-13 10:08:03 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_hash: %s: nethash = x%x, hosthash = x%x\n",
|
1996-10-11 03:12:43 +04:00
|
|
|
clnp_iso_addrp(&siso->siso_addr), hp->afh_nethash,
|
|
|
|
hp->afh_hosthash);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* FUNCTION: iso_netof
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Extract the network portion of the iso address.
|
|
|
|
* The network portion of the iso address varies depending
|
|
|
|
* on the type of address. The network portion of the
|
|
|
|
* address will include the IDP. The network portion is:
|
|
|
|
*
|
|
|
|
* TYPE DESC
|
|
|
|
* t37 The AFI and x.121 (IDI)
|
|
|
|
* osinet The AFI, orgid, snetid
|
|
|
|
* rfc986 The AFI, vers and network part
|
|
|
|
* of internet address.
|
1994-05-13 10:08:03 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: number of bytes placed into buf.
|
1994-05-13 10:08:03 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1994-05-13 10:08:03 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* NOTES: Buf is assumed to be big enough
|
1994-05-13 10:08:03 +04:00
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
u_int
|
1994-05-13 10:08:03 +04:00
|
|
|
iso_netof(isoa, buf)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct iso_addr *isoa; /* address */
|
|
|
|
caddr_t buf; /* RESULT: network portion of address here */
|
1994-05-13 10:08:03 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
u_int len = 1;/* length of afi */
|
1994-05-13 10:08:03 +04:00
|
|
|
|
|
|
|
switch (isoa->isoa_afi) {
|
1996-02-14 01:07:57 +03:00
|
|
|
case AFI_37:
|
|
|
|
/*
|
|
|
|
* Due to classic x.25 tunnel vision, there is no
|
|
|
|
* net portion of an x.121 address. For our purposes
|
|
|
|
* the AFI will do, so that all x.25 -type addresses
|
|
|
|
* map to the single x.25 SNPA. (Cannot have more than
|
|
|
|
* one, obviously).
|
|
|
|
*/
|
1994-05-13 10:08:03 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
break;
|
1994-05-13 10:08:03 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
/* case AFI_OSINET: */
|
|
|
|
case AFI_RFC986:{
|
|
|
|
u_short idi; /* value of idi */
|
1994-05-13 10:08:03 +04:00
|
|
|
|
|
|
|
/* osinet and rfc986 have idi in the same place */
|
|
|
|
CTOH(isoa->rfc986_idi[0], isoa->rfc986_idi[1], idi);
|
|
|
|
|
|
|
|
if (idi == IDI_OSINET)
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* Network portion of OSINET address can only
|
|
|
|
* be the IDI. Clearly, with one x25 interface,
|
|
|
|
* one could get to several orgids, and
|
|
|
|
* several snetids.
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
len += (ADDROSINET_IDI_LEN +
|
|
|
|
OVLOSINET_ORGID_LEN +
|
|
|
|
OVLOSINET_SNETID_LEN);
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
len += ADDROSINET_IDI_LEN;
|
|
|
|
else if (idi == IDI_RFC986) {
|
1996-02-14 01:07:57 +03:00
|
|
|
struct ovl_rfc986 *o986 =
|
|
|
|
(struct ovl_rfc986 *) isoa;
|
1994-05-13 10:08:03 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* bump len to include idi and version (1
|
|
|
|
* byte)
|
|
|
|
*/
|
1994-05-13 10:08:03 +04:00
|
|
|
len += ADDRRFC986_IDI_LEN + 1;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_netof: isoa ");
|
1994-05-13 10:08:03 +04:00
|
|
|
dump_buf(isoa, sizeof(*isoa));
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_netof: inetaddr 0x%x ",
|
1996-10-11 03:12:43 +04:00
|
|
|
inetaddr);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* bump len by size of network portion of
|
|
|
|
* inet address
|
|
|
|
*/
|
1995-06-02 01:35:34 +04:00
|
|
|
if (IN_CLASSA(o986->o986_inetaddr)) {
|
1996-02-14 01:07:57 +03:00
|
|
|
len += 4 - IN_CLASSA_NSHIFT / 8;
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_netof: class A net len is now %d\n", len);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1995-06-02 01:35:34 +04:00
|
|
|
} else if (IN_CLASSB(o986->o986_inetaddr)) {
|
1996-02-14 01:07:57 +03:00
|
|
|
len += 4 - IN_CLASSB_NSHIFT / 8;
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_netof: class B net len is now %d\n", len);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
} else {
|
1996-02-14 01:07:57 +03:00
|
|
|
len += 4 - IN_CLASSC_NSHIFT / 8;
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_netof: class C net len is now %d\n", len);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
len = 0;
|
|
|
|
} break;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
default:
|
|
|
|
len = 0;
|
1994-05-13 10:08:03 +04:00
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
bcopy((caddr_t) isoa, buf, len);
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_netof: isoa ");
|
1994-05-13 10:08:03 +04:00
|
|
|
dump_buf(isoa, len);
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_netof: net ");
|
1994-05-13 10:08:03 +04:00
|
|
|
dump_buf(buf, len);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1994-05-13 10:08:03 +04:00
|
|
|
return len;
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* notdef */
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
|
|
|
* Generic iso control operations (ioctl's).
|
|
|
|
* Ifp is 0 if not an interface-specific ioctl.
|
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
1996-05-22 17:54:55 +04:00
|
|
|
iso_control(so, cmd, data, ifp, p)
|
|
|
|
struct socket *so;
|
|
|
|
u_long cmd;
|
|
|
|
caddr_t data;
|
2000-03-30 16:51:13 +04:00
|
|
|
struct ifnet *ifp;
|
1996-05-22 17:54:55 +04:00
|
|
|
struct proc *p;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct iso_ifreq *ifr = (struct iso_ifreq *) data;
|
|
|
|
struct iso_ifaddr *ia = 0;
|
1996-02-14 01:07:57 +03:00
|
|
|
struct iso_aliasreq *ifra = (struct iso_aliasreq *) data;
|
|
|
|
int error, hostIsNew, maskIsNew;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Find address for this interface, if it exists.
|
|
|
|
*/
|
|
|
|
if (ifp)
|
1995-06-13 11:13:14 +04:00
|
|
|
for (ia = iso_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next)
|
1993-04-09 16:00:07 +04:00
|
|
|
if (ia->ia_ifp == ifp)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
|
1999-04-01 10:51:48 +04:00
|
|
|
case SIOCAIFADDR_ISO:
|
|
|
|
case SIOCDIFADDR_ISO:
|
1993-04-09 16:00:07 +04:00
|
|
|
if (ifra->ifra_addr.siso_family == AF_ISO)
|
1996-09-08 18:28:08 +04:00
|
|
|
for (; ia != 0; ia = ia->ia_list.tqe_next) {
|
1996-02-14 01:07:57 +03:00
|
|
|
if (ia->ia_ifp == ifp &&
|
1996-09-08 18:28:08 +04:00
|
|
|
SAME_ISOADDR(&ia->ia_addr, &ifra->ifra_addr))
|
1996-02-14 01:07:57 +03:00
|
|
|
break;
|
|
|
|
}
|
1999-04-01 10:51:48 +04:00
|
|
|
if (cmd == SIOCDIFADDR_ISO && ia == 0)
|
1996-09-08 18:28:08 +04:00
|
|
|
return (EADDRNOTAVAIL);
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
#if 0
|
|
|
|
case SIOCSIFADDR:
|
|
|
|
case SIOCSIFNETMASK:
|
|
|
|
case SIOCSIFDSTADDR:
|
|
|
|
#endif
|
1996-05-22 17:54:55 +04:00
|
|
|
if (p == 0 || (error = suser(p->p_ucred, &p->p_acflag)))
|
1993-04-09 16:00:07 +04:00
|
|
|
return (EPERM);
|
1996-09-08 18:28:08 +04:00
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
if (ifp == 0)
|
|
|
|
panic("iso_control");
|
1995-06-13 11:13:14 +04:00
|
|
|
if (ia == 0) {
|
|
|
|
MALLOC(ia, struct iso_ifaddr *, sizeof(*ia),
|
1996-02-14 01:07:57 +03:00
|
|
|
M_IFADDR, M_WAITOK);
|
1995-06-13 11:13:14 +04:00
|
|
|
if (ia == 0)
|
1993-04-09 16:00:07 +04:00
|
|
|
return (ENOBUFS);
|
1996-09-08 18:28:08 +04:00
|
|
|
bzero((caddr_t)ia, sizeof(*ia));
|
1995-06-13 11:13:14 +04:00
|
|
|
TAILQ_INSERT_TAIL(&iso_ifaddr, ia, ia_list);
|
2000-02-02 01:52:04 +03:00
|
|
|
IFAREF((struct ifaddr *)ia);
|
1996-09-08 18:28:08 +04:00
|
|
|
TAILQ_INSERT_TAIL(&ifp->if_addrlist, (struct ifaddr *)ia,
|
|
|
|
ifa_list);
|
2000-02-02 01:52:04 +03:00
|
|
|
IFAREF((struct ifaddr *)ia);
|
1995-06-13 11:13:14 +04:00
|
|
|
ia->ia_ifa.ifa_addr = sisotosa(&ia->ia_addr);
|
|
|
|
ia->ia_ifa.ifa_dstaddr = sisotosa(&ia->ia_dstaddr);
|
|
|
|
ia->ia_ifa.ifa_netmask = sisotosa(&ia->ia_sockmask);
|
1993-04-09 16:00:07 +04:00
|
|
|
ia->ia_ifp = ifp;
|
1995-04-11 08:30:47 +04:00
|
|
|
if ((ifp->if_flags & IFF_LOOPBACK) == 0)
|
1993-04-09 16:00:07 +04:00
|
|
|
iso_interfaces++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-04-01 10:51:48 +04:00
|
|
|
case SIOCGIFADDR_ISO:
|
|
|
|
case SIOCGIFNETMASK_ISO:
|
|
|
|
case SIOCGIFDSTADDR_ISO:
|
1995-06-13 11:13:14 +04:00
|
|
|
if (ia == 0)
|
1993-04-09 16:00:07 +04:00
|
|
|
return (EADDRNOTAVAIL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (cmd) {
|
|
|
|
|
1999-04-01 10:51:48 +04:00
|
|
|
case SIOCGIFADDR_ISO:
|
|
|
|
ifr->ifr_Addr = ia->ia_addr;
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
1999-04-01 10:51:48 +04:00
|
|
|
case SIOCGIFDSTADDR_ISO:
|
1993-04-09 16:00:07 +04:00
|
|
|
if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
|
|
|
|
return (EINVAL);
|
1999-04-01 10:51:48 +04:00
|
|
|
ifr->ifr_Addr = ia->ia_dstaddr;
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
1999-04-01 10:51:48 +04:00
|
|
|
case SIOCGIFNETMASK_ISO:
|
|
|
|
ifr->ifr_Addr = ia->ia_sockmask;
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
1999-04-01 10:51:48 +04:00
|
|
|
case SIOCAIFADDR_ISO:
|
1996-02-14 01:07:57 +03:00
|
|
|
maskIsNew = 0;
|
|
|
|
hostIsNew = 1;
|
|
|
|
error = 0;
|
1993-04-09 16:00:07 +04:00
|
|
|
if (ia->ia_addr.siso_family == AF_ISO) {
|
|
|
|
if (ifra->ifra_addr.siso_len == 0) {
|
|
|
|
ifra->ifra_addr = ia->ia_addr;
|
|
|
|
hostIsNew = 0;
|
|
|
|
} else if (SAME_ISOADDR(&ia->ia_addr, &ifra->ifra_addr))
|
|
|
|
hostIsNew = 0;
|
|
|
|
}
|
|
|
|
if (ifra->ifra_mask.siso_len) {
|
|
|
|
iso_ifscrub(ifp, ia);
|
|
|
|
ia->ia_sockmask = ifra->ifra_mask;
|
|
|
|
maskIsNew = 1;
|
|
|
|
}
|
|
|
|
if ((ifp->if_flags & IFF_POINTOPOINT) &&
|
|
|
|
(ifra->ifra_dstaddr.siso_family == AF_ISO)) {
|
|
|
|
iso_ifscrub(ifp, ia);
|
|
|
|
ia->ia_dstaddr = ifra->ifra_dstaddr;
|
1996-02-14 01:07:57 +03:00
|
|
|
maskIsNew = 1; /* We lie; but the effect's the same */
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
if (ifra->ifra_addr.siso_family == AF_ISO &&
|
1996-09-08 18:28:08 +04:00
|
|
|
(hostIsNew || maskIsNew))
|
1993-04-09 16:00:07 +04:00
|
|
|
error = iso_ifinit(ifp, ia, &ifra->ifra_addr, 0);
|
|
|
|
if (ifra->ifra_snpaoffset)
|
|
|
|
ia->ia_snpaoffset = ifra->ifra_snpaoffset;
|
|
|
|
return (error);
|
|
|
|
|
1999-04-01 10:51:48 +04:00
|
|
|
case SIOCDIFADDR_ISO:
|
2000-02-02 01:52:04 +03:00
|
|
|
iso_purgeaddr(&ia->ia_ifa, ifp);
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
|
|
|
|
1996-09-08 18:28:08 +04:00
|
|
|
#define cmdbyte(x) (((x) >> 8) & 0xff)
|
1993-04-09 16:00:07 +04:00
|
|
|
default:
|
1996-09-08 18:28:08 +04:00
|
|
|
if (cmdbyte(cmd) == 'a')
|
|
|
|
return (snpac_ioctl(so, cmd, data, p));
|
1993-04-09 16:00:07 +04:00
|
|
|
if (ifp == 0 || ifp->if_ioctl == 0)
|
|
|
|
return (EOPNOTSUPP);
|
1996-09-08 18:28:08 +04:00
|
|
|
return ((*ifp->if_ioctl)(ifp, cmd, data));
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-02-02 01:52:04 +03:00
|
|
|
void
|
|
|
|
iso_purgeaddr(ifa, ifp)
|
|
|
|
struct ifaddr *ifa;
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
|
|
|
struct iso_ifaddr *ia = (void *) ifa;
|
|
|
|
|
|
|
|
iso_ifscrub(ifp, ia);
|
|
|
|
TAILQ_REMOVE(&ifp->if_addrlist, (struct ifaddr *)ia, ifa_list);
|
|
|
|
IFAFREE(&ia->ia_ifa);
|
|
|
|
TAILQ_REMOVE(&iso_ifaddr, ia, ia_list);
|
|
|
|
IFAFREE((&ia->ia_ifa));
|
|
|
|
}
|
|
|
|
|
2000-02-03 02:28:08 +03:00
|
|
|
void
|
|
|
|
iso_purgeif(ifp)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
|
|
|
struct ifaddr *ifa, *nifa;
|
|
|
|
|
|
|
|
for (ifa = TAILQ_FIRST(&ifp->if_addrlist); ifa != NULL; ifa = nifa) {
|
|
|
|
nifa = TAILQ_NEXT(ifa, ifa_list);
|
|
|
|
if (ifa->ifa_addr->sa_family != AF_ISO)
|
|
|
|
continue;
|
|
|
|
iso_purgeaddr(ifa, ifp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
|
|
|
* Delete any existing route for an interface.
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
void
|
1993-04-09 16:00:07 +04:00
|
|
|
iso_ifscrub(ifp, ia)
|
2000-03-30 16:51:13 +04:00
|
|
|
struct ifnet *ifp;
|
|
|
|
struct iso_ifaddr *ia;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
int nsellength = ia->ia_addr.siso_tlen;
|
1993-04-09 16:00:07 +04:00
|
|
|
if ((ia->ia_flags & IFA_ROUTE) == 0)
|
|
|
|
return;
|
|
|
|
ia->ia_addr.siso_tlen = 0;
|
|
|
|
if (ifp->if_flags & IFF_LOOPBACK)
|
1996-02-14 01:07:57 +03:00
|
|
|
rtinit(&(ia->ia_ifa), (int) RTM_DELETE, RTF_HOST);
|
1993-04-09 16:00:07 +04:00
|
|
|
else if (ifp->if_flags & IFF_POINTOPOINT)
|
1996-02-14 01:07:57 +03:00
|
|
|
rtinit(&(ia->ia_ifa), (int) RTM_DELETE, RTF_HOST);
|
1993-04-09 16:00:07 +04:00
|
|
|
else {
|
1996-02-14 01:07:57 +03:00
|
|
|
rtinit(&(ia->ia_ifa), (int) RTM_DELETE, 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
ia->ia_addr.siso_tlen = nsellength;
|
|
|
|
ia->ia_flags &= ~IFA_ROUTE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize an interface's internet address
|
|
|
|
* and routing table entry.
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
1993-04-09 16:00:07 +04:00
|
|
|
iso_ifinit(ifp, ia, siso, scrub)
|
2000-03-30 16:51:13 +04:00
|
|
|
struct ifnet *ifp;
|
|
|
|
struct iso_ifaddr *ia;
|
1993-04-09 16:00:07 +04:00
|
|
|
struct sockaddr_iso *siso;
|
1996-02-14 01:07:57 +03:00
|
|
|
int scrub;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
|
|
|
struct sockaddr_iso oldaddr;
|
2001-04-14 03:29:55 +04:00
|
|
|
int s = splnet(), error, nsellength;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
oldaddr = ia->ia_addr;
|
|
|
|
ia->ia_addr = *siso;
|
|
|
|
/*
|
|
|
|
* Give the interface a chance to initialize
|
|
|
|
* if this is its first address,
|
|
|
|
* and to validate the address if necessary.
|
|
|
|
*/
|
1994-05-13 10:08:03 +04:00
|
|
|
if (ifp->if_ioctl &&
|
1996-02-14 01:07:57 +03:00
|
|
|
(error = (*ifp->if_ioctl) (ifp, SIOCSIFADDR, (caddr_t) ia))) {
|
1993-04-09 16:00:07 +04:00
|
|
|
splx(s);
|
|
|
|
ia->ia_addr = oldaddr;
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
if (scrub) {
|
1995-06-13 11:13:14 +04:00
|
|
|
ia->ia_ifa.ifa_addr = sisotosa(&oldaddr);
|
1993-04-09 16:00:07 +04:00
|
|
|
iso_ifscrub(ifp, ia);
|
1995-06-13 11:13:14 +04:00
|
|
|
ia->ia_ifa.ifa_addr = sisotosa(&ia->ia_addr);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
/*
|
|
|
|
* XXX -- The following is here temporarily out of laziness in not
|
|
|
|
* changing every ethernet driver's if_ioctl routine
|
|
|
|
*/
|
1999-04-14 20:26:42 +04:00
|
|
|
if (ifp->if_type == IFT_ETHER || ifp->if_type == IFT_FDDI) {
|
1993-04-09 16:00:07 +04:00
|
|
|
ia->ia_ifa.ifa_rtrequest = llc_rtrequest;
|
|
|
|
ia->ia_ifa.ifa_flags |= RTF_CLONING;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Add route for the network.
|
|
|
|
*/
|
|
|
|
nsellength = ia->ia_addr.siso_tlen;
|
|
|
|
ia->ia_addr.siso_tlen = 0;
|
|
|
|
if (ifp->if_flags & IFF_LOOPBACK) {
|
|
|
|
ia->ia_ifa.ifa_dstaddr = ia->ia_ifa.ifa_addr;
|
1996-02-14 01:07:57 +03:00
|
|
|
error = rtinit(&(ia->ia_ifa), (int) RTM_ADD, RTF_HOST | RTF_UP);
|
1993-04-09 16:00:07 +04:00
|
|
|
} else if (ifp->if_flags & IFF_POINTOPOINT &&
|
1996-02-14 01:07:57 +03:00
|
|
|
ia->ia_dstaddr.siso_family == AF_ISO)
|
|
|
|
error = rtinit(&(ia->ia_ifa), (int) RTM_ADD, RTF_HOST | RTF_UP);
|
1993-04-09 16:00:07 +04:00
|
|
|
else {
|
|
|
|
rt_maskedcopy(ia->ia_ifa.ifa_addr, ia->ia_ifa.ifa_dstaddr,
|
1996-02-14 01:07:57 +03:00
|
|
|
ia->ia_ifa.ifa_netmask);
|
1993-04-09 16:00:07 +04:00
|
|
|
ia->ia_dstaddr.siso_nlen =
|
|
|
|
min(ia->ia_addr.siso_nlen, (ia->ia_sockmask.siso_len - 6));
|
1996-02-14 01:07:57 +03:00
|
|
|
error = rtinit(&(ia->ia_ifa), (int) RTM_ADD, RTF_UP);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
ia->ia_addr.siso_tlen = nsellength;
|
|
|
|
ia->ia_flags |= IFA_ROUTE;
|
|
|
|
splx(s);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
#ifdef notdef
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
struct ifaddr *
|
1993-04-09 16:00:07 +04:00
|
|
|
iso_ifwithidi(addr)
|
2000-03-30 16:51:13 +04:00
|
|
|
struct sockaddr *addr;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct ifnet *ifp;
|
|
|
|
struct ifaddr *ifa;
|
|
|
|
u_int af = addr->sa_family;
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if (af != AF_ISO)
|
|
|
|
return (0);
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf(">>> iso_ifwithidi addr\n");
|
1995-06-13 11:13:14 +04:00
|
|
|
dump_isoaddr(satosiso(addr));
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1995-06-13 09:52:42 +04:00
|
|
|
for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) {
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_ifwithidi ifnet %s\n", ifp->if_name);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
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) {
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_ifwithidi address ");
|
1995-06-13 11:13:14 +04:00
|
|
|
dump_isoaddr(satosiso(ifa->ifa_addr));
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
if (ifa->ifa_addr->sa_family != addr->sa_family)
|
|
|
|
continue;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf(" af same, args to iso_eqtype:\n");
|
|
|
|
printf("0x%x ", satosiso(ifa->ifa_addr)->siso_addr);
|
|
|
|
printf(" 0x%x\n",
|
1996-10-11 03:12:43 +04:00
|
|
|
&satosiso(addr)->siso_addr));
|
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 (iso_eqtype(&satosiso(ifa->ifa_addr)->siso_addr,
|
|
|
|
&satosiso(addr)->siso_addr)) {
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("ifa_ifwithidi: ifa found\n");
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
return (ifa);
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ROUTE]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf(" iso_eqtype failed\n");
|
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
|
|
|
return ((struct ifaddr *) 0);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#endif /* notdef */
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
|
|
|
* FUNCTION: iso_ck_addr
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: return true if the iso_addr passed is
|
|
|
|
* within the legal size limit for an iso address.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: true or false
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* SIDE EFFECTS:
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
|
|
|
*/
|
1996-02-14 01:07:57 +03:00
|
|
|
int
|
1993-04-09 16:00:07 +04:00
|
|
|
iso_ck_addr(isoa)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct iso_addr *isoa; /* address to check */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
|
|
|
return (isoa->isoa_len <= 20);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef notdef
|
|
|
|
/*
|
|
|
|
* FUNCTION: iso_eqtype
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Determine if two iso addresses are of the same type.
|
|
|
|
* This is flaky. Really we should consider all type
|
|
|
|
* 47 addrs to be the same - but there do exist different
|
|
|
|
* structures for 47 addrs. Gosip adds a 3rd.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: true if the addresses are the same type
|
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: By type, I mean rfc986, t37, or osinet
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* This will first compare afis. If they match, then
|
|
|
|
* if the addr is not t37, the idis must be compared.
|
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
|
|
|
iso_eqtype(isoaa, isoab)
|
1996-02-14 01:07:57 +03:00
|
|
|
struct iso_addr *isoaa; /* first addr to check */
|
|
|
|
struct iso_addr *isoab; /* other addr to check */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
|
|
|
if (isoaa->isoa_afi == isoab->isoa_afi) {
|
|
|
|
if (isoaa->isoa_afi == AFI_37)
|
1996-02-14 01:07:57 +03:00
|
|
|
return (1);
|
|
|
|
else
|
1993-04-09 16:00:07 +04:00
|
|
|
return (!bcmp(&isoaa->isoa_u, &isoab->isoa_u, 2));
|
|
|
|
}
|
1996-02-14 01:07:57 +03:00
|
|
|
return (0);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1994-05-13 10:08:03 +04:00
|
|
|
#endif /* notdef */
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
|
|
|
* FUNCTION: iso_localifa()
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Find an interface addresss having a given destination
|
|
|
|
* or at least matching the net.
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: ptr to an interface address
|
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
|
|
|
*/
|
|
|
|
struct iso_ifaddr *
|
|
|
|
iso_localifa(siso)
|
2000-03-30 16:51:13 +04:00
|
|
|
struct sockaddr_iso *siso;
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct iso_ifaddr *ia;
|
|
|
|
char *cp1, *cp2, *cp3;
|
|
|
|
struct ifnet *ifp;
|
1993-04-09 16:00:07 +04:00
|
|
|
struct iso_ifaddr *ia_maybe = 0;
|
|
|
|
/*
|
|
|
|
* We make one pass looking for both net matches and an exact
|
|
|
|
* dst addr.
|
|
|
|
*/
|
1995-06-13 11:13:14 +04:00
|
|
|
for (ia = iso_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) {
|
1993-04-09 16:00:07 +04:00
|
|
|
if ((ifp = ia->ia_ifp) == 0 || ((ifp->if_flags & IFF_UP) == 0))
|
|
|
|
continue;
|
|
|
|
if (ifp->if_flags & IFF_POINTOPOINT) {
|
|
|
|
if ((ia->ia_dstaddr.siso_family == AF_ISO) &&
|
1996-02-14 01:07:57 +03:00
|
|
|
SAME_ISOADDR(&ia->ia_dstaddr, siso))
|
1993-04-09 16:00:07 +04:00
|
|
|
return (ia);
|
1996-02-14 01:07:57 +03:00
|
|
|
else if (SAME_ISOADDR(&ia->ia_addr, siso))
|
|
|
|
ia_maybe = ia;
|
1993-04-09 16:00:07 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (ia->ia_sockmask.siso_len) {
|
1996-02-14 01:07:57 +03:00
|
|
|
char *cplim = ia->ia_sockmask.siso_len +
|
|
|
|
(char *) &ia->ia_sockmask;
|
1993-04-09 16:00:07 +04:00
|
|
|
cp1 = ia->ia_sockmask.siso_data;
|
|
|
|
cp2 = siso->siso_data;
|
|
|
|
cp3 = ia->ia_addr.siso_data;
|
|
|
|
while (cp1 < cplim)
|
|
|
|
if (*cp1++ & (*cp2++ ^ *cp3++))
|
|
|
|
goto next;
|
|
|
|
ia_maybe = ia;
|
|
|
|
}
|
|
|
|
if (SAME_ISOADDR(&ia->ia_addr, siso))
|
|
|
|
return ia;
|
1996-02-14 01:07:57 +03:00
|
|
|
next: ;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
return ia_maybe;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef TPCONS
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <netiso/cons.h>
|
1994-05-13 10:08:03 +04:00
|
|
|
#endif /* TPCONS */
|
1993-04-09 16:00:07 +04:00
|
|
|
/*
|
|
|
|
* FUNCTION: iso_nlctloutput
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: Set options at the network level
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: E*
|
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: This could embody some of the functions of
|
|
|
|
* rclnp_ctloutput and cons_ctloutput.
|
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
|
|
|
iso_nlctloutput(cmd, optname, pcb, m)
|
1996-02-14 01:07:57 +03:00
|
|
|
int cmd; /* command:set or get */
|
|
|
|
int optname;/* option of interest */
|
|
|
|
caddr_t pcb; /* nl pcb */
|
|
|
|
struct mbuf *m; /* data for set, buffer for get */
|
1993-04-09 16:00:07 +04:00
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef TPCONS
|
|
|
|
struct isopcb *isop = (struct isopcb *) pcb;
|
|
|
|
#endif
|
|
|
|
int error = 0; /* return value */
|
|
|
|
caddr_t data; /* data for option */
|
|
|
|
int data_len; /* data's length */
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ISO]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_nlctloutput: cmd %x, opt %x, pcb %p, m %p\n",
|
1996-10-11 03:12:43 +04:00
|
|
|
cmd, optname, pcb, m);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
if ((cmd != PRCO_GETOPT) && (cmd != PRCO_SETOPT))
|
1996-02-14 01:07:57 +03:00
|
|
|
return (EOPNOTSUPP);
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
data = mtod(m, caddr_t);
|
|
|
|
data_len = (m)->m_len;
|
|
|
|
|
1996-02-14 01:07:57 +03:00
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ISO]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_nlctloutput: data is:\n");
|
1993-04-09 16:00:07 +04:00
|
|
|
dump_buf(data, data_len);
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
#endif
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
switch (optname) {
|
|
|
|
|
|
|
|
#ifdef TPCONS
|
1996-02-14 01:07:57 +03:00
|
|
|
case CONSOPT_X25CRUD:
|
|
|
|
if (cmd == PRCO_GETOPT) {
|
|
|
|
error = EOPNOTSUPP;
|
1993-04-09 16:00:07 +04:00
|
|
|
break;
|
1996-02-14 01:07:57 +03:00
|
|
|
}
|
|
|
|
if (data_len > MAXX25CRUDLEN) {
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
if (argo_debug[D_ISO]) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("iso_nlctloutput: setting x25 crud\n");
|
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
|
|
|
bcopy(data, (caddr_t) isop->isop_x25crud, (unsigned) data_len);
|
|
|
|
isop->isop_x25crud_len = data_len;
|
|
|
|
break;
|
|
|
|
#endif /* TPCONS */
|
|
|
|
|
|
|
|
default:
|
|
|
|
error = EOPNOTSUPP;
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
1994-05-13 10:08:03 +04:00
|
|
|
if (cmd == PRCO_SETOPT)
|
|
|
|
m_freem(m);
|
1993-04-09 16:00:07 +04:00
|
|
|
return error;
|
|
|
|
}
|
1994-05-13 10:08:03 +04:00
|
|
|
#endif /* ISO */
|
1993-04-09 16:00:07 +04:00
|
|
|
|
|
|
|
#ifdef ARGO_DEBUG
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FUNCTION: dump_isoaddr
|
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* PURPOSE: debugging
|
1993-04-09 16:00:07 +04:00
|
|
|
*
|
1996-02-14 01:07:57 +03:00
|
|
|
* RETURNS: nada
|
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
|
|
|
dump_isoaddr(s)
|
|
|
|
struct sockaddr_iso *s;
|
|
|
|
{
|
1996-02-14 01:07:57 +03:00
|
|
|
if (s->siso_family == AF_ISO) {
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("ISO address: suffixlen %d, %s\n",
|
1996-02-14 01:07:57 +03:00
|
|
|
s->siso_tlen, clnp_saddr_isop(s));
|
|
|
|
} else if (s->siso_family == AF_INET) {
|
1993-04-09 16:00:07 +04:00
|
|
|
/* hack */
|
1995-06-13 11:13:14 +04:00
|
|
|
struct sockaddr_in *sin = satosin(s);
|
1993-04-09 16:00:07 +04:00
|
|
|
|
1996-10-13 06:03:00 +04:00
|
|
|
printf("%d.%d.%d.%d: %d",
|
1996-02-14 01:07:57 +03:00
|
|
|
(sin->sin_addr.s_addr >> 24) & 0xff,
|
|
|
|
(sin->sin_addr.s_addr >> 16) & 0xff,
|
|
|
|
(sin->sin_addr.s_addr >> 8) & 0xff,
|
|
|
|
(sin->sin_addr.s_addr) & 0xff,
|
|
|
|
sin->sin_port);
|
1993-04-09 16:00:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-05-13 10:08:03 +04:00
|
|
|
#endif /* ARGO_DEBUG */
|