A
download icmpv6.c
Language: C
License: GPL
LOC: 400
Project Info
IPgrab
Server: SourceForge
Type: cvs
...i\ipgrab\ipgrab\IPgrab\src\
   ah.c
   ah.h
   arp.c
   arp.h
   bgp.c
   bgp.h
   cbcp.c
   cbcp.h
   ccp.c
   ccp.h
   chap.c
   chap.h
   datalink.c
   datalink.h
   dhcp.c
   dhcp.h
   display.c
   display.h
   dns.c
   dns.h
   dynports.c
   dynports.h
   error.c
   error.h
   esp.c
   esp.h
   ethernet.c
   ethernet.h
   ethertypes.c
   ethertypes.h
   file.c
   file.h
   ftpctrl.c
   ftpctrl.h
   getopt.c
   getopt.h
   global.h
   gre.c
   gre.h
   hexbuffer.c
   hexbuffer.h
   http.c
   http.h
   iana.c
   iana.h
   icmp.c
   icmp.h
   icmpv6.c
   icmpv6.h
   igmp.c
   igmp.h
   ip.c
   ip.h
   ip_protocols.c
   ip_protocols.h
   ip_services.c
   ip_services.h
   ipcp.c
   ipcp.h
   ipgrab.c
   ipgrab.h
   ipgsnmp.h
   ipv6.c
   ipv6.h
   ipx.c
   ipx.h
   ipxrip.c
   ipxrip.h
   isakmp.c
   isakmp.h
   l2tp.c
   l2tp.h
   layers.c
   layers.h
   lcp.c
   lcp.h
   llc.c
   llc.h
   local.h
   loopback.c
   loopback.h
   Makefile.am
   Makefile.in
   mgcp.c
   mgcp.h
   mobileip.c
   mobileip.h
   mppc.c
   mppc.h
   netbios_ns.c
   netbios_ns.h
   nntp.c
   nntp.h
   ns_labels.c
   ns_labels.h
   open_pcap.c
   open_pcap.h
   ospf.c
   ospf.h
   packet_manip.c
   packet_manip.h
   padding.c
   padding.h
   parse_cl.c
   parse_cl.h
   payload.c
   payload.h
   ppp.c
   ppp.h
   pppoe.c
   pppoe.h
   pptp.c
   pptp.h
   protocols.h
   radius.c
   radius.h
   radius_3gpp2.c
   radius_3gpp2.h
   raw.c
   raw.h
   rip.c
   rip.h
   ripng.c
   ripng.h
   rsip.c
   rsip.h
   rsvp.c
   rsvp.h
   rtcp.c
   rtcp.h
   rtp.c
   rtp.h
   sdp.c
   sdp.h
   sip.c
   sip.h
   slip.c
   slip.h
   slp.c
   slp.h
   snmp.c
   spx.c
   spx.h
   ssh.c
   ssh.h
   state.c
   state.h
   stats.c
   stats.h
   strmap.c
   strmap.h
   tcp.c
   tcp.h
   template.c
   template.h
   tftp.c
   tftp.h
   udp.c
   udp.h
   utilities.c
   utilities.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
/**************************************************************************** 
** File: icmpv6.c
**
** Author: Mike Borella
**
** Comments: Dump ICMPv6 information
**
** $Id: icmpv6.c,v 1.16 2002/02/27 14:42:15 mborella Exp $
**
** 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 Library 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 "ipv6.h"
#include "icmpv6.h"

#define HOLDER_SIZE   64
#define IPV6ADDR_SIZE 16

/*
 * ICMPv6 type fields
 */

#define ICMPV6_TYPE_DESTUNREACHABLE     1
#define ICMPV6_TYPE_PACKETTOOBIG        2
#define ICMPV6_TYPE_TIMEEXCEEDED        3
#define ICMPV6_TYPE_PARAMETERPROBLEM    4
#define ICMPV6_TYPE_ECHOREQUEST         128
#define ICMPV6_TYPE_ECHOREPLY           129
#define ICMPV6_TYPE_GROUPMEMQUERY       130
#define ICMPV6_TYPE_GROUPMEMREPORT      131
#define ICMPV6_TYPE_GROUPMEMREDUCTION   132
#define ICMPV6_TYPE_ROUTERSOLICIT       133
#define ICMPV6_TYPE_ROUTERADVERT        134
#define ICMPV6_TYPE_NEIGHBORSOLICIT     135
#define ICMPV6_TYPE_NEIGHBORADVERT      136
#define ICMPV6_TYPE_REDIRECT            137

/*
 * ICMPv6 destination unreachable code fields
 */

#define ICMPV6_DUCODE_NOROUTE           0
#define ICMPV6_DUCODE_ADMIN             1
#define ICMPV6_DUCODE_ADDRUNREACHABLE   2
#define ICMPV6_DUCODE_PORTUNREACHABLE   3

/*
 * ICMPv6 time exceeded code fields
 */

#define ICMPV6_TECODE_HOPLIMIT          0
#define ICMPV6_TECODE_REASSEMBLY        1

/*
 * ICMPv6 parameter problem code fields
 */

#define ICMPV6_PPCODE_BADHEADERFIELD    0
#define ICMPV6_PPCODE_BADNEXTHEADER     1
#define ICMPV6_PPCODE_BADIPV6OPTION     2

/*
 * ICMPv6 options
 */

#define ICMPV6_OPTION_SRCLLADDR         1
#define ICMPV6_OPTION_DSTLLADDR         2
#define ICMPV6_OPTION_PREFIX            3
#define ICMPV6_OPTION_REDIRECTEDHDR     4
#define ICMPV6_OPTION_MTU               5

/*
 * ICMPv6 option map
 */

strmap_t icmpv6_option_map [] =
{
  { ICMPV6_OPTION_SRCLLADDR,    "source link-layer address" },
  { ICMPV6_OPTION_DSTLLADDR,    "destination link-layer address" },
  { ICMPV6_OPTION_PREFIX,       "prefix" },
  { ICMPV6_OPTION_REDIRECTEDHDR,"redirected header" },
  { ICMPV6_OPTION_MTU,          "MTU" },
  { 0, "" }
};

/*
 * ICMPv6 common header format
 */

typedef struct icmpv6_header
{
  u_int8_t       type;
  u_int8_t       code;
  u_int16_t      checksum;
} icmpv6_header_t;

/* 
 * ICMPv6 router advertisement structure
 */

typedef struct icmpv6_routeradvert
{
  u_int8_t   curr_hop_limit;
  u_int8_t   mo_reserved;
  u_int16_t  router_lifetime;
  u_int32_t  reachable_time;
  u_int32_t  retransmit_timer;  
} icmpv6_routeradvert_t;

/* 
 * ICMPv6 prefix option
 */

typedef struct icmpv6_option_prefix
{
  u_int8_t   prefix_length;
  u_int8_t   la_reserved;
  u_int32_t  valid_lifetime;
  u_int32_t  preferred_lifetime;
  u_int32_t  reserved2;
  u_int8_t   prefix [16];
} icmpv6_option_prefix_t;

/*
 * ICMPv6 type map
 */

strmap_t icmpv6_type_map [] =
{
  { ICMPV6_TYPE_DESTUNREACHABLE,    "destination unreachable" },
  { ICMPV6_TYPE_PACKETTOOBIG,       "packet too big" },
  { ICMPV6_TYPE_TIMEEXCEEDED,       "time exceeded" },
  { ICMPV6_TYPE_PARAMETERPROBLEM,   "parameter problem" },
  { ICMPV6_TYPE_ECHOREQUEST,        "echo request" },
  { ICMPV6_TYPE_ECHOREPLY,          "echo reply" },
  { ICMPV6_TYPE_GROUPMEMQUERY,      "group membership query" },
  { ICMPV6_TYPE_GROUPMEMREPORT,     "group membership report" },
  { ICMPV6_TYPE_GROUPMEMREDUCTION,  "group membership reduction" },
  { ICMPV6_TYPE_ROUTERSOLICIT,      "router solicitation" },
  { ICMPV6_TYPE_ROUTERADVERT,       "router advertisement" },
  { ICMPV6_TYPE_NEIGHBORSOLICIT,    "neighbor solicitation" },
  { ICMPV6_TYPE_NEIGHBORADVERT,     "neighbor advertisement" },
  { ICMPV6_TYPE_REDIRECT,           "redirect" },
  { 0, "" }
};

/*
 * ICMPv6 destination unreachable code map
 */

strmap_t icmpv6_ducode_map [] = 
{
  { ICMPV6_DUCODE_NOROUTE,          "no route" },
  { ICMPV6_DUCODE_ADMIN,            "administratively prohibited" },
  { ICMPV6_DUCODE_ADDRUNREACHABLE,  "address unreachable" },
  { ICMPV6_DUCODE_PORTUNREACHABLE,  "port unreachable" },
  { 0, "" }
};

extern struct arg_t *my_args;


/*----------------------------------------------------------------------------
**
** dump_icmpv6_options()
**
** Parse ICMPv6 options
**
**----------------------------------------------------------------------------
*/

void dump_icmpv6_options(packet_t * pkt)
{
  u_int8_t  type;
  u_int8_t  len;
  u_int8_t  real_len;

  while(get_packet_apparentbytesleft(pkt) >= 2)
    {
      /* Get type and len */
      if (get_packet_bytes((u_int8_t *) &type, pkt, 1) == 0)
	return;
      if (get_packet_bytes((u_int8_t *) &len, pkt, 1) == 0)
	return;

      /* Calculate the real length */
      real_len = (8 * len) - 2;

      /* Display type and code */
      if (my_args->m)
	{
	  display_minimal_strmap(type, icmpv6_option_map);
	  display_minimal_string(" ");
	}
      else
	{
	  display_strmap("Type", type, icmpv6_option_map);
	  display("  Length", (u_int8_t *) &len, 1, DISP_DEC);
	}

      /* Get the value */
      switch(type)
	{
	case ICMPV6_OPTION_SRCLLADDR:
	case ICMPV6_OPTION_DSTLLADDR:
	  {
	    u_int8_t * value;

	    /* Allocate memory */
	    value = my_malloc(real_len);
	    
	    /* Read and display the address */
	    if (get_packet_bytes(value, pkt, real_len) == 0)
	      return;
	    if (my_args->m)
	      {
		display_minimal(value, real_len, DISP_HEXCOLONS);
		display_minimal_string(" ");
	      }
	    else
	      display("  Address", value, real_len, DISP_HEXCOLONS);

	    /* Free memory */
	    my_free(value);
	  }
	  break;
	  
	case ICMPV6_OPTION_PREFIX:
	  {
	    /*
	     * I tried to read the rest of the prefix in using a structure 
	     * and for some weird reason it was misaligned.  This is a quick
	     * but ugly workaround.  
	     */

	    u_int8_t   prefix_length;
	    u_int8_t   la_reserved;
	    u_int8_t   l_bit, a_bit, reserved1;
	    u_int32_t  valid_lifetime;
	    u_int32_t  preferred_lifetime;
	    u_int32_t  reserved2;
	    u_int8_t   prefix[16];

	    /* Read the prefix option */
	    if (get_packet_bytes((u_int8_t *) &prefix_length, pkt, 1) == 0)
	      return;
	    if (get_packet_bytes((u_int8_t *) &la_reserved, pkt, 1) == 0)
	      return;
	    if (get_packet_bytes((u_int8_t *) &valid_lifetime, pkt, 4) == 0)
	      return;
	    if (get_packet_bytes((u_int8_t *) &preferred_lifetime, pkt, 4) == 0)
	      return;
	    if (get_packet_bytes((u_int8_t *) &reserved2, pkt, 4) == 0)
	      return;
	    if (get_packet_bytes((u_int8_t *) &prefix, pkt, 16) == 0)
	      return;


	    /* Conversions */
	    valid_lifetime = ntohl(valid_lifetime);
	    preferred_lifetime = ntohl(preferred_lifetime);
	    reserved2 = ntohl(reserved2);
	    l_bit = la_reserved >> 7;
	    a_bit = (la_reserved >> 6) & 0x01;
	    reserved1 = la_reserved & 0x3f;
	    
	    /* Display */
	    if (my_args->m)
	      {
		display_minimal_ipv6((u_int8_t *) &prefix);
		display_minimal_string(" ");
	      }
	    else
	      {
		display("  Prefix length", (u_int8_t *) &prefix_length, 
			1, DISP_DEC);
		display("  L (on-link) bit", (u_int8_t *) &l_bit, 1, DISP_DEC);
		display("  A (auto config) bit", (u_int8_t *) &l_bit, 1, 
			DISP_DEC);
		display("  Reserved", (u_int8_t *) &reserved1, 1, DISP_DEC);
		display("  Valid lifetime", 
			(u_int8_t *) &valid_lifetime, 4, DISP_DEC);
		display("  Preferred lifetime", 
			(u_int8_t *) &preferred_lifetime, 4, DISP_DEC);
		display("  Reserved", (u_int8_t *) &reserved2, 4, 
			DISP_HEX);
		display_ipv6("  Prefix", (u_int8_t *) &prefix);
	      }
	  }
	  break;

	case ICMPV6_OPTION_REDIRECTEDHDR:
	  {
	  }
	  break;

	case ICMPV6_OPTION_MTU:
	  {
	    u_int16_t reserved;
	    u_int32_t mtu;

	    /* Get the reserved and MTU fields */
	    if (get_packet_bytes((u_int8_t *) &reserved, pkt, 2) == 0)
	      return;
	    if (get_packet_bytes((u_int8_t *) &mtu, pkt, 4) == 0)
	      return;
	    
	    /* Conversions */
	    reserved = ntohs(reserved);
	    mtu = ntohl(mtu);

	    /* Display */
	    if (my_args->m)
	      {
		display_minimal((u_int8_t *) &mtu, 4, DISP_DEC);
		display_minimal_string(" ");
	      }
	    else
	      {
		display("  Reserved", (u_int8_t *) &reserved, 2, DISP_DEC);
		display("  MTU", (u_int8_t *) &mtu, 4, DISP_DEC);
	      }
	  }
	  break;

	default:
	  /* Just get the bytes and dump it as hex */
	  break;

	} /* switch */

    } /* while */

}

/*----------------------------------------------------------------------------
**
** dump_icmpv6()
**
** Parse ICMPv6 header and dump fields
**
**----------------------------------------------------------------------------
*/

void dump_icmpv6(packet_t *pkt)
{
  icmpv6_header_t icmpv6;
  char            holder[HOLDER_SIZE];
  u_int32_t       parameter;


  /* Set the layer */
  set_layer(LAYER_NETWORK);

  /*
   * Stats accounting
   */

  stats_update(STATS_ICMPV6);

  /*
   * Get the ICMPv6 header
   */

  if (get_packet_bytes((u_int8_t *) &icmpv6, pkt, 4) == 0)
    return;

  /*
   * Conversions
   */

  icmpv6.checksum = ntohs(icmpv6.checksum);

  /*
   * Dump header
   */

  if (my_args->m)
    {
      display_minimal_string("| ICMPv6 ");
      display_minimal_string(map2str(icmpv6_type_map, icmpv6.type));
      display_minimal_string(" ");
    }
  else
    {
      /* announcement */
      display_header_banner("ICMPv6 Header");
      
      /* print type */
      snprintf(holder, HOLDER_SIZE, "%d (%s)", icmpv6.type, 
	      map2str(icmpv6_type_map, icmpv6.type));
      display_string("Type", holder);
      
      /* based on the type, decide what to do with the code */
      switch(icmpv6.type)
	{
	case ICMPV6_TYPE_DESTUNREACHABLE:
	  snprintf(holder, HOLDER_SIZE, "%d (%s)", icmpv6.code, 
		  map2str(icmpv6_ducode_map, icmpv6.code));
	  display_string("Code", holder);
	  break;
	  
	default:
	  display("Code", (u_int8_t *) &icmpv6.code, 1, DISP_DEC);
	}
      
      display("Checksum", (u_int8_t *) &icmpv6.checksum, 2, DISP_DEC);
    }
  
  /*
   * Special processing of the rest of the ICMP part
   */

  switch(icmpv6.type)
    {
    case ICMPV6_TYPE_DESTUNREACHABLE:
    case ICMPV6_TYPE_TIMEEXCEEDED:
      {
	/* skip unused 4 bytes */
	if (skip_packet_bytes(pkt, 4) == 0)
	  break;
	/* dump the contained IPv6 header */
	if (get_packet_apparentbytesleft(pkt))
	  dump_ipv6(pkt);
      }
      break;
	
    case ICMPV6_TYPE_PACKETTOOBIG:
      {
	/* next 4 bytes should be the mtu, get them, convert, display */
	if (get_packet_bytes((u_int8_t *) &parameter, pkt, 4) == 0)
	  return;
	parameter = ntohl(parameter);
	display("MTU", (u_int8_t *) &parameter, 4, DISP_DEC);
	
	/* dump the contained IPv6 header */
	if (get_packet_apparentbytesleft(pkt))
	  dump_ipv6(pkt);
      }
      break;

    case ICMPV6_TYPE_PARAMETERPROBLEM:
      {
	/* next 4 bytes should be a pointer, get them, convert, display */
	if (get_packet_bytes((u_int8_t *) &parameter, pkt, 4) == 0)
	  return;
	parameter = ntohl(parameter);
	display("Pointer", (u_int8_t *) &parameter, 4, DISP_DEC);
	
	/* dump the contained IPv6 header */
	if (get_packet_apparentbytesleft(pkt))
	  dump_ipv6(pkt);
      }
      break;

    case ICMPV6_TYPE_ECHOREQUEST:
    case ICMPV6_TYPE_ECHOREPLY:
      {
	u_int16_t ping6_id, ping6_seqno;
	u_int8_t bytes_left;

	/* Next 4 bytes are an id followed by a seqno: get, convert, display */
	if (get_packet_bytes((u_int8_t *) &ping6_id, pkt, 2) == 0)
	  return;
	if (get_packet_bytes((u_int8_t *) &ping6_seqno, pkt, 2) == 0)
	  return;

	/* Conversion */
	ping6_id = ntohs(ping6_id);
	ping6_seqno = ntohs(ping6_seqno);

	/* Display */
	if (my_args->m)
	  {
	    display_minimal((u_int8_t *) &ping6_seqno, 2, DISP_DEC);
	  }
	else
	  {
	    display("Identifier", (u_int8_t *) &ping6_id, 2, DISP_DEC);
	    display("Sequence number", (u_int8_t *) &ping6_seqno, 2, 
		    DISP_DEC);
	  }

	/* Get and display the rest of the data */
	bytes_left = get_packet_apparentbytesleft(pkt);
	if (bytes_left <= 0)
	  break;
	dump_hexbytes("Data", pkt, bytes_left, 0);
	
      }
      break;

    case ICMPV6_TYPE_NEIGHBORSOLICIT:
    case ICMPV6_TYPE_NEIGHBORADVERT:
      {
	u_int32_t reserved;
	u_int32_t r_bit, s_bit;
	u_int8_t  v6addr[IPV6ADDR_SIZE];

	/* Get the reserved bytes */
	if (get_packet_bytes((u_int8_t *) &reserved, pkt, 4) == 0)
	  break;

	/* Conversion */
	reserved = ntohl(reserved);

	/* If the message is an advert, pick out the R and S bits */
	if (icmpv6.type == ICMPV6_TYPE_NEIGHBORADVERT)
	  {
	    r_bit = reserved >> 31;
	    s_bit = (reserved >> 30) & 0x0001;
	    reserved = reserved & 0x3fff;
	  }

	/* Next 16 bytes are an IPv6 address */
	if (get_packet_bytes((u_int8_t *) &v6addr, pkt, IPV6ADDR_SIZE) == 0)
	  break;

	/* Display */
	if (my_args->m)
	  {
	    display_minimal_ipv6((u_int8_t *) &v6addr);
	    display_minimal_string(" ");
	  }
	else
	  {
	    if (icmpv6.type == ICMPV6_TYPE_NEIGHBORADVERT)
	      {
		display("R (router) bit", (u_int8_t *) &r_bit, 4, DISP_DEC);
		display("S (solicited) bit", (u_int8_t *) &s_bit, 4, DISP_DEC);
	      }
	    display("Reserved", (u_int8_t *) &reserved, 4, DISP_DEC);
	    display_ipv6("Target address", (u_int8_t *) &v6addr);
	  }

	/* Parse options */
	dump_icmpv6_options(pkt);
      }
      break;

    case ICMPV6_TYPE_ROUTERSOLICIT:
      {
	u_int32_t reserved;

	/* Get the reserved bytes */
	if (get_packet_bytes((u_int8_t *) &reserved, pkt, 4) == 0)
	  break;

	/* Conversion */
	reserved = ntohl(reserved);

	/* Display */
	if (!my_args->m)
	  display("Reserved", (u_int8_t *) &reserved, 4, DISP_DEC);

	/* Parse options */
	dump_icmpv6_options(pkt);
      }
      break;
      
    case ICMPV6_TYPE_ROUTERADVERT:
      {
	icmpv6_routeradvert_t adv;
	u_int8_t              m_bit, o_bit;
	u_int8_t              reserved;

	/* Get the advert */
	if (get_packet_bytes((u_int8_t *) &adv, pkt, 
			     sizeof(icmpv6_routeradvert_t)) == 0)
	  break;
	
	/* Conversions */
	adv.router_lifetime = ntohs(adv.router_lifetime);
	adv.reachable_time = ntohl(adv.reachable_time);
	adv.retransmit_timer = ntohl(adv.retransmit_timer);
	m_bit = adv.mo_reserved >> 7;
	o_bit = (adv.mo_reserved >> 6) & 0x01;
	reserved = adv.mo_reserved & 0x3f;

	/* Display */
	if (my_args->m) 
	  {
	    display_minimal((u_int8_t *) &adv.router_lifetime, 2, DISP_DEC);
	    display_minimal_string(" ");
	  }
	else
	  {
	    display("Current hop limit", (u_int8_t *) &adv.curr_hop_limit, 1, 
		    DISP_DEC);
	    display("M (mngd config) bit", (u_int8_t *) &m_bit, 1, 
		    DISP_DEC);
	    display("O (other config) bit", (u_int8_t *) &o_bit, 1, DISP_DEC);
	    display("Reserved", (u_int8_t *) &reserved, 1, DISP_DEC);
	    display("Router lifetime", (u_int8_t *) &adv.router_lifetime, 2, 
		    DISP_DEC);
	    display("Reachable time", (u_int8_t *) &adv.reachable_time, 4, 
		    DISP_DEC);
	    display("Retransmit timer", (u_int8_t *) &adv.retransmit_timer, 4, 
		    DISP_DEC);
	  }
	
	/* Parse options */
	dump_icmpv6_options(pkt);

      }
      break;

    default:
      {
	int        bytes_left;
	
	/* Get the remaining number of bytes */
	bytes_left = get_packet_apparentbytesleft(pkt);
	if (bytes_left <= 0)
	  break;
	
	dump_hexbytes("Value", pkt, bytes_left, 1);
      } 
      break;
    }

  /* dump the hex buffer */
  hexbuffer_flush();

}




About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us