From 323b4c2a9fa579064bae4a1c548d6c480901dde5 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 3 Mar 2004 02:03:49 +0000 Subject: [PATCH] hcidump: Update copyright information --- tools/hcidump.c | 108 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 80 insertions(+), 28 deletions(-) diff --git a/tools/hcidump.c b/tools/hcidump.c index ac076d366..fa2711e48 100644 --- a/tools/hcidump.c +++ b/tools/hcidump.c @@ -1,54 +1,63 @@ -/* - HCIDump - HCI packet analyzer - Copyright (C) 2000-2001 Maxim Krasnyansky - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation; - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. - IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY CLAIM, - OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER - RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE - USE OR PERFORMANCE OF THIS SOFTWARE. - - ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, COPYRIGHTS, - TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS SOFTWARE IS DISCLAIMED. -*/ - /* - * $Id$ + * + * Bluetooth packet analyzer - HCIdump + * + * Copyright (C) 2000-2002 Maxim Krasnyansky + * Copyright (C) 2003-2004 Marcel Holtmann + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * $Id$ */ #include +#include +#include #include #include #include -#include -#include #include -#include #include +#include #include -#include #include +#include #include #include #include #include #include -#include #include -#include "hcidump.h" #include "parser.h" #include "sdp.h" + +#define SNAP_LEN HCI_MAX_FRAME_SIZE + +/* Modes */ +enum { + PARSE, + READ, + WRITE +}; + /* Default options */ static int device; static int snap_len = SNAP_LEN; @@ -58,6 +67,49 @@ static long flags; static long filter; static char *dump_file; +struct dump_hdr { + uint16_t len; + uint8_t in; + uint8_t pad; + uint32_t ts_sec; + uint32_t ts_usec; +} __attribute__ ((packed)); +#define DUMP_HDR_SIZE (sizeof(struct dump_hdr)) + +static inline int read_n(int fd, char *buf, int len) +{ + register int t = 0, w; + + while (len > 0) { + if ((w = read(fd, buf, len)) < 0) { + if( errno == EINTR || errno == EAGAIN ) + continue; + return -1; + } + if (!w) + return 0; + len -= w; buf += w; t += w; + } + return t; +} + +static inline int write_n(int fd, char *buf, int len) +{ + register int t = 0, w; + + while (len > 0) { + if ((w = write(fd, buf, len)) < 0) { + if( errno == EINTR || errno == EAGAIN ) + continue; + return -1; + } + if (!w) + return 0; + len -= w; buf += w; t += w; + } + return t; +} + static void process_frames(int dev, int sock, int file) { struct cmsghdr *cmsg; -- 2.47.3