]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
build: cbindgen
authorDanny Browning <danny.browning@protectwise.com>
Tue, 25 Jun 2019 18:16:52 +0000 (12:16 -0600)
committerJason Ish <jason.ish@oisf.net>
Fri, 24 Jan 2020 16:16:00 +0000 (10:16 -0600)
Rust headers are now generated using cbindgen. If cbindgen is present, they can
be generated during dist, otherwise they will be available for builds.

66 files changed:
.github/workflows/builds.yml
.travis.yml
appveyor.yml
configure.ac
rust/Makefile.am
rust/cbindgen.toml [new file with mode: 0644]
rust/gen-c-headers.py [deleted file]
src/Makefile.am
src/app-layer-dhcp.c
src/app-layer-dns-common.h
src/app-layer-dns-tcp.c
src/app-layer-dns-udp.c
src/app-layer-ftp.c
src/app-layer-ikev2.c
src/app-layer-krb5.c
src/app-layer-nfs-tcp.c
src/app-layer-nfs-udp.c
src/app-layer-ntp.c
src/app-layer-parser.h
src/app-layer-rdp.c
src/app-layer-sip.c
src/app-layer-sip.h
src/app-layer-smb.c
src/app-layer-snmp.c
src/app-layer-template-rust.c
src/app-layer-tftp.c
src/detect-dce-iface.c
src/detect-dce-opnum.c
src/detect-dce-stub-data.c
src/detect-dns-opcode.c
src/detect-dns-query.c
src/detect-krb5-cname.c
src/detect-krb5-errcode.c
src/detect-krb5-msgtype.c
src/detect-krb5-sname.c
src/detect-nfs-procedure.c
src/detect-nfs-version.c
src/detect-sip-method.c
src/detect-sip-protocol.c
src/detect-sip-request-line.c
src/detect-sip-response-line.c
src/detect-sip-stat-code.c
src/detect-sip-stat-msg.c
src/detect-sip-uri.c
src/detect-smb-share.c
src/detect-snmp-community.c
src/detect-snmp-pdu_type.c
src/detect-snmp-version.c
src/detect-template-rust-buffer.c
src/output-json-dhcp.c
src/output-json-dns.c
src/output-json-ikev2.c
src/output-json-krb5.c
src/output-json-nfs.c
src/output-json-rdp.c
src/output-json-sip.c
src/output-json-smb.c
src/output-json-snmp.c
src/output-json-template-rust.c
src/output-json-tftp.c
src/rust-context.h [new file with mode: 0644]
src/rust.h
src/suricata-common.h
src/suricata.c
src/util-debug.c
src/util-lua-dns.c

index 7dac3fcf0db45b289e162756b0d597c9bbb563ce..2eb64f9287161a686ddf0476198a1b5ac8b58fd6 100644 (file)
@@ -70,6 +70,8 @@ jobs:
                 texlive-upquote \
                 texlive-capt-of \
                 texlive-needspace \
+      - name: Install cbindgen
+        run: cargo install --force cbindgen
       - uses: actions/checkout@v1
       - name: Bundling libhtp
         run: git clone https://github.com/OISF/libhtp -b 0.5.x
@@ -139,6 +141,8 @@ jobs:
                 sudo \
                 which \
                 zlib-devel
+      - name: Install cbindgen
+        run: cargo install --force cbindgen
       - name: Download suricata.tar.gz
         uses: actions/download-artifact@v1
         with:
@@ -177,6 +181,8 @@ jobs:
                 sudo \
                 which \
                 zlib-devel
+      - name: Install cbindgen
+        run: cargo install --force cbindgen
       - name: Download suricata.tar.gz
         uses: actions/download-artifact@v1
         with:
@@ -241,6 +247,8 @@ jobs:
                 sudo \
                 which \
                 zlib-devel
+      - name: Install cbindgen
+        run: cargo install --force cbindgen
       - uses: actions/checkout@v1
       - run: git clone https://github.com/OISF/libhtp -b 0.5.x
       - run: ./autogen.sh
@@ -306,6 +314,8 @@ jobs:
         run: |
           add-apt-repository -y ppa:npalix/coccinelle
           apt -y install coccinelle
+      - name: Install cbindgen
+        run: cargo install --force cbindgen
       - uses: actions/checkout@v1
       - run: git clone https://github.com/OISF/libhtp -b 0.5.x
       - run: ./autogen.sh
@@ -357,6 +367,8 @@ jobs:
       - name: Install Rust
         run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.33.0 -y
       - run: echo "::add-path::/github/home/.cargo/bin"
+      - name: Install cbindgen
+        run: cargo install --force cbindgen
       - name: Download suricata.tar.gz
         uses: actions/download-artifact@v1
         with:
@@ -429,6 +441,8 @@ jobs:
                 sudo \
                 zlib1g \
                 zlib1g-dev
+      - name: Install cbindgen
+        run: cargo install --force cbindgen
       - uses: actions/checkout@v1
       - name: Bundling libhtp
         run: git clone https://github.com/OISF/libhtp -b 0.5.x
@@ -490,6 +504,8 @@ jobs:
       - name: Install Rust
         run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.33.0 -y
       - run: echo "::add-path::/github/home/.cargo/bin"
+      - name: Install cbindgen
+        run: cargo install --force cbindgen
       - uses: actions/checkout@v1
       - name: Bundling libhtp
         run: git clone https://github.com/OISF/libhtp -b 0.5.x
@@ -537,6 +553,8 @@ jobs:
           pkg-config \
           rust \
           xz
+      - name: Install cbindgen
+        run: cargo install --force cbindgen
       - run: pip install PyYAML
       - uses: actions/checkout@v1
       - run: git clone https://github.com/OISF/libhtp -b 0.5.x
index 1a7c4ea836ad93599a988011bcedad0f4b8bc98c..bea9fe9a2df8b5c73ed85e7c2f1ac819a02b3cae 100644 (file)
@@ -198,4 +198,6 @@ before_install:
     # match the requested version.
     rustup default "${RUST_VERSION}"
     rustc --version
+
+    cargo install --force cbindgen
   - ./qa/travis-libhtp.sh
index f3d96e06cc6732cbceffb522a44e52ed7b966e71..cc5b52921d3ef3ae7e9d0f050cf2db5f2479b6d3 100644 (file)
@@ -58,6 +58,8 @@ install:
 
 build_script:
   - set Path=%MINGW_DIR%\bin;c:\msys64\usr\bin;%PCAP_PATH%;%Path%
+  - cargo install --force cbindgen
+  - set Path=C:\Users\appveyor\.cargo\bin;%Path%
   - git clone https://github.com/OISF/libhtp -b 0.5.x
   - bash autogen.sh
   - bash configure %CONFIGURE% --disable-shared --%RUST%-rust
index 71efc2d703b564b6cab484c9191eeb94fa224348..54e58e84db4d9b27f9c8cbbb64df18ade37a1c24 100644 (file)
@@ -2387,17 +2387,6 @@ fi
     rust_vendor_comment="# "
     have_rust_vendor="no"
 
-    # We may require Python if the Rust header stubs are not already
-    # generated.
-    if test "x$enable_python" != "xyes" && test ! -f rust/gen/c-headers/rust-core-gen.h; then
-        echo ""
-        echo "   ERROR! Rust support requires Python."
-        echo
-        echo "   Ubuntu: apt install python"
-        echo
-        exit 1
-    fi
-
     if test "x$cross_compiling" = "xyes"; then
       RUST_SURICATA_LIB_XC_DIR="${host_alias}/"
     else
@@ -2411,7 +2400,7 @@ fi
     fi
 
     RUST_LDADD="${RUST_SURICATA_LIB} ${RUST_LDADD}"
-    CFLAGS="${CFLAGS} -I\${srcdir}/../rust/gen/c-headers"
+    CFLAGS="${CFLAGS} -I\${srcdir}/../rust/gen"
     AC_SUBST(RUST_SURICATA_LIB)
     AC_SUBST(RUST_LDADD)
     if test "x$CARGO_HOME" = "x"; then
@@ -2470,6 +2459,27 @@ fi
         have_cargo_vendor=$have_cargo_vendor_bin
     fi
 
+    AC_CHECK_FILES([$srcdir/rust/gen], [have_rust_headers="yes"])
+    AC_DEFINE([HAVE_RUST_HEADERS],[1],[Enable Rust language])
+    AM_CONDITIONAL([HAVE_RUST_HEADERS], [test "x$have_rust_headers" = "xyes"])
+    if test "x$have_rust_headers" != "xyes"; then
+      AC_PATH_PROG(HAVE_CARGO_CBINDGEN, cbindgen, "no") 
+      if test "x$HAVE_CARGO_CBINDGEN" = "xno"; then
+        echo "  Warning: cbindgen not found, it is required to generate header files"
+        echo "  To install: cargo install --force cbindgen"
+        AC_MSG_ERROR([cbindgen required])
+      fi
+      required_version=0.9.0
+      cbindgen_version=$(cbindgen --version | cut -d' ' -f2-)
+      lowest_version=$(printf '%s\n' $required_version $cbindgen_version | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | head -n1)
+      if test "x$lowest_version" != "x$required_version"; then
+        HAVE_CARGO_BINDGEN="no"
+        echo "  Warning: cbindgen must be at least version $required_version, version was $cbindgen_version, lowest version was $lowest_version"
+        echo "  To install: cargo install --force cbindgen"
+        AC_MSG_ERROR([incorrect cbindgen version])
+      fi
+    fi
+
     AM_CONDITIONAL([HAVE_CARGO_VENDOR], [test "x$have_cargo_vendor" != "xno"])
 
     AC_ARG_ENABLE(rust_strict,
index 747a59fb05fb8b7315d3fcd1675c82f7de8c86c1..534a5c8cb71c0e7518946c15a261523ed440c801 100644 (file)
@@ -1,6 +1,7 @@
 EXTRA_DIST =   src \
                .cargo/config.in \
-               gen-c-headers.py
+                gen \
+                cbindgen.toml
 
 if HAVE_CARGO_VENDOR
 EXTRA_DIST +=  vendor
@@ -22,10 +23,9 @@ if RUST_CROSS_COMPILE
 RUST_TARGET = --target $(host_triplet)
 endif
 
-all-local:
-if HAVE_PYTHON
-       cd $(top_srcdir)/rust && $(HAVE_PYTHON) ./gen-c-headers.py
-endif
+build-rust:
+       cd $(top_srcdir)/rust
+
 if HAVE_CYGPATH
        @rustup_home@ \
                CARGO_HOME="$(CARGO_HOME)" \
@@ -40,12 +40,30 @@ else
                        --features "$(RUST_FEATURES)" $(RUST_TARGET)
 endif
 
+if HAVE_RUST_HEADERS
+
+all-local: build-rust
+       echo Rust headers available
+
+clean-local:
+       -rm -rf target
+
+distclean-local: clean-local
+       rm -rf vendor Cargo.lock
+
+else 
+
+all-local: gen-headers build-rust
+       $(info Generating rust headers)
+
 clean-local:
        -rm -rf target gen
 
 distclean-local: clean-local
        rm -rf vendor gen Cargo.lock
 
+endif
+
 check:
        CARGO_HOME="$(CARGO_HOME)" @rustup_home@ \
                CARGO_TARGET_DIR="$(abs_top_builddir)/rust/target" \
@@ -58,11 +76,6 @@ else
 vendor:
 endif
 
-# Can only include the headers if we have Python to generate them.
-if HAVE_PYTHON
-EXTRA_DIST +=  gen/c-headers
-gen/c-headers:
-       cd $(top_srcdir)/rust && $(HAVE_PYTHON) ./gen-c-headers.py
-else
-gen/c-headers:
-endif
+gen-headers: FORCE
+       cbindgen --config cbindgen.toml --output "gen/rust-bindings.h" > /dev/null
+FORCE:
diff --git a/rust/cbindgen.toml b/rust/cbindgen.toml
new file mode 100644 (file)
index 0000000..f6117c4
--- /dev/null
@@ -0,0 +1,151 @@
+# The language to output bindings in
+#
+# possible values: "C", "C++"
+#
+# default: "C++"
+language = "C"
+
+
+# Options for wrapping the contents of the header:
+
+# An optional string of text to output at the beginning of the generated file
+# default: doesn't emit anything
+header = """/* Copyright (C) 2019 Open Information Security Foundation
+*
+* You can copy, redistribute or modify this Program under the terms of
+* the GNU General Public License version 2 as published by the Free
+* Software Foundation.
+*
+* 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
+* version 2 along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+* 02110-1301, USA.
+*/"""
+
+# An optional name to use as an include guard
+# default: doesn't emit an include guard
+include_guard = "__RUST_BINDINGS_GEN_H_"
+
+# An optional string of text to output between major sections of the generated
+# file as a warning against manual editing
+#
+# default: doesn't emit anything
+autogen_warning = "/* DO NOT EDIT This file is autogenerated by cbindgen. Don't modify this manually. */"
+
+# Whether to include a comment with the version of cbindgen used to generate the file
+# default: false
+include_version = true
+
+# A list of headers to #include (with quotes)
+# default: []
+includes = ["rust.h"]
+
+# The desired length of a line to use when formatting lines
+# default: 100
+line_length = 80
+
+# The amount of spaces to indent by
+# default: 2
+tab_width = 4
+
+# How the generated documentation should be commented.
+#
+# possible values:
+# * "c": /* like this */
+# * "c99": // like this
+# * "c++": /// like this
+# * "doxy": like C, but with leading *'s on each line
+# * "auto": "c++" if that's the language, "doxy" otherwise
+#
+# default: "auto"
+documentation_style = "doxy"
+
+
+[export]
+# A list of additional items to always include in the generated bindings if they're
+# found but otherwise don't appear to be used by the public API.
+#
+# default: []
+include = ["AppLayerGetTxIterTuple"]
+
+# A list of items to not include in the generated bindings
+# default: []
+exclude = [
+    "AppLayerDecoderEvents",
+    "CLuaState",
+    "DetectEngineState",
+    "Flow",
+    "FileContainer",
+    "JsonT",
+    "IKEV2State",
+    "IKEV2Transaction",
+    "KRB5State",
+    "KRB5Transaction",
+    "NTPState",
+    "NTPTransaction",
+    "SNMPState",
+    "SNMPTransaction",
+    "SuricataContext",
+    "SuricataFileContext",
+    "TFTPState",
+    "TFTPTransaction"
+]
+
+# Types of items that we'll generate. If empty, then all types of item are emitted.
+#
+# possible items: (TODO: explain these in detail)
+# * "constants":
+# * "globals":
+# * "enums":
+# * "structs":
+# * "unions":
+# * "typedefs":
+# * "opaque":
+# * "functions":
+#
+# default: []
+item_types = ["structs","opaque","functions"]
+
+# Whether applying rules in export.rename prevents export.prefix from applying.
+#
+# e.g. given this toml:
+#
+# [export]
+# prefix = "capi_"
+[export.rename]
+"DNSState" = "RSDNSState"
+"DNSTransaction" = "RSDNSTransaction"
+"JsonT" = "json_t"
+"CLuaState" = "lua_State"
+
+#
+# You get the following results:
+#
+# renaming_overrides_prefixing = true:
+# "MyType" => "my_cool_type"
+#
+# renaming_overrides_prefixing = false:
+# "MyType => capi_my_cool_type"
+#
+# default: false
+renaming_overrides_prefixing = "true"
+
+[parse]
+# A black list of crate names that are not allowed to be parsed.
+# default: []
+exclude = ["libc"]
+
+[parse.expand]
+# A list of feature names that should be used when running `cargo expand`. This
+# combines with `default_features` like in your `Cargo.toml`. Note that the features
+# listed here are features for the current crate being built, *not* the crates
+# being expanded. The crate's `Cargo.toml` must take care of enabling the
+# appropriate features in its dependencies
+#
+# default: []
+features = ["cbindgen"]
diff --git a/rust/gen-c-headers.py b/rust/gen-c-headers.py
deleted file mode 100755 (executable)
index ea7f873..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-#! /usr/bin/env python2
-
-# This script will scan Rust source files looking for extern "C"
-# functions and generate C header files from them with a filename
-# based on the Rust filename.
-#
-# Usage: From the top suricata source directory:
-#
-#    ./rust/gen-c-headers.py
-#
-
-from __future__ import print_function
-
-import sys
-import os
-import re
-from io import StringIO
-
-template = """/* Copyright (C) 2017 Open Information Security Foundation
- *
- * You can copy, redistribute or modify this Program under the terms of
- * the GNU General Public License version 2 as published by the Free
- * Software Foundation.
- *
- * 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
- * version 2 along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-/*
- * DO NOT EDIT. This file is automatically generated.
- */
-
-#ifndef __%(name)s__
-#define __%(name)s__
-
-%(prototypes)s
-#endif /* ! __%(name)s__ */
-"""
-
-# Map of Rust types to C types.
-type_map = {
-    "bool": "bool",
-    "i8": "int8_t",
-    "i16" :"int16_t",
-    "i32" :"int32_t",
-    "i64" :"int64_t",
-
-    "u8": "uint8_t",
-    "u16" :"uint16_t",
-    "u32" :"uint32_t",
-    "u64" :"uint64_t",
-
-    "std::os::raw::c_void": "void",
-    "c_void": "void",
-
-    "std::os::raw::c_char": "char",
-    "c_char": "char",
-    "std::os::raw::c_int": "int",
-    "c_int": "int",
-    "std::os::raw::int8_t": "int8_t",
-    "std::os::raw::int32_t": "int32_t",
-
-    "std::os::raw::uint8_t": "uint8_t",
-    "std::os::raw::uint16_t": "uint16_t",
-    "std::os::raw::uint32_t": "uint32_t",
-    "std::os::raw::uint64_t": "uint64_t",
-
-    "SuricataContext": "SuricataContext",
-    "SuricataFileContext": "SuricataFileContext",
-    "FileContainer": "FileContainer",
-    "core::Flow": "Flow",
-    "Flow": "Flow",
-    "DNSState": "RSDNSState",
-    "DNSTransaction": "RSDNSTransaction",
-    "NFSState": "NFSState",
-    "NFSTransaction": "NFSTransaction",
-    "NTPState": "NTPState",
-    "NTPTransaction": "NTPTransaction",
-    "TFTPTransaction": "TFTPTransaction",
-    "TFTPState": "TFTPState",
-    "SMBState": "SMBState",
-    "SMBTransaction": "SMBTransaction",
-    "SNMPState": "SNMPState",
-    "SNMPTransaction": "SNMPTransaction",
-    "IKEV2State": "IKEV2State",
-    "IKEV2Transaction": "IKEV2Transaction",
-    "KRB5State": "KRB5State",
-    "KRB5Transaction": "KRB5Transaction",
-    "SIPState": "SIPState",
-    "SIPTransaction": "SIPTransaction",
-    "JsonT": "json_t",
-    "DetectEngineState": "DetectEngineState",
-    "core::DetectEngineState": "DetectEngineState",
-    "core::AppLayerDecoderEvents": "AppLayerDecoderEvents",
-    "AppLayerDecoderEvents": "AppLayerDecoderEvents",
-    "core::AppLayerEventType": "AppLayerEventType",
-    "applayer::AppLayerGetTxIterTuple": "AppLayerGetTxIterTuple",
-    "AppLayerGetTxIterTuple": "AppLayerGetTxIterTuple",
-    "AppLayerEventType": "AppLayerEventType",
-    "CLuaState": "lua_State",
-    "Store": "Store",
-    "AppProto": "AppProto",
-    "DetectDnsOpcode": "void *",
-}
-
-def convert_type(rs_type):
-    m = re.match("^[^\s]+$", rs_type)
-    if m:
-        if rs_type in type_map:
-            return type_map[rs_type]
-
-    m = re.match("^(.*)(\s[^\s]+)$", rs_type)
-    if m:
-        mod = m.group(1).strip()
-        rtype = m.group(2).strip()
-        if rtype in type_map:
-            if mod in [
-                    "*mut",
-                    "* mut",
-                    "&mut",
-                    "&'static mut",
-                    ]:
-                return "%s *" % (type_map[rtype])
-            elif mod in [
-                    "*const",
-                    "* const"]:
-                return "const %s *" % (type_map[rtype])
-            elif mod in [
-                    "*mut *const",
-                    "*mut*const"]:
-                return "const %s **" % (type_map[rtype])
-            else:
-                raise Exception("Unknown modifier '%s' in '%s'." % (
-                    mod, rs_type))
-        else:
-            raise Exception("Unknown type: %s" % (rtype))
-
-    raise Exception("Failed to parse Rust type: %s" % (rs_type))
-
-def make_output_filename(filename):
-    if filename.startswith("./"):
-        filename = filename[2:]
-    parts = filename.split(os.path.sep)[1:]
-    last = os.path.splitext(parts.pop())[0]
-    outpath = "./gen/c-headers/rust-%s-%s-gen.h" % (
-        "-".join(parts), last)
-    return outpath.replace("--", "-")
-
-def write_header(fileobj, filename):
-    filename = os.path.basename(filename).replace(
-        "-", "_").replace(".", "_").upper()
-    fileobj.write(file_header % {"name": filename})
-
-def should_regen(input_filename, output_filename):
-    """Check if a file should be regenerated. If the output doesn't exist,
-    or the input is newer than the output return True. Otherwise
-    return False.
-
-    """
-    if not os.path.exists(output_filename):
-        return True
-    if os.stat(input_filename).st_mtime > os.stat(output_filename).st_mtime:
-        return True
-    return False
-
-def gen_headers(filename):
-
-    output_filename = make_output_filename(filename)
-
-    if not should_regen(filename, output_filename):
-        return
-
-    buf = open(filename, "rb").read().decode("utf-8")
-    writer = StringIO()
-
-    for fn in re.findall(
-            r"^pub (unsafe )?extern \"C\" fn ([A_Za-z0-9_]+)\(([^{]+)?\)"
-            r"(\s+-> ([^{]+))?",
-            buf,
-            re.M | re.DOTALL):
-
-        args = []
-
-        fnName = fn[1]
-
-        for arg in fn[2].split(","):
-            if not arg.strip():
-                continue
-            arg_name, rs_type = arg.split(":", 1)
-            arg_name = arg_name.strip()
-            rs_type = rs_type.strip()
-            c_type = convert_type(rs_type)
-
-            if arg_name != "_":
-                args.append("%s %s" % (c_type, arg_name))
-            else:
-                args.append(c_type)
-
-        if not args:
-            args.append("void")
-
-        retType = fn[4].strip()
-        if retType == "":
-            returns = "void"
-        else:
-            returns = convert_type(retType)
-
-        writer.write(u"%s %s(%s);\n" % (returns, fnName, ", ".join(args)))
-
-    if writer.tell() > 0:
-        print("Writing %s" % (output_filename))
-        if not os.path.exists(os.path.dirname(output_filename)):
-            os.makedirs(os.path.dirname(output_filename))
-        with open(output_filename, "w") as output:
-            output.write(template % {
-                "prototypes": writer.getvalue(),
-                "name": os.path.basename(output_filename).replace(
-                    "-", "_").replace(".", "_").upper()
-            })
-
-def main():
-
-    rust_top = os.path.dirname(sys.argv[0])
-    os.chdir(rust_top)
-
-    for dirpath, dirnames, filenames in os.walk("./src"):
-        for filename in filenames:
-            if filename.endswith(".rs"):
-                path = os.path.join(dirpath, filename)
-                gen_headers(path)
-
-if __name__ == "__main__":
-    sys.exit(main())
index 8999f5dac88314ac8f8b0b13931188cdbb712f6b..e755556b4d08fffb23ce65a3273677d956d456ed 100755 (executable)
@@ -382,6 +382,7 @@ runmode-unix-socket.c runmode-unix-socket.h \
 runmode-windivert.c runmode-windivert.h \
 runmodes.c runmodes.h \
 rust.h \
+rust-context.h \
 source-af-packet.c source-af-packet.h \
 source-erf-dag.c source-erf-dag.h \
 source-erf-file.c source-erf-file.h \
index 33a38564a01a7a0b016a39d8098f4d2b1f8eb598..243cc63b73639c4afae2a01f8cebd51fe74af1a9 100644 (file)
@@ -25,7 +25,7 @@
 #include "util-unittest.h"
 #include "app-layer-parser.h"
 #include "app-layer-dhcp.h"
-#include "rust-dhcp-dhcp-gen.h"
+#include "rust.h"
 
 void RegisterDHCPParsers(void)
 {
index f5087ca3e38853c21559de0a29d1639efc0aa824..31892ebb529657aff3bf5b2682ed6025883bc791 100644 (file)
@@ -121,8 +121,6 @@ enum {
 };
 
 /** Opaque Rust types. */
-typedef struct RSDNSState_ RSDNSState;
-typedef struct RSDNSTransaction_ RSDNSTransaction;
 
 /** \brief DNS packet header */
 typedef struct DNSHeader_ {
index ac0f4b5de7c533e331ffc5574e35336216af9050..c47407c1cb25cbc89435e9589af6d2f5abdf6bd3 100644 (file)
@@ -26,7 +26,7 @@
 #include "util-unittest.h"
 
 #include "app-layer-dns-tcp.h"
-#include "rust-dns-dns-gen.h"
+#include "rust.h"
 
 #ifdef UNITTESTS
 static void RustDNSTCPParserRegisterTests(void);
index ec2fac5388d3697ad0e96440c29bbfdb4eab2d40..69251b3a7ec63a0ccde291cdd52a507a73105394 100644 (file)
@@ -26,7 +26,7 @@
 #include "util-unittest.h"
 
 #include "app-layer-dns-udp.h"
-#include "rust-dns-dns-gen.h"
+#include "rust.h"
 
 #ifdef UNITTESTS
 static void RustDNSUDPParserRegisterTests(void);
index 9574cf98f99feaba770e6cde5620a8952ec9274c..5561c28324f2911d197b57e3e3a5402b34c52c77 100644 (file)
@@ -59,9 +59,8 @@
 #include "util-mem.h"
 #include "util-misc.h"
 
-#include "rust-ftp-mod-gen.h"
-
 #include "output-json.h"
+#include "rust.h"
 
 typedef struct FTPThreadCtx_ {
     MpmThreadCtx *ftp_mpm_thread_ctx;
index 5de0014cac6dbe3437e061932b92309a1eda50c2..bc34d426db41508d2dad7c02834eaf3634f66f27 100644 (file)
@@ -33,8 +33,7 @@
 #include "app-layer-parser.h"
 
 #include "app-layer-ikev2.h"
-
-#include "rust-ikev2-ikev2-gen.h"
+#include "rust.h"
 
 void RegisterIKEV2Parsers(void)
 {
index ac73ffcf6cdc4ec76f6bf77f0df4443f0ad18708..7b2b63f11999a98af8bd6d6061c19b28a7fe3d08 100644 (file)
@@ -33,8 +33,7 @@
 #include "app-layer-parser.h"
 
 #include "app-layer-krb5.h"
-
-#include "rust-krb-krb5-gen.h"
+#include "rust.h"
 
 void RegisterKRB5Parsers(void)
 {
index 96f4f0bcf9204e3566a1a525ec3c7a66e22abaea..08a0b5139111accba1c9666783893f32e3831a56 100644 (file)
@@ -38,7 +38,6 @@
 #include "app-layer-nfs-tcp.h"
 
 #include "rust.h"
-#include "rust-nfs-nfs-gen.h"
 
 /* The default port to probe for echo traffic if not provided in the
  * configuration file. */
index c3cad69d225da4820d0e13147ae9ea964c96f8ef..31b68d5d58445b5d0268b18d2741905e06b854ff 100644 (file)
@@ -35,7 +35,6 @@
 #include "app-layer-nfs-udp.h"
 
 #include "rust.h"
-#include "rust-nfs-nfs-gen.h"
 
 /* The default port to probe for echo traffic if not provided in the
  * configuration file. */
index 00c1dc4f83ee7383febced66d852b78594cb9ddd..fa7f95d71124f4852b59dcfe3dab8dd88e98dbb9 100644 (file)
@@ -33,8 +33,7 @@
 #include "app-layer-parser.h"
 
 #include "app-layer-ntp.h"
-
-#include "rust-ntp-ntp-gen.h"
+#include "rust.h"
 
 void RegisterNTPParsers(void)
 {
index 0ce16c08985f7226bbeaaa04aad944d6ecec975b..02a1ee5485ff3a8e1d46be847ca5cd5471a6157c 100644 (file)
@@ -29,6 +29,7 @@
 #include "detect-engine-state.h"
 #include "util-file.h"
 #include "stream-tcp-private.h"
+#include "rust.h"
 
 /* Flags for AppLayerParserState. */
 #define APP_LAYER_PARSER_EOF                    BIT_U8(0)
@@ -94,12 +95,6 @@ typedef int (*AppLayerParserFPtr)(Flow *f, void *protocol_state,
         const uint8_t *buf, uint32_t buf_len,
         void *local_storage, const uint8_t flags);
 
-typedef struct AppLayerGetTxIterTuple {
-    void *tx_ptr;
-    uint64_t tx_id;
-    bool has_next;
-} AppLayerGetTxIterTuple;
-
 typedef struct AppLayerGetTxIterState {
     union {
         void *ptr;
index 1bae56227fb51ab65065b36b0c1be347e9915906..2611de4237b03c9aa18e6381e4d0ca3a3a9502b4 100644 (file)
@@ -30,7 +30,7 @@
 #include "app-layer-detect-proto.h"
 #include "app-layer-parser.h"
 #include "app-layer-rdp.h"
-#include "rust-rdp-rdp-gen.h"
+#include "rust.h"
 
 void RegisterRdpParsers(void) {
     SCLogDebug("Registering rdp parser");
index aa42044f4c681846a3df4968e203abdbe83d0dec..3717db3f75c5d2561ef2ca18af3f5c950ff23e6c 100644 (file)
@@ -33,7 +33,7 @@
 #include "app-layer-parser.h"
 
 #include "app-layer-sip.h"
-#include "rust-sip-sip-gen.h"
+#include "rust.h"
 
 void RegisterSIPParsers(void)
 {
index 0bae92496d32119b26439a9be5f1cb8f94b970de..299637179dadb21c760a5ef6f077e0b26d6799cb 100644 (file)
@@ -28,7 +28,5 @@ void RegisterSIPParsers(void);
 void SIPParserRegisterTests(void);
 
 /** Opaque Rust types. */
-typedef struct SIPState_ SIPState;
-typedef struct SIPTransaction_ SIPTransaction;
 
 #endif /* __APP_LAYER_SIP_H__ */
index 0b7f3bcab3ec5a4075fceac6dc0490e08b9963fd..a0917ff1633e83975637012a076109bcdd9ddbc7 100644 (file)
@@ -26,8 +26,6 @@
 
 #include "rust.h"
 #include "app-layer-smb.h"
-#include "rust-smb-smb-gen.h"
-#include "rust-smb-files-gen.h"
 #include "util-misc.h"
 
 #define MIN_REC_SIZE 32+4 // SMB hdr + nbss hdr
index 3f39148b1ef40329b0e768776071813c1fe296e6..589aa451ed4801939196df675321641da1137228 100644 (file)
@@ -34,8 +34,7 @@
 #include "app-layer-parser.h"
 
 #include "app-layer-snmp.h"
-
-#include "rust-snmp-snmp-gen.h"
+#include "rust.h"
 
 void RegisterSNMPParsers(void)
 {
index 201bec5b7eef668844fe93f878fdbbf1ec9f1252..e42e1247ea53276c87b57ac1169d3eb6d93f948a 100644 (file)
@@ -43,8 +43,7 @@
 #include "app-layer-parser.h"
 
 #include "app-layer-template-rust.h"
-
-#include "rust-applayertemplate-template-gen.h"
+#include "rust.h"
 
 void RegisterTemplateRustParsers(void)
 {
index fc4be55e059e7654c2e14f188d3c00e02a9ca7f3..95891371bf79a94791b36df21538e9e0807dcfb6 100644 (file)
@@ -35,8 +35,7 @@
 #include "app-layer-parser.h"
 
 #include "app-layer-tftp.h"
-
-#include "rust-tftp-tftp-gen.h"
+#include "rust.h"
 
 /* The default port to probe if not provided in the configuration file. */
 #define TFTP_DEFAULT_PORT "69"
index 242657f534874e329611c7391f3bd52cf1209a97..0c39f99aaee1ceea1389148296213be2d13565cf 100644 (file)
@@ -48,7 +48,6 @@
 #include "stream-tcp.h"
 
 #include "rust.h"
-#include "rust-smb-detect-gen.h"
 
 #define PARSE_REGEX "^\\s*([0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12})(?:\\s*,\\s*(<|>|=|!)([0-9]{1,5}))?(?:\\s*,\\s*(any_frag))?\\s*$"
 
index 93c83e98db4cbc4019e028bc5dd397eddce4d238..1edb9897fbcf27e1077fd5e0adb5f4d8e79e5318 100644 (file)
@@ -49,7 +49,6 @@
 #include "stream-tcp.h"
 
 #include "rust.h"
-#include "rust-smb-detect-gen.h"
 
 #define PARSE_REGEX "^\\s*([0-9]{1,5}(\\s*-\\s*[0-9]{1,5}\\s*)?)(,\\s*[0-9]{1,5}(\\s*-\\s*[0-9]{1,5})?\\s*)*$"
 
index ccbaf341ccff722835f16f770a3186a8a7a984d6..66b94dc04c085d6524d51a2675dcfcf36f47ca4a 100644 (file)
@@ -55,7 +55,6 @@
 #include "stream-tcp.h"
 
 #include "rust.h"
-#include "rust-smb-detect-gen.h"
 
 #define BUFFER_NAME "dce_stub_data"
 #define KEYWORD_NAME "dce_stub_data"
index 68edcdca4106a244baa3697a6dc25b1ebd59073c..067ccbfc46877569994849dbc42e33e59510f900 100644 (file)
@@ -21,7 +21,7 @@
 #include "detect-engine.h"
 #include "detect-dns-opcode.h"
 #include "app-layer-dns-common.h"
-#include "rust-dns-detect-gen.h"
+#include "rust.h"
 
 static int dns_opcode_list_id = 0;
 
index e50b23e9ae29e095de8ec6b0bf132a06a8fc6321..74d99f1c1d38b69565e5255a85cd20dd4f36859e 100644 (file)
@@ -59,8 +59,7 @@
 #include "detect-engine-dns.h"
 
 #include "util-unittest-helper.h"
-
-#include "rust-dns-dns-gen.h"
+#include "rust.h"
 
 static int DetectDnsQuerySetup (DetectEngineCtx *, Signature *, const char *);
 static void DetectDnsQueryRegisterTests(void);
index e502a1e9fbd6ff3ca0c28916edb90a78d7dfc9e1..519e4f2945648a8798cafe794c5cc178c5984993 100644 (file)
@@ -35,7 +35,6 @@
 
 #include "rust.h"
 #include "app-layer-krb5.h"
-#include "rust-krb-detect-gen.h"
 
 static int g_krb5_cname_buffer_id = 0;
 
index 6c1224ab40286417ec1bfb02ca15d2c98d5b110d..3dd88fdcbdfc0a133efbbf2b7103d4b4aab8eee3 100644 (file)
@@ -30,7 +30,7 @@
 #include "detect-krb5-errcode.h"
 
 #include "app-layer-krb5.h"
-#include "rust-krb-detect-gen.h"
+#include "rust.h"
 
 /**
  * \brief Regex for parsing our keyword options
index 0810ef533a8cb376118fe2ed05631fb76e44d903..d08e104e1f14674093d12384d663a1235a785e70 100644 (file)
@@ -30,7 +30,7 @@
 #include "detect-krb5-msgtype.h"
 
 #include "app-layer-krb5.h"
-#include "rust-krb-detect-gen.h"
+#include "rust.h"
 
 /**
  * \brief Regex for parsing our keyword options
index 85a2ab253f61f981fd280286a5364e6fea2f3cdc..bd05823b27392ebe05e6d372d7d73aa4b66cce11 100644 (file)
@@ -35,7 +35,6 @@
 
 #include "rust.h"
 #include "app-layer-krb5.h"
-#include "rust-krb-detect-gen.h"
 
 static int g_krb5_sname_buffer_id = 0;
 
index 5fafcdc2a12cf09cd308b83d9d192012b6284c3c..fcdc82223914570facebfee87b7fb2c46deb3d11 100644 (file)
@@ -45,7 +45,6 @@
 
 #include "app-layer-nfs-tcp.h"
 #include "rust.h"
-#include "rust-nfs-nfs-gen.h"
 
 /**
  *   [nfs_procedure]:[<|>]<proc>[<><proc>];
index 908a2b4e58f9e12d58a1737e223d34a84544aff9..17aac2f28d2e3d95cf29e79f92ca835ee118f656 100644 (file)
@@ -45,7 +45,6 @@
 
 #include "app-layer-nfs-tcp.h"
 #include "rust.h"
-#include "rust-nfs-nfs-gen.h"
 
 /**
  *   [nfs_procedure]:[<|>]<proc>[<><proc>];
index 9d6b472ce785f8498f8aadb0e1b7764cfa90a179..fc054e3bded485611e1e4d505a6e9e756513dd8d 100644 (file)
@@ -53,7 +53,6 @@
 
 #include "rust.h"
 #include "app-layer-sip.h"
-#include "rust-sip-detect-gen.h"
 
 #define KEYWORD_NAME "sip.method"
 #define KEYWORD_DOC  "sip-keywords.html#sip-method"
index 4bc3d4745f2e0396c0df76176e427d8f64cc0d21..839261ff4e6f6f7eb21506a69b1999b632753f78 100644 (file)
@@ -54,7 +54,6 @@
 
 #include "rust.h"
 #include "app-layer-sip.h"
-#include "rust-sip-detect-gen.h"
 
 #define KEYWORD_NAME "sip.protocol"
 #define KEYWORD_DOC  "sip-keywords.html#sip-protocol"
index 20fe8a7ab766a73f920a3a87978accc8c7af514a..af1c446a0093e2c5b41bbfaa963bc9b31fceeb8a 100644 (file)
@@ -53,7 +53,6 @@
 
 #include "rust.h"
 #include "app-layer-sip.h"
-#include "rust-sip-detect-gen.h"
 
 #define KEYWORD_NAME "sip.request_line"
 #define KEYWORD_DOC  "sip-keywords.html#sip-request-line"
index 33781fbba8f0bd018070467175b8cb0888a742d7..dabcf3e28568ac1c93d849126999fad6f1c78b27 100644 (file)
@@ -53,7 +53,6 @@
 
 #include "rust.h"
 #include "app-layer-sip.h"
-#include "rust-sip-detect-gen.h"
 
 #define KEYWORD_NAME "sip.response_line"
 #define KEYWORD_DOC  "sip-keywords.html#sip-response-line"
index 00553e1179e47c383cc7f1bb23164a4b631006c1..f06f67635b4f0ee1b0c5ae1e4812ed782465ea88 100644 (file)
@@ -54,7 +54,6 @@
 
 #include "rust.h"
 #include "app-layer-sip.h"
-#include "rust-sip-detect-gen.h"
 
 #define KEYWORD_NAME "sip.stat_code"
 #define KEYWORD_DOC  "sip-keywords.html#sip-stat-code"
index ffc3aaca2b70232834de5f2c8d673ea3e548c320..c2d39af7554a8f3c69170442c2118d1925af1528 100644 (file)
@@ -54,7 +54,6 @@
 
 #include "rust.h"
 #include "app-layer-sip.h"
-#include "rust-sip-detect-gen.h"
 
 #define KEYWORD_NAME "sip.stat_msg"
 #define KEYWORD_DOC  "sip-keywords.html#sip-stat-msg"
index 74bcddc2e5506e444bf8cb79ea991f434857f16b..8aeb335608885d39f064960c9647ca5c799f54a8 100644 (file)
@@ -54,7 +54,6 @@
 
 #include "rust.h"
 #include "app-layer-sip.h"
-#include "rust-sip-detect-gen.h"
 
 #define KEYWORD_NAME "sip.uri"
 #define KEYWORD_DOC  "sip-keywords.html#sip-uri"
index f2a21d9033b383857d108534ce7f95fa1fd174bc..f770929d4533bd81173ec66b0ecb7182863db7b7 100644 (file)
@@ -35,7 +35,6 @@
 
 #include "detect-smb-share.h"
 #include "rust.h"
-#include "rust-smb-detect-gen.h"
 
 #define BUFFER_NAME "smb_named_pipe"
 #define KEYWORD_NAME "smb.named_pipe"
index 55682b1267709c9d0ef3a807fce34a18e9429ff9..7e2efd8a8b9d4fc9dc436e23e3e9c75e97ae4848 100644 (file)
@@ -34,9 +34,7 @@
 #include "detect-engine-content-inspection.h"
 #include "detect-snmp-community.h"
 #include "app-layer-parser.h"
-
-#include "rust-snmp-snmp-gen.h"
-#include "rust-snmp-detect-gen.h"
+#include "rust.h"
 
 static int DetectSNMPCommunitySetup(DetectEngineCtx *, Signature *,
     const char *);
index d2d4f49372290367ab57432e1a50a4eabb1793e6..9a7068d26fe17b74c25c5e7228b861ac5a7fc421 100644 (file)
@@ -29,9 +29,7 @@
 #include "detect-engine-content-inspection.h"
 #include "detect-snmp-pdu_type.h"
 #include "app-layer-parser.h"
-
-#include "rust-snmp-snmp-gen.h"
-#include "rust-snmp-detect-gen.h"
+#include "rust.h"
 
 /**
  *   [snmp.pdu_type]:<type>;
index 7ca32d341f0af2a88647ec4d10144ce52301b224..f1240a96ea80f6f936ddb5d3bf3fbdd2ac8105af 100644 (file)
@@ -29,9 +29,7 @@
 #include "detect-engine-content-inspection.h"
 #include "detect-snmp-version.h"
 #include "app-layer-parser.h"
-
-#include "rust-snmp-snmp-gen.h"
-#include "rust-snmp-detect-gen.h"
+#include "rust.h"
 
 /**
  *   [snmp.version]:[<|>|<=|>=]<version>;
index 1de4655191241c04c6e9006e35cefb21aab7b56e..2979530421946d6b376819afbdc0be24e118d667 100644 (file)
@@ -38,7 +38,8 @@
 #include "detect-engine-content-inspection.h"
 #include "detect-template-rust-buffer.h"
 #include "app-layer-parser.h"
-#include "rust-applayertemplate-template-gen.h"
+#include "rust.h"
+
 
 static int DetectTemplateRustBufferSetup(DetectEngineCtx *, Signature *,
     const char *);
index e715de193a4d5ca5a23c2fbaee00fed68deb31c5..18cc8259e94b2dd4c3403b786bd86a0325f25b1e 100644 (file)
@@ -44,8 +44,8 @@
 
 #include "app-layer-dhcp.h"
 #include "output-json-dhcp.h"
+#include "rust.h"
 
-#include "rust-dhcp-logger-gen.h"
 
 typedef struct LogDHCPFileCtx_ {
     LogFileCtx *file_ctx;
index 7e915d4f903159f82d5a8360e90232f203e2e745..099106abac63e87774d3e9bdce5dc2d07585d3ee 100644 (file)
@@ -50,8 +50,7 @@
 
 #include "output-json.h"
 #include "output-json-dns.h"
-
-#include "rust-dns-log-gen.h"
+#include "rust.h"
 
 /* we can do query logging as well, but it's disabled for now as the
  * TX id handling doesn't expect it */
index c36525ba3ec326dd563faa4b1b78816e6a9dc3df..54ac2d63b1cf55a0e45df8d9a871a14205c32577 100644 (file)
@@ -48,7 +48,6 @@
 #include "output-json-ikev2.h"
 
 #include "rust.h"
-#include "rust-ikev2-log-gen.h"
 
 typedef struct LogIKEv2FileCtx_ {
     LogFileCtx *file_ctx;
index a6933c07ff0dd32fe71509b08b4b3b738cf398e3..fb16855a24981ba710c9684d80556e8a73278ba7 100644 (file)
@@ -48,7 +48,6 @@
 #include "output-json-krb5.h"
 
 #include "rust.h"
-#include "rust-krb-log-gen.h"
 
 typedef struct LogKRB5FileCtx_ {
     LogFileCtx *file_ctx;
index 7b5683b8613cf0b6a7bb83613f5fbdf377a96dd9..b3830981a353c858ac654c2b0a4fb5ae2ae9918d 100644 (file)
@@ -47,7 +47,6 @@
 #include "output-json-nfs.h"
 
 #include "rust.h"
-#include "rust-nfs-log-gen.h"
 
 json_t *JsonNFSAddMetadataRPC(const Flow *f, uint64_t tx_id)
 {
index 875033e18bdcc31128bc5a5f4c88ca9b22d2ec10..d1daa17b6ec6eb5c7dc6e3471b23435523086d42 100644 (file)
@@ -41,7 +41,7 @@
 #include "app-layer-parser.h"
 #include "app-layer-rdp.h"
 #include "output-json-rdp.h"
-#include "rust-rdp-log-gen.h"
+#include "rust.h"
 
 typedef struct LogRdpFileCtx_ {
     LogFileCtx *file_ctx;
index aea820e600757212771ec70ea1c596d45efcf20f..ca8491bc2fa7f4ab7fdd8f0a56fda79ca3998ebf 100644 (file)
@@ -48,7 +48,6 @@
 #include "output-json-sip.h"
 
 #include "rust.h"
-#include "rust-sip-log-gen.h"
 
 typedef struct LogSIPFileCtx_ {
     LogFileCtx *file_ctx;
index d5ada56d54ef07eedd53adea3b5ac7e1c3d713f7..61db3fd3b2f1179b11edc56b5ffb9143a09c1a02 100644 (file)
@@ -46,7 +46,6 @@
 #include "output-json-smb.h"
 
 #include "rust.h"
-#include "rust-smb-log-gen.h"
 
 json_t *JsonSMBAddMetadata(const Flow *f, uint64_t tx_id)
 {
index b584a1c9afa92c4c4691e5d96db05ce19595b8a9..a7e76304817c54b233e71983cfc0996c1eb1c156 100644 (file)
@@ -48,7 +48,6 @@
 #include "output-json-snmp.h"
 
 #include "rust.h"
-#include "rust-snmp-log-gen.h"
 
 typedef struct LogSNMPFileCtx_ {
     LogFileCtx *file_ctx;
index 4c1e2f9dccd0ca9ecedc04177a1554c12125bd60..73c0bfde816471522656dd9f83545a994a14c992 100644 (file)
@@ -52,8 +52,7 @@
 
 #include "app-layer-template-rust.h"
 #include "output-json-template-rust.h"
-
-#include "rust-applayertemplate-logger-gen.h"
+#include "rust.h"
 
 typedef struct LogTemplateFileCtx_ {
     LogFileCtx *file_ctx;
index 94f5b05e94ceddb1259611676be75a2043b0eb08..a1dd2a56810973ccd40917c6e99d0e3991d5f849 100644 (file)
@@ -49,7 +49,6 @@
 #include "output-json-tftp.h"
 
 #include "rust.h"
-#include "rust-tftp-log-gen.h"
 
 typedef struct LogTFTPFileCtx_ {
     LogFileCtx *file_ctx;
diff --git a/src/rust-context.h b/src/rust-context.h
new file mode 100644 (file)
index 0000000..86f73b5
--- /dev/null
@@ -0,0 +1,62 @@
+/* Copyright (C) 2017 Open Information Security Foundation
+ *
+ * You can copy, redistribute or modify this Program under the terms of
+ * the GNU General Public License version 2 as published by the Free
+ * Software Foundation.
+ *
+ * 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
+ * version 2 along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __RUST_CONTEXT_H__
+#define __RUST_CONTEXT_H__
+
+#include "detect-engine-state.h" //DetectEngineState
+#include "app-layer-krb5.h" //KRB5State, KRB5Transaction
+#include "app-layer-ikev2.h" //IKEV2State, IKEV2Transaction
+#include "app-layer-ntp.h" //NTPState, NTPTransaction
+#include "app-layer-snmp.h" //SNMPState, SNMPTransaction
+#include "app-layer-tftp.h" //TFTPState, TFTPTransaction
+
+typedef struct SuricataContext_ {
+    SCError (*SCLogMessage)(const SCLogLevel, const char *, const unsigned int,
+            const char *, const SCError, const char *message);
+    void (*DetectEngineStateFree)(DetectEngineState *);
+    void (*AppLayerDecoderEventsSetEventRaw)(AppLayerDecoderEvents **,
+            uint8_t);
+    void (*AppLayerDecoderEventsFreeEvents)(AppLayerDecoderEvents **);
+
+    int (*FileOpenFileWithId)(FileContainer *, const StreamingBufferConfig *,
+        uint32_t track_id, const uint8_t *name, uint16_t name_len,
+        const uint8_t *data, uint32_t data_len, uint16_t flags);
+    int (*FileCloseFileById)(FileContainer *, uint32_t track_id,
+            const uint8_t *data, uint32_t data_len, uint16_t flags);
+    int (*FileAppendDataById)(FileContainer *, uint32_t track_id,
+            const uint8_t *data, uint32_t data_len);
+    int (*FileAppendGAPById)(FileContainer *, uint32_t track_id,
+            const uint8_t *data, uint32_t data_len);
+    void (*FileContainerRecycle)(FileContainer *ffc);
+    void (*FilePrune)(FileContainer *ffc);
+    void (*FileSetTx)(FileContainer *, uint64_t);
+
+} SuricataContext;
+
+typedef struct SuricataFileContext_ {
+
+    const StreamingBufferConfig *sbcfg;
+
+} SuricataFileContext;
+
+struct _Store;
+typedef struct _Store Store;
+
+/** Opaque Rust types. */
+
+#endif /* !__RUST_CONTEXT_H__ */
index 151dc89f7d1e2f9641f9b5af5b5d9609a641373d..e4e4531a52f68db986faaa78a0da02208f0fca66 100644 (file)
 #ifndef __RUST_H__
 #define __RUST_H__
 
-typedef struct SuricataContext_ {
-    SCError (*SCLogMessage)(const SCLogLevel, const char *, const unsigned int,
-            const char *, const SCError, const char *message);
-    void (*DetectEngineStateFree)(DetectEngineState *);
-    void (*AppLayerDecoderEventsSetEventRaw)(AppLayerDecoderEvents **,
-            uint8_t);
-    void (*AppLayerDecoderEventsFreeEvents)(AppLayerDecoderEvents **);
-
-    int (*FileOpenFileWithId)(FileContainer *, const StreamingBufferConfig *,
-        uint32_t track_id, const uint8_t *name, uint16_t name_len,
-        const uint8_t *data, uint32_t data_len, uint16_t flags);
-    int (*FileCloseFileById)(FileContainer *, uint32_t track_id,
-            const uint8_t *data, uint32_t data_len, uint16_t flags);
-    int (*FileAppendDataById)(FileContainer *, uint32_t track_id,
-            const uint8_t *data, uint32_t data_len);
-    int (*FileAppendGAPById)(FileContainer *, uint32_t track_id,
-            const uint8_t *data, uint32_t data_len);
-    void (*FileContainerRecycle)(FileContainer *ffc);
-    void (*FilePrune)(FileContainer *ffc);
-    void (*FileSetTx)(FileContainer *, uint64_t);
-
-} SuricataContext;
-
-typedef struct SuricataFileContext_ {
-
-    const StreamingBufferConfig *sbcfg;
-
-} SuricataFileContext;
-
-struct _Store;
-typedef struct _Store Store;
-
-/** Opaque Rust types. */
-typedef struct NFState_ NFSState;
-typedef struct NFSTransaction_ NFSTransaction;
-typedef struct SMBState_ SMBState;
-typedef struct SMBTransaction_ SMBTransaction;
+#include "rust-context.h"
+#include "rust-bindings.h"
 
 #endif /* !__RUST_H__ */
index b55509c52eb942022f1f271faad501a6abca2379..753d1f5522dee447830c1023aaaf77e98d7c16fe 100644 (file)
@@ -479,6 +479,10 @@ typedef enum {
 #include <lua.h>
 #include <lualib.h>
 #include <lauxlib.h>
+#else
+/* If we don't have Lua, create a typedef for lua_State so the
+ * exported Lua functions don't fail the build. */
+typedef void lua_State;
 #endif
 
 #ifndef HAVE_STRLCAT
index f61ab4ad8a9929a8e8de975290b40e834aba6fb3..14b15403b1a22b45963a7e53918f70adec567d36 100644 (file)
 #include "util-lua.h"
 
 #include "rust.h"
-#include "rust-core-gen.h"
 
 /*
  * we put this here, because we only use it here in main.
index 07602373b697ccf3c81ced2036a3474c5088a920..4dbf1427a4482646479fb5ca6c8d765660bb5a59 100644 (file)
@@ -42,8 +42,8 @@
 
 #include "util-unittest.h"
 #include "util-syslog.h"
+#include "rust.h"
 
-#include "rust-log-gen.h"
 
 #include "conf.h"
 
index 4c473619ea9ae2843ebfc539c9ee3c9f0ab3da54..6ffbe8b15491575723c836d49724f1d47113f6d3 100644 (file)
@@ -47,6 +47,7 @@
 #include "util-proto-name.h"
 #include "util-logopenfile.h"
 #include "util-time.h"
+#include "rust.h"
 
 #ifdef HAVE_LUA
 
@@ -58,9 +59,6 @@
 #include "util-lua-common.h"
 #include "util-lua-dns.h"
 
-#include "rust-dns-dns-gen.h"
-#include "rust-dns-lua-gen.h"
-
 static int DnsGetDnsRrname(lua_State *luastate)
 {
     if (!(LuaStateNeedProto(luastate, ALPROTO_DNS)))