From 0152a779a13f106b856848171ff5b848540803a7 Mon Sep 17 00:00:00 2001
From: bms <bms@FreeBSD.org>
Date: Fri, 14 Nov 2003 16:33:33 +0000
Subject: Add mcl 2.99, implementation of the ALC and NORM Reliable Multicast
 Protocols.

PR:		58728
Submitted by:	past@noc.ntua.gr
---
 mbone/Makefile                                  |  1 +
 mbone/mcl/Makefile                              | 53 +++++++++++++++++++++++++
 mbone/mcl/distinfo                              |  1 +
 mbone/mcl/files/patch-Makefile                  | 13 ++++++
 mbone/mcl/files/patch-Makefile.common           | 33 +++++++++++++++
 mbone/mcl/files/patch-alc-Makefile              | 16 ++++++++
 mbone/mcl/files/patch-check-alc-Makefile        | 21 ++++++++++
 mbone/mcl/files/patch-fcast-Makefile            | 28 +++++++++++++
 mbone/mcl/files/patch-fcast.h                   | 20 ++++++++++
 mbone/mcl/files/patch-mcl_debug.cpp             | 11 +++++
 mbone/mcl/files/patch-mcl_includes.h            | 36 +++++++++++++++++
 mbone/mcl/files/patch-mcl_lib.cpp               | 14 +++++++
 mbone/mcl/files/patch-mcl_network.cpp           | 48 ++++++++++++++++++++++
 mbone/mcl/files/patch-mcl_osdep.h               | 32 +++++++++++++++
 mbone/mcl/files/patch-robcast-Makefile          | 19 +++++++++
 mbone/mcl/files/patch-test_abort.c              | 13 ++++++
 mbone/mcl/files/patch-test_demux_label1_rx.c    | 13 ++++++
 mbone/mcl/files/patch-test_demux_label1_tx.c    | 13 ++++++
 mbone/mcl/files/patch-test_dyn_tsi.c            | 13 ++++++
 mbone/mcl/files/patch-test_multi_sessions1.c    | 14 +++++++
 mbone/mcl/files/patch-test_multi_sessions2.c    | 14 +++++++
 mbone/mcl/files/patch-test_no_tx.c              | 13 ++++++
 mbone/mcl/files/patch-test_rebootable_client.c  | 13 ++++++
 mbone/mcl/files/patch-test_seq_of_tx_sessions.c | 14 +++++++
 mbone/mcl/files/patch-test_several_fec_codecs.c | 13 ++++++
 mbone/mcl/files/patch-test_vtm_rx.c             | 13 ++++++
 mbone/mcl/files/patch-test_vtm_tx.c             | 13 ++++++
 mbone/mcl/files/patch-test_wait_rx_receiver.c   | 12 ++++++
 mbone/mcl/files/patch-test_wait_rx_sender.c     | 12 ++++++
 mbone/mcl/files/patch-test_wait_tx.c            | 13 ++++++
 mbone/mcl/pkg-descr                             | 14 +++++++
 mbone/mcl/pkg-plist                             |  4 ++
 net/mcl/Makefile                                | 53 +++++++++++++++++++++++++
 net/mcl/distinfo                                |  1 +
 net/mcl/files/patch-Makefile                    | 13 ++++++
 net/mcl/files/patch-Makefile.common             | 33 +++++++++++++++
 net/mcl/files/patch-alc-Makefile                | 16 ++++++++
 net/mcl/files/patch-check-alc-Makefile          | 21 ++++++++++
 net/mcl/files/patch-fcast-Makefile              | 28 +++++++++++++
 net/mcl/files/patch-fcast.h                     | 20 ++++++++++
 net/mcl/files/patch-mcl_debug.cpp               | 11 +++++
 net/mcl/files/patch-mcl_includes.h              | 36 +++++++++++++++++
 net/mcl/files/patch-mcl_lib.cpp                 | 14 +++++++
 net/mcl/files/patch-mcl_network.cpp             | 48 ++++++++++++++++++++++
 net/mcl/files/patch-mcl_osdep.h                 | 32 +++++++++++++++
 net/mcl/files/patch-robcast-Makefile            | 19 +++++++++
 net/mcl/files/patch-test_abort.c                | 13 ++++++
 net/mcl/files/patch-test_demux_label1_rx.c      | 13 ++++++
 net/mcl/files/patch-test_demux_label1_tx.c      | 13 ++++++
 net/mcl/files/patch-test_dyn_tsi.c              | 13 ++++++
 net/mcl/files/patch-test_multi_sessions1.c      | 14 +++++++
 net/mcl/files/patch-test_multi_sessions2.c      | 14 +++++++
 net/mcl/files/patch-test_no_tx.c                | 13 ++++++
 net/mcl/files/patch-test_rebootable_client.c    | 13 ++++++
 net/mcl/files/patch-test_seq_of_tx_sessions.c   | 14 +++++++
 net/mcl/files/patch-test_several_fec_codecs.c   | 13 ++++++
 net/mcl/files/patch-test_vtm_rx.c               | 13 ++++++
 net/mcl/files/patch-test_vtm_tx.c               | 13 ++++++
 net/mcl/files/patch-test_wait_rx_receiver.c     | 12 ++++++
 net/mcl/files/patch-test_wait_rx_sender.c       | 12 ++++++
 net/mcl/files/patch-test_wait_tx.c              | 13 ++++++
 net/mcl/pkg-descr                               | 14 +++++++
 net/mcl/pkg-plist                               |  4 ++
 63 files changed, 1119 insertions(+)
 create mode 100644 mbone/mcl/Makefile
 create mode 100644 mbone/mcl/distinfo
 create mode 100644 mbone/mcl/files/patch-Makefile
 create mode 100644 mbone/mcl/files/patch-Makefile.common
 create mode 100644 mbone/mcl/files/patch-alc-Makefile
 create mode 100644 mbone/mcl/files/patch-check-alc-Makefile
 create mode 100644 mbone/mcl/files/patch-fcast-Makefile
 create mode 100644 mbone/mcl/files/patch-fcast.h
 create mode 100644 mbone/mcl/files/patch-mcl_debug.cpp
 create mode 100644 mbone/mcl/files/patch-mcl_includes.h
 create mode 100644 mbone/mcl/files/patch-mcl_lib.cpp
 create mode 100644 mbone/mcl/files/patch-mcl_network.cpp
 create mode 100644 mbone/mcl/files/patch-mcl_osdep.h
 create mode 100644 mbone/mcl/files/patch-robcast-Makefile
 create mode 100644 mbone/mcl/files/patch-test_abort.c
 create mode 100644 mbone/mcl/files/patch-test_demux_label1_rx.c
 create mode 100644 mbone/mcl/files/patch-test_demux_label1_tx.c
 create mode 100644 mbone/mcl/files/patch-test_dyn_tsi.c
 create mode 100644 mbone/mcl/files/patch-test_multi_sessions1.c
 create mode 100644 mbone/mcl/files/patch-test_multi_sessions2.c
 create mode 100644 mbone/mcl/files/patch-test_no_tx.c
 create mode 100644 mbone/mcl/files/patch-test_rebootable_client.c
 create mode 100644 mbone/mcl/files/patch-test_seq_of_tx_sessions.c
 create mode 100644 mbone/mcl/files/patch-test_several_fec_codecs.c
 create mode 100644 mbone/mcl/files/patch-test_vtm_rx.c
 create mode 100644 mbone/mcl/files/patch-test_vtm_tx.c
 create mode 100644 mbone/mcl/files/patch-test_wait_rx_receiver.c
 create mode 100644 mbone/mcl/files/patch-test_wait_rx_sender.c
 create mode 100644 mbone/mcl/files/patch-test_wait_tx.c
 create mode 100644 mbone/mcl/pkg-descr
 create mode 100644 mbone/mcl/pkg-plist
 create mode 100644 net/mcl/Makefile
 create mode 100644 net/mcl/distinfo
 create mode 100644 net/mcl/files/patch-Makefile
 create mode 100644 net/mcl/files/patch-Makefile.common
 create mode 100644 net/mcl/files/patch-alc-Makefile
 create mode 100644 net/mcl/files/patch-check-alc-Makefile
 create mode 100644 net/mcl/files/patch-fcast-Makefile
 create mode 100644 net/mcl/files/patch-fcast.h
 create mode 100644 net/mcl/files/patch-mcl_debug.cpp
 create mode 100644 net/mcl/files/patch-mcl_includes.h
 create mode 100644 net/mcl/files/patch-mcl_lib.cpp
 create mode 100644 net/mcl/files/patch-mcl_network.cpp
 create mode 100644 net/mcl/files/patch-mcl_osdep.h
 create mode 100644 net/mcl/files/patch-robcast-Makefile
 create mode 100644 net/mcl/files/patch-test_abort.c
 create mode 100644 net/mcl/files/patch-test_demux_label1_rx.c
 create mode 100644 net/mcl/files/patch-test_demux_label1_tx.c
 create mode 100644 net/mcl/files/patch-test_dyn_tsi.c
 create mode 100644 net/mcl/files/patch-test_multi_sessions1.c
 create mode 100644 net/mcl/files/patch-test_multi_sessions2.c
 create mode 100644 net/mcl/files/patch-test_no_tx.c
 create mode 100644 net/mcl/files/patch-test_rebootable_client.c
 create mode 100644 net/mcl/files/patch-test_seq_of_tx_sessions.c
 create mode 100644 net/mcl/files/patch-test_several_fec_codecs.c
 create mode 100644 net/mcl/files/patch-test_vtm_rx.c
 create mode 100644 net/mcl/files/patch-test_vtm_tx.c
 create mode 100644 net/mcl/files/patch-test_wait_rx_receiver.c
 create mode 100644 net/mcl/files/patch-test_wait_rx_sender.c
 create mode 100644 net/mcl/files/patch-test_wait_tx.c
 create mode 100644 net/mcl/pkg-descr
 create mode 100644 net/mcl/pkg-plist

diff --git a/mbone/Makefile b/mbone/Makefile
index 513f115af582..1b53a7d3ee92 100644
--- a/mbone/Makefile
+++ b/mbone/Makefile
@@ -2,6 +2,7 @@
 #
 
     SUBDIR += imm
+    SUBDIR += mcl
     SUBDIR += nte
     SUBDIR += rat
     SUBDIR += rat30
diff --git a/mbone/mcl/Makefile b/mbone/mcl/Makefile
new file mode 100644
index 000000000000..a6f7052421b1
--- /dev/null
+++ b/mbone/mcl/Makefile
@@ -0,0 +1,53 @@
+# New ports collection makefile for:   mcl
+# Date created:        29 October 2003
+# Whom:                past@noc.ntua.gr
+#
+# $FreeBSD$
+#
+
+PORTNAME=	mcl
+PORTVERSION=	2.99
+CATEGORIES=	mbone net
+MASTER_SITES=	http://www.inrialpes.fr/planete/people/roca/mcl/bin/
+DISTNAME=	mcl_v2.99
+EXTRACT_SUFX=	.tgz
+
+MAINTAINER=	past@noc.ntua.gr
+COMMENT=	Implementation of the ALC and NORM Reliable Multicast Protocols
+
+USE_GMAKE=	yes
+MAN1=		fcast.1 fcastn.1 mclrecv2.1 mclsend2.1
+MAN2=		mcl_abort.2 mcl_close.2 mcl_ctl.2 mcl_open.2 mcl_recv.2 \
+		mcl_send.2 mcl_wait_event.2
+WRKSRC=		${WRKDIR}/mcl_v2.99_src
+
+pre-patch:
+	@cd ${WRKSRC} &&  \
+		${MKDIR} bin/freebsd
+
+do-install:
+	${INSTALL_PROGRAM} ${WRKSRC}/bin/freebsd/fcast ${PREFIX}/bin
+	${INSTALL_PROGRAM} ${WRKSRC}/bin/freebsd/robcast_client ${PREFIX}/bin
+	${INSTALL_PROGRAM} ${WRKSRC}/bin/freebsd/robcast_server ${PREFIX}/bin
+	${INSTALL_DATA} ${WRKSRC}/bin/freebsd/libmclalc.a ${PREFIX}/lib
+	${INSTALL_MAN} ${WRKSRC}/man/fcast.man.1 ${PREFIX}/man/man1/fcast.1
+	${INSTALL_MAN} ${WRKSRC}/man/fcastn.man.1 ${PREFIX}/man/man1/fcastn.1
+	${INSTALL_MAN} ${WRKSRC}/man/mclrecv2.man.1 \
+		${PREFIX}/man/man1/mclrecv2.1
+	${INSTALL_MAN} ${WRKSRC}/man/mclsend2.man.1 \
+		${PREFIX}/man/man1/mclsend2.1
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_abort.man.2 \
+		${PREFIX}/man/man2/mcl_abort.2
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_close.man.2 \
+		${PREFIX}/man/man2/mcl_close.2
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_ctl.man.2 ${PREFIX}/man/man2/mcl_ctl.2
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_open.man.2 \
+		${PREFIX}/man/man2/mcl_open.2
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_recv.man.2 \
+		${PREFIX}/man/man2/mcl_recv.2
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_send.man.2 \
+		${PREFIX}/man/man2/mcl_send.2
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_wait_event.man.2 \
+		${PREFIX}/man/man2/mcl_wait_event.2
+
+.include <bsd.port.mk>
diff --git a/mbone/mcl/distinfo b/mbone/mcl/distinfo
new file mode 100644
index 000000000000..374107be22a4
--- /dev/null
+++ b/mbone/mcl/distinfo
@@ -0,0 +1 @@
+MD5 (mcl_v2.99.tgz) = d492d3df5b88ca563d0f484ce63f31f4
diff --git a/mbone/mcl/files/patch-Makefile b/mbone/mcl/files/patch-Makefile
new file mode 100644
index 000000000000..b557dae141b1
--- /dev/null
+++ b/mbone/mcl/files/patch-Makefile
@@ -0,0 +1,13 @@
+--- Makefile.orig	Tue Jul 22 19:37:39 2003
++++ Makefile	Tue Oct 14 11:55:56 2003
+@@ -5,8 +5,8 @@
+ # We need the GNU make tool, on some systems it is called
+ # gmake, on others make is an alias to gmake. Choose one...
+ #
+-MAKE = make
+-#MAKE = gmake
++#MAKE = make
++MAKE = gmake
+ 
+ 
+ # A phony target is one that is not really the name of a file.
diff --git a/mbone/mcl/files/patch-Makefile.common b/mbone/mcl/files/patch-Makefile.common
new file mode 100644
index 000000000000..2277615cfabd
--- /dev/null
+++ b/mbone/mcl/files/patch-Makefile.common
@@ -0,0 +1,33 @@
+--- Makefile.common.orig	Tue Jul 22 19:37:39 2003
++++ Makefile.common	Tue Oct 14 15:04:38 2003
+@@ -24,11 +24,15 @@
+ ifeq (${SYSTEM},SunOS)
+ 	OS = solaris
+ endif
++ifeq (${SYSTEM},FreeBSD)
++	OS = freebsd
++endif
+ #
+ # and the old way (e.g. if the above lines do not work!)
+ #
+ #OS = linux
+ #OS = solaris
++#OS = freebsd
+ 
+ 
+ # Do you want/need extended memory debugging?
+@@ -59,6 +63,14 @@
+ 	#
+ 	CC = /opt/SUNWspro/bin/CC
+ 	LD = /opt/SUNWspro/bin/CC 
++endif
++ifeq (${OS},freebsd)
++	OSFLAGS = -DFREEBSD -I/usr/include/g++
++	# Which compiler?
++	# NB: use -Wall for compilation warnings with gcc
++	#
++	CC = g++ -Wall
++	LD = g++ -Wall
+ endif
+ 
+ 
diff --git a/mbone/mcl/files/patch-alc-Makefile b/mbone/mcl/files/patch-alc-Makefile
new file mode 100644
index 000000000000..b38cb525c35f
--- /dev/null
+++ b/mbone/mcl/files/patch-alc-Makefile
@@ -0,0 +1,16 @@
+--- src/alc/Makefile.orig	Tue Jul 22 19:42:18 2003
++++ src/alc/Makefile	Wed Oct 15 17:21:25 2003
+@@ -36,6 +36,13 @@
+ 	LIBRARIES = -lc -lm -lsocket -lnsl -L/usr/ucblib -lucb -lpthread
+ endif
+ 
++ifeq (${OS},freebsd)
++	# FreeBSD version
++	BINDIR = ../../bin/freebsd
++	LDPC_BINDIR = ../../../ldpc/bin/freebsd
++	LIBRARIES = -lm -pthread
++endif
++
+ 
+ ###### Other Variables ######
+ 
diff --git a/mbone/mcl/files/patch-check-alc-Makefile b/mbone/mcl/files/patch-check-alc-Makefile
new file mode 100644
index 000000000000..65fa32515984
--- /dev/null
+++ b/mbone/mcl/files/patch-check-alc-Makefile
@@ -0,0 +1,21 @@
+--- check/alc/Makefile.orig	Wed Oct 15 18:02:27 2003
++++ check/alc/Makefile	Wed Oct 15 17:24:04 2003
+@@ -35,6 +35,18 @@
+ 	LIBRARIES = -lc -lm -lsocket -lnsl -L/usr/ucblib -lucb -lposix4 -mt -lpthread ${BINDIR}/libmclalc.a ${LDPC_BINDIR}/libldpc.a
+ endif
+ 
++ifeq (${OS},freebsd)
++	# Linux version
++	#
++	BINDIR = ../../bin/freebsd
++	LDPC_BINDIR = ../../../ldpc/bin/freebsd
++	# Edit the following two lines as appropriate, according to the FEC
++	# codec in use: if LDPC is used, then add the libbdpc.a library.
++	#
++	LIBRARIES = -lm -pthread ${BINDIR}/libmclalc.a
++	#LIBRARIES = -lm -pthread ${BINDIR}/libmclalc.a ${LDPC_BINDIR}/libldpc.a
++endif
++
+ 
+ ###### Other variables ######
+ 
diff --git a/mbone/mcl/files/patch-fcast-Makefile b/mbone/mcl/files/patch-fcast-Makefile
new file mode 100644
index 000000000000..dce7b64a9811
--- /dev/null
+++ b/mbone/mcl/files/patch-fcast-Makefile
@@ -0,0 +1,28 @@
+--- fcast/Makefile.orig	Tue Jul 22 19:43:25 2003
++++ fcast/Makefile	Wed Oct 15 17:20:46 2003
+@@ -39,6 +39,14 @@
+ 
+ endif
+ 
++ifeq (${OS},freebsd)
++	# FreeBSD version
++	#
++	BINDIR = ../bin/freebsd
++	LDPC_BINDIR = ../../ldpc/bin/freebsd
++	LIBRARIES = -lm -pthread
++endif
++
+ 
+ ###### Other variables ######
+ 
+@@ -76,8 +84,8 @@
+ # codec in use: if LDPC is used, then add the libbdpc.a library.
+ # If only RSE is used and if you don't have the LDPC archive, then
+ # remove the libbdpc.a library.
+-#alc:	MCL_LIBRARY = ${BINDIR}/libmclalc.a
+-alc:	MCL_LIBRARY = ${BINDIR}/libmclalc.a ${LDPC_BINDIR}/libldpc.a
++alc:	MCL_LIBRARY = ${BINDIR}/libmclalc.a
++#alc:	MCL_LIBRARY = ${BINDIR}/libmclalc.a ${LDPC_BINDIR}/libldpc.a
+ alc:	TARGET_FCAST = ${BINDIR}/fcast
+ #alc:	all
+ 
diff --git a/mbone/mcl/files/patch-fcast.h b/mbone/mcl/files/patch-fcast.h
new file mode 100644
index 000000000000..bd50c0f41eb7
--- /dev/null
+++ b/mbone/mcl/files/patch-fcast.h
@@ -0,0 +1,20 @@
+--- fcast/fcast.h.orig	Tue Jul 22 19:37:39 2003
++++ fcast/fcast.h	Wed Oct 15 16:59:13 2003
+@@ -62,12 +62,16 @@
+ #include "frecv.h"
+ 
+ 
++
+ #if defined(LINUX) /* On Linux systems, signal handlers must be of __sighandler_t type */
+ #define	sighandler_t	__sighandler_t
+ 
+ #elif defined(SOLARIS) || defined(IRIX) || defined(WIN32)
+-
+ #define	sighandler_t	void (*)(int)
++
++#elif defined(FREEBSD)
++#define sighandler_t	sig_t
++
+ #endif
+ 
+ 
diff --git a/mbone/mcl/files/patch-mcl_debug.cpp b/mbone/mcl/files/patch-mcl_debug.cpp
new file mode 100644
index 000000000000..982503f326c9
--- /dev/null
+++ b/mbone/mcl/files/patch-mcl_debug.cpp
@@ -0,0 +1,11 @@
+--- src/common/mcl_debug.cpp.orig	Tue Jul 22 19:37:39 2003
++++ src/common/mcl_debug.cpp	Wed Oct 15 17:55:58 2003
+@@ -73,7 +73,7 @@
+ 	PRINT_OUT((mcl_stdout, "\tDUMP %d first bytes...\n\t", i * sizeof(int)))
+ 	for (ptr = (int*)buf; i > 0; i--, ptr++) {
+ 		/* convert to big endian format to be sure of byte order */
+-		PRINT_OUT((mcl_stdout, "%08x ", htonl(*ptr)))
++		PRINT_OUT((mcl_stdout, "%08lx ", htonl(*ptr)))
+ 		if (++j == 8) {
+ 			j = 0;
+ 			PRINT_OUT((mcl_stdout, "\n\t"))
diff --git a/mbone/mcl/files/patch-mcl_includes.h b/mbone/mcl/files/patch-mcl_includes.h
new file mode 100644
index 000000000000..d68a50637331
--- /dev/null
+++ b/mbone/mcl/files/patch-mcl_includes.h
@@ -0,0 +1,36 @@
+--- src/alc/mcl_includes.h.orig	Tue Jul 22 19:37:39 2003
++++ src/alc/mcl_includes.h	Tue Oct 14 15:23:54 2003
+@@ -40,11 +40,13 @@
+ #include <sys/types.h>
+ #include <math.h>
+ 
++#ifndef FREEBSD
+ #if defined(DEBUG) && defined(MPATROL) && !defined(WIN32)
+ #include <mpatrol.h>
+ #else
+ #include <malloc.h>
+ #endif
++#endif
+ #include <new>		// required by _set_new_handler on linux
+ 
+ 
+@@ -58,14 +60,18 @@
+ #else	/* UNIX Systems */
+ 
+ #include <unistd.h>
++
++#ifndef FREEBSD
+ #include <values.h>	/* for MAXINT */
++#endif
++
+ #include <strings.h>
+ #include <sys/time.h>
+ #include <sys/wait.h>
+ #include <pthread.h>
+ #include <sys/uio.h>
+ 
+-#ifdef SOLARIS
++#if defined(SOLARIS) || defined(FREEBSD)
+ #include <netinet/in_systm.h>
+ #endif /* SOLARIS */
+ 
diff --git a/mbone/mcl/files/patch-mcl_lib.cpp b/mbone/mcl/files/patch-mcl_lib.cpp
new file mode 100644
index 000000000000..c76e22fadb91
--- /dev/null
+++ b/mbone/mcl/files/patch-mcl_lib.cpp
@@ -0,0 +1,14 @@
+--- src/alc/mcl_lib.cpp.orig	Tue Jul 22 19:37:39 2003
++++ src/alc/mcl_lib.cpp	Wed Oct 15 16:16:55 2003
+@@ -1265,8 +1265,10 @@
+ 	if (id >= MCLCB_MAX_ID || (mclcb = mclcbs[id]) == NULL) {
+ 		TRACE((mcl_stdout, "   mcl_recvfrom: not an MCL id, switch to standard recvfrom\n"))
+ 		return (recvfrom(id, (char*)buf, len, 0, saddr,
+-#ifdef LINUX
++#if defined(LINUX)
+ 				(size_t*) /* linux => uint, solaris => int */
++#elif defined(FREEBSD)
++				(socklen_t*) 
+ #endif
+ 				saddr_len));
+ 	}
diff --git a/mbone/mcl/files/patch-mcl_network.cpp b/mbone/mcl/files/patch-mcl_network.cpp
new file mode 100644
index 000000000000..6e5a8cfaebfe
--- /dev/null
+++ b/mbone/mcl/files/patch-mcl_network.cpp
@@ -0,0 +1,48 @@
+--- src/alc/mcl_network.cpp.orig	Tue Jul 22 19:37:39 2003
++++ src/alc/mcl_network.cpp	Tue Oct 14 15:47:45 2003
+@@ -414,8 +414,10 @@
+ 				pkt->pkt_len = recvfrom(mg->ses_sock,
+ 					pkt->get_buf(), pkt->get_buf_len(),
+ 					0, &saddr,
+-#ifdef LINUX
++#if defined(LINUX)
+ 					(size_t*)
++#elif defined(FREEBSD)
++					(socklen_t*)
+ #endif
+ 					&saddr_len);
+ #ifdef WIN32
+@@ -483,8 +485,10 @@
+ 			pkt->pkt_len = recvfrom(mg->priv_sock,
+ 					pkt->get_buf(), pkt->get_buf_len(),
+ 					0, &saddr,
+-#ifdef LINUX
++#if defined(LINUX)
+ 					(size_t*)
++#elif defined(FREEBSD)
++					(socklen_t*)
+ #endif
+ 					&saddr_len);
+ #ifdef WIN32
+@@ -663,8 +667,10 @@
+ 		err = setsockopt(fd, SOL_SOCKET, buf, (char*)&val, sizeof(val));
+ 	else
+ 		err = getsockopt(fd, SOL_SOCKET, buf, (char*)&val,
+-#ifdef LINUX
+-				(size_t*) /* linux => uint, solaris => int */
++#if defined(LINUX)
++					(size_t*)
++#elif defined(FREEBSD)
++					(socklen_t*)
+ #endif
+ 				&len);
+ 	if (err < 0) {
+@@ -938,7 +944,7 @@
+ 
+ 		if (mcl_is_valid_sock(mg->priv_sock) &&
+ 		    getsockname(mg->priv_sock, (struct sockaddr *)&tmp_addr,
+-#ifdef LINUX
++#if defined(LINUX) || defined(FREEBSD)
+ 				(socklen_t*)
+ #endif
+ 				&tmp_len) < 0) {
diff --git a/mbone/mcl/files/patch-mcl_osdep.h b/mbone/mcl/files/patch-mcl_osdep.h
new file mode 100644
index 000000000000..575afbc6f974
--- /dev/null
+++ b/mbone/mcl/files/patch-mcl_osdep.h
@@ -0,0 +1,32 @@
+--- src/common/mcl_osdep.h.orig	Tue Jul 22 19:37:39 2003
++++ src/common/mcl_osdep.h	Wed Oct 15 16:11:46 2003
+@@ -30,7 +30,7 @@
+ /*
+  * bit field order is compiler/OS dependant
+  */
+-#if defined(LINUX) || defined(WIN32)
++#if defined(LINUX) || defined(WIN32) || defined(FREEBSD)
+ #define _BIT_FIELDS_LTOH
+ #undef _BIT_FIELDS_HTOL
+ 
+@@ -44,7 +44,7 @@
+ /*
+  * sighandler
+  */
+-#if defined(LINUX)
++#if defined(LINUX) || defined(FREEBSD)
+ 	/* On Linux systems, signal handlers must be of __sighandler_t type */
+ #define	sighandler_t	__sighandler_t
+ 
+@@ -63,9 +63,9 @@
+ #define u_int16_t	ushort_t	/* or uint16_t */
+ #define u_int32_t	uint_t		/* or uint32_t */
+ 
+-#elif defined (WIN32) 
++#elif defined (WIN32) || defined (FREEBSD)
+ 
+-/* u_xxx absent from WIN32! */
++/* u_xxx absent from WIN32 and ulong absent from FreeBSD! */
+ #define u_int8_t	unsigned char		/* or uint8_t */
+ #define u_int16_t	unsigned short		/* or uint16_t */
+ #define u_int32_t	unsigned int		/* or uint32_t */
diff --git a/mbone/mcl/files/patch-robcast-Makefile b/mbone/mcl/files/patch-robcast-Makefile
new file mode 100644
index 000000000000..f6f4a21f0e42
--- /dev/null
+++ b/mbone/mcl/files/patch-robcast-Makefile
@@ -0,0 +1,19 @@
+--- robcast/Makefile.orig	Wed Oct 15 18:03:36 2003
++++ robcast/Makefile	Wed Oct 15 17:33:36 2003
+@@ -29,6 +29,16 @@
+ 	LIBRARIES = -lc -lm -lsocket -lnsl -L/usr/ucblib -lucb -lposix4 -lpthread ${BINDIR}/libmclalc.a ${LDPC_BINDIR}/libldpc.a
+ endif
+ 
++ifeq (${OS},freebsd)
++	# FreeBSD version
++	# MCL library requires -pthread
++	#
++	BINDIR = ../bin/freebsd
++	LDPC_BINDIR = ../../ldpc/bin/freebsd
++	LIBRARIES = -lm -pthread ${BINDIR}/libmclalc.a
++	#LIBRARIES = -lm -pthread ${BINDIR}/libmclalc.a ${LDPC_BINDIR}/libldpc.a
++endif
++
+ 
+ ###### Other variables ######
+ 
diff --git a/mbone/mcl/files/patch-test_abort.c b/mbone/mcl/files/patch-test_abort.c
new file mode 100644
index 000000000000..ad1116943ab0
--- /dev/null
+++ b/mbone/mcl/files/patch-test_abort.c
@@ -0,0 +1,13 @@
+--- check/alc/test_abort.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_abort.c	Wed Oct 15 17:10:42 2003
+@@ -26,6 +26,10 @@
+ #include <stdio.h>
+ #include <stdlib.h>			/* for exit */
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #include <io.h>
diff --git a/mbone/mcl/files/patch-test_demux_label1_rx.c b/mbone/mcl/files/patch-test_demux_label1_rx.c
new file mode 100644
index 000000000000..d172c016a3b0
--- /dev/null
+++ b/mbone/mcl/files/patch-test_demux_label1_rx.c
@@ -0,0 +1,13 @@
+--- check/alc/test_demux_label1_rx.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_demux_label1_rx.c	Wed Oct 15 17:13:17 2003
+@@ -26,6 +26,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/mbone/mcl/files/patch-test_demux_label1_tx.c b/mbone/mcl/files/patch-test_demux_label1_tx.c
new file mode 100644
index 000000000000..57e1efe5f915
--- /dev/null
+++ b/mbone/mcl/files/patch-test_demux_label1_tx.c
@@ -0,0 +1,13 @@
+--- check/alc/test_demux_label1_tx.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_demux_label1_tx.c	Wed Oct 15 17:12:56 2003
+@@ -25,6 +25,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/mbone/mcl/files/patch-test_dyn_tsi.c b/mbone/mcl/files/patch-test_dyn_tsi.c
new file mode 100644
index 000000000000..bf09722b074f
--- /dev/null
+++ b/mbone/mcl/files/patch-test_dyn_tsi.c
@@ -0,0 +1,13 @@
+--- check/alc/test_dyn_tsi.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_dyn_tsi.c	Wed Oct 15 17:13:37 2003
+@@ -30,6 +30,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/mbone/mcl/files/patch-test_multi_sessions1.c b/mbone/mcl/files/patch-test_multi_sessions1.c
new file mode 100644
index 000000000000..0b0af22dd2b1
--- /dev/null
+++ b/mbone/mcl/files/patch-test_multi_sessions1.c
@@ -0,0 +1,14 @@
+--- check/alc/test_multi_sessions1.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_multi_sessions1.c	Wed Oct 15 17:11:53 2003
+@@ -24,6 +24,11 @@
+  */
+ 
+ #include <stdio.h>
++
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/mbone/mcl/files/patch-test_multi_sessions2.c b/mbone/mcl/files/patch-test_multi_sessions2.c
new file mode 100644
index 000000000000..0033a72b5a86
--- /dev/null
+++ b/mbone/mcl/files/patch-test_multi_sessions2.c
@@ -0,0 +1,14 @@
+--- check/alc/test_multi_sessions2.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_multi_sessions2.c	Wed Oct 15 17:12:13 2003
+@@ -25,6 +25,11 @@
+  */
+ 
+ #include <stdio.h>
++
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #include <io.h>
diff --git a/mbone/mcl/files/patch-test_no_tx.c b/mbone/mcl/files/patch-test_no_tx.c
new file mode 100644
index 000000000000..e6f1e0b90d83
--- /dev/null
+++ b/mbone/mcl/files/patch-test_no_tx.c
@@ -0,0 +1,13 @@
+--- check/alc/test_no_tx.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_no_tx.c	Wed Oct 15 17:10:20 2003
+@@ -25,6 +25,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/mbone/mcl/files/patch-test_rebootable_client.c b/mbone/mcl/files/patch-test_rebootable_client.c
new file mode 100644
index 000000000000..9ee9725b77a9
--- /dev/null
+++ b/mbone/mcl/files/patch-test_rebootable_client.c
@@ -0,0 +1,13 @@
+--- check/alc/test_rebootable_client.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_rebootable_client.c	Wed Oct 15 17:18:38 2003
+@@ -35,6 +35,10 @@
+ #include <stdio.h>
+ #include <string.h>
+ 
++#ifdef FREEBSD
++#include <sys/time.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/mbone/mcl/files/patch-test_seq_of_tx_sessions.c b/mbone/mcl/files/patch-test_seq_of_tx_sessions.c
new file mode 100644
index 000000000000..31d967ca431e
--- /dev/null
+++ b/mbone/mcl/files/patch-test_seq_of_tx_sessions.c
@@ -0,0 +1,14 @@
+--- check/alc/test_seq_of_tx_sessions.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_seq_of_tx_sessions.c	Wed Oct 15 17:11:13 2003
+@@ -25,6 +25,11 @@
+  */
+ 
+ #include <stdio.h>
++
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/mbone/mcl/files/patch-test_several_fec_codecs.c b/mbone/mcl/files/patch-test_several_fec_codecs.c
new file mode 100644
index 000000000000..34da7be64644
--- /dev/null
+++ b/mbone/mcl/files/patch-test_several_fec_codecs.c
@@ -0,0 +1,13 @@
+--- check/alc/test_several_fec_codecs.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_several_fec_codecs.c	Wed Oct 15 17:05:40 2003
+@@ -28,6 +28,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/mbone/mcl/files/patch-test_vtm_rx.c b/mbone/mcl/files/patch-test_vtm_rx.c
new file mode 100644
index 000000000000..a0cf05b33306
--- /dev/null
+++ b/mbone/mcl/files/patch-test_vtm_rx.c
@@ -0,0 +1,13 @@
+--- check/alc/test_vtm_rx.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_vtm_rx.c	Wed Oct 15 17:14:28 2003
+@@ -27,6 +27,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/mbone/mcl/files/patch-test_vtm_tx.c b/mbone/mcl/files/patch-test_vtm_tx.c
new file mode 100644
index 000000000000..8d26b0f60d2d
--- /dev/null
+++ b/mbone/mcl/files/patch-test_vtm_tx.c
@@ -0,0 +1,13 @@
+--- check/alc/test_vtm_tx.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_vtm_tx.c	Wed Oct 15 17:14:02 2003
+@@ -25,6 +25,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/mbone/mcl/files/patch-test_wait_rx_receiver.c b/mbone/mcl/files/patch-test_wait_rx_receiver.c
new file mode 100644
index 000000000000..c03c4a4be206
--- /dev/null
+++ b/mbone/mcl/files/patch-test_wait_rx_receiver.c
@@ -0,0 +1,12 @@
+--- check/alc/test_wait_rx_receiver.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_wait_rx_receiver.c	Wed Oct 15 17:09:56 2003
+@@ -27,6 +27,9 @@
+ #include <stdio.h>
+ 
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
+ 
+ #ifdef WIN32
+ #include <winsock2.h>
diff --git a/mbone/mcl/files/patch-test_wait_rx_sender.c b/mbone/mcl/files/patch-test_wait_rx_sender.c
new file mode 100644
index 000000000000..694af55beed3
--- /dev/null
+++ b/mbone/mcl/files/patch-test_wait_rx_sender.c
@@ -0,0 +1,12 @@
+--- check/alc/test_wait_rx_sender.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_wait_rx_sender.c	Wed Oct 15 17:09:33 2003
+@@ -27,6 +27,9 @@
+ #include <stdio.h>
+ 
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
+ 
+ #ifdef WIN32
+ #include <winsock2.h>
diff --git a/mbone/mcl/files/patch-test_wait_tx.c b/mbone/mcl/files/patch-test_wait_tx.c
new file mode 100644
index 000000000000..b0b816cc8cd8
--- /dev/null
+++ b/mbone/mcl/files/patch-test_wait_tx.c
@@ -0,0 +1,13 @@
+--- check/alc/test_wait_tx.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_wait_tx.c	Wed Oct 15 17:09:00 2003
+@@ -25,6 +25,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/mbone/mcl/pkg-descr b/mbone/mcl/pkg-descr
new file mode 100644
index 000000000000..27a280bad227
--- /dev/null
+++ b/mbone/mcl/pkg-descr
@@ -0,0 +1,14 @@
+This is a port of MCLv3, an open source implementation of the ALC and 
+NORM Reliable Multicast Protocols.
+
+The MCLv3 project is an Open-Source GNU/GPL, multi-platform 
+implementation of the two major reliable multicast protocols being 
+standardized by the RMT IETF working group: ALC/LCT and NORM. It is 
+composed of a C/C++ library and several applications built on top of it 
+and provides an easy-to-use and integrated solution for reliable and 
+highly scalable multicast delivery of data.
+
+WWW: http://www.inrialpes.fr/planete/people/roca/mcl/mcl.html
+
+- Panagiotis Astithas
+past@noc.ntua.gr
diff --git a/mbone/mcl/pkg-plist b/mbone/mcl/pkg-plist
new file mode 100644
index 000000000000..cd9eeac40007
--- /dev/null
+++ b/mbone/mcl/pkg-plist
@@ -0,0 +1,4 @@
+bin/fcast
+bin/robcast_client
+bin/robcast_server
+lib/libmclalc.a
diff --git a/net/mcl/Makefile b/net/mcl/Makefile
new file mode 100644
index 000000000000..a6f7052421b1
--- /dev/null
+++ b/net/mcl/Makefile
@@ -0,0 +1,53 @@
+# New ports collection makefile for:   mcl
+# Date created:        29 October 2003
+# Whom:                past@noc.ntua.gr
+#
+# $FreeBSD$
+#
+
+PORTNAME=	mcl
+PORTVERSION=	2.99
+CATEGORIES=	mbone net
+MASTER_SITES=	http://www.inrialpes.fr/planete/people/roca/mcl/bin/
+DISTNAME=	mcl_v2.99
+EXTRACT_SUFX=	.tgz
+
+MAINTAINER=	past@noc.ntua.gr
+COMMENT=	Implementation of the ALC and NORM Reliable Multicast Protocols
+
+USE_GMAKE=	yes
+MAN1=		fcast.1 fcastn.1 mclrecv2.1 mclsend2.1
+MAN2=		mcl_abort.2 mcl_close.2 mcl_ctl.2 mcl_open.2 mcl_recv.2 \
+		mcl_send.2 mcl_wait_event.2
+WRKSRC=		${WRKDIR}/mcl_v2.99_src
+
+pre-patch:
+	@cd ${WRKSRC} &&  \
+		${MKDIR} bin/freebsd
+
+do-install:
+	${INSTALL_PROGRAM} ${WRKSRC}/bin/freebsd/fcast ${PREFIX}/bin
+	${INSTALL_PROGRAM} ${WRKSRC}/bin/freebsd/robcast_client ${PREFIX}/bin
+	${INSTALL_PROGRAM} ${WRKSRC}/bin/freebsd/robcast_server ${PREFIX}/bin
+	${INSTALL_DATA} ${WRKSRC}/bin/freebsd/libmclalc.a ${PREFIX}/lib
+	${INSTALL_MAN} ${WRKSRC}/man/fcast.man.1 ${PREFIX}/man/man1/fcast.1
+	${INSTALL_MAN} ${WRKSRC}/man/fcastn.man.1 ${PREFIX}/man/man1/fcastn.1
+	${INSTALL_MAN} ${WRKSRC}/man/mclrecv2.man.1 \
+		${PREFIX}/man/man1/mclrecv2.1
+	${INSTALL_MAN} ${WRKSRC}/man/mclsend2.man.1 \
+		${PREFIX}/man/man1/mclsend2.1
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_abort.man.2 \
+		${PREFIX}/man/man2/mcl_abort.2
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_close.man.2 \
+		${PREFIX}/man/man2/mcl_close.2
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_ctl.man.2 ${PREFIX}/man/man2/mcl_ctl.2
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_open.man.2 \
+		${PREFIX}/man/man2/mcl_open.2
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_recv.man.2 \
+		${PREFIX}/man/man2/mcl_recv.2
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_send.man.2 \
+		${PREFIX}/man/man2/mcl_send.2
+	${INSTALL_MAN} ${WRKSRC}/man/mcl_wait_event.man.2 \
+		${PREFIX}/man/man2/mcl_wait_event.2
+
+.include <bsd.port.mk>
diff --git a/net/mcl/distinfo b/net/mcl/distinfo
new file mode 100644
index 000000000000..374107be22a4
--- /dev/null
+++ b/net/mcl/distinfo
@@ -0,0 +1 @@
+MD5 (mcl_v2.99.tgz) = d492d3df5b88ca563d0f484ce63f31f4
diff --git a/net/mcl/files/patch-Makefile b/net/mcl/files/patch-Makefile
new file mode 100644
index 000000000000..b557dae141b1
--- /dev/null
+++ b/net/mcl/files/patch-Makefile
@@ -0,0 +1,13 @@
+--- Makefile.orig	Tue Jul 22 19:37:39 2003
++++ Makefile	Tue Oct 14 11:55:56 2003
+@@ -5,8 +5,8 @@
+ # We need the GNU make tool, on some systems it is called
+ # gmake, on others make is an alias to gmake. Choose one...
+ #
+-MAKE = make
+-#MAKE = gmake
++#MAKE = make
++MAKE = gmake
+ 
+ 
+ # A phony target is one that is not really the name of a file.
diff --git a/net/mcl/files/patch-Makefile.common b/net/mcl/files/patch-Makefile.common
new file mode 100644
index 000000000000..2277615cfabd
--- /dev/null
+++ b/net/mcl/files/patch-Makefile.common
@@ -0,0 +1,33 @@
+--- Makefile.common.orig	Tue Jul 22 19:37:39 2003
++++ Makefile.common	Tue Oct 14 15:04:38 2003
+@@ -24,11 +24,15 @@
+ ifeq (${SYSTEM},SunOS)
+ 	OS = solaris
+ endif
++ifeq (${SYSTEM},FreeBSD)
++	OS = freebsd
++endif
+ #
+ # and the old way (e.g. if the above lines do not work!)
+ #
+ #OS = linux
+ #OS = solaris
++#OS = freebsd
+ 
+ 
+ # Do you want/need extended memory debugging?
+@@ -59,6 +63,14 @@
+ 	#
+ 	CC = /opt/SUNWspro/bin/CC
+ 	LD = /opt/SUNWspro/bin/CC 
++endif
++ifeq (${OS},freebsd)
++	OSFLAGS = -DFREEBSD -I/usr/include/g++
++	# Which compiler?
++	# NB: use -Wall for compilation warnings with gcc
++	#
++	CC = g++ -Wall
++	LD = g++ -Wall
+ endif
+ 
+ 
diff --git a/net/mcl/files/patch-alc-Makefile b/net/mcl/files/patch-alc-Makefile
new file mode 100644
index 000000000000..b38cb525c35f
--- /dev/null
+++ b/net/mcl/files/patch-alc-Makefile
@@ -0,0 +1,16 @@
+--- src/alc/Makefile.orig	Tue Jul 22 19:42:18 2003
++++ src/alc/Makefile	Wed Oct 15 17:21:25 2003
+@@ -36,6 +36,13 @@
+ 	LIBRARIES = -lc -lm -lsocket -lnsl -L/usr/ucblib -lucb -lpthread
+ endif
+ 
++ifeq (${OS},freebsd)
++	# FreeBSD version
++	BINDIR = ../../bin/freebsd
++	LDPC_BINDIR = ../../../ldpc/bin/freebsd
++	LIBRARIES = -lm -pthread
++endif
++
+ 
+ ###### Other Variables ######
+ 
diff --git a/net/mcl/files/patch-check-alc-Makefile b/net/mcl/files/patch-check-alc-Makefile
new file mode 100644
index 000000000000..65fa32515984
--- /dev/null
+++ b/net/mcl/files/patch-check-alc-Makefile
@@ -0,0 +1,21 @@
+--- check/alc/Makefile.orig	Wed Oct 15 18:02:27 2003
++++ check/alc/Makefile	Wed Oct 15 17:24:04 2003
+@@ -35,6 +35,18 @@
+ 	LIBRARIES = -lc -lm -lsocket -lnsl -L/usr/ucblib -lucb -lposix4 -mt -lpthread ${BINDIR}/libmclalc.a ${LDPC_BINDIR}/libldpc.a
+ endif
+ 
++ifeq (${OS},freebsd)
++	# Linux version
++	#
++	BINDIR = ../../bin/freebsd
++	LDPC_BINDIR = ../../../ldpc/bin/freebsd
++	# Edit the following two lines as appropriate, according to the FEC
++	# codec in use: if LDPC is used, then add the libbdpc.a library.
++	#
++	LIBRARIES = -lm -pthread ${BINDIR}/libmclalc.a
++	#LIBRARIES = -lm -pthread ${BINDIR}/libmclalc.a ${LDPC_BINDIR}/libldpc.a
++endif
++
+ 
+ ###### Other variables ######
+ 
diff --git a/net/mcl/files/patch-fcast-Makefile b/net/mcl/files/patch-fcast-Makefile
new file mode 100644
index 000000000000..dce7b64a9811
--- /dev/null
+++ b/net/mcl/files/patch-fcast-Makefile
@@ -0,0 +1,28 @@
+--- fcast/Makefile.orig	Tue Jul 22 19:43:25 2003
++++ fcast/Makefile	Wed Oct 15 17:20:46 2003
+@@ -39,6 +39,14 @@
+ 
+ endif
+ 
++ifeq (${OS},freebsd)
++	# FreeBSD version
++	#
++	BINDIR = ../bin/freebsd
++	LDPC_BINDIR = ../../ldpc/bin/freebsd
++	LIBRARIES = -lm -pthread
++endif
++
+ 
+ ###### Other variables ######
+ 
+@@ -76,8 +84,8 @@
+ # codec in use: if LDPC is used, then add the libbdpc.a library.
+ # If only RSE is used and if you don't have the LDPC archive, then
+ # remove the libbdpc.a library.
+-#alc:	MCL_LIBRARY = ${BINDIR}/libmclalc.a
+-alc:	MCL_LIBRARY = ${BINDIR}/libmclalc.a ${LDPC_BINDIR}/libldpc.a
++alc:	MCL_LIBRARY = ${BINDIR}/libmclalc.a
++#alc:	MCL_LIBRARY = ${BINDIR}/libmclalc.a ${LDPC_BINDIR}/libldpc.a
+ alc:	TARGET_FCAST = ${BINDIR}/fcast
+ #alc:	all
+ 
diff --git a/net/mcl/files/patch-fcast.h b/net/mcl/files/patch-fcast.h
new file mode 100644
index 000000000000..bd50c0f41eb7
--- /dev/null
+++ b/net/mcl/files/patch-fcast.h
@@ -0,0 +1,20 @@
+--- fcast/fcast.h.orig	Tue Jul 22 19:37:39 2003
++++ fcast/fcast.h	Wed Oct 15 16:59:13 2003
+@@ -62,12 +62,16 @@
+ #include "frecv.h"
+ 
+ 
++
+ #if defined(LINUX) /* On Linux systems, signal handlers must be of __sighandler_t type */
+ #define	sighandler_t	__sighandler_t
+ 
+ #elif defined(SOLARIS) || defined(IRIX) || defined(WIN32)
+-
+ #define	sighandler_t	void (*)(int)
++
++#elif defined(FREEBSD)
++#define sighandler_t	sig_t
++
+ #endif
+ 
+ 
diff --git a/net/mcl/files/patch-mcl_debug.cpp b/net/mcl/files/patch-mcl_debug.cpp
new file mode 100644
index 000000000000..982503f326c9
--- /dev/null
+++ b/net/mcl/files/patch-mcl_debug.cpp
@@ -0,0 +1,11 @@
+--- src/common/mcl_debug.cpp.orig	Tue Jul 22 19:37:39 2003
++++ src/common/mcl_debug.cpp	Wed Oct 15 17:55:58 2003
+@@ -73,7 +73,7 @@
+ 	PRINT_OUT((mcl_stdout, "\tDUMP %d first bytes...\n\t", i * sizeof(int)))
+ 	for (ptr = (int*)buf; i > 0; i--, ptr++) {
+ 		/* convert to big endian format to be sure of byte order */
+-		PRINT_OUT((mcl_stdout, "%08x ", htonl(*ptr)))
++		PRINT_OUT((mcl_stdout, "%08lx ", htonl(*ptr)))
+ 		if (++j == 8) {
+ 			j = 0;
+ 			PRINT_OUT((mcl_stdout, "\n\t"))
diff --git a/net/mcl/files/patch-mcl_includes.h b/net/mcl/files/patch-mcl_includes.h
new file mode 100644
index 000000000000..d68a50637331
--- /dev/null
+++ b/net/mcl/files/patch-mcl_includes.h
@@ -0,0 +1,36 @@
+--- src/alc/mcl_includes.h.orig	Tue Jul 22 19:37:39 2003
++++ src/alc/mcl_includes.h	Tue Oct 14 15:23:54 2003
+@@ -40,11 +40,13 @@
+ #include <sys/types.h>
+ #include <math.h>
+ 
++#ifndef FREEBSD
+ #if defined(DEBUG) && defined(MPATROL) && !defined(WIN32)
+ #include <mpatrol.h>
+ #else
+ #include <malloc.h>
+ #endif
++#endif
+ #include <new>		// required by _set_new_handler on linux
+ 
+ 
+@@ -58,14 +60,18 @@
+ #else	/* UNIX Systems */
+ 
+ #include <unistd.h>
++
++#ifndef FREEBSD
+ #include <values.h>	/* for MAXINT */
++#endif
++
+ #include <strings.h>
+ #include <sys/time.h>
+ #include <sys/wait.h>
+ #include <pthread.h>
+ #include <sys/uio.h>
+ 
+-#ifdef SOLARIS
++#if defined(SOLARIS) || defined(FREEBSD)
+ #include <netinet/in_systm.h>
+ #endif /* SOLARIS */
+ 
diff --git a/net/mcl/files/patch-mcl_lib.cpp b/net/mcl/files/patch-mcl_lib.cpp
new file mode 100644
index 000000000000..c76e22fadb91
--- /dev/null
+++ b/net/mcl/files/patch-mcl_lib.cpp
@@ -0,0 +1,14 @@
+--- src/alc/mcl_lib.cpp.orig	Tue Jul 22 19:37:39 2003
++++ src/alc/mcl_lib.cpp	Wed Oct 15 16:16:55 2003
+@@ -1265,8 +1265,10 @@
+ 	if (id >= MCLCB_MAX_ID || (mclcb = mclcbs[id]) == NULL) {
+ 		TRACE((mcl_stdout, "   mcl_recvfrom: not an MCL id, switch to standard recvfrom\n"))
+ 		return (recvfrom(id, (char*)buf, len, 0, saddr,
+-#ifdef LINUX
++#if defined(LINUX)
+ 				(size_t*) /* linux => uint, solaris => int */
++#elif defined(FREEBSD)
++				(socklen_t*) 
+ #endif
+ 				saddr_len));
+ 	}
diff --git a/net/mcl/files/patch-mcl_network.cpp b/net/mcl/files/patch-mcl_network.cpp
new file mode 100644
index 000000000000..6e5a8cfaebfe
--- /dev/null
+++ b/net/mcl/files/patch-mcl_network.cpp
@@ -0,0 +1,48 @@
+--- src/alc/mcl_network.cpp.orig	Tue Jul 22 19:37:39 2003
++++ src/alc/mcl_network.cpp	Tue Oct 14 15:47:45 2003
+@@ -414,8 +414,10 @@
+ 				pkt->pkt_len = recvfrom(mg->ses_sock,
+ 					pkt->get_buf(), pkt->get_buf_len(),
+ 					0, &saddr,
+-#ifdef LINUX
++#if defined(LINUX)
+ 					(size_t*)
++#elif defined(FREEBSD)
++					(socklen_t*)
+ #endif
+ 					&saddr_len);
+ #ifdef WIN32
+@@ -483,8 +485,10 @@
+ 			pkt->pkt_len = recvfrom(mg->priv_sock,
+ 					pkt->get_buf(), pkt->get_buf_len(),
+ 					0, &saddr,
+-#ifdef LINUX
++#if defined(LINUX)
+ 					(size_t*)
++#elif defined(FREEBSD)
++					(socklen_t*)
+ #endif
+ 					&saddr_len);
+ #ifdef WIN32
+@@ -663,8 +667,10 @@
+ 		err = setsockopt(fd, SOL_SOCKET, buf, (char*)&val, sizeof(val));
+ 	else
+ 		err = getsockopt(fd, SOL_SOCKET, buf, (char*)&val,
+-#ifdef LINUX
+-				(size_t*) /* linux => uint, solaris => int */
++#if defined(LINUX)
++					(size_t*)
++#elif defined(FREEBSD)
++					(socklen_t*)
+ #endif
+ 				&len);
+ 	if (err < 0) {
+@@ -938,7 +944,7 @@
+ 
+ 		if (mcl_is_valid_sock(mg->priv_sock) &&
+ 		    getsockname(mg->priv_sock, (struct sockaddr *)&tmp_addr,
+-#ifdef LINUX
++#if defined(LINUX) || defined(FREEBSD)
+ 				(socklen_t*)
+ #endif
+ 				&tmp_len) < 0) {
diff --git a/net/mcl/files/patch-mcl_osdep.h b/net/mcl/files/patch-mcl_osdep.h
new file mode 100644
index 000000000000..575afbc6f974
--- /dev/null
+++ b/net/mcl/files/patch-mcl_osdep.h
@@ -0,0 +1,32 @@
+--- src/common/mcl_osdep.h.orig	Tue Jul 22 19:37:39 2003
++++ src/common/mcl_osdep.h	Wed Oct 15 16:11:46 2003
+@@ -30,7 +30,7 @@
+ /*
+  * bit field order is compiler/OS dependant
+  */
+-#if defined(LINUX) || defined(WIN32)
++#if defined(LINUX) || defined(WIN32) || defined(FREEBSD)
+ #define _BIT_FIELDS_LTOH
+ #undef _BIT_FIELDS_HTOL
+ 
+@@ -44,7 +44,7 @@
+ /*
+  * sighandler
+  */
+-#if defined(LINUX)
++#if defined(LINUX) || defined(FREEBSD)
+ 	/* On Linux systems, signal handlers must be of __sighandler_t type */
+ #define	sighandler_t	__sighandler_t
+ 
+@@ -63,9 +63,9 @@
+ #define u_int16_t	ushort_t	/* or uint16_t */
+ #define u_int32_t	uint_t		/* or uint32_t */
+ 
+-#elif defined (WIN32) 
++#elif defined (WIN32) || defined (FREEBSD)
+ 
+-/* u_xxx absent from WIN32! */
++/* u_xxx absent from WIN32 and ulong absent from FreeBSD! */
+ #define u_int8_t	unsigned char		/* or uint8_t */
+ #define u_int16_t	unsigned short		/* or uint16_t */
+ #define u_int32_t	unsigned int		/* or uint32_t */
diff --git a/net/mcl/files/patch-robcast-Makefile b/net/mcl/files/patch-robcast-Makefile
new file mode 100644
index 000000000000..f6f4a21f0e42
--- /dev/null
+++ b/net/mcl/files/patch-robcast-Makefile
@@ -0,0 +1,19 @@
+--- robcast/Makefile.orig	Wed Oct 15 18:03:36 2003
++++ robcast/Makefile	Wed Oct 15 17:33:36 2003
+@@ -29,6 +29,16 @@
+ 	LIBRARIES = -lc -lm -lsocket -lnsl -L/usr/ucblib -lucb -lposix4 -lpthread ${BINDIR}/libmclalc.a ${LDPC_BINDIR}/libldpc.a
+ endif
+ 
++ifeq (${OS},freebsd)
++	# FreeBSD version
++	# MCL library requires -pthread
++	#
++	BINDIR = ../bin/freebsd
++	LDPC_BINDIR = ../../ldpc/bin/freebsd
++	LIBRARIES = -lm -pthread ${BINDIR}/libmclalc.a
++	#LIBRARIES = -lm -pthread ${BINDIR}/libmclalc.a ${LDPC_BINDIR}/libldpc.a
++endif
++
+ 
+ ###### Other variables ######
+ 
diff --git a/net/mcl/files/patch-test_abort.c b/net/mcl/files/patch-test_abort.c
new file mode 100644
index 000000000000..ad1116943ab0
--- /dev/null
+++ b/net/mcl/files/patch-test_abort.c
@@ -0,0 +1,13 @@
+--- check/alc/test_abort.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_abort.c	Wed Oct 15 17:10:42 2003
+@@ -26,6 +26,10 @@
+ #include <stdio.h>
+ #include <stdlib.h>			/* for exit */
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #include <io.h>
diff --git a/net/mcl/files/patch-test_demux_label1_rx.c b/net/mcl/files/patch-test_demux_label1_rx.c
new file mode 100644
index 000000000000..d172c016a3b0
--- /dev/null
+++ b/net/mcl/files/patch-test_demux_label1_rx.c
@@ -0,0 +1,13 @@
+--- check/alc/test_demux_label1_rx.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_demux_label1_rx.c	Wed Oct 15 17:13:17 2003
+@@ -26,6 +26,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/net/mcl/files/patch-test_demux_label1_tx.c b/net/mcl/files/patch-test_demux_label1_tx.c
new file mode 100644
index 000000000000..57e1efe5f915
--- /dev/null
+++ b/net/mcl/files/patch-test_demux_label1_tx.c
@@ -0,0 +1,13 @@
+--- check/alc/test_demux_label1_tx.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_demux_label1_tx.c	Wed Oct 15 17:12:56 2003
+@@ -25,6 +25,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/net/mcl/files/patch-test_dyn_tsi.c b/net/mcl/files/patch-test_dyn_tsi.c
new file mode 100644
index 000000000000..bf09722b074f
--- /dev/null
+++ b/net/mcl/files/patch-test_dyn_tsi.c
@@ -0,0 +1,13 @@
+--- check/alc/test_dyn_tsi.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_dyn_tsi.c	Wed Oct 15 17:13:37 2003
+@@ -30,6 +30,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/net/mcl/files/patch-test_multi_sessions1.c b/net/mcl/files/patch-test_multi_sessions1.c
new file mode 100644
index 000000000000..0b0af22dd2b1
--- /dev/null
+++ b/net/mcl/files/patch-test_multi_sessions1.c
@@ -0,0 +1,14 @@
+--- check/alc/test_multi_sessions1.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_multi_sessions1.c	Wed Oct 15 17:11:53 2003
+@@ -24,6 +24,11 @@
+  */
+ 
+ #include <stdio.h>
++
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/net/mcl/files/patch-test_multi_sessions2.c b/net/mcl/files/patch-test_multi_sessions2.c
new file mode 100644
index 000000000000..0033a72b5a86
--- /dev/null
+++ b/net/mcl/files/patch-test_multi_sessions2.c
@@ -0,0 +1,14 @@
+--- check/alc/test_multi_sessions2.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_multi_sessions2.c	Wed Oct 15 17:12:13 2003
+@@ -25,6 +25,11 @@
+  */
+ 
+ #include <stdio.h>
++
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #include <io.h>
diff --git a/net/mcl/files/patch-test_no_tx.c b/net/mcl/files/patch-test_no_tx.c
new file mode 100644
index 000000000000..e6f1e0b90d83
--- /dev/null
+++ b/net/mcl/files/patch-test_no_tx.c
@@ -0,0 +1,13 @@
+--- check/alc/test_no_tx.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_no_tx.c	Wed Oct 15 17:10:20 2003
+@@ -25,6 +25,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/net/mcl/files/patch-test_rebootable_client.c b/net/mcl/files/patch-test_rebootable_client.c
new file mode 100644
index 000000000000..9ee9725b77a9
--- /dev/null
+++ b/net/mcl/files/patch-test_rebootable_client.c
@@ -0,0 +1,13 @@
+--- check/alc/test_rebootable_client.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_rebootable_client.c	Wed Oct 15 17:18:38 2003
+@@ -35,6 +35,10 @@
+ #include <stdio.h>
+ #include <string.h>
+ 
++#ifdef FREEBSD
++#include <sys/time.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/net/mcl/files/patch-test_seq_of_tx_sessions.c b/net/mcl/files/patch-test_seq_of_tx_sessions.c
new file mode 100644
index 000000000000..31d967ca431e
--- /dev/null
+++ b/net/mcl/files/patch-test_seq_of_tx_sessions.c
@@ -0,0 +1,14 @@
+--- check/alc/test_seq_of_tx_sessions.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_seq_of_tx_sessions.c	Wed Oct 15 17:11:13 2003
+@@ -25,6 +25,11 @@
+  */
+ 
+ #include <stdio.h>
++
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/net/mcl/files/patch-test_several_fec_codecs.c b/net/mcl/files/patch-test_several_fec_codecs.c
new file mode 100644
index 000000000000..34da7be64644
--- /dev/null
+++ b/net/mcl/files/patch-test_several_fec_codecs.c
@@ -0,0 +1,13 @@
+--- check/alc/test_several_fec_codecs.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_several_fec_codecs.c	Wed Oct 15 17:05:40 2003
+@@ -28,6 +28,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/net/mcl/files/patch-test_vtm_rx.c b/net/mcl/files/patch-test_vtm_rx.c
new file mode 100644
index 000000000000..a0cf05b33306
--- /dev/null
+++ b/net/mcl/files/patch-test_vtm_rx.c
@@ -0,0 +1,13 @@
+--- check/alc/test_vtm_rx.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_vtm_rx.c	Wed Oct 15 17:14:28 2003
+@@ -27,6 +27,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/net/mcl/files/patch-test_vtm_tx.c b/net/mcl/files/patch-test_vtm_tx.c
new file mode 100644
index 000000000000..8d26b0f60d2d
--- /dev/null
+++ b/net/mcl/files/patch-test_vtm_tx.c
@@ -0,0 +1,13 @@
+--- check/alc/test_vtm_tx.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_vtm_tx.c	Wed Oct 15 17:14:02 2003
+@@ -25,6 +25,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/net/mcl/files/patch-test_wait_rx_receiver.c b/net/mcl/files/patch-test_wait_rx_receiver.c
new file mode 100644
index 000000000000..c03c4a4be206
--- /dev/null
+++ b/net/mcl/files/patch-test_wait_rx_receiver.c
@@ -0,0 +1,12 @@
+--- check/alc/test_wait_rx_receiver.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_wait_rx_receiver.c	Wed Oct 15 17:09:56 2003
+@@ -27,6 +27,9 @@
+ #include <stdio.h>
+ 
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
+ 
+ #ifdef WIN32
+ #include <winsock2.h>
diff --git a/net/mcl/files/patch-test_wait_rx_sender.c b/net/mcl/files/patch-test_wait_rx_sender.c
new file mode 100644
index 000000000000..694af55beed3
--- /dev/null
+++ b/net/mcl/files/patch-test_wait_rx_sender.c
@@ -0,0 +1,12 @@
+--- check/alc/test_wait_rx_sender.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_wait_rx_sender.c	Wed Oct 15 17:09:33 2003
+@@ -27,6 +27,9 @@
+ #include <stdio.h>
+ 
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
+ 
+ #ifdef WIN32
+ #include <winsock2.h>
diff --git a/net/mcl/files/patch-test_wait_tx.c b/net/mcl/files/patch-test_wait_tx.c
new file mode 100644
index 000000000000..b0b816cc8cd8
--- /dev/null
+++ b/net/mcl/files/patch-test_wait_tx.c
@@ -0,0 +1,13 @@
+--- check/alc/test_wait_tx.c.orig	Tue Jul 22 19:37:39 2003
++++ check/alc/test_wait_tx.c	Wed Oct 15 17:09:00 2003
+@@ -25,6 +25,10 @@
+ 
+ #include <stdio.h>
+ 
++#ifdef FREEBSD
++#include <sys/types.h>
++#endif
++
+ #ifdef WIN32
+ #include <winsock2.h>
+ #else
diff --git a/net/mcl/pkg-descr b/net/mcl/pkg-descr
new file mode 100644
index 000000000000..27a280bad227
--- /dev/null
+++ b/net/mcl/pkg-descr
@@ -0,0 +1,14 @@
+This is a port of MCLv3, an open source implementation of the ALC and 
+NORM Reliable Multicast Protocols.
+
+The MCLv3 project is an Open-Source GNU/GPL, multi-platform 
+implementation of the two major reliable multicast protocols being 
+standardized by the RMT IETF working group: ALC/LCT and NORM. It is 
+composed of a C/C++ library and several applications built on top of it 
+and provides an easy-to-use and integrated solution for reliable and 
+highly scalable multicast delivery of data.
+
+WWW: http://www.inrialpes.fr/planete/people/roca/mcl/mcl.html
+
+- Panagiotis Astithas
+past@noc.ntua.gr
diff --git a/net/mcl/pkg-plist b/net/mcl/pkg-plist
new file mode 100644
index 000000000000..cd9eeac40007
--- /dev/null
+++ b/net/mcl/pkg-plist
@@ -0,0 +1,4 @@
+bin/fcast
+bin/robcast_client
+bin/robcast_server
+lib/libmclalc.a
-- 
cgit