| 1 |
/* |
| 2 |
* table_generic.c |
| 3 |
* |
| 4 |
* Generic table API framework |
| 5 |
*/ |
| 6 |
|
| 7 |
/** @defgroup table_generic generic_table_API |
| 8 |
* General requirements for a table helper. |
| 9 |
* @ingroup table |
| 10 |
* |
| 11 |
* A given table helper need not implement the whole of this API, |
| 12 |
* and may need to adjust the prototype of certain routines. |
| 13 |
* But this description provides a suitable standard design framework. |
| 14 |
* |
| 15 |
* @{ |
| 16 |
*/ |
| 17 |
|
| 18 |
/* ======================================================= |
| 19 |
* |
| 20 |
* Table Maintenance: |
| 21 |
* create/delete table |
| 22 |
* create/copy/clone/delete row |
| 23 |
* add/replace/remove row |
| 24 |
* |
| 25 |
* ======================================================= */ |
| 26 |
|
| 27 |
/** @defgroup table_maintenance table_maintenance |
| 28 |
* |
| 29 |
* Routines for maintaining the contents of a table. |
| 30 |
* This would typically be part of implementing an SNMP MIB, |
| 31 |
* but could potentially also be used for a standalone table. |
| 32 |
* |
| 33 |
* This section of the generic API is primarily relevant to |
| 34 |
* table helpers where the representation of the table is |
| 35 |
* constructed and maintained within the helper itself. |
| 36 |
* "External" tables will typically look after such aspects |
| 37 |
* directly, although this section of the abstract API |
| 38 |
* framework could also help direct the design of such |
| 39 |
* table-specific implementations. |
| 40 |
* |
| 41 |
* @{ |
| 42 |
*/ |
| 43 |
|
| 44 |
/** Create a structure to represent the table. |
| 45 |
* |
| 46 |
* This could be as simple as the head of a linked |
| 47 |
* list, or a more complex container structure. |
| 48 |
* The 'name' field would typically be used to |
| 49 |
* distinguish between several tables implemented |
| 50 |
* using the same table helper. The 'flags' field |
| 51 |
* would be used to control various (helper-specific) |
| 52 |
* aspects of table behaviour. |
| 53 |
* |
| 54 |
* The table structure returned should typically be |
| 55 |
* regarded as an opaque, private structure. All |
| 56 |
* operations on the content of the table should |
| 57 |
* ideally use the appropriate routines from this API. |
| 58 |
*/ |
| 59 |
void * |
| 60 |
netsnmp_generic_create_table( const char *name, int flags ) { |
| 61 |
} |
| 62 |
|
| 63 |
/** Release the structure representing a table. |
| 64 |
* Any rows still contained within the table |
| 65 |
* should also be removed and deleted. |
| 66 |
*/ |
| 67 |
void |
| 68 |
netsnmp_generic_delete_table( void *table ) { |
| 69 |
} |
| 70 |
|
| 71 |
/** Create a new row structure suitable for this style of table. |
| 72 |
* Note that this would typically be a 'standalone' row, and |
| 73 |
* would not automatically be inserted into an actual table. |
| 74 |
*/ |
| 75 |
void * |
| 76 |
netsnmp_generic_create_row( void ) { |
| 77 |
} |
| 78 |
|
| 79 |
/** Create a new copy of the specified row. |
| 80 |
*/ |
| 81 |
void * |
| 82 |
netsnmp_generic_clone_row( void *row ) { |
| 83 |
} |
| 84 |
|
| 85 |
/** Copy the contents of one row into another. |
| 86 |
* The destination row structure should be |
| 87 |
* created before this routine is called. |
| 88 |
*/ |
| 89 |
int |
| 90 |
netsnmp_generic_copy_row( void *dst_row, void *src_row ) { |
| 91 |
} |
| 92 |
|
| 93 |
/** Delete a row data structure. |
| 94 |
* The row should be removed from any relevant |
| 95 |
* table(s) before this routine is called. |
| 96 |
*/ |
| 97 |
void |
| 98 |
netsnmp_generic_delete_row( void *row ) { |
| 99 |
} |
| 100 |
|
| 101 |
/** Add a row to the table. |
| 102 |
*/ |
| 103 |
int |
| 104 |
netsnmp_generic_add_row( void *table, void *row ) { |
| 105 |
} |
| 106 |
|
| 107 |
/** Replace one row with another in the table. |
| 108 |
* This will typically (but not necessarily) involve |
| 109 |
* two rows sharing the same index information (e.g. |
| 110 |
* to implement update/restore-style SET behaviour). |
| 111 |
*/ |
| 112 |
int |
| 113 |
netsnmp_generic_replace_row( void *table, void *old_row, void *new_row ) { |
| 114 |
} |
| 115 |
|
| 116 |
/** Remove a row from the table. |
| 117 |
* The data structure for the row should not be released, |
| 118 |
* and would be the return value of this routine. |
| 119 |
*/ |
| 120 |
void * |
| 121 |
netsnmp_generic_remove_row( void *table, void *row ) { |
| 122 |
} |
| 123 |
|
| 124 |
/** Remove and delete a row from the table. |
| 125 |
*/ |
| 126 |
void |
| 127 |
netsnmp_generic_remove_delete_row( void *table, void *row ) { |
| 128 |
} |
| 129 |
|
| 130 |
/** @} end of table_maintenance */ |
| 131 |
|
| 132 |
/* ======================================================= |
| 133 |
* |
| 134 |
* MIB Maintenance: |
| 135 |
* create a handler registration |
| 136 |
* register/unregister table |
| 137 |
* extract table from request |
| 138 |
* extract/insert row |
| 139 |
* |
| 140 |
* ======================================================= */ |
| 141 |
|
| 142 |
/** @defgroup mib_maintenance mib_maintenance |
| 143 |
* |
| 144 |
* Routines for maintaining a MIB table. |
| 145 |
* |
| 146 |
* @{ |
| 147 |
*/ |
| 148 |
|
| 149 |
/** Create a MIB handler structure. |
| 150 |
* This will typically be invoked within the corresponding |
| 151 |
* 'netsnmp_generic_register' routine (or the registration |
| 152 |
* code of a sub-helper based on this helper). |
| 153 |
* |
| 154 |
* Alternatively, it might be called from the initialisation |
| 155 |
* code of a particular MIB table implementation. |
| 156 |
*/ |
| 157 |
netsnmp_mib_handler * |
| 158 |
netsnmp_generic_get_handler(void /* table specific */ ) { |
| 159 |
|
| 160 |
} |
| 161 |
|
| 162 |
/** Free a MIB handler structure, releasing any related resources. |
| 163 |
* Possibly called automatically by 'netsnmp_unregister_handler' ? |
| 164 |
*/ |
| 165 |
netsnmp_generic_free_handler( netsnmp_mib_handler *handler ) { |
| 166 |
|
| 167 |
} |
| 168 |
|
| 169 |
/** Register a MIB table with the SNMP agent. |
| 170 |
*/ |
| 171 |
int |
| 172 |
netsnmp_generic_register(netsnmp_handler_registration *reginfo, |
| 173 |
void *table, |
| 174 |
netsnmp_table_registration_info *table_info) { |
| 175 |
} |
| 176 |
|
| 177 |
/** Unregister a MIB table from the SNMP agent. |
| 178 |
* This should also release the internal representation of the table. |
| 179 |
* ?? Is a table-specific version of this needed, or would |
| 180 |
* 'netsnmp_unregister_handler' + 'netsnmp_generic_free_handler' do? |
| 181 |
*/ |
| 182 |
int |
| 183 |
netsnmp_generic_unregister(netsnmp_handler_registration *reginfo) { |
| 184 |
} |
| 185 |
|
| 186 |
/** Extract the table relating to a requested varbind. |
| 187 |
*/ |
| 188 |
void |
| 189 |
netsnmp_generic_extract_table( netsnmp_request_info *request ) { |
| 190 |
} |
| 191 |
|
| 192 |
/** Extract the row relating to a requested varbind. |
| 193 |
*/ |
| 194 |
void |
| 195 |
netsnmp_generic_extract_row( netsnmp_request_info *request ) { |
| 196 |
} |
| 197 |
|
| 198 |
/** Associate a (new) row with the requested varbind. |
| 199 |
* The row should also be associated with any other |
| 200 |
* varbinds that refer to the same index values. |
| 201 |
*/ |
| 202 |
void |
| 203 |
netsnmp_generic_insert_row( netsnmp_request_info *request, void *row ) { |
| 204 |
} |
| 205 |
|
| 206 |
/** @} end of mib_maintenance */ |
| 207 |
|
| 208 |
/* ======================================================= |
| 209 |
* |
| 210 |
* Row Operations |
| 211 |
* get first/this/next row |
| 212 |
* get row/next row by index |
| 213 |
* get row/next row by OID |
| 214 |
* number of rows |
| 215 |
* |
| 216 |
* ======================================================= */ |
| 217 |
|
| 218 |
/** @defgroup table_rows table_rows |
| 219 |
* |
| 220 |
* Routines for working with the rows of a table. |
| 221 |
* |
| 222 |
* @{ |
| 223 |
*/ |
| 224 |
|
| 225 |
/** Retrieve the first row of the table. |
| 226 |
*/ |
| 227 |
void * |
| 228 |
netsnmp_generic_row_first( void *table ) { |
| 229 |
} |
| 230 |
|
| 231 |
/** Retrieve the given row from the table. |
| 232 |
* This could either be the same data pointer, |
| 233 |
* passed in, or a separate row structure |
| 234 |
* sharing the same index values (or NULL). |
| 235 |
* |
| 236 |
* This routine also provides a means to tell |
| 237 |
* whether a given row is present in the table. |
| 238 |
*/ |
| 239 |
void * |
| 240 |
netsnmp_generic_row_get( void *table, void *row ) { |
| 241 |
} |
| 242 |
|
| 243 |
/** Retrieve the following row from the table. |
| 244 |
* If the specified row is not present, this |
| 245 |
* routine should return the entry next after |
| 246 |
* the position this row would have occupied. |
| 247 |
*/ |
| 248 |
void * |
| 249 |
netsnmp_generic_row_next( void *table, void *row ) { |
| 250 |
} |
| 251 |
|
| 252 |
/** Retrieve the row with the specified index values. |
| 253 |
*/ |
| 254 |
void * |
| 255 |
netsnmp_generic_row_get_byidx( void *table, |
| 256 |
netsnmp_variable_list *indexes ) { |
| 257 |
} |
| 258 |
|
| 259 |
/** Retrieve the next row after the specified index values. |
| 260 |
*/ |
| 261 |
void * |
| 262 |
netsnmp_generic_row_next_byidx( void *table, |
| 263 |
netsnmp_variable_list *indexes ) { |
| 264 |
|
| 265 |
} |
| 266 |
|
| 267 |
/** Retrieve the row with the specified instance OIDs. |
| 268 |
*/ |
| 269 |
void * |
| 270 |
netsnmp_generic_row_get_byoid( void *table, oid *instance, size_t len ) { |
| 271 |
} |
| 272 |
|
| 273 |
/** Retrieve the next row after the specified instance OIDs. |
| 274 |
*/ |
| 275 |
void * |
| 276 |
netsnmp_generic_row_next_byoid( void *table, oid *instance, size_t len ) { |
| 277 |
} |
| 278 |
|
| 279 |
/** Report the number of rows in the table. |
| 280 |
*/ |
| 281 |
int |
| 282 |
netsnmp_generic_row_count( void *table ) { |
| 283 |
} |
| 284 |
|
| 285 |
/** @} end of table_rows */ |
| 286 |
|
| 287 |
/* ======================================================= |
| 288 |
* |
| 289 |
* Index Operations |
| 290 |
* get table index structure |
| 291 |
* get row index values/OIDs |
| 292 |
* compare row with index/OIDs |
| 293 |
* subtree comparisons (index/OIDs) |
| 294 |
* |
| 295 |
* ======================================================= */ |
| 296 |
|
| 297 |
/** @defgroup table_indexes table_indexes |
| 298 |
* |
| 299 |
* Routines for working with row indexes. |
| 300 |
* |
| 301 |
* @{ |
| 302 |
*/ |
| 303 |
|
| 304 |
/** Retrieve the indexing structure of the table. |
| 305 |
*/ |
| 306 |
netsnmp_variable_list * |
| 307 |
netsnmp_generic_idx( void *table ) { |
| 308 |
} |
| 309 |
|
| 310 |
/** Report the index values for a row. |
| 311 |
*/ |
| 312 |
netsnmp_variable_list * |
| 313 |
netsnmp_generic_row_idx( void *row ) { |
| 314 |
} |
| 315 |
|
| 316 |
/** Report the instance OIDs for a row. |
| 317 |
*/ |
| 318 |
size_t |
| 319 |
netsnmp_generic_row_oid( void *row, oid *instances ) { |
| 320 |
} |
| 321 |
|
| 322 |
/** Compare a row against the specified index values. |
| 323 |
*/ |
| 324 |
int |
| 325 |
netsnmp_generic_compare_idx( void *row, netsnmp_variable_list *index ) { |
| 326 |
} |
| 327 |
|
| 328 |
/** Compare a row against the specified instance OIDs. |
| 329 |
*/ |
| 330 |
int |
| 331 |
netsnmp_generic_compare_oid( void *row, oid *instances, size_t len ) { |
| 332 |
} |
| 333 |
|
| 334 |
/** Check if a row lies within a subtree of index values. |
| 335 |
*/ |
| 336 |
int |
| 337 |
netsnmp_generic_compare_subtree_idx( void *row, netsnmp_variable_list *index ) { |
| 338 |
} |
| 339 |
|
| 340 |
/** Check if a row lies within a subtree of instance OIDs. |
| 341 |
*/ |
| 342 |
int |
| 343 |
netsnmp_generic_compare_subtree_oid( void *row, oid *instances, size_t len ) { |
| 344 |
} |
| 345 |
|
| 346 |
/** @} end of table_indexes */ |
| 347 |
/** @} end of table_generic */ |