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 .\" $FreeBSD: src/lib/libbluetooth/bluetooth.3,v 1.7 2005/01/21 10:26:11 ru Exp $
33 .Nm bt_gethostbyname ,
34 .Nm bt_gethostbyaddr ,
38 .Nm bt_getprotobyname ,
39 .Nm bt_getprotobynumber ,
45 .Nd Bluetooth host lookup routines
51 .Fn bt_gethostbyname "const char *name"
53 .Fn bt_gethostbyaddr "const char *addr" "int len" "int type"
55 .Fn bt_gethostent void
57 .Fn bt_sethostent "int stayopen"
59 .Fn bt_endhostent void
61 .Fn bt_getprotobyname "const char *name"
63 .Fn bt_getprotobynumber "int proto"
65 .Fn bt_getprotoent void
67 .Fn bt_setprotoent "int stayopen"
69 .Fn bt_endprotoent void
71 .Fn bt_aton "const char *str" "bdaddr_t *ba"
73 .Fn bt_ntoa "const bdaddr_t *ba" "char *str"
77 .Fn bt_gethostbyname ,
80 functions each return a pointer to an object with the
82 structure describing a Bluetooth host
83 referenced by name or by address, respectively.
90 .Dv NUL Ns -terminated
96 should point to an address which is
100 (i.e., not a Bluetooth BD_ADDR in human readable
105 argument specifies the address family of this address and must be set to
108 The structure returned contains the information obtained from a line in
109 .Pa /etc/bluetooth/hosts
114 function controls whether
115 .Pa /etc/bluetooth/hosts
116 file should stay open after each call to
119 .Fn bt_gethostbyaddr .
122 flag is non-zero, the file will not be closed.
127 .Pa /etc/bluetooth/hosts
132 .Fn bt_getprotobyname ,
134 .Fn bt_getprotobynumber
135 functions each return a pointer to an object with the
137 structure describing a Bluetooth Protocol Service Multiplexor referenced
138 by name or number, respectively.
143 .Fn bt_getprotobyname
145 .Dv NUL Ns -terminated
146 Bluetooth Protocol Service Multiplexor name.
150 .Fn bt_getprotobynumber
151 should have numeric value of the desired Bluetooth Protocol Service
154 The structure returned contains the information obtained from a line in
155 .Pa /etc/bluetooth/protocols
160 function controls whether
161 .Pa /etc/bluetooth/protocols
162 file should stay open after each call to
163 .Fn bt_getprotobyname
165 .Fn bt_getprotobynumber .
168 flag is non-zero, the file will not be closed.
173 .Pa /etc/bluetooth/protocols
178 routine interprets the specified character string as a Bluetooth address,
179 placing the address into the structure provided.
180 It returns 1 if the string was successfully interpreted,
181 or 0 if the string is invalid.
185 takes a Bluetooth address and places an
187 string representing the address into the buffer provided.
188 It is up to the caller to ensure that provided buffer has enough space.
189 If no buffer was provided then an internal static buffer will be used.
191 .Bl -tag -width ".Pa /etc/bluetooth/hosts" -compact
192 .It Pa /etc/bluetooth/hosts
193 .It Pa /etc/bluetooth/protocols
196 Print out the hostname associated with a specific BD_ADDR:
197 .Bd -literal -offset indent
198 const char *bdstr = "00:01:02:03:04:05";
202 if (!bt_aton(bdstr, \*[Am]bd))
203 errx(1, "can't parse BD_ADDR %s", bdstr);
205 if ((hp = bt_gethostbyaddr((const char *)\*[Am]bd,
206 sizeof(bd), AF_BLUETOOTH)) == NULL)
207 errx(1, "no name associated with %s", bdstr);
209 printf("name associated with %s is %s\en", bdstr, hp-\*[Gt]h_name);
212 Error return status from
214 .Fn bt_gethostbyname ,
217 is indicated by return of a
222 may then be checked to see whether this is a temporary failure
223 or an invalid or unknown host.
226 can be used to print an error message describing the failure.
231 it is printed, followed by a colon and a space.
232 The error message is printed with a trailing newline.
236 can have the following values:
237 .Bl -tag -width ".Dv HOST_NOT_FOUND"
238 .It Dv HOST_NOT_FOUND
239 No such host is known.
241 Some unexpected server failure was encountered.
242 This is a non-recoverable error.
247 .Fn bt_getprotobyname ,
249 .Fn bt_getprotobynumber
254 .Xr gethostbyaddr 3 ,
255 .Xr gethostbyname 3 ,
256 .Xr getprotobyname 3 ,
257 .Xr getprotobynumber 3 ,
271 .An Maksim Yevmenkin Aq m_evmenkin@yahoo.com
276 function reads the next line of
277 .Pa /etc/bluetooth/hosts ,
278 opening the file if necessary.
282 function opens and/or rewinds the
283 .Pa /etc/bluetooth/hosts
288 function reads the next line of
289 .Pa /etc/bluetooth/protocols ,
290 opening the file if necessary.
294 function opens and/or rewinds the
295 .Pa /etc/bluetooth/protocols
298 These functions use static data storage;
299 if the data is needed for future use, it should be
300 copied before any subsequent calls overwrite it.