From: Matthew Jordan <mjordan@digium.com>
Date: Thu, 17 Jan 2013 02:28:31 +0000
Subject: Fix issue where chan_mobile fails to bind to first available port
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-16357
Origin: http://svnview.digium.com/svn/asterisk?view=rev&rev=379342

Per the bluez API, in order to bind to the first available port, the rc_channel
field of the socket addressing structure used to bind the socket should be set
to 0. Previously, Asterisk had set the rc_channel field set to 1, causing it
to connect to whatever happens to be on port 1.

We could probably not explicitly set rc_channel to 0 since we memset the struct
earlier, but explicitly setting it will hopefully prevent someone from coming
in and setting it to some explicit port in the future.

---
 addons/chan_mobile.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/addons/chan_mobile.c
+++ b/addons/chan_mobile.c
@@ -1370,7 +1370,7 @@ static int rfcomm_connect(bdaddr_t src,
 	memset(&addr, 0, sizeof(addr));
 	addr.rc_family = AF_BLUETOOTH;
 	bacpy(&addr.rc_bdaddr, &src);
-	addr.rc_channel = (uint8_t) 1;
+	addr.rc_channel = (uint8_t) 0;
 	if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
 		ast_debug(1, "bind() failed (%d).\n", errno);
 		close(s);
