SIP-Header Pass-Through

Home » Asterisk Users » SIP-Header Pass-Through
Asterisk Users 2 Comments

Hi,

quick question:
I need to pass-through some headers from the A-Leg to the B-Leg, which are connected using PJSIP. Currently I do the following:

[handler]
exten => addheader,1,GotoIf($[“${ARG1}” == “”]?3)
exten => addheader,2,Set(PJSIP_HEADER(add,Route)=${ARG1})
exten => addheader,3,GotoIf($[“${ARG2}” == “”]?5)
exten => addheader,4,Set(PJSIP_HEADER(add,P-Charging-Vector)=${ARG2})
exten => addheader,5,GotoIf($[“${ARG3}” == “”]?7)
exten => addheader,6,Set(PJSIP_HEADER(add,P-Visited-Network-ID)=${ARG3})
exten => addheader,7,GotoIf($[“${ARG4}” == “”]?9)
exten => addheader,8,Set(PJSIP_HEADER(add,X-C-Params)=${ARG4})
exten => addheader,9,GotoIf($[“${ARG5}” == “”]?11)
exten => addheader,10,Set(PJSIP_HEADER(add,X-URI)=${ARG5})
exten => addheader,11,Return

[pcscf1]
exten => _.,1,Dial(PJSIP/pcscf1/sip:${EXTEN}@${SIPDOMAIN},,b(handler^addheader^1,(${PJSIP_HEADER(read,Route)},${PJSIP_HEADER(read,P-Charging-Vector)},${PJSIP_HEADER(read,P-Visited-Network-ID)},${PJSIP_HEADER(read,X-C-Params)},${PJSIP_HEADER(read,X-URI)})))

This works, but you’ll have to admit, it’s not the most readable-Version of an extensions.conf.

Are there any better solutions around?

Thanks, Carsten

P.S.: I may have found an issue in Asterisk 13.x (LTS); if I send the right SIP-Message I can make it crash. I’m currently verifying, if it still happens with the latest 13.x release from GIT. If I can confirm it with the latest 13.x from GIT, should I post my findings to the dev-list or is there some security mailing list, as this would apply to all installations around there?


Carsten Bock CEO (Geschäftsführer)

ng-voice GmbH
Millerntorplatz 1
20359 Hamburg / Germany

http://www.ng-voice.com mailto:carsten@ng-voice.com

Office +49 40 5247593-40
Fax +49 40 5247593-99

Sitz der Gesellschaft: Hamburg Registergericht: Amtsgericht Hamburg, HRB 120189
Geschäftsführer: Carsten Bock Ust-ID: DE279344284

Hier finden Sie unsere handelsrechtlichen Pflichtangaben:

Imprint

2 thoughts on - SIP-Header Pass-Through

  • My only suggestion would be you could reduce your line count by replacing your GotoIf statements with ExecIF statements.

    exten => addheader,1,ExecIf($[“x${ARG1}” !=
    “x”]?Set(PJSIP_HEADER(add,Route)=${ARG1}))
    same => n,ExecIf($[“x${ARG2}” !=
    “x”]?Set(PJSIP_HEADER(add,P-Charging-Vector)=${ARG2}))
    same => n,ExecIf($[“x${ARG3}” !=
    “x”]?Set(PJSIP_HEADER(add,P-Visited-Network-ID)=${ARG3}))
    same => n,ExecIf($[“x${ARG4}” !=
    “x”]?Set(PJSIP_HEADER(add,X-C-Params)=${ARG4}))
    same => n,ExecIf($[“x${ARG5}” != “x”]?Set(PJSIP_HEADER(add,X-URI)=${ARG5}))
    same => n,Return()