[go: up one dir, main page]

File: sonet-mib.c

package info (click to toggle)
scli 0.3.1-3.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,872 kB
  • ctags: 8,627
  • sloc: ansic: 32,657; sh: 7,388; makefile: 321
file content (730 lines) | stat: -rw-r--r-- 25,633 bytes parent folder | download
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
/*							-- DO NOT EDIT --
 * Generated by smidump version 0.4.3:
 *   smidump -f scli \
 *     --scli-include='sonetMediumEntry|sonetSection' SONET-MIB
 *
 * Derived from SONET-MIB:
 *   The MIB module to describe SONET/SDH interface objects.
 *   
 *   Copyright (C) The Internet Society (2003).  This version
 *   of this MIB module is part of RFC 3592;  see the RFC
 *   itself for full legal notices.
 *
 * Revision 2003-08-11 00:00:
 *   The key changes made to this MIB module
 *   since its publication in RFC 2558
 *   are as follows.
 *   
 *   (1) Corrected typographical error
 *       (bellcore1991(2) in sonetSESthresholdSet)
 *   
 *   (2) Added support for sts192cSTM64(6) and
 *       sts768cSTM256(7) in sonetPathCurrentWidth
 *   
 *   (3) Corrected description of the applicability
 *       of VTs for SDH for improved accuracy
 *   
 *   (4) Added clarification in the SES description that
 *       CV counts should be frozen during SESs
 *   
 *   (5) Corrected typographical errors:
 *       - Line Alarm Indication Signal description of the
 *         Terminology section (20.5 --> 2.5 seconds)
 *       - In the Terminology section
 *         sonetSESThresholdSet  --> sonetSESthresholdSet
 *       
 *
 * Revision 1998-10-19 00:00:
 *   The RFC 2558 version of this MIB module.
 *   
 *   
 *   
 *   
 *   
 *   The key changes made to this MIB module
 *   since its initial publication in RFC 1595
 *   are as follows.
 *   
 *   (1) The MODULE-IDENTITY has been updated to reflect the
 *       changes to the MIB.
 *   
 *   (2) Where applicable, the textual conventions
 *       PerfCurrentCount and PerfIntervalCount from
 *       PerfHist-TC-MIB have been used in place of Gauge32.
 *   
 *   (3) An agent now has the option to delay updates to
 *       the various performance counts in lieu of performing
 *       retroactive adjustments upon entering into or exiting
 *       from unavailable time. This implementation option is
 *       described in Appendix A of this memo.
 *   
 *   (4) In order to make the SONET-MIB more useful for
 *       circuit provisioning, the formerly read-only objects
 *       sonetMediumType, sonetMediumLineCoding,
 *       sonetMediumLineType, and sonetMediumCircuitIdentifier
 *       have been given a MAX-ACCESS of read-write. The
 *       MIN-ACCESS remains read-only.
 *   
 *   (5) The DESCRIPTION clause for sonetMediumTimeElapsed has
 *       been updated to describe its behaviour if the duration
 *       of the current interval exceeds the maximum value.
 *   
 *   (6) The DESCRIPTION clause for sonetMediumValidIntervals
 *       has been updated to describe its behaviour when some
 *       intervals may be unavailable, and the object
 *       sonetMediumInvalidIntervals has been added to keep
 *       count of the number of missing intervals (if any).
 *   
 *   (7) The object sonetMediumLoopbackConfig has been added
 *       to enable or disable loopback configurations.
 *   
 *   (8) Because the error count thresholds for declaring
 *       severely errored seconds that are specified in ANSI
 *       T1.231-1993, ITU-T G.826-1995, and ANSI T1.231-1997
 *       are all different from each other and from the thresholds
 *       specified in RFC 1595, an enumerated INTEGER object
 *       sonetSESthresholdSet has been added to allow an agent
 *       to specify which threshold set is in use. Text has
 *       been added to Section 3 stating that if this object is
 *       not implemented the thresholds specified in RFC 1595
 *       should be assumed, and the table containing those
 *       thresholds has been moved to Appendix B of this memo.
 *   
 *   
 *   
 *   (9) A column with SYNTAX TruthValue has been added to each
 *       interval table.  The purpose of the additional column
 *       is to indicate, for each interval, whether the data
 *       is valid in the sense intended by ANSI T1.231 clause
 *       9.1.2.2 [T1.231a][T1.231b]. The objects in question are:
 *   
 *           sonetSectionIntervalValidData
 *           sonetLineIntervalValidData
 *           sonetFarEndLineIntervalValidData
 *           sonetPathIntervalValidData
 *           sonetFarEndPathIntervalValidData
 *           sonetVTIntervalValidData
 *           sonetFarEndVTIntervalValidData
 *   
 *   (10) The ranges for sonetPathCurrentStatus and
 *       sonetVTCurrentStatus have been made consistent
 *       with the DESCRIPTION clauses.
 *   
 *   (11) The conformance information has been updated. Previous
 *       conformance information from RFC 1595 has been
 *       deprecated. Some typographical errors in the deprecated
 *       section have been corrected in order to prevent
 *       MIB compilation errors.
 *
 * Revision 1994-01-03 00:00:
 *   The RFC 1595 version of this MIB module.
 *
 * $Id: sonet-mib.c 1788 2006-02-21 20:47:18Z schoenw $
 */

#include "sonet-mib.h"

GNetSnmpEnum const sonet_mib_enums_sonetMediumType[] = {
    { SONET_MIB_SONETMEDIUMTYPE_SONET, "sonet" },
    { SONET_MIB_SONETMEDIUMTYPE_SDH,   "sdh" },
    { 0, NULL }
};

GNetSnmpEnum const sonet_mib_enums_sonetMediumLineCoding[] = {
    { SONET_MIB_SONETMEDIUMLINECODING_SONETMEDIUMOTHER, "sonetMediumOther" },
    { SONET_MIB_SONETMEDIUMLINECODING_SONETMEDIUMB3ZS,  "sonetMediumB3ZS" },
    { SONET_MIB_SONETMEDIUMLINECODING_SONETMEDIUMCMI,   "sonetMediumCMI" },
    { SONET_MIB_SONETMEDIUMLINECODING_SONETMEDIUMNRZ,   "sonetMediumNRZ" },
    { SONET_MIB_SONETMEDIUMLINECODING_SONETMEDIUMRZ,    "sonetMediumRZ" },
    { 0, NULL }
};

GNetSnmpEnum const sonet_mib_enums_sonetMediumLineType[] = {
    { SONET_MIB_SONETMEDIUMLINETYPE_SONETOTHER,           "sonetOther" },
    { SONET_MIB_SONETMEDIUMLINETYPE_SONETSHORTSINGLEMODE, "sonetShortSingleMode" },
    { SONET_MIB_SONETMEDIUMLINETYPE_SONETLONGSINGLEMODE,  "sonetLongSingleMode" },
    { SONET_MIB_SONETMEDIUMLINETYPE_SONETMULTIMODE,       "sonetMultiMode" },
    { SONET_MIB_SONETMEDIUMLINETYPE_SONETCOAX,            "sonetCoax" },
    { SONET_MIB_SONETMEDIUMLINETYPE_SONETUTP,             "sonetUTP" },
    { 0, NULL }
};


static gint32 sonetMediumTimeElapsed_constraints[] = {1L, 900L, 0, 0};
static gint32 sonetMediumValidIntervals_constraints[] = {0L, 96L, 0, 0};
static guint16 sonetMediumCircuitIdentifier_constraints[] = {0U, 255U, 0, 0};
static gint32 sonetMediumInvalidIntervals_constraints[] = {0L, 96L, 0, 0};
static gint32 sonetSectionCurrentStatus_constraints[] = {1L, 6L, 0, 0};


static guint32 const sonetMediumEntry_oid[] = {1, 3, 6, 1, 2, 1, 10, 39, 1, 1, 1, 1};

static GNetSnmpAttribute sonetMediumEntry_attr[] = {
    { 1, GNET_SNMP_VARBIND_TYPE_INTEGER32,
      SONET_MIB_SONETMEDIUMTYPE, "sonetMediumType",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetMediumEntry_t, sonetMediumType),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 2, GNET_SNMP_VARBIND_TYPE_INTEGER32,
      SONET_MIB_SONETMEDIUMTIMEELAPSED, "sonetMediumTimeElapsed",
       sonetMediumTimeElapsed_constraints,
      G_STRUCT_OFFSET(sonet_mib_sonetMediumEntry_t, sonetMediumTimeElapsed),
      0,
      0 },
    { 3, GNET_SNMP_VARBIND_TYPE_INTEGER32,
      SONET_MIB_SONETMEDIUMVALIDINTERVALS, "sonetMediumValidIntervals",
       sonetMediumValidIntervals_constraints,
      G_STRUCT_OFFSET(sonet_mib_sonetMediumEntry_t, sonetMediumValidIntervals),
      0,
      0 },
    { 4, GNET_SNMP_VARBIND_TYPE_INTEGER32,
      SONET_MIB_SONETMEDIUMLINECODING, "sonetMediumLineCoding",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetMediumEntry_t, sonetMediumLineCoding),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 5, GNET_SNMP_VARBIND_TYPE_INTEGER32,
      SONET_MIB_SONETMEDIUMLINETYPE, "sonetMediumLineType",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetMediumEntry_t, sonetMediumLineType),
      0,
      GSNMP_ATTR_FLAG_WRITABLE },
    { 6, GNET_SNMP_VARBIND_TYPE_OCTETSTRING,
      SONET_MIB_SONETMEDIUMCIRCUITIDENTIFIER, "sonetMediumCircuitIdentifier",
       sonetMediumCircuitIdentifier_constraints,
      G_STRUCT_OFFSET(sonet_mib_sonetMediumEntry_t, sonetMediumCircuitIdentifier),
      G_STRUCT_OFFSET(sonet_mib_sonetMediumEntry_t, _sonetMediumCircuitIdentifierLength),
      GSNMP_ATTR_FLAG_WRITABLE },
    { 7, GNET_SNMP_VARBIND_TYPE_INTEGER32,
      SONET_MIB_SONETMEDIUMINVALIDINTERVALS, "sonetMediumInvalidIntervals",
       sonetMediumInvalidIntervals_constraints,
      G_STRUCT_OFFSET(sonet_mib_sonetMediumEntry_t, sonetMediumInvalidIntervals),
      0,
      0 },
    { 8, GNET_SNMP_VARBIND_TYPE_OCTETSTRING,
      SONET_MIB_SONETMEDIUMLOOPBACKCONFIG, "sonetMediumLoopbackConfig",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetMediumEntry_t, sonetMediumLoopbackConfig),
      G_STRUCT_OFFSET(sonet_mib_sonetMediumEntry_t, _sonetMediumLoopbackConfigLength),
      GSNMP_ATTR_FLAG_WRITABLE },
    { 0, 0, 0, NULL }
};

static guint32 const sonetSectionCurrentEntry_oid[] = {1, 3, 6, 1, 2, 1, 10, 39, 1, 2, 1, 1};

static GNetSnmpAttribute sonetSectionCurrentEntry_attr[] = {
    { 1, GNET_SNMP_VARBIND_TYPE_INTEGER32,
      SONET_MIB_SONETSECTIONCURRENTSTATUS, "sonetSectionCurrentStatus",
       sonetSectionCurrentStatus_constraints,
      G_STRUCT_OFFSET(sonet_mib_sonetSectionCurrentEntry_t, sonetSectionCurrentStatus),
      0,
      0 },
    { 2, GNET_SNMP_VARBIND_TYPE_UNSIGNED32,
      SONET_MIB_SONETSECTIONCURRENTESS, "sonetSectionCurrentESs",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetSectionCurrentEntry_t, sonetSectionCurrentESs),
      0,
      0 },
    { 3, GNET_SNMP_VARBIND_TYPE_UNSIGNED32,
      SONET_MIB_SONETSECTIONCURRENTSESS, "sonetSectionCurrentSESs",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetSectionCurrentEntry_t, sonetSectionCurrentSESs),
      0,
      0 },
    { 4, GNET_SNMP_VARBIND_TYPE_UNSIGNED32,
      SONET_MIB_SONETSECTIONCURRENTSEFSS, "sonetSectionCurrentSEFSs",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetSectionCurrentEntry_t, sonetSectionCurrentSEFSs),
      0,
      0 },
    { 5, GNET_SNMP_VARBIND_TYPE_UNSIGNED32,
      SONET_MIB_SONETSECTIONCURRENTCVS, "sonetSectionCurrentCVs",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetSectionCurrentEntry_t, sonetSectionCurrentCVs),
      0,
      0 },
    { 0, 0, 0, NULL }
};

static guint32 const sonetSectionIntervalEntry_oid[] = {1, 3, 6, 1, 2, 1, 10, 39, 1, 2, 2, 1};

static GNetSnmpAttribute sonetSectionIntervalEntry_attr[] = {
    { 2, GNET_SNMP_VARBIND_TYPE_UNSIGNED32,
      SONET_MIB_SONETSECTIONINTERVALESS, "sonetSectionIntervalESs",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetSectionIntervalEntry_t, sonetSectionIntervalESs),
      0,
      0 },
    { 3, GNET_SNMP_VARBIND_TYPE_UNSIGNED32,
      SONET_MIB_SONETSECTIONINTERVALSESS, "sonetSectionIntervalSESs",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetSectionIntervalEntry_t, sonetSectionIntervalSESs),
      0,
      0 },
    { 4, GNET_SNMP_VARBIND_TYPE_UNSIGNED32,
      SONET_MIB_SONETSECTIONINTERVALSEFSS, "sonetSectionIntervalSEFSs",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetSectionIntervalEntry_t, sonetSectionIntervalSEFSs),
      0,
      0 },
    { 5, GNET_SNMP_VARBIND_TYPE_UNSIGNED32,
      SONET_MIB_SONETSECTIONINTERVALCVS, "sonetSectionIntervalCVs",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetSectionIntervalEntry_t, sonetSectionIntervalCVs),
      0,
      0 },
    { 6, GNET_SNMP_VARBIND_TYPE_INTEGER32,
      SONET_MIB_SONETSECTIONINTERVALVALIDDATA, "sonetSectionIntervalValidData",
       NULL,
      G_STRUCT_OFFSET(sonet_mib_sonetSectionIntervalEntry_t, sonetSectionIntervalValidData),
      0,
      0 },
    { 0, 0, 0, NULL }
};


sonet_mib_sonetMediumEntry_t *
sonet_mib_new_sonetMediumEntry()
{
    sonet_mib_sonetMediumEntry_t *sonetMediumEntry;

    sonetMediumEntry = (sonet_mib_sonetMediumEntry_t *) g_malloc0(sizeof(sonet_mib_sonetMediumEntry_t) + sizeof(gpointer));
    return sonetMediumEntry;
}

static inline int
unpack_sonetMediumEntry(GNetSnmpVarBind *vb, sonet_mib_sonetMediumEntry_t *sonetMediumEntry)
{
    guint8 idx = 13;

    if (vb->oid_len < idx) return -1;
    sonetMediumEntry->ifIndex = vb->oid[idx++];
    if ((sonetMediumEntry->ifIndex < 1)) {
         return -1;
    }
    if (vb->oid_len > idx) return -1;
    return 0;
}

static inline gint8
pack_sonetMediumEntry(guint32 *base, gint32 ifIndex)
{
    guint8 idx = 13;

    base[idx++] = ifIndex;
    return idx;
}

static inline sonet_mib_sonetMediumEntry_t *
assign_sonetMediumEntry(GList *vbl)
{
    sonet_mib_sonetMediumEntry_t *sonetMediumEntry;
    char *p;

    sonetMediumEntry = sonet_mib_new_sonetMediumEntry();
    p = (char *) sonetMediumEntry + sizeof(sonet_mib_sonetMediumEntry_t);
    * (GList **) p = vbl;

    if (unpack_sonetMediumEntry((GNetSnmpVarBind *) vbl->data, sonetMediumEntry) < 0) {
        g_warning("%s: invalid instance identifier", "sonetMediumEntry");
        g_free(sonetMediumEntry);
        return NULL;
    }

    gnet_snmp_attr_assign(vbl, sonetMediumEntry_oid, G_N_ELEMENTS(sonetMediumEntry_oid),
                      sonetMediumEntry_attr, sonetMediumEntry);

    return sonetMediumEntry;
}

void
sonet_mib_get_sonetMediumTable(GNetSnmp *s, sonet_mib_sonetMediumEntry_t ***sonetMediumEntry, gint64 mask)
{
    GList *in = NULL, *out = NULL;
    GList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 10, 39, 1, 1, 1, 1, 0};

    *sonetMediumEntry = NULL;

    gnet_snmp_attr_get(s, &in, base, 13, 12, sonetMediumEntry_attr, mask);

    out = gnet_snmp_sync_table(s, in);
    /* gnet_snmp_varbind_list_free(in); */

    if (out) {
        *sonetMediumEntry = (sonet_mib_sonetMediumEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(sonet_mib_sonetMediumEntry_t *));
        for (row = out, i = 0; row; row = g_list_next(row), i++) {
            (*sonetMediumEntry)[i] = assign_sonetMediumEntry(row->data);
        }
    }
}

void
sonet_mib_get_sonetMediumEntry(GNetSnmp *s, sonet_mib_sonetMediumEntry_t **sonetMediumEntry, gint32 ifIndex, gint64 mask)
{
    GList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memcpy(base, sonetMediumEntry_oid, sizeof(sonetMediumEntry_oid));
    len = pack_sonetMediumEntry(base, ifIndex);
    if (len < 0) {
        g_warning("%s: invalid index values", "sonetMediumEntry");
        s->error_status = GNET_SNMP_PDU_ERR_INTERNAL;
        return;
    }

    *sonetMediumEntry = NULL;

    gnet_snmp_attr_get(s, &in, base, len, 12, sonetMediumEntry_attr, mask);

    out = gnet_snmp_sync_get(s, in);
    g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL);
    g_list_free(in);
    if (out) {
        if (s->error_status != GNET_SNMP_PDU_ERR_NOERROR) {
            g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL);
            g_list_free(out);
            return;
        }
        *sonetMediumEntry = assign_sonetMediumEntry(out);
    }
}

void
sonet_mib_set_sonetMediumEntry(GNetSnmp *s, sonet_mib_sonetMediumEntry_t *sonetMediumEntry, gint64 mask)
{
    GList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memcpy(base, sonetMediumEntry_oid, sizeof(sonetMediumEntry_oid));
    len = pack_sonetMediumEntry(base, sonetMediumEntry->ifIndex);
    if (len < 0) {
        g_warning("%s: invalid index values", "sonetMediumEntry");
        s->error_status = GNET_SNMP_PDU_ERR_INTERNAL;
        return;
    }

    gnet_snmp_attr_set(s, &in, base, len, 12, sonetMediumEntry_attr, mask, sonetMediumEntry);

    out = gnet_snmp_sync_set(s, in);
    g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL);
    g_list_free(in);
    if (out) {
        g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL);
        g_list_free(out);
    }
}

void
sonet_mib_free_sonetMediumEntry(sonet_mib_sonetMediumEntry_t *sonetMediumEntry)
{
    GList *vbl;
    char *p;

    if (sonetMediumEntry) {
        p = (char *) sonetMediumEntry + sizeof(sonet_mib_sonetMediumEntry_t);
        vbl = * (GList **) p;
        g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL);
        g_list_free(vbl);
        g_free(sonetMediumEntry);
    }
}

void
sonet_mib_free_sonetMediumTable(sonet_mib_sonetMediumEntry_t **sonetMediumEntry)
{
    int i;

    if (sonetMediumEntry) {
        for (i = 0; sonetMediumEntry[i]; i++) {
            sonet_mib_free_sonetMediumEntry(sonetMediumEntry[i]);
        }
        g_free(sonetMediumEntry);
    }
}

sonet_mib_sonetSectionCurrentEntry_t *
sonet_mib_new_sonetSectionCurrentEntry()
{
    sonet_mib_sonetSectionCurrentEntry_t *sonetSectionCurrentEntry;

    sonetSectionCurrentEntry = (sonet_mib_sonetSectionCurrentEntry_t *) g_malloc0(sizeof(sonet_mib_sonetSectionCurrentEntry_t) + sizeof(gpointer));
    return sonetSectionCurrentEntry;
}

static inline int
unpack_sonetSectionCurrentEntry(GNetSnmpVarBind *vb, sonet_mib_sonetSectionCurrentEntry_t *sonetSectionCurrentEntry)
{
    guint8 idx = 13;

    if (vb->oid_len < idx) return -1;
    sonetSectionCurrentEntry->ifIndex = vb->oid[idx++];
    if ((sonetSectionCurrentEntry->ifIndex < 1)) {
         return -1;
    }
    if (vb->oid_len > idx) return -1;
    return 0;
}

static inline gint8
pack_sonetSectionCurrentEntry(guint32 *base, gint32 ifIndex)
{
    guint8 idx = 13;

    base[idx++] = ifIndex;
    return idx;
}

static inline sonet_mib_sonetSectionCurrentEntry_t *
assign_sonetSectionCurrentEntry(GList *vbl)
{
    sonet_mib_sonetSectionCurrentEntry_t *sonetSectionCurrentEntry;
    char *p;

    sonetSectionCurrentEntry = sonet_mib_new_sonetSectionCurrentEntry();
    p = (char *) sonetSectionCurrentEntry + sizeof(sonet_mib_sonetSectionCurrentEntry_t);
    * (GList **) p = vbl;

    if (unpack_sonetSectionCurrentEntry((GNetSnmpVarBind *) vbl->data, sonetSectionCurrentEntry) < 0) {
        g_warning("%s: invalid instance identifier", "sonetSectionCurrentEntry");
        g_free(sonetSectionCurrentEntry);
        return NULL;
    }

    gnet_snmp_attr_assign(vbl, sonetSectionCurrentEntry_oid, G_N_ELEMENTS(sonetSectionCurrentEntry_oid),
                      sonetSectionCurrentEntry_attr, sonetSectionCurrentEntry);

    return sonetSectionCurrentEntry;
}

void
sonet_mib_get_sonetSectionCurrentTable(GNetSnmp *s, sonet_mib_sonetSectionCurrentEntry_t ***sonetSectionCurrentEntry, gint64 mask)
{
    GList *in = NULL, *out = NULL;
    GList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 10, 39, 1, 2, 1, 1, 0};

    *sonetSectionCurrentEntry = NULL;

    gnet_snmp_attr_get(s, &in, base, 13, 12, sonetSectionCurrentEntry_attr, mask);

    out = gnet_snmp_sync_table(s, in);
    /* gnet_snmp_varbind_list_free(in); */

    if (out) {
        *sonetSectionCurrentEntry = (sonet_mib_sonetSectionCurrentEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(sonet_mib_sonetSectionCurrentEntry_t *));
        for (row = out, i = 0; row; row = g_list_next(row), i++) {
            (*sonetSectionCurrentEntry)[i] = assign_sonetSectionCurrentEntry(row->data);
        }
    }
}

void
sonet_mib_get_sonetSectionCurrentEntry(GNetSnmp *s, sonet_mib_sonetSectionCurrentEntry_t **sonetSectionCurrentEntry, gint32 ifIndex, gint64 mask)
{
    GList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memcpy(base, sonetSectionCurrentEntry_oid, sizeof(sonetSectionCurrentEntry_oid));
    len = pack_sonetSectionCurrentEntry(base, ifIndex);
    if (len < 0) {
        g_warning("%s: invalid index values", "sonetSectionCurrentEntry");
        s->error_status = GNET_SNMP_PDU_ERR_INTERNAL;
        return;
    }

    *sonetSectionCurrentEntry = NULL;

    gnet_snmp_attr_get(s, &in, base, len, 12, sonetSectionCurrentEntry_attr, mask);

    out = gnet_snmp_sync_get(s, in);
    g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL);
    g_list_free(in);
    if (out) {
        if (s->error_status != GNET_SNMP_PDU_ERR_NOERROR) {
            g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL);
            g_list_free(out);
            return;
        }
        *sonetSectionCurrentEntry = assign_sonetSectionCurrentEntry(out);
    }
}

void
sonet_mib_free_sonetSectionCurrentEntry(sonet_mib_sonetSectionCurrentEntry_t *sonetSectionCurrentEntry)
{
    GList *vbl;
    char *p;

    if (sonetSectionCurrentEntry) {
        p = (char *) sonetSectionCurrentEntry + sizeof(sonet_mib_sonetSectionCurrentEntry_t);
        vbl = * (GList **) p;
        g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL);
        g_list_free(vbl);
        g_free(sonetSectionCurrentEntry);
    }
}

void
sonet_mib_free_sonetSectionCurrentTable(sonet_mib_sonetSectionCurrentEntry_t **sonetSectionCurrentEntry)
{
    int i;

    if (sonetSectionCurrentEntry) {
        for (i = 0; sonetSectionCurrentEntry[i]; i++) {
            sonet_mib_free_sonetSectionCurrentEntry(sonetSectionCurrentEntry[i]);
        }
        g_free(sonetSectionCurrentEntry);
    }
}

sonet_mib_sonetSectionIntervalEntry_t *
sonet_mib_new_sonetSectionIntervalEntry()
{
    sonet_mib_sonetSectionIntervalEntry_t *sonetSectionIntervalEntry;

    sonetSectionIntervalEntry = (sonet_mib_sonetSectionIntervalEntry_t *) g_malloc0(sizeof(sonet_mib_sonetSectionIntervalEntry_t) + sizeof(gpointer));
    return sonetSectionIntervalEntry;
}

static inline int
unpack_sonetSectionIntervalEntry(GNetSnmpVarBind *vb, sonet_mib_sonetSectionIntervalEntry_t *sonetSectionIntervalEntry)
{
    guint8 idx = 13;

    if (vb->oid_len < idx) return -1;
    sonetSectionIntervalEntry->ifIndex = vb->oid[idx++];
    if ((sonetSectionIntervalEntry->ifIndex < 1)) {
         return -1;
    }
    if (vb->oid_len < idx) return -1;
    sonetSectionIntervalEntry->sonetSectionIntervalNumber = vb->oid[idx++];
    if ((sonetSectionIntervalEntry->sonetSectionIntervalNumber < 1 || sonetSectionIntervalEntry->sonetSectionIntervalNumber > 96)) {
         return -1;
    }
    if (vb->oid_len > idx) return -1;
    return 0;
}

static inline gint8
pack_sonetSectionIntervalEntry(guint32 *base, gint32 ifIndex, gint32 sonetSectionIntervalNumber)
{
    guint8 idx = 13;

    base[idx++] = ifIndex;
    base[idx++] = sonetSectionIntervalNumber;
    return idx;
}

static inline sonet_mib_sonetSectionIntervalEntry_t *
assign_sonetSectionIntervalEntry(GList *vbl)
{
    sonet_mib_sonetSectionIntervalEntry_t *sonetSectionIntervalEntry;
    char *p;

    sonetSectionIntervalEntry = sonet_mib_new_sonetSectionIntervalEntry();
    p = (char *) sonetSectionIntervalEntry + sizeof(sonet_mib_sonetSectionIntervalEntry_t);
    * (GList **) p = vbl;

    if (unpack_sonetSectionIntervalEntry((GNetSnmpVarBind *) vbl->data, sonetSectionIntervalEntry) < 0) {
        g_warning("%s: invalid instance identifier", "sonetSectionIntervalEntry");
        g_free(sonetSectionIntervalEntry);
        return NULL;
    }

    gnet_snmp_attr_assign(vbl, sonetSectionIntervalEntry_oid, G_N_ELEMENTS(sonetSectionIntervalEntry_oid),
                      sonetSectionIntervalEntry_attr, sonetSectionIntervalEntry);

    return sonetSectionIntervalEntry;
}

void
sonet_mib_get_sonetSectionIntervalTable(GNetSnmp *s, sonet_mib_sonetSectionIntervalEntry_t ***sonetSectionIntervalEntry, gint64 mask)
{
    GList *in = NULL, *out = NULL;
    GList *row;
    int i;
    static guint32 base[] = {1, 3, 6, 1, 2, 1, 10, 39, 1, 2, 2, 1, 0};

    *sonetSectionIntervalEntry = NULL;

    gnet_snmp_attr_get(s, &in, base, 13, 12, sonetSectionIntervalEntry_attr, mask);

    out = gnet_snmp_sync_table(s, in);
    /* gnet_snmp_varbind_list_free(in); */

    if (out) {
        *sonetSectionIntervalEntry = (sonet_mib_sonetSectionIntervalEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(sonet_mib_sonetSectionIntervalEntry_t *));
        for (row = out, i = 0; row; row = g_list_next(row), i++) {
            (*sonetSectionIntervalEntry)[i] = assign_sonetSectionIntervalEntry(row->data);
        }
    }
}

void
sonet_mib_get_sonetSectionIntervalEntry(GNetSnmp *s, sonet_mib_sonetSectionIntervalEntry_t **sonetSectionIntervalEntry, gint32 ifIndex, gint32 sonetSectionIntervalNumber, gint64 mask)
{
    GList *in = NULL, *out = NULL;
    guint32 base[128];
    gint8 len;

    memcpy(base, sonetSectionIntervalEntry_oid, sizeof(sonetSectionIntervalEntry_oid));
    len = pack_sonetSectionIntervalEntry(base, ifIndex, sonetSectionIntervalNumber);
    if (len < 0) {
        g_warning("%s: invalid index values", "sonetSectionIntervalEntry");
        s->error_status = GNET_SNMP_PDU_ERR_INTERNAL;
        return;
    }

    *sonetSectionIntervalEntry = NULL;

    gnet_snmp_attr_get(s, &in, base, len, 12, sonetSectionIntervalEntry_attr, mask);

    out = gnet_snmp_sync_get(s, in);
    g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL);
    g_list_free(in);
    if (out) {
        if (s->error_status != GNET_SNMP_PDU_ERR_NOERROR) {
            g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL);
            g_list_free(out);
            return;
        }
        *sonetSectionIntervalEntry = assign_sonetSectionIntervalEntry(out);
    }
}

void
sonet_mib_free_sonetSectionIntervalEntry(sonet_mib_sonetSectionIntervalEntry_t *sonetSectionIntervalEntry)
{
    GList *vbl;
    char *p;

    if (sonetSectionIntervalEntry) {
        p = (char *) sonetSectionIntervalEntry + sizeof(sonet_mib_sonetSectionIntervalEntry_t);
        vbl = * (GList **) p;
        g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL);
        g_list_free(vbl);
        g_free(sonetSectionIntervalEntry);
    }
}

void
sonet_mib_free_sonetSectionIntervalTable(sonet_mib_sonetSectionIntervalEntry_t **sonetSectionIntervalEntry)
{
    int i;

    if (sonetSectionIntervalEntry) {
        for (i = 0; sonetSectionIntervalEntry[i]; i++) {
            sonet_mib_free_sonetSectionIntervalEntry(sonetSectionIntervalEntry[i]);
        }
        g_free(sonetSectionIntervalEntry);
    }
}