[asterisk-dev] Adding headers to NOTIFY responses

asterisk at phreaknet.org asterisk at phreaknet.org
Tue Nov 15 08:44:25 CST 2022


I am working on something where I need to be able to add a custom header 
to an outgoing NOTIFY response for a subscription.

We have the concept of "body generators" for adding stuff to the body of 
an outgoing NOTIFY, but I'm not seeing anything akin to "header 
generators" that would easily allow doing this.

I believe typically this is done by adding the header to the tdata pool, 
e.g. ast_sip_add_header(tdata, "Expires", buf) as one way of doing it.

However, res_pjsip_pubsub doesn't generate/initialize a pjsip_tx_data 
until after ast_sip_subscription_notify is already called, so it 
certainly can't be done before a pubsub module calls on the pubsub core 
to send the notify. Is there any way I've missed that allows us to 
access the tdata from a pubsub module, so we can add a header to the 
NOTIFY response?

I do see there is an ast_sip_subscription_response_data struct defined 
in res_pjsip_pubsub.h. However, this is used literally nowhere in the 
code, only defined, so it's not clear to me how this is supposed to be 
used, since nothing currently uses it. Was this intended to be used for 
this purpose, or something else?

If res_pjsip_pubsub would need to be extended to support this, would it 
reasonable to add a callback to a pubsub module that allows it access to 
the pjsip_tx_data, so it can do whatever it needs to with it, before the 
response gets sent? Or another preferred method of allowing modules to 
add headers?

Any insights or thoughts on this appreciated... thanks!

NA




More information about the asterisk-dev mailing list