ACC module cdr_extra modparam allows saving additional custom values in cdr entries using dlg_vars.
When you define a new value to be saved:
modparam("acc", "cdr_extra", "c1=$dlg_var(caller)")
and you set a $dlg_var(c1) in the logic, everything works as expected.
But if you set it to $null or you don't even define it, it is saved as '' (empty string).
Would be nice that setting to $null would store the underlying null value (NULL in SQL database) and not defining it would lead to not even including it in the final INSERT?
Define a new value to be saved:
modparam("acc", "cdr_extra", "c1=$dlg_var(caller)")
And in the kamailio.cfg logic:
If you set $dlg_var(c1) to any string ('', 'foo', '2'), it is saved as expected ('', 'foo', '2').
If you set $dlg_var(c1) to an integer different from 0 (1, 2, 3), it is saved as a string containing that number ('1', '2', '3'). This seems normal as dlg_vars can only store strings.
If you set $dlg_var(c1) to 0, it is saved as an empty string (''). Seems normal too.
If you set $dlg_var(c1) to $null, it is saved as an empty string ('').
If you don't define $dlg_var(c1) at all, it is saved as an empty string ('').
Both extra2strar and extra2strar_dlg_only functions defined in acc_extra.c set cdr_type_array entry to TYPE_NULL, but that array is not used in subsequent for loop.
Modify the logic in the for loop so that it invokes VAL_NULL macro for null values using cdr_type_array.
With this change both $null values and undefined values would use underlying NULL value. I could try to make further changes to avoid the key in the insert for undefined values instead of setting it to NULL.
kamailio -v
version: kamailio 4.4.6 (x86_64/linux) 0a8379-dirty
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 0a8379 -dirty
compiled on 12:23:36 Dec 20 2017 with gcc 6.3.0
Linux 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u3 (2017-08-06) x86_64 GNU/Linux
Is there any reason I missed for not doing this change (this comment makes me think so)? If not, I can try to provide a PR with these changes.
Regards,
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.