summaryrefslogtreecommitdiff
path: root/local/mib2c.emulation.conf
blob: 20d2e7bf69d05383f10ff1df6d0452e09edf4af9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
############################################## -*- Mib2c -*-
##
## File   : mib2c.emulation.conf
## Author : Robert Story <rstory@freesnmp.com>
## Purpose: A mib2c conf file to generate snmpd.conf configuration to
##          provide basic/simplistic emulation for a particular MIB.
##
## 
## $Id$
######################################################################
@open ${name}-emulation.conf@
#
# $name.module MIB emulation
# Base OID: $name.objectID
#
# Requirements: Net-SNMP 5.2 or greater
#
# This file can be used as (part of) a Net-SNMP snmpd.conf
# configuration file to emulate (in a minimal fashion) the objects defined
# in the $name MIB.
#
# It is important to note that this file merely creates dummy values
# and variables and does not implement any of the functionality which
# the mib objects are actually supposed to implement!
#
# Also, it just defaults to 0, '' or 0.0 for initial values, so you'll need
# to tweak all the vaules. For any tables, you'll have set any indexes.
#
# The configuration tokens used in this file are documented in the
# snmpd.conf manual page, with the exception of the first line, which
# is documented in the snmp.conf and snmp_config manual pages.
#
#
# To use this file, you have several options:
#
#   1) add the contents to your existing snmpd.conf file
#   2) copy it to a new snmpd.conf, somewhere in SNMPCONFPATH
#   3) copy it to snmpd.conf.local, somewhere in SNMPCONFPATH
#
# The command 'net-snmp-config --snmpconfpath' will give your the
# SNMPCONFPATH (5.3.x and later).


# Here we tell the agent to load the MIB, so we can use names instead
# of OIDs. You may need to add other MIBs that this MIB depends on.
# Also, you might want to consider adding these to the global snmp.conf,
# so all users can reference them.
#
# See the Net-SNMP FAQ for more information on MIB loading.
#
[snmp] mibs +$name.module

#
# $name Scalar variables
#

@foreach $node scalar@
@   print Scalar: $node@
# $node.module::$node.parent.$node($node.subid) [$node.syntax = $node.type]
@   if "$node.status" eq "Deprecated"@
# **** WARNING: deprecated object ****
@   end@
@if $node.enums == 1@
@    eval $m2c_evals = ""@
@    eval $m2c_first = 1@
@    foreach $e $v enum@
@        if $m2c_first == 1@
@            eval $m2c_first = 0@
@        else@
@            eval $m2c_evals = "$m2c_evals,"@
@        end@
@        eval $m2c_evals = "$m2c_evals $e($v)"@
@        if $node.hasdefval == 1@
@           if (("$node.defval" eq "$e") || ("$node.defval" eq "$v"))@
@              eval $m2c_evals = "${m2c_evals}*"@
@           end@
@        end@
@    end@
# Enum range: $node.enumrange. Values: $m2c_evals
@elsif $node.ranges == 1@
@    eval $m2c_range_max = 0@
@    eval $m2c_evals = ""@
@    eval $m2c_first = 1@
@    foreach $a $b range $node@
@        if $m2c_first == 1@
@            eval $m2c_first = 0@
@        else@
@            eval $m2c_evals = "$m2c_evals,"@
@        end@
@        if $a == $b@
@            eval $m2c_evals = "$m2c_evals $a"@
@        else@
@            eval $m2c_evals = "$m2c_evals $a - $b"@
@        end@
@        eval $m2c_range_max = max($m2c_range_max,$b)@
@    end@
# Ranges: $m2c_evals;
@end@ #ranges
@   if $node.hasdefval == 1@
@      eval $m2c_emu_def = "$node.defval"@
@   else@
#  (no default value)
@      if "$node.type" eq "ASN_OCTET_STR"@
@         eval $m2c_emu_def = "''" @
@      elsif "$node.type" eq "ASN_OBJECT_ID"@
@         eval $m2c_emu_def = "0.0" @
@      else@
@         eval $m2c_emu_def = "0" @
@      end@
@   end@
##  uggh.. try to convert type into something 5.3.x override understands
@   eval $m2c_emu_type = lc($node.type)@
@   perleval $vars{'m2c_emu_type'} =~ s/asn_//; 0;@
@   if $node.settable@
#override -rw ${node}.0 $m2c_emu_type $m2c_emu_def
@   else@
#override ${node}.0 $m2c_emu_type $m2c_emu_def
@   end@

@end@


##======================================================================
#
# Note that in tables, all indices are shown first, then each
# readable column. This results in indices being given twice.
#
@foreach $node table@
@   print Table: $node@
# $node.module::$node.parent.$node($node.subid)
table $node
##============================================================
@   eval $m2c_idx_def = ""@
@   eval $m2c_add_def = ""@
@   foreach $col index@
# [$col] ($node.accessible) $col.syntax / $col.type / $m2c_decl ($col.decl)
@      if $col.enums == 1@
@          eval $m2c_evals = ""@
@          eval $m2c_first = 1@
@          foreach $e $v enum@
@              if $m2c_first == 1@
@                  eval $m2c_first = 0@
@              else@
@                  eval $m2c_evals = "$m2c_evals,"@
@              end@
@              eval $m2c_evals = "$m2c_evals $e($v)"@
@              if $col.hasdefval == 1@
@                 if (("$col.defval" eq "$e") || ("$col.defval" eq "$v"))@
@                    eval $m2c_evals = "${m2c_evals}*"@
@                 end@
@              end@
@          end@
#      enum range: $col.enumrange. Values: $m2c_evals
@      elsif $col.ranges == 1@
@          eval $m2c_range_max = 0@
@          eval $m2c_evals = ""@
@          eval $m2c_first = 1@
@          foreach $a $b range $col@
@              if $m2c_first == 1@
@                  eval $m2c_first = 0@
@              else@
@                  eval $m2c_evals = "$m2c_evals,"@
@              end@
@              if $a == $b@
@                  eval $m2c_evals = "$m2c_evals $a"@
@              else@
@                  eval $m2c_evals = "$m2c_evals $a - $b"@
@              end@
@              eval $m2c_range_max = max($m2c_range_max,$b)@
@          end@
#      ranges: $m2c_evals;
@      end@ #ranges
@      if $col.hasdefval == 1@
@         eval $m2c_col_def = '$col.defval'@
@      else@
@         if "$col.type" eq "ASN_OCTET_STR"@
@            eval $m2c_col_def = "''" @
@         elsif "$col.type" eq "ASN_OBJECT_ID"@
@            eval $m2c_col_def = "0.0" @
@         else@
@            eval $m2c_col_def = "0" @
@         end@
@      end@
@      eval $m2c_add_def = "$m2c_add_def $m2c_col_def"@
##@      if $node.accessible == 1@
@         eval $m2c_idx_def = "$m2c_idx_def $m2c_col_def"@
##@      end@
@   end@ ## col
##===================================================
@   foreach $col nonindex@
# $col [$col.syntax = $col.type]
@      if "$col.status" eq "Deprecated"@
# **** WARNING: deprecated object ****
@      end@
@      if $col.enums == 1@
@          eval $m2c_evals = ""@
@          eval $m2c_first = 1@
@          foreach $e $v enum@
@              if $m2c_first == 1@
@                  eval $m2c_first = 0@
@              else@
@                  eval $m2c_evals = "$m2c_evals,"@
@              end@
@              eval $m2c_evals = "$m2c_evals $e($v)"@
@              if $col.hasdefval == 1@
@                 if (("$col.defval" eq "$e") || ("$col.defval" eq "$v"))@
@                    eval $m2c_evals = "${m2c_evals}*"@
@                 end@
@              end@
@          end@
#      enum range: $col.enumrange. Values: $m2c_evals
@      elsif $col.ranges == 1@
@          eval $m2c_range_max = 0@
@          eval $m2c_evals = ""@
@          eval $m2c_first = 1@
@          foreach $a $b range $col@
@              if $m2c_first == 1@
@                  eval $m2c_first = 0@
@              else@
@                  eval $m2c_evals = "$m2c_evals,"@
@              end@
@              if $a == $b@
@                  eval $m2c_evals = "$m2c_evals $a"@
@              else@
@                  eval $m2c_evals = "$m2c_evals $a - $b"@
@              end@
@              eval $m2c_range_max = max($m2c_range_max,$b)@
@          end@
#      ranges: $m2c_evals;
@      end@ #ranges
@      if $col.hasdefval == 1@
@         eval $m2c_col_def = '$col.defval'@
@      else@
@         if "$col.type" eq "ASN_OCTET_STR"@
@            eval $m2c_col_def = "''" @
@         elsif "$col.type" eq "ASN_OBJECT_ID"@
@            eval $m2c_col_def = "0.0" @
@         else@
@            eval $m2c_col_def = "0" @
@         end@
@      end@
@      eval $m2c_add_def = "$m2c_add_def $m2c_col_def"@
@   end@ ## col
#add_row $node $m2c_idx_def $m2c_add_def

@end@ ## table