summaryrefslogtreecommitdiffstats
path: root/compat
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-08-08 00:23:49 +0200
committerMarcel Holtmann <marcel@holtmann.org>2008-08-08 00:23:49 +0200
commit6bf2e483a385c2761ba2bd5a0b4299bc0a67c0e6 (patch)
tree8508d9f792ff669107d6f1f7ac15bec88933959d /compat
parentbd022e2e05b7adb33c1b5328ddb652231cbf7e58 (diff)
Allow BNEP connection to timeout after 30 seconds
Diffstat (limited to 'compat')
-rw-r--r--compat/bnep.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/compat/bnep.c b/compat/bnep.c
index 604ed552..841e5fad 100644
--- a/compat/bnep.c
+++ b/compat/bnep.c
@@ -257,6 +257,7 @@ int bnep_create_connection(int sk, uint16_t role, uint16_t svc, char *dev)
struct bnep_setup_conn_req *req;
struct bnep_control_rsp *rsp;
struct __service_16 *s;
+ struct timeval timeo;
unsigned char pkt[BNEP_MTU];
int r;
@@ -265,10 +266,16 @@ int bnep_create_connection(int sk, uint16_t role, uint16_t svc, char *dev)
req->type = BNEP_CONTROL;
req->ctrl = BNEP_SETUP_CONN_REQ;
req->uuid_size = 2; /* 16bit UUID */
+
s = (void *) req->service;
s->dst = htons(svc);
s->src = htons(role);
+ memset(&timeo, 0, sizeof(timeo));
+ timeo.tv_sec = 30;
+
+ setsockopt(sk, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo));
+
if (send(sk, pkt, sizeof(*req) + sizeof(*s), 0) < 0)
return -1;
@@ -278,6 +285,11 @@ receive:
if (r <= 0)
return -1;
+ memset(&timeo, 0, sizeof(timeo));
+ timeo.tv_sec = 0;
+
+ setsockopt(sk, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo));
+
errno = EPROTO;
if (r < sizeof(*rsp))