[sr-dev] git:master:1c402ddc: core: new command line parameter --modparam

2019-11-25 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 1c402ddc4cc499700e186b65108303a2aaec6287
URL: 
https://github.com/kamailio/kamailio/commit/1c402ddc4cc499700e186b65108303a2aaec6287

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2019-11-26T08:49:02+01:00

core: new command line parameter --modparam

- allow setting a module parameter via command line
- format: --modparam=modname:paramname:type:valye
- type can be: 'i' for integer value; 's' for string value
- example:

kamailio --loadmodule=xprint.so --modparam=xprint:buf_size:i:2048

---

Modified: src/core/modparam.c
Modified: src/core/modparam.h
Modified: src/main.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/1c402ddc4cc499700e186b65108303a2aaec6287.diff
Patch: 
https://github.com/kamailio/kamailio/commit/1c402ddc4cc499700e186b65108303a2aaec6287.patch

---

diff --git a/src/core/modparam.c b/src/core/modparam.c
index 72ad2fbc9e..1a7d8acd78 100644
--- a/src/core/modparam.c
+++ b/src/core/modparam.c
@@ -154,3 +154,63 @@ int set_mod_param_regex(char* regex, char* name, 
modparam_t type, void* val)
}
return 0;
 }
+
+int set_mod_param_serialized(char* mval)
+{
+#define MPARAM_MBUF_SIZE 256
+   char mbuf[MPARAM_MBUF_SIZE];
+   char *mname = NULL;
+   char *mparam = NULL;
+   char *sval = NULL;
+   int ival = 0;
+   int ptype = PARAM_STRING;
+   char *p = NULL;
+
+   if(strlen(mval) >= MPARAM_MBUF_SIZE) {
+   LM_ERR("argument is too long: %s\n", mval);
+   return -1;
+   }
+   strcpy(mbuf, mval);
+   mname = mbuf;
+   p = strchr(mbuf, ':');
+   if(p==NULL) {
+   LM_ERR("invalid format for argument: %s\n", mval);
+   return -1;
+   }
+   *p = '\0';
+   p++;
+   mparam = p;
+   p = strchr(p, ':');
+   if(p==NULL) {
+   LM_ERR("invalid format for argument: %s\n", mval);
+   return -1;
+   }
+   *p = '\0';
+   p++;
+   if(*p=='i' || *p=='I') {
+   ptype = PARAM_INT;
+   } else if(*p=='s' || *p=='S') {
+   ptype = PARAM_STRING;
+   } else {
+   LM_ERR("invalid format for argument: %s\n", mval);
+   return -1;
+   }
+   p++;
+   if(*p!=':') {
+   LM_ERR("invalid format for argument: %s\n", mval);
+   return -1;
+   }
+   p++;
+   sval = p;
+
+   if(ptype == PARAM_STRING) {
+   return set_mod_param_regex(mname, mparam, PARAM_STRING, sval);
+   } else {
+   if(strlen(sval) <= 0) {
+   LM_ERR("invalid format for argument: %s\n", mval);
+   return -1;
+   }
+   strz2sint(sval, );
+   return set_mod_param_regex(mname, mparam, PARAM_INT, 
(void*)(long)ival);
+   }
+}
diff --git a/src/core/modparam.h b/src/core/modparam.h
index 91c6867d59..0a4241ad4a 100644
--- a/src/core/modparam.h
+++ b/src/core/modparam.h
@@ -34,4 +34,6 @@ int set_mod_param(char* _mod, char* _name, modparam_t _type, 
void* _val);
 
 int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val);
 
+int set_mod_param_serialized(char* mval);
+
 #endif
diff --git a/src/main.c b/src/main.c
index 31af3d2cef..0bc2e650dc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -78,6 +78,7 @@
 #include "core/mem/shm_mem.h"
 #include "core/shm_init.h"
 #include "core/sr_module.h"
+#include "core/modparam.h"
 #include "core/timer.h"
 #include "core/parser/msg_parser.h"
 #include "core/ip_addr.h"
@@ -196,6 +197,9 @@ Options:\n\
 --loadmodule=name load the module specified by name\n\
 -L path  Modules search path (default: " MODS_DIR ")\n\
 -m nrSize of shared memory allocated in Megabytes\n\
+--modparam=modname:paramname:type:value set the module parameter\n\
+  type has to be 's' for string value and 'i' for int value, 
\n\
+  example: --modparam=corex:alias_subdomains:s:" NAME ".org\n\
 -M nrSize of private memory allocated, in Megabytes\n\
 -n processes Number of child processes to fork per interface\n\
   (default: 8)\n"
@@ -1924,6 +1928,7 @@ int main(int argc, char** argv)
{"substdefs",   required_argument, 0, KARGOPTVAL + 3},
{"server-id",   required_argument, 0, KARGOPTVAL + 4},
{"loadmodule",  required_argument, 0, KARGOPTVAL + 5},
+   {"modparam",required_argument, 0, KARGOPTVAL + 6},
{0, 0, 0, 0 }
};
 
@@ -2140,6 +2145,7 @@ int main(int argc, char** argv)
case 's':
case 'Y':
case KARGOPTVAL+5:
+   case KARGOPTVAL+6:
break;
 
/* long options */
@@ -2239,6 +2245,12 @@ int main(int argc, char** argv)
goto 

[sr-dev] git:master:b36da1dc: core: utils functions to converts strz to integer

2019-11-25 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: b36da1dca71036ea3aa52675d3166317851e6594
URL: 
https://github.com/kamailio/kamailio/commit/b36da1dca71036ea3aa52675d3166317851e6594

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2019-11-26T08:49:02+01:00

core: utils functions to converts strz to integer

---

Modified: src/core/ut.h

---

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

---

diff --git a/src/core/ut.h b/src/core/ut.h
index 8b64070947..a841449164 100644
--- a/src/core/ut.h
+++ b/src/core/ut.h
@@ -689,6 +689,62 @@ static inline int str2sint(str* _s, int* _r)
 }
 
 
+/*
+ * Convert a str into integer
+ */
+static inline int strz2int(char* _s, unsigned int* _r)
+{
+   int i;
+
+   if (_r == NULL) return -1;
+   *_r = 0;
+   if (_s == NULL) return -1;
+
+   for(i = 0; _s[i] != '\0'; i++) {
+   if ((_s[i] >= '0') && (_s[i] <= '9')) {
+   *_r *= 10;
+   *_r += _s[i] - '0';
+   } else {
+   return -1;
+   }
+   }
+
+   return 0;
+}
+
+/*
+ * Convert an str to signed integer
+ */
+static inline int strz2sint(char* _s, int* _r)
+{
+   int i;
+   int sign;
+
+   if (_r == NULL) return -1;
+   *_r = 0;
+   if (_s == NULL) return -1;
+
+   sign = 1;
+   i = 0;
+   if (_s[0] == '+') {
+   i++;
+   } else if (_s[0] == '-') {
+   sign = -1;
+   i++;
+   }
+   for(; _s[i] != '\0'; i++) {
+   if ((_s[i] >= '0') && (_s[i] <= '9')) {
+   *_r *= 10;
+   *_r += _s[i] - '0';
+   } else {
+   return -1;
+   }
+   }
+   *_r *= sign;
+
+   return 0;
+}
+
 
 /**
  * \brief Make a copy of a str structure to a str using shm_malloc


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] git:master:063e6a02: core: increase SHM memory pool to 128 MB

2019-11-25 Thread Daniel-Constantin Mierla
Hello,

On 25.11.19 20:57, Henning Westerholt wrote:
> Hi Daniel,
>
> from time to time there are reports that people run into issues after trying 
> to load larger data sets into the memory (e.g. with routing tables).

As I said, I haven't noticed any such report and actually I just
searched now on site:lists.kamailio.org for the past year and I couldn't
find anything.


>
> I also thought about the system package files, if its ok I would also check 
> them to increase it as well to 128 MB.


Personally I didn't meet any case lately where the default value has to
be changed for shm and the defaults should be for the avearage use of
Kamailio -- that's the reason I wanted to know about some of these cases.

I do not want to get Kamailio look greedy in resources because the
defaults are tuned for corner cases. I did increase many of the internal
buffers/sizes whenerver there were related reports, but didn't noticed
the default shm is even getting closer to being filled up for new comers
playing with kamailio.

If there is a need for such increase for new comers, I would rather keep
the default in the source code lower and increase it in startup scripts.
Who starts from command line is expected to have some knowledge about
its parameters, easily set the -M and -m.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference - April 27-29, 2020, in Berlin -- 
www.kamailioworld.com


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] [kamailio/kamailio] Avoid full table scan for dispatcher table using db_redis using ds_reload() from config script In (#2149)

2019-11-25 Thread Joel Serrano
# Description

Trying to avoid getting this warning:

Nov 22 20:36:35 test COPS[25531]: WARNING: db_redis [redis_dbase.c:1098]: 
db_redis_perform_query(): performing full table scan on table 'dispatcher' 
while performing query

### Troubleshooting

Having: 
```
modparam("db_redis", "keys", "version=entry:table_name")
modparam("db_redis", "keys", "dispatcher=entry:id")
```

And debug logs showing the key being found:

```

 Reproduction


zz
 Debugging Data



```
(paste your debugging data here)
```

 Log Messages



```
(paste your log messages here)
```

 SIP Traffic



```
(paste your sip traffic here)
```

### Possible Solutions



### Additional Information

  * **Kamailio Version** - output of `kamailio -v`

```
(paste your output here)
```

* **Operating System**:



```
(paste your output here)
```


-- 
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/2149___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] git:master:063e6a02: core: increase SHM memory pool to 128 MB

2019-11-25 Thread Henning Westerholt
Hi Daniel,

from time to time there are reports that people run into issues after trying to 
load larger data sets into the memory (e.g. with routing tables).

I also thought about the system package files, if its ok I would also check 
them to increase it as well to 128 MB.

Cheers,

Henning

-- 
Henning Westerholt – https://skalatan.de/blog/
Kamailio services – https://gilawa.com 
Kamailio Merchandising – https://skalatan.de/merchandising 

-Original Message-
From: Daniel-Constantin Mierla  
Sent: Monday, November 25, 2019 11:00 AM
To: Kamailio (SER) - Development Mailing List ; 
Henning Westerholt 
Subject: Re: [sr-dev] git:master:063e6a02: core: increase SHM memory pool to 
128 MB

Hello,

On 23.11.19 23:23, Henning Westerholt wrote:
> Module: kamailio
> Branch: master
> Commit: 063e6a025b8ca0163af2147f057d29447c6f9760
> URL: 
> https://github.com/kamailio/kamailio/commit/063e6a025b8ca0163af2147f05
> 7d29447c6f9760
>
> Author: Henning Westerholt 
> Committer: Henning Westerholt 
> Date: 2019-11-23T22:49:28+01:00
>
> core: increase SHM memory pool to 128 MB
>
> - increase SHM memory pool to 128 MB
> - even an embedded system like Raspberry Pi has 1 GB RAM nowadays
> - make it less likely that new users run into issues because of lack 
> of memory

I am curious about the last remark, can you priovide more details on issues for 
new uses because lack of memory? I haven't noticed and such report on mailling 
lists or issue tracker later, whondering if it is some particular use case that 
can lead to this issue.

Because a start of kamailio with default config file is using less than 3MB of 
shared memory, being plenty of space to fill up to 64MB with registrations, 
transactions, etc... states taken a few minutes ago with git master branch:

    "shmem:max_used_size = 2836288",
    "shmem:real_used_size = 2836288",
    "shmem:used_size = 2594376"

Then, my actual remark is that I think the new users tend to use the packages, 
which use init.d/systemd to start kamailio, and there are values for pkg and 
shm sizes in the unit files, so this change doesn't really make a difference, 
because kamailio is started with different -m and -M command line parameters.

Cheers,
Daniel

>
> [...]
>
--
Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- 
www.linkedin.com/in/miconda Kamailio World Conference - April 27-29, 2020, in 
Berlin -- www.kamailioworld.com

___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:cef6284f: nathelper: remove AVP from log message, use generic term

2019-11-25 Thread Henning Westerholt
Module: kamailio
Branch: master
Commit: cef6284f18e0d4c606dcee3198f77e34e4c0863d
URL: 
https://github.com/kamailio/kamailio/commit/cef6284f18e0d4c606dcee3198f77e34e4c0863d

Author: Henning Westerholt 
Committer: Henning Westerholt 
Date: 2019-11-25T20:53:37+01:00

nathelper: remove AVP from log message, use generic term

---

Modified: src/modules/nathelper/nathelper.c

---

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

---

diff --git a/src/modules/nathelper/nathelper.c 
b/src/modules/nathelper/nathelper.c
index be95ddd8cd..aae1791b94 100644
--- a/src/modules/nathelper/nathelper.c
+++ b/src/modules/nathelper/nathelper.c
@@ -2544,7 +2544,7 @@ static int write_to_avp(struct sip_msg *msg, str *data, 
str *uri_avp){
memset(, 0, sizeof(pv_value_t));
 
if(!data->s){
-   LM_ERR("There isn't any data to write to avp\n");
+   LM_ERR("There isn't any data to write to the destination\n");
return -1;
}
 


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:9ba1a6c8: nathelper: remove redundant check for zero

2019-11-25 Thread Henning Westerholt
Module: kamailio
Branch: master
Commit: 9ba1a6c851aafc402f5fbe211638159717120c31
URL: 
https://github.com/kamailio/kamailio/commit/9ba1a6c851aafc402f5fbe211638159717120c31

Author: Henning Westerholt 
Committer: Henning Westerholt 
Date: 2019-11-25T20:48:05+01:00

nathelper: remove redundant check for zero

---

Modified: src/modules/nathelper/nathelper.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/9ba1a6c851aafc402f5fbe211638159717120c31.diff
Patch: 
https://github.com/kamailio/kamailio/commit/9ba1a6c851aafc402f5fbe211638159717120c31.patch

---

diff --git a/src/modules/nathelper/nathelper.c 
b/src/modules/nathelper/nathelper.c
index afc38f727b..be95ddd8cd 100644
--- a/src/modules/nathelper/nathelper.c
+++ b/src/modules/nathelper/nathelper.c
@@ -2581,7 +2581,7 @@ static int alias_to_uri(str *contact_header, str 
*alias_uri){
i=i+SALIAS_LEN;
host.s = _header->s[i];
memchr_pointer = memchr(host.s , 126 /* ~ 
*/,contact_header->len-i);
-   if(memchr_pointer == NULL || memchr_pointer == 
0) {
+   if(memchr_pointer == NULL) {
LM_ERR("No alias parameter found for 
host\n");
return -1;
} else {


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:0cc8a34d: nathelper: small spelling fix in docs

2019-11-25 Thread Henning Westerholt
Module: kamailio
Branch: master
Commit: 0cc8a34d3ddf2239fa8b9585d2b4432fe8362116
URL: 
https://github.com/kamailio/kamailio/commit/0cc8a34d3ddf2239fa8b9585d2b4432fe8362116

Author: Henning Westerholt 
Committer: Henning Westerholt 
Date: 2019-11-25T20:45:46+01:00

nathelper: small spelling fix in docs

---

Modified: src/modules/nathelper/doc/nathelper_admin.xml

---

Diff:  
https://github.com/kamailio/kamailio/commit/0cc8a34d3ddf2239fa8b9585d2b4432fe8362116.diff
Patch: 
https://github.com/kamailio/kamailio/commit/0cc8a34d3ddf2239fa8b9585d2b4432fe8362116.patch

---

diff --git a/src/modules/nathelper/doc/nathelper_admin.xml 
b/src/modules/nathelper/doc/nathelper_admin.xml
index 8c3245c5b8..732a617396 100644
--- a/src/modules/nathelper/doc/nathelper_admin.xml
+++ b/src/modules/nathelper/doc/nathelper_admin.xml
@@ -829,7 +829,7 @@ if(is_rfc1918("$rd")) {


Reads ;alias=ip~port~transport from Contact 
header then
-   writes to target avp as a sip uri.
+   writes to target pseudo-variable as a sip uri.


This function can be used from


___
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] nathelper : added new function set_alias_to_pv (#2124)

2019-11-25 Thread Henning Westerholt
Thank you, merged. I will add 1-2 small formatting changes directly in git 
master. If there are more changes, they can be done directly in git master as 
well.

-- 
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/2124#issuecomment-558306721___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:46b713d3: nathelper : added doc for set_alias_to_avp

2019-11-25 Thread Henning Westerholt
Module: kamailio
Branch: master
Commit: 46b713d35ebb99ccb60768d939d71f675bd016f5
URL: 
https://github.com/kamailio/kamailio/commit/46b713d35ebb99ccb60768d939d71f675bd016f5

Author: Yasin CANER 
Committer: Henning Westerholt 
Date: 2019-11-25T20:33:30+01:00

nathelper : added doc for set_alias_to_avp

added documents for set_alias_to_avp function

---

Modified: src/modules/nathelper/doc/nathelper_admin.xml

---

Diff:  
https://github.com/kamailio/kamailio/commit/46b713d35ebb99ccb60768d939d71f675bd016f5.diff
Patch: 
https://github.com/kamailio/kamailio/commit/46b713d35ebb99ccb60768d939d71f675bd016f5.patch

---

diff --git a/src/modules/nathelper/doc/nathelper_admin.xml 
b/src/modules/nathelper/doc/nathelper_admin.xml
index b5a5b08167..d983e99aa4 100644
--- a/src/modules/nathelper/doc/nathelper_admin.xml
+++ b/src/modules/nathelper/doc/nathelper_admin.xml
@@ -823,6 +823,27 @@ if(is_rfc1918("$rd")) {



+   
+   
+   set_alias_to_avp(target_avp)
+   
+   
+   Reads ;alias=ip~port~transport from Contact 
header then
+   writes to target avp as a sip uri.
+   
+   
+   This function can be used from
+   REQUEST_ROUTE, ONREPLY_ROUTE, BRANCH_ROUTE, and FAILURE_ROUTE.
+   
+   
+   set_alias_to_avp usage
+   
+...
+   set_alias_to_avp("$avp(aliasuri)");
+...
+   
+   
+   
 

 


___
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] nathelper : added new function set_alias_to_pv (#2124)

2019-11-25 Thread Henning Westerholt
Merged #2124 into master.

-- 
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/2124#event-2829364019___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:28cfa397: nathelper : set_alias_to_avp is renamed to set_alias_to_pv

2019-11-25 Thread Henning Westerholt
Module: kamailio
Branch: master
Commit: 28cfa3978684838442fbd3b4861765023252e963
URL: 
https://github.com/kamailio/kamailio/commit/28cfa3978684838442fbd3b4861765023252e963

Author: Yasin CANER 
Committer: Henning Westerholt 
Date: 2019-11-25T20:33:30+01:00

nathelper : set_alias_to_avp is renamed to set_alias_to_pv

set_alias_to_avp renamed to set_alias_to_pv

---

Modified: src/modules/nathelper/doc/nathelper_admin.xml
Modified: src/modules/nathelper/nathelper.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/28cfa3978684838442fbd3b4861765023252e963.diff
Patch: 
https://github.com/kamailio/kamailio/commit/28cfa3978684838442fbd3b4861765023252e963.patch

---

diff --git a/src/modules/nathelper/doc/nathelper_admin.xml 
b/src/modules/nathelper/doc/nathelper_admin.xml
index d983e99aa4..8c3245c5b8 100644
--- a/src/modules/nathelper/doc/nathelper_admin.xml
+++ b/src/modules/nathelper/doc/nathelper_admin.xml
@@ -823,9 +823,9 @@ if(is_rfc1918("$rd")) {



-   
+   

-   set_alias_to_avp(target_avp)
+   set_alias_to_pv(target_avp)


Reads ;alias=ip~port~transport from Contact 
header then
@@ -836,10 +836,10 @@ if(is_rfc1918("$rd")) {
REQUEST_ROUTE, ONREPLY_ROUTE, BRANCH_ROUTE, and FAILURE_ROUTE.


-   set_alias_to_avp usage
+   set_alias_to_pv usage

 ...
-   set_alias_to_avp("$avp(aliasuri)");
+   set_alias_to_pv("$avp(aliasuri)");
 ...


diff --git a/src/modules/nathelper/nathelper.c 
b/src/modules/nathelper/nathelper.c
index 3f820fb02c..afc38f727b 100644
--- a/src/modules/nathelper/nathelper.c
+++ b/src/modules/nathelper/nathelper.c
@@ -125,8 +125,8 @@ static int add_rcv_param_f(struct sip_msg *, char *, char 
*);
 static int nh_sip_reply_received(sip_msg_t *msg);
 static int test_sdp_cline(struct sip_msg *msg);
 
-static int w_set_alias_to_avp(struct sip_msg *msg, char *uri_avp, char 
*hollow);
-static int ki_set_alias_to_avp(struct sip_msg *msg, str *uri_avp);
+static int w_set_alias_to_pv(struct sip_msg *msg, char *uri_avp, char *hollow);
+static int ki_set_alias_to_pv(struct sip_msg *msg, str *uri_avp);
 static int alias_to_uri(str *contact_header, str *alias_uri);
 static int write_to_avp(struct sip_msg *msg, str *data, str *uri_avp);
 
@@ -228,7 +228,7 @@ static cmd_export_t cmds[] = {
{"is_rfc1918", (cmd_function)is_rfc1918_f,   1,
fixup_spve_null, 0,
ANY_ROUTE },
-   {"set_alias_to_avp",   (cmd_function)w_set_alias_to_avp, 1,
+   {"set_alias_to_pv",   (cmd_function)w_set_alias_to_pv, 1,
0, 0, ANY_ROUTE },
{0, 0, 0, 0, 0, 0}
 };
@@ -2453,14 +2453,14 @@ static int sel_rewrite_contact(str *res, select_t *s, 
struct sip_msg *msg)
return 0;
 }
 /*!
-* @function w_set_alias_to_avp
+* @function w_set_alias_to_pv
 * @abstract wrapper of set_alias_to_avp_f
 * @param msg sip message
 * @param uri_avp given avp name
 *
 * @result 1 successful  , -1 fail
 */
-static int w_set_alias_to_avp(struct sip_msg *msg, char *uri_avp, char 
*hollow){
+static int w_set_alias_to_pv(struct sip_msg *msg, char *uri_avp, char *hollow){
str dest_avp={0,0};
 
if(!uri_avp)
@@ -2469,11 +2469,11 @@ static int w_set_alias_to_avp(struct sip_msg *msg, char 
*uri_avp, char *hollow){
dest_avp.s=uri_avp;
dest_avp.len=strlen(dest_avp.s);
 
-   return ki_set_alias_to_avp(msg,_avp);
+   return ki_set_alias_to_pv(msg,_avp);
 }
 
 /*!
-* @function ki_set_alias_to_avp
+* @function ki_set_alias_to_pv
 * @abstract reads from  msg then write to given avp uri_avp as sip uri
 *
 * @param msg sip message
@@ -2481,7 +2481,7 @@ static int w_set_alias_to_avp(struct sip_msg *msg, char 
*uri_avp, char *hollow){
 *
 * @result 1 successful  , -1 fail
 */
-static int ki_set_alias_to_avp(struct sip_msg *msg, str *uri_avp){
+static int ki_set_alias_to_pv(struct sip_msg *msg, str *uri_avp){
str contact;
str alias_uri={0,0};
 
@@ -2701,7 +2701,7 @@ static sr_kemi_t sr_kemi_nathelper_exports[] = {
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
{ str_init("nathelper"), str_init("set_alias_to_avp"),
-   SR_KEMIP_INT, ki_set_alias_to_avp,
+   SR_KEMIP_INT, ki_set_alias_to_pv,
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:72efa93c: nathelper : new function set_alias_to_avp_f is renamed

2019-11-25 Thread Henning Westerholt
Module: kamailio
Branch: master
Commit: 72efa93cbf5926402f008180c026d0afbd2c0f9f
URL: 
https://github.com/kamailio/kamailio/commit/72efa93cbf5926402f008180c026d0afbd2c0f9f

Author: Yasin CANER 
Committer: Henning Westerholt 
Date: 2019-11-25T20:33:30+01:00

nathelper : new function set_alias_to_avp_f is renamed

function set_alias_to_avp_f is renamed to w_set_alias_to_avp
added kemi interface

---

Modified: src/core/parser/parse_uri.h
Modified: src/modules/nathelper/nathelper.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/72efa93cbf5926402f008180c026d0afbd2c0f9f.diff
Patch: 
https://github.com/kamailio/kamailio/commit/72efa93cbf5926402f008180c026d0afbd2c0f9f.patch

---

diff --git a/src/core/parser/parse_uri.h b/src/core/parser/parse_uri.h
index 7def5becf3..a3c8c7142c 100644
--- a/src/core/parser/parse_uri.h
+++ b/src/core/parser/parse_uri.h
@@ -47,4 +47,5 @@ int parse_orig_ruri(struct sip_msg* msg);
 int normalize_tel_user(char* res, str* src);
 void uri_type_to_str(uri_type type, str *s);
 void proto_type_to_str(unsigned short type, str *s);
+
 #endif /* PARSE_URI_H */
diff --git a/src/modules/nathelper/nathelper.c 
b/src/modules/nathelper/nathelper.c
index 681606bb5b..3f820fb02c 100644
--- a/src/modules/nathelper/nathelper.c
+++ b/src/modules/nathelper/nathelper.c
@@ -125,8 +125,8 @@ static int add_rcv_param_f(struct sip_msg *, char *, char 
*);
 static int nh_sip_reply_received(sip_msg_t *msg);
 static int test_sdp_cline(struct sip_msg *msg);
 
-static int ki_set_alias_to_avp(struct sip_msg *msg, char *uri_avp);
-static int set_alias_to_avp_f(struct sip_msg *msg, str *uri_avp);
+static int w_set_alias_to_avp(struct sip_msg *msg, char *uri_avp, char 
*hollow);
+static int ki_set_alias_to_avp(struct sip_msg *msg, str *uri_avp);
 static int alias_to_uri(str *contact_header, str *alias_uri);
 static int write_to_avp(struct sip_msg *msg, str *data, str *uri_avp);
 
@@ -228,7 +228,7 @@ static cmd_export_t cmds[] = {
{"is_rfc1918", (cmd_function)is_rfc1918_f,   1,
fixup_spve_null, 0,
ANY_ROUTE },
-   {"set_alias_to_avp",   (cmd_function)ki_set_alias_to_avp, 1,
+   {"set_alias_to_avp",   (cmd_function)w_set_alias_to_avp, 1,
0, 0, ANY_ROUTE },
{0, 0, 0, 0, 0, 0}
 };
@@ -2453,14 +2453,14 @@ static int sel_rewrite_contact(str *res, select_t *s, 
struct sip_msg *msg)
return 0;
 }
 /*!
-* @function ki_set_alias_to_avp
+* @function w_set_alias_to_avp
 * @abstract wrapper of set_alias_to_avp_f
 * @param msg sip message
 * @param uri_avp given avp name
 *
 * @result 1 successful  , -1 fail
 */
-static int ki_set_alias_to_avp(struct sip_msg *msg, char *uri_avp){
+static int w_set_alias_to_avp(struct sip_msg *msg, char *uri_avp, char 
*hollow){
str dest_avp={0,0};
 
if(!uri_avp)
@@ -2469,11 +2469,11 @@ static int ki_set_alias_to_avp(struct sip_msg *msg, 
char *uri_avp){
dest_avp.s=uri_avp;
dest_avp.len=strlen(dest_avp.s);
 
-   return set_alias_to_avp_f(msg,_avp);
-
+   return ki_set_alias_to_avp(msg,_avp);
 }
+
 /*!
-* @function set_alias_to_avp_f
+* @function ki_set_alias_to_avp
 * @abstract reads from  msg then write to given avp uri_avp as sip uri
 *
 * @param msg sip message
@@ -2481,7 +2481,7 @@ static int ki_set_alias_to_avp(struct sip_msg *msg, char 
*uri_avp){
 *
 * @result 1 successful  , -1 fail
 */
-static int set_alias_to_avp_f(struct sip_msg *msg, str *uri_avp){
+static int ki_set_alias_to_avp(struct sip_msg *msg, str *uri_avp){
str contact;
str alias_uri={0,0};
 
@@ -2700,6 +2700,11 @@ static sr_kemi_t sr_kemi_nathelper_exports[] = {
{ SR_KEMIP_INT, SR_KEMIP_STR, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+   { str_init("nathelper"), str_init("set_alias_to_avp"),
+   SR_KEMIP_INT, ki_set_alias_to_avp,
+   { 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 } }
 };


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:138c9df9: nathelper : fixed memory-leak for set_alias_to_avp

2019-11-25 Thread Henning Westerholt
Module: kamailio
Branch: master
Commit: 138c9df907f04003bafe80bad3cb98e031a6ef50
URL: 
https://github.com/kamailio/kamailio/commit/138c9df907f04003bafe80bad3cb98e031a6ef50

Author: Yasin CANER 
Committer: Henning Westerholt 
Date: 2019-11-25T20:33:30+01:00

nathelper : fixed memory-leak for set_alias_to_avp

fixed memory-leak for new function set_alias_to_avp
fixed some spelling
added return for functions write_to_avp and alias_to_uri

---

Modified: src/core/parser/parse_uri.c
Modified: src/core/parser/parse_uri.h
Modified: src/modules/nathelper/nathelper.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/138c9df907f04003bafe80bad3cb98e031a6ef50.diff
Patch: 
https://github.com/kamailio/kamailio/commit/138c9df907f04003bafe80bad3cb98e031a6ef50.patch


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:0fbc7a10: nathelper : added description of set_alias_to_avp function

2019-11-25 Thread Henning Westerholt
Module: kamailio
Branch: master
Commit: 0fbc7a1026e6dc9dda34b75aef7a26e41ccf3b80
URL: 
https://github.com/kamailio/kamailio/commit/0fbc7a1026e6dc9dda34b75aef7a26e41ccf3b80

Author: Yasin CANER 
Committer: Henning Westerholt 
Date: 2019-11-25T20:33:30+01:00

nathelper : added description of set_alias_to_avp function

added description of set_alias_to_avp function

---

Modified: src/modules/nathelper/nathelper.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/0fbc7a1026e6dc9dda34b75aef7a26e41ccf3b80.diff
Patch: 
https://github.com/kamailio/kamailio/commit/0fbc7a1026e6dc9dda34b75aef7a26e41ccf3b80.patch

---

diff --git a/src/modules/nathelper/nathelper.c 
b/src/modules/nathelper/nathelper.c
index 45c3425c5f..259d4d8997 100644
--- a/src/modules/nathelper/nathelper.c
+++ b/src/modules/nathelper/nathelper.c
@@ -2452,6 +2452,9 @@ static int sel_rewrite_contact(str *res, select_t *s, 
struct sip_msg *msg)
 
return 0;
 }
+/**
+* wrapper of set_alias_to_avp_f
+*/
 static int ki_set_alias_to_avp(struct sip_msg *msg, char *uri_avp){
str dest_avp={0,0};
 
@@ -2464,6 +2467,13 @@ static int ki_set_alias_to_avp(struct sip_msg *msg, char 
*uri_avp){
return set_alias_to_avp_f(msg,_avp);
 
 }
+/**
+* function reads from @param msg then write to given avp @param uri_avp
+* as sip uri
+* @result 1 succes , -1 fail
+* @param msg sip message
+* @param uri_avp given avp name
+*/
 static int set_alias_to_avp_f(struct sip_msg *msg, str *uri_avp){
str contact;
str alias_uri={0,0};
@@ -2495,7 +2505,11 @@ static int set_alias_to_avp_f(struct sip_msg *msg, str 
*uri_avp){
return 1;
 
 }
-
+/**
+* write_to_avp function writes data to given avp
+* @param data  source data
+* @param uri_avp destination avp name
+*/
 void write_to_avp(struct sip_msg *msg, str *data, str *uri_avp){
pv_spec_t *pvresult = NULL;
pv_value_t valx;
@@ -2525,6 +2539,12 @@ void write_to_avp(struct sip_msg *msg, str *data, str 
*uri_avp){
pvresult->setf(msg, >pvp, (int)EQ_T, );
 
 }
+/**
+* function alias_to_uri  select alias paramter from @param contact_header
+* then writes to @param alias_uri
+* @param contact_header  Source contact header
+* @param alias_uri destination string
+*/
 void alias_to_uri(str *contact_header, str *alias_uri){
int i=0; // index
str host={0,0};


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:6b725120: nathelper : added new function set_alias_to_avp

2019-11-25 Thread Henning Westerholt
Module: kamailio
Branch: master
Commit: 6b725120bec491197c29bd059c11d8efea58255e
URL: 
https://github.com/kamailio/kamailio/commit/6b725120bec491197c29bd059c11d8efea58255e

Author: Yasin CANER 
Committer: Henning Westerholt 
Date: 2019-11-25T20:33:30+01:00

nathelper : added new function set_alias_to_avp

new function that read alias then write to given avp as sip uri

---

Modified: src/modules/nathelper/nathelper.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/6b725120bec491197c29bd059c11d8efea58255e.diff
Patch: 
https://github.com/kamailio/kamailio/commit/6b725120bec491197c29bd059c11d8efea58255e.patch


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:29a81852: parse_uri : added new function proto type int to str

2019-11-25 Thread Henning Westerholt
Module: kamailio
Branch: master
Commit: 29a818525572e19510cafb7aef9ed62eab98a369
URL: 
https://github.com/kamailio/kamailio/commit/29a818525572e19510cafb7aef9ed62eab98a369

Author: root 
Committer: Henning Westerholt 
Date: 2019-11-25T20:33:30+01:00

parse_uri : added new function proto type int to str

added new function proto type int to str

---

Modified: src/core/parser/parse_uri.c
Modified: src/core/parser/parse_uri.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/29a818525572e19510cafb7aef9ed62eab98a369.diff
Patch: 
https://github.com/kamailio/kamailio/commit/29a818525572e19510cafb7aef9ed62eab98a369.patch

---

diff --git a/src/core/parser/parse_uri.c b/src/core/parser/parse_uri.c
index ec39ea7cf2..283443dacd 100644
--- a/src/core/parser/parse_uri.c
+++ b/src/core/parser/parse_uri.c
@@ -1439,3 +1439,26 @@ void proto_type_to_str(unsigned short type, str *s) {
*s = s_null;
}
 }
+
+void proto_type_int_to_str(int type, str *s) {
+   switch (type) {
+   case PROTO_UDP:
+   *s = s_udp;
+   break;
+   case PROTO_TCP:
+   *s = s_tcp;
+   break;
+   case PROTO_TLS:
+   *s = s_tls;
+   break;
+   case PROTO_SCTP:
+   *s = s_sctp;
+   break;
+   case PROTO_WS:
+   case PROTO_WSS:
+   *s = s_ws;
+   break;
+   default:
+   *s = s_null;
+   }
+}
diff --git a/src/core/parser/parse_uri.h b/src/core/parser/parse_uri.h
index a3c8c7142c..8a8dfac258 100644
--- a/src/core/parser/parse_uri.h
+++ b/src/core/parser/parse_uri.h
@@ -47,5 +47,5 @@ int parse_orig_ruri(struct sip_msg* msg);
 int normalize_tel_user(char* res, str* src);
 void uri_type_to_str(uri_type type, str *s);
 void proto_type_to_str(unsigned short type, str *s);
-
+void proto_type_int_to_str(int type, str *s);
 #endif /* PARSE_URI_H */


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] git:master:7fad9c51: app_sqlang: fix squirrel warning: ‘nArgs’ may be used uninitialized in this function

2019-11-25 Thread Henning Westerholt
Hi Daniel,

Upstream issue: https://github.com/albertodemichelis/squirrel/issues/205

Cheers,

Henning

--
Henning Westerholt – https://skalatan.de/blog/
Kamailio services – https://gilawa.com
Kamailio Merchandising – https://skalatan.de/merchandising

From: Daniel-Constantin Mierla 
Sent: Monday, November 25, 2019 11:11 AM
To: Kamailio (SER) - Development Mailing List ; 
Henning Westerholt 
Subject: Re: git:master:7fad9c51: app_sqlang: fix squirrel warning: ‘nArgs’ 
may be used uninitialized in this function

Hello,

this change has to be pushed to the upstream project, otheriwse with the next 
sync it is going to be lost -- we do not maintain the code of squirrel 
interpreter, it is used as an embedded library. The project is at:

  * https://github.com/albertodemichelis/squirrel

Cheers,
Daniel

On 23.11.19 18:54, Henning Westerholt wrote:

Module: kamailio

Branch: master

Commit: 7fad9c51f71854e0649fe76e273190e4b4f82438

URL: 
https://github.com/kamailio/kamailio/commit/7fad9c51f71854e0649fe76e273190e4b4f82438



Author: Henning Westerholt 

Committer: Henning Westerholt 

Date: 2019-11-23T18:53:17+01:00



app_sqlang: fix squirrel warning: ‘nArgs’ may be used uninitialized 
in this function



---



Modified: src/modules/app_sqlang/squirrel/squirrel/sqbaselib.cpp



---



Diff:  
https://github.com/kamailio/kamailio/commit/7fad9c51f71854e0649fe76e273190e4b4f82438.diff

Patch: 
https://github.com/kamailio/kamailio/commit/7fad9c51f71854e0649fe76e273190e4b4f82438.patch



---



diff --git a/src/modules/app_sqlang/squirrel/squirrel/sqbaselib.cpp 
b/src/modules/app_sqlang/squirrel/squirrel/sqbaselib.cpp

index f3b8103185..fb6545f921 100644

--- a/src/modules/app_sqlang/squirrel/squirrel/sqbaselib.cpp

+++ b/src/modules/app_sqlang/squirrel/squirrel/sqbaselib.cpp

@@ -625,7 +625,7 @@ static SQInteger __map_array(SQArray *dest,SQArray 
*src,HSQUIRRELVM v) {

 SQObject  = stack_get(v, 2);

 v->Push(closure);



-SQInteger nArgs;

+SQInteger nArgs = 0;

 if(sq_type(closure) == OT_CLOSURE) {

 nArgs = _closure(closure)->_function->_nparameters;

 }







___

Kamailio (SER) - Development Mailing List

sr-dev@lists.kamailio.org

https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev



--

Daniel-Constantin Mierla -- www.asipto.com

www.twitter.com/miconda -- 
www.linkedin.com/in/miconda

Kamailio World Conference - April 27-29, 2020, in Berlin -- 
www.kamailioworld.com
___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] removing xprint module

2019-11-25 Thread Henning Westerholt
Hi Daniel,

thanks - I somehow missed this, I just looked for the xprint API.

Cheers,

Henning

--
Henning Westerholt - https://skalatan.de/blog/
Kamailio services - https://gilawa.com
Kamailio Merchandising - https://skalatan.de/merchandising

From: Daniel-Constantin Mierla 
Sent: Monday, November 25, 2019 11:14 AM
To: Kamailio (SER) - Development Mailing List ; 
Henning Westerholt 
Subject: Re: [sr-dev] removing xprint module


Hello,

actually there are modules still using code from it:

src/modules/db2_ops/db2_ops.c
34:#include "../../modules/xprint/xp_lib.h"

src/modules/avp/avp.c
50:#include "../xprint/xp_lib.h"

Then I am aware ofa few (initially) ser-based deployed that still have it.

In general, the removal of a module with config functions should be asked on 
sr-users, that's where potentially users may be found.

Cheers,
Daniel
On 23.11.19 21:24, Henning Westerholt wrote:
Hello,

>From the xprint module README:

The xprint module is the former xlog module from SIP Express Router (SER), kept 
because it is used by other modules via API to get the value for strings with 
specifiers. If you want to print log messages from configuration file, use the 
real module named 'xlog'.

I just checked, there seems to be no module using it anymore. Therefore, I 
would like to propose to remove it in git master.

/repositories/kamailio$ grep -R xl_api * | egrep -v "modules/xprint"
/repositories/kamailio$

Cheers,

Henning

--
Henning Westerholt - https://skalatan.de/blog/
Kamailio services - https://gilawa.com
Kamailio Merchandising - https://skalatan.de/merchandising




___

Kamailio (SER) - Development Mailing List

sr-dev@lists.kamailio.org

https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

--

Daniel-Constantin Mierla -- www.asipto.com

www.twitter.com/miconda -- 
www.linkedin.com/in/miconda

Kamailio World Conference - April 27-29, 2020, in Berlin -- 
www.kamailioworld.com
___
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] cancel the branches instantly instead of on provisional replies (#909)

2019-11-25 Thread Henning Westerholt
Thanks for the feedback

-- 
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/909#issuecomment-558287255___
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] cancel the branches instantly instead of on provisional replies (#909)

2019-11-25 Thread Henning Westerholt
Closed #909.

-- 
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/909#event-2829213081___
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)

2019-11-25 Thread Henning Westerholt
Hello, thanks for the pull request.

Please separate the bugfixes (that needs to be backported) from functional 
additions next time. I assume that the bugfix is in spi_gen.c and also one 
related to the log in int add_supported_secagree_header(struct sip_msg* m) . 
After merging I can manually backport.

About the functional change:
* in ipsec_forward() add supported and require secagree headers only for 
Register reply with code 200. Set SND_F_FORCE_SOCKET for request messages.

Two questions:
- Was the previous behaviour to apply it for all SIP methods wrong?
- Are there cases where one does not want to force the send socket for the 
messages?

I am just trying to sort out if the change might break other people configs and 
some parameter needs to be added.

I have one general remark related to the locking in the module. It uses 
directly the pthread function calls. Usually all modules should use the 
kamailio locking interface (in core/locking.h). The simple lock is probably ok 
for this module. Would be great if you could convert it to this in one of your 
next changes. You can look to e.g. to the ims_usrloc* modules to have a look to 
the implementation.

-- 
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-558286133___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:7966f102: Merge pull request #2147 from kamailio/grumvalski/local_request_drop

2019-11-25 Thread GitHub
Module: kamailio
Branch: master
Commit: 7966f10292cb3c0d0c1ccda20c8475822b4e0993
URL: 
https://github.com/kamailio/kamailio/commit/7966f10292cb3c0d0c1ccda20c8475822b4e0993

Author: Federico Cabiddu 
Committer: GitHub 
Date: 2019-11-25T19:29:21+01:00

Merge pull request #2147 from kamailio/grumvalski/local_request_drop

tm: add support for dropping messages in local-request event route

---

Modified: src/core/error.h
Modified: src/modules/tm/uac.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/7966f10292cb3c0d0c1ccda20c8475822b4e0993.diff
Patch: 
https://github.com/kamailio/kamailio/commit/7966f10292cb3c0d0c1ccda20c8475822b4e0993.patch

---

diff --git a/src/core/error.h b/src/core/error.h
index 829073e555..8ac763bf2d 100644
--- a/src/core/error.h
+++ b/src/core/error.h
@@ -48,6 +48,7 @@
 #define E_Q_EMPTY   -16 /* Empty q */
 #define E_Q_TOO_BIG -17 /* q too big (> 1) */
 #define E_Q_DEC_MISSING -18 /* Decimal part missing */
+#define E_DROP  -19 /* Dropped in script */
 
 
 
diff --git a/src/modules/tm/uac.c b/src/modules/tm/uac.c
index 1478853d3d..1112d7758c 100644
--- a/src/modules/tm/uac.c
+++ b/src/modules/tm/uac.c
@@ -239,6 +239,8 @@ static inline int t_run_local_req(
msg_ctx_id_t backup_ctxid;
int refresh_shortcuts = 0;
sr_kemi_eng_t *keng = NULL;
+   run_act_ctx_t ra_ctx;
+   run_act_ctx_t *bctx;
str evname = str_init("tm:local-request");
 
LM_DBG("executing event_route[tm:local-request]\n");
@@ -271,18 +273,24 @@ static inline int t_run_local_req(
tm_global_ctx_id.msgid=lreq.id;
tm_global_ctx_id.pid=lreq.pid;
set_t(new_cell, T_BR_UNDEFINED);
+  
+   init_run_actions_ctx(_ctx);
+   
if(goto_on_local_req>=0) {
-   run_top_route(event_rt.rlist[goto_on_local_req], , 0);
+   run_top_route(event_rt.rlist[goto_on_local_req], , 
_ctx);
} else {
keng = sr_kemi_eng_get();
if(keng==NULL) {
LM_WARN("event callback (%s) set, but no cfg engine\n",
tm_event_callback.s);
} else {
+   bctx = sr_kemi_act_ctx_get();
+   sr_kemi_act_ctx_set(_ctx);
if(sr_kemi_route(keng, , EVENT_ROUTE,
_event_callback, )<0) 
{
LM_ERR("error running event route kemi 
callback\n");
}
+   sr_kemi_act_ctx_set(bctx);
}
}
/* restore original environment */
@@ -296,6 +304,12 @@ static inline int t_run_local_req(
tm_xdata_swap(new_cell, _xd, 1);
setsflagsval(sflag_bk);
 
+   if (unlikely(ra_ctx.run_flags_R_F)) {
+   LM_DBG("tm:local-request dropped msg. to %.*s\n", 
+   lreq.dst_uri.len, lreq.dst_uri.s);
+   refresh_shortcuts = E_DROP;
+   goto clean;
+   }
/* rebuild the new message content */
if(lreq.force_send_socket != uac_r->dialog->send_sock) {
LM_DBG("Send socket updated to: %.*s",
@@ -350,6 +364,7 @@ static inline int t_run_local_req(
}
}
 
+clean:
/* clean local msg structure */
if (unlikely(lreq.new_uri.s))
{
@@ -514,6 +529,10 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
 #ifdef WITH_EVENT_LOCAL_REQUEST
if (unlikely(goto_on_local_req>=0 || tm_event_callback.len>0)) {
refresh_shortcuts = t_run_local_req(, _len, uac_r, 
new_cell, request);
+   if (unlikely(refresh_shortcuts==E_DROP)) {
+   ret=E_DROP;
+   goto error1;
+   }   
}
 #endif
 
@@ -605,6 +624,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
 int prepare_req_within(uac_req_t *uac_r,
struct retr_buf **dst_req)
 {
+   int ret = -1;
if (!uac_r || !uac_r->method || !uac_r->dialog) {
LM_ERR("Invalid parameter value\n");
goto err;
@@ -619,13 +639,17 @@ int prepare_req_within(uac_req_t *uac_r,
if ((uac_r->method->len == 6) && (!memcmp("CANCEL", uac_r->method->s, 
6))) goto send;
uac_r->dialog->loc_seq.value++; /* Increment CSeq */
  send:
-   return t_uac_prepare(uac_r, dst_req, 0);
+   ret = t_uac_prepare(uac_r, dst_req, 0);
+   
+   if (unlikely(ret < 0 && ret == E_DROP)) {
+   ret = 0;
+   }
 
  err:
/* if (cbp) shm_free(cbp); */
/* !! never free cbp here because if t_uac_prepare fails, cbp is not 
freed
 * and thus caller has no chance to discover if it is freed or not !! */
-   return -1;
+   return ret;
 }
 
 static inline int send_prepared_request_impl(struct retr_buf *request, int 
retransmit, int branch)
@@ -711,7 +735,14 @@ int t_uac_with_ids(uac_req_t *uac_r,

[sr-dev] git:master:2ad60234: tm: initialize the context before running event route

2019-11-25 Thread Federico Cabiddu
Module: kamailio
Branch: master
Commit: 2ad6023432ae37b1709638ead2c77e1e4130678a
URL: 
https://github.com/kamailio/kamailio/commit/2ad6023432ae37b1709638ead2c77e1e4130678a

Author: Federico Cabiddu 
Committer: Federico Cabiddu 
Date: 2019-11-25T09:14:40+01:00

tm: initialize the context before running event route

---

Modified: src/modules/tm/uac.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/2ad6023432ae37b1709638ead2c77e1e4130678a.diff
Patch: 
https://github.com/kamailio/kamailio/commit/2ad6023432ae37b1709638ead2c77e1e4130678a.patch

---

diff --git a/src/modules/tm/uac.c b/src/modules/tm/uac.c
index 9af3da951a..1112d7758c 100644
--- a/src/modules/tm/uac.c
+++ b/src/modules/tm/uac.c
@@ -273,6 +273,9 @@ static inline int t_run_local_req(
tm_global_ctx_id.msgid=lreq.id;
tm_global_ctx_id.pid=lreq.pid;
set_t(new_cell, T_BR_UNDEFINED);
+  
+   init_run_actions_ctx(_ctx);
+   
if(goto_on_local_req>=0) {
run_top_route(event_rt.rlist[goto_on_local_req], , 
_ctx);
} else {


___
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] tm: add support for dropping messages in local-request event route (#2147)

2019-11-25 Thread Federico Cabiddu
Merged #2147 into master.

-- 
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/2147#event-2829172430___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:00f4147a: tm: add support for dropping messages in local-request event route

2019-11-25 Thread Federico Cabiddu
Module: kamailio
Branch: master
Commit: 00f4147a410990d3ebeeef8825329bbdff728d1a
URL: 
https://github.com/kamailio/kamailio/commit/00f4147a410990d3ebeeef8825329bbdff728d1a

Author: Federico Cabiddu 
Committer: Federico Cabiddu 
Date: 2019-11-25T08:51:30+01:00

tm: add support for dropping messages in local-request event route

---

Modified: src/core/error.h
Modified: src/modules/tm/uac.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/00f4147a410990d3ebeeef8825329bbdff728d1a.diff
Patch: 
https://github.com/kamailio/kamailio/commit/00f4147a410990d3ebeeef8825329bbdff728d1a.patch

---

diff --git a/src/core/error.h b/src/core/error.h
index 829073e555..8ac763bf2d 100644
--- a/src/core/error.h
+++ b/src/core/error.h
@@ -48,6 +48,7 @@
 #define E_Q_EMPTY   -16 /* Empty q */
 #define E_Q_TOO_BIG -17 /* q too big (> 1) */
 #define E_Q_DEC_MISSING -18 /* Decimal part missing */
+#define E_DROP  -19 /* Dropped in script */
 
 
 
diff --git a/src/modules/tm/uac.c b/src/modules/tm/uac.c
index 1478853d3d..9af3da951a 100644
--- a/src/modules/tm/uac.c
+++ b/src/modules/tm/uac.c
@@ -239,6 +239,8 @@ static inline int t_run_local_req(
msg_ctx_id_t backup_ctxid;
int refresh_shortcuts = 0;
sr_kemi_eng_t *keng = NULL;
+   run_act_ctx_t ra_ctx;
+   run_act_ctx_t *bctx;
str evname = str_init("tm:local-request");
 
LM_DBG("executing event_route[tm:local-request]\n");
@@ -272,17 +274,20 @@ static inline int t_run_local_req(
tm_global_ctx_id.pid=lreq.pid;
set_t(new_cell, T_BR_UNDEFINED);
if(goto_on_local_req>=0) {
-   run_top_route(event_rt.rlist[goto_on_local_req], , 0);
+   run_top_route(event_rt.rlist[goto_on_local_req], , 
_ctx);
} else {
keng = sr_kemi_eng_get();
if(keng==NULL) {
LM_WARN("event callback (%s) set, but no cfg engine\n",
tm_event_callback.s);
} else {
+   bctx = sr_kemi_act_ctx_get();
+   sr_kemi_act_ctx_set(_ctx);
if(sr_kemi_route(keng, , EVENT_ROUTE,
_event_callback, )<0) 
{
LM_ERR("error running event route kemi 
callback\n");
}
+   sr_kemi_act_ctx_set(bctx);
}
}
/* restore original environment */
@@ -296,6 +301,12 @@ static inline int t_run_local_req(
tm_xdata_swap(new_cell, _xd, 1);
setsflagsval(sflag_bk);
 
+   if (unlikely(ra_ctx.run_flags_R_F)) {
+   LM_DBG("tm:local-request dropped msg. to %.*s\n", 
+   lreq.dst_uri.len, lreq.dst_uri.s);
+   refresh_shortcuts = E_DROP;
+   goto clean;
+   }
/* rebuild the new message content */
if(lreq.force_send_socket != uac_r->dialog->send_sock) {
LM_DBG("Send socket updated to: %.*s",
@@ -350,6 +361,7 @@ static inline int t_run_local_req(
}
}
 
+clean:
/* clean local msg structure */
if (unlikely(lreq.new_uri.s))
{
@@ -514,6 +526,10 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
 #ifdef WITH_EVENT_LOCAL_REQUEST
if (unlikely(goto_on_local_req>=0 || tm_event_callback.len>0)) {
refresh_shortcuts = t_run_local_req(, _len, uac_r, 
new_cell, request);
+   if (unlikely(refresh_shortcuts==E_DROP)) {
+   ret=E_DROP;
+   goto error1;
+   }   
}
 #endif
 
@@ -605,6 +621,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
 int prepare_req_within(uac_req_t *uac_r,
struct retr_buf **dst_req)
 {
+   int ret = -1;
if (!uac_r || !uac_r->method || !uac_r->dialog) {
LM_ERR("Invalid parameter value\n");
goto err;
@@ -619,13 +636,17 @@ int prepare_req_within(uac_req_t *uac_r,
if ((uac_r->method->len == 6) && (!memcmp("CANCEL", uac_r->method->s, 
6))) goto send;
uac_r->dialog->loc_seq.value++; /* Increment CSeq */
  send:
-   return t_uac_prepare(uac_r, dst_req, 0);
+   ret = t_uac_prepare(uac_r, dst_req, 0);
+   
+   if (unlikely(ret < 0 && ret == E_DROP)) {
+   ret = 0;
+   }
 
  err:
/* if (cbp) shm_free(cbp); */
/* !! never free cbp here because if t_uac_prepare fails, cbp is not 
freed
 * and thus caller has no chance to discover if it is freed or not !! */
-   return -1;
+   return ret;
 }
 
 static inline int send_prepared_request_impl(struct retr_buf *request, int 
retransmit, int branch)
@@ -711,7 +732,14 @@ int t_uac_with_ids(uac_req_t *uac_r,
branch_bm_t added_branches = 1;
 
ret = t_uac_prepare(uac_r, , );
-   if (ret < 0) return ret;
+   
+   if (ret < 0) {
+

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

2019-11-25 Thread alexyosifov
- fixed a defect reported from Coverity Scan - Concurrent data access
  violations in spi_gen.c for spi_data-spi_val.
- added a new conf param - ipsec_reuse_server_port - reuse or not
  PCSCF server port for UA Re-registration.
- added description for the new parameter in ims_ipsec_pcscf_admin.xml.
- in fill_contact() for Request messages set received host, port and
  proto fro request uri if alias is presented.
- A new server port is used for Re-registration, depending on the new
  parameter ipsec_reuse_server_port.
- in create_ipsec_tunnel() return -1 when unable to convert ip address.
- in ipsec_forward() add supported and require secagree headers only
  for Register reply with code 200. Set SND_F_FORCE_SOCKET for
  request messages.

!-- Kamailio Pull Request Template --

!--
IMPORTANT:
  - for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
  - pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
  - backports to stable branches must be done with git cherry-pick -x 
...
  - code is contributed under BSD for core and main components (tm, sl, auth, 
tls)
  - code is contributed GPLv2 or a compatible license for the other components
  - GPL code is contributed with OpenSSL licensing exception
--

 Pre-Submission Checklist
!-- Go over all points below, and after creating the PR, tick all the 
checkboxes that apply --
!-- All points should be verified, otherwise, read the CONTRIBUTING 
guidelines from above--
!-- If youre unsure about any of these, dont hesitate to ask on 
sr-dev mailing list --
- [ ] Commit message has the format required by CONTRIBUTING guide
- [ ] Commits are split per component (core, individual modules, libs, utils, 
...)
- [ ] Each component has a single commit (if not, squash them into one commit)
- [ ] No commits to README files for modules (changes must be done to docbook 
files
in `doc/` subfolder, the README file is autogenerated)

 Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)

 Checklist:
!-- Go over all points below, and after creating the PR, tick the 
checkboxes that apply --
- [ ] PR should be backported to stable branches
- [ ] Tested changes locally
- [ ] Related to issue # (replace  with an open issue number)

 Description
!-- Describe your changes in detail --

You can view, comment on, or merge this pull request online at:

  https://github.com/kamailio/kamailio/pull/2148

-- Commit Summary --

  * ims_ipsec_pcscf: fixed warnings, added a new config param

-- File Changes --

M src/modules/ims_ipsec_pcscf/cmd.c (209)
M src/modules/ims_ipsec_pcscf/doc/ims_ipsec_pcscf_admin.xml (22)
M src/modules/ims_ipsec_pcscf/ims_ipsec_pcscf_mod.c (2)
M src/modules/ims_ipsec_pcscf/spi_gen.c (14)

-- Patch Links --

https://github.com/kamailio/kamailio/pull/2148.patch
https://github.com/kamailio/kamailio/pull/2148.diff

-- 
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
___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] Kamailio developers meeting - follow up remarks

2019-11-25 Thread Daniel-Constantin Mierla
Hello,

one addition to section 8):

  * it was discussed if internal libraries still have a good purpose,
given low activity there and some of the libs there are used in a few
modules, which case also use intermodule API, while some are becoming
more like general purpose scope (json lib, with use in rpc control
interface, or uuid). There is also some complexity added to packaging
dependencies, as many packages we do with modules depend on same
internal lib. As a result, code from internal libs may be relocated over
time.

Cheers,
Daniel

On 22.11.19 09:59, Daniel-Constantin Mierla wrote:
> Hello,
>
> last week we had the 2nd annual Kamailio Developers Meeting hosted by
> Sipgate in Dusseldorf, Germany:
>
>   * https://www.kamailio.org/w/developers-meeting/
>
> 16 people were at the event in various roles.
>
> Giacomo Vacca published on his blog a good summary of what happened there:
>
>   *
> https://www.giacomovacca.com/2019/11/my-notes-on-kamailio-developer-meeting.html
>
> This year we had a lot of discussions, as well as work done on multiple
> planes, not only Kamailio code. So I am trying to list here some of the
> conclusions for future development, the technical aspects of the
> meeting, so everyone is aware and can provide feedback.
>
> 1) Effective work was done on:
>
>   * kamailio code
>   * kamailio rpm packaging
>   * kamailio tools (kamctl)
>   * kamailio release process
>   * kamailio project keys (to be used to sign the packages)
>
> 2) Documentation
>
> 2.a) Wiki
>
>   * it was somehow a rough consensus to move the wiki content to github,
> along with changing the format from dokuwiki markdown to the
> standard/github markdown. This should enable people to make pull
> requests so developers or community members can review and aprove new
> content. It also makes it easier to contribute using existing github
> account, now the kamailio.org/wiki is requiring to make a dedicated
> account, which many prefer not to do it.
>
>   * the presentation can be done either by using mkdocs to generate html
> files hosted on kamailio.org or using the github provided wiki portal.
>
>  2.b) Docs for variables and transformations
>
>   * there was a proposal to move them in the documentation the modules
> that export them, there are pros and cons, needs more discussions. Now
> they are in the wiki, so this probably has to resume after deciding on 2.a).
>
> 3) Kamailio Modules
>
> 3.a) replication (dmq) - several participants discussed about
> negotiations between nodes to take active role on some cases (e.g.,
> active dialogs)
>
> 3.b) api integration - quite some interest in JSON-based API routing,
> concluding in extending rtjson to cover more use cases
>
> 3.c) security - have options to restrict the use of TLS1.3 or newer
>
> 4) Kamailio Releases
>
>   * v5.3.2 was released during the event, allowing to document the process
>   * work to automatize the process is planned, then eventually assing
> teams for takeing cares of releases from specific branches
>
> 5) Kamailio Testing
>
>   * existing docker-based testing framework should be extended and
> integrated in CD/CI pipeline
>
> 6) Kamailio packages
>
> 6.a) rpms
>
>   * rpm.kamailio.org has been prepared and is expected to take over the
> opensuse build service for building rpms and hosting them. Expected to
> provide support for hosting many kamailio versions in the same release
> series so one can do downgrade to older releases. Also, there is work in
> progress to provide nightly builds.
>
> 6.b) debs
>
>   * work is planned to offer many kamailio versions in the same release
> series
>
> 7) Kamailio tools
>
>   * kamctl/kamdbctl should be obsoleted in favor of kamcli, which offers
> a better framework for input validation and output formatting, as well
> as better portability, no longer depending on shell interpreter
>
> 8) Various discussions
>
>   * kemi exports from C point of view and how to combine the
> documentation for modules and their kemi exports
>   * how to make kamaiio friendlier in virtualized environments (ended up
> in the need of making the use of advertised address a bit more dynamic)
>   * project organizatoric topics - to be approached separately
>   * next events - Fosdem - someone should submit a proposal to present
> about Kamailio
>
> 9) Long term goals
>
> We speak here more or less about Kamailio 6.0 ...
>
>   * change the behaviour of the native config interpreter to be
> consistent with the other programming languages in terms of handling the
> response code (change what is now: the evaluation of negative value to
> false and positive value to true and the hidden return 0 to exit)
>
>   * make the pool of processes more generic, so they can handle traffic
> from more sockets (being sip traffic or something else) -- this should
> make better use of resources, as some sockets might be less busy that others
>
> I hope I covered the important topics, if I remember something else, I
> will reply on this thread. Or 

Re: [sr-dev] [kamailio/kamailio] tm: add support for dropping messages in local-request event route (#2147)

2019-11-25 Thread Federico Cabiddu
I did put it in the core to avoid conflicts with other returned codes and for 
beeing used in the future (in case). I'll leave it in the core.

-- 
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/2147#issuecomment-558148176___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:d48ae799: app_lua_sr: use snprintf() instead of sprintf()

2019-11-25 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: d48ae7995374ee4be01cdd28b4f65706a04b620c
URL: 
https://github.com/kamailio/kamailio/commit/d48ae7995374ee4be01cdd28b4f65706a04b620c

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2019-11-25T12:02:01+01:00

app_lua_sr: use snprintf() instead of sprintf()

---

Modified: src/modules/app_lua_sr/app_lua_sr_exp.c

---

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

---

diff --git a/src/modules/app_lua_sr/app_lua_sr_exp.c 
b/src/modules/app_lua_sr/app_lua_sr_exp.c
index 7218b206f2..3dab788436 100644
--- a/src/modules/app_lua_sr/app_lua_sr_exp.c
+++ b/src/modules/app_lua_sr/app_lua_sr_exp.c
@@ -655,7 +655,7 @@ static int lua_sr_tm_t_on_branch_failure(lua_State *L)
}
rt_name.len = rt_name_len;
}
-   sprintf(rt_name.s, "%s:%s", BRANCH_FAILURE_ROUTE_PREFIX, name);
+   snprintf(rt_name.s, rt_name_len+1, "%s:%s", 
BRANCH_FAILURE_ROUTE_PREFIX, name);
 
i = route_get(_rt, rt_name.s);
if(i < 0 || event_rt.rlist[i]==0)


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:7be06d44: pike: use snprintf() instead of sprintf()

2019-11-25 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 7be06d444a0ca295e53efadb093f07e19a18cea8
URL: 
https://github.com/kamailio/kamailio/commit/7be06d444a0ca295e53efadb093f07e19a18cea8

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2019-11-25T11:29:16+01:00

pike: use snprintf() instead of sprintf()

---

Modified: src/modules/pike/pike_top.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/7be06d444a0ca295e53efadb093f07e19a18cea8.diff
Patch: 
https://github.com/kamailio/kamailio/commit/7be06d444a0ca295e53efadb093f07e19a18cea8.patch

---

diff --git a/src/modules/pike/pike_top.c b/src/modules/pike/pike_top.c
index 662f26a5de..62d23b0fc3 100644
--- a/src/modules/pike/pike_top.c
+++ b/src/modules/pike/pike_top.c
@@ -41,22 +41,28 @@ char *pike_top_print_addr( unsigned char *ip, int iplen, 
char *buff,
int buffsize )
 {
unsigned short *ipv6_ptr = (unsigned short *)ip;
-   memset(buff, 0, PIKE_BUFF_SIZE*sizeof(char));
+   int bsize;
+   int blen;
+
+   bsize = PIKE_BUFF_SIZE*sizeof(char);
+   memset(buff, 0, bsize);
 
DBG("pike:top:print_addr(iplen: %d, buffsize: %d)", iplen, buffsize);
 
if ( iplen == 4 ) {
inet_ntop(AF_INET, ip, buff, buffsize);
-   }
-   else if ( iplen == 16 ) {
+   } else if ( iplen == 16 ) {
inet_ntop(AF_INET6, ip, buff, buffsize);
-   }
-   else {
-   sprintf( buff, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
+   } else {
+   blen = snprintf(buff, bsize, 
"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
htons(ipv6_ptr[0]), htons(ipv6_ptr[1]), 
htons(ipv6_ptr[2]),
htons(ipv6_ptr[3]),
htons(ipv6_ptr[4]), htons(ipv6_ptr[5]), 
htons(ipv6_ptr[6]),
htons(ipv6_ptr[7]));
+   if(blen < 0 || blen >= bsize) {
+   LM_ERR("failed to print the address - reset it\n");
+   memset(buff, 0, bsize);
+   }
}
 
return buff;


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:f39f7320: tm: use snprintf() instead of sprintf()

2019-11-25 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: f39f73204d53312612ef2c3d3cec9c2fd51532c7
URL: 
https://github.com/kamailio/kamailio/commit/f39f73204d53312612ef2c3d3cec9c2fd51532c7

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2019-11-25T11:54:36+01:00

tm: use snprintf() instead of sprintf()

---

Modified: src/modules/tm/tm.c

---

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

---

diff --git a/src/modules/tm/tm.c b/src/modules/tm/tm.c
index 6cbdaf1776..ba6fc82c74 100644
--- a/src/modules/tm/tm.c
+++ b/src/modules/tm/tm.c
@@ -538,21 +538,27 @@ static int fixup_on_failure(void** param, int param_no)
 static int fixup_on_branch_failure(void** param, int param_no)
 {
char *full_route_name = NULL;
-   int len;
+   int blen =0;
+   int bsize = 0;
int ret = 0;
-   if (param_no==1){
-   if((len = strlen((char*)*param))<=1
-   && (*(char*)(*param)==0 || 
*(char*)(*param)=='0')) {
+   if (param_no==1) {
+   bsize = strlen((char*)*param);
+   if((bsize <=1) && (*(char*)(*param)==0 || 
*(char*)(*param)=='0')) {
*param = (void*)0;
return 0;
}
-   len += strlen(BRANCH_FAILURE_ROUTE_PREFIX) + 1;
-   if ((full_route_name = pkg_malloc(len+1)) == NULL)
-   {
+   bsize += strlen(BRANCH_FAILURE_ROUTE_PREFIX) + 2;
+   if ((full_route_name = pkg_malloc(bsize)) == NULL) {
LM_ERR("No memory left in branch_failure fixup\n");
return -1;
}
-   sprintf(full_route_name, "%s:%s", BRANCH_FAILURE_ROUTE_PREFIX, 
(char*)*param);
+   blen = snprintf(full_route_name, bsize, "%s:%s",
+   BRANCH_FAILURE_ROUTE_PREFIX, 
(char*)*param);
+   if(blen<0 || blen>=bsize) {
+   LM_ERR("Failure to construct route block name\n");
+   pkg_free(full_route_name);
+   return -1;
+   }
*param=(void*)full_route_name;
ret = fixup_routes("t_on_branch_failure", _rt, param);
pkg_free(full_route_name);


___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] git:master:dadbc0cf: sl: use snprintf() instead of sprintf()

2019-11-25 Thread Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: dadbc0cf4a3a198e7a3791d830ed2cd5ffa8bfdd
URL: 
https://github.com/kamailio/kamailio/commit/dadbc0cf4a3a198e7a3791d830ed2cd5ffa8bfdd

Author: Daniel-Constantin Mierla 
Committer: Daniel-Constantin Mierla 
Date: 2019-11-25T11:21:08+01:00

sl: use snprintf() instead of sprintf()

---

Modified: src/modules/sl/sl_funcs.c

---

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

---

diff --git a/src/modules/sl/sl_funcs.c b/src/modules/sl/sl_funcs.c
index 3c74955e7e..c832f4fb09 100644
--- a/src/modules/sl/sl_funcs.c
+++ b/src/modules/sl/sl_funcs.c
@@ -237,6 +237,7 @@ int sl_reply_helper(struct sip_msg *msg, int code, char 
*reason, str *tag)
struct cseq_body *cseqb;
char *tmp2;
int len;
+   int tsize;
 
if ((hf = (hdr_field_t*) 
pkg_malloc(sizeof(struct hdr_field))) == NULL)
{
@@ -251,8 +252,9 @@ int sl_reply_helper(struct sip_msg *msg, int code, char 
*reason, str *tag)
goto event_route_error;
}
 
-   if ((tmp = (char *) pkg_malloc(sizeof(char)
-   * 
(msg->first_line.u.request.method.len + 5))) == NULL)
+   tsize = sizeof(char)
+   * 
(msg->first_line.u.request.method.len + 5);
+   if ((tmp = (char *) pkg_malloc(tsize)) == NULL)
{
LM_ERR("out of package memory\n");
pkg_free(cseqb);
@@ -263,9 +265,16 @@ int sl_reply_helper(struct sip_msg *msg, int code, char 
*reason, str *tag)
memset(hf, 0, sizeof(struct hdr_field));
memset(cseqb, 0, sizeof(struct cseq_body));
 
-   len = sprintf(tmp, "0 %.*s\r\n",
+   len = snprintf(tmp, tsize, "0 %.*s\r\n",

msg->first_line.u.request.method.len,

msg->first_line.u.request.method.s);
+   if(len<0 || len>tsize) {
+   LM_ERR("failed to print the tmp 
cseq\n");
+   pkg_free(tmp);
+   pkg_free(cseqb);
+   pkg_free(hf);
+   goto event_route_error;
+   }
tmp2 = parse_cseq(tmp, [len], cseqb);
 
hf->type = HDR_CSEQ_T;


___
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] cancel the branches instantly instead of on provisional replies (#909)

2019-11-25 Thread aqsyounas
@henningw i don't think i would need this at the moment. You may close this if 
nobody else need it :)
Thanks for the awesome works you guys are doing.  

-- 
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/909#issuecomment-558095856___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] removing xprint module

2019-11-25 Thread Daniel-Constantin Mierla
Hello,

actually there are modules still using code from it:

src/modules/db2_ops/db2_ops.c
34:#include "../../modules/xprint/xp_lib.h"

src/modules/avp/avp.c
50:#include "../xprint/xp_lib.h"

Then I am aware ofa few (initially) ser-based deployed that still have it.

In general, the removal of a module with config functions should be
asked on sr-users, that's where potentially users may be found.

Cheers,
Daniel

On 23.11.19 21:24, Henning Westerholt wrote:
>
> Hello,
>
>  
>
> From the xprint module README:
>
>  
>
> The xprint module is the former xlog module from SIP Express Router
> (SER), kept because it is used by other modules via API to get the
> value for strings with specifiers. If you want to print log messages
> from configuration file, use the real module named 'xlog'.
>
>  
>
> I just checked, there seems to be no module using it anymore.
> Therefore, I would like to propose to remove it in git master.
>
>  
>
> /repositories/kamailio$ grep -R xl_api * | egrep -v "modules/xprint"
>
> /repositories/kamailio$
>
>  
>
> Cheers,
>
>  
>
> Henning
>
>  
>
> -- 
>
> Henning Westerholt – https://skalatan.de/blog/
>
> Kamailio services – https://gilawa.com 
>
> Kamailio Merchandising – https://skalatan.de/merchandising
>
>  
>
>
> ___
> Kamailio (SER) - Development Mailing List
> sr-dev@lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference - April 27-29, 2020, in Berlin -- 
www.kamailioworld.com

___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] git:master:7fad9c51: app_sqlang: fix squirrel warning: ‘nArgs’ may be used uninitialized in this function

2019-11-25 Thread Daniel-Constantin Mierla
Hello,

this change has to be pushed to the upstream project, otheriwse with the
next sync it is going to be lost -- we do not maintain the code of
squirrel interpreter, it is used as an embedded library. The project is at:

  * https://github.com/albertodemichelis/squirrel

Cheers,
Daniel

On 23.11.19 18:54, Henning Westerholt wrote:
> Module: kamailio
> Branch: master
> Commit: 7fad9c51f71854e0649fe76e273190e4b4f82438
> URL: 
> https://github.com/kamailio/kamailio/commit/7fad9c51f71854e0649fe76e273190e4b4f82438
>
> Author: Henning Westerholt 
> Committer: Henning Westerholt 
> Date: 2019-11-23T18:53:17+01:00
>
> app_sqlang: fix squirrel warning: ‘nArgs’ may be used uninitialized 
> in this function
>
> ---
>
> Modified: src/modules/app_sqlang/squirrel/squirrel/sqbaselib.cpp
>
> ---
>
> Diff:  
> https://github.com/kamailio/kamailio/commit/7fad9c51f71854e0649fe76e273190e4b4f82438.diff
> Patch: 
> https://github.com/kamailio/kamailio/commit/7fad9c51f71854e0649fe76e273190e4b4f82438.patch
>
> ---
>
> diff --git a/src/modules/app_sqlang/squirrel/squirrel/sqbaselib.cpp 
> b/src/modules/app_sqlang/squirrel/squirrel/sqbaselib.cpp
> index f3b8103185..fb6545f921 100644
> --- a/src/modules/app_sqlang/squirrel/squirrel/sqbaselib.cpp
> +++ b/src/modules/app_sqlang/squirrel/squirrel/sqbaselib.cpp
> @@ -625,7 +625,7 @@ static SQInteger __map_array(SQArray *dest,SQArray 
> *src,HSQUIRRELVM v) {
>  SQObject  = stack_get(v, 2);
>  v->Push(closure);
>  
> -SQInteger nArgs;
> +SQInteger nArgs = 0;
>  if(sq_type(closure) == OT_CLOSURE) {
>  nArgs = _closure(closure)->_function->_nparameters;
>  }
>
>
>
> ___
> Kamailio (SER) - Development Mailing List
> sr-dev@lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference - April 27-29, 2020, in Berlin -- 
www.kamailioworld.com

___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


Re: [sr-dev] git:master:063e6a02: core: increase SHM memory pool to 128 MB

2019-11-25 Thread Daniel-Constantin Mierla
Hello,

On 23.11.19 23:23, Henning Westerholt wrote:
> Module: kamailio
> Branch: master
> Commit: 063e6a025b8ca0163af2147f057d29447c6f9760
> URL: 
> https://github.com/kamailio/kamailio/commit/063e6a025b8ca0163af2147f057d29447c6f9760
>
> Author: Henning Westerholt 
> Committer: Henning Westerholt 
> Date: 2019-11-23T22:49:28+01:00
>
> core: increase SHM memory pool to 128 MB
>
> - increase SHM memory pool to 128 MB
> - even an embedded system like Raspberry Pi has 1 GB RAM nowadays
> - make it less likely that new users run into issues because of lack of memory

I am curious about the last remark, can you priovide more details on
issues for new uses because lack of memory? I haven't noticed and such
report on mailling lists or issue tracker later, whondering if it is
some particular use case that can lead to this issue.

Because a start of kamailio with default config file is using less than
3MB of shared memory, being plenty of space to fill up to 64MB with
registrations, transactions, etc... states taken a few minutes ago with
git master branch:

    "shmem:max_used_size = 2836288",
    "shmem:real_used_size = 2836288",
    "shmem:used_size = 2594376"

Then, my actual remark is that I think the new users tend to use the
packages, which use init.d/systemd to start kamailio, and there are
values for pkg and shm sizes in the unit files, so this change doesn't
really make a difference, because kamailio is started with different -m
and -M command line parameters.

Cheers,
Daniel

>
> [...]
>
-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference - April 27-29, 2020, in Berlin -- 
www.kamailioworld.com


___
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] tm: add support for dropping messages in local-request event route (#2147)

2019-11-25 Thread Daniel-Constantin Mierla
If you keep it in core, then E_DROP is fine, it can be used in the future for 
similar purposes. If you rename it and make it specific to tm usage for local 
request route, then place the define in the tm module. We should not populate 
core with module specific needs.

-- 
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/2147#issuecomment-558071971___
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] tm: add support for dropping messages in local-request event route (#2147)

2019-11-25 Thread Henning Westerholt
Ok, this might be better understandable in the years to come. :-) Good 
addition, 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/2147#issuecomment-558069222___
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] tm: add support for dropping messages in local-request event route (#2147)

2019-11-25 Thread Federico Cabiddu
I haven't spotted any other usage for the moment. I could rename it like 
E_LOCAL_DROP. 

-- 
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/2147#issuecomment-558067764___
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] tm: add support for dropping messages in local-request event route (#2147)

2019-11-25 Thread Henning Westerholt
One remark - the E_DROP error is planned to be used for all kinds of drop() or 
only for the local request event route type? If the latter - maybe making the 
name a bit more specific to highlight that is only used for this particular 
case.

-- 
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/2147#issuecomment-558053706___
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] tm: add support for dropping messages in local-request event route (#2147)

2019-11-25 Thread Daniel-Constantin Mierla
OK, fine for me.

-- 
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/2147#issuecomment-558049490___
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] tm: add support for dropping messages in local-request event route (#2147)

2019-11-25 Thread Federico Cabiddu
right, added now.

-- 
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/2147#issuecomment-558041500___
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] tm: add support for dropping messages in local-request event route (#2147)

2019-11-25 Thread Federico Cabiddu
@grumvalski pushed 1 commit.

2ad6023432ae37b1709638ead2c77e1e4130678a  tm: initialize the context before 
running event route


-- 
You are receiving this because you are subscribed to this thread.
View it on GitHub:
https://github.com/kamailio/kamailio/pull/2147/files/b58bfec2413a09568343fa1e2b2e199cfaa2e1fa..2ad6023432ae37b1709638ead2c77e1e4130678a
___
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] tm: add support for dropping messages in local-request event route (#2147)

2019-11-25 Thread Federico Cabiddu
@grumvalski pushed 1 commit.

b58bfec2413a09568343fa1e2b2e199cfaa2e1fa  tm: initialize the context before 
running event route


-- 
You are receiving this because you are subscribed to this thread.
View it on GitHub:
https://github.com/kamailio/kamailio/pull/2147/files/00f4147a410990d3ebeeef8825329bbdff728d1a..b58bfec2413a09568343fa1e2b2e199cfaa2e1fa
___
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] tm: add support for dropping messages in local-request event route (#2147)

2019-11-25 Thread Daniel-Constantin Mierla
Thanks!

I couldn't spot quickly the initialization of the context, something like:

```
init_run_actions_ctx(_ctx);
```

-- 
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/2147#issuecomment-558039570___
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] force_send_socket with pseudo variable (#2145)

2019-11-25 Thread Henning Westerholt
I've added a short note about it to the 5.3 and devel cookbook.
IMHO we should think about removing this old redundant functions, at least if 
there are several newer implementation, where one is functional equivalent.
I was already discussed one year ago, without conclusion: 
[link](http://sip-router.1086192.n5.nabble.com/force-send-socket-fs-behaviour-when-binding-to-INADDR-ANY-td140353.html)

-- 
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/2145#issuecomment-558038851___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev


[sr-dev] [kamailio/kamailio] tm: add support for dropping messages in local-request event route (#2147)

2019-11-25 Thread Federico Cabiddu
!-- Kamailio Pull Request Template --

!--
IMPORTANT:
  - for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
  - pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
  - backports to stable branches must be done with git cherry-pick -x 
...
  - code is contributed under BSD for core and main components (tm, sl, auth, 
tls)
  - code is contributed GPLv2 or a compatible license for the other components
  - GPL code is contributed with OpenSSL licensing exception
--

 Pre-Submission Checklist
!-- Go over all points below, and after creating the PR, tick all the 
checkboxes that apply --
!-- All points should be verified, otherwise, read the CONTRIBUTING 
guidelines from above--
!-- If youre unsure about any of these, dont hesitate to ask on 
sr-dev mailing list --
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, 
...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook 
files
in `doc/` subfolder, the README file is autogenerated)

 Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)

 Checklist:
!-- Go over all points below, and after creating the PR, tick the 
checkboxes that apply --
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue # (replace  with an open issue number)

 Description
!-- Describe your changes in detail --
Currently it is not possible to drop a local generated message in 
tm:local-request event route because there is no context associated when 
running the event route. With this PR I tried to solve this introducing a new 
returned error (E_DROP) and a context into t_run_local_req.
You can view, comment on, or merge this pull request online at:

  https://github.com/kamailio/kamailio/pull/2147

-- Commit Summary --

  * tm: add support for dropping messages in local-request event route

-- File Changes --

M src/core/error.h (1)
M src/modules/tm/uac.c (36)

-- Patch Links --

https://github.com/kamailio/kamailio/pull/2147.patch
https://github.com/kamailio/kamailio/pull/2147.diff

-- 
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/2147
___
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev