[asterisk-dev] [Code Review] Add the ability to set/get custom headers/data on ast_msgs

Terry Wilson reviewboard at asterisk.org
Mon Apr 18 17:14:44 CDT 2011


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1189/
-----------------------------------------------------------

Review request for Asterisk Developers and Russell Bryant.


Summary
-------

This patch adds the ability to store/retrieve custom data (in the case of SIP, custom headers) on an ast_msg.

Currently the channel implementation is done only for SIP as I'm not sure it makes sense on XMPP messages or not. If it does, it should be very easy to add.

The ast_msg implementation is through an ao2_container of key/value pairs that also have a flag for whether or not the data should be sent on outbound messages. This flag is needed because MESSAGE()/MessageSend() on an inbound message carries the data over from the original message. Since we can not upon receiving a message determine which headers are custom and which are not, we must append all of them to the ast_msg. Then, from the dialplan we specify which headers we want to add, delete, or pass through to the outbound message.

To read a header:
exten => s,1,NoOp(${MESSAGE_DATA(headername)})

To add a header:
exten => s,1,Set(MESSAGE_DATA(headername)=Whatever)

To clear a custom header:
exten => s,1,Set(MESSAGE_DATA(headername)=)

To copy a header:
exten => s,1,Set(MESSAGE_DATA(newheadername)=${MESSAGE_DATA(headername)})

To pass a header through:
exten => s,1,Set(MESSAGE_DATA(headername)=${MESSAGE_DATA(headername)})

While the syntax for passing a header through looks a little oddly redundant, it is consistent. It would also be possible to create a dialplan app like MessageDataPassthrough(headername), but I'm not sure I really like that.

NOTE: I see the red. I've already fixed it on my end. :-p


Diffs
-----

  /team/russell/messaging/channels/chan_sip.c 312991 
  /team/russell/messaging/include/asterisk/message.h 312991 
  /team/russell/messaging/main/message.c 312991 

Diff: https://reviewboard.asterisk.org/r/1189/diff


Testing
-------

read, added, cleared, copied, and passed through SIP headers via sipp.


Thanks,

Terry

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20110418/64387574/attachment.htm>


More information about the asterisk-dev mailing list