summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/net/if_ethersubr.c110
-rw-r--r--sys/net/if_loop.c14
-rw-r--r--sys/net/netisr.h3
3 files changed, 124 insertions, 3 deletions
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 00b249418fd..36f1b0e20cb 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ethersubr.c,v 1.17 1997/01/26 21:43:36 tholo Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.18 1997/07/23 03:46:01 denny Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
@@ -85,6 +85,20 @@
#include <netccitt/dll.h>
#include <netccitt/llc_var.h>
+#ifdef NETATALK
+#include <netatalk/at.h>
+#include <netatalk/at_var.h>
+#include <netatalk/at_extern.h>
+
+/* Should we include <netatalk/phase2.h> here instead? */
+#define llc_snap_org_code llc_un.type_snap.org_code
+#define llc_snap_ether_type llc_un.type_snap.ether_type
+
+extern u_char at_org_code[ 3 ];
+extern u_char aarp_org_code[ 3 ];
+#endif /* NETATALK */
+
+
#if defined(CCITT)
#include <sys/socketvar.h>
#endif
@@ -128,6 +142,11 @@ ether_ioctl(ifp, arp, cmd, data)
break;
}
#endif /* IPX */
+#ifdef NETATALK
+ case AF_APPLETALK:
+ /* Nothing to do. */
+ break;
+#endif /* NETATALK */
#ifdef NS
/* XXX - This code is probably wrong. */
case AF_NS:
@@ -234,6 +253,55 @@ ether_output(ifp, m0, dst, rt0)
mcopy = m_copy(m, 0, (int)M_COPYALL);
break;
#endif
+#ifdef NETATALK
+ case AF_APPLETALK: {
+ struct at_ifaddr *aa;
+
+ if (!aarpresolve(ac, m, (struct sockaddr_at *)dst, edst)) {
+#ifdef NETATALKDEBUG
+ extern char *prsockaddr(struct sockaddr *);
+ printf("aarpresolv: failed for %s\n", prsockaddr(dst));
+#endif /* NETATALKDEBUG */
+ return (0);
+ }
+
+ /*
+ * ifaddr is the first thing in at_ifaddr
+ */
+ aa = (struct at_ifaddr *)at_ifawithnet(
+ (struct sockaddr_at *)dst,
+ ifp->if_addrlist.tqh_first);
+ if (aa == 0)
+ goto bad;
+
+ /*
+ * In the phase 2 case, we need to prepend an mbuf for the llc
+ * header. Since we must preserve the value of m, which is
+ * passed to us by value, we m_copy() the first mbuf,
+ * and use it for our llc header.
+ */
+ if ( aa->aa_flags & AFA_PHASE2 ) {
+ struct llc llc;
+
+ /* XXX Really this should use netisr too */
+ M_PREPEND(m, AT_LLC_SIZE, M_WAIT);
+ /*
+ * FreeBSD doesn't count the LLC len in
+ * ifp->obytes, so they increment a length
+ * field here. We don't do this.
+ */
+ llc.llc_dsap = llc.llc_ssap = LLC_SNAP_LSAP;
+ llc.llc_control = LLC_UI;
+ bcopy(at_org_code, llc.llc_snap_org_code,
+ sizeof(at_org_code));
+ llc.llc_snap_ether_type = htons( ETHERTYPE_AT );
+ bcopy(&llc, mtod(m, caddr_t), AT_LLC_SIZE);
+ etype = htons(m->m_pkthdr.len);
+ } else {
+ etype = htons(ETHERTYPE_AT);
+ }
+ } break;
+#endif /* NETATALK */
#ifdef ISO
case AF_ISO: {
int snpalen;
@@ -439,6 +507,17 @@ decapsulate:
inq = &nsintrq;
break;
#endif
+#ifdef NETATALK
+ case ETHERTYPE_AT:
+ schednetisr(NETISR_ATALK);
+ inq = &atintrq1;
+ break;
+ case ETHERTYPE_AARP:
+ /* probably this should be done with a NETISR as well */
+ /* XXX queue this */
+ aarpinput((struct arpcom *)ifp, m);
+ return;
+#endif
default:
if (llcfound || etype > ETHERMTU)
goto dropanyway;
@@ -446,6 +525,35 @@ decapsulate:
l = mtod(m, struct llc *);
switch (l->llc_dsap) {
case LLC_SNAP_LSAP:
+ /*
+ * Some protocols (like Appletalk) need special
+ * handling depending on if they are type II
+ * or SNAP encapsulated. Everything else
+ * gets handled by stripping off the SNAP header
+ * and going back up to decapsulate.
+ */
+ if (l->llc_control == LLC_UI &&
+ l->llc_ssap == LLC_SNAP_LSAP &&
+ Bcmp(&(l->llc_snap_org_code)[0],
+ at_org_code, sizeof(at_org_code)) == 0 &&
+ ntohs(l->llc_snap_ether_type) == ETHERTYPE_AT) {
+ inq = &atintrq2;
+ m_adj(m, AT_LLC_SIZE);
+ schednetisr(NETISR_ATALK);
+ break;
+ }
+
+ if (l->llc_control == LLC_UI &&
+ l->llc_ssap == LLC_SNAP_LSAP &&
+ Bcmp(&(l->llc_snap_org_code)[0],
+ aarp_org_code, sizeof(aarp_org_code)) == 0 &&
+ ntohs(l->llc_snap_ether_type) == ETHERTYPE_AARP) {
+ m_adj(m, AT_LLC_SIZE);
+ /* XXX Really this should use netisr too */
+ aarpinput((struct arpcom *)ifp, m);
+ return;
+ }
+
if (l->llc_control == LLC_UI &&
l->llc_dsap == LLC_SNAP_LSAP &&
l->llc_ssap == LLC_SNAP_LSAP) {
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index d1e36af3962..0463158054c 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_loop.c,v 1.6 1996/06/29 18:54:11 deraadt Exp $ */
+/* $OpenBSD: if_loop.c,v 1.7 1997/07/23 03:46:01 denny Exp $ */
/* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */
/*
@@ -81,6 +81,12 @@
#include <netiso/iso_var.h>
#endif
+#ifdef NETATALK
+#include <netinet/if_ether.h>
+#include <netatalk/at.h>
+#include <netatalk/at_var.h>
+#endif
+
#if NBPFILTER > 0
#include <net/bpf.h>
#endif
@@ -186,6 +192,12 @@ looutput(ifp, m, dst, rt)
isr = NETISR_ISO;
break;
#endif
+#ifdef NETATALK
+ case AF_APPLETALK:
+ ifq = &atintrq2;
+ isr = NETISR_ATALK;
+ break;
+#endif NETATALK
default:
printf("%s: can't handle af%d\n", ifp->if_xname,
dst->sa_family);
diff --git a/sys/net/netisr.h b/sys/net/netisr.h
index b1cd7e356d1..c1223868c2d 100644
--- a/sys/net/netisr.h
+++ b/sys/net/netisr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: netisr.h,v 1.9 1997/02/24 13:34:03 niklas Exp $ */
+/* $OpenBSD: netisr.h,v 1.10 1997/07/23 03:46:02 denny Exp $ */
/* $NetBSD: netisr.h,v 1.12 1995/08/12 23:59:24 mycroft Exp $ */
/*
@@ -59,6 +59,7 @@
#define NETISR_NS 6 /* same as AF_NS */
#define NETISR_ISO 7 /* same as AF_ISO */
#define NETISR_CCITT 10 /* same as AF_CCITT */
+#define NETISR_ATALK 16 /* same as AF_APPLETALK */
#define NETISR_ARP 18 /* same as AF_LINK */
#define NETISR_IPX 23 /* same as AF_IPX */
#define NETISR_ISDN 26 /* same as AF_E164 */