r3547 - in trunk: build.d libmnetutil libmnetutil/include libmnetutil/include/libmnetutil libmnetutil/m4 libmnetutil/source libmsip libmsip/source libmsip/source/transports
mikma at minisip.org
mikma at minisip.org
Sun Dec 2 22:48:22 CET 2007
Author: mikma
Date: 2007-12-02 22:48:22 +0100 (Sun, 02 Dec 2007)
New Revision: 3547
Added:
trunk/libmnetutil/include/libmnetutil/SctpServerSocket.h
trunk/libmnetutil/include/libmnetutil/SctpSocket.h
trunk/libmnetutil/source/SctpServerSocket.cxx
trunk/libmnetutil/source/SctpSocket.cxx
trunk/libmsip/source/transports/SipTransportSctp.cxx
trunk/libmsip/source/transports/SipTransportSctp.h
trunk/libmsip/source/transports/SipTransportTlsSctp.cxx
trunk/libmsip/source/transports/SipTransportTlsSctp.h
Modified:
trunk/build.d/build.conf
trunk/libmnetutil/Makefile.am
trunk/libmnetutil/configure.ac
trunk/libmnetutil/include/Makefile.am
trunk/libmnetutil/include/libmnetutil/Socket.h
trunk/libmnetutil/m4/libmnetutil.m4
trunk/libmnetutil/source/IP4Address.cxx
trunk/libmnetutil/source/SocketServer.cxx
trunk/libmsip/Makefile.am
trunk/libmsip/configure.ac
trunk/libmsip/source/SipStack.cxx
trunk/libmsip/source/transports/SipTransport.cxx
Log:
* Add support for SCTP sockets, and SCTP SIP and SIPS transports.
* Add sctp libmnetutil flag to the build system config.
* Clean-up unused includes in SipStack.cxx.
Modified: trunk/build.d/build.conf
===================================================================
--- trunk/build.d/build.conf 2007-12-02 17:57:24 UTC (rev 3546)
+++ trunk/build.d/build.conf 2007-12-02 21:48:22 UTC (rev 3547)
@@ -76,6 +76,7 @@
%common_params,
ipv6 => 1, # enables IPV6 support
ldap => undef, # enables LDAP support
+ sctp => undef, # enables SCTP support
);
my %libmikey_params = (
Modified: trunk/libmnetutil/Makefile.am
===================================================================
--- trunk/libmnetutil/Makefile.am 2007-12-02 17:57:24 UTC (rev 3546)
+++ trunk/libmnetutil/Makefile.am 2007-12-02 21:48:22 UTC (rev 3547)
@@ -52,6 +52,8 @@
source/SocketServer.cxx \
source/TCPSocket.cxx \
source/TcpServerSocket.cxx \
+ source/SctpSocket.cxx \
+ source/SctpServerSocket.cxx \
source/NetUtil.cxx \
source/UDPSocket.cxx \
source/DatagramSocket.cxx \
Modified: trunk/libmnetutil/configure.ac
===================================================================
--- trunk/libmnetutil/configure.ac 2007-12-02 17:57:24 UTC (rev 3546)
+++ trunk/libmnetutil/configure.ac 2007-12-02 21:48:22 UTC (rev 3547)
@@ -40,6 +40,16 @@
AM_CONDITIONAL(ENABLE_LDAP, test "${ENABLE_LDAP}" = "yes" )
AC_SUBST(LDAP_LIBS)
+AC_ARG_ENABLE(sctp,
+ AS_HELP_STRING([--enable-sctp],
+ [Enable SCTP]),,[enable_sctp=no])
+
+if test "${enable_ldap}" = "yes"; then
+ AC_DEFINE(ENABLE_SCTP, [], [Define to 1 if you have SCTP support])
+ have_sctp=yes
+fi
+AM_CONDITIONAL(ENABLE_SCTP, test "${have_sctp}" = "yes" )
+
AG_CHECK_POSIX_REGCOMP
AM_CONDITIONAL(HAVE_POSIX_REGCOMP, test "${ag_cv_posix_regcomp}" = "yes")
Modified: trunk/libmnetutil/include/Makefile.am
===================================================================
--- trunk/libmnetutil/include/Makefile.am 2007-12-02 17:57:24 UTC (rev 3546)
+++ trunk/libmnetutil/include/Makefile.am 2007-12-02 21:48:22 UTC (rev 3547)
@@ -20,6 +20,8 @@
libmnetutil/StreamSocket.h \
libmnetutil/TCPSocket.h \
libmnetutil/TcpServerSocket.h \
+ libmnetutil/SctpSocket.h \
+ libmnetutil/SctpServerSocket.h \
libmnetutil/NetUtil.h \
libmnetutil/UDPSocket.h \
libmnetutil/DatagramSocket.h \
Added: trunk/libmnetutil/include/libmnetutil/SctpServerSocket.h
===================================================================
--- trunk/libmnetutil/include/libmnetutil/SctpServerSocket.h (rev 0)
+++ trunk/libmnetutil/include/libmnetutil/SctpServerSocket.h 2007-12-02 21:48:22 UTC (rev 3547)
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2007 Mikael Magnusson
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/*
+ * Authors: Mikael Magnusson <mikma at users.sourceforge.net>
+ */
+
+#ifndef SCTP_SERVER_SOCKET_H
+#define SCTP_SERVER_SOCKET_H
+
+#include<libmnetutil/libmnetutil_config.h>
+
+#include<libmnetutil/ServerSocket.h>
+#include<libmnetutil/StreamSocket.h>
+
+class LIBMNETUTIL_API SctpServerSocket : public ServerSocket {
+ public:
+ static SctpServerSocket *create( int32_t listenport,
+ bool useIpv6=false,
+ int32_t backlog=25 );
+
+ // ServerSocket
+ virtual MRef<StreamSocket *> createSocket( int32_t fd,
+ struct sockaddr *sa,
+ int32_t salen );
+
+ // MObject
+ virtual std::string getMemObjectType() const {return "SctpServerSocket";}
+
+ protected:
+ SctpServerSocket( const IPAddress &addr );
+};
+
+#endif
Property changes on: trunk/libmnetutil/include/libmnetutil/SctpServerSocket.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/libmnetutil/include/libmnetutil/SctpSocket.h
===================================================================
--- trunk/libmnetutil/include/libmnetutil/SctpSocket.h (rev 0)
+++ trunk/libmnetutil/include/libmnetutil/SctpSocket.h 2007-12-02 21:48:22 UTC (rev 3547)
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2007 Mikael Magnusson
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/*
+ * Authors: Mikael Magnusson <mikma at users.sourceforge.net>
+ */
+
+#ifndef SCTP_SOCKET_H
+#define SCTP_SOCKET_H
+
+#include<libmnetutil/libmnetutil_config.h>
+
+#include<libmnetutil/StreamSocket.h>
+#include<libmnetutil/IPAddress.h>
+
+class LIBMNETUTIL_API SctpSocket : public StreamSocket {
+ public:
+ SctpSocket( const IPAddress &addr, int32_t port );
+ SctpSocket(int32_t fd_, struct sockaddr * addr, int32_t addr_len);
+
+ virtual ~SctpSocket();
+
+ // DatagramSocket
+ virtual std::string getMemObjectType() const {return "SctpSocket";}
+};
+#endif
Property changes on: trunk/libmnetutil/include/libmnetutil/SctpSocket.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/libmnetutil/include/libmnetutil/Socket.h
===================================================================
--- trunk/libmnetutil/include/libmnetutil/Socket.h 2007-12-02 17:57:24 UTC (rev 3546)
+++ trunk/libmnetutil/include/libmnetutil/Socket.h 2007-12-02 21:48:22 UTC (rev 3547)
@@ -30,6 +30,8 @@
#define SOCKET_TYPE_TCP 0x11
#define SOCKET_TYPE_TLS 0x12
#define SOCKET_TYPE_TLSSRP 0x13
+#define SOCKET_TYPE_SCTP 0x14
+#define SOCKET_TYPE_TLS_SCTP 0x15
#define SOCKET_TYPE_UDP 0x20
Modified: trunk/libmnetutil/m4/libmnetutil.m4
===================================================================
--- trunk/libmnetutil/m4/libmnetutil.m4 2007-12-02 17:57:24 UTC (rev 3546)
+++ trunk/libmnetutil/m4/libmnetutil.m4 2007-12-02 21:48:22 UTC (rev 3547)
@@ -62,3 +62,33 @@
])
# End of AM_MINISIP_CHECK_LIBMNETUTIL
#
+
+# AM_MINISIP_CHECK_LIBMNETUTIL_SCTP([ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
+# ------------------------------------
+AC_DEFUN([AM_MINISIP_CHECK_LIBMNETUTIL_SCTP],[
+ AC_REQUIRE([AM_MINISIP_CHECK_LIBMNETUTIL]) dnl
+ mnetutil_sctp_found=yes
+
+dnl Checks for SCTP support in libmnetutil
+ mnetutil_save_LIBS="$LIBS"
+ mnetutil_save_LDFLAGS="$LDFLAGS"
+ mnetutil_save_CPPFLAGS="$CPPFLAGS"
+ LDFLAGS="$LDFLAGS $LIBMNETUTIL_LDFLAGS"
+ LIBS="$MINISIP_LIBS $LIBS"
+ CPPFLAGS="$CPPFLAGS $MINISIP_CFLAGS"
+ AM_MINISIP_CHECK_WINFUNCS(["new SctpSocket(0,0,0)"],,[mnetutil_sctp_found=no],[dnl
+#include<libmnetutil/SctpSocket.h>
+])
+ LIBS="$mnetutil_save_LIBS"
+ LDFLAGS="$mnetutil_save_LDFLAGS"
+ CPPFLAGS="$mnetutil_save_CPPFLAGS"
+
+ if test "${mnetutil_sctp_found}" = "yes"; then
+ AC_DEFINE([HAVE_SCTP], 1, [Define to 1 if you have libmnetutil with SCTP support])
+ ifelse([$1], , :, [$1])
+ else
+ ifelse([$2], , :, [$2])
+ fi
+ ])
+# End of AM_MINISIP_CHECK_LIBMNETUTIL_SCTP
+#
Modified: trunk/libmnetutil/source/IP4Address.cxx
===================================================================
--- trunk/libmnetutil/source/IP4Address.cxx 2007-12-02 17:57:24 UTC (rev 3546)
+++ trunk/libmnetutil/source/IP4Address.cxx 2007-12-02 21:48:22 UTC (rev 3547)
@@ -216,9 +216,10 @@
int error = ::connect(socket.getFd(), (struct sockaddr *)&sin, sizeof(sin));
if (error < 0){
+ int failedErrno = errno;
merror("connect");
socket.close();
- throw ConnectFailed( error );
+ throw ConnectFailed( failedErrno );
}
}
Added: trunk/libmnetutil/source/SctpServerSocket.cxx
===================================================================
--- trunk/libmnetutil/source/SctpServerSocket.cxx (rev 0)
+++ trunk/libmnetutil/source/SctpServerSocket.cxx 2007-12-02 21:48:22 UTC (rev 3547)
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2007 Mikael Magnusson
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/*
+ * Authors: Mikael Magnusson <mikma at users.sourceforge.net>
+ */
+
+#include<config.h>
+
+#include<libmnetutil/SctpServerSocket.h>
+#include<libmnetutil/SctpSocket.h>
+
+using namespace std;
+
+SctpServerSocket::SctpServerSocket( const IPAddress &addr ):
+ ServerSocket( addr.getAddressFamily(),
+ SOCK_STREAM, IPPROTO_SCTP )
+{
+ type = SOCKET_TYPE_SCTP;
+}
+
+SctpServerSocket *SctpServerSocket::create( int32_t listenport, bool useIpv6,
+ int32_t backlog )
+{
+ MRef<IPAddress*> addr;
+
+ if( useIpv6 )
+ addr = IPAddress::create("::", true);
+ else
+ addr = IPAddress::create("0.0.0.0", false);
+
+ SctpServerSocket* sock = new SctpServerSocket( **addr );
+ sock->listen( **addr, listenport, backlog );
+ return sock;
+}
+
+MRef<StreamSocket *> SctpServerSocket::createSocket( int32_t fd_,
+ struct sockaddr *sa,
+ int32_t salen )
+{
+ return new SctpSocket( fd_, sa, salen );
+}
Property changes on: trunk/libmnetutil/source/SctpServerSocket.cxx
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/libmnetutil/source/SctpSocket.cxx
===================================================================
--- trunk/libmnetutil/source/SctpSocket.cxx (rev 0)
+++ trunk/libmnetutil/source/SctpSocket.cxx 2007-12-02 21:48:22 UTC (rev 3547)
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2007 Mikael Magnusson
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/*
+ * Authors: Mikael Magnusson <mikma at users.sourceforge.net>
+ */
+
+#include<config.h>
+
+#include<libmnetutil/NetworkException.h>
+#include<libmnetutil/SctpSocket.h>
+
+using namespace std;
+
+SctpSocket::SctpSocket( const IPAddress &addr, int32_t port ){
+ type = SOCKET_TYPE_SCTP;
+ peerAddress = addr.clone();
+ peerPort = port;
+
+ if ((fd = (int32_t)::socket(addr.getProtocolFamily(), SOCK_STREAM, IPPROTO_SCTP ))<0){
+ throw SocketFailed( errno );
+ }
+ int32_t on=1;
+#ifndef WIN32
+ setsockopt(fd,SOL_SOCKET,SO_REUSEADDR, (void *) (&on),sizeof(on));
+#else
+ setsockopt(fd,SOL_SOCKET,SO_REUSEADDR, (const char *) (&on),sizeof(on));
+#endif
+
+ addr.connect(*this, port);
+}
+
+SctpSocket::SctpSocket(int32_t fd_, struct sockaddr * addr, int32_t addr_len){
+ type = SOCKET_TYPE_SCTP;
+ fd = fd_;
+ peerAddress = IPAddress::create( addr, addr_len );
+ peerPort = peerAddress->getPort();
+}
+
+SctpSocket::~SctpSocket(){
+}
Property changes on: trunk/libmnetutil/source/SctpSocket.cxx
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/libmnetutil/source/SocketServer.cxx
===================================================================
--- trunk/libmnetutil/source/SocketServer.cxx 2007-12-02 17:57:24 UTC (rev 3546)
+++ trunk/libmnetutil/source/SocketServer.cxx 2007-12-02 21:48:22 UTC (rev 3547)
@@ -85,6 +85,7 @@
SocketServer::~SocketServer()
{
stop();
+ join();
}
void SocketServer::start()
Modified: trunk/libmsip/Makefile.am
===================================================================
--- trunk/libmsip/Makefile.am 2007-12-02 17:57:24 UTC (rev 3546)
+++ trunk/libmsip/Makefile.am 2007-12-02 21:48:22 UTC (rev 3547)
@@ -24,6 +24,13 @@
source/transports/SipTransportDtlsUdp.cxx
endif HAVE_DTLS
+if HAVE_SCTP
+msip_sctp_src = source/transports/SipTransportSctp.h \
+ source/transports/SipTransportSctp.cxx \
+ source/transports/SipTransportTlsSctp.h \
+ source/transports/SipTransportTlsSctp.cxx
+endif HAVE_SCTP
+
msip_src = source/SipDialogConfig.cxx \
source/SipAuthenticationDigest.cxx \
source/SipStack.cxx \
@@ -68,6 +75,7 @@
source/transports/SipTransportTls.h \
source/transports/SipTransportTls.cxx \
$(msip_dtls_src) \
+ $(msip_sctp_src) \
source/dialogs/SipTransitionUtils.cxx \
source/dialogs/SipDialog.cxx \
source/dialogs/SipDialogRegister.cxx \
Modified: trunk/libmsip/configure.ac
===================================================================
--- trunk/libmsip/configure.ac 2007-12-02 17:57:24 UTC (rev 3546)
+++ trunk/libmsip/configure.ac 2007-12-02 21:48:22 UTC (rev 3547)
@@ -45,6 +45,10 @@
AM_MINISIP_CHECK_LIBMCRYPTO([0.3.0])
AM_MINISIP_CHECK_COMPLETE
+dnl Checks for SCTP support in libmnetutil
+AM_MINISIP_CHECK_LIBMNETUTIL_SCTP([have_sctp=yes], [have_sctp=no])
+AM_CONDITIONAL(HAVE_SCTP, test "${have_sctp}" = "yes")
+
dnl Checks for DTLS support in libmcrypto
AM_MINISIP_CHECK_LIBMCRYPTO_DTLS([have_dtls=yes], [have_dtls=no])
AM_CONDITIONAL(HAVE_DTLS, test "${have_dtls}" = "yes")
Modified: trunk/libmsip/source/SipStack.cxx
===================================================================
--- trunk/libmsip/source/SipStack.cxx 2007-12-02 17:57:24 UTC (rev 3546)
+++ trunk/libmsip/source/SipStack.cxx 2007-12-02 21:48:22 UTC (rev 3547)
@@ -27,42 +27,6 @@
#include"SipLayerTransport.h"
#include"SipCommandDispatcher.h"
#include<libmsip/SipTransport.h>
-#include<libmsip/SipMessageContentIM.h>
-#include<libmsip/SipMessageContentMime.h>
-#include<libmutil/Timestamp.h>
-
-#include<libmsip/SipHeaderContact.h>
-#include<libmsip/SipHeaderUnknown.h>
-#include<libmsip/SipHeaderContentLength.h>
-#include<libmsip/SipHeaderUserAgent.h>
-#include<libmsip/SipHeaderContentType.h>
-#include<libmsip/SipHeaderVia.h>
-#include<libmsip/SipHeaderCSeq.h>
-#include<libmsip/SipHeaderWarning.h>
-#include<libmsip/SipHeaderEvent.h>
-#include<libmsip/SipHeaderExpires.h>
-#include<libmsip/SipHeaderFrom.h>
-#include<libmsip/SipHeader.h>
-#include<libmsip/SipHeaderMaxForwards.h>
-#include<libmsip/SipHeaderProxyAuthenticate.h>
-#include<libmsip/SipHeaderProxyAuthorization.h>
-#include<libmsip/SipHeaderAcceptContact.h>
-#include<libmsip/SipHeaderRecordRoute.h>
-#include<libmsip/SipHeaderAccept.h>
-#include<libmsip/SipHeaderRAck.h>
-#include<libmsip/SipHeaderRSeq.h>
-#include<libmsip/SipHeaderRoute.h>
-#include<libmsip/SipHeaderReferTo.h>
-#include<libmsip/SipHeaderAuthorization.h>
-#include<libmsip/SipHeaderRequire.h>
-#include<libmsip/SipHeaderSubject.h>
-#include<libmsip/SipHeaderSupported.h>
-#include<libmsip/SipHeaderUnsupported.h>
-#include<libmsip/SipHeaderCallID.h>
-#include<libmsip/SipHeaderTo.h>
-#include<libmsip/SipHeaderWWWAuthenticate.h>
-#include<libmsip/SipCommandString.h>
-
#include<libmutil/massert.h>
#include<libmutil/dbg.h>
Modified: trunk/libmsip/source/transports/SipTransport.cxx
===================================================================
--- trunk/libmsip/source/transports/SipTransport.cxx 2007-12-02 17:57:24 UTC (rev 3546)
+++ trunk/libmsip/source/transports/SipTransport.cxx 2007-12-02 21:48:22 UTC (rev 3547)
@@ -27,6 +27,8 @@
#include"SipTransportTcp.h"
#include"SipTransportTls.h"
#include"SipTransportDtlsUdp.h"
+#include"SipTransportSctp.h"
+#include"SipTransportTlsSctp.h"
#include<algorithm>
@@ -65,6 +67,10 @@
#ifdef HAVE_DTLS
registerPlugin( new SipTransportDtlsUdp( NULL ) );
#endif
+#ifdef HAVE_SCTP
+ registerPlugin( new SipTransportSctp( NULL ) );
+ registerPlugin( new SipTransportTlsSctp( NULL ) );
+#endif
}
list<string> SipTransportRegistry::getNaptrServices( bool secureOnly ) const{
@@ -119,6 +125,7 @@
}
}
+ mdbg << "SipTransport: transport not found!!! = '" << lcProt << "'" << endl;
return NULL;
}
Added: trunk/libmsip/source/transports/SipTransportSctp.cxx
===================================================================
--- trunk/libmsip/source/transports/SipTransportSctp.cxx (rev 0)
+++ trunk/libmsip/source/transports/SipTransportSctp.cxx 2007-12-02 21:48:22 UTC (rev 3547)
@@ -0,0 +1,87 @@
+/*
+ Copyright (C) 2005, 2004 Erik Eliasson, Johan Bilien
+ Copyright (C) 2005-2007 Mikael Magnusson
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/*
+ * Authors: Erik Eliasson <eliasson at it.kth.se>
+ * Johan Bilien <jobi at via.ecp.fr>
+ * Mikael Magnusson <mikma at users.sourceforge.net>
+*/
+
+#include<config.h>
+#include<libmnetutil/NetworkException.h>
+#include<libmnetutil/SctpSocket.h>
+#include<libmnetutil/SctpServerSocket.h>
+#include"SipTransportSctp.h"
+
+static std::list<std::string> pluginList;
+static int initialized;
+
+using namespace std;
+
+extern "C" LIBMSIP_API
+std::list<std::string> *msctp_LTX_listPlugins( MRef<Library*> lib ){
+ if( !initialized ){
+ pluginList.push_back("getPlugin");
+ initialized = true;
+ }
+
+ return &pluginList;
+}
+
+extern "C" LIBMSIP_API
+MPlugin * msctp_LTX_getPlugin( MRef<Library*> lib ){
+ return new SipTransportSctp( lib );
+}
+
+
+SipTransportSctp::SipTransportSctp( MRef<Library*> lib ) : SipTransport( lib ){
+}
+
+SipTransportSctp::~SipTransportSctp(){
+}
+
+
+
+MRef<SipSocketServer *> SipTransportSctp::createServer( MRef<SipSocketReceiver*> receiver, bool ipv6, const string &ipString, int32_t &prefPort, MRef<CertificateSet *> cert_db, MRef<CertificateChain *> certChain )
+{
+ MRef<ServerSocket *> sock;
+ MRef<SipSocketServer *> server;
+ int32_t port = prefPort;
+
+ try {
+ sock = SctpServerSocket::create( port, ipv6 );
+ }
+ catch ( const BindFailed &bf ){
+ sock = SctpServerSocket::create( 0, ipv6 );
+ }
+
+ server = new StreamSocketServer( receiver, sock );
+ server->setExternalIp( ipString );
+ prefPort = sock->getPort();
+
+ return server;
+}
+
+MRef<StreamSocket *> SipTransportSctp::connect( const IPAddress &addr, uint16_t port, MRef<CertificateSet *> cert_db, MRef<CertificateChain *> certChain ){
+ return new SctpSocket( addr, port );
+}
+
+uint32_t SipTransportSctp::getVersion() const{
+ return 0x00000001;
+}
Property changes on: trunk/libmsip/source/transports/SipTransportSctp.cxx
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/libmsip/source/transports/SipTransportSctp.h
===================================================================
--- trunk/libmsip/source/transports/SipTransportSctp.h (rev 0)
+++ trunk/libmsip/source/transports/SipTransportSctp.h 2007-12-02 21:48:22 UTC (rev 3547)
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2006-2007 Mikael Magnusson
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/*
+ * Authors: Mikael Magnusson <mikma at users.sourceforge.net>
+*/
+
+#ifndef SIP_TRANSPORT_SCTP_H
+#define SIP_TRANSPORT_SCTP_H
+
+#include<libmsip/libmsip_config.h>
+
+#include<string>
+#include<libmsip/SipTransport.h>
+#include<libmnetutil/SctpSocket.h>
+
+class SipTransportSctp: public SipTransport{
+ public:
+ SipTransportSctp( MRef<Library *> lib );
+ virtual ~SipTransportSctp();
+
+ // SipTransport
+ virtual bool isSecure() const { return false; }
+
+ virtual std::string getProtocol() const { return "sctp"; }
+
+ virtual std::string getViaProtocol() const { return "SCTP"; }
+
+ virtual int32_t getSocketType() const { return SOCKET_TYPE_SCTP; }
+
+ virtual std::string getNaptrService() const { return "SIP+D2S"; }
+
+ virtual MRef<SipSocketServer *> createServer( MRef<SipSocketReceiver*> receiver, bool ipv6, const std::string &ipString, int32_t &prefPort, MRef<CertificateSet *> cert_db = NULL, MRef<CertificateChain *> certChain = NULL );
+
+ virtual MRef<StreamSocket *> connect( const IPAddress &addr, uint16_t port, MRef<CertificateSet *> cert_db = NULL, MRef<CertificateChain *> certChain = NULL );
+
+ // MPlugin
+ virtual std::string getName() const { return "SCTP"; }
+
+ virtual uint32_t getVersion() const;
+
+ virtual std::string getDescription() const { return "SIP Transport SCTP"; };
+
+ // MObject
+ virtual std::string getMemObjectType() const { return getName(); }
+};
+
+#endif
Property changes on: trunk/libmsip/source/transports/SipTransportSctp.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/libmsip/source/transports/SipTransportTlsSctp.cxx
===================================================================
--- trunk/libmsip/source/transports/SipTransportTlsSctp.cxx (rev 0)
+++ trunk/libmsip/source/transports/SipTransportTlsSctp.cxx 2007-12-02 21:48:22 UTC (rev 3547)
@@ -0,0 +1,105 @@
+/*
+ Copyright (C) 2005, 2004 Erik Eliasson, Johan Bilien
+ Copyright (C) 2005-2007 Mikael Magnusson
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/*
+ * Authors: Erik Eliasson <eliasson at it.kth.se>
+ * Johan Bilien <jobi at via.ecp.fr>
+ * Mikael Magnusson <mikma at users.sourceforge.net>
+*/
+
+/*
+ * FIXME use ordered delivery!
+ */
+
+#include<config.h>
+#include<libmnetutil/NetworkException.h>
+#include<libmnetutil/SctpSocket.h>
+#include<libmnetutil/SctpServerSocket.h>
+#include<libmcrypto/TlsSocket.h>
+#include<libmcrypto/TlsServerSocket.h>
+#include"SipTransportTlsSctp.h"
+
+static std::list<std::string> pluginList;
+static int initialized;
+
+using namespace std;
+
+extern "C" LIBMSIP_API
+std::list<std::string> *mtlssctp_LTX_listPlugins( MRef<Library*> lib ){
+ if( !initialized ){
+ pluginList.push_back("getPlugin");
+ initialized = true;
+ }
+
+ return &pluginList;
+}
+
+extern "C" LIBMSIP_API
+MPlugin * mtlssctp_LTX_getPlugin( MRef<Library*> lib ){
+ return new SipTransportTlsSctp( lib );
+}
+
+
+SipTransportTlsSctp::SipTransportTlsSctp( MRef<Library*> lib ) : SipTransport( lib ){
+}
+
+SipTransportTlsSctp::~SipTransportTlsSctp(){
+}
+
+
+
+MRef<SipSocketServer *> SipTransportTlsSctp::createServer( MRef<SipSocketReceiver*> receiver, bool ipv6, const string &ipString, int32_t &prefPort, MRef<CertificateSet *> cert_db, MRef<CertificateChain *> certChain )
+{
+ MRef<ServerSocket *> ssock;
+ MRef<ServerSocket *> sock;
+ MRef<SipSocketServer *> server;
+ int32_t port = prefPort;
+
+ if( certChain.isNull() || certChain->getFirst().isNull() ){
+ merr << "You need a personal certificate to run "
+ "a TLS server. Please specify one in "
+ "the certificate settings. minisip will "
+ "now disable the TLS server." << endl;
+ return NULL;
+ }
+
+ try {
+ ssock = SctpServerSocket::create( port, ipv6 );
+ }
+ catch ( const BindFailed &bf ){
+ ssock = SctpServerSocket::create( 0, ipv6 );
+ }
+
+ sock = TLSServerSocket::create( ssock, certChain->getFirst(),
+ cert_db );
+ server = new StreamSocketServer( receiver, sock );
+ server->setExternalIp( ipString );
+ prefPort = ssock->getPort();
+
+ return server;
+}
+
+MRef<StreamSocket *> SipTransportTlsSctp::connect( const IPAddress &addr, uint16_t port, MRef<CertificateSet *> cert_db, MRef<CertificateChain *> certChain ){
+ MRef<StreamSocket*> sock = new SctpSocket( addr, port );
+ return TLSSocket::connect( sock, certChain->getFirst(), cert_db );
+}
+
+uint32_t SipTransportTlsSctp::getVersion() const{
+ return 0x00000001;
+}
Property changes on: trunk/libmsip/source/transports/SipTransportTlsSctp.cxx
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/libmsip/source/transports/SipTransportTlsSctp.h
===================================================================
--- trunk/libmsip/source/transports/SipTransportTlsSctp.h (rev 0)
+++ trunk/libmsip/source/transports/SipTransportTlsSctp.h 2007-12-02 21:48:22 UTC (rev 3547)
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2006-2007 Mikael Magnusson
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/*
+ * Authors: Mikael Magnusson <mikma at users.sourceforge.net>
+*/
+
+#ifndef SIP_TRANSPORT_TLS_SCTP_H
+#define SIP_TRANSPORT_TLS_SCTP_H
+
+#include<libmsip/libmsip_config.h>
+
+#include<string>
+#include<libmsip/SipTransport.h>
+#include<libmnetutil/SctpSocket.h>
+
+class SipTransportTlsSctp: public SipTransport{
+ public:
+ SipTransportTlsSctp( MRef<Library *> lib );
+ virtual ~SipTransportTlsSctp();
+
+ // SipTransport
+ virtual bool isSecure() const { return true; }
+
+ virtual std::string getProtocol() const { return "sctp"; }
+
+ virtual std::string getViaProtocol() const { return "TLS-SCTP"; }
+
+ virtual int32_t getSocketType() const { return SOCKET_TYPE_TLS_SCTP; }
+
+ virtual std::string getNaptrService() const { return "SIPS+D2S"; }
+
+ virtual MRef<SipSocketServer *> createServer( MRef<SipSocketReceiver*> receiver, bool ipv6, const std::string &ipString, int32_t &prefPort, MRef<CertificateSet *> cert_db = NULL, MRef<CertificateChain *> certChain = NULL );
+
+ virtual MRef<StreamSocket *> connect( const IPAddress &addr, uint16_t port, MRef<CertificateSet *> cert_db = NULL, MRef<CertificateChain *> certChain = NULL );
+
+ // MPlugin
+ virtual std::string getName() const { return "TLS-SCTP"; }
+
+ virtual uint32_t getVersion() const;
+
+ virtual std::string getDescription() const { return "SIPS Transport TLS-SCTP"; };
+
+ // MObject
+ virtual std::string getMemObjectType() const { return getName(); }
+};
+
+#endif
Property changes on: trunk/libmsip/source/transports/SipTransportTlsSctp.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
More information about the Minisip-devel
mailing list