<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>
<div>
<div>Yes. I hadn’t thought about using shared variables. That would be a good way to go as well.</div>
<div>
<div id="MAC_OUTLOOK_SIGNATURE">
<div><br>
</div>
<div>Ben Newlin</div>
</div>
</div>
</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:12pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>&lt;<a href="mailto:users-bounces@lists.opensips.org">users-bounces@lists.opensips.org</a>&gt; on behalf of Stefan Tobé &lt;<a href="mailto:stefan.tobe@privatemobility.nl">stefan.tobe@privatemobility.nl</a>&gt;<br>
<span style="font-weight:bold">Reply-To: </span>OpenSIPS users mailling list &lt;<a href="mailto:users@lists.opensips.org">users@lists.opensips.org</a>&gt;<br>
<span style="font-weight:bold">Date: </span>Thursday, April 28, 2016 at 11:33 AM<br>
<span style="font-weight:bold">To: </span>OpenSIPS users mailling list &lt;<a href="mailto:users@lists.opensips.org">users@lists.opensips.org</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>Re: [OpenSIPS-Users] opensips 2.1.2 not accepting transformation in if statement and t_relay()<br>
</div>
<div><br>
</div>
<span style="mso-bookmark:_MailOriginalBody">
<div>
<div>
<div dir="ltr">
<div>
<div>Thanks Ben,<br>
</div>
so it is either <br>
<ol>
<li>using shared variable ($shv(name)) which is <b>globally available</b> (and adaptable using MI...)&nbsp;&nbsp;&nbsp;&nbsp; OR</li><li>re-initialize variable $var(xyz) every time in <b>(main) route {}</b> loop with these dashboard values?</li></ol>
</div>
Stefan<br>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Apr 28, 2016 at 3:10 PM, Newlin, Ben <span dir="ltr">
&lt;<a href="mailto:Ben.Newlin@inin.com" target="_blank">Ben.Newlin@inin.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif">
<div>
<div>
<div>Stefan,</div>
<div><br>
</div>
<div>$var type variable have process-level scope [1]. This means they are only valid in the same script process that initialized them. It is very likely in your case that the startup_route is running in a different child process than the message processing
 routes and that is causing the problem. You can add some xlog statements to check the values of the variables before using them. Xlog will print the process ID as part of the output as well so you can verify that. You can also try running OpenSIPS in foreground
 mode with the –F flag. This will cause it to run with only one process.</div>
<div><br>
</div>
<div>If you need multiple processes you cannot use $var for this. I would suggest looking into the local caching functionality instead [2].</div>
<div><br>
</div>
<div>[1]&nbsp;<a href="http://www.opensips.org/Documentation/Script-CoreVar-1-11" target="_blank">http://www.opensips.org/Documentation/Script-CoreVar-1-11</a></div>
<div><u>[2]&nbsp;</u><a href="http://www.opensips.org/Documentation/Script-CoreFunctions-1-11#toc3" target="_blank">http://www.opensips.org/Documentation/Script-CoreFunctions-1-11#toc3</a></div>
<div>
<div>
<div><br>
</div>
<div>Ben Newlin</div>
</div>
</div>
</div>
</div>
<div><br>
</div>
<span>
<div style="font-family:Calibri;font-size:12pt;text-align:left;color:black;BORDER-BOTTOM:medium none;BORDER-LEFT:medium none;PADDING-BOTTOM:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;BORDER-TOP:#b5c4df 1pt solid;BORDER-RIGHT:medium none;PADDING-TOP:3pt">
<span style="font-weight:bold">From: </span>&lt;<a href="mailto:users-bounces@lists.opensips.org" target="_blank">users-bounces@lists.opensips.org</a>&gt; on behalf of Stefan Tobé &lt;<a href="mailto:stefan.tobe@gmail.com" target="_blank">stefan.tobe@gmail.com</a>&gt;<br>
<span style="font-weight:bold">Reply-To: </span>OpenSIPS users mailling list &lt;<a href="mailto:users@lists.opensips.org" target="_blank">users@lists.opensips.org</a>&gt;<br>
<span style="font-weight:bold">Date: </span>Thursday, April 28, 2016 at 8:50 AM<br>
<span style="font-weight:bold">To: </span>&quot;<a href="mailto:users@lists.opensips.org" target="_blank">users@lists.opensips.org</a>&quot; &lt;<a href="mailto:users@lists.opensips.org" target="_blank">users@lists.opensips.org</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>[OpenSIPS-Users] opensips 2.1.2 not accepting transformation in if statement and t_relay()<br>
</div>
<div>
<div class="h5">
<div><br>
</div>
<span>
<div>
<div>
<div dir="ltr">
<div>
<div>
<div>Hi there,<br>
</div>
I am trying to sanitize the opensips script by using a script 'dashboard' in the beginning of the script (using&nbsp; startup_route)<br>
<br>
I face two problems here (opensips script errors)<br>
problem 1: $var(uriqp) should be the uri-string in order to use that in t_relay() which is rejected<br>
</div>
problem 2: completing IF statement where src_ip should be compared to transformed (to binary) ip address&nbsp; and source port is both rejected<br>
<br>
</div>
Can somebody explain <br>
<ol>
<li>what the correct uri string for use in t_relay() would need to be ? (just entering t_relay(&quot;udp:<a href="http://10.130.2.4:5060" target="_blank">10.130.2.4:5060</a>&quot;) works fine)</li><li>what the correct way of transformation I need to use in order to have this IF statement accepted?</li></ol>
<p>thanks</p>
<p>Stefan Tobé<br>
</p>
<div>
<div><br>
<br>
<br>
####### Routing Logic ########<br>
startup_route {<br>
&nbsp;&nbsp;&nbsp; ####### Local Parameters / Dashboard #########<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $var(qpip)=&nbsp;&nbsp; &quot;10.130.2.4&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $var(qpprt)=&nbsp; &quot;5090&quot;;<br>
# &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $var(qpprt)=&nbsp; 5090;<br>
<br>
&nbsp;&nbsp;&nbsp;<span style="color:rgb(255,0,0)"><b> $var(uriqp)=&nbsp; &quot;udp:&quot;&#43;$var(qpip)&#43;&quot;:&quot;&#43;$var(qpprt);<br>
</b></span><br>
<br>
}<br>
<br>
<br>
route{<br>
<br>
<b><span style="color:rgb(255,0,0)">if (src_ip == $(var(qpip){ip.pton}) &amp;&amp; src_port == $var(qpprt)) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (=&gt; won't accept
</span><span style="color:rgb(255,0,0)">regardless whether $var(qpprt)=&nbsp; &quot;5090&quot; or $var(qpprt)=&nbsp; 5090)</span></b><br>
&nbsp;&nbsp;&nbsp; # code here<br>
&nbsp;&nbsp;&nbsp; route(sbc);<br>
}<br>
</div>
<div>else ....<br>
</div>
<div>}<br>
<br>
route[qp] {<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;<span style="color:rgb(255,0,0)"><b> if (!t_relay($var(uriqp)) {</b></span><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; send_reply(&quot;500&quot;,&quot;Internal Error&quot;);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; exit;<br>
}<br clear="all">
<div>
<div><br>
-- <br>
<div>mvg<br>
Stefan Tobé<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</span></div>
</div>
</span></div>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div>mvg<br>
Stefan Tobé<br>
<br>
</div>
<b></b><br>
Private Mobility Nederland B.V.<br>
Bolderweg 2<br>
1332 AT Almere<br>
tel: 06 21 26 59 68<br>
email: <a href="mailto:stefan.tobe@privatemobility.nl" target="_blank">stefan.tobe@privatemobility.nl</a><br>
internet: <a href="http://www.privatemobility.nl" target="_blank">www.privatemobility.nl</a><br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</span></span>
</body>
</html>