mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 18:40:46 +00:00
Cleanup unload calls
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1850 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -5330,6 +5330,33 @@ static struct ast_switch iax_switch =
|
|||||||
matchmore: iax_matchmore,
|
matchmore: iax_matchmore,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int __unload_module(void)
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
/* Cancel the network thread, close the net socket */
|
||||||
|
pthread_cancel(netthreadid);
|
||||||
|
pthread_join(netthreadid, NULL);
|
||||||
|
close(netsocket);
|
||||||
|
for (x=0;x<AST_IAX_MAX_CALLS;x++)
|
||||||
|
if (iaxs[x])
|
||||||
|
iax_destroy(x);
|
||||||
|
ast_manager_unregister( "IAXpeers" );
|
||||||
|
ast_cli_unregister(&cli_show_users);
|
||||||
|
ast_cli_unregister(&cli_show_channels);
|
||||||
|
ast_cli_unregister(&cli_show_peers);
|
||||||
|
ast_cli_unregister(&cli_set_jitter);
|
||||||
|
ast_cli_unregister(&cli_show_stats);
|
||||||
|
ast_cli_unregister(&cli_show_cache);
|
||||||
|
ast_unregister_switch(&iax_switch);
|
||||||
|
delete_users();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int unload_module()
|
||||||
|
{
|
||||||
|
return __unload_module();
|
||||||
|
}
|
||||||
|
|
||||||
int load_module(void)
|
int load_module(void)
|
||||||
{
|
{
|
||||||
char *config = "iax.conf";
|
char *config = "iax.conf";
|
||||||
@@ -5379,7 +5406,7 @@ int load_module(void)
|
|||||||
|
|
||||||
if (ast_channel_register(type, tdesc, iax_capability, iax_request)) {
|
if (ast_channel_register(type, tdesc, iax_capability, iax_request)) {
|
||||||
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
||||||
unload_module();
|
__unload_module();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5426,28 +5453,6 @@ char *description()
|
|||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int unload_module()
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
/* Cancel the network thread, close the net socket */
|
|
||||||
pthread_cancel(netthreadid);
|
|
||||||
pthread_join(netthreadid, NULL);
|
|
||||||
close(netsocket);
|
|
||||||
for (x=0;x<AST_IAX_MAX_CALLS;x++)
|
|
||||||
if (iaxs[x])
|
|
||||||
iax_destroy(x);
|
|
||||||
ast_manager_unregister( "IAXpeers" );
|
|
||||||
ast_cli_unregister(&cli_show_users);
|
|
||||||
ast_cli_unregister(&cli_show_channels);
|
|
||||||
ast_cli_unregister(&cli_show_peers);
|
|
||||||
ast_cli_unregister(&cli_set_jitter);
|
|
||||||
ast_cli_unregister(&cli_show_stats);
|
|
||||||
ast_cli_unregister(&cli_show_cache);
|
|
||||||
ast_unregister_switch(&iax_switch);
|
|
||||||
delete_users();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int usecount()
|
int usecount()
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
@@ -5986,6 +5986,33 @@ static struct ast_switch iax2_switch =
|
|||||||
matchmore: iax2_matchmore,
|
matchmore: iax2_matchmore,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int __unload_module(void)
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
/* Cancel the network thread, close the net socket */
|
||||||
|
pthread_cancel(netthreadid);
|
||||||
|
pthread_join(netthreadid, NULL);
|
||||||
|
close(netsocket);
|
||||||
|
for (x=0;x<IAX_MAX_CALLS;x++)
|
||||||
|
if (iaxs[x])
|
||||||
|
iax2_destroy(x);
|
||||||
|
ast_manager_unregister( "IAXpeers" );
|
||||||
|
ast_cli_unregister(&cli_show_users);
|
||||||
|
ast_cli_unregister(&cli_show_channels);
|
||||||
|
ast_cli_unregister(&cli_show_peers);
|
||||||
|
ast_cli_unregister(&cli_set_jitter);
|
||||||
|
ast_cli_unregister(&cli_show_stats);
|
||||||
|
ast_cli_unregister(&cli_show_cache);
|
||||||
|
ast_unregister_switch(&iax2_switch);
|
||||||
|
delete_users();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int unload_module()
|
||||||
|
{
|
||||||
|
return __unload_module();
|
||||||
|
}
|
||||||
|
|
||||||
int load_module(void)
|
int load_module(void)
|
||||||
{
|
{
|
||||||
char *config = "iax.conf";
|
char *config = "iax.conf";
|
||||||
@@ -6048,7 +6075,7 @@ int load_module(void)
|
|||||||
|
|
||||||
if (ast_channel_register(type, tdesc, iax2_capability, iax2_request)) {
|
if (ast_channel_register(type, tdesc, iax2_capability, iax2_request)) {
|
||||||
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
||||||
unload_module();
|
__unload_module();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6095,28 +6122,6 @@ char *description()
|
|||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int unload_module()
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
/* Cancel the network thread, close the net socket */
|
|
||||||
pthread_cancel(netthreadid);
|
|
||||||
pthread_join(netthreadid, NULL);
|
|
||||||
close(netsocket);
|
|
||||||
for (x=0;x<IAX_MAX_CALLS;x++)
|
|
||||||
if (iaxs[x])
|
|
||||||
iax2_destroy(x);
|
|
||||||
ast_manager_unregister( "IAXpeers" );
|
|
||||||
ast_cli_unregister(&cli_show_users);
|
|
||||||
ast_cli_unregister(&cli_show_channels);
|
|
||||||
ast_cli_unregister(&cli_show_peers);
|
|
||||||
ast_cli_unregister(&cli_set_jitter);
|
|
||||||
ast_cli_unregister(&cli_show_stats);
|
|
||||||
ast_cli_unregister(&cli_show_cache);
|
|
||||||
ast_unregister_switch(&iax2_switch);
|
|
||||||
delete_users();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int usecount()
|
int usecount()
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
@@ -840,97 +840,7 @@ static unsigned int get_group(char *s)
|
|||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
int load_module()
|
static int __unload_module(void)
|
||||||
{
|
|
||||||
struct ast_config *cfg;
|
|
||||||
struct ast_variable *v;
|
|
||||||
struct ast_modem_pvt *tmp;
|
|
||||||
char driver[80];
|
|
||||||
cfg = ast_load(config);
|
|
||||||
|
|
||||||
/* We *must* have a config file otherwise stop immediately */
|
|
||||||
if (!cfg) {
|
|
||||||
ast_log(LOG_ERROR, "Unable to load config %s\n", config);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (ast_mutex_lock(&iflock)) {
|
|
||||||
/* It's a little silly to lock it, but we mind as well just to be sure */
|
|
||||||
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
v = ast_variable_browse(cfg, "interfaces");
|
|
||||||
while(v) {
|
|
||||||
/* Create the interface list */
|
|
||||||
if (!strcasecmp(v->name, "device")) {
|
|
||||||
tmp = mkif(v->value);
|
|
||||||
if (tmp) {
|
|
||||||
tmp->next = iflist;
|
|
||||||
iflist = tmp;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
|
|
||||||
ast_destroy(cfg);
|
|
||||||
ast_mutex_unlock(&iflock);
|
|
||||||
unload_module();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else if (!strcasecmp(v->name, "driver")) {
|
|
||||||
snprintf(driver, sizeof(driver), "chan_modem_%s.so", v->value);
|
|
||||||
if (option_verbose > 1)
|
|
||||||
ast_verbose(VERBOSE_PREFIX_2 "Loading modem driver %s", driver);
|
|
||||||
|
|
||||||
if (ast_load_resource(driver)) {
|
|
||||||
ast_log(LOG_ERROR, "Failed to load driver %s\n", driver);
|
|
||||||
ast_destroy(cfg);
|
|
||||||
ast_mutex_unlock(&iflock);
|
|
||||||
unload_module();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else if (!strcasecmp(v->name, "mode")) {
|
|
||||||
if (!strncasecmp(v->value, "ri", 2))
|
|
||||||
gmode = MODEM_MODE_WAIT_RING;
|
|
||||||
else if (!strncasecmp(v->value, "im", 2))
|
|
||||||
gmode = MODEM_MODE_IMMEDIATE;
|
|
||||||
else if (!strncasecmp(v->value, "an", 2))
|
|
||||||
gmode = MODEM_MODE_WAIT_ANSWER;
|
|
||||||
else
|
|
||||||
ast_log(LOG_WARNING, "Unknown mode: %s\n", v->value);
|
|
||||||
} else if (!strcasecmp(v->name, "stripmsd")) {
|
|
||||||
stripmsd = atoi(v->value);
|
|
||||||
} else if (!strcasecmp(v->name, "type")) {
|
|
||||||
strncpy(mtype, v->value, sizeof(mtype)-1);
|
|
||||||
} else if (!strcasecmp(v->name, "initstr")) {
|
|
||||||
strncpy(initstr, v->value, sizeof(initstr)-1);
|
|
||||||
} else if (!strcasecmp(v->name, "dialtype")) {
|
|
||||||
dialtype = toupper(v->value[0]);
|
|
||||||
} else if (!strcasecmp(v->name, "context")) {
|
|
||||||
strncpy(context, v->value, sizeof(context)-1);
|
|
||||||
} else if (!strcasecmp(v->name, "msn")) {
|
|
||||||
strncpy(msn, v->value, sizeof(msn)-1);
|
|
||||||
} else if (!strcasecmp(v->name, "incomingmsn")) {
|
|
||||||
strncpy(incomingmsn, v->value, sizeof(incomingmsn)-1);
|
|
||||||
} else if (!strcasecmp(v->name, "language")) {
|
|
||||||
strncpy(language, v->value, sizeof(language)-1);
|
|
||||||
} else if (!strcasecmp(v->name, "group")) {
|
|
||||||
cur_group = get_group(v->value);
|
|
||||||
}
|
|
||||||
v = v->next;
|
|
||||||
}
|
|
||||||
ast_mutex_unlock(&iflock);
|
|
||||||
if (ast_channel_register(type, tdesc, /* XXX Don't know our types -- maybe we should register more than one XXX */
|
|
||||||
AST_FORMAT_SLINEAR, modem_request)) {
|
|
||||||
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
|
||||||
ast_destroy(cfg);
|
|
||||||
unload_module();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ast_destroy(cfg);
|
|
||||||
/* And start the monitor for the first time */
|
|
||||||
restart_monitor();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int unload_module()
|
|
||||||
{
|
{
|
||||||
struct ast_modem_pvt *p, *pl;
|
struct ast_modem_pvt *p, *pl;
|
||||||
/* First, take us out of the channel loop */
|
/* First, take us out of the channel loop */
|
||||||
@@ -983,6 +893,101 @@ int unload_module()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int unload_module()
|
||||||
|
{
|
||||||
|
return __unload_module();
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module()
|
||||||
|
{
|
||||||
|
struct ast_config *cfg;
|
||||||
|
struct ast_variable *v;
|
||||||
|
struct ast_modem_pvt *tmp;
|
||||||
|
char driver[80];
|
||||||
|
cfg = ast_load(config);
|
||||||
|
|
||||||
|
/* We *must* have a config file otherwise stop immediately */
|
||||||
|
if (!cfg) {
|
||||||
|
ast_log(LOG_ERROR, "Unable to load config %s\n", config);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (ast_mutex_lock(&iflock)) {
|
||||||
|
/* It's a little silly to lock it, but we mind as well just to be sure */
|
||||||
|
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
v = ast_variable_browse(cfg, "interfaces");
|
||||||
|
while(v) {
|
||||||
|
/* Create the interface list */
|
||||||
|
if (!strcasecmp(v->name, "device")) {
|
||||||
|
tmp = mkif(v->value);
|
||||||
|
if (tmp) {
|
||||||
|
tmp->next = iflist;
|
||||||
|
iflist = tmp;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
|
||||||
|
ast_destroy(cfg);
|
||||||
|
ast_mutex_unlock(&iflock);
|
||||||
|
__unload_module();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (!strcasecmp(v->name, "driver")) {
|
||||||
|
snprintf(driver, sizeof(driver), "chan_modem_%s.so", v->value);
|
||||||
|
if (option_verbose > 1)
|
||||||
|
ast_verbose(VERBOSE_PREFIX_2 "Loading modem driver %s", driver);
|
||||||
|
|
||||||
|
if (ast_load_resource(driver)) {
|
||||||
|
ast_log(LOG_ERROR, "Failed to load driver %s\n", driver);
|
||||||
|
ast_destroy(cfg);
|
||||||
|
ast_mutex_unlock(&iflock);
|
||||||
|
__unload_module();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (!strcasecmp(v->name, "mode")) {
|
||||||
|
if (!strncasecmp(v->value, "ri", 2))
|
||||||
|
gmode = MODEM_MODE_WAIT_RING;
|
||||||
|
else if (!strncasecmp(v->value, "im", 2))
|
||||||
|
gmode = MODEM_MODE_IMMEDIATE;
|
||||||
|
else if (!strncasecmp(v->value, "an", 2))
|
||||||
|
gmode = MODEM_MODE_WAIT_ANSWER;
|
||||||
|
else
|
||||||
|
ast_log(LOG_WARNING, "Unknown mode: %s\n", v->value);
|
||||||
|
} else if (!strcasecmp(v->name, "stripmsd")) {
|
||||||
|
stripmsd = atoi(v->value);
|
||||||
|
} else if (!strcasecmp(v->name, "type")) {
|
||||||
|
strncpy(mtype, v->value, sizeof(mtype)-1);
|
||||||
|
} else if (!strcasecmp(v->name, "initstr")) {
|
||||||
|
strncpy(initstr, v->value, sizeof(initstr)-1);
|
||||||
|
} else if (!strcasecmp(v->name, "dialtype")) {
|
||||||
|
dialtype = toupper(v->value[0]);
|
||||||
|
} else if (!strcasecmp(v->name, "context")) {
|
||||||
|
strncpy(context, v->value, sizeof(context)-1);
|
||||||
|
} else if (!strcasecmp(v->name, "msn")) {
|
||||||
|
strncpy(msn, v->value, sizeof(msn)-1);
|
||||||
|
} else if (!strcasecmp(v->name, "incomingmsn")) {
|
||||||
|
strncpy(incomingmsn, v->value, sizeof(incomingmsn)-1);
|
||||||
|
} else if (!strcasecmp(v->name, "language")) {
|
||||||
|
strncpy(language, v->value, sizeof(language)-1);
|
||||||
|
} else if (!strcasecmp(v->name, "group")) {
|
||||||
|
cur_group = get_group(v->value);
|
||||||
|
}
|
||||||
|
v = v->next;
|
||||||
|
}
|
||||||
|
ast_mutex_unlock(&iflock);
|
||||||
|
if (ast_channel_register(type, tdesc, /* XXX Don't know our types -- maybe we should register more than one XXX */
|
||||||
|
AST_FORMAT_SLINEAR, modem_request)) {
|
||||||
|
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
||||||
|
ast_destroy(cfg);
|
||||||
|
__unload_module();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ast_destroy(cfg);
|
||||||
|
/* And start the monitor for the first time */
|
||||||
|
restart_monitor();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int usecount(void)
|
int usecount(void)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
@@ -252,27 +252,30 @@ static struct ast_channel *nbs_request(char *type, int format, void *data)
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __unload_module(void)
|
||||||
|
{
|
||||||
|
/* First, take us out of the channel loop */
|
||||||
|
ast_channel_unregister(type);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
return __unload_module();
|
||||||
|
}
|
||||||
|
|
||||||
int load_module()
|
int load_module()
|
||||||
{
|
{
|
||||||
/* Make sure we can register our Adtranphone channel type */
|
/* Make sure we can register our Adtranphone channel type */
|
||||||
if (ast_channel_register(type, tdesc,
|
if (ast_channel_register(type, tdesc,
|
||||||
AST_FORMAT_SLINEAR, nbs_request)) {
|
AST_FORMAT_SLINEAR, nbs_request)) {
|
||||||
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
||||||
unload_module();
|
__unload_module();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int unload_module()
|
|
||||||
{
|
|
||||||
/* First, take us out of the channel loop */
|
|
||||||
ast_channel_unregister(type);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int usecount()
|
int usecount()
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
@@ -1051,103 +1051,7 @@ static int parse_gain_value(char *gain_type, char *value)
|
|||||||
return (int)gain;
|
return (int)gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
int load_module()
|
static int __unload_module(void)
|
||||||
{
|
|
||||||
struct ast_config *cfg;
|
|
||||||
struct ast_variable *v;
|
|
||||||
struct phone_pvt *tmp;
|
|
||||||
int mode = MODE_IMMEDIATE;
|
|
||||||
int txgain = DEFAULT_GAIN, rxgain = DEFAULT_GAIN; /* default gain 1.0 */
|
|
||||||
cfg = ast_load(config);
|
|
||||||
|
|
||||||
/* We *must* have a config file otherwise stop immediately */
|
|
||||||
if (!cfg) {
|
|
||||||
ast_log(LOG_ERROR, "Unable to load config %s\n", config);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (ast_mutex_lock(&iflock)) {
|
|
||||||
/* It's a little silly to lock it, but we mind as well just to be sure */
|
|
||||||
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
v = ast_variable_browse(cfg, "interfaces");
|
|
||||||
while(v) {
|
|
||||||
/* Create the interface list */
|
|
||||||
if (!strcasecmp(v->name, "device")) {
|
|
||||||
tmp = mkif(v->value, mode, txgain, rxgain);
|
|
||||||
if (tmp) {
|
|
||||||
tmp->next = iflist;
|
|
||||||
iflist = tmp;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
|
|
||||||
ast_destroy(cfg);
|
|
||||||
ast_mutex_unlock(&iflock);
|
|
||||||
unload_module();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else if (!strcasecmp(v->name, "silencesupression")) {
|
|
||||||
silencesupression = ast_true(v->value);
|
|
||||||
} else if (!strcasecmp(v->name, "language")) {
|
|
||||||
strncpy(language, v->value, sizeof(language)-1);
|
|
||||||
} else if (!strcasecmp(v->name, "callerid")) {
|
|
||||||
strncpy(callerid, v->value, sizeof(callerid)-1);
|
|
||||||
} else if (!strcasecmp(v->name, "mode")) {
|
|
||||||
if (!strncasecmp(v->value, "di", 2))
|
|
||||||
mode = MODE_DIALTONE;
|
|
||||||
else if (!strncasecmp(v->value, "im", 2))
|
|
||||||
mode = MODE_IMMEDIATE;
|
|
||||||
else if (!strncasecmp(v->value, "fx", 2))
|
|
||||||
mode = MODE_FXO;
|
|
||||||
else
|
|
||||||
ast_log(LOG_WARNING, "Unknown mode: %s\n", v->value);
|
|
||||||
} else if (!strcasecmp(v->name, "context")) {
|
|
||||||
strncpy(context, v->value, sizeof(context)-1);
|
|
||||||
} else if (!strcasecmp(v->name, "format")) {
|
|
||||||
if (!strcasecmp(v->value, "g723.1")) {
|
|
||||||
prefformat = AST_FORMAT_G723_1;
|
|
||||||
} else if (!strcasecmp(v->value, "slinear")) {
|
|
||||||
prefformat = AST_FORMAT_SLINEAR;
|
|
||||||
} else if (!strcasecmp(v->value, "ulaw")) {
|
|
||||||
prefformat = AST_FORMAT_ULAW;
|
|
||||||
} else
|
|
||||||
ast_log(LOG_WARNING, "Unknown format '%s'\n", v->value);
|
|
||||||
} else if (!strcasecmp(v->name, "echocancel")) {
|
|
||||||
if (!strcasecmp(v->value, "off")) {
|
|
||||||
echocancel = AEC_OFF;
|
|
||||||
} else if (!strcasecmp(v->value, "low")) {
|
|
||||||
echocancel = AEC_LOW;
|
|
||||||
} else if (!strcasecmp(v->value, "medium")) {
|
|
||||||
echocancel = AEC_MED;
|
|
||||||
} else if (!strcasecmp(v->value, "high")) {
|
|
||||||
echocancel = AEC_HIGH;
|
|
||||||
} else
|
|
||||||
ast_log(LOG_WARNING, "Unknown echo cancellation '%s'\n", v->value);
|
|
||||||
} else if (!strcasecmp(v->name, "txgain")) {
|
|
||||||
txgain = parse_gain_value(v->name, v->value);
|
|
||||||
} else if (!strcasecmp(v->name, "rxgain")) {
|
|
||||||
rxgain = parse_gain_value(v->name, v->value);
|
|
||||||
}
|
|
||||||
v = v->next;
|
|
||||||
}
|
|
||||||
ast_mutex_unlock(&iflock);
|
|
||||||
/* Make sure we can register our Adtranphone channel type */
|
|
||||||
if (ast_channel_register(type, tdesc,
|
|
||||||
AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, phone_request)) {
|
|
||||||
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
|
||||||
ast_destroy(cfg);
|
|
||||||
unload_module();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ast_destroy(cfg);
|
|
||||||
/* And start the monitor for the first time */
|
|
||||||
restart_monitor();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int unload_module()
|
|
||||||
{
|
{
|
||||||
struct phone_pvt *p, *pl;
|
struct phone_pvt *p, *pl;
|
||||||
/* First, take us out of the channel loop */
|
/* First, take us out of the channel loop */
|
||||||
@@ -1200,6 +1104,105 @@ int unload_module()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
return __unload_module();
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module()
|
||||||
|
{
|
||||||
|
struct ast_config *cfg;
|
||||||
|
struct ast_variable *v;
|
||||||
|
struct phone_pvt *tmp;
|
||||||
|
int mode = MODE_IMMEDIATE;
|
||||||
|
int txgain = DEFAULT_GAIN, rxgain = DEFAULT_GAIN; /* default gain 1.0 */
|
||||||
|
cfg = ast_load(config);
|
||||||
|
|
||||||
|
/* We *must* have a config file otherwise stop immediately */
|
||||||
|
if (!cfg) {
|
||||||
|
ast_log(LOG_ERROR, "Unable to load config %s\n", config);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (ast_mutex_lock(&iflock)) {
|
||||||
|
/* It's a little silly to lock it, but we mind as well just to be sure */
|
||||||
|
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
v = ast_variable_browse(cfg, "interfaces");
|
||||||
|
while(v) {
|
||||||
|
/* Create the interface list */
|
||||||
|
if (!strcasecmp(v->name, "device")) {
|
||||||
|
tmp = mkif(v->value, mode, txgain, rxgain);
|
||||||
|
if (tmp) {
|
||||||
|
tmp->next = iflist;
|
||||||
|
iflist = tmp;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
|
||||||
|
ast_destroy(cfg);
|
||||||
|
ast_mutex_unlock(&iflock);
|
||||||
|
__unload_module();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (!strcasecmp(v->name, "silencesupression")) {
|
||||||
|
silencesupression = ast_true(v->value);
|
||||||
|
} else if (!strcasecmp(v->name, "language")) {
|
||||||
|
strncpy(language, v->value, sizeof(language)-1);
|
||||||
|
} else if (!strcasecmp(v->name, "callerid")) {
|
||||||
|
strncpy(callerid, v->value, sizeof(callerid)-1);
|
||||||
|
} else if (!strcasecmp(v->name, "mode")) {
|
||||||
|
if (!strncasecmp(v->value, "di", 2))
|
||||||
|
mode = MODE_DIALTONE;
|
||||||
|
else if (!strncasecmp(v->value, "im", 2))
|
||||||
|
mode = MODE_IMMEDIATE;
|
||||||
|
else if (!strncasecmp(v->value, "fx", 2))
|
||||||
|
mode = MODE_FXO;
|
||||||
|
else
|
||||||
|
ast_log(LOG_WARNING, "Unknown mode: %s\n", v->value);
|
||||||
|
} else if (!strcasecmp(v->name, "context")) {
|
||||||
|
strncpy(context, v->value, sizeof(context)-1);
|
||||||
|
} else if (!strcasecmp(v->name, "format")) {
|
||||||
|
if (!strcasecmp(v->value, "g723.1")) {
|
||||||
|
prefformat = AST_FORMAT_G723_1;
|
||||||
|
} else if (!strcasecmp(v->value, "slinear")) {
|
||||||
|
prefformat = AST_FORMAT_SLINEAR;
|
||||||
|
} else if (!strcasecmp(v->value, "ulaw")) {
|
||||||
|
prefformat = AST_FORMAT_ULAW;
|
||||||
|
} else
|
||||||
|
ast_log(LOG_WARNING, "Unknown format '%s'\n", v->value);
|
||||||
|
} else if (!strcasecmp(v->name, "echocancel")) {
|
||||||
|
if (!strcasecmp(v->value, "off")) {
|
||||||
|
echocancel = AEC_OFF;
|
||||||
|
} else if (!strcasecmp(v->value, "low")) {
|
||||||
|
echocancel = AEC_LOW;
|
||||||
|
} else if (!strcasecmp(v->value, "medium")) {
|
||||||
|
echocancel = AEC_MED;
|
||||||
|
} else if (!strcasecmp(v->value, "high")) {
|
||||||
|
echocancel = AEC_HIGH;
|
||||||
|
} else
|
||||||
|
ast_log(LOG_WARNING, "Unknown echo cancellation '%s'\n", v->value);
|
||||||
|
} else if (!strcasecmp(v->name, "txgain")) {
|
||||||
|
txgain = parse_gain_value(v->name, v->value);
|
||||||
|
} else if (!strcasecmp(v->name, "rxgain")) {
|
||||||
|
rxgain = parse_gain_value(v->name, v->value);
|
||||||
|
}
|
||||||
|
v = v->next;
|
||||||
|
}
|
||||||
|
ast_mutex_unlock(&iflock);
|
||||||
|
/* Make sure we can register our Adtranphone channel type */
|
||||||
|
if (ast_channel_register(type, tdesc,
|
||||||
|
AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, phone_request)) {
|
||||||
|
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
||||||
|
ast_destroy(cfg);
|
||||||
|
__unload_module();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ast_destroy(cfg);
|
||||||
|
/* And start the monitor for the first time */
|
||||||
|
restart_monitor();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int usecount()
|
int usecount()
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
@@ -1136,61 +1136,7 @@ static struct ast_channel *vofr_request(char *type, int format, void *data)
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int load_module()
|
static int __unload_module(void)
|
||||||
{
|
|
||||||
struct ast_config *cfg;
|
|
||||||
struct ast_variable *v;
|
|
||||||
struct vofr_pvt *tmp;
|
|
||||||
cfg = ast_load(config);
|
|
||||||
|
|
||||||
/* We *must* have a config file otherwise stop immediately */
|
|
||||||
if (!cfg) {
|
|
||||||
ast_log(LOG_ERROR, "Unable to load config %s\n", config);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (ast_mutex_lock(&iflock)) {
|
|
||||||
/* It's a little silly to lock it, but we mind as well just to be sure */
|
|
||||||
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
v = ast_variable_browse(cfg, "interfaces");
|
|
||||||
while(v) {
|
|
||||||
/* Create the interface list */
|
|
||||||
if (!strcasecmp(v->name, "user") ||
|
|
||||||
!strcasecmp(v->name, "network")) {
|
|
||||||
tmp = mkif(v->name, v->value);
|
|
||||||
if (tmp) {
|
|
||||||
tmp->next = iflist;
|
|
||||||
iflist = tmp;
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
|
|
||||||
ast_destroy(cfg);
|
|
||||||
ast_mutex_unlock(&iflock);
|
|
||||||
unload_module();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else if (!strcasecmp(v->name, "context")) {
|
|
||||||
strncpy(context, v->value, sizeof(context)-1);
|
|
||||||
} else if (!strcasecmp(v->name, "language")) {
|
|
||||||
strncpy(language, v->value, sizeof(language)-1);
|
|
||||||
}
|
|
||||||
v = v->next;
|
|
||||||
}
|
|
||||||
ast_mutex_unlock(&iflock);
|
|
||||||
/* Make sure we can register our AdtranVoFR channel type */
|
|
||||||
if (ast_channel_register(type, tdesc, AST_FORMAT_G723_1, vofr_request)) {
|
|
||||||
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
|
||||||
ast_destroy(cfg);
|
|
||||||
unload_module();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ast_destroy(cfg);
|
|
||||||
/* And start the monitor for the first time */
|
|
||||||
restart_monitor();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int unload_module()
|
|
||||||
{
|
{
|
||||||
struct vofr_pvt *p, *pl;
|
struct vofr_pvt *p, *pl;
|
||||||
/* First, take us out of the channel loop */
|
/* First, take us out of the channel loop */
|
||||||
@@ -1244,6 +1190,65 @@ int unload_module()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int unload_module()
|
||||||
|
{
|
||||||
|
return __unload_module();
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_module()
|
||||||
|
{
|
||||||
|
struct ast_config *cfg;
|
||||||
|
struct ast_variable *v;
|
||||||
|
struct vofr_pvt *tmp;
|
||||||
|
cfg = ast_load(config);
|
||||||
|
|
||||||
|
/* We *must* have a config file otherwise stop immediately */
|
||||||
|
if (!cfg) {
|
||||||
|
ast_log(LOG_ERROR, "Unable to load config %s\n", config);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (ast_mutex_lock(&iflock)) {
|
||||||
|
/* It's a little silly to lock it, but we mind as well just to be sure */
|
||||||
|
ast_log(LOG_ERROR, "Unable to lock interface list???\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
v = ast_variable_browse(cfg, "interfaces");
|
||||||
|
while(v) {
|
||||||
|
/* Create the interface list */
|
||||||
|
if (!strcasecmp(v->name, "user") ||
|
||||||
|
!strcasecmp(v->name, "network")) {
|
||||||
|
tmp = mkif(v->name, v->value);
|
||||||
|
if (tmp) {
|
||||||
|
tmp->next = iflist;
|
||||||
|
iflist = tmp;
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
|
||||||
|
ast_destroy(cfg);
|
||||||
|
ast_mutex_unlock(&iflock);
|
||||||
|
__unload_module();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (!strcasecmp(v->name, "context")) {
|
||||||
|
strncpy(context, v->value, sizeof(context)-1);
|
||||||
|
} else if (!strcasecmp(v->name, "language")) {
|
||||||
|
strncpy(language, v->value, sizeof(language)-1);
|
||||||
|
}
|
||||||
|
v = v->next;
|
||||||
|
}
|
||||||
|
ast_mutex_unlock(&iflock);
|
||||||
|
/* Make sure we can register our AdtranVoFR channel type */
|
||||||
|
if (ast_channel_register(type, tdesc, AST_FORMAT_G723_1, vofr_request)) {
|
||||||
|
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
||||||
|
ast_destroy(cfg);
|
||||||
|
__unload_module();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ast_destroy(cfg);
|
||||||
|
/* And start the monitor for the first time */
|
||||||
|
restart_monitor();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int usecount()
|
int usecount()
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
@@ -1112,6 +1112,62 @@ static float parse_gain_value(char *gain_type, char *value)
|
|||||||
return gain;
|
return gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __unload_module(void)
|
||||||
|
{
|
||||||
|
struct vpb_pvt *p;
|
||||||
|
/* First, take us out of the channel loop */
|
||||||
|
ast_channel_unregister(type);
|
||||||
|
|
||||||
|
ast_mutex_lock(&iflock); {
|
||||||
|
/* Hangup all interfaces if they have an owner */
|
||||||
|
p = iflist;
|
||||||
|
while(p) {
|
||||||
|
if (p->owner)
|
||||||
|
ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
|
||||||
|
p = p->next;
|
||||||
|
}
|
||||||
|
iflist = NULL;
|
||||||
|
} ast_mutex_unlock(&iflock);
|
||||||
|
|
||||||
|
ast_mutex_lock(&monlock); {
|
||||||
|
if (mthreadactive > -1) {
|
||||||
|
pthread_cancel(monitor_thread);
|
||||||
|
pthread_join(monitor_thread, NULL);
|
||||||
|
}
|
||||||
|
mthreadactive = -2;
|
||||||
|
} ast_mutex_unlock(&monlock);
|
||||||
|
|
||||||
|
ast_mutex_lock(&iflock); {
|
||||||
|
/* Destroy all the interfaces and free their memory */
|
||||||
|
|
||||||
|
while(iflist) {
|
||||||
|
p = iflist;
|
||||||
|
ast_mutex_destroy(&p->lock);
|
||||||
|
pthread_cancel(p->readthread);
|
||||||
|
p->readthread = 0;
|
||||||
|
|
||||||
|
iflist = iflist->next;
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
iflist = NULL;
|
||||||
|
} ast_mutex_unlock(&iflock);
|
||||||
|
|
||||||
|
ast_mutex_lock(&bridge_lock); {
|
||||||
|
memset(bridges, 0, sizeof bridges);
|
||||||
|
} ast_mutex_unlock(&bridge_lock);
|
||||||
|
ast_mutex_destroy(&bridge_lock);
|
||||||
|
|
||||||
|
tcounter = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int unload_module(void)
|
||||||
|
{
|
||||||
|
return __unload_module();
|
||||||
|
}
|
||||||
|
|
||||||
int load_module()
|
int load_module()
|
||||||
{
|
{
|
||||||
struct ast_config *cfg;
|
struct ast_config *cfg;
|
||||||
@@ -1213,65 +1269,13 @@ int load_module()
|
|||||||
|
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
unload_module();
|
__unload_module();
|
||||||
else
|
else
|
||||||
restart_monitor(); /* And start the monitor for the first time */
|
restart_monitor(); /* And start the monitor for the first time */
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int unload_module()
|
|
||||||
{
|
|
||||||
struct vpb_pvt *p;
|
|
||||||
/* First, take us out of the channel loop */
|
|
||||||
ast_channel_unregister(type);
|
|
||||||
|
|
||||||
ast_mutex_lock(&iflock); {
|
|
||||||
/* Hangup all interfaces if they have an owner */
|
|
||||||
p = iflist;
|
|
||||||
while(p) {
|
|
||||||
if (p->owner)
|
|
||||||
ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
|
|
||||||
p = p->next;
|
|
||||||
}
|
|
||||||
iflist = NULL;
|
|
||||||
} ast_mutex_unlock(&iflock);
|
|
||||||
|
|
||||||
ast_mutex_lock(&monlock); {
|
|
||||||
if (mthreadactive > -1) {
|
|
||||||
pthread_cancel(monitor_thread);
|
|
||||||
pthread_join(monitor_thread, NULL);
|
|
||||||
}
|
|
||||||
mthreadactive = -2;
|
|
||||||
} ast_mutex_unlock(&monlock);
|
|
||||||
|
|
||||||
ast_mutex_lock(&iflock); {
|
|
||||||
/* Destroy all the interfaces and free their memory */
|
|
||||||
|
|
||||||
while(iflist) {
|
|
||||||
p = iflist;
|
|
||||||
ast_mutex_destroy(&p->lock);
|
|
||||||
pthread_cancel(p->readthread);
|
|
||||||
p->readthread = 0;
|
|
||||||
|
|
||||||
iflist = iflist->next;
|
|
||||||
|
|
||||||
free(p);
|
|
||||||
}
|
|
||||||
iflist = NULL;
|
|
||||||
} ast_mutex_unlock(&iflock);
|
|
||||||
|
|
||||||
ast_mutex_lock(&bridge_lock); {
|
|
||||||
memset(bridges, 0, sizeof bridges);
|
|
||||||
} ast_mutex_unlock(&bridge_lock);
|
|
||||||
ast_mutex_destroy(&bridge_lock);
|
|
||||||
|
|
||||||
tcounter = 0;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int usecount()
|
int usecount()
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
@@ -6914,7 +6914,7 @@ static int action_zapdialoffhook(struct mansession *s, struct message *m)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int zt_unload(void)
|
static int __unload_module(void)
|
||||||
{
|
{
|
||||||
struct zt_pvt *p, *pl;
|
struct zt_pvt *p, *pl;
|
||||||
/* First, take us out of the channel loop */
|
/* First, take us out of the channel loop */
|
||||||
@@ -6977,7 +6977,7 @@ static int zt_unload(void)
|
|||||||
|
|
||||||
int unload_module()
|
int unload_module()
|
||||||
{
|
{
|
||||||
return zt_unload();
|
return __unload_module();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int setup_zap(void)
|
static int setup_zap(void)
|
||||||
@@ -7016,7 +7016,7 @@ static int setup_zap(void)
|
|||||||
ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
|
ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n");
|
||||||
ast_destroy(cfg);
|
ast_destroy(cfg);
|
||||||
ast_mutex_unlock(&iflock);
|
ast_mutex_unlock(&iflock);
|
||||||
zt_unload();
|
__unload_module();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
c = v->value;
|
c = v->value;
|
||||||
@@ -7033,7 +7033,7 @@ static int setup_zap(void)
|
|||||||
ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
|
ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", v->value, chan);
|
||||||
ast_destroy(cfg);
|
ast_destroy(cfg);
|
||||||
ast_mutex_unlock(&iflock);
|
ast_mutex_unlock(&iflock);
|
||||||
zt_unload();
|
__unload_module();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (finish < start) {
|
if (finish < start) {
|
||||||
@@ -7051,7 +7051,7 @@ static int setup_zap(void)
|
|||||||
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
|
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
|
||||||
ast_destroy(cfg);
|
ast_destroy(cfg);
|
||||||
ast_mutex_unlock(&iflock);
|
ast_mutex_unlock(&iflock);
|
||||||
zt_unload();
|
__unload_module();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7293,7 +7293,7 @@ static int setup_zap(void)
|
|||||||
ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
|
ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value);
|
||||||
ast_destroy(cfg);
|
ast_destroy(cfg);
|
||||||
ast_mutex_unlock(&iflock);
|
ast_mutex_unlock(&iflock);
|
||||||
zt_unload();
|
__unload_module();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(v->name, "minunused")) {
|
} else if (!strcasecmp(v->name, "minunused")) {
|
||||||
@@ -7354,12 +7354,12 @@ int load_module(void)
|
|||||||
/* Make sure we can register our Zap channel type */
|
/* Make sure we can register our Zap channel type */
|
||||||
if (ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, zt_request)) {
|
if (ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, zt_request)) {
|
||||||
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
|
||||||
zt_unload();
|
__unload_module();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (ast_channel_register(typecompat, tdesc, AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, zt_request)) {
|
if (ast_channel_register(typecompat, tdesc, AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, zt_request)) {
|
||||||
ast_log(LOG_ERROR, "Unable to register channel class %s\n", typecompat);
|
ast_log(LOG_ERROR, "Unable to register channel class %s\n", typecompat);
|
||||||
zt_unload();
|
__unload_module();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef ZAPATA_PRI
|
#ifdef ZAPATA_PRI
|
||||||
|
Reference in New Issue
Block a user