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

Benoit Duverger bduverger at atwtech.com
Wed Oct 21 12:28:08 CDT 2020


Thanks for your quick answer.

I'm not sure to understand how Pre-Dial Handlers can help my module written
in C. But if I decide to rewrite this module in asterisk language, that
could help me. For the moment I hope to fix my C module.

A big resume of what this part of my module do is:
pbx_exec(chan, "SipAddHeader(X-MyHeader:valuetest)");
pbx_exec(chan, "Dial(SIP/101 at trunk-test,10)");
That works in asterisk 1.8, 11 and probably in asterisk 16 if I use
chan_sip but SipAddHeader is no longer a valid application in my asterisk
because I don't load chan_sip.so, just all modules related to PJSIP.

So with PJSIP, I try:
pbx_builtin_setvar_helper(chan, "PJSIP_HEADER(add,X-MyHeader)",
"valuetest");
pbx_exec(chan, "Dial(PJSIP/101 at trunk-test,10)");

I didn't have any errors but my header is not added.

Thanks


Le mer. 21 oct. 2020 à 12:23, Richard Mudgett <rmudgett at digium.com> a
écrit :

> 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
>
> --
> _____________________________________________________________________
> -- 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



-- 
*Benoit Duverger*
*Administrateur Systèmes et Réseaux*
Sysadmin
T : 514- <(514)%20985-2570>*985-2570* #148
www.atwtech.com
1050 de la Montagne, Suite 400
Montréal (Québec) H3G 1Y8
*Avis de confidentialité*
Le contenu de ce message ainsi que du ou des fichiers qui y sont joints est
strictement confidentiel et destiné exclusivement à son ou sa destinataire.
Si vous n’êtes pas cette personne, nous attirons votre attention sur le
fait qu’il est strictement interdit de copier, de faire suivre ou
d’utiliser les informations contenues dans ce courriel. Si vous l’avez reçu
par erreur, nous vous remercions de nous le faire savoir et de détruire
toute copie de ce message.

*Confidentiality Warning*
The information contained in this email and any attachments may be
privileged, confidential, and/or proprietary and is intended solely for the
use of the person(s) to whom it is addressed. If you are not the intended
recipient, any review, retransmission, dissemination or any other use of
the information contained in this email and any attachments is strictly
prohibited. If you have received this communication in error, please notify
the sender immediately by replying to this email and delete all copies of
the message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20201021/57bacb0e/attachment.html>


More information about the asterisk-dev mailing list