From: Ronny L Nilsson <bb@arbetsmyra.dyndns.org>
To: bluez-devel@lists.sourceforge.net
Subject: [Bluez-devel] bccmd patch, find connection handle by bdaddr
Date: Mon, 8 Aug 2005 13:55:05 +0200 [thread overview]
Message-ID: <20050808115620.EEB243BF@arbetsmyra.dyndns.org> (raw)
[-- 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];
next reply other threads:[~2005-08-08 11:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-08 11:55 Ronny L Nilsson [this message]
2005-08-08 17:32 ` [Bluez-devel] bccmd patch, find connection handle by bdaddr Marcel Holtmann
2005-08-09 14:36 ` Ronny L Nilsson
2005-08-16 15:28 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050808115620.EEB243BF@arbetsmyra.dyndns.org \
--to=bb@arbetsmyra.dyndns.org \
--cc=bluez-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox