Module: kamailio Branch: master Commit: 499c3957773cfb7e8e350872832b51b8bdef2c62 URL: https://github.com/kamailio/kamailio/commit/499c3957773cfb7e8e350872832b51b8bdef2c62
Author: Daniel-Constantin Mierla <mico...@gmail.com> Committer: Daniel-Constantin Mierla <mico...@gmail.com> Date: 2024-11-06T09:11:33+01:00 core: dset - function to get/set all sip branches --- Modified: src/core/dset.c Modified: src/core/dset.h --- Diff: https://github.com/kamailio/kamailio/commit/499c3957773cfb7e8e350872832b51b8bdef2c62.diff Patch: https://github.com/kamailio/kamailio/commit/499c3957773cfb7e8e350872832b51b8bdef2c62.patch --- diff --git a/src/core/dset.c b/src/core/dset.c index eb99db3a51f..fbfbd939394 100644 --- a/src/core/dset.c +++ b/src/core/dset.c @@ -132,6 +132,44 @@ branch_t *get_sip_branch(int idx) return 0; } +/** + * + */ +int get_all_sip_branches(branch_t **vbranches, unsigned int *nbranches) +{ + if(nr_branches == 0) { + *vbranches = NULL; + *nbranches = 0; + return 0; + } + + *vbranches = (branch_t *)pkg_malloc(nr_branches * sizeof(branch_t)); + if(*vbranches == NULL) { + PKG_MEM_ERROR; + return -1; + } + memcpy(*vbranches, _ksr_branches, nr_branches * sizeof(branch_t)); + *nbranches = nr_branches; + + return 0; +} + +/** + * + */ +int set_all_sip_branches(branch_t *vbranches, unsigned int nbranches) +{ + if(nbranches == 0) { + nr_branches = 0; + return 0; + } + + memcpy(_ksr_branches, vbranches, nbranches * sizeof(branch_t)); + nr_branches = nbranches; + + return 0; +} + /*! \brief * Drop branch[idx] * @param idx - branch index diff --git a/src/core/dset.h b/src/core/dset.h index 73f4fe49680..b5b8dc34089 100644 --- a/src/core/dset.h +++ b/src/core/dset.h @@ -105,6 +105,9 @@ unsigned int get_nr_branches(void); */ branch_t *get_sip_branch(int idx); +int get_all_sip_branches(branch_t **vbranches, unsigned int *nbranches); +int set_all_sip_branches(branch_t *vbranches, unsigned int nbranches); + /*! \brief * Drop branch[idx] */ _______________________________________________ Kamailio (SER) - Development Mailing List To unsubscribe send an email to sr-dev-le...@lists.kamailio.org