aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/src/agent/snmpa_conf.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/snmp/src/agent/snmpa_conf.erl')
-rw-r--r--lib/snmp/src/agent/snmpa_conf.erl96
1 files changed, 65 insertions, 31 deletions
diff --git a/lib/snmp/src/agent/snmpa_conf.erl b/lib/snmp/src/agent/snmpa_conf.erl
index c17a6abbd7..a405987c8a 100644
--- a/lib/snmp/src/agent/snmpa_conf.erl
+++ b/lib/snmp/src/agent/snmpa_conf.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2006-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2006-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -123,21 +123,24 @@ append_agent_config(Dir, Conf)
read_agent_config(Dir) ->
- Verify = fun(Entry) -> verify_agent_conf_entry(Entry) end,
- read_config_file(Dir, "agent.conf", Verify).
+ Order = fun snmp_framework_mib:order_agent/2,
+ Check = fun check_agent_conf_entry/2,
+ read_config_file(Dir, "agent.conf", Order, Check).
-
-verify_agent_conf([]) ->
+
+verify_agent_conf(Conf) ->
+ verify_agent_conf(Conf, undefined).
+%%
+verify_agent_conf([], _) ->
ok;
-verify_agent_conf([H|T]) ->
- verify_agent_conf_entry(H),
- verify_agent_conf(T);
-verify_agent_conf(X) ->
+verify_agent_conf([H|T], State) ->
+ {_, NewState} = check_agent_conf_entry(H, State),
+ verify_agent_conf(T, NewState);
+verify_agent_conf(X, _) ->
error({bad_agent_config, X}).
-verify_agent_conf_entry(Entry) ->
- ok = snmp_framework_mib:check_agent(Entry),
- ok.
+check_agent_conf_entry(Entry, State) ->
+ {ok, _NewState} = snmp_framework_mib:check_agent(Entry, State).
write_agent_conf(Fd, "", Conf) ->
write_agent_conf(Fd, Conf);
@@ -204,8 +207,12 @@ append_context_config(Dir, Conf)
read_context_config(Dir) ->
- Verify = fun(Entry) -> verify_context_conf_entry(Entry) end,
- read_config_file(Dir, "context.conf", Verify).
+ Order = fun snmp_conf:no_order/2,
+ Verify =
+ fun (Entry, State) ->
+ {verify_context_conf_entry(Entry), State}
+ end,
+ read_config_file(Dir, "context.conf", Order, Verify).
verify_context_conf([]) ->
@@ -286,8 +293,12 @@ append_community_config(Dir, Conf)
read_community_config(Dir) ->
- Verify = fun(Entry) -> verify_community_conf_entry(Entry) end,
- read_config_file(Dir, "community.conf", Verify).
+ Order = fun snmp_conf:no_order/2,
+ Verify =
+ fun (Entry, State) ->
+ {verify_community_conf_entry(Entry), State}
+ end,
+ read_config_file(Dir, "community.conf", Order, Verify).
verify_community_conf([]) ->
@@ -358,8 +369,12 @@ append_standard_config(Dir, Conf)
read_standard_config(Dir) ->
- Verify = fun(Entry) -> verify_standard_conf_entry(Entry) end,
- read_config_file(Dir, "standard.conf", Verify).
+ Order = fun snmp_conf:no_order/2,
+ Verify =
+ fun (Entry, State) ->
+ {verify_standard_conf_entry(Entry), State}
+ end,
+ read_config_file(Dir, "standard.conf", Order, Verify).
verify_standard_conf([]) ->
@@ -520,8 +535,12 @@ append_target_addr_config(Dir, Conf)
read_target_addr_config(Dir) ->
- Verify = fun(Entry) -> verify_target_addr_conf_entry(Entry) end,
- read_config_file(Dir, "target_addr.conf", Verify).
+ Order = fun snmp_conf:no_order/2,
+ Verify =
+ fun (Entry, State) ->
+ {verify_target_addr_conf_entry(Entry), State}
+ end,
+ read_config_file(Dir, "target_addr.conf", Order, Verify).
verify_target_addr_conf([]) ->
@@ -626,8 +645,12 @@ append_target_params_config(Dir, Conf)
read_target_params_config(Dir) ->
- Verify = fun(Entry) -> verify_target_params_conf_entry(Entry) end,
- read_config_file(Dir, "target_params.conf", Verify).
+ Order = fun snmp_conf:no_order/2,
+ Verify =
+ fun (Entry, State) ->
+ {verify_target_params_conf_entry(Entry), State}
+ end,
+ read_config_file(Dir, "target_params.conf", Order, Verify).
verify_target_params_conf([]) ->
@@ -698,8 +721,12 @@ append_notify_config(Dir, Conf)
read_notify_config(Dir) ->
- Verify = fun(Entry) -> verify_notify_conf_entry(Entry) end,
- read_config_file(Dir, "notify.conf", Verify).
+ Order = fun snmp_conf:no_order/2,
+ Verify =
+ fun (Entry, State) ->
+ {verify_notify_conf_entry(Entry), State}
+ end,
+ read_config_file(Dir, "notify.conf", Order, Verify).
verify_notify_conf([]) ->
@@ -794,8 +821,12 @@ append_usm_config(Dir, Conf)
read_usm_config(Dir) ->
- Verify = fun(Entry) -> verify_usm_conf_entry(Entry) end,
- read_config_file(Dir, "usm.conf", Verify).
+ Order = fun snmp_conf:no_order/2,
+ Verify =
+ fun (Entry, State) ->
+ {verify_usm_conf_entry(Entry), State}
+ end,
+ read_config_file(Dir, "usm.conf", Order, Verify).
verify_usm_conf([]) ->
@@ -903,8 +934,12 @@ append_vacm_config(Dir, Conf)
read_vacm_config(Dir) ->
- Verify = fun(Entry) -> verify_vacm_conf_entry(Entry) end,
- read_config_file(Dir, "vacm.conf", Verify).
+ Order = fun snmp_conf:no_order/2,
+ Verify =
+ fun (Entry, State) ->
+ {verify_vacm_conf_entry(Entry), State}
+ end,
+ read_config_file(Dir, "vacm.conf", Order, Verify).
verify_vacm_conf([]) ->
@@ -958,8 +993,8 @@ write_config_file(Dir, File, Verify, Write) ->
append_config_file(Dir, File, Verify, Write) ->
snmp_config:append_config_file(Dir, File, Verify, Write).
-read_config_file(Dir, File, Verify) ->
- snmp_config:read_config_file(Dir, File, Verify).
+read_config_file(Dir, File, Order, Check) ->
+ snmp_config:read_config_file(Dir, File, Order, Check).
%% ---- config file utility functions ----
@@ -972,6 +1007,5 @@ header() ->
"~2.2.0w:~2.2.0w:~2.2.0w\n",
[?MODULE, ?version, Y, Mo, D, H, Mi, S]).
-
error(R) ->
throw({error, R}).