summaryrefslogtreecommitdiff
path: root/accel-pppd/extra/net-snmp/sessionTable_data_get.c
blob: 1dcea1e80a59fd98376c8491f16d074bc9c6d2b2 (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
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
/*
 * Note: this file originally auto-generated by mib2c using
 *       version : 12088 $ of $ 
 *
 * $Id:$
 */
/* standard Net-SNMP includes */
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>

/* include our parent header */
#include "sessionTable.h"


/** @defgroup data_get data_get: Routines to get data
 *
 * TODO:230:M: Implement sessionTable get routines.
 * TODO:240:M: Implement sessionTable mapping routines (if any).
 *
 * These routine are used to get the value for individual objects. The
 * row context is passed, along with a pointer to the memory where the
 * value should be copied.
 *
 * @{
 */
/**********************************************************************
 **********************************************************************
 ***
 *** Table sessionTable
 ***
 **********************************************************************
 **********************************************************************/
/*
 * ACCEL-PPP-MIB::sessionTable is subid 1 of accelPPPSessions.
 * Its status is Current.
 * OID: .1.3.6.1.4.1.8072.100.2.1, length: 10
*/

/* ---------------------------------------------------------------------
 * TODO:200:r: Implement sessionTable data context functions.
 */
/*
 * sessionTable_allocate_data
 *
 * Purpose: create new sessionTable_data->
 */
sessionTable_data *
sessionTable_allocate_data(void)
{
    sessionTable_data *rtn = SNMP_MALLOC_TYPEDEF(sessionTable_data);

    DEBUGMSGTL(("verbose:sessionTable:sessionTable_allocate_data","called\n"));

    if(NULL == rtn) {
        snmp_log(LOG_ERR, "unable to malloc memory for new "
                 "sessionTable_data->\n");
    }

		memset(rtn, 0, sizeof(*rtn));

    return rtn;
} /* sessionTable_allocate_data */

/*
 * sessionTable_release_data
 *
 * Purpose: release sessionTable data->
 */
void
sessionTable_release_data(sessionTable_data *data)
{
    DEBUGMSGTL(("verbose:sessionTable:sessionTable_release_data","called\n"));

		if (data->username)
			free(data->username);

		if (data->calling_sid)
			free(data->calling_sid);

		if (data->called_sid)
			free(data->called_sid);

    free(data);
} /* sessionTable_release_data */



/**
 * set mib index(es)
 *
 * @param tbl_idx mib index structure
 * @param sesSID_ptr
 * @param sesSID_ptr_len
 *
 * @retval MFD_SUCCESS     : success.
 * @retval MFD_ERROR       : other error.
 *
 * @remark
 *  This convenience function is useful for setting all the MIB index
 *  components with a single function call. It is assume that the C values
 *  have already been mapped from their native/rawformat to the MIB format.
 */
int
sessionTable_indexes_set_tbl_idx(sessionTable_mib_index *tbl_idx, char *sesSID_val_ptr,  size_t sesSID_val_ptr_len)
{
    DEBUGMSGTL(("verbose:sessionTable:sessionTable_indexes_set_tbl_idx","called\n"));

    /* sesSID(1)/OCTETSTR/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/h */
    tbl_idx->sesSID_len = sizeof(tbl_idx->sesSID)/sizeof(tbl_idx->sesSID[0]); /* max length */
    /** WARNING: this code might not work for struct sessionTable_data_s */
    /*
     * make sure there is enough space for sesSID data
     */
    if ((NULL == tbl_idx->sesSID) ||
        (tbl_idx->sesSID_len <
         (sesSID_val_ptr_len))) {
        snmp_log(LOG_ERR,"not enough space for value\n");
        return MFD_ERROR;
    }
    tbl_idx->sesSID_len = sesSID_val_ptr_len;
    memcpy( tbl_idx->sesSID, sesSID_val_ptr, sesSID_val_ptr_len* sizeof(sesSID_val_ptr[0]) );
    

    return MFD_SUCCESS;
} /* sessionTable_indexes_set_tbl_idx */

/**
 * @internal
 * set row context indexes
 *
 * @param reqreq_ctx the row context that needs updated indexes
 *
 * @retval MFD_SUCCESS     : success.
 * @retval MFD_ERROR       : other error.
 *
 * @remark
 *  This function sets the mib indexs, then updates the oid indexs
 *  from the mib index.
 */
int
sessionTable_indexes_set(sessionTable_rowreq_ctx *rowreq_ctx, char *sesSID_val_ptr,  size_t sesSID_val_ptr_len)
{
    DEBUGMSGTL(("verbose:sessionTable:sessionTable_indexes_set","called\n"));

    if(MFD_SUCCESS != sessionTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx
                                   , sesSID_val_ptr, sesSID_val_ptr_len
           ))
        return MFD_ERROR;

    /*
     * convert mib index to oid index
     */
    rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid);
    if(0 != sessionTable_index_to_oid(&rowreq_ctx->oid_idx,
                                    &rowreq_ctx->tbl_idx)) {
        return MFD_ERROR;
    }

    return MFD_SUCCESS;
} /* sessionTable_indexes_set */


/*---------------------------------------------------------------------
 * ACCEL-PPP-MIB::sessionEntry.sesIfName
 * sesIfName is subid 2 of sessionEntry.
 * Its status is Current, and its access level is ReadOnly.
 * OID: .1.3.6.1.4.1.8072.100.2.1.1.2
 * Description:
name of ppp interface
 *
 * Attributes:
 *   accessible 1     isscalar 0     enums  0      hasdefval 0
 *   readable   1     iscolumn 1     ranges 0      hashint   0
 *   settable   0
 *
 *
 * Its syntax is OCTETSTR (based on perltype OCTETSTR)
 * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char)
 * This data type requires a length.
 */
/**
 * Extract the current value of the sesIfName data->
 *
 * Set a value using the data context for the row.
 *
 * @param rowreq_ctx
 *        Pointer to the row request context.
 * @param sesIfName_val_ptr_ptr
 *        Pointer to storage for a char variable
 * @param sesIfName_val_ptr_len_ptr
 *        Pointer to a size_t. On entry, it will contain the size (in bytes)
 *        pointed to by sesIfName.
 *        On exit, this value should contain the data size (in bytes).
 *
 * @retval MFD_SUCCESS         : success
 * @retval MFD_SKIP            : skip this node (no value for now)
 * @retval MFD_ERROR           : Any other error
*
 * @note If you need more than (*sesIfName_val_ptr_len_ptr) bytes of memory,
 *       allocate it using malloc() and update sesIfName_val_ptr_ptr.
 *       <b>DO NOT</b> free the previous pointer.
 *       The MFD helper will release the memory you allocate.
 *
 * @remark If you call this function yourself, you are responsible
 *         for checking if the pointer changed, and freeing any
 *         previously allocated memory. (Not necessary if you pass
 *         in a pointer to static memory, obviously.)
 */
int
sesIfName_get( sessionTable_rowreq_ctx *rowreq_ctx, char **sesIfName_val_ptr_ptr, size_t *sesIfName_val_ptr_len_ptr )
{
   int len;
   /** we should have a non-NULL pointer and enough storage */
   netsnmp_assert( (NULL != sesIfName_val_ptr_ptr) && (NULL != *sesIfName_val_ptr_ptr));
   netsnmp_assert( NULL != sesIfName_val_ptr_len_ptr );


    DEBUGMSGTL(("verbose:sessionTable:sesIfName_get","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

		len = strlen(rowreq_ctx->data->ifname);

    if ((NULL == (* sesIfName_val_ptr_ptr )) ||
        ((* sesIfName_val_ptr_len_ptr ) < len)) {
        /*
         * allocate space for sesIfName data
         */
        (* sesIfName_val_ptr_ptr ) = malloc(len);
        if(NULL == (* sesIfName_val_ptr_ptr )) {
            snmp_log(LOG_ERR,"could not allocate memory\n");
            return MFD_ERROR;
        }
    }
    (* sesIfName_val_ptr_len_ptr ) = len;
    memcpy( (* sesIfName_val_ptr_ptr ), rowreq_ctx->data->ifname, len);

    return MFD_SUCCESS;
} /* sesIfName_get */

/*---------------------------------------------------------------------
 * ACCEL-PPP-MIB::sessionEntry.sesUsername
 * sesUsername is subid 3 of sessionEntry.
 * Its status is Current, and its access level is ReadOnly.
 * OID: .1.3.6.1.4.1.8072.100.2.1.1.3
 * Description:
session user name
 *
 * Attributes:
 *   accessible 1     isscalar 0     enums  0      hasdefval 0
 *   readable   1     iscolumn 1     ranges 0      hashint   0
 *   settable   0
 *
 *
 * Its syntax is OCTETSTR (based on perltype OCTETSTR)
 * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char)
 * This data type requires a length.
 */
/**
 * Extract the current value of the sesUsername data->
 *
 * Set a value using the data context for the row.
 *
 * @param rowreq_ctx
 *        Pointer to the row request context.
 * @param sesUsername_val_ptr_ptr
 *        Pointer to storage for a char variable
 * @param sesUsername_val_ptr_len_ptr
 *        Pointer to a size_t. On entry, it will contain the size (in bytes)
 *        pointed to by sesUsername.
 *        On exit, this value should contain the data size (in bytes).
 *
 * @retval MFD_SUCCESS         : success
 * @retval MFD_SKIP            : skip this node (no value for now)
 * @retval MFD_ERROR           : Any other error
*
 * @note If you need more than (*sesUsername_val_ptr_len_ptr) bytes of memory,
 *       allocate it using malloc() and update sesUsername_val_ptr_ptr.
 *       <b>DO NOT</b> free the previous pointer.
 *       The MFD helper will release the memory you allocate.
 *
 * @remark If you call this function yourself, you are responsible
 *         for checking if the pointer changed, and freeing any
 *         previously allocated memory. (Not necessary if you pass
 *         in a pointer to static memory, obviously.)
 */
int
sesUsername_get( sessionTable_rowreq_ctx *rowreq_ctx, char **sesUsername_val_ptr_ptr, size_t *sesUsername_val_ptr_len_ptr )
{
   int len;
   /** we should have a non-NULL pointer and enough storage */
   netsnmp_assert( (NULL != sesUsername_val_ptr_ptr) && (NULL != *sesUsername_val_ptr_ptr));
   netsnmp_assert( NULL != sesUsername_val_ptr_len_ptr );


    DEBUGMSGTL(("verbose:sessionTable:sesUsername_get","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

		len = strlen(rowreq_ctx->data->username);

    if ((NULL == (* sesUsername_val_ptr_ptr )) ||
        ((* sesUsername_val_ptr_len_ptr ) < len)) {
        /*
         * allocate space for sesIfName data
         */
        (* sesUsername_val_ptr_ptr ) = malloc(len);
        if(NULL == (* sesUsername_val_ptr_ptr )) {
            snmp_log(LOG_ERR,"could not allocate memory\n");
            return MFD_ERROR;
        }
    }
    (* sesUsername_val_ptr_len_ptr ) = len;
    memcpy( (* sesUsername_val_ptr_ptr ), rowreq_ctx->data->username, len);
    
		return MFD_SUCCESS;
} /* sesUsername_get */

/*---------------------------------------------------------------------
 * ACCEL-PPP-MIB::sessionEntry.sesIP
 * sesIP is subid 4 of sessionEntry.
 * Its status is Current, and its access level is ReadOnly.
 * OID: .1.3.6.1.4.1.8072.100.2.1.1.4
 * Description:
assigned IP address
 *
 * Attributes:
 *   accessible 1     isscalar 0     enums  0      hasdefval 0
 *   readable   1     iscolumn 1     ranges 0      hashint   0
 *   settable   0
 *
 *
 * Its syntax is OCTETSTR (based on perltype OCTETSTR)
 * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char)
 * This data type requires a length.
 */
/**
 * Extract the current value of the sesIP data->
 *
 * Set a value using the data context for the row.
 *
 * @param rowreq_ctx
 *        Pointer to the row request context.
 * @param sesIP_val_ptr_ptr
 *        Pointer to storage for a char variable
 * @param sesIP_val_ptr_len_ptr
 *        Pointer to a size_t. On entry, it will contain the size (in bytes)
 *        pointed to by sesIP.
 *        On exit, this value should contain the data size (in bytes).
 *
 * @retval MFD_SUCCESS         : success
 * @retval MFD_SKIP            : skip this node (no value for now)
 * @retval MFD_ERROR           : Any other error
*
 * @note If you need more than (*sesIP_val_ptr_len_ptr) bytes of memory,
 *       allocate it using malloc() and update sesIP_val_ptr_ptr.
 *       <b>DO NOT</b> free the previous pointer.
 *       The MFD helper will release the memory you allocate.
 *
 * @remark If you call this function yourself, you are responsible
 *         for checking if the pointer changed, and freeing any
 *         previously allocated memory. (Not necessary if you pass
 *         in a pointer to static memory, obviously.)
 */
int
sesIP_get( sessionTable_rowreq_ctx *rowreq_ctx, char **sesIP_val_ptr_ptr, size_t *sesIP_val_ptr_len_ptr )
{
   int len = 4;
   /** we should have a non-NULL pointer and enough storage */
   netsnmp_assert( (NULL != sesIP_val_ptr_ptr) && (NULL != *sesIP_val_ptr_ptr));
   netsnmp_assert( NULL != sesIP_val_ptr_len_ptr );


    DEBUGMSGTL(("verbose:sessionTable:sesIP_get","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

    if ((NULL == (* sesIP_val_ptr_ptr )) ||
        ((* sesIP_val_ptr_len_ptr ) < len)) {
        /*
         * allocate space for sesIfName data
         */
        (* sesIP_val_ptr_ptr ) = malloc(len);
        if(NULL == (* sesIP_val_ptr_ptr )) {
            snmp_log(LOG_ERR,"could not allocate memory\n");
            return MFD_ERROR;
        }
    }
    (* sesIP_val_ptr_len_ptr ) = len;
    memcpy( (* sesIP_val_ptr_ptr ), &rowreq_ctx->data->peer_addr, len);

    return MFD_SUCCESS;
} /* sesIP_get */

/*---------------------------------------------------------------------
 * ACCEL-PPP-MIB::sessionEntry.sesType
 * sesType is subid 5 of sessionEntry.
 * Its status is Current, and its access level is ReadOnly.
 * OID: .1.3.6.1.4.1.8072.100.2.1.1.5
 * Description:
name of ppp interface
 *
 * Attributes:
 *   accessible 1     isscalar 0     enums  1      hasdefval 0
 *   readable   1     iscolumn 1     ranges 0      hashint   0
 *   settable   0
 *
 * Enum range: 10/16. Values:  other(1), direct(2), gre(3), minimal(4), l2tp(5), pptp(6), l2f(7), udp(8), atmp(9), msdp(10), sixToFour(11), sixOverFour(12), isatap(13), teredo(14)
 *
 * Its syntax is IANAtunnelType (based on perltype INTEGER)
 * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long)
 */
/**
 * Extract the current value of the sesType data->
 *
 * Set a value using the data context for the row.
 *
 * @param rowreq_ctx
 *        Pointer to the row request context.
 * @param sesType_val_ptr
 *        Pointer to storage for a long variable
 *
 * @retval MFD_SUCCESS         : success
 * @retval MFD_SKIP            : skip this node (no value for now)
 * @retval MFD_ERROR           : Any other error
 */
int
sesType_get( sessionTable_rowreq_ctx *rowreq_ctx, u_long * sesType_val_ptr )
{
   /** we should have a non-NULL pointer */
   netsnmp_assert( NULL != sesType_val_ptr );


    DEBUGMSGTL(("verbose:sessionTable:sesType_get","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

    (* sesType_val_ptr ) = rowreq_ctx->data->type;

    return MFD_SUCCESS;
} /* sesType_get */

/*---------------------------------------------------------------------
 * ACCEL-PPP-MIB::sessionEntry.sesState
 * sesState is subid 6 of sessionEntry.
 * Its status is Current, and its access level is ReadOnly.
 * OID: .1.3.6.1.4.1.8072.100.2.1.1.6
 * Description:
state of session
 *
 * Attributes:
 *   accessible 1     isscalar 0     enums  1      hasdefval 0
 *   readable   1     iscolumn 1     ranges 0      hashint   0
 *   settable   0
 *
 * Enum range: 3/8. Values:  starting(1), active(2), finishing(3)
 *
 * Its syntax is INTEGER (based on perltype INTEGER)
 * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long)
 */
/**
 * Extract the current value of the sesState data->
 *
 * Set a value using the data context for the row.
 *
 * @param rowreq_ctx
 *        Pointer to the row request context.
 * @param sesState_val_ptr
 *        Pointer to storage for a long variable
 *
 * @retval MFD_SUCCESS         : success
 * @retval MFD_SKIP            : skip this node (no value for now)
 * @retval MFD_ERROR           : Any other error
 */
int
sesState_get( sessionTable_rowreq_ctx *rowreq_ctx, u_long * sesState_val_ptr )
{
   /** we should have a non-NULL pointer */
   netsnmp_assert( NULL != sesState_val_ptr );


    DEBUGMSGTL(("verbose:sessionTable:sesState_get","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);
    
		(* sesState_val_ptr ) = rowreq_ctx->data->state;

    return MFD_SUCCESS;
} /* sesState_get */

/*---------------------------------------------------------------------
 * ACCEL-PPP-MIB::sessionEntry.sesUptime
 * sesUptime is subid 7 of sessionEntry.
 * Its status is Current, and its access level is ReadOnly.
 * OID: .1.3.6.1.4.1.8072.100.2.1.1.7
 * Description:
uptime of session
 *
 * Attributes:
 *   accessible 1     isscalar 0     enums  0      hasdefval 0
 *   readable   1     iscolumn 1     ranges 0      hashint   0
 *   settable   0
 *
 *
 * Its syntax is TICKS (based on perltype TICKS)
 * The net-snmp type is ASN_TIMETICKS. The C type decl is u_long (u_long)
 */
/**
 * Extract the current value of the sesUptime data->
 *
 * Set a value using the data context for the row.
 *
 * @param rowreq_ctx
 *        Pointer to the row request context.
 * @param sesUptime_val_ptr
 *        Pointer to storage for a u_long variable
 *
 * @retval MFD_SUCCESS         : success
 * @retval MFD_SKIP            : skip this node (no value for now)
 * @retval MFD_ERROR           : Any other error
 */
int
sesUptime_get( sessionTable_rowreq_ctx *rowreq_ctx, u_long * sesUptime_val_ptr )
{
   /** we should have a non-NULL pointer */
   netsnmp_assert( NULL != sesUptime_val_ptr );


    DEBUGMSGTL(("verbose:sessionTable:sesUptime_get","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

    (* sesUptime_val_ptr ) = rowreq_ctx->data->uptime;

    return MFD_SUCCESS;
} /* sesUptime_get */

/*---------------------------------------------------------------------
 * ACCEL-PPP-MIB::sessionEntry.sesCallingSID
 * sesCallingSID is subid 8 of sessionEntry.
 * Its status is Current, and its access level is ReadOnly.
 * OID: .1.3.6.1.4.1.8072.100.2.1.1.8
 * Description:
Calling-Station-ID
 *
 * Attributes:
 *   accessible 1     isscalar 0     enums  0      hasdefval 0
 *   readable   1     iscolumn 1     ranges 0      hashint   0
 *   settable   0
 *
 *
 * Its syntax is OCTETSTR (based on perltype OCTETSTR)
 * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char)
 * This data type requires a length.
 */
/**
 * Extract the current value of the sesCallingSID data->
 *
 * Set a value using the data context for the row.
 *
 * @param rowreq_ctx
 *        Pointer to the row request context.
 * @param sesCallingSID_val_ptr_ptr
 *        Pointer to storage for a char variable
 * @param sesCallingSID_val_ptr_len_ptr
 *        Pointer to a size_t. On entry, it will contain the size (in bytes)
 *        pointed to by sesCallingSID.
 *        On exit, this value should contain the data size (in bytes).
 *
 * @retval MFD_SUCCESS         : success
 * @retval MFD_SKIP            : skip this node (no value for now)
 * @retval MFD_ERROR           : Any other error
*
 * @note If you need more than (*sesCallingSID_val_ptr_len_ptr) bytes of memory,
 *       allocate it using malloc() and update sesCallingSID_val_ptr_ptr.
 *       <b>DO NOT</b> free the previous pointer.
 *       The MFD helper will release the memory you allocate.
 *
 * @remark If you call this function yourself, you are responsible
 *         for checking if the pointer changed, and freeing any
 *         previously allocated memory. (Not necessary if you pass
 *         in a pointer to static memory, obviously.)
 */
int
sesCallingSID_get( sessionTable_rowreq_ctx *rowreq_ctx, char **sesCallingSID_val_ptr_ptr, size_t *sesCallingSID_val_ptr_len_ptr )
{
   int len;
   /** we should have a non-NULL pointer and enough storage */
   netsnmp_assert( (NULL != sesCallingSID_val_ptr_ptr) && (NULL != *sesCallingSID_val_ptr_ptr));
   netsnmp_assert( NULL != sesCallingSID_val_ptr_len_ptr );


    DEBUGMSGTL(("verbose:sessionTable:sesCallingSID_get","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

		len = strlen(rowreq_ctx->data->calling_sid);

    if ((NULL == (* sesCallingSID_val_ptr_ptr )) ||
        ((* sesCallingSID_val_ptr_len_ptr ) < len)) {
        /*
         * allocate space for sesCallingSID data
         */
        (* sesCallingSID_val_ptr_ptr ) = malloc(len);
        if(NULL == (* sesCallingSID_val_ptr_ptr )) {
            snmp_log(LOG_ERR,"could not allocate memory\n");
            return MFD_ERROR;
        }
    }
    (* sesCallingSID_val_ptr_len_ptr ) = len;
    memcpy( (* sesCallingSID_val_ptr_ptr ), rowreq_ctx->data->calling_sid, len);

    return MFD_SUCCESS;
} /* sesCallingSID_get */

/*---------------------------------------------------------------------
 * ACCEL-PPP-MIB::sessionEntry.sesCalledSID
 * sesCalledSID is subid 9 of sessionEntry.
 * Its status is Current, and its access level is ReadOnly.
 * OID: .1.3.6.1.4.1.8072.100.2.1.1.9
 * Description:
Called-Station-ID
 *
 * Attributes:
 *   accessible 1     isscalar 0     enums  0      hasdefval 0
 *   readable   1     iscolumn 1     ranges 0      hashint   0
 *   settable   0
 *
 *
 * Its syntax is OCTETSTR (based on perltype OCTETSTR)
 * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char)
 * This data type requires a length.
 */
/**
 * Extract the current value of the sesCalledSID data->
 *
 * Set a value using the data context for the row.
 *
 * @param rowreq_ctx
 *        Pointer to the row request context.
 * @param sesCalledSID_val_ptr_ptr
 *        Pointer to storage for a char variable
 * @param sesCalledSID_val_ptr_len_ptr
 *        Pointer to a size_t. On entry, it will contain the size (in bytes)
 *        pointed to by sesCalledSID.
 *        On exit, this value should contain the data size (in bytes).
 *
 * @retval MFD_SUCCESS         : success
 * @retval MFD_SKIP            : skip this node (no value for now)
 * @retval MFD_ERROR           : Any other error
*
 * @note If you need more than (*sesCalledSID_val_ptr_len_ptr) bytes of memory,
 *       allocate it using malloc() and update sesCalledSID_val_ptr_ptr.
 *       <b>DO NOT</b> free the previous pointer.
 *       The MFD helper will release the memory you allocate.
 *
 * @remark If you call this function yourself, you are responsible
 *         for checking if the pointer changed, and freeing any
 *         previously allocated memory. (Not necessary if you pass
 *         in a pointer to static memory, obviously.)
 */
int
sesCalledSID_get( sessionTable_rowreq_ctx *rowreq_ctx, char **sesCalledSID_val_ptr_ptr, size_t *sesCalledSID_val_ptr_len_ptr )
{
	 int len;

   /** we should have a non-NULL pointer and enough storage */
   netsnmp_assert( (NULL != sesCalledSID_val_ptr_ptr) && (NULL != *sesCalledSID_val_ptr_ptr));
   netsnmp_assert( NULL != sesCalledSID_val_ptr_len_ptr );


    DEBUGMSGTL(("verbose:sessionTable:sesCalledSID_get","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

		len = strlen(rowreq_ctx->data->called_sid);

    if ((NULL == (* sesCalledSID_val_ptr_ptr )) ||
        ((* sesCalledSID_val_ptr_len_ptr ) < len)) {
        /*
         * allocate space for sesCalledSID data
         */
        (* sesCalledSID_val_ptr_ptr ) = malloc(len);
        if(NULL == (* sesCalledSID_val_ptr_ptr )) {
            snmp_log(LOG_ERR,"could not allocate memory\n");
            return MFD_ERROR;
        }
    }
    (* sesCalledSID_val_ptr_len_ptr ) = len;
    memcpy( (* sesCalledSID_val_ptr_ptr ), rowreq_ctx->data->called_sid, len);

    return MFD_SUCCESS;
} /* sesCalledSID_get */

/** @} */