From: Jehan Monnier Date: Thu, 3 Jun 2010 06:45:24 +0000 (+0200) Subject: enable tcp transport X-Git-Url: http://sjero.net/git/?p=linphone;a=commitdiff_plain;h=9c828b17277311835e6ca9ff58c0d8243fd0a322 enable tcp transport --- diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index f62449e6..518d887b 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -646,7 +646,18 @@ static void sip_config_read(LinphoneCore *lc) } linphone_core_enable_ipv6(lc,ipv6); port=lp_config_get_int(lc->config,"sip","sip_port",5060); - linphone_core_set_sip_port(lc,port); + + tmpstr=lp_config_get_string(lc->config,"sip","transport","udp"); + if (strcmp("udp",tmpstr) == 0 ) { + lc->sip_conf.transport=SalTransportDatagram; + } else if (strcmp("tcp",tmpstr) == 0) { + lc->sip_conf.transport=SalTransportStream; + } else { + lc->sip_conf.transport=SalTransportDatagram; + ms_warning("unsupported transport, using udp"); + } + /*start listening on port*/ + linphone_core_set_sip_port(lc,port); tmpstr=lp_config_get_string(lc->config,"sip","contact",NULL); if (tmpstr==NULL || linphone_core_set_primary_contact(lc,tmpstr)==-1) { @@ -697,6 +708,11 @@ static void sip_config_read(LinphoneCore *lc) break; } } + + + + + lc->sip_conf.sdp_200_ack=lp_config_get_int(lc->config,"sip","sdp_200_ack",0); /*for tuning or test*/ lc->sip_conf.sdp_200_ack=lp_config_get_int(lc->config,"sip","sdp_200_ack",0); @@ -1482,9 +1498,11 @@ void linphone_core_set_sip_port(LinphoneCore *lc,int port) anyaddr="::0"; else anyaddr="0.0.0.0"; - err=sal_listen_port (lc->sal,anyaddr,port, SalTransportDatagram,FALSE); + + + err=sal_listen_port (lc->sal,anyaddr,port, lc->sip_conf.transport,FALSE); if (err<0){ - char *msg=ortp_strdup_printf("UDP port %i seems already in use ! Cannot initialize.",port); + char *msg=ortp_strdup_printf("Port %i seems already in use ! Cannot initialize.",port); ms_warning(msg); lc->vtable.display_warning(lc,msg); ms_free(msg); diff --git a/coreapi/private.h b/coreapi/private.h index c3e2960a..ff09be8d 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -242,6 +242,7 @@ struct _LinphoneFriend{ bool_t inc_subscribe_pending; }; + typedef struct sip_config { char *contact; @@ -261,6 +262,8 @@ typedef struct sip_config bool_t ping_with_options; bool_t auto_net_state_mon; unsigned int keepalive_period; /* interval in ms between keep alive messages sent to the proxy server*/ + SalTransport transport; + } sip_config_t; typedef struct rtp_config diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 97cde63c..463f0bcd 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -314,6 +314,17 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i bool_t ipv6; int proto=IPPROTO_UDP; + switch (tr) { + case SalTransportDatagram: + proto=IPPROTO_UDP; + break; + case SalTransportStream: + proto= IPPROTO_TCP; + break; + default: + ms_warning("unexpected proto, using datagram"); + } + if (ctx->running){ eXosip_quit(); eXosip_init(); @@ -325,8 +336,8 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i ipv6=strchr(addr,':')!=NULL; eXosip_enable_ipv6(ipv6); - if (tr!=SalTransportDatagram || is_secure){ - ms_fatal("SIP over TCP or TLS or DTLS is not supported yet."); + if (is_secure){ + ms_fatal("SIP over TLS or DTLS is not supported yet."); return -1; } err=eXosip_listen_addr(proto, addr, port, ipv6 ? PF_INET6 : PF_INET, 0); diff --git a/m4/exosip.m4 b/m4/exosip.m4 index fc1775a4..fb75e672 100644 --- a/m4/exosip.m4 +++ b/m4/exosip.m4 @@ -3,6 +3,13 @@ AC_DEFUN([LP_SETUP_EXOSIP],[ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([LP_CHECK_OSIP2]) + +case $target_os in + *darwin*) + OSIP_LIBS="$OSIP_LIBS -framework CoreFoundation -framework CFNetwork " + ;; +esac + dnl eXosip embeded stuff EXOSIP_CFLAGS="$OSIP_CFLAGS -DOSIP_MT " EXOSIP_LIBS="$OSIP_LIBS -leXosip2 " @@ -12,6 +19,8 @@ CPPFLAGS="$OSIP_CFLAGS $CPPFLAGS" AC_CHECK_HEADER([eXosip2/eXosip.h], ,AC_MSG_ERROR([Could not find eXosip2 headers !])) CPPFLAGS=$CPPFLAGS_save + + dnl check for eXosip2 libs LDFLAGS_save=$LDFLAGS LDFLAGS="$OSIP_LIBS $LDFLAGS"