Module: kamailio
Branch: master
Commit: 51505a0f5eadcdb8ca4aa3108b060802d7a55972
URL:
https://github.com/kamailio/kamailio/commit/51505a0f5eadcdb8ca4aa3108b06080…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-04-16T16:44:17+02:00
corex: new function is_faked_msg()
- return 1 (native cfg true) if the message under processing is faked (a
static sip message structure used internally by kamailio)
- return -1 (native cfg false) if it is a received sip message
- useful for checking in event routes or async route blocks when can be
both types of messages
---
Modified: src/modules/corex/corex_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/51505a0f5eadcdb8ca4aa3108b06080…
Patch:
https://github.com/kamailio/kamailio/commit/51505a0f5eadcdb8ca4aa3108b06080…
---
diff --git a/src/modules/corex/corex_mod.c b/src/modules/corex/corex_mod.c
index febd97f0f3..e23aae325d 100644
--- a/src/modules/corex/corex_mod.c
+++ b/src/modules/corex/corex_mod.c
@@ -29,6 +29,7 @@
#include "../../core/resolve.h"
#include "../../core/lvalue.h"
#include "../../core/pvar.h"
+#include "../../core/fmsg.h"
#include "../../core/kemi.h"
#include "../../core/parser/parse_uri.h"
@@ -61,6 +62,7 @@ static int w_set_source_address(sip_msg_t *msg, char *paddr, char *p2);
static int w_via_add_srvid(sip_msg_t *msg, char *pflags, char *p2);
static int w_via_add_xavp_params(sip_msg_t *msg, char *pflags, char *p2);
static int w_via_use_xavp_fields(sip_msg_t *msg, char *pflags, char *p2);
+static int w_is_faked_msg(sip_msg_t *msg, char *p1, char *p2);
static int fixup_file_op(void** param, int param_no);
@@ -130,6 +132,8 @@ static cmd_export_t cmds[]={
0, ANY_ROUTE },
{"via_use_xavp_fields", (cmd_function)w_via_use_xavp_fields, 1,
fixup_igp_null,
0, ANY_ROUTE },
+ {"is_faked_msg", (cmd_function)w_is_faked_msg, 0, 0,
+ 0, ANY_ROUTE },
{0, 0, 0, 0, 0, 0}
};
@@ -927,6 +931,28 @@ static int ki_has_user_agent(sip_msg_t *msg)
return -1;
}
+/**
+ *
+ */
+static int ki_is_faked_msg(sip_msg_t *msg)
+{
+ if(faked_msg_match(msg)) {
+ return 1;
+ }
+ return -1;
+}
+
+/**
+ *
+ */
+static int w_is_faked_msg(sip_msg_t *msg, char *p1, char *p2)
+{
+ if(faked_msg_match(msg)) {
+ return 1;
+ }
+ return -1;
+}
+
/**
*
*/
@@ -1022,6 +1048,11 @@ static sr_kemi_t sr_kemi_corex_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("corex"), str_init("is_faked_msg"),
+ SR_KEMIP_INT, ki_is_faked_msg,
+ { SR_KEMIP_NONE, 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 } }
};