Module: kamailio
Branch: master
Commit: 2e842e9c11b136270b56b2b48a0364a94749c4ed
URL:
https://github.com/kamailio/kamailio/commit/2e842e9c11b136270b56b2b48a0364a…
Author: Federico Cabiddu <federico.cabiddu(a)gmail.com>
Committer: Federico Cabiddu <federico.cabiddu(a)gmail.com>
Date: 2020-05-26T10:24:58+02:00
dispatcher: add attrs param to rpc 'add' call
---
Modified: src/modules/dispatcher/dispatch.c
Modified: src/modules/dispatcher/dispatch.h
Modified: src/modules/dispatcher/dispatcher.c
Modified: src/modules/dispatcher/doc/dispatcher_admin.xml
---
Diff:
https://github.com/kamailio/kamailio/commit/2e842e9c11b136270b56b2b48a0364a…
Patch:
https://github.com/kamailio/kamailio/commit/2e842e9c11b136270b56b2b48a0364a…
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index b5d56d405a..8cff6cdb56 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -2419,15 +2419,16 @@ void ds_add_dest_cb(ds_set_t *node, int i, void *arg)
}
/* add dispatcher entry to in-memory dispatcher list */
-int ds_add_dst(int group, str *address, int flags)
+int ds_add_dst(int group, str *address, int flags, str *attrs)
{
int setn, priority;
- str attrs;
setn = _ds_list_nr;
priority = 0;
- attrs.s = 0;
- attrs.len = 0;
+
+ if (attrs->len == 0) {
+ attrs->s = 0;
+ }
*next_idx = (*crt_idx + 1) % 2;
ds_avl_destroy(&ds_lists[*next_idx]);
@@ -2436,7 +2437,7 @@ int ds_add_dst(int group, str *address, int flags)
ds_iter_set(_ds_list, &ds_add_dest_cb, NULL);
// add new destination
- if(add_dest2list(group, *address, flags, priority, &attrs,
+ if(add_dest2list(group, *address, flags, priority, attrs,
*next_idx, &setn) != 0) {
LM_WARN("unable to add destination %.*s to set %d", address->len,
address->s, group);
if(ds_load_mode==1) {
diff --git a/src/modules/dispatcher/dispatch.h b/src/modules/dispatcher/dispatch.h
index ee4ea0b760..2bd63dc64b 100644
--- a/src/modules/dispatcher/dispatch.h
+++ b/src/modules/dispatcher/dispatch.h
@@ -140,7 +140,7 @@ int ds_select_dst_limit(sip_msg_t *msg, int set, int alg, uint32_t
limit,
int mode);
int ds_select_dst(struct sip_msg *msg, int set, int alg, int mode);
int ds_update_dst(struct sip_msg *msg, int upos, int mode);
-int ds_add_dst(int group, str *address, int flags);
+int ds_add_dst(int group, str *address, int flags, str *attrs);
int ds_remove_dst(int group, str *address);
int ds_update_state(sip_msg_t *msg, int group, str *address, int state,
ds_rctx_t *rctx);
diff --git a/src/modules/dispatcher/dispatcher.c b/src/modules/dispatcher/dispatcher.c
index 2a566ab730..b2693a2947 100644
--- a/src/modules/dispatcher/dispatcher.c
+++ b/src/modules/dispatcher/dispatcher.c
@@ -1800,15 +1800,16 @@ static void dispatcher_rpc_add(rpc_t *rpc, void *ctx)
{
int group, flags;
str dest;
+ str attrs;
flags = 0;
- if(rpc->scan(ctx, "dS*d", &group, &dest, &flags) < 2) {
+ if(rpc->scan(ctx, "dS*d", &group, &dest, &flags, &attrs)
< 3) {
rpc->fault(ctx, 500, "Invalid Parameters");
return;
}
- if(ds_add_dst(group, &dest, flags) != 0) {
+ if(ds_add_dst(group, &dest, flags, &attrs) != 0) {
rpc->fault(ctx, 500, "Adding dispatcher dst failed");
return;
}
diff --git a/src/modules/dispatcher/doc/dispatcher_admin.xml
b/src/modules/dispatcher/doc/dispatcher_admin.xml
index b872adc156..984b53258d 100644
--- a/src/modules/dispatcher/doc/dispatcher_admin.xml
+++ b/src/modules/dispatcher/doc/dispatcher_admin.xml
@@ -1938,15 +1938,19 @@ DEST: {
<listitem><para>_flags_ (optional): as described in the list file format,
default 0</para></listitem>
+ <listitem><para>_attrs_ (optional): as described in the list file format,
+ default ""</para></listitem>
+
</itemizedlist>
<para>
Example:
</para>
<programlisting format="linespecific">
...
-# prototype: &sercmd; dispatcher.add _group_ _address_ _flags_
+# prototype: &sercmd; dispatcher.add _group_ _address_ _flags_ _attrs_
&sercmd; dispatcher.add 2 sip:127.0.0.1:5080
&sercmd; dispatcher.add 3 sip:127.0.0.1:5075 8
+&sercmd; dispatcher.add 3 sip:127.0.0.1:5075 0 duid=abc;socket=udp:127.0.0.1:5060
...
</programlisting>
</section>