Hello,
following the recent new feature of #!ifexp based on snexpr
(https://www.kamailio.org/w/2022/09/ifexp-conditional-preprocessor-blocks/),
another preprocessor directive was added which allows defining IDs with
a value computed from the evaluation of an expression, respectively:
#!defexp ID EXP
The EXP can be any expression supported by snexpr, including the
previously defined IDs. For example:
#!define IPADDR 1.2.3.4
#!define PORT 5060
#!defexp SIPURI "sip:" + IPADDR + ":" + PORT
The result is that SIPURI is defined to sip:1.2.3.4:5060.
Another variant is available as #!defexps, which encloses the result of
the expression in double quotes, making it suitable to be used further
as string value:
#!defexps SIPURI "sip:" + IPADDR + ":" + PORT
The result is that SIPURI is defined to “sip:1.2.3.4:5060”.
More details at:
- https://www.kamailio.org/wikidocs/cookbooks/devel/core/#defexp
- https://www.kamailio.org/wikidocs/cookbooks/devel/core/#defexps
Testing would be appreciated, feedback can be addressed to sr-users
mailing list!
Cheers,
Daniel
--
Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - Online
Nov 7-10, 2022 (Europe Timezone)
* https://www.asipto.com/sw/kamailio-advanced-training-online/
### Description
After upgrading from the 5.6.1 release by applying 5.6 branch changes through ebda78c92c, the `acc_cdr` entries for `start_time` and `end_time` in my PostgreSQL database are incorrect; the syslog output is also incorrect. The entries in the `acc` table contain the correct timestamps.
In PostgreSQL, each of these timestamp columns are `timestamp without time zone`.
```
kamailio=# SELECT id, start_time, end_time, duration, callid FROM acc_cdrs ORDER BY id DESC LIMIT 1;
id | start_time | end_time | duration | callid
-------+---------------------+---------------------+----------+-----------------------------------------
24867 | 1969-12-31 18:00:25 | 1969-12-31 18:00:25 | 25.41 | 0_1083748456@fd00:a::215:65ff:fe9e:e168
(1 row)
kamailio=# SELECT id, method, time, callid FROM acc ORDER BY id DESC LIMIT 2;
id | method | time | callid
--------+--------+---------------------+-----------------------------------------
108653 | BYE | 2022-09-17 20:54:43 | 0_1083748456@fd00:a::215:65ff:fe9e:e168
108652 | INVITE | 2022-09-17 20:54:18 | 0_1083748456@fd00:a::215:65ff:fe9e:e168
```
#### Log Messages
It appears that `duration` is being copied into `start_time` and `end_time`.
```
INFO: acc [acc_cdr.c:367]: log_write_cdr(): start_time=25.410; end_time=25.410; duration=25.410; callid=0_1083748456@fd00:a::215:65ff:fe9e:e168; from_tag=1137456145; to_tag=645d9eee-9c3a-420a-ac37-8d3c741a5ce9;
```
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.6.1-2.20220917gitebda78c9.fc36 (x86_64/linux) b36a13
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: b36a13
compiled on 00:00:00 Sep 18 2022 with gcc 12.2.1
```
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `lsb_release -a` and `uname -a`)
-->
```
Fedora 36
Linux 5.19.9-200.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Sep 15 09:49:52 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3243
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3243(a)github.com>