authentification, encryption, and secure connection for rfcomm
PATCH 1/1 authentification, encryption, and secure connection for rfcomm
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
? 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
main.c +47 -3
@@ -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
rfcomm.1 +23 -3
@@ -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
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel Holtmann
maintainerHi Frederic,
Quoted 2 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
I have acquired the Core Spec 2.1,can I develop it and patch to bluez kernel?
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/
Marcel Holtmann
maintainerRe: [Bluez-devel] I have acquired the Core Spec 2.1, can I develop it and patch to bluez kernel?
Hi,
Quoted 2 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel