1
#include <net-snmp/net-snmp-config.h>
9
#include <net-snmp/net-snmp-includes.h>
10
#include <net-snmp/agent/net-snmp-agent-includes.h>
11
#include <net-snmp/agent/table.h>
12
#include <net-snmp/agent/table_iterator.h>
14
#include "vacm_context.h"
16
static oid vacm_context_oid[] = { 1, 3, 6, 1, 6, 3, 16, 1, 1 };
18
#define CONTEXTNAME_COLUMN 1
21
* return the index data from the first node in the agent's
22
* subtree_context_cache list.
24
netsnmp_variable_list *
25
get_first_context(void **my_loop_context, void **my_data_context,
26
netsnmp_variable_list * put_data,
27
netsnmp_iterator_info *iinfo)
29
subtree_context_cache *context_ptr;
30
context_ptr = get_top_context_cache();
35
*my_loop_context = context_ptr;
36
*my_data_context = context_ptr;
38
snmp_set_var_value(put_data, context_ptr->context_name,
39
strlen(context_ptr->context_name));
44
* return the next index data from the first node in the agent's
45
* subtree_context_cache list.
47
netsnmp_variable_list *
48
get_next_context(void **my_loop_context,
49
void **my_data_context,
50
netsnmp_variable_list * put_data,
51
netsnmp_iterator_info *iinfo)
53
subtree_context_cache *context_ptr;
55
if (!my_loop_context || !*my_loop_context)
58
context_ptr = (subtree_context_cache *) (*my_loop_context);
59
context_ptr = context_ptr->next;
60
*my_loop_context = context_ptr;
61
*my_data_context = context_ptr;
66
snmp_set_var_value(put_data, context_ptr->context_name,
67
strlen(context_ptr->context_name));
72
init_vacm_context(void)
77
netsnmp_handler_registration *my_handler;
78
netsnmp_table_registration_info *table_info;
79
netsnmp_iterator_info *iinfo;
81
my_handler = netsnmp_create_handler_registration("vacm_context",
92
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
93
iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
95
if (!table_info || !iinfo)
98
netsnmp_table_helper_add_index(table_info, ASN_OCTET_STR)
99
table_info->min_column = 1;
100
table_info->max_column = 1;
101
iinfo->get_first_data_point = get_first_context;
102
iinfo->get_next_data_point = get_next_context;
103
iinfo->table_reginfo = table_info;
104
netsnmp_register_table_iterator(my_handler, iinfo);
108
* returns a list of known context names
112
vacm_context_handler(netsnmp_mib_handler *handler,
113
netsnmp_handler_registration *reginfo,
114
netsnmp_agent_request_info *reqinfo,
115
netsnmp_request_info *requests)
117
subtree_context_cache *context_ptr;
119
for(; requests; requests = requests->next) {
120
netsnmp_variable_list *var = requests->requestvb;
122
if (requests->processed != 0)
126
context_ptr = (subtree_context_cache *)
127
netsnmp_extract_iterator_context(requests);
129
if (context_ptr == NULL) {
131
"vacm_context_handler called without data\n");
135
switch (reqinfo->mode) {
138
* if here we should have a context_ptr passed in already
141
* only one column should ever reach us, so don't check it
143
snmp_set_var_typed_value(var, ASN_OCTET_STR,
144
context_ptr->context_name,
145
strlen(context_ptr->context_name));
151
* We should never get here, getnext already have been
152
* handled by the table_iterator and we're read_only
155
"vacm_context table accessed as mode=%d. We're improperly registered!",
163
return SNMP_ERR_NOERROR;