[Freeswitch-users] Not Able to Export Multiple Diversion Headers

Sanjiv Kumar sanjiv at simple2call.com
Tue Apr 22 00:27:08 MSD 2014

My ultimate goal is to receive a call from gateway-A manipulate the
destination number and send the call to gateway-B. My test setup will bridge
the call to extension 1001 instead to sending to gateway-B

Gatway-A is sending me destination number in the format 

INVITE sip:9999188855512121877555121218665551212 at SIP/2.0


Where First 4 digits are a predefined prefix. (9999)

Next 11 digits are real destination number. (18885551212)

Next 11 digits are original called number (OCN). (18775551212)

Next 11 digits are redirected number(RDN). (18665551212)


My plan is to receive the call with above invite, parse the destination
number and export OCN and RDN into diversion sip header and send the call to

In the following config, I am exporting the diversion field twice but I see
only one diversion (last one with RDN) filed on the leg-B side.

What can I do to see both diversion fields.



<extension name="public_did">


    <!--matching prefix -->

    <condition field="destination_number" expression="^9999(\d{33})$">

      <action application="set" data="orig_digits=$1"/>


     <!-parsing destination number -->

      <action application="set" data="my_ocn=${orig_digits:11:11}"/>

      <action application="set" data="my_rdn=${orig_digits:22:11}"/>


      <!--debugging -->

      <action application="log" data="INFO variable ORIG_DIGITS has a value
= ${orig_digits}"/>

      <action application="log" data="INFO variable MY_OCN has a value =

      <action application="log" data="INFO variable MY_RDN has a value =


        <!-Exporting OCN/RDN into sip diversion header -->

      <action application="export" data=" nolocal:sip_h_Diversion

      <action application="export" data=" nolocal:sip_h_Diversion


      <action application="set" data="hangup_after_bridge=true" />

      <action application="set" data="continue_on_fail=true"/>


      <action application="transfer" data="1001 XML default"/>








-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140421/9b9486ff/attachment.html 

Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-users mailing list