Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Mar 2009 18:03:46 +0000 (UTC)
From:      Maksim Yevmenkin <emax@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r189414 - in stable/7/usr.sbin/bluetooth: . btpand sdpd
Message-ID:  <200903051803.n25I3kEn095351@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emax
Date: Thu Mar  5 18:03:46 2009
New Revision: 189414
URL: http://svn.freebsd.org/changeset/base/189414

Log:
  MFC r187938
  Add btpand(8) daemon from NetBSD. This daemon provides support for
  Bluetooth Network Access Point (NAP), Group Ad-hoc Network (GN) and
  Personal Area Network User (PANU) profiles.
  
  MFC r188013
  Fix client mode. Pick up service availability changes.
  
  MFC r188014
  Hook up btpand(8) to the build
  
  Obtained from:	NetBSD

Added:
  stable/7/usr.sbin/bluetooth/btpand/
     - copied from r187938, head/usr.sbin/bluetooth/btpand/
Modified:
  stable/7/usr.sbin/bluetooth/   (props changed)
  stable/7/usr.sbin/bluetooth/Makefile
  stable/7/usr.sbin/bluetooth/btpand/btpand.c
  stable/7/usr.sbin/bluetooth/btpand/btpand.h
  stable/7/usr.sbin/bluetooth/btpand/server.c
  stable/7/usr.sbin/bluetooth/sdpd/   (props changed)

Modified: stable/7/usr.sbin/bluetooth/Makefile
==============================================================================
--- stable/7/usr.sbin/bluetooth/Makefile	Thu Mar  5 17:54:28 2009	(r189413)
+++ stable/7/usr.sbin/bluetooth/Makefile	Thu Mar  5 18:03:46 2009	(r189414)
@@ -6,6 +6,7 @@ SUBDIR= \
 	bt3cfw \
 	bthidcontrol \
 	bthidd \
+	btpand \
 	hccontrol \
 	hcsecd \
 	hcseriald \

Modified: stable/7/usr.sbin/bluetooth/btpand/btpand.c
==============================================================================
--- head/usr.sbin/bluetooth/btpand/btpand.c	Fri Jan 30 22:23:21 2009	(r187938)
+++ stable/7/usr.sbin/bluetooth/btpand/btpand.c	Thu Mar  5 18:03:46 2009	(r189414)
@@ -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;

Modified: stable/7/usr.sbin/bluetooth/btpand/btpand.h
==============================================================================
--- head/usr.sbin/bluetooth/btpand/btpand.h	Fri Jan 30 22:23:21 2009	(r187938)
+++ stable/7/usr.sbin/bluetooth/btpand/btpand.h	Thu Mar  5 18:03:46 2009	(r189414)
@@ -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;

Modified: stable/7/usr.sbin/bluetooth/btpand/server.c
==============================================================================
--- head/usr.sbin/bluetooth/btpand/server.c	Fri Jan 30 22:23:21 2009	(r187938)
+++ stable/7/usr.sbin/bluetooth/btpand/server.c	Thu Mar  5 18:03:46 2009	(r189414)
@@ -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
 
 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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903051803.n25I3kEn095351>