Skip to content

Commit

Permalink
dispatcher: add attrs param to rpc 'add' call
Browse files Browse the repository at this point in the history
  • Loading branch information
grumvalski committed May 26, 2020
1 parent e6aefeb commit 2e842e9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/modules/dispatcher/dispatch.c
Expand Up @@ -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]);
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/dispatcher/dispatch.h
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/modules/dispatcher/dispatcher.c
Expand Up @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion src/modules/dispatcher/doc/dispatcher_admin.xml
Expand Up @@ -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>
Expand Down

0 comments on commit 2e842e9

Please sign in to comment.