aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/snmp')
-rw-r--r--lib/snmp/src/manager/snmpm.erl13
-rw-r--r--lib/snmp/src/manager/snmpm_config.erl78
-rw-r--r--lib/snmp/src/manager/snmpm_mpd.erl32
-rw-r--r--lib/snmp/src/manager/snmpm_net_if.erl2
-rw-r--r--lib/snmp/src/manager/snmpm_server.erl2
-rw-r--r--lib/snmp/src/misc/snmp_conf.erl2
6 files changed, 37 insertions, 92 deletions
diff --git a/lib/snmp/src/manager/snmpm.erl b/lib/snmp/src/manager/snmpm.erl
index 67e3673b74..6d2ac8d747 100644
--- a/lib/snmp/src/manager/snmpm.erl
+++ b/lib/snmp/src/manager/snmpm.erl
@@ -380,11 +380,6 @@ which_users() ->
%% Config -> Agent configuration: [config()]
do_register_agent(UserId, TargetName, Config) ->
- io:format("do_register_agent -> entry with"
- "~n UserId: ~p"
- "~n TargetName: ~p"
- "~n Config: ~p"
- "~n", [UserId, TargetName, Config]),
snmpm_config:register_agent(UserId, TargetName, Config).
register_agent(UserId, TargetName, Config)
@@ -411,21 +406,13 @@ register_agent(UserId, Addr) ->
%% Backward compatibility
register_agent(UserId, Addr, Port, Config0) ->
- io:format("register_agent -> entry with"
- "~n UserId: ~p"
- "~n Addr: ~p"
- "~n Port: ~p"
- "~n Config0: ~p"
- "~n", [UserId, Addr, Port, Config0]),
case lists:keymember(target_name, 1, Config0) of
false ->
- io:format("register_agent -> no target_name~n", []),
TargetName = mk_target_name(Addr, Port, Config0),
Config = [{reg_type, addr_port},
{address, Addr}, {port, Port} | Config0],
do_register_agent(UserId, TargetName, ensure_engine_id(Config));
true ->
- io:format("register_agent -> target_name~n", []),
{value, {_, TargetName}} =
lists:keysearch(target_name, 1, Config0),
Config1 = lists:keydelete(target_name, 1, Config0),
diff --git a/lib/snmp/src/manager/snmpm_config.erl b/lib/snmp/src/manager/snmpm_config.erl
index 6cafa1fef8..e61e7abb31 100644
--- a/lib/snmp/src/manager/snmpm_config.erl
+++ b/lib/snmp/src/manager/snmpm_config.erl
@@ -165,7 +165,7 @@
%%%-------------------------------------------------------------------
default_transport_domain() ->
- snmpUDPDomain.
+ transportDomainUdpIpv4.
start_link(Opts) ->
@@ -329,12 +329,6 @@ register_agent(UserId, TargetName, Config0)
"~n TargetName: ~p"
"~n Config0: ~p", [UserId, TargetName, Config0]),
- io:format("register_agent -> entry with"
- "~n UserId: ~p"
- "~n TargetName: ~p"
- "~n Config0: ~p"
- "~n", [UserId, TargetName, Config0]),
-
%% Check:
%% 1) That the mandatory configs are present
%% 2) That no illegal config, e.g. user_id (used internally),
@@ -343,9 +337,6 @@ register_agent(UserId, TargetName, Config0)
%% 4) Check that the manager is capable of using the selected version
case verify_agent_config(Config0) of
{ok, Config} ->
- io:format("register_agent -> agent config verified"
- "~n Config: ~p"
- "~n", [Config]),
call({register_agent, UserId, TargetName, Config});
Error ->
Error
@@ -358,15 +349,9 @@ verify_agent_config(Conf0) ->
verify_mandatory(Conf0, [engine_id, address, reg_type]),
verify_invalid(Conf0, [user_id]),
Conf = verify_agent_config3(Conf0),
- io:format("verify_agent_config -> agent config verified: "
- "~n Conf: ~p"
- "~n", [Conf]),
Vsns = versions(),
- io:format("verify_agent_config -> Vsns: ~p~n", [Vsns]),
Vsn = which_version(Conf),
- io:format("verify_agent_config -> Vsn: ~p~n", [Vsn]),
verify_version(Vsn, Vsns),
- io:format("verify_agent_config -> version verified~n", []),
{ok, Conf}
end
catch
@@ -401,16 +386,13 @@ verify_version(Vsn, Vsns) ->
verify_agent_config3(Conf0) ->
%% Fix (transport) address and domain
- io:format("verify_agent_config3 -> entry with"
- "~n Conf0: ~p"
- "~n", [Conf0]),
{TDomain, Conf1} =
case lists:keysearch(tdomain, 1, Conf0) of
- {value, {domain, Dom}} ->
+ {value, {tdomain, Dom}} ->
{Dom, Conf0};
false ->
Dom = default_transport_domain(),
- {Dom, [{domain, Dom} | Conf0]}
+ {Dom, [{tdomain, Dom} | Conf0]}
end,
Conf2 = case lists:keysearch(address, 1, Conf1) of
{value, {address, Address}} ->
@@ -505,12 +487,12 @@ verify_agent_info(TargetName, Info0) ->
%% If not, lookup what is already stored for
%% this agent and use that.
Domain =
- case lists:keysearch(domain, 1, Info0) of
- {value, {domain, Dom}} ->
+ case lists:keysearch(tdomain, 1, Info0) of
+ {value, {tdomain, Dom}} ->
Dom;
false ->
{ok, Dom} =
- agent_info(TargetName, domain),
+ agent_info(TargetName, tdomain),
Dom
end,
Addr2 = {Domain, Addr},
@@ -1797,7 +1779,7 @@ verify_agent({UserId,
%% the property tdomain is needed.
Conf0 =
[{reg_type, target_name},
- {domain, TDomain},
+ {tdomain, TDomain},
%% This should be taddress, but what the*...
{address, {TDomain, Ip}},
{port, Port},
@@ -1818,25 +1800,13 @@ verify_agent({UserId,
end.
verify_agent2(Conf) ->
- io:format("verify_agent2 -> entry with"
- "~n Conf: ~p"
- "~n", [Conf]),
verify_agent2(Conf, []).
verify_agent2([], VerifiedConf) ->
- io:format("verify_agent2 -> entry when done with"
- "~n VerifiedConf: ~p"
- "~n", [VerifiedConf]),
{ok, VerifiedConf};
verify_agent2([{Item, Val0}|Items], VerifiedConf) ->
- io:format("verify_agent2 -> entry with"
- "~n Item: ~p"
- "~n Val0: ~p"
- "~n VerifiedConf: ~p"
- "~n", [Item, Val0, VerifiedConf]),
case verify_val(Item, Val0) of
{ok, Val} ->
- io:format("verify_agent2 -> ~p verified: ~p~n", [Item, Val]),
verify_agent2(Items, [{Item, Val} | VerifiedConf]);
Err ->
Err
@@ -3003,40 +2973,22 @@ usm_key(EngineId, Name) ->
%% ---------------------------------------------------------------------
verify_mandatory(_, []) ->
- io:format("verify_mandatory -> entry when done~n", []),
ok;
verify_mandatory(Conf, [Mand|Mands]) ->
- io:format("verify_mandatory -> entry with"
- "~n Mand: ~p"
- "~n Conf: ~p"
- "~n", [Mand, Conf]),
case lists:keymember(Mand, 1, Conf) of
true ->
- io:format("verify_mandatory -> Mandatory option ~p present~n",
- [Mand]),
verify_mandatory(Conf, Mands);
false ->
- io:format("verify_mandatory -> "
- "Mandatory option ~p *not* present~n", [Mand]),
throw({error, {missing_mandatory_config, Mand}})
end.
verify_invalid(_, []) ->
- io:format("verify_invalid -> entry when done~n", []),
ok;
verify_invalid(Conf, [Inv|Invs]) ->
- io:format("verify_invalid -> entry with"
- "~n inv: ~p"
- "~n Conf: ~p"
- "~n", [Inv, Conf]),
case lists:member(Inv, Conf) of
false ->
- io:format("verify_invalid -> ~p *not* present"
- "~n", [Inv]),
verify_invalid(Conf, Invs);
true ->
- io:format("verify_invalid -> ~p *present*"
- "~n", [Inv]),
throw({error, {illegal_config, Inv}})
end.
@@ -3046,17 +2998,17 @@ verify_val(user_id, UserId) ->
verify_val(reg_type, RegType)
when (RegType =:= addr_port) orelse (RegType =:= target_name) ->
{ok, RegType};
-verify_val(domain, snmpUDPDomain = _Domain) ->
- verify_val(domain, transportDomainUdpIpv4);
-verify_val(domain, Domain) ->
- case lists:member(Domain, ?VALID_DOMAINS) of
+verify_val(tdomain = Item, snmpUDPDomain = _Domain) ->
+ verify_val(Item, transportDomainUdpIpv4);
+verify_val(tdomain, TDomain) ->
+ case lists:member(TDomain, ?VALID_DOMAINS) of
true ->
- {ok, Domain};
+ {ok, TDomain};
false ->
- error({bad_domain, Domain})
+ error({bad_tdomain, TDomain})
end;
-verify_val(address, {Domain, Addr0}) ->
- case normalize_address(Domain, Addr0) of
+verify_val(address, {TDomain, Addr0}) ->
+ case normalize_address(TDomain, Addr0) of
{_A1, _A2, _A3, _A4} = Addr ->
{ok, Addr};
{_A1, _A2, _A3, _A4, _A5, _A6, _A7, _A8} = Addr ->
diff --git a/lib/snmp/src/manager/snmpm_mpd.erl b/lib/snmp/src/manager/snmpm_mpd.erl
index 3d93c461bd..627838e3d4 100644
--- a/lib/snmp/src/manager/snmpm_mpd.erl
+++ b/lib/snmp/src/manager/snmpm_mpd.erl
@@ -110,10 +110,10 @@ process_msg(Msg, Domain, Addr, Port, State, NoteStore, Logger) ->
#message{version = 'version-2', vsn_hdr = Community, data = Data}
when State#state.v2c =:= true ->
HS = ?empty_msg_size + length(Community),
- process_v1_v2c_msg('version-2', NoteStore, Msg,
- Domain, Addr, Port,
- Community, Data, HS, Logger);
-
+ (catch process_v1_v2c_msg('version-2', NoteStore, Msg,
+ Domain, Addr, Port,
+ Community, Data, HS, Logger));
+
%% Version 3
#message{version = 'version-3', vsn_hdr = H, data = Data}
when State#state.v3 =:= true ->
@@ -154,13 +154,23 @@ process_v1_v2c_msg(Vsn, _NoteStore, Msg, Domain,
?vdebug("process_v1_v2c_msg -> entry with"
"~n Vsn: ~p"
+ "~n Domain: ~p"
"~n Addr: ~p"
"~n Port: ~p"
"~n Community: ~p"
- "~n HS: ~p", [Vsn, Addr, Port, Community, HS]),
-
- TDomain = snmp_conf:mk_tdomain(Domain),
- TAddress = snmp_conf:mk_taddress(Domain, Addr, Port),
+ "~n HS: ~p", [Vsn, Domain, Addr, Port, Community, HS]),
+
+ {TDomain, TAddress} =
+ try
+ begin
+ TD = snmp_conf:mk_tdomain(Domain),
+ TA = snmp_conf:mk_taddress(Domain, Addr, Port),
+ {TD, TA}
+ end
+ catch
+ throw:{error, TReason} ->
+ throw({discarded, {badarg, Domain, TReason}})
+ end,
Max = get_max_message_size(),
AgentMax = get_agent_max_message_size(Addr, Port),
@@ -188,11 +198,7 @@ process_v1_v2c_msg(Vsn, _NoteStore, Msg, Domain,
"~n Reason: ~p", [Reason]),
inc(snmpInASNParseErrs),
{discarded, Reason}
- end;
-process_v1_v2c_msg(_Vsn, _NoteStore, _Msg, Domain,
- _Addr, _Port,
- _Comm, _HS, _Data, _Log) ->
- {discarded, {badarg, Domain}}.
+ end.
pdu_ms(MgrMMS, AgentMMS, HS) when AgentMMS < MgrMMS ->
AgentMMS - HS;
diff --git a/lib/snmp/src/manager/snmpm_net_if.erl b/lib/snmp/src/manager/snmpm_net_if.erl
index e6013d1658..4d6bd9aa33 100644
--- a/lib/snmp/src/manager/snmpm_net_if.erl
+++ b/lib/snmp/src/manager/snmpm_net_if.erl
@@ -753,7 +753,7 @@ maybe_handle_send_pdu(Pdu, Vsn, MsgData, Domain, Addr, Port,
handle_send_pdu(Pdu, Vsn, MsgData, Domain, Addr, Port, State)
end.
-handle_send_pdu(Pdu, Vsn, MsgData, Domain, Addr, Port,
+handle_send_pdu(Pdu, Vsn, MsgData, _Domain, Addr, Port,
#state{server = Pid,
note_store = NoteStore,
sock = Sock,
diff --git a/lib/snmp/src/manager/snmpm_server.erl b/lib/snmp/src/manager/snmpm_server.erl
index 374ecbd561..484954addb 100644
--- a/lib/snmp/src/manager/snmpm_server.erl
+++ b/lib/snmp/src/manager/snmpm_server.erl
@@ -3203,7 +3203,7 @@ agent_data(TargetName, SendOpts) ->
{Comm, SecModel}
end,
- Domain = agent_data_item(domain, Info),
+ Domain = agent_data_item(tdomain, Info),
Addr = agent_data_item(address, Info),
Port = agent_data_item(port, Info),
RegType = agent_data_item(reg_type, Info),
diff --git a/lib/snmp/src/misc/snmp_conf.erl b/lib/snmp/src/misc/snmp_conf.erl
index 20f4455d10..99f97cd6e1 100644
--- a/lib/snmp/src/misc/snmp_conf.erl
+++ b/lib/snmp/src/misc/snmp_conf.erl
@@ -388,7 +388,7 @@ check_tdomain(TDomain) ->
%% ---------
mk_tdomain(snmpUDPDomain) ->
- ?snmpUDPDomain;
+ mk_tdomain(transportDomainUdpIpv4);
mk_tdomain(transportDomainUdpIpv4) ->
?transportDomainUdpIpv4;
mk_tdomain(transportDomainUdpIpv6) ->