Module: kamailio Branch: master Commit: 9115bcdabaa3da04e3e563bb43a04358b33e2c17 URL: https://github.com/kamailio/kamailio/commit/9115bcdabaa3da04e3e563bb43a04358...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2019-08-16T11:05:35+02:00
core: dset - function to push a new branch and return its pointer
---
Modified: src/core/dset.c Modified: src/core/dset.h
---
Diff: https://github.com/kamailio/kamailio/commit/9115bcdabaa3da04e3e563bb43a04358... Patch: https://github.com/kamailio/kamailio/commit/9115bcdabaa3da04e3e563bb43a04358...
---
diff --git a/src/core/dset.c b/src/core/dset.c index 1803155206..184ddc9e92 100644 --- a/src/core/dset.c +++ b/src/core/dset.c @@ -328,7 +328,7 @@ void clear_branches(void)
-/** Add a new branch to the current transaction. +/** Add a new branch to the current destination set. * @param msg sip message, used for getting the uri if not specified (0). * @param uri uri, can be 0 (in which case the uri is taken from msg) * @param dst_uri destination uri, can be 0. @@ -352,7 +352,7 @@ int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path, str luri;
/* if we have already set up the maximum number - * of branches, don't try new ones + * of branches, don't try new ones */ if (unlikely(nr_branches == sr_dst_max_branches - 1)) { LM_ERR("max nr of branches exceeded\n"); @@ -466,12 +466,40 @@ int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path, branches[nr_branches].location_ua[0] = '\0'; branches[nr_branches].location_ua_len = 0; } - + nr_branches++; return 1; }
+/** Push a new branch to the current destination set. + * @param msg sip message, used for getting the uri if not specified (0). + * @param uri uri, can be 0 (in which case the uri is taken from msg) + * @param dst_uri destination uri, can be 0. + * @param path path vector (passed in a string), can be 0. + * @param q q value. + * @param flags per branch flags. + * @param force_socket socket that should be used when sending. + * @param instance sip instance contact header param value + * @param reg_id reg-id contact header param value + * @param ruid ruid value from usrloc + * @param location_ua location user agent + * + * @return NULL on failure, new branch pointer on success. + */ +branch_t* ksr_push_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path, + qvalue_t q, unsigned int flags, + struct socket_info* force_socket, + str* instance, unsigned int reg_id, + str* ruid, str* location_ua) +{ + if(append_branch(msg, uri, dst_uri, path, q, flags, force_socket, + instance, reg_id, ruid, location_ua)<0) { + return NULL; + } + return &branches[nr_branches-1]; +} + /*! \brief * Combines the given elements into a Contact header field * dest = target buffer, will be updated to new position after the printed contact diff --git a/src/core/dset.h b/src/core/dset.h index 96f31978a6..ebb4e765bb 100644 --- a/src/core/dset.h +++ b/src/core/dset.h @@ -94,7 +94,16 @@ branch_t *get_sip_branch(int idx); int drop_sip_branch(int idx);
/*! \brief - * Add a new branch to current transaction + * Push a new branch to current destination set + */ +branch_t *ksr_push_branch(sip_msg_t* msg, str* uri, str* dst_uri, str* path, + qvalue_t q, unsigned int flags, + struct socket_info* force_socket, + str* instance, unsigned int reg_id, + str* ruid, str* location_ua); + +/*! \brief + * Add a new branch to current destination set */ int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path, qvalue_t q, unsigned int flags,