[asterisk-dev] Accessing SIP Headers from within a module

Josh josh at sentrix.co.uk
Wed Aug 14 11:57:04 CDT 2013


Hi Mark, 

Many thanks for your helpful reply, it makes complete sense now!

I simply add in a pbx_builtin_setvar_helper() call in 

chan_sip.c 
static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *title)

and then access this using pbx_builtin_getvar_helper() within 
app_voicemail.c

I will give it a go, 

Thanks again :)

Josh

On Wed, Aug 14, 2013 at 11:19:38AM -0500, Mark Michelson wrote:
> A design principle of Asterisk is that channel technology-specific details
> are only obtainable from the channel driver for that technology.
> 
> Trying to transplant functions from chan_sip.c into app_voicemail.c is
> going to lead to, well let's just say, pain :).
> 
> What you're better off doing is trying to get data from the SIP header from
> within chan_sip.c when a SIP request arrives. You can then save that
> information on the ast_channel, potentially using a channel variable (see
> pbx_builtin_setvar_helper() and pbx_builtin_getvar_helper() in
> include/asterisk/pbx.h). This way, the data will be available on the
> channel itself in app_voicemail.c.
> 
> Good luck!
> Mark Michelson
> 
> 
> On Wed, Aug 14, 2013 at 10:36 AM, Josh <josh at sentrix.co.uk> wrote:
> 
> >
> > Dear Asterisk-Dev,
> >
> > Apologies if this isn't the right place, I'm mainly looking for a pointer
> > on how to access sip headers from within app_voicemail.c, unfortunately I'm
> > using asterisk 1.4 (duck!). Is this possible? I have seen the function
> >
> > func_header_read(chan, NULL, "diversion", diversion, 100);
> >
> > which is declared static in chan_sip.c so I can't use it.
> > Copying the important parts from the routine gives me the
> > following:
> >
> > struct sip_pvt *p;
> > p = chan->tech_pvt;
> > sip_req *req = (sip_req *)p->initreq; // doesn't compile
> > ast_log(LOG_WARNING, "DATA:%s",&p->initreq->header[0]); // doesn't work as
> > above.
> >
> > Is there another way to access these? A function already? Any help/pointer
> > would be amazing,
> >
> > thanks for your time,
> >
> > Josh
> >
> > --
> >
> > --
> > _____________________________________________________________________
> > -- 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


-- 



More information about the asterisk-dev mailing list