Module: kamailio
Branch: master
Commit: 3af6fa666f0291b6182cc80f1a498f0c066b5185
URL: https://github.com/kamailio/kamailio/commit/3af6fa666f0291b6182cc80f1a498f0…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2016-04-11T18:06:14+02:00
core: added generic interface for kamailio embedded api
---
Added: kemi.c
Added: kemi.h
---
Diff: https://github.com/kamailio/kamailio/commit/3af6fa666f0291b6182cc80f1a498f0…
Patch: https://github.com/kamailio/kamailio/commit/3af6fa666f0291b6182cc80f1a498f0…
---
diff --git a/kemi.c b/kemi.c
new file mode 100644
index 0000000..fa3ad8f
--- /dev/null
+++ b/kemi.c
@@ -0,0 +1,29 @@
+/**
+ * Copyright (C) 2016 Daniel-Constantin Mierla (asipto.com)
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "dprint.h"
+
+#include "kemi.h"
+
diff --git a/kemi.h b/kemi.h
new file mode 100644
index 0000000..cc49212
--- /dev/null
+++ b/kemi.h
@@ -0,0 +1,77 @@
+/**
+ * Copyright (C) 2016 Daniel-Constantin Mierla (asipto.com)
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef _SR_KEMI_H_
+#define _SR_KEMI_H_
+
+#include "str.h"
+#include "parser/msg_parser.h"
+
+#define SR_KEMIP_NONE (0)
+#define SR_KEMIP_INT (1<<0)
+#define SR_KEMIP_STR (1<<1)
+#define SR_KEMIP_BOOL (1<<2)
+
+#define SR_KEMI_PARAMS_MAX 6
+
+typedef struct sr_kemi {
+ str mname;
+ str fname;
+ int rtype;
+ void *func;
+ int ptypes[SR_KEMI_PARAMS_MAX];
+} sr_kemi_t;
+
+typedef struct sr_kemi_item {
+ sr_kemi_t *item;
+ int nparams;
+ struct sr_kemi_item *next;
+} sr_kemi_item_t;
+
+typedef union {
+ int n;
+ str s;
+} sr_kemi_val_t;
+
+/* only sip_msg_t */
+typedef int (*sr_kemi_fm_f)(sip_msg_t*);
+
+/* sip_msg_t and one int|str param */
+typedef int (*sr_kemi_fmn_f)(sip_msg_t*, int);
+typedef int (*sr_kemi_fms_f)(sip_msg_t*, str*);
+
+/* sip_msg_t and two int|str param */
+typedef int (*sr_kemi_fmnn_f)(sip_msg_t*, int, int);
+typedef int (*sr_kemi_fmns_f)(sip_msg_t*, int, str*);
+typedef int (*sr_kemi_fmsn_f)(sip_msg_t*, str*, int);
+typedef int (*sr_kemi_fmss_f)(sip_msg_t*, str*, str*);
+
+/* sip_msg_t and three int|str param */
+typedef int (*sr_kemi_fmnnn_f)(sip_msg_t*, int, int, int);
+typedef int (*sr_kemi_fmnns_f)(sip_msg_t*, int, int, str*);
+typedef int (*sr_kemi_fmnsn_f)(sip_msg_t*, int, str*, int);
+typedef int (*sr_kemi_fmnss_f)(sip_msg_t*, int, str*, str*);
+typedef int (*sr_kemi_fmsnn_f)(sip_msg_t*, str*, int, int);
+typedef int (*sr_kemi_fmsns_f)(sip_msg_t*, str*, int, str*);
+typedef int (*sr_kemi_fmssn_f)(sip_msg_t*, str*, str*, int);
+typedef int (*sr_kemi_fmsss_f)(sip_msg_t*, str*, str*, str*);
+
+#endif
Version 4.3.4 fails to escape the string that contains Unicode characters:
$var(test) = "Foobar s.à.r.l.";
$var(test_escaped) = $(var(test){s.escape.user});
Mar 23 16:00:28 sp1 (local7.err) proxy[27853]: ERROR: <core> [strcommon.c:241]: escape_user(): invalid escaped character <4294967235>
Mar 23 16:00:28 sp1 (local7.err) proxy[27853]: ERROR: <core> [lvalue.c:345]: lval_pvar_assign(): non existing right pvar
Mar 23 16:00:28 sp1 (local7.err) proxy[27853]: ERROR: <core> [lvalue.c:405]: lval_assign(): assignment failed at pos: (701,35-701,97)
is there a way to ignore those characters or is it something we have to live with?
Some background: we are storing some user-defined data as custom attributes in acc src_leg/dst_leg. As you know the fields in src/dst_leg are pipe-separated. In order to prevent the user from hijacking the attributes we have devided to escape the user-provided fields. This is when we realized that this is limited to latin1 encoding. In theory we can escape it using lua just wanted to avoid the overhead of calling the interpreter too often.
---
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/549
Experiencing an issue with QMalloc when Kamailio receives a lot of subscriptions (dialog-info) in a short period of time. The following is reported in logs and the TCP (TLS) connection fails:
```Apr 4 18:06:04 ua-proxy-01 /usr/local/sbin/kamailio[28456]: ERROR: <core> [tcp_main.c:959]: tcpconn_new(): mem. allocation failure
Apr 4 18:06:04 ua-proxy-01 /usr/local/sbin/kamailio[28456]: ERROR: <core> [tcp_main.c:3977]: handle_new_connect(): tcpconn_new failed, closing socket```
A snapshot of SHM usage from around the time of the connection is as follows:
```shmem:fragments = 39604
shmem:free_size = 49473400
shmem:max_used_size = 67108696
shmem:real_used_size = 17635464
shmem:total_size = 67108864
shmem:used_size = 9423760```
Kamailio `-I` output is as follows:
```Print out of kamailio internals
Version: kamailio 4.3.4 (x86_64/linux) b2843e
Default config: /usr/local/etc/kamailio/kamailio.cfg
Default paths to modules: /usr/local/lib64/kamailio/modules
Compile flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, DBG_QM_MALLOC, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
MAX_RECV_BUFFER_SIZE=262144
MAX_LISTEN=16
MAX_URI_SIZE=1024
BUF_SIZE=65535
DEFAULT PKG_SIZE=8MB
DEFAULT SHM_SIZE=64MB
ADAPTIVE_WAIT_LOOPS=1024
TCP poll methods: poll, epoll_lt, epoll_et, sigio_rt, select
Source code revision ID: b2843e
Compiled with: gcc 4.7.2
Compiled on: 17:56:04 Apr 4 2016
Thank you for flying kamailio!```
Once it has gotten in this state, TCP connections will no longer work, regardless of how low the SHM gets. Other connections (UDP) and subscriptions (dialog-info) work correctly at this time. There are no other OOM errors in the logs. The only thing that will resolve the issue is to restart Kamailio.
Compiling to use FMalloc (`MEMMNG=0 MEMDBG=1 make cfg`) appears to resolve the issue. Kamailio `-I` output as follows:
```Print out of kamailio internals
Version: kamailio 4.3.4 (x86_64/linux) b2843e
Default config: /usr/local/etc/kamailio/kamailio.cfg
Default paths to modules: /usr/local/lib64/kamailio/modules
Compile flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, F_MALLOC, DBG_F_MALLOC, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
MAX_RECV_BUFFER_SIZE=262144
MAX_LISTEN=16
MAX_URI_SIZE=1024
BUF_SIZE=65535
DEFAULT PKG_SIZE=8MB
DEFAULT SHM_SIZE=64MB
ADAPTIVE_WAIT_LOOPS=1024
TCP poll methods: poll, epoll_lt, epoll_et, sigio_rt, select
Source code revision ID: b2843e
Compiled with: gcc 4.7.2
Compiled on: 18:07:19 Apr 4 2016
Thank you for flying kamailio!```
At the time the TCP connection works correctly, the SHM usage is:
```shmem:fragments = 40669
shmem:free_size = 51558136
shmem:max_used_size = 67107816
shmem:real_used_size = 15550728
shmem:total_size = 67108864
shmem:used_size = 10045520```
---
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/562
When attempting to start kamailio built from the 4.4 branch at commit cf3457f, it dumps core.
```
Reading symbols from /usr/sbin/kamailio...Reading symbols from /usr/lib/debug/usr/sbin/kamailio.debug...done.
done.
[New LWP 19570]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `/usr/sbin/kamailio -c'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000000000447026 in cnt_hash_add (group=0x71fd26, name=0x7202b8, flags=369, cbk=0x71fd10 <__func__.6293>, param=0x6371d5 <fm_realloc+4612>, doc=0x7ffd0c70dd30 "\f\336p\f\375\177") at counters.c:328
328 doc_len = doc?strlen(doc):0;
(gdb) bt full
#0 0x0000000000447026 in cnt_hash_add (group=0x71fd26, name=0x7202b8, flags=369, cbk=0x71fd10 <__func__.6293>, param=0x6371d5 <fm_realloc+4612>, doc=0x7ffd0c70dd30 "\f\336p\f\375\177") at counters.c:328
e = 0x0
cnt_rec = 0x489159e
grp_rec = 0x7ffd0c70e2a0
p = 0x0
v = 0xffffffffb8ec5010
doc_len = 0
n = 32691
__func__ = "cnt_hash_add"
#1 0x00000000004491b8 in counter_get_name (handle=...) at counters.c:684
__llevel = 32691
__func__ = "counter_get_name"
#2 0x000000000044b6eb in ip_addr2sbuf (ip=0x771d60, buff=0xa081e0 <core_cfg_def+544> "\200ܫ", len=0) at ./ip_addr.h:658
__llevel = 1
__func__ = "ip_addr2sbuf"
#3 0x000000000051aaa0 in fix_sock_str (si=0xffffffff0c70e1e0) at socket_info.c:443
__llevel = 0
len = -1
__func__ = "fix_sock_str"
#4 0x00007fb3b96e6580 in __libc_start_main (main=0x517fd2 <add_alias+381>, argc=2, argv=0x7ffd0c70e2a8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffd0c70e298) at libc-start.c:289
result = <optimized out>
unwind_buf = {cancel_jmp_buf = {{jmp_buf = {0, -7223469352753121223, 4288480, 140724812178080, 0, 0, 7222380612212668473, 7252597343634765881}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x712580 <__libc_csu_init+32>,
0x7ffd0c70e2a8}, data = {prev = 0x0, cleanup = 0x0, canceltype = 7415168}}}
not_first_call = <optimized out>
#5 0x0000000000417009 in _start ()
No symbol table info available.
```
---
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/560
Hi guys!
I am developing custom kamailio module in which I am parsing some
properties from incoming SIP messages and I am persisting them within
linked list of my custom structure.
I am also accessing this linked list and I am deciding on the data which
part of my program will be executed. I am also at some point removing items
from linked list.
I was testing my module only in single fork while I was developing it but
now I want to use it with multiple forks. My linked list is allocated via
`shm_malloc` function and all data within it as well. I assumed that I need
to allocate some lock as well so at the time of creation single node I am
allocating lock by
http://www.asipto.com/pub/kamailio-devel-guide/#c03lock_init
Unfortunately I didn't find anywhere how should I access this kind of data.
Do I need to check every time I want to access my structure if the lock is
unlocked and if I am accessing it I need to lock it? Or are these actions
performed by kamailio internally?
Another question is if it is sufficient to have one lock per structure or I
need to lock every structure within that structure? For instance:
typedef struct node {
char *some_property;
another_node_t *some_other_property;
another_node_t *another_property;
struct node *prev;
struct node *next;
gen_lock_t *lock;
} node_t;
In this scenario do I need create `gen_lock_t` also within `another_node_t`
structure?
Thanks in advance for any help