[sr-dev] Header parsing/processing problem
Daniel-Constantin Mierla
miconda at gmail.com
Thu Oct 25 21:09:11 CEST 2012
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20121025/626e684e/attachment.htm>
More information about the sr-dev
mailing list