Module: kamailio
Branch: master
Commit: a8d3274c32ba7d7cfb93d0f6d4090a7832db7ff7
URL:
https://github.com/kamailio/kamailio/commit/a8d3274c32ba7d7cfb93d0f6d4090a7…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-08-19T11:37:40+02:00
core: dset - function to link branch data in a structure
- existing functions to retrive branch attributes have too many parameters already
---
Modified: src/core/dset.c
Modified: src/core/dset.h
---
Diff:
https://github.com/kamailio/kamailio/commit/a8d3274c32ba7d7cfb93d0f6d4090a7…
Patch:
https://github.com/kamailio/kamailio/commit/a8d3274c32ba7d7cfb93d0f6d4090a7…
---
diff --git a/src/core/dset.c b/src/core/dset.c
index 184ddc9e92..f1b79ba037 100644
--- a/src/core/dset.c
+++ b/src/core/dset.c
@@ -232,9 +232,9 @@ void set_branch_iterator(int n)
* more branches
*/
char* get_branch(unsigned int i, int* len, qvalue_t* q, str* dst_uri,
- str* path, unsigned int *flags,
- struct socket_info** force_socket,
- str *ruid, str *instance, str *location_ua)
+ str* path, unsigned int *flags,
+ struct socket_info** force_socket,
+ str *ruid, str *instance, str *location_ua)
{
if (i < nr_branches) {
*len = branches[i].len;
@@ -302,18 +302,69 @@ char* get_branch(unsigned int i, int* len, qvalue_t* q, str*
dst_uri,
* 0 is returned if there are no more branches
*/
char* next_branch(int* len, qvalue_t* q, str* dst_uri, str* path,
- unsigned int* flags, struct socket_info** force_socket,
- str* ruid, str *instance, str *location_ua)
+ unsigned int* flags, struct socket_info** force_socket,
+ str* ruid, str *instance, str *location_ua)
{
char* ret;
-
+
ret=get_branch(branch_iterator, len, q, dst_uri, path, flags,
- force_socket, ruid, instance, location_ua);
+ force_socket, ruid, instance, location_ua);
if (likely(ret))
branch_iterator++;
return ret;
}
+int get_branch_data(unsigned int i, branch_data_t *vbranch)
+{
+ if(vbranch==NULL) {
+ return -1;
+ }
+ memset(vbranch, 0, sizeof(branch_data_t));
+
+ if (i < nr_branches) {
+ vbranch->uri.s = branches[i].uri;
+ vbranch->uri.len = branches[i].len;
+ vbranch->q = branches[i].q;
+ if (branches[i].dst_uri_len > 0) {
+ vbranch->dst_uri.len = branches[i].dst_uri_len;
+ vbranch->dst_uri.s = branches[i].dst_uri;
+ }
+ if (branches[i].path_len > 0) {
+ vbranch->path.len = branches[i].path_len;
+ vbranch->path.s = branches[i].path;
+ }
+ vbranch->force_socket = branches[i].force_send_socket;
+ vbranch->flags = branches[i].flags;
+ if (branches[i].ruid_len > 0) {
+ vbranch->ruid.len = branches[i].ruid_len;
+ vbranch->ruid.s = branches[i].ruid;
+ }
+ if (branches[i].instance_len > 0) {
+ vbranch->instance.len = branches[i].instance_len;
+ vbranch->instance.s =branches[i].instance;
+ }
+ if (branches[i].location_ua_len > 0) {
+ vbranch->location_ua.len = branches[i].location_ua_len;
+ vbranch->location_ua.s = branches[i].location_ua;
+ }
+ vbranch->otcpid = branches[i].otcpid;
+ } else {
+ vbranch->q = Q_UNSPECIFIED;
+ }
+
+ return 0;
+}
+
+int next_branch_data(branch_data_t *vbranch)
+{
+ int ret;
+ ret= get_branch_data(branch_iterator, vbranch);
+ if (ret < 0) {
+ return ret;
+ }
+ branch_iterator++;
+ return ret;
+}
/*
* Empty the dset array
diff --git a/src/core/dset.h b/src/core/dset.h
index ebb4e765bb..9a640da704 100644
--- a/src/core/dset.h
+++ b/src/core/dset.h
@@ -43,7 +43,7 @@ extern int ruri_is_new;
/*! \brief
* Structure for storing branch attributes
*/
-struct branch
+typedef struct branch
{
char uri[MAX_URI_SIZE];
unsigned int len;
@@ -79,9 +79,20 @@ struct branch
/* Branch flags */
flag_t flags;
-};
-
-typedef struct branch branch_t;
+} branch_t;
+
+typedef struct branch_data {
+ str uri;
+ str dst_uri;
+ qvalue_t q;
+ str path;
+ unsigned int flags;
+ socket_info_t* force_socket;
+ str ruid;
+ str instance;
+ str location_ua;
+ int otcpid;
+} branch_data_t;
/*! \brief
* Return pointer to branch[idx] structure
@@ -163,6 +174,9 @@ char* get_branch( unsigned int i, int* len, qvalue_t* q, str*
dst_uri,
struct socket_info** force_socket,
str* ruid, str *instance, str *location_ua);
+int get_branch_data(unsigned int i, branch_data_t *vbranch);
+int next_branch_data(branch_data_t *vbranch);
+
/*! \brief
* Empty the array of branches
*/