< Previous by Date Date Index Next by Date >
  Thread Index  

[reSIProcate] resip::HeaderBase


Greetings,

I have written a routing engine with a plugin architecture for SIP
routing using reciprocate as an underlying sip stack.  From my routing
script, I load a plugin which can modify the sip message.  One of the
functions of this plugin is designed to remove a sip header from the sip
message, should it exist.

My routing script might look like this: <RemoveHeader
headerName="Expires"/>

I will only have the string name of the header in which to search for
within the SIP message (in this particular case "Expires").  Ultimately,
what I am trying to do is search the sip message for the given header
name, and then remove it.

Generally speaking, I am looking for a way to search the SipMessage
object for a given header.  The only way that I have found to do this is
to get the raw headers and the raw unknown headers and search through
them because you don't know if the header you are looking for is of a
predefined HeaderBase Type.  If it does turn out to be a known
Header::Type (using resip::Headers::getType()), then it does not seem to
me that one can ever get the HeaderBase from a Header::Type so that I
can use the exists() or remove() method in the Sip::Message.

I hope this is a sufficient explanation.

Thanks in advance!
Michael Baj

/*****
 * Sample pseudo code
 * note:  This does not work or compile
 ******/

std::string headerName("Expires");
resip::Headers::Type headerType =
resip::Headers::getType(headerName.c_str(), headerName.length());


if ( headerType != resip::Headers::UNKNOWN )
{
        // normal header type
        if ( message.exists( headerType ) )
        {
                message.remove( headerType );
        }
        else
        {
                // header must be an extension header
                resip::ExtensionHeader eh( headerName.c_str() );
                if ( message.exists( eh ) )
                {
                        message.remove( eh );
                }
        }
}