--- ip_fw2.c.orig	Wed May  9 05:24:38 2007
+++ ip_fw2.c	Mon May 14 16:49:05 2007
@@ -44,6 +44,7 @@
 #endif
 #include "opt_inet6.h"
 #include "opt_ipsec.h"
+#include "opt_xcast6.h"
 #include "opt_mac.h"
 
 #include <sys/param.h>
@@ -96,6 +97,9 @@
 #ifdef INET6
 #include <netinet6/scope6_var.h>
 #endif
+#ifdef XCAST6
+#include <netinet6/xcast6.h>
+#endif
 
 #include <netinet/if_ether.h> /* XXX for ETHERTYPE_IP */
 
@@ -2235,6 +2239,10 @@
 	/* end of ipv6 variables */
 	int is_ipv4 = 0;
 
+#ifdef XCAST6
+	int is_xcast6;
+#endif
+
 	if (m->m_flags & M_SKIP_FIREWALL)
 		return (IP_FW_PASS);	/* accept */
 
@@ -2273,6 +2281,9 @@
 		args->f_id.addr_type = 6;
 		hlen = sizeof(struct ip6_hdr);
 		proto = ip6->ip6_nxt;
+#ifdef XCAST6
+		is_xcast6 = 0;
+#endif
 
 		/* Search extension headers to find upper layer protocols */
 		while (ulp == NULL) {
@@ -2300,6 +2311,9 @@
 				ext_hd |= EXT_HOPOPTS;
 				hlen += (((struct ip6_hbh *)ulp)->ip6h_len + 1) << 3;
 				proto = ((struct ip6_hbh *)ulp)->ip6h_nxt;
+#ifdef XCAST6
+				is_xcast6 = 1;
+#endif
 				ulp = NULL;
 				break;
 
@@ -2307,6 +2321,9 @@
 				PULLUP_TO(hlen, ulp, struct ip6_rthdr);
 				switch (((struct ip6_rthdr *)ulp)->ip6r_type) {
 				case 0:
+#ifdef IPV6_RTHDR_TYPE_XCAST6
+				case IPV6_RTHDR_TYPE_XCAST6:
+#endif
 					break;
 				default:
 					printf("IPFW2: IPV6 - Unknown Routing "
@@ -2396,6 +2413,14 @@
 
 			case IPPROTO_IPV6:	/* RFC 2893 */
 				PULLUP_TO(hlen, ulp, struct ip6_hdr);
+#ifdef XCAST6
+				if (is_xcast6) {
+					hlen += sizeof(struct ip6_hdr);
+					proto = ((struct ip6_hdr *)ulp)->ip6_nxt;
+					ulp = NULL;
+					break;
+				}
+#endif
 				break;
 
 			case IPPROTO_IPV4:	/* RFC 2893 */

