Merging upstream version 1.2.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
9ce9cc1418
commit
cc381791fc
340 changed files with 71346 additions and 6734 deletions
|
@ -1,6 +0,0 @@
|
|||
BasedOnStyle: webkit
|
||||
IndentWidth: 4
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveDeclarations: true
|
||||
AlignOperands: true
|
||||
SortIncludes: false
|
|
@ -1,23 +0,0 @@
|
|||
top=..
|
||||
|
||||
all: srpm
|
||||
|
||||
prereq: $(top)/rpmbuild
|
||||
rpm -q git rpm-build >/dev/null || dnf -y install git rpm-build
|
||||
|
||||
update-dist-tools: $(top)/dist-tools
|
||||
( cd "$(top)/dist-tools" && git pull )
|
||||
|
||||
$(top)/dist-tools:
|
||||
git clone https://github.com/jelu/dist-tools.git "$(top)/dist-tools"
|
||||
|
||||
$(top)/rpmbuild:
|
||||
mkdir -p "$(top)"/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
||||
|
||||
srpm: prereq update-dist-tools
|
||||
test -f .gitmodules && git submodule update --init || true
|
||||
echo "$(spec)" | grep -q "develop.spec" && auto_build_number=`date --utc +%s` message="Auto build `date --utc --iso-8601=seconds`" "$(top)/dist-tools/spec-new-changelog-entry" || true
|
||||
overwrite=yes nosign=yes "$(top)/dist-tools/create-source-packages" rpm
|
||||
cp ../*.orig.tar.gz "$(top)/rpmbuild/SOURCES/"
|
||||
echo "$(spec)" | grep -q "develop.spec" && rpmbuild -bs --define "%_topdir $(top)/rpmbuild" --undefine=dist rpm/*.spec || rpmbuild -bs --define "%_topdir $(top)/rpmbuild" --undefine=dist "$(spec)"
|
||||
cp "$(top)"/rpmbuild/SRPMS/*.src.rpm "$(outdir)"
|
1
.github/FUNDING.yml
vendored
1
.github/FUNDING.yml
vendored
|
@ -1 +0,0 @@
|
|||
custom: https://www.dns-oarc.net/donate
|
100
.gitignore
vendored
100
.gitignore
vendored
|
@ -1,100 +0,0 @@
|
|||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
# Automake
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
ar-lib
|
||||
autom4te.cache
|
||||
compile
|
||||
config.guess
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
ltmain.sh
|
||||
m4/libtool.m4
|
||||
m4/ltoptions.m4
|
||||
m4/ltsugar.m4
|
||||
m4/ltversion.m4
|
||||
m4/lt~obsolete.m4
|
||||
missing
|
||||
config.h.in
|
||||
config.h.in~
|
||||
test-driver
|
||||
|
||||
# Configure
|
||||
Makefile
|
||||
config.log
|
||||
config.status
|
||||
libtool
|
||||
.deps
|
||||
src/config.h
|
||||
src/stamp-h1
|
||||
build
|
||||
.dirstamp
|
||||
|
||||
# Project specific files
|
||||
*.luao
|
||||
*.luaho
|
||||
src/dnsjit
|
||||
src/dnsjit.1
|
||||
src/dnsjit.*.3in
|
||||
src/dnsjit.*.3
|
||||
src/core/compat.hh
|
||||
src/core/log_errstr.c
|
||||
src/test/test-suite.log
|
||||
src/test/test*.sh.log
|
||||
src/test/test*.sh.trs
|
||||
src/test/*.dist
|
||||
src/test/*-dist
|
21
.lgtm.yml
21
.lgtm.yml
|
@ -1,21 +0,0 @@
|
|||
extraction:
|
||||
cpp:
|
||||
prepare:
|
||||
packages:
|
||||
- build-essential
|
||||
- automake
|
||||
- autoconf
|
||||
- libtool
|
||||
- pkg-config
|
||||
- libluajit-5.1-dev
|
||||
- libpcap-dev
|
||||
- luajit
|
||||
- liblmdb-dev
|
||||
- libck-dev
|
||||
- libgnutls28-dev
|
||||
- libuv1-dev
|
||||
- libnghttp2-dev
|
||||
configure:
|
||||
command:
|
||||
- ./autogen.sh
|
||||
- ./configure
|
29
.travis.yml
29
.travis.yml
|
@ -1,29 +0,0 @@
|
|||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
update: true
|
||||
packages:
|
||||
- libluajit-5.1-dev
|
||||
- libpcap-dev
|
||||
- luajit
|
||||
- liblmdb-dev
|
||||
- libck-dev
|
||||
- libgnutls28-dev
|
||||
- libuv1-dev
|
||||
- libnghttp2-dev
|
||||
language: c
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
install: ./autogen.sh
|
||||
script:
|
||||
- ./configure --enable-warn-all
|
||||
- make dist
|
||||
- tar zxvf *.tar.gz
|
||||
- cd dnsjit-[0-9]*
|
||||
- mkdir build
|
||||
- cd build
|
||||
- ../configure --enable-warn-all
|
||||
- make
|
||||
- make test
|
||||
- cat src/test/test*.sh.log
|
100
CHANGES
100
CHANGES
|
@ -1,3 +1,103 @@
|
|||
2021-07-07 Jerry Lundström
|
||||
|
||||
Release 1.2.1
|
||||
|
||||
This patch release fixes packages for SLE/openSUSE and the generation
|
||||
of an environment script for the stand-alone tool example.
|
||||
|
||||
9c6f630 SLE/openSUSE
|
||||
f07ac4a Stand-alone tool example
|
||||
|
||||
2021-07-05 Jerry Lundström
|
||||
|
||||
Release 1.2.0
|
||||
|
||||
This release adds development files and autotool examples for C/Lua
|
||||
modules or stand-alone tools for dnsjit.
|
||||
|
||||
In `examples/` you'll now also find:
|
||||
|
||||
- `modules/input-example`
|
||||
This input example is based on `dnsjit.input.zero` which was a testing
|
||||
modules during the early days of dnsjit.
|
||||
It's a C module that generates empty objects for the receiver.
|
||||
|
||||
- `modules/filter-example`:
|
||||
This filter example is C module that counts the number of objects
|
||||
passed to it before sending it to the receiver.
|
||||
|
||||
- `modules/output-example`:
|
||||
This output example is based on `dnsjit.output.null` which was a testing
|
||||
modules during the early days of dnsjit.
|
||||
It's a C module that will just discard objects it receives.
|
||||
|
||||
- `modules/lib-example`:
|
||||
This example Lua module takes two `core_timespec_t` C objects and gives
|
||||
the duration between them as a string.
|
||||
|
||||
- `stand-alone-tool`:
|
||||
This example is based on `test_pcap_read.lua` and `test_throughput.lua`
|
||||
which was previous located in `examples/`.
|
||||
There are two installable Lua programs and shows how to depend on
|
||||
a dnsjit version, depend on specific dnsjit modules and how to run
|
||||
tests using `make test`.
|
||||
|
||||
All these examples can easily be copied and renamed to build and
|
||||
distribute your own dnsjit modules and tools, using autotool for
|
||||
`configure`, `make` and `make install`.
|
||||
|
||||
Development files will also be installed, or can be installed via
|
||||
`dnsjit-dev`/`dnsjit-devel` packages. All C headers have been prefixed
|
||||
with `dnsjit/` (for example `#include <dnsjit/version.h>`).
|
||||
|
||||
Thanks to this new setup, the module `output.dnssim` has been moved out
|
||||
from dnsjit's repository and placed in DNS shotgun's:
|
||||
|
||||
https://gitlab.nic.cz/knot/shotgun/-/tree/master/replay/dnssim
|
||||
|
||||
This will help CZ.NIC to maintain and release both the module and tool
|
||||
at the same time.
|
||||
|
||||
New modules:
|
||||
- Added `input.zpcap`, module for reading LZ4/ZSTD compressed PCAPs
|
||||
- Added `core.loader`, module for loading C modules using LuaJIT's `ffi` interface and `package.cpath`
|
||||
- Added `core.file` with `core_file_exists()`, a C function to check if a file exists
|
||||
|
||||
Other changes:
|
||||
- Add `<dnsjit/version.h>` for `DNSJIT_MAJOR_VERSION`, `DNSJIT_MINOR_VERSION`, `DNSJIT_PATCH_VERSION`
|
||||
- `dnsjit`: Remove version print on start
|
||||
- `dnsjit.input.zero`: Will `require("example.input.zero")` for backwards compatibility
|
||||
- `dnsjit.output.null`: Will `require("example.output.null")` for backwards compatibility
|
||||
- `core/timespec`: Add `:max_init()`, return a new object with maximum values set for seconds and nanoseconds.
|
||||
- `output/pcap`:
|
||||
- Update `open()` man-page, indicate usage of `pcap_dump_open()`
|
||||
- Add `have_errors()` to check for write errors during/after dumping
|
||||
- `input.fpcap`: Add `fadvise_sequential()` to advise sequential read of the file
|
||||
- `examples/dumpdns.lua`: Add support for dumping compressed PCAPs
|
||||
|
||||
Bugfixes:
|
||||
- `lib/getopt`: Fix short options, error if length is not 1
|
||||
- `core/timespec`: Fix typo in struct documentation
|
||||
|
||||
892ac65 example lib
|
||||
ae7e647 stand alone tool, dnsjit
|
||||
2d937a5 Package
|
||||
5c5ba74 Package
|
||||
6059bb5 Package
|
||||
48df46f zpcap
|
||||
ff13586 Remove dnssim
|
||||
389f274 filter example
|
||||
45e0102 output example
|
||||
9d76760 Example input
|
||||
f823db8 Example modules - input
|
||||
df12078 f/m-advise
|
||||
31ee04d WIP: Advise kernel that inputs are read sequentially
|
||||
eff6313 Output PCAP man-page, errors
|
||||
ac60fec Timespec
|
||||
cea7936 Bye Travis
|
||||
a5c967f getopt
|
||||
506ee99 getopt: detect incorrect short strings
|
||||
|
||||
2021-02-03 Jerry Lundström
|
||||
|
||||
Release 1.1.0
|
||||
|
|
|
@ -26,6 +26,6 @@ SUBDIRS = src examples
|
|||
|
||||
dist_doc_DATA = CHANGES README.md LICENSE
|
||||
|
||||
EXTRA_DIST = m4
|
||||
EXTRA_DIST = m4 include
|
||||
|
||||
test: check
|
||||
|
|
909
Makefile.in
Normal file
909
Makefile.in
Normal file
|
@ -0,0 +1,909 @@
|
|||
# Makefile.in generated by automake 1.16.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
# Copyright (c) 2018-2021, OARC, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of dnsjit.
|
||||
#
|
||||
# dnsjit 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
*) echo "am__make_running_with_option: internal error: invalid" \
|
||||
"target option '$${target_option-}' specified" >&2; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
has_opt=no; \
|
||||
sane_makeflags=$$MAKEFLAGS; \
|
||||
if $(am__is_gnu_make); then \
|
||||
sane_makeflags=$$MFLAGS; \
|
||||
else \
|
||||
case $$MAKEFLAGS in \
|
||||
*\\[\ \ ]*) \
|
||||
bs=\\; \
|
||||
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
|
||||
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
|
||||
esac; \
|
||||
fi; \
|
||||
skip_next=no; \
|
||||
strip_trailopt () \
|
||||
{ \
|
||||
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
|
||||
}; \
|
||||
for flg in $$sane_makeflags; do \
|
||||
test $$skip_next = yes && { skip_next=no; continue; }; \
|
||||
case $$flg in \
|
||||
*=*|--*) continue;; \
|
||||
-*I) strip_trailopt 'I'; skip_next=yes;; \
|
||||
-*I?*) strip_trailopt 'I';; \
|
||||
-*O) strip_trailopt 'O'; skip_next=yes;; \
|
||||
-*O?*) strip_trailopt 'O';; \
|
||||
-*l) strip_trailopt 'l'; skip_next=yes;; \
|
||||
-*l?*) strip_trailopt 'l';; \
|
||||
-[dEDm]) skip_next=yes;; \
|
||||
-[JT]) skip_next=yes;; \
|
||||
esac; \
|
||||
case $$flg in \
|
||||
*$$target_option*) has_opt=yes; break;; \
|
||||
esac; \
|
||||
done; \
|
||||
test $$has_opt = yes
|
||||
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
|
||||
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = .
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
|
||||
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
|
||||
$(top_srcdir)/m4/ax_compiler_vendor.m4 \
|
||||
$(top_srcdir)/m4/ax_ext.m4 \
|
||||
$(top_srcdir)/m4/ax_gcc_x86_avx_xgetbv.m4 \
|
||||
$(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \
|
||||
$(top_srcdir)/m4/ax_prepend_flag.m4 \
|
||||
$(top_srcdir)/m4/ax_pthread.m4 \
|
||||
$(top_srcdir)/m4/ax_require_defined.m4 \
|
||||
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
|
||||
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
|
||||
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
|
||||
$(am__configure_deps) $(dist_doc_DATA) $(am__DIST_COMMON)
|
||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
configure.lineno config.status.lineno
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/src/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
am__v_P_1 = :
|
||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
|
||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
am__v_GEN_1 =
|
||||
AM_V_at = $(am__v_at_@AM_V@)
|
||||
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
|
||||
am__v_at_0 = @
|
||||
am__v_at_1 =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
|
||||
ctags-recursive dvi-recursive html-recursive info-recursive \
|
||||
install-data-recursive install-dvi-recursive \
|
||||
install-exec-recursive install-html-recursive \
|
||||
install-info-recursive install-pdf-recursive \
|
||||
install-ps-recursive install-recursive installcheck-recursive \
|
||||
installdirs-recursive pdf-recursive ps-recursive \
|
||||
tags-recursive uninstall-recursive
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
am__uninstall_files_from_dir = { \
|
||||
test -z "$$files" \
|
||||
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|
||||
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
|
||||
$(am__cd) "$$dir" && rm -f $$files; }; \
|
||||
}
|
||||
am__installdirs = "$(DESTDIR)$(docdir)"
|
||||
DATA = $(dist_doc_DATA)
|
||||
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
|
||||
distclean-recursive maintainer-clean-recursive
|
||||
am__recursive_targets = \
|
||||
$(RECURSIVE_TARGETS) \
|
||||
$(RECURSIVE_CLEAN_TARGETS) \
|
||||
$(am__extra_recursive_targets)
|
||||
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
|
||||
cscope distdir distdir-am dist dist-all distcheck
|
||||
am__extra_recursive_targets = gcov-recursive
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
# *not* preserved.
|
||||
am__uniquify_input = $(AWK) '\
|
||||
BEGIN { nonempty = 0; } \
|
||||
{ items[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in items) print i; }; } \
|
||||
'
|
||||
# Make sure the list of sources is unique. This is necessary because,
|
||||
# e.g., the same source file might be shared among _SOURCES variables
|
||||
# for different programs/libraries.
|
||||
am__define_uniq_tagged_files = \
|
||||
list='$(am__tagged_files)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
CSCOPE = cscope
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in ar-lib compile config.guess \
|
||||
config.sub install-sh ltmain.sh missing
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
am__remove_distdir = \
|
||||
if test -d "$(distdir)"; then \
|
||||
find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
|
||||
&& rm -rf "$(distdir)" \
|
||||
|| { sleep 5 && rm -rf "$(distdir)"; }; \
|
||||
else :; fi
|
||||
am__post_remove_distdir = $(am__remove_distdir)
|
||||
am__relativize = \
|
||||
dir0=`pwd`; \
|
||||
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
|
||||
sed_rest='s,^[^/]*/*,,'; \
|
||||
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
|
||||
sed_butlast='s,/*[^/]*$$,,'; \
|
||||
while test -n "$$dir1"; do \
|
||||
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
|
||||
if test "$$first" != "."; then \
|
||||
if test "$$first" = ".."; then \
|
||||
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
|
||||
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
|
||||
else \
|
||||
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
|
||||
if test "$$first2" = "$$first"; then \
|
||||
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
|
||||
else \
|
||||
dir2="../$$dir2"; \
|
||||
fi; \
|
||||
dir0="$$dir0"/"$$first"; \
|
||||
fi; \
|
||||
fi; \
|
||||
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
|
||||
done; \
|
||||
reldir="$$dir2"
|
||||
DIST_ARCHIVES = $(distdir).tar.gz
|
||||
GZIP_ENV = --best
|
||||
DIST_TARGETS = dist-gzip
|
||||
distuninstallcheck_listfiles = find . -type f -print
|
||||
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
|
||||
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
|
||||
distcleancheck_listfiles = find . -type f -print
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CPUEXT_FLAGS = @CPUEXT_FLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
LUAJIT = @LUAJIT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
|
||||
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
|
||||
PTHREAD_CC = @PTHREAD_CC@
|
||||
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
|
||||
PTHREAD_LIBS = @PTHREAD_LIBS@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
SIMD_FLAGS = @SIMD_FLAGS@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
ax_pthread_config = @ax_pthread_config@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
ck_CFLAGS = @ck_CFLAGS@
|
||||
ck_LIBS = @ck_LIBS@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
liblz4_CFLAGS = @liblz4_CFLAGS@
|
||||
liblz4_LIBS = @liblz4_LIBS@
|
||||
libzstd_CFLAGS = @libzstd_CFLAGS@
|
||||
libzstd_LIBS = @libzstd_LIBS@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
luajit_CFLAGS = @luajit_CFLAGS@
|
||||
luajit_LIBS = @luajit_LIBS@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in \
|
||||
$(srcdir)/src/config.h.in~ \
|
||||
$(srcdir)/configure
|
||||
|
||||
SUBDIRS = src examples
|
||||
dist_doc_DATA = CHANGES README.md LICENSE
|
||||
EXTRA_DIST = m4 include
|
||||
all: all-recursive
|
||||
|
||||
.SUFFIXES:
|
||||
am--refresh: Makefile
|
||||
@:
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
|
||||
$(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
echo ' $(SHELL) ./config.status'; \
|
||||
$(SHELL) ./config.status;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
$(am__cd) $(srcdir) && $(AUTOCONF)
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool config.lt
|
||||
install-dist_docDATA: $(dist_doc_DATA)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
|
||||
if test -n "$$list"; then \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \
|
||||
fi; \
|
||||
for p in $$list; do \
|
||||
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||
echo "$$d$$p"; \
|
||||
done | $(am__base_list) | \
|
||||
while read files; do \
|
||||
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \
|
||||
$(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \
|
||||
done
|
||||
|
||||
uninstall-dist_docDATA:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
|
||||
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
|
||||
dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir)
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run 'make' without going through this Makefile.
|
||||
# To change the values of 'make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in 'config.status', edit 'config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run 'make');
|
||||
# (2) otherwise, pass the desired values on the 'make' command line.
|
||||
$(am__recursive_targets):
|
||||
@fail=; \
|
||||
if $(am__make_keepgoing); then \
|
||||
failcom='fail=yes'; \
|
||||
else \
|
||||
failcom='exit 1'; \
|
||||
fi; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
case "$@" in \
|
||||
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
|
||||
*) list='$(SUBDIRS)' ;; \
|
||||
esac; \
|
||||
for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| eval $$failcom; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; test -z "$$fail"
|
||||
gcov-local:
|
||||
|
||||
ID: $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); mkid -fID $$unique
|
||||
tags: tags-recursive
|
||||
TAGS: tags
|
||||
|
||||
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
|
||||
include_option=--etags-include; \
|
||||
empty_fix=.; \
|
||||
else \
|
||||
include_option=--include; \
|
||||
empty_fix=; \
|
||||
fi; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test ! -f $$subdir/TAGS || \
|
||||
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
$(am__define_uniq_tagged_files); \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: ctags-recursive
|
||||
|
||||
CTAGS: ctags
|
||||
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
cscope: cscope.files
|
||||
test ! -s cscope.files \
|
||||
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
|
||||
clean-cscope:
|
||||
-rm -f cscope.files
|
||||
cscope.files: clean-cscope cscopelist
|
||||
cscopelist: cscopelist-recursive
|
||||
|
||||
cscopelist-am: $(am__tagged_files)
|
||||
list='$(am__tagged_files)'; \
|
||||
case "$(srcdir)" in \
|
||||
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
|
||||
*) sdir=$(subdir)/$(srcdir) ;; \
|
||||
esac; \
|
||||
for i in $$list; do \
|
||||
if test -f "$$i"; then \
|
||||
echo "$(subdir)/$$i"; \
|
||||
else \
|
||||
echo "$$sdir/$$i"; \
|
||||
fi; \
|
||||
done >> $(top_builddir)/cscope.files
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
distdir-am: $(DISTFILES)
|
||||
$(am__remove_distdir)
|
||||
test -d "$(distdir)" || mkdir "$(distdir)"
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
$(am__make_dryrun) \
|
||||
|| test -d "$(distdir)/$$subdir" \
|
||||
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|
||||
|| exit 1; \
|
||||
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
|
||||
$(am__relativize); \
|
||||
new_distdir=$$reldir; \
|
||||
dir1=$$subdir; dir2="$(top_distdir)"; \
|
||||
$(am__relativize); \
|
||||
new_top_distdir=$$reldir; \
|
||||
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
|
||||
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
|
||||
($(am__cd) $$subdir && \
|
||||
$(MAKE) $(AM_MAKEFLAGS) \
|
||||
top_distdir="$$new_top_distdir" \
|
||||
distdir="$$new_distdir" \
|
||||
am__remove_distdir=: \
|
||||
am__skip_length_check=: \
|
||||
am__skip_mode_fix=: \
|
||||
distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
-test -n "$(am__skip_mode_fix)" \
|
||||
|| find "$(distdir)" -type d ! -perm -755 \
|
||||
-exec chmod u+rwx,go+rx {} \; -o \
|
||||
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|
||||
|| chmod -R a+r "$(distdir)"
|
||||
dist-gzip: distdir
|
||||
tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-bzip2: distdir
|
||||
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-lzip: distdir
|
||||
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-xz: distdir
|
||||
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-tarZ: distdir
|
||||
@echo WARNING: "Support for distribution archives compressed with" \
|
||||
"legacy program 'compress' is deprecated." >&2
|
||||
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
|
||||
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-shar: distdir
|
||||
@echo WARNING: "Support for shar distribution archives is" \
|
||||
"deprecated." >&2
|
||||
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
|
||||
shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-zip: distdir
|
||||
-rm -f $(distdir).zip
|
||||
zip -rq $(distdir).zip $(distdir)
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist dist-all:
|
||||
$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
# This target untars the dist file and tries a VPATH configuration. Then
|
||||
# it guarantees that the distribution is self-contained by making another
|
||||
# tarfile.
|
||||
distcheck: dist
|
||||
case '$(DIST_ARCHIVES)' in \
|
||||
*.tar.gz*) \
|
||||
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
|
||||
*.tar.bz2*) \
|
||||
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
|
||||
*.tar.lz*) \
|
||||
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
|
||||
*.tar.xz*) \
|
||||
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
|
||||
*.tar.Z*) \
|
||||
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
|
||||
*.shar.gz*) \
|
||||
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
|
||||
*.zip*) \
|
||||
unzip $(distdir).zip ;;\
|
||||
esac
|
||||
chmod -R a-w $(distdir)
|
||||
chmod u+w $(distdir)
|
||||
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
|
||||
chmod a-w $(distdir)
|
||||
test -d $(distdir)/_build || exit 0; \
|
||||
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
|
||||
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
|
||||
&& am__cwd=`pwd` \
|
||||
&& $(am__cd) $(distdir)/_build/sub \
|
||||
&& ../../configure \
|
||||
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
|
||||
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||
--srcdir=../.. --prefix="$$dc_install_base" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
|
||||
distuninstallcheck \
|
||||
&& chmod -R a-w "$$dc_install_base" \
|
||||
&& ({ \
|
||||
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
|
||||
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
|
||||
} || { rm -rf "$$dc_destdir"; exit 1; }) \
|
||||
&& rm -rf "$$dc_destdir" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dist \
|
||||
&& rm -rf $(DIST_ARCHIVES) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
|
||||
&& cd "$$am__cwd" \
|
||||
|| exit 1
|
||||
$(am__post_remove_distdir)
|
||||
@(echo "$(distdir) archives ready for distribution: "; \
|
||||
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
|
||||
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
|
||||
distuninstallcheck:
|
||||
@test -n '$(distuninstallcheck_dir)' || { \
|
||||
echo 'ERROR: trying to run $@ with an empty' \
|
||||
'$$(distuninstallcheck_dir)' >&2; \
|
||||
exit 1; \
|
||||
}; \
|
||||
$(am__cd) '$(distuninstallcheck_dir)' || { \
|
||||
echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
|
||||
exit 1; \
|
||||
}; \
|
||||
test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
|
||||
|| { echo "ERROR: files left after uninstall:" ; \
|
||||
if test -n "$(DESTDIR)"; then \
|
||||
echo " (check DESTDIR support)"; \
|
||||
fi ; \
|
||||
$(distuninstallcheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
distcleancheck: distclean
|
||||
@if test '$(srcdir)' = . ; then \
|
||||
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|
||||
|| { echo "ERROR: files left in build directory after distclean:" ; \
|
||||
$(distcleancheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
all-am: Makefile $(DATA)
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
for dir in "$(DESTDIR)$(docdir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-recursive
|
||||
install-exec: install-exec-recursive
|
||||
install-data: install-data-recursive
|
||||
uninstall: uninstall-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-recursive
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
|
||||
clean: clean-recursive
|
||||
|
||||
clean-am: clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-recursive
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-generic distclean-libtool \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-recursive
|
||||
|
||||
dvi-am:
|
||||
|
||||
gcov: gcov-recursive
|
||||
|
||||
gcov-am: gcov-local
|
||||
|
||||
html: html-recursive
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-recursive
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am: install-dist_docDATA
|
||||
|
||||
install-dvi: install-dvi-recursive
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-recursive
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-recursive
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-recursive
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-recursive
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf $(top_srcdir)/autom4te.cache
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-recursive
|
||||
|
||||
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
|
||||
|
||||
pdf: pdf-recursive
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-recursive
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-dist_docDATA
|
||||
|
||||
.MAKE: $(am__recursive_targets) install-am install-strip
|
||||
|
||||
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
|
||||
am--refresh check check-am clean clean-cscope clean-generic \
|
||||
clean-libtool cscope cscopelist-am ctags ctags-am dist \
|
||||
dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \
|
||||
dist-xz dist-zip distcheck distclean distclean-generic \
|
||||
distclean-libtool distclean-tags distcleancheck distdir \
|
||||
distuninstallcheck dvi dvi-am gcov-am gcov-local html html-am \
|
||||
info info-am install install-am install-data install-data-am \
|
||||
install-dist_docDATA install-dvi install-dvi-am install-exec \
|
||||
install-exec-am install-html install-html-am install-info \
|
||||
install-info-am install-man install-pdf install-pdf-am \
|
||||
install-ps install-ps-am install-strip installcheck \
|
||||
installcheck-am installdirs installdirs-am maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-generic \
|
||||
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
|
||||
uninstall-am uninstall-dist_docDATA
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
test: check
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
15
README.md
15
README.md
|
@ -1,6 +1,6 @@
|
|||
# Engine for capturing, parsing and replaying DNS
|
||||
|
||||
[![Build Status](https://travis-ci.com/DNS-OARC/dnsjit.svg?branch=develop)](https://travis-ci.com/DNS-OARC/dnsjit) [![Total alerts](https://img.shields.io/lgtm/alerts/g/DNS-OARC/dnsjit.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/DNS-OARC/dnsjit/alerts/) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=dns-oarc%3Adnsjit&metric=bugs)](https://sonarcloud.io/dashboard?id=dns-oarc%3Adnsjit) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=dns-oarc%3Adnsjit&metric=security_rating)](https://sonarcloud.io/dashboard?id=dns-oarc%3Adnsjit)
|
||||
[![Total alerts](https://img.shields.io/lgtm/alerts/g/DNS-OARC/dnsjit.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/DNS-OARC/dnsjit/alerts/) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=dns-oarc%3Adnsjit&metric=bugs)](https://sonarcloud.io/dashboard?id=dns-oarc%3Adnsjit) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=dns-oarc%3Adnsjit&metric=security_rating)](https://sonarcloud.io/dashboard?id=dns-oarc%3Adnsjit)
|
||||
|
||||
**dnsjit** is a combination of parts taken from **dsc**, **dnscap**, **drool**,
|
||||
and put together around Lua to create a script-based engine for easy
|
||||
|
@ -47,18 +47,19 @@ architectures because of LuaJIT.
|
|||
- [liblmdb](https://github.com/LMDB/lmdb)
|
||||
- [libck](https://github.com/concurrencykit/ck)
|
||||
- [libgnutls](https://www.gnutls.org/)
|
||||
- [libuv](http://libuv.org/)
|
||||
- [libnghttp2](https://www.nghttp2.org/)
|
||||
- [liblz4](http://www.lz4.org/)
|
||||
- [libzstd](http://www.zstd.net/)
|
||||
- [luajit](http://luajit.org/) (for building)
|
||||
- automake/autoconf/libtool/pkg-config (for building)
|
||||
|
||||
Debian/Ubuntu: `apt-get install libluajit-5.1-dev libpcap-dev luajit liblmdb-dev libck-dev libgnutls28-dev libuv1-dev libnghttp2-dev`
|
||||
Debian/Ubuntu: `apt-get install libluajit-5.1-dev libpcap-dev luajit liblmdb-dev libck-dev libgnutls28-dev liblz4-dev libzstd-dev`
|
||||
- Note: On Xenial you'll need to install `libzstd1-dev`
|
||||
|
||||
CentOS: `yum install luajit-devel libpcap-devel lmdb-devel ck-devel gnutls-devel libuv-devel libnghttp2-devel`
|
||||
CentOS: `yum install luajit-devel libpcap-devel lmdb-devel ck-devel gnutls-devel lz4-devel libzstd-devel`
|
||||
|
||||
FreeBSD: `pkg install luajit libpcap lmdb gnutls concurrencykit libuv libnghttp2`
|
||||
FreeBSD: `pkg install luajit libpcap lmdb gnutls concurrencykit zstd liblz4`
|
||||
|
||||
OpenBSD: `pkg_add luajit gnutls libuv nghttp2` + manual install of libpcap, liblmdb and libck
|
||||
OpenBSD: `pkg_add luajit gnutls lz4 zstd` + manual install of libpcap, liblmdb and libck
|
||||
|
||||
On some version of SUSE Linux Enterprise moonjit is used as an compatible
|
||||
alternative to luajit.
|
||||
|
|
1502
aclocal.m4
vendored
Normal file
1502
aclocal.m4
vendored
Normal file
File diff suppressed because it is too large
Load diff
270
ar-lib
Executable file
270
ar-lib
Executable file
|
@ -0,0 +1,270 @@
|
|||
#! /bin/sh
|
||||
# Wrapper for Microsoft lib.exe
|
||||
|
||||
me=ar-lib
|
||||
scriptversion=2012-03-01.08; # UTC
|
||||
|
||||
# Copyright (C) 2010-2018 Free Software Foundation, Inc.
|
||||
# Written by Peter Rosin <peda@lysator.liu.se>.
|
||||
#
|
||||
# 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, 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
|
||||
# func_error message
|
||||
func_error ()
|
||||
{
|
||||
echo "$me: $1" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv in
|
||||
mingw)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_at_file at_file operation archive
|
||||
# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
|
||||
# for each of them.
|
||||
# When interpreting the content of the @FILE, do NOT use func_file_conv,
|
||||
# since the user would need to supply preconverted file names to
|
||||
# binutils ar, at least for MinGW.
|
||||
func_at_file ()
|
||||
{
|
||||
operation=$2
|
||||
archive=$3
|
||||
at_file_contents=`cat "$1"`
|
||||
eval set x "$at_file_contents"
|
||||
shift
|
||||
|
||||
for member
|
||||
do
|
||||
$AR -NOLOGO $operation:"$member" "$archive" || exit $?
|
||||
done
|
||||
}
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
func_error "no command. Try '$0 --help' for more information."
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<EOF
|
||||
Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
|
||||
|
||||
Members may be specified in a file named with @FILE.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "$me, version $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
if test $# -lt 3; then
|
||||
func_error "you must specify a program, an action and an archive"
|
||||
fi
|
||||
|
||||
AR=$1
|
||||
shift
|
||||
while :
|
||||
do
|
||||
if test $# -lt 2; then
|
||||
func_error "you must specify a program, an action and an archive"
|
||||
fi
|
||||
case $1 in
|
||||
-lib | -LIB \
|
||||
| -ltcg | -LTCG \
|
||||
| -machine* | -MACHINE* \
|
||||
| -subsystem* | -SUBSYSTEM* \
|
||||
| -verbose | -VERBOSE \
|
||||
| -wx* | -WX* )
|
||||
AR="$AR $1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
action=$1
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
orig_archive=$1
|
||||
shift
|
||||
func_file_conv "$orig_archive"
|
||||
archive=$file
|
||||
|
||||
# strip leading dash in $action
|
||||
action=${action#-}
|
||||
|
||||
delete=
|
||||
extract=
|
||||
list=
|
||||
quick=
|
||||
replace=
|
||||
index=
|
||||
create=
|
||||
|
||||
while test -n "$action"
|
||||
do
|
||||
case $action in
|
||||
d*) delete=yes ;;
|
||||
x*) extract=yes ;;
|
||||
t*) list=yes ;;
|
||||
q*) quick=yes ;;
|
||||
r*) replace=yes ;;
|
||||
s*) index=yes ;;
|
||||
S*) ;; # the index is always updated implicitly
|
||||
c*) create=yes ;;
|
||||
u*) ;; # TODO: don't ignore the update modifier
|
||||
v*) ;; # TODO: don't ignore the verbose modifier
|
||||
*)
|
||||
func_error "unknown action specified"
|
||||
;;
|
||||
esac
|
||||
action=${action#?}
|
||||
done
|
||||
|
||||
case $delete$extract$list$quick$replace,$index in
|
||||
yes,* | ,yes)
|
||||
;;
|
||||
yesyes*)
|
||||
func_error "more than one action specified"
|
||||
;;
|
||||
*)
|
||||
func_error "no action specified"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -n "$delete"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_at_file "${1#@}" -REMOVE "$archive"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
$AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
elif test -n "$extract"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
if test $# -gt 0; then
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_at_file "${1#@}" -EXTRACT "$archive"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
$AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
$AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
|
||||
do
|
||||
$AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
|
||||
done
|
||||
fi
|
||||
|
||||
elif test -n "$quick$replace"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
if test -z "$create"; then
|
||||
echo "$me: creating $orig_archive"
|
||||
fi
|
||||
orig_archive=
|
||||
else
|
||||
orig_archive=$archive
|
||||
fi
|
||||
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_file_conv "${1#@}"
|
||||
set x "$@" "@$file"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
set x "$@" "$file"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
shift
|
||||
done
|
||||
|
||||
if test -n "$orig_archive"; then
|
||||
$AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
|
||||
else
|
||||
$AR -NOLOGO -OUT:"$archive" "$@" || exit $?
|
||||
fi
|
||||
|
||||
elif test -n "$list"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
$AR -NOLOGO -LIST "$archive" || exit $?
|
||||
fi
|
348
compile
Executable file
348
compile
Executable file
|
@ -0,0 +1,348 @@
|
|||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# 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, 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_dashL linkdir
|
||||
# Make cl look for libraries in LINKDIR
|
||||
func_cl_dashL ()
|
||||
{
|
||||
func_file_conv "$1"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
}
|
||||
|
||||
# func_cl_dashl library
|
||||
# Do a library search-path lookup for cl
|
||||
func_cl_dashl ()
|
||||
{
|
||||
lib=$1
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.dll.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/lib$lib.a"; then
|
||||
found=yes
|
||||
lib=$dir/lib$lib.a
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
if test "$found" != yes; then
|
||||
lib=$lib.lib
|
||||
fi
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I)
|
||||
eat=1
|
||||
func_file_conv "$2" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l)
|
||||
eat=1
|
||||
func_cl_dashl "$2"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
func_cl_dashl "${1#-l}"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-L)
|
||||
eat=1
|
||||
func_cl_dashL "$2"
|
||||
;;
|
||||
-L*)
|
||||
func_cl_dashL "${1#-L}"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
|
||||
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
1480
config.guess
vendored
Executable file
1480
config.guess
vendored
Executable file
File diff suppressed because it is too large
Load diff
1801
config.sub
vendored
Executable file
1801
config.sub
vendored
Executable file
File diff suppressed because it is too large
Load diff
10
configure.ac
10
configure.ac
|
@ -17,10 +17,10 @@
|
|||
# along with dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_PREREQ(2.64)
|
||||
AC_INIT([dnsjit], [1.1.0], [admin@dns-oarc.net], [dnsjit], [https://github.com/DNS-OARC/dnsjit/issues])
|
||||
AC_INIT([dnsjit], [1.2.1], [admin@dns-oarc.net], [dnsjit], [https://github.com/DNS-OARC/dnsjit/issues])
|
||||
AC_DEFINE([PACKAGE_MAJOR_VERSION], [1], [Define to the major version of this package.])
|
||||
AC_DEFINE([PACKAGE_MINOR_VERSION], [1], [Define to the minor version of this package.])
|
||||
AC_DEFINE([PACKAGE_PATCH_VERSION], [0], [Define to the patch version of this package.])
|
||||
AC_DEFINE([PACKAGE_MINOR_VERSION], [2], [Define to the minor version of this package.])
|
||||
AC_DEFINE([PACKAGE_PATCH_VERSION], [1], [Define to the patch version of this package.])
|
||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
|
||||
AC_CONFIG_SRCDIR([src/dnsjit.c])
|
||||
AC_CONFIG_HEADER([src/config.h])
|
||||
|
@ -83,8 +83,6 @@ if test "x$ac_cv_path_LUAJIT" = "x"; then
|
|||
fi
|
||||
AC_CHECK_HEADERS([lmdb.h])
|
||||
AC_CHECK_LIB([lmdb], [mdb_env_create])
|
||||
PKG_CHECK_MODULES([libuv], [libuv])
|
||||
PKG_CHECK_MODULES([libnghttp2], [libnghttp2])
|
||||
PKG_CHECK_MODULES([ck], [ck >= 0], [
|
||||
AS_VAR_APPEND([CFLAGS], [" $ck_CFLAGS"])
|
||||
AS_VAR_APPEND([LIBS], [" $ck_LIBS"])
|
||||
|
@ -93,6 +91,8 @@ PKG_CHECK_MODULES([ck], [ck >= 0], [
|
|||
AC_CHECK_LIB([ck], [ck_array_init],, [AC_MSG_ERROR([libck not found])])
|
||||
])
|
||||
AC_CHECK_LIB([gnutls], [gnutls_init],, [AC_MSG_ERROR([libgnutls not found])])
|
||||
PKG_CHECK_MODULES([liblz4], [liblz4 >= 1.8.0 liblz4 != 131], [AC_DEFINE([HAVE_LZ4], [], [Use liblz4])],:)
|
||||
PKG_CHECK_MODULES([libzstd], [libzstd >= 1.3.0], [AC_DEFINE([HAVE_ZSTD], [], [Use libzstd])],:)
|
||||
|
||||
# Checks for sizes
|
||||
AC_CHECK_SIZEOF([void*])
|
||||
|
|
791
depcomp
Executable file
791
depcomp
Executable file
|
@ -0,0 +1,791 @@
|
|||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
|
||||
|
||||
# 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, 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by 'PROGRAMS ARGS'.
|
||||
object Object file output by 'PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputting dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
# Get the directory component of the given path, and save it in the
|
||||
# global variables '$dir'. Note that this directory component will
|
||||
# be either empty or ending with a '/' character. This is deliberate.
|
||||
set_dir_from ()
|
||||
{
|
||||
case $1 in
|
||||
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
|
||||
*) dir=;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Get the suffix-stripped basename of the given path, and save it the
|
||||
# global variable '$base'.
|
||||
set_base_from ()
|
||||
{
|
||||
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
|
||||
}
|
||||
|
||||
# If no dependency file was actually created by the compiler invocation,
|
||||
# we still have to create a dummy depfile, to avoid errors with the
|
||||
# Makefile "include basename.Plo" scheme.
|
||||
make_dummy_depfile ()
|
||||
{
|
||||
echo "#dummy" > "$depfile"
|
||||
}
|
||||
|
||||
# Factor out some common post-processing of the generated depfile.
|
||||
# Requires the auxiliary global variable '$tmpdepfile' to be set.
|
||||
aix_post_process_depfile ()
|
||||
{
|
||||
# If the compiler actually managed to produce a dependency file,
|
||||
# post-process it.
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form 'foo.o: dependency.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# $object: dependency.h
|
||||
# and one to simply output
|
||||
# dependency.h:
|
||||
# which is needed to avoid the deleted-header problem.
|
||||
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
|
||||
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
|
||||
} > "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
}
|
||||
|
||||
# A tabulation character.
|
||||
tab=' '
|
||||
# A newline character.
|
||||
nl='
|
||||
'
|
||||
# Character ranges might be problematic outside the C locale.
|
||||
# These definitions help.
|
||||
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
lower=abcdefghijklmnopqrstuvwxyz
|
||||
digits=0123456789
|
||||
alpha=${upper}${lower}
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Avoid interferences from the environment.
|
||||
gccflag= dashmflag=
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
if test "$depmode" = msvc7msys; then
|
||||
# This is just like msvc7 but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvc7
|
||||
fi
|
||||
|
||||
if test "$depmode" = xlc; then
|
||||
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
|
||||
gccflag=-qmakedep=gcc,-MF
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
|
||||
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
|
||||
## (see the conditional assignment to $gccflag above).
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say). Also, it might not be
|
||||
## supported by the other compilers which use the 'gcc' depmode.
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The second -e expression handles DOS-style file names with drive
|
||||
# letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the "deleted header file" problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
## Some versions of gcc put a space before the ':'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well. hp depmode also adds that space, but also prefixes the VPATH
|
||||
## to the object. Take care to not repeat it in the output.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like '#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
|
||||
| tr "$nl" ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
xlc)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts '$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
tcc)
|
||||
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
|
||||
# FIXME: That version still under development at the moment of writing.
|
||||
# Make that this statement remains true also for stable, released
|
||||
# versions.
|
||||
# It will wrap lines (doesn't matter whether long or short) with a
|
||||
# trailing '\', as in:
|
||||
#
|
||||
# foo.o : \
|
||||
# foo.c \
|
||||
# foo.h \
|
||||
#
|
||||
# It will put a trailing '\' even on the last line, and will use leading
|
||||
# spaces rather than leading tabs (at least since its commit 0394caf7
|
||||
# "Emit spaces for -MD").
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
|
||||
# We have to change lines of the first kind to '$object: \'.
|
||||
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
|
||||
# And for each line of the second kind, we have to emit a 'dep.h:'
|
||||
# dummy dependency, to avoid the deleted-header problem.
|
||||
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
## The order of this option in the case statement is important, since the
|
||||
## shell code in configure will try each of these formats in the order
|
||||
## listed in this file. A plain '-MD' option would be understood by many
|
||||
## compilers, so we must ensure this comes after the gcc and icc options.
|
||||
pgcc)
|
||||
# Portland's C compiler understands '-MD'.
|
||||
# Will always output deps to 'file.d' where file is the root name of the
|
||||
# source file under compilation, even if file resides in a subdirectory.
|
||||
# The object file name does not affect the name of the '.d' file.
|
||||
# pgcc 10.2 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using '\' :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
set_dir_from "$object"
|
||||
# Use the source, not the object, to determine the base name, since
|
||||
# that's sadly what pgcc will do too.
|
||||
set_base_from "$source"
|
||||
tmpdepfile=$base.d
|
||||
|
||||
# For projects that build the same source file twice into different object
|
||||
# files, the pgcc approach of using the *source* file root name can cause
|
||||
# problems in parallel builds. Use a locking strategy to avoid stomping on
|
||||
# the same $tmpdepfile.
|
||||
lockdir=$base.d-lock
|
||||
trap "
|
||||
echo '$0: caught signal, cleaning up...' >&2
|
||||
rmdir '$lockdir'
|
||||
exit 1
|
||||
" 1 2 13 15
|
||||
numtries=100
|
||||
i=$numtries
|
||||
while test $i -gt 0; do
|
||||
# mkdir is a portable test-and-set.
|
||||
if mkdir "$lockdir" 2>/dev/null; then
|
||||
# This process acquired the lock.
|
||||
"$@" -MD
|
||||
stat=$?
|
||||
# Release the lock.
|
||||
rmdir "$lockdir"
|
||||
break
|
||||
else
|
||||
# If the lock is being held by a different process, wait
|
||||
# until the winning process is done or we timeout.
|
||||
while test -d "$lockdir" && test $i -gt 0; do
|
||||
sleep 1
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
fi
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
trap - 1 2 13 15
|
||||
if test $i -le 0; then
|
||||
echo "$0: failed to acquire lock after $numtries attempts" >&2
|
||||
echo "$0: check lockdir '$lockdir'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add 'dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in 'foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# Libtool generates 2 separate objects for the 2 libraries. These
|
||||
# two compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
|
||||
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
# Same post-processing that is required for AIX mode.
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
msvc7)
|
||||
if test "$libtool" = yes; then
|
||||
showIncludes=-Wc,-showIncludes
|
||||
else
|
||||
showIncludes=-showIncludes
|
||||
fi
|
||||
"$@" $showIncludes > "$tmpdepfile"
|
||||
stat=$?
|
||||
grep -v '^Note: including file: ' "$tmpdepfile"
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The first sed program below extracts the file names and escapes
|
||||
# backslashes for cygpath. The second sed program outputs the file
|
||||
# name when reading, but also accumulates all include files in the
|
||||
# hold buffer in order to output them again at the end. This only
|
||||
# works with sed implementations that can handle large buffers.
|
||||
sed < "$tmpdepfile" -n '
|
||||
/^Note: including file: *\(.*\)/ {
|
||||
s//\1/
|
||||
s/\\/\\\\/g
|
||||
p
|
||||
}' | $cygpath_u | sort -u | sed -n '
|
||||
s/ /\\ /g
|
||||
s/\(.*\)/'"$tab"'\1 \\/p
|
||||
s/.\(.*\) \\/\1:/
|
||||
H
|
||||
$ {
|
||||
s/.*/'"$tab"'/
|
||||
G
|
||||
p
|
||||
}' >> "$depfile"
|
||||
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvc7msys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for ':'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this sed invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
# makedepend may prepend the VPATH from the source file name to the object.
|
||||
# No need to regex-escape $object, excess matching of '.' is harmless.
|
||||
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process the last invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed '1,2d' "$tmpdepfile" \
|
||||
| tr ' ' "$nl" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E \
|
||||
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
| sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
|
||||
echo "$tab" >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
|
@ -18,4 +18,4 @@
|
|||
|
||||
dist_doc_DATA = capture.lua dumpdns2pcap.lua dumpdns.lua dumpdns-qr.lua \
|
||||
filter_rcode.lua qr-multi-pcap-state.lua readme.lua replay.lua \
|
||||
replay_multicli.lua respdiff.lua test_pcap_read.lua test_throughput.lua
|
||||
replay_multicli.lua respdiff.lua
|
||||
|
|
548
examples/Makefile.in
Normal file
548
examples/Makefile.in
Normal file
|
@ -0,0 +1,548 @@
|
|||
# Makefile.in generated by automake 1.16.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
# Copyright (c) 2018-2021, OARC, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of dnsjit.
|
||||
#
|
||||
# dnsjit 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
*) echo "am__make_running_with_option: internal error: invalid" \
|
||||
"target option '$${target_option-}' specified" >&2; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
has_opt=no; \
|
||||
sane_makeflags=$$MAKEFLAGS; \
|
||||
if $(am__is_gnu_make); then \
|
||||
sane_makeflags=$$MFLAGS; \
|
||||
else \
|
||||
case $$MAKEFLAGS in \
|
||||
*\\[\ \ ]*) \
|
||||
bs=\\; \
|
||||
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
|
||||
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
|
||||
esac; \
|
||||
fi; \
|
||||
skip_next=no; \
|
||||
strip_trailopt () \
|
||||
{ \
|
||||
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
|
||||
}; \
|
||||
for flg in $$sane_makeflags; do \
|
||||
test $$skip_next = yes && { skip_next=no; continue; }; \
|
||||
case $$flg in \
|
||||
*=*|--*) continue;; \
|
||||
-*I) strip_trailopt 'I'; skip_next=yes;; \
|
||||
-*I?*) strip_trailopt 'I';; \
|
||||
-*O) strip_trailopt 'O'; skip_next=yes;; \
|
||||
-*O?*) strip_trailopt 'O';; \
|
||||
-*l) strip_trailopt 'l'; skip_next=yes;; \
|
||||
-*l?*) strip_trailopt 'l';; \
|
||||
-[dEDm]) skip_next=yes;; \
|
||||
-[JT]) skip_next=yes;; \
|
||||
esac; \
|
||||
case $$flg in \
|
||||
*$$target_option*) has_opt=yes; break;; \
|
||||
esac; \
|
||||
done; \
|
||||
test $$has_opt = yes
|
||||
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
|
||||
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = examples
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
|
||||
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
|
||||
$(top_srcdir)/m4/ax_compiler_vendor.m4 \
|
||||
$(top_srcdir)/m4/ax_ext.m4 \
|
||||
$(top_srcdir)/m4/ax_gcc_x86_avx_xgetbv.m4 \
|
||||
$(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \
|
||||
$(top_srcdir)/m4/ax_prepend_flag.m4 \
|
||||
$(top_srcdir)/m4/ax_pthread.m4 \
|
||||
$(top_srcdir)/m4/ax_require_defined.m4 \
|
||||
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
|
||||
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
|
||||
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(dist_doc_DATA) \
|
||||
$(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/src/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
am__v_P_1 = :
|
||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
|
||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
am__v_GEN_1 =
|
||||
AM_V_at = $(am__v_at_@AM_V@)
|
||||
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
|
||||
am__v_at_0 = @
|
||||
am__v_at_1 =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
am__uninstall_files_from_dir = { \
|
||||
test -z "$$files" \
|
||||
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|
||||
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
|
||||
$(am__cd) "$$dir" && rm -f $$files; }; \
|
||||
}
|
||||
am__installdirs = "$(DESTDIR)$(docdir)"
|
||||
DATA = $(dist_doc_DATA)
|
||||
am__extra_recursive_targets = gcov-recursive
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CPUEXT_FLAGS = @CPUEXT_FLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
LUAJIT = @LUAJIT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
|
||||
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
|
||||
PTHREAD_CC = @PTHREAD_CC@
|
||||
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
|
||||
PTHREAD_LIBS = @PTHREAD_LIBS@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
SIMD_FLAGS = @SIMD_FLAGS@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
ax_pthread_config = @ax_pthread_config@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
ck_CFLAGS = @ck_CFLAGS@
|
||||
ck_LIBS = @ck_LIBS@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
liblz4_CFLAGS = @liblz4_CFLAGS@
|
||||
liblz4_LIBS = @liblz4_LIBS@
|
||||
libzstd_CFLAGS = @libzstd_CFLAGS@
|
||||
libzstd_LIBS = @libzstd_LIBS@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
luajit_CFLAGS = @luajit_CFLAGS@
|
||||
luajit_LIBS = @luajit_LIBS@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
dist_doc_DATA = capture.lua dumpdns2pcap.lua dumpdns.lua dumpdns-qr.lua \
|
||||
filter_rcode.lua qr-multi-pcap-state.lua readme.lua replay.lua \
|
||||
replay_multicli.lua respdiff.lua
|
||||
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign examples/Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
install-dist_docDATA: $(dist_doc_DATA)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
|
||||
if test -n "$$list"; then \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \
|
||||
fi; \
|
||||
for p in $$list; do \
|
||||
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||
echo "$$d$$p"; \
|
||||
done | $(am__base_list) | \
|
||||
while read files; do \
|
||||
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \
|
||||
$(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \
|
||||
done
|
||||
|
||||
uninstall-dist_docDATA:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
|
||||
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
|
||||
dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir)
|
||||
gcov-local:
|
||||
tags TAGS:
|
||||
|
||||
ctags CTAGS:
|
||||
|
||||
cscope cscopelist:
|
||||
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
distdir-am: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(DATA)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(docdir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-generic
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
gcov: gcov-am
|
||||
|
||||
gcov-am: gcov-local
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am: install-dist_docDATA
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-dist_docDATA
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
|
||||
cscopelist-am ctags-am distclean distclean-generic \
|
||||
distclean-libtool distdir dvi dvi-am gcov-am gcov-local html \
|
||||
html-am info info-am install install-am install-data \
|
||||
install-data-am install-dist_docDATA install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-pdf install-pdf-am install-ps install-ps-am \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags-am uninstall uninstall-am uninstall-dist_docDATA
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
|
@ -1,50 +0,0 @@
|
|||
#!/usr/bin/env dnsjit
|
||||
-- count-pkts-per-ip.lua: count number of packets received from each IP/IPv6 address
|
||||
|
||||
local input = require("dnsjit.input.pcap").new()
|
||||
local layer = require("dnsjit.filter.layer").new()
|
||||
local object = require("dnsjit.core.objects")
|
||||
local ip = require("dnsjit.lib.ip")
|
||||
local trie = require("dnsjit.lib.trie").new("uint64_t", true)
|
||||
local getopt = require("dnsjit.lib.getopt").new({})
|
||||
|
||||
local pcap = unpack(getopt:parse())
|
||||
if pcap == nil then
|
||||
print("usage: "..arg[1].." <pcap>")
|
||||
end
|
||||
|
||||
-- Set up input
|
||||
input:open_offline(pcap)
|
||||
layer:producer(input)
|
||||
local produce, pctx = layer:produce()
|
||||
|
||||
-- Read input and count packets
|
||||
while true do
|
||||
local obj = produce(pctx)
|
||||
if obj == nil then break end
|
||||
local pkt = obj:cast_to(object.IP) or obj:cast_to(object.IP6)
|
||||
|
||||
if pkt ~= nil then
|
||||
local iplen = 4
|
||||
if pkt:type() == "ip6" then
|
||||
iplen = 16
|
||||
end
|
||||
|
||||
local node = trie:get_ins(pkt.src, iplen)
|
||||
node:set(node:get() + 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- Print statistics
|
||||
local iter = trie:iter()
|
||||
local node = iter:node()
|
||||
|
||||
while node ~= nil do
|
||||
local npkts = tonumber(node:get())
|
||||
local key = node:key()
|
||||
local ipstr = ip.tostring(key, true)
|
||||
|
||||
print(ipstr.." sent "..npkts.." packets")
|
||||
iter:next()
|
||||
node = iter:node()
|
||||
end
|
|
@ -1,18 +1,30 @@
|
|||
#!/usr/bin/env dnsjit
|
||||
local pcap = arg[2]
|
||||
local compression = arg[3]
|
||||
|
||||
if pcap == nil then
|
||||
print("usage: "..arg[1].." <pcap>")
|
||||
print("usage: "..arg[1].." <pcap> [compression]")
|
||||
return
|
||||
end
|
||||
|
||||
local object = require("dnsjit.core.objects")
|
||||
local input = require("dnsjit.input.pcap").new()
|
||||
local zinput = require("dnsjit.input.zpcap").new()
|
||||
local layer = require("dnsjit.filter.layer").new()
|
||||
local dns = require("dnsjit.core.object.dns").new()
|
||||
|
||||
if string.lower(string.sub(pcap, -4)) == ".zst" or compression == "zstd" then
|
||||
zinput:zstd()
|
||||
zinput:open(pcap)
|
||||
layer:producer(zinput)
|
||||
elseif string.lower(string.sub(pcap, -4)) == ".lz4" or compression == "lz4" then
|
||||
zinput:lz4()
|
||||
zinput:open(pcap)
|
||||
layer:producer(zinput)
|
||||
else
|
||||
input:open_offline(pcap)
|
||||
layer:producer(input)
|
||||
end
|
||||
local producer, ctx = layer:produce()
|
||||
|
||||
while true do
|
||||
|
|
|
@ -1,149 +0,0 @@
|
|||
#!/usr/bin/env dnsjit
|
||||
local clock = require("dnsjit.lib.clock")
|
||||
local log = require("dnsjit.core.log")
|
||||
local getopt = require("dnsjit.lib.getopt").new({
|
||||
{ "v", "verbose", 0, "Enable and increase verbosity for each time given", "?+" },
|
||||
{ "l", "layer", false, "Test also with dnsjit.filter.layer", "?" },
|
||||
{ "p", "producer", false, "Test with the producer interface rather then receiver interface", "?" },
|
||||
})
|
||||
local pcap, runs = unpack(getopt:parse())
|
||||
if getopt:val("help") then
|
||||
getopt:usage()
|
||||
return
|
||||
end
|
||||
local v = getopt:val("v")
|
||||
if v > 0 then
|
||||
log.enable("warning")
|
||||
end
|
||||
if v > 1 then
|
||||
log.enable("notice")
|
||||
end
|
||||
if v > 2 then
|
||||
log.enable("info")
|
||||
end
|
||||
if v > 3 then
|
||||
log.enable("debug")
|
||||
end
|
||||
|
||||
if pcap == nil then
|
||||
print("usage: "..arg[1].." <pcap> [runs]")
|
||||
return
|
||||
end
|
||||
|
||||
inputs = { "fpcap", "mmpcap", "pcap" }
|
||||
result = {}
|
||||
results = {}
|
||||
highest = nil
|
||||
|
||||
if runs == nil then
|
||||
runs = 10
|
||||
else
|
||||
runs = tonumber(runs)
|
||||
end
|
||||
|
||||
if getopt:val("p") then
|
||||
for _, name in pairs(inputs) do
|
||||
rt = 0.0
|
||||
p = 0
|
||||
|
||||
print("run", name)
|
||||
for n = 1, runs do
|
||||
o = require("dnsjit.output.null").new()
|
||||
i = require("dnsjit.input."..name).new()
|
||||
|
||||
if name == "pcap" then
|
||||
i:open_offline(pcap)
|
||||
else
|
||||
i:open(pcap)
|
||||
end
|
||||
|
||||
if getopt:val("l") then
|
||||
f = require("dnsjit.filter.layer").new()
|
||||
f:producer(i)
|
||||
o:producer(f)
|
||||
else
|
||||
o:producer(i)
|
||||
end
|
||||
|
||||
ss, sns = clock:monotonic()
|
||||
o:run()
|
||||
es, ens = clock:monotonic()
|
||||
|
||||
if es > ss then
|
||||
rt = rt + ((es - ss) - 1) + ((1000000000 - sns + ens)/1000000000)
|
||||
elseif es == ss and ens > sns then
|
||||
rt = rt + (ens - sns) / 1000000000
|
||||
end
|
||||
|
||||
p = p + o:packets()
|
||||
end
|
||||
|
||||
result[name] = {
|
||||
rt = rt,
|
||||
p = p
|
||||
}
|
||||
if highest == nil or rt > result[highest].rt then
|
||||
highest = name
|
||||
end
|
||||
table.insert(results, name)
|
||||
end
|
||||
else
|
||||
for _, name in pairs(inputs) do
|
||||
rt = 0.0
|
||||
p = 0
|
||||
|
||||
print("run", name)
|
||||
for n = 1, runs do
|
||||
o = require("dnsjit.output.null").new()
|
||||
i = require("dnsjit.input."..name).new()
|
||||
|
||||
if name == "pcap" then
|
||||
i:open_offline(pcap)
|
||||
else
|
||||
i:open(pcap)
|
||||
end
|
||||
|
||||
if getopt:val("l") then
|
||||
f = require("dnsjit.filter.layer").new()
|
||||
f:receiver(o)
|
||||
i:receiver(f)
|
||||
else
|
||||
i:receiver(o)
|
||||
end
|
||||
|
||||
ss, sns = clock:monotonic()
|
||||
if name == "pcap" then
|
||||
i:dispatch()
|
||||
else
|
||||
i:run()
|
||||
end
|
||||
es, ens = clock:monotonic()
|
||||
|
||||
if es > ss then
|
||||
rt = rt + ((es - ss) - 1) + ((1000000000 - sns + ens)/1000000000)
|
||||
elseif es == ss and ens > sns then
|
||||
rt = rt + (ens - sns) / 1000000000
|
||||
end
|
||||
|
||||
p = p + o:packets()
|
||||
end
|
||||
|
||||
result[name] = {
|
||||
rt = rt,
|
||||
p = p
|
||||
}
|
||||
if highest == nil or rt > result[highest].rt then
|
||||
highest = name
|
||||
end
|
||||
table.insert(results, name)
|
||||
end
|
||||
end
|
||||
|
||||
print("name", "runtime", "pps", "x", "pkts")
|
||||
print(highest, result[highest].rt, result[highest].p/result[highest].rt, 1.0, result[highest].p)
|
||||
for _, name in pairs(results) do
|
||||
if name ~= highest then
|
||||
local f = result[name].p / result[highest].p
|
||||
print(name, result[name].rt, result[name].p/result[name].rt, (result[highest].rt/result[name].rt)*f, result[name].p)
|
||||
end
|
||||
end
|
|
@ -1,539 +0,0 @@
|
|||
#!/usr/bin/env dnsjit
|
||||
local ffi = require("ffi")
|
||||
local object = require("dnsjit.core.objects")
|
||||
local clock = require("dnsjit.lib.clock")
|
||||
local log = require("dnsjit.core.log")
|
||||
local getopt = require("dnsjit.lib.getopt").new({
|
||||
{ "v", "verbose", 0, "Enable and increase verbosity for each time given", "?+" },
|
||||
{ "s", "split", false, "Test also with dnsjit.filter.split", "?" },
|
||||
{ "t", "thread", false, "Test also with dnsjit.core.thread using dnsjit.core.channel", "?" },
|
||||
})
|
||||
local num, runs = unpack(getopt:parse())
|
||||
if getopt:val("help") then
|
||||
getopt:usage()
|
||||
return
|
||||
end
|
||||
local v = getopt:val("v")
|
||||
if v > 0 then
|
||||
log.enable("warning")
|
||||
end
|
||||
if v > 1 then
|
||||
log.enable("notice")
|
||||
end
|
||||
if v > 2 then
|
||||
log.enable("info")
|
||||
end
|
||||
if v > 3 then
|
||||
log.enable("debug")
|
||||
end
|
||||
|
||||
if num == nil then
|
||||
print("usage: "..arg[1].." <num> [runs]")
|
||||
return
|
||||
else
|
||||
num = tonumber(num)
|
||||
end
|
||||
|
||||
if runs == nil then
|
||||
runs = 1
|
||||
else
|
||||
runs = tonumber(runs)
|
||||
end
|
||||
|
||||
print("zero:receiver() -> null:receive()")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local o = require("dnsjit.output.null").new()
|
||||
|
||||
i:receiver(o)
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
i:run(num)
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec", o:packets())
|
||||
end
|
||||
|
||||
print("lua -> null:receive()")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local o = require("dnsjit.output.null").new()
|
||||
local recv, rctx = o:receive()
|
||||
local pkt = ffi.new("core_object_null_t")
|
||||
pkt.obj_type = object.NULL
|
||||
local obj = ffi.cast("core_object_t*", pkt)
|
||||
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
for n = 1, num do
|
||||
recv(rctx, obj)
|
||||
end
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec", o:packets())
|
||||
end
|
||||
|
||||
-- TODO: use core.thread
|
||||
|
||||
print("zero:produce() <- null:producer()")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local o = require("dnsjit.output.null").new()
|
||||
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
o:producer(i)
|
||||
o:run(num)
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec", o:packets())
|
||||
end
|
||||
|
||||
print("zero:produce() <- lua")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local prod, pctx = i:produce()
|
||||
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
for n = 1, num do
|
||||
prod(pctx)
|
||||
end
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec", num)
|
||||
end
|
||||
|
||||
print("zero:produce() <- lua -> null:receive()")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local o = require("dnsjit.output.null").new()
|
||||
local prod, pctx = i:produce()
|
||||
local recv, rctx = o:receive()
|
||||
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
for n = 1, num do
|
||||
recv(rctx, prod(pctx))
|
||||
end
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec", num)
|
||||
end
|
||||
|
||||
if getopt:val("s") then
|
||||
print("zero:receiver() -> split:receiver() -> null:receive() x1")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local s = require("dnsjit.filter.split").new()
|
||||
local o1 = require("dnsjit.output.null").new()
|
||||
|
||||
s:receiver(o1)
|
||||
i:receiver(s)
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
i:run(num)
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec", o1:packets(), o1:packets())
|
||||
end
|
||||
|
||||
print("zero:receiver() -> split:receiver() -> null:receive() x2")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local s = require("dnsjit.filter.split").new()
|
||||
local o1 = require("dnsjit.output.null").new()
|
||||
local o2 = require("dnsjit.output.null").new()
|
||||
|
||||
s:receiver(o1)
|
||||
s:receiver(o2)
|
||||
i:receiver(s)
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
i:run(num)
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec", o1:packets() + o2:packets(), o1:packets(), o2:packets())
|
||||
end
|
||||
|
||||
print("zero:receiver() -> split:receiver() -> null:receive() x4")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local s = require("dnsjit.filter.split").new()
|
||||
local o1 = require("dnsjit.output.null").new()
|
||||
local o2 = require("dnsjit.output.null").new()
|
||||
local o3 = require("dnsjit.output.null").new()
|
||||
local o4 = require("dnsjit.output.null").new()
|
||||
|
||||
s:receiver(o1)
|
||||
s:receiver(o2)
|
||||
s:receiver(o3)
|
||||
s:receiver(o4)
|
||||
i:receiver(s)
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
i:run(num)
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec", o1:packets() + o2:packets() + o3:packets() + o4:packets(), o1:packets(), o2:packets(), o3:packets(), o4:packets())
|
||||
end
|
||||
|
||||
print("zero:receiver() -> lua split table -> null:receive() x4")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local o1 = require("dnsjit.output.null").new()
|
||||
local o2 = require("dnsjit.output.null").new()
|
||||
local o3 = require("dnsjit.output.null").new()
|
||||
local o4 = require("dnsjit.output.null").new()
|
||||
|
||||
local prod, pctx = i:produce()
|
||||
local recv, rctx = {}, {}
|
||||
|
||||
local f, c = o1:receive()
|
||||
table.insert(recv, f)
|
||||
table.insert(rctx, c)
|
||||
f, c = o2:receive()
|
||||
table.insert(recv, f)
|
||||
table.insert(rctx, c)
|
||||
f, c = o3:receive()
|
||||
table.insert(recv, f)
|
||||
table.insert(rctx, c)
|
||||
f, c = o4:receive()
|
||||
table.insert(recv, f)
|
||||
table.insert(rctx, c)
|
||||
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
local idx = 1
|
||||
for n = 1, num do
|
||||
local f, c = recv[idx], rctx[idx]
|
||||
if not f then
|
||||
idx = 1
|
||||
f, c = recv[1], rctx[1]
|
||||
end
|
||||
f(c, prod(pctx))
|
||||
idx = idx + 1
|
||||
end
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec", o1:packets() + o2:packets() + o3:packets() + o4:packets(), o1:packets(), o2:packets(), o3:packets(), o4:packets())
|
||||
end
|
||||
|
||||
print("zero:receiver() -> lua split gen code -> null:receive() x4")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local o1 = require("dnsjit.output.null").new()
|
||||
local o2 = require("dnsjit.output.null").new()
|
||||
local o3 = require("dnsjit.output.null").new()
|
||||
local o4 = require("dnsjit.output.null").new()
|
||||
|
||||
local prod, pctx = i:produce()
|
||||
local f1, c1 = o1:receive()
|
||||
local f2, c2 = o2:receive()
|
||||
local f3, c3 = o3:receive()
|
||||
local f4, c4 = o4:receive()
|
||||
|
||||
local code = "return function (num, prod, pctx, f1, c1, f2, c2, f3, c3, f4, c4)\nlocal n = 0\nwhile n < num do\n"
|
||||
code = code .. "f1(c1,prod(pctx))\n"
|
||||
code = code .. "n = n + 1\n"
|
||||
code = code .. "f2(c2,prod(pctx))\n"
|
||||
code = code .. "n = n + 1\n"
|
||||
code = code .. "f3(c3,prod(pctx))\n"
|
||||
code = code .. "n = n + 1\n"
|
||||
code = code .. "f4(c4,prod(pctx))\n"
|
||||
code = code .. "n = n + 1\n"
|
||||
code = code .. "end\n"
|
||||
code = code .. "end"
|
||||
local f = assert(loadstring(code))()
|
||||
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
f(num, prod, pctx, f1, c1, f2, c2, f3, c3, f4, c4)
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec", o1:packets() + o2:packets() + o3:packets() + o4:packets(), o1:packets(), o2:packets(), o3:packets(), o4:packets())
|
||||
end
|
||||
end
|
||||
|
||||
if getopt:val("t") then
|
||||
print("zero:receiver() -> thread lua x1")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local c = require("dnsjit.core.channel").new()
|
||||
local t = require("dnsjit.core.thread").new()
|
||||
|
||||
t:start(function(t)
|
||||
local c = t:pop()
|
||||
|
||||
while true do
|
||||
local o = c:get()
|
||||
if o == nil then break end
|
||||
end
|
||||
end)
|
||||
t:push(c)
|
||||
|
||||
local prod, pctx = i:produce()
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
for n = 1, num do
|
||||
c:put(prod(pctx))
|
||||
end
|
||||
c:close()
|
||||
t:stop()
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec")
|
||||
end
|
||||
|
||||
print("zero:receiver() -> thread lua x2")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local c = require("dnsjit.core.channel").new()
|
||||
local c2 = require("dnsjit.core.channel").new()
|
||||
local t = require("dnsjit.core.thread").new()
|
||||
local t2 = require("dnsjit.core.thread").new()
|
||||
|
||||
local f = function(t)
|
||||
local c = t:pop()
|
||||
|
||||
while true do
|
||||
local o = c:get()
|
||||
if o == nil then break end
|
||||
end
|
||||
end
|
||||
|
||||
t:start(f)
|
||||
t2:start(f)
|
||||
t:push(c)
|
||||
t2:push(c2)
|
||||
|
||||
local prod, pctx = i:produce()
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
for n = 1, num/2 do
|
||||
c:put(prod(pctx))
|
||||
c2:put(prod(pctx))
|
||||
end
|
||||
c:close()
|
||||
c2:close()
|
||||
t:stop()
|
||||
t2:stop()
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec")
|
||||
end
|
||||
|
||||
print("zero:receiver() -> thread lua x4")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local c = require("dnsjit.core.channel").new()
|
||||
local c2 = require("dnsjit.core.channel").new()
|
||||
local c3 = require("dnsjit.core.channel").new()
|
||||
local c4 = require("dnsjit.core.channel").new()
|
||||
local t = require("dnsjit.core.thread").new()
|
||||
local t2 = require("dnsjit.core.thread").new()
|
||||
local t3 = require("dnsjit.core.thread").new()
|
||||
local t4 = require("dnsjit.core.thread").new()
|
||||
|
||||
local f = function(t)
|
||||
local c = t:pop()
|
||||
|
||||
while true do
|
||||
local o = c:get()
|
||||
if o == nil then break end
|
||||
end
|
||||
end
|
||||
|
||||
t:start(f)
|
||||
t2:start(f)
|
||||
t3:start(f)
|
||||
t4:start(f)
|
||||
t:push(c)
|
||||
t2:push(c2)
|
||||
t3:push(c3)
|
||||
t4:push(c4)
|
||||
|
||||
local prod, pctx = i:produce()
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
for n = 1, num/4 do
|
||||
c:put(prod(pctx))
|
||||
c2:put(prod(pctx))
|
||||
c3:put(prod(pctx))
|
||||
c4:put(prod(pctx))
|
||||
end
|
||||
c:close()
|
||||
c2:close()
|
||||
c3:close()
|
||||
c4:close()
|
||||
t:stop()
|
||||
t2:stop()
|
||||
t3:stop()
|
||||
t4:stop()
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec")
|
||||
end
|
||||
|
||||
print("zero:receiver() -> thread lua x1 -> null:receiver()")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local c = require("dnsjit.core.channel").new()
|
||||
local t = require("dnsjit.core.thread").new()
|
||||
|
||||
t:start(function(t)
|
||||
local c = t:pop()
|
||||
local o = require("dnsjit.output.null").new()
|
||||
|
||||
local recv, rctx = o:receive()
|
||||
while true do
|
||||
local obj = c:get()
|
||||
if obj == nil then break end
|
||||
recv(rctx, obj)
|
||||
end
|
||||
end)
|
||||
t:push(c)
|
||||
|
||||
local prod, pctx = i:produce()
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
for n = 1, num do
|
||||
c:put(prod(pctx))
|
||||
end
|
||||
c:close()
|
||||
t:stop()
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec")
|
||||
end
|
||||
|
||||
print("zero:receiver() -> thread x1 -> null:receiver()")
|
||||
local run
|
||||
for run = 1, runs do
|
||||
local i = require("dnsjit.input.zero").new()
|
||||
local c = require("dnsjit.core.channel").new()
|
||||
local t = require("dnsjit.core.thread").new()
|
||||
|
||||
t:start(function(t)
|
||||
local c = t:pop()
|
||||
local o = require("dnsjit.output.null").new()
|
||||
|
||||
c:receiver(o)
|
||||
c:run()
|
||||
end)
|
||||
t:push(c)
|
||||
|
||||
i:receiver(c)
|
||||
local start_sec, start_nsec = clock:monotonic()
|
||||
i:run(num)
|
||||
c:close()
|
||||
t:stop()
|
||||
local end_sec, end_nsec = clock:monotonic()
|
||||
|
||||
local runtime = 0
|
||||
if end_sec > start_sec then
|
||||
runtime = ((end_sec - start_sec) - 1) + ((1000000000 - start_nsec + end_nsec)/1000000000)
|
||||
elseif end_sec == start_sec and end_nsec > start_nsec then
|
||||
runtime = (end_nsec - start_nsec) / 1000000000
|
||||
end
|
||||
|
||||
print(run, "runtime", runtime, num/runtime, "/sec")
|
||||
end
|
||||
end
|
287
include/dnsjit/Makefile.am
Normal file
287
include/dnsjit/Makefile.am
Normal file
|
@ -0,0 +1,287 @@
|
|||
# Copyright (c) 2018-2021, OARC, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of dnsjit.
|
||||
#
|
||||
# dnsjit 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
|
||||
CLEANFILES = *.gcda *.gcno *.gcov
|
||||
|
||||
SUBDIRS = test
|
||||
|
||||
AM_CFLAGS = -Werror=attributes \
|
||||
-I$(srcdir) \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/include \
|
||||
$(SIMD_FLAGS) $(CPUEXT_FLAGS) \
|
||||
$(PTHREAD_CFLAGS) \
|
||||
$(luajit_CFLAGS) \
|
||||
$(liblz4_CFLAGS) $(libzstd_CFLAGS)
|
||||
|
||||
EXTRA_DIST = gen-manpage.lua gen-compat.lua gen-errno.sh dnsjit.1in
|
||||
|
||||
BUILT_SOURCES = core/compat.hh core/log_errstr.c
|
||||
|
||||
bin_PROGRAMS = dnsjit
|
||||
|
||||
dnsjit_SOURCES = dnsjit.c globals.c
|
||||
dist_dnsjit_SOURCES = core.lua lib.lua input.lua filter.lua output.lua
|
||||
dnsjitincludedir = $(includedir)/dnsjit
|
||||
nobase_dnsjitinclude_HEADERS = globals.h version.h
|
||||
lua_hobjects = core/compat.luaho
|
||||
lua_objects = core.luao lib.luao input.luao filter.luao output.luao
|
||||
dnsjit_LDADD = $(PTHREAD_LIBS) $(luajit_LIBS) $(liblz4_LIBS) $(libzstd_LIBS)
|
||||
|
||||
# C source and headers
|
||||
dnsjit_SOURCES += core/channel.c core/compat.c core/file.c core/log.c core/object.c core/object/dns.c core/object/ether.c core/object/gre.c core/object/icmp6.c core/object/icmp.c core/object/ieee802.c core/object/ip6.c core/object/ip.c core/object/linuxsll.c core/object/loop.c core/object/null.c core/object/payload.c core/object/pcap.c core/object/tcp.c core/object/udp.c core/producer.c core/receiver.c core/thread.c filter/copy.c filter/ipsplit.c filter/layer.c filter/split.c filter/timing.c input/fpcap.c input/mmpcap.c input/pcap.c input/zpcap.c lib/base64url.c lib/clock.c lib/trie.c output/dnscli.c output/pcap.c output/respdiff.c output/tcpcli.c output/tlscli.c output/udpcli.c
|
||||
nobase_dnsjitinclude_HEADERS += core/assert.h core/channel.h core/compat.h core/file.h core/log.h core/object/dns.h core/object/ether.h core/object/gre.h core/object.h core/object/icmp6.h core/object/icmp.h core/object/ieee802.h core/object/ip6.h core/object/ip.h core/object/linuxsll.h core/object/loop.h core/object/null.h core/object/payload.h core/object/pcap.h core/object/tcp.h core/object/udp.h core/producer.h core/receiver.h core/thread.h core/timespec.h filter/copy.h filter/ipsplit.h filter/layer.h filter/split.h filter/timing.h input/fpcap.h input/mmpcap.h input/pcap.h input/zpcap.h lib/base64url.h lib/clock.h lib/trie.h output/dnscli.h output/pcap.h output/respdiff.h output/tcpcli.h output/tlscli.h output/udpcli.h
|
||||
|
||||
# Lua headers
|
||||
nobase_dnsjitinclude_HEADERS += core/channel.hh core/file.hh core/log.hh core/object/dns.hh core/object/ether.hh core/object/gre.hh core/object.hh core/object/icmp6.hh core/object/icmp.hh core/object/ieee802.hh core/object/ip6.hh core/object/ip.hh core/object/linuxsll.hh core/object/loop.hh core/object/null.hh core/object/payload.hh core/object/pcap.hh core/object/tcp.hh core/object/udp.hh core/producer.hh core/receiver.hh core/thread.hh core/timespec.hh filter/copy.hh filter/ipsplit.hh filter/layer.hh filter/split.hh filter/timing.hh input/fpcap.hh input/mmpcap.hh input/pcap.hh input/zpcap.hh lib/base64url.hh lib/clock.hh lib/trie.hh output/dnscli.hh output/pcap.hh output/respdiff.hh output/tcpcli.hh output/tlscli.hh output/udpcli.hh
|
||||
lua_hobjects += core/channel.luaho core/file.luaho core/log.luaho core/object/dns.luaho core/object/ether.luaho core/object/gre.luaho core/object/icmp6.luaho core/object/icmp.luaho core/object/ieee802.luaho core/object/ip6.luaho core/object/ip.luaho core/object/linuxsll.luaho core/object/loop.luaho core/object.luaho core/object/null.luaho core/object/payload.luaho core/object/pcap.luaho core/object/tcp.luaho core/object/udp.luaho core/producer.luaho core/receiver.luaho core/thread.luaho core/timespec.luaho filter/copy.luaho filter/ipsplit.luaho filter/layer.luaho filter/split.luaho filter/timing.luaho input/fpcap.luaho input/mmpcap.luaho input/pcap.luaho input/zpcap.luaho lib/base64url.luaho lib/clock.luaho lib/trie.luaho output/dnscli.luaho output/pcap.luaho output/respdiff.luaho output/tcpcli.luaho output/tlscli.luaho output/udpcli.luaho
|
||||
|
||||
# Lua sources
|
||||
dist_dnsjit_SOURCES += core/channel.lua core/compat.lua core/file.lua core/loader.lua core/log.lua core/object/dns/label.lua core/object/dns.lua core/object/dns/q.lua core/object/dns/rr.lua core/object/ether.lua core/object/gre.lua core/object/icmp6.lua core/object/icmp.lua core/object/ieee802.lua core/object/ip6.lua core/object/ip.lua core/object/linuxsll.lua core/object/loop.lua core/object.lua core/object/null.lua core/object/payload.lua core/object/pcap.lua core/objects.lua core/object/tcp.lua core/object/udp.lua core/producer.lua core/receiver.lua core/thread.lua core/timespec.lua filter/copy.lua filter/ipsplit.lua filter/layer.lua filter/split.lua filter/timing.lua input/fpcap.lua input/mmpcap.lua input/pcap.lua input/zero.lua input/zpcap.lua lib/base64url.lua lib/clock.lua lib/getopt.lua lib/ip.lua lib/parseconf.lua lib/trie/iter.lua lib/trie.lua lib/trie/node.lua output/dnscli.lua output/null.lua output/pcap.lua output/respdiff.lua output/tcpcli.lua output/tlscli.lua output/udpcli.lua
|
||||
lua_objects += core/channel.luao core/compat.luao core/file.luao core/loader.luao core/log.luao core/object/dns/label.luao core/object/dns.luao core/object/dns/q.luao core/object/dns/rr.luao core/object/ether.luao core/object/gre.luao core/object/icmp6.luao core/object/icmp.luao core/object/ieee802.luao core/object/ip6.luao core/object/ip.luao core/object/linuxsll.luao core/object/loop.luao core/object.luao core/object/null.luao core/object/payload.luao core/object/pcap.luao core/objects.luao core/object/tcp.luao core/object/udp.luao core/producer.luao core/receiver.luao core/thread.luao core/timespec.luao filter/copy.luao filter/ipsplit.luao filter/layer.luao filter/split.luao filter/timing.luao input/fpcap.luao input/mmpcap.luao input/pcap.luao input/zero.luao input/zpcap.luao lib/base64url.luao lib/clock.luao lib/getopt.luao lib/ip.luao lib/parseconf.luao lib/trie/iter.luao lib/trie.luao lib/trie/node.luao output/dnscli.luao output/null.luao output/pcap.luao output/respdiff.luao output/tcpcli.luao output/tlscli.luao output/udpcli.luao
|
||||
|
||||
dnsjit_LDFLAGS = -Wl,-E
|
||||
dnsjit_LDADD += $(lua_hobjects) $(lua_objects)
|
||||
CLEANFILES += $(lua_hobjects) $(lua_objects)
|
||||
|
||||
man1_MANS = dnsjit.1
|
||||
CLEANFILES += $(man1_MANS)
|
||||
|
||||
man3_MANS = dnsjit.core.3 dnsjit.lib.3 dnsjit.input.3 dnsjit.filter.3 dnsjit.output.3
|
||||
man3_MANS += dnsjit.core.channel.3 dnsjit.core.compat.3 dnsjit.core.file.3 dnsjit.core.loader.3 dnsjit.core.log.3 dnsjit.core.object.3 dnsjit.core.object.dns.3 dnsjit.core.object.dns.label.3 dnsjit.core.object.dns.q.3 dnsjit.core.object.dns.rr.3 dnsjit.core.object.ether.3 dnsjit.core.object.gre.3 dnsjit.core.object.icmp.3 dnsjit.core.object.icmp6.3 dnsjit.core.object.ieee802.3 dnsjit.core.object.ip.3 dnsjit.core.object.ip6.3 dnsjit.core.object.linuxsll.3 dnsjit.core.object.loop.3 dnsjit.core.object.null.3 dnsjit.core.object.payload.3 dnsjit.core.object.pcap.3 dnsjit.core.objects.3 dnsjit.core.object.tcp.3 dnsjit.core.object.udp.3 dnsjit.core.producer.3 dnsjit.core.receiver.3 dnsjit.core.thread.3 dnsjit.core.timespec.3 dnsjit.filter.copy.3 dnsjit.filter.ipsplit.3 dnsjit.filter.layer.3 dnsjit.filter.split.3 dnsjit.filter.timing.3 dnsjit.input.fpcap.3 dnsjit.input.mmpcap.3 dnsjit.input.pcap.3 dnsjit.input.zero.3 dnsjit.input.zpcap.3 dnsjit.lib.base64url.3 dnsjit.lib.clock.3 dnsjit.lib.getopt.3 dnsjit.lib.ip.3 dnsjit.lib.parseconf.3 dnsjit.lib.trie.3 dnsjit.lib.trie.iter.3 dnsjit.lib.trie.node.3 dnsjit.output.dnscli.3 dnsjit.output.null.3 dnsjit.output.pcap.3 dnsjit.output.respdiff.3 dnsjit.output.tcpcli.3 dnsjit.output.tlscli.3 dnsjit.output.udpcli.3
|
||||
CLEANFILES += *.3in $(man3_MANS)
|
||||
|
||||
.lua.luao:
|
||||
@mkdir -p `dirname "$@"`
|
||||
$(LUAJIT) -bg -n "dnsjit.`echo \"$@\" | sed 's%\..*%%' | sed 's%/%.%g'`" -t o "$<" "$@"
|
||||
|
||||
.luah.luaho:
|
||||
@mkdir -p `dirname "$@"`
|
||||
$(LUAJIT) -bg -n "dnsjit.`echo \"$@\" | sed 's%\..*%%' | sed 's%/%.%g'`_h" -t o "$<" "$@"
|
||||
|
||||
.hh.luah:
|
||||
@mkdir -p `dirname "$@"`
|
||||
@echo 'module(...,package.seeall);' > "$@"
|
||||
@cat "$<" | grep '^//lua:' | sed 's%^//lua:%%' >> "$@"
|
||||
@echo 'require("ffi").cdef[[' >> "$@"
|
||||
@cat "$<" | grep -v '^#' >> "$@"
|
||||
@echo ']]' >> "$@"
|
||||
|
||||
.1in.1:
|
||||
sed -e 's,[@]PACKAGE_VERSION[@],$(PACKAGE_VERSION),g' \
|
||||
-e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \
|
||||
-e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
|
||||
< "$<" > "$@"
|
||||
|
||||
.3in.3:
|
||||
sed -e 's,[@]PACKAGE_VERSION[@],$(PACKAGE_VERSION),g' \
|
||||
-e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \
|
||||
-e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
|
||||
< "$<" > "$@"
|
||||
|
||||
if ENABLE_GCOV
|
||||
gcov-local:
|
||||
for src in $(dnsjit_SOURCES); do \
|
||||
gcov -x -l -r -s "$(srcdir)" "$$src"; \
|
||||
done
|
||||
endif
|
||||
|
||||
core/compat.hh: gen-compat.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-compat.lua" > "$@"
|
||||
|
||||
core/log_errstr.c: gen-errno.sh
|
||||
"$(srcdir)/gen-errno.sh" > "$@"
|
||||
|
||||
|
||||
dnsjit.core.3in: core.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core.lua" > "$@"
|
||||
|
||||
dnsjit.lib.3in: lib.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/lib.lua" > "$@"
|
||||
|
||||
dnsjit.input.3in: input.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/input.lua" > "$@"
|
||||
|
||||
dnsjit.filter.3in: filter.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/filter.lua" > "$@"
|
||||
|
||||
dnsjit.output.3in: output.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/output.lua" > "$@"
|
||||
|
||||
dnsjit.core.channel.3in: core/channel.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/channel.lua" > "$@"
|
||||
|
||||
dnsjit.core.compat.3in: core/compat.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/compat.lua" > "$@"
|
||||
|
||||
dnsjit.core.file.3in: core/file.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/file.lua" > "$@"
|
||||
|
||||
dnsjit.core.loader.3in: core/loader.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/loader.lua" > "$@"
|
||||
|
||||
dnsjit.core.log.3in: core/log.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/log.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.dns.label.3in: core/object/dns/label.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/dns/label.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.dns.3in: core/object/dns.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/dns.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.dns.q.3in: core/object/dns/q.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/dns/q.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.dns.rr.3in: core/object/dns/rr.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/dns/rr.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.ether.3in: core/object/ether.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/ether.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.gre.3in: core/object/gre.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/gre.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.icmp6.3in: core/object/icmp6.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/icmp6.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.icmp.3in: core/object/icmp.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/icmp.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.ieee802.3in: core/object/ieee802.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/ieee802.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.ip6.3in: core/object/ip6.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/ip6.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.ip.3in: core/object/ip.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/ip.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.linuxsll.3in: core/object/linuxsll.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/linuxsll.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.loop.3in: core/object/loop.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/loop.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.3in: core/object.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.null.3in: core/object/null.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/null.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.payload.3in: core/object/payload.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/payload.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.pcap.3in: core/object/pcap.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/pcap.lua" > "$@"
|
||||
|
||||
dnsjit.core.objects.3in: core/objects.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/objects.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.tcp.3in: core/object/tcp.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/tcp.lua" > "$@"
|
||||
|
||||
dnsjit.core.object.udp.3in: core/object/udp.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/object/udp.lua" > "$@"
|
||||
|
||||
dnsjit.core.producer.3in: core/producer.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/producer.lua" > "$@"
|
||||
|
||||
dnsjit.core.receiver.3in: core/receiver.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/receiver.lua" > "$@"
|
||||
|
||||
dnsjit.core.thread.3in: core/thread.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/thread.lua" > "$@"
|
||||
|
||||
dnsjit.core.timespec.3in: core/timespec.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/core/timespec.lua" > "$@"
|
||||
|
||||
dnsjit.filter.copy.3in: filter/copy.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/filter/copy.lua" > "$@"
|
||||
|
||||
dnsjit.filter.ipsplit.3in: filter/ipsplit.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/filter/ipsplit.lua" > "$@"
|
||||
|
||||
dnsjit.filter.layer.3in: filter/layer.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/filter/layer.lua" > "$@"
|
||||
|
||||
dnsjit.filter.split.3in: filter/split.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/filter/split.lua" > "$@"
|
||||
|
||||
dnsjit.filter.timing.3in: filter/timing.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/filter/timing.lua" > "$@"
|
||||
|
||||
dnsjit.input.fpcap.3in: input/fpcap.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/input/fpcap.lua" > "$@"
|
||||
|
||||
dnsjit.input.mmpcap.3in: input/mmpcap.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/input/mmpcap.lua" > "$@"
|
||||
|
||||
dnsjit.input.pcap.3in: input/pcap.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/input/pcap.lua" > "$@"
|
||||
|
||||
dnsjit.input.zero.3in: input/zero.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/input/zero.lua" > "$@"
|
||||
|
||||
dnsjit.input.zpcap.3in: input/zpcap.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/input/zpcap.lua" > "$@"
|
||||
|
||||
dnsjit.lib.base64url.3in: lib/base64url.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/lib/base64url.lua" > "$@"
|
||||
|
||||
dnsjit.lib.clock.3in: lib/clock.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/lib/clock.lua" > "$@"
|
||||
|
||||
dnsjit.lib.getopt.3in: lib/getopt.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/lib/getopt.lua" > "$@"
|
||||
|
||||
dnsjit.lib.ip.3in: lib/ip.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/lib/ip.lua" > "$@"
|
||||
|
||||
dnsjit.lib.parseconf.3in: lib/parseconf.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/lib/parseconf.lua" > "$@"
|
||||
|
||||
dnsjit.lib.trie.iter.3in: lib/trie/iter.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/lib/trie/iter.lua" > "$@"
|
||||
|
||||
dnsjit.lib.trie.3in: lib/trie.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/lib/trie.lua" > "$@"
|
||||
|
||||
dnsjit.lib.trie.node.3in: lib/trie/node.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/lib/trie/node.lua" > "$@"
|
||||
|
||||
dnsjit.output.dnscli.3in: output/dnscli.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/output/dnscli.lua" > "$@"
|
||||
|
||||
dnsjit.output.null.3in: output/null.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/output/null.lua" > "$@"
|
||||
|
||||
dnsjit.output.pcap.3in: output/pcap.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/output/pcap.lua" > "$@"
|
||||
|
||||
dnsjit.output.respdiff.3in: output/respdiff.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/output/respdiff.lua" > "$@"
|
||||
|
||||
dnsjit.output.tcpcli.3in: output/tcpcli.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/output/tcpcli.lua" > "$@"
|
||||
|
||||
dnsjit.output.tlscli.3in: output/tlscli.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/output/tlscli.lua" > "$@"
|
||||
|
||||
dnsjit.output.udpcli.3in: output/udpcli.lua gen-manpage.lua
|
||||
$(LUAJIT) "$(srcdir)/gen-manpage.lua" "$(srcdir)/output/udpcli.lua" > "$@"
|
1652
include/dnsjit/Makefile.in
Normal file
1652
include/dnsjit/Makefile.in
Normal file
File diff suppressed because it is too large
Load diff
295
include/dnsjit/config.h.in
Normal file
295
include/dnsjit/config.h.in
Normal file
|
@ -0,0 +1,295 @@
|
|||
/* src/config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 to support Advanced Bit Manipulation */
|
||||
#undef HAVE_ABM
|
||||
|
||||
/* Define to 1 to support Multi-Precision Add-Carry Instruction Extensions */
|
||||
#undef HAVE_ADX
|
||||
|
||||
/* Define to 1 to support Advanced Encryption Standard New Instruction Set
|
||||
(AES-NI) */
|
||||
#undef HAVE_AES
|
||||
|
||||
/* Support Altivec instructions */
|
||||
#undef HAVE_ALTIVEC
|
||||
|
||||
/* Define to 1 to support Advanced Vector Extensions */
|
||||
#undef HAVE_AVX
|
||||
|
||||
/* Define to 1 to support Advanced Vector Extensions 2 */
|
||||
#undef HAVE_AVX2
|
||||
|
||||
/* Define to 1 to support AVX-512 Byte and Word Instructions */
|
||||
#undef HAVE_AVX512_BW
|
||||
|
||||
/* Define to 1 to support AVX-512 Conflict Detection Instructions */
|
||||
#undef HAVE_AVX512_CD
|
||||
|
||||
/* Define to 1 to support AVX-512 Doubleword and Quadword Instructions */
|
||||
#undef HAVE_AVX512_DQ
|
||||
|
||||
/* Define to 1 to support AVX-512 Exponential & Reciprocal Instructions */
|
||||
#undef HAVE_AVX512_ER
|
||||
|
||||
/* Define to 1 to support AVX-512 Foundation Extensions */
|
||||
#undef HAVE_AVX512_F
|
||||
|
||||
/* Define to 1 to support AVX-512 Integer Fused Multiply Add Instructions */
|
||||
#undef HAVE_AVX512_IFMA
|
||||
|
||||
/* Define to 1 to support AVX-512 Conflict Prefetch Instructions */
|
||||
#undef HAVE_AVX512_PF
|
||||
|
||||
/* Define to 1 to support AVX-512 Vector Byte Manipulation Instructions */
|
||||
#undef HAVE_AVX512_VBMI
|
||||
|
||||
/* Define to 1 to support AVX-512 Vector Length Extensions */
|
||||
#undef HAVE_AVX512_VL
|
||||
|
||||
/* Define to 1 to support Bit Manipulation Instruction Set 1 */
|
||||
#undef HAVE_BMI1
|
||||
|
||||
/* Define to 1 to support Bit Manipulation Instruction Set 2 */
|
||||
#undef HAVE_BMI2
|
||||
|
||||
/* Define to 1 if you have the <byteswap.h> header file. */
|
||||
#undef HAVE_BYTESWAP_H
|
||||
|
||||
/* Define to 1 if you have the <ck_pr.h> header file. */
|
||||
#undef HAVE_CK_PR_H
|
||||
|
||||
/* Define to 1 if you have the <ck_ring.h> header file. */
|
||||
#undef HAVE_CK_RING_H
|
||||
|
||||
/* Define to 1 if you have the `clock_nanosleep' function. */
|
||||
#undef HAVE_CLOCK_NANOSLEEP
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <endian.h> header file. */
|
||||
#undef HAVE_ENDIAN_H
|
||||
|
||||
/* Define to 1 to support Fused Multiply-Add Extensions 3 */
|
||||
#undef HAVE_FMA3
|
||||
|
||||
/* Define to 1 to support Fused Multiply-Add Extensions 4 */
|
||||
#undef HAVE_FMA4
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `ck' library (-lck). */
|
||||
#undef HAVE_LIBCK
|
||||
|
||||
/* Define to 1 if you have the `gnutls' library (-lgnutls). */
|
||||
#undef HAVE_LIBGNUTLS
|
||||
|
||||
/* Define to 1 if you have the `lmdb' library (-llmdb). */
|
||||
#undef HAVE_LIBLMDB
|
||||
|
||||
/* Define to 1 if you have the `pcap' library (-lpcap). */
|
||||
#undef HAVE_LIBPCAP
|
||||
|
||||
/* Define to 1 if you have the <lmdb.h> header file. */
|
||||
#undef HAVE_LMDB_H
|
||||
|
||||
/* Use liblz4 */
|
||||
#undef HAVE_LZ4
|
||||
|
||||
/* Define to 1 if you have the <machine/endian.h> header file. */
|
||||
#undef HAVE_MACHINE_ENDIAN_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 to support Multimedia Extensions */
|
||||
#undef HAVE_MMX
|
||||
|
||||
/* Define to 1 to support Memory Protection Extensions */
|
||||
#undef HAVE_MPX
|
||||
|
||||
/* Define to 1 if you have the `nanosleep' function. */
|
||||
#undef HAVE_NANOSLEEP
|
||||
|
||||
/* Define to 1 if you have the <net/ethernet.h> header file. */
|
||||
#undef HAVE_NET_ETHERNET_H
|
||||
|
||||
/* Define to 1 if you have the <net/ethertypes.h> header file. */
|
||||
#undef HAVE_NET_ETHERTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `pcap_activate' function. */
|
||||
#undef HAVE_PCAP_ACTIVATE
|
||||
|
||||
/* Define to 1 if you have the `pcap_create' function. */
|
||||
#undef HAVE_PCAP_CREATE
|
||||
|
||||
/* Define to 1 if the system has the type `pcap_direction_t'. */
|
||||
#undef HAVE_PCAP_DIRECTION_T
|
||||
|
||||
/* Define to 1 if you have the `pcap_open_offline_with_tstamp_precision'
|
||||
function. */
|
||||
#undef HAVE_PCAP_OPEN_OFFLINE_WITH_TSTAMP_PRECISION
|
||||
|
||||
/* Define to 1 if you have the `pcap_setdirection' function. */
|
||||
#undef HAVE_PCAP_SETDIRECTION
|
||||
|
||||
/* Define to 1 if you have the `pcap_set_immediate_mode' function. */
|
||||
#undef HAVE_PCAP_SET_IMMEDIATE_MODE
|
||||
|
||||
/* Define to 1 if you have the `pcap_set_tstamp_precision' function. */
|
||||
#undef HAVE_PCAP_SET_TSTAMP_PRECISION
|
||||
|
||||
/* Define to 1 if you have the `pcap_set_tstamp_type' function. */
|
||||
#undef HAVE_PCAP_SET_TSTAMP_TYPE
|
||||
|
||||
/* Define to 1 to support Prefetch Vector Data Into Caches WT1 */
|
||||
#undef HAVE_PREFETCHWT1
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#undef HAVE_PTHREAD
|
||||
|
||||
/* Have PTHREAD_PRIO_INHERIT. */
|
||||
#undef HAVE_PTHREAD_PRIO_INHERIT
|
||||
|
||||
/* Define to 1 to support Digital Random Number Generator */
|
||||
#undef HAVE_RDRND
|
||||
|
||||
/* Define to 1 if you have the `sched_yield' function. */
|
||||
#undef HAVE_SCHED_YIELD
|
||||
|
||||
/* Define to 1 to support Secure Hash Algorithm Extension */
|
||||
#undef HAVE_SHA
|
||||
|
||||
/* Define to 1 to support Streaming SIMD Extensions */
|
||||
#undef HAVE_SSE
|
||||
|
||||
/* Define to 1 to support Streaming SIMD Extensions */
|
||||
#undef HAVE_SSE2
|
||||
|
||||
/* Define to 1 to support Streaming SIMD Extensions 3 */
|
||||
#undef HAVE_SSE3
|
||||
|
||||
/* Define to 1 to support Streaming SIMD Extensions 4.1 */
|
||||
#undef HAVE_SSE4_1
|
||||
|
||||
/* Define to 1 to support Streaming SIMD Extensions 4.2 */
|
||||
#undef HAVE_SSE4_2
|
||||
|
||||
/* Define to 1 to support AMD Streaming SIMD Extensions 4a */
|
||||
#undef HAVE_SSE4a
|
||||
|
||||
/* Define to 1 to support Supplemental Streaming SIMD Extensions 3 */
|
||||
#undef HAVE_SSSE3
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/endian.h> header file. */
|
||||
#undef HAVE_SYS_ENDIAN_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Support VSX instructions */
|
||||
#undef HAVE_VSX
|
||||
|
||||
/* Define to 1 to support eXtended Operations Extensions */
|
||||
#undef HAVE_XOP
|
||||
|
||||
/* Use libzstd */
|
||||
#undef HAVE_ZSTD
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the major version of this package. */
|
||||
#undef PACKAGE_MAJOR_VERSION
|
||||
|
||||
/* Define to the minor version of this package. */
|
||||
#undef PACKAGE_MINOR_VERSION
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the patch version of this package. */
|
||||
#undef PACKAGE_PATCH_VERSION
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
#undef PTHREAD_CREATE_JOINABLE
|
||||
|
||||
/* The size of `ck_ring_buffer_t', as computed by sizeof. */
|
||||
#undef SIZEOF_CK_RING_BUFFER_T
|
||||
|
||||
/* The size of `ck_ring_t', as computed by sizeof. */
|
||||
#undef SIZEOF_CK_RING_T
|
||||
|
||||
/* The size of `gnutls_certificate_credentials_t', as computed by sizeof. */
|
||||
#undef SIZEOF_GNUTLS_CERTIFICATE_CREDENTIALS_T
|
||||
|
||||
/* The size of `gnutls_session_t', as computed by sizeof. */
|
||||
#undef SIZEOF_GNUTLS_SESSION_T
|
||||
|
||||
/* The size of `pthread_cond_t', as computed by sizeof. */
|
||||
#undef SIZEOF_PTHREAD_COND_T
|
||||
|
||||
/* The size of `pthread_mutex_t', as computed by sizeof. */
|
||||
#undef SIZEOF_PTHREAD_MUTEX_T
|
||||
|
||||
/* The size of `pthread_t', as computed by sizeof. */
|
||||
#undef SIZEOF_PTHREAD_T
|
||||
|
||||
/* The size of `struct pollfd', as computed by sizeof. */
|
||||
#undef SIZEOF_STRUCT_POLLFD
|
||||
|
||||
/* The size of `struct sockaddr_storage', as computed by sizeof. */
|
||||
#undef SIZEOF_STRUCT_SOCKADDR_STORAGE
|
||||
|
||||
/* The size of `void*', as computed by sizeof. */
|
||||
#undef SIZEOF_VOIDP
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
45
include/dnsjit/core.lua
Normal file
45
include/dnsjit/core.lua
Normal file
|
@ -0,0 +1,45 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core
|
||||
-- Core modules for dnsjit
|
||||
--
|
||||
-- Core modules for handling things like logging, DNS messages and
|
||||
-- receiver/receive functionality.
|
||||
-- .SS Global Variables
|
||||
-- The following global variables exists in
|
||||
-- .IR dnsjit .
|
||||
-- .TP
|
||||
-- .B arg
|
||||
-- A table with the arguments given on the command line, the first will be
|
||||
-- the path to the
|
||||
-- .I dnsjit
|
||||
-- binary, second will be the path to the
|
||||
-- .IR script .
|
||||
module(...,package.seeall)
|
||||
|
||||
-- dnsjit.core.channel (3),
|
||||
-- dnsjit.core.compat (3),
|
||||
-- dnsjit.core.log (3),
|
||||
-- dnsjit.core.object (3),
|
||||
-- dnsjit.core.objects (3),
|
||||
-- dnsjit.core.producer (3),
|
||||
-- dnsjit.core.receiver (3),
|
||||
-- dnsjit.core.thread (3),
|
||||
-- dnsjit.core.timespec (3)
|
||||
return
|
46
include/dnsjit/core/assert.h
Normal file
46
include/dnsjit/core/assert.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __dnsjit_core_assert_h
|
||||
#define __dnsjit_core_assert_h
|
||||
|
||||
#include <dnsjit/core/log.h>
|
||||
|
||||
#define mlassert_self() \
|
||||
if (!self) \
|
||||
core_log_fatal(&_log, __FILE__, __LINE__, "self is nil")
|
||||
#define glassert_self() \
|
||||
if (!self) \
|
||||
core_log_fatal(0, __FILE__, __LINE__, "self is nil")
|
||||
|
||||
#define lassert(expression, msg...) \
|
||||
if (!(expression)) \
|
||||
core_log_fatal(&self->_log, __FILE__, __LINE__, msg)
|
||||
#define lpassert(expression, msg...) \
|
||||
if (!(expression)) \
|
||||
core_log_fatal(self->_log, __FILE__, __LINE__, msg)
|
||||
#define mlassert(expression, msg...) \
|
||||
if (!(expression)) \
|
||||
core_log_fatal(&_log, __FILE__, __LINE__, msg)
|
||||
#define glassert(expression, msg...) \
|
||||
if (!(expression)) \
|
||||
core_log_fatal(0, __FILE__, __LINE__, msg)
|
||||
|
||||
#endif
|
169
include/dnsjit/core/channel.c
Normal file
169
include/dnsjit/core/channel.c
Normal file
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/channel.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
#include <sched.h>
|
||||
|
||||
static core_log_t _log = LOG_T_INIT("core.channel");
|
||||
static core_channel_t _defaults = {
|
||||
LOG_T_INIT_OBJ("core.channel"),
|
||||
0, { 0 }, 0, 0,
|
||||
0, 0
|
||||
};
|
||||
|
||||
core_log_t* core_channel_log()
|
||||
{
|
||||
return &_log;
|
||||
}
|
||||
|
||||
static inline bool _is_pow2(size_t num)
|
||||
{
|
||||
while (num != 1) {
|
||||
if (num % 2 != 0)
|
||||
return false;
|
||||
num = num / 2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void core_channel_init(core_channel_t* self, size_t capacity)
|
||||
{
|
||||
mlassert_self();
|
||||
if (capacity < 4 || !_is_pow2(capacity)) {
|
||||
mlfatal("invalid capacity");
|
||||
}
|
||||
|
||||
*self = _defaults;
|
||||
self->capacity = capacity;
|
||||
|
||||
lfatal_oom(self->ring_buf = malloc(sizeof(ck_ring_buffer_t) * capacity));
|
||||
ck_ring_init(&self->ring, capacity);
|
||||
}
|
||||
|
||||
void core_channel_destroy(core_channel_t* self)
|
||||
{
|
||||
mlassert_self();
|
||||
free(self->ring_buf);
|
||||
}
|
||||
|
||||
void core_channel_put(core_channel_t* self, const void* obj)
|
||||
{
|
||||
mlassert_self();
|
||||
lassert(self->ring_buf, "ring_buf is nil");
|
||||
|
||||
while (!ck_ring_enqueue_spsc(&self->ring, self->ring_buf, (void*)obj)) {
|
||||
sched_yield();
|
||||
}
|
||||
}
|
||||
|
||||
int core_channel_try_put(core_channel_t* self, const void* obj)
|
||||
{
|
||||
mlassert_self();
|
||||
lassert(self->ring_buf, "ring_buf is nil");
|
||||
|
||||
if (!ck_ring_enqueue_spsc(&self->ring, self->ring_buf, (void*)obj)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* core_channel_get(core_channel_t* self)
|
||||
{
|
||||
void* obj = 0;
|
||||
mlassert_self();
|
||||
lassert(self->ring_buf, "ring_buf is nil");
|
||||
|
||||
while (!ck_ring_dequeue_spsc(&self->ring, self->ring_buf, &obj)) {
|
||||
sched_yield();
|
||||
if (ck_pr_load_int(&self->closed)) {
|
||||
linfo("channel closed");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
void* core_channel_try_get(core_channel_t* self)
|
||||
{
|
||||
void* obj = 0;
|
||||
mlassert_self();
|
||||
lassert(self->ring_buf, "ring_buf is nil");
|
||||
|
||||
if (!ck_ring_dequeue_spsc(&self->ring, self->ring_buf, &obj)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
int core_channel_size(core_channel_t* self)
|
||||
{
|
||||
mlassert_self();
|
||||
return ck_ring_size(&self->ring);
|
||||
}
|
||||
|
||||
bool core_channel_full(core_channel_t* self)
|
||||
{
|
||||
mlassert_self();
|
||||
|
||||
/* ck_ring can only hold capacity minus one enties at a time */
|
||||
if (ck_ring_size(&self->ring) < (self->capacity - 1)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void core_channel_close(core_channel_t* self)
|
||||
{
|
||||
mlassert_self();
|
||||
ck_pr_store_int(&self->closed, 1);
|
||||
}
|
||||
|
||||
core_receiver_t core_channel_receiver()
|
||||
{
|
||||
return (core_receiver_t)core_channel_put;
|
||||
}
|
||||
|
||||
void core_channel_run(core_channel_t* self)
|
||||
{
|
||||
void* obj = 0;
|
||||
mlassert_self();
|
||||
lassert(self->ring_buf, "ring_buf is nil");
|
||||
if (!self->recv) {
|
||||
lfatal("no receiver set");
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
while (!ck_ring_dequeue_spsc(&self->ring, self->ring_buf, &obj)) {
|
||||
sched_yield();
|
||||
if (ck_pr_load_int(&self->closed)) {
|
||||
linfo("channel closed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
self->recv(self->ctx, obj);
|
||||
}
|
||||
}
|
41
include/dnsjit/core/channel.h
Normal file
41
include/dnsjit/core/channel.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/log.h>
|
||||
#include <dnsjit/core/receiver.h>
|
||||
|
||||
#ifndef __dnsjit_core_channel_h
|
||||
#define __dnsjit_core_channel_h
|
||||
|
||||
#if defined(__GNUC__) || defined(__SUNPRO_C)
|
||||
#include "gcc/ck_cc.h"
|
||||
#ifdef CK_CC_RESTRICT
|
||||
#undef CK_CC_RESTRICT
|
||||
#define CK_CC_RESTRICT __restrict__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <ck_ring.h>
|
||||
#include <ck_pr.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <dnsjit/core/channel.hh>
|
||||
|
||||
#endif
|
49
include/dnsjit/core/channel.hh
Normal file
49
include/dnsjit/core/channel.hh
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.compat_h")
|
||||
//lua:require("dnsjit.core.log")
|
||||
//lua:require("dnsjit.core.receiver_h")
|
||||
|
||||
typedef struct core_channel {
|
||||
core_log_t _log;
|
||||
ck_ring_buffer_t* ring_buf;
|
||||
ck_ring_t ring;
|
||||
int closed;
|
||||
size_t capacity;
|
||||
|
||||
core_receiver_t recv;
|
||||
void* ctx;
|
||||
} core_channel_t;
|
||||
|
||||
core_log_t* core_channel_log();
|
||||
|
||||
void core_channel_init(core_channel_t* self, size_t capacity);
|
||||
void core_channel_destroy(core_channel_t* self);
|
||||
void core_channel_put(core_channel_t* self, const void* obj);
|
||||
int core_channel_try_put(core_channel_t* self, const void* obj);
|
||||
void* core_channel_get(core_channel_t* self);
|
||||
void* core_channel_try_get(core_channel_t* self);
|
||||
int core_channel_size(core_channel_t* self);
|
||||
bool core_channel_full(core_channel_t* self);
|
||||
void core_channel_close(core_channel_t* self);
|
||||
|
||||
core_receiver_t core_channel_receiver();
|
||||
void core_channel_run(core_channel_t* self);
|
142
include/dnsjit/core/channel.lua
Normal file
142
include/dnsjit/core/channel.lua
Normal file
|
@ -0,0 +1,142 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.channel
|
||||
-- Send data to another thread
|
||||
-- local chan = require("dnsjit.core.channel").new()
|
||||
-- local thr = require("dnsjit.core.thread").new()
|
||||
-- thr:start(function(thr)
|
||||
-- local chan = thr:pop()
|
||||
-- local obj = chan:get()
|
||||
-- ...
|
||||
-- end)
|
||||
-- thr:push(chan)
|
||||
-- chan:put(...)
|
||||
-- chan:close()
|
||||
-- thr:stop()
|
||||
--
|
||||
-- A channel can be used to send data to another thread, this is done by
|
||||
-- putting a pointer to the data into a wait-free and lock-free ring buffer
|
||||
-- (concurrency kit).
|
||||
-- The channel uses the single producer, single consumer model (SPSC) so
|
||||
-- there can only be one writer and one reader.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- int closed
|
||||
-- Is 1 if the channel has been closed.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.channel_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local t_name = "core_channel_t"
|
||||
local core_channel_t
|
||||
local Channel = {}
|
||||
|
||||
-- Create a new Channel, use the optional
|
||||
-- .I capacity
|
||||
-- to specify the capacity of the channel (buffer).
|
||||
-- Capacity must be a power-of-two greater than or equal to 4.
|
||||
-- Default capacity is 2048.
|
||||
function Channel.new(capacity)
|
||||
if capacity == nil then
|
||||
capacity = 2048
|
||||
end
|
||||
local self = core_channel_t()
|
||||
C.core_channel_init(self, capacity)
|
||||
ffi.gc(self, C.core_channel_destroy)
|
||||
return self
|
||||
end
|
||||
|
||||
-- Return the Log object to control logging of this instance or module.
|
||||
function Channel:log()
|
||||
if self == nil then
|
||||
return C.core_channel_log()
|
||||
end
|
||||
return self._log
|
||||
end
|
||||
|
||||
-- Return information to use when sharing this object between threads.
|
||||
function Channel:share()
|
||||
return ffi.cast("void*", self), t_name.."*", "dnsjit.core.channel"
|
||||
end
|
||||
|
||||
-- Put an object into the channel, if the channel is full then it will
|
||||
-- stall and wait until space becomes available.
|
||||
-- Object may be nil.
|
||||
function Channel:put(obj)
|
||||
C.core_channel_put(self, obj)
|
||||
end
|
||||
|
||||
-- Try and put an object into the channel.
|
||||
-- Returns 0 on success.
|
||||
function Channel:put(obj)
|
||||
C.core_channel_try_put(self, obj)
|
||||
end
|
||||
|
||||
-- Get an object from the channel, if the channel is empty it will wait until
|
||||
-- an object is available.
|
||||
-- Returns nil if the channel is closed or if a nil object was explicitly put
|
||||
-- into the channel.
|
||||
function Channel:get()
|
||||
return C.core_channel_get(self)
|
||||
end
|
||||
|
||||
-- Try and get an object from the channel.
|
||||
-- Returns nil if there was no objects to get.
|
||||
function Channel:try_get()
|
||||
return C.core_channel_try_get(self)
|
||||
end
|
||||
|
||||
-- Return number of enqueued objects.
|
||||
function Channel:size()
|
||||
return C.core_channel_size(self)
|
||||
end
|
||||
|
||||
-- Returns true when channel is full.
|
||||
function Channel:full()
|
||||
return C.core_channel_full(self)
|
||||
end
|
||||
|
||||
-- Close the channel.
|
||||
function Channel:close()
|
||||
C.core_channel_close(self)
|
||||
end
|
||||
|
||||
-- Return the C functions and context for receiving objects.
|
||||
function Channel:receive()
|
||||
return C.core_channel_receiver(), self
|
||||
end
|
||||
|
||||
-- Set the receiver to pass objects to.
|
||||
-- NOTE; The channel keeps no reference of the receiver, it needs to live as
|
||||
-- long as the channel does.
|
||||
function Channel:receiver(o)
|
||||
self.recv, self.ctx = o:receive()
|
||||
end
|
||||
|
||||
-- Retrieve all objects from the channel and send it to the receiver.
|
||||
function Channel:run()
|
||||
C.core_channel_run(self)
|
||||
end
|
||||
|
||||
core_channel_t = ffi.metatype(t_name, { __index = Channel })
|
||||
|
||||
-- dnsjit.core.thread (3)
|
||||
return Channel
|
25
include/dnsjit/core/compat.c
Normal file
25
include/dnsjit/core/compat.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "core/compat.hh"
|
32
include/dnsjit/core/compat.h
Normal file
32
include/dnsjit/core/compat.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __dnsjit_core_compat_h
|
||||
#define __dnsjit_core_compat_h
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __ssize_t_defined
|
||||
typedef ssize_t luajit_ssize_t;
|
||||
#else
|
||||
typedef long luajit_ssize_t;
|
||||
#endif
|
||||
|
||||
#endif
|
41
include/dnsjit/core/compat.lua
Normal file
41
include/dnsjit/core/compat.lua
Normal file
|
@ -0,0 +1,41 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.compat
|
||||
-- Cross platform compatibility support
|
||||
-- require("dnsjit.core.compat_h")
|
||||
--
|
||||
-- This module defines various system structures so they can be exposed into
|
||||
-- Lua but not really used. The size is generated at compile time to match
|
||||
-- that of the structures on the platform.
|
||||
-- .SS Structures
|
||||
-- .TP
|
||||
-- pthread_t
|
||||
-- .TP
|
||||
-- pthread_cond_t
|
||||
-- .TP
|
||||
-- pthread_mutex_t
|
||||
-- .TP
|
||||
-- struct sockaddr_storage
|
||||
-- .TP
|
||||
-- ck_ring_t
|
||||
-- .TP
|
||||
-- ck_ring_buffer_t
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.compat_h")
|
37
include/dnsjit/core/file.c
Normal file
37
include/dnsjit/core/file.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/file.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int core_file_exists(const char* filename)
|
||||
{
|
||||
struct stat s;
|
||||
|
||||
if (stat(filename, &s)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
26
include/dnsjit/core/file.h
Normal file
26
include/dnsjit/core/file.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __dnsjit_core_file_h
|
||||
#define __dnsjit_core_file_h
|
||||
|
||||
#include <dnsjit/core/file.hh>
|
||||
|
||||
#endif
|
21
include/dnsjit/core/file.hh
Normal file
21
include/dnsjit/core/file.hh
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
int core_file_exists(const char*);
|
37
include/dnsjit/core/file.lua
Normal file
37
include/dnsjit/core/file.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.file
|
||||
-- OS file operations
|
||||
-- require("dnsjit.core.file")
|
||||
-- local ffi = require("ffi")
|
||||
-- if ffi.C.core_file_exists("path/file") == 0 then
|
||||
-- ...
|
||||
-- end
|
||||
--
|
||||
-- Module that exposes some file operations that are missing from Lua.
|
||||
-- .SS C functions
|
||||
-- .TP
|
||||
-- core_file_exists(path/filename)
|
||||
-- Function that takes a string and uses
|
||||
-- .B stat()
|
||||
-- to check if that path/filename exists.
|
||||
-- Returns zero if it exists.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.file_h")
|
68
include/dnsjit/core/loader.lua
Normal file
68
include/dnsjit/core/loader.lua
Normal file
|
@ -0,0 +1,68 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.loader
|
||||
-- Dynamic library loader
|
||||
-- local loader = require("dnsjit.core.loader")
|
||||
-- loader.load("example-input-zero/zero")
|
||||
--
|
||||
-- Module for loading dynamic libraries (.so) in more ways then LuaJIT can.
|
||||
-- This is mainly used in external modules.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.file")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local Loader = {}
|
||||
|
||||
-- Search
|
||||
-- .B package.cpath
|
||||
-- for the given name and load the first found.
|
||||
-- If
|
||||
-- .B global
|
||||
-- is true (default true if not given) then the loaded symbols will also
|
||||
-- be available globally.
|
||||
-- Returns the loaded C library as per
|
||||
-- .BR ffi.load() .
|
||||
-- .br
|
||||
-- The
|
||||
-- .B ?
|
||||
-- in each path of
|
||||
-- .B package.cpath
|
||||
-- will be replace by the given name, so usually the ".so" part of the
|
||||
-- library does not need to be given.
|
||||
-- See
|
||||
-- .I package.cpath
|
||||
-- and
|
||||
-- .I package.loaders
|
||||
-- in Lua 5.1 for more information.
|
||||
function Loader.load(name, global)
|
||||
if global ~= false then
|
||||
global = true
|
||||
end
|
||||
for path in string.gmatch(package.cpath, "[^;]+") do
|
||||
path = path:gsub("?", name)
|
||||
if C.core_file_exists(path) == 0 then
|
||||
return ffi.load(path, global)
|
||||
end
|
||||
end
|
||||
return ffi.load(name)
|
||||
end
|
||||
|
||||
return Loader
|
399
include/dnsjit/core/log.c
Normal file
399
include/dnsjit/core/log.c
Normal file
|
@ -0,0 +1,399 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static core_log_t _log = LOG_T_INIT("core");
|
||||
|
||||
void core_log_debug(const core_log_t* l, const char* file, size_t line, const char* msg, ...)
|
||||
{
|
||||
char buf[512];
|
||||
va_list ap;
|
||||
if (!l) {
|
||||
if (_log.settings.debug != 3) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (l->settings.debug) {
|
||||
if (l->settings.debug != 3) {
|
||||
return;
|
||||
}
|
||||
} else if (l->module && l->module->debug) {
|
||||
if (l->module->debug != 3) {
|
||||
return;
|
||||
}
|
||||
} else if (_log.settings.debug != 3) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
va_start(ap, msg);
|
||||
vsnprintf(buf, sizeof(buf), msg, ap);
|
||||
va_end(ap);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
for (;;) {
|
||||
if (!l) {
|
||||
if (_log.settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (l->settings.display_file_line) {
|
||||
if (l->settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else if (l->module && l->module->display_file_line) {
|
||||
if (l->module->display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else if (_log.settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (l) {
|
||||
if (l->is_obj) {
|
||||
fprintf(stderr, "%s[%zu] %s[%p] debug: %s\n", file, line, l->name, l, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s[%zu] %s debug: %s\n", file, line, l->name, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s[%zu] %s debug: %s\n", file, line, _log.name, buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (l) {
|
||||
if (l->is_obj) {
|
||||
fprintf(stderr, "%s[%p] debug: %s\n", l->name, l, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s debug: %s\n", l->name, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s debug: %s\n", _log.name, buf);
|
||||
}
|
||||
|
||||
void core_log_info(const core_log_t* l, const char* file, size_t line, const char* msg, ...)
|
||||
{
|
||||
char buf[512];
|
||||
va_list ap;
|
||||
if (!l) {
|
||||
if (_log.settings.info != 3) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (l->settings.info) {
|
||||
if (l->settings.info != 3) {
|
||||
return;
|
||||
}
|
||||
} else if (l->module && l->module->info) {
|
||||
if (l->module->info != 3) {
|
||||
return;
|
||||
}
|
||||
} else if (_log.settings.info != 3) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
va_start(ap, msg);
|
||||
vsnprintf(buf, sizeof(buf), msg, ap);
|
||||
va_end(ap);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
for (;;) {
|
||||
if (!l) {
|
||||
if (_log.settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (l->settings.display_file_line) {
|
||||
if (l->settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else if (l->module && l->module->display_file_line) {
|
||||
if (l->module->display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else if (_log.settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (l) {
|
||||
if (l->is_obj) {
|
||||
fprintf(stderr, "%s[%zu] %s[%p] info: %s\n", file, line, l->name, l, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s[%zu] %s info: %s\n", file, line, l->name, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s[%zu] %s info: %s\n", file, line, _log.name, buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (l) {
|
||||
if (l->is_obj) {
|
||||
fprintf(stderr, "%s[%p] info: %s\n", l->name, l, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s info: %s\n", l->name, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s info: %s\n", _log.name, buf);
|
||||
}
|
||||
|
||||
void core_log_notice(const core_log_t* l, const char* file, size_t line, const char* msg, ...)
|
||||
{
|
||||
char buf[512];
|
||||
va_list ap;
|
||||
if (!l) {
|
||||
if (_log.settings.notice != 3) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (l->settings.notice) {
|
||||
if (l->settings.notice != 3) {
|
||||
return;
|
||||
}
|
||||
} else if (l->module && l->module->notice) {
|
||||
if (l->module->notice != 3) {
|
||||
return;
|
||||
}
|
||||
} else if (_log.settings.notice != 3) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
va_start(ap, msg);
|
||||
vsnprintf(buf, sizeof(buf), msg, ap);
|
||||
va_end(ap);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
for (;;) {
|
||||
if (!l) {
|
||||
if (_log.settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (l->settings.display_file_line) {
|
||||
if (l->settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else if (l->module && l->module->display_file_line) {
|
||||
if (l->module->display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else if (_log.settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (l) {
|
||||
if (l->is_obj) {
|
||||
fprintf(stderr, "%s[%zu] %s[%p] notice: %s\n", file, line, l->name, l, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s[%zu] %s notice: %s\n", file, line, l->name, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s[%zu] %s notice: %s\n", file, line, _log.name, buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (l) {
|
||||
if (l->is_obj) {
|
||||
fprintf(stderr, "%s[%p] notice: %s\n", l->name, l, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s notice: %s\n", l->name, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s notice: %s\n", _log.name, buf);
|
||||
}
|
||||
|
||||
void core_log_warning(const core_log_t* l, const char* file, size_t line, const char* msg, ...)
|
||||
{
|
||||
char buf[512];
|
||||
va_list ap;
|
||||
if (!l) {
|
||||
if (_log.settings.warning != 3) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (l->settings.warning) {
|
||||
if (l->settings.warning != 3) {
|
||||
return;
|
||||
}
|
||||
} else if (l->module && l->module->warning) {
|
||||
if (l->module->warning != 3) {
|
||||
return;
|
||||
}
|
||||
} else if (_log.settings.warning != 3) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
va_start(ap, msg);
|
||||
vsnprintf(buf, sizeof(buf), msg, ap);
|
||||
va_end(ap);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
for (;;) {
|
||||
if (!l) {
|
||||
if (_log.settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (l->settings.display_file_line) {
|
||||
if (l->settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else if (l->module && l->module->display_file_line) {
|
||||
if (l->module->display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else if (_log.settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (l) {
|
||||
if (l->is_obj) {
|
||||
fprintf(stderr, "%s[%zu] %s[%p] warning: %s\n", file, line, l->name, l, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s[%zu] %s warning: %s\n", file, line, l->name, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s[%zu] %s warning: %s\n", file, line, _log.name, buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (l) {
|
||||
if (l->is_obj) {
|
||||
fprintf(stderr, "%s[%p] warning: %s\n", l->name, l, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s warning: %s\n", l->name, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s warning: %s\n", _log.name, buf);
|
||||
}
|
||||
|
||||
void core_log_critical(const core_log_t* l, const char* file, size_t line, const char* msg, ...)
|
||||
{
|
||||
char buf[512];
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
vsnprintf(buf, sizeof(buf), msg, ap);
|
||||
va_end(ap);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
for (;;) {
|
||||
if (!l) {
|
||||
if (_log.settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (l->settings.display_file_line) {
|
||||
if (l->settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else if (l->module && l->module->display_file_line) {
|
||||
if (l->module->display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else if (_log.settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (l) {
|
||||
if (l->is_obj) {
|
||||
fprintf(stderr, "%s[%zu] %s[%p] critical: %s\n", file, line, l->name, l, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s[%zu] %s critical: %s\n", file, line, l->name, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s[%zu] %s critical: %s\n", file, line, _log.name, buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (l) {
|
||||
if (l->is_obj) {
|
||||
fprintf(stderr, "%s[%p] critical: %s\n", l->name, l, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s critical: %s\n", l->name, buf);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "%s critical: %s\n", _log.name, buf);
|
||||
}
|
||||
|
||||
void core_log_fatal(const core_log_t* l, const char* file, size_t line, const char* msg, ...)
|
||||
{
|
||||
char buf[512];
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
vsnprintf(buf, sizeof(buf), msg, ap);
|
||||
va_end(ap);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
for (;;) {
|
||||
if (!l) {
|
||||
if (_log.settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (l->settings.display_file_line) {
|
||||
if (l->settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else if (l->module && l->module->display_file_line) {
|
||||
if (l->module->display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
} else if (_log.settings.display_file_line != 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (l) {
|
||||
if (l->is_obj) {
|
||||
fprintf(stderr, "%s[%zu] %s[%p] fatal: %s\n", file, line, l->name, l, buf);
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "%s[%zu] %s fatal: %s\n", file, line, l->name, buf);
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "%s[%zu] %s fatal: %s\n", file, line, _log.name, buf);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (l) {
|
||||
if (l->is_obj) {
|
||||
fprintf(stderr, "%s[%p] fatal: %s\n", l->name, l, buf);
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "%s fatal: %s\n", l->name, buf);
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "%s fatal: %s\n", _log.name, buf);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
core_log_t* core_log_log()
|
||||
{
|
||||
return &_log;
|
||||
}
|
||||
|
||||
#include "core/log_errstr.c"
|
105
include/dnsjit/core/log.h
Normal file
105
include/dnsjit/core/log.h
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __dnsjit_core_log_h
|
||||
#define __dnsjit_core_log_h
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define LOG_SETTINGS_T_INIT \
|
||||
{ \
|
||||
0, 0, 0, 0, 0 \
|
||||
}
|
||||
#define LOG_T_INIT(name) \
|
||||
{ \
|
||||
name, 0, LOG_SETTINGS_T_INIT, 0 \
|
||||
}
|
||||
#define LOG_T_INIT_OBJ(name) \
|
||||
{ \
|
||||
name, 1, LOG_SETTINGS_T_INIT, &_log.settings \
|
||||
}
|
||||
|
||||
#include <dnsjit/core/log.hh>
|
||||
|
||||
#ifdef DNSJIT_NO_LOGGING
|
||||
#define ldebug(msg...)
|
||||
#define linfo(msg...)
|
||||
#define lnotice(msg...)
|
||||
#define lwarning(msg...)
|
||||
#define lcritical(msg...)
|
||||
#define lpdebug(msg...)
|
||||
#define lpinfo(msg...)
|
||||
#define lpnotice(msg...)
|
||||
#define lpwarning(msg...)
|
||||
#define lpcritical(msg...)
|
||||
#define mldebug(msg...)
|
||||
#define mlinfo(msg...)
|
||||
#define mlnotice(msg...)
|
||||
#define mlwarning(msg...)
|
||||
#define mlcritical(msg...)
|
||||
#define gldebug(msg...)
|
||||
#define glinfo(msg...)
|
||||
#define glnotice(msg...)
|
||||
#define glwarning(msg...)
|
||||
#define glcritical(msg...)
|
||||
#else
|
||||
#define ldebug(msg...) core_log_debug(&self->_log, __FILE__, __LINE__, msg)
|
||||
#define linfo(msg...) core_log_info(&self->_log, __FILE__, __LINE__, msg)
|
||||
#define lnotice(msg...) core_log_notice(&self->_log, __FILE__, __LINE__, msg)
|
||||
#define lwarning(msg...) core_log_warning(&self->_log, __FILE__, __LINE__, msg)
|
||||
#define lcritical(msg...) core_log_critical(&self->_log, __FILE__, __LINE__, msg)
|
||||
#define lpdebug(msg...) core_log_debug(self->_log, __FILE__, __LINE__, msg)
|
||||
#define lpinfo(msg...) core_log_info(self->_log, __FILE__, __LINE__, msg)
|
||||
#define lpnotice(msg...) core_log_notice(self->_log, __FILE__, __LINE__, msg)
|
||||
#define lpwarning(msg...) core_log_warning(self->_log, __FILE__, __LINE__, msg)
|
||||
#define lpcritical(msg...) core_log_critical(self->_log, __FILE__, __LINE__, msg)
|
||||
#define mldebug(msg...) core_log_debug(&_log, __FILE__, __LINE__, msg)
|
||||
#define mlinfo(msg...) core_log_info(&_log, __FILE__, __LINE__, msg)
|
||||
#define mlnotice(msg...) core_log_notice(&_log, __FILE__, __LINE__, msg)
|
||||
#define mlwarning(msg...) core_log_warning(&_log, __FILE__, __LINE__, msg)
|
||||
#define mlcritical(msg...) core_log_critical(&_log, __FILE__, __LINE__, msg)
|
||||
#define gldebug(msg...) core_log_debug(0, __FILE__, __LINE__, msg)
|
||||
#define glinfo(msg...) core_log_info(0, __FILE__, __LINE__, msg)
|
||||
#define glnotice(msg...) core_log_notice(0, __FILE__, __LINE__, msg)
|
||||
#define glwarning(msg...) core_log_warning(0, __FILE__, __LINE__, msg)
|
||||
#define glcritical(msg...) core_log_critical(0, __FILE__, __LINE__, msg)
|
||||
#endif
|
||||
|
||||
#define lfatal(msg...) core_log_fatal(&self->_log, __FILE__, __LINE__, msg)
|
||||
#define lpfatal(msg...) core_log_fatal(self->_log, __FILE__, __LINE__, msg)
|
||||
#define mlfatal(msg...) core_log_fatal(&_log, __FILE__, __LINE__, msg)
|
||||
#define glfatal(msg...) core_log_fatal(0, __FILE__, __LINE__, msg)
|
||||
|
||||
#define lfatal_oom(expression) \
|
||||
if (!(expression)) \
|
||||
core_log_fatal(&self->_log, __FILE__, __LINE__, "out of memory")
|
||||
#define lpfatal_oom(expression) \
|
||||
if (!(expression)) \
|
||||
core_log_fatal(self->_log, __FILE__, __LINE__, "out of memory")
|
||||
#define mlfatal_oom(expression) \
|
||||
if (!(expression)) \
|
||||
core_log_fatal(&_log, __FILE__, __LINE__, "out of memory")
|
||||
#define glfatal_oom(expression) \
|
||||
if (!(expression)) \
|
||||
core_log_fatal(0, __FILE__, __LINE__, "out of memory")
|
||||
|
||||
#endif
|
44
include/dnsjit/core/log.hh
Normal file
44
include/dnsjit/core/log.hh
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
typedef struct core_log_settings {
|
||||
uint8_t debug;
|
||||
uint8_t info;
|
||||
uint8_t notice;
|
||||
uint8_t warning;
|
||||
uint8_t display_file_line;
|
||||
} core_log_settings_t;
|
||||
|
||||
typedef struct core_log {
|
||||
char name[32];
|
||||
uint8_t is_obj;
|
||||
core_log_settings_t settings;
|
||||
const core_log_settings_t* module;
|
||||
} core_log_t;
|
||||
|
||||
void core_log_debug(const core_log_t* l, const char* file, size_t line, const char* msg, ...);
|
||||
void core_log_info(const core_log_t* l, const char* file, size_t line, const char* msg, ...);
|
||||
void core_log_notice(const core_log_t* l, const char* file, size_t line, const char* msg, ...);
|
||||
void core_log_warning(const core_log_t* l, const char* file, size_t line, const char* msg, ...);
|
||||
void core_log_critical(const core_log_t* l, const char* file, size_t line, const char* msg, ...);
|
||||
void core_log_fatal(const core_log_t* l, const char* file, size_t line, const char* msg, ...);
|
||||
const char* core_log_errstr(int err);
|
||||
|
||||
core_log_t* core_log_log();
|
639
include/dnsjit/core/log.lua
Normal file
639
include/dnsjit/core/log.lua
Normal file
|
@ -0,0 +1,639 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.log
|
||||
-- Core logging facility
|
||||
-- .SS Usage to control global log level
|
||||
-- local log = require("dnsjit.core.log")
|
||||
-- log.enable("all")
|
||||
-- log.disable("debug")
|
||||
-- .SS Usage to control module log level
|
||||
-- local example = require("example") -- Example as below
|
||||
-- example.log():enable("all")
|
||||
-- example.log():disable("debug")
|
||||
-- .SS Usage to control object instance log level
|
||||
-- local example = require("example") -- Example as below
|
||||
-- local obj = example.new()
|
||||
-- obj:log():enable("all")
|
||||
-- obj:log():disable("debug")
|
||||
-- .SS Usage in C module
|
||||
-- .B NOTE
|
||||
-- naming of variables and module only globals are required to exactly as
|
||||
-- described in order for the macros to work;
|
||||
-- .B self
|
||||
-- is the pointer to the object instance,
|
||||
-- .B self->_log
|
||||
-- is the object instance logging configuration struct,
|
||||
-- .B _log
|
||||
-- is the module logging configuration struct.
|
||||
-- .LP
|
||||
-- Include logging:
|
||||
-- #include "core/log.h"
|
||||
-- .LP
|
||||
-- Add the logging struct to the module struct:
|
||||
-- typedef struct example {
|
||||
-- core_log_t _log;
|
||||
-- ...
|
||||
-- } example_t;
|
||||
-- .LP
|
||||
-- Add a module logging configuration and a struct default:
|
||||
-- static core_log_t _log = LOG_T_INIT("example");
|
||||
-- static example_t _defaults = {
|
||||
-- LOG_T_INIT_OBJ("example"),
|
||||
-- ...
|
||||
-- };
|
||||
-- .LP
|
||||
-- Use new/free and/or init/destroy functions (depends if you create the
|
||||
-- object in Lua or not):
|
||||
-- example_t* example_new() {
|
||||
-- example_t* self = calloc(1, sizeof(example_t));
|
||||
-- .
|
||||
-- *self = _defaults;
|
||||
-- ldebug("new()");
|
||||
-- .
|
||||
-- return self;
|
||||
-- }
|
||||
-- .
|
||||
-- void example_free(example_t* self) {
|
||||
-- ldebug("free()");
|
||||
-- free(self);
|
||||
-- }
|
||||
-- .
|
||||
-- int example_init(example_t* self) {
|
||||
-- *self = _defaults;
|
||||
-- .
|
||||
-- ldebug("init()");
|
||||
-- .
|
||||
-- return 0;
|
||||
-- }
|
||||
-- .
|
||||
-- void example_destroy(example_t* self) {
|
||||
-- ldebug("destroy()");
|
||||
-- ...
|
||||
-- }
|
||||
-- .LP
|
||||
-- In the Lua part of the C module you need to create a function that
|
||||
-- returns either the object instance Log or the modules Log.
|
||||
-- .LP
|
||||
-- Add C function to get module only Log:
|
||||
-- core_log_t* example_log() {
|
||||
-- return &_log;
|
||||
-- }
|
||||
-- .LP
|
||||
-- For the structures metatable add the following function:
|
||||
-- local ffi = require("ffi")
|
||||
-- local C = ffi.C
|
||||
-- .
|
||||
-- function Example:log()
|
||||
-- if self == nil then
|
||||
-- return C.example_log()
|
||||
-- end
|
||||
-- return self._log
|
||||
-- end
|
||||
-- .SS Usage in pure Lua module
|
||||
-- local log = require("dnsjit.core.log")
|
||||
-- local ffi = require("ffi")
|
||||
-- local C = ffi.C
|
||||
-- .
|
||||
-- local Example = {}
|
||||
-- local module_log = log.new("example")
|
||||
-- .
|
||||
-- function Example.new()
|
||||
-- local self = setmetatable({
|
||||
-- _log = log.new("example", module_log),
|
||||
-- }, { __index = Example })
|
||||
-- .
|
||||
-- self._log:debug("new()")
|
||||
-- .
|
||||
-- return self
|
||||
-- end
|
||||
-- .
|
||||
-- function Example:log()
|
||||
-- if self == nil then
|
||||
-- return module_log
|
||||
-- end
|
||||
-- return self._log
|
||||
-- end
|
||||
--
|
||||
-- Core logging facility used by all modules.
|
||||
-- .SS Log levels
|
||||
-- .TP
|
||||
-- all
|
||||
-- Keyword to enable/disable all changeable log levels.
|
||||
-- .TP
|
||||
-- debug
|
||||
-- Used for debug information.
|
||||
-- .TP
|
||||
-- info
|
||||
-- Used for informational processing messages.
|
||||
-- .TP
|
||||
-- notice
|
||||
-- Used for messages of that may have impact on processing.
|
||||
-- .TP
|
||||
-- warning
|
||||
-- Used for messages that has impact on processing.
|
||||
-- .TP
|
||||
-- critical
|
||||
-- Used for messages that have severe impact on processing, this level can
|
||||
-- not be disabled.
|
||||
-- .TP
|
||||
-- fatal
|
||||
-- Used to display a message before stopping all processing and existing,
|
||||
-- this level can not be disabled.
|
||||
-- .SS C macros
|
||||
-- .TP
|
||||
-- Object instance macros
|
||||
-- The following macros uses
|
||||
-- .IR &self->_log :
|
||||
-- .BR ldebug(msg...) ,
|
||||
-- .BR linfo(msg...) ,
|
||||
-- .BR lnotice(msg...) ,
|
||||
-- .BR lwarning(msg...) ,
|
||||
-- .BR lcritical(msg...) ,
|
||||
-- .BR lfatal(msg...) .
|
||||
-- .TP
|
||||
-- Object pointer instance macros
|
||||
-- The following macros uses
|
||||
-- .IR self->_log :
|
||||
-- .BR lpdebug(msg...) ,
|
||||
-- .BR lpinfo(msg...) ,
|
||||
-- .BR lpnotice(msg...) ,
|
||||
-- .BR lpwarning(msg...) ,
|
||||
-- .BR lpcritical(msg...) ,
|
||||
-- .BR lpfatal(msg...) .
|
||||
-- .TP
|
||||
-- Module macros
|
||||
-- The following macros uses
|
||||
-- .IR &_log :
|
||||
-- .BR mldebug(msg...) ,
|
||||
-- .BR mlinfo(msg...) ,
|
||||
-- .BR mlnotice(msg...) ,
|
||||
-- .BR mlwarning(msg...) ,
|
||||
-- .BR mlcritical(msg...) ,
|
||||
-- .BR mlfatal(msg...) .
|
||||
-- .TP
|
||||
-- Global macros
|
||||
-- The following macros uses the global logging configuration:
|
||||
-- .BR gldebug(msg...) ,
|
||||
-- .BR glinfo(msg...) ,
|
||||
-- .BR glnotice(msg...) ,
|
||||
-- .BR glwarning(msg...) ,
|
||||
-- .BR glcritical(msg...) ,
|
||||
-- .BR glfatal(msg...) .
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.log_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
local L = C.core_log_log()
|
||||
|
||||
local t_name = "core_log_t"
|
||||
local core_log_t
|
||||
local Log = {}
|
||||
|
||||
-- Create a new Log object with the given module
|
||||
-- .I name
|
||||
-- and an optional shared
|
||||
-- .I module
|
||||
-- Log object.
|
||||
function Log.new(name, module)
|
||||
local self
|
||||
if ffi.istype(t_name, module) then
|
||||
self = core_log_t({ is_obj = 1, module = module.settings })
|
||||
else
|
||||
self = core_log_t()
|
||||
end
|
||||
|
||||
local len = #name
|
||||
if len > 31 then
|
||||
len = 31
|
||||
end
|
||||
ffi.copy(self.name, name, len)
|
||||
self.name[len] = 0
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
-- Enable specified log level.
|
||||
function Log:enable(level)
|
||||
if not ffi.istype(t_name, self) then
|
||||
level = self
|
||||
self = L
|
||||
end
|
||||
if level == "all" then
|
||||
self.settings.debug = 3
|
||||
self.settings.info = 3
|
||||
self.settings.notice = 3
|
||||
self.settings.warning = 3
|
||||
elseif level == "debug" then
|
||||
self.settings.debug = 3
|
||||
elseif level == "info" then
|
||||
self.settings.info = 3
|
||||
elseif level == "notice" then
|
||||
self.settings.notice = 3
|
||||
elseif level == "warning" then
|
||||
self.settings.warning = 3
|
||||
else
|
||||
error("invalid log level: "..level)
|
||||
end
|
||||
end
|
||||
|
||||
-- Disable specified log level.
|
||||
function Log:disable(level)
|
||||
if not ffi.istype(t_name, self) then
|
||||
level = self
|
||||
self = L
|
||||
end
|
||||
if level == "all" then
|
||||
self.settings.debug = 2
|
||||
self.settings.info = 2
|
||||
self.settings.notice = 2
|
||||
self.settings.warning = 2
|
||||
elseif level == "debug" then
|
||||
self.settings.debug = 2
|
||||
elseif level == "info" then
|
||||
self.settings.info = 2
|
||||
elseif level == "notice" then
|
||||
self.settings.notice = 2
|
||||
elseif level == "warning" then
|
||||
self.settings.warning = 2
|
||||
else
|
||||
error("invalid log level: "..level)
|
||||
end
|
||||
end
|
||||
|
||||
-- Clear specified log level, which means it will revert back to default
|
||||
-- or inherited settings.
|
||||
function Log:clear(level)
|
||||
if not ffi.istype(t_name, self) then
|
||||
level = self
|
||||
self = L
|
||||
end
|
||||
if level == "all" then
|
||||
self.settings.debug = 0
|
||||
self.settings.info = 0
|
||||
self.settings.notice = 0
|
||||
self.settings.warning = 0
|
||||
elseif level == "debug" then
|
||||
self.settings.debug = 0
|
||||
elseif level == "info" then
|
||||
self.settings.info = 0
|
||||
elseif level == "notice" then
|
||||
self.settings.notice = 0
|
||||
elseif level == "warning" then
|
||||
self.settings.warning = 0
|
||||
else
|
||||
error("invalid log level: "..level)
|
||||
end
|
||||
end
|
||||
|
||||
-- Enable or disable the displaying of file and line for messages.
|
||||
function Log:display_file_line(bool)
|
||||
if not ffi.istype(t_name, self) then
|
||||
bool = self
|
||||
self = L
|
||||
end
|
||||
if bool == true then
|
||||
self.settings.display_file_line = 3
|
||||
else
|
||||
self.settings.display_file_line = 0
|
||||
end
|
||||
end
|
||||
|
||||
-- Convert error number to its text representation.
|
||||
function Log.errstr(errno)
|
||||
return ffi.string(C.core_log_errstr(errno))
|
||||
end
|
||||
|
||||
-- Generate a debug message.
|
||||
function Log.debug(self, ...)
|
||||
local format
|
||||
if not ffi.istype(t_name, self) then
|
||||
format = self
|
||||
self = nil
|
||||
end
|
||||
if not self then
|
||||
if L.settings.debug ~= 3 then
|
||||
return
|
||||
end
|
||||
else
|
||||
if self.settings.debug ~= 0 then
|
||||
if self.settings.debug ~= 3 then
|
||||
return
|
||||
end
|
||||
elseif self.module ~= nil and self.module.debug ~= 0 then
|
||||
if self.module.debug ~= 3 then
|
||||
return
|
||||
end
|
||||
elseif L.settings.debug ~= 3 then
|
||||
return
|
||||
end
|
||||
end
|
||||
while true do
|
||||
if not self then
|
||||
if L.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
else
|
||||
if self.settings.display_file_line ~= 0 then
|
||||
if self.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
elseif self.module ~= nil and self.module.display_file_line ~= 0 then
|
||||
if self.module.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
elseif L.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
end
|
||||
local info = debug.getinfo(2, "S")
|
||||
if format then
|
||||
C.core_log_debug(self, info.source, info.linedefined, format, ...)
|
||||
return
|
||||
end
|
||||
C.core_log_debug(self, info.source, info.linedefined, ...)
|
||||
return
|
||||
end
|
||||
|
||||
if format then
|
||||
C.core_log_debug(self, nil, 0, format, ...)
|
||||
return
|
||||
end
|
||||
C.core_log_debug(self, nil, 0, ...)
|
||||
end
|
||||
|
||||
-- Generate an info message.
|
||||
function Log.info(self, ...)
|
||||
local format
|
||||
if not ffi.istype(t_name, self) then
|
||||
format = self
|
||||
self = nil
|
||||
end
|
||||
if not self then
|
||||
if L.settings.info ~= 3 then
|
||||
return
|
||||
end
|
||||
else
|
||||
if self.settings.info ~= 0 then
|
||||
if self.settings.info ~= 3 then
|
||||
return
|
||||
end
|
||||
elseif self.module ~= nil and self.module.info ~= 0 then
|
||||
if self.module.info ~= 3 then
|
||||
return
|
||||
end
|
||||
elseif L.settings.info ~= 3 then
|
||||
return
|
||||
end
|
||||
end
|
||||
while true do
|
||||
if not self then
|
||||
if L.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
else
|
||||
if self.settings.display_file_line ~= 0 then
|
||||
if self.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
elseif self.module ~= nil and self.module.display_file_line ~= 0 then
|
||||
if self.module.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
elseif L.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
end
|
||||
local info = debug.getinfo(2, "S")
|
||||
if format then
|
||||
C.core_log_info(self, info.source, info.linedefined, format, ...)
|
||||
return
|
||||
end
|
||||
C.core_log_info(self, info.source, info.linedefined, ...)
|
||||
return
|
||||
end
|
||||
|
||||
if format then
|
||||
C.core_log_info(self, nil, 0, format, ...)
|
||||
return
|
||||
end
|
||||
C.core_log_info(self, nil, 0, ...)
|
||||
end
|
||||
|
||||
-- Generate a notice message.
|
||||
function Log.notice(self, ...)
|
||||
local format
|
||||
if not ffi.istype(t_name, self) then
|
||||
format = self
|
||||
self = nil
|
||||
end
|
||||
if not self then
|
||||
if L.settings.notice ~= 3 then
|
||||
return
|
||||
end
|
||||
else
|
||||
if self.settings.notice ~= 0 then
|
||||
if self.settings.notice ~= 3 then
|
||||
return
|
||||
end
|
||||
elseif self.module ~= nil and self.module.notice ~= 0 then
|
||||
if self.module.notice ~= 3 then
|
||||
return
|
||||
end
|
||||
elseif L.settings.notice ~= 3 then
|
||||
return
|
||||
end
|
||||
end
|
||||
while true do
|
||||
if not self then
|
||||
if L.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
else
|
||||
if self.settings.display_file_line ~= 0 then
|
||||
if self.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
elseif self.module ~= nil and self.module.display_file_line ~= 0 then
|
||||
if self.module.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
elseif L.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
end
|
||||
local info = debug.getinfo(2, "S")
|
||||
if format then
|
||||
C.core_log_notice(self, info.source, info.linedefined, format, ...)
|
||||
return
|
||||
end
|
||||
C.core_log_notice(self, info.source, info.linedefined, ...)
|
||||
return
|
||||
end
|
||||
|
||||
if format then
|
||||
C.core_log_notice(self, nil, 0, format, ...)
|
||||
return
|
||||
end
|
||||
C.core_log_notice(self, nil, 0, ...)
|
||||
end
|
||||
|
||||
-- Generate a warning message.
|
||||
function Log.warning(self, ...)
|
||||
local format
|
||||
if not ffi.istype(t_name, self) then
|
||||
format = self
|
||||
self = nil
|
||||
end
|
||||
if not self then
|
||||
if L.settings.warning ~= 3 then
|
||||
return
|
||||
end
|
||||
else
|
||||
if self.settings.warning ~= 0 then
|
||||
if self.settings.warning ~= 3 then
|
||||
return
|
||||
end
|
||||
elseif self.module ~= nil and self.module.warning ~= 0 then
|
||||
if self.module.warning ~= 3 then
|
||||
return
|
||||
end
|
||||
elseif L.settings.warning ~= 3 then
|
||||
return
|
||||
end
|
||||
end
|
||||
while true do
|
||||
if not self then
|
||||
if L.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
else
|
||||
if self.settings.display_file_line ~= 0 then
|
||||
if self.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
elseif self.module ~= nil and self.module.display_file_line ~= 0 then
|
||||
if self.module.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
elseif L.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
end
|
||||
local info = debug.getinfo(2, "S")
|
||||
if format then
|
||||
C.core_log_warning(self, info.source, info.linedefined, format, ...)
|
||||
return
|
||||
end
|
||||
C.core_log_warning(self, info.source, info.linedefined, ...)
|
||||
return
|
||||
end
|
||||
|
||||
if format then
|
||||
C.core_log_warning(self, nil, 0, format, ...)
|
||||
return
|
||||
end
|
||||
C.core_log_warning(self, nil, 0, ...)
|
||||
end
|
||||
|
||||
-- Generate a critical message.
|
||||
function Log.critical(self, ...)
|
||||
local format
|
||||
if not ffi.istype(t_name, self) then
|
||||
format = self
|
||||
self = nil
|
||||
end
|
||||
while true do
|
||||
if not self then
|
||||
if L.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
else
|
||||
if self.settings.display_file_line ~= 0 then
|
||||
if self.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
elseif self.module ~= nil and self.module.display_file_line ~= 0 then
|
||||
if self.module.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
elseif L.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
end
|
||||
local info = debug.getinfo(2, "S")
|
||||
if format then
|
||||
C.core_log_critical(self, info.source, info.linedefined, format, ...)
|
||||
return
|
||||
end
|
||||
C.core_log_critical(self, info.source, info.linedefined, ...)
|
||||
return
|
||||
end
|
||||
|
||||
if format then
|
||||
C.core_log_critical(self, nil, 0, format, ...)
|
||||
return
|
||||
end
|
||||
C.core_log_critical(self, nil, 0, ...)
|
||||
end
|
||||
|
||||
-- Generate a fatal message.
|
||||
function Log.fatal(self, ...)
|
||||
local format
|
||||
if not ffi.istype(t_name, self) then
|
||||
format = self
|
||||
self = nil
|
||||
end
|
||||
while true do
|
||||
if not self then
|
||||
if L.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
else
|
||||
if self.settings.display_file_line ~= 0 then
|
||||
if self.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
elseif self.module ~= nil and self.module.display_file_line ~= 0 then
|
||||
if self.module.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
elseif L.settings.display_file_line ~= 3 then
|
||||
break
|
||||
end
|
||||
end
|
||||
local info = debug.getinfo(2, "S")
|
||||
if format then
|
||||
C.core_log_fatal(self, info.source, info.linedefined, format, ...)
|
||||
return
|
||||
end
|
||||
C.core_log_fatal(self, info.source, info.linedefined, ...)
|
||||
return
|
||||
end
|
||||
|
||||
if format then
|
||||
C.core_log_fatal(self, nil, 0, format, ...)
|
||||
return
|
||||
end
|
||||
C.core_log_fatal(self, nil, 0, ...)
|
||||
end
|
||||
|
||||
core_log_t = ffi.metatype(t_name, { __index = Log })
|
||||
|
||||
return Log
|
135
include/dnsjit/core/object.c
Normal file
135
include/dnsjit/core/object.c
Normal file
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/object.h"
|
||||
#include "core/assert.h"
|
||||
#include "core/object/pcap.h"
|
||||
#include "core/object/ether.h"
|
||||
#include "core/object/null.h"
|
||||
#include "core/object/loop.h"
|
||||
#include "core/object/linuxsll.h"
|
||||
#include "core/object/ieee802.h"
|
||||
#include "core/object/gre.h"
|
||||
#include "core/object/ip.h"
|
||||
#include "core/object/ip6.h"
|
||||
#include "core/object/icmp.h"
|
||||
#include "core/object/icmp6.h"
|
||||
#include "core/object/udp.h"
|
||||
#include "core/object/tcp.h"
|
||||
#include "core/object/payload.h"
|
||||
#include "core/object/dns.h"
|
||||
|
||||
core_object_t* core_object_copy(const core_object_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
|
||||
switch (self->obj_type) {
|
||||
case CORE_OBJECT_PCAP:
|
||||
return (core_object_t*)core_object_pcap_copy((core_object_pcap_t*)self);
|
||||
case CORE_OBJECT_ETHER:
|
||||
return (core_object_t*)core_object_ether_copy((core_object_ether_t*)self);
|
||||
case CORE_OBJECT_NULL:
|
||||
return (core_object_t*)core_object_null_copy((core_object_null_t*)self);
|
||||
case CORE_OBJECT_LOOP:
|
||||
return (core_object_t*)core_object_loop_copy((core_object_loop_t*)self);
|
||||
case CORE_OBJECT_LINUXSLL:
|
||||
return (core_object_t*)core_object_linuxsll_copy((core_object_linuxsll_t*)self);
|
||||
case CORE_OBJECT_IEEE802:
|
||||
return (core_object_t*)core_object_ieee802_copy((core_object_ieee802_t*)self);
|
||||
case CORE_OBJECT_GRE:
|
||||
return (core_object_t*)core_object_gre_copy((core_object_gre_t*)self);
|
||||
case CORE_OBJECT_IP:
|
||||
return (core_object_t*)core_object_ip_copy((core_object_ip_t*)self);
|
||||
case CORE_OBJECT_IP6:
|
||||
return (core_object_t*)core_object_ip6_copy((core_object_ip6_t*)self);
|
||||
case CORE_OBJECT_ICMP:
|
||||
return (core_object_t*)core_object_icmp_copy((core_object_icmp_t*)self);
|
||||
case CORE_OBJECT_ICMP6:
|
||||
return (core_object_t*)core_object_icmp6_copy((core_object_icmp6_t*)self);
|
||||
case CORE_OBJECT_UDP:
|
||||
return (core_object_t*)core_object_udp_copy((core_object_udp_t*)self);
|
||||
case CORE_OBJECT_TCP:
|
||||
return (core_object_t*)core_object_tcp_copy((core_object_tcp_t*)self);
|
||||
case CORE_OBJECT_PAYLOAD:
|
||||
return (core_object_t*)core_object_payload_copy((core_object_payload_t*)self);
|
||||
case CORE_OBJECT_DNS:
|
||||
return (core_object_t*)core_object_dns_copy((core_object_dns_t*)self);
|
||||
default:
|
||||
glfatal("unknown type %d", self->obj_type);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void core_object_free(core_object_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
|
||||
switch (self->obj_type) {
|
||||
case CORE_OBJECT_PCAP:
|
||||
core_object_pcap_free((core_object_pcap_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_ETHER:
|
||||
core_object_ether_free((core_object_ether_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_NULL:
|
||||
core_object_null_free((core_object_null_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_LOOP:
|
||||
core_object_loop_free((core_object_loop_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_LINUXSLL:
|
||||
core_object_linuxsll_free((core_object_linuxsll_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_IEEE802:
|
||||
core_object_ieee802_free((core_object_ieee802_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_GRE:
|
||||
core_object_gre_free((core_object_gre_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_IP:
|
||||
core_object_ip_free((core_object_ip_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_IP6:
|
||||
core_object_ip6_free((core_object_ip6_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_ICMP:
|
||||
core_object_icmp_free((core_object_icmp_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_ICMP6:
|
||||
core_object_icmp6_free((core_object_icmp6_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_UDP:
|
||||
core_object_udp_free((core_object_udp_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_TCP:
|
||||
core_object_tcp_free((core_object_tcp_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_PAYLOAD:
|
||||
core_object_payload_free((core_object_payload_t*)self);
|
||||
break;
|
||||
case CORE_OBJECT_DNS:
|
||||
core_object_dns_free((core_object_dns_t*)self);
|
||||
break;
|
||||
default:
|
||||
glfatal("unknown type %d", self->obj_type);
|
||||
}
|
||||
}
|
51
include/dnsjit/core/object.h
Normal file
51
include/dnsjit/core/object.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __dnsjit_core_object_h
|
||||
#define __dnsjit_core_object_h
|
||||
|
||||
#define CORE_OBJECT_NONE 0
|
||||
#define CORE_OBJECT_PCAP 1
|
||||
/* link level objects */
|
||||
#define CORE_OBJECT_ETHER 10
|
||||
#define CORE_OBJECT_NULL 11
|
||||
#define CORE_OBJECT_LOOP 12
|
||||
#define CORE_OBJECT_LINUXSLL 13
|
||||
#define CORE_OBJECT_IEEE802 14
|
||||
#define CORE_OBJECT_GRE 15
|
||||
/* protocol objects */
|
||||
#define CORE_OBJECT_IP 20
|
||||
#define CORE_OBJECT_IP6 21
|
||||
#define CORE_OBJECT_ICMP 22
|
||||
#define CORE_OBJECT_ICMP6 23
|
||||
/* payload carrying objects */
|
||||
#define CORE_OBJECT_UDP 30
|
||||
#define CORE_OBJECT_TCP 31
|
||||
/* payload */
|
||||
#define CORE_OBJECT_PAYLOAD 40
|
||||
/* service object(s) */
|
||||
#define CORE_OBJECT_DNS 50
|
||||
|
||||
#include <stdint.h>
|
||||
#include <dnsjit/core/object.hh>
|
||||
|
||||
#define CORE_OBJECT_INIT(type, prev) (core_object_t*)prev, type
|
||||
|
||||
#endif
|
28
include/dnsjit/core/object.hh
Normal file
28
include/dnsjit/core/object.hh
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 objectd a copy of the GNU General Public License
|
||||
* along with dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
typedef struct core_object core_object_t;
|
||||
struct core_object {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
};
|
||||
|
||||
core_object_t* core_object_copy(const core_object_t* self);
|
||||
void core_object_free(core_object_t* self);
|
177
include/dnsjit/core/object.lua
Normal file
177
include/dnsjit/core/object.lua
Normal file
|
@ -0,0 +1,177 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object
|
||||
-- Base object that is passed between receiver and receivee
|
||||
-- require("dnsjit.core.object")
|
||||
-- print(object:type())
|
||||
-- packet = object:cast()
|
||||
--
|
||||
-- This is the base object that can be casted to other objects that to
|
||||
-- describe a DNS message, how it was captured or generated.
|
||||
-- Objects can be chained together, for example a DNS message is created
|
||||
-- ontop of a packet.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- obj_type
|
||||
-- The enum of the object type.
|
||||
-- .TP
|
||||
-- obj_prev
|
||||
-- The previous object in the object chain.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object_h")
|
||||
require("dnsjit.core.object.pcap_h")
|
||||
require("dnsjit.core.object.ether_h")
|
||||
require("dnsjit.core.object.null_h")
|
||||
require("dnsjit.core.object.loop_h")
|
||||
require("dnsjit.core.object.linuxsll_h")
|
||||
require("dnsjit.core.object.ieee802_h")
|
||||
require("dnsjit.core.object.gre_h")
|
||||
require("dnsjit.core.object.ip_h")
|
||||
require("dnsjit.core.object.ip6_h")
|
||||
require("dnsjit.core.object.icmp_h")
|
||||
require("dnsjit.core.object.icmp6_h")
|
||||
require("dnsjit.core.object.udp_h")
|
||||
require("dnsjit.core.object.tcp_h")
|
||||
require("dnsjit.core.object.payload_h")
|
||||
require("dnsjit.core.object.dns_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local t_name = "core_object_t"
|
||||
local core_object_t
|
||||
local Object = {
|
||||
NONE = 0,
|
||||
PCAP = 1,
|
||||
ETHER = 10,
|
||||
NULL = 11,
|
||||
LOOP = 12,
|
||||
LINUXSLL = 13,
|
||||
IEEE802 = 14,
|
||||
GRE = 15,
|
||||
IP = 20,
|
||||
IP6 = 21,
|
||||
ICMP = 22,
|
||||
ICMP6 = 23,
|
||||
UDP = 30,
|
||||
TCP = 31,
|
||||
PAYLOAD = 40,
|
||||
DNS = 50
|
||||
}
|
||||
|
||||
local _type = {}
|
||||
_type[Object.PCAP] = "pcap"
|
||||
_type[Object.ETHER] = "ether"
|
||||
_type[Object.NULL] = "null"
|
||||
_type[Object.LOOP] = "loop"
|
||||
_type[Object.LINUXSLL] = "linuxsll"
|
||||
_type[Object.IEEE802] = "ieee802"
|
||||
_type[Object.GRE] = "gre"
|
||||
_type[Object.IP] = "ip"
|
||||
_type[Object.IP6] = "ip6"
|
||||
_type[Object.ICMP] = "icmp"
|
||||
_type[Object.ICMP6] = "icmp6"
|
||||
_type[Object.UDP] = "udp"
|
||||
_type[Object.TCP] = "tcp"
|
||||
_type[Object.PAYLOAD] = "payload"
|
||||
_type[Object.DNS] = "dns"
|
||||
|
||||
_type[Object.NONE] = "none"
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Object:type()
|
||||
return _type[self.obj_type]
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Object:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
local _cast = {}
|
||||
_cast[Object.PCAP] = "core_object_pcap_t*"
|
||||
_cast[Object.ETHER] = "core_object_ether_t*"
|
||||
_cast[Object.NULL] = "core_object_null_t*"
|
||||
_cast[Object.LOOP] = "core_object_loop_t*"
|
||||
_cast[Object.LINUXSLL] = "core_object_linuxsll_t*"
|
||||
_cast[Object.IEEE802] = "core_object_ieee802_t*"
|
||||
_cast[Object.GRE] = "core_object_gre_t*"
|
||||
_cast[Object.IP] = "core_object_ip_t*"
|
||||
_cast[Object.IP6] = "core_object_ip6_t*"
|
||||
_cast[Object.ICMP] = "core_object_icmp_t*"
|
||||
_cast[Object.ICMP6] = "core_object_icmp6_t*"
|
||||
_cast[Object.UDP] = "core_object_udp_t*"
|
||||
_cast[Object.TCP] = "core_object_tcp_t*"
|
||||
_cast[Object.PAYLOAD] = "core_object_payload_t*"
|
||||
_cast[Object.DNS] = "core_object_dns_t*"
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Object:cast()
|
||||
return ffi.cast(_cast[self.obj_type], self)
|
||||
end
|
||||
|
||||
-- Cast the object to the specified object module and return it.
|
||||
-- Returns nil if the object chain doesn't contained the specified object type.
|
||||
function Object:cast_to(obj_type)
|
||||
if obj_type == nil then
|
||||
obj_type = self.obj_type
|
||||
end
|
||||
|
||||
local obj = self
|
||||
while obj.obj_type ~= obj_type do
|
||||
obj = obj.obj_prev
|
||||
if obj == nil then return nil end
|
||||
end
|
||||
|
||||
return ffi.cast(_cast[obj_type], obj)
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Object:uncast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Object:copy()
|
||||
return C.core_object_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Object:free()
|
||||
C.core_object_free(self)
|
||||
end
|
||||
|
||||
core_object_t = ffi.metatype(t_name, { __index = Object })
|
||||
|
||||
-- dnsjit.core.object.pcap (3),
|
||||
-- dnsjit.core.object.ether (3),
|
||||
-- dnsjit.core.object.null (3),
|
||||
-- dnsjit.core.object.loop (3),
|
||||
-- dnsjit.core.object.linuxsll (3),
|
||||
-- dnsjit.core.object.ieee802 (3),
|
||||
-- dnsjit.core.object.gre (3),
|
||||
-- dnsjit.core.object.ip (3),
|
||||
-- dnsjit.core.object.ip6 (3),
|
||||
-- dnsjit.core.object.icmp (3),
|
||||
-- dnsjit.core.object.icmp6 (3),
|
||||
-- dnsjit.core.object.udp (3),
|
||||
-- dnsjit.core.object.tcp (3),
|
||||
-- dnsjit.core.object.payload (3),
|
||||
-- dnsjit.core.object.dns (3)
|
||||
return Object
|
471
include/dnsjit/core/object/dns.c
Normal file
471
include/dnsjit/core/object/dns.c
Normal file
|
@ -0,0 +1,471 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/object/dns.h"
|
||||
#include "core/object/payload.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_ENDIAN_H
|
||||
#include <endian.h>
|
||||
#else
|
||||
#ifdef HAVE_SYS_ENDIAN_H
|
||||
#include <sys/endian.h>
|
||||
#else
|
||||
#ifdef HAVE_MACHINE_ENDIAN_H
|
||||
#include <machine/endian.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HAVE_BYTESWAP_H
|
||||
#include <byteswap.h>
|
||||
#endif
|
||||
#ifndef bswap_16
|
||||
#ifndef bswap16
|
||||
#define bswap_16(x) swap16(x)
|
||||
#define bswap_32(x) swap32(x)
|
||||
#define bswap_64(x) swap64(x)
|
||||
#else
|
||||
#define bswap_16(x) bswap16(x)
|
||||
#define bswap_32(x) bswap32(x)
|
||||
#define bswap_64(x) bswap64(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _ERR_MALFORMED -2
|
||||
#define _ERR_NEEDLABELS -3
|
||||
|
||||
static core_log_t _log = LOG_T_INIT("core.object.dns");
|
||||
static core_object_dns_t _defaults = CORE_OBJECT_DNS_INIT(0);
|
||||
|
||||
static core_object_dns_label_t _defaults_label = { 0 };
|
||||
static core_object_dns_rr_t _defaults_rr = { 0 };
|
||||
static core_object_dns_q_t _defaults_q = { 0 };
|
||||
|
||||
core_log_t* core_object_dns_log()
|
||||
{
|
||||
return &_log;
|
||||
}
|
||||
|
||||
core_object_dns_t* core_object_dns_new()
|
||||
{
|
||||
core_object_dns_t* self;
|
||||
|
||||
mlfatal_oom(self = malloc(sizeof(core_object_dns_t)));
|
||||
*self = _defaults;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
core_object_dns_t* core_object_dns_copy(const core_object_dns_t* self)
|
||||
{
|
||||
core_object_dns_t* copy;
|
||||
mlassert_self();
|
||||
|
||||
mlfatal_oom(copy = malloc(sizeof(core_object_dns_t)));
|
||||
memcpy(copy, self, sizeof(core_object_dns_t));
|
||||
copy->obj_prev = 0;
|
||||
|
||||
return (core_object_dns_t*)copy;
|
||||
}
|
||||
|
||||
void core_object_dns_free(core_object_dns_t* self)
|
||||
{
|
||||
mlassert_self();
|
||||
free(self);
|
||||
}
|
||||
|
||||
#define need8(v, p, l) \
|
||||
if (l < 1) { \
|
||||
break; \
|
||||
} \
|
||||
v = *p; \
|
||||
p += 1; \
|
||||
l -= 1
|
||||
|
||||
static inline uint16_t _need16(const void* ptr)
|
||||
{
|
||||
uint16_t v;
|
||||
memcpy(&v, ptr, sizeof(v));
|
||||
return be16toh(v);
|
||||
}
|
||||
|
||||
#define need16(v, p, l) \
|
||||
if (l < 2) { \
|
||||
break; \
|
||||
} \
|
||||
v = _need16(p); \
|
||||
p += 2; \
|
||||
l -= 2
|
||||
|
||||
static inline uint32_t _need32(const void* ptr)
|
||||
{
|
||||
uint32_t v;
|
||||
memcpy(&v, ptr, sizeof(v));
|
||||
return be32toh(v);
|
||||
}
|
||||
|
||||
#define need32(v, p, l) \
|
||||
if (l < 4) { \
|
||||
break; \
|
||||
} \
|
||||
v = _need32(p); \
|
||||
p += 4; \
|
||||
l -= 4
|
||||
|
||||
#define needxb(b, x, p, l) \
|
||||
if (l < x) { \
|
||||
break; \
|
||||
} \
|
||||
memcpy(b, p, x); \
|
||||
p += x; \
|
||||
l -= x
|
||||
|
||||
#define advancexb(x, p, l) \
|
||||
if (l < x) { \
|
||||
break; \
|
||||
} \
|
||||
p += x; \
|
||||
l -= x
|
||||
|
||||
int core_object_dns_parse_header(core_object_dns_t* self)
|
||||
{
|
||||
const core_object_payload_t* payload;
|
||||
uint8_t byte;
|
||||
mlassert_self();
|
||||
|
||||
if (!(payload = (core_object_payload_t*)self->obj_prev) || payload->obj_type != CORE_OBJECT_PAYLOAD) {
|
||||
mlfatal("no obj_prev or invalid type");
|
||||
}
|
||||
if (!payload->payload || !payload->len) {
|
||||
mlfatal("no payload set or zero length");
|
||||
}
|
||||
|
||||
self->payload = self->at = payload->payload;
|
||||
self->len = self->left = payload->len;
|
||||
|
||||
for (;;) {
|
||||
if (self->includes_dnslen) {
|
||||
need16(self->dnslen, self->at, self->left);
|
||||
self->have_dnslen = 1;
|
||||
}
|
||||
need16(self->id, self->at, self->left);
|
||||
self->have_id = 1;
|
||||
|
||||
need8(byte, self->at, self->left);
|
||||
self->qr = byte & (1 << 7) ? 1 : 0;
|
||||
self->opcode = (byte >> 3) & 0xf;
|
||||
self->aa = byte & (1 << 2) ? 1 : 0;
|
||||
self->tc = byte & (1 << 1) ? 1 : 0;
|
||||
self->rd = byte & (1 << 0) ? 1 : 0;
|
||||
self->have_qr = self->have_opcode = self->have_aa = self->have_tc = self->have_rd = 1;
|
||||
|
||||
need8(byte, self->at, self->left);
|
||||
self->ra = byte & (1 << 7) ? 1 : 0;
|
||||
self->z = byte & (1 << 6) ? 1 : 0;
|
||||
self->ad = byte & (1 << 5) ? 1 : 0;
|
||||
self->cd = byte & (1 << 4) ? 1 : 0;
|
||||
self->rcode = byte & 0xf;
|
||||
self->have_ra = self->have_z = self->have_ad = self->have_cd = self->have_rcode = 1;
|
||||
|
||||
need16(self->qdcount, self->at, self->left);
|
||||
self->have_qdcount = 1;
|
||||
|
||||
need16(self->ancount, self->at, self->left);
|
||||
self->have_ancount = 1;
|
||||
|
||||
need16(self->nscount, self->at, self->left);
|
||||
self->have_nscount = 1;
|
||||
|
||||
need16(self->arcount, self->at, self->left);
|
||||
self->have_arcount = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO: error here on malformed/truncated? could be quite spammy
|
||||
return _ERR_MALFORMED;
|
||||
}
|
||||
|
||||
static inline size_t _rdata_labels(uint16_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case CORE_OBJECT_DNS_TYPE_NS:
|
||||
case CORE_OBJECT_DNS_TYPE_MD:
|
||||
case CORE_OBJECT_DNS_TYPE_MF:
|
||||
case CORE_OBJECT_DNS_TYPE_CNAME:
|
||||
case CORE_OBJECT_DNS_TYPE_MB:
|
||||
case CORE_OBJECT_DNS_TYPE_MG:
|
||||
case CORE_OBJECT_DNS_TYPE_MR:
|
||||
case CORE_OBJECT_DNS_TYPE_PTR:
|
||||
case CORE_OBJECT_DNS_TYPE_NXT:
|
||||
case CORE_OBJECT_DNS_TYPE_DNAME:
|
||||
case CORE_OBJECT_DNS_TYPE_NSEC:
|
||||
case CORE_OBJECT_DNS_TYPE_TKEY:
|
||||
case CORE_OBJECT_DNS_TYPE_TSIG:
|
||||
return 1;
|
||||
|
||||
case CORE_OBJECT_DNS_TYPE_SOA:
|
||||
case CORE_OBJECT_DNS_TYPE_MINFO:
|
||||
case CORE_OBJECT_DNS_TYPE_RP:
|
||||
case CORE_OBJECT_DNS_TYPE_TALINK:
|
||||
return 2;
|
||||
|
||||
case CORE_OBJECT_DNS_TYPE_MX:
|
||||
case CORE_OBJECT_DNS_TYPE_AFSDB:
|
||||
case CORE_OBJECT_DNS_TYPE_RT:
|
||||
case CORE_OBJECT_DNS_TYPE_KX:
|
||||
case CORE_OBJECT_DNS_TYPE_LP:
|
||||
return 1;
|
||||
|
||||
case CORE_OBJECT_DNS_TYPE_PX:
|
||||
return 2;
|
||||
|
||||
case CORE_OBJECT_DNS_TYPE_SIG:
|
||||
case CORE_OBJECT_DNS_TYPE_RRSIG:
|
||||
return 1;
|
||||
|
||||
case CORE_OBJECT_DNS_TYPE_SRV:
|
||||
return 1;
|
||||
|
||||
case CORE_OBJECT_DNS_TYPE_NAPTR:
|
||||
return 1;
|
||||
|
||||
case CORE_OBJECT_DNS_TYPE_HIP:
|
||||
return 1;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline size_t _label(core_object_dns_t* self, core_object_dns_label_t* label, size_t labels)
|
||||
{
|
||||
size_t n;
|
||||
|
||||
for (n = 0; self->left && n < labels; n++) {
|
||||
core_object_dns_label_t* l = &label[n];
|
||||
*l = _defaults_label;
|
||||
|
||||
need8(l->length, self->at, self->left);
|
||||
|
||||
if ((l->length & 0xc0) == 0xc0) {
|
||||
need8(l->offset, self->at, self->left);
|
||||
l->offset |= (l->length & 0x3f) << 8;
|
||||
l->have_offset = 1;
|
||||
return n;
|
||||
} else if (l->length & 0xc0) {
|
||||
l->extension_bits = l->length >> 6;
|
||||
l->have_extension_bits = 1;
|
||||
return n;
|
||||
} else if (l->length) {
|
||||
l->have_length = 1;
|
||||
|
||||
l->offset = self->at - self->payload - 1;
|
||||
advancexb(l->length, self->at, self->left);
|
||||
l->have_dn = 1;
|
||||
} else {
|
||||
l->is_end = 1;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int core_object_dns_parse_q(core_object_dns_t* self, core_object_dns_q_t* q, core_object_dns_label_t* label, size_t labels)
|
||||
{
|
||||
mlassert_self();
|
||||
mlassert(q, "q is nil");
|
||||
mlassert(label, "label is nil");
|
||||
mlassert(labels, "labels is zero");
|
||||
mlassert(self->at, "at is nil");
|
||||
|
||||
for (;;) {
|
||||
*q = _defaults_q;
|
||||
q->labels = _label(self, label, labels);
|
||||
if (q->labels < labels) {
|
||||
core_object_dns_label_t* l = &label[q->labels];
|
||||
if (!(l->have_offset | l->have_extension_bits | l->is_end)) {
|
||||
// TODO: error here on malformed/truncated? could be quite spammy
|
||||
return _ERR_MALFORMED;
|
||||
}
|
||||
} else {
|
||||
mlwarning("need more labels, aborting DNS parsing");
|
||||
return _ERR_NEEDLABELS;
|
||||
}
|
||||
q->labels++;
|
||||
|
||||
need16(q->type, self->at, self->left);
|
||||
q->have_type = 1;
|
||||
|
||||
need16(q->class, self->at, self->left);
|
||||
q->have_class = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO: error here on malformed/truncated? could be quite spammy
|
||||
return _ERR_MALFORMED;
|
||||
}
|
||||
|
||||
int core_object_dns_parse_rr(core_object_dns_t* self, core_object_dns_rr_t* rr, core_object_dns_label_t* label, size_t labels)
|
||||
{
|
||||
size_t rdata_label_sets;
|
||||
mlassert_self();
|
||||
mlassert(rr, "rr is nil");
|
||||
mlassert(label, "label is nil");
|
||||
mlassert(labels, "labels is zero");
|
||||
mlassert(self->at, "at is nil");
|
||||
|
||||
for (;;) {
|
||||
*rr = _defaults_rr;
|
||||
rr->labels = _label(self, label, labels);
|
||||
if (rr->labels < labels) {
|
||||
core_object_dns_label_t* l = &label[rr->labels];
|
||||
if (!(l->have_offset | l->have_extension_bits | l->is_end)) {
|
||||
// TODO: error here on malformed/truncated? could be quite spammy
|
||||
return _ERR_MALFORMED;
|
||||
}
|
||||
} else {
|
||||
mlwarning("need more labels, aborting DNS parsing");
|
||||
return _ERR_NEEDLABELS;
|
||||
}
|
||||
rr->labels++;
|
||||
|
||||
need16(rr->type, self->at, self->left);
|
||||
rr->have_type = 1;
|
||||
|
||||
need16(rr->class, self->at, self->left);
|
||||
rr->have_class = 1;
|
||||
|
||||
need32(rr->ttl, self->at, self->left);
|
||||
rr->have_ttl = 1;
|
||||
|
||||
need16(rr->rdlength, self->at, self->left);
|
||||
rr->have_rdlength = 1;
|
||||
|
||||
rr->rdata_offset = self->at - self->payload;
|
||||
if (!(rdata_label_sets = _rdata_labels(rr->type))) {
|
||||
advancexb(rr->rdlength, self->at, self->left);
|
||||
rr->have_rdata = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (rr->type) {
|
||||
case CORE_OBJECT_DNS_TYPE_MX:
|
||||
case CORE_OBJECT_DNS_TYPE_AFSDB:
|
||||
case CORE_OBJECT_DNS_TYPE_RT:
|
||||
case CORE_OBJECT_DNS_TYPE_KX:
|
||||
case CORE_OBJECT_DNS_TYPE_LP:
|
||||
case CORE_OBJECT_DNS_TYPE_PX:
|
||||
advancexb(2, self->at, self->left);
|
||||
break;
|
||||
|
||||
case CORE_OBJECT_DNS_TYPE_SIG:
|
||||
case CORE_OBJECT_DNS_TYPE_RRSIG:
|
||||
advancexb(18, self->at, self->left);
|
||||
break;
|
||||
|
||||
case CORE_OBJECT_DNS_TYPE_SRV:
|
||||
advancexb(6, self->at, self->left);
|
||||
break;
|
||||
|
||||
case CORE_OBJECT_DNS_TYPE_NAPTR: {
|
||||
uint8_t naptr_length;
|
||||
|
||||
advancexb(4, self->at, self->left);
|
||||
need8(naptr_length, self->at, self->left);
|
||||
advancexb(naptr_length, self->at, self->left);
|
||||
need8(naptr_length, self->at, self->left);
|
||||
advancexb(naptr_length, self->at, self->left);
|
||||
need8(naptr_length, self->at, self->left);
|
||||
advancexb(naptr_length, self->at, self->left);
|
||||
} break;
|
||||
|
||||
case CORE_OBJECT_DNS_TYPE_HIP: {
|
||||
uint8_t hit_length;
|
||||
uint16_t pk_length;
|
||||
|
||||
need8(hit_length, self->at, self->left);
|
||||
advancexb(1, self->at, self->left);
|
||||
need16(pk_length, self->at, self->left);
|
||||
advancexb(hit_length, self->at, self->left);
|
||||
advancexb(pk_length, self->at, self->left);
|
||||
|
||||
if (self->at - self->payload >= rr->rdata_offset + rr->rdlength) {
|
||||
rdata_label_sets = 0;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
while (rdata_label_sets) {
|
||||
rr->rdata_labels += _label(self, &label[rr->labels + rr->rdata_labels], labels - rr->labels - rr->rdata_labels);
|
||||
if (rr->labels + rr->rdata_labels < labels) {
|
||||
core_object_dns_label_t* l = &label[rr->labels + rr->rdata_labels];
|
||||
if (!(l->have_offset | l->have_extension_bits | l->is_end)) {
|
||||
// TODO: error here on malformed/truncated? could be quite spammy
|
||||
return _ERR_MALFORMED;
|
||||
}
|
||||
} else {
|
||||
mlwarning("need more labels, aborting DNS parsing");
|
||||
return _ERR_NEEDLABELS;
|
||||
}
|
||||
rr->rdata_labels++;
|
||||
|
||||
if (rr->type == CORE_OBJECT_DNS_TYPE_HIP && self->at - self->payload < rr->rdata_offset + rr->rdlength) {
|
||||
continue;
|
||||
}
|
||||
|
||||
rdata_label_sets--;
|
||||
}
|
||||
|
||||
if (self->at - self->payload < rr->rdata_offset + rr->rdlength) {
|
||||
rr->padding_offset = self->at - self->payload;
|
||||
rr->padding_length = rr->rdlength - (rr->padding_offset - rr->rdata_offset);
|
||||
|
||||
advancexb(rr->padding_length, self->at, self->left);
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
*
|
||||
* This can indicate padding but we do not set that we have padding
|
||||
* yet because we need to fully understand all record types before
|
||||
* that and process valid data after the labels
|
||||
*
|
||||
rr->have_padding = 1;
|
||||
*/
|
||||
} else if (self->at - self->payload > rr->rdata_offset + rr->rdlength) {
|
||||
// TODO: error here on malformed/truncated? could be quite spammy
|
||||
return _ERR_MALFORMED;
|
||||
}
|
||||
rr->have_rdata = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO: error here on malformed/truncated? could be quite spammy
|
||||
return _ERR_MALFORMED;
|
||||
}
|
184
include/dnsjit/core/object/dns.h
Normal file
184
include/dnsjit/core/object/dns.h
Normal file
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/log.h>
|
||||
#include <dnsjit/core/object.h>
|
||||
|
||||
#ifndef __dnsjit_core_object_dns_h
|
||||
#define __dnsjit_core_object_dns_h
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <dnsjit/core/object/dns.hh>
|
||||
|
||||
#define CORE_OBJECT_DNS_INIT(prev) \
|
||||
{ \
|
||||
CORE_OBJECT_INIT(CORE_OBJECT_DNS, prev) \
|
||||
, \
|
||||
0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
}
|
||||
|
||||
/*
|
||||
* 2016-12-09 https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml
|
||||
*/
|
||||
|
||||
#define CORE_OBJECT_DNS_CLASS_IN 1
|
||||
#define CORE_OBJECT_DNS_CLASS_CH 3
|
||||
#define CORE_OBJECT_DNS_CLASS_HS 4
|
||||
#define CORE_OBJECT_DNS_CLASS_NONE 254
|
||||
#define CORE_OBJECT_DNS_CLASS_ANY 255
|
||||
|
||||
#define CORE_OBJECT_DNS_TYPE_A 1
|
||||
#define CORE_OBJECT_DNS_TYPE_NS 2
|
||||
#define CORE_OBJECT_DNS_TYPE_MD 3
|
||||
#define CORE_OBJECT_DNS_TYPE_MF 4
|
||||
#define CORE_OBJECT_DNS_TYPE_CNAME 5
|
||||
#define CORE_OBJECT_DNS_TYPE_SOA 6
|
||||
#define CORE_OBJECT_DNS_TYPE_MB 7
|
||||
#define CORE_OBJECT_DNS_TYPE_MG 8
|
||||
#define CORE_OBJECT_DNS_TYPE_MR 9
|
||||
#define CORE_OBJECT_DNS_TYPE_NULL 10
|
||||
#define CORE_OBJECT_DNS_TYPE_WKS 11
|
||||
#define CORE_OBJECT_DNS_TYPE_PTR 12
|
||||
#define CORE_OBJECT_DNS_TYPE_HINFO 13
|
||||
#define CORE_OBJECT_DNS_TYPE_MINFO 14
|
||||
#define CORE_OBJECT_DNS_TYPE_MX 15
|
||||
#define CORE_OBJECT_DNS_TYPE_TXT 16
|
||||
#define CORE_OBJECT_DNS_TYPE_RP 17
|
||||
#define CORE_OBJECT_DNS_TYPE_AFSDB 18
|
||||
#define CORE_OBJECT_DNS_TYPE_X25 19
|
||||
#define CORE_OBJECT_DNS_TYPE_ISDN 20
|
||||
#define CORE_OBJECT_DNS_TYPE_RT 21
|
||||
#define CORE_OBJECT_DNS_TYPE_NSAP 22
|
||||
#define CORE_OBJECT_DNS_TYPE_NSAP_PTR 23
|
||||
#define CORE_OBJECT_DNS_TYPE_SIG 24
|
||||
#define CORE_OBJECT_DNS_TYPE_KEY 25
|
||||
#define CORE_OBJECT_DNS_TYPE_PX 26
|
||||
#define CORE_OBJECT_DNS_TYPE_GPOS 27
|
||||
#define CORE_OBJECT_DNS_TYPE_AAAA 28
|
||||
#define CORE_OBJECT_DNS_TYPE_LOC 29
|
||||
#define CORE_OBJECT_DNS_TYPE_NXT 30
|
||||
#define CORE_OBJECT_DNS_TYPE_EID 31
|
||||
#define CORE_OBJECT_DNS_TYPE_NIMLOC 32
|
||||
#define CORE_OBJECT_DNS_TYPE_SRV 33
|
||||
#define CORE_OBJECT_DNS_TYPE_ATMA 34
|
||||
#define CORE_OBJECT_DNS_TYPE_NAPTR 35
|
||||
#define CORE_OBJECT_DNS_TYPE_KX 36
|
||||
#define CORE_OBJECT_DNS_TYPE_CERT 37
|
||||
#define CORE_OBJECT_DNS_TYPE_A6 38
|
||||
#define CORE_OBJECT_DNS_TYPE_DNAME 39
|
||||
#define CORE_OBJECT_DNS_TYPE_SINK 40
|
||||
#define CORE_OBJECT_DNS_TYPE_OPT 41
|
||||
#define CORE_OBJECT_DNS_TYPE_APL 42
|
||||
#define CORE_OBJECT_DNS_TYPE_DS 43
|
||||
#define CORE_OBJECT_DNS_TYPE_SSHFP 44
|
||||
#define CORE_OBJECT_DNS_TYPE_IPSECKEY 45
|
||||
#define CORE_OBJECT_DNS_TYPE_RRSIG 46
|
||||
#define CORE_OBJECT_DNS_TYPE_NSEC 47
|
||||
#define CORE_OBJECT_DNS_TYPE_DNSKEY 48
|
||||
#define CORE_OBJECT_DNS_TYPE_DHCID 49
|
||||
#define CORE_OBJECT_DNS_TYPE_NSEC3 50
|
||||
#define CORE_OBJECT_DNS_TYPE_NSEC3PARAM 51
|
||||
#define CORE_OBJECT_DNS_TYPE_TLSA 52
|
||||
#define CORE_OBJECT_DNS_TYPE_SMIMEA 53
|
||||
#define CORE_OBJECT_DNS_TYPE_HIP 55
|
||||
#define CORE_OBJECT_DNS_TYPE_NINFO 56
|
||||
#define CORE_OBJECT_DNS_TYPE_RKEY 57
|
||||
#define CORE_OBJECT_DNS_TYPE_TALINK 58
|
||||
#define CORE_OBJECT_DNS_TYPE_CDS 59
|
||||
#define CORE_OBJECT_DNS_TYPE_CDNSKEY 60
|
||||
#define CORE_OBJECT_DNS_TYPE_OPENPGPKEY 61
|
||||
#define CORE_OBJECT_DNS_TYPE_CSYNC 62
|
||||
#define CORE_OBJECT_DNS_TYPE_SPF 99
|
||||
#define CORE_OBJECT_DNS_TYPE_UINFO 100
|
||||
#define CORE_OBJECT_DNS_TYPE_UID 101
|
||||
#define CORE_OBJECT_DNS_TYPE_GID 102
|
||||
#define CORE_OBJECT_DNS_TYPE_UNSPEC 103
|
||||
#define CORE_OBJECT_DNS_TYPE_NID 104
|
||||
#define CORE_OBJECT_DNS_TYPE_L32 105
|
||||
#define CORE_OBJECT_DNS_TYPE_L64 106
|
||||
#define CORE_OBJECT_DNS_TYPE_LP 107
|
||||
#define CORE_OBJECT_DNS_TYPE_EUI48 108
|
||||
#define CORE_OBJECT_DNS_TYPE_EUI64 109
|
||||
#define CORE_OBJECT_DNS_TYPE_TKEY 249
|
||||
#define CORE_OBJECT_DNS_TYPE_TSIG 250
|
||||
#define CORE_OBJECT_DNS_TYPE_IXFR 251
|
||||
#define CORE_OBJECT_DNS_TYPE_AXFR 252
|
||||
#define CORE_OBJECT_DNS_TYPE_MAILB 253
|
||||
#define CORE_OBJECT_DNS_TYPE_MAILA 254
|
||||
#define CORE_OBJECT_DNS_TYPE_ANY 255
|
||||
#define CORE_OBJECT_DNS_TYPE_URI 256
|
||||
#define CORE_OBJECT_DNS_TYPE_CAA 257
|
||||
#define CORE_OBJECT_DNS_TYPE_AVC 258
|
||||
#define CORE_OBJECT_DNS_TYPE_TA 32768
|
||||
#define CORE_OBJECT_DNS_TYPE_DLV 32769
|
||||
|
||||
#define CORE_OBJECT_DNS_OPCODE_QUERY 0
|
||||
#define CORE_OBJECT_DNS_OPCODE_IQUERY 1
|
||||
#define CORE_OBJECT_DNS_OPCODE_STATUS 2
|
||||
#define CORE_OBJECT_DNS_OPCODE_NOTIFY 4
|
||||
#define CORE_OBJECT_DNS_OPCODE_UPDATE 5
|
||||
|
||||
#define CORE_OBJECT_DNS_RCODE_NOERROR 0
|
||||
#define CORE_OBJECT_DNS_RCODE_FORMERR 1
|
||||
#define CORE_OBJECT_DNS_RCODE_SERVFAIL 2
|
||||
#define CORE_OBJECT_DNS_RCODE_NXDOMAIN 3
|
||||
#define CORE_OBJECT_DNS_RCODE_NOTIMP 4
|
||||
#define CORE_OBJECT_DNS_RCODE_REFUSED 5
|
||||
#define CORE_OBJECT_DNS_RCODE_YXDOMAIN 6
|
||||
#define CORE_OBJECT_DNS_RCODE_YXRRSET 7
|
||||
#define CORE_OBJECT_DNS_RCODE_NXRRSET 8
|
||||
#define CORE_OBJECT_DNS_RCODE_NOTAUTH 9
|
||||
#define CORE_OBJECT_DNS_RCODE_NOTZONE 10
|
||||
#define CORE_OBJECT_DNS_RCODE_BADVERS 16
|
||||
#define CORE_OBJECT_DNS_RCODE_BADSIG 16
|
||||
#define CORE_OBJECT_DNS_RCODE_BADKEY 17
|
||||
#define CORE_OBJECT_DNS_RCODE_BADTIME 18
|
||||
#define CORE_OBJECT_DNS_RCODE_BADMODE 19
|
||||
#define CORE_OBJECT_DNS_RCODE_BADNAME 20
|
||||
#define CORE_OBJECT_DNS_RCODE_BADALG 21
|
||||
#define CORE_OBJECT_DNS_RCODE_BADTRUNC 22
|
||||
#define CORE_OBJECT_DNS_RCODE_BADCOOKIE 23
|
||||
|
||||
#define CORE_OBJECT_DNS_AFSDB_SUBTYPE_AFS3LOCSRV 1
|
||||
#define CORE_OBJECT_DNS_AFSDB_SUBTYPE_DCENCA_ROOT 2
|
||||
|
||||
#define CORE_OBJECT_DNS_DHCID_TYPE_1OCTET 0
|
||||
#define CORE_OBJECT_DNS_DHCID_TYPE_DATAOCTET 1
|
||||
#define CORE_OBJECT_DNS_DHCID_TYPE_CLIENT_DUID 2
|
||||
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_LLQ 1
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_UL 2
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_NSID 3
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_DAU 5
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_DHU 6
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_N3U 7
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_CLIENT_SUBNET 8
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_EXPIRE 9
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_COOKIE 10
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_TCP_KEEPALIVE 11
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_PADDING 12
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_CHAIN 13
|
||||
#define CORE_OBJECT_DNS_EDNS0_OPT_DEVICEID 26946
|
||||
|
||||
#endif
|
119
include/dnsjit/core/object/dns.hh
Normal file
119
include/dnsjit/core/object/dns.hh
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.log")
|
||||
//lua:require("dnsjit.core.object_h")
|
||||
|
||||
typedef struct core_object_dns_label {
|
||||
uint8_t is_end;
|
||||
uint8_t have_length;
|
||||
uint8_t have_offset;
|
||||
uint8_t have_extension_bits;
|
||||
uint8_t have_dn;
|
||||
uint8_t extension_bits;
|
||||
|
||||
uint8_t length;
|
||||
uint16_t offset;
|
||||
} core_object_dns_label_t;
|
||||
|
||||
typedef struct core_object_dns_rr {
|
||||
uint8_t have_type;
|
||||
uint8_t have_class;
|
||||
uint8_t have_ttl;
|
||||
uint8_t have_rdlength;
|
||||
uint8_t have_rdata;
|
||||
uint8_t have_rdata_labels;
|
||||
uint8_t have_padding;
|
||||
|
||||
uint16_t type;
|
||||
uint16_t class;
|
||||
uint32_t ttl;
|
||||
uint16_t rdlength;
|
||||
|
||||
size_t labels;
|
||||
size_t rdata_offset;
|
||||
size_t rdata_labels;
|
||||
size_t padding_offset;
|
||||
size_t padding_length;
|
||||
} core_object_dns_rr_t;
|
||||
|
||||
typedef struct core_object_dns_q {
|
||||
uint8_t have_type;
|
||||
uint8_t have_class;
|
||||
|
||||
uint16_t type;
|
||||
uint16_t class;
|
||||
|
||||
size_t labels;
|
||||
} core_object_dns_q_t;
|
||||
|
||||
typedef struct core_object_dns {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
|
||||
int includes_dnslen;
|
||||
const uint8_t *payload, *at;
|
||||
size_t len, left;
|
||||
|
||||
uint8_t have_dnslen;
|
||||
uint8_t have_id;
|
||||
uint8_t have_qr;
|
||||
uint8_t have_opcode;
|
||||
uint8_t have_aa;
|
||||
uint8_t have_tc;
|
||||
uint8_t have_rd;
|
||||
uint8_t have_ra;
|
||||
uint8_t have_z;
|
||||
uint8_t have_ad;
|
||||
uint8_t have_cd;
|
||||
uint8_t have_rcode;
|
||||
uint8_t have_qdcount;
|
||||
uint8_t have_ancount;
|
||||
uint8_t have_nscount;
|
||||
uint8_t have_arcount;
|
||||
|
||||
uint16_t dnslen;
|
||||
uint16_t id;
|
||||
int8_t qr;
|
||||
uint8_t opcode;
|
||||
uint8_t aa;
|
||||
uint8_t tc;
|
||||
uint8_t rd;
|
||||
uint8_t ra;
|
||||
uint8_t z;
|
||||
uint8_t ad;
|
||||
uint8_t cd;
|
||||
uint8_t rcode;
|
||||
uint16_t qdcount;
|
||||
uint16_t ancount;
|
||||
uint16_t nscount;
|
||||
uint16_t arcount;
|
||||
} core_object_dns_t;
|
||||
|
||||
core_log_t* core_object_dns_log();
|
||||
|
||||
core_object_dns_t* core_object_dns_new();
|
||||
core_object_dns_t* core_object_dns_copy(const core_object_dns_t* self);
|
||||
void core_object_dns_free(core_object_dns_t* self);
|
||||
void core_object_dns_reset(core_object_dns_t* self, const core_object_t* obj);
|
||||
|
||||
int core_object_dns_parse_header(core_object_dns_t* self);
|
||||
int core_object_dns_parse_q(core_object_dns_t* self, core_object_dns_q_t* q, core_object_dns_label_t* label, size_t labels);
|
||||
int core_object_dns_parse_rr(core_object_dns_t* self, core_object_dns_rr_t* rr, core_object_dns_label_t* label, size_t labels);
|
797
include/dnsjit/core/object/dns.lua
Normal file
797
include/dnsjit/core/object/dns.lua
Normal file
|
@ -0,0 +1,797 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.dns
|
||||
-- Container of a DNS message
|
||||
-- .SS Parse DNS header and check if query or response
|
||||
-- local dns = require("dnsjit.core.object.dns").new(payload)
|
||||
-- if dns:parse_header() == 0 then
|
||||
-- if dns.qr == 0 then
|
||||
-- print(dns.id, dns.opcode_tostring(dns.opcode))
|
||||
-- else
|
||||
-- print(dns.id, dns.rcode_tostring(dns.rcode))
|
||||
-- end
|
||||
-- end
|
||||
-- .SS Print a DNS payload
|
||||
-- local dns = require("dnsjit.core.object.dns").new(payload)
|
||||
-- dns:print()
|
||||
-- .SS Parse a DNS payload
|
||||
-- local dns = require("dnsjit.core.object.dns").new(payload)
|
||||
-- local qs, q_labels, rrs, rr_labels = dns:parse()
|
||||
-- if qs and q_labels then
|
||||
-- ...
|
||||
-- if rrs and rr_labels then
|
||||
-- ...
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- The object that describes a DNS message.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- includes_dnslen
|
||||
-- If non-zero then this indicates that the DNS length is included in the
|
||||
-- payload (for example if the transport is TCP) and will affect parsing of it.
|
||||
-- .TP
|
||||
-- have_dnslen
|
||||
-- Set if the dnslen was included in the payload and could be read.
|
||||
-- .TP
|
||||
-- have_id
|
||||
-- Set if there is a DNS ID.
|
||||
-- .TP
|
||||
-- have_qr
|
||||
-- Set if there is a QR flag.
|
||||
-- .TP
|
||||
-- have_opcode
|
||||
-- Set if there is an OPCODE.
|
||||
-- .TP
|
||||
-- have_aa
|
||||
-- Set if there is a AA flag.
|
||||
-- .TP
|
||||
-- have_tc
|
||||
-- Set if there is a TC flag.
|
||||
-- .TP
|
||||
-- have_rd
|
||||
-- Set if there is a RD flag.
|
||||
-- .TP
|
||||
-- have_ra
|
||||
-- Set if there is a RA flag.
|
||||
-- .TP
|
||||
-- have_z
|
||||
-- Set if there is a Z flag.
|
||||
-- .TP
|
||||
-- have_ad
|
||||
-- Set if there is a AD flag.
|
||||
-- .TP
|
||||
-- have_cd
|
||||
-- Set if there is a CD flag.
|
||||
-- .TP
|
||||
-- have_rcode
|
||||
-- Set if there is a RCODE.
|
||||
-- .TP
|
||||
-- have_qdcount
|
||||
-- Set if there is an QDCOUNT.
|
||||
-- .TP
|
||||
-- have_ancount
|
||||
-- Set if there is an ANCOUNT.
|
||||
-- .TP
|
||||
-- have_nscount
|
||||
-- Set if there is a NSCOUNT.
|
||||
-- .TP
|
||||
-- have_arcount
|
||||
-- Set if there is an ARCOUNT.
|
||||
-- .TP
|
||||
-- dnslen
|
||||
-- The DNS length found in the payload.
|
||||
-- .TP
|
||||
-- id
|
||||
-- The DNS ID.
|
||||
-- .TP
|
||||
-- qr
|
||||
-- The QR flag.
|
||||
-- .TP
|
||||
-- opcode
|
||||
-- The OPCODE.
|
||||
-- .TP
|
||||
-- aa
|
||||
-- The AA flag.
|
||||
-- .TP
|
||||
-- tc
|
||||
-- The TC flag.
|
||||
-- .TP
|
||||
-- rd
|
||||
-- The RD flag.
|
||||
-- .TP
|
||||
-- ra
|
||||
-- The RA flag.
|
||||
-- .TP
|
||||
-- z
|
||||
-- The Z flag.
|
||||
-- .TP
|
||||
-- ad
|
||||
-- The AD flag.
|
||||
-- .TP
|
||||
-- cd
|
||||
-- The CD flag.
|
||||
-- .TP
|
||||
-- rcode
|
||||
-- The RCODE.
|
||||
-- .TP
|
||||
-- qdcount
|
||||
-- The QDCOUNT.
|
||||
-- .TP
|
||||
-- ancount
|
||||
-- The ANCOUNT.
|
||||
-- .TP
|
||||
-- nscount
|
||||
-- The NSCOUNT.
|
||||
-- .TP
|
||||
-- arcount
|
||||
-- The ARCOUNT.
|
||||
-- .SS Constants
|
||||
-- The following tables exists for DNS parameters, taken from
|
||||
-- .I https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml
|
||||
-- on the 2016-12-09.
|
||||
-- .LP
|
||||
-- .IR CLASS ,
|
||||
-- .IR CLASS_STR ,
|
||||
-- .IR TYPE ,
|
||||
-- .IR TYPE_STR ,
|
||||
-- .IR OPCODE ,
|
||||
-- .IR OPCODE_STR ,
|
||||
-- .IR RCODE ,
|
||||
-- .IR RCODE_STR ,
|
||||
-- .IR AFSDB ,
|
||||
-- .IR AFSDB_STR ,
|
||||
-- .IR DHCID ,
|
||||
-- .IR DHCID_STR ,
|
||||
-- .IR ENDS0 ,
|
||||
-- .IR ENDS0_STR
|
||||
-- .LP
|
||||
-- The
|
||||
-- .I *_STR
|
||||
-- tables can be used to get a textual representation of the numbers, see also
|
||||
-- .IR class_tostring() ,
|
||||
-- .IR type_tostring() ,
|
||||
-- .IR opcode_tostring() ,
|
||||
-- .IR rcode_tostring() ,
|
||||
-- .IR afsdb_tostring() ,
|
||||
-- .I dhcid_tostring()
|
||||
-- and
|
||||
-- .IR edns0_tostring() .
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.dns_h")
|
||||
local label = require("dnsjit.core.object.dns.label")
|
||||
local Q = require("dnsjit.core.object.dns.q")
|
||||
local RR = require("dnsjit.core.object.dns.rr")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local t_name = "core_object_dns_t"
|
||||
local core_object_dns_t
|
||||
local Dns = {
|
||||
CLASS = {
|
||||
IN = 1,
|
||||
CH = 3,
|
||||
HS = 4,
|
||||
NONE = 254,
|
||||
ANY = 255,
|
||||
},
|
||||
TYPE = {
|
||||
A = 1,
|
||||
NS = 2,
|
||||
MD = 3,
|
||||
MF = 4,
|
||||
CNAME = 5,
|
||||
SOA = 6,
|
||||
MB = 7,
|
||||
MG = 8,
|
||||
MR = 9,
|
||||
NULL = 10,
|
||||
WKS = 11,
|
||||
PTR = 12,
|
||||
HINFO = 13,
|
||||
MINFO = 14,
|
||||
MX = 15,
|
||||
TXT = 16,
|
||||
RP = 17,
|
||||
AFSDB = 18,
|
||||
X25 = 19,
|
||||
ISDN = 20,
|
||||
RT = 21,
|
||||
NSAP = 22,
|
||||
NSAP_PTR = 23,
|
||||
SIG = 24,
|
||||
KEY = 25,
|
||||
PX = 26,
|
||||
GPOS = 27,
|
||||
AAAA = 28,
|
||||
LOC = 29,
|
||||
NXT = 30,
|
||||
EID = 31,
|
||||
NIMLOC = 32,
|
||||
SRV = 33,
|
||||
ATMA = 34,
|
||||
NAPTR = 35,
|
||||
KX = 36,
|
||||
CERT = 37,
|
||||
A6 = 38,
|
||||
DNAME = 39,
|
||||
SINK = 40,
|
||||
OPT = 41,
|
||||
APL = 42,
|
||||
DS = 43,
|
||||
SSHFP = 44,
|
||||
IPSECKEY = 45,
|
||||
RRSIG = 46,
|
||||
NSEC = 47,
|
||||
DNSKEY = 48,
|
||||
DHCID = 49,
|
||||
NSEC3 = 50,
|
||||
NSEC3PARAM = 51,
|
||||
TLSA = 52,
|
||||
SMIMEA = 53,
|
||||
HIP = 55,
|
||||
NINFO = 56,
|
||||
RKEY = 57,
|
||||
TALINK = 58,
|
||||
CDS = 59,
|
||||
CDNSKEY = 60,
|
||||
OPENPGPKEY = 61,
|
||||
CSYNC = 62,
|
||||
SPF = 99,
|
||||
UINFO = 100,
|
||||
UID = 101,
|
||||
GID = 102,
|
||||
UNSPEC = 103,
|
||||
NID = 104,
|
||||
L32 = 105,
|
||||
L64 = 106,
|
||||
LP = 107,
|
||||
EUI48 = 108,
|
||||
EUI64 = 109,
|
||||
TKEY = 249,
|
||||
TSIG = 250,
|
||||
IXFR = 251,
|
||||
AXFR = 252,
|
||||
MAILB = 253,
|
||||
MAILA = 254,
|
||||
ANY = 255,
|
||||
URI = 256,
|
||||
CAA = 257,
|
||||
AVC = 258,
|
||||
TA = 32768,
|
||||
DLV = 32769,
|
||||
},
|
||||
OPCODE = {
|
||||
QUERY = 0,
|
||||
IQUERY = 1,
|
||||
STATUS = 2,
|
||||
NOTIFY = 4,
|
||||
UPDATE = 5,
|
||||
},
|
||||
RCODE = {
|
||||
NOERROR = 0,
|
||||
FORMERR = 1,
|
||||
SERVFAIL = 2,
|
||||
NXDOMAIN = 3,
|
||||
NOTIMP = 4,
|
||||
REFUSED = 5,
|
||||
YXDOMAIN = 6,
|
||||
YXRRSET = 7,
|
||||
NXRRSET = 8,
|
||||
NOTAUTH = 9,
|
||||
NOTZONE = 10,
|
||||
BADVERS = 16,
|
||||
BADSIG = 16,
|
||||
BADKEY = 17,
|
||||
BADTIME = 18,
|
||||
BADMODE = 19,
|
||||
BADNAME = 20,
|
||||
BADALG = 21,
|
||||
BADTRUNC = 22,
|
||||
BADCOOKIE = 23,
|
||||
},
|
||||
AFSDB = {
|
||||
SUBTYPE_AFS3LOCSRV = 1,
|
||||
SUBTYPE_DCENCA_ROOT = 2,
|
||||
},
|
||||
DHCID = {
|
||||
TYPE_1OCTET = 0,
|
||||
TYPE_DATAOCTET = 1,
|
||||
TYPE_CLIENT_DUID = 2,
|
||||
},
|
||||
EDNS0 = {
|
||||
OPT_LLQ = 1,
|
||||
OPT_UL = 2,
|
||||
OPT_NSID = 3,
|
||||
OPT_DAU = 5,
|
||||
OPT_DHU = 6,
|
||||
OPT_N3U = 7,
|
||||
OPT_CLIENT_SUBNET = 8,
|
||||
OPT_EXPIRE = 9,
|
||||
OPT_COOKIE = 10,
|
||||
OPT_TCP_KEEPALIVE = 11,
|
||||
OPT_PADDING = 12,
|
||||
OPT_CHAIN = 13,
|
||||
OPT_DEVICEID = 26946,
|
||||
},
|
||||
}
|
||||
local _CLASS = {}
|
||||
_CLASS[Dns.CLASS.IN] = "IN"
|
||||
_CLASS[Dns.CLASS.CH] = "CH"
|
||||
_CLASS[Dns.CLASS.HS] = "HS"
|
||||
_CLASS[Dns.CLASS.NONE] = "NONE"
|
||||
_CLASS[Dns.CLASS.ANY] = "ANY"
|
||||
local _TYPE = {}
|
||||
_TYPE[Dns.TYPE.A] = "A"
|
||||
_TYPE[Dns.TYPE.NS] = "NS"
|
||||
_TYPE[Dns.TYPE.MD] = "MD"
|
||||
_TYPE[Dns.TYPE.MF] = "MF"
|
||||
_TYPE[Dns.TYPE.CNAME] = "CNAME"
|
||||
_TYPE[Dns.TYPE.SOA] = "SOA"
|
||||
_TYPE[Dns.TYPE.MB] = "MB"
|
||||
_TYPE[Dns.TYPE.MG] = "MG"
|
||||
_TYPE[Dns.TYPE.MR] = "MR"
|
||||
_TYPE[Dns.TYPE.NULL] = "NULL"
|
||||
_TYPE[Dns.TYPE.WKS] = "WKS"
|
||||
_TYPE[Dns.TYPE.PTR] = "PTR"
|
||||
_TYPE[Dns.TYPE.HINFO] = "HINFO"
|
||||
_TYPE[Dns.TYPE.MINFO] = "MINFO"
|
||||
_TYPE[Dns.TYPE.MX] = "MX"
|
||||
_TYPE[Dns.TYPE.TXT] = "TXT"
|
||||
_TYPE[Dns.TYPE.RP] = "RP"
|
||||
_TYPE[Dns.TYPE.AFSDB] = "AFSDB"
|
||||
_TYPE[Dns.TYPE.X25] = "X25"
|
||||
_TYPE[Dns.TYPE.ISDN] = "ISDN"
|
||||
_TYPE[Dns.TYPE.RT] = "RT"
|
||||
_TYPE[Dns.TYPE.NSAP] = "NSAP"
|
||||
_TYPE[Dns.TYPE.NSAP_PTR] = "NSAP_PTR"
|
||||
_TYPE[Dns.TYPE.SIG] = "SIG"
|
||||
_TYPE[Dns.TYPE.KEY] = "KEY"
|
||||
_TYPE[Dns.TYPE.PX] = "PX"
|
||||
_TYPE[Dns.TYPE.GPOS] = "GPOS"
|
||||
_TYPE[Dns.TYPE.AAAA] = "AAAA"
|
||||
_TYPE[Dns.TYPE.LOC] = "LOC"
|
||||
_TYPE[Dns.TYPE.NXT] = "NXT"
|
||||
_TYPE[Dns.TYPE.EID] = "EID"
|
||||
_TYPE[Dns.TYPE.NIMLOC] = "NIMLOC"
|
||||
_TYPE[Dns.TYPE.SRV] = "SRV"
|
||||
_TYPE[Dns.TYPE.ATMA] = "ATMA"
|
||||
_TYPE[Dns.TYPE.NAPTR] = "NAPTR"
|
||||
_TYPE[Dns.TYPE.KX] = "KX"
|
||||
_TYPE[Dns.TYPE.CERT] = "CERT"
|
||||
_TYPE[Dns.TYPE.A6] = "A6"
|
||||
_TYPE[Dns.TYPE.DNAME] = "DNAME"
|
||||
_TYPE[Dns.TYPE.SINK] = "SINK"
|
||||
_TYPE[Dns.TYPE.OPT] = "OPT"
|
||||
_TYPE[Dns.TYPE.APL] = "APL"
|
||||
_TYPE[Dns.TYPE.DS] = "DS"
|
||||
_TYPE[Dns.TYPE.SSHFP] = "SSHFP"
|
||||
_TYPE[Dns.TYPE.IPSECKEY] = "IPSECKEY"
|
||||
_TYPE[Dns.TYPE.RRSIG] = "RRSIG"
|
||||
_TYPE[Dns.TYPE.NSEC] = "NSEC"
|
||||
_TYPE[Dns.TYPE.DNSKEY] = "DNSKEY"
|
||||
_TYPE[Dns.TYPE.DHCID] = "DHCID"
|
||||
_TYPE[Dns.TYPE.NSEC3] = "NSEC3"
|
||||
_TYPE[Dns.TYPE.NSEC3PARAM] = "NSEC3PARAM"
|
||||
_TYPE[Dns.TYPE.TLSA] = "TLSA"
|
||||
_TYPE[Dns.TYPE.SMIMEA] = "SMIMEA"
|
||||
_TYPE[Dns.TYPE.HIP] = "HIP"
|
||||
_TYPE[Dns.TYPE.NINFO] = "NINFO"
|
||||
_TYPE[Dns.TYPE.RKEY] = "RKEY"
|
||||
_TYPE[Dns.TYPE.TALINK] = "TALINK"
|
||||
_TYPE[Dns.TYPE.CDS] = "CDS"
|
||||
_TYPE[Dns.TYPE.CDNSKEY] = "CDNSKEY"
|
||||
_TYPE[Dns.TYPE.OPENPGPKEY] = "OPENPGPKEY"
|
||||
_TYPE[Dns.TYPE.CSYNC] = "CSYNC"
|
||||
_TYPE[Dns.TYPE.SPF] = "SPF"
|
||||
_TYPE[Dns.TYPE.UINFO] = "UINFO"
|
||||
_TYPE[Dns.TYPE.UID] = "UID"
|
||||
_TYPE[Dns.TYPE.GID] = "GID"
|
||||
_TYPE[Dns.TYPE.UNSPEC] = "UNSPEC"
|
||||
_TYPE[Dns.TYPE.NID] = "NID"
|
||||
_TYPE[Dns.TYPE.L32] = "L32"
|
||||
_TYPE[Dns.TYPE.L64] = "L64"
|
||||
_TYPE[Dns.TYPE.LP] = "LP"
|
||||
_TYPE[Dns.TYPE.EUI48] = "EUI48"
|
||||
_TYPE[Dns.TYPE.EUI64] = "EUI64"
|
||||
_TYPE[Dns.TYPE.TKEY] = "TKEY"
|
||||
_TYPE[Dns.TYPE.TSIG] = "TSIG"
|
||||
_TYPE[Dns.TYPE.IXFR] = "IXFR"
|
||||
_TYPE[Dns.TYPE.AXFR] = "AXFR"
|
||||
_TYPE[Dns.TYPE.MAILB] = "MAILB"
|
||||
_TYPE[Dns.TYPE.MAILA] = "MAILA"
|
||||
_TYPE[Dns.TYPE.ANY] = "ANY"
|
||||
_TYPE[Dns.TYPE.URI] = "URI"
|
||||
_TYPE[Dns.TYPE.CAA] = "CAA"
|
||||
_TYPE[Dns.TYPE.AVC] = "AVC"
|
||||
_TYPE[Dns.TYPE.TA] = "TA"
|
||||
_TYPE[Dns.TYPE.DLV] = "DLV"
|
||||
local _OPCODE = {}
|
||||
_OPCODE[Dns.OPCODE.QUERY] = "QUERY"
|
||||
_OPCODE[Dns.OPCODE.IQUERY] = "IQUERY"
|
||||
_OPCODE[Dns.OPCODE.STATUS] = "STATUS"
|
||||
_OPCODE[Dns.OPCODE.NOTIFY] = "NOTIFY"
|
||||
_OPCODE[Dns.OPCODE.UPDATE] = "UPDATE"
|
||||
local _RCODE = {}
|
||||
_RCODE[Dns.RCODE.NOERROR] = "NOERROR"
|
||||
_RCODE[Dns.RCODE.FORMERR] = "FORMERR"
|
||||
_RCODE[Dns.RCODE.SERVFAIL] = "SERVFAIL"
|
||||
_RCODE[Dns.RCODE.NXDOMAIN] = "NXDOMAIN"
|
||||
_RCODE[Dns.RCODE.NOTIMP] = "NOTIMP"
|
||||
_RCODE[Dns.RCODE.REFUSED] = "REFUSED"
|
||||
_RCODE[Dns.RCODE.YXDOMAIN] = "YXDOMAIN"
|
||||
_RCODE[Dns.RCODE.YXRRSET] = "YXRRSET"
|
||||
_RCODE[Dns.RCODE.NXRRSET] = "NXRRSET"
|
||||
_RCODE[Dns.RCODE.NOTAUTH] = "NOTAUTH"
|
||||
_RCODE[Dns.RCODE.NOTZONE] = "NOTZONE"
|
||||
_RCODE[Dns.RCODE.BADVERS] = "BADVERS"
|
||||
_RCODE[Dns.RCODE.BADSIG] = "BADSIG"
|
||||
_RCODE[Dns.RCODE.BADKEY] = "BADKEY"
|
||||
_RCODE[Dns.RCODE.BADTIME] = "BADTIME"
|
||||
_RCODE[Dns.RCODE.BADMODE] = "BADMODE"
|
||||
_RCODE[Dns.RCODE.BADNAME] = "BADNAME"
|
||||
_RCODE[Dns.RCODE.BADALG] = "BADALG"
|
||||
_RCODE[Dns.RCODE.BADTRUNC] = "BADTRUNC"
|
||||
_RCODE[Dns.RCODE.BADCOOKIE] = "BADCOOKIE"
|
||||
local _AFSDB = {}
|
||||
_AFSDB[Dns.AFSDB.SUBTYPE_AFS3LOCSRV] = "SUBTYPE_AFS3LOCSRV"
|
||||
_AFSDB[Dns.AFSDB.SUBTYPE_DCENCA_ROOT] = "SUBTYPE_DCENCA_ROOT"
|
||||
local _DHCID = {}
|
||||
_DHCID[Dns.DHCID.TYPE_1OCTET] = "TYPE_1OCTET"
|
||||
_DHCID[Dns.DHCID.TYPE_DATAOCTET] = "TYPE_DATAOCTET"
|
||||
_DHCID[Dns.DHCID.TYPE_CLIENT_DUID] = "TYPE_CLIENT_DUID"
|
||||
local _EDNS0 = {}
|
||||
_EDNS0[Dns.EDNS0.OPT_LLQ] = "OPT_LLQ"
|
||||
_EDNS0[Dns.EDNS0.OPT_UL] = "OPT_UL"
|
||||
_EDNS0[Dns.EDNS0.OPT_NSID] = "OPT_NSID"
|
||||
_EDNS0[Dns.EDNS0.OPT_DAU] = "OPT_DAU"
|
||||
_EDNS0[Dns.EDNS0.OPT_DHU] = "OPT_DHU"
|
||||
_EDNS0[Dns.EDNS0.OPT_N3U] = "OPT_N3U"
|
||||
_EDNS0[Dns.EDNS0.OPT_CLIENT_SUBNET] = "OPT_CLIENT_SUBNET"
|
||||
_EDNS0[Dns.EDNS0.OPT_EXPIRE] = "OPT_EXPIRE"
|
||||
_EDNS0[Dns.EDNS0.OPT_COOKIE] = "OPT_COOKIE"
|
||||
_EDNS0[Dns.EDNS0.OPT_TCP_KEEPALIVE] = "OPT_TCP_KEEPALIVE"
|
||||
_EDNS0[Dns.EDNS0.OPT_PADDING] = "OPT_PADDING"
|
||||
_EDNS0[Dns.EDNS0.OPT_CHAIN] = "OPT_CHAIN"
|
||||
_EDNS0[Dns.EDNS0.OPT_DEVICEID] = "OPT_DEVICEID"
|
||||
Dns.CLASS_STR = _CLASS
|
||||
Dns.TYPE_STR = _TYPE
|
||||
Dns.OPCODE_STR = _OPCODE
|
||||
Dns.RCODE_STR = _RCODE
|
||||
Dns.AFSDB_STR = _AFSDB
|
||||
Dns.DHCID_STR = _DHCID
|
||||
Dns.EDNS0_STR = _EDNS0
|
||||
|
||||
-- Create a new DNS object, optionally on-top of another object.
|
||||
function Dns.new(obj)
|
||||
local self = C.core_object_dns_new()
|
||||
self.obj_prev = obj
|
||||
ffi.gc(self, C.core_object_dns_free)
|
||||
return self
|
||||
end
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Dns:type()
|
||||
return "dns"
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Dns:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Dns:cast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Dns:uncast()
|
||||
return ffi.cast("core_object_t*", self)
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Dns:copy()
|
||||
return C.core_object_dns_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Dns:free()
|
||||
C.core_object_dns_free(self)
|
||||
end
|
||||
|
||||
-- Return the Log object to control logging of this module.
|
||||
function Dns:log()
|
||||
return C.core_object_dns_log()
|
||||
end
|
||||
|
||||
-- Begin parsing the underlaying object, first the header is parsed then
|
||||
-- optionally continue calling
|
||||
-- .IR parse_q ()
|
||||
-- for the number of questions (see
|
||||
-- .IR qdcount ).
|
||||
-- After that continue calling
|
||||
-- .IR parse_rr ()
|
||||
-- for the number of answers, authorities and additionals resource records
|
||||
-- (see
|
||||
-- .IR ancount ", "
|
||||
-- .I nscount
|
||||
-- and
|
||||
-- .IR arcount ).
|
||||
-- Returns 0 on success or negative integer on error which can be for
|
||||
-- malformed or truncated DNS (-2) or if more space for labels is needed (-3).
|
||||
function Dns:parse_header()
|
||||
return C.core_object_dns_parse_header(self)
|
||||
end
|
||||
|
||||
-- Parse the next resource record as a question.
|
||||
-- Returns 0 on success or negative integer on error which can be for
|
||||
-- malformed or truncated DNS (-2) or if more space for labels is needed (-3).
|
||||
function Dns:parse_q(q, labels, num_labels)
|
||||
return C.core_object_dns_parse_q(self, q, labels, num_labels)
|
||||
end
|
||||
|
||||
-- Parse the next resource record.
|
||||
-- Returns 0 on success or negative integer on error which can be for
|
||||
-- malformed or truncated DNS (-2) or if more space for labels is needed (-3).
|
||||
function Dns:parse_rr(rr, labels, num_labels)
|
||||
return C.core_object_dns_parse_rr(self, rr, labels, num_labels)
|
||||
end
|
||||
|
||||
-- Begin parsing the underlaying object using
|
||||
-- .IR parse_header "(), "
|
||||
-- .IR parse_q ()
|
||||
-- and
|
||||
-- .IR parse_rr ().
|
||||
-- The optional
|
||||
-- .I num_labels
|
||||
-- can be used to set a specific number of labels used for each question
|
||||
-- and resource record (default 16).
|
||||
-- Returns result code, an array of questions, an array of question labels,
|
||||
-- an array of resource records and an array of resource records labels.
|
||||
-- Result code is 0 on success or negative integer on error which can be for
|
||||
-- malformed or truncated DNS (-2) or if more space for labels is needed (-3).
|
||||
function Dns:parse(num_labels)
|
||||
local qs, qls, rrs, rrls = {}, {}, {}, {}
|
||||
if num_labels == nil then
|
||||
num_labels = 16
|
||||
end
|
||||
|
||||
ret = self:parse_header()
|
||||
if ret ~= 0 then
|
||||
return ret, qs, qls, rrs, rrls
|
||||
end
|
||||
for n = 1, self.qdcount do
|
||||
local labels = label.new(num_labels)
|
||||
local q = Q.new()
|
||||
local ret = C.core_object_dns_parse_q(self, q, labels, num_labels)
|
||||
|
||||
if ret ~= 0 then
|
||||
return ret, qs, qls, rrs, rrls
|
||||
end
|
||||
table.insert(qs, q)
|
||||
table.insert(qls, labels)
|
||||
end
|
||||
for n = 1, self.ancount do
|
||||
local labels = label.new(num_labels)
|
||||
local rr = RR.new()
|
||||
local ret = C.core_object_dns_parse_rr(self, rr, labels, num_labels)
|
||||
|
||||
if ret ~= 0 then
|
||||
return ret, qs, qls, rrs, rrls
|
||||
end
|
||||
table.insert(rrs, rr)
|
||||
table.insert(rrls, labels)
|
||||
end
|
||||
for n = 1, self.nscount do
|
||||
local labels = label.new(num_labels)
|
||||
local rr = RR.new()
|
||||
local ret = C.core_object_dns_parse_rr(self, rr, labels, num_labels)
|
||||
|
||||
if ret ~= 0 then
|
||||
return ret, qs, qls, rrs, rrls
|
||||
end
|
||||
table.insert(rrs, rr)
|
||||
table.insert(rrls, labels)
|
||||
end
|
||||
for n = 1, self.arcount do
|
||||
local labels = label.new(num_labels)
|
||||
local rr = RR.new()
|
||||
local ret = C.core_object_dns_parse_rr(self, rr, labels, num_labels)
|
||||
|
||||
if ret ~= 0 then
|
||||
return ret, qs, qls, rrs, rrls
|
||||
end
|
||||
table.insert(rrs, rr)
|
||||
table.insert(rrls, labels)
|
||||
end
|
||||
|
||||
return 0, qs, qls, rrs, rrls
|
||||
end
|
||||
|
||||
-- Begin parsing the underlaying object using
|
||||
-- .IR parse_header "(), "
|
||||
-- .IR parse_q ()
|
||||
-- and
|
||||
-- .IR parse_rr (),
|
||||
-- and print it's content.
|
||||
-- The optional
|
||||
-- .I num_labels
|
||||
-- can be used to set a specific number of labels used for each question
|
||||
-- and resource record (default 16).
|
||||
function Dns:print(num_labels)
|
||||
if num_labels == nil then
|
||||
num_labels = 16
|
||||
end
|
||||
local labels = label.new(num_labels)
|
||||
local q = Q.new()
|
||||
local rr = RR.new()
|
||||
|
||||
if self:parse_header() ~= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local flags = {}
|
||||
if self.have_aa and self.aa == 1 then
|
||||
table.insert(flags, "AA")
|
||||
end
|
||||
if self.have_tc and self.tc == 1 then
|
||||
table.insert(flags, "TC")
|
||||
end
|
||||
if self.have_rd and self.rd == 1 then
|
||||
table.insert(flags, "RD")
|
||||
end
|
||||
if self.have_ra and self.ra == 1 then
|
||||
table.insert(flags, "RA")
|
||||
end
|
||||
if self.have_z and self.z == 1 then
|
||||
table.insert(flags, "Z")
|
||||
end
|
||||
if self.have_ad and self.ad == 1 then
|
||||
table.insert(flags, "AD")
|
||||
end
|
||||
if self.have_cd and self.cd == 1 then
|
||||
table.insert(flags, "CD")
|
||||
end
|
||||
|
||||
print("id:", self.id)
|
||||
print("", "qr:", self.qr)
|
||||
print("", "opcode:", Dns.opcode_tostring(self.opcode))
|
||||
print("", "flags:", table.concat(flags, " "))
|
||||
print("", "rcode:", Dns.rcode_tostring(self.rcode))
|
||||
print("", "qdcount:", self.qdcount)
|
||||
print("", "ancount:", self.ancount)
|
||||
print("", "nscount:", self.nscount)
|
||||
print("", "arcount:", self.arcount)
|
||||
|
||||
if self.qdcount > 0 then
|
||||
print("questions:", "class", "type", "labels")
|
||||
for n = 1, self.qdcount do
|
||||
if C.core_object_dns_parse_q(self, q, labels, num_labels) ~= 0 then
|
||||
return
|
||||
end
|
||||
print("", Dns.class_tostring(q.class), Dns.type_tostring(q.type), label.tooffstr(self, labels, num_labels))
|
||||
end
|
||||
end
|
||||
if self.ancount > 0 then
|
||||
print("answers:", "class", "type", "ttl", "labels", "RR labels")
|
||||
for n = 1, self.ancount do
|
||||
if C.core_object_dns_parse_rr(self, rr, labels, num_labels) ~= 0 then
|
||||
return
|
||||
end
|
||||
if rr.rdata_labels == 0 then
|
||||
print("", Dns.class_tostring(rr.class), Dns.type_tostring(rr.type), rr.ttl, label.tooffstr(self, labels, rr.labels))
|
||||
else
|
||||
print("", Dns.class_tostring(rr.class), Dns.type_tostring(rr.type), rr.ttl, label.tooffstr(self, labels, rr.labels), label.tooffstr(self, labels, rr.rdata_labels, rr.labels))
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.nscount > 0 then
|
||||
print("authorities:", "class", "type", "ttl", "labels", "RR labels")
|
||||
for n = 1, self.nscount do
|
||||
if C.core_object_dns_parse_rr(self, rr, labels, num_labels) ~= 0 then
|
||||
return
|
||||
end
|
||||
if rr.rdata_labels == 0 then
|
||||
print("", Dns.class_tostring(rr.class), Dns.type_tostring(rr.type), rr.ttl, label.tooffstr(self, labels, rr.labels))
|
||||
else
|
||||
print("", Dns.class_tostring(rr.class), Dns.type_tostring(rr.type), rr.ttl, label.tooffstr(self, labels, rr.labels), label.tooffstr(self, labels, rr.rdata_labels, rr.labels))
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.arcount > 0 then
|
||||
print("additionals:", "class", "type", "ttl", "labels", "RR labels")
|
||||
for n = 1, self.arcount do
|
||||
if C.core_object_dns_parse_rr(self, rr, labels, num_labels) ~= 0 then
|
||||
return
|
||||
end
|
||||
if rr.rdata_labels == 0 then
|
||||
print("", Dns.class_tostring(rr.class), Dns.type_tostring(rr.type), rr.ttl, label.tooffstr(self, labels, rr.labels))
|
||||
else
|
||||
print("", Dns.class_tostring(rr.class), Dns.type_tostring(rr.type), rr.ttl, label.tooffstr(self, labels, rr.labels), label.tooffstr(self, labels, rr.rdata_labels, rr.labels))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Return the textual name for a class.
|
||||
function Dns.class_tostring(class)
|
||||
if Dns.CLASS_STR[class] == nil then
|
||||
return "UNKNOWN("..class..")"
|
||||
end
|
||||
return Dns.CLASS_STR[class]
|
||||
end
|
||||
|
||||
-- Return the textual name for a type.
|
||||
function Dns.type_tostring(type)
|
||||
if Dns.TYPE_STR[type] == nil then
|
||||
return "UNKNOWN("..type..")"
|
||||
end
|
||||
return Dns.TYPE_STR[type]
|
||||
end
|
||||
|
||||
-- Return the textual name for an opcode.
|
||||
function Dns.opcode_tostring(opcode)
|
||||
if Dns.OPCODE_STR[opcode] == nil then
|
||||
return "UNKNOWN("..opcode..")"
|
||||
end
|
||||
return Dns.OPCODE_STR[opcode]
|
||||
end
|
||||
|
||||
-- Return the textual name for a rcode.
|
||||
function Dns.rcode_tostring(rcode)
|
||||
if Dns.RCODE_STR[rcode] == nil then
|
||||
return "UNKNOWN("..rcode..")"
|
||||
end
|
||||
return Dns.RCODE_STR[rcode]
|
||||
end
|
||||
|
||||
-- Return the textual name for an afsdb subtype.
|
||||
function Dns.afsdb_tostring(afsdb)
|
||||
if Dns.AFSDB_STR[afsdb] == nil then
|
||||
return "UNKNOWN("..afsdb..")"
|
||||
end
|
||||
return Dns.AFSDB_STR[afsdb]
|
||||
end
|
||||
|
||||
-- Return the textual name for a dhcid type.
|
||||
function Dns.dhcid_tostring(dhcid)
|
||||
if Dns.DHCID_STR[dhcid] == nil then
|
||||
return "UNKNOWN("..dhcid..")"
|
||||
end
|
||||
return Dns.DHCID_STR[dhcid]
|
||||
end
|
||||
|
||||
-- Return the textual name for an EDNS0 OPT record.
|
||||
function Dns.edns0_tostring(edns0)
|
||||
if Dns.EDNS0_STR[edns0] == nil then
|
||||
return "UNKNOWN("..edns0..")"
|
||||
end
|
||||
return Dns.EDNS0_STR[edns0]
|
||||
end
|
||||
|
||||
core_object_dns_t = ffi.metatype(t_name, { __index = Dns })
|
||||
|
||||
-- dnsjit.core.object (3),
|
||||
-- dnsjit.core.object.payload (3),
|
||||
-- dnsjit.core.object.dns.label (3),
|
||||
-- dnsjit.core.object.dns.q (3),
|
||||
-- dnsjit.core.object.dns.rr (3)
|
||||
return Dns
|
118
include/dnsjit/core/object/dns/label.lua
Normal file
118
include/dnsjit/core/object/dns/label.lua
Normal file
|
@ -0,0 +1,118 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.dns.label
|
||||
-- Container of a DNS label
|
||||
--
|
||||
-- The object that describes a DNS label.
|
||||
-- To extract a domain name label first check that
|
||||
-- .I have_dn
|
||||
-- is set, then use
|
||||
-- .I "offset + 1"
|
||||
-- to indicate where in the payload the label start and
|
||||
-- .I length
|
||||
-- for how many bytes long it is.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- is_end
|
||||
-- .TP
|
||||
-- have_length
|
||||
-- Set if there is a length.
|
||||
-- .TP
|
||||
-- have_offset
|
||||
-- Set if there is an offset.
|
||||
-- .TP
|
||||
-- have_extension_bits
|
||||
-- Set if there is extension bits.
|
||||
-- .TP
|
||||
-- have_dn
|
||||
-- Set if the label contained a domain name.
|
||||
-- .TP
|
||||
-- extension_bits
|
||||
-- The extension bits.
|
||||
-- .TP
|
||||
-- length
|
||||
-- The length of the domain name.
|
||||
-- .TP
|
||||
-- offset
|
||||
-- If
|
||||
-- .I have_dn
|
||||
-- is set then this contains the offset within the payload to where this label
|
||||
-- start otherwise it contains the offset to another label.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.dns_h")
|
||||
local ffi = require("ffi")
|
||||
|
||||
local Label = {}
|
||||
|
||||
-- Create a new array of labels.
|
||||
function Label.new(size)
|
||||
return ffi.new("core_object_dns_label_t[?]", size)
|
||||
end
|
||||
|
||||
-- Returns labels as a string and an offset to the next label.
|
||||
-- The string may be nil if the first label was an offset.
|
||||
-- The offset may be nil if the last label was an extension bits or end marker.
|
||||
function Label.tostring(dns, labels, num_labels, offset_labels)
|
||||
if offset_labels == nil then
|
||||
offset_labels = 0
|
||||
end
|
||||
local dn
|
||||
for n = 1, tonumber(num_labels) do
|
||||
local label = labels[n - 1 + offset_labels]
|
||||
|
||||
if label.have_dn == 1 then
|
||||
if dn == nil then
|
||||
dn = ""
|
||||
end
|
||||
dn = dn .. ffi.string(dns.payload + label.offset + 1, label.length) .. "."
|
||||
elseif label.have_offset == 1 then
|
||||
return dn, label.offset
|
||||
else
|
||||
return dn, nil
|
||||
end
|
||||
end
|
||||
return dn, nil
|
||||
end
|
||||
|
||||
-- Returns labels as a string which also includes a textual notation of the
|
||||
-- offset in the form of
|
||||
-- .IR "<offset>label" .
|
||||
function Label.tooffstr(dns, labels, num_labels, offset_labels)
|
||||
if offset_labels == nil then
|
||||
offset_labels = 0
|
||||
end
|
||||
local dn = ""
|
||||
for n = 1, tonumber(num_labels) do
|
||||
local label = labels[n - 1 + offset_labels]
|
||||
|
||||
if label.have_dn == 1 then
|
||||
dn = dn .. "<" .. tonumber(label.offset) .. ">" .. ffi.string(dns.payload + label.offset + 1, label.length) .. "."
|
||||
elseif label.have_offset == 1 then
|
||||
dn = dn .. "<" .. tonumber(label.offset) .. ">"
|
||||
break
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
return dn
|
||||
end
|
||||
|
||||
-- dnsjit.core.object.dns (3)
|
||||
return Label
|
52
include/dnsjit/core/object/dns/q.lua
Normal file
52
include/dnsjit/core/object/dns/q.lua
Normal file
|
@ -0,0 +1,52 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.dns.q
|
||||
-- Container of a DNS question
|
||||
--
|
||||
-- The object that describes a DNS question.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- have_type
|
||||
-- Set if there is a type.
|
||||
-- .TP
|
||||
-- have_class
|
||||
-- Set if there is a class.
|
||||
-- .TP
|
||||
-- type
|
||||
-- The type.
|
||||
-- .TP
|
||||
-- class
|
||||
-- The class.
|
||||
-- .TP
|
||||
-- labels
|
||||
-- The number of labels found in the question.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.dns_h")
|
||||
local ffi = require("ffi")
|
||||
|
||||
local Q = {}
|
||||
|
||||
-- Create a new question.
|
||||
function Q.new(size)
|
||||
return ffi.new("core_object_dns_q_t")
|
||||
end
|
||||
|
||||
-- dnsjit.core.object.dns (3)
|
||||
return Q
|
85
include/dnsjit/core/object/dns/rr.lua
Normal file
85
include/dnsjit/core/object/dns/rr.lua
Normal file
|
@ -0,0 +1,85 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.dns.rr
|
||||
-- Container of a DNS resource record
|
||||
--
|
||||
-- The object that describes a DNS resource record.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- have_type
|
||||
-- Set if there is a type.
|
||||
-- .TP
|
||||
-- have_class
|
||||
-- Set if there is a class.
|
||||
-- .TP
|
||||
-- have_ttl
|
||||
-- Set if there is a ttl.
|
||||
-- .TP
|
||||
-- have_rdlength
|
||||
-- Set if there is a rdlength.
|
||||
-- .TP
|
||||
-- have_rdata
|
||||
-- Set if there is resource record data.
|
||||
-- .TP
|
||||
-- have_rdata_labels
|
||||
-- Set if there are any labels within the rdata.
|
||||
-- .TP
|
||||
-- have_padding
|
||||
-- Set if there is padding.
|
||||
-- .TP
|
||||
-- type
|
||||
-- The type.
|
||||
-- .TP
|
||||
-- class
|
||||
-- The class.
|
||||
-- .TP
|
||||
-- ttl
|
||||
-- The TTL.
|
||||
-- .TP
|
||||
-- rdlength
|
||||
-- The resource record data length.
|
||||
-- .TP
|
||||
-- labels
|
||||
-- The number of labels found in the record.
|
||||
-- .TP
|
||||
-- rdata_offset
|
||||
-- The offset within the payload for the resource record data.
|
||||
-- .TP
|
||||
-- rdata_labels
|
||||
-- The number of labels found inside the resource record data.
|
||||
-- .TP
|
||||
-- padding_offset
|
||||
-- The offset within the payload where the padding starts.
|
||||
-- .TP
|
||||
-- padding_length
|
||||
-- The length of the padding.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.dns_h")
|
||||
local ffi = require("ffi")
|
||||
|
||||
local Rr = {}
|
||||
|
||||
-- Create a new resource record.
|
||||
function Rr.new()
|
||||
return ffi.new("core_object_dns_rr_t")
|
||||
end
|
||||
|
||||
-- dnsjit.core.object.dns (3)
|
||||
return Rr
|
45
include/dnsjit/core/object/ether.c
Normal file
45
include/dnsjit/core/object/ether.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/object/ether.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
core_object_ether_t* core_object_ether_copy(const core_object_ether_t* self)
|
||||
{
|
||||
core_object_ether_t* copy;
|
||||
glassert_self();
|
||||
|
||||
glfatal_oom(copy = malloc(sizeof(core_object_ether_t)));
|
||||
memcpy(copy, self, sizeof(core_object_ether_t));
|
||||
copy->obj_prev = 0;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void core_object_ether_free(core_object_ether_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
free(self);
|
||||
}
|
38
include/dnsjit/core/object/ether.h
Normal file
38
include/dnsjit/core/object/ether.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/object.h>
|
||||
#include <dnsjit/core/timespec.h>
|
||||
|
||||
#ifndef __dnsjit_core_object_ether_h
|
||||
#define __dnsjit_core_object_ether_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <dnsjit/core/object/ether.hh>
|
||||
|
||||
#define CORE_OBJECT_ETHER_INIT(prev) \
|
||||
{ \
|
||||
CORE_OBJECT_INIT(CORE_OBJECT_ETHER, prev) \
|
||||
, \
|
||||
{ 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 }, 0 \
|
||||
}
|
||||
|
||||
#endif
|
33
include/dnsjit/core/object/ether.hh
Normal file
33
include/dnsjit/core/object/ether.hh
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.object_h")
|
||||
|
||||
typedef struct core_object_ether {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
|
||||
uint8_t dhost[6];
|
||||
uint8_t shost[6];
|
||||
uint16_t type;
|
||||
} core_object_ether_t;
|
||||
|
||||
core_object_ether_t* core_object_ether_copy(const core_object_ether_t* self);
|
||||
void core_object_ether_free(core_object_ether_t* self);
|
78
include/dnsjit/core/object/ether.lua
Normal file
78
include/dnsjit/core/object/ether.lua
Normal file
|
@ -0,0 +1,78 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.ether
|
||||
-- Ether part of a packet
|
||||
--
|
||||
-- The ether part of a packet that usually can be found in the object chain
|
||||
-- after parsing with, for example, Layer filter.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- dhost
|
||||
-- The destination ether address.
|
||||
-- .TP
|
||||
-- shost
|
||||
-- The source ether address.
|
||||
-- .TP
|
||||
-- type
|
||||
-- The packet type ID field / EtherType field.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.ether_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local t_name = "core_object_ether_t"
|
||||
local core_object_ether_t
|
||||
local Ether = {}
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Ether:type()
|
||||
return "ether"
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Ether:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Ether:cast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Ether:uncast()
|
||||
return ffi.cast("core_object_t*", self)
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Ether:copy()
|
||||
return C.core_object_ether_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Ether:free()
|
||||
C.core_object_ether_free(self)
|
||||
end
|
||||
|
||||
core_object_ether_t = ffi.metatype(t_name, { __index = Ether })
|
||||
|
||||
-- dnsjit.core.object (3),
|
||||
-- dnsjit.filter.layer (3)
|
||||
return Ether
|
|
@ -18,20 +18,28 @@
|
|||
* along with dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.log")
|
||||
//lua:require("dnsjit.core.receiver_h")
|
||||
//lua:require("dnsjit.core.producer_h")
|
||||
#include "config.h"
|
||||
|
||||
typedef struct output_null {
|
||||
core_log_t _log;
|
||||
core_producer_t prod;
|
||||
void* ctx;
|
||||
size_t pkts;
|
||||
} output_null_t;
|
||||
#include "core/object/gre.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
core_log_t* output_null_log();
|
||||
void output_null_init(output_null_t* self);
|
||||
void output_null_destroy(output_null_t* self);
|
||||
void output_null_run(output_null_t* self, int64_t num);
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
core_receiver_t output_null_receiver();
|
||||
core_object_gre_t* core_object_gre_copy(const core_object_gre_t* self)
|
||||
{
|
||||
core_object_gre_t* copy;
|
||||
glassert_self();
|
||||
|
||||
glfatal_oom(copy = malloc(sizeof(core_object_gre_t)));
|
||||
memcpy(copy, self, sizeof(core_object_gre_t));
|
||||
copy->obj_prev = 0;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void core_object_gre_free(core_object_gre_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
free(self);
|
||||
}
|
38
include/dnsjit/core/object/gre.h
Normal file
38
include/dnsjit/core/object/gre.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/object.h>
|
||||
#include <dnsjit/core/timespec.h>
|
||||
|
||||
#ifndef __dnsjit_core_object_gre_h
|
||||
#define __dnsjit_core_object_gre_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <dnsjit/core/object/gre.hh>
|
||||
|
||||
#define CORE_OBJECT_GRE_INIT(prev) \
|
||||
{ \
|
||||
CORE_OBJECT_INIT(CORE_OBJECT_GRE, prev) \
|
||||
, \
|
||||
0, 0, 0, 0, 0 \
|
||||
}
|
||||
|
||||
#endif
|
37
include/dnsjit/core/object/gre.hh
Normal file
37
include/dnsjit/core/object/gre.hh
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.object_h")
|
||||
|
||||
typedef struct core_object_gre {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
|
||||
uint16_t gre_flags;
|
||||
uint16_t ether_type;
|
||||
uint16_t checksum;
|
||||
uint16_t offset;
|
||||
uint32_t key;
|
||||
uint32_t sequence;
|
||||
// TODO: routing list, check RFC 1701.
|
||||
} core_object_gre_t;
|
||||
|
||||
core_object_gre_t* core_object_gre_copy(const core_object_gre_t* self);
|
||||
void core_object_gre_free(core_object_gre_t* self);
|
87
include/dnsjit/core/object/gre.lua
Normal file
87
include/dnsjit/core/object/gre.lua
Normal file
|
@ -0,0 +1,87 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.gre
|
||||
-- Generic Routing Encapsulation (GRE) part of a packet
|
||||
--
|
||||
-- The GRE part of a packet that usually can be found in the object chain
|
||||
-- after parsing with, for example, Layer filter.
|
||||
-- See RFC 1701.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- gre_flags
|
||||
-- The GRE flags.
|
||||
-- .TP
|
||||
-- ether_type
|
||||
-- The protocol type of the payload packet.
|
||||
-- .TP
|
||||
-- checksum
|
||||
-- The checksum of the GRE header and the payload packet.
|
||||
-- .TP
|
||||
-- key
|
||||
-- The Key field contains a four octet number which was inserted by
|
||||
-- the encapsulator.
|
||||
-- .TP
|
||||
-- sequence
|
||||
-- The Sequence Number field contains an unsigned 32 bit integer which is
|
||||
-- inserted by the encapsulator.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.gre_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local t_name = "core_object_gre_t"
|
||||
local core_object_gre_t
|
||||
local Gre = {}
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Gre:type()
|
||||
return "gre"
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Gre:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Gre:cast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Gre:uncast()
|
||||
return ffi.cast("core_object_t*", self)
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Gre:copy()
|
||||
return C.core_object_gre_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Gre:free()
|
||||
C.core_object_gre_free(self)
|
||||
end
|
||||
|
||||
core_object_gre_t = ffi.metatype(t_name, { __index = Gre })
|
||||
|
||||
-- dnsjit.core.object (3),
|
||||
-- dnsjit.filter.layer (3)
|
||||
return Gre
|
45
include/dnsjit/core/object/icmp.c
Normal file
45
include/dnsjit/core/object/icmp.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/object/icmp.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
core_object_icmp_t* core_object_icmp_copy(const core_object_icmp_t* self)
|
||||
{
|
||||
core_object_icmp_t* copy;
|
||||
glassert_self();
|
||||
|
||||
glfatal_oom(copy = malloc(sizeof(core_object_icmp_t)));
|
||||
memcpy(copy, self, sizeof(core_object_icmp_t));
|
||||
copy->obj_prev = 0;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void core_object_icmp_free(core_object_icmp_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
free(self);
|
||||
}
|
38
include/dnsjit/core/object/icmp.h
Normal file
38
include/dnsjit/core/object/icmp.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/object.h>
|
||||
#include <dnsjit/core/timespec.h>
|
||||
|
||||
#ifndef __dnsjit_core_object_icmp_h
|
||||
#define __dnsjit_core_object_icmp_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <dnsjit/core/object/icmp.hh>
|
||||
|
||||
#define CORE_OBJECT_ICMP_INIT(prev) \
|
||||
{ \
|
||||
CORE_OBJECT_INIT(CORE_OBJECT_ICMP, prev) \
|
||||
, \
|
||||
0, 0, 0 \
|
||||
}
|
||||
|
||||
#endif
|
33
include/dnsjit/core/object/icmp.hh
Normal file
33
include/dnsjit/core/object/icmp.hh
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.object_h")
|
||||
|
||||
typedef struct core_object_icmp {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
|
||||
uint8_t type;
|
||||
uint8_t code;
|
||||
uint16_t cksum;
|
||||
} core_object_icmp_t;
|
||||
|
||||
core_object_icmp_t* core_object_icmp_copy(const core_object_icmp_t* self);
|
||||
void core_object_icmp_free(core_object_icmp_t* self);
|
78
include/dnsjit/core/object/icmp.lua
Normal file
78
include/dnsjit/core/object/icmp.lua
Normal file
|
@ -0,0 +1,78 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.icmp
|
||||
-- An ICMP packet
|
||||
--
|
||||
-- An ICMP packet which is usually at the top of the object chain
|
||||
-- after parsing with, for example, Layer filter.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- type
|
||||
-- The type of ICMP message.
|
||||
-- .TP
|
||||
-- code
|
||||
-- The (response/error) code for the ICMP type message.
|
||||
-- .TP
|
||||
-- cksum
|
||||
-- The ICMP checksum.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.icmp_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local t_name = "core_object_icmp_t"
|
||||
local core_object_icmp_t
|
||||
local Icmp = {}
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Icmp:type()
|
||||
return "icmp"
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Icmp:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Icmp:cast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Icmp:uncast()
|
||||
return ffi.cast("core_object_t*", self)
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Icmp:copy()
|
||||
return C.core_object_icmp_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Icmp:free()
|
||||
C.core_object_icmp_free(self)
|
||||
end
|
||||
|
||||
core_object_icmp_t = ffi.metatype(t_name, { __index = Icmp })
|
||||
|
||||
-- dnsjit.core.object (3),
|
||||
-- dnsjit.filter.layer (3)
|
||||
return Icmp
|
45
include/dnsjit/core/object/icmp6.c
Normal file
45
include/dnsjit/core/object/icmp6.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/object/icmp6.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
core_object_icmp6_t* core_object_icmp6_copy(const core_object_icmp6_t* self)
|
||||
{
|
||||
core_object_icmp6_t* copy;
|
||||
glassert_self();
|
||||
|
||||
glfatal_oom(copy = malloc(sizeof(core_object_icmp6_t)));
|
||||
memcpy(copy, self, sizeof(core_object_icmp6_t));
|
||||
copy->obj_prev = 0;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void core_object_icmp6_free(core_object_icmp6_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
free(self);
|
||||
}
|
38
include/dnsjit/core/object/icmp6.h
Normal file
38
include/dnsjit/core/object/icmp6.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/object.h>
|
||||
#include <dnsjit/core/timespec.h>
|
||||
|
||||
#ifndef __dnsjit_core_object_icmp6_h
|
||||
#define __dnsjit_core_object_icmp6_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <dnsjit/core/object/icmp6.hh>
|
||||
|
||||
#define CORE_OBJECT_ICMP6_INIT(prev) \
|
||||
{ \
|
||||
CORE_OBJECT_INIT(CORE_OBJECT_ICMP6, prev) \
|
||||
, \
|
||||
0, 0, 0 \
|
||||
}
|
||||
|
||||
#endif
|
33
include/dnsjit/core/object/icmp6.hh
Normal file
33
include/dnsjit/core/object/icmp6.hh
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.object_h")
|
||||
|
||||
typedef struct core_object_icmp6 {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
|
||||
uint8_t type;
|
||||
uint8_t code;
|
||||
uint16_t cksum;
|
||||
} core_object_icmp6_t;
|
||||
|
||||
core_object_icmp6_t* core_object_icmp6_copy(const core_object_icmp6_t* self);
|
||||
void core_object_icmp6_free(core_object_icmp6_t* self);
|
78
include/dnsjit/core/object/icmp6.lua
Normal file
78
include/dnsjit/core/object/icmp6.lua
Normal file
|
@ -0,0 +1,78 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.icmp6
|
||||
-- An ICMPv6 packet
|
||||
--
|
||||
-- An ICMPv6 packet which is usually at the top of the object chain
|
||||
-- after parsing with, for example, Layer filter.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- type
|
||||
-- The type of ICMPv6 message.
|
||||
-- .TP
|
||||
-- code
|
||||
-- The (response/error) code for the ICMPv6 type message.
|
||||
-- .TP
|
||||
-- cksum
|
||||
-- The ICMPv6 checksum.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.icmp6_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local t_name = "core_object_icmp6_t"
|
||||
local core_object_icmp6_t
|
||||
local Icmp6 = {}
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Icmp6:type()
|
||||
return "icmp6"
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Icmp6:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Icmp6:cast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Icmp6:uncast()
|
||||
return ffi.cast("core_object_t*", self)
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Icmp6:copy()
|
||||
return C.core_object_icmp6_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Icmp6:free()
|
||||
C.core_object_icmp6_free(self)
|
||||
end
|
||||
|
||||
core_object_icmp6_t = ffi.metatype(t_name, { __index = Icmp6 })
|
||||
|
||||
-- dnsjit.core.object (3),
|
||||
-- dnsjit.filter.layer (3)
|
||||
return Icmp6
|
45
include/dnsjit/core/object/ieee802.c
Normal file
45
include/dnsjit/core/object/ieee802.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/object/ieee802.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
core_object_ieee802_t* core_object_ieee802_copy(const core_object_ieee802_t* self)
|
||||
{
|
||||
core_object_ieee802_t* copy;
|
||||
glassert_self();
|
||||
|
||||
glfatal_oom(copy = malloc(sizeof(core_object_ieee802_t)));
|
||||
memcpy(copy, self, sizeof(core_object_ieee802_t));
|
||||
copy->obj_prev = 0;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void core_object_ieee802_free(core_object_ieee802_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
free(self);
|
||||
}
|
38
include/dnsjit/core/object/ieee802.h
Normal file
38
include/dnsjit/core/object/ieee802.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/object.h>
|
||||
#include <dnsjit/core/timespec.h>
|
||||
|
||||
#ifndef __dnsjit_core_object_ieee802_h
|
||||
#define __dnsjit_core_object_ieee802_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <dnsjit/core/object/ieee802.hh>
|
||||
|
||||
#define CORE_OBJECT_IEEE802_INIT(prev) \
|
||||
{ \
|
||||
CORE_OBJECT_INIT(CORE_OBJECT_IEEE802, prev) \
|
||||
, \
|
||||
0, 0, 0, 0, 0 \
|
||||
}
|
||||
|
||||
#endif
|
35
include/dnsjit/core/object/ieee802.hh
Normal file
35
include/dnsjit/core/object/ieee802.hh
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.object_h")
|
||||
|
||||
typedef struct core_object_ieee802 {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
|
||||
uint16_t tpid;
|
||||
uint8_t pcp;
|
||||
uint8_t dei;
|
||||
uint8_t vid;
|
||||
uint16_t ether_type;
|
||||
} core_object_ieee802_t;
|
||||
|
||||
core_object_ieee802_t* core_object_ieee802_copy(const core_object_ieee802_t* self);
|
||||
void core_object_ieee802_free(core_object_ieee802_t* self);
|
84
include/dnsjit/core/object/ieee802.lua
Normal file
84
include/dnsjit/core/object/ieee802.lua
Normal file
|
@ -0,0 +1,84 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.ieee802
|
||||
-- IEEE802 part of a packet
|
||||
--
|
||||
-- The IEEE802 part of a packet that usually can be found in the object chain
|
||||
-- after parsing with, for example, Layer filter.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- tpid
|
||||
-- Tag protocol identifier.
|
||||
-- .TP
|
||||
-- pcp
|
||||
-- Priority code point.
|
||||
-- .TP
|
||||
-- dei
|
||||
-- Drop eligible indicator.
|
||||
-- .TP
|
||||
-- vid
|
||||
-- VLAN identifier.
|
||||
-- .TP
|
||||
-- ether_type
|
||||
-- The packet type ID field / EtherType field.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.ieee802_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local t_name = "core_object_ieee802_t"
|
||||
local core_object_ieee802_t
|
||||
local Ieee802 = {}
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Ieee802:type()
|
||||
return "ieee802"
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Ieee802:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Ieee802:cast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Ieee802:uncast()
|
||||
return ffi.cast("core_object_t*", self)
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Ieee802:copy()
|
||||
return C.core_object_ieee802_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Ieee802:free()
|
||||
C.core_object_ieee802_free(self)
|
||||
end
|
||||
|
||||
core_object_ieee802_t = ffi.metatype(t_name, { __index = Ieee802 })
|
||||
|
||||
-- dnsjit.core.object (3),
|
||||
-- dnsjit.filter.layer (3)
|
||||
return Ieee802
|
45
include/dnsjit/core/object/ip.c
Normal file
45
include/dnsjit/core/object/ip.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/object/ip.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
core_object_ip_t* core_object_ip_copy(const core_object_ip_t* self)
|
||||
{
|
||||
core_object_ip_t* copy;
|
||||
glassert_self();
|
||||
|
||||
glfatal_oom(copy = malloc(sizeof(core_object_ip_t)));
|
||||
memcpy(copy, self, sizeof(core_object_ip_t));
|
||||
copy->obj_prev = 0;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void core_object_ip_free(core_object_ip_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
free(self);
|
||||
}
|
38
include/dnsjit/core/object/ip.h
Normal file
38
include/dnsjit/core/object/ip.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/object.h>
|
||||
#include <dnsjit/core/timespec.h>
|
||||
|
||||
#ifndef __dnsjit_core_object_ip_h
|
||||
#define __dnsjit_core_object_ip_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <dnsjit/core/object/ip.hh>
|
||||
|
||||
#define CORE_OBJECT_IP_INIT(prev) \
|
||||
{ \
|
||||
CORE_OBJECT_INIT(CORE_OBJECT_IP, prev) \
|
||||
, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, \
|
||||
}
|
||||
|
||||
#endif
|
40
include/dnsjit/core/object/ip.hh
Normal file
40
include/dnsjit/core/object/ip.hh
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.object_h")
|
||||
|
||||
typedef struct core_object_ip {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
|
||||
uint8_t v;
|
||||
uint8_t hl;
|
||||
uint8_t tos;
|
||||
uint16_t len;
|
||||
uint16_t id;
|
||||
uint16_t off;
|
||||
uint8_t ttl;
|
||||
uint8_t p;
|
||||
uint16_t sum;
|
||||
uint8_t src[4], dst[4];
|
||||
} core_object_ip_t;
|
||||
|
||||
core_object_ip_t* core_object_ip_copy(const core_object_ip_t* self);
|
||||
void core_object_ip_free(core_object_ip_t* self);
|
122
include/dnsjit/core/object/ip.lua
Normal file
122
include/dnsjit/core/object/ip.lua
Normal file
|
@ -0,0 +1,122 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.ip
|
||||
-- An IP packet
|
||||
--
|
||||
-- An IP packet that usually can be found in the object chain
|
||||
-- after parsing with, for example, Layer filter.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- v
|
||||
-- Version.
|
||||
-- .TP
|
||||
-- hl
|
||||
-- Header length.
|
||||
-- .TP
|
||||
-- tos
|
||||
-- Type of service.
|
||||
-- .TP
|
||||
-- len
|
||||
-- Total length.
|
||||
-- .TP
|
||||
-- id
|
||||
-- Identification.
|
||||
-- .TP
|
||||
-- off
|
||||
-- Fragment offset field.
|
||||
-- .TP
|
||||
-- ttl
|
||||
-- Time to live.
|
||||
-- .TP
|
||||
-- p
|
||||
-- Protocol.
|
||||
-- .TP
|
||||
-- sum
|
||||
-- Checksum.
|
||||
-- .TP
|
||||
-- src
|
||||
-- Source address.
|
||||
-- .TP
|
||||
-- dst
|
||||
-- Destination address.
|
||||
-- .TP
|
||||
-- payload
|
||||
-- A pointer to the payload.
|
||||
-- .TP
|
||||
-- plen
|
||||
-- The length of the payload.
|
||||
-- .TP
|
||||
-- pad_len
|
||||
-- The length of padding found, if any.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.ip_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
local libip = require("dnsjit.lib.ip")
|
||||
|
||||
local t_name = "core_object_ip_t"
|
||||
local core_object_ip_t
|
||||
local Ip = {}
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Ip:type()
|
||||
return "ip"
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Ip:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Ip:cast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Ip:uncast()
|
||||
return ffi.cast("core_object_t*", self)
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Ip:copy()
|
||||
return C.core_object_ip_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Ip:free()
|
||||
C.core_object_ip_free(self)
|
||||
end
|
||||
|
||||
-- Return the IP source as a string.
|
||||
function Ip:source()
|
||||
return libip.ipstring(self.src)
|
||||
end
|
||||
|
||||
-- Return the IP destination as a string.
|
||||
function Ip:destination()
|
||||
return libip.ipstring(self.dst)
|
||||
end
|
||||
|
||||
core_object_ip_t = ffi.metatype(t_name, { __index = Ip })
|
||||
|
||||
-- dnsjit.core.object (3),
|
||||
-- dnsjit.filter.layer (3)
|
||||
return Ip
|
45
include/dnsjit/core/object/ip6.c
Normal file
45
include/dnsjit/core/object/ip6.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/object/ip6.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
core_object_ip6_t* core_object_ip6_copy(const core_object_ip6_t* self)
|
||||
{
|
||||
core_object_ip6_t* copy;
|
||||
glassert_self();
|
||||
|
||||
glfatal_oom(copy = malloc(sizeof(core_object_ip6_t)));
|
||||
memcpy(copy, self, sizeof(core_object_ip6_t));
|
||||
copy->obj_prev = 0;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void core_object_ip6_free(core_object_ip6_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
free(self);
|
||||
}
|
42
include/dnsjit/core/object/ip6.h
Normal file
42
include/dnsjit/core/object/ip6.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/object.h>
|
||||
#include <dnsjit/core/timespec.h>
|
||||
|
||||
#ifndef __dnsjit_core_object_ip6_h
|
||||
#define __dnsjit_core_object_ip6_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <dnsjit/core/object/ip6.hh>
|
||||
|
||||
#define CORE_OBJECT_IP6_INIT(prev) \
|
||||
{ \
|
||||
CORE_OBJECT_INIT(CORE_OBJECT_IP6, prev) \
|
||||
, \
|
||||
0, 0, 0, 0, \
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \
|
||||
0, 0, 0, 0, \
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \
|
||||
}
|
||||
|
||||
#endif
|
42
include/dnsjit/core/object/ip6.hh
Normal file
42
include/dnsjit/core/object/ip6.hh
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.object_h")
|
||||
|
||||
typedef struct core_object_ip6 {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
|
||||
uint32_t flow;
|
||||
uint16_t plen;
|
||||
uint8_t nxt;
|
||||
uint8_t hlim;
|
||||
uint8_t src[16];
|
||||
uint8_t dst[16];
|
||||
|
||||
uint8_t is_frag;
|
||||
uint8_t have_rtdst;
|
||||
uint16_t frag_offlg;
|
||||
uint16_t frag_ident;
|
||||
uint8_t rtdst[16];
|
||||
} core_object_ip6_t;
|
||||
|
||||
core_object_ip6_t* core_object_ip6_copy(const core_object_ip6_t* self);
|
||||
void core_object_ip6_free(core_object_ip6_t* self);
|
130
include/dnsjit/core/object/ip6.lua
Normal file
130
include/dnsjit/core/object/ip6.lua
Normal file
|
@ -0,0 +1,130 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.ip6
|
||||
-- An IPv6 packet
|
||||
--
|
||||
-- An IPv6 packet that usually can be found in the object chain
|
||||
-- after parsing with, for example, Layer filter.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- flow
|
||||
-- 4 bits version, 8 bits TC and 20 bits flow-ID.
|
||||
-- .TP
|
||||
-- plen
|
||||
-- Payload length (as in the IPv6 header).
|
||||
-- .TP
|
||||
-- nxt
|
||||
-- Next header.
|
||||
-- .TP
|
||||
-- hlim
|
||||
-- Hop limit.
|
||||
-- .TP
|
||||
-- src
|
||||
-- Source address.
|
||||
-- .TP
|
||||
-- dst
|
||||
-- Destination address.
|
||||
-- .TP
|
||||
-- is_frag
|
||||
-- 1 bit, set if packet is a fragment.
|
||||
-- .TP
|
||||
-- have_rtdst
|
||||
-- 1 bit, set if
|
||||
-- .I rtdst
|
||||
-- is set.
|
||||
-- .TP
|
||||
-- frag_offlg
|
||||
-- Offset, reserved, and flag taken from the fragment header.
|
||||
-- .TP
|
||||
-- frag_ident
|
||||
-- Identification taken from the fragment header.
|
||||
-- .TP
|
||||
-- rtdst
|
||||
-- Destination address found in the routing extension header.
|
||||
-- .TP
|
||||
-- payload
|
||||
-- A pointer to the payload.
|
||||
-- .TP
|
||||
-- len
|
||||
-- The length of the payload.
|
||||
-- .TP
|
||||
-- pad_len
|
||||
-- The length of padding found, if any.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.ip6_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
local libip = require("dnsjit.lib.ip")
|
||||
|
||||
local t_name = "core_object_ip6_t"
|
||||
local core_object_ip6_t
|
||||
local Ip6 = {}
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Ip6:type()
|
||||
return "ip6"
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Ip6:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Ip6:cast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Ip6:uncast()
|
||||
return ffi.cast("core_object_t*", self)
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Ip6:copy()
|
||||
return C.core_object_ip6_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Ip6:free()
|
||||
C.core_object_ip6_free(self)
|
||||
end
|
||||
|
||||
-- Return the IPv6 source as a string.
|
||||
-- If
|
||||
-- .I pretty
|
||||
-- is true then return an easier to read IPv6 address.
|
||||
function Ip6:source(pretty)
|
||||
return libip.ip6string(self.src, pretty)
|
||||
end
|
||||
|
||||
-- Return the IPv6 destination as a string.
|
||||
-- If
|
||||
-- .I pretty
|
||||
-- is true then return an easier to read IPv6 address.
|
||||
function Ip6:destination(pretty)
|
||||
return libip.ip6string(self.dst, pretty)
|
||||
end
|
||||
|
||||
core_object_ip6_t = ffi.metatype(t_name, { __index = Ip6 })
|
||||
|
||||
-- dnsjit.core.object (3),
|
||||
-- dnsjit.filter.layer (3)
|
||||
return Ip6
|
45
include/dnsjit/core/object/linuxsll.c
Normal file
45
include/dnsjit/core/object/linuxsll.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/object/linuxsll.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
core_object_linuxsll_t* core_object_linuxsll_copy(const core_object_linuxsll_t* self)
|
||||
{
|
||||
core_object_linuxsll_t* copy;
|
||||
glassert_self();
|
||||
|
||||
glfatal_oom(copy = malloc(sizeof(core_object_linuxsll_t)));
|
||||
memcpy(copy, self, sizeof(core_object_linuxsll_t));
|
||||
copy->obj_prev = 0;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void core_object_linuxsll_free(core_object_linuxsll_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
free(self);
|
||||
}
|
38
include/dnsjit/core/object/linuxsll.h
Normal file
38
include/dnsjit/core/object/linuxsll.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/object.h>
|
||||
#include <dnsjit/core/timespec.h>
|
||||
|
||||
#ifndef __dnsjit_core_object_linuxsll_h
|
||||
#define __dnsjit_core_object_linuxsll_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <dnsjit/core/object/linuxsll.hh>
|
||||
|
||||
#define CORE_OBJECT_LINUXSLL_INIT(prev) \
|
||||
{ \
|
||||
CORE_OBJECT_INIT(CORE_OBJECT_LINUXSLL, prev) \
|
||||
, \
|
||||
0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 }, 0 \
|
||||
}
|
||||
|
||||
#endif
|
35
include/dnsjit/core/object/linuxsll.hh
Normal file
35
include/dnsjit/core/object/linuxsll.hh
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.object_h")
|
||||
|
||||
typedef struct core_object_linuxsll {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
|
||||
uint16_t packet_type;
|
||||
uint16_t arp_hardware;
|
||||
uint16_t link_layer_address_length;
|
||||
uint8_t link_layer_address[8];
|
||||
uint16_t ether_type;
|
||||
} core_object_linuxsll_t;
|
||||
|
||||
core_object_linuxsll_t* core_object_linuxsll_copy(const core_object_linuxsll_t* self);
|
||||
void core_object_linuxsll_free(core_object_linuxsll_t* self);
|
84
include/dnsjit/core/object/linuxsll.lua
Normal file
84
include/dnsjit/core/object/linuxsll.lua
Normal file
|
@ -0,0 +1,84 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.linuxsll
|
||||
-- Linux cooked-mode capture (SLL) part of a packet
|
||||
--
|
||||
-- The SLL part of a packet that usually can be found in the object chain
|
||||
-- after parsing with, for example, Layer filter.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- packet_type
|
||||
-- The packet type.
|
||||
-- .TP
|
||||
-- arp_hardware
|
||||
-- The link-layer device type.
|
||||
-- .TP
|
||||
-- link_layer_address_length
|
||||
-- The length of the link-layer address.
|
||||
-- .TP
|
||||
-- link_layer_address
|
||||
-- The link-layer address.
|
||||
-- .TP
|
||||
-- ether_type
|
||||
-- An Ethernet protocol type.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.linuxsll_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local t_name = "core_object_linuxsll_t"
|
||||
local core_object_linuxsll_t
|
||||
local Linuxsll = {}
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Linuxsll:type()
|
||||
return "linuxsll"
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Linuxsll:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Linuxsll:cast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Linuxsll:uncast()
|
||||
return ffi.cast("core_object_t*", self)
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Linuxsll:copy()
|
||||
return C.core_object_linuxsll_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Linuxsll:free()
|
||||
C.core_object_linuxsll_free(self)
|
||||
end
|
||||
|
||||
core_object_linuxsll_t = ffi.metatype(t_name, { __index = Linuxsll })
|
||||
|
||||
-- dnsjit.core.object (3).
|
||||
-- dnsjit.filter.layer (3)
|
||||
return Linuxsll
|
45
include/dnsjit/core/object/loop.c
Normal file
45
include/dnsjit/core/object/loop.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/object/loop.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
core_object_loop_t* core_object_loop_copy(const core_object_loop_t* self)
|
||||
{
|
||||
core_object_loop_t* copy;
|
||||
glassert_self();
|
||||
|
||||
glfatal_oom(copy = malloc(sizeof(core_object_loop_t)));
|
||||
memcpy(copy, self, sizeof(core_object_loop_t));
|
||||
copy->obj_prev = 0;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void core_object_loop_free(core_object_loop_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
free(self);
|
||||
}
|
38
include/dnsjit/core/object/loop.h
Normal file
38
include/dnsjit/core/object/loop.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/object.h>
|
||||
#include <dnsjit/core/timespec.h>
|
||||
|
||||
#ifndef __dnsjit_core_object_loop_h
|
||||
#define __dnsjit_core_object_loop_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <dnsjit/core/object/loop.hh>
|
||||
|
||||
#define CORE_OBJECT_LOOP_INIT(prev) \
|
||||
{ \
|
||||
CORE_OBJECT_INIT(CORE_OBJECT_LOOP, prev) \
|
||||
, \
|
||||
0 \
|
||||
}
|
||||
|
||||
#endif
|
31
include/dnsjit/core/object/loop.hh
Normal file
31
include/dnsjit/core/object/loop.hh
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.object_h")
|
||||
|
||||
typedef struct core_object_loop {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
|
||||
uint32_t family;
|
||||
} core_object_loop_t;
|
||||
|
||||
core_object_loop_t* core_object_loop_copy(const core_object_loop_t* self);
|
||||
void core_object_loop_free(core_object_loop_t* self);
|
72
include/dnsjit/core/object/loop.lua
Normal file
72
include/dnsjit/core/object/loop.lua
Normal file
|
@ -0,0 +1,72 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.loop
|
||||
-- OpenBSD loopback encapsulation (loop) part of a packet
|
||||
--
|
||||
-- The loop part of a packet that usually can be found in the object chain
|
||||
-- after parsing with, for example, Layer filter.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- family
|
||||
-- The link-layer header describing what type of packet is encapsulated.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.loop_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local t_name = "core_object_loop_t"
|
||||
local core_object_loop_t
|
||||
local Loop = {}
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Loop:type()
|
||||
return "loop"
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Loop:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Loop:cast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Loop:uncast()
|
||||
return ffi.cast("core_object_t*", self)
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Loop:copy()
|
||||
return C.core_object_loop_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Loop:free()
|
||||
C.core_object_loop_free(self)
|
||||
end
|
||||
|
||||
core_object_loop_t = ffi.metatype(t_name, { __index = Loop })
|
||||
|
||||
-- dnsjit.core.object (3),
|
||||
-- dnsjit.filter.layer (3)
|
||||
return Loop
|
45
include/dnsjit/core/object/null.c
Normal file
45
include/dnsjit/core/object/null.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/object/null.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
core_object_null_t* core_object_null_copy(const core_object_null_t* self)
|
||||
{
|
||||
core_object_null_t* copy;
|
||||
glassert_self();
|
||||
|
||||
glfatal_oom(copy = malloc(sizeof(core_object_null_t)));
|
||||
memcpy(copy, self, sizeof(core_object_null_t));
|
||||
copy->obj_prev = 0;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void core_object_null_free(core_object_null_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
free(self);
|
||||
}
|
38
include/dnsjit/core/object/null.h
Normal file
38
include/dnsjit/core/object/null.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/object.h>
|
||||
#include <dnsjit/core/timespec.h>
|
||||
|
||||
#ifndef __dnsjit_core_object_null_h
|
||||
#define __dnsjit_core_object_null_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <dnsjit/core/object/null.hh>
|
||||
|
||||
#define CORE_OBJECT_NULL_INIT(prev) \
|
||||
{ \
|
||||
CORE_OBJECT_INIT(CORE_OBJECT_NULL, prev) \
|
||||
, \
|
||||
0 \
|
||||
}
|
||||
|
||||
#endif
|
31
include/dnsjit/core/object/null.hh
Normal file
31
include/dnsjit/core/object/null.hh
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.object_h")
|
||||
|
||||
typedef struct core_object_null {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
|
||||
uint32_t family;
|
||||
} core_object_null_t;
|
||||
|
||||
core_object_null_t* core_object_null_copy(const core_object_null_t* self);
|
||||
void core_object_null_free(core_object_null_t* self);
|
72
include/dnsjit/core/object/null.lua
Normal file
72
include/dnsjit/core/object/null.lua
Normal file
|
@ -0,0 +1,72 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.null
|
||||
-- BSD loopback encapsulation (null) part of a packet
|
||||
--
|
||||
-- The null part of a packet that usually can be found in the object chain
|
||||
-- after parsing with, for example, Layer filter.
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- family
|
||||
-- The link-layer header describing what type of packet is encapsulated.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.null_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local t_name = "core_object_null_t"
|
||||
local core_object_null_t
|
||||
local Null = {}
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Null:type()
|
||||
return "null"
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Null:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Null:cast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Null:uncast()
|
||||
return ffi.cast("core_object_t*", self)
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Null:copy()
|
||||
return C.core_object_null_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Null:free()
|
||||
C.core_object_null_free(self)
|
||||
end
|
||||
|
||||
core_object_null_t = ffi.metatype(t_name, { __index = Null })
|
||||
|
||||
-- dnsjit.core.object (3),
|
||||
-- dnsjit.filter.layer (3)
|
||||
return Null
|
50
include/dnsjit/core/object/payload.c
Normal file
50
include/dnsjit/core/object/payload.c
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "core/object/payload.h"
|
||||
#include "core/assert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
core_object_payload_t* core_object_payload_copy(const core_object_payload_t* self)
|
||||
{
|
||||
core_object_payload_t* copy;
|
||||
glassert_self();
|
||||
|
||||
glfatal_oom(copy = malloc(sizeof(core_object_payload_t) + self->len + self->padding));
|
||||
memcpy(copy, self, sizeof(core_object_payload_t));
|
||||
copy->obj_prev = 0;
|
||||
|
||||
if (copy->payload) {
|
||||
copy->payload = (void*)copy + sizeof(core_object_payload_t);
|
||||
memcpy((void*)copy->payload, self->payload, self->len + self->padding);
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
void core_object_payload_free(core_object_payload_t* self)
|
||||
{
|
||||
glassert_self();
|
||||
free(self);
|
||||
}
|
38
include/dnsjit/core/object/payload.h
Normal file
38
include/dnsjit/core/object/payload.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <dnsjit/core/object.h>
|
||||
#include <dnsjit/core/timespec.h>
|
||||
|
||||
#ifndef __dnsjit_core_object_payload_h
|
||||
#define __dnsjit_core_object_payload_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <dnsjit/core/object/payload.hh>
|
||||
|
||||
#define CORE_OBJECT_PAYLOAD_INIT(prev) \
|
||||
{ \
|
||||
CORE_OBJECT_INIT(CORE_OBJECT_PAYLOAD, prev) \
|
||||
, \
|
||||
0, 0, 0 \
|
||||
}
|
||||
|
||||
#endif
|
32
include/dnsjit/core/object/payload.hh
Normal file
32
include/dnsjit/core/object/payload.hh
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, OARC, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of dnsjit.
|
||||
*
|
||||
* dnsjit 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//lua:require("dnsjit.core.object_h")
|
||||
|
||||
typedef struct core_object_payload {
|
||||
const core_object_t* obj_prev;
|
||||
int32_t obj_type;
|
||||
|
||||
const uint8_t* payload;
|
||||
size_t len, padding;
|
||||
} core_object_payload_t;
|
||||
|
||||
core_object_payload_t* core_object_payload_copy(const core_object_payload_t* self);
|
||||
void core_object_payload_free(core_object_payload_t* self);
|
83
include/dnsjit/core/object/payload.lua
Normal file
83
include/dnsjit/core/object/payload.lua
Normal file
|
@ -0,0 +1,83 @@
|
|||
-- Copyright (c) 2018-2021, OARC, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is part of dnsjit.
|
||||
--
|
||||
-- dnsjit 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 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- dnsjit 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 dnsjit. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
-- dnsjit.core.object.payload
|
||||
-- Application data payload
|
||||
--
|
||||
-- Payload object contains the data carried by the underlying transport
|
||||
-- protocol.
|
||||
-- Payload is usually at the top of the object chain after parsing with,
|
||||
-- for example,
|
||||
-- .IR dnsjit.filter.layer .
|
||||
-- .SS Attributes
|
||||
-- .TP
|
||||
-- payload
|
||||
-- A pointer to the payload.
|
||||
-- .TP
|
||||
-- len
|
||||
-- The length of the payload.
|
||||
-- .TP
|
||||
-- padding
|
||||
-- The length of padding in the underlying packet.
|
||||
module(...,package.seeall)
|
||||
|
||||
require("dnsjit.core.object.payload_h")
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
|
||||
local t_name = "core_object_payload_t"
|
||||
local core_object_payload_t
|
||||
local Payload = {}
|
||||
|
||||
-- Return the textual type of the object.
|
||||
function Payload:type()
|
||||
return "payload"
|
||||
end
|
||||
|
||||
-- Return the previous object.
|
||||
function Payload:prev()
|
||||
return self.obj_prev
|
||||
end
|
||||
|
||||
-- Cast the object to the underlining object module and return it.
|
||||
function Payload:cast()
|
||||
return self
|
||||
end
|
||||
|
||||
-- Cast the object to the generic object module and return it.
|
||||
function Payload:uncast()
|
||||
return ffi.cast("core_object_t*", self)
|
||||
end
|
||||
|
||||
-- Make a copy of the object and return it.
|
||||
function Payload:copy()
|
||||
return C.core_object_payload_copy(self)
|
||||
end
|
||||
|
||||
-- Free the object, should only be used on copies or otherwise allocated.
|
||||
function Payload:free()
|
||||
C.core_object_payload_free(self)
|
||||
end
|
||||
|
||||
core_object_payload_t = ffi.metatype(t_name, { __index = Payload })
|
||||
|
||||
-- dnsjit.core.object (3),
|
||||
-- dnsjit.core.object.udp (3),
|
||||
-- dnsjit.core.object.tcp (3),
|
||||
-- dnsjit.filter.layer (3)
|
||||
return Payload
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue