* Added preference file saves and reads.
[obnox/wireshark/wip.git] / packet-ipv6.c
1 /* packet-ipv6.c
2  * Routines for IPv6 packet disassembly 
3  *
4  * $Id: packet-ipv6.c,v 1.3 1998/09/27 22:12:30 gerald Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@zing.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * 
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.
15  * 
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.
20  * 
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.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <gtk/gtk.h>
31 #include <pcap.h>
32
33 #include <stdio.h>
34
35 #ifdef HAVE_SYS_TYPES_H
36 # include <sys/types.h>
37 #endif
38
39 #ifdef HAVE_NETINET_IN_H
40 # include <netinet/in.h>
41 #endif
42
43 #include "ethereal.h"
44 #include "packet.h"
45 #include "packet-ipv6.h"
46 #include "etypes.h"
47
48 void
49 dissect_ipv6(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
50   GtkWidget *ipv6_tree, *ti;
51
52   e_ipv6_header ipv6;
53
54   memcpy(&ipv6, (void *) &pd[offset], 8); 
55
56   if (fd->win_info[COL_NUM]) {
57       switch(ipv6.next_header){
58           /*
59           case IP_PROTO_ICMP:
60           case IP_PROTO_IGMP:
61           case IP_PROTO_TCP:
62           case IP_PROTO_UDP:
63           case IP_PROTO_OSPF:
64           */
65           /* Names are set in the associated dissect_* routines */
66           /*    break; */
67          default:
68              strcpy(fd->win_info[COL_PROTOCOL], "IPv6");
69              sprintf(fd->win_info[COL_INFO], "IPv6 support is still under development (%d)", ipv6.next_header);
70       }
71   }
72   if (tree) {
73     /* !!! specify length */
74     ti = add_item_to_tree(GTK_WIDGET(tree), offset, 40,
75       "Internet Protocol Version 6");
76     ipv6_tree = gtk_tree_new();
77     add_subtree(ti, ipv6_tree, ETT_IPv6);
78
79     /* !!! warning: version also contains 4 Bit priority */
80     add_item_to_tree(ipv6_tree, offset,      1, "Version: %d Priority: %d", ipv6.version >> 4 , ipv6.version & 15);
81     add_item_to_tree(ipv6_tree, offset + 6,  1, "Next Header: %d", ipv6.next_header);
82     add_item_to_tree(ipv6_tree, offset + 4,  2, "Payload Length: %d", ntohs(ipv6.payload_length));
83   }
84
85   /* start of the new header (could be a extension header) */
86   offset += 40;
87   switch (ipv6.next_header) {
88       case IP_PROTO_ICMP:
89           dissect_icmp(pd, offset, fd, tree);
90           break;
91       case IP_PROTO_IGMP:
92           dissect_igmp(pd, offset, fd, tree);
93           break;
94       case IP_PROTO_TCP:
95           dissect_tcp(pd, offset, fd, tree);
96           break;
97       case IP_PROTO_UDP:
98           dissect_udp(pd, offset, fd, tree);
99           break;
100       case IP_PROTO_OSPF:
101           dissect_ospf(pd, offset, fd, tree);
102           break;
103       default:
104           dissect_data(pd, offset, fd, tree);
105   }
106 }
107