diff options
author | Micael Karlberg <bmk@erlang.org> | 2012-08-01 10:28:50 +0200 |
---|---|---|
committer | Micael Karlberg <bmk@erlang.org> | 2012-08-01 10:48:01 +0200 |
commit | 6c3ce92734fe80bec370857a83ccf375c3f20565 (patch) | |
tree | 1aa0c69ce6c1125aecf72f801ec9a78084a0277d /lib/snmp/src | |
parent | 730ef404d96a9db21e92101409cf9043b2126848 (diff) | |
download | otp-6c3ce92734fe80bec370857a83ccf375c3f20565.tar.gz otp-6c3ce92734fe80bec370857a83ccf375c3f20565.tar.bz2 otp-6c3ce92734fe80bec370857a83ccf375c3f20565.zip |
[snmp/agent] Cleanup
Diffstat (limited to 'lib/snmp/src')
-rw-r--r-- | lib/snmp/src/agent/snmp_view_based_acm_mib.erl | 161 |
1 files changed, 82 insertions, 79 deletions
diff --git a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl index 71dcc0f849..e7dea52857 100644 --- a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl +++ b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl @@ -565,85 +565,88 @@ vacmAccessTable(is_set_ok, RowIndex, Cols0) -> case (catch verify_vacmAccessTable_cols(Cols0, [])) of {ok, Cols} -> IsValidKey = is_valid_key(RowIndex), - StatusCol = lists:keyfind(?vacmAccessStatus, 1, Cols), - OldRow = snmpa_vacm:get_row(RowIndex), - case {StatusCol, OldRow} of - {{Col, ?'RowStatus_active'}, false} -> - % row does not yet exist => inconsistentValue - % (see SNMPv2-TC.mib, RowStatus textual convention) - {inconsistentValue, Col}; - {{Col, ?'RowStatus_active'}, {ok, Row}} -> - %% Ok, if contextMatch is init - case element(?vacmAContextMatch, Row) of - noinit -> - % check whether ContextMatch is being set in the same operation - case proplists:get_value(?vacmAccessContextMatch, Cols) of - undefined -> - % no, we can't make this row active yet - {inconsistentValue, Col}; - _ -> - % ok, activate the row - {noError, 0} - end; - _ -> - {noError, 0} - end; - {{Col, ?'RowStatus_notInService'}, false} -> - % row does not yet exist => inconsistentValue - % (see SNMPv2-TC.mib, RowStatus textual convention) - {inconsistentValue, Col}; - {{Col, ?'RowStatus_notInService'}, {ok, Row}} -> - % Ok, if not notReady - case element(?vacmAStatus, Row) of - ?'RowStatus_notReady' -> - {inconsistentValue, Col}; - _ -> - {noError, 0} - end; - {{Col, ?'RowStatus_notReady'}, _} -> - % never ok! - {inconsistentValue, Col}; - {{Col, ?'RowStatus_createAndGo'}, false} -> - % ok, if it doesn't exist - Res = lists:keysearch(?vacmAccessContextMatch, 1, Cols), - if - IsValidKey /= true -> - % bad RowIndex => noCreation - {noCreation, Col}; - is_tuple(Res) -> - % required field is present => noError - {noError, 0}; - true -> - % required field is missing => inconsistentValue - {inconsistentValue, Col} - end; - {{Col, ?'RowStatus_createAndGo'}, _} -> - % row already exists => inconsistentValue - {inconsistentValue, Col}; - {{Col, ?'RowStatus_createAndWait'}, false} -> - % ok, if it doesn't exist - if - IsValidKey =:= true -> - % RowIndex is valid => noError - {noError, 0}; - true -> - {noCreation, Col} - end; - {{Col, ?'RowStatus_createAndWait'}, _} -> - % Row already exists => inconsistentValue - {inconsistentValue, Col}; - {value, {_Col, ?'RowStatus_destroy'}} -> - % always ok! - {noError, 0}; - {_, false} -> - % otherwise, it's a row change; row does not exist => inconsistentName - {inconsistentName, element(1, hd(Cols))}; - _ -> - % row change and row exists => noError - {noError, 0} - end; - Error -> - Error + StatusCol = lists:keyfind(?vacmAccessStatus, 1, Cols), + MaybeRow = snmpa_vacm:get_row(RowIndex), + case {StatusCol, MaybeRow} of + {{Col, ?'RowStatus_active'}, false} -> + %% row does not yet exist => inconsistentValue + %% (see SNMPv2-TC.mib, RowStatus textual convention) + {inconsistentValue, Col}; + {{Col, ?'RowStatus_active'}, {ok, Row}} -> + %% Ok, if contextMatch is init + case element(?vacmAContextMatch, Row) of + noinit -> + %% check whether ContextMatch is being set in + %% the same operation + case proplists:get_value(?vacmAccessContextMatch, + Cols) of + undefined -> + %% no, we can't make this row active yet + {inconsistentValue, Col}; + _ -> + %% ok, activate the row + {noError, 0} + end; + _ -> + {noError, 0} + end; + {{Col, ?'RowStatus_notInService'}, false} -> + %% row does not yet exist => inconsistentValue + %% (see SNMPv2-TC.mib, RowStatus textual convention) + {inconsistentValue, Col}; + {{Col, ?'RowStatus_notInService'}, {ok, Row}} -> + %% Ok, if not notReady + case element(?vacmAStatus, Row) of + ?'RowStatus_notReady' -> + {inconsistentValue, Col}; + _ -> + {noError, 0} + end; + {{Col, ?'RowStatus_notReady'}, _} -> + %% never ok! + {inconsistentValue, Col}; + {{Col, ?'RowStatus_createAndGo'}, false} -> + %% ok, if it doesn't exist + Res = lists:keysearch(?vacmAccessContextMatch, 1, Cols), + if + IsValidKey =/= true -> + %% bad RowIndex => noCreation + {noCreation, Col}; + is_tuple(Res) -> + %% required field is present => noError + {noError, 0}; + true -> + %% required field is missing => inconsistentValue + {inconsistentValue, Col} + end; + {{Col, ?'RowStatus_createAndGo'}, _} -> + %% row already exists => inconsistentValue + {inconsistentValue, Col}; + {{Col, ?'RowStatus_createAndWait'}, false} -> + %% ok, if it doesn't exist + if + IsValidKey =:= true -> + %% RowIndex is valid => noError + {noError, 0}; + true -> + {noCreation, Col} + end; + {{Col, ?'RowStatus_createAndWait'}, _} -> + %% Row already exists => inconsistentValue + {inconsistentValue, Col}; + {value, {_Col, ?'RowStatus_destroy'}} -> + %% always ok! + {noError, 0}; + {_, false} -> + %% otherwise, it's a row change; + %% row does not exist => inconsistentName + {inconsistentName, element(1, hd(Cols))}; + _ -> + %% row change and row exists => noError + {noError, 0} + end; + Error -> + Error end; vacmAccessTable(set, RowIndex, Cols0) -> case (catch verify_vacmAccessTable_cols(Cols0, [])) of |