Commit graph

47 commits

Author SHA1 Message Date
Robin Sommer
61cc83affa binpac: Adding an interface to manually control the buffering for generated
parsers.

This consists of two parts:

    1. The generated Flow classes expose their flow buffers via a new
       method flow_buffer().

    2. Flow buffers get two new methods:

        // Interface for delayed parsing. Sometimes BinPAC doesn't get the
        // buffering right and then one can use these to feed parts
        // individually and assemble them internally. After calling
        // FinishBuffer(), one can send the uppper-layer flow an FlowEOF()
        // to trigger parsing.
        void BufferData(const_byteptr data, const_byteptr end);
        void FinishBuffer();
2025-08-20 08:52:23 -07:00
Jon Siwek
ce2b56751b binpac: Fix an exception slicing issue in binpac generated cleanup code.
Switch to using a no-argument throw to preserve the dynamic type of
the binpac exception.  Otherwise, the exception is "sliced" and can only
be subsequently handled as binpac::Exception and not a derived type.
2025-08-20 08:52:23 -07:00
Jon Siwek
14e3d5a1a3 binpac: Add scoping to usages of binpac::Exception classes in generated code.
This allows analyzers to define their own types of the same name
without mistakingly overshadowing the usages of binpac::Exception
and its derived types in the generated parser code.
2025-08-20 08:52:23 -07:00
Robin Sommer
6c70f7851b binpac: Silence warning for generated code when compiling with clang. 2025-08-20 08:52:23 -07:00
Jon Siwek
8cf0be6d0f binpac: Change binpac.h integral typedefs and reimplement 64-bit pac_swap().
Integer types now use <inttypes.h>, and the 64-bit byte-swapping
function uses a union approach instead of masking/bit-shifting.

Addresses #761.
2025-08-20 08:52:23 -07:00
Jon Siwek
bf2184bb0f binpac: Raise minimum required CMake version to 2.6.3 2025-08-20 08:52:23 -07:00
Robin Sommer
fccf3a7340 binpac: Distribution cleanup. 2025-08-20 08:52:23 -07:00
Robin Sommer
092d049f8e binpac: Arrays now suport the &transient attribute.
If set, parsed elements won't actually be added to the array, and read
access to the array aren't permitted. This is helpful to save memory
in the case of large arrays for which elements don't need (or can't)
be buffered.
2025-08-20 08:52:23 -07:00
Jon Siwek
5db7ba4050 binpac: Update to use cmake submodule 2025-08-20 08:52:23 -07:00
Jon Siwek
969998d148 binpac: Remove $Id$ tags 2025-08-20 08:52:23 -07:00
Jon Siwek
3841c68d87 binpac: Install binaries with an RPATH 2025-08-20 08:52:23 -07:00
Jon Siwek
a4f05185d6 binpac: Workaround for FreeBSD CMake port missing debug flags 2025-08-20 08:52:23 -07:00
Robin Sommer
77e4315a57 binpac: Fixing compiler warning 2025-08-20 08:52:23 -07:00
Seth Hall
1d6cea8c52 binpac: Adding int64 and uint64 types to binpac. 2025-08-20 08:52:23 -07:00
Jon Siwek
50f5a913c3 binpac: Adding files to CMake build targets so they show up in generated IDE projects.
This addresses #413.
2025-08-20 08:52:23 -07:00
Robin Sommer
d41a2def5a binpac: Fixing crash with undefined case expressions.
Found by Emmanuele Zambon.
2025-08-20 08:52:23 -07:00
Jon Siwek
e7e2ee38e7 binpac: Add explicit CMake check for compiler 2025-08-20 08:52:23 -07:00
Seth Hall
1a15b968e6 binpac: Added an option to quiet the status output from binpac.
This adds the -q command line flag to quiet the output.
It also fixes a small compiler warning.
2025-08-20 08:52:23 -07:00
Jon Siwek
c2dbefab17 binpac: MacPorts & Fink paths now prepended to default search prefixes 2025-08-20 08:52:23 -07:00
Jon Siwek
2260d6c60e binpac: Add warning when building and installing are done by different users 2025-08-20 08:52:22 -07:00
Jon Siwek
4dd640d0f7 binpac: CMake 2.6 compatibility changes 2025-08-20 08:52:22 -07:00
Robin Sommer
71cc7e9d5b binpac: Cleaning up. 2025-08-20 08:52:22 -07:00
Jon Siwek
67e5bc7198 binpac: Made uninstall target cooperate with other projects 2025-08-20 08:52:22 -07:00
Jon Siwek
aacc6ee043 binpac: Added uninstall target 2025-08-20 08:52:22 -07:00
Jon Siwek
ed7e697d35 binpac: Changed default CMAKE_BUILD_TYPE to RelWithDebInfo
The --enable-debug option of the configure wrapper changes it to Debug.
Removed --enable-release option of the configure wrapper.
2025-08-20 08:52:22 -07:00
Jon Siwek
32423cf27b binpac: Customizable error messages for missing prereqs.
Adds the FindRequiredPackage() macro that wraps the functionality
of the standard find_package() macro.
2025-08-20 08:52:22 -07:00
Jon Siwek
173c3784ab binpac: Prepend build dir to search path.
This avoids inclusion of conflicting superproject config.h.
2025-08-20 08:52:22 -07:00
Jon Siwek
6b1b6b178a binpac: configure now writes directly to CMakeCache.txt
The intermediate BuildOptions.cmake file is no longer needed.
2025-08-20 08:52:22 -07:00
Jon Siwek
8366dd6bcb binpac: Minor style changes. 2025-08-20 08:52:22 -07:00
Jon Siwek
32db4e4447 binpac: CMake module path adjustment.
To allow inclusion from a superproject.
2025-08-20 08:52:22 -07:00
Jon Siwek
a05eb8b150 binpac: Added configure script to wrap cmake functionality 2025-08-20 08:52:22 -07:00
Jon Siwek
92f936fdb8 binpac: Added headers to install target.
Also set some convenience variables that mimic what a FindBinPAC
module would set.  These could be used by a superproject that
wants to decide whether to use an existing BinPAC installation
or (re)build from source.
2025-08-20 08:52:22 -07:00
Jon Siwek
47c64d7fed binpac: Changes to add an install target. 2025-08-20 08:52:22 -07:00
Jon Siwek
4644605860 binpac: Added debug/release mode compiler flags and build summary output. 2025-08-20 08:52:22 -07:00
Jon Siwek
0944e3619c binpac: Added bison flag for verbose output. 2025-08-20 08:52:22 -07:00
Jon Siwek
9d7d6f8868 binpac: Two small changes:
- Moved find_package() calls up to top directory so failure can occur
  right away if any dependencies are missing
- Got rid of a bunch of header checks and preprocessor definitions that
  aren't ever used; not sure why I had them there in the first place
2025-08-20 08:52:22 -07:00
Jon Siwek
677ae82203 binpac: Changes to the config.h generation.
- Renamed VERSION preprocessor definition to not conflict with Bro's.
- Removed check for HAVE_CONFIG_H; config.h will always be generated in the
  binpac build directory, but if a parent directory has generated a config.h
  and added that to compiler include search paths via include_directories(),
  then that one should be used -- include_directories() appends paths by
  default and the parent CMakeLists.txt will have called it first.
2025-08-20 08:52:22 -07:00
Jon Siwek
73a67f0ae3 binpac: Removed unnecessary subdir for custom CMake modules. 2025-08-20 08:52:22 -07:00
Jon Siwek
65668d3ea6 binpac: Initial, working CMake build added. 2025-08-20 08:52:22 -07:00
Jon Siwek
c8665318e6 binpac: Initial import of Bro's binpac subdirectory from SVN r7088. 2025-08-20 08:52:22 -07:00
Tim Wojtulewicz
e64ec54172
Revert "Move BinPAC, bifcl, af_packet, and gen_zam submodules into main zeek repo" 2025-08-15 15:11:22 -07:00
Tim Wojtulewicz
f194b14727 Fix clang-tidy and pre-commit warnings for gen-zam code files 2025-08-15 13:57:27 -07:00
Tim Wojtulewicz
8f918dab47 Move gen-zam code into the main Zeek repository
This is based on commit 56a6db00b887c79d26f303676677cb490d1c296d from
the gen-zam repository.
2025-08-15 13:57:27 -07:00
Tim Wojtulewicz
68926faf47 Move the bifcl code into the main Zeek repository
This is based on commit 5947749f7850b075f11d6a2aaefe7dad4f63cb62f from
the bifcl repository.
2025-08-15 13:57:27 -07:00
Tim Wojtulewicz
cd1414ab69 Fix clang-tidy findings in the binpac lib code 2025-08-15 13:57:27 -07:00
Tim Wojtulewicz
4ae8bb856d Add copyright headers to all of the binpac source files 2025-08-15 13:57:27 -07:00
Tim Wojtulewicz
ff26835976 Move binpac code into the main Zeek repository
This is based on commit 48f75b5f6415fe9d597e3e991cec635b1bc400dc from
the binpac repository.
2025-08-15 13:57:27 -07:00