nlookup.9 - document nlookup_init_root
[dragonfly.git] / usr.sbin / sdpd / hset.c
blobd33e42e737da943c01f0b08c1e9cd9fb8029e72e
1 /* $NetBSD: hset.c,v 1.2 2007/11/09 20:08:41 plunky Exp $ */
2 /* $DragonFly: src/usr.sbin/sdpd/hset.c,v 1.1 2008/01/06 21:51:30 hasso Exp $ */
4 /*-
5 * Copyright (c) 2006 Itronix Inc.
6 * All rights reserved.
8 * Written by Iain Hibbert for Itronix Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. The name of Itronix Inc. may not be used to endorse
19 * or promote products derived from this software without specific
20 * prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
35 #include <sys/queue.h>
36 #include <bluetooth.h>
37 #include <sdp.h>
38 #include <stdio.h>
39 #include <string.h>
41 #include <netbt/rfcomm.h>
43 #include "profile.h"
44 #include "provider.h"
46 static int32_t
47 hset_profile_create_service_class_id_list(
48 uint8_t *buf, uint8_t const * const eob,
49 uint8_t const *data, uint32_t datalen)
51 static uint16_t service_classes[] = {
52 SDP_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY,
53 SDP_SERVICE_CLASS_GENERIC_AUDIO,
56 return (common_profile_create_service_class_id_list(
57 buf, eob,
58 (uint8_t const *) service_classes,
59 sizeof(service_classes)));
62 static int32_t
63 hset_profile_create_protocol_descriptor_list(
64 uint8_t *buf, uint8_t const * const eob,
65 uint8_t const *data, uint32_t datalen)
67 provider_t const *provider = (provider_t const *) data;
68 sdp_hset_profile_t *hset = (sdp_hset_profile_t *) provider->data;
70 return (rfcomm_profile_create_protocol_descriptor_list(
71 buf, eob,
72 (uint8_t const *) &hset->server_channel, 1));
75 static int32_t
76 hset_profile_create_bluetooth_profile_descriptor_list(
77 uint8_t *buf, uint8_t const * const eob,
78 uint8_t const *data, uint32_t datalen)
80 static uint16_t profile_descriptor_list[] = {
81 SDP_SERVICE_CLASS_HEADSET,
82 0x0100
85 return (common_profile_create_bluetooth_profile_descriptor_list(
86 buf, eob,
87 (uint8_t const *) profile_descriptor_list,
88 sizeof(profile_descriptor_list)));
91 static int32_t
92 hset_profile_create_service_name(
93 uint8_t *buf, uint8_t const * const eob,
94 uint8_t const *data, uint32_t datalen)
96 static char service_name[] = "Voice Gateway";
98 return (common_profile_create_string8(
99 buf, eob,
100 (uint8_t const *) service_name, strlen(service_name)));
103 static int32_t
104 hset_profile_data_valid(uint8_t const *data, uint32_t datalen)
106 sdp_hset_profile_t const *hset = (sdp_hset_profile_t const *) data;
108 if (hset->server_channel < RFCOMM_CHANNEL_MIN
109 || hset->server_channel > RFCOMM_CHANNEL_MAX)
110 return 0;
112 return 1;
115 static attr_t hset_profile_attrs[] = {
116 { SDP_ATTR_SERVICE_RECORD_HANDLE,
117 common_profile_create_service_record_handle },
118 { SDP_ATTR_SERVICE_CLASS_ID_LIST,
119 hset_profile_create_service_class_id_list },
120 { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
121 hset_profile_create_protocol_descriptor_list },
122 { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST,
123 hset_profile_create_bluetooth_profile_descriptor_list },
124 { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET,
125 hset_profile_create_service_name },
126 { 0, NULL } /* end entry */
129 static uint16_t hset_profile_uuids[] = {
130 SDP_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY,
131 SDP_SERVICE_CLASS_GENERIC_AUDIO,
132 SDP_UUID_PROTOCOL_L2CAP,
133 SDP_UUID_PROTOCOL_RFCOMM,
134 SDP_SERVICE_CLASS_HEADSET,
137 profile_t hset_profile_descriptor = {
138 hset_profile_uuids,
139 sizeof(hset_profile_uuids),
140 sizeof(sdp_hset_profile_t),
141 hset_profile_data_valid,
142 (attr_t const * const) &hset_profile_attrs