Hi List, 

I faced a problem with FS, concerning SIP messages with multiple same headers (for example, Diversion headers).
FS wasn't able to manage those headers, and only the first one was taken in account by FS.

After some searches in mod_sofia.c, I've made a patch, giving the ability to FS to display and manage multiple SIP Diversion headers (or other headers)
You can find it here : http://jira.freeswitch.org/browse/FS-5411

But, I'm facing a new problem : FS is able to read some identical headers and display them as "Diversion", "Diversion-1", "Diversion-2", etc... , but it's not able to write some identical headers

Here is an extract of my test dialplan

<condition field="${sip_h_Diversion}" expression="\+(\d+).*;reason=(\w+);privacy=(\w+);counter=(\d{1})" break="never">
        <action application="log" data="LOG Modifying first Diversion" />
        <action application="set" data="sip_h_Diversion=<sip:+$1>;reason=$2;privacy=$3;counter=$4" />
 </condition>
<condition field="${sip_h_Diversion-1}" expression="\+(\d+).*;reason=(\w+);privacy=(\w+);counter=(\d{1})" break="never">
        <action application="log" data="LOG Modifying second Diversion-1" />
        <action application="set" data="sip_h_Diversion=<sip:+$1>;reason=$2;privacy=$3;counter=$4" />
</condition>

 
You can see that I'm trying to write two Diversion headers, because what I'd like to obtain is something like that : 

INVITE sip:+123456789@fsbox.domain
From: ....
To : ....
........
Diversion: <sip:+987654321@domain.com>;reason=unavailable;privacy=off;counter=1
Diversion: <sip:+258147369@domain.com>;reason=do-not-disturb;privacy=off;counter=1

But what I really obtain is : 

INVITE sip:+123456789@fsbox.domain
From: ....
To : ....
........
Diversion: <sip:+987654321@domain.com>;reason=unavailable;privacy=off;counter=1
Diversion-1: <sip:+258147369@domain.com>;reason=do-not-disturb;privacy=off;counter=1

So, FS automatically write the second Diversion header with a "-1" at the end ... And it's really frustrating !

Moreover, I don't want to use a FS function to make every SIP headers copied automatically from A-leg to B-leg, because some of my SIP providers don't support every header, and I have to only send essential ones.


Do you have any idea / question / answer to help me, please ?  Perhaps my patch may be corrected, but I don't know how... 
 
Thanks a lot, 


Bien cordialement, 
Best Regards, 

Kevin MATHY