diff --git a/build_wireshark.sh b/build_wireshark.sh new file mode 100755 index 0000000..03935d0 --- /dev/null +++ b/build_wireshark.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# +# Make a set of dissectors and build custom wireshark build directory. +# To install the custom wireshark executables change directory to the build +# directory and use +# sudo make install + +ORIG_DIR=$(pwd) +WIRESHARK_LATEST_URL=https://1.na.dl.wireshark.org/src/wireshark-latest.tar.xz +WIRESHARK_SRC=$(realpath ./wireshark-src) +BUILD_DIR=$(pwd)/wireshark-build +OFILE_DIR="${WIRESHARK_SRC}/custom_epan" +CUSTOM_CMAKE_LIST_FILE=${WIRESHARK_SRC}/epan/dissectors/CMakeListsCustom.txt + +eobi_proto_list=("14.0" "14.1" "15.0") +eti_proto_list=("14.0" "14.1" "15.0") + +# dowload latest wireshark source and unpack to local source dir +curl -o /tmp/wireshark-latest.tar.xz "${WIRESHARK_LATEST_URL}" +mkdir -p "${WIRESHARK_SRC}" +tar xvf /tmp/wireshark-latest.tar.xz -C "${WIRESHARK_SRC}" --strip-components=1 + +# Can change this to only do this step if the build directory does not exist +mkdir -p "${BUILD_DIR}" && cd "${BUILD_DIR}" || exit +mkdir -p "${OFILE_DIR}" + +SRC_LIST="" + +# Process EOBI XML files +for p in "${eobi_proto_list[@]}" +do + PROTO="eobi_$(echo "${p}" | tr "." "_")" + PROTO_DIR="T7_$(echo "$PROTO" | tr [:lower:] [:upper:])" + XML="${ORIG_DIR}/temp/${PROTO_DIR}/eobi.xml" + OFILE="${OFILE_DIR}/packet-eobi-${p}.c" + # echo "${p} => ${PROTO}, ${XML}, ${OFILE}" + "${ORIG_DIR}"/eti2wireshark.py --proto "${PROTO}" --desc "Enhanced Order Book Interface" "${XML}" -o "${OFILE}" + SRC_LIST="${SRC_LIST}\t${OFILE}\n" +done + +# Process ETI XML files +for p in "${eti_proto_list[@]}" +do + PROTO="eti_$(echo "${p}" | tr "." "_")" + PROTO_DIR="T7_$(echo "$PROTO" | tr [:lower:] [:upper:])" + XML="${ORIG_DIR}/temp/${PROTO_DIR}/eti_Derivatives.xml" + OFILE="${OFILE_DIR}/packet-eti-${p}.c" + # echo "${p} => ${PROTO}, ${XML}, ${OFILE}" + "${ORIG_DIR}"/eti2wireshark.py --proto "${PROTO}" --desc "ETI Derivatives" "${XML}" -o "${OFILE}" + SRC_LIST="${SRC_LIST}\t${OFILE}\n" +done + +# Create custom dissector list for Cmake +cat > "${CUSTOM_CMAKE_LIST_FILE}" << END +# CMakeListsCustom.txt +# +# Custom EOBI/ETI dissectors, generated using eti2wireshark.py + +END + +echo -e "set(CUSTOM_DISSECTOR_SRC\n$SRC_LIST)" >> "${CUSTOM_CMAKE_LIST_FILE}" + +cmake "$WIRESHARK_SRC" + +make -j32 +cd "$ORIG_DIR" || exit +echo -e "To install Wireshark use:\ncd wireshark-build && sudo make install" \ No newline at end of file diff --git a/eti2wireshark.py b/eti2wireshark.py index b7d523b..110e476 100755 --- a/eti2wireshark.py +++ b/eti2wireshark.py @@ -521,7 +521,7 @@ def mk_int_case(size, signed, proto): else: hex_str = '0x' + 'ff' * size if size == 1: - fn = f'tvb_get_g{unsigned_str}int8' + fn = f'tvb_get_{unsigned_str}int8' else: fn = f'tvb_get_letoh{signed_str}{size_str}' s = f'''case {size}: @@ -589,7 +589,7 @@ def gen_dissect_fn(st, dt, ts, sh, ams, proto, o=sys.stdout): col_set_str(pinfo->cinfo, COL_PROTOCOL, "{proto.upper()}"); col_clear(pinfo->cinfo, COL_INFO); guint16 templateid = tvb_get_letohs(tvb, {template_off}); - const char *template_str = val_to_str_ext(templateid, &template_id_vals_ext, "Unknown {proto.upper()} template: 0x%04x"); + const char *template_str = val_to_str_ext_const(templateid, &template_id_vals_ext, "Unknown {proto.upper()} template: 0x%04x"); col_add_fstr(pinfo->cinfo, COL_INFO, "%s", template_str); /* create display subtree for the protocol */ @@ -706,7 +706,7 @@ def gen_dissect_fn(st, dt, ts, sh, ams, proto, o=sys.stdout): break; case ETI_STRING: {{ - guint8 c = tvb_get_guint8(tvb, off); + guint8 c = tvb_get_uint8(tvb, off); if (c) proto_tree_add_item(t, hf_{proto}[fields[fidx].field_handle_idx], tvb, off, fields[fidx].size, ENC_ASCII); else {{ @@ -733,7 +733,7 @@ def gen_dissect_fn(st, dt, ts, sh, ams, proto, o=sys.stdout): switch (fields[fidx].size) {{ case 1: {{ - guint8 x = tvb_get_guint8(tvb, off); + guint8 x = tvb_get_uint8(tvb, off); if (x == UINT8_MAX) {{ proto_tree_add_uint_format_value(t, hf_{proto}[fields[fidx].field_handle_idx], tvb, off, fields[fidx].size, x, "NO_VALUE (0xff)"); counter[fields[fidx].counter_off] = 0; diff --git a/makefile b/makefile index 2e9c367..f144a12 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ -url_eti_15_0 = https://www.eurex.com/resource/blob/5411648/98579acd90ea352ca2e223114fae34bd/data/T7_R.15.0_Enhanced_Trading_Interface_-_XSD_XML_representation_and_layouts_Version_1.zip +url_eti_15_0 = https://www.eurex.com/resource/blob/5411648/a9499dd5637698a05d3da21f19b93439/data/T7_R.15.0_Enhanced_Trading_Interface_-_XSD_XML_representation_and_layouts_Version_2.zip url_eti_14_1 = https://www.eurex.com/resource/blob/5032540/1961cd153b2559c4c2b9495963b33993/data/T7_R.14.1_Enhanced_Trading_Interface_-_XSD_XML_representation_and_layouts_Version_2.zip url_eti_14_0 = https://www.eurex.com/resource/blob/4629436/aa33fd54021ac40840ea7c7646a870f2/data/T7_R.14.0_Enhanced_Trading_Interface_-_XSD_XML_representation_and_layouts_Version_2.zip url_eti_13_1 = https://www.eurex.com/resource/blob/4332324/7c358b1edeef76eeb3b758c437d9c955/data/T7_R.13.1_Enhanced_Trading_Interface_-_XSD_XML_representation_and_layouts_Version_2.zip @@ -11,7 +11,7 @@ url_eti_11_0 = https://www.eurex.com/resource/blob/3312766/b0432bd1900c4e9926dff url_eti_10_1 = https://www.eurex.com/resource/blob/3116352/44bc86eee29639a491664d3b71cd34fc/data/T7_R.10.1_Enhanced_Trading_Interface_-_XSD_XML_representation_and_layouts_v.1.2.zip url_eti_10_0 = https://www.eurex.com/resource/blob/2827374/da41cfed961c5635fd438d848af30a43/data/T7_R.10.0_Enhanced_Trading_Interface_-_XSD_XML_representation_and_layouts_v.1.2.zip url_eti_9_1 = https://www.eurex.com/resource/blob/2609690/62b03a26ce2075635b329e6c688d69b9/data/T7_R.9.1_Enhanced_Trading_Interface_-_XSD_XML_representation_and_layouts_v.1.1.zip -url_eti_9_0 = https://www.xetra.com/resource/blob/2339516/fb5884fb098c442a4bf7cc8c57912ca7/data/T7_R.9.0_Enhanced_Trading_Interface_-_XSD_XML_representation_and_layouts_v.1.2.zip +url_eti_9_0 = https://www.eurex.com/resource/blob/2339516/fb5884fb098c442a4bf7cc8c57912ca7/data/T7_R.9.0_Enhanced_Trading_Interface_-_XSD_XML_representation_and_layouts_v.1.2.zip url_eti_8_1 = https://www.eurex.com/resource/blob/1896940/e00bfe40dc3ceed5e99e3bfd9a47af54/data/T7_R.8.1_Enhanced_Trading_Interface_-_XSD_XML_representation_and_layouts_v.1.2.zip url_eti_8_0 = https://www.eurex.com/resource/blob/1614576/6734877da8532f0e3859c8681c42f5e9/data/T7_Enhanced_Trading_Interface_-_XSD_XML_representation_and_layouts.zip @@ -28,7 +28,7 @@ url_eobi_11_0 = https://www.eurex.com/resource/blob/3312796/8a105318a6a80f40b168 url_eobi_10_1 = https://www.eurex.com/resource/blob/3093156/a85addae564114a5e0a7abaec9b17189/data/T7_EOBI_XML_Representation_v.10.1.1.zip url_eobi_10_0 = https://www.eurex.com/resource/blob/2827418/d9c79556c0aea9bfc9db8b7ef262fe4b/data/T7_EOBI_XML_Representation_v.10.0.1.zip url_eobi_9_1 = https://www.eurex.com/resource/blob/2612882/6e784f79cac7928d39d7dbcf831cc14e/data/T7_EOBI_XML_Representation_v.9.1.1.zip -url_eobi_9_0 = https://www.xetra.com/resource/blob/2221290/00792edace1aaa799a42c67a7638efbf/data/T7_EOBI_XML_Representation_v.9.0.1.zip +url_eobi_9_0 = https://www.eurex.com/resource/blob/2221290/00792edace1aaa799a42c67a7638efbf/data/T7_EOBI_XML_Representation_v.9.0.1.zip url_eobi_8_1 = https://www.eurex.com/resource/blob/2128192/2209fe1a6f0a78a27baf6411698690b0/data/T7_EOBI_XML_Representation_v.8.1.1.zip url_eobi_8_0 = https://www.eurex.com/resource/blob/1741872/baeb2d87c8cc518f2ff2738a74356548/data/T7_EOBI_XML_Representation_v.8.0.3.zip