#include "asterisk.h"
#include "asterisk/channel.h"
#include "asterisk/module.h"
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "snmp/agent.h"
Include dependency graph for res_snmp.c:
Go to the source code of this file.
Defines | |
#define | MODULE_DESCRIPTION "SNMP [Sub]Agent for Asterisk" |
Functions | |
AST_MODULE_INFO (ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS,"SNMP [Sub]Agent for Asterisk",.load=load_module,.unload=unload_module,.reload=reload,) | |
static int | load_config (void) |
static int | load_module (void) |
static int | reload (void) |
static int | unload_module (void) |
Variables | |
int | res_snmp_agentx_subagent |
int | res_snmp_dont_stop |
int | res_snmp_enabled |
static pthread_t | thread = AST_PTHREADT_NULL |
Definition in file res_snmp.c.
#define MODULE_DESCRIPTION "SNMP [Sub]Agent for Asterisk" |
Definition at line 32 of file res_snmp.c.
AST_MODULE_INFO | ( | ASTERISK_GPL_KEY | , | |
AST_MODFLAG_GLOBAL_SYMBOLS | , | |||
"SNMP Agent for Asterisk" | [Sub], | |||
. | load = load_module , |
|||
. | unload = unload_module , |
|||
. | reload = reload | |||
) |
static int load_config | ( | void | ) | [static] |
Definition at line 40 of file res_snmp.c.
References ast_category_browse(), ast_config_destroy(), ast_config_load(), ast_false(), ast_log(), ast_true(), ast_variable_browse(), LOG_ERROR, LOG_WARNING, and var.
00041 { 00042 struct ast_variable *var; 00043 struct ast_config *cfg; 00044 char *cat; 00045 00046 res_snmp_enabled = 0; 00047 res_snmp_agentx_subagent = 1; 00048 cfg = ast_config_load("res_snmp.conf"); 00049 if (!cfg) { 00050 ast_log(LOG_WARNING, "Could not load res_snmp.conf\n"); 00051 return 0; 00052 } 00053 cat = ast_category_browse(cfg, NULL); 00054 while (cat) { 00055 var = ast_variable_browse(cfg, cat); 00056 00057 if (strcasecmp(cat, "general") == 0) { 00058 while (var) { 00059 if (strcasecmp(var->name, "subagent") == 0) { 00060 if (ast_true(var->value)) 00061 res_snmp_agentx_subagent = 1; 00062 else if (ast_false(var->value)) 00063 res_snmp_agentx_subagent = 0; 00064 else { 00065 ast_log(LOG_ERROR, "Value '%s' does not evaluate to true or false.\n", var->value); 00066 ast_config_destroy(cfg); 00067 return 1; 00068 } 00069 } else if (strcasecmp(var->name, "enabled") == 0) { 00070 res_snmp_enabled = ast_true(var->value); 00071 } else { 00072 ast_log(LOG_ERROR, "Unrecognized variable '%s' in category '%s'\n", var->name, cat); 00073 ast_config_destroy(cfg); 00074 return 1; 00075 } 00076 var = var->next; 00077 } 00078 } else { 00079 ast_log(LOG_ERROR, "Unrecognized category '%s'\n", cat); 00080 ast_config_destroy(cfg); 00081 return 1; 00082 } 00083 00084 cat = ast_category_browse(cfg, cat); 00085 } 00086 ast_config_destroy(cfg); 00087 return 1; 00088 }
static int load_module | ( | void | ) | [static] |
Definition at line 90 of file res_snmp.c.
References AST_MODULE_LOAD_DECLINE, ast_pthread_create_background, ast_verbose(), load_config(), and VERBOSE_PREFIX_1.
00091 { 00092 if(!load_config()) 00093 return AST_MODULE_LOAD_DECLINE; 00094 00095 ast_verbose(VERBOSE_PREFIX_1 "Loading [Sub]Agent Module\n"); 00096 00097 res_snmp_dont_stop = 1; 00098 if (res_snmp_enabled) 00099 return ast_pthread_create_background(&thread, NULL, agent_thread, NULL); 00100 else 00101 return 0; 00102 }
static int reload | ( | void | ) | [static] |
Definition at line 112 of file res_snmp.c.
References ast_pthread_create_background, AST_PTHREADT_NULL, ast_verbose(), load_config(), and VERBOSE_PREFIX_1.
00113 { 00114 ast_verbose(VERBOSE_PREFIX_1 "Reloading [Sub]Agent Module\n"); 00115 00116 res_snmp_dont_stop = 0; 00117 if (thread != AST_PTHREADT_NULL) 00118 pthread_join(thread, NULL); 00119 thread = AST_PTHREADT_NULL; 00120 load_config(); 00121 00122 res_snmp_dont_stop = 1; 00123 if (res_snmp_enabled) 00124 return ast_pthread_create_background(&thread, NULL, agent_thread, NULL); 00125 else 00126 return 0; 00127 }
static int unload_module | ( | void | ) | [static] |
Definition at line 104 of file res_snmp.c.
References AST_PTHREADT_NULL, ast_verbose(), and VERBOSE_PREFIX_1.
00105 { 00106 ast_verbose(VERBOSE_PREFIX_1 "Unloading [Sub]Agent Module\n"); 00107 00108 res_snmp_dont_stop = 0; 00109 return ((thread != AST_PTHREADT_NULL) ? pthread_join(thread, NULL) : 0); 00110 }
Definition at line 34 of file res_snmp.c.
Definition at line 35 of file res_snmp.c.
int res_snmp_enabled |
Definition at line 36 of file res_snmp.c.
pthread_t thread = AST_PTHREADT_NULL [static] |
Definition at line 38 of file res_snmp.c.