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

Re: [reSIProcate] accessing headers parameters


Most of what was said was absolutely correct (particularly the pointer to the
bit of documentation and examples). However, there was a little confusion about
the specific header involved.

The "Contact" header allows mulitple values.
Resiprocate manages this by returning a collection from the header accessor.

Collections of headers do not have parameters; each header value has its own
parameters.

NameAddrs is a collection of NameAddr.

So the code will be more like:

// access parameter on first contact:
if (sipmessage->exists(h_Contacts))
{
   const NameAddrs& contacts = sipmessage->header(h_Contacts);
   if (!contacts.empty())
   {
      // this is a design bug -- should return an IntegerParameter,
      // but does not!
      int expires = contacts.front().param(p_expires);
   }
}

// access each contact's parameters:
if (sipmessage->exists(h_Contacts))
{
    for (NameAddrs::const_iterator i = sipmessage->header(h_Contacts).begin();
         i != sipmessage->header(h_Contacts).end(); ++i)
    {
       int expires = i->param(p_expires);
       ...
    }
}

david


Quoting Jason Fischl <jason@xxxxxxxxxxxxxx>:

> Gianluca Martiniello wrote:
> > Hi,
> > 
> > I am trying to use resiprocate to implement a registrar server. I need 
> > to access various headers parameters (e.g. "expires" parameter in 
> > contact header) and I wonder if there is some way to get a parameter 
> > value from an header.
> > 
> > For instance, when I need to get the header contact from a sip message 
> > what I do is:
> > 
> > NameAddrs contacts = sipmessage->header(h_Contacts);
> > 
> > Is there a similar method to get the parameters associated to this 
> > header? Something like:
> > 
> > IntegerParameter expires = contacts.parameter(p_expires);
> > 
> 
> Yes
> // access the value:
> int expires = contacts.param(p_expires);
> 
> // set the vlaue
> contacts.param(p_expires) = 50;
> 
> Some more documentation on using the parser.
> http://www.sipfoundry.org/reSIProcate/using.txt
> 
> > 
> > Thanks in advance,
> > 
> > Gianluca
> > _______________________________________________
> > resiprocate-devel mailing list
> > resiprocate-devel@xxxxxxxxxxxxxxxxxxx
> > https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel
> 
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel@xxxxxxxxxxxxxxxxxxx
> https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel
>