From bd7410308177659ad15c770d6d4700219bbe6978 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 30 Nov 2010 18:36:39 +0100 Subject: First version. No documentation and no testing. --- lib/snmp/src/compile/snmpc.erl | 6 ++++++ lib/snmp/src/compile/snmpc.hrl | 15 ++++++++++++++- lib/snmp/src/compile/snmpc_mib_gram.yrl | 25 ++++++++++++++++++++++++- lib/snmp/vsn.mk | 21 ++++++++++++++++++++- 4 files changed, 64 insertions(+), 3 deletions(-) (limited to 'lib/snmp') diff --git a/lib/snmp/src/compile/snmpc.erl b/lib/snmp/src/compile/snmpc.erl index a7f2cdc2bc..0f90d541e8 100644 --- a/lib/snmp/src/compile/snmpc.erl +++ b/lib/snmp/src/compile/snmpc.erl @@ -921,6 +921,12 @@ definitions_loop([{#mc_notification{name = TrapName, snmpc_lib:add_cdata(#cdata.traps, [Notif]), definitions_loop(T, Data); +definitions_loop([{#mc_agent_capabilities{name = Name},Line}|T], Data) -> + ?vlog2("defloop -> agent_capabilities:" + "~n Name: ~p", [Name], Line), + ensure_macro_imported('AGENT-CAPABILITIES', Line), + definitions_loop(T, Data); + definitions_loop([{#mc_module_compliance{name = Name},Line}|T], Data) -> ?vlog2("defloop -> module_compliance:" "~n Name: ~p", [Name], Line), diff --git a/lib/snmp/src/compile/snmpc.hrl b/lib/snmp/src/compile/snmpc.hrl index eb896cde6b..5dd8d9a139 100644 --- a/lib/snmp/src/compile/snmpc.hrl +++ b/lib/snmp/src/compile/snmpc.hrl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. +%% Copyright Ericsson AB 1997-2010. 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 @@ -103,6 +103,19 @@ ). +-record(mc_agent_capabilities, + {name, + product_release, + status, + description, + reference, + module, + name_assign + } + ). + + + -record(mc_module_compliance, {name, status, diff --git a/lib/snmp/src/compile/snmpc_mib_gram.yrl b/lib/snmp/src/compile/snmpc_mib_gram.yrl index 1957f52936..3536b538df 100644 --- a/lib/snmp/src/compile/snmpc_mib_gram.yrl +++ b/lib/snmp/src/compile/snmpc_mib_gram.yrl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. +%% Copyright Ericsson AB 1996-2010. 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 @@ -59,6 +59,7 @@ newtypename objectidentifier objectname objecttypev1 +prodrelpart range_num referpart size @@ -101,6 +102,7 @@ textualconvention objectgroup notificationgroup modulecompliance +agentcapabilities modulepart modules module @@ -161,6 +163,8 @@ integer variable atom string quote '{' '}' '::=' ':' '=' ',' '.' '(' ')' ';' '|' 'CONTACT-INFO' 'MODULE-IDENTITY' 'NOTIFICATION-TYPE' +'PRODUCT-RELEASE' +'AGENT-CAPABILITIES' 'MODULE-COMPLIANCE' 'OBJECT-GROUP' 'NOTIFICATION-GROUP' @@ -505,6 +509,7 @@ definitionv2 -> notification : '$1'. definitionv2 -> objectgroup : '$1'. definitionv2 -> notificationgroup : '$1'. definitionv2 -> modulecompliance : '$1'. +definitionv2 -> agentcapabilities : '$1'. listofdefinitionsv2 -> '$empty' : [] . listofdefinitionsv2 -> listofdefinitionsv2 definitionv2 : ['$2' | '$1']. @@ -540,6 +545,15 @@ modulecompliance -> objectname 'MODULE-COMPLIANCE' 'STATUS' statusv2 '$7', '$8'), {MC, line_of('$2')}. +agentcapabilities -> objectname 'AGENT-CAPABILITIES' + 'PRODUCT-RELEASE' prodrelpart 'STATUS' statusv2 + description referpart modulepart nameassign : + MC = make_agent_capabilities('$1', '$4', '$6', '$7', + '$8', '$9', '$10'), + {MC, line_of('$2')}. + +prodrelpart -> string : $1. + modulepart -> '$empty'. modulepart -> modules. @@ -744,6 +758,15 @@ make_notification(Name, Vars, Status, Desc, Ref, NA) -> reference = Ref, name_assign = NA}. +make_agent_capabilities(Name, ProdRel, Status, Desc, Ref, Mod, NA) -> + #mc_agent_capabilities{name = Name, + product_release = ProdRel, + status = Status, + description = Desc, + reference = Ref, + module = Mod, + name_assign = NA}. + make_module_compliance(Name, Status, Desc, Ref, Mod, NA) -> #mc_module_compliance{name = Name, status = Status, diff --git a/lib/snmp/vsn.mk b/lib/snmp/vsn.mk index 1229b12ae2..12a9d8ed3c 100644 --- a/lib/snmp/vsn.mk +++ b/lib/snmp/vsn.mk @@ -1,3 +1,22 @@ -SNMP_VSN = 4.18 +#-*-makefile-*- ; force emacs to enter makefile-mode + +# %CopyrightBegin% +# +# Copyright Ericsson AB 1997-2010. 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 +# compliance with the License. You should have received a copy of the +# Erlang Public License along with this software. If not, it can be +# retrieved online at http://www.erlang.org/. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +# the License for the specific language governing rights and limitations +# under the License. +# +# %CopyrightEnd% + +SNMP_VSN = 4.19 PRE_VSN = APP_VSN = "snmp-$(SNMP_VSN)$(PRE_VSN)" -- cgit v1.2.3 From 5210341783f4c3ca9611c7ea5e630fde4d067f10 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 2 Dec 2010 21:02:12 +0100 Subject: Really time to go home checkin. --- lib/snmp/src/compile/snmpc.erl | 50 +++++++++- lib/snmp/src/compile/snmpc.hrl | 19 +++- lib/snmp/src/compile/snmpc_lib.erl | 5 +- lib/snmp/src/compile/snmpc_mib_gram.yrl | 131 +++++++++++++++++++++++++-- lib/snmp/src/compile/snmpc_tok.erl | 9 +- lib/snmp/test/modules.mk | 1 + lib/snmp/test/snmp_compiler_test.erl | 15 +++ lib/snmp/test/snmp_test_data/AC-TEST-MIB.mib | 131 +++++++++++++++++++++++++++ 8 files changed, 344 insertions(+), 17 deletions(-) create mode 100644 lib/snmp/test/snmp_test_data/AC-TEST-MIB.mib (limited to 'lib/snmp') diff --git a/lib/snmp/src/compile/snmpc.erl b/lib/snmp/src/compile/snmpc.erl index 0f90d541e8..84c9c46fc9 100644 --- a/lib/snmp/src/compile/snmpc.erl +++ b/lib/snmp/src/compile/snmpc.erl @@ -921,10 +921,42 @@ definitions_loop([{#mc_notification{name = TrapName, snmpc_lib:add_cdata(#cdata.traps, [Notif]), definitions_loop(T, Data); -definitions_loop([{#mc_agent_capabilities{name = Name},Line}|T], Data) -> - ?vlog2("defloop -> agent_capabilities:" - "~n Name: ~p", [Name], Line), +definitions_loop([{#mc_agent_capabilities{name = Name, + status = Status, + description = Desc, + reference = Ref, + modules = Mods, + name_assign = {Parent, SubIdx}},Line}|T], Data) -> + ?vlog2("defloop -> agent_capabilities ~p:" + "~n Status: ~p" + "~n Desc: ~p" + "~n Parent: ~p" + "~n SubIndex: ~p", + [Name, Status, Desc, Parent, SubIdx], Line), ensure_macro_imported('AGENT-CAPABILITIES', Line), + snmpc_lib:register_oid(Line, Name, Parent, SubIdx), + NewME = snmpc_lib:makeInternalNode2(false, Name), + Description = make_description(Desc), + Reference = + case Ref of + undefined -> + []; + _ -> + [{reference, Ref}] + end, + Modules = + case Mods of + undefined -> + []; + [] -> + []; + _ -> + [{modules, Mods}] + end, + AssocList = Reference ++ Modules, + NewME2 = NewME#me{description = Description, + assocList = AssocList}, + snmpc_lib:add_cdata(#cdata.mes, [NewME2]), definitions_loop(T, Data); definitions_loop([{#mc_module_compliance{name = Name},Line}|T], Data) -> @@ -1334,22 +1366,26 @@ save(Filename, MibName, Options) -> parse(FileName) -> + ?vtrace("parse -> start tokenizer for ~p", [FileName]), case snmpc_tok:start_link(reserved_words(), [{file, FileName ++ ".mib"}, {forget_stringdata, true}]) of {error,ReasonStr} -> snmpc_lib:error(lists:flatten(ReasonStr),[]); {ok, TokPid} -> + ?vtrace("parse -> tokenizer start, now get tokens", []), Toks = snmpc_tok:get_all_tokens(TokPid), + ?vtrace("parse -> tokens: ~p", [Toks]), set_version(Toks), %% io:format("parse -> lexical analysis: ~n~p~n", [Toks]), - %% t("parse -> lexical analysis: ~n~p", [Toks]), + %% ?vtrace("parse -> lexical analysis: ~n~p", [Toks]), CDataArg = case lists:keysearch(module, 1, get(options)) of {value, {module, M}} -> {module, M}; _ -> {file, FileName ++ ".funcs"} end, put(cdata,snmpc_lib:make_cdata(CDataArg)), + ?vtrace("parse -> stop tokenizer and then do the actual parse", []), snmpc_tok:stop(TokPid), Res = if is_list(Toks) -> @@ -1357,7 +1393,7 @@ parse(FileName) -> true -> Toks end, - %% t("parse -> parsed: ~n~p", [Res]), + ?vtrace("parse -> parsed result: ~n~p", [Res]), case Res of {ok, PData} -> {ok, PData}; @@ -1449,6 +1485,10 @@ reserved_words() -> 'NOTIFICATION-GROUP', 'NOTIFICATIONS', 'MODULE-COMPLIANCE', + 'AGENT-CAPABILITIES', + 'PRODUCT-RELEASE', + 'SUPPORTS', + 'INCLUDES', 'MODULE', 'MANDATORY-GROUPS', 'GROUP', diff --git a/lib/snmp/src/compile/snmpc.hrl b/lib/snmp/src/compile/snmpc.hrl index 5dd8d9a139..254ede51af 100644 --- a/lib/snmp/src/compile/snmpc.hrl +++ b/lib/snmp/src/compile/snmpc.hrl @@ -109,11 +109,28 @@ status, description, reference, - module, + modules, name_assign } ). +-record(mc_ac_object_variation, + {name, + syntax, + write_syntax, + access, + creation, + default_value, + description + } + ). + +-record(mc_ac_notification_variation, + {name, + access, + description + } + ). -record(mc_module_compliance, diff --git a/lib/snmp/src/compile/snmpc_lib.erl b/lib/snmp/src/compile/snmpc_lib.erl index 4490412e84..4f71c47bfa 100644 --- a/lib/snmp/src/compile/snmpc_lib.erl +++ b/lib/snmp/src/compile/snmpc_lib.erl @@ -306,7 +306,10 @@ import_mib({{'SNMPv2-TC', ImportsFromMib},Line}) -> Macros = ['TEXTUAL-CONVENTION'], import_built_in_loop(ImportsFromMib,Nodes,Types,Macros,'SNMPv2-TC',Line); import_mib({{'SNMPv2-CONF', ImportsFromMib},Line}) -> - Macros = ['OBJECT-GROUP','NOTIFICATION-GROUP','MODULE-COMPLIANCE'], + Macros = ['OBJECT-GROUP', + 'NOTIFICATION-GROUP', + 'MODULE-COMPLIANCE', + 'AGENT-CAPABILITIES'], import_built_in_loop(ImportsFromMib,[],[],Macros,'SNMPv2-CONF',Line); import_mib({{'RFC1155-SMI', ImportsFromMib},Line}) -> Nodes = [makeInternalNode(internet, [1,3,6,1]), diff --git a/lib/snmp/src/compile/snmpc_mib_gram.yrl b/lib/snmp/src/compile/snmpc_mib_gram.yrl index 3536b538df..7af27ba816 100644 --- a/lib/snmp/src/compile/snmpc_mib_gram.yrl +++ b/lib/snmp/src/compile/snmpc_mib_gram.yrl @@ -59,7 +59,7 @@ newtypename objectidentifier objectname objecttypev1 -prodrelpart +prodrel range_num referpart size @@ -103,6 +103,17 @@ objectgroup notificationgroup modulecompliance agentcapabilities +ac_status +ac_modulepart +ac_modules +ac_module +ac_modulenamepart +ac_variationpart +ac_variations +ac_variation +ac_accesspart +ac_access +ac_creationpart modulepart modules module @@ -165,6 +176,10 @@ integer variable atom string quote '{' '}' '::=' ':' '=' ',' '.' '(' ')' ';' '|' 'NOTIFICATION-TYPE' 'PRODUCT-RELEASE' 'AGENT-CAPABILITIES' +'INCLUDES' +'SUPPORTS' +'VARIATION' +'CREATION-REQUIRES' 'MODULE-COMPLIANCE' 'OBJECT-GROUP' 'NOTIFICATION-GROUP' @@ -255,6 +270,8 @@ import_stuff -> 'MODULE-IDENTITY' : ensure_ver(2,'$1'), {builtin, 'MODULE-IDENTITY'}. import_stuff -> 'NOTIFICATION-TYPE' : ensure_ver(2,'$1'), {builtin, 'NOTIFICATION-TYPE'}. +import_stuff -> 'AGENT-CAPABILITIES' + : ensure_ver(2,'$1'), {builtin, 'AGENT-CAPABILITIES'}. import_stuff -> 'MODULE-COMPLIANCE' : ensure_ver(2,'$1'), {builtin, 'MODULE-COMPLIANCE'}. import_stuff -> 'NOTIFICATION-GROUP' @@ -545,14 +562,56 @@ modulecompliance -> objectname 'MODULE-COMPLIANCE' 'STATUS' statusv2 '$7', '$8'), {MC, line_of('$2')}. + agentcapabilities -> objectname 'AGENT-CAPABILITIES' - 'PRODUCT-RELEASE' prodrelpart 'STATUS' statusv2 - description referpart modulepart nameassign : - MC = make_agent_capabilities('$1', '$4', '$6', '$7', - '$8', '$9', '$10'), - {MC, line_of('$2')}. + 'PRODUCT-RELEASE' prodrel + 'STATUS' ac_status + description referpart ac_modulepart nameassign : + AC = make_agent_capabilities('$1', '$4', '$6', '$7', + '$8', '$9', '$10'), + {AC, line_of('$2')}. + +prodrel -> string : lists:reverse(val('$1')). + +ac_status -> atom : ac_status('$1'). + +ac_modulepart -> ac_modules : lists:reverse('$1'). +ac_modulepart -> '$empty' : []. + +ac_modules -> ac_module : ['$1']. +ac_modules -> ac_modules ac_module : ['$2' | '$1']. + +ac_module -> 'SUPPORTS' ac_modulenamepart 'INCLUDES' '{' objects '}' ac_variationpart : + {'$2', '$5', '$7'}. + +ac_modulenamepart -> mibname : '$1'. +ac_modulenamepart -> '$empty' : undefined. + +ac_variationpart -> '$empty' : []. +ac_variationpart -> ac_variations : lists:reverse('$1'). + +ac_variations -> ac_variation : ['$1']. +ac_variations -> ac_variations ac_variation : ['$2' | '$1']. + +%% ac_variation -> ac_objectvariation. +%% ac_variation -> ac_notificationvariation. + +ac_variation -> 'VARIATION' objectname syntaxpart writesyntaxpart ac_accesspart ac_creationpart defvalpart description : + make_ac_variation('$2', '$3', '$4', '$5', '$6', '$7', '$8'). + +%% ac_objectvariation -> 'VARIATION' objectname syntaxpart writesyntaxpart ac_accesspart ac_creationpart ac_defvalpart description : +%% make_ac_object_variation('$2', '$3', '$4', '$5', '$6', '$7', '$8'). + +%% ac_notificationvariation -> 'VARIATION' objectname ac_accesspart description : +%% make_ac_notification_variation('$2', '$3', '$4'). + +ac_accesspart -> 'ACCESS' ac_access : '$2'. +ac_accesspart -> '$empty' : undefined. + +ac_access -> atom: ac_access('$1'). -prodrelpart -> string : $1. +ac_creationpart -> 'CREATION-REQUIRES' '{' objects '}' : lists:reverse('$3'). +ac_creationpart -> '$empty' : []. modulepart -> '$empty'. modulepart -> modules. @@ -669,6 +728,14 @@ statusv2(Tok) -> "syntax error before: " ++ atom_to_list(Else)) end. +ac_status(Tok) -> + case val(Tok) of + current -> current; + obsolete -> obsolete; + Else -> return_error(line_of(Tok), + "syntax error before: " ++ atom_to_list(Else)) + end. + accessv1(Tok) -> case val(Tok) of 'read-only' -> 'read-only'; @@ -690,6 +757,18 @@ accessv2(Tok) -> "syntax error before: " ++ atom_to_list(Else)) end. +ac_access(Tok) -> + case val(Tok) of + 'not-implemented' -> 'not-implemented'; % only for notifications + 'accessible-for-notify' -> 'accessible-for-notify'; + 'read-only' -> 'read-only'; + 'read-write' -> 'read-write'; + 'read-create' -> 'read-create'; + 'write-only' -> 'write-only'; % for backward-compatibility only + Else -> return_error(line_of(Tok), + "syntax error before: " ++ atom_to_list(Else)) + end. + %% --------------------------------------------------------------------- %% Various basic record build functions %% --------------------------------------------------------------------- @@ -758,15 +837,49 @@ make_notification(Name, Vars, Status, Desc, Ref, NA) -> reference = Ref, name_assign = NA}. -make_agent_capabilities(Name, ProdRel, Status, Desc, Ref, Mod, NA) -> +make_agent_capabilities(Name, ProdRel, Status, Desc, Ref, Mods, NA) -> #mc_agent_capabilities{name = Name, product_release = ProdRel, status = Status, description = Desc, reference = Ref, - module = Mod, + modules = Mods, name_assign = NA}. +make_ac_variation(Name, + undefined = _Syntax, + undefined = _WriteSyntax, + Access, + undefined = _Creation, + undefined = _DefVal, + Desc) -> +%% io:format("make_ac_variation -> entry with" +%% "~n Name: ~p" +%% "~n Access: ~p" +%% "~n Desc: ~p" +%% "~n", [Name, Access, Desc]), + #mc_ac_notification_variation{name = Name, + access = Access, + description = Desc}; + +make_ac_variation(Name, Syntax, WriteSyntax, Access, Creation, DefVal, Desc) -> +%% io:format("make_ac_variation -> entry with" +%% "~n Name: ~p" +%% "~n Syntax: ~p" +%% "~n WriteSyntax: ~p" +%% "~n Access: ~p" +%% "~n Creation: ~p" +%% "~n DefVal: ~p" +%% "~n Desc: ~p" +%% "~n", [Name, Syntax, WriteSyntax, Access, Creation, DefVal, Desc]), + #mc_ac_object_variation{name = Name, + syntax = Syntax, + write_syntax = WriteSyntax, + access = Access, + creation = Creation, + default_value = DefVal, + description = Desc}. + make_module_compliance(Name, Status, Desc, Ref, Mod, NA) -> #mc_module_compliance{name = Name, status = Status, diff --git a/lib/snmp/src/compile/snmpc_tok.erl b/lib/snmp/src/compile/snmpc_tok.erl index 6b99e7ae43..e238b256d0 100644 --- a/lib/snmp/src/compile/snmpc_tok.erl +++ b/lib/snmp/src/compile/snmpc_tok.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. +%% Copyright Ericsson AB 1996-2010. 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 @@ -37,6 +37,8 @@ -export([null_get_line/0, format_error/1, terminate/2, handle_call/3, init/1, test/0]). +-include("snmpc_lib.hrl"). + %%---------------------------------------------------------------------- %% Reserved_words: list of KeyWords. Example: ['IF', 'BEGIN', ..., 'GOTO'] @@ -130,6 +132,10 @@ test() -> 'current','deprecated','not-accessible','obsolete', 'read-create','read-only','read-write', 'IMPORTS', 'FROM', 'MODULE-COMPLIANCE', + 'AGENT-CAPABILITIES', + 'PRODUCT-RELEASE', + 'SUPPORTS', + 'INCLUDES', 'DisplayString', 'PhysAddress', 'MacAddress', @@ -225,6 +231,7 @@ get_all_tokens(Str,Toks) -> case catch tokenise(Str) of {error, ErrorInfo} -> {error, ErrorInfo}; {Token, RestChars} when is_tuple(Token) -> + %% ?vtrace("get_all_tokens -> Token: ~p", [Token]), get_all_tokens(RestChars, [Token|Toks]) end. diff --git a/lib/snmp/test/modules.mk b/lib/snmp/test/modules.mk index 6a0c3e9481..b90c6af482 100644 --- a/lib/snmp/test/modules.mk +++ b/lib/snmp/test/modules.mk @@ -62,6 +62,7 @@ COMPILER_MIB_FILES = \ OTP8574-MIB MIB_FILES = \ + AC-TEST-MIB.mib \ OLD-SNMPEA-MIB.mib \ OLD-SNMPEA-MIB-v2.mib \ Klas1.mib \ diff --git a/lib/snmp/test/snmp_compiler_test.erl b/lib/snmp/test/snmp_compiler_test.erl index ad77b01362..e2925ed6ed 100644 --- a/lib/snmp/test/snmp_compiler_test.erl +++ b/lib/snmp/test/snmp_compiler_test.erl @@ -44,6 +44,7 @@ oid_conflicts/1, imports/1, module_identity/1, + agent_capabilities/1, tickets/1, otp_6150/1, @@ -96,6 +97,7 @@ all(suite) -> oid_conflicts, imports, module_identity, + agent_capabilities, tickets ]. @@ -169,6 +171,19 @@ module_identity(Config) when is_list(Config) -> ?SKIP(not_yet_implemented). +agent_capabilities(suite) -> + []; +agent_capabilities(Config) when is_list(Config) -> + put(tname,agent_capabilities), + p("starting with Config: ~p~n", [Config]), + + Dir = ?config(comp_dir, Config), + Mib = join(Dir,"AC-TEST-MIB.mib"), + ?line {ok, Mib} = snmpc:compile(Mib, [{outdir, Dir}, {verbosity,trace}]), + io:format("agent_capabilities -> Mib: ~n~p~n", [Mib]), + ok. + + otp_6150(suite) -> []; otp_6150(Config) when is_list(Config) -> diff --git a/lib/snmp/test/snmp_test_data/AC-TEST-MIB.mib b/lib/snmp/test/snmp_test_data/AC-TEST-MIB.mib new file mode 100644 index 0000000000..58defbe1cf --- /dev/null +++ b/lib/snmp/test/snmp_test_data/AC-TEST-MIB.mib @@ -0,0 +1,131 @@ +-- +-- AC-TEST-MIB.mib +-- MIB generated by MG-SOFT Visual MIB Builder Version 5.0 Build 250 +-- Tuesday, November 30, 2010 at 23:03:18 +-- + + AC-TEST-MIB DEFINITIONS ::= BEGIN + + IMPORTS + otpExpr + FROM OTP-REG + OBJECT-GROUP, AGENT-CAPABILITIES + FROM SNMPv2-CONF + Integer32, OBJECT-TYPE, MODULE-IDENTITY, OBJECT-IDENTITY + FROM SNMPv2-SMI; + + + acTestModule MODULE-IDENTITY + LAST-UPDATED "201011302230Z" -- November 30, 2010 at 22:30 GMT + ORGANIZATION + "Ac Test Co." + CONTACT-INFO + "developer@small.company." + DESCRIPTION + "Ac Test module." + ::= { reg 1 } + + + +-- +-- Node definitions +-- + + acTest OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Test area." + ::= { otpExpr 4321 } + + + reg OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Registrations." + ::= { acTest 1 } + + + mib OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Objects." + ::= { acTest 2 } + + + someObject OBJECT-TYPE + SYNTAX Integer32 + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Description." + ::= { mib 1 } + + + oneMore OBJECT-TYPE + SYNTAX Integer32 + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Description." + ::= { mib 2 } + + + grp OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Groups + ." + ::= { acTest 3 } + + + basicGrp OBJECT-GROUP + OBJECTS { someObject } + STATUS current + DESCRIPTION + "Basic set of objects." + ::= { grp 1 } + + + allObjects OBJECT-GROUP + OBJECTS { someObject, oneMore } + STATUS current + DESCRIPTION + "Complete set." + ::= { grp 2 } + + + cap OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Capabilities." + ::= { acTest 5 } + + + basicAgent AGENT-CAPABILITIES + PRODUCT-RELEASE + "Product release v1." + STATUS current + DESCRIPTION + "Basic agent." + SUPPORTS AC-TEST-MIB + INCLUDES { basicGrp } + ::= { cap 1 } + + + fullAgent AGENT-CAPABILITIES + PRODUCT-RELEASE + "Product release v2." + STATUS current + DESCRIPTION + "Full featured agent." + SUPPORTS AC-TEST-MIB + INCLUDES { allObjects } + ::= { cap 2 } + + + + END + +-- +-- AC-TEST-MIB.mib +-- -- cgit v1.2.3 From 66dc042ce9a0e888cfdb8f1b0f5a2e9d4d046f9e Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 3 Dec 2010 14:44:12 +0100 Subject: Changed compiler version (to 3.2). --- lib/snmp/include/snmp_types.hrl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/snmp') diff --git a/lib/snmp/include/snmp_types.hrl b/lib/snmp/include/snmp_types.hrl index 1fd6d153c9..4adb24361c 100644 --- a/lib/snmp/include/snmp_types.hrl +++ b/lib/snmp/include/snmp_types.hrl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. +%% Copyright Ericsson AB 1996-2010. 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 @@ -192,7 +192,7 @@ %%---------------------------------------------------------------------- -record(mib, {misc = [], - mib_format_version = "3.1", + mib_format_version = "3.2", name = "", module_identity, %% Not in SMIv1, and only with +module_identity mes = [], -- cgit v1.2.3 From 314e80f58bbee2924bf61bdc7b987750d58ca2ef Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 3 Dec 2010 16:13:18 +0100 Subject: Typed more of the info. Also added more of it in the compiled mib. Also prepared for future module_compilance addition. --- lib/snmp/src/compile/snmpc.erl | 12 ++--- lib/snmp/src/compile/snmpc.hrl | 20 +++++++++ lib/snmp/src/compile/snmpc_mib_gram.yrl | 79 +++++++++++++++++++-------------- lib/snmp/test/snmp_compiler_test.erl | 18 +++++--- 4 files changed, 84 insertions(+), 45 deletions(-) (limited to 'lib/snmp') diff --git a/lib/snmp/src/compile/snmpc.erl b/lib/snmp/src/compile/snmpc.erl index 84c9c46fc9..d6abf273a1 100644 --- a/lib/snmp/src/compile/snmpc.erl +++ b/lib/snmp/src/compile/snmpc.erl @@ -1366,18 +1366,17 @@ save(Filename, MibName, Options) -> parse(FileName) -> - ?vtrace("parse -> start tokenizer for ~p", [FileName]), +%% ?vtrace("parse -> start tokenizer for ~p", [FileName]), case snmpc_tok:start_link(reserved_words(), [{file, FileName ++ ".mib"}, {forget_stringdata, true}]) of {error,ReasonStr} -> snmpc_lib:error(lists:flatten(ReasonStr),[]); {ok, TokPid} -> - ?vtrace("parse -> tokenizer start, now get tokens", []), +%% ?vtrace("parse -> tokenizer start, now get tokens", []), Toks = snmpc_tok:get_all_tokens(TokPid), - ?vtrace("parse -> tokens: ~p", [Toks]), +%% ?vtrace("parse -> tokens: ~p", [Toks]), set_version(Toks), - %% io:format("parse -> lexical analysis: ~n~p~n", [Toks]), %% ?vtrace("parse -> lexical analysis: ~n~p", [Toks]), CDataArg = case lists:keysearch(module, 1, get(options)) of @@ -1385,7 +1384,8 @@ parse(FileName) -> _ -> {file, FileName ++ ".funcs"} end, put(cdata,snmpc_lib:make_cdata(CDataArg)), - ?vtrace("parse -> stop tokenizer and then do the actual parse", []), +%% ?vtrace("parse -> stop tokenizer and then do the actual parse", +%% []), snmpc_tok:stop(TokPid), Res = if is_list(Toks) -> @@ -1393,7 +1393,7 @@ parse(FileName) -> true -> Toks end, - ?vtrace("parse -> parsed result: ~n~p", [Res]), +%% ?vtrace("parse -> parsed result: ~n~p", [Res]), case Res of {ok, PData} -> {ok, PData}; diff --git a/lib/snmp/src/compile/snmpc.hrl b/lib/snmp/src/compile/snmpc.hrl index 254ede51af..76508486fd 100644 --- a/lib/snmp/src/compile/snmpc.hrl +++ b/lib/snmp/src/compile/snmpc.hrl @@ -132,6 +132,13 @@ } ). +-record(mc_ac_module, + {name, + groups, + variation + } + ). + -record(mc_module_compliance, {name, @@ -143,6 +150,19 @@ } ). +-record(mc_mc_compliance_group, + {name, + description + } + ). + +-record(mc_mc_module, + {name, + mandatory, + compliance + } + ). + -record(mc_object_group, {name, diff --git a/lib/snmp/src/compile/snmpc_mib_gram.yrl b/lib/snmp/src/compile/snmpc_mib_gram.yrl index 7af27ba816..5b91cb5d01 100644 --- a/lib/snmp/src/compile/snmpc_mib_gram.yrl +++ b/lib/snmp/src/compile/snmpc_mib_gram.yrl @@ -114,15 +114,15 @@ ac_variation ac_accesspart ac_access ac_creationpart -modulepart -modules -module -modulenamepart -mandatorypart -compliancepart -compliances -compliance -compliancegroup +mc_modulepart +mc_modules +mc_module +mc_modulenamepart +mc_mandatorypart +mc_compliancepart +mc_compliances +mc_compliance +mc_compliancegroup object syntaxpart writesyntaxpart @@ -557,7 +557,7 @@ notificationgroup -> objectname 'NOTIFICATION-GROUP' 'NOTIFICATIONS' '{' {NG, line_of('$2')}. modulecompliance -> objectname 'MODULE-COMPLIANCE' 'STATUS' statusv2 - description referpart modulepart nameassign : + description referpart mc_modulepart nameassign : MC = make_module_compliance('$1', '$4', '$5', '$6', '$7', '$8'), {MC, line_of('$2')}. @@ -582,7 +582,7 @@ ac_modules -> ac_module : ['$1']. ac_modules -> ac_modules ac_module : ['$2' | '$1']. ac_module -> 'SUPPORTS' ac_modulenamepart 'INCLUDES' '{' objects '}' ac_variationpart : - {'$2', '$5', '$7'}. + make_ac_module('$2', '$5', '$7'). ac_modulenamepart -> mibname : '$1'. ac_modulenamepart -> '$empty' : undefined. @@ -599,44 +599,40 @@ ac_variations -> ac_variations ac_variation : ['$2' | '$1']. ac_variation -> 'VARIATION' objectname syntaxpart writesyntaxpart ac_accesspart ac_creationpart defvalpart description : make_ac_variation('$2', '$3', '$4', '$5', '$6', '$7', '$8'). -%% ac_objectvariation -> 'VARIATION' objectname syntaxpart writesyntaxpart ac_accesspart ac_creationpart ac_defvalpart description : -%% make_ac_object_variation('$2', '$3', '$4', '$5', '$6', '$7', '$8'). - -%% ac_notificationvariation -> 'VARIATION' objectname ac_accesspart description : -%% make_ac_notification_variation('$2', '$3', '$4'). - ac_accesspart -> 'ACCESS' ac_access : '$2'. ac_accesspart -> '$empty' : undefined. ac_access -> atom: ac_access('$1'). ac_creationpart -> 'CREATION-REQUIRES' '{' objects '}' : lists:reverse('$3'). -ac_creationpart -> '$empty' : []. +ac_creationpart -> '$empty' : []. -modulepart -> '$empty'. -modulepart -> modules. +mc_modulepart -> '$empty' : []. +mc_modulepart -> mc_modules : lists:reverse('$1'). -modules -> module. -modules -> modules module. +mc_modules -> mc_module. +mc_modules -> mc_modules mc_module. -module -> 'MODULE' modulenamepart mandatorypart compliancepart. +mc_module -> 'MODULE' mc_modulenamepart mc_mandatorypart mc_compliancepart : + make_mc_module('$2', '$3', '$4'). -modulenamepart -> mibname. -modulenamepart -> '$empty'. +mc_modulenamepart -> mibname : '$1'. +mc_modulenamepart -> '$empty' : undefined. -mandatorypart -> 'MANDATORY-GROUPS' '{' objects '}'. -mandatorypart -> '$empty'. +mc_mandatorypart -> 'MANDATORY-GROUPS' '{' objects '}' : lists:reverse('$3'). +mc_mandatorypart -> '$empty' : []. -compliancepart -> compliances. -compliancepart -> '$empty'. +mc_compliancepart -> mc_compliances. +mc_compliancepart -> '$empty'. -compliances -> compliance. -compliances -> compliances compliance. +mc_compliances -> mc_compliance. +mc_compliances -> mc_compliances mc_compliance. -compliance -> compliancegroup. -compliance -> object. +mc_compliance -> mc_compliancegroup. +mc_compliance -> object. -compliancegroup -> 'GROUP' objectname description. +mc_compliancegroup -> 'GROUP' objectname description : + make_mc_compliance_group('$2', '$3'). object -> 'OBJECT' objectname syntaxpart writesyntaxpart accesspart description. @@ -880,6 +876,12 @@ make_ac_variation(Name, Syntax, WriteSyntax, Access, Creation, DefVal, Desc) -> default_value = DefVal, description = Desc}. +make_ac_module(Name, Grps, Var) -> + #mc_ac_module{name = Name, + groups = Grps, + variation = Var}. + + make_module_compliance(Name, Status, Desc, Ref, Mod, NA) -> #mc_module_compliance{name = Name, status = Status, @@ -888,6 +890,15 @@ make_module_compliance(Name, Status, Desc, Ref, Mod, NA) -> module = Mod, name_assign = NA}. +make_mc_module(Name, Mand, Compl) -> + #mc_mc_module{name = Name, + mandatory = Mand, + compliance = Compl}. + +make_mc_compliance_group(Name, Desc) -> + #mc_mc_compliance_group{name = Name, + description = Desc}. + make_object_group(Name, Objs, Status, Desc, Ref, NA) -> #mc_object_group{name = Name, objects = Objs, diff --git a/lib/snmp/test/snmp_compiler_test.erl b/lib/snmp/test/snmp_compiler_test.erl index e2925ed6ed..09fc417af4 100644 --- a/lib/snmp/test/snmp_compiler_test.erl +++ b/lib/snmp/test/snmp_compiler_test.erl @@ -79,10 +79,10 @@ init_per_testcase(_Case, Config) when is_list(Config) -> MibDir = join(lists:reverse(["snmp_test_data"|RL])), CompDir = join(Dir, "comp_dir/"), ?line ok = file:make_dir(CompDir), - [{comp_dir, CompDir},{mib_dir, MibDir}|Config]. + [{comp_dir, CompDir}, {mib_dir, MibDir} | Config]. fin_per_testcase(_Case, Config) when is_list(Config) -> - CompDir = ?config(comp_dir, Config), + CompDir = ?config(comp_dir, Config), ?line ok = ?DEL_DIR(CompDir), lists:keydelete(comp_dir, 1, Config). @@ -177,9 +177,17 @@ agent_capabilities(Config) when is_list(Config) -> put(tname,agent_capabilities), p("starting with Config: ~p~n", [Config]), - Dir = ?config(comp_dir, Config), - Mib = join(Dir,"AC-TEST-MIB.mib"), - ?line {ok, Mib} = snmpc:compile(Mib, [{outdir, Dir}, {verbosity,trace}]), + SnmpPrivDir = code:priv_dir(snmp), + SnmpMibsDir = join(SnmpPrivDir, "mibs"), + OtpMibsPrivDir = code:priv_dir(otp_mibs), + OtpMibsMibsDir = join(OtpMibsPrivDir, "mibs"), + Dir = ?config(mib_dir, Config), + AcMib = join(Dir,"AC-TEST-MIB.mib"), + ?line {ok, Mib} = snmpc:compile(AcMib, [options, + version, + {i, [SnmpMibsDir, OtpMibsMibsDir]}, + {outdir, Dir}, + {verbosity, trace}]), io:format("agent_capabilities -> Mib: ~n~p~n", [Mib]), ok. -- cgit v1.2.3 From c5c4c480f559b805a73d31448e211235da1a2098 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 3 Dec 2010 16:40:27 +0100 Subject: The parser exports even more of the module-complience data for future use. In later stages, the compiler curently dropps this info. --- lib/snmp/src/compile/snmpc.erl | 7 +++-- lib/snmp/src/compile/snmpc.hrl | 23 +++++++++----- lib/snmp/src/compile/snmpc_mib_gram.yrl | 56 +++++++++++++++++++-------------- 3 files changed, 52 insertions(+), 34 deletions(-) (limited to 'lib/snmp') diff --git a/lib/snmp/src/compile/snmpc.erl b/lib/snmp/src/compile/snmpc.erl index d6abf273a1..af6e39d058 100644 --- a/lib/snmp/src/compile/snmpc.erl +++ b/lib/snmp/src/compile/snmpc.erl @@ -933,18 +933,19 @@ definitions_loop([{#mc_agent_capabilities{name = Name, "~n Parent: ~p" "~n SubIndex: ~p", [Name, Status, Desc, Parent, SubIdx], Line), + update_status(Name, Status), ensure_macro_imported('AGENT-CAPABILITIES', Line), snmpc_lib:register_oid(Line, Name, Parent, SubIdx), - NewME = snmpc_lib:makeInternalNode2(false, Name), + NewME = snmpc_lib:makeInternalNode2(false, Name), Description = make_description(Desc), - Reference = + Reference = case Ref of undefined -> []; _ -> [{reference, Ref}] end, - Modules = + Modules = case Mods of undefined -> []; diff --git a/lib/snmp/src/compile/snmpc.hrl b/lib/snmp/src/compile/snmpc.hrl index 76508486fd..f349cae3f2 100644 --- a/lib/snmp/src/compile/snmpc.hrl +++ b/lib/snmp/src/compile/snmpc.hrl @@ -114,6 +114,13 @@ } ). +-record(mc_ac_module, + {name, + groups, + variation + } + ). + -record(mc_ac_object_variation, {name, syntax, @@ -132,13 +139,6 @@ } ). --record(mc_ac_module, - {name, - groups, - variation - } - ). - -record(mc_module_compliance, {name, @@ -156,6 +156,15 @@ } ). +-record(mc_mc_object, + {name, + syntax, + write_syntax, + access, + description + } + ). + -record(mc_mc_module, {name, mandatory, diff --git a/lib/snmp/src/compile/snmpc_mib_gram.yrl b/lib/snmp/src/compile/snmpc_mib_gram.yrl index 5b91cb5d01..18e9b4f1f2 100644 --- a/lib/snmp/src/compile/snmpc_mib_gram.yrl +++ b/lib/snmp/src/compile/snmpc_mib_gram.yrl @@ -102,6 +102,17 @@ textualconvention objectgroup notificationgroup modulecompliance +mc_modulepart +mc_modules +mc_module +mc_modulenamepart +mc_mandatorypart +mc_compliancepart +mc_compliances +mc_compliance +mc_compliancegroup +mc_object +mc_accesspart agentcapabilities ac_status ac_modulepart @@ -114,19 +125,8 @@ ac_variation ac_accesspart ac_access ac_creationpart -mc_modulepart -mc_modules -mc_module -mc_modulenamepart -mc_mandatorypart -mc_compliancepart -mc_compliances -mc_compliance -mc_compliancegroup -object syntaxpart writesyntaxpart -accesspart fsyntax defbitsvalue defbitsnames @@ -622,28 +622,29 @@ mc_modulenamepart -> '$empty' : undefined. mc_mandatorypart -> 'MANDATORY-GROUPS' '{' objects '}' : lists:reverse('$3'). mc_mandatorypart -> '$empty' : []. -mc_compliancepart -> mc_compliances. -mc_compliancepart -> '$empty'. +mc_compliancepart -> mc_compliances : lists:reverse('$1'). +mc_compliancepart -> '$empty' : []. -mc_compliances -> mc_compliance. -mc_compliances -> mc_compliances mc_compliance. +mc_compliances -> mc_compliance : '$1'. +mc_compliances -> mc_compliances mc_compliance : ['$2' | '$1']. -mc_compliance -> mc_compliancegroup. -mc_compliance -> object. +mc_compliance -> mc_compliancegroup : '$1'. +mc_compliance -> mc_object : '$1'. mc_compliancegroup -> 'GROUP' objectname description : make_mc_compliance_group('$2', '$3'). -object -> 'OBJECT' objectname syntaxpart writesyntaxpart accesspart description. +mc_object -> 'OBJECT' objectname syntaxpart writesyntaxpart mc_accesspart description : + make_mc_object('$2', '$3', '$4', '$5', '$6'). -syntaxpart -> 'SYNTAX' syntax. -syntaxpart -> '$empty'. +syntaxpart -> 'SYNTAX' syntax : '$2'. +syntaxpart -> '$empty' : undefined. -writesyntaxpart -> 'WRITE-SYNTAX' syntax. -writesyntaxpart -> '$empty'. +writesyntaxpart -> 'WRITE-SYNTAX' syntax : '$2'. +writesyntaxpart -> '$empty' : undefined. -accesspart -> 'MIN-ACCESS' accessv2. -accesspart -> '$empty'. +mc_accesspart -> 'MIN-ACCESS' accessv2 : '$2'. +mc_accesspart -> '$empty' : undefined. objecttypev2 -> objectname 'OBJECT-TYPE' 'SYNTAX' syntax @@ -899,6 +900,13 @@ make_mc_compliance_group(Name, Desc) -> #mc_mc_compliance_group{name = Name, description = Desc}. +make_mc_object(Name, Syntax, WriteSyntax, Access, Desc) -> + #mc_mc_object{name = Name, + syntax = Syntax, + write_syntax = WriteSyntax, + access = Access, + description = Desc}. + make_object_group(Name, Objs, Status, Desc, Ref, NA) -> #mc_object_group{name = Name, objects = Objs, -- cgit v1.2.3 From e9f9a77ddba0ed8089840e6080b18fa60e1566de Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 3 Dec 2010 17:26:39 +0100 Subject: Fixed release notes and appup file. --- lib/snmp/doc/src/notes.xml | 36 +++++++++++++++++++++++++++++------- lib/snmp/src/app/snmp.appup.src | 8 ++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) (limited to 'lib/snmp') diff --git a/lib/snmp/doc/src/notes.xml b/lib/snmp/doc/src/notes.xml index 493e7aa092..0c43be695f 100644 --- a/lib/snmp/doc/src/notes.xml +++ b/lib/snmp/doc/src/notes.xml @@ -32,23 +32,45 @@ notes.xml +
+ SNMP Development Toolkit 4.19 +

Version 4.19 supports code replacement in runtime from/to + version 4.18, 4.17.1, 4.17.

+ +
+ Improvements and new features + + +

[compiler] Added support for the textual convention + AGENT-CAPABILITIES, exported by the SNMPv2-CONF mib.

+

The reference and modules part(s) are + stored in the assocList of the mib-entry record + (me).

+

Own Id: OTP-8966

+
+
+
+ +
+ Fixed Bugs and Malfunctions +

-

+
+ +
+
SNMP 4.18
Fixed Bugs and Malfunctions -

- When the function FilterMod:accept_recv/2 returned false - the SNMP agent stopped collecting messages from UDP.

-

- Own Id: OTP-8761

+

Cosmetic prep for R14B (plain) release.

-
+ -
+
SNMP Development Toolkit 4.17.1

Version 4.17.1 supports code replacement in runtime from/to version 4.17, 4.16.2, 4.16.1, 4.16, 4.15, 4.14 and 4.13.5.

diff --git a/lib/snmp/src/app/snmp.appup.src b/lib/snmp/src/app/snmp.appup.src index 2375e3df70..9bb4846c6e 100644 --- a/lib/snmp/src/app/snmp.appup.src +++ b/lib/snmp/src/app/snmp.appup.src @@ -22,6 +22,10 @@ %% ----- U p g r a d e ------------------------------------------------------- [ + {"4.18", + [ + ] + }, {"4.17.1", [ {load_module, snmp_community_mib, soft_purge, soft_purge, []}, @@ -66,6 +70,10 @@ %% ------D o w n g r a d e --------------------------------------------------- [ + {"4.18", + [ + ] + }, {"4.17.1", [ {load_module, snmp_community_mib, soft_purge, soft_purge, []}, -- cgit v1.2.3 From 59bb06ecfad98e38a849740fc0388668bb9a1eeb Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 18 Feb 2011 13:47:39 +0100 Subject: Fixed "some things". Also added a *lot* of debug printouts... --- lib/snmp/src/compile/snmpc_mib_gram.yrl | 153 +++++++++++++++++++++++--------- 1 file changed, 111 insertions(+), 42 deletions(-) (limited to 'lib/snmp') diff --git a/lib/snmp/src/compile/snmpc_mib_gram.yrl b/lib/snmp/src/compile/snmpc_mib_gram.yrl index 18e9b4f1f2..8be8375280 100644 --- a/lib/snmp/src/compile/snmpc_mib_gram.yrl +++ b/lib/snmp/src/compile/snmpc_mib_gram.yrl @@ -231,8 +231,8 @@ mib -> mibname 'DEFINITIONS' implies 'BEGIN' defs = Defs}. v1orv2 -> moduleidentity listofdefinitionsv2 : - {v2_mib, ['$1'|lists:reverse('$2')]}. -v1orv2 -> listofdefinitions : {v1_mib, lists:reverse('$1')}. + {v2_mib, ['$1'|lrev(v1orv2_mod, '$2')]}. +v1orv2 -> listofdefinitions : {v1_mib, lrev(v1orv2_list, '$1')}. definition -> objectidentifier : '$1'. definition -> objecttypev1 : '$1'. @@ -250,7 +250,7 @@ imports -> imports_from_one_mib : ['$1']. imports -> imports_from_one_mib imports : ['$1' | '$2']. imports_from_one_mib -> listofimports 'FROM' variable : - {{val('$3'), lists:reverse('$1')}, line_of('$2')}. + {{val('$3'), lrev(imports, '$1')}, line_of('$2')}. listofimports -> import_stuff : ['$1']. listofimports -> listofimports ',' import_stuff : ['$3' | '$1']. @@ -317,7 +317,7 @@ import_stuff -> 'TAddress' traptype -> objectname 'TRAP-TYPE' 'ENTERPRISE' objectname varpart description referpart implies integer : - Trap = make_trap('$1', '$4', lists:reverse('$5'), + Trap = make_trap('$1', '$4', lrev(trap, '$5'), '$6', '$7', val('$9')), {Trap, line_of('$2')}. @@ -345,7 +345,7 @@ newtype -> newtypename implies syntax : {NT, line_of('$2')}. tableentrydefinition -> newtypename implies 'SEQUENCE' '{' fields '}' : - Seq = make_sequence('$1', lists:reverse('$5')), + Seq = make_sequence('$1', lrev(table_entry, '$5')), {Seq, line_of('$3')}. % returns: list of {, } @@ -429,9 +429,9 @@ variables -> variables ',' objectname : ['$3' | '$1']. implies -> '::=' : '$1'. implies -> ':' ':' '=' : w("Sloppy asignment on line ~p", [line_of('$1')]), '$1'. -descriptionfield -> string : lists:reverse(val('$1')). +descriptionfield -> string : lrev(descriptionfield, val('$1')). descriptionfield -> '$empty' : undefined. -description -> 'DESCRIPTION' string : lists:reverse(val('$2')). +description -> 'DESCRIPTION' string : lrev(description, val('$2')). description -> '$empty' : undefined. displaypart -> 'DISPLAY-HINT' string : display_hint('$2') . @@ -439,7 +439,7 @@ displaypart -> '$empty' : undefined . % returns: {indexes, undefined} % | {indexes, IndexList} where IndexList is a list of aliasnames. -indexpartv1 -> 'INDEX' '{' indextypesv1 '}' : {indexes, lists:reverse('$3')}. +indexpartv1 -> 'INDEX' '{' indextypesv1 '}' : {indexes, lrev(index, '$3')}. indexpartv1 -> '$empty' : {indexes, undefined}. indextypesv1 -> indextypev1 : ['$1']. @@ -458,13 +458,13 @@ defvalpart -> 'DEFVAL' '{' integer '}' : {defval, val('$3')}. defvalpart -> 'DEFVAL' '{' atom '}' : {defval, val('$3')}. defvalpart -> 'DEFVAL' '{' '{' defbitsvalue '}' '}' : {defval, '$4'}. defvalpart -> 'DEFVAL' '{' quote atom '}' - : {defval, make_defval_for_string(line_of('$1'), lists:reverse(val('$3')), + : {defval, make_defval_for_string(line_of('$1'), lrev(defval_atom, val('$3')), val('$4'))}. defvalpart -> 'DEFVAL' '{' quote variable '}' - : {defval, make_defval_for_string(line_of('$1'), lists:reverse(val('$3')), + : {defval, make_defval_for_string(line_of('$1'), lrev(defval_variable, val('$3')), val('$4'))}. defvalpart -> 'DEFVAL' '{' string '}' - : {defval, lists:reverse(val('$3'))}. + : {defval, lrev(defval_string, val('$3'))}. defvalpart -> '$empty' : undefined. defbitsvalue -> defbitsnames : '$1'. @@ -482,7 +482,7 @@ accessv1 -> atom: accessv1('$1'). statusv1 -> atom : statusv1('$1'). -referpart -> 'REFERENCE' string : lists:reverse(val('$2')). +referpart -> 'REFERENCE' string : lrev(refer, val('$2')). referpart -> '$empty' : undefined. @@ -501,20 +501,20 @@ moduleidentity -> mibid 'MODULE-IDENTITY' {MI, line_of('$2')}. mibid -> atom : val('$1'). -last_updated -> string : lists:reverse(val('$1')) . -oranization -> string : lists:reverse(val('$1')) . -contact_info -> string : lists:reverse(val('$1')) . +last_updated -> string : lrev(last_upd, val('$1')) . +oranization -> string : lrev(org, val('$1')) . +contact_info -> string : lrev(contact, val('$1')) . revisionpart -> '$empty' : [] . -revisionpart -> revisions : lists:reverse('$1') . +revisionpart -> revisions : lrev(revision, '$1') . revisions -> revision : ['$1'] . revisions -> revisions revision : ['$2' | '$1'] . revision -> 'REVISION' revision_string 'DESCRIPTION' revision_desc : make_revision('$2', '$4') . -revision_string -> string : lists:reverse(val('$1')) . -revision_desc -> string : lists:reverse(val('$1')) . +revision_string -> string : lrev(revision_str, val('$1')) . +revision_desc -> string : lrev(revision_desc, val('$1')) . definitionv2 -> objectidentifier : '$1'. definitionv2 -> objecttypev2 : '$1'. @@ -558,8 +558,19 @@ notificationgroup -> objectname 'NOTIFICATION-GROUP' 'NOTIFICATIONS' '{' modulecompliance -> objectname 'MODULE-COMPLIANCE' 'STATUS' statusv2 description referpart mc_modulepart nameassign : + io:format("modulecompliance -> " + "~n '$1': ~p" + "~n '$4': ~p" + "~n '$5': ~p" + "~n '$6': ~p" + "~n '$7': ~p" + "~n '$8': ~p" + "~n", ['$1', '$4', '$5', '$6', '$7', '$8']), MC = make_module_compliance('$1', '$4', '$5', '$6', '$7', '$8'), + io:format("modulecompliance -> " + "~n MC: ~p" + "~n", [MC]), {MC, line_of('$2')}. @@ -571,15 +582,15 @@ agentcapabilities -> objectname 'AGENT-CAPABILITIES' '$8', '$9', '$10'), {AC, line_of('$2')}. -prodrel -> string : lists:reverse(val('$1')). +prodrel -> string : lrev(prodrel, val('$1')). ac_status -> atom : ac_status('$1'). -ac_modulepart -> ac_modules : lists:reverse('$1'). +ac_modulepart -> ac_modules : lrev(ac_module, '$1'). ac_modulepart -> '$empty' : []. -ac_modules -> ac_module : ['$1']. -ac_modules -> ac_modules ac_module : ['$2' | '$1']. +ac_modules -> ac_module : '$1'. +ac_modules -> ac_modules ac_module : ['$2' | ['$1']]. ac_module -> 'SUPPORTS' ac_modulenamepart 'INCLUDES' '{' objects '}' ac_variationpart : make_ac_module('$2', '$5', '$7'). @@ -588,10 +599,10 @@ ac_modulenamepart -> mibname : '$1'. ac_modulenamepart -> '$empty' : undefined. ac_variationpart -> '$empty' : []. -ac_variationpart -> ac_variations : lists:reverse('$1'). +ac_variationpart -> ac_variations : lrev(ac_variation, '$1'). -ac_variations -> ac_variation : ['$1']. -ac_variations -> ac_variations ac_variation : ['$2' | '$1']. +ac_variations -> ac_variation : '$1'. +ac_variations -> ac_variations ac_variation : ['$2' | ['$1']]. %% ac_variation -> ac_objectvariation. %% ac_variation -> ac_notificationvariation. @@ -604,37 +615,78 @@ ac_accesspart -> '$empty' : undefined. ac_access -> atom: ac_access('$1'). -ac_creationpart -> 'CREATION-REQUIRES' '{' objects '}' : lists:reverse('$3'). -ac_creationpart -> '$empty' : []. - -mc_modulepart -> '$empty' : []. -mc_modulepart -> mc_modules : lists:reverse('$1'). - -mc_modules -> mc_module. -mc_modules -> mc_modules mc_module. +ac_creationpart -> 'CREATION-REQUIRES' '{' objects '}' : + io:format("ac_creationpart -> $3: ~p~n", ['$3']), + lrev(ac_creation, '$3'). +ac_creationpart -> '$empty' : + []. + +mc_modulepart -> '$empty' : + io:format("mc_modulepart -> empty~n", []), []. +mc_modulepart -> mc_modules : + io:format("mc_modulepart -> $1: ~p~n", ['$1']), + lrev(mc_modulepart, '$1'). + +mc_modules -> mc_module: + io:format("mc_modules -> (module) $1: ~p~n", ['$1']), + ['$1']. +mc_modules -> mc_modules mc_module: + io:format("mc_modules -> (modules module)" + "~n $1: ~p" + "~n $2: ~p" + "~n", ['$1', '$2']), + ['$1' | ['$2']]. mc_module -> 'MODULE' mc_modulenamepart mc_mandatorypart mc_compliancepart : + io:format("mc_module -> " + "~n $2: ~p" + "~n $3: ~p" + "~n $4: ~p" + "~n", ['$2', '$3', '$4']), make_mc_module('$2', '$3', '$4'). mc_modulenamepart -> mibname : '$1'. mc_modulenamepart -> '$empty' : undefined. -mc_mandatorypart -> 'MANDATORY-GROUPS' '{' objects '}' : lists:reverse('$3'). -mc_mandatorypart -> '$empty' : []. +mc_mandatorypart -> 'MANDATORY-GROUPS' '{' objects '}' : + io:format("mc_mandatorypart -> $3: ~p~n", ['$3']), + lrev(mc_mandatorypart, '$3'). +mc_mandatorypart -> '$empty' : + io:format("mc_mandatorypart -> empty~n", []), + []. -mc_compliancepart -> mc_compliances : lists:reverse('$1'). -mc_compliancepart -> '$empty' : []. +mc_compliancepart -> mc_compliances : + io:format("mc_compliancepart -> $1: ~p~n", ['$1']), + lrev(mc_compliancepart, '$1'). +mc_compliancepart -> '$empty' : + io:format("mc_compliancepart -> empty~n", []), + []. mc_compliances -> mc_compliance : '$1'. -mc_compliances -> mc_compliances mc_compliance : ['$2' | '$1']. +mc_compliances -> mc_compliances mc_compliance : ['$2' | ['$1']]. -mc_compliance -> mc_compliancegroup : '$1'. -mc_compliance -> mc_object : '$1'. +mc_compliance -> mc_compliancegroup : + io:format("mc_compliance -> (compliancegroup) ~p~n", ['$1']), + '$1'. +mc_compliance -> mc_object : + io:format("mc_compliance -> (object) ~p~n", ['$1']), + '$1'. mc_compliancegroup -> 'GROUP' objectname description : + io:format("mc_compliancegroup -> " + "~n $2: ~p" + "~n $3: ~p" + "~n", ['$2', '$3']), make_mc_compliance_group('$2', '$3'). mc_object -> 'OBJECT' objectname syntaxpart writesyntaxpart mc_accesspart description : + io:format("mc_object -> " + "~n $2: ~p" + "~n $3: ~p" + "~n $4: ~p" + "~n $5: ~p" + "~n $6: ~p" + "~n", ['$2', '$3', '$4', '$5', '$6']), make_mc_object('$2', '$3', '$4', '$5', '$6'). syntaxpart -> 'SYNTAX' syntax : '$2'. @@ -659,7 +711,7 @@ objecttypev2 -> objectname 'OBJECT-TYPE' '$11', '$12', Kind, '$15'), {OT, line_of('$2')}. -indexpartv2 -> 'INDEX' '{' indextypesv2 '}' : {indexes, lists:reverse('$3')}. +indexpartv2 -> 'INDEX' '{' indextypesv2 '}' : {indexes, lrev(indexv2, '$3')}. indexpartv2 -> 'AUGMENTS' '{' entry '}' : {augments, '$3'}. indexpartv2 -> '$empty' : {indexes, undefined}. @@ -684,7 +736,7 @@ notification -> objectname 'NOTIFICATION-TYPE' objectspart Not = make_notification('$1','$3','$5', '$7', '$8', '$9'), {Not, line_of('$2')}. -objectspart -> 'OBJECTS' '{' objects '}' : lists:reverse('$3'). +objectspart -> 'OBJECTS' '{' objects '}' : lrev(objects, '$3'). objectspart -> '$empty' : []. objects -> objectname : ['$1']. @@ -1123,6 +1175,23 @@ filter_v2imports(_,Type) -> {type, Type}. w(F, A) -> ?vwarning(F, A). +lrev(Tag, L) when is_list(L) -> + io:format("lrev -> try reverse list ~p: " + "~n ~p" + "~n", [Tag, L]), + case (catch lists:reverse(L)) of + RevL when is_list(RevL) -> + RevL; + {'EXIT', Reason} -> + io:format("lrev -> failed reversing list: " + "~n ~p" + "~n", [Reason]), + exit({failed_reversing_list, Reason}) + end; +lrev(Tag, X) -> + exit({bad_list, Tag, X}). + + %i(F, A) -> % io:format("~w:" ++ F ++ "~n", [?MODULE|A]). -- cgit v1.2.3 From 21017ea91338cd3f14f3957869e4bba1780c39df Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 18 Feb 2011 14:28:47 +0100 Subject: Fixed mc_compliancepart rule (improper list). --- lib/snmp/src/compile/snmpc_mib_gram.yrl | 190 ++++++++++++++++---------------- 1 file changed, 96 insertions(+), 94 deletions(-) (limited to 'lib/snmp') diff --git a/lib/snmp/src/compile/snmpc_mib_gram.yrl b/lib/snmp/src/compile/snmpc_mib_gram.yrl index 8be8375280..b817b66df3 100644 --- a/lib/snmp/src/compile/snmpc_mib_gram.yrl +++ b/lib/snmp/src/compile/snmpc_mib_gram.yrl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% Copyright Ericsson AB 1996-2011. 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 @@ -80,7 +80,7 @@ revisions listofdefinitionsv2 mibid last_updated -oranization +organization contact_info revision revision_string @@ -231,8 +231,8 @@ mib -> mibname 'DEFINITIONS' implies 'BEGIN' defs = Defs}. v1orv2 -> moduleidentity listofdefinitionsv2 : - {v2_mib, ['$1'|lrev(v1orv2_mod, '$2')]}. -v1orv2 -> listofdefinitions : {v1_mib, lrev(v1orv2_list, '$1')}. + {v2_mib, ['$1'|lreverse(v1orv2_mod, '$2')]}. +v1orv2 -> listofdefinitions : {v1_mib, lreverse(v1orv2_list, '$1')}. definition -> objectidentifier : '$1'. definition -> objecttypev1 : '$1'. @@ -250,7 +250,7 @@ imports -> imports_from_one_mib : ['$1']. imports -> imports_from_one_mib imports : ['$1' | '$2']. imports_from_one_mib -> listofimports 'FROM' variable : - {{val('$3'), lrev(imports, '$1')}, line_of('$2')}. + {{val('$3'), lreverse(imports_from_one_mib, '$1')}, line_of('$2')}. listofimports -> import_stuff : ['$1']. listofimports -> listofimports ',' import_stuff : ['$3' | '$1']. @@ -317,7 +317,7 @@ import_stuff -> 'TAddress' traptype -> objectname 'TRAP-TYPE' 'ENTERPRISE' objectname varpart description referpart implies integer : - Trap = make_trap('$1', '$4', lrev(trap, '$5'), + Trap = make_trap('$1', '$4', lreverse(traptype, '$5'), '$6', '$7', val('$9')), {Trap, line_of('$2')}. @@ -345,7 +345,7 @@ newtype -> newtypename implies syntax : {NT, line_of('$2')}. tableentrydefinition -> newtypename implies 'SEQUENCE' '{' fields '}' : - Seq = make_sequence('$1', lrev(table_entry, '$5')), + Seq = make_sequence('$1', lreverse(tableentrydefinition, '$5')), {Seq, line_of('$3')}. % returns: list of {, } @@ -429,9 +429,9 @@ variables -> variables ',' objectname : ['$3' | '$1']. implies -> '::=' : '$1'. implies -> ':' ':' '=' : w("Sloppy asignment on line ~p", [line_of('$1')]), '$1'. -descriptionfield -> string : lrev(descriptionfield, val('$1')). +descriptionfield -> string : lreverse(descriptionfield, val('$1')). descriptionfield -> '$empty' : undefined. -description -> 'DESCRIPTION' string : lrev(description, val('$2')). +description -> 'DESCRIPTION' string : lreverse(description, val('$2')). description -> '$empty' : undefined. displaypart -> 'DISPLAY-HINT' string : display_hint('$2') . @@ -439,7 +439,7 @@ displaypart -> '$empty' : undefined . % returns: {indexes, undefined} % | {indexes, IndexList} where IndexList is a list of aliasnames. -indexpartv1 -> 'INDEX' '{' indextypesv1 '}' : {indexes, lrev(index, '$3')}. +indexpartv1 -> 'INDEX' '{' indextypesv1 '}' : {indexes, lreverse(indexpartv1, '$3')}. indexpartv1 -> '$empty' : {indexes, undefined}. indextypesv1 -> indextypev1 : ['$1']. @@ -457,14 +457,16 @@ parentintegers -> atom '(' integer ')' parentintegers : [val('$3') | '$5']. defvalpart -> 'DEFVAL' '{' integer '}' : {defval, val('$3')}. defvalpart -> 'DEFVAL' '{' atom '}' : {defval, val('$3')}. defvalpart -> 'DEFVAL' '{' '{' defbitsvalue '}' '}' : {defval, '$4'}. -defvalpart -> 'DEFVAL' '{' quote atom '}' - : {defval, make_defval_for_string(line_of('$1'), lrev(defval_atom, val('$3')), - val('$4'))}. -defvalpart -> 'DEFVAL' '{' quote variable '}' - : {defval, make_defval_for_string(line_of('$1'), lrev(defval_variable, val('$3')), - val('$4'))}. -defvalpart -> 'DEFVAL' '{' string '}' - : {defval, lrev(defval_string, val('$3'))}. +defvalpart -> 'DEFVAL' '{' quote atom '}' : + {defval, make_defval_for_string(line_of('$1'), + lreverse(defvalpart_quote_atom, val('$3')), + val('$4'))}. +defvalpart -> 'DEFVAL' '{' quote variable '}' : + {defval, make_defval_for_string(line_of('$1'), + lreverse(defvalpart_quote_variable, val('$3')), + val('$4'))}. +defvalpart -> 'DEFVAL' '{' string '}' : + {defval, lreverse(defvalpart_string, val('$3'))}. defvalpart -> '$empty' : undefined. defbitsvalue -> defbitsnames : '$1'. @@ -482,7 +484,7 @@ accessv1 -> atom: accessv1('$1'). statusv1 -> atom : statusv1('$1'). -referpart -> 'REFERENCE' string : lrev(refer, val('$2')). +referpart -> 'REFERENCE' string : lreverse(referpart, val('$2')). referpart -> '$empty' : undefined. @@ -492,7 +494,7 @@ referpart -> '$empty' : undefined. %%---------------------------------------------------------------------- moduleidentity -> mibid 'MODULE-IDENTITY' 'LAST-UPDATED' last_updated - 'ORGANIZATION' oranization + 'ORGANIZATION' organization 'CONTACT-INFO' contact_info 'DESCRIPTION' descriptionfield revisionpart nameassign : @@ -501,20 +503,20 @@ moduleidentity -> mibid 'MODULE-IDENTITY' {MI, line_of('$2')}. mibid -> atom : val('$1'). -last_updated -> string : lrev(last_upd, val('$1')) . -oranization -> string : lrev(org, val('$1')) . -contact_info -> string : lrev(contact, val('$1')) . +last_updated -> string : lreverse(last_updated, val('$1')) . +organization -> string : lreverse(organization, val('$1')) . +contact_info -> string : lreverse(contact_info, val('$1')) . revisionpart -> '$empty' : [] . -revisionpart -> revisions : lrev(revision, '$1') . +revisionpart -> revisions : lreverse(revisionpart, '$1') . revisions -> revision : ['$1'] . revisions -> revisions revision : ['$2' | '$1'] . revision -> 'REVISION' revision_string 'DESCRIPTION' revision_desc : make_revision('$2', '$4') . -revision_string -> string : lrev(revision_str, val('$1')) . -revision_desc -> string : lrev(revision_desc, val('$1')) . +revision_string -> string : lreverse(revision_string, val('$1')) . +revision_desc -> string : lreverse(revision_desc, val('$1')) . definitionv2 -> objectidentifier : '$1'. definitionv2 -> objecttypev2 : '$1'. @@ -558,19 +560,19 @@ notificationgroup -> objectname 'NOTIFICATION-GROUP' 'NOTIFICATIONS' '{' modulecompliance -> objectname 'MODULE-COMPLIANCE' 'STATUS' statusv2 description referpart mc_modulepart nameassign : - io:format("modulecompliance -> " - "~n '$1': ~p" - "~n '$4': ~p" - "~n '$5': ~p" - "~n '$6': ~p" - "~n '$7': ~p" - "~n '$8': ~p" - "~n", ['$1', '$4', '$5', '$6', '$7', '$8']), +%% io:format("modulecompliance -> " +%% "~n '$1': ~p" +%% "~n '$4': ~p" +%% "~n '$5': ~p" +%% "~n '$6': ~p" +%% "~n '$7': ~p" +%% "~n '$8': ~p" +%% "~n", ['$1', '$4', '$5', '$6', '$7', '$8']), MC = make_module_compliance('$1', '$4', '$5', '$6', '$7', '$8'), - io:format("modulecompliance -> " - "~n MC: ~p" - "~n", [MC]), +%% io:format("modulecompliance -> " +%% "~n MC: ~p" +%% "~n", [MC]), {MC, line_of('$2')}. @@ -582,11 +584,11 @@ agentcapabilities -> objectname 'AGENT-CAPABILITIES' '$8', '$9', '$10'), {AC, line_of('$2')}. -prodrel -> string : lrev(prodrel, val('$1')). +prodrel -> string : lreverse(prodrel, val('$1')). ac_status -> atom : ac_status('$1'). -ac_modulepart -> ac_modules : lrev(ac_module, '$1'). +ac_modulepart -> ac_modules : lreverse(ac_modulepart, '$1'). ac_modulepart -> '$empty' : []. ac_modules -> ac_module : '$1'. @@ -599,7 +601,7 @@ ac_modulenamepart -> mibname : '$1'. ac_modulenamepart -> '$empty' : undefined. ac_variationpart -> '$empty' : []. -ac_variationpart -> ac_variations : lrev(ac_variation, '$1'). +ac_variationpart -> ac_variations : lreverse(ac_variationpart, '$1'). ac_variations -> ac_variation : '$1'. ac_variations -> ac_variations ac_variation : ['$2' | ['$1']]. @@ -616,77 +618,88 @@ ac_accesspart -> '$empty' : undefined. ac_access -> atom: ac_access('$1'). ac_creationpart -> 'CREATION-REQUIRES' '{' objects '}' : - io:format("ac_creationpart -> $3: ~p~n", ['$3']), - lrev(ac_creation, '$3'). +%% io:format("ac_creationpart -> $3: ~p~n", ['$3']), + lreverse(ac_creationpart, '$3'). ac_creationpart -> '$empty' : []. mc_modulepart -> '$empty' : - io:format("mc_modulepart -> empty~n", []), []. +%% io:format("mc_modulepart -> empty~n", []), + []. mc_modulepart -> mc_modules : - io:format("mc_modulepart -> $1: ~p~n", ['$1']), - lrev(mc_modulepart, '$1'). +%% io:format("mc_modulepart -> $1: ~p~n", ['$1']), + lreverse(mc_modulepart, '$1'). mc_modules -> mc_module: - io:format("mc_modules -> (module) $1: ~p~n", ['$1']), +%% io:format("mc_modules -> (module) $1: ~p~n", ['$1']), ['$1']. mc_modules -> mc_modules mc_module: - io:format("mc_modules -> (modules module)" - "~n $1: ~p" - "~n $2: ~p" - "~n", ['$1', '$2']), +%% io:format("mc_modules -> (modules module)" +%% "~n $1: ~p" +%% "~n $2: ~p" +%% "~n", ['$1', '$2']), ['$1' | ['$2']]. mc_module -> 'MODULE' mc_modulenamepart mc_mandatorypart mc_compliancepart : - io:format("mc_module -> " - "~n $2: ~p" - "~n $3: ~p" - "~n $4: ~p" - "~n", ['$2', '$3', '$4']), +%% io:format("mc_module -> " +%% "~n $2: ~p" +%% "~n $3: ~p" +%% "~n $4: ~p" +%% "~n", ['$2', '$3', '$4']), make_mc_module('$2', '$3', '$4'). mc_modulenamepart -> mibname : '$1'. mc_modulenamepart -> '$empty' : undefined. mc_mandatorypart -> 'MANDATORY-GROUPS' '{' objects '}' : - io:format("mc_mandatorypart -> $3: ~p~n", ['$3']), - lrev(mc_mandatorypart, '$3'). +%% io:format("mc_mandatorypart -> $3: ~p~n", ['$3']), + lreverse(mc_mandatorypart, '$3'). mc_mandatorypart -> '$empty' : - io:format("mc_mandatorypart -> empty~n", []), +%% io:format("mc_mandatorypart -> empty~n", []), []. mc_compliancepart -> mc_compliances : - io:format("mc_compliancepart -> $1: ~p~n", ['$1']), - lrev(mc_compliancepart, '$1'). +%% i("mc_compliancepart -> " +%% "~n $1: ~p", ['$1']), + lreverse(mc_compliancepart, '$1'). mc_compliancepart -> '$empty' : - io:format("mc_compliancepart -> empty~n", []), +%% i("mc_compliancepart -> empty", []), []. -mc_compliances -> mc_compliance : '$1'. -mc_compliances -> mc_compliances mc_compliance : ['$2' | ['$1']]. +mc_compliances -> mc_compliance : +%% i("mc_compliances -> " +%% "~n $1: ~p", ['$1']), + ['$1']. +mc_compliances -> mc_compliance mc_compliances : +%% i("mc_compliances -> " +%% "~n $1: ~p" +%% "~n $2: ~p", ['$1', '$2']), + ['$1' | '$2']. mc_compliance -> mc_compliancegroup : - io:format("mc_compliance -> (compliancegroup) ~p~n", ['$1']), +%% i("mc_compliance -> " +%% "~n [compliancegroup] $1: ~p", ['$1']), '$1'. mc_compliance -> mc_object : - io:format("mc_compliance -> (object) ~p~n", ['$1']), +%% i("mc_compliance -> " +%% "~n [object] $1: ~p", ['$1']), '$1'. mc_compliancegroup -> 'GROUP' objectname description : - io:format("mc_compliancegroup -> " - "~n $2: ~p" - "~n $3: ~p" - "~n", ['$2', '$3']), +%% i("mc_compliancegroup -> " +%% "~n $2: ~p" +%% "~n $3: ~p" +%% "~n", ['$2', '$3']), make_mc_compliance_group('$2', '$3'). mc_object -> 'OBJECT' objectname syntaxpart writesyntaxpart mc_accesspart description : - io:format("mc_object -> " - "~n $2: ~p" - "~n $3: ~p" - "~n $4: ~p" - "~n $5: ~p" - "~n $6: ~p" - "~n", ['$2', '$3', '$4', '$5', '$6']), +%% i("mc_object -> " +%% "~n $2: ~p" +%% "~n $3: ~p" +%% "~n $4: ~p" +%% "~n $5: ~p" +%% "~n $6: ~p" +%% "~n", ['$2', '$3', '$4', '$5', '$6']), make_mc_object('$2', '$3', '$4', '$5', '$6'). syntaxpart -> 'SYNTAX' syntax : '$2'. @@ -711,7 +724,7 @@ objecttypev2 -> objectname 'OBJECT-TYPE' '$11', '$12', Kind, '$15'), {OT, line_of('$2')}. -indexpartv2 -> 'INDEX' '{' indextypesv2 '}' : {indexes, lrev(indexv2, '$3')}. +indexpartv2 -> 'INDEX' '{' indextypesv2 '}' : {indexes, lreverse(indexpartv2, '$3')}. indexpartv2 -> 'AUGMENTS' '{' entry '}' : {augments, '$3'}. indexpartv2 -> '$empty' : {indexes, undefined}. @@ -736,7 +749,7 @@ notification -> objectname 'NOTIFICATION-TYPE' objectspart Not = make_notification('$1','$3','$5', '$7', '$8', '$9'), {Not, line_of('$2')}. -objectspart -> 'OBJECTS' '{' objects '}' : lrev(objects, '$3'). +objectspart -> 'OBJECTS' '{' objects '}' : lreverse(objectspart, '$3'). objectspart -> '$empty' : []. objects -> objectname : ['$1']. @@ -1175,23 +1188,12 @@ filter_v2imports(_,Type) -> {type, Type}. w(F, A) -> ?vwarning(F, A). -lrev(Tag, L) when is_list(L) -> - io:format("lrev -> try reverse list ~p: " - "~n ~p" - "~n", [Tag, L]), - case (catch lists:reverse(L)) of - RevL when is_list(RevL) -> - RevL; - {'EXIT', Reason} -> - io:format("lrev -> failed reversing list: " - "~n ~p" - "~n", [Reason]), - exit({failed_reversing_list, Reason}) - end; -lrev(Tag, X) -> +lreverse(_Tag, L) when is_list(L) -> + lists:reverse(L); +lreverse(Tag, X) -> exit({bad_list, Tag, X}). -%i(F, A) -> -% io:format("~w:" ++ F ++ "~n", [?MODULE|A]). +%% i(F, A) -> +%% io:format("~w:" ++ F ++ "~n", [?MODULE|A]). -- cgit v1.2.3 From 439262b1a593a98cba7ed25e9453bf026696ebcc Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 18 Feb 2011 14:44:23 +0100 Subject: Fixed mc_modules and ac_variations. --- lib/snmp/src/compile/snmpc_mib_gram.yrl | 59 ++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 19 deletions(-) (limited to 'lib/snmp') diff --git a/lib/snmp/src/compile/snmpc_mib_gram.yrl b/lib/snmp/src/compile/snmpc_mib_gram.yrl index b817b66df3..b322b45022 100644 --- a/lib/snmp/src/compile/snmpc_mib_gram.yrl +++ b/lib/snmp/src/compile/snmpc_mib_gram.yrl @@ -600,17 +600,38 @@ ac_module -> 'SUPPORTS' ac_modulenamepart 'INCLUDES' '{' objects '}' ac_variatio ac_modulenamepart -> mibname : '$1'. ac_modulenamepart -> '$empty' : undefined. -ac_variationpart -> '$empty' : []. -ac_variationpart -> ac_variations : lreverse(ac_variationpart, '$1'). - -ac_variations -> ac_variation : '$1'. -ac_variations -> ac_variations ac_variation : ['$2' | ['$1']]. +ac_variationpart -> '$empty' : +%% i("ac_variationpart -> empty", []), + []. +ac_variationpart -> ac_variations : +%% i("ac_variationpart -> " +%% "~n $1: ~p", ['$1']), + lreverse(ac_variationpart, '$1'). + +ac_variations -> ac_variation : +%% i("ac_variations -> " +%% "~n $1: ~p", ['$1']), + ['$1']. +ac_variations -> ac_variation ac_variations : +%% i("ac_variations -> " +%% "~n $1: ~p" +%% "~n $2: ~p", ['$1', '$2']), + ['$1' | '$2']. %% ac_variation -> ac_objectvariation. %% ac_variation -> ac_notificationvariation. ac_variation -> 'VARIATION' objectname syntaxpart writesyntaxpart ac_accesspart ac_creationpart defvalpart description : - make_ac_variation('$2', '$3', '$4', '$5', '$6', '$7', '$8'). +%% i("mc_module -> " +%% "~n $2: ~p" +%% "~n $3: ~p" +%% "~n $4: ~p" +%% "~n $5: ~p" +%% "~n $6: ~p" +%% "~n $7: ~p" +%% "~n $8: ~p" +%% "~n", ['$2', '$3', '$4', '$5', '$6', '$7', '$8']), + make_ac_variation('$2', '$3', '$4', '$5', '$6', '$7', '$8'). ac_accesspart -> 'ACCESS' ac_access : '$2'. ac_accesspart -> '$empty' : undefined. @@ -630,22 +651,22 @@ mc_modulepart -> mc_modules : %% io:format("mc_modulepart -> $1: ~p~n", ['$1']), lreverse(mc_modulepart, '$1'). -mc_modules -> mc_module: -%% io:format("mc_modules -> (module) $1: ~p~n", ['$1']), +mc_modules -> mc_module : +%% i("mc_modules -> " +%% "~n $1: ~p", ['$1']), ['$1']. -mc_modules -> mc_modules mc_module: -%% io:format("mc_modules -> (modules module)" -%% "~n $1: ~p" -%% "~n $2: ~p" -%% "~n", ['$1', '$2']), - ['$1' | ['$2']]. +mc_modules -> mc_module mc_modules : +%% i("mc_modules -> (modules module)" +%% "~n $1: ~p" +%% "~n $2: ~p", ['$1', '$2']), + ['$1' | '$2']. mc_module -> 'MODULE' mc_modulenamepart mc_mandatorypart mc_compliancepart : -%% io:format("mc_module -> " -%% "~n $2: ~p" -%% "~n $3: ~p" -%% "~n $4: ~p" -%% "~n", ['$2', '$3', '$4']), +%% i("mc_module -> " +%% "~n $2: ~p" +%% "~n $3: ~p" +%% "~n $4: ~p" +%% "~n", ['$2', '$3', '$4']), make_mc_module('$2', '$3', '$4'). mc_modulenamepart -> mibname : '$1'. -- cgit v1.2.3 From d7c6e2781c64e5e75add8a89d1b553bd5e9283f1 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 18 Feb 2011 19:18:12 +0100 Subject: Lost of fixes... *) Update release notes (with regard to module_compliance) *) New compiler options: agent_capabilities and module_compliance *) Update mib compiler option description (new options for agent_capabilities and module_compliance) *) New test case for module_compliance. *) Added test mib for module_complianc test case. *) Added some options for the MIB makefile. ... --- lib/snmp/doc/src/notes.xml | 17 ++- lib/snmp/doc/src/snmpc.xml | 43 ++++++- lib/snmp/mibs/Makefile.in | 26 +++- lib/snmp/src/compile/snmpc.erl | 137 ++++++++++++++++----- lib/snmp/src/compile/snmpc.hrl | 4 +- lib/snmp/src/compile/snmpc_mib_gram.yrl | 34 ++++-- lib/snmp/test/modules.mk | 3 +- lib/snmp/test/snmp_compiler_test.erl | 77 ++++++++++-- lib/snmp/test/snmp_test_data/MC-TEST-MIB.mib | 173 +++++++++++++++++++++++++++ 9 files changed, 452 insertions(+), 62 deletions(-) create mode 100644 lib/snmp/test/snmp_test_data/MC-TEST-MIB.mib (limited to 'lib/snmp') diff --git a/lib/snmp/doc/src/notes.xml b/lib/snmp/doc/src/notes.xml index 0c43be695f..e9c7bef68f 100644 --- a/lib/snmp/doc/src/notes.xml +++ b/lib/snmp/doc/src/notes.xml @@ -4,7 +4,7 @@
- 19962010 + 19962011 Ericsson AB. All Rights Reserved. @@ -42,10 +42,21 @@

[compiler] Added support for the textual convention - AGENT-CAPABILITIES, exported by the SNMPv2-CONF mib.

+ AGENT-CAPABILITIES, exported by the SNMPv2-CONF mib.

The reference and modules part(s) are stored in the assocList of the mib-entry record - (me).

+ (me). + Only handled if the option agent_capabilities + is provided to the compiler.

+

Also added ("full") support for MODULE-COMPLIANCE, + which is handled in a similar way. + Only handled if the option module_compliance + is provided to the compiler.

+

See compile/2 + for more info.

+

For backward compatibillity, the MIBs provided with + this appliaction are not compiled with these + options.

Own Id: OTP-8966

diff --git a/lib/snmp/doc/src/snmpc.xml b/lib/snmp/doc/src/snmpc.xml index fbd0950c69..e33828326a 100644 --- a/lib/snmp/doc/src/snmpc.xml +++ b/lib/snmp/doc/src/snmpc.xml @@ -4,7 +4,7 @@
- 20042010 + 20042011 Ericsson AB. All Rights Reserved. @@ -37,6 +37,7 @@

The module snmpc contains interface functions to the SNMP toolkit MIB compiler.

+ @@ -47,7 +48,7 @@ File = string() Options = [opt()] - opt() = db() | relaxed_row_name_assign_check() | deprecated() | description() | reference() | group_check() | i() | il() | imports() | module() | module_identity() | outdir() | no_defs() | verbosity() | warnings() + opt() = db() | relaxed_row_name_assign_check() | deprecated() | description() | reference() | group_check() | i() | il() | imports() | module() | module_identity() | module_compliance() | agent_capabilities() | outdir() | no_defs() | verbosity() | warnings() db() = {db, volatile|persistent|mnesia} deprecated() = {deprecated, bool()} relaxed_row_name_assign_check() = relaxed_row_name_assign_check @@ -59,6 +60,8 @@ imports() = imports module() = {module, atom()} module_identity() = module_identity + module_compliance() = module_compliance + agent_capabilities() = agent_capabilities no_defs() = no_defs outdir() = {outdir, dir()} verbosity() = {verbosity, silence|warning|info|log|debug|trace} @@ -77,6 +80,7 @@ be used for the default instrumentation.

Default is volatile.

+

The option deprecated specifies if a deprecated definition should be kept or not. If the option is @@ -84,6 +88,7 @@ definitions.

Default is true.

+

The option relaxed_row_name_assign_check, if present, specifies that the row name assign check shall not be done @@ -94,12 +99,14 @@

By default it is not included, but if this option is present it will be.

+

The option description specifies if the text of the DESCRIPTION field will be included or not.

By default it is not included, but if this option is present it will be.

+

The option reference specifies if the text of the REFERENCE field, when found in a table definition, @@ -108,18 +115,21 @@ it will be. The reference text will be placed in the allocList field of the mib-entry record (#me{}) for the table.

+

The option group_check specifies whether the mib compiler should check the OBJECT-GROUP macro and the NOTIFICATION-GROUP macro for correctness or not.

Default is true.

+

The option i specifies the path to search for imported (compiled) MIB files. The directories should be strings with a trailing directory delimiter.

Default is ["./"].

+

The option il (include_lib) also specifies a list of directories to search for imported MIBs. It @@ -132,11 +142,13 @@ /priv/mibs/]]> are always listed last in the include path.

+

The option imports, if present, specifies that the IMPORT statement of the MIB shall be included in the compiled mib.

+

The option module, if present, specifies the name of a module which implements all instrumentation @@ -145,11 +157,29 @@ functions must be the same as the corresponding managed object it implements.

+

The option module_identity, if present, specifies that the info part of the MODULE-IDENTITY statement of the MIB shall be included in the compiled mib.

+ + +

The option module_compliance, if present, specifies + that the MODULE-COMPLIANCE statement of the MIB shall be included + (with a mib-entry record) in the compiled mib. The mib-entry record + of the module-compliance will contain reference and module + part(s) this info in the assocList field).

+
+ + +

The option agent_capabilities, if present, specifies + that the AGENT-CAPABILITIES statement of the MIB shall be included + (with a mib-entry record) in the compiled mib. The mib-entry record + of the agent-capabilitie will contain reference and modules + part(s) this info in the assocList field).

+
+

The option no_defs, if present, specifies that if a managed object does not have an instrumentation @@ -157,6 +187,7 @@ be used, instead this is reported as an error, and the compilation aborts.

+

The option verbosity specifies the verbosity of the SNMP mib compiler. I.e. if warning, info, log, debug @@ -166,11 +197,13 @@ option verbosity is silence, warning messages will still be shown.

+

The option warnings specifies whether warning messages should be shown.

Default is true.

+

The MIB compiler understands both SMIv1 and SMIv2 MIBs. It uses the MODULE-IDENTITY statement to determine if the MIB is @@ -185,8 +218,11 @@ have to be specified to erlc using the syntax +term. See erlc(1) for details.

+ + + is_consistent(Mibs) -> ok | {error, Reason} Check for OID conflicts between MIBs @@ -198,8 +234,11 @@

Checks for multiple usage of object identifiers and traps between MIBs.

+ +
+ mib_to_hrl(MibName) -> ok | {error, Reason} Generate constants for the objects in the MIB diff --git a/lib/snmp/mibs/Makefile.in b/lib/snmp/mibs/Makefile.in index b85a8b0767..7aefb0ea34 100644 --- a/lib/snmp/mibs/Makefile.in +++ b/lib/snmp/mibs/Makefile.in @@ -2,7 +2,7 @@ # %CopyrightBegin% # -# Copyright Ericsson AB 1996-2009. All Rights Reserved. +# Copyright Ericsson AB 1996-2011. 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 @@ -108,20 +108,28 @@ TARGET_FILES = \ # FLAGS # ---------------------------------------------------- -SNMP_FLAGS += -pa ../ebin +version +SNMP_FLAGS += -pa ../ebin +version ifneq ($(MIBS_VERBOSITY),) -SNMP_FLAGS += +'{verbosity,$(MIBS_VERBOSITY)}' +SNMP_FLAGS += +'{verbosity, $(MIBS_VERBOSITY)}' endif -ifneq ($(MIBS_REFERENCE),) +ifeq ($(MIBS_REFERENCE),true) SNMP_FLAGS += +reference endif -ifneq ($(MIBS_OPTIONS),) +ifeq ($(MIBS_OPTIONS),true) SNMP_FLAGS += +options endif +ifeq ($(MIBS_MC),true) +SNMP_FLAGS += +module_compliance +endif + +ifeq ($(MIBS_AC),true) +SNMP_FLAGS += +agent_capabilities +endif + # ---------------------------------------------------- # Targets @@ -148,6 +156,14 @@ conf: cd ..; $(MAKE) conf info: + @echo "MIBS_REFERENCE = $(MIBS_REFERENCE)" + @echo "" + @echo "MIBS_OPTIONS = $(MIBS_OPTIONS)" + @echo "" + @echo "MIBS_MC = $(MIBS_MC)" + @echo "" + @echo "MIBS_AC = $(MIBS_AC)" + @echo "" @echo "SNMP_FLAGS = $(SNMP_FLAGS)" @echo "" @echo "MIBS = $(MIBS)" diff --git a/lib/snmp/src/compile/snmpc.erl b/lib/snmp/src/compile/snmpc.erl index af6e39d058..a3a893dd51 100644 --- a/lib/snmp/src/compile/snmpc.erl +++ b/lib/snmp/src/compile/snmpc.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% Copyright Ericsson AB 1997-2011. 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 @@ -112,6 +112,8 @@ compile(FileName) -> %% description %% reference %% imports +%% agent_capabilities +%% module_compliance %% module_identity %% {module, string()} %% no_defs @@ -203,6 +205,10 @@ get_options([imports|Opts], Formats, Args) -> get_options(Opts, ["~n imports"|Formats], Args); get_options([module_identity|Opts], Formats, Args) -> get_options(Opts, ["~n module_identity"|Formats], Args); +get_options([module_compliance|Opts], Formats, Args) -> + get_options(Opts, ["~n module_compliance"|Formats], Args); +get_options([agent_capabilities|Opts], Formats, Args) -> + get_options(Opts, ["~n agent_capabilities"|Formats], Args); get_options([relaxed_row_name_assign_check|Opts], Formats, Args) -> get_options(Opts, ["~n relaxed_row_name_assign_check"|Formats], Args); get_options([_|Opts], Formats, Args) -> @@ -288,6 +294,10 @@ check_options([imports| T]) -> check_options(T); check_options([module_identity| T]) -> check_options(T); +check_options([module_compliance| T]) -> + check_options(T); +check_options([agent_capabilities| T]) -> + check_options(T); check_options([relaxed_row_name_assign_check| T]) -> check_options(T); check_options([{module, M} | T]) when is_atom(M) -> @@ -315,6 +325,12 @@ get_description(Options) -> get_reference(Options) -> get_bool_option(reference, Options). +get_agent_capabilities(Options) -> + get_bool_option(agent_capabilities, Options). + +get_module_compliance(Options) -> + get_bool_option(module_compliance, Options). + get_relaxed_row_name_assign_check(Options) -> lists:member(relaxed_row_name_assign_check, Options). @@ -387,10 +403,12 @@ get_verbosity(Options) -> init(From, MibFileName, Options) -> {A,B,C} = now(), random:seed(A,B,C), - put(options, Options), - put(verbosity, get_verbosity(Options)), - put(description, get_description(Options)), - put(reference, get_reference(Options)), + put(options, Options), + put(verbosity, get_verbosity(Options)), + put(description, get_description(Options)), + put(reference, get_reference(Options)), + put(agent_capabilities, get_agent_capabilities(Options)), + put(module_compliance, get_module_compliance(Options)), File = filename:rootname(MibFileName, ".mib"), put(filename, filename:basename(File ++ ".mib")), R = case catch c_impl(File) of @@ -930,42 +948,95 @@ definitions_loop([{#mc_agent_capabilities{name = Name, ?vlog2("defloop -> agent_capabilities ~p:" "~n Status: ~p" "~n Desc: ~p" + "~n Ref: ~p" + "~n Mods: ~p" "~n Parent: ~p" "~n SubIndex: ~p", - [Name, Status, Desc, Parent, SubIdx], Line), - update_status(Name, Status), + [Name, Status, Desc, Ref, Mods, Parent, SubIdx], Line), ensure_macro_imported('AGENT-CAPABILITIES', Line), - snmpc_lib:register_oid(Line, Name, Parent, SubIdx), - NewME = snmpc_lib:makeInternalNode2(false, Name), - Description = make_description(Desc), - Reference = - case Ref of - undefined -> - []; - _ -> - [{reference, Ref}] - end, - Modules = - case Mods of - undefined -> - []; - [] -> - []; - _ -> - [{modules, Mods}] - end, - AssocList = Reference ++ Modules, - NewME2 = NewME#me{description = Description, - assocList = AssocList}, - snmpc_lib:add_cdata(#cdata.mes, [NewME2]), + case get(agent_capabilities) of + true -> + update_status(Name, Status), + snmpc_lib:register_oid(Line, Name, Parent, SubIdx), + NewME = snmpc_lib:makeInternalNode2(false, Name), + Description = make_description(Desc), + Reference = + case Ref of + undefined -> + []; + _ -> + [{reference, Ref}] + end, + Modules = + case Mods of + undefined -> + []; + [] -> + []; + _ -> + [{modules, Mods}] + end, + AssocList = Reference ++ Modules, + NewME2 = NewME#me{description = Description, + assocList = AssocList}, + snmpc_lib:add_cdata(#cdata.mes, [NewME2]); + _ -> + ok + end, definitions_loop(T, Data); -definitions_loop([{#mc_module_compliance{name = Name},Line}|T], Data) -> - ?vlog2("defloop -> module_compliance:" - "~n Name: ~p", [Name], Line), +definitions_loop([{#mc_module_compliance{name = Name, + status = Status, + description = Desc, + reference = Ref, + modules = Mods, + name_assign = {Parent, SubIdx}},Line}|T], Data) -> + ?vlog2("defloop -> module_compliance: ~p" + "~n Status: ~p" + "~n Desc: ~p" + "~n Ref: ~p" + "~n Mods: ~p" + "~n Parent: ~p" + "~n SubIndex: ~p", + [Name, Status, Desc, Ref, Mods, Parent, SubIdx], Line), ensure_macro_imported('MODULE-COMPLIANCE', Line), + case get(module_compliance) of + true -> + update_status(Name, Status), + snmpc_lib:register_oid(Line, Name, Parent, SubIdx), + NewME = snmpc_lib:makeInternalNode2(false, Name), + Description = make_description(Desc), + Reference = + case Ref of + undefined -> + []; + _ -> + [{reference, Ref}] + end, + Modules = + case Mods of + undefined -> + []; + [] -> + []; + _ -> + [{modules, Mods}] + end, + AssocList = Reference ++ Modules, + NewME2 = NewME#me{description = Description, + assocList = AssocList}, + snmpc_lib:add_cdata(#cdata.mes, [NewME2]); + _ -> + ok + end, definitions_loop(T, Data); +%% definitions_loop([{#mc_module_compliance{name = Name},Line}|T], Data) -> +%% ?vlog2("defloop -> module_compliance:" +%% "~n Name: ~p", [Name], Line), +%% ensure_macro_imported('MODULE-COMPLIANCE', Line), +%% definitions_loop(T, Data); + definitions_loop([{#mc_object_group{name = Name, objects = GroupObjects, status = Status, diff --git a/lib/snmp/src/compile/snmpc.hrl b/lib/snmp/src/compile/snmpc.hrl index f349cae3f2..1c0808d065 100644 --- a/lib/snmp/src/compile/snmpc.hrl +++ b/lib/snmp/src/compile/snmpc.hrl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% Copyright Ericsson AB 1997-2011. 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 @@ -145,7 +145,7 @@ status, description, reference, - module, + modules, name_assign } ). diff --git a/lib/snmp/src/compile/snmpc_mib_gram.yrl b/lib/snmp/src/compile/snmpc_mib_gram.yrl index b322b45022..a0c59059d2 100644 --- a/lib/snmp/src/compile/snmpc_mib_gram.yrl +++ b/lib/snmp/src/compile/snmpc_mib_gram.yrl @@ -588,13 +588,29 @@ prodrel -> string : lreverse(prodrel, val('$1')). ac_status -> atom : ac_status('$1'). -ac_modulepart -> ac_modules : lreverse(ac_modulepart, '$1'). -ac_modulepart -> '$empty' : []. +ac_modulepart -> ac_modules : +%% i("ac_modulepart -> " +%% "~n $1: ~p", ['$1']), + lreverse(ac_modulepart, '$1'). +ac_modulepart -> '$empty' : +%% i("ac_modulepart -> empty", []), + []. -ac_modules -> ac_module : '$1'. -ac_modules -> ac_modules ac_module : ['$2' | ['$1']]. +ac_modules -> ac_module : +%% i("ac_modules -> " +%% "~n $1: ~p", ['$1']), + ['$1']. +ac_modules -> ac_module ac_modules : +%% i("ac_modules -> " +%% "~n $1: ~p" +%% "~n $2: ~p", ['$1', '$2']), + ['$1' | '$2']. ac_module -> 'SUPPORTS' ac_modulenamepart 'INCLUDES' '{' objects '}' ac_variationpart : +%% i("ac_module -> " +%% "~n $2: ~p" +%% "~n $5: ~p" +%% "~n $7: ~p", ['$2', '$5', '$7']), make_ac_module('$2', '$5', '$7'). ac_modulenamepart -> mibname : '$1'. @@ -645,10 +661,10 @@ ac_creationpart -> '$empty' : []. mc_modulepart -> '$empty' : -%% io:format("mc_modulepart -> empty~n", []), +%% i("mc_modulepart -> empty", []), []. mc_modulepart -> mc_modules : -%% io:format("mc_modulepart -> $1: ~p~n", ['$1']), +%% i("mc_modulepart -> $1: ~p", ['$1']), lreverse(mc_modulepart, '$1'). mc_modules -> mc_module : @@ -656,7 +672,7 @@ mc_modules -> mc_module : %% "~n $1: ~p", ['$1']), ['$1']. mc_modules -> mc_module mc_modules : -%% i("mc_modules -> (modules module)" +%% i("mc_modules -> " %% "~n $1: ~p" %% "~n $2: ~p", ['$1', '$2']), ['$1' | '$2']. @@ -969,12 +985,12 @@ make_ac_module(Name, Grps, Var) -> variation = Var}. -make_module_compliance(Name, Status, Desc, Ref, Mod, NA) -> +make_module_compliance(Name, Status, Desc, Ref, Mods, NA) -> #mc_module_compliance{name = Name, status = Status, description = Desc, reference = Ref, - module = Mod, + modules = Mods, name_assign = NA}. make_mc_module(Name, Mand, Compl) -> diff --git a/lib/snmp/test/modules.mk b/lib/snmp/test/modules.mk index b90c6af482..eacc749b53 100644 --- a/lib/snmp/test/modules.mk +++ b/lib/snmp/test/modules.mk @@ -2,7 +2,7 @@ # %CopyrightBegin% # -# Copyright Ericsson AB 2004-2010. All Rights Reserved. +# Copyright Ericsson AB 2004-2011. 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 @@ -63,6 +63,7 @@ COMPILER_MIB_FILES = \ MIB_FILES = \ AC-TEST-MIB.mib \ + MC-TEST-MIB.mib \ OLD-SNMPEA-MIB.mib \ OLD-SNMPEA-MIB-v2.mib \ Klas1.mib \ diff --git a/lib/snmp/test/snmp_compiler_test.erl b/lib/snmp/test/snmp_compiler_test.erl index 09fc417af4..592b3efee2 100644 --- a/lib/snmp/test/snmp_compiler_test.erl +++ b/lib/snmp/test/snmp_compiler_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2003-2010. All Rights Reserved. +%% Copyright Ericsson AB 2003-2011. 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 @@ -45,6 +45,7 @@ imports/1, module_identity/1, agent_capabilities/1, + module_compliance/1, tickets/1, otp_6150/1, @@ -98,6 +99,7 @@ all(suite) -> imports, module_identity, agent_capabilities, + module_compliance, tickets ]. @@ -183,12 +185,73 @@ agent_capabilities(Config) when is_list(Config) -> OtpMibsMibsDir = join(OtpMibsPrivDir, "mibs"), Dir = ?config(mib_dir, Config), AcMib = join(Dir,"AC-TEST-MIB.mib"), - ?line {ok, Mib} = snmpc:compile(AcMib, [options, - version, - {i, [SnmpMibsDir, OtpMibsMibsDir]}, - {outdir, Dir}, - {verbosity, trace}]), - io:format("agent_capabilities -> Mib: ~n~p~n", [Mib]), + ?line {ok, MibFile1} = snmpc:compile(AcMib, [options, + version, + {i, [SnmpMibsDir, OtpMibsMibsDir]}, + {outdir, Dir}, + {verbosity, trace}]), + ?line {ok, Mib1} = snmp_misc:read_mib(MibFile1), + ?line {ok, MibFile2} = snmpc:compile(AcMib, [options, + version, + agent_capabilities, + {i, [SnmpMibsDir, OtpMibsMibsDir]}, + {outdir, Dir}, + {verbosity, trace}]), + ?line {ok, Mib2} = snmp_misc:read_mib(MibFile2), + MEDiff = Mib2#mib.mes -- Mib1#mib.mes, + %% This is a rather pathetic test, but it is somthing... + io:format("agent_capabilities -> " + "~n MEDiff: ~p" + "~n Mib1: ~p" + "~n Mib2: ~p" + "~n", [MEDiff, Mib1, Mib2]), + case length(MEDiff) of + 2 -> + ok; + _BadLen -> + exit({unexpected_mes, MEDiff}) + end, + ok. + + +module_compliance(suite) -> + []; +module_compliance(Config) when is_list(Config) -> + put(tname,module_compliance), + p("starting with Config: ~p~n", [Config]), + + SnmpPrivDir = code:priv_dir(snmp), + SnmpMibsDir = join(SnmpPrivDir, "mibs"), + OtpMibsPrivDir = code:priv_dir(otp_mibs), + OtpMibsMibsDir = join(OtpMibsPrivDir, "mibs"), + Dir = ?config(mib_dir, Config), + AcMib = join(Dir,"MC-TEST-MIB.mib"), + ?line {ok, MibFile1} = snmpc:compile(AcMib, [options, + version, + {i, [SnmpMibsDir, OtpMibsMibsDir]}, + {outdir, Dir}, + {verbosity, trace}]), + ?line {ok, Mib1} = snmp_misc:read_mib(MibFile1), + ?line {ok, MibFile2} = snmpc:compile(AcMib, [options, + version, + module_compliance, + {i, [SnmpMibsDir, OtpMibsMibsDir]}, + {outdir, Dir}, + {verbosity, trace}]), + ?line {ok, Mib2} = snmp_misc:read_mib(MibFile2), + MEDiff = Mib2#mib.mes -- Mib1#mib.mes, + %% This is a rather pathetic test, but it is somthing... + io:format("agent_capabilities -> " + "~n MEDiff: ~p" + "~n Mib1: ~p" + "~n Mib2: ~p" + "~n", [MEDiff, Mib1, Mib2]), + case length(MEDiff) of + 1 -> + ok; + _BadLen -> + exit({unexpected_mes, MEDiff}) + end, ok. diff --git a/lib/snmp/test/snmp_test_data/MC-TEST-MIB.mib b/lib/snmp/test/snmp_test_data/MC-TEST-MIB.mib new file mode 100644 index 0000000000..cadaa6f891 --- /dev/null +++ b/lib/snmp/test/snmp_test_data/MC-TEST-MIB.mib @@ -0,0 +1,173 @@ +MC-TEST-MIB DEFINITIONS ::= BEGIN + +IMPORTS + otpExpr + FROM OTP-REG + MODULE-IDENTITY, OBJECT-TYPE, + mib-2, NOTIFICATION-TYPE, OBJECT-IDENTITY + FROM SNMPv2-SMI + TDomain, TAddress, DisplayString, TEXTUAL-CONVENTION, + AutonomousType, RowPointer, TimeStamp, + RowStatus, StorageType + FROM SNMPv2-TC + MODULE-COMPLIANCE, OBJECT-GROUP, NOTIFICATION-GROUP + FROM SNMPv2-CONF; + +mcTestModule MODULE-IDENTITY + LAST-UPDATED "9605160000Z" + ORGANIZATION "MC Test Co." + CONTACT-INFO + "developer@small.company." + DESCRIPTION + "MC Test module." + ::= { reg 1 } + +mcObjects OBJECT IDENTIFIER ::= { mcTestModule 1 } + +-- MIB contains one group + +mcMisc OBJECT IDENTIFIER ::= { mcObjects 1 } +mcGeneral OBJECT IDENTIFIER ::= { mcObjects 2 } + + +mcTest OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Test area." + ::= { otpExpr 4322 } + + +reg OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Registrations." + ::= { mcTest 1 } + + +mcTable OBJECT-TYPE + SYNTAX SEQUENCE OF McEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table contains one row per physical entity. There is + always at least one row for an 'overall' physical entity." + ::= { mcMisc 1 } + +mcEntry OBJECT-TYPE + SYNTAX McEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Table entry..." + INDEX { mcIndex } + ::= { mcTable 1 } + +McEntry ::= SEQUENCE { + mcIndex INTEGER, + mcName DisplayString, + mcStorageType StorageType, + mcRowStatus RowStatus +} + +mcIndex OBJECT-TYPE + SYNTAX INTEGER + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The index for this entry." + ::= { mcEntry 1 } + +mcName OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Name of... " + ::= { mcEntry 2 } + + +mcStorageType OBJECT-TYPE + SYNTAX StorageType + MAX-ACCESS read-create + STATUS current + DESCRIPTION + "The storage type for this conceptual row." + DEFVAL { nonVolatile } + ::= { mcEntry 3 } + +mcRowStatus OBJECT-TYPE + SYNTAX RowStatus + MAX-ACCESS read-create + STATUS current + DESCRIPTION + "The status of this conceptual row..." + ::= { mcEntry 4 } + + +-- last change time stamp for the whole MIB +mcTimeStamp OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The sysUpTime value when of the last time *anything* in the + MIB was changed. " + ::= { mcGeneral 1 } + +-- Entity MIB Trap Definitions +mcTraps OBJECT IDENTIFIER ::= { mcTestModule 2 } +mcTrapPrefix OBJECT IDENTIFIER ::= { mcTraps 0 } + +mcConfigChange NOTIFICATION-TYPE + STATUS current + DESCRIPTION + "An mcConfigChange trap is sent when the value of + entLastChangeTime changes..." + ::= { mcTrapPrefix 1 } + +-- conformance information +mcConformance OBJECT IDENTIFIER ::= { mcTestModule 3 } + +mcCompliances OBJECT IDENTIFIER ::= { mcConformance 1 } +mcGroups OBJECT IDENTIFIER ::= { mcConformance 2 } + +-- compliance statements + + +mcCompliance MODULE-COMPLIANCE + STATUS current + DESCRIPTION + "The compliance statement for SNMP entities which implement + the MC Test MIB." + MODULE -- this module + MANDATORY-GROUPS { mcGeneralGroup, + mcNotificationsGroup } + ::= { mcCompliances 1 } + +-- MIB groupings + +mcGeneralGroup OBJECT-GROUP + OBJECTS { + mcName, + mcStorageType, + mcRowStatus, + mcTimeStamp + } + STATUS current + DESCRIPTION + "The collection of objects which are used to represent + general information..." + ::= { mcGroups 1 } + +mcNotificationsGroup NOTIFICATION-GROUP + NOTIFICATIONS { mcConfigChange } + STATUS current + DESCRIPTION + "The collection of notifications..." + ::= { mcGroups 2 } + + +END + + + -- cgit v1.2.3