All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/1] Bluetooth: mgmt: Add helper function for Address Type
@ 2012-04-16  9:04 Hemant Gupta
  2012-04-16  9:04 ` [PATCH v1 1/1] Bluetooth: mgmt: Fix address type while loading Long Term Key Hemant Gupta
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Hemant Gupta @ 2012-04-16  9:04 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Hemant Gupta

This patch adds helper function for converting address type received
from user space to corresponding Address types as per BT spec.

Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
---
 net/bluetooth/mgmt.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 880b7c9..cb83644 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1644,6 +1644,25 @@ static u8 link_to_mgmt(u8 link_type, u8 addr_type)
 	}
 }
 
+static u8 mgmt_to_link(u8 link_type, u8 addr_type)
+{
+	switch (link_type) {
+	case LE_LINK:
+		switch (addr_type) {
+		case MGMT_ADDR_LE_PUBLIC:
+			return ADDR_LE_DEV_PUBLIC;
+
+		default:
+			/* Fallback to LE Random address type */
+			return ADDR_LE_DEV_RANDOM;
+		}
+
+	default:
+		/* Fallback to BR/EDR type */
+		return ACL_LINK;
+	}
+}
+
 static int get_connections(struct sock *sk, struct hci_dev *hdev, void *data,
 			   u16 data_len)
 {
-- 
1.7.0.4


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

* [PATCH v1 1/1] Bluetooth: mgmt: Fix address type while loading Long Term Key
  2012-04-16  9:04 [PATCH v1 0/1] Bluetooth: mgmt: Add helper function for Address Type Hemant Gupta
@ 2012-04-16  9:04 ` Hemant Gupta
  2012-04-16  9:13 ` [PATCH v1 0/1] Bluetooth: mgmt: Add helper function for Address Type Hemant Gupta
  2012-04-16  9:19 ` Johan Hedberg
  2 siblings, 0 replies; 5+ messages in thread
From: Hemant Gupta @ 2012-04-16  9:04 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Hemant Gupta

This patch fixes the address type while loading long term keys when BT is
switched on. Without this fix pairing is reinitated even though LTK exists
for remote device because of mismatch of address type.

Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
---
 net/bluetooth/mgmt.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 880b7c9..b84de64 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2652,7 +2652,8 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
 		else
 			type = HCI_SMP_LTK_SLAVE;
 
-		hci_add_ltk(hdev, &key->addr.bdaddr, key->addr.type,
+		hci_add_ltk(hdev, &key->addr.bdaddr,
+			    mgmt_to_link(LE_LINK, key->addr.type),
 			    type, 0, key->authenticated, key->val,
 			    key->enc_size, key->ediv, key->rand);
 	}
-- 
1.7.0.4


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

* Re: [PATCH v1 0/1] Bluetooth: mgmt: Add helper function for Address Type
  2012-04-16  9:04 [PATCH v1 0/1] Bluetooth: mgmt: Add helper function for Address Type Hemant Gupta
  2012-04-16  9:04 ` [PATCH v1 1/1] Bluetooth: mgmt: Fix address type while loading Long Term Key Hemant Gupta
@ 2012-04-16  9:13 ` Hemant Gupta
  2012-04-16  9:19 ` Johan Hedberg
  2 siblings, 0 replies; 5+ messages in thread
From: Hemant Gupta @ 2012-04-16  9:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Hemant Gupta

Hi,

On Mon, Apr 16, 2012 at 2:34 PM, Hemant Gupta
<hemant.gupta@stericsson.com> wrote:
> This patch adds helper function for converting address type received
> from user space to corresponding Address types as per BT spec.
>
> Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
> ---
>  net/bluetooth/mgmt.c |   19 +++++++++++++++++++
>  1 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 880b7c9..cb83644 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -1644,6 +1644,25 @@ static u8 link_to_mgmt(u8 link_type, u8 addr_type)
>        }
>  }
>
> +static u8 mgmt_to_link(u8 link_type, u8 addr_type)
> +{
> +       switch (link_type) {
> +       case LE_LINK:
> +               switch (addr_type) {
> +               case MGMT_ADDR_LE_PUBLIC:
> +                       return ADDR_LE_DEV_PUBLIC;
> +
> +               default:
> +                       /* Fallback to LE Random address type */
> +                       return ADDR_LE_DEV_RANDOM;
> +               }
> +
> +       default:
> +               /* Fallback to BR/EDR type */
> +               return ACL_LINK;
> +       }
> +}
> +
>  static int get_connections(struct sock *sk, struct hci_dev *hdev, void *data,
>                           u16 data_len)
>  {
> --
> 1.7.0.4
>
> --
> 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

Please ignore this patch, as compiler warning is generated because of
non usage of static function, will send a new single patch shortly

-- 
Best Regards
Hemant Gupta
ST-Ericsson India

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

* Re: [PATCH v1 0/1] Bluetooth: mgmt: Add helper function for Address Type
  2012-04-16  9:04 [PATCH v1 0/1] Bluetooth: mgmt: Add helper function for Address Type Hemant Gupta
  2012-04-16  9:04 ` [PATCH v1 1/1] Bluetooth: mgmt: Fix address type while loading Long Term Key Hemant Gupta
  2012-04-16  9:13 ` [PATCH v1 0/1] Bluetooth: mgmt: Add helper function for Address Type Hemant Gupta
@ 2012-04-16  9:19 ` Johan Hedberg
  2012-04-16  9:21   ` Hemant Gupta
  2 siblings, 1 reply; 5+ messages in thread
From: Johan Hedberg @ 2012-04-16  9:19 UTC (permalink / raw)
  To: Hemant Gupta; +Cc: linux-bluetooth

Hi Hemant,

On Mon, Apr 16, 2012, Hemant Gupta wrote:
> +static u8 mgmt_to_link(u8 link_type, u8 addr_type)
> +{
> +	switch (link_type) {
> +	case LE_LINK:
> +		switch (addr_type) {
> +		case MGMT_ADDR_LE_PUBLIC:
> +			return ADDR_LE_DEV_PUBLIC;
> +
> +		default:
> +			/* Fallback to LE Random address type */
> +			return ADDR_LE_DEV_RANDOM;
> +		}
> +
> +	default:
> +		/* Fallback to BR/EDR type */
> +		return ACL_LINK;
> +	}
> +}

This isn't right. The mgmt address type includes all possible address
types in it, i.e. the input to this function should be a single value
and the output should be two separate values (just like link_to_mgmt has
two inputs and one output).

However, I'm not sure you even need this generic helper here since you
only have a single user for it and it's restricted to LE only. If we get
more users then we can consider it, but for now either do the conversion
inline or do an LE specific helper:

static u8 mgmt_to_le(u8 mgmt_type)
{
	switch (mgmt_type) {
	case MGMT_ADDR_LE_PUBLIC:
		return ADDR_LE_DEV_PUBLIC;
	case MGMT_ADDR_LE_RANDOM:
	default:
		return ADDR_LE_DEV_RANDOM;
}

Johan

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

* Re: [PATCH v1 0/1] Bluetooth: mgmt: Add helper function for Address Type
  2012-04-16  9:19 ` Johan Hedberg
@ 2012-04-16  9:21   ` Hemant Gupta
  0 siblings, 0 replies; 5+ messages in thread
From: Hemant Gupta @ 2012-04-16  9:21 UTC (permalink / raw)
  To: Hemant Gupta, linux-bluetooth

Hi Johan,

On Mon, Apr 16, 2012 at 2:49 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Hemant,
>
> On Mon, Apr 16, 2012, Hemant Gupta wrote:
>> +static u8 mgmt_to_link(u8 link_type, u8 addr_type)
>> +{
>> +     switch (link_type) {
>> +     case LE_LINK:
>> +             switch (addr_type) {
>> +             case MGMT_ADDR_LE_PUBLIC:
>> +                     return ADDR_LE_DEV_PUBLIC;
>> +
>> +             default:
>> +                     /* Fallback to LE Random address type */
>> +                     return ADDR_LE_DEV_RANDOM;
>> +             }
>> +
>> +     default:
>> +             /* Fallback to BR/EDR type */
>> +             return ACL_LINK;
>> +     }
>> +}
>
> This isn't right. The mgmt address type includes all possible address
> types in it, i.e. the input to this function should be a single value
> and the output should be two separate values (just like link_to_mgmt has
> two inputs and one output).
>
> However, I'm not sure you even need this generic helper here since you
> only have a single user for it and it's restricted to LE only. If we get
> more users then we can consider it, but for now either do the conversion
> inline or do an LE specific helper:
>
> static u8 mgmt_to_le(u8 mgmt_type)
> {
>        switch (mgmt_type) {
>        case MGMT_ADDR_LE_PUBLIC:
>                return ADDR_LE_DEV_PUBLIC;
>        case MGMT_ADDR_LE_RANDOM:
>        default:
>                return ADDR_LE_DEV_RANDOM;
> }
>
Thanks for the comemnts, will send new patch shortly.
> 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



-- 
Best Regards
Hemant Gupta
ST-Ericsson India

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

end of thread, other threads:[~2012-04-16  9:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-16  9:04 [PATCH v1 0/1] Bluetooth: mgmt: Add helper function for Address Type Hemant Gupta
2012-04-16  9:04 ` [PATCH v1 1/1] Bluetooth: mgmt: Fix address type while loading Long Term Key Hemant Gupta
2012-04-16  9:13 ` [PATCH v1 0/1] Bluetooth: mgmt: Add helper function for Address Type Hemant Gupta
2012-04-16  9:19 ` Johan Hedberg
2012-04-16  9:21   ` Hemant Gupta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.