* Re: [PATCH] BT_SECURITY_HIGH requires 16 digit pin code
From: Johan Hedberg @ 2010-09-02 13:51 UTC (permalink / raw)
To: Waldemar.Rymarkiewicz
Cc: hadess, linux-bluetooth, par-gunnar.p.hjalmdahl, joakim.xj.ceder,
arunkr.singh
In-Reply-To: <99B09243E1A5DA4898CDD8B7001114480979219655@EXMB04.eu.tieto.com>
Hi Waldek,
On Thu, Sep 02, 2010, Waldemar.Rymarkiewicz@tieto.com wrote:
> I've completed more tests on the patches and didn't faced any problems
> do far. Legacy paring, ssp, sec mode 3, refresh existing keys and
> security upgrading have finished with success. I did the tests for
> bluez as initiator and again when bluez was an acceptor. All tests
> were done against different controllers CSR (1.1, 2.0, 2.1), Broadcom
> (2.0, 2.1), ST-Ericsson (2.1). I also tried different combinations of
> the controllers in the same use case.
>
> So, I'm pretty sure that it will not introduce any regression.
Ok, that's good to hear.
> Aditionally, we plan to bring this to the UPF and it would be
> appreciated if also other would have that possibility for regression
> testing.
I'll be at the UPF too, so this might be possible.
> If it comes to interaction with the agent I would do this in a
> seperate patch which will contain a new property when 16 digit pin
> code is required.
That's fine.
> I attached slightly updated patches.
Thanks. However, the kernel patch and new ioctl will need comments at
least from Marcel. Once we add an ioctl we're stuck with it for quite
some time and have to maintain it, no matter what kind of newer/better
kernel-userspace interfaces we come up with. So the choice of accepting
a new ioctl isn't so easy.
One thing that you'd definitely need to fix in your patches is to keep
at least the same level of support that the current BlueZ has with
kernels that don't have the new ioctl. Right now your patch would make
legacy pairing fail in such cases which is not acceptable. Only with a
major version change (5.x) would it be possible to consider requiring a
newer kernel version in order to have essential functionality in place.
With all this in mind I'd still prefer it if we postpone the feature
addition until the point where we have a more flexible kernel-userspace
API in place and most of the security logic and information on the
kernel side.
Johan
^ permalink raw reply
* RE: [PATCH] BT_SECURITY_HIGH requires 16 digit pin code
From: Waldemar.Rymarkiewicz @ 2010-09-02 13:27 UTC (permalink / raw)
To: johan.hedberg
Cc: hadess, linux-bluetooth, par-gunnar.p.hjalmdahl, joakim.xj.ceder,
arunkr.singh
In-Reply-To: <20100827124524.GA9484@jh-x301>
[-- Attachment #1: Type: text/plain, Size: 2150 bytes --]
Johan,
>From: Johan Hedberg [mailto:johan.hedberg@gmail.com]
>Sent: Friday, August 27, 2010 2:45 PM
>So how well have you tested the patches? I.e. how confident
>are you that you're not introducing any regressions? Scenarios
>that would need to be tested before an upstream merge are (and
>I'm probably forgetting several of them):
>
>- legacy pairing acceptor & initiator
>- security mode 3 acceptor & initiator
>- ssp acceptor & initiator
>- renewed link key handling for both debug and normal keys
>- security level upgrading (i.e. connect first to a low security socket
> and then over the same ACL to a higher security socket)
>- complete and partial failure scenarios for all of the above
I've completed more tests on the patches and didn't faced any problems do far.
Legacy paring, ssp, sec mode 3, refresh existing keys and security upgrading have finished with success. I did the tests for bluez as initiator and again when bluez was an acceptor. All tests were done against different controllers CSR (1.1, 2.0, 2.1), Broadcom (2.0, 2.1), ST-Ericsson (2.1). I also tried different combinations of the controllers in the same use case.
So, I'm pretty sure that it will not introduce any regression.
>Additionally all these test should be done against several
>different controllers due to differences in HCI interface
>behavior (event ordering, error codes, etc). In that list I'd
>include at least one CSR, and one Broadcom adapter and any
>other adapters from other manufacturers that you can get hold of.
>
>So how many of these tests do you already have covered? I'm
>not very comfortable with pushing the patches upstream before
>most of the above scenarios have been tested and verified not
>to introduce any regressions.
>
Aditionally, we plan to bring this to the UPF and it would be appreciated if also other would have that possibility for regression testing.
If it comes to interaction with the agent I would do this in a seperate patch which will contain a new property when 16 digit pin code is required.
I attached slightly updated patches.
Regards,
/Waldek
[-- Attachment #2: 0001-BT_SECURITY_HIGH-requires-16-digit-pin-code.patch --]
[-- Type: application/octet-stream, Size: 6043 bytes --]
From 7c1eeda7c1aa5e19c310e965be192f124df7c6fd Mon Sep 17 00:00:00 2001
From: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Date: Mon, 21 Jun 2010 18:53:51 +0200
Subject: [PATCH] BT_SECURITY_HIGH requires 16 digit pin code
The security level BT_SECURITY_HIGH expects secure connection
and a minimum 16 digit pin code used for bonding. It's required by the
Sim Access Profile.
Patch on behalf of ST-Ericsson SA.
Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
---
lib/hci.h | 8 +++++++-
src/dbus-hci.c | 32 +++++++++++++++++++++++++++-----
src/security.c | 39 +++++++++++++++++++++++++++++++++++----
3 files changed, 69 insertions(+), 10 deletions(-)
diff --git a/lib/hci.h b/lib/hci.h
index 512dab9..a313929 100644
--- a/lib/hci.h
+++ b/lib/hci.h
@@ -96,7 +96,7 @@ enum {
#define HCISETLINKMODE _IOW('H', 226, int)
#define HCISETACLMTU _IOW('H', 227, int)
#define HCISETSCOMTU _IOW('H', 228, int)
-
+#define HCISETCONNINFO _IOW('H', 229, int)
#define HCIBLOCKADDR _IOW('H', 230, int)
#define HCIUNBLOCKADDR _IOW('H', 231, int)
@@ -2326,9 +2326,15 @@ struct hci_conn_info_req {
struct hci_conn_info conn_info[0];
};
+struct hci_set_conn_info_req {
+ bdaddr_t bdaddr;
+ uint8_t pin_len;
+ uint8_t key_type;
+};
struct hci_auth_info_req {
bdaddr_t bdaddr;
uint8_t type;
+ uint8_t level;
};
struct hci_inquiry_req {
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index 9055ffe..fe38e45 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -165,6 +165,8 @@ static void pincode_cb(struct agent *agent, DBusError *err,
{
struct btd_adapter *adapter = device_get_adapter(device);
pin_code_reply_cp pr;
+ struct hci_auth_info_req ar;
+ struct hci_set_conn_info_req cr;
bdaddr_t sba, dba;
size_t len;
int dev;
@@ -180,13 +182,29 @@ static void pincode_cb(struct agent *agent, DBusError *err,
adapter_get_address(adapter, &sba);
device_get_address(device, &dba);
- if (err) {
- hci_send_cmd(dev, OGF_LINK_CTL,
- OCF_PIN_CODE_NEG_REPLY, 6, &dba);
- goto done;
- }
+ if (err)
+ goto reject;
len = strlen(pincode);
+ memset(&ar, 0, sizeof(ar));
+ bacpy(&ar.bdaddr, &dba);
+ if (ioctl(dev, HCIGETAUTHINFO, (unsigned long) &ar) < 0) {
+ error("Can't get auth info: %s (%d)", strerror(errno), errno);
+ goto reject;
+ }
+
+ if (ar.level == BT_SECURITY_HIGH && len < 16) {
+ error("PIN code is not a 16 digit (%d).", len);
+ goto reject;
+ }
+
+ bacpy(&cr.bdaddr, &dba);
+ cr.pin_len = len;
+ cr.key_type = 0xff;
+ if (ioctl(dev, HCISETCONNINFO, (unsigned long) &cr) < 0) {
+ error("Can't set conn info: %s (%d)", strerror(errno), errno);
+ goto reject;
+ }
set_pin_length(&sba, len);
@@ -196,7 +214,11 @@ static void pincode_cb(struct agent *agent, DBusError *err,
pr.pin_len = len;
hci_send_cmd(dev, OGF_LINK_CTL, OCF_PIN_CODE_REPLY,
PIN_CODE_REPLY_CP_SIZE, &pr);
+ goto done;
+reject:
+ hci_send_cmd(dev, OGF_LINK_CTL,
+ OCF_PIN_CODE_NEG_REPLY, 6, &dba);
done:
hci_close_dev(dev);
}
diff --git a/src/security.c b/src/security.c
index 667f1f1..a4eedc2 100644
--- a/src/security.c
+++ b/src/security.c
@@ -309,6 +309,7 @@ static void link_key_request(int dev, bdaddr_t *sba, bdaddr_t *dba)
char sa[18], da[18];
uint8_t type;
int err;
+ int pinlen;
if (!get_adapter_and_device(sba, dba, &adapter, &device, FALSE))
device = NULL;
@@ -325,9 +326,11 @@ static void link_key_request(int dev, bdaddr_t *sba, bdaddr_t *dba)
DBG("HCIGETAUTHINFO failed %s (%d)",
strerror(errno), errno);
req.type = 0x00;
+ req.level = BT_SECURITY_LOW;
}
- DBG("kernel auth requirements = 0x%02x", req.type);
+ DBG("kernel auth requirements = 0x%02x and security level = 0x%02x", \
+ req.type, req.level);
if (main_opts.debug_keys && device && device_get_debug_key(device, key))
type = 0x03;
@@ -341,18 +344,35 @@ static void link_key_request(int dev, bdaddr_t *sba, bdaddr_t *dba)
DBG("link key type = 0x%02x", type);
+ pinlen = read_pin_length(sba, dba);
+ DBG("stored link key type = 0x%02x pin_len = %d", type, pinlen);
+
/* Don't use unauthenticated combination keys if MITM is
- * required */
- if (type == 0x04 && req.type != 0xff && (req.type & 0x01))
+ * required and also don't use combination link keys authenticated
+ * with the PIN code len < 16 if security level BT_SECURITY_HIGH
+ * is required */
+ if ((type == 0x04 && req.type != 0xff && (req.type & 0x01)) ||
+ (type == 0x00 && req.level == BT_SECURITY_HIGH && pinlen < 16))
hci_send_cmd(dev, OGF_LINK_CTL, OCF_LINK_KEY_NEG_REPLY,
6, dba);
else {
link_key_reply_cp lr;
+ struct hci_set_conn_info_req cr;
memcpy(lr.link_key, key, 16);
bacpy(&lr.bdaddr, dba);
- hci_send_cmd(dev, OGF_LINK_CTL, OCF_LINK_KEY_REPLY,
+ bacpy(&cr.bdaddr, dba);
+ cr.pin_len = pinlen;
+ cr.key_type = type;
+
+ if (ioctl(dev, HCISETCONNINFO, (unsigned long) &cr) < 0) {
+ error("Can't set conn info: %s (%d)", strerror(errno),
+ errno);
+ hci_send_cmd(dev, OGF_LINK_CTL, OCF_LINK_KEY_NEG_REPLY,
+ 6, dba);
+ } else
+ hci_send_cmd(dev, OGF_LINK_CTL, OCF_LINK_KEY_REPLY,
LINK_KEY_REPLY_CP_SIZE, &lr);
}
}
@@ -523,6 +543,7 @@ static void pin_code_request(int dev, bdaddr_t *sba, bdaddr_t *dba)
pin_code_reply_cp pr;
struct hci_conn_info_req *cr;
struct hci_conn_info *ci;
+ struct hci_auth_info_req ar;
char sa[18], da[18], pin[17];
int pinlen;
@@ -542,10 +563,20 @@ static void pin_code_request(int dev, bdaddr_t *sba, bdaddr_t *dba)
}
ci = cr->conn_info;
+ memset(&ar, 0, sizeof(ar));
+ bacpy(&ar.bdaddr, dba);
+ if (ioctl(dev, HCIGETAUTHINFO, (unsigned long) &ar) < 0) {
+ error("Can't get auth info: %s (%d)", strerror(errno), errno);
+ goto reject;
+ }
memset(pin, 0, sizeof(pin));
pinlen = read_pin_code(sba, dba, pin);
if (pinlen > 0) {
+ if (ar.level == BT_SECURITY_HIGH && pinlen < 16) {
+ error("Not 16 digit pin code.");
+ goto reject;
+ }
set_pin_length(sba, pinlen);
memcpy(pr.pin_code, pin, pinlen);
pr.pin_len = pinlen;
--
1.7.0.4
[-- Attachment #3: 0001-Bluetooth-BT_SECURITY_HIGH-requires-16-digit-pin-cod.patch --]
[-- Type: application/octet-stream, Size: 9554 bytes --]
From acc1dd35f7fd6f9d24c328aef244365ef6716382 Mon Sep 17 00:00:00 2001
From: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Date: Wed, 25 Aug 2010 17:48:32 +0200
Subject: [PATCH] Bluetooth: BT_SECURITY_HIGH requires 16 digit pin code
The security level BT_SECURITY_HIGH expects secure connection
and a minimum 16 digit pin code used for bonding. It's required by the
Sim Access Profile.
Patch on behalf of ST-Ericsson SA.
Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
---
include/net/bluetooth/hci.h | 17 +++++++
include/net/bluetooth/hci_core.h | 4 ++
net/bluetooth/hci_conn.c | 97 +++++++++++++++++++++++++++++++-------
net/bluetooth/hci_event.c | 4 ++
net/bluetooth/hci_sock.c | 3 +
net/bluetooth/rfcomm/core.c | 10 ++++-
6 files changed, 116 insertions(+), 19 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index bcbdd6d..32a33c0 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -99,6 +99,7 @@ enum {
#define HCISETLINKMODE _IOW('H', 226, int)
#define HCISETACLMTU _IOW('H', 227, int)
#define HCISETSCOMTU _IOW('H', 228, int)
+#define HCISETCONNINFO _IOW('H', 229, int)
#define HCIBLOCKADDR _IOW('H', 230, int)
#define HCIUNBLOCKADDR _IOW('H', 231, int)
@@ -224,6 +225,15 @@ enum {
#define HCI_AT_GENERAL_BONDING 0x04
#define HCI_AT_GENERAL_BONDING_MITM 0x05
+/* Link Key types */
+#define HCI_LK_COMBINATION 0x00
+#define HCI_LK_LOCAL_UNIT 0x01
+#define HCI_LK_REMOTE_UNIT 0x02
+#define HCI_LK_DEBUG_COMBINATION 0x03
+#define HCI_LK_UNAUTHENTICATED_COMBINATION 0x04
+#define HCI_LK_AUTHENTICATED_COMBINATION 0x05
+#define HCI_LK_CHANGEED_COMBINATION_KEY 0x06
+
/* ----- HCI Commands ---- */
#define HCI_OP_INQUIRY 0x0401
struct hci_cp_inquiry {
@@ -1022,9 +1032,16 @@ struct hci_conn_info_req {
struct hci_conn_info conn_info[0];
};
+struct hci_set_conn_info_req {
+ bdaddr_t bdaddr;
+ __u8 pin_len;
+ __u8 key_type;
+};
+
struct hci_auth_info_req {
bdaddr_t bdaddr;
__u8 type;
+ __u8 level;
};
struct hci_inquiry_req {
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 4568b93..9eb2da3 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -183,6 +183,8 @@ struct hci_conn {
__u32 link_mode;
__u8 auth_type;
__u8 sec_level;
+ __u8 key_type;
+ __u8 pin_len;
__u8 power_save;
__u16 disc_timeout;
unsigned long pend;
@@ -430,6 +432,8 @@ int hci_get_dev_info(void __user *arg);
int hci_get_conn_list(void __user *arg);
int hci_get_conn_info(struct hci_dev *hdev, void __user *arg);
int hci_get_auth_info(struct hci_dev *hdev, void __user *arg);
+int hci_set_conn_info(struct hci_dev *hdev, void __user *arg);
+
int hci_inquiry(void __user *arg);
struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr);
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 0b1e460..54709fa 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -233,6 +233,8 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
conn->mode = HCI_CM_ACTIVE;
conn->state = BT_OPEN;
conn->auth_type = HCI_AT_GENERAL_BONDING;
+ conn->key_type = 0xff;
+ conn->pin_len = 0;
conn->power_save = 1;
conn->disc_timeout = HCI_DISCONN_TIMEOUT;
@@ -433,15 +435,11 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
EXPORT_SYMBOL(hci_conn_check_link_mode);
/* Authenticate remote device */
-static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
+static void hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
{
BT_DBG("conn %p", conn);
- if (sec_level > conn->sec_level)
- conn->sec_level = sec_level;
- else if (conn->link_mode & HCI_LM_AUTH)
- return 1;
-
+ conn->sec_level = sec_level;
conn->auth_type = auth_type;
if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
@@ -450,8 +448,20 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED,
sizeof(cp), &cp);
}
+}
- return 0;
+/* Encrypt the the link */
+static void hci_conn_encrypt(struct hci_conn *conn)
+{
+ BT_DBG("conn %p", conn);
+
+ if (!test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) {
+ struct hci_cp_set_conn_encrypt cp;
+ cp.handle = cpu_to_le16(conn->handle);
+ cp.encrypt = 1;
+ hci_send_cmd(conn->hdev, HCI_OP_SET_CONN_ENCRYPT,
+ sizeof(cp), &cp);
+ }
}
/* Enable security */
@@ -459,28 +469,54 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
{
BT_DBG("conn %p", conn);
+ /* For sdp we do not need the link key. */
if (sec_level == BT_SECURITY_SDP)
return 1;
+ /* For non 2.1 devices and low security level we do not need the
+ link key. */
if (sec_level == BT_SECURITY_LOW &&
(!conn->ssp_mode || !conn->hdev->ssp_mode))
return 1;
- if (conn->link_mode & HCI_LM_ENCRYPT)
- return hci_conn_auth(conn, sec_level, auth_type);
-
+ /* For other security levels we need link key. */
+ if (!(conn->link_mode & HCI_LM_AUTH))
+ goto do_auth;
+
+ /* An authenticated combination key has sufficient security for any
+ security level. */
+ if (conn->key_type == HCI_LK_AUTHENTICATED_COMBINATION)
+ goto do_encrypt;
+
+ /* An unauthenticated combination key has sufficient security for
+ security level 1 and 2. */
+ if (conn->key_type == HCI_LK_UNAUTHENTICATED_COMBINATION
+ && (sec_level == BT_SECURITY_MEDIUM
+ || sec_level == BT_SECURITY_LOW))
+ goto do_encrypt;
+
+ /* A combination key has always sufficient security for the security
+ levels 1 or 2. High security level requires that the combination key
+ was generated using the maximum PIN code length (16).
+ For pre 2.1 units. */
+ if ((conn->key_type == HCI_LK_COMBINATION))
+ if ((sec_level != BT_SECURITY_HIGH) || (conn->pin_len >= 16))
+ goto do_encrypt;
+
+do_auth:
if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend))
return 0;
- if (hci_conn_auth(conn, sec_level, auth_type)) {
- struct hci_cp_set_conn_encrypt cp;
- cp.handle = cpu_to_le16(conn->handle);
- cp.encrypt = 1;
- hci_send_cmd(conn->hdev, HCI_OP_SET_CONN_ENCRYPT,
- sizeof(cp), &cp);
- }
-
+ hci_conn_auth(conn, sec_level, auth_type);
return 0;
+
+do_encrypt:
+ if (conn->link_mode & HCI_LM_ENCRYPT)
+ return 1; /* sufficient link key */
+ else{
+ hci_conn_encrypt(conn);
+ return 0; /* auth pending */
+ }
}
EXPORT_SYMBOL(hci_conn_security);
@@ -713,6 +749,30 @@ int hci_get_conn_info(struct hci_dev *hdev, void __user *arg)
return copy_to_user(ptr, &ci, sizeof(ci)) ? -EFAULT : 0;
}
+int hci_set_conn_info(struct hci_dev *hdev, void __user *arg)
+{
+ struct hci_set_conn_info_req req;
+ struct hci_conn *conn;
+
+ if (copy_from_user(&req, arg, sizeof(req))) {
+ BT_DBG("copy from user failed");
+ return -EFAULT;
+ }
+
+ hci_dev_lock_bh(hdev);
+ conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &req.bdaddr);
+ if (conn) {
+ conn->pin_len = req.pin_len;
+ conn->key_type = req.key_type;
+ }
+ hci_dev_unlock_bh(hdev);
+
+ if (!conn)
+ return -ENOENT;
+
+ return 0;
+}
+
int hci_get_auth_info(struct hci_dev *hdev, void __user *arg)
{
struct hci_auth_info_req req;
@@ -725,6 +785,7 @@ int hci_get_auth_info(struct hci_dev *hdev, void __user *arg)
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &req.bdaddr);
if (conn)
req.type = conn->auth_type;
+ req.level = conn->sec_level;
hci_dev_unlock_bh(hdev);
if (!conn)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index bfef5ba..6d6b04c 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1521,6 +1521,10 @@ static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
if (conn) {
hci_conn_hold(conn);
+ /* For Changed Combination Link Key the only link key has
+ * been changed, not link key type. */
+ if (conn->key_type != HCI_LK_CHANGEED_COMBINATION_KEY)
+ conn->key_type = ev->key_type;
conn->disc_timeout = HCI_DISCONN_TIMEOUT;
hci_conn_put(conn);
}
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 83acd16..502a7b0 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -269,6 +269,9 @@ static inline int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, unsign
case HCIGETCONNINFO:
return hci_get_conn_info(hdev, (void __user *) arg);
+ case HCISETCONNINFO:
+ return hci_set_conn_info(hdev, (void __user *) arg);
+
case HCIGETAUTHINFO:
return hci_get_auth_info(hdev, (void __user *) arg);
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 7dca91b..2e248d5 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -2086,7 +2086,15 @@ static void rfcomm_security_cfm(struct hci_conn *conn, u8 status, u8 encrypt)
continue;
if (!status)
- set_bit(RFCOMM_AUTH_ACCEPT, &d->flags);
+ if (d->sec_level != BT_SECURITY_HIGH)
+ set_bit(RFCOMM_AUTH_ACCEPT, &d->flags);
+ else
+ if ((conn->key_type == HCI_LK_AUTHENTICATED_COMBINATION)
+ || (conn->key_type == HCI_LK_COMBINATION
+ && conn->pin_len >= 16))
+ set_bit(RFCOMM_AUTH_ACCEPT, &d->flags);
+ else
+ set_bit(RFCOMM_AUTH_REJECT, &d->flags);
else
set_bit(RFCOMM_AUTH_REJECT, &d->flags);
}
--
1.7.0.4
^ permalink raw reply related
* Re: AVRCP future
From: Luiz Augusto von Dentz @ 2010-09-02 12:56 UTC (permalink / raw)
To: Sander van Grieken; +Cc: Johan Hedberg, linux-bluetooth
In-Reply-To: <201009021020.50162.sander@outrightsolutions.nl>
Hi,
On Thu, Sep 2, 2010 at 11:20 AM, Sander van Grieken
<sander@outrightsolutions.nl> wrote:
> I'm not in favor of having (multiple) storage plugins. Simply because a storage backend is
> not a player. This distinction is important. MeeGo/tracker is a semantic index, so in
> theory you could browse the media through it, but the player might have 'smart' playlist,
> or is only able to play media of a certain kind. Also the current playlist is a player-
> only thing (and is also a browsable item). So I think browsing should go _through_ the
> player.
>
> I was more thinking of exposing a dbus interface that allows a player (or any TG) to
> register itself as a TG, then acting on signals/sending events/responses.
That could be done, actually this is a similar idea as we are planning
to have[1] for replacing our audio ipc, but for things like progress
we would really need to cache it since most device Ive seem keep
polling this. Another possibility is to use MPRIS and PulseAudio
together, but the spec of MPRIS need some work right now the player
assume some name with a prefix e.g: org.freedesktop.MPRIS which is not
that nice, perhaps making MPRIS a separate daemon would make more
sense.
This means that for freedesktop we have:
BlueZ <-> PulseAudio <-> MPRIS
For the rest:
BlueZ <-> Player/whatever
If that is done in PulseAudio we could probably associate the metadata
directly with the stream using MPRIS, if it is up to the player then
we don't care they can set this information directly via some D-Bus
API that is yet to be defined, which wouldn't require player to
implement MPRIS spec. Joao Paulo has something already so I guess we
can start from there[2].
[1] http://gitorious.org/~vudentz/bluez/vudentzs-clone/commits/endpoint
[2] http://git.profusion.mobi/cgit.cgi/jprvita/bluez/log/?h=avrcp_metadata
--
Luiz Augusto von Dentz
Computer Engineer
^ permalink raw reply
* Re: [PATCH] Get IEEE1284 for a single printer
From: Bastien Nocera @ 2010-09-02 10:07 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20100901184902.GA30041@jh-x301>
On Wed, 2010-09-01 at 21:49 +0300, Johan Hedberg wrote:
> Hi Bastien,
>
> On Wed, Sep 01, 2010, Bastien Nocera wrote:
> > From: Bastien Nocera <hadess@hadess.net>
> > Date: Sun, 6 Jun 2010 15:48:26 +0100
> > Subject: [PATCH] (cups) Add ability to print IEEE1284 device ID
> >
> > Add ability to print IEEE1284 device ID for Bluetooth
> > printers to allow auto-configuration once paired.
> > ---
> > cups/main.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 files changed, 83 insertions(+), 0 deletions(-)
>
> Thanks for the updated patch. It's now pushed upstream.
Thanks.
> > I've only fixed the style problems in the patch itself. I'm happy to do
> > the rest of the file, if you have a "indent" magic incantation for it.
>
> In my experience indent can produce quite a mess compared to fixing
> style issues manually. Anyway, I went ahead and did the cleanup myself
> for the issues that I could quickly spot and pushed the fixes as a
> separate patch upstream.
OK. Indent should be able to do this without making a mess as long as
you know the exact parameters. Mind, some of the restrictions feel like
they're from COBOL days (79 characters line width?).
I prefer readable code to mashed-up code that looks that way because of
hard constraints.
^ permalink raw reply
* Re: [PATCH] Bluetooth: fix MTU L2CAP configuration parameter
From: Ville Tervo @ 2010-09-02 9:34 UTC (permalink / raw)
To: ext Emeltchenko Andrei; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1283343445-9328-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
On Wed, Sep 01, 2010 at 02:17:25PM +0200, ext Emeltchenko Andrei wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
>
> When receiving L2CAP negative configuration response with respect
> to MTU parameter we modify wrong field. MTU here means proposed
> value of MTU that the remote device intends to transmit. So for local
> L2CAP socket it is pi->imtu.
>
Yes imtu is negotiated in this phase.
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
Acked-by: Ville Tervo <ville.tervo@nokia.com>
> ---
> net/bluetooth/l2cap.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
> index c784703..9fad312 100644
> --- a/net/bluetooth/l2cap.c
> +++ b/net/bluetooth/l2cap.c
> @@ -2771,10 +2771,10 @@ static int l2cap_parse_conf_rsp(struct sock *sk, void *rsp, int len, void *data,
> case L2CAP_CONF_MTU:
> if (val < L2CAP_DEFAULT_MIN_MTU) {
> *result = L2CAP_CONF_UNACCEPT;
> - pi->omtu = L2CAP_DEFAULT_MIN_MTU;
> + pi->imtu = L2CAP_DEFAULT_MIN_MTU;
> } else
> - pi->omtu = val;
> - l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->omtu);
> + pi->imtu = val;
> + l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->imtu);
> break;
>
> case L2CAP_CONF_FLUSH_TO:
> --
> 1.7.0.4
--
Ville
^ permalink raw reply
* Re: AVRCP future
From: Sander van Grieken @ 2010-09-02 8:20 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20100901185729.GB30041@jh-x301>
Hi Johan,
Thanks for your feedback.
On Wednesday 01 September 2010 20:57:29 Johan Hedberg wrote:
> Hi Sander,
>
> On Wed, Sep 01, 2010, Sander van Grieken wrote:
> > - Is anyone working on AVRCP, besides jprvita?
>
> Maybe, but nothing I'm aware of.
>
> > - Aside from the proposed D-Bus API in doc/control-api.txt, has anyone
> > done some research how an AVRCP1.4 interface should look?
>
> Mostly just ideas that haven't really been written down.
Argh, there a wiki would come in handy ;) It has probably gone over the list a few times,
but I just joined the list and the web archives are.. cumbersome, and google didn't find
much of avrcp in the list.
> It'd be easier
> if we talked about specific features though than about a profile version
> since different features will require different design solutions and
> API's. E.g. in the MeeGo case we'd probably be talking to tracker in
> order to implement media browsing, however other platforms might have a
> different storage backend which means that we'll need some sort of
> backend driver abstraction (we have a similar situation already in obexd
> PBAP and contact storage).
I'm not in favor of having (multiple) storage plugins. Simply because a storage backend is
not a player. This distinction is important. MeeGo/tracker is a semantic index, so in
theory you could browse the media through it, but the player might have 'smart' playlist,
or is only able to play media of a certain kind. Also the current playlist is a player-
only thing (and is also a browsable item). So I think browsing should go _through_ the
player.
I was more thinking of exposing a dbus interface that allows a player (or any TG) to
register itself as a TG, then acting on signals/sending events/responses.
> > - Are there objections to conforming to section 2.3.2, i.e. untying
> > the AVRCP connection from the A2DP connection?
>
> If by that you mean adding Connect() and Disconnect() method calls to
> the org.bluez.Control D-Bus interface, then I'd be happy to accept
> patches for it. However, the automated connecting of AVRCP as triggered
> by an A2DP connection should stay in order to keep good interoperability
> and make things easy for the user interface code.
Agreed.
>
> Johan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* Re: [PATCH] Add handling of UID contact's field in vCard
From: Johan Hedberg @ 2010-09-02 8:10 UTC (permalink / raw)
To: Rafał Michalski; +Cc: linux-bluetooth
In-Reply-To: <AANLkTi=nEVCDx3L3B5d0Xet7uJU0XXpBqgCYf0AQ5fz9@mail.gmail.com>
Hi Rafal,
On Thu, Sep 02, 2010, Rafał Michalski wrote:
> From: Rafal Michalski <michalski.raf@gmail.com>
> Date: Wed, 1 Sep 2010 16:08:35 +0200
> Subject: [PATCH] Add handling of UID contact's field in vCard
>
> After pulling contacts this field wasn't presented in downloaded vCard
> structure in spite of that it existed (not empty). Now it shows downloaded
> UID (using database query).
> ---
> plugins/phonebook-tracker.c | 1 +
> plugins/vcard.c | 4 ++++
> plugins/vcard.h | 1 +
> 3 files changed, 6 insertions(+), 0 deletions(-)
Thanks. The patch has been pushed upstream.
Johan
^ permalink raw reply
* Re: [PATCH 1/2] hid/hid-sony: Apply sixaxis quirks only to sixaxis
From: Jiri Kosina @ 2010-09-02 7:41 UTC (permalink / raw)
To: Antonio Ospite; +Cc: Bastien Nocera, linux-input, linux-bluetooth, cbe-oss-dev
In-Reply-To: <20100901192055.2f23c8c7.ospite@studenti.unina.it>
On Wed, 1 Sep 2010, Antonio Ospite wrote:
> > > Be more explicit and avoid calling sony_set_operational_usb() when we
> > > have USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE.
> > >
> > > While at it, rename the sony_set_operational routines to
> > > sixaxis_set_operational as they are sixaxis specific.
> > >
> > > This is also in preparation for the sysfs interface to set and get bdaddr
> > > over usb and for some other Sixaxis report fixup.
> > >
> > > Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
> >
> > Signed-off-by: Bastien Nocera <hadess@hadess.net>
> >
>
> Thanks Bastien for bringing this up again, I was going to repost
> this patch sometime this month.
>
> Added Jiri to CC as I forgot to do that back then.
Thanks, I have missed that one on linux-input@.
Applied now.
--
Jiri Kosina
SUSE Labs, Novell Inc.
^ permalink raw reply
* [PATCH] Add handling of UID contact's field in vCard
From: Rafał Michalski @ 2010-09-02 7:04 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Rafał Michalski
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 0001-Add-handling-of-UID-contact-s-field-in-vCard.patch --]
[-- Type: text/x-patch, Size: 2012 bytes --]
From 4c3ee0455ea066b5fd4cb07a54c0bc6e0012d848 Mon Sep 17 00:00:00 2001
From: Rafal Michalski <michalski.raf@gmail.com>
Date: Wed, 1 Sep 2010 16:08:35 +0200
Subject: [PATCH] Add handling of UID contact's field in vCard
After pulling contacts this field wasn't presented in downloaded vCard
structure in spite of that it existed (not empty). Now it shows downloaded
UID (using database query).
---
plugins/phonebook-tracker.c | 1 +
plugins/vcard.c | 4 ++++
plugins/vcard.h | 1 +
3 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 193226f..bdd9587 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -866,6 +866,7 @@ add_entry:
contact->company = g_strdup(reply[22]);
contact->department = g_strdup(reply[23]);
contact->title = g_strdup(reply[24]);
+ contact->uid = g_strdup(reply[CONTACTS_ID_COL]);
set_call_type(contact, reply[COL_DATE], reply[COL_SENT],
reply[COL_ANSWERED]);
diff --git a/plugins/vcard.c b/plugins/vcard.c
index 6d74e06..4a77eb3 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -468,6 +468,9 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
vcard_printf_begin(vcards, format);
+ if (filter & FILTER_UID)
+ vcard_printf_tag(vcards, format, "UID", NULL, contact->uid);
+
if (filter & FILTER_N)
vcard_printf_name(vcards, contact);
@@ -580,6 +583,7 @@ void phonebook_contact_free(struct phonebook_contact *contact)
g_slist_foreach(contact->addresses, address_free, NULL);
g_slist_free(contact->addresses);
+ g_free(contact->uid);
g_free(contact->fullname);
g_free(contact->given);
g_free(contact->family);
diff --git a/plugins/vcard.h b/plugins/vcard.h
index d012106..4d134c2 100644
--- a/plugins/vcard.h
+++ b/plugins/vcard.h
@@ -62,6 +62,7 @@ struct phonebook_address {
};
struct phonebook_contact {
+ char *uid;
char *fullname;
char *given;
char *family;
--
1.6.3.3
^ permalink raw reply related
* Re: AVRCP future
From: Johan Hedberg @ 2010-09-01 18:57 UTC (permalink / raw)
To: Sander van Grieken; +Cc: linux-bluetooth
In-Reply-To: <201009011603.02153.sander@outrightsolutions.nl>
Hi Sander,
On Wed, Sep 01, 2010, Sander van Grieken wrote:
> - Is anyone working on AVRCP, besides jprvita?
Maybe, but nothing I'm aware of.
> - Aside from the proposed D-Bus API in doc/control-api.txt, has anyone
> done some research how an AVRCP1.4 interface should look?
Mostly just ideas that haven't really been written down. It'd be easier
if we talked about specific features though than about a profile version
since different features will require different design solutions and
API's. E.g. in the MeeGo case we'd probably be talking to tracker in
order to implement media browsing, however other platforms might have a
different storage backend which means that we'll need some sort of
backend driver abstraction (we have a similar situation already in obexd
PBAP and contact storage).
> - Are there objections to conforming to section 2.3.2, i.e. untying
> the AVRCP connection from the A2DP connection?
If by that you mean adding Connect() and Disconnect() method calls to
the org.bluez.Control D-Bus interface, then I'd be happy to accept
patches for it. However, the automated connecting of AVRCP as triggered
by an A2DP connection should stay in order to keep good interoperability
and make things easy for the user interface code.
Johan
^ permalink raw reply
* Re: [PATCH] Get IEEE1284 for a single printer
From: Johan Hedberg @ 2010-09-01 18:49 UTC (permalink / raw)
To: Bastien Nocera; +Cc: linux-bluetooth
In-Reply-To: <1283351741.2361.19.camel@localhost.localdomain>
Hi Bastien,
On Wed, Sep 01, 2010, Bastien Nocera wrote:
> From: Bastien Nocera <hadess@hadess.net>
> Date: Sun, 6 Jun 2010 15:48:26 +0100
> Subject: [PATCH] (cups) Add ability to print IEEE1284 device ID
>
> Add ability to print IEEE1284 device ID for Bluetooth
> printers to allow auto-configuration once paired.
> ---
> cups/main.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 83 insertions(+), 0 deletions(-)
Thanks for the updated patch. It's now pushed upstream.
> I've only fixed the style problems in the patch itself. I'm happy to do
> the rest of the file, if you have a "indent" magic incantation for it.
In my experience indent can produce quite a mess compared to fixing
style issues manually. Anyway, I went ahead and did the cleanup myself
for the issues that I could quickly spot and pushed the fixes as a
separate patch upstream.
Johan
^ permalink raw reply
* Re: [PATCH 2/2] hid/hid-sony: get and set Sixaxis bdaddr via sysfs
From: Bastien Nocera @ 2010-09-01 17:41 UTC (permalink / raw)
To: Antonio Ospite; +Cc: linux-input, linux-bluetooth, cbe-oss-dev, Jiri Kosina
In-Reply-To: <20100901192854.9370c605.ospite@studenti.unina.it>
On Wed, 2010-09-01 at 19:28 +0200, Antonio Ospite wrote:
> On Wed, 01 Sep 2010 17:17:54 +0100
> Bastien Nocera <hadess@hadess.net> wrote:
>
> > On Mon, 2010-05-03 at 22:15 +0200, Antonio Ospite wrote:
> > > Expose to userspace a simple way to get device bdaddr, and get/set master
> > > bdaddr on Sixaxis controller.
> > >
> > > Right now userspace softwares which manage pairing the controller with a
> > > bluetooth adapter, rely on libusb and hence have to detach and reattach
> > > usbhid, which is not very nice.
> > >
> > > Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
> > > ---
> > >
> > > As said, ideally this should be done with an interface such as hidraw, but its
> > > limitations prevent us from doing it the right way; and I am not going to
> > > touch hidraw myself anytime soon.
> >
> > Rest looks alright to me. Thanks!
>
> Bastien, Jiri, this patch can be DISCARDED. The hidraw work from Alan
> Ott (waiting for Marcel to ACK the bluetooth part) will make this kernel
> approach overkill.
>
> I already have some bluez patches based on Alan's work, but I am waiting
> for the needed changes to land into linus tree before submitting them.
>
> Sorry for making you wasting some time reviewing this one, I told you on
> IRC it could be discarded, but we know: "IRCs volant, emails manent".
Given the time it took me to review it, it's my own damn fault anyway ;)
^ permalink raw reply
* Re: [PATCH 2/2] hid/hid-sony: get and set Sixaxis bdaddr via sysfs
From: Antonio Ospite @ 2010-09-01 17:28 UTC (permalink / raw)
To: Bastien Nocera; +Cc: linux-input, linux-bluetooth, cbe-oss-dev, Jiri Kosina
In-Reply-To: <1283357874.2361.24.camel@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 1501 bytes --]
On Wed, 01 Sep 2010 17:17:54 +0100
Bastien Nocera <hadess@hadess.net> wrote:
> On Mon, 2010-05-03 at 22:15 +0200, Antonio Ospite wrote:
> > Expose to userspace a simple way to get device bdaddr, and get/set master
> > bdaddr on Sixaxis controller.
> >
> > Right now userspace softwares which manage pairing the controller with a
> > bluetooth adapter, rely on libusb and hence have to detach and reattach
> > usbhid, which is not very nice.
> >
> > Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
> > ---
> >
> > As said, ideally this should be done with an interface such as hidraw, but its
> > limitations prevent us from doing it the right way; and I am not going to
> > touch hidraw myself anytime soon.
>
> Rest looks alright to me. Thanks!
Bastien, Jiri, this patch can be DISCARDED. The hidraw work from Alan
Ott (waiting for Marcel to ACK the bluetooth part) will make this kernel
approach overkill.
I already have some bluez patches based on Alan's work, but I am waiting
for the needed changes to land into linus tree before submitting them.
Sorry for making you wasting some time reviewing this one, I told you on
IRC it could be discarded, but we know: "IRCs volant, emails manent".
Regards,
Antonio
--
Antonio Ospite
http://ao2.it
PGP public key ID: 0x4553B001
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply
* Re: [PATCH 1/2] hid/hid-sony: Apply sixaxis quirks only to sixaxis
From: Antonio Ospite @ 2010-09-01 17:20 UTC (permalink / raw)
To: Bastien Nocera; +Cc: linux-input, linux-bluetooth, cbe-oss-dev, Jiri Kosina
In-Reply-To: <1283357615.2361.20.camel@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 1071 bytes --]
On Wed, 01 Sep 2010 17:13:35 +0100
Bastien Nocera <hadess@hadess.net> wrote:
> On Mon, 2010-05-03 at 22:15 +0200, Antonio Ospite wrote:
> > Be more explicit and avoid calling sony_set_operational_usb() when we
> > have USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE.
> >
> > While at it, rename the sony_set_operational routines to
> > sixaxis_set_operational as they are sixaxis specific.
> >
> > This is also in preparation for the sysfs interface to set and get bdaddr
> > over usb and for some other Sixaxis report fixup.
> >
> > Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
>
> Signed-off-by: Bastien Nocera <hadess@hadess.net>
>
Thanks Bastien for bringing this up again, I was going to repost
this patch sometime this month.
Added Jiri to CC as I forgot to do that back then.
Regards,
Antonio
--
Antonio Ospite
http://ao2.it
PGP public key ID: 0x4553B001
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply
* Re: [PATCH 2/2] hid/hid-sony: get and set Sixaxis bdaddr via sysfs
From: Bastien Nocera @ 2010-09-01 16:17 UTC (permalink / raw)
To: Antonio Ospite; +Cc: linux-input, linux-bluetooth, cbe-oss-dev
In-Reply-To: <1272917756-31098-3-git-send-email-ospite@studenti.unina.it>
On Mon, 2010-05-03 at 22:15 +0200, Antonio Ospite wrote:
> Expose to userspace a simple way to get device bdaddr, and get/set master
> bdaddr on Sixaxis controller.
>
> Right now userspace softwares which manage pairing the controller with a
> bluetooth adapter, rely on libusb and hence have to detach and reattach
> usbhid, which is not very nice.
>
> Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
> ---
>
> As said, ideally this should be done with an interface such as hidraw, but its
> limitations prevent us from doing it the right way; and I am not going to
> touch hidraw myself anytime soon.
Rest looks alright to me. Thanks!
> drivers/hid/hid-sony.c | 148 +++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 145 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> index d61f268..1b611ec 100644
> --- a/drivers/hid/hid-sony.c
> +++ b/drivers/hid/hid-sony.c
> @@ -47,6 +47,131 @@ static void sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
> }
>
> /*
> + * Show and set the master bdaddr for PS3 controller, without disconnecting
> + * the device.
> + */
> +static ssize_t show_sixaxis_master_bdaddr(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct usb_interface *intf = to_usb_interface(dev);
> + struct usb_device *udev = interface_to_usbdev(intf);
> + __u16 ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
> + int ret;
> + unsigned char *mbuf = kmalloc(9, GFP_KERNEL);
> +
> + if (!mbuf)
> + return -ENOMEM;
> +
> + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
> + HID_REQ_GET_REPORT,
> + USB_DIR_IN | USB_TYPE_CLASS |
> + USB_RECIP_INTERFACE,
> + (3 << 8) | 0xf5, ifnum, mbuf, 8,
> + USB_CTRL_GET_TIMEOUT);
> + if (ret < 0)
> + dev_err(dev, "%s failed to get master bdaddr, ret: %d\n",
> + __func__, ret);
> + else
> + /* 18 is strlen("00:00:00:00:00:00\n") */
Could you please check for the actual returned length of mbuf here?
> + ret = snprintf(buf, 18, "%02x:%02x:%02x:%02x:%02x:%02x\n",
> + mbuf[2], mbuf[3], mbuf[4],
> + mbuf[5], mbuf[6], mbuf[7]);
> +
> + kfree(mbuf);
> +
> + return ret;
> +}
> +
> +static ssize_t store_sixaxis_master_bdaddr(struct device *dev,
> + struct device_attribute *attr, const char *buf, size_t count)
> +{
> + struct usb_interface *intf = to_usb_interface(dev);
> + struct usb_device *udev = interface_to_usbdev(intf);
> + __u16 ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
> + int ret;
> + unsigned char *mbuf = kmalloc(9, GFP_KERNEL);
Check for count != 6 and bail?
And also check for mbuf != NULL.
> + mbuf[0] = 0x01;
> + mbuf[1] = 0x00;
> + ret = sscanf(buf, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
> + &mbuf[2], &mbuf[3], &mbuf[4],
> + &mbuf[5], &mbuf[6], &mbuf[7]);
> + if (ret != 6) {
> + dev_err(dev, "%s failed, ret: %d\n", __func__, ret);
> + return -EINVAL;
> + }
> +
> + ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
> + HID_REQ_SET_REPORT,
> + USB_DIR_OUT | USB_TYPE_CLASS |
> + USB_RECIP_INTERFACE,
> + (3 << 8) | 0xf5, ifnum, mbuf, 8,
> + USB_CTRL_GET_TIMEOUT);
> +
> + kfree(mbuf);
> +
> + if (ret < 0) {
> + dev_err(dev, "%s failed to set master bdaddr, ret: %d\n",
> + __func__, ret);
> + return ret;
> + }
> +
> + return count;
> +}
> +
> +/*
> + * Show the bdaddr for PS3 controller, without disconnecting the device.
> + */
> +static ssize_t show_sixaxis_bdaddr(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct usb_interface *intf = to_usb_interface(dev);
> + struct usb_device *udev = interface_to_usbdev(intf);
> + __u16 ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
> + int ret;
> + unsigned char *mbuf = kmalloc(18, GFP_KERNEL);
> +
> + if (!mbuf)
> + return -ENOMEM;
> +
> + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
> + HID_REQ_GET_REPORT,
> + USB_DIR_IN | USB_TYPE_CLASS |
> + USB_RECIP_INTERFACE,
> + (3 << 8) | 0xf2, ifnum, mbuf, 17,
> + USB_CTRL_GET_TIMEOUT);
> + if (ret < 0)
> + dev_err(dev, "%s failed to get device bdaddr, ret: %d\n",
> + __func__, ret);
> + else
> + /* 18 is strlen("00:00:00:00:00:00\n") */
length of mbuf != 9?
> + ret = snprintf(buf, 18, "%02x:%02x:%02x:%02x:%02x:%02x\n",
> + mbuf[4], mbuf[5], mbuf[6],
> + mbuf[7], mbuf[8], mbuf[9]);
> +
> + kfree(mbuf);
> +
> + return ret;
> +}
> +
> +static DEVICE_ATTR(sixaxis_master_bdaddr, S_IWUSR|S_IRUGO,
> + show_sixaxis_master_bdaddr, store_sixaxis_master_bdaddr);
> +
> +static DEVICE_ATTR(sixaxis_bdaddr, S_IRUGO,
> + show_sixaxis_bdaddr, NULL);
> +
> +static struct attribute *sixaxis_attributes[] = {
> + &dev_attr_sixaxis_master_bdaddr.attr,
> + &dev_attr_sixaxis_bdaddr.attr,
> + NULL
> +};
> +
> +static const struct attribute_group sixaxis_attr_group = {
> + .attrs = sixaxis_attributes,
> +};
> +
> +
> +/*
> * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
> * to "operational". Without this, the ps3 controller will not report any
> * events.
> @@ -57,8 +182,9 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev)
> struct usb_device *dev = interface_to_usbdev(intf);
> __u16 ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
> int ret;
> - char *buf = kmalloc(18, GFP_KERNEL);
> + unsigned char *buf = kmalloc(18, GFP_KERNEL);
buf != NULL.
> + dev_info(&hdev->dev, "Calling %s\n", __func__);
> if (!buf)
> return -ENOMEM;
>
> @@ -70,6 +196,9 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev)
> USB_CTRL_GET_TIMEOUT);
> if (ret < 0)
> dev_err(&hdev->dev, "can't set operational mode\n");
> + else
> + dev_info(&hdev->dev, "Sony PS3 Controller bdaddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
> + buf[4], buf[5], buf[6], buf[7], buf[8], buf[9]);
>
> kfree(buf);
>
> @@ -110,9 +239,17 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
> goto err_free;
> }
>
> - if (sc->quirks & SIXAXIS_CONTROLLER_USB)
> + if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
> + struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
> + ret = sysfs_create_group(&intf->dev.kobj, &sixaxis_attr_group);
> + if (ret < 0) {
> + dev_err(&hdev->dev,
> + "cannot register sixaxis sysfs hooks\n");
> + goto err_stop;
> + }
> +
> ret = sixaxis_set_operational_usb(hdev);
> - else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
> + } else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
> ret = sixaxis_set_operational_bt(hdev);
> else
> ret = 0;
> @@ -130,6 +267,11 @@ err_free:
>
> static void sony_remove(struct hid_device *hdev)
> {
> + struct sony_sc *sc = hid_get_drvdata(hdev);
> + if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
> + struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
> + sysfs_remove_group(&intf->dev.kobj, &sixaxis_attr_group);
> + }
> hid_hw_stop(hdev);
> kfree(hid_get_drvdata(hdev));
> }
^ permalink raw reply
* Re: [PATCH 1/2] hid/hid-sony: Apply sixaxis quirks only to sixaxis
From: Bastien Nocera @ 2010-09-01 16:13 UTC (permalink / raw)
To: Antonio Ospite; +Cc: linux-input, linux-bluetooth, cbe-oss-dev
In-Reply-To: <1272917756-31098-2-git-send-email-ospite@studenti.unina.it>
On Mon, 2010-05-03 at 22:15 +0200, Antonio Ospite wrote:
> Be more explicit and avoid calling sony_set_operational_usb() when we
> have USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE.
>
> While at it, rename the sony_set_operational routines to
> sixaxis_set_operational as they are sixaxis specific.
>
> This is also in preparation for the sysfs interface to set and get bdaddr
> over usb and for some other Sixaxis report fixup.
>
> Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Bastien Nocera <hadess@hadess.net>
> ---
> drivers/hid/hid-sony.c | 28 ++++++++++++++--------------
> 1 files changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> index 402d557..d61f268 100644
> --- a/drivers/hid/hid-sony.c
> +++ b/drivers/hid/hid-sony.c
> @@ -24,7 +24,9 @@
>
> #include "hid-ids.h"
>
> -#define VAIO_RDESC_CONSTANT 0x0001
> +#define VAIO_RDESC_CONSTANT (1 << 0)
> +#define SIXAXIS_CONTROLLER_USB (1 << 1)
> +#define SIXAXIS_CONTROLLER_BT (1 << 2)
>
> struct sony_sc {
> unsigned long quirks;
> @@ -49,7 +51,7 @@ static void sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
> * to "operational". Without this, the ps3 controller will not report any
> * events.
> */
> -static int sony_set_operational_usb(struct hid_device *hdev)
> +static int sixaxis_set_operational_usb(struct hid_device *hdev)
> {
> struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
> struct usb_device *dev = interface_to_usbdev(intf);
> @@ -74,7 +76,7 @@ static int sony_set_operational_usb(struct hid_device *hdev)
> return ret;
> }
>
> -static int sony_set_operational_bt(struct hid_device *hdev)
> +static int sixaxis_set_operational_bt(struct hid_device *hdev)
> {
> unsigned char buf[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 };
> return hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
> @@ -108,16 +110,12 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
> goto err_free;
> }
>
> - switch (hdev->bus) {
> - case BUS_USB:
> - ret = sony_set_operational_usb(hdev);
> - break;
> - case BUS_BLUETOOTH:
> - ret = sony_set_operational_bt(hdev);
> - break;
> - default:
> + if (sc->quirks & SIXAXIS_CONTROLLER_USB)
> + ret = sixaxis_set_operational_usb(hdev);
> + else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
> + ret = sixaxis_set_operational_bt(hdev);
> + else
> ret = 0;
> - }
>
> if (ret < 0)
> goto err_stop;
> @@ -137,8 +135,10 @@ static void sony_remove(struct hid_device *hdev)
> }
>
> static const struct hid_device_id sony_devices[] = {
> - { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
> - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
> + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
> + .driver_data = SIXAXIS_CONTROLLER_USB },
> + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
> + .driver_data = SIXAXIS_CONTROLLER_BT },
> { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE),
> .driver_data = VAIO_RDESC_CONSTANT },
> { }
^ permalink raw reply
* Re: [PATCH] Get IEEE1284 for a single printer
From: Bastien Nocera @ 2010-09-01 14:35 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20100608092621.GA8254@jh-x301>
[-- Attachment #1: Type: text/plain, Size: 769 bytes --]
On Tue, 2010-06-08 at 17:26 +0800, Johan Hedberg wrote:
> Hi Bastien,
>
> On Tue, Jun 08, 2010, Bastien Nocera wrote:
> > > I have nothing against pushing the patch upstream as long as its coding
> > > style issues are fixed:
> > <snip>
> > > Mixed tabs and spaces.
> >
> > You do realise that all those are cut'n'paste from another function in
> > the same source file?
>
> Nope, didn't realize that. So the whole file needs coding style cleanups
> then.
I've only fixed the style problems in the patch itself. I'm happy to do
the rest of the file, if you have a "indent" magic incantation for it.
> > > > + fprintf(stderr, "Invalid Bluetooth address '%s'\n", argv[2]);
> > >
> > > Too long line.
> >
> > Right, I'll fix that.
Done.
Updated patch attached.
[-- Attachment #2: 0001-cups-Add-ability-to-print-IEEE1284-device-ID.patch --]
[-- Type: text/x-patch, Size: 3158 bytes --]
>From 35c984cfbe0a17bb3dd7231450f72854b3ffb7d0 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Sun, 6 Jun 2010 15:48:26 +0100
Subject: [PATCH] (cups) Add ability to print IEEE1284 device ID
Add ability to print IEEE1284 device ID for Bluetooth
printers to allow auto-configuration once paired.
---
cups/main.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/cups/main.c b/cups/main.c
index 9659a11..b420643 100644
--- a/cups/main.c
+++ b/cups/main.c
@@ -605,6 +605,79 @@ static gboolean list_printers(void)
return TRUE;
}
+static gboolean print_ieee1284(const char *bdaddr)
+{
+ DBusMessage *message, *reply, *adapter_reply;
+ DBusMessageIter iter;
+ char *object_path = NULL;
+ char *adapter;
+ char *id;
+
+ adapter_reply = NULL;
+
+ conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL);
+ if (conn == NULL)
+ return FALSE;
+
+ message = dbus_message_new_method_call("org.bluez", "/",
+ "org.bluez.Manager",
+ "DefaultAdapter");
+
+ adapter_reply = dbus_connection_send_with_reply_and_block(conn,
+ message, -1, NULL);
+
+ dbus_message_unref(message);
+
+ if (dbus_message_get_args(adapter_reply, NULL,
+ DBUS_TYPE_OBJECT_PATH, &adapter,
+ DBUS_TYPE_INVALID) == FALSE)
+ return FALSE;
+
+ message = dbus_message_new_method_call("org.bluez", adapter,
+ "org.bluez.Adapter",
+ "FindDevice");
+ dbus_message_iter_init_append(message, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &bdaddr);
+
+ if (adapter_reply != NULL)
+ dbus_message_unref(adapter_reply);
+
+ reply = dbus_connection_send_with_reply_and_block(conn,
+ message, -1, NULL);
+
+ dbus_message_unref(message);
+
+ if (!reply) {
+ message = dbus_message_new_method_call("org.bluez", adapter,
+ "org.bluez.Adapter",
+ "CreateDevice");
+ dbus_message_iter_init_append(message, &iter);
+ dbus_message_iter_append_basic(&iter,
+ DBUS_TYPE_STRING, &bdaddr);
+
+ reply = dbus_connection_send_with_reply_and_block(conn,
+ message, -1, NULL);
+
+ dbus_message_unref(message);
+
+ if (!reply)
+ return FALSE;
+ }
+ if (dbus_message_get_args(reply, NULL,
+ DBUS_TYPE_OBJECT_PATH, &object_path,
+ DBUS_TYPE_INVALID) == FALSE) {
+ return FALSE;
+ }
+
+ id = device_get_ieee1284_id(adapter, object_path);
+ if (id == NULL)
+ return FALSE;
+ printf("%s", id);
+ g_free(id);
+
+ return TRUE;
+}
+
/*
* Usage: printer-uri job-id user title copies options [file]
*
@@ -642,10 +715,20 @@ int main(int argc, char *argv[])
return CUPS_BACKEND_OK;
else
return CUPS_BACKEND_FAILED;
+ } else if (argc == 3 && strcmp(argv[1], "--get-deviceid") == 0) {
+ if (bachk(argv[2]) < 0) {
+ fprintf(stderr, "Invalid Bluetooth address '%s'\n",
+ argv[2]);
+ return CUPS_BACKEND_FAILED;
+ }
+ if (print_ieee1284(argv[2]) == FALSE)
+ return CUPS_BACKEND_FAILED;
+ return CUPS_BACKEND_OK;
}
if (argc < 6 || argc > 7) {
fprintf(stderr, "Usage: bluetooth job-id user title copies options [file]\n");
+ fprintf(stderr, " bluetooth --get-deviceid [bdaddr]\n");
return CUPS_BACKEND_FAILED;
}
--
1.7.0.1
^ permalink raw reply related
* AVRCP future
From: Sander van Grieken @ 2010-09-01 14:03 UTC (permalink / raw)
To: linux-bluetooth
Hi All,
I've been looking into AVRCP a bit lately, since I'm interested in the 'Remote Control
from Separate Controller' usecase as described in the AVRCP spec, section 2.3.1.1.
However, from the BlueZ source, it seems an AVRCP connection is only set up/allowed when
there is a AVD sink present, which is in violation of the bluetooth spec, section 2.3.2
Also, the recent progress made by João Paulo Rechi Vita bind the control and audio stream
closely together (basically disabling the control once audio is not pulseaudio-routed to
the bluetooth peer).
Now, my questions:
- Is anyone working on AVRCP, besides jprvita?
- Aside from the proposed D-Bus API in doc/control-api.txt, has anyone done some research
how an AVRCP1.4 interface should look?
- Are there objections to conforming to section 2.3.2, i.e. untying the AVRCP connection
from the A2DP connection?
I'm willing to put some effort in improving AVRCP, but before I go off blindly coding such
stuff, please give as much feedback as possible :)
grtz,
Sander
^ permalink raw reply
* Re: [PATCH] Add handling for more than one address in vCard
From: Johan Hedberg @ 2010-09-01 13:44 UTC (permalink / raw)
To: Rafał Michalski; +Cc: linux-bluetooth
In-Reply-To: <AANLkTinHqG2Vbfr5qyEX0v8dAxATWy3nO_r25TkY8io3@mail.gmail.com>
Hi Rafal,
On Wed, Sep 01, 2010, Rafał Michalski wrote:
> From: Rafal Michalski <michalski.raf@gmail.com>
> Date: Wed, 1 Sep 2010 13:07:12 +0200
> Subject: [PATCH] Add handling for more than one address in vCard
>
> After pulling contacts only fields (pobox, extended, street, locality,
> region, postal, country) of one address were present in downloaded vCard
> structure (under ADR tag) in spite of that there can be more adresses
> stored on phonebook. To solve this problem extending number of columns and
> queries of database was needed especially. Distinguish between two types
> of address (HOME and WORK) is supported.
> ---
> plugins/phonebook-tracker.c | 93 ++++++++++++++++++++++++++++++++++++------
> plugins/vcard.c | 89 ++++++++++++++++++++++++++++++++++-------
> plugins/vcard.h | 15 ++++++-
> 3 files changed, 167 insertions(+), 30 deletions(-)
Thanks. This patch is now upstream.
Johan
^ permalink raw reply
* Re: [PATCH]Bluetooth:net/bluetooth/hci_core.c Fix system crash when creating a new device with bluetooth-applet
From: Justin P. Mattock @ 2010-09-01 12:30 UTC (permalink / raw)
To: Suraj Sumangala
Cc: Gustavo F. Padovan, linux-bluetooth@vger.kernel.org,
marcel@holtmann.org, Suraj Sumangala,
linux-kernel@vger.kernel.org
In-Reply-To: <4C7E156A.3050403@Atheros.com>
On 09/01/2010 01:57 AM, Suraj Sumangala wrote:
> Hi Justin,
>
> On 9/1/2010 1:30 PM, Gustavo F. Padovan wrote:
>> Hi Justin,
>>
>> * Justin P. Mattock<justinmattock@gmail.com> [2010-08-31 10:13:47 -0700]:
>>
>>> When using bluetooth-applet adding my apple magic mouse I'm getting a
>>> total system freeze.
>>> I used firescope to grab the crash data(below) The results of the
>>> bisect pointed to here:
>>> Bluetooth: Implemented HCI frame reassembly from RX stream
>>> commit:9981151086385eecc2febf4ba95a14593f834b3d
>>>
>>> after looking through, and at the crash log, I couldn't help but
>>> notice something in there
>>> with IRQ, then after looking at hci_h4.c /* H4 receiver States */ #58
>>> I noticed
>>> #define H4_W4_PACKET_TYPE 0 is at zero as well as #define
>>> STREAM_REASSEMBLY 0
>>> so changing STREAM_REASSEMBLY to a different number that isn't taken
>>> gets my machine to connect
>>> perfectly to my magic mouse. Please have a look and let me know if
>>> this is a good
>>> solution and/or send me something else to test out.
>>
>> Your patch seems very wrong, H4_W4_PACKET_TYPE and STREAM_REASSEMBLY
>> have nothing to do with each other, your commit message doesn't make
>> sense. Also the patch corrupts 'struct hci_dev'.
>> If you pay attention on the code flow you can check that
>> STREAM_REASSEMBLY is never used in the crash log you sent.
> Gustavo is correct. This should not have any effect on the code flow for
> you as you are using USB transport and STREAM_REASSEMBLY is relevant
> only for UART transport.
>
> So, I guess your problem is not 100% reproducible.
easily reproducible open bluetooth applet connect new device once I see
the spinning animation ring say connected the whole system just locks
up.(keep in mind this is with a apple magic mouse)
>>
>>>
>>> crash:
>>>
>>>
>>> <1>[ 1755.556472] BUG: unable to handle kernel paging request at
>>> ffff880224d0c548
>>> <1>[ 1755.556485] IP: [<ffffffffa0042bec>]
>>> hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>>> <4>[ 1755.556507] PGD 1609063 PUD 0
>>> <0>[ 1755.556515] Oops: 0000 [#1] SMP
>>> <0>[ 1755.556522] last sysfs file:
>>> /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/voltage_now
>>>
>>> <4>[ 1755.556530] CPU 0
>>> <4>[ 1755.556533] Modules linked in: usb_storage xfrm4_mode_transport
>>> xcbc rmd160 sha512_generic sco bnep xt_tcpudp ipt_LOG iptable_nat
>>> nf_nat xt_state nf_conntrack_ftp nf_conntrack_ipv4 nf_conntrack
>>> nf_defrag_ipv4 iptable_filter ip_tables x_tables ath9k firewire_ohci
>>> ath9k_common firewire_core ath9k_hw battery ac ohci1394 evdev thermal
>>> ath sky2 joydev button snd_hda_codec_idt snd_hda_intel snd_hda_codec
>>> snd_hwdep snd_pcm snd_timer i2c_i801 snd soundcore snd_page_alloc
>>> video aes_x86_64 lzo lzo_compress tun kvm_intel ipcomp xfrm_ipcomp
>>> crypto_null sha256_generic cbc des_generic cast5 blowfish serpent
>>> camellia twofish_generic twofish_x86_64 twofish_common ctr ah4 esp4
>>> authenc raw1394 ieee1394 uhci_hcd ehci_hcd hci_uart rfcomm btusb hidp
>>> l2cap bluetooth coretemp acpi_cpufreq processor mperf appletouch
>>> applesmc
>>> <4>[ 1755.556676]
>>> <4>[ 1755.556682] Pid: 0, comm: swapper Not tainted 2.6.36-rc3 #3
>>> Mac-F42187C8/MacBookPro2,2
>>> <4>[ 1755.556688] RIP: 0010:[<ffffffffa0042bec>] [<ffffffffa0042bec>]
>>> hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>>> <4>[ 1755.556705] RSP: 0018:ffff880001803ca8 EFLAGS: 00010092
>>> <4>[ 1755.556710] RAX: 000000003df64001 RBX: 0000000000000014 RCX:
>>> 0000000000000014
>>> <4>[ 1755.556716] RDX: ffff8800372018d8 RSI: 0000000000000002 RDI:
>>> ffff8800351ec240
>>> <4>[ 1755.556722] RBP: ffff880001803cf8 R08: ffff88003df64001 R09:
>>> ffff88000180f398
>>> <4>[ 1755.556728] R10: dead000000100100 R11: dead000000200200 R12:
>>> ffff8800351ec240
>>> <4>[ 1755.556733] R13: 0000000000000002 R14: 000000003df64001 R15:
>>> 0000000000000001
>>> <4>[ 1755.556740] FS: 0000000000000000(0000)
>>> GS:ffff880001800000(0000) knlGS:0000000000000000
>>> <4>[ 1755.556746] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
>>> <4>[ 1755.556752] CR2: ffff880224d0c548 CR3: 0000000001608000 CR4:
>>> 00000000000006f0
>>> <4>[ 1755.556758] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
>>> 0000000000000000
>>> <4>[ 1755.556763] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7:
>>> 0000000000000400
>>> <4>[ 1755.556770] Process swapper (pid: 0, threadinfo
>>> ffffffff815f0000, task ffffffff81610020)
>>> <0>[ 1755.556774] Stack:
>>> <4>[ 1755.556778] ffffea0000b9fdc8 ffff88003df64000 ffff8800372018d8
>>> ffffffffa00a189f
>>> <4>[ 1755.556787]<0> ffff880001803d08 0000000000000014
>>> 0000000000000002 ffff8800372018d8
>>> <4>[ 1755.556797]<0> ffff8800351ec240 0000000000000001
>>> ffff880001803d38 ffffffffa0042dc5
>>> <0>[ 1755.556809] Call Trace:
>>> <0>[ 1755.556813]<IRQ>
>>> <4>[ 1755.556825] [<ffffffffa00a189f>] ? uhci_free_urb_priv+0xa6/0xb3
>>> [uhci_hcd]
>>> <4>[ 1755.556839] [<ffffffffa0042dc5>] hci_recv_fragment+0x47/0x65
>>> [bluetooth]
>>> <4>[ 1755.556851] [<ffffffffa00705ee>] btusb_bulk_complete+0x56/0xd6
>>> [btusb]
>>> <4>[ 1755.556862] [<ffffffff812c1df9>] usb_hcd_giveback_urb+0x5d/0x8d
>>> <4>[ 1755.556873] [<ffffffffa00a217b>] uhci_giveback_urb+0x11a/0x1a9
>>> [uhci_hcd]
>>> <4>[ 1755.556884] [<ffffffffa00a2a1a>] uhci_scan_schedule+0x544/0x84e
>>> [uhci_hcd]
>>> <4>[ 1755.556896] [<ffffffffa00a3343>] uhci_irq+0xee/0x104 [uhci_hcd]
>>> <4>[ 1755.556903] [<ffffffff812c1a08>] usb_hcd_irq+0x43/0x79
>>> <4>[ 1755.556913] [<ffffffff81098c0b>] handle_IRQ_event+0x6e/0x14b
>>> <4>[ 1755.556922] [<ffffffff8109aa52>] handle_fasteoi_irq+0x92/0xd2
>>> <4>[ 1755.556931] [<ffffffff81029ab6>] handle_irq+0x86/0x8c
>>> <4>[ 1755.556938] [<ffffffff8102975c>] do_IRQ+0x57/0xbe
>>> <4>[ 1755.556948] [<ffffffff813ecb93>] ret_from_intr+0x0/0x11
>>> <0>[ 1755.556952]<EOI>
>>> <4>[ 1755.556966] [<ffffffffa0022e7b>] ?
>>> acpi_idle_enter_bm+0x252/0x28a [processor]
>>> <4>[ 1755.556979] [<ffffffffa0022e74>] ?
>>> acpi_idle_enter_bm+0x24b/0x28a [processor]
>>> <4>[ 1755.556988] [<ffffffff8130a5d5>] ? menu_select+0x16f/0x296
>>> <4>[ 1755.556996] [<ffffffff81309501>] cpuidle_idle_call+0x9f/0x119
>>> <4>[ 1755.557004] [<ffffffff81025db4>] cpu_idle+0x62/0xc5
>>> <4>[ 1755.557014] [<ffffffff813d1bd4>] rest_init+0x68/0x6a
>>> <4>[ 1755.557024] [<ffffffff8168cb7b>] start_kernel+0x365/0x370
>>> <4>[ 1755.557033] [<ffffffff8168c2a6>]
>>> x86_64_start_reservations+0xad/0xb1
>>> <4>[ 1755.557042] [<ffffffff8168c140>] ? early_idt_handler+0x0/0x71
>>> <4>[ 1755.557050] [<ffffffff8168c3a3>] x86_64_start_kernel+0xf9/0x108
>>> <0>[ 1755.557055] Code: 41 5c 41 5d 41 5e c9 c3 55 49 63 c0 48 89 e5
>>> 41 57 41 56 45 89 c6 41 55 41 89 f5 41 54 49 89 fc 53 89 cb 48 83 ec
>>> 28 48 89 55 c0<48> 8b 94 c7 00 03 00 00 48 85 d2 0f 85 61 01 00 00 41
>>> 8d 45 fe
>>> <1>[ 1755.557139] RIP [<ffffffffa0042bec>]
>>> hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>>> <4>[ 1755.557154] RSP<ffff880001803ca8>
>>> <0>[ 1755.557158] CR2: ffff880224d0c548
>>> <4>[ 1755.557164] ---[ end trace 6c64514f0ad01ea5 ]---
>>> <0>[ 1755.557169] Kernel panic - not syncing: Fatal exception in
>>> interrupt
>>> <4>[ 1755.557176] Pid: 0, comm: swapper Tainted: G D 2.6.36-rc3 #3
>>> <4>[ 1755.557180] Call Trace:
>>> <4>[ 1755.557183]<IRQ> [<ffffffff813e47d2>] panic+0x8c/0x189
>>> <4>[ 1755.557199] [<ffffffff813ed90c>] oops_end+0x87/0x94
>>> <4>[ 1755.557206] [<ffffffff813e4737>] no_context+0x1f4/0x203
>>> <4>[ 1755.557216] [<ffffffff8104487f>]
>>> __bad_area_nosemaphore+0x17f/0x1a2
>>> <4>[ 1755.557224] [<ffffffff810448b0>] bad_area_nosemaphore+0xe/0x10
>>> <4>[ 1755.557233] [<ffffffff813ef9fd>] do_page_fault+0x1ee/0x3c2
>>> <4>[ 1755.557243] [<ffffffff810e4748>] ? check_object+0x151/0x202
>>> <4>[ 1755.557254] [<ffffffffa00a336f>] ?
>>> uhci_alloc_td.isra.22+0x16/0x44 [uhci_hcd]
>>> <4>[ 1755.557265] [<ffffffffa00a3b17>] ?
>>> uhci_submit_common.isra.24+0x233/0x2d3 [uhci_hcd]
>>> <4>[ 1755.557273] [<ffffffff813ecde5>] page_fault+0x25/0x30
>>> <4>[ 1755.557287] [<ffffffffa0042bec>] ?
>>> hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>>> <4>[ 1755.557298] [<ffffffffa00a189f>] ? uhci_free_urb_priv+0xa6/0xb3
>>> [uhci_hcd]
>>> <4>[ 1755.557311] [<ffffffffa0042dc5>] hci_recv_fragment+0x47/0x65
>>> [bluetooth]
>>> <4>[ 1755.557322] [<ffffffffa00705ee>] btusb_bulk_complete+0x56/0xd6
>>> [btusb]
>>> <4>[ 1755.557330] [<ffffffff812c1df9>] usb_hcd_giveback_urb+0x5d/0x8d
>>> <4>[ 1755.557340] [<ffffffffa00a217b>] uhci_giveback_urb+0x11a/0x1a9
>>> [uhci_hcd]
>>> <4>[ 1755.557351] [<ffffffffa00a2a1a>] uhci_scan_schedule+0x544/0x84e
>>> [uhci_hcd]
>>> <4>[ 1755.557362] [<ffffffffa00a3343>] uhci_irq+0xee/0x104 [uhci_hcd]
>>> <4>[ 1755.557369] [<ffffffff812c1a08>] usb_hcd_irq+0x43/0x79
>>> <4>[ 1755.557377] [<ffffffff81098c0b>] handle_IRQ_event+0x6e/0x14b
>>> <4>[ 1755.557386] [<ffffffff8109aa52>] handle_fasteoi_irq+0x92/0xd2
>>> <4>[ 1755.557393] [<ffffffff81029ab6>] handle_irq+0x86/0x8c
>>> <4>[ 1755.557401] [<ffffffff8102975c>] do_IRQ+0x57/0xbe
>>> <4>[ 1755.557408] [<ffffffff813ecb93>] ret_from_intr+0x0/0x11
>>> <4>[ 1755.557413]<EOI> [<ffffffffa0022e7b>] ?
>>> acpi_idle_enter_bm+0x252/0x28a [processor]
>>> <4>[ 1755.557420] [<ffffffffa0022e74>] ?
>>> acpi_idle_enter_bm+0x24b/0x28a [processor]
>>> <4>[ 1755.557420] [<ffffffff8130a5d5>] ? menu_select+0x16f/0x296
>>> <4>[ 1755.557420] [<ffffffff81309501>] cpuidle_idle_call+0x9f/0x119>
>>> <4>[ 1755.557420] [<ffffffff81025db4>] cpu_idle+0x62/0xc5> <4>[
>>> 1755.557420] [<ffffffff813d1bd4>] rest_init+0x68/0x6a> <4>[
>>> 1755.557420] [<ffffffff8168cb7b>] start_kernel+0x365/0x370
>>> <4>[ 1755.557420] [<ffffffff8168c2a6>]
>>> x86_64_start_reservations+0xad/0xb1
>>> <4>[ 1755.557420] [<ffffffff8168c140>] ? early_idt_handler+0x0/0x71
>>> <4>[ 1755.557420] [<ffffffff8168c3a3>] x86_64_start_kernel+0xf9/0x108
>>
>> Suraj, do you have any idea on that?
>>
>
> can you verify the return status of hci_reassembly()? I guess there
> could be some mismatch in the packet received.
>
> Regards
> Suraj
>
>
Ill have to look into to that and see.
Justin P. Mattock
^ permalink raw reply
* Re: [PATCH]Bluetooth:net/bluetooth/hci_core.c Fix system crash when creating a new device with bluetooth-applet
From: Justin P. Mattock @ 2010-09-01 12:26 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth, marcel, suraj, linux-kernel
In-Reply-To: <20100901010821.GA28764@vigoh>
On 09/01/2010 01:00 AM, Gustavo F. Padovan wrote:
> Hi Justin,
>
> * Justin P. Mattock<justinmattock@gmail.com> [2010-08-31 10:13:47 -0700]:
>
>> When using bluetooth-applet adding my apple magic mouse I'm getting a total system freeze.
>> I used firescope to grab the crash data(below) The results of the bisect pointed to here:
>> Bluetooth: Implemented HCI frame reassembly from RX stream
>> commit:9981151086385eecc2febf4ba95a14593f834b3d
>>
>> after looking through, and at the crash log, I couldn't help but notice something in there
>> with IRQ, then after looking at hci_h4.c /* H4 receiver States */ #58 I noticed
>> #define H4_W4_PACKET_TYPE 0 is at zero as well as #define STREAM_REASSEMBLY 0
>> so changing STREAM_REASSEMBLY to a different number that isn't taken gets my machine to connect
>> perfectly to my magic mouse. Please have a look and let me know if this is a good
>> solution and/or send me something else to test out.
>
> Your patch seems very wrong, H4_W4_PACKET_TYPE and STREAM_REASSEMBLY
> have nothing to do with each other, your commit message doesn't make
> sense. Also the patch corrupts 'struct hci_dev'.
> If you pay attention on the code flow you can check that
> STREAM_REASSEMBLY is never used in the crash log you sent.
>
yeah I admit, I didnt really know what todo with this..(but gave it a try)
>>
>> crash:
>>
>>
>> <1>[ 1755.556472] BUG: unable to handle kernel paging request at ffff880224d0c548
>> <1>[ 1755.556485] IP: [<ffffffffa0042bec>] hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>> <4>[ 1755.556507] PGD 1609063 PUD 0
>> <0>[ 1755.556515] Oops: 0000 [#1] SMP
>> <0>[ 1755.556522] last sysfs file: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/voltage_now
>> <4>[ 1755.556530] CPU 0
>> <4>[ 1755.556533] Modules linked in: usb_storage xfrm4_mode_transport xcbc rmd160 sha512_generic sco bnep xt_tcpudp ipt_LOG iptable_nat nf_nat xt_state nf_conntrack_ftp nf_conntrack_ipv4 nf_conntrack nf_defrag_ipv4 iptable_filter ip_tables x_tables ath9k firewire_ohci ath9k_common firewire_core ath9k_hw battery ac ohci1394 evdev thermal ath sky2 joydev button snd_hda_codec_idt snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_timer i2c_i801 snd soundcore snd_page_alloc video aes_x86_64 lzo lzo_compress tun kvm_intel ipcomp xfrm_ipcomp crypto_null sha256_generic cbc des_generic cast5 blowfish serpent camellia twofish_generic twofish_x86_64 twofish_common ctr ah4 esp4 authenc raw1394 ieee1394 uhci_hcd ehci_hcd hci_uart rfcomm btusb hidp l2cap bluetooth coretemp acpi_cpufreq processor mperf appletouch applesmc
>> <4>[ 1755.556676]
>> <4>[ 1755.556682] Pid: 0, comm: swapper Not tainted 2.6.36-rc3 #3 Mac-F42187C8/MacBookPro2,2
>> <4>[ 1755.556688] RIP: 0010:[<ffffffffa0042bec>] [<ffffffffa0042bec>] hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>> <4>[ 1755.556705] RSP: 0018:ffff880001803ca8 EFLAGS: 00010092
>> <4>[ 1755.556710] RAX: 000000003df64001 RBX: 0000000000000014 RCX: 0000000000000014
>> <4>[ 1755.556716] RDX: ffff8800372018d8 RSI: 0000000000000002 RDI: ffff8800351ec240
>> <4>[ 1755.556722] RBP: ffff880001803cf8 R08: ffff88003df64001 R09: ffff88000180f398
>> <4>[ 1755.556728] R10: dead000000100100 R11: dead000000200200 R12: ffff8800351ec240
>> <4>[ 1755.556733] R13: 0000000000000002 R14: 000000003df64001 R15: 0000000000000001
>> <4>[ 1755.556740] FS: 0000000000000000(0000) GS:ffff880001800000(0000) knlGS:0000000000000000
>> <4>[ 1755.556746] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
>> <4>[ 1755.556752] CR2: ffff880224d0c548 CR3: 0000000001608000 CR4: 00000000000006f0
>> <4>[ 1755.556758] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
>> <4>[ 1755.556763] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
>> <4>[ 1755.556770] Process swapper (pid: 0, threadinfo ffffffff815f0000, task ffffffff81610020)
>> <0>[ 1755.556774] Stack:
>> <4>[ 1755.556778] ffffea0000b9fdc8 ffff88003df64000 ffff8800372018d8 ffffffffa00a189f
>> <4>[ 1755.556787]<0> ffff880001803d08 0000000000000014 0000000000000002 ffff8800372018d8
>> <4>[ 1755.556797]<0> ffff8800351ec240 0000000000000001 ffff880001803d38 ffffffffa0042dc5
>> <0>[ 1755.556809] Call Trace:
>> <0>[ 1755.556813]<IRQ>
>> <4>[ 1755.556825] [<ffffffffa00a189f>] ? uhci_free_urb_priv+0xa6/0xb3 [uhci_hcd]
>> <4>[ 1755.556839] [<ffffffffa0042dc5>] hci_recv_fragment+0x47/0x65 [bluetooth]
>> <4>[ 1755.556851] [<ffffffffa00705ee>] btusb_bulk_complete+0x56/0xd6 [btusb]
>> <4>[ 1755.556862] [<ffffffff812c1df9>] usb_hcd_giveback_urb+0x5d/0x8d
>> <4>[ 1755.556873] [<ffffffffa00a217b>] uhci_giveback_urb+0x11a/0x1a9 [uhci_hcd]
>> <4>[ 1755.556884] [<ffffffffa00a2a1a>] uhci_scan_schedule+0x544/0x84e [uhci_hcd]
>> <4>[ 1755.556896] [<ffffffffa00a3343>] uhci_irq+0xee/0x104 [uhci_hcd]
>> <4>[ 1755.556903] [<ffffffff812c1a08>] usb_hcd_irq+0x43/0x79
>> <4>[ 1755.556913] [<ffffffff81098c0b>] handle_IRQ_event+0x6e/0x14b
>> <4>[ 1755.556922] [<ffffffff8109aa52>] handle_fasteoi_irq+0x92/0xd2
>> <4>[ 1755.556931] [<ffffffff81029ab6>] handle_irq+0x86/0x8c
>> <4>[ 1755.556938] [<ffffffff8102975c>] do_IRQ+0x57/0xbe
>> <4>[ 1755.556948] [<ffffffff813ecb93>] ret_from_intr+0x0/0x11
>> <0>[ 1755.556952]<EOI>
>> <4>[ 1755.556966] [<ffffffffa0022e7b>] ? acpi_idle_enter_bm+0x252/0x28a [processor]
>> <4>[ 1755.556979] [<ffffffffa0022e74>] ? acpi_idle_enter_bm+0x24b/0x28a [processor]
>> <4>[ 1755.556988] [<ffffffff8130a5d5>] ? menu_select+0x16f/0x296
>> <4>[ 1755.556996] [<ffffffff81309501>] cpuidle_idle_call+0x9f/0x119
>> <4>[ 1755.557004] [<ffffffff81025db4>] cpu_idle+0x62/0xc5
>> <4>[ 1755.557014] [<ffffffff813d1bd4>] rest_init+0x68/0x6a
>> <4>[ 1755.557024] [<ffffffff8168cb7b>] start_kernel+0x365/0x370
>> <4>[ 1755.557033] [<ffffffff8168c2a6>] x86_64_start_reservations+0xad/0xb1
>> <4>[ 1755.557042] [<ffffffff8168c140>] ? early_idt_handler+0x0/0x71
>> <4>[ 1755.557050] [<ffffffff8168c3a3>] x86_64_start_kernel+0xf9/0x108
>> <0>[ 1755.557055] Code: 41 5c 41 5d 41 5e c9 c3 55 49 63 c0 48 89 e5 41 57 41 56 45 89 c6 41 55 41 89 f5 41 54 49 89 fc 53 89 cb 48 83 ec 28 48 89 55 c0<48> 8b 94 c7 00 03 00 00 48 85 d2 0f 85 61 01 00 00 41 8d 45 fe
>> <1>[ 1755.557139] RIP [<ffffffffa0042bec>] hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>> <4>[ 1755.557154] RSP<ffff880001803ca8>
>> <0>[ 1755.557158] CR2: ffff880224d0c548
>> <4>[ 1755.557164] ---[ end trace 6c64514f0ad01ea5 ]---
>> <0>[ 1755.557169] Kernel panic - not syncing: Fatal exception in interrupt
>> <4>[ 1755.557176] Pid: 0, comm: swapper Tainted: G D 2.6.36-rc3 #3
>> <4>[ 1755.557180] Call Trace:
>> <4>[ 1755.557183]<IRQ> [<ffffffff813e47d2>] panic+0x8c/0x189
>> <4>[ 1755.557199] [<ffffffff813ed90c>] oops_end+0x87/0x94
>> <4>[ 1755.557206] [<ffffffff813e4737>] no_context+0x1f4/0x203
>> <4>[ 1755.557216] [<ffffffff8104487f>] __bad_area_nosemaphore+0x17f/0x1a2
>> <4>[ 1755.557224] [<ffffffff810448b0>] bad_area_nosemaphore+0xe/0x10
>> <4>[ 1755.557233] [<ffffffff813ef9fd>] do_page_fault+0x1ee/0x3c2
>> <4>[ 1755.557243] [<ffffffff810e4748>] ? check_object+0x151/0x202
>> <4>[ 1755.557254] [<ffffffffa00a336f>] ? uhci_alloc_td.isra.22+0x16/0x44 [uhci_hcd]
>> <4>[ 1755.557265] [<ffffffffa00a3b17>] ? uhci_submit_common.isra.24+0x233/0x2d3 [uhci_hcd]
>> <4>[ 1755.557273] [<ffffffff813ecde5>] page_fault+0x25/0x30
>> <4>[ 1755.557287] [<ffffffffa0042bec>] ? hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>> <4>[ 1755.557298] [<ffffffffa00a189f>] ? uhci_free_urb_priv+0xa6/0xb3 [uhci_hcd]
>> <4>[ 1755.557311] [<ffffffffa0042dc5>] hci_recv_fragment+0x47/0x65 [bluetooth]
>> <4>[ 1755.557322] [<ffffffffa00705ee>] btusb_bulk_complete+0x56/0xd6 [btusb]
>> <4>[ 1755.557330] [<ffffffff812c1df9>] usb_hcd_giveback_urb+0x5d/0x8d
>> <4>[ 1755.557340] [<ffffffffa00a217b>] uhci_giveback_urb+0x11a/0x1a9 [uhci_hcd]
>> <4>[ 1755.557351] [<ffffffffa00a2a1a>] uhci_scan_schedule+0x544/0x84e [uhci_hcd]
>> <4>[ 1755.557362] [<ffffffffa00a3343>] uhci_irq+0xee/0x104 [uhci_hcd]
>> <4>[ 1755.557369] [<ffffffff812c1a08>] usb_hcd_irq+0x43/0x79
>> <4>[ 1755.557377] [<ffffffff81098c0b>] handle_IRQ_event+0x6e/0x14b
>> <4>[ 1755.557386] [<ffffffff8109aa52>] handle_fasteoi_irq+0x92/0xd2
>> <4>[ 1755.557393] [<ffffffff81029ab6>] handle_irq+0x86/0x8c
>> <4>[ 1755.557401] [<ffffffff8102975c>] do_IRQ+0x57/0xbe
>> <4>[ 1755.557408] [<ffffffff813ecb93>] ret_from_intr+0x0/0x11
>> <4>[ 1755.557413]<EOI> [<ffffffffa0022e7b>] ? acpi_idle_enter_bm+0x252/0x28a [processor]
>> <4>[ 1755.557420] [<ffffffffa0022e74>] ? acpi_idle_enter_bm+0x24b/0x28a [processor]
>> <4>[ 1755.557420] [<ffffffff8130a5d5>] ? menu_select+0x16f/0x296
>> <4>[ 1755.557420] [<ffffffff81309501>] cpuidle_idle_call+0x9f/0x119> <4>[ 1755.557420] [<ffffffff81025db4>] cpu_idle+0x62/0xc5> <4>[ 1755.557420] [<ffffffff813d1bd4>] rest_init+0x68/0x6a> <4>[ 1755.557420] [<ffffffff8168cb7b>] start_kernel+0x365/0x370
>> <4>[ 1755.557420] [<ffffffff8168c2a6>] x86_64_start_reservations+0xad/0xb1
>> <4>[ 1755.557420] [<ffffffff8168c140>] ? early_idt_handler+0x0/0x71
>> <4>[ 1755.557420] [<ffffffff8168c3a3>] x86_64_start_kernel+0xf9/0x108
>
> Suraj, do you have any idea on that?
>
let me know if you guys need any info about this(vary reproducible from
here)
Justin P. Mattock
^ permalink raw reply
* [PATCH] Bluetooth: fix MTU L2CAP configuration parameter
From: Emeltchenko Andrei @ 2010-09-01 12:17 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
When receiving L2CAP negative configuration response with respect
to MTU parameter we modify wrong field. MTU here means proposed
value of MTU that the remote device intends to transmit. So for local
L2CAP socket it is pi->imtu.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
---
net/bluetooth/l2cap.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index c784703..9fad312 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -2771,10 +2771,10 @@ static int l2cap_parse_conf_rsp(struct sock *sk, void *rsp, int len, void *data,
case L2CAP_CONF_MTU:
if (val < L2CAP_DEFAULT_MIN_MTU) {
*result = L2CAP_CONF_UNACCEPT;
- pi->omtu = L2CAP_DEFAULT_MIN_MTU;
+ pi->imtu = L2CAP_DEFAULT_MIN_MTU;
} else
- pi->omtu = val;
- l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->omtu);
+ pi->imtu = val;
+ l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->imtu);
break;
case L2CAP_CONF_FLUSH_TO:
--
1.7.0.4
^ permalink raw reply related
* [PATCH] Add handling for more than one address in vCard
From: Rafał Michalski @ 2010-09-01 11:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Rafał Michalski
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 0001-Add-handling-for-more-than-one-address-in-vCard.patch --]
[-- Type: text/x-patch, Size: 14399 bytes --]
From 43270b7ca9e0b54b976a40162c6ad7c062cb206a Mon Sep 17 00:00:00 2001
From: Rafal Michalski <michalski.raf@gmail.com>
Date: Wed, 1 Sep 2010 13:07:12 +0200
Subject: [PATCH] Add handling for more than one address in vCard
After pulling contacts only fields (pobox, extended, street, locality,
region, postal, country) of one address were present in downloaded vCard
structure (under ADR tag) in spite of that there can be more adresses
stored on phonebook. To solve this problem extending number of columns and
queries of database was needed especially. Distinguish between two types
of address (HOME and WORK) is supported.
---
plugins/phonebook-tracker.c | 93 ++++++++++++++++++++++++++++++++++++------
plugins/vcard.c | 89 ++++++++++++++++++++++++++++++++++-------
plugins/vcard.h | 15 ++++++-
3 files changed, 167 insertions(+), 30 deletions(-)
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index bff85b8..193226f 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -43,16 +43,17 @@
#define TRACKER_RESOURCES_INTERFACE "org.freedesktop.Tracker1.Resources"
#define TRACKER_DEFAULT_CONTACT_ME "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#default-contact-me"
-#define CONTACTS_ID_COL 28
-#define PULL_QUERY_COL_AMOUNT 29
+#define CONTACTS_ID_COL 35
+#define PULL_QUERY_COL_AMOUNT 36
#define COL_HOME_NUMBER 0
#define COL_HOME_EMAIL 7
#define COL_WORK_NUMBER 8
#define COL_FAX_NUMBER 16
#define COL_WORK_EMAIL 17
-#define COL_DATE 25
-#define COL_SENT 26
-#define COL_ANSWERED 27
+#define COL_DATE 32
+#define COL_SENT 33
+#define COL_ANSWERED 34
+#define ADDR_FIELD_AMOUNT 7
#define CONTACTS_QUERY_ALL \
"SELECT ?v nco:fullname(?c) " \
@@ -64,7 +65,9 @@
"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew) " \
"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) " \
"nco:photo(?c) nco:fullname(?o) nco:department(?a) " \
- "nco:role(?a) " \
+ "nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) " \
+ "nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) " \
+ "nco:postalcode(?pw) nco:country(?pw) " \
"\"NOTACALL\" \"false\" \"false\" ?c " \
"WHERE { " \
"?c a nco:PersonContact . " \
@@ -84,6 +87,7 @@
"?c nco:hasAffiliation ?a . " \
"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " \
"OPTIONAL { ?a nco:hasEmailAddress ?ew . } " \
+ "OPTIONAL { ?a nco:hasPostalAddress ?pw . } " \
"OPTIONAL { ?a nco:org ?o . } " \
"} " \
"}"
@@ -112,7 +116,9 @@
"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew) " \
"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) " \
"nco:photo(?c) nco:fullname(?o) nco:department(?a) " \
- "nco:role(?a) " \
+ "nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) " \
+ "nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) " \
+ "nco:postalcode(?pw) nco:country(?pw) " \
"nmo:receivedDate(?call) " \
"nmo:isSent(?call) nmo:isAnswered(?call) ?c " \
"WHERE { " \
@@ -133,6 +139,7 @@
"?c nco:hasAffiliation ?a . " \
"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " \
"OPTIONAL { ?a nco:hasEmailAddress ?ew . } " \
+ "OPTIONAL { ?a nco:hasPostalAddress ?pw . } " \
"OPTIONAL { ?a nco:org ?o . } " \
"} " \
"} ORDER BY DESC(nmo:receivedDate(?call))"
@@ -161,7 +168,9 @@
"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew) " \
"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) " \
"nco:photo(?c) nco:fullname(?o) nco:department(?a) " \
- "nco:role(?a) " \
+ "nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) " \
+ "nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) " \
+ "nco:postalcode(?pw) nco:country(?pw) " \
"nmo:receivedDate(?call) " \
"nmo:isSent(?call) nmo:isAnswered(?call) ?c " \
"WHERE { " \
@@ -182,6 +191,7 @@
"?c nco:hasAffiliation ?a . " \
"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " \
"OPTIONAL { ?a nco:hasEmailAddress ?ew . } " \
+ "OPTIONAL { ?a nco:hasPostalAddress ?pw . } " \
"OPTIONAL { ?a nco:org ?o . } " \
"} " \
"} ORDER BY DESC(nmo:receivedDate(?call))"
@@ -210,7 +220,9 @@
"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew)" \
"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) " \
"nco:photo(?c) nco:fullname(?o) nco:department(?a) " \
- "nco:role(?a) " \
+ "nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) " \
+ "nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) " \
+ "nco:postalcode(?pw) nco:country(?pw) " \
"nmo:receivedDate(?call) " \
"nmo:isSent(?call) nmo:isAnswered(?call) ?c " \
"WHERE { " \
@@ -230,6 +242,7 @@
"?c nco:hasAffiliation ?a . " \
"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " \
"OPTIONAL { ?a nco:hasEmailAddress ?ew . } " \
+ "OPTIONAL { ?a nco:hasPostalAddress ?pw . } " \
"OPTIONAL { ?a nco:org ?o . } " \
"} " \
"} ORDER BY DESC(nmo:sentDate(?call))"
@@ -257,7 +270,9 @@
"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew) " \
"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) " \
"nco:photo(?c) nco:fullname(?o) nco:department(?a) " \
- "nco:role(?a) " \
+ "nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) " \
+ "nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) " \
+ "nco:postalcode(?pw) nco:country(?pw) " \
"nmo:receivedDate(?call) " \
"nmo:isSent(?call) nmo:isAnswered(?call) ?c " \
"WHERE { " \
@@ -277,6 +292,7 @@
"OPTIONAL { ?c nco:hasAffiliation ?a . " \
"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " \
"OPTIONAL { ?a nco:hasEmailAddress ?ew . } " \
+ "OPTIONAL { ?a nco:hasPostalAddress ?pw . } " \
"OPTIONAL { ?a nco:org ?o . } " \
"} " \
"} UNION { " \
@@ -295,6 +311,7 @@
"OPTIONAL { ?c nco:hasAffiliation ?a . " \
"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " \
"OPTIONAL { ?a nco:hasEmailAddress ?ew . } " \
+ "OPTIONAL { ?a nco:hasPostalAddress ?pw . } " \
"OPTIONAL { ?a nco:org ?o . } " \
"} " \
"} } ORDER BY DESC(nmo:receivedDate(?call))"
@@ -329,7 +346,9 @@
"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew)" \
"nco:birthDate(<%s>) nco:nickname(<%s>) nco:websiteUrl(<%s>) " \
"nco:photo(<%s>) nco:fullname(?o) nco:department(?a) " \
- "nco:role(?a) " \
+ "nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) " \
+ "nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) " \
+ "nco:postalcode(?pw) nco:country(?pw) " \
"\"NOTACALL\" \"false\" \"false\" <%s> " \
"WHERE { " \
"<%s> a nco:Contact . " \
@@ -349,6 +368,7 @@
"<%s> nco:hasAffiliation ?a . " \
"OPTIONAL { ?a nco:hasPhoneNumber ?w . }" \
"OPTIONAL { ?a nco:hasEmailAddress ?ew . }" \
+ "OPTIONAL { ?a nco:hasPostalAddress ?pw . } " \
"OPTIONAL { ?a nco:org ?o . } " \
"} " \
"}"
@@ -721,6 +741,41 @@ static void add_email(struct phonebook_contact *contact, const char *address,
contact->emails = g_slist_append(contact->emails, email);
}
+static struct phonebook_address *find_address(GSList *addresses,
+ const char *address, int type)
+{
+ GSList *l;
+
+ for (l = addresses; l; l = l->next) {
+ struct phonebook_address *addr = l->data;
+ if (g_strcmp0(addr->addr, address) == 0 &&
+ addr->type == type)
+ return addr;
+ }
+
+ return NULL;
+}
+
+static void add_address(struct phonebook_contact *contact,
+ const char *address, int type)
+{
+ struct phonebook_address *addr;
+
+ if (address == NULL || address_fields_present(address) == FALSE)
+ return;
+
+ /* Not adding address if there is already added with the same value */
+ if (find_address(contact->addresses, address, type))
+ return;
+
+ addr = g_new0(struct phonebook_address, 1);
+
+ addr->addr = g_strdup(address);
+ addr->type = type;
+
+ contact->addresses = g_slist_append(contact->addresses, addr);
+}
+
static GString *gen_vcards(GSList *contacts,
const struct apparam_field *params)
{
@@ -753,6 +808,7 @@ static void pull_contacts(char **reply, int num_fields, void *user_data)
GString *vcards;
int last_index, i;
gboolean cdata_present = FALSE;
+ char *home_addr, *work_addr;
DBG("reply %p", reply);
@@ -803,9 +859,6 @@ add_entry:
contact->additional = g_strdup(reply[4]);
contact->prefix = g_strdup(reply[5]);
contact->suffix = g_strdup(reply[6]);
- contact->address = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
- reply[9], reply[10], reply[11], reply[12],
- reply[13], reply[14], reply[15]);
contact->birthday = g_strdup(reply[18]);
contact->nickname = g_strdup(reply[19]);
contact->website = g_strdup(reply[20]);
@@ -827,6 +880,18 @@ add_numbers:
add_email(contact, reply[COL_HOME_EMAIL], EMAIL_TYPE_HOME);
add_email(contact, reply[COL_WORK_EMAIL], EMAIL_TYPE_WORK);
+ /* Adding addresses */
+ home_addr = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
+ reply[9], reply[10], reply[11], reply[12],
+ reply[13], reply[14], reply[15]);
+
+ work_addr = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
+ reply[25], reply[26], reply[27], reply[28],
+ reply[29], reply[30], reply[31]);
+
+ add_address(contact, home_addr, ADDR_TYPE_HOME);
+ add_address(contact, work_addr, ADDR_TYPE_WORK);
+
DBG("contact %p", contact);
/* Adding contacts data to wrapper struct - this data will be used to
diff --git a/plugins/vcard.c b/plugins/vcard.c
index 33a1ede..6d74e06 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -156,21 +156,20 @@ static gboolean contact_fields_present(struct phonebook_contact * contact)
return FALSE;
}
-static gboolean address_fields_present(struct phonebook_contact *contact)
+gboolean address_fields_present(const char *address)
{
- gchar **address_fields = g_strsplit(contact->address, ";",
- ADDR_FIELD_AMOUNT);
- int i = 0;
+ gchar **fields = g_strsplit(address, ";", ADDR_FIELD_AMOUNT);
+ int i;
- for (; i < ADDR_FIELD_AMOUNT; ++i) {
+ for (i = 0; i < ADDR_FIELD_AMOUNT; ++i) {
- if (strlen(address_fields[i]) != 0) {
- g_strfreev(address_fields);
+ if (strlen(fields[i]) != 0) {
+ g_strfreev(fields);
return TRUE;
}
}
- g_strfreev(address_fields);
+ g_strfreev(fields);
return FALSE;
}
@@ -376,15 +375,54 @@ static void vcard_printf_org(GString *vcards,
contact->department, contact->title);
}
-static void vcard_printf_adr(GString *vcards,
- struct phonebook_contact *contact)
+static void vcard_printf_address(GString *vcards, uint8_t format,
+ const char *address,
+ enum phonebook_address_type category)
{
- if (address_fields_present(contact) == FALSE) {
+ char buf[LEN_MAX];
+ char field[ADDR_FIELD_AMOUNT][LEN_MAX];
+ const char *category_string = "";
+ int len, i;
+ gchar **address_fields;
+
+ if (!address || address_fields_present(address) == FALSE) {
vcard_printf(vcards, "ADR:");
return;
}
- vcard_printf(vcards, "ADR:%s", contact->address);
+ switch (category) {
+ case ADDR_TYPE_HOME:
+ if (format == FORMAT_VCARD21)
+ category_string = "HOME";
+ else if (format == FORMAT_VCARD30)
+ category_string = "TYPE=HOME";
+ break;
+ case ADDR_TYPE_WORK:
+ if (format == FORMAT_VCARD21)
+ category_string = "WORK";
+ else if (format == FORMAT_VCARD30)
+ category_string = "TYPE=WORK";
+ break;
+ default:
+ if (format == FORMAT_VCARD21)
+ category_string = "OTHER";
+ else if (format == FORMAT_VCARD30)
+ category_string = "TYPE=OTHER";
+ break;
+ }
+
+ address_fields = g_strsplit(address, ";", ADDR_FIELD_AMOUNT);
+
+ for (i = 0; i < ADDR_FIELD_AMOUNT; ++i) {
+ len = strlen(address_fields[i]);
+ add_slash(field[i], address_fields[i], LEN_MAX, len);
+ }
+
+ snprintf(buf, LEN_MAX, "%s;%s;%s;%s;%s;%s;%s",
+ field[0], field[1], field[2], field[3], field[4], field[5], field[6]);
+ g_strfreev(address_fields);
+
+ vcard_printf(vcards,"ADR;%s:%s", category_string, buf);
}
static void vcard_printf_datetime(GString *vcards,
@@ -465,8 +503,19 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
}
}
- if (filter & FILTER_ADR)
- vcard_printf_adr(vcards, contact);
+ if (filter & FILTER_ADR) {
+ GSList *l = contact->addresses;
+
+ if (g_slist_length(l) == 0)
+ vcard_printf_address(vcards, format, NULL,
+ ADDR_TYPE_OTHER);
+
+ for (; l; l = l->next) {
+ struct phonebook_address *addr = l->data;
+ vcard_printf_address(vcards, format, addr->addr,
+ addr->type);
+ }
+ }
if (filter & FILTER_BDAY)
vcard_printf_tag(vcards, format, "BDAY", NULL,
@@ -509,6 +558,14 @@ static void email_free(gpointer data, gpointer user_data)
g_free(email);
}
+static void address_free(gpointer data, gpointer user_data)
+{
+ struct phonebook_address *addr = data;
+
+ g_free(addr->addr);
+ g_free(addr);
+}
+
void phonebook_contact_free(struct phonebook_contact *contact)
{
if (contact == NULL)
@@ -520,13 +577,15 @@ void phonebook_contact_free(struct phonebook_contact *contact)
g_slist_foreach(contact->emails, email_free, NULL);
g_slist_free(contact->emails);
+ g_slist_foreach(contact->addresses, address_free, NULL);
+ g_slist_free(contact->addresses);
+
g_free(contact->fullname);
g_free(contact->given);
g_free(contact->family);
g_free(contact->additional);
g_free(contact->prefix);
g_free(contact->suffix);
- g_free(contact->address);
g_free(contact->birthday);
g_free(contact->nickname);
g_free(contact->website);
diff --git a/plugins/vcard.h b/plugins/vcard.h
index b1e971e..d012106 100644
--- a/plugins/vcard.h
+++ b/plugins/vcard.h
@@ -40,6 +40,12 @@ enum phonebook_call_type {
CALL_TYPE_OUTGOING,
};
+enum phonebook_address_type {
+ ADDR_TYPE_HOME,
+ ADDR_TYPE_WORK,
+ ADDR_TYPE_OTHER,
+};
+
struct phonebook_number {
char *tel;
int type;
@@ -50,6 +56,11 @@ struct phonebook_email {
int type;
};
+struct phonebook_address {
+ char *addr;
+ int type;
+};
+
struct phonebook_contact {
char *fullname;
char *given;
@@ -59,7 +70,7 @@ struct phonebook_contact {
GSList *emails;
char *prefix;
char *suffix;
- char *address;
+ GSList *addresses;
char *birthday;
char *nickname;
char *website;
@@ -75,3 +86,5 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
uint64_t filter, uint8_t format);
void phonebook_contact_free(struct phonebook_contact *contact);
+
+gboolean address_fields_present(const char *address);
--
1.6.3.3
^ permalink raw reply related
* Re: [PATCH 2/2] Add handling for more than one address in vCard
From: Johan Hedberg @ 2010-09-01 10:48 UTC (permalink / raw)
To: Rafał Michalski; +Cc: linux-bluetooth
In-Reply-To: <AANLkTikGen9zKWdi=J558PXOBKhreu=WJ9_KCrQ=n_sx@mail.gmail.com>
Hi Rafal,
On Wed, Sep 01, 2010, Rafał Michalski wrote:
> +static struct phonebook_address *find_address(GSList *addresses,
> + const char *address, int type)
> +{
> + GSList *l = addresses;
> +
> + for (; l; l = l->next) {
Please avoid initialization upon declaration of variables when possible.
The first part of the for-statement is where you should usually
initialize the iterator, i.e. in this case do the l = addresses there.
> +static gboolean address_fields_present(const char *address)
> +{
> + gchar **address_fields = g_strsplit(address, ";",
> + ADDR_FIELD_AMOUNT);
> + int i = 0;
> +
> + for (; i < ADDR_FIELD_AMOUNT; ++i) {
Same here for i. Additionally you could rename address_fields to simply
fields since the function is short and the context pretty obvious.
You'll also avoid the split line that way (another thing I wouldn't
object to is to move the initialization separate from the variable
declaration).
> -static gboolean address_fields_present(struct phonebook_contact *contact)
> +static gboolean address_fields_present(const char *address)
> {
> - gchar **address_fields = g_strsplit(contact->address, ";",
> + gchar **address_fields = g_strsplit(address, ";",
> ADDR_FIELD_AMOUNT);
> int i = 0;
Hmm, it seems you have the same function in vcard.c and
phonebook-tracker.c? Why not remove the phonebook-tracker.c one and
export the vcard.c version through vcard.h?
Johan
^ permalink raw reply
* Re: [PATCH 1/2] Merging address fields to single field
From: Johan Hedberg @ 2010-09-01 10:36 UTC (permalink / raw)
To: Rafał Michalski; +Cc: linux-bluetooth
In-Reply-To: <AANLkTikL2mskaXPygeWvmdy6zjiRDExiq-yW+PaXoVsU@mail.gmail.com>
Hi Rafal,
On Wed, Sep 01, 2010, Rafał Michalski wrote:
> From: Rafal Michalski <michalski.raf@gmail.com>
> Date: Wed, 1 Sep 2010 11:49:28 +0200
> Subject: [PATCH 1/2] Merging address fields to single field
>
> So far in code all seven address fields (pobox, extended, street,
> locality, region, postal, country) was represented separately.
> In vCard structure address is represented by one field so all
> mentioned above fields are merged to single field.
> ---
> plugins/phonebook-tracker.c | 10 +++-------
> plugins/vcard.c | 41 ++++++++++++++++-------------------------
> plugins/vcard.h | 8 +-------
> 3 files changed, 20 insertions(+), 39 deletions(-)
Thanks. This patch is now upstream.
Johan
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox