Skip to content

Commit

Permalink
dmq: add optional parameter to dmq_handle_message()
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Schmidbauer committed Aug 31, 2018
1 parent 7f848ef commit bce0890
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/modules/dmq/dmq.c
Expand Up @@ -91,6 +91,8 @@ static void destroy(void);
static cmd_export_t cmds[] = {
{"dmq_handle_message", (cmd_function)dmq_handle_message, 0,
0, 0, REQUEST_ROUTE},
{"dmq_handle_message", (cmd_function)w_dmq_handle_message, 1,
fixup_int_1, 0, REQUEST_ROUTE},
{"dmq_send_message", (cmd_function)cfg_dmq_send_message, 4,
fixup_spve_all, 0, ANY_ROUTE},
{"dmq_bcast_message", (cmd_function)cfg_dmq_bcast_message, 3,
Expand Down Expand Up @@ -412,4 +414,4 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2)
{
sr_kemi_modules_add(sr_kemi_dmq_exports);
return 0;
}
}
12 changes: 11 additions & 1 deletion src/modules/dmq/doc/dmq_admin.xml
Expand Up @@ -219,12 +219,22 @@ modparam("dmq", "ping_interval", 90)
<title>Functions</title>
<section id="dmq.f.dmq_handle_message">
<title>
<function moreinfo="none">dmq_handle_message()</function>
<function moreinfo="none">dmq_handle_message([continue])</function>
</title>
<para>
Handles a DMQ message by passing it to the appropriate local peer (module).
The peer is identified by the user part of the To header.
</para>
<para>Meaning of parameters:</para>
<itemizedlist>
<listitem>
<para>
<emphasis>continue</emphasis> - by default, dmq_handle_message() will end
execution of routing script. If this optional parameter is set to "1", dmq_handle_message()
will continue executing the routing script after it's been called.
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE.
</para>
Expand Down
20 changes: 15 additions & 5 deletions src/modules/dmq/message.c
Expand Up @@ -40,7 +40,7 @@ str dmq_404_rpl = str_init("User Not Found");
/**
* @brief config function to handle dmq messages
*/
int ki_dmq_handle_message(sip_msg_t *msg)
int ki_dmq_handle_message(sip_msg_t *msg, int returnval)
{
dmq_peer_t *peer;
if((parse_sip_msg_uri(msg) < 0) || (!msg->parsed_uri.user.s)) {
Expand All @@ -60,20 +60,30 @@ int ki_dmq_handle_message(sip_msg_t *msg)
LM_ERR("sending reply\n");
goto error;
}
return 0;
return returnval;
}
LM_DBG("dmq_handle_message peer found: %.*s\n", msg->parsed_uri.user.len,
msg->parsed_uri.user.s);
if(add_dmq_job(msg, peer) < 0) {
LM_ERR("failed to add dmq job\n");
goto error;
}
return 0;
return returnval;
error:
return -1;
}

int w_dmq_handle_message(struct sip_msg *msg, char *str1, char *str2)
{
int i = 0;
if(str1) {
if(get_int_fparam(&i, msg, (fparam_t*)str1)<0) return -1;
}
if(i>1) i = 1;
return ki_dmq_handle_message(msg, i);
}

int dmq_handle_message(struct sip_msg *msg, char *str1, char *str2)
{
return ki_dmq_handle_message(msg);
}
return ki_dmq_handle_message(msg, 0);
}
3 changes: 2 additions & 1 deletion src/modules/dmq/message.h
Expand Up @@ -24,7 +24,8 @@
#ifndef _MESSAGE_H_
#define _MESSAGE_H_

int w_dmq_handle_message(struct sip_msg *, char *str1, char *str2);
int dmq_handle_message(struct sip_msg *, char *str1, char *str2);
int ki_dmq_handle_message(sip_msg_t *msg);
int ki_dmq_handle_message(sip_msg_t *msg, int returnval);

#endif

1 comment on commit bce0890

@eschmidbauer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miconda any chance this can get tagged for next release?

Please sign in to comment.