? compile/IPANET
? compile/CARDBUS
? i386/conf/IPANET
? i386/conf/CARDBUS
Index: conf/files
===================================================================
RCS file: /home/ncvs/src/sys/conf/files,v
retrieving revision 1.511
diff -u -r1.511 files
--- conf/files	2001/04/27 19:28:19	1.511
+++ conf/files	2001/05/01 14:39:15
@@ -989,6 +989,7 @@
 net/slcompress.c	optional netgraph_vjc
 netinet/accf_data.c		optional accept_filter_data
 netinet/accf_http.c		optional accept_filter_http
+netinet/anet.c		optional ipanet
 netinet/fil.c		optional ipfilter inet
 netinet/if_atm.c	optional atm
 netinet/if_ether.c	optional ether
Index: conf/options
===================================================================
RCS file: /home/ncvs/src/sys/conf/options,v
retrieving revision 1.270
diff -u -r1.270 options
--- conf/options	2001/04/20 11:58:40	1.270
+++ conf/options	2001/05/01 14:39:16
@@ -255,6 +255,7 @@
 INET			opt_inet.h
 SOMAXCONN		opt_inet.h
 INET6			opt_inet6.h
+IPANET			opt_ipanet.h
 IPSEC			opt_ipsec.h
 IPSEC_ESP		opt_ipsec.h
 IPSEC_DEBUG		opt_ipsec.h
Index: netinet/anet.c
===================================================================
RCS file: anet.c
diff -N anet.c
--- /dev/null	Tue May  1 07:29:04 2001
+++ anet.c	Tue May  1 07:39:44 2001
@@ -0,0 +1,138 @@
+/*-
+ * Copyright (c) 2001 Robert N. M. Watson
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD: $
+ */
+/*
+ * Support for IPPROTO_ANET, a strong-active net "active packet" model.
+ */
+
+#include "opt_ipanet.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
+
+#include <netinet/anet.h>
+#include <netinet/in_systm.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+
+#ifdef IPANET
+
+#define	AN_DEBUG
+
+void
+ipanet_input(struct mbuf *m, int off, int proto)
+{
+	struct anethdr *ah;
+	struct ip *ip;
+	int iphlen = off, len;
+
+#if 0
+	printf("ipanet_input()\n");
+#endif
+#if 0
+	/*
+	 * XXX: Strip IP options for the time being.
+	 */
+	if (iphlen > sizeof(struct ip)) {
+		ip_stripoptions(m, (struct mbuf *)0);
+		iphlen = sizeof(struct ip);
+	}
+#endif
+
+	/*
+	 * Pull up the anet header.
+	 */
+	ip = mtod(m, struct ip *);
+	if (m->m_len < iphlen + sizeof(struct anethdr)) {
+		if ((m = m_pullup(m, iphlen + sizeof(struct anethdr))) ==
+		    NULL) {
+#ifdef AN_DEBUG
+			printf("ipanet_input: no room for header\n");
+#endif
+			return;
+		}
+		ip = mtod(m, struct ip *);
+	}
+	ah = (struct anethdr *)((caddr_t)ip + iphlen);
+
+	/* Does anethdr fit in declared header length? */
+	if (ntohs(ah->ah_hdrlen) < sizeof(struct anethdr)) {
+#ifdef AN_DEBUG
+		printf("ipanet_input: declared an_hdrlen too short\n");
+#endif
+		goto bad;
+	}
+	/* Does declared header length fit in declared data length? */
+	if (ntohs(ah->ah_hdrlen) > ntohs(ah->ah_len)) {
+#ifdef AN_DEBUG
+		printf("ipanet_input: declared an_hdrlen longer than an_len\n");
+#endif
+		goto bad;
+	}
+	/* Does the declared data length fit in the IP packet? */
+	if (ntohs(ah->ah_len) + iphlen > ip->ip_len) {
+#ifdef AN_DEBUG
+		printf("ipanet_input: declared an_len longer than IP packet\n");
+#endif
+		goto bad;
+	}
+	/* Is the port valid? */
+	if (ntohs(ah->ah_port) == 0) {
+#ifdef AN_DEBUG
+		printf("ipanet_input: port 0\n");
+#endif
+		goto bad;
+	}
+
+	/*
+	 * Truncate anet packet to length defined in header.
+	 */
+	len = ntohs((u_short)ah->ah_len) + iphlen;
+	if (ip->ip_len != len) {
+		if (len > ip->ip_len)
+			goto bad;
+		m_adj(m, len - ip->ip_len);
+	}
+
+	rip_input(m, off, proto);
+	return;
+
+bad:
+	m_freem(m);
+}
+
+void
+ipanet_init(void)
+{
+
+	printf("IP ActiveNet Module Prototype initialized.\n");
+	printf("NAI Labs at Network Associates\n");
+}
+
+#endif /* !IPANET */
Index: netinet/anet.h
===================================================================
RCS file: anet.h
diff -N anet.h
--- /dev/null	Tue May  1 07:29:04 2001
+++ anet.h	Tue May  1 07:39:44 2001
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 2001 Robert N. M. Watson
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD: $
+ */
+
+#ifndef _NETINET_ANET_H
+#define	_NETINET_ANET_H
+
+#define	ANET_XID_LEN	8
+struct anethdr {
+	u_int16_t	ah_port;	/* application port */
+	u_int16_t	ah_hdrlen;	/* length of header incl. options */
+	u_int16_t	ah_len;		/* length of activenet hdr+data */
+	u_int16_t	ah_pad;		/* reserved */
+	u_char	ah_xid[ANET_XID_LEN];	/* transaction id */
+};
+
+struct anethdr_opt {
+	u_int16_t	aho_type;	/* option type */
+	u_int8_t	aho_len;	/* option length, incl. opt hdr */
+	u_int8_t	aho_pad;	/* reserved */
+	u_int8_t	aho_first[1];	/* first byte */
+};
+
+#ifdef _KERNEL
+
+void	ipanet_input __P((struct mbuf *m, int off, int proto));
+void	ipanet_init __P((void));
+
+#endif /* !_KERNEL */
+
+#endif /* !_NETINET_ANET_H */
Index: netinet/in.h
===================================================================
RCS file: /home/ncvs/src/sys/netinet/in.h,v
retrieving revision 1.54
diff -u -r1.54 in.h
--- netinet/in.h	2001/03/23 18:59:31	1.54
+++ netinet/in.h	2001/05/01 14:39:44
@@ -151,6 +151,7 @@
 /* 101-254: Partly Unassigned */
 #define	IPPROTO_PIM		103		/* Protocol Independent Mcast */
 #define	IPPROTO_PGM		113		/* PGM */
+#define	IPPROTO_ANET		123		/* Active networks */
 /* 255: Reserved */
 /* BSD Private, local use, namespace incursion */
 #define	IPPROTO_DIVERT		254		/* divert pseudo-protocol */
Index: netinet/in_proto.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/in_proto.c,v
retrieving revision 1.55
diff -u -r1.55 in_proto.c
--- netinet/in_proto.c	2000/08/03 14:09:52	1.55
+++ netinet/in_proto.c	2001/05/01 14:39:45
@@ -34,6 +34,7 @@
  * $FreeBSD: src/sys/netinet/in_proto.c,v 1.55 2000/08/03 14:09:52 ru Exp $
  */
 
+#include "opt_ipanet.h"
 #include "opt_ipdivert.h"
 #include "opt_ipx.h"
 #include "opt_ipsec.h"
@@ -50,6 +51,7 @@
 #include <net/if.h>
 #include <net/route.h>
 
+#include <netinet/anet.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
@@ -197,6 +199,14 @@
   &rip_usrreqs
 },
 #endif
+#ifdef IPANET
+{ SOCK_RAW,	&inetdomain,	IPPROTO_ANET,	PR_ATOMIC|PR_ADDR,
+  ipanet_input,	NULL,		NULL,		rip_ctloutput,
+  NULL,
+  ipanet_init,	NULL,		NULL,		NULL,
+  &rip_usrreqs
+},
+#endif /* !IPANET */
 	/* raw wildcard */
 { SOCK_RAW,	&inetdomain,	0,		PR_ATOMIC|PR_ADDR,
   rip_input,	0,		0,		rip_ctloutput,
Index: netinet/ip_input.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.165
diff -u -r1.165 ip_input.c
--- netinet/ip_input.c	2001/03/19 09:16:16	1.165
+++ netinet/ip_input.c	2001/05/01 14:39:46
@@ -37,6 +37,7 @@
 #define	_IP_VHL
 
 #include "opt_bootp.h"
+#include "opt_ipanet.h"
 #include "opt_ipfw.h"
 #include "opt_ipdn.h"
 #include "opt_ipdivert.h"
@@ -511,6 +512,14 @@
          */
 	if (rsvp_on && ip->ip_p==IPPROTO_RSVP) 
 		goto ours;
+
+#ifdef IPANET
+	/*
+	 * IPANET is also greedy in the style of RSVP.
+	 */
+	if (ip->ip_p == IPPROTO_ANET)
+		goto ours;
+#endif /* !IPANET */
 
 	/*
 	 * Check our list of addresses, to see if the packet is for us.
