diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2005-01-23 19:44:12 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2005-01-23 19:44:12 +0000 |
commit | ba53bc4c8888a3dee5214b25a1f8f846ea8b5bc4 (patch) | |
tree | 1ca839d0221f2eda8ced79b85a53393299f5fd00 | |
parent | 9f859424c471dc8e52a1fa3873ab627966d80316 (diff) |
Enable the RFCOMM service level security
-rw-r--r-- | dund/dund.1 | 3 | ||||
-rw-r--r-- | dund/main.c | 27 |
2 files changed, 28 insertions, 2 deletions
diff --git a/dund/dund.1 b/dund/dund.1 index 7b4e7cd9..41354774 100644 --- a/dund/dund.1 +++ b/dund/dund.1 @@ -38,6 +38,9 @@ Disable SDP \fB\-\-encrypt\fR \fB\-E\fR Enable encryption .TP +\fB\-\-secure\fR \fB\-S\fR +Secure connection +.TP \fB\-\-master\fR \fB\-M\fR Become the master of a piconet .TP 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; |