linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez-devel] [PATCH] authentification, encryption, and secure connection for rfcomm
@ 2006-12-04 11:17 Frédéric DALLEAU
  2006-12-24 13:49 ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: Frédéric DALLEAU @ 2006-12-04 11:17 UTC (permalink / raw)
  To: BlueZ development

[-- Attachment #1: Type: text/plain, Size: 168 bytes --]

Hi,

This patch adds command line options to rfcomm (--auth, --encrypt, 
--secure, --master) as in pand. It also updates the man page.

best regards,
Frédéric


[-- Attachment #2: patch_bluez_rfcomm_encrypt.patch --]
[-- Type: text/x-patch, Size: 4981 bytes --]

? Doxyfile
? Makefile.in
? aclocal.m4
? autom4te.cache
? bluezutils.kdevelop
? bluezutils.kdevelop.pcs
? bluezutils.kdevses
? config.guess
? config.h.in
? config.sub
? configure
? debug
? depcomp
? install-sh
? ltmain.sh
? missing
? stamp-h.in
? alsa/Makefile.in
? audio/Makefile.in
? common/Makefile.in
? cups/Makefile.in
? daemon/Makefile.in
? daemon/bt.echod
? daemon/service-agent-glue.h
? dund/Makefile.in
? fuse/Makefile.in
? hcid/Makefile.in
? hidd/Makefile.in
? input/Makefile.in
? network/Makefile.in
? pand/Makefile.in
? rfcomm/Makefile.in
? rfcomm/cvs
? rfcomm/main.c.modified
? rfcomm/main.patch
? scripts/Makefile.in
? sdpd/Makefile.in
? sync/Makefile.in
? test/Makefile.in
? tools/Makefile.in
Index: rfcomm/main.c
===================================================================
RCS file: /cvsroot/bluez/utils/rfcomm/main.c,v
retrieving revision 1.25
diff -u -r1.25 main.c
--- rfcomm/main.c	10 Nov 2006 23:18:53 -0000	1.25
+++ rfcomm/main.c	4 Dec 2006 11:09:55 -0000
@@ -54,7 +54,11 @@
 #endif
 
 static char *rfcomm_config_file = NULL;
-static int rfcomm_raw_tty = 0;
+static int  rfcomm_raw_tty = 0;
+static int  auth = 0;
+static int  encryption = 0;
+static int  secure = 0;
+static int  master = 0;
 
 extern int optind, opterr, optopt;
 extern char *optarg;
@@ -468,7 +472,7 @@
 	sigset_t sigs;
 	socklen_t alen;
 	char dst[18], devname[MAXPATHLEN];
-	int sk, nsk, fd, try = 30;
+	int sk, nsk, fd, lm, try = 30;
 
 	laddr.rc_family = AF_BLUETOOTH;
 	bacpy(&laddr.rc_bdaddr, bdaddr);
@@ -480,6 +484,22 @@
 		return;
 	}
 
+	lm = 0;
+	if (master)
+		lm |= RFCOMM_LM_MASTER;
+	if (auth)
+		lm |= RFCOMM_LM_AUTH;
+	if (encryption)
+		lm |= RFCOMM_LM_ENCRYPT;
+	if (secure)
+		lm |= RFCOMM_LM_SECURE;
+
+	if (lm && setsockopt(sk, SOL_RFCOMM, RFCOMM_LM, &lm, sizeof(lm)) < 0) {
+		perror("Can't set RFCOMM socket link mode");
+		return;
+	}
+
+
 	if (bind(sk, (struct sockaddr *)&laddr, sizeof(laddr)) < 0) {
 		perror("Can't bind RFCOMM socket");
 		close(sk);
@@ -660,6 +680,10 @@
 		"\t-i [hciX|bdaddr]      Local HCI device or BD Address\n"
 		"\t-h, --help            Display help\n"
 		"\t-r, --raw             Switch TTY into raw mode\n"
+		"\t-A, --auth            Enable authentication\n"
+		"\t-E, --encrypt         Enable encryption\n"
+		"\t-S, --secure          Secure connection\n"
+		"\t-M, --master          Become the master of a piconet\n"
 		"\t-f, --config [file]   Specify alternate config file\n" 
 		"\t-a                    Show all devices (default)\n"
 		"\n");
@@ -679,6 +703,10 @@
 	{ "device",	1, 0, 'i' },
 	{ "config",	1, 0, 'f' },
 	{ "raw",	0, 0, 'r' },
+	{ "auth",	0, 0, 'A' },
+	{ "encrypt",	0, 0, 'E' },
+	{ "secure",	0, 0, 'S' },
+	{ "master",	0, 0, 'M' },
 	{ 0, 0, 0, 0 }
 };
 
@@ -690,7 +718,7 @@
 
 	bacpy(&bdaddr, BDADDR_ANY);
 
-	while ((opt = getopt_long(argc, argv, "+i:f:rah", main_options, NULL)) != -1) {
+	while ((opt = getopt_long(argc, argv, "+i:f:rahAESM", main_options, NULL)) != -1) {
 		switch(opt) {
 		case 'i':
 			if (strncmp(optarg, "hci", 3) == 0)
@@ -714,6 +742,22 @@
 			usage();
 			exit(0);
 
+		case 'A':
+			auth = 1;
+			break;
+
+		case 'E':
+			encryption = 1;
+			break;
+
+		case 'S':
+			secure = 1;
+			break;
+
+		case 'M':
+			master = 1;
+			break;
+
 		default:
 			exit(0);
 		}
Index: rfcomm/rfcomm.1
===================================================================
RCS file: /cvsroot/bluez/utils/rfcomm/rfcomm.1,v
retrieving revision 1.5
diff -u -r1.5 rfcomm.1
--- rfcomm/rfcomm.1	10 Aug 2006 09:48:13 -0000	1.5
+++ rfcomm/rfcomm.1	4 Dec 2006 11:09:55 -0000
@@ -53,6 +53,14 @@
 .TP
 .BI -i " <hciX> | <bdaddr>"
 The command is applied to device
+.BI -A
+Enable authentification
+.BI -E
+Enable encryption
+.BI -S
+Secure connection
+.BI -M
+Become the master of a piconet
 .I
 hciX
 , which must be the name or the address of an installed Bluetooth
@@ -70,10 +78,22 @@
 tries to read the data from the config file. This command can
 be terminated with the key sequence CTRL-C.
 .TP 
-.BI listen " <dev> [channel]"
+.BI listen " <dev> [channel] [cmd]"
 Listen on a specified RFCOMM channel for incoming connections.
-If no channel is specified, it will use the channel number 1.
-This command can be terminated with the key sequence CTRL-C.
+If no channel is specified, it will use the channel number 1, but
+a channel must be specified before cmd. If cmd is given, it will be
+executed as soon as a client connects. When the child process 
+terminates or the client disconnect, the command will terminate.
+Occurences of {} in cmd will be replaced by the name of the device
+used by the connection. This command can be terminated with the key
+sequence CTRL-C.
+.TP
+.BI watch " <dev> [channel] [cmd]"
+Watch is identical to
+.B listen
+except that when the child process terminates or the client
+disconnect, the command will restart listening with the same 
+parameters.
 .TP
 .BI bind " <dev> [bdaddr] [channel]"
 This binds the RFCOMM device to a remote Bluetooth device. The

[-- Attachment #3: Type: text/plain, Size: 347 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Bluez-devel] [PATCH] authentification, encryption, and secure connection for rfcomm
  2006-12-04 11:17 [Bluez-devel] [PATCH] authentification, encryption, and secure connection for rfcomm Frédéric DALLEAU
@ 2006-12-24 13:49 ` Marcel Holtmann
  2006-12-24 14:00   ` I have acquired the Core Spec 2.1,can I develop it and patch to bluez kernel? 高 迎宾
  0 siblings, 1 reply; 4+ messages in thread
From: Marcel Holtmann @ 2006-12-24 13:49 UTC (permalink / raw)
  To: BlueZ development

Hi Frederic,

> This patch adds command line options to rfcomm (--auth, --encrypt, 
> --secure, --master) as in pand. It also updates the man page.

you actually forgot one close(sk) in the error path and the manual page
changes are screwed up, but besides that patch is fine. I fixed this and
committed it.

Regards

Marcel



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* I have acquired the Core Spec 2.1,can I develop it and patch to bluez kernel?
  2006-12-24 13:49 ` Marcel Holtmann
@ 2006-12-24 14:00   ` 高 迎宾
  2006-12-24 14:34     ` [Bluez-devel] I have acquired the Core Spec 2.1, can " Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: 高 迎宾 @ 2006-12-24 14:00 UTC (permalink / raw)
  To: bluez-devel; +Cc: marcel

Hi, marcel,
I have acquired the Core Spec 2.1,can I develop it and patch to bluez 
kernel? 
thanks.

_________________________________________________________________
免费下载 MSN Explorer:   http://explorer.msn.com/lccn/  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Bluez-devel] I have acquired the Core Spec 2.1, can I develop it and patch to bluez kernel?
  2006-12-24 14:00   ` I have acquired the Core Spec 2.1,can I develop it and patch to bluez kernel? 高 迎宾
@ 2006-12-24 14:34     ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2006-12-24 14:34 UTC (permalink / raw)
  To: 高 迎宾; +Cc: bluez-devel

Hi,

> I have acquired the Core Spec 2.1,can I develop it and patch to bluez 
> kernel? 

feel free to send in patches. We will review them.

Regards

Marcel



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-12-24 14:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-04 11:17 [Bluez-devel] [PATCH] authentification, encryption, and secure connection for rfcomm Frédéric DALLEAU
2006-12-24 13:49 ` Marcel Holtmann
2006-12-24 14:00   ` I have acquired the Core Spec 2.1,can I develop it and patch to bluez kernel? 高 迎宾
2006-12-24 14:34     ` [Bluez-devel] I have acquired the Core Spec 2.1, can " Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).