diff options
Diffstat (limited to 'compat')
-rw-r--r-- | compat/bnep.c | 12 |
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)) |