Commit 1884e97a authored by jehan's avatar jehan
Browse files

test basic invite + basic register

parent bb3fbc74
......@@ -64,6 +64,7 @@ typedef enum belle_sip_type_id{
BELLE_SIP_TYPE_ID(belle_sip_header_record_route_t),
BELLE_SIP_TYPE_ID(belle_sip_header_content_length_t),
BELLE_SIP_TYPE_ID(belle_sip_header_t),
BELLE_SIP_TYPE_ID(belle_sip_header_extension_t),
belle_sip_type_id_end
}belle_sip_type_id_t;
......
......@@ -250,4 +250,17 @@ unsigned int belle_sip_header_content_length_get_content_length(const belle_sip_
void belle_sip_header_content_length_set_content_length(belle_sip_header_content_length_t* content_length,unsigned int length);
#define BELLE_SIP_HEADER_CONTENT_LENGTH(t) BELLE_SIP_CAST(t,belle_sip_header_content_length_t)
/******************************
* Extension header hinerite from header
*
******************************/
typedef struct _belle_sip_header_extension belle_sip_header_extension_t;
belle_sip_header_extension_t* belle_sip_header_extension_new();
belle_sip_header_extension_t* belle_sip_header_extension_parse (const char* extension) ;
const char* belle_sip_header_extension_length_get_value(const belle_sip_header_extension_t* extension);
void belle_sip_header_extension_length_set_value(belle_sip_header_extension_t* extension,const char* value);
#define BELLE_SIP_HEADER_EXTENSION(t) BELLE_SIP_CAST(t,belle_sip_header_extension_t)
#endif /* HEADERS_H_ */
......@@ -98,7 +98,7 @@ void belle_sip_header_contact_destroy(belle_sip_header_contact_t* contact) {
void belle_sip_header_contact_clone(belle_sip_header_contact_t *contact, const belle_sip_header_contact_t *orig){
}
BELLE_SIP_NEW_WITH_NAME(header_contact,header_address,"Contact")
BELLE_SIP_NEW_HEADER(header_contact,header_address,"Contact")
BELLE_SIP_PARSE(header_contact)
GET_SET_INT_PARAM_PRIVATE(belle_sip_header_contact,expires,int,_)
......@@ -140,7 +140,7 @@ static void belle_sip_header_from_clone(belle_sip_header_from_t* from, const bel
}
BELLE_SIP_NEW_WITH_NAME(header_from,header_address,"From")
BELLE_SIP_NEW_HEADER(header_from,header_address,"From")
BELLE_SIP_PARSE(header_from)
GET_SET_STRING_PARAM(belle_sip_header_from,tag);
......@@ -158,7 +158,7 @@ static void belle_sip_header_to_destroy(belle_sip_header_to_t* to) {
void belle_sip_header_to_clone(belle_sip_header_to_t *contact, const belle_sip_header_to_t *orig){
}
BELLE_SIP_NEW_WITH_NAME(header_to,header_address,"To")
BELLE_SIP_NEW_HEADER(header_to,header_address,"To")
BELLE_SIP_PARSE(header_to)
GET_SET_STRING_PARAM(belle_sip_header_to,tag);
......@@ -182,7 +182,7 @@ static void belle_sip_header_via_destroy(belle_sip_header_via_t* via) {
static void belle_sip_header_via_clone(belle_sip_header_via_t* via, const belle_sip_header_via_t*orig){
}
BELLE_SIP_NEW_WITH_NAME(header_via,header_address,"Via")
BELLE_SIP_NEW_HEADER(header_via,header_address,"Via")
BELLE_SIP_PARSE(header_via)
GET_SET_STRING(belle_sip_header_via,protocol);
GET_SET_STRING(belle_sip_header_via,transport);
......@@ -236,7 +236,7 @@ int belle_sip_header_via_get_listening_port(const belle_sip_header_via_t *via){
****************************
*/
struct _belle_sip_header_call_id {
belle_sip_object_t base;
belle_sip_header_t header;
const char* call_id;
};
......@@ -247,7 +247,7 @@ static void belle_sip_header_call_id_destroy(belle_sip_header_call_id_t* call_id
static void belle_sip_header_call_id_clone(belle_sip_header_call_id_t* call_id,const belle_sip_header_call_id_t *orig){
}
BELLE_SIP_NEW_WITH_NAME(header_call_id,header,"Call-ID")
BELLE_SIP_NEW_HEADER(header_call_id,header,"Call-ID")
BELLE_SIP_PARSE(header_call_id)
GET_SET_STRING(belle_sip_header_call_id,call_id);
/**************************
......@@ -255,7 +255,7 @@ GET_SET_STRING(belle_sip_header_call_id,call_id);
****************************
*/
struct _belle_sip_header_cseq {
belle_sip_object_t base;
belle_sip_header_t header;
const char* method;
unsigned int seq_number;
};
......@@ -268,7 +268,7 @@ static void belle_sip_header_cseq_clone(belle_sip_header_cseq_t* cseq, const bel
if (cseq->method) belle_sip_free((void*)cseq->method);
}
BELLE_SIP_NEW_WITH_NAME(header_cseq,header,"Cseq")
BELLE_SIP_NEW_HEADER(header_cseq,header,"CSeq")
BELLE_SIP_PARSE(header_cseq)
GET_SET_STRING(belle_sip_header_cseq,method);
GET_SET_INT(belle_sip_header_cseq,seq_number,unsigned int)
......@@ -290,7 +290,7 @@ static void belle_sip_header_content_type_destroy(belle_sip_header_content_type_
static void belle_sip_header_content_type_clone(belle_sip_header_content_type_t* content_type, const belle_sip_header_content_type_t* orig){
}
BELLE_SIP_NEW_WITH_NAME(header_content_type,parameters,"Content-Type")
BELLE_SIP_NEW_HEADER(header_content_type,parameters,"Content-Type")
BELLE_SIP_PARSE(header_content_type)
GET_SET_STRING(belle_sip_header_content_type,type);
GET_SET_STRING(belle_sip_header_content_type,subtype);
......@@ -308,7 +308,7 @@ static void belle_sip_header_route_destroy(belle_sip_header_route_t* route) {
static void belle_sip_header_route_clone(belle_sip_header_route_t* route, const belle_sip_header_route_t* orig) {
}
BELLE_SIP_NEW_WITH_NAME(header_route,header_address,"Route")
BELLE_SIP_NEW_HEADER(header_route,header_address,"Route")
BELLE_SIP_PARSE(header_route)
/**************************
* Record route header object inherent from header_address
......@@ -325,14 +325,14 @@ static void belle_sip_header_record_route_clone(belle_sip_header_record_route_t*
const belle_sip_header_record_route_t* orig ) {
}
BELLE_SIP_NEW_WITH_NAME(header_record_route,header_address,"Record-Route")
BELLE_SIP_NEW_HEADER(header_record_route,header_address,"Record-Route")
BELLE_SIP_PARSE(header_record_route)
/**************************
* content length header object inherent from object
****************************
*/
struct _belle_sip_header_content_length {
belle_sip_object_t base;
belle_sip_header_t header;
unsigned int content_length;
};
......@@ -344,6 +344,49 @@ static void belle_sip_header_content_length_clone(belle_sip_header_content_lengt
}
BELLE_SIP_NEW_WITH_NAME(header_content_length,header,"Content-Length")
BELLE_SIP_NEW_HEADER(header_content_length,header,"Content-Length")
BELLE_SIP_PARSE(header_content_length)
GET_SET_INT(belle_sip_header_content_length,content_length,unsigned int)
/******************************
* Extension header hinerite from header
*
******************************/
struct _belle_sip_header_extension {
belle_sip_header_t header;
const char* value;
};
static void belle_sip_header_extension_destroy(belle_sip_header_extension_t* extension) {
if (extension->value) belle_sip_free((void*)extension->value);
}
static void belle_sip_header_extension_clone(belle_sip_header_extension_t* extension, const belle_sip_header_extension_t* orig){
}
BELLE_SIP_NEW_HEADER(header_extension,header,NULL)
/**
* special case for this header. I don't know why
*/
belle_sip_header_extension_t* belle_sip_header_extension_parse (const char* value) {
pANTLR3_INPUT_STREAM input;
pbelle_sip_messageLexer lex;
pANTLR3_COMMON_TOKEN_STREAM tokens;
pbelle_sip_messageParser parser;
input = antlr3NewAsciiStringCopyStream (
(pANTLR3_UINT8)value,
(ANTLR3_UINT32)strlen(value),
((void *)0));
lex = belle_sip_messageLexerNew (input);
tokens = antlr3CommonTokenStreamSourceNew (1025, lex->pLexer->rec->state->tokSource);
parser = belle_sip_messageParserNew (tokens);
belle_sip_messageParser_header_extension_return l_parsed_object = parser->header_extension(parser,FALSE);
parser ->free(parser);
tokens ->free(tokens);
lex ->free(lex);
input ->close(input);
if (l_parsed_object.ret == NULL) belle_sip_error("Parser error for [%s]",value);\
return BELLE_SIP_HEADER_EXTENSION(l_parsed_object.ret);
}
GET_SET_STRING(belle_sip_header_extension,value);
......@@ -357,17 +357,18 @@ belle_sip_##object_type##_t* belle_sip_##object_type##_parse (const char* value)
tokens ->free(tokens);\
lex ->free(lex);\
input ->close(input);\
if (l_parsed_object == NULL) belle_sip_error(#object_type" parser error for [%s]",value);\
return l_parsed_object;\
}
#define BELLE_SIP_NEW(object_type,super_type) BELLE_SIP_NEW_WITH_NAME(object_type,super_type,NULL)
#define BELLE_SIP_NEW(object_type,super_type) BELLE_SIP_NEW_HEADER(object_type,super_type,NULL)
#define BELLE_SIP_NEW_WITH_NAME(object_type,super_type,name) \
#define BELLE_SIP_NEW_HEADER(object_type,super_type,name) \
BELLE_SIP_INSTANCIATE_VPTR(belle_sip_##object_type##_t,belle_sip_##super_type##_t , belle_sip_##object_type##_destroy, belle_sip_##object_type##_clone); \
belle_sip_##object_type##_t* belle_sip_##object_type##_new () { \
belle_sip_##object_type##_t* l_object = belle_sip_object_new(belle_sip_##object_type##_t);\
belle_sip_##super_type##_init((belle_sip_##super_type##_t*)l_object); \
belle_sip_object_set_name(BELLE_SIP_OBJECT(l_object),name);\
if (name) belle_sip_header_set_name(BELLE_SIP_HEADER(l_object),name);\
return l_object;\
}
typedef struct belle_sip_param_pair_t {
......
......@@ -36,13 +36,13 @@ message returns [belle_sip_message_t* ret]
request returns [belle_sip_request_t* ret]
scope { belle_sip_request_t* current; }
@init {$request::current = belle_sip_request_new(); $ret=$request::current; }
: request_line message_header[BELLE_SIP_MESSAGE($request::current)]+ CRLF message_body ? ;
: request_line message_header[BELLE_SIP_MESSAGE($request::current)]+ CRLF /*message_body ?*/ ;
request_line
: method {belle_sip_request_set_method($request::current,(const char*)($method.text->chars));}
SP
(SP)=>LWS
uri {belle_sip_request_set_uri($request::current,$uri.ret);}
SP
LWS
sip_version
CRLF ;
......@@ -52,52 +52,54 @@ sip_version
message_header [belle_sip_message_t* message]
: (/*accept
| accept_encoding
| accept_language
| alert_info
| allow
| authentication_info
| authorization
|*/ header_call_id {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_call_id.ret));}/*
| call_info
| contact
| content_disposition
| content_encoding
| content_language*/
| header_content_length {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_content_length.ret));}
| header_content_type {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_content_type.ret));}
| header_cseq {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_cseq.ret));}/*
| date
| error_info
| expires*/
| header_from {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_from.ret));}/*
| in_reply_to
| max_forwards
| mime_version
| min_expires
| organization
| priority
| proxy_authenticate
| proxy_authorization
| proxy_require*/
| header_record_route {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_record_route.ret));}/*
| reply_to
| require
| retry_after*/
| header_route {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_route.ret));}/*
| server
| subject
| supported
| timestamp*/
| header_to {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_to.ret));}/*
| unsupported
| user_agent*/
| header_via {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_via.ret));}/*
| warning
| www_authenticate*/
| header_extension_header
// | accept_encoding
// | accept_language
// | alert_info
// | allow
// | authentication_info
// | authorization
// | header_call_id {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_call_id.ret));}/*
// | call_info
// | header_contact {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_contact.ret));}
// | content_disposition
// | content_encoding
// | content_language*/
// | header_content_length {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_content_length.ret));}
// | header_content_type {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_content_type.ret));}
// | header_cseq {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_cseq.ret));}/*
// | date
// | error_info
// | expires*/
// | header_from {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_from.ret));}/*
// | in_reply_to
// | max_forwards
// | mime_version
// | min_expires
// | organization
// | priority
// | proxy_authenticate
// | proxy_authorization
// | proxy_require*/
// | header_record_route {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_record_route.ret));}/*
// | reply_to
// | require
// | retry_after*/
// | header_route {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_route.ret));}/*
// | server
// | subject
// | supported
// | timestamp*/
// | header_to {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_to.ret));}/*
// | unsupported
// | user_agent*/
// | header_via {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_via.ret));}/*
// | warning
// | www_authenticate*/
header_extension[TRUE] {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_extension.ret));}
) CRLF
;
/*
invitem
: 'INVITE' ; //INVITE in caps
......@@ -159,7 +161,7 @@ qvalue
generic_param [belle_sip_parameters_t* object] returns [belle_sip_param_pair_t* ret]
scope{int is_value;}
@init { $generic_param::is_value=0; }
: SP* token ( SP* EQUAL SP* gen_value {$generic_param::is_value = 1;} )? {
: token ( equal gen_value {$generic_param::is_value = 1;} )? {
if (object == NULL) {
$ret=belle_sip_param_pair_new((const char*)($token.text->chars)
,$generic_param::is_value?(const char*)($gen_value.text->chars):NULL);
......@@ -306,7 +308,7 @@ scope { belle_sip_header_contact_t* current; }
| (contact_param (COMMA contact_param)*)) {$ret = $header_contact::current;};
contact_param
: (name_addr[BELLE_SIP_HEADER_ADDRESS($header_contact::current)]
| addr_spec[BELLE_SIP_HEADER_ADDRESS($header_contact::current)]) (SEMI contact_params)*;
| addr_spec[BELLE_SIP_HEADER_ADDRESS($header_contact::current)]) (semi contact_params)*;
name_addr[belle_sip_header_address_t* object]
: ( display_name[object] )? sp_laquot_sp addr_spec[object] sp_raquot_sp;
......@@ -384,7 +386,7 @@ media_type
: m_type {belle_sip_header_content_type_set_type($header_content_type::current,(const char*)$m_type.text->chars);}
slash
m_subtype {belle_sip_header_content_type_set_subtype($header_content_type::current,(const char*)$m_subtype.text->chars);}
(SEMI generic_param [BELLE_SIP_PARAMETERS($header_content_type::current)]);
(semi generic_param [BELLE_SIP_PARAMETERS($header_content_type::current)])*;
m_type
: token; /* discrete_type | composite_type;
discrete_type
......@@ -416,7 +418,7 @@ scope { belle_sip_header_cseq_t* current; }
: cseq_token
hcolon
seq_number {belle_sip_header_cseq_set_seq_number($header_cseq::current,atoi((const char*)$seq_number.text->chars));}
lws
LWS
method {belle_sip_header_cseq_set_method($header_cseq::current,(const char*)$method.text->chars);} ;
seq_number:DIGIT+;
/*
......@@ -541,7 +543,7 @@ scope { belle_sip_header_record_route_t* current; }
: record_route_token /*'Record-Route'*/ hcolon rec_route /*(COMMA rec_route)**/;
rec_route
: name_addr[BELLE_SIP_HEADER_ADDRESS($header_record_route::current)] ( SEMI rr_param )*;
: name_addr[BELLE_SIP_HEADER_ADDRESS($header_record_route::current)] ( semi rr_param )*;
rr_param
: generic_param[BELLE_SIP_PARAMETERS($header_record_route::current)];
/*
......@@ -572,7 +574,7 @@ 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 )*;
: name_addr[BELLE_SIP_HEADER_ADDRESS($header_route::current)] ( semi r_param )*;
r_param
: generic_param[BELLE_SIP_PARAMETERS($header_route::current)];
/*
......@@ -607,10 +609,10 @@ 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' )*/ hcolon to_spec {$ret = $header_to::current;};
: to_token /*'To' ( '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 )*;
( semi to_param )*;
to_param
: /*tag_param |*/ generic_param [BELLE_SIP_PARAMETERS($header_to::current)];
/*
......@@ -627,7 +629,7 @@ scope { belle_sip_header_via_t* current; }
: via_token/* ( 'via' | 'v' )*/ hcolon via_parm (COMMA via_parm)* {$ret = $header_via::current;};
via_parm
: sent_protocol SP* sent_by ( SEMI via_params )*;
: sent_protocol LWS sent_by ( semi via_params )*;
via_params
: /*via_ttl | via_maddr
| via_received | via_branch
......@@ -643,8 +645,8 @@ via_branch
via_extension
: generic_param;*/
sent_protocol
: (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 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
......@@ -677,12 +679,40 @@ pseudonym
www_authenticate
: 'WWW-Authenticate' HCOLON challenge;
*/
header_extension_header
: header_name hcolon header_value;
header_extension[ANTLR3_BOOLEAN check_for_known_header] returns [belle_sip_header_t* ret]
: header_name
hcolon
header_value {if (check_for_known_header && strcmp("Contact",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_contact_parse((const char*)$header_extension.text->chars));
} else if (check_for_known_header && strcmp("From",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_from_parse((const char*)$header_extension.text->chars));
} else if (check_for_known_header && strcmp("To",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_to_parse((const char*)$header_extension.text->chars));
} else if (check_for_known_header && strcmp("Call-ID",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_call_id_parse((const char*)$header_extension.text->chars));
} else if (check_for_known_header && strcmp("Content-Length",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_content_length_parse((const char*)$header_extension.text->chars));
} else if (check_for_known_header && strcmp("Content-Type",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_content_type_parse((const char*)$header_extension.text->chars));
} else if (check_for_known_header && strcmp("CSeq",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_cseq_parse((const char*)$header_extension.text->chars));
} else if (check_for_known_header && strcmp("Route",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_route_parse((const char*)$header_extension.text->chars));
} else if (check_for_known_header && strcmp("Record-Route",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_record_route_parse((const char*)$header_extension.text->chars));
} else if (check_for_known_header && strcmp("Via",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_via_parse((const char*)$header_extension.text->chars));
} else {
$ret = BELLE_SIP_HEADER(belle_sip_header_extension_new());
belle_sip_header_extension_set_value($ret,(const char*)$header_value.text->chars);
belle_sip_header_set_name($ret,(const char*)$header_name.text->chars);
}
} ;
header_name
: token;
header_value
: (~CRLF)*;
: ~(CRLF)* ;
message_body
options { greedy = false; }
......@@ -692,7 +722,11 @@ uri returns [belle_sip_uri_t* ret]
scope { belle_sip_uri_t* current; }
@init { $uri::current = belle_sip_uri_new(); }
: sip_schema ((userinfo hostport) | hostport ) uri_parameters? headers? {$ret = $uri::current;};
sip_schema : ('sip' | is_sips='sips') COLON {if ($is_sips) belle_sip_uri_set_secure($uri::current,1);};
sip_token: {strcmp("sip",(const char*)(INPUT->toStringTT(INPUT,LT(1),LT(3)))->chars) == 0}? token;
sips_token: {strcmp("sips",(const char*)(INPUT->toStringTT(INPUT,LT(1),LT(4)))->chars) == 0}? token;
sip_schema : (sips_token {belle_sip_uri_set_secure($uri::current,1);}
| sip_token) COLON ;
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;
......@@ -715,7 +749,7 @@ port returns [int ret]: DIGIT+ { $ret=atoi((const char *)$text->chars); };
uri_parameters
: ( SEMI uri_parameter )+;
: ( semi uri_parameter )+;
uri_parameter //all parameters are considered as other
: other_param ;
other_param
......@@ -736,7 +770,7 @@ pvalue
paramchar
: param_unreserved | unreserved | escaped;
param_unreserved
: '[' | ']' | SLASH | COLON | '&' | '+' | '$' | '.';
: '[' | ']' | SLASH | COLON | '&' | PLUS | '$' | '.';
headers : '?' header ( '&' header )* ;
header : hname EQUAL hvalue? {belle_sip_uri_set_header($uri::current,(const char *)$hname.text->chars,(const char *)$hvalue.text->chars);};
......@@ -744,15 +778,15 @@ hname : ( hnv_unreserved | unreserved | escaped )+;
hvalue : ( hnv_unreserved | unreserved | escaped )+;
hnv_unreserved : '[' | ']' | '|' | '?' | COLON | '+' | '$' ;
hnv_unreserved : '[' | ']' | '|' | '?' | COLON | PLUS | '$' ;
escaped : '%' hexdigit hexdigit;
ttl : three_digit;
three_digit: DIGIT | (DIGIT DIGIT) | (DIGIT DIGIT DIGIT) ;
token
: (alphanum | mark | '%' | '+' | '`' )+;
: (alphanum | mark | '%' | PLUS | '`' )+;
reserved
: SEMI | SLASH | '?' | COLON | '@' | '&' | EQUAL | '+'
: SEMI | SLASH | '?' | COLON | '@' | '&' | EQUAL | PLUS
| '$' | COMMA;
unreserved : alphanum |mark;
......@@ -762,8 +796,8 @@ hexdigit
alpha : HEX_CHAR | COMMON_CHAR;
word
: (alphanum | '-' | '.' | '!' | '%' | STAR |
'_' | '+' | '`' | '\'' | '~' |
: (alphanum | mark | '%'
| PLUS | '`' |
LPAREN | RPAREN | LAQUOT | RAQUOT |
COLON | '\\' | DQUOTE | SLASH | '[' | ']' | '?' | '{' | '}' )+;
......@@ -782,8 +816,8 @@ CRLF : '\r\n';
hcolon : ( SP | HTAB )* COLON sws ; //SWS;
hcolon : ( LWS | HTAB )* COLON LWS? //SWS;
;//|( SP | HTAB )* COLON LWS+;
HTAB : ' ';
......@@ -796,19 +830,23 @@ HTAB : ' ';
DQUOTE : '"';
// open double quotation mark
//SWS : LWS? ;
lws : (SP* CRLF)? SP+ ; //linear whitespace
sws : lws? ;
LWS : (SP* CRLF)? SP+ ; //linear whitespace
PLUS: '+';
COLON
: ':'
;
semi: sws SEMI sws;
semi: LWS? SEMI LWS?;
SEMI
: ';'
;
......@@ -818,9 +856,9 @@ COMMA
;
sp_laquot_sp
: SP* LAQUOT SP*;
: LWS? LAQUOT LWS?;
sp_raquot_sp
: SP* RAQUOT SP*;
: LWS? RAQUOT LWS?;
LAQUOT
: '<'
;
......@@ -837,11 +875,13 @@ LPAREN
: '('
;
equal:
LWS? EQUAL LWS?;
EQUAL
: '='
;
slash : sws SLASH sws;
slash : LWS? SLASH LWS?;
SLASH
: '/'
;
......@@ -849,7 +889,7 @@ SLASH
STAR
: '*'
;
fragment
SP
: ' '
;
......
......@@ -59,7 +59,7 @@ void belle_sip_uri_destroy(belle_sip_uri_t* uri) {
BELLE_SIP_PARSE(uri);
BELLE_SIP_INSTANCIATE_VPTR(belle_sip_uri_t,belle_sip_object_t,belle_sip_uri_destroy,NULL);
BELLE_SIP_INSTANCIATE_VPTR(belle_sip_uri_t,belle_sip_parameters_t,belle_sip_uri_destroy,NULL);
belle_sip_uri_t* belle_sip_uri_new () {
......
......@@ -28,7 +28,7 @@ typedef struct _headers_container {
static headers_container_t* belle_sip_message_headers_container_new(const char* name) {
headers_container_t* headers_container = belle_sip_new0(headers_container_t);
headers_container->name= belle_sip_strdup(name);
return NULL; /*FIXME*/
return headers_container;
}
static void belle_sip_headers_container_delete(headers_container_t *obj){
......@@ -70,14 +70,14 @@ headers_container_t * get_or_create_container(belle_sip_message_t *message, cons
headers_container_t* headers_container = belle_sip_headers_container_get(message,header_name);
if (headers_container == NULL) {
headers_container = belle_sip_message_headers_container_new(header_name);
belle_sip_list_append(message->header_list,headers_container);
message->header_list=belle_sip_list_append(message->header_list,headers_container);
}
return headers_container;
}
void belle_sip_message_add_header(belle_sip_message_t *message,belle_sip_header_t* header) {
headers_container_t *headers_container=get_or_create_container(message,belle_sip_header_get_name(header));
belle_sip_list_append(headers_container->header_list,belle_sip_object_ref(header));
headers_container->header_list=belle_sip_list_append(headers_container->header_list,belle_sip_object_ref(header));
}
void belle_sip_message_add_headers(belle_sip_message_t *message, const belle_sip_list_t *header_list){
......@@ -89,7 +89,7 @@ void belle_sip_message_add_headers(belle_sip_message_t *message, const belle_sip
belle_sip_fatal("Bad use of belle_sip_message_add_headers(): all headers of the list must be of the same type.");
return ;
}
belle_sip_list_append(headers_container->header_list,belle_sip_object_ref(h));
headers_container->header_list=belle_sip_list_append(headers_container->header_list,belle_sip_object_ref(h));
}
}
......@@ -101,6 +101,7 @@ const belle_sip_list_t* belle_sip_message_get_headers(belle_sip_message_t *messa
struct _belle_sip_request {
belle_sip_message_t message;
const char* method;
belle_sip_uri_t* uri;
};
static void belle_sip_request_destroy(belle_sip_request_t* request) {
......@@ -116,11 +117,14 @@ BELLE_SIP_PARSE(request)
GET_SET_STRING(belle_sip_request,method);
void belle_sip_request_set_uri(belle_sip_request_t* request,belle_sip_uri_t* uri) {
if (request->uri) {
belle_sip_object_unref(request->uri);
}
request->uri=BELLE_SIP_URI(belle_sip_object_ref(uri));
}
belle_sip_uri_t * belle_sip_request_get_uri(belle_sip_request_t *request){
return NULL;
return request->uri;
}
int belle_sip_message_is_request(belle_sip_message_t *msg){
......