Module: kamailio
Branch: master
Commit: abbe518724d645b6f977ca526011285bc03c581c
URL:
https://github.com/kamailio/kamailio/commit/abbe518724d645b6f977ca526011285…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-06-16T12:29:33+02:00
pua_json: exported KSR.pua_json.publish() to kemi
- corresponding to config pua_json_publish()
- use fixup_spve_null() and fixup_free_spve_null() for
pua_json_publish() config export
---
Modified: src/modules/pua_json/pua_json_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/abbe518724d645b6f977ca526011285…
Patch:
https://github.com/kamailio/kamailio/commit/abbe518724d645b6f977ca526011285…
---
diff --git a/src/modules/pua_json/pua_json_mod.c b/src/modules/pua_json/pua_json_mod.c
index 2c7e7f5513..2b51e5020e 100644
--- a/src/modules/pua_json/pua_json_mod.c
+++ b/src/modules/pua_json/pua_json_mod.c
@@ -27,31 +27,41 @@
#include "../json/api.h"
#include "../presence/bind_presence.h"
+#include "../../core/mod_fix.h"
+#include "../../core/kemi.h"
+
#include "pua_json_mod.h"
MODULE_VERSION
+static int w_pua_json_publish(sip_msg_t *msg, char *p1pjson, char *p2);
+
+/* clang-format off */
static param_export_t params[] = {
- {"pua_include_entity", INT_PARAM, &pua_include_entity},
- {0, 0, 0}};
+ {"pua_include_entity", PARAM_INT, &pua_include_entity},
+ {0, 0, 0}
+};
static cmd_export_t cmds[] = {
- {"pua_json_publish", (cmd_function)pua_json_publish, 1, 0, 0,
- ANY_ROUTE},
- {0, 0, 0, 0, 0, 0}};
+ {"pua_json_publish", (cmd_function)w_pua_json_publish, 1,
+ fixup_spve_null, fixup_free_spve_null, ANY_ROUTE},
+
+ {0, 0, 0, 0, 0, 0}
+};
struct module_exports exports = {
- "pua_json", /* module name */
- DEFAULT_DLFLAGS, /* dlopen flags */
- cmds, /* exported functions */
- params, /* exported parameters */
- 0, /* RPC method exports */
- 0, /* exported pseudo-variables */
- 0, /* response handling function */
- mod_init, /* module initialization function */
- 0, /* per-child init function */
- 0 /* module destroy function */
+ "pua_json", /* module name */
+ DEFAULT_DLFLAGS, /* dlopen flags */
+ cmds, /* exported functions */
+ params, /* exported parameters */
+ 0, /* RPC method exports */
+ 0, /* exported pseudo-variables */
+ 0, /* response handling function */
+ mod_init, /* module initialization function */
+ 0, /* per-child init function */
+ 0 /* module destroy function */
};
+/* clang-format on */
static int mod_init(void)
{
@@ -66,3 +76,50 @@ static int mod_init(void)
return 0;
}
+
+/**
+ *
+ */
+static int ki_pua_json_publish(sip_msg_t* msg, str* pjson)
+{
+ return pua_json_publish(msg, pjson->s);
+}
+
+/**
+ *
+ */
+static int w_pua_json_publish(sip_msg_t *msg, char *p1pjson, char *p2)
+{
+ str pjson = STR_NULL;
+
+ if(fixup_get_svalue(msg, (gparam_t*)p1pjson, &pjson)<0) {
+ LM_ERR("failed to get p1 value\n");
+ return -1;
+ }
+
+ return pua_json_publish(msg, pjson.s);
+}
+
+/**
+ *
+ */
+/* clang-format off */
+static sr_kemi_t sr_kemi_pua_json_exports[] = {
+ { str_init("pua_json"), str_init("publish"),
+ SR_KEMIP_INT, ki_pua_json_publish,
+ { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+
+ { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
+};
+/* clang-format on */
+
+/**
+ *
+ */
+int mod_register(char *path, int *dlflags, void *p1, void *p2)
+{
+ sr_kemi_modules_add(sr_kemi_pua_json_exports);
+ return 0;
+}