Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from AndreyRybkin/master
usrloc_dmq: add module for usrloc sync via dmq
- Loading branch information
Showing
7 changed files
with
795 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include ../../Makefile.defs | ||
auto_gen= | ||
NAME=usrloc_dmq.so | ||
|
||
DEFS+=-DKAMAILIO_MOD_INTERFACE | ||
|
||
SERLIBPATH=../../lib | ||
SER_LIBS+=$(SERLIBPATH)/srutils/srutils | ||
include ../../Makefile.modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
docs = usrloc_dmq.xml | ||
|
||
docbook_dir = ../../../docbook | ||
include $(docbook_dir)/Makefile.module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding='ISO-8859-1'?> | ||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" | ||
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ | ||
|
||
<!-- Include general documentation entities --> | ||
<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml"> | ||
%docentities; | ||
|
||
]> | ||
|
||
<book xmlns:xi="http://www.w3.org/2001/XInclude"> | ||
<bookinfo> | ||
<title>usrloc_dmq Module</title> | ||
<productname class="trade">&kamailioname;</productname> | ||
<authorgroup> | ||
<author> | ||
<firstname>Andrey</firstname> | ||
<surname>Rybkin</surname> | ||
<affiliation><orgname>bks.tv</orgname></affiliation> | ||
<email>rybkin.a@bks.tv</email> | ||
<address> | ||
<otheraddr> | ||
<ulink></ulink> | ||
</otheraddr> | ||
</address> | ||
</author> | ||
<editor> | ||
<firstname>Andrey</firstname> | ||
<surname>Rybkin</surname> | ||
<affiliation><orgname>bks.tv</orgname></affiliation> | ||
<email>rybkin.a@bks.tv</email> | ||
<address> | ||
<otheraddr> | ||
<ulink></ulink> | ||
</otheraddr> | ||
</address> | ||
</editor> | ||
</authorgroup> | ||
<copyright> | ||
<year>2014</year> | ||
</copyright> | ||
</bookinfo> | ||
<toc></toc> | ||
|
||
<xi:include href="usrloc_dmq_admin.xml"/> | ||
|
||
|
||
</book> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding='ISO-8859-1'?> | ||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" | ||
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ | ||
|
||
<!-- Include general documentation entities --> | ||
<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml"> | ||
%docentities; | ||
|
||
]> | ||
<!-- Module User's Guide --> | ||
|
||
<chapter> | ||
|
||
<title>&adminguide;</title> | ||
|
||
<section> | ||
<title>Overview</title> | ||
<para> | ||
The module add usrloc contacts replication between multiple servers via DMQ module. | ||
</para> | ||
</section> | ||
<section> | ||
<title>Dependencies</title> | ||
<section> | ||
<title>&kamailio; Modules</title> | ||
<para> | ||
The following modules must be loaded before this module: | ||
<itemizedlist> | ||
<listitem> | ||
<para> | ||
<emphasis>DMQ module must be loaded first.</emphasis>. | ||
<emphasis>USRLOC module must be loaded first.</emphasis>. | ||
</para> | ||
</listitem> | ||
</itemizedlist> | ||
</para> | ||
</section> | ||
<section> | ||
<title>Parameters</title> | ||
<section id="usrloc_dmq.p.enable"> | ||
<title><varname>enable</varname> (int)</title> | ||
<para> | ||
USRLOC replication | ||
0 - disabled | ||
1 - enabled | ||
</para> | ||
<emphasis> | ||
Default value is 0. | ||
</emphasis> | ||
</para> | ||
</section> | ||
<section id="usrloc_dmq.p.flag"> | ||
<title><varname>flag</varname> (int)</title> | ||
<para> | ||
Flag to be used for marking if a contact should be constructed for the DMQ | ||
</para> | ||
<para> | ||
<emphasis> | ||
Default value is 2. | ||
</emphasis> | ||
</para> | ||
<example> | ||
<title>Set <varname>flag</varname> parameter</title> | ||
<programlisting format="linespecific"> | ||
... | ||
modparam("usrloc_dmq", "flag", 2) | ||
... | ||
</programlisting> | ||
</example> | ||
</section> | ||
</section> | ||
|
||
</chapter> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#include <stdio.h> | ||
#include "../../sr_module.h" | ||
#include "../../dprint.h" | ||
#include "../../error.h" | ||
#include "../../modules/usrloc/usrloc.h" | ||
#include "../usrloc/ul_callback.h" | ||
#include "../../modules/sl/sl.h" | ||
#include "../../mod_fix.h" | ||
|
||
#include "usrloc_sync.h" | ||
|
||
static int mod_init(void); | ||
static int child_init(int); | ||
|
||
int enable_usrloc = 0; | ||
int usrloc_syncflag = 2; | ||
|
||
MODULE_VERSION | ||
|
||
static param_export_t params[] = { | ||
{"enable", INT_PARAM, &enable_usrloc}, | ||
{"flag", INT_PARAM, &usrloc_syncflag}, | ||
{0, 0, 0} | ||
}; | ||
|
||
struct module_exports exports = { | ||
"usrloc_dmq", /* module name */ | ||
DEFAULT_DLFLAGS, /* dlopen flags */ | ||
0, /* exported functions */ | ||
params, /* exported parameters */ | ||
0, /* exported statistics */ | ||
0, /* exported MI functions */ | ||
0, /* exported pseudo-variables */ | ||
0, /* extra processes */ | ||
mod_init, /* module initialization function */ | ||
0, /* response handling function */ | ||
0, /* destroy function */ | ||
child_init /* per-child init function */ | ||
}; | ||
|
||
|
||
static int mod_init(void) | ||
{ | ||
LM_ERR("dmq_sync loaded: usrloc=%d\n", enable_usrloc); | ||
|
||
if (enable_usrloc) { | ||
usrloc_dmq_flag = 1 << usrloc_syncflag; | ||
bind_usrloc_t bind_usrloc; | ||
|
||
bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); | ||
if (!bind_usrloc) { | ||
LM_ERR("can't bind usrloc\n"); | ||
return -1; | ||
} | ||
if (bind_usrloc(&ul) < 0) { | ||
LM_ERR("Can't bind ul\n"); | ||
return -1; | ||
} | ||
if(ul.register_ulcb != NULL) { | ||
if(ul.register_ulcb(ULCB_MAX, ul_cb_contact, 0)< 0) | ||
{ | ||
LM_ERR("can not register callback for expired contacts\n"); | ||
return -1; | ||
} | ||
} | ||
if (!usrloc_dmq_initialize()){ | ||
LM_DBG("usrloc_dmq initialized\n"); | ||
} else { | ||
LM_ERR("Error in usrloc_dmq_initialize()\n"); | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
static int child_init(int rank) | ||
{ | ||
|
||
if (rank == PROC_MAIN) { | ||
LM_ERR("child_init PROC_MAIN\n"); | ||
return 0; | ||
} | ||
if(rank == PROC_INIT || rank == PROC_TCP_MAIN) { | ||
LM_ERR("child_init PROC_INIT\n"); | ||
return 0; | ||
} | ||
return 0; | ||
} |
Oops, something went wrong.