1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 1996-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20-module(snmpa_mib_data). 21 22-include_lib("snmp/include/snmp_types.hrl"). 23 24%%%----------------------------------------------------------------- 25%%% This is the behaviour for the MIB server backend internal 26%%% data storage. 27%%%----------------------------------------------------------------- 28 29%% These types should really be defined elsewhere... 30-export_type([ 31 mib_view/0, 32 mib_view_elem/0, 33 mib_view_mask/0, 34 mib_view_inclusion/0 35 ]). 36 37-type mib_view() :: [mib_view_elem()]. 38-type mib_view_elem() :: {SubTree :: snmp:oid(), 39 Mask :: [non_neg_integer()], 40 Inclusion :: mib_view_inclusion()}. 41-type mib_view_mask() :: [non_neg_integer()]. 42-type mib_view_inclusion() :: 1 | 2. % 1 = included, 2 = excluded 43 44-type filename() :: file:filename(). 45 46 47-callback new(MibStorage :: snmpa:mib_storage()) -> State :: term(). 48 49-callback close(State :: term()) -> ok. 50 51-callback sync(State :: term()) -> ok. 52 53-callback load_mib(State :: term(), FileName :: string(), 54 MeOverride :: boolean(), 55 TeOverride :: boolean()) -> 56 {ok, NewState :: term()} | {error, Reason :: already_loaded | term()}. 57 58-callback unload_mib(State :: term(), FileName :: string(), 59 MeOverride :: boolean(), 60 TeOverride :: boolean()) -> 61 {ok, NewState :: term()} | {error, Reason :: not_loaded | term()}. 62 63-callback lookup(State :: term(), Oid :: snmp:oid()) -> 64 {false, Reason :: term()} | 65 {variable, MibEntry :: snmpa:me()} | 66 {table_column, MibEntry :: snmpa:me(), TableEntryOid :: snmp:oid()} | 67 {subagent, SubAgentPid :: pid(), SAOid :: snmp:oid()}. 68 69-callback next(State :: term(), Oid :: snmp:oid(), MibView :: mib_view()) -> 70 endOfView | false | 71 {subagent, SubAgentPid :: pid(), SAOid :: snmp:oid()} | 72 {variable, MibEntry :: snmpa:me(), VarOid :: snmp:oid()} | 73 {table, TableOid :: snmp:oid(), TableRestOid :: snmp:oid(), MibEntry :: snmpa:me()}. 74 75-callback register_subagent(State :: term(), 76 Oid :: snmp:oid(), 77 Pid :: pid()) -> 78 {ok, NewState :: term()} | {error, Reason :: term()}. 79 80-callback unregister_subagent(State :: term(), 81 PidOrOid :: pid() | snmp:oid()) -> 82 {ok, NewState :: term()} | % When second arg was a pid() 83 {ok, NewState :: term(), Pid :: pid()} | % When second arg was a oid() 84 {error, Reason :: term()}. 85 86-callback dump(State :: term(), Destination :: io | filename()) -> 87 ok | {error, Reason :: term()}. 88 89-callback which_mib(State :: term(), Oid :: snmp:oid()) -> 90 {ok, Mib :: string()} | {error, Reason :: term()}. 91 92-callback which_mibs(State :: term()) -> 93 [{MibName :: atom(), Filename :: string()}]. 94 95-callback whereis_mib(State :: term(), MibName :: atom()) -> 96 {ok, Filename :: string()} | {error, Reason :: term()}. 97 98-callback info(State :: term()) -> list(). 99 100-callback backup(State :: term(), BackupDir :: string()) -> 101 ok | {error, Reason :: term()}. 102 103-callback code_change(Direction :: up | down, 104 Vsn :: term(), 105 Extra :: term(), 106 State :: term()) -> 107 NewState :: term(). 108 109 110 111