diff --git a/trunk/tinyDEMO/core-ericsson.sn b/trunk/tinyDEMO/core-ericsson.sn index 1fb25ca9..7d5c3fb0 100644 --- a/trunk/tinyDEMO/core-ericsson.sn +++ b/trunk/tinyDEMO/core-ericsson.sn @@ -7,7 +7,7 @@ %%proxy_ip 192.168.0.13 # IP address or FQDN %%proxy_port 5081 %%proxy_trans tcp # udp, tcp, tls or sctp -%%expires 36 # expires used by all dialogs +%%expires 10 # expires used by all dialogs %%sleep-sec 1.0 # number of seconds to wait before sending next sip message %%reg-sid @@ -46,12 +46,12 @@ --header Allow-Events=refer, presence, presence.winfo, xcap-diff, conference >>(sub-reg-sid) #subscribe to presence event package (alice) -#++sub --to sip:alice@$$(domain) --xp $$(expires) --header Event=presence --header Supported=eventlist\ -# --header Accept=multipart/related, application/rlmi+xml, application/pidf+xml, application/rpid+xml, application/xcap-diff+xml, message/external-body \ -# --header Allow-Events=refer, presence, presence.winfo, xcap-diff, conference >>(sub-pres-sid) +++sub --to sip:alice@$$(domain) --xp $$(expires) --header Event=presence --header Supported=eventlist\ + --header Accept=multipart/related, application/rlmi+xml, application/pidf+xml, application/rpid+xml, application/xcap-diff+xml, message/external-body \ + --header Allow-Events=refer, presence, presence.winfo, xcap-diff, conference >>(sub-pres-sid) #publish -#++sn --path ./publish.sn +++sn --path ./publish.sn #send Pager Mode IM #++m --to sip:alice@$$(domain) \ diff --git a/trunk/tinyDEMO/core-micromethod.sn b/trunk/tinyDEMO/core-micromethod.sn index cdd04c7d..f84e8813 100644 --- a/trunk/tinyDEMO/core-micromethod.sn +++ b/trunk/tinyDEMO/core-micromethod.sn @@ -27,9 +27,9 @@ ++r # REGISTER -++reg --xp $$(expires) --caps +g.oma.sip-im --caps +g.3gpp.smsip --caps language="en,fr" \ - --header Action-Header=Myheader-value @@action\ - >>(reg-sid) +#++reg --xp $$(expires) --caps +g.oma.sip-im --caps +g.3gpp.smsip --caps language="en,fr" \ +# --header Action-Header=Myheader-value @@action\ +# >>(reg-sid) # sleep #++sleep --sec $$(sleep-sec) diff --git a/trunk/tinyDEMO/main.sn b/trunk/tinyDEMO/main.sn index ae26e09b..6d57047f 100644 --- a/trunk/tinyDEMO/main.sn +++ b/trunk/tinyDEMO/main.sn @@ -5,13 +5,13 @@ #++sn --path ./core-colibria.sn # Ericsson -#++sn --path ./core-ericsson.sn +++sn --path ./core-ericsson.sn # Inexbee #++sn --path ./core-inexbee.sn # Micromethod -++sn --path ./core-micromethod.sn +#++sn --path ./core-micromethod.sn # Nokia Siemens Networks #++sn --path ./core-nsn.sn diff --git a/trunk/tinyHTTP/src/thttp.c b/trunk/tinyHTTP/src/thttp.c index 33228f66..9aced6e4 100644 --- a/trunk/tinyHTTP/src/thttp.c +++ b/trunk/tinyHTTP/src/thttp.c @@ -244,8 +244,10 @@ int ret = thttp_action_GET(session, "http://ipv6.google.com", /**@defgroup thttp_stack_group HTTP/HTTPS stack */ -/** Callback function used by the transport layer to alert the stack when new messages come. -*/ +/* min size of a stream chunck to form a valid HTTP message */ +#define THTTP_MIN_STREAM_CHUNCK_SIZE 0x32 + +/** Callback function used by the transport layer to alert the stack when new messages come. */ static int thttp_transport_layer_stream_cb(const tnet_transport_event_t* e) { int ret = -1; @@ -306,6 +308,7 @@ static int thttp_transport_layer_stream_cb(const tnet_transport_event_t* e) tsk_buffer_append(dialog->buf, e->data, e->size); /* Check if we have all HTTP headers. */ +parse_buffer: if((endOfheaders = tsk_strindexOf(TSK_BUFFER_DATA(dialog->buf), TSK_BUFFER_SIZE(dialog->buf), "\r\n\r\n"/*2CRLF*/)) < 0){ TSK_DEBUG_INFO("No all HTTP headers in the TCP buffer."); goto bail; @@ -369,10 +372,15 @@ static int thttp_transport_layer_stream_cb(const tnet_transport_event_t* e) } } - /* Alert the operation (FSM) */ + /* Alert the dialog (FSM) */ if(message){ if(have_all_content){ /* only if we have all data */ ret = thttp_dialog_fsm_act(dialog, thttp_atype_i_message, message, tsk_null); + /* Parse next chunck */ + if(TSK_BUFFER_SIZE(dialog->buf) >= THTTP_MIN_STREAM_CHUNCK_SIZE){ + TSK_OBJECT_SAFE_FREE(message); + goto parse_buffer; + } } } diff --git a/trunk/tinyHTTP/test/test_url.h b/trunk/tinyHTTP/test/test_url.h index 1e7761e3..12c3b5de 100644 --- a/trunk/tinyHTTP/test/test_url.h +++ b/trunk/tinyHTTP/test/test_url.h @@ -65,7 +65,7 @@ void test_url_parser() printf("port: %u\n", url->port); printf("hpath: %s\n", url->hpath); printf("search: %s\n", url->search); - printf("host-type: %s\n", url->host_type == host_ipv4 ? "IPv4" : (url->host_type == host_ipv6 ? "IPv6" : (url->host_type == host_hostname ? "HOSTNAME" : "UNKNOWN")) ); + printf("host-type: %s\n", url->host_type == thttp_host_ipv4 ? "IPv4" : (url->host_type == thttp_host_ipv6 ? "IPv6" : (url->host_type == thttp_host_hostname ? "HOSTNAME" : "UNKNOWN")) ); printf("---PARAMS---\n"); diff --git a/trunk/tinySIP/src/dialogs/tsip_dialog_publish.client.c b/trunk/tinySIP/src/dialogs/tsip_dialog_publish.client.c index 2f7a6758..1262f52d 100644 --- a/trunk/tinySIP/src/dialogs/tsip_dialog_publish.client.c +++ b/trunk/tinySIP/src/dialogs/tsip_dialog_publish.client.c @@ -43,7 +43,7 @@ #include "tsk_debug.h" #include "tsk_time.h" -#define DEBUG_STATE_MACHINE 1 +#define DEBUG_STATE_MACHINE 0 #define TSIP_DIALOG_PUBLISH_TIMER_SCHEDULE(TX) TSIP_DIALOG_TIMER_SCHEDULE(publish, TX) #define TSIP_DIALOG_PUBLISH_SIGNAL(self, type, code, phrase, message) \ tsip_publish_event_signal(type, TSIP_DIALOG(self)->ss, code, phrase, message) diff --git a/trunk/tinySIP/src/dialogs/tsip_dialog_register.client.c b/trunk/tinySIP/src/dialogs/tsip_dialog_register.client.c index d6a160d9..352e9132 100644 --- a/trunk/tinySIP/src/dialogs/tsip_dialog_register.client.c +++ b/trunk/tinySIP/src/dialogs/tsip_dialog_register.client.c @@ -47,7 +47,7 @@ #include "tsk_debug.h" #include "tsk_time.h" -#define DEBUG_STATE_MACHINE 1 +#define DEBUG_STATE_MACHINE 0 #define TSIP_DIALOG_REGISTER_TIMER_SCHEDULE(TX) TSIP_DIALOG_TIMER_SCHEDULE(register, TX) #define TSIP_DIALOG_REGISTER_SIGNAL(self, type, code, phrase, message) \ tsip_register_event_signal(type, TSIP_DIALOG(self)->ss, code, phrase, message) diff --git a/trunk/tinySIP/src/dialogs/tsip_dialog_subscribe.client.c b/trunk/tinySIP/src/dialogs/tsip_dialog_subscribe.client.c index 7f1b8e02..34a9c9ab 100644 --- a/trunk/tinySIP/src/dialogs/tsip_dialog_subscribe.client.c +++ b/trunk/tinySIP/src/dialogs/tsip_dialog_subscribe.client.c @@ -43,7 +43,7 @@ -#define DEBUG_STATE_MACHINE 1 +#define DEBUG_STATE_MACHINE 0 #define TSIP_DIALOG_SUBSCRIBE_TIMER_SCHEDULE(TX) TSIP_DIALOG_TIMER_SCHEDULE(subscribe, TX) #define TSIP_DIALOG_SUBSCRIBE_SIGNAL(self, type, code, phrase, message) \ tsip_subscribe_event_signal(type, TSIP_DIALOG(self)->ss, code, phrase, message) diff --git a/trunk/tinySIP/src/transactions/tsip_transac_nict.c b/trunk/tinySIP/src/transactions/tsip_transac_nict.c index 597e43fb..62694ac0 100644 --- a/trunk/tinySIP/src/transactions/tsip_transac_nict.c +++ b/trunk/tinySIP/src/transactions/tsip_transac_nict.c @@ -75,7 +75,7 @@ #include "tsk_debug.h" -#define DEBUG_STATE_MACHINE 1 +#define DEBUG_STATE_MACHINE 0 #define TRANSAC_NICT_TIMER_SCHEDULE(TX) TRANSAC_TIMER_SCHEDULE(nict, TX) diff --git a/trunk/tinySIP/src/transports/tsip_transport_layer.c b/trunk/tinySIP/src/transports/tsip_transport_layer.c index 24d3b252..5d02f3e6 100644 --- a/trunk/tinySIP/src/transports/tsip_transport_layer.c +++ b/trunk/tinySIP/src/transports/tsip_transport_layer.c @@ -39,6 +39,13 @@ #include "tsk_thread.h" #include "tsk_debug.h" +/* max size of a stream chunck to form a valid SIP message */ +#define TSIP_MAX_STREAM_CHUNCK_SIZE 0xFFFF +/* min size of a stream chunck to form a valid SIP message +* (Request/Response)-Line, Via, From, To, Call-Id, CSeq and Content-Length +* Tests have been done with both compact and full headers */ +#define TSIP_MIN_STREAM_CHUNCK_SIZE 0xA0 + tsip_transport_layer_t* tsip_transport_layer_create(tsip_stack_t *stack) { return tsk_object_new(tsip_transport_layer_def_t, stack); @@ -99,7 +106,8 @@ static int tsip_transport_layer_stream_cb(const tnet_transport_event_t* e) */ /* Check if buffer is too big to be valid (have we missed some chuncks?) */ - if(TSK_BUFFER_SIZE(transport->buff_stream) >= 0xFFFF){ + if(TSK_BUFFER_SIZE(transport->buff_stream) >= TSIP_MAX_STREAM_CHUNCK_SIZE){ + TSK_DEBUG_ERROR("TCP Buffer is too big to be valid"); tsk_buffer_cleanup(transport->buff_stream); } @@ -107,6 +115,7 @@ static int tsip_transport_layer_stream_cb(const tnet_transport_event_t* e) tsk_buffer_append(transport->buff_stream, e->data, e->size); /* Check if we have all SIP headers. */ +parse_buffer: if((endOfheaders = tsk_strindexOf(TSK_BUFFER_DATA(transport->buff_stream),TSK_BUFFER_SIZE(transport->buff_stream), "\r\n\r\n"/*2CRLF*/)) < 0){ TSK_DEBUG_INFO("No all SIP headers in the TCP buffer."); goto bail; @@ -142,8 +151,17 @@ static int tsip_transport_layer_stream_cb(const tnet_transport_event_t* e) message->sockfd = e->fd; /* Alert transaction/dialog layer */ ret = tsip_transport_layer_handle_incoming_msg(transport, message); + /* Parse next chunck */ + if(TSK_BUFFER_SIZE(transport->buff_stream) >= TSIP_MIN_STREAM_CHUNCK_SIZE){ + /* message already passed to the dialog/transac layers */ + TSK_OBJECT_SAFE_FREE(message); + goto parse_buffer; + } + } + else{ + TSK_DEBUG_ERROR("Failed to parse SIP message"); + ret = -15; } - else ret = -15; bail: TSK_OBJECT_SAFE_FREE(message);