summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bluetooth
diff options
context:
space:
mode:
authoremax <emax@FreeBSD.org>2009-02-02 18:08:22 +0000
committeremax <emax@FreeBSD.org>2009-02-02 18:08:22 +0000
commitd19589c5eef4f8d9e8660cee6ad86e0b06350d9f (patch)
tree2e54c06154bb4794d41def7e9ec81c7d7196651d /usr.sbin/bluetooth
parent286b1aea9dca17ec0ddf351a096c7530fc43f114 (diff)
downloadFreeBSD-src-d19589c5eef4f8d9e8660cee6ad86e0b06350d9f.zip
FreeBSD-src-d19589c5eef4f8d9e8660cee6ad86e0b06350d9f.tar.gz
Fix client mode. Pick up service availability changes.
Obtained from: NetBSD MFC after: 1 month
Diffstat (limited to 'usr.sbin/bluetooth')
-rw-r--r--usr.sbin/bluetooth/btpand/btpand.c7
-rw-r--r--usr.sbin/bluetooth/btpand/btpand.h4
-rw-r--r--usr.sbin/bluetooth/btpand/server.c29
3 files changed, 19 insertions, 21 deletions
diff --git a/usr.sbin/bluetooth/btpand/btpand.c b/usr.sbin/bluetooth/btpand/btpand.c
index 57ee133..99a3bc7 100644
--- a/usr.sbin/bluetooth/btpand/btpand.c
+++ b/usr.sbin/bluetooth/btpand/btpand.c
@@ -54,8 +54,8 @@ uint16_t service_class;
bdaddr_t local_bdaddr; /* -d <addr> */
bdaddr_t remote_bdaddr; /* -a <addr> */
-uint16_t l2cap_psm = 15; /* -p <psm> */
-int l2cap_mode = 0; /* -m <mode> */
+uint16_t l2cap_psm; /* -p <psm> */
+int l2cap_mode; /* -m <mode> */
int server_limit; /* -n <limit> */
@@ -177,6 +177,9 @@ main(int argc, char *argv[])
if (interface_name == NULL)
interface_name = "/dev/tap";
+ if (l2cap_psm == 0)
+ l2cap_psm = L2CAP_PSM_BNEP;
+
if (bdaddr_any(&remote_bdaddr) && server_limit == 0) {
if (service_class == SDP_SERVICE_CLASS_PANU)
server_limit = 1;
diff --git a/usr.sbin/bluetooth/btpand/btpand.h b/usr.sbin/bluetooth/btpand/btpand.h
index 23a9c76..c5f7204 100644
--- a/usr.sbin/bluetooth/btpand/btpand.h
+++ b/usr.sbin/bluetooth/btpand/btpand.h
@@ -51,6 +51,10 @@
#define L2CAP_PSM_INVALID(psm) (((psm) & 0x0101) != 0x0001)
#endif
+#ifndef L2CAP_PSM_BNEP
+#define L2CAP_PSM_BNEP 15
+#endif
+
typedef struct channel channel_t;
typedef struct pfilter pfilter_t;
typedef struct mfilter mfilter_t;
diff --git a/usr.sbin/bluetooth/btpand/server.c b/usr.sbin/bluetooth/btpand/server.c
index 5600c3b..0843d0c 100644
--- a/usr.sbin/bluetooth/btpand/server.c
+++ b/usr.sbin/bluetooth/btpand/server.c
@@ -1,4 +1,4 @@
-/* $NetBSD: server.c,v 1.1 2008/08/17 13:20:57 plunky Exp $ */
+/* $NetBSD: server.c,v 1.2 2009/01/24 17:29:28 plunky Exp $ */
/*-
* Copyright (c) 2008 Iain Hibbert
@@ -28,11 +28,12 @@
/* $FreeBSD$ */
#include <sys/cdefs.h>
-__RCSID("$NetBSD: server.c,v 1.1 2008/08/17 13:20:57 plunky Exp $");
+__RCSID("$NetBSD: server.c,v 1.2 2009/01/24 17:29:28 plunky Exp $");
#include <sys/ioctl.h>
#include <bluetooth.h>
+#include <inttypes.h>
#include <errno.h>
#include <sdp.h>
#include <unistd.h>
@@ -42,7 +43,7 @@ __RCSID("$NetBSD: server.c,v 1.1 2008/08/17 13:20:57 plunky Exp $");
static struct event server_ev;
static int server_fd;
-static int server_load;
+static int server_avail;
static void * server_ss;
static uint32_t server_handle;
@@ -73,13 +74,13 @@ server_update(int count)
log_debug("count %d", count);
- server_load = (count - 1) * 100 / server_limit;
- log_info("server_load: %d%%", server_load);
+ server_avail = UINT8_MAX - (count - 1) * UINT8_MAX / server_limit;
+ log_info("Service Availability: %d/%d", server_avail, UINT8_MAX);
- if (server_load > 99 && server_fd != -1)
+ if (server_avail == 0 && server_fd != -1)
server_close();
- if (server_load < 100 && server_fd == -1)
+ if (server_avail > 0 && server_fd == -1)
server_open();
if (service_name)
@@ -257,19 +258,9 @@ server_register(void)
}
memset(&p, 0, sizeof(p));
-
p.psm = l2cap_psm;
-
- if (server_load < 1) p.load_factor = 0;
- else if (server_load <= 17) p.load_factor = 1;
- else if (server_load <= 33) p.load_factor = 2;
- else if (server_load <= 50) p.load_factor = 3;
- else if (server_load <= 67) p.load_factor = 4;
- else if (server_load <= 83) p.load_factor = 5;
- else if (server_load <= 99) p.load_factor = 6;
- else p.load_factor = 7;
-
- if (l2cap_mode != 0) p.security_description = 0x0001;
+ p.load_factor = server_avail;
+ p.security_description = (l2cap_mode == 0 ? 0x0000 : 0x0001);
if (server_handle)
rv = sdp_change_service(server_ss, server_handle,
OpenPOWER on IntegriCloud