Expand Up
@@ -410,6 +410,7 @@ static void testMalformedMessageWithWrongStart(void) {
BC_ASSERT_PTR_NULL (message );
}
void channel_parser_tester_recovery_from_error_base (const char * prelude ,const char * raw_message ) {
belle_sip_stack_t * stack = belle_sip_stack_new (NULL );
Expand Down
Expand Up
@@ -683,10 +684,75 @@ static void testMalformedFrom2(void){
belle_sip_object_unref (provider );
belle_sip_object_unref (stack );
belle_sip_object_unref (message );
}
static void testMalformedFrom3 (void ) {
belle_sip_stack_t * stack = belle_sip_stack_new (NULL );
belle_sip_listening_point_t * lp = belle_sip_stack_create_listening_point (stack ,
"127.0.0.1" ,
LISTENING_POINT_PORT ,
"tcp" );
belle_sip_provider_t * provider = belle_sip_provider_new (stack ,lp );
belle_sip_listener_callbacks_t listener_cbs = {0 };
const char * raw_message = "INVITE sip:us2@172.1.1.1 SIP/2.0\r\n"
"Via: SIP/2.0/TCP " LISTENING_POINT_HOSTPORT ";branch=z9hG4bK-edx-U_1zoIkaq72GJPqpSmDpJQ-ouBelFuLODzf9oS5J9MeFUA;rport\r\n"
"From: </coucou>\r\n"
"To: <sip:us2@172.1.1.1;transport=tcp>\r\n"
"Contact: <sip:00_12_34_56_78_90@172.2.2.2>\r\n"
"Call-ID: 2b6fb0320-1384-179494-426025-23b6b0-2e3303331@172.16.42.1\r\n"
"Content-Type: application/sdp\r\n"
"Content-Length: 389\r\n"
"CSeq: 1 INVITE\r\n"
"Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, INFO, UPDATE, REGISTER, MESSAGE, REFER, SUBSCRIBE, PRACK\r\n"
"Accept: application/sdp, application/dtmf-relay\r\n"
"Max-Forwards: 69\r\n"
"\r\n"
"v=0\r\n"
"o=- 1826 1826 IN IP4 172.16.42.1\r\n"
"s=Pouetpouet\r\n"
"c=IN IP4 172.16.42.1\r\n"
"t=0 0\r\n"
"m=audio 20506 RTP/AVP 0 8 13 101\r\n"
"a=rtpmap:0 PCMU/8000\r\n"
"a=rtpmap:8 PCMA/8000\r\n"
"a=rtpmap:13 CN/8000\r\n"
"a=rtpmap:101 telephone-event/8000\r\n"
"a=fmtp:101 0-15\r\n"
"m=video 24194 RTP/AVP 105 104\r\n"
"a=sendonly\r\n"
"a=rtpmap:105 H264/90000\r\n"
"a=fmtp:105 packetization-mode=0\r\n"
"a=rtpmap:104 H263-1998/90000\r\n"
"a=fmtp:104 CIF=1;J=1\r\n" ;
belle_sip_message_t * message = belle_sip_message_parse (raw_message );
belle_sip_listener_t * listener = NULL ;
int called_times = 0 ;
listener_cbs .process_response_event = testMalformedFrom_process_response_cb ;
listener = belle_sip_listener_create_from_callbacks (& listener_cbs , & called_times );
belle_sip_provider_add_sip_listener (provider , listener );
belle_sip_object_ref (message );
belle_sip_object_ref (message ); /* double ref: originally the message is created with 0 refcount, and dispatch_message will unref() it.*/
belle_sip_provider_dispatch_message (provider , message );
// we expect the stack to send a 400 error
belle_sip_stack_sleep (stack ,1000 );
BC_ASSERT_EQUAL (called_times ,1 ,int ,"%d" );
belle_sip_provider_remove_sip_listener (provider ,listener );
belle_sip_object_unref (listener );
belle_sip_object_unref (provider );
belle_sip_object_unref (stack );
belle_sip_object_unref (message );
}
static void testMalformedMandatoryField (void ){
belle_sip_stack_t * stack = belle_sip_stack_new (NULL );
belle_sip_listening_point_t * lp = belle_sip_stack_create_listening_point (stack ,
Expand Down
Expand Up
@@ -1120,6 +1186,7 @@ test_t message_tests[] = {
TEST_NO_TAG ("Malformed mandatory field" , testMalformedMandatoryField ),
TEST_NO_TAG ("Malformed invite with bad begin" , testMalformedMessageWithWrongStart ),
TEST_NO_TAG ("Malformed register" , testMalformedOptionnalHeaderInMessage ),
TEST_NO_TAG ("Malformed from 3" , testMalformedFrom3 ),
TEST_NO_TAG ("Channel parser error recovery" , channel_parser_tester_recovery_from_error ),
TEST_NO_TAG ("Channel parser malformed start" , channel_parser_malformed_start ),
TEST_NO_TAG ("Channel parser truncated start" , channel_parser_truncated_start ),
Expand Down