2 * Routines for Appletalk ARP packet disassembly
4 * $Id: packet-aarp.c,v 1.8 1999/09/23 05:21:28 guy Exp $
6 * Simon Wilkinson <sxw@dcs.ed.ac.uk>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #ifdef HAVE_SYS_TYPES_H
28 # include <sys/types.h>
36 static int proto_aarp = -1;
38 typedef struct _e_ether_aarp {
49 #define AARP_REQUEST 0x0001
52 #define AARP_REPLY 0x0002
55 #define AARP_PROBE 0x0003
59 atalkid_to_str(guint8 *ad) {
61 static gchar str[3][16];
64 if (cur == &str[0][0]) {
66 } else if (cur == &str[1][0]) {
73 sprintf(cur, "%d.%d",node,ad[3]);
78 dissect_aarp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
80 proto_tree *aarp_tree;
83 value_string op_vals[] = { {AARP_REQUEST, "AARP request" },
84 {AARP_REPLY, "AARP reply" },
85 {AARP_PROBE, "AARP probe" },
88 ea.htype = pntohs(&pd[offset]);
89 ea.ptype = pntohs(&pd[offset + 2]);
90 ea.halen = (guint8) pd[offset + 4];
91 ea.palen = (guint8) pd[offset + 5];
92 ea.op = pntohs(&pd[offset + 6]);
93 memcpy(&ea.hsaddr, &pd[offset + 8], 6);
94 memcpy(&ea.psaddr, &pd[offset + 14], 4);
95 memcpy(&ea.hdaddr, &pd[offset + 18], 6);
96 memcpy(&ea.pdaddr, &pd[offset + 24], 4);
98 if(check_col(fd, COL_PROTOCOL))
99 col_add_str(fd, COL_PROTOCOL, "AARP");
102 if ((op_str = match_strval(ea.op, op_vals)))
103 ti = proto_tree_add_item_format(tree, proto_aarp, offset, 28, NULL, op_str);
105 ti = proto_tree_add_item_format(tree, proto_aarp, offset, 28, NULL,
106 "Unknown AARP (opcode 0x%04x)", ea.op);
107 aarp_tree = proto_item_add_subtree(ti, ETT_AARP);
108 proto_tree_add_text(aarp_tree, offset, 2,
109 "Hardware type: 0x%04x", ea.htype);
110 proto_tree_add_text(aarp_tree, offset + 2, 2,
111 "Protocol type: 0x%04x", ea.ptype);
112 proto_tree_add_text(aarp_tree, offset + 4, 1,
113 "Hardware size: 0x%02x", ea.halen);
114 proto_tree_add_text(aarp_tree, offset + 5, 1,
115 "Protocol size: 0x%02x", ea.palen);
116 proto_tree_add_text(aarp_tree, offset + 6, 2,
117 "Opcode: 0x%04x (%s)", ea.op, op_str ? op_str : "Unknown");
118 proto_tree_add_text(aarp_tree, offset + 8, 6,
119 "Sender ether: %s", ether_to_str((guint8 *) ea.hsaddr));
120 proto_tree_add_text(aarp_tree, offset + 14, 4,
121 "Sender ID: %s", atalkid_to_str((guint8 *) ea.psaddr));
122 proto_tree_add_text(aarp_tree, offset + 18, 6,
123 "Target ether: %s", ether_to_str((guint8 *) ea.hdaddr));
124 proto_tree_add_text(aarp_tree, offset + 24, 4,
125 "Target ID: %s", atalkid_to_str((guint8 *) ea.pdaddr));
128 if (ea.ptype != ETHERTYPE_AARP && ea.ptype != ETHERTYPE_ATALK &&
129 check_col(fd, COL_INFO)) {
130 col_add_fstr(fd, COL_INFO, "h/w %d (%d) prot %d (%d) op 0x%04x",
131 ea.htype, ea.halen, ea.ptype, ea.palen, ea.op);
134 if (check_col(fd, COL_INFO)) {
137 col_add_fstr(fd, COL_INFO, "Who has %s? Tell %s",
138 atalkid_to_str((guint8 *) ea.pdaddr), atalkid_to_str((guint8 *) ea.psaddr));
141 col_add_fstr(fd, COL_INFO, "%s is at %s",
142 atalkid_to_str((guint8 *) ea.psaddr),
143 ether_to_str((guint8 *) ea.hsaddr));
146 col_add_fstr(fd, COL_INFO, "Is there a %s",
147 atalkid_to_str((guint8 *) ea.pdaddr));
154 proto_register_aarp(void)
156 /* static hf_register_info hf[] = {
158 { "Name", "aarp.abbreviation", TYPE, VALS_POINTER }},
161 proto_aarp = proto_register_protocol("Appletalk Address Resolution Protocol", "aarp");
162 /* proto_register_field_array(proto_aarp, hf, array_length(hf));*/