All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
To: linux-bluetooth <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH 1/5] lib/uuid: Add uuid conversion to 16 bit uuid
Date: Mon, 4 May 2015 15:56:53 +0200	[thread overview]
Message-ID: <CAMv5Gbe2N53GZe=Q9o5P++sUGzdTMPNyV10xPaa7_4cr_NotoA@mail.gmail.com> (raw)
In-Reply-To: <1427973328-22329-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

ping

On 2 April 2015 at 13:15, Grzegorz Kolodziejczyk
<grzegorz.kolodziejczyk@tieto.com> wrote:
> This patch allows to cut bluetooth base if it's bluetooth base uuid.
> If the uuid is bluetooth base, src uuid can be converted, otherwise
> error is returned.
> ---
>  lib/uuid.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  lib/uuid.h |  1 +
>  2 files changed, 45 insertions(+)
>
> diff --git a/lib/uuid.c b/lib/uuid.c
> index fd61968..d2ad66d 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -73,6 +73,34 @@ static void bt_uuid32_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst)
>         memcpy(&dst->value.u128.data[BASE_UUID32_OFFSET], &be32, sizeof(be32));
>  }
>
> +static int bt_uuid128_to_uuid16(const bt_uuid_t *src, bt_uuid_t *dst)
> +{
> +       if (memcmp(&src->value.u128.data, &bluetooth_base_uuid.data, 2) ||
> +                                       memcmp(&src->value.u128.data[4],
> +                                       &bluetooth_base_uuid.data[4], 12))
> +               return -EINVAL;
> +
> +       dst->type = BT_UUID16;
> +
> +       memcpy(&dst->value.u16, &src->value.u128.data[BASE_UUID16_OFFSET],
> +                                                       sizeof(uint16_t));
> +
> +       return 0;
> +}
> +
> +static int bt_uuid32_to_uuid16(const bt_uuid_t *src, bt_uuid_t *dst)
> +{
> +       /* Bluetooth base have zeroized first two bytes */
> +       if (src->value.u32 & 0xffff0000)
> +               return -EINVAL;
> +
> +       dst->type = BT_UUID16;
> +
> +       dst->value.u16 = src->value.u32 & 0x0000ffff;
> +
> +       return 0;
> +}
> +
>  void bt_uuid_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst)
>  {
>         switch (src->type) {
> @@ -91,6 +119,22 @@ void bt_uuid_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst)
>         }
>  }
>
> +int bt_uuid_to_uuid16(const bt_uuid_t *src, bt_uuid_t *dst)
> +{
> +       switch (src->type) {
> +       case BT_UUID128:
> +               return bt_uuid128_to_uuid16(src, dst);
> +       case BT_UUID32:
> +               return bt_uuid32_to_uuid16(src, dst);
> +       case BT_UUID16:
> +               *dst = *src;
> +               return 0;
> +       case BT_UUID_UNSPEC:
> +       default:
> +               return -EINVAL;
> +       }
> +}
> +
>  static int bt_uuid128_cmp(const bt_uuid_t *u1, const bt_uuid_t *u2)
>  {
>         return memcmp(&u1->value.u128, &u2->value.u128, sizeof(uint128_t));
> diff --git a/lib/uuid.h b/lib/uuid.h
> index 2dcfe9e..26f8532 100644
> --- a/lib/uuid.h
> +++ b/lib/uuid.h
> @@ -161,6 +161,7 @@ int bt_uuid128_create(bt_uuid_t *btuuid, uint128_t value);
>
>  int bt_uuid_cmp(const bt_uuid_t *uuid1, const bt_uuid_t *uuid2);
>  void bt_uuid_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst);
> +int bt_uuid_to_uuid16(const bt_uuid_t *src, bt_uuid_t *dst);
>
>  #define MAX_LEN_UUID_STR 37
>
> --
> 2.1.0
>

      parent reply	other threads:[~2015-05-04 13:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 11:15 [PATCH 1/5] lib/uuid: Add uuid conversion to 16 bit uuid Grzegorz Kolodziejczyk
2015-04-02 11:15 ` [PATCH 2/5] profiles/network: Use lib/uuid instead of operating on raw bnep msg Grzegorz Kolodziejczyk
2015-04-02 11:15 ` [PATCH 3/5] lib/uuid: Modify bt_uuid_to_le return value to uuid len Grzegorz Kolodziejczyk
2015-04-02 11:15 ` [PATCH 4/5] shared/gatt-db: Use lib/uuid uuid_to_le function Grzegorz Kolodziejczyk
2015-04-02 11:15 ` [PATCH 5/5] shared/gatt-db: Convert uuid32 to uuid128 in le_to_uuid Grzegorz Kolodziejczyk
2015-05-04 13:56 ` Grzegorz Kolodziejczyk [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMv5Gbe2N53GZe=Q9o5P++sUGzdTMPNyV10xPaa7_4cr_NotoA@mail.gmail.com' \
    --to=grzegorz.kolodziejczyk@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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.