* Implementation of RFC 3261 - without S/MIME, TCP and TLS support
* Configuration file \link Config_sip sip.conf \endlink
*
+ *
* \todo SIP over TCP
* \todo SIP over TLS
* \todo Better support of forking
+ *
+ * \ingroup channel_drivers
*/
AST_MUTEX_DEFINE_STATIC(sip_reload_lock);
static int sip_reloading = 0;
+static enum channelreloadreason sip_reloadreason; /*!< Reason for last reload/load of configuration */
/* States for outbound registrations (with register= lines in sip.conf */
#define REG_STATE_UNREGISTERED 0
static int update_call_counter(struct sip_pvt *fup, int event);
static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int realtime);
static struct sip_user *build_user(const char *name, struct ast_variable *v, int realtime);
-static int sip_do_reload(void);
+static int sip_do_reload(enum channelreloadreason reason);
static int expire_register(void *data);
static struct ast_channel *sip_request_call(const char *type, int format, void *data, int *cause);
return ret;
}
-/* Structure to declare a dialplan function: SIPPEER */
+/*! \brief Structure to declare a dialplan function: SIPPEER */
struct ast_custom_function sippeer_function = {
.name = "SIPPEER",
.synopsis = "Gets SIP peer information",
return buf;
}
-/* Structure to declare a dialplan function: SIPCHANINFO */
+/*! \brief Structure to declare a dialplan function: SIPCHANINFO */
static struct ast_custom_function sipchaninfo_function = {
.name = "SIPCHANINFO",
.synopsis = "Gets the specified SIP parameter from the current channel",
if (reloading) {
if (option_verbose > 0)
ast_verbose(VERBOSE_PREFIX_1 "Reloading SIP\n");
- sip_do_reload();
+ sip_do_reload(sip_reloadreason);
}
/* Check for interfaces needing to be killed */
ast_mutex_lock(&iflock);
change configuration data at restart, not at reload.
SIP debug and recordhistory state will not change
*/
-static int reload_config(void)
+static int reload_config(enum channelreloadreason reason)
{
struct ast_config *cfg;
struct ast_variable *v;
struct ast_flags dummy;
int auto_sip_domains = 0;
struct sockaddr_in old_bindaddr = bindaddr;
+ int registry_count = 0, peer_count = 0, user_count = 0;
cfg = ast_config_load(config);
else
add_sip_domain(ast_strip(domain), SIP_DOMAIN_CONFIG, context ? ast_strip(context) : "");
} else if (!strcasecmp(v->name, "register")) {
- sip_register(v->value, v->lineno);
+ if (sip_register(v->value, v->lineno) == 0)
+ registry_count++;
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &global_tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno);
if (user) {
ASTOBJ_CONTAINER_LINK(&userl,user);
ASTOBJ_UNREF(user, sip_destroy_user);
+ user_count++;
}
}
if (is_peer) {
if (peer) {
ASTOBJ_CONTAINER_LINK(&peerl,peer);
ASTOBJ_UNREF(peer, sip_destroy_peer);
+ peer_count++;
}
}
}
ast_config_destroy(notify_types);
notify_types = ast_config_load(notify_config);
+ /* Done, tell the manager */
+ manager_event(EVENT_FLAG_SYSTEM, "ChannelReload", "Channel: SIP\r\nReloadReason: %s\r\nRegistry_Count: %d\r\nPeer_Count: %d\r\nUser_Count: %d\r\n\r\n", channelreloadreason2txt(reason), registry_count, peer_count, user_count);
+
return 0;
}
}
/*! \brief sip_do_reload: Reload module */
-static int sip_do_reload(void)
+static int sip_do_reload(enum channelreloadreason reason)
{
clear_realm_authentication(authl);
clear_sip_domains();
ASTOBJ_CONTAINER_DESTROYALL(&userl, sip_destroy_user);
ASTOBJ_CONTAINER_DESTROYALL(®l, sip_registry_destroy);
ASTOBJ_CONTAINER_MARKALL(&peerl);
- reload_config();
+ reload_config(reason);
/* Prune peers who still are supposed to be deleted */
ASTOBJ_CONTAINER_PRUNE_MARKED(&peerl, sip_destroy_peer);
ast_mutex_lock(&sip_reload_lock);
if (sip_reloading) {
ast_verbose("Previous SIP reload not yet done\n");
- } else
+ } else {
sip_reloading = 1;
+ if (fd)
+ sip_reloadreason = CHANNEL_CLI_RELOAD;
+ else
+ sip_reloadreason = CHANNEL_MODULE_RELOAD;
+ }
ast_mutex_unlock(&sip_reload_lock);
restart_monitor();
if (!io) {
ast_log(LOG_WARNING, "Unable to create I/O context\n");
}
-
- reload_config(); /* Load the configuration from sip.conf */
+ sip_reloadreason = CHANNEL_MODULE_LOAD;
+ reload_config(sip_reloadreason); /* Load the configuration from sip.conf */
/* Make sure we can register our sip channel type */
if (ast_channel_register(&sip_tech)) {