1 /****************************************************************************
2 ** File: ethertypes.c
3 **
4 ** Author: Mike Borella
5 **
6 ** Comments: Functions to handle ethernet types
7 **
8 ** $Id: ethertypes.c,v 1.6 2001/11/02 00:23:06 mborella Exp $
9 **
10 ** This program is free software; you can redistribute it and/or modify
11 ** it under the terms of the GNU General Public License as published by
12 ** the Free Software Foundation; either version 2 of the License, or
13 ** (at your option) any later version.
14 **
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ** GNU Library General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program; if not, write to the Free Software
22 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 **
24 *****************************************************************************/
25
26 #include "ethertypes.h"
27
28 /*
29 * Ethernet type map
30 */
31
32 strmap_t ethertype_map[] =
33 {
34 { ETHERTYPE_IP, "IP" },
35 { ETHERTYPE_ARP, "ARP" },
36 { ETHERTYPE_RARP, "RARP" },
37 { ETHERTYPE_IPX, "IPX" },
38 { ETHERTYPE_IPV6, "IPV6" },
39 { ETHERTYPE_PPP, "PPP" },
40 { ETHERTYPE_PPPOED, "PPPoEd" },
41 { ETHERTYPE_PPPOES, "PPPoEs" },
42 { ETHERTYPE_PPPHDLC, "PPP with HDLC framing" },
43 { 0, "" }
44 };
45
46 /*----------------------------------------------------------------------------
47 **
48 ** ethertype2func()
49 **
50 ** Map an ethertype to a function that handles that type
51 **
52 **----------------------------------------------------------------------------
53 */
54
ethertype2func(u_int16_t et)55 ethertype_func_t ethertype2func(u_int16_t et)
56 {
57 ethertype_func_t f;
58
59 switch(et)
60 {
61 case ETHERTYPE_IP:
62 f = dump_ip;
63 break;
64
65 case ETHERTYPE_ARP:
66 case ETHERTYPE_RARP:
67 f = dump_arp;
68 break;
69
70 case ETHERTYPE_IPX:
71 f = dump_ipx;
72 break;
73
74 case ETHERTYPE_IPV6:
75 f = dump_ipv6;
76 break;
77
78 case ETHERTYPE_PPP:
79 f = dump_ppp;
80 break;
81
82 case ETHERTYPE_PPPHDLC:
83 f = dump_ppp_hdlc;
84 break;
85
86 case ETHERTYPE_PPPOED:
87 f = dump_pppoed;
88 break;
89
90 case ETHERTYPE_PPPOES:
91 f = dump_pppoes;
92 break;
93
94 default:
95 f = NULL;
96 break;
97 }
98
99 return f;
100 }
101