<?xml version="1.0" encoding="latin1" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<erlref>
  <header>
    <copyright>
      <year>2007</year><year>2010</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      The contents of this file are subject to the Erlang Public License,
      Version 1.1, (the "License"); you may not use this file except in
      compliance with the License. You should have received a copy of the
      Erlang Public License along with this software. If not, it can be
      retrieved online at http://www.erlang.org/.

      Software distributed under the License is distributed on an "AS IS"
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
      the License for the specific language governing rights and limitations
      under the License.

    </legalnotice>

    <title>snmpa_network_interface_filter</title>
    <prepared></prepared>
    <responsible></responsible>
    <docno></docno>
    <approved></approved>
    <checked></checked>
    <date></date>
    <rev></rev>
    <file>snmpa_network_interface_filter.xml</file>
  </header>
  <module>snmpa_network_interface_filter</module>
  <modulesummary>Behaviour module for the SNMP agent network-interface filter.</modulesummary>
  <description>
    <p>This module defines the behaviour of the agent network interface
      filter. A <c>snmpa_network_interface_filter</c> compliant module 
      must export the following functions: </p>
    <list type="bulleted">
      <item>
        <p><seealso marker="#accept_recv">accept_recv/2</seealso></p>
      </item>
      <item>
        <p><seealso marker="#accept_send">accept_send/2</seealso></p>
      </item>
      <item>
        <p><seealso marker="#accept_recv_pdu">accept_recv_pdu/3</seealso></p>
      </item>
      <item>
        <p><seealso marker="#accept_send_pdu">accept_send_pdu/2</seealso></p>
      </item>
    </list>
    <p>The semantics of them and their exact signatures are explained
      below. </p>
    <p>The purpose of the network interface filter is to allow for filtering
      of messages (accept or reject) receive and send. This is done 
      on two levels: </p>
    <list type="bulleted">
      <item>
        <p>The first level is at the UDP entry / exit point, i.e. 
          immediately after the receipt of the message, before any message 
          processing is done (accept_recv) and 
          immediately before sending the message, after all message 
          processing is done (accept_send).</p>
      </item>
      <item>
        <p>The second level is at the MPD entry / exit point, i.e.
          immediately after the basic message processing (accept_recv_pdu) / 
          immediately before the basic message processing (accept_send_pdu).</p>
      </item>
    </list>
    <p>Note that the network interface filter is something which is used 
      by the network interface implementation provided by the application 
      (<c>snmpa_net_if</c>). The default filter accepts all messages.</p>
    <p>A network interface filter can e.g. be used during testing or for load 
      regulation. If the intended use is load regulation, see also 
      <seealso marker="snmp_app#configuration_params">req_limit</seealso> and 
      the function 
      <seealso marker="snmpa#register_notification_filter">register_notification_filter</seealso>. </p>
  </description>

  <section>
    <title>DATA TYPES</title>
    <code type="none">
port() = integer() > 0
pdu_type() = 'get-request' | 'get-next-request' | 'get-response' | 'set-request' | trap | 'get-bulk-request' | 'inform-request' | report
    </code>
    <marker id="accept_recv"></marker>
  </section>
  <funcs>
    <func>
      <name>accept_recv(Ip, Port) -> boolean()</name>
      <fsummary>Shall the received message be accepted</fsummary>
      <type>
        <v>Ip = ip_address()</v>
        <v>Port = port()</v>
      </type>
      <desc>
        <p>Called at the reception of a message (before <em>any</em> processing 
          has been done).</p>
        <p>For the message to be discarded, the function <em>must</em> return
          <em>false</em>. </p>
        <marker id="accept_send"></marker>
      </desc>
    </func>
    <func>
      <name>accept_send(Ip, Port) -> boolean()</name>
      <fsummary>Shall the message be sent</fsummary>
      <type>
        <v>Ip = ip_address()</v>
        <v>Port = port()</v>
      </type>
      <desc>
        <p>Called before the sending of a message (after <em>all</em> processing 
          has been done).</p>
        <p>For the message to be discarded, the function <em>must</em> return
          <em>false</em>. </p>
        <marker id="accept_recv_pdu"></marker>
      </desc>
    </func>
    <func>
      <name>accept_recv_pdu(Ip, Port, PduType) -> boolean()</name>
      <fsummary>Shall the received pdu be accepted</fsummary>
      <type>
        <v>Ip = ip_address()</v>
        <v>Port = port()</v>
        <v>PduType = pdu_type()</v>
      </type>
      <desc>
        <p>Called after the basic message processing (MPD) has been done, 
          but before the pdu is handed over to the master-agent for 
          primary processing.</p>
        <p>For the pdu to be discarded, the function <em>must</em> return
          <em>false</em>. </p>
        <marker id="accept_send_pdu"></marker>
      </desc>
    </func>
    <func>
      <name>accept_send_pdu(Targets, PduType) -> Reply</name>
      <fsummary>Shall the pdu be sent</fsummary>
      <type>
        <v>Targets = targets()</v>
        <v>targets() = [target()]</v>
        <v>target() = {ip_address(), port()}</v>
        <v>PduType = pdu_type() > 0</v>
        <v>Reply = boolean() | NewTargets</v>
        <v>NewTargets = targets()</v>
      </type>
      <desc>
        <p>Called before the basic message processing (MPD) is done, 
          when a pdu has been received from the master-agent.</p>
        <p>For the message to be discarded all together, the function 
          <em>must</em> return <em>false</em>. </p>
        <p>Note that it is possible for this function to filter out targets
          (but <em>not</em> add its own) by returning an updated
          <c>Targets</c> list (<c>NewTargets</c>). </p>
      </desc>
    </func>
  </funcs>
  
</erlref>

