jerome.marchet@orange-ftgroup.com wrote:
Hi all,
I use Kamailio 3.0.0 currently, but I have a problem with the topoh module.
Indeed, I want to create an exported function called « topoh_required »( so, to be used in the config file) for this module, I read and execute the instruction of the devel guide to do this:
in topoh_mod.c, I add or modify:
int th_param_mask = 0;
...
static cmd_export_t cmds[] = {
{"topoh_required", (cmd_function)m_topoh, 1, fixup_uint_null , REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
{0, 0, 0, 0, 0}
};
...
struct module_exports exports= {
"topoh",
DEFAULT_DLFLAGS, /* dlopen flags */
*cmds, /*added*/*
params,
0, /* exported statistics */
0, /* exported MI functions */
0, /* exported pseudo-variables */
0, /* extra processes */
mod_init, /* module initialization function */
0,
0,
0 /* per-child init function */
};
...
static int m_topoh(struct sip_msg *msg, char *value)
{
unsigned int temp = (unsigned int) value;
if(temp==1)
{
th_param_mask=1;
return 1;
}
else if (temp==0)
{
th_param_mask=0;
return 0;
}
else return -1;
}
I do make module and make ... no problem,
Hello Jerome
Have you installed your module? Can you double check that the module loaded from the config is the same as your patched one? You can also use full paths to load module, so I suggest to do a
loadmodule "/home/path/to/kamailio/modules/topoh/topoh.so"
Also check if the m_topoh function is compiled by looking at the symbol table in the topoh.so file
nm -a topoh.so | grep m_topoh should work just fine.
As I look thru your code, I can't see any possible errors. I will look more closely if with these suggestions don't work
Cheers Marius
but when I start Kamailio with the function topoh_required(« 1 »); in the config file, it says:
Not starting kamailio: invalid configuration file!
0(19524) : <core> [cfg.y:3329]: parse error in config file /usr/local/etc/kamailio/kamailio.cfg, line 328, column 20: unknown command, missing loadmodule?
ERROR: bad config file (1 errors)
So It doesn't know the topoh_required function. But I don't know how to solve this problem.
Can somebody help me please? Thank you very much for your help.
Jérôme
jerome.marchet@orange-ftgroup.com wrote:
Thank you Marius,
I do loadmodule "/home/path/to/kamailio/modules/topoh/topoh.so"
and now I have another problem, When it starts, Kamailio says :
Not starting kamailio: invalid configuration file!
0(19622) : <core> [cfg.y:3329]: parse error in config file /usr/local/etc/kamailio/kamailio.cfg, line 328, column 19: Command cannot be used in the block
ERROR: bad config file (1 errors)
Hello, In what block are you using the function ? As I check the module exports you kind of have everything there . Can you provide a snippet of your cfg that shows how the function is used along with the block information (failure_route, reply_route)
I search on google and i find this:
http://www.mail-archive.com/users@lists.kamailio.org/msg07610.html
Is it the same problem for topoh as in this mail with tm ?
Not quite. The tm "problem" is a design decision that somehow manifests the same why as your problem
I suggest that you add the cmd with this line
{"topoh_required", (cmd_function)m_topoh, 1, fixup_uint_null , ANY_ROUTE}
so you can call the function from any cfg block(it your resposability to ensure that it makes sense to do it so)
thank you
You're welcome Marius
Jérôme
ps: I check if the m_topoh function is compiled by looking at the symbol table in the topoh.so file
nm -a topoh.so | grep m_topoh 00008c70 t m_topoh
jerome.marchet@orange-ftgroup.com wrote:
Hi all,
I use Kamailio 3.0.0 currently, but I have a problem with the topoh module.
Indeed, I want to create an exported function called « topoh_required »( so, to be used in the config file) for this module, I read and execute the instruction of the devel guide to do this:
in topoh_mod.c, I add or modify:
int th_param_mask = 0;
...
static cmd_export_t cmds[] = {
{"topoh_required", (cmd_function)m_topoh, 1, fixup_uint_null , REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
{0, 0, 0, 0, 0}
};
Hello Jerome,
It seems the prototype is wrong in the devel guide.
The cmd_export_t should have 6 members instead of 5. It works with
static cmd_export_t cmds[] = {
{"topoh_required", (cmd_function)m_topoh, 1, fixup_uint_null , 0, REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
{0, 0, 0, 0, 0, 0}
};
Can you give me the exact URL of the docs so I can also update them?
Thanks Marius
On Jun 14, 2010 at 17:07, marius zbihlei marius.zbihlei@1and1.ro wrote:
jerome.marchet@orange-ftgroup.com wrote:
Hi all,
I use Kamailio 3.0.0 currently, but I have a problem with the topoh module.
Indeed, I want to create an exported function called « topoh_required »( so, to be used in the config file) for this module, I read and execute the instruction of the devel guide to do this:
in topoh_mod.c, I add or modify:
int th_param_mask = 0;
...
static cmd_export_t cmds[] = {
{"topoh_required", (cmd_function)m_topoh, 1, fixup_uint_null , REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
{0, 0, 0, 0, 0}
};
Hello Jerome,
It seems the prototype is wrong in the devel guide.
The cmd_export_t should have 6 members instead of 5. It works with
static cmd_export_t cmds[] = {
{"topoh_required", (cmd_function)m_topoh, 1, fixup_uint_null , 0, REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
{0, 0, 0, 0, 0, 0}
};
Can you give me the exact URL of the docs so I can also update them?
Actually it depends on which module interface one uses. The ser modules interface uses 5 parameters, while the kamailio one 6 (kamailio has an extra free_fixup). To find out what version a module uses: grep MOD_INTERFACE modules*/mod_name/Makefile .
Andrei