<!DOCTYPE Book PUBLIC "-//OASIS//DTD DocBook V4.2//EN" [

<!ENTITY ser "SIP Express Router">
]>

<book>
    <bookinfo>
	<title>avp Module</title>
	<authorgroup>
	    <author>
		<firstname>Jiri</firstname>
		<surname>Kuthan</surname>
		<affiliation><orgname>FhG Fokus</orgname></affiliation>
		<email>jiri@iptel.org</email>
	    </author>
	</authorgroup>
	<copyright>
	    <year>2004</year>
	    <year>2005</year>
	    <holder>FhG FOKUS</holder>
	</copyright>
	<revhistory>
	    <revision>
		<revnumber>$Revision: 1.1.2.1 $</revnumber>
		<date>$Date: 2005/06/22 23:16:51 $</date>
	    </revision>
	</revhistory>
    </bookinfo>
    <toc></toc>
    
    <chapter>
	<title>User's Guide</title>
	
	<section>
	    <title>Overview</title>
	    <para>
		This module contains several functions that can be used to
		manipulate the contents of AVPs (Attribute-Value pairs). The
		AVPs are variables attached to the SIP message being
		processed. Each variable has its name and value. AVPs can be
		used to store arbitrary data or as a means of inter-module comminication.
		
	    </para>
	    <para>
		You may also want to check the avpops module which is more
		flexible and contains more functions. In future SER releases
		the avp module will be probably deprecated in favor of avpops module.
	    </para>
	</section>
	<section>
	<title>Dependencies</title>
	    <para>
		None.
	    </para>
	</section>
	<section>
	    <title>Exported Parameters</title>
	    <para>
		The module exports no parameters.
	    </para>
	</section>
	
	<section>
	    <title>Exported Functions</title>

	    <section>
		<title><function moreinfo="none">set_iattr(attribute,value)</function></title>
		<para>
		    Create an AVP of type integer.
		</para>
		<para>Meaning of the parameter is as follows:</para>
		<itemizedlist>
		    <listitem>
			<para><emphasis>attribute</emphasis> - The name of of the
			    AVP to be created.
			</para>
		    </listitem>
		    <listitem>
			<para><emphasis>value</emphasis> - Integer value of the AVP.
			</para>
		    </listitem>
		</itemizedlist>
		
		<example>
		    <title><function moreinfo="none">set_iattr</function> usage</title>
		    <programlisting format="linespecific">
...
set_iattr("fr_inv_timer", "60")
...
</programlisting>
		</example>
	    </section>

	    <section>
		<title><function moreinfo="none">flags2attr()</function></title>
		<para>
		    Store the current state of SER flags into AVP called "flags".
		</para>
		<example>
		    <title><function moreinfo="none">flags2attr</function> usage</title>
		    <programlisting format="linespecific">
...
flags2attr()
...
</programlisting>
	    </example>
	    </section>
	    
	    <section>
		<title><function moreinfo="none">set_sattr(attribute,value)</function></title>
		<para>
		    Create an AVP of type string.
		</para>
		<para>Meaning of the parameter is as follows:</para>
		<itemizedlist>
		    <listitem>
			<para><emphasis>attribute</emphasis> - The name of of the
			    AVP to be created.
			</para>
		    </listitem>
		    <listitem>
			<para><emphasis>value</emphasis> - String value of the AVP.
			</para>
		    </listitem>
		</itemizedlist>
		
		<example>
		    <title><function moreinfo="none">set_sattr</function> usage</title>
		    <programlisting format="linespecific">
...
set_sattr("called_number", "1234")
...
</programlisting>
		</example>
	    </section>
	    

	    <section>
		<title><function moreinfo="none">uri2attr(attribute)</function></title>
		<para>
		    Store the Request-URI of the message being processed in an
		    AVP. The new value of the Request-URI will be used if it
		    has been already rewritten by some other function or module.
		</para>
		<para>Meaning of the parameter is as follows:</para>
		<itemizedlist>
		    <listitem>
			<para><emphasis>attribute</emphasis> - The name of of the
			    AVP.
			</para>
		    </listitem>
		</itemizedlist>
		
		<example>
		    <title><function moreinfo="none">uri2attr</function> usage</title>
		    <programlisting format="linespecific">
...
uri2attr("saved_ruri")
...
</programlisting>
		</example>
	    </section>

	    <section>
		<title><function moreinfo="none">print_sattr(attribute)</function></title>
		<para>
		    Print the value of an AVP to syslog.
		</para>
		<para>Meaning of the parameter is as follows:</para>
		<itemizedlist>
		    <listitem>
			<para><emphasis>attribute</emphasis> - The name of of the
			    AVP.
			</para>
		    </listitem>
		</itemizedlist>
	    </section>

	    <section>
		<title><function moreinfo="none">attr2uri(attribute)</function></title>
		<para>
		    Rewrite the Request-URI of the message being processed with
		    the value of an AVP.
		</para>
		<para>Meaning of the parameter is as follows:</para>
		<itemizedlist>
		    <listitem>
			<para><emphasis>attribute</emphasis> - The name of of the
			    AVP.
			</para>
		    </listitem>
		</itemizedlist>
	    </section>

	    <section>
		<title><function moreinfo="none">is_sattr_set(attribute)</function></title>
		<para>
		    Test for the existence of AVP with given name. The function
		    returns 1 if given AVP exists and 0 if not.
		</para>
		<para>Meaning of the parameter is as follows:</para>
		<itemizedlist>
		    <listitem>
			<para><emphasis>attribute</emphasis> - The name of of the
			    AVP.
			</para>
		    </listitem>
		</itemizedlist>
		<example>
		    <title><function moreinfo="none">is_sattr_set</function> usage</title>
		    <programlisting format="linespecific">
...
if (is_sattr_set("saved_ruri")) {
  uri2attr("saved_uri");
} else {
  rewriteuri("sip:a@iptel.org");
};
...
</programlisting>
		</example>
	    </section>

	    <section>
		<title><function moreinfo="none">avp_exists(attribute, value)</function></title>
		<para>
		    Test whether an AVP with given name and value exists. The
		    functio returns 1 if the AVP with given name and value
		    exists and 0 if not. The value of the AVP is compared
		    string-wise. The comparison is case sensitive.
		</para>
		<para>Meaning of the parameter is as follows:</para>
		<itemizedlist>
		    <listitem>
			<para><emphasis>attribute</emphasis> - The name of of the
			    AVP.
			</para>
		    </listitem>
		    <listitem>
			<para><emphasis>value</emphasis> - The AVP value to
			look for.
			</para>
		    </listitem>
		</itemizedlist>
	    </section>
	</section>
    </chapter>
</book>

<!-- Keep this element at the end of the file
Local Variables:
sgml-parent-document: ("auth_radius.sgml" "Book" "chapter")
End:
-->
