1124758Semax/* 2124758Semax * sp.c 3124758Semax * 4124758Semax * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com> 5124758Semax * All rights reserved. 6124758Semax * 7124758Semax * Redistribution and use in source and binary forms, with or without 8124758Semax * modification, are permitted provided that the following conditions 9124758Semax * are met: 10124758Semax * 1. Redistributions of source code must retain the above copyright 11124758Semax * notice, this list of conditions and the following disclaimer. 12124758Semax * 2. Redistributions in binary form must reproduce the above copyright 13124758Semax * notice, this list of conditions and the following disclaimer in the 14124758Semax * documentation and/or other materials provided with the distribution. 15124758Semax * 16124758Semax * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17124758Semax * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18124758Semax * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19124758Semax * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20124758Semax * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21124758Semax * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22124758Semax * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23124758Semax * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24124758Semax * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25124758Semax * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26124758Semax * SUCH DAMAGE. 27124758Semax * 28124758Semax * $Id: sp.c,v 1.5 2004/01/13 01:54:39 max Exp $ 29124758Semax * $FreeBSD$ 30124758Semax */ 31124758Semax 32124758Semax#include <sys/queue.h> 33124758Semax#include <bluetooth.h> 34124758Semax#include <sdp.h> 35124758Semax#include <string.h> 36124758Semax#include "profile.h" 37124758Semax#include "provider.h" 38124758Semax 39124758Semaxstatic int32_t 40124758Semaxsp_profile_create_service_class_id_list( 41124758Semax uint8_t *buf, uint8_t const * const eob, 42124758Semax uint8_t const *data, uint32_t datalen) 43124758Semax{ 44124758Semax static uint16_t service_classes[] = { 45124758Semax SDP_SERVICE_CLASS_SERIAL_PORT 46124758Semax }; 47124758Semax 48124758Semax return (common_profile_create_service_class_id_list( 49124758Semax buf, eob, 50124758Semax (uint8_t const *) service_classes, 51124758Semax sizeof(service_classes))); 52124758Semax} 53124758Semax 54124758Semaxstatic int32_t 55124758Semaxsp_profile_create_bluetooth_profile_descriptor_list( 56124758Semax uint8_t *buf, uint8_t const * const eob, 57124758Semax uint8_t const *data, uint32_t datalen) 58124758Semax{ 59124758Semax static uint16_t profile_descriptor_list[] = { 60124758Semax SDP_SERVICE_CLASS_SERIAL_PORT, 61124758Semax 0x0100 62124758Semax }; 63124758Semax 64124758Semax return (common_profile_create_bluetooth_profile_descriptor_list( 65124758Semax buf, eob, 66124758Semax (uint8_t const *) profile_descriptor_list, 67124758Semax sizeof(profile_descriptor_list))); 68124758Semax} 69124758Semax 70124758Semaxstatic int32_t 71124758Semaxsp_profile_create_service_name( 72124758Semax uint8_t *buf, uint8_t const * const eob, 73124758Semax uint8_t const *data, uint32_t datalen) 74124758Semax{ 75124758Semax static char service_name[] = "Serial Port"; 76124758Semax 77124758Semax return (common_profile_create_string8( 78124758Semax buf, eob, 79124758Semax (uint8_t const *) service_name, strlen(service_name))); 80124758Semax} 81124758Semax 82124758Semaxstatic int32_t 83124758Semaxsp_profile_create_protocol_descriptor_list( 84124758Semax uint8_t *buf, uint8_t const * const eob, 85124758Semax uint8_t const *data, uint32_t datalen) 86124758Semax{ 87124758Semax provider_p provider = (provider_p) data; 88124758Semax sdp_sp_profile_p sp = (sdp_sp_profile_p) provider->data; 89124758Semax 90124758Semax return (rfcomm_profile_create_protocol_descriptor_list( 91124758Semax buf, eob, 92124758Semax (uint8_t const *) &sp->server_channel, 1)); 93124758Semax} 94124758Semax 95124758Semaxstatic attr_t sp_profile_attrs[] = { 96124758Semax { SDP_ATTR_SERVICE_RECORD_HANDLE, 97124758Semax common_profile_create_service_record_handle }, 98124758Semax { SDP_ATTR_SERVICE_CLASS_ID_LIST, 99124758Semax sp_profile_create_service_class_id_list }, 100124758Semax { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, 101124758Semax sp_profile_create_bluetooth_profile_descriptor_list }, 102124758Semax { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, 103124758Semax common_profile_create_language_base_attribute_id_list }, 104124758Semax { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, 105124758Semax sp_profile_create_service_name }, 106124758Semax { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, 107124758Semax sp_profile_create_protocol_descriptor_list }, 108124758Semax { 0, NULL } /* end entry */ 109124758Semax}; 110124758Semax 111124758Semaxprofile_t sp_profile_descriptor = { 112124758Semax SDP_SERVICE_CLASS_SERIAL_PORT, 113124758Semax sizeof(sdp_sp_profile_t), 114124758Semax common_profile_server_channel_valid, 115124758Semax (attr_t const * const) &sp_profile_attrs 116124758Semax}; 117124758Semax 118