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 .Nd get Bluetooth host entry
39 .Nm bt_getprotobyname ,
40 .Nm bt_getprotobynumber ,
44 .Nd get Bluetooth Protocol Service Multiplexor entry
48 .Nd Bluetooth address manipulation routines
54 .Fn bt_gethostbyname "const char *name"
56 .Fn bt_gethostbyaddr "const char *addr" "int 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"
84 each return a pointer to an object with the
86 structure describing a Bluetooth host
87 referenced by name or by address, respectively.
94 .Dv NUL Ns -terminated
100 should point to an address which is
104 (i.e. not an Bluetooth BD_ADDR in human readable
109 argument specifies the address family of this address and must be set to
112 The structure returned contains the information obtained from a line in
113 .Pa /etc/bluetooth/hosts
118 function controls whether
119 .Pa /etc/bluetooth/hosts
120 file should stay open after each call to
123 .Fn bt_gethostbyaddr .
126 flag is non-zero, the file will not be closed.
131 .Pa /etc/bluetooth/hosts
136 .Fn bt_getprotobyname
138 .Fn bt_getprotobynumber
139 functions each return a pointer to an object with the
141 structure describing a Bluetooth Protocol Service Multiplexor referenced
142 by name or number, respectively.
147 .Fn bt_getprotobyname
149 .Dv NUL Ns -terminated
150 Bluetooth Protocol Service Multiplexor name.
154 .Fn bt_getprotobynumber
155 should have numeric value of the desired Bluetooth Protocol Service Multiplexor.
157 The structure returned contains the information obtained from a line in
158 .Pa /etc/bluetooth/protocols
163 function controls whether
164 .Pa /etc/bluetooth/protocols
165 file should stay open after each call to
166 .Fn bt_getprotobyname
168 .Fn bt_getprotobynumber .
171 flag is non-zero, the file will not be closed.
176 .Pa /etc/bluetooth/protocols
181 routine interprets the specified character string as a Bluetooth address,
182 placing the address into the structure provided.
183 It returns 1 if the string was successfully interpreted,
184 or 0 if the string is invalid.
188 takes a Bluetooth address and places an
190 string representing the address into the buffer provided.
191 It is up to the caller to ensure that provided buffer has enough space.
192 If no buffer was provided then internal static buffer will be used.
194 .Bl -tag -width /etc/bluetooth/hosts -compact
195 .It Pa /etc/bluetooth/hosts
196 .It Pa /etc/bluetooth/protocols
199 Print out the hostname associated with a specific BD_ADDR:
200 .Bd -literal -offset indent
201 const char *bdstr = "00:01:02:03:04:05";
205 if (!bt_aton(bdstr, &bd))
206 errx(1, "can't parse BD_ADDR %s", bdstr);
208 if ((hp = bt_gethostbyaddr((const char *)&bd,
209 sizeof(bd), AF_BLUETOOTH)) == NULL)
210 errx(1, "no name associated with %s", bdstr);
212 printf("name associated with %s is %s\en", bdstr, hp->h_name);
215 Error return status from
220 is indicated by return of a
225 may then be checked to see whether this is a temporary failure
226 or an invalid or unknown host.
229 can be used to print an error message describing the failure.
234 it is printed, followed by a colon and a space.
235 The error message is printed with a trailing newline.
239 can have the following values:
240 .Bl -tag -width HOST_NOT_FOUND
241 .It Dv HOST_NOT_FOUND
242 No such host is known.
244 Some unexpected server failure was encountered.
245 This is a non-recoverable error.
250 .Fn bt_getprotobyname
252 .Fn bt_getprotobynumber
253 return Null pointer (0) on
257 .Xr gethostbyaddr 3 ,
258 .Xr gethostbyname 3 ,
259 .Xr getprotobyaddr 3 ,
260 .Xr getprotobynumber 3 ,
267 function reads the next line of
268 .Pa /etc/bluetooth/hosts ,
269 opening the file if necessary.
273 function opens and/or rewinds the
274 .Pa /etc/bluetooth/hosts
279 function reads the next line of
280 .Pa /etc/bluetooth/protocols ,
281 opening the file if necessary.
285 function opens and/or rewinds the
286 .Pa /etc/bluetooth/protocols
289 These functions use static data storage;
290 if the data is needed for future use, it should be
291 copied before any subsequent calls overwrite it.
293 .An Maksim Yevmenkin Aq m_evmenkin@yahoo.com