On most systems, bit-swap the bytes of an FDDI MAC address. (List of
[obnox/wireshark/wip.git] / ethertype.c
1 /* ethertype.c
2  * Routines for calling the right protocol for the ethertype.
3  * This is called by both packet-eth.c (Ethernet II) and packet-llc.c (SNAP)
4  *
5  * $Id: ethertype.c,v 1.5 1998/10/10 03:32:06 gerald Exp $
6  *
7  * Gilbert Ramirez <gram@verdict.uthscsa.edu>
8  *
9  * Ethereal - Network traffic analyzer
10  * By Gerald Combs <gerald@zing.org>
11  * Copyright 1998 Gerald Combs
12  *
13  * 
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  * 
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  * 
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
27  */
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #ifdef HAVE_SYS_TYPES_H
34 # include <sys/types.h>
35 #endif
36
37 #include <gtk/gtk.h>
38
39 #include <stdio.h>
40
41 #include <pcap.h>
42
43 #include "ethereal.h"
44 #include "packet.h"
45 #include "etypes.h"
46
47 void
48 ethertype(guint16 etype, int offset,
49                 const u_char *pd, frame_data *fd, GtkTree *tree, GtkWidget
50                 *fh_tree)
51 {
52   gchar      etype_str[][10] = {"IP", "ARP", "RARP", "AppleTalk", "AARP"};
53
54   switch (etype) {
55     case ETHERTYPE_IP:
56       if (tree) {
57         add_item_to_tree(fh_tree, offset - 2, 2, "Type: IP (0x%04x)",
58           etype);
59       }
60       dissect_ip(pd, offset, fd, tree);
61       break;
62     case ETHERTYPE_IPv6:
63       if (tree) {
64         add_item_to_tree(fh_tree, offset - 2, 2, "Type: IPv6 (0x%04x)",
65           etype);
66       }
67       dissect_ipv6(pd, offset, fd, tree);
68       break;
69     case ETHERTYPE_ARP:
70       if (tree) {
71         add_item_to_tree(fh_tree, offset - 2, 2,
72           "Type: ARP (0x%04x)", etype);
73       }
74       dissect_arp(pd, offset, fd, tree);
75       break;
76     case ETHERTYPE_REVARP:
77       if (tree) {
78         add_item_to_tree(fh_tree, offset - 2, 2,
79           "Type: RARP (0x%04x)", etype);
80       }
81       dissect_arp(pd, offset, fd, tree);
82       break;
83     case ETHERTYPE_ATALK:
84       if (tree) {
85         add_item_to_tree(fh_tree, offset - 2, 2,
86           "Type: AppleTalk (0x%04x)", etype);
87       }
88       if (fd->win_info[COL_NUM]) { strcpy(fd->win_info[COL_PROTOCOL], etype_str[3]); }
89       break;
90     case ETHERTYPE_AARP:
91       if (tree) {
92         add_item_to_tree(fh_tree, offset - 2, 2,
93           "Type: AARP (0x%04x)", etype);
94       }
95       if (fd->win_info[COL_NUM]) { strcpy(fd->win_info[COL_PROTOCOL], etype_str[4]); }
96       break;
97     case ETHERTYPE_IPX:
98       if (tree) {
99         add_item_to_tree(fh_tree, offset - 2, 2,
100           "Type: Netware IPX/SPX (0x%04x)", etype);
101       }
102       dissect_ipx(pd, offset, fd, tree);
103       break;
104     case ETHERTYPE_VINES:
105       if (tree) {
106         add_item_to_tree(fh_tree, offset - 2, 2,
107           "Type Vines (0x%04x)", etype);
108       }
109       dissect_vines(pd, offset, fd, tree);
110       break;
111     default:
112       if (tree) {
113         add_item_to_tree(fh_tree, offset - 2, 2,
114           "Type: Unknown (0x%04x)", etype);
115                   dissect_data(pd, offset, fd, tree);
116           }
117       if (fd->win_info[COL_NUM]) { sprintf(fd->win_info[COL_PROTOCOL], "0x%04x", etype); }
118       break;
119   }
120  }