OK Thanks Daniel.
I was initially thinking this was a cost of memory vs. CPU scenario, but
actually on 2nd thoughts, the CPU cycles is the same. So effectively we use
less memory by default and any code that requires extra headers can parse
them on a need-to-have basis.
Thanks for clearing up
Cheers
Jason
On Fri, Nov 4, 2011 at 10:49 AM, Daniel-Constantin Mierla <miconda(a)gmail.com
Hi Jason,
I'm just continuing on a topic discussed few messages back in this thread.
Actually it is recommended to avoid adding new direct header hooks in
sip_msg_t structure, because it becomes too big compared with what actually
a SIP message has in terms of headers. Apart of invite which can have
between 10-20 headers in average, the rest have less number of headers.
Note that all headers are linked in a list held in sip_msg_t->headers.
Getting a header from the list is possible with several functions,
depending whether you want the first or next header, searched by internal
ID (if that header has one) or simply by name. The prototypes for these
functions are in parser/msg_parse.h:
hdr_field_t* get_hdr(sip_msg_t *msg, enum _hdr_types_t ht);
hdr_field_t* next_sibling_hdr(hdr_field_t *hf);
hdr_field_t* get_hdr_by_name(sip_msg_t *msg, char *name, int name_len);
hdr_field_t* next_sibling_hdr_by_name(hdr_field_t *hf);
So getting my X-Header would be like:
parse_headers(msg, HDR_EOH_F, 0);
hdr = get_hdr_by_name(msg, "X-Header", strlen("X-Header"));
Some of them may be even removed from sip_msg_t (like priority or subject)
which are not common at all.
Cheers,
Daniel
On 11/4/11 6:35 AM, Jason Penton wrote:
Hey Henning,
Ahh, thanks for that, thats perfect for now!
A pity, those names should have been a little more descriptive ;)
Thanks
Jason
On Thu, Nov 3, 2011 at 3:27 PM, Henning Westerholt <hw(a)kamailio.org>wrote;wrote:
On Thursday 03 November 2011, Jason Penton
wrote:
For Asserted and preferred identities, we
don't need to parse the
content,
but in other headers I have not gotten to yet, we
may need to.
Hi Jason,
do you talk about p-asserted and p-preferred header? This are fairly
standard
headers, there are even some PVs to access them right now i think.
Please help me understand, I would have thought
from an architecture
perspective, we would populate the sip_msg structure with all possible
sip
headers as well as the parsers. What is the
reason we don't do this
currently? performance?
I'd guess the reasons is memory efficiency. The structure get bigger and
bigger with every pointer. But for p-asserted and p-preffered, they are
already included it seems:
struct hdr_field* pai;
struct hdr_field* ppi;
Best regards,
Henning
_______________________________________________
sr-dev mailing
listsr-dev@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
--
Daniel-Constantin Mierla --
http://www.asipto.com
Kamailio Advanced Training, Dec 5-8, Berlin:
http://asipto.com/u/kathttp://linkedin.com/in/miconda --
http://twitter.com/miconda