Commit c0be4ce3 authored by jehan's avatar jehan

add route and record route headers

parent 9afc476d
......@@ -60,6 +60,8 @@ typedef enum belle_sip_type_id{
BELLE_SIP_TYPE_ID(belle_sip_header_cseq_t),
BELLE_SIP_TYPE_ID(belle_sip_header_content_type_t),
BELLE_SIP_TYPE_ID(belle_sip_sender_task_t),
BELLE_SIP_TYPE_ID(belle_sip_header_route_t),
BELLE_SIP_TYPE_ID(belle_sip_header_record_route_t),
belle_sip_type_id_end
}belle_sip_type_id_t;
......
......@@ -210,4 +210,25 @@ void belle_sip_header_content_type_set_type(belle_sip_header_content_type_t* con
const char* belle_sip_header_content_type_get_subtype(belle_sip_header_content_type_t* content_type);
void belle_sip_header_content_type_set_subtype(belle_sip_header_content_type_t* content_type,const char* sub_type);
#define BELLE_SIP_HEADER_CONTENT_TYPE(t) BELLE_SIP_CAST(t,belle_sip_header_content_type_t)
/******************************
* Route header object inherent from header_address
*
******************************/
typedef struct _belle_sip_header_route belle_sip_header_route_t;
belle_sip_header_route_t* belle_sip_header_route_new();
belle_sip_header_route_t* belle_sip_header_route_parse (const char* route) ;
#define BELLE_SIP_HEADER_ROUTE(t) BELLE_SIP_CAST(t,belle_sip_header_route_t)
/******************************
* Record route header object inherent from header_address
*
******************************/
typedef struct _belle_sip_header_record_route belle_sip_header_record_route_t;
belle_sip_header_record_route_t* belle_sip_header_record_route_new();
belle_sip_header_record_route_t* belle_sip_header_record_route_parse (const char* route) ;
#define BELLE_SIP_HEADER_RECORD_ROUTE(t) BELLE_SIP_CAST(t,belle_sip_header_record_route_t)
#endif /* HEADERS_H_ */
......@@ -252,3 +252,32 @@ BELLE_SIP_NEW(header_content_type,parameters)
BELLE_SIP_PARSE(header_content_type)
GET_SET_STRING(belle_sip_header_content_type,type);
GET_SET_STRING(belle_sip_header_content_type,subtype);
/**************************
* Route header object inherent from header_address
****************************
*/
struct _belle_sip_header_route {
belle_sip_header_address_t address;
};
static void belle_sip_header_route_destroy(belle_sip_header_route_t* route) {
belle_sip_header_address_destroy(BELLE_SIP_HEADER_ADDRESS(route));
}
BELLE_SIP_NEW(header_route,header_address)
BELLE_SIP_PARSE(header_route)
/**************************
* Record route header object inherent from header_address
****************************
*/
struct _belle_sip_header_record_route {
belle_sip_header_address_t address;
};
static void belle_sip_header_record_route_destroy(belle_sip_header_record_route_t* record_route) {
belle_sip_header_address_destroy(BELLE_SIP_HEADER_ADDRESS(record_route));
}
BELLE_SIP_NEW(header_record_route,header_address)
BELLE_SIP_PARSE(header_record_route)
......@@ -517,14 +517,19 @@ proxy_require
(COMMA option_tag)*;
option_tag
: token;
*/
record_route_token: {strcmp("Record-Route",(const char*)(INPUT->toStringTT(INPUT,LT(1),LT(12)))->chars) == 0}? token;
header_record_route returns [belle_sip_header_record_route_t* ret]
scope { belle_sip_header_record_route_t* current; }
@init { $header_record_route::current = belle_sip_header_record_route_new();$ret = $header_record_route::current; }
record_route
: 'Record-Route' HCOLON rec_route (COMMA rec_route)*;
: record_route_token /*'Record-Route'*/ hcolon rec_route /*(COMMA rec_route)**/;
rec_route
: name_addr ( SEMI rr_param );
: name_addr[BELLE_SIP_HEADER_ADDRESS($header_record_route::current)] ( SEMI rr_param )*;
rr_param
: generic_param;
: generic_param[BELLE_SIP_PARAMETERS($header_record_route::current)];
/*
reply_to
: 'Reply-To' HCOLON rplyto_spec;
rplyto_spec
......@@ -545,12 +550,17 @@ comment : '(' . ')';
retry_param
: ('duration' EQUAL delta_seconds)
| generic_param;
route
: 'Route' HCOLON route_param (COMMA route_param)*;
route_param
: name_addr ( SEMI rr_param )*;
*/
route_token: {strcmp("Route",(const char*)(INPUT->toStringTT(INPUT,LT(1),LT(5)))->chars) == 0}? token;
header_route returns [belle_sip_header_route_t* ret]
scope { belle_sip_header_route_t* current; }
@init { $header_route::current = belle_sip_header_route_new();$ret = $header_route::current; }
: route_token /*'Route'*/ hcolon route_param /*(COMMA rec_route)**/;
route_param
: name_addr[BELLE_SIP_HEADER_ADDRESS($header_route::current)] ( SEMI r_param )*;
r_param
: generic_param[BELLE_SIP_PARAMETERS($header_route::current)];
/*
server
: 'Server' HCOLON server_val (LWS server_val)*;
server_val
......@@ -781,7 +791,7 @@ sws : lws? ;
COLON
: ':'
;
semi: sws SEMI sws;
SEMI
: ';'
;
......
......@@ -119,6 +119,24 @@ void test_header_content_type(void) {
CU_ASSERT_STRING_EQUAL(belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(L_content_type),"charset"),"ISO-8859-4");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_content_type));
}
void test_header_record_route(void) {
belle_sip_header_record_route_t* L_record_route = belle_sip_header_record_route_parse("Record-Route: <sip:212.27.52.5:5060;transport=udp;lr>;charset=ISO-8859-4");
belle_sip_uri_t* L_uri = belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(L_record_route));
CU_ASSERT_PTR_NULL(belle_sip_uri_get_user(L_uri));
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_host(L_uri), "212.27.52.5");
CU_ASSERT_STRING_EQUAL(belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(L_record_route),"charset"),"ISO-8859-4");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_record_route));
}
void test_header_route(void) {
belle_sip_header_route_t* L_route = belle_sip_header_route_parse("Route: <sip:212.27.52.5:5060;transport=udp;lr>;charset=ISO-8859-4");
belle_sip_uri_t* L_uri = belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(L_route));
CU_ASSERT_PTR_NULL(belle_sip_uri_get_user(L_uri));
CU_ASSERT_EQUAL(belle_sip_uri_get_port(L_uri), 5060);
CU_ASSERT_STRING_EQUAL(belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(L_route),"charset"),"ISO-8859-4");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_route));
}
int belle_sip_headers_test_suite() {
......@@ -152,5 +170,11 @@ int belle_sip_headers_test_suite() {
if (NULL == CU_add_test(pSuite, "test of content type header", test_header_content_type)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "test of record route header", test_header_record_route)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "test of route header", test_header_route)) {
return CU_get_error();
}
return 0;
}
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