diff options
Diffstat (limited to 'tools')
l--------- | tools/zpu-dissector/cmake | 1 | ||||
-rw-r--r-- | tools/zpu-dissector/cmake/Modules/FindGLIB2.cmake | 238 | ||||
-rw-r--r-- | tools/zpu-dissector/cmake/Modules/FindWireshark.cmake | 28 | ||||
l---------[-rwxr-xr-x] | tools/zpu-dissector/make-dissector-reg.py | 306 | ||||
-rw-r--r-- | tools/zpu-dissector/packet-zpu.c | 70 | ||||
-rw-r--r-- | tools/zpu-dissector/zpu_addr_names.h | 38 |
6 files changed, 89 insertions, 592 deletions
diff --git a/tools/zpu-dissector/cmake b/tools/zpu-dissector/cmake new file mode 120000 index 000000000..ec7b5e3b5 --- /dev/null +++ b/tools/zpu-dissector/cmake @@ -0,0 +1 @@ +../chdr-dissector/cmake
\ No newline at end of file diff --git a/tools/zpu-dissector/cmake/Modules/FindGLIB2.cmake b/tools/zpu-dissector/cmake/Modules/FindGLIB2.cmake deleted file mode 100644 index ae7baddbb..000000000 --- a/tools/zpu-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/zpu-dissector/cmake/Modules/FindWireshark.cmake b/tools/zpu-dissector/cmake/Modules/FindWireshark.cmake deleted file mode 100644 index 59497da16..000000000 --- a/tools/zpu-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_info.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/zpu-dissector/make-dissector-reg.py b/tools/zpu-dissector/make-dissector-reg.py index 44972909b..cad30999e 100755..120000 --- a/tools/zpu-dissector/make-dissector-reg.py +++ b/tools/zpu-dissector/make-dissector-reg.py @@ -1,305 +1 @@ -#!/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) - - +../chdr-dissector/make-dissector-reg.py
\ No newline at end of file diff --git a/tools/zpu-dissector/packet-zpu.c b/tools/zpu-dissector/packet-zpu.c index 4bff97912..b6192c275 100644 --- a/tools/zpu-dissector/packet-zpu.c +++ b/tools/zpu-dissector/packet-zpu.c @@ -1,8 +1,7 @@ -/* - * packet-chdr.c - * Dissector for UHD CHDR packets +/* + * Dissector for ZPU packets (communication with X300 firmware) * - * Copyright 2010-2013 Ettus Research LLC + * Copyright 2013-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 @@ -19,12 +18,27 @@ * */ +/* Format of ZPU packets is defined in x300_fw_commons.h, + * x300_fw_comms_t. + * + * Reminder: + * + * uint32_t flags; (ack, error, peek, poke) + * uint32_t sequence; + * uint32_t addr; + * uint32_t data; + */ + #include "config.h" #include <glib.h> #include <epan/packet.h> #include <ctype.h> #include <stdio.h> +#include <endian.h> + +#include "../../host/lib/usrp/x300/x300_fw_common.h" +#include "zpu_addr_names.h" #define LOG_HEADER "[ZPU] " @@ -32,7 +46,7 @@ #define min(a,b) ((a<b)?a:b) #endif // min -const unsigned int FW_PORT = 49152; +const unsigned int FW_PORT = X300_FW_COMMS_UDP_PORT; static int proto_zpu = -1; static int hf_zpu_flags = -1; @@ -44,6 +58,7 @@ static int hf_zpu_seq = -1; static int hf_zpu_addr = -1; static int hf_zpu_data = -1; static int hf_zpu_shmem_addr = -1; +static int hf_zpu_shmem_addr_name = -1; /* Subtree handles: set by register_subtree_array */ static gint ett_zpu = -1; @@ -63,15 +78,15 @@ static void dissect_zpu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *flags_item; proto_tree *flags_tree; gint len; - + gboolean is_network; gint endianness; - - if(pinfo->match_uint == FW_PORT){ + + if (pinfo->match_uint == FW_PORT) { is_network = TRUE; endianness = ENC_BIG_ENDIAN; } - else{ + else { is_network = FALSE; endianness = ENC_LITTLE_ENDIAN; } @@ -79,16 +94,18 @@ static void dissect_zpu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) len = tvb_reported_length(tvb); col_append_str(pinfo->cinfo, COL_PROTOCOL, "/ZPU"); - col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "ZPU", tvb_format_text_wsp(tvb, 0, len)); + /*col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "ZPU", tvb_format_text_wsp(tvb, 0, len));*/ + col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "ZPU"); if (tree) { item = proto_tree_add_item(tree, proto_zpu, tvb, 0, min(16, len), ENC_NA); - + + // Dissect 'flags' if (len >= 4) { zpu_tree = proto_item_add_subtree(item, ett_zpu); - + flags_item = proto_tree_add_item(zpu_tree, hf_zpu_flags, tvb, 0, 4, endianness); flags_tree = proto_item_add_subtree(flags_item, ett_zpu_flags); @@ -96,28 +113,39 @@ static void dissect_zpu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(flags_tree, hf_zpu_flags_error, tvb, 0, 4, ENC_NA); proto_tree_add_item(flags_tree, hf_zpu_flags_poke, tvb, 0, 4, ENC_NA); proto_tree_add_item(flags_tree, hf_zpu_flags_peek, tvb, 0, 4, ENC_NA); - + + // Dissect 'sequence number' if (len >= 8) { proto_tree_add_item(zpu_tree, hf_zpu_seq, tvb, 4, 4, ENC_NA); - + + // Dissect 'address' if (len >= 12) { proto_tree_add_item(zpu_tree, hf_zpu_addr, tvb, 8, 4, ENC_NA); - + guint8 *bytes = tvb_get_string(tvb, 8, 4); unsigned int addr = 0; memcpy(&addr, bytes, 4); - const unsigned int shmmem_base = 0x6000; + /* TODO proper endianness handling */ addr = (addr >> 24) | ((addr & 0x00FF0000) >> 8) | ((addr & 0x0000FF00) << 8) | ((addr & 0x000000FF) << 24); - if (addr >= shmmem_base) + /* TODO check the actual size of shmem instead of this constant */ + if (addr >= X300_FW_SHMEM_BASE && addr <= X300_FW_SHMEM_BASE + 0x2000) { - addr -= 0x6000; + proto_item *shmem_addr_item = NULL; + + // Convert the address to a register number (32-bit registers == 4-byte registers) + addr -= X300_FW_SHMEM_BASE; addr /= 4; - - proto_tree_add_uint(zpu_tree, hf_zpu_shmem_addr, tvb, 8, 4, addr); + + shmem_addr_item = proto_tree_add_uint(zpu_tree, hf_zpu_shmem_addr, tvb, 8, 4, addr); + proto_item_append_text(shmem_addr_item, ", Register name: %s", + val_to_str(addr, X300_SHMEM_NAMES, "Unknown (0x%04x)") + ); + } - + + // Dissect 'data' if (len >= 16) { proto_tree_add_item(zpu_tree, hf_zpu_data, tvb, 12, 4, ENC_NA); diff --git a/tools/zpu-dissector/zpu_addr_names.h b/tools/zpu-dissector/zpu_addr_names.h new file mode 100644 index 000000000..ebbf423ed --- /dev/null +++ b/tools/zpu-dissector/zpu_addr_names.h @@ -0,0 +1,38 @@ +/* + * Dissector for ZPU packets (communication with X300 firmware) + * + * Copyright 2013-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/>. + * + */ + +/* TODO: autogenerate this file */ + +/* Names of SHMEM registers: */ +static const value_string X300_SHMEM_NAMES[] = { + { 0, "X300_FW_SHMEM_COMPAT_NUM" }, + { 1, "X300_FW_SHMEM_GPSDO_STATUS" }, + { 2, "X300_FW_SHMEM_UART_RX_INDEX" }, + { 3, "X300_FW_SHMEM_UART_TX_INDEX" }, + { 5, "X300_FW_SHMEM_CLAIM_STATUS" }, + { 6, "X300_FW_SHMEM_CLAIM_TIME" }, + { 7, "X300_FW_SHMEM_CLAIM_SRC" }, + { 8, "X300_FW_SHMEM_UART_RX_ADDR" }, + { 9, "X300_FW_SHMEM_UART_TX_ADDR" }, + { 10, "X300_FW_SHMEM_UART_WORDS32" }, + { 11, "X300_FW_SHMEM_ROUTE_MAP_ADDR" }, + { 12, "X300_FW_SHMEM_ROUTE_MAP_LEN" } +}; + |