aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaksim Yevmenkin <emax@FreeBSD.org>2004-01-09 22:44:28 +0000
committerMaksim Yevmenkin <emax@FreeBSD.org>2004-01-09 22:44:28 +0000
commita4b187fa33f1856b9c0293b900d36b4c797b459d (patch)
tree6ed17ae08cf9c5d4fd244460555de488ae99253b
parent91c9d24e52990321cc7f9b116388386f065b34e5 (diff)
downloadsrc-a4b187fa33f1856b9c0293b900d36b4c797b459d.tar.gz
src-a4b187fa33f1856b9c0293b900d36b4c797b459d.zip
Notes
-rw-r--r--lib/libsdp/sdp.310
-rw-r--r--lib/libsdp/sdp.h2
-rw-r--r--lib/libsdp/session.c7
-rw-r--r--usr.sbin/bluetooth/sdpcontrol/sdpcontrol.825
-rw-r--r--usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c47
-rw-r--r--usr.sbin/bluetooth/sdpcontrol/search.c72
6 files changed, 103 insertions, 60 deletions
diff --git a/lib/libsdp/sdp.3 b/lib/libsdp/sdp.3
index 88c6ff7c0f8e..e849780e265e 100644
--- a/lib/libsdp/sdp.3
+++ b/lib/libsdp/sdp.3
@@ -73,7 +73,7 @@
.Ft void *
.Fn sdp_open "bdaddr_t const *l" "bdaddr_t const *r"
.Ft void *
-.Fn sdp_open_local "void"
+.Fn sdp_open_local "char const *control"
.Ft int32_t
.Fn sdp_close "void *xs"
.Ft int32_t
@@ -134,7 +134,13 @@ Remote BD_ADDR can not be
.Dv NG_HCI_BDADDR_ANY .
The
.Fn sdp_open_local
-function takes no arguments and opens a connection to a local SDP server.
+function takes path to the control socket and opens a connection to a local
+SDP server.
+If path to the control socket is
+.Dv NULL
+then default
+.Pa /var/run/sdp
+path will be used.
.Pp
The
.Fn sdp_close
diff --git a/lib/libsdp/sdp.h b/lib/libsdp/sdp.h
index 3987ffb28352..4f5fb277bca4 100644
--- a/lib/libsdp/sdp.h
+++ b/lib/libsdp/sdp.h
@@ -469,7 +469,7 @@ typedef struct sdp_attr * sdp_attr_p;
#endif /* BYTE_ORDER */
void * sdp_open (bdaddr_t const *l, bdaddr_t const *r);
-void * sdp_open_local (void);
+void * sdp_open_local (char const *control);
int32_t sdp_close (void *xs);
int32_t sdp_error (void *xs);
diff --git a/lib/libsdp/session.c b/lib/libsdp/session.c
index 2a1303905b0f..a31f3278dc0f 100644
--- a/lib/libsdp/session.c
+++ b/lib/libsdp/session.c
@@ -102,7 +102,7 @@ fail:
}
void *
-sdp_open_local(void)
+sdp_open_local(char const *control)
{
sdp_session_p ss = NULL;
struct sockaddr_un sa;
@@ -116,9 +116,12 @@ sdp_open_local(void)
goto fail;
}
+ if (control == NULL)
+ control = SDP_LOCAL_PATH;
+
sa.sun_len = sizeof(sa);
sa.sun_family = AF_UNIX;
- strlcpy(sa.sun_path, SDP_LOCAL_PATH, sizeof(sa.sun_path));
+ strlcpy(sa.sun_path, control, sizeof(sa.sun_path));
if (connect(ss->s, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
ss->error = errno;
diff --git a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.8 b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.8
index a7f1f6b26e7d..b37c47d8dcf3 100644
--- a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.8
+++ b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.8
@@ -30,18 +30,25 @@
.Os
.Sh NAME
.Nm spdcontrol
-.Nd SDP configuration utility
+.Nd SDP query utility
.Sh SYNOPSIS
.Nm
-.Op Fl h
+.Fl h
+.Nm
.Fl a Ar BD_ADDR
.Ar command
.Op Ar parameters ...
+.Nm
+.Fl l
+.Op Fl c Ar path
+.Ar command
+.Op Ar parameters ...
.Sh DESCRIPTION
The
.Nm
-utility connects to the remote device with the specified BD_ADDR and attempts
-to send query via Service Discovery Protocol (SDP).
+utility attempts to query specified Service Discovery Protocol (SDP) server.
+Remote SDP servers are identified by their BD_ADDRs.
+Connection to the local SDP server is made via control socket.
The
.Nm
utility will use Service Search Attribute Request and will print results to
@@ -53,8 +60,14 @@ The options are as follows:
Connect to the remote device with the specified BD_ADDR.
Example:
.Fl a Li 00:01:02:03:04:05 .
+.It Fl c Ar path
+Specify path to the control socket.
+The default path is
+.Pa /var/run/sdp .
.It Fl h
Display usage message and exit.
+.It Fl l
+Query the local SDP server via the control socket.
.It Ar command
One of the supported commands (see below).
Special command
@@ -75,13 +88,13 @@ are:
.It Cm Search
.El
.Sh CAVEAT
-Currently, the
+The
.Nm
utility only implements client side functionality.
.Pp
The
.Nm
-utility only request the following attributes from the remote SDP server:
+utility only requests the following attributes from the SDP server:
.Bl -enum -offset indent -compact
.It
Service Record Handle
diff --git a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c
index b5a1a4d8afa8..d77438655c46 100644
--- a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c
+++ b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c
@@ -41,7 +41,8 @@
#include "sdpcontrol.h"
/* Prototypes */
-static int do_sdp_command (bdaddr_p, int, char **);
+static int do_sdp_command (bdaddr_p, char const *, int,
+ int, char **);
static struct sdp_command * find_sdp_command (char const *,
struct sdp_command *);
static void print_sdp_command (struct sdp_command *);
@@ -51,15 +52,16 @@ static void usage (void);
int
main(int argc, char *argv[])
{
- int n;
- bdaddr_t bdaddr;
+ char const *control = SDP_LOCAL_PATH;
+ int n, local;
+ bdaddr_t bdaddr;
memset(&bdaddr, 0, sizeof(bdaddr));
/* Process command line arguments */
- while ((n = getopt(argc, argv, "a:h")) != -1) {
+ while ((n = getopt(argc, argv, "a:c:lh")) != -1) {
switch (n) {
- case 'a':
+ case 'a': /* bdaddr */
if (!bt_aton(optarg, &bdaddr)) {
struct hostent *he = NULL;
@@ -70,6 +72,14 @@ main(int argc, char *argv[])
}
break;
+ case 'c': /* control socket */
+ control = optarg;
+ break;
+
+ case 'l': /* local sdpd */
+ local = 1;
+ break;
+
case 'h':
default:
usage();
@@ -83,12 +93,13 @@ main(int argc, char *argv[])
if (*argv == NULL)
usage();
- return (do_sdp_command(&bdaddr, argc, argv));
+ return (do_sdp_command(&bdaddr, control, local, argc, argv));
}
/* Execute commands */
static int
-do_sdp_command(bdaddr_p bdaddr, int argc, char **argv)
+do_sdp_command(bdaddr_p bdaddr, char const *control, int local,
+ int argc, char **argv)
{
char *cmd = argv[0];
struct sdp_command *c = NULL;
@@ -120,12 +131,16 @@ do_sdp_command(bdaddr_p bdaddr, int argc, char **argv)
}
if (!help) {
- if (memcmp(bdaddr, NG_HCI_BDADDR_ANY, sizeof(*bdaddr)) == 0)
- usage();
+ if (!local) {
+ if (memcmp(bdaddr, NG_HCI_BDADDR_ANY, sizeof(*bdaddr)) == 0)
+ usage();
- if ((xs = sdp_open(NG_HCI_BDADDR_ANY, bdaddr)) == NULL)
- errx(1, "Could not create SDP session object");
+ xs = sdp_open(NG_HCI_BDADDR_ANY, bdaddr);
+ } else
+ xs = sdp_open_local(control);
+ if (xs == NULL)
+ errx(1, "Could not create SDP session object");
if (sdp_error(xs) == 0)
e = (c->handler)(xs, -- argc, ++ argv);
else
@@ -190,8 +205,14 @@ print_sdp_command(struct sdp_command *category)
static void
usage(void)
{
- fprintf(stdout, "Usage: sdpcontrol -a BD_ADDR [-h] " \
- "cmd [p1] [..]]\n");
+ fprintf(stderr,
+"Usage: sdpcontrol options command\n" \
+"Where options are:\n"
+" -a bdaddr specify bdaddr\n" \
+" -c path path to the control socket (default is %s)\n" \
+" -h display usage and quit\n" \
+" -l connect to the local SDP server via control socket\n" \
+" command one of the supported commands\n", SDP_LOCAL_PATH);
exit(255);
} /* usage */
diff --git a/usr.sbin/bluetooth/sdpcontrol/search.c b/usr.sbin/bluetooth/sdpcontrol/search.c
index 71809524aa71..458d78b62cc5 100644
--- a/usr.sbin/bluetooth/sdpcontrol/search.c
+++ b/usr.sbin/bluetooth/sdpcontrol/search.c
@@ -37,7 +37,7 @@
#include "sdpcontrol.h"
/* List of the attributes we are looking for */
-static u_int32_t attrs[] =
+static uint32_t attrs[] =
{
SDP_ATTR_RANGE( SDP_ATTR_SERVICE_RECORD_HANDLE,
SDP_ATTR_SERVICE_RECORD_HANDLE),
@@ -53,7 +53,7 @@ static u_int32_t attrs[] =
/* Buffer for the attributes */
#define NRECS 25 /* request this much records from the SDP server */
#define BSIZE 256 /* one attribute buffer size */
-static u_int8_t buffer[NRECS * attrs_len][BSIZE];
+static uint8_t buffer[NRECS * attrs_len][BSIZE];
/* SDP attributes */
static sdp_attr_t values[NRECS * attrs_len];
@@ -70,9 +70,9 @@ static sdp_attr_t values[NRECS * attrs_len];
*/
static void
-print_service_class_id_list(u_int8_t const *start, u_int8_t const *end)
+print_service_class_id_list(uint8_t const *start, uint8_t const *end)
{
- u_int32_t type, len, value;
+ uint32_t type, len, value;
if (end - start < 2) {
fprintf(stderr, "Invalid Service Class ID List. " \
@@ -120,12 +120,12 @@ print_service_class_id_list(u_int8_t const *start, u_int8_t const *end)
SDP_GET128(&uuid, start);
fprintf(stdout, "\t%#8.8x-%4.4x-%4.4x-%4.4x-%4.4x%8.8x\n",
- *(u_int32_t *)&uuid.b[0],
- *(u_int16_t *)&uuid.b[4],
- *(u_int16_t *)&uuid.b[6],
- *(u_int16_t *)&uuid.b[8],
- *(u_int16_t *)&uuid.b[10],
- *(u_int32_t *)&uuid.b[12]);
+ *(uint32_t *)&uuid.b[0],
+ *(uint16_t *)&uuid.b[4],
+ *(uint16_t *)&uuid.b[6],
+ *(uint16_t *)&uuid.b[8],
+ *(uint16_t *)&uuid.b[10],
+ *(uint32_t *)&uuid.b[12]);
} break;
default:
@@ -153,7 +153,7 @@ print_service_class_id_list(u_int8_t const *start, u_int8_t const *end)
*/
static void
-print_protocol_descriptor(u_int8_t const *start, u_int8_t const *end)
+print_protocol_descriptor(uint8_t const *start, uint8_t const *end)
{
union {
uint8_t uint8;
@@ -162,7 +162,7 @@ print_protocol_descriptor(u_int8_t const *start, u_int8_t const *end)
uint64_t uint64;
int128_t int128;
} value;
- u_int32_t type, len, param;
+ uint32_t type, len, param;
/* Get Protocol UUID */
SDP_GET8(type, start);
@@ -181,12 +181,12 @@ print_protocol_descriptor(u_int8_t const *start, u_int8_t const *end)
case SDP_DATA_UUID128:
SDP_GET128(&value.int128, start);
fprintf(stdout, "\t%#8.8x-%4.4x-%4.4x-%4.4x-%4.4x%8.8x\n",
- *(u_int32_t *)&value.int128.b[0],
- *(u_int16_t *)&value.int128.b[4],
- *(u_int16_t *)&value.int128.b[6],
- *(u_int16_t *)&value.int128.b[8],
- *(u_int16_t *)&value.int128.b[10],
- *(u_int32_t *)&value.int128.b[12]);
+ *(uint32_t *)&value.int128.b[0],
+ *(uint16_t *)&value.int128.b[4],
+ *(uint16_t *)&value.int128.b[6],
+ *(uint16_t *)&value.int128.b[8],
+ *(uint16_t *)&value.int128.b[10],
+ *(uint32_t *)&value.int128.b[12]);
break;
default:
@@ -238,12 +238,12 @@ print_protocol_descriptor(u_int8_t const *start, u_int8_t const *end)
case SDP_DATA_UUID128:
SDP_GET128(&value.int128, start);
fprintf(stdout, "u/int/uuid128 %#8.8x-%4.4x-%4.4x-%4.4x-%4.4x%8.8x\n",
- *(u_int32_t *)&value.int128.b[0],
- *(u_int16_t *)&value.int128.b[4],
- *(u_int16_t *)&value.int128.b[6],
- *(u_int16_t *)&value.int128.b[8],
- *(u_int16_t *)&value.int128.b[10],
- *(u_int32_t *)&value.int128.b[12]);
+ *(uint32_t *)&value.int128.b[0],
+ *(uint16_t *)&value.int128.b[4],
+ *(uint16_t *)&value.int128.b[6],
+ *(uint16_t *)&value.int128.b[8],
+ *(uint16_t *)&value.int128.b[10],
+ *(uint32_t *)&value.int128.b[12]);
break;
case SDP_DATA_STR8:
@@ -301,9 +301,9 @@ print_protocol_descriptor(u_int8_t const *start, u_int8_t const *end)
} /* print_protocol_descriptor */
static void
-print_protocol_descriptor_list(u_int8_t const *start, u_int8_t const *end)
+print_protocol_descriptor_list(uint8_t const *start, uint8_t const *end)
{
- u_int32_t type, len;
+ uint32_t type, len;
if (end - start < 2) {
fprintf(stderr, "Invalid Protocol Descriptor List. " \
@@ -375,9 +375,9 @@ print_protocol_descriptor_list(u_int8_t const *start, u_int8_t const *end)
*/
static void
-print_bluetooth_profile_descriptor_list(u_int8_t const *start, u_int8_t const *end)
+print_bluetooth_profile_descriptor_list(uint8_t const *start, uint8_t const *end)
{
- u_int32_t type, len, value;
+ uint32_t type, len, value;
if (end - start < 2) {
fprintf(stderr, "Invalid Bluetooth Profile Descriptor List. " \
@@ -448,12 +448,12 @@ print_bluetooth_profile_descriptor_list(u_int8_t const *start, u_int8_t const *e
SDP_GET128(&uuid, start);
fprintf(stdout, "\t%#8.8x-%4.4x-%4.4x-%4.4x-%4.4x%8.8x ",
- *(u_int32_t *)&uuid.b[0],
- *(u_int16_t *)&uuid.b[4],
- *(u_int16_t *)&uuid.b[6],
- *(u_int16_t *)&uuid.b[8],
- *(u_int16_t *)&uuid.b[10],
- *(u_int32_t *)&uuid.b[12]);
+ *(uint32_t *)&uuid.b[0],
+ *(uint16_t *)&uuid.b[4],
+ *(uint16_t *)&uuid.b[6],
+ *(uint16_t *)&uuid.b[8],
+ *(uint16_t *)&uuid.b[10],
+ *(uint32_t *)&uuid.b[12]);
} break;
default:
@@ -485,7 +485,7 @@ do_sdp_search(void *xs, int argc, char **argv)
{
char *ep = NULL;
int32_t n, type, value;
- u_int16_t service;
+ uint16_t service;
/* Parse command line arguments */
switch (argc) {
@@ -570,7 +570,7 @@ do_sdp_search(void *xs, int argc, char **argv)
/* NOT REACHED */
}
} else
- service = (u_int16_t) n;
+ service = (uint16_t) n;
break;
default: