diff options
Diffstat (limited to 'tools/chdr-dissector')
-rw-r--r-- | tools/chdr-dissector/.gitignore | 2 | ||||
-rw-r--r-- | tools/chdr-dissector/CMakeLists.txt | 96 | ||||
-rw-r--r-- | tools/chdr-dissector/cmake/Modules/FindGLIB2.cmake | 238 | ||||
-rw-r--r-- | tools/chdr-dissector/cmake/Modules/FindWireshark.cmake | 28 | ||||
-rwxr-xr-x | tools/chdr-dissector/make-dissector-reg.py | 305 | ||||
-rw-r--r-- | tools/chdr-dissector/moduleinfo.h | 9 | ||||
-rw-r--r-- | tools/chdr-dissector/packet-chdr.c | 472 | ||||
-rw-r--r-- | tools/chdr-dissector/plugin.rc.in | 34 |
8 files changed, 0 insertions, 1184 deletions
diff --git a/tools/chdr-dissector/.gitignore b/tools/chdr-dissector/.gitignore deleted file mode 100644 index 0187b3dac..000000000 --- a/tools/chdr-dissector/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build/ -*~ diff --git a/tools/chdr-dissector/CMakeLists.txt b/tools/chdr-dissector/CMakeLists.txt deleted file mode 100644 index 8d19807d8..000000000 --- a/tools/chdr-dissector/CMakeLists.txt +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright 2010-2013 Ettus Research LLC -# -# GNU Radio 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 3, or (at your option) -# any later version. -# -# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - - -######################################################################## -# Project setup -######################################################################## -cmake_minimum_required(VERSION 2.6) -project(chdr-dissector C) -set(chdr-dissector_VERSION_MAJOR 0) -set(chdr-dissector_VERSION_MINOR 0) -enable_testing() - -#select the release build type by default to get optimization flags -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") - message(STATUS "Build type not specified: defaulting to release.") -endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") - -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) - -######################################################################## -# Compiler specific setup -######################################################################## -#if(CMAKE_COMPILER_IS_GNUC AND NOT WIN32) -# #http://gcc.gnu.org/wiki/Visibility -# add_definitions(-fvisibility=visible) -#endif() - -find_package(GLIB2) -if(NOT GLIB2_FOUND) - message(FATAL_ERROR "Glib not found") -endif() - -find_package(Wireshark) -if(NOT WIRESHARK_FOUND) - message(FATAL_ERROR "Wireshark dev package not found") -endif() - - -######################################################################## -# Setup the include and linker paths -######################################################################## -include_directories( - ${CMAKE_SOURCE_DIR} - ${GLIB2_INCLUDE_DIRS} - ${WIRESHARK_INCLUDE_DIRS} -) - -#link_directories( -# ${Boost_LIBRARY_DIRS} -#) -set(CMAKE_INSTALL_LIBDIR ~/.wireshark) - -# Set component parameters -set(CHDR_DISSECTOR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR} CACHE INTERNAL "" FORCE) - -set(CHDR_PLUGIN_SRC ${CMAKE_SOURCE_DIR}/packet-chdr.c) - -set(PLUGIN_C_GENERATOR ${CMAKE_SOURCE_DIR}/make-dissector-reg.py) -set(PLUGIN_C plugin.c) - -add_custom_command( - OUTPUT ${PLUGIN_C} - DEPENDS ${CHDR_PLUGIN_SRC} - COMMAND ${PLUGIN_C_GENERATOR} ${CMAKE_SOURCE_DIR} plugin ${CHDR_PLUGIN_SRC} - COMMENT "Generating ${PLUGIN_C}" -) - -add_library(chdr-plugin MODULE - ${PLUGIN_C} - moduleinfo.h - ${CHDR_PLUGIN_SRC} -) -set_target_properties(chdr-plugin PROPERTIES PREFIX "") -set_target_properties(chdr-plugin PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}") -target_link_libraries(chdr-plugin wireshark) - -install(TARGETS chdr-plugin - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/plugins NAMELINK_SKIP -) diff --git a/tools/chdr-dissector/cmake/Modules/FindGLIB2.cmake b/tools/chdr-dissector/cmake/Modules/FindGLIB2.cmake deleted file mode 100644 index ae7baddbb..000000000 --- a/tools/chdr-dissector/cmake/Modules/FindGLIB2.cmake +++ /dev/null @@ -1,238 +0,0 @@ -# -# $Id: FindGLIB2.cmake 34248 2010-09-25 15:38:12Z jmayer $ -# -# - Try to find GLib2 -# Once done this will define -# -# GLIB2_FOUND - system has GLib2 -# GLIB2_INCLUDE_DIRS - the GLib2 include directory -# GLIB2_LIBRARIES - Link these to use GLib2 -# -# HAVE_GLIB_GREGEX_H glib has gregex.h header and -# supports g_regex_match_simple -# -# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org> -# Copyright (c) 2006 Philippe Bernery <philippe.bernery@gmail.com> -# Copyright (c) 2007 Daniel Gollub <gollub@b1-systems.de> -# Copyright (c) 2007 Alban Browaeys <prahal@yahoo.com> -# Copyright (c) 2008 Michael Bell <michael.bell@web.de> -# Copyright (c) 2008-2009 Bjoern Ricks <bjoern.ricks@googlemail.com> -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# - - -IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) - # in cache already - SET(GLIB2_FOUND TRUE) -ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) - - INCLUDE(FindPkgConfig) - - ## Glib - IF ( GLIB2_FIND_REQUIRED ) - SET( _pkgconfig_REQUIRED "REQUIRED" ) - ELSE ( GLIB2_FIND_REQUIRED ) - SET( _pkgconfig_REQUIRED "" ) - ENDIF ( GLIB2_FIND_REQUIRED ) - - IF ( GLIB2_MIN_VERSION ) - PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} ) - ELSE ( GLIB2_MIN_VERSION ) - PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 ) - ENDIF ( GLIB2_MIN_VERSION ) - IF ( PKG_CONFIG_FOUND ) - IF ( GLIB2_FOUND ) - SET ( GLIB2_CORE_FOUND TRUE ) - ELSE ( GLIB2_FOUND ) - SET ( GLIB2_CORE_FOUND FALSE ) - ENDIF ( GLIB2_FOUND ) - ENDIF ( PKG_CONFIG_FOUND ) - - # Look for glib2 include dir and libraries w/o pkgconfig - IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) - FIND_PATH( - _glibconfig_include_DIR - NAMES - glibconfig.h - PATHS - /opt/gnome/lib64 - /opt/gnome/lib - /opt/lib/ - /opt/local/lib - /sw/lib/ - /usr/lib64 - /usr/lib - /usr/local/include - ${CMAKE_LIBRARY_PATH} - PATH_SUFFIXES - glib-2.0/include - ) - - FIND_PATH( - _glib2_include_DIR - NAMES - glib.h - PATHS - /opt/gnome/include - /opt/local/include - /sw/include - /usr/include - /usr/local/include - PATH_SUFFIXES - glib-2.0 - ) - - #MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}") - - FIND_LIBRARY( - _glib2_link_DIR - NAMES - glib-2.0 - glib - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/lib - /usr/local/lib - ) - IF ( _glib2_include_DIR AND _glib2_link_DIR ) - SET ( _glib2_FOUND TRUE ) - ENDIF ( _glib2_include_DIR AND _glib2_link_DIR ) - - - IF ( _glib2_FOUND ) - SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} ) - SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} ) - SET ( GLIB2_CORE_FOUND TRUE ) - ELSE ( _glib2_FOUND ) - SET ( GLIB2_CORE_FOUND FALSE ) - ENDIF ( _glib2_FOUND ) - - # Handle dependencies - # libintl - IF ( NOT LIBINTL_FOUND ) - FIND_PATH(LIBINTL_INCLUDE_DIR - NAMES - libintl.h - PATHS - /opt/gnome/include - /opt/local/include - /sw/include - /usr/include - /usr/local/include - ) - - FIND_LIBRARY(LIBINTL_LIBRARY - NAMES - intl - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/local/lib - /usr/lib - ) - - IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) - SET (LIBINTL_FOUND TRUE) - ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) - ENDIF ( NOT LIBINTL_FOUND ) - - # libiconv - IF ( NOT LIBICONV_FOUND ) - FIND_PATH(LIBICONV_INCLUDE_DIR - NAMES - iconv.h - PATHS - /opt/gnome/include - /opt/local/include - /opt/local/include - /sw/include - /sw/include - /usr/local/include - /usr/include - PATH_SUFFIXES - glib-2.0 - ) - - FIND_LIBRARY(LIBICONV_LIBRARY - NAMES - iconv - PATHS - /opt/gnome/lib - /opt/local/lib - /sw/lib - /usr/lib - /usr/local/lib - ) - - IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - SET (LIBICONV_FOUND TRUE) - ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - ENDIF ( NOT LIBICONV_FOUND ) - - IF (LIBINTL_FOUND) - SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY}) - SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR}) - ENDIF (LIBINTL_FOUND) - - IF (LIBICONV_FOUND) - SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) - SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) - ENDIF (LIBICONV_FOUND) - - ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) - ## - - IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) - SET (GLIB2_FOUND TRUE) - ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) - - IF (GLIB2_FOUND) - IF (NOT GLIB2_FIND_QUIETLY) - MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}") - ENDIF (NOT GLIB2_FIND_QUIETLY) - ELSE (GLIB2_FOUND) - IF (GLIB2_FIND_REQUIRED) - MESSAGE (SEND_ERROR "Could not find GLib2") - ENDIF (GLIB2_FIND_REQUIRED) - ENDIF (GLIB2_FOUND) - - # show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view - MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES) - MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY) - MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY) - -ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS) - -IF ( WIN32 ) - # include libiconv for win32 - IF ( NOT LIBICONV_FOUND ) - FIND_PATH(LIBICONV_INCLUDE_DIR iconv.h PATH_SUFFIXES glib-2.0) - - FIND_LIBRARY(LIBICONV_LIBRARY NAMES iconv) - - IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - SET (LIBICONV_FOUND TRUE) - ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) - ENDIF ( NOT LIBICONV_FOUND ) - IF (LIBICONV_FOUND) - SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) - SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) - ENDIF (LIBICONV_FOUND) -ENDIF ( WIN32 ) - -IF ( GLIB2_FOUND ) - # Check if system has a newer version of glib - # which supports g_regex_match_simple - INCLUDE( CheckIncludeFiles ) - SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} ) - CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H ) - CHECK_INCLUDE_FILES ( glib/gchecksum.h HAVE_GLIB_GCHECKSUM_H ) - # Reset CMAKE_REQUIRED_INCLUDES - SET( CMAKE_REQUIRED_INCLUDES "" ) -ENDIF( GLIB2_FOUND ) diff --git a/tools/chdr-dissector/cmake/Modules/FindWireshark.cmake b/tools/chdr-dissector/cmake/Modules/FindWireshark.cmake deleted file mode 100644 index 276201245..000000000 --- a/tools/chdr-dissector/cmake/Modules/FindWireshark.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# -# Try to find the wireshark library and its includes -# -# This snippet sets the following variables: -# WIRESHARK_FOUND True if wireshark library got found -# WIRESHARK_INCLUDE_DIRS Location of the wireshark headers -# WIRESHARK_LIBRARIES List of libraries to use wireshark -# -# Copyright (c) 2011 Reinhold Kainhofer <reinhold@kainhofer.com> -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# - -# wireshark does not install its library with pkg-config information, -# so we need to manually find the libraries and headers - -FIND_PATH( WIRESHARK_INCLUDE_DIRS epan/column.h PATH_SUFFIXES wireshark ) -FIND_LIBRARY( WIRESHARK_LIBRARIES wireshark ) - -# Report results -IF ( WIRESHARK_LIBRARIES AND WIRESHARK_INCLUDE_DIRS ) - SET( WIRESHARK_FOUND 1 ) -ELSE ( WIRESHARK_LIBRARIES AND WIRESHARK_INCLUDE_DIRS ) - MESSAGE( SEND_ERROR "Could NOT find the wireshark library and headers" ) -ENDIF ( WIRESHARK_LIBRARIES AND WIRESHARK_INCLUDE_DIRS ) - diff --git a/tools/chdr-dissector/make-dissector-reg.py b/tools/chdr-dissector/make-dissector-reg.py deleted file mode 100755 index 44972909b..000000000 --- a/tools/chdr-dissector/make-dissector-reg.py +++ /dev/null @@ -1,305 +0,0 @@ -#!/usr/bin/env python -# -# Looks for registration routines in the protocol dissectors, -# and assembles C code to call all the routines. -# -# This is a Python version of the make-reg-dotc shell script. -# Running the shell script on Win32 is very very slow because of -# all the process-launching that goes on --- multiple greps and -# seds for each input file. I wrote this python version so that -# less processes would have to be started. -# -# $Id: make-dissector-reg.py 30447 2009-10-09 20:47:18Z krj $ - -import os -import sys -import re -import pickle -from stat import * - -VERSION_KEY = '_VERSION' -CUR_VERSION = '$Id: make-dissector-reg.py 30447 2009-10-09 20:47:18Z krj $' - -# -# The first argument is the directory in which the source files live. -# -srcdir = sys.argv[1] - -# -# The second argument is either "plugin" or "dissectors"; if it's -# "plugin", we build a plugin.c for a plugin, and if it's -# "dissectors", we build a register.c for libwireshark. -# -registertype = sys.argv[2] -if registertype == "plugin" or registertype == "plugin_wtap": - tmp_filename = "plugin.c-tmp" - final_filename = "plugin.c" - cache_filename = None - preamble = """\ -/* - * Do not modify this file. - * - * It is created automatically by Makefile or Makefile.nmake. - */ -""" -elif registertype == "dissectors": - tmp_filename = "register.c-tmp" - final_filename = "register.c" - cache_filename = "register-cache.pkl" - preamble = """\ -/* - * Do not modify this file. - * - * It is created automatically by the "register.c" target in - * epan/dissectors/Makefile or Makefile.nmake using information in - * epan/dissectors/register-cache.pkl. - * - * You can force this file to be regenerated completely by deleting - * it along with epan/dissectors/register-cache.pkl. - */ -""" -else: - print "Unknown output type '%s'" % registertype - sys.exit(1) - - -# -# All subsequent arguments are the files to scan. -# -files = sys.argv[3:] - -# Create the proper list of filenames -filenames = [] -for file in files: - if os.path.isfile(file): - filenames.append(file) - else: - filenames.append(os.path.join(srcdir, file)) - -if len(filenames) < 1: - print "No files found" - sys.exit(1) - - -# Look through all files, applying the regex to each line. -# If the pattern matches, save the "symbol" section to the -# appropriate array. -regs = { - 'proto_reg': [], - 'handoff_reg': [], - 'wtap_register': [], - } - -# For those that don't know Python, r"" indicates a raw string, -# devoid of Python escapes. -proto_regex0 = r"^(?P<symbol>proto_register_[_A-Za-z0-9]+)\s*\([^;]+$" -proto_regex1 = r"void\s+(?P<symbol>proto_register_[_A-Za-z0-9]+)\s*\([^;]+$" - -handoff_regex0 = r"^(?P<symbol>proto_reg_handoff_[_A-Za-z0-9]+)\s*\([^;]+$" -handoff_regex1 = r"void\s+(?P<symbol>proto_reg_handoff_[_A-Za-z0-9]+)\s*\([^;]+$" - -wtap_reg_regex0 = r"^(?P<symbol>wtap_register_[_A-Za-z0-9]+)\s*\([^;]+$" -wtap_reg_regex1 = r"void\s+(?P<symbol>wtap_register_[_A-Za-z0-9]+)\s*\([^;]+$" - -# This table drives the pattern-matching and symbol-harvesting -patterns = [ - ( 'proto_reg', re.compile(proto_regex0) ), - ( 'proto_reg', re.compile(proto_regex1) ), - ( 'handoff_reg', re.compile(handoff_regex0) ), - ( 'handoff_reg', re.compile(handoff_regex1) ), - ( 'wtap_register', re.compile(wtap_reg_regex0) ), - ( 'wtap_register', re.compile(wtap_reg_regex1) ), - ] - -# Open our registration symbol cache -cache = None -if cache_filename: - try: - cache_file = open(cache_filename, 'rb') - cache = pickle.load(cache_file) - cache_file.close() - if not cache.has_key(VERSION_KEY) or cache[VERSION_KEY] != CUR_VERSION: - cache = {VERSION_KEY: CUR_VERSION} - except: - cache = {VERSION_KEY: CUR_VERSION} - -# Grep -for filename in filenames: - file = open(filename) - cur_mtime = os.fstat(file.fileno())[ST_MTIME] - if cache and cache.has_key(filename): - cdict = cache[filename] - if cur_mtime == cdict['mtime']: -# print "Pulling %s from cache" % (filename) - regs['proto_reg'].extend(cdict['proto_reg']) - regs['handoff_reg'].extend(cdict['handoff_reg']) - regs['wtap_register'].extend(cdict['wtap_register']) - file.close() - continue - # We don't have a cache entry - if cache is not None: - cache[filename] = { - 'mtime': cur_mtime, - 'proto_reg': [], - 'handoff_reg': [], - 'wtap_register': [], - } -# print "Searching %s" % (filename) - for line in file.readlines(): - for action in patterns: - regex = action[1] - match = regex.search(line) - if match: - symbol = match.group("symbol") - sym_type = action[0] - regs[sym_type].append(symbol) - if cache is not None: -# print "Caching %s for %s: %s" % (sym_type, filename, symbol) - cache[filename][sym_type].append(symbol) - file.close() - -if cache is not None and cache_filename is not None: - cache_file = open(cache_filename, 'wb') - pickle.dump(cache, cache_file) - cache_file.close() - -# Make sure we actually processed something -if len(regs['proto_reg']) < 1: - print "No protocol registrations found" - sys.exit(1) - -# Sort the lists to make them pretty -regs['proto_reg'].sort() -regs['handoff_reg'].sort() -regs['wtap_register'].sort() - -reg_code = open(tmp_filename, "w") - -reg_code.write(preamble) - -# Make the routine to register all protocols -if registertype == "plugin" or registertype == "plugin_wtap": - reg_code.write(""" -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <gmodule.h> - -#include "moduleinfo.h" - -#ifndef ENABLE_STATIC -G_MODULE_EXPORT const gchar version[] = VERSION; - -/* Start the functions we need for the plugin stuff */ - -G_MODULE_EXPORT void -plugin_register (void) -{ -"""); -else: - reg_code.write(""" -#include "register.h" -void -register_all_protocols(register_cb cb, gpointer client_data) -{ -"""); - -for symbol in regs['proto_reg']: - if registertype == "plugin" or registertype == "plugin_wtap": - line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) - else: - line = " {extern void %s (void); if(cb) (*cb)(RA_REGISTER, \"%s\", client_data); %s ();}\n" % (symbol, symbol, symbol) - reg_code.write(line) - -reg_code.write("}\n") - - -# Make the routine to register all protocol handoffs -if registertype == "plugin" or registertype == "plugin_wtap": - reg_code.write(""" -G_MODULE_EXPORT void -plugin_reg_handoff(void) -{ -"""); -else: - reg_code.write(""" -void -register_all_protocol_handoffs(register_cb cb, gpointer client_data) -{ -"""); - -for symbol in regs['handoff_reg']: - if registertype == "plugin" or registertype == "plugin_wtap": - line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) - else: - line = " {extern void %s (void); if(cb) (*cb)(RA_HANDOFF, \"%s\", client_data); %s ();}\n" % (symbol, symbol, symbol) - reg_code.write(line) - -reg_code.write("}\n") - -if registertype == "plugin": - reg_code.write("#endif\n"); -elif registertype == "plugin_wtap": - reg_code.write(""" -G_MODULE_EXPORT void -register_wtap_module(void) -{ -"""); - - for symbol in regs['wtap_register']: - line = " {extern void %s (void); %s ();}\n" % (symbol, symbol) - reg_code.write(line) - - reg_code.write("}\n"); - reg_code.write("#endif\n"); -else: - reg_code.write(""" -static gulong proto_reg_count(void) -{ -"""); - - line = " return %d;\n" % len(regs['proto_reg']) - reg_code.write(line) - - reg_code.write(""" -} -"""); - reg_code.write(""" -static gulong handoff_reg_count(void) -{ -"""); - - line = " return %d;\n" % len(regs['handoff_reg']) - reg_code.write(line) - - reg_code.write(""" -} -"""); - reg_code.write(""" -gulong register_count(void) -{ -"""); - - line = " return proto_reg_count() + handoff_reg_count();" - reg_code.write(line) - - reg_code.write(""" -}\n -"""); - - -# Close the file -reg_code.close() - -# Remove the old final_file if it exists. -try: - os.stat(final_filename) - os.remove(final_filename) -except OSError: - pass - -# Move from tmp file to final file -os.rename(tmp_filename, final_filename) - - diff --git a/tools/chdr-dissector/moduleinfo.h b/tools/chdr-dissector/moduleinfo.h deleted file mode 100644 index d8f0570c7..000000000 --- a/tools/chdr-dissector/moduleinfo.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifdef PACKAGE -#undef PACKAGE -#endif -#define PACKAGE "chdr" -#ifdef VERSION -#undef VERSION -#endif -#define VERSION "0.0.0.1" - diff --git a/tools/chdr-dissector/packet-chdr.c b/tools/chdr-dissector/packet-chdr.c deleted file mode 100644 index 079e6bb3b..000000000 --- a/tools/chdr-dissector/packet-chdr.c +++ /dev/null @@ -1,472 +0,0 @@ -/* - * Dissector for UHD CVITA (CHDR) packets - * - * Copyright 2010-2014 Ettus Research LLC - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - * - */ - -#include "config.h" - -#include <glib.h> -#include <epan/packet.h> -#include <ctype.h> -#include <stdio.h> - -#include "../../host/lib/usrp/x300/x300_fw_common.h" - -#define LOG_HEADER "[UHD CHDR] " - -#ifndef min -#define min(a,b) ((a<b)?a:b) -#endif // min - -const unsigned int CHDR_PORT = X300_VITA_UDP_PORT; - -static int proto_chdr = -1; -static int hf_chdr_hdr = -1; -static int hf_chdr_type = -1; -static int hf_chdr_has_time = -1; -static int hf_chdr_eob = -1; -static int hf_chdr_error = -1; -static int hf_chdr_sequence = -1; -static int hf_chdr_packet_size = -1; -static int hf_chdr_stream_id = -1; -static int hf_chdr_src_dev = -1; -static int hf_chdr_src_ep = -1; -static int hf_chdr_src_blockport = -1; -static int hf_chdr_dst_dev = -1; -static int hf_chdr_dst_ep = -1; -static int hf_chdr_dst_blockport = -1; -static int hf_chdr_timestamp = -1; -static int hf_chdr_payload = -1; -static int hf_chdr_ext_response = -1; -static int hf_chdr_ext_status_code = -1; -static int hf_chdr_ext_seq_num = -1; -static int hf_chdr_cmd = -1; -static int hf_chdr_cmd_address = -1; -static int hf_chdr_cmd_value = -1; - -static const value_string CHDR_PACKET_TYPES[] = { - { 0, "Data" }, - { 1, "Data (End-of-Burst)" }, - { 4, "Flow Control" }, - { 8, "Command" }, - { 12, "Response" }, - { 13, "Error Response" }, -}; - -static const value_string CHDR_PACKET_TYPES_SHORT[] = { - { 0, "data" }, - { 1, "data" }, - { 4, "fc" }, - { 8, "cmd" }, - { 12, "resp" }, - { 13, "resp" }, -}; - -/* the heuristic dissector is called on every packet with payload. - * The warning printed for this should only be printed once. - */ -static int heur_warning_printed = 0; - -/* Subtree handles: set by register_subtree_array */ -static gint ett_chdr = -1; -static gint ett_chdr_header = -1; -static gint ett_chdr_id = -1; -static gint ett_chdr_response = -1; -static gint ett_chdr_cmd = -1; - -/* Forward-declare the dissector functions */ -void proto_register_chdr(void); -void proto_reg_handoff_chdr(void); -static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); - -/* heuristic dissector call. Will always return. */ -static gboolean heur_dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* whatislove) -{ - if(heur_warning_printed < 1){ - printf(LOG_HEADER"heuristic dissector always returns true!\n"); - heur_warning_printed++; - } - dissect_chdr(tvb, pinfo, tree); - return (TRUE); -} - -static void byte_swap(guint8 *bytes, gint len) -{ - guint8 tmp[4]; - - if(len != sizeof(tmp)){ - printf(LOG_HEADER"FATAL! number of bytes don't match 32 bit!\n"); - return; - } - - memcpy(tmp, bytes, sizeof(tmp)); - bytes[0] = tmp[3]; - bytes[1] = tmp[2]; - bytes[2] = tmp[1]; - bytes[3] = tmp[0]; -} - -static unsigned long long get_timestamp(guint8 *bytes, gint len) -{ - unsigned long long ts; - unsigned long long trans; - int it; - - if(len != sizeof(unsigned long long)){ - printf(LOG_HEADER"FATAL! timestamps always consist of 64 bits!\n"); - } - - byte_swap(bytes + 0, 4); - byte_swap(bytes + 4, 4); - - ts = 0; - for(it = 0; it < 8; it++){ - ts = ts << 8; - trans = (guint64) bytes[it]; - ts = ts | trans; - } - - return (ts); -} - -/* The dissector itself */ -static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) -{ - // Here are all the variables - proto_item *item; - proto_item *stream_item; - proto_tree *chdr_tree; - proto_item *header_item; - proto_tree *header_tree; - proto_tree *stream_tree; - proto_item *response_item; - proto_tree *response_tree; - proto_item *cmd_item; - proto_tree *cmd_tree; - gint len; - - gint flag_offset; - guint8 *bytes; - guint8 hdr_bits = 0; - guint8 pkt_type = 0; - gboolean flag_has_time = 0; - gboolean flag_is_data = 0; - gboolean flag_is_fc = 0; - gboolean flag_is_cmd = 0; - gboolean flag_is_resp = 0; - gboolean flag_is_eob = 0; - gboolean flag_is_error = 0; - unsigned long long timestamp; - gboolean is_network; - gint endianness; - gint id_pos_usb[4] = {7, 6, 5, 4}; - gint id_pos_net[4] = {4, 5, 6, 7}; - gint id_pos[4] = {7, 6, 5, 4}; - - if(pinfo->match_uint == CHDR_PORT){ - is_network = TRUE; - flag_offset = 0; - endianness = ENC_BIG_ENDIAN; - memcpy(id_pos, id_pos_net, 4 * sizeof(gint)); - } - else{ // Parsing a USB capture - is_network = FALSE; - flag_offset = 3; - endianness = ENC_LITTLE_ENDIAN; - memcpy(id_pos, id_pos_usb, 4 * sizeof(gint)); - } - - len = tvb_reported_length(tvb); - - col_append_str(pinfo->cinfo, COL_PROTOCOL, "/CHDR"); - /* This throws a warning: */ - /*col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "CHDR", tvb_format_text_wsp(tvb, 0, len));*/ - col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "CHDR"); - - if (tree){ - int chdr_size = -1; - - if (len >= 4){ - chdr_size = 8; - bytes = tvb_get_string(wmem_packet_scope(), tvb, 0, 4); - hdr_bits = (bytes[flag_offset] & 0xF0) >> 4; - pkt_type = hdr_bits >> 2; - flag_is_data = (pkt_type == 0); - flag_is_fc = (pkt_type == 1); - flag_is_cmd = (pkt_type == 2); - flag_is_resp = (pkt_type == 3); - flag_is_eob = flag_is_data && (hdr_bits & 0x1); - flag_is_error = flag_is_resp && (hdr_bits & 0x1); - flag_has_time = hdr_bits & 0x2; - if (flag_has_time) - chdr_size += 8; // 64-bit timestamp - } - - /* Start with a top-level item to add everything else to */ - item = proto_tree_add_item(tree, proto_chdr, tvb, 0, min(len, chdr_size), ENC_NA); - - if (len >= 4) { - chdr_tree = proto_item_add_subtree(item, ett_chdr); - - /* Header info. First, a top-level header tree item: */ - header_item = proto_tree_add_item(chdr_tree, hf_chdr_hdr, tvb, flag_offset, 1, endianness); - header_tree = proto_item_add_subtree(header_item, ett_chdr_header); - proto_item_append_text(header_item, ", Packet type: %s", - val_to_str(hdr_bits & 0xD, CHDR_PACKET_TYPES, "Unknown (0x%x)") - ); - /* Let us query hdr.type */ - proto_tree_add_string( - header_tree, hf_chdr_type, tvb, flag_offset, 1, - val_to_str(hdr_bits & 0xD, CHDR_PACKET_TYPES_SHORT, "invalid") - ); - /* And other flags */ - proto_tree_add_boolean(header_tree, hf_chdr_has_time, tvb, flag_offset, 1, flag_has_time); - if (flag_is_data) { - proto_tree_add_boolean(header_tree, hf_chdr_eob, tvb, flag_offset, 1, flag_is_eob); - } - if (flag_is_resp) { - proto_tree_add_boolean(header_tree, hf_chdr_error, tvb, flag_offset, 1, flag_is_error); - } - - /* These lines add sequence, packet_size and stream ID */ - proto_tree_add_item(chdr_tree, hf_chdr_sequence, tvb, (is_network ? 0:2), 2, endianness); - proto_tree_add_item(chdr_tree, hf_chdr_packet_size, tvb, (is_network ? 2:0), 2, endianness); - - if (len >= 8){ - /* stream id can be broken down to 4 sections. these are collapsed in a subtree */ - stream_item = proto_tree_add_item(chdr_tree, hf_chdr_stream_id, tvb, 4, 4, endianness); - stream_tree = proto_item_add_subtree(stream_item, ett_chdr_id); - proto_tree_add_item(stream_tree, hf_chdr_src_dev, tvb, id_pos[0], 1, ENC_NA); - proto_tree_add_item(stream_tree, hf_chdr_src_ep, tvb, id_pos[1], 1, ENC_NA); - proto_tree_add_item(stream_tree, hf_chdr_dst_dev, tvb, id_pos[2], 1, ENC_NA); - proto_tree_add_item(stream_tree, hf_chdr_dst_ep, tvb, id_pos[3], 1, ENC_NA); - - /* Block ports (only add them if address points to a device) */ - bytes = tvb_get_string(wmem_packet_scope(), tvb, 0, 8); - if (bytes[id_pos[0]] != 0) { - proto_tree_add_item(stream_tree, hf_chdr_src_blockport, tvb, id_pos[1], 1, ENC_NA); - } - if (bytes[id_pos[2]] != 0) { - proto_tree_add_item(stream_tree, hf_chdr_dst_blockport, tvb, id_pos[3], 1, ENC_NA); - } - - /* Append SID in sid_t hex format */ - proto_item_append_text(stream_item, " (%02X:%02X>%02X:%02X)", - bytes[id_pos[0]], - bytes[id_pos[1]], - bytes[id_pos[2]], - bytes[id_pos[3]] - ); - - /* if has_time flag is present interpret timestamp */ - if ((flag_has_time) && (len >= 16)){ - if (is_network) - item = proto_tree_add_item(chdr_tree, hf_chdr_timestamp, tvb, 8, 8, endianness); - else{ - bytes = (guint8*) tvb_get_string(wmem_packet_scope(), tvb, 8, sizeof(unsigned long long)); - timestamp = get_timestamp(bytes, sizeof(unsigned long long)); - proto_tree_add_uint64(chdr_tree, hf_chdr_timestamp, tvb, 8, 8, timestamp); - } - } - - int remaining_bytes = (len - chdr_size); - int show_raw_payload = (remaining_bytes > 0); - - if (flag_is_cmd && remaining_bytes == 8) { - cmd_item = proto_tree_add_item(chdr_tree, hf_chdr_cmd, tvb, chdr_size, 8, endianness); - cmd_tree = proto_item_add_subtree(cmd_item, ett_chdr_cmd); - proto_tree_add_item(cmd_tree, hf_chdr_cmd_address, tvb, chdr_size, 4, endianness); - proto_tree_add_item(cmd_tree, hf_chdr_cmd_value, tvb, chdr_size + 4, 4, endianness); - } else if (flag_is_resp) { - response_item = proto_tree_add_item(chdr_tree, hf_chdr_ext_response, tvb, chdr_size, 8, endianness); - response_tree = proto_item_add_subtree(response_item, ett_chdr_response); - - proto_tree_add_item(response_tree, hf_chdr_ext_status_code, tvb, chdr_size, 4, endianness); - /* This will show the 12-bits of sequence ID in the last 2 bytes */ - proto_tree_add_item(response_tree, hf_chdr_ext_seq_num, tvb, (chdr_size + 4 + (is_network ? 2 : 0)), 2, endianness); - } else if (show_raw_payload) { - proto_tree_add_item(chdr_tree, hf_chdr_payload, tvb, chdr_size, -1, ENC_NA); - } - } - } - } -} - -void proto_register_chdr(void) -{ - static hf_register_info hf[] = { - { &hf_chdr_hdr, - { "Header bits", "chdr.hdr", - FT_UINT8, BASE_HEX, - NULL, 0xF0, - NULL, HFILL } - }, - { &hf_chdr_type, - { "Packet Type", "chdr.hdr.type", - FT_STRINGZ, BASE_NONE, - NULL, 0x00, - "Packet Type", HFILL } - }, - { &hf_chdr_has_time, - { "Time present", "chdr.hdr.has_time", - FT_BOOLEAN, BASE_NONE, - NULL, 0x20, - NULL, HFILL } - }, - { &hf_chdr_eob, - { "End Of Burst", "chdr.hdr.eob", - FT_BOOLEAN, BASE_NONE, - NULL, 0x10, - NULL, HFILL } - }, - { &hf_chdr_error, - { "Error Flag", "chdr.hdr.error", - FT_BOOLEAN, BASE_NONE, - NULL, 0x10, - NULL, HFILL } - }, - { &hf_chdr_sequence, - { "Sequence ID", "chdr.seq", - FT_UINT16, BASE_DEC, - NULL, 0x0FFF, - NULL, HFILL } - }, - { &hf_chdr_packet_size, - { "Packet size", "chdr.size", - FT_UINT16, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_stream_id, - { "Stream ID", "chdr.sid", - FT_IPv4, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_src_dev, - { "Source device", "chdr.src_dev", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_src_ep, - { "Source endpoint", "chdr.src_ep", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_src_blockport, - { "Source block port", "chdr.src_bp", - FT_UINT8, BASE_DEC, - NULL, 0xF, - NULL, HFILL } - }, - { &hf_chdr_dst_dev, - { "Destination device", "chdr.dst_dev", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_dst_ep, - { "Destination endpoint", "chdr.dst_ep", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_dst_blockport, - { "Destination block port", "chdr.dst_bp", - FT_UINT8, BASE_DEC, - NULL, 0xF, - NULL, HFILL } - }, - { &hf_chdr_timestamp, - { "Time", "chdr.time", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_payload, - { "Payload", "chdr.payload", - FT_BYTES, BASE_NONE, - NULL, 0x0, - NULL, HFILL - } - }, - { &hf_chdr_ext_response, - { "Response", "chdr.res", - FT_BYTES, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_ext_status_code, - { "Status code", "chdr.res.status", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_ext_seq_num, - { "Response to sequence ID", "chdr.res.seq", - FT_UINT16, BASE_DEC, - NULL, 0x0FFF, - NULL, HFILL } - }, - { &hf_chdr_cmd, - { "Command", "chdr.cmd", - FT_BYTES, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_cmd_address, - { "Register Address", "chdr.cmd.addr", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_chdr_cmd_value, - { "Command Value", "chdr.cmd.val", - FT_UINT32, BASE_HEX, - NULL, 0x0, - NULL, HFILL } - }, - }; - - static gint *ett[] = { - &ett_chdr, - &ett_chdr_header, - &ett_chdr_id, - &ett_chdr_response, - &ett_chdr_cmd - }; - - proto_chdr = proto_register_protocol("UHD CHDR", "CHDR", "chdr"); - proto_register_field_array(proto_chdr, hf, array_length(hf)); - proto_register_subtree_array(ett, array_length(ett)); - register_dissector("chdr", dissect_chdr, proto_chdr); -} - -/* Handler registration */ -void proto_reg_handoff_chdr(void) -{ - /* register heuristic dissector for use with USB */ - heur_dissector_add("usb.bulk", heur_dissect_chdr, proto_chdr); - - /* register dissector for UDP packets */ - static dissector_handle_t chdr_handle; - chdr_handle = create_dissector_handle(dissect_chdr, proto_chdr); - dissector_add_uint("udp.port", CHDR_PORT, chdr_handle); -} diff --git a/tools/chdr-dissector/plugin.rc.in b/tools/chdr-dissector/plugin.rc.in deleted file mode 100644 index f9d714704..000000000 --- a/tools/chdr-dissector/plugin.rc.in +++ /dev/null @@ -1,34 +0,0 @@ -#include "winver.h" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION @RC_MODULE_VERSION@ - PRODUCTVERSION @RC_VERSION@ - FILEFLAGSMASK 0x0L -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0 -#endif - FILEOS VOS_NT_WINDOWS32 - FILETYPE VFT_DLL -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "Ettus Research LLC\0" - VALUE "FileDescription", "@PACKAGE@ dissector\0" - VALUE "FileVersion", "@MODULE_VERSION@\0" - VALUE "InternalName", "@PACKAGE@ @MODULE_VERSION@\0" - VALUE "LegalCopyright", "Copyright © 2013 Ettus Research LLC\0" - VALUE "OriginalFilename", "@PLUGIN_NAME@.dll\0" - VALUE "ProductName", "Wireshark\0" - VALUE "ProductVersion", "@VERSION@\0" - VALUE "Comments", "Build with @MSVC_VARIANT@\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END |