Deleted Added
full compact
print-mobility.c (313537) print-mobility.c (327234)
1/*
2 * Copyright (C) 2002 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30/* \summary: IPv6 mobility printer */
1/*
2 * Copyright (C) 2002 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30/* \summary: IPv6 mobility printer */
31/* RFC 3775 */
31
32#ifdef HAVE_CONFIG_H
33#include "config.h"
34#endif
35
36#include <netdissect-stdinc.h>
37
32
33#ifdef HAVE_CONFIG_H
34#include "config.h"
35#endif
36
37#include <netdissect-stdinc.h>
38
38#include "ip6.h"
39#include "netdissect.h"
40#include "addrtoname.h"
41#include "extract.h"
42
39#include "netdissect.h"
40#include "addrtoname.h"
41#include "extract.h"
42
43#include "ip6.h"
44
43static const char tstr[] = "[|MOBILITY]";
44
45/* Mobility header */
46struct ip6_mobility {
47 uint8_t ip6m_pproto; /* following payload protocol (for PG) */
48 uint8_t ip6m_len; /* length in units of 8 octets */
49 uint8_t ip6m_type; /* message type */
50 uint8_t reserved; /* reserved */

--- 92 unchanged lines hidden (view full) ---

143 ND_PRINT((ndo, "(padn)"));
144 break;
145 case IP6MOPT_REFRESH:
146 if (len - i < IP6MOPT_REFRESH_MINLEN) {
147 ND_PRINT((ndo, "(refresh: trunc)"));
148 goto trunc;
149 }
150 /* units of 4 secs */
45static const char tstr[] = "[|MOBILITY]";
46
47/* Mobility header */
48struct ip6_mobility {
49 uint8_t ip6m_pproto; /* following payload protocol (for PG) */
50 uint8_t ip6m_len; /* length in units of 8 octets */
51 uint8_t ip6m_type; /* message type */
52 uint8_t reserved; /* reserved */

--- 92 unchanged lines hidden (view full) ---

145 ND_PRINT((ndo, "(padn)"));
146 break;
147 case IP6MOPT_REFRESH:
148 if (len - i < IP6MOPT_REFRESH_MINLEN) {
149 ND_PRINT((ndo, "(refresh: trunc)"));
150 goto trunc;
151 }
152 /* units of 4 secs */
153 ND_TCHECK_16BITS(&bp[i+2]);
151 ND_PRINT((ndo, "(refresh: %u)",
152 EXTRACT_16BITS(&bp[i+2]) << 2));
153 break;
154 case IP6MOPT_ALTCOA:
155 if (len - i < IP6MOPT_ALTCOA_MINLEN) {
156 ND_PRINT((ndo, "(altcoa: trunc)"));
157 goto trunc;
158 }
154 ND_PRINT((ndo, "(refresh: %u)",
155 EXTRACT_16BITS(&bp[i+2]) << 2));
156 break;
157 case IP6MOPT_ALTCOA:
158 if (len - i < IP6MOPT_ALTCOA_MINLEN) {
159 ND_PRINT((ndo, "(altcoa: trunc)"));
160 goto trunc;
161 }
162 ND_TCHECK_128BITS(&bp[i+2]);
159 ND_PRINT((ndo, "(alt-CoA: %s)", ip6addr_string(ndo, &bp[i+2])));
160 break;
161 case IP6MOPT_NONCEID:
162 if (len - i < IP6MOPT_NONCEID_MINLEN) {
163 ND_PRINT((ndo, "(ni: trunc)"));
164 goto trunc;
165 }
163 ND_PRINT((ndo, "(alt-CoA: %s)", ip6addr_string(ndo, &bp[i+2])));
164 break;
165 case IP6MOPT_NONCEID:
166 if (len - i < IP6MOPT_NONCEID_MINLEN) {
167 ND_PRINT((ndo, "(ni: trunc)"));
168 goto trunc;
169 }
170 ND_TCHECK_16BITS(&bp[i+2]);
171 ND_TCHECK_16BITS(&bp[i+4]);
166 ND_PRINT((ndo, "(ni: ho=0x%04x co=0x%04x)",
167 EXTRACT_16BITS(&bp[i+2]),
168 EXTRACT_16BITS(&bp[i+4])));
169 break;
170 case IP6MOPT_AUTH:
171 if (len - i < IP6MOPT_AUTH_MINLEN) {
172 ND_PRINT((ndo, "(auth: trunc)"));
173 goto trunc;

--- 62 unchanged lines hidden (view full) ---

236 switch (type) {
237 case IP6M_BINDING_REQUEST:
238 hlen = IP6M_MINLEN;
239 break;
240 case IP6M_HOME_TEST_INIT:
241 case IP6M_CAREOF_TEST_INIT:
242 hlen = IP6M_MINLEN;
243 if (ndo->ndo_vflag) {
172 ND_PRINT((ndo, "(ni: ho=0x%04x co=0x%04x)",
173 EXTRACT_16BITS(&bp[i+2]),
174 EXTRACT_16BITS(&bp[i+4])));
175 break;
176 case IP6MOPT_AUTH:
177 if (len - i < IP6MOPT_AUTH_MINLEN) {
178 ND_PRINT((ndo, "(auth: trunc)"));
179 goto trunc;

--- 62 unchanged lines hidden (view full) ---

242 switch (type) {
243 case IP6M_BINDING_REQUEST:
244 hlen = IP6M_MINLEN;
245 break;
246 case IP6M_HOME_TEST_INIT:
247 case IP6M_CAREOF_TEST_INIT:
248 hlen = IP6M_MINLEN;
249 if (ndo->ndo_vflag) {
244 ND_TCHECK2(*mh, hlen + 8);
250 ND_TCHECK_32BITS(&bp[hlen + 4]);
245 ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
246 type == IP6M_HOME_TEST_INIT ? "Home" : "Care-of",
247 EXTRACT_32BITS(&bp[hlen]),
248 EXTRACT_32BITS(&bp[hlen + 4])));
249 }
250 hlen += 8;
251 break;
252 case IP6M_HOME_TEST:
253 case IP6M_CAREOF_TEST:
254 ND_TCHECK(mh->ip6m_data16[0]);
255 ND_PRINT((ndo, " nonce id=0x%x", EXTRACT_16BITS(&mh->ip6m_data16[0])));
256 hlen = IP6M_MINLEN;
257 if (ndo->ndo_vflag) {
251 ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
252 type == IP6M_HOME_TEST_INIT ? "Home" : "Care-of",
253 EXTRACT_32BITS(&bp[hlen]),
254 EXTRACT_32BITS(&bp[hlen + 4])));
255 }
256 hlen += 8;
257 break;
258 case IP6M_HOME_TEST:
259 case IP6M_CAREOF_TEST:
260 ND_TCHECK(mh->ip6m_data16[0]);
261 ND_PRINT((ndo, " nonce id=0x%x", EXTRACT_16BITS(&mh->ip6m_data16[0])));
262 hlen = IP6M_MINLEN;
263 if (ndo->ndo_vflag) {
258 ND_TCHECK2(*mh, hlen + 8);
264 ND_TCHECK_32BITS(&bp[hlen + 4]);
259 ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
260 type == IP6M_HOME_TEST ? "Home" : "Care-of",
261 EXTRACT_32BITS(&bp[hlen]),
262 EXTRACT_32BITS(&bp[hlen + 4])));
263 }
264 hlen += 8;
265 if (ndo->ndo_vflag) {
265 ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
266 type == IP6M_HOME_TEST ? "Home" : "Care-of",
267 EXTRACT_32BITS(&bp[hlen]),
268 EXTRACT_32BITS(&bp[hlen + 4])));
269 }
270 hlen += 8;
271 if (ndo->ndo_vflag) {
266 ND_TCHECK2(*mh, hlen + 8);
272 ND_TCHECK_32BITS(&bp[hlen + 4]);
267 ND_PRINT((ndo, " %s Keygen Token=%08x:%08x",
268 type == IP6M_HOME_TEST ? "Home" : "Care-of",
269 EXTRACT_32BITS(&bp[hlen]),
270 EXTRACT_32BITS(&bp[hlen + 4])));
271 }
272 hlen += 8;
273 break;
274 case IP6M_BINDING_UPDATE:
275 ND_TCHECK(mh->ip6m_data16[0]);
276 ND_PRINT((ndo, " seq#=%u", EXTRACT_16BITS(&mh->ip6m_data16[0])));
277 hlen = IP6M_MINLEN;
273 ND_PRINT((ndo, " %s Keygen Token=%08x:%08x",
274 type == IP6M_HOME_TEST ? "Home" : "Care-of",
275 EXTRACT_32BITS(&bp[hlen]),
276 EXTRACT_32BITS(&bp[hlen + 4])));
277 }
278 hlen += 8;
279 break;
280 case IP6M_BINDING_UPDATE:
281 ND_TCHECK(mh->ip6m_data16[0]);
282 ND_PRINT((ndo, " seq#=%u", EXTRACT_16BITS(&mh->ip6m_data16[0])));
283 hlen = IP6M_MINLEN;
278 ND_TCHECK2(*mh, hlen + 1);
279 if (bp[hlen] & 0xf0)
284 ND_TCHECK_16BITS(&bp[hlen]);
285 if (bp[hlen] & 0xf0) {
280 ND_PRINT((ndo, " "));
286 ND_PRINT((ndo, " "));
281 if (bp[hlen] & 0x80)
282 ND_PRINT((ndo, "A"));
283 if (bp[hlen] & 0x40)
284 ND_PRINT((ndo, "H"));
285 if (bp[hlen] & 0x20)
286 ND_PRINT((ndo, "L"));
287 if (bp[hlen] & 0x10)
288 ND_PRINT((ndo, "K"));
287 if (bp[hlen] & 0x80)
288 ND_PRINT((ndo, "A"));
289 if (bp[hlen] & 0x40)
290 ND_PRINT((ndo, "H"));
291 if (bp[hlen] & 0x20)
292 ND_PRINT((ndo, "L"));
293 if (bp[hlen] & 0x10)
294 ND_PRINT((ndo, "K"));
295 }
289 /* Reserved (4bits) */
290 hlen += 1;
291 /* Reserved (8bits) */
292 hlen += 1;
296 /* Reserved (4bits) */
297 hlen += 1;
298 /* Reserved (8bits) */
299 hlen += 1;
293 ND_TCHECK2(*mh, hlen + 2);
300 ND_TCHECK_16BITS(&bp[hlen]);
294 /* units of 4 secs */
295 ND_PRINT((ndo, " lifetime=%u", EXTRACT_16BITS(&bp[hlen]) << 2));
296 hlen += 2;
297 break;
298 case IP6M_BINDING_ACK:
299 ND_TCHECK(mh->ip6m_data8[0]);
300 ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
301 /* units of 4 secs */
302 ND_PRINT((ndo, " lifetime=%u", EXTRACT_16BITS(&bp[hlen]) << 2));
303 hlen += 2;
304 break;
305 case IP6M_BINDING_ACK:
306 ND_TCHECK(mh->ip6m_data8[0]);
307 ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
308 ND_TCHECK(mh->ip6m_data8[1]);
301 if (mh->ip6m_data8[1] & 0x80)
302 ND_PRINT((ndo, " K"));
303 /* Reserved (7bits) */
304 hlen = IP6M_MINLEN;
309 if (mh->ip6m_data8[1] & 0x80)
310 ND_PRINT((ndo, " K"));
311 /* Reserved (7bits) */
312 hlen = IP6M_MINLEN;
305 ND_TCHECK2(*mh, hlen + 2);
313 ND_TCHECK_16BITS(&bp[hlen]);
306 ND_PRINT((ndo, " seq#=%u", EXTRACT_16BITS(&bp[hlen])));
307 hlen += 2;
314 ND_PRINT((ndo, " seq#=%u", EXTRACT_16BITS(&bp[hlen])));
315 hlen += 2;
308 ND_TCHECK2(*mh, hlen + 2);
316 ND_TCHECK_16BITS(&bp[hlen]);
309 /* units of 4 secs */
310 ND_PRINT((ndo, " lifetime=%u", EXTRACT_16BITS(&bp[hlen]) << 2));
311 hlen += 2;
312 break;
313 case IP6M_BINDING_ERROR:
314 ND_TCHECK(mh->ip6m_data8[0]);
315 ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
316 /* Reserved */
317 hlen = IP6M_MINLEN;
317 /* units of 4 secs */
318 ND_PRINT((ndo, " lifetime=%u", EXTRACT_16BITS(&bp[hlen]) << 2));
319 hlen += 2;
320 break;
321 case IP6M_BINDING_ERROR:
322 ND_TCHECK(mh->ip6m_data8[0]);
323 ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
324 /* Reserved */
325 hlen = IP6M_MINLEN;
318 ND_TCHECK2(*mh, hlen + 16);
326 ND_TCHECK2(bp[hlen], 16);
319 ND_PRINT((ndo, " homeaddr %s", ip6addr_string(ndo, &bp[hlen])));
320 hlen += 16;
321 break;
322 default:
323 ND_PRINT((ndo, " len=%u", mh->ip6m_len));
324 return(mhlen);
325 break;
326 }
327 if (ndo->ndo_vflag)
328 if (mobility_opt_print(ndo, &bp[hlen], mhlen - hlen))
329 goto trunc;;
330
331 return(mhlen);
332
333 trunc:
334 ND_PRINT((ndo, "%s", tstr));
327 ND_PRINT((ndo, " homeaddr %s", ip6addr_string(ndo, &bp[hlen])));
328 hlen += 16;
329 break;
330 default:
331 ND_PRINT((ndo, " len=%u", mh->ip6m_len));
332 return(mhlen);
333 break;
334 }
335 if (ndo->ndo_vflag)
336 if (mobility_opt_print(ndo, &bp[hlen], mhlen - hlen))
337 goto trunc;;
338
339 return(mhlen);
340
341 trunc:
342 ND_PRINT((ndo, "%s", tstr));
335 return(mhlen);
343 return(-1);
336}
344}