[sr-dev] Header parsing/processing problem

Peter Dunkley peter.dunkley at crocodile-rcs.com
Thu Oct 25 21:37:04 CEST 2012


Thanks,

I've fixed that.  Also put it in a couple of other places where I should
have before - it looks like it's only been luck that this hasn't caused
some problems in the past!

Regards,

Peter

On Thu, 2012-10-25 at 21:09 +0200, Daniel-Constantin Mierla wrote:

> Hello,
> 
> headers are parsed as needed -- the core has an incremental sip
> parser. By default ony few are parsed (like: call-id, csec, to, top
> via).
> 
> Some of the well known headers have internal flags, so parsing to
> locate them would be like (example for Authorization and
> Proxy-Authorization):
> 
> parse_headers(msg, HDR_PROXYAUTH_F|HDR_AUTHORIZATION_F, 0)
> 
> If this function does not return error, then you can get these headers
> via their hooks in the sip_msg_t or iterating through headers list.
> 
> If you look for undefined header, you have to parse to the end of
> headers with:
> 
>     if(parse_headers(msg, HDR_EOH_F, 0)<0)
>     {
>         LM_ERR("error parsing headers\n");
>         return -1;
>     }
> 
> Then you iterate through headers and find it by name if it is actually
> in the message.
> 
> The parser does caching, so when parsing to locate a header, all the
> headers found before it are added to the list. For example, calling
> second time parse_headers(msg, HDR_EOH_F, 0) does pretty much nothing,
> as sip_msg_t keeps a flag that message was already parsed to the last
> header.
> 
> Cheers,
> Daniel
> 
> 
> On 10/25/12 8:58 PM, Peter Dunkley wrote:
> 
> > 
> > Hi,
> > 
> > When adding the oma.xcap-directory auid support to xcap_server I
> > couldn't get the following bit of code (in
> > xcap_server.c:xcaps_get_directory()) to work:
> > 
> >       while (hdr != NULL)
> >         {
> >                 if (cmp_hdrname_strzn(&hdr->name, "Host", 4) == 0)
> >                 {
> >                         server_name = hdr->body;
> >                         break;
> >                 }
> >                 hdr = hdr->next;
> >         }
> > 
> > The host header was never found.  However, simply putting
> > 'xdbg("$hdr(Host)\n");' in event_route[xhttp:request] made it start
> > working.
> > 
> > Have I missed something in the code, or is this a bug?
> > 
> > Regards,
> > 
> > Peter
> > 
> > 
> > -- 
> > Peter Dunkley
> > Technical Director
> > Crocodile RCS Ltd
> > 
> > 
> > 
> > _______________________________________________
> > sr-dev mailing list
> > sr-dev at lists.sip-router.org
> > http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
> 
> 
> 
> -- 
> Daniel-Constantin Mierla - http://www.asipto.com
> http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
> Kamailio Advanced Training, Berlin, Nov 5-8, 2012 - http://asipto.com/u/kat
> Kamailio Advanced Training, Miami, USA, Nov 12-14, 2012 - http://asipto.com/u/katu


-- 
Peter Dunkley
Technical Director
Crocodile RCS Ltd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20121025/eaaa0bc2/attachment.htm>


More information about the sr-dev mailing list