aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2007-12-16 14:21:37 +0000
committerStig Bjørlykke <stig@bjorlykke.org>2007-12-16 14:21:37 +0000
commitfa34d4685193d15f856182c73e097702be1453e3 (patch)
treed74c802d7aa125ab811a5e94734c6a25ebb1f456 /wiretap
parent53f5c9aaf5a15b46c6615e8dfc414c6f08464843 (diff)
downloadwireshark-fa34d4685193d15f856182c73e097702be1453e3.tar.gz
wireshark-fa34d4685193d15f856182c73e097702be1453e3.tar.bz2
wireshark-fa34d4685193d15f856182c73e097702be1453e3.zip
From Fulko Hew:
1/ patches to support the libpcap/SITA format 'WTAP_ENCAP_SITA'. 2/ patches to the LAPB dissector to accept MLP (Multi-link protocol) (although MLP dissection has _not_ been added (yet)). 3/ New protocol dissectors for: a) SITA's WAN layer 0 status header, b) An airline protocol ALC, c) An airline (and other industry) protocol UTS. These patches are submitted as a set since the new protocol dissectors are not useful without the libpcap/SITA related changes, and there is no point in having those changes without the additional dissectors. This fixes bug/enhancement 2016. svn path=/trunk/; revision=23885
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/libpcap.c103
-rw-r--r--wiretap/wtap.c3
-rw-r--r--wiretap/wtap.h66
3 files changed, 172 insertions, 0 deletions
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index e8bd95ade1..268d25d370 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -76,6 +76,16 @@
#define MTP2_HDR_LEN 4 /* length of the header */
/*
+ * A header containing additional SITA WAN information.
+ */
+#define SITA_FLAGS_OFFSET 0 /* 1 byte */
+#define SITA_SIGNALS_OFFSET 1 /* 1 byte */
+#define SITA_ERRORS1_OFFSET 2 /* 1 byte */
+#define SITA_ERRORS2_OFFSET 3 /* 1 byte */
+#define SITA_PROTO_OFFSET 4 /* 1 byte */
+#define SITA_HDR_LEN 5 /* length of the header */
+
+/*
* The fake link-layer header of LAPD packets.
*/
#ifndef ETH_P_LAPD
@@ -127,6 +137,10 @@ static gboolean libpcap_get_mtp2_pseudoheader(const guint8 *mtp2_hdr,
union wtap_pseudo_header *pseudo_header);
static gboolean libpcap_read_mtp2_pseudoheader(FILE_T fh,
union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
+static gboolean libpcap_get_sita_pseudoheader(const guint8 *sita_phdr,
+ union wtap_pseudo_header *pseudo_header);
+static gboolean libpcap_read_sita_pseudoheader(FILE_T fh,
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
static gboolean libpcap_get_lapd_pseudoheader(const guint8 *lapd_phdr,
union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
static gboolean libpcap_read_lapd_pseudoheader(FILE_T fh,
@@ -429,6 +443,8 @@ static const struct {
{ 189, WTAP_ENCAP_USB_LINUX },
/* Per-Packet Information header */
{ 192, WTAP_ENCAP_PPI },
+ /* SITA File Encapsulation */
+ { 196, WTAP_ENCAP_SITA },
/* Endace Record File Encapsulation */
{ 197, WTAP_ENCAP_ERF },
/* Bluetooth HCI UART transport (part H:4) frames, like hcidump */
@@ -1371,6 +1387,29 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
wth->data_offset += LAPD_SLL_LEN;
break;
+ case WTAP_ENCAP_SITA:
+ if (packet_size < SITA_HDR_LEN) {
+ /*
+ * Uh-oh, the packet isn't big enough to even
+ * have a pseudo-header.
+ */
+ *err = WTAP_ERR_BAD_RECORD;
+ *err_info = g_strdup_printf("libpcap: SITA file has a %u-byte packet, too small to have even a SITA pseudo-header\n",
+ packet_size);
+ return FALSE;
+ }
+ if (!libpcap_read_sita_pseudoheader(wth->fh, &wth->pseudo_header,
+ err, err_info))
+ return FALSE; /* Read error */
+
+ /*
+ * Don't count the pseudo-header as part of the packet.
+ */
+ orig_size -= SITA_HDR_LEN;
+ packet_size -= SITA_HDR_LEN;
+ wth->data_offset += SITA_HDR_LEN;
+ break;
+
case WTAP_ENCAP_USB_LINUX:
if (packet_size < sizeof (struct linux_usb_phdr)) {
/*
@@ -1576,6 +1615,14 @@ libpcap_seek_read(wtap *wth, gint64 seek_off,
}
break;
+ case WTAP_ENCAP_SITA:
+ if (!libpcap_read_sita_pseudoheader(wth->random_fh, pseudo_header,
+ err, err_info)) {
+ /* Read error */
+ return FALSE;
+ }
+ break;
+
case WTAP_ENCAP_USB_LINUX:
if (!libpcap_read_linux_usb_pseudoheader(wth, wth->random_fh,
pseudo_header, err))
@@ -1986,6 +2033,36 @@ libpcap_read_lapd_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_heade
err_info);
}
+static gboolean
+libpcap_get_sita_pseudoheader(const guint8 *sita_phdr,
+ union wtap_pseudo_header *pseudo_header)
+{
+ pseudo_header->sita.flags = sita_phdr[SITA_FLAGS_OFFSET];
+ pseudo_header->sita.signals = sita_phdr[SITA_SIGNALS_OFFSET];
+ pseudo_header->sita.errors1 = sita_phdr[SITA_ERRORS1_OFFSET];
+ pseudo_header->sita.errors2 = sita_phdr[SITA_ERRORS2_OFFSET];
+ pseudo_header->sita.proto = sita_phdr[SITA_PROTO_OFFSET];
+ return TRUE;
+}
+
+static gboolean
+libpcap_read_sita_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info _U_)
+{
+ guint8 sita_phdr[SITA_HDR_LEN];
+ int bytes_read;
+
+ errno = WTAP_ERR_CANT_READ;
+ bytes_read = file_read(sita_phdr, 1, SITA_HDR_LEN, fh);
+ if (bytes_read != SITA_HDR_LEN) {
+ *err = file_error(fh);
+ if (*err == 0)
+ *err = WTAP_ERR_SHORT_READ;
+ return FALSE;
+ }
+
+ return libpcap_get_sita_pseudoheader(sita_phdr, pseudo_header);
+}
+
static void
libpcap_swap_linux_usb_pseudoheader(struct linux_usb_phdr *phdr)
{
@@ -2364,6 +2441,7 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
guint8 irda_hdr[IRDA_SLL_LEN];
guint8 lapd_hdr[LAPD_SLL_LEN];
guint8 mtp2_hdr[MTP2_HDR_LEN];
+ guint8 sita_hdr[SITA_HDR_LEN];
guint8 erf_hdr[ sizeof(struct erf_mc_phdr)];
int hdrsize, size;
@@ -2385,6 +2463,10 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
hdrsize = LAPD_SLL_LEN;
break;
+ case WTAP_ENCAP_SITA:
+ hdrsize = SITA_HDR_LEN;
+ break;
+
case WTAP_ENCAP_USB_LINUX:
hdrsize = sizeof (struct linux_usb_phdr);
break;
@@ -2602,6 +2684,27 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
wdh->bytes_dumped += sizeof(lapd_hdr);
break;
+ case WTAP_ENCAP_SITA:
+ /*
+ * Write the SITA header.
+ */
+ memset(&sita_hdr, 0, sizeof(sita_hdr));
+ sita_hdr[SITA_FLAGS_OFFSET] = pseudo_header->sita.flags;
+ sita_hdr[SITA_SIGNALS_OFFSET] = pseudo_header->sita.signals;
+ sita_hdr[SITA_ERRORS1_OFFSET] = pseudo_header->sita.errors1;
+ sita_hdr[SITA_ERRORS2_OFFSET] = pseudo_header->sita.errors2;
+ sita_hdr[SITA_PROTO_OFFSET] = pseudo_header->sita.proto;
+ nwritten = fwrite(&sita_hdr, 1, sizeof(sita_hdr), wdh->fh);
+ if (nwritten != sizeof(sita_hdr)) {
+ if (nwritten == 0 && ferror(wdh->fh))
+ *err = errno;
+ else
+ *err = WTAP_ERR_SHORT_WRITE;
+ return FALSE;
+ }
+ wdh->bytes_dumped += sizeof(sita_hdr);
+ break;
+
case WTAP_ENCAP_USB_LINUX:
/*
* Write out the pseudo-header; it has the same format
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 759fbed3da..2ddb55bbfc 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -389,6 +389,9 @@ static struct encap_type_info encap_table_base[] = {
/* WTAP_ENCAP_BT_H4 */
{ "Bluetooth H4 with linux header", "bluetooth-h4" },
+
+ /* WTAP_ENCAP_SITA */
+ { "SITA WAN packets", "sita-wan" },
};
gint wtap_num_encap_types = sizeof(encap_table_base) / sizeof(struct encap_type_info);
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 030aa08456..2c0df52b26 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -194,6 +194,7 @@ extern "C" {
#define WTAP_ENCAP_PPI 97
#define WTAP_ENCAP_ERF 98
#define WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR 99
+#define WTAP_ENCAP_SITA 100
#define WTAP_NUM_ENCAP_TYPES wtap_get_num_encap_types()
@@ -644,6 +645,70 @@ struct erf_mc_phdr {
} subhdr;
};
+#define SITA_FRAME_DIR_TXED (0x00) /* values of sita_phdr.flags */
+#define SITA_FRAME_DIR_RXED (0x01)
+#define SITA_FRAME_DIR (0x01) /* mask */
+#define SITA_ERROR_NO_BUFFER (0x80)
+
+#define SITA_SIG_DSR (0x01) /* values of sita_phdr.signals */
+#define SITA_SIG_DTR (0x02)
+#define SITA_SIG_CTS (0x04)
+#define SITA_SIG_RTS (0x08)
+#define SITA_SIG_DCD (0x10)
+#define SITA_SIG_UNDEF1 (0x20)
+#define SITA_SIG_UNDEF2 (0x40)
+#define SITA_SIG_UNDEF3 (0x80)
+
+#define SITA_ERROR_TX_UNDERRUN (0x01) /* values of sita_phdr.errors2 (if SITA_FRAME_DIR_TXED) */
+#define SITA_ERROR_TX_CTS_LOST (0x02)
+#define SITA_ERROR_TX_UART_ERROR (0x04)
+#define SITA_ERROR_TX_RETX_LIMIT (0x08)
+#define SITA_ERROR_TX_UNDEF1 (0x10)
+#define SITA_ERROR_TX_UNDEF2 (0x20)
+#define SITA_ERROR_TX_UNDEF3 (0x40)
+#define SITA_ERROR_TX_UNDEF4 (0x80)
+
+#define SITA_ERROR_RX_FRAMING (0x01) /* values of sita_phdr.errors1 (if SITA_FRAME_DIR_RXED) */
+#define SITA_ERROR_RX_PARITY (0x02)
+#define SITA_ERROR_RX_COLLISION (0x04)
+#define SITA_ERROR_RX_FRAME_LONG (0x08)
+#define SITA_ERROR_RX_FRAME_SHORT (0x10)
+#define SITA_ERROR_RX_UNDEF1 (0x20)
+#define SITA_ERROR_RX_UNDEF2 (0x40)
+#define SITA_ERROR_RX_UNDEF3 (0x80)
+
+#define SITA_ERROR_RX_NONOCTET_ALIGNED (0x01) /* values of sita_phdr.errors2 (if SITA_FRAME_DIR_RXED) */
+#define SITA_ERROR_RX_ABORT (0x02)
+#define SITA_ERROR_RX_CD_LOST (0x04)
+#define SITA_ERROR_RX_DPLL (0x08)
+#define SITA_ERROR_RX_OVERRUN (0x10)
+#define SITA_ERROR_RX_FRAME_LEN_VIOL (0x20)
+#define SITA_ERROR_RX_CRC (0x40)
+#define SITA_ERROR_RX_BREAK (0x80)
+
+#define SITA_PROTO_UNUSED (0x00) /* values of sita_phdr.proto */
+#define SITA_PROTO_BOP_LAPB (0x01)
+#define SITA_PROTO_ETHERNET (0x02)
+#define SITA_PROTO_ASYNC_INTIO (0x03)
+#define SITA_PROTO_ASYNC_BLKIO (0x04)
+#define SITA_PROTO_ALC (0x05)
+#define SITA_PROTO_UTS (0x06)
+#define SITA_PROTO_PPP_HDLC (0x07)
+#define SITA_PROTO_SDLC (0x08)
+#define SITA_PROTO_TOKENRING (0x09)
+#define SITA_PROTO_I2C (0x10)
+#define SITA_PROTO_DPM_LINK (0x11)
+#define SITA_PROTO_BOP_FRL (0x12)
+
+struct sita_phdr {
+ guint8 flags;
+ guint8 signals;
+ guint8 errors1;
+ guint8 errors2;
+ guint8 proto;
+};
+
+
union wtap_pseudo_header {
struct eth_phdr eth;
struct x25_phdr x25;
@@ -661,6 +726,7 @@ union wtap_pseudo_header {
struct catapult_dct2000_phdr dct2000;
struct linux_usb_phdr linux_usb;
struct erf_mc_phdr erf;
+ struct sita_phdr sita;
};
struct wtap_nstime {