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

Russell Bryant reviewboard at asterisk.org
Mon Apr 25 12:46:36 CDT 2011


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

Ship it!


It would be really awesome to have what you described as how you tested this in the form of tests in the testsuite.  :-)


/team/russell/messaging/main/message.c
<https://reviewboard.asterisk.org/r/1189/#comment7050>

    It's probably worth noting in the documentation that the data is stored in an unordered fashion.  The order in which the data will be placed on the outgoing message is undefined.  I don't think this will be a problem, but it would be good to note it in case someone expects the headers to show up in a SIP MESSAGE in the same order that it was added in the dialplan.


- Russell


On 2011-04-21 11:17:06, Terry Wilson wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1189/
> -----------------------------------------------------------
> 
> (Updated 2011-04-21 11:17:06)
> 
> 
> 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/doc/asterisk-messaging.txt 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/20110425/d984438d/attachment.htm>


More information about the asterisk-dev mailing list