public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] bccmd patch, find connection handle by bdaddr
@ 2005-08-08 11:55 Ronny L Nilsson
  2005-08-08 17:32 ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: Ronny L Nilsson @ 2005-08-08 11:55 UTC (permalink / raw)
  To: bluez-devel

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]


Hi
I've got a whole bunch of little enhancement patches to the bccmd, 
pskey and l2ping utils. Marcel, as you wished earlier I'm posting them 
small and separate. The one attached makes bccmd able to find a ACL 
connection handle itself, instead of require user to provide it on 
commandline. I'm using it in a cmd_keylen() patch (which I post when 
this one gets applied).

Regards
/Ronny



[-- Attachment #2: bccmd-handle.diff --]
[-- Type: text/x-diff, Size: 1443 bytes --]

Index: utils/tools/bccmd.c
===================================================================
RCS file: /cvsroot/bluez/utils/tools/bccmd.c,v
retrieving revision 1.3
diff -u -p -r1.3 bccmd.c
--- utils/tools/bccmd.c	3 Jul 2005 13:13:17 -0000	1.3
+++ utils/tools/bccmd.c	8 Aug 2005 11:44:45 -0000
@@ -35,6 +35,7 @@
 #include <stdlib.h>
 #include <getopt.h>
 #include <sys/socket.h>
+#include <sys/ioctl.h>
 
 #include <bluetooth/bluetooth.h>
 #include <bluetooth/hci.h>
@@ -42,6 +43,41 @@
 
 #include "csr.h"
 
+
+//-------------------------------------------------------------
+// Finds the ACL handle (or -1 on error) for a
+// existing connection to remote <bdaddr>.
+//-------------------------------------------------------------
+int32_t find_conn_handle(int dd, bdaddr_t *bdaddr) {
+	struct hci_conn_info_req *conReq;
+	int32_t handle = -1;
+	
+	conReq = malloc(sizeof(struct hci_conn_info_req) + 
+		sizeof(struct hci_conn_info));
+	if(!conReq) {
+		perror("Can't get mem");
+		goto out;
+	}
+	
+	bacpy(&conReq->bdaddr, bdaddr);
+	conReq->type = ACL_LINK;
+	if (ioctl(dd, HCIGETCONNINFO, (unsigned long) conReq) < 0) {
+		perror("Couldn't get connection info");
+		goto out;
+	}
+	if(bacmp(bdaddr, &conReq->bdaddr)==0) {
+		handle=conReq->conn_info->handle;
+	} else {
+		fprintf(stderr, "Not connected");
+	}
+	
+out:
+	free(conReq);
+	return handle;
+}
+
+
+
 static int cmd_keylen(int dd, int argc, char *argv[])
 {
 	uint8_t buf[8];

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-08-16 15:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-08 11:55 [Bluez-devel] bccmd patch, find connection handle by bdaddr Ronny L Nilsson
2005-08-08 17:32 ` Marcel Holtmann
2005-08-09 14:36   ` Ronny L Nilsson
2005-08-16 15:28     ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox