[asterisk-dev] Any plans for func_config to use sorcery?

George Joseph george.joseph at fairview5.com
Thu Sep 5 15:52:07 CDT 2013


On Thu, Sep 5, 2013 at 2:29 PM, Mark Michelson <mmichelson at digium.com> wrote:
>
> I've spent a bit of time giving some thoughts to implementation details of
> PJSIP_HEADER.
>
> The challenge is that in chan_sip.c, the initial request that started a
> dialog is cached on the sip_pvt struct. This can easily be queried from the
> dialplan. With PJSIP, the pjsip_rx_data for the initial INVITE has been
> freed by the time the dialplan runs.
>
> My thought is to write a session supplement that is triggered on incoming
> INVITEs. The module that implements the session supplement would also
> implement the PJSIP_HEADER dialplan function.
>
> On an incoming INVITE, the session supplement would use pjsip_msg_clone() in
> order to make a copy of the rdata->msg_info.msg. This could then be stored
> on a datastore on the session. When PJSIP_HEADER() is called in order to
> read a specific header, the datastore can be retrieved from the session and
> pjsip_msg_find_hdr_by_name() can be used to find the value of a specific
> header.
>
> As for PJIPAddHeader (or making PJSIP_HEADER operate in write mode to add
> headers), this could be done similarly, but in reverse. When PJSIPAddHeader
> is called, the proposed header could be stored on the session in a
> datastore. On an outgoing INVITE, the session supplement could query the
> datastore for extra headers to add and call ast_sip_add_header() to add the
> headers to the outgoing request. If you look at
> res/res_pjsip/pjsip_global_headers.c, you can see an example of adding
> headers from a list onto requests and responses; however, that file does not
> make use of a datastore.
>
> One further note: PJSIPAddHeader should not work the same way that it
> currently does for chan_sip.c. In chan_sip.c, you call SIPAddHeader on an
> incoming call and the header is then added to the outgoing call's INVITE.
> For PJSIP, we should only ever modify the relevant session. If people want
> to add headers to an outgoing INVITE, then they can use PJSIPAddHeader in a
> predial handler. This adds the flexibility, if desired, of adding specific
> headers to specific outgoing call legs without forcing the same headers on
> all outgoing call legs.
>
>

Perfect!  I can start on this this afternoon actually.  Looks like
there's plenty of material I can draw on.



More information about the asterisk-dev mailing list