diff options
Diffstat (limited to 'src/varnish_mib.mib2c')
-rw-r--r-- | src/varnish_mib.mib2c | 258 |
1 files changed, 235 insertions, 23 deletions
diff --git a/src/varnish_mib.mib2c b/src/varnish_mib.mib2c index 9825728..34f0f16 100644 --- a/src/varnish_mib.mib2c +++ b/src/varnish_mib.mib2c | |||
@@ -23,28 +23,6 @@ | |||
23 | vi: set ro: | 23 | vi: set ro: |
24 | */ | 24 | */ |
25 | @enddefine@ | 25 | @enddefine@ |
26 | @open ${name}@ | ||
27 | /* THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT. */ | ||
28 | |||
29 | #include "varnish_mib.h" | ||
30 | |||
31 | static struct VSM_data *vd; | ||
32 | |||
33 | void | ||
34 | varnish_snmp_init(void) | ||
35 | { | ||
36 | vd = VSM_New(); | ||
37 | |||
38 | if (VSM_Open(vd)) | ||
39 | exit(1); | ||
40 | } | ||
41 | |||
42 | void | ||
43 | varnish_snmp_deinit(void) | ||
44 | { | ||
45 | VSM_Close(vd); | ||
46 | } | ||
47 | |||
48 | @startperl@ | 26 | @startperl@ |
49 | $vars{'varnish_translate'} = sub { | 27 | $vars{'varnish_translate'} = sub { |
50 | my $name = shift; | 28 | my $name = shift; |
@@ -141,10 +119,83 @@ $vars{'varnish_translate'} = sub { | |||
141 | $vars{'modulename'} = $vars{'name'}; | 119 | $vars{'modulename'} = $vars{'name'}; |
142 | $vars{'modulename'} =~ s#.*/##; | 120 | $vars{'modulename'} =~ s#.*/##; |
143 | $vars{'modulename'} =~ s/\.c$//; | 121 | $vars{'modulename'} =~ s/\.c$//; |
144 | print "$vars{'modulename'}\n"; | 122 | #print "$vars{'modulename'}\n"; |
145 | 123 | ||
146 | 0; | 124 | 0; |
147 | @endperl@ | 125 | @endperl@ |
126 | @open ${modulename}.h@ | ||
127 | /* THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT. */ | ||
128 | #include <config.h> | ||
129 | #include <stdlib.h> | ||
130 | #include <stdint.h> | ||
131 | |||
132 | #include <vapi/vsc.h> | ||
133 | #include <vapi/vsm.h> | ||
134 | #include <vcli.h> | ||
135 | |||
136 | #include <net-snmp/net-snmp-config.h> | ||
137 | #include <net-snmp/net-snmp-includes.h> | ||
138 | #include <net-snmp/agent/net-snmp-agent-includes.h> | ||
139 | |||
140 | typedef struct vcli_conn { | ||
141 | int fd; | ||
142 | char *secret; | ||
143 | int resp; | ||
144 | char *base; | ||
145 | size_t bufmax; | ||
146 | size_t bufsize; | ||
147 | } vcli_conn_t; | ||
148 | |||
149 | int vcli_write(vcli_conn_t *conn); | ||
150 | int vcli_read_response(vcli_conn_t *conn); | ||
151 | int vcli_vasprintf(vcli_conn_t *conn, const char *fmt, va_list ap); | ||
152 | int vcli_asprintf(vcli_conn_t *conn, const char *fmt, ...); | ||
153 | void vcli_disconnect(vcli_conn_t *conn); | ||
154 | int vcli_connect(struct VSM_data *vd, vcli_conn_t *conn); | ||
155 | |||
156 | struct VSM_data *varnish_get_vsm_data(void); | ||
157 | |||
158 | int varnish_auth_response(const char *file, const char *challenge, | ||
159 | char response[CLI_AUTH_RESPONSE_LEN + 1]); | ||
160 | |||
161 | int varnish_ban(netsnmp_agent_request_info *reqinfo, | ||
162 | netsnmp_request_info *requests, | ||
163 | struct VSM_data *vd); | ||
164 | |||
165 | extern unsigned banTable_timeout; | ||
166 | |||
167 | @open ${name}@ | ||
168 | /* THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT. */ | ||
169 | |||
170 | #include "varnish_mib.h" | ||
171 | |||
172 | static struct VSM_data *vd; | ||
173 | |||
174 | void | ||
175 | varnish_snmp_init(void) | ||
176 | { | ||
177 | vd = VSM_New(); | ||
178 | |||
179 | if (VSM_Open(vd)) | ||
180 | exit(1); | ||
181 | } | ||
182 | |||
183 | void | ||
184 | varnish_snmp_deinit(void) | ||
185 | { | ||
186 | VSM_Close(vd); | ||
187 | } | ||
188 | |||
189 | struct VSM_data * | ||
190 | varnish_get_vsm_data() | ||
191 | { | ||
192 | if (VSM_Abandoned(vd)) { | ||
193 | DEBUGMSGTL(("$modulename", "reopening vd\n")); | ||
194 | VSM_Close(vd); | ||
195 | VSM_Open(vd); | ||
196 | } | ||
197 | return vd; | ||
198 | } | ||
148 | 199 | ||
149 | /* Variable handlers. | 200 | /* Variable handlers. |
150 | 201 | ||
@@ -273,6 +324,164 @@ handle_$i(netsnmp_mib_handler *handler, | |||
273 | } | 324 | } |
274 | @end@ | 325 | @end@ |
275 | 326 | ||
327 | @foreach $i table@ | ||
328 | ## Determine the first/last column names | ||
329 | @eval $first_column = "-"@ | ||
330 | @eval $last_column = "-"@ | ||
331 | @foreach $c column@ | ||
332 | @if $c.readable@ | ||
333 | @if "$first_column" eq "-"@ | ||
334 | @eval $first_column = $c@ | ||
335 | @end@ | ||
336 | @eval $last_column = $c@ | ||
337 | @end@ | ||
338 | @end@ | ||
339 | |||
340 | @push@ | ||
341 | @append ${modulename}.h@ | ||
342 | /* column number definitions for table $i */ | ||
343 | @foreach $c column@ | ||
344 | #define COLUMN_$c.uc $c.subid | ||
345 | @end@ | ||
346 | |||
347 | struct ${i}_entry { | ||
348 | /* Index values */ | ||
349 | @foreach $idx index@ | ||
350 | @if $idx.needlength@ | ||
351 | $idx.decl *$idx; | ||
352 | size_t ${idx}_len; | ||
353 | @else@ | ||
354 | $idx.decl $idx; | ||
355 | @end@ | ||
356 | @end@ | ||
357 | |||
358 | /* Column values */ | ||
359 | @foreach $c nonindex@ | ||
360 | @if $c.readable@ | ||
361 | @if $c.needlength@ | ||
362 | $c.decl *$c; | ||
363 | size_t ${c}_len; | ||
364 | @else@ | ||
365 | $c.decl $c; | ||
366 | @end@ | ||
367 | @end@ | ||
368 | @end@ | ||
369 | }; | ||
370 | |||
371 | int ${i}_load(netsnmp_cache *cache, void *vmagic); | ||
372 | void ${i}_free(netsnmp_cache *cache, void *vmagic); | ||
373 | @pop@ | ||
374 | |||
375 | /** handles requests for the $i table */ | ||
376 | static int | ||
377 | handle_table_${i}( | ||
378 | netsnmp_mib_handler *handler, | ||
379 | netsnmp_handler_registration *reginfo, | ||
380 | netsnmp_agent_request_info *reqinfo, | ||
381 | netsnmp_request_info *requests) | ||
382 | { | ||
383 | netsnmp_request_info *request; | ||
384 | netsnmp_table_request_info *table_info; | ||
385 | struct ${i}_entry *table_entry; | ||
386 | |||
387 | switch (reqinfo->mode) { | ||
388 | case MODE_GET: | ||
389 | for (request = requests; request; request = request->next) { | ||
390 | table_entry = (struct ${i}_entry *) | ||
391 | netsnmp_tdata_extract_entry(request); | ||
392 | table_info = netsnmp_extract_table_info(request); | ||
393 | |||
394 | switch (table_info->colnum) { | ||
395 | @foreach $c column@ | ||
396 | @if $c.readable@ | ||
397 | case COLUMN_$c.uc: | ||
398 | if (!table_entry) { | ||
399 | netsnmp_set_request_error(reqinfo, request, | ||
400 | SNMP_NOSUCHINSTANCE); | ||
401 | continue; | ||
402 | } | ||
403 | @if $c.needlength@ | ||
404 | snmp_set_var_typed_value(request->requestvb, $c.type, | ||
405 | table_entry->$c, | ||
406 | table_entry->${c}_len); | ||
407 | @else@ | ||
408 | snmp_set_var_typed_integer(request->requestvb, $c.type, | ||
409 | table_entry->$c); | ||
410 | @end@ | ||
411 | break; | ||
412 | @end@ | ||
413 | @end@ | ||
414 | default: | ||
415 | netsnmp_set_request_error(reqinfo, request, | ||
416 | SNMP_NOSUCHOBJECT); | ||
417 | break; | ||
418 | } | ||
419 | } | ||
420 | break; | ||
421 | default: | ||
422 | /* we should never get here, so this is a really bad error */ | ||
423 | snmp_log(LOG_ERR, "unknown mode (%d) in handle_table_${i}\n", | ||
424 | reqinfo->mode); | ||
425 | return SNMP_ERR_GENERR; | ||
426 | |||
427 | } | ||
428 | return SNMP_ERR_NOERROR; | ||
429 | } | ||
430 | |||
431 | /** Initialize the $i table by defining its contents and how it's structured */ | ||
432 | static void | ||
433 | initialize_table_$i(void) | ||
434 | { | ||
435 | const oid ${i}_oid[] = {$i.commaoid}; | ||
436 | const size_t ${i}_oid_len = OID_LENGTH(${i}_oid); | ||
437 | netsnmp_handler_registration *reg; | ||
438 | netsnmp_tdata *table_data; | ||
439 | netsnmp_table_registration_info *table_info; | ||
440 | netsnmp_cache *cache; | ||
441 |