diff -ur kame/netinet/sctp_asconf.c dfly/netinet/sctp_asconf.c
--- kame/netinet/sctp_asconf.c	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctp_asconf.c	2005-06-18 12:41:43.000000000 +0000
@@ -135,7 +135,7 @@
 	struct mbuf *m_reply = NULL;
 	struct sctp_asconf_paramhdr *aph;
 
-	MGET(m_reply, M_DONTWAIT, MT_DATA);
+	MGET(m_reply, MB_DONTWAIT, MT_DATA);
 	if (m_reply == NULL) {
 #ifdef SCTP_DEBUG
 		if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
@@ -163,7 +163,7 @@
 	struct sctp_error_cause *error;
 	uint8_t *tlv;
 
-	MGET(m_reply, M_DONTWAIT, MT_DATA);
+	MGET(m_reply, MB_DONTWAIT, MT_DATA);
 	if (m_reply == NULL) {
 #ifdef SCTP_DEBUG
 		if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
@@ -644,7 +644,7 @@
 		sctp_m_freem(asoc->last_asconf_ack_sent);
 		asoc->last_asconf_ack_sent = NULL;
 	}
-	MGETHDR(m_ack, M_DONTWAIT, MT_DATA);
+	MGETHDR(m_ack, MB_DONTWAIT, MT_DATA);
 	if (m_ack == NULL) {
 #ifdef SCTP_DEBUG
 		if (sctp_debug_on & SCTP_DEBUG_ASCONF1) {
@@ -2273,7 +2273,7 @@
 	 * address on the fly
 	 */
 	m_asconf_chk = NULL;
-	MGETHDR(m_asconf_chk, M_DONTWAIT, MT_DATA);
+	MGETHDR(m_asconf_chk, MB_DONTWAIT, MT_DATA);
 	if (m_asconf_chk == NULL) {
 		/* no mbuf's */
 #ifdef SCTP_DEBUG
@@ -2283,7 +2283,7 @@
 		return (NULL);
 	}
 	m_asconf = NULL;
-	MGETHDR(m_asconf, M_DONTWAIT, MT_HEADER);
+	MGETHDR(m_asconf, MB_DONTWAIT, MT_HEADER);
 	if (m_asconf == NULL) {
 		/* no mbuf's */
 #ifdef SCTP_DEBUG
@@ -2293,7 +2293,7 @@
 		sctp_m_freem(m_asconf_chk);
 		return (NULL);
 	}
-	MCLGET(m_asconf, M_DONTWAIT);
+	MCLGET(m_asconf, MB_DONTWAIT);
 	if ((m_asconf->m_flags & M_EXT) != M_EXT) {
 		/* failed to get cluster buffer */
 #ifdef SCTP_DEBUG
diff -ur kame/netinet/sctp_constants.h dfly/netinet/sctp_constants.h
--- kame/netinet/sctp_constants.h	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctp_constants.h	2005-06-18 12:41:43.000000000 +0000
@@ -801,7 +801,7 @@
 
 #if defined(_KERNEL) || (defined(__APPLE__) && defined(KERNEL))
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 #define SCTP_GETTIME_TIMEVAL(x)	(microuptime(x))
 #define SCTP_GETTIME_TIMESPEC(x) (nanouptime(x))
 #else
diff -ur kame/netinet/sctp_indata.c dfly/netinet/sctp_indata.c
--- kame/netinet/sctp_indata.c	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctp_indata.c	2005-06-18 12:41:43.000000000 +0000
@@ -32,7 +32,7 @@
 #if !(defined(__OpenBSD__) || defined(__APPLE__))
 #include "opt_ipsec.h"
 #endif
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include "opt_inet6.h"
 #include "opt_inet.h"
 #endif
@@ -202,7 +202,7 @@
 		return (NULL);
 	}
 
-	MGETHDR(ret, M_DONTWAIT, MT_CONTROL);
+	MGETHDR(ret, MB_DONTWAIT, MT_CONTROL);
 	if (ret == NULL) {
 		/* No space */
 		return (ret);
@@ -252,7 +252,7 @@
 		/* user does not want the sndrcv ctl */
 		return (NULL);
 	}
-	MGET(ret, M_DONTWAIT, MT_CONTROL);
+	MGET(ret, MB_DONTWAIT, MT_CONTROL);
 	if (ret == NULL) {
 		/* No space */
 		return (ret);
@@ -394,7 +394,7 @@
 #endif
 	/* XXX need to append PKTHDR to the socket buffer first */
 	if ((chk->data->m_flags & M_PKTHDR) == 0) {
-		MGETHDR(m, M_DONTWAIT, MT_DATA);
+		MGETHDR(m, MB_DONTWAIT, MT_DATA);
 		if (m == NULL) {
 			/* no room! */
 			if (hold_locks == 0)
@@ -616,7 +616,7 @@
 		}
 
 		if ((chk->data->m_flags & M_PKTHDR) == 0) {
-			MGETHDR(m, M_DONTWAIT, MT_DATA);
+			MGETHDR(m, MB_DONTWAIT, MT_DATA);
 			if (m == NULL) {
 				/* no room! */
 				if (hold_locks == 0)
@@ -852,7 +852,7 @@
 		 * association destruction
 		 */
 		TAILQ_INSERT_HEAD(&strm->inqueue, chk, sctp_next);
-		MGET(oper, M_DONTWAIT, MT_DATA);
+		MGET(oper, MB_DONTWAIT, MT_DATA);
 		if (oper) {
 			struct sctp_paramhdr *ph;
 			u_int32_t *ippp;
@@ -1083,7 +1083,7 @@
 					printf("Gak, Evil plot, its not first, no fragmented delivery in progress\n");
 				}
 #endif
-				MGET(oper, M_DONTWAIT, MT_DATA);
+				MGET(oper, MB_DONTWAIT, MT_DATA);
 				if (oper) {
 					struct sctp_paramhdr *ph;
 					u_int32_t *ippp;
@@ -1113,7 +1113,7 @@
 					printf("Gak, Evil plot, it IS a first and fragmented delivery in progress\n");
 				}
 #endif
-				MGET(oper, M_DONTWAIT, MT_DATA);
+				MGET(oper, MB_DONTWAIT, MT_DATA);
 				if (oper) {
 					struct sctp_paramhdr *ph;
 					u_int32_t *ippp;
@@ -1143,7 +1143,7 @@
 						    asoc->str_of_pdapi);
 					}
 #endif
-					MGET(oper, M_DONTWAIT, MT_DATA);
+					MGET(oper, MB_DONTWAIT, MT_DATA);
 					if (oper) {
 						struct sctp_paramhdr *ph;
 						u_int32_t *ippp;
@@ -1174,7 +1174,7 @@
 						    asoc->ssn_of_pdapi);
 					}
 #endif
-					MGET(oper, M_DONTWAIT, MT_DATA);
+					MGET(oper, MB_DONTWAIT, MT_DATA);
 					if (oper) {
 						struct sctp_paramhdr *ph;
 						u_int32_t *ippp;
@@ -1274,7 +1274,7 @@
 						printf("Gak, Evil plot, it's a FIRST!\n");
 					}
 #endif
-					MGET(oper, M_DONTWAIT, MT_DATA);
+					MGET(oper, MB_DONTWAIT, MT_DATA);
 					if (oper) {
 						struct sctp_paramhdr *ph;
 						u_int32_t *ippp;
@@ -1310,7 +1310,7 @@
 						    prev->rec.data.stream_number);
 					}
 #endif
-					MGET(oper, M_DONTWAIT, MT_DATA);
+					MGET(oper, MB_DONTWAIT, MT_DATA);
 					if (oper) {
 						struct sctp_paramhdr *ph;
 						u_int32_t *ippp;
@@ -1348,7 +1348,7 @@
 						    prev->rec.data.stream_seq);
 					}
 #endif
-					MGET(oper, M_DONTWAIT, MT_DATA);
+					MGET(oper, MB_DONTWAIT, MT_DATA);
 					if (oper) {
 						struct sctp_paramhdr *ph;
 						u_int32_t *ippp;
@@ -1382,7 +1382,7 @@
 						printf("Prev check - Gak, evil plot, its not FIRST and it must be!\n");
 					}
 #endif
-					MGET(oper, M_DONTWAIT, MT_DATA);
+					MGET(oper, MB_DONTWAIT, MT_DATA);
 					if (oper) {
 						struct sctp_paramhdr *ph;
 						u_int32_t *ippp;
@@ -1427,7 +1427,7 @@
 						printf("Gak, Evil plot, its not a last!\n");
 					}
 #endif
-					MGET(oper, M_DONTWAIT, MT_DATA);
+					MGET(oper, MB_DONTWAIT, MT_DATA);
 					if (oper) {
 						struct sctp_paramhdr *ph;
 						u_int32_t *ippp;
@@ -1464,7 +1464,7 @@
 						printf("Gak, Evil plot, new prev chunk is a LAST\n");
 					}
 #endif
-					MGET(oper, M_DONTWAIT, MT_DATA);
+					MGET(oper, MB_DONTWAIT, MT_DATA);
 					if (oper) {
 						struct sctp_paramhdr *ph;
 						u_int32_t *ippp;
@@ -1500,7 +1500,7 @@
 						    next->rec.data.stream_number);
 					}
 #endif
-					MGET(oper, M_DONTWAIT, MT_DATA);
+					MGET(oper, MB_DONTWAIT, MT_DATA);
 					if (oper) {
 						struct sctp_paramhdr *ph;
 						u_int32_t *ippp;
@@ -1538,7 +1538,7 @@
 						    next->rec.data.stream_seq);
 					}
 #endif
-					MGET(oper, M_DONTWAIT, MT_DATA);
+					MGET(oper, MB_DONTWAIT, MT_DATA);
 					if (oper) {
 						struct sctp_paramhdr *ph;
 						u_int32_t *ippp;
@@ -1810,7 +1810,7 @@
 		struct sctp_paramhdr *phdr;
 		struct mbuf *mb;
 
-		MGETHDR(mb, M_DONTWAIT, MT_DATA);
+		MGETHDR(mb, MB_DONTWAIT, MT_DATA);
 		if (mb != NULL) {
 			/* add some space up front so prepend will work well */
 			mb->m_data += sizeof(struct sctp_chunkhdr);
@@ -1862,7 +1862,7 @@
 		 * throw it in the stream so it gets cleaned up in
 		 * association destruction
 		 */
-		MGET(oper, M_DONTWAIT, MT_DATA);
+		MGET(oper, MB_DONTWAIT, MT_DATA);
 		if (oper) {
 			struct sctp_paramhdr *ph;
 			u_int32_t *ippp;
@@ -1886,7 +1886,7 @@
 	if (last_chunk == 0) {
 		dmbuf = sctp_m_copym(*m,
 		    (offset + sizeof(struct sctp_data_chunk)),
-		    the_len, M_DONTWAIT);
+		    the_len, MB_DONTWAIT);
 	} else {
 		/* We can steal the last chunk */
 		dmbuf = *m;
@@ -1934,7 +1934,7 @@
 
 		if ((dmbuf->m_flags & M_PKTHDR) == 0) {
 			struct mbuf *tmp;
-			MGETHDR(tmp, M_DONTWAIT, MT_DATA);
+			MGETHDR(tmp, MB_DONTWAIT, MT_DATA);
 			if (tmp == NULL) {
 
 				/* no room! */
@@ -2077,7 +2077,7 @@
 			if (TAILQ_EMPTY(&asoc->reasmqueue) &&
 			    (estimate_tsn == chk->rec.data.TSN_seq)) {
 				/* Evil/Broke peer */
-				MGET(oper, M_DONTWAIT, MT_DATA);
+				MGET(oper, MB_DONTWAIT, MT_DATA);
 				if (oper) {
 					struct sctp_paramhdr *ph;
 					u_int32_t *ippp;
@@ -2100,7 +2100,7 @@
 				return (0);
 			} else {
 				if (sctp_does_chk_belong_to_reasm(asoc, chk)) {
-					MGET(oper, M_DONTWAIT, MT_DATA);
+					MGET(oper, MB_DONTWAIT, MT_DATA);
 					if (oper) {
 						struct sctp_paramhdr *ph;
 						u_int32_t *ippp;
@@ -2134,7 +2134,7 @@
 				 * our peer is broken or evil.
 				 */
 				if (sctp_does_chk_belong_to_reasm(asoc, chk)) {
-					MGET(oper, M_DONTWAIT, MT_DATA);
+					MGET(oper, MB_DONTWAIT, MT_DATA);
 					if (oper) {
 						struct sctp_paramhdr *ph;
 						u_int32_t *ippp;
@@ -2556,7 +2556,12 @@
 	 */
 	if (m->m_len < (long)MHLEN && m->m_next == NULL) {
 		/* we only handle mbufs that are singletons.. not chains */
-		MGET(m, M_DONTWAIT, MT_DATA);
+#ifdef __DragonFly__
+		if ((*mm)->m_flags & M_PKTHDR)
+			MGETHDR(m, MB_DONTWAIT, MT_HEADER);
+		else
+#endif
+			MGET(m, MB_DONTWAIT, MT_DATA);
 		if (m) {
 			/* ok lets see if we can copy the data up */
 			caddr_t *from, *to;
@@ -2583,6 +2588,7 @@
 			m = *mm;
 		}
 	}
+
 	/* get pointer to the first chunk header */
 	ch = (struct sctp_data_chunk *)sctp_m_getptr(m, *offset,
 	    sizeof(chunk_buf), (u_int8_t *)&chunk_buf);
@@ -2613,7 +2619,7 @@
 			 * data chunk.
 			 */
 			struct mbuf *op_err;
-			MGET(op_err, M_DONTWAIT, MT_DATA);
+			MGET(op_err, MB_DONTWAIT, MT_DATA);
 			if (op_err) {
 				struct sctp_paramhdr *ph;
 				u_int32_t *ippp;
@@ -3616,7 +3622,7 @@
 		hopeless_peer:
 			*abort_now = 1;
 			/* XXX */
-			MGET(oper, M_DONTWAIT, MT_DATA);
+			MGET(oper, MB_DONTWAIT, MT_DATA);
 			if (oper) {
 				struct sctp_paramhdr *ph;
 				u_int32_t *ippp;
diff -ur kame/netinet/sctp_input.c dfly/netinet/sctp_input.c
--- kame/netinet/sctp_input.c	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctp_input.c	2005-06-18 12:41:43.000000000 +0000
@@ -32,7 +32,7 @@
 #if !(defined(__OpenBSD__) || defined(__APPLE__))
 #include "opt_ipsec.h"
 #endif
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include "opt_compat.h"
 #include "opt_inet6.h"
 #include "opt_inet.h"
@@ -131,7 +131,7 @@
 	op_err = NULL;
 	init = &cp->init;
 	/* First are we accepting? */
-	if (((inp->sctp_flags & SCTP_PCB_FLAGS_ACCEPTING) == 0) ||
+	if ((inp->sctp_flags & SCTP_PCB_FLAGS_ACCEPTING) == 0 ||
 	    (inp->sctp_socket->so_qlimit == 0)) {
 		sctp_abort_association(inp, stcb, m, iphlen, sh, op_err);
 		return;
@@ -1090,7 +1090,7 @@
 			printf("sctp_handle_cookie: got a cookie, while shutting down!\n");
 		}
 #endif
-		MGETHDR(op_err, M_DONTWAIT, MT_HEADER);
+		MGETHDR(op_err, MB_DONTWAIT, MT_HEADER);
 		if (op_err == NULL) {
 			/* FOOBAR */
 			return (NULL);
@@ -1809,7 +1809,7 @@
 		return (NULL);
 	}
 
-	m_sig = m_split(m, sig_offset, M_DONTWAIT);
+	m_sig = m_split(m, sig_offset, MB_DONTWAIT);
 	if (m_sig == NULL) {
 		/* out of memory or ?? */
 #ifdef SCTP_DEBUG
@@ -1960,7 +1960,7 @@
 			printf("sctp_handle_cookie: got a STALE cookie!\n");
 		}
 #endif
-		MGETHDR(op_err, M_DONTWAIT, MT_HEADER);
+		MGETHDR(op_err, MB_DONTWAIT, MT_HEADER);
 		if (op_err == NULL) {
 			/* FOOBAR */
 			return (NULL);
@@ -3249,7 +3249,7 @@
 				struct mbuf *oper;
 				struct sctp_paramhdr *phdr;
 				oper = NULL;
-				MGETHDR(oper, M_DONTWAIT, MT_HEADER);
+				MGETHDR(oper, MB_DONTWAIT, MT_HEADER);
 				if (oper) {
 					/* pre-reserve some space */
 					oper->m_data +=
@@ -3502,6 +3502,7 @@
 			 * a INIT-ACK and then closed. We opened and bound..
 			 * and are now no longer listening.
 			 */
+			printf("flags: %x qlimit: %d\n", inp->sctp_flags, inp->sctp_socket->so_qlimit);
 			if (((inp->sctp_flags & SCTP_PCB_FLAGS_ACCEPTING) == 0) ||
 			    (inp->sctp_socket->so_qlimit == 0)) {
 				sctp_abort_association(inp, stcb, m, iphlen, sh,
@@ -3516,7 +3517,7 @@
 					struct mbuf *oper;
 					struct sctp_paramhdr *phdr;
 					oper = NULL;
-					MGETHDR(oper, M_DONTWAIT, MT_HEADER);
+					MGETHDR(oper, MB_DONTWAIT, MT_HEADER);
 					if (oper) {
 						oper->m_len =
 						    oper->m_pkthdr.len =
@@ -3717,7 +3718,7 @@
 			if ((ch->chunk_type & 0x40) && (stcb != NULL)) {
 				struct mbuf *mm;
 				struct sctp_paramhdr *phd;
-				MGETHDR(mm, M_DONTWAIT, MT_HEADER);
+				MGETHDR(mm, MB_DONTWAIT, MT_HEADER);
 				if (mm) {
 					phd = mtod(mm, struct sctp_paramhdr *);
 					/* We cheat and use param type since we
@@ -3733,7 +3734,7 @@
 					mm->m_len = sizeof(*phd);
 					mm->m_next = sctp_m_copym(m, *offset,
 					    SCTP_SIZE32(chk_length),
-					    M_DONTWAIT);
+					    MB_DONTWAIT);
 					if (mm->m_next) {
 						mm->m_pkthdr.len =
 						    SCTP_SIZE32(chk_length) +
@@ -4111,12 +4112,17 @@
 #endif
 
 #if !(defined(__FreeBSD__) || defined(__APPLE__))
-	int off;
+#ifdef __DragonFly__
+	__va_list ap;
+	__va_start(ap, m);
+	iphlen = __va_arg(ap, int);
+	__va_end(ap);
+#else
 	va_list ap;
-
 	va_start(ap, m);
-	iphlen = off = va_arg(ap, int);
+	iphlen = va_arg(ap, int);
 	va_end(ap);
+#endif
 #else
 	iphlen = off;
 #endif
@@ -4136,7 +4142,7 @@
 	 * Strip IP options, we don't allow any in or out.
 	 */
 	if ((size_t)iphlen > sizeof(struct ip)) {
-		ip_stripoptions(m, (struct mbuf *)0);
+		ip_stripoptions(m);
 		iphlen = sizeof(struct ip);
 	}
 
@@ -4368,7 +4374,7 @@
 	/*
 	 * common chunk processing
 	 */
-#if defined(__FreeBSD__)  || defined(__APPLE__)
+#if defined(__FreeBSD__)  || defined(__APPLE__) || defined(__DragonFly__)
 	length = ip->ip_len + iphlen;
 #else
 	length = ip->ip_len - (ip->ip_hl << 2) + iphlen;
diff -ur kame/netinet/sctp_output.c dfly/netinet/sctp_output.c
--- kame/netinet/sctp_output.c	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctp_output.c	2005-06-18 12:41:43.000000000 +0000
@@ -32,7 +32,7 @@
 #if !(defined(__OpenBSD__) || defined (__APPLE__))
 #include "opt_ipsec.h"
 #endif
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include "opt_compat.h"
 #include "opt_inet6.h"
 #include "opt_inet.h"
@@ -74,7 +74,7 @@
 #include <net/if.h>
 #include <net/if_types.h>
 
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include <net/if_var.h>
 #endif
 
@@ -93,7 +93,7 @@
 #include <netinet6/scope6_var.h>
 #include <netinet6/nd6.h>
 
-#if defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
 #include <netinet6/in6_pcb.h>
 #elif defined(__OpenBSD__)
 #include <netinet/in_pcb.h>
@@ -105,7 +105,7 @@
 
 #include <net/net_osdep.h>
 
-#if defined(HAVE_NRL_INPCB) || defined(__FreeBSD__)
+#if defined(HAVE_NRL_INPCB) || defined(__FreeBSD__) || defined(__DragonFly__)
 #ifndef in6pcb
 #define in6pcb		inpcb
 #endif
@@ -214,7 +214,7 @@
 		while (mret->m_next != NULL) {
 			mret = mret->m_next;
 		}
-		MGET(mret->m_next, M_DONTWAIT, MT_DATA);
+		MGET(mret->m_next, MB_DONTWAIT, MT_DATA);
 		if (mret->m_next == NULL) {
 			/* We are hosed, can't add more addresses */
 			return (m);
@@ -265,17 +265,17 @@
 
 	mret = NULL;
 
-	MGET(mret, M_DONTWAIT, MT_DATA);
+	MGET(mret, MB_DONTWAIT, MT_DATA);
 	if (mret == NULL) {
 		return (NULL);
 	}
-	copy_init = sctp_m_copym(init, init_offset, M_COPYALL, M_DONTWAIT);
+	copy_init = sctp_m_copym(init, init_offset, M_COPYALL, MB_DONTWAIT);
 	if (copy_init == NULL) {
 		sctp_m_freem(mret);
 		return (NULL);
 	}
 	copy_initack = sctp_m_copym(initack, initack_offset, M_COPYALL,
-	    M_DONTWAIT);
+	    MB_DONTWAIT);
 	if (copy_initack == NULL) {
 		sctp_m_freem(mret);
 		sctp_m_freem(copy_init);
@@ -317,7 +317,7 @@
 			break;
 		}
 	}
-	MGET(sig, M_DONTWAIT, MT_DATA);
+	MGET(sig, MB_DONTWAIT, MT_DATA);
 	if (sig == NULL) {
 		/* no space */
 		sctp_m_freem(mret);
@@ -1157,7 +1157,7 @@
 		 * Need a route to cache.
 		 *
 		 */
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		rtalloc_ign(ro, 0UL);
 #else
 		rtalloc(ro);
@@ -1903,7 +1903,7 @@
 		to->sin6_scope_id = 0;
 #endif
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		rtalloc_ign(ro, 0UL);
 #else
 		rtalloc(ro);
@@ -2133,7 +2133,7 @@
 	if (to->sa_family == AF_INET) {
 		struct ip *ip;
 		struct route iproute;
-		M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
+		M_PREPEND(m, sizeof(struct ip), MB_DONTWAIT);
 		if (m == NULL) {
 			/* failed to prepend data, give up */
 			return (ENOMEM);
@@ -2142,7 +2142,7 @@
 		ip->ip_v = IPVERSION;
 		ip->ip_hl = (sizeof(struct ip) >> 2);
 		if (nofragment_flag) {
-#if defined(WITH_CONVERT_IP_OFF) || defined(__FreeBSD__)
+#if defined(WITH_CONVERT_IP_OFF) || defined(__FreeBSD__) || defined(__DragonFly__)
 #if defined( __OpenBSD__) || defined(__NetBSD__)
 			/* OpenBSD has WITH_CONVERT_IP_OFF defined?? */
 			ip->ip_off = htons(IP_DF);
@@ -2162,7 +2162,7 @@
 		ip->ip_id = htons(ip_id++);
 #endif
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		ip->ip_ttl = inp->ip_inp.inp.inp_ip_ttl;
 #else
 		ip->ip_ttl = inp->inp_ip_ttl;
@@ -2175,7 +2175,7 @@
 		if (stcb) {
 			if ((stcb->asoc.ecn_allowed) && ecn_ok) {
 				/* Enable ECN */
-#if defined(__FreeBSD__) || defined (__APPLE__)
+#if defined(__FreeBSD__) || defined (__APPLE__) || defined(__DragonFly__)
 				ip->ip_tos = (u_char)((inp->ip_inp.inp.inp_ip_tos & 0x000000fc) |
 						      sctp_get_ect(stcb, chk));
 #elif defined(__NetBSD__)
@@ -2187,7 +2187,7 @@
 #endif
 			} else {
 				/* No ECN */
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 				ip->ip_tos = inp->ip_inp.inp.inp_ip_tos;
 #elif defined(__NetBSD__)
 				ip->ip_tos = inp->ip_inp.inp.inp_ip.ip_tos;
@@ -2197,7 +2197,7 @@
 			}
 		} else {
 			/* no association at all */
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 			ip->ip_tos = inp->ip_inp.inp.inp_ip_tos;
 #else
 			ip->ip_tos = inp->inp_ip_tos;
@@ -2292,7 +2292,8 @@
 		}
 		ret = ip_output(m, inp->ip_inp.inp.inp_options,
 				ro, o_flgs, inp->ip_inp.inp.inp_moptions
-#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version >= 480000)
+#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version >= 480000) \
+    || defined(__DragonFly__)
 				, (struct inpcb *)NULL
 #endif
 #if defined(__NetBSD__)
@@ -2346,7 +2347,7 @@
 		int error;
 		u_short prev_port=0;
 
-		M_PREPEND(m, sizeof(struct ip6_hdr), M_DONTWAIT);
+		M_PREPEND(m, sizeof(struct ip6_hdr), MB_DONTWAIT);
 		if (m == NULL) {
 			/* failed to prepend data, give up */
 			return (ENOMEM);
@@ -2368,7 +2369,7 @@
 		sin6 = &tmp;
 
 		/* KAME hack: embed scopeid */
-#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__)
+#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__) || defined(__DragonFly__)
 		if (in6_embedscope(&sin6->sin6_addr, sin6, NULL, NULL) != 0)
 #else
 		if (in6_embedscope(&sin6->sin6_addr, sin6) != 0)
@@ -2522,7 +2523,7 @@
 				 (struct socket *)inp->sctp_socket,
 #endif
 				 &ifp
-#if (defined(__FreeBSD__) && __FreeBSD_version >= 480000)
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 480000) || defined(__DragonFly__)
 		    , NULL
 #endif
 			);
@@ -2701,13 +2702,13 @@
 		/* we are hosed since I can't start the INIT timer? */
 		return;
 	}
-	MGETHDR(m, M_DONTWAIT, MT_HEADER);
+	MGETHDR(m, MB_DONTWAIT, MT_HEADER);
 	if (m == NULL) {
 		/* No memory, INIT timer will re-attempt. */
 		return;
 	}
 	/* make it into a M_EXT */
-	MCLGET(m, M_DONTWAIT);
+	MCLGET(m, MB_DONTWAIT);
 	if ((m->m_flags & M_EXT) != M_EXT) {
 		/* Failed to get cluster buffer */
 		sctp_m_freem(m);
@@ -3060,7 +3061,7 @@
 			*abort_processing = 1;
 			if (op_err == NULL) {
 				/* Ok need to try to get a mbuf */
-				MGETHDR(op_err, M_DONTWAIT, MT_DATA);
+				MGETHDR(op_err, MB_DONTWAIT, MT_DATA);
 				if (op_err) {
 					op_err->m_len = 0;
 					op_err->m_pkthdr.len = 0;
@@ -3115,7 +3116,7 @@
 #endif
 				if (op_err == NULL) {
 					/* Ok need to try to get an mbuf */
-					MGETHDR(op_err, M_DONTWAIT, MT_DATA);
+					MGETHDR(op_err, MB_DONTWAIT, MT_DATA);
 					if (op_err) {
 						op_err->m_len = 0;
 						op_err->m_pkthdr.len = 0;
@@ -3373,14 +3374,14 @@
 		sctp_send_abort(init_pkt, iphlen, sh, init_chk->init.initiate_tag, op_err);
 		return;
 	}
-	MGETHDR(m, M_DONTWAIT, MT_HEADER);
+	MGETHDR(m, MB_DONTWAIT, MT_HEADER);
 	if (m == NULL) {
 		/* No memory, INIT timer will re-attempt. */
 		if (op_err)
 			sctp_m_freem(op_err);
 		return;
 	}
-	MCLGET(m, M_DONTWAIT);
+	MCLGET(m, MB_DONTWAIT);
 	if ((m->m_flags & M_EXT) != M_EXT) {
 		/* Failed to get cluster buffer */
 		if (op_err)
@@ -3447,7 +3448,7 @@
 		stc.ipv6_addr_legal = 1;
 		/* Now look at the binding flag to see if V4 will be legal */
 		if (
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		    (in_inp->inp_flags & IN6P_IPV6_V6ONLY)
 #elif defined(__OpenBSD__)
 		    (0)	/* For openbsd we do dual bind only */
@@ -3566,7 +3567,7 @@
 				/* pull out the scope_id from incoming pkt */
 				(void)in6_recoverscope(sin6, &ip6->ip6_src,
 				    init_pkt->m_pkthdr.rcvif);
-#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__)
+#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__) || defined(__DragonFly__)
 				in6_embedscope(&sin6->sin6_addr, sin6, NULL,
 				    NULL);
 #else
@@ -4246,7 +4247,7 @@
 					dataout += n->m_len;
 				}
 			}
-			M_PREPEND(m, sizeof(struct sctp_paramhdr), M_DONTWAIT);
+			M_PREPEND(m, sizeof(struct sctp_paramhdr), MB_DONTWAIT);
 			if (m) {
 				struct sctp_paramhdr *ph;
 				m->m_len = sizeof(struct sctp_paramhdr) + dataout;
@@ -4476,7 +4477,7 @@
 			 * We can wait since this is called from the user
 			 * send side
 			 */
-			n->m_nextpkt = m_split(n, siz, M_WAIT);
+			n->m_nextpkt = m_split(n, siz, MB_WAIT);
 			if (n->m_nextpkt == NULL) {
 				error = EFAULT;
 				SOCKBUF_LOCK(&so->so_snd);
@@ -4698,12 +4699,12 @@
 #if defined(__FreeBSD__) || defined(__NetBSD__)
 	/* Supposedly m_copypacket is an optimization, use it if we can */
 	if (clonechain->m_flags & M_PKTHDR) {
-		appendchain = m_copypacket(clonechain, M_DONTWAIT);
+		appendchain = m_copypacket(clonechain, MB_DONTWAIT);
 		sctp_pegs[SCTP_CACHED_SRC]++;
 	} else
 		appendchain = m_copy(clonechain, 0, M_COPYALL);
 #elif defined(__APPLE__)
-	appendchain = sctp_m_copym(clonechain, 0, M_COPYALL, M_DONTWAIT);
+	appendchain = sctp_m_copym(clonechain, 0, M_COPYALL, MB_DONTWAIT);
 #else
 	appendchain = m_copy(clonechain, 0, M_COPYALL);
 #endif
@@ -4814,7 +4815,7 @@
 	struct mbuf *ret, *at;
 	int left, willcpy, cancpy, error;
 
-	MGETHDR(ret, M_WAIT, MT_HEADER);
+	MGETHDR(ret, MB_WAIT, MT_HEADER);
 	if (ret == NULL) {
 		/* TSNH */
 		return (NULL);
@@ -4822,7 +4823,7 @@
 	left = len;
 	ret->m_len = 0;
 	ret->m_pkthdr.len = len;
-	MCLGET(ret, M_WAIT);
+	MCLGET(ret, MB_WAIT);
 	if (ret == NULL) {
 		return (NULL);
 	}
@@ -4846,13 +4847,13 @@
 		at->m_nextpkt = at->m_next = 0;
 		left -= willcpy;
 		if (left > 0) {
-			MGET(at->m_next, M_WAIT, MT_DATA);
+			MGET(at->m_next, MB_WAIT, MT_DATA);
 			if (at->m_next == NULL) {
 				goto err_out_now;
 			}
 			at = at->m_next;
 			at->m_len = 0;
-			MCLGET(at, M_WAIT);
+			MCLGET(at, MB_WAIT);
 			if (at == NULL) {
 				goto err_out_now;
 			}
@@ -4872,7 +4873,7 @@
 	int ret;
 	struct sctp_copy_all *ca;
 	MALLOC(ca, struct sctp_copy_all *,
-	       sizeof(struct sctp_copy_all), M_PCB, M_WAIT);
+	       sizeof(struct sctp_copy_all), M_PCB, MB_WAIT);
 	if (ca == NULL) {
 		m_freem(m);
 		return (ENOMEM);
@@ -5110,7 +5111,7 @@
 		nchk = TAILQ_NEXT(chk, sctp_next);
 		/* now put in the chunk header */
 		orig = chk->data;
-		M_PREPEND(chk->data, sizeof(struct sctp_data_chunk), M_DONTWAIT);
+		M_PREPEND(chk->data, sizeof(struct sctp_data_chunk), MB_DONTWAIT);
 		if (chk->data == NULL) {
 			/* HELP */
 			failed++;
@@ -5688,7 +5689,7 @@
 						 */
 						outchain->m_len = sizeof(struct sctphdr);
 					} else {
-						M_PREPEND(outchain, sizeof(struct sctphdr), M_DONTWAIT);
+						M_PREPEND(outchain, sizeof(struct sctphdr), MB_DONTWAIT);
 						if (outchain == NULL) {
 							/* no memory */
 							error = ENOBUFS;
@@ -5942,7 +5943,7 @@
 			if ((outchain->m_flags & M_PKTHDR) == 0) {
 				struct mbuf *t;
 
-				MGETHDR(t, M_DONTWAIT, MT_HEADER);
+				MGETHDR(t, MB_DONTWAIT, MT_HEADER);
 				if (t == NULL) {
 					sctp_m_freem(outchain);
 					return (ENOMEM);
@@ -5966,7 +5967,7 @@
 				MH_ALIGN(outchain, sizeof(struct sctphdr));
 				outchain->m_len = sizeof(struct sctphdr);
 			} else {
-				M_PREPEND(outchain, sizeof(struct sctphdr), M_DONTWAIT);
+				M_PREPEND(outchain, sizeof(struct sctphdr), MB_DONTWAIT);
 				if (outchain == NULL) {
 					/* out of mbufs */
 					error = ENOBUFS;
@@ -6090,7 +6091,7 @@
 	}
 	sctppcbinfo.ipi_count_chunk++;
 	sctppcbinfo.ipi_gencnt_chunk++;
-	M_PREPEND(op_err, sizeof(struct sctp_chunkhdr), M_DONTWAIT);
+	M_PREPEND(op_err, sizeof(struct sctp_chunkhdr), MB_DONTWAIT);
 	if (op_err == NULL) {
 		SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_chunk, chk);
 		sctppcbinfo.ipi_count_chunk--;
@@ -6157,7 +6158,7 @@
 			if ((pad = (plen % 4))) {
 				plen += 4 - pad;
 			}
-			cookie = sctp_m_copym(m, at, plen, M_DONTWAIT);
+			cookie = sctp_m_copym(m, at, plen, MB_DONTWAIT);
 			if (cookie == NULL) {
 				/* No memory */
 				return (-2);
@@ -6179,7 +6180,7 @@
 	/* now we MUST have a PKTHDR on it */
 	if ((cookie->m_flags & M_PKTHDR) != M_PKTHDR) {
 		/* we hope this happens rarely */
-		MGETHDR(mat, M_DONTWAIT, MT_HEADER);
+		MGETHDR(mat, MB_DONTWAIT, MT_HEADER);
 		if (mat == NULL) {
 			sctp_m_freem(cookie);
 			return (-4);
@@ -6232,7 +6233,7 @@
 		/* must have a net pointer */
 		return;
 
-	outchain = sctp_m_copym(m, offset, chk_length, M_DONTWAIT);
+	outchain = sctp_m_copym(m, offset, chk_length, MB_DONTWAIT);
 	if (outchain == NULL) {
 		/* gak out of memory */
 		return;
@@ -6243,7 +6244,7 @@
 	if ((outchain->m_flags & M_PKTHDR) != M_PKTHDR) {
 		/* should not happen but we are cautious. */
 		struct mbuf *tmp;
-		MGETHDR(tmp, M_DONTWAIT, MT_HEADER);
+		MGETHDR(tmp, MB_DONTWAIT, MT_HEADER);
 		if (tmp == NULL) {
 			return;
 		}
@@ -6290,7 +6291,7 @@
 	struct sctp_tmit_chunk *chk;
 
 	cookie_ack = NULL;
-	MGETHDR(cookie_ack, M_DONTWAIT, MT_HEADER);
+	MGETHDR(cookie_ack, MB_DONTWAIT, MT_HEADER);
 	if (cookie_ack == NULL) {
 		/* no mbuf's */
 		return (-1);
@@ -6339,7 +6340,7 @@
 	struct sctp_tmit_chunk *chk;
 
 	m_shutdown_ack = NULL;
-	MGETHDR(m_shutdown_ack, M_DONTWAIT, MT_HEADER);
+	MGETHDR(m_shutdown_ack, MB_DONTWAIT, MT_HEADER);
 	if (m_shutdown_ack == NULL) {
 		/* no mbuf's */
 		return (-1);
@@ -6384,7 +6385,7 @@
 	struct sctp_tmit_chunk *chk;
 
 	m_shutdown = NULL;
-	MGETHDR(m_shutdown, M_DONTWAIT, MT_HEADER);
+	MGETHDR(m_shutdown, MB_DONTWAIT, MT_HEADER);
 	if (m_shutdown == NULL) {
 		/* no mbuf's */
 		return (-1);
@@ -6489,7 +6490,7 @@
 	 * use it if we can.
 	 */
 	if (stcb->asoc.last_asconf_ack_sent->m_flags & M_PKTHDR) {
-		m_ack = m_copypacket(stcb->asoc.last_asconf_ack_sent, M_DONTWAIT);
+		m_ack = m_copypacket(stcb->asoc.last_asconf_ack_sent, MB_DONTWAIT);
 		sctp_pegs[SCTP_CACHED_SRC]++;
 	} else
 		m_ack = m_copy(stcb->asoc.last_asconf_ack_sent, 0, M_COPYALL);
@@ -6650,7 +6651,7 @@
 			 */
 			m->m_len = sizeof(struct sctphdr);
 		} else {
-			M_PREPEND(m, sizeof(struct sctphdr), M_DONTWAIT);
+			M_PREPEND(m, sizeof(struct sctphdr), MB_DONTWAIT);
 			if (m == NULL) {
 				return (ENOBUFS);
 			}
@@ -6844,7 +6845,7 @@
 				 */
 				m->m_len = sizeof(struct sctphdr);
 			} else {
-				M_PREPEND(m, sizeof(struct sctphdr), M_DONTWAIT);
+				M_PREPEND(m, sizeof(struct sctphdr), MB_DONTWAIT);
 				if (m == NULL) {
 					return (ENOBUFS);
 				}
@@ -7198,7 +7199,7 @@
      struct mbuf *m;
      struct sockaddr *addr;
      struct mbuf *control;
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
      struct thread *p;
 #else
      struct proc *p;
@@ -7477,7 +7478,7 @@
 				MALLOC(asoc->strmout, struct sctp_stream_out *,
 				       asoc->streamoutcnt *
 				       sizeof(struct sctp_stream_out), M_PCB,
-				       M_WAIT);
+				       MB_WAIT);
 				for (i = 0; i < asoc->streamoutcnt; i++) {
 					/*
 					 * inbound side must be set to 0xffff,
@@ -7662,7 +7663,7 @@
 	sctppcbinfo.ipi_gencnt_chunk++;
 	chk->rec.chunk_id = SCTP_FORWARD_CUM_TSN;
 	chk->asoc = asoc;
-	MGETHDR(chk->data, M_DONTWAIT, MT_DATA);
+	MGETHDR(chk->data, MB_DONTWAIT, MT_DATA);
 	if (chk->data == NULL) {
 		chk->whoTo->ref_count--;
 		SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_chunk, chk);
@@ -7709,7 +7710,7 @@
 			/* Need a M_EXT, get one and move
 			 * fwdtsn to data area.
 			 */
-			MCLGET(chk->data, M_DONTWAIT);
+			MCLGET(chk->data, MB_DONTWAIT);
 		}
 		cnt_of_space = M_TRAILINGSPACE(chk->data);
 
@@ -7885,7 +7886,7 @@
 		a_chk->whoTo->ref_count++;
 
 	/* Ok now lets formulate a MBUF with our sack */
-	MGETHDR(a_chk->data, M_DONTWAIT, MT_DATA);
+	MGETHDR(a_chk->data, MB_DONTWAIT, MT_DATA);
 	if ((a_chk->data == NULL) ||
 	    (a_chk->whoTo == NULL)) {
 		/* rats, no mbuf memory */
@@ -8006,7 +8007,7 @@
 
 	if ((space+SCTP_MIN_OVERHEAD) > MHLEN) {
 		/* We need a cluster */
-		MCLGET(a_chk->data, M_DONTWAIT);
+		MCLGET(a_chk->data, MB_DONTWAIT);
 		if ((a_chk->data->m_flags & M_EXT) != M_EXT) {
 			/* can't get a cluster
 			 * give up and try later.
@@ -8103,7 +8104,7 @@
 	struct sctp_abort_msg *abort_m;
 	int sz;
 	abort_m = NULL;
-	MGETHDR(m_abort, M_DONTWAIT, MT_HEADER);
+	MGETHDR(m_abort, MB_DONTWAIT, MT_HEADER);
 	if (m_abort == NULL) {
 		/* no mbuf's */
 		return;
@@ -8147,7 +8148,7 @@
 	struct sctp_shutdown_complete_msg *comp_cp;
 
 	m_shutdown_comp = NULL;
-	MGETHDR(m_shutdown_comp, M_DONTWAIT, MT_HEADER);
+	MGETHDR(m_shutdown_comp, MB_DONTWAIT, MT_HEADER);
 	if (m_shutdown_comp == NULL) {
 		/* no mbuf's */
 		return (-1);
@@ -8186,7 +8187,7 @@
 	int offset_out;
 	struct sctp_shutdown_complete_msg *comp_cp;
 
-	MGETHDR(mout, M_DONTWAIT, MT_HEADER);
+	MGETHDR(mout, MB_DONTWAIT, MT_HEADER);
 	if (mout == NULL) {
 		/* no mbuf's */
 		return (-1);
@@ -8279,7 +8280,8 @@
 #endif
 		/* out it goes */
 		ip_output(mout, 0, &ro, IP_RAWOUTPUT, NULL
-#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version >= 480000)  || defined(__NetBSD__)
+#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version >= 480000) \
+    || defined(__NetBSD__) || defined(__DragonFly__)
 		    , NULL
 #endif
 		    );
@@ -8305,7 +8307,7 @@
 #if defined(__NetBSD__)
 			   , NULL
 #endif
-#if (defined(__FreeBSD__) && __FreeBSD_version >= 480000)
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 480000) || defined(__DragonFly__)
 			   , NULL
 #endif
 		    );
@@ -8489,7 +8491,7 @@
 	chk->rec.chunk_id = SCTP_HEARTBEAT_REQUEST;
 	chk->asoc = &stcb->asoc;
 	chk->send_size = sizeof(struct sctp_heartbeat_chunk);
-	MGETHDR(chk->data, M_DONTWAIT, MT_DATA);
+	MGETHDR(chk->data, MB_DONTWAIT, MT_DATA);
 	if (chk->data == NULL) {
 		SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_chunk, chk);
 		sctppcbinfo.ipi_count_chunk--;
@@ -8619,7 +8621,7 @@
 	chk->rec.chunk_id = SCTP_ECN_ECHO;
 	chk->asoc = &stcb->asoc;
 	chk->send_size = sizeof(struct sctp_ecne_chunk);
-	MGETHDR(chk->data, M_DONTWAIT, MT_DATA);
+	MGETHDR(chk->data, MB_DONTWAIT, MT_DATA);
 	if (chk->data == NULL) {
 		SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_chunk, chk);
 		sctppcbinfo.ipi_count_chunk--;
@@ -8693,7 +8695,7 @@
 		chk->send_size = len = m->m_pkthdr.len - iphlen;
 	}
 	chk->asoc = &stcb->asoc;
-	MGETHDR(chk->data, M_DONTWAIT, MT_DATA);
+	MGETHDR(chk->data, MB_DONTWAIT, MT_DATA);
 	if (chk->data == NULL) {
 	jump_out:
 		SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_chunk, chk);
@@ -8705,7 +8707,7 @@
 		return;
 	}
 	if ((chk->send_size+sizeof(struct sctp_pktdrop_chunk)+SCTP_MIN_OVERHEAD) > MHLEN) {
-		MCLGET(chk->data, M_DONTWAIT);
+		MCLGET(chk->data, MB_DONTWAIT);
 		if ((chk->data->m_flags & M_EXT) == 0) {
 			/* Give up */
 			sctp_m_freem(chk->data);
@@ -8802,7 +8804,7 @@
 	chk->rec.chunk_id = SCTP_ECN_CWR;
 	chk->asoc = &stcb->asoc;
 	chk->send_size = sizeof(struct sctp_cwr_chunk);
-	MGETHDR(chk->data, M_DONTWAIT, MT_DATA);
+	MGETHDR(chk->data, MB_DONTWAIT, MT_DATA);
 	if (chk->data == NULL) {
 		SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_chunk, chk);
 		sctppcbinfo.ipi_count_chunk--;
@@ -8875,7 +8877,7 @@
 	chk->rec.chunk_id = SCTP_STREAM_RESET;
 	chk->asoc = &stcb->asoc;
 	chk->send_size = sizeof(struct sctp_stream_reset_resp) + (number_entries * sizeof(uint16_t));
-	MGETHDR(chk->data, M_DONTWAIT, MT_DATA);
+	MGETHDR(chk->data, MB_DONTWAIT, MT_DATA);
 	if (chk->data == NULL) {
 	strresp_jump_out:
 		SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_chunk, chk);
@@ -8889,7 +8891,7 @@
 	chk->data->m_data += SCTP_MIN_OVERHEAD;
 	chk->data->m_pkthdr.len = chk->data->m_len = SCTP_SIZE32(chk->send_size);
 	if (M_TRAILINGSPACE(chk->data) < (int)SCTP_SIZE32(chk->send_size)) {
-		MCLGET(chk->data, M_DONTWAIT);
+		MCLGET(chk->data, MB_DONTWAIT);
 		if ((chk->data->m_flags & M_EXT) == 0) {
 			/* Give up */
 			sctp_m_freem(chk->data);
@@ -9030,7 +9032,7 @@
 	chk->rec.chunk_id = SCTP_STREAM_RESET;
 	chk->asoc = &stcb->asoc;
 	chk->send_size = sizeof(struct sctp_stream_reset_req) + (number_entrys * sizeof(uint16_t));
-	MGETHDR(chk->data, M_DONTWAIT, MT_DATA);
+	MGETHDR(chk->data, MB_DONTWAIT, MT_DATA);
 	if (chk->data == NULL) {
 	strreq_jump_out:
 		SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_chunk, chk);
@@ -9044,7 +9046,7 @@
 	chk->data->m_data += SCTP_MIN_OVERHEAD;
 	chk->data->m_pkthdr.len = chk->data->m_len = SCTP_SIZE32(chk->send_size);
 	if (M_TRAILINGSPACE(chk->data) < (int)SCTP_SIZE32(chk->send_size)) {
-		MCLGET(chk->data, M_DONTWAIT);
+		MCLGET(chk->data, MB_DONTWAIT);
 		if ((chk->data->m_flags & M_EXT) == 0) {
 			/* Give up */
 			sctp_m_freem(chk->data);
@@ -9134,7 +9136,7 @@
 			sctp_m_freem(err_cause);
 		return;
 	}
-	MGETHDR(mout, M_DONTWAIT, MT_HEADER);
+	MGETHDR(mout, MB_DONTWAIT, MT_HEADER);
 	if (mout == NULL) {
 		if (err_cause)
 			sctp_m_freem(err_cause);
@@ -9247,7 +9249,8 @@
 #endif
 		/* out it goes */
 		(void)ip_output(mout, 0, &ro, IP_RAWOUTPUT, NULL
-#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version >= 480000) || defined(__NetBSD__)
+#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version >= 480000) \
+    || defined(__NetBSD__) || defined(__DragonFly__)
 		    , NULL
 #endif
 		    );
@@ -9273,7 +9276,7 @@
 #if defined(__NetBSD__)
 			, NULL
 #endif
-#if (defined(__FreeBSD__) && __FreeBSD_version >= 480000)
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 480000) || defined(__DragonFly__)
 		    , NULL
 #endif
 		    );
@@ -9281,7 +9284,7 @@
 		if (ro.ro_rt)
 			RTFREE(ro.ro_rt);
 	}
-        sctp_pegs[SCTP_DATAGRAMS_SENT]++;
+	sctp_pegs[SCTP_DATAGRAMS_SENT]++;
 }
 
 void
@@ -9307,7 +9310,7 @@
 		m_freem(scm);
 		return;
 	}
-	M_PREPEND(scm, (sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr)), M_DONTWAIT);
+	M_PREPEND(scm, (sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr)), MB_DONTWAIT);
 	if (scm == NULL) {
 		/* can't send because we can't add a mbuf */
 		return;
@@ -9340,7 +9343,7 @@
 		/* V4 */
 		struct ip *out;
 		struct route ro;
-		M_PREPEND(scm, sizeof(struct ip), M_DONTWAIT);
+		M_PREPEND(scm, sizeof(struct ip), MB_DONTWAIT);
 		if (scm == NULL)
 			return;
 		bzero(&ro, sizeof ro);
@@ -9361,7 +9364,8 @@
 		out->ip_len = htons(scm->m_pkthdr.len);
 #endif
 		retcode = ip_output(scm, 0, &ro, IP_RAWOUTPUT, NULL
-#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version >= 480000) || defined(__NetBSD__)
+#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version >= 480000) \
+    || defined(__NetBSD__) || defined(__DragonFly__)
 		    , NULL
 #endif
 			);
@@ -9378,7 +9382,7 @@
 #endif
 		struct ip6_hdr *out6, *in6;
 
-		M_PREPEND(scm, sizeof(struct ip6_hdr), M_DONTWAIT);
+		M_PREPEND(scm, sizeof(struct ip6_hdr), MB_DONTWAIT);
 		if (scm == NULL)
 			return;
 		bzero(&ro, sizeof ro);
@@ -9411,7 +9415,7 @@
 #if defined(__NetBSD__)
 	    , NULL
 #endif
-#if (defined(__FreeBSD__) && __FreeBSD_version >= 480000)
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 480000) || defined(__DragonFly__)
 	    , NULL
 #endif
 		);
@@ -9435,7 +9439,7 @@
 	}
 	m->m_len = 0;
 	if ((left+resv_upfront) > (int)MHLEN) {
-		MCLGET(m, M_WAIT);
+		MCLGET(m, MB_WAIT);
 		if (m == NULL) {
 			*mbcnt = 0;
 			return (ENOMEM);
@@ -9471,7 +9475,7 @@
 		m->m_nextpkt = 0;
 		left -= willcpy;
 		if (left > 0) {
-			MGET(m->m_next, M_WAIT, MT_DATA);
+			MGET(m->m_next, MB_WAIT, MT_DATA);
 			if (m->m_next == NULL) {
 				*mbcnt = 0;
 				return (ENOMEM);
@@ -9480,7 +9484,7 @@
 			m->m_len = 0;
 			*mbcnt += MSIZE;
 			if (left > (int)MHLEN) {
-				MCLGET(m, M_WAIT);
+				MCLGET(m, MB_WAIT);
 				if (m == NULL) {
 					*mbcnt = 0;
 					return (ENOMEM);
@@ -9675,7 +9679,7 @@
 			 * it is done that way in the sosend code so I guess
 			 * it is ok :-0
 			 */
- 			MGETHDR(mm, M_WAIT, MT_DATA);
+ 			MGETHDR(mm, MB_WAIT, MT_DATA);
 			if (mm) {
 				struct sctp_paramhdr *ph;
 
@@ -9686,7 +9690,7 @@
 						tot_demand = MCLBYTES;
 						tot_out = tot_demand - sizeof(struct sctp_paramhdr);
 					}
-					MCLGET(mm, M_WAIT);
+					MCLGET(mm, MB_WAIT);
 					if ((mm->m_flags & M_EXT) == 0) {
 						/* truncate further */
 						tot_demand = MHLEN;
@@ -9786,7 +9790,7 @@
 		sctppcbinfo.ipi_count_chunk++;
 		sctppcbinfo.ipi_gencnt_chunk++;
 		asoc->chunks_on_out_queue++;
-		MGETHDR(mm, M_WAIT, MT_DATA);
+		MGETHDR(mm, MB_WAIT, MT_DATA);
 		if (mm == NULL) {
 			error = ENOMEM;
 			goto clean_up;
@@ -9881,7 +9885,7 @@
 			sctppcbinfo.ipi_gencnt_chunk++;
 			*chk = template;
 			chk->whoTo->ref_count++;
-			MGETHDR(chk->data, M_WAIT, MT_DATA);
+			MGETHDR(chk->data, MB_WAIT, MT_DATA);
 			if (chk->data == NULL) {
 				error = ENOMEM;
 				goto temp_clean_up;
@@ -10077,7 +10081,7 @@
 	    int flags
 #else
 	    int flags,
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 	    struct thread *p
 #else
 	    struct proc *p
@@ -10282,7 +10286,7 @@
 					       struct sctp_stream_out *,
 					       asoc->streamoutcnt *
 					       sizeof(struct sctp_stream_out),
-					       M_PCB, M_WAIT);
+					       M_PCB, MB_WAIT);
 					for (i = 0; i < asoc->streamoutcnt; i++) {
 						/*
 						 * inbound side must be set to 0xffff,
@@ -10352,7 +10356,7 @@
 	}
 	/* Ok, we will attempt a msgsnd :> */
 	if (p)
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 		p->td_proc->p_stats->p_ru.ru_msgsnd++;
 #else
 	p->p_stats->p_ru.ru_msgsnd++;
diff -ur kame/netinet/sctp_output.h dfly/netinet/sctp_output.h
--- kame/netinet/sctp_output.h	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctp_output.h	2005-06-18 12:41:43.000000000 +0000
@@ -82,7 +82,7 @@
 
 void sctp_fix_ecn_echo(struct sctp_association *);
 
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 int sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
     struct mbuf *, struct thread *, int);
 #else
@@ -140,7 +140,7 @@
     int flags
 #else
     int flags,
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
     struct thread *p
 #else
     struct proc *p
diff -ur kame/netinet/sctp_pcb.c dfly/netinet/sctp_pcb.c
--- kame/netinet/sctp_pcb.c	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctp_pcb.c	2005-06-18 12:41:43.000000000 +0000
@@ -34,7 +34,7 @@
 #if !(defined(__OpenBSD__) || defined(__APPLE__))
 #include "opt_ipsec.h"
 #endif
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include "opt_compat.h"
 #include "opt_inet6.h"
 #include "opt_inet.h"
@@ -59,7 +59,7 @@
 #include <sys/proc.h>
 #include <sys/kernel.h>
 #include <sys/sysctl.h>
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 #include <sys/random.h>
 #endif
 #if defined(__NetBSD__)
@@ -98,7 +98,7 @@
 #include <netinet/ip6.h>
 #include <netinet6/ip6_var.h>
 #include <netinet6/scope6_var.h>
-#if defined(__FreeBSD__) || (__NetBSD__)
+#if defined(__FreeBSD__) || (__NetBSD__) || defined(__DragonFly__)
 #include <netinet6/in6_pcb.h>
 #elif defined(__OpenBSD__)
 #include <netinet/in_pcb.h>
@@ -813,7 +813,7 @@
 			/* got it */
 			if ((nam->sa_family == AF_INET) &&
 			    (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 			    (((struct inpcb *)inp)->inp_flags & IN6P_IPV6_V6ONLY)
 #else
 #if defined(__OpenBSD__)
@@ -1300,14 +1300,14 @@
 		to6->sin6_port = sh->dest_port;
 		/* Get the scopes in properly to the sin6 addr's */
 		(void)in6_recoverscope(to6, &to6->sin6_addr, NULL);
-#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__)
+#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__) || defined(__DragonFly__)
 		(void)in6_embedscope(&to6->sin6_addr, to6, NULL, NULL);
 #else
 		(void)in6_embedscope(&to6->sin6_addr, to6);
 #endif
 
 		(void)in6_recoverscope(from6, &from6->sin6_addr, NULL);
-#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__)
+#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__) || defined(__DragonFly__)
 		(void)in6_embedscope(&from6->sin6_addr, from6, NULL, NULL);
 #else
 		(void)in6_embedscope(&from6->sin6_addr, from6);
@@ -1516,7 +1516,7 @@
 	}
 #endif /* IPSEC */
 	sctppcbinfo.ipi_count_ep++;
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	inp->ip_inp.inp.inp_gencnt = ++sctppcbinfo.ipi_gencnt_ep;
 	inp->ip_inp.inp.inp_ip_ttl = ip_defttl;
 #else
@@ -1584,6 +1584,7 @@
 #else
 	callout_init(&inp->sctp_ep.signature_change.timer);
 #endif
+	printf("signature_change.timer has been initiated!\n");
 	inp->sctp_ep.signature_change.type = SCTP_TIMER_TYPE_NEWCOOKIE;
 
 	/* now init the actual endpoint default data */
@@ -1620,7 +1621,7 @@
 	/* seed random number generator */
 	m->random_counter = 1;
 	m->store_at = SCTP_SIGNATURE_SIZE;
-#if defined(__FreeBSD__) && (__FreeBSD_version < 500000)
+#if (defined(__FreeBSD__) && (__FreeBSD_version < 500000)) || defined(__DragonFly__)
 	read_random_unlimited(m->random_numbers, sizeof(m->random_numbers));
 #elif defined(__APPLE__) || (__FreeBSD_version > 500000)
 	read_random(m->random_numbers, sizeof(m->random_numbers));
@@ -1807,7 +1808,7 @@
 	return (0);
 }
 
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 /*
  * Don't know why, but without this there is an unknown reference when
  * compiling NetBSD... hmm
@@ -1817,7 +1818,7 @@
 
 
 int
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, struct thread *p)
 #else
 sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, struct proc *p)
@@ -1857,7 +1858,7 @@
 
 			/* IPV6_V6ONLY socket? */
 			if (
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 				(ip_inp->inp_flags & IN6P_IPV6_V6ONLY)
 #else
 #if defined(__OpenBSD__)
@@ -1892,7 +1893,7 @@
 			if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
 				bindall = 0;
 				/* KAME hack: embed scopeid */
-#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__)
+#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__) || defined(__DragonFly__)
 				if (in6_embedscope(&sin6->sin6_addr, sin6,
 				    ip_inp, NULL) != 0)
 					return (EINVAL);
@@ -1926,7 +1927,7 @@
 		/* got to be root to get at low ports */
 		if (ntohs(lport) < IPPORT_RESERVED) {
 			if (p && (error =
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__)
 #if __FreeBSD_version >= 500000
 			    suser_cred(p->td_ucred, 0)
 #else
@@ -1934,6 +1935,8 @@
 #endif
 #elif defined(__NetBSD__) || defined(__APPLE__)
 			    suser(p->p_ucred, &p->p_acflag)
+#elif defined(__DragonFly__)
+			    suser(p)
 #else
 			    suser(p, 0)
 #endif
@@ -2293,7 +2296,7 @@
 				) {
 				/* Left with Data unread */
 				struct mbuf *op_err;
-				MGET(op_err, M_DONTWAIT, MT_DATA);
+				MGET(op_err, MB_DONTWAIT, MT_DATA);
 				if (op_err) {
 					/* Fill in the user initiated abort */
 					struct sctp_paramhdr *ph;
@@ -2355,7 +2358,7 @@
  	rt = ip_pcb->inp_route.ro_rt;
 #endif
 
-	callout_stop(&inp->sctp_ep.signature_change.timer);
+	sctp_timer_stop(SCTP_TIMER_TYPE_INPKILL, inp, NULL, NULL);
 
 	if (so) {
 	/* First take care of socket level things */
@@ -2412,7 +2415,7 @@
 		ip_freemoptions(ip_pcb->inp_moptions);
 		ip_pcb->inp_moptions = 0;
 	}
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 	inp->inp_vflag = 0;
 #else
 	ip_pcb->inp_vflag = 0;
@@ -2432,7 +2435,7 @@
 		SCTP_TCB_LOCK(asoc);
 		if (SCTP_GET_STATE(&asoc->asoc) != SCTP_STATE_COOKIE_WAIT) {
 			struct mbuf *op_err;
-			MGET(op_err, M_DONTWAIT, MT_DATA);
+			MGET(op_err, MB_DONTWAIT, MT_DATA);
 			if (op_err) {
 				/* Fill in the user initiated abort */
 				struct sctp_paramhdr *ph;
@@ -2767,8 +2770,10 @@
 	/* Init the timer structure */
 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
 	callout_init(&net->rxt_timer.timer, 0);
+	callout_init(&net->pmtu_timer.timer, 0);
 #else
 	callout_init(&net->rxt_timer.timer);
+	callout_init(&net->pmtu_timer.timer);
 #endif
 
 	/* Now generate a route for this guy */
@@ -2776,7 +2781,7 @@
 	if (newaddr->sa_family == AF_INET6) {
 		struct sockaddr_in6 *sin6;
 		sin6 = (struct sockaddr_in6 *)&net->ro._l_addr;
-#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__)
+#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__) || defined(__DragonFly__)
 		(void)in6_embedscope(&sin6->sin6_addr, sin6,
 		    &stcb->sctp_ep->ip_inp.inp, NULL);
 #else
@@ -2786,7 +2791,7 @@
 		sin6->sin6_scope_id = 0;
 #endif
 	}
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	rtalloc_ign((struct route *)&net->ro, 0UL);
 #else
 	rtalloc((struct route *)&net->ro);
@@ -2992,7 +2997,7 @@
 
 		if ((err = sctp_inpcb_bind(inp->sctp_socket,
 		    (struct sockaddr *)NULL,
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 					   (struct thread *)NULL
 #else
 					   (struct proc *)NULL
@@ -3096,12 +3101,14 @@
 	callout_init(&asoc->asconf_timer.timer, 0);
 	callout_init(&asoc->shut_guard_timer.timer, 0);
 	callout_init(&asoc->autoclose_timer.timer, 0);
+	callout_init(&asoc->delayed_event_timer.timer, 0);
 #else
 	callout_init(&asoc->hb_timer.timer);
 	callout_init(&asoc->dack_timer.timer);
 	callout_init(&asoc->asconf_timer.timer);
 	callout_init(&asoc->shut_guard_timer.timer);
 	callout_init(&asoc->autoclose_timer.timer);
+	callout_init(&asoc->delayed_event_timer.timer);
 #endif
 	LIST_INSERT_HEAD(&inp->sctp_asoc_list, stcb, sctp_tcblist);
 	/* now file the port under the hash as well */
@@ -3669,13 +3676,13 @@
 	}
 	/* NOTE: all "scope" checks are done when local addresses are added */
 	if (destaddr->sa_family == AF_INET6) {
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 		answer = inp->inp_vflag & INP_IPV6;
 #else
 		answer = inp->ip_inp.inp.inp_vflag & INP_IPV6;
 #endif
 	} else if (destaddr->sa_family == AF_INET) {
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 		answer = inp->inp_vflag & INP_IPV4;
 #else
 		answer = inp->ip_inp.inp.inp_vflag & INP_IPV4;
@@ -3695,7 +3702,7 @@
 	struct sctp_laddr *laddr;
 
 	/* first clear the flag */
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 	inp->inp_vflag = 0;
 #else
 	inp->ip_inp.inp.inp_vflag = 0;
@@ -3714,13 +3721,13 @@
 			continue;
 		}
 		if (laddr->ifa->ifa_addr->sa_family == AF_INET6) {
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 			inp->inp_vflag |= INP_IPV6;
 #else
 			inp->ip_inp.inp.inp_vflag |= INP_IPV6;
 #endif
 		} else if (laddr->ifa->ifa_addr->sa_family == AF_INET) {
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 			inp->inp_vflag |= INP_IPV4;
 #else
 			inp->ip_inp.inp.inp_vflag |= INP_IPV4;
@@ -3768,13 +3775,13 @@
 		inp->laddr_count++;
 		/* update inp_vflag flags */
 		if (ifa->ifa_addr->sa_family == AF_INET6) {
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 			inp->inp_vflag |= INP_IPV6;
 #else
 			inp->ip_inp.inp.inp_vflag |= INP_IPV6;
 #endif
 		} else if (ifa->ifa_addr->sa_family == AF_INET) {
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 			inp->inp_vflag |= INP_IPV4;
 #else
 			inp->ip_inp.inp.inp_vflag |= INP_IPV4;
@@ -4081,12 +4088,12 @@
 
 static char sctp_pcb_initialized = 0;
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 /* sysctl */
 static int sctp_max_number_of_assoc = SCTP_MAX_NUM_OF_ASOC;
 static int sctp_scale_up_for_address = SCTP_SCALE_FOR_ADDR;
 
-#endif /* FreeBSD || APPLE */
+#endif /* FreeBSD || APPLE || DragonFly */
 
 #ifndef SCTP_TCBHASHSIZE
 #define SCTP_TCBHASHSIZE 1024
@@ -4106,7 +4113,7 @@
 	int i;
 	int hashtblsize = SCTP_TCBHASHSIZE;
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	int sctp_chunkscale = SCTP_CHUNKQUEUE_SCALE;
 #endif
 
@@ -4230,7 +4237,8 @@
 	/* mbuf tracker */
 	sctppcbinfo.mbuf_track = 0;
 	/* port stuff */
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) \
+    || defined(__DragonFly__)
 	sctppcbinfo.lastlow = ipport_firstauto;
 #else
 	sctppcbinfo.lastlow = anonportmin;
diff -ur kame/netinet/sctp_pcb.h dfly/netinet/sctp_pcb.h
--- kame/netinet/sctp_pcb.h	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctp_pcb.h	2005-06-18 12:41:43.000000000 +0000
@@ -159,7 +159,7 @@
 	struct sctpiterators iteratorhead;
 
 	/* ep zone info */
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 #if __FreeBSD_version >= 500000
 	struct uma_zone *ipi_zone_ep;
 	struct uma_zone *ipi_zone_asoc;
@@ -336,7 +336,7 @@
 	uint32_t sctp_vtag_first;
 	struct mbuf *pkt, *pkt_last, *sb_last_mpkt;
 	struct mbuf *control;
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 #ifndef INP_IPV6
 #define INP_IPV6	0x1
 #endif
@@ -601,7 +601,7 @@
 
 struct sctp_inpcb *sctp_pcb_findep(struct sockaddr *, int, int);
 
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 int sctp_inpcb_bind(struct socket *, struct sockaddr *, struct thread *);
 #else
 int sctp_inpcb_bind(struct socket *, struct sockaddr *, struct proc *);
diff -ur kame/netinet/sctp_peeloff.c dfly/netinet/sctp_peeloff.c
--- kame/netinet/sctp_peeloff.c	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctp_peeloff.c	2005-06-18 12:41:43.000000000 +0000
@@ -31,7 +31,7 @@
 #if !(defined(__OpenBSD__) || defined(__APPLE__))
 #include "opt_ipsec.h"
 #endif
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include "opt_inet6.h"
 #include "opt_inet.h"
 #endif
@@ -190,7 +190,7 @@
 	newso->so_state &= ~SS_NBIO;
 	newso->so_state |= SS_ISCONNECTED;
 	/* We remove it right away */
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	SOCK_LOCK(head);
 	TAILQ_REMOVE(&head->so_comp, newso, so_list);
 	head->so_qlen--;
diff -ur kame/netinet/sctp_timer.c dfly/netinet/sctp_timer.c
--- kame/netinet/sctp_timer.c	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctp_timer.c	2005-06-18 12:41:43.000000000 +0000
@@ -31,7 +31,7 @@
 #if !(defined(__OpenBSD__) || defined(__APPLE__))
 #include "opt_ipsec.h"
 #endif
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include "opt_compat.h"
 #include "opt_inet6.h"
 #include "opt_inet.h"
@@ -208,7 +208,7 @@
 	if (stcb->asoc.overall_error_count > threshold) {
 		/* Abort notification sends a ULP notify */
 		struct mbuf *oper;
-		MGET(oper, M_DONTWAIT, MT_DATA);
+		MGET(oper, MB_DONTWAIT, MT_DATA);
 		if (oper) {
 			struct sctp_paramhdr *ph;
 			u_int32_t *ippp;
@@ -259,7 +259,7 @@
 			struct sockaddr_in6 *sin6;
 			sin6 = (struct sockaddr_in6 *)&alt->ro._l_addr;
 			if (sin6->sin6_family == AF_INET6) {
-#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__)
+#if defined(SCTP_BASE_FREEBSD) || defined(__APPLE__) || defined(__DragonFly__)
 				(void)in6_embedscope(&sin6->sin6_addr, sin6,
 						     NULL, NULL);
 #else
@@ -267,7 +267,7 @@
 #endif
 			}
 #endif
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 			rtalloc_ign((struct route*)&alt->ro, 0UL);
 #else
 			rtalloc((struct route*)&alt->ro);
@@ -940,7 +940,7 @@
 		if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED) {
 			/* FOOBAR! */
 			struct mbuf *oper;
-			MGET(oper, M_DONTWAIT, MT_DATA);
+			MGET(oper, MB_DONTWAIT, MT_DATA);
 			if (oper) {
 				struct sctp_paramhdr *ph;
 				u_int32_t *ippp;
diff -ur kame/netinet/sctp_usrreq.c dfly/netinet/sctp_usrreq.c
--- kame/netinet/sctp_usrreq.c	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctp_usrreq.c	2005-06-18 12:41:43.000000000 +0000
@@ -34,7 +34,7 @@
 #if !(defined(__OpenBSD__) || defined(__APPLE__))
 #include "opt_ipsec.h"
 #endif
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include "opt_inet6.h"
 #include "opt_inet.h"
 #endif
@@ -62,7 +62,7 @@
 #include <sys/syslog.h>
 #include <net/if.h>
 #include <net/if_types.h>
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 #include <net/if_var.h>
 #endif
 #include <net/route.h>
@@ -98,7 +98,7 @@
 
 #include <net/net_osdep.h>
 
-#if defined(HAVE_NRL_INPCB) || defined(__FreeBSD__)
+#if defined(HAVE_NRL_INPCB) || defined(__FreeBSD__) || defined(__DragonFly__)
 #ifndef in6pcb
 #define in6pcb		inpcb
 #endif
@@ -223,7 +223,7 @@
 	/* Copy it all */
 	*new_chk = *chk;
 	/*  split the data */
-	new_chk->data = m_split(chk->data, (chk->send_size>>1), M_DONTWAIT);
+	new_chk->data = m_split(chk->data, (chk->send_size>>1), MB_DONTWAIT);
 	if (new_chk->data == NULL) {
 		/* Can't split */
 		chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
@@ -444,7 +444,7 @@
 	}
 }
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 void
 #else
 void *
@@ -461,7 +461,7 @@
 
 	if (sa->sa_family != AF_INET ||
 	    ((struct sockaddr_in *)sa)->sin_addr.s_addr == INADDR_ANY) {
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		return;
 #else
 		return (NULL);
@@ -471,7 +471,7 @@
 	if (PRC_IS_REDIRECT(cmd)) {
 		ip = 0;
 	} else if ((unsigned)cmd >= PRC_NCMDS || inetctlerrmap[cmd] == 0) {
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		return;
 #else
 		return (NULL);
@@ -522,7 +522,7 @@
 				sctp_notify_mbuf(inp, stcb, net, ip, sh);
 			}
 		} else {
-#if defined(__FreeBSD__) && __FreeBSD_version < 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version < 500000) || defined(__DragonFly__)
                         /* XXX must be fixed for 5.x and higher, leave for 4.x */
 			if (PRC_IS_REDIRECT(cmd) && inp) {
 				in_rtchange((struct inpcb *)inp,
@@ -539,14 +539,14 @@
 		}
 		splx(s);
 	}
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	return;
 #else
 	return (NULL);
 #endif
 }
 
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 static int
 sctp_getcred(SYSCTL_HANDLER_ARGS)
 {
@@ -556,7 +556,7 @@
 	struct sctp_tcb *stcb;
 	int error, s;
 
-#if __FreeBSD_version >= 500000
+#if __FreeBSD_version >= 500000 || defined(__DragonFly__)
 	error = suser(req->td);
 #else
 	error = suser(req->p);
@@ -590,12 +590,17 @@
 
 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, getcred, CTLTYPE_OPAQUE|CTLFLAG_RW,
 	    0, 0, sctp_getcred, "S,ucred", "Get the ucred of a SCTP connection");
-#endif /* #if defined(__FreeBSD__) */
+#endif /* #if defined(__FreeBSD__) || defined(__DragonFly__) */
 
 /*
  * sysctl definitions
  */
-#if defined(__FreeBSD__) || defined (__APPLE__)
+#if defined(__FreeBSD__) || defined (__APPLE__) || defined(__DragonFly__)
+
+SYSCTL_DECL(_net_inet);
+
+SYSCTL_NODE(_net_inet, OID_AUTO, sctp, CTLFLAG_RD, 0,
+	"sctp values");
 
 SYSCTL_INT(_net_inet_sctp, OID_AUTO, maxdgram, CTLFLAG_RW,
 	   &sctp_sendspace, 0, "Maximum outgoing SCTP buffer size");
@@ -720,6 +725,8 @@
 static int
 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
 sctp_attach(struct socket *so, int proto, struct thread *p)
+#elif defined(__DragonFly__)
+sctp_attach(struct socket *so, int proto, struct pru_attach_info *ai)
 #else
 sctp_attach(struct socket *so, int proto, struct proc *p)
 #endif
@@ -738,7 +745,7 @@
 		splx(s);
 		return EINVAL;
 	}
-	error = soreserve(so, sctp_sendspace, sctp_recvspace);
+	error = soreserve(so, sctp_sendspace, sctp_recvspace, NULL);
 	if (error) {
 		splx(s);
 		return error;
@@ -753,7 +760,7 @@
 
 	inp->sctp_flags &= ~SCTP_PCB_FLAGS_BOUND_V6;	/* I'm not v6! */
 	ip_inp = &inp->ip_inp.inp;
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	ip_inp->inp_vflag |= INP_IPV4;
 	ip_inp->inp_ip_ttl = ip_defttl;
 #else
@@ -779,7 +786,7 @@
 }
 
 static int
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 sctp_bind(struct socket *so, struct sockaddr *addr, struct thread *p)
 {
 #elif defined(__FreeBSD__) || defined(__APPLE__)
@@ -838,7 +845,7 @@
 }
 
 int
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 sctp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
 	  struct mbuf *control, struct thread *p);
 #else
@@ -847,7 +854,7 @@
 #endif
 
 int
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 sctp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
 	  struct mbuf *control, struct thread *p)
 {
@@ -924,7 +931,7 @@
 		inp->pkt_last = inp->pkt = m;
 	}
 	if (
-#if defined (__FreeBSD__) || defined(__APPLE__)
+#if defined (__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	    /* FreeBSD uses a flag passed */
 	    ((flags & PRUS_MORETOCOME) == 0)
 #elif defined( __NetBSD__)
@@ -995,7 +1002,7 @@
 					/* Left with Data unread */
 					struct mbuf *err;
 					err = NULL;
-					MGET(err, M_DONTWAIT, MT_DATA);
+					MGET(err, MB_DONTWAIT, MT_DATA);
 					if (err) {
 						/* Fill in the user initiated abort */
 						struct sctp_paramhdr *ph;
@@ -1444,7 +1451,7 @@
 sctp_do_connect_x(struct socket *so,
 		  struct sctp_inpcb *inp,
 		  struct mbuf *m,
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 		  struct thread *p,
 #else
   	          struct proc *p,
@@ -1643,7 +1650,7 @@
 sctp_optsget(struct socket *so,
 	     int opt,
 	     struct mbuf **mp,
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 	     struct thread *p
 #else
 	     struct proc *p
@@ -2704,7 +2711,7 @@
 sctp_optsset(struct socket *so,
 	     int opt,
 	     struct mbuf **mp,
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 	     struct thread *p
 #else
 	     struct proc *p
@@ -3593,7 +3600,7 @@
 }
 
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 int
 sctp_ctloutput(struct socket *so, struct sockopt *sopt)
 {
@@ -3632,9 +3639,9 @@
 	}
 	if (sopt->sopt_valsize) {
 
-		m = m_get(M_WAIT, MT_DATA);
+		m = m_get(MB_WAIT, MT_DATA);
 		if (sopt->sopt_valsize > MLEN) {
-			MCLGET(m, M_DONTWAIT);
+			MCLGET(m, MB_DONTWAIT);
 			if ((m->m_flags & M_EXT) == 0) {
 				sctp_m_freem(m);
 				splx(s);
@@ -3650,13 +3657,13 @@
 		m->m_len = sopt->sopt_valsize;
 	}
 	if (sopt->sopt_dir == SOPT_SET) {
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 		error = sctp_optsset(so, sopt->sopt_name, &m, sopt->sopt_td);
 #else
 		error = sctp_optsset(so, sopt->sopt_name, &m, sopt->sopt_p);
 #endif
 	} else if (sopt->sopt_dir == SOPT_GET) {
-#if defined (__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined (__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 		error = sctp_optsget(so, sopt->sopt_name, &m, sopt->sopt_td);
 #else
 		error = sctp_optsget(so, sopt->sopt_name, &m, sopt->sopt_p);
@@ -3757,7 +3764,7 @@
 #endif
 
 static int
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 sctp_connect(struct socket *so, struct sockaddr *addr, struct thread *p)
 {
 #else
@@ -4020,7 +4027,7 @@
 }
 
 int
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 sctp_listen(struct socket *so, struct thread *p)
 #else
 sctp_listen(struct socket *so, struct proc *p)
@@ -4034,6 +4041,7 @@
 	 * to the sys/kern/uipc_socket.c module to reverse this but this
 	 * MUST be in place if the socket API for SCTP is to work properly.
 	 */
+	printf("listenthingy\n");
 #if defined(__NetBSD__) || defined(__OpenBSD__)
 	int s = splsoftnet();
 #else
@@ -4069,6 +4077,7 @@
 	}
 	SOCK_LOCK(so);
 	SCTP_INP_WLOCK(inp);
+	printf("something: %d\n", inp->sctp_socket->so_qlimit);
 	if (inp->sctp_socket->so_qlimit) {
 		if (inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) {
 			/*
@@ -4077,6 +4086,7 @@
 			 * The TCP model (when present) will do accept which
 			 * then prohibits connect().
 			 */
+			printf("Dropping SO_ACCEPTCONN 2\n");
 			inp->sctp_socket->so_options &= ~SO_ACCEPTCONN;
 		}
 		inp->sctp_flags |= SCTP_PCB_FLAGS_ACCEPTING;
@@ -4088,6 +4098,7 @@
 			 */
 			inp->sctp_flags &= ~SCTP_PCB_FLAGS_ACCEPTING;
 		}
+		printf("Dropping SO_ACCEPTCONN\n");
 		inp->sctp_socket->so_options &= ~SO_ACCEPTCONN;
 	}
 	SCTP_INP_WUNLOCK(inp);
@@ -4097,7 +4108,7 @@
 }
 
 int
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 sctp_accept(struct socket *so, struct sockaddr **addr)
 {
 #else
@@ -4114,6 +4125,7 @@
 	struct sockaddr *prim;
 	struct sctp_inpcb *inp;
 
+	printf("hei hei\n");
 	inp = (struct sctp_inpcb *)so->so_pcb;
 
 	if (inp == 0) {
@@ -4137,7 +4149,7 @@
 	prim = (struct sockaddr *)&stcb->asoc.primary_destination->ro._l_addr;
 	if (prim->sa_family == AF_INET) {
 		struct sockaddr_in *sin;
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME,
 		       M_WAITOK | M_ZERO);
 #else
@@ -4148,14 +4160,14 @@
 		sin->sin_len = sizeof(*sin);
 		sin->sin_port = ((struct sockaddr_in *)prim)->sin_port;
 		sin->sin_addr = ((struct sockaddr_in *)prim)->sin_addr;
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		*addr = (struct sockaddr *)sin;
 #else
 		nam->m_len = sizeof(*sin);
 #endif
 	} else {
 		struct sockaddr_in6 *sin6;
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		MALLOC(sin6, struct sockaddr_in6 *, sizeof *sin6, M_SONAME,
 		       M_WAITOK | M_ZERO);
 #else
@@ -4172,7 +4184,7 @@
 			in6_recoverscope(sin6, &sin6->sin6_addr, NULL);  /* skip ifp check */
 		else
 			sin6->sin6_scope_id = 0;	/*XXX*/
-#if defined(__FreeBSD__) || defined (__APPLE__)
+#if defined(__FreeBSD__) || defined (__APPLE__) || defined(__DragonFly__)
 		*addr= (struct sockaddr *)sin6;
 #else
 		nam->m_len = sizeof(*sin6);
@@ -4206,13 +4218,13 @@
 }
 
 int
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 sctp_ingetaddr(struct socket *so, struct sockaddr **addr)
 #else
 sctp_ingetaddr(struct socket *so, struct mbuf *nam)
 #endif
 {
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	struct sockaddr_in *sin;
 #else
 	struct sockaddr_in *sin = mtod(nam, struct sockaddr_in *);
@@ -4222,7 +4234,7 @@
 	/*
 	 * Do the malloc first in case it blocks.
 	 */
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME, M_WAITOK |
 	       M_ZERO);
 #else
@@ -4239,7 +4251,7 @@
 	inp = (struct sctp_inpcb *)so->so_pcb;
 	if (!inp) {
 		splx(s);
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		FREE(sin, M_SONAME);
 #endif
 		return ECONNRESET;
@@ -4296,7 +4308,7 @@
 		}
 		if (!fnd) {
 			splx(s);
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 			FREE(sin, M_SONAME);
 #endif
 			SCTP_INP_RUNLOCK(inp);
@@ -4305,14 +4317,14 @@
 	}
 	SCTP_INP_RUNLOCK(inp);
 	splx(s);
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	(*addr) = (struct sockaddr *)sin;
 #endif
 	return (0);
 }
 
 int
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 sctp_peeraddr(struct socket *so, struct sockaddr **addr)
 {
 	struct sockaddr_in *sin = (struct sockaddr_in *)*addr;
@@ -4340,7 +4352,7 @@
 	s = splnet();
 #endif
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME, M_WAITOK |
 	       M_ZERO);
 #else
@@ -4354,7 +4366,7 @@
 	inp = (struct sctp_inpcb *)so->so_pcb;
 	if (!inp) {
 		splx(s);
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		FREE(sin, M_SONAME);
 #endif
 		return ECONNRESET;
@@ -4366,7 +4378,7 @@
 	SCTP_INP_RUNLOCK(inp);
 	if (stcb == NULL) {
 		splx(s);
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		FREE(sin, M_SONAME);
 #endif
 		return ECONNRESET;
@@ -4385,7 +4397,7 @@
 	if (!fnd) {
 		/* No IPv4 address */
 		splx(s);
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		FREE(sin, M_SONAME);
 #endif
 		return ENOENT;
@@ -4394,7 +4406,7 @@
 	return (0);
 }
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 struct pr_usrreqs sctp_usrreqs = {
 	sctp_abort,
 	sctp_accept,
diff -ur kame/netinet/sctp_var.h dfly/netinet/sctp_var.h
--- kame/netinet/sctp_var.h	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctp_var.h	2005-06-18 12:41:43.000000000 +0000
@@ -148,7 +148,7 @@
 
 #if defined(_KERNEL) || (defined(__APPLE__) && defined(KERNEL))
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 #ifdef SYSCTL_DECL
 SYSCTL_DECL(_net_inet_sctp);
 #endif
@@ -183,6 +183,10 @@
 void	sctp_ctlinput __P((int, struct sockaddr *, void *));
 int	sctp_ctloutput __P((struct socket *, struct sockopt *));
 void	sctp_input __P((struct mbuf *, int));
+#elif defined(__DragonFly__)
+void	sctp_ctlinput __P((int, struct sockaddr *, void *));
+int	sctp_ctloutput __P((struct socket *, struct sockopt *));
+void	sctp_input __P((struct mbuf *, ... ));
 #else
 void*	sctp_ctlinput __P((int, struct sockaddr *, void *));
 int	sctp_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
@@ -212,7 +216,7 @@
 
 
 int sctp_ingetaddr(struct socket *,
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		   struct sockaddr **
 #else
 		   struct mbuf *
@@ -220,20 +224,20 @@
 );
 
 int sctp_peeraddr(struct socket *,
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		  struct sockaddr **
 #else
 		  struct mbuf *
 #endif
 );
 
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 int sctp_listen(struct socket *, struct thread *);
 #else
 int sctp_listen(struct socket *, struct proc *);
 #endif
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 int sctp_accept(struct socket *, struct sockaddr **);
 #else
 int sctp_accept(struct socket *, struct mbuf *);
diff -ur kame/netinet/sctputil.c dfly/netinet/sctputil.c
--- kame/netinet/sctputil.c	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctputil.c	2005-06-18 12:41:43.000000000 +0000
@@ -35,13 +35,13 @@
 #if !(defined(__OpenBSD__) || defined(__APPLE__))
 #include "opt_ipsec.h"
 #endif
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include "opt_compat.h"
 #include "opt_inet6.h"
 #include "opt_inet.h"
-#ifndef SCTP_BASE_FREEBSD
+#if !(defined(SCTP_BASE_FREEBSD) || defined(__DragonFly__))
 #include "opt_mpath.h"
-#endif /* SCTP_BASE_FREEBSD */
+#endif /* SCTP_BASE_FREEBSD || __DragonFly__ */
 #endif /* FreeBSD */
 #if defined(__NetBSD__)
 #include "opt_inet.h"
@@ -64,7 +64,7 @@
 #include <sys/kernel.h>
 #include <sys/sysctl.h>
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include <sys/callout.h>
 #else
 #include <netinet/sctp_callout.h>	/* for callout_active() */
@@ -100,7 +100,7 @@
 #include <netinet/ip6.h>
 #include <netinet6/ip6_var.h>
 
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined(__DragonFly_)
 #include <netinet6/in6_pcb.h>
 #elif defined(__OpenBSD__)
 #include <netinet/in_pcb.h>
@@ -2066,7 +2066,7 @@
 	} else {
 		/* Hard way we must grow the mbuf */
 		struct mbuf *tmp;
-		MGET(tmp, M_DONTWAIT, MT_DATA);
+		MGET(tmp, MB_DONTWAIT, MT_DATA);
 		if (tmp == NULL) {
 			/* Out of space GAK! we are in big trouble. */
 			return (ENOSPC);
@@ -2140,7 +2140,7 @@
 		/* event not enabled */
 		return;
 	}
-	MGETHDR(m_notify, M_DONTWAIT, MT_DATA);
+	MGETHDR(m_notify, MB_DONTWAIT, MT_DATA);
 	if (m_notify == NULL)
 		/* no space left */
 		return;
@@ -2226,12 +2226,12 @@
 		/* event not enabled */
 		return;
 
-	MGETHDR(m_notify, M_DONTWAIT, MT_DATA);
+	MGETHDR(m_notify, MB_DONTWAIT, MT_DATA);
 	if (m_notify == NULL)
 		return;
 	m_notify->m_len = 0;
 
-	MCLGET(m_notify, M_DONTWAIT);
+	MCLGET(m_notify, MB_DONTWAIT);
 	if ((m_notify->m_flags & M_EXT) != M_EXT) {
 		sctp_m_freem(m_notify);
 		return;
@@ -2319,7 +2319,7 @@
 		return;
 
 	length = sizeof(struct sctp_send_failed) + chk->send_size;
-	MGETHDR(m_notify, M_DONTWAIT, MT_DATA);
+	MGETHDR(m_notify, MB_DONTWAIT, MT_DATA);
 	if (m_notify == NULL)
 		/* no space left */
 		return;
@@ -2417,7 +2417,7 @@
 		/* event not enabled */
 		return;
 
-	MGETHDR(m_notify, M_DONTWAIT, MT_DATA);
+	MGETHDR(m_notify, MB_DONTWAIT, MT_DATA);
 	if (m_notify == NULL)
 		/* no space left */
 		return;
@@ -2493,7 +2493,7 @@
 		/* event not enabled */
 		return;
 
-	MGETHDR(m_notify, M_DONTWAIT, MT_DATA);
+	MGETHDR(m_notify, MB_DONTWAIT, MT_DATA);
 	if (m_notify == NULL)
 		/* no space left */
 		return;
@@ -2579,7 +2579,7 @@
 		/* event not enabled */
 		return;
 
-	MGETHDR(m_notify, M_DONTWAIT, MT_DATA);
+	MGETHDR(m_notify, MB_DONTWAIT, MT_DATA);
 	if (m_notify == NULL)
 		/* no space left */
 		return;
@@ -2655,14 +2655,14 @@
 		/* event not enabled */
 		return;
 
-	MGETHDR(m_notify, M_DONTWAIT, MT_DATA);
+	MGETHDR(m_notify, MB_DONTWAIT, MT_DATA);
 	if (m_notify == NULL)
 		/* no space left */
 		return;
 	m_notify->m_len = 0;
 	len = sizeof(struct sctp_stream_reset_event) + (number_entries * sizeof(uint16_t));
 	if (len > M_TRAILINGSPACE(m_notify)) {
-		MCLGET(m_notify, M_WAIT);
+		MCLGET(m_notify, MB_WAIT);
 	}
 	if (m_notify == NULL)
 		/* no clusters */
@@ -3270,7 +3270,7 @@
 	}
 	if (((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) == 0) ||
 	    ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)== 0)) {
-		MGETHDR(m, M_DONTWAIT, MT_SONAME);
+		MGETHDR(m, MB_DONTWAIT, MT_SONAME);
 		if (m == 0)
 			return (0);
 		m->m_len = 0;
@@ -3318,7 +3318,7 @@
 	}
 	return (1);
 #endif
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	struct mbuf *m, *n, *nlast;
 	int cnt=0;
 
@@ -3333,8 +3333,8 @@
 	    ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)== 0)) {
 		if (asa->sa_len > MHLEN)
 			return (0);
- try_again:
-		MGETHDR(m, M_DONTWAIT, MT_SONAME);
+try_again:
+		MGETHDR(m, MB_DONTWAIT, MT_SONAME);
 		if (m == 0)
 			return (0);
 		m->m_len = 0;
@@ -3372,11 +3372,11 @@
 		inp->sctp_vtag_first = tag;
 	}
 
-#ifdef __FREEBSD__
+#if defined(__FREEBSD__)
 	if (sb->sb_mb == NULL)
 		inp->sctp_vtag_first = tag;
 	SCTP_SBLINKRECORD(sb, m);
-	sb->sb_mbtail = nlast;
+	sb->sb_lastrecord = nlast;
 #else
 	if ((n = sb->sb_mb) != NULL) {
 		if ((n->m_nextpkt != inp->sb_last_mpkt) && (n->m_nextpkt == NULL)) {
@@ -3413,7 +3413,7 @@
 	    ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)== 0)) {
 		if (asa->sa_len > MHLEN)
 			return (0);
-		MGETHDR(m, M_DONTWAIT, MT_SONAME);
+		MGETHDR(m, MB_DONTWAIT, MT_SONAME);
 		if (m == 0)
 			return (0);
 		m->m_len = asa->sa_len;
@@ -3465,7 +3465,7 @@
 	/* Return a MBUF with a invalid mandatory parameter */
 	struct mbuf *m;
 
-	MGET(m, M_DONTWAIT, MT_DATA);
+	MGET(m, MB_DONTWAIT, MT_DATA);
 	if (m) {
 		struct sctp_paramhdr *ph;
 		m->m_len = sizeof(struct sctp_paramhdr);
diff -ur kame/netinet/sctputil.h dfly/netinet/sctputil.h
--- kame/netinet/sctputil.h	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet/sctputil.h	2005-06-18 12:41:43.000000000 +0000
@@ -57,7 +57,7 @@
  * size = size of each zone/pool element
  * number = number of elements in zone/pool
  */
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #if __FreeBSD_version >= 500000
 #include <vm/uma.h>
 #else
@@ -68,7 +68,7 @@
 #endif
 
 /* SCTP_ZONE_INIT: initialize the zone */
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #if __FreeBSD_version >= 500000
 #define UMA_ZFLAG_FULL	0x0020
 #define SCTP_ZONE_INIT(zone, name, size, number) { \
@@ -100,6 +100,9 @@
 #define SCTP_ZONE_GET(zone) \
 	zalloci(zone);
 #endif
+#elif defined(__DragonFly__)
+#define SCTP_ZONE_GET(zone) \
+		zalloc(zone);
 #elif defined(__APPLE__)
 #define SCTP_ZONE_GET(zone) \
 	zalloc(zone);
@@ -120,6 +123,9 @@
 #define SCTP_ZONE_FREE(zone, element) \
 	zfreei(zone, element);
 #endif
+#elif defined(__DragonFly__)
+#define SCTP_ZONE_FREE(zone, element) \
+	zfree(zone, element);
 #elif defined(__APPLE__)
 #define SCTP_ZONE_FREE(zone, element) \
 	zfree(zone, element);
@@ -250,7 +256,7 @@
 
 #endif
 
-#ifdef SCTP_BASE_FREEBSD
+#if defined(SCTP_BASE_FREEBSD) || defined(__DragonFly__)
 /* Note: these are in <sys/time.h>, but not in kernel space */
 #define	timerclear(tvp)		(tvp)->tv_sec = (tvp)->tv_usec = 0
 #define	timerisset(tvp)		((tvp)->tv_sec || (tvp)->tv_usec)
diff -ur kame/netinet6/sctp6_usrreq.c dfly/netinet6/sctp6_usrreq.c
--- kame/netinet6/sctp6_usrreq.c	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet6/sctp6_usrreq.c	2005-06-18 12:41:43.000000000 +0000
@@ -34,7 +34,7 @@
 #if !(defined(__OpenBSD__) || defined(__APPLE__))
 #include "opt_inet.h"
 #endif
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include "opt_inet6.h"
 #include "opt_inet.h"
 #endif
@@ -106,7 +106,7 @@
 
 extern struct protosw inetsw[];
 
-#if defined(HAVE_NRL_INPCB) || defined(__FreeBSD__)
+#if defined(HAVE_NRL_INPCB) || defined(__FreeBSD__) || defined(__DragonFly__)
 #ifndef in6pcb
 #define in6pcb		inpcb
 #endif
@@ -121,7 +121,7 @@
 
 static	int sctp6_detach __P((struct socket *so));
 
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 extern void in6_sin_2_v4mapsin6 (struct sockaddr_in *sin,
 				 struct sockaddr_in6 *sin6);
 extern void in6_sin6_2_sin (struct sockaddr_in *,
@@ -418,8 +418,9 @@
 	    || (in6p->sctp_socket->so_options & SO_TIMESTAMP)
 #endif
 	    ) {
-#if defined(__FreeBSD__) || defined(__APPLE__)
-#if (defined(SCTP_BASE_FREEBSD) && __FreeBSD_version < 501113) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
+#if (defined(SCTP_BASE_FREEBSD) && __FreeBSD_version < 501113) || \
+    defined(__APPLE__) || defined(__DragonFly__)
 		ip6_savecontrol(in6p_ip, &opts, ip6, m);
 #elif __FreeBSD_version >= 440000 || (defined(SCTP_BASE_FREEBSD) && __FreeBSD_version >= 501113)
 		ip6_savecontrol(in6p_ip, m, &opts);
@@ -765,6 +766,8 @@
 static int
 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
 sctp6_attach(struct socket *so, int proto, struct thread *p)
+#elif defined(__DragonFly__)
+sctp6_attach(struct socket *so, int proto, struct pru_attach_info *ai)
 #else
 sctp6_attach(struct socket *so, int proto, struct proc *p)
 #endif
@@ -778,7 +781,7 @@
 		return EINVAL;
 
 	if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
-		error = soreserve(so, sctp_sendspace, sctp_recvspace);
+		error = soreserve(so, sctp_sendspace, sctp_recvspace, NULL);
 		if (error)
 			return error;
 	}
@@ -795,7 +798,7 @@
 	inp->sctp_flags |= SCTP_PCB_FLAGS_BOUND_V6;	/* I'm v6! */
 	inp6 = (struct in6pcb *)inp;
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	inp6->inp_vflag |= INP_IPV6;
 #else
 #if defined(__OpenBSD__)
@@ -819,7 +822,7 @@
 	 * because the socket may be bound to an IPv6 wildcard address,
 	 * which may match an IPv4-mapped IPv6 address.
 	 */
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	inp6->inp_ip_ttl = ip_defttl;
 #else
 	inp->inp_ip_ttl = ip_defttl;
@@ -833,7 +836,7 @@
 }
 
 static int
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 sctp6_bind(struct socket *so, struct sockaddr *addr, struct thread *p)
 {
 #else
@@ -855,7 +858,7 @@
 		return EINVAL;
 
 	inp6 = (struct in6pcb *)inp;
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	inp6->inp_vflag &= ~INP_IPV4;
 	inp6->inp_vflag |= INP_IPV6;
 #else
@@ -878,7 +881,7 @@
 	     == 0) {
 		if (addr->sa_family == AF_INET) {
 			/* binding v4 addr to v6 socket, so reset flags */
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 			inp6->inp_vflag |= INP_IPV4;
 			inp6->inp_vflag &= ~INP_IPV6;
 #else
@@ -895,7 +898,7 @@
 			sin6_p = (struct sockaddr_in6 *)addr;
 
 			if (IN6_IS_ADDR_UNSPECIFIED(&sin6_p->sin6_addr)) {
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 			  inp6->inp_vflag |= INP_IPV4;
 #else
 #if defined(__OpenBSD__)
@@ -908,7 +911,7 @@
 			else if (IN6_IS_ADDR_V4MAPPED(&sin6_p->sin6_addr)) {
 				struct sockaddr_in sin;
 				in6_sin6_2_sin(&sin, sin6_p);
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 				inp6->inp_vflag |= INP_IPV4;
 				inp6->inp_vflag &= ~INP_IPV6;
 #else
@@ -1075,7 +1078,7 @@
 }
 
 int
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 sctp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
 	  struct mbuf *control, struct thread *p);
 #else
@@ -1085,7 +1088,7 @@
 
 
 static int
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 sctp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
 	   struct mbuf *control, struct thread *p)
 {
@@ -1204,7 +1207,7 @@
 		inp->pkt_last = inp->pkt = m;
 	}
 	if (
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	    /* FreeBSD and MacOSX uses a flag passed */
 	    ((flags & PRUS_MORETOCOME) == 0)
 #elif defined(__NetBSD__)
@@ -1232,7 +1235,7 @@
 }
 
 static int
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
+#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
 sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p)
 {
 #else
@@ -1384,7 +1387,7 @@
 }
 
 static int
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 sctp6_getaddr(struct socket *so, struct sockaddr **addr)
 {
 	struct sockaddr_in6 *sin6;
@@ -1397,7 +1400,7 @@
 	/*
 	 * Do the malloc first in case it blocks.
 	 */
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	MALLOC(sin6, struct sockaddr_in6 *, sizeof *sin6, M_SONAME,
 	       M_WAITOK | M_ZERO);
 #else
@@ -1409,7 +1412,7 @@
 
 	inp = (struct sctp_inpcb *)so->so_pcb;
 	if (!inp) {
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		FREE(sin6, M_SONAME);
 #endif
 		return ECONNRESET;
@@ -1463,7 +1466,7 @@
 			}
 		}
 		if (!fnd) {
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 			FREE(sin6, M_SONAME);
 #endif
 			return ENOENT;
@@ -1475,14 +1478,14 @@
 		in6_recoverscope(sin6, &sin6->sin6_addr, NULL);
 	else
 		sin6->sin6_scope_id = 0;	/*XXX*/
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	(*addr) = (struct sockaddr *)sin6;
 #endif
 	return (0);
 }
 
 static int
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 sctp6_peeraddr(struct socket *so, struct sockaddr **addr)
 {
 	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)*addr;
@@ -1504,7 +1507,7 @@
 		/* UDP type and listeners will drop out here */
 		return (ENOTCONN);
 	}
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	MALLOC(sin6, struct sockaddr_in6 *, sizeof *sin6, M_SONAME,
 	       M_WAITOK | M_ZERO);
 #else
@@ -1517,14 +1520,14 @@
 	/* We must recapture incase we blocked */
 	inp = (struct sctp_inpcb *)so->so_pcb;
 	if (!inp) {
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		FREE(sin6, M_SONAME);
 #endif
 		return ECONNRESET;
 	}
 	stcb = LIST_FIRST(&inp->sctp_asoc_list);
 	if (stcb == NULL) {
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		FREE(sin6, M_SONAME);
 #endif
 		return ECONNRESET;
@@ -1541,20 +1544,20 @@
 	}
 	if (!fnd) {
 		/* No IPv4 address */
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		FREE(sin6, M_SONAME);
 #endif
 		return ENOENT;
 	}
 	in6_recoverscope(sin6, &sin6->sin6_addr, NULL);
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 	*addr = (struct sockaddr *)sin6;
 #endif
 	return (0);
 }
 
 static int
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 sctp6_in6getaddr(struct socket *so, struct sockaddr **nam)
 {
 	struct sockaddr *addr;
@@ -1583,7 +1586,7 @@
 			splx(s);
 			return (error);
 		}
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 		addr = *nam;
 #endif
 		/* if I'm V6ONLY, convert it to v4-mapped */
@@ -1599,15 +1602,15 @@
 			struct sockaddr_in6 sin6;
 			in6_sin_2_v4mapsin6((struct sockaddr_in *)addr, &sin6);
 			memcpy(addr, &sin6, sizeof(struct sockaddr_in6));
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 			nam->m_len = sizeof(sin6);
 #endif
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 		} else {
 			nam->m_len = sizeof(struct sockaddr_in);
 #endif
 		}
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 	} else {
 		nam->m_len = sizeof(struct sockaddr_in6);
 #endif
@@ -1618,7 +1621,7 @@
 
 
 static int
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 sctp6_getpeeraddr(struct socket *so, struct sockaddr **nam)
 {
 	struct sockaddr *addr = *nam;
@@ -1660,15 +1663,15 @@
 			struct sockaddr_in6 sin6;
 			in6_sin_2_v4mapsin6((struct sockaddr_in *)addr, &sin6);
 			memcpy(addr, &sin6, sizeof(struct sockaddr_in6));
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 			nam->m_len = sizeof(sin6);
 #endif
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 		} else {
 			nam->m_len = sizeof(struct sockaddr_in);
 #endif
 		}
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
 	} else {
 		nam->m_len = sizeof(struct sockaddr_in6);
 #endif
@@ -1677,7 +1680,7 @@
 	return error;
 }
 
-#if defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
 struct pr_usrreqs sctp6_usrreqs = {
 	sctp6_abort, sctp_accept, sctp6_attach, sctp6_bind,
 	sctp6_connect, pru_connect2_notsupp, in6_control,
diff -ur kame/netinet6/sctp6_var.h dfly/netinet6/sctp6_var.h
--- kame/netinet6/sctp6_var.h	2005-06-18 12:42:56.000000000 +0000
+++ dfly/netinet6/sctp6_var.h	2005-06-18 12:41:43.000000000 +0000
@@ -36,7 +36,7 @@
 
 #if defined(_KERNEL) || (defined(__APPLE__) && defined(KERNEL))
 
-#if defined(__FreeBSD__) || (__APPLE__)
+#if defined(__FreeBSD__) || (__APPLE__) || defined(__DragonFly__)
 SYSCTL_DECL(_net_inet6_sctp6);
 extern struct pr_usrreqs sctp6_usrreqs;
 int	sctp6_ctloutput __P((struct socket *, struct sockopt *));
@@ -49,7 +49,7 @@
 int	sctp6_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *,
 			   struct mbuf *));
 #endif /* __NetBSD__ || __OpenBSD__ */
-#endif /* __FreeBSD__ */
+#endif /* __FreeBSD__ || __APPLE__ || __DragonFly__ */
 
 #if defined(__APPLE__)
 int	sctp6_input __P((struct mbuf **, int *));
