php_snmp.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Rasmus Lerdorf <rasmus@php.net> |
  16. | Mike Jackson <mhjack@tscnet.com> |
  17. | Steven Lawrance <slawrance@technologist.com> |
  18. | Harrie Hazewinkel <harrie@lisanza.net> |
  19. | Johann Hanne <jonny@nurfuerspam.de> |
  20. | Boris Lytockin <lytboris@gmail.com> |
  21. +----------------------------------------------------------------------+
  22. */
  23. /* $Id$ */
  24. #ifndef PHP_SNMP_H
  25. #define PHP_SNMP_H
  26. #define PHP_SNMP_VERSION "0.1"
  27. #if HAVE_SNMP
  28. #ifndef DLEXPORT
  29. #define DLEXPORT
  30. #endif
  31. extern zend_module_entry snmp_module_entry;
  32. #define snmp_module_ptr &snmp_module_entry
  33. #ifdef ZTS
  34. #include "TSRM.h"
  35. #endif
  36. #include <net-snmp/net-snmp-config.h>
  37. #include <net-snmp/net-snmp-includes.h>
  38. PHP_MINIT_FUNCTION(snmp);
  39. PHP_MSHUTDOWN_FUNCTION(snmp);
  40. PHP_MINFO_FUNCTION(snmp);
  41. PHP_FUNCTION(snmpget);
  42. PHP_FUNCTION(snmpgetnext);
  43. PHP_FUNCTION(snmpwalk);
  44. PHP_FUNCTION(snmprealwalk);
  45. PHP_FUNCTION(snmpset);
  46. PHP_FUNCTION(snmp_get_quick_print);
  47. PHP_FUNCTION(snmp_set_quick_print);
  48. PHP_FUNCTION(snmp_set_enum_print);
  49. PHP_FUNCTION(snmp_set_oid_output_format);
  50. PHP_FUNCTION(snmp2_get);
  51. PHP_FUNCTION(snmp2_getnext);
  52. PHP_FUNCTION(snmp2_walk);
  53. PHP_FUNCTION(snmp2_real_walk);
  54. PHP_FUNCTION(snmp2_set);
  55. PHP_FUNCTION(snmp3_get);
  56. PHP_FUNCTION(snmp3_getnext);
  57. PHP_FUNCTION(snmp3_walk);
  58. PHP_FUNCTION(snmp3_real_walk);
  59. PHP_FUNCTION(snmp3_set);
  60. PHP_FUNCTION(snmp_set_valueretrieval);
  61. PHP_FUNCTION(snmp_get_valueretrieval);
  62. PHP_FUNCTION(snmp_read_mib);
  63. PHP_METHOD(SNMP, setSecurity);
  64. PHP_METHOD(SNMP, close);
  65. PHP_METHOD(SNMP, get);
  66. PHP_METHOD(SNMP, getnext);
  67. PHP_METHOD(SNMP, walk);
  68. PHP_METHOD(SNMP, set);
  69. PHP_METHOD(SNMP, getErrno);
  70. PHP_METHOD(SNMP, getError);
  71. typedef struct _php_snmp_object {
  72. zend_object zo;
  73. struct snmp_session *session;
  74. int max_oids;
  75. int valueretrieval;
  76. int quick_print;
  77. int enum_print;
  78. int oid_output_format;
  79. int snmp_errno;
  80. int oid_increasing_check;
  81. int exceptions_enabled;
  82. char snmp_errstr[256];
  83. } php_snmp_object;
  84. typedef int (*php_snmp_read_t)(php_snmp_object *snmp_object, zval **retval TSRMLS_DC);
  85. typedef int (*php_snmp_write_t)(php_snmp_object *snmp_object, zval *newval TSRMLS_DC);
  86. typedef struct _ptp_snmp_prop_handler {
  87. const char *name;
  88. size_t name_length;
  89. php_snmp_read_t read_func;
  90. php_snmp_write_t write_func;
  91. } php_snmp_prop_handler;
  92. typedef struct _snmpobjarg {
  93. char *oid;
  94. char type;
  95. char *value;
  96. oid name[MAX_OID_LEN];
  97. size_t name_length;
  98. } snmpobjarg;
  99. ZEND_BEGIN_MODULE_GLOBALS(snmp)
  100. int valueretrieval;
  101. ZEND_END_MODULE_GLOBALS(snmp)
  102. #ifdef ZTS
  103. #define SNMP_G(v) TSRMG(snmp_globals_id, zend_snmp_globals *, v)
  104. #else
  105. #define SNMP_G(v) (snmp_globals.v)
  106. #endif
  107. #define REGISTER_SNMP_CLASS_CONST_LONG(const_name, value) \
  108. zend_declare_class_constant_long(php_snmp_ce, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
  109. #else
  110. #define snmp_module_ptr NULL
  111. #endif /* HAVE_SNMP */
  112. #define phpext_snmp_ptr snmp_module_ptr
  113. #endif /* PHP_SNMP_H */