4
%% Copyright Ericsson AB 2004-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 2004-2010. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
19
19
-module(snmpa_net_if).
55
55
-define(DEFAULT_FILTER_MODULE, snmpa_net_if_filter).
56
56
-define(DEFAULT_FILTER_OPTS, [{module, ?DEFAULT_FILTER_MODULE}]).
58
-define(ATL_SEQNO_INITIAL, 1).
59
-define(ATL_SEQNO_MAX, 2147483647).
59
62
%%%-----------------------------------------------------------------
60
63
%%% This module implements the default Network Interface part
194
197
{error, {udp_open, UDPPort, Reason}}
198
202
case ets:lookup(snmp_agent_table, audit_trail_log) of
201
205
[{audit_trail_log, AtlOpts}] ->
202
?vtrace("AtlOpts: ~p",[AtlOpts]),
206
?vtrace("AtlOpts: ~p", [AtlOpts]),
203
207
Type = get_atl_type(AtlOpts),
204
208
Dir = get_atl_dir(AtlOpts),
205
209
Size = get_atl_size(AtlOpts),
206
210
Repair = get_atl_repair(AtlOpts),
207
211
Name = ?audit_trail_log_name,
208
212
File = filename:absname(?audit_trail_log_file, Dir),
209
case snmp_log:create(Name, File, Size, Repair, true) of
211
?vdebug("log created: ~w",[Log]),
214
throw({error, {create_log, Reason}})
213
case get_atl_seqno(AtlOpts) of
215
Initial = ?ATL_SEQNO_INITIAL,
216
Max = ?ATL_SEQNO_MAX,
217
Module = snmpa_agent,
218
Function = increment_counter,
219
Args = [atl_seqno, Initial, Max],
220
SeqNoGen = {Module, Function, Args},
221
case snmp_log:create(Name, File,
222
SeqNoGen, Size, Repair, true) of
224
?vdebug("log created: ~w", [Log]),
227
throw({error, {create_log, Reason}})
230
case snmp_log:create(Name, File, Size, Repair, true) of
232
?vdebug("log created: ~w", [Log]),
235
throw({error, {create_log, Reason}})
920
942
system_terminate(Reason, _Parent, _Dbg, #state{log = Log}) ->
943
?vlog("system-terminate -> entry with"
944
"~n Reason: ~p", [Reason]),
921
945
do_close_log(Log),
924
system_code_change(OldState, _Module, _OldVsn, upgrade_from_pre_4_10) ->
930
usock_opts = SockOpts,
931
mpd_state = MpdState,
936
rcnt = RCNT} = OldState,
937
NewState = #state{parent = Parent,
941
usock_opts = SockOpts,
942
mpd_state = MpdState,
948
filter = create_filter(?DEFAULT_FILTER_OPTS)},
950
system_code_change(OldState, _Module, _OldVsn, downgrade_to_pre_4_10) ->
951
#state{parent = Parent,
955
usock_opts = SockOpts,
956
mpd_state = MpdState,
961
rcnt = RCNT} = OldState,
968
usock_opts = SockOpts,
969
mpd_state = MpdState,
948
system_code_change(OldState, _Module, _OldVsn, downgrade_to_pre_4_16) ->
949
{OldLog, Type} = OldState#state.log,
950
NewLog = snmp_log:downgrade(OldLog),
951
NewState = OldState#state{log = {NewLog, Type}},
954
system_code_change(OldState, _Module, _OldVsn, upgrade_from_pre_4_16) ->
955
Initial = ?ATL_SEQNO_INITIAL,
956
Max = ?ATL_SEQNO_MAX,
957
Module = snmpa_agent,
958
Function = increment_counter,
959
Args = [atl_seqno, Initial, Max],
960
SeqNoGen = {Module, Function, Args},
961
{OldLog, Type} = OldState#state.log,
962
NewLog = snmp_log:upgrade(OldLog, SeqNoGen),
963
NewState = OldState#state{log = {NewLog, Type}},
976
966
system_code_change(S, _Module, _OldVsn, _Extra) ->