diff options
author | Peter Wu <lekensteyn@gmail.com> | 2012-12-16 22:47:45 +0100 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2013-11-30 12:44:38 +0100 |
commit | 300ae01b643628340d0125f6a87edb8685bfe1b2 (patch) | |
tree | fda9c69a1c5001188fade423ac196acf3f61b2a0 | |
parent | 0e1a1c746a4e2a9e607121219f115de45bf49c78 (diff) | |
download | wireshark-300ae01b643628340d0125f6a87edb8685bfe1b2.tar.gz |
ALOT WIP
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | configure.in | 1 | ||||
-rw-r--r-- | epan/Makefile.am | 1 | ||||
-rw-r--r-- | plugins/Makefile.am | 1 | ||||
-rw-r--r-- | plugins/alot/Custom.m4 | 5 | ||||
-rw-r--r-- | plugins/alot/Custom.make | 13 | ||||
-rw-r--r-- | plugins/alot/Makefile.am | 129 | ||||
-rw-r--r-- | plugins/alot/Makefile.common | 39 | ||||
-rw-r--r-- | plugins/alot/moduleinfo.h | 52 | ||||
-rw-r--r-- | plugins/alot/packet-alot.c | 132 |
10 files changed, 374 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 59fd8b0feb..1a2e8ef6a3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -273,6 +273,7 @@ PLATFORM_SRC = capture-pcap-util-unix.c if HAVE_PLUGINS -include plugins/Custom.make plugin_ldadd = $(_CUSTOM_plugin_ldadd_) \ + -dlopen plugins/alot/alot.la \ -dlopen plugins/asn1/asn1.la \ -dlopen plugins/docsis/docsis.la \ -dlopen plugins/ethercat/ethercat.la \ diff --git a/configure.in b/configure.in index c758319366..d6a96a5176 100644 --- a/configure.in +++ b/configure.in @@ -2095,6 +2095,7 @@ AC_OUTPUT( packaging/svr4/checkinstall packaging/svr4/pkginfo plugins/Makefile + plugins/alot/Makefile plugins/asn1/Makefile plugins/docsis/Makefile plugins/ethercat/Makefile diff --git a/epan/Makefile.am b/epan/Makefile.am index 001f5e8b43..1e40628b30 100644 --- a/epan/Makefile.am +++ b/epan/Makefile.am @@ -208,6 +208,7 @@ if HAVE_PLUGINS if ENABLE_STATIC -include ../plugins/Custom.make plugin_src = \ + ../plugins/alot/packet-alot.c \ ../plugins/asn1/packet-asn1.c \ ../plugins/docsis/packet-bintrngreq.c \ ../plugins/docsis/packet-bpkmattr.c \ diff --git a/plugins/Makefile.am b/plugins/Makefile.am index c895d0ebd4..44bb17260d 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -23,6 +23,7 @@ -include Custom.make SUBDIRS = $(_CUSTOM_SUBDIRS_) \ + alot \ asn1 \ docsis \ ethercat \ diff --git a/plugins/alot/Custom.m4 b/plugins/alot/Custom.m4 new file mode 100644 index 0000000000..fdaa07f487 --- /dev/null +++ b/plugins/alot/Custom.m4 @@ -0,0 +1,5 @@ +# +# $Id: Custom.m4.example 45172 2012-09-27 11:39:54Z etxrab $ +# + +m4_define([_CUSTOM_AC_OUTPUT_], [plugins/alot/Makefile]) diff --git a/plugins/alot/Custom.make b/plugins/alot/Custom.make new file mode 100644 index 0000000000..6cab64b73e --- /dev/null +++ b/plugins/alot/Custom.make @@ -0,0 +1,13 @@ +# +# $Id: Custom.make.example 45172 2012-09-27 11:39:54Z etxrab $ +# + +_CUSTOM_SUBDIRS_ = \ + alot + +_CUSTOM_EXTRA_DIST_ = \ + Custom.m4 \ + Custom.make + +_CUSTOM_plugin_ldadd_ = \ + -dlopen plugins/alot/alot.la diff --git a/plugins/alot/Makefile.am b/plugins/alot/Makefile.am new file mode 100644 index 0000000000..44ebc4cd6b --- /dev/null +++ b/plugins/alot/Makefile.am @@ -0,0 +1,129 @@ +# Makefile.am +# Automake file for M2M plugin +# +# $Id: Makefile.am 42972 2012-06-01 14:44:35Z wmeier $ +# +# 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$(includedir) + +include Makefile.common + +if HAVE_WARNINGS_AS_ERRORS +AM_CFLAGS = -Werror +endif + +plugindir = @plugindir@ + +plugin_LTLIBRARIES = alot.la +alot_la_SOURCES = \ + plugin.c \ + moduleinfo.h \ + $(DISSECTOR_SRC) \ + $(DISSECTOR_SUPPORT_SRC) \ + $(DISSECTOR_INCLUDES) +alot_la_LDFLAGS = -module -avoid-version +alot_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 = + +# +# Build plugin.c, which contains the plugin version[] string, a +# function plugin_register() that calls the register routines for all +# protocols, and a function plugin_reg_handoff() that calls the handoff +# registration routines for all protocols. +# +# We do this by scanning sources. If that turns out to be too slow, +# maybe we could just require every .o file to have an register routine +# of a given name (packet-aarp.o -> proto_register_aarp, etc.). +# +# Formatting conventions: The name of the proto_register_* routines an +# proto_reg_handoff_* routines must start in column zero, or must be +# preceded only by "void " starting in column zero, and must not be +# inside #if. +# +# DISSECTOR_SRC is assumed to have all the files that need to be scanned. +# +# For some unknown reason, having a big "for" loop in the Makefile +# to scan all the files doesn't work with some "make"s; they seem to +# pass only the first few names in the list to the shell, for some +# reason. +# +# Therefore, we have a script to generate the plugin.c file. +# The shell script runs slowly, as multiple greps and seds are run +# for each input file; this is especially slow on Windows. Therefore, +# if Python is present (as indicated by PYTHON being defined), we run +# a faster Python script to do that work instead. +# +# The first argument is the directory in which the source files live. +# The second argument is "plugin", to indicate that we should build +# a plugin.c file for a plugin. +# All subsequent arguments are the files to scan. +# +plugin.c: $(DISSECTOR_SRC) Makefile.common $(top_srcdir)/tools/make-dissector-reg \ + $(top_srcdir)/tools/make-dissector-reg.py + @if test -n "$(PYTHON)"; then \ + echo Making plugin.c with python ; \ + $(PYTHON) $(top_srcdir)/tools/make-dissector-reg.py $(srcdir) \ + plugin $(DISSECTOR_SRC) ; \ + else \ + echo Making plugin.c with shell script ; \ + $(top_srcdir)/tools/make-dissector-reg $(srcdir) \ + $(plugin_src) plugin $(DISSECTOR_SRC) ; \ + fi + +# +# Currently plugin.c can be included in the distribution because +# we always build all protocol dissectors. We used to have to check +# whether or not to build the snmp dissector. If we again need to +# variably build something, making plugin.c non-portable, uncomment +# the dist-hook line below. +# +# Oh, yuk. We don't want to include "plugin.c" in the distribution, as +# its contents depend on the configuration, and therefore we want it +# to be built when the first "make" is done; however, Automake insists +# on putting *all* source into the distribution. +# +# We work around this by having a "dist-hook" rule that deletes +# "plugin.c", so that "dist" won't pick it up. +# +#dist-hook: +# @rm -f $(distdir)/plugin.c + +CLEANFILES = \ + alot \ + *~ + +MAINTAINERCLEANFILES = \ + Makefile.in \ + plugin.c + +EXTRA_DIST = \ + Makefile.common \ + Makefile.nmake \ + moduleinfo.nmake \ + plugin.rc.in \ + CMakeLists.txt + +checkapi: + $(PERL) $(top_srcdir)/tools/checkAPIs.pl -g abort -g termoutput -build $(DISSECTOR_SRC) $(DISSECTOR_INCLUDES) diff --git a/plugins/alot/Makefile.common b/plugins/alot/Makefile.common new file mode 100644 index 0000000000..331e01f96c --- /dev/null +++ b/plugins/alot/Makefile.common @@ -0,0 +1,39 @@ +# Makefile.common for M2M plugin +# Contains the stuff from Makefile.am and Makefile.nmake that is +# a) common to both files and +# b) portable between both files +# +# $Id: Makefile.common 22435 2007-08-01 17:42:43Z jake $ +# +# 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. + +# the name of the plugin +PLUGIN_NAME = alot + +# the dissector sources (without any helpers) +DISSECTOR_SRC = \ + packet-alot.c + +# corresponding headers +DISSECTOR_INCLUDES = + +# Dissector helpers. They're included in the source files in this +# directory, but they're not dissectors themselves, i.e. they're not +# used to generate "register.c"). +DISSECTOR_SUPPORT_SRC = diff --git a/plugins/alot/moduleinfo.h b/plugins/alot/moduleinfo.h new file mode 100644 index 0000000000..d3871c368d --- /dev/null +++ b/plugins/alot/moduleinfo.h @@ -0,0 +1,52 @@ +/* moduleinfo.h + * + * Copyright (c) 2007 by Intel Corporation. + * + * Author: Lu Pan + * + * $Id: moduleinfo.h 21945 2007-05-25 23:40:42Z gerald $ + * + * 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 "alot" + + +#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.0." stringize(BUILD_NUMBER) + diff --git a/plugins/alot/packet-alot.c b/plugins/alot/packet-alot.c new file mode 100644 index 0000000000..e8d79376b0 --- /dev/null +++ b/plugins/alot/packet-alot.c @@ -0,0 +1,132 @@ +#include "config.h" +#include <epan/packet.h> + +#define ALOT_PORT 4107 + +static int proto_alot = -1; +static int alot_messages = -1; + +static int hf_roomid = -1; +static int hf_seq_no = -1; +static int hf_mcount = -1; +static int hf_alot_messages = -1; +static int hf_mtype = -1; +static int hf_msize = -1; +static gint ett_alot = -1; +static gint ett_alot_messages = -1; + +static const guint8 ALOT_MAGIC[] = { 'A', 'L', 'O', 'T' }; + +static void +dissect_alot(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + gint pktlen = tvb_length_remaining(tvb, 0); + + if (tvb_memeql(tvb, 0, ALOT_MAGIC, 4) != 0) + return; + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "ALOT"); + /* Clear out stuff in the info column */ + col_clear(pinfo->cinfo, COL_INFO); + + if (pktlen < 8 + 4) { + /* need at least packet header + msg */ + proto_tree_add_text(tree, tvb, 0, -1, "MALFORMED (header too short)"); + return; + } + + if (tree) { /* we are being asked for details */ + proto_item *ti = NULL, *mt_item = NULL; + proto_item *ti_messages = NULL; + proto_tree *alot_tree = NULL; + proto_tree *messages_tree = NULL; + guint8 mcount, i, pos; + + /* root */ + ti = proto_tree_add_item(tree, proto_alot, tvb, 0, -1, ENC_NA); + alot_tree = proto_item_add_subtree(ti, ett_alot); + + /* packet headers */ + proto_tree_add_item(alot_tree, hf_roomid, tvb, 4, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(alot_tree, hf_seq_no, tvb, 6, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(alot_tree, hf_mcount, tvb, 7, 1, ENC_BIG_ENDIAN); + mcount = tvb_get_guint8(tvb, 7); + + /* messages */ + pos = 8; + //ti_messages = proto_tree_add_item(alot_tree, alot_messages, tvb, pos, -1, ENC_NA); + mt_item = proto_tree_add_item(alot_tree, hf_alot_messages, tvb, 0, -1, ENC_NA); + messages_tree = proto_item_add_subtree(mt_item, ett_alot_messages); + for (i = 0; i < mcount; i++) { + proto_tree_add_item(messages_tree, hf_mtype, tvb, pos, 1, ENC_BIG_ENDIAN); + pos++; + proto_tree_add_item(messages_tree, hf_msize, tvb, pos, 3, ENC_BIG_ENDIAN); + pos += 3; + } + } +} + +void +proto_register_alot(void) +{ + static hf_register_info hf[] = { + { &hf_roomid, + { "Room ID", "alot.roomid", + FT_UINT16, BASE_HEX, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_seq_no, + { "Sequence Number", "alot.seqno", + FT_UINT8, BASE_HEX, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_mcount, + { "Messages count", "alot.mcount", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_alot_messages, + { "Messages", "alot.messages", + FT_NONE, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_mtype, + { "Message type", "alot.mtype", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_msize, + { "Message length", "alot.mlen", + FT_UINT24, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + }; + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_alot, + &ett_alot_messages + }; + + proto_alot = proto_register_protocol( + "ALOT Application Layer Protocol", + "AALP", + "alot" + ); + proto_register_field_array(proto_alot, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); +} + +void +proto_reg_handoff_alot(void) +{ + static dissector_handle_t alot_handle; + alot_handle = create_dissector_handle(dissect_alot, proto_alot); + dissector_add_uint("udp.port", ALOT_PORT, alot_handle); + dissector_add_uint("tcp.port", ALOT_PORT, alot_handle); +} |