[SR-Users] Issue using subst

Uriel Rozenbaum uriel.rozenbaum at gmail.com
Fri Aug 13 17:18:39 CEST 2010


Here it comes.

Fell free to make any notations, we are all here to improve the matter:

   # From Edition
   if (is_present_hf("From"))
   {
      $avp(s:newFrom) = $avp(s:ANIegress) + " <sip:" +
$avp(s:ANIegress) + "@" + $(hdr(From){tobody.host}) + ">;" +
$(hdr(From){tobody.params});
      remove_hf("From");
      insert_hf("From: $avp(s:newFrom)\r\n", "Contact");

   }

   # Remote-Party-ID manipulation
   if (is_present_hf("Remote-Party-ID"))
   {
      # 1 or 2 RPID headers?
      if($(hdr(Remote-Party-ID)[0]{s.len}) != $(hdr(Remote-Party-ID)[*]{s.len}))
      {
         if($(hdr(Remote-Party-ID)[0]{tobody.params}{param.value,party})
== "calling")
         {
            $avp(s:newRPID) = $avp(s:ANIegress) + " <sip:" +
$avp(s:ANIegress) + "@" + $(hdr(Remote-Party-ID)[0]{tobody.host}) +
">;" + $(hdr(Remote-Party-ID)[0]{tobody.params});
            $avp(s:oldRPID) = $(hdr(Remote-Party-ID)[0]);
            $avp(s:otherRPID) = $(hdr(Remote-Party-ID)[1]);
         }
         else
         {
            $avp(s:newRPID) = $avp(s:ANIegress) + " <sip:" +
$avp(s:ANIegress) + "@" + $(hdr(Remote-Party-ID)[1]{tobody.host}) +
">;" + $(hdr(Remote-Party-ID)[1]{tobody.params});
            $avp(s:oldRPID) = $(hdr(Remote-Party-ID)[1]);
            $avp(s:otherRPID) = $(hdr(Remote-Party-ID)[0]);
         }
         remove_hf("Remote-Party-ID");
         append_hf("Remote-Party-ID: $avp(s:newRPID)\r\n", "Allow");
         append_hf("Remote-Party-ID: $avp(s:otherRPID)\r\n", "Remote-Party-ID");
      }
      else
      {
         $avp(s:newRPID) = $avp(s:ANIegress) + " <sip:" +
$avp(s:ANIegress) + "@" + $(hdr(Remote-Party-ID){tobody.host}) + ">;"
+ $(hdr(Remote-Party-ID){tobody.params});
         $avp(s:oldRPID) = $(hdr(Remote-Party-ID));
         remove_hf("Remote-Party-ID");
         append_hf("Remote-Party-ID: $avp(s:newRPID)\r\n", "Allow");
      }
   }

   # P-Asserted-Identity manipulation
   if (is_present_hf("P-Asserted-Identity"))
   {

      if($avp(s:paiMODE) == "Tel-URI")
      {
         $avp(s:newPAI) = "<tel:" + $avp(s:ANIegress) + ">";
         $avp(s:oldPAI) = $(hdr(P-Asserted-Identity));
      }
      else if($avp(s:paiMODE) == "SIP-URI")
      {
         $avp(s:newPAI) = $avp(s:ANIegress) + " <sip:" +
$avp(s:ANIegress) + "@" + $(hdr(P-Asserted-Identity){tobody.host}) +
">";
         $avp(s:oldPAI) = $(hdr(P-Asserted-Identity));
      }
      remove_hf("P-Asserted-Identity");
      append_hf("P-Asserted-Identity: $avp(s:newPAI)\r\n", "Privacy");
   }

Cheers,
Uriel

On Thu, Aug 12, 2010 at 6:29 PM, Alex Balashov
<abalashov at evaristesys.com> wrote:
> On 08/12/2010 05:27 PM, Uriel Rozenbaum wrote:
>
>> Takes a little more work but works perfectly. Thanks!!!
>
> Yes, but a lot easier to read, understand and modify from a code and
> business process management perspective.
>
>> I have to be aware of calls that have 2 RPID headers (party=called and
>> party=calling), is you're interested I can paste the code once I'm
>> done coding and testisng. :)
>
> Sure, example code is always good for posterity.
>
> --
> Alex Balashov - Principal
> Evariste Systems LLC
> 1170 Peachtree Street
> 12th Floor, Suite 1200
> Atlanta, GA 30309
> Tel: +1-678-954-0670
> Fax: +1-404-961-1892
> Web: http://www.evaristesys.com/
>



More information about the sr-users mailing list