php_snmp.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | https://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Authors: Rasmus Lerdorf <rasmus@php.net> |
  14. | Mike Jackson <mhjack@tscnet.com> |
  15. | Steven Lawrance <slawrance@technologist.com> |
  16. | Harrie Hazewinkel <harrie@lisanza.net> |
  17. | Johann Hanne <jonny@nurfuerspam.de> |
  18. | Boris Lytockin <lytboris@gmail.com> |
  19. +----------------------------------------------------------------------+
  20. */
  21. #ifndef PHP_SNMP_H
  22. #define PHP_SNMP_H
  23. #define PHP_SNMP_VERSION PHP_VERSION
  24. #if HAVE_SNMP
  25. #ifndef DLEXPORT
  26. #define DLEXPORT
  27. #endif
  28. extern zend_module_entry snmp_module_entry;
  29. #define snmp_module_ptr &snmp_module_entry
  30. #ifdef ZTS
  31. #include "TSRM.h"
  32. #endif
  33. #include <net-snmp/net-snmp-config.h>
  34. #include <net-snmp/net-snmp-includes.h>
  35. PHP_MINIT_FUNCTION(snmp);
  36. PHP_MSHUTDOWN_FUNCTION(snmp);
  37. PHP_MINFO_FUNCTION(snmp);
  38. typedef struct _php_snmp_object {
  39. struct snmp_session *session;
  40. int max_oids;
  41. int valueretrieval;
  42. int quick_print;
  43. int enum_print;
  44. int oid_output_format;
  45. int snmp_errno;
  46. int oid_increasing_check;
  47. int exceptions_enabled;
  48. char snmp_errstr[256];
  49. zend_object zo;
  50. } php_snmp_object;
  51. static inline php_snmp_object *php_snmp_fetch_object(zend_object *obj) {
  52. return (php_snmp_object *)((char*)(obj) - XtOffsetOf(php_snmp_object, zo));
  53. }
  54. #define Z_SNMP_P(zv) php_snmp_fetch_object(Z_OBJ_P((zv)))
  55. typedef int (*php_snmp_read_t)(php_snmp_object *snmp_object, zval *retval);
  56. typedef int (*php_snmp_write_t)(php_snmp_object *snmp_object, zval *newval);
  57. typedef struct _ptp_snmp_prop_handler {
  58. const char *name;
  59. size_t name_length;
  60. php_snmp_read_t read_func;
  61. php_snmp_write_t write_func;
  62. } php_snmp_prop_handler;
  63. typedef struct _snmpobjarg {
  64. char *oid;
  65. char type;
  66. char *value;
  67. oid name[MAX_OID_LEN];
  68. size_t name_length;
  69. } snmpobjarg;
  70. ZEND_BEGIN_MODULE_GLOBALS(snmp)
  71. int valueretrieval;
  72. ZEND_END_MODULE_GLOBALS(snmp)
  73. #ifdef ZTS
  74. #define SNMP_G(v) TSRMG(snmp_globals_id, zend_snmp_globals *, v)
  75. #else
  76. #define SNMP_G(v) (snmp_globals.v)
  77. #endif
  78. #define REGISTER_SNMP_CLASS_CONST_LONG(const_name, value) \
  79. zend_declare_class_constant_long(php_snmp_ce, const_name, sizeof(const_name)-1, (zend_long)value);
  80. #else
  81. #define snmp_module_ptr NULL
  82. #endif /* HAVE_SNMP */
  83. #define phpext_snmp_ptr snmp_module_ptr
  84. #endif /* PHP_SNMP_H */