[asterisk-commits] jeffg: branch jeffg/jeffg-moresnmp-branch r144860 - in /team/jeffg/jeffg-more...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 26 18:32:43 CDT 2008


Author: jeffg
Date: Fri Sep 26 18:32:43 2008
New Revision: 144860

URL: http://svn.digium.com/view/asterisk?view=rev&rev=144860
Log:
Reorganize res_snmp includes to accommodate traps

Added:
    team/jeffg/jeffg-moresnmp-branch/include/asterisk/trap_defs.h   (with props)
    team/jeffg/jeffg-moresnmp-branch/res/snmp/res_snmp_common.h   (with props)
    team/jeffg/jeffg-moresnmp-branch/res/snmp/traps.c   (with props)
Modified:
    team/jeffg/jeffg-moresnmp-branch/res/Makefile
    team/jeffg/jeffg-moresnmp-branch/res/res_snmp.c
    team/jeffg/jeffg-moresnmp-branch/res/snmp/agent.c

Added: team/jeffg/jeffg-moresnmp-branch/include/asterisk/trap_defs.h
URL: http://svn.digium.com/view/asterisk/team/jeffg/jeffg-moresnmp-branch/include/asterisk/trap_defs.h?view=auto&rev=144860
==============================================================================
--- team/jeffg/jeffg-moresnmp-branch/include/asterisk/trap_defs.h (added)
+++ team/jeffg/jeffg-moresnmp-branch/include/asterisk/trap_defs.h Fri Sep 26 18:32:43 2008
@@ -1,0 +1,38 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2008, Digium, Inc.
+ *
+ * Jeff Gehlbach <jeffg at opennms.org>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \author Jeff Gehlbach <jeffg at opennms.org>
+ * \brief SNMP trap definitions
+ */
+
+#ifndef AST_TRAP_DEFS_H
+#define AST_TRAP_DEFS_H
+
+#define TRAP_GROUP_SYSTEM		1
+#define TRAP_SYSTEM_AST_START			1
+#define TRAP_SYSTEM_AST_STOP_REQUESTED		2
+#define TRAP_SYSTEM_AST_STOPPING		3
+#define TRAP_GROUP_FOO			2
+#define TRAP_FOO_BAR				1
+#define TRAP_FOO_BAZ				2
+
+void snmp_dispatch_trap(int trap_group, int trap_specific, void **varbinds, int varbind_count);
+
+#endif /* AST_TRAP_DEFS_H */

Propchange: team/jeffg/jeffg-moresnmp-branch/include/asterisk/trap_defs.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/jeffg/jeffg-moresnmp-branch/include/asterisk/trap_defs.h
------------------------------------------------------------------------------
    svn:keywords = None

Propchange: team/jeffg/jeffg-moresnmp-branch/include/asterisk/trap_defs.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/jeffg/jeffg-moresnmp-branch/res/Makefile
URL: http://svn.digium.com/view/asterisk/team/jeffg/jeffg-moresnmp-branch/res/Makefile?view=diff&rev=144860&r1=144859&r2=144860
==============================================================================
--- team/jeffg/jeffg-moresnmp-branch/res/Makefile (original)
+++ team/jeffg/jeffg-moresnmp-branch/res/Makefile Fri Sep 26 18:32:43 2008
@@ -39,7 +39,7 @@
 
 $(if $(filter res_ais,$(EMBEDDED_MODS)),modules.link,res_ais.so): ais/clm.o ais/evt.o
 
-$(if $(filter res_snmp,$(EMBEDDED_MODS)),modules.link,res_snmp.so): snmp/agent.o
+$(if $(filter res_snmp,$(EMBEDDED_MODS)),modules.link,res_snmp.so): snmp/agent.o snmp/traps.o
 
 $(if $(filter res_ael_share,$(EMBEDDED_MODS)),modules.link,res_ael_share.so): ael/ael_lex.o ael/ael.tab.o ael/pval.o
 

Modified: team/jeffg/jeffg-moresnmp-branch/res/res_snmp.c
URL: http://svn.digium.com/view/asterisk/team/jeffg/jeffg-moresnmp-branch/res/res_snmp.c?view=diff&rev=144860&r1=144859&r2=144860
==============================================================================
--- team/jeffg/jeffg-moresnmp-branch/res/res_snmp.c (original)
+++ team/jeffg/jeffg-moresnmp-branch/res/res_snmp.c Fri Sep 26 18:32:43 2008
@@ -35,6 +35,8 @@
 int res_snmp_agentx_subagent;
 int res_snmp_dont_stop;
 int res_snmp_enabled;
+
+int res_snmp_traps_peerstate;
 
 static pthread_t thread = AST_PTHREADT_NULL;
 
@@ -81,6 +83,22 @@
 				}
 				var = var->next;
 			}
+		} else if (strcasecmp(cat, "traps") == 0) {
+			while (var) {
+				if (strcasecmp(var->name, "peer_state_change")) {
+					if (ast_true(var->value))
+						res_snmp_traps_peerstate = 1;
+					else {
+						ast_log(LOG_ERROR, "Value '%s' does not evaluate to true or false.\n", var->value);
+						ast_config_destroy(cfg);
+						return 1;
+					}
+				} else {
+					ast_log(LOG_ERROR, "Unrecognized variable '%s' in category '%s'\n", var->name, cat);
+					ast_config_destroy(cfg);
+					return 1;
+				}
+			}
 		} else {
 			ast_log(LOG_ERROR, "Unrecognized category '%s'\n", cat);
 			ast_config_destroy(cfg);

Modified: team/jeffg/jeffg-moresnmp-branch/res/snmp/agent.c
URL: http://svn.digium.com/view/asterisk/team/jeffg/jeffg-moresnmp-branch/res/snmp/agent.c?view=diff&rev=144860&r1=144859&r2=144860
==============================================================================
--- team/jeffg/jeffg-moresnmp-branch/res/snmp/agent.c (original)
+++ team/jeffg/jeffg-moresnmp-branch/res/snmp/agent.c Fri Sep 26 18:32:43 2008
@@ -12,44 +12,14 @@
  * \brief SNMP Agent / SubAgent support for Asterisk
  *
  * \author Thorsten Lockert <tholo at voop.as>
+ * \author Jeff Gehlbach <jeffg at opennms.org>
  */
 
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-/*
- * There is some collision collision between netsmp and asterisk names,
- * causing build under AST_DEVMODE to fail.
- *
- * The following PACKAGE_* macros are one place.
- * Also netsnmp has an improper check for HAVE_DMALLOC_H, using
- *    #if HAVE_DMALLOC_H   instead of #ifdef HAVE_DMALLOC_H
- * As a countermeasure we define it to 0, however this will fail
- * when the proper check is implemented.
- */
-#ifdef PACKAGE_NAME
-#undef PACKAGE_NAME
-#endif
-#ifdef PACKAGE_BUGREPORT
-#undef PACKAGE_BUGREPORT
-#endif
-#ifdef PACKAGE_STRING
-#undef PACKAGE_STRING
-#endif
-#ifdef PACKAGE_TARNAME
-#undef PACKAGE_TARNAME
-#endif
-#ifdef PACKAGE_VERSION
-#undef PACKAGE_VERSION
-#endif
-#ifndef HAVE_DMALLOC_H
-#define HAVE_DMALLOC_H 0	/* XXX we shouldn't do this */
-#endif
-
-#include <net-snmp/net-snmp-config.h>
-#include <net-snmp/net-snmp-includes.h>
-#include <net-snmp/agent/net-snmp-agent-includes.h>
+#include "res_snmp_common.h"
 
 #include "asterisk/paths.h"	/* need ast_config_AST_SOCKET */
 #include "asterisk/channel.h"
@@ -59,18 +29,7 @@
 #include "asterisk/ast_version.h"
 #include "asterisk/pbx.h"
 
-/* Colission between Net-SNMP and Asterisk */
-#define unload_module ast_unload_module
-#include "asterisk/module.h"
-#undef unload_module
-
 #include "agent.h"
-
-/* Helper functions in Net-SNMP, header file not installed by default */
-int header_generic(struct variable *, oid *, size_t *, int, size_t *, WriteMethod **);
-int header_simple_table(struct variable *, oid *, size_t *, int, size_t *, WriteMethod **, int);
-int register_sysORTable(oid *, size_t, const char *);
-int unregister_sysORTable(oid *, size_t);
 
 /* Forward declaration */
 static void init_asterisk_mib(void);

Added: team/jeffg/jeffg-moresnmp-branch/res/snmp/res_snmp_common.h
URL: http://svn.digium.com/view/asterisk/team/jeffg/jeffg-moresnmp-branch/res/snmp/res_snmp_common.h?view=auto&rev=144860
==============================================================================
--- team/jeffg/jeffg-moresnmp-branch/res/snmp/res_snmp_common.h (added)
+++ team/jeffg/jeffg-moresnmp-branch/res/snmp/res_snmp_common.h Fri Sep 26 18:32:43 2008
@@ -1,0 +1,44 @@
+/*
+ * There is some collision collision between netsmp and asterisk names,
+ * causing build under AST_DEVMODE to fail.
+ *
+ * The following PACKAGE_* macros are one place.
+ * Also netsnmp has an improper check for HAVE_DMALLOC_H, using
+ *    #if HAVE_DMALLOC_H   instead of #ifdef HAVE_DMALLOC_H
+ * As a countermeasure we define it to 0, however this will fail
+ * when the proper check is implemented.
+ */
+#ifdef PACKAGE_NAME
+#undef PACKAGE_NAME
+#endif
+#ifdef PACKAGE_BUGREPORT
+#undef PACKAGE_BUGREPORT
+#endif
+#ifdef PACKAGE_STRING
+#undef PACKAGE_STRING
+#endif
+#ifdef PACKAGE_TARNAME
+#undef PACKAGE_TARNAME
+#endif
+#ifdef PACKAGE_VERSION
+#undef PACKAGE_VERSION
+#endif
+#ifndef HAVE_DMALLOC_H
+#define HAVE_DMALLOC_H 0	/* XXX we shouldn't do this */
+#endif
+
+#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-includes.h>
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+
+/* Collision between Net-SNMP and Asterisk */
+#define unload_module ast_unload_module
+#include "asterisk/module.h"
+#undef unload_module
+
+/* Helper functions in Net-SNMP, header file not installed by default */
+int header_generic(struct variable *, oid *, size_t *, int, size_t *, WriteMethod **);
+int header_simple_table(struct variable *, oid *, size_t *, int, size_t *, WriteMethod **, int);
+int register_sysORTable(oid *, size_t, const char *);
+int unregister_sysORTable(oid *, size_t);
+

Propchange: team/jeffg/jeffg-moresnmp-branch/res/snmp/res_snmp_common.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/jeffg/jeffg-moresnmp-branch/res/snmp/res_snmp_common.h
------------------------------------------------------------------------------
    svn:keywords = None

Propchange: team/jeffg/jeffg-moresnmp-branch/res/snmp/res_snmp_common.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/jeffg/jeffg-moresnmp-branch/res/snmp/traps.c
URL: http://svn.digium.com/view/asterisk/team/jeffg/jeffg-moresnmp-branch/res/snmp/traps.c?view=auto&rev=144860
==============================================================================
--- team/jeffg/jeffg-moresnmp-branch/res/snmp/traps.c (added)
+++ team/jeffg/jeffg-moresnmp-branch/res/snmp/traps.c Fri Sep 26 18:32:43 2008
@@ -1,0 +1,23 @@
+/*
+ * Copyright (C) 2008 The OpenNMS Group
+ * Jeff Gehlbach <jeffg at opennms.org>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief SNMP Agent / SubAgent trap support for Asterisk
+ *
+ * \author Jeff Gehlbach <jeffg at opennms.org>
+ */
+
+#include "asterisk.h"
+#include "res_snmp_common.h"
+#include "asterisk/trap_defs.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+

Propchange: team/jeffg/jeffg-moresnmp-branch/res/snmp/traps.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/jeffg/jeffg-moresnmp-branch/res/snmp/traps.c
------------------------------------------------------------------------------
    svn:keywords = Revieion

Propchange: team/jeffg/jeffg-moresnmp-branch/res/snmp/traps.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list