Debian Codegraph @

include/net-snmp/agent/table.h

raw ◀ ▶
1 Debian patch touch this file
1 /* Portions of this file are subject to the following copyright(s). See
2 * the Net-SNMP's COPYING file for more details and other copyrights
3 * that may apply:
4 */
5 /*
6 * Portions of this file are copyrighted by:
•7 * Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
8 * Use is subject to license terms specified in the COPYING file
9 * distributed with the Net-SNMP package.
10 */
11 /*
12 * Portions of this file are copyrighted by:
13 * Copyright (C) 2007 Apple, Inc. All rights reserved.
14 * Use is subject to license terms specified in the COPYING file
15 * distributed with the Net-SNMP package.
16 */
17 /**
18 * @file table.h
19 *
20 * @addtogroup table
21 *
22 * @{
23 */
24 #ifndef _TABLE_HANDLER_H_
25 #define _TABLE_HANDLER_H_
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /**
32 * The table helper is designed to simplify the task of writing a
33 * table handler for the net-snmp agent. You should create a normal
34 * handler and register it using the netsnmp_register_table() function
35 * instead of the netsnmp_register_handler() function.
36 */
37
38 /**
39 * Notes:
40 *
41 * 1) illegal indexes automatically get handled for get/set cases.
42 * Simply check to make sure the value is type ASN_NULL before
43 * you answer a request.
44 */
45
46 /**
47 * used as an index to parent_data lookups
48 */
49 #define TABLE_HANDLER_NAME "table"
50
51 /** @typedef struct netsnmp_column_info_t netsnmp_column_info
52 * Typedefs the netsnmp_column_info_t struct into netsnmp_column_info */
53
54 /**
55 * @struct netsnmp_column_info_t
56 * column info struct. OVERLAPPING RANGES ARE NOT SUPPORTED.
57 */
58 typedef struct netsnmp_column_info_t {
59 char isRange;
60 /** only useful if isRange == 0 */
61 char list_count;
62
63 union {
64 unsigned int range[2];
65 unsigned int *list;
66 } details;
67
68 struct netsnmp_column_info_t *next;
69
70 } netsnmp_column_info;
71
72 /** @typedef struct netsnmp_table_registration_info_s netsnmp_table_registration_info
73 * Typedefs the netsnmp_table_registration_info_s struct into
74 * netsnmp_table_registration_info */
75
76 /**
77 * @struct netsnmp_table_registration_info_s
78 * Table registration structure.
79 */
80 typedef struct netsnmp_table_registration_info_s {
81 /** list of varbinds with only 'type' set */
82 netsnmp_variable_list *indexes;
83 /** calculated automatically */
84 unsigned int number_indexes;
85
86 /**
87 * the minimum columns number. If there are columns
88 * in-between which are not valid, use valid_columns to get
89 * automatic column range checking.
90 */
91 unsigned int min_column;
92 /** the maximum columns number */
93 unsigned int max_column;
94
95 /** more details on columns */
96 netsnmp_column_info *valid_columns;
97
98 } netsnmp_table_registration_info;
99
100 /** @typedef struct netsnmp_table_request_info_s netsnmp_table_request_info
101 * Typedefs the netsnmp_table_request_info_s struct into
102 * netsnmp_table_request_info */
103
104 /**
105 * @struct netsnmp_table_request_info_s
106 * The table request info structure.
107 */
108 typedef struct netsnmp_table_request_info_s {
109 /** 0 if OID not long enough */
110 unsigned int colnum;
111 /** 0 if failure to parse any */
112 unsigned int number_indexes;
113 /** contents freed by helper upon exit */
114 netsnmp_variable_list *indexes;
115
116 oid index_oid[MAX_OID_LEN];
117 size_t index_oid_len;
118 netsnmp_table_registration_info *reg_info;
119 } netsnmp_table_request_info;
120
121 netsnmp_mib_handler
122 *netsnmp_get_table_handler(netsnmp_table_registration_info
123 *tabreq);
124 void netsnmp_handler_owns_table_info(netsnmp_mib_handler *handler);
125 void netsnmp_registration_owns_table_info(netsnmp_handler_registration *reg);
126 int netsnmp_register_table( netsnmp_handler_registration *reginfo,
127 netsnmp_table_registration_info *tabreq);
128 int netsnmp_unregister_table(netsnmp_handler_registration *reginfo);
129 int netsnmp_table_build_oid( netsnmp_handler_registration *reginfo,
130 netsnmp_request_info *reqinfo,
131 netsnmp_table_request_info *table_info);
132 int
133 netsnmp_table_build_oid_from_index(netsnmp_handler_registration
134 *reginfo,
135 netsnmp_request_info *reqinfo,
136 netsnmp_table_request_info
137 *table_info);
138 int netsnmp_table_build_result(netsnmp_handler_registration
139 *reginfo,
140 netsnmp_request_info
141 *reqinfo,
142 netsnmp_table_request_info
143 *table_info, u_char type,
144 u_char * result,
145 size_t result_len);
146 int
147 netsnmp_update_variable_list_from_index(netsnmp_table_request_info
148 *);
149 int
150 netsnmp_update_indexes_from_variable_list
151 (netsnmp_table_request_info *tri);
152 netsnmp_table_registration_info
153 *netsnmp_find_table_registration_info(netsnmp_handler_registration
154 *reginfo);
155 netsnmp_table_registration_info *
156 netsnmp_table_registration_info_clone(netsnmp_table_registration_info *tri);
157 void netsnmp_table_registration_info_free(netsnmp_table_registration_info *);
158
159 netsnmp_index * netsnmp_table_index_find_next_row(netsnmp_container *c,
160 netsnmp_table_request_info *tblreq);
161
162 unsigned int netsnmp_closest_column(unsigned int current,
163 netsnmp_column_info
164 *valid_columns);
165
166 Netsnmp_Node_Handler table_helper_handler;
167
168 #define netsnmp_table_helper_add_index(tinfo, type) snmp_varlist_add_variable(&tinfo->indexes, NULL, 0, (u_char)type, NULL, 0);
169
170 void
171 netsnmp_table_helper_add_indexes(netsnmp_table_registration_info
172 *tinfo, ...);
173
174 int netsnmp_check_getnext_reply(netsnmp_request_info *request,
175 oid * prefix, size_t prefix_len,
176 netsnmp_variable_list * newvar,
177 netsnmp_variable_list ** outvar);
178
179 netsnmp_table_request_info
180 *netsnmp_extract_table_info(netsnmp_request_info *);
181 netsnmp_oid_stash_node
182 **netsnmp_table_get_or_create_row_stash(netsnmp_agent_request_info
183 *reqinfo,
184 const u_char *
185 storage_name);
186 unsigned int
187 netsnmp_table_next_column(netsnmp_table_request_info *table_info);
188
189
190 int netsnmp_sparse_table_register(netsnmp_handler_registration *reginfo,
191 netsnmp_table_registration_info *tabreq);
192
193 netsnmp_mib_handler *netsnmp_sparse_table_handler_get(void);
194
195 #ifdef __cplusplus
196 }
197 #endif
198
199 #endif /* _TABLE_HANDLER_H_ */
200 /** @} */