<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns:fn="http://www.w3.org/2005/02/xpath-functions"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css"> <title>Erlang -- Definition of Agent Net if</title> </head> <body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container"> <script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript"> <!-- function getWinHeight() { var myHeight = 0; if( typeof( window.innerHeight ) == 'number' ) { //Non-IE myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myHeight = document.body.clientHeight; } return myHeight; } function setscrollpos() { var objf=document.getElementById('loadscrollpos'); document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2; } function addEvent(obj, evType, fn){ if (obj.addEventListener){ obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } addEvent(window, 'load', setscrollpos); //--></script><div id="leftnav"><div class="innertube"> <img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/snmp-4.21.1.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>Simple Network Management Protocol (SNMP)</strong><br><strong>User's Guide</strong><br><small>Version 4.21.1</small></p> <br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Chapters</strong></small></p> <ul class="flipMenu" imagepath="../../../../doc/js/flipmenu"> <li id="no" title="SNMP Introduction" expanded="false">SNMP Introduction<ul> <li><a href="snmp_intro.html"> Top of chapter </a></li> <li title="Scope and Purpose"><a href="snmp_intro.html#id136711">Scope and Purpose</a></li> <li title="Prerequisites"><a href="snmp_intro.html#id134129">Prerequisites</a></li> <li title="Definitions"><a href="snmp_intro.html#id131879">Definitions</a></li> <li title="About This Manual"><a href="snmp_intro.html#id136976">About This Manual</a></li> <li title="Where to Find More Information"><a href="snmp_intro.html#id138752">Where to Find More Information</a></li> </ul> </li> <li id="no" title="Agent Functional Description" expanded="false">Agent Functional Description<ul> <li><a href="snmp_agent_funct_descr.html"> Top of chapter </a></li> <li title="Features"><a href="snmp_agent_funct_descr.html#id139873">Features</a></li> <li title="SNMPv1, SNMPv2 and SNMPv3"><a href="snmp_agent_funct_descr.html#id138359">SNMPv1, SNMPv2 and SNMPv3</a></li> <li title="Operation"><a href="snmp_agent_funct_descr.html#id144137">Operation</a></li> <li title="Sub-agents and MIB Loading"><a href="snmp_agent_funct_descr.html#id148343">Sub-agents and MIB Loading</a></li> <li title="Contexts and Communities"><a href="snmp_agent_funct_descr.html#id148513">Contexts and Communities</a></li> <li title="Management of the Agent"><a href="snmp_agent_funct_descr.html#id148647">Management of the Agent</a></li> <li title="Notifications"><a href="snmp_agent_funct_descr.html#id147124">Notifications</a></li> <li title="Discovery"><a href="snmp_agent_funct_descr.html#id147463">Discovery</a></li> </ul> </li> <li id="no" title="Manager Functional Description" expanded="false">Manager Functional Description<ul> <li><a href="snmp_manager_funct_descr.html"> Top of chapter </a></li> <li title="Features"><a href="snmp_manager_funct_descr.html#id147607">Features</a></li> <li title="Operation"><a href="snmp_manager_funct_descr.html#id149064">Operation</a></li> <li title="MIB loading"><a href="snmp_manager_funct_descr.html#id149132">MIB loading</a></li> </ul> </li> <li id="no" title="The MIB Compiler" expanded="false">The MIB Compiler<ul> <li><a href="snmp_mib_compiler.html"> Top of chapter </a></li> <li title="Operation"><a href="snmp_mib_compiler.html#id149255">Operation</a></li> <li title="Importing MIBs"><a href="snmp_mib_compiler.html#id149318">Importing MIBs</a></li> <li title="MIB Consistency Checking"><a href="snmp_mib_compiler.html#id149389">MIB Consistency Checking</a></li> <li title=".hrl File Generation"><a href="snmp_mib_compiler.html#id149426">.hrl File Generation</a></li> <li title="Emacs Integration"><a href="snmp_mib_compiler.html#id149476">Emacs Integration</a></li> <li title="Compiling from a Shell or a Makefile"><a href="snmp_mib_compiler.html#id149522">Compiling from a Shell or a Makefile</a></li> <li title="Deviations from the Standard"><a href="snmp_mib_compiler.html#id149576">Deviations from the Standard</a></li> </ul> </li> <li id="no" title="Running the application" expanded="false">Running the application<ul> <li><a href="snmp_config.html"> Top of chapter </a></li> <li title="Configuring the application"><a href="snmp_config.html#id149835">Configuring the application</a></li> <li title="Modifying the Configuration Files"><a href="snmp_config.html#id151959">Modifying the Configuration Files</a></li> <li title="Starting the application"><a href="snmp_config.html#id152049">Starting the application</a></li> <li title="Debugging the application"><a href="snmp_config.html#id152099">Debugging the application</a></li> </ul> </li> <li id="no" title="Definition of Agent Configuration Files" expanded="false">Definition of Agent Configuration Files<ul> <li><a href="snmp_agent_config_files.html"> Top of chapter </a></li> <li title="Agent Information"><a href="snmp_agent_config_files.html#id152592">Agent Information</a></li> <li title="Contexts"><a href="snmp_agent_config_files.html#id152669">Contexts</a></li> <li title="System Information"><a href="snmp_agent_config_files.html#id152722">System Information</a></li> <li title="Communities"><a href="snmp_agent_config_files.html#id152790">Communities</a></li> <li title="MIB Views for VACM"><a href="snmp_agent_config_files.html#id152873">MIB Views for VACM</a></li> <li title="Security data for USM"><a href="snmp_agent_config_files.html#id153112">Security data for USM</a></li> <li title="Notify Definitions"><a href="snmp_agent_config_files.html#id153328">Notify Definitions</a></li> <li title="Target Address Definitions"><a href="snmp_agent_config_files.html#id153408">Target Address Definitions</a></li> <li title="Target Parameters Definitions"><a href="snmp_agent_config_files.html#id153614">Target Parameters Definitions</a></li> </ul> </li> <li id="no" title="Definition of Manager Configuration Files" expanded="false">Definition of Manager Configuration Files<ul> <li><a href="snmp_manager_config_files.html"> Top of chapter </a></li> <li title="Manager Information"><a href="snmp_manager_config_files.html#id153846">Manager Information</a></li> <li title="Users"><a href="snmp_manager_config_files.html#id153987">Users</a></li> <li title="Agents"><a href="snmp_manager_config_files.html#id154088">Agents</a></li> <li title="Security data for USM"><a href="snmp_manager_config_files.html#id154271">Security data for USM</a></li> </ul> </li> <li id="no" title="Agent Implementation Example" expanded="false">Agent Implementation Example<ul> <li><a href="snmp_impl_example_agent.html"> Top of chapter </a></li> <li title="MIB"><a href="snmp_impl_example_agent.html#id154522">MIB</a></li> <li title="Default Implementation"><a href="snmp_impl_example_agent.html#id154562">Default Implementation</a></li> <li title="Manual Implementation"><a href="snmp_impl_example_agent.html#id154642">Manual Implementation</a></li> </ul> </li> <li id="no" title="Manager Implementation Example" expanded="false">Manager Implementation Example<ul> <li><a href="snmp_impl_example_manager.html"> Top of chapter </a></li> <li title="The example manager"><a href="snmp_impl_example_manager.html#id154974">The example manager</a></li> <li title="A simple standard test"><a href="snmp_impl_example_manager.html#id155064">A simple standard test</a></li> </ul> </li> <li id="no" title="Instrumentation Functions" expanded="false">Instrumentation Functions<ul> <li><a href="snmp_instr_functions.html"> Top of chapter </a></li> <li title="Instrumentation Functions"><a href="snmp_instr_functions.html#id155207">Instrumentation Functions</a></li> <li title="Using the ExtraArgument"><a href="snmp_instr_functions.html#id155822">Using the ExtraArgument</a></li> <li title="Default Instrumentation"><a href="snmp_instr_functions.html#id155930">Default Instrumentation</a></li> <li title="Atomic Set"><a href="snmp_instr_functions.html#id156035">Atomic Set</a></li> </ul> </li> <li id="no" title="Definition of Instrumentation Functions" expanded="false">Definition of Instrumentation Functions<ul> <li><a href="snmp_def_instr_functions.html"> Top of chapter </a></li> <li title="Variable Instrumentation"><a href="snmp_def_instr_functions.html#id156211">Variable Instrumentation</a></li> <li title="Table Instrumentation"><a href="snmp_def_instr_functions.html#id156586">Table Instrumentation</a></li> </ul> </li> <li id="loadscrollpos" title="Definition of Agent Net if" expanded="true">Definition of Agent Net if<ul> <li><a href="snmp_agent_netif.html"> Top of chapter </a></li> <li title="Mandatory Functions"><a href="snmp_agent_netif.html#id157489">Mandatory Functions</a></li> <li title="Messages"><a href="snmp_agent_netif.html#id157511">Messages</a></li> </ul> </li> <li id="no" title="Definition of Manager Net if" expanded="false">Definition of Manager Net if<ul> <li><a href="snmp_manager_netif.html"> Top of chapter </a></li> <li title="Mandatory Functions"><a href="snmp_manager_netif.html#id158310">Mandatory Functions</a></li> <li title="Messages"><a href="snmp_manager_netif.html#id158328">Messages</a></li> </ul> </li> <li id="no" title="Audit Trail Log" expanded="false">Audit Trail Log<ul> <li><a href="snmp_audit_trail_log.html"> Top of chapter </a></li> <li title="Agent Logging"><a href="snmp_audit_trail_log.html#id158735">Agent Logging</a></li> <li title="Manager Logging"><a href="snmp_audit_trail_log.html#id158778">Manager Logging</a></li> </ul> </li> <li id="no" title="Advanced Agent Topics" expanded="false">Advanced Agent Topics<ul> <li><a href="snmp_advanced_agent.html"> Top of chapter </a></li> <li title="When to use a Sub-agent"><a href="snmp_advanced_agent.html#id158927">When to use a Sub-agent</a></li> <li title="Agent Semantics"><a href="snmp_advanced_agent.html#id159037">Agent Semantics</a></li> <li title="Sub-agents and Dependencies "><a href="snmp_advanced_agent.html#id159101">Sub-agents and Dependencies </a></li> <li title="Distributed Tables"><a href="snmp_advanced_agent.html#id159118">Distributed Tables</a></li> <li title="Fault Tolerance"><a href="snmp_advanced_agent.html#id159175">Fault Tolerance</a></li> <li title="Using Mnesia Tables as SNMP Tables"><a href="snmp_advanced_agent.html#id159249">Using Mnesia Tables as SNMP Tables</a></li> <li title="Deviations from the Standard"><a href="snmp_advanced_agent.html#id159527">Deviations from the Standard</a></li> </ul> </li> <li id="no" title="SNMP Appendix A" expanded="false">SNMP Appendix A<ul> <li><a href="snmp_app_a.html"> Top of chapter </a></li> <li title="Appendix A"><a href="snmp_app_a.html#id159675">Appendix A</a></li> </ul> </li> <li id="no" title="SNMP Appendix B" expanded="false">SNMP Appendix B<ul> <li><a href="snmp_app_b.html"> Top of chapter </a></li> <li title="Appendix B"><a href="snmp_app_b.html#id160066">Appendix B</a></li> </ul> </li> </ul> </div></div> <div id="content"> <div class="innertube"> <h1>12 Definition of Agent Net if</h1> <p></p> <img alt="IMAGE MISSING" src="snmp_agent_netif_1.gif"><br> <em>Figure 12.1: The Purpose of Agent Net if</em> <p>The Network Interface (Net if) process delivers SNMP PDUs to a master agent, and receives SNMP PDUs from the master agent. The most common behaviour of a Net if process is that is receives bytes from a network, decodes them into an SNMP PDU, which it sends to a master agent. When the master agent has processed the PDU, it sends a response PDU to the Net if process, which encodes the PDU into bytes and transmits the bytes onto the network. </p> <p>However, that simple behaviour can be modified in numerous ways. For example, the Net if process can apply some kind of encrypting/decrypting scheme on the bytes or act as a proxy filter, which sends some packets to a proxy agent and some packets to the master agent. </p> <p>It is also possible to write your own Net if process. The default Net if process is implemented in the module <span class="code">snmpa_net_if</span> and it uses UDP as the transport protocol. </p> <p>This section describes how to write a Net if process. </p> <h3><a name="id157489">12.1 Mandatory Functions</a></h3> <a name="mandatory_functions"></a> <p>A Net if process must implement the SNMP agent <span class="bold_code"><a href="snmpa_network_interface.html">network interface behaviour</a></span>. </p> <h3><a name="id157511">12.2 Messages</a></h3> <a name="messages"></a> <p>The section <strong>Messages</strong> describes mandatory messages, which Net if must send and be able to receive. </p> <h4>Outgoing Messages</h4> <a name="outgoing_messages"></a> <p>Net if must send the following message when it receives an SNMP PDU from the network that is aimed for the MasterAgent: </p> <a name="om_snmp_pdu"></a> <div class="example"><pre> MasterAgent ! {snmp_pdu, Vsn, Pdu, PduMS, ACMData, From, Extra} </pre></div> <ul> <li> <span class="code">Vsn</span> is either <span class="code">'version-1'</span>, <span class="code">'version-2'</span>, or <span class="code">'version-3'</span>. </li> <li> <span class="code">Pdu</span> is an SNMP PDU record, as defined in <span class="code">snmp_types.hrl</span>, with the SNMP request. </li> <li> <span class="code">PduMS</span> is the Maximum Size of the response Pdu allowed. Normally this is returned from <span class="code">snmpa_mpd:process_packet</span> (see Reference Manual). </li> <li> <span class="code">ACMData</span> is data used by the Access Control Module in use. Normally this is returned from <span class="code">snmpa_mpd:process_packet</span> (see Reference Manual). </li> <li> <span class="code">From</span> is the source address. If UDP over IP is used, this should be a 2-tuple <span class="code">{IP, UDPport}</span>, where <span class="code">IP</span> is a 4-tuple with the IP address, and <span class="code">UDPport</span> is an integer. </li> <li> <span class="code">Extra</span> is any term the Net if process wishes to send to the agent. This term can be retrieved by the instrumentation functions by calling <span class="code">snmp:current_net_if_data()</span>. This data is also sent back to the Net if process when the agent generates a response to the request.</li> </ul> <p>The following message is used to report that a response to a request has been received. The only request an agent can send is an Inform-Request. </p> <a name="om_snmp_response_received"></a> <div class="example"><pre> Pid ! {snmp_response_received, Vsn, Pdu, From} </pre></div> <ul> <li> <span class="code">Pid</span> is the Process that waits for the response for the request. The Pid was specified in the <span class="code">send_pdu_req</span> message <span class="bold_code"><a href="#im_send_pdu_req">(see below)</a></span>. </li> <li> <span class="code">Vsn</span> is either <span class="code">'version-1'</span>, <span class="code">'version-2'</span>, or <span class="code">'version-3'</span>. </li> <li> <span class="code">Pdu</span> is the SNMP Pdu received </li> <li> <span class="code">From</span> is the source address. If UDP over IP is used, this should be a 2-tuple <span class="code">{IP, UDPport}</span>, where <span class="code">IP</span> is a 4-tuple with the IP address, and <span class="code">UDPport</span> is an integer. </li> </ul> <h4>Incoming Messages</h4> <a name="incoming_messages"></a> <p>This section describes the incoming messages which a Net if process must be able to receive. </p> <ul> <li> <a name="im_snmp_response"></a> <p><span class="code">{snmp_response, Vsn, Pdu, Type, ACMData, To, Extra}</span></p> <p>This message is sent to the Net if process from a master agent as a response to a previously received request. </p> <ul> <li> <p><span class="code">Vsn</span> is either <span class="code">'version-1'</span>, <span class="code">'version-2'</span>, or <span class="code">'version-3'</span>. </p> </li> <li> <p><span class="code">Pdu</span> is an SNMP PDU record (as defined in snmp_types.hrl) with the SNMP response. </p> </li> <li> <p><span class="code">Type</span> is the <span class="code">#pdu.type</span> of the original request. </p> </li> <li> <p><span class="code">ACMData</span> is data used by the Access Control Module in use. Normally this is just sent to <span class="code">snmpa_mpd:generate_response_message</span> (see Reference Manual). </p> </li> <li> <p><span class="code">To</span> is the destination address. If UDP over IP is used, this should be a 2-tuple <span class="code">{IP, UDPport}</span>, where <span class="code">IP</span> is a 4-tuple with the IP address, and <span class="code">UDPport</span> is an integer. </p> </li> <li> <p><span class="code">Extra</span> is the term that the Net if process sent to the agent when the request was sent to the agent. </p> </li> </ul> </li> <li> <a name="im_discarded_pdu"></a> <p><span class="code">{discarded_pdu, Vsn, ReqId, ACMData, Variable, Extra}</span></p> <p>This message is sent from a master agent if it for some reason decided to discard the pdu. </p> <ul> <li> <p><span class="code">Vsn</span> is either <span class="code">'version-1'</span>, <span class="code">'version-2'</span>, or <span class="code">'version-3'</span>. </p> </li> <li> <p><span class="code">ReqId</span> is the request id of the original request. </p> </li> <li> <p><span class="code">ACMData</span> is data used by the Access Control Module in use. Normally this is just sent to <span class="code">snmpa_mpd:generate_response_message</span> (see Reference Manual). </p> </li> <li> <p><span class="code">Variable</span> is the name of an snmp counter that represents the error, e.g. <span class="code">snmpInBadCommunityUses</span>. </p> </li> <li> <p><span class="code">Extra</span> is the term that the Net if process sent to the agent when the request was sent to the agent. </p> </li> </ul> </li> <li> <a name="im_send_pdu"></a> <p><span class="code">{send_pdu, Vsn, Pdu, MsgData, To, Extra}</span></p> <p>This message is sent from a master agent when a trap is to be sent. </p> <ul> <li> <p><span class="code">Vsn</span> is either <span class="code">'version-1'</span>, <span class="code">'version-2'</span>, or <span class="code">'version-3'</span>.</p> </li> <li> <p><span class="code">Pdu</span> is an SNMP PDU record (as defined in snmp_types.hrl) with the SNMP response. </p> </li> <li> <p><span class="code">MsgData</span> is the message specific data used in the SNMP message. This value is normally sent to <span class="code">snmpa_mpd:generate_message/4</span>. In SNMPv1 and SNMPv2c, this message data is the community string. In SNMPv3, it is the context information. </p> </li> <li> <p><span class="code">To</span> is a list of the destination addresses and their corresponding security parameters. This value is normally sent to <span class="code">snmpa_mpd:generate_message/4</span>. </p> </li> <li> <p><span class="code">Extra</span> is any term that the notification sender wishes to pass to the Net if process when sending a notification (see <span class="bold_code"><a href="snmpa.html#send_notification2">send notification </a></span> for more info). </p> </li> </ul> </li> <li> <a name="im_send_pdu_req"></a> <p><span class="code">{send_pdu_req, Vsn, Pdu, MsgData, To, Pid, Extra}</span></p> <p>This message is sent from a master agent when a request is to be sent. The only request an agent can send is Inform-Request. The net if process needs to remember the request id and the Pid, and when a response is received for the request id, send it to Pid, using a <span class="code">snmp_response_received</span> message. </p> <ul> <li> <p><span class="code">Vsn</span> is either <span class="code">'version-1'</span>, <span class="code">'version-2'</span>, or <span class="code">'version-3'</span>.</p> </li> <li> <p><span class="code">Pdu</span> is an SNMP PDU record (as defined in snmp_types.hrl) with the SNMP response. </p> </li> <li> <p><span class="code">MsgData</span> is the message specific data used in the SNMP message. This value is normally sent to <span class="code">snmpa_mpd:generate_message/4</span>. In SNMPv1 and SNMPv2c, this message data is the community string. In SNMPv3, it is the context information. </p> </li> <li> <p><span class="code">To</span> is a list of the destination addresses and their corresponding security parameters. This value is normally sent to <span class="code">snmpa_mpd:generate_message/4</span>. </p> </li> <li> <p><span class="code">Pid</span> is a process identifier. </p> </li> <li> <p><span class="code">Extra</span> is any term that the notification sender wishes to pass to the Net if process when sending a notification (see <span class="bold_code"><a href="snmpa.html#send_notification2">send notification </a></span> for more info). </p> </li> </ul> </li> </ul> <h4>Notes</h4> <p>Since the Net if process is responsible for encoding and decoding of SNMP messages, it must also update the relevant counters in the SNMP group in MIB-II. It can use the functions in the module <span class="code">snmpa_mpd</span> for this purpose (refer to the Reference Manual, section <span class="code">snmp</span>, module <span class="bold_code"><a href="snmp_pdus.html">snmpa_mpd</a></span> for more details.) </p> <p>There are also some useful functions for encoding and decoding of SNMP messages in the module <span class="bold_code"><a href="snmp_pdus.html">snmp_pdus</a></span>. </p> </div> <div class="footer"> <hr> <p>Copyright © 1997-2011 Ericsson AB. All Rights Reserved.</p> </div> </div> </div></body> </html>