Commit 3139ec12 authored by Sandrine Avakian's avatar Sandrine Avakian

Merge branch 'master' into socket_api

* master:
  Add macro to declare vptr without symbol export attribute.
  Fix build on Windows 10.
  Increase version number to 1.6.0
  Update README.md
  Rename README into README.md
  Fix build.
  fix issue #3620 (lost registration forever) occuring when multiple transactions notify a same channel about a timeout.
parents f55b35a5 766c7942
......@@ -21,7 +21,7 @@
############################################################################
cmake_minimum_required(VERSION 3.0)
project(belle-sip VERSION 1.5.0 LANGUAGES C CXX)
project(belle-sip VERSION 1.6.0 LANGUAGES C CXX)
set(PACKAGE "${PROJECT_NAME}")
......@@ -218,8 +218,8 @@ set(BELLESIP_CPPFLAGS ${BCTOOLBOX_CPPFLAGS})
if(ENABLE_STATIC)
list(APPEND BELLESIP_CPPFLAGS "-DBELLESIP_STATIC")
endif()
list(REMOVE_DUPLICATES BELLESIP_CPPFLAGS)
if(BELLESIP_CPPFLAGS)
list(REMOVE_DUPLICATES BELLESIP_CPPFLAGS)
add_definitions(${BELLESIP_CPPFLAGS})
endif()
add_definitions("-DBELLESIP_EXPORTS")
......
belle-sip-1.6.0 -- February 23th, 2017
belle-sip-1.5.0 -- August 8th, 2016
* move general purpose and encryption related functions to bctoolbox, which becomes a mandatory dependency.
* mbedTLS support through bctoolbox
......
# Belle-sip
## Overview
Belle-sip is a SIP (RFC3261) implementation written in C, with an object oriented API.
Please check "NEWS" file for an overview of current features.
Copyright 2012-2014, Belledonne Communications SARL <contact@belledonne-communications.com>, all rights reserved.
Belle-sip is distributed to everyone under the GNU GPLv2 (see COPYING file for details).
Incorporating belle-sip within a closed source project is not possible under the GPL.
Commercial licensing can be purchased for that purpose from [Belledonne Communications](http://www.belledonne-communications.com).
## Build prerequisite
* [Java SE](http://www.oracle.com/technetwork/java/javase/downloads/index.html) on openJDK
This is required to generate a C sourcefile from SIP grammar using [antlr3](http://www.antlr3.org/) generator.
### Dependencies
* libtool
* intltool
* pkg-config
* libantlr3c-3.2 or 3.4
* antlr3-3.4
* bctoolbox (see below)
* C++ compiler (for instance g++ or clang++)
* (optional) BCUnit
#### Under Debian/Ubuntu
apt-get install libtool intltool pkg-config libantlr3c-dev antlr3 g++ make
#and for optional dependencies
apt-get install libbcunit1-dev libpolarssl-dev
#### Under MacOS X using HomeBrew
brew install intltool libtool pkg-config automake libantlr3.4c homebrew/versions/antlr3
ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
#### Under Windows using mingw and Visual Studio
The procedure is tested for Visual Studio Express 2012.
* Compile and install libantlr3c, BCUnit with ./configure && make && make install
* get antlr3 from linphone's git server (see above). This version contains up to date visual studio project and solution files.
* get BCUnit from linphone's git server (see above). This version contains up to date visual studio project and solution files.
* put belle-sip next to antlr3 and to bcunit (in the same directory).
* open belle-sip/build/windows/belle-sip-tester/belle-sip-tester.sln or belle-sip/build/windows/belle-sip/belle-sip.sln
* Build the solution (antlr3 and bcunit are built automatically)
#### Building bctoolbox
bctoolbox build system is Cmake only, but provides pkg-config file for integration with autotools.
git://git.linphone.org/bctoolbox.git
#### Known issues
1. Antlr3 on windows
On windows you have to edit /usr/local/include/antl3defs.h replace:
#include <winsock.h>
with:
#include <winsock2.h>
Or get the source code from linphone's git (linphone branch):
git clone -b linphone git://git.linphone.org/antlr3.git
git clone -b linphone git://git.linphone.org/bcunit.git
Belle-sip
=========
Overview
--------
Belle-sip is a SIP (RFC3261) implementation written in C, with an object oriented API.
Please check "NEWS" file for an overview of current features.
Copyright 2012-2014, Belledonne Communications SARL <contact@belledonne-communications.com>, all rights reserved.
Belle-sip is distributed to everyone under the GNU GPLv2 (see COPYING file for details).
Incorporating belle-sip within a closed source project is not possible under the GPL.
Commercial licensing can be purchased for that purpose from [Belledonne Communications](http://www.belledonne-communications.com).
Dependencies
------------
### Build-time dependencies
These are required to generate a C sourcefile from SIP grammar using [antlr3](http://www.antlr3.org/) generator:
* [Java SE](http://www.oracle.com/technetwork/java/javase/downloads/index.html) or OpenJDK
* [antlr 3.4](https://github.com/antlr/website-antlr3/blob/gh-pages/download/antlr-3.4-complete.jar)
### Runtime dependencies
- *libantlr3c* version 3.2 or 3.4
- *bctoolbox* (git://git.linphone.org/bctoolbox.git or <http://www.linphone.org/releases/sources/bctoolbox/>)
### Under Debian/Ubuntu
apt-get install libantlr3c-dev antlr3
### Under MacOS X using HomeBrew
brew install libantlr3.4c homebrew/versions/antlr3
Building bctoolbox with CMake
-----------------------------
cmake . -DCMAKE_INSTALL_PREFIX=<prefix> -DCMAKE_PREFIX_PATH=<search_prefix>
make
make install
Build options
-------------
* `CMAKE_INSTALL_PREFIX=<string>` : install prefix.
* `CMAKE_PREFIX_PATH=<string>` : column-separated list of prefixes where to find dependencies.
* `ENABLE_TESTS=NO` : disable non-regression tests.
* `ENABLE_STRICT=NO` : build without strict build options like `-Wall -Werror`
* `ENABLE_SHARED=NO` : do not build the shared library
* `ENABLE_STATIC=NO` : do not build the static library
Note for packagers
------------------
Our CMake scripts may automatically add some paths into research paths of generated binaries.
To ensure that the installed binaries are striped of any rpath, use `-DCMAKE_SKIP_INSTALL_RPATH=ON`
while you invoke cmake.
......@@ -3,7 +3,7 @@
AC_PREREQ([2.63])
AC_INIT([belle-sip],[1.5.0],[jehan.monnier@linphone.org])
AC_INIT([belle-sip],[1.6.0],[jehan.monnier@linphone.org])
BELLESIP_SO_CURRENT=0 dnl increment this number when you add/change/remove an interface
BELLESIP_SO_REVISION=0 dnl increment this number when you change source code, without changing interfaces; set to 0 when incrementing CURRENT
......
......@@ -55,6 +55,16 @@ typedef unsigned int belle_sip_type_id_t;
struct object_type##_vptr_struct{\
BELLE_SIP_OBJECT_VPTR_TYPE(parent_type) base;
#define BELLE_SIP_DECLARE_VPTR_NO_EXPORT(object_type) \
typedef belle_sip_object_vptr_t BELLE_SIP_OBJECT_VPTR_TYPE(object_type);\
BELLE_SIP_OBJECT_VPTR_TYPE(object_type) * BELLE_SIP_OBJECT_GET_VPTR_FUNC(object_type)(void);
#define BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN_NO_EXPORT(object_type, parent_type) \
typedef struct object_type##_vptr_struct BELLE_SIP_OBJECT_VPTR_TYPE(object_type);\
BELLE_SIP_OBJECT_VPTR_TYPE(object_type) * BELLE_SIP_OBJECT_GET_VPTR_FUNC(object_type)(void); \
struct object_type##_vptr_struct{\
BELLE_SIP_OBJECT_VPTR_TYPE(parent_type) base;
#define BELLE_SIP_DECLARE_CUSTOM_VPTR_END };
#define BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_BEGIN(object_type) \
......
......@@ -536,11 +536,11 @@ struct belle_sip_stack{
unsigned char dns_search_enabled;
};
BELLESIP_INTERNAL_EXPORT belle_sip_hop_t* belle_sip_hop_new(const char* transport, const char *cname, const char* host,int port);
BELLESIP_INTERNAL_EXPORT belle_sip_hop_t* belle_sip_hop_new_from_uri(const belle_sip_uri_t *uri);
BELLESIP_INTERNAL_EXPORT belle_sip_hop_t* belle_sip_hop_new_from_generic_uri(const belle_generic_uri_t *uri);
BELLESIP_EXPORT belle_sip_hop_t* belle_sip_hop_new(const char* transport, const char *cname, const char* host,int port);
BELLESIP_EXPORT belle_sip_hop_t* belle_sip_hop_new_from_uri(const belle_sip_uri_t *uri);
BELLESIP_EXPORT belle_sip_hop_t* belle_sip_hop_new_from_generic_uri(const belle_generic_uri_t *uri);
BELLESIP_INTERNAL_EXPORT belle_sip_hop_t * belle_sip_stack_get_next_hop(belle_sip_stack_t *stack, belle_sip_request_t *req);
BELLESIP_EXPORT belle_sip_hop_t * belle_sip_stack_get_next_hop(belle_sip_stack_t *stack, belle_sip_request_t *req);
/*
belle_sip_provider_t
......@@ -562,12 +562,12 @@ struct belle_sip_provider{
unsigned short unconditional_answer;
};
BELLESIP_INTERNAL_EXPORT belle_sip_provider_t *belle_sip_provider_new(belle_sip_stack_t *s, belle_sip_listening_point_t *lp);
BELLESIP_EXPORT belle_sip_provider_t *belle_sip_provider_new(belle_sip_stack_t *s, belle_sip_listening_point_t *lp);
void belle_sip_provider_add_client_transaction(belle_sip_provider_t *prov, belle_sip_client_transaction_t *t);
belle_sip_client_transaction_t *belle_sip_provider_find_matching_client_transaction(belle_sip_provider_t *prov, belle_sip_response_t *resp);
void belle_sip_provider_remove_client_transaction(belle_sip_provider_t *prov, belle_sip_client_transaction_t *t);
void belle_sip_provider_add_server_transaction(belle_sip_provider_t *prov, belle_sip_server_transaction_t *t);
BELLESIP_INTERNAL_EXPORT belle_sip_server_transaction_t * belle_sip_provider_find_matching_server_transaction(belle_sip_provider_t *prov,belle_sip_request_t *req);
BELLESIP_EXPORT belle_sip_server_transaction_t * belle_sip_provider_find_matching_server_transaction(belle_sip_provider_t *prov,belle_sip_request_t *req);
void belle_sip_provider_remove_server_transaction(belle_sip_provider_t *prov, belle_sip_server_transaction_t *t);
void belle_sip_provider_set_transaction_terminated(belle_sip_provider_t *p, belle_sip_transaction_t *t);
void *belle_sip_transaction_get_application_data_internal(const belle_sip_transaction_t *t);
......@@ -580,7 +580,7 @@ void belle_sip_provider_remove_internal_sip_listener(belle_sip_provider_t *p, be
belle_sip_client_transaction_t * belle_sip_provider_find_matching_client_transaction_from_req(belle_sip_provider_t *prov, belle_sip_request_t *req);
belle_sip_dialog_t *belle_sip_provider_find_dialog_from_message(belle_sip_provider_t *prov, belle_sip_message_t *msg, int as_uas);
/*for testing purpose only:*/
BELLESIP_INTERNAL_EXPORT void belle_sip_provider_dispatch_message(belle_sip_provider_t *prov, belle_sip_message_t *msg);
BELLESIP_EXPORT void belle_sip_provider_dispatch_message(belle_sip_provider_t *prov, belle_sip_message_t *msg);
typedef struct listener_ctx{
belle_sip_listener_t *listener;
......@@ -975,16 +975,16 @@ belle_sip_refresher_t* belle_sip_refresher_new(belle_sip_client_transaction_t* t
* returns a char, even if entry is escaped*/
size_t belle_sip_get_char (const char*a,char*out);
/*return an escaped string*/
BELLESIP_INTERNAL_EXPORT char* belle_sip_uri_to_escaped_username(const char* buff) ;
BELLESIP_INTERNAL_EXPORT char* belle_sip_uri_to_escaped_userpasswd(const char* buff) ;
BELLESIP_INTERNAL_EXPORT char* belle_sip_uri_to_escaped_parameter(const char* buff) ;
BELLESIP_INTERNAL_EXPORT char* belle_sip_uri_to_escaped_header(const char* buff) ;
BELLESIP_EXPORT char* belle_sip_uri_to_escaped_username(const char* buff) ;
BELLESIP_EXPORT char* belle_sip_uri_to_escaped_userpasswd(const char* buff) ;
BELLESIP_EXPORT char* belle_sip_uri_to_escaped_parameter(const char* buff) ;
BELLESIP_EXPORT char* belle_sip_uri_to_escaped_header(const char* buff) ;
/*(uri RFC 2396)*/
BELLESIP_INTERNAL_EXPORT char* belle_generic_uri_to_escaped_query(const char* buff);
BELLESIP_INTERNAL_EXPORT char* belle_generic_uri_to_escaped_path(const char* buff);
BELLESIP_EXPORT char* belle_generic_uri_to_escaped_query(const char* buff);
BELLESIP_EXPORT char* belle_generic_uri_to_escaped_path(const char* buff);
#define BELLE_SIP_SOCKET_TIMEOUT 30000
......@@ -1020,7 +1020,7 @@ belle_sip_header_extension_t* belle_sip_header_extension_new(void);
belle_sip_header_extension_t* belle_sip_header_extension_parse (const char* extension) ;
belle_sip_header_extension_t* belle_sip_header_extension_create (const char* name,const char* value);
BELLESIP_INTERNAL_EXPORT const char* belle_sip_header_extension_get_value(const belle_sip_header_extension_t* extension);
BELLESIP_EXPORT const char* belle_sip_header_extension_get_value(const belle_sip_header_extension_t* extension);
void belle_sip_header_extension_set_value(belle_sip_header_extension_t* extension,const char* value);
#define BELLE_SIP_HEADER_EXTENSION(t) BELLE_SIP_CAST(t,belle_sip_header_extension_t)
......
......@@ -737,7 +737,7 @@ belle_sip_list_t *belle_sip_parse_directory(const char *path, const char *file_t
}
/* loop on all directory files */
errno = 0;
errno = 0;
ent = readdir(dir);
while (ent != NULL) {
/* filter on file type if given */
......
......@@ -1012,6 +1012,12 @@ static void belle_sip_channel_handle_error(belle_sip_channel_t *obj){
int belle_sip_channel_notify_timeout(belle_sip_channel_t *obj){
const int too_long=60;
if (obj->state != BELLE_SIP_CHANNEL_READY){
/*no need to notify the timeout if the channel is already in error or retry state*/
return FALSE;
}
if ((int)(belle_sip_time_ms() - obj->last_recv_time) >= (too_long * 1000)){
belle_sip_message("A timeout related to this channel occured and no message received during last %i seconds. This channel is suspect, moving to error state",too_long);
channel_set_state(obj,BELLE_SIP_CHANNEL_ERROR);
......
......@@ -205,7 +205,7 @@ void belle_sip_channel_force_close(belle_sip_channel_t *obj);
int belle_sip_channel_notify_timeout(belle_sip_channel_t *obj);
/*Used by transaction layer to report a server having internal errors, so that we can retry with another IP (in case of DNS SRV)*/
BELLESIP_INTERNAL_EXPORT void belle_sip_channel_notify_server_error(belle_sip_channel_t *obj);
BELLESIP_EXPORT void belle_sip_channel_notify_server_error(belle_sip_channel_t *obj);
BELLE_SIP_END_DECLS
......
......@@ -81,7 +81,7 @@ options {
#include "belle-sip/message.h"
#include "belle-sip/http-message.h"
#include "parserutils.h"
BELLESIP_INTERNAL_EXPORT void belle_sip_header_address_set_quoted_displayname(belle_sip_header_address_t* address,const char* value);
BELLESIP_EXPORT void belle_sip_header_address_set_quoted_displayname(belle_sip_header_address_t* address,const char* value);
}
@rulecatch
......
......@@ -33,10 +33,10 @@
#define ANTLR3_LOG_EXCEPTION() belle_sip_message("[\%s] reason [\%s] at line[\%u] position[\%d]",(const char*)EXCEPTION->name,(const char*)EXCEPTION->message,EXCEPTION->line,EXCEPTION->charPositionInLine);
BELLESIP_INTERNAL_EXPORT belle_sip_header_t* belle_sip_header_get_next(const belle_sip_header_t* headers);
BELLESIP_INTERNAL_EXPORT void belle_sip_header_set_next(belle_sip_header_t* header,belle_sip_header_t* next);
BELLESIP_EXPORT belle_sip_header_t* belle_sip_header_get_next(const belle_sip_header_t* headers);
BELLESIP_EXPORT void belle_sip_header_set_next(belle_sip_header_t* header,belle_sip_header_t* next);
BELLESIP_INTERNAL_EXPORT char* belle_sip_to_unescaped_string(const char* buff);
BELLESIP_EXPORT char* belle_sip_to_unescaped_string(const char* buff);
belle_sip_param_pair_t* belle_sip_param_pair_new(const char* name,const char* value);
char* _belle_sip_str_dup_and_unquote_string(const char* quoted_string);
......@@ -49,7 +49,7 @@ char* _belle_sip_str_dup_and_unquote_string(const char* quoted_string);
remove any \
* */
BELLESIP_INTERNAL_EXPORT char* belle_sip_string_to_backslash_less_unescaped_string(const char* buff);
BELLESIP_INTERNAL_EXPORT char* belle_sip_display_name_to_backslashed_escaped_string(const char* buff);
BELLESIP_EXPORT char* belle_sip_string_to_backslash_less_unescaped_string(const char* buff);
BELLESIP_EXPORT char* belle_sip_display_name_to_backslashed_escaped_string(const char* buff);
#endif
......@@ -84,22 +84,12 @@
# endif
#endif
#if defined(_WIN32) || defined(_WIN32) || defined(__WIN32) || defined(__WIN32__)
#ifdef BELLESIP_INTERNAL_EXPORTS
#define BELLESIP_INTERNAL_EXPORT __declspec(dllexport)
#else
#define BELLESIP_INTERNAL_EXPORT
#endif
#else
#define BELLESIP_INTERNAL_EXPORT extern
#endif
/*
* Socket abstraction layer
*/
BELLESIP_INTERNAL_EXPORT int belle_sip_init_sockets(void);
BELLESIP_INTERNAL_EXPORT void belle_sip_uninit_sockets(void);
BELLESIP_EXPORT int belle_sip_init_sockets(void);
BELLESIP_EXPORT void belle_sip_uninit_sockets(void);
int belle_sip_socket_set_nonblocking (belle_sip_socket_t sock);
int belle_sip_socket_set_dscp(belle_sip_socket_t sock, int ai_family, int dscp);
int belle_sip_socket_enable_dual_stack(belle_sip_socket_t sock);
......@@ -166,7 +156,7 @@ typedef pthread_mutex_t belle_sip_mutex_t;
#endif
#ifndef BELLE_SIP_WINDOWS_DESKTOP
BELLESIP_INTERNAL_EXPORT void belle_sip_sleep(unsigned int ms);
BELLESIP_EXPORT void belle_sip_sleep(unsigned int ms);
#else
#define belle_sip_sleep Sleep
#endif
......
......@@ -277,7 +277,7 @@ void belle_sip_transaction_notify_timeout(belle_sip_transaction_t *t){
belle_sip_object_ref(t); /*take a ref in the case where the app calls belle_sip_transaction_terminate() within the timeout listener*/
if (strcmp(belle_sip_request_get_method(t->request),"REGISTER")==0){
if ( belle_sip_channel_notify_timeout(t->channel)==TRUE){
belle_sip_warning("Transaction [%p] reporting timeout, reporting to channel.",t);
belle_sip_warning("Transaction [%p] has timeout, reported to channel.",t);
t->timed_out=TRUE;
}
}else {
......
......@@ -43,7 +43,7 @@ BELLE_SIP_DECLARE_CUSTOM_VPTR_END
void belle_sip_stream_channel_init_client(belle_sip_stream_channel_t *obj, belle_sip_stack_t *stack, const char *bindip, int localport,const char *peer_cname, const char *dest, int port);
BELLESIP_INTERNAL_EXPORT belle_sip_channel_t * belle_sip_stream_channel_new_client(belle_sip_stack_t *stack, const char *bindip, int localport, const char *peer_cname, const char *name, int port);
BELLESIP_EXPORT belle_sip_channel_t * belle_sip_stream_channel_new_client(belle_sip_stack_t *stack, const char *bindip, int localport, const char *peer_cname, const char *name, int port);
belle_sip_channel_t * belle_sip_stream_channel_new_child(belle_sip_stack_t *stack, belle_sip_socket_t sock, struct sockaddr *remote_addr, socklen_t slen);
void stream_channel_close(belle_sip_stream_channel_t *obj);
......@@ -55,5 +55,5 @@ int stream_channel_recv(belle_sip_stream_channel_t *obj, void *buf, size_t bufle
/*for testing purpose*/
BELLESIP_INTERNAL_EXPORT void belle_sip_channel_parse_stream(belle_sip_channel_t *obj, int end_of_stream);
BELLESIP_EXPORT void belle_sip_channel_parse_stream(belle_sip_channel_t *obj, int end_of_stream);
#endif /* STREAM_CHANNEL_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment