You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kamailio/doc/tutorials/serdev/to_parser.xml

59 lines
2.4 KiB

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<section id="to_parser" xmlns:xi="http://www.w3.org/2001/XInclude">
<sectioninfo>
<revhistory>
<revision>
<revnumber>$Revision$</revnumber>
<date>$Date$</date>
</revision>
</revhistory>
</sectioninfo>
<title>To Header Field Parser</title>
<para>
Purpose of this parser is to parse body of To header field. The parser
can be found in file <filename>parse_to.c</filename> under
<filename>parser</filename> subdirectory.
</para>
<para>
Main function is <function>parse_to</function> but there is no need to
call the function explicitly. Every time the parser finds a To header
field, this function will be called automatically. Result of the parser
is <structname>to_body</structname> structure. Pointer to the structure
will be stored in <structfield>parsed</structfield> field of
<structname>hdr_field</structname> structure. Since the pointer is
<type>void*</type>, there is a convenience macro
<function>get_to</function> in file <filename>parse_to.h</filename>
that will do the necessary type-casting and will return pointer to
<structname>to_body</structname> structure.
</para>
<para>
The parser itself is a finite state machine that will parse To body
according to the grammar defined in <acronym>RFC3261</acronym> and
store result in <structname>to_body</structname> structure.
</para>
<para>
The parser gets called automatically from function
<function>get_hdr_field</function> in file
<filename>msg_parser.c</filename>. The function first creates and
initializes an instance of <structname>to_body</structname> structure,
then calls <function>parse_to</function> function with the structure as
a parameter and if everything went OK, puts the pointer to the
structure in <structfield>parsed</structfield> field of
<structname>hdr_field</structname> structure representing the parsed To
header field.
</para>
<para>
The newly created structure will be freed when the message is being
destroyed, see function <function>clean_hdr_field</function> in file
<filename>hf.c</filename> for more details.
</para>
<para>
See <xref linkend="to_body"/> for detailed description of the data
structure produced by this parser.
</para>
</section>