Commit 3200c2e8 authored by jehan's avatar jehan
Browse files

Add headers cseq,content_type and callid

parent 356cc400
......@@ -36,6 +36,9 @@ typedef enum belle_sip_type_id{
BELLE_SIP_TYPE_ID(belle_sip_uri_t),
BELLE_SIP_TYPE_ID(belle_sip_object_t),
BELLE_SIP_TYPE_ID(belle_sip_parameters_t),
BELLE_SIP_TYPE_ID(belle_sip_header_callid_t),
BELLE_SIP_TYPE_ID(belle_sip_header_cseq_t),
BELLE_SIP_TYPE_ID(belle_sip_header_content_type_t),
belle_sip_type_id_end
}belle_sip_type_id_t;
......
......@@ -149,41 +149,65 @@ belle_sip_header_via_t* belle_sip_header_via_new();
belle_sip_header_via_t* belle_sip_header_via_parse (const char* via) ;
const char* belle_sip_header_via_get_branch(belle_sip_header_via_t* via);
const char* belle_sip_header_via_get_transport(belle_sip_header_via_t* via);
const char* belle_sip_header_via_get_host(belle_sip_header_via_t* via);
/*
String getMAddr()
Returns the value of the maddr parameter, or null if this is not set.
int getPort()
Returns the port part of this ViaHeader.
String getProtocol()
Returns the value of the protocol used.
String getReceived()
Gets the received paramater of the ViaHeader.
int getRPort()
Returns the rport part of this ViaHeader.
String getTransport()
Returns the value of the transport parameter.
int getTTL()
Returns the value of the ttl parameter, or -1 if this is not set.
void setBranch(String branch)
Sets the branch parameter of the ViaHeader to the newly supplied branch value.
void setHost(String host)
Set the host part of this ViaHeader to the newly supplied host parameter.
void setMAddr(String mAddr)
Sets the value of the maddr parameter of this ViaHeader.
void setPort(int port)
Set the port part of this ViaHeader to the newly supplied port parameter.
void setProtocol(String protocol)
Sets the value of the protocol parameter.
void setReceived(String received)
Sets the received parameter of ViaHeader.
void setRPort()
Set the rport part of this ViaHeader.
void setTransport(String transport)
Sets the value of the transport.
void setTTL(int ttl)
*/
int belle_sip_header_via_get_port(belle_sip_header_via_t* via);
const char* belle_sip_header_via_get_maddr(belle_sip_header_via_t* via);
const char* belle_sip_header_via_get_protocol(belle_sip_header_via_t* via);
const char* belle_sip_header_via_get_received(belle_sip_header_via_t* via);
int belle_sip_header_via_get_rport(belle_sip_header_via_t* via);
int belle_sip_header_via_get_ttl(belle_sip_header_via_t* via);
void belle_sip_header_via_set_branch(belle_sip_header_via_t* via,const char* branch);
void belle_sip_header_via_set_host(belle_sip_header_via_t* via, const char* host);
int belle_sip_header_via_set_port(belle_sip_header_via_t* via,int port);
void belle_sip_header_via_set_maddr(belle_sip_header_via_t* via, const char* maddr);
void belle_sip_header_via_set_protocol(belle_sip_header_via_t* via, const char* protocol);
void belle_sip_header_via_set_received(belle_sip_header_via_t* via, const char* received);
int belle_sip_header_via_set_rport(belle_sip_header_via_t* via,int rport);
void belle_sip_header_via_set_transport(belle_sip_header_via_t* via,const char* transport);
int belle_sip_header_via_set_ttl(belle_sip_header_via_t* via, int ttl);
#define BELLE_SIP_HEADER_VIA(t) BELLE_SIP_CAST(t,belle_sip_header_via_t)
/******************************
* Call id object inherent from object
*
******************************/
typedef struct _belle_sip_header_callid belle_sip_header_callid_t;
belle_sip_header_callid_t* belle_sip_header_callid_new();
belle_sip_header_callid_t* belle_sip_header_callid_parse (const char* callid) ;
const char* belle_sip_header_callid_get_callid(belle_sip_header_callid_t* callid);
void belle_sip_header_callid_set_callid(belle_sip_header_callid_t* via,const char* callid);
#define BELLE_SIP_HEADER_CALLID(t) BELLE_SIP_CAST(t,belle_sip_header_callid_t)
/******************************
* cseq object inherent from object
*
******************************/
typedef struct _belle_sip_header_cseq belle_sip_header_cseq_t;
belle_sip_header_cseq_t* belle_sip_header_cseq_new();
belle_sip_header_cseq_t* belle_sip_header_cseq_parse (const char* cseq) ;
const char* belle_sip_header_cseq_get_method(belle_sip_header_cseq_t* cseq);
void belle_sip_header_cseq_set_method(belle_sip_header_cseq_t* cseq,const char* method);
unsigned int belle_sip_header_cseq_get_seq_number(belle_sip_header_cseq_t* cseq);
void belle_sip_header_cseq_set_seq_number(belle_sip_header_cseq_t* cseq,unsigned int seq_number);
#define BELLE_SIP_HEADER_CSEQ(t) BELLE_SIP_CAST(t,belle_sip_header_cseq_t)
/******************************
* content type object inherent from parameters
*
******************************/
typedef struct _belle_sip_header_content_type belle_sip_header_content_type_t;
belle_sip_header_content_type_t* belle_sip_header_content_type_new();
belle_sip_header_content_type_t* belle_sip_header_content_type_parse (const char* content_type) ;
const char* belle_sip_header_content_type_get_type(belle_sip_header_content_type_t* content_type);
void belle_sip_header_content_type_set_type(belle_sip_header_content_type_t* content_type,const char* type);
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)
#endif /* HEADERS_H_ */
......@@ -87,6 +87,7 @@ GET_SET_BOOL(belle_sip_header_contact,wildcard,is);
int belle_sip_header_contact_set_expires(belle_sip_header_contact_t* contact, int expires) {
if (expires < 0 ) {
belle_sip_error("bad expires value [%i] for contact",expires);
return -1;
}
_belle_sip_header_contact_set_expires(contact,expires);
......@@ -94,6 +95,7 @@ int belle_sip_header_contact_set_expires(belle_sip_header_contact_t* contact, in
}
int belle_sip_header_contact_set_qvalue(belle_sip_header_contact_t* contact, float qValue) {
if (qValue != -1 && qValue < 0 && qValue >1) {
belle_sip_error("bad q value [%f] for contact",qValue);
return -1;
}
_belle_sip_header_contact_set_q(contact,qValue);
......@@ -133,21 +135,120 @@ static void belle_sip_header_to_destroy(belle_sip_header_to_t* to) {
BELLE_SIP_NEW(header_to,header_address)
BELLE_SIP_PARSE(header_to)
GET_SET_STRING_PARAM(belle_sip_header_to,tag);
/**************************
* Viq header object inherent from header_address
* Viq header object inherent from parameters
****************************
*/
struct _belle_sip_header_via {
belle_sip_header_address_t address;
belle_sip_parameters_t params_list;
const char* protocol;
const char* transport;
const char* host;
int port;
};
static void belle_sip_header_via_destroy(belle_sip_header_via_t* to) {
belle_sip_header_address_destroy(BELLE_SIP_HEADER_ADDRESS(to));
static void belle_sip_header_via_destroy(belle_sip_header_via_t* via) {
belle_sip_parameters_destroy(BELLE_SIP_PARAMETERS(via));
if (via->host) belle_sip_free((void*)via->host);
if (via->protocol) belle_sip_free((void*)via->protocol);
}
BELLE_SIP_NEW(header_via,header_address)
BELLE_SIP_PARSE(header_via)
GET_SET_STRING(belle_sip_header_via,protocol);
GET_SET_STRING(belle_sip_header_via,transport);
GET_SET_STRING(belle_sip_header_via,host);
GET_SET_INT_PRIVATE(belle_sip_header_via,port,int,_);
GET_SET_STRING_PARAM(belle_sip_header_via,branch);
GET_SET_STRING_PARAM(belle_sip_header_via,maddr);
GET_SET_STRING_PARAM(belle_sip_header_via,received);
GET_SET_INT_PARAM_PRIVATE(belle_sip_header_via,rport,int,_)
GET_SET_INT_PARAM_PRIVATE(belle_sip_header_via,ttl,int,_)
int belle_sip_header_via_set_rport (belle_sip_header_via_t* obj,int value) {
if (value ==-1 || (value>0 && value<65536)) {
_belle_sip_header_via_set_rport(obj,value);
return 0;
} else {
belle_sip_error("bad rport value [%i] for via",value);
return -1;
}
}
int belle_sip_header_via_set_ttl (belle_sip_header_via_t* obj,int value) {
if (value ==-1 || (value>0 && value<=255)) {
_belle_sip_header_via_set_ttl(obj,value);
return 0;
} else {
belle_sip_error("bad ttl value [%i] for via",value);
return -1;
}
}
int belle_sip_header_via_set_port (belle_sip_header_via_t* obj,int value) {
if (value ==-1 || (value>0 && value<65536)) {
_belle_sip_header_via_set_port(obj,value);
return 0;
} else {
belle_sip_error("bad port value [%i] for via",value);
return -1;
}
}
/**************************
* callid header object inherent from object
****************************
*/
struct _belle_sip_header_callid {
belle_sip_object_t base;
const char* callid;
};
static void belle_sip_header_callid_destroy(belle_sip_header_callid_t* callid) {
belle_sip_object_destroy(BELLE_SIP_OBJECT(callid));
if (callid->callid) belle_sip_free((void*)callid->callid);
}
BELLE_SIP_NEW(header_callid,object)
BELLE_SIP_PARSE(header_callid)
GET_SET_STRING(belle_sip_header_callid,callid);
/**************************
* cseq header object inherent from object
****************************
*/
struct _belle_sip_header_cseq {
belle_sip_object_t base;
const char* method;
unsigned int seq_number;
};
static void belle_sip_header_cseq_destroy(belle_sip_header_cseq_t* cseq) {
belle_sip_object_destroy(BELLE_SIP_OBJECT(cseq));
if (cseq->method) belle_sip_free((void*)cseq->method);
}
BELLE_SIP_NEW(header_cseq,object)
BELLE_SIP_PARSE(header_cseq)
GET_SET_STRING(belle_sip_header_cseq,method);
GET_SET_INT(belle_sip_header_cseq,seq_number,unsigned int)
/**************************
* content type header object inherent from parameters
****************************
*/
struct _belle_sip_header_content_type {
belle_sip_parameters_t params_list;
const char* type;
const char* subtype;
};
static void belle_sip_header_content_type_destroy(belle_sip_header_content_type_t* content_type) {
belle_sip_parameters_destroy(BELLE_SIP_PARAMETERS(content_type));
if (content_type->type) belle_sip_free((void*)content_type->type);
if (content_type->subtype) belle_sip_free((void*)content_type->subtype);
}
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);
......@@ -260,6 +260,10 @@ uint64_t belle_sip_time_ms(void);
}\
void set_prefix##object_type##_set_##func_name (object_type##_t* obj,type value) {\
char l_str_value[16];\
if (value == -1) { \
belle_sip_parameters_remove_parameter(BELLE_SIP_PARAMETERS(obj),#attribute);\
return;\
}\
snprintf(l_str_value,16,FORMAT_(type),value);\
belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(obj),#attribute,(const char*)l_str_value);\
}
......@@ -338,6 +342,7 @@ struct _belle_sip_parameters {
};
void belle_sip_parameters_init(belle_sip_parameters_t *obj);
void belle_sip_parameters_destroy(belle_sip_parameters_t* params);
#ifdef __cplusplus
}
......
/*
belle-sip - SIP (RFC3261) library.
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
......@@ -99,12 +99,12 @@ cancelm : 'CANCEL' ; //CANCEL in caps
registerm
: 'REGISTER' ; //REGISTER in caps
optionm : 'OPTION';
method : invitem | ackm | optionm | byem | cancelm | registerm |extension_method ;
*/
method : /* invitem | ackm | optionm | byem | cancelm | registerm |*/extension_method ;
extension_method
: token;
/*
response
: status_line message-header* CRLF message_body ;
......@@ -148,14 +148,16 @@ qvalue
| ( '1'( '.'DIGIT+)? );
*/
generic_param [belle_sip_parameters_t* object] returns [belle_sip_param_pair_t* ret]
: SP* token ( SP* EQUAL SP* is_gen=gen_value )? {
scope{int is_value;}
@init { $generic_param::is_value=0; }
: SP* token ( SP* EQUAL SP* gen_value {$generic_param::is_value = 1;} )? {
if (object == NULL) {
$ret=belle_sip_param_pair_new((const char*)($token.text->chars)
,$is_gen.text?(const char*)($gen_value.text->chars):NULL);
,$generic_param::is_value?(const char*)($gen_value.text->chars):NULL);
} else {
belle_sip_parameters_set_parameter(object
,(const char*)($token.text->chars)
,$is_gen.text?(const char*)($gen_value.text->chars):NULL);
,$generic_param::is_value?(const char*)($gen_value.text->chars):NULL);
$ret=NULL;
}
};
......@@ -265,11 +267,17 @@ response_auth
: 'rspauth' EQUAL response_digest;
response_digest
: LDQUOT hexdigit* RDQUOT;
*/
/*callid header*/
callid_token: {strcmp("Call-ID",(const char*)(INPUT->toStringTT(INPUT,LT(1),LT(7)))->chars) == 0}? token;
call_id : ( 'Call-ID' | 'i' ) HCOLON callid;
header_callid returns [belle_sip_header_callid_t* ret]
scope { belle_sip_header_callid_t* current; }
@init {$header_callid::current = belle_sip_header_callid_new(); $ret=$header_callid::current; }
: callid_token /*( 'Call-ID' | 'i' )*/ hcolon callid;
callid
: word ( '@' word )?;
: word ( '@' word )? {belle_sip_header_callid_set_callid($header_callid::current,(const char*) $text->chars); };
/*
call_info
: 'Call-Info' HCOLON info (COMMA info)*;
info
......@@ -284,7 +292,7 @@ contact_token: {strcmp("Contact",(const char*)(INPUT->toStringTT(INPUT,LT(1),LT(
header_contact returns [belle_sip_header_contact_t* ret]
scope { belle_sip_header_contact_t* current; }
@init { $header_contact::current = belle_sip_header_contact_new(); }
: (contact_token /*'Contact'*/ /*| 'm'*/ ) hcolom
: (contact_token /*'Contact'*/ /*| 'm'*/ ) hcolon
( STAR { belle_sip_header_contact_set_wildcard($header_contact::current,1);}
| (contact_param (COMMA contact_param)*)) {$ret = $header_contact::current;};
contact_param
......@@ -351,12 +359,19 @@ huit_alpha
content_length
: ( 'Content-Length' | 'l' ) HCOLON DIGIT+;
content_type
: ( 'Content-Type' | 'c' ) HCOLON media_type;
*/
content_type_token : {strcmp("Content-Type",(const char*)(INPUT->toStringTT(INPUT,LT(1),LT(12)))->chars) == 0}? token;
header_content_type returns [belle_sip_header_content_type_t* ret]
scope { belle_sip_header_content_type_t* current;}
@init { $header_content_type::current = belle_sip_header_content_type_new();$ret=$header_content_type::current; }
: content_type_token/* ( 'Content-Type' | 'c' )*/ hcolon media_type;
media_type
: m_type SLASH m_subtype (SEMI m_parameter);
: m_type {belle_sip_header_content_type_set_type($header_content_type::current,$m_type.text->chars);}
slash
m_subtype {belle_sip_header_content_type_set_subtype($header_content_type::current,$m_subtype.text->chars);}
(SEMI generic_param [BELLE_SIP_PARAMETERS($header_content_type::current)]);
m_type
: discrete_type | composite_type;
: token; /* discrete_type | composite_type;
discrete_type
: 'text' | 'image' | 'audio' | 'video'
| 'application' | extension_token;
......@@ -367,8 +382,8 @@ extension_token
ietf_token
: token;
x_token
: 'x-' token;
m_subtype : extension_token | iana_token;
: 'x-' token;*/
m_subtype : token ;/* extension_token | iana_token;
iana_token
: token;
m_parameter
......@@ -377,9 +392,19 @@ m_attribute
: token;
m_value
: token | quoted_string;
*/
cseq : 'CSeq' HCOLON DIGIT+ LWS method;
cseq_token : {strcmp("CSeq",(const char*)(INPUT->toStringTT(INPUT,LT(1),LT(4)))->chars) == 0}? token;
header_cseq returns [belle_sip_header_cseq_t* ret]
scope { belle_sip_header_cseq_t* current; }
@init { $header_cseq::current = belle_sip_header_cseq_new();$ret = $header_cseq::current; }
: cseq_token
hcolon
seq_number {belle_sip_header_cseq_set_seq_number($header_cseq::current,atoi((const char*)$seq_number.text->chars));}
lws
method {belle_sip_header_cseq_set_method($header_cseq::current,(const char*)$method.text->chars);} ;
seq_number:DIGIT+;
/*
date
: 'Date' HCOLON sip_date;
sip_date
......@@ -407,9 +432,9 @@ expires
from_token: {strcmp("From",(const char*)(INPUT->toStringTT(INPUT,LT(1),LT(4)))->chars) == 0}? token;
header_from returns [belle_sip_header_from_t* ret]
scope { belle_sip_header_from_t* current; }
@init { $header_from::current = belle_sip_header_from_new(); }
@init { $header_from::current = belle_sip_header_from_new();$ret = $header_from::current; }
: from_token/* ( 'From' | 'f' )*/ hcolom from_spec {$ret = $header_from::current;};
: from_token/* ( 'From' | 'f' )*/ hcolon from_spec ;
from_spec
: ( name_addr[BELLE_SIP_HEADER_ADDRESS($header_from::current)] | addr_spec[BELLE_SIP_HEADER_ADDRESS($header_from::current)] )
( SEMI from_param )*;
......@@ -557,7 +582,7 @@ header_to returns [belle_sip_header_to_t* ret]
scope { belle_sip_header_to_t* current; }
@init { $header_to::current = belle_sip_header_to_new(); }
: to_token/* ( 'To' | 't' )*/ hcolom to_spec {$ret = $header_to::current;};
: to_token/* ( 'To' | 't' )*/ hcolon to_spec {$ret = $header_to::current;};
to_spec
: ( name_addr[BELLE_SIP_HEADER_ADDRESS($header_to::current)] | addr_spec[BELLE_SIP_HEADER_ADDRESS($header_to::current)] )
( SEMI to_param )*;
......@@ -574,10 +599,10 @@ header_via returns [belle_sip_header_via_t* ret]
scope { belle_sip_header_via_t* current; }
@init { $header_via::current = belle_sip_header_via_new(); }
: to_token/* ( 'via' | 'v' )*/ hcolom via_parm (COMMA via_parm)* {$ret = $header_via::current;};
: via_token/* ( 'via' | 'v' )*/ hcolon via_parm (COMMA via_parm)* {$ret = $header_via::current;};
via_parm
: sent_protocol LWS sent_by ( SEMI via_params )*;
: sent_protocol SP* sent_by ( SEMI via_params )*;
via_params
: /*via_ttl | via_maddr
| via_received | via_branch
......@@ -593,8 +618,8 @@ via_branch
via_extension
: generic_param;*/
sent_protocol
: protocol_name SLASH protocol_version
SLASH transport;
: (protocol_name SLASH protocol_version) {belle_sip_header_via_set_protocol($header_via::current,(const char*)$text->chars);}
SLASH transport {belle_sip_header_via_set_transport($header_via::current,(const char*)$transport.text->chars);} ;
protocol_name
: /*'SIP' |*/ token;
protocol_version
......@@ -606,7 +631,8 @@ other_transport
: token;
sent_by
: host ( COLON port )?;
: host {belle_sip_header_via_set_host($header_via::current,(const char*)$host.text->chars);}
( COLON port {belle_sip_header_via_set_port($header_via::current,$port.ret);} )? ;
/*
warning
: 'Warning' HCOLON warning_value (COMMA warning_value)*;
......@@ -644,7 +670,7 @@ userinfo : user ( COLON password )? '@' ;
user : ( unreserved | escaped | user_unreserved )+ {belle_sip_uri_set_user($uri::current,(const char *)$text->chars);};
user_unreserved : '&' | EQUAL | '+' | '$' | COMMA | SEMI | '?' | SLASH;
password : ( unreserved |'&' | EQUAL | '+' | '$' | COMMA )*;
hostport : host ( COLON port )? {belle_sip_uri_set_host($uri::current,(const char *)$host.text->chars);};
hostport : host ( COLON port {belle_sip_uri_set_port($uri::current,$port.ret);})? {belle_sip_uri_set_host($uri::current,(const char *)$host.text->chars);};
host : (hostname | ipv4address | ipv6reference) ;
hostname : ( domainlabel '.' )* toplabel '.'? ;
......@@ -658,7 +684,7 @@ hexpart : hexseq | hexseq '::' ( hexseq )? | '::' ( hexseq )?;
hexseq : hex4 ( COLON hex4)*;
hex4 : hexdigit hexdigit hexdigit hexdigit ;
port : DIGIT+ {belle_sip_uri_set_port($uri::current,atoi((const char *)$text->chars));};
port returns [int ret]: DIGIT+ { $ret=atoi((const char *)$text->chars); };
uri_parameters
......@@ -729,7 +755,7 @@ CRLF : '\r\n';
hcolom : ( SP | HTAB )* COLON SP* ; //SWS;
hcolon : ( SP | HTAB )* COLON sws ; //SWS;
HTAB : ' ';
......@@ -744,8 +770,8 @@ HTAB : ' ';
DQUOTE : '"';
// open double quotation mark
LWS : (SP* CRLF) SP* ; //linear whitespace
SWS : LWS? ;
lws : (SP* CRLF)? SP+ ; //linear whitespace
sws : lws? ;
......@@ -788,6 +814,7 @@ EQUAL
: '='
;
slash : sws SLASH sws;
SLASH
: '/'
;
......
......@@ -85,6 +85,40 @@ void test_simple_header_to(void) {
CU_ASSERT_STRING_EQUAL(belle_sip_header_to_get_tag(L_to),"dlfjklcn6545614XX");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_to));
}
void test_header_via(void) {
belle_sip_header_via_t* L_via = belle_sip_header_via_parse("Via: SIP/2.0/UDP 192.168.0.19:5062;rport;received=192.169.0.4;branch=z9hG4bK368560724");
CU_ASSERT_STRING_EQUAL(belle_sip_header_via_get_protocol(L_via), "SIP/2.0");
CU_ASSERT_STRING_EQUAL(belle_sip_header_via_get_transport(L_via), "UDP");
CU_ASSERT_STRING_EQUAL(belle_sip_header_via_get_host(L_via), "192.168.0.19");
CU_ASSERT_EQUAL(belle_sip_header_via_get_port(L_via),5062);
CU_ASSERT_TRUE(belle_sip_parameters_is_parameter(BELLE_SIP_PARAMETERS(L_via),"rport"));
CU_ASSERT_STRING_EQUAL(belle_sip_header_via_get_received(L_via),"192.169.0.4");
CU_ASSERT_STRING_EQUAL(belle_sip_header_via_get_branch(L_via),"z9hG4bK368560724");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_via));
}
void test_header_callid(void) {
belle_sip_header_callid_t* L_callid = belle_sip_header_callid_parse("Call-ID: 1665237789@titi.com");
CU_ASSERT_STRING_EQUAL(belle_sip_header_callid_get_callid(L_callid), "1665237789@titi.com");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_callid));
}
void test_header_cseq(void) {
belle_sip_header_cseq_t* L_cseq = belle_sip_header_cseq_parse("CSeq: 21 INVITE");
CU_ASSERT_EQUAL(belle_sip_header_cseq_get_seq_number(L_cseq),21);
CU_ASSERT_STRING_EQUAL(belle_sip_header_cseq_get_method(L_cseq),"INVITE");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_cseq));
}
void test_header_content_type(void) {
belle_sip_header_content_type_t* L_content_type = belle_sip_header_content_type_parse("Content-Type: text/html; charset=ISO-8859-4");
CU_ASSERT_STRING_EQUAL(belle_sip_header_content_type_get_type(L_content_type),"text");
CU_ASSERT_STRING_EQUAL(belle_sip_header_content_type_get_subtype(L_content_type),"html");
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));
}
int belle_sip_headers_test_suite() {
......@@ -106,5 +140,17 @@ int belle_sip_headers_test_suite() {
if (NULL == CU_add_test(pSuite, "test of to header", test_simple_header_to)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "test of via header", test_header_via)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "test of callid header", test_header_callid)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "test of cseq header", test_header_cseq)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "test of content type header", test_header_content_type)) {
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