[asterisk-dev] adding SIP Headers a SIP dialog

Marco Happenhofer marco.happenhofer at tuwien.ac.at
Tue May 6 09:53:15 CDT 2008


Klaus Darilion wrote:
> Marco Happenhofer wrote:
>   
>> Hi,
>>
>> I need to insert a SIP Header in all SIP Messages for a single dialog.
>> I tried the SIPAddHeader Method, but with this function the header is 
>> only added to the first SIP INVITE.
>>
>> Is there any possibility to add SIP Headers for the dialog (including 
>> ACK and BYE), not only for the single Message?
>>
>> If no, how much effort has to be taken to implement this feature?
>>     
>
> 1. grep for "SIPAddHeader" in the Asterisk directory. You will find out 
> that it is implemented in chan_sip.
>
> 2. open chan_sip in an editor an search for: SIPAddHeader. You will find 
> out, that the SIPAddHeader does nothing more then setting the 
> SIPADDHEADER variable. (Using _ as prefix to mark it as a gobal variable 
> - thus, this variable will be copied from the incoming channel to the 
> outgoing channel).
>
> 3. search in chan_sip for SIPADDHEADER. You will the corresponding code 
>   in transmit_invite(). I guess it should be rather easy to copy the 
> code part also to other functions like transmit_reinvite_with_sdp() or 
> transmit_request(). Probably you should extract the relevant code 
> snippet into a new function which will be called from the other functions.
>
> 4. Mabye it might be useful to make a new VARIABLE for this, e.g. 
> SIPADDHEADERALWAYS.
>
> 5. Post in bugs.digium.org ;-)
>
> regards
> klaus
>
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev
>   
Thx its was easy to follow these steps...
but at the end I had some problems, because the headers were not added 
to all messages ...

My Configuration:
UA1(SIP) ---> * ----> UA2(SIP)

UA1 --->* INVITE
UA1 <--- * 100 Trying
* --->UA2 INVITE (headers inserted)
.
..
UA1 --->*   BYE
UA1 <---*   200 OK
* ---> INVITE (this is the last message which has the inserted headers..)
* <--- 100 Trying
* <--- 200 OK
* ---> ACK (headers are missing)
* ---> BYE (headers are missing)
* <--- 200 OK


I added this function you mentioned at step 3 to following functions (on 
the correct places):
static int transmit_reinvite_with_sdp(struct sip_pvt *p)
static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, 
int init)
static int transmit_sip_request(struct sip_pvt *p, struct sip_request *req)
static int transmit_request(struct sip_pvt *p, int sipmethod, int seqno, 
enum xmittype reliable, int newbranch)
static int transmit_request_with_auth(struct sip_pvt *p, int sipmethod, 
int seqno, enum xmittype reliable, int newbranch)

So, first why do I need an Invite after the A Party sent a BYE and 
second want do I wrong that in most of these Requests are the headers 
not added ?

regards, marco





More information about the asterisk-dev mailing list