Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
64c03d4d
Commit
64c03d4d
authored
9 years ago
by
zuul
Committed by
Gerrit Code Review
9 years ago
Browse files
Options
Downloads
Plain Diff
Merge "config_transport: Fix objects returned by ast_sip_get_transport_states"
parents
afef0dc0
7b71bca8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
res/res_pjsip/config_transport.c
+75
-2
75 additions, 2 deletions
res/res_pjsip/config_transport.c
with
75 additions
and
2 deletions
res/res_pjsip/config_transport.c
+
75
−
2
View file @
64c03d4d
...
@@ -108,6 +108,56 @@ static int internal_state_cmp(void *obj, void *arg, int flags)
...
@@ -108,6 +108,56 @@ static int internal_state_cmp(void *obj, void *arg, int flags)
return
CMP_MATCH
;
return
CMP_MATCH
;
}
}
/*! \brief hashing function for state objects */
static
int
transport_state_hash
(
const
void
*
obj
,
const
int
flags
)
{
const
struct
ast_sip_transport_state
*
object
;
const
char
*
key
;
switch
(
flags
&
OBJ_SEARCH_MASK
)
{
case
OBJ_SEARCH_KEY
:
key
=
obj
;
break
;
case
OBJ_SEARCH_OBJECT
:
object
=
obj
;
key
=
object
->
id
;
break
;
default:
ast_assert
(
0
);
return
0
;
}
return
ast_str_hash
(
key
);
}
/*! \brief comparator function for state objects */
static
int
transport_state_cmp
(
void
*
obj
,
void
*
arg
,
int
flags
)
{
const
struct
ast_sip_transport_state
*
object_left
=
obj
;
const
struct
ast_sip_transport_state
*
object_right
=
arg
;
const
char
*
right_key
=
arg
;
int
cmp
;
switch
(
flags
&
OBJ_SEARCH_MASK
)
{
case
OBJ_SEARCH_OBJECT
:
right_key
=
object_right
->
id
;
/* Fall through */
case
OBJ_SEARCH_KEY
:
cmp
=
strcmp
(
object_left
->
id
,
right_key
);
break
;
case
OBJ_SEARCH_PARTIAL_KEY
:
/* Not supported by container. */
ast_assert
(
0
);
return
0
;
default:
cmp
=
0
;
break
;
}
if
(
cmp
)
{
return
0
;
}
return
CMP_MATCH
;
}
static
int
sip_transport_to_ami
(
const
struct
ast_sip_transport
*
transport
,
static
int
sip_transport_to_ami
(
const
struct
ast_sip_transport
*
transport
,
struct
ast_str
**
buf
)
struct
ast_str
**
buf
)
{
{
...
@@ -499,7 +549,6 @@ static int transport_apply(const struct ast_sorcery *sorcery, void *obj)
...
@@ -499,7 +549,6 @@ static int transport_apply(const struct ast_sorcery *sorcery, void *obj)
if
(
res
==
PJ_SUCCESS
&&
(
transport
->
tos
||
transport
->
cos
))
{
if
(
res
==
PJ_SUCCESS
&&
(
transport
->
tos
||
transport
->
cos
))
{
pj_sock_t
sock
;
pj_sock_t
sock
;
pj_qos_params
qos_params
;
pj_qos_params
qos_params
;
sock
=
pjsip_udp_transport_get_socket
(
temp_state
->
state
->
transport
);
sock
=
pjsip_udp_transport_get_socket
(
temp_state
->
state
->
transport
);
pj_sock_get_qos_params
(
sock
,
&
qos_params
);
pj_sock_get_qos_params
(
sock
,
&
qos_params
);
set_qos
(
transport
,
&
qos_params
);
set_qos
(
transport
,
&
qos_params
);
...
@@ -657,6 +706,11 @@ static int privkey_file_to_str(const void *obj, const intptr_t *args, char **buf
...
@@ -657,6 +706,11 @@ static int privkey_file_to_str(const void *obj, const intptr_t *args, char **buf
static
int
transport_protocol_handler
(
const
struct
aco_option
*
opt
,
struct
ast_variable
*
var
,
void
*
obj
)
static
int
transport_protocol_handler
(
const
struct
aco_option
*
opt
,
struct
ast_variable
*
var
,
void
*
obj
)
{
{
struct
ast_sip_transport
*
transport
=
obj
;
struct
ast_sip_transport
*
transport
=
obj
;
RAII_VAR
(
struct
ast_sip_transport_state
*
,
state
,
find_or_create_temporary_state
(
transport
),
ao2_cleanup
);
if
(
!
state
)
{
return
-
1
;
}
if
(
!
strcasecmp
(
var
->
value
,
"udp"
))
{
if
(
!
strcasecmp
(
var
->
value
,
"udp"
))
{
transport
->
type
=
AST_TRANSPORT_UDP
;
transport
->
type
=
AST_TRANSPORT_UDP
;
...
@@ -672,6 +726,8 @@ static int transport_protocol_handler(const struct aco_option *opt, struct ast_v
...
@@ -672,6 +726,8 @@ static int transport_protocol_handler(const struct aco_option *opt, struct ast_v
return
-
1
;
return
-
1
;
}
}
state
->
type
=
transport
->
type
;
return
0
;
return
0
;
}
}
...
@@ -1240,9 +1296,26 @@ struct ast_sip_transport_state *ast_sip_get_transport_state(const char *transpor
...
@@ -1240,9 +1296,26 @@ struct ast_sip_transport_state *ast_sip_get_transport_state(const char *transpor
return
state
->
state
;
return
state
->
state
;
}
}
static
int
populate_transport_states
(
void
*
obj
,
void
*
arg
,
int
flags
)
{
struct
internal_state
*
state
=
obj
;
struct
ao2_container
*
container
=
arg
;
ao2_link
(
container
,
state
->
state
);
return
CMP_MATCH
;
}
struct
ao2_container
*
ast_sip_get_transport_states
(
void
)
struct
ao2_container
*
ast_sip_get_transport_states
(
void
)
{
{
return
ao2_container_clone
(
transport_states
,
0
);
struct
ao2_container
*
states
=
ao2_container_alloc
(
DEFAULT_STATE_BUCKETS
,
transport_state_hash
,
transport_state_cmp
);
if
(
!
states
)
{
return
NULL
;
}
ao2_callback
(
transport_states
,
OBJ_NODATA
|
OBJ_MULTIPLE
,
populate_transport_states
,
states
);
return
states
;
}
}
/*! \brief Initialize sorcery with transport support */
/*! \brief Initialize sorcery with transport support */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment