2 * Copyright (C) 2006 Voop as
3 * Thorsten Lockert <tholo@voop.as>
5 * This program is free software, distributed under the terms of
6 * the GNU General Public License Version 2. See the LICENSE file
7 * at the top of the source tree.
12 * \brief SNMP Agent / SubAgent support for Asterisk
14 * \author Thorsten Lockert <tholo@voop.as>
18 <support_level>extended</support_level>
23 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
26 * There is some collision collision between netsmp and asterisk names,
27 * causing build under AST_DEVMODE to fail.
29 * The following PACKAGE_* macros are one place.
30 * Also netsnmp has an improper check for HAVE_DMALLOC_H, using
31 * #if HAVE_DMALLOC_H instead of #ifdef HAVE_DMALLOC_H
32 * As a countermeasure we define it to 0, however this will fail
33 * when the proper check is implemented.
38 #ifdef PACKAGE_BUGREPORT
39 #undef PACKAGE_BUGREPORT
44 #ifdef PACKAGE_TARNAME
45 #undef PACKAGE_TARNAME
47 #ifdef PACKAGE_VERSION
48 #undef PACKAGE_VERSION
50 #ifndef HAVE_DMALLOC_H
51 #define HAVE_DMALLOC_H 0 /* XXX we shouldn't do this */
54 #if defined(__OpenBSD__)
56 * OpenBSD uses old "legacy" cc which has a rather pedantic builtin preprocessor.
57 * Using a macro which is not #defined throws an error.
59 #define __NetBSD_Version__ 0
62 #include <net-snmp/net-snmp-config.h>
63 #include <net-snmp/net-snmp-includes.h>
64 #include <net-snmp/agent/net-snmp-agent-includes.h>
66 #include "asterisk/paths.h" /* need ast_config_AST_SOCKET */
67 #include "asterisk/channel.h"
68 #include "asterisk/logger.h"
69 #include "asterisk/options.h"
70 #include "asterisk/indications.h"
71 #include "asterisk/ast_version.h"
72 #include "asterisk/pbx.h"
74 /* Colission between Net-SNMP and Asterisk */
75 #define unload_module ast_unload_module
76 #include "asterisk/module.h"
81 /* Helper functions in Net-SNMP, header file not installed by default */
82 int header_generic(struct variable *, oid *, size_t *, int, size_t *, WriteMethod **);
83 int header_simple_table(struct variable *, oid *, size_t *, int, size_t *, WriteMethod **, int);
84 int register_sysORTable(oid *, size_t, const char *);
85 int unregister_sysORTable(oid *, size_t);
87 /* Forward declaration */
88 static void init_asterisk_mib(void);
91 * Anchor for all the Asterisk MIB values
93 static oid asterisk_oid[] = { 1, 3, 6, 1, 4, 1, 22736, 1 };
96 * MIB values -- these correspond to values in the Asterisk MIB,
97 * and MUST be kept in sync with the MIB for things to work as
101 #define ASTVERSTRING 1
104 #define ASTCONFIGURATION 2
105 #define ASTCONFUPTIME 1
106 #define ASTCONFRELOADTIME 2
108 #define ASTCONFSOCKET 4
109 #define ASTCONFACTIVECALLS 5
110 #define ASTCONFPROCESSEDCALLS 6
113 #define ASTMODCOUNT 1
115 #define ASTINDICATIONS 4
116 #define ASTINDCOUNT 1
117 #define ASTINDCURRENT 2
119 #define ASTINDTABLE 3
120 #define ASTINDINDEX 1
121 #define ASTINDCOUNTRY 2
122 #define ASTINDALIAS 3
123 #define ASTINDDESCRIPTION 4
125 #define ASTCHANNELS 5
126 #define ASTCHANCOUNT 1
128 #define ASTCHANTABLE 2
129 #define ASTCHANINDEX 1
130 #define ASTCHANNAME 2
131 #define ASTCHANLANGUAGE 3
132 #define ASTCHANTYPE 4
133 #define ASTCHANMUSICCLASS 5
134 #define ASTCHANBRIDGE 6
135 #define ASTCHANMASQ 7
136 #define ASTCHANMASQR 8
137 #define ASTCHANWHENHANGUP 9
138 #define ASTCHANAPP 10
139 #define ASTCHANDATA 11
140 #define ASTCHANCONTEXT 12
141 #define ASTCHANMACROCONTEXT 13
142 #define ASTCHANMACROEXTEN 14
143 #define ASTCHANMACROPRI 15
144 #define ASTCHANEXTEN 16
145 #define ASTCHANPRI 17
146 #define ASTCHANACCOUNTCODE 18
147 #define ASTCHANFORWARDTO 19
148 #define ASTCHANUNIQUEID 20
149 #define ASTCHANCALLGROUP 21
150 #define ASTCHANPICKUPGROUP 22
151 #define ASTCHANSTATE 23
152 #define ASTCHANMUTED 24
153 #define ASTCHANRINGS 25
154 #define ASTCHANCIDDNID 26
155 #define ASTCHANCIDNUM 27
156 #define ASTCHANCIDNAME 28
157 #define ASTCHANCIDANI 29
158 #define ASTCHANCIDRDNIS 30
159 #define ASTCHANCIDPRES 31
160 #define ASTCHANCIDANI2 32
161 #define ASTCHANCIDTON 33
162 #define ASTCHANCIDTNS 34
163 #define ASTCHANAMAFLAGS 35
164 #define ASTCHANADSI 36
165 #define ASTCHANTONEZONE 37
166 #define ASTCHANHANGUPCAUSE 38
167 #define ASTCHANVARIABLES 39
168 #define ASTCHANFLAGS 40
169 #define ASTCHANTRANSFERCAP 41
171 #define ASTCHANTYPECOUNT 3
173 #define ASTCHANTYPETABLE 4
174 #define ASTCHANTYPEINDEX 1
175 #define ASTCHANTYPENAME 2
176 #define ASTCHANTYPEDESC 3
177 #define ASTCHANTYPEDEVSTATE 4
178 #define ASTCHANTYPEINDICATIONS 5
179 #define ASTCHANTYPETRANSFER 6
180 #define ASTCHANTYPECHANNELS 7
182 #define ASTCHANSCALARS 5
183 #define ASTCHANBRIDGECOUNT 1
185 void *agent_thread(void *arg)
187 ast_verb(2, "Starting %sAgent\n", res_snmp_agentx_subagent ? "Sub" : "");
189 snmp_enable_stderrlog();
191 if (res_snmp_agentx_subagent)
192 netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
193 NETSNMP_DS_AGENT_ROLE,
196 init_agent("asterisk");
200 init_snmp("asterisk");
202 if (!res_snmp_agentx_subagent)
205 while (res_snmp_dont_stop)
206 agent_check_and_process(1);
208 snmp_shutdown("asterisk");
210 ast_verb(2, "Terminating %sAgent\n", res_snmp_agentx_subagent ? "Sub" : "");
216 ast_var_channels(struct variable *vp, oid *name, size_t *length,
217 int exact, size_t *var_len, WriteMethod **write_method)
219 static unsigned long long_ret;
221 if (header_generic(vp, name, length, exact, var_len, write_method))
224 if (vp->magic != ASTCHANCOUNT)
227 long_ret = ast_active_channels();
229 return (u_char *)&long_ret;
232 static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *length,
233 int exact, size_t *var_len, WriteMethod **write_method)
235 static unsigned long long_ret;
236 static u_char bits_ret[2];
237 static char string_ret[256];
238 struct ast_channel *chan, *bridge;
242 struct ast_str *out = ast_str_alloca(2048);
243 struct ast_channel_iterator *iter;
245 if (header_simple_table(vp, name, length, exact, var_len, write_method, ast_active_channels()))
248 i = name[*length - 1] - 1;
250 if (!(iter = ast_channel_iterator_all_new())) {
254 while ((chan = ast_channel_iterator_next(iter)) && i) {
255 ast_channel_unref(chan);
259 iter = ast_channel_iterator_destroy(iter);
265 *var_len = sizeof(long_ret);
267 ast_channel_lock(chan);
271 long_ret = name[*length - 1];
272 ret = (u_char *)&long_ret;
275 if (!ast_strlen_zero(ast_channel_name(chan))) {
276 ast_copy_string(string_ret, ast_channel_name(chan), sizeof(string_ret));
277 *var_len = strlen(string_ret);
278 ret = (u_char *)string_ret;
281 case ASTCHANLANGUAGE:
282 if (!ast_strlen_zero(ast_channel_language(chan))) {
283 ast_copy_string(string_ret, ast_channel_language(chan), sizeof(string_ret));
284 *var_len = strlen(string_ret);
285 ret = (u_char *)string_ret;
289 ast_copy_string(string_ret, ast_channel_tech(chan)->type, sizeof(string_ret));
290 *var_len = strlen(string_ret);
291 ret = (u_char *)string_ret;
293 case ASTCHANMUSICCLASS:
294 if (!ast_strlen_zero(ast_channel_musicclass(chan))) {
295 ast_copy_string(string_ret, ast_channel_musicclass(chan), sizeof(string_ret));
296 *var_len = strlen(string_ret);
297 ret = (u_char *)string_ret;
301 if ((bridge = ast_bridged_channel(chan)) != NULL) {
302 ast_copy_string(string_ret, ast_channel_name(bridge), sizeof(string_ret));
303 *var_len = strlen(string_ret);
304 ret = (u_char *)string_ret;
308 if (ast_channel_masq(chan) && !ast_strlen_zero(ast_channel_name(ast_channel_masq(chan)))) {
309 ast_copy_string(string_ret, ast_channel_name(ast_channel_masq(chan)), sizeof(string_ret));
310 *var_len = strlen(string_ret);
311 ret = (u_char *)string_ret;
315 if (ast_channel_masqr(chan) && !ast_strlen_zero(ast_channel_name(ast_channel_masqr(chan)))) {
316 ast_copy_string(string_ret, ast_channel_name(ast_channel_masqr(chan)), sizeof(string_ret));
317 *var_len = strlen(string_ret);
318 ret = (u_char *)string_ret;
321 case ASTCHANWHENHANGUP:
322 if (!ast_tvzero(*ast_channel_whentohangup(chan))) {
323 gettimeofday(&tval, NULL);
324 long_ret = difftime(ast_channel_whentohangup(chan)->tv_sec, tval.tv_sec) * 100 - tval.tv_usec / 10000;
325 ret= (u_char *)&long_ret;
329 if (ast_channel_appl(chan)) {
330 ast_copy_string(string_ret, ast_channel_appl(chan), sizeof(string_ret));
331 *var_len = strlen(string_ret);
332 ret = (u_char *)string_ret;
336 if (ast_channel_data(chan)) {
337 ast_copy_string(string_ret, ast_channel_data(chan), sizeof(string_ret));
338 *var_len = strlen(string_ret);
339 ret = (u_char *)string_ret;
343 ast_copy_string(string_ret, ast_channel_context(chan), sizeof(string_ret));
344 *var_len = strlen(string_ret);
345 ret = (u_char *)string_ret;
347 case ASTCHANMACROCONTEXT:
348 ast_copy_string(string_ret, ast_channel_macrocontext(chan), sizeof(string_ret));
349 *var_len = strlen(string_ret);
350 ret = (u_char *)string_ret;
352 case ASTCHANMACROEXTEN:
353 ast_copy_string(string_ret, ast_channel_macroexten(chan), sizeof(string_ret));
354 *var_len = strlen(string_ret);
355 ret = (u_char *)string_ret;
357 case ASTCHANMACROPRI:
358 long_ret = ast_channel_macropriority(chan);
359 ret = (u_char *)&long_ret;
362 ast_copy_string(string_ret, ast_channel_exten(chan), sizeof(string_ret));
363 *var_len = strlen(string_ret);
364 ret = (u_char *)string_ret;
367 long_ret = ast_channel_priority(chan);
368 ret = (u_char *)&long_ret;
370 case ASTCHANACCOUNTCODE:
371 if (!ast_strlen_zero(ast_channel_accountcode(chan))) {
372 ast_copy_string(string_ret, ast_channel_accountcode(chan), sizeof(string_ret));
373 *var_len = strlen(string_ret);
374 ret = (u_char *)string_ret;
377 case ASTCHANFORWARDTO:
378 if (!ast_strlen_zero(ast_channel_call_forward(chan))) {
379 ast_copy_string(string_ret, ast_channel_call_forward(chan), sizeof(string_ret));
380 *var_len = strlen(string_ret);
381 ret = (u_char *)string_ret;
384 case ASTCHANUNIQUEID:
385 ast_copy_string(string_ret, ast_channel_uniqueid(chan), sizeof(string_ret));
386 *var_len = strlen(string_ret);
387 ret = (u_char *)string_ret;
389 case ASTCHANCALLGROUP:
390 long_ret = ast_channel_callgroup(chan);
391 ret = (u_char *)&long_ret;
393 case ASTCHANPICKUPGROUP:
394 long_ret = ast_channel_pickupgroup(chan);
395 ret = (u_char *)&long_ret;
398 long_ret = ast_channel_state(chan) & 0xffff;
399 ret = (u_char *)&long_ret;
402 long_ret = ast_channel_state(chan) & AST_STATE_MUTE ? 1 : 2;
403 ret = (u_char *)&long_ret;
406 long_ret = ast_channel_rings(chan);
407 ret = (u_char *)&long_ret;
410 if (ast_channel_dialed(chan)->number.str) {
411 ast_copy_string(string_ret, ast_channel_dialed(chan)->number.str, sizeof(string_ret));
412 *var_len = strlen(string_ret);
413 ret = (u_char *)string_ret;
417 if (ast_channel_caller(chan)->id.number.valid && ast_channel_caller(chan)->id.number.str) {
418 ast_copy_string(string_ret, ast_channel_caller(chan)->id.number.str, sizeof(string_ret));
419 *var_len = strlen(string_ret);
420 ret = (u_char *)string_ret;
424 if (ast_channel_caller(chan)->id.name.valid && ast_channel_caller(chan)->id.name.str) {
425 ast_copy_string(string_ret, ast_channel_caller(chan)->id.name.str, sizeof(string_ret));
426 *var_len = strlen(string_ret);
427 ret = (u_char *)string_ret;
431 if (ast_channel_caller(chan)->ani.number.valid && ast_channel_caller(chan)->ani.number.str) {
432 ast_copy_string(string_ret, ast_channel_caller(chan)->ani.number.str, sizeof(string_ret));
433 *var_len = strlen(string_ret);
434 ret = (u_char *)string_ret;
437 case ASTCHANCIDRDNIS:
438 if (ast_channel_redirecting(chan)->from.number.valid && ast_channel_redirecting(chan)->from.number.str) {
439 ast_copy_string(string_ret, ast_channel_redirecting(chan)->from.number.str, sizeof(string_ret));
440 *var_len = strlen(string_ret);
441 ret = (u_char *)string_ret;
445 long_ret = ast_party_id_presentation(&ast_channel_caller(chan)->id);
446 ret = (u_char *)&long_ret;
449 long_ret = ast_channel_caller(chan)->ani2;
450 ret = (u_char *)&long_ret;
453 long_ret = ast_channel_caller(chan)->id.number.plan;
454 ret = (u_char *)&long_ret;
457 long_ret = ast_channel_dialed(chan)->transit_network_select;
458 ret = (u_char *)&long_ret;
460 case ASTCHANAMAFLAGS:
461 long_ret = ast_channel_amaflags(chan);
462 ret = (u_char *)&long_ret;
465 long_ret = ast_channel_adsicpe(chan);
466 ret = (u_char *)&long_ret;
468 case ASTCHANTONEZONE:
469 if (ast_channel_zone(chan)) {
470 ast_copy_string(string_ret, ast_channel_zone(chan)->country, sizeof(string_ret));
471 *var_len = strlen(string_ret);
472 ret = (u_char *)string_ret;
475 case ASTCHANHANGUPCAUSE:
476 long_ret = ast_channel_hangupcause(chan);
477 ret = (u_char *)&long_ret;
479 case ASTCHANVARIABLES:
480 if (pbx_builtin_serialize_variables(chan, &out)) {
481 *var_len = ast_str_strlen(out);
482 ret = (u_char *)ast_str_buffer(out);
487 for (bit = 0; bit < 8; bit++)
488 bits_ret[0] |= ((ast_channel_flags(chan)->flags & (1 << bit)) >> bit) << (7 - bit);
490 for (bit = 0; bit < 8; bit++)
491 bits_ret[1] |= (((ast_channel_flags(chan)->flags >> 8) & (1 << bit)) >> bit) << (7 - bit);
495 case ASTCHANTRANSFERCAP:
496 long_ret = ast_channel_transfercapability(chan);
497 ret = (u_char *)&long_ret;
502 ast_channel_unlock(chan);
503 chan = ast_channel_unref(chan);
508 static u_char *ast_var_channel_types(struct variable *vp, oid *name, size_t *length,
509 int exact, size_t *var_len, WriteMethod **write_method)
511 static unsigned long long_ret;
512 struct ast_variable *channel_types, *next;
514 if (header_generic(vp, name, length, exact, var_len, write_method))
517 if (vp->magic != ASTCHANTYPECOUNT)
520 for (long_ret = 0, channel_types = next = ast_channeltype_list(); next; next = next->next)
522 ast_variables_destroy(channel_types);
524 return (u_char *)&long_ret;
527 static u_char *ast_var_channel_types_table(struct variable *vp, oid *name, size_t *length,
528 int exact, size_t *var_len, WriteMethod **write_method)
530 const struct ast_channel_tech *tech = NULL;
531 struct ast_variable *channel_types, *next;
532 static unsigned long long_ret;
533 struct ast_channel *chan;
536 if (header_simple_table(vp, name, length, exact, var_len, write_method, -1))
539 channel_types = ast_channeltype_list();
540 for (i = 1, next = channel_types; next && i != name[*length - 1]; next = next->next, i++)
543 tech = ast_get_channel_tech(next->name);
544 ast_variables_destroy(channel_types);
545 if (next == NULL || tech == NULL)
549 case ASTCHANTYPEINDEX:
550 long_ret = name[*length - 1];
551 return (u_char *)&long_ret;
552 case ASTCHANTYPENAME:
553 *var_len = strlen(tech->type);
554 return (u_char *)tech->type;
555 case ASTCHANTYPEDESC:
556 *var_len = strlen(tech->description);
557 return (u_char *)tech->description;
558 case ASTCHANTYPEDEVSTATE:
559 long_ret = tech->devicestate ? 1 : 2;
560 return (u_char *)&long_ret;
561 case ASTCHANTYPEINDICATIONS:
562 long_ret = tech->indicate ? 1 : 2;
563 return (u_char *)&long_ret;
564 case ASTCHANTYPETRANSFER:
565 long_ret = tech->transfer ? 1 : 2;
566 return (u_char *)&long_ret;
567 case ASTCHANTYPECHANNELS:
569 struct ast_channel_iterator *iter;
573 if (!(iter = ast_channel_iterator_all_new())) {
577 while ((chan = ast_channel_iterator_next(iter))) {
578 if (ast_channel_tech(chan) == tech) {
581 chan = ast_channel_unref(chan);
584 ast_channel_iterator_destroy(iter);
586 return (u_char *)&long_ret;
594 static u_char *ast_var_channel_bridge(struct variable *vp, oid *name, size_t *length,
595 int exact, size_t *var_len, WriteMethod **write_method)
597 static unsigned long long_ret;
598 struct ast_channel *chan = NULL;
599 struct ast_channel_iterator *iter;
603 if (header_generic(vp, name, length, exact, var_len, write_method)) {
607 if (!(iter = ast_channel_iterator_all_new())) {
611 while ((chan = ast_channel_iterator_next(iter))) {
612 ast_channel_lock(chan);
613 if (ast_bridged_channel(chan)) {
616 ast_channel_unlock(chan);
617 chan = ast_channel_unref(chan);
620 ast_channel_iterator_destroy(iter);
622 *var_len = sizeof(long_ret);
624 return (vp->magic == ASTCHANBRIDGECOUNT) ? (u_char *) &long_ret : NULL;
627 static u_char *ast_var_Config(struct variable *vp, oid *name, size_t *length,
628 int exact, size_t *var_len, WriteMethod **write_method)
630 static unsigned long long_ret;
633 if (header_generic(vp, name, length, exact, var_len, write_method))
638 gettimeofday(&tval, NULL);
639 long_ret = difftime(tval.tv_sec, ast_startuptime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_startuptime.tv_usec / 10000;
640 return (u_char *)&long_ret;
641 case ASTCONFRELOADTIME:
642 gettimeofday(&tval, NULL);
643 if (ast_lastreloadtime.tv_sec)
644 long_ret = difftime(tval.tv_sec, ast_lastreloadtime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_lastreloadtime.tv_usec / 10000;
646 long_ret = difftime(tval.tv_sec, ast_startuptime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_startuptime.tv_usec / 10000;
647 return (u_char *)&long_ret;
650 return (u_char *)&long_ret;
652 *var_len = strlen(ast_config_AST_SOCKET);
653 return (u_char *)ast_config_AST_SOCKET;
654 case ASTCONFACTIVECALLS:
655 long_ret = ast_active_calls();
656 return (u_char *)&long_ret;
657 case ASTCONFPROCESSEDCALLS:
658 long_ret = ast_processed_calls();
659 return (u_char *)&long_ret;
666 static u_char *ast_var_indications(struct variable *vp, oid *name, size_t *length,
667 int exact, size_t *var_len, WriteMethod **write_method)
669 static unsigned long long_ret;
670 static char ret_buf[128];
671 struct ast_tone_zone *tz = NULL;
673 if (header_generic(vp, name, length, exact, var_len, write_method))
679 struct ao2_iterator i;
683 i = ast_tone_zone_iterator_init();
684 while ((tz = ao2_iterator_next(&i))) {
685 tz = ast_tone_zone_unref(tz);
688 ao2_iterator_destroy(&i);
690 return (u_char *) &long_ret;
693 tz = ast_get_indication_zone(NULL);
695 ast_copy_string(ret_buf, tz->country, sizeof(ret_buf));
696 *var_len = strlen(ret_buf);
697 tz = ast_tone_zone_unref(tz);
698 return (u_char *) ret_buf;
708 static u_char *ast_var_indications_table(struct variable *vp, oid *name, size_t *length,
709 int exact, size_t *var_len, WriteMethod **write_method)
711 static unsigned long long_ret;
712 static char ret_buf[256];
713 struct ast_tone_zone *tz = NULL;
715 struct ao2_iterator iter;
717 if (header_simple_table(vp, name, length, exact, var_len, write_method, -1)) {
721 i = name[*length - 1] - 1;
723 iter = ast_tone_zone_iterator_init();
725 while ((tz = ao2_iterator_next(&iter)) && i) {
726 tz = ast_tone_zone_unref(tz);
729 ao2_iterator_destroy(&iter);
737 ast_tone_zone_unref(tz);
738 long_ret = name[*length - 1];
739 return (u_char *)&long_ret;
741 ast_copy_string(ret_buf, tz->country, sizeof(ret_buf));
742 ast_tone_zone_unref(tz);
743 *var_len = strlen(ret_buf);
744 return (u_char *) ret_buf;
746 /* No longer exists */
747 ast_tone_zone_unref(tz);
749 case ASTINDDESCRIPTION:
750 ast_tone_zone_lock(tz);
751 ast_copy_string(ret_buf, tz->description, sizeof(ret_buf));
752 ast_tone_zone_unlock(tz);
753 ast_tone_zone_unref(tz);
754 *var_len = strlen(ret_buf);
755 return (u_char *) ret_buf;
757 ast_tone_zone_unref(tz);
763 static int countmodule(const char *mod, const char *desc, int use, const char *like)
768 static u_char *ast_var_Modules(struct variable *vp, oid *name, size_t *length,
769 int exact, size_t *var_len, WriteMethod **write_method)
771 static unsigned long long_ret;
773 if (header_generic(vp, name, length, exact, var_len, write_method))
776 if (vp->magic != ASTMODCOUNT)
779 long_ret = ast_update_module_list(countmodule, NULL);
781 return (u_char *)&long_ret;
784 static u_char *ast_var_Version(struct variable *vp, oid *name, size_t *length,
785 int exact, size_t *var_len, WriteMethod **write_method)
787 static unsigned long long_ret;
789 if (header_generic(vp, name, length, exact, var_len, write_method))
795 const char *version = ast_get_version();
796 *var_len = strlen(version);
797 return (u_char *)version;
800 sscanf(ast_get_version_num(), "%30lu", &long_ret);
801 return (u_char *)&long_ret;
808 static int term_asterisk_mib(int majorID, int minorID, void *serverarg, void *clientarg)
810 unregister_sysORTable(asterisk_oid, OID_LENGTH(asterisk_oid));
814 static void init_asterisk_mib(void)
816 static struct variable4 asterisk_vars[] = {
817 {ASTVERSTRING, ASN_OCTET_STR, RONLY, ast_var_Version, 2, {ASTVERSION, ASTVERSTRING}},
818 {ASTVERTAG, ASN_UNSIGNED, RONLY, ast_var_Version, 2, {ASTVERSION, ASTVERTAG}},
819 {ASTCONFUPTIME, ASN_TIMETICKS, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFUPTIME}},
820 {ASTCONFRELOADTIME, ASN_TIMETICKS, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFRELOADTIME}},
821 {ASTCONFPID, ASN_INTEGER, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFPID}},
822 {ASTCONFSOCKET, ASN_OCTET_STR, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFSOCKET}},
823 {ASTCONFACTIVECALLS, ASN_GAUGE, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFACTIVECALLS}},
824 {ASTCONFPROCESSEDCALLS, ASN_COUNTER, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFPROCESSEDCALLS}},
825 {ASTMODCOUNT, ASN_INTEGER, RONLY, ast_var_Modules , 2, {ASTMODULES, ASTMODCOUNT}},
826 {ASTINDCOUNT, ASN_INTEGER, RONLY, ast_var_indications, 2, {ASTINDICATIONS, ASTINDCOUNT}},
827 {ASTINDCURRENT, ASN_OCTET_STR, RONLY, ast_var_indications, 2, {ASTINDICATIONS, ASTINDCURRENT}},
828 {ASTINDINDEX, ASN_INTEGER, RONLY, ast_var_indications_table, 4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDINDEX}},
829 {ASTINDCOUNTRY, ASN_OCTET_STR, RONLY, ast_var_indications_table, 4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDCOUNTRY}},
830 {ASTINDALIAS, ASN_OCTET_STR, RONLY, ast_var_indications_table, 4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDALIAS}},
831 {ASTINDDESCRIPTION, ASN_OCTET_STR, RONLY, ast_var_indications_table, 4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDDESCRIPTION}},
832 {ASTCHANCOUNT, ASN_GAUGE, RONLY, ast_var_channels, 2, {ASTCHANNELS, ASTCHANCOUNT}},
833 {ASTCHANINDEX, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANINDEX}},
834 {ASTCHANNAME, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANNAME}},
835 {ASTCHANLANGUAGE, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANLANGUAGE}},
836 {ASTCHANTYPE, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTYPE}},
837 {ASTCHANMUSICCLASS, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMUSICCLASS}},
838 {ASTCHANBRIDGE, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANBRIDGE}},
839 {ASTCHANMASQ, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMASQ}},
840 {ASTCHANMASQR, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMASQR}},
841 {ASTCHANWHENHANGUP, ASN_TIMETICKS, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANWHENHANGUP}},
842 {ASTCHANAPP, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANAPP}},
843 {ASTCHANDATA, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANDATA}},
844 {ASTCHANCONTEXT, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCONTEXT}},
845 {ASTCHANMACROCONTEXT, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMACROCONTEXT}},
846 {ASTCHANMACROEXTEN, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMACROEXTEN}},
847 {ASTCHANMACROPRI, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMACROPRI}},
848 {ASTCHANEXTEN, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANEXTEN}},
849 {ASTCHANPRI, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANPRI}},
850 {ASTCHANACCOUNTCODE, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANACCOUNTCODE}},
851 {ASTCHANFORWARDTO, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANFORWARDTO}},
852 {ASTCHANUNIQUEID, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANUNIQUEID}},
853 {ASTCHANCALLGROUP, ASN_UNSIGNED, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCALLGROUP}},
854 {ASTCHANPICKUPGROUP, ASN_UNSIGNED, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANPICKUPGROUP}},
855 {ASTCHANSTATE, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANSTATE}},
856 {ASTCHANMUTED, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMUTED}},
857 {ASTCHANRINGS, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANRINGS}},
858 {ASTCHANCIDDNID, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDDNID}},
859 {ASTCHANCIDNUM, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDNUM}},
860 {ASTCHANCIDNAME, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDNAME}},
861 {ASTCHANCIDANI, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDANI}},
862 {ASTCHANCIDRDNIS, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDRDNIS}},
863 {ASTCHANCIDPRES, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDPRES}},
864 {ASTCHANCIDANI2, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDANI2}},
865 {ASTCHANCIDTON, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDTON}},
866 {ASTCHANCIDTNS, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDTNS}},
867 {ASTCHANAMAFLAGS, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANAMAFLAGS}},
868 {ASTCHANADSI, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANADSI}},
869 {ASTCHANTONEZONE, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTONEZONE}},
870 {ASTCHANHANGUPCAUSE, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANHANGUPCAUSE}},
871 {ASTCHANVARIABLES, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANVARIABLES}},
872 {ASTCHANFLAGS, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANFLAGS}},
873 {ASTCHANTRANSFERCAP, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTRANSFERCAP}},
874 {ASTCHANTYPECOUNT, ASN_INTEGER, RONLY, ast_var_channel_types, 2, {ASTCHANNELS, ASTCHANTYPECOUNT}},
875 {ASTCHANTYPEINDEX, ASN_INTEGER, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEINDEX}},
876 {ASTCHANTYPENAME, ASN_OCTET_STR, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPENAME}},
877 {ASTCHANTYPEDESC, ASN_OCTET_STR, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEDESC}},
878 {ASTCHANTYPEDEVSTATE, ASN_INTEGER, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEDEVSTATE}},
879 {ASTCHANTYPEINDICATIONS, ASN_INTEGER, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEINDICATIONS}},
880 {ASTCHANTYPETRANSFER, ASN_INTEGER, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPETRANSFER}},
881 {ASTCHANTYPECHANNELS, ASN_GAUGE, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPECHANNELS}},
882 {ASTCHANBRIDGECOUNT, ASN_GAUGE, RONLY, ast_var_channel_bridge, 3, {ASTCHANNELS, ASTCHANSCALARS, ASTCHANBRIDGECOUNT}},
885 register_sysORTable(asterisk_oid, OID_LENGTH(asterisk_oid),
886 "ASTERISK-MIB implementation for Asterisk.");
888 REGISTER_MIB("res_snmp", asterisk_vars, variable4, asterisk_oid);
890 snmp_register_callback(SNMP_CALLBACK_LIBRARY,
891 SNMP_CALLBACK_SHUTDOWN,
892 term_asterisk_mib, NULL);
898 * c-file-offsets: ((case-label . 0))
900 * indent-tabs-mode: t