summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorfjoe <fjoe@FreeBSD.org>2001-10-14 20:17:53 +0000
committerfjoe <fjoe@FreeBSD.org>2001-10-14 20:17:53 +0000
commit8ef8a1b13f436d2f49044e9cab13f39e36047b92 (patch)
tree537998a7e486402b035834f0510ec757a6d5a925 /sys/net
parente338dc78bdc960ef8f56856b5312ff770d9e773d (diff)
downloadFreeBSD-src-8ef8a1b13f436d2f49044e9cab13f39e36047b92.zip
FreeBSD-src-8ef8a1b13f436d2f49044e9cab13f39e36047b92.tar.gz
bring in ARP support for variable length link level addresses
Reviewed by: jdp Approved by: jdp Obtained from: NetBSD MFC after: 6 weeks
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c1
-rw-r--r--sys/net/if_arc.h149
-rw-r--r--sys/net/if_arp.h10
-rw-r--r--sys/net/if_ethersubr.c5
-rw-r--r--sys/net/if_fddisubr.c3
-rw-r--r--sys/net/if_iso88025subr.c5
-rw-r--r--sys/net/if_var.h4
-rw-r--r--sys/net/if_vlan.c2
8 files changed, 173 insertions, 6 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 339ddd2..5e7b5bc1 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -429,6 +429,7 @@ if_attach(ifp)
sdl->sdl_data[--namelen] = 0xff;
TAILQ_INSERT_HEAD(&ifp->if_addrhead, ifa, ifa_link);
}
+ ifp->if_broadcastaddr = 0; /* reliably crash if used uninitialized */
}
/*
diff --git a/sys/net/if_arc.h b/sys/net/if_arc.h
new file mode 100644
index 0000000..630c41f
--- /dev/null
+++ b/sys/net/if_arc.h
@@ -0,0 +1,149 @@
+/* $NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * from: NetBSD: if_ether.h,v 1.10 1994/06/29 06:37:55 cgd Exp
+ * @(#)if_ether.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NET_IF_ARC_H_
+#define _NET_IF_ARC_H_
+
+/*
+ * Arcnet address - 1 octets
+ * don't know who uses this.
+ */
+struct arc_addr {
+ u_int8_t arc_addr_octet[1];
+} __attribute__((__packed__));
+
+/*
+ * Structure of a 2.5MB/s Arcnet header.
+ * as given to interface code.
+ */
+struct arc_header {
+ u_int8_t arc_shost;
+ u_int8_t arc_dhost;
+ u_int8_t arc_type;
+ /*
+ * only present for newstyle encoding with LL fragmentation.
+ * Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead.
+ */
+ u_int8_t arc_flag;
+ u_int16_t arc_seqid;
+
+ /*
+ * only present in exception packets (arc_flag == 0xff)
+ */
+ u_int8_t arc_type2; /* same as arc_type */
+ u_int8_t arc_flag2; /* real flag value */
+ u_int16_t arc_seqid2; /* real seqid value */
+} __attribute__((__packed__));
+
+#define ARC_ADDR_LEN 1
+
+#define ARC_HDRLEN 3
+#define ARC_HDRNEWLEN 6
+#define ARC_HDRNEWLEN_EXC 10
+
+/* these lengths are data link layer length - 2*ARC_ADDR_LEN */
+#define ARC_MIN_LEN 1
+#define ARC_MIN_FORBID_LEN 254
+#define ARC_MAX_FORBID_LEN 256
+#define ARC_MAX_LEN 508
+
+
+/* RFC 1051 */
+#define ARCTYPE_IP_OLD 240 /* IP protocol */
+#define ARCTYPE_ARP_OLD 241 /* address resolution protocol */
+
+/* RFC 1201 */
+#define ARCTYPE_IP 212 /* IP protocol */
+#define ARCTYPE_ARP 213 /* address resolution protocol */
+#define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */
+
+#define ARCTYPE_ATALK 221 /* Appletalk */
+#define ARCTYPE_BANIAN 247 /* Banyan Vines */
+#define ARCTYPE_IPX 250 /* Novell IPX */
+
+#define ARCTYPE_INET6 0xc4 /* IPng */
+#define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */
+
+#define ARCMTU 507
+#define ARCMIN 0
+
+#define ARC_PHDS_MAXMTU 60480
+
+struct arccom {
+ struct ifnet ac_if; /* network-visible interface */
+
+ u_int16_t ac_seqid; /* seq. id used by PHDS encap. */
+
+ u_int8_t arc_shost;
+ u_int8_t arc_dhost;
+ u_int8_t arc_type;
+
+ u_int8_t dummy0;
+ u_int16_t dummy1;
+ int sflag, fsflag, rsflag;
+ struct mbuf *curr_frag;
+
+ struct ac_frag {
+ u_int8_t af_maxflag; /* from first packet */
+ u_int8_t af_lastseen; /* last split flag seen */
+ u_int16_t af_seqid;
+ struct mbuf *af_packet;
+ } ac_fragtab[256]; /* indexed by sender ll address */
+};
+
+#ifdef _KERNEL
+extern u_int8_t arcbroadcastaddr;
+extern int arc_ipmtu; /* XXX new ip only, no RFC 1051! */
+
+void arc_ifattach __P((struct ifnet *, u_int8_t));
+void arc_ifdetach __P((struct ifnet *));
+void arc_storelladdr __P((struct ifnet *, u_int8_t));
+char *arc_sprintf __P((u_int8_t *));
+int arc_isphds __P((int));
+void arc_input __P((struct ifnet *, struct mbuf *));
+int arc_output __P((struct ifnet *, struct mbuf *,
+ struct sockaddr *, struct rtentry *));
+int arc_ioctl __P((struct ifnet *, int, caddr_t));
+
+void arc_frag_init __P((struct ifnet *));
+struct mbuf * arc_frag_next __P((struct ifnet *));
+
+#endif
+
+#endif /* _NET_IF_ARC_H_ */
diff --git a/sys/net/if_arp.h b/sys/net/if_arp.h
index 6760972..227a7d2 100644
--- a/sys/net/if_arp.h
+++ b/sys/net/if_arp.h
@@ -51,6 +51,7 @@ struct arphdr {
u_short ar_hrd; /* format of hardware address */
#define ARPHRD_ETHER 1 /* ethernet hardware format */
#define ARPHRD_IEEE802 6 /* token-ring hardware format */
+#define ARPHRD_ARCNET 7 /* arcnet hardware format */
#define ARPHRD_FRELAY 15 /* frame relay hardware format */
u_short ar_pro; /* format of protocol address */
u_char ar_hln; /* length of hardware address */
@@ -74,6 +75,15 @@ struct arphdr {
#endif
};
+#define ar_sha(ap) (((caddr_t)((ap)+1)) + 0)
+#define ar_spa(ap) (((caddr_t)((ap)+1)) + (ap)->ar_hln)
+#define ar_tha(ap) (((caddr_t)((ap)+1)) + (ap)->ar_hln + (ap)->ar_pln)
+#define ar_tpa(ap) (((caddr_t)((ap)+1)) + 2*(ap)->ar_hln + (ap)->ar_pln)
+
+#define arphdr_len2(ar_hln, ar_pln) \
+ (sizeof(struct arphdr) + 2*(ar_hln) + 2*(ar_pln))
+#define arphdr_len(ap) (arphdr_len2((ap)->ar_hln, (ap)->ar_pln))
+
/*
* ARP ioctl request
*/
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 05c2723..fe2cb63 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -178,7 +178,7 @@ ether_output(ifp, m, dst, rt0)
switch (dst->sa_family) {
#ifdef INET
case AF_INET:
- if (!arpresolve(ac, rt, m, dst, edst, rt0))
+ if (!arpresolve(ifp, rt, m, dst, edst, rt0))
return (0); /* if not yet resolved */
off = m->m_pkthdr.len - m->m_len;
type = htons(ETHERTYPE_IP);
@@ -663,6 +663,7 @@ ether_ifattach(ifp, bpf)
ifp->if_resolvemulti = ether_resolvemulti;
if (ifp->if_baudrate == 0)
ifp->if_baudrate = 10000000;
+ ifp->if_broadcastaddr = etherbroadcastaddr;
ifa = ifaddr_byindex(ifp->if_index);
KASSERT(ifa != NULL, ("%s: no lladdr!\n", __FUNCTION__));
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
@@ -715,7 +716,7 @@ ether_ioctl(ifp, command, data)
#ifdef INET
case AF_INET:
ifp->if_init(ifp->if_softc); /* before arpwhohas */
- arp_ifinit(IFP2AC(ifp), ifa);
+ arp_ifinit(ifp, ifa);
break;
#endif
#ifdef IPX
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c
index 400106b..37f91bf 100644
--- a/sys/net/if_fddisubr.c
+++ b/sys/net/if_fddisubr.c
@@ -166,7 +166,7 @@ fddi_output(ifp, m, dst, rt0)
#ifdef INET
case AF_INET: {
#if !defined(__bsdi__) || _BSDI_VERSION >= 199401
- if (!ARPRESOLVE(ac, rt, m, dst, edst, rt0))
+ if (!ARPRESOLVE(ifp, rt, m, dst, edst, rt0))
return (0); /* if not yet resolved */
#else
int usetrailers;
@@ -525,6 +525,7 @@ fddi_ifattach(ifp)
#ifdef IFF_NOTRAILERS
ifp->if_flags |= IFF_NOTRAILERS;
#endif
+ ifp->if_broadcastaddr = fddibroadcastaddr;
#if defined(__FreeBSD__)
ifa = ifaddr_byindex(ifp->if_index);
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c
index 4351db2..fd0cd0a 100644
--- a/sys/net/if_iso88025subr.c
+++ b/sys/net/if_iso88025subr.c
@@ -101,6 +101,7 @@ iso88025_ifattach(struct ifnet *ifp)
ifp->if_baudrate = TR_16MBPS; /* 16Mbit should be a safe default */
if (ifp->if_mtu == 0)
ifp->if_mtu = ISO88025_DEFAULT_MTU;
+ ifp->if_broadcastaddr = etherbroadcastaddr;
ifa = ifaddr_byindex(ifp->if_index);
if (ifa == 0) {
@@ -142,7 +143,7 @@ iso88025_ioctl(struct ifnet *ifp, int command, caddr_t data)
#ifdef INET
case AF_INET:
ifp->if_init(ifp->if_softc); /* before arpwhohas */
- arp_ifinit((struct arpcom *)ifp, ifa);
+ arp_ifinit(ifp, ifa);
break;
#endif /* INET */
#ifdef IPX
@@ -272,7 +273,7 @@ iso88025_output(ifp, m, dst, rt0)
switch (dst->sa_family) {
#ifdef INET
case AF_INET:
- if (!arpresolve(ac, rt, m, dst, edst, rt0))
+ if (!arpresolve(ifp, rt, m, dst, edst, rt0))
return (0); /* if not yet resolved */
snap_type = ETHERTYPE_IP;
break;
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index b3d4900..cc1983d 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -158,6 +158,7 @@ struct ifnet {
struct ifqueue if_snd; /* output queue */
struct ifqueue *if_poll_slowq; /* input queue for slow devices */
struct ifprefixhead if_prefixhead; /* list of prefixes per if */
+ u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */
};
typedef void if_init_f_t __P((void *));
@@ -447,6 +448,9 @@ void if_clone_detach __P((struct if_clone *));
int if_clone_create __P((char *, int));
int if_clone_destroy __P((const char *));
+#define IF_LLADDR(ifp) \
+ LLADDR((struct sockaddr_dl *) ifaddr_byindex((ifp)->if_index)->ifa_addr)
+
#endif /* _KERNEL */
#endif /* !_NET_IF_VAR_H_ */
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 0f9cfff..ce4fbf3 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -581,7 +581,7 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
switch (ifa->ifa_addr->sa_family) {
#ifdef INET
case AF_INET:
- arp_ifinit(&ifv->ifv_ac, ifa);
+ arp_ifinit(&ifv->ifv_if, ifa);
break;
#endif
default:
OpenPOWER on IntegriCloud