Commit 5afdfd43 authored by jehan's avatar jehan

dialog testing

parent 6c40a924
......@@ -194,7 +194,7 @@
</scannerInfoProvider>
</profile>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.macosx.base.557244179.959032290;cdt.managedbuild.toolchain.gnu.macosx.base.557244179.959032290.;cdt.managedbuild.tool.gnu.c.compiler.macosx.base.3940526;cdt.managedbuild.tool.gnu.c.compiler.input.2089521215">
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.macosx.base.557244179;cdt.managedbuild.toolchain.gnu.macosx.base.557244179.779699347;cdt.managedbuild.tool.gnu.c.compiler.macosx.base.1327025999;cdt.managedbuild.tool.gnu.c.compiler.input.1517483722">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
<buildOutputProvider>
......@@ -237,7 +237,7 @@
</scannerInfoProvider>
</profile>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.macosx.base.557244179;cdt.managedbuild.toolchain.gnu.macosx.base.557244179.779699347;cdt.managedbuild.tool.gnu.c.compiler.macosx.base.1327025999;cdt.managedbuild.tool.gnu.c.compiler.input.1517483722">
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.macosx.base.557244179.959032290;cdt.managedbuild.toolchain.gnu.macosx.base.557244179.959032290.;cdt.managedbuild.tool.gnu.c.compiler.macosx.base.3940526;cdt.managedbuild.tool.gnu.c.compiler.input.2089521215">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
<buildOutputProvider>
......
......@@ -36,7 +36,8 @@ void belle_sip_transaction_set_application_data(belle_sip_transaction_t *t, void
const char *belle_sip_transaction_get_branch_id(const belle_sip_transaction_t *t);
belle_sip_transaction_state_t belle_sip_transaction_get_state(const belle_sip_transaction_t *t);
void belle_sip_transaction_terminate(belle_sip_transaction_t *t);
belle_sip_request_t *belle_sip_transaction_get_request(belle_sip_transaction_t *t);
belle_sip_request_t *belle_sip_transaction_get_request(const belle_sip_transaction_t *t);
belle_sip_dialog_t* belle_sip_transaction_get_dialog(const belle_sip_transaction_t *t);
void belle_sip_server_transaction_send_response(belle_sip_server_transaction_t *t, belle_sip_response_t *resp);
......
......@@ -207,7 +207,8 @@ BELLE_SIP_NEW_HEADER(header_contact,header_address,BELLE_SIP_CONTACT)
BELLE_SIP_PARSE(header_contact)
belle_sip_header_contact_t* belle_sip_header_contact_create (const belle_sip_header_address_t* contact) {
belle_sip_header_contact_t* header = belle_sip_header_contact_new();
belle_sip_header_address_clone(BELLE_SIP_HEADER_ADDRESS(header),contact);
_belle_sip_object_copy(BELLE_SIP_OBJECT(header),BELLE_SIP_OBJECT(contact));
belle_sip_header_set_name(BELLE_SIP_HEADER(header),BELLE_SIP_CONTACT); /*restaure header name*/
return header;
}
GET_SET_INT_PARAM_PRIVATE(belle_sip_header_contact,expires,int,_)
......@@ -269,7 +270,7 @@ belle_sip_header_from_t* belle_sip_header_from_create2(const char *address, cons
belle_sip_header_from_t* belle_sip_header_from_create(const belle_sip_header_address_t* address, const char *tag) {
belle_sip_header_from_t* header= belle_sip_header_from_new();
_belle_sip_object_copy((belle_sip_object_t*)header,(belle_sip_object_t*)address);
/*belle_sip_header_set_name(BELLE_SIP_HEADER(header),BELLE_SIP_FROM);*/ /*restaure header name*/
belle_sip_header_set_name(BELLE_SIP_HEADER(header),BELLE_SIP_FROM); /*restaure header name*/
if (tag) belle_sip_header_from_set_tag(header,tag);
return header;
}
......
......@@ -515,7 +515,7 @@ char* _belle_sip_str_dup_and_unquote_string(const char* quoted_string) {
}
unsigned int belle_sip_random(void){
#ifdef __linux
#if __linux || __APPLE__
static int fd=-1;
if (fd==-1) fd=open("/dev/urandom",O_RDONLY);
if (fd!=-1){
......
......@@ -175,8 +175,9 @@ void belle_sip_channel_process_data(belle_sip_channel_t *obj,unsigned int revent
if (obj->input_stream.state==BODY_AQUISITION) {
content_length=belle_sip_header_content_length_get_content_length((belle_sip_header_content_length_t*)belle_sip_message_get_header(obj->input_stream.msg,BELLE_SIP_CONTENT_LENGTH));
if (content_length >= obj->input_stream.write_ptr-obj->input_stream.read_ptr) {
if (content_length <= obj->input_stream.write_ptr-obj->input_stream.read_ptr) {
/*great body completed*/
belle_sip_message("read body from %s:%i\n%s",obj->peer_name,obj->peer_port,obj->input_stream.read_ptr);
belle_sip_message_set_body(obj->input_stream.msg,obj->input_stream.read_ptr,content_length);
goto message_ready;
......
......@@ -459,8 +459,7 @@ belle_sip_response_t *belle_sip_response_create_from_request(belle_sip_request_t
belle_sip_header_t *h;
belle_sip_header_to_t *to;
belle_sip_response_init_default(resp,status_code,NULL);
if (status_code==100){
h=belle_sip_message_get_header((belle_sip_message_t*)req,"timestamp");
if (status_code==100 && (h=belle_sip_message_get_header((belle_sip_message_t*)req,"timestamp"))){
belle_sip_message_add_header((belle_sip_message_t*)resp,h);
}
belle_sip_message_add_headers((belle_sip_message_t*)resp,belle_sip_message_get_headers ((belle_sip_message_t*)req,"via"));
......@@ -472,7 +471,7 @@ belle_sip_response_t *belle_sip_response_create_from_request(belle_sip_request_t
}else{
to=(belle_sip_header_to_t*)h;
}
belle_sip_message_add_header((belle_sip_message_t*)req,(belle_sip_header_t*)to);
belle_sip_message_add_header((belle_sip_message_t*)resp,(belle_sip_header_t*)to);
h=belle_sip_message_get_header((belle_sip_message_t*)req,"call-id");
belle_sip_message_add_header((belle_sip_message_t*)resp,h);
belle_sip_message_add_header((belle_sip_message_t*)resp,belle_sip_message_get_header((belle_sip_message_t*)req,"cseq"));
......@@ -494,7 +493,7 @@ void belle_sip_response_fill_for_dialog(belle_sip_response_t *obj, belle_sip_req
void belle_sip_response_get_return_hop(belle_sip_response_t *msg, belle_sip_hop_t *hop){
belle_sip_header_via_t *via=BELLE_SIP_HEADER_VIA(belle_sip_message_get_header(BELLE_SIP_MESSAGE(msg),"via"));
const char *host;
hop->transport=belle_sip_strdup(belle_sip_header_via_get_protocol(via));
hop->transport=belle_sip_strdup(belle_sip_header_via_get_transport(via));
host=belle_sip_header_via_get_received(via);
if (host==NULL)
host=belle_sip_header_via_get_host(via);
......
......@@ -231,8 +231,8 @@ belle_sip_dialog_t * belle_sip_provider_create_dialog(belle_sip_provider_t *prov
int code=belle_sip_response_get_status_code(t->last_response);
if (code>=200 && code<300){
belle_sip_fatal("You must not create dialog after sending the response that establish the dialog.");
return NULL;
}
return NULL;
}
dialog=belle_sip_dialog_new(t);
if (dialog)
......
......@@ -85,7 +85,7 @@ void belle_sip_transaction_terminate(belle_sip_transaction_t *t){
belle_sip_provider_set_transaction_terminated(t->provider,t);
}
belle_sip_request_t *belle_sip_transaction_get_request(belle_sip_transaction_t *t){
belle_sip_request_t *belle_sip_transaction_get_request(const belle_sip_transaction_t *t){
return t->request;
}
......@@ -331,4 +331,7 @@ void belle_sip_client_transaction_init(belle_sip_client_transaction_t *obj, bell
belle_sip_transaction_init((belle_sip_transaction_t*)obj, prov,req);
}
belle_sip_dialog_t* belle_sip_transaction_get_dialog(const belle_sip_transaction_t *t) {
return t->dialog;
}
......@@ -91,13 +91,35 @@ static void process_io_error(void *user_ctx, const belle_sip_io_error_event_t *e
belle_sip_message("process_io_error not implemented yet");
}
static void process_request_event(void *user_ctx, const belle_sip_request_event_t *event) {
/*belle_sip_server_transaction_t* server_transaction = belle_sip_request_event_get_server_transaction(event);
SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(BELLE_SIP_TRANSACTION(server_transaction));*/
belle_sip_server_transaction_t* server_transaction = belle_sip_request_event_get_server_transaction(event);
if (!server_transaction) {
server_transaction= belle_sip_provider_create_server_transaction(prov,belle_sip_request_event_get_request(event));
}
belle_sip_dialog_t* dialog = belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(server_transaction));
belle_sip_response_t* ringing_response;
if (!dialog ) {
CU_ASSERT_STRING_EQUAL_FATAL("INVITE",belle_sip_request_get_method(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(server_transaction))))
dialog=belle_sip_provider_create_dialog(prov,BELLE_SIP_TRANSACTION(server_transaction));
}
if (belle_sip_dialog_get_state(dialog) == BELLE_SIP_DIALOG_NULL) {
ringing_response = belle_sip_response_create_from_request(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(server_transaction)),180);
belle_sip_server_transaction_send_response(server_transaction,ringing_response);
}
belle_sip_message("process_request_event not implemented yet");
}
static void process_response_event(void *user_ctx, const belle_sip_response_event_t *event){
belle_sip_message("process_response_event not implemented yet");
static void caller_process_response_event(void *user_ctx, const belle_sip_response_event_t *event){
belle_sip_client_transaction_t* client_transaction = belle_sip_response_event_get_client_transaction(event);
belle_sip_dialog_t* dialog = belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(client_transaction));
CU_ASSERT_PTR_NOT_NULL_FATAL(dialog);
belle_sip_message("caller_process_response_event");
}
static void callee_process_response_event(void *user_ctx, const belle_sip_response_event_t *event){
/*belle_sip_client_transaction_t* server_transaction = belle_sip_response_event_get_client_transaction(event);*/
belle_sip_message("callee_process_response_event");
}
static void process_timeout(void *user_ctx, const belle_sip_timeout_event_t *event) {
/* belle_sip_client_transaction_t* client_transaction = belle_sip_timeout_event_get_client_transaction(event);
......@@ -157,15 +179,15 @@ static void simple_call(void) {
caller_listener_callbacks.process_dialog_terminated=process_dialog_terminated;
caller_listener_callbacks.process_io_error=process_io_error;
caller_listener_callbacks.process_request_event=process_request_event;
caller_listener_callbacks.process_response_event=process_response_event;
caller_listener_callbacks.process_request_event=NULL;
caller_listener_callbacks.process_response_event=caller_process_response_event;
caller_listener_callbacks.process_timeout=process_timeout;
caller_listener_callbacks.process_transaction_terminated=process_transaction_terminated;
callee_listener_callbacks.process_dialog_terminated=process_dialog_terminated;
callee_listener_callbacks.process_io_error=process_io_error;
callee_listener_callbacks.process_request_event=process_request_event;
callee_listener_callbacks.process_response_event=process_response_event;
callee_listener_callbacks.process_response_event=callee_process_response_event;
callee_listener_callbacks.process_timeout=process_timeout;
callee_listener_callbacks.process_transaction_terminated=process_transaction_terminated;
......@@ -192,6 +214,8 @@ static void simple_call(void) {
client_transaction = belle_sip_provider_create_client_transaction(prov,req);
belle_sip_provider_create_dialog(prov,BELLE_SIP_TRANSACTION(client_transaction));
CU_ASSERT_PTR_NOT_NULL_FATAL(belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(client_transaction)));
//belle_sip_transaction_set_application_data(BELLE_SIP_TRANSACTION(client_transaction),op);
belle_sip_client_transaction_send_request(client_transaction);
belle_sip_stack_sleep(stack,3000);
......
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