ssr.c (126245) | ssr.c (139721) |
---|---|
1/* 2 * ssr.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: ssr.c,v 1.5 2004/01/13 01:54:39 max Exp $ | 1/* 2 * ssr.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: ssr.c,v 1.5 2004/01/13 01:54:39 max Exp $ |
29 * $FreeBSD: head/usr.sbin/bluetooth/sdpd/ssr.c 126245 2004-02-25 22:43:43Z emax $ | 29 * $FreeBSD: head/usr.sbin/bluetooth/sdpd/ssr.c 139721 2005-01-05 18:37:37Z emax $ |
30 */ 31 32#include <sys/queue.h> 33#include <sys/uio.h> 34#include <netinet/in.h> 35#include <arpa/inet.h> 36#include <assert.h> 37#include <bluetooth.h> 38#include <errno.h> 39#include <sdp.h> 40#include <string.h> 41#include "profile.h" 42#include "provider.h" 43#include "server.h" | 30 */ 31 32#include <sys/queue.h> 33#include <sys/uio.h> 34#include <netinet/in.h> 35#include <arpa/inet.h> 36#include <assert.h> 37#include <bluetooth.h> 38#include <errno.h> 39#include <sdp.h> 40#include <string.h> 41#include "profile.h" 42#include "provider.h" 43#include "server.h" |
44#include "uuid-private.h" |
|
44 45/* 46 * Prepare SDP Service Search Response 47 */ 48 49int32_t 50server_prepare_service_search_response(server_p srv, int32_t fd) 51{ 52 uint8_t const *req = srv->req + sizeof(sdp_pdu_t); 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 *ptr = NULL; 58 provider_t *provider = NULL; | 45 46/* 47 * Prepare SDP Service Search Response 48 */ 49 50int32_t 51server_prepare_service_search_response(server_p srv, int32_t fd) 52{ 53 uint8_t const *req = srv->req + sizeof(sdp_pdu_t); 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 *ptr = NULL; 59 provider_t *provider = NULL; |
59 int32_t type, ssplen, rsp_limit, rcount, cslen, cs, uuid; | 60 int32_t type, ssplen, rsp_limit, rcount, cslen, cs; 61 uint128_t uuid, puuid; |
60 61 /* 62 * Minimal SDP Service Search Request 63 * 64 * seq8 len8 - 2 bytes 65 * uuid16 value16 - 3 bytes ServiceSearchPattern 66 * value16 - 2 bytes MaximumServiceRecordCount 67 * value8 - 1 byte ContinuationState --- 72 unchanged lines hidden (view full) --- 140 SDP_GET8(type, req); 141 ssplen --; 142 143 switch (type) { 144 case SDP_DATA_UUID16: 145 if (ssplen < 2) 146 return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); 147 | 62 63 /* 64 * Minimal SDP Service Search Request 65 * 66 * seq8 len8 - 2 bytes 67 * uuid16 value16 - 3 bytes ServiceSearchPattern 68 * value16 - 2 bytes MaximumServiceRecordCount 69 * value8 - 1 byte ContinuationState --- 72 unchanged lines hidden (view full) --- 142 SDP_GET8(type, req); 143 ssplen --; 144 145 switch (type) { 146 case SDP_DATA_UUID16: 147 if (ssplen < 2) 148 return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); 149 |
148 SDP_GET16(uuid, req); | 150 memcpy(&uuid, &uuid_base, sizeof(uuid)); 151 uuid.b[2] = *req ++; 152 uuid.b[3] = *req ++; |
149 ssplen -= 2; 150 break; 151 | 153 ssplen -= 2; 154 break; 155 |
152 case SDP_DATA_UUID32: /* XXX FIXME */ 153 case SDP_DATA_UUID128: /* XXX FIXME */ | 156 case SDP_DATA_UUID32: 157 if (ssplen < 4) 158 return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); 159 160 memcpy(&uuid, &uuid_base, sizeof(uuid)); 161 uuid.b[0] = *req ++; 162 uuid.b[1] = *req ++; 163 uuid.b[2] = *req ++; 164 uuid.b[3] = *req ++; 165 ssplen -= 4; 166 break; 167 168 case SDP_DATA_UUID128: 169 if (ssplen < 16) 170 return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); 171 172 memcpy(uuid.b, req, 16); 173 req += 16; 174 ssplen -= 16; 175 break; 176 |
154 default: 155 return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); 156 /* NOT REACHED */ 157 } 158 159 for (provider = provider_get_first(); 160 provider != NULL && rcount < rsp_limit; 161 provider = provider_get_next(provider)) { 162 if (!provider_match_bdaddr(provider, &srv->req_sa.l2cap_bdaddr)) 163 continue; 164 | 177 default: 178 return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); 179 /* NOT REACHED */ 180 } 181 182 for (provider = provider_get_first(); 183 provider != NULL && rcount < rsp_limit; 184 provider = provider_get_next(provider)) { 185 if (!provider_match_bdaddr(provider, &srv->req_sa.l2cap_bdaddr)) 186 continue; 187 |
165 if (provider->profile->uuid == uuid || 166 SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP == uuid) { | 188 memcpy(&puuid, &uuid_base, sizeof(puuid)); 189 puuid.b[2] = provider->profile->uuid >> 8; 190 puuid.b[3] = provider->profile->uuid; 191 192 if (memcmp(&uuid, &puuid, sizeof(uuid)) == 0 || 193 memcmp(&uuid, &uuid_public_browse_group, sizeof(uuid)) == 0) { |
167 SDP_PUT32(provider->handle, ptr); 168 rcount ++; 169 } 170 } 171 } 172 173 /* Set reply size (not counting PDU header and continuation state) */ 174 srv->fdidx[fd].rsp_limit = srv->fdidx[fd].omtu - sizeof(sdp_pdu_t) - 4; --- 81 unchanged lines hidden --- | 194 SDP_PUT32(provider->handle, ptr); 195 rcount ++; 196 } 197 } 198 } 199 200 /* Set reply size (not counting PDU header and continuation state) */ 201 srv->fdidx[fd].rsp_limit = srv->fdidx[fd].omtu - sizeof(sdp_pdu_t) - 4; --- 81 unchanged lines hidden --- |