Debian Codegraph @

include/net-snmp/output_api.h

raw
1 #ifndef NET_SNMP_OUTPUT_API_H
2 #define NET_SNMP_OUTPUT_API_H
3
4 /**
5 * Library API routines concerned with logging and message output
6 * (including error handling and debugging).
7 */
8
9 #include <stdarg.h> /* for va_list */
10 #include <net-snmp/types.h>
11 #include <net-snmp/library/netsnmp-attribute-format.h>
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 /* Error reporting */
18 NETSNMP_IMPORT
19 void snmp_error(netsnmp_session *sess, int *clib_errorno,
20 int *snmp_errorno, char **errstring);
21 NETSNMP_IMPORT
22 void snmp_sess_error( void *sess, int *clib_errorno,
23 int *snmp_errorno, char **errstring);
24
25 NETSNMP_IMPORT
26 const char *snmp_api_errstring(int snmp_errorno); /* library errors */
27 NETSNMP_IMPORT
28 const char *snmp_errstring(int snmp_errorno); /* protocol errors */
29
30 NETSNMP_IMPORT
31 void snmp_perror(const char *msg); /* for parsing errors only */
32
33 NETSNMP_IMPORT
34 void snmp_sess_perror(const char *msg, netsnmp_session *sess);
35 /* for all other SNMP library errors */
36 NETSNMP_IMPORT
37 void snmp_log_perror(const char *msg);
38 /* for system library errors */
39
40 /* Logging messages */
41
42 NETSNMP_IMPORT
43 int snmp_log( int priority, const char *format, ...)
44 NETSNMP_ATTRIBUTE_FORMAT(printf, 2, 3);
45 NETSNMP_IMPORT
46 int snmp_vlog(int priority, const char *format, va_list ap);
47 NETSNMP_IMPORT
48 int snmp_get_do_logging( void);
49 NETSNMP_IMPORT
50 void snmp_disable_log( void);
51 NETSNMP_IMPORT
52 void shutdown_snmp_logging( void);
53
54 #undef _LOG_ATTR
55
56 /* Debug messages */
57 #ifndef NETSNMP_NO_DEBUGGING
58 #include <net-snmp/library/snmp_debug.h> /* for internal macros */
59 #define DEBUGMSG(x) do {if (_DBG_IF_) {debugmsg x;} }while(0)
60 #define DEBUGMSGT(x) do {if (_DBG_IF_) {__DBGMSGT(x);} }while(0)
61 #define DEBUGTRACE do {if (_DBG_IF_) {__DBGTRACE;} }while(0)
62 #define DEBUGTRACETOK(x) do {if (_DBG_IF_) {__DBGTRACETOK(x);} }while(0)
63 #define DEBUGMSGL(x) do {if (_DBG_IF_) {__DBGMSGL(x);} }while(0)
64 #define DEBUGMSGTL(x) do {if (_DBG_IF_) {__DBGMSGTL(x);} }while(0)
65 #define DEBUGMSGOID(x) do {if (_DBG_IF_) {__DBGMSGOID(x);} }while(0)
66 #define DEBUGMSGSUBOID(x) do {if (_DBG_IF_) {__DBGMSGSUBOID(x);} }while(0)
67 #define DEBUGMSGVAR(x) do {if (_DBG_IF_) {__DBGMSGVAR(x);} }while(0)
68 #define DEBUGMSGOIDRANGE(x) do {if (_DBG_IF_) {__DBGMSGOIDRANGE(x);} }while(0)
69 #define DEBUGMSGHEX(x) do {if (_DBG_IF_) {__DBGMSGHEX(x);} }while(0)
70 #define DEBUGMSGHEXTLI(x) do {if (_DBG_IF_) {__DBGMSGHEXTLI(x);} }while(0)
71 #define DEBUGINDENTADD(x) do {if (_DBG_IF_) {__DBGINDENTADD(x);} }while(0)
72 #define DEBUGINDENTMORE() do {if (_DBG_IF_) {__DBGINDENTMORE();} }while(0)
73 #define DEBUGINDENTLESS() do {if (_DBG_IF_) {__DBGINDENTLESS();} }while(0)
74 #define DEBUGPRINTINDENT(token) \
75 do {if (_DBG_IF_) {__DBGPRINTINDENT(token);} }while(0)
76 #define DEBUGDUMPHEADER(token,x) \
77 do {if (_DBG_IF_) {__DBGDUMPHEADER(token,x);} }while(0)
78 #define DEBUGDUMPSECTION(token,x) \
79 do {if (_DBG_IF_) {__DBGDUMPSECTION(token,x);} }while(0)
80 #define DEBUGDUMPSETUP(token,buf,len) \
81 do {if (_DBG_IF_) {__DBGDUMPSETUP(token,buf,len);} }while(0)
82 #define DEBUGMSG_NC(x) do { __DBGMSG_NC(x); }while(0)
83 #define DEBUGMSGT_NC(x) do { __DBGMSGT_NC(x); }while(0)
84
85 #else /* NETSNMP_NO_DEBUGGING := enable streamlining of the code */
86
87 NETSNMP_STATIC_INLINE void
88 netsnmp_debug_no_msg(const char *token, const char *fmt, ...)
89 { }
90
91 NETSNMP_STATIC_INLINE void
92 netsnmp_debug_no_tracetok(const char *token)
93 { }
94
95 NETSNMP_STATIC_INLINE void
96 netsnmp_debug_no_oid(const char *token, const oid *oid, size_t oid_len)
97 { }
98
99 struct variable_list;
100
101 NETSNMP_STATIC_INLINE void
102 netsnmp_debug_no_var(const char *token, const struct variable_list *var)
103 { }
104
105 NETSNMP_STATIC_INLINE void
106 netsnmp_debug_no_dumpsetup(const char *token, const void *buf, size_t len)
107 { }
108
109 #define DEBUGMSG(x) do { netsnmp_debug_no_msg x; } while (0)
110 #define DEBUGMSGT(x) do { netsnmp_debug_no_msg x; } while (0)
111 #define DEBUGTRACE do { } while (0)
112 #define DEBUGTRACETOK(x) \
113 do { netsnmp_debug_no_tracetok(x); } while (0)
114 #define DEBUGMSGL(x) do { netsnmp_debug_no_msg x; } while (0)
115 #define DEBUGMSGTL(x) do { netsnmp_debug_no_msg x; } while (0)
116 #define DEBUGMSGOID(x) do { netsnmp_debug_no_oid x; } while (0)
117 #define DEBUGMSGSUBOID(x) do { netsnmp_debug_no_oid x; } while (0)
118 #define DEBUGMSGVAR(x) do { netsnmp_debug_no_var x; } while (0)
119 #define DEBUGMSGOIDRANGE(x)
120 #define DEBUGMSGHEX(x)
121 #define DEBUGIF(x) if(0)
122 #define DEBUGDUMP(t,b,l,p)
123 #define DEBUGINDENTMORE()
124 #define DEBUGINDENTLESS()
125 #define DEBUGINDENTADD(x)
126 #define DEBUGMSGHEXTLI(x)
127 #define DEBUGPRINTINDENT(token)
128 #define DEBUGDUMPHEADER(token,x)
129 #define DEBUGDUMPSECTION(token,x)
130 #define DEBUGDUMPSETUP(token, buf, len) \
131 do { netsnmp_debug_no_dumpsetup(token, buf, len); } while (0)
132
133 #define DEBUGMSG_NC(x) do { netsnmp_debug_no_msg x; } while (0)
134 #define DEBUGMSGT_NC(x) do { netsnmp_debug_no_msg x; } while (0)
135
136 #endif /* NETSNMP_NO_DEBUGGING */
137
138 NETSNMP_IMPORT
139 void debug_register_tokens(const char *tokens);
140 NETSNMP_IMPORT
141 int debug_enable_token_logs (const char *token);
142 NETSNMP_IMPORT
143 int debug_disable_token_logs (const char *token);
144 NETSNMP_IMPORT
145 int debug_is_token_registered(const char *token);
146 NETSNMP_IMPORT
147 void snmp_set_do_debugging(int);
148 NETSNMP_IMPORT
149 int snmp_get_do_debugging(void);
150 #ifndef NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL
151 NETSNMP_IMPORT
152 void netsnmp_set_debug_log_level(int val);
153 NETSNMP_IMPORT
154 int netsnmp_get_debug_log_level(void);
155 #endif /* NETSNMP_DISABLE_DYNAMIC_LOG_LEVEL */
156
157 /*
158 * Having extracted the main ("public API") calls relevant
159 * to this area of the Net-SNMP project, the next step is to
160 * identify the related "public internal API" routines.
161 *
162 * In due course, these should probably be gathered
163 * together into a companion 'library/output_api.h' header file.
164 * [Or some suitable name]
165 *
166 * But for the time being, the expectation is that the
167 * traditional headers that provided the above definitions
168 * will probably also cover the relevant internal API calls.
169 * Hence they are listed here:
170 */
171
172 #ifdef __cplusplus
173 }
174 #endif
175
176 #include <net-snmp/library/snmp_api.h>
177 #include <net-snmp/library/snmp_client.h>
178 #include <net-snmp/library/snmp_debug.h>
179 #include <net-snmp/library/snmp_logging.h>
180
181 #ifndef ERROR_MSG
182 #define ERROR_MSG(string) snmp_set_detail(string)
183 #endif
184
185 #endif /* NET_SNMP_OUTPUT_API_H */