Is there a way to generate a random number between min and max currently?
i.e.
$var(rand) = $rand(0, 5) // generates a random int between 0 and 5?
This could be useful for in configuration weighting / load distribution
without a dispatcher module.
Thanks!
Hi !.,
Kamailio websocket state is going into FINWAIT1 without sending FIN message
out when we do service kamailio restart.
I have a Primary and Secondary node configured. When I perform switchover
socket status is going into FINWAIT1 state without sending FIN to the
client hence client status is showing established, This is happening 90+%
of times but does work sometimes.
AT Kamailio:
[root@localhost ~]# netstat -tunelap | grep 41034
tcp 0 1 172.27.45.198:9040 172.27.6.98:41034
FIN_WAIT1 0 0 -
[root@localhost ~]#
AT Nginx (client):
root@meet:~# netstat -tunelap | grep 9040
tcp 0 0 172.27.6.98:41034 172.27.45.198:9040
ESTABLISHED 33 763106 1322/nginx: worker
root@meet:~#
Thanks,
Shahid
Module: kamailio
Branch: 5.5
Commit: 557ac56a6ec6b4ca3d76a57ff8b21c64027791f2
URL: https://github.com/kamailio/kamailio/commit/557ac56a6ec6b4ca3d76a57ff8b21c6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-06-29T14:42:12+02:00
core: str list - added function to insert a block string in list
(cherry picked from commit b92b931c26c199b756fd08e9c80cc9305469fd2b)
---
Modified: src/core/str_list.c
Modified: src/core/str_list.h
---
Diff: https://github.com/kamailio/kamailio/commit/557ac56a6ec6b4ca3d76a57ff8b21c6…
Patch: https://github.com/kamailio/kamailio/commit/557ac56a6ec6b4ca3d76a57ff8b21c6…
---
diff --git a/src/core/str_list.c b/src/core/str_list.c
index f63b4c9151..207cee5bc3 100644
--- a/src/core/str_list.c
+++ b/src/core/str_list.c
@@ -13,13 +13,13 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
- * @file
+ * @file
* @brief Kamailio core :: Simple str type list and helper functions
* @ingroup core
* Module: @ref core
@@ -32,7 +32,7 @@
/**
* @brief Add a new allocated list element to an existing list
- *
+ *
* Add a new allocated list element to an existing list, the allocation is done
* from the private memory pool
* @param s input character
@@ -43,18 +43,45 @@
*/
struct str_list *append_str_list(char *s, int len, struct str_list **last, int *total)
{
- struct str_list *new;
- new = pkg_malloc(sizeof(struct str_list));
- if (!new) {
+ struct str_list *nv;
+ nv = pkg_malloc(sizeof(struct str_list));
+ if (!nv) {
PKG_MEM_ERROR;
return 0;
}
- new->s.s = s;
- new->s.len = len;
- new->next = 0;
+ nv->s.s = s;
+ nv->s.len = len;
+ nv->next = 0;
- (*last)->next = new;
- *last = new;
+ (*last)->next = nv;
+ *last = nv;
*total += len;
- return new;
+ return nv;
+}
+
+/**
+ * @brief Add a new allocated list element with cloned block value to an existing list
+ *
+ * Add a new allocated list element with cloned value in block to an existing list,
+ * the allocation is done from the private memory pool
+ * @param head existing list
+ * @param s input character
+ * @param len length of input character
+ * @return extended list
+ */
+str_list_t *str_list_block_add(str_list_t **head, char *s, int len)
+{
+ str_list_t *nv;
+ nv = pkg_mallocxz(sizeof(str_list_t) + (len+1)*sizeof(char));
+ if (!nv) {
+ PKG_MEM_ERROR;
+ return 0;
+ }
+ nv->s.s = (char*)nv + sizeof(str_list_t);
+ memcpy(nv->s.s, s, len);
+ nv->s.len = len;
+ nv->next = *head;
+ *head = nv;
+
+ return nv;
}
diff --git a/src/core/str_list.h b/src/core/str_list.h
index db3fa12887..1eac2578b0 100644
--- a/src/core/str_list.h
+++ b/src/core/str_list.h
@@ -51,4 +51,16 @@ typedef struct str_list {
*/
struct str_list *append_str_list(char *s, int len, struct str_list **last, int *total);
+/**
+ * @brief Add a new allocated list element with cloned block value to an existing list
+ *
+ * Add a new allocated list element with cloned value in block to an existing list,
+ * the allocation is done from the private memory pool
+ * @param head existing list
+ * @param s input character
+ * @param len length of input character
+ * @return extended list
+ */
+str_list_t *str_list_block_add(str_list_t **head, char *s, int len);
+
#endif
Module: kamailio
Branch: master
Commit: 3a0a9292ec40d25f5246573d4a2a51838819d930
URL: https://github.com/kamailio/kamailio/commit/3a0a9292ec40d25f5246573d4a2a518…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2021-07-07T12:46:15+02:00
modules: readme files regenerated - textopsx ... [skip ci]
---
Modified: src/modules/textopsx/README
---
Diff: https://github.com/kamailio/kamailio/commit/3a0a9292ec40d25f5246573d4a2a518…
Patch: https://github.com/kamailio/kamailio/commit/3a0a9292ec40d25f5246573d4a2a518…
---
diff --git a/src/modules/textopsx/README b/src/modules/textopsx/README
index dbb27653a0..e290fc172f 100644
--- a/src/modules/textopsx/README
+++ b/src/modules/textopsx/README
@@ -34,6 +34,9 @@ Daniel-Constantin Mierla
2.13. include_hf_value(hf, hvalue)
2.14. exclude_hf_value(hf, hvalue)
2.15. hf_value_exists(hf, hvalue)
+ 2.16. hf_iterator_start(iname)
+ 2.17. hf_iterator_end(iname)
+ 2.18. textopsx.f.hf_iterator_next(iname)
3. Selects
@@ -58,7 +61,10 @@ Daniel-Constantin Mierla
1.13. include_hf_value usage
1.14. exclude_hf_value usage
1.15. hf_value_exists usage
- 1.16. @hf_value select usage
+ 1.16. hf_iterator_start usage
+ 1.17. hf_iterator_end usage
+ 1.18. hf_iterator_next usage
+ 1.19. @hf_value select usage
Chapter 1. Admin Guide
@@ -82,6 +88,9 @@ Chapter 1. Admin Guide
2.13. include_hf_value(hf, hvalue)
2.14. exclude_hf_value(hf, hvalue)
2.15. hf_value_exists(hf, hvalue)
+ 2.16. hf_iterator_start(iname)
+ 2.17. hf_iterator_end(iname)
+ 2.18. textopsx.f.hf_iterator_next(iname)
3. Selects
@@ -116,6 +125,9 @@ Chapter 1. Admin Guide
2.13. include_hf_value(hf, hvalue)
2.14. exclude_hf_value(hf, hvalue)
2.15. hf_value_exists(hf, hvalue)
+ 2.16. hf_iterator_start(iname)
+ 2.17. hf_iterator_end(iname)
+ 2.18. textopsx.f.hf_iterator_next(iname)
2.1. msg_apply_changes()
@@ -406,6 +418,58 @@ if (@hf_value_exists.supported.path == "1") {
}
...
+2.16. hf_iterator_start(iname)
+
+ Start an iterator for headers in the current SIP message. The parameter
+ iname is used to identify the iterator. There can be up to 4 iterators
+ at the same time, with different name.
+
+ The parameter can be a dynamic string with variables.
+
+ This function can be used from ANY_ROUTE.
+
+ Example 1.16. hf_iterator_start usage
+...
+hf_iterator_start("i1");
+...
+
+2.17. hf_iterator_end(iname)
+
+ Close the iterator identified by iname parameter. The iname value must
+ be the same used for sht_iterator_start().
+
+ The parameter can be dynamic string with variables.
+
+ This function can be used from ANY_ROUTE.
+
+ Example 1.17. hf_iterator_end usage
+...
+hf_iterator_end("i1");
+...
+
+2.18. textopsx.f.hf_iterator_next(iname)
+
+ Move the iterator to the next header. It must be called also after
+ sht_iterator_start() to get the first header.
+
+ The return code is false when there is no other header in the list.
+
+ The item name and value are accessible via variables: $hfitname(iname)
+ and $hfitbody(iname).
+
+ The parameter can be dynamic string with variables.
+
+ This function can be used from ANY_ROUTE.
+
+ Example 1.18. hf_iterator_next usage
+...
+ hf_iterator_start("i1");
+ while(hf_iterator_next("i1")) {
+ xlog("hdr[$hfitname(i1)] is: $hfitbody(i1)\n");
+ }
+ hf_iterator_end("i1");
+...
+
3. Selects
3.1. @hf_value
@@ -441,7 +505,7 @@ if (@hf_value_exists.supported.path == "1") {
* IDX - Value index, negative value counts from bottom
* PARAM_NAME - name of parameter
- Example 1.16. @hf_value select usage
+ Example 1.19. @hf_value select usage
...
$a = @hf_value.my_header[1].my_param;
xplog("L_ERR", "$sel((a)hf_value.via[-1]), $sel((a)hf_value.from.tag)\n");