Wed Jan 8 2020 09:50:19

Asterisk developer's documentation


res_stun_monitor.c File Reference

STUN Network Monitor. More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/event.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 <fcntl.h>

Go to the source code of this file.

Macros

#define DEFAULT_MONITOR_REFRESH   30
 

Functions

static void __reg_module (void)
 
static int __reload (int startup)
 
static void __unreg_module (void)
 
static int load_config (int startup)
 
static int load_module (void)
 
static int reload (void)
 
static int setup_stunaddr (const char *value)
 
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 = "ac1f6a56484a8820659555499174e588" , .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 struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_sched_threadsched
 
static const char stun_conf_file [] = "res_stun_monitor.conf"
 

Detailed Description

STUN Network Monitor.

Author
David Vossel dvoss.nosp@m.el@d.nosp@m.igium.nosp@m..com

Definition in file res_stun_monitor.c.

Macro Definition Documentation

#define DEFAULT_MONITOR_REFRESH   30

Default refresh period in seconds

Definition at line 44 of file res_stun_monitor.c.

Referenced by load_config().

Function Documentation

static void __reg_module ( void  )
static

Definition at line 388 of file res_stun_monitor.c.

static int __reload ( int  startup)
static

Definition at line 342 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().

343 {
344  int res;
345 
346  ast_mutex_lock(&args.lock);
347  if (!(res = load_config(startup)) && args.monitor_enabled) {
348  res = stun_start_monitor();
349  }
350  ast_mutex_unlock(&args.lock);
351 
352  if (res < 0 || !args.monitor_enabled) {
354  }
355 
356  return res;
357 }
#define ast_mutex_lock(a)
Definition: lock.h:155
static int load_config(int startup)
static int stun_start_monitor(void)
static struct @350 args
#define ast_mutex_unlock(a)
Definition: lock.h:156
static void stun_stop_monitor(void)
static void __unreg_module ( void  )
static

Definition at line 388 of file res_stun_monitor.c.

static int load_config ( int  startup)
static

Definition at line 293 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(), and ast_variable::value.

Referenced by __reload().

294 {
295  struct ast_flags config_flags = { 0, };
296  struct ast_config *cfg;
297  struct ast_variable *v;
298 
299  if (!startup) {
300  ast_set_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
301  }
302 
303  cfg = ast_config_load2(stun_conf_file, "res_stun_monitor", config_flags);
304  if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
305  ast_log(LOG_WARNING, "Unable to load config %s\n", stun_conf_file);
306  return -1;
307  }
308  if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
309  return 0;
310  }
311 
312  /* clean up any previous open socket */
313  stun_close_sock();
314  args.stun_poll_failed_gripe = 0;
315 
316  /* set defaults */
317  args.monitor_enabled = 0;
318  args.refresh = DEFAULT_MONITOR_REFRESH;
319 
320  for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
321  if (!strcasecmp(v->name, "stunaddr")) {
322  if (setup_stunaddr(v->value)) {
323  ast_log(LOG_WARNING, "Invalid STUN server address: %s at line %d\n",
324  v->value, v->lineno);
325  }
326  } else if (!strcasecmp(v->name, "stunrefresh")) {
327  if ((sscanf(v->value, "%30u", &args.refresh) != 1) || !args.refresh) {
328  ast_log(LOG_WARNING, "Invalid stunrefresh value '%s', must be an integer > 0 at line %d\n", v->value, v->lineno);
329  args.refresh = DEFAULT_MONITOR_REFRESH;
330  }
331  } else {
332  ast_log(LOG_WARNING, "Invalid config option %s at line %d\n",
333  v->value, v->lineno);
334  }
335  }
336 
337  ast_config_destroy(cfg);
338 
339  return 0;
340 }
#define DEFAULT_MONITOR_REFRESH
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define LOG_WARNING
Definition: logger.h:144
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
Definition: config.c:597
int lineno
Definition: config.h:87
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Definition: config.c:2499
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: config.c:1037
const char * value
Definition: config.h:79
const char * name
Definition: config.h:77
static int setup_stunaddr(const char *value)
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static const char stun_conf_file[]
static void stun_close_sock(void)
Structure used to handle boolean flags.
Definition: utils.h:200
struct ast_variable * next
Definition: config.h:82
#define CONFIG_STATUS_FILEINVALID
Definition: config.h:52
#define CONFIG_STATUS_FILEUNCHANGED
Definition: config.h:51
static int load_module ( void  )
static

Definition at line 371 of file res_stun_monitor.c.

References __reload(), args, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_mutex_destroy, and ast_mutex_init.

372 {
373  ast_mutex_init(&args.lock);
374  args.stun_sock = -1;
375  if (__reload(1)) {
376  ast_mutex_destroy(&args.lock);
378  }
379 
381 }
static int __reload(int startup)
static struct @350 args
#define ast_mutex_init(pmutex)
Definition: lock.h:152
#define ast_mutex_destroy(a)
Definition: lock.h:154
static int reload ( void  )
static

Definition at line 359 of file res_stun_monitor.c.

References __reload().

360 {
361  return __reload(0);
362 }
static int __reload(int startup)
static int setup_stunaddr ( const char *  value)
static

Definition at line 243 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, ast_sockaddr::ss, and STANDARD_STUN_PORT.

Referenced by load_config().

244 {
245  char *val;
246  char *host_str;
247  char *port_str;
248  unsigned int port;
249  struct ast_sockaddr stun_addr;
250 
251  if (ast_strlen_zero(value)) {
252  /* Setting to an empty value disables STUN monitoring. */
253  args.monitor_enabled = 0;
254  return 0;
255  }
256 
257  val = ast_strdupa(value);
258  if (!ast_sockaddr_split_hostport(val, &host_str, &port_str, 0)
259  || ast_strlen_zero(host_str)) {
260  return -1;
261  }
262 
263  /* Determine STUN port */
264  if (ast_strlen_zero(port_str)
265  || 1 != sscanf(port_str, "%30u", &port)) {
266  port = STANDARD_STUN_PORT;
267  }
268 
269  host_str = ast_strdup(host_str);
270  if (!host_str) {
271  return -1;
272  }
273 
274  /* Lookup STUN address. */
275  memset(&stun_addr, 0, sizeof(stun_addr));
276  stun_addr.ss.ss_family = AF_INET;
277  if (ast_get_ip(&stun_addr, host_str)) {
278  ast_log(LOG_WARNING, "Unable to lookup STUN server '%s'\n", host_str);
279  ast_free(host_str);
280  return -1;
281  }
282 
283  /* Save STUN server information. */
284  ast_free((char *) args.server_hostname);
285  args.server_hostname = host_str;
286  args.stun_port = port;
287 
288  /* Enable STUN monitor */
289  args.monitor_enabled = 1;
290  return 0;
291 }
#define ast_strdup(a)
Definition: astmm.h:109
Definition: ast_expr2.c:325
#define LOG_WARNING
Definition: logger.h:144
int value
Definition: syslog.c:39
Socket address structure.
Definition: netsock2.h:63
int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags)
Splits a string into its host and port components.
Definition: netsock2.c:132
static const int STANDARD_STUN_PORT
Definition: stun.h:35
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
Definition: stun.c:89
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int ast_get_ip(struct ast_sockaddr *addr, const char *hostname)
Get the IP address given a hostname.
Definition: acl.c:700
#define ast_free(a)
Definition: astmm.h:97
static void stun_close_sock ( void  )
static

Definition at line 70 of file res_stun_monitor.c.

References args.

Referenced by load_config(), stun_monitor_request(), and stun_stop_monitor().

71 {
72  if (0 <= args.stun_sock) {
73  close(args.stun_sock);
74  args.stun_sock = -1;
75  }
76 }
static struct @350 args
static int stun_monitor_request ( const void *  blarg)
static

Definition at line 79 of file res_stun_monitor.c.

References args, ast_connect(), ast_event_destroy(), AST_EVENT_IE_END, AST_EVENT_NETWORK_CHANGE, ast_event_new(), ast_event_queue(), ast_get_ip(), ast_inet_ntoa(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_sockaddr_set_port, ast_sockaddr_stringify(), ast_strdupa, ast_stun_request(), errno, LOG_ERROR, LOG_NOTICE, LOG_WARNING, ast_sockaddr::ss, and stun_close_sock().

Referenced by stun_start_monitor().

80 {
81  int res;
82  struct sockaddr_in answer;
83  static const struct sockaddr_in no_addr = { 0, };
84 
85  ast_mutex_lock(&args.lock);
86  if (!args.monitor_enabled) {
87  goto monitor_request_cleanup;
88  }
89 
90  if (args.stun_sock < 0) {
91  struct ast_sockaddr stun_addr;
92 
93  /* STUN socket not open. Refresh the server DNS address resolution. */
94  if (!args.server_hostname) {
95  /* No STUN hostname? */
96  goto monitor_request_cleanup;
97  }
98 
99  /* Lookup STUN address. */
100  memset(&stun_addr, 0, sizeof(stun_addr));
101  stun_addr.ss.ss_family = AF_INET;
102  if (ast_get_ip(&stun_addr, args.server_hostname)) {
103  /* Lookup failed. */
104  ast_log(LOG_WARNING, "Unable to lookup STUN server '%s'\n",
105  args.server_hostname);
106  goto monitor_request_cleanup;
107  }
108  ast_sockaddr_set_port(&stun_addr, args.stun_port);
109 
110  /* open socket binding */
111  args.stun_sock = socket(AF_INET, SOCK_DGRAM, 0);
112  if (args.stun_sock < 0) {
113  ast_log(LOG_WARNING, "Unable to create STUN socket: %s\n", strerror(errno));
114  goto monitor_request_cleanup;
115  }
116  if (ast_connect(args.stun_sock, &stun_addr)) {
117  ast_log(LOG_WARNING, "STUN Failed to connect to %s: %s\n",
118  ast_sockaddr_stringify(&stun_addr), strerror(errno));
119  stun_close_sock();
120  goto monitor_request_cleanup;
121  }
122  }
123 
124  res = ast_stun_request(args.stun_sock, NULL, NULL, &answer);
125  if (res) {
126  /*
127  * STUN request timed out or errored.
128  *
129  * Refresh the server DNS address resolution next time around.
130  */
131  if (!args.stun_poll_failed_gripe) {
132  args.stun_poll_failed_gripe = 1;
133  ast_log(LOG_WARNING, "STUN poll %s. Re-evaluating STUN server address.\n",
134  res < 0 ? "failed" : "got no response");
135  }
136  stun_close_sock();
137  } else {
138  args.stun_poll_failed_gripe = 0;
139  if (memcmp(&no_addr, &answer, sizeof(no_addr))
140  && memcmp(&args.external_addr, &answer, sizeof(args.external_addr))) {
141  const char *newaddr = ast_strdupa(ast_inet_ntoa(answer.sin_addr));
142  int newport = ntohs(answer.sin_port);
143 
144  ast_log(LOG_NOTICE, "Old external address/port %s:%d now seen as %s:%d.\n",
145  ast_inet_ntoa(args.external_addr.sin_addr),
146  ntohs(args.external_addr.sin_port), newaddr, newport);
147 
148  args.external_addr = answer;
149 
150  if (args.external_addr_known) {
151  struct ast_event *event;
152 
153  /*
154  * The external address was already known, and has changed...
155  * generate event.
156  */
158  if (!event) {
159  ast_log(LOG_ERROR, "Could not create AST_EVENT_NETWORK_CHANGE event.\n");
160  } else if (ast_event_queue(event)) {
161  ast_event_destroy(event);
162  ast_log(LOG_ERROR, "Could not queue AST_EVENT_NETWORK_CHANGE event.\n");
163  }
164  } else {
165  /* this was the first external address we found, do not alert listeners
166  * until this address changes to something else. */
167  args.external_addr_known = 1;
168  }
169  }
170  }
171 
172 monitor_request_cleanup:
173  /* always refresh this scheduler item. It will be removed elsewhere when
174  * it is supposed to go away */
175  res = args.refresh * 1000;
176  ast_mutex_unlock(&args.lock);
177 
178  return res;
179 }
An event.
Definition: event.c:85
#define LOG_WARNING
Definition: logger.h:144
#define ast_mutex_lock(a)
Definition: lock.h:155
Socket address structure.
Definition: netsock2.h:63
int ast_event_queue(struct ast_event *event)
Queue an event.
Definition: event.c:1517
int ast_stun_request(int s, struct sockaddr_in *dst, const char *username, struct sockaddr_in *answer)
Generic STUN request.
Definition: stun.c:373
Definition: stun.c:89
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
static struct @350 args
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
Definition: netsock2.h:422
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
Definition: netsock2.h:210
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int ast_get_ip(struct ast_sockaddr *addr, const char *hostname)
Get the IP address given a hostname.
Definition: acl.c:700
#define LOG_NOTICE
Definition: logger.h:133
int errno
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: utils.c:564
static void stun_close_sock(void)
void ast_event_destroy(struct ast_event *event)
Destroy an event.
Definition: event.c:1314
struct ast_event * ast_event_new(enum ast_event_type event_type,...)
Create a new event.
Definition: event.c:1202
int ast_connect(int sockfd, const struct ast_sockaddr *addr)
Wrapper around connect(2) that uses struct ast_sockaddr.
Definition: netsock2.c:467
#define ast_mutex_unlock(a)
Definition: lock.h:156
static int stun_start_monitor ( void  )
static

Definition at line 212 of file res_stun_monitor.c.

References args, ast_log(), ast_sched_thread_add_variable(), ast_sched_thread_create(), ast_sched_thread_destroy(), LOG_ERROR, LOG_NOTICE, and stun_monitor_request().

Referenced by __reload().

213 {
214  /* if scheduler thread is not started, make sure to start it now */
215  if (sched) {
216  return 0; /* already started */
217  }
218 
219  if (!(sched = ast_sched_thread_create())) {
220  ast_log(LOG_ERROR, "Failed to create stun monitor scheduler thread\n");
221  return -1;
222  }
223 
224  if (ast_sched_thread_add_variable(sched, (args.refresh * 1000), stun_monitor_request, NULL, 1) < 0) {
225  ast_log(LOG_ERROR, "Unable to schedule STUN network monitor \n");
227  return -1;
228  }
229 
230  ast_log(LOG_NOTICE, "STUN monitor started\n");
231  return 0;
232 }
struct ast_sched_thread * ast_sched_thread_destroy(struct ast_sched_thread *st)
Destroy a scheduler and its thread.
Definition: sched.c:143
static int stun_monitor_request(const void *blarg)
struct ast_sched_thread * ast_sched_thread_create(void)
Create a scheduler with a dedicated thread.
Definition: sched.c:167
int ast_sched_thread_add_variable(struct ast_sched_thread *st, int when, ast_sched_cb cb, const void *data, int variable)
Add a variable reschedule time scheduler entry.
Definition: sched.c:195
Definition: sched.c:57
#define LOG_ERROR
Definition: logger.h:155
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
static void stun_stop_monitor ( void  )
static

Definition at line 189 of file res_stun_monitor.c.

References args, ast_free, ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_sched_thread_destroy(), LOG_NOTICE, and stun_close_sock().

Referenced by __reload(), and unload_module().

190 {
191  ast_mutex_lock(&args.lock);
192  args.monitor_enabled = 0;
193  ast_free((char *) args.server_hostname);
194  args.server_hostname = NULL;
195  stun_close_sock();
196  ast_mutex_unlock(&args.lock);
197 
198  if (sched) {
200  ast_log(LOG_NOTICE, "STUN monitor stopped\n");
201  }
202 }
struct ast_sched_thread * ast_sched_thread_destroy(struct ast_sched_thread *st)
Destroy a scheduler and its thread.
Definition: sched.c:143
Definition: sched.c:57
#define ast_mutex_lock(a)
Definition: lock.h:155
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
#define ast_free(a)
Definition: astmm.h:97
static void stun_close_sock(void)
#define ast_mutex_unlock(a)
Definition: lock.h:156
static int unload_module ( void  )
static

Definition at line 364 of file res_stun_monitor.c.

References args, ast_mutex_destroy, and stun_stop_monitor().

365 {
367  ast_mutex_destroy(&args.lock);
368  return 0;
369 }
static struct @350 args
#define ast_mutex_destroy(a)
Definition: lock.h:154
static void stun_stop_monitor(void)

Variable Documentation

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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DEPEND }
static

Definition at line 388 of file res_stun_monitor.c.

struct { ... } args

Referenced by __reload(), acf_curl_helper(), acf_isexten_exec(), acf_jabberreceive_read(), acf_jabberstatus_read(), acf_meetme_info(), acf_odbc_read(), acf_odbc_write(), acf_rand_exec(), acf_strftime(), acf_strptime(), acf_transaction_read(), acf_transaction_write(), acf_version_exec(), acf_vmcount_exec(), add_agent(), add_cfg_entry(), add_rt_cfg_entry(), add_rt_multi_cfg_entry(), admin_exec(), adsi_process(), aelsub_exec(), aes_helper(), agi_exec_full(), aji_join_exec(), aji_leave_exec(), aji_send_exec(), aji_sendgroup_exec(), aji_status_exec(), answer_exec_enable(), app_exec(), aqm_exec(), ast_cc_agent_callback(), ast_cc_agent_status_response(), ast_cli_command_full(), ast_eivr_senddtmf(), ast_func_read(), ast_func_read2(), ast_func_write(), ast_queue_log(), asyncgoto_exec(), background_detect_exec(), bridge_exec(), builtin_automixmonitor(), builtin_automonitor(), calendar_query_exec(), calendar_query_result_exec(), callerid_read(), cc_agent_callback_helper(), cc_do_state_change(), cc_request_state_change(), cc_status_response(), cdr_read(), cdr_write(), celgenuserevent_exec(), chanavail_exec(), channel_admin_exec(), channel_set_debug(), chanspy_exec(), cli_odbc_read(), cli_odbc_write(), conf_exec(), confbridge_exec(), config_function_read(), controlplayback_exec(), count_exec(), cut_internal(), dahdi_accept_r2_call_exec(), dahdi_send_callrerouting_facility_exec(), dahdiras_exec(), determine_starting_point(), dial_exec_full(), dial_trunk(), dialgroup_write(), dictate_exec(), directory_exec(), disa_exec(), dundi_query_read(), dundi_result_read(), dundifunc_read(), enable_jack_hook(), enum_query_read(), enum_result_read(), exec_exec(), extenspy_exec(), festival_exec(), file_count_line(), file_read(), file_write(), filter(), find_call(), find_conf(), find_realtime_gw(), func_args(), func_header_read(), function_agent(), function_db_delete(), function_db_exists(), function_db_read(), function_db_write(), function_enum(), function_fieldnum_helper(), function_fieldqty_helper(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_write(), function_txtcidname(), gosubif_exec(), handle_verbose(), hint_read(), iconv_read(), import_helper(), isAnsweringMachine(), isexten_function_read(), jb_debug_output(), jb_error_output(), jb_warning_output(), kqueue_timer_cmp(), listfilter(), load_config(), load_module(), log_exec(), login_exec(), man_do_variable_value(), math(), misdn_call(), misdn_check_l2l1(), misdn_facility_exec(), misdn_request(), mixmonitor_exec(), my_pri_make_cc_dialstring(), originate_exec(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), oss_call(), oss_request(), page_exec(), parkandannounce_exec(), pbx_builtin_answer(), pbx_builtin_background(), pbx_builtin_resetcdr(), pbx_builtin_saydate(), pbx_builtin_saytime(), pbx_builtin_setvar_multiple(), pbx_builtin_waitexten(), peek_read(), pickup_by_name_cb(), pickupchan_exec(), playback_exec(), pqm_exec(), privacy_exec(), process_applicationmap_line(), pvalAppCallWalkArgs(), pvalMacroCallWalkArgs(), ql_exec(), queue_exec(), queue_function_memberpenalty_read(), queue_function_memberpenalty_write(), queue_function_queuememberpaused(), queue_function_queuememberstatus(), rcvfax_exec(), realtimefield_read(), receivefax_exec(), record_exec(), recordthread(), reg_source_db(), regex(), reload_single_member(), replace(), retrydial_exec(), rqm_exec(), run_station(), saycountedadj_exec(), saycountednoun_exec(), sayunixtime_exec(), senddtmf_exec(), sendfax_exec(), sendurl_exec(), setup_stunaddr(), shared_read(), shared_write(), shift_pop(), sig_pri_call(), sig_pri_extract_called_num_subaddr(), sip_acf_channel_read(), sip_request_call(), sip_tcptls_client_args_destructor(), sla_trunk_exec(), smdi_msg_read(), smdi_msg_retrieve_read(), sndfax_exec(), softhangup_exec(), spawn_ras(), speech_background(), speech_load(), srv_result_read(), stackpeek_read(), start_monitor_exec(), stun_close_sock(), stun_monitor_request(), stun_start_monitor(), stun_stop_monitor(), timerfd_timer_cmp(), transfer_exec(), tryexec_exec(), unload_module(), unshift_push(), upqm_exec(), user_chan_cb(), userevent_exec(), verbose_exec(), vm_box_exists(), vm_exec(), vm_execmain(), volume_write(), and zapateller_exec().

Definition at line 388 of file res_stun_monitor.c.

struct sockaddr_in external_addr

Current perceived external address.

Definition at line 53 of file res_stun_monitor.c.

unsigned int external_addr_known

TRUE if the perceived external address is valid/known.

Definition at line 65 of file res_stun_monitor.c.

STUN monitor protection lock.

Definition at line 51 of file res_stun_monitor.c.

unsigned int monitor_enabled

TRUE if the STUN monitor is enabled.

Definition at line 63 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 59 of file res_stun_monitor.c.

Referenced by iax2_ack_registry(), and update_registry().

struct ast_sched_thread* sched
static

Definition at line 47 of file res_stun_monitor.c.

const char* server_hostname

STUN server host name.

Definition at line 55 of file res_stun_monitor.c.

const char stun_conf_file[] = "res_stun_monitor.conf"
static

Definition at line 46 of file res_stun_monitor.c.

unsigned int stun_poll_failed_gripe

TRUE if we have already griped about a STUN poll failing.

Definition at line 67 of file res_stun_monitor.c.

unsigned int stun_port

Port of STUN server to use

Definition at line 57 of file res_stun_monitor.c.

int stun_sock

Monitoring STUN socket.

Definition at line 61 of file res_stun_monitor.c.