Skinny: tuple profile, device_name, device_instance is unique

This commit is contained in:
Mathieu Parent 2010-05-10 18:18:55 +02:00
parent bd6f7e73c0
commit 194e57268a
1 changed files with 13 additions and 1 deletions

View File

@ -1710,13 +1710,14 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r
switch_event_t *event = NULL;
switch_event_t *params = NULL;
switch_xml_t xroot, xdomain, xgroup, xuser, xskinny, xparams, xparam, xbuttons, xbutton;
listener_t *listener2 = NULL;
char *sql;
assert(listener->profile);
profile = listener->profile;
skinny_check_data_length(request, sizeof(request->data.reg));
if(!zstr(listener->device_name)) {
if (!zstr(listener->device_name)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"A device is already registred on this listener.\n");
send_register_reject(listener, "A device is already registred on this listener");
@ -1736,6 +1737,17 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r
goto end;
}
skinny_profile_find_listener_by_device_name_and_instance(listener->profile,
request->data.reg.device_name, request->data.reg.instance, &listener2);
if (listener2) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Device %s:%d is already registred on another listener.\n",
request->data.reg.device_name, request->data.reg.instance);
send_register_reject(listener, "Device is already registred on another listener");
status = SWITCH_STATUS_FALSE;
goto end;
}
if ((sql = switch_mprintf(
"INSERT INTO skinny_devices "
"(name, user_id, instance, ip, type, max_streams, codec_string) "