From 0b06407eae0095eb7cdb40ce774bb66f5b820ab5 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 23 Mar 2004 01:02:41 +0000 Subject: [PATCH] Add support for DLT_APPLE_IP_OVER_IEEE_1394. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@10446 f5534014-38df-0310-8fa8-9805f1628bb7 --- Makefile.common | 3 +- capture.c | 5 +- epan/Makefile.common | 3 +- epan/packet_info.h | 9 ++-- epan/to_str.c | 7 ++- packet-ap1394.c | 125 +++++++++++++++++++++++++++++++++++++++++++ packet-ap1394.h | 29 ++++++++++ wiretap/libpcap.c | 9 ++-- wiretap/wtap.c | 5 +- wiretap/wtap.h | 5 +- 10 files changed, 186 insertions(+), 14 deletions(-) create mode 100644 packet-ap1394.c create mode 100644 packet-ap1394.h diff --git a/Makefile.common b/Makefile.common index ecd9a0396d..0d5cd3ebf7 100644 --- a/Makefile.common +++ b/Makefile.common @@ -3,7 +3,7 @@ # a) common to both files and # b) portable between both files # -# $Id: Makefile.common,v 1.30 2004/03/19 07:54:57 guy Exp $ +# $Id: Makefile.common,v 1.31 2004/03/23 01:02:40 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs @@ -34,6 +34,7 @@ DISSECTOR_INCLUDES = \ packet-afs.h \ packet-ansi_a.h \ packet-ansi_map.h \ + packet-ap1394.h \ packet-arcnet.h \ packet-arp.h \ packet-atalk.h \ diff --git a/capture.c b/capture.c index be3a16c17a..c18879b7c2 100644 --- a/capture.c +++ b/capture.c @@ -1,7 +1,7 @@ /* capture.c * Routines for packet capture windows * - * $Id: capture.c,v 1.246 2004/03/13 22:49:30 ulfl Exp $ + * $Id: capture.c,v 1.247 2004/03/23 01:02:40 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -2321,6 +2321,9 @@ capture_pcap_cb(guchar *user, const struct pcap_pkthdr *phdr, case WTAP_ENCAP_ARCNET_LINUX: capture_arcnet(pd, whdr.caplen, &ld->counts, TRUE, FALSE); break; + case WTAP_ENCAP_APPLE_IP_OVER_IEEE1394: + capture_ap1394(pd, 0, whdr.caplen, &ld->counts); + break; /* XXX - some ATM drivers on FreeBSD might prepend a 4-byte ATM pseudo-header to DLT_ATM_RFC1483, with LLC header following; we might have to implement that at some point. */ diff --git a/epan/Makefile.common b/epan/Makefile.common index ff94ab44c5..c915244d07 100644 --- a/epan/Makefile.common +++ b/epan/Makefile.common @@ -3,7 +3,7 @@ # a) common to both files and # b) portable between both files # -# $Id: Makefile.common,v 1.10 2004/03/21 17:13:01 nneul Exp $ +# $Id: Makefile.common,v 1.11 2004/03/23 01:02:40 guy Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs @@ -41,6 +41,7 @@ DISSECTOR_SRC = \ ../packet-ansi_a.c \ ../packet-ansi_map.c \ ../packet-aodv.c \ + ../packet-ap1394.c \ ../packet-arcnet.c \ ../packet-arp.c \ ../packet-asap.c \ diff --git a/epan/packet_info.h b/epan/packet_info.h index ee6d6e01ec..41eb393675 100644 --- a/epan/packet_info.h +++ b/epan/packet_info.h @@ -1,7 +1,7 @@ /* packet_info.h * Definitions for packet info structures and routines * - * $Id: packet_info.h,v 1.39 2004/02/29 08:47:11 guy Exp $ + * $Id: packet_info.h,v 1.40 2004/03/23 01:02:40 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -40,9 +40,10 @@ typedef enum { AT_VINES, /* Banyan Vines */ AT_OSI, /* OSI NSAP */ AT_ARCNET, /* ARCNET */ - AT_FC, /* Fibre Channel */ - AT_SS7PC, /* SS7 Point Code */ - AT_STRINGZ /* null-terminated string */ + AT_FC, /* Fibre Channel */ + AT_SS7PC, /* SS7 Point Code */ + AT_STRINGZ, /* null-terminated string */ + AT_EUI64 /* IEEE EUI-64 */ } address_type; typedef struct _address { diff --git a/epan/to_str.c b/epan/to_str.c index 5742eebb91..1d09a6f256 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -1,7 +1,7 @@ /* to_str.c * Routines for utilities to convert various other types to strings. * - * $Id: to_str.c,v 1.42 2003/12/09 05:06:22 guy Exp $ + * $Id: to_str.c,v 1.43 2004/03/23 01:02:40 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -864,6 +864,11 @@ address_to_str_buf(address *addr, gchar *buf) case AT_SS7PC: mtp3_addr_to_str_buf(addr->data, buf); break; + case AT_EUI64: + sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", + addr->data[0], addr->data[1], addr->data[2], addr->data[3], + addr->data[4], addr->data[5], addr->data[6], addr->data[7]); + break; default: g_assert_not_reached(); } diff --git a/packet-ap1394.c b/packet-ap1394.c new file mode 100644 index 0000000000..6f9f00002c --- /dev/null +++ b/packet-ap1394.c @@ -0,0 +1,125 @@ +/* packet-ap1394.c + * Routines for Apple IP-over-IEEE 1394 packet disassembly + * + * $Id: packet-ap1394.c,v 1.1 2004/03/23 01:02:40 guy Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include + +#include "packet-ap1394.h" +#include "etypes.h" + +static int proto_ap1394 = -1; +static int hf_ap1394_dst = -1; +static int hf_ap1394_src = -1; +static int hf_ap1394_type = -1; + +static gint ett_ap1394 = -1; + +void +capture_ap1394(const guchar *pd, int offset, int len, packet_counts *ld) +{ + guint16 etype; + + if (!BYTES_ARE_IN_FRAME(offset, len, 18)) { + ld->other++; + return; + } + + /* Skip destination and source addresses */ + offset += 16; + + etype = pntohs(&pd[offset]); + offset += 2; + capture_ethertype(etype, pd, offset, len, ld); +} + +static void +dissect_ap1394(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + proto_item *ti; + proto_tree *fh_tree = NULL; + const char *src_addr, *dst_addr; + guint16 etype; + + if (check_col(pinfo->cinfo, COL_PROTOCOL)) + col_set_str(pinfo->cinfo, COL_PROTOCOL, "IP/IEEE1394"); + if (check_col(pinfo->cinfo, COL_INFO)) + col_clear(pinfo->cinfo, COL_INFO); + + src_addr=tvb_get_ptr(tvb, 8, 8); + SET_ADDRESS(&pinfo->dl_src, AT_EUI64, 8, src_addr); + SET_ADDRESS(&pinfo->src, AT_EUI64, 8, src_addr); + dst_addr=tvb_get_ptr(tvb, 0, 8); + SET_ADDRESS(&pinfo->dl_dst, AT_EUI64, 8, dst_addr); + SET_ADDRESS(&pinfo->dst, AT_EUI64, 8, dst_addr); + + if (tree) { + ti = proto_tree_add_protocol_format(tree, proto_ap1394, tvb, 0, 18, + "Apple IP-over-IEEE 1394, Src: %s, Dst: %s", + bytes_to_str(src_addr, 8), bytes_to_str(dst_addr, 8)); + fh_tree = proto_item_add_subtree(ti, ett_ap1394); + proto_tree_add_bytes(fh_tree, hf_ap1394_dst, tvb, 0, 8, dst_addr); + proto_tree_add_bytes(fh_tree, hf_ap1394_src, tvb, 8, 8, src_addr); + } + etype = tvb_get_ntohs(tvb, 16); + ethertype(etype, tvb, 18, pinfo, tree, fh_tree, hf_ap1394_type, -1, 0); +} + +void +proto_register_ap1394(void) +{ + static hf_register_info hf[] = { + { &hf_ap1394_dst, + { "Destination", "ap1394.dst", FT_BYTES, BASE_NONE, + NULL, 0x0, "Destination address", HFILL }}, + { &hf_ap1394_src, + { "Source", "ap1394.src", FT_BYTES, BASE_NONE, + NULL, 0x0, "Source address", HFILL }}, + /* registered here but handled in ethertype.c */ + { &hf_ap1394_type, + { "Type", "ap1394.type", FT_UINT16, BASE_HEX, + VALS(etype_vals), 0x0, "", HFILL }}, + }; + static gint *ett[] = { + &ett_ap1394, + }; + + proto_ap1394 = proto_register_protocol("Apple IP-over-IEEE 1394", "IP/IEEE1394", "ap1394"); + proto_register_field_array(proto_ap1394, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); +} + +void +proto_reg_handoff_ap1394(void) +{ + dissector_handle_t ap1394_handle; + + ap1394_handle = create_dissector_handle(dissect_ap1394, proto_ap1394); + dissector_add("wtap_encap", WTAP_ENCAP_APPLE_IP_OVER_IEEE1394, ap1394_handle); +} diff --git a/packet-ap1394.h b/packet-ap1394.h new file mode 100644 index 0000000000..55e6ac3810 --- /dev/null +++ b/packet-ap1394.h @@ -0,0 +1,29 @@ +/* packet-ap1394.h + * + * $Id: packet-ap1394.h,v 1.1 2004/03/23 01:02:40 guy Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * 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. + */ + +#ifndef __PACKET_AP1394_H__ +#define __PACKET_AP1394_H__ + +void capture_ap1394(const guchar *, int, int, packet_counts *); + +#endif diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index 89fa2a69b7..e7cd0c278e 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -1,6 +1,6 @@ /* libpcap.c * - * $Id: libpcap.c,v 1.118 2004/03/19 05:22:41 guy Exp $ + * $Id: libpcap.c,v 1.119 2004/03/23 01:02:41 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -296,10 +296,13 @@ static const struct { /* * Values 130 through 137 are reserved for use in Juniper * hardware. - * - * 138 is reserved for Apple IP-over-IEEE 1394. */ + { 138, WTAP_ENCAP_APPLE_IP_OVER_IEEE1394 }, + /* Apple IP-over-IEEE 1394 */ + + /* 139 is reserved for SS7 */ + { 140, WTAP_ENCAP_MTP2 }, { 141, WTAP_ENCAP_MTP3 }, { 143, WTAP_ENCAP_DOCSIS }, diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 82225d2b60..0496ca4da6 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -1,6 +1,6 @@ /* wtap.c * - * $Id: wtap.c,v 1.91 2004/03/11 09:18:33 guy Exp $ + * $Id: wtap.c,v 1.92 2004/03/23 01:02:41 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -244,6 +244,9 @@ static const struct encap_type_info { /* WTAP_ENCAP_SYMANTEC */ { "Symantec Enterprise Firewall", "symantec" }, + + /* WTAP_ENCAP_APPLE_IP_OVER_IEEE1394 */ + { "Apple IP-over-IEEE 1394", "ap1394" }, }; /* Name that should be somewhat descriptive. */ diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 639b623e88..3398a9c698 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -1,6 +1,6 @@ /* wtap.h * - * $Id: wtap.h,v 1.153 2004/03/11 09:18:33 guy Exp $ + * $Id: wtap.h,v 1.154 2004/03/23 01:02:41 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -151,9 +151,10 @@ #define WTAP_ENCAP_USER14 59 #define WTAP_ENCAP_USER15 60 #define WTAP_ENCAP_SYMANTEC 61 +#define WTAP_ENCAP_APPLE_IP_OVER_IEEE1394 62 /* last WTAP_ENCAP_ value + 1 */ -#define WTAP_NUM_ENCAP_TYPES 62 +#define WTAP_NUM_ENCAP_TYPES 63 /* File types that can be read by wiretap. We support writing some many of these file types, too, so we -- 2.34.1