1 # - Convert ASN.1 file into C source and header files that can be used to create a wireshark dissector
3 # A2W_OUTPUT_DIR - directory where the generated packet-${PROTOCOL_NAME}.c is
4 # saved. The default location is meant for the Wireshark
5 # source tree. For external dissectors, set it to the
6 # absolute path (e.g. "${CMAKE_CURRENT_SOURCE_DIR}").
10 set(PROTO_OPT -p ${PROTOCOL_NAME})
11 elseif(PROTO_OPT STREQUAL "_EMPTY_")
15 if(NOT A2W_OUTPUT_DIR)
16 set(A2W_OUTPUT_DIR "${CMAKE_SOURCE_DIR}/epan/dissectors")
19 set(DISSECTOR "${A2W_OUTPUT_DIR}/packet-${PROTOCOL_NAME}.c")
21 # Besides the file dependency (for timestamp comparison), add a target such
22 # that other directories can request it to be built (ordering dependency).
23 foreach(_v EXTRA_CNF EXPORT_DEPENDS)
25 foreach(entry IN LISTS ${_v})
26 string(REGEX MATCH "[^/]+-exp\\.cnf$" _exp_cnf_filename "${entry}")
28 list(APPEND ${_v}_targets generate-${_exp_cnf_filename})
33 if(NOT ENABLE_DEBUG_A2W)
34 set(A2W_FLAGS ${A2W_FLAGS} -q -L)
37 # Creates a dissector in the source directory and store the timestamp.
39 OUTPUT packet-${PROTOCOL_NAME}-stamp
40 COMMAND "${Python3_EXECUTABLE}"
41 ${CMAKE_SOURCE_DIR}/tools/asn2wrs.py
44 -c "${CMAKE_CURRENT_SOURCE_DIR}/${PROTOCOL_NAME}.cnf"
45 -s "${CMAKE_CURRENT_SOURCE_DIR}/packet-${PROTOCOL_NAME}-template"
46 -D "${CMAKE_CURRENT_SOURCE_DIR}"
47 -O "${A2W_OUTPUT_DIR}"
48 ${EXT_ASN_FILE_LIST} ${ASN_FILE_LIST} ${EXT_ASN_FILE_LIST_LATE}
50 "${Python3_EXECUTABLE}" -c
51 "import shutil, sys; x,s,d=sys.argv; open(d, 'w'); shutil.copystat(s, d)"
52 "${A2W_OUTPUT_DIR}/packet-${PROTOCOL_NAME}.c"
53 packet-${PROTOCOL_NAME}-stamp
55 ${CMAKE_SOURCE_DIR}/tools/asn2wrs.py
62 add_custom_target(generate_dissector-${PROTOCOL_NAME} ALL
63 DEPENDS packet-${PROTOCOL_NAME}-stamp
66 foreach(_asn2wrs_export_file IN LISTS EXPORT_FILES)
68 OUTPUT ${_asn2wrs_export_file}
69 COMMAND "${Python3_EXECUTABLE}"
70 ${CMAKE_SOURCE_DIR}/tools/asn2wrs.py
74 -c "${CMAKE_CURRENT_SOURCE_DIR}/${PROTOCOL_NAME}.cnf"
75 -D "${CMAKE_CURRENT_SOURCE_DIR}"
76 ${EXT_ASN_FILE_LIST} ${ASN_FILE_LIST} ${EXT_ASN_FILE_LIST_LATE}
78 ${CMAKE_SOURCE_DIR}/tools/asn2wrs.py
80 ${EXPORT_DEPENDS_targets}
83 # This target enables other dissectors to trigger the -exp cnf build
84 add_custom_target(generate-${_asn2wrs_export_file}
85 DEPENDS ${_asn2wrs_export_file}