1234949Sbapt/*
2234949Sbapt * irmc.c
3234949Sbapt *
4234949Sbapt * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
5234949Sbapt * All rights reserved.
6234949Sbapt *
7234949Sbapt * Redistribution and use in source and binary forms, with or without
8234949Sbapt * modification, are permitted provided that the following conditions
9234949Sbapt * are met:
10234949Sbapt * 1. Redistributions of source code must retain the above copyright
11234949Sbapt *    notice, this list of conditions and the following disclaimer.
12234949Sbapt * 2. Redistributions in binary form must reproduce the above copyright
13234949Sbapt *    notice, this list of conditions and the following disclaimer in the
14234949Sbapt *    documentation and/or other materials provided with the distribution.
15234949Sbapt *
16234949Sbapt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17234949Sbapt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18234949Sbapt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19234949Sbapt * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20234949Sbapt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21234949Sbapt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22234949Sbapt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23234949Sbapt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24234949Sbapt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25234949Sbapt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26234949Sbapt * SUCH DAMAGE.
27234949Sbapt *
28234949Sbapt * $Id: irmc.c,v 1.6 2004/01/13 19:31:54 max Exp $
29234949Sbapt * $FreeBSD: releng/11.0/usr.sbin/bluetooth/sdpd/irmc.c 281210 2015-04-07 16:48:23Z takawata $
30234949Sbapt */
31234949Sbapt
32234949Sbapt#include <sys/queue.h>
33234949Sbapt#define L2CAP_SOCKET_CHECKED
34234949Sbapt#include <bluetooth.h>
35234949Sbapt#include <sdp.h>
36234949Sbapt#include <string.h>
37234949Sbapt#include "profile.h"
38234949Sbapt#include "provider.h"
39234949Sbapt
40234949Sbaptstatic int32_t
41234949Sbaptirmc_profile_create_service_class_id_list(
42234949Sbapt		uint8_t *buf, uint8_t const * const eob,
43234949Sbapt		uint8_t const *data, uint32_t datalen)
44234949Sbapt{
45234949Sbapt	static uint16_t	service_classes[] = {
46234949Sbapt		SDP_SERVICE_CLASS_IR_MC_SYNC
47234949Sbapt	};
48234949Sbapt
49234949Sbapt	return (common_profile_create_service_class_id_list(
50234949Sbapt			buf, eob,
51234949Sbapt			(uint8_t const *) service_classes,
52234949Sbapt			sizeof(service_classes)));
53234949Sbapt}
54234949Sbapt
55234949Sbaptstatic int32_t
56234949Sbaptirmc_profile_create_bluetooth_profile_descriptor_list(
57234949Sbapt		uint8_t *buf, uint8_t const * const eob,
58234949Sbapt		uint8_t const *data, uint32_t datalen)
59234949Sbapt{
60234949Sbapt	static uint16_t	profile_descriptor_list[] = {
61234949Sbapt		SDP_SERVICE_CLASS_IR_MC_SYNC,
62234949Sbapt		0x0100
63234949Sbapt	};
64234949Sbapt
65234949Sbapt	return (common_profile_create_bluetooth_profile_descriptor_list(
66234949Sbapt			buf, eob,
67234949Sbapt			(uint8_t const *) profile_descriptor_list,
68234949Sbapt			sizeof(profile_descriptor_list)));
69234949Sbapt}
70234949Sbapt
71234949Sbaptstatic int32_t
72234949Sbaptirmc_profile_create_service_name(
73234949Sbapt		uint8_t *buf, uint8_t const * const eob,
74234949Sbapt		uint8_t const *data, uint32_t datalen)
75234949Sbapt{
76234949Sbapt	static char	service_name[] = "IrMC Synchronization";
77234949Sbapt
78234949Sbapt	return (common_profile_create_string8(
79234949Sbapt			buf, eob,
80234949Sbapt			(uint8_t const *) service_name, strlen(service_name)));
81234949Sbapt}
82234949Sbapt
83234949Sbaptstatic int32_t
84234949Sbaptirmc_profile_create_protocol_descriptor_list(
85234949Sbapt		uint8_t *buf, uint8_t const * const eob,
86234949Sbapt		uint8_t const *data, uint32_t datalen)
87234949Sbapt{
88234949Sbapt	provider_p		provider = (provider_p) data;
89234949Sbapt	sdp_irmc_profile_p	irmc = (sdp_irmc_profile_p) provider->data;
90234949Sbapt
91234949Sbapt	return (obex_profile_create_protocol_descriptor_list(
92234949Sbapt			buf, eob,
93234949Sbapt			(uint8_t const *) &irmc->server_channel, 1));
94234949Sbapt}
95234949Sbapt
96234949Sbaptstatic int32_t
97234949Sbaptirmc_profile_create_supported_formats_list(
98234949Sbapt		uint8_t *buf, uint8_t const * const eob,
99234949Sbapt		uint8_t const *data, uint32_t datalen)
100234949Sbapt{
101234949Sbapt	provider_p		provider = (provider_p) data;
102234949Sbapt	sdp_irmc_profile_p	irmc = (sdp_irmc_profile_p) provider->data;
103234949Sbapt
104234949Sbapt	return (obex_profile_create_supported_formats_list(
105234949Sbapt			buf, eob,
106234949Sbapt			(uint8_t const *) irmc->supported_formats,
107234949Sbapt			irmc->supported_formats_size));
108234949Sbapt}
109234949Sbapt
110234949Sbaptstatic attr_t	irmc_profile_attrs[] = {
111234949Sbapt	{ SDP_ATTR_SERVICE_RECORD_HANDLE,
112234949Sbapt	  common_profile_create_service_record_handle },
113	{ SDP_ATTR_SERVICE_CLASS_ID_LIST,
114	  irmc_profile_create_service_class_id_list },
115	{ SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST,
116	  irmc_profile_create_bluetooth_profile_descriptor_list },
117	{ SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST,
118	  common_profile_create_language_base_attribute_id_list },
119	{ SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET,
120	  irmc_profile_create_service_name },
121	{ SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
122	  irmc_profile_create_protocol_descriptor_list },
123	{ SDP_ATTR_SUPPORTED_FORMATS_LIST,
124	  irmc_profile_create_supported_formats_list },
125	{ 0, NULL } /* end entry */
126};
127
128profile_t	irmc_profile_descriptor = {
129	SDP_SERVICE_CLASS_IR_MC_SYNC,
130	sizeof(sdp_irmc_profile_t),
131	obex_profile_data_valid,
132	(attr_t const * const) &irmc_profile_attrs
133};
134
135