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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 27 unneback
# mib2c.storage.conf:
2
#
3
#  This is a special mib2c.conf file that assumes that you want to do
4
#  all storage of information locally rather than pulling the
5
#  information from another source outside the agent (EG, the
6
#  kernel).  To accomplish this, it defines a structure for the
7
#  storage of tables and assumes you want to use the header_complex
8
#  functions for retrieving and storing that data in a local data
9
#  store.  It even writes a .conf file parser for you and sets you up
10
#  for being able to do persistant storage fairly simply.
11
#
12
#  In short:  it trys to do almost all of the work for you...  Almost...
13
 
14
#
15
# Define types of data by mib type, and translate into needed C code.
16
#
17
 
18
# We need to get some extra stuff into the variable declarations
19
# before sourcing the main mib2c.vartypes.conf file below.
20
type:           OCTETSTR
21
storage:            char   *${name};
22
storage:            size_t  ${name}Len;
23
varlenname:     StorageTmp->${name}Len
24
vartest:          if (StorageTmp->${name} == NULL) {
25
vartest:            config_perror(\"invalid specification for ${name}\");
26
vartest:            return;
27
vartest:          }
28
vartest:
29
action:              tmpvar = StorageTmp->$name;
30
action:              tmplen = StorageTmp->${name}Len;
31
action:              memdup((u_char **) &StorageTmp->$name, var_val, var_val_len);
32
action:              StorageTmp->${name}Len = var_val_len;
33
undo:                SNMP_FREE(StorageTmp->${name});
34
undo:                StorageTmp->${name} = tmpvar;
35
undo:                StorageTmp->${name}Len = tmplen;
36
commit:              SNMP_FREE(tmpvar);
37
sizeofstart:
38
sizeofend:      Len
39
tmpvar:         char *
40
casttmp:        strdup((char *) tmpvar);
41
#
42
type:           INTEGER
43
storage:            long    $name;
44
storageret:     &
45
varlenname:     tmpint
46
sizeofstart:    sizeof(
47
sizeofend:      )
48
tmpvar:         int
49
action:              tmpvar = StorageTmp->$name;
50
action:              StorageTmp->${name} = *((long *) var_val);
51
undo:                StorageTmp->${name} = tmpvar;
52
casttmp:        tmpvar;
53
#
54
type:           OBJECTID
55
storage:            oid     *$name;
56
storage:            size_t   ${name}Len
57
varlenname:     StorageTmp->${name}Len
58
vartest:          if (StorageTmp->${name} == NULL) {
59
vartest:            config_perror(\"invalid specification for ${name}\");
60
vartest:            return;
61
vartest:          }
62
vartest:
63
action:              tmpvar = StorageTmp->$name;
64
action:              tmplen = StorageTmp->${name}Len;
65
action:              memdup((u_char **) &StorageTmp->$name, var_val, var_val_len);
66
action:              StorageTmp->${name}Len = var_val_len/sizeof(oid);
67
undo:                SNMP_FREE(StorageTmp->${name});
68
undo:                StorageTmp->${name} = tmpvar;
69
undo:                StorageTmp->${name}Len = tmplen;
70
commit:              SNMP_FREE(tmpvar);
71
sizeofstart:
72
sizeofend:      Len
73
tmpvar:         oid *
74
casttmp:        (oid *) tmpvar;
75
freetmp:        SNMP_FREE(tmpvar);
76
#
77
type:           COUNTER64
78
storage:            struct counter64 $name;
79
varlenname:     tmpint
80
sizeofstart:    sizeof(
81
sizeofend:      )
82
tmpvar:         struct counter64 *
83
casttmp:        (struct counter64 *) tmpvar;
84
 
85
############################################################################
86
# source variable typing information:
87
include: mib2c.vartypes.conf
88
 
89
############################################################################
90
# The .h file
91
############################################################################
92
type:   code-dot-h
93
code:   /* This file was generated by mib2c and is intended for use as a mib module
94
code:     for the ucd-snmp snmpd agent. */
95
code:
96
code:   #ifndef _MIBGROUP_${OUTPUTNAME}_H
97
code:   #define _MIBGROUP_${OUTPUTNAME}_H
98
code:
99
code:   /* we may use header_complex from the header_complex module */
100
code:
101
code:   config_require(header_complex)
102
code:
103
code:   /* our storage structure(s) */
104
code:   $variables{'code-structure-per-table'}{'processed'}
105
code:
106
code:   /* enum definitions from the covered mib sections */
107
code:
108
code:   $variables{'code-enums'}{'processed'}
109
code:
110
code:   /* function prototypes */
111
code:
112
code:   void   init_$outputName(void);
113
code:   $variables{'code-var-table-decl'}{'processed'}
114
code:   $variables{'code-write-func-decl'}{'processed'}
115
code:   $variables{'code-write-rowstatus-decl'}{'processed'}
116
code:
117
code:   #endif /* _MIBGROUP_${OUTPUTNAME}_H */
118
 
119
#
120
# Structure definition, one per table
121
#
122
type:           code-structure-per-table
123
processtable:   code-structure-per-table
124
 
125
code:   struct ${vtable}_data {
126
code:   $variables{$vtable}{'code-structure'}{'processed'}
127
code:   };
128
 
129
#
130
# Structure storage arrays, one per table
131
#
132
type:           code-structure-storage
133
processtable:   code-structure-storage
134
 
135
code:   static struct header_complex_index *${vtable}Storage = NULL;
136
 
137
#
138
# Structure definition line.
139
#
140
type:   code-structure
141
process: code-structure
142
 
143
code:   " . eval ("\"$variables{$mib->{'type'}}{'storage'}\"") . "
144
#$variables{$i}{'code'}\""evalstr(
145
#
146
# ENUM definitions
147
#
148
type:           code-enums
149
process:        code-enums
150
skipif: $mib->{'textualConvention'} eq "RowStatus" || $mib->{'textualConvention'} eq "StorageType"
151
 
152
code:   " . eval{ my ($i, $x); foreach $i (sort {$mib->{'enums'}{$a} <=> $mib->{'enums'}{$b}} keys(%{$mib->{'enums'}})) { $x .= sprintf("#define %-40s %d\n","${NAME}_" . uc($i),$mib->{'enums'}{$i}); } $x; } . "
153
 
154
############################################################################
155
# The .c file, top
156
############################################################################
157
type:   code-main-part
158
code:   /* This file was generated by mib2c and is intended for use as
159
code:      a mib module for the ucd-snmp snmpd agent. */
160
code:
161
code:   /* This should always be included first before anything else */
162
code:   #include 
163
code:   #if HAVE_STDLIB_H
164
code:   #include 
165
code:   #endif
166
code:   #if HAVE_STRING_H
167
code:   #include 
168
code:   #else
169
code:   #include 
170
code:   #endif
171
code:
172
code:   /* minimal include directives */
173
code:   #include \"mibincl.h\"
174
code:   #include \"header_complex.h\"
175
code:   #include \"$outputName.h\"
176
code:   #include \"snmp-tc.h\"
177
code:
178
code:   /*
179
code:    * ${outputName}_variables_oid:
180
code:    *   this is the top level oid that we want to register under.  This
181
code:    *   is essentially a prefix, with the suffix appearing in the
182
code:    *   variable below.
183
code:    */
184
code:
185
code:   oid ${outputName}_variables_oid[] = { $commaoid };
186
code:
187
code:   /*
188
code:    * variable$varlen ${outputName}_variables:
189
code:    *   this variable defines function callbacks and type return information
190
code:    *   for the $outputName mib section
191
code:    */
192
code:
193
code:   struct variable$varlen ${outputName}_variables[] = {
194
code:   /*  magic number        , variable type , ro/rw , callback fn  , L, oidsuffix */
195
code:   $variables{'variable-structure-info'}{'processed'}
196
code:   };
197
code:   /*    (L = length of the oidsuffix) */
198
code:
199
code:   /* global storage of our data, saved in and configured by header_complex() */
200
code:   $variables{'code-structure-storage'}{'processed'}
201
code:
202
code:   /*
203
code:    * init_$outputName():
204
code:    *   Initialization routine.  This is called when the agent starts up.
205
code:    *   At a minimum, registration of your variables should take place here.
206
code:    */
207
code:   void init_$outputName(void) {
208
code:     DEBUGMSGTL((\"$outputName\", \"initializing...  \"));
209
code:
210
code:     /* register ourselves with the agent to handle our mib tree */
211
code:     REGISTER_MIB(\"$outputName\", ${outputName}_variables, variable$varlen,\
212
code:                  ${outputName}_variables_oid);
213
code:
214
code:     /* register our config handler(s) to deal with registrations */
215
code:   $variables{'code-parser-registration'}{'processed'}
216
code:
217
code:     /* place any other initialization junk you need here */
218
code:
219
code:     DEBUGMSGTL((\"$outputName\", \"done.\\n\"));
220
code:   }
221
code:
222
code:   $variables{'code-parser'}{'processed'}
223
code:
224
code:   $variables{'code-var_table'}{'processed'}
225
code:
226
code:   $variables{'code-write-func'}{'processed'}
227
code:
228
code:   $variables{'code-write-rowstatus'}{'processed'}
229
 
230
############################################################################
231
# var_ function for tables, which is handled specially and used above
232
#
233
#   Note: $vtable is set to the table name in the processtable loop.
234
############################################################################
235
 
236
#
237
# header file defs first
238
#
239
type:           code-var-table-decl
240
processtable:   code-var-table-decl
241
 
242
code:   FindVarMethod var_$vtable;
243
code:   void parse_$vtable(char *, char *);
244
 
245
#
246
# .conf Parser Code per table
247
#
248
type:           code-parser-registration
249
processtable:   code-parser-registration
250
code:     snmpd_register_config_handler(\"$vtable\", parse_$vtable, NULL,
251
code:                                   \"HELP STRING\");
252
 
253
type:           code-varlist-add
254
process:        code-varlist-add
255
skipif:         $variables{$vroutine}{$name}{'isanindex'} != 1
256
code:     snmp_varlist_add_variable(&vars, NULL, 0, $variables{$mib->{type}}{asnType}, ($variables{$mib->{type}}{'cast'}) thedata->$name, $variables{$mib->{type}}{'sizeofstart'}thedata->$name$variables{$mib->{type}}{'sizeofend'}); /* $name */
257
 
258
type:           code-parser
259
processtable:   code-parser
260
 
261
code:   /*
262
code:    * ${vtable}_add(): adds a structure node to our data set
263
code:    */
264
code:   int
265
code:   ${vtable}_add(struct ${vtable}_data *thedata) {
266
code:     struct variable_list *vars = NULL;
267
code:
268
code:     DEBUGMSGTL((\"$outputName\", \"adding data...  \"));
269
code:    /* add the index variables to the varbind list, which is
270
code:       used by header_complex to index the data */
271
code:
272
code:   $variables{$vtable}{'code-varlist-add'}{'processed'}
273
code:
274
code:     header_complex_add_data(&${vtable}Storage, vars, thedata);
275
code:     DEBUGMSGTL((\"$vtable\",\"registered an entry\\n\"));
276
code:
277
code:     DEBUGMSGTL((\"$outputName\", \"done.\\n\"));
278
code:     return SNMPERR_SUCCESS;
279
code:   }
280
code:
281
code:   /*
282
code:    * parse_$vtable():
283
code:    *   parses .conf file entries needed to configure the mib.
284
code:    */
285
code:   void
286
code:   parse_$vtable(char *token, char *line) {
287
code:     size_t tmpint;
288
code:     struct ${vtable}_data *StorageTmp = SNMP_MALLOC_STRUCT(${vtable}_data);
289
code:     struct variable_list *vars = NULL;
290
code:
291
code:       DEBUGMSGTL((\"$outputName\", \"parsing config...  \"));
292
code:
293
code:     if (StorageTmp == NULL) {
294
code:       config_perror(\"malloc failure\");
295
code:       return;
296
code:     }
297
code:
298
code:   $variables{$vtable}{'code-parser-sections'}{'processed'}
299
code:
300
code:     ${vtable}_add(StorageTmp);
301
code:
302
code:     DEBUGMSGTL((\"$outputName\", \"done.\\n\"));
303
code:   }
304
code:
305
code:
306
code:   /*
307
code:    * store_$vtable():
308
code:    *   stores .conf file entries needed to configure the mib.
309
code:    */
310
code:   void
311
code:   store_$vtable(void) {
312
code:     char line[SNMP_MAXBUF];
313
code:     char *cptr;
314
code:     size_t tmpint;
315
code:     struct ${vtable}_data *StorageTmp;
316
code:     struct header_complex_index *hcindex;
317
code:
318
code:     DEBUGMSGTL((\"$outputName\", \"storing data...  \"));
319
code:
320
code:     memset(line,0,sizeof(line));
321
code:
322
code:     strcat(line, \"$vtable\");
323
code:     cptr = line + strlen(line);
324
code:
325
code:     for(hcindex=${vtable}Storage; hcindex != NULL;
326
code:         hcindex = hcindex->next) {
327
code:       StorageTmp = (struct ${vtable}_data *) hcindex->data;
328
code:
329
code:   $variables{$vtable}{'code-persistent-sections'}{'processed'}
330
code:
331
code:       snmpd_store_config(line);
332
code:     }
333
code:     DEBUGMSGTL((\"$outputName\", \"done.\\n\"));
334
code:   }
335
 
336
# individual sections for the parser
337
type:           code-parser-sections
338
process:        code-parser-sections
339
skipif:         $mib->{'access'} =~ /NoAccess/
340
 
341
code:     line = read_config_read_data($variables{$mib->{type}}{asnType}, line, &StorageTmp->$name, &" . eval ("\"$variables{$mib->{type}}{varlenname}\"") . ");
342
code:   " . eval ("\"$variables{$mib->{type}}{vartest}\"") . "
343
 
344
#
345
# .conf persistent save Code per table
346
#
347
type:           code-persistent-sections
348
process:        code-persistent-sections
349
skipif:         $mib->{'access'} =~ /NoAccess/
350
code:       cptr = read_config_store_data($variables{$mib->{type}}{asnType}, cptr, &StorageTmp->$name, &" . eval ("\"$variables{$mib->{type}}{varlenname}\"") . ");
351
 
352
#
353
# Code code per table
354
#
355
type:           code-var_table
356
processtable:   code-var_table
357
 
358
code:   /*
359
code:    * var_$vtable():
360
code:    *   Handle this table separately from the scalar value case.
361
code:    *   The workings of this are basically the same as for var_$outputName above.
362
code:    */
363
code:   unsigned char *
364
code:   var_$vtable(struct variable *vp,
365
code:               oid     *name,
366
code:               size_t  *length,
367
code:               int     exact,
368
code:               size_t  *var_len,
369
code:               WriteMethod **write_method)
370
code:   {
371
code:
372
code:   struct ${vtable}_data *StorageTmp = NULL;
373
code:
374
code:     DEBUGMSGTL((\"$outputName\", \"var_$vtable: Entering...  \\n\"));
375
code:     /*
376
code:      * this assumes you have registered all your data properly
377
cdoe:      * with header_complex_add() somewhere before this
378
code:      */
379
code:     if ((StorageTmp =
380
code:          header_complex(${vtable}Storage, vp,name,length,exact,
381
code:                              var_len,write_method)) == NULL)
382
code:       return NULL;
383
code:
384
code:     /*
385
code:      * this is where we do the value assignments for the mib results.
386
code:      */
387
code:     switch(vp->magic) {\n\n
388
code:   $variables{$vtable}{'code-case-statements'}{'processed'}
389
code:       default:
390
code:         ERROR_MSG(\"\");
391
code:     }
392
code:     return NULL;
393
code:   }
394
 
395
 
396
############################################################################
397
# case statement sections
398
############################################################################
399
type:           code-case-statements
400
process:        code-case-statements
401
skipif:         $mib->{'access'} =~ /NoAccess/
402
 
403
code:               case $NAME:
404
code:                   " . (($mib->{'access'} =~ /ReadWrite|WriteOnly|Create/) ? "*write_method = write_$mib->{label};" : "") . "
405
code:                   *var_len = $variables{$mib->{'type'}}{'sizeofstart'}StorageTmp->$mib->{label}$variables{$mib->{'type'}}{'sizeofend'};
406
code:                   return (u_char *) $variables{$mib->{'type'}}{'storageret'}StorageTmp->$mib->{label};
407
code:
408
 
409
############################################################################
410
# storage structure information
411
############################################################################
412
type:           variable-structure-info
413
process:        variable-structure-info
414
skipif:         $mib->{'access'} =~ /NoAccess/
415
code:           " . sprintf("#define   %-20s  $count", $NAME) . "
416
code:           " . sprintf("  { %-20s, %-14s, %-6.6s, %s, %d, { %s } },", $NAME, $variables{$mib->{'type'}}{'asnType'}, $accessToUCD{$mib->{'access'}}, "var_$vroutine", $depth-1, $subid) . "
417
 
418
############################################################################
419
# write function definition, also appended to the end of the .c file.
420
############################################################################
421
#
422
# Header info: declair write functions for set processing
423
#
424
process:        code-write-func-decl
425
type:           code-write-func-decl
426
skipif:         $mib->{'access'} !~ /Write|Create/
427
code:           WriteMethod write_$name;
428
#
429
# C code
430
#
431
type:           code-write-func
432
process:        code-write-func
433
skipif:         $mib->{'textualConvention'} eq "RowStatus" || $mib->{'access'} !~ /Write|Create/
434
code:   int
435
code:   write_$name(int      action,
436
code:               u_char   *var_val,
437
code:               u_char   var_val_type,
438
code:               size_t   var_val_len,
439
code:               u_char   *statP,
440
code:               oid      *name,
441
code:               size_t    name_len)
442
code:   {
443
code:     static $variables{$mib->{'type'}}{tmpvar} tmpvar;
444
code:     struct ${vroutine}_data *StorageTmp = NULL;
445
code:     static size_t tmplen;
446
code:     size_t newlen=name_len - (sizeof(${outputName}_variables_oid)/sizeof(oid) + $depth - 1);
447
code:
448
code:     DEBUGMSGTL((\"$outputName\", \"write_$name entering action=%d...  \\n\", action));
449
code:     if ((StorageTmp =
450
code:          header_complex(${vroutine}Storage, NULL,
451
code:                         &name[sizeof(${outputName}_variables_oid)/sizeof(oid) + $depth - 1],
452
code:                         &newlen, 1, NULL, NULL)) == NULL)
453
code:         return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
454
code:
455
code:     switch ( action ) {
456
code:           case RESERVE1:
457
code:             if (var_val_type != $variables{$mib->{'type'}}{asnType}){
458
code:                 fprintf(stderr, \"write to $name not $variables{$mib->{'type'}}{asnType}\\n\");
459
code:                 return SNMP_ERR_WRONGTYPE;
460
code:             }
461
code:             break;
462
code:
463
code:           case RESERVE2:
464
code:                /* memory reseveration, final preparation... */
465
code:             break;
466
code:
467
code:           case FREE:
468
code:                /* Release any resources that have been allocated */
469
code:             break;
470
code:
471
code:           case ACTION:
472
code:                /* The variable has been stored in $variables{$mib->{'type'}}{variable} for
473
code:                you to use, and you have just been asked to do something with
474
code:                it.  Note that anything done here must be reversable in the UNDO case */
475
code:           ".eval ("\"$variables{$mib->{type}}{action}\"")."
476
code:             break;
477
code:
478
code:           case UNDO:
479
code:                /* Back out any changes made in the ACTION case */
480
code:           ".eval ("\"$variables{$mib->{type}}{undo}\"")."
481
code:             break;
482
code:
483
code:           case COMMIT:
484
code:                /* Things are working well, so it's now safe to make the change
485
code:                permanently.  Make sure that anything done here can't fail! */
486
code:           ".eval ("\"$variables{$mib->{'type'}}{'commit'}\"")."
487
code:             break;
488
code:     }
489
code:     return SNMP_ERR_NOERROR;
490
code:   }
491
code:
492
code:
493
############################################################################
494
# copy memory from varlist
495
############################################################################
496
type:           code-varlist-copy
497
process:        code-varlist-copy
498
skipif:         $variables{$vroutine}{$name}{'isanindex'} != 1
499
code:               memdup((u_char **) &(StorageNew->$name),
500
code:                      vp->val.$variables{$mib->{'type'}}{variable},
501
code:                      vp->val_len);
502
code:               StorageNew->${name}Len = vp->val_len;
503
code:               vp = vp->next_variable;
504
############################################################################
505
# add null pointers to a varlist; value to be parsed later
506
############################################################################
507
type:           code-varlist-add-null
508
process:        code-varlist-add-null
509
skipif:         $variables{$vroutine}{$name}{'isanindex'} != 1
510
code:             snmp_varlist_add_variable(&vars, NULL, 0, $variables{$mib->{'type'}}{asnType}, NULL, 0); /* $name */
511
############################################################################
512
# write function definition for a RowStatus object,
513
#   - allows for creation/deletion.
514
############################################################################
515
#
516
# Header info: declair write functions for set processing
517
#
518
process:        code-write-rowstatus-decl
519
type:           code-write-rowstatus-decl
520
skipif:         $mib->{'textualConvention'} ne "RowStatus"
521
code:           WriteMethod write_$name;
522
#
523
# code
524
#
525
type:           code-write-rowstatus
526
process:        code-write-rowstatus
527
skipif:         $mib->{'textualConvention'} ne "RowStatus"
528
code:   int
529
code:   write_$name(int      action,
530
code:               u_char   *var_val,
531
code:               u_char   var_val_type,
532
code:               size_t   var_val_len,
533
code:               u_char   *statP,
534
code:               oid      *name,
535
code:               size_t    name_len)
536
code:   {
537
code:     struct ${vroutine}_data *StorageTmp = NULL;
538
code:     static struct ${vroutine}_data *StorageNew, *StorageDel;
539
code:     size_t newlen=name_len - (sizeof(${vroutine}_variables_oid)/sizeof(oid) + 3 - 1);
540
code:     static int old_value;
541
code:     int set_value;
542
code:     static struct variable_list *vars, *vp;
543
code:     struct header_complex_index *hciptr;
544
code:     char who[MAX_OID_LEN], flagName[MAX_OID_LEN];
545
code:
546
code:     StorageTmp =
547
code:       header_complex(${vroutine}Storage, NULL,
548
code:                      &name[sizeof(${vroutine}_variables_oid)/sizeof(oid) + 3 - 1],
549
code:                      &newlen, 1, NULL, NULL);
550
code:
551
code:
552
code:     if (var_val_type != ASN_INTEGER || var_val == NULL){
553
code:       fprintf(stderr, \"write to $name not ASN_INTEGER\\n\");
554
code:       return SNMP_ERR_WRONGTYPE;
555
code:     }
556
code:     set_value = *((long *) var_val);
557
code:
558
code:     /* check legal range, and notReady is reserved for us, not a user */
559
code:     if (set_value < 1 || set_value > 6 || set_value == RS_NOTREADY)
560
code:       return SNMP_ERR_INCONSISTENTVALUE;
561
code:
562
code:     switch ( action ) {
563
code:           case RESERVE1:
564
code:             /* stage one: test validity */
565
code:             if (StorageTmp == NULL) {
566
code:               /* create the row now? */
567
code:
568
code:               /* ditch illegal values now */
569
code:               if (set_value == RS_ACTIVE || set_value == RS_NOTINSERVICE)
570
code:                 return SNMP_ERR_INCONSISTENTVALUE;
571
code:
572
code:               /* destroying a non-existent row is actually legal */
573
code:               if (set_value == RS_DESTROY) {
574
code:                 return SNMP_ERR_NOERROR;
575
code:               }
576
code:
577
code:               /* illegal creation values */
578
code:               if (set_value == RS_ACTIVE || set_value == RS_NOTINSERVICE) {
579
code:                 return SNMP_ERR_INCONSISTENTVALUE;
580
code:               }
581
code:             } else {
582
code:               /* row exists.  Check for a valid state change */
583
code:               if (set_value == RS_CREATEANDGO || set_value == RS_CREATEANDWAIT) {
584
code:                 /* can't create a row that exists */
585
code:                 return SNMP_ERR_INCONSISTENTVALUE;
586
code:               }
587
code:               /* XXX: interaction with row storage type needed */
588
code:             }
589
code:             break;
590
code:
591
code:
592
code:           case RESERVE2:
593
code:             /* memory reseveration, final preparation... */
594
code:             if (StorageTmp == NULL) {
595
code:               /* creation */
596
code:               vars = NULL;
597
code:
598
code:   $variables{'code-varlist-add-null'}{'processed'}
599
code:
600
code:               if (header_complex_parse_oid(&(name[sizeof(${vroutine}_variables_oid)/sizeof(oid)+2]), newlen,
601
code:                                            vars) != SNMPERR_SUCCESS) {
602
code:                 /* XXX: free, zero vars */
603
code:                 return SNMP_ERR_INCONSISTENTNAME;
604
code:               }
605
code:               vp = vars;
606
code:
607
code:               StorageNew = SNMP_MALLOC_STRUCT(${vroutine}_data);
608
code:   $variables{'code-varlist-copy'}{'processed'}
609
code:
610
code:               StorageNew->$name = set_value;
611
code:               /* XXX: free, zero vars, no longer needed? */
612
code:             }
613
code:
614
code:             break;
615
code:
616
code:
617
code:           case FREE:
618
code:             /* XXX: free, zero vars */
619
code:             /* Release any resources that have been allocated */
620
code:             break;
621
code:
622
code:
623
code:           case ACTION:
624
code:                /* The variable has been stored in set_value for you to
625
code:                use, and you have just been asked to do something with
626
code:                it.  Note that anything done here must be reversable in
627
code:                the UNDO case */
628
code:
629
code:                if (StorageTmp == NULL) {
630
code:                  /* row creation, so add it */
631
code:                  if (StorageNew != NULL)
632
code:                    ${vroutine}_add(StorageNew);
633
code:                  /* XXX: ack, and if it is NULL? */
634
code:                } else if (set_value != RS_DESTROY) {
635
code:                  /* set the flag? */
636
code:                  old_value = StorageTmp->$name;
637
code:                  StorageTmp->$name = *((long *) var_val);
638
code:                } else {
639
code:                  /* destroy...  extract it for now */
640
code:                  hciptr =
641
code:                    header_complex_find_entry(${vroutine}Storage,
642
code:                                              StorageTmp);
643
code:                  StorageDel =
644
code:                    header_complex_extract_entry(&${vroutine}Storage,
645
code:                                                 hciptr);
646
code:                }
647
code:             break;
648
code:
649
code:
650
code:           case UNDO:
651
code:                /* Back out any changes made in the ACTION case */
652
code:                if (StorageTmp == NULL) {
653
code:                  /* row creation, so remove it again */
654
code:                  hciptr =
655
code:                    header_complex_find_entry(${vroutine}Storage,
656
code:                                              StorageTmp);
657
code:                  StorageDel =
658
code:                    header_complex_extract_entry(&${vroutine}Storage,
659
code:                                                 hciptr);
660
code:                  /* XXX: free it */
661
code:                } else if (StorageDel != NULL) {
662
code:                  /* row deletion, so add it again */
663
code:                  ${vroutine}_add(StorageDel);
664
code:                } else {
665
code:                  StorageTmp->$name = old_value;
666
code:                }
667
code:             break;
668
code:
669
code:
670
code:           case COMMIT:
671
code:                /* Things are working well, so it's now safe to make the change
672
code:                permanently.  Make sure that anything done here can't fail! */
673
code:             if (StorageDel != NULL) {
674
code:               StorageDel == 0;
675
code:               /* XXX: free it, its dead */
676
code:             }
677
code:             break;
678
code:     }
679
code:     return SNMP_ERR_NOERROR;
680
code:   }
681
code:

powered by: WebSVN 2.1.0

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