summaryrefslogtreecommitdiffstats
path: root/dund/main.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-01-23 19:44:12 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-01-23 19:44:12 +0000
commitba53bc4c8888a3dee5214b25a1f8f846ea8b5bc4 (patch)
tree1ca839d0221f2eda8ced79b85a53393299f5fd00 /dund/main.c
parent9f859424c471dc8e52a1fa3873ab627966d80316 (diff)
Enable the RFCOMM service level security
Diffstat (limited to 'dund/main.c')
-rw-r--r--dund/main.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/dund/main.c b/dund/main.c
index b7d2b356..3eb4eb7f 100644
--- a/dund/main.c
+++ b/dund/main.c
@@ -71,6 +71,7 @@ static int detach = 1;
static int persist;
static int use_sdp = 1;
static int encrypt;
+static int secure;
static int master;
static int mrouter;
static int search_duration = 10;
@@ -103,7 +104,7 @@ static int create_connection(char *dst, bdaddr_t *bdaddr, int mrouter);
static int do_listen(void)
{
struct sockaddr_rc sa;
- int sk;
+ int sk, lm;
if (mrouter) {
if (!cache.valid)
@@ -142,6 +143,20 @@ static int do_listen(void)
return -1;
}
+ /* Set link mode */
+ lm = 0;
+ if (master)
+ lm |= RFCOMM_LM_MASTER;
+ if (encrypt)
+ lm |= RFCOMM_LM_ENCRYPT;
+ if (secure)
+ lm |= RFCOMM_LM_SECURE;
+
+ if (lm && setsockopt(sk, SOL_RFCOMM, RFCOMM_LM, &lm, sizeof(lm)) < 0) {
+ syslog(LOG_ERR, "Failed to set link mode. %s(%d)", strerror(errno), errno);
+ return -1;
+ }
+
listen(sk, 10);
while (!terminate) {
@@ -376,6 +391,7 @@ static struct option main_lopts[] = {
{ "nodetach", 0, 0, 'n' },
{ "persist", 2, 0, 'p' },
{ "encrypt", 0, 0, 'E' },
+ { "secure", 0, 0, 'S' },
{ "master", 0, 0, 'M' },
{ "cache", 0, 0, 'C' },
{ "pppd", 1, 0, 'd' },
@@ -384,7 +400,7 @@ static struct option main_lopts[] = {
{ 0, 0, 0, 0 }
};
-static char main_sopts[] = "hsc:k:Kr:i:lnp::DQ::EMP:C::P:X";
+static char main_sopts[] = "hsc:k:Kr:i:lnp::DQ::ESMP:C::P:X";
static char main_help[] =
"Bluetooth LAP (LAN Access over PPP) daemon version " VERSION " \n"
@@ -401,6 +417,9 @@ static char main_help[] =
"\t--channel -P <channel> RFCOMM channel\n"
"\t--device -i <bdaddr> Source bdaddr\n"
"\t--nosdp -D Disable SDP\n"
+ "\t--encrypt -E Enable encryption\n"
+ "\t--secure -S Secure connection\n"
+ "\t--master -M Become the master of a piconet\n"
"\t--nodetach -n Do not become a daemon\n"
"\t--persist -p[interval] Persist mode\n"
"\t--pppd -d <pppd> Location of the PPP daemon (pppd)\n"
@@ -465,6 +484,10 @@ int main(int argc, char **argv)
encrypt = 1;
break;
+ case 'S':
+ secure = 1;
+ break;
+
case 'M':
master = 1;
break;