Revision
17513
Author
math.parent
Date
2010-05-10 11:19:58 -0500 (Mon, 10 May 2010)

Log Message

Skinny: tuple profile, device_name, device_instance is unique

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c (17512 => 17513)


--- freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c	2010-05-10 16:19:58 UTC (rev 17512)
+++ freeswitch/trunk/src/mod/endpoints/mod_skinny/skinny_protocol.c	2010-05-10 16:19:58 UTC (rev 17513)
@@ -1710,13 +1710,14 @@
 	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 @@
 		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) "