Module: kamailio
Branch: master
Commit: dfbd4e12d6c4b3c9664d58ffbc479de9ea68f03e
URL: https://github.com/kamailio/kamailio/commit/dfbd4e12d6c4b3c9664d58ffbc479de…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-03-24T17:42:26+01:00
lwsc: added inter-module api
- exported lwsc request function to send data to a ws target and proto,
then wait for response data for a specific time interval
---
Added: src/modules/lwsc/api.h
Modified: src/modules/lwsc/lwsc_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/dfbd4e12d6c4b3c9664d58ffbc479de…
Patch: https://github.com/kamailio/kamailio/commit/dfbd4e12d6c4b3c9664d58ffbc479de…
---
diff --git a/src/modules/lwsc/api.h b/src/modules/lwsc/api.h
new file mode 100644
index 0000000000..c76fb8c6b1
--- /dev/null
+++ b/src/modules/lwsc/api.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2021 Daniel-Constantin Mierla (asipto.com)
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * @brief LWSC - API definitions
+ * @ingroup lwsc
+ * Module: @ref lwsc
+ */
+
+#ifndef _LWSC_API_H_
+#define _LWSC_API_H_
+
+#include "../../core/str.h"
+
+typedef int (*lwsc_api_request_f)(str *wsurl, str *wsproto, str *sdata,
+ str *rdata, int rtimeout);
+
+/**
+ * @brief Stateless (sl) API structure
+ */
+typedef struct lwsc_api {
+ lwsc_api_request_f request; /* send and receice data */
+} lwsc_api_t;
+
+typedef int (*bind_lwsc_f)(lwsc_api_t* api);
+
+/**
+ * @brief Load the LWSX API
+ */
+static inline int lwsc_load_api(lwsc_api_t *lwscb)
+{
+ bind_lwsc_f bindlwsc;
+
+ bindlwsc = (bind_lwsc_f)find_export("bind_lwsc", 0, 0);
+ if ( bindlwsc == 0) {
+ LM_ERR("cannot find bind_lwsc exported function\n");
+ return -1;
+ }
+ if (bindlwsc(lwscb)==-1)
+ {
+ LM_ERR("cannot bind lwsc api\n");
+ return -1;
+ }
+ return 0;
+}
+
+#endif
diff --git a/src/modules/lwsc/lwsc_mod.c b/src/modules/lwsc/lwsc_mod.c
index 8e5e068bdd..ada873f215 100644
--- a/src/modules/lwsc/lwsc_mod.c
+++ b/src/modules/lwsc/lwsc_mod.c
@@ -36,12 +36,15 @@
#include "../../core/kemi.h"
#include "../../core/parser/parse_param.h"
+#include "api.h"
+
MODULE_VERSION
static int mod_init(void);
static int child_init(int);
static void mod_destroy(void);
+static int bind_lwsc(lwsc_api_t* api);
static int w_lwsc_request(sip_msg_t* msg, char* pwsurl, char* pdata);
static int w_lwsc_notify(sip_msg_t* msg, char* pwsurl, char* pdata);
@@ -57,6 +60,8 @@ static cmd_export_t cmds[]={
fixup_spve_all, 0, ANY_ROUTE},
{"lwsc_notify", (cmd_function)w_lwsc_notify, 2,
fixup_spve_all, 0, ANY_ROUTE},
+ {"bind_lwsc", (cmd_function)bind_lwsc, 0,
+ 0, 0, 0},
{0, 0, 0, 0, 0, 0}
};
@@ -759,6 +764,20 @@ static int lwsc_pv_parse_name(pv_spec_t *sp, str *in)
return 0;
}
+/**
+ * @brief bind functions to LWSC API structure
+ */
+static int bind_lwsc(lwsc_api_t* api)
+{
+ if (!api) {
+ LM_ERR("invalid parameter value\n");
+ return -1;
+ }
+ api->request = lwsc_api_request;
+
+ return 0;
+}
+
/**
*
*/
Hello,
compiling the latest version of Kamailio results in a warning for
mohqueue module:
CC (gcc) [M mohqueue.so] mohq_funcs.o
mohq_funcs.c:225:23: warning: incompatible pointer types passing
'tm_cell_t *' (aka 'struct cell *') to parameter of type 'struct sip_msg *'
[-Wincompatible-pointer-types]
if (ptm->t_release (ptcell) < 0)
I noticed you pushed some changes recently, likely the warning was
introduced by them, not noticing it before. Anyhow, it seems something
that should be reviewed and fixed, otherwise may result in a crash by
passing incorrect structure pointer.
Cheers,
Daniel
--
Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
Funding: https://www.paypal.me/dcmierla
Module: kamailio
Branch: master
Commit: 868ff72ad17573657ce19239a6f394cb117475c6
URL: https://github.com/kamailio/kamailio/commit/868ff72ad17573657ce19239a6f394c…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2021-03-24T10:31:18+01:00
modules: readme files regenerated - pv ... [skip ci]
---
Modified: src/modules/pv/README
---
Diff: https://github.com/kamailio/kamailio/commit/868ff72ad17573657ce19239a6f394c…
Patch: https://github.com/kamailio/kamailio/commit/868ff72ad17573657ce19239a6f394c…
---
diff --git a/src/modules/pv/README b/src/modules/pv/README
index 4aaa44c225..10698c1dd4 100644
--- a/src/modules/pv/README
+++ b/src/modules/pv/README
@@ -194,16 +194,16 @@ Chapter 1. Admin Guide
The value of the parameter has the format: _name_ '=' _type_ ':'
_value_
-
- Note: this is special useful for usage with KEMI scripts, the $shv(...)
- variables must be defined during Kamailio initialization in order to
- become available in all worker processes.
* _name_: shared variable name
* _type_: type of the value
+ “i”: integer value
+ “s”: string value
* _value_: value to be set
+ Note: this is special useful for usage with KEMI scripts, the $shv(...)
+ variables must be defined during Kamailio initialization in order to
+ become available in all worker processes.
+
Default value is “NULL”.
Example 1.1. shvset parameter usage
Module: kamailio
Branch: master
Commit: c959a3c5f5efa1158bd53a31476f33d080793928
URL: https://github.com/kamailio/kamailio/commit/c959a3c5f5efa1158bd53a31476f33d…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-03-24T10:21:07+01:00
pv: docs - relocated shvset note outside of param definition details [skip ci]
---
Modified: src/modules/pv/doc/pv_admin.xml
---
Diff: https://github.com/kamailio/kamailio/commit/c959a3c5f5efa1158bd53a31476f33d…
Patch: https://github.com/kamailio/kamailio/commit/c959a3c5f5efa1158bd53a31476f33d…
---
diff --git a/src/modules/pv/doc/pv_admin.xml b/src/modules/pv/doc/pv_admin.xml
index 5fbe706c8e..1c4c84e0fb 100644
--- a/src/modules/pv/doc/pv_admin.xml
+++ b/src/modules/pv/doc/pv_admin.xml
@@ -63,11 +63,6 @@
The value of the parameter has the format:
_name_ '=' _type_ ':' _value_
</para>
- <para>
- Note: this is special useful for usage with KEMI scripts, the $shv(...)
- variables must be defined during Kamailio initialization in order to
- become available in all worker processes.
- </para>
<itemizedlist>
<listitem><para>_name_: shared variable name</para></listitem>
@@ -81,6 +76,11 @@
<listitem><para>_value_: value to be set</para></listitem>
</itemizedlist>
<para>
+ Note: this is special useful for usage with KEMI scripts, the $shv(...)
+ variables must be defined during Kamailio initialization in order to
+ become available in all worker processes.
+ </para>
+ <para>
Default value is <quote>NULL</quote>.
</para>
<example>
Module: kamailio
Branch: master
Commit: fa136edab5e552ed7b9e01af602bc09c98afce35
URL: https://github.com/kamailio/kamailio/commit/fa136edab5e552ed7b9e01af602bc09…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2021-03-24T10:16:24+01:00
modules: readme files regenerated - pv ... [skip ci]
---
Modified: src/modules/pv/README
---
Diff: https://github.com/kamailio/kamailio/commit/fa136edab5e552ed7b9e01af602bc09…
Patch: https://github.com/kamailio/kamailio/commit/fa136edab5e552ed7b9e01af602bc09…
---
diff --git a/src/modules/pv/README b/src/modules/pv/README
index a6702afa12..4aaa44c225 100644
--- a/src/modules/pv/README
+++ b/src/modules/pv/README
@@ -189,11 +189,15 @@ Chapter 1. Admin Guide
3.1. shvset (string)
- Set the value of a shared variable ($shv(name)). The parameter can be
- set many times.
+ Set the initial value of a shared variable ($shv(name)). The parameter
+ can be set many times.
The value of the parameter has the format: _name_ '=' _type_ ':'
_value_
+
+ Note: this is special useful for usage with KEMI scripts, the $shv(...)
+ variables must be defined during Kamailio initialization in order to
+ become available in all worker processes.
* _name_: shared variable name
* _type_: type of the value
+ “i”: integer value
Module: kamailio
Branch: master
Commit: bcc6370cdc00f25ce3d0f29e168c20ca880dcda2
URL: https://github.com/kamailio/kamailio/commit/bcc6370cdc00f25ce3d0f29e168c20c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-03-24T09:46:53+01:00
pv: docs - note about use of $shv() in kemi scripts for shvset param [skip ci]
---
Modified: src/modules/pv/doc/pv_admin.xml
---
Diff: https://github.com/kamailio/kamailio/commit/bcc6370cdc00f25ce3d0f29e168c20c…
Patch: https://github.com/kamailio/kamailio/commit/bcc6370cdc00f25ce3d0f29e168c20c…
---
diff --git a/src/modules/pv/doc/pv_admin.xml b/src/modules/pv/doc/pv_admin.xml
index 61df878c3a..5fbe706c8e 100644
--- a/src/modules/pv/doc/pv_admin.xml
+++ b/src/modules/pv/doc/pv_admin.xml
@@ -56,13 +56,18 @@
<section id="pv.p.shvset">
<title><varname>shvset</varname> (string)</title>
<para>
- Set the value of a shared variable ($shv(name)). The parameter
+ Set the initial value of a shared variable ($shv(name)). The parameter
can be set many times.
</para>
<para>
The value of the parameter has the format:
_name_ '=' _type_ ':' _value_
</para>
+ <para>
+ Note: this is special useful for usage with KEMI scripts, the $shv(...)
+ variables must be defined during Kamailio initialization in order to
+ become available in all worker processes.
+ </para>
<itemizedlist>
<listitem><para>_name_: shared variable name</para></listitem>