Commit 1c7e3e47 authored by jehan's avatar jehan

add header P-Preferred-Identity

parent bd1c3725
......@@ -106,8 +106,8 @@ BELLE_SIP_DECLARE_TYPES_BEGIN(belle_sip,1)
BELLE_SIP_TYPE_ID(belle_sip_header_refer_to_t),
BELLE_SIP_TYPE_ID(belle_sip_header_referred_by_t),
BELLE_SIP_TYPE_ID(belle_sip_header_replaces_t),
BELLE_SIP_TYPE_ID(belle_sip_header_date_t)
BELLE_SIP_TYPE_ID(belle_sip_header_date_t),
BELLE_SIP_TYPE_ID(belle_sip_header_p_preferred_identity_t)
BELLE_SIP_DECLARE_TYPES_END
......
......@@ -588,4 +588,19 @@ BELLESIP_EXPORT void belle_sip_header_date_set_date(belle_sip_header_date_t *obj
#define BELLE_SIP_HEADER_DATE(obj) BELLE_SIP_CAST(obj,belle_sip_header_date_t)
#define BELLE_SIP_DATE "Date"
/******************************
* To header object inherent from header_address
*
******************************/
typedef struct _belle_sip_header_p_preferred_identity belle_sip_header_p_preferred_identity_t;
BELLESIP_EXPORT belle_sip_header_p_preferred_identity_t* belle_sip_header_p_preferred_identity_new();
BELLESIP_EXPORT belle_sip_header_p_preferred_identity_t* belle_sip_header_p_preferred_identity_parse(const char* p_preferred_identity) ;
BELLESIP_EXPORT belle_sip_header_p_preferred_identity_t* belle_sip_header_p_preferred_identity_create(const belle_sip_header_address_t *address);
#define BELLE_SIP_HEADER_P_PREFERRED_IDENTITY(t) BELLE_SIP_CAST(t,belle_sip_header_p_preferred_identity_t)
#define BELLE_SIP_P_PREFERRED_IDENTITY "P-Preferred-Identity"
#endif /* HEADERS_H_ */
......@@ -1493,3 +1493,31 @@ BELLESIP_EXPORT void belle_sip_header_date_set_time(belle_sip_header_date_t *obj
GET_SET_STRING(belle_sip_header_date,date);
/************************
* header_p_prefered_identity
***********************/
struct _belle_sip_header_p_preferred_identity {
belle_sip_header_address_t address;
};
void belle_sip_header_p_preferred_identity_destroy(belle_sip_header_p_preferred_identity_t* p_preferred_identity) {
}
void belle_sip_header_p_preferred_identity_clone(belle_sip_header_p_preferred_identity_t *p_preferred_identity, const belle_sip_header_p_preferred_identity_t *orig){
}
int belle_sip_header_p_preferred_identity_marshal(belle_sip_header_p_preferred_identity_t* p_preferred_identity, char* buff,unsigned int offset,unsigned int buff_size) {
unsigned int current_offset=offset;
current_offset+=belle_sip_header_marshal(BELLE_SIP_HEADER(p_preferred_identity), buff,offset, buff_size);
current_offset+=belle_sip_header_address_marshal(&p_preferred_identity->address, buff,current_offset, buff_size);
return MIN(current_offset-offset,buff_size-offset);
}
BELLE_SIP_NEW_HEADER(header_p_preferred_identity,header_address,BELLE_SIP_P_PREFERRED_IDENTITY)
BELLE_SIP_PARSE(header_p_preferred_identity)
belle_sip_header_p_preferred_identity_t* belle_sip_header_p_preferred_identity_create (const belle_sip_header_address_t* p_preferred_identity) {
belle_sip_header_p_preferred_identity_t* header = belle_sip_header_p_preferred_identity_new();
_belle_sip_object_copy(BELLE_SIP_OBJECT(header),BELLE_SIP_OBJECT(p_preferred_identity));
belle_sip_header_set_name(BELLE_SIP_HEADER(header),BELLE_SIP_P_PREFERRED_IDENTITY); /*restaure header name*/
return header;
}
......@@ -186,6 +186,7 @@ BELLE_SIP_DECLARE_VPTR(belle_sip_header_replaces_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_date_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_hop_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_object_pool_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_p_preferred_identity_t);
typedef void (*belle_sip_source_remove_callback_t)(belle_sip_source_t *);
......@@ -729,6 +730,7 @@ belle_sip_hop_t* belle_sip_response_get_return_hop(belle_sip_response_t *msg);
strcasecmp(#token,(const char*)(INPUT->toStringTT(INPUT,LT(1),LT(strlen(#token)))->chars)) == 0:0)
char* _belle_sip_str_dup_and_unquote_string(const char* quoted_string);
#define IS_HEADER_NAMED(name,compressed_name) IS_TOKEN(name) || (compressed_name && IS_TOKEN(compressed_name))
/*********************************************************
* SDP
*/
......
......@@ -461,16 +461,18 @@ catch [ANTLR3_MISMATCHED_TOKEN_EXCEPTION]
$header_contact::current=$contact_param::prev;
}
header_address returns [belle_sip_header_address_t* ret]
scope { belle_sip_header_address_t* current; }
@init { $header_address::current = belle_sip_header_address_new(); $ret=$header_address::current; }
: name_addr[BELLE_SIP_HEADER_ADDRESS($header_address::current)]
| addr_spec[BELLE_SIP_HEADER_ADDRESS($header_address::current)];
header_address returns [belle_sip_header_address_t* ret]
: header_address_base[belle_sip_header_address_new()] {$ret=$header_address_base.ret;};
header_address_base[belle_sip_header_address_t* obj] returns [belle_sip_header_address_t* ret]
@init { $ret=obj; }
: name_addr[BELLE_SIP_HEADER_ADDRESS($ret)]
| addr_spec[BELLE_SIP_HEADER_ADDRESS($ret)];
catch [ANTLR3_MISMATCHED_TOKEN_EXCEPTION]
{
belle_sip_message("[\%s] reason [\%s]",(const char*)EXCEPTION->name,(const char*)EXCEPTION->message);
belle_sip_object_unref($header_address::current);
$ret=NULL;
belle_sip_message("[\%s] reason [\%s]",(const char*)EXCEPTION->name,(const char*)EXCEPTION->message);
belle_sip_object_unref($ret);
$ret=NULL;
}
name_addr[belle_sip_header_address_t* object]
: ( display_name[object] )? sp_laquot_sp addr_spec[object] sp_raquot_sp;
......@@ -1171,6 +1173,17 @@ catch [ANTLR3_MISMATCHED_TOKEN_EXCEPTION]
$ret=NULL;
}
//**********************************Privacy*******************************//
header_p_preferred_identity returns [belle_sip_header_p_preferred_identity_t* ret]
: {IS_HEADER_NAMED(P-Preferred-Identity,NULL)}? token /*"P-Preferred-Identity"*/
hcolon header_address_base[belle_sip_header_p_preferred_identity_new()] {$ret=$header_address_base.ret;};
//********************************************************************************************//
header_extension[ANTLR3_BOOLEAN check_for_known_header] returns [belle_sip_header_t* ret]
: header_name
hcolon
......@@ -1222,6 +1235,8 @@ header_extension[ANTLR3_BOOLEAN check_for_known_header] returns [belle_sip_head
$ret = BELLE_SIP_HEADER(belle_sip_header_replaces_parse((const char*)$header_extension.text->chars));
}else if (check_for_known_header && strcasecmp(BELLE_SIP_DATE,(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_date_parse((const char*)$header_extension.text->chars));
}else if (check_for_known_header && strcasecmp(BELLE_SIP_P_PREFERRED_IDENTITY,(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_p_preferred_identity_parse((const char*)$header_extension.text->chars));
}else {
$ret = BELLE_SIP_HEADER(belle_sip_header_extension_new());
belle_sip_header_extension_set_value((belle_sip_header_extension_t*)$ret,(const char*)$header_value.text->chars);
......
......@@ -88,6 +88,8 @@ int belle_sip_tls_listening_point_set_root_ca(belle_sip_tls_listening_point_t *l
if (path){
lp->root_ca=belle_sip_strdup(path);
belle_sip_message("Root ca path set to %s",lp->root_ca);
} else {
belle_sip_message("Root ca path disabled");
}
return 0;
}
......
......@@ -683,6 +683,21 @@ static void test_date_header(void){
}
static void test_p_preferred_identity_header(void) {
belle_sip_uri_t* L_uri;
belle_sip_header_p_preferred_identity_t* L_p_preferred_identity = belle_sip_header_p_preferred_identity_parse("P-Preferred-Identity: \"Cullen Jennings\" <sip:fluffy@cisco.com>");
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_p_preferred_identity));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_p_preferred_identity));
L_p_preferred_identity = belle_sip_header_p_preferred_identity_parse(l_raw_header);
belle_sip_free(l_raw_header);
L_uri = belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(L_p_preferred_identity));
CU_ASSERT_STRING_EQUAL(belle_sip_header_address_get_displayname(BELLE_SIP_HEADER_ADDRESS(L_p_preferred_identity)),"Cullen Jennings");
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_user(L_uri),"fluffy");
CU_ASSERT_STRING_EQUAL(belle_sip_uri_get_host(L_uri), "cisco.com");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_p_preferred_identity));
}
test_t headers_tests[] = {
{ "Address", test_address_header },
......@@ -702,6 +717,7 @@ test_t headers_tests[] = {
{ "From", test_from_header },
{ "From (Param-less address spec)", test_from_header_with_paramless_address_spec },
{ "Max-Forwards", test_max_forwards_header },
{ "P-Preferred-Identity", test_p_preferred_identity_header },
{ "Proxy-Authenticate", test_proxy_authenticate_header },
{ "Proxy-Authorization", test_proxy_authorization_header },
{ "Record-Route", test_record_route_header },
......
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