SNMP Agent / SubAgent support for Asterisk. More...
#include "asterisk.h"#include "asterisk/channel.h"#include "asterisk/module.h"#include "snmp/agent.h"
Go to the source code of this file.
Defines | |
| #define | MODULE_DESCRIPTION "SNMP [Sub]Agent for Asterisk" |
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static int | load_config (void) |
| Load res_snmp.conf config file. | |
| static int | load_module (void) |
| static int | unload_module (void) |
Variables | |
| static struct ast_module_info __MODULE_INFO_SECTION | __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS , .description = "SNMP [Sub]Agent for Asterisk" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| int | res_snmp_agentx_subagent |
| int | res_snmp_dont_stop |
| int | res_snmp_enabled |
| static pthread_t | thread = AST_PTHREADT_NULL |
SNMP Agent / SubAgent support for Asterisk.
Definition in file res_snmp.c.
| #define MODULE_DESCRIPTION "SNMP [Sub]Agent for Asterisk" |
Definition at line 33 of file res_snmp.c.
| static void __reg_module | ( | void | ) | [static] |
Definition at line 121 of file res_snmp.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 121 of file res_snmp.c.
| static int load_config | ( | void | ) | [static] |
Load res_snmp.conf config file.
Definition at line 45 of file res_snmp.c.
References ast_category_browse(), ast_config_destroy(), ast_config_load, ast_false(), ast_log(), ast_true(), ast_variable_browse(), CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, LOG_ERROR, LOG_WARNING, ast_variable::name, ast_variable::next, ast_variable::value, and var.
Referenced by load_module().
{
struct ast_variable *var;
struct ast_config *cfg;
struct ast_flags config_flags = { 0 };
char *cat;
res_snmp_enabled = 0;
res_snmp_agentx_subagent = 1;
cfg = ast_config_load("res_snmp.conf", config_flags);
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_WARNING, "Could not load res_snmp.conf\n");
return 0;
}
cat = ast_category_browse(cfg, NULL);
while (cat) {
var = ast_variable_browse(cfg, cat);
if (strcasecmp(cat, "general") == 0) {
while (var) {
if (strcasecmp(var->name, "subagent") == 0) {
if (ast_true(var->value))
res_snmp_agentx_subagent = 1;
else if (ast_false(var->value))
res_snmp_agentx_subagent = 0;
else {
ast_log(LOG_ERROR, "Value '%s' does not evaluate to true or false.\n", var->value);
ast_config_destroy(cfg);
return 1;
}
} else if (strcasecmp(var->name, "enabled") == 0) {
res_snmp_enabled = ast_true(var->value);
} else {
ast_log(LOG_ERROR, "Unrecognized variable '%s' in category '%s'\n", var->name, cat);
ast_config_destroy(cfg);
return 1;
}
var = var->next;
}
} else {
ast_log(LOG_ERROR, "Unrecognized category '%s'\n", cat);
ast_config_destroy(cfg);
return 1;
}
cat = ast_category_browse(cfg, cat);
}
ast_config_destroy(cfg);
return 1;
}
| static int load_module | ( | void | ) | [static] |
Definition at line 96 of file res_snmp.c.
References agent_thread(), AST_MODULE_LOAD_DECLINE, ast_pthread_create_background, ast_verb, and load_config().
{
if(!load_config())
return AST_MODULE_LOAD_DECLINE;
ast_verb(1, "Loading [Sub]Agent Module\n");
res_snmp_dont_stop = 1;
if (res_snmp_enabled)
return ast_pthread_create_background(&thread, NULL, agent_thread, NULL);
else
return 0;
}
| static int unload_module | ( | void | ) | [static] |
Definition at line 110 of file res_snmp.c.
References AST_PTHREADT_NULL, and ast_verb.
{
ast_verb(1, "Unloading [Sub]Agent Module\n");
res_snmp_dont_stop = 0;
return ((thread != AST_PTHREADT_NULL) ? pthread_join(thread, NULL) : 0);
}
struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS , .description = "SNMP [Sub]Agent for Asterisk" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 121 of file res_snmp.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 121 of file res_snmp.c.
Definition at line 35 of file res_snmp.c.
Referenced by agent_thread().
Definition at line 36 of file res_snmp.c.
Referenced by agent_thread().
| int res_snmp_enabled |
Definition at line 37 of file res_snmp.c.
pthread_t thread = AST_PTHREADT_NULL [static] |
Definition at line 39 of file res_snmp.c.