/
openserSIPRegUserLookupTable.c
824 lines (679 loc) · 23.1 KB
/
openserSIPRegUserLookupTable.c
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
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
/*
* SNMPStats Module
* Copyright (C) 2006 SOMA Networks, INC.
* Written by: Jeffrey Magder (jmagder@somanetworks.com)
*
* This file is part of opensips, a free SIP server.
*
* opensips is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* opensips is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* History:
* --------
* 2006-11-23 initial version (jmagder)
*
* Note: this file originally auto-generated by mib2c using
* mib2c.array-user.conf
*
* This file implements the openserSIPRegUserLookupTable. For a full
* description of the table, please see the OPENSER-SIP-SERVER-MIB.
*
* This file is much larger and more complicated than the files for other
* tables. This is because the table is settable, bringing a lot of SNMP
* overhead. Most of the file consists of the original auto-generated
* code (aside from white space and comment changes).
*
* The functions that have been modified to implement this table are the
* following:
*
* 1) openserSIPRegUserLookupTable_extract_index()
*
* - Modified to fail if the index is invalid. The index is invalid if it
* does not match up with the global userLookupCounter.
*
* 2) openserSIPRegUserLookupTable_can_[activate|deactivate|delete]()
*
* - Simplified to always allow activation/deactivation/deletion.
*
* 3) openserSIPRegUserLookupTable_set_reserve1()
*
* - The reserve1 phase passes if the row is new, and the rowStatus column
* is being set to 'createAndGo'
* - The reserve1 phase passes if the row is not new, and the rowStatus
* column is being set to 'destroy'
*
* 4) openserSIPRegUserLookupTable_set_action()
*
* - The function was modified to populate the row with the userIndex of the
* supplied URI if that URI was found on the system, and set the rowStatus
* to 'active'. If the URI was not found, the rowStatus is set to
* 'notInService'
*
* You can safely ignore the other functions.
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include <net-snmp/library/snmp_assert.h>
#include "openserSIPRegUserLookupTable.h"
#include "snmpstats_globals.h"
#include "hashTable.h"
#include "interprocess_buffer.h"
static netsnmp_handler_registration *my_handler = NULL;
static netsnmp_table_array_callbacks cb;
oid openserSIPRegUserLookupTable_oid[] = {
openserSIPRegUserLookupTable_TABLE_OID };
size_t openserSIPRegUserLookupTable_oid_len =
OID_LENGTH(openserSIPRegUserLookupTable_oid);
/*
* Initializes the openserSIPRegUserLookupTable table. This step is easier
* than in the other tables because there is no table population. All table
* population takes place during run time.
*/
void init_openserSIPRegUserLookupTable(void)
{
initialize_table_openserSIPRegUserLookupTable();
}
/* the *_row_copy routine */
static int openserSIPRegUserLookupTable_row_copy(
openserSIPRegUserLookupTable_context * dst,
openserSIPRegUserLookupTable_context * src)
{
if(!dst||!src)
{
return 1;
}
/* copy index, if provided */
if(dst->index.oids)
{
free(dst->index.oids);
}
if(snmp_clone_mem( (void*)&dst->index.oids, src->index.oids,
src->index.len * sizeof(oid) )) {
dst->index.oids = NULL;
return 1;
}
dst->index.len = src->index.len;
/* Copy out almost all components of the structure. We don't copy out
* the openserSIPRegUSerLookupURI (or its length). */
dst->openserSIPRegUserLookupIndex = src->openserSIPRegUserLookupIndex;
dst->openserSIPRegUserIndex = src->openserSIPRegUserIndex;
dst->openserSIPRegUserLookupRowStatus =
src->openserSIPRegUserLookupRowStatus;
return 0;
}
/*
* the *_extract_index routine. (Mostly auto-generated)
*
* This routine is called when a set request is received for an index
* that was not found in the table container. Here, we parse the oid
* in the individual index components and copy those indexes to the
* context. Then we make sure the indexes for the new row are valid.
*
* It has been modified from its original form in that if the indexes are
* invalid, then they aren't returned. An index is invalid if:
*
* 1) It is < 1
* 2) It doesn't match the global userLookupIndex. (As per MIB specs)
*
*/
int openserSIPRegUserLookupTable_extract_index(
openserSIPRegUserLookupTable_context * ctx,
netsnmp_index * hdr)
{
/*
* temporary local storage for extracting oid index
*
* extract index uses varbinds (netsnmp_variable_list) to parse
* the index OID into the individual components for each index part.
*/
netsnmp_variable_list var_openserSIPRegUserLookupIndex;
int err;
/* copy index, if provided */
if(hdr) {
netsnmp_assert(ctx->index.oids == NULL);
if((hdr->len > MAX_OID_LEN) ||
snmp_clone_mem( (void*)&ctx->index.oids, hdr->oids,
hdr->len * sizeof(oid) )) {
return -1;
}
ctx->index.len = hdr->len;
}
/* Set up the index */
memset(&var_openserSIPRegUserLookupIndex, 0x00,
sizeof(var_openserSIPRegUserLookupIndex));
var_openserSIPRegUserLookupIndex.type = ASN_UNSIGNED;
var_openserSIPRegUserLookupIndex.next_variable = NULL;
/* parse the oid into the individual index components */
err = parse_oid_indexes( hdr->oids, hdr->len,
&var_openserSIPRegUserLookupIndex );
if (err == SNMP_ERR_NOERROR) {
/* copy index components into the context structure */
ctx->openserSIPRegUserLookupIndex =
*var_openserSIPRegUserLookupIndex.val.integer;
/*
* Check to make sure that the index corresponds to the
* global_userLookupCounter, as per the MIB specifications.
*/
if (*var_openserSIPRegUserLookupIndex.val.integer !=
global_UserLookupCounter ||
*var_openserSIPRegUserLookupIndex.val.integer < 1) {
err = -1;
}
}
/* parsing may have allocated memory. free it. */
snmp_reset_var_buffers( &var_openserSIPRegUserLookupIndex );
return err;
}
/*
* This is an auto-generated function. In general the *_can_activate routine
* is called when a row is changed to determine if all the values set are
* consistent with the row's rules for a row status of ACTIVE. If not, then 0
* can be returned to prevent the row status from becomming final.
*
* For our purposes, we have no need for this check, so we always return 1.
*/
int openserSIPRegUserLookupTable_can_activate(
openserSIPRegUserLookupTable_context *undo_ctx,
openserSIPRegUserLookupTable_context *row_ctx,
netsnmp_request_group * rg)
{
return 1;
}
/*
* This is an auto-generated function. In general the *_can_deactivate routine
* is called when a row that is currently ACTIVE is set to a state other than
* ACTIVE. If there are conditions in which a row should not be allowed to
* transition out of the ACTIVE state (such as the row being referred to by
* another row or table), check for them here.
*
* Since this table has no reason why this shouldn't be allowed, we always
* return 1;
*/
int openserSIPRegUserLookupTable_can_deactivate(
openserSIPRegUserLookupTable_context *undo_ctx,
openserSIPRegUserLookupTable_context *row_ctx,
netsnmp_request_group * rg)
{
return 1;
}
/*
* This is an auto-generated function. In general the *_can_delete routine is
* called to determine if a row can be deleted. This usually involved checking
* if it can be deactivated, and if it can be, then checking for other
* conditions.
*
* Since this table ha no reason why row deletion shouldn't be allowed, we
* always return 1, unless we can't deactivate.
*/
int openserSIPRegUserLookupTable_can_delete(
openserSIPRegUserLookupTable_context *undo_ctx,
openserSIPRegUserLookupTable_context *row_ctx,
netsnmp_request_group * rg)
{
if(openserSIPRegUserLookupTable_can_deactivate(undo_ctx,row_ctx,rg) != 1)
return 0;
return 1;
}
/*
* This is an auto-generated function.
*
* The *_create_row routine is called by the table handler to create a new row
* for a given index. This is the first stage of the row creation process. The
* *_set_reserve_* functions can be used to prevent the row from being inserted
* into the table even if the row passes any preliminary checks set here.
*
* Returns a newly allocated openserSIPRegUserLookupTable_context structure (a
* row in the table) if the indexes are legal. NULL will be returned otherwise.
*/
openserSIPRegUserLookupTable_context *
openserSIPRegUserLookupTable_create_row( netsnmp_index* hdr)
{
openserSIPRegUserLookupTable_context * ctx =
SNMP_MALLOC_TYPEDEF(openserSIPRegUserLookupTable_context);
if (!ctx)
{
return NULL;
}
/*
* Extract the index. The function has been modified from its original
* auto-generated version in that the function will fail if index is
* somehow invalid.
*/
if(openserSIPRegUserLookupTable_extract_index( ctx, hdr ))
{
if (NULL != ctx->index.oids)
{
free(ctx->index.oids);
}
free(ctx);
return NULL;
}
ctx->openserSIPRegUserLookupURI = NULL;
ctx->openserSIPRegUserLookupURI_len = 0;
ctx->openserSIPRegUserIndex = 0;
ctx->openserSIPRegUserLookupRowStatus = 0;
return ctx;
}
/*
* Auto-generated function. The *_duplicate row routine
*/
openserSIPRegUserLookupTable_context *
openserSIPRegUserLookupTable_duplicate_row(
openserSIPRegUserLookupTable_context * row_ctx)
{
openserSIPRegUserLookupTable_context * dup;
if(!row_ctx)
return NULL;
dup = SNMP_MALLOC_TYPEDEF(openserSIPRegUserLookupTable_context);
if(!dup)
return NULL;
if(openserSIPRegUserLookupTable_row_copy(dup,row_ctx)) {
free(dup);
dup = NULL;
}
return dup;
}
/*
* The *_delete_row method is auto-generated, and is called to delete a row.
*
* This will not be called if earlier checks said that this row can't be
* deleted. However, in our implementation there is never a reason why this
* function can't be called.
*/
netsnmp_index * openserSIPRegUserLookupTable_delete_row(
openserSIPRegUserLookupTable_context * ctx )
{
if(ctx->index.oids)
{
free(ctx->index.oids);
}
if (ctx->openserSIPRegUserLookupURI != NULL)
{
pkg_free(ctx->openserSIPRegUserLookupURI);
}
free( ctx );
return NULL;
}
/*
* Large parts of this function have been auto-generated. The functions purpose
* is to check to make sure all SNMP set values for the given row, have been
* valid. If not, then the process is supposed to be aborted. Otherwise, we
* pass on to the *_reserve2 function.
*
* For our purposes, our only check is to make sure that either of the following
* conditions are true:
*
* 1) If this row already exists, then the SET request is setting the rowStatus
* column to 'destroy'.
*
* 2) If this row does not already exist, then the SET request is setting the
* rowStatus to 'createAndGo'.
*
* Since the MIB specified there are to be no other modifications to the row,
* any other condition is considered illegal, and will result in an SNMP error
* being returned.
*/
void openserSIPRegUserLookupTable_set_reserve1( netsnmp_request_group *rg )
{
openserSIPRegUserLookupTable_context *row_ctx =
(openserSIPRegUserLookupTable_context *)rg->existing_row;
netsnmp_variable_list *var;
netsnmp_request_group_item *current;
int rc;
for( current = rg->list; current; current = current->next ) {
var = current->ri->requestvb;
rc = SNMP_ERR_NOERROR;
switch(current->tri->colnum)
{
case COLUMN_OPENSERSIPREGUSERLOOKUPURI:
if (row_ctx->openserSIPRegUserLookupRowStatus == 0 ||
row_ctx->openserSIPRegUserLookupRowStatus ==
TC_ROWSTATUS_NOTREADY) {
} else {
rc = SNMP_ERR_BADVALUE;
}
break;
case COLUMN_OPENSERSIPREGUSERLOOKUPROWSTATUS:
/** RowStatus = ASN_INTEGER */
rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER,
sizeof(
row_ctx->openserSIPRegUserLookupRowStatus));
/* Want to make sure that if it already exists that it
* is setting it to 'destroy', or if it doesn't exist,
* that it is setting it to 'createAndGo' */
if (row_ctx->openserSIPRegUserLookupRowStatus == 0 &&
*var->val.integer != TC_ROWSTATUS_CREATEANDGO)
{
rc = SNMP_ERR_BADVALUE;
}
else if (row_ctx->openserSIPRegUserLookupRowStatus ==
TC_ROWSTATUS_ACTIVE &&
*var->val.integer !=
TC_ROWSTATUS_DESTROY)
{
rc = SNMP_ERR_BADVALUE;
}
break;
default: /** We shouldn't get here */
rc = SNMP_ERR_GENERR;
snmp_log(LOG_ERR, "unknown column in openserSIPReg"
"UserLookupTable_set_reserve1\n");
}
if (rc)
{
netsnmp_set_mode_request_error(
MODE_SET_BEGIN, current->ri, rc );
}
rg->status = SNMP_MAX( rg->status, current->ri->status );
}
}
/*
* Auto-generated function. The function is supposed to check for any
* last-minute conditions not being met. However, we don't have any such
* conditions, so we leave the default function as is.
*/
void openserSIPRegUserLookupTable_set_reserve2( netsnmp_request_group *rg )
{
openserSIPRegUserLookupTable_context *undo_ctx =
(openserSIPRegUserLookupTable_context *)rg->undo_info;
netsnmp_request_group_item *current;
int rc;
rg->rg_void = rg->list->ri;
for( current = rg->list; current; current = current->next ) {
rc = SNMP_ERR_NOERROR;
switch(current->tri->colnum)
{
case COLUMN_OPENSERSIPREGUSERLOOKUPURI:
break;
case COLUMN_OPENSERSIPREGUSERLOOKUPROWSTATUS:
/** RowStatus = ASN_INTEGER */
rc = netsnmp_check_vb_rowstatus(current->ri->requestvb,
undo_ctx ?
undo_ctx->openserSIPRegUserLookupRowStatus:0);
rg->rg_void = current->ri;
break;
default: /** We shouldn't get here */
netsnmp_assert(0); /** why wasn't this caught in reserve1? */
}
if (rc)
{
netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri, rc);
}
}
}
/*
* This function is called only when all the *_reserve[1|2] functions were
* succeful. Its purpose is to make any changes to the row before it is
* inserted into the table.
*
* In the case of this table, this involves looking up the index of the
* requested user in the URI to userIndex mapping hash table. If the result is
* found, the index will be copied to the row, and the rowStatus set to
* 'active'. Otherwise, the row status will be set to 'notInService'
*
* All other handling is auto-generated.
*/
void openserSIPRegUserLookupTable_set_action( netsnmp_request_group *rg )
{
/* First things first, we need to consume the interprocess buffer, in
* case something has changed. We want to return the freshest data. */
consumeInterprocessBuffer();
aorToIndexStruct_t *hashRecord;
netsnmp_variable_list *var;
openserSIPRegUserLookupTable_context *row_ctx =
(openserSIPRegUserLookupTable_context *)rg->existing_row;
openserSIPRegUserLookupTable_context *undo_ctx =
(openserSIPRegUserLookupTable_context *)rg->undo_info;
netsnmp_request_group_item *current;
int row_err = 0;
/* Copy the actual data to the row. */
for( current = rg->list; current; current = current->next ) {
var = current->ri->requestvb;
switch(current->tri->colnum)
{
case COLUMN_OPENSERSIPREGUSERLOOKUPURI:
row_ctx->openserSIPRegUserLookupURI =
pkg_malloc(sizeof(char)*(var->val_len + 1));
memcpy(row_ctx->openserSIPRegUserLookupURI,
var->val.string,
var->val_len);
/* Usually NetSNMP won't terminate strings with '\0'.
* The hash function expect them to be terminated
* though, so we have to add this on to the end. The +1
* in the malloc makes sure of the extra space for us.
*/
row_ctx->openserSIPRegUserLookupURI[var->val_len] = '\0';
row_ctx->openserSIPRegUserLookupURI_len = var->val_len;
/* Do the lookup. If we could find the record, then set
* the index and the row status to active. Otherwise,
* set the row to notInService */
hashRecord =
findHashRecord(hashTable,
(char *)
row_ctx->openserSIPRegUserLookupURI,
HASH_SIZE);
if (hashRecord == NULL)
{
row_ctx->openserSIPRegUserIndex = 0;
row_ctx->openserSIPRegUserLookupRowStatus =
TC_ROWSTATUS_NOTINSERVICE;
}
else
{
row_ctx->openserSIPRegUserIndex =
hashRecord->userIndex;
row_ctx->openserSIPRegUserLookupRowStatus =
TC_ROWSTATUS_ACTIVE;
}
break;
case COLUMN_OPENSERSIPREGUSERLOOKUPROWSTATUS:
row_ctx->openserSIPRegUserLookupRowStatus =
*var->val.integer;
if (*var->val.integer == TC_ROWSTATUS_CREATEANDGO)
{
rg->row_created = 1;
/* Set to NOT READY until the lookup URI has
* been supplied. */
row_ctx->openserSIPRegUserLookupRowStatus =
TC_ROWSTATUS_NOTREADY;
}
else if (*var->val.integer == TC_ROWSTATUS_DESTROY)
{
rg->row_deleted = 1;
}
else
{
/* We should never be here, because the RESERVE
* functions should have taken care of all other
* values. */
LM_ERR("invalid RowStatus in openserSIPStatusCodesTable\n");
}
break;
default: /** We shouldn't get here */
netsnmp_assert(0); /** why wasn't this caught in reserve1? */
}
}
/*
* done with all the columns. Could check row related
* requirements here.
*/
#ifndef openserSIPRegUserLookupTable_CAN_MODIFY_ACTIVE_ROW
if( undo_ctx && RS_IS_ACTIVE(undo_ctx->openserSIPRegUserLookupRowStatus) &&
row_ctx && RS_IS_ACTIVE(row_ctx->openserSIPRegUserLookupRowStatus) ) {
row_err = 1;
}
#endif
/*
* check activation/deactivation
*/
row_err = netsnmp_table_array_check_row_status(&cb, rg,
row_ctx ? &row_ctx->openserSIPRegUserLookupRowStatus : NULL,
undo_ctx ? &undo_ctx->openserSIPRegUserLookupRowStatus : NULL);
if(row_err) {
netsnmp_set_mode_request_error(MODE_SET_BEGIN,
(netsnmp_request_info*)rg->rg_void, row_err);
return;
}
}
/*
* The COMMIT phase is used to do any extra processing after the ACTION phase.
* In our table, there is nothing to do, so the function body is empty.
*/
void openserSIPRegUserLookupTable_set_commit( netsnmp_request_group *rg )
{
}
/*
* This function is called if the *_reserve[1|2] calls failed. Its supposed to
* free up any resources allocated earlier. However, we already take care of
* all these resources in earlier functions. So for our purposes, the function
* body is empty.
*/
void openserSIPRegUserLookupTable_set_free( netsnmp_request_group *rg )
{
}
/*
* This function is called if an ACTION phase fails, to do extra clean-up work.
* We don't have anything complicated enough to warrant putting anything in this
* function. Therefore, its just left with an empty function body.
*/
void openserSIPRegUserLookupTable_set_undo( netsnmp_request_group *rg )
{
}
/*
* Initialize the openserSIPRegUserLookupTable table by defining how it is
* structured.
*
* This function is mostly auto-generated.
*/
void initialize_table_openserSIPRegUserLookupTable(void)
{
netsnmp_table_registration_info *table_info;
if(my_handler) {
snmp_log(LOG_ERR, "initialize_table_openserSIPRegUserLookup"
"Table_handler called again\n");
return;
}
memset(&cb, 0x00, sizeof(cb));
/** create the table structure itself */
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
my_handler = netsnmp_create_handler_registration(
"openserSIPRegUserLookupTable",
netsnmp_table_array_helper_handler,
openserSIPRegUserLookupTable_oid,
openserSIPRegUserLookupTable_oid_len,
HANDLER_CAN_RWRITE);
if (!my_handler || !table_info) {
snmp_log(LOG_ERR, "malloc failed in "
"initialize_table_openserSIPRegUserLookup"
"Table_handler\n");
if (table_info)
SNMP_FREE(table_info);
return; /** mallocs failed */
}
/*
* Setting up the table's definition
*/
netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);
table_info->min_column = openserSIPRegUserLookupTable_COL_MIN;
table_info->max_column = openserSIPRegUserLookupTable_COL_MAX;
/*
* registering the table with the master agent
*/
cb.get_value = openserSIPRegUserLookupTable_get_value;
cb.container = netsnmp_container_find(
"openserSIPRegUserLookupTable_primary:"
"openserSIPRegUserLookupTable:"
"table_container");
cb.can_set = 1;
cb.create_row =
(UserRowMethod*)openserSIPRegUserLookupTable_create_row;
cb.duplicate_row =
(UserRowMethod*)openserSIPRegUserLookupTable_duplicate_row;
cb.delete_row =
(UserRowMethod*)openserSIPRegUserLookupTable_delete_row;
cb.row_copy =
(Netsnmp_User_Row_Operation *)
openserSIPRegUserLookupTable_row_copy;
cb.can_activate = (Netsnmp_User_Row_Action *)
openserSIPRegUserLookupTable_can_activate;
cb.can_deactivate = (Netsnmp_User_Row_Action *)
openserSIPRegUserLookupTable_can_deactivate;
cb.can_delete = (Netsnmp_User_Row_Action *)
openserSIPRegUserLookupTable_can_delete;
cb.set_reserve1 = openserSIPRegUserLookupTable_set_reserve1;
cb.set_reserve2 = openserSIPRegUserLookupTable_set_reserve2;
cb.set_action = openserSIPRegUserLookupTable_set_action;
cb.set_commit = openserSIPRegUserLookupTable_set_commit;
cb.set_free = openserSIPRegUserLookupTable_set_free;
cb.set_undo = openserSIPRegUserLookupTable_set_undo;
DEBUGMSGTL(("initialize_table_openserSIPRegUserLookupTable",
"Registering table openserSIPRegUserLookupTable "
"as a table array\n"));
netsnmp_table_container_register(my_handler, table_info, &cb,
cb.container, 1);
}
/*
* This function was auto-generated and didn't need modifications from its
* auto-generation. It is called to handle an SNMP GET request.
*/
int openserSIPRegUserLookupTable_get_value(
netsnmp_request_info *request,
netsnmp_index *item,
netsnmp_table_request_info *table_info )
{
netsnmp_variable_list *var = request->requestvb;
openserSIPRegUserLookupTable_context *context =
(openserSIPRegUserLookupTable_context *)item;
switch(table_info->colnum)
{
case COLUMN_OPENSERSIPREGUSERLOOKUPURI:
/** SnmpAdminString = ASN_OCTET_STR */
snmp_set_var_typed_value(var, ASN_OCTET_STR,
(unsigned char*)
context->openserSIPRegUserLookupURI,
context->openserSIPRegUserLookupURI_len);
break;
case COLUMN_OPENSERSIPREGUSERINDEX:
/** UNSIGNED32 = ASN_UNSIGNED */
snmp_set_var_typed_value(var, ASN_UNSIGNED,
(unsigned char*)
&context->openserSIPRegUserIndex,
sizeof(context->openserSIPRegUserIndex));
break;
case COLUMN_OPENSERSIPREGUSERLOOKUPROWSTATUS:
/** RowStatus = ASN_INTEGER */
snmp_set_var_typed_value(var, ASN_INTEGER,
(unsigned char*)
&context->openserSIPRegUserLookupRowStatus,
sizeof(
context->openserSIPRegUserLookupRowStatus));
break;
default: /** We shouldn't get here */
snmp_log(LOG_ERR, "unknown column in "
"openserSIPRegUserLookupTable_get_value\n");
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
/*
* openserSIPRegUserLookupTable_get_by_idx
*/
const openserSIPRegUserLookupTable_context *
openserSIPRegUserLookupTable_get_by_idx(netsnmp_index * hdr)
{
return (const openserSIPRegUserLookupTable_context *)
CONTAINER_FIND(cb.container, hdr );
}