From 58d00bad1a2c4298bd58013e4808899feb657422 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 14 Feb 2016 17:00:38 -0800 Subject: Build the extcap programs in the extcap directory. That lets the version of Wireshark built with autotools find the extcap programs. Don't install the extcap programs under ${datadir} - that puts it under a share directory, and share directories are for platform-independent files, which executable images aren't (they're instruction-set dependent, hence platform-dependent). Change-Id: I992eeb984bdbe6b3476777f7114628c83df6080f Reviewed-on: https://code.wireshark.org/review/13943 Reviewed-by: Guy Harris --- CMakeLists.txt | 7 +- Makefile.am | 61 +--- Makefile.common | 23 +- Makefile.nmake | 11 +- configure.ac | 6 +- extcap/Makefile.am | 74 ++++ extcap/Makefile.common | 34 ++ extcap/Makefile.nmake | 143 ++++++++ extcap/randpktdump.c | 2 +- packaging/macosx/osx-app.sh | 59 +++- randpkt-core.c | 813 ------------------------------------------- randpkt-core.h | 84 ----- randpkt.c | 4 +- randpkt_core/CMakeLists.txt | 47 +++ randpkt_core/Makefile.am | 73 ++++ randpkt_core/Makefile.common | 28 ++ randpkt_core/Makefile.nmake | 78 +++++ randpkt_core/doxygen.cfg.in | 81 +++++ randpkt_core/randpkt_core.c | 813 +++++++++++++++++++++++++++++++++++++++++++ randpkt_core/randpkt_core.h | 84 +++++ 20 files changed, 1538 insertions(+), 987 deletions(-) create mode 100644 extcap/Makefile.am create mode 100644 extcap/Makefile.common create mode 100644 extcap/Makefile.nmake delete mode 100644 randpkt-core.c delete mode 100644 randpkt-core.h create mode 100644 randpkt_core/CMakeLists.txt create mode 100644 randpkt_core/Makefile.am create mode 100644 randpkt_core/Makefile.common create mode 100644 randpkt_core/Makefile.nmake create mode 100644 randpkt_core/doxygen.cfg.in create mode 100644 randpkt_core/randpkt_core.c create mode 100644 randpkt_core/randpkt_core.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ecba8a1ecb..dde0c995a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1018,6 +1018,7 @@ add_subdirectory( caputils ) add_subdirectory( codecs ) add_subdirectory( docbook ) add_subdirectory( epan ) +add_subdirectory( randpkt_core ) add_subdirectory( tools/lemon ) add_subdirectory( ui ) add_subdirectory( wiretap ) @@ -1205,6 +1206,7 @@ set( IN_FILES packaging/macosx/Info.plist.in packaging/macosx/osx-dmg.sh.in packaging/macosx/Wireshark_package.pmdoc/index.xml.in + randpkt_core/doxygen.cfg.in ui/doxygen.cfg.in ui/gtk/doxygen.cfg.in ui/qt/doxygen.cfg.in @@ -1231,6 +1233,7 @@ link_directories( ${CMAKE_BINARY_DIR}/caputils ${CMAKE_BINARY_DIR}/codecs ${CMAKE_BINARY_DIR}/epan + ${CMAKE_BINARY_DIR}/randpkt_core ${CMAKE_BINARY_DIR}/wiretap ${CMAKE_BINARY_DIR}/wsutil ) @@ -2146,6 +2149,7 @@ endif() if(BUILD_randpkt) set(randpkt_LIBS + randpkt_core wiretap wsutil ${M_LIBRARIES} @@ -2158,7 +2162,6 @@ if(BUILD_randpkt) ) set(randpkt_FILES randpkt.c - randpkt-core.c ) add_executable(randpkt ${randpkt_FILES}) set_extra_executable_properties(randpkt "Executables") @@ -2398,13 +2401,13 @@ endif() if(BUILD_randpktdump) set(randpktdump_LIBS + randpkt_core wiretap ${GLIB2_LIBRARIES} ${CMAKE_DL_LIBS} ) set(randpktdump_FILES extcap/randpktdump.c - randpkt-core.c ) add_executable(randpktdump WIN32 ${randpktdump_FILES}) diff --git a/Makefile.am b/Makefile.am index 617db111ec..1976a2bfd2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,14 +45,11 @@ bin_PROGRAMS = \ @dumpcap_bin@ \ @reordercap_bin@ \ @rawshark_bin@ \ - @androiddump_bin@ \ - @sshdump_bin@ \ - @randpktdump_bin@ \ @echld_test_bin@ -EXTRA_PROGRAMS = wireshark-gtk wireshark tshark tfshark capinfos captype editcap \ - mergecap dftest randpkt text2pcap dumpcap reordercap rawshark androiddump \ - sshdump randpktdump echld_test +EXTRA_PROGRAMS = wireshark-gtk wireshark tshark tfshark capinfos captype \ + editcap mergecap dftest randpkt text2pcap dumpcap reordercap \ + rawshark echld_test # # Wireshark configuration files are put in $(pkgdatadir). @@ -528,46 +525,6 @@ rawshark_LDADD = \ @LIBGNUTLS_LIBS@ \ @LIBSMI_LDFLAGS@ -if ENABLE_STATIC -androiddump_LDFLAGS = -Wl,-static -all-static -else -androiddump_LDFLAGS = -export-dynamic -endif - -# Libraries and plugin flags with which to link androiddump. -androiddump_LDADD = \ - wiretap/libwiretap.la \ - wsutil/libwsutil.la \ - @GLIB_LIBS@ \ - @SOCKET_LIBS@ - -if ENABLE_STATIC - sshdump_LDFLAGS = -Wl,-static -all-static -else - sshdump_LDFLAGS = -export-dynamic -endif - -# Libraries and plugin flags with which to link sshdump. -sshdump_LDADD = \ - wiretap/libwiretap.la \ - wsutil/libwsutil.la \ - @GLIB_LIBS@ \ - @LIBSSH_LIBS@ \ - @SOCKET_LIBS@ - -if ENABLE_STATIC - randpktdump_LDFLAGS = -Wl,-static -all-static -else - randpktdump_LDFLAGS = -export-dynamic -endif - -# Libraries and plugin flags with which to link randpktdump. -randpktdump_LDADD = \ - wiretap/libwiretap.la \ - wsutil/libwsutil.la \ - @GLIB_LIBS@ \ - @SOCKET_LIBS@ - # Libraries with which to link text2pcap. text2pcap_LDADD = \ wsutil/libwsutil.la \ @@ -612,6 +569,7 @@ reordercap_LDADD = \ # Libraries with which to link randpkt. randpkt_LDADD = \ + randpkt_core/librandpkt_core.a \ wiretap/libwiretap.la \ wsutil/libwsutil.la \ @GLIB_LIBS@ \ @@ -1407,9 +1365,11 @@ DIST_SUBDIRS = \ help \ packaging \ plugins \ + randpkt_core \ tools \ wiretap \ wsutil \ + extcap \ docbook SUBDIRS = \ @@ -1426,6 +1386,8 @@ SUBDIRS = \ ui \ @wireshark_SUBDIRS@ \ ui/cli \ + randpkt_core \ + extcap \ . \ doc @@ -1638,7 +1600,10 @@ osx-app: $(PROGRAMS) $(SCRIPTS) $(MANS) $(DATA) packaging/macosx/Info.plist cd $(srcdir)/packaging/macosx ; \ ./osx-app.sh @OSX_APP_FLAGS@ \ --create-bundle \ - --binary-path ../staging/$(PACKAGE).inst$(bindir) ; \ + --binary-path ../staging/$(PACKAGE).inst$(bindir) \ + --plugin-path ../staging/$(PACKAGE).inst$(plugindir) \ + --extcap-path ../staging/$(PACKAGE).inst$(extcapdir) \ + --library-path ../staging/$(PACKAGE).inst$(libdir) ; \ else \ echo "Error: OS X packaging tools not found." ; \ echo "Package build abandoned." ; \ @@ -1694,6 +1659,7 @@ checkapi: checkapi_local cd epan/dissectors && $(MAKE) checkapi cd epan/dissectors/dcerpc && $(MAKE) checkapi cd plugins && $(MAKE) checkapi + cd randpkt_core && $(MAKE) checkapi cd wsutil && $(MAKE) checkapi wsar_html: doxygen.cfg doxygen_global.cfg FORCE @@ -1702,6 +1668,7 @@ if HAVE_DOXYGEN cd epan && $(MAKE) $@ cd capchild && $(MAKE) $@ cd caputils && $(MAKE) $@ + cd randpkt_core && $(MAKE) $@ cd ui && $(MAKE) $@ (umask 022 ; $(DOXYGEN) doxygen.cfg) endif diff --git a/Makefile.common b/Makefile.common index 0f9e7e721b..9a7b401ccd 100644 --- a/Makefile.common +++ b/Makefile.common @@ -95,19 +95,6 @@ rawshark_SOURCES = \ $(SHARK_COMMON_SRC) \ rawshark.c -# androiddump specifics -androiddump_SOURCES = \ - extcap/androiddump.c - -# sshdump specifics -sshdump_SOURCES = \ - extcap/sshdump.c - -# randpktdump specifics -randpktdump_SOURCES = \ - randpkt-core.c \ - extcap/randpktdump.c - # text2pcap specifics text2pcap_SOURCES = \ pcapio.c \ @@ -155,12 +142,7 @@ echld_test_SOURCES = \ # randpkt specifics randpkt_SOURCES = \ - randpkt.c \ - randpkt-core.c - -# corresponding headers -randpkt_INCLUDES = \ - randpkt-core.h + randpkt.c # dumpcap specifics dumpcap_SOURCES = \ @@ -184,5 +166,4 @@ dumpcap_INCLUDES = \ noinst_HEADERS = \ $(SHARK_COMMON_INCLUDES) \ $(WIRESHARK_COMMON_INCLUDES) \ - $(dumpcap_INCLUDES) \ - $(randpkt_INCLUDES) + $(dumpcap_INCLUDES) diff --git a/Makefile.nmake b/Makefile.nmake index 14875c4a6b..b1fd6f504d 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -187,7 +187,8 @@ sshdump_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \ wsutil\libwsutil.lib \ $(LIBSSH_LIBS) \ -randpktdump_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \ +randpktdump_LIBS= randpkt_core\randpkt_core.lib \ + wiretap\wiretap-$(WTAP_VERSION).lib \ wsock32.lib user32.lib \ wsutil\libwsutil.lib \ $(GLIB_LIBS) @@ -454,10 +455,10 @@ androiddump.exe : $(LIBS_CHECK) config.h androiddump.obj wsutil\libwsutil.lib wi mt.exe -nologo -manifest "androiddump.exe.manifest" -outputresource:androiddump.exe;1 !ENDIF -randpktdump.exe : $(LIBS_CHECK) config.h randpktdump.obj randpkt-core.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib +randpktdump.exe : $(LIBS_CHECK) config.h randpktdump.obj randpkt_core\randpkt_core.lib wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib @echo Linking $@ $(LINK) @<< - /OUT:randpktdump.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:WINDOWS randpktdump.obj randpkt-core.obj $(randpktdump_LIBS) + /OUT:randpktdump.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:WINDOWS randpktdump.obj $(randpktdump_LIBS) << !IFDEF MANIFEST_INFO_REQUIRED mt.exe -nologo -manifest "randpktdump.exe.manifest" -outputresource:randpktdump.exe;1 @@ -613,7 +614,7 @@ androiddump.obj : extcap/androiddump.c sshdump.obj : extcap/sshdump.c $(CC) $(CFLAGS) -Fd.\ -c $? -randpktdump.obj : extcap/randpktdump.c randpkt-core.c +randpktdump.obj : extcap/randpktdump.c $(CC) $(CFLAGS) -Fd.\ -c $? test-programs: @@ -632,7 +633,7 @@ clean-local: reordercap.obj nio-ie5.obj update.obj \ text2pcap-scanner.obj text2pcap-scanner.c \ config.h ps.c $(LIBS_CHECK) \ - dftest.obj dftest.exe randpkt.obj randpkt-core.obj randpkt.exe \ + dftest.obj dftest.exe randpkt.obj randpkt.exe \ doxygen.cfg \ $(RESOURCES) libwireshark.dll wiretap-$(WTAP_VERSION).dll \ libwscodecs.lib libwsutil.dll \ diff --git a/configure.ac b/configure.ac index 65d05fc7d6..ceb2378bf9 100644 --- a/configure.ac +++ b/configure.ac @@ -3059,8 +3059,8 @@ dnl dnl check whether extcap programs should be enabled and, if they should be, dnl check for extcap directory - stolen from Amanda's configure.ac dnl -dnl we don't wish to expand ${datadir} yet -extcapdir="\${datadir}/wireshark/extcap" +dnl we don't wish to expand ${libdir} yet +extcapdir="\${libdir}/wireshark/extcap" AC_ARG_WITH(extcap, AC_HELP_STRING( [--with-extcap@<:@=DIR@:>@], [use extcap for external capture sources (installed in DIR, if supplied) @<:@default=yes, if possible@:>@]), @@ -3288,6 +3288,7 @@ AC_OUTPUT( epan/nghttp2/Makefile epan/wmem/Makefile epan/wslua/Makefile + extcap/Makefile codecs/Makefile ui/Makefile ui/doxygen.cfg @@ -3324,6 +3325,7 @@ AC_OUTPUT( plugins/wimax/Makefile plugins/wimaxasncp/Makefile plugins/wimaxmacphy/Makefile + randpkt_core/Makefile tools/Makefile tools/lemon/Makefile wiretap/Makefile diff --git a/extcap/Makefile.am b/extcap/Makefile.am new file mode 100644 index 0000000000..08ea26e641 --- /dev/null +++ b/extcap/Makefile.am @@ -0,0 +1,74 @@ +# Makefile.am +# Automake file for extcap tools +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +include ../Makefile.am.inc + +ACLOCAL_AMFLAGS = `../aclocal-flags` + +AM_CPPFLAGS += -I$(top_srcdir)/wiretap + +extcap_PROGRAMS = \ + @androiddump_bin@ \ + @randpktdump_bin@ \ + @sshdump_bin@ + +EXTRA_PROGRAMS = androiddump randpktdump sshdump + +if ENABLE_STATIC +androiddump_LDFLAGS = -Wl,-static -all-static +else +androiddump_LDFLAGS = -export-dynamic +endif + +# Libraries and plugin flags with which to link androiddump. +androiddump_LDADD = \ + ../wiretap/libwiretap.la \ + ../wsutil/libwsutil.la \ + @GLIB_LIBS@ \ + @SOCKET_LIBS@ + +if ENABLE_STATIC + randpktdump_LDFLAGS = -Wl,-static -all-static +else + randpktdump_LDFLAGS = -export-dynamic +endif + +# Libraries and plugin flags with which to link randpktdump. +randpktdump_LDADD = \ + ../randpkt_core/librandpkt_core.a \ + ../wiretap/libwiretap.la \ + ../wsutil/libwsutil.la \ + @GLIB_LIBS@ \ + @SOCKET_LIBS@ + +if ENABLE_STATIC + sshdump_LDFLAGS = -Wl,-static -all-static +else + sshdump_LDFLAGS = -export-dynamic +endif + +# Libraries and plugin flags with which to link sshdump. +sshdump_LDADD = \ + ../wiretap/libwiretap.la \ + ../wsutil/libwsutil.la \ + @GLIB_LIBS@ \ + @LIBSSH_LIBS@ \ + @SOCKET_LIBS@ diff --git a/extcap/Makefile.common b/extcap/Makefile.common new file mode 100644 index 0000000000..e727ea60cc --- /dev/null +++ b/extcap/Makefile.common @@ -0,0 +1,34 @@ +# Makefile.common +# Contains the stuff from Makefile.am and Makefile.nmake that is +# a) common to both files and +# b) portable between both files +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# androiddump specifics +androiddump_SOURCES = \ + androiddump.c + +# randpktdump specifics +randpktdump_SOURCES = \ + randpktdump.c + +# sshdump specifics +sshdump_SOURCES = \ + sshdump.c diff --git a/extcap/Makefile.nmake b/extcap/Makefile.nmake new file mode 100644 index 0000000000..e85096164d --- /dev/null +++ b/extcap/Makefile.nmake @@ -0,0 +1,143 @@ +## Makefile for building wireshark.exe with Microsoft C and nmake +## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake +# +# We "Deploy using XCopy," which is described at +# http://msdn.microsoft.com/en-us/library/ms235291.aspx + +include ..\config.nmake +include ..\Makefile.nmake.inc + +############### no need to modify below this line ######### + +CC = cl +LINK= link + +LDFLAGS = /NOLOGO /INCREMENTAL:NO $(LOCAL_LDFLAGS) + +# We use GENERATED_CFLAGS to get around flex's non-LLP64-compliant output +GENERATED_CFLAGS=\ + $(STANDARD_CFLAGS) \ + /I. /Iwiretap $(GLIB_CFLAGS) \ + $(ZLIB_CFLAGS) /I$(PCAP_DIR)\include $(AIRPCAP_CFLAGS) \ + $(C_ARES_CFLAGS) $(ADNS_CFLAGS) $(GNUTLS_CFLAGS) \ + $(SMI_CFLAGS) $(GEOIP_CFLAGS) $(LIBSSH_CFLAGS) $(WINSPARKLE_CFLAGS) + +CFLAGS=$(WARNINGS_ARE_ERRORS) $(GENERATED_CFLAGS) + +.c.obj:: + $(CC) $(CFLAGS) -Fd.\ -c $< + +include Makefile.common + +androiddump_OBJECTS = $(androiddump_SOURCES:.c=.obj) + +anddroiddump_WSLIBS = \ + ..\wiretap\wiretap-$(WTAP_VERSION).lib \ + ..\wsutil\libwsutil.lib + +androiddump_LIBS = $(anddroiddump_WSLIBS) \ + wsock32.lib user32.lib \ + $(GLIB_LIBS) + +randpktdump_OBJECTS = $(randpktdump_SOURCES:.c=.obj) + +randpktdump_WSLIBS = \ + ..\randpkt_core\randpkt_core.lib \ + ..\wiretap\wiretap-$(WTAP_VERSION).lib \ + ..\wsutil\libwsutil.lib + +randpktdump_LIBS = $(randpktdump_WSLIBS) \ + wsock32.lib user32.lib \ + $(GLIB_LIBS) + +sshdump_OBJECTS = $(sshdump_SOURCES:.c=.obj) + +sshdump_WSLIBS = \ + ..\wiretap\wiretap-$(WTAP_VERSION).lib \ + ..\wsutil\libwsutil.lib + +sshdump_LIBS = $(sshdump_WSLIBS) \ + wsock32.lib user32.lib \ + $(LIBSSH_LIBS) \ + $(GLIB_LIBS) + +EXECUTABLES=androiddump.exe randpktdump.exe + +!IFDEF LIBSSH_DIR +EXECUTABLES += sshdump.exe +!ENDIF + +androiddump.exe : $(LIBS_CHECK) config.h androiddump.obj $(anddroiddump_WSLIBS) + @echo Linking $@ + $(LINK) @<< + /OUT:androiddump.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:WINDOWS androiddump.obj $(androiddump_LIBS) +<< +!IFDEF MANIFEST_INFO_REQUIRED + mt.exe -nologo -manifest "androiddump.exe.manifest" -outputresource:androiddump.exe;1 +!ENDIF + +randpktdump.exe : $(LIBS_CHECK) config.h randpktdump.obj $(randpktdump_WSLIBS) + @echo Linking $@ + $(LINK) @<< + /OUT:randpktdump.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:WINDOWS randpktdump.obj $(randpktdump_LIBS) +<< +!IFDEF MANIFEST_INFO_REQUIRED + mt.exe -nologo -manifest "randpktdump.exe.manifest" -outputresource:randpktdump.exe;1 +!ENDIF + +!IFDEF LIBSSH_DIR +sshdump.exe : $(LIBS_CHECK) config.h sshdump.obj $(sshdump_WSLIBS) + @echo Linking $@ + $(LINK) @<< + /OUT:sshdump.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:WINDOWS sshdump.obj $(sshdump_LIBS) +<< +!IFDEF MANIFEST_INFO_REQUIRED + mt.exe -nologo -manifest "sshdump.exe.manifest" -outputresource:sshdump.exe;1 +!ENDIF +!ENDIF + +clean: + rm -f $(androiddump_OBJECTS) $(randpktdump_OBJECTS) $(sshdump_OBJECTS) \ + $(EXECUTABLES) *.nativecodeanalysis.xml *.pdb *.sbr \ + doxygen.cfg *.exe.manifest + +# "distclean" removes all files not part of the distribution. +# It does not remove generated files that are part of the distribution. +distclean: clean + rm -f $(BUILT_SOURCES) + +# Make "maintainer-clean" only if you would like to remove ALL generated +# files. +# Be sure to have python and perl installed to regenerate them. +maintainer-clean: distclean + +# convert doxygen.cfg.in to doxygen.cfg with stamped version info +doxygen.cfg: ..\config.nmake doxygen.cfg.in +!IFDEF DOXYGEN + sed -e s/@VERSION@/$(VERSION)/ \ + < doxygen.cfg.in > $@ +!ENDIF + +doxygen-run: +!IFDEF DOXYGEN + $(DOXYGEN) doxygen.cfg +!ENDIF + +# MS html help compiler hhc returns 1 on success, but as nmake expects 0 it would stop here. +# the prepended -1 will raise the accepted error levels of nmake, so it will continue +doxygen.chm: +!IFDEF HHC + -1 $(HHC) html\index.hhp +!ENDIF + +doxygen: doxygen.cfg doxygen-run doxygen.chm + +checkapi: checkapi-base checkapi-todo + +checkapi-base: + $(PERL) ../tools/checkAPIs.pl -g deprecated-gtk -build \ + $(androiddump_SOURCES) $(randpktdump_SOURCES) $(sshdump_SOURCES) + +checkapi-todo: + $(PERL) ../tools/checkAPIs.pl -M -g deprecated-gtk-todo -build \ + $(androiddump_SOURCES) $(randpktdump_SOURCES) $(sshdump_SOURCES) diff --git a/extcap/randpktdump.c b/extcap/randpktdump.c index a36231efa4..a2c7dfbce8 100644 --- a/extcap/randpktdump.c +++ b/extcap/randpktdump.c @@ -24,7 +24,7 @@ #include "config.h" -#include "randpkt-core.h" +#include "randpkt_core/randpkt_core.h" #include #include diff --git a/packaging/macosx/osx-app.sh b/packaging/macosx/osx-app.sh index 82ae000435..be1faadcc8 100755 --- a/packaging/macosx/osx-app.sh +++ b/packaging/macosx/osx-app.sh @@ -1,7 +1,9 @@ #!/bin/bash # # USAGE -# osx-app [-s] [-l /path/to/libraries] -bp /path/to/wireshark/bin -p /path/to/Info.plist +# osx-app [-s] [-l /path/to/libraries] -bp /path/to/wireshark/bin +# -lp /path/to/wireshark/lib -ep /path/to/wireshark/extcap/binaries +# -pp /path/to/wireshark/plugins -p /path/to/Info.plist # # This script attempts to build an Wireshark.app bundle for OS X, resolving # dynamic libraries, etc. @@ -36,6 +38,9 @@ # Defaults strip=false binary_path="/tmp/inst/bin" +library_path="/tmp/inst/lib" +plugin_path="/tmp/inst/lib/wireshark/plugins" +extcap_path="/tmp/inst/lib/wireshark/extcap" plist="./Info.plist" exclude_prefixes="/System/|/Library/|/usr/lib/|/usr/X11/|/opt/X11/|@rpath|@executable_path" create_bundle=false @@ -59,12 +64,14 @@ binary_list=" rawshark text2pcap tshark +" +extcap_binary_list=" extcap/androiddump extcap/randpktdump " if [ -x "extcap/sshdump" ]; then - binary_list="$binary_list extcap/sshdump" + extcap_binary_list="$extcap_binary_list extcap/sshdump" fi cs_binary_list= @@ -103,6 +110,15 @@ OPTIONS -bp,--binary-path Specify the path to the Wireshark binaries. By default it is /tmp/inst/bin. + -lp,--library-path + Specify the path to the Wireshark libraries. By default it + is /tmp/inst/lib. + -pp,--plugin-path + Specify the path to the Wireshark plugins. By default it + is /tmp/inst/lib/wireshark/plugins. + -ep,--extcap-path + Specify the path to the Wireshark extcap binaries. By + default it is /tmp/inst/lib/wireshark/extcap. -p,--plist Specify the path to Info.plist. Info.plist can be found in the base directory of the source code once configure @@ -133,6 +149,15 @@ do -bp|--binary-path) binary_path="$2" shift 1 ;; + -lp|--library-path) + library_path="$2" + shift 1 ;; + -pp|--plugin-path) + plugin_path="$2" + shift 1 ;; + -ep|--extcap-path) + extcap_path="$2" + shift 1 ;; -cb|--create-bundle) create_bundle=true;; -p|--plist) @@ -176,6 +201,14 @@ if [ "$create_bundle" = "true" ]; then fi done + for binary in $extcap_binary_list ; do + binary=$( basename $binary ) + if [ ! -x "$extcap_path/$binary" ]; then + echo "Couldn't find $binary (or it's not executable)" >&2 + exit 1 + fi + done + if [ ! -f "$plist" ]; then echo "Need plist file" >&2 exit 1 @@ -308,29 +341,35 @@ create_bundle() { done elif [ "$ui_toolkit" = "qt" ] ; then for binary in $binary_list ; do - bin_dest="$pkgexec" - if [ "$( dirname $binary )" == "extcap" ] ; then - binary=$( basename $binary ) - bin_dest="$pkgexec/$( dirname $binary )" - fi - # Copy the binary to its destination + bin_dest="$pkgexec" cp -v "$binary_path/$binary" "$bin_dest" cs_binary_list="$cs_binary_list $bin_dest/$binary" done fi + # + # extcap binaries + # + for binary in $extcap_binary_list ; do + # Copy the binary to its destination + binary=$( basename $binary ) + bin_dest="$pkgexec/extcap" + cp -v "$extcap_path/$binary" "$bin_dest" + cs_binary_list="$cs_binary_list $bin_dest/$binary" + done + # The rest of the Wireshark installation (we handled bin above) rsync -av \ --exclude bin/ \ --exclude lib/ \ "$binary_path/.."/* "$pkgres" - rsync -av $binary_path/../lib/*.dylib "$pkglib/" + rsync -av $library_path/*.dylib "$pkglib/" # Copy the plugins from the "make install" location for them # to the plugin directory, removing the version number - find "$binary_path/../lib/wireshark/plugins" \ + find "$plugin_path" \ -type f \ \( -name "*.so" -o -name "*.dylib" \) \ -exec cp -fv "{}" "$pkgplugin/" \; diff --git a/randpkt-core.c b/randpkt-core.c deleted file mode 100644 index 0e997b79fc..0000000000 --- a/randpkt-core.c +++ /dev/null @@ -1,813 +0,0 @@ -/* - * randpkt-core.c - * --------- - * Creates random packet traces. Useful for debugging sniffers by testing - * assumptions about the veracity of the data found in the packet. - * - * Copyright (C) 1999 by Gilbert Ramirez - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "randpkt-core.h" - -#include - -#include -#include -#include -#include -#include "wsutil/file_util.h" - -#ifdef _WIN32 -#include -#endif /* _WIN32 */ - -#define array_length(x) (sizeof x / sizeof x[0]) - -/* Types of produceable packets */ -enum { - PKT_ARP, - PKT_BGP, - PKT_BVLC, - PKT_DNS, - PKT_ETHERNET, - PKT_FDDI, - PKT_GIOP, - PKT_ICMP, - PKT_IP, - PKT_LLC, - PKT_M2M, - PKT_MEGACO, - PKT_NBNS, - PKT_NCP2222, - PKT_SCTP, - PKT_SYSLOG, - PKT_TCP, - PKT_TDS, - PKT_TR, - PKT_UDP, - PKT_USB, - PKT_USB_LINUX -}; - -/* Ethernet, indicating ARP */ -guint8 pkt_arp[] = { - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x00, 0x00, - 0x32, 0x25, 0x0f, 0xff, - 0x08, 0x06 -}; - -/* Ethernet+IP+UDP, indicating DNS */ -guint8 pkt_dns[] = { - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x08, 0x00, - - 0x45, 0x00, 0x00, 0x3c, - 0xc5, 0x9e, 0x40, 0x00, - 0xff, 0x11, 0xd7, 0xe0, - 0xd0, 0x15, 0x02, 0xb8, - 0x0a, 0x01, 0x01, 0x63, - - 0x05, 0xe8, 0x00, 0x35, - 0xff, 0xff, 0x2a, 0xb9, - 0x30 -}; - -/* Ethernet+IP, indicating ICMP */ -guint8 pkt_icmp[] = { - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x08, 0x00, - - 0x45, 0x00, 0x00, 0x54, - 0x8f, 0xb3, 0x40, 0x00, - 0xfd, 0x01, 0x8a, 0x99, - 0xcc, 0xfc, 0x66, 0x0b, - 0xce, 0x41, 0x62, 0x12 -}; - -/* Ethernet, indicating IP */ -guint8 pkt_ip[] = { - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x08, 0x00 -}; - -/* TR, indicating LLC */ -guint8 pkt_llc[] = { - 0x10, 0x40, 0x68, 0x00, - 0x19, 0x69, 0x95, 0x8b, - 0x00, 0x01, 0xfa, 0x68, - 0xc4, 0x67 -}; - -/* Ethernet, indicating WiMAX M2M */ -guint8 pkt_m2m[] = { - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x00, 0x00, - 0x32, 0x25, 0x0f, 0xff, - 0x08, 0xf0 -}; - -/* Ethernet+IP+UDP, indicating NBNS */ -guint8 pkt_nbns[] = { - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x08, 0x00, - - 0x45, 0x00, 0x00, 0x3c, - 0xc5, 0x9e, 0x40, 0x00, - 0xff, 0x11, 0xd7, 0xe0, - 0xd0, 0x15, 0x02, 0xb8, - 0x0a, 0x01, 0x01, 0x63, - - 0x00, 0x89, 0x00, 0x89, - 0x00, 0x00, 0x2a, 0xb9, - 0x30 -}; - -/* Ethernet+IP+UDP, indicating syslog */ -guint8 pkt_syslog[] = { - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x08, 0x00, - - 0x45, 0x00, 0x00, 0x64, - 0x20, 0x48, 0x00, 0x00, - 0xfc, 0x11, 0xf8, 0x03, - 0xd0, 0x15, 0x02, 0xb8, - 0x0a, 0x01, 0x01, 0x63, - - 0x05, 0xe8, 0x02, 0x02, - 0x00, 0x50, 0x51, 0xe1, - 0x3c -}; - -/* TR+LLC+IP, indicating TCP */ -guint8 pkt_tcp[] = { - 0x10, 0x40, 0x68, 0x00, - 0x19, 0x69, 0x95, 0x8b, - 0x00, 0x01, 0xfa, 0x68, - 0xc4, 0x67, - - 0xaa, 0xaa, 0x03, 0x00, - 0x00, 0x00, 0x08, 0x00, - - 0x45, 0x00, 0x00, 0x28, - 0x0b, 0x0b, 0x40, 0x00, - 0x20, 0x06, 0x85, 0x37, - 0xc0, 0xa8, 0x27, 0x01, - 0xc0, 0xa8, 0x22, 0x3c -}; - -/* Ethernet+IP, indicating UDP */ -guint8 pkt_udp[] = { - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x08, 0x00, - - 0x45, 0x00, 0x00, 0x3c, - 0xc5, 0x9e, 0x40, 0x00, - 0xff, 0x11, 0xd7, 0xe0, - 0xd0, 0x15, 0x02, 0xb8, - 0x0a, 0x01, 0x01, 0x63 -}; - -/* Ethernet+IP+UDP, indicating BVLC */ -guint8 pkt_bvlc[] = { - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x08, 0x00, - - 0x45, 0x00, 0x00, 0x3c, - 0xc5, 0x9e, 0x40, 0x00, - 0xff, 0x11, 0x01, 0xaa, - 0xc1, 0xff, 0x19, 0x1e, - 0xc1, 0xff, 0x19, 0xff, - 0xba, 0xc0, 0xba, 0xc0, - 0x00, 0xff, 0x2d, 0x5e, - 0x81 -}; - -/* TR+LLC+IPX, indicating NCP, with NCP Type == 0x2222 */ -guint8 pkt_ncp2222[] = { - 0x10, 0x40, 0x00, 0x00, - 0xf6, 0x7c, 0x9b, 0x70, - 0x68, 0x00, 0x19, 0x69, - 0x95, 0x8b, 0xe0, 0xe0, - 0x03, 0xff, 0xff, 0x00, - 0x25, 0x02, 0x11, 0x00, - 0x00, 0x74, 0x14, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x01, 0x04, 0x51, 0x00, - 0x00, 0x00, 0x04, 0x00, - 0x02, 0x16, 0x19, 0x7a, - 0x84, 0x40, 0x01, 0x22, - 0x22 -}; - -/* Ethernet+IP+TCP, indicating GIOP */ -guint8 pkt_giop[] = { - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x08, 0x00, - - 0x45, 0x00, 0x00, 0xa6, - 0x00, 0x2f, 0x40, 0x00, - 0x40, 0x06, 0x3c, 0x21, - 0x7f, 0x00, 0x00, 0x01, - 0x7f, 0x00, 0x00, 0x01, - - 0x30, 0x39, 0x04, 0x05, - 0xac, 0x02, 0x1e, 0x69, - 0xab, 0x74, 0xab, 0x64, - 0x80, 0x18, 0x79, 0x60, - 0xc4, 0xb8, 0x00, 0x00, - 0x01, 0x01, 0x08, 0x0a, - 0x00, 0x00, 0x48, 0xf5, - 0x00, 0x00, 0x48, 0xf5, - - 0x47, 0x49, 0x4f, 0x50, - 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x30, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x01 -}; - -/* Ethernet+IP+TCP, indicating BGP */ -guint8 pkt_bgp[] = { - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - 0x08, 0x00, - - 0x45, 0x00, 0x00, 0xa6, - 0x00, 0x2f, 0x40, 0x00, - 0x40, 0x06, 0x3c, 0x21, - 0x7f, 0x00, 0x00, 0x01, - 0x7f, 0x00, 0x00, 0x01, - - 0x30, 0x39, 0x00, 0xb3, - 0xac, 0x02, 0x1e, 0x69, - 0xab, 0x74, 0xab, 0x64, - 0x80, 0x18, 0x79, 0x60, - 0xc4, 0xb8, 0x00, 0x00, - 0x01, 0x01, 0x08, 0x0a, - 0x00, 0x00, 0x48, 0xf5, - 0x00, 0x00, 0x48, 0xf5, - - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, -}; - -/* Ethernet+IP+TCP, indicating TDS NetLib */ -guint8 pkt_tds[] = { - 0x00, 0x50, 0x8b, 0x0d, - 0x7a, 0xed, 0x00, 0x08, - 0xa3, 0x98, 0x39, 0x81, - 0x08, 0x00, - - 0x45, 0x00, 0x03, 0x8d, - 0x90, 0xd4, 0x40, 0x00, - 0x7c, 0x06, 0xc3, 0x1b, - 0xac, 0x14, 0x02, 0x22, - 0x0a, 0xc2, 0xee, 0x82, - - 0x05, 0x99, 0x08, 0xf8, - 0xff, 0x4e, 0x85, 0x46, - 0xa2, 0xb4, 0x42, 0xaa, - 0x50, 0x18, 0x3c, 0x28, - 0x0f, 0xda, 0x00, 0x00, -}; - -/* Ethernet+IP, indicating SCTP */ -guint8 pkt_sctp[] = { - 0x00, 0xa0, 0x80, 0x00, - 0x5e, 0x46, 0x08, 0x00, - 0x03, 0x4a, 0x00, 0x35, - 0x08, 0x00, - - 0x45, 0x00, 0x00, 0x7c, - 0x14, 0x1c, 0x00, 0x00, - 0x3b, 0x84, 0x4a, 0x54, - 0x0a, 0x1c, 0x06, 0x2b, - 0x0a, 0x1c, 0x06, 0x2c, -}; - - -/* Ethernet+IP+SCTP, indicating MEGACO */ -guint8 pkt_megaco[] = { - 0x00, 0xa0, 0x80, 0x00, - 0x5e, 0x46, 0x08, 0x00, - 0x03, 0x4a, 0x00, 0x35, - 0x08, 0x00, - - 0x45, 0x00, 0x00, 0x7c, - 0x14, 0x1c, 0x00, 0x00, - 0x3b, 0x84, 0x4a, 0x54, - 0x0a, 0x1c, 0x06, 0x2b, - 0x0a, 0x1c, 0x06, 0x2c, - - 0x40, 0x00, 0x0b, 0x80, - 0x00, 0x01, 0x6f, 0x0a, - 0x6d, 0xb0, 0x18, 0x82, - 0x00, 0x03, 0x00, 0x5b, - 0x28, 0x02, 0x43, 0x45, - 0x00, 0x00, 0xa0, 0xbd, - 0x00, 0x00, 0x00, 0x07, -}; - -/* This little data table drives the whole program */ -static randpkt_example examples[] = { - { "arp", "Address Resolution Protocol", - PKT_ARP, WTAP_ENCAP_ETHERNET, - pkt_arp, array_length(pkt_arp), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "bgp", "Border Gateway Protocol", - PKT_BGP, WTAP_ENCAP_ETHERNET, - pkt_bgp, array_length(pkt_bgp), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "bvlc", "BACnet Virtual Link Control", - PKT_BVLC, WTAP_ENCAP_ETHERNET, - pkt_bvlc, array_length(pkt_bvlc), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "dns", "Domain Name Service", - PKT_DNS, WTAP_ENCAP_ETHERNET, - pkt_dns, array_length(pkt_dns), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "eth", "Ethernet", - PKT_ETHERNET, WTAP_ENCAP_ETHERNET, - NULL, 0, - NULL, 0, - NULL, NULL, - 1000, - }, - - { "fddi", "Fiber Distributed Data Interface", - PKT_FDDI, WTAP_ENCAP_FDDI, - NULL, 0, - NULL, 0, - NULL, NULL, - 1000, - }, - - { "giop", "General Inter-ORB Protocol", - PKT_GIOP, WTAP_ENCAP_ETHERNET, - pkt_giop, array_length(pkt_giop), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "icmp", "Internet Control Message Protocol", - PKT_ICMP, WTAP_ENCAP_ETHERNET, - pkt_icmp, array_length(pkt_icmp), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "ip", "Internet Protocol", - PKT_IP, WTAP_ENCAP_ETHERNET, - pkt_ip, array_length(pkt_ip), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "llc", "Logical Link Control", - PKT_LLC, WTAP_ENCAP_TOKEN_RING, - pkt_llc, array_length(pkt_llc), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "m2m", "WiMAX M2M Encapsulation Protocol", - PKT_M2M, WTAP_ENCAP_ETHERNET, - pkt_m2m, array_length(pkt_m2m), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "megaco", "MEGACO", - PKT_MEGACO, WTAP_ENCAP_ETHERNET, - pkt_megaco, array_length(pkt_megaco), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "nbns", "NetBIOS-over-TCP Name Service", - PKT_NBNS, WTAP_ENCAP_ETHERNET, - pkt_nbns, array_length(pkt_nbns), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "ncp2222", "NetWare Core Protocol", - PKT_NCP2222, WTAP_ENCAP_TOKEN_RING, - pkt_ncp2222, array_length(pkt_ncp2222), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "sctp", "Stream Control Transmission Protocol", - PKT_SCTP, WTAP_ENCAP_ETHERNET, - pkt_sctp, array_length(pkt_sctp), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "syslog", "Syslog message", - PKT_SYSLOG, WTAP_ENCAP_ETHERNET, - pkt_syslog, array_length(pkt_syslog), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "tds", "TDS NetLib", - PKT_TDS, WTAP_ENCAP_ETHERNET, - pkt_tds, array_length(pkt_tds), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "tcp", "Transmission Control Protocol", - PKT_TCP, WTAP_ENCAP_TOKEN_RING, - pkt_tcp, array_length(pkt_tcp), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "tr", "Token-Ring", - PKT_TR, WTAP_ENCAP_TOKEN_RING, - NULL, 0, - NULL, 0, - NULL, NULL, - 1000, - }, - - { "udp", "User Datagram Protocol", - PKT_UDP, WTAP_ENCAP_ETHERNET, - pkt_udp, array_length(pkt_udp), - NULL, 0, - NULL, NULL, - 1000, - }, - - { "usb", "Universal Serial Bus", - PKT_USB, WTAP_ENCAP_USB, - NULL, 0, - NULL, 0, - NULL, NULL, - 1000, - }, - - { "usb-linux", "Universal Serial Bus with Linux specific header", - PKT_USB_LINUX, WTAP_ENCAP_USB_LINUX, - NULL, 0, - NULL, 0, - NULL, NULL, - 1000, - }, - -}; - -guint randpkt_example_count(void) -{ - return array_length(examples); -} - -/* Find pkt_example record and return pointer to it */ -randpkt_example* randpkt_find_example(int type) -{ - int num_entries = array_length(examples); - int i; - - for (i = 0; i < num_entries; i++) { - if (examples[i].produceable_type == type) { - return &examples[i]; - } - } - - fprintf(stderr, "randpkt: Internal error. Type %d has no entry in examples table.\n", - type); - return NULL; -} - -void randpkt_loop(randpkt_example* example, guint64 produce_count) -{ - guint i; - int j; - int err; - int len_random; - int len_this_pkt; - gchar* err_info; - union wtap_pseudo_header* ps_header; - guint8 buffer[65536]; - struct wtap_pkthdr* pkthdr; - - pkthdr = g_new0(struct wtap_pkthdr, 1); - - pkthdr->rec_type = REC_TYPE_PACKET; - pkthdr->presence_flags = WTAP_HAS_TS; - pkthdr->pkt_encap = example->sample_wtap_encap; - - memset(pkthdr, 0, sizeof(struct wtap_pkthdr)); - memset(buffer, 0, sizeof(buffer)); - - ps_header = &pkthdr->pseudo_header; - - /* Load the sample pseudoheader into our pseudoheader buffer */ - if (example->pseudo_buffer) - memcpy(ps_header, example->pseudo_buffer, example->pseudo_length); - - /* Load the sample into our buffer */ - if (example->sample_buffer) - memcpy(buffer, example->sample_buffer, example->sample_length); - - /* Produce random packets */ - for (i = 0; i < produce_count; i++) { - if (example->produce_max_bytes > 0) { - len_random = (rand() % example->produce_max_bytes + 1); - } - else { - len_random = 0; - } - - len_this_pkt = example->sample_length + len_random; - - pkthdr->caplen = len_this_pkt; - pkthdr->len = len_this_pkt; - pkthdr->ts.secs = i; /* just for variety */ - - for (j = example->pseudo_length; j < (int) sizeof(*ps_header); j++) { - ((guint8*)ps_header)[j] = (rand() % 0x100); - } - - for (j = example->sample_length; j < len_this_pkt; j++) { - /* Add format strings here and there */ - if ((int) (100.0*rand()/(RAND_MAX+1.0)) < 3 && j < (len_random - 3)) { - memcpy(&buffer[j], "%s", 3); - j += 2; - } else { - buffer[j] = (rand() % 0x100); - } - } - - if (!wtap_dump(example->dump, pkthdr, buffer, &err, &err_info)) { - fprintf(stderr, "randpkt: Error writing to %s: %s\n", - example->filename, wtap_strerror(err)); - switch (err) { - - case WTAP_ERR_UNWRITABLE_ENCAP: - /* - * This is a problem with the particular - * frame we're writing and the file type - * and subtype we're writing; note that, - * and report the file type/subtype. - */ - fprintf(stderr, - "Frame has a network type that can't be saved in a \"%s\" file.\n", - wtap_file_type_subtype_short_string(WTAP_FILE_TYPE_SUBTYPE_PCAP)); - break; - - case WTAP_ERR_PACKET_TOO_LARGE: - /* - * This is a problem with the particular - * frame we're writing and the file type - * and subtype we're writing; note that, - * and report the file type/subtype. - */ - fprintf(stderr, - "Frame is too large for a \"%s\" file.\n", - wtap_file_type_subtype_short_string(WTAP_FILE_TYPE_SUBTYPE_PCAP)); - break; - - case WTAP_ERR_UNWRITABLE_REC_TYPE: - /* - * This is a problem with the particular - * record we're writing and the file type - * and subtype we're writing; note that, - * and report the file type/subtype. - */ - fprintf(stderr, - "Record has a record type that can't be saved in a \"%s\" file.\n", - wtap_file_type_subtype_short_string(WTAP_FILE_TYPE_SUBTYPE_PCAP)); - break; - - case WTAP_ERR_UNWRITABLE_REC_DATA: - /* - * This is a problem with the particular - * record we're writing and the file type - * and subtype we're writing; note that, - * and report the file type/subtype. - */ - fprintf(stderr, - "Record has data that can't be saved in a \"%s\" file.\n(%s)\n", - wtap_file_type_subtype_short_string(WTAP_FILE_TYPE_SUBTYPE_PCAP), - err_info != NULL ? err_info : "no information supplied"); - g_free(err_info); - break; - - default: - break; - } - } - } - - g_free(pkthdr); -} - -gboolean randpkt_example_close(randpkt_example* example) -{ - int err; - - if (!wtap_dump_close(example->dump, &err)) { - fprintf(stderr, "Error writing to %s: %s\n", - example->filename, wtap_strerror(err)); - return FALSE; - } - return TRUE; -} - -void randpkt_example_init(randpkt_example* example, char* produce_filename, int produce_max_bytes) -{ - int err; - - if (strcmp(produce_filename, "-") == 0) { - /* Write to the standard output. */ - example->dump = wtap_dump_open_stdout(WTAP_FILE_TYPE_SUBTYPE_PCAP, - example->sample_wtap_encap, produce_max_bytes, FALSE /* compressed */, &err); - example->filename = "the standard output"; - } else { - example->dump = wtap_dump_open(produce_filename, WTAP_FILE_TYPE_SUBTYPE_PCAP, - example->sample_wtap_encap, produce_max_bytes, FALSE /* compressed */, &err); - example->filename = produce_filename; - } - if (!example->dump) { - fprintf(stderr, "randpkt: Error writing to %s\n", example->filename); - exit(2); - } - - /* reduce max_bytes by # of bytes already in sample */ - if (produce_max_bytes <= example->sample_length) { - fprintf(stderr, "randpkt: Sample packet length is %d, which is greater than " - "or equal to\n", example->sample_length); - fprintf(stderr, "your requested max_bytes value of %d\n", produce_max_bytes); - exit(1); - } else { - example->produce_max_bytes = produce_max_bytes - example->sample_length; - } -} - -/* Seed the random-number generator */ -void -randpkt_seed(void) -{ - unsigned int randomness; - time_t now; -#ifndef _WIN32 - int fd; - ssize_t ret; - -#define RANDOM_DEV "/dev/urandom" - - /* - * Assume it's at least worth trying /dev/urandom on UN*X. - * If it doesn't exist, fall back on time(). - * - * XXX - Use CryptGenRandom on Windows? - */ - fd = ws_open(RANDOM_DEV, O_RDONLY); - if (fd == -1) { - if (errno != ENOENT) { - fprintf(stderr, - "randpkt: Could not open " RANDOM_DEV " for reading: %s\n", - g_strerror(errno)); - exit(2); - } - goto fallback; - } - - ret = ws_read(fd, &randomness, sizeof randomness); - if (ret == -1) { - fprintf(stderr, - "randpkt: Could not read from " RANDOM_DEV ": %s\n", - g_strerror(errno)); - exit(2); - } - if ((size_t)ret != sizeof randomness) { - fprintf(stderr, - "randpkt: Tried to read %lu bytes from " RANDOM_DEV ", got %ld\n", - (unsigned long)sizeof randomness, (long)ret); - exit(2); - } - srand(randomness); - ws_close(fd); - return; - -fallback: -#endif - now = time(NULL); - randomness = (unsigned int) now; - - srand(randomness); -} - -/* Parse command-line option "type" and return enum type */ -int randpkt_parse_type(char *string) -{ - int num_entries = array_length(examples); - int i; - - /* Called with NULL, choose a random packet */ - if (!string) { - return examples[rand() % num_entries].produceable_type; - } - - for (i = 0; i < num_entries; i++) { - if (g_strcmp0(examples[i].abbrev, string) == 0) { - return examples[i].produceable_type; - } - } - - /* Complain */ - fprintf(stderr, "randpkt: Type %s not known.\n", string); - return -1; -} - -void randpkt_example_list(const char*** abbrev_list, const char*** longname_list, unsigned* list_num) -{ - unsigned i; - *list_num = randpkt_example_count(); - *abbrev_list = g_new0(const char*, *list_num); - *longname_list = g_new0(const char*, *list_num); - for (i = 0; i < *list_num; i++) { - (*abbrev_list)[i] = examples[i].abbrev; - (*longname_list)[i] = examples[i].longname; - } -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=4 tabstop=4 noexpandtab: - * :indentSize=4:tabSize=4:noTabs=false: - */ diff --git a/randpkt-core.h b/randpkt-core.h deleted file mode 100644 index ae17fd8cfb..0000000000 --- a/randpkt-core.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * randpkt-core.h - * --------- - * Creates random packet traces. Useful for debugging sniffers by testing - * assumptions about the veracity of the data found in the packet. - * - * Copyright (C) 1999 by Gilbert Ramirez - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __RANDPKT_CORE_H__ -#define __RANDPKT_CORE_H__ - -#include -#include "wiretap/wtap.h" - -#define MAXBYTES_LIMIT 65536 - -typedef struct { - const char* abbrev; - const char* longname; - int produceable_type; - int sample_wtap_encap; - guint8* sample_buffer; - int sample_length; - guint8* pseudo_buffer; - guint pseudo_length; - wtap_dumper* dump; - const char* filename; - guint produce_max_bytes; - -} randpkt_example; - -/* Return the number of active examples */ -guint randpkt_example_count(void); - -/* Return the list of the active examples */ -void randpkt_example_list(const char*** abbrev_list, const char*** longname_list, unsigned* list_num); - -/* Seed the random-number generator */ -void randpkt_seed(void); - -/* Parse command-line option "type" and return enum type */ -int randpkt_parse_type(char *string); - -/* Find pkt_example record and return pointer to it */ -randpkt_example* randpkt_find_example(int type); - -/* Init a new example */ -void randpkt_example_init(randpkt_example* example, char* produce_filename, int produce_max_bytes); - -/* Loop the packet generation */ -void randpkt_loop(randpkt_example* example, guint64 produce_count); - -/* Close the current example */ -gboolean randpkt_example_close(randpkt_example* example); - -#endif - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=4 tabstop=4 noexpandtab: - * :indentSize=4:tabSize=4:noTabs=false: - */ diff --git a/randpkt.c b/randpkt.c index ec34a35471..073d50d38f 100644 --- a/randpkt.c +++ b/randpkt.c @@ -21,8 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "randpkt-core.h" - #include #include #include @@ -38,6 +36,8 @@ #include "wsutil/wsgetopt.h" #endif +#include "randpkt_core/randpkt_core.h" + /* Print usage statement and exit program */ static void usage(gboolean is_error) diff --git a/randpkt_core/CMakeLists.txt b/randpkt_core/CMakeLists.txt new file mode 100644 index 0000000000..f40f745408 --- /dev/null +++ b/randpkt_core/CMakeLists.txt @@ -0,0 +1,47 @@ +# CMakeLists.txt +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + + +set(RANDPKT_CORE_SRC + randpkt_core.c +) + +set(CLEAN_FILES + ${RANDPKT_CORE_SRC} +) + +if (WERROR_COMMON_FLAGS) + set_source_files_properties( + ${CLEAN_FILES} + PROPERTIES + COMPILE_FLAGS ${WERROR_COMMON_FLAGS} + ) +endif() + +file(GLOB RANDPKT_CORE_HEADERS randpkt_core.h) + +add_library(randpkt_core STATIC + ${RANDPKT_CORE_SRC} +) + +set_target_properties(randpkt_core PROPERTIES + LINK_FLAGS "${WS_LINK_FLAGS}" + FOLDER "Libs") diff --git a/randpkt_core/Makefile.am b/randpkt_core/Makefile.am new file mode 100644 index 0000000000..5f35912bdb --- /dev/null +++ b/randpkt_core/Makefile.am @@ -0,0 +1,73 @@ +# Makefile.am +# Automake file for the "random packet generator" routines for Wireshark +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +include Makefile.common +include $(top_srcdir)/Makefile.am.inc + +AM_CPPFLAGS += -I$(top_srcdir)/wiretap $(LIBGCRYPT_CFLAGS) \ + $(LIBGNUTLS_CFLAGS) $(PORTAUDIO_INCLUDES) + +noinst_LIBRARIES = librandpkt_core.a + +CLEANFILES = \ + doxygen-randpkt_core.tag \ + librandpkt_core.a \ + *~ + +MAINTAINERCLEANFILES = \ + $(GENERATED_FILES) \ + Makefile.in + +# All sources that should be put in the source distribution tarball +librandpkt_core_a_SOURCES = \ + $(RANDPKT_CORE_SRC) \ + $(noinst_HEADERS) + +librandpkt_core_a_DEPENDENCIES = + +doxygen: +if HAVE_DOXYGEN + $(DOXYGEN) doxygen.cfg +endif # HAVE_DOXYGEN + +wsar_html: doxygen.cfg ../doxygen_global.cfg +if HAVE_DOXYGEN + (umask 022 ; $(DOXYGEN) doxygen.cfg) +endif + +checkapi: checkapi-base checkapi-todo + +checkapi-base: + $(PERL) $(top_srcdir)/tools/checkAPIs.pl -g deprecated-gtk -build \ + -sourcedir=$(srcdir) \ + $(RANDPKT_CORE_SRC) + +checkapi-todo: + $(PERL) $(top_srcdir)/tools/checkAPIs.pl -M -g deprecated-gtk-todo -build \ + -sourcedir=$(srcdir) \ + $(RANDPKT_CORE_SRC) + +EXTRA_DIST = \ + $(GENERATOR_FILES) \ + CMakeLists.txt \ + doxygen.cfg.in \ + Makefile.common \ + Makefile.nmake diff --git a/randpkt_core/Makefile.common b/randpkt_core/Makefile.common new file mode 100644 index 0000000000..b7f72fc4c4 --- /dev/null +++ b/randpkt_core/Makefile.common @@ -0,0 +1,28 @@ +# Makefile.common +# Contains the stuff from Makefile.am and Makefile.nmake that is +# a) common to both files and +# b) portable between both files +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +RANDPKT_CORE_SRC = \ + randpkt_core.c + +noinst_HEADERS = \ + randpkt_core.h diff --git a/randpkt_core/Makefile.nmake b/randpkt_core/Makefile.nmake new file mode 100644 index 0000000000..5ab93cff9d --- /dev/null +++ b/randpkt_core/Makefile.nmake @@ -0,0 +1,78 @@ +## Makefile for building wireshark.exe with Microsoft C and nmake +## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake +# + +include ..\config.nmake +include ..\Makefile.nmake.inc + +############### no need to modify below this line ######### + +# We use GENERATED_CFLAGS to get around flex's non-LLP64-compliant output +GENERATED_CFLAGS=\ + $(STANDARD_CFLAGS) \ + /Zm800 \ + /I.. /I../wiretap $(GLIB_CFLAGS) $(GNUTLS_CFLAGS) \ + /I$(PCAP_DIR)\WPCAP\LIBPCAP /I$(PCAP_DIR)\WPCAP\LIBPCAP\bpf \ + /I$(PCAP_DIR)\WPCAP\LIBPCAP\lbl \ + /I$(PCAP_DIR)\include $(AIRPCAP_CFLAGS) \ + $(PORTAUDIO_CFLAGS) $(GEOIP_CFLAGS) $(WINSPARKLE_CFLAGS) \ + $(HHC_CFLAGS) + +CFLAGS=$(WARNINGS_ARE_ERRORS) $(GENERATED_CFLAGS) + +.c.obj:: + $(CC) $(CFLAGS) $(WSUG_CFLAGS) -Fd.\ -c $< + +include Makefile.common + + +# if you add files here, be sure to include them also in Makefile.am EXTRA_DIST +RANDPKT_CORE_OBJECTS = \ + $(RANDPKT_CORE_SRC:.c=.obj) + +RUNLEX=../tools/runlex.sh + +librandpkt_core.lib : ..\config.h $(RANDPKT_CORE_OBJECTS) + link /lib /out:librandpkt_core.lib $(RANDPKT_CORE_OBJECTS) + +clean: + rm -f $(RANDPKT_CORE_OBJECTS) librandpkt_core.lib \ + *.nativecodeanalysis.xml *.pdb *.sbr \ + doxygen.cfg html/*.* wireshark-tap-register-cache.pkl + if exist html rmdir html + +distclean: clean + +maintainer-clean: distclean + rm -f $(GENERATED_FILES) + +# convert doxygen.cfg.in to doxygen.cfg with stamped version info +doxygen.cfg: ..\config.nmake doxygen.cfg.in +!IFDEF DOXYGEN + sed -e s/@VERSION@/$(VERSION)/ \ + < doxygen.cfg.in > $@ +!ENDIF + +doxygen-run: +!IFDEF DOXYGEN + $(DOXYGEN) doxygen.cfg +!ENDIF + +# MS html help compiler hhc returns 1 on success, but as nmake expects 0 it would stop here. +# the prepended -1 will raise the accepted error levels of nmake, so it will continue +doxygen.chm: +!IFDEF HHC + -1 $(HHC) html\index.hhp +!ENDIF + +doxygen: doxygen.cfg doxygen-run doxygen.chm + +checkapi: checkapi-base checkapi-todo + +checkapi-base: + $(PERL) ../tools/checkAPIs.pl -g deprecated-gtk -build \ + $(RANDPKT_CORE_SRC) + +checkapi-todo: + $(PERL) ../tools/checkAPIs.pl -M -g deprecated-gtk-todo -build \ + $(RANDPKT_CORE_SRC) diff --git a/randpkt_core/doxygen.cfg.in b/randpkt_core/doxygen.cfg.in new file mode 100644 index 0000000000..baa9159fc3 --- /dev/null +++ b/randpkt_core/doxygen.cfg.in @@ -0,0 +1,81 @@ +# @configure_input@ + +@INCLUDE = ../doxygen_global.cfg + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "Wireshark Random Packet Generation Library" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = @VERSION@ + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = ../wsar_html + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = randpkt-core + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = ../doxygen-core.tag=.. + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = doxygen-randpkt-core.tag + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories +# that are symbolic links (a Unix filesystem feature) are excluded from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. + +EXCLUDE_PATTERNS = + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = wireshark-randpkt-core.chm diff --git a/randpkt_core/randpkt_core.c b/randpkt_core/randpkt_core.c new file mode 100644 index 0000000000..c329dc627d --- /dev/null +++ b/randpkt_core/randpkt_core.c @@ -0,0 +1,813 @@ +/* + * randpkt_core.c + * --------- + * Creates random packet traces. Useful for debugging sniffers by testing + * assumptions about the veracity of the data found in the packet. + * + * Copyright (C) 1999 by Gilbert Ramirez + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "randpkt_core.h" + +#include + +#include +#include +#include +#include +#include "wsutil/file_util.h" + +#ifdef _WIN32 +#include +#endif /* _WIN32 */ + +#define array_length(x) (sizeof x / sizeof x[0]) + +/* Types of produceable packets */ +enum { + PKT_ARP, + PKT_BGP, + PKT_BVLC, + PKT_DNS, + PKT_ETHERNET, + PKT_FDDI, + PKT_GIOP, + PKT_ICMP, + PKT_IP, + PKT_LLC, + PKT_M2M, + PKT_MEGACO, + PKT_NBNS, + PKT_NCP2222, + PKT_SCTP, + PKT_SYSLOG, + PKT_TCP, + PKT_TDS, + PKT_TR, + PKT_UDP, + PKT_USB, + PKT_USB_LINUX +}; + +/* Ethernet, indicating ARP */ +guint8 pkt_arp[] = { + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, + 0x32, 0x25, 0x0f, 0xff, + 0x08, 0x06 +}; + +/* Ethernet+IP+UDP, indicating DNS */ +guint8 pkt_dns[] = { + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0x3c, + 0xc5, 0x9e, 0x40, 0x00, + 0xff, 0x11, 0xd7, 0xe0, + 0xd0, 0x15, 0x02, 0xb8, + 0x0a, 0x01, 0x01, 0x63, + + 0x05, 0xe8, 0x00, 0x35, + 0xff, 0xff, 0x2a, 0xb9, + 0x30 +}; + +/* Ethernet+IP, indicating ICMP */ +guint8 pkt_icmp[] = { + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0x54, + 0x8f, 0xb3, 0x40, 0x00, + 0xfd, 0x01, 0x8a, 0x99, + 0xcc, 0xfc, 0x66, 0x0b, + 0xce, 0x41, 0x62, 0x12 +}; + +/* Ethernet, indicating IP */ +guint8 pkt_ip[] = { + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x08, 0x00 +}; + +/* TR, indicating LLC */ +guint8 pkt_llc[] = { + 0x10, 0x40, 0x68, 0x00, + 0x19, 0x69, 0x95, 0x8b, + 0x00, 0x01, 0xfa, 0x68, + 0xc4, 0x67 +}; + +/* Ethernet, indicating WiMAX M2M */ +guint8 pkt_m2m[] = { + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, + 0x32, 0x25, 0x0f, 0xff, + 0x08, 0xf0 +}; + +/* Ethernet+IP+UDP, indicating NBNS */ +guint8 pkt_nbns[] = { + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0x3c, + 0xc5, 0x9e, 0x40, 0x00, + 0xff, 0x11, 0xd7, 0xe0, + 0xd0, 0x15, 0x02, 0xb8, + 0x0a, 0x01, 0x01, 0x63, + + 0x00, 0x89, 0x00, 0x89, + 0x00, 0x00, 0x2a, 0xb9, + 0x30 +}; + +/* Ethernet+IP+UDP, indicating syslog */ +guint8 pkt_syslog[] = { + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0x64, + 0x20, 0x48, 0x00, 0x00, + 0xfc, 0x11, 0xf8, 0x03, + 0xd0, 0x15, 0x02, 0xb8, + 0x0a, 0x01, 0x01, 0x63, + + 0x05, 0xe8, 0x02, 0x02, + 0x00, 0x50, 0x51, 0xe1, + 0x3c +}; + +/* TR+LLC+IP, indicating TCP */ +guint8 pkt_tcp[] = { + 0x10, 0x40, 0x68, 0x00, + 0x19, 0x69, 0x95, 0x8b, + 0x00, 0x01, 0xfa, 0x68, + 0xc4, 0x67, + + 0xaa, 0xaa, 0x03, 0x00, + 0x00, 0x00, 0x08, 0x00, + + 0x45, 0x00, 0x00, 0x28, + 0x0b, 0x0b, 0x40, 0x00, + 0x20, 0x06, 0x85, 0x37, + 0xc0, 0xa8, 0x27, 0x01, + 0xc0, 0xa8, 0x22, 0x3c +}; + +/* Ethernet+IP, indicating UDP */ +guint8 pkt_udp[] = { + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0x3c, + 0xc5, 0x9e, 0x40, 0x00, + 0xff, 0x11, 0xd7, 0xe0, + 0xd0, 0x15, 0x02, 0xb8, + 0x0a, 0x01, 0x01, 0x63 +}; + +/* Ethernet+IP+UDP, indicating BVLC */ +guint8 pkt_bvlc[] = { + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0x3c, + 0xc5, 0x9e, 0x40, 0x00, + 0xff, 0x11, 0x01, 0xaa, + 0xc1, 0xff, 0x19, 0x1e, + 0xc1, 0xff, 0x19, 0xff, + 0xba, 0xc0, 0xba, 0xc0, + 0x00, 0xff, 0x2d, 0x5e, + 0x81 +}; + +/* TR+LLC+IPX, indicating NCP, with NCP Type == 0x2222 */ +guint8 pkt_ncp2222[] = { + 0x10, 0x40, 0x00, 0x00, + 0xf6, 0x7c, 0x9b, 0x70, + 0x68, 0x00, 0x19, 0x69, + 0x95, 0x8b, 0xe0, 0xe0, + 0x03, 0xff, 0xff, 0x00, + 0x25, 0x02, 0x11, 0x00, + 0x00, 0x74, 0x14, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x01, 0x04, 0x51, 0x00, + 0x00, 0x00, 0x04, 0x00, + 0x02, 0x16, 0x19, 0x7a, + 0x84, 0x40, 0x01, 0x22, + 0x22 +}; + +/* Ethernet+IP+TCP, indicating GIOP */ +guint8 pkt_giop[] = { + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0xa6, + 0x00, 0x2f, 0x40, 0x00, + 0x40, 0x06, 0x3c, 0x21, + 0x7f, 0x00, 0x00, 0x01, + 0x7f, 0x00, 0x00, 0x01, + + 0x30, 0x39, 0x04, 0x05, + 0xac, 0x02, 0x1e, 0x69, + 0xab, 0x74, 0xab, 0x64, + 0x80, 0x18, 0x79, 0x60, + 0xc4, 0xb8, 0x00, 0x00, + 0x01, 0x01, 0x08, 0x0a, + 0x00, 0x00, 0x48, 0xf5, + 0x00, 0x00, 0x48, 0xf5, + + 0x47, 0x49, 0x4f, 0x50, + 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x30, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x01 +}; + +/* Ethernet+IP+TCP, indicating BGP */ +guint8 pkt_bgp[] = { + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0xa6, + 0x00, 0x2f, 0x40, 0x00, + 0x40, 0x06, 0x3c, 0x21, + 0x7f, 0x00, 0x00, 0x01, + 0x7f, 0x00, 0x00, 0x01, + + 0x30, 0x39, 0x00, 0xb3, + 0xac, 0x02, 0x1e, 0x69, + 0xab, 0x74, 0xab, 0x64, + 0x80, 0x18, 0x79, 0x60, + 0xc4, 0xb8, 0x00, 0x00, + 0x01, 0x01, 0x08, 0x0a, + 0x00, 0x00, 0x48, 0xf5, + 0x00, 0x00, 0x48, 0xf5, + + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, +}; + +/* Ethernet+IP+TCP, indicating TDS NetLib */ +guint8 pkt_tds[] = { + 0x00, 0x50, 0x8b, 0x0d, + 0x7a, 0xed, 0x00, 0x08, + 0xa3, 0x98, 0x39, 0x81, + 0x08, 0x00, + + 0x45, 0x00, 0x03, 0x8d, + 0x90, 0xd4, 0x40, 0x00, + 0x7c, 0x06, 0xc3, 0x1b, + 0xac, 0x14, 0x02, 0x22, + 0x0a, 0xc2, 0xee, 0x82, + + 0x05, 0x99, 0x08, 0xf8, + 0xff, 0x4e, 0x85, 0x46, + 0xa2, 0xb4, 0x42, 0xaa, + 0x50, 0x18, 0x3c, 0x28, + 0x0f, 0xda, 0x00, 0x00, +}; + +/* Ethernet+IP, indicating SCTP */ +guint8 pkt_sctp[] = { + 0x00, 0xa0, 0x80, 0x00, + 0x5e, 0x46, 0x08, 0x00, + 0x03, 0x4a, 0x00, 0x35, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0x7c, + 0x14, 0x1c, 0x00, 0x00, + 0x3b, 0x84, 0x4a, 0x54, + 0x0a, 0x1c, 0x06, 0x2b, + 0x0a, 0x1c, 0x06, 0x2c, +}; + + +/* Ethernet+IP+SCTP, indicating MEGACO */ +guint8 pkt_megaco[] = { + 0x00, 0xa0, 0x80, 0x00, + 0x5e, 0x46, 0x08, 0x00, + 0x03, 0x4a, 0x00, 0x35, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0x7c, + 0x14, 0x1c, 0x00, 0x00, + 0x3b, 0x84, 0x4a, 0x54, + 0x0a, 0x1c, 0x06, 0x2b, + 0x0a, 0x1c, 0x06, 0x2c, + + 0x40, 0x00, 0x0b, 0x80, + 0x00, 0x01, 0x6f, 0x0a, + 0x6d, 0xb0, 0x18, 0x82, + 0x00, 0x03, 0x00, 0x5b, + 0x28, 0x02, 0x43, 0x45, + 0x00, 0x00, 0xa0, 0xbd, + 0x00, 0x00, 0x00, 0x07, +}; + +/* This little data table drives the whole program */ +static randpkt_example examples[] = { + { "arp", "Address Resolution Protocol", + PKT_ARP, WTAP_ENCAP_ETHERNET, + pkt_arp, array_length(pkt_arp), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "bgp", "Border Gateway Protocol", + PKT_BGP, WTAP_ENCAP_ETHERNET, + pkt_bgp, array_length(pkt_bgp), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "bvlc", "BACnet Virtual Link Control", + PKT_BVLC, WTAP_ENCAP_ETHERNET, + pkt_bvlc, array_length(pkt_bvlc), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "dns", "Domain Name Service", + PKT_DNS, WTAP_ENCAP_ETHERNET, + pkt_dns, array_length(pkt_dns), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "eth", "Ethernet", + PKT_ETHERNET, WTAP_ENCAP_ETHERNET, + NULL, 0, + NULL, 0, + NULL, NULL, + 1000, + }, + + { "fddi", "Fiber Distributed Data Interface", + PKT_FDDI, WTAP_ENCAP_FDDI, + NULL, 0, + NULL, 0, + NULL, NULL, + 1000, + }, + + { "giop", "General Inter-ORB Protocol", + PKT_GIOP, WTAP_ENCAP_ETHERNET, + pkt_giop, array_length(pkt_giop), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "icmp", "Internet Control Message Protocol", + PKT_ICMP, WTAP_ENCAP_ETHERNET, + pkt_icmp, array_length(pkt_icmp), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "ip", "Internet Protocol", + PKT_IP, WTAP_ENCAP_ETHERNET, + pkt_ip, array_length(pkt_ip), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "llc", "Logical Link Control", + PKT_LLC, WTAP_ENCAP_TOKEN_RING, + pkt_llc, array_length(pkt_llc), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "m2m", "WiMAX M2M Encapsulation Protocol", + PKT_M2M, WTAP_ENCAP_ETHERNET, + pkt_m2m, array_length(pkt_m2m), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "megaco", "MEGACO", + PKT_MEGACO, WTAP_ENCAP_ETHERNET, + pkt_megaco, array_length(pkt_megaco), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "nbns", "NetBIOS-over-TCP Name Service", + PKT_NBNS, WTAP_ENCAP_ETHERNET, + pkt_nbns, array_length(pkt_nbns), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "ncp2222", "NetWare Core Protocol", + PKT_NCP2222, WTAP_ENCAP_TOKEN_RING, + pkt_ncp2222, array_length(pkt_ncp2222), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "sctp", "Stream Control Transmission Protocol", + PKT_SCTP, WTAP_ENCAP_ETHERNET, + pkt_sctp, array_length(pkt_sctp), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "syslog", "Syslog message", + PKT_SYSLOG, WTAP_ENCAP_ETHERNET, + pkt_syslog, array_length(pkt_syslog), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "tds", "TDS NetLib", + PKT_TDS, WTAP_ENCAP_ETHERNET, + pkt_tds, array_length(pkt_tds), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "tcp", "Transmission Control Protocol", + PKT_TCP, WTAP_ENCAP_TOKEN_RING, + pkt_tcp, array_length(pkt_tcp), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "tr", "Token-Ring", + PKT_TR, WTAP_ENCAP_TOKEN_RING, + NULL, 0, + NULL, 0, + NULL, NULL, + 1000, + }, + + { "udp", "User Datagram Protocol", + PKT_UDP, WTAP_ENCAP_ETHERNET, + pkt_udp, array_length(pkt_udp), + NULL, 0, + NULL, NULL, + 1000, + }, + + { "usb", "Universal Serial Bus", + PKT_USB, WTAP_ENCAP_USB, + NULL, 0, + NULL, 0, + NULL, NULL, + 1000, + }, + + { "usb-linux", "Universal Serial Bus with Linux specific header", + PKT_USB_LINUX, WTAP_ENCAP_USB_LINUX, + NULL, 0, + NULL, 0, + NULL, NULL, + 1000, + }, + +}; + +guint randpkt_example_count(void) +{ + return array_length(examples); +} + +/* Find pkt_example record and return pointer to it */ +randpkt_example* randpkt_find_example(int type) +{ + int num_entries = array_length(examples); + int i; + + for (i = 0; i < num_entries; i++) { + if (examples[i].produceable_type == type) { + return &examples[i]; + } + } + + fprintf(stderr, "randpkt: Internal error. Type %d has no entry in examples table.\n", + type); + return NULL; +} + +void randpkt_loop(randpkt_example* example, guint64 produce_count) +{ + guint i; + int j; + int err; + int len_random; + int len_this_pkt; + gchar* err_info; + union wtap_pseudo_header* ps_header; + guint8 buffer[65536]; + struct wtap_pkthdr* pkthdr; + + pkthdr = g_new0(struct wtap_pkthdr, 1); + + pkthdr->rec_type = REC_TYPE_PACKET; + pkthdr->presence_flags = WTAP_HAS_TS; + pkthdr->pkt_encap = example->sample_wtap_encap; + + memset(pkthdr, 0, sizeof(struct wtap_pkthdr)); + memset(buffer, 0, sizeof(buffer)); + + ps_header = &pkthdr->pseudo_header; + + /* Load the sample pseudoheader into our pseudoheader buffer */ + if (example->pseudo_buffer) + memcpy(ps_header, example->pseudo_buffer, example->pseudo_length); + + /* Load the sample into our buffer */ + if (example->sample_buffer) + memcpy(buffer, example->sample_buffer, example->sample_length); + + /* Produce random packets */ + for (i = 0; i < produce_count; i++) { + if (example->produce_max_bytes > 0) { + len_random = (rand() % example->produce_max_bytes + 1); + } + else { + len_random = 0; + } + + len_this_pkt = example->sample_length + len_random; + + pkthdr->caplen = len_this_pkt; + pkthdr->len = len_this_pkt; + pkthdr->ts.secs = i; /* just for variety */ + + for (j = example->pseudo_length; j < (int) sizeof(*ps_header); j++) { + ((guint8*)ps_header)[j] = (rand() % 0x100); + } + + for (j = example->sample_length; j < len_this_pkt; j++) { + /* Add format strings here and there */ + if ((int) (100.0*rand()/(RAND_MAX+1.0)) < 3 && j < (len_random - 3)) { + memcpy(&buffer[j], "%s", 3); + j += 2; + } else { + buffer[j] = (rand() % 0x100); + } + } + + if (!wtap_dump(example->dump, pkthdr, buffer, &err, &err_info)) { + fprintf(stderr, "randpkt: Error writing to %s: %s\n", + example->filename, wtap_strerror(err)); + switch (err) { + + case WTAP_ERR_UNWRITABLE_ENCAP: + /* + * This is a problem with the particular + * frame we're writing and the file type + * and subtype we're writing; note that, + * and report the file type/subtype. + */ + fprintf(stderr, + "Frame has a network type that can't be saved in a \"%s\" file.\n", + wtap_file_type_subtype_short_string(WTAP_FILE_TYPE_SUBTYPE_PCAP)); + break; + + case WTAP_ERR_PACKET_TOO_LARGE: + /* + * This is a problem with the particular + * frame we're writing and the file type + * and subtype we're writing; note that, + * and report the file type/subtype. + */ + fprintf(stderr, + "Frame is too large for a \"%s\" file.\n", + wtap_file_type_subtype_short_string(WTAP_FILE_TYPE_SUBTYPE_PCAP)); + break; + + case WTAP_ERR_UNWRITABLE_REC_TYPE: + /* + * This is a problem with the particular + * record we're writing and the file type + * and subtype we're writing; note that, + * and report the file type/subtype. + */ + fprintf(stderr, + "Record has a record type that can't be saved in a \"%s\" file.\n", + wtap_file_type_subtype_short_string(WTAP_FILE_TYPE_SUBTYPE_PCAP)); + break; + + case WTAP_ERR_UNWRITABLE_REC_DATA: + /* + * This is a problem with the particular + * record we're writing and the file type + * and subtype we're writing; note that, + * and report the file type/subtype. + */ + fprintf(stderr, + "Record has data that can't be saved in a \"%s\" file.\n(%s)\n", + wtap_file_type_subtype_short_string(WTAP_FILE_TYPE_SUBTYPE_PCAP), + err_info != NULL ? err_info : "no information supplied"); + g_free(err_info); + break; + + default: + break; + } + } + } + + g_free(pkthdr); +} + +gboolean randpkt_example_close(randpkt_example* example) +{ + int err; + + if (!wtap_dump_close(example->dump, &err)) { + fprintf(stderr, "Error writing to %s: %s\n", + example->filename, wtap_strerror(err)); + return FALSE; + } + return TRUE; +} + +void randpkt_example_init(randpkt_example* example, char* produce_filename, int produce_max_bytes) +{ + int err; + + if (strcmp(produce_filename, "-") == 0) { + /* Write to the standard output. */ + example->dump = wtap_dump_open_stdout(WTAP_FILE_TYPE_SUBTYPE_PCAP, + example->sample_wtap_encap, produce_max_bytes, FALSE /* compressed */, &err); + example->filename = "the standard output"; + } else { + example->dump = wtap_dump_open(produce_filename, WTAP_FILE_TYPE_SUBTYPE_PCAP, + example->sample_wtap_encap, produce_max_bytes, FALSE /* compressed */, &err); + example->filename = produce_filename; + } + if (!example->dump) { + fprintf(stderr, "randpkt: Error writing to %s\n", example->filename); + exit(2); + } + + /* reduce max_bytes by # of bytes already in sample */ + if (produce_max_bytes <= example->sample_length) { + fprintf(stderr, "randpkt: Sample packet length is %d, which is greater than " + "or equal to\n", example->sample_length); + fprintf(stderr, "your requested max_bytes value of %d\n", produce_max_bytes); + exit(1); + } else { + example->produce_max_bytes = produce_max_bytes - example->sample_length; + } +} + +/* Seed the random-number generator */ +void +randpkt_seed(void) +{ + unsigned int randomness; + time_t now; +#ifndef _WIN32 + int fd; + ssize_t ret; + +#define RANDOM_DEV "/dev/urandom" + + /* + * Assume it's at least worth trying /dev/urandom on UN*X. + * If it doesn't exist, fall back on time(). + * + * XXX - Use CryptGenRandom on Windows? + */ + fd = ws_open(RANDOM_DEV, O_RDONLY); + if (fd == -1) { + if (errno != ENOENT) { + fprintf(stderr, + "randpkt: Could not open " RANDOM_DEV " for reading: %s\n", + g_strerror(errno)); + exit(2); + } + goto fallback; + } + + ret = ws_read(fd, &randomness, sizeof randomness); + if (ret == -1) { + fprintf(stderr, + "randpkt: Could not read from " RANDOM_DEV ": %s\n", + g_strerror(errno)); + exit(2); + } + if ((size_t)ret != sizeof randomness) { + fprintf(stderr, + "randpkt: Tried to read %lu bytes from " RANDOM_DEV ", got %ld\n", + (unsigned long)sizeof randomness, (long)ret); + exit(2); + } + srand(randomness); + ws_close(fd); + return; + +fallback: +#endif + now = time(NULL); + randomness = (unsigned int) now; + + srand(randomness); +} + +/* Parse command-line option "type" and return enum type */ +int randpkt_parse_type(char *string) +{ + int num_entries = array_length(examples); + int i; + + /* Called with NULL, choose a random packet */ + if (!string) { + return examples[rand() % num_entries].produceable_type; + } + + for (i = 0; i < num_entries; i++) { + if (g_strcmp0(examples[i].abbrev, string) == 0) { + return examples[i].produceable_type; + } + } + + /* Complain */ + fprintf(stderr, "randpkt: Type %s not known.\n", string); + return -1; +} + +void randpkt_example_list(const char*** abbrev_list, const char*** longname_list, unsigned* list_num) +{ + unsigned i; + *list_num = randpkt_example_count(); + *abbrev_list = g_new0(const char*, *list_num); + *longname_list = g_new0(const char*, *list_num); + for (i = 0; i < *list_num; i++) { + (*abbrev_list)[i] = examples[i].abbrev; + (*longname_list)[i] = examples[i].longname; + } +} + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: t + * End: + * + * vi: set shiftwidth=4 tabstop=4 noexpandtab: + * :indentSize=4:tabSize=4:noTabs=false: + */ diff --git a/randpkt_core/randpkt_core.h b/randpkt_core/randpkt_core.h new file mode 100644 index 0000000000..35265480cb --- /dev/null +++ b/randpkt_core/randpkt_core.h @@ -0,0 +1,84 @@ +/* + * randpkt_core.h + * --------- + * Creates random packet traces. Useful for debugging sniffers by testing + * assumptions about the veracity of the data found in the packet. + * + * Copyright (C) 1999 by Gilbert Ramirez + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __RANDPKT_CORE_H__ +#define __RANDPKT_CORE_H__ + +#include +#include "wiretap/wtap.h" + +#define MAXBYTES_LIMIT 65536 + +typedef struct { + const char* abbrev; + const char* longname; + int produceable_type; + int sample_wtap_encap; + guint8* sample_buffer; + int sample_length; + guint8* pseudo_buffer; + guint pseudo_length; + wtap_dumper* dump; + const char* filename; + guint produce_max_bytes; + +} randpkt_example; + +/* Return the number of active examples */ +guint randpkt_example_count(void); + +/* Return the list of the active examples */ +void randpkt_example_list(const char*** abbrev_list, const char*** longname_list, unsigned* list_num); + +/* Seed the random-number generator */ +void randpkt_seed(void); + +/* Parse command-line option "type" and return enum type */ +int randpkt_parse_type(char *string); + +/* Find pkt_example record and return pointer to it */ +randpkt_example* randpkt_find_example(int type); + +/* Init a new example */ +void randpkt_example_init(randpkt_example* example, char* produce_filename, int produce_max_bytes); + +/* Loop the packet generation */ +void randpkt_loop(randpkt_example* example, guint64 produce_count); + +/* Close the current example */ +gboolean randpkt_example_close(randpkt_example* example); + +#endif + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: t + * End: + * + * vi: set shiftwidth=4 tabstop=4 noexpandtab: + * :indentSize=4:tabSize=4:noTabs=false: + */ -- cgit v1.2.3