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
01f7b920
Commit
01f7b920
authored
Oct 12, 2015
by
jehan
Browse files
add support for header supported
parent
4c1cb2bf
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
119 additions
and
2 deletions
+119
-2
include/belle-sip/headers.h
include/belle-sip/headers.h
+15
-0
include/belle-sip/types.h
include/belle-sip/types.h
+2
-1
src/CMakeLists.txt
src/CMakeLists.txt
+2
-0
src/belle_sip_headers_impl.c
src/belle_sip_headers_impl.c
+48
-0
src/belle_sip_internal.h
src/belle_sip_internal.h
+1
-0
src/grammars/belle_sip_message.g
src/grammars/belle_sip_message.g
+16
-0
tester/belle_sip_headers_tester.c
tester/belle_sip_headers_tester.c
+35
-1
No files found.
include/belle-sip/headers.h
View file @
01f7b920
...
...
@@ -686,6 +686,21 @@ BELLESIP_EXPORT void belle_sip_header_event_set_id(belle_sip_header_event_t* eve
#define BELLE_SIP_HEADER_EVENT(t) BELLE_SIP_CAST(t,belle_sip_header_event_t)
#define BELLE_SIP_EVENT "Event"
/******************************
* Supported header object inherent from header
*
******************************/
typedef
struct
_belle_sip_header_supported
belle_sip_header_supported_t
;
BELLESIP_EXPORT
belle_sip_header_supported_t
*
belle_sip_header_supported_new
();
BELLESIP_EXPORT
belle_sip_header_supported_t
*
belle_sip_header_supported_parse
(
const
char
*
supported
)
;
BELLESIP_EXPORT
belle_sip_header_supported_t
*
belle_sip_header_supported_create
(
const
char
*
supported
);
BELLESIP_EXPORT
void
belle_sip_header_supported_add_supported
(
belle_sip_header_supported_t
*
supported
,
const
char
*
value
);
BELLESIP_EXPORT
void
belle_sip_header_supported_set_supported
(
belle_sip_header_supported_t
*
supported
,
belle_sip_list_t
*
supported_values
);
BELLESIP_EXPORT
belle_sip_list_t
*
belle_sip_header_supported_get_supported
(
const
belle_sip_header_supported_t
*
supported
);
#define BELLE_SIP_HEADER_SUPPORTED(t) BELLE_SIP_CAST(t,belle_sip_header_supported_t)
#define BELLE_SIP_SUPPORTED "Supported"
BELLE_SIP_END_DECLS
...
...
include/belle-sip/types.h
View file @
01f7b920
...
...
@@ -131,7 +131,8 @@ BELLE_SIP_DECLARE_TYPES_BEGIN(belle_sip,1)
BELLE_SIP_TYPE_ID
(
belle_sip_user_body_handler_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_file_body_handler_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_multipart_body_handler_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_header_event_t
)
BELLE_SIP_TYPE_ID
(
belle_sip_header_event_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_header_supported_t
)
BELLE_SIP_DECLARE_TYPES_END
...
...
src/CMakeLists.txt
View file @
01f7b920
...
...
@@ -133,6 +133,8 @@ set(SOURCE_FILES
transports/stream_listeningpoint.c
transports/udp_channel.c
transports/udp_listeningpoint.c
grammars/belle_sip_message.g
grammars/belle_sdp.g
${
SDP_GENERATED_SOURCE_FILES
}
${
SIP_MESSAGE_GENERATED_SOURCE_FILES
}
${
TLS_SOURCE_FILES
}
...
...
src/belle_sip_headers_impl.c
View file @
01f7b920
...
...
@@ -77,6 +77,8 @@ static struct header_name_func_pair header_table[] = {
,{
PROTO_SIP
,
BELLE_SIP_P_PREFERRED_IDENTITY
,
(
header_parse_func
)
belle_sip_header_p_preferred_identity_parse
}
,{
PROTO_SIP
,
BELLE_SIP_PRIVACY
,
(
header_parse_func
)
belle_sip_header_privacy_parse
}
,{
PROTO_SIP
,
BELLE_SIP_EVENT
,
(
header_parse_func
)
belle_sip_header_event_parse
}
,{
PROTO_SIP
,
BELLE_SIP_SUPPORTED
,
(
header_parse_func
)
belle_sip_header_privacy_parse
}
,{
PROTO_SIP
,
"k"
,
(
header_parse_func
)
belle_sip_header_privacy_parse
}
};
static
belle_sip_header_t
*
belle_header_create
(
const
char
*
name
,
const
char
*
value
,
int
protocol
)
{
...
...
@@ -1855,4 +1857,50 @@ belle_sip_header_event_t* belle_sip_header_event_create (const char* package_nam
return
event
;
}
/******************************
* Supported header inherits from header
*
******************************/
struct
_belle_sip_header_supported
{
belle_sip_header_t
header
;
belle_sip_list_t
*
supported
;
};
static
void
belle_sip_header_supported_destroy
(
belle_sip_header_supported_t
*
p
)
{
belle_sip_header_supported_set_supported
(
p
,
NULL
);
}
static
void
belle_sip_header_supported_clone
(
belle_sip_header_supported_t
*
p
,
const
belle_sip_header_supported_t
*
orig
){
belle_sip_list_t
*
list
=
orig
->
supported
;
for
(;
list
!=
NULL
;
list
=
list
->
next
){
belle_sip_header_supported_add_supported
(
p
,(
const
char
*
)
list
->
data
);
}
}
belle_sip_error_code
belle_sip_header_supported_marshal
(
belle_sip_header_supported_t
*
p
,
char
*
buff
,
size_t
buff_size
,
size_t
*
offset
)
{
belle_sip_error_code
error
=
BELLE_SIP_OK
;
belle_sip_list_t
*
list
=
p
->
supported
;
error
=
belle_sip_header_marshal
(
BELLE_SIP_HEADER
(
p
),
buff
,
buff_size
,
offset
);
if
(
error
!=
BELLE_SIP_OK
)
return
error
;
for
(;
list
!=
NULL
;
list
=
list
->
next
){
error
=
belle_sip_snprintf
(
buff
,
buff_size
,
offset
,
list
==
p
->
supported
?
"%s"
:
", %s"
,(
const
char
*
)
list
->
data
);
if
(
error
!=
BELLE_SIP_OK
)
return
error
;
}
return
error
;
}
BELLE_SIP_NEW_HEADER
(
header_supported
,
header
,
BELLE_SIP_SUPPORTED
)
BELLE_SIP_PARSE
(
header_supported
)
belle_sip_list_t
*
belle_sip_header_supported_get_supported
(
const
belle_sip_header_supported_t
*
p
)
{
return
p
->
supported
;
}
SET_ADD_STRING_LIST
(
belle_sip_header_supported
,
supported
)
belle_sip_header_supported_t
*
belle_sip_header_supported_create
(
const
char
*
supported
)
{
belle_sip_header_supported_t
*
supported_header
=
belle_sip_header_supported_new
();
belle_sip_header_supported_add_supported
(
supported_header
,
supported
);
return
supported_header
;
}
src/belle_sip_internal.h
View file @
01f7b920
...
...
@@ -205,6 +205,7 @@ BELLE_SIP_DECLARE_VPTR(belle_http_callbacks_t);
BELLE_SIP_DECLARE_VPTR
(
belle_tls_verify_policy_t
);
BELLE_SIP_DECLARE_VPTR
(
belle_http_header_authorization_t
);
BELLE_SIP_DECLARE_VPTR
(
belle_sip_header_event_t
);
BELLE_SIP_DECLARE_VPTR
(
belle_sip_header_supported_t
);
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN
(
belle_sip_resolver_context_t
,
belle_sip_source_t
)
void
(
*
cancel
)(
belle_sip_resolver_context_t
*
);
...
...
src/grammars/belle_sip_message.g
View file @
01f7b920
...
...
@@ -1405,6 +1405,22 @@ catch [ANTLR3_RECOGNITION_EXCEPTION]
}
privacy_val: token {belle_sip_header_privacy_add_privacy($header_privacy::current,(const char*)$token.text->chars);};
//**********************************Supported*******************************//
header_supported returns [belle_sip_header_supported_t* ret]
scope { belle_sip_header_supported_t* current; }
@init { $header_supported::current = belle_sip_header_supported_new();$ret = $header_supported::current;}
: {IS_TOKEN(Supported)}? token /*'Supported'*/ hcolon supported_val (comma supported_val)*;
catch [ANTLR3_RECOGNITION_EXCEPTION]
{
belle_sip_message("[\%s] reason [\%s]",(const char*)EXCEPTION->name,(const char*)EXCEPTION->message);
belle_sip_object_unref($ret);
$ret=NULL;
}
supported_val: token {belle_sip_header_supported_add_supported($header_supported::current,(const char*)$token.text->chars);};
header returns [belle_sip_header_t* ret=NULL]
: header_extension_base[FALSE] {$ret=$header_extension_base.ret;};
...
...
tester/belle_sip_headers_tester.c
View file @
01f7b920
...
...
@@ -1010,6 +1010,39 @@ static void test_event_header(void) {
BC_ASSERT_PTR_NULL
(
belle_sip_header_event_parse
(
"nimportequoi"
));
}
static
void
test_supported
(
const
char
*
raw_header
,
const
char
*
values
[],
size_t
number_values
)
{
belle_sip_list_t
*
list
;
belle_sip_header_supported_t
*
L_tmp
;
belle_sip_header_supported_t
*
L_supported
=
belle_sip_header_supported_parse
(
raw_header
);
char
*
l_raw_header
=
belle_sip_object_to_string
(
BELLE_SIP_OBJECT
(
L_supported
));
size_t
i
=
0
;
belle_sip_object_unref
(
BELLE_SIP_OBJECT
(
L_supported
));
L_tmp
=
belle_sip_header_supported_parse
(
l_raw_header
);
L_supported
=
BELLE_SIP_HEADER_SUPPORTED
(
belle_sip_object_clone
(
BELLE_SIP_OBJECT
(
L_tmp
)));
belle_sip_object_unref
(
BELLE_SIP_OBJECT
(
L_tmp
));
belle_sip_free
(
l_raw_header
);
list
=
belle_sip_header_supported_get_supported
(
L_supported
);
for
(
i
=
0
;
i
<
number_values
;
i
++
){
BC_ASSERT_PTR_NOT_NULL
(
list
);
if
(
list
)
{
BC_ASSERT_STRING_EQUAL
((
const
char
*
)(
list
->
data
),
values
[
i
]);
list
=
list
->
next
;
}
}
belle_sip_object_unref
(
BELLE_SIP_OBJECT
(
L_supported
));
BC_ASSERT_PTR_NULL
(
belle_sip_header_supported_parse
(
"nimportequoi"
));
}
static
void
test_supported_header
(
void
)
{
const
char
*
value1
[]
=
{
"user"
,
"critical"
};
const
char
*
value2
[]
=
{
"id"
};
test_supported
(
"Supported: user, critical"
,
value1
,
2
);
test_supported
(
"Supported: id"
,
value2
,
1
);
}
test_t
headers_tests
[]
=
{
{
"Address"
,
test_address_header
},
{
"Address tel uri"
,
test_address_header_with_tel_uri
},
...
...
@@ -1048,7 +1081,8 @@ test_t headers_tests[] = {
{
"WWW-Authenticate"
,
test_www_authenticate_header
},
{
"Header extension"
,
test_header_extension_1
},
{
"Header extension 2"
,
test_header_extension_2
},
{
"Header event"
,
test_event_header
}
{
"Header event"
,
test_event_header
},
{
"Header Supported"
,
test_supported_header
}
};
...
...
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