[reSIProcate] multiple instances of the same parameter in a header

John Gregg jgregg at aylus.com
Fri May 30 10:42:43 CDT 2014


I am running into this situation in a SIP header:

FooHeader: value1;faz-param=45;faz-param=67;faz-param=89;faz-param=123;

And in the current code I have no way of walking through those separate 
instances of the faz-param. Just calling 
msg->header(h_FooHeader).param(p_faz_param) gives me the very first one, 
with no way of getting to the others. So here is what I've done.

in ParserCategory, I gave an optional inst parameter to 
getParameterByEnum and getParameterByData:

Parameter* getParameterByEnum(ParameterTypes::Type type, int inst = 0) 
const;
Parameter* getParameterByData(const Data& data, int inst = 0) const;

I do the same for exists() and param() in ParserCategory and Token, 
modifying the defineParam definition in Token accordingly. That is:

bool exists(const Param<Token>& paramType, int inst = 0) const;
const Data& param(const ExtensionParameter& param, int inst = 0) const;

This way, all the normal code stays the same, and you can call 
msg->header(h_FooHeader).exists(p_faz_param) as always, but you can also 
call msg->header(h_FooHeader).exists(p_faz_param, 3). Interestingly, 
under the hood the multiple parameters were all stored just fine, there 
was just no user-visible way to see them.

I only did the Token derived class, if anyone wants the other classes 
derived from ParserCategory, it should be obvious how to do it (cut and 
paste).

Four diff files attached from resip/stack, version 1.9.6.

-John Gregg



-------------- next part --------------
A non-text attachment was scrubbed...
Name: ParserCategory.cxx.diff
Type: text/x-patch
Size: 2382 bytes
Desc: not available
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20140530/42790590/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ParserCategory.hxx.diff
Type: text/x-patch
Size: 2361 bytes
Desc: not available
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20140530/42790590/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Token.cxx.diff
Type: text/x-patch
Size: 3277 bytes
Desc: not available
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20140530/42790590/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Token.hxx.diff
Type: text/x-patch
Size: 1041 bytes
Desc: not available
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20140530/42790590/attachment-0003.bin>


More information about the resiprocate-devel mailing list