Hi folks, On Fri, Feb 11, 2011 at 6:37 PM, Claudio Takahasi <claudio.takahasi@xxxxxxxxxxxxx> wrote: > Function to convert 128-bits values from little endian to host > order. Different than SDP, ATT uses little endian format. > --- > Âattrib/att.c   Â|  12 ++++++++---- > Âattrib/att.h   Â|  10 ++++++++++ > Âattrib/gatt.c   |  13 ++++++++----- > Âattrib/gatttool.c |  Â6 ++++-- > Â4 files changed, 30 insertions(+), 11 deletions(-) > > diff --git a/attrib/att.c b/attrib/att.c > index dff8597..5b851a2 100644 > --- a/attrib/att.c > +++ b/attrib/att.c > @@ -141,8 +141,10 @@ uint16_t dec_read_by_grp_req(const uint8_t *pdu, int len, uint16_t *start, >    Â*end = att_get_u16(&pdu[3]); >    Âif (len == min_len + 2) >        Âsdp_uuid16_create(uuid, att_get_u16(&pdu[5])); > -    else > -        sdp_uuid128_create(uuid, &pdu[5]); > +    else { > +        uint128_t h128 = att_get_u128(&pdu[5]); > +        sdp_uuid128_create(uuid, &h128); > +    } > >    Âreturn len; > Â} > @@ -370,8 +372,10 @@ uint16_t dec_read_by_type_req(const uint8_t *pdu, int len, uint16_t *start, > >    Âif (len == min_len + 2) >        Âsdp_uuid16_create(uuid, att_get_u16(&pdu[5])); > -    else > -        sdp_uuid128_create(uuid, &pdu[5]); > +    else { > +        uint128_t h128 = att_get_u128(&pdu[5]); > +        sdp_uuid128_create(uuid, &h128); > +    } > >    Âreturn len; > Â} > diff --git a/attrib/att.h b/attrib/att.h > index 7e81dc4..0cd6626 100644 > --- a/attrib/att.h > +++ b/attrib/att.h > @@ -170,6 +170,16 @@ static inline uint32_t att_get_u32(const void *ptr) >    Âreturn btohl(bt_get_unaligned(u32_ptr)); > Â} > > +static inline uint128_t att_get_u128(const void *ptr) Pass a uint128_t pointer or return the struct uint128_t? BR, Claudio > +{ > +    const uint128_t *u128_ptr = ptr; > +    uint128_t dst; > + > +    btoh128(u128_ptr, &dst); > + > +    return dst; > +} > + > Âstatic inline void att_put_u8(uint8_t src, void *dst) > Â{ >    Âbt_put_unaligned(src, (uint8_t *) dst); > diff --git a/attrib/gatt.c b/attrib/gatt.c > index b99d39c..3fedcc4 100644 > --- a/attrib/gatt.c > +++ b/attrib/gatt.c > @@ -174,9 +174,10 @@ static void primary_all_cb(guint8 status, const guint8 *ipdu, guint16 iplen, >                    Âatt_get_u16(&data[4])); >            Âsdp_uuid16_to_uuid128(&u128, &u16); > > -        } else if (list->len == 20) > -            sdp_uuid128_create(&u128, &data[4]); > -        else > +        } else if (list->len == 20) { > +            uint128_t h128 = att_get_u128(&data[4]); > +            sdp_uuid128_create(&u128, &h128); > +        } else >            Â/* Skipping invalid data */ >            Âcontinue; > > @@ -271,8 +272,10 @@ static void char_discovered_cb(guint8 status, const guint8 *ipdu, guint16 iplen, >        Âif (list->len == 7) { >            Âsdp_uuid16_create(&u16, att_get_u16(&value[5])); >            Âsdp_uuid16_to_uuid128(&u128, &u16); > -        } else > -            sdp_uuid128_create(&u128, &value[5]); > +        } else { > +            uint128_t h128 = att_get_u128(&value[5]); > +            sdp_uuid128_create(&u128, &h128); > +        } > >        Âchars = g_try_new0(struct att_char, 1); >        Âif (!chars) { > diff --git a/attrib/gatttool.c b/attrib/gatttool.c > index 8e8ed8e..6c9394e 100644 > --- a/attrib/gatttool.c > +++ b/attrib/gatttool.c > @@ -464,8 +464,10 @@ static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen, > >        Âif (format == 0x01) >            Âsdp_uuid16_create(&uuid, att_get_u16(&value[2])); > -        else > -            sdp_uuid128_create(&uuid, &value[2]); > +        else { > +            uint128_t h128 = att_get_u128(&value[2]); > +            sdp_uuid128_create(&uuid, &h128); > +        } > >        Âsdp_uuid2strn(&uuid, uuidstr, MAX_LEN_UUID_STR); >        Âg_print("handle = 0x%04x, uuid = %s\n", handle, uuidstr); > -- > 1.7.4 > > ÿô.nÇ·®+%˱é¥wÿº{.nÇ·¥{±ý¶â^nr¡öë¨è&£ûz¹Þúzf£¢·h§~Ûÿÿïÿê_èæ+v¨þ)ßø