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 ++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 2 deletions(-) (limited to 'lib/snmp/src/compile') 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, -- 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 ++- 5 files changed, 197 insertions(+), 17 deletions(-) (limited to 'lib/snmp/src/compile') 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. -- 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 +++++++++++++++++++-------------- 3 files changed, 71 insertions(+), 40 deletions(-) (limited to 'lib/snmp/src/compile') 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, -- 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/src/compile') 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 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/src/compile') 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/src/compile') 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/src/compile') 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/src/compile/snmpc.erl | 137 ++++++++++++++++++++++++-------- lib/snmp/src/compile/snmpc.hrl | 4 +- lib/snmp/src/compile/snmpc_mib_gram.yrl | 34 +++++--- 3 files changed, 131 insertions(+), 44 deletions(-) (limited to 'lib/snmp/src/compile') 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) -> -- cgit v1.2.3