Various small chan_skinny fixes and cleanup

Added test to skinny_register to only allow device to register against
a device that is not already registered.

Addback l->device test for skinny_show_lines. Fixes segfault if a line
is configured but not configured to a device. Reverses part of r368680.

Removed redundant l->device tests in subsubstate and dumpsub. l->device
will always be valid if these routines are called. Reverses 368948 -
discussed with mjordan on irc.

Some indentation cleanup.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369034 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Damien Wedhorn
2012-06-15 21:18:56 +00:00
parent bf6ef69702
commit 3d38998b70

View File

@@ -2084,7 +2084,7 @@ static int skinny_register(struct skinny_req *req, struct skinnysession *s)
AST_LIST_TRAVERSE(&devices, d, list){ AST_LIST_TRAVERSE(&devices, d, list){
struct ast_sockaddr addr; struct ast_sockaddr addr;
ast_sockaddr_from_sin(&addr, &s->sin); ast_sockaddr_from_sin(&addr, &s->sin);
if (!strcasecmp(req->data.reg.name, d->id) if (!d->session && !strcasecmp(req->data.reg.name, d->id)
&& ast_apply_ha(d->ha, &addr)) { && ast_apply_ha(d->ha, &addr)) {
s->device = d; s->device = d;
d->type = letohl(req->data.reg.type); d->type = letohl(req->data.reg.type);
@@ -2109,25 +2109,24 @@ static int skinny_register(struct skinny_req *req, struct skinnysession *s)
instance++; instance++;
} }
AST_LIST_TRAVERSE(&d->lines, l, list) { AST_LIST_TRAVERSE(&d->lines, l, list) {
/* FIXME: All sorts of issues will occur if this line is already connected to a device */ ast_format_cap_joint_copy(l->confcap, d->cap, l->cap);
ast_format_cap_joint_copy(l->confcap, d->cap, l->cap); l->prefs = l->confprefs;
l->prefs = l->confprefs; if (!l->prefs.order[0]) {
if (!l->prefs.order[0]) { l->prefs = d->confprefs;
l->prefs = d->confprefs; }
} /* l->capability = d->capability;
/* l->capability = d->capability; l->prefs = d->prefs; */
l->prefs = d->prefs; */ l->instance = instance;
l->instance = instance; l->newmsgs = ast_app_has_voicemail(l->mailbox, NULL);
l->newmsgs = ast_app_has_voicemail(l->mailbox, NULL); set_callforwards(l, NULL, 0);
set_callforwards(l, NULL, 0); manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: Skinny\r\nPeer: Skinny/%s@%s\r\nPeerStatus: Registered\r\n", l->name, d->name);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: Skinny\r\nPeer: Skinny/%s@%s\r\nPeerStatus: Registered\r\n", l->name, d->name); register_exten(l);
register_exten(l); /* initialize MWI on line and device */
/* initialize MWI on line and device */ mwi_event_cb(0, l);
mwi_event_cb(0, l); AST_LIST_TRAVERSE(&l->sublines, subline, list) {
AST_LIST_TRAVERSE(&l->sublines, subline, list) { ast_extension_state_add(subline->context, subline->exten, skinny_extensionstate_cb, subline->container);
ast_extension_state_add(subline->context, subline->exten, skinny_extensionstate_cb, subline->container); }
} ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Skinny/%s", l->name);
ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Skinny/%s", l->name);
--instance; --instance;
} }
break; break;
@@ -3856,7 +3855,7 @@ static char *_skinny_show_lines(int fd, int *total, struct mansession *s, const
if (!s) { if (!s) {
ast_cli(fd, "%-20s %-20s %8d %-20s\n", ast_cli(fd, "%-20s %-20s %8d %-20s\n",
l->name, l->name,
l->device->name, (l->device ? l->device->name : "Not connected"),
l->instance, l->instance,
l->label); l->label);
if (verbose) { if (verbose) {
@@ -3879,7 +3878,7 @@ static char *_skinny_show_lines(int fd, int *total, struct mansession *s, const
"Label: %s\r\n", "Label: %s\r\n",
idtext, idtext,
l->name, l->name,
l->device->name, (l->device ? l->device->name : "None"),
l->instance, l->instance,
l->label); l->label);
} }
@@ -5011,11 +5010,6 @@ static void setsubstate(struct skinny_subchannel *sub, int state)
pthread_t t; pthread_t t;
int actualstate = state; int actualstate = state;
if (!l->device) {
ast_log(LOG_WARNING, "Device for line %s is not registered.\n", l->name);
return;
}
if (sub->substate == SUBSTATE_ONHOOK) { if (sub->substate == SUBSTATE_ONHOOK) {
return; return;
} }
@@ -5408,11 +5402,6 @@ static void dumpsub(struct skinny_subchannel *sub, int forcehangup)
struct skinny_subchannel *activate_sub = NULL; struct skinny_subchannel *activate_sub = NULL;
struct skinny_subchannel *tsub; struct skinny_subchannel *tsub;
if (!l->device) {
ast_log(LOG_WARNING, "Device for line %s is not registered.\n", l->name);
return;
}
if (skinnydebug) { if (skinnydebug) {
ast_verb(3, "Sub %d - Dumping\n", sub->callid); ast_verb(3, "Sub %d - Dumping\n", sub->callid);
} }