Commit a3df8247 authored by Simon Morlat's avatar Simon Morlat

http in progress

Merge branch 'master' into dev_http

Conflicts:
	src/Makefile.am
	src/listeningpoint.c
parents 18110440 fdc3a4ac
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/
)
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()
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)
......@@ -25,6 +25,7 @@ bellesip_HEADERS=\
http-provider.h \
http-message.h \
http-listener.h \
generic-uri.h
generic-uri.h \
types.h
EXTRA_DIST=$(bellesip_HEADERS)
......@@ -19,8 +19,7 @@
#ifndef BELLE_SDP_H_
#define BELLE_SDP_H_
#include "belle-sip/defs.h"
#include "belle-sip/belle-sip.h"
#include "belle-sip/list.h"
#define BELLE_SDP_CAST(obj,t) BELLE_SIP_CAST(obj,t)
......@@ -111,11 +110,13 @@ BELLESIP_EXPORT belle_sdp_media_t* belle_sdp_media_create(const char* media_type
,const char* protocol
,belle_sip_list_t* static_media_formats);
BELLESIP_EXPORT belle_sip_list_t* belle_sdp_media_get_media_formats(const belle_sdp_media_t* media);
BELLESIP_EXPORT const char* belle_sdp_media_get_raw_fmt(const belle_sdp_media_t* media);
BELLESIP_EXPORT int belle_sdp_media_get_media_port(const belle_sdp_media_t* media);
BELLESIP_EXPORT const char* belle_sdp_media_get_media_type(const belle_sdp_media_t* media);
BELLESIP_EXPORT int belle_sdp_media_get_port_count(const belle_sdp_media_t* media);
BELLESIP_EXPORT const char* belle_sdp_media_get_protocol(const belle_sdp_media_t* media);
BELLESIP_EXPORT void belle_sdp_media_set_media_formats(belle_sdp_media_t* media, belle_sip_list_t* mediaFormats);
BELLESIP_EXPORT void belle_sdp_media_set_raw_fmt(belle_sdp_media_t* media, const char* fmt);
BELLESIP_EXPORT void belle_sdp_media_set_media_port(belle_sdp_media_t* media, int port);
BELLESIP_EXPORT void belle_sdp_media_set_media_type(belle_sdp_media_t* media, const char* mediaType);
BELLESIP_EXPORT void belle_sdp_media_set_port_count(belle_sdp_media_t* media, int port_count);
......@@ -295,13 +296,7 @@ BELLESIP_EXPORT void belle_sdp_version_set_version(belle_sdp_version_t* version,
typedef struct _belle_sdp_session_description belle_sdp_session_description_t;
BELLESIP_EXPORT belle_sdp_session_description_t* belle_sdp_session_description_new();
BELLESIP_EXPORT belle_sdp_session_description_t* belle_sdp_session_description_parse (const char* session_description);
/*sdp managementy helper method*/
/*
* create a session description object from a message
* @param message to get sdp from
* @returns belle_sdp_session_description_t or NULL if no sdp present
* */
BELLESIP_EXPORT belle_sdp_session_description_t* belle_sdp_session_description_create(belle_sip_message_t* message);
BELLESIP_EXPORT const char* belle_sdp_session_description_get_attribute_value(const belle_sdp_session_description_t* session_description, const char* name);
BELLESIP_EXPORT const belle_sdp_attribute_t* belle_sdp_session_description_get_attribute(const belle_sdp_session_description_t* session_description, const char* name);
BELLESIP_EXPORT int belle_sdp_session_description_get_bandwidth(const belle_sdp_session_description_t* session_description, const char* name);
......
......@@ -18,149 +18,7 @@
#ifndef BELLE_SIP_H
#define BELLE_SIP_H
#include <stdlib.h>
#include "belle-sip/defs.h"
#include "belle-sip/object.h"
#include "belle-sip/dict.h"
/**
* This enum declares all object types used in belle-sip (see belle_sip_object_t)
**/
BELLE_SIP_DECLARE_TYPES_BEGIN(belle_sip,1)
BELLE_SIP_TYPE_ID(belle_sip_stack_t),
BELLE_SIP_TYPE_ID(belle_sip_hop_t),
BELLE_SIP_TYPE_ID(belle_sip_object_pool_t),
BELLE_SIP_TYPE_ID(belle_sip_listening_point_t),
BELLE_SIP_TYPE_ID(belle_sip_datagram_listening_point_t),
BELLE_SIP_TYPE_ID(belle_sip_udp_listening_point_t),
BELLE_SIP_TYPE_ID(belle_sip_stream_listening_point_t),
BELLE_SIP_TYPE_ID(belle_sip_tls_listening_point_t),
BELLE_SIP_TYPE_ID(belle_sip_tunnel_listening_point_t),
BELLE_SIP_TYPE_ID(belle_sip_channel_t),
BELLE_SIP_TYPE_ID(belle_sip_udp_channel_t),
BELLE_SIP_TYPE_ID(belle_sip_stream_channel_t),
BELLE_SIP_TYPE_ID(belle_sip_tls_channel_t),
BELLE_SIP_TYPE_ID(belle_sip_tunnel_channel_t),
BELLE_SIP_TYPE_ID(belle_sip_provider_t),
BELLE_SIP_TYPE_ID(belle_sip_main_loop_t),
BELLE_SIP_TYPE_ID(belle_sip_source_t),
BELLE_SIP_TYPE_ID(belle_sip_resolver_context_t),
BELLE_SIP_TYPE_ID(belle_sip_transaction_t),
BELLE_SIP_TYPE_ID(belle_sip_server_transaction_t),
BELLE_SIP_TYPE_ID(belle_sip_client_transaction_t),
BELLE_SIP_TYPE_ID(belle_sip_ict_t),
BELLE_SIP_TYPE_ID(belle_sip_nict_t),
BELLE_SIP_TYPE_ID(belle_sip_ist_t),
BELLE_SIP_TYPE_ID(belle_sip_nist_t),
BELLE_SIP_TYPE_ID(belle_sip_dialog_t),
BELLE_SIP_TYPE_ID(belle_sip_header_address_t),
BELLE_SIP_TYPE_ID(belle_sip_header_contact_t),
BELLE_SIP_TYPE_ID(belle_sip_header_from_t),
BELLE_SIP_TYPE_ID(belle_sip_header_to_t),
BELLE_SIP_TYPE_ID(belle_sip_header_via_t),
BELLE_SIP_TYPE_ID(belle_sip_uri_t),
BELLE_SIP_TYPE_ID(belle_sip_message_t),
BELLE_SIP_TYPE_ID(belle_sip_request_t),
BELLE_SIP_TYPE_ID(belle_sip_response_t),
BELLE_SIP_TYPE_ID(belle_sip_object_t),
BELLE_SIP_TYPE_ID(belle_sip_parameters_t),
BELLE_SIP_TYPE_ID(belle_sip_header_call_id_t),
BELLE_SIP_TYPE_ID(belle_sip_header_cseq_t),
BELLE_SIP_TYPE_ID(belle_sip_header_content_type_t),
BELLE_SIP_TYPE_ID(belle_sip_header_route_t),
BELLE_SIP_TYPE_ID(belle_sip_header_record_route_t),
BELLE_SIP_TYPE_ID(belle_sip_header_user_agent_t),
BELLE_SIP_TYPE_ID(belle_sip_header_content_length_t),
BELLE_SIP_TYPE_ID(belle_sip_header_t),
BELLE_SIP_TYPE_ID(belle_sip_header_extension_t),
BELLE_SIP_TYPE_ID(belle_sip_header_authorization_t),
BELLE_SIP_TYPE_ID(belle_sip_header_proxy_authorization_t),
BELLE_SIP_TYPE_ID(belle_sip_header_www_authenticate_t),
BELLE_SIP_TYPE_ID(belle_sip_header_proxy_authenticate_t),
BELLE_SIP_TYPE_ID(belle_sip_header_max_forwards_t),
BELLE_SIP_TYPE_ID(belle_sip_header_expires_t),
BELLE_SIP_TYPE_ID(belle_sip_header_allow_t),
BELLE_SIP_TYPE_ID(belle_sdp_attribute_t),
BELLE_SIP_TYPE_ID(belle_sdp_bandwidth_t),
BELLE_SIP_TYPE_ID(belle_sdp_connection_t),
BELLE_SIP_TYPE_ID(belle_sdp_email_t),
BELLE_SIP_TYPE_ID(belle_sdp_info_t),
BELLE_SIP_TYPE_ID(belle_sdp_key_t),
BELLE_SIP_TYPE_ID(belle_sdp_media_t),
BELLE_SIP_TYPE_ID(belle_sdp_media_description_t),
BELLE_SIP_TYPE_ID(belle_sdp_origin_t),
BELLE_SIP_TYPE_ID(belle_sdp_phone_t),
BELLE_SIP_TYPE_ID(belle_sdp_repeate_time_t),
BELLE_SIP_TYPE_ID(belle_sdp_session_description_t),
BELLE_SIP_TYPE_ID(belle_sdp_session_name_t),
BELLE_SIP_TYPE_ID(belle_sdp_time_t),
BELLE_SIP_TYPE_ID(belle_sdp_time_description_t),
BELLE_SIP_TYPE_ID(belle_sdp_uri_t),
BELLE_SIP_TYPE_ID(belle_sdp_version_t),
BELLE_SIP_TYPE_ID(belle_sdp_base_description_t),
BELLE_SIP_TYPE_ID(belle_sdp_mime_parameter_t),
BELLE_SIP_TYPE_ID(belle_sip_callbacks_t),
BELLE_SIP_TYPE_ID(belle_sip_refresher_t),
BELLE_SIP_TYPE_ID(belle_sip_header_subscription_state_t),
BELLE_SIP_TYPE_ID(belle_sip_header_service_route_t),
BELLE_SIP_TYPE_ID(belle_sip_header_refer_to_t),
BELLE_SIP_TYPE_ID(belle_sip_header_referred_by_t),
BELLE_SIP_TYPE_ID(belle_sip_header_replaces_t),
BELLE_SIP_TYPE_ID(belle_sip_header_date_t),
BELLE_SIP_TYPE_ID(belle_sip_header_p_preferred_identity_t),
BELLE_SIP_TYPE_ID(belle_sip_header_privacy_t),
BELLE_SIP_TYPE_ID(belle_sip_certificates_chain_t),
BELLE_SIP_TYPE_ID(belle_sip_signing_key_t),
BELLE_SIP_TYPE_ID(belle_sip_dns_srv_t),
BELLE_SIP_TYPE_ID(belle_sip_simple_resolver_context_t),
BELLE_SIP_TYPE_ID(belle_sip_combined_resolver_context_t),
BELLE_SIP_TYPE_ID(belle_sip_dict_t),
BELLE_SIP_TYPE_ID(belle_sip_dual_resolver_context_t),
BELLE_SIP_TYPE_ID(belle_http_provider_t),
BELLE_SIP_TYPE_ID(belle_http_request_t),
BELLE_SIP_TYPE_ID(belle_http_response_t),
BELLE_SIP_TYPE_ID(belle_http_channel_context_t),
BELLE_SIP_TYPE_ID(belle_generic_uri_t)
BELLE_SIP_DECLARE_TYPES_END
enum belle_sip_interface_ids{
belle_sip_interface_id_first=1,
BELLE_SIP_INTERFACE_ID(belle_sip_channel_listener_t),
BELLE_SIP_INTERFACE_ID(belle_sip_listener_t),
BELLE_SIP_INTERFACE_ID(belle_http_request_listener_t)
};
BELLE_SIP_BEGIN_DECLS
BELLESIP_EXPORT void *belle_sip_malloc(size_t size);
BELLESIP_EXPORT void *belle_sip_malloc0(size_t size);
BELLESIP_EXPORT void *belle_sip_realloc(void *ptr, size_t size);
BELLESIP_EXPORT void belle_sip_free(void *ptr);
BELLESIP_EXPORT char * belle_sip_strdup(const char *s);
BELLE_SIP_END_DECLS
/*these types are declared here because they are widely used in many headers included after*/
typedef struct belle_sip_listening_point belle_sip_listening_point_t;
typedef struct belle_sip_tls_listening_point belle_sip_tls_listening_point_t;
typedef struct belle_sip_stack belle_sip_stack_t;
typedef struct belle_sip_provider belle_sip_provider_t;
typedef struct belle_http_provider belle_http_provider_t;
typedef struct belle_sip_dialog belle_sip_dialog_t;
typedef struct belle_sip_transaction belle_sip_transaction_t;
typedef struct belle_sip_server_transaction belle_sip_server_transaction_t;
typedef struct belle_sip_client_transaction belle_sip_client_transaction_t;
typedef struct _belle_sip_message belle_sip_message_t;
typedef struct _belle_sip_request belle_sip_request_t;
typedef struct _belle_sip_response belle_sip_response_t;
typedef struct belle_http_request belle_http_request_t;
typedef struct belle_http_response belle_http_response_t;
typedef struct belle_sip_hop belle_sip_hop_t;
typedef struct belle_http_url belle_http_url_t;
#include "belle-sip/types.h"
#include "belle-sip/utils.h"
#include "belle-sip/list.h"
#include "belle-sip/listener.h"
......@@ -180,15 +38,9 @@ typedef struct belle_http_url belle_http_url_t;
#include "belle-sip/generic-uri.h"
#include "belle-sip/http-listener.h"
#include "belle-sip/http-provider.h"
#include "belle-sip/http-listener.h"
#include "belle-sip/http-message.h"
#undef TRUE
#define TRUE 1
#undef FALSE
#define FALSE 0
#include "belle-sip/belle-sdp.h"
#define BELLE_SIP_POINTER_TO_INT(p) ((int)(long)(p))
......
......@@ -54,4 +54,11 @@ typedef unsigned char uint8_t;
#define BELLESIP_UNUSED(a) (void)a;
#undef TRUE
#define TRUE 1
#undef FALSE
#define FALSE 0
#endif
......@@ -25,7 +25,6 @@
#include "belle-sip/utils.h"
typedef struct _belle_generic_uri belle_generic_uri_t;
BELLE_SIP_BEGIN_DECLS
......@@ -37,7 +36,7 @@ BELLESIP_EXPORT belle_generic_uri_t* belle_generic_uri_new();
/**
*
*/
BELLESIP_EXPORT belle_generic_uri_t* belle_generic_uri_parse (const char* uri) ;
BELLESIP_EXPORT belle_generic_uri_t* belle_generic_uri_parse (const char* uri);
/*
* Returns the host part of this uri.
*
......
......@@ -22,6 +22,7 @@
#include "belle-sip/defs.h"
#include "belle-sip/sip-uri.h"
#include "belle-sip/utils.h"
#include "belle-sip/parameters.h"
#include <time.h>
......@@ -74,7 +75,7 @@ BELLESIP_EXPORT void belle_sip_header_address_set_displayname(belle_sip_header_a
*
**************************************************************************************/
typedef struct _belle_sip_header belle_sip_header_t;
BELLESIP_EXPORT belle_sip_header_t* belle_sip_header_create (const char* name,const char* value);
BELLESIP_EXPORT const char* belle_sip_header_get_name (const belle_sip_header_t* obj);
BELLESIP_EXPORT void belle_sip_header_set_name (belle_sip_header_t* obj,const char* value);
......
......@@ -51,10 +51,13 @@ BELLE_SIP_DECLARE_INTERFACE_END
struct belle_http_request_listener_callbacks{
BELLE_HTTP_INTERFACE_FUNCS(void*)
void (*listener_destroyed)(void *user_ctx);
};
typedef struct belle_http_request_listener_callbacks belle_http_request_listener_callbacks_t;
#define BELLE_HTTP_REQUEST_LISTENER(obj) BELLE_SIP_INTERFACE_CAST(obj,belle_http_request_listener_t)
BELLE_SIP_BEGIN_DECLS
/**
* Creates an object implementing the belle_http_request_listener_t interface.
......
......@@ -18,15 +18,20 @@
#ifndef BELLE_HTTP_MESSAGE_H
#define BELLE_HTTP_MESSAGE_H
#include "belle-sip/generic-uri.h"
#define BELLE_HTTP_REQUEST(obj) BELLE_SIP_CAST(obj,belle_http_request_t)
#define BELLE_HTTP_RESPONSE(obj) BELLE_SIP_CAST(obj,belle_http_response_t)
BELLE_SIP_BEGIN_DECLS
/***
* http request
/**
* Create an http request.
* @param method
* @param uri the http uri
* @param ... optional list of belle_sip_header_t* to be included in the request, ending with NULL.
*/
BELLESIP_EXPORT belle_http_request_t *belle_http_request_create(const char *method, belle_generic_uri_t *uri, ...);
BELLESIP_EXPORT belle_http_request_t* belle_http_request_new();
BELLESIP_EXPORT belle_http_request_t* belle_http_request_parse(const char* raw);
......@@ -35,6 +40,7 @@ BELLESIP_EXPORT void belle_http_request_set_uri(belle_http_request_t* request, b
BELLESIP_EXPORT const char* belle_http_request_get_method(const belle_http_request_t* request);
BELLESIP_EXPORT void belle_http_request_set_method(belle_http_request_t* request,const char* method);
BELLESIP_EXPORT belle_http_response_t *belle_http_request_get_response(belle_http_request_t *req);
/**
* http response
......
......@@ -18,7 +18,7 @@
#ifndef BELLE_SIP_MESSAGE_H
#define BELLE_SIP_MESSAGE_H
#include "belle-sip/headers.h"
#define BELLE_SIP_MESSAGE(obj) BELLE_SIP_CAST(obj,belle_sip_message_t)
#define BELLE_SIP_REQUEST(obj) BELLE_SIP_CAST(obj,belle_sip_request_t)
......
......@@ -29,8 +29,6 @@ BELLE_SIP_BEGIN_DECLS
*
*/
typedef struct _belle_sip_parameters belle_sip_parameters_t;
belle_sip_parameters_t* belle_sip_parameters_new();
/*
* remove all parameters */
......
......@@ -26,7 +26,7 @@ BELLE_SIP_BEGIN_DECLS
BELLESIP_EXPORT belle_sip_uri_t *belles_sip_provider_find_our_origin(belle_sip_provider_t *p, belle_sip_request_t *req);
BELLESIP_EXPORT unsigned char belle_sip_provider_is_us(belle_sip_provider_t *p, belle_sip_uri_t*);
BELLESIP_EXPORT int belle_sip_provider_is_us(belle_sip_provider_t *p, belle_sip_uri_t*);
BELLESIP_EXPORT int belle_sip_provider_add_listening_point(belle_sip_provider_t *p, belle_sip_listening_point_t *lp);
......
......@@ -22,9 +22,7 @@
#include "belle-sip/defs.h"
#include "belle-sip/list.h"
#include "belle-sip/utils.h"
/*inherite from belle_sip_parameters_t*/
typedef struct _belle_sip_uri belle_sip_uri_t;
#include "belle-sip/types.h"
BELLE_SIP_BEGIN_DECLS
......
......@@ -23,7 +23,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <stdlib.h>
BELLE_SIP_BEGIN_DECLS
BELLESIP_EXPORT void *belle_sip_malloc(size_t size);
BELLESIP_EXPORT void *belle_sip_malloc0(size_t size);
BELLESIP_EXPORT void *belle_sip_realloc(void *ptr, size_t size);
BELLESIP_EXPORT void belle_sip_free(void *ptr);
BELLESIP_EXPORT char * belle_sip_strdup(const char *s);
BELLE_SIP_END_DECLS
/***************/
/* logging api */
......
set(SDP_GENERATED_SOURCE_FILES
${CMAKE_CURRENT_BINARY_DIR}/belle_sdpLexer.c
${CMAKE_CURRENT_BINARY_DIR}/belle_sdpLexer.h
${CMAKE_CURRENT_BINARY_DIR}/belle_sdpParser.c
${CMAKE_CURRENT_BINARY_DIR}/belle_sdpParser.h
)
add_custom_command(
OUTPUT ${SDP_GENERATED_SOURCE_FILES}
COMMAND java -jar ${ANTLR3_ROOT_DIR}/antlr-3.4-complete.jar -make -fo ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/belle_sdp.g
DEPENDS belle_sdp.g
)
set(SIP_MESSAGE_GENERATED_SOURCE_FILES
${CMAKE_CURRENT_BINARY_DIR}/belle_sip_messageLexer.c
${CMAKE_CURRENT_BINARY_DIR}/belle_sip_messageLexer.h
${CMAKE_CURRENT_BINARY_DIR}/belle_sip_messageParser.c
${CMAKE_CURRENT_BINARY_DIR}/belle_sip_messageParser.h
)
add_custom_command(
OUTPUT ${SIP_MESSAGE_GENERATED_SOURCE_FILES}
COMMAND java -jar ${ANTLR3_ROOT_DIR}/antlr-3.4-complete.jar -make -fo ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/belle_sip_message.g
DEPENDS belle_sip_message.g
)
set(SOURCE_FILES
auth_event.c
auth_helper.c
belle_sdp_impl.c
belle_sip_headers_impl.c
belle_sip_loop.c
belle_sip_object.c
belle_sip_parameters.c
belle_sip_resolver.c
belle_sip_uri_impl.c
belle_sip_utils.c
channel.c
dialog.c
dns.c
ict.c
ist.c
listeningpoint.c
md5.c
message.c
nict.c
nist.c
port.c
provider.c
refresher.c
siplistener.c
sipstack.c
transaction.c
transports/stream_channel.c
transports/stream_listeningpoint.c
transports/tls_channel_polarssl.c
transports/tls_listeningpoint_polarssl.c
transports/udp_channel.c
transports/udp_listeningpoint.c
${SDP_GENERATED_SOURCE_FILES}
${SIP_MESSAGE_GENERATED_SOURCE_FILES}
)
add_definitions(
-DBELLESIP_EXPORTS
-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)
target_link_libraries(libbellesip ${LIBS})
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)
if(USE_INSTALLED_COMPONENTS)
add_dependencies(libbellesip
INSTALL_libantlr3c
INSTALL_libpolarssl
INSTALL_libortp)
endif()
......@@ -47,7 +47,8 @@ libbellesip_la_SOURCES= \
belle_sip_dict.c \
generic-uri.c \
http-provider.c \
http-message.c
http-message.c \
http-listener.c
if BUILD_TUNNEL
libbellesip_la_SOURCES+= transports/tunnel_listeningpoint.c \
......
......@@ -183,6 +183,7 @@ struct _belle_sdp_media {
belle_sip_list_t* media_formats;
int port_count;
const char* protocol;
const char* raw_fmt;
};
belle_sip_list_t* belle_sdp_media_get_media_formats(const belle_sdp_media_t* media) {
return media->media_formats;
......@@ -991,16 +992,7 @@ belle_sip_error_code belle_sdp_session_description_marshal(belle_sdp_session_des
BELLE_SDP_NEW(session_description,belle_sdp_base_description)
BELLE_SDP_PARSE(session_description)
belle_sdp_session_description_t* belle_sdp_session_description_create(belle_sip_message_t* message) {
belle_sdp_session_description_t* session_desc=NULL;
belle_sip_header_content_type_t* content_type=belle_sip_message_get_header_by_type(message,belle_sip_header_content_type_t);
if (content_type
&& strcmp("application",belle_sip_header_content_type_get_type(content_type))==0
&& strcmp("sdp",belle_sip_header_content_type_get_subtype(content_type))==0) {
session_desc=belle_sdp_session_description_parse(belle_sip_message_get_body(message));
}
return session_desc;
}
const char* belle_sdp_session_description_get_attribute_value(const belle_sdp_session_description_t* session_description, const char* name) {
return belle_sdp_base_description_get_attribute_value(BELLE_SIP_CAST(session_description,belle_sdp_base_description_t),name);
}
......
......@@ -63,7 +63,6 @@
#endif
#include "port.h"
/*etc*/
......@@ -107,6 +106,10 @@
method(__obj,arg1,arg2,arg3);\
__BELLE_SIP_INVOKE_LISTENER_END
#define BELLE_SIP_INVOKE_LISTENER_ARG(listener,interface_name,method,arg) \
((BELLE_SIP_INTERFACE_GET_METHODS((listener),interface_name)->method!=NULL) ? \
BELLE_SIP_INTERFACE_GET_METHODS((listener),interface_name)->method(listener,(arg)) : 0 )
typedef struct weak_ref{
struct weak_ref *next;
belle_sip_object_destroy_notify_t notify;
......@@ -196,6 +199,7 @@ BELLE_SIP_DECLARE_VPTR(belle_http_channel_context_t);
BELLE_SIP_DECLARE_VPTR(belle_http_request_t);
BELLE_SIP_DECLARE_VPTR(belle_http_response_t);
BELLE_SIP_DECLARE_VPTR(belle_generic_uri_t);
BELLE_SIP_DECLARE_VPTR(belle_http_callbacks_t);
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_resolver_context_t,belle_sip_source_t)
void (*cancel)(belle_sip_resolver_context_t *);
......@@ -433,15 +437,12 @@ antlr3NewAsciiStringCopyStream((pANTLR3_UINT8)value,(ANTLR3_UINT32)length,NULL)
if (name) belle_sip_header_set_name(BELLE_SIP_HEADER(l_object),name);\
return l_object;\
}
typedef struct belle_sip_param_pair_t {
typedef struct belle_sip_param_pair {
int ref;
char* name;
char* value;
} belle_sip_param_pair_t;
belle_sip_param_pair_t* belle_sip_param_pair_new(const char* name,const char* value);
void belle_sip_param_pair_destroy(belle_sip_param_pair_t* pair) ;
int belle_sip_param_pair_comp_func(const belle_sip_param_pair_t *a, const char*b) ;
......@@ -463,7 +464,6 @@ struct _belle_sip_header {
};
void belle_sip_header_set_next(belle_sip_header_t* header,belle_sip_header_t* next);
BELLESIP_INTERNAL_EXPORT belle_sip_header_t* belle_sip_header_get_next(const belle_sip_header_t* headers);
void belle_sip_response_fill_for_dialog(belle_sip_response_t *obj, belle_sip_request_t *req);
void belle_sip_util_copy_headers(belle_sip_message_t *orig, belle_sip_message_t *dest, const char*header, int multiple);
......@@ -515,6 +515,7 @@ struct belle_sip_stack{
belle_sip_hop_t* belle_sip_hop_new(const char* transport, const char *cname, const char* host,int port);
belle_sip_hop_t* belle_sip_hop_new_from_uri(const belle_sip_uri_t *uri);
belle_sip_hop_t* belle_sip_hop_new_from_generic_uri(const belle_generic_uri_t *uri);
belle_sip_hop_t * belle_sip_stack_get_next_hop(belle_sip_stack_t *stack, belle_sip_request_t *req);
const belle_sip_timer_config_t *belle_sip_stack_get_timer_config(const belle_sip_stack_t *stack);
......@@ -596,8 +597,19 @@ struct _belle_sip_request {
unsigned char dialog_queued;
};
void belle_http_request_set_listener(belle_http_request_t *req, belle_http_request_listener_t *l);
/** HTTP request**/
struct belle_http_request{
belle_sip_message_t base;
belle_generic_uri_t *req_uri;
char* method;
belle_http_request_listener_t *listener;
belle_http_response_t *response;
};
void belle_http_request_set_listener(belle_http_request_t *req, belle_http_request_listener_t *l);
void belle_http_request_set_response(belle_http_request_t *req, belle_http_response_t *resp);
/*
belle_sip_transaction_t
*/
......@@ -792,15 +804,6 @@ void belle_sip_dialog_queue_client_transaction(belle_sip_dialog_t *dialog, belle
*/
belle_sip_hop_t* belle_sip_response_get_return_hop(belle_sip_response_t *msg);
#define IS_TOKEN(token) \
(INPUT->toStringTT(INPUT,LT(1),LT(strlen(#token)))->chars ?\
strcasecmp(#token,(const char*)(INPUT->toStringTT(INPUT,LT(1),LT(strlen(#token)))->chars)) == 0:0)
char* _belle_sip_str_dup_and_unquote_string(const char* quoted_string);
#define IS_HEADER_NAMED(name,compressed_name) (IS_TOKEN(compressed_name) || IS_TOKEN(name))
#define STRCASECMP_HEADER_NAMED(name,compressed_name,value) \
(strcasecmp(compressed_name,(const char*)value) == 0 || strcasecmp(name,(const char*)value) == 0 )
/*********************************************************
* SDP
......@@ -922,7 +925,7 @@ BELLESIP_INTERNAL_EXPORT char* belle_sip_uri_to_escaped_username(const char* buf
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_INTERNAL_EXPORT char* belle_sip_to_unescaped_string(const char* buff) ;
/*(uri RFC 2396)*/
......@@ -943,4 +946,6 @@ void belle_sip_dialog_update_request(belle_sip_dialog_t *dialog, belle_sip_reque
belle_sip_error_code belle_sip_headers_marshal(belle_sip_message_t *message, char* buff, size_t buff_size, size_t *offset);
#include "parserutils.h"
#endif
......@@ -213,7 +213,8 @@ static struct dns_resolv_conf *resconf(belle_sip_simple_resolver_context_t *ctx)
for(i=0;i<sizeof(ctx->resconf->nameserver)/sizeof(ctx->resconf->nameserver[0]);++i){
struct sockaddr *ns_addr=(struct sockaddr*)&ctx->resconf->nameserver[i];
if (ns_addr->sa_family==AF_UNSPEC) break;
getnameinfo(ns_addr,sizeof(struct sockaddr_storage),ip,sizeof(ip),serv,sizeof(serv),NI_NUMERICHOST|NI_NUMERICSERV);
getnameinfo(ns_addr,ns_addr->sa_family==AF_INET6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr)
,ip,sizeof(ip),serv,sizeof(serv),NI_NUMERICHOST|NI_NUMERICSERV);
belle_sip_message("\t%s",ip);
if (ns_addr->sa_family==AF_INET6) using_ipv6=TRUE;
}
......
......@@ -85,11 +85,15 @@ static void fix_incoming_via(belle_sip_request_t *msg, const struct addrinfo* or
char rport[NI_MAXSERV];
belle_sip_header_via_t *via;
int err;
struct sockaddr_storage saddr;
socklen_t slen=sizeof(saddr);
if (!origin) {
belle_sip_warning("cannot fix via for message [%p], probably a test",msg);
return;
}
err=getnameinfo(origin->ai_addr,origin->ai_addrlen,received,sizeof(received),
belle_sip_address_remove_v4_mapping(origin->ai_addr, (struct sockaddr*)&saddr, &slen);
err=getnameinfo((struct sockaddr*)&saddr,slen,received,sizeof(received),
rport,sizeof(rport),NI_NUMERICHOST|NI_NUMERICSERV);
if (err!=0){
belle_sip_error("fix_via: getnameinfo() failed: %s",gai_strerror(errno));
......@@ -714,7 +718,12 @@ void belle_sip_channel_set_ready(belle_sip_channel_t *obj, const struct sockaddr
char serv[NI_MAXSERV];
if (obj->local_ip==NULL){
int err=getnameinfo(addr,slen,name,sizeof(name),serv,sizeof(serv),NI_NUMERICHOST|NI_NUMERICSERV);
struct sockaddr_storage saddr;
socklen_t slen2=sizeof(saddr);
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);
if (err!=0){
belle_sip_error("belle_sip_channel_set_ready(): getnameinfo() failed: %s",gai_strerror(err));
}else{
......
......@@ -133,7 +133,7 @@ void belle_sip_channel_init_with_addr(belle_sip_channel_t *obj, belle_sip_stack_
void belle_sip_channel_set_socket(belle_sip_channel_t *obj, belle_sip_socket_t sock, belle_sip_source_func_t datafunc);
/*end of channel implementations*/
/**
* pickup last received message. This method take the ownership of the message.
* Get a received message from the receive queue. This caller takes the ownership of the message.
*/
belle_sip_message_t* belle_sip_channel_pick_message(belle_sip_channel_t *obj);
......
......@@ -69,9 +69,23 @@ options {
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wunused"
}
@rulecatch
{
if (HASEXCEPTION())
{
// This is ugly. We set the exception type to ANTLR3_RECOGNITION_EXCEPTION so we can always
// catch them.
//PREPORTERROR();
EXCEPTION->type = ANTLR3_RECOGNITION_EXCEPTION;
}
}
@includes {
#include "belle-sip/defs.h"
#include "belle-sip/types.h"
#include "parserutils.h"
#include "belle-sip/belle-sdp.h"
#include "belle_sip_internal.h"
}
session_description returns [belle_sdp_session_description_t* ret]
......@@ -87,7 +101,7 @@ scope { belle_sdp_session_description_t* current; }
(connection {belle_sdp_session_description_set_connection($session_description::current,$connection.ret);} CR LF)?
(bandwidth {belle_sdp_session_description_add_bandwidth($session_description::current,$bandwidth.ret);} CR LF)*
time_field CR LF
(repeat_time CR LF)?
(repeat_time CR LF)*