Commit f80fb643 authored by jehan's avatar jehan

start sdp parser implementation

parent db2eea2e
This diff is collapsed.
......@@ -68,6 +68,23 @@ typedef enum belle_sip_type_id{
BELLE_SIP_TYPE_ID(belle_sip_header_authorization_t),
BELLE_SIP_TYPE_ID(belle_sip_header_www_authenticate_t),
BELLE_SIP_TYPE_ID(belle_sip_header_proxy_authorization_t),
BELLE_SIP_TYPE_ID(belle_sdp_attribute_t),
BELLE_SIP_TYPE_ID(belle_sdp_bandwidth_t),
BELLE_SIP_TYPE_ID(belle_sdp_connection_t),
BELLE_SIP_TYPE_ID(belle_sdp_email_t),
BELLE_SIP_TYPE_ID(belle_sdp_info_t),
BELLE_SIP_TYPE_ID(belle_sdp_key_t),
BELLE_SIP_TYPE_ID(belle_sdp_media_t),
BELLE_SIP_TYPE_ID(belle_sdp_media_description_t),
BELLE_SIP_TYPE_ID(belle_sdp_origin_t),
BELLE_SIP_TYPE_ID(belle_sdp_phone_t),
BELLE_SIP_TYPE_ID(belle_sdp_repeate_time_t),
BELLE_SIP_TYPE_ID(belle_sdp_session_description_t),
BELLE_SIP_TYPE_ID(belle_sdp_session_name_t),
BELLE_SIP_TYPE_ID(belle_sdp_time_t),
BELLE_SIP_TYPE_ID(belle_sdp_time_description_t),
BELLE_SIP_TYPE_ID(belle_sdp_uri_t),
BELLE_SIP_TYPE_ID(belle_sdp_version_t),
belle_sip_type_id_end
}belle_sip_type_id_t;
......
/*
belle-sdp - SDP (RFC) library.
Copyright (C) 2010 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
grammar belle_sdp;
options {
language = C;
}
@header {
#include "belle-sip/belle-sdp.h"
#include "belle_sip_internal.h"
}
titi: TOTO;
TOTO: .;
grammar belle_sip_uri;
options {
language = C;
}
@header { #include "belle-sip/uri.h"}
to_header : 'TO' ':' an_sip_uri;
an_sip_uri returns [belle_sip_uri_t* ret]
scope { belle_sip_uri_t* current; }
@init { $an_sip_uri::current = belle_sip_uri_new(); }
: sip_schema ((userinfo hostport) | hostport ) uri_parameters? headers? {$ret = $an_sip_uri::current;};
sip_schema : ('sip' | is_sips='sips') ':' {if ($is_sips) belle_sip_uri_set_secure($an_sip_uri::current,1);};
userinfo : user ( ':' password )? '@' ;
user : ( unreserved | escaped | user_unreserved )+ {belle_sip_uri_set_user($an_sip_uri::current,(const char *)$text->chars);};
user_unreserved : '&' | '=' | '+' | '$' | ',' | ';' | '?' | '/';
password : ( unreserved |'&' | '=' | '+' | '$' | ',' )*;
hostport : host ( ':' port )? {belle_sip_uri_set_host($an_sip_uri::current,(const char *)$host.text->chars);};
host : (hostname | ipv4address | ipv6reference) ;
hostname : ( domainlabel '.' )* toplabel '.'? ;
domainlabel : alphanum | (alphanum ( alphanum | '-' )* alphanum) ;
toplabel : alpha | (alpha ( alphanum | '-' )* alphanum) ;
ipv4address : three_digit '.' three_digit '.' three_digit '.' three_digit;
ipv6reference : '[' ipv6address ']';
ipv6address : hexpart ( ':' ipv4address )?;
hexpart : hexseq | hexseq '::' ( hexseq )? | '::' ( hexseq )?;
hexseq : hex4 ( ':' hex4)*;
hex4 : hexdigit hexdigit hexdigit hexdigit ;
port : DIGIT+ {belle_sip_uri_set_port($an_sip_uri::current,atoi((const char *)$text->chars));};
uri_parameters
: ( ';' uri_parameter )+;
uri_parameter //all parameters are considered as other
: other_param ;
other_param : pname ( '=' pvalue )?
{
if (strcmp("lr",(const char *)$pname.text->chars) == 0) {
belle_sip_uri_set_lr_param($an_sip_uri::current,1);
} else if (strcmp("transport",(const char*)$pname.text->chars)==0) {
belle_sip_uri_set_transport_param($an_sip_uri::current,(const char *)$pvalue.text->chars);
} else if (strcmp("user",(const char *)$pname.text->chars)==0) {
belle_sip_uri_set_user_param($an_sip_uri::current,(const char *)$pvalue.text->chars);
} else if (strcmp("maddr",(const char *)$pname.text->chars)==0) {
belle_sip_uri_set_maddr_param($an_sip_uri::current,(const char *)$pvalue.text->chars);
} else if (strcmp("ttl",(const char *)$pname.text->chars)==0) {
belle_sip_uri_set_ttl_param($an_sip_uri::current,atoi((const char *)$pvalue.text->chars));
}
};
pname
: paramchar+;
pvalue
: paramchar+;
paramchar
: param_unreserved | unreserved | escaped;
param_unreserved
: '[' | ']' | '/' | ':' | '&' | '+' | '$' | '.';
headers : '?' header ( '&' header )* ;
header : hname '=' hvalue? {belle_sip_uri_set_header($an_sip_uri::current,(const char *)$hname.text->chars,(const char *)$hvalue.text->chars);};
hname : ( hnv_unreserved | unreserved | escaped )+;
hvalue : ( hnv_unreserved | unreserved | escaped )+;
hnv_unreserved : '[' | ']' | '|' | '?' | ':' | '+' | '$' ;
escaped : '%' hexdigit hexdigit;
ttl : three_digit;
three_digit: DIGIT | (DIGIT DIGIT) | (DIGIT DIGIT DIGIT) ;
token
: (alphanum | MARK_LEX | '%' | '+' | '`' )+;
unreserved : alphanum |MARK_LEX;
alphanum : alpha | DIGIT ;
hexdigit
: HEX_CHAR|DIGIT;
alpha : HEX_CHAR | COMMON_CHAR;
COMMON_CHAR
: 'g'..'z' | 'G'..'Z' ;
MARK_LEX : '-' | '_' | '.' | '!' | '~' | '*' | '\'' ;
HEX_CHAR: 'a'..'f' |'A'..'F';
DIGIT : '0'..'9' ;
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