Teach sdpd(8) about 32-bit and 128-bit uuid's.
MFC after: 3 days
This commit is contained in:
parent
122dc5646e
commit
ee935b5800
@ -5,7 +5,7 @@ PROG= sdpd
|
||||
MAN= sdpd.8
|
||||
SRCS= bgd.c dun.c ftrn.c irmc.c irmc_command.c lan.c log.c main.c \
|
||||
opush.c profile.c provider.c sar.c scr.c sd.c server.c sp.c \
|
||||
srr.c ssar.c ssr.c sur.c
|
||||
srr.c ssar.c ssr.c sur.c uuid.c
|
||||
|
||||
CFLAGS+= -I${.CURDIR}
|
||||
WARNS?= 2
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "profile.h"
|
||||
#include "provider.h"
|
||||
#include "server.h"
|
||||
#include "uuid-private.h"
|
||||
|
||||
/* from sar.c */
|
||||
int32_t server_prepare_attr_list(provider_p const provider,
|
||||
@ -58,7 +59,8 @@ server_prepare_service_search_attribute_response(server_p srv, int32_t fd)
|
||||
uint8_t *ptr = NULL;
|
||||
|
||||
provider_t *provider = NULL;
|
||||
int32_t type, rsp_limit, ssplen, aidlen, cslen, cs, uuid;
|
||||
int32_t type, rsp_limit, ssplen, aidlen, cslen, cs;
|
||||
uint128_t uuid, puuid;
|
||||
|
||||
/*
|
||||
* Minimal Service Search Attribute Request request
|
||||
@ -177,12 +179,33 @@ server_prepare_service_search_attribute_response(server_p srv, int32_t fd)
|
||||
if (ssplen < 2)
|
||||
return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX);
|
||||
|
||||
SDP_GET16(uuid, sspptr);
|
||||
memcpy(&uuid, &uuid_base, sizeof(uuid));
|
||||
uuid.b[2] = *sspptr ++;
|
||||
uuid.b[3] = *sspptr ++;
|
||||
ssplen -= 2;
|
||||
break;
|
||||
|
||||
case SDP_DATA_UUID32: /* XXX FIXME */
|
||||
case SDP_DATA_UUID128: /* XXX FIXME */
|
||||
case SDP_DATA_UUID32:
|
||||
if (ssplen < 4)
|
||||
return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX);
|
||||
|
||||
memcpy(&uuid, &uuid_base, sizeof(uuid));
|
||||
uuid.b[0] = *sspptr ++;
|
||||
uuid.b[1] = *sspptr ++;
|
||||
uuid.b[2] = *sspptr ++;
|
||||
uuid.b[3] = *sspptr ++;
|
||||
ssplen -= 4;
|
||||
break;
|
||||
|
||||
case SDP_DATA_UUID128:
|
||||
if (ssplen < 16)
|
||||
return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX);
|
||||
|
||||
memcpy(uuid.b, sspptr, 16);
|
||||
sspptr += 16;
|
||||
ssplen -= 16;
|
||||
break;
|
||||
|
||||
default:
|
||||
return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX);
|
||||
/* NOT REACHED */
|
||||
@ -194,8 +217,12 @@ server_prepare_service_search_attribute_response(server_p srv, int32_t fd)
|
||||
if (!provider_match_bdaddr(provider, &srv->req_sa.l2cap_bdaddr))
|
||||
continue;
|
||||
|
||||
if (provider->profile->uuid != uuid &&
|
||||
SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP != uuid)
|
||||
memcpy(&puuid, &uuid_base, sizeof(puuid));
|
||||
puuid.b[2] = provider->profile->uuid >> 8;
|
||||
puuid.b[3] = provider->profile->uuid;
|
||||
|
||||
if (memcmp(&uuid, &puuid, sizeof(uuid)) != 0 &&
|
||||
memcmp(&uuid, &uuid_public_browse_group, sizeof(uuid)) != 0)
|
||||
continue;
|
||||
|
||||
cs = server_prepare_attr_list(provider,
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "profile.h"
|
||||
#include "provider.h"
|
||||
#include "server.h"
|
||||
#include "uuid-private.h"
|
||||
|
||||
/*
|
||||
* Prepare SDP Service Search Response
|
||||
@ -56,7 +57,8 @@ server_prepare_service_search_response(server_p srv, int32_t fd)
|
||||
|
||||
uint8_t *ptr = NULL;
|
||||
provider_t *provider = NULL;
|
||||
int32_t type, ssplen, rsp_limit, rcount, cslen, cs, uuid;
|
||||
int32_t type, ssplen, rsp_limit, rcount, cslen, cs;
|
||||
uint128_t uuid, puuid;
|
||||
|
||||
/*
|
||||
* Minimal SDP Service Search Request
|
||||
@ -145,12 +147,33 @@ server_prepare_service_search_response(server_p srv, int32_t fd)
|
||||
if (ssplen < 2)
|
||||
return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX);
|
||||
|
||||
SDP_GET16(uuid, req);
|
||||
memcpy(&uuid, &uuid_base, sizeof(uuid));
|
||||
uuid.b[2] = *req ++;
|
||||
uuid.b[3] = *req ++;
|
||||
ssplen -= 2;
|
||||
break;
|
||||
|
||||
case SDP_DATA_UUID32: /* XXX FIXME */
|
||||
case SDP_DATA_UUID128: /* XXX FIXME */
|
||||
case SDP_DATA_UUID32:
|
||||
if (ssplen < 4)
|
||||
return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX);
|
||||
|
||||
memcpy(&uuid, &uuid_base, sizeof(uuid));
|
||||
uuid.b[0] = *req ++;
|
||||
uuid.b[1] = *req ++;
|
||||
uuid.b[2] = *req ++;
|
||||
uuid.b[3] = *req ++;
|
||||
ssplen -= 4;
|
||||
break;
|
||||
|
||||
case SDP_DATA_UUID128:
|
||||
if (ssplen < 16)
|
||||
return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX);
|
||||
|
||||
memcpy(uuid.b, req, 16);
|
||||
req += 16;
|
||||
ssplen -= 16;
|
||||
break;
|
||||
|
||||
default:
|
||||
return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX);
|
||||
/* NOT REACHED */
|
||||
@ -162,8 +185,12 @@ server_prepare_service_search_response(server_p srv, int32_t fd)
|
||||
if (!provider_match_bdaddr(provider, &srv->req_sa.l2cap_bdaddr))
|
||||
continue;
|
||||
|
||||
if (provider->profile->uuid == uuid ||
|
||||
SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP == uuid) {
|
||||
memcpy(&puuid, &uuid_base, sizeof(puuid));
|
||||
puuid.b[2] = provider->profile->uuid >> 8;
|
||||
puuid.b[3] = provider->profile->uuid;
|
||||
|
||||
if (memcmp(&uuid, &puuid, sizeof(uuid)) == 0 ||
|
||||
memcmp(&uuid, &uuid_public_browse_group, sizeof(uuid)) == 0) {
|
||||
SDP_PUT32(provider->handle, ptr);
|
||||
rcount ++;
|
||||
}
|
||||
|
39
usr.sbin/bluetooth/sdpd/uuid-private.h
Normal file
39
usr.sbin/bluetooth/sdpd/uuid-private.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* uuid-private.h
|
||||
*
|
||||
* Copyright (c) 2005 Maksim Yevmenkin <m_evmenkin@yahoo.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: uuid-private.h,v 1.1 2004/12/09 18:20:26 max Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _UUID_PRIVATE_H_
|
||||
#define _UUID_PRIVATE_H_
|
||||
|
||||
extern uint128_t uuid_base;
|
||||
extern uint128_t uuid_public_browse_group;
|
||||
|
||||
#endif /* ndef _UUID_PRIVATE_H_ */
|
||||
|
56
usr.sbin/bluetooth/sdpd/uuid.c
Normal file
56
usr.sbin/bluetooth/sdpd/uuid.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* uuid.c
|
||||
*
|
||||
* Copyright (c) 2005 Maksim Yevmenkin <m_evmenkin@yahoo.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: uuid.c,v 1.1 2004/12/09 18:20:26 max Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <bluetooth.h>
|
||||
#include <sdp.h>
|
||||
#include <uuid.h>
|
||||
#include "uuid-private.h"
|
||||
|
||||
uint128_t uuid_base = {
|
||||
.b = {
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x10, 0x00,
|
||||
0x80, 0x00,
|
||||
0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb
|
||||
}
|
||||
};
|
||||
|
||||
uint128_t uuid_public_browse_group = {
|
||||
.b = {
|
||||
0x00, 0x00, 0x10, 0x02,
|
||||
0x00, 0x00,
|
||||
0x10, 0x00,
|
||||
0x80, 0x00,
|
||||
0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user