Commit 6b9d281b authored by jehan's avatar jehan
Browse files

Non ist still need to be fixed.

However, call establishment is now fonctionnal.
parent 0619bcbe
......@@ -135,7 +135,11 @@ void belle_sip_channel_process_data(belle_sip_channel_t *obj,unsigned int revent
belle_sip_header_content_length_t* content_length_header;
int content_length;
if (revents)
num=belle_sip_channel_recv(obj,obj->input_stream.write_ptr,belle_sip_channel_input_stream_get_buff_lenght(&obj->input_stream)-1);
else
num=obj->input_stream.write_ptr-obj->input_stream.read_ptr;
if (num>0){
/*first null terminate the buff*/
obj->input_stream.write_ptr[num]='\0';
......@@ -203,7 +207,7 @@ void belle_sip_channel_process_data(belle_sip_channel_t *obj,unsigned int revent
BELLE_SIP_INVOKE_LISTENERS_ARG1_ARG2(obj->listeners,belle_sip_channel_listener_t,on_event,obj,revents);
if (obj->input_stream.write_ptr-obj->input_stream.read_ptr>0) {
/*process residu*/
belle_sip_channel_process_data(obj,revents);
belle_sip_channel_process_data(obj,0);
}
return;
} else if (num == 0) {
......
......@@ -89,8 +89,8 @@ static void ict_on_response(belle_sip_ict_t *obj, belle_sip_response_t *resp){
case BELLE_SIP_TRANSACTION_PROCEEDING:
if (code>=300){
base->state=BELLE_SIP_TRANSACTION_COMPLETED;
belle_sip_client_transaction_notify_response((belle_sip_client_transaction_t*)obj,resp);
belle_sip_channel_queue_message(base->channel,(belle_sip_message_t*)make_ack(obj,resp));
belle_sip_client_transaction_notify_response((belle_sip_client_transaction_t*)obj,resp);
obj->timer_D=belle_sip_timeout_source_new((belle_sip_source_func_t)ict_on_timer_D,obj,32000);
belle_sip_transaction_start_timer(base,obj->timer_D);
}else if (code>=200){
......
......@@ -59,14 +59,17 @@ static int nist_send_new_response(belle_sip_nist_t *obj, belle_sip_response_t *r
case BELLE_SIP_TRANSACTION_TRYING:
if (code<200){
base->state=BELLE_SIP_TRANSACTION_PROCEEDING;
belle_sip_channel_queue_message(base->channel,(belle_sip_message_t*)base->last_response);
}
belle_sip_channel_queue_message(base->channel,(belle_sip_message_t*)resp);
break;
}
/* no break nist can directly pass from TRYING to PROCEEDING*/
case BELLE_SIP_TRANSACTION_PROCEEDING:
if (code>=200){
nist_set_completed(obj);
}
belle_sip_channel_queue_message(base->channel,(belle_sip_message_t*)base->last_response);
belle_sip_channel_queue_message(base->channel,(belle_sip_message_t*)resp);
/*FIXME*/
belle_sip_warning("nist_send_new_response(): FIX ME what about retransmision timers ??");
break;
case BELLE_SIP_TRANSACTION_COMPLETED:
belle_sip_warning("nist_send_new_response(): not allowed to send a response while transaction is completed.");
......
......@@ -18,6 +18,7 @@
#include "belle_sip_internal.h"
#include "listeningpoint_internal.h"
belle_sip_dialog_t *belle_sip_provider_find_dialog(belle_sip_provider_t *prov, belle_sip_request_t *msg, int as_uas);
typedef struct authorization_context {
belle_sip_header_call_id_t* callid;
......@@ -75,16 +76,20 @@ static void channel_state_changed(belle_sip_channel_listener_t *obj, belle_sip_c
static void belle_sip_provider_dispatch_request(belle_sip_provider_t* prov, belle_sip_request_t *req){
belle_sip_server_transaction_t *t;
belle_sip_request_event_t ev;
t=belle_sip_provider_find_matching_server_transaction(prov,req);
if (t){
belle_sip_object_ref(t);
belle_sip_server_transaction_on_request(t,req);
belle_sip_object_unref(t);
}else{
belle_sip_request_event_t ev;
ev.dialog=NULL;
/* Should we limit to ACK ? if (strcmp("ACK",belle_sip_request_get_method(req))==0) */
/*Search for a dialog if exist */
ev.dialog=belle_sip_provider_find_dialog(prov,req,0);
ev.source=prov;
ev.server_transaction=NULL;
ev.dialog=NULL;
ev.request=req;
BELLE_SIP_PROVIDER_INVOKE_LISTENERS(prov,process_request_event,&ev);
}
......@@ -273,8 +278,10 @@ belle_sip_dialog_t * belle_sip_provider_create_dialog(belle_sip_provider_t *prov
}
}
dialog=belle_sip_dialog_new(t);
if (dialog)
if (dialog) {
t->dialog=(belle_sip_dialog_t*)belle_sip_object_ref(dialog);
belle_sip_provider_add_dialog(prov,(belle_sip_dialog_t*)belle_sip_object_ref(dialog));
}
return dialog;
}
......
......@@ -88,6 +88,11 @@ static void process_transaction_terminated(belle_sip_listener_t *l, const belle_
if (obj->cbs.process_transaction_terminated)
obj->cbs.process_transaction_terminated(obj->user_ctx,event);
}
static void process_auth_requested(belle_sip_listener_t *l, belle_sip_auth_event_t *event){
belle_sip_callbacks_t *obj=(belle_sip_callbacks_t*)l;
if (obj->cbs.process_auth_requested)
obj->cbs.process_auth_requested(obj->user_ctx,event);
}
BELLE_SIP_DECLARE_VPTR(belle_sip_callbacks_t);
......@@ -97,7 +102,8 @@ BELLE_SIP_IMPLEMENT_INTERFACE_BEGIN(belle_sip_callbacks_t,belle_sip_listener_t)
process_request_event,
process_response_event,
process_timeout,
process_transaction_terminated
process_transaction_terminated,
process_auth_requested
BELLE_SIP_IMPLEMENT_INTERFACE_END
BELLE_SIP_DECLARE_IMPLEMENTED_INTERFACES_1(belle_sip_callbacks_t,belle_sip_listener_t);
......
......@@ -24,6 +24,7 @@
extern belle_sip_stack_t * stack;
extern belle_sip_provider_t *prov;
extern const char *test_domain;
int call_endeed;
extern int register_init(void);
extern int register_uninit(void);
extern belle_sip_request_t* register_user(belle_sip_stack_t * stack
......@@ -116,6 +117,22 @@ static void process_dialog_terminated(void *user_ctx, const belle_sip_dialog_ter
static void process_io_error(void *user_ctx, const belle_sip_io_error_event_t *event){
belle_sip_message("process_io_error not implemented yet");
}
static void caller_process_request_event(void *user_ctx, const belle_sip_request_event_t *event) {
belle_sip_header_to_t* to=belle_sip_message_get_header_by_type(belle_sip_request_event_get_request(event),belle_sip_header_to_t);
if (!belle_sip_uri_equals(BELLE_SIP_URI(user_ctx),belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(to)))) {
return; /*not for the caller*/
}
belle_sip_message("caller_process_request_event received [%s] message",belle_sip_request_get_method(belle_sip_request_event_get_request(event)));
belle_sip_server_transaction_t* server_transaction =belle_sip_provider_create_server_transaction(prov,belle_sip_request_event_get_request(event));
belle_sip_response_t* resp;
CU_ASSERT_STRING_EQUAL_FATAL("BYE",belle_sip_request_get_method(belle_sip_request_event_get_request(event)));
belle_sip_dialog_t* dialog = belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(server_transaction));
CU_ASSERT_PTR_NOT_NULL_FATAL(dialog);
CU_ASSERT_EQUAL(belle_sip_dialog_get_state(dialog) , BELLE_SIP_DIALOG_CONFIRMED);
resp=belle_sip_response_create_from_request(belle_sip_request_event_get_request(event),200);
belle_sip_server_transaction_send_response(server_transaction,resp);
}
static void callee_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);
belle_sip_header_to_t* to=belle_sip_message_get_header_by_type(belle_sip_request_event_get_request(event),belle_sip_header_to_t);
......@@ -150,6 +167,10 @@ static void callee_process_request_event(void *user_ctx, const belle_sip_request
belle_sip_message_set_body(BELLE_SIP_MESSAGE(ok_response),sdp,strlen(sdp));
/*only send ringing*/
belle_sip_server_transaction_send_response(server_transaction,ringing_response);
} else if (belle_sip_dialog_get_state(dialog) == BELLE_SIP_DIALOG_CONFIRMED) {
/*time to send bye*/
belle_sip_client_transaction_t* client_transaction = belle_sip_provider_create_client_transaction(prov,belle_sip_dialog_create_request(dialog,"BYE"));
belle_sip_client_transaction_send_request(client_transaction);
}
}
......@@ -235,7 +256,7 @@ 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=NULL;
caller_listener_callbacks.process_request_event=caller_process_request_event;
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;
......@@ -275,7 +296,10 @@ static void simple_call(void) {
caller_dialog=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);
call_endeed=0;
belle_sip_client_transaction_send_request(client_transaction);
int i=0;
for(i=0;i<10 &&!call_endeed;i++)
belle_sip_stack_sleep(stack,3000);
belle_sip_provider_remove_sip_listener(prov,caller_listener);
......
......@@ -313,7 +313,7 @@ int belle_sip_register_test_suite(){
if (NULL == CU_add_test(pSuite, "stateful-udp-register-with-network-delay", stateful_register_udp_delayed)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "stateful tcp register", stateful_register_tcp)) {
if (NULL == CU_add_test(pSuite, "stateful-tcp-register", stateful_register_tcp)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "stateful tls register", stateful_register_tls)) {
......
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