diff options
author | Gerald Combs <gerald@wireshark.org> | 2007-05-25 23:40:42 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2007-05-25 23:40:42 +0000 |
commit | a491fec183044f6065b8d92a3775f5130049b636 (patch) | |
tree | 3f899da6a2bb6dead6dbfa2392764a88ac26faa6 /plugins/m2m | |
parent | 1e7c1bc0369f0c962ed73e8e34fa5ba7fa1a6c3d (diff) | |
download | wireshark-a491fec183044f6065b8d92a3775f5130049b636.tar.gz |
From Mike Harvey: Support for WiMAX and the WiMAX M2M encapsulation protocol.
Add support for WiMAX and M2M to various makefiles and installer files. Add
basic support for M2M to randpkt.
svn path=/trunk/; revision=21945
Diffstat (limited to 'plugins/m2m')
-rw-r--r-- | plugins/m2m/AUTHORS | 6 | ||||
-rw-r--r-- | plugins/m2m/COPYING | 340 | ||||
-rw-r--r-- | plugins/m2m/ChangeLog | 3 | ||||
-rw-r--r-- | plugins/m2m/Makefile.am | 47 | ||||
-rw-r--r-- | plugins/m2m/Makefile.nmake | 30 | ||||
-rw-r--r-- | plugins/m2m/moduleinfo.h | 52 | ||||
-rw-r--r-- | plugins/m2m/packet-m2m.c | 888 | ||||
-rw-r--r-- | plugins/m2m/wimax_tlv.c | 188 | ||||
-rw-r--r-- | plugins/m2m/wmxtypes.h | 36 |
9 files changed, 1590 insertions, 0 deletions
diff --git a/plugins/m2m/AUTHORS b/plugins/m2m/AUTHORS new file mode 100644 index 0000000000..8719f3c817 --- /dev/null +++ b/plugins/m2m/AUTHORS @@ -0,0 +1,6 @@ +Authors: +Lu Pan <lu.pan@intel.com> +Michael Harvey <michael.harvey@intel.com> +John Underwood <junderx@yahoo.com> +Steve Lo <steve.lo@intel.com> + diff --git a/plugins/m2m/COPYING b/plugins/m2m/COPYING new file mode 100644 index 0000000000..d60c31a97a --- /dev/null +++ b/plugins/m2m/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/plugins/m2m/ChangeLog b/plugins/m2m/ChangeLog new file mode 100644 index 0000000000..71f656b224 --- /dev/null +++ b/plugins/m2m/ChangeLog @@ -0,0 +1,3 @@ +Splited the code into two plugins: wimax and m2m. +wimax contains all the WiMax Protocol related dissectors +m2m contains only the WiMax MAC to MAC Protocol TLV packet dissector. diff --git a/plugins/m2m/Makefile.am b/plugins/m2m/Makefile.am new file mode 100644 index 0000000000..374214cb8d --- /dev/null +++ b/plugins/m2m/Makefile.am @@ -0,0 +1,47 @@ +# Makefile.am +# Automake file for Wireshark/M2M +# +# $Id$ +# +# Wireshark - Network traffic analyzer +# By Gerald Combs <gerald@wireshark.org> +# Copyright 1998 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. +# + +INCLUDES = -I$(top_srcdir) -I../wimax + +plugindir = @plugindir@ + +plugin_LTLIBRARIES = m2m.la +m2m_la_SOURCES = packet-m2m.c wimax_tlv.c moduleinfo.h +m2m_la_LDFLAGS = -module -avoid-version +m2m_la_LIBADD = @PLUGIN_LIBS@ + +# Libs must be cleared, or else libtool won't create a shared module. +# If your module needs to be linked against any particular libraries, +# add them here. +LIBS = + +CLEANFILES = \ + m2m \ + *~ + +MAINTAINERCLEANFILES = \ + Makefile.in + +EXTRA_DIST = \ + Makefile.nmake diff --git a/plugins/m2m/Makefile.nmake b/plugins/m2m/Makefile.nmake new file mode 100644 index 0000000000..dabd2d2f8a --- /dev/null +++ b/plugins/m2m/Makefile.nmake @@ -0,0 +1,30 @@ +# +# + +include ..\..\config.nmake + +############### no need to modify below this line ######### + +CFLAGS=/DHAVE_CONFIG_H /I../.. /I../wimax /I../../wiretap $(GLIB_CFLAGS) \ + /I$(PCAP_DIR)\include -D_U_="" $(LOCAL_CFLAGS) + +#LDFLAGS = /NOLOGO /INCREMENTAL:no /MACHINE:I386 $(LOCAL_LDFLAGS) + +!IFDEF ENABLE_LIBWIRESHARK +LINK_PLUGIN_WITH=..\..\epan\libwireshark.lib +CFLAGS=/DHAVE_WIN32_LIBWIRESHARK_LIB /D_NEED_VAR_IMPORT_ $(CFLAGS) + +OBJECTS=packet-m2m.obj wimax_tlv.obj + +m2m.dll m2m.exp m2m.lib : $(OBJECTS) $(LINK_PLUGIN_WITH) + link -dll /out:m2m.dll $(LDFLAGS) $(OBJECTS) $(LINK_PLUGIN_WITH) \ + $(GLIB_LIBS) + +!ENDIF + +clean: + rm -f $(OBJECTS) m2m.dll m2m.exp m2m.lib $(PDB_FILE) + +distclean: clean + +maintainer-clean: distclean diff --git a/plugins/m2m/moduleinfo.h b/plugins/m2m/moduleinfo.h new file mode 100644 index 0000000000..39b5e25d04 --- /dev/null +++ b/plugins/m2m/moduleinfo.h @@ -0,0 +1,52 @@ +/* moduleinfo.h + * + * Copyright (c) 2007 by Intel Corporation. + * + * Author: Lu Pan + * + * $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. + */ + +/* Included *after* config.h, in order to re-define these macros */ + +#ifdef PACKAGE +#undef PACKAGE +#endif + +/* Name of package */ +#define PACKAGE "m2m" + + +#ifdef VERSION +#undef VERSION +#endif + +/* Version number of package */ + +#define stringiz1(x) #x +#define stringize(x) stringiz1(x) + +#ifndef BUILD_NUMBER +#define BUILD_NUMBER 0 +#endif + +#define VERSION "1.1." stringize(BUILD_NUMBER) + diff --git a/plugins/m2m/packet-m2m.c b/plugins/m2m/packet-m2m.c new file mode 100644 index 0000000000..41bf1884d1 --- /dev/null +++ b/plugins/m2m/packet-m2m.c @@ -0,0 +1,888 @@ +/* packet-m2m.c + * Routines for WiMax MAC to MAC TLV packet disassembly + * + * 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. + */ + +/* Include files */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <string.h> +#include "moduleinfo.h" + +#include <string.h> +#include <gmodule.h> +#include <epan/packet.h> +#include <epan/prefs.h> +#include <epan/reassemble.h> +#include <plugins/wimax/wimax_tlv.h> +#include "wmxtypes.h" + +/* Define version if we are not building wireshark statically */ +#ifndef ENABLE_STATIC +G_MODULE_EXPORT const gchar version[] = VERSION; +#endif + +/* forward reference */ +void proto_register_m2m(); +void proto_reg_handoff_m2m(void); +static void dissect_m2m(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); +static void fch_burst_decoder(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, packet_info *pinfo); +static void cdma_code_decoder(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, packet_info *pinfo); +static void pdu_burst_decoder(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, packet_info *pinfo, gint burst_number, gint frag_type, gint frag_number); +static void fast_feedback_burst_decoder(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, packet_info *pinfo); +static void harq_ack_bursts_decoder(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, packet_info *pinfo); +static void physical_attributes_decoder(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, packet_info *pinfo); +static void extended_tlv_decoder(packet_info *pinfo); +void proto_tree_add_tlv(tlv_info_t *this, tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, gint hf); + +/* Global variables */ +gint sequence_number = 0; +GHashTable *pdu_frag_table = NULL; +guint g_frame_number = 0; + +/* Local Variables */ +static gint proto_m2m = -1; +static dissector_handle_t m2m_handle = NULL; +static dissector_handle_t wimax_fch_burst_handle = NULL; +static dissector_handle_t wimax_cdma_code_burst_handle = NULL; +static dissector_handle_t wimax_pdu_burst_handle = NULL; +static dissector_handle_t wimax_ffb_burst_handle = NULL; +static dissector_handle_t wimax_hack_burst_handle = NULL; +static dissector_handle_t wimax_phy_attributes_burst_handle = NULL; + +static gint ett_m2m = -1; +static gint ett_m2m_tlv = -1; +static gint ett_m2m_fch = -1; +static gint ett_m2m_cdma = -1; +static gint ett_m2m_ffb = -1; + +/* Setup protocol subtree array */ +static gint *ett[] = +{ + &ett_m2m, + &ett_m2m_tlv, + &ett_m2m_fch, + &ett_m2m_cdma, + &ett_m2m_ffb, +}; + +/* TLV types (rev:0.2) */ +#define TLV_PROTO_VER 1 +#define TLV_FRAME_NUM 2 +#define TLV_BURST_NUM 3 +#define TLV_FRAG_TYPE 4 +#define TLV_FRAG_NUM 5 +#define TLV_CDMA_CODE 7 +#define TLV_FCH_BURST 8 +#define TLV_PDU_BURST 9 +#define TLV_FAST_FB 10 +#define TLV_CRC16_STATUS 11 +#define TLV_BURST_POWER 12 +#define TLV_BURST_CINR 13 +#define TLV_PREAMBLE 14 +#define TLV_HARQ_ACK_BURST 15 +#define TLV_PHY_ATTRIBUTES 16 +#define TLV_EXTENDED_TLV 255 + +/* TLV names */ +static const value_string tlv_name[] = +{ + { TLV_PROTO_VER, "Protocol Version" }, + { TLV_FRAME_NUM, "Frame Number" }, + { TLV_BURST_NUM, "Burst Number" }, + { TLV_FRAG_TYPE, "Fragment Type" }, + { TLV_FRAG_NUM, "Fragment Number" }, + { TLV_CDMA_CODE, "CDMA Attribute" }, + { TLV_FCH_BURST, "FCH Burst" }, + { TLV_PDU_BURST, "PDU Burst" }, + { TLV_FAST_FB, "Fast Feedback Burst" }, + { TLV_CRC16_STATUS, "CRC16 Status" }, + { TLV_BURST_POWER, " Burst Power" }, + { TLV_BURST_CINR, "Burst CINR" }, + { TLV_PREAMBLE, "Preamble" }, + { TLV_HARQ_ACK_BURST, "HARQ ACK Bursts" }, + { TLV_PHY_ATTRIBUTES, "PDU Burst Physical Attributes" }, + { TLV_EXTENDED_TLV, "Extended TLV" }, + { 0, NULL } +}; + +/* TLV Fragment types */ +#define TLV_NO_FRAG 0 +#define TLV_FIRST_FRAG 1 +#define TLV_MIDDLE_FRAG 2 +#define TLV_LAST_FRAG 3 + +/* TLV Fragment Type names */ +static const value_string tlv_frag_type_name[] = +{ + { TLV_NO_FRAG, "No TLV Fragment" }, + { TLV_FIRST_FRAG, "First TLV Fragment" }, + { TLV_MIDDLE_FRAG, "Middle TLV Fragment" }, + { TLV_LAST_FRAG, "Last TLV Fragment" }, + { 0, NULL } +}; + +/* TLV CRC16 Status */ +static const value_string tlv_crc16_status[] = +{ + { 0, "No CRC-16 in burst" }, + { 1, "Good CRC-16 in burst" }, + { 2, "Bad CRC-16 in burst" }, + { 0, NULL } +}; + +static gint hf_m2m_sequence_number = -1; +static gint hf_m2m_frame_number = -1; +static gint hf_m2m_tlv_count = -1; + +/* M2M TLV display */ +static hf_register_info hf[] = +{ + { + &hf_m2m_sequence_number, + { + "Packet Sequence Number", "m2m.seq_number", + FT_UINT16, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_frame_number, + { + "Value", "m2m.frame_number", + FT_UINT24, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_tlv_count, + { + "Number of TLVs in the packet", "m2m.tlv_count", + FT_UINT16, BASE_DEC, NULL, 0x0, + "", HFILL + } + } +}; + +static gint hf_m2m_type = -1; +static gint hf_m2m_len = -1; +static gint hf_m2m_len_size = -1; +static gint hf_m2m_value_bytes = -1; +static gint hf_wimax_invalid_tlv = -1; +static gint hf_m2m_value_protocol_vers_uint8 = -1; +static gint hf_m2m_value_burst_num_uint8 = -1; +static gint hf_m2m_value_frag_type_uint8 = -1; +static gint hf_m2m_value_frag_num_uint8 = -1; +static gint hf_m2m_value_pdu_burst = -1; +static gint hf_m2m_value_fast_fb = -1; +static gint hf_m2m_value_fch_burst_uint24 = -1; +static gint hf_m2m_value_cdma_code_uint24 = -1; +static gint hf_m2m_value_crc16_status_uint8 = -1; +static gint hf_m2m_value_burst_power_uint16 = -1; +static gint hf_m2m_value_burst_cinr_uint16 = -1; +static gint hf_m2m_value_preamble_uint16 = -1; +static gint hf_m2m_value_harq_ack_burst_bytes = -1; +static gint hf_m2m_phy_attributes = -1; + +/* WiMax TLV display */ +static hf_register_info hf_tlv[] = +{ + { + &hf_m2m_type, + { + "Type", "m2m.tlv_type", + FT_UINT8, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_len, + { + "Length", "m2m.tlv_len", + FT_UINT8, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_len_size, + { + "Length Size", "m2m.tlv_len_size", + FT_UINT8, BASE_HEX, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_bytes, + { + "Value (hex)", "m2m.multibyte_tlv_value", + FT_BYTES, BASE_HEX, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_protocol_vers_uint8, + { + "Value", "m2m.protocol_vers_tlv_value", + FT_UINT8, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_burst_num_uint8, + { + "Value", "m2m.burst_num_tlv_value", + FT_UINT8, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_frag_type_uint8, + { + "Value", "m2m.frag_type_tlv_value", + FT_UINT8, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_frag_num_uint8, + { + "Value", "m2m.frag_num_tlv_value", + FT_UINT8, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_pdu_burst, + { + "Value (hex)", "m2m.pdu_burst_tlv_value", + FT_BYTES, BASE_HEX, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_fast_fb, + { + "Value (hex)", "m2m.fast_fb_tlv_value", + FT_BYTES, BASE_HEX, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_fch_burst_uint24, + { + "Value", "m2m.fch_burst_tlv_value", + FT_BYTES, BASE_HEX, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_cdma_code_uint24, + { + "Value", "m2m.cdma_code_tlv_value", + FT_UINT24, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_crc16_status_uint8, + { + "Value", "m2m.crc16_status_tlv_value", + FT_UINT8, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_burst_power_uint16, + { + "Value", "m2m.burst_power_tlv_value", + FT_UINT16, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_burst_cinr_uint16, + { + "Value", "m2m.burst_cinr_tlv_value", + FT_UINT16, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_preamble_uint16, + { + "Value", "m2m.preamble_tlv_value", + FT_UINT16, BASE_DEC, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_value_harq_ack_burst_bytes, + { + "Value (hex)", "m2m.harq_ack_burst_tlv_value", + FT_BYTES, BASE_HEX, NULL, 0x0, + "", HFILL + } + }, + { + &hf_m2m_phy_attributes, + { + "Value (hex)", "m2m.phy_attributes", + FT_BYTES, BASE_HEX, NULL, 0x0, + "", HFILL + } + }, + { + &hf_wimax_invalid_tlv, + { + "Invalid TLV (hex)", "m2m.invalid_tlv", + FT_BYTES, BASE_HEX, NULL, 0x0, + "", HFILL + } + } +}; + +#ifndef ENABLE_STATIC +/* for plugins only */ +G_MODULE_EXPORT void plugin_register(void) +{ + /* register the new protocol, protocol fields, and subtrees */ + if (proto_m2m == -1) + { /* execute protocol initialization only once */ + proto_register_m2m(); + } +} + +G_MODULE_EXPORT void plugin_reg_handoff(void) +{ + proto_reg_handoff_m2m(); +} +#endif + +/* Register M2M defrag table init routine. */ +static void +m2m_defragment_init(void) +{ + fragment_table_init(&pdu_frag_table); +} + +/* Register Wimax Mac to Mac Protocol */ +void proto_register_m2m(void) +{ + if (proto_m2m == -1) + { + proto_m2m = proto_register_protocol ( + "WiMax Mac to Mac Packet", /* name */ + "M2M (m2m)", /* short name */ + "m2m" /* abbrev */ + ); + + proto_register_field_array(proto_m2m, hf, array_length(hf)); + proto_register_field_array(proto_m2m, hf_tlv, array_length(hf_tlv)); + proto_register_subtree_array(ett, array_length(ett)); + } + prefs_register_protocol(proto_m2m, proto_reg_handoff_m2m); + + /* init the PDU fragment table */ + fragment_table_init(&pdu_frag_table); + /* Register the PDU fragment table init routine */ + register_init_routine(m2m_defragment_init); + + /* Add new protocols here */ +} + +/* Register Wimax Mac to Mac Protocol handler */ +void proto_reg_handoff_m2m(void) +{ + static int Initialized = FALSE; + + if (!Initialized) + { + m2m_handle = create_dissector_handle(dissect_m2m, proto_m2m); + dissector_add("ethertype", WMX_M2M, m2m_handle); + } +} + +/* WiMax MAC to MAC protocol dissector */ +static void dissect_m2m(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + proto_item *ti = NULL; + proto_item *m2m_item = NULL; + proto_tree *m2m_tree = NULL; + proto_tree *tlv_tree = NULL; + gint burst_number = 0; + gint length, offset = 0; + gint tlv_count; + gint tlv_type, tlv_len, tlv_offset, tlv_value; + gint tlv_frag_type = 0; + gint tlv_frag_number = 0; + tlv_info_t m2m_tlv_info; + gint i; + gint hf = 0; + static gboolean checked_frame = FALSE; + static gint frame_col = -1; + + /* display the M2M protocol name */ + if (check_col(pinfo->cinfo, COL_PROTOCOL)) + { + col_set_str(pinfo->cinfo, COL_PROTOCOL, "WiMax"); + } + + /* Clear out stuff in the info column */ + if (check_col(pinfo->cinfo, COL_INFO)) + { + col_clear(pinfo->cinfo, COL_INFO); + } + + if (tree) + { /* we are being asked for details */ + m2m_item = proto_tree_add_item(tree, proto_m2m, tvb, 0, -1, FALSE); + m2m_tree = proto_item_add_subtree(m2m_item, ett_m2m); + /* get the tvb length */ + length = tvb_length(tvb); + /* add the size info */ + /* + proto_item_append_text(m2m_item, " (%u bytes) - Packet Sequence Number,Number of TLVs", length); + */ + proto_item_append_text(m2m_item, " (%u bytes)", length); + /* get the sequence number */ + sequence_number = tvb_get_ntohs(tvb, offset); + /* display the sequence number */ + proto_tree_add_item(m2m_tree, hf_m2m_sequence_number, tvb, offset, 2, FALSE); + offset += 2; + /* display the TLV count */ + proto_tree_add_item(m2m_tree, hf_m2m_tlv_count, tvb, offset, 2, FALSE); + tlv_count = tvb_get_ntohs(tvb, offset); + offset += 2; + /* parses the TLVs within current packet */ + while ( tlv_count > 0) + { /* init MAC to MAC TLV information */ + init_tlv_info(&m2m_tlv_info, tvb, offset); + /* get the TLV type */ + tlv_type = get_tlv_type(&m2m_tlv_info); + /* get the TLV length */ + tlv_len = get_tlv_length(&m2m_tlv_info); + if(tlv_type == -1 || tlv_len > 64000 || tlv_len < 1) + { /* invalid tlv info */ + if(pinfo->cinfo) + { + col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", "M2M TLV error"); + } + /* display the invalid TLV in HEX */ + proto_tree_add_item(m2m_tree, hf_wimax_invalid_tlv, tvb, offset, (length - offset), FALSE); + break; + } + /* get the TLV value offset */ + tlv_offset = get_tlv_value_offset(&m2m_tlv_info); + /* display TLV type */ + ti = proto_tree_add_protocol_format(m2m_tree, proto_m2m, tvb, offset, (tlv_len + tlv_offset), val_to_str(tlv_type, tlv_name, "Unknown TLV")); + /* add TLV subtree */ + tlv_tree = proto_item_add_subtree(ti, ett_m2m_tlv); + /* update the offset */ + offset += tlv_offset; + /* add the size info */ + /* decode TLV content (TLV value) */ + switch (tlv_type) + { + case TLV_PROTO_VER: + /* get the protocol version */ + tlv_value = tvb_get_guint8( tvb, offset ); + /* add the description */ + proto_item_append_text(ti, ": %d", tlv_value); + hf = hf_m2m_value_protocol_vers_uint8; + break; + + case TLV_BURST_NUM: + /* get the burst number */ + burst_number = tvb_get_guint8( tvb, offset ); + /* add the description */ + proto_item_append_text(ti, ": %d", burst_number); + hf = hf_m2m_value_burst_num_uint8; + break; + + case TLV_FRAG_TYPE: + /* add the description */ + tlv_frag_type = tvb_get_guint8( tvb, offset ); + proto_item_append_text(ti, ": %s", val_to_str(tlv_frag_type, tlv_frag_type_name, "Unknown")); + hf = hf_m2m_value_frag_type_uint8; + break; + + case TLV_FRAG_NUM: + /* get the fragment number */ + tlv_frag_number = tvb_get_guint8( tvb, offset ); + /* add the description */ + proto_item_append_text(ti, ": %d", tlv_frag_number); + hf = hf_m2m_value_frag_num_uint8; + break; + + case TLV_PDU_BURST: + /* display PDU Burst length info */ + proto_item_append_text(ti, " (%u bytes)", tlv_len); + /* decode and display the PDU Burst */ + pdu_burst_decoder(tree, tvb, offset, tlv_len, pinfo, burst_number, tlv_frag_type, tlv_frag_number); + hf = hf_m2m_value_pdu_burst; + break; + + case TLV_FAST_FB: + /* display the Fast Feedback Burst length info */ + proto_item_append_text(ti, " (%u bytes)", tlv_len); + /* decode and display the Fast Feedback Burst */ + fast_feedback_burst_decoder(tree, tvb, offset, tlv_len, pinfo); + hf = hf_m2m_value_fast_fb; + break; + + case TLV_FRAME_NUM: + /* get the frame number */ + g_frame_number = tvb_get_ntoh24( tvb, offset ); + /* add the description */ + proto_tree_add_item(tlv_tree, hf_m2m_frame_number, tvb, offset, 3, FALSE); + proto_item_append_text(ti, ": %d", g_frame_number); + if (!checked_frame) + { + /* See if a "Frame" column is defined */ + if (pinfo->cinfo != NULL) + { + for (i=0; i < pinfo->cinfo->num_cols; i++ ) + { + if (strcmp(pinfo->cinfo->col_title[i], "Frame") == 0) + { + frame_col = i; + } + } + } + checked_frame = TRUE; + } + if (check_col(pinfo->cinfo, COL_IF_DIR)) + { + /* Check if Frame column is present */ + if (frame_col != -1) + { + /* Display frame number in Frame column */ + + col_append_fstr(pinfo->cinfo, COL_IF_DIR, "%7u", g_frame_number); + } + } + break; + + case TLV_FCH_BURST: + /* add the description */ + tlv_value = tvb_get_ntoh24( tvb, offset ); + proto_item_append_text(ti, ": 0x%X", tlv_value); + /* decode and display the TLV FCH bust */ + fch_burst_decoder(tree, tvb, offset, tlv_len, pinfo); + hf = hf_m2m_value_fch_burst_uint24; + break; + + case TLV_CDMA_CODE: + /* add the description */ + tlv_value = tvb_get_ntoh24( tvb, offset ); + proto_item_append_text(ti, ": 0x%X", tlv_value); + /* decode and display the CDMA Code */ + cdma_code_decoder(tree, tvb, offset, tlv_len, pinfo); + hf = hf_m2m_value_cdma_code_uint24; + break; + + case TLV_CRC16_STATUS: + /* add the description */ + tlv_value = tvb_get_guint8( tvb, offset ); + proto_item_append_text(ti, ": %s", val_to_str(tlv_value, tlv_crc16_status, "Unknown")); + hf = hf_m2m_value_crc16_status_uint8; + break; + + case TLV_BURST_POWER: + /* add the description */ + tlv_value = tvb_get_ntohs( tvb, offset ); + proto_item_append_text(ti, ": %d", tlv_value); + hf = hf_m2m_value_burst_power_uint16; + break; + + case TLV_BURST_CINR: + /* add the description */ + tlv_value = tvb_get_ntohs( tvb, offset ); + proto_item_append_text(ti, ": 0x%X", tlv_value); + hf = hf_m2m_value_burst_cinr_uint16; + break; + + case TLV_PREAMBLE: + /* add the description */ + tlv_value = tvb_get_ntohs( tvb, offset ); + proto_item_append_text(ti, ": 0x%X", tlv_value); + hf = hf_m2m_value_preamble_uint16; + break; + + case TLV_HARQ_ACK_BURST: + /* display the Burst length info */ + proto_item_append_text(ti, " (%u bytes)", tlv_len); + /* decode and display the HARQ ACK Bursts */ + harq_ack_bursts_decoder(tree, tvb, offset, tlv_len, pinfo); + hf = hf_m2m_value_harq_ack_burst_bytes; + break; + + case TLV_PHY_ATTRIBUTES: + /* display the Burst length info */ + proto_item_append_text(ti, " (%u bytes)", tlv_len); + /* decode and display the PDU Burst Physical Attributes */ + physical_attributes_decoder(tree, tvb, offset, tlv_len, pinfo); + hf = hf_m2m_phy_attributes; + break; + + case TLV_EXTENDED_TLV: + /* display the Burst length info */ + proto_item_append_text(ti, " (%u bytes)", tlv_len); + /* decode and display the Extended TLV */ + extended_tlv_decoder(pinfo); + break; + + default: + /* update the info column */ + if (check_col(pinfo->cinfo, COL_INFO)) + { + col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", "Unknown TLV Type"); + } + break; + } + /* expand the TLV detail */ + proto_tree_add_tlv(&m2m_tlv_info, tvb, offset - tlv_offset, pinfo, tlv_tree, hf); + offset += tlv_len; + /* update tlv_count */ + tlv_count--; + } + } +} + +/* Decode and display the FCH burst */ +static void fch_burst_decoder(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, packet_info *pinfo) +{ + /* find the TLV FCH Burst handler */ + wimax_fch_burst_handle = find_dissector("wimax_fch_burst_handler"); + if(wimax_fch_burst_handle) + { /* call FCH dissector */ + call_dissector(wimax_fch_burst_handle, tvb_new_subset(tvb, offset, length, length), pinfo, tree); + } + else /* display FCH info */ + { /* update the info column */ + if (check_col(pinfo->cinfo, COL_INFO)) + { + col_append_str(pinfo->cinfo, COL_INFO, "FCH Burst: DL Frame Prefix"); + } + } +} + +/* Decode and display the CDMA Code Attribute */ +static void cdma_code_decoder(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, packet_info *pinfo) +{ + /* find the TLV CDMA CODE Burst handler */ + wimax_cdma_code_burst_handle = find_dissector("wimax_cdma_code_burst_handler"); + if(wimax_cdma_code_burst_handle) + { /* call CDMA dissector */ + call_dissector(wimax_cdma_code_burst_handle, tvb_new_subset(tvb, offset, length, length), pinfo, tree); + } + else /* display CDMA Code Attribute info */ + { /* update the info column */ + if (check_col(pinfo->cinfo, COL_INFO)) + { + col_append_str(pinfo->cinfo, COL_INFO, "CDMA Code Attribute"); + } + } +} + +/* Decode and display the PDU Burst */ +static void pdu_burst_decoder(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, packet_info *pinfo, gint burst_number, gint frag_type, gint frag_number) +{ + fragment_data *pdu_frag; + tvbuff_t *pdu_tvb = NULL; + gint pdu_length = 0; + + /* update the info column */ + if (check_col(pinfo->cinfo, COL_INFO)) + { + switch (frag_type) + { + case TLV_FIRST_FRAG: + col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "First TLV Fragment (%d)", frag_number); + break; + case TLV_LAST_FRAG: + col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "Last TLV Fragment (%d)", frag_number); + break; + case TLV_MIDDLE_FRAG: + col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "Middle TLV Fragment %d", frag_number); + break; + } + } + if(frag_type == TLV_NO_FRAG) + { /* not fragmented PDU */ + pdu_tvb = tvb_new_subset(tvb, offset, length, length); + pdu_length = length; + } + else /* fragmented PDU */ + { /* add the frag */ + pdu_frag = fragment_add_seq(tvb, offset, pinfo, burst_number, pdu_frag_table, frag_number - 1, length, ((frag_type==TLV_LAST_FRAG)?0:1)); + if(pdu_frag && frag_type == TLV_LAST_FRAG) + { + pdu_length = pdu_frag->len; + /* create the new tvb for defraged frame */ + pdu_tvb = tvb_new_real_data(pdu_frag->data, pdu_length, pdu_length); + /* attach the pdu_tvb to tvb so that it will be cleaned up when tvb is cleaned up */ + tvb_set_child_real_data_tvbuff(tvb, pdu_tvb); + /* add the defragmented data to the data source list */ + add_new_data_source(pinfo, pdu_tvb, "Reassembled WiMax PDU Frame"); + } + else + { + pdu_tvb = NULL; + if(frag_type == TLV_LAST_FRAG) + { /* update the info column */ + if (check_col(pinfo->cinfo, COL_INFO)) + col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", "Incomplete PDU frame"); + } + } + } + /* process the defragmented PDU burst */ + if(pdu_tvb) + { /* find the TLV PDU Burst handler */ + wimax_pdu_burst_handle = find_dissector("wimax_pdu_burst_handler"); + if(wimax_pdu_burst_handle) + /* decode and display PDU Burst */ + call_dissector(wimax_pdu_burst_handle, pdu_tvb, pinfo, tree); + else /* display PDU Burst info */ + { /* update the info column */ + if (check_col(pinfo->cinfo, COL_INFO)) + { + col_append_str(pinfo->cinfo, COL_INFO, "PDU Burst"); + } + } + } +} + +/* Decode and display the Fast Feedback Burst */ +static void fast_feedback_burst_decoder(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, packet_info *pinfo) +{ + /* find the TLV Fast Feedback Burst handler */ + wimax_ffb_burst_handle = find_dissector("wimax_ffb_burst_handler"); + if(wimax_ffb_burst_handle) + { /* display the TLV Fast Feedback Burst dissector info */ + call_dissector(wimax_ffb_burst_handle, tvb_new_subset(tvb, offset, length, length), pinfo, tree); + } + else /* display the Fast Feedback Burst info */ + { /* update the info column */ + if (check_col(pinfo->cinfo, COL_INFO)) + { + col_append_str(pinfo->cinfo, COL_INFO, "Fast Feedback Burst"); + } + } +} + +static void harq_ack_bursts_decoder(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, packet_info *pinfo) +{ + /* find the TLV HARQ ACK Bursts handler */ + wimax_hack_burst_handle = find_dissector("wimax_hack_burst_handler"); + if(wimax_hack_burst_handle) + { /* call the TLV HARQ ACK Bursts dissector */ + call_dissector(wimax_hack_burst_handle, tvb_new_subset(tvb, offset, length, length), pinfo, tree); + } + else /* display the TLV HARQ ACK Bursts info */ + { /* update the info column */ + if (check_col(pinfo->cinfo, COL_INFO)) + { + col_append_str(pinfo->cinfo, COL_INFO, "HARQ ACK Bursts"); + } + } +} + +static void physical_attributes_decoder(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, packet_info *pinfo) +{ + /* find the TLV PDU Burst Physical Attributes handler */ + wimax_phy_attributes_burst_handle = find_dissector("wimax_phy_attributes_burst_handler"); + if(wimax_phy_attributes_burst_handle) + { /* call the TLV PDU Burst Physical Attributes dissector */ + call_dissector(wimax_phy_attributes_burst_handle, tvb_new_subset(tvb, offset, length, length), pinfo, tree); + } + else /* display the TLV PDU Burst Physical Attributes info */ + { /* update the info column */ + if (check_col(pinfo->cinfo, COL_INFO)) + { + col_append_str(pinfo->cinfo, COL_INFO, "PHY-attr"); + } + } +} + +static void extended_tlv_decoder(packet_info *pinfo) +{ + /* display the Extended TLV info */ + /* update the info column */ + if (check_col(pinfo->cinfo, COL_INFO)) + { + col_append_str(pinfo->cinfo, COL_INFO, "Extended TLV"); + } +} + +/* Display the raw WiMax TLV */ +void proto_tree_add_tlv(tlv_info_t *this, tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, gint hf) +{ + guint tlv_offset; + gint tlv_type, tlv_len; + + /* make sure the TLV information is valid */ + if(!this->valid) + { /* invalid TLV info */ + if(pinfo->cinfo) + { + col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "Invalid TLV"); + } + return; + } + tlv_offset = offset; + /* display TLV type */ + proto_tree_add_item(tree, hf_m2m_type, tvb, tlv_offset, 1, FALSE); + tlv_offset++; + /* check the TLV length type */ + if( this->length_type ) + { /* multiple bytes TLV length */ + /* display the length of the TLV length with MSB */ + proto_tree_add_item(tree, hf_m2m_len_size, tvb, tlv_offset, 1, FALSE); + tlv_offset++; + if(this->size_of_length) + /* display the multiple byte TLV length */ + proto_tree_add_item(tree, hf_m2m_len, tvb, tlv_offset, this->size_of_length, FALSE); + else + return; + } + else /* display the single byte TLV length */ + proto_tree_add_item(tree, hf_m2m_len, tvb, tlv_offset, 1, FALSE); + + tlv_type = get_tlv_type(this); + /* Display Frame Number as special case for filter */ + if ( tlv_type == TLV_FRAME_NUM ) + { + return; + } + + /* get the TLV length */ + tlv_len = get_tlv_length(this); + proto_tree_add_item(tree, hf, tvb, (offset + this->value_offset), tlv_len, FALSE); +} diff --git a/plugins/m2m/wimax_tlv.c b/plugins/m2m/wimax_tlv.c new file mode 100644 index 0000000000..a37a653637 --- /dev/null +++ b/plugins/m2m/wimax_tlv.c @@ -0,0 +1,188 @@ +/* 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; +} diff --git a/plugins/m2m/wmxtypes.h b/plugins/m2m/wmxtypes.h new file mode 100644 index 0000000000..91cf4378be --- /dev/null +++ b/plugins/m2m/wmxtypes.h @@ -0,0 +1,36 @@ +/* wmxtypes.h + * Defines WiMax packet types. + * + * 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 1998 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. + */ + +#ifndef __WMXTYPES_H__ +#define __WMXTYPES_H__ + +/* Protocol types */ +#define WMX_M2M 0x08F0 /* WiMax MAC to MAC protocol */ + +#endif /* wmxtypes.h */ |