aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/src/agent
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2014-04-11 16:14:00 +0200
committerRaimo Niskanen <[email protected]>2014-07-22 09:59:15 +0200
commit7bc7e5821ea0614ca82467bf0349f82b61d89971 (patch)
tree7e805194510601fa7394320742da3da846bc9a1f /lib/snmp/src/agent
parent768a6d38597b8bedf6551ad2e6472b2965765dd2 (diff)
downloadotp-7bc7e5821ea0614ca82467bf0349f82b61d89971.tar.gz
otp-7bc7e5821ea0614ca82467bf0349f82b61d89971.tar.bz2
otp-7bc7e5821ea0614ca82467bf0349f82b61d89971.zip
wip
Diffstat (limited to 'lib/snmp/src/agent')
-rw-r--r--lib/snmp/src/agent/snmp_framework_mib.erl9
-rw-r--r--lib/snmp/src/agent/snmp_target_mib.erl22
-rw-r--r--lib/snmp/src/agent/snmpa_conf.erl2
-rw-r--r--lib/snmp/src/agent/snmpa_mpd.erl16
4 files changed, 25 insertions, 24 deletions
diff --git a/lib/snmp/src/agent/snmp_framework_mib.erl b/lib/snmp/src/agent/snmp_framework_mib.erl
index 84f39df228..51f8c46d19 100644
--- a/lib/snmp/src/agent/snmp_framework_mib.erl
+++ b/lib/snmp/src/agent/snmp_framework_mib.erl
@@ -197,12 +197,7 @@ check_context(Context) ->
%% {Name, Value}.
%%-----------------------------------------------------------------
check_agent({intAgentTransportDomain, D}, Domain) ->
- case Domain of
- undefined ->
- {snmp_conf:check_domain(D), D};
- _ ->
- error({invalid_agent_attribute, D})
- end;
+ {snmp_conf:check_domain(D), D};
check_agent({intAgentTransportAddress, Address}, Domain) ->
{snmp_conf:check_address(Domain, Address), Domain};
check_agent(Entry, Domain) ->
@@ -224,7 +219,7 @@ check_agent(X) ->
%% Ordering function to sort intAgentTransportDomain first
%% hence before intAgentTransportAddress
-order_agent({intAgentTransportDomain, _}, {intAgentTransportDomain, _}) ->
+order_agent({Name, _}, {Name, _}) ->
true; %% Less than or equal
order_agent(_, {intAgentTransportDomain, _}) ->
false; %% Greater than
diff --git a/lib/snmp/src/agent/snmp_target_mib.erl b/lib/snmp/src/agent/snmp_target_mib.erl
index 6dd3b6e23a..cff1e253c3 100644
--- a/lib/snmp/src/agent/snmp_target_mib.erl
+++ b/lib/snmp/src/agent/snmp_target_mib.erl
@@ -263,16 +263,16 @@ check_target_addr(
TagList, Params, EngineId, Mask, MMS]),
snmp_conf:check_string(Name,{gt,0}),
snmp_conf:check_domain(Domain),
- snmp_conf:check_address(Domain, Address),
+ NAddress = snmp_conf:check_address(Domain, Address),
snmp_conf:check_integer(Timeout, {gte, 0}),
snmp_conf:check_integer(RetryCount, {gte,0}),
snmp_conf:check_string(TagList),
snmp_conf:check_string(Params),
check_engine_id(EngineId),
- check_mask(Domain, Mask),
+ NMask = check_mask(Domain, Mask),
TDomain = snmp_conf:mk_tdomain(Domain),
- TAddress = snmp_conf:mk_taddress(Domain, Address),
- TMask = snmp_conf:mk_taddress(Domain, Mask),
+ TAddress = snmp_conf:mk_taddress(Domain, NAddress),
+ TMask = snmp_conf:mk_taddress(Domain, NMask),
snmp_conf:check_packet_size(MMS),
?vtrace("check target address done",[]),
Addr = {Name, TDomain, TAddress, Timeout,
@@ -286,13 +286,21 @@ check_engine_id(discovery) ->
check_engine_id(EngineId) ->
snmp_conf:check_string(EngineId).
+check_address(Domain, Address) ->
+ case snmp_conf:check_address(Domain, Address) of
+ ok ->
+ Address;
+ {ok, FixedAddress} ->
+ FixedAddress
+ end.
+
check_mask(_Domain, []) ->
- ok;
+ [];
check_mask(Domain, Mask) ->
- try snmp_conf:check_address(Domain, Mask)
+ try check_address(Domain, Mask)
catch
{error, {invalid_address, Info}} ->
- {error, {invalid_mask, Info}}
+ error({invalid_mask, Info})
end.
%%-----------------------------------------------------------------
diff --git a/lib/snmp/src/agent/snmpa_conf.erl b/lib/snmp/src/agent/snmpa_conf.erl
index a405987c8a..f055f89880 100644
--- a/lib/snmp/src/agent/snmpa_conf.erl
+++ b/lib/snmp/src/agent/snmpa_conf.erl
@@ -140,7 +140,7 @@ verify_agent_conf(X, _) ->
error({bad_agent_config, X}).
check_agent_conf_entry(Entry, State) ->
- {ok, _NewState} = snmp_framework_mib:check_agent(Entry, State).
+ snmp_framework_mib:check_agent(Entry, State).
write_agent_conf(Fd, "", Conf) ->
write_agent_conf(Fd, Conf);
diff --git a/lib/snmp/src/agent/snmpa_mpd.erl b/lib/snmp/src/agent/snmpa_mpd.erl
index 9bb4556788..2db98d9fc2 100644
--- a/lib/snmp/src/agent/snmpa_mpd.erl
+++ b/lib/snmp/src/agent/snmpa_mpd.erl
@@ -186,12 +186,12 @@ discarded_pdu(Variable) -> inc(Variable).
v1_v2c_proc(
Vsn, NoteStore, Community, Domain, Address,
LocalEngineID, Data, HS, Log, Packet) ->
- try snmp_conf:check_domain(Domain) of
- ok ->
- try snmp_conf:check_address(Domain, Address) of
- ok ->
+ try snmp_conf:mk_tdomain(Domain) of
+ TDomain ->
+ try snmp_conf:mk_taddress(Domain, Address) of
+ TAddress ->
v1_v2c_proc_dec(
- Vsn, NoteStore, Community, Domain, Address,
+ Vsn, NoteStore, Community, TDomain, TAddress,
LocalEngineID, Data, HS, Log, Packet)
catch
_ ->
@@ -203,10 +203,8 @@ v1_v2c_proc(
end.
v1_v2c_proc_dec(
- Vsn, NoteStore, Community, Domain, Address,
+ Vsn, NoteStore, Community, TDomain, TAddress,
LocalEngineID, Data, HS, Log, Packet) ->
- TDomain = snmp_conf:mk_tdomain(Domain),
- TAddress = snmp_conf:mk_taddress(Domain, Address),
AgentMS = get_engine_max_message_size(LocalEngineID),
MgrMS = snmp_community_mib:get_target_addr_ext_mms(TDomain, TAddress),
PduMS = case MgrMS of
@@ -233,7 +231,7 @@ v1_v2c_proc_dec(
case Pdu#pdu.type of
'set-request' ->
%% Check if this message has already been processed
- Key = {agent, {Domain, Address}, ReqId},
+ Key = {agent, {TDomain, TAddress}, ReqId},
case snmp_note_store:get_note(NoteStore, Key) of
undefined ->
%% Set the processed note _after_ pdu processing.