Re: [sr-dev] [kamailio/kamailio] KEMI: kx subclass not found (#2196)

2020-01-14 Thread Daniel-Constantin Mierla
Feel free to make a pull request to the docs for clarifying.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2196#issuecomment-574282184___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] KEMI: kx subclass not found (#2196)

2020-01-14 Thread Romain Untereiner
Closed #2196.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2196#event-2947689918___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] KEMI: kx subclass not found (#2196)

2020-01-14 Thread Romain Untereiner
Thank you @miconda, super quick! Indeed I did not understand from where were 
being extracted all KSR.kx. functions. Fixed by adding `kemix` in 
`included_modules` before installing, and `loadmodule "kemix.so"` into the 
config.

We might add clarification on [KEMI 
docs](https://kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/modules/#kex)
 in order to avoid brain conflicts between KEMI, kemix, kex, and kx terms. We 
do you think? I'd be happy to add it if lgtm.

Thanks again, closing.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2196#issuecomment-574250193___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] KEMI: kx subclass not found (#2196)

2020-01-14 Thread Daniel-Constantin Mierla
You have to load `kemix` module.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2196#issuecomment-574235106___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] [kamailio/kamailio] KEMI: kx subclass not found (#2196)

2020-01-14 Thread Romain Untereiner
## Description

Hello all, I'm migrating my Kamailio logics from legacy .cfg file to KEMI 
script. 
I began with Python but switched then to Lua, but there are some subclass / 
functions described in KEMI documentation that seem not to be present in Lua 
KSR object.

In this case, I am having trouble with the subclass "kx" described 
[here](https://kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/modules/#ksrkxget_srcip)
 which is used in the default Lua script example 
[here](https://github.com/kamailio/kamailio/blob/ca49dc0344f2ca4eae1999f6b46e0ab8c30bd1a3/misc/examples/kemi/kamailio-basic-kemi-lua.lua)

The error in the logs:
```bash
 app_lua [app_lua_api.c:726]: app_lua_run_ex(): error from Lua: 
/etc/kamailio/kamailio.lua:196: attempt to index field 'kx' (a nil value)
```

Referring to the following line in my Lua script:
```lua
function ksr_route_reqinit()
if not KSR.is_myself_srcip() then
local srcip = KSR.kx.get_srcip();
if KSR.htable.sht_match_name("ipban", "eq", srcip) > 0 then
-- ip is already blocked
KSR.dbg("request from blocked IP - " .. 
KSR.pv.get("$rm")
.. " from " .. KSR.kex.gete_furi() .. " 
(IP:"
.. srcip .. ":" .. 
KSR.kex.get_srcport() .. ")\n");
KSR.x.exit();
end
if KSR.pike.pike_check_req() < 0 then
KSR.err("ALERT: pike blocking " .. KSR.pv.get("$rm")
.. " from " .. KSR.kex.gete_furi() .. " 
(IP:"
.. srcip .. ":" .. 
KSR.kex.get_srcport() .. ")\n");
KSR.htable.sht_seti("ipban", srcip, 1);
KSR.x.exit();
end
end
end
```

- Should this function be available through KSR object ? If yes we're talking 
about an issue
Or
-  Is this function not supported anymore / not with app_lua ? In this case we 
should fix the documentation + the example script

### Troubleshooting

Debian Jessie
Kamailio 5.3
Lua 5.2

 Reproduction

I tried different versions, all KO (Kamailio 5.2, 5.3, and last commit on 
master: kamailio 5.4.0-dev3 (x86_64/linux) 5afe1e)

1. Install Debian Jessie
2. Clone Kamilio GIT
3. Build from source with make (enabling the desired modules before)
4. Insert Lua script (demo one is fine to reproduce my issue)

 Debugging Data

```bash
@b:/# kamailio -V
version: kamailio 5.4.0-dev3 (x86_64/linux) 5afe1e
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, 
USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, 
DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, 
USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, 
TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, 
BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 5afe1e
compiled on 14:27:15 Jan 14 2020 with gcc 6.3.0
```

 Log Messages

```bash
app_lua [app_lua_api.c:726]: app_lua_run_ex(): error from Lua: 
/etc/kamailio/kamailio.lua:196: attempt to index field 'kx' (a nil value)
```

 SIP Traffic

Any message going through ksr_route_reqinit() function is triggering the error


Thanks !

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2196___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] ims_ipsec_pcscf: fixed warnings, added a new config param (#2148)

2020-01-14 Thread Victor Seva
Closed #2148.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/2148#event-2947307133___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] [kamailio/kamailio] ims_ipsec_pcscf: fixed warnings, added a new config param (#2148)

2020-01-14 Thread alexyosifov
This pull request can be closed. Dedicated pull requests already merged.
Thanks!

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/2148#issuecomment-574185292___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:5afe1e59: pv: new transformations s.encode.base64t and s.decode.base64t

2020-01-14 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 5afe1e5942ba586ef3165e220a588a7176fc79e9
URL: 
https://github.com/kamailio/kamailio/commit/5afe1e5942ba586ef3165e220a588a7176fc79e9

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2020-01-14T09:38:54+01:00

pv: new transformations s.encode.base64t and s.decode.base64t

- base64 encode/decode with optional trailing padding

---

Modified: src/modules/pv/pv_trans.c
Modified: src/modules/pv/pv_trans.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/5afe1e5942ba586ef3165e220a588a7176fc79e9.diff
Patch: 
https://github.com/kamailio/kamailio/commit/5afe1e5942ba586ef3165e220a588a7176fc79e9.patch

---

diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index 547ba60705..354a51795c 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -465,6 +465,55 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, 
int subtype,
val->rs.s = _tr_buffer;
val->rs.len = i;
break;
+   case TR_S_ENCODEBASE64T:
+   if(!(val->flags_VAL_STR))
+   val->rs.s = int2str(val->ri, >rs.len);
+   i = base64_enc((unsigned char *) val->rs.s, val->rs.len,
+   (unsigned char *) _tr_buffer, 
TR_BUFFER_SIZE-1);
+   if (i < 0)
+   return -1;
+   if (i>1 && _tr_buffer[i-1] == '=') {
+   i--;
+   if (i>1 && _tr_buffer[i-1] == '=') {
+   i--;
+   }
+   }
+   _tr_buffer[i] = '\0';
+   memset(val, 0, sizeof(pv_value_t));
+   val->flags = PV_VAL_STR;
+   val->rs.s = _tr_buffer;
+   val->rs.len = i;
+   break;
+   case TR_S_DECODEBASE64T:
+   if(!(val->flags_VAL_STR))
+   val->rs.s = int2str(val->ri, >rs.len);
+   if(val->rs.len % 4) {
+   if(val->rs.len + 4 >= TR_BUFFER_SIZE-1) {
+   LM_ERR("not enough space to insert 
padding\n");
+   return -1;
+   }
+   memcpy(_tr_buffer, val->rs.s, val->rs.len);
+   for(i=0; i < (4 - (val->rs.len % 4)); i++) {
+   _tr_buffer[val->rs.len + i] = '=';
+   }
+   st.s = _tr_buffer;
+   st.len = val->rs.len + (4 - (val->rs.len % 4));
+   /* move to next buffer */
+   tr_set_crt_buffer();
+   i = base64_dec((unsigned char *) st.s, st.len,
+   (unsigned char *) _tr_buffer, 
TR_BUFFER_SIZE-1);
+   } else {
+   i = base64_dec((unsigned char *) val->rs.s, 
val->rs.len,
+   (unsigned char *) _tr_buffer, 
TR_BUFFER_SIZE-1);
+   }
+   if (i < 0 || (i == 0 && val->rs.len > 0))
+   return -1;
+   _tr_buffer[i] = '\0';
+   memset(val, 0, sizeof(pv_value_t));
+   val->flags = PV_VAL_STR;
+   val->rs.s = _tr_buffer;
+   val->rs.len = i;
+   break;
case TR_S_ESCAPECOMMON:
if(!(val->flags_VAL_STR))
val->rs.s = int2str(val->ri, >rs.len);
@@ -2315,6 +2364,12 @@ char* tr_parse_string(str* in, trans_t *t)
} else if(name.len==13 && strncasecmp(name.s, "decode.base64", 13)==0) {
t->subtype = TR_S_DECODEBASE64;
goto done;
+   } else if(name.len==14 && strncasecmp(name.s, "encode.base64t", 14)==0) 
{
+   t->subtype = TR_S_ENCODEBASE64T;
+   goto done;
+   } else if(name.len==14 && strncasecmp(name.s, "decode.base64t", 14)==0) 
{
+   t->subtype = TR_S_DECODEBASE64T;
+   goto done;
} else if(name.len==13 && strncasecmp(name.s, "escape.common", 13)==0) {
t->subtype = TR_S_ESCAPECOMMON;
goto done;
diff --git a/src/modules/pv/pv_trans.h b/src/modules/pv/pv_trans.h
index 0b579e4b27..88cb9eb321 100644
--- a/src/modules/pv/pv_trans.h
+++ b/src/modules/pv/pv_trans.h
@@ -13,8 +13,8 @@
  * 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