ssar.c (124758) | ssar.c (139721) |
---|---|
1/* 2 * ssar.c 3 * 4 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 12 unchanged lines hidden (view full) --- 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $Id: ssar.c,v 1.4 2004/01/12 22:54:31 max Exp $ | 1/* 2 * ssar.c 3 * 4 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 12 unchanged lines hidden (view full) --- 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $Id: ssar.c,v 1.4 2004/01/12 22:54:31 max Exp $ |
29 * $FreeBSD: head/usr.sbin/bluetooth/sdpd/ssar.c 124758 2004-01-20 20:48:26Z emax $ | 29 * $FreeBSD: head/usr.sbin/bluetooth/sdpd/ssar.c 139721 2005-01-05 18:37:37Z emax $ |
30 */ 31 32#include <sys/queue.h> 33#include <bluetooth.h> 34#include <sdp.h> 35#include <string.h> 36#include "profile.h" 37#include "provider.h" 38#include "server.h" | 30 */ 31 32#include <sys/queue.h> 33#include <bluetooth.h> 34#include <sdp.h> 35#include <string.h> 36#include "profile.h" 37#include "provider.h" 38#include "server.h" |
39#include "uuid-private.h" |
|
39 40/* from sar.c */ 41int32_t server_prepare_attr_list(provider_p const provider, 42 uint8_t const *req, uint8_t const * const req_end, 43 uint8_t *rsp, uint8_t const * const rsp_end); 44 45/* 46 * Prepare SDP Service Search Attribute Response --- 6 unchanged lines hidden (view full) --- 53 uint8_t const *req_end = req + ((sdp_pdu_p)(srv->req))->len; 54 uint8_t *rsp = srv->fdidx[fd].rsp; 55 uint8_t const *rsp_end = rsp + NG_L2CAP_MTU_MAXIMUM; 56 57 uint8_t const *sspptr = NULL, *aidptr = NULL; 58 uint8_t *ptr = NULL; 59 60 provider_t *provider = NULL; | 40 41/* from sar.c */ 42int32_t server_prepare_attr_list(provider_p const provider, 43 uint8_t const *req, uint8_t const * const req_end, 44 uint8_t *rsp, uint8_t const * const rsp_end); 45 46/* 47 * Prepare SDP Service Search Attribute Response --- 6 unchanged lines hidden (view full) --- 54 uint8_t const *req_end = req + ((sdp_pdu_p)(srv->req))->len; 55 uint8_t *rsp = srv->fdidx[fd].rsp; 56 uint8_t const *rsp_end = rsp + NG_L2CAP_MTU_MAXIMUM; 57 58 uint8_t const *sspptr = NULL, *aidptr = NULL; 59 uint8_t *ptr = NULL; 60 61 provider_t *provider = NULL; |
61 int32_t type, rsp_limit, ssplen, aidlen, cslen, cs, uuid; | 62 int32_t type, rsp_limit, ssplen, aidlen, cslen, cs; 63 uint128_t uuid, puuid; |
62 63 /* 64 * Minimal Service Search Attribute Request request 65 * 66 * seq8 len8 - 2 bytes 67 * uuid16 value16 - 3 bytes ServiceSearchPattern 68 * value16 - 2 bytes MaximumAttributeByteCount 69 * seq8 len8 - 2 bytes --- 102 unchanged lines hidden (view full) --- 172 SDP_GET8(type, sspptr); 173 ssplen --; 174 175 switch (type) { 176 case SDP_DATA_UUID16: 177 if (ssplen < 2) 178 return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); 179 | 64 65 /* 66 * Minimal Service Search Attribute Request request 67 * 68 * seq8 len8 - 2 bytes 69 * uuid16 value16 - 3 bytes ServiceSearchPattern 70 * value16 - 2 bytes MaximumAttributeByteCount 71 * seq8 len8 - 2 bytes --- 102 unchanged lines hidden (view full) --- 174 SDP_GET8(type, sspptr); 175 ssplen --; 176 177 switch (type) { 178 case SDP_DATA_UUID16: 179 if (ssplen < 2) 180 return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); 181 |
180 SDP_GET16(uuid, sspptr); | 182 memcpy(&uuid, &uuid_base, sizeof(uuid)); 183 uuid.b[2] = *sspptr ++; 184 uuid.b[3] = *sspptr ++; |
181 ssplen -= 2; 182 break; 183 | 185 ssplen -= 2; 186 break; 187 |
184 case SDP_DATA_UUID32: /* XXX FIXME */ 185 case SDP_DATA_UUID128: /* XXX FIXME */ | 188 case SDP_DATA_UUID32: 189 if (ssplen < 4) 190 return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); 191 192 memcpy(&uuid, &uuid_base, sizeof(uuid)); 193 uuid.b[0] = *sspptr ++; 194 uuid.b[1] = *sspptr ++; 195 uuid.b[2] = *sspptr ++; 196 uuid.b[3] = *sspptr ++; 197 ssplen -= 4; 198 break; 199 200 case SDP_DATA_UUID128: 201 if (ssplen < 16) 202 return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); 203 204 memcpy(uuid.b, sspptr, 16); 205 sspptr += 16; 206 ssplen -= 16; 207 break; 208 |
186 default: 187 return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); 188 /* NOT REACHED */ 189 } 190 191 for (provider = provider_get_first(); 192 provider != NULL; 193 provider = provider_get_next(provider)) { 194 if (!provider_match_bdaddr(provider, &srv->req_sa.l2cap_bdaddr)) 195 continue; 196 | 209 default: 210 return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); 211 /* NOT REACHED */ 212 } 213 214 for (provider = provider_get_first(); 215 provider != NULL; 216 provider = provider_get_next(provider)) { 217 if (!provider_match_bdaddr(provider, &srv->req_sa.l2cap_bdaddr)) 218 continue; 219 |
197 if (provider->profile->uuid != uuid && 198 SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP != uuid) | 220 memcpy(&puuid, &uuid_base, sizeof(puuid)); 221 puuid.b[2] = provider->profile->uuid >> 8; 222 puuid.b[3] = provider->profile->uuid; 223 224 if (memcmp(&uuid, &puuid, sizeof(uuid)) != 0 && 225 memcmp(&uuid, &uuid_public_browse_group, sizeof(uuid)) != 0) |
199 continue; 200 201 cs = server_prepare_attr_list(provider, 202 aidptr, aidptr + aidlen, ptr, rsp_end); 203 if (cs < 0) 204 return (SDP_ERROR_CODE_INSUFFICIENT_RESOURCES); 205 206 ptr += cs; --- 19 unchanged lines hidden --- | 226 continue; 227 228 cs = server_prepare_attr_list(provider, 229 aidptr, aidptr + aidlen, ptr, rsp_end); 230 if (cs < 0) 231 return (SDP_ERROR_CODE_INSUFFICIENT_RESOURCES); 232 233 ptr += cs; --- 19 unchanged lines hidden --- |