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

📄 plugins-wimax-wimax_tlv.c

📁 Intel的WIMAX代码,主要是mac层code
💻 C
字号:
plugins/wimax/wimax_tlv.c - Google Code Search这是 Google 取自 
      http://anonsvn.wireshark.org/wireshark/trunk 的 plugins/wimax/wimax_tlv.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
    /* wimax_tlv.c
 * WiMax TLV handling functions
 *
 * 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.
 */

/*************************************************************/
/*   ----------------------- NOTE -------------------------  */
/* There is an identical copy of this file, wimax_tlv.c, in  */
/* both .../plugins/m2m and .../plugins/wimax.  If either    */
/* one needs to be modified, please be sure to copy the file */
/* to the sister directory and check it in there also.       */
/* This prevents having to generate a complicated            */
/* Makefile.nmake in .../plugins/m2m.                        */
/*************************************************************/

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

#include "wimax_tlv.h"

/*************************************************************/
/* init_tlv_info()                                           */
/* retrive the tlv information from specified tvb and offset */
/* parameter:                                                */
/*   this - pointer of a tlv information data structure      */
/* return:                                                   */
/*   0-success                                               */
/*   !=0-the invalid size of the TLV length (failed)         */
/*************************************************************/
gint init_tlv_info(tlv_info_t *this, tvbuff_t *tvb, gint offset)
{
	guint tlv_len;

	/* get TLV type */
	this->type = (guint8)tvb_get_guint8( tvb, offset );
	/* get TLV length */
	tlv_len = (guint)tvb_get_guint8( tvb, (offset + 1) );
	/* set the TLV value offset */
	this->value_offset = 2;
	/* adjust for multiple-byte TLV length */
	if((tlv_len & WIMAX_TLV_EXTENDED_LENGTH_MASK) != 0)
	{	/* multiple bytes TLV length */
		this->length_type = 1;
		/* get the size of the TLV length */
		tlv_len = (tlv_len & WIMAX_TLV_LENGTH_MASK);
		this->size_of_length = tlv_len;
		/* update the TLV value offset */
		this->value_offset += tlv_len;
		switch (tlv_len)
		{
			case 0:
				this->length = 0;  /* no length */
			break;
			case 1:
				this->length = (gint32)tvb_get_guint8( tvb, (offset + 2) ); /* 8 bit */
			break;
			case 2:
				this->length = (gint32)tvb_get_ntohs( tvb, (offset + 2) ); /* 16 bit */
			break;
			case 3:
				this->length = (gint32)tvb_get_ntoh24( tvb, (offset + 2) ); /* 24 bit */
			break;
			case 4:
				this->length = (gint32)tvb_get_ntohl( tvb, (offset + 2) ); /* 32 bit */
			break;
			default:
				/* mark invalid tlv */
				this->valid = 0;
				/* failed, return the invalid size of the tlv length */
				return (gint)tlv_len;
			break;
		}
	}
	else	/* single byte length */
	{
		this->length_type = 0;
		this->size_of_length = 0;
		this->length = (gint32)tlv_len;
	}
	/* mark valid tlv */
	this->valid = 1;
	/* success */
	return 0;
}

/*************************************************************/
/* get_tlv_type()                                            */
/* get the tlv type of the specified tlv information         */
/* parameter:                                                */
/*   this - pointer of a tlv information data structure      */
/* return:                                                   */
/*   >=0 - TLV type                                           */
/*   =-1 - invalid tlv info                                  */
/*************************************************************/
gint get_tlv_type(tlv_info_t *this)
{
	if(this->valid)
		return (gint)this->type;
	return -1;
}

/**************************************************************/
/* get_tlv_size_of_length()                                   */
/* get the size of tlv length of the specified tlv information*/
/* parameter:                                                 */
/*   this - pointer of a tlv information data structure       */
/* return:                                                    */
/*   >=0 - the size of TLV length                              */
/*   =-1 - invalid tlv info                                   */
/**************************************************************/
gint get_tlv_size_of_length(tlv_info_t *this)
{
	if(this->valid)
		return (gint)this->size_of_length;
	return -1;
}

/*************************************************************/
/* get_tlv_length()                                          */
/* get the tlv length of the specified tlv information       */
/* parameter:                                                */
/*   this - pointer of a tlv information data structure      */
/* return:                                                   */
/*   >=0 - TLV length                                         */
/*   =-1 - invalid tlv info                                  */
/*************************************************************/
gint32 get_tlv_length(tlv_info_t *this)
{
	if(this->valid)
		return (gint32)this->length;
	return -1;
}

/*************************************************************/
/* get_tlv_value_offset()                                    */
/* get the tlv value offset of the specified tlv information */
/* parameter:                                                */
/*   this - pointer of a tlv information data structure      */
/* return:                                                   */
/*   >0 - TLV value offset in byte                           */
/*   =-1 - invalid tlv info                                  */
/*************************************************************/
gint get_tlv_value_offset(tlv_info_t *this)
{
	if(this->valid)
		return (gint)this->value_offset;
	return -1;
}

/*************************************************************/
/* get_tlv_length_type()                                     */
/* get the tlv length type of the specified tlv information  */
/* parameter:                                                */
/*   this - pointer of a tlv information data structure      */
/* return:                                                   */
/*   0 - single byte TLV length                              */
/*   1 - multiple bytes TLV length                           */
/*************************************************************/
gint get_tlv_length_type(tlv_info_t *this)
{
	if(this->valid)
		return (gint)this->length_type;
	return -1;
}



      取自 
      http://anonsvn.wireshark.org/wireshark/trunk 的 plugins/wimax/wimax_tlv.c - 
      LGPL - C


⌨️ 快捷键说明

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