Commit 920b48b7 authored by Erwan Croze's avatar Erwan Croze 👋🏻

Merge branch 'fix/domain_name_number'

parents f1ae0683 c012afe7
Pipeline #261 failed with stage
in 0 seconds
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* This C source file was generated by $ANTLR version 3.4 * This C source file was generated by $ANTLR version 3.4
* *
* - From the grammar source file : ../grammars/belle_sdp.g * - From the grammar source file : ../grammars/belle_sdp.g
* - On : 2018-08-07 09:33:26 * - On : 2018-08-08 15:41:42
* - for the lexer : belle_sdpLexerLexer * - for the lexer : belle_sdpLexerLexer
* *
* Editing it, at least manually, is not wise. * Editing it, at least manually, is not wise.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* This C header file was generated by $ANTLR version 3.4 * This C header file was generated by $ANTLR version 3.4
* *
* - From the grammar source file : ../grammars/belle_sdp.g * - From the grammar source file : ../grammars/belle_sdp.g
* - On : 2018-08-07 09:33:26 * - On : 2018-08-08 15:41:42
* - for the lexer : belle_sdpLexerLexer * - for the lexer : belle_sdpLexerLexer
* *
* Editing it, at least manually, is not wise. * Editing it, at least manually, is not wise.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* This C source file was generated by $ANTLR version 3.4 * This C source file was generated by $ANTLR version 3.4
* *
* - From the grammar source file : ../grammars/belle_sdp.g * - From the grammar source file : ../grammars/belle_sdp.g
* - On : 2018-08-07 09:33:25 * - On : 2018-08-08 15:41:41
* - for the parser : belle_sdpParserParser * - for the parser : belle_sdpParserParser
* *
* Editing it, at least manually, is not wise. * Editing it, at least manually, is not wise.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* This C header file was generated by $ANTLR version 3.4 * This C header file was generated by $ANTLR version 3.4
* *
* - From the grammar source file : ../grammars/belle_sdp.g * - From the grammar source file : ../grammars/belle_sdp.g
* - On : 2018-08-07 09:33:25 * - On : 2018-08-08 15:41:41
* - for the parser : belle_sdpParserParser * - for the parser : belle_sdpParserParser
* *
* Editing it, at least manually, is not wise. * Editing it, at least manually, is not wise.
......
...@@ -1891,7 +1891,7 @@ scope { const char* current; } ...@@ -1891,7 +1891,7 @@ scope { const char* current; }
hostname : ( domainlabel DOT )* (toplabel)=>toplabel DOT? ; hostname : ( domainlabel DOT )* (toplabel)=>toplabel DOT? ;
domainlabel : alphanum | (alphanum ( alphanum | DASH )* alphanum) ; domainlabel : alphanum | (alphanum ( alphanum | DASH )* alphanum) ;
toplabel : alpha | (alpha ( DASH? alphanum)+) ; toplabel : alphanum ( DASH? alphanum)+;
ipv4address : three_digit DOT three_digit DOT three_digit DOT three_digit ; ipv4address : three_digit DOT three_digit DOT three_digit DOT three_digit ;
ipv6reference returns [const char* ret=NULL] : LSBRAQUET ipv6address RSBRAQUET {$ret=(const char *)$ipv6address.text->chars;}; ipv6reference returns [const char* ret=NULL] : LSBRAQUET ipv6address RSBRAQUET {$ret=(const char *)$ipv6address.text->chars;};
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* This C source file was generated by $ANTLR version 3.4 * This C source file was generated by $ANTLR version 3.4
* *
* - From the grammar source file : ../grammars/belle_sip_message.g * - From the grammar source file : ../grammars/belle_sip_message.g
* - On : 2018-08-07 09:33:40 * - On : 2018-08-08 15:41:56
* - for the lexer : belle_sip_messageLexerLexer * - for the lexer : belle_sip_messageLexerLexer
* *
* Editing it, at least manually, is not wise. * Editing it, at least manually, is not wise.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* This C header file was generated by $ANTLR version 3.4 * This C header file was generated by $ANTLR version 3.4
* *
* - From the grammar source file : ../grammars/belle_sip_message.g * - From the grammar source file : ../grammars/belle_sip_message.g
* - On : 2018-08-07 09:33:40 * - On : 2018-08-08 15:41:56
* - for the lexer : belle_sip_messageLexerLexer * - for the lexer : belle_sip_messageLexerLexer
* *
* Editing it, at least manually, is not wise. * Editing it, at least manually, is not wise.
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* This C header file was generated by $ANTLR version 3.4 * This C header file was generated by $ANTLR version 3.4
* *
* - From the grammar source file : ../grammars/belle_sip_message.g * - From the grammar source file : ../grammars/belle_sip_message.g
* - On : 2018-08-07 09:33:37 * - On : 2018-08-08 15:41:53
* - for the parser : belle_sip_messageParserParser * - for the parser : belle_sip_messageParserParser
* *
* Editing it, at least manually, is not wise. * Editing it, at least manually, is not wise.
......
...@@ -120,8 +120,39 @@ static void test_from_header(void) { ...@@ -120,8 +120,39 @@ static void test_from_header(void) {
BC_ASSERT_STRING_EQUAL(belle_sip_header_from_get_tag(L_from),"dlfjklcn6545614XX"); BC_ASSERT_STRING_EQUAL(belle_sip_header_from_get_tag(L_from),"dlfjklcn6545614XX");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_from)); belle_sip_object_unref(BELLE_SIP_OBJECT(L_from));
// Test Domain name RFC1123-2.1
L_from = belle_sip_header_from_parse("f:<sip:123jeff;transport=tcp>;tag=dlfjklcn6545614XX");
l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_from));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_from));
L_tmp = belle_sip_header_from_parse(l_raw_header);
L_from = BELLE_SIP_HEADER_FROM(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
/*test factory*/ L_uri = belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(L_from));
BC_ASSERT_PTR_NULL(belle_sip_uri_get_user(L_uri));
BC_ASSERT_STRING_EQUAL(belle_sip_uri_get_host(L_uri), "123jeff");
BC_ASSERT_STRING_EQUAL(belle_sip_header_from_get_tag(L_from),"dlfjklcn6545614XX");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_from));
L_from = belle_sip_header_from_parse("f:<sip:12345678987;transport=tcp>;tag=dlfjklcn6545614XX");
l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_from));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_from));
L_tmp = belle_sip_header_from_parse(l_raw_header);
L_from = BELLE_SIP_HEADER_FROM(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
L_uri = belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(L_from));
BC_ASSERT_PTR_NULL(belle_sip_uri_get_user(L_uri));
BC_ASSERT_STRING_EQUAL(belle_sip_uri_get_host(L_uri), "12345678987");
BC_ASSERT_STRING_EQUAL(belle_sip_header_from_get_tag(L_from),"dlfjklcn6545614XX");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_from));
// Test factory
L_from = belle_sip_header_from_create2("super <sip:titi.com:5060;lr;ttl=1;method=INVITE;maddr=192.168.0.1;transport=tcp?header=123>","12345-abc"); L_from = belle_sip_header_from_create2("super <sip:titi.com:5060;lr;ttl=1;method=INVITE;maddr=192.168.0.1;transport=tcp?header=123>","12345-abc");
if (!BC_ASSERT_PTR_NOT_NULL(L_from)) return; if (!BC_ASSERT_PTR_NOT_NULL(L_from)) return;
L_uri = belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(L_from)); L_uri = belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(L_from));
......
...@@ -620,6 +620,71 @@ static void testMalformedFrom(void){ ...@@ -620,6 +620,71 @@ static void testMalformedFrom(void){
} }
static void testMalformedFrom2(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: RottenFrom <sip:@somehost>;tag=klsk+kwDc\r\n" /** The userpart is empty before '@', this is not allowed */
"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){ static void testMalformedMandatoryField(void){
belle_sip_stack_t* stack = belle_sip_stack_new(NULL); belle_sip_stack_t* stack = belle_sip_stack_new(NULL);
...@@ -1050,6 +1115,7 @@ test_t message_tests[] = { ...@@ -1050,6 +1115,7 @@ test_t message_tests[] = {
TEST_NO_TAG("SIP frag", test_sipfrag), TEST_NO_TAG("SIP frag", test_sipfrag),
TEST_NO_TAG("Malformed invite", testMalformedMessage), TEST_NO_TAG("Malformed invite", testMalformedMessage),
TEST_NO_TAG("Malformed from", testMalformedFrom), TEST_NO_TAG("Malformed from", testMalformedFrom),
TEST_NO_TAG("Malformed from 2", testMalformedFrom2),
TEST_NO_TAG("Malformed mandatory field", testMalformedMandatoryField), TEST_NO_TAG("Malformed mandatory field", testMalformedMandatoryField),
TEST_NO_TAG("Malformed invite with bad begin", testMalformedMessageWithWrongStart), TEST_NO_TAG("Malformed invite with bad begin", testMalformedMessageWithWrongStart),
TEST_NO_TAG("Malformed register", testMalformedOptionnalHeaderInMessage), TEST_NO_TAG("Malformed register", testMalformedOptionnalHeaderInMessage),
......
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