1124758Semax/* 2124758Semax * opush.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: opush.c,v 1.6 2004/01/13 19:31:54 max Exp $ 29124758Semax * $FreeBSD: releng/10.2/usr.sbin/bluetooth/sdpd/opush.c 124758 2004-01-20 20:48:26Z emax $ 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 40124758Semaxopush_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_OBEX_OBJECT_PUSH 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 55124758Semaxopush_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_OBEX_OBJECT_PUSH, 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 71124758Semaxopush_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[] = "OBEX Object Push"; 76124758Semax 77124758Semax return (common_profile_create_string8( 78124758Semax buf, eob, 79124758Semax (uint8_t const *) service_name, strlen(service_name))); 80124758Semax} 81124758Semax 82124758Semaxstatic int32_t 83124758Semaxopush_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_opush_profile_p opush = (sdp_opush_profile_p) provider->data; 89124758Semax 90124758Semax return (obex_profile_create_protocol_descriptor_list( 91124758Semax buf, eob, 92124758Semax (uint8_t const *) &opush->server_channel, 1)); 93124758Semax} 94124758Semax 95124758Semaxstatic int32_t 96124758Semaxopush_profile_create_supported_formats_list( 97124758Semax uint8_t *buf, uint8_t const * const eob, 98124758Semax uint8_t const *data, uint32_t datalen) 99124758Semax{ 100124758Semax provider_p provider = (provider_p) data; 101124758Semax sdp_opush_profile_p opush = (sdp_opush_profile_p) provider->data; 102124758Semax 103124758Semax return (obex_profile_create_supported_formats_list( 104124758Semax buf, eob, 105124758Semax (uint8_t const *) opush->supported_formats, 106124758Semax opush->supported_formats_size)); 107124758Semax} 108124758Semax 109124758Semaxstatic attr_t opush_profile_attrs[] = { 110124758Semax { SDP_ATTR_SERVICE_RECORD_HANDLE, 111124758Semax common_profile_create_service_record_handle }, 112124758Semax { SDP_ATTR_SERVICE_CLASS_ID_LIST, 113124758Semax opush_profile_create_service_class_id_list }, 114124758Semax { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, 115124758Semax opush_profile_create_bluetooth_profile_descriptor_list }, 116124758Semax { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, 117124758Semax common_profile_create_language_base_attribute_id_list }, 118124758Semax { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, 119124758Semax opush_profile_create_service_name }, 120124758Semax { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, 121124758Semax opush_profile_create_protocol_descriptor_list }, 122124758Semax { SDP_ATTR_SUPPORTED_FORMATS_LIST, 123124758Semax opush_profile_create_supported_formats_list }, 124124758Semax { 0, NULL } /* end entry */ 125124758Semax}; 126124758Semax 127124758Semaxprofile_t opush_profile_descriptor = { 128124758Semax SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH, 129124758Semax sizeof(sdp_opush_profile_t), 130124758Semax obex_profile_data_valid, 131124758Semax (attr_t const * const) &opush_profile_attrs 132124758Semax}; 133124758Semax 134