Move the routines to talk to dumpcap into a static libcapchild.

This pulls some stuff out of the top-level directory, and means we don't
have to build them once for every program using them.

Change-Id: I37b31fed20f2d5c3563ecd2bae9fd86af70afff5
Reviewed-on: https://code.wireshark.org/review/2591
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-06-23 16:48:41 -07:00
parent e22d3c9b74
commit 213189ef9e
15 changed files with 294 additions and 19 deletions

View File

@ -735,6 +735,7 @@ foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
endforeach()
add_subdirectory( asn1 EXCLUDE_FROM_ALL )
add_subdirectory( capchild )
add_subdirectory( codecs )
add_subdirectory( epan )
add_subdirectory( filetap )
@ -861,6 +862,7 @@ link_directories(
${CMAKE_BINARY_DIR}/ui
${CMAKE_BINARY_DIR}/ui/gtk
${CMAKE_BINARY_DIR}/ui/qt
${CMAKE_BINARY_DIR}/capchild
${CMAKE_BINARY_DIR}/codecs
${CMAKE_BINARY_DIR}/epan
${CMAKE_BINARY_DIR}/filetap
@ -922,8 +924,6 @@ set(SHARK_COMMON_SRC
# sources common for wireshark and tshark, but not rawshark;
# these are for programs that capture traffic by running dumpcap
set(SHARK_COMMON_CAPTURE_SRC
capture_ifinfo.c
capture_sync.c
capture_ui_utils.c
)
@ -1055,6 +1055,7 @@ if(BUILD_wireshark AND GTK_FOUND)
set(wireshark_LIBS
gtkui
ui
capchild
${GTK2_LIBRARIES}
${GTK3_LIBRARIES}
${GTHREAD2_LIBRARIES}
@ -1081,6 +1082,7 @@ if(BUILD_qtshark AND QT_FOUND)
set(qtshark_LIBS
qtui
ui
capchild
${QT_LIBRARIES}
${GTHREAD2_LIBRARIES}
codecs
@ -1108,6 +1110,7 @@ register_tap_files(tshark-tap-register.c
if(BUILD_tshark)
set(tshark_LIBS
ui
capchild
${LIBEPAN_LIBS}
${APPLE_CORE_FOUNDATION_LIBRARY}
${APPLE_SYSTEM_CONFIGURATION_LIBRARY}

View File

@ -351,6 +351,7 @@ endif
# GLIB_LIBS (that's the case on my machine right now, for example).
#
wireshark_ldadd = \
capchild/libcapchild.a \
ui/libui.a \
ui/libui_dirty.a \
codecs/libcodec.a \
@ -418,6 +419,7 @@ endif
# Libraries and plugin flags with which to link tshark.
tshark_LDADD = \
capchild/libcapchild.a \
ui/cli/libcliui.a \
ui/libui.a \
wiretap/libwiretap.la \
@ -1049,13 +1051,42 @@ endif
endif
DIST_SUBDIRS = asn1 codecs doc epan echld filetap ui ui/cli ui/gtk ui/qt help packaging plugins tools wiretap wsutil docbook
DIST_SUBDIRS = \
asn1 \
capchild \
codecs \
doc \
epan \
echld \
filetap \
ui \
ui/cli \
ui/gtk \
ui/qt \
help \
packaging \
plugins \
tools \
wiretap \
wsutil \
docbook
if HAVE_PLUGINS
SUBDIRS = tools wsutil wiretap filetap epan @echld_dir@ plugins packaging help ui @wireshark_SUBDIRS@ ui/cli . doc
else
SUBDIRS = tools wsutil wiretap filetap epan @echld_dir@ packaging help ui @wireshark_SUBDIRS@ ui/cli . doc
endif
SUBDIRS = \
tools \
wsutil \
wiretap \
filetap \
epan \
capchild \
@echld_dir@ \
@plugins_dir@ \
packaging \
help \
ui \
@wireshark_SUBDIRS@ \
ui/cli \
. \
doc
help/faq.txt: $(srcdir)/help/faq.py
$(AM_V_GEN)(cd help ; \
@ -1199,6 +1230,7 @@ checkapi: checkapi_local
cd wiretap && $(MAKE) checkapi
cd filetap && $(MAKE) checkapi
cd codecs && $(MAKE) checkapi
cd capchild && $(MAKE) checkapi
cd ui && $(MAKE) checkapi
cd ui/gtk && $(MAKE) checkapi
## cd epan && $(MAKE) checkapi
@ -1214,6 +1246,7 @@ wsar_html: doxygen.cfg doxygen_global.cfg FORCE
if HAVE_DOXYGEN
rm -rf wsar_html
cd epan && $(MAKE) $@
cd capchild && $(MAKE) $@
cd ui && $(MAKE) $@
(umask 022 ; $(DOXYGEN) doxygen.cfg)
endif

View File

@ -68,15 +68,11 @@ SHARK_COMMON_INCLUDES = \
# sources common for wireshark and tshark, but not rawshark;
# these are for programs that capture traffic by running dumpcap
SHARK_COMMON_CAPTURE_SRC = \
capture_ifinfo.c \
capture_sync.c \
capture_ui_utils.c
# corresponding headers
SHARK_COMMON_CAPTURE_INCLUDES = \
capture_ifinfo.h \
capture_session.h \
capture_sync.h \
capture_ui_utils.h
# wireshark specifics

View File

@ -265,6 +265,7 @@ packaging_zip: all
# See: http://ask.wireshark.org/questions/8660/wireshark-building-and-debugging-on-visual-c-or-visual-studio
wireshark.bsc: \
*.sbr \
capchild\*.sbr \
codecs\*.sbr \
epan\*.sbr \
epan\crypt\*.sbr \
@ -314,21 +315,21 @@ $(RESOURCES): image
filetap\filetap-$(FTAP_VERSION).lib: image $(ZLIB_DLL) filetap
wiretap\wiretap-$(WTAP_VERSION).lib: image $(ZLIB_DLL) wiretap
wireshark.exe : $(LIBS_CHECK) config.h $(wireshark_OBJECTS) codecs epan ui gtk win32 image\wireshark.res image\file_dlg_win32.res wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib codecs\codecs.lib ui\libui.lib ui\gtk\libgtkui.lib ui\win32\libgtkui_win32.lib plugins
wireshark.exe : $(LIBS_CHECK) config.h $(wireshark_OBJECTS) capchild codecs epan ui gtk win32 image\wireshark.res image\file_dlg_win32.res wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib codecs\codecs.lib ui\libui.lib ui\gtk\libgtkui.lib ui\win32\libgtkui_win32.lib plugins
@echo Linking $@
$(LINK) @<<
/OUT:$(PROGRAM_NAME).exe $(guiflags) $(guilibsdll) $(LDFLAGS) /LARGEADDRESSAWARE $(wireshark_LIBS) $(GTK_LIBS) codecs\codecs.lib ui\gtk\libgtkui.lib ui\win32\libgtkui_win32.lib ui\libui.lib $(wireshark_OBJECTS) image\wireshark.res image\file_dlg_win32.res
/OUT:$(PROGRAM_NAME).exe $(guiflags) $(guilibsdll) $(LDFLAGS) /LARGEADDRESSAWARE $(wireshark_LIBS) $(GTK_LIBS) capchild\capchild.lib codecs\codecs.lib ui\gtk\libgtkui.lib ui\win32\libgtkui_win32.lib ui\libui.lib $(wireshark_OBJECTS) image\wireshark.res image\file_dlg_win32.res
<<
!IFDEF MANIFEST_INFO_REQUIRED
mt.exe -nologo -manifest "wireshark.exe.manifest" -outputresource:$(PROGRAM_NAME).exe;1
!ENDIF
qtshark.exe : install-generated-files $(LIBS_CHECK) config.h epan ui qt wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib plugins
qtshark.exe : install-generated-files $(LIBS_CHECK) config.h capchild epan ui qt wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib plugins
tshark.exe : $(LIBS_CHECK) config.h $(tshark_OBJECTS) epan ui cli image\tshark.res wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib plugins
tshark.exe : $(LIBS_CHECK) config.h $(tshark_OBJECTS) capchild epan ui cli image\tshark.res wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib plugins
@echo Linking $@
$(LINK) @<<
/OUT:tshark.exe $(conflags) $(conlibsdll) $(LDFLAGS) /LARGEADDRESSAWARE $(tshark_LIBS) $(tshark_OBJECTS) ui\cli\libcliui.lib ui\libui.lib image\tshark.res
/OUT:tshark.exe $(conflags) $(conlibsdll) $(LDFLAGS) /LARGEADDRESSAWARE $(tshark_LIBS) $(tshark_OBJECTS) capchild\libcapchild.lib ui\cli\libcliui.lib ui\libui.lib image\tshark.res
<<
!IFDEF MANIFEST_INFO_REQUIRED
mt.exe -nologo -manifest "tshark.exe.manifest" -outputresource:tshark.exe;1
@ -797,6 +798,11 @@ filetap::
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
cd ..
capchild:: help config.h version.h doxygen
cd capchild
$(MAKE) /$(MAKEFLAGS) /f Makefile.nmake libcapchild.lib
cd ..
codecs::
cd codecs
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake

46
capchild/CMakeLists.txt Normal file
View File

@ -0,0 +1,46 @@
# CMakeLists.txt
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
set(CAPCHILD_SRC
capture_ifinfo.c
capture_sync.c
)
set(CLEAN_FILES
${CAPCHILD_SRC}
)
if (WERROR)
set_source_files_properties(
${CLEAN_FILES}
PROPERTIES
COMPILE_FLAGS -Werror
)
endif()
add_library(capchild STATIC
${CAPCHILD_SRC}
)
set_target_properties(capchild PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
set_target_properties(capchild PROPERTIES FOLDER "CAPCHILD")

80
capchild/Makefile.am Normal file
View File

@ -0,0 +1,80 @@
# Makefile.am
# Automake file for the "talking to dumpcap" routines for Wireshark
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include Makefile.common
include ../Makefile.am.inc
if HAVE_WARNINGS_AS_ERRORS
AM_CLEAN_CFLAGS = -Werror
endif
noinst_LIBRARIES = libcapchild.a
CLEANFILES = \
doxygen-capchild.tag \
libcapchild.a \
*~
MAINTAINERCLEANFILES = \
$(GENERATED_FILES) \
Makefile.in
# All sources that should be put in the source distribution tarball
libcapchild_a_SOURCES = \
$(CAPCHILD_SRC) \
$(noinst_HEADERS)
libcapchild_a_CFLAGS = $(AM_CLEAN_CFLAGS)
libcapchild_a_DEPENDENCIES =
# Common headers
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/wiretap $(LIBGCRYPT_CFLAGS) $(LIBGNUTLS_CFLAGS) $(PORTAUDIO_INCLUDES)
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) \
$(CAPCHILD_SRC)
checkapi-todo:
$(PERL) $(top_srcdir)/tools/checkAPIs.pl -M -g deprecated-gtk-todo -build \
-sourcedir=$(srcdir) \
$(CAPCHILD_SRC)
EXTRA_DIST = \
$(GENERATOR_FILES) \
CMakeLists.txt \
doxygen.cfg.in \
Makefile.common \
Makefile.nmake

30
capchild/Makefile.common Normal file
View File

@ -0,0 +1,30 @@
# 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 <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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
CAPCHILD_SRC = \
capture_ifinfo.c \
capture_sync.c
noinst_HEADERS = \
capture_ifinfo.h \
capture_sync.h

77
capchild/Makefile.nmake Normal file
View File

@ -0,0 +1,77 @@
## 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
CAPCHILD_OBJECTS = \
$(CAPCHILD_SRC:.c=.obj)
RUNLEX=..\tools\runlex.sh
libcapchild.lib : ..\config.h $(CAPCHILD_OBJECTS)
link /lib /out:libcapchild.lib $(CAPCHILD_OBJECTS)
clean:
rm -f $(CAPCHILD_OBJECTS) $(WIRESHARK_TAP_OBJECTS) libcapchild.lib *.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 \
$(CAPCHILD_SRC)
checkapi-todo:
$(PERL) ../tools/checkAPIs.pl -M -g deprecated-gtk-todo -build \
$(CAPCHILD_SRC)

View File

@ -34,7 +34,7 @@
# include <sys/types.h> /* for gid_t */
#endif
#include "capture_ifinfo.h"
#include <capchild/capture_ifinfo.h>
#ifdef __cplusplus
extern "C" {

View File

@ -1676,10 +1676,13 @@ LIBS="$ac_save_LIBS"
if test "$ac_cv_glib_supports_modules" = yes ; then
AC_MSG_RESULT(yes)
have_plugins=yes
plugins_dir="plugins"
else
AC_MSG_RESULT(no)
have_plugins=no
plugins_dir=""
fi
AC_SUBST(plugins_dir)
#
# If we have <dlfcn.h>, check whether we have dladdr.
@ -2873,6 +2876,7 @@ AC_OUTPUT(
asn1/x509if/Makefile
asn1/x509sat/Makefile
asn1/x721/Makefile
capchild/Makefile
doc/Makefile
docbook/Makefile
epan/Makefile

View File

@ -47,7 +47,7 @@
#include "ws80211_utils.h"
#include "capture_session.h"
#include "capture_sync.h"
#include <capchild/capture_sync.h>
static GtkWidget *tb80211_tb, *tb80211_iface_list_box, *tb80211_freq_list_box, *tb80211_chan_type_box, *tb80211_info_label;