[asterisk-users] Parsing custom SIP headers

Philipp Kempgen philipp.kempgen at amooma.de
Sun Nov 29 06:34:53 CST 2009


Hi,

Just to be sure: Is there a dialplan function in Asterisk that
parses custom "name-addr"-style SIP headers for me?

If I wanted to do it right the syntax
	name-addr *(SEMI generic-param)
is quite complex to parse in the dialplan using nothing but CUT().
It's so easy to make false assumtions about angle brackets (< >),
whitespace (LWS), quotes (") around the display-name, character
escaping etc. All of the applications of CUT() I have seen are
way too simplistic.

Example of how it could work:
Set(addr=${SIP_PARSE_HEADER(${SIP_HEADER(P-Asserted-Identity)},addr-spec)});

Interesting parts include:
name-addr, display-name, addr-spec, scheme, userinfo, user,
telephone-subscriber, host, hostname, port, ...

Actually headers like P-Asserted-Identity can even have more then
one value.
---cut---
      PAssertedID = "P-Asserted-Identity" HCOLON PAssertedID-value
                      *(COMMA PAssertedID-value)
      PAssertedID-value = name-addr / addr-spec
---cut---
so I guess SIP_PARSE_HEADER() would need an index argument, just
like SIP_HEADER().

Proper parsing could be done in an AGI() script of course but that
involves a big overhead especially since the code to parse name-addr
is already in Asterisk. It's just not available in the dialplan.


    Philipp Kempgen
-- 
AMOOMA GmbH - Bachstr. 126 - 56566 Neuwied  ->  http://www.amooma.de
Geschäftsführer: Stefan Wintermeyer, Handelsregister: Neuwied B14998
Asterisk: http://the-asterisk-book.com - http://das-asterisk-buch.de
Videos of the AMOOCON VoIP conference 2009 ->  http://www.amoocon.de
-- 



More information about the asterisk-users mailing list