aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/snmp')
-rw-r--r--lib/snmp/doc/src/notes.xml91
-rw-r--r--lib/snmp/doc/src/snmp.xml28
-rw-r--r--lib/snmp/doc/src/snmp_app.xml12
-rw-r--r--lib/snmp/doc/src/snmp_config.xml12
-rw-r--r--lib/snmp/doc/src/snmp_manager_netif.xml43
-rw-r--r--lib/snmp/doc/src/snmpa.xml32
-rw-r--r--lib/snmp/doc/src/snmpm.xml34
-rw-r--r--lib/snmp/doc/src/snmpm_network_interface_filter.xml9
-rw-r--r--lib/snmp/examples/ex2/snmp_ex2_manager.erl13
-rw-r--r--lib/snmp/src/agent/snmpa.erl24
-rw-r--r--lib/snmp/src/agent/snmpa_agent.erl2
-rw-r--r--lib/snmp/src/agent/snmpa_local_db.erl4
-rw-r--r--lib/snmp/src/agent/snmpa_mib.erl2
-rw-r--r--lib/snmp/src/app/snmp.app.src3
-rw-r--r--lib/snmp/src/app/snmp.appup.src321
-rw-r--r--lib/snmp/src/app/snmp.erl7
-rw-r--r--lib/snmp/src/manager/depend.mk9
-rw-r--r--lib/snmp/src/manager/modules.mk3
-rw-r--r--lib/snmp/src/manager/snmpm.erl25
-rw-r--r--lib/snmp/src/manager/snmpm_config.erl2
-rw-r--r--lib/snmp/src/manager/snmpm_mpd.erl6
-rw-r--r--lib/snmp/src/manager/snmpm_net_if_mt.erl1259
-rw-r--r--lib/snmp/src/misc/snmp_log.erl110
-rw-r--r--lib/snmp/src/misc/snmp_verbosity.erl4
-rw-r--r--lib/snmp/test/exp/.gitignore0
-rw-r--r--lib/snmp/test/exp/snmp_agent_bl_test.erl (renamed from lib/snmp/test/snmp_agent_bl_test.erl)0
-rw-r--r--lib/snmp/test/exp/snmp_agent_ms_test.erl (renamed from lib/snmp/test/snmp_agent_ms_test.erl)0
-rw-r--r--lib/snmp/test/exp/snmp_agent_mt_test.erl (renamed from lib/snmp/test/snmp_agent_mt_test.erl)0
-rw-r--r--lib/snmp/test/exp/snmp_agent_v1_test.erl (renamed from lib/snmp/test/snmp_agent_v1_test.erl)0
-rw-r--r--lib/snmp/test/exp/snmp_agent_v2_test.erl (renamed from lib/snmp/test/snmp_agent_v2_test.erl)0
-rw-r--r--lib/snmp/test/exp/snmp_agent_v3_test.erl (renamed from lib/snmp/test/snmp_agent_v3_test.erl)0
-rw-r--r--lib/snmp/test/snmp_SUITE.erl47
-rw-r--r--lib/snmp/test/snmp_agent_test.erl413
-rw-r--r--lib/snmp/test/snmp_agent_test_lib.erl211
-rw-r--r--lib/snmp/test/snmp_app_test.erl40
-rw-r--r--lib/snmp/test/snmp_compiler_test.erl61
-rw-r--r--lib/snmp/test/snmp_log_test.erl27
-rw-r--r--lib/snmp/test/snmp_manager_test.erl294
-rw-r--r--lib/snmp/test/snmp_test_lib.erl87
39 files changed, 2522 insertions, 713 deletions
diff --git a/lib/snmp/doc/src/notes.xml b/lib/snmp/doc/src/notes.xml
index a40e325ea2..9cc6ae0b16 100644
--- a/lib/snmp/doc/src/notes.xml
+++ b/lib/snmp/doc/src/notes.xml
@@ -36,17 +36,34 @@
<section>
<title>SNMP Development Toolkit 4.22</title>
<p>Version 4.22 supports code replacement in runtime from/to
- version 4.21.7, 4.21.6, 4.21.5, 4.21.4, 4.21.3, 4.21.2, 4.21.1 and
- 4.21. </p>
+ version 4.21.7 4.21.6 4.21.5, 4.21.4, 4.21.3, 4.21.2, 4.21.1 and 4.21. </p>
<section>
<title>Improvements and new features</title>
- <!--
+<!--
<p>-</p>
- -->
+-->
<list type="bulleted">
<item>
+ <p>Added the <c>log_to_io</c> audit-trail-log converter function
+ to the api modules of both the
+ <seealso marker="snmpm#log_to_io">manager</seealso>
+ and
+ <seealso marker="snmpa#log_to_io">agent</seealso>. </p>
+ <p>Own Id: OTP-9940</p>
+ </item>
+
+ <item>
+ <p>[manager] Introduced a new transport module,
+ <c>snmpm_net_if_mt</c>,
+ which handles all incomming and outgoing
+ traffic in newly created processes. The message/request is
+ processed and then the process exits. </p>
+ <p>Own Id: OTP-9876</p>
+ </item>
+
+ <item>
<p>[agent] Documenting previously existing but undocumented function,
<seealso marker="snmp_generic#get_table_info">snmp_generic:get_table_info/2</seealso>. </p>
<p>Own Id: OTP-9942</p>
@@ -57,17 +74,17 @@
</section>
<section>
- <title>Reported Fixed Bugs and Malfunctions</title>
+ <title>Fixed Bugs and Malfunctions</title>
<p>-</p>
<!--
<list type="bulleted">
<item>
<p>[agent] Simultaneous
- <seealso marker="snmpa#backup">snmpa:backup/1,2</seealso>
- calls can interfere.
- The master agent did not check if a backup was already in
- progress when a backup request was accepted. </p>
+ <seealso marker="snmpa#backup">snmpa:backup/1,2</seealso>
+ calls can interfere.
+ The master agent did not check if a backup was already in
+ progress when a backup request was accepted. </p>
<p>Own Id: OTP-9884</p>
<p>Aux Id: Seq 11995</p>
</item>
@@ -99,14 +116,14 @@
<list type="bulleted">
<item>
<p>[agent] DoS attack using GET-BULK with large value of
- MaxRepetitions.
- A preventive method has been implementing by simply
- limit the number of varbinds that can be included in
- a Get-BULK response message. This is specified by the
- new config option,
- <seealso marker="snmp_app#agent_gb_max_vbs">gb_max_vbs</seealso>.
- </p>
- <p>Own Id: OTP-9700</p>
+ MaxRepetitions.
+ A preventive method has been implementing by simply
+ limit the number of varbinds that can be included in
+ a Get-BULK response message. This is specified by the
+ new config option,
+ <seealso marker="snmp_app#agent_gb_max_vbs">gb_max_vbs</seealso>.
+ </p>
+ <p>Own Id: OTP-9700</p>
</item>
</list>
@@ -115,7 +132,7 @@
</section>
<section>
- <title>Reported Fixed Bugs and Malfunctions</title>
+ <title>Fixed Bugs and Malfunctions</title>
<!--
<p>-</p>
-->
@@ -123,10 +140,10 @@
<list type="bulleted">
<item>
<p>[agent] Simultaneous
- <seealso marker="snmpa#backup">snmpa:backup/1,2</seealso>
- calls can interfere.
- The master agent did not check if a backup was already in
- progress when a backup request was accepted. </p>
+ <seealso marker="snmpa#backup">snmpa:backup/1,2</seealso>
+ calls can interfere.
+ The master agent did not check if a backup was already in
+ progress when a backup request was accepted. </p>
<p>Own Id: OTP-9884</p>
<p>Aux Id: Seq 11995</p>
</item>
@@ -158,14 +175,14 @@
<list type="bulleted">
<item>
<p>[agent] DoS attack using GET-BULK with large value of
- MaxRepetitions.
- A preventive method has been implementing by simply
- limit the number of varbinds that can be included in
- a Get-BULK response message. This is specified by the
- new config option,
- <seealso marker="snmp_app#agent_gb_max_vbs">gb_max_vbs</seealso>.
- </p>
- <p>Own Id: OTP-9700</p>
+ MaxRepetitions.
+ A preventive method has been implementing by simply
+ limit the number of varbinds that can be included in
+ a Get-BULK response message. This is specified by the
+ new config option,
+ <seealso marker="snmp_app#agent_gb_max_vbs">gb_max_vbs</seealso>.
+ </p>
+ <p>Own Id: OTP-9700</p>
</item>
</list>
@@ -173,7 +190,7 @@
</section>
<section>
- <title>Reported Fixed Bugs and Malfunctions</title>
+ <title>Fixed Bugs and Malfunctions</title>
<!--
<p>-</p>
-->
@@ -181,12 +198,12 @@
<list type="bulleted">
<item>
<p>[agent] Mib server cache gclimit update function incorrectly calls
- age update function.
- The gclimit update function,
- <seealso marker="snmpa#update_mibs_cache_gclimit">update_mibs_cache_gclimit/1</seealso>,
- <em>incorrectly</em> called the age update function,
- <seealso marker="snmpa#update_mibs_cache_age">update_mibs_cache_age/2</seealso>. </p>
- <p>Johan Claesson</p>
+ age update function.
+ The gclimit update function,
+ <seealso marker="snmpa#update_mibs_cache_gclimit">update_mibs_cache_gclimit/1</seealso>,
+ <em>incorrectly</em> called the age update function,
+ <seealso marker="snmpa#update_mibs_cache_age">update_mibs_cache_age/2</seealso>. </p>
+ <p>Johan Claesson</p>
<p>Own Id: OTP-9868</p>
</item>
diff --git a/lib/snmp/doc/src/snmp.xml b/lib/snmp/doc/src/snmp.xml
index af0833f005..3e6610891f 100644
--- a/lib/snmp/doc/src/snmp.xml
+++ b/lib/snmp/doc/src/snmp.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1996</year><year>2009</year>
+ <year>1996</year><year>2012</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -391,6 +391,30 @@
version of the protocol data unit. There is a new line
between <c>Vsn</c> and <c>PDU</c>.</p>
+ <marker id="log_to_io"></marker>
+ </desc>
+ </func>
+
+ <func>
+ <name>log_to_io(LogDir, Mibs, LogName, LogFile) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs, LogName, LogFile, Start) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs, LogName, LogFile, Start, Stop) -> ok | {error, Reason}</name>
+ <fsummary>Convert an Audit Trail Log to text format</fsummary>
+ <type>
+ <v>LogDir = string()</v>
+ <v>Mibs = [MibName]</v>
+ <v>MibName = string()</v>
+ <v>LogName = string()</v>
+ <v>LogFile = string()</v>
+ <v>Start = Stop = null | datetime() | {local_time,datetime()} | {universal_time,datetime()} </v>
+ <v>Reason = term()</v>
+ </type>
+ <desc>
+ <p>Converts an Audit Trail Log to a readable format and
+ prints it on stdio. See
+ <seealso marker="snmp#log_to_txt">log_to_txt</seealso>
+ above for more info.</p>
+
<marker id="change_log_size"></marker>
</desc>
</func>
diff --git a/lib/snmp/doc/src/snmp_app.xml b/lib/snmp/doc/src/snmp_app.xml
index f6abe783b3..d11eaa2771 100644
--- a/lib/snmp/doc/src/snmp_app.xml
+++ b/lib/snmp/doc/src/snmp_app.xml
@@ -35,8 +35,8 @@
<appsummary>The SNMP Application</appsummary>
<description>
<p>This chapter describes the <c>snmp</c>
- application in OTP. The SNMP application provides the following
- services:</p>
+ application in OTP. The SNMP application provides the following
+ services:</p>
<list type="bulleted">
<item>
<p>a multilingual extensible SNMP agent</p>
@@ -589,16 +589,16 @@
{no_reuse, no_reuse()} |
{filter, manager_net_if_filter_options()} </c></p>
<p>These options are actually specific to the used module.
- The ones shown here are applicable to the default
- <c>manager_net_if_module()</c>.</p>
+ The ones shown here are applicable to the default
+ <c>manager_net_if_module()</c>.</p>
<p>For defaults see the options in <c>manager_net_if_option()</c>.</p>
</item>
<marker id="manager_ni_module"></marker>
<tag><c><![CDATA[manager_net_if_module() = atom() <optional>]]></c></tag>
<item>
- <p>Module which handles the network interface part for the
- SNMP manager. Must implement the
+ <p>The module which handles the network interface part for the
+ SNMP manager. It must implement the
<seealso marker="snmpm_network_interface">snmpm_network_interface</seealso> behaviour.</p>
<p>Default is <c>snmpm_net_if</c>.</p>
</item>
diff --git a/lib/snmp/doc/src/snmp_config.xml b/lib/snmp/doc/src/snmp_config.xml
index 0a49b7a62e..b756f3da7d 100644
--- a/lib/snmp/doc/src/snmp_config.xml
+++ b/lib/snmp/doc/src/snmp_config.xml
@@ -586,18 +586,18 @@
{no_reuse, no_reuse()} |
{filter, manager_net_if_filter_options()}</c></p>
<p>These options are actually specific to the used module.
- The ones shown here are applicable to the default
- <c>manager_net_if_module()</c>.</p>
+ The ones shown here are applicable to the default
+ <c>manager_net_if_module()</c>. </p>
<p>For defaults see the options in <c>manager_net_if_option()</c>.</p>
</item>
<marker id="manager_ni_module"></marker>
<tag><c><![CDATA[manager_net_if_module() = atom() <optional>]]></c></tag>
<item>
- <p>Module which handles the network interface part for the
- SNMP manager. Must implement the
- <seealso marker="snmpm_network_interface">snmpm_network_interface</seealso> behaviour.</p>
- <p>Default is <c>snmpm_net_if</c>.</p>
+ <p>The module which handles the network interface part for the
+ SNMP manager. It must implement the
+ <seealso marker="snmpm_network_interface">snmpm_network_interface</seealso> behaviour. </p>
+ <p>Default is <c>snmpm_net_if</c>. </p>
</item>
<marker id="manager_ni_filter_opts"></marker>
diff --git a/lib/snmp/doc/src/snmp_manager_netif.xml b/lib/snmp/doc/src/snmp_manager_netif.xml
index 2738ca76c1..169e20d10b 100644
--- a/lib/snmp/doc/src/snmp_manager_netif.xml
+++ b/lib/snmp/doc/src/snmp_manager_netif.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE chapter SYSTEM "chapter.dtd">
<chapter>
<header>
<copyright>
- <year>2004</year><year>2009</year>
+ <year>2004</year><year>2012</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -35,31 +35,34 @@
<image file="snmp_manager_netif_1.gif">
<icaption>The Purpose of Manager Net if</icaption>
</image>
+
<p>The Network Interface (Net if) process delivers SNMP PDUs to the
- manager server, and receives SNMP PDUs from the manager server.
- The most common behaviour of a Net if process is that is receives
- request PDU from the manager server, encodes the PDU into bytes
- and transmits the bytes onto the network to an agent. When the
- reply from the agent is received by the Net if process, which it
- decodes into an SNMP PDU, which it sends to the manager server.
- </p>
+ manager server, and receives SNMP PDUs from the manager server.
+ The most common behaviour of a Net if process is that is receives
+ request PDU from the manager server, encodes the PDU into bytes
+ and transmits the bytes onto the network to an agent. When the
+ reply from the agent is received by the Net if process, which it
+ decodes into an SNMP PDU, which it sends to the manager server. </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.
- </p>
- <p>It is also possible to write your own Net if process. The default
- Net if process is implemented in the module <c>snmpm_net_if</c> and
- it uses UDP as the transport protocol.
- </p>
- <p>This section describes how to write a Net if process.
- </p>
+ ways. For example, the Net if process can apply some kind of
+ encrypting/decrypting scheme on the bytes. </p>
+
+ <p>The snmp application provides two different modules,
+ <c>snmpm_net_if</c> (the default) and <c>snmpm_net_if_mt</c>,
+ both uses the UDP as the transport protocol. The difference
+ between the two modules is that the latter is "multi-threaded",
+ i.e. for each message/request a new process is created that
+ process the message/request and then exits. </p>
+
+ <p>It is also possible to write your own Net if process,
+ this section describes how to write a Net if processdo that.</p>
<section>
<marker id="mandatory_functions"></marker>
<title>Mandatory Functions</title>
<p>A Net if process must implement the SNMP manager
- <seealso marker="snmpm_network_interface">network interface behaviour</seealso>.
- </p>
+ <seealso marker="snmpm_network_interface">network interface behaviour</seealso>. </p>
</section>
<section>
diff --git a/lib/snmp/doc/src/snmpa.xml b/lib/snmp/doc/src/snmpa.xml
index 2322af28cc..86fde03205 100644
--- a/lib/snmp/doc/src/snmpa.xml
+++ b/lib/snmp/doc/src/snmpa.xml
@@ -501,6 +501,7 @@ notification_delivery_info() = #snmpa_notification_delivery_info{}
</func>
<func>
+ <name>log_to_txt(LogDir)</name>
<name>log_to_txt(LogDir, Mibs)</name>
<name>log_to_txt(LogDir, Mibs, OutFile) -> ok | {error, Reason}</name>
<name>log_to_txt(LogDir, Mibs, OutFile, LogName) -> ok | {error, Reason}</name>
@@ -528,6 +529,37 @@ notification_delivery_info() = #snmpa_notification_delivery_info{}
See <seealso marker="snmp#log_to_txt">snmp:log_to_txt</seealso>
for more info.</p>
+ <marker id="log_to_io"></marker>
+ </desc>
+ </func>
+
+ <func>
+ <name>log_to_io(LogDir) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs, LogName) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs, LogName, LogFile) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs, LogName, LogFile, Start) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs, LogName, LogFile, Start, Stop) -> ok | {error, Reason}</name>
+ <fsummary>Convert an Audit Trail Log to text format</fsummary>
+ <type>
+ <v>LogDir = string()</v>
+ <v>Mibs = [MibName]</v>
+ <v>MibName = string()</v>
+ <v>LogName = string()</v>
+ <v>LogFile = string()</v>
+ <v>Start = Stop = null | datetime() | {local_time,datetime()} | {universal_time,datetime()} </v>
+ <v>Reason = disk_log_open_error() | file_open_error() | term()</v>
+ <v>disk_log_open_error() = {LogName, term()}</v>
+ <v>file_open_error() = {OutFile, term()}</v>
+ </type>
+ <desc>
+ <p>Converts an Audit Trail Log to a readable format and
+ prints it on stdio.
+ <c>LogName</c> defaults to "snmpa_log".
+ <c>LogFile</c> defaults to "snmpa.log".
+ See <seealso marker="snmp#log_to_io">snmp:log_to_io</seealso>
+ for more info.</p>
+
<marker id="change_log_size"></marker>
</desc>
</func>
diff --git a/lib/snmp/doc/src/snmpm.xml b/lib/snmp/doc/src/snmpm.xml
index c36a1b2a24..9bbb6cdbdb 100644
--- a/lib/snmp/doc/src/snmpm.xml
+++ b/lib/snmp/doc/src/snmpm.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>2004</year><year>2011</year>
+ <year>2004</year><year>2012</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -1237,6 +1237,38 @@ priv_key = [integer()] (length is 16 if priv = usmDESPrivProtocol | usmAesCfb1
See <seealso marker="snmp#log_to_txt">snmp:log_to_txt</seealso>
for more info.</p>
+ <marker id="log_to_io"></marker>
+ </desc>
+ </func>
+
+ <func>
+ <name>log_to_io(LogDir) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs, LogName) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs, LogName, LogFile) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs, LogName, LogFile, Start) -> ok | {error, Reason}</name>
+ <name>log_to_io(LogDir, Mibs, LogName, LogFile, Start, Stop) -> ok | {error, Reason}</name>
+ <fsummary>Convert an Audit Trail Log to text format</fsummary>
+ <type>
+ <v>LogDir = string()</v>
+ <v>Mibs = [MibName]</v>
+ <v>MibName = string()</v>
+ <v>LogName = string()</v>
+ <v>LogFile = string()</v>
+ <v>Start = Stop = null | datetime() | {local_time,datetime()} | {universal_time,datetime()} </v>
+ <v>Reason = disk_log_open_error() | file_open_error() | term()</v>
+ <v>disk_log_open_error() = {LogName, term()}</v>
+ <v>file_open_error() = {OutFile, term()}</v>
+ </type>
+ <desc>
+ <p>Converts an Audit Trail Log to a readable format and
+ prints it on stdio.
+ <c>LogName</c> defaults to "snmpm_log".
+ <c>LogFile</c> defaults to "snmpm.log".
+ See <seealso marker="snmp#log_to_io">snmp:log_to_io</seealso>
+ for more info.</p>
+
<marker id="change_log_size"></marker>
</desc>
</func>
diff --git a/lib/snmp/doc/src/snmpm_network_interface_filter.xml b/lib/snmp/doc/src/snmpm_network_interface_filter.xml
index ea1e183848..5f80cec94e 100644
--- a/lib/snmp/doc/src/snmpm_network_interface_filter.xml
+++ b/lib/snmp/doc/src/snmpm_network_interface_filter.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>2007</year><year>2009</year>
+ <year>2007</year><year>2012</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -72,9 +72,10 @@
</list>
<p>Note that the network interface filter is something which is used
by the network interface implementation provided by the application
- (<c>snmpm_net_if</c>). The default filter accepts all messages.</p>
+ (<c>snmpm_net_if</c> and <c>snmpm_net_if_mt</c>).
+ The default filter accepts all messages.</p>
<p>A network interface filter can e.g. be used during testing or for load
- regulation. </p>
+ regulation. </p>
</description>
<section>
diff --git a/lib/snmp/examples/ex2/snmp_ex2_manager.erl b/lib/snmp/examples/ex2/snmp_ex2_manager.erl
index ff873327bc..1b247d713d 100644
--- a/lib/snmp/examples/ex2/snmp_ex2_manager.erl
+++ b/lib/snmp/examples/ex2/snmp_ex2_manager.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2006-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2006-2012. All Rights Reserved.
%%
%% 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
@@ -39,7 +39,7 @@
%% Manager callback API:
-export([handle_error/3,
- handle_agent/4,
+ handle_agent/5,
handle_pdu/4,
handle_trap/3,
handle_inform/3,
@@ -265,16 +265,17 @@ handle_snmp_callback(handle_error, {ReqId, Reason}) ->
"~n Reason: ~p"
"~n", [ReqId, Reason]),
ok;
-handle_snmp_callback(handle_agent, {Addr, Port, SnmpInfo}) ->
+handle_snmp_callback(handle_agent, {Addr, Port, Type, SnmpInfo}) ->
{ES, EI, VBs} = SnmpInfo,
io:format("*** UNKNOWN AGENT ***"
"~n Address: ~p"
"~n Port: ~p"
+ "~n Type: ~p"
"~n SNMP Info: "
"~n Error Status: ~w"
"~n Error Index: ~w"
"~n Varbinds: ~p"
- "~n", [Addr, Port, ES, EI, VBs]),
+ "~n", [Addr, Port, Type, ES, EI, VBs]),
ok;
handle_snmp_callback(handle_pdu, {TargetName, ReqId, SnmpResponse}) ->
{ES, EI, VBs} = SnmpResponse,
@@ -382,8 +383,8 @@ handle_error(ReqId, Reason, Server) when is_pid(Server) ->
ignore.
-handle_agent(Addr, Port, SnmpInfo, Server) when is_pid(Server) ->
- report_callback(Server, handle_agent, {Addr, Port, SnmpInfo}),
+handle_agent(Addr, Port, Type, SnmpInfo, Server) when is_pid(Server) ->
+ report_callback(Server, handle_agent, {Addr, Port, Type, SnmpInfo}),
ignore.
diff --git a/lib/snmp/src/agent/snmpa.erl b/lib/snmp/src/agent/snmpa.erl
index c400aaddf7..b45a47ec6b 100644
--- a/lib/snmp/src/agent/snmpa.erl
+++ b/lib/snmp/src/agent/snmpa.erl
@@ -83,8 +83,11 @@
-export([add_agent_caps/2, del_agent_caps/1, get_agent_caps/0]).
%% Audit Trail Log functions
--export([log_to_txt/2, log_to_txt/3, log_to_txt/4,
+-export([log_to_txt/1,
+ log_to_txt/2, log_to_txt/3, log_to_txt/4,
log_to_txt/5, log_to_txt/6, log_to_txt/7,
+ log_to_io/1, log_to_io/2, log_to_io/3,
+ log_to_io/4, log_to_io/5, log_to_io/6,
log_info/0,
change_log_size/1,
get_log_type/0, get_log_type/1,
@@ -780,6 +783,8 @@ get_agent_caps() ->
%%% Audit Trail Log functions
%%%-----------------------------------------------------------------
+log_to_txt(LogDir) ->
+ log_to_txt(LogDir, []).
log_to_txt(LogDir, Mibs) ->
OutFile = "snmpa_log.txt",
LogName = ?audit_trail_log_name,
@@ -800,6 +805,23 @@ log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start, Stop) ->
snmp:log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start, Stop).
+log_to_io(LogDir) ->
+ log_to_io(LogDir, []).
+log_to_io(LogDir, Mibs) ->
+ LogName = ?audit_trail_log_name,
+ LogFile = ?audit_trail_log_file,
+ snmp:log_to_io(LogDir, Mibs, LogName, LogFile).
+log_to_io(LogDir, Mibs, LogName) ->
+ LogFile = ?audit_trail_log_file,
+ snmp:log_to_io(LogDir, Mibs, LogName, LogFile).
+log_to_io(LogDir, Mibs, LogName, LogFile) ->
+ snmp:log_to_io(LogDir, Mibs, LogName, LogFile).
+log_to_io(LogDir, Mibs, LogName, LogFile, Start) ->
+ snmp:log_to_io(LogDir, Mibs, LogName, LogFile, Start).
+log_to_io(LogDir, Mibs, LogName, LogFile, Start, Stop) ->
+ snmp:log_to_io(LogDir, Mibs, LogName, LogFile, Start, Stop).
+
+
log_info() ->
LogName = ?audit_trail_log_name,
snmp_log:info(LogName).
diff --git a/lib/snmp/src/agent/snmpa_agent.erl b/lib/snmp/src/agent/snmpa_agent.erl
index 9cc986cf47..9d30e332f1 100644
--- a/lib/snmp/src/agent/snmpa_agent.erl
+++ b/lib/snmp/src/agent/snmpa_agent.erl
@@ -1281,7 +1281,7 @@ handle_call({backup, BackupDir}, From, #state{backup = undefined} = S) ->
?vtrace("backup server: ~p", [BackupServer]),
{noreply, S#state{backup = {BackupServer, From}}};
-handle_call({backup, _BackupDir}, From, #state{backup = Backup} = S) ->
+handle_call({backup, _BackupDir}, _From, #state{backup = Backup} = S) ->
?vinfo("backup already in progress: ~p", [Backup]),
{reply, {error, backup_in_progress}, S};
diff --git a/lib/snmp/src/agent/snmpa_local_db.erl b/lib/snmp/src/agent/snmpa_local_db.erl
index 1ec8dd3874..2c0cad807a 100644
--- a/lib/snmp/src/agent/snmpa_local_db.erl
+++ b/lib/snmp/src/agent/snmpa_local_db.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% 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
@@ -515,7 +515,7 @@ handle_call({backup, BackupDir}, From,
{reply, Error, State}
end;
-handle_call({backup, _BackupDir}, From, #state{backup = Backup} = S) ->
+handle_call({backup, _BackupDir}, _From, #state{backup = Backup} = S) ->
?vinfo("backup already in progress: ~p", [Backup]),
{reply, {error, backup_in_progress}, S};
diff --git a/lib/snmp/src/agent/snmpa_mib.erl b/lib/snmp/src/agent/snmpa_mib.erl
index 574467d38f..575a018c0c 100644
--- a/lib/snmp/src/agent/snmpa_mib.erl
+++ b/lib/snmp/src/agent/snmpa_mib.erl
@@ -580,7 +580,7 @@ handle_call({backup, BackupDir}, From,
{reply, Error, State}
end;
-handle_call({backup, _BackupDir}, From, #state{backup = Backup} = S) ->
+handle_call({backup, _BackupDir}, _From, #state{backup = Backup} = S) ->
?vinfo("backup already in progress: ~p", [Backup]),
{reply, {error, backup_in_progress}, S};
diff --git a/lib/snmp/src/app/snmp.app.src b/lib/snmp/src/app/snmp.app.src
index a880a14696..b11c1ef934 100644
--- a/lib/snmp/src/app/snmp.app.src
+++ b/lib/snmp/src/app/snmp.app.src
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% 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
@@ -91,6 +91,7 @@
snmpm_mpd,
snmpm_net_if,
snmpm_net_if_filter,
+ snmpm_net_if_mt,
snmpm_network_interface,
snmpm_network_interface_filter,
snmpm_server,
diff --git a/lib/snmp/src/app/snmp.appup.src b/lib/snmp/src/app/snmp.appup.src
index c8e5eec6db..14b87390c9 100644
--- a/lib/snmp/src/app/snmp.appup.src
+++ b/lib/snmp/src/app/snmp.appup.src
@@ -22,16 +22,47 @@
%% ----- U p g r a d e -------------------------------------------------------
[
+ {"4.21.7",
+ [
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {update, snmpa_local_db, soft, soft_purge, soft_purge, []},
+ {update, snmpa_mib, soft, soft_purge, soft_purge, []},
+ {update, snmpa_agent, soft, soft_purge, soft_purge, []},
+
+ {add_module, snmpm_net_if_mt}
+ ]
+ },
{"4.21.6",
[
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, []}
+ {update, snmpa_agent, soft, soft_purge, soft_purge, []},
+
+ {add_module, snmpm_net_if_mt}
]
},
{"4.21.5",
[
- {load_module, snmpa, soft_purge, soft_purge, []},
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
@@ -39,12 +70,20 @@
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, []}
+ {update, snmpa_agent, soft, soft_purge, soft_purge, []},
+
+ {add_module, snmpm_net_if_mt}
]
},
{"4.21.4",
[
- {load_module, snmpa, soft_purge, soft_purge, []},
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
@@ -55,12 +94,20 @@
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, []}
+ {update, snmpa_agent, soft, soft_purge, soft_purge, []},
+
+ {add_module, snmpm_net_if_mt}
]
},
{"4.21.3",
[
- {load_module, snmpa, soft_purge, soft_purge, []},
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
@@ -71,12 +118,20 @@
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, []}
+ {update, snmpa_agent, soft, soft_purge, soft_purge, []},
+
+ {add_module, snmpm_net_if_mt}
]
},
{"4.21.2",
[
- {load_module, snmpa, soft_purge, soft_purge, []},
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
@@ -89,12 +144,20 @@
{load_module, snmp_generic_mnesia, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, []}
+ {update, snmpa_agent, soft, soft_purge, soft_purge, []},
+
+ {add_module, snmpm_net_if_mt}
]
},
{"4.21.1",
[
- {load_module, snmpa, soft_purge, soft_purge, []},
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
@@ -108,12 +171,20 @@
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
{update, snmpa_agent, soft, soft_purge, soft_purge, []},
- {update, snmp_note_store, soft, soft_purge, soft_purge, []}
+ {update, snmp_note_store, soft, soft_purge, soft_purge, []},
+
+ {add_module, snmpm_net_if_mt}
]
},
{"4.21",
[
- {load_module, snmpa, soft_purge, soft_purge, []},
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
@@ -127,72 +198,9 @@
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
{update, snmpa_agent, soft, soft_purge, soft_purge, []},
- {update, snmp_note_store, soft, soft_purge, soft_purge, []}
- ]
- },
- {"4.20.1",
- [
- {load_module, snmpa, soft_purge, soft_purge, []},
- {load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
- {update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
+ {update, snmp_note_store, soft, soft_purge, soft_purge, []},
- {load_module, snmpa_vacm, soft_purge, soft_purge, []},
- {load_module, snmpa_set_lib, soft_purge, soft_purge, []},
- {load_module, snmpa_trap, soft_purge, soft_purge, []},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
- {load_module, snmpm, soft_purge, soft_purge,
- [snmpm_server, snmpm_config, snmp_config]},
- {load_module, snmp_conf, soft_purge, soft_purge, []},
- {load_module, snmp_config, soft_purge, soft_purge, []},
- {load_module, snmpm_mpd, soft_purge, soft_purge,
- [snmp_conf, snmp_config, snmpm_config]},
- {load_module, snmpa_mpd, soft_purge, soft_purge,
- [snmp_conf, snmp_config]},
- {load_module, snmpa_conf, soft_purge, soft_purge, [snmp_config]},
- {update, snmp_note_store, soft, soft_purge, soft_purge, []},
- {load_module, snmp_generic_mnesia, soft_purge, soft_purge, []},
- {update, snmpa_local_db, soft, soft_purge, soft_purge, []},
- {update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, [snmpa_mpd]},
- {update, snmpm_config, soft, soft_purge, soft_purge, [snmp_conf]},
- {update, snmpm_server, soft, soft_purge, soft_purge,
- [snmpm_net_if, snmpm_mpd, snmpm_config]},
- {update, snmpm_net_if, soft, soft_purge, soft_purge,
- [snmp_conf, snmpm_mpd, snmpm_config]}
- ]
- },
- {"4.20",
- [
- {load_module, snmpa, soft_purge, soft_purge, []},
- {load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
- {update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
-
- {load_module, snmpa_vacm, soft_purge, soft_purge, []},
- {load_module, snmpa_set_lib, soft_purge, soft_purge, []},
- {load_module, snmpa_trap, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
- {load_module, snmp_target_mib, soft_purge, soft_purge,
- [snmpa_mib_lib, snmp_conf]},
- {load_module, snmpm, soft_purge, soft_purge,
- [snmpm_server, snmpm_config, snmp_config]},
- {load_module, snmp_conf, soft_purge, soft_purge, []},
- {load_module, snmp_config, soft_purge, soft_purge, []},
- {load_module, snmpm_mpd, soft_purge, soft_purge,
- [snmp_conf, snmp_config, snmpm_config]},
- {load_module, snmpa_mpd, soft_purge, soft_purge,
- [snmp_conf, snmp_config]},
- {load_module, snmpa_conf, soft_purge, soft_purge, [snmp_config]},
- {update, snmp_note_store, soft, soft_purge, soft_purge, []},
- {load_module, snmp_generic_mnesia, soft_purge, soft_purge, []},
- {update, snmpa_local_db, soft, soft_purge, soft_purge, []},
- {update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, [snmpa_mpd]},
- {update, snmpm_config, soft, soft_purge, soft_purge, [snmp_conf]},
- {update, snmpm_server, soft, soft_purge, soft_purge,
- [snmpm_net_if, snmpm_mpd, snmpm_config]},
- {update, snmpm_net_if, soft, soft_purge, soft_purge,
- [snmp_conf, snmpm_mpd, snmpm_config]}
+ {add_module, snmpm_net_if_mt}
]
}
],
@@ -200,16 +208,47 @@
%% ------D o w n g r a d e ---------------------------------------------------
[
+ {"4.21.7",
+ [
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {update, snmpa_local_db, soft, soft_purge, soft_purge, []},
+ {update, snmpa_mib, soft, soft_purge, soft_purge, []},
+ {update, snmpa_agent, soft, soft_purge, soft_purge, []},
+
+ {remove, {snmpm_net_if_mt, soft_purge, soft_purge}}
+ ]
+ },
{"4.21.6",
[
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, []}
+ {update, snmpa_agent, soft, soft_purge, soft_purge, []},
+
+ {remove, {snmpm_net_if_mt, soft_purge, soft_purge}}
]
},
{"4.21.5",
[
- {load_module, snmpa, soft_purge, soft_purge, []},
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
@@ -217,12 +256,20 @@
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, []}
+ {update, snmpa_agent, soft, soft_purge, soft_purge, []},
+
+ {remove, {snmpm_net_if_mt, soft_purge, soft_purge}}
]
},
{"4.21.4",
[
- {load_module, snmpa, soft_purge, soft_purge, []},
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
@@ -233,12 +280,20 @@
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, []}
+ {update, snmpa_agent, soft, soft_purge, soft_purge, []},
+
+ {remove, {snmpm_net_if_mt, soft_purge, soft_purge}}
]
},
{"4.21.3",
[
- {load_module, snmpa, soft_purge, soft_purge, []},
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{load_module, snmpa_trap, soft_purge, soft_purge, []},
@@ -249,12 +304,20 @@
{load_module, snmpa_vacm, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, []}
+ {update, snmpa_agent, soft, soft_purge, soft_purge, []},
+
+ {remove, {snmpm_net_if_mt, soft_purge, soft_purge}}
]
},
{"4.21.2",
[
- {load_module, snmpa, soft_purge, soft_purge, []},
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
@@ -267,12 +330,20 @@
{load_module, snmp_generic_mnesia, soft_purge, soft_purge, []},
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, []}
+ {update, snmpa_agent, soft, soft_purge, soft_purge, []},
+
+ {remove, {snmpm_net_if_mt, soft_purge, soft_purge}}
]
},
{"4.21.1",
[
- {load_module, snmpa, soft_purge, soft_purge, []},
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmp_target_mib, soft_purge, soft_purge, [snmpa_mib_lib]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
@@ -286,12 +357,20 @@
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
{update, snmpa_agent, soft, soft_purge, soft_purge, []},
- {update, snmp_note_store, soft, soft_purge, soft_purge, []}
+ {update, snmp_note_store, soft, soft_purge, soft_purge, []},
+
+ {remove, {snmpm_net_if_mt, soft_purge, soft_purge}}
]
},
{"4.21",
[
- {load_module, snmpa, soft_purge, soft_purge, []},
+ {load_module, snmp, soft_purge, soft_purge, [snmp_log]},
+ {load_module, snmpm, soft_purge, soft_purge, [snmp]},
+ {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
+ {load_module, snmpm_mpd, soft_purge, soft_purge, []},
+
+ {load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
{update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
@@ -305,71 +384,9 @@
{update, snmpa_local_db, soft, soft_purge, soft_purge, []},
{update, snmpa_mib, soft, soft_purge, soft_purge, []},
{update, snmpa_agent, soft, soft_purge, soft_purge, []},
- {update, snmp_note_store, soft, soft_purge, soft_purge, []}
- ]
- },
- {"4.20.1",
- [
- {load_module, snmpa, soft_purge, soft_purge, []},
- {load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
- {update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
-
- {load_module, snmpa_vacm, soft_purge, soft_purge, []},
- {load_module, snmpa_set_lib, soft_purge, soft_purge, []},
- {load_module, snmpa_trap, soft_purge, soft_purge, []},
- {load_module, snmp_target_mib, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
- {load_module, snmpm, soft_purge, soft_purge,
- [snmpm_server, snmpm_config, snmp_config]},
- {load_module, snmp_conf, soft_purge, soft_purge, []},
- {load_module, snmp_config, soft_purge, soft_purge, []},
- {load_module, snmpm_mpd, soft_purge, soft_purge,
- [snmp_conf, snmp_config, snmpm_config]},
- {load_module, snmpa_mpd, soft_purge, soft_purge,
- [snmp_conf, snmp_config]},
- {load_module, snmpa_conf, soft_purge, soft_purge, [snmp_config]},
{update, snmp_note_store, soft, soft_purge, soft_purge, []},
- {load_module, snmp_generic_mnesia, soft_purge, soft_purge, []},
- {update, snmpa_local_db, soft, soft_purge, soft_purge, []},
- {update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, [snmpa_mpd]},
- {update, snmpm_config, soft, soft_purge, soft_purge, [snmp_conf]},
- {update, snmpm_server, soft, soft_purge, soft_purge,
- [snmpm_net_if, snmpm_mpd, snmpm_config]},
- {update, snmpm_net_if, soft, soft_purge, soft_purge,
- [snmp_conf, snmpm_mpd, snmpm_config]}
- ]
- },
- {"4.20",
- [
- {load_module, snmpa, soft_purge, soft_purge, []},
- {load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
- {update, snmpa_supervisor, soft, soft_purge, soft_purge, []},
- {load_module, snmpa_vacm, soft_purge, soft_purge, []},
- {load_module, snmpa_set_lib, soft_purge, soft_purge, []},
- {load_module, snmpa_trap, soft_purge, soft_purge, []},
- {load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
- {load_module, snmp_target_mib, soft_purge, soft_purge, [snmp_conf]},
- {load_module, snmpm, soft_purge, soft_purge,
- [snmpm_server, snmpm_config, snmp_config]},
- {load_module, snmp_conf, soft_purge, soft_purge, []},
- {load_module, snmp_config, soft_purge, soft_purge, []},
- {load_module, snmpm_mpd, soft_purge, soft_purge,
- [snmp_conf, snmp_config, snmpm_config]},
- {load_module, snmpa_mpd, soft_purge, soft_purge,
- [snmp_conf, snmp_config]},
- {load_module, snmpa_conf, soft_purge, soft_purge, [snmp_config]},
- {update, snmp_note_store, soft, soft_purge, soft_purge, []},
- {load_module, snmp_generic_mnesia, soft_purge, soft_purge, []},
- {update, snmpa_local_db, soft, soft_purge, soft_purge, []},
- {update, snmpa_mib, soft, soft_purge, soft_purge, []},
- {update, snmpa_agent, soft, soft_purge, soft_purge, [snmpa_mpd]},
- {update, snmpm_config, soft, soft_purge, soft_purge, [snmp_conf]},
- {update, snmpm_server, soft, soft_purge, soft_purge,
- [snmpm_net_if, snmpm_mpd, snmpm_config]},
- {update, snmpm_net_if, soft, soft_purge, soft_purge,
- [snmp_conf, snmpm_mpd, snmpm_config]}
+ {remove, {snmpm_net_if_mt, soft_purge, soft_purge}}
]
}
]
diff --git a/lib/snmp/src/app/snmp.erl b/lib/snmp/src/app/snmp.erl
index 3e0f05e604..fc03757e3f 100644
--- a/lib/snmp/src/app/snmp.erl
+++ b/lib/snmp/src/app/snmp.erl
@@ -50,6 +50,7 @@
read_mib/1,
log_to_txt/5, log_to_txt/6, log_to_txt/7,
+ log_to_io/4, log_to_io/5, log_to_io/6,
change_log_size/2,
octet_string_to_bits/1, bits_to_octet_string/1,
@@ -843,6 +844,12 @@ log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start) ->
log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start, Stop) ->
snmp_log:log_to_txt(LogName, LogFile, LogDir, Mibs, OutFile, Start, Stop).
+log_to_io(LogDir, Mibs, LogName, LogFile) ->
+ snmp_log:log_to_io(LogName, LogFile, LogDir, Mibs).
+log_to_io(LogDir, Mibs, LogName, LogFile, Start) ->
+ snmp_log:log_to_io(LogName, LogFile, LogDir, Mibs, Start).
+log_to_io(LogDir, Mibs, LogName, LogFile, Start, Stop) ->
+ snmp_log:log_to_io(LogName, LogFile, LogDir, Mibs, Start, Stop).
change_log_size(LogName, NewSize) ->
snmp_log:change_size(LogName, NewSize).
diff --git a/lib/snmp/src/manager/depend.mk b/lib/snmp/src/manager/depend.mk
index 0e7e9e3df7..2e7783c8ed 100644
--- a/lib/snmp/src/manager/depend.mk
+++ b/lib/snmp/src/manager/depend.mk
@@ -2,7 +2,7 @@
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2004-2009. All Rights Reserved.
+# Copyright Ericsson AB 2004-2012. All Rights Reserved.
#
# 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
@@ -49,6 +49,13 @@ $(EBIN)/snmpm_net_if.$(EMULATOR): \
snmpm_net_if.erl \
snmpm_network_interface.erl
+$(EBIN)/snmpm_net_if_mt.$(EMULATOR): \
+ ../../include/snmp_types.hrl \
+ ../misc/snmp_debug.hrl \
+ ../misc/snmp_verbosity.hrl \
+ snmpm_net_if_mt.erl \
+ snmpm_network_interface.erl
+
$(EBIN)/snmpm_server.$(EMULATOR): \
../../include/snmp_types.hrl \
../../include/STANDARD-MIB.hrl \
diff --git a/lib/snmp/src/manager/modules.mk b/lib/snmp/src/manager/modules.mk
index 79f3dd65d9..d46545ea3f 100644
--- a/lib/snmp/src/manager/modules.mk
+++ b/lib/snmp/src/manager/modules.mk
@@ -2,7 +2,7 @@
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2004-2009. All Rights Reserved.
+# Copyright Ericsson AB 2004-2012. All Rights Reserved.
#
# 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
@@ -31,6 +31,7 @@ MODULES = \
snmpm_mpd \
snmpm_misc_sup \
snmpm_net_if \
+ snmpm_net_if_mt \
snmpm_net_if_filter \
snmpm_server \
snmpm_server_sup \
diff --git a/lib/snmp/src/manager/snmpm.erl b/lib/snmp/src/manager/snmpm.erl
index 6d2ac8d747..89eaee9f80 100644
--- a/lib/snmp/src/manager/snmpm.erl
+++ b/lib/snmp/src/manager/snmpm.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2004-2012. All Rights Reserved.
%%
%% 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
@@ -75,8 +75,11 @@
%%
%% Logging
+ log_to_txt/1,
log_to_txt/2, log_to_txt/3, log_to_txt/4,
log_to_txt/5, log_to_txt/6, log_to_txt/7,
+ log_to_io/1, log_to_io/2, log_to_io/3,
+ log_to_io/4, log_to_io/5, log_to_io/6,
change_log_size/1,
get_log_type/0,
set_log_type/1,
@@ -1371,6 +1374,9 @@ cancel_async_request(UserId, ReqId) ->
%%%-----------------------------------------------------------------
%%% Audit Trail Log functions (for backward compatibility)
%%%-----------------------------------------------------------------
+
+log_to_txt(LogDir) ->
+ log_to_txt(LogDir, []).
log_to_txt(LogDir, Mibs) ->
OutFile = "snmpm_log.txt",
LogName = ?audit_trail_log_name,
@@ -1391,6 +1397,23 @@ log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start, Stop) ->
snmp:log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start, Stop).
+log_to_io(LogDir) ->
+ log_to_io(LogDir, []).
+log_to_io(LogDir, Mibs) ->
+ LogName = ?audit_trail_log_name,
+ LogFile = ?audit_trail_log_file,
+ snmp:log_to_io(LogDir, Mibs, LogName, LogFile).
+log_to_io(LogDir, Mibs, LogName) ->
+ LogFile = ?audit_trail_log_file,
+ snmp:log_to_io(LogDir, Mibs, LogName, LogFile).
+log_to_io(LogDir, Mibs, LogName, LogFile) ->
+ snmp:log_to_io(LogDir, Mibs, LogName, LogFile).
+log_to_io(LogDir, Mibs, LogName, LogFile, Start) ->
+ snmp:log_to_io(LogDir, Mibs, LogName, LogFile, Start).
+log_to_io(LogDir, Mibs, LogName, LogFile, Start, Stop) ->
+ snmp:log_to_io(LogDir, Mibs, LogFile, Start, Stop).
+
+
change_log_size(NewSize) ->
LogName = ?audit_trail_log_name,
snmp:change_log_size(LogName, NewSize).
diff --git a/lib/snmp/src/manager/snmpm_config.erl b/lib/snmp/src/manager/snmpm_config.erl
index c2e57abddb..5bbf9e5542 100644
--- a/lib/snmp/src/manager/snmpm_config.erl
+++ b/lib/snmp/src/manager/snmpm_config.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2004-2012. All Rights Reserved.
%%
%% 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
diff --git a/lib/snmp/src/manager/snmpm_mpd.erl b/lib/snmp/src/manager/snmpm_mpd.erl
index 103c87d32b..883224143e 100644
--- a/lib/snmp/src/manager/snmpm_mpd.erl
+++ b/lib/snmp/src/manager/snmpm_mpd.erl
@@ -110,9 +110,9 @@ process_msg(Msg, Domain, Addr, Port, State, NoteStore, Logger) ->
#message{version = 'version-2', vsn_hdr = Community, data = Data}
when State#state.v2c =:= true ->
HS = ?empty_msg_size + length(Community),
- (catch process_v1_v2c_msg('version-2', NoteStore, Msg,
- Domain, Addr, Port,
- Community, Data, HS, Logger));
+ process_v1_v2c_msg('version-2', NoteStore, Msg,
+ Domain, Addr, Port,
+ Community, Data, HS, Logger);
%% Version 3
#message{version = 'version-3', vsn_hdr = H, data = Data}
diff --git a/lib/snmp/src/manager/snmpm_net_if_mt.erl b/lib/snmp/src/manager/snmpm_net_if_mt.erl
new file mode 100644
index 0000000000..3e87f6a7fb
--- /dev/null
+++ b/lib/snmp/src/manager/snmpm_net_if_mt.erl
@@ -0,0 +1,1259 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2004-2012. All Rights Reserved.
+%%
+%% 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.
+%%
+%% %CopyrightEnd%
+%%
+
+-module(snmpm_net_if_mt).
+
+-behaviour(gen_server).
+-behaviour(snmpm_network_interface).
+
+
+%% Network Interface callback functions
+-export([
+ start_link/2,
+ stop/1,
+ send_pdu/6, % Backward compatibillity
+ send_pdu/7, % Backward compatibillity
+ send_pdu/8,
+
+ inform_response/4,
+
+ note_store/2,
+
+ info/1,
+ verbosity/2,
+ %% system_info_updated/2,
+ get_log_type/1, set_log_type/2,
+ filter_reset/1
+ ]).
+
+%% gen_server callbacks
+-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
+ code_change/3, terminate/2]).
+
+-define(SNMP_USE_V3, true).
+-include("snmp_types.hrl").
+-include("snmpm_internal.hrl").
+-include("snmpm_atl.hrl").
+-include("snmp_debug.hrl").
+
+%% -define(VMODULE,"NET_IF").
+-include("snmp_verbosity.hrl").
+
+-record(state,
+ {
+ server,
+ note_store,
+ sock,
+ mpd_state,
+ log,
+ irb = auto, % auto | {user, integer()}
+ irgc,
+ filter
+ }).
+
+
+-define(DEFAULT_FILTER_MODULE, snmpm_net_if_filter).
+-define(DEFAULT_FILTER_OPTS, [{module, ?DEFAULT_FILTER_MODULE}]).
+
+-ifdef(snmp_debug).
+-define(GS_START_LINK(Args),
+ gen_server:start_link(?MODULE, Args, [{debug,[trace]}])).
+-else.
+-define(GS_START_LINK(Args),
+ gen_server:start_link(?MODULE, Args, [])).
+-endif.
+
+
+-define(IRGC_TIMEOUT, timer:minutes(5)).
+
+-define(ATL_SEQNO_INITIAL, 1).
+-define(ATL_SEQNO_MAX, 2147483647).
+
+
+%%%-------------------------------------------------------------------
+%%% API
+%%%-------------------------------------------------------------------
+start_link(Server, NoteStore) ->
+ ?d("start_link -> entry with"
+ "~n Server: ~p"
+ "~n NoteStore: ~p", [Server, NoteStore]),
+ Args = [Server, NoteStore],
+ ?GS_START_LINK(Args).
+
+stop(Pid) ->
+ call(Pid, stop).
+
+send_pdu(Pid, Pdu, Vsn, MsgData, Addr, Port) ->
+ send_pdu(Pid, Pdu, Vsn, MsgData, Addr, Port, ?DEFAULT_EXTRA_INFO).
+
+send_pdu(Pid, Pdu, Vsn, MsgData, Addr, Port, ExtraInfo) ->
+ Domain = snmpm_config:default_transport_domain(),
+ send_pdu(Pid, Pdu, Vsn, MsgData, Domain, Addr, Port, ExtraInfo).
+
+send_pdu(Pid, Pdu, Vsn, MsgData, Domain, Addr, Port, ExtraInfo)
+ when is_record(Pdu, pdu) ->
+ ?d("send_pdu -> entry with"
+ "~n Pid: ~p"
+ "~n Pdu: ~p"
+ "~n Vsn: ~p"
+ "~n MsgData: ~p"
+ "~n Domain: ~p"
+ "~n Addr: ~p"
+ "~n Port: ~p", [Pid, Pdu, Vsn, MsgData, Domain, Addr, Port]),
+ cast(Pid, {send_pdu, Pdu, Vsn, MsgData, Domain, Addr, Port, ExtraInfo}).
+
+note_store(Pid, NoteStore) ->
+ call(Pid, {note_store, NoteStore}).
+
+inform_response(Pid, Ref, Addr, Port) ->
+ cast(Pid, {inform_response, Ref, Addr, Port}).
+
+info(Pid) ->
+ call(Pid, info).
+
+verbosity(Pid, V) ->
+ call(Pid, {verbosity, V}).
+
+%% system_info_updated(Pid, What) ->
+%% call(Pid, {system_info_updated, What}).
+
+get_log_type(Pid) ->
+ call(Pid, get_log_type).
+
+set_log_type(Pid, NewType) ->
+ call(Pid, {set_log_type, NewType}).
+
+filter_reset(Pid) ->
+ cast(Pid, filter_reset).
+
+
+%%%-------------------------------------------------------------------
+%%% Callback functions from gen_server
+%%%-------------------------------------------------------------------
+
+%%--------------------------------------------------------------------
+%% Func: init/1
+%% Returns: {ok, State} |
+%% {ok, State, Timeout} |
+%% ignore |
+%% {stop, Reason}
+%%--------------------------------------------------------------------
+init([Server, NoteStore]) ->
+ ?d("init -> entry with"
+ "~n Server: ~p"
+ "~n NoteStore: ~p", [Server, NoteStore]),
+ case (catch do_init(Server, NoteStore)) of
+ {error, Reason} ->
+ {stop, Reason};
+ {ok, State} ->
+ {ok, State}
+ end.
+
+do_init(Server, NoteStore) ->
+ process_flag(trap_exit, true),
+
+ %% -- Prio --
+ {ok, Prio} = snmpm_config:system_info(prio),
+ process_flag(priority, Prio),
+
+ %% -- Create inform request table --
+ %% This should really be protected, but it also needs to
+ %% be writable for the worker processes, so...
+ ets:new(snmpm_inform_request_table,
+ [set, public, named_table, {keypos, 1}]),
+
+ %% -- Verbosity --
+ {ok, Verbosity} = snmpm_config:system_info(net_if_verbosity),
+ put(sname, mnif),
+ put(verbosity, Verbosity),
+ ?vlog("starting", []),
+
+ %% -- MPD --
+ {ok, Vsns} = snmpm_config:system_info(versions),
+ MpdState = snmpm_mpd:init(Vsns),
+ ?vdebug("MpdState: ~w", [MpdState]),
+
+ %% -- Module dependent options --
+ {ok, Opts} = snmpm_config:system_info(net_if_options),
+
+ %% -- Inform response behaviour --
+ {ok, IRB} = snmpm_config:system_info(net_if_irb),
+ IrGcRef = irgc_start(IRB),
+
+ %% -- Socket --
+ SndBuf = get_opt(Opts, sndbuf, default),
+ RecBuf = get_opt(Opts, recbuf, default),
+ BindTo = get_opt(Opts, bind_to, false),
+ NoReuse = get_opt(Opts, no_reuse, false),
+ {ok, Port} = snmpm_config:system_info(port),
+ {ok, Sock} = do_open_port(Port, SndBuf, RecBuf, BindTo, NoReuse),
+
+ %% Flow control --
+ FilterOpts = get_opt(Opts, filter, []),
+ FilterMod = create_filter(FilterOpts),
+ ?vdebug("FilterMod: ~w", [FilterMod]),
+
+ %% -- Audit trail log ---
+ {ok, ATL} = snmpm_config:system_info(audit_trail_log),
+ Log = do_init_log(ATL),
+ ?vdebug("Log: ~w", [Log]),
+
+ %% -- Initiate counters ---
+ init_counters(),
+
+ %% -- We are done ---
+ State = #state{server = Server,
+ note_store = NoteStore,
+ mpd_state = MpdState,
+ sock = Sock,
+ log = Log,
+ irb = IRB,
+ irgc = IrGcRef,
+ filter = FilterMod},
+ ?vdebug("started", []),
+ {ok, State}.
+
+
+%% Open port
+do_open_port(Port, SendSz, RecvSz, BindTo, NoReuse) ->
+ ?vtrace("do_open_port -> entry with"
+ "~n Port: ~p"
+ "~n SendSz: ~p"
+ "~n RecvSz: ~p"
+ "~n BindTo: ~p"
+ "~n NoReuse: ~p", [Port, SendSz, RecvSz, BindTo, NoReuse]),
+ IpOpts1 = bind_to(BindTo),
+ IpOpts2 = no_reuse(NoReuse),
+ IpOpts3 = recbuf(RecvSz),
+ IpOpts4 = sndbuf(SendSz),
+ IpOpts = [binary | IpOpts1 ++ IpOpts2 ++ IpOpts3 ++ IpOpts4],
+ OpenRes =
+ case init:get_argument(snmpm_fd) of
+ {ok, [[FdStr]]} ->
+ Fd = list_to_integer(FdStr),
+ gen_udp:open(0, [{fd, Fd}|IpOpts]);
+ error ->
+ gen_udp:open(Port, IpOpts)
+ end,
+ case OpenRes of
+ {error, _} = Error ->
+ throw(Error);
+ OK ->
+ OK
+ end.
+
+bind_to(true) ->
+ case snmpm_config:system_info(address) of
+ {ok, Addr} when is_list(Addr) ->
+ [{ip, list_to_tuple(Addr)}];
+ {ok, Addr} ->
+ [{ip, Addr}];
+ _ ->
+ []
+ end;
+bind_to(_) ->
+ [].
+
+no_reuse(false) ->
+ [{reuseaddr, true}];
+no_reuse(_) ->
+ [].
+
+recbuf(default) ->
+ [];
+recbuf(Sz) ->
+ [{recbuf, Sz}].
+
+sndbuf(default) ->
+ [];
+sndbuf(Sz) ->
+ [{sndbuf, Sz}].
+
+
+create_filter(Opts) when is_list(Opts) ->
+ case get_opt(Opts, module, ?DEFAULT_FILTER_MODULE) of
+ ?DEFAULT_FILTER_MODULE = Mod ->
+ Mod;
+ Module ->
+ snmpm_network_interface_filter:verify(Module),
+ Module
+ end;
+create_filter(BadOpts) ->
+ throw({error, {bad_filter_opts, BadOpts}}).
+
+
+%% ----------------------------------------------------------------------
+%% Audit Trail Logger
+%% ----------------------------------------------------------------------
+
+%% Open log
+do_init_log(false) ->
+ ?vtrace("do_init_log(false) -> entry", []),
+ undefined;
+do_init_log(true) ->
+ ?vtrace("do_init_log(true) -> entry", []),
+ {ok, Type} = snmpm_config:system_info(audit_trail_log_type),
+ {ok, Dir} = snmpm_config:system_info(audit_trail_log_dir),
+ {ok, Size} = snmpm_config:system_info(audit_trail_log_size),
+ {ok, Repair} = snmpm_config:system_info(audit_trail_log_repair),
+ Name = ?audit_trail_log_name,
+ File = filename:absname(?audit_trail_log_file, Dir),
+ case snmpm_config:system_info(audit_trail_log_seqno) of
+ {ok, true} ->
+ Initial = ?ATL_SEQNO_INITIAL,
+ Max = ?ATL_SEQNO_MAX,
+ Module = snmpm_config,
+ Function = increment_counter,
+ Args = [atl_seqno, Initial, Max],
+ SeqNoGen = {Module, Function, Args},
+ case snmp_log:create(Name, File, SeqNoGen, Size, Repair, true) of
+ {ok, Log} ->
+ ?vdebug("log created: ~w", [Log]),
+ {Name, Log, Type};
+ {error, Reason} ->
+ throw({error, {failed_create_audit_log, Reason}})
+ end;
+ _ ->
+ case snmp_log:create(Name, File, Size, Repair, true) of
+ {ok, Log} ->
+ ?vdebug("log created: ~w", [Log]),
+ {Name, Log, Type};
+ {error, Reason} ->
+ throw({error, {failed_create_audit_log, Reason}})
+ end
+ end.
+
+
+%% ----------------------------------------------------------------------
+
+%%--------------------------------------------------------------------
+%% Func: handle_call/3
+%% Returns: {reply, Reply, State} |
+%% {reply, Reply, State, Timeout} |
+%% {noreply, State} |
+%% {noreply, State, Timeout} |
+%% {stop, Reason, Reply, State} | (terminate/2 is called)
+%% {stop, Reason, State} (terminate/2 is called)
+%%--------------------------------------------------------------------
+handle_call({verbosity, Verbosity}, _From, State) ->
+ ?vlog("received verbosity request", []),
+ put(verbosity, Verbosity),
+ {reply, ok, State};
+
+%% handle_call({system_info_updated, What}, _From, State) ->
+%% ?vlog("received system_info_updated request with What = ~p", [What]),
+%% {NewState, Reply} = handle_system_info_updated(State, What),
+%% {reply, Reply, NewState};
+
+handle_call(get_log_type, _From, State) ->
+ ?vlog("received get-log-type request", []),
+ Reply = (catch handle_get_log_type(State)),
+ {reply, Reply, State};
+
+handle_call({set_log_type, NewType}, _From, State) ->
+ ?vlog("received set-log-type request with NewType = ~p", [NewType]),
+ {NewState, Reply} = (catch handle_set_log_type(State, NewType)),
+ {reply, Reply, NewState};
+
+handle_call({note_store, Pid}, _From, State) ->
+ ?vlog("received new note_store: ~w", [Pid]),
+ {reply, ok, State#state{note_store = Pid}};
+
+handle_call(stop, _From, State) ->
+ ?vlog("received stop request", []),
+ Reply = ok,
+ {stop, normal, Reply, State};
+
+handle_call(info, _From, State) ->
+ ?vlog("received info request", []),
+ Reply = get_info(State),
+ {reply, Reply, State};
+
+handle_call(Req, From, State) ->
+ warning_msg("received unknown request (from ~p): ~n~p", [Req, From]),
+ {reply, {error, {invalid_request, Req}}, State}.
+
+
+%%--------------------------------------------------------------------
+%% Func: handle_cast/2
+%% Returns: {noreply, State} |
+%% {noreply, State, Timeout} |
+%% {stop, Reason, State} (terminate/2 is called)
+%%--------------------------------------------------------------------
+handle_cast({send_pdu, Pdu, Vsn, MsgData, Domain, Addr, Port, ExtraInfo},
+ State) ->
+ ?vlog("received send_pdu message with"
+ "~n Pdu: ~p"
+ "~n Vsn: ~p"
+ "~n MsgData: ~p"
+ "~n Domain: ~p"
+ "~n Addr: ~p"
+ "~n Port: ~p", [Pdu, Vsn, MsgData, Domain, Addr, Port]),
+ maybe_process_extra_info(ExtraInfo),
+ handle_send_pdu(Pdu, Vsn, MsgData, Domain, Addr, Port, State),
+ {noreply, State};
+
+handle_cast({inform_response, Ref, Addr, Port}, State) ->
+ ?vlog("received inform_response message with"
+ "~n Ref: ~p"
+ "~n Addr: ~p"
+ "~n Port: ~p", [Ref, Addr, Port]),
+ handle_inform_response(Ref, Addr, Port, State),
+ {noreply, State};
+
+handle_cast(filter_reset, State) ->
+ ?vlog("received filter_reset message", []),
+ reset_counters(),
+ {noreply, State};
+
+handle_cast(Msg, State) ->
+ warning_msg("received unknown message: ~n~p", [Msg]),
+ {noreply, State}.
+
+
+%%--------------------------------------------------------------------
+%% Func: handle_info/2
+%% Returns: {noreply, State} |
+%% {noreply, State, Timeout} |
+%% {stop, Reason, State} (terminate/2 is called)
+%%--------------------------------------------------------------------
+handle_info({udp, Sock, Ip, Port, Bytes}, #state{sock = Sock} = State) ->
+ ?vlog("received ~w bytes from ~p:~p", [size(Bytes), Ip, Port]),
+ handle_udp(Ip, Port, Bytes, State),
+ {noreply, State};
+
+handle_info(inform_response_gc, State) ->
+ ?vlog("received inform_response_gc message", []),
+ State2 = handle_inform_response_gc(State),
+ {noreply, State2};
+
+handle_info({disk_log, _Node, Log, Info}, State) ->
+ ?vlog("received disk_log message: "
+ "~n Info: ~p", [Info]),
+ State2 = handle_disk_log(Log, Info, State),
+ {noreply, State2};
+
+handle_info({'DOWN', _MRef, process, Pid, {net_if_worker, ExitStatus}},
+ State) ->
+ ?vdebug("received DOWN message from net_if-worker: "
+ "~n ExitStatus: ~p", [ExitStatus]),
+ handle_worker_exit(Pid, ExitStatus),
+ {noreply, State};
+
+handle_info(Info, State) ->
+ warning_msg("received unknown info: ~n~p", [Info]),
+ {noreply, State}.
+
+
+%%--------------------------------------------------------------------
+%% Func: terminate/2
+%% Purpose: Shutdown the server
+%% Returns: any (ignored by gen_server)
+%%--------------------------------------------------------------------
+terminate(Reason, #state{log = Log, irgc = IrGcRef}) ->
+ ?vdebug("terminate: ~p", [Reason]),
+ irgc_stop(IrGcRef),
+ %% Close logs
+ do_close_log(Log),
+ ok.
+
+
+do_close_log({Log, _Type}) ->
+ (catch snmp_log:sync(Log)),
+ (catch snmp_log:close(Log)),
+ ok;
+do_close_log(_) ->
+ ok.
+
+
+%%----------------------------------------------------------------------
+%% Func: code_change/3
+%% Purpose: Convert process state when code is changed
+%% Returns: {ok, NewState}
+%%----------------------------------------------------------------------
+
+code_change(_Vsn, State, _Extra) ->
+ ?d("code_change -> entry with"
+ "~n Vsn: ~p"
+ "~n State: ~p"
+ "~n Extra: ~p", [_Vsn, State, _Extra]),
+ {ok, State}.
+
+
+%%%-------------------------------------------------------------------
+%%% Internal functions
+%%%-------------------------------------------------------------------
+
+handle_udp(Addr, Port, Bytes, State) ->
+ Verbosity = get(verbosity),
+ spawn_opt(fun() ->
+ Log = worker_init(State, Verbosity),
+ Res = (catch maybe_handle_recv_msg(
+ Addr, Port, Bytes,
+ State#state{log = Log})),
+ worker_exit(udp, {Addr, Port}, Res)
+ end,
+ [monitor]).
+
+
+maybe_handle_recv_msg(Addr, Port, Bytes, #state{filter = FilterMod} = State) ->
+ case (catch FilterMod:accept_recv(Addr, Port)) of
+ false ->
+ %% Drop the received packet
+ inc(netIfMsgInDrops),
+ ok;
+ _ ->
+ handle_recv_msg(Addr, Port, Bytes, State)
+ end.
+
+
+handle_recv_msg(Addr, Port, Bytes, #state{server = Pid})
+ when is_binary(Bytes) andalso (size(Bytes) =:= 0) ->
+ Pid ! {snmp_error, {empty_message, Addr, Port}, Addr, Port},
+ ok;
+
+handle_recv_msg(Addr, Port, Bytes,
+ #state{server = Pid,
+ note_store = NoteStore,
+ mpd_state = MpdState,
+ sock = Sock,
+ log = Log} = State) ->
+ Domain = snmp_conf:which_domain(Addr), % What the ****...
+ Logger = logger(Log, read, Addr, Port),
+ case (catch snmpm_mpd:process_msg(Bytes, Domain, Addr, Port,
+ MpdState, NoteStore, Logger)) of
+
+ {ok, Vsn, Pdu, MS, ACM} ->
+ maybe_handle_recv_pdu(Addr, Port, Vsn, Pdu, MS, ACM,
+ Logger, State);
+
+ {discarded, Reason, Report} ->
+ ?vdebug("discarded: ~p", [Reason]),
+ ErrorInfo = {failed_processing_message, Reason},
+ Pid ! {snmp_error, ErrorInfo, Addr, Port},
+ maybe_udp_send(State#state.filter, Sock, Addr, Port, Report),
+ ok;
+
+ {discarded, Reason} ->
+ ?vdebug("discarded: ~p", [Reason]),
+ ErrorInfo = {failed_processing_message, Reason},
+ Pid ! {snmp_error, ErrorInfo, Addr, Port},
+ ok;
+
+ Error ->
+ error_msg("processing of received message failed: "
+ "~n ~p", [Error]),
+ ok
+ end.
+
+
+maybe_handle_recv_pdu(Addr, Port,
+ Vsn, #pdu{type = Type} = Pdu, PduMS, ACM,
+ Logger,
+ #state{filter = FilterMod} = State) ->
+ case (catch FilterMod:accept_recv_pdu(Addr, Port, Type)) of
+ false ->
+ inc(netIfPduInDrops),
+ ok;
+ _ ->
+ handle_recv_pdu(Addr, Port, Vsn, Pdu, PduMS, ACM, Logger, State)
+ end;
+maybe_handle_recv_pdu(Addr, Port, Vsn, Trap, PduMS, ACM, Logger,
+ #state{filter = FilterMod} = State)
+ when is_record(Trap, trappdu) ->
+ case (catch FilterMod:accept_recv_pdu(Addr, Port, trappdu)) of
+ false ->
+ inc(netIfPduInDrops),
+ ok;
+ _ ->
+ handle_recv_pdu(Addr, Port, Vsn, Trap, PduMS, ACM, Logger, State)
+ end;
+maybe_handle_recv_pdu(Addr, Port, Vsn, Pdu, PduMS, ACM, Logger, State) ->
+ handle_recv_pdu(Addr, Port, Vsn, Pdu, PduMS, ACM, Logger, State).
+
+
+handle_recv_pdu(Addr, Port,
+ Vsn, #pdu{type = 'inform-request'} = Pdu, _PduMS, ACM,
+ Logger, #state{server = Pid, irb = IRB} = State) ->
+ handle_inform_request(IRB, Pid, Vsn, Pdu, ACM,
+ Addr, Port, Logger, State);
+handle_recv_pdu(Addr, Port,
+ _Vsn, #pdu{type = report} = Pdu, _PduMS, ok,
+ _Logger,
+ #state{server = Pid} = _State) ->
+ ?vtrace("received report - ok", []),
+ Pid ! {snmp_report, {ok, Pdu}, Addr, Port},
+ ok;
+handle_recv_pdu(Addr, Port,
+ _Vsn, #pdu{type = report} = Pdu, _PduMS,
+ {error, ReqId, Reason},
+ _Logger,
+ #state{server = Pid} = _State) ->
+ ?vtrace("received report - error", []),
+ Pid ! {snmp_report, {error, ReqId, Reason, Pdu}, Addr, Port},
+ ok;
+handle_recv_pdu(Addr, Port,
+ _Vsn, #pdu{type = 'snmpv2-trap'} = Pdu, _PduMS, _ACM,
+ _Logger,
+ #state{server = Pid} = _State) ->
+ ?vtrace("received snmpv2-trap", []),
+ Pid ! {snmp_trap, Pdu, Addr, Port},
+ ok;
+handle_recv_pdu(Addr, Port,
+ _Vsn, Trap, _PduMS, _ACM,
+ _Logger,
+ #state{server = Pid} = _State) when is_record(Trap, trappdu) ->
+ ?vtrace("received trappdu", []),
+ Pid ! {snmp_trap, Trap, Addr, Port},
+ ok;
+handle_recv_pdu(Addr, Port,
+ _Vsn, Pdu, _PduMS, _ACM,
+ _Logger,
+ #state{server = Pid} = _State) when is_record(Pdu, pdu) ->
+ ?vtrace("received pdu", []),
+ Pid ! {snmp_pdu, Pdu, Addr, Port},
+ ok;
+handle_recv_pdu(_Addr, _Port, _Vsn, Pdu, _PduMS, ACM, _Logger, _State) ->
+ ?vlog("received unexpected pdu: "
+ "~n Pdu: ~p"
+ "~n ACM: ~p", [Pdu, ACM]),
+ ok.
+
+
+handle_inform_request(auto, Pid, Vsn, Pdu, ACM, Addr, Port, Logger, State) ->
+ ?vtrace("received inform-request (true)", []),
+ Pid ! {snmp_inform, ignore, Pdu, Addr, Port},
+ RePdu = make_response_pdu(Pdu),
+ maybe_send_inform_response(RePdu, Vsn, ACM, Addr, Port, Logger, State);
+handle_inform_request({user, To}, Pid, Vsn, #pdu{request_id = ReqId} = Pdu,
+ ACM, Addr, Port, _Logger, _State) ->
+ ?vtrace("received inform-request (false)", []),
+
+ Pid ! {snmp_inform, ReqId, Pdu, Addr, Port},
+
+ %% Before we go any further, we need to check that we have not
+ %% already received this message (possible resend).
+
+ Key = {ReqId, Addr, Port},
+ case ets:lookup(snmpm_inform_request_table, Key) of
+ [_] ->
+ %% OK, we already know about this. We assume this
+ %% is a resend. Either the agent is really eager or
+ %% the user has not answered yet. Bad user!
+ ok;
+ [] ->
+ RePdu = make_response_pdu(Pdu),
+ Expire = t() + To,
+ Rec = {Key, Expire, {Vsn, ACM, RePdu}},
+ ets:insert(snmpm_inform_request_table, Rec)
+ end,
+ ok.
+
+handle_inform_response(Ref, Addr, Port, State) ->
+ Verbosity = get(verbosity),
+ spawn_opt(fun() ->
+ Log = worker_init(State, Verbosity),
+ Res = (catch do_handle_inform_response(
+ Ref,
+ Addr, Port,
+ State#state{log = Log})),
+ worker_exit(inform_reponse, {Addr, Port}, Res)
+ end,
+ [monitor]).
+
+
+
+do_handle_inform_response(Ref, Addr, Port, State) ->
+ Key = {Ref, Addr, Port},
+ case ets:lookup(snmpm_inform_request_table, Key) of
+ [{Key, _, {Vsn, ACM, RePdu}}] ->
+ Logger = logger(State#state.log, read, Addr, Port),
+ ets:delete(snmpm_inform_request_table, Key),
+ maybe_send_inform_response(RePdu, Vsn, ACM, Addr, Port,
+ Logger, State);
+ [] ->
+ %% Already acknowledged, or the user was to slow to reply...
+ ok
+ end,
+ ok.
+
+maybe_send_inform_response(RePdu, Vsn, ACM, Addr, Port, Logger,
+ #state{server = Pid,
+ sock = Sock,
+ filter = FilterMod}) ->
+ case (catch FilterMod:accept_send_pdu(Addr, Port, pdu_type_of(RePdu))) of
+ false ->
+ inc(netIfPduOutDrops),
+ ok;
+ _ ->
+ case snmpm_mpd:generate_response_msg(Vsn, RePdu, ACM, Logger) of
+ {ok, Msg} ->
+ maybe_udp_send(FilterMod, Sock, Addr, Port, Msg);
+ {discarded, Reason} ->
+ ?vlog("failed generating response message:"
+ "~n Reason: ~p", [Reason]),
+ ReqId = RePdu#pdu.request_id,
+ ErrorInfo = {failed_generating_response, {RePdu, Reason}},
+ Pid ! {snmp_error, ReqId, ErrorInfo, Addr, Port},
+ ok
+ end
+ end.
+
+handle_inform_response_gc(#state{irb = IRB} = State) ->
+ ets:safe_fixtable(snmpm_inform_request_table, true),
+ do_irgc(ets:first(snmpm_inform_request_table), t()),
+ ets:safe_fixtable(snmpm_inform_request_table, false),
+ State#state{irgc = irgc_start(IRB)}.
+
+%% We are deleting at the same time as we are traversing the table!!!
+do_irgc('$end_of_table', _) ->
+ ok;
+do_irgc(Key, Now) ->
+ Next = ets:next(snmpm_inform_request_table, Key),
+ case ets:lookup(snmpm_inform_request_table, Key) of
+ [{Key, BestBefore, _}] when BestBefore < Now ->
+ ets:delete(snmpm_inform_request_table, Key);
+ _ ->
+ ok
+ end,
+ do_irgc(Next, Now).
+
+irgc_start(auto) ->
+ undefined;
+irgc_start(_) ->
+ erlang:send_after(?IRGC_TIMEOUT, self(), inform_response_gc).
+
+irgc_stop(undefined) ->
+ ok;
+irgc_stop(Ref) ->
+ (catch erlang:cancel_timer(Ref)).
+
+
+handle_send_pdu(Pdu, Vsn, MsgData, Domain, Addr, Port, State) ->
+ Verbosity = get(verbosity),
+ spawn_opt(fun() ->
+ Log = worker_init(State, Verbosity),
+ Res = (catch maybe_handle_send_pdu(
+ Pdu, Vsn, MsgData,
+ Domain, Addr, Port,
+ State#state{log = Log})),
+ worker_exit(send_pdu, {Domain, Addr, Port}, Res)
+ end,
+ [monitor]).
+
+maybe_handle_send_pdu(Pdu, Vsn, MsgData, Domain, Addr, Port,
+ #state{filter = FilterMod} = State) ->
+ case (catch FilterMod:accept_send_pdu(Addr, Port, pdu_type_of(Pdu))) of
+ false ->
+ inc(netIfPduOutDrops),
+ ok;
+ _ ->
+ do_handle_send_pdu(Pdu, Vsn, MsgData, Domain, Addr, Port, State)
+ end.
+
+do_handle_send_pdu(Pdu, Vsn, MsgData, _Domain, Addr, Port,
+ #state{server = Pid,
+ note_store = NoteStore,
+ sock = Sock,
+ log = Log,
+ filter = FilterMod}) ->
+ Logger = logger(Log, write, Addr, Port),
+ case (catch snmpm_mpd:generate_msg(Vsn, NoteStore,
+ Pdu, MsgData, Logger)) of
+ {ok, Msg} ->
+ ?vtrace("do_handle_send_pdu -> message generated", []),
+ maybe_udp_send(FilterMod, Sock, Addr, Port, Msg);
+ {discarded, Reason} ->
+ ?vlog("PDU not sent: "
+ "~n PDU: ~p"
+ "~n Reason: ~p", [Pdu, Reason]),
+ Pid ! {snmp_error, Pdu, Reason},
+ ok
+ end.
+
+
+maybe_udp_send(FilterMod, Sock, Addr, Port, Msg) ->
+ case (catch FilterMod:accept_send(Addr, Port)) of
+ false ->
+ inc(netIfMsgOutDrops),
+ ok;
+ _ ->
+ udp_send(Sock, Addr, Port, Msg)
+ end.
+
+
+udp_send(Sock, Addr, Port, Msg) ->
+ case (catch gen_udp:send(Sock, Addr, Port, Msg)) of
+ ok ->
+ ?vdebug("sent ~w bytes to ~w:~w [~w]",
+ [sz(Msg), Addr, Port, Sock]),
+ ok;
+ {error, Reason} ->
+ error_msg("failed sending message to ~p:~p: "
+ "~n ~p",[Addr, Port, Reason]),
+ ok;
+ Error ->
+ error_msg("failed sending message to ~p:~p: "
+ "~n ~p",[Addr, Port, Error]),
+ ok
+ end.
+
+sz(B) when is_binary(B) ->
+ size(B);
+sz(L) when is_list(L) ->
+ length(L);
+sz(_) ->
+ undefined.
+
+
+handle_disk_log(_Log, {wrap, NoLostItems}, State) ->
+ ?vlog("Audit Trail Log - wrapped: ~w previously logged items where lost",
+ [NoLostItems]),
+ State;
+handle_disk_log(_Log, {truncated, NoLostItems}, State) ->
+ ?vlog("Audit Trail Log - truncated: ~w items where lost when truncating",
+ [NoLostItems]),
+ State;
+handle_disk_log(_Log, full, State) ->
+ error_msg("Failed to write to Audit Trail Log (full)", []),
+ State;
+handle_disk_log(_Log, {error_status, ok}, State) ->
+ State;
+handle_disk_log(_Log, {error_status, {error, Reason}}, State) ->
+ error_msg("Error status received from Audit Trail Log: "
+ "~n~p", [Reason]),
+ State;
+handle_disk_log(_Log, _Info, State) ->
+ State.
+
+
+%% mk_discovery_msg('version-3', Pdu, _VsnHdr, UserName) ->
+%% ScopedPDU = #scopedPdu{contextEngineID = "",
+%% contextName = "",
+%% data = Pdu},
+%% Bytes = snmp_pdus:enc_scoped_pdu(ScopedPDU),
+%% MsgID = get(msg_id),
+%% put(msg_id,MsgID+1),
+%% UsmSecParams =
+%% #usmSecurityParameters{msgAuthoritativeEngineID = "",
+%% msgAuthoritativeEngineBoots = 0,
+%% msgAuthoritativeEngineTime = 0,
+%% msgUserName = UserName,
+%% msgPrivacyParameters = "",
+%% msgAuthenticationParameters = ""},
+%% SecBytes = snmp_pdus:enc_usm_security_parameters(UsmSecParams),
+%% PduType = Pdu#pdu.type,
+%% Hdr = #v3_hdr{msgID = MsgID,
+%% msgMaxSize = 1000,
+%% msgFlags = snmp_misc:mk_msg_flags(PduType, 0),
+%% msgSecurityModel = ?SEC_USM,
+%% msgSecurityParameters = SecBytes},
+%% Msg = #message{version = 'version-3', vsn_hdr = Hdr, data = Bytes},
+%% case (catch snmp_pdus:enc_message_only(Msg)) of
+%% {'EXIT', Reason} ->
+%% error("Encoding error. Pdu: ~w. Reason: ~w",[Pdu, Reason]),
+%% error;
+%% L when list(L) ->
+%% {Msg, L}
+%% end;
+%% mk_discovery_msg(Version, Pdu, {Com, _, _, _, _}, UserName) ->
+%% Msg = #message{version = Version, vsn_hdr = Com, data = Pdu},
+%% case catch snmp_pdus:enc_message(Msg) of
+%% {'EXIT', Reason} ->
+%% error("Encoding error. Pdu: ~w. Reason: ~w",[Pdu, Reason]),
+%% error;
+%% L when list(L) ->
+%% {Msg, L}
+%% end.
+
+
+%% mk_msg('version-3', Pdu, {Context, User, EngineID, CtxEngineId, SecLevel},
+%% MsgData) ->
+%% %% Code copied from snmp_mpd.erl
+%% {MsgId, SecName, SecData} =
+%% if
+%% tuple(MsgData), Pdu#pdu.type == 'get-response' ->
+%% MsgData;
+%% true ->
+%% Md = get(msg_id),
+%% put(msg_id, Md + 1),
+%% {Md, User, []}
+%% end,
+%% ScopedPDU = #scopedPdu{contextEngineID = CtxEngineId,
+%% contextName = Context,
+%% data = Pdu},
+%% ScopedPDUBytes = snmp_pdus:enc_scoped_pdu(ScopedPDU),
+
+%% PduType = Pdu#pdu.type,
+%% V3Hdr = #v3_hdr{msgID = MsgId,
+%% msgMaxSize = 1000,
+%% msgFlags = snmp_misc:mk_msg_flags(PduType, SecLevel),
+%% msgSecurityModel = ?SEC_USM},
+%% Message = #message{version = 'version-3', vsn_hdr = V3Hdr,
+%% data = ScopedPDUBytes},
+%% SecEngineID = case PduType of
+%% 'get-response' -> snmp_framework_mib:get_engine_id();
+%% _ -> EngineID
+%% end,
+%% case catch snmp_usm:generate_outgoing_msg(Message, SecEngineID,
+%% SecName, SecData, SecLevel) of
+%% {'EXIT', Reason} ->
+%% error("Encoding error. Pdu: ~w. Reason: ~w",[Pdu, Reason]),
+%% error;
+%% {error, Reason} ->
+%% error("Encoding error. Pdu: ~w. Reason: ~w",[Pdu, Reason]),
+%% error;
+%% Packet ->
+%% Packet
+%% end;
+%% mk_msg(Version, Pdu, {Com, _User, _EngineID, _Ctx, _SecLevel}, _SecData) ->
+%% Msg = #message{version = Version, vsn_hdr = Com, data = Pdu},
+%% case catch snmp_pdus:enc_message(Msg) of
+%% {'EXIT', Reason} ->
+%% error("Encoding error. Pdu: ~w. Reason: ~w",[Pdu, Reason]),
+%% error;
+%% B when list(B) ->
+%% B
+%% end.
+
+
+%% handle_system_info_updated(#state{log = {Log, _OldType}} = State,
+%% audit_trail_log_type = _What) ->
+%% %% Just to make sure, check that ATL is actually enabled
+%% case snmpm_config:system_info(audit_trail_log) of
+%% {ok, true} ->
+%% {ok, Type} = snmpm_config:system_info(audit_trail_log_type),
+%% NewState = State#state{log = {Log, Type}},
+%% {NewState, ok};
+%% _ ->
+%% {State, {error, {adt_not_enabled}}}
+%% end;
+%% handle_system_info_updated(_State, _What) ->
+%% ok.
+
+handle_get_log_type(#state{log = {_Log, Value}} = State) ->
+ %% Just to make sure, check that ATL is actually enabled
+ case snmpm_config:system_info(audit_trail_log) of
+ {ok, true} ->
+ Type =
+ case {lists:member(read, Value), lists:member(write, Value)} of
+ {true, true} ->
+ read_write;
+ {true, false} ->
+ read;
+ {false, true} ->
+ write;
+ {false, false} ->
+ throw({State, {error, {bad_atl_type, Value}}})
+ end,
+ {ok, Type};
+ _ ->
+ {error, not_enabled}
+ end;
+handle_get_log_type(_State) ->
+ {error, not_enabled}.
+
+handle_set_log_type(#state{log = {Log, OldValue}} = State, NewType) ->
+ %% Just to make sure, check that ATL is actually enabled
+ case snmpm_config:system_info(audit_trail_log) of
+ {ok, true} ->
+ NewValue =
+ case NewType of
+ read ->
+ [read];
+ write ->
+ [write];
+ read_write ->
+ [read,write];
+ _ ->
+ throw({State, {error, {bad_atl_type, NewType}}})
+ end,
+ NewState = State#state{log = {Log, NewValue}},
+ OldType =
+ case {lists:member(read, OldValue),
+ lists:member(write, OldValue)} of
+ {true, true} ->
+ read_write;
+ {true, false} ->
+ read;
+ {false, true} ->
+ write;
+ {false, false} ->
+ throw({State, {error, {bad_atl_type, OldValue}}})
+ end,
+ {NewState, {ok, OldType}};
+ _ ->
+ {State, {error, not_enabled}}
+ end;
+handle_set_log_type(State, _NewType) ->
+ {State, {error, not_enabled}}.
+
+
+%% -------------------------------------------------------------------
+
+worker_init(#state{log = undefined = Log}, Verbosity) ->
+ worker_init2(Log, Verbosity);
+worker_init(#state{log = {Name, Log, Type}}, Verbosity) ->
+ case snmp_log:open(Name, Log) of
+ {ok, NewLog} ->
+ worker_init2({Name, NewLog, Type}, Verbosity);
+ {error, Reason} ->
+ warning_msg("NetIf worker ~p failed opening ATL: "
+ "~n ~p", [self(), Reason]),
+ NewLog = undefined,
+ worker_init2({Name, NewLog, Type}, Verbosity)
+ end;
+worker_init(State, Verbosity) ->
+ ?vinfo("worker_init -> entry with invalid data: "
+ "~n State: ~p"
+ "~n Verbosity: ~p", [State, Verbosity]),
+ exit({worker_init, State, Verbosity}).
+
+worker_init2(Log, Verbosity) ->
+ put(sname, mnifw),
+ put(verbosity, Verbosity),
+ Log.
+
+
+worker_exit(Tag, Info, Result) ->
+ exit({net_if_worker, {Tag, Info, Result}}).
+
+handle_worker_exit(_, {_, _, ok}) ->
+ ok;
+handle_worker_exit(Pid, {udp, {Addr, Port}, ExitStatus}) ->
+ warning_msg("Worker process (~p) terminated "
+ "while processing (incomming) message from ~w:~w: "
+ "~n~p", [Pid, Addr, Port, ExitStatus]),
+ ok;
+handle_worker_exit(Pid, {send_pdu, {Domain, Addr, Port}, ExitStatus}) ->
+ warning_msg("Worker process (~p) terminated "
+ "while processing (outgoing) pdu for [~w] ~w:~w: "
+ "~n~p", [Pid, Domain, Addr, Port, ExitStatus]),
+ ok;
+handle_worker_exit(Pid, {inform_response, {Addr, Port}, ExitStatus}) ->
+ warning_msg("Worker process (~p) terminated "
+ "while processing (outgoing) inform response for ~w:~w: "
+ "~n~p", [Pid, Addr, Port, ExitStatus]),
+ ok;
+handle_worker_exit(_, _) ->
+ ok.
+
+
+%% -------------------------------------------------------------------
+
+make_response_pdu(#pdu{request_id = ReqId, varbinds = Vbs}) ->
+ #pdu{type = 'get-response',
+ request_id = ReqId,
+ error_status = noError,
+ error_index = 0,
+ varbinds = Vbs}.
+
+
+%% ----------------------------------------------------------------
+
+pdu_type_of(#pdu{type = Type}) ->
+ Type;
+pdu_type_of(TrapPdu) when is_record(TrapPdu, trappdu) ->
+ trap.
+
+
+%% -------------------------------------------------------------------
+
+%% At this point this function is used during testing
+maybe_process_extra_info(?DEFAULT_EXTRA_INFO) ->
+ ok;
+maybe_process_extra_info({?SNMPM_EXTRA_INFO_TAG, Fun})
+ when is_function(Fun, 0) ->
+ (catch Fun()),
+ ok;
+maybe_process_extra_info(_ExtraInfo) ->
+ ok.
+
+
+%% -------------------------------------------------------------------
+
+t() ->
+ {A,B,C} = erlang:now(),
+ A*1000000000+B*1000+(C div 1000).
+
+
+%% -------------------------------------------------------------------
+
+logger(undefined, _Type, _Addr, _Port) ->
+ fun(_) ->
+ ok
+ end;
+logger({_Name, Log, Types}, Type, Addr, Port) ->
+ case lists:member(Type, Types) of
+ true ->
+ fun(Msg) ->
+ snmp_log:log(Log, Msg, Addr, Port)
+ end;
+ false ->
+ fun(_) ->
+ ok
+ end
+ end.
+
+
+%% -------------------------------------------------------------------
+
+%% info_msg(F, A) ->
+%% ?snmpm_info("NET-IF server: " ++ F, A).
+
+warning_msg(F, A) ->
+ ?snmpm_warning("NET-IF server: " ++ F, A).
+
+error_msg(F, A) ->
+ ?snmpm_error("NET-IF server: " ++ F, A).
+
+
+
+%%%-------------------------------------------------------------------
+
+% get_opt(Key, Opts) ->
+% ?vtrace("get option ~w", [Key]),
+% snmp_misc:get_option(Key, Opts).
+
+get_opt(Opts, Key, Def) ->
+ ?vtrace("get option ~w with default ~p", [Key, Def]),
+ snmp_misc:get_option(Key, Opts, Def).
+
+
+%% -------------------------------------------------------------------
+
+get_info(#state{sock = Id}) ->
+ ProcSize = proc_mem(self()),
+ PortInfo = get_port_info(Id),
+ [{process_memory, ProcSize}, {port_info, PortInfo}].
+
+proc_mem(P) when is_pid(P) ->
+ case (catch erlang:process_info(P, memory)) of
+ {memory, Sz} when is_integer(Sz) ->
+ Sz;
+ _ ->
+ undefined
+ end.
+%% proc_mem(_) ->
+%% undefined.
+
+
+get_port_info(Id) ->
+ PortInfo =
+ case (catch erlang:port_info(Id)) of
+ PI when is_list(PI) ->
+ [{port_info, PI}];
+ _ ->
+ []
+ end,
+ PortStatus =
+ case (catch prim_inet:getstatus(Id)) of
+ {ok, PS} ->
+ [{port_status, PS}];
+ _ ->
+ []
+ end,
+ PortAct =
+ case (catch inet:getopts(Id, [active])) of
+ {ok, PA} ->
+ [{port_act, PA}];
+ _ ->
+ []
+ end,
+ PortStats =
+ case (catch inet:getstat(Id)) of
+ {ok, Stat} ->
+ [{port_stats, Stat}];
+ _ ->
+ []
+ end,
+ IfList =
+ case (catch inet:getif(Id)) of
+ {ok, IFs} ->
+ [{interfaces, IFs}];
+ _ ->
+ []
+ end,
+ BufSz =
+ case (catch inet:getopts(Id, [recbuf, sndbuf, buffer])) of
+ {ok, Sz} ->
+ [{buffer_size, Sz}];
+ _ ->
+ []
+ end,
+ [{socket, Id}] ++
+ IfList ++
+ PortStats ++
+ PortInfo ++
+ PortStatus ++
+ PortAct ++
+ BufSz.
+
+
+%%-----------------------------------------------------------------
+%% Counter functions
+%%-----------------------------------------------------------------
+init_counters() ->
+ F = fun(Counter) -> maybe_create_counter(Counter) end,
+ lists:map(F, counters()).
+
+reset_counters() ->
+ F = fun(Counter) -> snmpm_config:reset_stats_counter(Counter) end,
+ lists:map(F, counters()).
+
+maybe_create_counter(Counter) ->
+ snmpm_config:maybe_cre_stats_counter(Counter, 0).
+
+counters() ->
+ [
+ netIfMsgOutDrops,
+ netIfMsgInDrops,
+ netIfPduOutDrops,
+ netIfPduInDrops
+ ].
+
+inc(Name) -> inc(Name, 1).
+inc(Name, N) -> snmpm_config:incr_stats_counter(Name, N).
+
+%% get_counters() ->
+%% Counters = counters(),
+%% get_counters(Counters, []).
+
+%% get_counters([], Acc) ->
+%% lists:reverse(Acc);
+%% get_counters([Counter|Counters], Acc) ->
+%% case snmpm_config:get_stats_counter(Counter) of
+%% {ok, CounterVal} ->
+%% get_counters(Counters, [{Counter, CounterVal}|Acc]);
+%% _ ->
+%% get_counters(Counters, Acc)
+%% end.
+
+
+%% ----------------------------------------------------------------
+
+call(Pid, Req) ->
+ call(Pid, Req, infinity).
+
+call(Pid, Req, Timeout) ->
+ gen_server:call(Pid, Req, Timeout).
+
+cast(Pid, Msg) ->
+ gen_server:cast(Pid, Msg).
+
diff --git a/lib/snmp/src/misc/snmp_log.erl b/lib/snmp/src/misc/snmp_log.erl
index 2c781810ef..a8c5df0b64 100644
--- a/lib/snmp/src/misc/snmp_log.erl
+++ b/lib/snmp/src/misc/snmp_log.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% 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
@@ -21,7 +21,7 @@
-export([
- create/4, create/5, create/6,
+ create/4, create/5, create/6, open/1, open/2,
change_size/2, close/1, sync/1, info/1,
log/4,
log_to_txt/5, log_to_txt/6, log_to_txt/7,
@@ -109,6 +109,24 @@ create(Name, File, SeqNoGen, Size, Repair, Notify) ->
{error, {bad_args, Name, File, SeqNoGen, Size, Repair, Notify}}.
+%% -- open ---
+
+%% Open an already existing ( = open ) log
+
+open(Name) ->
+ open(Name, #snmp_log{seqno = disabled}).
+open(Name, #snmp_log{seqno = SeqNoGen} = _OldLog) ->
+ %% We include mode in the opts just to be on the safe side
+ case disk_log:open([{name, Name}, {mode, read_write}]) of
+ {ok, Log} ->
+ %% SeqNo must be proprly initiated also
+ {ok, #snmp_log{id = Log, seqno = SeqNoGen}};
+ {repaired, Log, _RecBytes, _BadBytes} ->
+ {ok, #snmp_log{id = Log, seqno = SeqNoGen}};
+ ERROR ->
+ ERROR
+ end.
+
%% -- close ---
@@ -394,6 +412,14 @@ log_to_io(Log, FileName, Dir, Mibs, Start) ->
log_to_io(Log, FileName, Dir, Mibs, Start, Stop)
when is_list(Mibs) ->
+ ?vtrace("log_to_io -> entry with"
+ "~n Log: ~p"
+ "~n FileName: ~p"
+ "~n Dir: ~p"
+ "~n Mibs: ~p"
+ "~n Start: ~p"
+ "~n Stop: ~p",
+ [Log, FileName, Dir, Mibs, Start, Stop]),
File = filename:join(Dir, FileName),
Converter = fun(L) ->
do_log_to_io(L, Mibs, Start, Stop)
@@ -401,28 +427,10 @@ log_to_io(Log, FileName, Dir, Mibs, Start, Stop)
log_convert(Log, File, Converter).
-%% -- log_to_plain ---
-
-%% log_to_plain(Log, FileName, Dir) ->
-%% log_to_plain(Log, FileName, Dir, null, null).
-
-%% log_to_plain(Log, FileName, Dir, Start) ->
-%% log_to_plain(Log, FileName, Dir, Start, null).
-
-%% log_to_plain(Log, FileName, Dir, Start, Stop)
-%% when is_list(Mibs) ->
-%% File = filename:join(Dir, FileName),
-%% Converter = fun(L) ->
-%% do_log_to_plain(L, Start, Stop)
-%% end,
-%% log_convert(Log, File, Converter).
-
-
%% --------------------------------------------------------------------
%% Internal functions
%% --------------------------------------------------------------------
-
%% -- log_convert ---
log_convert(#snmp_log{id = Log}, File, Converter) ->
@@ -431,6 +439,26 @@ log_convert(Log, File, Converter) ->
do_log_convert(Log, File, Converter).
do_log_convert(Log, File, Converter) ->
+ %% ?vtrace("do_log_converter -> entry with"
+ %% "~n Log: ~p"
+ %% "~n File: ~p"
+ %% "~n disk_log:info(Log): ~p", [Log, File, disk_log:info(Log)]),
+ {Pid, Ref} =
+ erlang:spawn_monitor(
+ fun() ->
+ Result = do_log_convert2(Log, File, Converter),
+ exit(Result)
+ end),
+ receive
+ {'DOWN', Ref, process, Pid, Result} ->
+ %% ?vtrace("do_log_converter -> received result"
+ %% "~n Result: ~p"
+ %% "~n disk_log:info(Log): ~p",
+ %% [Result, disk_log:info(Log)]),
+ Result
+ end.
+
+do_log_convert2(Log, File, Converter) ->
%% First check if the caller process has already opened the
%% log, because if we close an already open log we will cause
%% a runtime error.
@@ -439,29 +467,18 @@ do_log_convert(Log, File, Converter) ->
Converter(Log);
false ->
%% Not yet member of the ruling party, apply for membership...
- %% If a log is opened as read_write it is not possible to
- %% open it as read_only. So, to get around this we open
- %% it under a different name...
- Log2 = convert_name(Log),
- case log_open(Log2, File) of
+ case log_open(Log, File) of
{ok, _} ->
- Res = Converter(Log2),
- disk_log:close(Log2),
+ Res = Converter(Log),
+ disk_log:close(Log),
Res;
{error, {name_already_open, _}} ->
- Converter(Log2);
+ Converter(Log);
{error, Reason} ->
{error, {Log, Reason}}
end
end.
-convert_name(Name) when is_list(Name) ->
- Name ++ "_tmp";
-convert_name(Name) when is_atom(Name) ->
- list_to_atom(atom_to_list(Name) ++ "_tmp");
-convert_name(Name) ->
- lists:flatten(io_lib:format("~w_tmp", [Name])).
-
%% -- do_log_to_text ---
@@ -705,21 +722,21 @@ tsf_ge(_Local,Universal,{universal_time,DateTime}) ->
tsf_ge(Local,_Universal,DateTime) ->
tsf_ge(Local,DateTime).
-tsf_ge(TimeStamp,DateTime) ->
+tsf_ge(TimeStamp, DateTime) ->
T1 = calendar:datetime_to_gregorian_seconds(TimeStamp),
T2 = calendar:datetime_to_gregorian_seconds(DateTime),
T1 >= T2.
-tsf_le(_Local,_Universal,null) ->
+tsf_le(_Local, _Universal, null) ->
true;
-tsf_le(Local,_Universal,{local_time,DateTime}) ->
- tsf_le(Local,DateTime);
-tsf_le(_Local,Universal,{universal_time,DateTime}) ->
- tsf_le(Universal,DateTime);
-tsf_le(Local,_Universal,DateTime) ->
+tsf_le(Local, _Universal, {local_time, DateTime}) ->
+ tsf_le(Local, DateTime);
+tsf_le(_Local, Universal, {universal_time, DateTime}) ->
+ tsf_le(Universal, DateTime);
+tsf_le(Local, _Universal, DateTime) ->
tsf_le(Local,DateTime).
-tsf_le(TimeStamp,DateTime) ->
+tsf_le(TimeStamp, DateTime) ->
T1 = calendar:datetime_to_gregorian_seconds(TimeStamp),
T2 = calendar:datetime_to_gregorian_seconds(DateTime),
T1 =< T2.
@@ -864,11 +881,8 @@ do_std_log_open(Name, File, Size, Repair, Notify) ->
log_open(Name, File) ->
- Opts = [{name, Name},
- {file, File},
- {type, ?LOG_TYPE},
- {format, ?LOG_FORMAT},
- {mode, read_only}],
+ Opts = [{name, Name},
+ {file, File}],
case disk_log:open(Opts) of
{error, {badarg, size}} ->
{error, no_such_log};
diff --git a/lib/snmp/src/misc/snmp_verbosity.erl b/lib/snmp/src/misc/snmp_verbosity.erl
index 85037ba2ae..f2f85ebf79 100644
--- a/lib/snmp/src/misc/snmp_verbosity.erl
+++ b/lib/snmp/src/misc/snmp_verbosity.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2000-2009. All Rights Reserved.
+%% Copyright Ericsson AB 2000-2012. All Rights Reserved.
%%
%% 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
@@ -144,6 +144,8 @@ image_of_sname(mse) -> "M-SERVER";
image_of_sname(msew) -> io_lib:format("M-SERVER-worker(~p)", [self()]);
image_of_sname(mns) -> "M-NOTE-STORE";
image_of_sname(mnif) -> "M-NET-IF";
+image_of_sname(mnifl) -> "M-NET-IF-LOGGER";
+image_of_sname(mnifw) -> io_lib:format("M-NET-IF-worker(~p)", [self()]);
image_of_sname(mconf) -> "M-CONF";
image_of_sname(mgr) -> "MGR";
diff --git a/lib/snmp/test/exp/.gitignore b/lib/snmp/test/exp/.gitignore
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/lib/snmp/test/exp/.gitignore
diff --git a/lib/snmp/test/snmp_agent_bl_test.erl b/lib/snmp/test/exp/snmp_agent_bl_test.erl
index b17489a755..b17489a755 100644
--- a/lib/snmp/test/snmp_agent_bl_test.erl
+++ b/lib/snmp/test/exp/snmp_agent_bl_test.erl
diff --git a/lib/snmp/test/snmp_agent_ms_test.erl b/lib/snmp/test/exp/snmp_agent_ms_test.erl
index 1f34f1c8d1..1f34f1c8d1 100644
--- a/lib/snmp/test/snmp_agent_ms_test.erl
+++ b/lib/snmp/test/exp/snmp_agent_ms_test.erl
diff --git a/lib/snmp/test/snmp_agent_mt_test.erl b/lib/snmp/test/exp/snmp_agent_mt_test.erl
index 4f125c0017..4f125c0017 100644
--- a/lib/snmp/test/snmp_agent_mt_test.erl
+++ b/lib/snmp/test/exp/snmp_agent_mt_test.erl
diff --git a/lib/snmp/test/snmp_agent_v1_test.erl b/lib/snmp/test/exp/snmp_agent_v1_test.erl
index 737bb25cc3..737bb25cc3 100644
--- a/lib/snmp/test/snmp_agent_v1_test.erl
+++ b/lib/snmp/test/exp/snmp_agent_v1_test.erl
diff --git a/lib/snmp/test/snmp_agent_v2_test.erl b/lib/snmp/test/exp/snmp_agent_v2_test.erl
index dc94c18ad9..dc94c18ad9 100644
--- a/lib/snmp/test/snmp_agent_v2_test.erl
+++ b/lib/snmp/test/exp/snmp_agent_v2_test.erl
diff --git a/lib/snmp/test/snmp_agent_v3_test.erl b/lib/snmp/test/exp/snmp_agent_v3_test.erl
index 266be72878..266be72878 100644
--- a/lib/snmp/test/snmp_agent_v3_test.erl
+++ b/lib/snmp/test/exp/snmp_agent_v3_test.erl
diff --git a/lib/snmp/test/snmp_SUITE.erl b/lib/snmp/test/snmp_SUITE.erl
index b6d72da2fa..22b9c64588 100644
--- a/lib/snmp/test/snmp_SUITE.erl
+++ b/lib/snmp/test/snmp_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% 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
@@ -19,6 +19,8 @@
-module(snmp_SUITE).
+-include("snmp_test_lib.hrl").
+
-export([all/0,
suite/0,
groups/0,
@@ -39,6 +41,21 @@ end_per_testcase(_Case, Config) when is_list(Config) ->
Config.
+init_per_suite(Config) when is_list(Config) ->
+
+ ?DBG("init_per_suite -> entry with"
+ "~n Config: ~p", [Config]),
+
+ Config.
+
+end_per_suite(Config) when is_list(Config) ->
+
+ ?DBG("end_per_suite -> entry with"
+ "~n Config: ~p", [Config]),
+
+ Config.
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Top test case
@@ -53,7 +70,8 @@ all() ->
{group, manager}].
groups() ->
- [{app, [], [{group, app_test},
+ [
+ {app, [], [{group, app_test},
{group, appup_test}]},
{compiler, [], [{group, compiler_test}]},
{misc, [], [{group, conf_test},
@@ -66,6 +84,7 @@ groups() ->
{manager, [], [{group, manager_config_test},
{group, manager_user_test},
{group, manager_test}]},
+
{app_test, [], [{snmp_app_test, all}]},
{appup_test, [], [{snmp_appup_test, all}]},
{compiler_test, [], [{snmp_compiler_test, all}]},
@@ -78,17 +97,25 @@ groups() ->
{agent_test, [], [{snmp_agent_test, all}]},
{manager_config_test, [], [{snmp_manager_config_test, all}]},
{manager_user_test, [], [{snmp_manager_user_test, all}]},
- {manager_test, [], [{snmp_manager_test, all}]}].
+ {manager_test, [], [{snmp_manager_test, all}]}
+ ].
-init_per_suite(Config) ->
- Config.
-end_per_suite(_Config) ->
- ok.
+init_per_group(GroupName, Config0) ->
-init_per_group(_GroupName, Config) ->
- Config.
+ ?DBG("init_per_group -> entry with"
+ "~n GroupName: ~p"
+ "~n Config0: ~p", [GroupName, Config0]),
+
+ %% Group name is not really the suite name
+ %% (but it is a good enough approximation),
+ %% but it does not matter since we only need
+ %% it to be unique.
+ snmp_test_lib:init_suite_top_dir(GroupName, Config0).
+
end_per_group(_GroupName, Config) ->
- Config.
+ lists:keydelete(snmp_suite_top_dir, 1, Config).
+
+
diff --git a/lib/snmp/test/snmp_agent_test.erl b/lib/snmp/test/snmp_agent_test.erl
index e968bc65b1..b5acf7cd87 100644
--- a/lib/snmp/test/snmp_agent_test.erl
+++ b/lib/snmp/test/snmp_agent_test.erl
@@ -228,48 +228,79 @@ groups() ->
}
].
-init_per_group(all_tcs, Config) ->
- init_all(Config);
-init_per_group(otp_7157, Config) ->
- init_otp_7157(Config);
-init_per_group(otp_4394, Config) ->
- init_otp_4394(Config);
-init_per_group(v2_inform, Config) ->
- init_v2_inform(Config);
-init_per_group(multiple_reqs_2, Config) ->
- init_mul(Config);
-init_per_group(multiple_reqs, Config) ->
- init_mul(Config);
-init_per_group(test_multi_threaded, Config) ->
- init_mt(Config);
-init_per_group(test_v3, Config) ->
- init_v3(Config);
-init_per_group(test_v1_v2, Config) ->
- init_v1_v2(Config);
-init_per_group(test_v2, Config) ->
- init_v2(Config);
-init_per_group(test_v1, Config) ->
- init_v1(Config);
-init_per_group(misc, Config) ->
- init_misc(Config);
-init_per_group(mib_storage_varm_mnesia, Config) ->
- init_varm_mib_storage_mnesia(Config);
-init_per_group(mib_storage_varm_dets, Config) ->
- init_varm_mib_storage_dets(Config);
-init_per_group(mib_storage_size_check_mnesia, Config) ->
- init_size_check_msm(Config);
-init_per_group(mib_storage_size_check_dets, Config) ->
- init_size_check_msd(Config);
-init_per_group(mib_storage_size_check_ets, Config) ->
- init_size_check_mse(Config);
-init_per_group(mib_storage_mnesia, Config) ->
- init_mib_storage_mnesia(Config);
-init_per_group(mib_storage_dets, Config) ->
- init_mib_storage_dets(Config);
-init_per_group(mib_storage_ets, Config) ->
- init_mib_storage_ets(Config);
-init_per_group(_GroupName, Config) ->
- Config.
+
+init_per_suite(Config0) when is_list(Config0) ->
+
+ ?DBG("init_per_suite -> entry with"
+ "~n Config0: ~p", [Config0]),
+
+ Config1 = snmp_test_lib:init_suite_top_dir(?MODULE, Config0),
+ Config2 = snmp_test_lib:fix_data_dir(Config1),
+
+ %% Mib-dirs
+ MibDir = snmp_test_lib:lookup(data_dir, Config2),
+ StdMibDir = filename:join([code:priv_dir(snmp), "mibs"]),
+
+ Config3 = [{mib_dir, MibDir}, {std_mib_dir, StdMibDir} | Config2],
+
+ ?DBG("init_per_suite -> end with"
+ "~n Config3: ~p", [Config3]),
+
+ Config3.
+
+end_per_suite(Config) when is_list(Config) ->
+
+ ?DBG("end_per_suite -> entry with"
+ "~n Config: ~p", [Config]),
+
+ Config.
+
+
+init_per_group(all_tcs = GroupName, Config) ->
+ init_all(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(otp_7157 = GroupName, Config) ->
+ init_otp_7157(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(otp_4394 = GroupName, Config) ->
+ init_otp_4394(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(v2_inform = GroupName, Config) ->
+ init_v2_inform(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(multiple_reqs_2 = GroupName, Config) ->
+ init_mul(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(multiple_reqs = GroupName, Config) ->
+ init_mul(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(test_multi_threaded = GroupName, Config) ->
+ init_mt(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(test_v3 = GroupName, Config) ->
+ init_v3(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(test_v1_v2 = GroupName, Config) ->
+ init_v1_v2(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(test_v2 = GroupName, Config) ->
+ init_v2(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(test_v1 = GroupName, Config) ->
+ init_v1(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(misc = GroupName, Config) ->
+ init_misc(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(mib_storage_varm_mnesia = GroupName, Config) ->
+ init_varm_mib_storage_mnesia(snmp_test_lib:init_group_top_dir(GroupName,
+ Config));
+init_per_group(mib_storage_varm_dets = GroupName, Config) ->
+ init_varm_mib_storage_dets(snmp_test_lib:init_group_top_dir(GroupName,
+ Config));
+init_per_group(mib_storage_size_check_mnesia = GroupName, Config) ->
+ init_size_check_msm(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(mib_storage_size_check_dets = GroupName, Config) ->
+ init_size_check_msd(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(mib_storage_size_check_ets = GroupName, Config) ->
+ init_size_check_mse(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(mib_storage_mnesia = GroupName, Config) ->
+ init_mib_storage_mnesia(snmp_test_lib:init_group_top_dir(GroupName,
+ Config));
+init_per_group(mib_storage_dets = GroupName, Config) ->
+ init_mib_storage_dets(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(mib_storage_ets = GroupName, Config) ->
+ init_mib_storage_ets(snmp_test_lib:init_group_top_dir(GroupName, Config));
+init_per_group(GroupName, Config) ->
+ snmp_test_lib:init_group_top_dir(GroupName, Config).
end_per_group(all_tcs, Config) ->
finish_all(Config);
@@ -320,38 +351,36 @@ init_per_testcase(otp8395 = Case, Config) when is_list(Config) ->
?DBG("init_per_testcase -> entry with"
"~n Case: ~p"
"~n Config: ~p", [Case, Config]),
- Config2 = init_per_testcase2(Case, init_per_suite(Config)),
- otp8395({init, Config2});
+ otp8395({init, init_per_testcase2(Case, Config)});
init_per_testcase(otp9884 = Case, Config) when is_list(Config) ->
?DBG("init_per_testcase -> entry with"
"~n Case: ~p"
"~n Config: ~p", [Case, Config]),
- Config2 = init_per_testcase2(Case, init_per_suite(Config)),
- otp9884({init, Config2});
+ otp9884({init, init_per_testcase2(Case, Config)});
init_per_testcase(otp_7157_test = _Case, Config) when is_list(Config) ->
?DBG("init_per_testcase -> entry with"
"~n Case: ~p"
"~n Config: ~p", [_Case, Config]),
Dog = ?WD_START(?MINS(1)),
- [{watchdog, Dog}|Config];
+ [{watchdog, Dog} | Config ];
init_per_testcase(v2_inform_i = _Case, Config) when is_list(Config) ->
?DBG("init_per_testcase -> entry with"
"~n Case: ~p"
"~n Config: ~p", [_Case, Config]),
Dog = ?WD_START(?MINS(10)),
- [{watchdog, Dog}|Config];
+ [{watchdog, Dog} | Config ];
init_per_testcase(v3_inform_i = _Case, Config) when is_list(Config) ->
?DBG("init_per_testcase -> entry with"
"~n Case: ~p"
"~n Config: ~p", [_Case, Config]),
Dog = ?WD_START(?MINS(10)),
- [{watchdog, Dog}|Config];
+ [{watchdog, Dog} | Config ];
init_per_testcase(_Case, Config) when is_list(Config) ->
?DBG("init_per_testcase -> entry with"
"~n Case: ~p"
"~n Config: ~p", [_Case, Config]),
Dog = ?WD_START(?MINS(6)),
- [{watchdog, Dog}|Config].
+ [{watchdog, Dog}| Config ].
end_per_testcase(otp8395, Config) when is_list(Config) ->
otp8395({fin, Config});
@@ -366,65 +395,13 @@ end_per_testcase(_Case, Config) when is_list(Config) ->
Config.
-init_per_suite(Config) ->
- ?DBG("init_per_suite -> entry with"
- "~n Config: ~p", [Config]),
-
- %% Suite root dir for test suite
- PrivDir = ?config(priv_dir, Config),
-
- %% Create top-directory for this sub-suite
- SuiteTopDir = filename:join([PrivDir, ?MODULE]),
- case file:make_dir(SuiteTopDir) of
- ok ->
- ok;
- {error, eexist} ->
- %% This can happen since this is not really a
- %% suite-init function.
- ok;
- {error, Reason} ->
- ?FAIL({failed_creating_suite_top_dir, SuiteTopDir, Reason})
- end,
-
-
- %% --
- %% Fix config (data-dir is not correct):
- %%
-
- Config1 = fix_data_dir(Config),
- %% Config1 = Config,
-
- %% Mib-dirs
- MibDir = ?config(data_dir, Config1),
- StdMibDir = filename:join([code:priv_dir(snmp), "mibs"]),
-
- Config2 = [{suite_top_dir, SuiteTopDir},
- {mib_dir, MibDir},
- {std_mib_dir, StdMibDir} | Config1],
-
- ?DBG("init_per_suite -> done when"
- "~n Config2: ~p", [Config2]),
- Config2.
-
-%% end_per_suite(Config) ->
-end_per_suite(Config) ->
- Config.
-
-fix_data_dir(Config) ->
- DataDir0 = ?config(data_dir, Config),
- DataDir1 = filename:split(filename:absname(DataDir0)),
- [_|DataDir2] = lists:reverse(DataDir1),
- DataDir = filename:join(lists:reverse(DataDir2) ++ [?snmp_test_data]),
- Config1 = lists:keydelete(data_dir, 1, Config),
- [{data_dir, DataDir} | Config1].
+init_per_testcase2(Case, Config) ->
+ ?DBG("end_per_testcase2 -> entry with"
+ "~n Case: ~p"
+ "~n Config: ~p", [Case, Config]),
-init_per_testcase2(Case, Config) ->
- SuiteToDir = ?config(suite_top_dir, Config),
-
- %% Create top-directory for this test-case
- CaseTopDir = filename:join([SuiteToDir, Case]),
- ok = file:make_dir(CaseTopDir),
+ CaseTopDir = snmp_test_lib:init_testcase_top_dir(Case, Config),
%% Create agent top-dir(s)
AgentTopDir = filename:join([CaseTopDir, agent]),
@@ -623,19 +600,19 @@ mib_storage_mnesia_cases() ->
msm_mib_of].
mse_size_check_cases() ->
-[mse_size_check].
+ [mse_size_check].
msd_size_check_cases() ->
-[msd_size_check].
+ [msd_size_check].
msm_size_check_cases() ->
-[msm_size_check].
+ [msm_size_check].
varm_mib_storage_dets_cases() ->
-[msd_varm_mib_start].
+ [msd_varm_mib_start].
varm_mib_storage_mnesia_cases() ->
-[msm_varm_mib_start].
+ [msm_varm_mib_start].
init_mib_storage_ets(Config) when is_list(Config) ->
?LOG("init_mib_storage_ets -> entry", []),
@@ -655,17 +632,18 @@ init_mib_storage_mnesia(Config) when is_list(Config) ->
init_ms(Config, Opts) when is_list(Config) ->
?LOG("init_mib_storage_ets -> entry", []),
- ?line SaNode = ?GCONF(snmp_sa, Config),
+ ?line SaNode = ?GCONF(snmp_sa, Config),
?line create_tables(SaNode),
- ?line AgentDir = ?GCONF(agent_dir, Config),
- ?line MgrDir = ?GCONF(mgr_dir, Config),
- ?line Ip = ?GCONF(ip, Config),
- ?line config([v1], MgrDir, AgentDir, tuple_to_list(Ip), tuple_to_list(Ip)),
+ ?line AgentConfDir = ?GCONF(agent_conf_dir, Config),
+ ?line MgrDir = ?GCONF(mgr_dir, Config),
+ ?line Ip = ?GCONF(ip, Config),
+ ?line config([v1], MgrDir, AgentConfDir,
+ tuple_to_list(Ip), tuple_to_list(Ip)),
MasterAgentVerbosity = {snmp_master_agent_verbosity, trace},
MibsVerbosity = {snmp_mibserver_verbosity, trace},
SymStoreVerbosity = {snmp_symbolic_store_verbosity, trace},
- Opts1 = [MasterAgentVerbosity,MibsVerbosity,SymStoreVerbosity|Opts],
- [{vsn, v1} | start_v1_agent(Config,Opts1)].
+ Opts1 = [MasterAgentVerbosity, MibsVerbosity, SymStoreVerbosity | Opts],
+ [{vsn, v1} | start_v1_agent(Config, Opts1)].
init_size_check_mse(Config) when is_list(Config) ->
MibStorage = {snmp_mib_storage, ets},
@@ -1189,10 +1167,11 @@ v1_cases() ->
init_v1(Config) when is_list(Config) ->
?line SaNode = ?config(snmp_sa, Config),
?line create_tables(SaNode),
- ?line AgentDir = ?config(agent_dir, Config),
+ ?line AgentConfDir = ?config(agent_conf_dir, Config),
?line MgrDir = ?config(mgr_dir, Config),
?line Ip = ?config(ip, Config),
- ?line config([v1], MgrDir, AgentDir, tuple_to_list(Ip), tuple_to_list(Ip)),
+ ?line config([v1], MgrDir, AgentConfDir,
+ tuple_to_list(Ip), tuple_to_list(Ip)),
[{vsn, v1} | start_v1_agent(Config)].
finish_v1(Config) when is_list(Config) ->
@@ -1232,10 +1211,11 @@ v2_cases() ->
init_v2(Config) when is_list(Config) ->
SaNode = ?config(snmp_sa, Config),
create_tables(SaNode),
- AgentDir = ?config(agent_dir, Config),
+ AgentConfDir = ?config(agent_conf_dir, Config),
MgrDir = ?config(mgr_dir, Config),
Ip = ?config(ip, Config),
- config([v2], MgrDir, AgentDir, tuple_to_list(Ip), tuple_to_list(Ip)),
+ config([v2], MgrDir, AgentConfDir,
+ tuple_to_list(Ip), tuple_to_list(Ip)),
[{vsn, v2} | start_v2_agent(Config)].
finish_v2(Config) when is_list(Config) ->
@@ -1251,10 +1231,11 @@ v1_v2_cases() ->
init_v1_v2(Config) when is_list(Config) ->
SaNode = ?config(snmp_sa, Config),
create_tables(SaNode),
- AgentDir = ?config(agent_dir, Config),
+ AgentConfDir = ?config(agent_conf_dir, Config),
MgrDir = ?config(mgr_dir, Config),
Ip = ?config(ip, Config),
- config([v1,v2], MgrDir, AgentDir, tuple_to_list(Ip), tuple_to_list(Ip)),
+ config([v1,v2], MgrDir, AgentConfDir,
+ tuple_to_list(Ip), tuple_to_list(Ip)),
[{vsn, bilingual} | start_bilingual_agent(Config)].
finish_v1_v2(Config) when is_list(Config) ->
@@ -1315,10 +1296,10 @@ init_v3(Config) when is_list(Config) ->
end,
SaNode = ?config(snmp_sa, Config),
create_tables(SaNode),
- AgentDir = ?config(agent_dir, Config),
+ AgentConfDir = ?config(agent_conf_dir, Config),
MgrDir = ?config(mgr_dir, Config),
Ip = ?config(ip, Config),
- ?line ok = config([v3], MgrDir, AgentDir,
+ ?line ok = config([v3], MgrDir, AgentConfDir,
tuple_to_list(Ip), tuple_to_list(Ip)),
[{vsn, v3} | start_v3_agent(Config)].
@@ -1338,11 +1319,11 @@ mt_cases() ->
init_mt(Config) when is_list(Config) ->
SaNode = ?config(snmp_sa, Config),
create_tables(SaNode),
- AgentDir = ?config(agent_dir, Config),
+ AgentConfDir = ?config(agent_conf_dir, Config),
MgrDir = ?config(mgr_dir, Config),
Ip = ?config(ip, Config),
- ?line ok =
- config([v2], MgrDir, AgentDir, tuple_to_list(Ip), tuple_to_list(Ip)),
+ ?line ok = config([v2], MgrDir, AgentConfDir,
+ tuple_to_list(Ip), tuple_to_list(Ip)),
[{vsn, v2} | start_multi_threaded_agent(Config)].
finish_mt(Config) when is_list(Config) ->
@@ -1421,7 +1402,13 @@ simple(Config) when is_list(Config) ->
?P(simple),
init_case(Config),
- try_test(simple_standard_test).
+ try_test(simple_standard_test),
+
+ p("Display log"),
+ display_log(Config),
+
+ p("done"),
+ ok.
simple_2(X) -> ?P(simple_2), simple(X).
@@ -1601,7 +1588,7 @@ change_target_addr_config(Config) when is_list(Config) ->
try_test(ma_trap1, [MA]),
?LOG("change_target_addr_config -> set silence verbosity for local_db",[]),
- ?line snmpa:verbosity(local_db,silence),
+ ?line snmpa:verbosity(local_db, silence),
%% Start new dummy listener
?LOG("change_target_addr_config -> start dummy manager",[]),
@@ -1609,9 +1596,9 @@ change_target_addr_config(Config) when is_list(Config) ->
%% Reconfigure
?LOG("change_target_addr_config -> reconfigure",[]),
- AgentDir = ?config(agent_dir, Config),
- ?line rewrite_target_addr_conf(AgentDir, NewPort),
- ?line snmp_target_mib:reconfigure(AgentDir),
+ AgentConfDir = ?config(agent_conf_dir, Config),
+ ?line rewrite_target_addr_conf(AgentConfDir, NewPort),
+ ?line snmp_target_mib:reconfigure(AgentConfDir),
%% Send the trap again
?LOG("change_target_addr_config -> send trap again",[]),
@@ -1624,7 +1611,7 @@ change_target_addr_config(Config) when is_list(Config) ->
?line ok = dummy_manager_stop(Pid),
?LOG("change_target_addr_config -> reset target address config",[]),
- ?line reset_target_addr_conf(AgentDir),
+ ?line reset_target_addr_conf(AgentConfDir),
?LOG("change_target_addr_config -> unload TestTrap",[]),
?line unload_master("TestTrap").
@@ -2067,7 +2054,7 @@ v3_inform(_X) ->
{req, [], {conf, init_v3_inform, [v3_inform_i], finish_v3_inform}}.
init_v2_inform(Config) when is_list(Config) ->
- _Dir = ?config(agent_dir, Config),
+ _Dir = ?config(agent_conf_dir, Config),
%% snmp_internal_mib:configure(Dir),
Config.
@@ -2075,7 +2062,7 @@ init_v3_inform(X) ->
init_v2_inform(X).
finish_v2_inform(Config) when is_list(Config) ->
- _Dir = ?config(agent_dir, Config),
+ _Dir = ?config(agent_conf_dir, Config),
%% snmp_internal_mib:configure(Dir),
Config.
@@ -2377,9 +2364,9 @@ v3_md5_auth(Config) when is_list(Config) ->
?P1("Testing MD5 authentication...takes a few seconds..."),
- AgentDir = ?config(agent_dir, Config),
- ?line rewrite_target_params_conf(AgentDir, "authMD5", authNoPriv),
- ?line snmp_target_mib:reconfigure(AgentDir),
+ AgentConfDir = ?config(agent_conf_dir, Config),
+ ?line rewrite_target_params_conf(AgentConfDir, "authMD5", authNoPriv),
+ ?line snmp_target_mib:reconfigure(AgentConfDir),
MA = whereis(snmp_master_agent),
@@ -2388,14 +2375,14 @@ v3_md5_auth(Config) when is_list(Config) ->
?line load_master("TestTrapv2"),
try_test(v3_sync, [[{v2_proc, []},
- {ma_v2_trap1, [MA]},
- {v3_inform_sync, [MA]}]],
- [{sec_level, authNoPriv}, {user, "authMD5"}]),
+ {ma_v2_trap1, [MA]},
+ {v3_inform_sync, [MA]}]],
+ [{sec_level, authNoPriv}, {user, "authMD5"}]),
?line unload_master("TestTrapv2"),
?line unload_master("TestTrap"),
?line unload_master("Test2"),
- ?line reset_target_params_conf(AgentDir).
+ ?line reset_target_params_conf(AgentConfDir).
v3_sha_auth(suite) -> [];
v3_sha_auth(Config) when is_list(Config) ->
@@ -2404,9 +2391,9 @@ v3_sha_auth(Config) when is_list(Config) ->
?P1("Testing SHA authentication...takes a few seconds..."),
- AgentDir = ?config(agent_dir, Config),
- ?line rewrite_target_params_conf(AgentDir, "authSHA", authNoPriv),
- ?line snmp_target_mib:reconfigure(AgentDir),
+ AgentConfDir = ?config(agent_conf_dir, Config),
+ ?line rewrite_target_params_conf(AgentConfDir, "authSHA", authNoPriv),
+ ?line snmp_target_mib:reconfigure(AgentConfDir),
MA = whereis(snmp_master_agent),
@@ -2415,14 +2402,14 @@ v3_sha_auth(Config) when is_list(Config) ->
?line load_master("TestTrapv2"),
try_test(v3_sync, [[{v2_proc, []},
- {ma_v2_trap1, [MA]},
- {v3_inform_sync, [MA]}]],
- [{sec_level, authNoPriv}, {user, "authSHA"}]),
+ {ma_v2_trap1, [MA]},
+ {v3_inform_sync, [MA]}]],
+ [{sec_level, authNoPriv}, {user, "authSHA"}]),
?line unload_master("TestTrapv2"),
?line unload_master("TestTrap"),
?line unload_master("Test2"),
- ?line reset_target_params_conf(AgentDir).
+ ?line reset_target_params_conf(AgentConfDir).
v3_des_priv(suite) -> [];
v3_des_priv(Config) when is_list(Config) ->
@@ -2431,9 +2418,9 @@ v3_des_priv(Config) when is_list(Config) ->
?P1("Testing DES encryption...takes a few seconds..."),
- AgentDir = ?config(agent_dir, Config),
- ?line rewrite_target_params_conf(AgentDir, "privDES", authPriv),
- ?line snmp_target_mib:reconfigure(AgentDir),
+ AgentConfDir = ?config(agent_conf_dir, Config),
+ ?line rewrite_target_params_conf(AgentConfDir, "privDES", authPriv),
+ ?line snmp_target_mib:reconfigure(AgentConfDir),
MA = whereis(snmp_master_agent),
@@ -2444,14 +2431,14 @@ v3_des_priv(Config) when is_list(Config) ->
?line load_master("TestTrapv2"),
try_test(v3_sync, [[{v2_proc, []},
- {ma_v2_trap1, [MA]},
- {v3_inform_sync, [MA]}]],
- [{sec_level, authPriv}, {user, "privDES"}]),
+ {ma_v2_trap1, [MA]},
+ {v3_inform_sync, [MA]}]],
+ [{sec_level, authPriv}, {user, "privDES"}]),
?line unload_master("TestTrapv2"),
?line unload_master("TestTrap"),
?line unload_master("Test2"),
- ?line reset_target_params_conf(AgentDir).
+ ?line reset_target_params_conf(AgentConfDir).
%% -define(usmStatsNotInTimeWindows_instance, [1,3,6,1,6,3,15,1,1,2,0]).
@@ -4795,7 +4782,7 @@ snmp_user_based_sm_mib_3(Config) when is_list(Config) ->
?P(snmp_user_based_sm_mib_3),
init_case(Config),
- _AgentDir = ?config(agent_dir, Config),
+ _AgentDir = ?config(agent_conf_dir, Config),
?line load_master_std("SNMP-USER-BASED-SM-MIB"),
%% The newUser used here already has VACM access.
@@ -5727,28 +5714,28 @@ otp_3725_test(MaNode) ->
init_otp_4394(Config) when is_list(Config) ->
?DBG("init_otp_4394 -> entry with"
"~n Config: ~p", [Config]),
- ?line AgentDir = ?config(agent_dir, Config),
- ?line MgrDir = ?config(mgr_dir, Config),
- ?line Ip = ?config(ip, Config),
- ?line otp_4394_config(AgentDir, MgrDir, Ip),
+ ?line AgentConfDir = ?config(agent_conf_dir, Config),
+ ?line MgrDir = ?config(mgr_dir, Config),
+ ?line Ip = ?config(ip, Config),
+ ?line otp_4394_config(AgentConfDir, MgrDir, Ip),
MasterAgentVerbosity = {master_agent_verbosity, trace},
NetIfVerbosity = {net_if_verbosity, trace},
- Opts = [MasterAgentVerbosity,NetIfVerbosity],
- [{vsn, v1} | start_v1_agent(Config,Opts)].
+ Opts = [MasterAgentVerbosity, NetIfVerbosity],
+ [{vsn, v1} | start_v1_agent(Config, Opts)].
-otp_4394_config(AgentDir, MgrDir, Ip0) ->
+otp_4394_config(AgentConfDir, MgrDir, Ip0) ->
?DBG("otp_4394_config -> entry with"
- "~n AgentDir: ~p"
- "~n MgrDir: ~p"
- "~n Ip0: ~p", [AgentDir, MgrDir, Ip0]),
+ "~n AgentConfDir: ~p"
+ "~n MgrDir: ~p"
+ "~n Ip0: ~p", [AgentConfDir, MgrDir, Ip0]),
Vsn = [v1],
Ip = tuple_to_list(Ip0),
- ?line snmp_config:write_agent_snmp_files(AgentDir, Vsn, Ip,
+ ?line snmp_config:write_agent_snmp_files(AgentConfDir, Vsn, Ip,
?TRAP_UDP, Ip, 4000,
"OTP-4394 test"),
- ?line case update_usm(Vsn, AgentDir) of
+ ?line case update_usm(Vsn, AgentConfDir) of
true ->
- ?line copy_file(filename:join(AgentDir, "usm.conf"),
+ ?line copy_file(filename:join(AgentConfDir, "usm.conf"),
filename:join(MgrDir, "usm.conf")),
?line update_usm_mgr(Vsn, MgrDir);
false ->
@@ -5756,8 +5743,8 @@ otp_4394_config(AgentDir, MgrDir, Ip0) ->
end,
C1 = {"a", "all-rights", "initial", "", "pc"},
C2 = {"c", "secret", "secret_name", "", "secret_tag"},
- ?line write_community_conf(AgentDir, [C1, C2]),
- ?line update_vacm(Vsn, AgentDir),
+ ?line write_community_conf(AgentConfDir, [C1, C2]),
+ ?line update_vacm(Vsn, AgentConfDir),
Ta1 = {"shelob v1",
[134,138,177,177], 5000, 1500, 3, %% Anv�nd Ip och modda
"pc1",
@@ -5771,9 +5758,9 @@ otp_4394_config(AgentDir, MgrDir, Ip0) ->
"target_v1", "",
%% [255,255,255,255,0,0],
[], 2048},
- ?line write_target_addr_conf(AgentDir, [Ta1, Ta2]),
- ?line write_target_params_conf(AgentDir, Vsn),
- ?line write_notify_conf(AgentDir),
+ ?line write_target_addr_conf(AgentConfDir, [Ta1, Ta2]),
+ ?line write_target_params_conf(AgentConfDir, Vsn),
+ ?line write_notify_conf(AgentConfDir),
ok.
@@ -5826,10 +5813,11 @@ init_otp_7157(Config) when is_list(Config) ->
?DBG("init_otp_7157 -> entry with"
"~n Config: ~p", [Config]),
- ?line AgentDir = ?config(agent_dir, Config),
+ ?line AgentConfDir = ?config(agent_conf_dir, Config),
?line MgrDir = ?config(mgr_dir, Config),
?line Ip = ?config(ip, Config),
- ?line config([v2], MgrDir, AgentDir, tuple_to_list(Ip), tuple_to_list(Ip)),
+ ?line config([v2], MgrDir, AgentConfDir,
+ tuple_to_list(Ip), tuple_to_list(Ip)),
MasterAgentVerbosity = {master_agent_verbosity, trace},
NetIfVerbosity = {net_if_verbosity, trace},
Opts = [MasterAgentVerbosity, NetIfVerbosity],
@@ -6562,8 +6550,8 @@ write_community_conf(Dir, Conf) ->
write_target_addr_conf(Dir, Conf) ->
snmp_agent_test_lib:write_target_addr_conf(Dir, Conf).
-write_target_addr_conf(Dir, ManagerIp, UDP, Vsns) ->
- snmp_agent_test_lib:write_target_addr_conf(Dir, ManagerIp, UDP, Vsns).
+%% write_target_addr_conf(Dir, ManagerIp, UDP, Vsns) ->
+%% snmp_agent_test_lib:write_target_addr_conf(Dir, ManagerIp, UDP, Vsns).
rewrite_target_addr_conf(Dir, NewPort) ->
snmp_agent_test_lib:rewrite_target_addr_conf(Dir, NewPort).
@@ -6596,9 +6584,42 @@ copy_file(From, To) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+display_log(Config) ->
+ case lists:keysearch(agent_log_dir, 1, Config) of
+ {value, {_, Dir}} ->
+ case lists:keysearch(snmp_master, 1, Config) of
+ {value, {_, Node}} ->
+ LogDir = Dir,
+ Mibs = [],
+ OutFile = filename:join(LogDir, "snmpa_log.txt"),
+ p("~n"
+ "========================="
+ " < Audit Trail Log > "
+ "========================="
+ "~n"),
+ rcall(Node, snmpa, log_to_txt, [LogDir, Mibs, OutFile]),
+ rcall(Node, snmpa, log_to_io, [LogDir, Mibs]),
+ p("~n"
+ "========================="
+ " < / Audit Trail Log > "
+ "========================="
+ "~n", []);
+ false ->
+ p("display_log -> no agent node found"),
+ ok
+ end;
+ false ->
+ p("display_log -> no agent log dir found: "
+ "~n ~p", [Config]),
+ ok
+ end.
+
+
+%% ------
+
display_memory_usage() ->
Info = snmpa:info(snmp_master_agent),
- AMU = display_agent_memory_uasge(Info),
+ AMU = display_agent_memory_usage(Info),
NIMU = display_net_if_memory_usage(Info),
NSMU = display_note_store_memory_usage(Info),
SSMU = display_symbolic_store_memory_usage(Info),
@@ -6608,7 +6629,7 @@ display_memory_usage() ->
AMU ++ NIMU ++ NSMU ++ SSMU ++ LDBMU ++ MSMU, []),
ok.
-display_agent_memory_uasge(Info) ->
+display_agent_memory_usage(Info) ->
AgentInfo = lists_key1search(agent, Info),
ProcMem =
lists_key1search([process_memory,master_agent], AgentInfo),
@@ -6717,3 +6738,27 @@ lists_key1search(Key, List) when is_atom(Key) ->
regs() ->
lists:sort(registered()).
+
+%% ------
+
+rcall(Node, Mod, Func, Args) ->
+ case rpc:call(Node, Mod, Func, Args) of
+ {badrpc, nodedown} ->
+ ?FAIL({rpc_failure, Node});
+ Else ->
+ Else
+ end.
+
+
+%% ------
+
+p(F) ->
+ p(F, []).
+
+p(F, A) ->
+ io:format("*** [~s] ***"
+ "~n" ++ F ++ "~n", [formated_timestamp()|A]).
+
+formated_timestamp() ->
+ snmp_test_lib:formated_timestamp().
+
diff --git a/lib/snmp/test/snmp_agent_test_lib.erl b/lib/snmp/test/snmp_agent_test_lib.erl
index 084b3ee8da..cd9a87eab8 100644
--- a/lib/snmp/test/snmp_agent_test_lib.erl
+++ b/lib/snmp/test/snmp_agent_test_lib.erl
@@ -119,20 +119,10 @@
%%% didn't undo (since it failed).
%%%-----------------------------------------------------------------
-init_all(Config0) when is_list(Config0) ->
- ?LOG("init_all -> entry with"
- "~n Config0: ~p",[Config0]),
-
- %% --
- %% Fix config:
- %%
+init_all(Config) when is_list(Config) ->
- DataDir0 = ?config(data_dir, Config0),
- DataDir1 = filename:split(filename:absname(DataDir0)),
- [_|DataDir2] = lists:reverse(DataDir1),
- DataDir3 = filename:join(lists:reverse(DataDir2) ++ [?snmp_test_data]),
- Config1 = lists:keydelete(data_dir, 1, Config0),
- Config = [{data_dir, DataDir3 ++ "/"}|Config1],
+ ?LOG("init_all -> entry with"
+ "~n Config: ~p",[Config]),
%% --
%% Start nodes
@@ -143,34 +133,43 @@ init_all(Config0) when is_list(Config0) ->
%% --
- %% Create necessary files
+ %% Create necessary files ( and dirs )
%%
- PrivDir = ?config(priv_dir, Config),
- ?DBG("init_all -> PrivDir ~p", [PrivDir]),
+ SuiteTopDir = ?config(snmp_suite_top_dir, Config),
+ ?DBG("init_all -> SuiteTopDir ~p", [SuiteTopDir]),
- TopDir = filename:join(PrivDir, snmp_agent_test),
- case file:make_dir(TopDir) of
- ok ->
- ok;
- {error, eexist} ->
- ok;
- Error ->
- ?FAIL({failed_creating_subsuite_top_dir, Error})
- end,
+ AgentDir = filename:join(SuiteTopDir, "agent/"),
+ ?line ok = file:make_dir(AgentDir),
+ ?DBG("init_all -> AgentDir ~p", [AgentDir]),
- DataDir = ?config(data_dir, Config),
- ?DBG("init_all -> DataDir ~p", [DataDir]),
+ AgentDbDir = filename:join(AgentDir, "db/"),
+ ?line ok = file:make_dir(AgentDbDir),
+ ?DBG("init_all -> AgentDbDir ~p", [AgentDbDir]),
- ?line ok = file:make_dir(MgrDir = filename:join(TopDir, "mgr_dir/")),
- ?DBG("init_all -> MgrDir ~p", [MgrDir]),
+ AgentLogDir = filename:join(AgentDir, "log/"),
+ ?line ok = file:make_dir(AgentLogDir),
+ ?DBG("init_all -> AgentLogDir ~p", [AgentLogDir]),
- ?line ok = file:make_dir(AgentDir = filename:join(TopDir, "agent_dir/")),
- ?DBG("init_all -> AgentDir ~p", [AgentDir]),
+ AgentConfDir = filename:join(AgentDir, "conf/"),
+ ?line ok = file:make_dir(AgentConfDir),
+ ?DBG("init_all -> AgentConfDir ~p", [AgentConfDir]),
- ?line ok = file:make_dir(SaDir = filename:join(TopDir, "sa_dir/")),
+ MgrDir = filename:join(SuiteTopDir, "mgr/"),
+ ?line ok = file:make_dir(MgrDir),
+ ?DBG("init_all -> MgrDir ~p", [MgrDir]),
+
+ SaDir = filename:join(SuiteTopDir, "sa/"),
+ ?line ok = file:make_dir(SaDir),
?DBG("init_all -> SaDir ~p", [SaDir]),
+ SaDbDir = filename:join(SaDir, "db/"),
+ ?line ok = file:make_dir(SaDbDir),
+ ?DBG("init_all -> SaDbDir ~p", [SaDbDir]),
+
+ %% MibDir = ?config(mib_dir, Config),
+ %% ?DBG("init_all -> MibDir ~p", [DataDir]),
+
%% --
%% Start and initiate mnesia
@@ -184,11 +183,11 @@ init_all(Config0) when is_list(Config0) ->
?DBG("init_all -> application mnesia: set_env dir",[]),
?line application_controller:set_env(mnesia, dir,
- filename:join(TopDir, "Mnesia1")),
+ filename:join(AgentDbDir, "Mnesia1")),
?DBG("init_all -> application mnesia: set_env dir on node ~p",[SaNode]),
- ?line rpc:call(SaNode, application_controller, set_env,
- [mnesia, dir, filename:join(TopDir, "Mnesia2")]),
+ ?line rpc:call(SaNode, application_controller, set_env,
+ [mnesia, dir, filename:join(SaDir, "Mnesia2")]),
?DBG("init_all -> create mnesia schema",[]),
?line ok = mnesia:create_schema([SaNode, node()]),
@@ -199,13 +198,18 @@ init_all(Config0) when is_list(Config0) ->
?DBG("init_all -> start application mnesia on ~p",[SaNode]),
?line ok = rpc:call(SaNode, application, start, [mnesia]),
Ip = ?LOCALHOST(),
- [{snmp_sa, SaNode},
- {snmp_mgr, MgrNode},
- {agent_dir, AgentDir ++ "/"},
- {mgr_dir, MgrDir ++ "/"},
- {sa_dir, SaDir ++ "/"},
- {mib_dir, DataDir},
- {ip, Ip} |
+ [{snmp_sa, SaNode},
+ {snmp_mgr, MgrNode},
+ {snmp_master, node()},
+ {agent_dir, AgentDir ++ "/"},
+ {agent_db_dir, AgentDbDir ++ "/"},
+ {agent_log_dir, AgentLogDir ++ "/"},
+ {agent_conf_dir, AgentConfDir ++ "/"},
+ {sa_dir, SaDir ++ "/"},
+ {sa_db_dir, SaDbDir ++ "/"},
+ {mgr_dir, MgrDir ++ "/"},
+ %% {mib_dir, DataDir},
+ {ip, Ip} |
Config].
@@ -220,11 +224,14 @@ finish_all(Config) when is_list(Config) ->
%% --- This one *must* be run first in each case ---
init_case(Config) when is_list(Config) ->
+
?DBG("init_case -> entry with"
- "~n Config: ~p", [Config]),
- SaNode = ?config(snmp_sa, Config),
- MgrNode = ?config(snmp_mgr, Config),
- MasterNode = node(),
+ "~n Config: ~p", [Config]),
+
+ SaNode = ?config(snmp_sa, Config),
+ MgrNode = ?config(snmp_mgr, Config),
+ MasterNode = ?config(snmp_master, Config),
+ %% MasterNode = node(),
SaHost = ?HOSTNAME(SaNode),
MgrHost = ?HOSTNAME(MgrNode),
@@ -411,7 +418,8 @@ start_v3_agent(Config, Opts) when is_list(Config) andalso is_list(Opts) ->
start_bilingual_agent(Config) when is_list(Config) ->
start_agent(Config, [v1,v2]).
-start_bilingual_agent(Config, Opts) when is_list(Config) andalso is_list(Opts) ->
+start_bilingual_agent(Config, Opts)
+ when is_list(Config) andalso is_list(Opts) ->
start_agent(Config, [v1,v2], Opts).
start_mt_agent(Config) when is_list(Config) ->
@@ -423,57 +431,33 @@ start_mt_agent(Config, Opts) when is_list(Config) andalso is_list(Opts) ->
start_agent(Config, Vsns) ->
start_agent(Config, Vsns, []).
start_agent(Config, Vsns, Opts) ->
+
?LOG("start_agent -> entry (~p) with"
"~n Config: ~p"
"~n Vsns: ~p"
"~n Opts: ~p", [node(), Config, Vsns, Opts]),
- ?line AgentDir = ?config(agent_dir, Config),
- ?line SaNode = ?config(snmp_sa, Config),
-
-%% AgentConfig =
-%% [{agent_type, master},
-%% %% {multi_threaded, MultiT},
-%% %% {priority, Prio},
-%% %% {error_report_mod, ErrorReportMod},
-%% {versions, Vsns},
-%% {db_dir, AgentDir},
-%% %% {db_init_error, DbInitError},
-%% %% {set_mechanism, SetModule},
-%% %% {authentication_service, AuthModule},
-%% {audit_trail_log, [{type, read_write},
-%% {dir, AgentDir},
-%% {size, {10240, 10}},
-%% {repair, true}]},
-%% {config, [{verbosity, info},
-%% {dir, AgentDir},
-%% {force_load, false}]},
-%% {mibs, Mibs},
-%% %% {mib_storage, MibStorage},
-%% {local_db, []},
-%% {mib_server, []},
-%% {symbolic_store, []},
-%% {note_store, []},
-%% {net_if, []},
-%% %% {supervisor, SupOpts}
-%% ],
-
+ ?line AgentLogDir = ?config(agent_log_dir, Config),
+ ?line AgentConfDir = ?config(agent_conf_dir, Config),
+ ?line AgentDbDir = ?config(agent_db_dir, Config),
+ ?line SaNode = ?config(snmp_sa, Config),
+
app_env_init(vsn_init(Vsns) ++
- [{audit_trail_log, read_write_log},
- {audit_trail_log_dir, AgentDir},
- {audit_trail_log_size, {10240, 10}},
- {force_config_reload, false},
- {snmp_agent_type, master},
- {snmp_config_dir, AgentDir},
- {snmp_db_dir, AgentDir},
- {snmp_local_db_auto_repair, true},
- {snmp_local_db_verbosity, log},
- {snmp_master_agent_verbosity, trace},
- {snmp_supervisor_verbosity, trace},
- {snmp_mibserver_verbosity, log},
+ [{audit_trail_log, read_write_log},
+ {audit_trail_log_dir, AgentLogDir},
+ {audit_trail_log_size, {10240, 10}},
+ {force_config_reload, false},
+ {snmp_agent_type, master},
+ {snmp_config_dir, AgentConfDir},
+ {snmp_db_dir, AgentDbDir},
+ {snmp_local_db_auto_repair, true},
+ {snmp_local_db_verbosity, log},
+ {snmp_master_agent_verbosity, trace},
+ {snmp_supervisor_verbosity, trace},
+ {snmp_mibserver_verbosity, log},
{snmp_symbolic_store_verbosity, log},
- {snmp_note_store_verbosity, log},
- {snmp_net_if_verbosity, trace}],
+ {snmp_note_store_verbosity, log},
+ {snmp_net_if_verbosity, trace}],
Opts),
@@ -1237,30 +1221,44 @@ stop_node(Node) ->
%%% Configuration
%%%-----------------------------------------------------------------
-config(Vsns, MgrDir, AgentDir, MIp, AIp) ->
- ?line snmp_config:write_agent_snmp_files(AgentDir, Vsns, MIp,
- ?TRAP_UDP, AIp, 4000,
+config(Vsns, MgrDir, AgentConfDir, MIp, AIp) ->
+ ?LOG("config -> entry with"
+ "~n Vsns: ~p"
+ "~n MgrDir: ~p"
+ "~n AgentConfDir: ~p"
+ "~n MIp: ~p"
+ "~n AIp: ~p",
+ [Vsns, MgrDir, AgentConfDir, MIp, AIp]),
+ ?line snmp_config:write_agent_snmp_files(AgentConfDir, Vsns,
+ MIp, ?TRAP_UDP, AIp, 4000,
"test"),
- ?line case update_usm(Vsns, AgentDir) of
+ ?line case update_usm(Vsns, AgentConfDir) of
true ->
- ?line copy_file(filename:join(AgentDir, "usm.conf"),
+ ?line copy_file(filename:join(AgentConfDir, "usm.conf"),
filename:join(MgrDir, "usm.conf")),
?line update_usm_mgr(Vsns, MgrDir);
false ->
?line ok
end,
- ?line update_community(Vsns, AgentDir),
- ?line update_vacm(Vsns, AgentDir),
- ?line write_target_addr_conf(AgentDir, MIp, ?TRAP_UDP, Vsns),
- ?line write_target_params_conf(AgentDir, Vsns),
- ?line write_notify_conf(AgentDir),
+ ?line update_community(Vsns, AgentConfDir),
+ ?line update_vacm(Vsns, AgentConfDir),
+ ?line write_target_addr_conf(AgentConfDir, MIp, ?TRAP_UDP, Vsns),
+ ?line write_target_params_conf(AgentConfDir, Vsns),
+ ?line write_notify_conf(AgentConfDir),
ok.
delete_files(Config) ->
- Dir = ?config(agent_dir, Config),
- {ok, List} = file:list_dir(Dir),
+ AgentDir = ?config(agent_dir, Config),
+ delete_files(AgentDir, [db, conf]).
+
+delete_files(_AgentFiles, []) ->
+ ok;
+delete_files(AgentDir, [DirName|DirNames]) ->
+ Dir = filename:join(AgentDir, DirName),
+ {ok, Files} = file:list_dir(Dir),
lists:foreach(fun(FName) -> file:delete(filename:join(Dir, FName)) end,
- List).
+ Files),
+ delete_files(AgentDir, DirNames).
update_usm(Vsns, Dir) ->
case lists:member(v3, Vsns) of
@@ -1418,8 +1416,8 @@ rewrite_target_addr_conf2(_NewPort,O) ->
O.
reset_target_addr_conf(Dir) ->
- ?line ok = file:rename(filename:join(Dir,"target_addr.old"),
- filename:join(Dir,"target_addr.conf")).
+ ?line ok = file:rename(filename:join(Dir, "target_addr.old"),
+ filename:join(Dir, "target_addr.conf")).
write_target_params_conf(Dir, Vsns) ->
F = fun(v1) -> {"target_v1", v1, v1, "all-rights", noAuthNoPriv};
@@ -1458,7 +1456,6 @@ copy_file(From, To) ->
ok = file:write_file(To, Bin).
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
display_memory_usage() ->
diff --git a/lib/snmp/test/snmp_app_test.erl b/lib/snmp/test/snmp_app_test.erl
index bc62c8d530..825a232c99 100644
--- a/lib/snmp/test/snmp_app_test.erl
+++ b/lib/snmp/test/snmp_app_test.erl
@@ -23,8 +23,8 @@
-module(snmp_app_test).
-export([
- all/0,groups/0,init_per_group/2,end_per_group/2, init_per_suite/1,
- end_per_suite/1,
+ all/0, groups/0, init_per_group/2, end_per_group/2,
+ init_per_suite/1, end_per_suite/1,
init_per_testcase/2, end_per_testcase/2,
fields/1,
@@ -52,33 +52,47 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
all() ->
-Cases = [fields, modules, exportall, app_depend,
- undef_funcs, {group, start_and_stop}],
- Cases.
+ Cases =
+ [
+ fields,
+ modules,
+ exportall,
+ app_depend,
+ undef_funcs,
+ {group, start_and_stop}
+ ],
+ Cases.
groups() ->
[{start_and_stop, [],
- [start_and_stop_empty, start_and_stop_with_agent,
- start_and_stop_with_manager,
- start_and_stop_with_agent_and_manager,
- start_epmty_and_then_agent_and_manager_and_stop,
- start_with_agent_and_then_manager_and_stop,
- start_with_manager_and_then_agent_and_stop]}].
+ [start_and_stop_empty,
+ start_and_stop_with_agent,
+ start_and_stop_with_manager,
+ start_and_stop_with_agent_and_manager,
+ start_epmty_and_then_agent_and_manager_and_stop,
+ start_with_agent_and_then_manager_and_stop,
+ start_with_manager_and_then_agent_and_stop]}].
init_per_group(_GroupName, Config) ->
- Config.
+ Config.
end_per_group(_GroupName, Config) ->
- Config.
+ Config.
init_per_suite(Config) when is_list(Config) ->
?DISPLAY_SUITE_INFO(),
+
+ %% Note that part of this stuff (the suite top dir creation)
+ %% may already be done (if we run the entire snmp suite).
+
PrivDir = ?config(priv_dir, Config),
TopDir = filename:join(PrivDir, app),
case file:make_dir(TopDir) of
ok ->
ok;
+ {error, eexist} ->
+ ok;
Error ->
fail({failed_creating_subsuite_top_dir, Error})
end,
diff --git a/lib/snmp/test/snmp_compiler_test.erl b/lib/snmp/test/snmp_compiler_test.erl
index 0a147130b0..f3a1e77322 100644
--- a/lib/snmp/test/snmp_compiler_test.erl
+++ b/lib/snmp/test/snmp_compiler_test.erl
@@ -40,6 +40,7 @@
all/0,
groups/0, init_per_group/2, end_per_group/2,
init_per_testcase/2, end_per_testcase/2,
+ init_per_suite/1, end_per_suite/1,
description/1,
oid_conflicts/1,
@@ -74,19 +75,41 @@
%% External functions
%%======================================================================
-init_per_testcase(_Case, Config) when is_list(Config) ->
- Dir = ?config(priv_dir, Config),
- DataDir = ?config(data_dir, Config),
- [_|RL] = lists:reverse(filename:split(DataDir)),
- MibDir = join(lists:reverse(["snmp_test_data"|RL])),
- CompDir = join(Dir, "comp_dir/"),
- ?line ok = file:make_dir(CompDir),
- [{comp_dir, CompDir}, {mib_dir, MibDir} | Config].
+init_per_suite(Config0) when is_list(Config0) ->
+
+ ?DBG("init_per_suite -> entry with"
+ "~n Config0: ~p", [Config0]),
+
+ Config1 = snmp_test_lib:init_suite_top_dir(?MODULE, Config0),
+ Config2 = snmp_test_lib:fix_data_dir(Config1),
+
+ %% Mib-dirs
+ %% data_dir is trashed by the test-server / common-test
+ %% so there is no point in fixing it...
+ MibDir = snmp_test_lib:lookup(data_dir, Config2),
+ StdMibDir = filename:join([code:priv_dir(snmp), "mibs"]),
+
+ [{mib_dir, MibDir}, {std_mib_dir, StdMibDir} | Config2].
+
+end_per_suite(Config) when is_list(Config) ->
+
+ ?DBG("end_per_suite -> entry with"
+ "~n Config: ~p", [Config]),
+
+ Config.
+
+
+init_per_testcase(Case, Config) when is_list(Config) ->
+
+ ?DBG("init_per_testcase -> entry with"
+ "~n Config: ~p", [Config]),
+
+ CaseTopDir = snmp_test_lib:init_testcase_top_dir(Case, Config),
+
+ [{case_top_dir, CaseTopDir} | Config].
end_per_testcase(_Case, Config) when is_list(Config) ->
- CompDir = ?config(comp_dir, Config),
- ?line ok = ?DEL_DIR(CompDir),
- lists:keydelete(comp_dir, 1, Config).
+ Config.
%%======================================================================
@@ -126,7 +149,7 @@ description(Config) when is_list(Config) ->
put(tname,desc),
p("starting with Config: ~p~n", [Config]),
- Dir = ?config(comp_dir, Config),
+ Dir = ?config(case_top_dir, Config),
Filename = join(Dir,"test"),
MibSrcName = Filename ++ ".mib",
MibBinName = Filename ++ ".bin",
@@ -161,7 +184,7 @@ oid_conflicts(Config) when is_list(Config) ->
put(tname,oid_conflicts),
p("starting with Config: ~p~n", [Config]),
- Dir = ?config(comp_dir, Config),
+ Dir = ?config(case_top_dir, Config),
Mib = join(Dir,"TESTv2.mib"),
?line ok = write_oid_conflict_mib(Mib),
?line {error,compilation_failed} =
@@ -278,7 +301,7 @@ warnings_as_errors(suite) ->
warnings_as_errors(Config) when is_list(Config) ->
put(tname,warnings_as_errors),
p("starting with Config: ~p~n", [Config]),
- Dir = ?config(comp_dir, Config),
+ Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
MibFile = join(MibDir, "OTP8574-MIB.mib"),
OutFile = join(Dir, "OTP8574-MIB.bin"),
@@ -303,7 +326,7 @@ otp_6150(Config) when is_list(Config) ->
put(tname,otp_6150),
p("starting with Config: ~p~n", [Config]),
- Dir = ?config(comp_dir, Config),
+ Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
MibFile = join(MibDir, "ERICSSON-TOP-MIB.mib"),
?line {ok, Mib} = snmpc:compile(MibFile, [{outdir, Dir}, {verbosity, trace}]),
@@ -319,7 +342,7 @@ otp_8574(Config) when is_list(Config) ->
put(tname,otp_8574),
p("starting with Config: ~p~n", [Config]),
- Dir = ?config(comp_dir, Config),
+ Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
MibFile = join(MibDir, "OTP8574-MIB.mib"),
@@ -352,7 +375,7 @@ otp_8595(Config) when is_list(Config) ->
put(tname,otp_8595),
p("starting with Config: ~p~n", [Config]),
- Dir = ?config(comp_dir, Config),
+ Dir = ?config(case_top_dir, Config),
MibDir = ?config(mib_dir, Config),
MibFile = join(MibDir, "OTP8595-MIB.mib"),
?line {ok, Mib} =
@@ -546,8 +569,8 @@ check_desc(Desc1, Desc2) ->
exit({'description not equal', Desc1, Desc2}).
-join(Comp) ->
- filename:join(Comp).
+%% join(Comp) ->
+%% filename:join(Comp).
join(A,B) ->
filename:join(A,B).
diff --git a/lib/snmp/test/snmp_log_test.erl b/lib/snmp/test/snmp_log_test.erl
index b692017407..8478825f59 100644
--- a/lib/snmp/test/snmp_log_test.erl
+++ b/lib/snmp/test/snmp_log_test.erl
@@ -42,7 +42,11 @@
-export([
init_per_testcase/2, end_per_testcase/2,
- all/0,groups/0,init_per_group/2,end_per_group/2,
+ all/0,
+ groups/0,
+ init_per_group/2,
+ end_per_group/2,
+
open_and_close/1,
open_write_and_close1/1,
@@ -109,16 +113,21 @@ end_per_testcase(_Case, Config) when is_list(Config) ->
%%======================================================================
%% ?SKIP(not_yet_implemented).
all() ->
-[open_and_close, {group, open_write_and_close},
- {group, log_to_io}, {group, log_to_txt}].
+ [
+ open_and_close,
+ {group, open_write_and_close},
+ {group, log_to_io},
+ {group, log_to_txt}].
groups() ->
- [{open_write_and_close, [],
- [open_write_and_close1, open_write_and_close2,
- open_write_and_close3, open_write_and_close4]},
- {log_to_io, [], [log_to_io1, log_to_io2]},
- {log_to_txt, [],
- [log_to_txt1, log_to_txt2, log_to_txt3]}].
+ [
+ {open_write_and_close, [],
+ [open_write_and_close1, open_write_and_close2,
+ open_write_and_close3, open_write_and_close4]},
+ {log_to_io, [], [log_to_io1, log_to_io2]},
+ {log_to_txt, [],
+ [log_to_txt1, log_to_txt2, log_to_txt3]}
+ ].
init_per_group(_GroupName, Config) ->
Config.
diff --git a/lib/snmp/test/snmp_manager_test.erl b/lib/snmp/test/snmp_manager_test.erl
index 75c9f7b277..c374a2f0a6 100644
--- a/lib/snmp/test/snmp_manager_test.erl
+++ b/lib/snmp/test/snmp_manager_test.erl
@@ -49,6 +49,8 @@
init_per_group/2, end_per_group/2,
init_per_testcase/2, end_per_testcase/2,
+ init_per_suite/1, end_per_suite/1,
+
simple_start_and_stop1/1,
simple_start_and_stop2/1,
@@ -146,36 +148,43 @@
%% External functions
%%======================================================================
+init_per_suite(Config0) when is_list(Config0) ->
+
+ ?DBG("init_per_suite -> entry with"
+ "~n Config0: ~p", [Config0]),
+
+ Config1 = snmp_test_lib:init_suite_top_dir(?MODULE, Config0),
+ Config2 = snmp_test_lib:fix_data_dir(Config1),
+
+ %% Mib-dirs
+ %% data_dir is trashed by the test-server / common-test
+ %% so there is no point in fixing it...
+ MibDir = snmp_test_lib:lookup(data_dir, Config2),
+ StdMibDir = filename:join([code:priv_dir(snmp), "mibs"]),
+
+ [{mib_dir, MibDir}, {std_mib_dir, StdMibDir} | Config2].
+
+end_per_suite(Config) when is_list(Config) ->
+
+ ?DBG("end_per_suite -> entry with"
+ "~n Config: ~p", [Config]),
+
+ Config.
+
+
init_per_testcase(Case, Config) when is_list(Config) ->
io:format(user, "~n~n*** INIT ~w:~w ***~n~n", [?MODULE,Case]),
init_per_testcase2(Case, Config).
init_per_testcase2(Case, Config) ->
- ?DBG("init [~w] Nodes [1]: ~p", [Case, erlang:nodes()]),
-
- %% Fix a correct data dir (points to the wrong location):
- DataDir0 = ?config(data_dir, Config),
- DataDir1 = filename:split(filename:absname(DataDir0)),
- [_|DataDir2] = lists:reverse(DataDir1),
- DataDir = filename:join(lists:reverse(DataDir2) ++ [?snmp_test_data]),
+ ?DBG("init_per_testcase2 -> ~p", [erlang:nodes()]),
- PrivDir = ?config(priv_dir, Config),
+ CaseTopDir = snmp_test_lib:init_testcase_top_dir(Case, Config),
- TopDir = filename:join(PrivDir, ?MODULE),
- case file:make_dir(TopDir) of
- ok ->
- ok;
- {error, eexist} ->
- ok;
- Error ->
- ?FAIL({failed_creating_subsuite_top_dir, Error})
- end,
-
- CaseTopDir = filename:join(TopDir, Case),
- ?line ok = file:make_dir(CaseTopDir),
-
%% -- Manager dirs --
- MgrTopDir = filename:join(CaseTopDir, "manager/"),
+ MgrTopDir = filename:join(CaseTopDir, "manager/"),
+ ?DBG("init_per_testcase2 -> try create manager top dir: ~n~p",
+ [MgrTopDir]),
?line ok = file:make_dir(MgrTopDir),
MgrConfDir = filename:join(MgrTopDir, "conf/"),
@@ -200,10 +209,9 @@ init_per_testcase2(Case, Config) ->
AgLogDir = filename:join(AgTopDir, "log/"),
?line ok = file:make_dir(AgLogDir),
- Conf = [{snmp_data_dir, DataDir},
- {watchdog, ?WD_START(?MINS(5))},
+ Conf = [{watchdog, ?WD_START(?MINS(5))},
{ip, ?LOCALHOST()},
- {top_dir, TopDir},
+ {case_top_dir, CaseTopDir},
{agent_dir, AgTopDir},
{agent_conf_dir, AgConfDir},
{agent_db_dir, AgDbDir},
@@ -388,9 +396,11 @@ all() ->
{group, user_tests},
{group, agent_tests},
{group, request_tests},
+ {group, request_tests_mt},
{group, event_tests},
+ {group, event_tests_mt},
discovery,
- {group, tickets}
+ {group, tickets}
].
groups() ->
@@ -431,6 +441,15 @@ groups() ->
{group, misc_request_tests}
]
},
+ {request_tests_mt, [],
+ [
+ {group, get_tests},
+ {group, get_next_tests},
+ {group, set_tests},
+ {group, bulk_tests},
+ {group, misc_request_tests}
+ ]
+ },
{get_tests, [],
[
simple_sync_get1,
@@ -477,18 +496,30 @@ groups() ->
misc_async2
]
},
- {event_tests, [],
- [
- trap1%% ,
- %% trap2,
- %% inform1,
- %% inform2,
- %% inform3,
- %% inform4,
- %% inform_swarm,
- %% report
- ]
- },
+ {event_tests, [],
+ [
+ trap1,
+ trap2,
+ inform1,
+ inform2,
+ inform3,
+ inform4,
+ inform_swarm,
+ report
+ ]
+ },
+ {event_tests_mt, [],
+ [
+ trap1,
+ trap2,
+ inform1,
+ inform2,
+ inform3,
+ inform4,
+ inform_swarm,
+ report
+ ]
+ },
{tickets, [],
[
{group, otp8015},
@@ -507,11 +538,21 @@ groups() ->
}
].
-init_per_group(_GroupName, Config) ->
- Config.
+init_per_group(request_tests_mt = GroupName, Config) ->
+ snmp_test_lib:init_group_top_dir(
+ GroupName,
+ [{manager_net_if_module, snmpm_net_if_mt} | Config]);
+init_per_group(event_tests_mt = GroupName, Config) ->
+ snmp_test_lib:init_group_top_dir(
+ GroupName,
+ [{manager_net_if_module, snmpm_net_if_mt} | Config]);
+init_per_group(GroupName, Config) ->
+ snmp_test_lib:init_group_top_dir(GroupName, Config).
+
end_per_group(_GroupName, Config) ->
- Config.
+ %% Do we really need to do this?
+ lists:keydelete(snmp_group_top_dir, 1, Config).
%%======================================================================
@@ -1571,6 +1612,11 @@ simple_sync_get1(Config) when is_list(Config) ->
?line ok = mgr_user_load_mib(Node, std_mib()),
Oids2 = [[sysObjectID, 0], [sysDescr, 0], [sysUpTime, 0]],
?line ok = do_simple_sync_get(Node, Addr, Port, Oids2),
+
+ p("Display log"),
+ display_log(Config),
+
+ p("done"),
ok.
do_simple_sync_get(Node, Addr, Port, Oids) ->
@@ -1578,7 +1624,7 @@ do_simple_sync_get(Node, Addr, Port, Oids) ->
?DBG("~n Reply: ~p"
"~n Rem: ~w", [Reply, Rem]),
-
+
%% verify that the operation actually worked:
%% The order should be the same, so no need to seach
?line ok = case Reply of
@@ -1612,7 +1658,9 @@ simple_sync_get2(suite) -> [];
simple_sync_get2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
put(tname, ssg2),
- do_simple_sync_get2(Config).
+ do_simple_sync_get2(Config),
+ display_log(Config),
+ ok.
do_simple_sync_get2(Config) ->
Get = fun(Node, TargetName, Oids) ->
@@ -1677,7 +1725,9 @@ simple_sync_get3(suite) -> [];
simple_sync_get3(Config) when is_list(Config) ->
process_flag(trap_exit, true),
put(tname, ssg3),
- do_simple_sync_get3(Config).
+ do_simple_sync_get3(Config),
+ display_log(Config),
+ ok.
do_simple_sync_get3(Config) ->
Self = self(),
@@ -1703,8 +1753,8 @@ do_simple_sync_get3(Config) ->
%%======================================================================
-simple_async_get1(doc) -> ["Simple (async) get-request - "
- "Old style (Addr & Port)"];
+simple_async_get1(doc) ->
+ ["Simple (async) get-request - Old style (Addr & Port)"];
simple_async_get1(suite) -> [];
simple_async_get1(Config) when is_list(Config) ->
process_flag(trap_exit, true),
@@ -1766,6 +1816,7 @@ simple_async_get1(Config) when is_list(Config) ->
p("manager info when ending test: ~n~p", [mgr_info(MgrNode)]),
p("agent info when ending test: ~n~p", [agent_info(AgentNode)]),
+ display_log(Config),
ok.
async_g_exec1(Node, Addr, Port, Oids) ->
@@ -1816,7 +1867,9 @@ simple_async_get2(Config) when is_list(Config) ->
TargetName = ?config(manager_agent_target_name, Config),
Get = fun(Oids) -> async_g_exec2(MgrNode, TargetName, Oids) end,
PostVerify = fun(Res) -> Res end,
- do_simple_async_sync_get2(Config, MgrNode, AgentNode, Get, PostVerify).
+ do_simple_async_sync_get2(Config, MgrNode, AgentNode, Get, PostVerify),
+ display_log(Config),
+ ok.
do_simple_async_sync_get2(Config, MgrNode, AgentNode, Get, PostVerify) ->
?line ok = mgr_user_load_mib(MgrNode, std_mib()),
@@ -1905,7 +1958,9 @@ simple_async_get3(Config) when is_list(Config) ->
PostVerify = fun(ok) -> receive Msg -> ok end;
(Error) -> Error
end,
- do_simple_async_sync_get2(Config, MgrNode, AgentNode, Get, PostVerify).
+ do_simple_async_sync_get2(Config, MgrNode, AgentNode, Get, PostVerify),
+ display_log(Config),
+ ok.
async_g_exec3(Node, TargetName, Oids, SendOpts) ->
mgr_user_async_get2(Node, TargetName, Oids, SendOpts).
@@ -1999,6 +2054,8 @@ simple_sync_get_next1(Config) when is_list(Config) ->
end,
?line ok = do_simple_get_next(8,
MgrNode, Addr, Port, Oids08, VF08),
+
+ display_log(Config),
ok.
@@ -2062,7 +2119,10 @@ simple_sync_get_next2(Config) when is_list(Config) ->
mgr_user_sync_get_next(Node, TargetName, Oids)
end,
PostVerify = fun(Res) -> Res end,
- do_simple_sync_get_next2(Config, GetNext, PostVerify).
+ do_simple_sync_get_next2(Config, GetNext, PostVerify),
+ display_log(Config),
+ ok.
+
do_simple_sync_get_next2(Config, GetNext, PostVerify)
when is_function(GetNext, 3) andalso is_function(PostVerify, 1) ->
@@ -2193,7 +2253,9 @@ simple_sync_get_next3(Config) when is_list(Config) ->
PostVerify = fun(ok) -> receive Msg -> ok end;
(Error) -> Error
end,
- do_simple_sync_get_next2(Config, GetNext, PostVerify).
+ do_simple_sync_get_next2(Config, GetNext, PostVerify),
+ display_log(Config),
+ ok.
%%======================================================================
@@ -2286,6 +2348,7 @@ simple_async_get_next1(Config) when is_list(Config) ->
p("manager info when ending test: ~n~p", [mgr_info(MgrNode)]),
p("agent info when ending test: ~n~p", [agent_info(AgentNode)]),
+ display_log(Config),
ok.
@@ -2315,7 +2378,9 @@ simple_async_get_next2(Config) when is_list(Config) ->
async_gn_exec2(MgrNode, TargetName, Oids)
end,
PostVerify = fun(Res) -> Res end,
- do_simple_async_get_next2(MgrNode, AgentNode, GetNext, PostVerify).
+ do_simple_async_get_next2(MgrNode, AgentNode, GetNext, PostVerify),
+ display_log(Config),
+ ok.
do_simple_async_get_next2(MgrNode, AgentNode, GetNext, PostVerify)
when is_function(GetNext, 1) andalso is_function(PostVerify, 1) ->
@@ -2437,7 +2502,9 @@ simple_async_get_next3(Config) when is_list(Config) ->
(Error) -> Error
end,
- do_simple_async_get_next2(MgrNode, AgentNode, GetNext, PostVerify).
+ do_simple_async_get_next2(MgrNode, AgentNode, GetNext, PostVerify),
+ display_log(Config),
+ ok.
async_gn_exec3(Node, TargetName, Oids, SendOpts) ->
mgr_user_async_get_next2(Node, TargetName, Oids, SendOpts).
@@ -2475,6 +2542,8 @@ simple_sync_set1(Config) when is_list(Config) ->
{[sysLocation, 0], Val22}
],
?line ok = do_simple_set1(Node, Addr, Port, VAVs2),
+
+ display_log(Config),
ok.
do_simple_set1(Node, Addr, Port, VAVs) ->
@@ -2527,7 +2596,9 @@ simple_sync_set2(Config) when is_list(Config) ->
end,
PostVerify = fun() -> ok end,
- do_simple_sync_set2(Config, Set, PostVerify).
+ do_simple_sync_set2(Config, Set, PostVerify),
+ display_log(Config),
+ ok.
do_simple_sync_set2(Config, Set, PostVerify)
when is_function(Set, 3) andalso is_function(PostVerify, 0) ->
@@ -2604,7 +2675,9 @@ simple_sync_set3(Config) when is_list(Config) ->
end,
PostVerify = fun() -> receive Msg -> ok end end,
- do_simple_sync_set2(Config, Set, PostVerify).
+ do_simple_sync_set2(Config, Set, PostVerify),
+ display_log(Config),
+ ok.
%%======================================================================
@@ -2663,6 +2736,7 @@ simple_async_set1(Config) when is_list(Config) ->
p("manager info when ending test: ~n~p", [mgr_info(MgrNode)]),
p("agent info when ending test: ~n~p", [agent_info(AgentNode)]),
+ display_log(Config),
ok.
@@ -2724,7 +2798,9 @@ simple_async_set2(Config) when is_list(Config) ->
end,
PostVerify = fun(Res) -> Res end,
- do_simple_async_set2(MgrNode, AgentNode, Set, PostVerify).
+ do_simple_async_set2(MgrNode, AgentNode, Set, PostVerify),
+ display_log(Config),
+ ok.
do_simple_async_set2(MgrNode, AgentNode, Set, PostVerify) ->
Requests =
@@ -2806,7 +2882,9 @@ simple_async_set3(Config) when is_list(Config) ->
(Res) -> Res
end,
- do_simple_async_set2(MgrNode, AgentNode, Set, PostVerify).
+ do_simple_async_set2(MgrNode, AgentNode, Set, PostVerify),
+ display_log(Config),
+ ok.
async_s_exec3(Node, TargetName, VAVs, SendOpts) ->
mgr_user_async_set2(Node, TargetName, VAVs, SendOpts).
@@ -2932,6 +3010,7 @@ simple_sync_get_bulk1(Config) when is_list(Config) ->
0, 2,
[[TCnt2, 1]], VF11),
+ display_log(Config),
ok.
fl(L) ->
@@ -3004,7 +3083,9 @@ simple_sync_get_bulk2(Config) when is_list(Config) ->
end,
PostVerify = fun(Res) -> Res end,
- do_simple_sync_get_bulk2(Config, MgrNode, AgentNode, GetBulk, PostVerify).
+ do_simple_sync_get_bulk2(Config, MgrNode, AgentNode, GetBulk, PostVerify),
+ display_log(Config),
+ ok.
do_simple_sync_get_bulk2(Config, MgrNode, AgentNode, GetBulk, PostVerify) ->
%% -- 1 --
@@ -3169,7 +3250,9 @@ simple_sync_get_bulk3(Config) when is_list(Config) ->
(Res) -> Res
end,
- do_simple_sync_get_bulk2(Config, MgrNode, AgentNode, GetBulk, PostVerify).
+ do_simple_sync_get_bulk2(Config, MgrNode, AgentNode, GetBulk, PostVerify),
+ display_log(Config),
+ ok.
%%======================================================================
@@ -3308,6 +3391,7 @@ simple_async_get_bulk1(Config) when is_list(Config) ->
p("manager info when ending test: ~n~p", [mgr_info(MgrNode)]),
p("agent info when ending test: ~n~p", [agent_info(AgentNode)]),
+ display_log(Config),
ok.
@@ -3340,7 +3424,9 @@ simple_async_get_bulk2(Config) when is_list(Config) ->
end,
PostVerify = fun(Res) -> Res end,
- do_simple_async_get_bulk2(MgrNode, AgentNode, GetBulk, PostVerify).
+ do_simple_async_get_bulk2(MgrNode, AgentNode, GetBulk, PostVerify),
+ display_log(Config),
+ ok.
do_simple_async_get_bulk2(MgrNode, AgentNode, GetBulk, PostVerify) ->
%% We re-use the verification functions from the ssgb test-case
@@ -3505,7 +3591,9 @@ simple_async_get_bulk3(Config) when is_list(Config) ->
(Res) -> Res
end,
- do_simple_async_get_bulk2(MgrNode, AgentNode, GetBulk, PostVerify).
+ do_simple_async_get_bulk2(MgrNode, AgentNode, GetBulk, PostVerify),
+ display_log(Config),
+ ok.
async_gb_exec3(Node, TargetName, {NR, MR, Oids}, SendOpts) ->
mgr_user_async_get_bulk2(Node, TargetName, NR, MR, Oids, SendOpts).
@@ -3697,6 +3785,7 @@ misc_async1(Config) when is_list(Config) ->
p("manager info when ending test: ~n~p", [mgr_info(MgrNode)]),
p("agent info when ending test: ~n~p", [agent_info(AgentNode)]),
+ display_log(Config),
ok.
@@ -3885,6 +3974,7 @@ misc_async2(Config) when is_list(Config) ->
p("manager info when ending test: ~n~p", [mgr_info(MgrNode)]),
p("agent info when ending test: ~n~p", [agent_info(AgentNode)]),
+ display_log(Config),
ok.
@@ -4099,7 +4189,9 @@ trap1(Config) when is_list(Config) ->
{5, "Manager and agent info after test completion", Cmd1}
],
- command_handler(Commands).
+ command_handler(Commands),
+ display_log(Config),
+ ok.
%%======================================================================
@@ -4290,7 +4382,9 @@ trap2(Config) when is_list(Config) ->
{7, "Manager and agent info after test completion", Cmd1}
],
- command_handler(Commands).
+ command_handler(Commands),
+ display_log(Config),
+ ok.
%%======================================================================
@@ -4415,7 +4509,9 @@ inform1(Config) when is_list(Config) ->
{6, "Manager and agent info after test completion", Cmd1}
],
- command_handler(Commands).
+ command_handler(Commands),
+ display_log(Config),
+ ok.
%%======================================================================
@@ -4423,7 +4519,7 @@ inform1(Config) when is_list(Config) ->
inform2(suite) -> [];
inform2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- put(tname,i2),
+ put(tname, i2),
p("starting with Config: ~p~n", [Config]),
MgrNode = ?config(manager_node, Config),
@@ -4577,7 +4673,7 @@ inform2(Config) when is_list(Config) ->
[
{1, "Manager and agent info at start of test", Cmd1},
{2, "Send notifcation [no receiver] from agent", Cmd2},
- {3, "await inform-sent acknowledge from agent", Cmd3},
+ {3, "Await inform-sent acknowledge from agent", Cmd3},
{4, "Await first inform to manager - do not reply", Cmd4},
{5, "Await second inform to manager - reply", Cmd5},
{6, "await inform-acknowledge from agent", Cmd6},
@@ -4585,7 +4681,9 @@ inform2(Config) when is_list(Config) ->
{8, "Manager and agent info after test completion", Cmd1}
],
- command_handler(Commands).
+ command_handler(Commands),
+ display_log(Config),
+ ok.
%%======================================================================
@@ -4719,7 +4817,9 @@ inform3(Config) when is_list(Config) ->
{9, "Manager and agent info after test completion", Cmd1}
],
- command_handler(Commands).
+ command_handler(Commands),
+ display_log(Config),
+ ok.
%%======================================================================
@@ -4835,7 +4935,9 @@ inform4(Config) when is_list(Config) ->
{6, "Manager and agent info after test completion", Cmd1}
],
- command_handler(Commands).
+ command_handler(Commands),
+ display_log(Config),
+ ok.
%%======================================================================
@@ -4923,7 +5025,10 @@ inform_swarm(Config) when is_list(Config) ->
{5, "Manager and agent info after test completion", Cmd1}
],
- command_handler(Commands).
+ command_handler(Commands),
+ display_log(Config),
+ ok.
+
inform_swarm_collector(N) ->
inform_swarm_collector(N, 0, 0, 0, 10000).
@@ -5227,8 +5332,8 @@ init_agent(Config) ->
%% --
%% Retrieve some dir's
%%
- Dir = ?config(top_dir, Config),
- DataDir = ?config(data_dir, Config),
+ Dir = ?config(agent_dir, Config),
+ MibDir = ?config(mib_dir, Config),
%% --
%% Start node
@@ -5259,7 +5364,7 @@ init_agent(Config) ->
?line ok = write_agent_config(Vsns, Config),
Conf = [{agent_node, Node},
- {mib_dir, DataDir} | Config],
+ {mib_dir, MibDir} | Config],
%%
%% Start the agent
@@ -5720,6 +5825,15 @@ start_manager(Node, Vsns, Conf0, Opts) ->
AtlSeqNo = get_opt(manager_atl_seqno, Conf0, false),
+ NetIfConf =
+ case get_opt(manager_net_if_module, Conf0, no_module) of
+ no_module ->
+ [{verbosity, NetIfVerbosity}];
+ NetIfModule ->
+ [{module, NetIfModule},
+ {verbosity, NetIfVerbosity}]
+ end,
+
Env = [{versions, Vsns},
{inform_request_behaviour, IRB},
{audit_trail_log, [{type, read_write},
@@ -5732,7 +5846,7 @@ start_manager(Node, Vsns, Conf0, Opts) ->
{verbosity, ConfigVerbosity}]},
{note_store, [{verbosity, NoteStoreVerbosity}]},
{server, [{verbosity, ServerVerbosity}]},
- {net_if, [{verbosity, NetIfVerbosity}]}],
+ {net_if, NetIfConf}],
?line ok = set_mgr_env(Node, Env),
?line ok = start_snmp(Node),
@@ -6018,6 +6132,38 @@ write_conf_file(Dir, File, Str) ->
%% ------
+display_log(Config) ->
+ case lists:keysearch(manager_log_dir, 1, Config) of
+ {value, {_, Dir}} ->
+ case lists:keysearch(manager_node, 1, Config) of
+ {value, {_, Node}} ->
+ LogDir = Dir,
+ Mibs = [],
+ OutFile = j(LogDir, "snmpm_log.txt"),
+ p("~n"
+ "========================="
+ " < Audit Trail Log > "
+ "========================="
+ "~n"),
+ rcall(Node, snmpm, log_to_txt, [LogDir, Mibs, OutFile]),
+ rcall(Node, snmpm, log_to_io, [LogDir, Mibs]),
+ p("~n"
+ "========================="
+ " < / Audit Trail Log > "
+ "========================="
+ "~n");
+ false ->
+ p("display_log -> no manager node found"),
+ ok
+ end;
+ false ->
+ p("display_log -> no manager log dir found"),
+ ok
+ end.
+
+
+%% ------
+
test2_mib(Config) ->
j(test_mib_dir(Config), "Test2.bin").
@@ -6034,7 +6180,7 @@ snmpv2_mib() ->
j(mib_dir(), "SNMPv2-MIB.bin").
test_mib_dir(Config) ->
- ?config(snmp_data_dir, Config).
+ ?config(mib_dir, Config).
mib_dir() ->
j(code:priv_dir(snmp), "mibs").
diff --git a/lib/snmp/test/snmp_test_lib.erl b/lib/snmp/test/snmp_test_lib.erl
index e4d58a1253..bc54361aaf 100644
--- a/lib/snmp/test/snmp_test_lib.erl
+++ b/lib/snmp/test/snmp_test_lib.erl
@@ -25,7 +25,10 @@
-export([hostname/0, hostname/1, localhost/0, os_type/0, sz/1,
display_suite_info/1]).
-export([non_pc_tc_maybe_skip/4, os_based_skip/1]).
--export([replace_config/3, set_config/3, get_config/2, get_config/3]).
+-export([fix_data_dir/1,
+ init_suite_top_dir/2, init_group_top_dir/2, init_testcase_top_dir/2,
+ lookup/2,
+ replace_config/3, set_config/3, get_config/2, get_config/3]).
-export([fail/3, skip/3]).
-export([millis/0, millis_diff/2, hours/1, minutes/1, seconds/1, sleep/1]).
-export([flush_mqueue/0, trap_exit/0, trap_exit/1]).
@@ -198,6 +201,85 @@ os_based_skip(_Crap) ->
%% Test suite utility functions
%%
+fix_data_dir(Config) ->
+ DataDir0 = lookup(data_dir, Config),
+ DataDir1 = filename:split(filename:absname(DataDir0)),
+ [_|DataDir2] = lists:reverse(DataDir1),
+ DataDir = filename:join(lists:reverse(DataDir2) ++ [?snmp_test_data]),
+ Config1 = lists:keydelete(data_dir, 1, Config),
+ [{data_dir, DataDir ++ "/"} | Config1].
+
+
+init_suite_top_dir(Suite, Config0) ->
+ Dir = lookup(priv_dir, Config0),
+ SuiteTopDir = filename:join(Dir, Suite),
+ case file:make_dir(SuiteTopDir) of
+ ok ->
+ ok;
+ {error, eexist} ->
+ ok;
+ {error, Reason} ->
+ fail({failed_creating_suite_top_dir, SuiteTopDir, Reason},
+ ?MODULE, ?LINE)
+ end,
+
+ %% This is just in case...
+ Config1 = lists:keydelete(snmp_group_top_dir, 1, Config0),
+ Config2 = lists:keydelete(snmp_suite_top_dir, 1, Config1),
+ [{snmp_suite_top_dir, SuiteTopDir} | Config2].
+
+
+init_group_top_dir(GroupName, Config) ->
+ case lists:keysearch(snmp_group_top_dir, 1, Config) of
+ {value, {_Key, Dir}} ->
+ %% This is a sub-group, so create our dir within Dir
+ GroupTopDir = filename:join(Dir, GroupName),
+ case file:make_dir(GroupTopDir) of
+ ok ->
+ ok;
+ {error, Reason} ->
+ fail({failed_creating_group_top_dir, GroupTopDir, Reason},
+ ?MODULE, ?LINE)
+ end,
+ [{snmp_group_top_dir, GroupTopDir} | Config];
+
+ _ ->
+ case lists:keysearch(snmp_suite_top_dir, 1, Config) of
+ {value, {_Key, Dir}} ->
+ GroupTopDir = filename:join(Dir, GroupName),
+ case file:make_dir(GroupTopDir) of
+ ok ->
+ ok;
+ {error, Reason} ->
+ fail({failed_creating_group_top_dir,
+ GroupTopDir, Reason},
+ ?MODULE, ?LINE)
+ end,
+ [{snmp_group_top_dir, GroupTopDir} | Config];
+ _ ->
+ fail(could_not_find_suite_top_dir, ?MODULE, ?LINE)
+ end
+ end.
+
+
+init_testcase_top_dir(Case, Config) ->
+ case lists:keysearch(snmp_group_top_dir, 1, Config) of
+ {value, {_Key, Dir}} ->
+ CaseTopDir = filename:join(Dir, Case),
+ ok = file:make_dir(CaseTopDir),
+ CaseTopDir;
+ false ->
+ case lists:keysearch(snmp_suite_top_dir, 1, Config) of
+ {value, {_Key, Dir}} ->
+ CaseTopDir = filename:join(Dir, Case),
+ ok = file:make_dir(CaseTopDir),
+ CaseTopDir;
+ false ->
+ fail(failed_creating_case_top_dir, ?MODULE, ?LINE)
+ end
+ end.
+
+
replace_config(Key, Config, NewValue) ->
lists:keyreplace(Key, 1, Config, {Key, NewValue}).
@@ -220,6 +302,9 @@ get_config(Key,C,Default) ->
Default
end.
+lookup(Key, Config) ->
+ {value, {Key, Value}} = lists:keysearch(Key, 1, Config),
+ Value.
fail(Reason, Mod, Line) ->
exit({suite_failed, Reason, Mod, Line}).