3
* BlueZ - Bluetooth protocol stack for Linux
5
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
6
* Copyright (C) 2002-2008 Marcel Holtmann <marcel@holtmann.org>
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
46
static sigjmp_buf jmp;
50
static void sig_alarm(int sig)
52
siglongjmp(jmp, MS_TIMEOUT);
55
static int w4_str(int fd, char *str)
61
r = read(fd, buf + len, sizeof(buf) - len - 1);
63
if (errno == EINTR || errno == EAGAIN)
72
if (len < strlen(str))
86
static int ms_server(int fd)
88
switch (w4_str(fd, "CLIENT")) {
90
write_n(fd, "CLIENTSERVER", 12);
98
static int ms_client(int fd)
100
write_n(fd, "CLIENT", 6);
101
return w4_str(fd, "CLIENTSERVER");
104
int ms_dun(int fd, int server, int timeo)
114
osig = signal(SIGALRM, sig_alarm);
117
int r = sigsetjmp(jmp, 1);
119
if (r == MS_TIMEOUT && !server && --retry)
123
signal(SIGALRM, osig);