summaryrefslogtreecommitdiff
path: root/agent/helpers/table_generic.c
blob: 75424f3a1e14b54416a02ef12a75912eb2afe884 (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
/*
 * table_generic.c
 *
 *    Generic table API framework
 */

/** @defgroup table_generic generic_table_API
 *  General requirements for a table helper.
 *  @ingroup table
 *
 * A given table helper need not implement the whole of this API,
 *   and may need to adjust the prototype of certain routines.
 * But this description provides a suitable standard design framework.
 *   
 * @{
 */

/* =======================================================
 * 
 *  Table Maintenance:
 *      create/delete table
 *      create/copy/clone/delete row
 *      add/replace/remove row
 *
 * ======================================================= */

/** @defgroup table_maintenance table_maintenance
 *
 * Routines for maintaining the contents of a table.
 * This would typically be part of implementing an SNMP MIB,
 *   but could potentially also be used for a standalone table.
 *
 * This section of the generic API is primarily relevant to
 *   table helpers where the representation of the table is 
 *   constructed and maintained within the helper itself.
 * "External" tables will typically look after such aspects
 *   directly, although this section of the abstract API 
 *   framework could also help direct the design of such
 *   table-specific implementations.
 *
 * @{
 */

/** Create a structure to represent the table.
  *
  * This could be as simple as the head of a linked
  *   list, or a more complex container structure.
  * The 'name' field would typically be used to
  *  distinguish between several tables implemented
  *  using the same table helper.  The 'flags' field
  *  would be used to control various (helper-specific)
  *  aspects of table behaviour.
  *
  * The table structure returned should typically be
  *  regarded as an opaque, private structure. All
  *  operations on the content of the table should
  *  ideally use the appropriate routines from this API.
  */
void *
netsnmp_generic_create_table( const char *name, int flags ) {
}

/** Release the structure representing a table.
  * Any rows still contained within the table
  *   should also be removed and deleted.
  */
void
netsnmp_generic_delete_table( void *table ) {
}

/** Create a new row structure suitable for this style of table.
  * Note that this would typically be a 'standalone' row, and
  *   would not automatically be inserted into an actual table.
  */
void *
netsnmp_generic_create_row( void ) {
}

/** Create a new copy of the specified row.
  */
void *
netsnmp_generic_clone_row( void *row ) {
}

/** Copy the contents of one row into another.
  * The destination row structure should be
  *   created before this routine is called.
  */
int
netsnmp_generic_copy_row( void *dst_row, void *src_row ) {
}

/** Delete a row data structure.
  * The row should be removed from any relevant
  *   table(s) before this routine is called.
  */
void
netsnmp_generic_delete_row( void *row ) {
}

/** Add a row to the table.
  */
int
netsnmp_generic_add_row( void *table, void *row ) {
}

/** Replace one row with another in the table.
  * This will typically (but not necessarily) involve
  *   two rows sharing the same index information (e.g.
  *   to implement update/restore-style SET behaviour).
  */
int
netsnmp_generic_replace_row( void *table, void *old_row, void *new_row ) {
}

/** Remove a row from the table.
  * The data structure for the row should not be released,
  *   and would be the return value of this routine.
  */
void *
netsnmp_generic_remove_row( void *table, void *row ) {
}

/** Remove and delete a row from the table.
  */
void
netsnmp_generic_remove_delete_row( void *table, void *row ) {
}

/** @} end of table_maintenance */

/* =======================================================
 * 
 *  MIB Maintenance:
 *      create a handler registration
 *      register/unregister table
 *      extract table from request
 *      extract/insert row
 *
 * ======================================================= */

/** @defgroup mib_maintenance mib_maintenance
 *
 * Routines for maintaining a MIB table.
 *
 * @{
 */

/** Create a MIB handler structure.
  * This will typically be invoked within the corresponding
  *   'netsnmp_generic_register' routine (or the registration
  *   code of a sub-helper based on this helper).
  *
  * Alternatively, it might be called from the initialisation
  *   code of a particular MIB table implementation.
  */
netsnmp_mib_handler *
netsnmp_generic_get_handler(void /* table specific */ ) {

}

/** Free a MIB handler structure, releasing any related resources.
  * Possibly called automatically by 'netsnmp_unregister_handler' ?
  */
netsnmp_generic_free_handler( netsnmp_mib_handler *handler ) {

}

/** Register a MIB table with the SNMP agent.
  */
int
netsnmp_generic_register(netsnmp_handler_registration    *reginfo,
                         void                            *table,
                         netsnmp_table_registration_info *table_info) {
}

/** Unregister a MIB table from the SNMP agent.
  * This should also release the internal representation of the table.
  * ?? Is a table-specific version of this needed, or would
  *    'netsnmp_unregister_handler' + 'netsnmp_generic_free_handler' do?
  */
int
netsnmp_generic_unregister(netsnmp_handler_registration    *reginfo) {
}

/** Extract the table relating to a requested varbind.
  */
void
netsnmp_generic_extract_table( netsnmp_request_info *request ) {
}

/** Extract the row relating to a requested varbind.
  */
void
netsnmp_generic_extract_row( netsnmp_request_info *request ) {
}

/** Associate a (new) row with the requested varbind.
  * The row should also be associated with any other
  *   varbinds that refer to the same index values.
  */
void
netsnmp_generic_insert_row( netsnmp_request_info *request, void *row ) {
}

/** @} end of mib_maintenance */

/* =======================================================
 * 
 *  Row Operations
 *      get first/this/next row
 *      get row/next row by index
 *      get row/next row by OID
 *      number of rows
 *
 * ======================================================= */

/** @defgroup table_rows table_rows
 *
 * Routines for working with the rows of a table.
 *
 * @{
 */

/** Retrieve the first row of the table.
  */
void *
netsnmp_generic_row_first( void *table ) {
}

/** Retrieve the given row from the table.
  * This could either be the same data pointer,
  *   passed in, or a separate row structure
  *   sharing the same index values (or NULL).
  *
  * This routine also provides a means to tell
  *   whether a given row is present in the table.
  */
void *
netsnmp_generic_row_get( void *table, void *row ) {
}

/** Retrieve the following row from the table.
  * If the specified row is not present, this
  *   routine should return the entry next after
  *   the position this row would have occupied.
  */
void *
netsnmp_generic_row_next( void *table, void *row ) {
}

/** Retrieve the row with the specified index values.
  */
void *
netsnmp_generic_row_get_byidx(  void *table,
                                netsnmp_variable_list *indexes ) {
}

/** Retrieve the next row after the specified index values.
  */
void *
netsnmp_generic_row_next_byidx( void *table,
                                netsnmp_variable_list *indexes ) {

}

/** Retrieve the row with the specified instance OIDs.
  */
void *
netsnmp_generic_row_get_byoid(  void *table, oid *instance, size_t len ) {
}

/** Retrieve the next row after the specified instance OIDs.
  */
void *
netsnmp_generic_row_next_byoid( void *table, oid *instance, size_t len ) {
}

/** Report the number of rows in the table.
  */
int
netsnmp_generic_row_count( void *table ) {
}

/** @} end of table_rows */

/* =======================================================
 * 
 *  Index Operations
 *      get table index structure
 *      get row index values/OIDs
 *      compare row with index/OIDs
 *      subtree comparisons (index/OIDs)
 *
 * ======================================================= */

/** @defgroup table_indexes table_indexes
 *
 * Routines for working with row indexes.
 *
 * @{
 */

/** Retrieve the indexing structure of the table.
  */
netsnmp_variable_list *
netsnmp_generic_idx( void *table ) {
}

/** Report the index values for a row.
  */
netsnmp_variable_list *
netsnmp_generic_row_idx( void *row ) {
}

/** Report the instance OIDs for a row.
  */
size_t
netsnmp_generic_row_oid( void *row, oid *instances ) {
}

/** Compare a row against the specified index values.
  */
int
netsnmp_generic_compare_idx( void *row, netsnmp_variable_list *index ) {
}

/** Compare a row against the specified instance OIDs.
  */
int
netsnmp_generic_compare_oid( void *row, oid *instances, size_t len ) {
}

/** Check if a row lies within a subtree of index values.
  */
int
netsnmp_generic_compare_subtree_idx( void *row, netsnmp_variable_list *index ) {
}

/** Check if a row lies within a subtree of instance OIDs.
  */
int
netsnmp_generic_compare_subtree_oid( void *row, oid *instances, size_t len ) {
}

/** @} end of table_indexes */
/** @} end of table_generic */