Module: kamailio
Branch: master
Commit: 0292cae2812628e433cc07af6a45bf229e2ba708
URL:
https://github.com/kamailio/kamailio/commit/0292cae2812628e433cc07af6a45bf2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-03-31T08:23:58+02:00
evrexec: exposed src ip and port via variable
---
Modified: src/modules/evrexec/evrexec_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/0292cae2812628e433cc07af6a45bf2…
Patch:
https://github.com/kamailio/kamailio/commit/0292cae2812628e433cc07af6a45bf2…
---
diff --git a/src/modules/evrexec/evrexec_mod.c b/src/modules/evrexec/evrexec_mod.c
index e3d131ff9f..253197d100 100644
--- a/src/modules/evrexec/evrexec_mod.c
+++ b/src/modules/evrexec/evrexec_mod.c
@@ -286,6 +286,11 @@ void evrexec_process_socket(evrexec_task_t *it, int idx)
NI_NUMERICHOST | NI_NUMERICSERV);
if(ret == 0) {
LM_DBG("received data from %s port %s\n", srchostval, srcportval);
+ _evrexec_info.srcip.s = srchostval;
+ _evrexec_info.srcip.len = strlen(_evrexec_info.srcip.s);
+ _evrexec_info.srcport.s = srcportval;
+ _evrexec_info.srcport.len = strlen(_evrexec_info.srcport.s);
+ str2sint(&_evrexec_info.srcport, &_evrexec_info.srcportno);
}
_evrexec_info.data.s = rcvbuf;
@@ -424,6 +429,19 @@ static int pv_get_evr(sip_msg_t *msg, pv_param_t *param, pv_value_t
*res)
switch(param->pvn.u.isname.name.n) {
case 0: /* data */
return pv_get_strval(msg, param, res, &_evrexec_info.data);
+ case 1: /* srcpip */
+ if(_evrexec_info.srcip.s==NULL) {
+ return pv_get_null(msg, param, res);
+ }
+ return pv_get_strval(msg, param, res, &_evrexec_info.srcip);
+ case 2: /* srcport */
+ if(_evrexec_info.srcport.s==NULL) {
+ return pv_get_null(msg, param, res);
+ }
+ return pv_get_strval(msg, param, res, &_evrexec_info.srcport);
+ case 3: /* srcportno */
+ return pv_get_sintval(msg, param, res, _evrexec_info.srcportno);
+
default:
return pv_get_null(msg, param, res);
}
@@ -445,6 +463,27 @@ static int pv_parse_evr_name(pv_spec_p sp, str *in)
goto error;
}
break;
+ case 5:
+ if(strncmp(in->s, "srcip", 5)==0) {
+ sp->pvp.pvn.u.isname.name.n = 1;
+ } else {
+ goto error;
+ }
+ break;
+ case 7:
+ if(strncmp(in->s, "srcport", 7)==0) {
+ sp->pvp.pvn.u.isname.name.n = 2;
+ } else {
+ goto error;
+ }
+ break;
+ case 9:
+ if(strncmp(in->s, "srcportno", 9)==0) {
+ sp->pvp.pvn.u.isname.name.n = 3;
+ } else {
+ goto error;
+ }
+ break;
default:
goto error;
}