Put the Makefile back, in the hopes that it'll prevent at least one of
[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.4 1998/11/12 00:06:29 gram 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
32 #include <stdio.h>
33
34 #ifdef HAVE_SYS_TYPES_H
35 # include <sys/types.h>
36 #endif
37
38 #ifdef HAVE_NETINET_IN_H
39 # include <netinet/in.h>
40 #endif
41
42 #include "ethereal.h"
43 #include "packet.h"
44 #include "packet-ipv6.h"
45 #include "etypes.h"
46
47 void
48 dissect_ipv6(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
49   GtkWidget *ipv6_tree, *ti;
50
51   e_ipv6_header ipv6;
52
53   memcpy(&ipv6, (void *) &pd[offset], 8); 
54
55   if (fd->win_info[COL_NUM]) {
56       switch(ipv6.next_header){
57           /*
58           case IP_PROTO_ICMP:
59           case IP_PROTO_IGMP:
60           case IP_PROTO_TCP:
61           case IP_PROTO_UDP:
62           case IP_PROTO_OSPF:
63           */
64           /* Names are set in the associated dissect_* routines */
65           /*    break; */
66          default:
67              strcpy(fd->win_info[COL_PROTOCOL], "IPv6");
68              sprintf(fd->win_info[COL_INFO], "IPv6 support is still under development (%d)", ipv6.next_header);
69       }
70   }
71   if (tree) {
72     /* !!! specify length */
73     ti = add_item_to_tree(GTK_WIDGET(tree), offset, 40,
74       "Internet Protocol Version 6");
75     ipv6_tree = gtk_tree_new();
76     add_subtree(ti, ipv6_tree, ETT_IPv6);
77
78     /* !!! warning: version also contains 4 Bit priority */
79     add_item_to_tree(ipv6_tree, offset,      1, "Version: %d Priority: %d", ipv6.version >> 4 , ipv6.version & 15);
80     add_item_to_tree(ipv6_tree, offset + 6,  1, "Next Header: %d", ipv6.next_header);
81     add_item_to_tree(ipv6_tree, offset + 4,  2, "Payload Length: %d", ntohs(ipv6.payload_length));
82   }
83
84   /* start of the new header (could be a extension header) */
85   offset += 40;
86   switch (ipv6.next_header) {
87       case IP_PROTO_ICMP:
88           dissect_icmp(pd, offset, fd, tree);
89           break;
90       case IP_PROTO_IGMP:
91           dissect_igmp(pd, offset, fd, tree);
92           break;
93       case IP_PROTO_TCP:
94           dissect_tcp(pd, offset, fd, tree);
95           break;
96       case IP_PROTO_UDP:
97           dissect_udp(pd, offset, fd, tree);
98           break;
99       case IP_PROTO_OSPF:
100           dissect_ospf(pd, offset, fd, tree);
101           break;
102       default:
103           dissect_data(pd, offset, fd, tree);
104   }
105 }
106