Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tr_lookup(): error parsing [{param.count,,}] #1041

Closed
slavrov opened this issue Mar 23, 2017 · 9 comments
Closed

tr_lookup(): error parsing [{param.count,,}] #1041

slavrov opened this issue Mar 23, 2017 · 9 comments

Comments

@slavrov
Copy link

slavrov commented Mar 23, 2017

Kamailio can't parse construction like $(hdr(History-Info)[*]{param.count,,}) where delimiter is comma.
I tried to use delimiter as , / ',' / "," wuthout success.

ERROR: pv [pv_trans.c:2631]: tr_parse_paramlist(): invalid separator in transformation: count,,}
ERROR: [pvapi.c:1629]: tr_lookup(): error parsing [{param.count,,}]
ERROR: [pvapi.c:1010]: pv_parse_spec2(): bad tr in pvar name "hdr"
ERROR: [pvapi.c:1036]: pv_parse_spec2(): invalid parsing in [$(hdr(History-Info)[*]{param.count,,})] at (4)

ERROR: pv [pv_trans.c:2639]: tr_parse_paramlist(): invalid name transformation: count,','}!
ERROR: [pvapi.c:1629]: tr_lookup(): error parsing [{param.count,','}]
ERROR: [pvapi.c:1010]: pv_parse_spec2(): bad tr in pvar name "hdr"
ERROR: [pvapi.c:1036]: pv_parse_spec2(): invalid parsing in [$(hdr(History-Info)[*]{param.count,','})] at (4)

ERROR: bad config file (1 errors)
ERROR: pv [pv_trans.c:2639]: tr_parse_paramlist(): invalid name transformation: count,","}!
ERROR: [pvapi.c:1629]: tr_lookup(): error parsing [{param.count,","}]
ERROR: [pvapi.c:1010]: pv_parse_spec2(): bad tr in pvar name "hdr"
ERROR: [pvapi.c:1036]: pv_parse_spec2(): invalid parsing in [$(hdr(History-Info)[*]{param.count,","})] at (4)

kamailio -v
version: kamailio 4.4.5 (x86_64/linux) f98162
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: f98162
compiled on 03:47:31 Feb 27 2017 with gcc 4.8.5

@miconda
Copy link
Member

miconda commented Mar 23, 2017

Can you try storing the delimiter in a variable (eg. $var(...)) and provide the variable to the transformation? It could be a quick around for now.

@slavrov
Copy link
Author

slavrov commented Mar 24, 2017

Unfortunately, this doesn't work:

$var(delimiter) = ",";                                              
$var(count) = $(hdr(History-Info)[*]{param.count, $var(delimiter)});
ERROR: pv [pv_trans.c:2631]: tr_parse_paramlist(): invalid separator in transformation: count, $var(delimiter)}
ERROR: <core> [pvapi.c:1629]: tr_lookup(): error parsing [{param.count, $var(delimiter)}]

@miconda
Copy link
Member

miconda commented Mar 24, 2017

Is there a whitespace before the variable?

@slavrov
Copy link
Author

slavrov commented Mar 24, 2017

Yes, there was whitespace. I tried without whitespace without success.

$var(delimiter) = ",";                                             
$var(count) = $(hdr(History-Info)[*]{param.count,$var(delimiter)});

ERROR: pv [pv_trans.c:2631]: tr_parse_paramlist(): invalid separator in transformation: count,$var(delimiter)}
ERROR: <core> [pvapi.c:1629]: tr_lookup(): error parsing [{param.count,$var(delimiter)}]
ERROR: <core> [pvapi.c:1010]: pv_parse_spec2(): bad tr in pvar name "hdr"
ERROR: <core> [pvapi.c:1036]: pv_parse_spec2(): invalid parsing in [$(hdr(History-Info)[*]{param.count,$var(delimiter)})] at (4)

@miconda
Copy link
Member

miconda commented Mar 27, 2017

OK, it seems this needs more investigation.

Meanwhile, maybe you can use other function or transformation to replace the , with another character and the count.

On the other hand, if you just want to count those headers, probably you can do a while loop to check how many headers are.

miconda added a commit that referenced this issue Mar 28, 2017
miconda added a commit that referenced this issue Mar 28, 2017
- reported by GH #1041

(cherry picked from commit f151c26)
miconda added a commit that referenced this issue Mar 28, 2017
- reported by GH #1041

(cherry picked from commit f151c26)
(cherry picked from commit a032c4c)
miconda added a commit that referenced this issue Mar 28, 2017
miconda added a commit that referenced this issue Mar 28, 2017
miconda added a commit that referenced this issue Mar 28, 2017
- reported by GH #1041

(cherry picked from commit 9645575)
(cherry picked from commit 2608015)
@miconda
Copy link
Member

miconda commented Mar 28, 2017

Can you try with latest 4.4 branch? I pushed some commits to fix the use of variable for separator.

@miconda
Copy link
Member

miconda commented Mar 30, 2017

Reopen if the option with variable doesn't work.

@miconda miconda closed this as completed Mar 30, 2017
@slavrov
Copy link
Author

slavrov commented Dec 7, 2018

Unfortunalty param.count still can't accept comma (,) as separator.
Code block:

if ($(dlg_var(cgrSuppliers){param.count,,}) > 0)
{
}

Errors:

ERROR: pv [pv_trans.c:2854]: tr_parse_paramlist(): invalid separator in transformation: count,,}
ERROR: <core> [core/pvapi.c:1715]: tr_lookup(): error parsing [{param.count,,}]
ERROR: <core> [core/pvapi.c:1085]: pv_parse_spec2(): bad tr in pvar name "dlg_var"
ERROR: <core> [core/pvapi.c:1111]: pv_parse_spec2(): invalid parsing in [$(dlg_var(cgrSuppliers){param.count,,})] at (4)
CRITICAL: <core> [core/cfg.y:3508]: yyerror_at(): parse error in config file /etc/kamailio/kamailio.cfg, line 950, column 8-46: Can't get from cache: $(dlg_var(cgrSuppliers){param.count,,})

kamailio -V

version: kamailio 5.2.0 (x86_64/linux) 535e13
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, 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_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 535e13
compiled on 19:17:13 Dec  3 2018 with gcc 4.8.5

cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

@miconda
Copy link
Member

miconda commented Dec 8, 2018

Have you tried with variable?

$var(delimiter) = ",";
if ($(dlg_var(cgrSuppliers){param.count,$var(delimiter)}) > 0) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants