summaryrefslogtreecommitdiffstats
path: root/pand
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-08-16 10:54:06 +0000
committerMarcel Holtmann <marcel@holtmann.org>2006-08-16 10:54:06 +0000
commita1bc48d15a5d6e78efe744eb7b27b6421cb7222f (patch)
treea7880f87c2585311975e4087d36255c9f1f0b7ec /pand
parenta23442be507d9384175898a28fb72c35f790fbd1 (diff)
Convert to using ppoll() and pselect()
Diffstat (limited to 'pand')
-rw-r--r--pand/Makefile.am2
-rw-r--r--pand/main.c34
2 files changed, 17 insertions, 19 deletions
diff --git a/pand/Makefile.am b/pand/Makefile.am
index 3d92aa85..342b2244 100644
--- a/pand/Makefile.am
+++ b/pand/Makefile.am
@@ -6,6 +6,8 @@ pand_LDADD = @BLUEZ_LIBS@
AM_CFLAGS = @BLUEZ_CFLAGS@
+INCLUDES = -I$(top_srcdir)/common
+
man_MANS = pand.1
EXTRA_DIST = $(man_MANS)
diff --git a/pand/main.c b/pand/main.c
index fd77e4ab..026a879d 100644
--- a/pand/main.c
+++ b/pand/main.c
@@ -26,6 +26,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
@@ -48,6 +49,10 @@
#include "pand.h"
+#ifdef NEED_PPOLL
+#include "ppoll.h"
+#endif
+
static uint16_t role = BNEP_SVC_PANU; /* Local role (ie service) */
static uint16_t service = BNEP_SVC_NAP; /* Remote service */
@@ -55,10 +60,7 @@ static int detach = 1;
static int persist;
static int use_sdp = 1;
static int use_cache;
-static int auth;
-static int encrypt;
-static int secure;
-static int master;
+static int link_mode = 0;
static int cleanup;
static int search_duration = 10;
@@ -168,16 +170,7 @@ static int do_listen(void)
}
/* Set link mode */
- lm = 0;
- if (master)
- lm |= L2CAP_LM_MASTER;
- if (auth)
- lm |= L2CAP_LM_AUTH;
- if (encrypt)
- lm |= L2CAP_LM_ENCRYPT;
- if (secure)
- lm |= L2CAP_LM_SECURE;
-
+ lm = link_mode;
if (lm && setsockopt(sk, SOL_L2CAP, L2CAP_LM, &lm, sizeof(lm)) < 0) {
syslog(LOG_ERR, "Failed to set link mode. %s(%d)",
strerror(errno), errno);
@@ -238,12 +231,15 @@ static int do_listen(void)
static int w4_hup(int sk)
{
struct pollfd pf;
+ sigset_t sigs;
int n;
+ sigfillset(&sigs);
+
while (!terminate) {
pf.fd = sk;
pf.events = POLLERR | POLLHUP;
- n = poll(&pf, 1, -1);
+ n = ppoll(&pf, 1, NULL, &sigs);
if (n < 0) {
if (errno == EINTR || errno == EAGAIN)
continue;
@@ -614,19 +610,19 @@ int main(int argc, char *argv[])
break;
case 'A':
- auth = 1;
+ link_mode |= L2CAP_LM_AUTH;
break;
case 'E':
- encrypt = 1;
+ link_mode |= L2CAP_LM_ENCRYPT;
break;
case 'S':
- secure = 1;
+ link_mode |= L2CAP_LM_SECURE;
break;
case 'M':
- master = 1;
+ link_mode |= L2CAP_LM_MASTER;
break;
case 'e':