Enable Lua tcp tap userdata.
[obnox/wireshark/wip.git] / epan / dissectors / packet-airopeek.c
1 /* packet-airopeek.c
2  *
3  * Routines for the disassembly airopeek encapsulated wireless
4  * traces (tested with frames captured from a Cisco WCS).
5  *
6  * $Id$
7  *
8  * Copyright 2007 Joerg Mayer (see AUTHORS file)
9  *
10  * Wireshark - Network traffic analyzer
11  * By Gerald Combs <gerald@wireshark.org>
12  * Copyright 1998 Gerald Combs
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 /*
30  * TODO: Decode meta information.
31  *       Check on fillup bytes in capture (fcs sometimes wrong)
32  * From:
33  * http://www.cisco.com/univercd/cc/td/doc/product/wireless/pahcont/oweb.pdf
34  * "It will include information on timestamp, signal strength, packet size
35  *  and so on"
36  */
37
38 #ifdef HAVE_CONFIG_H
39 # include "config.h"
40 #endif
41
42 #include <string.h>
43 #include <glib.h>
44 #include <epan/packet.h>
45
46 static int proto_airopeek = -1;
47 static gint hf_airopeek_unknown1 = -1;
48 static gint hf_airopeek_unknown2 = -1;
49 static gint hf_airopeek_unknown3 = -1;
50 static gint hf_airopeek_unknown4 = -1;
51 static gint hf_airopeek_unknown5 = -1;
52 static gint hf_airopeek_unknown6 = -1;
53 static gint hf_airopeek_channel = -1;
54 static gint hf_airopeek_timestamp = -1;
55 static gint ett_airopeek = -1;
56
57 static dissector_handle_t ieee80211_handle;
58
59 static void
60 dissect_airopeek(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
61 {
62   tvbuff_t *next_tvb;
63   proto_tree *airopeek_tree = NULL;
64   proto_item *ti = NULL;
65
66   if (check_col(pinfo->cinfo, COL_PROTOCOL))
67     col_set_str(pinfo->cinfo, COL_PROTOCOL, "AIROPEEK");
68   if (check_col(pinfo->cinfo, COL_INFO))
69     col_clear(pinfo->cinfo, COL_INFO);
70
71   if (tree) {
72     ti = proto_tree_add_item(tree, proto_airopeek, tvb, 0, -1, FALSE);
73     airopeek_tree = proto_item_add_subtree(ti, ett_airopeek);
74
75     proto_tree_add_item(airopeek_tree, hf_airopeek_unknown1, tvb, 0, 2,  FALSE);
76     proto_tree_add_item(airopeek_tree, hf_airopeek_unknown2, tvb, 2, 2,  FALSE);
77     proto_tree_add_item(airopeek_tree, hf_airopeek_unknown3, tvb, 4, 2,  FALSE);
78     proto_tree_add_item(airopeek_tree, hf_airopeek_unknown4, tvb, 6, 5, FALSE);
79     proto_tree_add_item(airopeek_tree, hf_airopeek_timestamp, tvb, 11, 4, FALSE);
80     proto_tree_add_item(airopeek_tree, hf_airopeek_unknown5, tvb, 15, 2, FALSE);
81     proto_tree_add_item(airopeek_tree, hf_airopeek_channel, tvb, 17, 1, FALSE);
82     proto_tree_add_item(airopeek_tree, hf_airopeek_unknown6, tvb, 18, 2, FALSE);
83   }
84   next_tvb = tvb_new_subset(tvb, 20, -1, -1);
85   pinfo->pseudo_header->ieee_802_11.fcs_len = 4;
86   call_dissector(ieee80211_handle, next_tvb, pinfo, tree);
87 }
88
89 void
90 proto_register_airopeek(void)
91 {
92   static hf_register_info hf[] = {
93         { &hf_airopeek_unknown1,
94            { "Unknown1",      "airopeek.unknown1", FT_BYTES, BASE_NONE, NULL,
95              0x0, "", HFILL }},
96
97         { &hf_airopeek_unknown2,
98            { "caplength1",      "airopeek.unknown2", FT_UINT16, BASE_DEC, NULL,
99              0x0, "", HFILL }},
100
101         { &hf_airopeek_unknown3,
102            { "caplength2",      "airopeek.unknown3", FT_UINT16, BASE_DEC, NULL,
103              0x0, "", HFILL }},
104
105         { &hf_airopeek_unknown4,
106            { "Unknown4",      "airopeek.unknown4", FT_BYTES, BASE_NONE, NULL,
107              0x0, "", HFILL }},
108
109         { &hf_airopeek_unknown5,
110            { "Unknown5",      "airopeek.unknown5", FT_BYTES, BASE_NONE, NULL,
111              0x0, "", HFILL }},
112
113         { &hf_airopeek_unknown6,
114            { "Unknown6",      "airopeek.unknown6", FT_BYTES, BASE_NONE, NULL,
115              0x0, "", HFILL }},
116
117         { &hf_airopeek_timestamp,
118            { "Timestamp?",       "airopeek.timestamp", FT_UINT32, BASE_DEC, NULL,
119              0x0, "", HFILL }},
120
121         { &hf_airopeek_channel,
122            { "Channel",       "airopeek.channel", FT_UINT8, BASE_DEC, NULL,
123              0x0, "", HFILL }},
124
125   };
126   static gint *ett[] = {
127     &ett_airopeek,
128   };
129
130   proto_airopeek = proto_register_protocol(
131         "Airopeek encapsulated IEEE 802.11", "AIROPEEK", "airopeek");
132   proto_register_field_array(proto_airopeek, hf, array_length(hf));
133   proto_register_subtree_array(ett, array_length(ett));
134 }
135
136 void
137 proto_reg_handoff_airopeek(void)
138 {
139   dissector_handle_t airopeek_handle;
140
141   ieee80211_handle = find_dissector("wlan_datapad");
142
143   airopeek_handle = create_dissector_handle(dissect_airopeek, proto_airopeek);
144   dissector_add("udp.port", 5000, airopeek_handle);
145 }