2007-09-25 07:46:26 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007
|
|
|
|
* paolo.abeni@email.it All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that: (1) source code distributions
|
|
|
|
* retain the above copyright notice and this paragraph in its entirety, (2)
|
|
|
|
* distributions including binary code include the above copyright notice and
|
|
|
|
* this paragraph in its entirety in the documentation or other materials
|
|
|
|
* provided with the distribution, and (3) all advertising materials mentioning
|
|
|
|
* features or use of this software display the following acknowledgement:
|
2014-01-02 10:27:54 +08:00
|
|
|
* ``This product includes software developed by Paolo Abeni.''
|
|
|
|
* The name of author may not be used to endorse or promote products derived
|
2007-09-25 07:46:26 +08:00
|
|
|
* from this software without specific prior written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
|
|
|
|
2016-08-14 21:42:19 +08:00
|
|
|
/* \summary: Bluetooth printer */
|
|
|
|
|
2018-01-22 04:27:08 +08:00
|
|
|
#include <config.h>
|
2007-09-25 07:46:26 +08:00
|
|
|
|
2018-01-20 22:59:49 +08:00
|
|
|
#include "netdissect-stdinc.h"
|
2007-09-25 07:46:26 +08:00
|
|
|
|
2020-10-17 19:55:33 +08:00
|
|
|
#define ND_LONGJMP_FROM_TCHECK
|
2015-09-06 05:35:58 +08:00
|
|
|
#include "netdissect.h"
|
2010-02-21 16:27:00 +08:00
|
|
|
#include "extract.h"
|
2007-09-25 07:46:26 +08:00
|
|
|
|
2018-05-24 05:12:45 +08:00
|
|
|
#ifdef DLT_BLUETOOTH_HCI_H4_WITH_PHDR
|
2007-09-25 07:46:26 +08:00
|
|
|
|
2018-05-24 05:12:45 +08:00
|
|
|
/*
|
|
|
|
* Header prepended by libpcap to each bluetooth h4 frame;
|
|
|
|
* the direction field is in network byte order.
|
|
|
|
*/
|
|
|
|
typedef struct _bluetooth_h4_header {
|
|
|
|
nd_uint32_t direction; /* if first bit is set direction is incoming */
|
|
|
|
} bluetooth_h4_header;
|
|
|
|
|
|
|
|
#define BT_HDRLEN sizeof(bluetooth_h4_header)
|
2018-04-05 04:20:23 +08:00
|
|
|
|
2007-09-25 07:46:26 +08:00
|
|
|
/*
|
|
|
|
* This is the top level routine of the printer. 'p' points
|
|
|
|
* to the bluetooth header of the packet, 'h->ts' is the timestamp,
|
|
|
|
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
|
|
|
|
* is the number of bytes actually captured.
|
|
|
|
*/
|
2020-02-07 03:27:06 +08:00
|
|
|
void
|
2014-03-07 21:52:45 +08:00
|
|
|
bt_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
|
2007-09-25 07:46:26 +08:00
|
|
|
{
|
|
|
|
u_int length = h->len;
|
|
|
|
u_int caplen = h->caplen;
|
2021-12-31 03:07:18 +08:00
|
|
|
const bluetooth_h4_header *hdr = (const bluetooth_h4_header *)p;
|
2007-09-25 07:46:26 +08:00
|
|
|
|
2019-03-19 21:53:09 +08:00
|
|
|
ndo->ndo_protocol = "bluetooth";
|
|
|
|
nd_print_protocol(ndo);
|
2020-10-17 19:55:33 +08:00
|
|
|
ND_TCHECK_LEN(p, BT_HDRLEN);
|
2020-07-14 23:32:55 +08:00
|
|
|
ndo->ndo_ll_hdr_len += BT_HDRLEN;
|
2007-09-25 07:46:26 +08:00
|
|
|
caplen -= BT_HDRLEN;
|
|
|
|
length -= BT_HDRLEN;
|
|
|
|
p += BT_HDRLEN;
|
2014-03-07 21:52:45 +08:00
|
|
|
if (ndo->ndo_eflag)
|
2019-03-19 21:53:09 +08:00
|
|
|
ND_PRINT(", hci length %u, direction %s", length,
|
2018-06-16 23:23:21 +08:00
|
|
|
(GET_BE_U_4(hdr->direction)&0x1) ? "in" : "out");
|
2007-09-25 07:46:26 +08:00
|
|
|
|
2014-03-07 21:52:45 +08:00
|
|
|
if (!ndo->ndo_suppress_default_print)
|
2014-03-26 22:52:40 +08:00
|
|
|
ND_DEFAULTPRINT(p, caplen);
|
2007-09-25 07:46:26 +08:00
|
|
|
}
|
|
|
|
#endif
|