Adding a header to outgoing Invite

I have asterisk-1.6.3 running in my environment with few extensions configured. I want to add the Sip header to the INVITE message before it is delivered it to the recipient. The configuration for the extensions are :-

sip.conf

[102]
type=friend
host=dynamic
nat=no
canreinvite=no
context=test

[103]
type=friend
host=dynamic
nat=no
canreinvite=no
context=test

extensions.conf

[test]
extern => _[0-9].,1,SipAddHeader(Orig-Cc: 777777)
exten => _[0-9].,1,Dial(SIP/${EXTEN})

I don’t care even if the header goes along with the rest of sip messages.

your code looks fine… what’s the problem.

The only issue I see is that you have an extra “r” in your “exten=>” declaration for the SipAddHeader() call.

Thanks for the response.

Sorry…that was a stutter. I do have exten in the conf file.

The problem is with the given configuration; my extensions are not working at all and I am seeing the following error in the log file:-

[Mar 20 10:29:21] DEBUG[2051]: chan_sip.c:19633 sip_devicestate: Checking device state for peer 102
[Mar 20 10:29:21] DEBUG[2051]: devicestate.c:441 do_state_change: Changing state for SIP/102 - state 1 (Not in use)
[Mar 20 10:29:21] DEBUG[2060]: app_queue.c:767 handle_statechange: Device ‘SIP/102’ changed to state ‘1’ (Not in use) but we don’t care because they’re not a member of any queue.
[Mar 20 10:29:21] DEBUG[2060]: app_queue.c:767 handle_statechange: Device ‘SIP/102’ changed to state ‘1’ (Not in use) but we don’t care because they’re not a member of any queue.
[Mar 20 10:29:21] DEBUG[2057]: chan_sip.c:18496 handle_incoming: **** Received ACK (6) - Command in SIP ACK
[Mar 20 10:29:21] DEBUG[2057]: chan_sip.c:3066 __sip_ack: Stopping retransmission on ‘6c424124-94d1b816-d2e1902d@166.34.161.67’ of Response 1: Match Found

If I comment the line "exten => _[0-9].,1,SipAddHeader(Orig-Cc: 777777) "; then everything starts working. But at the same time I want to use the SipAddHeader function to add the header.

You had two step (priority) ones, for the same extension, in your dialplan, as copied here.

To debug this, sort of thing you need to use sip set debug, not core set debug. core set verbose may have helped show the dialplan errors.