Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
belle-sip
Commits
48d9aa44
Commit
48d9aa44
authored
Sep 30, 2010
by
jehan
Browse files
implement lr & maddr
parent
37ccabae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
16 deletions
+65
-16
include/belle_sip_uri.h
include/belle_sip_uri.h
+2
-2
src/belle_sip_uri.g
src/belle_sip_uri.g
+21
-13
src/belle_sip_uri_impl.c
src/belle_sip_uri_impl.c
+15
-0
tester/belle_sip_uri_tester.c
tester/belle_sip_uri_tester.c
+27
-1
No files found.
include/belle_sip_uri.h
View file @
48d9aa44
...
...
@@ -102,7 +102,7 @@ typedef struct _belle_sip_uri belle_sip_uri;
* Sets the value of the lr parameter of this SipURI.
*
*/
void
belle_sip_uri_set_lr_param
(
belle_sip_uri
*
uri
)
;
void
belle_sip_uri_set_lr_param
(
belle_sip_uri
*
uri
,
unsigned
int
param
)
;
/**
* Sets the value of the maddr parameter of this SipURI.
*
...
...
@@ -122,7 +122,7 @@ typedef struct _belle_sip_uri belle_sip_uri;
* Sets the scheme of this URI to sip or sips depending on whether the argument is true or false.
*
*/
void
belle_sip_uri_set_secure
(
belle_sip_uri
*
uri
,
unsigned
secure
)
;
void
belle_sip_uri_set_secure
(
belle_sip_uri
*
uri
,
unsigned
int
secure
)
;
/**
* Sets the value of the "transport" parameter.
*
...
...
src/belle_sip_uri.g
View file @
48d9aa44
...
...
@@ -6,17 +6,26 @@ options { language = C;}
an_sip_uri returns [belle_sip_uri* ret]
scope { belle_sip_uri* current; }
@init { $an_sip_uri::current = belle_sip_uri_new(); }
: 'sip:' userinfo? hostport uri_parameters {$ret = $an_sip_uri::current;};
: sip_schema userinfo? hostport uri_parameters {$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 | user_unreserved )+ {belle_sip_uri_set_user($an_sip_uri::current,(const char *)$text->chars);};
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 )?;
host : hostname
{belle_sip_uri_set_host($an_sip_uri::current,(const char *)$text->chars);}
;
hostname : ( domainlabel '.' )* toplabel '.'? ;
hostport : host ( ':' port )?
{belle_sip_uri_set_host($an_sip_uri::current,(const char *)$host.text->chars);}
;
host :
(
hostname
| ipv4address | ipv6reference)
;
fragment
hostname : ( domainlabel '.' )* toplabel '.'? ;
domainlabel : alphanum | alphanum ( alphanum | '-' )* alphanum ;
toplabel : ALPHA | ALPHA ( alphanum | '-' )* alphanum;
fragment domainlabel : alphanum | alphanum ( alphanum | '-' )* alphanum ;
fragment toplabel : ALPHA | ALPHA ( alphanum | '-' )* alphanum;
ipv4address : three_digit '.' three_digit '.' three_digit '.' three_digit;
ipv6reference : '[' ipv6address ']';
ipv6address : hexpart ( ':' ipv4address )?;
fragment hexpart : hexseq | hexseq '::' ( hexseq )? | '::' ( hexseq )?;
fragment hexseq : hex4 ( ':' hex4)*;
fragment hex4 : HEXDIG HEXDIG HEXDIG HEXDIG ;
port : DIGIT+ {belle_sip_uri_set_port($an_sip_uri::current,atoi((const char *)$text->chars));};
...
...
@@ -39,9 +48,9 @@ other_user
ttl_param
: 'ttl=' ttl;
maddr_param
: 'maddr=' host;
: 'maddr=' host
{belle_sip_uri_set_maddr_param($an_sip_uri::current,(const char *)$host.text->chars);}
;
lr_param
: 'lr';
: 'lr'
{belle_sip_uri_set_lr_param($an_sip_uri::current,1);}
;
other_param : pname ( '=' pvalue )?;
pname
: paramchar+;
...
...
@@ -52,10 +61,9 @@ paramchar
param_unreserved
: '[' | ']' | '/' | ':' | '&' | '+' | '$';
fragment ttl
: DIGIT DIGIT? DIGIT? ;
fragment escaped
: '%' HEXDIG HEXDIG;
fragment escaped : '%' HEXDIG HEXDIG;
fragment ttl : three_digit;
fragment three_digit: DIGIT DIGIT? DIGIT? ;
fragment token
: (alphanum | MARK_LEX | '%' | '+' | '`' )+;
...
...
src/belle_sip_uri_impl.c
View file @
48d9aa44
...
...
@@ -34,7 +34,16 @@
#define SIP_URI_GET_SET_UINT(attribute) GET_SET_UINT(belle_sip_uri,attribute)
#define GET_SET_BOOL(object_type,attribute,getter) \
unsigned int object_type##_##getter##_##attribute (object_type* obj) {\
return obj->attribute;\
}\
void object_type##_set_##attribute (object_type* obj,unsigned int value) {\
obj->attribute=value;\
}
#define SIP_URI_GET_SET_BOOL(attribute) GET_SET_BOOL(belle_sip_uri,attribute,is)
#define SIP_URI_HAS_SET_BOOL(attribute) GET_SET_BOOL(belle_sip_uri,attribute,has)
...
...
@@ -44,6 +53,9 @@ struct _belle_sip_uri {
const
char
*
host
;
const
char
*
transport_param
;
unsigned
int
port
;
unsigned
int
secure
;
unsigned
int
lr_param
;
const
char
*
maddr_param
;
};
belle_sip_uri
*
belle_sip_uri_parse
(
const
char
*
uri
)
{
pANTLR3_INPUT_STREAM
input
;
...
...
@@ -137,4 +149,7 @@ char* belle_sip_uri_to_string(belle_sip_uri* uri) {
SIP_URI_GET_SET_STRING
(
user
)
SIP_URI_GET_SET_STRING
(
host
)
SIP_URI_GET_SET_STRING
(
transport_param
)
SIP_URI_GET_SET_STRING
(
maddr_param
)
SIP_URI_GET_SET_UINT
(
port
)
SIP_URI_GET_SET_BOOL
(
secure
)
SIP_URI_HAS_SET_BOOL
(
lr_param
)
tester/belle_sip_uri_tester.c
View file @
48d9aa44
...
...
@@ -33,6 +33,28 @@ void testCOMPLEXURI(void) {
CU_ASSERT_STRING_EQUAL
(
belle_sip_uri_get_host
(
L_uri
),
"titi.com"
);
CU_ASSERT_STRING_EQUAL
(
belle_sip_uri_get_transport_param
(
L_uri
),
"tcp"
);
}
void
testSIPSURI
(
void
)
{
belle_sip_uri
*
L_uri
=
belle_sip_uri_parse
(
"sips:titi.com"
);
CU_ASSERT_EQUAL
(
belle_sip_uri_is_secure
(
L_uri
),
1
);
belle_sip_uri_delete
(
L_uri
);
L_uri
=
belle_sip_uri_parse
(
"sip:titi.com"
);
CU_ASSERT_EQUAL
(
belle_sip_uri_is_secure
(
L_uri
),
0
);
}
void
test_ip_host
(
void
)
{
belle_sip_uri
*
L_uri
=
belle_sip_uri_parse
(
"sip:192.168.0.1"
);
CU_ASSERT_STRING_EQUAL
(
belle_sip_uri_get_host
(
L_uri
),
"192.168.0.1"
);
}
void
test_lr
(
void
)
{
belle_sip_uri
*
L_uri
=
belle_sip_uri_parse
(
"sip:192.168.0.1;lr"
);
CU_ASSERT_STRING_EQUAL
(
belle_sip_uri_get_host
(
L_uri
),
"192.168.0.1"
);
CU_ASSERT_EQUAL
(
belle_sip_uri_has_lr_param
(
L_uri
),
1
);
}
void
test_maddr
(
void
)
{
belle_sip_uri
*
L_uri
=
belle_sip_uri_parse
(
"sip:192.168.0.1;lr;maddr=linphone.org"
);
CU_ASSERT_STRING_EQUAL
(
belle_sip_uri_get_maddr_param
(
L_uri
),
"linphone.org"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -53,7 +75,11 @@ int main (int argc, char *argv[]) {
/* add the tests to the suite */
/* NOTE - ORDER IS IMPORTANT - MUST TEST fread() AFTER fprintf() */
if
((
NULL
==
CU_add_test
(
pSuite
,
"test of simple uri"
,
testSIMPLEURI
))
||
(
NULL
==
CU_add_test
(
pSuite
,
"test of complex uri"
,
testCOMPLEXURI
)))
(
NULL
==
CU_add_test
(
pSuite
,
"test of complex uri"
,
testCOMPLEXURI
))
||
(
NULL
==
CU_add_test
(
pSuite
,
"test of ip uri"
,
test_ip_host
))
||
(
NULL
==
CU_add_test
(
pSuite
,
"test of lr uri"
,
test_lr
))
||
(
NULL
==
CU_add_test
(
pSuite
,
"test of maddr uri"
,
test_maddr
))
||
(
NULL
==
CU_add_test
(
pSuite
,
"test of sips uri"
,
testSIPSURI
)))
{
CU_cleanup_registry
();
return
CU_get_error
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment