<?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="maxfwd.functions" xmlns:xi="http://www.w3.org/2001/XInclude">
    <sectioninfo>
	<revhistory>
	    <revision>
		<revnumber>$Revision: 1.1 $</revnumber>
		<date>$Date: 2005/11/17 12:28:12 $</date>
	    </revision>
	</revhistory>
    </sectioninfo>

    <title>Functions</title>

    <section id="mf_process_maxfwd_header">
	<title>
	    <function>mf_process_maxfwd_header(max_value)</function>
	</title>
	<para>
	    If no Max-Forward header is present in the received request, a
	    header will be added having the original value equal with
	    "max_value". An OK code is returned by the function.
	</para>
	<para>
	    If a Max-Forward header is already present, its value will be
	    decremented. If after this operation its value will be positive
	    non-zero, an OK code will be returned. Otherwise (for a zero value)
	    an error code will be returned.  Note that an error code will be
	    also returned if the SIP message couldn't be parsed or if the
	    Max-Forward header's body invalid (non numerical string or negative
	    numerical value).
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para>
		    <emphasis>max_value</emphasis> - Value to be added if there
		    is no Max-Forwards header field in the message.
		</para>
	    </listitem>
	</itemizedlist>
	<example>
	    <title><function>mx_process_maxfwd_header</function> usage</title>
	    <programlisting>
...
# initial sanity checks -- messages with
# max_forwards==0, or excessively long requests
if (!mf_process_maxfwd_header("10")) {
    sl_send_reply("483","Too Many Hops");
    break;
};
...
	    </programlisting>
	</example>
    </section>
</section>
