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

[reSIProcate] FW: resip::SipMessage:addHeader


Greetings,

I have a unique problem with using reciprocate.  Below is an email
thread I have been having with Alan Hawrylyshen.  We have not been able
to come up with an answer.  I sincerely hope one of you might be able to
help out.

Thanks in advance!
Michael Baj

-----Original Message-----
From: Michael Baj 
Sent: Friday, January 13, 2006 10:10 AM
To: 'Alan Hawrylyshen'
Subject: RE: resip::SipMessage:addHeader

Alan,

This is precisely my problem.  The method SipMessage::exists() takes an
argument of type HeaderBase, not Header::Type.  My problem is that I
don't know how to convert a known Header::Type to a HeaderBase.

Thanks,
Mike

-----Original Message-----
From: Alan Hawrylyshen [mailto:ahawrylyshen@xxxxxxxxxxxxxxxxxxxxx] 
Sent: Thursday, January 12, 2006 8:04 PM
To: Michael Baj
Subject: Re: resip::SipMessage:addHeader

I would suggest calling the in_word_set wrapper to get the type  
(enum) if the header IS known. If you get Unknown as the type, then  
you can iterate and search on only the UNKNOWN headers...

In pseudocode it would look like:

const char * headername = "Expires";

Header::type t = Headers::toType(headername);

if (t != Headers::UNKNOWN)
{
        if (message.exists(t)) message.erase(t);
} else {
        // iterate through unknown headers
}

I'll try to dig something up that's more concrete than this. I  
haven't done this in a LONG while, but there are examples in the test  
driver directories that show known vs. unknown (extension) header  
manipulations.

A

On 2006.01.11, at 13:24 , Michael Baj wrote:

> Alan,
>
> Thanks for replying so quickly.
>
> 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 if it exists.
>
> My routing script might look like this: <RemoveHeader
> headerName="Expires"/>
>
> That being said, 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  
> already
> a predefined HeaderBase.  If it does turn out to be a known  
> Header::Type
> (using resip::Headers::getType()), then it does not seem to me that  
> you
> can ever get the HeaderBase of the Header::Type so that I can use the
> exists() method in the Sip::Message.
>
> I hope this clears up the issue a little more.  If not, I will gladly
> share more with you as well as any code that might help further  
> explain
> the situation.
>
> Michael Baj
>
>
> -----Original Message-----
> From: Alan Hawrylyshen [mailto:ahawrylyshen@xxxxxxxxxxxxxxxxxxxxx]
> Sent: Tuesday, January 10, 2006 5:03 PM
> To: Michael Baj
> Subject: Re: resip::SipMessage:addHeader
>
> I'm not 100% sure I understand the dilema and it appears that your
> pseudo code has an error, so can you please describe what you have,
> and what you want a bit more clearly and I'll see if I can assist at
> all. You might want to post to the resiprocate-devel list too.
>
> Alan
>
> On 2006.01.10, at 13:44 , Michael Baj wrote:
>
>> Is it possible to convert a resip::Header::Type to a
>> resip::HeaderBase?
>>
>> This is what I am trying to do and I find it odd that it can not be
>> done.
>> Ultimately, I want to remove the header from the SIP message, but I
>> don't know what type it is other than by name.
>>
>> The resip::SipMessage::remove() method simply calls
>> resip::HeaderBase:getTypeNum().  Shouldn't there also be a means of
>> passing in the Header::Type?
>>
>> std::string headerName("To");
>> resip::Headers::Type headerType =
>> resip::Headers::getType(headerName.c_str(), headerName.length());
>>
>> if ( headerType != resip::Headers::UNKNOWN )
>> {
>>      // normal header type
>>      if ( message.exists( headerType ) )
>>      {
>>              //...
>>      }
>>      else
>>      {
>>              // header must be an extension header
>>              resip::ExtensionHeader eh( headerName.c_str() );
>>              if ( message.exists( eh ) )
>>              {
>>                      //...
>>              }
>>      }
>> }
>>
>> Thanks in advance!
>> Michael Baj
>
>
>
> --
> a h a w r y l y s h e n a t u s e r s d o t s o u r c e f o r g e d o
> t n e t