1 .\" $NetBSD: bluetooth.3,v 1.3 2006/07/30 00:15:54 wiz Exp $
3 .\" Copyright (c) 2003 Maksim Yevmenkin <m_evmenkin@yahoo.com>
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" $Id: bluetooth.3,v 1.3 2006/07/30 00:15:54 wiz Exp $
28 .\" $FreeBSD: src/lib/libbluetooth/bluetooth.3,v 1.7 2005/01/21 10:26:11 ru Exp $
34 .Nm bt_gethostbyname ,
35 .Nm bt_gethostbyaddr ,
39 .Nm bt_getprotobyname ,
40 .Nm bt_getprotobynumber ,
48 .Nd Bluetooth routines
54 .Fn bt_gethostbyname "const char *name"
56 .Fn bt_gethostbyaddr "const void *addr" "socklen_t len" "int type"
58 .Fn bt_gethostent void
60 .Fn bt_sethostent "int stayopen"
62 .Fn bt_endhostent void
64 .Fn bt_getprotobyname "const char *name"
66 .Fn bt_getprotobynumber "int proto"
68 .Fn bt_getprotoent void
70 .Fn bt_setprotoent "int stayopen"
72 .Fn bt_endprotoent void
74 .Fn bt_aton "const char *str" "bdaddr_t *ba"
76 .Fn bt_ntoa "const bdaddr_t *ba" "char *str"
78 .Fn bt_devaddr "const char *name" "bdaddr_t *addr"
80 .Fn bt_devname "char *name" "const bdaddr_t *addr"
84 .Fn bt_gethostbyname ,
87 functions each return a pointer to an object with the
89 structure describing a Bluetooth host
90 referenced by name or by address, respectively.
97 .Dv NUL Ns -terminated
103 should point to an address which is
107 (i.e., not a Bluetooth BD_ADDR in human readable
112 argument specifies the address family of this address and must be set to
115 The structure returned contains the information obtained from a line in
116 .Pa /etc/bluetooth/hosts
121 function controls whether
122 .Pa /etc/bluetooth/hosts
123 file should stay open after each call to
126 .Fn bt_gethostbyaddr .
129 flag is non-zero, the file will not be closed.
134 .Pa /etc/bluetooth/hosts
139 .Fn bt_getprotobyname ,
141 .Fn bt_getprotobynumber
142 functions each return a pointer to an object with the
144 structure describing a Bluetooth Protocol Service Multiplexor referenced
145 by name or number, respectively.
150 .Fn bt_getprotobyname
152 .Dv NUL Ns -terminated
153 Bluetooth Protocol Service Multiplexor name.
157 .Fn bt_getprotobynumber
158 should have numeric value of the desired Bluetooth Protocol Service
161 The structure returned contains the information obtained from a line in
162 .Pa /etc/bluetooth/protocols
167 function controls whether
168 .Pa /etc/bluetooth/protocols
169 file should stay open after each call to
170 .Fn bt_getprotobyname
172 .Fn bt_getprotobynumber .
175 flag is non-zero, the file will not be closed.
180 .Pa /etc/bluetooth/protocols
185 routine interprets the specified character string as a Bluetooth address,
186 placing the address into the structure provided.
187 It returns 1 if the string was successfully interpreted,
188 or 0 if the string is invalid.
192 takes a Bluetooth address and places an
194 string representing the address into the buffer provided.
195 It is up to the caller to ensure that provided buffer has enough space.
196 If no buffer was provided then an internal static buffer will be used.
200 function interprets the specified character string as the
201 address or device name of a Bluetooth device on the local system, and
202 places the device address in the structure provided, if any.
203 It returns 1 if the string was successfully interpreted,
204 or 0 if the string did not match any local device. The
206 function takes a Bluetooth device address and copies the local device
207 name associated with that address into the buffer provided, if any.
208 It returns 1 when the device was found, otherwise 0.
210 .Bl -tag -width ".Pa /etc/bluetooth/hosts" -compact
211 .It Pa /etc/bluetooth/hosts
212 .It Pa /etc/bluetooth/protocols
215 Print out the hostname associated with a specific BD_ADDR:
216 .Bd -literal -offset indent
217 const char *bdstr = "00:01:02:03:04:05";
221 if (!bt_aton(bdstr, \*[Am]bd))
222 errx(1, "can't parse BD_ADDR %s", bdstr);
224 if ((hp = bt_gethostbyaddr(\*[Am]bd, sizeof(bd),
225 AF_BLUETOOTH)) == NULL)
226 errx(1, "no name associated with %s", bdstr);
228 printf("name associated with %s is %s\en", bdstr, hp-\*[Gt]h_name);
231 Error return status from
233 .Fn bt_gethostbyname ,
236 is indicated by return of a
241 may then be checked to see whether this is a temporary failure
242 or an invalid or unknown host.
245 can be used to print an error message describing the failure.
250 it is printed, followed by a colon and a space.
251 The error message is printed with a trailing newline.
255 can have the following values:
256 .Bl -tag -width ".Dv HOST_NOT_FOUND"
257 .It Dv HOST_NOT_FOUND
258 No such host is known.
260 Some unexpected server failure was encountered.
261 This is a non-recoverable error.
266 .Fn bt_getprotobyname ,
268 .Fn bt_getprotobynumber
273 .Xr gethostbyaddr 3 ,
274 .Xr gethostbyname 3 ,
275 .Xr getprotobyname 3 ,
276 .Xr getprotobynumber 3 ,
293 .An Maksim Yevmenkin Aq Mt m_evmenkin@yahoo.com
298 function reads the next line of
299 .Pa /etc/bluetooth/hosts ,
300 opening the file if necessary.
304 function opens and/or rewinds the
305 .Pa /etc/bluetooth/hosts
310 function reads the next line of
311 .Pa /etc/bluetooth/protocols ,
312 opening the file if necessary.
316 function opens and/or rewinds the
317 .Pa /etc/bluetooth/protocols
320 These functions use static data storage;
321 if the data is needed for future use, it should be
322 copied before any subsequent calls overwrite it.