/*-1* sur.c2*3* SPDX-License-Identifier: BSD-2-Clause4*5* Copyright (c) 2004 Maksim Yevmenkin <[email protected]>6* All rights reserved.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions10* are met:11* 1. Redistributions of source code must retain the above copyright12* notice, this list of conditions and the following disclaimer.13* 2. Redistributions in binary form must reproduce the above copyright14* notice, this list of conditions and the following disclaimer in the15* documentation and/or other materials provided with the distribution.16*17* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND18* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE19* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE20* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE21* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS23* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)24* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT25* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF27* SUCH DAMAGE.28*29* $Id: sur.c,v 1.1 2004/01/13 01:54:39 max Exp $30*/3132#include <sys/queue.h>33#define L2CAP_SOCKET_CHECKED34#include <bluetooth.h>35#include <errno.h>36#include <sdp.h>37#include <string.h>38#include "profile.h"39#include "provider.h"40#include "server.h"4142/*43* Prepare Service Unregister response44*/4546int32_t47server_prepare_service_unregister_response(server_p srv, int32_t fd)48{49uint8_t const *req = srv->req + sizeof(sdp_pdu_t);50uint8_t const *req_end = req + ((sdp_pdu_p)(srv->req))->len;51uint8_t *rsp = srv->fdidx[fd].rsp;5253provider_t *provider = NULL;54uint32_t handle;5556/*57* Minimal Service Unregister Request58*59* value32 - uuid 4 bytes60*/6162if (!srv->fdidx[fd].control ||63!srv->fdidx[fd].priv || req_end - req < 4)64return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX);6566/* Get handle */67SDP_GET32(handle, req);6869/* Lookup provider */70provider = provider_by_handle(handle);71if (provider == NULL || provider->fd != fd)72return (SDP_ERROR_CODE_INVALID_SERVICE_RECORD_HANDLE);7374provider_unregister(provider);75SDP_PUT16(0, rsp);7677/* Set reply size */78srv->fdidx[fd].rsp_limit = srv->fdidx[fd].omtu - sizeof(sdp_pdu_t);79srv->fdidx[fd].rsp_size = rsp - srv->fdidx[fd].rsp;80srv->fdidx[fd].rsp_cs = 0;8182return (0);83}84858687