aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2003-01-31 01:02:14 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2003-01-31 01:02:14 +0000
commitf01ce99614a950a3e71a6a5735823890e614f9bc (patch)
tree4fc64f4ea929901c9f1cc62467bfce72435baa2b
parentc09d718c7733a0174c2d01f0af54f18400c5b9d3 (diff)
Add WTAP_ENCAP_FRELAY_WITH_PHDR for use with Frame Relay capture files
that have direction information. Support writing WTAP_ENCAP_FRELAY_WITH_PHDR and WTAP_ENCAP_PPP_WITH_PHDR captures out in libpcap format - we throw away the direction information, but so it goes. When reading/writing Windows Sniffer format, read and write the direction flag. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7052 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--packet-fr.c3
-rw-r--r--packet-frame.c4
-rw-r--r--wiretap/libpcap.c35
-rw-r--r--wiretap/netxray.c35
-rw-r--r--wiretap/ngsniffer.c10
-rw-r--r--wiretap/visual.c61
-rw-r--r--wiretap/wtap.c5
-rw-r--r--wiretap/wtap.h29
8 files changed, 120 insertions, 62 deletions
diff --git a/packet-fr.c b/packet-fr.c
index e7fd939b1d..1948e66e2a 100644
--- a/packet-fr.c
+++ b/packet-fr.c
@@ -3,7 +3,7 @@
*
* Copyright 2001, Paul Ionescu <paul@acorp.ro>
*
- * $Id: packet-fr.c,v 1.32 2002/10/22 08:22:02 guy Exp $
+ * $Id: packet-fr.c,v 1.33 2003/01/31 01:02:03 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -429,6 +429,7 @@ void proto_reg_handoff_fr(void)
fr_handle = create_dissector_handle(dissect_fr, proto_fr);
dissector_add("wtap_encap", WTAP_ENCAP_FRELAY, fr_handle);
+ dissector_add("wtap_encap", WTAP_ENCAP_FRELAY_WITH_PHDR, fr_handle);
dissector_add("gre.proto", GRE_FR, fr_handle);
data_handle = find_dissector("data");
}
diff --git a/packet-frame.c b/packet-frame.c
index f44fa308c8..9ff60ba1dd 100644
--- a/packet-frame.c
+++ b/packet-frame.c
@@ -2,7 +2,7 @@
*
* Top-most dissector. Decides dissector based on Wiretap Encapsulation Type.
*
- * $Id: packet-frame.c,v 1.33 2002/12/20 07:56:07 sharpe Exp $
+ * $Id: packet-frame.c,v 1.34 2003/01/31 01:02:03 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -90,7 +90,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
break;
case WTAP_ENCAP_LAPB:
- case WTAP_ENCAP_FRELAY:
+ case WTAP_ENCAP_FRELAY_WITH_PHDR:
pinfo->p2p_dir =
(pinfo->pseudo_header->x25.flags & FROM_DCE) ?
P2P_DIR_RECV : P2P_DIR_SENT;
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index 7e74bbec42..b7d633817a 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -1,6 +1,6 @@
/* libpcap.c
*
- * $Id: libpcap.c,v 1.91 2003/01/23 04:04:00 guy Exp $
+ * $Id: libpcap.c,v 1.92 2003/01/31 01:02:07 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -1217,15 +1217,32 @@ static int wtap_wtap_encap_to_pcap_encap(int encap)
{
unsigned int i;
- /*
- * Special-case WTAP_ENCAP_FDDI and WTAP_ENCAP_FDDI_BITSWAPPED;
- * both of them get mapped to DLT_FDDI (even though that may
- * mean that the bit order in the FDDI MAC addresses is wrong;
- * so it goes - libpcap format doesn't record the byte order,
- * so that's not fixable).
- */
- if (encap == WTAP_ENCAP_FDDI || encap == WTAP_ENCAP_FDDI_BITSWAPPED)
+ switch (encap) {
+
+ case WTAP_ENCAP_FDDI:
+ case WTAP_ENCAP_FDDI_BITSWAPPED:
+ /*
+ * Special-case WTAP_ENCAP_FDDI and
+ * WTAP_ENCAP_FDDI_BITSWAPPED; both of them get mapped
+ * to DLT_FDDI (even though that may mean that the bit
+ * order in the FDDI MAC addresses is wrong; so it goes
+ * - libpcap format doesn't record the byte order,
+ * so that's not fixable).
+ */
return 10; /* that's DLT_FDDI */
+
+ case WTAP_ENCAP_PPP_WITH_PHDR:
+ /*
+ * Also special-case PPP and Frame Relay with direction
+ * bits; map them to PPP and Frame Relay, even though
+ * that means that the direction of the packet is lost.
+ */
+ return 9;
+
+ case WTAP_ENCAP_FRELAY_WITH_PHDR:
+ return 107;
+ }
+
for (i = 0; i < NUM_PCAP_ENCAPS; i++) {
if (pcap_to_wtap_map[i].wtap_encap_value == encap)
return pcap_to_wtap_map[i].dlt_value;
diff --git a/wiretap/netxray.c b/wiretap/netxray.c
index f6a3cd98d5..19648eb2a1 100644
--- a/wiretap/netxray.c
+++ b/wiretap/netxray.c
@@ -1,6 +1,6 @@
/* netxray.c
*
- * $Id: netxray.c,v 1.75 2003/01/30 22:38:47 guy Exp $
+ * $Id: netxray.c,v 1.76 2003/01/31 01:02:08 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -280,7 +280,7 @@ int netxray_open(wtap *wth, int *err)
/*
* Frame Relay.
*/
- file_encap = WTAP_ENCAP_FRELAY;
+ file_encap = WTAP_ENCAP_FRELAY_WITH_PHDR;
break;
case 6:
@@ -633,8 +633,9 @@ netxray_set_pseudo_header(wtap *wth, const guint8 *pd, int len,
break;
case WTAP_ENCAP_LAPB:
+ case WTAP_ENCAP_FRELAY_WITH_PHDR:
/*
- * LAPB/X.25.
+ * LAPB/X.25 and Frame Relay.
*
* The bottommost bit of byte 12 of "hdr.hdr_2_x.xxx"
* is the direction flag. (Probably true for other
@@ -944,11 +945,11 @@ static const struct {
int wtap_encap_value;
int ndis_value;
} wtap_encap_2_0[] = {
- { WTAP_ENCAP_ETHERNET, 0 }, /* -> NDIS Ethernet */
- { WTAP_ENCAP_TOKEN_RING, 1 }, /* -> NDIS Token Ring */
- { WTAP_ENCAP_FDDI, 2 }, /* -> NDIS FDDI */
- { WTAP_ENCAP_FDDI_BITSWAPPED, 2 }, /* -> NDIS FDDI */
- { WTAP_ENCAP_FRELAY, 3 }, /* -> NDIS WAN(PPP) */
+ { WTAP_ENCAP_ETHERNET, 0 }, /* -> NDIS Ethernet */
+ { WTAP_ENCAP_TOKEN_RING, 1 }, /* -> NDIS Token Ring */
+ { WTAP_ENCAP_FDDI, 2 }, /* -> NDIS FDDI */
+ { WTAP_ENCAP_FDDI_BITSWAPPED, 2 }, /* -> NDIS FDDI */
+ { WTAP_ENCAP_FRELAY_WITH_PHDR, 3 }, /* -> NDIS WAN(PPP) */
};
#define NUM_WTAP_ENCAPS_2_0 (sizeof wtap_encap_2_0 / sizeof wtap_encap_2_0[0])
@@ -1048,11 +1049,17 @@ static gboolean netxray_dump_2_0(wtap_dumper *wdh,
rec_hdr.orig_len = htoles(phdr->len);
rec_hdr.incl_len = htoles(phdr->caplen);
- if (phdr->pkt_encap == WTAP_ENCAP_IEEE_802_11_WITH_RADIO)
- {
- rec_hdr.xxx[12] = pseudo_header->ieee_802_11.channel;
- rec_hdr.xxx[13] = pseudo_header->ieee_802_11.data_rate;
- rec_hdr.xxx[14] = pseudo_header->ieee_802_11.signal_level;
+ switch (phdr->pkt_encap) {
+
+ case WTAP_ENCAP_IEEE_802_11_WITH_RADIO:
+ rec_hdr.xxx[12] = pseudo_header->ieee_802_11.channel;
+ rec_hdr.xxx[13] = pseudo_header->ieee_802_11.data_rate;
+ rec_hdr.xxx[14] = pseudo_header->ieee_802_11.signal_level;
+ break;
+
+ case WTAP_ENCAP_FRELAY_WITH_PHDR:
+ rec_hdr.xxx[12] |= (pseudo_header->x25.flags & FROM_DCE) ? 0x00 : 0x01;
+ break;
}
nwritten = fwrite(&rec_hdr, 1, sizeof(rec_hdr), wdh->fh);
@@ -1118,7 +1125,7 @@ static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err)
file_hdr.timehi = htolel(0);
switch (wdh->encap) {
- case WTAP_ENCAP_FRELAY:
+ case WTAP_ENCAP_FRELAY_WITH_PHDR:
file_hdr.xxb[20] = 4;
break;
}
diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c
index 40bd388e5d..33e336912d 100644
--- a/wiretap/ngsniffer.c
+++ b/wiretap/ngsniffer.c
@@ -1,6 +1,6 @@
/* ngsniffer.c
*
- * $Id: ngsniffer.c,v 1.108 2003/01/14 19:52:47 guy Exp $
+ * $Id: ngsniffer.c,v 1.109 2003/01/31 01:02:09 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -546,7 +546,7 @@ int ngsniffer_open(wtap *wth, int *err)
* one we've seen is a Frame Relay capture,
* so mark it as Frame Relay for now.
*/
- wth->file_encap = WTAP_ENCAP_FRELAY;
+ wth->file_encap = WTAP_ENCAP_FRELAY_WITH_PHDR;
break;
}
}
@@ -830,7 +830,7 @@ process_rec_header2_v145(wtap *wth, unsigned char *buffer, guint16 length,
break;
case NET_FRAME_RELAY:
- wth->file_encap = WTAP_ENCAP_FRELAY;
+ wth->file_encap = WTAP_ENCAP_FRELAY_WITH_PHDR;
break;
case NET_ROUTER:
@@ -1255,7 +1255,7 @@ static void set_pseudo_header_frame2(wtap *wth,
break;
case WTAP_ENCAP_LAPB:
- case WTAP_ENCAP_FRELAY:
+ case WTAP_ENCAP_FRELAY_WITH_PHDR:
case WTAP_ENCAP_PER_PACKET:
pseudo_header->x25.flags = (frame2->fs & 0x80) ? 0x00 : FROM_DCE;
break;
@@ -1632,7 +1632,7 @@ static int infer_pkt_encap(const guint8 *pd, int len)
* file, where we might just not yet have found where
* the subtype is specified in the capture?
*/
- return WTAP_ENCAP_FRELAY;
+ return WTAP_ENCAP_FRELAY_WITH_PHDR;
}
if (len >= 2) {
diff --git a/wiretap/visual.c b/wiretap/visual.c
index 8807cac5d8..18af191d0d 100644
--- a/wiretap/visual.c
+++ b/wiretap/visual.c
@@ -2,7 +2,7 @@
* File read and write routines for Visual Networks cap files.
* Copyright (c) 2001, Tom Nisbet tnisbet@visualnetworks.com
*
- * $Id: visual.c,v 1.11 2002/08/28 20:30:45 jmayer Exp $
+ * $Id: visual.c,v 1.12 2003/01/31 01:02:11 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -172,11 +172,26 @@ int visual_open(wtap *wth, int *err)
get sorted out after the first packet is read. */
switch (pletohs(&vfile_hdr.media_type))
{
- case 6: encap = WTAP_ENCAP_ETHERNET; break;
- case 9: encap = WTAP_ENCAP_TOKEN_RING; break;
- case 16: encap = WTAP_ENCAP_LAPB; break;
- case 22: encap = WTAP_ENCAP_CHDLC; break;
- case 32: encap = WTAP_ENCAP_FRELAY; break;
+ case 6:
+ encap = WTAP_ENCAP_ETHERNET;
+ break;
+
+ case 9:
+ encap = WTAP_ENCAP_TOKEN_RING;
+ break;
+
+ case 16:
+ encap = WTAP_ENCAP_LAPB;
+ break;
+
+ case 22:
+ encap = WTAP_ENCAP_CHDLC;
+ break;
+
+ case 32:
+ encap = WTAP_ENCAP_FRELAY_WITH_PHDR;
+ break;
+
default:
g_message("visual: network type %u unknown or unsupported",
vfile_hdr.media_type);
@@ -297,7 +312,7 @@ static gboolean visual_read(wtap *wth, int *err, long *data_offset)
wth->pseudo_header.p2p.sent = (packet_status & PS_SENT) ? TRUE : FALSE;
break;
- case WTAP_ENCAP_FRELAY:
+ case WTAP_ENCAP_FRELAY_WITH_PHDR:
case WTAP_ENCAP_LAPB:
wth->pseudo_header.x25.flags =
(packet_status & PS_SENT) ? 0x00 : FROM_DCE;
@@ -373,7 +388,7 @@ static gboolean visual_seek_read (wtap *wth, long seek_off,
pseudo_header->p2p.sent = (packet_status & PS_SENT) ? TRUE : FALSE;
break;
- case WTAP_ENCAP_FRELAY:
+ case WTAP_ENCAP_FRELAY_WITH_PHDR:
case WTAP_ENCAP_LAPB:
pseudo_header->x25.flags = (packet_status & PS_SENT) ? 0x00 : FROM_DCE;
break;
@@ -399,7 +414,7 @@ int visual_dump_can_write_encap(int encap)
case WTAP_ENCAP_TOKEN_RING:
case WTAP_ENCAP_LAPB:
case WTAP_ENCAP_CHDLC:
- case WTAP_ENCAP_FRELAY:
+ case WTAP_ENCAP_FRELAY_WITH_PHDR:
case WTAP_ENCAP_PPP:
case WTAP_ENCAP_PPP_WITH_PHDR:
return 0;
@@ -507,7 +522,7 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
case WTAP_ENCAP_CHDLC: /* HDLC Router */
vpkt_hdr.encap_hint = 13;
break;
- case WTAP_ENCAP_FRELAY: /* Frame Relay Auto-detect */
+ case WTAP_ENCAP_FRELAY_WITH_PHDR: /* Frame Relay Auto-detect */
vpkt_hdr.encap_hint = 12;
break;
case WTAP_ENCAP_LAPB: /* Unknown */
@@ -527,7 +542,7 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
packet_status |= (pseudo_header->p2p.sent ? PS_SENT : 0x00);
break;
- case WTAP_ENCAP_FRELAY:
+ case WTAP_ENCAP_FRELAY_WITH_PHDR:
case WTAP_ENCAP_LAPB:
packet_status |=
((pseudo_header->x25.flags & FROM_DCE) ? 0x00 : PS_SENT);
@@ -641,13 +656,27 @@ static gboolean visual_dump_close(wtap_dumper *wdh, int *err)
/* Translate the encapsulation type */
switch (wdh->encap)
{
- case WTAP_ENCAP_ETHERNET: vfile_hdr.media_type = htoles(6); break;
- case WTAP_ENCAP_TOKEN_RING: vfile_hdr.media_type = htoles(9); break;
- case WTAP_ENCAP_LAPB: vfile_hdr.media_type = htoles(16); break;
+ case WTAP_ENCAP_ETHERNET:
+ vfile_hdr.media_type = htoles(6);
+ break;
+
+ case WTAP_ENCAP_TOKEN_RING:
+ vfile_hdr.media_type = htoles(9);
+ break;
+
+ case WTAP_ENCAP_LAPB:
+ vfile_hdr.media_type = htoles(16);
+ break;
+
case WTAP_ENCAP_PPP: /* PPP is differentiated from CHDLC in PktHdr */
case WTAP_ENCAP_PPP_WITH_PHDR:
- case WTAP_ENCAP_CHDLC: vfile_hdr.media_type = htoles(22); break;
- case WTAP_ENCAP_FRELAY: vfile_hdr.media_type = htoles(32); break;
+ case WTAP_ENCAP_CHDLC:
+ vfile_hdr.media_type = htoles(22);
+ break;
+
+ case WTAP_ENCAP_FRELAY_WITH_PHDR:
+ vfile_hdr.media_type = htoles(32);
+ break;
}
/* Write the file header following the magic bytes. */
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index b7cb34f826..eb152beec8 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -1,6 +1,6 @@
/* wtap.c
*
- * $Id: wtap.c,v 1.79 2003/01/23 04:04:01 guy Exp $
+ * $Id: wtap.c,v 1.80 2003/01/31 01:02:12 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -131,6 +131,9 @@ static const struct encap_type_info {
/* WTAP_ENCAP_FRELAY */
{ "Frame Relay", "frelay" },
+ /* WTAP_ENCAP_FRELAY_WITH_PHDR */
+ { "Frame Relay with Directional Info", "frelay-with-direction" },
+
/* WTAP_ENCAP_CHDLC */
{ "Cisco HDLC", "chdlc" },
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 2a514ad4b7..0c3b1c1075 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1,6 +1,6 @@
/* wtap.h
*
- * $Id: wtap.h,v 1.133 2003/01/23 04:04:01 guy Exp $
+ * $Id: wtap.h,v 1.134 2003/01/31 01:02:14 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -113,21 +113,22 @@
#define WTAP_ENCAP_IEEE_802_11_WITH_RADIO 21
#define WTAP_ENCAP_SLL 22
#define WTAP_ENCAP_FRELAY 23
-#define WTAP_ENCAP_CHDLC 24
-#define WTAP_ENCAP_CISCO_IOS 25
-#define WTAP_ENCAP_LOCALTALK 26
-#define WTAP_ENCAP_PRISM_HEADER 27
-#define WTAP_ENCAP_PFLOG 28
-#define WTAP_ENCAP_HHDLC 29
-#define WTAP_ENCAP_DOCSIS 30
-#define WTAP_ENCAP_COSINE 31
-#define WTAP_ENCAP_WLAN_HEADER 32
-#define WTAP_ENCAP_WFLEET_HDLC 33
-#define WTAP_ENCAP_SDLC 34
-#define WTAP_ENCAP_TZSP 35
+#define WTAP_ENCAP_FRELAY_WITH_PHDR 24
+#define WTAP_ENCAP_CHDLC 25
+#define WTAP_ENCAP_CISCO_IOS 26
+#define WTAP_ENCAP_LOCALTALK 27
+#define WTAP_ENCAP_PRISM_HEADER 28
+#define WTAP_ENCAP_PFLOG 29
+#define WTAP_ENCAP_HHDLC 30
+#define WTAP_ENCAP_DOCSIS 31
+#define WTAP_ENCAP_COSINE 32
+#define WTAP_ENCAP_WLAN_HEADER 33
+#define WTAP_ENCAP_WFLEET_HDLC 34
+#define WTAP_ENCAP_SDLC 35
+#define WTAP_ENCAP_TZSP 36
/* last WTAP_ENCAP_ value + 1 */
-#define WTAP_NUM_ENCAP_TYPES 36
+#define WTAP_NUM_ENCAP_TYPES 37
/* File types that can be read by wiretap.
We support writing some many of these file types, too, so we