1 .\" Copyright (c) 2003 Maksim Yevmenkin <m_evmenkin@yahoo.com>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" $Id: bluetooth.3,v 1.5 2003/05/20 23:04:30 max Exp $
32 .Nm bt_gethostbyname ,
33 .Nm bt_gethostbyaddr ,
37 .Nm bt_getprotobyname ,
38 .Nm bt_getprotobynumber ,
44 .Nd Bluetooth routines
50 .Fn bt_gethostbyname "const char *name"
52 .Fn bt_gethostbyaddr "const char *addr" "int len" "int type"
54 .Fn bt_gethostent void
56 .Fn bt_sethostent "int stayopen"
58 .Fn bt_endhostent void
60 .Fn bt_getprotobyname "const char *name"
62 .Fn bt_getprotobynumber "int proto"
64 .Fn bt_getprotoent void
66 .Fn bt_setprotoent "int stayopen"
68 .Fn bt_endprotoent void
70 .Fn bt_aton "const char *str" "bdaddr_t *ba"
72 .Fn bt_ntoa "const bdaddr_t *ba" "char *str"
80 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 Multiplexor.
153 The structure returned contains the information obtained from a line in
154 .Pa /etc/bluetooth/protocols
159 function controls whether
160 .Pa /etc/bluetooth/protocols
161 file should stay open after each call to
162 .Fn bt_getprotobyname
164 .Fn bt_getprotobynumber .
167 flag is non-zero, the file will not be closed.
172 .Pa /etc/bluetooth/protocols
177 routine interprets the specified character string as a Bluetooth address,
178 placing the address into the structure provided.
179 It returns 1 if the string was successfully interpreted,
180 or 0 if the string is invalid.
184 takes a Bluetooth address and places an
186 string representing the address into the buffer provided.
187 It is up to the caller to ensure that provided buffer has enough space.
188 If no buffer was provided then internal static buffer will be used.
190 .Bl -tag -width ".Pa /etc/bluetooth/hosts" -compact
191 .It Pa /etc/bluetooth/hosts
192 .It Pa /etc/bluetooth/protocols
195 Print out the hostname associated with a specific BD_ADDR:
196 .Bd -literal -offset indent
197 const char *bdstr = "00:01:02:03:04:05";
201 if (!bt_aton(bdstr, &bd))
202 errx(1, "can't parse BD_ADDR %s", bdstr);
204 if ((hp = bt_gethostbyaddr((const char *)&bd,
205 sizeof(bd), AF_BLUETOOTH)) == NULL)
206 errx(1, "no name associated with %s", bdstr);
208 printf("name associated with %s is %s\en", bdstr, hp->h_name);
211 Error return status from
216 is indicated by return of a
221 may then be checked to see whether this is a temporary failure
222 or an invalid or unknown host.
225 can be used to print an error message describing the failure.
230 it is printed, followed by a colon and a space.
231 The error message is printed with a trailing newline.
235 can have the following values:
236 .Bl -tag -width ".Dv HOST_NOT_FOUND"
237 .It Dv HOST_NOT_FOUND
238 No such host is known.
240 Some unexpected server failure was encountered.
241 This is a non-recoverable error.
246 .Fn bt_getprotobyname
248 .Fn bt_getprotobynumber
253 .Xr gethostbyaddr 3 ,
254 .Xr gethostbyname 3 ,
255 .Xr getprotobyname 3 ,
256 .Xr getprotobynumber 3 ,
263 function reads the next line of
264 .Pa /etc/bluetooth/hosts ,
265 opening the file if necessary.
269 function opens and/or rewinds the
270 .Pa /etc/bluetooth/hosts
275 function reads the next line of
276 .Pa /etc/bluetooth/protocols ,
277 opening the file if necessary.
281 function opens and/or rewinds the
282 .Pa /etc/bluetooth/protocols
285 .An Maksim Yevmenkin Aq m_evmenkin@yahoo.com
287 These functions use static data storage;
288 if the data is needed for future use, it should be
289 copied before any subsequent calls overwrite it.