⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plugins-wimax-mac_hd_generic_decoder.c

📁 Intel的WIMAX代码,主要是mac层code
💻 C
📖 第 1 页 / 共 5 页
字号:
plugins/wimax/mac_hd_generic_decoder.c - Google Code Search这是 Google 取自 
      http://anonsvn.wireshark.org/wireshark/trunk 的 
      plugins/wimax/mac_hd_generic_decoder.c 缓存副本

      Google 和网页作者无关,不对网页的内容负责。



http://anonsvn.wireshark.org/wireshark/trunk/plugins/wimax/
          AUTHORS
COPYING
ChangeLog
Makefile.am
Makefile.common
Makefile.nmake
README.wimax
crc.c
crc.h
crc_data.c
mac_hd_generic_decoder.c
mac_hd_type1_decoder.c
mac_hd_type2_decoder.c
mac_mgmt_msg_decoder.c
moduleinfo.h
moduleinfo.nmake
msg_aas_beam.c
msg_aas_fbck.c
msg_arq.c
msg_clk_cmp.c
msg_dcd.c
msg_dlmap.c
msg_dreg.c
msg_dsa.c
msg_dsc.c
msg_dsd.c
msg_dsx_rvd.c
msg_fpc.c
msg_pkm.c
msg_pmc.c
msg_prc_lt_ctrl.c
msg_reg_req.c
msg_reg_rsp.c
msg_rep.c
msg_res_cmd.c
msg_rng_req.c
msg_rng_rsp.c
msg_sbc.c
msg_ucd.c
msg_ulmap.c
packet-wmx.c
plugin.rc.in
wimax_bits.h
wimax_cdma_code_decoder.c
wimax_compact_dlmap_ie_decoder.c
wimax_compact_ulmap_ie_decoder.c
wimax_fch_decoder.c
wimax_ffb_decoder.c
wimax_hack_decoder.c
wimax_harq_map_decoder.c
wimax_mac.h
wimax_pdu_decoder.c
wimax_phy_attributes_decoder.c
wimax_tlv.c
wimax_tlv.h
wimax_utils.c
wimax_utils.h
    /* mac_hd_generic_decoder.c
 * WiMax Generic MAC Header decoder
 *
 * Copyright (c) 2007 by Intel Corporation.
 *
 * Author: Lu Pan <lu.pan@intel.com>
 *
 * $Id$
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1999 Gerald Combs
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

/* TODO:  Add FT_UINT24 and FT_INT24 cases to gtk_widget_get_toplevel()
 * to prevent having to make all the changes from BASE_DEC to BASE_HEX
 * made to this file today: 10/20/06.
 */

/* Include files */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

/*
#define DEBUG
*/

#include "moduleinfo.h"

#include <string.h>
#include <glib.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/address.h>
#include <epan/reassemble.h>
#include "crc.h"

extern gint proto_wimax;

extern gint seen_a_service_type;
extern gboolean first_gmh;			/* defined in wimax_pdu_decoder.c */
guint get_service_type( void ); 		/* defined in wimax_utils.c */

extern gint8 arq_enabled;                      /* declared in packet-wmx.c */
extern gint  scheduling_service_type;          /* declared in packet-wmx.c */
extern gint  mac_sdu_length;                   /* declared in packet-wmx.c */

extern address bs_address;			/* declared in packet-wmx.c */
extern guint max_logical_bands;			/* declared in wimax_compact_dlmap_ie_decoder.c */
extern gboolean is_down_link(address *src_address);/* declared in packet-wmx.c */
extern void proto_register_mac_mgmt_msg(void); /* defined in macmgmtmsgdecoder.c */
extern void init_wimax_globals();		/* defined in msg_ulmap.c */

extern void dissect_mac_mgmt_msg_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);

/* global variables */
gboolean include_cor2_changes = FALSE;

/* Well-known CIDs */
guint cid_initial_ranging  = 0x0000;
guint global_cid_max_basic = 320;
guint cid_max_primary      = 640;
guint cid_aas_ranging      = 0xFeFF;
guint cid_normal_multicast = 0xFFFa;
guint cid_sleep_multicast  = 0xFFFb;
guint cid_idle_multicast   = 0xFFFc;
guint cid_frag_broadcast   = 0xFFFd;
guint cid_padding          = 0xFFFe;
guint cid_broadcast        = 0xFFFF;

/* Maximum number of CID's */
#define MAX_CID 64

/* forward reference */
void dissect_mac_header_generic_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
static gint extended_subheader_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
static gint arq_feedback_payload_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *parent_item);

/* Static variables */
static GHashTable *payload_frag_table = NULL;

gint proto_mac_header_generic_decoder = -1;
static gint ett_mac_header_generic_decoder = -1;
static gint ett_mac_subheader_decoder = -1;
static gint ett_mac_mesh_subheader_decoder = -1;
static gint ett_mac_frag_subheader_decoder = -1;
static gint ett_mac_grant_mgmt_subheader_decoder = -1;
static gint ett_mac_pkt_subheader_decoder = -1;
static gint ett_mac_fast_fb_subheader_decoder = -1;
static gint ett_mac_ext_subheader_decoder = -1;
static gint ett_mac_ext_subheader_dl_decoder = -1;
static gint ett_mac_ext_subheader_ul_decoder = -1;
static gint ett_mac_arq_fb_payload_decoder = -1;
static gint ett_mac_data_pdu_decoder = -1;
static gint hf_mac_header_generic_value_bytes = -1;

static guint frag_type, frag_len;
static guint extended_type, arq_fb_payload, seq_number;

static guint cid_adjust[MAX_CID];  /* Must not start with 0 */
static guint cid_vernier[MAX_CID];
static guint cid_adj_array_size = 0;
static guint *cid_adj_array = NULL;
static guint8 *frag_num_array = NULL;

static address save_src;
static address save_dst;

/* Setup protocol subtree array */
static gint *ett[] =
{
	&ett_mac_header_generic_decoder,
	&ett_mac_subheader_decoder,
	&ett_mac_mesh_subheader_decoder,
	&ett_mac_frag_subheader_decoder,
	&ett_mac_grant_mgmt_subheader_decoder,
	&ett_mac_pkt_subheader_decoder,
	&ett_mac_fast_fb_subheader_decoder,
	&ett_mac_ext_subheader_decoder,
	&ett_mac_ext_subheader_dl_decoder,
	&ett_mac_ext_subheader_ul_decoder,
	&ett_mac_arq_fb_payload_decoder,
	&ett_mac_data_pdu_decoder,
};

#define WIMAX_MAC_HEADER_SIZE      6
#define IP_HEADER_BYTE 0x45

#define EXTENDED_SUB_HEADER_RSV_MASK   0x80
#define EXTENDED_SUB_HEADER_TYPE_MASK  0x7F

/* WIMAX GENERIC MAC HEADER FIELDS (figure 19) */
/* 1st to 3rd bytes */
#define WIMAX_MAC_HEADER_GENERIC_HT           0x800000
#define WIMAX_MAC_HEADER_GENERIC_EC           0x400000
#define WIMAX_MAC_HEADER_GENERIC_TYPE_5       0x200000
#define WIMAX_MAC_HEADER_GENERIC_TYPE_4       0x100000
#define WIMAX_MAC_HEADER_GENERIC_TYPE_3       0x080000
#define WIMAX_MAC_HEADER_GENERIC_TYPE_2       0x040000
#define WIMAX_MAC_HEADER_GENERIC_TYPE_1       0x020000
#define WIMAX_MAC_HEADER_GENERIC_TYPE_0       0x010000
#define WIMAX_MAC_HEADER_GENERIC_ESF          0x008000
#define WIMAX_MAC_HEADER_GENERIC_CI           0x004000
#define WIMAX_MAC_HEADER_GENERIC_EKS          0x003000
#define WIMAX_MAC_HEADER_GENERIC_RSV          0x000800
#define WIMAX_MAC_HEADER_GENERIC_LEN          0x0007FF

/* WIMAX GENERIC MAC HEADER 1st byte masks */
#define WIMAX_MAC_HEADER_GENERIC_HT_MASK     0x80
#define WIMAX_MAC_HEADER_GENERIC_EC_MASK     0x40
#define WIMAX_MAC_HEADER_GENERIC_TYPE_MASK   0x3F
/* WiMax Generic MAC Header Sub Type Masks */
#define GENERIC_SUB_TYPE_0         0x01
#define GENERIC_SUB_TYPE_1         0x02
#define GENERIC_SUB_TYPE_2         0x04
#define GENERIC_SUB_TYPE_3         0x08
#define GENERIC_SUB_TYPE_4         0x10
#define GENERIC_SUB_TYPE_5         0x20

/* WIMAX GENERIC MAC HEADER 2nd byte masks */
#define WIMAX_MAC_HEADER_GENERIC_ESF_MASK    0x80
#define WIMAX_MAC_HEADER_GENERIC_CI_MASK     0x40
#define WIMAX_MAC_HEADER_GENERIC_EKS_MASK    0x30
#define WIMAX_MAC_HEADER_GENERIC_LEN_MASK    0x07

static int hf_mac_header_generic_ht = -1;
static int hf_mac_header_generic_ec = -1;
static int hf_mac_header_generic_type_0 = -1;
static int hf_mac_header_generic_type_1 = -1;
static int hf_mac_header_generic_type_2 = -1;
static int hf_mac_header_generic_type_3 = -1;
static int hf_mac_header_generic_type_4 = -1;
static int hf_mac_header_generic_type_5 = -1;
static int hf_mac_header_generic_esf = -1;
static int hf_mac_header_generic_ci = -1;
static int hf_mac_header_generic_eks = -1;
static int hf_mac_header_generic_rsv = -1;
static int hf_mac_header_generic_len = -1;
static int hf_mac_header_generic_cid = -1;
static int hf_mac_header_generic_hcs = -1;
static int hf_mac_header_generic_crc = -1;

/* MAC Header types */
static const value_string ht_msgs[] =
{
	{ 0, "Generic" },
	{ 1, "Signaling" },
	{ 0,  NULL}
};

/* Encryption Controls */
static const value_string ec_msgs[] =
{
	{ 0, "Not encrypted" },
	{ 1, "Encrypted" },
	{ 0,  NULL}
};

/* ESF messages */
static const value_string esf_msgs[] =
{
	{ 0, "Extended subheader is absent" },
	{ 1, "Extended subheader is present" },
	{ 0,  NULL}
};

/* CRC Indicator messages */
static const value_string ci_msgs[] =
{
	{ 0, "No CRC is included" },
	{ 1, "CRC is included" },
	{ 0,  NULL}
};

/* Sub-Type message 0 */
static const value_string type_msg0[] =
{
	{ 0, "Fast-feedback allocation subheader(DL)/Grant management subheader(UL) is absent" },
	{ 1, "Fast-feedback allocation subheader(DL)/Grant management subheader(UL) is present" },
	{ 0,  NULL}
};

/* Sub-Type message 1 */
static const value_string type_msg1[] =
{
	{ 0, "Packing subheader is absent" },
	{ 1, "Packing Subheader is present" },
	{ 0,  NULL}
};

/* Sub-Type message 2 */
static const value_string type_msg2[] =
{
	{ 0, "Fragmentation subheader is absent" },
	{ 1, "Fragmentation subheader is present" },
	{ 0,  NULL}
};

/* Sub-Type message 3 */
static const value_string type_msg3[] =
{
	{ 0, "The subheader is not extended" },
	{ 1, "The subheader is extended" },
	{ 0,  NULL}
};

/* Sub-Type message 4 */
static const value_string type_msg4[] =
{
	{ 0, "ARQ feedback payload is absent" },
	{ 1, "ARQ feedback payload is present" },
	{ 0,  NULL}
};

/* Sub-Type message 5 */
static const value_string type_msg5[] =
{
	{ 0, "Mesh subheader is absent" },
	{ 1, "Mesh subheader is present" },
	{ 0,  NULL}
};

/* Fast-Feedback Feedback Types */
static const value_string fast_fb_types[] =
{
	{ 0, "Fast DL measurement" },
	{ 1, "Fast MIMO Feedback, Antenna #0" },
	{ 2, "Fast MIMO Feedback, Antenna #1" },
	{ 3, "MIMO Mode and Permutation Mode Feedback" },
	{ 0,  NULL}
};

/* Generic MAC header display */
static hf_register_info hf[] =
{
	{
		&hf_mac_header_generic_value_bytes,
		{
			"Values", "wimax.genericValueBytes",
			FT_BYTES, BASE_HEX, NULL, 0x0,
			"", HFILL
		}
	},
	{
		&hf_mac_header_generic_ht,
		{
			"MAC Header Type", "wimax.genericHt",
			FT_UINT24, BASE_HEX, VALS(ht_msgs), WIMAX_MAC_HEADER_GENERIC_HT,
			"", HFILL
		}
	},
	{
		&hf_mac_header_generic_ec,
		{
			"MAC Encryption Control", "wimax.genericEc",
			FT_UINT24, BASE_HEX, VALS(ec_msgs), WIMAX_MAC_HEADER_GENERIC_EC,
			"", HFILL
		}
	},
	{
		&hf_mac_header_generic_type_0,
		{
			"MAC Sub-type Bit 0", "wimax.genericType0",
			FT_UINT24, BASE_HEX, VALS(type_msg0), WIMAX_MAC_HEADER_GENERIC_TYPE_0,
			"", HFILL
		}
	},
	{
		&hf_mac_header_generic_type_1,
		{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -