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
22 #ifndef PHP_SNMP_H
23 #define PHP_SNMP_H
24
25 #define PHP_SNMP_VERSION PHP_VERSION
26
27 #if HAVE_SNMP
28
29 #ifndef DLEXPORT
30 #define DLEXPORT
31 #endif
32
33 extern zend_module_entry snmp_module_entry;
34 #define snmp_module_ptr &snmp_module_entry
35
36 #ifdef ZTS
37 #include "TSRM.h"
38 #endif
39
40 #include <net-snmp/net-snmp-config.h>
41 #include <net-snmp/net-snmp-includes.h>
42
43 PHP_MINIT_FUNCTION(snmp);
44 PHP_MSHUTDOWN_FUNCTION(snmp);
45 PHP_MINFO_FUNCTION(snmp);
46
47 typedef struct _php_snmp_object {
48 struct snmp_session *session;
49 int max_oids;
50 int valueretrieval;
51 int quick_print;
52 int enum_print;
53 int oid_output_format;
54 int snmp_errno;
55 int oid_increasing_check;
56 int exceptions_enabled;
57 char snmp_errstr[256];
58 zend_object zo;
59 } php_snmp_object;
60
php_snmp_fetch_object(zend_object * obj)61 static inline php_snmp_object *php_snmp_fetch_object(zend_object *obj) {
62 return (php_snmp_object *)((char*)(obj) - XtOffsetOf(php_snmp_object, zo));
63 }
64
65 #define Z_SNMP_P(zv) php_snmp_fetch_object(Z_OBJ_P((zv)))
66
67 typedef int (*php_snmp_read_t)(php_snmp_object *snmp_object, zval *retval);
68 typedef int (*php_snmp_write_t)(php_snmp_object *snmp_object, zval *newval);
69
70 typedef struct _ptp_snmp_prop_handler {
71 const char *name;
72 size_t name_length;
73 php_snmp_read_t read_func;
74 php_snmp_write_t write_func;
75 } php_snmp_prop_handler;
76
77 typedef struct _snmpobjarg {
78 char *oid;
79 char type;
80 char *value;
81 oid name[MAX_OID_LEN];
82 size_t name_length;
83 } snmpobjarg;
84
85 ZEND_BEGIN_MODULE_GLOBALS(snmp)
86 int valueretrieval;
87 ZEND_END_MODULE_GLOBALS(snmp)
88
89 #ifdef ZTS
90 #define SNMP_G(v) TSRMG(snmp_globals_id, zend_snmp_globals *, v)
91 #else
92 #define SNMP_G(v) (snmp_globals.v)
93 #endif
94
95 #define REGISTER_SNMP_CLASS_CONST_LONG(const_name, value) \
96 zend_declare_class_constant_long(php_snmp_ce, const_name, sizeof(const_name)-1, (zend_long)value);
97
98 #else
99
100 #define snmp_module_ptr NULL
101
102 #endif /* HAVE_SNMP */
103
104 #define phpext_snmp_ptr snmp_module_ptr
105
106 #endif /* PHP_SNMP_H */
107