<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Thank you Razvan.<br><br>Bogdan<br><br>--- On <b>Wed, 4/13/11, Razvan Crainea <i>&lt;razvancrainea@opensips.org&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Razvan Crainea &lt;razvancrainea@opensips.org&gt;<br>Subject: Re: [OpenSIPS-Users] function with 6 parameters<br>To: "rad bogdan" &lt;bogdan_rad2004@yahoo.com&gt;<br>Cc: users@lists.opensips.org<br>Date: Wednesday, April 13, 2011, 5:28 PM<br><br><div id="yiv1738753224">

  

    
    <title></title>
  Hello, Bogdan,<br>
    <br>
    The problem is that the function you are using to fetch the values
    of the pseudo variables (fixup_get_svalue) uses static buffers to
    store the string values. These buffers are only 5 an they are used
    circularly. That's why the first value is the same with the last
    one.<br>
    The best solution is to make sure you don't use more than 5 buffers
    concurrently, preferably process the value right after fetching it
    (in your example print the value right after getting it). Another
    solution is to use the "pv_printf" function where you can specify
    your buffer. As a last resort you can increase the buffers number in
    "pvar.c" (search PV_PRINT_BUF_NO definition).<br>
    <br>
    Regards,<br>
    Razvan<br>
    <br>
    On 04/13/2011 01:58 PM, rad bogdan wrote:
    <blockquote type="cite">
      <table border="0" cellpadding="0" cellspacing="0">
        <tbody>
          <tr>
            <td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit; -x-system-font: none;" valign="top">Hi Razvan,<br>
              <br>
              I've applied the patch you gave me.<br>
              This is the output:<br>
              <br>
              INFO:core:do_action: called test6(0x81b1398, 0x81b144c,
              0x81b14b4, 0x81b151c, 0x81b1584, 0x81b15ec) <br>
              INFO:test:test6: arg1: [789]<br>
              INFO:test:test6: arg2: [222]<br>
              INFO:test:test6: arg3: [333]<br>
              INFO:test:test6: arg4: [123]<br>
              INFO:test:test6: arg5: [456]<br>
              INFO:test:test6: arg6: [789]<br>
              <br>
              INFO:core:fix_actions: fixed test6[1] 0x81b1398 <br>
              INFO:core:fix_actions: fixed test6[2] 0x81b144c <br>
              INFO:core:fix_actions: fixed test6[3] 0x81b14b4 <br>
              INFO:core:fix_actions: fixed test6[4] 0x81b151c <br>
              INFO:core:fix_actions: fixed test6[5] 0x81b1584 <br>
              INFO:core:fix_actions: fixed test6[6] 0x81b15ec <br>
              <br>
              This is the code from opensips.cfg:<br>
              <br>
              $var(var1) = 111;<br>
              $var(var2) = 222;<br>
              $var(var3) = 333;<br>
              <br>
              $avp(s:avp1) = 123;<br>
              $avp(s:avp2) = 456;<br>
              $avp(s:avp3) = 789;<br>
              <br>
              test6("$var(var1)", "$var(var2)", "$var(var3)",
              "$avp(s:avp1)", "$avp(s:avp2)", "$avp(s:avp3)");<br>
              <br>
              Attached is the module.<br>
              <br>
              Thanks,<br>
              Bogdan<br>
              <br>
              --- On <b>Mon, 4/11/11, Razvan Crainea <i><a rel="nofollow" class="yiv1738753224moz-txt-link-rfc2396E" ymailto="mailto:razvancrainea@opensips.org" target="_blank" href="/mc/compose?to=razvancrainea@opensips.org">&lt;razvancrainea@opensips.org&gt;</a></i></b>
              wrote:<br>
              <blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>
                From: Razvan Crainea <a rel="nofollow" class="yiv1738753224moz-txt-link-rfc2396E" ymailto="mailto:razvancrainea@opensips.org" target="_blank" href="/mc/compose?to=razvancrainea@opensips.org">&lt;razvancrainea@opensips.org&gt;</a><br>
                Subject: Re: [OpenSIPS-Users] function with 6 parameters<br>
                To: <a rel="nofollow" class="yiv1738753224moz-txt-link-abbreviated" ymailto="mailto:users@lists.opensips.org" target="_blank" href="/mc/compose?to=users@lists.opensips.org">users@lists.opensips.org</a><br>
                Date: Monday, April 11, 2011, 1:45 PM<br>
                <br>
                <div id="yiv1738753224">
                  <title></title>
                  Hello Bogdan,<br>
                  <br>
                  I implemented a similar test function that takes 6
                  parameters.<br>
                  All values seems to be in the correct order in both
                  fixup function and triggered function.<br>
                  <br>
                  I attached a small patch that prints the value of the
                  parameters right after the fixup function and then
                  again before the function is called.<br>
                  <br>
                  Please apply this patch and then check if the
                  parameters values and order match between the fixup
                  and triggered function?<br>
                  <br>
                  Regards,<br>
                  Razvan<br>
                  <br>
                  On 04/06/2011 05:51 PM, rad bogdan wrote:
                  <blockquote type="cite">
                    <table border="0" cellpadding="0" cellspacing="0">
                      <tbody>
                        <tr>
                          <td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit; -x-system-font: none;" valign="top">Hi
                            Bogdan,<br>
                            <br>
                            The "inversion" is only in the triggered
                            function.<br>
                            The arguments are passed correctly from left
                            to right to the fixup function.<br>
                            <br>
                            The triggered function is:<br>
                            <br>
                            test_function(struct sip_msg *msg, char
                            *arg1, char *arg2, char* arg3, char* arg4,
                            char* arg5, char* arg6)<br>
                            {<br>
                            &nbsp;&nbsp;&nbsp; str arg1_s&nbsp; = {NULL, 0};<br>
                            <br>
                            &nbsp;&nbsp;&nbsp; if(arg1 == NULL || fixup_get_svalue(msg,
                            (gparam_p)arg1, &amp;arg1_s) != 0)<br>
                            &nbsp;&nbsp;&nbsp; {<br>
                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LM_ERR("Invalid arg1 argument\n");<br>
                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return -1;<br>
                            &nbsp;&nbsp;&nbsp; }<br>
                            .........<br>
                            }<br>
                            <br>
                            arg1_s.s has the value of arg6_s.s while
                            arg6_s.s has the correct value.<br>
                            <br>
                            Thanks,<br>
                            Bogdan<br>
                            <br>
                            --- On <b>Wed, 4/6/11, Bogdan-Andrei Iancu
                              <i><a rel="nofollow" class="yiv1738753224moz-txt-link-rfc2396E">&lt;bogdan@opensips.org&gt;</a></i></b>
                            wrote:<br>
                            <blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>
                              From: Bogdan-Andrei Iancu <a rel="nofollow" class="yiv1738753224moz-txt-link-rfc2396E">&lt;bogdan@opensips.org&gt;</a><br>
                              Subject: Re: [OpenSIPS-Users] function
                              with 6 parameters<br>
                              To: "OpenSIPS users mailling list" <a rel="nofollow" class="yiv1738753224moz-txt-link-rfc2396E">&lt;users@lists.opensips.org&gt;</a><br>
                              Cc: "rad bogdan" <a rel="nofollow" class="yiv1738753224moz-txt-link-rfc2396E">&lt;bogdan_rad2004@yahoo.com&gt;</a><br>
                              Date: Wednesday, April 6, 2011, 5:15 PM<br>
                              <br>
                              <div id="yiv1738753224"> Hi Bogdan,<br>
                                <br>
                                This "inversion" is visible in the fixup
                                function or is the triggered function ?<br>
                                <br>
                                Regards,<br>
                                Bogdan<br>
                                <br>
                                On 04/06/2011 02:44 PM, rad bogdan
                                wrote:
                                <blockquote type="cite">
                                  <table border="0" cellpadding="0" cellspacing="0">
                                    <tbody>
                                      <tr>
                                        <td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit; -x-system-font: none;" valign="top">Hi everyone,<br>
                                          <br>
                                          I implemented an OpenSIPS
                                          custom module that
                                          communicates with an external
                                          application. From the routing
                                          script I call a function with
                                          6 parameters:<br>
                                          <br>
                                          test_function('$fU', '$tU',
                                          '$ci', '$avp(s:name1)',
                                          '$avp(s:name2)',
                                          '$var(name3)')<br>
                                          <br>
                                          The problem is that when the
                                          corresponding function is
                                          called in C, the first
                                          parameter gets the value of
                                          the last one.<br>
                                          <br>
                                          This doesn't happen when the
                                          function is made to take 5
                                          parameters.<br>
                                          <br>
                                          The fixup function that I use
                                          is this:<br>
                                          <br>
                                          static int
                                          pvn_fixup_spve_spve_6(void**
                                          param, int param_no)<br>
                                          {<br>
                                          &nbsp;&nbsp;&nbsp; if (!(param_no &gt;= 1
                                          &amp;&amp; param_no &lt;= 6))<br>
                                          &nbsp;&nbsp;&nbsp; {<br>
                                          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LM_ERR("invalid
                                          parameter number %d\n",
                                          param_no);<br>
                                          &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return E_UNSPEC;<br>
                                          &nbsp;&nbsp;&nbsp; }<br>
                                          &nbsp;&nbsp;&nbsp; <br>
                                          &nbsp;&nbsp;&nbsp; return fixup_spve(param);<br>
                                          }<br>
                                          <br>
                                          Is there something wrong with
                                          it or the problem is elsewhere
                                          ?<br>
                                          <br>
                                          Thanks,<br>
                                          Bogdan<br>
                                        </td>
                                      </tr>
                                    </tbody>
                                  </table>
                                  <pre><fieldset class="yiv1738753224mimeAttachmentHeader"></fieldset><br>_______________________________________________<br>Users mailing list<br><a rel="nofollow" class="yiv1738753224moz-txt-link-abbreviated">Users@lists.opensips.org</a><br><a rel="nofollow" class="yiv1738753224moz-txt-link-freetext" target="_blank" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br></pre>
                                </blockquote>
                                <br>
                                <br>
                                <pre class="yiv1738753224moz-signature">-- <br>Bogdan-Andrei Iancu<br>OpenSIPS eBootcamp - 2nd of May 2011<br>OpenSIPS solutions and "know-how"</pre>
                              </div>
                            </blockquote>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                    <pre><fieldset class="yiv1738753224mimeAttachmentHeader"></fieldset><br>_______________________________________________<br>Users mailing list<br><a rel="nofollow" class="yiv1738753224moz-txt-link-abbreviated">Users@lists.opensips.org</a><br><a rel="nofollow" class="yiv1738753224moz-txt-link-freetext" target="_blank" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br></pre>
                  </blockquote>
                </div>
                <br>
                -----Inline Attachment Follows-----<br>
                <br>
                <div class="yiv1738753224plainMail">_______________________________________________<br>
                  Users mailing list<br>
                  <a rel="nofollow">Users@lists.opensips.org</a><br>
                  <a rel="nofollow" target="_blank" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
                </div>
              </blockquote>
            </td>
          </tr>
        </tbody>
      </table>
    </blockquote>
  
</div></blockquote></td></tr></table>