1124758Semax/* 2124758Semax * bgd.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: bgd.c,v 1.4 2004/01/13 01:54:39 max Exp $ 29124758Semax * $FreeBSD: releng/10.2/usr.sbin/bluetooth/sdpd/bgd.c 124758 2004-01-20 20:48:26Z emax $ 30124758Semax */ 31124758Semax 32124758Semax#include <bluetooth.h> 33124758Semax#include <sdp.h> 34124758Semax#include <string.h> 35124758Semax#include "profile.h" 36124758Semax 37124758Semaxstatic int32_t 38124758Semaxbgd_profile_create_service_class_id_list( 39124758Semax uint8_t *buf, uint8_t const * const eob, 40124758Semax uint8_t const *data, uint32_t datalen) 41124758Semax{ 42124758Semax static uint16_t service_classes[] = { 43124758Semax SDP_SERVICE_CLASS_BROWSE_GROUP_DESCRIPTOR 44124758Semax }; 45124758Semax 46124758Semax return (common_profile_create_service_class_id_list( 47124758Semax buf, eob, 48124758Semax (uint8_t const *) service_classes, 49124758Semax sizeof(service_classes))); 50124758Semax} 51124758Semax 52124758Semaxstatic int32_t 53124758Semaxbgd_profile_create_service_name( 54124758Semax uint8_t *buf, uint8_t const * const eob, 55124758Semax uint8_t const *data, uint32_t datalen) 56124758Semax{ 57124758Semax static char service_name[] = "Public Browse Group Root"; 58124758Semax 59124758Semax return (common_profile_create_string8( 60124758Semax buf, eob, 61124758Semax (uint8_t const *) service_name, strlen(service_name))); 62124758Semax} 63124758Semax 64124758Semaxstatic int32_t 65124758Semaxbgd_profile_create_group_id( 66124758Semax uint8_t *buf, uint8_t const * const eob, 67124758Semax uint8_t const *data, uint32_t datalen) 68124758Semax{ 69124758Semax if (buf + 3 > eob) 70124758Semax return (-1); 71124758Semax 72124758Semax SDP_PUT8(SDP_DATA_UUID16, buf); 73124758Semax SDP_PUT16(SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP, buf); 74124758Semax 75124758Semax return (3); 76124758Semax} 77124758Semax 78124758Semaxstatic attr_t bgd_profile_attrs[] = { 79124758Semax { SDP_ATTR_SERVICE_RECORD_HANDLE, 80124758Semax common_profile_create_service_record_handle }, 81124758Semax { SDP_ATTR_SERVICE_CLASS_ID_LIST, 82124758Semax bgd_profile_create_service_class_id_list }, 83124758Semax { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, 84124758Semax common_profile_create_language_base_attribute_id_list }, 85124758Semax { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, 86124758Semax bgd_profile_create_service_name }, 87124758Semax { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_DESCRIPTION_OFFSET, 88124758Semax bgd_profile_create_service_name }, 89124758Semax { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_PROVIDER_NAME_OFFSET, 90124758Semax common_profile_create_service_provider_name }, 91124758Semax { SDP_ATTR_GROUP_ID, 92124758Semax bgd_profile_create_group_id }, 93124758Semax { 0, NULL } /* end entry */ 94124758Semax}; 95124758Semax 96124758Semaxprofile_t bgd_profile_descriptor = { 97124758Semax SDP_SERVICE_CLASS_BROWSE_GROUP_DESCRIPTOR, 98124758Semax 0, 99124758Semax (profile_data_valid_p) NULL, 100124758Semax (attr_t const * const) &bgd_profile_attrs 101124758Semax}; 102124758Semax 103