removed some gcc warnings (hopefully)
[obnox/wireshark/wip.git] / epan / dissectors / packet-maccontrol.c
1 /* packet-maccontrol.c
2  * Routines for MAC Control ethernet header disassembly
3  *
4  * $Id$
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (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 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 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <glib.h>
30 #include <epan/packet.h>
31 #include "packet-ieee8023.h"
32 #include "packet-llc.h"
33 #include "etypes.h"
34
35 static int proto_macctrl = -1;
36
37 static gint ett_macctrl = -1;
38 static int hf_macctrl_pause = -1;
39 static int hf_macctrl_quanta = -1;
40
41
42 static void
43 dissect_macctrl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
44 {
45   proto_tree *ti;
46   proto_tree *volatile macctrl_tree;
47         guint16 pause;
48         guint16 pause_quanta;
49
50         pause = tvb_get_ntohs(tvb, 0);
51         pause_quanta = tvb_get_ntohs(tvb, 2);
52
53   if (check_col(pinfo->cinfo, COL_PROTOCOL))
54     col_set_str(pinfo->cinfo, COL_PROTOCOL, "CTRL");
55   if (check_col(pinfo->cinfo, COL_INFO))
56     col_clear(pinfo->cinfo, COL_INFO);
57
58   if (pause==1){
59     if (check_col(pinfo->cinfo, COL_INFO)) {
60       col_add_fstr(pinfo->cinfo, COL_INFO, "MAC PAUSE: Quanta %d", pause_quanta);
61     }
62   } 
63
64   macctrl_tree = NULL;
65
66   if (tree) {
67                 ti = proto_tree_add_item(tree, proto_macctrl, tvb, 0, 4, FALSE);
68                 macctrl_tree = proto_item_add_subtree(ti, ett_macctrl);
69                 
70                 proto_tree_add_uint(macctrl_tree, hf_macctrl_pause, tvb, 0, 2, pause);
71     proto_tree_add_uint(macctrl_tree, hf_macctrl_quanta, tvb, 2, 2, pause_quanta);
72         }
73
74 }
75
76
77 void
78 proto_register_macctrl(void)
79 {
80         static hf_register_info hf[] = {
81         { &hf_macctrl_pause, 
82         {  "Pause", "macctrl.pause", FT_UINT16, BASE_HEX,
83            NULL, 0x0, "MAC control Pause", HFILL}},
84
85         { &hf_macctrl_quanta,
86         { "Quanta", "macctrl.quanta", FT_UINT16, BASE_DEC,
87           NULL, 0x0, "MAC control quanta", HFILL }}
88         };
89
90   static gint *ett[] = {
91         &ett_macctrl,
92   };
93   proto_macctrl = proto_register_protocol("MAC Control", "MACC", "macc");
94         proto_register_field_array(proto_macctrl, hf, array_length(hf));
95   proto_register_subtree_array(ett, array_length(ett));
96 }
97
98 void
99 proto_reg_handoff_macctrl(void)
100 {
101   dissector_handle_t macctrl_handle;
102
103   macctrl_handle = create_dissector_handle(dissect_macctrl, proto_macctrl);
104   dissector_add("ethertype", ETHERTYPE_MAC_CONTROL, macctrl_handle);
105 }