summaryrefslogtreecommitdiff
path: root/sys/netiso/iso_snpac.c
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1996-03-04 10:37:32 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1996-03-04 10:37:32 +0000
commit19b3595c2000294ed57cd7cb23e1d91ee553215d (patch)
tree404b337fc172b005d07d5f30eeeb873a270a9eac /sys/netiso/iso_snpac.c
parentd4b3fca05966647ecd8191d973cdce74570844ca (diff)
Initial commit of NetBSD 960217 netiso.
all the rest is the fixes to the import by Niklas.
Diffstat (limited to 'sys/netiso/iso_snpac.c')
-rw-r--r--sys/netiso/iso_snpac.c607
1 files changed, 323 insertions, 284 deletions
diff --git a/sys/netiso/iso_snpac.c b/sys/netiso/iso_snpac.c
index f03c7bc68f3..55138723796 100644
--- a/sys/netiso/iso_snpac.c
+++ b/sys/netiso/iso_snpac.c
@@ -1,4 +1,5 @@
-/* $NetBSD: iso_snpac.c,v 1.10 1995/06/13 08:12:41 mycroft Exp $ */
+/* $OpenBSD: iso_snpac.c,v 1.2 1996/03/04 10:35:39 mickey Exp $ */
+/* $NetBSD: iso_snpac.c,v 1.11 1996/02/13 22:10:25 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -40,13 +41,13 @@
All Rights Reserved
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
+both that copyright notice and this permission notice appear in
supporting documentation, and that the name of IBM not be
used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
+software without specific, written prior permission.
IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -79,6 +80,9 @@ SOFTWARE.
#include <net/if_dl.h>
#include <net/route.h>
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+
#include <netiso/iso.h>
#include <netiso/iso_var.h>
#include <netiso/iso_snpac.h>
@@ -87,23 +91,23 @@ SOFTWARE.
#include <netiso/esis.h>
#include <netiso/argo_debug.h>
-int iso_systype = SNPA_ES; /* default to be an ES */
-extern short esis_holding_time, esis_config_time, esis_esconfig_time;
-extern struct timeval time;
-extern void esis_config();
-extern int hz;
-static void snpac_fixdstandmask();
+int iso_systype = SNPA_ES; /* default to be an ES */
+extern short esis_holding_time, esis_config_time, esis_esconfig_time;
+extern struct timeval time;
+extern int hz;
LIST_HEAD(, llinfo_llc) llinfo_llc;
struct sockaddr_iso blank_siso = {sizeof(blank_siso), AF_ISO};
-extern u_long iso_hashchar();
static struct sockaddr_iso
- dst = {sizeof(dst), AF_ISO},
- gte = {sizeof(dst), AF_ISO},
- src = {sizeof(dst), AF_ISO},
- msk = {sizeof(dst), AF_ISO},
- zmk = {0};
+ dst = {sizeof(dst), AF_ISO},
+ gte = {sizeof(gte), AF_ISO},
+#if 0
+ src = {sizeof(src), AF_ISO},
+#endif
+ msk = {sizeof(msk), AF_ISO},
+ zmk = {0, 0};
+
#define zsi blank_siso
#define zero_isoa zsi.siso_addr
#define zap_isoaddr(a, b) {Bzero(&a.siso_addr, sizeof(*r)); r = b; \
@@ -115,10 +119,12 @@ static struct sockaddr_dl gte_dl;
#define zap_linkaddr(a, b, c, i) \
(*a = blank_dl, bcopy(b, a->sdl_data, a->sdl_alen = c), a->sdl_index = i)
+static void snpac_fixdstandmask __P((int));
+
/*
* We only keep track of a single IS at a time.
*/
-struct rtentry *known_is;
+struct rtentry *known_is;
/*
* Addresses taken from NBS agreements, December 1987.
@@ -137,199 +143,211 @@ struct rtentry *known_is;
* lan_output() That means that if these multicast addresses change
* the token ring driver must be altered.
*/
-char all_es_snpa[] = { 0x09, 0x00, 0x2b, 0x00, 0x00, 0x04 };
-char all_is_snpa[] = { 0x09, 0x00, 0x2b, 0x00, 0x00, 0x05 };
-char all_l1is_snpa[] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x14};
-char all_l2is_snpa[] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x15};
+char all_es_snpa[] = {0x09, 0x00, 0x2b, 0x00, 0x00, 0x04};
+char all_is_snpa[] = {0x09, 0x00, 0x2b, 0x00, 0x00, 0x05};
+char all_l1is_snpa[] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x14};
+char all_l2is_snpa[] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x15};
union sockunion {
struct sockaddr_iso siso;
- struct sockaddr_dl sdl;
- struct sockaddr sa;
+ struct sockaddr_dl sdl;
+ struct sockaddr sa;
};
/*
* FUNCTION: llc_rtrequest
*
- * PURPOSE: Manage routing table entries specific to LLC for ISO.
+ * PURPOSE: Manage routing table entries specific to LLC for ISO.
*
- * NOTES: This does a lot of obscure magic;
+ * NOTES: This does a lot of obscure magic;
*/
+void
llc_rtrequest(req, rt, sa)
-int req;
-register struct rtentry *rt;
-struct sockaddr *sa;
+ int req;
+ register struct rtentry *rt;
+ struct sockaddr *sa;
{
- register union sockunion *gate = (union sockunion *)rt->rt_gateway;
- register struct llinfo_llc *lc = (struct llinfo_llc *)rt->rt_llinfo, *lc2;
- struct rtentry *rt2;
- struct ifnet *ifp = rt->rt_ifp;
- int addrlen = ifp->if_addrlen;
-#define LLC_SIZE 3 /* XXXXXX do this right later */
-
- IFDEBUG (D_SNPA)
- printf("llc_rtrequest(%d, %x, %x)\n", req, rt, sa);
- ENDDEBUG
+ register union sockunion *gate = (union sockunion *) rt->rt_gateway;
+ register struct llinfo_llc *lc = (struct llinfo_llc *) rt->rt_llinfo;
+ struct ifnet *ifp = rt->rt_ifp;
+ int addrlen = ifp->if_addrlen;
+#define LLC_SIZE 3 /* XXXXXX do this right later */
+
+#ifdef ARGO_DEBUG
+ if (argo_debug[D_SNPA]) {
+ printf("llc_rtrequest(%d, %x, %x)\n", req,
+ (unsigned int) rt, (unsigned int) sa);
+ }
+#endif
if (rt->rt_flags & RTF_GATEWAY)
return;
- else switch (req) {
- case RTM_ADD:
- /*
- * Case 1: This route may come from a route to iface with mask
- * or from a default route.
- */
- if (rt->rt_flags & RTF_CLONING) {
- iso_setmcasts(ifp, req);
- rt_setgate(rt, rt_key(rt),
- (struct sockaddr *)&blank_dl);
- return;
- }
- if (lc != 0)
- return; /* happens on a route change */
- /* FALLTHROUGH */
- case RTM_RESOLVE:
- /*
- * Case 2: This route may come from cloning, or a manual route
- * add with a LL address.
- */
- if (gate->sdl.sdl_family != AF_LINK) {
- log(LOG_DEBUG, "llc_rtrequest: got non-link non-gateway route\n");
+ else
+ switch (req) {
+ case RTM_ADD:
+ /*
+ * Case 1: This route may come from a route to iface with mask
+ * or from a default route.
+ */
+ if (rt->rt_flags & RTF_CLONING) {
+ iso_setmcasts(ifp, req);
+ rt_setgate(rt, rt_key(rt),
+ (struct sockaddr *) & blank_dl);
+ return;
+ }
+ if (lc != 0)
+ return; /* happens on a route change */
+ /* FALLTHROUGH */
+ case RTM_RESOLVE:
+ /*
+ * Case 2: This route may come from cloning, or a manual route
+ * add with a LL address.
+ */
+ if (gate->sdl.sdl_family != AF_LINK) {
+ log(LOG_DEBUG, "llc_rtrequest: got non-link non-gateway route\n");
+ break;
+ }
+ R_Malloc(lc, struct llinfo_llc *, sizeof(*lc));
+ rt->rt_llinfo = (caddr_t) lc;
+ if (lc == 0) {
+ log(LOG_DEBUG, "llc_rtrequest: malloc failed\n");
+ break;
+ }
+ Bzero(lc, sizeof(*lc));
+ lc->lc_rt = rt;
+ rt->rt_flags |= RTF_LLINFO;
+ LIST_INSERT_HEAD(&llinfo_llc, lc, lc_list);
+ if (gate->sdl.sdl_alen == sizeof(struct esis_req) + addrlen) {
+ gate->sdl.sdl_alen -= sizeof(struct esis_req);
+ bcopy(addrlen + LLADDR(&gate->sdl),
+ (caddr_t) & lc->lc_er, sizeof(lc->lc_er));
+ } else if (gate->sdl.sdl_alen == addrlen)
+ lc->lc_flags = (SNPA_ES | SNPA_VALID | SNPA_PERM);
break;
- }
- R_Malloc(lc, struct llinfo_llc *, sizeof (*lc));
- rt->rt_llinfo = (caddr_t)lc;
- if (lc == 0) {
- log(LOG_DEBUG, "llc_rtrequest: malloc failed\n");
+ case RTM_DELETE:
+ if (rt->rt_flags & RTF_CLONING)
+ iso_setmcasts(ifp, req);
+ if (lc == 0)
+ return;
+ LIST_REMOVE(lc, lc_list);
+ Free(lc);
+ rt->rt_llinfo = 0;
+ rt->rt_flags &= ~RTF_LLINFO;
break;
}
- Bzero(lc, sizeof(*lc));
- lc->lc_rt = rt;
- rt->rt_flags |= RTF_LLINFO;
- LIST_INSERT_HEAD(&llinfo_llc, lc, lc_list);
- if (gate->sdl.sdl_alen == sizeof(struct esis_req) + addrlen) {
- gate->sdl.sdl_alen -= sizeof(struct esis_req);
- bcopy(addrlen + LLADDR(&gate->sdl),
- (caddr_t)&lc->lc_er, sizeof(lc->lc_er));
- } else if (gate->sdl.sdl_alen == addrlen)
- lc->lc_flags = (SNPA_ES | SNPA_VALID | SNPA_PERM);
- break;
- case RTM_DELETE:
- if (rt->rt_flags & RTF_CLONING)
- iso_setmcasts(ifp, req);
- if (lc == 0)
- return;
- LIST_REMOVE(lc, lc_list);
- Free(lc);
- rt->rt_llinfo = 0;
- rt->rt_flags &= ~RTF_LLINFO;
- break;
- }
if (rt->rt_rmx.rmx_mtu == 0) {
- rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu - LLC_SIZE;
+ rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu - LLC_SIZE;
}
}
+
/*
* FUNCTION: iso_setmcasts
*
- * PURPOSE: Enable/Disable ESIS/ISIS multicast reception on interfaces.
+ * PURPOSE: Enable/Disable ESIS/ISIS multicast reception on
+ * interfaces.
*
- * NOTES: This also does a lot of obscure magic;
+ * NOTES: This also does a lot of obscure magic;
*/
+void
iso_setmcasts(ifp, req)
- struct ifnet *ifp;
- int req;
+ struct ifnet *ifp;
+ int req;
{
- static char *addrlist[] =
- { all_es_snpa, all_is_snpa, all_l1is_snpa, all_l2is_snpa, 0};
- struct ifreq ifr;
+ static char *addrlist[] =
+ {all_es_snpa, all_is_snpa, all_l1is_snpa, all_l2is_snpa, 0};
+ struct ifreq ifr;
register caddr_t *cpp;
- int doreset = 0;
+ int doreset = 0;
- bzero((caddr_t)&ifr, sizeof(ifr));
- for (cpp = (caddr_t *)addrlist; *cpp; cpp++) {
- bcopy(*cpp, (caddr_t)ifr.ifr_addr.sa_data, 6);
+ bzero((caddr_t) & ifr, sizeof(ifr));
+ for (cpp = (caddr_t *) addrlist; *cpp; cpp++) {
+ bcopy(*cpp, (caddr_t) ifr.ifr_addr.sa_data, 6);
if (req == RTM_ADD)
- if (ether_addmulti(&ifr, (struct arpcom *)ifp) == ENETRESET)
+ if (ether_addmulti(&ifr, (struct arpcom *) ifp) == ENETRESET)
doreset++;
- else
- if (ether_delmulti(&ifr, (struct arpcom *)ifp) == ENETRESET)
+ else if (ether_delmulti(&ifr, (struct arpcom *) ifp) == ENETRESET)
doreset++;
}
if (doreset) {
if (ifp->if_reset)
- (*ifp->if_reset)(ifp->if_unit);
+ (*ifp->if_reset) (ifp->if_unit);
else
printf("iso_setmcasts: %s%d needs reseting to receive iso mcasts\n",
- ifp->if_name, ifp->if_unit);
+ ifp->if_name, ifp->if_unit);
}
}
+
/*
* FUNCTION: iso_snparesolve
*
- * PURPOSE: Resolve an iso address into snpa address
+ * PURPOSE: Resolve an iso address into snpa address
*
- * RETURNS: 0 if addr is resolved
- * errno if addr is unknown
+ * RETURNS: 0 if addr is resolved
+ * errno if addr is unknown
*
- * SIDE EFFECTS:
+ * SIDE EFFECTS:
*
- * NOTES: Now that we have folded the snpa cache into the routing
- * table, we know there is no snpa address known for this
- * destination. If we know of a default IS, then the address
- * of the IS is returned. If no IS is known, then return the
- * multi-cast address for "all ES" for this interface.
+ * NOTES: Now that we have folded the snpa cache into the routing
+ * table, we know there is no snpa address known for this
+ * destination. If we know of a default IS, then the
+ * address of the IS is returned. If no IS is known,
+ * then return the multi-cast address for "all ES" for
+ * this interface.
*
- * NB: the last case described above constitutes the
- * query configuration function 9542, sec 6.5
- * A mechanism is needed to prevent this function from
- * being invoked if the system is an IS.
+ * NB: the last case described above constitutes the
+ * query configuration function 9542, sec 6.5
+ * A mechanism is needed to prevent this function from
+ * being invoked if the system is an IS.
*/
+int
iso_snparesolve(ifp, dest, snpa, snpa_len)
-struct ifnet *ifp; /* outgoing interface */
-struct sockaddr_iso *dest; /* destination */
-caddr_t snpa; /* RESULT: snpa to be used */
-int *snpa_len; /* RESULT: length of snpa */
+ struct ifnet *ifp; /* outgoing interface */
+ struct sockaddr_iso *dest; /* destination */
+ caddr_t snpa; /* RESULT: snpa to be used */
+ int *snpa_len; /* RESULT: length of snpa */
{
- struct llinfo_llc *sc; /* ptr to snpa table entry */
- caddr_t found_snpa;
- int addrlen;
+ struct llinfo_llc *sc; /* ptr to snpa table entry */
+ caddr_t found_snpa;
+ int addrlen;
/*
- * This hack allows us to send esis packets that have the destination snpa
- * addresss embedded in the destination nsap address
+ * This hack allows us to send esis packets that have the destination
+ * snpa addresss embedded in the destination nsap address
*/
if (dest->siso_data[0] == AFI_SNA) {
/*
* This is a subnetwork address. Return it immediately
*/
- IFDEBUG(D_SNPA)
+#ifdef ARGO_DEBUG
+ if (argo_debug[D_SNPA]) {
printf("iso_snparesolve: return SN address\n");
- ENDDEBUG
+ }
+#endif
addrlen = dest->siso_nlen - 1; /* subtract size of AFI */
found_snpa = (caddr_t) dest->siso_data + 1;
- /*
- * If we are an IS, we can't do much with the packet;
- * Check if we know about an IS.
- */
+ /*
+ * If we are an IS, we can't do much with the packet; Check
+ * if we know about an IS.
+ */
} else if (iso_systype != SNPA_IS && known_is != 0 &&
- (sc = (struct llinfo_llc *)known_is->rt_llinfo) &&
- (sc->lc_flags & SNPA_VALID)) {
+ (sc = (struct llinfo_llc *) known_is->rt_llinfo) &&
+ (sc->lc_flags & SNPA_VALID)) {
register struct sockaddr_dl *sdl =
- (struct sockaddr_dl *)(known_is->rt_gateway);
+ (struct sockaddr_dl *) (known_is->rt_gateway);
found_snpa = LLADDR(sdl);
addrlen = sdl->sdl_alen;
} else if (ifp->if_flags & IFF_BROADCAST) {
- /*
- * no IS, no match. Return "all es" multicast address for this
- * interface, as per Query Configuration Function (9542 sec 6.5)
+ /*
+ * no IS, no match. Return "all es" multicast address for
+ * this interface, as per Query Configuration Function (9542
+ * sec 6.5)
*
- * Note: there is a potential problem here. If the destination
- * is on the subnet and it does not respond with a ESH, but
- * does send back a TP CC, a connection could be established
- * where we always transmit the CLNP packet to "all es"
+ * Note: there is a potential problem here. If the destination
+ * is on the subnet and it does not respond with a ESH, but
+ * does send back a TP CC, a connection could be established
+ * where we always transmit the CLNP packet to "all es"
*/
addrlen = ifp->if_addrlen;
- found_snpa = (caddr_t)all_es_snpa;
+ found_snpa = (caddr_t) all_es_snpa;
} else
return (ENETUNREACH);
bcopy(found_snpa, snpa, *snpa_len = addrlen);
@@ -340,28 +358,28 @@ int *snpa_len; /* RESULT: length of snpa */
/*
* FUNCTION: snpac_free
*
- * PURPOSE: free an entry in the iso address map table
+ * PURPOSE: free an entry in the iso address map table
*
- * RETURNS: nothing
+ * RETURNS: nothing
*
- * SIDE EFFECTS:
+ * SIDE EFFECTS:
*
- * NOTES: If there is a route entry associated with cache
- * entry, then delete that as well
+ * NOTES: If there is a route entry associated with cache
+ * entry, then delete that as well
*/
+void
snpac_free(lc)
-register struct llinfo_llc *lc; /* entry to free */
+ register struct llinfo_llc *lc; /* entry to free */
{
register struct rtentry *rt = lc->lc_rt;
- register struct iso_addr *r;
if (known_is == rt)
known_is = 0;
if (rt && (rt->rt_flags & RTF_UP) &&
- (rt->rt_flags & (RTF_DYNAMIC | RTF_MODIFIED))) {
- RTFREE(rt);
- rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, rt_mask(rt),
- rt->rt_flags, (struct rtentry **)0);
+ (rt->rt_flags & (RTF_DYNAMIC | RTF_MODIFIED))) {
+ RTFREE(rt);
+ rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, rt_mask(rt),
+ rt->rt_flags, (struct rtentry **) 0);
RTFREE(rt);
}
}
@@ -369,79 +387,90 @@ register struct llinfo_llc *lc; /* entry to free */
/*
* FUNCTION: snpac_add
*
- * PURPOSE: Add an entry to the snpa cache
+ * PURPOSE: Add an entry to the snpa cache
*
- * RETURNS:
+ * RETURNS:
*
- * SIDE EFFECTS:
+ * SIDE EFFECTS:
*
- * NOTES: If entry already exists, then update holding time.
+ * NOTES: If entry already exists, then update holding time.
*/
+int
snpac_add(ifp, nsap, snpa, type, ht, nsellength)
-struct ifnet *ifp; /* interface info is related to */
-struct iso_addr *nsap; /* nsap to add */
-caddr_t snpa; /* translation */
-char type; /* SNPA_IS or SNPA_ES */
-u_short ht; /* holding time (in seconds) */
-int nsellength; /* nsaps may differ only in trailing bytes */
+ struct ifnet *ifp; /* interface info is related to */
+ struct iso_addr *nsap; /* nsap to add */
+ caddr_t snpa; /* translation */
+ char type; /* SNPA_IS or SNPA_ES */
+ u_short ht; /* holding time (in seconds) */
+ int nsellength; /* nsaps may differ only in trailing
+ * bytes */
{
- register struct llinfo_llc *lc;
+ register struct llinfo_llc *lc;
register struct rtentry *rt;
- struct rtentry *mrt = 0;
- register struct iso_addr *r; /* for zap_isoaddr macro */
- int snpalen = min(ifp->if_addrlen, MAX_SNPALEN);
- int new_entry = 0, index = ifp->if_index, iftype = ifp->if_type;
+ struct rtentry *mrt = 0;
+ register struct iso_addr *r; /* for zap_isoaddr macro */
+ int snpalen = min(ifp->if_addrlen, MAX_SNPALEN);
+ int new_entry = 0, index = ifp->if_index, iftype = ifp->if_type;
- IFDEBUG(D_SNPA)
+#ifdef ARGO_DEBUG
+ if (argo_debug[D_SNPA]) {
printf("snpac_add(%x, %x, %x, %x, %x, %x)\n",
- ifp, nsap, snpa, type, ht, nsellength);
- ENDDEBUG
+ (unsigned int) ifp,
+ (unsigned int) nsap,
+ (unsigned int) snpa, type, ht, nsellength);
+ }
+#endif
zap_isoaddr(dst, nsap);
rt = rtalloc1(sisotosa(&dst), 0);
- IFDEBUG(D_SNPA)
- printf("snpac_add: rtalloc1 returns %x\n", rt);
- ENDDEBUG
+#ifdef ARGO_DEBUG
+ if (argo_debug[D_SNPA]) {
+ printf("snpac_add: rtalloc1 returns %x\n", (unsigned int) rt);
+ }
+#endif
if (rt == 0) {
struct sockaddr *netmask;
- int flags;
- add:
+ int flags;
+add:
if (nsellength) {
- netmask = sisotosa(&msk); flags = RTF_UP;
+ netmask = sisotosa(&msk);
+ flags = RTF_UP;
snpac_fixdstandmask(nsellength);
} else {
- netmask = 0; flags = RTF_UP | RTF_HOST;
+ netmask = 0;
+ flags = RTF_UP | RTF_HOST;
}
new_entry = 1;
zap_linkaddr((&gte_dl), snpa, snpalen, index);
gte_dl.sdl_type = iftype;
if (rtrequest(RTM_ADD, sisotosa(&dst), S(gte_dl), netmask,
- flags, &mrt) || mrt == 0)
+ flags, &mrt) || mrt == 0)
return (0);
rt = mrt;
rt->rt_refcnt--;
} else {
- register struct sockaddr_dl *sdl = (struct sockaddr_dl *)rt->rt_gateway;
+ register struct sockaddr_dl *sdl = (struct sockaddr_dl *) rt->rt_gateway;
rt->rt_refcnt--;
if ((rt->rt_flags & RTF_LLINFO) == 0)
goto add;
if (nsellength && (rt->rt_flags & RTF_HOST)) {
if (rt->rt_refcnt == 0) {
rtrequest(RTM_DELETE, sisotosa(&dst),
- (struct sockaddr *)0, (struct sockaddr *)0,
- 0, (struct rtentry **)0);
+ (struct sockaddr *) 0, (struct sockaddr *) 0,
+ 0, (struct rtentry **) 0);
rt = 0;
goto add;
} else {
- static struct iso_addr nsap2; register char *cp;
+ static struct iso_addr nsap2;
+ register char *cp;
nsap2 = *nsap;
cp = nsap2.isoa_genaddr + nsap->isoa_len - nsellength;
- while (cp < (char *)(1 + &nsap2))
+ while (cp < (char *) (1 + &nsap2))
*cp++ = 0;
(void) snpac_add(ifp, &nsap2, snpa, type, ht, nsellength);
}
}
if (sdl->sdl_family != AF_LINK || sdl->sdl_alen == 0) {
- int old_sdl_len = sdl->sdl_len;
+ int old_sdl_len = sdl->sdl_len;
if (old_sdl_len < sizeof(*sdl)) {
log(LOG_DEBUG, "snpac_add: cant make room for lladdr\n");
return (0);
@@ -452,7 +481,7 @@ int nsellength; /* nsaps may differ only in trailing bytes */
new_entry = 1;
}
}
- if ((lc = (struct llinfo_llc *)rt->rt_llinfo) == 0)
+ if ((lc = (struct llinfo_llc *) rt->rt_llinfo) == 0)
panic("snpac_rtrequest");
rt->rt_rmx.rmx_expire = ht + time.tv_sec;
lc->lc_flags = SNPA_VALID | type;
@@ -463,17 +492,18 @@ int nsellength; /* nsaps may differ only in trailing bytes */
static void
snpac_fixdstandmask(nsellength)
+ int nsellength;
{
- register char *cp = msk.siso_data, *cplim;
+ register char *cp = msk.siso_data, *cplim;
cplim = cp + (dst.siso_nlen -= nsellength);
- msk.siso_len = cplim - (char *)&msk;
+ msk.siso_len = cplim - (char *) &msk;
msk.siso_nlen = 0;
while (cp < cplim)
*cp++ = -1;
- while (cp < (char *)msk.siso_pad)
+ while (cp < (char *) msk.siso_pad)
*cp++ = 0;
- for (cp = dst.siso_data + dst.siso_nlen; cp < (char *)dst.siso_pad; )
+ for (cp = dst.siso_data + dst.siso_nlen; cp < (char *) dst.siso_pad;)
*cp++ = 0;
}
@@ -484,43 +514,46 @@ snpac_fixdstandmask(nsellength)
*
* RETURNS: 0 on success, or unix error code
*
- * SIDE EFFECTS:
+ * SIDE EFFECTS:
*
- * NOTES:
+ * NOTES:
*/
-snpac_ioctl (so, cmd, data)
-struct socket *so;
-u_long cmd; /* ioctl to process */
-caddr_t data; /* data for the cmd */
+int
+snpac_ioctl(so, cmd, data)
+ struct socket *so;
+ u_long cmd; /* ioctl to process */
+ caddr_t data; /* data for the cmd */
{
- register struct systype_req *rq = (struct systype_req *)data;
+ register struct systype_req *rq = (struct systype_req *) data;
- IFDEBUG(D_IOCTL)
+#ifdef ARGO_DEBUG
+ if (argo_debug[D_IOCTL]) {
if (cmd == SIOCSSTYPE)
printf("snpac_ioctl: cmd set, type x%x, ht %d, ct %d\n",
- rq->sr_type, rq->sr_holdt, rq->sr_configt);
+ rq->sr_type, rq->sr_holdt, rq->sr_configt);
else
printf("snpac_ioctl: cmd get\n");
- ENDDEBUG
+ }
+#endif
if (cmd == SIOCSSTYPE) {
if ((so->so_state & SS_PRIV) == 0)
return (EPERM);
- if ((rq->sr_type & (SNPA_ES|SNPA_IS)) == (SNPA_ES|SNPA_IS))
- return(EINVAL);
+ if ((rq->sr_type & (SNPA_ES | SNPA_IS)) == (SNPA_ES | SNPA_IS))
+ return (EINVAL);
if (rq->sr_type & SNPA_ES) {
iso_systype = SNPA_ES;
} else if (rq->sr_type & SNPA_IS) {
iso_systype = SNPA_IS;
} else {
- return(EINVAL);
+ return (EINVAL);
}
esis_holding_time = rq->sr_holdt;
esis_config_time = rq->sr_configt;
if (esis_esconfig_time != rq->sr_esconfigt) {
- untimeout(esis_config, (caddr_t)0);
+ untimeout(esis_config, (caddr_t) 0);
esis_esconfig_time = rq->sr_esconfigt;
- esis_config();
+ esis_config(NULL);
}
} else if (cmd == SIOCGSTYPE) {
rq->sr_type = iso_systype;
@@ -540,15 +573,14 @@ caddr_t data; /* data for the cmd */
*
* RETURNS: nothing
*
- * SIDE EFFECTS:
+ * SIDE EFFECTS:
*
- * NOTES:
+ * NOTES:
*/
+void
snpac_logdefis(sc)
-register struct rtentry *sc;
+ register struct rtentry *sc;
{
- register struct iso_addr *r;
- register struct sockaddr_dl *sdl = (struct sockaddr_dl *)sc->rt_gateway;
register struct rtentry *rt;
if (known_is == sc || !(sc->rt_flags & RTF_HOST))
@@ -558,12 +590,12 @@ register struct rtentry *sc;
}
known_is = sc;
sc->rt_refcnt++;
- rt = rtalloc1((struct sockaddr *)&zsi, 0);
+ rt = rtalloc1((struct sockaddr *) & zsi, 0);
if (rt == 0)
rtrequest(RTM_ADD, sisotosa(&zsi), rt_key(sc), sisotosa(&zmk),
- RTF_DYNAMIC|RTF_GATEWAY, 0);
+ RTF_DYNAMIC | RTF_GATEWAY, 0);
else {
- if ((rt->rt_flags & RTF_DYNAMIC) &&
+ if ((rt->rt_flags & RTF_DYNAMIC) &&
(rt->rt_flags & RTF_GATEWAY) && rt_mask(rt)->sa_len == 0)
rt_setgate(rt, rt_key(rt), rt_key(sc));
}
@@ -572,31 +604,33 @@ register struct rtentry *sc;
/*
* FUNCTION: snpac_age
*
- * PURPOSE: Time out snpac entries
+ * PURPOSE: Time out snpac entries
*
- * RETURNS:
+ * RETURNS:
*
- * SIDE EFFECTS:
+ * SIDE EFFECTS:
*
- * NOTES: When encountering an entry for the first time, snpac_age
- * may delete up to SNPAC_AGE too many seconds. Ie.
- * if the entry is added a moment before snpac_age is
- * called, the entry will immediately have SNPAC_AGE
- * seconds taken off the holding time, even though
- * it has only been held a brief moment.
+ * NOTES: When encountering an entry for the first time, snpac_age
+ * may delete up to SNPAC_AGE too many seconds. Ie.
+ * if the entry is added a moment before snpac_age is
+ * called, the entry will immediately have SNPAC_AGE
+ * seconds taken off the holding time, even though
+ * it has only been held a brief moment.
*
- * The proper way to do this is set an expiry timeval
- * equal to current time + holding time. Then snpac_age
- * would time out entries where expiry date is older
- * than the current time.
+ * The proper way to do this is set an expiry timeval
+ * equal to current time + holding time. Then snpac_age
+ * would time out entries where expiry date is older
+ * than the current time.
*/
+/*ARGSUSED*/
void
-snpac_age()
+snpac_age(v)
+ void *v;
{
- register struct llinfo_llc *lc, *nlc;
- register struct rtentry *rt;
+ register struct llinfo_llc *lc, *nlc;
+ register struct rtentry *rt;
- timeout(snpac_age, (caddr_t)0, SNPAC_AGE * hz);
+ timeout(snpac_age, (caddr_t) 0, SNPAC_AGE * hz);
for (lc = llinfo_llc.lh_first; lc != 0; lc = nlc) {
nlc = lc->lc_list.le_next;
@@ -611,42 +645,44 @@ snpac_age()
/*
* FUNCTION: snpac_ownmulti
*
- * PURPOSE: Determine if the snpa address is a multicast address
- * of the same type as the system.
+ * PURPOSE: Determine if the snpa address is a multicast address
+ * of the same type as the system.
*
- * RETURNS: true or false
+ * RETURNS: true or false
*
- * SIDE EFFECTS:
+ * SIDE EFFECTS:
*
- * NOTES: Used by interface drivers when not in eavesdrop mode
- * as interm kludge until
- * real multicast addresses can be configured
+ * NOTES: Used by interface drivers when not in eavesdrop mode
+ * as interm kludge until
+ * real multicast addresses can be configured
*/
+int
snpac_ownmulti(snpa, len)
-caddr_t snpa;
-u_int len;
+ caddr_t snpa;
+ u_int len;
{
return (((iso_systype & SNPA_ES) &&
- (!bcmp(snpa, (caddr_t)all_es_snpa, len))) ||
- ((iso_systype & SNPA_IS) &&
- (!bcmp(snpa, (caddr_t)all_is_snpa, len))));
+ (!bcmp(snpa, (caddr_t) all_es_snpa, len))) ||
+ ((iso_systype & SNPA_IS) &&
+ (!bcmp(snpa, (caddr_t) all_is_snpa, len))));
}
/*
* FUNCTION: snpac_flushifp
*
- * PURPOSE: Flush entries associated with specific ifp
+ * PURPOSE: Flush entries associated with specific ifp
*
- * RETURNS: nothing
+ * RETURNS: nothing
*
- * SIDE EFFECTS:
+ * SIDE EFFECTS:
*
- * NOTES:
+ * NOTES:
*/
+void
snpac_flushifp(ifp)
-struct ifnet *ifp;
+ struct ifnet *ifp;
{
- register struct llinfo_llc *lc;
+ register struct llinfo_llc *lc;
for (lc = llinfo_llc.lh_first; lc != 0; lc = lc->lc_list.le_next) {
if (lc->lc_rt->rt_ifp == ifp && (lc->lc_flags & SNPA_VALID))
@@ -657,36 +693,39 @@ struct ifnet *ifp;
/*
* FUNCTION: snpac_rtrequest
*
- * PURPOSE: Make a routing request
+ * PURPOSE: Make a routing request
*
- * RETURNS: nothing
+ * RETURNS: nothing
*
- * SIDE EFFECTS:
+ * SIDE EFFECTS:
*
- * NOTES: In the future, this should make a request of a user
- * level routing daemon.
+ * NOTES: In the future, this should make a request of a user
+ * level routing daemon.
*/
+void
snpac_rtrequest(req, host, gateway, netmask, flags, ret_nrt)
-int req;
-struct iso_addr *host;
-struct iso_addr *gateway;
-struct iso_addr *netmask;
-short flags;
-struct rtentry **ret_nrt;
+ int req;
+ struct iso_addr *host;
+ struct iso_addr *gateway;
+ struct iso_addr *netmask;
+ short flags;
+ struct rtentry **ret_nrt;
{
register struct iso_addr *r;
- IFDEBUG(D_SNPA)
+#ifdef ARGO_DEBUG
+ if (argo_debug[D_SNPA]) {
printf("snpac_rtrequest: ");
if (req == RTM_ADD)
printf("add");
else if (req == RTM_DELETE)
printf("delete");
- else
+ else
printf("unknown command");
printf(" dst: %s\n", clnp_iso_addrp(host));
printf("\tgateway: %s\n", clnp_iso_addrp(gateway));
- ENDDEBUG
+ }
+#endif
zap_isoaddr(dst, host);
@@ -694,35 +733,35 @@ struct rtentry **ret_nrt;
if (netmask) {
zap_isoaddr(msk, netmask);
msk.siso_nlen = 0;
- msk.siso_len = msk.siso_pad - (u_char *)&msk;
+ msk.siso_len = msk.siso_pad - (u_char *) & msk;
}
-
rtrequest(req, sisotosa(&dst), sisotosa(&gte),
- (netmask ? sisotosa(&msk) : (struct sockaddr *)0), flags, ret_nrt);
+ (netmask ? sisotosa(&msk) : (struct sockaddr *) 0), flags, ret_nrt);
}
/*
* FUNCTION: snpac_addrt
*
- * PURPOSE: Associate a routing entry with an snpac entry
+ * PURPOSE: Associate a routing entry with an snpac entry
*
- * RETURNS: nothing
+ * RETURNS: nothing
*
- * SIDE EFFECTS:
+ * SIDE EFFECTS:
*
- * NOTES: If a cache entry exists for gateway, then
- * make a routing entry (host, gateway) and associate
- * with gateway.
+ * NOTES: If a cache entry exists for gateway, then
+ * make a routing entry (host, gateway) and associate
+ * with gateway.
*
- * If a route already exists and is different, first delete
- * it.
+ * If a route already exists and is different, first delete
+ * it.
*
- * This could be made more efficient by checking
- * the existing route before adding a new one.
+ * This could be made more efficient by checking
+ * the existing route before adding a new one.
*/
+void
snpac_addrt(ifp, host, gateway, netmask)
-struct ifnet *ifp;
-struct iso_addr *host, *gateway, *netmask;
+ struct ifnet *ifp;
+ struct iso_addr *host, *gateway, *netmask;
{
register struct iso_addr *r;
@@ -731,11 +770,11 @@ struct iso_addr *host, *gateway, *netmask;
if (netmask) {
zap_isoaddr(msk, netmask);
msk.siso_nlen = 0;
- msk.siso_len = msk.siso_pad - (u_char *)&msk;
+ msk.siso_len = msk.siso_pad - (u_char *) & msk;
rtredirect(sisotosa(&dst), sisotosa(&gte), sisotosa(&msk),
- RTF_DONE, sisotosa(&gte), 0);
+ RTF_DONE, sisotosa(&gte), 0);
} else
- rtredirect(sisotosa(&dst), sisotosa(&gte), (struct sockaddr *)0,
- RTF_DONE | RTF_HOST, sisotosa(&gte), 0);
+ rtredirect(sisotosa(&dst), sisotosa(&gte), (struct sockaddr *) 0,
+ RTF_DONE | RTF_HOST, sisotosa(&gte), 0);
}
-#endif /* ISO */
+#endif /* ISO */