Date: Sun, 29 Mar 2015 20:48:15 -0700 From: Waitman Gobble <gobble.wa@gmail.com> To: Maksim Yevmenkin <maksim.yevmenkin@gmail.com> Cc: "freebsd-bluetooth@freebsd.org" <freebsd-bluetooth@freebsd.org>, Iain Hibbert <plunky@ogmig.net> Subject: Re: register HID with SDP error Message-ID: <CAFuo_fyYyoX6rNwN6_TfB01_xp5EQHFu-CJG=_dab_Qe7x1hkA@mail.gmail.com> In-Reply-To: <CAFuo_fzRGc0_yrHYyqcfLrWX7q3AuLwA3v%2B9_QRTirU-Bx4xkw@mail.gmail.com> References: <CAFuo_fy9xRU2T3GUPY8116yZCUd8sL9pBQ9ixXnMwO56niJFog@mail.gmail.com> <CAFuo_fzdmB79qdoH8P5EcO_ZZoa=_id6h=eqFBXvP_a%2B3WMkLw@mail.gmail.com> <CAFuo_fzB3A5L3vivH7Z80OEoBtVEHftEYE4LUkhnrkguzL5GDA@mail.gmail.com> <CAFuo_fzrk%2BWLXivZrnTsGQD%2BS7mq%2BUSXB7Mn6%2BJT=y64JakGSw@mail.gmail.com> <CAFPOs6q3iVcNthF=S--UgTm=5wA0HM6coqB7AcmCKb=55OWdTQ@mail.gmail.com> <CAFuo_fxgBVKxmzbJs%2B-XDz%2Bu4tb2_i3eYXSa-oiOoU%2BQD6ApwQ@mail.gmail.com> <CAFPOs6r_D7bcGCMP_bP%2BQtZgKt7Oj5jRJ2v872RODekn%2B6xv1Q@mail.gmail.com> <CAFuo_fwPuaD4bYwfZou0RBswZsTmdtVZA1B2GqUdo3ZJJiWRQg@mail.gmail.com> <0AD7A2F7-37BE-4F6A-9FD6-F6C81B2CAF36@gmail.com> <CAFuo_fye5RWNtjsutHa%2BbXL0AYHYRpJxW-b=48o0iMwX227wdA@mail.gmail.com> <alpine.NEB.2.11.1503170658130.4414@galant.ogmig.net> <CAFuo_fx47uRC-eKD_KtsSsrMCQZauyHyCOgRxGbtp_WEZ49o_Q@mail.gmail.com> <alpine.NEB.2.11.1503171759510.4792@galant.ogmig.net> <CAFPOs6omaOOOumNk2Zg=YBgK9cy7JumOZ6k-89oTbVw-3PgAvg@mail.gmail.com> <CAFuo_fy%2BdmpcswwLMV3LaGGkN6VyQ%2B=ieEzYUT=omSLkhS8=EA@mail.gmail.com> <CAFuo_fwBcBQOZzFNntBSP0AwyAkGq=s-eeKJ1CCgjPp5tWdG=A@mail.gmail.com> <CAFPOs6rJJW2BC3rru%2Bvb5dAE0yaHGvr=0s8K9FZ1ee0rf-ML-w@mail.gmail.com> <CAFuo_fzRGc0_yrHYyqcfLrWX7q3AuLwA3v%2B9_QRTirU-Bx4xkw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 25, 2015 at 8:46 AM, Waitman Gobble <gobble.wa@gmail.com> wrote: > On Wed, Mar 25, 2015 at 8:16 AM, Maksim Yevmenkin > <maksim.yevmenkin@gmail.com> wrote: >> Hello, >> >> sorry for the delay... >> >>> Through trial and error I found that this code is preventing the >>> response to the 0x0100 (L2CAP) query. >>> >>> in sdpd/ssar.c around line 230 or so. >>> >>> if (memcmp(&uuid, &puuid, sizeof(uuid)) != 0 && >>> memcmp(&uuid, &uuid_public_browse_group, sizeof(uuid)) != 0) >>> continue; >> >> right. this is to match uuid from the request with the uuid of >> registered services, or, special case, uuid for public browse group >> that is expected to return everything that is public. >> >>> When I comment that code out then it responds to the request with the >>> list of registered and advertised services and my clients then >>> magically connect. >> >> well, that's plain just wrong. you completely disabled any filtering. >> basically request for any uuid will return everything. including >> things that client has not asked for. the correct way is to add a list >> of addition uuid's (such as l2cap uuid) to every profile that should >> be checked as well. when client makes request for l2cap uuid it >> effectively asking to give back everything that "runs over l2cap". >> >>> Can you please explain the purpose of that code so I can fully >>> understand what I'm commenting out of the provider lookup loop in >>> sdpd/ssar.c ? >> >> please read above. also please read SDP spec, particularly part that >> talks about Service Search Request and Service Search Attribute >> Request. >> >> thanks >> max > > Thanks Max, I appreciate your reply and helpful information. > I will experiment and see if I can get this right. > > -- > Waitman Gobble > Los Altos California USA > 510-830-7975 Hi, I'm not sure I'm getting it right.. in ssar.c, if the uuid query is L2CAP 0x0100 i set dol2capquery = 1; /* * Service Search Attribute Response format * * value16 - 2 bytes AttributeListByteCount (not incl.) * seq8 len16 - 3 bytes * attr list - 3+ bytes AttributeLists * [ attr list ] */ ptr = rsp + 3; while (ssplen > 0) { SDP_GET8(type, sspptr); ssplen --; switch (type) { case SDP_DATA_UUID16: if (ssplen < 2) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); memcpy(&uuid, &uuid_base, sizeof(uuid)); uuid.b[2] = *sspptr ++; uuid.b[3] = *sspptr ++; if ((uuid.b[2]==1) && (uuid.b[3]==0)) //0x0100 { dol2capquery = 1; } ssplen -= 2; break; Then while iterating through provider list, if the uuid matches something with l2cap then it sends back the response with those records. I don't think this should be 'hardcoded' in this way, but at the moment I'm tinkering. for (provider = provider_get_first(); provider != NULL; provider = provider_get_next(provider)) { if (!provider_match_bdaddr(provider, &srv->req_sa.l2cap_bdaddr)) continue; memcpy(&puuid, &uuid_base, sizeof(puuid)); puuid.b[2] = provider->profile->uuid >> 8; puuid.b[3] = provider->profile->uuid; if (dol2capquery) { switch (provider->profile->uuid) { case 0x1124: /* HID */ case 0x1200: /* PNP */ break; default: continue; break; } } else { if (memcmp(&uuid, &puuid, sizeof(uuid)) != 0 && memcmp(&uuid, &uuid_public_browse_group, sizeof(uuid)) != 0) continue; } My client is still connecting to PSM channels, but I'm seeing syntax errors https://gist.github.com/waitman/811e4dde41bfefd32054 So I'm wondering if i'm supposed to send the whole record or maybe just matching aids... Also just in case someone reading mailing list messages needs a way to associate BDADDR with 'previously negotiated human identification numbers' instead of hard config-file pins, I added a "BRIG" mode to hcsecd. As an example, you might want 1000 clients to pair and you wish to associate the BDADDR with a phone number or some other number the people know exclusively and can remember. # printf "5108307975" > /tmp/brig.txt Then the person pairs using their phone number. The tmp file is removed by hcsecd after use. This isn't something you'd want to set up a long time before pairing. But, like the person doing the pairing is standing there and is ready to pair. Then you can build an index of BDADDR with human id's which can be used later when either continuous scanning of devices and/or pairing from a database. https://github.com/waitman/hcsecd Thank you, -- Waitman Gobble Los Altos California USA 510-830-7975
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFuo_fyYyoX6rNwN6_TfB01_xp5EQHFu-CJG=_dab_Qe7x1hkA>