aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2010-12-03 16:13:18 +0100
committerMicael Karlberg <[email protected]>2010-12-03 16:13:18 +0100
commit314e80f58bbee2924bf61bdc7b987750d58ca2ef (patch)
treeadb70ece58251746adecc5a07a82e5f82740013b
parent66dc042ce9a0e888cfdb8f1b0f5a2e9d4d046f9e (diff)
downloadotp-314e80f58bbee2924bf61bdc7b987750d58ca2ef.tar.gz
otp-314e80f58bbee2924bf61bdc7b987750d58ca2ef.tar.bz2
otp-314e80f58bbee2924bf61bdc7b987750d58ca2ef.zip
Typed more of the info. Also added more of it in the compiled mib.
Also prepared for future module_compilance addition.
-rw-r--r--lib/snmp/src/compile/snmpc.erl12
-rw-r--r--lib/snmp/src/compile/snmpc.hrl20
-rw-r--r--lib/snmp/src/compile/snmpc_mib_gram.yrl79
-rw-r--r--lib/snmp/test/snmp_compiler_test.erl18
4 files changed, 84 insertions, 45 deletions
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.