aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2011-04-15 15:23:42 +0200
committerMicael Karlberg <[email protected]>2011-04-15 15:23:42 +0200
commitf404041f4ce1a94c5784fb2c39b2d5624d58f624 (patch)
treedc25c320aec2a8a6a03ff2d2000357f3b7904e35 /lib/snmp
parent0dd3ff7f7e7c15e912645b1d4cc42fcef25ee29d (diff)
parent8bf62843795deb64ccc0abcb11c35adc32b4a6a6 (diff)
downloadotp-f404041f4ce1a94c5784fb2c39b2d5624d58f624.tar.gz
otp-f404041f4ce1a94c5784fb2c39b2d5624d58f624.tar.bz2
otp-f404041f4ce1a94c5784fb2c39b2d5624d58f624.zip
Merge branch 'bmk/snmp/manager/request_override_options' into bmk/snmp/snmp420_integration
Conflicts: lib/snmp/src/app/snmp.appup.src OTP-9162
Diffstat (limited to 'lib/snmp')
-rw-r--r--lib/snmp/doc/src/notes.xml39
-rw-r--r--lib/snmp/doc/src/snmpm.xml559
-rw-r--r--lib/snmp/src/app/snmp.appup.src20
-rw-r--r--lib/snmp/src/manager/snmpm.erl408
-rw-r--r--lib/snmp/src/manager/snmpm_internal.hrl7
-rw-r--r--lib/snmp/src/manager/snmpm_net_if.erl18
-rw-r--r--lib/snmp/src/manager/snmpm_server.erl684
-rw-r--r--lib/snmp/test/Makefile7
-rw-r--r--lib/snmp/test/snmp_agent_test.erl161
-rw-r--r--lib/snmp/test/snmp_manager_test.erl1090
-rw-r--r--lib/snmp/test/snmp_manager_user.erl135
11 files changed, 2425 insertions, 703 deletions
diff --git a/lib/snmp/doc/src/notes.xml b/lib/snmp/doc/src/notes.xml
index 7d31b9585d..c507965cd8 100644
--- a/lib/snmp/doc/src/notes.xml
+++ b/lib/snmp/doc/src/notes.xml
@@ -44,12 +44,6 @@
-->
<list type="bulleted">
<item>
- <p>Added type specs for functions that do not return. </p>
- <p>Kostis Sagonas</p>
- <p>Own Id: OTP-9174</p>
- </item>
-
- <item>
<p>[agent] Added support for sending traps to IPv6 targets. </p>
<p>See the
<seealso marker="snmp_agent_config_files#target_addr">target address config file</seealso>,
@@ -60,12 +54,39 @@
</item>
<item>
+ <p>[manager] The API for snmp requests has been augmented to
+ allow the caller to override some configuration. </p>
+ <p>This has been done by introducing a new set of API functions, see
+ <seealso marker="snmpm#sync_get2">sync_get2/3,4</seealso>,
+ <seealso marker="snmpm#async_get2">async_get2/3,4</seealso>,
+ <seealso marker="snmpm#sync_get_next2">sync_get_next2/3,4</seealso>,
+ <seealso marker="snmpm#async_get_next2">async_get_next2/3,4</seealso>,
+ <seealso marker="snmpm#sync_get_bulk2">sync_get_bulk2/5,6</seealso>,
+ <seealso marker="snmpm#async_get_bulk2">async_get_bulk2/5,6</seealso>,
+ <seealso marker="snmpm#sync_set2">sync_set2/3,4</seealso> and
+ <seealso marker="snmpm#async_set2">async_set2/3,4</seealso>
+ for more info. </p>
+ <p>Own Id: OTP-9162</p>
+ </item>
+
+ <item>
<p>[manager] The old API functions (for get and set
- requests) are now officially deprecated.
+ requests:
+ snmpm:g/3,4,5,6,7, snmpm:ag/3,4,5,6,7,
+ snmpm:gn/3,4,5,6,7, snmpm:agn/3,4,5,6,7,
+ snmpm:s/3,4,5,6,7, snmpm:s/3,4,5,6,7,
+ snmpm:gb/5,6,7,8,9 and snmpm:agb/5,6,7,8,9)
+ are now officially deprecated.
They will be removed as of R16B. </p>
<p>Own Id: OTP-9174</p>
</item>
+ <item>
+ <p>Added type specs for functions that do not return. </p>
+ <p>Kostis Sagonas</p>
+ <p>Own Id: OTP-9208</p>
+ </item>
+
</list>
</section>
@@ -289,7 +310,7 @@ snmp_view_basec_acm_mib:vacmAccessTable(set, RowIndex, Cols).
<p>The config utility
(<seealso marker="snmp#config">snmp:config/0</seealso>)
generated a default notify.conf
- with a bad name for the starndard trap entry (was "stadard trap",
+ with a bad name for the standard trap entry (was "stadard trap",
but should have been "standard trap"). This has been corrected. </p>
<p>Kenji Rikitake</p>
<p>Own Id: OTP-8433</p>
@@ -493,7 +514,7 @@ snmp_view_basec_acm_mib:vacmAccessTable(set, RowIndex, Cols).
<p>The config utility
(<seealso marker="snmp#config">snmp:config/0</seealso>)
generated a default notify.conf
- with a bad name for the starndard trap entry (was "stadard trap",
+ with a bad name for the standard trap entry (was "stadard trap",
but should have been "standard trap"). This has been corrected. </p>
<p>Kenji Rikitake</p>
<p>Own Id: OTP-8433</p>
diff --git a/lib/snmp/doc/src/snmpm.xml b/lib/snmp/doc/src/snmpm.xml
index 1ee391d9ba..72849b9c9e 100644
--- a/lib/snmp/doc/src/snmpm.xml
+++ b/lib/snmp/doc/src/snmpm.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
@@ -63,6 +63,10 @@ value_type() = o ('OBJECT IDENTIFIER') |
c64 ('Counter64') |
tt ('TimeTicks')
value() = term()
+community() = string()
+sec_model() = any | v1 | v2c | usm
+sec_name() = string()
+sec_level() = noAuthNoPriv | authNoPriv | authPriv
]]></code>
<marker id="monitor"></marker>
@@ -482,11 +486,65 @@ priv_key = [integer()] (length is 16 if priv = usmDESPrivProtocol | usmAesCfb1
<p>Get a list of all registered usm users with engine-id
<c>EngineID</c>.</p>
- <marker id="sync_get"></marker>
+ <marker id="sync_get2"></marker>
</desc>
</func>
<func>
+ <name>sync_get2(UserId, TargetName, Oids) -> {ok, SnmpReply, Remaining} | {error, Reason}</name>
+ <name>sync_get2(UserId, TargetName, Oids, SendOpts) -> {ok, SnmpReply, Remaining} | {error, Reason}</name>
+ <fsummary>Synchronous <c>get-request</c></fsummary>
+ <type>
+ <v>UserId = term()</v>
+ <v>TargetName = target_name()</v>
+ <v>Oids = [oid()]</v>
+ <v>SendOpts = send_opts()</v>
+ <v>send_opts() = [send_opt()]</v>
+ <v>send_opt() = {context, string()} | {timeout, pos_integer()} | {extra, term()} | {community, community()} | {sec_model, sec_model()} | {sec_name, string()} | {sec_level, sec_level()} | {max_message_size, pos_integer()}</v>
+ <v>SnmpReply = snmp_reply()</v>
+ <v>Remaining = integer()</v>
+ <v>Reason = {send_failed, ReqId, ActualReason} | {invalid_sec_info, SecInfo, SnmpInfo} | term()</v>
+ <v>ReqId = term()</v>
+ <v>ActualReason = term()</v>
+ <v>SecInfo = [sec_info()]</v>
+ <v>sec_info() = {sec_tag(), ExpectedValue, ReceivedValue}</v>
+ <v>sec_tag() = atom()</v>
+ <v>ExpectedValue = ReceivedValue = term()</v>
+ <v>SnmpInfo = term()</v>
+ </type>
+ <desc>
+ <p>Synchronous <c>get-request</c>. </p>
+
+ <p><c>Remaining</c> is the remaining time of the given (or default)
+ timeout time.</p>
+
+ <p>When <em>Reason</em> is <em>{send_failed, ...}</em> it means that
+ the net_if process failed to send the message. This could happen
+ because of any number of reasons, i.e. encoding error.
+ <em>ActualReason</em> is the actual reason in this case. </p>
+
+ <p>The send option <c>extra</c> specifies an opaque data structure
+ passed on to the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a option (when using the built in
+ net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <p>Some of the send options (<c>community</c>, <c>sec_model</c>,
+ <c>sec_name</c>, <c>sec_level</c> and <c>max_message_size</c>)
+ are <c>override options</c>. That is,
+ for <em>this</em> request, they override any configuration done
+ when the agent was registered. </p>
+
+ <p>For <c>SnmpInfo</c>, see the user callback function
+ <seealso marker="snmpm_user#handle_report">handle_report</seealso>.</p>
+
+ <marker id="sync_get"></marker>
+ </desc>
+ </func>
+
+ <func>
<name>sync_get(UserId, TargetName, Oids) -> {ok, SnmpReply, Remaining} | {error, Reason}</name>
<name>sync_get(UserId, TargetName, ContextName, Oids) -> {ok, SnmpReply, Remaining} | {error, Reason}</name>
<name>sync_get(UserId, TargetName, Oids, Timeout) -> {ok, SnmpReply, Remaining} | {error, Reason}</name>
@@ -513,19 +571,63 @@ priv_key = [integer()] (length is 16 if priv = usmDESPrivProtocol | usmAesCfb1
<desc>
<p>Synchronous <c>get-request</c>. </p>
<p><c>Remaining</c> is the remaining time of the given or
- default timeout time.</p>
+ default timeout time.</p>
<p>When <em>Reason</em> is <em>{send_failed, ...}</em> it means that
- the net_if process failed to send the message. This could happen
- because of any number of reasons, i.e. encoding error. <em>R</em>
- is the actual reason in this case. </p>
- <p><c>ExtraInfo</c> is an opaque data structure passed on to
- the net-if process. The net-if process included in this
- application makes no use of this info, so the only use for it
- in such a configuration (when using the built in net-if) would
- be tracing.</p>
+ the net_if process failed to send the message. This could happen
+ because of any number of reasons, i.e. encoding error. <em>R</em>
+ is the actual reason in this case. </p>
+ <p><c>ExtraInfo</c> is an opaque data structure passed on to
+ the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a configuration (when using the
+ built in net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
<p>For <c>SnmpInfo</c>, see the user callback function
<seealso marker="snmpm_user#handle_report">handle_report</seealso>.</p>
+ <marker id="async_get2"></marker>
+ </desc>
+ </func>
+
+ <func>
+ <name>async_get2(UserId, TargetName, Oids) -> {ok, ReqId} | {error, Reason}</name>
+ <name>async_get2(UserId, TargetName, Oids, SendOpts) -> {ok, ReqId} | {error, Reason}</name>
+ <fsummary>Asynchronous <c>get-request</c></fsummary>
+ <type>
+ <v>UserId = term()</v>
+ <v>TargetName = target_name()</v>
+ <v>Oids = [oid()]</v>
+ <v>SendOpts = send_opts()</v>
+ <v>send_opts() = [send_opt()]</v>
+ <v>send_opt() = {context, string()} | {timeout, pos_integer()} | {extra, term()} | {community, community()} | {sec_model, sec_model()} | {sec_name, string()} | {sec_level, sec_level()} | {max_message_size, pos_integer()}</v>
+ <v>ReqId = term()</v>
+ <v>Reason = term()</v>
+ </type>
+ <desc>
+ <p>Asynchronous <c>get-request</c>.</p>
+
+ <p>The reply, if it arrives, will be delivered to the user
+ through a call to the snmpm_user callback function
+ <c>handle_pdu</c>.</p>
+
+ <p>The send option <c>timeout</c> specifies for how long the request is
+ valid (after which the manager is free to delete it).</p>
+
+ <p>The send option <c>extra</c> specifies an opaque data structure
+ passed on to the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a option (when using the built in
+ net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <p>Some of the send options (<c>community</c>, <c>sec_model</c>,
+ <c>sec_name</c>, <c>sec_level</c> and <c>max_message_size</c>)
+ are <c>override options</c>. That is,
+ for <em>this</em> request, they override any configuration done
+ when the agent was registered. </p>
+
<marker id="async_get"></marker>
</desc>
</func>
@@ -550,17 +652,73 @@ priv_key = [integer()] (length is 16 if priv = usmDESPrivProtocol | usmAesCfb1
<desc>
<p>Asynchronous <c>get-request</c>.</p>
<p>The reply, if it arrives, will be delivered to the user
- through a call to the snmpm_user callback function
- <c>handle_pdu</c>.</p>
- <p>The <c>Expire</c> time indicates for how long the request is
- valid (after which the manager is free to delete it).</p>
- <p><c>ExtraInfo</c> is an opaque data structure passed on to
- the net-if process. The net-if process included in this
- application makes no use of this info, so the only use for it
- in such a configuration (when using the built in net-if) would
- be tracing.</p>
-
- <marker id="sync_get_next"></marker>
+ through a call to the snmpm_user callback function
+ <c>handle_pdu</c>.</p>
+ <p>The <c>Expire</c> time indicates for how long the request is
+ valid (after which the manager is free to delete it).</p>
+ <p><c>ExtraInfo</c> is an opaque data structure passed on to
+ the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a configuration (when using the
+ built in net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <marker id="sync_get_next2"></marker>
+ </desc>
+ </func>
+
+ <func>
+ <name>sync_get_next2(UserId, TargetName, Oids) -> {ok, SnmpReply, Remaining} | {error, Reason}</name>
+ <name>sync_get_next2(UserId, TargetName, Oids, SendOpts) -> {ok, SnmpReply, Remaining} | {error, Reason}</name>
+ <fsummary>Synchronous <c>get-next-request</c></fsummary>
+ <type>
+ <v>UserId = term()</v>
+ <v>TargetName = target_name()</v>
+ <v>Oids = [oid()]</v>
+ <v>SendOpts = send_opts()</v>
+ <v>send_opts() = [send_opt()]</v>
+ <v>send_opt() = {context, string()} | {timeout, pos_integer()} | {extra, term()} | {community, community()} | {sec_model, sec_model()} | {sec_name, string()} | {sec_level, sec_level()} | {max_message_size, pos_integer()}</v>
+ <v>SnmpReply = snmp_reply()</v>
+ <v>Remaining = integer()</v>
+ <v>Reason = {send_failed, ReqId, ActualReason} | {invalid_sec_info, SecInfo, SnmpInfo} | term()</v>
+ <v>ReqId = term()</v>
+ <v>ActualReason = term()</v>
+ <v>SecInfo = [sec_info()]</v>
+ <v>sec_info() = {sec_tag(), ExpectedValue, ReceivedValue}</v>
+ <v>sec_tag() = atom()</v>
+ <v>ExpectedValue = ReceivedValue = term()</v>
+ <v>SnmpInfo = term()</v>
+ </type>
+ <desc>
+ <p>Synchronous <c>get-next-request</c>. </p>
+
+ <p><c>Remaining</c> is the remaining time of the given (or default)
+ timeout time.</p>
+
+ <p>When <em>Reason</em> is <em>{send_failed, ...}</em> it means that
+ the net_if process failed to send the message. This could happen
+ because of any number of reasons, i.e. encoding error.
+ <em>ActualReason</em> is the actual reason in this case. </p>
+
+ <p>The send option <c>extra</c> specifies an opaque data structure
+ passed on to the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a option (when using the built in
+ net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <p>Some of the send options (<c>community</c>, <c>sec_model</c>,
+ <c>sec_name</c>, <c>sec_level</c> and <c>max_message_size</c>)
+ are <c>override options</c>. That is,
+ for <em>this</em> request, they override any configuration done
+ when the agent was registered. </p>
+
+ <p>For <c>SnmpInfo</c>, see the user callback function
+ <seealso marker="snmpm_user#handle_report">handle_report</seealso>.</p>
+
+ <marker id="sync_get_next"></marker>
</desc>
</func>
@@ -587,16 +745,57 @@ priv_key = [integer()] (length is 16 if priv = usmDESPrivProtocol | usmAesCfb1
<p>Synchronous <c>get-next-request</c>. </p>
<p><c>Remaining</c> time of the given or default timeout time.</p>
<p>When <em>Reason</em> is <em>{send_failed, ...}</em> it means that
- the net_if process failed to send the message. This could happen
- because of any number of reasons, i.e. encoding error. <em>R</em>
- is the actual reason in this case. </p>
- <p><c>ExtraInfo</c> is an opaque data structure passed on to
- the net-if process. The net-if process included in this
- application makes no use of this info, so the only use for it
- in such a configuration (when using the built in net-if) would
- be tracing.</p>
-
- <marker id="async_get_next"></marker>
+ the net_if process failed to send the message. This could happen
+ because of any number of reasons, i.e. encoding error. <em>R</em>
+ is the actual reason in this case. </p>
+ <p><c>ExtraInfo</c> is an opaque data structure passed on to
+ the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a configuration (when using the
+ built in net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <marker id="async_get_next2"></marker>
+ </desc>
+ </func>
+
+ <func>
+ <name>async_get_next2(UserId, TargetName, Oids) -> {ok, ReqId} | {error, Reason}</name>
+ <name>async_get_next2(UserId, TargetName, Oids, SendOpts) -> {ok, ReqId} | {error, Reason}</name>
+ <fsummary>Asynchronous <c>get-next-request</c></fsummary>
+ <type>
+ <v>UserId = term()</v>
+ <v>TargetName = target_name()</v>
+ <v>Oids = [oid()]</v>
+ <v>send_opt() = {context, string()} | {timeout, pos_integer()} | {extra, term()} | {community, community()} | {sec_model, sec_model()} | {sec_name, string()} | {sec_level, sec_level()} | {max_message_size, pos_integer()}</v>
+ <v>ReqId = integer()</v>
+ <v>Reason = term()</v>
+ </type>
+ <desc>
+ <p>Asynchronous <c>get-next-request</c>. </p>
+
+ <p>The reply will be delivered to the user through a call
+ to the snmpm_user callback function <c>handle_pdu</c>.</p>
+
+ <p>The send option <c>timeout</c> specifies for how long the request is
+ valid (after which the manager is free to delete it).</p>
+
+ <p>The send option <c>extra</c> specifies an opaque data structure
+ passed on to the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a option (when using the built in
+ net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <p>Some of the send options (<c>community</c>, <c>sec_model</c>,
+ <c>sec_name</c>, <c>sec_level</c> and <c>max_message_size</c>)
+ are <c>override options</c>. That is,
+ for <em>this</em> request, they override any configuration done
+ when the agent was registered. </p>
+
+ <marker id="async_get_next"></marker>
</desc>
</func>
@@ -620,11 +819,75 @@ priv_key = [integer()] (length is 16 if priv = usmDESPrivProtocol | usmAesCfb1
<desc>
<p>Asynchronous <c>get-next-request</c>. </p>
<p>The reply will be delivered to the user through a call
- to the snmpm_user callback function <c>handle_pdu</c>.</p>
+ to the snmpm_user callback function <c>handle_pdu</c>.</p>
<p>The <c>Expire</c> time indicates for how long the request is
- valid (after which the manager is free to delete it).</p>
+ valid (after which the manager is free to delete it).</p>
+ <p><c>ExtraInfo</c> is an opaque data structure passed on to
+ the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a configuration (when using the
+ built in net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <marker id="sync_set2"></marker>
+ </desc>
+ </func>
- <marker id="sync_set"></marker>
+ <func>
+ <name>sync_set2(UserId, TargetName, VarsAndVals) -> {ok, SnmpReply, Remaining} | {error, Reason}</name>
+ <name>sync_set2(UserId, TargetName, VarsAndVals, SendOpts) -> {ok, SnmpReply, Remaining} | {error, Reason}</name>
+ <fsummary>Synchronous <c>set-request</c></fsummary>
+ <type>
+ <v>UserId = term()</v>
+ <v>TargetName = target_name()</v>
+ <v>VarsAndVals = vars_and_vals()</v>
+ <v>SendOpts = send_opts()</v>
+ <v>send_opts() = [send_opt()]</v>
+ <v>send_opt() = {context, string()} | {timeout, pos_integer()} | {extra, term()} | {community, community()} | {sec_model, sec_model()} | {sec_name, string()} | {sec_level, sec_level()} | {max_message_size, pos_integer()}</v>
+ <v>SnmpReply = snmp_reply()</v>
+ <v>Remaining = integer()</v>
+ <v>Reason = {send_failed, ReqId, ActualReason} | {invalid_sec_info, SecInfo, SnmpInfo} | term()</v>
+ <v>ReqId = term()</v>
+ <v>ActualReason = term()</v>
+ <v>SecInfo = [sec_info()]</v>
+ <v>sec_info() = {sec_tag(), ExpectedValue, ReceivedValue}</v>
+ <v>sec_tag() = atom()</v>
+ <v>ExpectedValue = ReceivedValue = term()</v>
+ <v>SnmpInfo = term()</v>
+ </type>
+ <desc>
+ <p>Synchronous <c>set-request</c>. </p>
+
+ <p><c>Remaining</c> is the remaining time of the given (or default)
+ timeout time.</p>
+
+ <p>When <em>Reason</em> is <em>{send_failed, ...}</em> it means that
+ the net_if process failed to send the message. This could happen
+ because of any number of reasons, i.e. encoding error.
+ <em>ActualReason</em> is the actual reason in this case. </p>
+
+ <p>When <em>var_and_val()</em> is <em>{oid(), value()}</em>, the
+ manager makes an educated guess based on the loaded mibs. </p>
+
+ <p>The send option <c>extra</c> specifies an opaque data structure
+ passed on to the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a option (when using the built in
+ net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <p>Some of the send options (<c>community</c>, <c>sec_model</c>,
+ <c>sec_name</c>, <c>sec_level</c> and <c>max_message_size</c>)
+ are <c>override options</c>. That is,
+ for <em>this</em> request, they override any configuration done
+ when the agent was registered. </p>
+
+ <p>For <c>SnmpInfo</c>, see the user callback function
+ <seealso marker="snmpm_user#handle_report">handle_report</seealso>.</p>
+
+ <marker id="sync_set"></marker>
</desc>
</func>
@@ -651,18 +914,64 @@ priv_key = [integer()] (length is 16 if priv = usmDESPrivProtocol | usmAesCfb1
<p>Synchronous <c>set-request</c>. </p>
<p><c>Remaining</c> time of the given or default timeout time.</p>
<p>When <em>Reason</em> is <em>{send_failed, ...}</em> it means that
- the net_if process failed to send the message. This could happen
- because of any number of reasons, i.e. encoding error. <em>R</em>
- is the actual reason in this case. </p>
- <p>When <em>var_and_val()</em> is <em>{oid(), value()}</em>, the
- manager makes an educated guess based on the loaded mibs. </p>
- <p><c>ExtraInfo</c> is an opaque data structure passed on to
- the net-if process. The net-if process included in this
- application makes no use of this info, so the only use for it
- in such a configuration (when using the built in net-if) would
- be tracing.</p>
-
- <marker id="async_set"></marker>
+ the net_if process failed to send the message. This could happen
+ because of any number of reasons, i.e. encoding error. <em>R</em>
+ is the actual reason in this case. </p>
+ <p>When <em>var_and_val()</em> is <em>{oid(), value()}</em>, the
+ manager makes an educated guess based on the loaded mibs. </p>
+ <p><c>ExtraInfo</c> is an opaque data structure passed on to
+ the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a configuration (when using the
+ built in net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <marker id="async_set2"></marker>
+ </desc>
+ </func>
+
+ <func>
+ <name>async_set2(UserId, TargetName, VarsAndVals) -> {ok, ReqId} | {error, Reason}</name>
+ <name>async_set2(UserId, TargetName, VarsAndVals, SendOpts) -> {ok, ReqId} | {error, Reason}</name>
+ <fsummary>Asynchronous <c>set-request</c></fsummary>
+ <type>
+ <v>UserId = term()</v>
+ <v>TargetName = target_name()</v>
+ <v>VarsAndVals = vars_and_vals()</v>
+ <v>SendOpts = send_opts()</v>
+ <v>send_opts() = [send_opt()]</v>
+ <v>send_opt() = {context, string()} | {timeout, pos_integer()} | {extra, term()} | {community, community()} | {sec_model, sec_model()} | {sec_name, string()} | {sec_level, sec_level()} | {max_message_size, pos_integer()}</v>
+ <v>ReqId = term()</v>
+ <v>Reason = term()</v>
+ </type>
+ <desc>
+ <p>Asynchronous <c>set-request</c>. </p>
+
+ <p>The reply will be delivered to the user through a call
+ to the snmpm_user callback function <c>handle_pdu</c>.</p>
+
+ <p>The send option <c>timeout</c> specifies for how long the request is
+ valid (after which the manager is free to delete it).</p>
+
+ <p>When <em>var_and_val()</em> is <em>{oid(), value()}</em>, the
+ manager makes an educated guess based on the loaded mibs. </p>
+
+ <p>The send option <c>extra</c> specifies an opaque data structure
+ passed on to the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a option (when using the built in
+ net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <p>Some of the send options (<c>community</c>, <c>sec_model</c>,
+ <c>sec_name</c>, <c>sec_level</c> and <c>max_message_size</c>)
+ are <c>override options</c>. That is,
+ for <em>this</em> request, they override any configuration done
+ when the agent was registered. </p>
+
+ <marker id="async_set"></marker>
</desc>
</func>
@@ -685,18 +994,76 @@ priv_key = [integer()] (length is 16 if priv = usmDESPrivProtocol | usmAesCfb1
<desc>
<p>Asynchronous <c>set-request</c>. </p>
<p>The reply will be delivered to the user through a call
- to the snmpm_user callback function <c>handle_pdu</c>.</p>
+ to the snmpm_user callback function <c>handle_pdu</c>.</p>
<p>The <c>Expire</c> time indicates for how long the request is
- valid (after which the manager is free to delete it).</p>
- <p>When <em>var_and_val()</em> is <em>{oid(), value()}</em>, the
- manager makes an educated guess based on the loaded mibs. </p>
- <p><c>ExtraInfo</c> is an opaque data structure passed on to
- the net-if process. The net-if process included in this
- application makes no use of this info, so the only use for it
- in such a configuration (when using the built in net-if) would
- be tracing.</p>
-
- <marker id="sync_get_bulk"></marker>
+ valid (after which the manager is free to delete it).</p>
+ <p>When <em>var_and_val()</em> is <em>{oid(), value()}</em>, the
+ manager makes an educated guess based on the loaded mibs. </p>
+ <p><c>ExtraInfo</c> is an opaque data structure passed on to
+ the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a configuration (when using the
+ built in net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <marker id="sync_get_bulk2"></marker>
+ </desc>
+ </func>
+
+ <func>
+ <name>sync_get_bulk2(UserId, TragetName, NonRep, MaxRep, Oids) -> {ok, SnmpReply, Remaining} | {error, Reason}</name>
+ <name>sync_get_bulk2(UserId, TragetName, NonRep, MaxRep, Oids, SendOpts) -> {ok, SnmpReply, Remaining} | {error, Reason}</name>
+ <fsummary>Synchronous <c>get-bulk-request</c></fsummary>
+ <type>
+ <v>UserId = term()</v>
+ <v>TargetName = target_name()</v>
+ <v>NonRep = integer()</v>
+ <v>MaxRep = integer()</v>
+ <v>Oids = [oid()]</v>
+ <v>SendOpts = send_opts()</v>
+ <v>send_opts() = [send_opt()]</v>
+ <v>send_opt() = {context, string()} | {timeout, pos_integer()} | {extra, term()} | {community, community()} | {sec_model, sec_model()} | {sec_name, string()} | {sec_level, sec_level()} | {max_message_size, pos_integer()}</v>
+ <v>SnmpReply = snmp_reply()</v>
+ <v>Remaining = integer()</v>
+ <v>Reason = {send_failed, ReqId, ActualReason} | {invalid_sec_info, SecInfo, SnmpInfo} | term()</v>
+ <v>ReqId = term()</v>
+ <v>ActualReason = term()</v>
+ <v>SecInfo = [sec_info()]</v>
+ <v>sec_info() = {sec_tag(), ExpectedValue, ReceivedValue}</v>
+ <v>sec_tag() = atom()</v>
+ <v>ExpectedValue = ReceivedValue = term()</v>
+ <v>SnmpInfo = term()</v>
+ </type>
+ <desc>
+ <p>Synchronous <c>get-bulk-request</c> (See RFC1905).</p>
+
+ <p><c>Remaining</c> is the remaining time of the given (or default)
+ timeout time.</p>
+
+ <p>When <em>Reason</em> is <em>{send_failed, ...}</em> it means that
+ the net_if process failed to send the message. This could happen
+ because of any number of reasons, i.e. encoding error.
+ <em>ActualReason</em> is the actual reason in this case. </p>
+
+ <p>The send option <c>extra</c> specifies an opaque data structure
+ passed on to the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a option (when using the built in
+ net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <p>Some of the send options (<c>community</c>, <c>sec_model</c>,
+ <c>sec_name</c>, <c>sec_level</c> and <c>max_message_size</c>)
+ are <c>override options</c>. That is,
+ for <em>this</em> request, they override any configuration done
+ when the agent was registered. </p>
+
+ <p>For <c>SnmpInfo</c>, see the user callback function
+ <seealso marker="snmpm_user#handle_report">handle_report</seealso>.</p>
+
+ <marker id="sync_get_bulk"></marker>
</desc>
</func>
@@ -723,17 +1090,60 @@ priv_key = [integer()] (length is 16 if priv = usmDESPrivProtocol | usmAesCfb1
<desc>
<p>Synchronous <c>get-bulk-request</c> (See RFC1905).</p>
<p><c>Remaining</c> time of the given or default timeout time.</p>
- <p>When <em>Reason</em> is <em>{send_failed, ...}</em> it means that
- the net_if process failed to send the message. This could happen
- because of any number of reasons, i.e. encoding error. <em>R</em>
- is the actual reason in this case. </p>
- <p><c>ExtraInfo</c> is an opaque data structure passed on to
- the net-if process. The net-if process included in this
- application makes no use of this info, so the only use for it
- in such a configuration (when using the built in net-if) would
- be tracing.</p>
-
- <marker id="async_get_bulk"></marker>
+ <p>When <em>Reason</em> is <em>{send_failed, ...}</em> it means that
+ the net_if process failed to send the message. This could happen
+ because of any number of reasons, i.e. encoding error. <em>R</em>
+ is the actual reason in this case. </p>
+ <p><c>ExtraInfo</c> is an opaque data structure passed on to
+ the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a configuration (when using the
+ built in net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
+
+ <marker id="async_get_bulk2"></marker>
+ </desc>
+ </func>
+
+ <func>
+ <name>async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids) -> {ok, ReqId} | {error, Reason}</name>
+ <name>async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts) -> {ok, ReqId} | {error, Reason}</name>
+ <fsummary>Asynchronous <c>get-bulk-request</c></fsummary>
+ <type>
+ <v>UserId = term()</v>
+ <v>TargetName = target_name()</v>
+ <v>NonRep = integer()</v>
+ <v>MaxRep = integer()</v>
+ <v>Oids = [oid()]</v>
+ <v>SendOpts = send_opts()</v>
+ <v>send_opts() = [send_opt()]</v>
+ <v>send_opt() = {context, string()} | {timeout, pos_integer()} | {extra, term()} | {community, community()} | {sec_model, sec_model()} | {sec_name, string()} | {sec_level, sec_level()} | {max_message_size, pos_integer()}</v>
+ <v>ReqId = integer()</v>
+ <v>Reason = term()</v>
+ </type>
+ <desc>
+ <p>Asynchronous <c>get-bulk-request</c> (See RFC1905).</p>
+
+ <p>The reply will be delivered to the user through a call
+ to the snmpm_user callback function <c>handle_pdu</c>.</p>
+
+ <p>The send option <c>timeout</c> specifies for how long the request is
+ valid (after which the manager is free to delete it).</p>
+
+ <p>The send option <c>extra</c> specifies an opaque data structure
+ passed on to the net-if process. The net-if process included in this
+ application makes no use of this info, so the only use for it
+ in such a configuration (when using the built in net-if) would
+ be tracing.</p>
+
+ <p>Some of the send options (<c>community</c>, <c>sec_model</c>,
+ <c>sec_name</c>, <c>sec_level</c> and <c>max_message_size</c>)
+ are <c>override options</c>. That is,
+ for <em>this</em> request, they override any configuration done
+ when the agent was registered. </p>
+
+ <marker id="async_get_bulk"></marker>
</desc>
</func>
@@ -759,9 +1169,16 @@ priv_key = [integer()] (length is 16 if priv = usmDESPrivProtocol | usmAesCfb1
<desc>
<p>Asynchronous <c>get-bulk-request</c> (See RFC1905).</p>
<p>The reply will be delivered to the user through a call
- to the snmpm_user callback function <c>handle_pdu</c>.</p>
+ to the snmpm_user callback function <c>handle_pdu</c>.</p>
<p>The <c>Expire</c> time indicates for how long the request is
- valid (after which the manager is free to delete it).</p>
+ valid (after which the manager is free to delete it).</p>
+ <p><c>ExtraInfo</c> is an opaque data structure passed on to
+ the net-if process. The net-if process included in this
+ application makes, with one exception, no use of this info,
+ so the only use for it in such a configuration (when using the
+ built in net-if) would be tracing. The one usage exception is:
+ <em>Any</em> tuple with <c>snmpm_extra_info_tag</c> as its first
+ element is reserved for internal use. </p>
<marker id="cancel_async_request"></marker>
</desc>
diff --git a/lib/snmp/src/app/snmp.appup.src b/lib/snmp/src/app/snmp.appup.src
index be3bb7dffa..4c2de0fcf4 100644
--- a/lib/snmp/src/app/snmp.appup.src
+++ b/lib/snmp/src/app/snmp.appup.src
@@ -24,7 +24,7 @@
[
{"4.19",
[
- {load_module, snmpm, soft_purge, soft_purge, []},
+ {load_module, snmpm, soft_purge, soft_purge, [snmpm_server]},
{load_module, snmpa_usm, soft_purge, soft_purge, []},
{load_module, snmpm_usm, soft_purge, soft_purge, []},
{load_module, snmp_conf, soft_purge, soft_purge, []},
@@ -42,6 +42,8 @@
[snmp_conf, snmp_target_mib]},
{load_module, snmp_target_mib, soft_purge, soft_purge,
[snmp_conf]},
+ {update, snmpm_net_if, soft, soft_purge, soft_purge, []},
+ {update, snmpm_server, soft, soft_purge, soft_purge, [snmpm_net_if]},
{update, snmpa_net_if, soft, soft_purge, soft_purge,
[snmp_conf, snmpa_mpd]},
{update, snmpa_agent, soft, soft_purge, soft_purge,
@@ -50,7 +52,7 @@
},
{"4.18",
[
- {load_module, snmpm, soft_purge, soft_purge, []},
+ {load_module, snmpm, soft_purge, soft_purge, [snmpm_server]},
{load_module, snmpa_usm, soft_purge, soft_purge, []},
{load_module, snmpm_usm, soft_purge, soft_purge, []},
{load_module, snmp_misc, soft_purge, soft_purge, []},
@@ -86,6 +88,9 @@
[snmpa_mib_lib, snmpa_vacm]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
+ {update, snmpm_net_if, soft, soft_purge, soft_purge, []},
+ {update, snmpm_server, soft, soft_purge, soft_purge, [snmpm_net_if]},
+
{update, snmpa_net_if, soft, soft_purge, soft_purge,
[snmp_conf, snmpa_mpd]},
{update, snmpa_agent, soft, soft_purge, soft_purge,
@@ -99,7 +104,7 @@
[
{"4.19",
[
- {load_module, snmpm, soft_purge, soft_purge, []},
+ {load_module, snmpm, soft_purge, soft_purge, [snmpm_server]},
{load_module, snmpa_usm, soft_purge, soft_purge, []},
{load_module, snmpm_usm, soft_purge, soft_purge, []},
{load_module, snmp_conf, soft_purge, soft_purge, []},
@@ -117,6 +122,10 @@
[snmp_conf, snmp_target_mib]},
{load_module, snmp_target_mib, soft_purge, soft_purge,
[snmp_conf]},
+
+ {update, snmpm_net_if, soft, soft_purge, soft_purge, []},
+ {update, snmpm_server, soft, soft_purge, soft_purge, [snmpm_net_if]},
+
{update, snmpa_net_if, soft, soft_purge, soft_purge,
[snmp_conf, snmpa_mpd]},
{update, snmpa_agent, soft, soft_purge, soft_purge,
@@ -125,7 +134,7 @@
},
{"4.18",
[
- {load_module, snmpm, soft_purge, soft_purge, []},
+ {load_module, snmpm, soft_purge, soft_purge, [snmpm_server]},
{load_module, snmpa_usm, soft_purge, soft_purge, []},
{load_module, snmpm_usm, soft_purge, soft_purge, []},
{load_module, snmp_misc, soft_purge, soft_purge, []},
@@ -161,6 +170,9 @@
[snmpa_mib_lib, snmpa_vacm]},
{load_module, snmpa_mib_lib, soft_purge, soft_purge, []},
+ {update, snmpm_net_if, soft, soft_purge, soft_purge, []},
+ {update, snmpm_server, soft, soft_purge, soft_purge, [snmpm_net_if]},
+
{update, snmpa_net_if, soft, soft_purge, soft_purge,
[snmp_conf, snmpa_mpd]},
{update, snmpa_agent, soft, soft_purge, soft_purge,
diff --git a/lib/snmp/src/manager/snmpm.erl b/lib/snmp/src/manager/snmpm.erl
index 36b4901e9a..8a629eaf3b 100644
--- a/lib/snmp/src/manager/snmpm.erl
+++ b/lib/snmp/src/manager/snmpm.erl
@@ -57,15 +57,16 @@
usm_user_info/3, update_usm_user_info/4,
%%
- %% Basic SNMP API
- sync_get/3, sync_get/4, sync_get/5, sync_get/6,
- async_get/3, async_get/4, async_get/5, async_get/6,
- sync_get_next/3, sync_get_next/4, sync_get_next/5, sync_get_next/6,
- async_get_next/3, async_get_next/4, async_get_next/5, async_get_next/6,
- sync_set/3, sync_set/4, sync_set/5, sync_set/6,
- async_set/3, async_set/4, async_set/5, async_set/6,
- sync_get_bulk/5, sync_get_bulk/6, sync_get_bulk/7, sync_get_bulk/8,
- async_get_bulk/5, async_get_bulk/6, async_get_bulk/7, async_get_bulk/8,
+ %% Basic SNMP API (version "3").
+ sync_get2/3, sync_get2/4,
+ async_get2/3, async_get2/4,
+ sync_get_next2/3, sync_get_next2/4,
+ async_get_next2/3, async_get_next2/4,
+ sync_set2/3, sync_set2/4,
+ async_set2/3, async_set2/4,
+ sync_get_bulk2/5, sync_get_bulk2/6,
+ async_get_bulk2/5, async_get_bulk2/6,
+
cancel_async_request/2,
%%
@@ -91,7 +92,19 @@
-export([format_reason/1, format_reason/2]).
-%% Backward compatibillity exports
+%% Backward compatibillity exports (API version "2")
+-export([
+ sync_get/3, sync_get/4, sync_get/5, sync_get/6,
+ async_get/3, async_get/4, async_get/5, async_get/6,
+ sync_get_next/3, sync_get_next/4, sync_get_next/5, sync_get_next/6,
+ async_get_next/3, async_get_next/4, async_get_next/5, async_get_next/6,
+ sync_set/3, sync_set/4, sync_set/5, sync_set/6,
+ async_set/3, async_set/4, async_set/5, async_set/6,
+ sync_get_bulk/5, sync_get_bulk/6, sync_get_bulk/7, sync_get_bulk/8,
+ async_get_bulk/5, async_get_bulk/6, async_get_bulk/7, async_get_bulk/8
+ ]).
+
+%% Backward compatibillity exports (API version "1")
-deprecated({agent_info, 3}).
-deprecated({update_agent_info, 5}).
-deprecated({g, 3}).
@@ -145,12 +158,12 @@
-export([start_link/3, snmpm_start_verify/2, snmpm_start_verify/3]).
--include("snmp_debug.hrl").
+-include_lib("snmp/src/misc/snmp_debug.hrl").
+-include_lib("snmp/include/snmp_types.hrl").
-include("snmpm_atl.hrl").
--include("snmp_types.hrl").
+-include("snmpm_internal.hrl").
-define(DEFAULT_AGENT_PORT, 161).
--define(DEFAULT_CONTEXT, "").
%% This function is called when the snmp application
@@ -497,23 +510,37 @@ which_usm_users(EngineID) when is_list(EngineID) ->
%% --- synchroneous get-request ---
%%
-sync_get(UserId, TargetName, Oids) ->
- sync_get(UserId, TargetName, ?DEFAULT_CONTEXT, Oids).
+sync_get2(UserId, TargetName, Oids) ->
+ sync_get2(UserId, TargetName, Oids, []).
-sync_get(UserId, TargetName, Context, Oids) when is_list(Oids) ->
- snmpm_server:sync_get(UserId, TargetName, Context, Oids);
+sync_get2(UserId, TargetName, Oids, SendOpts)
+ when is_list(Oids) andalso is_list(SendOpts) ->
+ snmpm_server:sync_get2(UserId, TargetName, Oids, SendOpts).
-sync_get(UserId, TargetName, Oids, Timeout) when is_integer(Timeout) ->
- sync_get(UserId, TargetName, ?DEFAULT_CONTEXT, Oids, Timeout).
+%% <BACKWARD-COMPAT>
+sync_get(UserId, TargetName, Oids) ->
+ sync_get2(UserId, TargetName, Oids).
+
+sync_get(UserId, TargetName, Oids, Timeout)
+ when is_list(Oids) andalso is_integer(Timeout) ->
+ SendOpts = [{timeout, Timeout}],
+ sync_get2(UserId, TargetName, Oids, SendOpts);
+sync_get(UserId, TargetName, Context, [OH|_] = Oids)
+ when is_list(Context) andalso is_list(OH) ->
+ SendOpts = [{context, Context}],
+ sync_get2(UserId, TargetName, Oids, SendOpts).
sync_get(UserId, TargetName, Context, Oids, Timeout) ->
- snmpm_server:sync_get(UserId, TargetName, Context, Oids, Timeout).
+ SendOpts = [{context, Context}, {timeout, Timeout}],
+ sync_get2(UserId, TargetName, Oids, SendOpts).
sync_get(UserId, TargetName, Context, Oids, Timeout, ExtraInfo) ->
- snmpm_server:sync_get(UserId, TargetName, Context, Oids, Timeout,
- ExtraInfo).
+ SendOpts = [{context, Context}, {timeout, Timeout}, {extra, ExtraInfo}],
+ sync_get2(UserId, TargetName, Oids, SendOpts).
+%% </BACKWARD-COMPAT>
+%% <DEPRECATED>
g(UserId, Addr, Oids) ->
g(UserId, Addr, ?DEFAULT_AGENT_PORT, Oids).
@@ -559,6 +586,7 @@ g(UserId, Addr, Port, CtxName, Oids, Timeout, ExtraInfo) ->
Error ->
Error
end.
+%% </DEPRECATED>
@@ -568,23 +596,36 @@ g(UserId, Addr, Port, CtxName, Oids, Timeout, ExtraInfo) ->
%% through a call to handle_pdu/5
%%
-async_get(UserId, TargetName, Oids) ->
- async_get(UserId, TargetName, ?DEFAULT_CONTEXT, Oids).
+async_get2(UserId, TargetName, Oids) ->
+ async_get2(UserId, TargetName, Oids, []).
+
+async_get2(UserId, TargetName, Oids, SendOpts)
+ when is_list(Oids) andalso is_list(SendOpts) ->
+ snmpm_server:async_get2(UserId, TargetName, Oids, SendOpts).
-async_get(UserId, TargetName, Context, Oids) when is_list(Oids) ->
- snmpm_server:async_get(UserId, TargetName, Context, Oids);
+%% <BACKWARD-COMPAT>
+async_get(UserId, TargetName, Oids) ->
+ async_get2(UserId, TargetName, Oids).
async_get(UserId, TargetName, Oids, Expire) when is_integer(Expire) ->
- async_get(UserId, TargetName, ?DEFAULT_CONTEXT, Oids, Expire).
+ SendOpts = [{timeout, Expire}],
+ async_get2(UserId, TargetName, Oids, SendOpts);
+async_get(UserId, TargetName, Context, Oids)
+ when is_list(Context) andalso is_list(Oids) ->
+ SendOpts = [{context, Context}],
+ async_get2(UserId, TargetName, Oids, SendOpts).
async_get(UserId, TargetName, Context, Oids, Expire) ->
- snmpm_server:async_get(UserId, TargetName, Context, Oids, Expire).
+ SendOpts = [{timeout, Expire}, {context, Context}],
+ async_get2(UserId, TargetName, Oids, SendOpts).
async_get(UserId, TargetName, Context, Oids, Expire, ExtraInfo) ->
- snmpm_server:async_get(UserId, TargetName, Context, Oids, Expire,
- ExtraInfo).
+ SendOpts = [{timeout, Expire}, {context, Context}, {extra, ExtraInfo}],
+ async_get2(UserId, TargetName, Oids, SendOpts).
+%% </BACKWARD-COMPAT>
+%% <DEPRECATED>
ag(UserId, Addr, Oids) ->
ag(UserId, Addr, ?DEFAULT_AGENT_PORT, Oids).
@@ -629,31 +670,44 @@ ag(UserId, Addr, Port, CtxName, Oids, Expire, ExtraInfo) ->
Error ->
Error
end.
+%% </DEPRECATED>
%% --- synchroneous get_next-request ---
%%
-sync_get_next(UserId, TargetName, Oids) ->
- sync_get_next(UserId, TargetName, ?DEFAULT_CONTEXT, Oids).
+sync_get_next2(UserId, TargetName, Oids) ->
+ sync_get_next2(UserId, TargetName, Oids, []).
-sync_get_next(UserId, TargetName, Context, Oids)
- when is_list(Context) andalso is_list(Oids) ->
- snmpm_server:sync_get_next(UserId, TargetName, Context, Oids);
+sync_get_next2(UserId, TargetName, Oids, SendOpts)
+ when is_list(Oids) andalso is_list(SendOpts) ->
+ snmpm_server:sync_get_next2(UserId, TargetName, Oids, SendOpts).
+
+%% <BACKWARD-COMPAT>
+sync_get_next(UserId, TargetName, Oids) ->
+ sync_get_next2(UserId, TargetName, Oids).
sync_get_next(UserId, TargetName, Oids, Timeout)
when is_list(Oids) andalso is_integer(Timeout) ->
- sync_get_next(UserId, TargetName, ?DEFAULT_CONTEXT, Oids, Timeout).
+ SendOpts = [{timeout, Timeout}],
+ sync_get_next2(UserId, TargetName, Oids, SendOpts);
+sync_get_next(UserId, TargetName, Context, Oids)
+ when is_list(Context) andalso is_list(Oids) ->
+ SendOpts = [{context, Context}],
+ sync_get_next2(UserId, TargetName, Oids, SendOpts).
sync_get_next(UserId, TargetName, Context, Oids, Timeout) ->
- snmpm_server:sync_get_next(UserId, TargetName, Context, Oids, Timeout).
+ SendOpts = [{timeout, Timeout}, {context, Context}],
+ sync_get_next2(UserId, TargetName, Oids, SendOpts).
sync_get_next(UserId, TargetName, Context, Oids, Timeout, ExtraInfo) ->
- snmpm_server:sync_get_next(UserId, TargetName, Context, Oids, Timeout,
- ExtraInfo).
+ SendOpts = [{timeout, Timeout}, {context, Context}, {extra, ExtraInfo}],
+ sync_get_next2(UserId, TargetName, Oids, SendOpts).
+%% </BACKWARD-COMPAT>
+%% <DEPRECATED>
gn(UserId, Addr, Oids) ->
gn(UserId, Addr, ?DEFAULT_AGENT_PORT, Oids).
@@ -698,30 +752,44 @@ gn(UserId, Addr, Port, CtxName, Oids, Timeout, ExtraInfo) ->
Error ->
Error
end.
+%% </DEPRECATED>
%% --- asynchroneous get_next-request ---
%%
+async_get_next2(UserId, TargetName, Oids) ->
+ async_get_next2(UserId, TargetName, Oids, []).
+
+async_get_next2(UserId, TargetName, Oids, SendOpts)
+ when is_list(Oids) andalso is_list(SendOpts) ->
+ snmpm_server:async_get_next2(UserId, TargetName, Oids, SendOpts).
+
+%% <BACKWARD-COMPAT>
async_get_next(UserId, TargetName, Oids) ->
- async_get_next(UserId, TargetName, ?DEFAULT_CONTEXT, Oids).
+ async_get_next2(UserId, TargetName, Oids).
+async_get_next(UserId, TargetName, Oids, Expire)
+ when is_list(Oids) andalso is_integer(Expire) ->
+ SendOpts = [{timeout, Expire}],
+ async_get_next2(UserId, TargetName, Oids, SendOpts);
async_get_next(UserId, TargetName, Context, Oids)
when is_list(Context) andalso is_list(Oids) ->
- snmpm_server:async_get_next(UserId, TargetName, Context, Oids);
+ SendOpts = [{context, Context}],
+ async_get_next2(UserId, TargetName, Oids, SendOpts).
-async_get_next(UserId, TargetName, Oids, Timeout)
- when is_list(Oids) andalso is_integer(Timeout) ->
- async_get_next(UserId, TargetName, ?DEFAULT_CONTEXT, Oids, Timeout).
+async_get_next(UserId, TargetName, Context, Oids, Expire) ->
+ SendOpts = [{timeout, Expire}, {context, Context}],
+ async_get_next2(UserId, TargetName, Oids, SendOpts).
-async_get_next(UserId, TargetName, Context, Oids, Timeout) ->
- snmpm_server:async_get_next(UserId, TargetName, Context, Oids, Timeout).
+async_get_next(UserId, TargetName, Context, Oids, Expire, ExtraInfo) ->
+ SendOpts = [{timeout, Expire}, {context, Context}, {extra, ExtraInfo}],
+ async_get_next2(UserId, TargetName, Oids, SendOpts).
+%% </BACKWARD-COMPAT>
-async_get_next(UserId, TargetName, Context, Oids, Timeout, ExtraInfo) ->
- snmpm_server:async_get_next(UserId, TargetName, Context, Oids, Timeout,
- ExtraInfo).
+%% <DEPRECATED>
agn(UserId, Addr, Oids) ->
agn(UserId, Addr, ?DEFAULT_AGENT_PORT, Oids).
@@ -767,31 +835,44 @@ agn(UserId, Addr, Port, CtxName, Oids, Expire, ExtraInfo) ->
Error ->
Error
end.
+%% </DEPRECATED>
%% --- synchroneous set-request ---
%%
-sync_set(UserId, TargetName, VarsAndVals) ->
- sync_set(UserId, TargetName, ?DEFAULT_CONTEXT, VarsAndVals).
+sync_set2(UserId, TargetName, VarsAndVals) ->
+ sync_set2(UserId, TargetName, VarsAndVals, []).
-sync_set(UserId, TargetName, Context, VarsAndVals)
- when is_list(Context) andalso is_list(VarsAndVals) ->
- snmpm_server:sync_set(UserId, TargetName, Context, VarsAndVals);
+sync_set2(UserId, TargetName, VarsAndVals, SendOpts)
+ when is_list(VarsAndVals) andalso is_list(SendOpts) ->
+ snmpm_server:sync_set2(UserId, TargetName, VarsAndVals, SendOpts).
+
+%% <BACKWARD-COMPAT>
+sync_set(UserId, TargetName, VarsAndVals) ->
+ sync_set2(UserId, TargetName, VarsAndVals).
sync_set(UserId, TargetName, VarsAndVals, Timeout)
when is_list(VarsAndVals) andalso is_integer(Timeout) ->
- sync_set(UserId, TargetName, ?DEFAULT_CONTEXT, VarsAndVals, Timeout).
+ SendOpts = [{timeout, Timeout}],
+ sync_set2(UserId, TargetName, VarsAndVals, SendOpts);
+sync_set(UserId, TargetName, Context, VarsAndVals)
+ when is_list(Context) andalso is_list(VarsAndVals) ->
+ SendOpts = [{context, Context}],
+ sync_set2(UserId, TargetName, VarsAndVals, SendOpts).
sync_set(UserId, TargetName, Context, VarsAndVals, Timeout) ->
- snmpm_server:sync_set(UserId, TargetName, Context, VarsAndVals, Timeout).
+ SendOpts = [{timeout, Timeout}, {context, Context}],
+ sync_set2(UserId, TargetName, VarsAndVals, SendOpts).
sync_set(UserId, TargetName, Context, VarsAndVals, Timeout, ExtraInfo) ->
- snmpm_server:sync_set(UserId, TargetName, Context, VarsAndVals, Timeout,
- ExtraInfo).
+ SendOpts = [{timeout, Timeout}, {context, Context}, {extra, ExtraInfo}],
+ sync_set2(UserId, TargetName, VarsAndVals, SendOpts).
+%% </BACKWARD-COMPAT>
+%% <DEPRECATED>
s(UserId, Addr, VarsAndVals) ->
s(UserId, Addr, ?DEFAULT_AGENT_PORT, VarsAndVals).
@@ -845,31 +926,44 @@ s(UserId, Addr, Port, CtxName, VarsAndVals, Timeout, ExtraInfo) ->
Error ->
Error
end.
+%% </DEPRECATED>
%% --- asynchroneous set-request ---
%%
-async_set(UserId, TargetName, VarsAndVals) ->
- async_set(UserId, TargetName, ?DEFAULT_CONTEXT, VarsAndVals).
+async_set2(UserId, TargetName, VarsAndVals) ->
+ async_set2(UserId, TargetName, VarsAndVals, []).
-async_set(UserId, TargetName, Context, VarsAndVals)
- when is_list(Context) andalso is_list(VarsAndVals) ->
- snmpm_server:async_set(UserId, TargetName, Context, VarsAndVals);
+async_set2(UserId, TargetName, VarsAndVals, SendOpts)
+ when is_list(VarsAndVals) andalso is_list(SendOpts) ->
+ snmpm_server:async_set2(UserId, TargetName, VarsAndVals, SendOpts).
+
+%% <BACKWARD-COMPAT>
+async_set(UserId, TargetName, VarsAndVals) ->
+ async_set2(UserId, TargetName, VarsAndVals).
async_set(UserId, TargetName, VarsAndVals, Expire)
when is_list(VarsAndVals) andalso is_integer(Expire) ->
- async_set(UserId, TargetName, ?DEFAULT_CONTEXT, VarsAndVals, Expire).
+ SendOpts = [{timeout, Expire}],
+ async_set2(UserId, TargetName, VarsAndVals, SendOpts);
+async_set(UserId, TargetName, Context, VarsAndVals)
+ when is_list(Context) andalso is_list(VarsAndVals) ->
+ SendOpts = [{context, Context}],
+ async_set2(UserId, TargetName, VarsAndVals, SendOpts).
async_set(UserId, TargetName, Context, VarsAndVals, Expire) ->
- snmpm_server:async_set(UserId, TargetName, Context, VarsAndVals, Expire).
+ SendOpts = [{timeout, Expire}, {context, Context}],
+ async_set2(UserId, TargetName, VarsAndVals, SendOpts).
async_set(UserId, TargetName, Context, VarsAndVals, Expire, ExtraInfo) ->
- snmpm_server:async_set(UserId, TargetName, Context, VarsAndVals, Expire,
- ExtraInfo).
+ SendOpts = [{timeout, Expire}, {context, Context}, {extra, ExtraInfo}],
+ async_set2(UserId, TargetName, VarsAndVals, SendOpts).
+%% </BACKWARD-COMPAT>
+%% <DEPRECATED>
as(UserId, Addr, VarsAndVals) ->
as(UserId, Addr, ?DEFAULT_AGENT_PORT, VarsAndVals).
@@ -923,44 +1017,77 @@ as(UserId, Addr, Port, CtxName, VarsAndVals, Expire, ExtraInfo) ->
Error ->
Error
end.
-
-
+%% </DEPRECATED>
%% --- synchroneous get-bulk ---
%%
-sync_get_bulk(UserId, TargetName, NonRep, MaxRep, Oids) ->
- sync_get_bulk(UserId, TargetName, NonRep, MaxRep, ?DEFAULT_CONTEXT, Oids).
+sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids) ->
+ sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, []).
-sync_get_bulk(UserId, TargetName, NonRep, MaxRep, Context, Oids)
+sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts)
when is_integer(NonRep) andalso
is_integer(MaxRep) andalso
- is_list(Context) andalso
- is_list(Oids) ->
- snmpm_server:sync_get_bulk(UserId, TargetName,
- NonRep, MaxRep,
- Context, Oids);
+ is_list(Oids) andalso
+ is_list(SendOpts) ->
+ %% p("sync_get_bulk -> entry with"
+ %% "~n UserId: ~p"
+ %% "~n TargetName: ~p"
+ %% "~n NonRep: ~p"
+ %% "~n MaxRep: ~p"
+ %% "~n Oids: ~p"
+ %% "~n SendOpts: ~p",
+ %% [UserId, TargetName, NonRep, MaxRep, Oids, SendOpts]),
+ snmpm_server:sync_get_bulk2(UserId, TargetName,
+ NonRep, MaxRep, Oids, SendOpts).
+
+%% <BACKWARD-COMPAT>
+sync_get_bulk(UserId, TargetName, NonRep, MaxRep, Oids) ->
+ sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids).
sync_get_bulk(UserId, TargetName, NonRep, MaxRep, Oids, Timeout)
when is_integer(NonRep) andalso
is_integer(MaxRep) andalso
is_list(Oids) andalso
is_integer(Timeout) ->
- sync_get_bulk(UserId, TargetName, NonRep, MaxRep,
- ?DEFAULT_CONTEXT, Oids, Timeout).
+ SendOpts = [{timeout, Timeout}],
+ sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts);
+sync_get_bulk(UserId, TargetName, NonRep, MaxRep, Context, Oids)
+ when is_integer(NonRep) andalso
+ is_integer(MaxRep) andalso
+ is_list(Context) andalso
+ is_list(Oids) ->
+ %% p("sync_get_bulk -> entry with"
+ %% "~n UserId: ~p"
+ %% "~n TargetName: ~p"
+ %% "~n NonRep: ~p"
+ %% "~n MaxRep: ~p"
+ %% "~n Context: ~p"
+ %% "~n Oids: ~p", [UserId, TargetName, NonRep, MaxRep, Context, Oids]),
+ SendOpts = [{context, Context}],
+ sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts).
sync_get_bulk(UserId, TargetName, NonRep, MaxRep, Context, Oids, Timeout) ->
- snmpm_server:sync_get_bulk(UserId, TargetName, NonRep, MaxRep,
- Context, Oids, Timeout).
+ SendOpts = [{timeout, Timeout}, {context, Context}],
+ sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts).
sync_get_bulk(UserId, TargetName, NonRep, MaxRep, Context, Oids, Timeout,
ExtraInfo) ->
- snmpm_server:sync_get_bulk(UserId, TargetName, NonRep, MaxRep,
- Context, Oids, Timeout, ExtraInfo).
+ SendOpts = [{timeout, Timeout}, {context, Context}, {extra, ExtraInfo}],
+ sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts).
+%% </BACKWARD-COMPAT>
+%% <DEPRECATED>
gb(UserId, Addr, NonRep, MaxRep, Oids) ->
+ %% p("gb -> entry with"
+ %% "~n UserId: ~p"
+ %% "~n Addr: ~p"
+ %% "~n NonRep: ~p"
+ %% "~n MaxRep: ~p"
+ %% "~n Oids: ~p",
+ %% [UserId, Addr, NonRep, MaxRep, Oids]),
gb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, Oids).
gb(UserId, Addr, Port, NonRep, MaxRep, Oids)
@@ -968,6 +1095,14 @@ gb(UserId, Addr, Port, NonRep, MaxRep, Oids)
is_integer(NonRep) andalso
is_integer(MaxRep) andalso
is_list(Oids) ->
+ %% p("gb -> entry with"
+ %% "~n UserId: ~p"
+ %% "~n Addr: ~p"
+ %% "~n Port: ~p"
+ %% "~n NonRep: ~p"
+ %% "~n MaxRep: ~p"
+ %% "~n Oids: ~p",
+ %% [UserId, Addr, Port, NonRep, MaxRep, Oids]),
gb(UserId, Addr, Port, NonRep, MaxRep, ?DEFAULT_CONTEXT, Oids);
gb(UserId, Addr, NonRep, MaxRep, CtxName, Oids)
@@ -975,6 +1110,14 @@ gb(UserId, Addr, NonRep, MaxRep, CtxName, Oids)
is_integer(MaxRep) andalso
is_list(CtxName) andalso
is_list(Oids) ->
+ %% p("gb -> entry with"
+ %% "~n UserId: ~p"
+ %% "~n Addr: ~p"
+ %% "~n NonRep: ~p"
+ %% "~n MaxRep: ~p"
+ %% "~n CtxName: ~p"
+ %% "~n Oids: ~p",
+ %% [UserId, Addr, NonRep, MaxRep, CtxName, Oids]),
gb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, CtxName, Oids);
gb(UserId, Addr, NonRep, MaxRep, Oids, Timeout)
@@ -982,6 +1125,14 @@ gb(UserId, Addr, NonRep, MaxRep, Oids, Timeout)
is_integer(MaxRep) andalso
is_list(Oids) andalso
is_integer(Timeout) ->
+ %% p("gb -> entry with"
+ %% "~n UserId: ~p"
+ %% "~n Addr: ~p"
+ %% "~n NonRep: ~p"
+ %% "~n MaxRep: ~p"
+ %% "~n Oids: ~p"
+ %% "~n Timeout: ~p",
+ %% [UserId, Addr, NonRep, MaxRep, Oids, Timeout]),
gb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, Oids, Timeout).
gb(UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids)
@@ -990,8 +1141,18 @@ gb(UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids)
is_integer(MaxRep) andalso
is_list(CtxName) andalso
is_list(Oids) ->
+ %% p("gb -> entry with"
+ %% "~n UserId: ~p"
+ %% "~n Addr: ~p"
+ %% "~n Port: ~p"
+ %% "~n NonRep: ~p"
+ %% "~n MaxRep: ~p"
+ %% "~n CtxName: ~p"
+ %% "~n Oids: ~p",
+ %% [UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids]),
case target_name(Addr, Port) of
{ok, TargetName} ->
+ %% p("gb -> TargetName: ~p", [TargetName]),
sync_get_bulk(UserId, TargetName, NonRep, MaxRep, CtxName, Oids);
Error ->
Error
@@ -1003,6 +1164,15 @@ gb(UserId, Addr, Port, NonRep, MaxRep, Oids, Timeout)
is_integer(MaxRep) andalso
is_list(Oids) andalso
is_integer(Timeout) ->
+ %% p("gb -> entry with"
+ %% "~n UserId: ~p"
+ %% "~n Addr: ~p"
+ %% "~n Port: ~p"
+ %% "~n NonRep: ~p"
+ %% "~n MaxRep: ~p"
+ %% "~n Oids: ~p"
+ %% "~n Timeout: ~p",
+ %% [UserId, Addr, Port, NonRep, MaxRep, Oids, Timeout]),
gb(UserId, Addr, Port, NonRep, MaxRep, ?DEFAULT_CONTEXT, Oids, Timeout);
gb(UserId, Addr, NonRep, MaxRep, CtxName, Oids, Timeout)
@@ -1011,10 +1181,29 @@ gb(UserId, Addr, NonRep, MaxRep, CtxName, Oids, Timeout)
is_list(CtxName) andalso
is_list(Oids) andalso
is_integer(Timeout) ->
+ %% p("gb -> entry with"
+ %% "~n UserId: ~p"
+ %% "~n Addr: ~p"
+ %% "~n NonRep: ~p"
+ %% "~n MaxRep: ~p"
+ %% "~n CtxName: ~p"
+ %% "~n Oids: ~p"
+ %% "~n Timeout: ~p",
+ %% [UserId, Addr, NonRep, MaxRep, CtxName, Oids, Timeout]),
gb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, CtxName, Oids,
Timeout).
gb(UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids, Timeout) ->
+ %% p("gb -> entry with"
+ %% "~n UserId: ~p"
+ %% "~n Addr: ~p"
+ %% "~n Port: ~p"
+ %% "~n NonRep: ~p"
+ %% "~n MaxRep: ~p"
+ %% "~n CtxName: ~p"
+ %% "~n Oids: ~p"
+ %% "~n Timeout: ~p",
+ %% [UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids, Timeout]),
case target_name(Addr, Port) of
{ok, TargetName} ->
sync_get_bulk(UserId, TargetName,
@@ -1024,6 +1213,17 @@ gb(UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids, Timeout) ->
end.
gb(UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids, Timeout, ExtraInfo) ->
+ %% p("gb -> entry with"
+ %% "~n UserId: ~p"
+ %% "~n Addr: ~p"
+ %% "~n Port: ~p"
+ %% "~n NonRep: ~p"
+ %% "~n MaxRep: ~p"
+ %% "~n CtxName: ~p"
+ %% "~n Oids: ~p"
+ %% "~n Timeout: ~p"
+ %% "~n ExtraInfo: ~p",
+ %% [UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids, Timeout, ExtraInfo]),
case target_name(Addr, Port) of
{ok, TargetName} ->
sync_get_bulk(UserId, TargetName,
@@ -1031,42 +1231,55 @@ gb(UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids, Timeout, ExtraInfo) ->
Error ->
Error
end.
+%% </DEPRECATED>
%% --- asynchroneous get-bulk ---
%%
-async_get_bulk(UserId, TargetName, NonRep, MaxRep, Oids) ->
- async_get_bulk(UserId, TargetName, NonRep, MaxRep, ?DEFAULT_CONTEXT, Oids).
+async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids) ->
+ async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, []).
-async_get_bulk(UserId, TargetName, NonRep, MaxRep, Context, Oids)
+async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts)
when is_integer(NonRep) andalso
is_integer(MaxRep) andalso
- is_list(Context) andalso
- is_list(Oids) ->
- snmpm_server:async_get_bulk(UserId, TargetName,
- NonRep, MaxRep, Context, Oids);
+ is_list(Oids) andalso
+ is_list(SendOpts) ->
+ snmpm_server:async_get_bulk2(UserId, TargetName,
+ NonRep, MaxRep, Oids, SendOpts).
+
+%% <BACKWARD-COMPAT>
+async_get_bulk(UserId, TargetName, NonRep, MaxRep, Oids) ->
+ async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids).
async_get_bulk(UserId, TargetName, NonRep, MaxRep, Oids, Expire)
when is_integer(NonRep) andalso
is_integer(MaxRep) andalso
is_list(Oids) andalso
is_integer(Expire) ->
- async_get_bulk(UserId, TargetName,
- NonRep, MaxRep, ?DEFAULT_CONTEXT, Oids, Expire).
+ SendOpts = [{timeout, Expire}],
+ async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts);
+async_get_bulk(UserId, TargetName, NonRep, MaxRep, Context, Oids)
+ when is_integer(NonRep) andalso
+ is_integer(MaxRep) andalso
+ is_list(Context) andalso
+ is_list(Oids) ->
+ SendOpts = [{context, Context}],
+ async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts).
async_get_bulk(UserId, TargetName, NonRep, MaxRep, Context, Oids, Expire) ->
- snmpm_server:async_get_bulk(UserId, TargetName,
- NonRep, MaxRep, Context, Oids, Expire).
+ SendOpts = [{timeout, Expire}, {context, Context}],
+ async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts).
async_get_bulk(UserId, TargetName, NonRep, MaxRep, Context, Oids, Expire,
ExtraInfo) ->
- snmpm_server:async_get_bulk(UserId, TargetName,
- NonRep, MaxRep,
- Context, Oids, Expire, ExtraInfo).
+ SendOpts = [{timeout, Expire}, {context, Context}, {extra, ExtraInfo}],
+ async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts).
+%% </BACKWARD-COMPAT>
+%% <DEPRECATED>
agb(UserId, Addr, NonRep, MaxRep, Oids) ->
agb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, Oids).
@@ -1139,6 +1352,7 @@ agb(UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids, Expire, ExtraInfo) ->
Error ->
Error
end.
+%% </DEPRECATED>
cancel_async_request(UserId, ReqId) ->
diff --git a/lib/snmp/src/manager/snmpm_internal.hrl b/lib/snmp/src/manager/snmpm_internal.hrl
index 5d9b32e3f6..53ad41c6b0 100644
--- a/lib/snmp/src/manager/snmpm_internal.hrl
+++ b/lib/snmp/src/manager/snmpm_internal.hrl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2006-2009. All Rights Reserved.
+%% Copyright Ericsson AB 2006-2011. 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
@@ -20,6 +20,11 @@
-ifndef(snmpm_internal).
-define(snmpm_internal, true).
+-define(DEFAULT_CONTEXT, "").
+-define(SNMPM_EXTRA_INFO_TAG, snmpm_extra_info_tag).
+-define(DEFAULT_EXTRA_INFO, {?SNMPM_EXTRA_INFO_TAG}).
+
+
-include_lib("snmp/src/app/snmp_internal.hrl").
-define(snmpm_info(F, A), ?snmp_info("manager", F, A)).
diff --git a/lib/snmp/src/manager/snmpm_net_if.erl b/lib/snmp/src/manager/snmpm_net_if.erl
index 07156dacd9..3d248fff57 100644
--- a/lib/snmp/src/manager/snmpm_net_if.erl
+++ b/lib/snmp/src/manager/snmpm_net_if.erl
@@ -99,7 +99,7 @@ stop(Pid) ->
call(Pid, stop).
send_pdu(Pid, Pdu, Vsn, MsgData, Addr, Port) ->
- send_pdu(Pid, Pdu, Vsn, MsgData, Addr, Port, undefined).
+ send_pdu(Pid, Pdu, Vsn, MsgData, Addr, Port, ?DEFAULT_EXTRA_INFO).
send_pdu(Pid, Pdu, Vsn, MsgData, Addr, Port, ExtraInfo)
when is_record(Pdu, pdu) ->
@@ -380,13 +380,14 @@ handle_call(Req, From, State) ->
%% {noreply, State, Timeout} |
%% {stop, Reason, State} (terminate/2 is called)
%%--------------------------------------------------------------------
-handle_cast({send_pdu, Pdu, Vsn, MsgData, Addr, Port, _ExtraInfo}, State) ->
+handle_cast({send_pdu, Pdu, Vsn, MsgData, Addr, Port, ExtraInfo}, State) ->
?vlog("received send_pdu message with"
"~n Pdu: ~p"
"~n Vsn: ~p"
"~n MsgData: ~p"
"~n Addr: ~p"
"~n Port: ~p", [Pdu, Vsn, MsgData, Addr, Port]),
+ maybe_process_extra_info(ExtraInfo),
maybe_handle_send_pdu(Pdu, Vsn, MsgData, Addr, Port, State),
{noreply, State};
@@ -999,6 +1000,19 @@ pdu_type_of(TrapPdu) when is_record(TrapPdu, trappdu) ->
%% -------------------------------------------------------------------
+%% 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).
diff --git a/lib/snmp/src/manager/snmpm_server.erl b/lib/snmp/src/manager/snmpm_server.erl
index d64b5b1d53..b8d7cf6375 100644
--- a/lib/snmp/src/manager/snmpm_server.erl
+++ b/lib/snmp/src/manager/snmpm_server.erl
@@ -32,14 +32,14 @@
register_user/4, register_user_monitor/4, unregister_user/1,
- sync_get/4, sync_get/5, sync_get/6,
- async_get/4, async_get/5, async_get/6,
- sync_get_next/4, sync_get_next/5, sync_get_next/6,
- async_get_next/4, async_get_next/5, async_get_next/6,
- sync_get_bulk/6, sync_get_bulk/7, sync_get_bulk/8,
- async_get_bulk/6, async_get_bulk/7, async_get_bulk/8,
- sync_set/4, sync_set/5, sync_set/6,
- async_set/4, async_set/5, async_set/6,
+ sync_get2/4,
+ async_get2/4,
+ sync_get_next2/4,
+ async_get_next2/4,
+ sync_get_bulk2/6,
+ async_get_bulk2/6,
+ sync_set2/4,
+ async_set2/4,
cancel_async_request/2,
%% discovery/2, discovery/3, discovery/4, discovery/5, discovery/6,
@@ -55,6 +55,20 @@
]).
+%% <BACKWARD-COMPAT>
+-export([sync_get/4, sync_get/5, sync_get/6,
+ async_get/4, async_get/5, async_get/6,
+ sync_get_next/4, sync_get_next/5, sync_get_next/6,
+ async_get_next/4, async_get_next/5, async_get_next/6,
+ sync_get_bulk/6, sync_get_bulk/7, sync_get_bulk/8,
+ async_get_bulk/6, async_get_bulk/7, async_get_bulk/8,
+ sync_set/4, sync_set/5, sync_set/6,
+ async_set/4, async_set/5, async_set/6
+ ]).
+%% </BACKWARD-COMPAT>
+
+
+
%% Internal exports
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
code_change/3, terminate/2]).
@@ -75,13 +89,39 @@
-define(SERVER, ?MODULE).
--define(SYNC_GET_TIMEOUT, 5000).
--define(SYNC_SET_TIMEOUT, 5000).
--define(DEFAULT_ASYNC_EXPIRE, 5000).
--define(EXTRA_INFO, undefined).
-
--define(SNMP_AGENT_PORT, 161).
-
+-define(DEFAULT_SYNC_TIMEOUT, timer:seconds(5)).
+-define(DEFAULT_SYNC_GET_TIMEOUT, ?DEFAULT_SYNC_TIMEOUT).
+-define(DEFAULT_SYNC_GET_NEXT_TIMEOUT, ?DEFAULT_SYNC_TIMEOUT).
+-define(DEFAULT_SYNC_GET_BULK_TIMEOUT, ?DEFAULT_SYNC_TIMEOUT).
+-define(DEFAULT_SYNC_SET_TIMEOUT, ?DEFAULT_SYNC_TIMEOUT).
+
+-define(DEFAULT_ASYNC_TIMEOUT, timer:seconds(5)).
+-define(DEFAULT_ASYNC_GET_TIMEOUT, ?DEFAULT_ASYNC_TIMEOUT).
+-define(DEFAULT_ASYNC_GET_NEXT_TIMEOUT, ?DEFAULT_ASYNC_TIMEOUT).
+-define(DEFAULT_ASYNC_GET_BULK_TIMEOUT, ?DEFAULT_ASYNC_TIMEOUT).
+-define(DEFAULT_ASYNC_SET_TIMEOUT, ?DEFAULT_ASYNC_TIMEOUT).
+
+-define(SNMP_AGENT_PORT, 161).
+
+-define(SYNC_GET_TIMEOUT(SendOpts),
+ get_opt(timeout, ?DEFAULT_SYNC_GET_TIMEOUT, SendOpts)).
+-define(SYNC_GET_NEXT_TIMEOUT(SendOpts),
+ get_opt(timeout, ?DEFAULT_SYNC_GET_NEXT_TIMEOUT, SendOpts)).
+-define(SYNC_GET_BULK_TIMEOUT(SendOpts),
+ get_opt(timeout, ?DEFAULT_SYNC_GET_BULK_TIMEOUT, SendOpts)).
+-define(SYNC_SET_TIMEOUT(SendOpts),
+ get_opt(timeout, ?DEFAULT_SYNC_SET_TIMEOUT, SendOpts)).
+
+-define(ASYNC_GET_TIMEOUT(SendOpts),
+ get_opt(timeout, ?DEFAULT_ASYNC_GET_TIMEOUT, SendOpts)).
+-define(ASYNC_GET_NEXT_TIMEOUT(SendOpts),
+ get_opt(timeout, ?DEFAULT_ASYNC_GET_NEXT_TIMEOUT, SendOpts)).
+-define(ASYNC_GET_BULK_TIMEOUT(SendOpts),
+ get_opt(timeout, ?DEFAULT_ASYNC_GET_BULK_TIMEOUT, SendOpts)).
+-define(ASYNC_SET_TIMEOUT(SendOpts),
+ get_opt(timeout, ?DEFAULT_ASYNC_SET_TIMEOUT, SendOpts)).
+
+-define(GET_EXTRA(SendOpts), get_opt(extra, ?DEFAULT_EXTRA_INFO, SendOpts)).
-ifdef(snmp_debug).
-define(GS_START_LINK(Args),
@@ -192,82 +232,140 @@ unregister_user(UserId) ->
%% -- [sync] get --
+%% The reason why we have a sync_get2 is to simplify backward
+%% compatibillity.
+
+%% sync_get2(UserId, TargetName, Oids) ->
+%% sync_get2(UserId, TargetName, Oids, []).
+sync_get2(UserId, TargetName, Oids, Opts) ->
+ call({sync_get, self(), UserId, TargetName, Oids, Opts}).
+
+
+%% <BACKWARD-COMPAT>
sync_get(UserId, TargetName, CtxName, Oids) ->
sync_get(UserId, TargetName, CtxName, Oids,
- ?SYNC_GET_TIMEOUT).
+ ?DEFAULT_SYNC_GET_TIMEOUT).
sync_get(UserId, TargetName, CtxName, Oids, Timeout) ->
- sync_get(UserId, TargetName, CtxName, Oids, Timeout, ?EXTRA_INFO).
+ sync_get(UserId, TargetName, CtxName, Oids, Timeout, ?DEFAULT_EXTRA_INFO).
sync_get(UserId, TargetName, CtxName, Oids, Timeout, ExtraInfo)
when is_list(TargetName) andalso
is_list(CtxName) andalso
is_list(Oids) andalso
is_integer(Timeout) ->
- call({sync_get, self(), UserId, TargetName, CtxName, Oids, Timeout, ExtraInfo}).
+ Opts = [{context, CtxName}, {timeout, Timeout}, {extra, ExtraInfo}],
+ sync_get2(UserId, TargetName, Oids, Opts).
+%% </BACKWARD-COMPAT>
+
+
%% -- [async] get --
+%% async_get2(UserId, TargetName, Oids) ->
+%% async_get2(UserId, TargetName, Oids, []).
+async_get2(UserId, TargetName, Oids, SendOpts) ->
+ call({async_get, self(), UserId, TargetName, Oids, SendOpts}).
+
+
+%% <BACKWARD-COMPAT>
async_get(UserId, TargetName, CtxName, Oids) ->
async_get(UserId, TargetName, CtxName, Oids,
- ?DEFAULT_ASYNC_EXPIRE, ?EXTRA_INFO).
+ ?DEFAULT_ASYNC_GET_TIMEOUT, ?DEFAULT_EXTRA_INFO).
async_get(UserId, TargetName, CtxName, Oids, Expire) ->
- async_get(UserId, TargetName, CtxName, Oids, Expire, ?EXTRA_INFO).
+ async_get(UserId, TargetName, CtxName, Oids, Expire, ?DEFAULT_EXTRA_INFO).
async_get(UserId, TargetName, CtxName, Oids, Expire, ExtraInfo)
when (is_list(TargetName) andalso
is_list(CtxName) andalso
is_list(Oids) andalso
is_integer(Expire) andalso (Expire >= 0)) ->
- call({async_get, self(), UserId, TargetName, CtxName, Oids, Expire,
- ExtraInfo}).
+ SendOpts = [{context, CtxName}, {expire, Expire}, {extra, ExtraInfo}],
+ async_get2(UserId, TargetName, Oids, SendOpts).
+%% </BACKWARD-COMPAT>
+
+
%% -- [sync] get-next --
+%% sync_get_next2(UserId, TargetName, Oids) ->
+%% sync_get_next2(UserId, TargetName, Oids, []).
+sync_get_next2(UserId, TargetName, Oids, SendOpts) ->
+ call({sync_get_next, self(), UserId, TargetName, Oids, SendOpts}).
+
+
+%% <BACKWARD-COMPAT>
sync_get_next(UserId, TargetName, CtxName, Oids) ->
- sync_get_next(UserId, TargetName, CtxName, Oids, ?SYNC_GET_TIMEOUT,
- ?EXTRA_INFO).
+ sync_get_next(UserId, TargetName, CtxName, Oids,
+ ?DEFAULT_SYNC_GET_TIMEOUT, ?DEFAULT_EXTRA_INFO).
sync_get_next(UserId, TargetName, CtxName, Oids, Timeout) ->
- sync_get_next(UserId, TargetName, CtxName, Oids, Timeout, ?EXTRA_INFO).
+ sync_get_next(UserId, TargetName, CtxName, Oids, Timeout,
+ ?DEFAULT_EXTRA_INFO).
sync_get_next(UserId, TargetName, CtxName, Oids, Timeout, ExtraInfo)
when is_list(TargetName) andalso
is_list(CtxName) andalso
is_list(Oids) andalso
is_integer(Timeout) ->
- call({sync_get_next, self(), UserId, TargetName, CtxName, Oids, Timeout,
- ExtraInfo}).
+ SendOpts = [{context, CtxName}, {timeout, Timeout}, {extra, ExtraInfo}],
+ sync_get_next2(UserId, TargetName, Oids, SendOpts).
+%% <BACKWARD-COMPAT>
+
+
%% -- [async] get-next --
+%% async_get_next2(UserId, TargetName, Oids) ->
+%% async_get_next2(UserId, TargetName, Oids, []).
+async_get_next2(UserId, TargetName, Oids, SendOpts) ->
+ call({async_get_next, self(), UserId, TargetName, Oids, SendOpts}).
+
+
async_get_next(UserId, TargetName, CtxName, Oids) ->
async_get_next(UserId, TargetName, CtxName, Oids,
- ?DEFAULT_ASYNC_EXPIRE, ?EXTRA_INFO).
+ ?DEFAULT_ASYNC_GET_NEXT_TIMEOUT, ?DEFAULT_EXTRA_INFO).
async_get_next(UserId, TargetName, CtxName, Oids, Expire) ->
- async_get_next(UserId, TargetName, CtxName, Oids, Expire, ?EXTRA_INFO).
+ async_get_next(UserId, TargetName, CtxName, Oids, Expire,
+ ?DEFAULT_EXTRA_INFO).
async_get_next(UserId, TargetName, CtxName, Oids, Expire, ExtraInfo)
when (is_list(TargetName) andalso
is_list(CtxName) andalso
is_list(Oids) andalso
is_integer(Expire) andalso (Expire >= 0)) ->
- call({async_get_next, self(), UserId, TargetName, CtxName, Oids,
- Expire, ExtraInfo}).
+ SendOpts = [{context, CtxName}, {expire, Expire}, {extra, ExtraInfo}],
+ async_get_next2(UserId, TargetName, Oids, SendOpts).
+
+
%% -- [sync] get-bulk --
+%% sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids) ->
+%% sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, []).
+sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts) ->
+ %% p("sync_get_bulk2 -> entry with"
+ %% "~n UserId: ~p"
+ %% "~n TargetName: ~p"
+ %% "~n NonRep: ~p"
+ %% "~n MaxRep: ~p"
+ %% "~n Oids: ~p"
+ %% "~n SendOpts: ~p",
+ %% [UserId, TargetName, NonRep, MaxRep, Oids, SendOpts]),
+ call({sync_get_bulk, self(), UserId, TargetName,
+ NonRep, MaxRep, Oids, SendOpts}).
+
sync_get_bulk(UserId, TargetName, NonRep, MaxRep, CtxName, Oids) ->
sync_get_bulk(UserId, TargetName,
NonRep, MaxRep, CtxName, Oids,
- ?SYNC_GET_TIMEOUT, ?EXTRA_INFO).
+ ?DEFAULT_SYNC_GET_TIMEOUT, ?DEFAULT_EXTRA_INFO).
sync_get_bulk(UserId, TargetName, NonRep, MaxRep, CtxName, Oids, Timeout) ->
sync_get_bulk(UserId, TargetName,
NonRep, MaxRep, CtxName, Oids,
- Timeout, ?EXTRA_INFO).
+ Timeout, ?DEFAULT_EXTRA_INFO).
sync_get_bulk(UserId, TargetName, NonRep, MaxRep, CtxName, Oids, Timeout,
ExtraInfo)
@@ -277,20 +375,28 @@ sync_get_bulk(UserId, TargetName, NonRep, MaxRep, CtxName, Oids, Timeout,
is_list(CtxName) andalso
is_list(Oids) andalso
is_integer(Timeout) ->
- call({sync_get_bulk, self(), UserId, TargetName,
- NonRep, MaxRep, CtxName, Oids, Timeout, ExtraInfo}).
+ SendOpts = [{context, CtxName}, {timeout, Timeout}, {extra, ExtraInfo}],
+ sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts).
+
%% -- [async] get-bulk --
+%% async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids) ->
+%% async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, []).
+async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts) ->
+ call({async_get_bulk, self(), UserId, TargetName, NonRep, MaxRep,
+ Oids, SendOpts}).
+
+
async_get_bulk(UserId, TargetName, NonRep, MaxRep, CtxName, Oids) ->
async_get_bulk(UserId, TargetName,
NonRep, MaxRep, CtxName, Oids,
- ?DEFAULT_ASYNC_EXPIRE, ?EXTRA_INFO).
+ ?DEFAULT_ASYNC_GET_BULK_TIMEOUT, ?DEFAULT_EXTRA_INFO).
async_get_bulk(UserId, TargetName, NonRep, MaxRep, CtxName, Oids, Expire) ->
async_get_bulk(UserId, TargetName,
NonRep, MaxRep, CtxName, Oids,
- Expire, ?EXTRA_INFO).
+ Expire, ?DEFAULT_EXTRA_INFO).
async_get_bulk(UserId, TargetName, NonRep, MaxRep, CtxName, Oids, Expire,
ExtraInfo)
@@ -300,45 +406,61 @@ async_get_bulk(UserId, TargetName, NonRep, MaxRep, CtxName, Oids, Expire,
is_list(CtxName) andalso
is_list(Oids) andalso
is_integer(Expire) ->
- call({async_get_bulk, self(), UserId, TargetName,
- NonRep, MaxRep, CtxName, Oids, Expire, ExtraInfo}).
+ SendOpts = [{context, CtxName}, {expire, Expire}, {extra, ExtraInfo}],
+ async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts).
+
+
%% -- [sync] set --
%% VarsAndValues is: {PlainOid, o|s|i, Value} (unknown mibs) | {Oid, Value}
+%% sync_set2(UserId, TargetName, VarsAndVals) ->
+%% sync_set2(UserId, TargetName, VarsAndVals, []).
+sync_set2(UserId, TargetName, VarsAndVals, SendOpts) ->
+ call({sync_set, self(), UserId, TargetName, VarsAndVals, SendOpts}).
+
+
sync_set(UserId, TargetName, CtxName, VarsAndVals) ->
sync_set(UserId, TargetName, CtxName, VarsAndVals,
- ?SYNC_SET_TIMEOUT, ?EXTRA_INFO).
+ ?DEFAULT_SYNC_SET_TIMEOUT, ?DEFAULT_EXTRA_INFO).
sync_set(UserId, TargetName, CtxName, VarsAndVals, Timeout) ->
sync_set(UserId, TargetName, CtxName, VarsAndVals,
- Timeout, ?EXTRA_INFO).
+ Timeout, ?DEFAULT_EXTRA_INFO).
sync_set(UserId, TargetName, CtxName, VarsAndVals, Timeout, ExtraInfo)
when is_list(TargetName) andalso
is_list(CtxName) andalso
is_list(VarsAndVals) andalso
is_integer(Timeout) ->
- call({sync_set, self(), UserId, TargetName,
- CtxName, VarsAndVals, Timeout, ExtraInfo}).
+ SendOpts = [{context, CtxName}, {timeout, Timeout}, {extra, ExtraInfo}],
+ sync_set2(UserId, TargetName, VarsAndVals, SendOpts).
+
+
%% -- [async] set --
+%% async_set2(UserId, TargetName, VarsAndVals) ->
+%% async_set2(UserId, TargetName, VarsAndVals, []).
+async_set2(UserId, TargetName, VarsAndVals, SendOpts) ->
+ call({async_set, self(), UserId, TargetName, VarsAndVals, SendOpts}).
+
+
async_set(UserId, TargetName, CtxName, VarsAndVals) ->
async_set(UserId, TargetName, CtxName, VarsAndVals,
- ?DEFAULT_ASYNC_EXPIRE, ?EXTRA_INFO).
+ ?DEFAULT_ASYNC_SET_TIMEOUT, ?DEFAULT_EXTRA_INFO).
async_set(UserId, TargetName, CtxName, VarsAndVals, Expire) ->
async_set(UserId, TargetName, CtxName, VarsAndVals,
- Expire, ?EXTRA_INFO).
+ Expire, ?DEFAULT_EXTRA_INFO).
async_set(UserId, TargetName, CtxName, VarsAndVals, Expire, ExtraInfo)
when (is_list(TargetName) andalso
is_list(CtxName) andalso
is_list(VarsAndVals) andalso
is_integer(Expire) andalso (Expire >= 0)) ->
- call({async_set, self(), UserId, TargetName,
- CtxName, VarsAndVals, Expire, ExtraInfo}).
+ SendOpts = [{context, CtxName}, {expire, Expire}, {extra, ExtraInfo}],
+ async_set2(UserId, TargetName, VarsAndVals, SendOpts).
cancel_async_request(UserId, ReqId) ->
@@ -571,9 +693,26 @@ handle_call({unregister_user, UserId}, _From, State) ->
%% We will reply to this request later, when the reply comes in from the
%% agent, or when the timeout hits (unless we get an error now).
-handle_call({sync_get, Pid, UserId, TargetName, CtxName, Oids, Timeout, ExtraInfo},
+handle_call({sync_get, Pid, UserId, TargetName, Oids, SendOpts},
+ From, State) ->
+ ?vlog("[~p,~p] received sync_get request for: "
+ "~n ~p", [UserId, TargetName, Oids]),
+ case (catch handle_sync_get(Pid,
+ UserId, TargetName, Oids, SendOpts,
+ From, State)) of
+ ok ->
+ {noreply, State};
+ Error ->
+ {reply, Error, State}
+ end;
+
+%% <BACKWARD-COMPAT>
+%% The only case where this would be called is during code upgrade
+handle_call({sync_get,
+ Pid, UserId, TargetName, CtxName, Oids, Timeout, ExtraInfo},
From, State) ->
- ?vlog("received sync_get [~p] request", [CtxName]),
+ ?vlog("[~p,~p,~p] received sync_get request for: "
+ "~n ~p", [UserId, TargetName, CtxName, Oids]),
case (catch handle_sync_get(Pid,
UserId, TargetName, CtxName, Oids,
Timeout, ExtraInfo, From, State)) of
@@ -582,10 +721,30 @@ handle_call({sync_get, Pid, UserId, TargetName, CtxName, Oids, Timeout, ExtraInf
Error ->
{reply, Error, State}
end;
+%% </BACKWARD-COMPAT>
+
+
+handle_call({sync_get_next, Pid, UserId, TargetName, Oids, SendOpts},
+ From, State) ->
+ ?vlog("[~p,~p] received sync_get_next request for: "
+ "~n ~p", [UserId, TargetName, SendOpts]),
+ case (catch handle_sync_get_next(Pid,
+ UserId, TargetName, Oids, SendOpts,
+ From, State)) of
+ ok ->
+ {noreply, State};
+ Error ->
+ {reply, Error, State}
+ end;
-handle_call({sync_get_next, Pid, UserId, TargetName, CtxName, Oids, Timeout, ExtraInfo}, From, State) ->
- ?vlog("received sync_get_next [~p] request", [CtxName]),
+%% <BACKWARD-COMPAT>
+%% The only case where this would be called is during code upgrade
+handle_call({sync_get_next,
+ Pid, UserId, TargetName, CtxName, Oids, Timeout, ExtraInfo},
+ From, State) ->
+ ?vlog("[~p,~p,~p] received sync_get_next request for"
+ "~n ~p", [UserId, TargetName, CtxName, Oids]),
case (catch handle_sync_get_next(Pid,
UserId, TargetName, CtxName, Oids,
Timeout, ExtraInfo, From, State)) of
@@ -594,13 +753,31 @@ handle_call({sync_get_next, Pid, UserId, TargetName, CtxName, Oids, Timeout, Ext
Error ->
{reply, Error, State}
end;
+%% </BACKWARD-COMPAT>
%% Check agent version? This op not in v1
+handle_call({sync_get_bulk,
+ Pid, UserId, TargetName, NonRep, MaxRep, Oids, SendOpts},
+ From, State) ->
+ ?vlog("[~p,~p] received sync_get_bulk request for: "
+ "~n ~p", [UserId, TargetName, Oids]),
+ case (catch handle_sync_get_bulk(Pid,
+ UserId, TargetName, NonRep, MaxRep, Oids,
+ SendOpts, From, State)) of
+ ok ->
+ {noreply, State};
+ Error ->
+ {reply, Error, State}
+ end;
+
+%% <BACKWARD-COMPAT>
+%% The only case where this would be called is during code upgrade
handle_call({sync_get_bulk, Pid, UserId, TargetName,
NonRep, MaxRep, CtxName, Oids, Timeout, ExtraInfo},
From, State) ->
- ?vlog("received sync_get_bulk [~p] request", [CtxName]),
+ ?vlog("[~p,~p] received sync_get_bulk request for: ~p"
+ "~n ~p", [UserId, TargetName, CtxName, Oids]),
case (catch handle_sync_get_bulk(Pid,
UserId, TargetName, CtxName,
NonRep, MaxRep, Oids,
@@ -610,12 +787,31 @@ handle_call({sync_get_bulk, Pid, UserId, TargetName,
Error ->
{reply, Error, State}
end;
+%% </BACKWARD-COMPAT>
+
+
+handle_call({sync_set,
+ Pid, UserId, TargetName, VarsAndVals, SendOpts},
+ From, State) ->
+ ?vlog("[~p,~p] received sync_set request for: "
+ "~n ~p", [UserId, TargetName, VarsAndVals]),
+ case (catch handle_sync_set(Pid,
+ UserId, TargetName, VarsAndVals, SendOpts,
+ From, State)) of
+ ok ->
+ {noreply, State};
+ Error ->
+ {reply, Error, State}
+ end;
+%% <BACKWARD-COMPAT>
+%% The only case where this would be called is during code upgrade
handle_call({sync_set, Pid, UserId, TargetName,
CtxName, VarsAndVals, Timeout, ExtraInfo},
From, State) ->
- ?vlog("received sync_set [~p] request", [CtxName]),
+ ?vlog("[~p,~p,~p] received sync_set request for: "
+ "~n ~p", [UserId, TargetName, CtxName, VarsAndVals]),
case (catch handle_sync_set(Pid,
UserId, TargetName, CtxName, VarsAndVals,
Timeout, ExtraInfo, From, State)) of
@@ -624,45 +820,105 @@ handle_call({sync_set, Pid, UserId, TargetName,
Error ->
{reply, Error, State}
end;
+%% </BACKWARD-COMPAT>
+handle_call({async_get, Pid, UserId, TargetName, Oids, SendOpts},
+ _From, State) ->
+ ?vlog("[~p,~p] received async_get request for: "
+ "~n ~p", [UserId, TargetName, Oids]),
+ Reply = (catch handle_async_get(Pid,
+ UserId, TargetName, Oids, SendOpts,
+ State)),
+ {reply, Reply, State};
+
+
+%% <BACKWARD-COMPAT>
+%% The only case where this would be called is during code upgrade
handle_call({async_get, Pid, UserId, TargetName,
CtxName, Oids, Expire, ExtraInfo},
_From, State) ->
- ?vlog("received async_get [~p] request", [CtxName]),
+ ?vlog("[~p,~p,~p] received async_get request for: "
+ "~n ~p", [UserId, TargetName, CtxName, Oids]),
Reply = (catch handle_async_get(Pid, UserId, TargetName, CtxName, Oids,
Expire, ExtraInfo, State)),
{reply, Reply, State};
+%% </BACKWARD-COMPAT>
+
+
+handle_call({async_get_next, Pid, UserId, TargetName, Oids, SendOpts},
+ _From, State) ->
+ ?vlog("[~p,~p] received async_get_next request for: "
+ "~n ~p", [UserId, TargetName, Oids]),
+ Reply = (catch handle_async_get_next(Pid,
+ UserId, TargetName, Oids, SendOpts,
+ State)),
+ {reply, Reply, State};
+%% <BACKWARD-COMPAT>
+%% The only case where this would be called is during code upgrade
handle_call({async_get_next, Pid, UserId, TargetName,
CtxName, Oids, Expire, ExtraInfo},
_From, State) ->
- ?vlog("received async_get_next [~p] request", [CtxName]),
+ ?vlog("[~p,~p,~p] received async_get_next request for: ",
+ [UserId, TargetName, CtxName, Oids]),
Reply = (catch handle_async_get_next(Pid, UserId, TargetName, CtxName,
Oids, Expire, ExtraInfo, State)),
{reply, Reply, State};
+%% </BACKWARD-COMPAT>
%% Check agent version? This op not in v1
+handle_call({async_get_bulk,
+ Pid, UserId, TargetName, NonRep, MaxRep, Oids, SendOpts},
+ _From, State) ->
+ ?vlog("[~p,~p] received async_get_bulk request for: "
+ "~n ~p", [UserId, TargetName, Oids]),
+ Reply = (catch handle_async_get_bulk(Pid,
+ UserId, TargetName,
+ NonRep, MaxRep, Oids, SendOpts,
+ State)),
+ {reply, Reply, State};
+
+
+%% <BACKWARD-COMPAT>
+%% The only case where this would be called is during code upgrade
handle_call({async_get_bulk, Pid, UserId, TargetName,
NonRep, MaxRep, CtxName, Oids, Expire, ExtraInfo},
_From, State) ->
- ?vlog("received async_get_bulk [~p] request", [CtxName]),
+ ?vlog("[~p,~p,~p] received async_get_bulk request for: "
+ "~n ~p", [UserId, TargetName, CtxName, Oids]),
Reply = (catch handle_async_get_bulk(Pid,
UserId, TargetName, CtxName,
NonRep, MaxRep, Oids,
Expire, ExtraInfo, State)),
{reply, Reply, State};
+%% </BACKWARD-COMPAT>
+
+
+handle_call({async_set,
+ Pid, UserId, TargetName, VarsAndVals, SendOpts},
+ _From, State) ->
+ ?vlog("[~p,~p] received async_set request for: "
+ "~n ~p", [UserId, TargetName, VarsAndVals]),
+ Reply = (catch handle_async_set(Pid,
+ UserId, TargetName, VarsAndVals, SendOpts,
+ State)),
+ {reply, Reply, State};
+%% <BACKWARD-COMPAT>
+%% The only case where this would be called is during code upgrade
handle_call({async_set, Pid, UserId, TargetName,
CtxName, VarsAndVals, Expire, ExtraInfo},
_From, State) ->
- ?vlog("received async_set [~p] request", [CtxName]),
+ ?vlog("[~p,~p,~p] received async_set request for: "
+ "~n ~p", [UserId, TargetName, CtxName, VarsAndVals]),
Reply = (catch handle_async_set(Pid, UserId, TargetName, CtxName,
VarsAndVals, Expire, ExtraInfo, State)),
{reply, Reply, State};
+%% </BACKWARD-COMPAT>
handle_call({cancel_async_request, UserId, ReqId}, _From, State) ->
@@ -901,36 +1157,46 @@ terminate(Reason, #state{gct = GCT}) ->
handle_sync_get(Pid, UserId, TargetName, CtxName, Oids, Timeout, ExtraInfo,
From, State) ->
+ SendOpts =
+ [
+ {context, CtxName},
+ {timeout, Timeout},
+ {extra, ExtraInfo}
+ ],
+ handle_sync_get(Pid, UserId, TargetName, Oids, SendOpts, From, State).
+
+handle_sync_get(Pid, UserId, TargetName, Oids, SendOpts, From, State) ->
?vtrace("handle_sync_get -> entry with"
"~n Pid: ~p"
"~n UserId: ~p"
"~n TargetName: ~p"
- "~n CtxName: ~p"
"~n Oids: ~p"
- "~n Timeout: ~p"
+ "~n SendOpts: ~p"
"~n From: ~p",
- [Pid, UserId, TargetName, CtxName, Oids, Timeout, From]),
- case agent_data(TargetName, CtxName) of
+ [Pid, UserId, TargetName, Oids, SendOpts, From]),
+ case agent_data(TargetName, SendOpts) of
{ok, RegType, Addr, Port, Vsn, MsgData} ->
?vtrace("handle_sync_get -> send a ~p message", [Vsn]),
- ReqId = send_get_request(Oids, Vsn, MsgData, Addr, Port,
- ExtraInfo, State),
+ Extra = ?GET_EXTRA(SendOpts),
+ ReqId = send_get_request(Oids, Vsn, MsgData,
+ Addr, Port, Extra, State),
?vdebug("handle_sync_get -> ReqId: ~p", [ReqId]),
- Msg = {sync_timeout, ReqId, From},
- Ref = erlang:send_after(Timeout, self(), Msg),
- MonRef = erlang:monitor(process, Pid),
+ Msg = {sync_timeout, ReqId, From},
+ Timeout = ?SYNC_GET_TIMEOUT(SendOpts),
+ Ref = erlang:send_after(Timeout, self(), Msg),
+ MonRef = erlang:monitor(process, Pid),
?vtrace("handle_sync_get -> MonRef: ~p", [MonRef]),
- Req = #request{id = ReqId,
- user_id = UserId,
- reg_type = RegType,
- target = TargetName,
- addr = Addr,
- port = Port,
- type = get,
- data = MsgData,
- ref = Ref,
- mon = MonRef,
- from = From},
+ Req = #request{id = ReqId,
+ user_id = UserId,
+ reg_type = RegType,
+ target = TargetName,
+ addr = Addr,
+ port = Port,
+ type = get,
+ data = MsgData,
+ ref = Ref,
+ mon = MonRef,
+ from = From},
ets:insert(snmpm_request_table, Req),
ok;
Error ->
@@ -940,39 +1206,49 @@ handle_sync_get(Pid, UserId, TargetName, CtxName, Oids, Timeout, ExtraInfo,
Error
end.
-
handle_sync_get_next(Pid, UserId, TargetName, CtxName, Oids, Timeout,
ExtraInfo, From, State) ->
+ SendOpts =
+ [
+ {context, CtxName},
+ {timeout, Timeout},
+ {extra, ExtraInfo}
+ ],
+ handle_sync_get_next(Pid, UserId, TargetName, Oids, SendOpts, From, State).
+
+handle_sync_get_next(Pid, UserId, TargetName, Oids, SendOpts,
+ From, State) ->
?vtrace("handle_sync_get_next -> entry with"
"~n Pid: ~p"
"~n UserId: ~p"
"~n TargetName: ~p"
- "~n CtxName: ~p"
"~n Oids: ~p"
- "~n Timeout: ~p"
+ "~n SendOpts: ~p"
"~n From: ~p",
- [Pid, UserId, TargetName, CtxName, Oids, Timeout, From]),
- case agent_data(TargetName, CtxName) of
+ [Pid, UserId, TargetName, Oids, SendOpts, From]),
+ case agent_data(TargetName, SendOpts) of
{ok, RegType, Addr, Port, Vsn, MsgData} ->
?vtrace("handle_sync_get_next -> send a ~p message", [Vsn]),
- ReqId = send_get_next_request(Oids, Vsn, MsgData,
- Addr, Port, ExtraInfo, State),
+ Extra = ?GET_EXTRA(SendOpts),
+ ReqId = send_get_next_request(Oids, Vsn, MsgData,
+ Addr, Port, Extra, State),
?vdebug("handle_sync_get_next -> ReqId: ~p", [ReqId]),
- Msg = {sync_timeout, ReqId, From},
- Ref = erlang:send_after(Timeout, self(), Msg),
- MonRef = erlang:monitor(process, Pid),
+ Msg = {sync_timeout, ReqId, From},
+ Timeout = ?SYNC_GET_NEXT_TIMEOUT(SendOpts),
+ Ref = erlang:send_after(Timeout, self(), Msg),
+ MonRef = erlang:monitor(process, Pid),
?vtrace("handle_sync_get_next -> MonRef: ~p", [MonRef]),
- Req = #request{id = ReqId,
- user_id = UserId,
- reg_type = RegType,
- target = TargetName,
- addr = Addr,
- port = Port,
- type = get_next,
- data = MsgData,
- ref = Ref,
- mon = MonRef,
- from = From},
+ Req = #request{id = ReqId,
+ user_id = UserId,
+ reg_type = RegType,
+ target = TargetName,
+ addr = Addr,
+ port = Port,
+ type = get_next,
+ data = MsgData,
+ ref = Ref,
+ mon = MonRef,
+ from = From},
ets:insert(snmpm_request_table, Req),
ok;
@@ -987,39 +1263,50 @@ handle_sync_get_next(Pid, UserId, TargetName, CtxName, Oids, Timeout,
handle_sync_get_bulk(Pid, UserId, TargetName, CtxName,
NonRep, MaxRep, Oids, Timeout,
ExtraInfo, From, State) ->
+ SendOpts =
+ [
+ {context, CtxName},
+ {timeout, Timeout},
+ {extra, ExtraInfo}
+ ],
+ handle_sync_get_bulk(Pid, UserId, TargetName, NonRep, MaxRep, Oids,
+ SendOpts, From, State).
+
+handle_sync_get_bulk(Pid, UserId, TargetName, NonRep, MaxRep, Oids, SendOpts,
+ From, State) ->
?vtrace("handle_sync_get_bulk -> entry with"
"~n Pid: ~p"
"~n UserId: ~p"
"~n TargetName: ~p"
- "~n CtxName: ~p"
"~n NonRep: ~p"
"~n MaxRep: ~p"
"~n Oids: ~p"
- "~n Timeout: ~p"
+ "~n SendOpts: ~p"
"~n From: ~p",
- [Pid, UserId, TargetName, CtxName, NonRep, MaxRep, Oids,
- Timeout, From]),
- case agent_data(TargetName, CtxName) of
+ [Pid, UserId, TargetName, NonRep, MaxRep, Oids, SendOpts, From]),
+ case agent_data(TargetName, SendOpts) of
{ok, RegType, Addr, Port, Vsn, MsgData} ->
?vtrace("handle_sync_get_bulk -> send a ~p message", [Vsn]),
- ReqId = send_get_bulk_request(Oids, Vsn, MsgData, Addr, Port,
- NonRep, MaxRep, ExtraInfo, State),
+ Extra = ?GET_EXTRA(SendOpts),
+ ReqId = send_get_bulk_request(Oids, Vsn, MsgData, Addr, Port,
+ NonRep, MaxRep, Extra, State),
?vdebug("handle_sync_get_bulk -> ReqId: ~p", [ReqId]),
- Msg = {sync_timeout, ReqId, From},
- Ref = erlang:send_after(Timeout, self(), Msg),
- MonRef = erlang:monitor(process, Pid),
+ Msg = {sync_timeout, ReqId, From},
+ Timeout = ?SYNC_GET_BULK_TIMEOUT(SendOpts),
+ Ref = erlang:send_after(Timeout, self(), Msg),
+ MonRef = erlang:monitor(process, Pid),
?vtrace("handle_sync_get_bulk -> MonRef: ~p", [MonRef]),
- Req = #request{id = ReqId,
- user_id = UserId,
- reg_type = RegType,
- target = TargetName,
- addr = Addr,
- port = Port,
- type = get_bulk,
- data = MsgData,
- ref = Ref,
- mon = MonRef,
- from = From},
+ Req = #request{id = ReqId,
+ user_id = UserId,
+ reg_type = RegType,
+ target = TargetName,
+ addr = Addr,
+ port = Port,
+ type = get_bulk,
+ data = MsgData,
+ ref = Ref,
+ mon = MonRef,
+ from = From},
ets:insert(snmpm_request_table, Req),
ok;
@@ -1033,36 +1320,47 @@ handle_sync_get_bulk(Pid, UserId, TargetName, CtxName,
handle_sync_set(Pid, UserId, TargetName, CtxName, VarsAndVals, Timeout,
ExtraInfo, From, State) ->
+ SendOpts =
+ [
+ {context, CtxName},
+ {timeout, Timeout},
+ {extra, ExtraInfo}
+ ],
+ handle_sync_set(Pid, UserId, TargetName, VarsAndVals, SendOpts,
+ From, State).
+
+handle_sync_set(Pid, UserId, TargetName, VarsAndVals, SendOpts, From, State) ->
?vtrace("handle_sync_set -> entry with"
"~n Pid: ~p"
"~n UserId: ~p"
"~n TargetName: ~p"
- "~n CtxName: ~p"
"~n VarsAndVals: ~p"
- "~n Timeout: ~p"
+ "~n SendOpts: ~p"
"~n From: ~p",
- [Pid, UserId, TargetName, CtxName, VarsAndVals, Timeout, From]),
- case agent_data(TargetName, CtxName) of
+ [Pid, UserId, TargetName, VarsAndVals, From]),
+ case agent_data(TargetName, SendOpts) of
{ok, RegType, Addr, Port, Vsn, MsgData} ->
?vtrace("handle_sync_set -> send a ~p message", [Vsn]),
- ReqId = send_set_request(VarsAndVals, Vsn, MsgData,
- Addr, Port, ExtraInfo, State),
+ Extra = ?GET_EXTRA(SendOpts),
+ ReqId = send_set_request(VarsAndVals, Vsn, MsgData,
+ Addr, Port, Extra, State),
?vdebug("handle_sync_set -> ReqId: ~p", [ReqId]),
- Msg = {sync_timeout, ReqId, From},
- Ref = erlang:send_after(Timeout, self(), Msg),
- MonRef = erlang:monitor(process, Pid),
+ Msg = {sync_timeout, ReqId, From},
+ Timeout = ?SYNC_SET_TIMEOUT(SendOpts),
+ Ref = erlang:send_after(Timeout, self(), Msg),
+ MonRef = erlang:monitor(process, Pid),
?vtrace("handle_sync_set -> MonRef: ~p", [MonRef]),
- Req = #request{id = ReqId,
- user_id = UserId,
- reg_type = RegType,
- target = TargetName,
- addr = Addr,
- port = Port,
- type = set,
- data = MsgData,
- ref = Ref,
- mon = MonRef,
- from = From},
+ Req = #request{id = ReqId,
+ user_id = UserId,
+ reg_type = RegType,
+ target = TargetName,
+ addr = Addr,
+ port = Port,
+ type = set,
+ data = MsgData,
+ ref = Ref,
+ mon = MonRef,
+ from = From},
ets:insert(snmpm_request_table, Req),
ok;
@@ -1076,20 +1374,30 @@ handle_sync_set(Pid, UserId, TargetName, CtxName, VarsAndVals, Timeout,
handle_async_get(Pid, UserId, TargetName, CtxName, Oids, Expire, ExtraInfo,
State) ->
+ SendOpts =
+ [
+ {context, CtxName},
+ {timeout, Expire},
+ {extra, ExtraInfo}
+ ],
+ handle_async_get(Pid, UserId, TargetName, Oids, SendOpts, State).
+
+handle_async_get(Pid, UserId, TargetName, Oids, SendOpts, State) ->
?vtrace("handle_async_get -> entry with"
"~n Pid: ~p"
"~n UserId: ~p"
"~n TargetName: ~p"
- "~n CtxName: ~p"
"~n Oids: ~p"
- "~n Expire: ~p",
- [Pid, UserId, TargetName, CtxName, Oids, Expire]),
- case agent_data(TargetName, CtxName) of
+ "~n SendOpts: ~p",
+ [Pid, UserId, TargetName, Oids, SendOpts]),
+ case agent_data(TargetName, SendOpts) of
{ok, RegType, Addr, Port, Vsn, MsgData} ->
?vtrace("handle_async_get -> send a ~p message", [Vsn]),
+ Extra = ?GET_EXTRA(SendOpts),
ReqId = send_get_request(Oids, Vsn, MsgData, Addr, Port,
- ExtraInfo, State),
+ Extra, State),
?vdebug("handle_async_get -> ReqId: ~p", [ReqId]),
+ Expire = ?ASYNC_GET_TIMEOUT(SendOpts),
Req = #request{id = ReqId,
user_id = UserId,
reg_type = RegType,
@@ -1114,20 +1422,30 @@ handle_async_get(Pid, UserId, TargetName, CtxName, Oids, Expire, ExtraInfo,
handle_async_get_next(Pid, UserId, TargetName, CtxName, Oids, Expire,
ExtraInfo, State) ->
+ SendOpts =
+ [
+ {context, CtxName},
+ {timeout, Expire},
+ {extra, ExtraInfo}
+ ],
+ handle_async_get_next(Pid, UserId, TargetName, Oids, SendOpts, State).
+
+handle_async_get_next(Pid, UserId, TargetName, Oids, SendOpts, State) ->
?vtrace("handle_async_get_next -> entry with"
"~n Pid: ~p"
"~n UserId: ~p"
"~n TargetName: ~p"
- "~n CtxName: ~p"
"~n Oids: ~p"
- "~n Expire: ~p",
- [Pid, UserId, TargetName, CtxName, Oids, Expire]),
- case agent_data(TargetName, CtxName) of
+ "~n SendOpts: ~p",
+ [Pid, UserId, TargetName, Oids, SendOpts]),
+ case agent_data(TargetName, SendOpts) of
{ok, RegType, Addr, Port, Vsn, MsgData} ->
?vtrace("handle_async_get_next -> send a ~p message", [Vsn]),
+ Extra = ?GET_EXTRA(SendOpts),
ReqId = send_get_next_request(Oids, Vsn, MsgData,
- Addr, Port, ExtraInfo, State),
+ Addr, Port, Extra, State),
?vdebug("handle_async_get_next -> ReqId: ~p", [ReqId]),
+ Expire = ?ASYNC_GET_NEXT_TIMEOUT(SendOpts),
Req = #request{id = ReqId,
user_id = UserId,
reg_type = RegType,
@@ -1153,22 +1471,36 @@ handle_async_get_next(Pid, UserId, TargetName, CtxName, Oids, Expire,
handle_async_get_bulk(Pid, UserId, TargetName, CtxName,
NonRep, MaxRep, Oids, Expire,
ExtraInfo, State) ->
+ SendOpts =
+ [
+ {context, CtxName},
+ {timeout, Expire},
+ {extra, ExtraInfo}
+ ],
+ handle_async_get_bulk(Pid,
+ UserId, TargetName, NonRep, MaxRep, Oids, SendOpts,
+ State).
+
+handle_async_get_bulk(Pid,
+ UserId, TargetName, NonRep, MaxRep, Oids, SendOpts,
+ State) ->
?vtrace("handle_async_get_bulk -> entry with"
"~n Pid: ~p"
"~n UserId: ~p"
"~n TargetName: ~p"
- "~n CtxName: ~p"
"~n NonRep: ~p"
"~n MaxRep: ~p"
"~n Oids: ~p"
- "~n Expire: ~p",
- [Pid, UserId, TargetName, CtxName, NonRep, MaxRep, Oids, Expire]),
- case agent_data(TargetName, CtxName) of
+ "~n SendOpts: ~p",
+ [Pid, UserId, TargetName, NonRep, MaxRep, Oids, SendOpts]),
+ case agent_data(TargetName, SendOpts) of
{ok, RegType, Addr, Port, Vsn, MsgData} ->
?vtrace("handle_async_get_bulk -> send a ~p message", [Vsn]),
+ Extra = ?GET_EXTRA(SendOpts),
ReqId = send_get_bulk_request(Oids, Vsn, MsgData, Addr, Port,
- NonRep, MaxRep, ExtraInfo, State),
+ NonRep, MaxRep, Extra, State),
?vdebug("handle_async_get_bulk -> ReqId: ~p", [ReqId]),
+ Expire = ?ASYNC_GET_BULK_TIMEOUT(SendOpts),
Req = #request{id = ReqId,
user_id = UserId,
reg_type = RegType,
@@ -1192,20 +1524,30 @@ handle_async_get_bulk(Pid, UserId, TargetName, CtxName,
handle_async_set(Pid, UserId, TargetName, CtxName, VarsAndVals, Expire,
ExtraInfo, State) ->
+ SendOpts =
+ [
+ {context, CtxName},
+ {timeout, Expire},
+ {extra, ExtraInfo}
+ ],
+ handle_async_set(Pid, UserId, TargetName, VarsAndVals, SendOpts, State).
+
+handle_async_set(Pid, UserId, TargetName, VarsAndVals, SendOpts, State) ->
?vtrace("handle_async_set -> entry with"
"~n Pid: ~p"
"~n UserId: ~p"
"~n TargetName: ~p"
- "~n CtxName: ~p"
"~n VarsAndVals: ~p"
- "~n Expire: ~p",
- [Pid, UserId, TargetName, CtxName, VarsAndVals, Expire]),
- case agent_data(TargetName, CtxName) of
+ "~n SendOpts: ~p",
+ [Pid, UserId, TargetName, VarsAndVals, SendOpts]),
+ case agent_data(TargetName, SendOpts) of
{ok, RegType, Addr, Port, Vsn, MsgData} ->
?vtrace("handle_async_set -> send a ~p message", [Vsn]),
+ Extra = ?GET_EXTRA(SendOpts),
ReqId = send_set_request(VarsAndVals, Vsn, MsgData,
- Addr, Port, ExtraInfo, State),
+ Addr, Port, Extra, State),
?vdebug("handle_async_set -> ReqId: ~p", [ReqId]),
+ Expire = ?ASYNC_SET_TIMEOUT(SendOpts),
Req = #request{id = ReqId,
user_id = UserId,
reg_type = RegType,
@@ -2798,10 +3140,7 @@ request_id() ->
%%----------------------------------------------------------------------
-agent_data(TargetName, CtxName) ->
- agent_data(TargetName, CtxName, []).
-
-agent_data(TargetName, CtxName, Config) ->
+agent_data(TargetName, SendOpts) ->
case snmpm_config:agent_info(TargetName, all) of
{ok, Info} ->
Version = agent_data_item(version, Info),
@@ -2813,15 +3152,18 @@ agent_data(TargetName, CtxName, Config) ->
DefSecLevel = agent_data_item(sec_level, Info),
EngineId = agent_data_item(engine_id, Info),
+ CtxName = agent_data_item(context,
+ SendOpts,
+ ?DEFAULT_CONTEXT),
SecModel = agent_data_item(sec_model,
- Config,
+ SendOpts,
DefSecModel),
SecName = agent_data_item(sec_name,
- Config,
+ SendOpts,
DefSecName),
SecLevel = agent_data_item(sec_level,
- Config,
+ SendOpts,
DefSecLevel),
{SecModel, SecName, mk_sec_level_flag(SecLevel),
@@ -2831,10 +3173,10 @@ agent_data(TargetName, CtxName, Config) ->
DefSecModel = agent_data_item(sec_model, Info),
Comm = agent_data_item(community,
- Config,
+ SendOpts,
DefComm),
SecModel = agent_data_item(sec_model,
- Config,
+ SendOpts,
DefSecModel),
{Comm, SecModel}
@@ -3003,6 +3345,12 @@ default_agent_config() ->
%%----------------------------------------------------------------------
+get_opt(Key, Default, Opts) ->
+ proplists:get_value(Key, Opts, Default).
+
+
+%%----------------------------------------------------------------------
+
is_started(#state{net_if = _Pid, net_if_mod = _Mod}) ->
%% Mod:is_started(Pid) and snmpm_config:is_started().
case snmpm_config:is_started() of
diff --git a/lib/snmp/test/Makefile b/lib/snmp/test/Makefile
index b7975024b4..0e9c73081d 100644
--- a/lib/snmp/test/Makefile
+++ b/lib/snmp/test/Makefile
@@ -145,9 +145,12 @@ endif
# ----------------------------------------------------
EBIN = .
-ERL_COMPILE_FLAGS += -I../src \
+ERL_COMPILE_FLAGS += -I../../snmp/src/app \
+ -I../../snmp/src/misc \
+ -I../../snmp/src/agent \
+ -I../../snmp/src/manager \
-I$(ERL_TOP)/lib/test_server/include \
- -I../include \
+ -I../../snmp/include \
-Dsnmp_test_data=snmp_test_data \
-Dversion=\"$(VSN)$(PRE_VSN)\" \
+'{parse_transform,sys_pre_attributes}' \
diff --git a/lib/snmp/test/snmp_agent_test.erl b/lib/snmp/test/snmp_agent_test.erl
index cf4d5523bf..acf62f5646 100644
--- a/lib/snmp/test/snmp_agent_test.erl
+++ b/lib/snmp/test/snmp_agent_test.erl
@@ -81,13 +81,12 @@
case get(vsn) of
v1 -> V1;
v2 -> V2;
- _ -> V3
+ _ -> V3
end).
all() ->
- Reqs = [mnesia, distribution, {local_slave_nodes, 2},
- {time, 360}],
+ %% Reqs = [mnesia, distribution, {local_slave_nodes, 2}, {time, 360}],
Conf1 = [{group, all_tcs}],
Conf2 = [{group, tickets2}],
Conf1 ++ Conf2.
@@ -95,62 +94,138 @@ all() ->
groups() ->
[{all_tcs, [], cases()},
{mib_storage, [],
- [{group, mib_storage_ets}, {group, mib_storage_dets},
+ [
+ {group, mib_storage_ets},
+ {group, mib_storage_dets},
{group, mib_storage_mnesia},
{group, mib_storage_size_check_ets},
{group, mib_storage_size_check_dets},
{group, mib_storage_size_check_mnesia},
{group, mib_storage_varm_dets},
- {group, mib_storage_varm_mnesia}]},
- {mib_storage_ets, [], mib_storage_ets_cases()},
- {mib_storage_dets, [], mib_storage_dets_cases()},
- {mib_storage_mnesia, [], mib_storage_mnesia_cases()},
- {mib_storage_size_check_ets, [], mse_size_check_cases()},
+ {group, mib_storage_varm_mnesia}
+ ]
+ },
+ {mib_storage_ets, [], mib_storage_ets_cases()},
+ {mib_storage_dets, [], mib_storage_dets_cases()},
+ {mib_storage_mnesia, [], mib_storage_mnesia_cases()},
+ {mib_storage_size_check_ets, [], mse_size_check_cases()},
{mib_storage_size_check_dets, [], msd_size_check_cases()},
{mib_storage_size_check_mnesia, [], msm_size_check_cases()},
- {mib_storage_varm_dets, [], varm_mib_storage_dets_cases()},
- {mib_storage_varm_mnesia, [], varm_mib_storage_mnesia_cases()},
- {misc, [], misc_cases()}, {test_v1, [], v1_cases()},
- {test_v2, [], v2_cases()},
- {test_v1_v2, [], v1_v2_cases()},
- {test_v3, [], v3_cases()},
- {test_multi_threaded, [], mt_cases()},
- {multiple_reqs, [], mul_cases()},
- {multiple_reqs_2, [], mul_cases_2()},
- {v2_inform, [], [v2_inform_i]},
+ {mib_storage_varm_dets, [], varm_mib_storage_dets_cases()},
+ {mib_storage_varm_mnesia, [], varm_mib_storage_mnesia_cases()},
+ {misc, [], misc_cases()},
+ {test_v1, [], v1_cases()},
+ {test_v2, [], v2_cases()},
+ {test_v1_v2, [], v1_v2_cases()},
+ {test_v3, [], v3_cases()},
+ {test_multi_threaded, [], mt_cases()},
+ {multiple_reqs, [], mul_cases()},
+ {multiple_reqs_2, [], mul_cases_2()},
+ {v2_inform, [],
+ [
+ v2_inform_i
+ ]
+ },
{v3_security, [],
- [v3_crypto_basic, v3_md5_auth, v3_sha_auth,
- v3_des_priv]},
+ [
+ v3_crypto_basic,
+ v3_md5_auth,
+ v3_sha_auth,
+ v3_des_priv
+ ]
+ },
{standard_mibs, [],
- [snmp_standard_mib, snmp_community_mib,
- snmp_framework_mib, snmp_target_mib,
- snmp_notification_mib, snmp_view_based_acm_mib]},
+ [
+ snmp_standard_mib,
+ snmp_community_mib,
+ snmp_framework_mib,
+ snmp_target_mib,
+ snmp_notification_mib,
+ snmp_view_based_acm_mib
+ ]
+ },
{standard_mibs_2, [],
- [snmpv2_mib_2, snmp_community_mib_2,
- snmp_framework_mib_2, snmp_target_mib_2,
- snmp_notification_mib_2, snmp_view_based_acm_mib_2]},
+ [
+ snmpv2_mib_2,
+ snmp_community_mib_2,
+ snmp_framework_mib_2,
+ snmp_target_mib_2,
+ snmp_notification_mib_2,
+ snmp_view_based_acm_mib_2
+ ]
+ },
{standard_mibs_3, [],
- [snmpv2_mib_3, snmp_framework_mib_3, snmp_mpd_mib_3,
- snmp_target_mib_3, snmp_notification_mib_3,
- snmp_view_based_acm_mib_3, snmp_user_based_sm_mib_3]},
+ [
+ snmpv2_mib_3,
+ snmp_framework_mib_3,
+ snmp_mpd_mib_3,
+ snmp_target_mib_3,
+ snmp_notification_mib_3,
+ snmp_view_based_acm_mib_3,
+ snmp_user_based_sm_mib_3
+ ]
+ },
{reported_bugs, [],
- [otp_1128, otp_1129, otp_1131, otp_1162, otp_1222,
- otp_1298, otp_1331, otp_1338, otp_1342, otp_2776,
- otp_2979, otp_3187, otp_3725]},
+ [
+ otp_1128,
+ otp_1129,
+ otp_1131,
+ otp_1162,
+ otp_1222,
+ otp_1298,
+ otp_1331,
+ otp_1338,
+ otp_1342,
+ otp_2776,
+ otp_2979,
+ otp_3187,
+ otp_3725
+ ]
+ },
{reported_bugs_2, [],
- [otp_1128_2, otp_1129_2, otp_1131_2, otp_1162_2,
- otp_1222_2, otp_1298_2, otp_1331_2, otp_1338_2,
- otp_1342_2, otp_2776_2, otp_2979_2, otp_3187_2]},
+ [
+ otp_1128_2,
+ otp_1129_2,
+ otp_1131_2,
+ otp_1162_2,
+ otp_1222_2,
+ otp_1298_2,
+ otp_1331_2,
+ otp_1338_2,
+ otp_1342_2,
+ otp_2776_2,
+ otp_2979_2,
+ otp_3187_2
+ ]
+ },
{reported_bugs_3, [],
- [otp_1128_3, otp_1129_3, otp_1131_3, otp_1162_3,
- otp_1222_3, otp_1298_3, otp_1331_3, otp_1338_3,
- otp_1342_3, otp_2776_3, otp_2979_3, otp_3187_3,
- otp_3542]},
- {tickets1, [], [{group, otp_4394}, {group, otp_7157}]},
+ [
+ otp_1128_3,
+ otp_1129_3,
+ otp_1131_3,
+ otp_1162_3,
+ otp_1222_3,
+ otp_1298_3,
+ otp_1331_3,
+ otp_1338_3,
+ otp_1342_3,
+ otp_2776_3,
+ otp_2979_3,
+ otp_3187_3,
+ otp_3542
+ ]
+ },
+ {tickets1, [],
+ [
+ {group, otp_4394},
+ {group, otp_7157}
+ ]
+ },
{tickets2, [], [otp8395]},
{otp_4394, [], [otp_4394_test]},
- {otp_7157, [],
- begin Reqs = [], Conf = [otp_7157_test], Conf end}].
+ {otp_7157, [], [otp_7157_test]
+ }
+ ].
init_per_group(all_tcs, Config) ->
init_all(Config);
diff --git a/lib/snmp/test/snmp_manager_test.erl b/lib/snmp/test/snmp_manager_test.erl
index 50836db731..6bd62df655 100644
--- a/lib/snmp/test/snmp_manager_test.erl
+++ b/lib/snmp/test/snmp_manager_test.erl
@@ -37,13 +37,16 @@
-include_lib("snmp/include/snmp_types.hrl").
-include_lib("snmp/include/STANDARD-MIB.hrl").
+-include_lib("snmp/src/manager/snmpm_internal.hrl").
%%----------------------------------------------------------------------
%% External exports
%%----------------------------------------------------------------------
-export([
- all/0,groups/0,init_per_group/2,end_per_group/2,
+ all/0,
+ groups/0,
+ init_per_group/2, end_per_group/2,
init_per_testcase/2, end_per_testcase/2,
@@ -54,49 +57,45 @@
notify_started01/1,
notify_started02/1,
-
register_user1/1,
-
register_agent1/1,
register_agent2/1,
-
info/1,
-
-
-
simple_sync_get1/1,
simple_sync_get2/1,
+ simple_sync_get3/1,
simple_async_get1/1,
simple_async_get2/1,
-
+ simple_async_get3/1,
simple_sync_get_next1/1,
simple_sync_get_next2/1,
+ simple_sync_get_next3/1,
simple_async_get_next1/1,
simple_async_get_next2/1,
-
+ simple_async_get_next3/1,
simple_sync_set1/1,
simple_sync_set2/1,
+ simple_sync_set3/1,
simple_async_set1/1,
simple_async_set2/1,
-
+ simple_async_set3/1,
simple_sync_get_bulk1/1,
simple_sync_get_bulk2/1,
+ simple_sync_get_bulk3/1,
simple_async_get_bulk1/1,
simple_async_get_bulk2/1,
-
+ simple_async_get_bulk3/1,
misc_async1/1,
misc_async2/1,
discovery/1,
-
-
trap1/1,
trap2/1,
@@ -109,8 +108,6 @@
report/1,
-
-
otp8015_1/1,
otp8395_1/1
@@ -220,7 +217,7 @@ init_per_testcase2(Case, Config) ->
Conf2.
init_per_testcase3(Case, Config) ->
- OldApiCases =
+ ApiCases01 =
[
simple_sync_get1,
simple_async_get1,
@@ -232,7 +229,7 @@ init_per_testcase3(Case, Config) ->
simple_async_get_bulk1,
misc_async1
],
- NewApiCases =
+ ApiCases02 =
[
simple_sync_get2,
simple_async_get2,
@@ -245,6 +242,17 @@ init_per_testcase3(Case, Config) ->
misc_async2,
otp8395_1
],
+ ApiCases03 =
+ [
+ simple_sync_get3,
+ simple_async_get3,
+ simple_sync_get_next3,
+ simple_async_get_next3,
+ simple_sync_set3,
+ simple_async_set3,
+ simple_sync_get_bulk3,
+ simple_async_get_bulk3
+ ],
Cases =
[
trap1,
@@ -256,8 +264,9 @@ init_per_testcase3(Case, Config) ->
inform_swarm,
report
] ++
- OldApiCases ++
- NewApiCases,
+ ApiCases01 ++
+ ApiCases02 ++
+ ApiCases03,
case lists:member(Case, Cases) of
true ->
NoAutoInformCases = [inform1, inform2, inform3, inform_swarm],
@@ -279,7 +288,7 @@ init_per_testcase3(Case, Config) ->
Conf2 = init_agent(Conf1),
Conf3 = init_manager(AutoInform, Conf2),
Conf4 = init_mgr_user(Conf3),
- case lists:member(Case, NewApiCases) of
+ case lists:member(Case, ApiCases02 ++ ApiCases03) of
true ->
init_mgr_user_data2(Conf4);
false ->
@@ -301,7 +310,7 @@ end_per_testcase(Case, Config) when is_list(Config) ->
Conf2.
end_per_testcase2(Case, Config) ->
- OldApiCases =
+ ApiCases01 =
[
simple_sync_get1,
simple_async_get1,
@@ -313,7 +322,7 @@ end_per_testcase2(Case, Config) ->
simple_async_get_bulk1,
misc_async1
],
- NewApiCases =
+ ApiCases02 =
[
simple_sync_get2,
simple_async_get2,
@@ -326,6 +335,17 @@ end_per_testcase2(Case, Config) ->
misc_async2,
otp8395_1
],
+ ApiCases03 =
+ [
+ simple_sync_get3,
+ simple_async_get3,
+ simple_sync_get_next3,
+ simple_async_get_next3,
+ simple_sync_set3,
+ simple_async_set3,
+ simple_sync_get_bulk3,
+ simple_async_get_bulk3
+ ],
Cases =
[
trap1,
@@ -337,11 +357,12 @@ end_per_testcase2(Case, Config) ->
inform_swarm,
report
] ++
- OldApiCases ++
- NewApiCases,
+ ApiCases01 ++
+ ApiCases02 ++
+ ApiCases03,
case lists:member(Case, Cases) of
true ->
- Conf1 = case lists:member(Case, NewApiCases) of
+ Conf1 = case lists:member(Case, ApiCases02 ++ ApiCases03) of
true ->
fin_mgr_user_data2(Config);
false ->
@@ -360,42 +381,129 @@ end_per_testcase2(Case, Config) ->
%%======================================================================
all() ->
-[{group, start_and_stop_tests}, {group, misc_tests},
- {group, user_tests}, {group, agent_tests},
- {group, request_tests}, {group, event_tests}, discovery,
- {group, tickets}].
+ [
+ {group, start_and_stop_tests},
+ {group, misc_tests},
+ {group, user_tests},
+ {group, agent_tests},
+ {group, request_tests},
+ {group, event_tests},
+ discovery,
+ {group, tickets}
+ ].
groups() ->
- [{start_and_stop_tests, [],
- [simple_start_and_stop1, simple_start_and_stop2,
- simple_start_and_monitor_crash1,
- simple_start_and_monitor_crash2, notify_started01,
- notify_started02]},
- {misc_tests, [], [info]},
- {user_tests, [], [register_user1]},
- {agent_tests, [], [register_agent1, register_agent2]},
- {request_tests, [],
- [{group, get_tests}, {group, get_next_tests},
- {group, set_tests}, {group, bulk_tests},
- {group, misc_request_tests}]},
- {get_tests, [],
- [simple_sync_get1, simple_sync_get2, simple_async_get1,
- simple_async_get2]},
- {get_next_tests, [],
- [simple_sync_get_next1, simple_sync_get_next2,
- simple_async_get_next1, simple_async_get_next2]},
- {set_tests, [],
- [simple_sync_set1, simple_sync_set2, simple_async_set1,
- simple_async_set2]},
- {bulk_tests, [],
- [simple_sync_get_bulk1, simple_sync_get_bulk2,
- simple_async_get_bulk1, simple_async_get_bulk2]},
- {misc_request_tests, [], [misc_async1, misc_async2]},
- {event_tests, [],
- [trap1, trap2, inform1, inform2, inform3, inform4,
- inform_swarm, report]},
- {tickets, [], [{group, otp8015}, {group, otp8395}]},
- {otp8015, [], [otp8015_1]}, {otp8395, [], [otp8395_1]}].
+ [
+ {start_and_stop_tests, [],
+ [
+ simple_start_and_stop1,
+ simple_start_and_stop2,
+ simple_start_and_monitor_crash1,
+ simple_start_and_monitor_crash2,
+ notify_started01,
+ notify_started02
+ ]
+ },
+ {misc_tests, [],
+ [
+ info
+ ]
+ },
+ {user_tests, [],
+ [
+ register_user1
+ ]
+ },
+ {agent_tests, [],
+ [
+ register_agent1,
+ register_agent2
+ ]
+ },
+ {request_tests, [],
+ [
+ {group, get_tests},
+ {group, get_next_tests},
+ {group, set_tests},
+ {group, bulk_tests},
+ {group, misc_request_tests}
+ ]
+ },
+ {get_tests, [],
+ [
+ simple_sync_get1,
+ simple_sync_get2,
+ simple_sync_get3,
+ simple_async_get1,
+ simple_async_get2,
+ simple_async_get3
+ ]
+ },
+ {get_next_tests, [],
+ [
+ simple_sync_get_next1,
+ simple_sync_get_next2,
+ simple_sync_get_next3,
+ simple_async_get_next1,
+ simple_async_get_next2,
+ simple_async_get_next3
+ ]
+ },
+ {set_tests, [],
+ [
+ simple_sync_set1,
+ simple_sync_set2,
+ simple_sync_set3,
+ simple_async_set1,
+ simple_async_set2,
+ simple_async_set3
+ ]
+ },
+ {bulk_tests, [],
+ [
+ simple_sync_get_bulk1,
+ simple_sync_get_bulk2,
+ simple_sync_get_bulk3,
+ simple_async_get_bulk1,
+ simple_async_get_bulk2,
+ simple_async_get_bulk3
+ ]
+ },
+ {misc_request_tests, [],
+ [
+ misc_async1,
+ misc_async2
+ ]
+ },
+ {event_tests, [],
+ [
+ trap1,
+ trap2,
+ inform1,
+ inform2,
+ inform3,
+ inform4,
+ inform_swarm,
+ report
+ ]
+ },
+ {tickets, [],
+ [
+ {group, otp8015},
+ {group, otp8395}
+ ]
+ },
+ {otp8015, [],
+ [
+ otp8015_1
+ ]
+ },
+ {otp8395, [],
+ [
+ otp8395_1
+ ]
+ }
+ ].
init_per_group(_GroupName, Config) ->
Config.
@@ -404,21 +512,6 @@ end_per_group(_GroupName, Config) ->
Config.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
%%======================================================================
%% Test functions
%%======================================================================
@@ -1319,15 +1412,15 @@ simple_sync_get1(Config) when is_list(Config) ->
p("issue get-request without loading the mib"),
Oids1 = [?sysObjectID_instance, ?sysDescr_instance, ?sysUpTime_instance],
- ?line ok = do_simple_get(Node, Addr, Port, Oids1),
+ ?line ok = do_simple_sync_get(Node, Addr, Port, Oids1),
p("issue get-request after first loading the mibs"),
?line ok = mgr_user_load_mib(Node, std_mib()),
Oids2 = [[sysObjectID, 0], [sysDescr, 0], [sysUpTime, 0]],
- ?line ok = do_simple_get(Node, Addr, Port, Oids2),
+ ?line ok = do_simple_sync_get(Node, Addr, Port, Oids2),
ok.
-do_simple_get(Node, Addr, Port, Oids) ->
+do_simple_sync_get(Node, Addr, Port, Oids) ->
?line {ok, Reply, Rem} = mgr_user_sync_get(Node, Addr, Port, Oids),
?DBG("~n Reply: ~p"
@@ -1360,14 +1453,22 @@ do_simple_get(Node, Addr, Port, Oids) ->
%%======================================================================
-simple_sync_get2(doc) -> ["Simple sync get-request - New style (TargetName)"];
+simple_sync_get2(doc) ->
+ ["Simple sync get-request - Version 2 API (TargetName)"];
simple_sync_get2(suite) -> [];
simple_sync_get2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
put(tname, ssg2),
- do_simple_get(Config).
+ do_simple_sync_get2(Config).
-do_simple_get(Config) ->
+do_simple_sync_get2(Config) ->
+ Get = fun(Node, TargetName, Oids) ->
+ mgr_user_sync_get(Node, TargetName, Oids)
+ end,
+ PostVerify = fun() -> ok end,
+ do_simple_sync_get2(Config, Get, PostVerify).
+
+do_simple_sync_get2(Config, Get, PostVerify) ->
p("starting with Config: ~p~n", [Config]),
Node = ?config(manager_node, Config),
@@ -1375,20 +1476,21 @@ do_simple_get(Config) ->
p("issue get-request without loading the mib"),
Oids1 = [?sysObjectID_instance, ?sysDescr_instance, ?sysUpTime_instance],
- ?line ok = do_simple_get(Node, TargetName, Oids1),
+ ?line ok = do_simple_sync_get2(Node, TargetName, Oids1, Get, PostVerify),
p("issue get-request after first loading the mibs"),
?line ok = mgr_user_load_mib(Node, std_mib()),
Oids2 = [[sysObjectID, 0], [sysDescr, 0], [sysUpTime, 0]],
- ?line ok = do_simple_get(Node, TargetName, Oids2),
+ ?line ok = do_simple_sync_get2(Node, TargetName, Oids2, Get, PostVerify),
ok.
-
-do_simple_get(Node, TargetName, Oids) ->
- ?line {ok, Reply, Rem} = mgr_user_sync_get(Node, TargetName, Oids),
+
+do_simple_sync_get2(Node, TargetName, Oids, Get, PostVerify)
+ when is_function(Get, 3) andalso is_function(PostVerify, 0) ->
+ ?line {ok, Reply, Rem} = Get(Node, TargetName, 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
@@ -1403,7 +1505,7 @@ do_simple_get(Node, TargetName, Oids) ->
"~n SysDescr: ~s"
"~n SysUpTime: ~w",
[SysObjectID, SysDescr, SysUpTime]),
- ok;
+ PostVerify();
{noError, 0, Vbs} ->
p("unexpected varbinds: ~n~p", [Vbs]),
{error, {unexpected_vbs, Vbs}};
@@ -1416,6 +1518,38 @@ do_simple_get(Node, TargetName, Oids) ->
%%======================================================================
+simple_sync_get3(doc) ->
+ ["Simple sync get-request - Version 3 API (TargetName and send-opts)"];
+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) ->
+ Self = self(),
+ Msg = simple_sync_get3,
+ Fun = fun() -> Self ! Msg end,
+ Extra = {?SNMPM_EXTRA_INFO_TAG, Fun},
+ SendOpts =
+ [
+ {extra, Extra}
+ ],
+ Get = fun(Node, TargetName, Oids) ->
+ mgr_user_sync_get2(Node, TargetName, Oids, SendOpts)
+ end,
+ PostVerify =
+ fun() ->
+ receive
+ Msg ->
+ ok
+ end
+ end,
+ do_simple_sync_get2(Config, Get, PostVerify).
+
+
+%%======================================================================
+
simple_async_get1(doc) -> ["Simple (async) get-request - "
"Old style (Addr & Port)"];
simple_async_get1(suite) -> [];
@@ -1435,40 +1569,41 @@ simple_async_get1(Config) when is_list(Config) ->
?line ok = agent_load_mib(AgentNode, Test2Mib),
Exec = fun(Data) ->
- async_g_exec1(MgrNode, Addr, Port, Data)
+ async_g_exec1(MgrNode, Addr, Port, Data)
end,
- Requests = [
- { 1,
- [?sysObjectID_instance],
- Exec,
- fun(X) -> sag_verify(X, [?sysObjectID_instance]) end},
- { 2,
- [?sysDescr_instance, ?sysUpTime_instance],
- Exec,
- fun(X) ->
- sag_verify(X, [?sysObjectID_instance,
- ?sysUpTime_instance])
- end},
- { 3,
- [[sysObjectID, 0], [sysDescr, 0], [sysUpTime, 0]],
- Exec,
- fun(X) ->
- sag_verify(X, [?sysObjectID_instance,
- ?sysDescr_instance,
- ?sysUpTime_instance])
- end},
- { 4,
- [?sysObjectID_instance,
- ?sysDescr_instance,
- ?sysUpTime_instance],
- Exec,
- fun(X) ->
- sag_verify(X, [?sysObjectID_instance,
- ?sysDescr_instance,
- ?sysUpTime_instance])
- end}
- ],
+ Requests =
+ [
+ { 1,
+ [?sysObjectID_instance],
+ Exec,
+ fun(X) -> sag_verify(X, [?sysObjectID_instance]) end },
+ { 2,
+ [?sysDescr_instance, ?sysUpTime_instance],
+ Exec,
+ fun(X) ->
+ sag_verify(X, [?sysObjectID_instance,
+ ?sysUpTime_instance])
+ end },
+ { 3,
+ [[sysObjectID, 0], [sysDescr, 0], [sysUpTime, 0]],
+ Exec,
+ fun(X) ->
+ sag_verify(X, [?sysObjectID_instance,
+ ?sysDescr_instance,
+ ?sysUpTime_instance])
+ end },
+ { 4,
+ [?sysObjectID_instance,
+ ?sysDescr_instance,
+ ?sysUpTime_instance],
+ Exec,
+ fun(X) ->
+ sag_verify(X, [?sysObjectID_instance,
+ ?sysDescr_instance,
+ ?sysUpTime_instance])
+ end }
+ ],
p("manager info when starting test: ~n~p", [mgr_info(MgrNode)]),
p("agent info when starting test: ~n~p", [agent_info(AgentNode)]),
@@ -1516,66 +1651,76 @@ sag_verify_vbs([Vb|_], [E|_]) ->
%%======================================================================
-simple_async_get2(doc) -> ["Simple (async) get-request - "
- "New style (TargetName)"];
+simple_async_get2(doc) ->
+ ["Simple (async) get-request - Version 2 API (TargetName)"];
simple_async_get2(suite) -> [];
simple_async_get2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
put(tname, sag2),
p("starting with Config: ~p~n", [Config]),
-
MgrNode = ?config(manager_node, Config),
AgentNode = ?config(agent_node, 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) ->
?line ok = mgr_user_load_mib(MgrNode, std_mib()),
Test2Mib = test2_mib(Config),
?line ok = mgr_user_load_mib(MgrNode, Test2Mib),
?line ok = agent_load_mib(AgentNode, Test2Mib),
-
- Exec = fun(Data) ->
- async_g_exec2(MgrNode, TargetName, Data)
- end,
-
- Requests = [
- { 1,
- [?sysObjectID_instance],
- Exec,
- fun(X) -> sag_verify(X, [?sysObjectID_instance]) end},
- { 2,
- [?sysDescr_instance, ?sysUpTime_instance],
- Exec,
- fun(X) ->
- sag_verify(X, [?sysObjectID_instance,
- ?sysUpTime_instance])
- end},
- { 3,
- [[sysObjectID, 0], [sysDescr, 0], [sysUpTime, 0]],
- Exec,
- fun(X) ->
- sag_verify(X, [?sysObjectID_instance,
- ?sysDescr_instance,
- ?sysUpTime_instance])
- end},
- { 4,
- [?sysObjectID_instance,
- ?sysDescr_instance,
- ?sysUpTime_instance],
- Exec,
- fun(X) ->
- sag_verify(X, [?sysObjectID_instance,
- ?sysDescr_instance,
- ?sysUpTime_instance])
- end}
- ],
+ do_simple_async_sync_get2(fun() -> mgr_info(MgrNode) end,
+ fun() -> agent_info(AgentNode) end,
+ Get, PostVerify).
+
+do_simple_async_sync_get2(MgrInfo, AgentInfo, Get, PostVerify)
+ when is_function(MgrInfo, 0) andalso
+ is_function(AgentInfo, 0) andalso
+ is_function(Get, 1) andalso
+ is_function(PostVerify, 1) ->
+ Requests =
+ [
+ { 1,
+ [?sysObjectID_instance],
+ Get,
+ fun(X) ->
+ PostVerify(sag_verify(X, [?sysObjectID_instance])) end},
+ { 2,
+ [?sysDescr_instance, ?sysUpTime_instance],
+ Get,
+ fun(X) ->
+ PostVerify(sag_verify(X, [?sysObjectID_instance,
+ ?sysUpTime_instance]))
+ end},
+ { 3,
+ [[sysObjectID, 0], [sysDescr, 0], [sysUpTime, 0]],
+ Get,
+ fun(X) ->
+ PostVerify(sag_verify(X, [?sysObjectID_instance,
+ ?sysDescr_instance,
+ ?sysUpTime_instance]))
+
+ end},
+ { 4,
+ [?sysObjectID_instance,
+ ?sysDescr_instance,
+ ?sysUpTime_instance],
+ Get,
+ fun(X) ->
+ PostVerify(sag_verify(X, [?sysObjectID_instance,
+ ?sysDescr_instance,
+ ?sysUpTime_instance]))
+ end}
+ ],
- p("manager info when starting test: ~n~p", [mgr_info(MgrNode)]),
- p("agent info when starting test: ~n~p", [agent_info(AgentNode)]),
+ p("manager info when starting test: ~n~p", [MgrInfo()]),
+ p("agent info when starting test: ~n~p", [AgentInfo()]),
?line ok = async_exec(Requests, []),
- p("manager info when ending test: ~n~p", [mgr_info(MgrNode)]),
- p("agent info when ending test: ~n~p", [agent_info(AgentNode)]),
+ p("manager info when ending test: ~n~p", [MgrInfo()]),
+ p("agent info when ending test: ~n~p", [AgentInfo()]),
ok.
@@ -1585,6 +1730,36 @@ async_g_exec2(Node, TargetName, Oids) ->
%%======================================================================
+simple_async_get3(doc) ->
+ ["Simple (async) get-request - Version 3 API (TargetName and send-opts)"];
+simple_async_get3(suite) -> [];
+simple_async_get3(Config) when is_list(Config) ->
+ process_flag(trap_exit, true),
+ put(tname, sag3),
+ p("starting with Config: ~p~n", [Config]),
+ MgrNode = ?config(manager_node, Config),
+ AgentNode = ?config(agent_node, Config),
+ TargetName = ?config(manager_agent_target_name, Config),
+ Self = self(),
+ Msg = simple_async_get3,
+ Fun = fun() -> Self ! Msg end,
+ Extra = {?SNMPM_EXTRA_INFO_TAG, Fun},
+ SendOpts =
+ [
+ {extra, Extra}
+ ],
+ Get = fun(Oids) -> async_g_exec3(MgrNode, TargetName, Oids, SendOpts) end,
+ PostVerify = fun(ok) -> receive Msg -> ok end;
+ (Error) -> Error
+ end,
+ do_simple_async_sync_get2(Config, MgrNode, AgentNode, Get, PostVerify).
+
+async_g_exec3(Node, TargetName, Oids, SendOpts) ->
+ mgr_user_async_get2(Node, TargetName, Oids, SendOpts).
+
+
+%%======================================================================
+
simple_sync_get_next1(doc) -> ["Simple (sync) get_next-request - "
"Old style (Addr & Port)"];
simple_sync_get_next1(suite) -> [];
@@ -1722,23 +1897,33 @@ check_ssgn_vbs([Vb|_], [E|_]) ->
%%======================================================================
-simple_sync_get_next2(doc) -> ["Simple (sync) get_next-request - "
- "New style (TargetName)"];
+simple_sync_get_next2(doc) ->
+ ["Simple (sync) get_next-request - Version 2 API (TargetName)"];
simple_sync_get_next2(suite) -> [];
simple_sync_get_next2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- put(tname, ssgn),
+ put(tname, ssgn2),
p("starting with Config: ~p~n", [Config]),
- MgrNode = ?config(manager_node, Config),
- AgentNode = ?config(agent_node, Config),
+ GetNext = fun(Node, TargetName, Oids) ->
+ 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)
+ when is_function(GetNext, 3) andalso is_function(PostVerify, 1) ->
+
+ MgrNode = ?config(manager_node, Config),
+ AgentNode = ?config(agent_node, Config),
TargetName = ?config(manager_agent_target_name, Config),
%% -- 1 --
Oids01 = [[1,3,7,1]],
VF01 = fun(X) -> verify_ssgn_reply1(X, [{[1,3,7,1],endOfMibView}]) end,
?line ok = do_simple_get_next(1,
- MgrNode, TargetName, Oids01, VF01),
+ MgrNode, TargetName, Oids01, VF01,
+ GetNext, PostVerify),
?line ok = mgr_user_load_mib(MgrNode, std_mib()),
@@ -1748,7 +1933,8 @@ simple_sync_get_next2(Config) when is_list(Config) ->
verify_ssgn_reply1(X, [?sysDescr_instance, endOfMibView])
end,
?line ok = do_simple_get_next(2,
- MgrNode, TargetName, Oids02, VF02),
+ MgrNode, TargetName, Oids02, VF02,
+ GetNext, PostVerify),
Test2Mib = test2_mib(Config),
?line ok = mgr_user_load_mib(MgrNode, Test2Mib),
@@ -1761,7 +1947,8 @@ simple_sync_get_next2(Config) when is_list(Config) ->
verify_ssgn_reply1(X, [{fl([TCnt2,2]), 100}])
end,
?line ok = do_simple_get_next(3,
- MgrNode, TargetName, Oids03, VF03),
+ MgrNode, TargetName, Oids03, VF03,
+ GetNext, PostVerify),
%% -- 4 --
Oids04 = [[TCnt2, 2]],
@@ -1769,7 +1956,8 @@ simple_sync_get_next2(Config) when is_list(Config) ->
verify_ssgn_reply1(X, [{fl([TCnt2,2]), endOfMibView}])
end,
?line ok = do_simple_get_next(4,
- MgrNode, TargetName, Oids04, VF04),
+ MgrNode, TargetName, Oids04, VF04,
+ GetNext, PostVerify),
%% -- 5 --
?line {ok, [TGenErr1|_]} = mgr_user_name_to_oid(MgrNode, tGenErr1),
@@ -1778,7 +1966,8 @@ simple_sync_get_next2(Config) when is_list(Config) ->
verify_ssgn_reply2(X, {genErr, 1, [TGenErr1]})
end,
?line ok = do_simple_get_next(5,
- MgrNode, TargetName, Oids05, VF05),
+ MgrNode, TargetName, Oids05, VF05,
+ GetNext, PostVerify),
%% -- 6 --
?line {ok, [TGenErr2|_]} = mgr_user_name_to_oid(MgrNode, tGenErr2),
@@ -1787,7 +1976,8 @@ simple_sync_get_next2(Config) when is_list(Config) ->
verify_ssgn_reply2(X, {genErr, 1, [TGenErr2]})
end,
?line ok = do_simple_get_next(6,
- MgrNode, TargetName, Oids06, VF06),
+ MgrNode, TargetName, Oids06, VF06,
+ GetNext, PostVerify),
%% -- 7 --
?line {ok, [TGenErr3|_]} = mgr_user_name_to_oid(MgrNode, tGenErr3),
@@ -1797,7 +1987,8 @@ simple_sync_get_next2(Config) when is_list(Config) ->
[?sysDescr, TGenErr3]})
end,
?line ok = do_simple_get_next(7,
- MgrNode, TargetName, Oids07, VF07),
+ MgrNode, TargetName, Oids07, VF07,
+ GetNext, PostVerify),
%% -- 8 --
?line {ok, [TTooBig|_]} = mgr_user_name_to_oid(MgrNode, tTooBig),
@@ -1806,18 +1997,19 @@ simple_sync_get_next2(Config) when is_list(Config) ->
verify_ssgn_reply2(X, {tooBig, 0, []})
end,
?line ok = do_simple_get_next(8,
- MgrNode, TargetName, Oids08, VF08),
+ MgrNode, TargetName, Oids08, VF08,
+ GetNext, PostVerify),
ok.
-do_simple_get_next(N, Node, TargetName, Oids, Verify) ->
+do_simple_get_next(N, Node, TargetName, Oids, Verify, GetNext, PostVerify) ->
p("issue get-next command ~w", [N]),
- case mgr_user_sync_get_next(Node, TargetName, Oids) of
+ case GetNext(Node, TargetName, Oids) of
{ok, Reply, Rem} ->
?DBG("get-next ok:"
"~n Reply: ~p"
"~n Rem: ~w", [Reply, Rem]),
- Verify(Reply);
+ PostVerify(Verify(Reply));
Error ->
{error, {unexpected_reply, Error}}
@@ -1826,6 +2018,33 @@ do_simple_get_next(N, Node, TargetName, Oids, Verify) ->
%%======================================================================
+simple_sync_get_next3(doc) ->
+ ["Simple (sync) get_next-request - "
+ "Version 3 API (TargetName with send-opts)"];
+simple_sync_get_next3(suite) -> [];
+simple_sync_get_next3(Config) when is_list(Config) ->
+ process_flag(trap_exit, true),
+ put(tname, ssgn3),
+ p("starting with Config: ~p~n", [Config]),
+ Self = self(),
+ Msg = simple_sync_get_next3,
+ Fun = fun() -> Self ! Msg end,
+ Extra = {?SNMPM_EXTRA_INFO_TAG, Fun},
+ SendOpts =
+ [
+ {extra, Extra}
+ ],
+ GetNext = fun(Node, TargetName, Oids) ->
+ mgr_user_sync_get_next2(Node, TargetName, Oids, SendOpts)
+ end,
+ PostVerify = fun(ok) -> receive Msg -> ok end;
+ (Error) -> Error
+ end,
+ do_simple_sync_get_next2(Config, GetNext, PostVerify).
+
+
+%%======================================================================
+
simple_async_get_next1(doc) -> ["Simple (async) get_next-request - "
"Old style (Addr & Port)"];
simple_async_get_next1(suite) -> [];
@@ -1923,8 +2142,8 @@ async_gn_exec1(Node, Addr, Port, Oids) ->
%%======================================================================
-simple_async_get_next2(doc) -> ["Simple (async) get_next-request - "
- "New style (TargetName)"];
+simple_async_get_next2(doc) ->
+ ["Simple (async) get_next-request - Version 2 API (TargetName)"];
simple_async_get_next2(suite) -> [];
simple_async_get_next2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
@@ -1939,11 +2158,14 @@ simple_async_get_next2(Config) when is_list(Config) ->
Test2Mib = test2_mib(Config),
?line ok = mgr_user_load_mib(MgrNode, Test2Mib),
?line ok = agent_load_mib(AgentNode, Test2Mib),
-
- Exec = fun(X) ->
- async_gn_exec2(MgrNode, TargetName, X)
- end,
-
+ GetNext = fun(Oids) ->
+ 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)
+ when is_function(GetNext, 1) andalso is_function(PostVerify, 1) ->
?line {ok, [TCnt2|_]} = mgr_user_name_to_oid(MgrNode, tCnt2),
?line {ok, [TGenErr1|_]} = mgr_user_name_to_oid(MgrNode, tGenErr1),
?line {ok, [TGenErr2|_]} = mgr_user_name_to_oid(MgrNode, tGenErr2),
@@ -1954,51 +2176,60 @@ simple_async_get_next2(Config) when is_list(Config) ->
[
{1,
[[1,3,7,1]],
- Exec,
+ GetNext,
fun(X) ->
- verify_ssgn_reply1(X, [{[1,3,7,1], endOfMibView}])
+ PostVerify(
+ verify_ssgn_reply1(X, [{[1,3,7,1], endOfMibView}]))
+
end},
{2,
[[sysDescr], [1,3,7,1]],
- Exec,
+ GetNext,
fun(X) ->
- verify_ssgn_reply1(X, [?sysDescr_instance, endOfMibView])
+ PostVerify(
+ verify_ssgn_reply1(X, [?sysDescr_instance, endOfMibView]))
end},
{3,
[[TCnt2, 1]],
- Exec,
+ GetNext,
fun(X) ->
- verify_ssgn_reply1(X, [{fl([TCnt2,2]), 100}])
+ PostVerify(
+ verify_ssgn_reply1(X, [{fl([TCnt2,2]), 100}]))
end},
{4,
[[TCnt2, 2]],
- Exec,
+ GetNext,
fun(X) ->
- verify_ssgn_reply1(X, [{fl([TCnt2,2]), endOfMibView}])
+ PostVerify(
+ verify_ssgn_reply1(X, [{fl([TCnt2,2]), endOfMibView}]))
end},
{5,
[TGenErr1],
- Exec,
+ GetNext,
fun(X) ->
- verify_ssgn_reply2(X, {genErr, 1, [TGenErr1]})
+ PostVerify(
+ verify_ssgn_reply2(X, {genErr, 1, [TGenErr1]}))
end},
{6,
[TGenErr2],
- Exec,
+ GetNext,
fun(X) ->
- verify_ssgn_reply2(X, {genErr, 1, [TGenErr2]})
+ PostVerify(
+ verify_ssgn_reply2(X, {genErr, 1, [TGenErr2]}))
end},
{7,
[[sysDescr], TGenErr3],
- Exec,
+ GetNext,
fun(X) ->
- verify_ssgn_reply2(X, {genErr, 2, [TGenErr3]})
+ PostVerify(
+ verify_ssgn_reply2(X, {genErr, 2, [TGenErr3]}))
end},
{8,
[TTooBig],
- Exec,
+ GetNext,
fun(X) ->
- verify_ssgn_reply2(X, {tooBig, 0, []})
+ PostVerify(
+ verify_ssgn_reply2(X, {tooBig, 0, []}))
end}
],
@@ -2019,6 +2250,48 @@ async_gn_exec2(Node, TargetName, Oids) ->
%%======================================================================
+simple_async_get_next3(doc) ->
+ ["Simple (async) get_next-request - "
+ "Version 3 API (TargetName with send-opts)"];
+simple_async_get_next3(suite) -> [];
+simple_async_get_next3(Config) when is_list(Config) ->
+ process_flag(trap_exit, true),
+ put(tname, ssgn2),
+ p("starting with Config: ~p~n", [Config]),
+
+ MgrNode = ?config(manager_node, Config),
+ AgentNode = ?config(agent_node, Config),
+ TargetName = ?config(manager_agent_target_name, Config),
+
+ ?line ok = mgr_user_load_mib(MgrNode, std_mib()),
+ Test2Mib = test2_mib(Config),
+ ?line ok = mgr_user_load_mib(MgrNode, Test2Mib),
+ ?line ok = agent_load_mib(AgentNode, Test2Mib),
+
+ Self = self(),
+ Msg = simple_async_get_next3,
+ Fun = fun() -> Self ! Msg end,
+ Extra = {?SNMPM_EXTRA_INFO_TAG, Fun},
+ SendOpts =
+ [
+ {extra, Extra}
+ ],
+
+ GetNext = fun(Oids) ->
+ async_gn_exec3(MgrNode, TargetName, Oids, SendOpts)
+ end,
+ PostVerify = fun(ok) -> receive Msg -> ok end;
+ (Error) -> Error
+ end,
+
+ do_simple_async_get_next2(MgrNode, AgentNode, GetNext, PostVerify).
+
+async_gn_exec3(Node, TargetName, Oids, SendOpts) ->
+ mgr_user_async_get_next2(Node, TargetName, Oids, SendOpts).
+
+
+%%======================================================================
+
simple_sync_set1(doc) -> ["Simple (sync) set-request - "
"Old style (Addr & Port)"];
simple_sync_set1(suite) -> [];
@@ -2088,14 +2361,25 @@ value_of_vavs([{_Oid, Val}|VAVs], Acc) ->
%%======================================================================
-simple_sync_set2(doc) -> ["Simple (sync) set-request - New style (TargetName)"];
+simple_sync_set2(doc) ->
+ ["Simple (sync) set-request - Version 2 API (TargetName)"];
simple_sync_set2(suite) -> [];
simple_sync_set2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
put(tname, sss2),
p("starting with Config: ~p~n", [Config]),
- Node = ?config(manager_node, Config),
+ Set = fun(Node, TargetName, VAVs) ->
+ mgr_user_sync_set(Node, TargetName, VAVs)
+ end,
+ PostVerify = fun() -> ok end,
+
+ do_simple_sync_set2(Config, Set, PostVerify).
+
+do_simple_sync_set2(Config, Set, PostVerify)
+ when is_function(Set, 3) andalso is_function(PostVerify, 0) ->
+
+ Node = ?config(manager_node, Config),
TargetName = ?config(manager_agent_target_name, Config),
p("issue set-request without loading the mib"),
@@ -2105,7 +2389,7 @@ simple_sync_set2(Config) when is_list(Config) ->
{?sysName_instance, s, Val11},
{?sysLocation_instance, s, Val12}
],
- ?line ok = do_simple_set2(Node, TargetName, VAVs1),
+ ?line ok = do_simple_set2(Node, TargetName, VAVs1, Set, PostVerify),
p("issue set-request after first loading the mibs"),
?line ok = mgr_user_load_mib(Node, std_mib()),
@@ -2115,12 +2399,12 @@ simple_sync_set2(Config) when is_list(Config) ->
{[sysName, 0], Val21},
{[sysLocation, 0], Val22}
],
- ?line ok = do_simple_set2(Node, TargetName, VAVs2),
+ ?line ok = do_simple_set2(Node, TargetName, VAVs2, Set, PostVerify),
ok.
-do_simple_set2(Node, TargetName, VAVs) ->
+do_simple_set2(Node, TargetName, VAVs, Set, PostVerify) ->
[SysName, SysLoc] = value_of_vavs(VAVs),
- ?line {ok, Reply, Rem} = mgr_user_sync_set(Node, TargetName, VAVs),
+ ?line {ok, Reply, Rem} = Set(Node, TargetName, VAVs),
?DBG("~n Reply: ~p"
"~n Rem: ~w", [Reply, Rem]),
@@ -2133,7 +2417,7 @@ do_simple_set2(Node, TargetName, VAVs) ->
value = SysName},
#varbind{oid = ?sysLocation_instance,
value = SysLoc}]} ->
- ok;
+ PostVerify();
{noError, 0, Vbs} ->
{error, {unexpected_vbs, Vbs}};
Else ->
@@ -2145,6 +2429,33 @@ do_simple_set2(Node, TargetName, VAVs) ->
%%======================================================================
+simple_sync_set3(doc) ->
+ ["Simple (sync) set-request - Version 3 API (TargetName with send-opts)"];
+simple_sync_set3(suite) -> [];
+simple_sync_set3(Config) when is_list(Config) ->
+ process_flag(trap_exit, true),
+ put(tname, sss3),
+ p("starting with Config: ~p~n", [Config]),
+
+ Self = self(),
+ Msg = simple_sync_set3,
+ Fun = fun() -> Self ! Msg end,
+ Extra = {?SNMPM_EXTRA_INFO_TAG, Fun},
+ SendOpts =
+ [
+ {extra, Extra}
+ ],
+
+ Set = fun(Node, TargetName, VAVs) ->
+ mgr_user_sync_set2(Node, TargetName, VAVs, SendOpts)
+ end,
+ PostVerify = fun() -> receive Msg -> ok end end,
+
+ do_simple_sync_set2(Config, Set, PostVerify).
+
+
+%%======================================================================
+
simple_async_set1(doc) -> ["Simple (async) set-request - "
"Old style (Addr & Port)"];
simple_async_set1(suite) -> [];
@@ -2237,8 +2548,8 @@ sas_verify_vbs([Vb|_], [E|_]) ->
%%======================================================================
-simple_async_set2(doc) -> ["Simple (async) set-request - "
- "New style (TargetName)"];
+simple_async_set2(doc) ->
+ ["Simple (async) set-request - Version 2 API (TargetName)"];
simple_async_set2(suite) -> [];
simple_async_set2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
@@ -2254,31 +2565,40 @@ simple_async_set2(Config) when is_list(Config) ->
?line ok = mgr_user_load_mib(MgrNode, Test2Mib),
?line ok = agent_load_mib(AgentNode, Test2Mib),
- Exec = fun(X) ->
- async_s_exec2(MgrNode, TargetName, X)
- end,
+ Set =
+ fun(Oids) ->
+ async_s_exec2(MgrNode, TargetName, Oids)
+ end,
+ PostVerify = fun(Res) -> Res end,
+
+ do_simple_async_set2(MgrNode, AgentNode, Set, PostVerify).
+do_simple_async_set2(MgrNode, AgentNode, Set, PostVerify) ->
Requests =
[
{1,
[{?sysName_instance, s, "Arne Anka"}],
- Exec,
+ Set,
fun(X) ->
- sas_verify(X, [?sysName_instance])
+ PostVerify(sas_verify(X, [?sysName_instance]))
end},
{2,
[{?sysLocation_instance, s, "Stockholm"},
{?sysName_instance, s, "Arne Anka"}],
- Exec,
+ Set,
fun(X) ->
- sas_verify(X, [?sysLocation_instance, ?sysName_instance])
+ PostVerify(sas_verify(X,
+ [?sysLocation_instance,
+ ?sysName_instance]))
end},
{3,
[{[sysName, 0], "Gothenburg"},
{[sysLocation, 0], "Sune Anka"}],
- Exec,
+ Set,
fun(X) ->
- sas_verify(X, [?sysName_instance, ?sysLocation_instance])
+ PostVerify(sas_verify(X,
+ [?sysName_instance,
+ ?sysLocation_instance]))
end}
],
@@ -2299,6 +2619,48 @@ async_s_exec2(Node, TargetName, VAVs) ->
%%======================================================================
+simple_async_set3(doc) ->
+ ["Simple (async) set-request - Version 3 API (TargetName with send-opts)"];
+simple_async_set3(suite) -> [];
+simple_async_set3(Config) when is_list(Config) ->
+ process_flag(trap_exit, true),
+ put(tname, sas3),
+ p("starting with Config: ~p~n", [Config]),
+
+ MgrNode = ?config(manager_node, Config),
+ AgentNode = ?config(agent_node, Config),
+ TargetName = ?config(manager_agent_target_name, Config),
+
+ ?line ok = mgr_user_load_mib(MgrNode, std_mib()),
+ Test2Mib = test2_mib(Config),
+ ?line ok = mgr_user_load_mib(MgrNode, Test2Mib),
+ ?line ok = agent_load_mib(AgentNode, Test2Mib),
+
+ Self = self(),
+ Msg = simple_async_set3,
+ Fun = fun() -> Self ! Msg end,
+ Extra = {?SNMPM_EXTRA_INFO_TAG, Fun},
+ SendOpts =
+ [
+ {extra, Extra}
+ ],
+
+ Set =
+ fun(Oids) ->
+ async_s_exec3(MgrNode, TargetName, Oids, SendOpts)
+ end,
+ PostVerify = fun(ok) -> receive Msg -> ok end;
+ (Res) -> Res
+ end,
+
+ do_simple_async_set2(MgrNode, AgentNode, Set, PostVerify).
+
+async_s_exec3(Node, TargetName, VAVs, SendOpts) ->
+ mgr_user_async_set2(Node, TargetName, VAVs, SendOpts).
+
+
+%%======================================================================
+
simple_sync_get_bulk1(doc) -> ["Simple (sync) get_bulk-request - "
"Old style (Addr & Port)"];
simple_sync_get_bulk1(suite) -> [];
@@ -2470,8 +2832,8 @@ check_ssgb_vbs([R|_], [E|_]) ->
%%======================================================================
-simple_sync_get_bulk2(doc) -> ["Simple (sync) get_bulk-request - "
- "New style (TargetName)"];
+simple_sync_get_bulk2(doc) ->
+ ["Simple (sync) get_bulk-request - Version 2 API (TargetName)"];
simple_sync_get_bulk2(suite) -> [];
simple_sync_get_bulk2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
@@ -2482,20 +2844,33 @@ simple_sync_get_bulk2(Config) when is_list(Config) ->
AgentNode = ?config(agent_node, Config),
TargetName = ?config(manager_agent_target_name, Config),
+ GetBulk =
+ fun(NonRep, MaxRep, Oids) ->
+ mgr_user_sync_get_bulk(MgrNode, TargetName,
+ NonRep, MaxRep, Oids)
+ 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) ->
%% -- 1 --
?line ok = do_simple_get_bulk2(1,
- MgrNode, TargetName, 1, 1, [],
- fun verify_ssgb_reply1/1),
+ 1, 1, [],
+ fun verify_ssgb_reply1/1,
+ GetBulk, PostVerify),
%% -- 2 --
?line ok = do_simple_get_bulk2(2,
- MgrNode, TargetName, -1, 1, [],
- fun verify_ssgb_reply1/1),
+ -1, 1, [],
+ fun verify_ssgb_reply1/1,
+ GetBulk, PostVerify),
%% -- 3 --
?line ok = do_simple_get_bulk2(3,
- MgrNode, TargetName, -1, -1, [],
- fun verify_ssgb_reply1/1),
+ -1, -1, [],
+ fun verify_ssgb_reply1/1,
+ GetBulk, PostVerify),
?line ok = mgr_user_load_mib(MgrNode, std_mib()),
%% -- 4 --
@@ -2503,13 +2878,13 @@ simple_sync_get_bulk2(Config) when is_list(Config) ->
verify_ssgb_reply2(X, [?sysDescr_instance, endOfMibView])
end,
?line ok = do_simple_get_bulk2(4,
- MgrNode, TargetName,
- 2, 0, [[sysDescr],[1,3,7,1]], VF04),
+ 2, 0, [[sysDescr],[1,3,7,1]], VF04,
+ GetBulk, PostVerify),
%% -- 5 --
?line ok = do_simple_get_bulk2(5,
- MgrNode, TargetName,
- 1, 2, [[sysDescr],[1,3,7,1]], VF04),
+ 1, 2, [[sysDescr],[1,3,7,1]], VF04,
+ GetBulk, PostVerify),
%% -- 6 --
VF06 = fun(X) ->
@@ -2518,8 +2893,8 @@ simple_sync_get_bulk2(Config) when is_list(Config) ->
?sysObjectID_instance, endOfMibView])
end,
?line ok = do_simple_get_bulk2(6,
- MgrNode, TargetName,
- 0, 2, [[sysDescr],[1,3,7,1]], VF06),
+ 0, 2, [[sysDescr],[1,3,7,1]], VF06,
+ GetBulk, PostVerify),
%% -- 7 --
VF07 = fun(X) ->
@@ -2529,10 +2904,10 @@ simple_sync_get_bulk2(Config) when is_list(Config) ->
?sysObjectID_instance, endOfMibView])
end,
?line ok = do_simple_get_bulk2(7,
- MgrNode, TargetName,
2, 2,
[[sysDescr],[1,3,7,1],[sysDescr],[1,3,7,1]],
- VF07),
+ VF07,
+ GetBulk, PostVerify),
Test2Mib = test2_mib(Config),
?line ok = mgr_user_load_mib(MgrNode, Test2Mib),
@@ -2545,17 +2920,17 @@ simple_sync_get_bulk2(Config) when is_list(Config) ->
?sysDescr_instance])
end,
?line ok = do_simple_get_bulk2(8,
- MgrNode, TargetName,
1, 2,
[[sysDescr],[sysDescr],[tTooBig]],
- VF08),
+ VF08,
+ GetBulk, PostVerify),
%% -- 9 --
?line ok = do_simple_get_bulk2(9,
- MgrNode, TargetName,
1, 12,
[[tDescr2], [sysDescr]],
- fun verify_ssgb_reply1/1),
+ fun verify_ssgb_reply1/1,
+ GetBulk, PostVerify),
%% -- 10 --
VF10 = fun(X) ->
@@ -2566,13 +2941,13 @@ simple_sync_get_bulk2(Config) when is_list(Config) ->
{?sysDescr, 'NULL'}])
end,
?line ok = do_simple_get_bulk2(10,
- MgrNode, TargetName,
2, 2,
[[sysDescr],
[sysObjectID],
[tGenErr1],
[sysDescr]],
- VF10),
+ VF10,
+ GetBulk, PostVerify),
%% -- 11 --
?line {ok, [TCnt2|_]} = mgr_user_name_to_oid(MgrNode, tCnt2),
@@ -2583,20 +2958,25 @@ simple_sync_get_bulk2(Config) when is_list(Config) ->
{fl([TCnt2,2]), endOfMibView}])
end,
?line ok = do_simple_get_bulk2(11,
- MgrNode, TargetName,
0, 2,
- [[TCnt2, 1]], VF11),
+ [[TCnt2, 1]], VF11,
+ GetBulk, PostVerify),
ok.
-do_simple_get_bulk2(N, Node, TargetName, NonRep, MaxRep, Oids, Verify) ->
+do_simple_get_bulk2(N,
+ NonRep, MaxRep, Oids,
+ Verify, GetBulk, PostVerify)
+ when is_function(Verify, 1) andalso
+ is_function(GetBulk, 3) andalso
+ is_function(PostVerify) ->
p("issue get-bulk command ~w", [N]),
- case mgr_user_sync_get_bulk(Node, TargetName, NonRep, MaxRep, Oids) of
+ case GetBulk(NonRep, MaxRep, Oids) of
{ok, Reply, Rem} ->
?DBG("get-bulk ok:"
"~n Reply: ~p"
"~n Rem: ~w", [Reply, Rem]),
- Verify(Reply);
+ PostVerify(Verify(Reply));
Error ->
{error, {unexpected_reply, Error}}
@@ -2605,6 +2985,42 @@ do_simple_get_bulk2(N, Node, TargetName, NonRep, MaxRep, Oids, Verify) ->
%%======================================================================
+simple_sync_get_bulk3(doc) ->
+ ["Simple (sync) get_bulk-request - "
+ "Version 3 API (TargetName with send-opts)"];
+simple_sync_get_bulk3(suite) -> [];
+simple_sync_get_bulk3(Config) when is_list(Config) ->
+ process_flag(trap_exit, true),
+ put(tname, ssgb3),
+ p("starting with Config: ~p~n", [Config]),
+
+ MgrNode = ?config(manager_node, Config),
+ AgentNode = ?config(agent_node, Config),
+ TargetName = ?config(manager_agent_target_name, Config),
+
+ Self = self(),
+ Msg = simple_async_set3,
+ Fun = fun() -> Self ! Msg end,
+ Extra = {?SNMPM_EXTRA_INFO_TAG, Fun},
+ SendOpts =
+ [
+ {extra, Extra}
+ ],
+
+ GetBulk =
+ fun(NonRep, MaxRep, Oids) ->
+ mgr_user_sync_get_bulk2(MgrNode, TargetName,
+ NonRep, MaxRep, Oids, SendOpts)
+ end,
+ PostVerify = fun(ok) -> receive Msg -> ok end;
+ (Res) -> Res
+ end,
+
+ do_simple_sync_get_bulk2(Config, MgrNode, AgentNode, GetBulk, PostVerify).
+
+
+%%======================================================================
+
simple_async_get_bulk1(doc) -> ["Simple (async) get_bulk-request - "
"Old style (Addr & Port)"];
simple_async_get_bulk1(suite) -> [];
@@ -2748,8 +3164,8 @@ async_gb_exec1(Node, Addr, Port, {NR, MR, Oids}) ->
%%======================================================================
-simple_async_get_bulk2(doc) -> ["Simple (async) get_bulk-request - "
- "New style (TargetName)"];
+simple_async_get_bulk2(doc) ->
+ ["Simple (async) get_bulk-request - Version 2 API (TargetName)"];
simple_async_get_bulk2(suite) -> [];
simple_async_get_bulk2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
@@ -2765,111 +3181,122 @@ simple_async_get_bulk2(Config) when is_list(Config) ->
?line ok = mgr_user_load_mib(MgrNode, Test2Mib),
?line ok = agent_load_mib(AgentNode, Test2Mib),
- Exec = fun(Data) ->
- async_gb_exec2(MgrNode, TargetName, Data)
- end,
+ GetBulk =
+ fun(Data) ->
+ async_gb_exec2(MgrNode, TargetName, Data)
+ end,
+ PostVerify = fun(Res) -> Res end,
+ do_simple_async_get_bulk2(MgrNode, AgentNode, GetBulk, PostVerify).
+
+do_simple_async_get_bulk2(MgrNode, AgentNode, GetBulk, PostVerify) ->
%% We re-use the verification functions from the ssgb test-case
VF04 = fun(X) ->
- verify_ssgb_reply2(X, [?sysDescr_instance, endOfMibView])
+ PostVerify(
+ verify_ssgb_reply2(X, [?sysDescr_instance, endOfMibView]))
end,
VF06 = fun(X) ->
- verify_ssgb_reply2(X,
- [?sysDescr_instance, endOfMibView,
- ?sysObjectID_instance, endOfMibView])
+ PostVerify(
+ verify_ssgb_reply2(X,
+ [?sysDescr_instance, endOfMibView,
+ ?sysObjectID_instance, endOfMibView]))
end,
VF07 = fun(X) ->
- verify_ssgb_reply2(X,
- [?sysDescr_instance, endOfMibView,
- ?sysDescr_instance, endOfMibView,
- ?sysObjectID_instance, endOfMibView])
+ PostVerify(
+ verify_ssgb_reply2(X,
+ [?sysDescr_instance, endOfMibView,
+ ?sysDescr_instance, endOfMibView,
+ ?sysObjectID_instance, endOfMibView]))
end,
VF08 = fun(X) ->
- verify_ssgb_reply2(X,
- [?sysDescr_instance,
- ?sysDescr_instance])
+ PostVerify(
+ verify_ssgb_reply2(X,
+ [?sysDescr_instance,
+ ?sysDescr_instance]))
end,
VF10 = fun(X) ->
- verify_ssgb_reply3(X,
- [{?sysDescr, 'NULL'},
- {?sysObjectID, 'NULL'},
- {?tGenErr1, 'NULL'},
- {?sysDescr, 'NULL'}])
+ PostVerify(
+ verify_ssgb_reply3(X,
+ [{?sysDescr, 'NULL'},
+ {?sysObjectID, 'NULL'},
+ {?tGenErr1, 'NULL'},
+ {?sysDescr, 'NULL'}]))
end,
?line {ok, [TCnt2|_]} = mgr_user_name_to_oid(MgrNode, tCnt2),
VF11 = fun(X) ->
- verify_ssgb_reply2(X,
- [{fl([TCnt2,2]), 100},
- {fl([TCnt2,2]), endOfMibView}])
+ PostVerify(
+ verify_ssgb_reply2(X,
+ [{fl([TCnt2,2]), 100},
+ {fl([TCnt2,2]), endOfMibView}]))
end,
Requests = [
{ 1,
{1, 1, []},
- Exec,
- fun verify_ssgb_reply1/1},
+ GetBulk,
+ fun(X) -> PostVerify(verify_ssgb_reply1(X)) end},
{ 2,
{-1, 1, []},
- Exec,
- fun verify_ssgb_reply1/1},
+ GetBulk,
+ fun(X) -> PostVerify(verify_ssgb_reply1(X)) end},
{ 3,
{-1, -1, []},
- Exec,
- fun verify_ssgb_reply1/1},
+ GetBulk,
+ fun(X) -> PostVerify(verify_ssgb_reply1(X)) end},
{ 4,
{2, 0, [[sysDescr],[1,3,7,1]]},
- Exec,
+ GetBulk,
VF04},
{ 5,
{1, 2, [[sysDescr],[1,3,7,1]]},
- Exec,
+ GetBulk,
VF04},
{ 6,
{0, 2, [[sysDescr],[1,3,7,1]]},
- Exec,
+ GetBulk,
VF06},
{ 7,
{2, 2, [[sysDescr],[1,3,7,1],[sysDescr],[1,3,7,1]]},
- Exec,
+ GetBulk,
VF07},
{ 8,
{1, 2, [[sysDescr],[sysDescr],[tTooBig]]},
- Exec,
+ GetBulk,
VF08},
{ 9,
{1, 12, [[tDescr2], [sysDescr]]},
- Exec,
- fun verify_ssgb_reply1/1},
+ GetBulk,
+ fun(X) -> PostVerify(verify_ssgb_reply1(X)) end},
{10,
{2, 2, [[sysDescr],[sysObjectID], [tGenErr1],[sysDescr]]},
- Exec,
+ GetBulk,
VF10},
{11,
{0, 2, [[TCnt2, 1]]},
- Exec,
+ GetBulk,
VF11},
{12,
{2, 0, [[sysDescr],[1,3,7,1]]},
- Exec,
+ GetBulk,
VF04},
{13,
{1, 12, [[tDescr2], [sysDescr]]},
- Exec,
- fun verify_ssgb_reply1/1},
+ GetBulk,
+ fun(X) -> PostVerify(verify_ssgb_reply1(X)) end},
{14,
{2, 2, [[sysDescr],[sysObjectID],[tGenErr1],[sysDescr]]},
- Exec,
+ GetBulk,
VF10},
{15,
{0, 2, [[TCnt2, 1]]},
- Exec,
+ GetBulk,
VF11},
{16,
{2, 2, [[sysDescr],[1,3,7,1],[sysDescr],[1,3,7,1]]},
- Exec,
+ GetBulk,
VF07},
{17,
{2, 2, [[sysDescr],[sysObjectID], [tGenErr1],[sysDescr]]},
- Exec,
+ GetBulk,
VF10}
],
@@ -2890,6 +3317,49 @@ async_gb_exec2(Node, TargetName, {NR, MR, Oids}) ->
%%======================================================================
+simple_async_get_bulk3(doc) ->
+ ["Simple (async) get_bulk-request - "
+ "Version 3 API (TargetName with send-opts)"];
+simple_async_get_bulk3(suite) -> [];
+simple_async_get_bulk3(Config) when is_list(Config) ->
+ process_flag(trap_exit, true),
+ put(tname, sagb3),
+ p("starting with Config: ~p~n", [Config]),
+
+ MgrNode = ?config(manager_node, Config),
+ AgentNode = ?config(agent_node, Config),
+ TargetName = ?config(manager_agent_target_name, Config),
+
+ ?line ok = mgr_user_load_mib(MgrNode, std_mib()),
+ Test2Mib = test2_mib(Config),
+ ?line ok = mgr_user_load_mib(MgrNode, Test2Mib),
+ ?line ok = agent_load_mib(AgentNode, Test2Mib),
+
+ Self = self(),
+ Msg = simple_async_get_bulk3,
+ Fun = fun() -> Self ! Msg end,
+ Extra = {?SNMPM_EXTRA_INFO_TAG, Fun},
+ SendOpts =
+ [
+ {extra, Extra}
+ ],
+
+ GetBulk =
+ fun(Data) ->
+ async_gb_exec3(MgrNode, TargetName, Data, SendOpts)
+ end,
+ PostVerify = fun(ok) -> receive Msg -> ok end;
+ (Res) -> Res
+ end,
+
+ do_simple_async_get_bulk2(MgrNode, AgentNode, GetBulk, PostVerify).
+
+async_gb_exec3(Node, TargetName, {NR, MR, Oids}, SendOpts) ->
+ mgr_user_async_get_bulk2(Node, TargetName, NR, MR, Oids, SendOpts).
+
+
+%%======================================================================
+
misc_async1(doc) -> ["Misc (async) request(s) - "
"Old style (Addr & Port)"];
misc_async1(suite) -> [];
@@ -3079,8 +3549,8 @@ misc_async1(Config) when is_list(Config) ->
%%======================================================================
-misc_async2(doc) -> ["Misc (async) request(s) - "
- "New style (TargetName)"];
+misc_async2(doc) ->
+ ["Misc (async) request(s) - Version 2 API (TargetName)"];
misc_async2(suite) -> [];
misc_async2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
@@ -4440,7 +4910,7 @@ otp8395_1(suite) -> [];
otp8395_1(Config) when is_list(Config) ->
process_flag(trap_exit, true),
put(tname, otp8395_1),
- do_simple_get(Config).
+ do_simple_sync_get2(Config).
%%======================================================================
@@ -4986,6 +5456,9 @@ mgr_user_sync_get(Node, Addr_or_TargetName, Oids) ->
mgr_user_sync_get(Node, Addr, Port, Oids) ->
rcall(Node, snmp_manager_user, sync_get, [Addr, Port, Oids]).
+mgr_user_sync_get2(Node, TargetName, Oids, SendOpts) ->
+ rcall(Node, snmp_manager_user, sync_get2, [TargetName, Oids, SendOpts]).
+
%% mgr_user_async_get(Node, Oids) ->
%% mgr_user_async_get(Node, ?LOCALHOST(), ?AGENT_PORT, Oids).
mgr_user_async_get(Node, Addr_or_TargetName, Oids) ->
@@ -4993,6 +5466,9 @@ mgr_user_async_get(Node, Addr_or_TargetName, Oids) ->
mgr_user_async_get(Node, Addr, Port, Oids) ->
rcall(Node, snmp_manager_user, async_get, [Addr, Port, Oids]).
+mgr_user_async_get2(Node, TargetName, Oids, SendOpts) ->
+ rcall(Node, snmp_manager_user, async_get2, [TargetName, Oids, SendOpts]).
+
%% mgr_user_sync_get_next(Node, Oids) ->
%% mgr_user_sync_get_next(Node, ?LOCALHOST(), ?AGENT_PORT, Oids).
mgr_user_sync_get_next(Node, Addr_or_TargetName, Oids) ->
@@ -5000,6 +5476,9 @@ mgr_user_sync_get_next(Node, Addr_or_TargetName, Oids) ->
mgr_user_sync_get_next(Node, Addr, Port, Oids) ->
rcall(Node, snmp_manager_user, sync_get_next, [Addr, Port, Oids]).
+mgr_user_sync_get_next2(Node, TargetName, Oids, SendOpts) ->
+ rcall(Node, snmp_manager_user, sync_get_next2, [TargetName, Oids, SendOpts]).
+
%% mgr_user_async_get_next(Node, Oids) ->
%% mgr_user_async_get_next(Node, ?LOCALHOST(), ?AGENT_PORT, Oids).
mgr_user_async_get_next(Node, Addr_or_TargetName, Oids) ->
@@ -5007,6 +5486,9 @@ mgr_user_async_get_next(Node, Addr_or_TargetName, Oids) ->
mgr_user_async_get_next(Node, Addr, Port, Oids) ->
rcall(Node, snmp_manager_user, async_get_next, [Addr, Port, Oids]).
+mgr_user_async_get_next2(Node, TargetName, Oids, SendOpts) ->
+ rcall(Node, snmp_manager_user, async_get_next2, [TargetName, Oids, SendOpts]).
+
%% mgr_user_sync_set(Node, VAV) ->
%% mgr_user_sync_set(Node, ?LOCALHOST(), ?AGENT_PORT, VAV).
mgr_user_sync_set(Node, Addr_or_TargetName, VAV) ->
@@ -5014,6 +5496,9 @@ mgr_user_sync_set(Node, Addr_or_TargetName, VAV) ->
mgr_user_sync_set(Node, Addr, Port, VAV) ->
rcall(Node, snmp_manager_user, sync_set, [Addr, Port, VAV]).
+mgr_user_sync_set2(Node, TargetName, VAV, SendOpts) ->
+ rcall(Node, snmp_manager_user, sync_set2, [TargetName, VAV, SendOpts]).
+
%% mgr_user_async_set(Node, VAV) ->
%% mgr_user_async_set(Node, ?LOCALHOST(), ?AGENT_PORT, VAV).
mgr_user_async_set(Node, Addr_or_TargetName, VAV) ->
@@ -5021,26 +5506,37 @@ mgr_user_async_set(Node, Addr_or_TargetName, VAV) ->
mgr_user_async_set(Node, Addr, Port, VAV) ->
rcall(Node, snmp_manager_user, async_set, [Addr, Port, VAV]).
+mgr_user_async_set2(Node, TargetName, VAV, SendOpts) ->
+ rcall(Node, snmp_manager_user, async_set2, [TargetName, VAV, SendOpts]).
+
%% mgr_user_sync_get_bulk(Node, NonRep, MaxRep, Oids) ->
%% mgr_user_sync_get_bulk(Node, ?LOCALHOST(), ?AGENT_PORT,
%% NonRep, MaxRep, Oids).
mgr_user_sync_get_bulk(Node, Addr_or_TargetName, NonRep, MaxRep, Oids) ->
rcall(Node, snmp_manager_user, sync_get_bulk,
- [Addr_or_TargetName, NonRep, MaxRep, Oids]).
+ [Addr_or_TargetName, NonRep, MaxRep, Oids]).
mgr_user_sync_get_bulk(Node, Addr, Port, NonRep, MaxRep, Oids) ->
rcall(Node, snmp_manager_user, sync_get_bulk,
[Addr, Port, NonRep, MaxRep, Oids]).
+mgr_user_sync_get_bulk2(Node, TargetName, NonRep, MaxRep, Oids, SendOpts) ->
+ rcall(Node, snmp_manager_user, sync_get_bulk2,
+ [TargetName, NonRep, MaxRep, Oids, SendOpts]).
+
%% mgr_user_async_get_bulk(Node, NonRep, MaxRep, Oids) ->
%% mgr_user_async_get_bulk(Node, ?LOCALHOST(), ?AGENT_PORT,
%% NonRep, MaxRep, Oids).
mgr_user_async_get_bulk(Node, Addr_or_TargetName, NonRep, MaxRep, Oids) ->
rcall(Node, snmp_manager_user, async_get_bulk,
- [Addr_or_TargetName, NonRep, MaxRep, Oids]).
+ [Addr_or_TargetName, NonRep, MaxRep, Oids]).
mgr_user_async_get_bulk(Node, Addr, Port, NonRep, MaxRep, Oids) ->
rcall(Node, snmp_manager_user, async_get_bulk,
[Addr, Port, NonRep, MaxRep, Oids]).
+mgr_user_async_get_bulk2(Node, TargetName, NonRep, MaxRep, Oids, SendOpts) ->
+ rcall(Node, snmp_manager_user, async_get_bulk2,
+ [TargetName, NonRep, MaxRep, Oids, SendOpts]).
+
mgr_user_purify_oid(Node, Oid) ->
rcall(Node, snmp_manager_user, purify_oid, [Oid]).
diff --git a/lib/snmp/test/snmp_manager_user.erl b/lib/snmp/test/snmp_manager_user.erl
index b0e192344d..30b5dd1fc7 100644
--- a/lib/snmp/test/snmp_manager_user.erl
+++ b/lib/snmp/test/snmp_manager_user.erl
@@ -50,14 +50,14 @@
update_agent_info/3, update_agent_info/4,
which_all_agents/0, which_own_agents/0,
load_mib/1, unload_mib/1,
- sync_get/1, sync_get/2, sync_get/3,
- async_get/1, async_get/2, async_get/3,
- sync_get_next/1, sync_get_next/2, sync_get_next/3,
- async_get_next/1, async_get_next/2, async_get_next/3,
- sync_set/1, sync_set/2, sync_set/3,
- async_set/1, async_set/2, async_set/3,
- sync_get_bulk/3, sync_get_bulk/4, sync_get_bulk/5,
- async_get_bulk/3, async_get_bulk/4, async_get_bulk/5,
+ sync_get/1, sync_get/2, sync_get/3, sync_get2/3,
+ async_get/1, async_get/2, async_get/3, async_get2/3,
+ sync_get_next/1, sync_get_next/2, sync_get_next/3, sync_get_next2/3,
+ async_get_next/1, async_get_next/2, async_get_next/3, async_get_next2/3,
+ sync_set/1, sync_set/2, sync_set/3, sync_set2/3,
+ async_set/1, async_set/2, async_set/3, async_set2/3,
+ sync_get_bulk/3, sync_get_bulk/4, sync_get_bulk/5, sync_get_bulk2/5,
+ async_get_bulk/3, async_get_bulk/4, async_get_bulk/5, async_get_bulk2/5,
name_to_oid/1, oid_to_name/1,
purify_oid/1
]).
@@ -171,6 +171,10 @@ sync_get(Addr_or_TargetName, Oids) ->
sync_get(Addr, Port, Oids) ->
call({sync_get, Addr, Port, Oids}).
+sync_get2(TargetName, Oids, SendOpts) ->
+ call({sync_get2, TargetName, Oids, SendOpts}).
+
+
%% --
async_get(Oids) ->
@@ -182,6 +186,9 @@ async_get(Addr_or_TargetName, Oids) ->
async_get(Addr, Port, Oids) ->
call({async_get, Addr, Port, Oids}).
+async_get2(TargetName, Oids, SendOpts) ->
+ call({async_get2, TargetName, Oids, SendOpts}).
+
%% --
sync_get_next(Oids) ->
@@ -193,6 +200,9 @@ sync_get_next(Addr_or_TargetName, Oids) ->
sync_get_next(Addr, Port, Oids) ->
call({sync_get_next, Addr, Port, Oids}).
+sync_get_next2(TargetName, Oids, SendOpts) ->
+ call({sync_get_next2, TargetName, Oids, SendOpts}).
+
%% --
async_get_next(Oids) ->
@@ -204,6 +214,9 @@ async_get_next(Addr_or_TargetName, Oids) ->
async_get_next(Addr, Port, Oids) ->
call({async_get_next, Addr, Port, Oids}).
+async_get_next2(TargetName, Oids, SendOpts) ->
+ call({async_get_next2, TargetName, Oids, SendOpts}).
+
%% --
sync_set(VAV) ->
@@ -215,6 +228,9 @@ sync_set(Addr_or_TargetName, VAV) ->
sync_set(Addr, Port, VAV) ->
call({sync_set, Addr, Port, VAV}).
+sync_set2(TargetName, VAV, SendOpts) ->
+ call({sync_set2, TargetName, VAV, SendOpts}).
+
%% --
async_set(VAV) ->
@@ -226,6 +242,9 @@ async_set(Addr_or_TargetName, VAV) ->
async_set(Addr, Port, VAV) ->
call({async_set, Addr, Port, VAV}).
+async_set2(TargetName, VAV, SendOpts) ->
+ call({async_set2, TargetName, VAV, SendOpts}).
+
%% --
sync_get_bulk(NonRep, MaxRep, Oids) ->
@@ -237,6 +256,9 @@ sync_get_bulk(Addr_or_TargetName, NonRep, MaxRep, Oids) ->
sync_get_bulk(Addr, Port, NonRep, MaxRep, Oids) ->
call({sync_get_bulk, Addr, Port, NonRep, MaxRep, Oids}).
+sync_get_bulk2(TargetName, NonRep, MaxRep, Oids, SendOpts) ->
+ call({sync_get_bulk2, TargetName, NonRep, MaxRep, Oids, SendOpts}).
+
%% --
async_get_bulk(NonRep, MaxRep, Oids) ->
@@ -248,6 +270,9 @@ async_get_bulk(Addr_or_TargetName, NonRep, MaxRep, Oids) ->
async_get_bulk(Addr, Port, NonRep, MaxRep, Oids) ->
call({async_get_bulk, Addr, Port, NonRep, MaxRep, Oids}).
+async_get_bulk2(TargetName, NonRep, MaxRep, Oids, SendOpts) ->
+ call({async_get_bulk2, TargetName, NonRep, MaxRep, Oids, SendOpts}).
+
%% --
name_to_oid(Name) ->
@@ -400,6 +425,16 @@ loop(#state{parent = Parent, id = Id} = S) ->
%% -- (sync) get-request --
%%
+ {{sync_get2, TargetName, Oids, SendOpts}, From, Ref}
+ when is_list(TargetName) ->
+ d("loop -> received sync_get2 request with"
+ "~n TargetName: ~p"
+ "~n Oids: ~p"
+ "~n SendOpts: ~p", [TargetName, Oids, SendOpts]),
+ Res = snmpm:sync_get2(Id, TargetName, Oids, SendOpts),
+ reply(From, Res, Ref),
+ loop(S);
+
%% No agent specified, so send it to all of them
{{sync_get, Oids}, From, Ref} ->
d("loop -> received sync_get request "
@@ -439,6 +474,16 @@ loop(#state{parent = Parent, id = Id} = S) ->
%% -- (async) get-request --
%%
+ {{async_get2, TargetName, Oids, SendOpts}, From, Ref}
+ when is_list(TargetName) ->
+ d("loop -> received async_get2 request with"
+ "~n TargetName: ~p"
+ "~n Oids: ~p"
+ "~n SendOpts: ~p", [TargetName, Oids, SendOpts]),
+ Res = snmpm:async_get2(Id, TargetName, Oids, SendOpts),
+ reply(From, Res, Ref),
+ loop(S);
+
%% No agent specified, so send it to all of them
{{async_get, Oids}, From, Ref} ->
d("loop -> received async_get request"),
@@ -472,6 +517,16 @@ loop(#state{parent = Parent, id = Id} = S) ->
%% -- (sync) get_next-request --
%%
+ {{sync_get_next2, TargetName, Oids, SendOpts}, From, Ref}
+ when is_list(TargetName) ->
+ d("loop -> received sync_get_next2 request with"
+ "~n TargetName: ~p"
+ "~n Oids: ~p"
+ "~n SendOpts: ~p", [TargetName, Oids, SendOpts]),
+ Res = snmpm:sync_get_next2(Id, TargetName, Oids, SendOpts),
+ reply(From, Res, Ref),
+ loop(S);
+
%% No agent specified, so send it to all of them
{{sync_get_next, Oids}, From, Ref} ->
d("loop -> received sync_get_next request"),
@@ -505,6 +560,16 @@ loop(#state{parent = Parent, id = Id} = S) ->
%% -- (async) get_next-request --
%%
+ {{async_get_next2, TargetName, Oids, SendOpts}, From, Ref}
+ when is_list(TargetName) ->
+ d("loop -> received async_get_next2 request with"
+ "~n TargetName: ~p"
+ "~n Oids: ~p"
+ "~n SendOpts: ~p", [TargetName, Oids, SendOpts]),
+ Res = snmpm:async_get_next2(Id, TargetName, Oids, SendOpts),
+ reply(From, Res, Ref),
+ loop(S);
+
%% No agent specified, so send it to all of them
{{async_get_next, Oids}, From, Ref} ->
d("loop -> received async_get_next request"),
@@ -538,6 +603,16 @@ loop(#state{parent = Parent, id = Id} = S) ->
%% -- (sync) set-request --
%%
+ {{sync_set2, TargetName, VAV, SendOpts}, From, Ref}
+ when is_list(TargetName) ->
+ d("loop -> received sync_set2 request with"
+ "~n TargetName: ~p"
+ "~n VAV: ~p"
+ "~n SendOpts: ~p", [TargetName, VAV, SendOpts]),
+ Res = snmpm:sync_set2(Id, TargetName, VAV, SendOpts),
+ reply(From, Res, Ref),
+ loop(S);
+
{{sync_set, VAV}, From, Ref} ->
d("loop -> received sync_set request"),
Res = [snmpm:sync_set(Id, TargetName, VAV) ||
@@ -568,6 +643,16 @@ loop(#state{parent = Parent, id = Id} = S) ->
%% -- (async) set-request --
%%
+ {{async_set2, TargetName, VAV, SendOpts}, From, Ref}
+ when is_list(TargetName) ->
+ d("loop -> received async_set2 request with"
+ "~n TargetName: ~p"
+ "~n VAV: ~p"
+ "~n SendOpts: ~p", [TargetName, VAV, SendOpts]),
+ Res = snmpm:async_set2(Id, TargetName, VAV, SendOpts),
+ reply(From, Res, Ref),
+ loop(S);
+
{{async_set, VAV}, From, Ref} ->
d("loop -> received async_set request"),
Res = [snmpm:async_set(Id, TargetName, VAV) ||
@@ -598,6 +683,20 @@ loop(#state{parent = Parent, id = Id} = S) ->
%% -- (sync) get-bulk-request --
%%
+ {{sync_get_bulk2, TargetName, NonRep, MaxRep, Oids, SendOpts}, From, Ref}
+ when is_list(TargetName) ->
+ d("loop -> received sync_get_bulk request with"
+ "~n TargetName: ~p"
+ "~n NonRep: ~w"
+ "~n MaxRep: ~w"
+ "~n Oids: ~p"
+ "~n SendOpts: ~p",
+ [TargetName, NonRep, MaxRep, Oids, SendOpts]),
+ Res = snmpm:sync_get_bulk2(Id, TargetName,
+ NonRep, MaxRep, Oids, SendOpts),
+ reply(From, Res, Ref),
+ loop(S);
+
%% No agent specified, so send it to all of them
{{sync_get_bulk, NonRep, MaxRep, Oids}, From, Ref} ->
d("loop -> received sync_get_bulk request with"
@@ -645,6 +744,20 @@ loop(#state{parent = Parent, id = Id} = S) ->
%% -- (async) get-bulk-request --
%%
+ {{async_get_bulk2, TargetName, NonRep, MaxRep, Oids, SendOpts},
+ From, Ref} when is_list(TargetName) ->
+ d("loop -> received async_get_bulk2 request with"
+ "~n TargetName: ~p"
+ "~n NonRep: ~w"
+ "~n MaxRep: ~w"
+ "~n Oids: ~p"
+ "~n SendOpts: ~p",
+ [TargetName, NonRep, MaxRep, Oids, SendOpts]),
+ Res = snmpm:async_get_bulk2(Id, TargetName,
+ NonRep, MaxRep, Oids, SendOpts),
+ reply(From, Res, Ref),
+ loop(S);
+
%% No agent specified, so send it to all of them
{{async_get_bulk, NonRep, MaxRep, Oids}, From, Ref} ->
d("loop -> received async_get_bulk request with"
@@ -847,7 +960,11 @@ call(Req, To) when is_integer(To) ->
{error, timeout}
end.
-reply(Pid, Reply, Ref) ->
+reply(Pid, Reply, Ref) ->
+ d("reply -> entry with"
+ "~n Pid: ~p"
+ "~n Reply: ~p"
+ "~n Ref: ~p", [Pid, Reply, Ref]),
Pid ! {Reply, Ref}.
cast(Msg) ->