/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Iain Hibbert.
*
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* These record manipulation requests are not part of the SDP
* specification, they are a private extension and valid only
* for privileged clients on the control socket.
*/
uint16_t
record_insert_request(server_t *srv, int fd)
{
sdp_data_t seq;
bdaddr_t bdaddr;
log_debug("RecordInsertRequest by client on fd#%d", fd);
/*
* fill in PDU header and we are done
*/
srv->pdu.pid = SDP_PDU_ERROR_RESPONSE;
srv->pdu.len = sizeof(uint16_t);
return 0;
}
/*
* validate ServiceRecord data element list
*
* The record must contain a list of attribute/value pairs where the
* attributes are unsigned 16-bit integer values in ascending order.
*/
static bool
sdpd_valid_record(sdp_data_t *data)
{
sdp_data_t d, s;
uintmax_t a0, a;
s = *data;
if (!sdp_data_valid(&s))
return false;
/* The first attribute must be ServiceRecordHandle */
if (!sdp_get_data(&s, &d)
|| sdp_data_type(&d) != SDP_DATA_UINT16
|| !sdp_get_uint(&d, &a0)
|| a0 != SDP_ATTR_SERVICE_RECORD_HANDLE
|| !sdp_get_data(&s, &d)
|| sdp_data_type(&d) != SDP_DATA_UINT32)
return false;
/* and remaining attribute IDs must be in ascending order */
while (sdp_get_data(&s, &d)
&& sdp_data_type(&d) == SDP_DATA_UINT16
&& sdp_get_uint(&d, &a)
&& a > a0
&& sdp_get_data(&s, &d))
a0 = a;