table_container.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * table_container.h
  3. * $Id$
  4. */
  5. #ifndef _TABLE_CONTAINER_HANDLER_H_
  6. #define _TABLE_CONTAINER_HANDLER_H_
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /*
  11. * The table container helper is designed to simplify the task of
  12. * writing a table handler for the net-snmp agent when the data being
  13. * accessed is accessible via a netsnmp_container.
  14. *
  15. * Functionally, it is a specialized version of the more
  16. * generic table helper but easies the burden of GETNEXT processing by
  17. * retrieving the appropriate row for each index through
  18. * function calls which should be supplied by the module that wishes
  19. * help. The module the table_container helps should, afterwards,
  20. * never be called for the case of "MODE_GETNEXT" and only for the GET
  21. * and SET related modes instead.
  22. */
  23. #include <net-snmp/library/container.h>
  24. #include <net-snmp/agent/table.h>
  25. #define TABLE_CONTAINER_ROW "table_container:row"
  26. #define TABLE_CONTAINER_CONTAINER "table_container:container"
  27. #define TABLE_CONTAINER_KEY_NETSNMP_INDEX 1 /* default */
  28. #define TABLE_CONTAINER_KEY_VARBIND_INDEX 2
  29. #define TABLE_CONTAINER_KEY_VARBIND_RAW 3
  30. /* ====================================
  31. * Container Table API: MIB maintenance
  32. * ==================================== */
  33. /*
  34. * get an injectable container table handler
  35. */
  36. netsnmp_mib_handler *
  37. netsnmp_container_table_handler_get(netsnmp_table_registration_info *tabreq,
  38. netsnmp_container *container,
  39. char key_type);
  40. /*
  41. * register a container table
  42. */
  43. int
  44. netsnmp_container_table_register(netsnmp_handler_registration *reginfo,
  45. netsnmp_table_registration_info *tabreq,
  46. netsnmp_container *container,
  47. char key_type);
  48. int
  49. netsnmp_container_table_unregister(netsnmp_handler_registration *reginfo);
  50. /** retrieve the container used by the table_container helper */
  51. netsnmp_container*
  52. netsnmp_container_table_container_extract(netsnmp_request_info *request);
  53. /** find the context data used by the table_container helper */
  54. #ifdef NETSNMP_USE_INLINE
  55. NETSNMP_STATIC_INLINE void *
  56. netsnmp_container_table_row_extract(netsnmp_request_info *request)
  57. {
  58. /*
  59. * NOTE: this function must match in table_container.c and table_container.h.
  60. * if you change one, change them both!
  61. */
  62. return netsnmp_request_get_list_data(request, TABLE_CONTAINER_ROW);
  63. }
  64. NETSNMP_STATIC_INLINE void *
  65. netsnmp_container_table_extract_context(netsnmp_request_info *request)
  66. {
  67. /*
  68. * NOTE: this function must match in table_container.c and table_container.h.
  69. * if you change one, change them both!
  70. */
  71. return netsnmp_request_get_list_data(request, TABLE_CONTAINER_ROW);
  72. }
  73. #else
  74. void *
  75. netsnmp_container_table_row_extract(netsnmp_request_info *request);
  76. void *
  77. netsnmp_container_table_extract_context(netsnmp_request_info *request);
  78. #endif /* inline */
  79. void netsnmp_container_table_row_insert(netsnmp_request_info *request,
  80. netsnmp_index *row);
  81. void netsnmp_container_table_row_remove(netsnmp_request_info *request,
  82. netsnmp_index *row);
  83. /* ===================================
  84. * Container Table API: Row operations
  85. * =================================== */
  86. void *
  87. netsnmp_container_table_find_next_row(netsnmp_request_info *request,
  88. netsnmp_table_request_info *tblreq,
  89. netsnmp_container *container,
  90. char key_type );
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif /* _TABLE_CONTAINER_HANDLER_H_ */