Import handy shorthand Bluetooth address (BD_ADDR) utility functions
from NetBSD and document them. Obtained from: NetBSD MFC after: 1 week
This commit is contained in:
parent
f40611e24f
commit
55034c7d1d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=181698
@ -27,4 +27,8 @@ MLINKS+= bluetooth.3 bt_endprotoent.3
|
|||||||
MLINKS+= bluetooth.3 bt_ntoa.3
|
MLINKS+= bluetooth.3 bt_ntoa.3
|
||||||
MLINKS+= bluetooth.3 bt_aton.3
|
MLINKS+= bluetooth.3 bt_aton.3
|
||||||
|
|
||||||
|
MLINKS+= bluetooth.3 bdaddr_same.3
|
||||||
|
MLINKS+= bluetooth.3 bdaddr_any.3
|
||||||
|
MLINKS+= bluetooth.3 bdaddr_copy.3
|
||||||
|
|
||||||
.include <bsd.lib.mk>
|
.include <bsd.lib.mk>
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
.\" $Id: bluetooth.3,v 1.5 2003/05/20 23:04:30 max Exp $
|
.\" $Id: bluetooth.3,v 1.5 2003/05/20 23:04:30 max Exp $
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd May 7, 2003
|
.Dd August 13, 2008
|
||||||
.Dt BLUETOOTH 3
|
.Dt BLUETOOTH 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -40,7 +40,10 @@
|
|||||||
.Nm bt_setprotoent ,
|
.Nm bt_setprotoent ,
|
||||||
.Nm bt_endprotoent ,
|
.Nm bt_endprotoent ,
|
||||||
.Nm bt_aton ,
|
.Nm bt_aton ,
|
||||||
.Nm bt_ntoa
|
.Nm bt_ntoa ,
|
||||||
|
.Nm bdaddr_same ,
|
||||||
|
.Nm bdaddr_any ,
|
||||||
|
.Nm bdaddr_copy
|
||||||
.Nd Bluetooth routines
|
.Nd Bluetooth routines
|
||||||
.Sh LIBRARY
|
.Sh LIBRARY
|
||||||
.Lb libbluetooth
|
.Lb libbluetooth
|
||||||
@ -70,6 +73,12 @@
|
|||||||
.Fn bt_aton "const char *str" "bdaddr_t *ba"
|
.Fn bt_aton "const char *str" "bdaddr_t *ba"
|
||||||
.Ft const char *
|
.Ft const char *
|
||||||
.Fn bt_ntoa "const bdaddr_t *ba" "char *str"
|
.Fn bt_ntoa "const bdaddr_t *ba" "char *str"
|
||||||
|
.Ft int
|
||||||
|
.Fn bdaddr_same "const bdaddr_t *a" "const bdaddr_t *b"
|
||||||
|
.Ft int
|
||||||
|
.Fn bdaddr_any "const bdaddr_t *a"
|
||||||
|
.Ft int
|
||||||
|
.Fn bdaddr_copy "const bdaddr_t *dst" "const bdaddr_t *src"
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Fn bt_gethostent ,
|
.Fn bt_gethostent ,
|
||||||
@ -186,6 +195,28 @@ takes a Bluetooth address and places an
|
|||||||
string representing the address into the buffer provided.
|
string representing the address into the buffer provided.
|
||||||
It is up to the caller to ensure that provided buffer has enough space.
|
It is up to the caller to ensure that provided buffer has enough space.
|
||||||
If no buffer was provided then internal static buffer will be used.
|
If no buffer was provided then internal static buffer will be used.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn bdaddr_same ,
|
||||||
|
.Fn bdaddr_any
|
||||||
|
and
|
||||||
|
.Fn bdaddr_copy
|
||||||
|
are handy shorthand Bluetooth address utility functions.
|
||||||
|
The
|
||||||
|
.Fn bdaddr_same
|
||||||
|
function will test if two provided BD_ADDRs are the same.
|
||||||
|
The
|
||||||
|
.Fn bdaddr_any
|
||||||
|
function will test if provided BD_ADDR is
|
||||||
|
.Dv ANY
|
||||||
|
BD_ADDR.
|
||||||
|
The
|
||||||
|
.Fn bdaddr_copy
|
||||||
|
function will copy provided
|
||||||
|
.Fa src
|
||||||
|
BD_ADDR into provided
|
||||||
|
.Fa dst
|
||||||
|
BD_ADDR.
|
||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Bl -tag -width ".Pa /etc/bluetooth/hosts" -compact
|
.Bl -tag -width ".Pa /etc/bluetooth/hosts" -compact
|
||||||
.It Pa /etc/bluetooth/hosts
|
.It Pa /etc/bluetooth/hosts
|
||||||
|
@ -72,6 +72,36 @@ void bt_endprotoent (void);
|
|||||||
char const * bt_ntoa (bdaddr_t const *ba, char *str);
|
char const * bt_ntoa (bdaddr_t const *ba, char *str);
|
||||||
int bt_aton (char const *str, bdaddr_t *ba);
|
int bt_aton (char const *str, bdaddr_t *ba);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* bdaddr utility functions (from NetBSD)
|
||||||
|
*/
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
bdaddr_same(const bdaddr_t *a, const bdaddr_t *b)
|
||||||
|
{
|
||||||
|
return (a->b[0] == b->b[0] && a->b[1] == b->b[1] &&
|
||||||
|
a->b[2] == b->b[2] && a->b[3] == b->b[3] &&
|
||||||
|
a->b[4] == b->b[4] && a->b[5] == b->b[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline int
|
||||||
|
bdaddr_any(const bdaddr_t *a)
|
||||||
|
{
|
||||||
|
return (a->b[0] == 0 && a->b[1] == 0 && a->b[2] == 0 &&
|
||||||
|
a->b[3] == 0 && a->b[4] == 0 && a->b[5] == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline void
|
||||||
|
bdaddr_copy(bdaddr_t *d, const bdaddr_t *s)
|
||||||
|
{
|
||||||
|
d->b[0] = s->b[0];
|
||||||
|
d->b[1] = s->b[1];
|
||||||
|
d->b[2] = s->b[2];
|
||||||
|
d->b[3] = s->b[3];
|
||||||
|
d->b[4] = s->b[4];
|
||||||
|
d->b[5] = s->b[5];
|
||||||
|
}
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
#endif /* ndef _BLUETOOTH_H_ */
|
#endif /* ndef _BLUETOOTH_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user