xref: /PHP-5.4/ext/snmp/php_snmp.h (revision c0d060f5)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 5                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2014 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 
24 /* $Id$ */
25 
26 #ifndef PHP_SNMP_H
27 #define PHP_SNMP_H
28 
29 #define PHP_SNMP_VERSION "0.1"
30 
31 #if HAVE_SNMP
32 
33 #ifndef DLEXPORT
34 #define DLEXPORT
35 #endif
36 
37 extern zend_module_entry snmp_module_entry;
38 #define snmp_module_ptr &snmp_module_entry
39 
40 #ifdef ZTS
41 #include "TSRM.h"
42 #endif
43 
44 #include <net-snmp/net-snmp-config.h>
45 #include <net-snmp/net-snmp-includes.h>
46 
47 PHP_MINIT_FUNCTION(snmp);
48 PHP_MSHUTDOWN_FUNCTION(snmp);
49 PHP_MINFO_FUNCTION(snmp);
50 
51 PHP_FUNCTION(snmpget);
52 PHP_FUNCTION(snmpgetnext);
53 PHP_FUNCTION(snmpwalk);
54 PHP_FUNCTION(snmprealwalk);
55 PHP_FUNCTION(snmpset);
56 PHP_FUNCTION(snmp_get_quick_print);
57 PHP_FUNCTION(snmp_set_quick_print);
58 PHP_FUNCTION(snmp_set_enum_print);
59 PHP_FUNCTION(snmp_set_oid_output_format);
60 
61 PHP_FUNCTION(snmp2_get);
62 PHP_FUNCTION(snmp2_getnext);
63 PHP_FUNCTION(snmp2_walk);
64 PHP_FUNCTION(snmp2_real_walk);
65 PHP_FUNCTION(snmp2_set);
66 
67 PHP_FUNCTION(snmp3_get);
68 PHP_FUNCTION(snmp3_getnext);
69 PHP_FUNCTION(snmp3_walk);
70 PHP_FUNCTION(snmp3_real_walk);
71 PHP_FUNCTION(snmp3_set);
72 
73 PHP_FUNCTION(snmp_set_valueretrieval);
74 PHP_FUNCTION(snmp_get_valueretrieval);
75 
76 PHP_FUNCTION(snmp_read_mib);
77 
78 PHP_METHOD(SNMP, setSecurity);
79 PHP_METHOD(SNMP, close);
80 PHP_METHOD(SNMP, get);
81 PHP_METHOD(SNMP, getnext);
82 PHP_METHOD(SNMP, walk);
83 PHP_METHOD(SNMP, set);
84 PHP_METHOD(SNMP, getErrno);
85 PHP_METHOD(SNMP, getError);
86 
87 typedef struct _php_snmp_object {
88 	zend_object zo;
89 	struct snmp_session *session;
90 	int max_oids;
91 	int valueretrieval;
92 	int quick_print;
93 	int enum_print;
94 	int oid_output_format;
95 	int snmp_errno;
96 	int oid_increasing_check;
97 	int exceptions_enabled;
98 	char snmp_errstr[256];
99 } php_snmp_object;
100 
101 
102 typedef int (*php_snmp_read_t)(php_snmp_object *snmp_object, zval **retval TSRMLS_DC);
103 typedef int (*php_snmp_write_t)(php_snmp_object *snmp_object, zval *newval TSRMLS_DC);
104 
105 typedef struct _ptp_snmp_prop_handler {
106 	const char *name;
107 	size_t name_length;
108 	php_snmp_read_t read_func;
109 	php_snmp_write_t write_func;
110 } php_snmp_prop_handler;
111 
112 typedef struct _snmpobjarg {
113 	char *oid;
114 	char type;
115 	char *value;
116 	oid  name[MAX_OID_LEN];
117 	size_t name_length;
118 } snmpobjarg;
119 
120 ZEND_BEGIN_MODULE_GLOBALS(snmp)
121 	int valueretrieval;
122 ZEND_END_MODULE_GLOBALS(snmp)
123 
124 #ifdef ZTS
125 #define SNMP_G(v) TSRMG(snmp_globals_id, zend_snmp_globals *, v)
126 #else
127 #define SNMP_G(v) (snmp_globals.v)
128 #endif
129 
130 #define REGISTER_SNMP_CLASS_CONST_LONG(const_name, value) \
131 	zend_declare_class_constant_long(php_snmp_ce, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
132 
133 #else
134 
135 #define snmp_module_ptr NULL
136 
137 #endif /* HAVE_SNMP */
138 
139 #define phpext_snmp_ptr snmp_module_ptr
140 
141 #endif  /* PHP_SNMP_H */
142