Skip to content

Commit

Permalink
Merge pull request #1485 from vasilevalex/drouting_sock
Browse files Browse the repository at this point in the history
Drouting module probing socket parameter
  • Loading branch information
bogdan-iancu committed Oct 9, 2018
1 parent fcbfed3 commit 94a3ede
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
29 changes: 29 additions & 0 deletions modules/drouting/doc/drouting_admin.xml
Expand Up @@ -912,6 +912,35 @@ modparam("drouting", "probing_reply_codes", "501, 403")
</example>
</section>

<section id="param_probing_socket" xreflabel="probing_socket">
<title><varname>probing_socket</varname> (string)</title>
<para>
A socket description [proto:]host[:port] of the local socket
(which is used by OpenSIPS for SIP traffic) to be used
(if multiple) for sending the probing messages from.
</para>
<para>
For probing gateway the highest priority has socket from gateway
configuration in dr_gateways table. Then socket from global
<varname>probing_socket</varname> parameter and the lowest
priority is default behaviour with auto selected socket wich
OpenSIPS listens on.
</para>
<para>
<emphasis>
Default value is <quote>NULL</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>probing_socket</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("drouting", "probing_socket", "udp:192.168.1.100:5060")
...
</programlisting>
</example>
</section>

<section id="param_status_replication_cluster" xreflabel="status_replication_cluster">
<title><varname>status_replication_cluster</varname> (integer)</title>
<para>
Expand Down
25 changes: 24 additions & 1 deletion modules/drouting/drouting.c
Expand Up @@ -78,6 +78,8 @@ static str dr_probe_replies = {NULL,0};
struct tm_binds dr_tmb;
str dr_probe_method = str_init("OPTIONS");
str dr_probe_from = str_init("sip:prober@localhost");
static char *dr_probe_sock_s = NULL;
struct socket_info *dr_probe_sock = NULL;
static int* probing_reply_codes = NULL;
static int probing_codes_no = 0;

Expand Down Expand Up @@ -413,6 +415,7 @@ static param_export_t params[] = {
{"probing_interval", INT_PARAM, &dr_prob_interval },
{"probing_method", STR_PARAM, &dr_probe_method.s },
{"probing_from", STR_PARAM, &dr_probe_from.s },
{"probing_socket", STR_PARAM, &dr_probe_sock_s },
{"probing_reply_codes",STR_PARAM, &dr_probe_replies.s },
{"persistent_state", INT_PARAM, &dr_persistent_state },
{"no_concurrent_reload",INT_PARAM, &no_concurrent_reload },
Expand Down Expand Up @@ -743,7 +746,7 @@ static void dr_prob_handler(unsigned int ticks, void* param)
/* Execute the Dialog using the "request"-Method of the
* TM-Module.*/
if (dr_tmb.new_auto_dlg_uac(&dr_probe_from, &uri, NULL, NULL,
dst->sock, &dlg)!=0) {
dst->sock?dst->sock:dr_probe_sock, &dlg)!=0) {
LM_ERR("failed to create new TM dlg\n");
continue;
}
Expand Down Expand Up @@ -1636,12 +1639,32 @@ static int dr_init(void)
head_end = 0;

if (dr_prob_interval) {

str host;
int port,proto;

/* load TM API */
if (load_tm_api(&dr_tmb)!=0) {
LM_ERR("can't load TM API\n");
return -1;
}

/* parse and look for the socket to ping from */
if (dr_probe_sock_s && dr_probe_sock_s[0]!=0 ) {
if (parse_phostport( dr_probe_sock_s, strlen(dr_probe_sock_s),
&host.s, &host.len, &port, &proto)!=0 ) {
LM_ERR("socket description <%s> is not valid\n",
dr_probe_sock_s);
return -1;
}
dr_probe_sock = grep_sock_info( &host, port, proto);
if (dr_probe_sock==NULL) {
LM_ERR("socket <%s> is not local to opensips (we must listen "
"on it\n", dr_probe_sock_s);
return -1;
}
}

/* probing method */
dr_probe_method.len = strlen(dr_probe_method.s);
dr_probe_from.len = strlen(dr_probe_from.s);
Expand Down

0 comments on commit 94a3ede

Please sign in to comment.