<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</p>
    <p>case values have to be constants, not variables, based on a quick
      look at the code, as I haven't implemented it. But this is anyhow
      the common for switch/case statements. The core cookbook also has
      the example only with constants.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 22.06.21 10:29, Joel Serrano wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAMtXxQkdcjpipypCRcp9PsyoFh3wQkfTZE_ph3sinQh_+rK5Tw@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi guys, 
        <div><br>
        </div>
        <div>Quick question, are AVPs valid in "switch" as "case"'s?</div>
        <div><br>
        </div>
        <div>Example:</div>
        <div><br>
        </div>
        <div>
          <div style="color:rgb(171,178,191);background-color:rgb(40,44,52);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre"><div>            $avp(var1) = <span style="color:rgb(152,195,121)">"101"</span>;</div><div>            $avp(var2) = <span style="color:rgb(152,195,121)">"201"</span>;</div><div>            <span style="color:rgb(198,120,221)">switch</span>($rU) {</div><div>                <span style="color:rgb(198,120,221)">case</span> <span style="color:rgb(152,195,121)">"$avp(var1)"</span>:</div><div>                    ...</div><div>                <span style="color:rgb(198,120,221)">break</span>;</div><div>                <span style="color:rgb(198,120,221)">case</span> <span style="color:rgb(152,195,121)">"$avp(var2)"</span>:</div><div>                    ...</div><div>                <span style="color:rgb(198,120,221)">break</span>;</div><div>                <span style="color:rgb(198,120,221)">default</span>:</div><div>                    send_reply(<span style="color:rgb(152,195,121)">"403"</span>, <span style="color:rgb(152,195,121)">"Forbidden"</span>);</div><div>                    <span style="color:rgb(97,175,239)">exit</span>;</div><div>            }</div></div>
        </div>
        <div><br>
        </div>
        <div>For some reason I can't get the case to match, and I'm
          thinking it's not using the actual value of $avp(var1) and
          instead it's using literally "$avp(var1)" as a string.<br>
        </div>
        <div><br>
        </div>
        <div>NOTE: I also tried without putting the AVPs in quotes, but
          Kamailio complains and doesn't start.</div>
        <div><br>
        </div>
        <div>Is this doable or do I need to use if..else if..else
          if..else for this?</div>
        <div><br>
        </div>
        <div>Thanks, </div>
        <div>Joel.</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * <a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
  * <a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a></pre>
  </body>
</html>