packet-airopeek.c
上传用户:aseley
上传日期:2016-01-25
资源大小:16644k
文件大小:4k
源码类别:

网络截获/分析

开发平台:

C/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: packet-airopeek.c 24395 2008-02-19 22:08:11Z jmayer $
  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.  * TODO: Decode meta information.
  30.  *       Check on fillup bytes in capture (fcs sometimes wrong)
  31.  * From:
  32.  * http://www.cisco.com/univercd/cc/td/doc/product/wireless/pahcont/oweb.pdf
  33.  * "It will include information on timestamp, signal strength, packet size
  34.  *  and so on"
  35.  */
  36. #ifdef HAVE_CONFIG_H
  37. # include "config.h"
  38. #endif
  39. #include <string.h>
  40. #include <glib.h>
  41. #include <epan/packet.h>
  42. static int proto_airopeek = -1;
  43. static gint hf_airopeek_unknown1 = -1;
  44. static gint hf_airopeek_unknown2 = -1;
  45. static gint hf_airopeek_unknown3 = -1;
  46. static gint hf_airopeek_unknown4 = -1;
  47. static gint ett_airopeek = -1;
  48. static dissector_handle_t ieee80211_handle;
  49. static void
  50. dissect_airopeek(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  51. {
  52.   tvbuff_t *next_tvb;
  53.   proto_tree *airopeek_tree = NULL;
  54.   proto_item *ti = NULL;
  55.   int offset = 0;
  56.   if (check_col(pinfo->cinfo, COL_PROTOCOL))
  57.     col_set_str(pinfo->cinfo, COL_PROTOCOL, "AIROPEEK");
  58.   if (check_col(pinfo->cinfo, COL_INFO))
  59.     col_clear(pinfo->cinfo, COL_INFO);
  60.   if (tree) {
  61.     ti = proto_tree_add_item(tree, proto_airopeek, tvb, 0, -1, FALSE);
  62.     airopeek_tree = proto_item_add_subtree(ti, ett_airopeek);
  63.   }
  64.   if (tree) {
  65.         proto_tree_add_item(airopeek_tree, hf_airopeek_unknown1, tvb, offset, 2,
  66.                 FALSE);
  67. offset += 2;
  68.         proto_tree_add_item(airopeek_tree, hf_airopeek_unknown2, tvb, offset, 2,
  69.                 FALSE);
  70. offset += 2;
  71.         proto_tree_add_item(airopeek_tree, hf_airopeek_unknown3, tvb, offset, 2,
  72.                 FALSE);
  73. offset += 2;
  74.         proto_tree_add_item(airopeek_tree, hf_airopeek_unknown4, tvb, offset, 14,
  75.                 FALSE);
  76. offset += 14;
  77.   }
  78.   next_tvb = tvb_new_subset(tvb, offset, -1, -1);
  79.   call_dissector(ieee80211_handle, next_tvb, pinfo, tree);
  80. }
  81. void
  82. proto_register_airopeek(void)
  83. {
  84.   static hf_register_info hf[] = {
  85. { &hf_airopeek_unknown1,
  86.            { "Unknown1",      "airopeek.unknown1", FT_BYTES, BASE_NONE, NULL,
  87.              0x0, "", HFILL }},
  88. { &hf_airopeek_unknown2,
  89.            { "caplength1",      "airopeek.unknown2", FT_UINT16, BASE_DEC, NULL,
  90.              0x0, "", HFILL }},
  91. { &hf_airopeek_unknown3,
  92.            { "caplength2",      "airopeek.unknown3", FT_UINT16, BASE_DEC, NULL,
  93.              0x0, "", HFILL }},
  94. { &hf_airopeek_unknown4,
  95.            { "Unknown4",      "airopeek.unknown4", FT_BYTES, BASE_NONE, NULL,
  96.              0x0, "", HFILL }},
  97.   };
  98.   static gint *ett[] = {
  99.     &ett_airopeek,
  100.   };
  101.   proto_airopeek = proto_register_protocol(
  102. "Airopeek encapsulated IEEE 802.11", "AIROPEEK", "airopeek");
  103.   proto_register_field_array(proto_airopeek, hf, array_length(hf));
  104.   proto_register_subtree_array(ett, array_length(ett));
  105. }
  106. void
  107. proto_reg_handoff_airopeek(void)
  108. {
  109.   dissector_handle_t airopeek_handle;
  110.   ieee80211_handle = find_dissector("wlan_datapad");
  111.   airopeek_handle = create_dissector_handle(dissect_airopeek, proto_airopeek);
  112.   dissector_add("udp.port", 5000, airopeek_handle);
  113. }