From deef1dc1ff22183c0b70ea65775c23c404c641bb Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Thu, 16 Jun 2016 14:58:19 -0700 Subject: [PATCH] cmake: add PIDL dissector generation support The dissectors list is generated based on regex magic on pidl/Makefile. A dssetup.cnf file is added because all other protocols already have this file. The srvsvc and wkssvc protocols cannot be built for some reason, so just disable it (this mirrors the original Makefile). Add frsrpc and samr to PIDL_DISSECTOR_SRC list which was missing compared to autotools. Tested with an out-of-tree and in-tree build with cmake (make and ninja): cmake -GNinja && ninja -v pidl-dissectors touch epan/dissectors/pidl/dfs/dfs.idl && ninja generate_dissector-dcerpc-dfs cmake . && make -C epan/dissectors/pidl generate_dissector-dcerpc-dfs Change-Id: Id8bf34e76c20053a8a393024560d90a048473e03 Reviewed-on: https://code.wireshark.org/review/15962 Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- .gitignore | 1 + CMakeOptions.txt | 1 - epan/dissectors/CMakeLists.txt | 31 +---- epan/dissectors/pidl/CMakeLists.txt | 169 +++++++++++++++++++++++ epan/dissectors/pidl/dssetup/dssetup.cnf | 1 + 5 files changed, 172 insertions(+), 31 deletions(-) create mode 100644 epan/dissectors/pidl/CMakeLists.txt create mode 100644 epan/dissectors/pidl/dssetup/dssetup.cnf diff --git a/.gitignore b/.gitignore index d3bd9f8d88..50f541612d 100644 --- a/.gitignore +++ b/.gitignore @@ -136,6 +136,7 @@ rules.ninja .ninja_deps .ninja_log epan/dissectors/asn1/*/*-stamp +epan/dissectors/pidl/*-stamp # Generated dir # diff --git a/CMakeOptions.txt b/CMakeOptions.txt index d4ed10933e..1f73fe7b45 100644 --- a/CMakeOptions.txt +++ b/CMakeOptions.txt @@ -19,7 +19,6 @@ option(BUILD_sshdump "Build sshdump" ON) option(BUILD_ciscodump "Build ciscodump" ON) option(BUILD_randpktdump "Build randpktdump" ON) option(AUTOGEN_dcerpc "Autogenerate DCE RPC dissectors" OFF) -option(AUTOGEN_pidl "Autogenerate pidl dissectors" OFF) option(DISABLE_WERROR "Do not treat warnings as errors" OFF) option(EXTCAP_ANDROIDDUMP_LIBPCAP "Build androiddump using libpcap" OFF) diff --git a/epan/dissectors/CMakeLists.txt b/epan/dissectors/CMakeLists.txt index f56676af72..cafc528791 100644 --- a/epan/dissectors/CMakeLists.txt +++ b/epan/dissectors/CMakeLists.txt @@ -23,16 +23,13 @@ ADD_CUSTOM_CMAKE_INCLUDE() add_subdirectory(asn1 EXCLUDE_FROM_ALL) add_subdirectory(dcerpc) +add_subdirectory(pidl EXCLUDE_FROM_ALL) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ) -if(AUTOGEN_pidl) - # TODO -endif() - if(AUTOGEN_dcerpc) foreach(PROTOCOL_NAME ${PIDL_DISSECTOR_AUTOGEN_NAMES}) list(APPEND PIDL_DISSECTOR_AUTOGEN_SRC @@ -98,32 +95,6 @@ add_custom_target(x11-dissector set_target_properties(x11-dissector PROPERTIES FOLDER "Generated Dissectors/X11") -# Note that some dissectors are added in dcerpc/CMakeLists.txt -set(PIDL_DISSECTOR_SRC - packet-dcerpc-atsvc.c -# packet-dcerpc-budb.c -# packet-dcerpc-butc.c - packet-dcerpc-dfs.c - packet-dcerpc-dnsserver.c -# packet-dcerpc-drsuapi.c - packet-dcerpc-dssetup.c - packet-dcerpc-efs.c - packet-dcerpc-eventlog.c - packet-dcerpc-frstrans.c - packet-dcerpc-initshutdown.c - packet-dcerpc-lsa.c - packet-dcerpc-mapi.c - packet-dcerpc-mdssvc.c - packet-dcerpc-misc.c - packet-dcerpc-nspi.c - packet-dcerpc-rfr.c - packet-dcerpc-srvsvc.c - packet-dcerpc-winreg.c - packet-dcerpc-witness.c - packet-dcerpc-wkssvc.c - packet-dcerpc-wzcsvc.c -) - set(ASN1_DISSECTOR_SRC packet-ansi_map.c packet-acp133.c diff --git a/epan/dissectors/pidl/CMakeLists.txt b/epan/dissectors/pidl/CMakeLists.txt new file mode 100644 index 0000000000..05fe5e677c --- /dev/null +++ b/epan/dissectors/pidl/CMakeLists.txt @@ -0,0 +1,169 @@ +# 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(PIDL_DISSECTOR_NAMES + atsvc + dfs + dnsserver + dssetup + efs + eventlog + frsrpc + frstrans + initshutdown + lsa + mapi + mdssvc + misc + nspi + rfr + samr + #srvsvc + winreg + witness + #wkssvc + wzcsvc +) + +set(PIDL_DISSECTOR_dssetup_EXTRA_DEPS + misc/misc.idl +) +set(PIDL_DISSECTOR_eventlog_EXTRA_DEPS + idl_types.h +) +set(PIDL_DISSECTOR_frsrpc_EXTRA_DEPS + misc/misc.idl + idl_types.h +) +set(PIDL_DISSECTOR_frstrans_EXTRA_DEPS + misc/misc.idl + idl_types.h +) +set(PIDL_DISSECTOR_initshutdown_EXTRA_DEPS + lsa/lsa.idl + idl_types.h +) +set(PIDL_DISSECTOR_lsa_EXTRA_DEPS + idl_types.h +) +set(PIDL_DISSECTOR_mapi_EXTRA_DEPS + mapi/request.cnf.c + mapi/response.cnf.c + idl_types.h + mapicodes_enum.h + mapitags_enum.h +) +set(PIDL_DISSECTOR_mdssvc_EXTRA_DEPS + misc/misc.idl +) +set(PIDL_DISSECTOR_misc_EXTRA_DEPS + idl_types.h +) +set(PIDL_DISSECTOR_nspi_EXTRA_DEPS + idl_types.h + mapicodes_enum.h + mapitags_enum.h +) +set(PIDL_DISSECTOR_rfr_EXTRA_DEPS + idl_types.h + mapicodes_enum.h +) +set(PIDL_DISSECTOR_samr_EXTRA_DEPS + idl_types.h +) +set(PIDL_DISSECTOR_srvsvc_EXTRA_DEPS + idl_types.h +) +set(PIDL_DISSECTOR_winreg_EXTRA_DEPS + misc/misc.idl +) +set(PIDL_DISSECTOR_witness_EXTRA_DEPS + misc/misc.idl + idl_types.h +) +set(PIDL_DISSECTOR_wkssvc_EXTRA_DEPS + lsa/lsa.idl + srvsvc/srvsvc.idl + idl_types.h +) + +set(PIDL_DISSECTOR_TARGETS) +set(PIDL_DISSECTOR_SRC) +# TODO fix these dissectors, remove this and update PIDL_DISSECTOR_NAMES above. +list(APPEND PIDL_DISSECTOR_SRC + packet-dcerpc-srvsvc.c + packet-dcerpc-wkssvc.c +) + +foreach(PROTOCOL_NAME IN LISTS PIDL_DISSECTOR_NAMES) + add_custom_command( + OUTPUT packet-dcerpc-${PROTOCOL_NAME}-stamp + COMMAND "${PERL_EXECUTABLE}" + "${CMAKE_SOURCE_DIR}/tools/pidl/pidl" + --ws-parser + --outputdir ../.. + --includedir .. + -- + ${PROTOCOL_NAME}.idl + COMMAND + "${CMAKE_COMMAND}" -E touch + "${CMAKE_CURRENT_BINARY_DIR}/packet-dcerpc-${PROTOCOL_NAME}-stamp" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${PROTOCOL_NAME}" + DEPENDS + "${CMAKE_SOURCE_DIR}/tools/pidl/pidl" + ${PROTOCOL_NAME}/${PROTOCOL_NAME}.idl + ${PROTOCOL_NAME}/${PROTOCOL_NAME}.cnf + ${PIDL_DISSECTOR_${PROTOCOL_NAME}_EXTRA_DEPS} + VERBATIM + ) + add_custom_target(generate_dissector-dcerpc-${PROTOCOL_NAME} + DEPENDS packet-dcerpc-${PROTOCOL_NAME}-stamp + ) + set_target_properties(generate_dissector-dcerpc-${PROTOCOL_NAME} + PROPERTIES FOLDER "Generated Dissectors/PIDL" + ) + list(APPEND PIDL_DISSECTOR_TARGETS + generate_dissector-dcerpc-${PROTOCOL_NAME} + ) + list(APPEND PIDL_DISSECTOR_SRC + packet-dcerpc-${PROTOCOL_NAME}.c + ) +endforeach() + +set(PIDL_DISSECTOR_SRC ${PIDL_DISSECTOR_SRC} PARENT_SCOPE) + +add_custom_target(pidl-dissectors ALL DEPENDS ${PIDL_DISSECTOR_TARGETS}) +set_target_properties(pidl-dissectors + PROPERTIES FOLDER "Generated Dissectors/PIDL" +) + +# +# Editor modelines - https://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/epan/dissectors/pidl/dssetup/dssetup.cnf b/epan/dissectors/pidl/dssetup/dssetup.cnf new file mode 100644 index 0000000000..a551614b73 --- /dev/null +++ b/epan/dissectors/pidl/dssetup/dssetup.cnf @@ -0,0 +1 @@ +# Conformance file for dssetup