diff options
Diffstat (limited to 'lib/snmp/src')
-rw-r--r-- | lib/snmp/src/agent/snmp_generic.erl | 30 | ||||
-rw-r--r-- | lib/snmp/src/app/snmp.appup.src | 8 | ||||
-rw-r--r-- | lib/snmp/src/compile/snmpc.erl | 103 | ||||
-rw-r--r-- | lib/snmp/src/compile/snmpc_lib.erl | 39 | ||||
-rw-r--r-- | lib/snmp/src/manager/snmpm_net_if.erl | 4 |
5 files changed, 115 insertions, 69 deletions
diff --git a/lib/snmp/src/agent/snmp_generic.erl b/lib/snmp/src/agent/snmp_generic.erl index fc23e16ef1..e67a1b3c80 100644 --- a/lib/snmp/src/agent/snmp_generic.erl +++ b/lib/snmp/src/agent/snmp_generic.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2017. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -413,20 +413,21 @@ table_check_status(NameDb, Col, ?'RowStatus_createAndGo', RowIndex, Cols) -> false -> % it's ok to use snmpa_local_db:table_construct_row since it's % side effect free and we only use the result temporary. - case catch snmpa_local_db:table_construct_row( + try snmpa_local_db:table_construct_row( NameDb, RowIndex, ?'RowStatus_createAndGo', Cols) of - {'EXIT', _Reason} -> - ?vtrace( - "failed construct row (createAndGo): " - " n Reason: ~p" - " n Stack: ~p", - [_Reason, erlang:get_stacktrace()]), - {noCreation, Col}; % Bad RowIndex Row -> case lists:member(noinit, tuple_to_list(Row)) of false -> {noError, 0}; _Found -> {inconsistentValue, Col} end + catch + _:_Reason -> + ?vtrace( + "failed construct row (createAndGo): " + " n Reason: ~p" + " n Stack: ~p", + [_Reason, erlang:get_stacktrace()]), + {noCreation, Col} % Bad RowIndex end; true -> {inconsistentValue, Col} end; @@ -435,17 +436,18 @@ table_check_status(NameDb, Col, ?'RowStatus_createAndGo', RowIndex, Cols) -> table_check_status(NameDb, Col, ?'RowStatus_createAndWait', RowIndex, Cols) -> case table_row_exists(NameDb, RowIndex) of false -> - case catch snmpa_local_db:table_construct_row( + try snmpa_local_db:table_construct_row( NameDb, RowIndex, ?'RowStatus_createAndGo', Cols) of - {'EXIT', _Reason} -> + _Row -> + {noError, 0} + catch + _:_Reason -> ?vtrace( "failed construct row (createAndWait): " " n Reason: ~p" " n Stack: ~p", [_Reason, erlang:get_stacktrace()]), - {noCreation, Col}; % Bad RowIndex - _Row -> - {noError, 0} + {noCreation, Col} % Bad RowIndex end; true -> {inconsistentValue, Col} end; diff --git a/lib/snmp/src/app/snmp.appup.src b/lib/snmp/src/app/snmp.appup.src index db09ec3dc5..ca61782639 100644 --- a/lib/snmp/src/app/snmp.appup.src +++ b/lib/snmp/src/app/snmp.appup.src @@ -8,10 +8,6 @@ %% {update, snmpa_local_db, soft, soft_purge, soft_purge, []} %% {add_module, snmpm_net_if_mt} [ - {<<"5\\.2\\.4">>, - [{load_module, snmp, soft_purge, soft_purge, []}, - {load_module, snmpc_lib, soft_purge, soft_purge, []}, - {load_module, snmpc_mib_gram, soft_purge, soft_purge, []}]}, {<<"5\\..*">>, [{restart_application, snmp}]}, {<<"4\\..*">>, [{restart_application, snmp}]} ], @@ -21,10 +17,6 @@ %% {remove, {snmpm_net_if_mt, soft_purge, soft_purge}} [ - {<<"5\\.2\\.4">>, - [{load_module, snmp, soft_purge, soft_purge, []}, - {load_module, snmpc_lib, soft_purge, soft_purge, []}, - {load_module, snmpc_mib_gram, soft_purge, soft_purge, []}]}, {<<"5\\..*">>, [{restart_application, snmp}]}, {<<"4\\..*">>, [{restart_application, snmp}]} ] diff --git a/lib/snmp/src/compile/snmpc.erl b/lib/snmp/src/compile/snmpc.erl index 416353508e..7f627d66d9 100644 --- a/lib/snmp/src/compile/snmpc.erl +++ b/lib/snmp/src/compile/snmpc.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2016. All Rights Reserved. +%% Copyright Ericsson AB 1997-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -455,7 +455,9 @@ compile_parsed_data(#pdata{mib_name = MibName, Deprecated = get_deprecated(Opts), RelChk = get_relaxed_row_name_assign_check(Opts), Data = #dldata{deprecated = Deprecated, - relaxed_row_name_assign_check = RelChk}, + relaxed_row_name_assign_check = RelChk}, + mc_new_type_loop(Definitions), + put(augmentations, false), definitions_loop(Definitions, Data), MibName. @@ -480,7 +482,40 @@ do_update_imports([{{Mib, ImportsFromMib0},_Line}|Imports], Acc) -> update_status(Name, Status) -> #cdata{status_ets = Ets} = get(cdata), ets:insert(Ets, {Name, Status}). - + + +mc_new_type_loop( + [{#mc_new_type{ + name = NewTypeName, + macro = Macro, + syntax = OldType, + display_hint = DisplayHint},Line}|T]) -> + ?vlog2("typeloop -> new_type:" + "~n Macro: ~p" + "~n NewTypeName: ~p" + "~n OldType: ~p" + "~n DisplayHint: ~p", + [Macro, NewTypeName, OldType, DisplayHint], Line), + ensure_macro_imported(Macro,Line), + Types = (get(cdata))#cdata.asn1_types, + case lists:keysearch(NewTypeName, #asn1_type.aliasname, Types) of + {value,_} -> + snmpc_lib:print_error("Type ~w already defined.", + [NewTypeName],Line); + false -> + %% NameOfOldType = element(2,OldType), + ASN1 = snmpc_lib:make_ASN1type(OldType), + snmpc_lib:add_cdata(#cdata.asn1_types, + [ASN1#asn1_type{aliasname = NewTypeName, + imported = false, + display_hint = DisplayHint}]) + end, + mc_new_type_loop(T); +mc_new_type_loop([_|T]) -> + mc_new_type_loop(T); +mc_new_type_loop([]) -> + ok. + %% A deprecated object definitions_loop([{#mc_object_type{name = ObjName, status = deprecated}, @@ -744,32 +779,8 @@ definitions_loop([{#mc_object_type{name = NameOfTable, ColMEs]), definitions_loop(RestObjs, Data); -definitions_loop([{#mc_new_type{name = NewTypeName, - macro = Macro, - syntax = OldType, - display_hint = DisplayHint},Line}|T], - Data) -> - ?vlog2("defloop -> new_type:" - "~n Macro: ~p" - "~n NewTypeName: ~p" - "~n OldType: ~p" - "~n DisplayHint: ~p", - [Macro, NewTypeName, OldType, DisplayHint], Line), - ensure_macro_imported(Macro,Line), - Types = (get(cdata))#cdata.asn1_types, - case lists:keysearch(NewTypeName, #asn1_type.aliasname, Types) of - {value,_} -> - snmpc_lib:print_error("Type ~w already defined.", - [NewTypeName],Line); - false -> - %% NameOfOldType = element(2,OldType), - ASN1 = snmpc_lib:make_ASN1type(OldType), - snmpc_lib:add_cdata(#cdata.asn1_types, - [ASN1#asn1_type{aliasname = NewTypeName, - imported = false, - display_hint = DisplayHint}]) - end, - definitions_loop(T, Data); +definitions_loop([{#mc_new_type{},_}|T], Data) -> + definitions_loop(T, Data); %% Plain variable definitions_loop([{#mc_object_type{name = NewVarName, @@ -1211,7 +1222,39 @@ definitions_loop([{Obj,Line}|T], Data) -> definitions_loop([], _Data) -> ?vlog("defloop -> done", []), - ok. + case get(augmentations) of + true -> + CData = get(cdata), + put(cdata, CData#cdata{mes = augmentations(CData#cdata.mes)}), + ok; + false -> + ok + end. + +augmentations( + [#me{ + aliasname = AliasName, + assocList = + [{table_info, + #table_info{ + index_types = + {augments, SrcTableEntry, Line}} = TableInfo}|Ref]} = Me + |Mes]) -> + ?vlog("augmentations(~w) ->" + "~n NameOfTable: ~p" + "~n IndexingInfo: ~p" + "~n Sline: ~p", + [?LINE, AliasName, {augments, SrcTableEntry}, Line]), + NewTableInfo = snmpc_lib:fix_table_info_augmentation(TableInfo), + [Me#me{assocList = [{table_info,NewTableInfo}|Ref]} + |augmentations(Mes)]; +augmentations([Me | Mes]) -> + [Me|augmentations(Mes)]; +augmentations([]) -> + ?vlog("augmentations -> done", []), + []. + + safe_elem(N,T) -> case catch(element(N,T)) of diff --git a/lib/snmp/src/compile/snmpc_lib.erl b/lib/snmp/src/compile/snmpc_lib.erl index 33ddd78308..19a6bc8851 100644 --- a/lib/snmp/src/compile/snmpc_lib.erl +++ b/lib/snmp/src/compile/snmpc_lib.erl @@ -26,7 +26,7 @@ -export([test_father/4, make_ASN1type/1, import/1, makeInternalNode2/2, is_consistent/1, resolve_defval/1, make_variable_info/1, check_trap_name/3, make_table_info/5, get_final_mib/2, set_dir/2, - look_at/1, add_cdata/2, + fix_table_info_augmentation/1, look_at/1, add_cdata/2, check_object_group/4, check_notification_group/4, check_notification/3, register_oid/4, @@ -710,25 +710,34 @@ check_trap_name(EnterpriseName, Line, MEs) -> %% functions for tables. %%---------------------------------------------------------------------- +fix_table_info_augmentation( + #table_info{index_types = {augments, SrcTableEntry, Line}} = TableInfo) -> + MEs = (get(cdata))#cdata.mes, + Aug = + case lookup(SrcTableEntry, MEs) of + false -> + print_error( + "Cannot AUGMENT the non-existing table entry ~p", + [SrcTableEntry], Line), + {augments, error}; + {value, ME} -> + {augments, + {SrcTableEntry, translate_type(ME#me.asn1_type)}} + end, + TableInfo#table_info{index_types = Aug}. + + make_table_info(Line, TableName, {augments, SrcTableEntry}, _, ColumnMEs) -> ColMEs = lists:keysort(#me.oid, ColumnMEs), - Nbr_of_Cols = length(ColMEs), - MEs = ColMEs ++ (get(cdata))#cdata.mes, - Aug = case lookup(SrcTableEntry, MEs) of - false -> - print_error("Cannot AUGMENT the non-existing table entry ~p", - [SrcTableEntry], Line), - {augments, error}; - {value, ME} -> - {augments, {SrcTableEntry, translate_type(ME#me.asn1_type)}} - end, - FirstNonIdxCol = augments_first_non_index_column(ColMEs), + Nbr_of_Cols = length(ColMEs), + put(augmentations, true), + FirstNonIdxCol = augments_first_non_index_column(ColMEs), NoAccs = list_not_accessible(FirstNonIdxCol, ColMEs), FirstAcc = first_accessible(TableName, ColMEs), #table_info{nbr_of_cols = Nbr_of_Cols, - first_accessible = FirstAcc, - not_accessible = NoAccs, - index_types = Aug}; + first_accessible = FirstAcc, + not_accessible = NoAccs, + index_types = {augments, SrcTableEntry, Line}}; make_table_info(Line, TableName, {indexes, []}, _, _ColumnMEs) -> print_error("Table ~w lacks indexes.", [TableName],Line), #table_info{}; diff --git a/lib/snmp/src/manager/snmpm_net_if.erl b/lib/snmp/src/manager/snmpm_net_if.erl index 93c987eb0f..29216f9d6a 100644 --- a/lib/snmp/src/manager/snmpm_net_if.erl +++ b/lib/snmp/src/manager/snmpm_net_if.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2004-2015. All Rights Reserved. +%% Copyright Ericsson AB 2004-2017. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -367,7 +367,7 @@ common_socket_opts(Opts) -> default -> []; Sz -> - [{sndbuf, Sz}] + [{recbuf, Sz}] end ++ case get_opt(Opts, no_reuse, false) of false -> |