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 #include #include +#include #include #include @@ -42,6 +43,41 @@ #include "csr.h" + +//------------------------------------------------------------- +// Finds the ACL handle (or -1 on error) for a +// existing connection to remote . +//------------------------------------------------------------- +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];