aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/src
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2014-04-17 16:29:51 +0200
committerRaimo Niskanen <[email protected]>2014-07-25 12:14:44 +0200
commit373d9fa059875a2d68251c485968d3aa78e830b4 (patch)
treebefc6315db5b1da0790120cb12eb03f7bfb9dc16 /lib/snmp/src
parent7bc7e5821ea0614ca82467bf0349f82b61d89971 (diff)
downloadotp-373d9fa059875a2d68251c485968d3aa78e830b4.tar.gz
otp-373d9fa059875a2d68251c485968d3aa78e830b4.tar.bz2
otp-373d9fa059875a2d68251c485968d3aa78e830b4.zip
wip-all-regression-tests-but-one-manager
Diffstat (limited to 'lib/snmp/src')
-rw-r--r--lib/snmp/src/agent/snmp_target_mib.erl15
-rw-r--r--lib/snmp/src/manager/snmpm_config.erl19
-rw-r--r--lib/snmp/src/misc/snmp_conf.erl16
-rw-r--r--lib/snmp/src/misc/snmp_config.erl4
4 files changed, 32 insertions, 22 deletions
diff --git a/lib/snmp/src/agent/snmp_target_mib.erl b/lib/snmp/src/agent/snmp_target_mib.erl
index cff1e253c3..3bcfd469e6 100644
--- a/lib/snmp/src/agent/snmp_target_mib.erl
+++ b/lib/snmp/src/agent/snmp_target_mib.erl
@@ -263,7 +263,7 @@ check_target_addr(
TagList, Params, EngineId, Mask, MMS]),
snmp_conf:check_string(Name,{gt,0}),
snmp_conf:check_domain(Domain),
- NAddress = snmp_conf:check_address(Domain, Address),
+ NAddress = check_address(Domain, Address),
snmp_conf:check_integer(Timeout, {gte, 0}),
snmp_conf:check_integer(RetryCount, {gte,0}),
snmp_conf:check_string(TagList),
@@ -290,19 +290,20 @@ check_address(Domain, Address) ->
case snmp_conf:check_address(Domain, Address) of
ok ->
Address;
- {ok, FixedAddress} ->
- FixedAddress
+ {ok, NAddress} ->
+ NAddress
end.
-check_mask(_Domain, []) ->
- [];
+check_mask(_Domain, [] = Mask) ->
+ Mask;
check_mask(Domain, Mask) ->
try check_address(Domain, Mask)
catch
- {error, {invalid_address, Info}} ->
- error({invalid_mask, Info})
+ {error, {bad_address, Info}} ->
+ error({bad_mask, Info})
end.
+
%%-----------------------------------------------------------------
%% TargetParams
%% {Name, MPModel, SecurityModel, SecurityName, SecurityLevel}
diff --git a/lib/snmp/src/manager/snmpm_config.erl b/lib/snmp/src/manager/snmpm_config.erl
index af2262d988..ea962575d5 100644
--- a/lib/snmp/src/manager/snmpm_config.erl
+++ b/lib/snmp/src/manager/snmpm_config.erl
@@ -1702,7 +1702,10 @@ verify_agent(Conf) ->
verify_agent(lists:sort(fun order_agent/2, Conf), []).
verify_agent([], VerifiedConf) ->
- list:reverse(VerifiedConf);
+ Ret = lists:reverse(VerifiedConf),
+ ?vdebug("verify_agent -> returns:~n"
+ " ~p", [Ret]),
+ Ret;
verify_agent([{_Item, _} = Entry|Conf], VerifiedConf) ->
%% verify_invalid(VerifiedConf, [_Item]), % Check for duplicate
verify_agent(Conf, VerifiedConf, Entry);
@@ -1744,11 +1747,11 @@ verify_agent(Conf, VerifiedConf, {address = Item, Address} = Entry) ->
{ok, {NAddress,FakePort}} ->
verify_agent(Conf, [{Item, NAddress}|VC]);
{ok, _} ->
- error({invalid_address, {TDomain, Address}})
+ error({bad_address, {TDomain, Address}})
end;
verify_agent(Conf, VerifiedConf, {port, Port} = Entry) ->
verify_invalid(VerifiedConf, [taddress]),
- ok = snmp_conf:check_address(snmpUDPDomain, {{0, 0, 0, 0}, Port}),
+ _ = snmp_conf:check_address(snmpUDPDomain, {{0, 0, 0, 0}, Port}),
verify_agent(Conf, [Entry|VerifiedConf]);
verify_agent(Conf, VerifiedConf, {Item, Val} = Entry) ->
case verify_agent_entry(Item, Val) of
@@ -1846,7 +1849,7 @@ check_user_config({Id, Mod, Data, DefaultAgentConfig} = _User)
end;
check_user_config({Id, _Mod, _Data, DefaultAgentConfig})
when (Id =/= ?DEFAULT_USER) ->
- {error, {bad_default_agent_config, DefaultAgentConfig}};
+ error({bad_default_agent_config, DefaultAgentConfig});
check_user_config({Id, _Mod, _Data, _DefaultAgentConfig}) ->
error({bad_user_id, Id});
check_user_config(User) ->
@@ -2146,7 +2149,7 @@ check_manager_config({engine_id, EngineID}) ->
check_manager_config({max_message_size, Max}) ->
snmp_conf:check_integer(Max, {gte, 484});
check_manager_config(Conf) ->
- {error, {unknown_config, Conf}}.
+ error({unknown_config, Conf}).
check_mandatory_manager_config(Conf) ->
@@ -2709,7 +2712,7 @@ handle_register_agent(UserId, TargetName, Config) ->
%% dirty crossref stuff
?vtrace("handle_register_agent -> lookup address", []),
{ok, Addr} = agent_info(TargetName, address),
- ?vtrace("handle_register_agent -> Addr: ~p, lookup Port",
+ ?vtrace("handle_register_agent -> Addr: ~p, lookup Port",
[Addr]),
{ok, Port} = agent_info(TargetName, port),
?vtrace("handle_register_agent -> register cross-ref fix", []),
@@ -2737,7 +2740,7 @@ handle_register_agent(UserId, TargetName, Config) ->
do_handle_register_agent(_TargetName, []) ->
ok;
do_handle_register_agent(TargetName, [{Item, Val}|Rest]) ->
- ?vtrace("handle_register_agent -> entry with"
+ ?vtrace("do_handle_register_agent -> entry with"
"~n TargetName: ~p"
"~n Item: ~p"
"~n Val: ~p"
@@ -2746,7 +2749,7 @@ do_handle_register_agent(TargetName, [{Item, Val}|Rest]) ->
ok ->
do_handle_register_agent(TargetName, Rest);
{error, Reason} ->
- ?vtrace("handle_register_agent -> failed updating ~p"
+ ?vtrace("do_handle_register_agent -> failed updating ~p"
"~n Item: ~p"
"~n Reason: ~p", [Item, Reason]),
ets:match_delete(snmpm_agent_table, {TargetName, '_'}),
diff --git a/lib/snmp/src/misc/snmp_conf.erl b/lib/snmp/src/misc/snmp_conf.erl
index f85f1d3828..3fefe3e8cd 100644
--- a/lib/snmp/src/misc/snmp_conf.erl
+++ b/lib/snmp/src/misc/snmp_conf.erl
@@ -596,6 +596,8 @@ mk_taddress(?transportDomainUdpIpv6, Address) ->
%%
mk_taddress(transportDomainUdpIpv4 = Domain, Address) ->
case Address of
+ [] -> % Empty mask
+ [];
{Ip, Port} when tuple_size(Ip) =:= 4, is_integer(Port) ->
tuple_to_list(Ip) ++ mk_bytes(Port);
_ ->
@@ -603,6 +605,8 @@ mk_taddress(transportDomainUdpIpv4 = Domain, Address) ->
end;
mk_taddress(transportDomainUdpIpv6 = Domain, Address) ->
case Address of
+ [] -> % Empty mask
+ [];
{Ip, Port}
when tuple_size(Ip) =:= 8, is_integer(Port) ->
tuple_to_list(Ip) ++ mk_bytes(Port);
@@ -710,14 +714,14 @@ check_ip(X) ->
check_ip(snmpUDPDomain, X) ->
check_ip(transportDomainUdpIpv4, X);
-check_ip(transportDomainUdpIpv4, X) ->
+check_ip(transportDomainUdpIpv4 = Domain, X) ->
case X of
[A,B,C,D] when ?is_ipv4_addr(A, B, C, D) ->
ok;
_ ->
- error({invalid_ip_address, X})
+ error({bad_address, {Domain, X}})
end;
-check_ip(transportDomainUdpIpv6, X) ->
+check_ip(transportDomainUdpIpv6 = Domain, X) ->
case X of
[A,B,C,D,E,F,G,H]
when ?is_ipv6_addr(A, B, C, D, E, F, G, H) ->
@@ -727,7 +731,7 @@ check_ip(transportDomainUdpIpv6, X) ->
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) ->
ok;
_ ->
- error({invalid_ip_address, X})
+ error({bad_address, {Domain, X}})
end;
%%
check_ip(BadDomain, _X) ->
@@ -744,7 +748,7 @@ check_address(Domain, Address, DefaultPort) ->
false ->
case check_address_ip_port(Domain, Address) of
false ->
- error({invalid_address, {Domain, Address}});
+ error({bad_address, {Domain, Address}});
true ->
{ok, Address};
FixedAddress ->
@@ -759,7 +763,7 @@ check_address(Domain, Address, DefaultPort) ->
check_address(Domain, Address) ->
case check_address_ip_port(Domain, Address) of
false ->
- error({invalid_address, {Domain, Address}});
+ error({bad_address, {Domain, Address}});
true ->
{ok, Address};
FixedAddress ->
diff --git a/lib/snmp/src/misc/snmp_config.erl b/lib/snmp/src/misc/snmp_config.erl
index ec6b2ac7e4..12467a1abf 100644
--- a/lib/snmp/src/misc/snmp_config.erl
+++ b/lib/snmp/src/misc/snmp_config.erl
@@ -2446,7 +2446,9 @@ write_config_file(Dir, FileName, Verify, Write)
throw:Error ->
Error;
T:E ->
- {error, {failed_write, Dir, FileName, T, E}}
+ {error,
+ {failed_write, Dir, FileName,
+ {T, E, erlang:get_stacktrace()}}}
end.