OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [snmp/] [agent/] [v2_0/] [utils/] [mib2c/] [mib2c.conf] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#
2
# Define types of data by mib type, and translate into needed C code.
3
#
4
 
5
############################################################################
6
# source variable typing information:
7
include: mib2c.vartypes.conf
8
 
9
# Begin code template section
10
############################################################################
11
# variable statemnts used in a couple of places below
12
############################################################################
13
type:   code-varInits
14
code:     /* variables we may use later */
15
code:     static long long_ret;
16
code:     static unsigned char string[SPRINT_MAX_LEN];
17
code:     static oid objid[MAX_OID_LEN];
18
code:     static struct counter64 c64;
19
 
20
 
21
############################################################################
22
# The .h file
23
############################################################################
24
type:   code-dot-h
25
code:   //==========================================================================
26
code:   //
27
code:   //      snmp/snmpagent/current/include/mibgroup/mibII/$outputName.h
28
code:   //
29
code:   //
30
code:   //==========================================================================
31
#####ECOSGPLCOPYRIGHTBEGIN####
32
## -------------------------------------------
33
## This file is part of eCos, the Embedded Configurable Operating System.
34
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
35
##
36
## eCos is free software; you can redistribute it and/or modify it under
37
## the terms of the GNU General Public License as published by the Free
38
## Software Foundation; either version 2 or (at your option) any later version.
39
##
40
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
41
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
42
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
43
## for more details.
44
##
45
## You should have received a copy of the GNU General Public License along
46
## with eCos; if not, write to the Free Software Foundation, Inc.,
47
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
48
##
49
## As a special exception, if other files instantiate templates or use macros
50
## or inline functions from this file, or you compile this file and link it
51
## with other works to produce a work based on this file, this file does not
52
## by itself cause the resulting work to be covered by the GNU General Public
53
## License. However the source code for this file must still be made available
54
## in accordance with section (3) of the GNU General Public License.
55
##
56
## This exception does not invalidate any other reasons why a work based on
57
## this file might be covered by the GNU General Public License.
58
##
59
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
60
## at http://sources.redhat.com/ecos/ecos-license/
61
## -------------------------------------------
62
#####ECOSGPLCOPYRIGHTEND####
63
code:   //####UCDSNMPCOPYRIGHTBEGIN####
64
code:   //
65
code:   // -------------------------------------------
66
code:   //
67
code:   // Portions of this software may have been derived from the UCD-SNMP
68
code:   // project,    from the University of
69
code:   // California at Davis, which was originally based on the Carnegie Mellon
70
code:   // University SNMP implementation.  Portions of this software are therefore
71
code:   // covered by the appropriate copyright disclaimers included herein.
72
code:   //
73
code:   // The release used was version 4.1.2 of May 2000.  \"ucd-snmp-4.1.2\"
74
code:   // -------------------------------------------
75
code:   //
76
code:   //####UCDSNMPCOPYRIGHTEND####
77
code:   //==========================================================================
78
code:   //#####DESCRIPTIONBEGIN####
79
code:   //
80
code:   // Author(s):    hmt
81
code:   // Contributors: hmt
82
code:   // Date:         2000-05-30
83
code:   // Purpose:      Port of UCD-SNMP distribution to eCos.
84
code:   // Description:
85
code:   //
86
code:   //
87
code:   //####DESCRIPTIONEND####
88
code:   //
89
code:   //==========================================================================
90
code:   /********************************************************************
91
code:          Copyright 1989, 1991, 1992 by Carnegie Mellon University
92
code:   \
93
code:                             Derivative Work -
94
code:   Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
95
code:   \
96
code:                            All Rights Reserved
97
code:   \
98
code:   Permission to use, copy, modify and distribute this software and its
99
code:   documentation for any purpose and without fee is hereby granted,
100
code:   provided that the above copyright notice appears in all copies and
101
code:   that both that copyright notice and this permission notice appear in
102
code:   supporting documentation, and that the name of CMU and The Regents of
103
code:   the University of California not be used in advertising or publicity
104
code:   pertaining to distribution of the software without specific written
105
code:   permission.
106
code:   \
107
code:   CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
108
code:   WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
109
code:   WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL CMU OR
110
code:   THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
111
code:   INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
112
code:   FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
113
code:   CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
114
code:   CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
115
code:   *********************************************************************/
116
code:   /* This file was generated by mib2c and is intended for use as a mib module
117
code:     for the ucd-snmp snmpd agent. */
118
code:
119
code:   #ifndef _MIBGROUP_${OUTPUTNAME}_H
120
code:   #define _MIBGROUP_${OUTPUTNAME}_H
121
code:
122
code:   /* we may use header_generic and header_simple_table from the util_funcs module */
123
code:
124
code:   config_require(util_funcs)
125
code:
126
code:   /* function prototypes */
127
code:
128
code:   void   init_$outputName(void);
129
code:   FindVarMethod var_$outputName;
130
code:   $variables{'code-var_table-decl'}{'processed'}
131
code:   $variables{'code-write-func-decl'}{'processed'}
132
code:
133
code:   #endif /* _MIBGROUP_${OUTPUTNAME}_H */
134
 
135
############################################################################
136
# The .c file, top
137
############################################################################
138
type:   code-main-part
139
code:   //==========================================================================
140
code:   //
141
code:   //      snmp/snmpagent/current/src/mibgroup/mibII/$outputName.c
142
code:   //
143
code:   //
144
code:   //==========================================================================
145
#####ECOSGPLCOPYRIGHTBEGIN####
146
## -------------------------------------------
147
## This file is part of eCos, the Embedded Configurable Operating System.
148
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
149
##
150
## eCos is free software; you can redistribute it and/or modify it under
151
## the terms of the GNU General Public License as published by the Free
152
## Software Foundation; either version 2 or (at your option) any later version.
153
##
154
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
155
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
156
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
157
## for more details.
158
##
159
## You should have received a copy of the GNU General Public License along
160
## with eCos; if not, write to the Free Software Foundation, Inc.,
161
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
162
##
163
## As a special exception, if other files instantiate templates or use macros
164
## or inline functions from this file, or you compile this file and link it
165
## with other works to produce a work based on this file, this file does not
166
## by itself cause the resulting work to be covered by the GNU General Public
167
## License. However the source code for this file must still be made available
168
## in accordance with section (3) of the GNU General Public License.
169
##
170
## This exception does not invalidate any other reasons why a work based on
171
## this file might be covered by the GNU General Public License.
172
##
173
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
174
## at http://sources.redhat.com/ecos/ecos-license/
175
## -------------------------------------------
176
#####ECOSGPLCOPYRIGHTEND####
177
code:   //####UCDSNMPCOPYRIGHTBEGIN####
178
code:   //
179
code:   // -------------------------------------------
180
code:   //
181
code:   // Portions of this software may have been derived from the UCD-SNMP
182
code:   // project,    from the University of
183
code:   // California at Davis, which was originally based on the Carnegie Mellon
184
code:   // University SNMP implementation.  Portions of this software are therefore
185
code:   // covered by the appropriate copyright disclaimers included herein.
186
code:   //
187
code:   // The release used was version 4.1.2 of May 2000.  \"ucd-snmp-4.1.2\"
188
code:   // -------------------------------------------
189
code:   //
190
code:   //####UCDSNMPCOPYRIGHTEND####
191
code:   //==========================================================================
192
code:   //#####DESCRIPTIONBEGIN####
193
code:   //
194
code:   // Author(s):    hmt
195
code:   // Contributors: hmt
196
code:   // Date:         2000-05-30
197
code:   // Purpose:      Port of UCD-SNMP distribution to eCos.
198
code:   // Description:
199
code:   //
200
code:   //
201
code:   //####DESCRIPTIONEND####
202
code:   //
203
code:   //==========================================================================
204
code:   /********************************************************************
205
code:          Copyright 1989, 1991, 1992 by Carnegie Mellon University
206
code:   \
207
code:                             Derivative Work -
208
code:   Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
209
code:   \
210
code:                            All Rights Reserved
211
code:   \
212
code:   Permission to use, copy, modify and distribute this software and its
213
code:   documentation for any purpose and without fee is hereby granted,
214
code:   provided that the above copyright notice appears in all copies and
215
code:   that both that copyright notice and this permission notice appear in
216
code:   supporting documentation, and that the name of CMU and The Regents of
217
code:   the University of California not be used in advertising or publicity
218
code:   pertaining to distribution of the software without specific written
219
code:   permission.
220
code:   \
221
code:   CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
222
code:   WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
223
code:   WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL CMU OR
224
code:   THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
225
code:   INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
226
code:   FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
227
code:   CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
228
code:   CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
229
code:   *********************************************************************/
230
code:   /* This file was generated by mib2c and is intended for use as a mib module
231
code:      for the ucd-snmp snmpd agent. */
232
code:
233
code:   /* This should always be included first before anything else */
234
code:   #include 
235
code:
236
code:   /* minimal include directives */
237
code:   #include \"mibincl.h\"
238
code:   #include \"mibgroup/util_funcs.h\"
239
code:   #include \"mibgroup/mibII/$outputName.h\"
240
code:
241
code:   /*
242
code:    * ${outputName}_variables_oid:
243
code:    *   this is the top level oid that we want to register under.  This
244
code:    *   is essentially a prefix, with the suffix appearing in the
245
code:    *   variable below.
246
code:    */
247
code:
248
code:   oid ${outputName}_variables_oid[] = { $commaoid };
249
code:
250
code:   /*
251
code:    * variable$varlen ${outputName}_variables:
252
code:    *   this variable defines function callbacks and type return information
253
code:    *   for the $outputName mib section
254
code:    */
255
code:
256
code:   struct variable$varlen ${outputName}_variables[] = {
257
code:   /*  magic number        , variable type , ro/rw , callback fn  , L, oidsuffix */
258
code:   $variables{'variable-structure-info'}{'processed'}
259
code:   };
260
code:   /*    (L = length of the oidsuffix) */
261
code:
262
code:   /*
263
code:    * init_$outputName():
264
code:    *   Initialization routine.  This is called when the agent starts up.
265
code:    *   At a minimum, registration of your variables should take place here.
266
code:    */
267
code:   void init_$outputName(void) {
268
code:
269
code:     /* register ourselves with the agent to handle our mib tree */
270
code:     REGISTER_MIB(\"$outputName\", ${outputName}_variables, variable$varlen,\
271
code:                  ${outputName}_variables_oid);
272
code:
273
code:     /* place any other initialization junk you need here */
274
code:   }
275
code:
276
code:   /*
277
code:    * var_$outputName():
278
code:    *   This function is called every time the agent gets a request for
279
code:    *   a scalar variable that might be found within your mib section
280
code:    *   registered above.  It is up to you to do the right thing and
281
code:    *   return the correct value.
282
code:    *     You should also correct the value of \"var_len\" if necessary.
283
code:    *
284
code:    *   Please see the documentation for more information about writing
285
code:    *   module extensions, and check out the examples in the examples
286
code:    *   and mibII directories.
287
code:    */
288
code:   unsigned char *
289
code:   var_$outputName(struct variable *vp,
290
code:                   oid     *name,
291
code:                   size_t  *length,
292
code:                   int     exact,
293
code:                   size_t  *var_len,
294
code:                   WriteMethod **write_method)
295
code:   {
296
code:
297
code:   $variables{'code-varInits'}{'code'}
298
code:
299
code:     if (header_generic(vp,name,length,exact,var_len,write_method)
300
code:                                     == MATCH_FAILED )
301
code:       return NULL;
302
code:
303
code:     /*
304
code:      * this is where we do the value assignments for the mib results.
305
code:      */
306
code:     switch(vp->magic) {\n\n
307
code:   $variables{$outputName}{'code-case-statements'}{'processed'}
308
code:       default:
309
code:         ERROR_MSG(\"\");
310
code:     }
311
code:     return NULL;
312
code:   }
313
code:
314
code:   $variables{'code-var_table'}{'processed'}
315
code:
316
code:   $variables{'code-write-func'}{'processed'}
317
 
318
############################################################################
319
# var_ function for tables, which is handled specially and used above
320
#
321
#   Note: $vtable is set to the table name in the processtable loop.
322
############################################################################
323
 
324
#
325
# header file defs first
326
#
327
type:           code-var_table-decl
328
processtable:   code-var_table-decl
329
 
330
code:   FindVarMethod var_$vtable;
331
 
332
#
333
# Code code per table
334
#
335
type:           code-var_table
336
processtable:   code-var_table
337
 
338
code:   /*
339
code:    * var_$vtable():
340
code:    *   Handle this table separately from the scalar value case.
341
code:    *   The workings of this are basically the same as for var_$outputName above.
342
code:    */
343
code:   unsigned char *
344
code:   var_$vtable(struct variable *vp,
345
code:               oid     *name,
346
code:               size_t  *length,
347
code:               int     exact,
348
code:               size_t  *var_len,
349
code:               WriteMethod **write_method)
350
code:   {
351
code:
352
code:   $variables{'code-varInits'}{'code'}
353
code:
354
code:     /*
355
code:      * This assumes that the table is a \'simple\' table.
356
code:      *    See the implementation documentation for the meaning of this.
357
code:      *    You will need to provide the correct value for the TABLE_SIZE parameter
358
code:      *
359
code:      * If this table does not meet the requirements for a simple table,
360
code:      *    you will need to provide the replacement code yourself.
361
code:      *    Mib2c is not smart enough to write this for you.
362
code:      *    Again, see the implementation documentation for what is required.
363
code:      */
364
code:     if (header_simple_table(vp,name,length,exact,var_len,write_method, TABLE_SIZE)
365
code:                                                   == MATCH_FAILED )
366
code:       return NULL;
367
code:
368
code:     /*
369
code:      * this is where we do the value assignments for the mib results.
370
code:      */
371
code:     switch(vp->magic) {\n\n
372
code:   $variables{$vtable}{'code-case-statements'}{'processed'}
373
code:       default:
374
code:         ERROR_MSG(\"\");
375
code:     }
376
code:     return NULL;
377
code:   }
378
 
379
 
380
############################################################################
381
# case statement sections
382
############################################################################
383
type:           code-case-statements
384
process:        code-case-statements
385
skipif:         $mib->{'access'} =~ /NoAccess/
386
 
387
code:               case $NAME:
388
code:                   " . (($mib->{'access'} =~ /ReadWrite|WriteOnly|Create/) ? "*write_method = write_$mib->{label};" : "") . "
389
code:           $variables{$mib->{'type'}}{'case'}
390
code:
391
 
392
############################################################################
393
# storage structure information
394
############################################################################
395
type:           variable-structure-info
396
process:        variable-structure-info
397
skipif:         $mib->{'access'} =~ /NoAccess/
398
code:           " . sprintf("#define   %-20s  $count", $NAME) . "
399
code:           " . sprintf("  { %-20s, %-14s, %-6.6s, %s, %d, { %s } },", $NAME, $variables{$mib->{'type'}}{'asnType'}, $accessToUCD{$mib->{'access'}}, "var_$vroutine", $depth-1, $subid) . "
400
 
401
############################################################################
402
# write function defitition, also appended to the end of the .c file.
403
############################################################################
404
#
405
# Header info: declair write functions for set processing
406
#
407
process:        code-write-func-decl
408
type:           code-write-func-decl
409
skipif:         $mib->{'access'} !~ /Write|Create/
410
code:           WriteMethod write_$name;
411
#
412
# C code
413
#
414
type:           code-write-func
415
process:        code-write-func
416
skipif:         $mib->{'access'} !~ /Write|Create/
417
code:   int
418
code:   write_$name(int      action,
419
code:               u_char   *var_val,
420
code:               u_char   var_val_type,
421
code:               size_t   var_val_len,
422
code:               u_char   *statP,
423
code:               oid      *name,
424
code:               size_t   name_len)
425
code:   {
426
code:     $variables{$mib->{'type'}}{writeInit}
427
code:     int size;
428
code:
429
code:     switch ( action ) {
430
code:           case RESERVE1:
431
code:             if (var_val_type != $variables{$mib->{'type'}}{asnType}){
432
code:                 fprintf(stderr, \"write to $name not $variables{$mib->{'type'}}{asnType}\\n\");
433
code:                 return SNMP_ERR_WRONGTYPE;
434
code:             }
435
code:             if (var_val_len > sizeof($variables{$mib->{'type'}}{variable})){
436
code:                 fprintf(stderr,\"write to $name: bad length\\n\");
437
code:                 return SNMP_ERR_WRONGLENGTH;
438
code:             }
439
code:             break;
440
code:
441
code:           case RESERVE2:
442
code:             size = var_val_len;
443
code:             $variables{$mib->{'type'}}{variable} = ($variables{$mib->{'type'}}{cast}) var_val;
444
code:
445
code:             break;
446
code:
447
code:           case FREE:
448
code:                /* Release any resources that have been allocated */
449
code:             break;
450
code:
451
code:           case ACTION:
452
code:                /* The variable has been stored in $variables{$mib->{'type'}}{variable} for
453
code:                you to use, and you have just been asked to do something with
454
code:                it.  Note that anything done here must be reversable in the UNDO case */
455
code:             break;
456
code:
457
code:           case UNDO:
458
code:                /* Back out any changes made in the ACTION case */
459
code:             break;
460
code:
461
code:           case COMMIT:
462
code:                /* Things are working well, so it's now safe to make the change
463
code:                permanently.  Make sure that anything done here can't fail! */
464
code:             break;
465
code:     }
466
code:     return SNMP_ERR_NOERROR;
467
code:   }
468
code:
469
code:

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.