2 * Routines for Mobile IP dissection
3 * Copyright 2000, Stefan Raab <Stefan.Raab@nextel.com>
5 * $Id: packet-mip.c,v 1.11 2001/01/03 16:41:06 gram Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@unicom.net>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #ifdef HAVE_SYS_TYPES_H
34 # include <sys/types.h>
37 #ifdef HAVE_NETINET_IN_H
38 # include <netinet/in.h>
44 #ifdef NEED_SNPRINTF_H
45 # include "snprintf.h"
50 /* Initialize the protocol and registered fields */
51 static int proto_mip = -1;
52 static int hf_mip_type = -1;
53 static int hf_mip_s = -1;
54 static int hf_mip_b = -1;
55 static int hf_mip_d = -1;
56 static int hf_mip_m = -1;
57 static int hf_mip_g = -1;
58 static int hf_mip_v = -1;
59 static int hf_mip_code = -1;
60 static int hf_mip_life = -1;
61 static int hf_mip_homeaddr = -1;
62 static int hf_mip_haaddr = -1;
63 static int hf_mip_coa = -1;
64 static int hf_mip_ident = -1;
66 /* Initialize the subtree pointers */
67 static gint ett_mip = -1;
69 /* Port used for Mobile IP */
70 #define UDP_PORT_MIP 434
79 struct mip_request_packet{
82 unsigned char life[2];
83 unsigned char homeaddr[4];
84 unsigned char haaddr[4];
86 unsigned char ident[8];
91 struct mip_reply_packet{
94 unsigned char life[2];
95 unsigned char homeaddr[4];
96 unsigned char haaddr[4];
97 unsigned char ident[8];
102 static const value_string mip_types[] = {
103 {1, "Registration Request"},
104 {3, "Registration Reply"},
108 static const value_string mip_reply_codes[]= {
109 {0, "Registration Accepted"},
110 {1, "Registration Accepted, no simul bindings"},
111 {64, "Registration Denied by FA, unspecified reason"},
112 {65, "Registration Denied by FA, Admin Prohibit"},
113 {66, "Registration Denied by FA, Insufficient Resources"},
114 {67, "Registration Denied by FA, MN failed Auth"},
115 {68, "Registration Denied by FA, HA failed Auth"},
116 {69, "Registration Denied by FA, Lifetime to long"},
117 {70, "Registration Denied by FA, Poorly Formed Request"},
118 {71, "Registration Denied by FA, Poorly Formed Reply"},
119 {72, "Registration Denied by FA, encap unavailable"},
120 {73, "Registration Denied by FA, VJ unavailable"},
121 {80, "Registration Denied by FA, Home net unreachable"},
122 {81, "Registration Denied by FA, Home Agent host unreachable"},
123 {82, "Registration Denied by FA, Home Agent port unreachable"},
124 {88, "Registration Denied by FA, Home Agent unreachable"},
125 {128, "Registration Denied by HA, unspecified"},
126 {129, "Registration Denied by HA, Admin Prohibit"},
127 {130, "Registration Denied by HA, insufficient resources"},
128 {131, "Registration Denied by HA, MN failed Auth"},
129 {132, "Registration Denied by HA, FA failed Auth"},
130 {133, "Registration Denied by HA, registration ID Mismatch"},
131 {134, "Registration Denied by HA, poorly formed request"},
132 {135, "Registration Denied by HA, too many simul bindings"},
133 {136, "Registration Denied by HA, unknown HA address"},
137 /* Code to actually dissect the packets */
139 dissect_mip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
142 /* Set up structures we will need to add the protocol subtree and manage it */
144 proto_tree *mip_tree;
147 /* Make our own tvb until the function call includes one */
149 packet_info *pinfo = π
150 tvb = tvb_create_from_top(offset);
152 CHECK_DISPLAY_AS_DATA(proto_mip, tvb, pinfo, tree);
154 /* Make entries in Protocol column and Info column on summary display */
156 pinfo->current_proto = "Mobile IP";
157 if (check_col(fd, COL_PROTOCOL))
158 col_set_str(fd, COL_PROTOCOL, "mip");
160 type = tvb_get_guint8(tvb, 0);
164 if (check_col(fd, COL_INFO))
165 col_set_str(fd, COL_INFO, "Mobile IP Registration Request");
168 ti = proto_tree_add_item(tree, proto_mip, tvb, 0, tvb_length(tvb), FALSE);
169 mip_tree = proto_item_add_subtree(ti, ett_mip);
170 proto_tree_add_int(mip_tree, hf_mip_type, tvb, 0, 1, type);
172 code = tvb_get_guint8(tvb, 1);
173 proto_tree_add_boolean(mip_tree, hf_mip_s, tvb, 1, 1, code);
174 proto_tree_add_boolean(mip_tree, hf_mip_b, tvb, 1, 1, code);
175 proto_tree_add_boolean(mip_tree, hf_mip_d, tvb, 1, 1, code);
176 proto_tree_add_boolean(mip_tree, hf_mip_m, tvb, 1, 1, code);
177 proto_tree_add_boolean(mip_tree, hf_mip_g, tvb, 1, 1, code);
178 proto_tree_add_boolean(mip_tree, hf_mip_v, tvb, 1, 1, code);
180 proto_tree_add_int(mip_tree, hf_mip_life, tvb, 2, 2, tvb_get_ntohs(tvb, 2));
181 proto_tree_add_ipv4(mip_tree, hf_mip_homeaddr, tvb, 4, 4, tvb_get_letohl(tvb, 4));
182 proto_tree_add_ipv4(mip_tree, hf_mip_haaddr, tvb, 8, 4, tvb_get_letohl(tvb, 8));
183 proto_tree_add_ipv4(mip_tree, hf_mip_coa, tvb, 12, 4, tvb_get_letohl(tvb, 12));
184 proto_tree_add_bytes(mip_tree, hf_mip_ident, tvb, 16, 8, tvb_get_ptr(tvb, 16, 8));
190 if (check_col(fd, COL_INFO))
191 col_set_str(fd, COL_INFO, "Mobile IP Registration Reply");
194 ti = proto_tree_add_item(tree, proto_mip, tvb, 0, tvb_length(tvb), FALSE);
195 mip_tree = proto_item_add_subtree(ti, ett_mip);
196 proto_tree_add_int(mip_tree, hf_mip_type, tvb, 0, 1, type);
198 code = tvb_get_guint8(tvb, 1);
199 proto_tree_add_uint(mip_tree, hf_mip_code, tvb, 1, 1, code);
200 proto_tree_add_int(mip_tree, hf_mip_life, tvb, 2, 2, tvb_get_ntohs(tvb, 2));
201 proto_tree_add_ipv4(mip_tree, hf_mip_homeaddr, tvb, 4, 4, tvb_get_letohl(tvb, 4));
202 proto_tree_add_ipv4(mip_tree, hf_mip_haaddr, tvb, 8, 4, tvb_get_letohl(tvb, 8));
203 proto_tree_add_bytes(mip_tree, hf_mip_ident, tvb, 12, 8, tvb_get_ptr(tvb, 12, 8));
208 /* Register the protocol with Ethereal */
209 void proto_register_mip(void)
212 /* Setup list of header fields */
213 static hf_register_info hf[] = {
215 { "Message Type", "mip.type",
216 FT_INT8, BASE_DEC, VALS(mip_types), 0,
217 "Mobile IP Message type." }
220 {"Simultaneous Bindings", "mip.s",
221 FT_BOOLEAN, 8, NULL, 128,
222 "Simultaneous Bindings Allowed" }
225 {"Broadcast Datagrams", "mip.b",
226 FT_BOOLEAN, 8, NULL, 64,
227 "Broadcast Datagrams requested" }
230 { "Co-lcated Care-of Address", "mip.d",
231 FT_BOOLEAN, 8, NULL, 32,
232 "MN using Co-located Care-of address" }
235 {"Minimal Encapsulation", "mip.m",
236 FT_BOOLEAN, 8, NULL, 16,
237 "MN wants Minimal encapsulation" }
241 FT_BOOLEAN, 8, NULL, 8,
242 "MN wants GRE encapsulation" }
245 { "Van Jacobson", "mip.v",
246 FT_BOOLEAN, 8, NULL, 4,
250 { "Reply Code", "mip.code",
251 FT_UINT8, BASE_DEC, VALS(mip_reply_codes), 0,
252 "Mobile IP Reply code." }
255 { "Lifetime", "mip.life",
256 FT_INT16, BASE_DEC, NULL, 0,
257 "Mobile IP Lifetime." }
260 { "Home Address", "mip.homeaddr",
261 FT_IPv4, BASE_NONE, NULL, 0,
262 "Mobile Node's home address." }
266 { "Home Agent", "mip.haaddr",
267 FT_IPv4, BASE_NONE, NULL, 0,
268 "Home agent IP Address." }
271 { "Care of Address", "mip.coa",
272 FT_IPv4, BASE_NONE, NULL, 0,
276 { "Identification", "mip.ident",
277 FT_BYTES, BASE_NONE, NULL, 0,
278 "MN Identification." }
286 /* Setup protocol subtree array */
287 static gint *ett[] = {
291 /* Register the protocol name and description */
292 proto_mip = proto_register_protocol("Mobile IP", "Mobile IP", "mip");
294 /* Required function calls to register the header fields and subtrees used */
295 proto_register_field_array(proto_mip, hf, array_length(hf));
296 proto_register_subtree_array(ett, array_length(ett));
300 proto_reg_handoff_mip(void)
302 old_dissector_add("udp.port", UDP_PORT_MIP, dissect_mip);