[SR-Users] How to use port number using $env in listen

Syed Shahryar syedshahryar at gmail.com
Tue Dec 22 18:07:04 CET 2020


I ran different combinations of the following simple configuration file but
still getting errors on 'listen':

#!KAMAILIO

loadmodule "pv.so"

#!define TLS_IP "0.0.0.0"

// #!define TLS_PORT $env(TLS_PORT)
//#!substdefs "/TLS_PORT/$env(TLS_PORT)/"
#!defenv TLS_PORT=TLS_PORT

#listen=udp:TLS_IP:TLS_PORT name "UDP_SOCKET"
listen=udp:TLS_IP:$env(TLS_PORT) name "UDP_SOCKET"


//// ERROR Lines ////

kamailio         |  0(6) CRITICAL: <core> [core/cfg.y:3588]: yyerror_at():
parse error in config file /usr/local/etc/kamailio/kamailio.test.cfg, line
11, column 19-26: syntax error

kamailio         |  0(6) CRITICAL: <core> [core/cfg.y:3588]: yyerror_at():
parse error in config file /usr/local/etc/kamailio/kamailio.test.cfg, line
11, column 19-26: ip address, interface name or hostname expected

kamailio         |  0(6) CRITICAL: <core> [core/cfg.y:3588]: yyerror_at():
parse error in config file /usr/local/etc/kamailio/kamailio.test.cfg, line
11, column 28-31:

kamailio         | ERROR: bad config file (3 errors)



>> Probably env and def variable should be relocated to core, not having
SIP/runtime dependency, to facilitate their use during start up.
Good idea!


On Tue, Dec 22, 2020 at 3:59 AM Daniel-Constantin Mierla <miconda at gmail.com>
wrote:

> You have to put the the #!subst and listen after loading pv module.
>
> Probably env and def variable should be relocated to core, not having
> SIP/runtime dependency, to facilitate their use during start up.
>
> Cheers,
> Daniel
>
> On 22.12.20 06:58, Syed Shahryar wrote:
>
> Any updates on this?
>
> On Tue, Dec 15, 2020 at 8:13 PM Syed Shahryar <syedshahryar at gmail.com>
> wrote:
>
>> I am new to Kamailio so may be doing something wrong. I looked at
>> https://www.kamailio.org/wiki/cookbooks/5.4.x/core.
>>
>> I tried the following combinations but getting errors in all cases:
>>
>> #!subst "/EVAPI_PORT/$env(EVAPI_PORT)/"
>> #!substdef "/EVAPI_PORT/$env(EVAPI_PORT)/"
>> #!substdefs "/EVAPI_PORT/$env(EVAPI_PORT)/"
>>
>> *Errors:*
>>  0(6) ERROR: <core> [core/pvapi.c:924]: pv_parse_spec2(): error searching
>> pvar "env"
>>  0(6) ERROR: <core> [core/pvapi.c:1127]: pv_parse_spec2(): wrong char
>> [E/69] in [$env(EVAPI_PORT)/] at [5 (5)]
>>  0(6) ERROR: <core> [core/re.c:170]: parse_repl(): bad specifier in
>> replace part /$env(EVAPI_PORT)/
>>  0(6) ERROR: <core> [core/ppcfg.c:69]: pp_subst_add(): bad subst
>> expression: /EVAPI_PORT/$env(EVAPI_PORT)/
>>
>> At a later step, I would like to do:
>> #!define EVAPI_LISTEN "0.0.0.0:EVAPI_PORT"
>>
>> And use EVAP_LISTEN in mod_param for the evapi module.
>>
>> And something similar to above for TLS settings.
>>
>>
>> On Tue, Dec 15, 2020 at 12:41 PM Daniel-Constantin Mierla <
>> miconda at gmail.com> wrote:
>>
>>> Hello,
>>>
>>> as written on the tracker, look at using #!subst or #!substdef (see core
>>> cookbook), they should be able to get the substitution value from
>>> environment using $env(NAME).
>>>
>>> The master branch introduced #!defenv as a (simpler) alternative.
>>>
>>> Cheers,
>>> Daniel
>>> On 12.12.20 05:33, Syed Shahryar wrote:
>>>
>>> I tried many combinations of the following but I keep getting syntax
>>> errors:
>>>
>>> listen=tls:TLS_IP:$env(TLS_PORT) advertise PUBLIC_IP:$env(TLS_PORT)
>>>
>>>
>>> TLS_IP and PUBLIC_IP are constants defined at the top using #!define.
>>> And, TLS_PORT is supposed to be the env variable.
>>>
>>>
>>> --
>>> --
>>> This message contains confidential information and is intended only for
>>> the individual named. If you are not the named addressee, you should not
>>> disseminate, distribute or copy this email. Please notify the sender
>>> immediately by email if you have received this email by mistake and delete
>>> this email from your system. Email transmission cannot be guaranteed to be
>>> secure or error-free, as information could be intercepted, corrupted, lost,
>>> destroyed, arrive late or incomplete, or contain viruses. The sender,
>>> therefore, does not accept liability for any errors or omissions in the
>>> contents of this message which arise as a result of email transmission. If
>>> verification is required, please request a hard-copy version.
>>>
>>> _______________________________________________
>>> Kamailio (SER) - Users Mailing Listsr-users at lists.kamailio.orghttps://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>
>>> --
>>> Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
>>> Funding: https://www.paypal.me/dcmierla
>>>
>>>
>>
>> --
>> --
>> This message contains confidential information and is intended only for
>> the individual named. If you are not the named addressee, you should not
>> disseminate, distribute or copy this email. Please notify the sender
>> immediately by email if you have received this email by mistake and delete
>> this email from your system. Email transmission cannot be guaranteed to be
>> secure or error-free, as information could be intercepted, corrupted, lost,
>> destroyed, arrive late or incomplete, or contain viruses. The sender,
>> therefore, does not accept liability for any errors or omissions in the
>> contents of this message which arise as a result of email transmission. If
>> verification is required, please request a hard-copy version.
>>
>
>
> --
> --
> This message contains confidential information and is intended only for
> the individual named. If you are not the named addressee, you should not
> disseminate, distribute or copy this email. Please notify the sender
> immediately by email if you have received this email by mistake and delete
> this email from your system. Email transmission cannot be guaranteed to be
> secure or error-free, as information could be intercepted, corrupted, lost,
> destroyed, arrive late or incomplete, or contain viruses. The sender,
> therefore, does not accept liability for any errors or omissions in the
> contents of this message which arise as a result of email transmission. If
> verification is required, please request a hard-copy version.
>
> _______________________________________________
> Kamailio (SER) - Users Mailing Listsr-users at lists.kamailio.orghttps://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
>
> --
> Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
> Funding: https://www.paypal.me/dcmierla
>
>

-- 
--
This message contains confidential information and is intended only for the
individual named. If you are not the named addressee, you should not
disseminate, distribute or copy this email. Please notify the sender
immediately by email if you have received this email by mistake and delete
this email from your system. Email transmission cannot be guaranteed to be
secure or error-free, as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender,
therefore, does not accept liability for any errors or omissions in the
contents of this message which arise as a result of email transmission. If
verification is required, please request a hard-copy version.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20201222/11a5b041/attachment.htm>


More information about the sr-users mailing list