/* packet-arp.c
* Routines for ARP packet disassembly
*
- * $Id: packet-arp.c,v 1.51 2002/03/10 00:05:20 guy Exp $
+ * $Id: packet-arp.c,v 1.58 2004/02/28 22:56:35 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* 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.
# include "config.h"
#endif
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
#include <string.h>
#include <glib.h>
#include <epan/packet.h>
#include <epan/resolv.h>
#include "packet-arp.h"
#include "etypes.h"
+#include "arcnet_pids.h"
static int proto_arp = -1;
static int hf_arp_hard_type = -1;
/* Definitions taken from Linux "linux/if_arp.h" header file, and from
- http://www.isi.edu/in-notes/iana/assignments/arp-parameters
+ http://www.iana.org/assignments/arp-parameters
*/
tot_len = MIN_ATMARP_HEADER_SIZE + ar_shl + ar_ssl + ar_spln +
ar_thl + ar_tsl + ar_tpln;
-
+
/* Adjust the length of this tvbuff to include only the ARP datagram.
Our caller may use that to determine how much of its packet
was padding. */
if (tree) {
if ((op_str = match_strval(ar_op, atmop_vals)))
ti = proto_tree_add_protocol_format(tree, proto_arp, tvb, 0, tot_len,
- "ATM Address Resolution Protocol (%s)",
+ "ATM Address Resolution Protocol (%s)",
op_str);
else
ti = proto_tree_add_protocol_format(tree, proto_arp, tvb, 0, tot_len,
}
static const guint8 mac_broadcast[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+static const guint8 mac_allzero[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static void
dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
ar_op = tvb_get_ntohs(tvb, AR_OP);
tot_len = MIN_ARP_HEADER_SIZE + ar_hln*2 + ar_pln*2;
-
+
/* Adjust the length of this tvbuff to include only the ARP datagram.
Our caller may use that to determine how much of its packet
was padding. */
spa_offset = sha_offset + ar_hln;
tha_offset = spa_offset + ar_pln;
tpa_offset = tha_offset + ar_hln;
-
+
if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
switch (ar_op) {
/* inform resolv.c module of the new discovered addresses */
- u_int ip;
+ guint ip;
const guint8 *mac;
- /* add sender address in all cases */
-
+ /* Add sender address if sender MAC address is neither a broadcast/
+ multicast address nor an all-zero address and if sender IP address
+ isn't all zeroes. */
tvb_memcpy(tvb, (guint8 *)&ip, spa_offset, sizeof(ip));
- add_ether_byip(ip, tvb_get_ptr(tvb, sha_offset, 6));
-
- if (ar_op == ARPOP_REQUEST) {
- /* Add target address *if* the target MAC address isn't a
- broadcast address. */
- tvb_memcpy(tvb, (guint8 *)&ip, tpa_offset, sizeof(ip));
- mac = tvb_get_ptr(tvb, tha_offset, 6);
- if (memcmp(mac, mac_broadcast, 6) != 0)
- add_ether_byip(ip, mac);
- }
+ mac = tvb_get_ptr(tvb, sha_offset, 6);
+ if ((mac[0] & 0x01) == 0 && memcmp(mac, mac_allzero, 6) != 0 && ip != 0)
+ add_ether_byip(ip, mac);
+
+ /* Add target address if target MAC address is neither a broadcast/
+ multicast address nor an all-zero address and if target IP address
+ isn't all zeroes. */
+ tvb_memcpy(tvb, (guint8 *)&ip, tpa_offset, sizeof(ip));
+ mac = tvb_get_ptr(tvb, tha_offset, 6);
+ if ((mac[0] & 0x01) == 0 && memcmp(mac, mac_allzero, 6) != 0 && ip != 0)
+ add_ether_byip(ip, mac);
}
if (tree) {
static hf_register_info hf[] = {
{ &hf_arp_hard_type,
- { "Hardware type", "arp.hw.type",
+ { "Hardware type", "arp.hw.type",
FT_UINT16, BASE_HEX, VALS(hrd_vals), 0x0,
"", HFILL }},
proto_register_subtree_array(ett, array_length(ett));
atmarp_handle = create_dissector_handle(dissect_atmarp, proto_arp);
+
+ register_dissector( "arp" , dissect_arp, proto_arp );
}
void
{
dissector_handle_t arp_handle;
- arp_handle = create_dissector_handle(dissect_arp, proto_arp);
+ arp_handle = find_dissector("arp");
+
dissector_add("ethertype", ETHERTYPE_ARP, arp_handle);
dissector_add("ethertype", ETHERTYPE_REVARP, arp_handle);
+ dissector_add("arcnet.protocol_id", ARCNET_PROTO_ARP_1051, arp_handle);
+ dissector_add("arcnet.protocol_id", ARCNET_PROTO_ARP_1201, arp_handle);
+ dissector_add("arcnet.protocol_id", ARCNET_PROTO_RARP_1201, arp_handle);
+
}