[asterisk-dev] Add SIP Header with PJSIP in C module

Richard Mudgett rmudgett at digium.com
Wed Oct 21 11:22:35 CDT 2020


You add headers in a similar way as before.  It is just a matter of adding
them to the right channel.
You must add them to the outgoing channel for PJSIP.  This can be
accomplished by using pre-dial handlers [1][2].

Richard

[1] https://wiki.asterisk.org/wiki/display/AST/Pre-Dial+Handlers
[2] https://www.asterisk.org/dialplan-handler-routines-allow-customization/

On Wed, Oct 21, 2020 at 10:49 AM Benoit Duverger <bduverger at atwtech.com>
wrote:

> Hello,
>
> We have a module written in C which was developed initially for asterisk
> 1.4, modified a few years ago to run in asterisk 1.8 then 11. This module
> is used to verify user's limits, route calls etc...
> Actually, I try to adapt it to run in asterisk 16, I moved from chan_sip
> to PJSIP and I don't know how can I add SIP Headers into the channel. With
> chan_sip we used that:
> sprintf( cmd, "SipAddHeader(command:%s)", command );
> res = astcmd( chan, cmd );
> astcmd is a custom function wrapped onto pbx_exec().
>
> I tried to use pbx_builtin_setvar_helper(), with the function
> PJSIP_HEADER() but I didn't see any custom headers in SIP... and no errors,
> res = 0.
> res = pbx_builtin_setvar_helper(chan, "PJSIP_HEADER(add, X-test)", "test");
>
>
> How can I use PJSIP_HEADER in a C module ?, which libraries should I need
> to import ?
>
> Thanks
>
> --
>
> Benoit
> --
> _____________________________________________________________________
> -- 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20201021/d60f2a25/attachment.html>


More information about the asterisk-dev mailing list