[Serdev] How does SER handle special headers?

Andrei Pelinescu-Onciul andrei at iptel.org
Tue Jun 28 21:42:33 UTC 2005


On Jun 28, 2005 at 19:37, Sven Ehlert <ehlert at fokus.fraunhofer.de> wrote:
> Hello,
> 
> After reading the SER Developer guide I wonder how does SER handle some
> special formed SIP messages where the header bodies to the same header
> field are split among different lines, e.g.
> 
> INVITE ...
> SomeHeader ...
> Contact : <sip:user at here.com>
> SomeOtherHeader ...
> YetAnotherHeader ...
> Contact: <sip:away at where.com>
> AndAnotherHeader ...
> Contact: <sip:me at there.com>
> ...
> 
> According to the (outdated?) Guide the parser incrementally parses the
> message, and stores the first occurence of the Contact field in a
> sip_msg->contact field.
> I'm wondering where the rest will go, as it says that only the first
> occurrence is stored there, further ones all go into the
> sip_msg->headers field. But How are they there accessed later? And how
> can they be found if the messages is constructed in the (well, highly
> unlikely) format as mentioned above?

You iterate on the headers list and check if the header type is what you
are looking for.

E.g., if you want to get all the contacts:

parse_heqaders(msg, HDR_EOH_T, 0);  /* you have to parse all the message
                                      if you want all the headers of
                                      some type */
/* error checks omitted */
for (hdr=msg->contact;  hdr; hdr=hdr->next){
    if (hdr->type==HDR_CONTACT_T){
        /* do something with it */
    }
}



Andrei




More information about the Serdev mailing list