diff options
Diffstat (limited to 'lib/snmp/src/manager/snmpm.erl')
-rw-r--r-- | lib/snmp/src/manager/snmpm.erl | 999 |
1 files changed, 595 insertions, 404 deletions
diff --git a/lib/snmp/src/manager/snmpm.erl b/lib/snmp/src/manager/snmpm.erl index 7e801ebc40..6d2ac8d747 100644 --- a/lib/snmp/src/manager/snmpm.erl +++ b/lib/snmp/src/manager/snmpm.erl @@ -24,6 +24,8 @@ %%---------------------------------------------------------------------- %% User interface +%% Avoid warning for local function demonitor/1 clashing with autoimported BIF. +-compile({no_auto_import,[demonitor/1]}). -export([ %% %% Management API @@ -48,22 +50,23 @@ register_agent/2, register_agent/3, register_agent/4, unregister_agent/2, unregister_agent/3, which_agents/0, which_agents/1, - agent_info/2, update_agent_info/4, + agent_info/2, update_agent_info/3, update_agent_info/4, register_usm_user/3, unregister_usm_user/2, which_usm_users/0, which_usm_users/1, 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, %% @@ -89,7 +92,61 @@ -export([format_reason/1, format_reason/2]). -%% Backward compatibillity exports +%% Backward compatibility 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 compatibility exports (API version "1") +-deprecated({agent_info, 3}). +-deprecated({update_agent_info, 5}). +-deprecated({g, 3}). +-deprecated({g, 4}). +-deprecated({g, 5}). +-deprecated({g, 6}). +-deprecated({g, 7}). +-deprecated({ag, 3}). +-deprecated({ag, 4}). +-deprecated({ag, 5}). +-deprecated({ag, 6}). +-deprecated({ag, 7}). +-deprecated({gn, 3}). +-deprecated({gn, 4}). +-deprecated({gn, 5}). +-deprecated({gn, 6}). +-deprecated({gn, 7}). +-deprecated({agn, 3}). +-deprecated({agn, 4}). +-deprecated({agn, 5}). +-deprecated({agn, 6}). +-deprecated({agn, 7}). +-deprecated({gb, 5}). +-deprecated({gb, 6}). +-deprecated({gb, 7}). +-deprecated({gb, 8}). +-deprecated({gb, 9}). +-deprecated({agb, 5}). +-deprecated({agb, 6}). +-deprecated({agb, 7}). +-deprecated({agb, 8}). +-deprecated({agb, 9}). +-deprecated({s, 3}). +-deprecated({s, 4}). +-deprecated({s, 5}). +-deprecated({s, 6}). +-deprecated({s, 7}). +-deprecated({as, 3}). +-deprecated({as, 4}). +-deprecated({as, 5}). +-deprecated({as, 6}). +-deprecated({as, 7}). -export([ agent_info/3, update_agent_info/5, g/3, g/4, g/5, g/6, g/7, @@ -106,12 +163,13 @@ -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"). +-include("snmp_verbosity.hrl"). -define(DEFAULT_AGENT_PORT, 161). --define(DEFAULT_CONTEXT, ""). %% This function is called when the snmp application @@ -330,23 +388,23 @@ register_agent(UserId, TargetName, Config) is_list(Config)) -> do_register_agent(UserId, TargetName, [{reg_type, target_name} | Config]); -%% Backward compatibillity +%% Backward compatibility %% Note that the agent engine id is a mandatory config option, %% so this function *will* fail! register_agent(UserId, Addr, Port) when is_integer(Port) -> register_agent(UserId, Addr, Port, []); -%% Backward compatibillity +%% Backward compatibility register_agent(UserId, Addr, Config) when is_list(Config) -> register_agent(UserId, Addr, ?DEFAULT_AGENT_PORT, Config). -%% Backward compatibillity +%% Backward compatibility %% Note that the agent engine id is a mandatory config option, %% so this function *will* fail! register_agent(UserId, Addr) -> register_agent(UserId, Addr, ?DEFAULT_AGENT_PORT, []). -%% Backward compatibillity +%% Backward compatibility register_agent(UserId, Addr, Port, Config0) -> case lists:keymember(target_name, 1, Config0) of false -> @@ -366,7 +424,7 @@ register_agent(UserId, Addr, Port, Config0) -> unregister_agent(UserId, TargetName) when is_list(TargetName) -> snmpm_config:unregister_agent(UserId, TargetName); -%% Backward compatibillity functions +%% Backward compatibility functions unregister_agent(UserId, Addr) -> unregister_agent(UserId, Addr, ?DEFAULT_AGENT_PORT). @@ -381,7 +439,7 @@ unregister_agent(UserId, Addr, Port) -> agent_info(TargetName, Item) -> snmpm_config:agent_info(TargetName, Item). -%% Backward compatibillity +%% Backward compatibility agent_info(Addr, Port, Item) -> case target_name(Addr, Port) of {ok, TargetName} -> @@ -390,25 +448,16 @@ agent_info(Addr, Port, Item) -> Error end. +update_agent_info(UserId, TargetName, Info) when is_list(Info) -> + snmpm_config:update_agent_info(UserId, TargetName, Info). + update_agent_info(UserId, TargetName, Item, Val) -> -%% p("update_agent_info -> entry with" -%% "~n UserId: ~p" -%% "~n TargetName: ~p" -%% "~n Item: ~p" -%% "~n Val: ~p", [UserId, TargetName, Item, Val]), - snmpm_config:update_agent_info(UserId, TargetName, Item, Val). - -%% Backward compatibillity functions + update_agent_info(UserId, TargetName, [{Item, Val}]). + +%% Backward compatibility functions update_agent_info(UserId, Addr, Port, Item, Val) -> -%% p("update_agent_info -> entry with" -%% "~n UserId: ~p" -%% "~n Addr: ~p" -%% "~n Port: ~p" -%% "~n Item: ~p" -%% "~n Val: ~p", [UserId, Addr, Port, Item, Val]), case target_name(Addr, Port) of {ok, TargetName} -> -%% p("update_agent_info -> TargetName: ~p", [TargetName]), update_agent_info(UserId, TargetName, Item, Val); Error -> Error @@ -470,47 +519,55 @@ which_usm_users(EngineID) when is_list(EngineID) -> %% --- synchroneous get-request --- %% +sync_get2(UserId, TargetName, Oids) -> + sync_get2(UserId, TargetName, Oids, []). + +sync_get2(UserId, TargetName, Oids, SendOpts) + when is_list(Oids) andalso is_list(SendOpts) -> + snmpm_server:sync_get2(UserId, TargetName, Oids, SendOpts). + +%% <BACKWARD-COMPAT> sync_get(UserId, TargetName, Oids) -> - sync_get(UserId, TargetName, ?DEFAULT_CONTEXT, Oids). - -sync_get(UserId, TargetName, {community, Community}, Oids) - when is_list(Oids) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:sync_get(UserId, TargetName, CC, Oids); -sync_get(UserId, TargetName, CC, Oids) when is_list(Oids) -> - snmpm_server:sync_get(UserId, TargetName, CC, Oids); -sync_get(UserId, TargetName, Oids, Timeout) when is_integer(Timeout) -> - sync_get(UserId, TargetName, ?DEFAULT_CONTEXT, Oids, Timeout). - -sync_get(UserId, TargetName, {community, Community}, Oids, Timeout) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:sync_get(UserId, TargetName, CC, Oids, Timeout); -sync_get(UserId, TargetName, CC, Oids, Timeout) -> - snmpm_server:sync_get(UserId, TargetName, CC, Oids, Timeout). - -sync_get(UserId, TargetName, {community, Community}, - Oids, Timeout, ExtraInfo) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:sync_get(UserId, TargetName, CC, Oids, Timeout, ExtraInfo); -sync_get(UserId, TargetName, CC, Oids, Timeout, ExtraInfo) -> - snmpm_server:sync_get(UserId, TargetName, CC, Oids, Timeout, ExtraInfo). + 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) -> + SendOpts = [{context, Context}, {timeout, Timeout}], + sync_get2(UserId, TargetName, Oids, SendOpts). +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). +g(UserId, Addr, CtxName, Oids) when is_list(CtxName) andalso is_list(Oids) -> + g(UserId, Addr, ?DEFAULT_AGENT_PORT, CtxName, Oids); + g(UserId, Addr, Port, Oids) when is_integer(Port) andalso is_list(Oids) -> g(UserId, Addr, Port, ?DEFAULT_CONTEXT, Oids); -g(UserId, Addr, CC, Oids) when is_list(Oids) -> - g(UserId, Addr, ?DEFAULT_AGENT_PORT, CC, Oids); -g(UserId, Addr, Oids, Timeout) when is_integer(Timeout) -> + +g(UserId, Addr, Oids, Timeout) + when is_list(Oids) andalso is_integer(Timeout) -> g(UserId, Addr, ?DEFAULT_AGENT_PORT, Oids, Timeout). -g(UserId, Addr, Port, CC, Oids) - when is_integer(Port) andalso is_list(Oids) -> +g(UserId, Addr, Port, CtxName, Oids) + when is_integer(Port) andalso is_list(CtxName) andalso is_list(Oids) -> case target_name(Addr, Port) of {ok, TargetName} -> - sync_get(UserId, TargetName, CC, Oids); + sync_get(UserId, TargetName, CtxName, Oids); Error -> Error end; @@ -519,25 +576,26 @@ g(UserId, Addr, Port, Oids, Timeout) when is_integer(Port) andalso is_list(Oids) andalso is_integer(Timeout) -> g(UserId, Addr, Port, ?DEFAULT_CONTEXT, Oids, Timeout); -g(UserId, Addr, CC, Oids, Timeout) - when is_list(Oids) andalso is_integer(Timeout) -> - g(UserId, Addr, ?DEFAULT_AGENT_PORT, CC, Oids, Timeout). +g(UserId, Addr, CtxName, Oids, Timeout) + when is_list(CtxName) andalso is_list(Oids) andalso is_integer(Timeout) -> + g(UserId, Addr, ?DEFAULT_AGENT_PORT, CtxName, Oids, Timeout). -g(UserId, Addr, Port, CC, Oids, Timeout) -> +g(UserId, Addr, Port, CtxName, Oids, Timeout) -> case target_name(Addr, Port) of {ok, TargetName} -> - sync_get(UserId, TargetName, CC, Oids, Timeout); + sync_get(UserId, TargetName, CtxName, Oids, Timeout); Error -> Error end. -g(UserId, Addr, Port, CC, Oids, Timeout, ExtraInfo) -> +g(UserId, Addr, Port, CtxName, Oids, Timeout, ExtraInfo) -> case target_name(Addr, Port) of {ok, TargetName} -> - sync_get(UserId, TargetName, CC, Oids, Timeout, ExtraInfo); + sync_get(UserId, TargetName, CtxName, Oids, Timeout, ExtraInfo); Error -> Error end. +%% </DEPRECATED> @@ -547,48 +605,53 @@ g(UserId, Addr, Port, CC, Oids, Timeout, ExtraInfo) -> %% through a call to handle_pdu/5 %% +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). + +%% <BACKWARD-COMPAT> async_get(UserId, TargetName, Oids) -> - async_get(UserId, TargetName, ?DEFAULT_CONTEXT, Oids). - -async_get(UserId, TargetName, {community, Community}, Oids) - when is_list(Oids) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:async_get(UserId, TargetName, CC, Oids); -async_get(UserId, TargetName, CC, Oids) when is_list(Oids) -> - snmpm_server:async_get(UserId, TargetName, CC, 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, {community, Community}, Oids, Expire) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:async_get(UserId, TargetName, CC, Oids, Expire); -async_get(UserId, TargetName, CC, Oids, Expire) -> - snmpm_server:async_get(UserId, TargetName, CC, Oids, Expire). +async_get(UserId, TargetName, Context, Oids, Expire) -> + SendOpts = [{timeout, Expire}, {context, Context}], + async_get2(UserId, TargetName, Oids, SendOpts). -async_get(UserId, TargetName, {community, Community}, - Oids, Expire, ExtraInfo) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:async_get(UserId, TargetName, CC, Oids, Expire, ExtraInfo); -async_get(UserId, TargetName, CC, Oids, Expire, ExtraInfo) -> - snmpm_server:async_get(UserId, TargetName, CC, Oids, Expire, ExtraInfo). +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). ag(UserId, Addr, Port, Oids) when is_integer(Port) andalso is_list(Oids) -> ag(UserId, Addr, Port, ?DEFAULT_CONTEXT, Oids); -ag(UserId, Addr, Oids, Expire) when is_list(Oids) andalso is_integer(Expire) -> - ag(UserId, Addr, ?DEFAULT_AGENT_PORT, ?DEFAULT_CONTEXT, Oids, Expire); -ag(UserId, Addr, CC, Oids) when is_list(Oids) -> - ag(UserId, Addr, ?DEFAULT_AGENT_PORT, CC, Oids). +ag(UserId, Addr, CtxName, Oids) when is_list(CtxName) andalso is_list(Oids) -> + ag(UserId, Addr, ?DEFAULT_AGENT_PORT, CtxName, Oids); + +ag(UserId, Addr, Oids, Expire) when is_list(Oids) andalso is_integer(Expire) -> + ag(UserId, Addr, ?DEFAULT_AGENT_PORT, ?DEFAULT_CONTEXT, Oids, Expire). -ag(UserId, Addr, Port, CC, Oids) - when is_integer(Port) andalso is_list(Oids) -> +ag(UserId, Addr, Port, CtxName, Oids) + when is_integer(Port) andalso is_list(CtxName) andalso is_list(Oids) -> case target_name(Addr, Port) of {ok, TargetName} -> - async_get(UserId, TargetName, CC, Oids); + async_get(UserId, TargetName, CtxName, Oids); Error -> Error end; @@ -596,581 +659,709 @@ ag(UserId, Addr, Port, CC, Oids) ag(UserId, Addr, Port, Oids, Expire) when is_integer(Port) andalso is_list(Oids) andalso is_integer(Expire) -> ag(UserId, Addr, Port, ?DEFAULT_CONTEXT, Oids, Expire); -ag(UserId, Addr, CC, Oids, Expire) - when is_list(Oids) andalso is_integer(Expire) -> - ag(UserId, Addr, ?DEFAULT_AGENT_PORT, CC, Oids, Expire). -ag(UserId, Addr, Port, CC, Oids, Expire) -> +ag(UserId, Addr, CtxName, Oids, Expire) + when is_list(CtxName) andalso is_list(Oids) andalso is_integer(Expire) -> + ag(UserId, Addr, ?DEFAULT_AGENT_PORT, CtxName, Oids, Expire). + +ag(UserId, Addr, Port, CtxName, Oids, Expire) -> case target_name(Addr, Port) of {ok, TargetName} -> - async_get(UserId, TargetName, CC, Oids, Expire); + async_get(UserId, TargetName, CtxName, Oids, Expire); Error -> Error end. -ag(UserId, Addr, Port, CC, Oids, Expire, ExtraInfo) -> +ag(UserId, Addr, Port, CtxName, Oids, Expire, ExtraInfo) -> case target_name(Addr, Port) of {ok, TargetName} -> - async_get(UserId, TargetName, CC, Oids, Expire, ExtraInfo); + async_get(UserId, TargetName, CtxName, Oids, Expire, ExtraInfo); Error -> Error end. +%% </DEPRECATED> %% --- synchroneous get_next-request --- %% +sync_get_next2(UserId, TargetName, Oids) -> + sync_get_next2(UserId, TargetName, 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_next(UserId, TargetName, ?DEFAULT_CONTEXT, Oids). - -sync_get_next(UserId, TargetName, {community, Community}, Oids) - when is_list(Oids) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:sync_get_next(UserId, TargetName, CC, Oids); -sync_get_next(UserId, TargetName, CC, Oids) - when is_list(Oids) -> - snmpm_server:sync_get_next(UserId, TargetName, CC, Oids); -sync_get_next(UserId, TargetName, Oids, Timeout) - when is_integer(Timeout) -> - sync_get_next(UserId, TargetName, ?DEFAULT_CONTEXT, Oids, Timeout). + sync_get_next2(UserId, TargetName, Oids). +sync_get_next(UserId, TargetName, Oids, Timeout) + when is_list(Oids) andalso is_integer(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, {community, Community}, Oids, Timeout) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:sync_get_next(UserId, TargetName, CC, Oids, Timeout); -sync_get_next(UserId, TargetName, CC, Oids, Timeout) -> - snmpm_server:sync_get_next(UserId, TargetName, CC, Oids, Timeout). +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, {community, Community}, - Oids, Timeout, ExtraInfo) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:sync_get_next(UserId, TargetName, CC, Oids, Timeout, - ExtraInfo); -sync_get_next(UserId, TargetName, CC, Oids, Timeout, ExtraInfo) -> - snmpm_server:sync_get_next(UserId, TargetName, CC, Oids, Timeout, - ExtraInfo). +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). +gn(UserId, Addr, CtxName, Oids) when is_list(CtxName) andalso is_list(Oids) -> + gn(UserId, Addr, ?DEFAULT_AGENT_PORT, CtxName, Oids); + +gn(UserId, Addr, Port, Oids) when is_integer(Port) andalso is_list(Oids) -> + gn(UserId, Addr, Port, ?DEFAULT_CONTEXT, Oids); + gn(UserId, Addr, Oids, Timeout) when is_list(Oids) andalso is_integer(Timeout) -> - gn(UserId, Addr, ?DEFAULT_AGENT_PORT, Oids, Timeout); -gn(UserId, Addr, Port, Oids) - when is_integer(Port) andalso is_list(Oids) -> - gn(UserId, Addr, Port, ?DEFAULT_CONTEXT, Oids); -gn(UserId, Addr, CC, Oids) - when is_list(Oids) -> - gn(UserId, Addr, ?DEFAULT_AGENT_PORT, CC, Oids). + gn(UserId, Addr, ?DEFAULT_AGENT_PORT, Oids, Timeout). -gn(UserId, Addr, Port, Oids, Timeout) - when is_integer(Port) andalso is_list(Oids) andalso is_integer(Timeout) -> - gn(UserId, Addr, Port, ?DEFAULT_CONTEXT, Oids, Timeout); -gn(UserId, Addr, Port, CC, Oids) - when is_integer(Port) andalso is_list(Oids) -> +gn(UserId, Addr, Port, CtxName, Oids) + when is_integer(Port) andalso is_list(CtxName) andalso is_list(Oids) -> case target_name(Addr, Port) of {ok, TargetName} -> - sync_get_next(UserId, TargetName, CC, Oids); + sync_get_next(UserId, TargetName, CtxName, Oids); Error -> Error end; -gn(UserId, Addr, CC, Oids, Timeout) - when is_list(Oids) andalso is_integer(Timeout) -> - gn(UserId, Addr, ?DEFAULT_AGENT_PORT, CC, Oids, Timeout). + +gn(UserId, Addr, Port, Oids, Timeout) + when is_integer(Port) andalso is_list(Oids) andalso is_integer(Timeout) -> + gn(UserId, Addr, Port, ?DEFAULT_CONTEXT, Oids, Timeout); +gn(UserId, Addr, CtxName, Oids, Timeout) + when is_list(CtxName) andalso is_list(Oids) andalso is_integer(Timeout) -> + gn(UserId, Addr, ?DEFAULT_AGENT_PORT, CtxName, Oids, Timeout). -gn(UserId, Addr, Port, CC, Oids, Timeout) -> +gn(UserId, Addr, Port, CtxName, Oids, Timeout) -> case target_name(Addr, Port) of {ok, TargetName} -> - sync_get_next(UserId, TargetName, CC, Oids, Timeout); + sync_get_next(UserId, TargetName, CtxName, Oids, Timeout); Error -> Error end. -gn(UserId, Addr, Port, CC, Oids, Timeout, ExtraInfo) -> +gn(UserId, Addr, Port, CtxName, Oids, Timeout, ExtraInfo) -> case target_name(Addr, Port) of {ok, TargetName} -> - sync_get_next(UserId, TargetName, CC, Oids, Timeout, ExtraInfo); + sync_get_next(UserId, TargetName, 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_next(UserId, TargetName, {community, Community}, Oids) - when is_list(Oids) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:async_get_next(UserId, TargetName, CC, Oids); -async_get_next(UserId, TargetName, CC, Oids) - when is_list(Oids) -> - snmpm_server:async_get_next(UserId, TargetName, CC, Oids); -async_get_next(UserId, TargetName, Oids, Timeout) - when is_integer(Timeout) -> - async_get_next(UserId, TargetName, ?DEFAULT_CONTEXT, Oids, Timeout). - -async_get_next(UserId, TargetName, {community, Community}, Oids, Timeout) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:async_get_next(UserId, TargetName, CC, Oids, Timeout); -async_get_next(UserId, TargetName, CC, Oids, Timeout) -> - snmpm_server:async_get_next(UserId, TargetName, CC, Oids, Timeout). - -async_get_next(UserId, TargetName, {community, Community}, - Oids, Timeout, ExtraInfo) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:async_get_next(UserId, TargetName, CC, Oids, Timeout, - ExtraInfo); -async_get_next(UserId, TargetName, CC, Oids, Timeout, ExtraInfo) -> - snmpm_server:async_get_next(UserId, TargetName, CC, Oids, Timeout, - ExtraInfo). + 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) -> + SendOpts = [{context, Context}], + async_get_next2(UserId, TargetName, Oids, SendOpts). + +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, Expire, ExtraInfo) -> + SendOpts = [{timeout, Expire}, {context, Context}, {extra, ExtraInfo}], + async_get_next2(UserId, TargetName, Oids, SendOpts). +%% </BACKWARD-COMPAT> + + +%% <DEPRECATED> agn(UserId, Addr, Oids) -> agn(UserId, Addr, ?DEFAULT_AGENT_PORT, Oids). +agn(UserId, Addr, CtxName, Oids) when is_list(CtxName) andalso is_list(Oids) -> + agn(UserId, Addr, ?DEFAULT_AGENT_PORT, CtxName, Oids); + +agn(UserId, Addr, Port, Oids) when is_integer(Port) andalso is_list(Oids) -> + agn(UserId, Addr, Port, ?DEFAULT_CONTEXT, Oids); + agn(UserId, Addr, Oids, Expire) when is_list(Oids) andalso is_integer(Expire) -> - agn(UserId, Addr, ?DEFAULT_AGENT_PORT, Oids, Expire); -agn(UserId, Addr, Port, Oids) - when is_integer(Port) andalso is_list(Oids) -> - agn(UserId, Addr, Port, ?DEFAULT_CONTEXT, Oids); -agn(UserId, Addr, CC, Oids) - when is_list(Oids) -> - agn(UserId, Addr, ?DEFAULT_AGENT_PORT, CC, Oids). + agn(UserId, Addr, ?DEFAULT_AGENT_PORT, Oids, Expire). -agn(UserId, Addr, Port, Oids, Expire) - when is_integer(Port) andalso is_integer(Expire) -> - agn(UserId, Addr, Port, ?DEFAULT_CONTEXT, Oids, Expire); -agn(UserId, Addr, CC, Oids, Expire) - when is_integer(Expire) -> - agn(UserId, Addr, ?DEFAULT_AGENT_PORT, CC, Oids, Expire); -agn(UserId, Addr, Port, CC, Oids) - when is_integer(Port) andalso is_list(Oids) -> +agn(UserId, Addr, Port, CtxName, Oids) + when is_integer(Port) andalso is_list(CtxName) andalso is_list(Oids) -> case target_name(Addr, Port) of {ok, TargetName} -> - async_get_next(UserId, TargetName, CC, Oids); + async_get_next(UserId, TargetName, CtxName, Oids); Error -> Error - end. + end; + +agn(UserId, Addr, Port, Oids, Expire) + when is_integer(Port) andalso is_list(Oids) andalso is_integer(Expire) -> + agn(UserId, Addr, Port, ?DEFAULT_CONTEXT, Oids, Expire); +agn(UserId, Addr, CtxName, Oids, Expire) + when is_list(CtxName) andalso is_list(CtxName) andalso is_integer(Expire) -> + agn(UserId, Addr, ?DEFAULT_AGENT_PORT, CtxName, Oids, Expire). -agn(UserId, Addr, Port, CC, Oids, Expire) -> +agn(UserId, Addr, Port, CtxName, Oids, Expire) -> case target_name(Addr, Port) of {ok, TargetName} -> - async_get_next(UserId, TargetName, CC, Oids, Expire); + async_get_next(UserId, TargetName, CtxName, Oids, Expire); Error -> Error end. -agn(UserId, Addr, Port, CC, Oids, Expire, ExtraInfo) -> +agn(UserId, Addr, Port, CtxName, Oids, Expire, ExtraInfo) -> case target_name(Addr, Port) of {ok, TargetName} -> - async_get_next(UserId, TargetName, CC, Oids, Expire, ExtraInfo); + async_get_next(UserId, TargetName, CtxName, Oids, Expire, + ExtraInfo); Error -> Error end. +%% </DEPRECATED> %% --- synchroneous set-request --- %% +sync_set2(UserId, TargetName, VarsAndVals) -> + sync_set2(UserId, TargetName, 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_set(UserId, TargetName, ?DEFAULT_CONTEXT, 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); -sync_set(UserId, TargetName, {community, Community}, VarsAndVals) - when is_list(VarsAndVals) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:sync_set(UserId, TargetName, CC, VarsAndVals); -sync_set(UserId, TargetName, CC, VarsAndVals) - when is_list(VarsAndVals) -> - snmpm_server:sync_set(UserId, TargetName, CC, VarsAndVals). - -sync_set(UserId, TargetName, {community, Community}, VarsAndVals, Timeout) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:sync_set(UserId, TargetName, CC, VarsAndVals, Timeout); -sync_set(UserId, TargetName, CC, VarsAndVals, Timeout) -> - snmpm_server:sync_set(UserId, TargetName, CC, VarsAndVals, Timeout). - -sync_set(UserId, TargetName, {community, Community}, - VarsAndVals, Timeout, ExtraInfo) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:sync_set(UserId, TargetName, CC, VarsAndVals, Timeout, - ExtraInfo); -sync_set(UserId, TargetName, CC, VarsAndVals, Timeout, ExtraInfo) -> - snmpm_server:sync_set(UserId, TargetName, CC, VarsAndVals, Timeout, - ExtraInfo). + 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) -> + SendOpts = [{timeout, Timeout}, {context, Context}], + sync_set2(UserId, TargetName, VarsAndVals, SendOpts). +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). s(UserId, Addr, Port, VarsAndVals) when is_integer(Port) andalso is_list(VarsAndVals) -> s(UserId, Addr, Port, ?DEFAULT_CONTEXT, VarsAndVals); + +s(UserId, Addr, CtxName, VarsAndVals) + when is_list(CtxName) andalso is_list(VarsAndVals) -> + s(UserId, Addr, ?DEFAULT_AGENT_PORT, CtxName, VarsAndVals); + s(UserId, Addr, VarsAndVals, Timeout) when is_list(VarsAndVals) andalso is_integer(Timeout) -> - s(UserId, Addr, ?DEFAULT_AGENT_PORT, VarsAndVals, Timeout); -s(UserId, Addr, CC, VarsAndVals) - when is_list(VarsAndVals) -> - s(UserId, Addr, ?DEFAULT_AGENT_PORT, CC, VarsAndVals). - + s(UserId, Addr, ?DEFAULT_AGENT_PORT, VarsAndVals, Timeout). -s(UserId, Addr, Port, VarsAndVals, Timeout) +s(UserId, Addr, Port, CtxName, VarsAndVals) when is_integer(Port) andalso - is_list(VarsAndVals) andalso - is_integer(Timeout) -> - s(UserId, Addr, Port, ?DEFAULT_CONTEXT, VarsAndVals, Timeout); -s(UserId, Addr, Port, CC, VarsAndVals) - when is_integer(Port) andalso is_list(VarsAndVals) -> + is_list(CtxName) andalso + is_list(VarsAndVals) -> case target_name(Addr, Port) of {ok, TargetName} -> - sync_set(UserId, TargetName, CC, VarsAndVals); + sync_set(UserId, TargetName, CtxName, VarsAndVals); Error -> Error end; -s(UserId, Addr, CC, VarsAndVals, Timeout) - when is_list(VarsAndVals) andalso is_integer(Timeout) -> - s(UserId, Addr, ?DEFAULT_AGENT_PORT, CC, VarsAndVals, Timeout). -s(UserId, Addr, Port, CC, VarsAndVals, Timeout) -> +s(UserId, Addr, Port, VarsAndVals, Timeout) + when is_integer(Port) andalso + is_list(VarsAndVals) andalso + is_integer(Timeout) -> + s(UserId, Addr, Port, ?DEFAULT_CONTEXT, VarsAndVals, Timeout); + +s(UserId, Addr, CtxName, VarsAndVals, Timeout) + when is_list(CtxName) andalso + is_list(VarsAndVals) andalso + is_integer(Timeout) -> + s(UserId, Addr, ?DEFAULT_AGENT_PORT, CtxName, VarsAndVals, Timeout). + +s(UserId, Addr, Port, CtxName, VarsAndVals, Timeout) -> case target_name(Addr, Port) of {ok, TargetName} -> - sync_set(UserId, TargetName, CC, VarsAndVals, Timeout); + sync_set(UserId, TargetName, CtxName, VarsAndVals, Timeout); Error -> Error end. -s(UserId, Addr, Port, CC, VarsAndVals, Timeout, ExtraInfo) -> +s(UserId, Addr, Port, CtxName, VarsAndVals, Timeout, ExtraInfo) -> case target_name(Addr, Port) of {ok, TargetName} -> - sync_set(UserId, TargetName, CC, VarsAndVals, Timeout, ExtraInfo); + sync_set(UserId, TargetName, CtxName, VarsAndVals, Timeout, ExtraInfo); Error -> Error end. +%% </DEPRECATED> %% --- asynchroneous set-request --- %% +async_set2(UserId, TargetName, VarsAndVals) -> + async_set2(UserId, TargetName, 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_set(UserId, TargetName, ?DEFAULT_CONTEXT, 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); -async_set(UserId, TargetName, {community, Community}, VarsAndVals) - when is_list(VarsAndVals) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:async_set(UserId, TargetName, CC, VarsAndVals); -async_set(UserId, TargetName, CC, VarsAndVals) - when is_list(VarsAndVals) -> - snmpm_server:async_set(UserId, TargetName, CC, VarsAndVals). - -async_set(UserId, TargetName, {community, Community}, VarsAndVals, Expire) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:async_set(UserId, TargetName, CC, VarsAndVals, Expire); -async_set(UserId, TargetName, CC, VarsAndVals, Expire) -> - snmpm_server:async_set(UserId, TargetName, CC, VarsAndVals, Expire). - -async_set(UserId, TargetName, {community, Community}, - VarsAndVals, Expire, ExtraInfo) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:async_set(UserId, TargetName, CC, VarsAndVals, Expire, - ExtraInfo); -async_set(UserId, TargetName, CC, VarsAndVals, Expire, ExtraInfo) -> - snmpm_server:async_set(UserId, TargetName, CC, VarsAndVals, Expire, - ExtraInfo). + 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) -> + SendOpts = [{timeout, Expire}, {context, Context}], + async_set2(UserId, TargetName, VarsAndVals, SendOpts). +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). -as(UserId, Addr, VarsAndVals, Expire) - when is_list(VarsAndVals) andalso is_integer(Expire) -> - as(UserId, Addr, ?DEFAULT_AGENT_PORT, VarsAndVals, Expire); as(UserId, Addr, Port, VarsAndVals) when is_integer(Port) andalso is_list(VarsAndVals) -> as(UserId, Addr, Port, ?DEFAULT_CONTEXT, VarsAndVals); -as(UserId, Addr, CC, VarsAndVals) - when is_list(VarsAndVals) -> - as(UserId, Addr, ?DEFAULT_AGENT_PORT, CC, VarsAndVals). +as(UserId, Addr, CtxName, VarsAndVals) + when is_list(CtxName) andalso is_list(VarsAndVals) -> + as(UserId, Addr, ?DEFAULT_AGENT_PORT, CtxName, VarsAndVals); -as(UserId, Addr, Port, VarsAndVals, Expire) +as(UserId, Addr, VarsAndVals, Expire) + when is_list(VarsAndVals) andalso is_integer(Expire) -> + as(UserId, Addr, ?DEFAULT_AGENT_PORT, VarsAndVals, Expire). + +as(UserId, Addr, Port, CtxName, VarsAndVals) when is_integer(Port) andalso - is_list(VarsAndVals) andalso - is_integer(Expire) -> - as(UserId, Addr, Port, ?DEFAULT_CONTEXT, VarsAndVals, Expire); -as(UserId, Addr, Port, CC, VarsAndVals) - when is_integer(Port) andalso is_list(VarsAndVals) -> + is_list(CtxName) andalso + is_list(VarsAndVals) -> case target_name(Addr, Port) of {ok, TargetName} -> - async_set(UserId, TargetName, CC, VarsAndVals); + async_set(UserId, TargetName, CtxName, VarsAndVals); Error -> Error end; -as(UserId, Addr, CC, VarsAndVals, Expire) - when is_list(VarsAndVals) andalso is_integer(Expire) -> - as(UserId, Addr, ?DEFAULT_AGENT_PORT, CC, VarsAndVals, Expire). + +as(UserId, Addr, Port, VarsAndVals, Expire) + when is_integer(Port) andalso + is_list(VarsAndVals) andalso + is_integer(Expire) -> + as(UserId, Addr, Port, ?DEFAULT_CONTEXT, VarsAndVals, Expire); + +as(UserId, Addr, CtxName, VarsAndVals, Expire) + when is_list(CtxName) andalso + is_list(VarsAndVals) andalso + is_integer(Expire) -> + as(UserId, Addr, ?DEFAULT_AGENT_PORT, CtxName, VarsAndVals, Expire). -as(UserId, Addr, Port, CC, VarsAndVals, Expire) -> +as(UserId, Addr, Port, CtxName, VarsAndVals, Expire) -> case target_name(Addr, Port) of {ok, TargetName} -> - async_set(UserId, TargetName, CC, VarsAndVals, Expire); + async_set(UserId, TargetName, CtxName, VarsAndVals, Expire); Error -> Error end. -as(UserId, Addr, Port, CC, VarsAndVals, Expire, ExtraInfo) -> +as(UserId, Addr, Port, CtxName, VarsAndVals, Expire, ExtraInfo) -> case target_name(Addr, Port) of {ok, TargetName} -> - async_set(UserId, TargetName, CC, VarsAndVals, Expire, ExtraInfo); + async_set(UserId, TargetName, CtxName, VarsAndVals, Expire, ExtraInfo); Error -> Error end. - - +%% </DEPRECATED> %% --- synchroneous 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) + when is_integer(NonRep) andalso + is_integer(MaxRep) andalso + 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_bulk(UserId, TargetName, NonRep, MaxRep, ?DEFAULT_CONTEXT, 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); -sync_get_bulk(UserId, TargetName, - NonRep, MaxRep, {community, Community}, Oids) + 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) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:sync_get_bulk(UserId, TargetName, - NonRep, MaxRep, - CC, Oids); -sync_get_bulk(UserId, TargetName, NonRep, MaxRep, CC, Oids) - when is_integer(NonRep) andalso - is_integer(MaxRep) andalso - is_list(Oids) -> - snmpm_server:sync_get_bulk(UserId, TargetName, - NonRep, MaxRep, - CC, Oids). - -sync_get_bulk(UserId, TargetName, - NonRep, MaxRep, {community, Community}, Oids, Timeout) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:sync_get_bulk(UserId, TargetName, - NonRep, MaxRep, CC, Oids, Timeout); -sync_get_bulk(UserId, TargetName, NonRep, MaxRep, CC, Oids, Timeout) -> - snmpm_server:sync_get_bulk(UserId, TargetName, - NonRep, MaxRep, CC, Oids, Timeout). - -sync_get_bulk(UserId, TargetName, - NonRep, MaxRep, {community, Community}, - Oids, Timeout, ExtraInfo) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:sync_get_bulk(UserId, TargetName, - NonRep, MaxRep, CC, Oids, Timeout, ExtraInfo); -sync_get_bulk(UserId, TargetName, NonRep, MaxRep, CC, Oids, Timeout, + %% 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) -> + 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, CC, 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, NonRep, MaxRep, Oids, Timeout) - when is_integer(NonRep) andalso - is_integer(MaxRep) andalso - is_list(Oids) andalso - is_integer(Timeout) -> - gb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, Oids, Timeout); gb(UserId, Addr, Port, NonRep, MaxRep, Oids) when is_integer(Port) andalso 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, CC, Oids) + +gb(UserId, Addr, NonRep, MaxRep, CtxName, Oids) when is_integer(NonRep) andalso is_integer(MaxRep) andalso + is_list(CtxName) andalso is_list(Oids) -> - gb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, CC, 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, Port, NonRep, MaxRep, Oids, Timeout) - when is_integer(Port) andalso - is_integer(NonRep) andalso - is_integer(MaxRep) andalso - is_list(Oids) andalso - is_integer(Timeout) -> - gb(UserId, Addr, Port, NonRep, MaxRep, ?DEFAULT_CONTEXT, Oids, Timeout); -gb(UserId, Addr, NonRep, MaxRep, CC, Oids, Timeout) +gb(UserId, Addr, NonRep, MaxRep, Oids, Timeout) when is_integer(NonRep) andalso is_integer(MaxRep) andalso is_list(Oids) andalso is_integer(Timeout) -> - gb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, CC, Oids, Timeout); -gb(UserId, Addr, Port, NonRep, MaxRep, CC, Oids) + %% 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) when is_integer(Port) andalso is_integer(NonRep) andalso 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} -> - sync_get_bulk(UserId, TargetName, NonRep, MaxRep, CC, Oids); + %% p("gb -> TargetName: ~p", [TargetName]), + sync_get_bulk(UserId, TargetName, NonRep, MaxRep, CtxName, Oids); Error -> Error - end. + end; -gb(UserId, Addr, Port, NonRep, MaxRep, CC, Oids, Timeout) -> +gb(UserId, Addr, Port, NonRep, MaxRep, Oids, Timeout) + when is_integer(Port) andalso + is_integer(NonRep) andalso + 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) + when is_integer(NonRep) andalso + is_integer(MaxRep) andalso + 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, - NonRep, MaxRep, CC, Oids, Timeout); + NonRep, MaxRep, CtxName, Oids, Timeout); Error -> Error end. -gb(UserId, Addr, Port, NonRep, MaxRep, CC, Oids, Timeout, ExtraInfo) -> +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, - NonRep, MaxRep, CC, Oids, Timeout, ExtraInfo); + NonRep, MaxRep, CtxName, Oids, Timeout, ExtraInfo); Error -> Error end. +%% </DEPRECATED> %% --- asynchroneous 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) + when is_integer(NonRep) andalso + is_integer(MaxRep) andalso + 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_bulk(UserId, TargetName, NonRep, MaxRep, ?DEFAULT_CONTEXT, 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); -async_get_bulk(UserId, TargetName, - NonRep, MaxRep, {community, Community}, Oids) + 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) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:async_get_bulk(UserId, TargetName, - NonRep, MaxRep, CC, Oids); -async_get_bulk(UserId, TargetName, NonRep, MaxRep, CC, Oids) - when is_integer(NonRep) andalso - is_integer(MaxRep) andalso - is_list(Oids) -> - snmpm_server:async_get_bulk(UserId, TargetName, - NonRep, MaxRep, CC, Oids). - -async_get_bulk(UserId, TargetName, NonRep, MaxRep, {community, Community}, - Oids, Expire) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:async_get_bulk(UserId, TargetName, - NonRep, MaxRep, CC, Oids, Expire); -async_get_bulk(UserId, TargetName, NonRep, MaxRep, CC, Oids, Expire) -> - snmpm_server:async_get_bulk(UserId, TargetName, - NonRep, MaxRep, CC, Oids, Expire). - -async_get_bulk(UserId, TargetName, - NonRep, MaxRep, {community, Community}, - Oids, Expire, ExtraInfo) -> - CC = {?DEFAULT_CONTEXT, Community}, - snmpm_server:async_get_bulk(UserId, TargetName, - NonRep, MaxRep, CC, Oids, Expire, ExtraInfo); -async_get_bulk(UserId, TargetName, NonRep, MaxRep, CC, Oids, Expire, + SendOpts = [{context, Context}], + async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts). + +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, CC, 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). -agb(UserId, Addr, NonRep, MaxRep, Oids, Expire) - when is_integer(NonRep) andalso - is_integer(MaxRep) andalso - is_list(Oids) andalso - is_integer(Expire) -> - agb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, Oids, Expire); agb(UserId, Addr, Port, NonRep, MaxRep, Oids) when is_integer(Port) andalso is_integer(NonRep) andalso is_integer(MaxRep) andalso is_list(Oids) -> agb(UserId, Addr, Port, NonRep, MaxRep, ?DEFAULT_CONTEXT, Oids); -agb(UserId, Addr, NonRep, MaxRep, CC, Oids) + +agb(UserId, Addr, NonRep, MaxRep, CtxName, Oids) when is_integer(NonRep) andalso is_integer(MaxRep) andalso + is_list(CtxName) andalso is_list(Oids) -> - agb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, CC, Oids). + agb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, CtxName, Oids); -agb(UserId, Addr, Port, NonRep, MaxRep, Oids, Expire) - when is_integer(Port) andalso - is_integer(NonRep) andalso - is_integer(MaxRep) andalso - is_list(Oids) andalso - is_integer(Expire) -> - agb(UserId, Addr, Port, NonRep, MaxRep, ?DEFAULT_CONTEXT, Oids, Expire); -agb(UserId, Addr, NonRep, MaxRep, CC, Oids, Expire) +agb(UserId, Addr, NonRep, MaxRep, Oids, Expire) when is_integer(NonRep) andalso is_integer(MaxRep) andalso is_list(Oids) andalso is_integer(Expire) -> - agb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, CC, Oids); -agb(UserId, Addr, Port, NonRep, MaxRep, CC, Oids) + agb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, Oids, Expire). + +agb(UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids) when is_integer(Port) andalso is_integer(NonRep) andalso is_integer(MaxRep), + is_list(CtxName) andalso is_list(Oids) -> case target_name(Addr, Port) of {ok, TargetName} -> async_get_bulk(UserId, TargetName, - NonRep, MaxRep, CC, Oids); + NonRep, MaxRep, CtxName, Oids); Error -> Error - end. + end; + +agb(UserId, Addr, Port, NonRep, MaxRep, Oids, Expire) + when is_integer(Port) andalso + is_integer(NonRep) andalso + is_integer(MaxRep) andalso + is_list(Oids) andalso + is_integer(Expire) -> + agb(UserId, Addr, Port, NonRep, MaxRep, ?DEFAULT_CONTEXT, Oids, Expire); -agb(UserId, Addr, Port, NonRep, MaxRep, CC, Oids, Expire) -> +agb(UserId, Addr, NonRep, MaxRep, CtxName, Oids, Expire) + when is_integer(NonRep) andalso + is_integer(MaxRep) andalso + is_list(CtxName) andalso + is_list(Oids) andalso + is_integer(Expire) -> + agb(UserId, Addr, ?DEFAULT_AGENT_PORT, NonRep, MaxRep, CtxName, Oids). + +agb(UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids, Expire) -> case target_name(Addr, Port) of {ok, TargetName} -> async_get_bulk(UserId, TargetName, - NonRep, MaxRep, CC, Oids, Expire); + NonRep, MaxRep, CtxName, Oids, Expire); Error -> Error end. -agb(UserId, Addr, Port, NonRep, MaxRep, CC, Oids, Expire, ExtraInfo) -> +agb(UserId, Addr, Port, NonRep, MaxRep, CtxName, Oids, Expire, ExtraInfo) -> case target_name(Addr, Port) of {ok, TargetName} -> async_get_bulk(UserId, TargetName, - NonRep, MaxRep, CC, Oids, Expire, ExtraInfo); + NonRep, MaxRep, CtxName, Oids, Expire, + ExtraInfo); Error -> Error end. +%% </DEPRECATED> cancel_async_request(UserId, ReqId) -> @@ -1178,7 +1369,7 @@ cancel_async_request(UserId, ReqId) -> %%%----------------------------------------------------------------- -%%% Audit Trail Log functions (for backward compatibillity) +%%% Audit Trail Log functions (for backward compatibility) %%%----------------------------------------------------------------- log_to_txt(LogDir, Mibs) -> OutFile = "snmpm_log.txt", |