Asterisk - The Open Source Telephony Project
18.5.0
|
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) |
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" |
Referenced by _stun_show_status().
#define DEFAULT_MONITOR_REFRESH 30 |
Default refresh period in seconds
Definition at line 47 of file res_stun_monitor.c.
Referenced by load_config().
#define DEFAULT_RETRIES 3 |
retries shown in stun show status matching static retries in stun.c
Definition at line 48 of file res_stun_monitor.c.
Referenced by _stun_show_status().
#define HEADER "%-25s %-5s %-7s %-8s %-7s %-16s %-s\n" |
Referenced by _stun_show_status().
|
static |
Definition at line 487 of file res_stun_monitor.c.
|
static |
Definition at line 433 of file res_stun_monitor.c.
References args, ast_mutex_lock, ast_mutex_unlock, load_config(), reload(), stun_start_monitor(), and stun_stop_monitor().
Referenced by load_module(), and reload().
|
static |
Definition at line 487 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 377 of file res_stun_monitor.c.
References a, args, ast_cli(), ast_inet_ntoa(), DATALN, DEFAULT_RETRIES, handle_cli_stun_show_status(), HEADER, and status.
Referenced by handle_cli_stun_show_status(), and load_config().
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 487 of file res_stun_monitor.c.
|
static |
Definition at line 408 of file res_stun_monitor.c.
References _stun_show_status(), ast_cli_args::argc, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, NULL, and ast_cli_entry::usage.
Referenced by _stun_show_status().
|
static |
Definition at line 327 of file res_stun_monitor.c.
References _stun_show_status(), 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(), and setup_stunaddr().
|
static |
Register CLI commands
Definition at line 466 of file res_stun_monitor.c.
References __reload(), args, ast_cli_register_multiple, AST_MODFLAG_GLOBAL_SYMBOLS, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CHANNEL_DEPEND, AST_MODULE_INFO(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_MODULE_SUPPORT_CORE, ast_mutex_destroy, ast_mutex_init, ASTERISK_GPL_KEY, reload(), and unload_module().
Referenced by unload_module().
|
static |
Definition at line 450 of file res_stun_monitor.c.
References __reload(), and unload_module().
Referenced by __reload(), load_module(), and stun_start_monitor().
|
static |
Definition at line 273 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, load_config(), LOG_WARNING, ast_sockaddr::ss, STANDARD_STUN_PORT, and value.
Referenced by load_config(), and stun_start_monitor().
|
static |
Definition at line 76 of file res_stun_monitor.c.
References args, and stun_monitor_request().
Referenced by load_config(), stun_monitor_request(), stun_start_monitor(), and stun_stop_monitor().
|
static |
Definition at line 85 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, ast_sockaddr::ss, stasis_message_create(), stasis_publish(), stun_close_sock(), and stun_stop_monitor().
Referenced by stun_close_sock(), and stun_start_monitor().
|
static |
Definition at line 233 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, reload(), setup_stunaddr(), stun_close_sock(), stun_monitor_request(), and value.
Referenced by __reload(), and stun_stop_monitor().
|
static |
Definition at line 209 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, stun_close_sock(), and stun_start_monitor().
Referenced by __reload(), stun_monitor_request(), and unload_module().
|
static |
Unregister CLI commands
Definition at line 455 of file res_stun_monitor.c.
References args, ARRAY_LEN, ast_cli_unregister_multiple(), ast_mutex_destroy, load_module(), and stun_stop_monitor().
Referenced by load_module(), and reload().
|
static |
Definition at line 487 of file res_stun_monitor.c.
struct { ... } args |
|
static |
Definition at line 487 of file res_stun_monitor.c.
|
static |
Definition at line 429 of file res_stun_monitor.c.
struct sockaddr_in external_addr |
Current perceived external address.
Definition at line 59 of file res_stun_monitor.c.
unsigned int external_addr_known |
TRUE if the perceived external address is valid/known.
Definition at line 71 of file res_stun_monitor.c.
ast_mutex_t lock |
STUN monitor protection lock.
Definition at line 57 of file res_stun_monitor.c.
unsigned int monitor_enabled |
TRUE if the STUN monitor is enabled.
Definition at line 69 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 65 of file res_stun_monitor.c.
Referenced by iax2_ack_registry(), and update_registry().
|
static |
Definition at line 53 of file res_stun_monitor.c.
const char* server_hostname |
STUN server host name.
Definition at line 61 of file res_stun_monitor.c.
|
static |
Definition at line 52 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 73 of file res_stun_monitor.c.
unsigned int stun_port |
Port of STUN server to use
Definition at line 63 of file res_stun_monitor.c.
int stun_sock |
Monitoring STUN socket.
Definition at line 67 of file res_stun_monitor.c.