Commit e4b65e10 authored by Simon Morlat's avatar Simon Morlat
Browse files

Merge remote-tracking branch 'origin/master' into dev_http

Conflicts:
	include/belle-sip/sip-uri.h
	src/Makefile.am
	tester/belle_sip_message_tester.c
parents 32441a97 b447a7bd
cmake_minimum_required(VERSION 2.6)
project(BELLESIP C)
if(NOT ANTLR3_ROOT_DIR)
set(ANTLR3_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../antlr3)
endif()
if(NOT ANTLR3C_INCLUDE_DIR)
set(ANTLR3C_INCLUDE_DIR ${ANTLR3_ROOT_DIR}/runtime/C/include)
endif()
if(NOT POLARSSL_INCLUDE_DIR)
set(POLARSSL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../polarssl/include)
endif()
if(NOT ORTP_ROOT_DIR)
set(ORTP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../linphone/oRTP)
endif()
include_directories(
include/
${CMAKE_CURRENT_BINARY_DIR}/src/
src/
${CMAKE_INSTALL_PREFIX}/include
)
if(USE_INSTALLED_COMPONENTS)
include_directories(${CMAKE_INSTALL_PREFIX}/include)
else()
include_directories(
${ANTLR3C_INCLUDE_DIR}
${POLARSSL_INCLUDE_DIR}
)
if(WIN32)
include_directories(${ORTP_ROOT_DIR}/build/vsx/oRTP/oRTP/)
endif(WIN32)
endif()
add_subdirectory(include)
add_subdirectory(src)
if(INSTALL_COMPONENT_IN_POSTBUILD)
add_install_target(INSTALL_libbellesip COMP_libbellesip libbellesip)
endif()
......@@ -15,6 +15,8 @@ Source0: %{name}-%{version}.tar.gz
%description
Belle-sip is an object oriented c written SIP stack used by Linphone.
BuildRequires: antlr3-tool antlr3-C-devel
%package devel
Summary: Development libraries for belle-sip
Group: Development/Libraries
......
......@@ -27,6 +27,15 @@ AM_PROG_CC_C_O
dnl AC_PROG_CC_C99
LT_INIT(win32-dll disable-static)
case "$target" in
#macosx 64 bits
x86_64-apple-darwin*)
LIBS="$LIBS -mmacosx-version-min=10.6"
CXXFLAGS="$CXXFLAGS -mmacosx-version-min=10.6"
CFLAGS="$CFLAGS -mmacosx-version-min=10.6"
;;
esac
dnl Workaround for mingw, whose compiler doesn't check in /usr/include ...
case "$target_os" in
*mingw*)
......@@ -37,6 +46,7 @@ case "$target_os" in
fi
fi
;;
esac
if test -f /etc/debian_version ; then
......@@ -100,15 +110,30 @@ dnl check antlr headers
CPPFLAGS_save=$CPPFLAGS
CPPFLAGS="$ANTLR_CFLAGS $CPPFLAGS"
AC_CHECK_HEADERS([antlr3.h], [found_antlr3=yes])
AC_CHECK_DECL( [antlr3StringStreamNew]
AC_CHECK_DECL([antlr3StringStreamNew]
,[AC_DEFINE(HAVE_ANTLR_STRING_STREAM_NEW,1,[Defined when antlr 3.4 api is detected])]
,[foo=bar]
,[#include <antlr3.h>])
AC_CHECK_DECL( [res_ndestroy]
,[AC_DEFINE(HAVE_RESINIT,1,[Defined when res_ninit api is available]) LIBS="$LIBS -lresolv"]
libresolv_have_res_get_servers=no
resolv_h_hav_res_ndestroy=no
LIBS_save=$LIBS
LIBS="$LIBS -lresolv"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <resolv.h>]],
[[res_getservers(NULL,NULL,0)]])]
,[libresolv_have_res_get_servers=yes
AC_MSG_NOTICE([res_getservers usable])]
,[LIBS=$LIBS_save
AC_MSG_WARN([res_getservers not usable])])
AC_CHECK_DECL([res_ndestroy]
,[resolv_h_hav_res_ndestroy=yes]
,[foo=bar]
,[#include <resolv.h>])
if test "${libresolv_have_res_get_servers}${resolv_h_hav_res_ndestroy}" == "yesyes" ; then
AC_DEFINE(HAVE_RESINIT,1,[Defined when res_ninit api is available])
fi
CPPFLAGS=$CPPFLAGS_save
if test "$found_antlr3" != "yes" ; then
......
file(GLOB HEADER_FILES "belle-sip/*.h")
install(FILES ${HEADER_FILES}
COMPONENT COMP_libbellesip
DESTINATION include/belle-sip
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2013 Belledonne Communications SARL, Grenoble, France
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
find_library(LIBANTLR3C NAMES antlr3c)
find_library(LIBPOLARSSL NAMES polarssl)
set(SDP_GENERATED_SOURCE_FILES
${CMAKE_CURRENT_BINARY_DIR}/belle_sdpLexer.c
${CMAKE_CURRENT_BINARY_DIR}/belle_sdpLexer.h
......@@ -64,28 +67,28 @@ add_definitions(
-DBELLESIP_INTERNAL_EXPORTS
-DHAVE_POLARSSL
-DHAVE_ANTLR_STRING_STREAM_NEW
-DHAVE_COMPILER_TLS
-DPACKAGE_VERSION="1.2.4"
)
if(WIN32)
set(LIBS ws2_32)
endif(WIN32)
set(LIBS ${LIBS} libantlr3c libpolarssl)
add_library(libbellesip SHARED ${SOURCE_FILES})
set_target_properties(libbellesip PROPERTIES VERSION 1.2.4 SOVERSION 1)
set(LIBS ${LIBS} ${LIBANTLR3C} ${LIBPOLARSSL})
target_link_libraries(libbellesip ${LIBS})
add_library(bellesip SHARED ${SOURCE_FILES})
set_target_properties(bellesip PROPERTIES VERSION 1.2.4 SOVERSION 1)
install(TARGETS libbellesip
COMPONENT COMP_libbellesip
DESTINATION ${LIB_INSTALL_DIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
target_link_libraries(bellesip ${LIBS})
if(USE_INSTALLED_COMPONENTS)
add_dependencies(libbellesip
INSTALL_libantlr3c
INSTALL_libpolarssl
INSTALL_libortp)
install(TARGETS bellesip
DESTINATION ${LIB_INSTALL_DIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
if(WIN32)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/bellesip.pdb
DESTINATION ${LIB_INSTALL_DIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
endif(WIN32)
SUBDIRS=grammars
AUTOMAKE_OPTIONS = subdir-objects
noinst_LTLIBRARIES=libbellesip_tls.la
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -19,6 +19,20 @@
#include "grammars/belle_sdpParser.h"
#include "grammars/belle_sdpLexer.h"
#include "belle_sip_internal.h"
struct _belle_sdp_mime_parameter {
belle_sip_object_t base;
int rate;
int channel_count;
int ptime;
int max_ptime;
int media_format;
const char* type;
const char* parameters;
};
/***************************************************************************************
* Attribute
*
......@@ -539,7 +553,7 @@ struct static_payload {
*
* */
struct static_payload static_payload_list [] ={
const struct static_payload static_payload_list [] ={
/*audio*/
{0,1,"PCMU",8000},
{3,1,"GSM",8000},
......@@ -567,21 +581,39 @@ struct static_payload static_payload_list [] ={
{33,-1,"MP2T",90000},
{34,-1,"H263",90000}
};
static const size_t payload_list_elements=sizeof(static_payload_list)/sizeof(struct static_payload);
static int mime_parameter_is_static(const belle_sdp_mime_parameter_t *param){
const struct static_payload* iterator;
int i;
for (iterator = static_payload_list,i=0;i<payload_list_elements;i++,iterator++) {
if (iterator->number == param->media_format &&
strcasecmp(iterator->type,param->type)==0 &&
iterator->channel_count==param->channel_count &&
iterator->rate==param->rate ) {
return TRUE;
}
}
return FALSE;
}
static int mime_parameter_fill_from_static(belle_sdp_mime_parameter_t *mime_parameter,int format) {
struct static_payload* iterator = static_payload_list;
const struct static_payload* iterator;
int i;
static size_t payload_list_element=sizeof(static_payload_list)/sizeof(struct static_payload);
for (i=0;i<payload_list_element;i++) {
for (iterator = static_payload_list,i=0;i<payload_list_elements;i++,iterator++) {
if (iterator->number == format) {
belle_sdp_mime_parameter_set_type(mime_parameter,iterator->type);
belle_sdp_mime_parameter_set_rate(mime_parameter,iterator->rate);
belle_sdp_mime_parameter_set_channel_count(mime_parameter,iterator->channel_count);
} else {
iterator++;
break;
}
}
return 0;
}
static int mime_parameter_fill_from_rtpmap(belle_sdp_mime_parameter_t *mime_parameter, const char *rtpmap){
char *mime=belle_sip_strdup(rtpmap);
char *p=strchr(mime,'/');
......@@ -655,13 +687,15 @@ belle_sip_list_t* belle_sdp_media_description_build_mime_parameters(const belle_
belle_sdp_mime_parameter_set_ptime(mime_parameter,ptime_as_int);
belle_sdp_mime_parameter_set_max_ptime(mime_parameter,max_ptime_as_int);
belle_sdp_mime_parameter_set_media_format(mime_parameter,(int)(long)media_formats->data);
mime_parameter_fill_from_static(mime_parameter,belle_sdp_mime_parameter_get_media_format(mime_parameter));
/*get rtpmap*/
rtpmap = belle_sdp_media_description_a_attr_value_get_with_pt(media_description
,belle_sdp_mime_parameter_get_media_format(mime_parameter)
,"rtpmap");
if (rtpmap) {
mime_parameter_fill_from_rtpmap(mime_parameter,rtpmap);
}else{
mime_parameter_fill_from_static(mime_parameter,belle_sdp_mime_parameter_get_media_format(mime_parameter));
}
fmtp = belle_sdp_media_description_a_attr_value_get_with_pt(media_description
,belle_sdp_mime_parameter_get_media_format(mime_parameter)
......@@ -674,11 +708,11 @@ belle_sip_list_t* belle_sdp_media_description_build_mime_parameters(const belle_
}
return mime_parameter_list;
}
#define MAX_FMTP_LENGH 512
#define MAX_FMTP_LENGTH 512
void belle_sdp_media_description_append_values_from_mime_parameter(belle_sdp_media_description_t* media_description, const belle_sdp_mime_parameter_t* mime_parameter) {
belle_sdp_media_t* media = belle_sdp_media_description_get_media(media_description);
char atribute_value [MAX_FMTP_LENGH];
char atribute_value [MAX_FMTP_LENGTH];
int current_ptime=0;
int current_max_ptime=0;
......@@ -696,31 +730,34 @@ void belle_sdp_media_description_append_values_from_mime_parameter(belle_sdp_med
}
#ifndef BELLE_SDP_FORCE_RTP_MAP /* defined to for RTP map even for static codec*/
if (belle_sdp_mime_parameter_get_media_format(mime_parameter) > 34) {
if (!mime_parameter_is_static(mime_parameter)) {
/*dynamic payload*/
#endif
if (belle_sdp_mime_parameter_get_channel_count(mime_parameter)>1) {
snprintf(atribute_value,MAX_FMTP_LENGH,"%i %s/%i/%i"
snprintf(atribute_value,MAX_FMTP_LENGTH,"%i %s/%i/%i"
,belle_sdp_mime_parameter_get_media_format(mime_parameter)
,belle_sdp_mime_parameter_get_type(mime_parameter)
,belle_sdp_mime_parameter_get_rate(mime_parameter)
,belle_sdp_mime_parameter_get_channel_count(mime_parameter));
} else {
snprintf(atribute_value,MAX_FMTP_LENGH,"%i %s/%i"
snprintf(atribute_value,MAX_FMTP_LENGTH,"%i %s/%i"
,belle_sdp_mime_parameter_get_media_format(mime_parameter)
,belle_sdp_mime_parameter_get_type(mime_parameter)
,belle_sdp_mime_parameter_get_rate(mime_parameter));
}
belle_sdp_media_description_set_attribute_value(media_description,"rtpmap",atribute_value);
if (belle_sdp_mime_parameter_get_parameters(mime_parameter)) {
snprintf(atribute_value,MAX_FMTP_LENGH,"%i %s"
,belle_sdp_mime_parameter_get_media_format(mime_parameter)
,belle_sdp_mime_parameter_get_parameters(mime_parameter));
belle_sdp_media_description_set_attribute_value(media_description,"fmtp",atribute_value);
}
#ifndef BELLE_SDP_FORCE_RTP_MAP
}
#endif
// always include fmtp parameters if available
if (belle_sdp_mime_parameter_get_parameters(mime_parameter)) {
snprintf(atribute_value,MAX_FMTP_LENGTH,"%i %s"
,belle_sdp_mime_parameter_get_media_format(mime_parameter)
,belle_sdp_mime_parameter_get_parameters(mime_parameter));
belle_sdp_media_description_set_attribute_value(media_description,"fmtp",atribute_value);
}
if (belle_sdp_mime_parameter_get_ptime(mime_parameter)>current_ptime) {
current_ptime=belle_sdp_mime_parameter_get_ptime(mime_parameter);
}
......@@ -1209,17 +1246,7 @@ GET_SET_INT(belle_sdp_version,version,int);
* mime_parameter
*
**************************************************************************************/
struct _belle_sdp_mime_parameter {
belle_sip_object_t base;
int rate;
int channel_count;
int ptime;
int max_ptime;
int media_format;
const char* type;
const char* parameters;
};
static void belle_sdp_mime_parameter_destroy(belle_sdp_mime_parameter_t *mime_parameter) {
if (mime_parameter->type) belle_sip_free((void*)mime_parameter->type);
if (mime_parameter->parameters) belle_sip_free((void*)mime_parameter->parameters);
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......@@ -947,7 +947,10 @@ belle_sip_header_extension_t* belle_sip_header_extension_parse (const char* valu
tokens ->free(tokens);
lex ->free(lex);
input ->close(input);
if (l_parsed_object.ret == NULL) belle_sip_error("Parser error for [%s]",value);\
if (l_parsed_object.ret == NULL) {\
belle_sip_error("Parser error for [%s]",value);\
return NULL;\
} else \
return BELLE_SIP_HEADER_EXTENSION(l_parsed_object.ret);
}
GET_SET_STRING(belle_sip_header_extension,value);
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......@@ -70,6 +70,7 @@ void belle_sip_object_unref(void *ptr){
if (obj->ref==-1) {
belle_sip_error("Object [%p] freed twice !",obj);
if (obj->vptr && obj->vptr->type_name) belle_sip_error("Object type might be [%s]",obj->vptr->type_name);
if (obj->name) belle_sip_error("Object name might be [%s]",obj->name);
belle_sip_fatal("Fatal object error encountered, aborting.");
return;
}
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......
......@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
......@@ -836,10 +836,11 @@ void belle_sip_channel_set_ready(belle_sip_channel_t *obj, const struct sockaddr
if (obj->local_ip==NULL){
struct sockaddr_storage saddr;
socklen_t slen2=sizeof(saddr);
int err;
belle_sip_address_remove_v4_mapping(addr,(struct sockaddr*) &saddr,&slen2);
int err=getnameinfo((struct sockaddr*)&saddr,slen,name,sizeof(name),serv,sizeof(serv),NI_NUMERICHOST|NI_NUMERICSERV);
err=getnameinfo((struct sockaddr*)&saddr,slen,name,sizeof(name),serv,sizeof(serv),NI_NUMERICHOST|NI_NUMERICSERV);
if (err!=0){
belle_sip_error("belle_sip_channel_set_ready(): getnameinfo() failed: %s",gai_strerror(err));
}else{
......