1190203Srpaulo/*
2190203Srpaulo * Copyright (c) 2007
3190203Srpaulo *	paolo.abeni@email.it  All rights reserved.
4190203Srpaulo *
5190203Srpaulo * Redistribution and use in source and binary forms, with or without
6190203Srpaulo * modification, are permitted provided that: (1) source code distributions
7190203Srpaulo * retain the above copyright notice and this paragraph in its entirety, (2)
8190203Srpaulo * distributions including binary code include the above copyright notice and
9190203Srpaulo * this paragraph in its entirety in the documentation or other materials
10190203Srpaulo * provided with the distribution, and (3) all advertising materials mentioning
11190203Srpaulo * features or use of this software display the following acknowledgement:
12190203Srpaulo * ``This product includes software developed by Paolo Abeni.''
13190203Srpaulo * The name of author may not be used to endorse or promote products derived
14190203Srpaulo * from this software without specific prior written permission.
15190203Srpaulo * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
16190203Srpaulo * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17190203Srpaulo * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18190203Srpaulo */
19190203Srpaulo
20190203Srpaulo#ifndef lint
21190203Srpaulostatic const char rcsid[] _U_ =
22214478Srpaulo    "@(#) $Header: /tcpdump/master/tcpdump/print-bt.c,v 1.2 2008-09-25 21:45:50 guy Exp $";
23190203Srpaulo#endif
24190203Srpaulo
25190203Srpaulo#ifdef HAVE_CONFIG_H
26190203Srpaulo#include "config.h"
27190203Srpaulo#endif
28190203Srpaulo
29190203Srpaulo#include <tcpdump-stdinc.h>
30190203Srpaulo
31190203Srpaulo#include <pcap.h>
32190203Srpaulo#include <stdio.h>
33190203Srpaulo#include <string.h>
34190203Srpaulo
35190203Srpaulo#include "interface.h"
36214478Srpaulo#include "extract.h"
37190203Srpaulo#include "addrtoname.h"
38190203Srpaulo
39190203Srpaulo#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
40190203Srpaulo#include <pcap/bluetooth.h>
41190203Srpaulo
42190203Srpaulo#define	BT_HDRLEN sizeof(pcap_bluetooth_h4_header)
43190203Srpaulo/*
44190203Srpaulo * This is the top level routine of the printer.  'p' points
45190203Srpaulo * to the bluetooth header of the packet, 'h->ts' is the timestamp,
46190203Srpaulo * 'h->len' is the length of the packet off the wire, and 'h->caplen'
47190203Srpaulo * is the number of bytes actually captured.
48190203Srpaulo */
49190203Srpaulou_int
50190203Srpaulobt_if_print(const struct pcap_pkthdr *h, const u_char *p)
51190203Srpaulo{
52190203Srpaulo	u_int length = h->len;
53190203Srpaulo	u_int caplen = h->caplen;
54190203Srpaulo	const pcap_bluetooth_h4_header* hdr = (const pcap_bluetooth_h4_header*)p;
55190203Srpaulo
56190203Srpaulo	if (caplen < BT_HDRLEN) {
57190203Srpaulo		printf("[|bt]");
58190203Srpaulo		return (BT_HDRLEN);
59190203Srpaulo	}
60190203Srpaulo	caplen -= BT_HDRLEN;
61190203Srpaulo	length -= BT_HDRLEN;
62190203Srpaulo	p += BT_HDRLEN;
63190203Srpaulo	if (eflag)
64214478Srpaulo		(void)printf("hci length %d, direction %s, ", length, (EXTRACT_32BITS(&hdr->direction)&0x1)?"in":"out");
65190203Srpaulo
66190203Srpaulo	if (!suppress_default_print)
67190203Srpaulo		default_print(p, caplen);
68190203Srpaulo
69190203Srpaulo	return (BT_HDRLEN);
70190203Srpaulo}
71190203Srpaulo#endif
72190203Srpaulo
73190203Srpaulo
74190203Srpaulo/*
75190203Srpaulo * Local Variables:
76190203Srpaulo * c-style: whitesmith
77190203Srpaulo * c-basic-offset: 8
78190203Srpaulo * End:
79190203Srpaulo */
80