diff options
author | emax <emax@FreeBSD.org> | 2003-10-12 22:04:24 +0000 |
---|---|---|
committer | emax <emax@FreeBSD.org> | 2003-10-12 22:04:24 +0000 |
commit | 41bb0e8fd2568243020852e22a6d176bccfa60cd (patch) | |
tree | 0ae0c2be63f9f9161693789721b96beb9cabcc77 /usr.sbin/bluetooth/hccontrol/util.c | |
parent | 66feac7937e372f502539e7d443aee80a25abe16 (diff) | |
download | FreeBSD-src-41bb0e8fd2568243020852e22a6d176bccfa60cd.zip FreeBSD-src-41bb0e8fd2568243020852e22a6d176bccfa60cd.tar.gz |
Update Bluetooth code.
Reviewed by: M. Warner Losh <imp@bsdimp.com>; John Hay <jhay@freebsd.org>
Approved by: M. Warner Losh <imp@bsdimp.com> (mentor)
Diffstat (limited to 'usr.sbin/bluetooth/hccontrol/util.c')
-rw-r--r-- | usr.sbin/bluetooth/hccontrol/util.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/usr.sbin/bluetooth/hccontrol/util.c b/usr.sbin/bluetooth/hccontrol/util.c index 7abe4d4..53b110a 100644 --- a/usr.sbin/bluetooth/hccontrol/util.c +++ b/usr.sbin/bluetooth/hccontrol/util.c @@ -25,11 +25,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: util.c,v 1.1 2002/11/24 20:22:38 max Exp $ + * $Id: util.c,v 1.2 2003/05/19 17:29:29 max Exp $ * $FreeBSD$ */ -#include <sys/types.h> +#include <sys/param.h> +#include <bluetooth.h> +#include <stdio.h> #include <string.h> #define SIZE(x) (sizeof((x))/sizeof((x)[0])) @@ -348,3 +350,29 @@ hci_status2str(int status) return (status >= SIZE(t)? "Unknown error" : t[status]); } /* hci_status2str */ +char const * const +hci_bdaddr2str(bdaddr_t const *ba) +{ + extern int numeric_bdaddr; + static char buffer[MAXHOSTNAMELEN]; + struct hostent *he = NULL; + + if (memcmp(ba, NG_HCI_BDADDR_ANY, sizeof(*ba)) == 0) { + buffer[0] = '*'; + buffer[1] = 0; + + return (buffer); + } + + if (!numeric_bdaddr && + (he = bt_gethostbyaddr((char *)ba, sizeof(*ba), AF_BLUETOOTH)) != NULL) { + strlcpy(buffer, he->h_name, sizeof(buffer)); + + return (buffer); + } + + bt_ntoa(ba, buffer); + + return (buffer); +} /* hci_bdaddr2str */ + |