Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
STUN Network Monitor. More...
#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/sched.h"
#include "asterisk/config.h"
#include "asterisk/stun.h"
#include "asterisk/netsock2.h"
#include "asterisk/lock.h"
#include "asterisk/acl.h"
#include "asterisk/cli.h"
#include "asterisk/json.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_system.h"
#include "asterisk/astobj2.h"
#include <fcntl.h>
Go to the source code of this file.
Macros | |
#define | DATALN "%-25s %-5u %-7u %-8d %-7s %-16s %-d\n" |
#define | DEFAULT_MONITOR_REFRESH 30 |
#define | DEFAULT_RETRIES 3 |
#define | HEADER "%-25s %-5s %-7s %-8s %-7s %-16s %-s\n" |
Functions | |
static void | __reg_module (void) |
static int | __reload (int startup) |
static void | __unreg_module (void) |
static void | _stun_show_status (int fd) |
Execute stun show status command. More... | |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static char * | handle_cli_stun_show_status (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | load_config (int startup) |
static int | load_module (void) |
static int | reload (void) |
static int | setup_stunaddr (const char *value, int reload) |
static void | stun_close_sock (void) |
static int | stun_monitor_request (const void *blarg) |
called by scheduler to send STUN request More... | |
static int | stun_start_monitor (void) |
static void | stun_stop_monitor (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "STUN Network Monitor" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DEPEND } |
struct { | |
struct sockaddr_in external_addr | |
unsigned int external_addr_known:1 | |
ast_mutex_t lock | |
unsigned int monitor_enabled:1 | |
unsigned int refresh | |
const char * server_hostname | |
unsigned int stun_poll_failed_gripe:1 | |
unsigned int stun_port | |
int stun_sock | |
} | args |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_cli_entry | cli_stun [] |
static struct ast_sched_context * | sched |
static const char | stun_conf_file [] = "res_stun_monitor.conf" |
STUN Network Monitor.
Definition in file res_stun_monitor.c.
#define DATALN "%-25s %-5u %-7u %-8d %-7s %-16s %-d\n" |
#define DEFAULT_MONITOR_REFRESH 30 |
Default refresh period in seconds
Definition at line 47 of file res_stun_monitor.c.
#define DEFAULT_RETRIES 3 |
retries shown in stun show status matching static retries in stun.c
Definition at line 49 of file res_stun_monitor.c.
#define HEADER "%-25s %-5s %-7s %-8s %-7s %-16s %-s\n" |
|
static |
Definition at line 483 of file res_stun_monitor.c.
|
static |
Definition at line 429 of file res_stun_monitor.c.
References args, ast_mutex_lock, ast_mutex_unlock, load_config(), stun_start_monitor(), and stun_stop_monitor().
Referenced by load_module(), and reload().
|
static |
Definition at line 483 of file res_stun_monitor.c.
|
static |
Execute stun show status command.
we only have one stun server, but start to play well with more
Definition at line 373 of file res_stun_monitor.c.
References args, ast_cli(), ast_inet_ntoa(), DATALN, DEFAULT_RETRIES, HEADER, and status.
Referenced by handle_cli_stun_show_status().
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 483 of file res_stun_monitor.c.
|
static |
Definition at line 404 of file res_stun_monitor.c.
References _stun_show_status(), a, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, and ast_cli_entry::usage.
|
static |
Definition at line 323 of file res_stun_monitor.c.
References args, ast_config_destroy(), ast_config_load2(), ast_log, ast_set_flag, ast_variable_browse(), CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, DEFAULT_MONITOR_REFRESH, ast_variable::lineno, LOG_WARNING, ast_variable::name, ast_variable::next, setup_stunaddr(), stun_close_sock(), stun_conf_file, and ast_variable::value.
Referenced by __reload().
|
static |
Register CLI commands
Definition at line 462 of file res_stun_monitor.c.
References __reload(), args, ast_cli_register_multiple, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_mutex_destroy, ast_mutex_init, and cli_stun.
|
static |
Definition at line 446 of file res_stun_monitor.c.
References __reload().
Referenced by setup_stunaddr().
|
static |
Definition at line 269 of file res_stun_monitor.c.
References args, ast_free, ast_get_ip(), ast_log, ast_sockaddr_split_hostport(), ast_strdup, ast_strdupa, ast_strlen_zero(), LOG_WARNING, reload(), STANDARD_STUN_PORT, and value.
Referenced by load_config().
|
static |
Definition at line 75 of file res_stun_monitor.c.
References args.
Referenced by load_config(), stun_monitor_request(), stun_start_monitor(), and stun_stop_monitor().
|
static |
called by scheduler to send STUN request
Definition at line 84 of file res_stun_monitor.c.
References answer(), ao2_cleanup, args, ast_connect(), ast_get_ip(), ast_inet_ntoa(), ast_json_object_create(), ast_json_payload_create(), ast_json_unref(), ast_log, ast_mutex_lock, ast_mutex_unlock, ast_network_change_type(), ast_sockaddr_set_port, ast_sockaddr_stringify(), ast_strdupa, ast_stun_request(), ast_system_topic(), errno, LOG_ERROR, LOG_NOTICE, LOG_WARNING, NULL, RAII_VAR, stasis_message_create(), stasis_publish(), and stun_close_sock().
Referenced by stun_start_monitor().
|
static |
Definition at line 228 of file res_stun_monitor.c.
References args, ast_log, ast_sched_add_variable(), ast_sched_context_create(), ast_sched_context_destroy(), ast_sched_start_thread(), LOG_ERROR, LOG_NOTICE, NULL, stun_close_sock(), and stun_monitor_request().
Referenced by __reload().
|
static |
Definition at line 206 of file res_stun_monitor.c.
References args, ast_free, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_sched_context_destroy(), LOG_NOTICE, NULL, and stun_close_sock().
Referenced by __reload(), and unload_module().
|
static |
Unregister CLI commands
Definition at line 451 of file res_stun_monitor.c.
References args, ARRAY_LEN, ast_cli_unregister_multiple(), ast_mutex_destroy, cli_stun, and stun_stop_monitor().
|
static |
Definition at line 483 of file res_stun_monitor.c.
struct { ... } args |
|
static |
Definition at line 483 of file res_stun_monitor.c.
|
static |
Definition at line 425 of file res_stun_monitor.c.
Referenced by load_module(), and unload_module().
struct sockaddr_in external_addr |
Current perceived external address.
Definition at line 58 of file res_stun_monitor.c.
unsigned int external_addr_known |
TRUE if the perceived external address is valid/known.
Definition at line 70 of file res_stun_monitor.c.
ast_mutex_t lock |
STUN monitor protection lock.
Definition at line 56 of file res_stun_monitor.c.
unsigned int monitor_enabled |
TRUE if the STUN monitor is enabled.
Definition at line 68 of file res_stun_monitor.c.
unsigned int refresh |
Number of seconds between polls to the STUN server for the external address.
Definition at line 64 of file res_stun_monitor.c.
Referenced by iax2_ack_registry(), and update_registry().
|
static |
Definition at line 52 of file res_stun_monitor.c.
const char* server_hostname |
STUN server host name.
Definition at line 60 of file res_stun_monitor.c.
|
static |
Definition at line 51 of file res_stun_monitor.c.
Referenced by load_config().
unsigned int stun_poll_failed_gripe |
TRUE if we have already griped about a STUN poll failing.
Definition at line 72 of file res_stun_monitor.c.
unsigned int stun_port |
Port of STUN server to use
Definition at line 62 of file res_stun_monitor.c.
int stun_sock |
Monitoring STUN socket.
Definition at line 66 of file res_stun_monitor.c.