├── debian
├── compat
├── docs
├── source
│ └── format
├── dnsjit-dev.install
├── dirs
├── dnsjit.install
├── rules
├── copyright
└── control
├── include
└── dnsjit
├── src
├── test
│ ├── dns.pcap
│ ├── sll2.pcap
│ ├── 46vs45.pcap
│ ├── dns.pcap.gz
│ ├── dns.pcap.lz4
│ ├── dns.pcap.xz
│ ├── dns.pcap.zst
│ ├── pellets.pcap
│ ├── ip6-tcp-padd.pcap
│ ├── ip6-udp-padd.pcap
│ ├── tcp-response-with-trailing-junk.pcap
│ ├── test_compressupport.lua
│ ├── test_base64url.lua
│ ├── test-sll2.gold
│ ├── test-trie.sh
│ ├── test-base64url.sh
│ ├── test-ipsplit.sh
│ ├── test4.gold
│ ├── test4.sh
│ ├── test2.sh
│ ├── test-sll2.sh
│ ├── test3.sh
│ ├── test6.sh
│ └── test-padding.sh
├── gen-errno.sh
├── core
│ ├── file.hh
│ ├── compat.c
│ ├── producer.c
│ ├── receiver.c
│ ├── timespec.hh
│ ├── producer.hh
│ ├── file.h
│ ├── receiver.hh
│ ├── producer.h
│ ├── receiver.h
│ ├── thread.h
│ ├── compat.h
│ ├── object.hh
│ ├── producer.lua
│ ├── receiver.lua
│ ├── timespec.h
│ ├── file.c
│ ├── object
│ │ ├── loop.hh
│ │ ├── null.hh
│ │ ├── icmp.hh
│ │ ├── icmp6.hh
│ │ ├── ether.hh
│ │ ├── udp.hh
│ │ ├── payload.hh
│ │ ├── ieee802.hh
│ │ ├── gre.h
│ │ ├── udp.h
│ │ ├── icmp.h
│ │ ├── loop.h
│ │ ├── null.h
│ │ ├── gre.hh
│ │ ├── icmp6.h
│ │ ├── linuxsll.hh
│ │ ├── ip.hh
│ │ ├── ieee802.h
│ │ ├── payload.h
│ │ ├── linuxsll.h
│ │ ├── ip.c
│ │ ├── pcap.hh
│ │ ├── ether.h
│ │ ├── tcp.h
│ │ ├── gre.c
│ │ ├── ip6.c
│ │ ├── tcp.c
│ │ ├── udp.c
│ │ ├── linuxsll2.h
│ │ ├── icmp.c
│ │ ├── loop.c
│ │ ├── null.c
│ │ ├── ether.c
│ │ ├── icmp6.c
│ │ ├── pcap.h
│ │ ├── ieee802.c
│ │ ├── linuxsll2.hh
│ │ ├── tcp.hh
│ │ ├── ip.h
│ │ ├── linuxsll.c
│ │ ├── linuxsll2.c
│ │ ├── ip6.hh
│ │ ├── dns
│ │ │ └── q.lua
│ │ ├── pcap.c
│ │ ├── payload.c
│ │ └── ip6.h
│ ├── channel.h
│ ├── file.lua
│ ├── compat.lua
│ ├── object.h
│ ├── assert.h
│ ├── timespec.lua
│ ├── channel.hh
│ └── log.hh
├── globals.h
├── lib
│ ├── clock.h
│ ├── base64url.h
│ ├── clock.hh
│ ├── trie.h
│ └── clock.lua
├── version.h
├── filter
│ ├── split.h
│ ├── ipsplit.h
│ ├── copy.h
│ ├── timing.h
│ ├── copy.hh
│ ├── layer.h
│ ├── split.hh
│ └── timing.hh
├── output
│ ├── respdiff.h
│ ├── pcap.h
│ ├── tcpcli.h
│ ├── tlscli.h
│ ├── udpcli.h
│ ├── null.lua
│ ├── dnscli.h
│ ├── respdiff.hh
│ └── pcap.hh
├── lib.lua
├── input
│ ├── fpcap.h
│ ├── zpcap.h
│ ├── mmpcap.h
│ ├── zmmpcap.h
│ ├── pcap.h
│ ├── zero.lua
│ ├── pcap.hh
│ └── mmpcap.hh
├── input.lua
├── filter.lua
├── output.lua
├── gen-compat.lua
├── core.lua
└── globals.c
├── examples
├── stand-alone-tool
│ ├── autogen.sh
│ ├── src
│ │ ├── test
│ │ │ ├── dns.pcap
│ │ │ ├── Makefile.am
│ │ │ └── test.sh
│ │ └── Makefile.am
│ ├── Makefile.am
│ ├── dnsjit_modules.lua
│ ├── dnsjit_version.lua
│ ├── configure.ac
│ └── README.md
├── modules
│ ├── filter-example
│ │ ├── autogen.sh
│ │ ├── Makefile.am
│ │ ├── src
│ │ │ ├── Makefile.am
│ │ │ └── filter
│ │ │ │ └── counter.c
│ │ ├── test.lua
│ │ ├── configure.ac
│ │ └── README.md
│ ├── input-example
│ │ ├── autogen.sh
│ │ ├── Makefile.am
│ │ ├── test.lua
│ │ ├── src
│ │ │ ├── Makefile.am
│ │ │ └── input
│ │ │ │ └── zero.c
│ │ ├── README.md
│ │ └── configure.ac
│ ├── lib-example
│ │ ├── autogen.sh
│ │ ├── src
│ │ │ ├── Makefile.am
│ │ │ └── lib
│ │ │ │ └── duration.lua
│ │ ├── test.lua
│ │ ├── Makefile.am
│ │ ├── dnsjit_version.lua
│ │ ├── README.md
│ │ └── configure.ac
│ └── output-example
│ │ ├── autogen.sh
│ │ ├── Makefile.am
│ │ ├── test.lua
│ │ ├── src
│ │ ├── Makefile.am
│ │ └── output
│ │ │ └── null.c
│ │ ├── README.md
│ │ └── configure.ac
├── readme.lua
├── Makefile.am
├── count-pkts-per-ip.lua
├── dumpdns2pcap.lua
├── filter_rcode.lua
└── capture.lua
├── .clang-format
├── autogen.sh
├── Makefile.am
├── .copr
└── Makefile
├── fmt.sh
├── m4
├── dl.sh
├── ax_require_defined.m4
├── ax_append_flag.m4
└── ax_prepend_flag.m4
└── .gitignore
/debian/compat:
--------------------------------------------------------------------------------
1 | 10
2 |
--------------------------------------------------------------------------------
/include/dnsjit:
--------------------------------------------------------------------------------
1 | ../src
--------------------------------------------------------------------------------
/debian/docs:
--------------------------------------------------------------------------------
1 | README.md
2 |
--------------------------------------------------------------------------------
/debian/source/format:
--------------------------------------------------------------------------------
1 | 3.0 (quilt)
2 |
--------------------------------------------------------------------------------
/debian/dnsjit-dev.install:
--------------------------------------------------------------------------------
1 | usr/include/dnsjit
2 |
--------------------------------------------------------------------------------
/debian/dirs:
--------------------------------------------------------------------------------
1 | usr/share/man/man1
2 | usr/share/man/man3
3 | usr/bin
4 |
--------------------------------------------------------------------------------
/src/test/dns.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DNS-OARC/dnsjit/HEAD/src/test/dns.pcap
--------------------------------------------------------------------------------
/src/test/sll2.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DNS-OARC/dnsjit/HEAD/src/test/sll2.pcap
--------------------------------------------------------------------------------
/src/test/46vs45.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DNS-OARC/dnsjit/HEAD/src/test/46vs45.pcap
--------------------------------------------------------------------------------
/src/test/dns.pcap.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DNS-OARC/dnsjit/HEAD/src/test/dns.pcap.gz
--------------------------------------------------------------------------------
/src/test/dns.pcap.lz4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DNS-OARC/dnsjit/HEAD/src/test/dns.pcap.lz4
--------------------------------------------------------------------------------
/src/test/dns.pcap.xz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DNS-OARC/dnsjit/HEAD/src/test/dns.pcap.xz
--------------------------------------------------------------------------------
/src/test/dns.pcap.zst:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DNS-OARC/dnsjit/HEAD/src/test/dns.pcap.zst
--------------------------------------------------------------------------------
/src/test/pellets.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DNS-OARC/dnsjit/HEAD/src/test/pellets.pcap
--------------------------------------------------------------------------------
/src/test/ip6-tcp-padd.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DNS-OARC/dnsjit/HEAD/src/test/ip6-tcp-padd.pcap
--------------------------------------------------------------------------------
/src/test/ip6-udp-padd.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DNS-OARC/dnsjit/HEAD/src/test/ip6-udp-padd.pcap
--------------------------------------------------------------------------------
/examples/stand-alone-tool/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 |
3 | autoreconf --force --install --no-recursive
4 |
--------------------------------------------------------------------------------
/debian/dnsjit.install:
--------------------------------------------------------------------------------
1 | usr/share/man/man1
2 | usr/share/man/man3
3 | usr/share/doc/dnsjit
4 | usr/bin/dnsjit
5 |
--------------------------------------------------------------------------------
/examples/modules/filter-example/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 |
3 | autoreconf --force --install --no-recursive
4 |
--------------------------------------------------------------------------------
/examples/modules/input-example/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 |
3 | autoreconf --force --install --no-recursive
4 |
--------------------------------------------------------------------------------
/examples/modules/lib-example/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 |
3 | autoreconf --force --install --no-recursive
4 |
--------------------------------------------------------------------------------
/examples/modules/output-example/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 |
3 | autoreconf --force --install --no-recursive
4 |
--------------------------------------------------------------------------------
/examples/stand-alone-tool/src/test/dns.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DNS-OARC/dnsjit/HEAD/examples/stand-alone-tool/src/test/dns.pcap
--------------------------------------------------------------------------------
/src/test/tcp-response-with-trailing-junk.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DNS-OARC/dnsjit/HEAD/src/test/tcp-response-with-trailing-junk.pcap
--------------------------------------------------------------------------------
/.clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: webkit
2 | IndentWidth: 4
3 | AlignConsecutiveAssignments: true
4 | AlignConsecutiveDeclarations: true
5 | AlignOperands: true
6 | SortIncludes: false
7 |
--------------------------------------------------------------------------------
/examples/stand-alone-tool/src/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 |
3 | SUBDIRS = test
4 |
5 | bin_SCRIPTS = dnsjit-test-pcap-read dnsjit-test-throughput
6 |
--------------------------------------------------------------------------------
/examples/modules/lib-example/src/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 |
3 | durationlibdir = $(datadir)/lua/5.1/example/lib
4 | dist_durationlib_DATA = lib/duration.lua
5 |
--------------------------------------------------------------------------------
/examples/modules/filter-example/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in \
2 | $(srcdir)/configure
3 |
4 | SUBDIRS = src
5 |
6 | dist_doc_DATA = README.md
7 |
8 | EXTRA_DIST = test.lua
9 |
10 | test:
11 | dnsjit $(srcdir)/test.lua
12 |
--------------------------------------------------------------------------------
/examples/modules/input-example/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in \
2 | $(srcdir)/configure
3 |
4 | SUBDIRS = src
5 |
6 | dist_doc_DATA = README.md
7 |
8 | EXTRA_DIST = test.lua
9 |
10 | test:
11 | dnsjit $(srcdir)/test.lua
12 |
--------------------------------------------------------------------------------
/examples/modules/output-example/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in \
2 | $(srcdir)/configure
3 |
4 | SUBDIRS = src
5 |
6 | dist_doc_DATA = README.md
7 |
8 | EXTRA_DIST = test.lua
9 |
10 | test:
11 | dnsjit $(srcdir)/test.lua
12 |
--------------------------------------------------------------------------------
/examples/stand-alone-tool/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in \
2 | $(srcdir)/configure
3 |
4 | SUBDIRS = src
5 |
6 | dist_doc_DATA = README.md
7 |
8 | EXTRA_DIST = dnsjit_version.lua dnsjit_modules.lua
9 |
10 | test: check
11 |
--------------------------------------------------------------------------------
/debian/rules:
--------------------------------------------------------------------------------
1 | #!/usr/bin/make -f
2 | # -*- makefile -*-
3 |
4 | # Uncomment this to turn on verbose mode.
5 | # export DH_VERBOSE=1
6 |
7 | %:
8 | dh $@
9 |
10 | override_dh_auto_configure:
11 | ./autogen.sh
12 | CC=`which gcc-5 gcc|head -n 1` dh_auto_configure
13 |
--------------------------------------------------------------------------------
/examples/modules/lib-example/test.lua:
--------------------------------------------------------------------------------
1 | local duration = require("example.lib.duration")
2 |
3 | require("dnsjit.lib.clock_h")
4 | local C = require("ffi").C
5 |
6 | local a = C.lib_clock_gettime("LIB_CLOCK_REALTIME")
7 | a.sec = a.sec - 60000
8 | local b = C.lib_clock_gettime("LIB_CLOCK_REALTIME")
9 |
10 | print(duration.duration(a, b))
11 |
--------------------------------------------------------------------------------
/examples/modules/input-example/test.lua:
--------------------------------------------------------------------------------
1 | local ffi = require("ffi")
2 | local zero = require("example.input.zero").new()
3 |
4 | local producer, context = zero:produce()
5 | local object = producer(context)
6 |
7 | if ffi.istype("struct core_object*", object) then
8 | print("loading and usage successful")
9 | os.exit(0)
10 | end
11 |
12 | os.exit(1)
13 |
--------------------------------------------------------------------------------
/examples/modules/lib-example/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in \
2 | $(srcdir)/configure
3 |
4 | SUBDIRS = src
5 |
6 | dist_doc_DATA = README.md
7 |
8 | EXTRA_DIST = dnsjit_version.lua test.lua
9 |
10 | test:
11 | LUA_CPATH="@DNSJIT_ROOT@/lib/lua/5.1/?.so;;" LUA_PATH="@DNSJIT_ROOT@/share/lua/5.1/?.lua;;" $(DNSJIT) $(srcdir)/test.lua
12 |
--------------------------------------------------------------------------------
/src/test/test_compressupport.lua:
--------------------------------------------------------------------------------
1 | local zpcap = require("dnsjit.input.zpcap").new()
2 |
3 | zpcap:lz4()
4 | if zpcap:have_support() then
5 | print("lz4")
6 | end
7 | zpcap:zstd()
8 | if zpcap:have_support() then
9 | print("zstd")
10 | end
11 | zpcap:lzma()
12 | if zpcap:have_support() then
13 | print("lzma")
14 | end
15 | zpcap:gzip()
16 | if zpcap:have_support() then
17 | print("gzip")
18 | end
19 |
--------------------------------------------------------------------------------
/examples/stand-alone-tool/dnsjit_modules.lua:
--------------------------------------------------------------------------------
1 | if arg[2] > "" then
2 | package.path = package.path .. ";" .. arg[2] .. "/share/lua/5.1/?.lua"
3 | package.cpath = package.cpath .. ";" .. arg[2] .. "/lib/lua/5.1/?.so"
4 | end
5 | local ok = pcall(function()
6 | require("example.input.zero")
7 | require("example.output.null")
8 | end)
9 | if ok == true then
10 | os.exit(0)
11 | end
12 | os.exit(1)
13 |
--------------------------------------------------------------------------------
/examples/modules/output-example/test.lua:
--------------------------------------------------------------------------------
1 | local ffi = require("ffi")
2 | local null = require("example.output.null").new()
3 | require("dnsjit.core.object.null")
4 |
5 | local receiver, context = null:receive()
6 |
7 | local object = ffi.new("core_object_null_t")
8 |
9 | receiver(context, object:uncast())
10 |
11 | if null:packets() == 1 then
12 | print("loading and usage successful")
13 | os.exit(0)
14 | end
15 |
16 | os.exit(1)
17 |
--------------------------------------------------------------------------------
/examples/modules/input-example/src/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 | CLEANFILES =
3 |
4 | AM_CFLAGS = -Werror=attributes \
5 | -I$(srcdir) \
6 | -I$(top_srcdir)
7 |
8 | pkglibdir = $(libdir)/lua/5.1/$(PACKAGE)
9 | pkglib_LTLIBRARIES = zero.la
10 | zero_la_SOURCES = input/zero.c
11 | zero_la_LDFLAGS = -Wl,-E -module -avoid-version -shared
12 |
13 | zerolibdir = $(datadir)/lua/5.1/example/input
14 | dist_zerolib_DATA = input/zero.lua
15 |
--------------------------------------------------------------------------------
/examples/modules/output-example/src/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 | CLEANFILES =
3 |
4 | AM_CFLAGS = -Werror=attributes \
5 | -I$(srcdir) \
6 | -I$(top_srcdir)
7 |
8 | pkglibdir = $(libdir)/lua/5.1/$(PACKAGE)
9 | pkglib_LTLIBRARIES = null.la
10 | null_la_SOURCES = output/null.c
11 | null_la_LDFLAGS = -Wl,-E -module -avoid-version -shared
12 |
13 | nulllibdir = $(datadir)/lua/5.1/example/output
14 | dist_nulllib_DATA = output/null.lua
15 |
--------------------------------------------------------------------------------
/examples/modules/filter-example/src/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 | CLEANFILES =
3 |
4 | AM_CFLAGS = -Werror=attributes \
5 | -I$(srcdir) \
6 | -I$(top_srcdir)
7 |
8 | pkglibdir = $(libdir)/lua/5.1/$(PACKAGE)
9 | pkglib_LTLIBRARIES = counter.la
10 | counter_la_SOURCES = filter/counter.c
11 | counter_la_LDFLAGS = -Wl,-E -module -avoid-version -shared
12 |
13 | counterlibdir = $(datadir)/lua/5.1/example/filter
14 | dist_counterlib_DATA = filter/counter.lua
15 |
--------------------------------------------------------------------------------
/examples/stand-alone-tool/dnsjit_version.lua:
--------------------------------------------------------------------------------
1 | local _, major, minor, patch = unpack(arg)
2 | major = tonumber(major)
3 | minor = tonumber(minor)
4 | patch = tonumber(patch)
5 | if DNSJIT_MAJOR_VERSION > major then os.exit(0) end
6 | if DNSJIT_MAJOR_VERSION < major then os.exit(1) end
7 | if DNSJIT_MINOR_VERSION > minor then os.exit(0) end
8 | if DNSJIT_MINOR_VERSION < minor then os.exit(1) end
9 | if DNSJIT_PATCH_VERSION > patch then os.exit(0) end
10 | if DNSJIT_PATCH_VERSION < patch then os.exit(1) end
11 | os.exit(0)
12 |
--------------------------------------------------------------------------------
/examples/modules/lib-example/dnsjit_version.lua:
--------------------------------------------------------------------------------
1 | local _, major, minor, patch = unpack(arg)
2 | major = tonumber(major)
3 | minor = tonumber(minor)
4 | patch = tonumber(patch)
5 | if DNSJIT_MAJOR_VERSION > major then os.exit(0) end
6 | if DNSJIT_MAJOR_VERSION < major then os.exit(1) end
7 | if DNSJIT_MINOR_VERSION > minor then os.exit(0) end
8 | if DNSJIT_MINOR_VERSION < minor then os.exit(1) end
9 | if DNSJIT_PATCH_VERSION > patch then os.exit(0) end
10 | if DNSJIT_PATCH_VERSION < patch then os.exit(1) end
11 | os.exit(0)
12 |
--------------------------------------------------------------------------------
/examples/stand-alone-tool/src/test/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in env.sh
2 | CLEANFILES = test*.log test*.trs test*.out *.pcap-dist
3 |
4 | TESTS = test.sh
5 |
6 | BUILT_SOURCES = env.sh
7 |
8 | env.sh:
9 | echo "export PATH=\"\$$PATH:@DNSJIT_ROOT@/bin\"" >"$@"
10 | echo "export LUA_CPATH=\"@DNSJIT_ROOT@/lib/lua/5.1/?.so;;\"" >>"$@"
11 | echo "export LUA_PATH=\"@DNSJIT_ROOT@/share/lua/5.1/?.lua;;\"" >>"$@"
12 |
13 | test.sh: env.sh dns.pcap-dist
14 |
15 | .pcap.pcap-dist:
16 | cp "$<" "$@"
17 |
18 | EXTRA_DIST = $(TESTS) dns.pcap
19 |
--------------------------------------------------------------------------------
/examples/modules/lib-example/README.md:
--------------------------------------------------------------------------------
1 | # Example dnsjit module
2 |
3 | This module is an example how to create your own modules for dnsjit.
4 |
5 | `duration` is a simple Lua module that tells you the duration between
6 | two `core.timespec`.
7 |
8 | # Dependencies
9 |
10 | To build this you will need `dnsjit` installed.
11 |
12 | ```
13 | add-apt-repository ppa:dns-oarc/dnsjit-pr
14 | apt-get install dnsjit
15 | ```
16 |
17 | ## Build
18 |
19 | ```
20 | sh autogen.sh
21 | mkdir -p build
22 | cd build
23 | ../configure
24 | make
25 | make install
26 | ```
27 |
28 | ## Test
29 |
30 | ```
31 | make test
32 | ```
33 |
--------------------------------------------------------------------------------
/examples/modules/filter-example/test.lua:
--------------------------------------------------------------------------------
1 | local ffi = require("ffi")
2 | local zero = require("example.input.zero").new()
3 | local counter = require("example.filter.counter").new()
4 | local null = require("example.output.null").new()
5 |
6 | -- set the counter to receive objects created by zero
7 | zero:receiver(counter)
8 | -- set the null to receive objects passed through counter
9 | counter:receiver(null)
10 |
11 | -- run and create 10 objects
12 | zero:run(10)
13 |
14 | if counter:count() == 10 then
15 | print("loading and usage successful, counted "..counter:count().." objects")
16 | os.exit(0)
17 | end
18 |
19 | os.exit(1)
20 |
--------------------------------------------------------------------------------
/examples/modules/input-example/README.md:
--------------------------------------------------------------------------------
1 | # Example dnsjit module
2 |
3 | This module is an example how to create your own modules for dnsjit.
4 |
5 | `zero` is a simple module that produces empty `dnsjit.core.object`'s.
6 |
7 | # Dependencies
8 |
9 | To build it you will need dnsjit's development files and if you want to run
10 | the test then `dnsjit` itself also.
11 |
12 | ```
13 | add-apt-repository ppa:dns-oarc/dnsjit-pr
14 | apt-get install dnsjit dnsjit-dev
15 | ```
16 |
17 | ## Build
18 |
19 | ```
20 | sh autogen.sh
21 | mkdir -p build
22 | cd build
23 | ../configure
24 | make
25 | make install
26 | ```
27 |
28 | ## Test
29 |
30 | ```
31 | make test
32 | ```
33 |
--------------------------------------------------------------------------------
/examples/modules/output-example/README.md:
--------------------------------------------------------------------------------
1 | # Example dnsjit module
2 |
3 | This module is an example how to create your own modules for dnsjit.
4 |
5 | `null` is a simple module that does nothing with the objects it receives.
6 |
7 | # Dependencies
8 |
9 | To build it you will need dnsjit's development files and if you want to run
10 | the test then `dnsjit` itself also.
11 |
12 | ```
13 | add-apt-repository ppa:dns-oarc/dnsjit-pr
14 | apt-get install dnsjit dnsjit-dev
15 | ```
16 |
17 | ## Build
18 |
19 | ```
20 | sh autogen.sh
21 | mkdir -p build
22 | cd build
23 | ../configure
24 | make
25 | make install
26 | ```
27 |
28 | ## Test
29 |
30 | ```
31 | make test
32 | ```
33 |
--------------------------------------------------------------------------------
/src/test/test_base64url.lua:
--------------------------------------------------------------------------------
1 | base64url = require("dnsjit.lib.base64url")
2 | ffi = require("ffi")
3 |
4 | -- empty string works
5 | assert(base64url.decode(base64url.encode("")) == "")
6 |
7 | -- regular string data
8 | assert(base64url.encode("abcd") == "YWJjZA")
9 | assert(base64url.decode(base64url.encode("abcd")) == "abcd")
10 |
11 | -- invalid base64 data
12 | base64url.decode("+")
13 |
14 | -- check all symbols - arbitrary binary data
15 | c_array = ffi.new("uint8_t[?]", 256)
16 | bin_symbols = {}
17 | for i = 0, 255 do
18 | bin_symbols[i + 1] = string.char(i)
19 | c_array[i] = i
20 | end
21 | bin_str = table.concat(bin_symbols)
22 |
23 | assert(base64url.decode(base64url.encode(bin_str)) == bin_str)
24 | assert(base64url.encode(c_array, 256) == base64url.encode(bin_str))
25 |
--------------------------------------------------------------------------------
/examples/modules/input-example/configure.ac:
--------------------------------------------------------------------------------
1 | AC_PREREQ(2.61)
2 | AC_INIT([example-input-zero], [1.0.0],,)
3 | AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
4 | AC_CONFIG_HEADER([src/config.h])
5 |
6 | # Checks for programs.
7 | AC_PROG_CC
8 | AM_PROG_CC_C_O
9 | AC_CANONICAL_HOST
10 | m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
11 | LT_INIT([disable-static])
12 |
13 | # Check for dnsjit development files
14 | AC_ARG_WITH([dnsjit], [AS_HELP_STRING([--with-dnsjit=PATH], [Use PATH when checking for dnsjit development files])], [
15 | AS_VAR_APPEND(CFLAGS, [" -I$withval/include"])
16 | ])
17 | AC_CHECK_HEADER([dnsjit/version.h],, [AC_MSG_ERROR([dnsjit development headers not found])])
18 |
19 | # Output Makefiles
20 | AC_CONFIG_FILES([
21 | Makefile
22 | src/Makefile
23 | ])
24 | AC_OUTPUT
25 |
--------------------------------------------------------------------------------
/examples/modules/output-example/configure.ac:
--------------------------------------------------------------------------------
1 | AC_PREREQ(2.61)
2 | AC_INIT([example-output-null], [1.0.0],,)
3 | AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
4 | AC_CONFIG_HEADER([src/config.h])
5 |
6 | # Checks for programs.
7 | AC_PROG_CC
8 | AM_PROG_CC_C_O
9 | AC_CANONICAL_HOST
10 | m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
11 | LT_INIT([disable-static])
12 |
13 | # Check for dnsjit development files
14 | AC_ARG_WITH([dnsjit], [AS_HELP_STRING([--with-dnsjit=PATH], [Use PATH when checking for dnsjit development files])], [
15 | AS_VAR_APPEND(CFLAGS, [" -I$withval/include"])
16 | ])
17 | AC_CHECK_HEADER([dnsjit/version.h],, [AC_MSG_ERROR([dnsjit development headers not found])])
18 |
19 | # Output Makefiles
20 | AC_CONFIG_FILES([
21 | Makefile
22 | src/Makefile
23 | ])
24 | AC_OUTPUT
25 |
--------------------------------------------------------------------------------
/examples/readme.lua:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dnsjit
2 |
3 | -- Disclaimer, to keep this example short it only works on pre-prepared
4 | -- PCAPs with only UDP DNS traffic in them.
5 |
6 | require("dnsjit.core.objects")
7 | local input = require("dnsjit.input.pcap").new()
8 | local layer = require("dnsjit.filter.layer").new()
9 | local dns = require("dnsjit.core.object.dns").new()
10 |
11 | input:open_offline(arg[2])
12 | layer:producer(input)
13 | local producer, ctx = layer:produce()
14 |
15 | while true do
16 | local object = producer(ctx)
17 | if object == nil then break end
18 | if object:type() == "payload" then
19 | dns:reset()
20 | dns.obj_prev = object
21 | if dns:parse_header() == 0 then
22 | print(dns.id)
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/examples/modules/filter-example/configure.ac:
--------------------------------------------------------------------------------
1 | AC_PREREQ(2.61)
2 | AC_INIT([example-filter-counter], [1.0.0],,)
3 | AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
4 | AC_CONFIG_HEADER([src/config.h])
5 |
6 | # Checks for programs.
7 | AC_PROG_CC
8 | AM_PROG_CC_C_O
9 | AC_CANONICAL_HOST
10 | m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
11 | LT_INIT([disable-static])
12 |
13 | # Check for dnsjit development files
14 | AC_ARG_WITH([dnsjit], [AS_HELP_STRING([--with-dnsjit=PATH], [Use PATH when checking for dnsjit development files])], [
15 | AS_VAR_APPEND(CFLAGS, [" -I$withval/include"])
16 | ])
17 | AC_CHECK_HEADER([dnsjit/version.h],, [AC_MSG_ERROR([dnsjit development headers not found])])
18 |
19 | # Output Makefiles
20 | AC_CONFIG_FILES([
21 | Makefile
22 | src/Makefile
23 | ])
24 | AC_OUTPUT
25 |
--------------------------------------------------------------------------------
/examples/modules/filter-example/README.md:
--------------------------------------------------------------------------------
1 | # Example dnsjit module
2 |
3 | This module is an example how to create your own modules for dnsjit.
4 |
5 | `counter` is a simple filter module that counts objects passed through it.
6 |
7 | # Dependencies
8 |
9 | To build it you will need dnsjit's development files and if you want to run
10 | the test then `dnsjit` itself also.
11 |
12 | ```
13 | add-apt-repository ppa:dns-oarc/dnsjit-pr
14 | apt-get install dnsjit dnsjit-dev
15 | ```
16 |
17 | This module also uses two other example modules, input-example and
18 | output-example, so they must also be installed.
19 |
20 | ## Build
21 |
22 | ```
23 | sh autogen.sh
24 | mkdir -p build
25 | cd build
26 | ../configure
27 | make
28 | make install
29 | ```
30 |
31 | ## Test
32 |
33 | ```
34 | make test
35 | ```
36 |
--------------------------------------------------------------------------------
/src/gen-errno.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | includes="/usr/include/errno.h"
4 | if [ -f /usr/include/sys/errno.h ]; then
5 | includes="$includes /usr/include/sys/errno.h"
6 | fi
7 | if [ -f /usr/include/asm-generic/errno.h ]; then
8 | includes="$includes /usr/include/asm-generic/errno.h"
9 | fi
10 | if [ -f /usr/include/asm-generic/errno-base.h ]; then
11 | includes="$includes /usr/include/asm-generic/errno-base.h"
12 | fi
13 |
14 | echo 'const char* core_log_errstr(int err)
15 | {
16 | switch (err) {'
17 |
18 | egrep -Eh '^#define[ ]+E\w+[ ]+[0-9]+' $includes |
19 | grep -v ELAST |
20 | awk '{print $2}' |
21 | sort -u |
22 | awk '{print "#ifdef " $1 "\n case " $1 ":\n return \"" $1 "\";\n#endif"}'
23 |
24 | echo ' default:
25 | break;
26 | }
27 | return "UNKNOWN";
28 | }'
29 |
--------------------------------------------------------------------------------
/src/test/test-sll2.gold:
--------------------------------------------------------------------------------
1 | udp 238.0.0.1:37273 -> 238.0.0.2:53
2 | id: 20793
3 | qr: 0
4 | opcode: QUERY
5 | flags: RD AD
6 | rcode: NOERROR
7 | qdcount: 1
8 | ancount: 0
9 | nscount: 0
10 | arcount: 1
11 | questions: class type labels
12 | IN A <12>,..
13 | additionals: class type ttl labels RR labels
14 | UNKNOWN(1232) OPT 32768
15 | udp 238.0.0.2:53 -> 238.0.0.1:37273
16 | id: 20793
17 | qr: 1
18 | opcode: QUERY
19 | flags: RD RA
20 | rcode: NXDOMAIN
21 | qdcount: 1
22 | ancount: 0
23 | nscount: 4
24 | arcount: 1
25 | questions: class type labels
26 | IN A <12>,..
27 | authorities: class type ttl labels RR labels
28 | IN SOA 5 <31>a.<33>root-servers.<46>net.
29 | IN RRSIG 5
30 | IN RRSIG 5
31 | IN NSEC 5 <678>aaa.
32 | additionals: class type ttl labels RR labels
33 | UNKNOWN(1220) OPT 32768
34 |
--------------------------------------------------------------------------------
/src/test/test-trie.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 | # Copyright (c) 2020, CZ.NIC, z.s.p.o.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | ../dnsjit "$srcdir/test_trie.lua"
21 |
--------------------------------------------------------------------------------
/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 | # Copyright (c) 2018-2025 OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | autoreconf --force --install --no-recursive --include=m4
21 |
--------------------------------------------------------------------------------
/src/core/file.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | int core_file_exists(const char*);
22 |
--------------------------------------------------------------------------------
/src/test/test-base64url.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 | # Copyright (c) 2020, CZ.NIC, z.s.p.o.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | ../dnsjit "$srcdir/test_base64url.lua"
21 |
--------------------------------------------------------------------------------
/src/test/test-ipsplit.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 | # Copyright (c) 2020, CZ.NIC, z.s.p.o.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | ../dnsjit "$srcdir/test_ipsplit.lua"
21 |
--------------------------------------------------------------------------------
/src/core/compat.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/compat.h"
24 |
--------------------------------------------------------------------------------
/src/test/test4.gold:
--------------------------------------------------------------------------------
1 | 59311
2 | 59311
3 | 35665
4 | 35665
5 | 5337
6 | 5337
7 | 22982
8 | 22982
9 | 18718
10 | 18718
11 | 22531
12 | 22531
13 | 58510
14 | 58510
15 | 45248
16 | 45248
17 | 49483
18 | 49483
19 | 31669
20 | 31669
21 | 25433
22 | 25433
23 | 63798
24 | 63798
25 | 8470
26 | 8470
27 | 60258
28 | 60258
29 | 44985
30 | 44985
31 | 45512
32 | 45512
33 | 22980
34 | 22980
35 | 1834
36 | 1834
37 | 25431
38 | 25431
39 | 48432
40 | 48432
41 | 47411
42 | 47411
43 | 12038
44 | 12038
45 | 11614
46 | 11614
47 | 59173
48 | 59173
49 | 45535
50 | 45535
51 | 60808
52 | 60808
53 | 64325
54 | 64325
55 | 25543
56 | 25543
57 | 20736
58 | 20736
59 | 25911
60 | 25911
61 | 64358
62 | 64358
63 | 37698
64 | 37698
65 | 54706
66 | 54706
67 | 32142
68 | 32142
69 | 41808
70 | 41808
71 | 18886
72 | 18886
73 | 10624
74 | 10624
75 | 33139
76 | 33139
77 | 61415
78 | 61415
79 | 59258
80 | 59258
81 | 17700
82 | 17700
83 |
--------------------------------------------------------------------------------
/src/core/producer.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/producer.h"
24 |
--------------------------------------------------------------------------------
/src/core/receiver.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/receiver.h"
24 |
--------------------------------------------------------------------------------
/debian/copyright:
--------------------------------------------------------------------------------
1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2 | Upstream-Name: dnsjit
3 | Source: https://codeberg.org/DNS-OARC/dnsjit
4 |
5 | Files: *
6 | Copyright: 2018-2025 OARC, Inc.
7 | License: GPLv3
8 |
9 | License: GPLv3
10 | This is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 | .
15 | This is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 | .
20 | You should have received a copy of the GNU General Public License
21 | along with this. If not, see .
22 |
--------------------------------------------------------------------------------
/src/test/test4.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 | # Copyright (c) 2018-2025 OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | ../dnsjit "$srcdir/../../examples/readme.lua" dns.pcap-dist >test4.out
21 | diff "$srcdir/test4.gold" test4.out
22 |
--------------------------------------------------------------------------------
/src/core/timespec.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | typedef struct core_timespec {
22 | int64_t sec;
23 | int64_t nsec;
24 | } core_timespec_t;
25 |
--------------------------------------------------------------------------------
/src/test/test2.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 | # Copyright (c) 2018-2025 OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | ../dnsjit "$srcdir/../../examples/dumpdns-qr.lua" dns.pcap-dist >test2.out
21 | diff "$srcdir/test2.gold" test2.out
22 |
--------------------------------------------------------------------------------
/src/core/producer.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef const core_object_t* (*core_producer_t)(void* ctx);
24 |
--------------------------------------------------------------------------------
/src/test/test-sll2.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -ex
2 | # Copyright (c) 2018-2025 OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | ../dnsjit "$srcdir/../../examples/dumpdns.lua" sll2.pcap-dist >test-sll2.out
21 | diff "$srcdir/test-sll2.gold" test-sll2.out
22 |
--------------------------------------------------------------------------------
/src/core/file.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #ifndef __dnsjit_core_file_h
22 | #define __dnsjit_core_file_h
23 |
24 | #include
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/src/core/receiver.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef void (*core_receiver_t)(void* ctx, const core_object_t* obj);
24 |
--------------------------------------------------------------------------------
/src/globals.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #ifndef __dnsjit_globals_h
22 | #define __dnsjit_globals_h
23 |
24 | #include
25 |
26 | void dnsjit_globals(lua_State* L);
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/examples/modules/lib-example/configure.ac:
--------------------------------------------------------------------------------
1 | AC_PREREQ(2.61)
2 | AC_INIT([example-lib-duration], [1.0.0],,)
3 | AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
4 | AC_CONFIG_SRCDIR([src/lib/duration.lua])
5 |
6 | # Checks for dnsjit.
7 | DNSJIT_ROOT=
8 | AC_ARG_WITH([dnsjit], [AS_HELP_STRING([--with-dnsjit=PATH], [Use PATH when checking for dnsjit binaries])], [
9 | AC_PATH_PROG([DNSJIT],[dnsjit],,[$withval/bin])
10 | DNSJIT_ROOT="$withval"
11 | ], [
12 | AC_PATH_PROG([DNSJIT],[dnsjit])
13 | ])
14 | AC_SUBST([DNSJIT_ROOT])
15 | AS_IF([test "x$ac_cv_path_DNSJIT" = "x"], [
16 | AC_MSG_ERROR([dnsjit was not found])
17 | ])
18 | AC_MSG_CHECKING([for dnsjit >= 1.0.0])
19 | AS_IF(["$DNSJIT" "$srcdir/dnsjit_version.lua" 1 0 0], [
20 | AC_MSG_RESULT([yes])
21 | ], [
22 | AC_MSG_RESULT([no])
23 | AC_MSG_ERROR([dnsjit version does not meet the requirements])
24 | ])
25 |
26 | # Output Makefiles
27 | AC_CONFIG_FILES([
28 | Makefile
29 | src/Makefile
30 | ])
31 | AC_OUTPUT
32 |
--------------------------------------------------------------------------------
/src/lib/clock.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 |
23 | #ifndef __dnsjit_lib_clock_h
24 | #define __dnsjit_lib_clock_h
25 |
26 | #include
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/examples/Makefile.am:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018-2025 OARC, Inc.
2 | # All rights reserved.
3 | #
4 | # This file is part of dnsjit.
5 | #
6 | # dnsjit is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # dnsjit is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with dnsjit. If not, see .
18 |
19 | dist_doc_DATA = capture.lua dumpdns2pcap.lua dumpdns.lua dumpdns-qr.lua \
20 | filter_rcode.lua qr-multi-pcap-state.lua readme.lua replay.lua \
21 | replay_multicli.lua respdiff.lua pcap2tcpdns.lua
22 |
--------------------------------------------------------------------------------
/src/lib/base64url.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, CZ.NIC, z.s.p.o.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 |
23 | #ifndef __dnsjit_lib_base64url_h
24 | #define __dnsjit_lib_base64url_h
25 |
26 | #include
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/src/core/producer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 |
23 | #ifndef __dnsjit_core_producer_h
24 | #define __dnsjit_core_producer_h
25 |
26 | #include
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/src/core/receiver.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 |
23 | #ifndef __dnsjit_core_receiver_h
24 | #define __dnsjit_core_receiver_h
25 |
26 | #include
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/src/test/test3.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 | # Copyright (c) 2018-2025 OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | ../dnsjit "$srcdir/../../examples/filter_rcode.lua" dns.pcap-dist 0 >test3.out
21 | ../dnsjit "$srcdir/../../examples/filter_rcode.lua" dns.pcap-dist 1 >>test3.out
22 | diff "$srcdir/test3.gold" test3.out
23 |
--------------------------------------------------------------------------------
/src/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #ifndef __dnsjit_version_h
22 | #define __dnsjit_version_h
23 |
24 | #define DNSJIT_MAJOR_VERSION 1
25 | #define DNSJIT_MINOR_VERSION 5
26 | #define DNSJIT_PATCH_VERSION 0
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/src/filter/split.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_filter_split_h
25 | #define __dnsjit_filter_split_h
26 |
27 | #include
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/src/core/thread.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 |
23 | #ifndef __dnsjit_core_thread_h
24 | #define __dnsjit_core_thread_h
25 |
26 | #include
27 | #include
28 |
29 | #include
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/filter/ipsplit.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2020 CZ.NIC, z.s.p.o.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_filter_ipsplit_h
25 | #define __dnsjit_filter_ipsplit_h
26 |
27 | #include
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/src/core/compat.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #ifndef __dnsjit_core_compat_h
22 | #define __dnsjit_core_compat_h
23 |
24 | #include
25 |
26 | #ifdef __ssize_t_defined
27 | typedef ssize_t luajit_ssize_t;
28 | #else
29 | typedef long luajit_ssize_t;
30 | #endif
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/src/filter/copy.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, CZ.NIC, z.s.p.o.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | #ifndef __dnsjit_filter_copy_h
26 | #define __dnsjit_filter_copy_h
27 |
28 | #include
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/Makefile.am:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018-2025 OARC, Inc.
2 | # All rights reserved.
3 | #
4 | # This file is part of dnsjit.
5 | #
6 | # dnsjit is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # dnsjit is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with dnsjit. If not, see .
18 |
19 | ACLOCAL_AMFLAGS = -I m4
20 |
21 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in \
22 | $(srcdir)/src/config.h.in~ \
23 | $(srcdir)/configure
24 |
25 | SUBDIRS = src examples
26 |
27 | dist_doc_DATA = CHANGES README.md LICENSE
28 |
29 | EXTRA_DIST = m4 include
30 |
31 | test: check
32 |
--------------------------------------------------------------------------------
/src/filter/timing.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | #ifndef __dnsjit_filter_timing_h
26 | #define __dnsjit_filter_timing_h
27 |
28 | #include
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/src/output/respdiff.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_output_respdiff_h
25 | #define __dnsjit_output_respdiff_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/.copr/Makefile:
--------------------------------------------------------------------------------
1 | top=..
2 |
3 | all: srpm
4 |
5 | prereq: $(top)/rpmbuild
6 | rpm -q git rpm-build >/dev/null || dnf -y install git rpm-build
7 |
8 | update-dist-tools: $(top)/dist-tools
9 | ( cd "$(top)/dist-tools" && git pull )
10 |
11 | $(top)/dist-tools:
12 | git clone https://github.com/jelu/dist-tools.git "$(top)/dist-tools"
13 |
14 | $(top)/rpmbuild:
15 | mkdir -p "$(top)"/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
16 |
17 | srpm: prereq update-dist-tools
18 | test -f .gitmodules && git submodule update --init || true
19 | 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
20 | overwrite=yes nosign=yes "$(top)/dist-tools/create-source-packages" rpm
21 | cp ../*.orig.tar.gz "$(top)/rpmbuild/SOURCES/"
22 | 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)"
23 | cp "$(top)"/rpmbuild/SRPMS/*.src.rpm "$(outdir)"
24 |
--------------------------------------------------------------------------------
/src/lib.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.lib
20 | -- Various Lua libraries or C library bindings
21 | module(...,package.seeall)
22 |
23 | -- dnsjit.lib.base64url (3),
24 | -- dnsjit.lib.clock (3),
25 | -- dnsjit.lib.getopt (3),
26 | -- dnsjit.lib.ip (3),
27 | -- dnsjit.lib.parseconf (3),
28 | -- dnsjit.lib.trie (3)
29 | return
30 |
--------------------------------------------------------------------------------
/src/output/pcap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | #ifndef __dnsjit_output_pcap_h
26 | #define __dnsjit_output_pcap_h
27 |
28 | #include
29 |
30 | #include
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/src/test/test6.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 | # Copyright (c) 2018-2025 OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | ../dnsjit "$srcdir/../../examples/dumpdns.lua" "$srcdir/dns.pcap" > test6-dns.out
21 | ../dnsjit "$srcdir/../../examples/dumpdns2pcap.lua" "$srcdir/dns.pcap" test6-pcap.out
22 | ../dnsjit "$srcdir/../../examples/dumpdns.lua" test6-pcap.out > test6-dns2.out
23 | diff test6-dns.out test6-dns2.out
24 |
--------------------------------------------------------------------------------
/src/core/object.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have objectd a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | typedef struct core_object core_object_t;
22 | struct core_object {
23 | const core_object_t* obj_prev;
24 | int32_t obj_type;
25 | };
26 |
27 | core_object_t* core_object_copy(const core_object_t* self);
28 | void core_object_free(core_object_t* self);
29 |
--------------------------------------------------------------------------------
/src/core/producer.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.core.producer
20 | -- Producer interfaces
21 | -- require("dnsjit.core.producer_h")
22 | --
23 | -- Producer interfaces are used by input, filter and output modules to pass
24 | -- objects for processing.
25 | module(...,package.seeall)
26 |
27 | -- dnsjit.core.object (3)
28 | return
29 |
--------------------------------------------------------------------------------
/src/core/receiver.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.core.receiver
20 | -- Receiver interfaces
21 | -- require("dnsjit.core.receiver_h")
22 | --
23 | -- Receiver interfaces are used by input, filter and output modules to pass
24 | -- objects for processing.
25 | module(...,package.seeall)
26 |
27 | -- dnsjit.core.object (3)
28 | return
29 |
--------------------------------------------------------------------------------
/src/core/timespec.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #ifndef __dnsjit_core_timespec_h
22 | #define __dnsjit_core_timespec_h
23 |
24 | #include
25 |
26 | #include
27 |
28 | #define CORE_TIMESPEC_INIT \
29 | { \
30 | 0, 0 \
31 | }
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/src/input/fpcap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | #ifndef __dnsjit_input_fpcap_h
27 | #define __dnsjit_input_fpcap_h
28 |
29 | #include
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/input/zpcap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | #ifndef __dnsjit_input_zpcap_h
27 | #define __dnsjit_input_zpcap_h
28 |
29 | #include
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/fmt.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Copyright (c) 2018-2025 OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | clang-format \
21 | -style=file \
22 | -i \
23 | src/*.c \
24 | `find src/core src/input src/filter src/output src/lib examples/modules -name '*.c'` \
25 | `find src/core src/input src/filter src/output src/lib -name '*.h'` \
26 | `find src/core src/input src/filter src/output src/lib -name '*.hh'`
27 |
--------------------------------------------------------------------------------
/src/input/mmpcap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | #ifndef __dnsjit_input_mmpcap_h
27 | #define __dnsjit_input_mmpcap_h
28 |
29 | #include
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/input/zmmpcap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | #ifndef __dnsjit_input_zmmpcap_h
27 | #define __dnsjit_input_zmmpcap_h
28 |
29 | #include
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/lib/clock.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.timespec_h")
22 |
23 | typedef enum lib_clock_clkid {
24 | LIB_CLOCK_REALTIME,
25 | LIB_CLOCK_MONOTONIC
26 | } lib_clock_clkid_t;
27 |
28 | core_timespec_t lib_clock_getres(lib_clock_clkid_t clkid);
29 | core_timespec_t lib_clock_gettime(lib_clock_clkid_t clkid);
30 |
--------------------------------------------------------------------------------
/src/input.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.input
20 | -- Input modules for dnsjit
21 | --
22 | -- Input modules used to read DNS messages in various ways.
23 | module(...,package.seeall)
24 |
25 | -- dnsjit.input.fpcap (3),
26 | -- dnsjit.input.mmpcap (3),
27 | -- dnsjit.input.pcap (3),
28 | -- dnsjit.input.zero (3),
29 | -- dnsjit.input.zpcap (3)
30 | return
31 |
--------------------------------------------------------------------------------
/src/input/pcap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | #ifndef __dnsjit_input_pcap_h
27 | #define __dnsjit_input_pcap_h
28 |
29 | #include
30 |
31 | #include
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/src/core/file.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/file.h"
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | int core_file_exists(const char* filename)
30 | {
31 | struct stat s;
32 |
33 | if (stat(filename, &s)) {
34 | return 1;
35 | }
36 | return 0;
37 | }
38 |
--------------------------------------------------------------------------------
/src/output/tcpcli.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | #ifndef __dnsjit_output_tcpcli_h
28 | #define __dnsjit_output_tcpcli_h
29 |
30 | #include
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/examples/stand-alone-tool/src/test/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 | # Copyright (c) 2018-2025 OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | . ./env.sh
21 |
22 | "$srcdir/../dnsjit-test-throughput" -vvvvv -t -s 1000000
23 | "$srcdir/../dnsjit-test-pcap-read" -vvvvv dns.pcap-dist
24 | "$srcdir/../dnsjit-test-pcap-read" -l -vvvvv dns.pcap-dist
25 | "$srcdir/../dnsjit-test-pcap-read" -p -vvvvv dns.pcap-dist
26 | "$srcdir/../dnsjit-test-pcap-read" -l -p -vvvvv dns.pcap-dist
27 |
--------------------------------------------------------------------------------
/m4/dl.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 | # Copyright (c) 2018-2025 OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | m4_files="ax_append_flag.m4 ax_cflags_warn_all.m4 ax_ext.m4 ax_pthread.m4
21 | ax_require_defined.m4 ax_gcc_x86_avx_xgetbv.m4 ax_gcc_x86_cpuid.m4
22 | ax_check_compile_flag.m4 ax_prepend_flag.m4 ax_compiler_vendor.m4"
23 |
24 | for ax in $m4_files; do
25 | rm -f "$ax"
26 | wget -O "$ax" "http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/$ax"
27 | done
28 |
--------------------------------------------------------------------------------
/src/filter.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.filter
20 | -- Filter/processing modules for dnsjit
21 | --
22 | -- Filter modules to process or manipulate objects, packets and/or DNS
23 | -- messages.
24 | module(...,package.seeall)
25 |
26 | -- dnsjit.filter.copy (3),
27 | -- dnsjit.filter.ipsplit (3),
28 | -- dnsjit.filter.layer (3),
29 | -- dnsjit.filter.split (3),
30 | -- dnsjit.filter.timing (3)
31 | return
32 |
--------------------------------------------------------------------------------
/src/output/tlscli.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | #ifndef __dnsjit_output_tlscli_h
28 | #define __dnsjit_output_tlscli_h
29 |
30 | #include
31 |
32 | #include
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/src/core/object/loop.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_loop {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint32_t family;
28 | } core_object_loop_t;
29 |
30 | core_object_loop_t* core_object_loop_copy(const core_object_loop_t* self);
31 | void core_object_loop_free(core_object_loop_t* self);
32 |
--------------------------------------------------------------------------------
/src/core/object/null.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_null {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint32_t family;
28 | } core_object_null_t;
29 |
30 | core_object_null_t* core_object_null_copy(const core_object_null_t* self);
31 | void core_object_null_free(core_object_null_t* self);
32 |
--------------------------------------------------------------------------------
/src/test/test-padding.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -ex
2 | # Copyright (c) 2025 OARC, Inc.
3 | # All rights reserved.
4 | #
5 | # This file is part of dnsjit.
6 | #
7 | # dnsjit is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # dnsjit is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with dnsjit. If not, see .
19 |
20 | ../dnsjit "$srcdir/test_padding.lua" -r 46vs45.pcap-dist >test_padding.out
21 | ../dnsjit "$srcdir/test_padding.lua" -r tcp-response-with-trailing-junk.pcap-dist >>test_padding.out
22 | ../dnsjit "$srcdir/test_padding.lua" -r ip6-udp-padd.pcap-dist >>test_padding.out
23 | ../dnsjit "$srcdir/test_padding.lua" -r ip6-tcp-padd.pcap-dist >>test_padding.out
24 | diff "$srcdir/test_padding.gold" test_padding.out
25 |
--------------------------------------------------------------------------------
/src/input/zero.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.input.zero
20 | -- Dummy layer to example.input.zero
21 | --
22 | -- This module has moved to example.input.zero, see examples/modules/input-example in
23 | -- dnsjit source repository.
24 | module(...,package.seeall)
25 |
26 | ok, cls = pcall(require, "example.input.zero")
27 | if not ok then
28 | error("You need to install the example module input-example\n" .. cls)
29 | end
30 |
31 | return cls
32 |
--------------------------------------------------------------------------------
/src/output/udpcli.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | #ifndef __dnsjit_output_udpcli_h
28 | #define __dnsjit_output_udpcli_h
29 |
30 | #include
31 | #include
32 |
33 | #include
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/src/output/null.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.output.null
20 | -- Dummy layer to example.output.null
21 | --
22 | -- This module has moved to example.output.null, see examples/modules/output-example in
23 | -- dnsjit source repository.
24 | module(...,package.seeall)
25 |
26 | ok, cls = pcall(require, "example.output.null")
27 | if not ok then
28 | error("You need to install the example module output-example\n" .. cls)
29 | end
30 |
31 | return cls
32 |
--------------------------------------------------------------------------------
/src/core/object/icmp.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_icmp {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint8_t type;
28 | uint8_t code;
29 | uint16_t cksum;
30 | } core_object_icmp_t;
31 |
32 | core_object_icmp_t* core_object_icmp_copy(const core_object_icmp_t* self);
33 | void core_object_icmp_free(core_object_icmp_t* self);
34 |
--------------------------------------------------------------------------------
/src/core/object/icmp6.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_icmp6 {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint8_t type;
28 | uint8_t code;
29 | uint16_t cksum;
30 | } core_object_icmp6_t;
31 |
32 | core_object_icmp6_t* core_object_icmp6_copy(const core_object_icmp6_t* self);
33 | void core_object_icmp6_free(core_object_icmp6_t* self);
34 |
--------------------------------------------------------------------------------
/src/output.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.output
20 | -- Output modules for dnsjit
21 | --
22 | -- Output modules used to display DNS message, export to various formats or
23 | -- replay them against other targets.
24 | module(...,package.seeall)
25 |
26 | -- dnsjit.output.dnscli (3),
27 | -- dnsjit.output.null (3),
28 | -- dnsjit.output.pcap (3),
29 | -- dnsjit.output.respdiff (3),
30 | -- dnsjit.output.tcpcli (3),
31 | -- dnsjit.output.tlscli (3),
32 | -- dnsjit.output.udpcli (3)
33 | return
34 |
--------------------------------------------------------------------------------
/src/core/object/ether.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_ether {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint8_t dhost[6];
28 | uint8_t shost[6];
29 | uint16_t type;
30 | } core_object_ether_t;
31 |
32 | core_object_ether_t* core_object_ether_copy(const core_object_ether_t* self);
33 | void core_object_ether_free(core_object_ether_t* self);
34 |
--------------------------------------------------------------------------------
/src/core/object/udp.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_udp {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint16_t sport;
28 | uint16_t dport;
29 | uint16_t ulen;
30 | uint16_t sum;
31 | } core_object_udp_t;
32 |
33 | core_object_udp_t* core_object_udp_copy(const core_object_udp_t* self);
34 | void core_object_udp_free(core_object_udp_t* self);
35 |
--------------------------------------------------------------------------------
/examples/stand-alone-tool/configure.ac:
--------------------------------------------------------------------------------
1 | AC_PREREQ(2.61)
2 | AC_INIT([dnsjit-test], [1.0.0],,)
3 | AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
4 | AC_CONFIG_SRCDIR([src/dnsjit-test-pcap-read])
5 |
6 | # Checks for dnsjit.
7 | DNSJIT_ROOT=
8 | AC_ARG_WITH([dnsjit], [AS_HELP_STRING([--with-dnsjit=PATH], [Use PATH when checking for dnsjit binaries])], [
9 | AC_PATH_PROG([DNSJIT],[dnsjit],,[$withval/bin])
10 | DNSJIT_ROOT="$withval"
11 | ], [
12 | AC_PATH_PROG([DNSJIT],[dnsjit])
13 | ])
14 | AC_SUBST([DNSJIT_ROOT])
15 | AS_IF([test "x$ac_cv_path_DNSJIT" = "x"], [
16 | AC_MSG_ERROR([dnsjit was not found])
17 | ])
18 | AC_MSG_CHECKING([for dnsjit >= 1.0.0])
19 | AS_IF(["$DNSJIT" "$srcdir/dnsjit_version.lua" 1 0 0], [
20 | AC_MSG_RESULT([yes])
21 | ], [
22 | AC_MSG_RESULT([no])
23 | AC_MSG_ERROR([dnsjit version does not meet the requirements])
24 | ])
25 |
26 | # Checks for dnsjit modules
27 | AC_MSG_CHECKING([for dnsjit modules])
28 | AS_IF(["$DNSJIT" "$srcdir/dnsjit_modules.lua" "$DNSJIT_ROOT"], [
29 | AC_MSG_RESULT([yes])
30 | ], [
31 | AC_MSG_RESULT([no])
32 | AC_MSG_ERROR([required dnsjit modules not found])
33 | ])
34 |
35 | # Output Makefiles
36 | AC_CONFIG_FILES([
37 | Makefile
38 | src/Makefile
39 | src/test/Makefile
40 | ])
41 | AC_OUTPUT
42 |
--------------------------------------------------------------------------------
/src/core/object/payload.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_payload {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | const uint8_t* payload;
28 | size_t len, padding;
29 | } core_object_payload_t;
30 |
31 | core_object_payload_t* core_object_payload_copy(const core_object_payload_t* self);
32 | void core_object_payload_free(core_object_payload_t* self);
33 |
--------------------------------------------------------------------------------
/examples/modules/lib-example/src/lib/duration.lua:
--------------------------------------------------------------------------------
1 | module(...,package.seeall)
2 |
3 | require("dnsjit.core.timespec_h")
4 | local ffi = require("ffi")
5 |
6 | local Duration = {}
7 |
8 | -- Return the duration between two core.timespec as a string.
9 | function Duration.duration(a, b)
10 | if ffi.istype("core_timespec_t", a) ~= true then
11 | error("first argument is not a core_timespec_t")
12 | end
13 | if ffi.istype("core_timespec_t", b) ~= true then
14 | error("second argument is not a core_timespec_t")
15 | end
16 | if a.sec == b.sec then
17 | if a.nsec < b.nsec then
18 | return string.format("0.%09ds", tonumber(b.nsec-a.nsec))
19 | end
20 | return string.format("0.%09ds", tonumber(a.nsec-b.nsec))
21 | else
22 | local sec, nsec
23 | if a.sec < b.sec then
24 | sec = b.sec - a.sec
25 | nsec = 1e9 - a.nsec + b.nsec
26 | else
27 | sec = a.sec - b.sec
28 | nsec = 1e9 - b.nsec + a.nsec
29 | end
30 | if nsec >= 1e9 then
31 | sec = sec + ( nsec / 1e9 )
32 | nsec = nsec - 1e9
33 | end
34 | return string.format("%d.%09ds", tonumber(sec), tonumber(nsec))
35 | end
36 | end
37 |
38 | return Duration
39 |
--------------------------------------------------------------------------------
/src/output/dnscli.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | #ifndef __dnsjit_output_dnscli_h
29 | #define __dnsjit_output_dnscli_h
30 |
31 | #include
32 | #include
33 | #include
34 | #include
35 |
36 | #include
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/core/channel.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_channel_h
25 | #define __dnsjit_core_channel_h
26 |
27 | #if defined(__GNUC__) || defined(__SUNPRO_C)
28 | #include "gcc/ck_cc.h"
29 | #ifdef CK_CC_RESTRICT
30 | #undef CK_CC_RESTRICT
31 | #define CK_CC_RESTRICT __restrict__
32 | #endif
33 | #endif
34 |
35 | #include
36 | #include
37 | #include
38 |
39 | #include
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/src/gen-compat.lua:
--------------------------------------------------------------------------------
1 | for line in io.lines("config.h") do
2 | local n, s = line:match("define SIZEOF_(%S*) (%d+)")
3 | if n and s then
4 | if n:match("^PTHREAD") or n:match("^CK_") or n:match("^GNUTLS_") then
5 | s = math.ceil(s / 8)
6 | print("#if !defined(SIZEOF_"..n..") || SIZEOF_"..n.." == 0")
7 | print("#error \""..n.." is undefined or zero\"")
8 | print("#endif")
9 | n = n:lower()
10 | print("typedef struct "..n:sub(1,-3).." { uint64_t a["..s.."]; } "..n..";")
11 | elseif n:match("^STRUCT") then
12 | n = n:match("^STRUCT_(%S*)")
13 | if n == "SOCKADDR_STORAGE" or n == "POLLFD" then
14 | print("#if !defined(SIZEOF_STRUCT_"..n..") || SIZEOF_STRUCT_"..n.." == 0")
15 | print("#error \""..n.." is undefined or zero\"")
16 | print("#endif")
17 | n = n:lower()
18 | print("struct "..n.." { uint8_t a["..s.."]; };")
19 | end
20 | end
21 | end
22 | end
23 | code, err = pcall(function()
24 | local ffi = require("ffi")
25 | ffi.cdef[[
26 | ssize_t dummy;
27 | ]]
28 | end)
29 | if code then
30 | print("typedef ssize_t luajit_ssize_t;")
31 | else
32 | print("typedef long luajit_ssize_t;")
33 | end
34 |
--------------------------------------------------------------------------------
/src/core/object/ieee802.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_ieee802 {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint16_t tpid;
28 | uint8_t pcp;
29 | uint8_t dei;
30 | uint8_t vid;
31 | uint16_t ether_type;
32 | } core_object_ieee802_t;
33 |
34 | core_object_ieee802_t* core_object_ieee802_copy(const core_object_ieee802_t* self);
35 | void core_object_ieee802_free(core_object_ieee802_t* self);
36 |
--------------------------------------------------------------------------------
/src/lib/trie.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017-2019 CZ.NIC, z.s.p.o.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #ifndef __dnsjit_contrib_trie_h
23 | #define __dnsjit_contrib_trie_h
24 |
25 | #include
26 |
27 | #ifndef likely
28 | /*! \brief Optimize for x to be true value. */
29 | #define likely(x) __builtin_expect((x), 1)
30 | #endif
31 |
32 | #ifndef unlikely
33 | /*! \brief Optimize for x to be false value. */
34 | #define unlikely(x) __builtin_expect((x), 0)
35 | #endif
36 |
37 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) /** Minimum of two numbers **/
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/src/core/object/gre.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_gre_h
25 | #define __dnsjit_core_object_gre_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_GRE_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_GRE, prev) \
34 | , \
35 | 0, 0, 0, 0, 0 \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/core/object/udp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_udp_h
25 | #define __dnsjit_core_object_udp_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_UDP_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_UDP, prev) \
34 | , \
35 | 0, 0, 0, 0, \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/core/object/icmp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_icmp_h
25 | #define __dnsjit_core_object_icmp_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_ICMP_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_ICMP, prev) \
34 | , \
35 | 0, 0, 0 \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/core/object/loop.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_loop_h
25 | #define __dnsjit_core_object_loop_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_LOOP_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_LOOP, prev) \
34 | , \
35 | 0 \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/core/object/null.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_null_h
25 | #define __dnsjit_core_object_null_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_NULL_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_NULL, prev) \
34 | , \
35 | 0 \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/m4/ax_require_defined.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_REQUIRE_DEFINED(MACRO)
8 | #
9 | # DESCRIPTION
10 | #
11 | # AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
12 | # been defined and thus are available for use. This avoids random issues
13 | # where a macro isn't expanded. Instead the configure script emits a
14 | # non-fatal:
15 | #
16 | # ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
17 | #
18 | # It's like AC_REQUIRE except it doesn't expand the required macro.
19 | #
20 | # Here's an example:
21 | #
22 | # AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
23 | #
24 | # LICENSE
25 | #
26 | # Copyright (c) 2014 Mike Frysinger
27 | #
28 | # Copying and distribution of this file, with or without modification, are
29 | # permitted in any medium without royalty provided the copyright notice
30 | # and this notice are preserved. This file is offered as-is, without any
31 | # warranty.
32 |
33 | #serial 2
34 |
35 | AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
36 | m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
37 | ])dnl AX_REQUIRE_DEFINED
38 |
--------------------------------------------------------------------------------
/src/core/object/gre.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_gre {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint16_t gre_flags;
28 | uint16_t ether_type;
29 | uint16_t checksum;
30 | uint16_t offset;
31 | uint32_t key;
32 | uint32_t sequence;
33 | // TODO: routing list, check RFC 1701.
34 | } core_object_gre_t;
35 |
36 | core_object_gre_t* core_object_gre_copy(const core_object_gre_t* self);
37 | void core_object_gre_free(core_object_gre_t* self);
38 |
--------------------------------------------------------------------------------
/src/core/object/icmp6.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_icmp6_h
25 | #define __dnsjit_core_object_icmp6_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_ICMP6_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_ICMP6, prev) \
34 | , \
35 | 0, 0, 0 \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/examples/stand-alone-tool/README.md:
--------------------------------------------------------------------------------
1 | # Example stand-alone dnsjit tool
2 |
3 | This example consist of two scripts `dnsjit-test-pcap-read` and
4 | `dnsjit-test-throughput`, and shows how you can build, test and install them
5 | using autotools.
6 |
7 | They require `input-example` and `output-example` modules to be installed
8 | and that is checked in `dnsjit_modules.lua` which is run during `configure`.
9 |
10 | `configure` also checks that `dnsjit` is available and above version 1.0.0
11 | by using `dnsjit_version.lua`.
12 |
13 | If you haven't installed `dnsjit` and the modules in a common place (such as
14 | `/usr/local`) then you can use `--with-dnsjit=PATH` to specify where it's
15 | installed (should be same path as given to `dnsjit`'s `--prefix`).
16 |
17 | What's not covered here is if you install these tools using `--prefix` in a
18 | custom location that is not known by Lua. Then you need to set `PATH`,
19 | `LUA_PATH` and `LUA_CPATH`, see `src/test` for example and the Lua manual
20 | how these paths work.
21 |
22 | # Dependencies
23 |
24 | To build this you will need `dnsjit` installed.
25 |
26 | ```
27 | add-apt-repository ppa:dns-oarc/dnsjit-pr
28 | apt-get install dnsjit
29 | ```
30 |
31 | ## Build
32 |
33 | ```
34 | sh autogen.sh
35 | mkdir -p build
36 | cd build
37 | ../configure
38 | make
39 | make install
40 | ```
41 |
42 | ## Test
43 |
44 | ```
45 | make test
46 | ```
47 |
--------------------------------------------------------------------------------
/src/core/file.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.core.file
20 | -- OS file operations
21 | -- require("dnsjit.core.file")
22 | -- local ffi = require("ffi")
23 | -- if ffi.C.core_file_exists("path/file") == 0 then
24 | -- ...
25 | -- end
26 | --
27 | -- Module that exposes some file operations that are missing from Lua.
28 | -- .SS C functions
29 | -- .TP
30 | -- core_file_exists(path/filename)
31 | -- Function that takes a string and uses
32 | -- .B stat()
33 | -- to check if that path/filename exists.
34 | -- Returns zero if it exists.
35 | module(...,package.seeall)
36 |
37 | require("dnsjit.core.file_h")
38 |
--------------------------------------------------------------------------------
/src/core/object/linuxsll.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_linuxsll {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint16_t packet_type;
28 | uint16_t arp_hardware;
29 | uint16_t link_layer_address_length;
30 | uint8_t link_layer_address[8];
31 | uint16_t ether_type;
32 | } core_object_linuxsll_t;
33 |
34 | core_object_linuxsll_t* core_object_linuxsll_copy(const core_object_linuxsll_t* self);
35 | void core_object_linuxsll_free(core_object_linuxsll_t* self);
36 |
--------------------------------------------------------------------------------
/src/core/object/ip.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_ip {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint8_t v;
28 | uint8_t hl;
29 | uint8_t tos;
30 | uint16_t len;
31 | uint16_t id;
32 | uint16_t off;
33 | uint8_t ttl;
34 | uint8_t p;
35 | uint16_t sum;
36 | uint8_t src[4], dst[4];
37 | } core_object_ip_t;
38 |
39 | core_object_ip_t* core_object_ip_copy(const core_object_ip_t* self);
40 | void core_object_ip_free(core_object_ip_t* self);
41 |
--------------------------------------------------------------------------------
/src/core/object/ieee802.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_ieee802_h
25 | #define __dnsjit_core_object_ieee802_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_IEEE802_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_IEEE802, prev) \
34 | , \
35 | 0, 0, 0, 0, 0 \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/core/object/payload.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_payload_h
25 | #define __dnsjit_core_object_payload_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_PAYLOAD_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_PAYLOAD, prev) \
34 | , \
35 | 0, 0, 0 \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/core/object/linuxsll.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_linuxsll_h
25 | #define __dnsjit_core_object_linuxsll_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_LINUXSLL_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_LINUXSLL, prev) \
34 | , \
35 | 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 }, 0 \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/core/object/ip.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/ip.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_ip_t* core_object_ip_copy(const core_object_ip_t* self)
30 | {
31 | core_object_ip_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_ip_t)));
35 | memcpy(copy, self, sizeof(core_object_ip_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_ip_free(core_object_ip_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/object/pcap.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 | // lua:require("dnsjit.core.timespec_h")
23 |
24 | typedef struct core_object_pcap {
25 | const core_object_t* obj_prev;
26 | int32_t obj_type;
27 |
28 | uint32_t snaplen, linktype;
29 |
30 | core_timespec_t ts;
31 | uint32_t caplen, len;
32 | const unsigned char* bytes;
33 |
34 | uint8_t is_swapped;
35 | } core_object_pcap_t;
36 |
37 | core_object_pcap_t* core_object_pcap_copy(const core_object_pcap_t* self);
38 | void core_object_pcap_free(core_object_pcap_t* self);
39 |
--------------------------------------------------------------------------------
/src/core/object/ether.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_ether_h
25 | #define __dnsjit_core_object_ether_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_ETHER_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_ETHER, prev) \
34 | , \
35 | { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 }, 0 \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/core/object/tcp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_tcp_h
25 | #define __dnsjit_core_object_tcp_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_TCP_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_TCP, prev) \
34 | , \
35 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
36 | { 0 }, 0 \
37 | }
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/src/core/object/gre.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/gre.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_gre_t* core_object_gre_copy(const core_object_gre_t* self)
30 | {
31 | core_object_gre_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_gre_t)));
35 | memcpy(copy, self, sizeof(core_object_gre_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_gre_free(core_object_gre_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/object/ip6.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/ip6.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_ip6_t* core_object_ip6_copy(const core_object_ip6_t* self)
30 | {
31 | core_object_ip6_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_ip6_t)));
35 | memcpy(copy, self, sizeof(core_object_ip6_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_ip6_free(core_object_ip6_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/object/tcp.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/tcp.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_tcp_t* core_object_tcp_copy(const core_object_tcp_t* self)
30 | {
31 | core_object_tcp_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_tcp_t)));
35 | memcpy(copy, self, sizeof(core_object_tcp_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_tcp_free(core_object_tcp_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/object/udp.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/udp.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_udp_t* core_object_udp_copy(const core_object_udp_t* self)
30 | {
31 | core_object_udp_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_udp_t)));
35 | memcpy(copy, self, sizeof(core_object_udp_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_udp_free(core_object_udp_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/examples/modules/input-example/src/input/zero.c:
--------------------------------------------------------------------------------
1 | #include "config.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | typedef struct input_zero {
10 | core_log_t _log;
11 | core_receiver_t recv;
12 | void* ctx;
13 | } input_zero_t;
14 |
15 | static core_log_t _log = LOG_T_INIT("example.input.zero");
16 | static input_zero_t _defaults = {
17 | LOG_T_INIT_OBJ("example.input.zero"),
18 | 0,
19 | 0,
20 | };
21 |
22 | static core_object_null_t _null = CORE_OBJECT_NULL_INIT(0);
23 |
24 | core_log_t* input_zero_log()
25 | {
26 | return &_log;
27 | }
28 |
29 | void input_zero_init(input_zero_t* self)
30 | {
31 | mlassert_self();
32 |
33 | *self = _defaults;
34 | }
35 |
36 | void input_zero_destroy(input_zero_t* self)
37 | {
38 | mlassert_self();
39 | }
40 |
41 | void input_zero_run(input_zero_t* self, uint64_t num)
42 | {
43 | mlassert_self();
44 | if (!self->recv) {
45 | lfatal("no receiver set");
46 | }
47 |
48 | while (num--) {
49 | self->recv(self->ctx, (core_object_t*)&_null);
50 | }
51 | }
52 |
53 | static const core_object_t* _produce(void* ctx)
54 | {
55 | return (core_object_t*)&_null;
56 | }
57 |
58 | core_producer_t input_zero_producer()
59 | {
60 | return _produce;
61 | }
62 |
--------------------------------------------------------------------------------
/src/core/object/linuxsll2.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_linuxsll2_h
25 | #define __dnsjit_core_object_linuxsll2_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_LINUXSLL2_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_LINUXSLL2, prev) \
34 | , \
35 | 0, 0, 0, 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/core/compat.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.core.compat
20 | -- Cross platform compatibility support
21 | -- require("dnsjit.core.compat_h")
22 | --
23 | -- This module defines various system structures so they can be exposed into
24 | -- Lua but not really used. The size is generated at compile time to match
25 | -- that of the structures on the platform.
26 | -- .SS Structures
27 | -- .TP
28 | -- pthread_t
29 | -- .TP
30 | -- pthread_cond_t
31 | -- .TP
32 | -- pthread_mutex_t
33 | -- .TP
34 | -- struct sockaddr_storage
35 | -- .TP
36 | -- ck_ring_t
37 | -- .TP
38 | -- ck_ring_buffer_t
39 | module(...,package.seeall)
40 |
41 | require("dnsjit.core.compat_h")
42 |
--------------------------------------------------------------------------------
/src/core/object/icmp.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/icmp.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_icmp_t* core_object_icmp_copy(const core_object_icmp_t* self)
30 | {
31 | core_object_icmp_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_icmp_t)));
35 | memcpy(copy, self, sizeof(core_object_icmp_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_icmp_free(core_object_icmp_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/object/loop.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/loop.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_loop_t* core_object_loop_copy(const core_object_loop_t* self)
30 | {
31 | core_object_loop_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_loop_t)));
35 | memcpy(copy, self, sizeof(core_object_loop_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_loop_free(core_object_loop_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/object/null.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/null.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_null_t* core_object_null_copy(const core_object_null_t* self)
30 | {
31 | core_object_null_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_null_t)));
35 | memcpy(copy, self, sizeof(core_object_null_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_null_free(core_object_null_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/object/ether.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/ether.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_ether_t* core_object_ether_copy(const core_object_ether_t* self)
30 | {
31 | core_object_ether_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_ether_t)));
35 | memcpy(copy, self, sizeof(core_object_ether_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_ether_free(core_object_ether_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/object/icmp6.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/icmp6.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_icmp6_t* core_object_icmp6_copy(const core_object_icmp6_t* self)
30 | {
31 | core_object_icmp6_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_icmp6_t)));
35 | memcpy(copy, self, sizeof(core_object_icmp6_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_icmp6_free(core_object_icmp6_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/src/filter/copy.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, CZ.NIC z.s.p.o.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.log")
22 | // lua:require("dnsjit.core.receiver_h")
23 |
24 | typedef struct filter_copy {
25 | core_log_t _log;
26 |
27 | core_receiver_t recv;
28 | void* recv_ctx;
29 |
30 | uint64_t copy;
31 | } filter_copy_t;
32 |
33 | core_log_t* filter_copy_log();
34 |
35 | void filter_copy_init(filter_copy_t* self);
36 | void filter_copy_destroy(filter_copy_t* self);
37 | void filter_copy_set(filter_copy_t* self, int32_t obj_type);
38 | uint64_t filter_copy_get(filter_copy_t* self, int32_t obj_type);
39 |
40 | core_receiver_t filter_copy_receiver(filter_copy_t* self);
41 |
--------------------------------------------------------------------------------
/src/core/object/pcap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_pcap_h
25 | #define __dnsjit_core_object_pcap_h
26 |
27 | #include
28 |
29 | #define CORE_OBJECT_PCAP_INIT(prev) \
30 | { \
31 | CORE_OBJECT_INIT(CORE_OBJECT_PCAP, prev) \
32 | , \
33 | 0, 0, \
34 | { 0, 0 }, 0, 0, 0, \
35 | 0 \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/core/object/ieee802.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/ieee802.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_ieee802_t* core_object_ieee802_copy(const core_object_ieee802_t* self)
30 | {
31 | core_object_ieee802_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_ieee802_t)));
35 | memcpy(copy, self, sizeof(core_object_ieee802_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_ieee802_free(core_object_ieee802_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/object/linuxsll2.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_linuxsll2 {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint16_t protocol_type;
28 | uint16_t reserved;
29 | uint32_t interface_index;
30 | uint16_t arphrd_type;
31 | uint8_t packet_type;
32 | uint8_t link_layer_address_length;
33 | uint8_t link_layer_address[8];
34 | } core_object_linuxsll2_t;
35 |
36 | core_object_linuxsll2_t* core_object_linuxsll2_copy(const core_object_linuxsll2_t* self);
37 | void core_object_linuxsll2_free(core_object_linuxsll2_t* self);
38 |
--------------------------------------------------------------------------------
/src/core/object/tcp.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_tcp {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint16_t sport;
28 | uint16_t dport;
29 | uint32_t seq;
30 | uint32_t ack;
31 | uint8_t off : 4;
32 | uint8_t x2 : 4;
33 | uint8_t flags;
34 | uint16_t win;
35 | uint16_t sum;
36 | uint16_t urp;
37 |
38 | uint8_t opts[64];
39 | size_t opts_len;
40 | } core_object_tcp_t;
41 |
42 | core_object_tcp_t* core_object_tcp_copy(const core_object_tcp_t* self);
43 | void core_object_tcp_free(core_object_tcp_t* self);
44 |
--------------------------------------------------------------------------------
/src/core/object/ip.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_ip_h
25 | #define __dnsjit_core_object_ip_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_IP_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_IP, prev) \
34 | , \
35 | 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, \
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/src/core/object/linuxsll.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/linuxsll.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_linuxsll_t* core_object_linuxsll_copy(const core_object_linuxsll_t* self)
30 | {
31 | core_object_linuxsll_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_linuxsll_t)));
35 | memcpy(copy, self, sizeof(core_object_linuxsll_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_linuxsll_free(core_object_linuxsll_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/object/linuxsll2.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/linuxsll2.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_linuxsll2_t* core_object_linuxsll2_copy(const core_object_linuxsll2_t* self)
30 | {
31 | core_object_linuxsll2_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_linuxsll2_t)));
35 | memcpy(copy, self, sizeof(core_object_linuxsll2_t));
36 | copy->obj_prev = 0;
37 |
38 | return copy;
39 | }
40 |
41 | void core_object_linuxsll2_free(core_object_linuxsll2_t* self)
42 | {
43 | glassert_self();
44 | free(self);
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/object/ip6.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.object_h")
22 |
23 | typedef struct core_object_ip6 {
24 | const core_object_t* obj_prev;
25 | int32_t obj_type;
26 |
27 | uint32_t flow;
28 | uint16_t plen;
29 | uint8_t nxt;
30 | uint8_t hlim;
31 | uint8_t src[16];
32 | uint8_t dst[16];
33 |
34 | uint8_t is_frag;
35 | uint8_t have_rtdst;
36 | uint16_t frag_offlg;
37 | uint16_t frag_ident;
38 | uint8_t rtdst[16];
39 |
40 | uint16_t hlen;
41 | } core_object_ip6_t;
42 |
43 | core_object_ip6_t* core_object_ip6_copy(const core_object_ip6_t* self);
44 | void core_object_ip6_free(core_object_ip6_t* self);
45 |
--------------------------------------------------------------------------------
/examples/count-pkts-per-ip.lua:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dnsjit
2 | -- count-pkts-per-ip.lua: count number of packets received from each IP/IPv6 address
3 |
4 | local input = require("dnsjit.input.pcap").new()
5 | local layer = require("dnsjit.filter.layer").new()
6 | local object = require("dnsjit.core.objects")
7 | local ip = require("dnsjit.lib.ip")
8 | local trie = require("dnsjit.lib.trie").new("uint64_t", true)
9 | local getopt = require("dnsjit.lib.getopt").new({})
10 |
11 | local pcap = unpack(getopt:parse())
12 | if pcap == nil then
13 | print("usage: "..arg[1].." ")
14 | end
15 |
16 | -- Set up input
17 | input:open_offline(pcap)
18 | layer:producer(input)
19 | local produce, pctx = layer:produce()
20 |
21 | -- Read input and count packets
22 | while true do
23 | local obj = produce(pctx)
24 | if obj == nil then break end
25 | local pkt = obj:cast_to(object.IP) or obj:cast_to(object.IP6)
26 |
27 | if pkt ~= nil then
28 | local iplen = 4
29 | if pkt:type() == "ip6" then
30 | iplen = 16
31 | end
32 |
33 | local node = trie:get_ins(pkt.src, iplen)
34 | node:set(node:get() + 1)
35 | end
36 | end
37 |
38 | -- Print statistics
39 | local iter = trie:iter()
40 | local node = iter:node()
41 |
42 | while node ~= nil do
43 | local npkts = tonumber(node:get())
44 | local key = node:key()
45 | local ipstr = ip.tostring(key, true)
46 |
47 | print(ipstr.." sent "..npkts.." packets")
48 | iter:next()
49 | node = iter:node()
50 | end
51 |
--------------------------------------------------------------------------------
/src/output/respdiff.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.log")
22 | // lua:require("dnsjit.core.receiver_h")
23 |
24 | typedef struct output_respdiff {
25 | core_log_t _log;
26 | void * env, *txn, *qdb, *rdb, *meta;
27 | uint32_t id;
28 | size_t count;
29 | } output_respdiff_t;
30 |
31 | core_log_t* output_respdiff_log();
32 | void output_respdiff_init(output_respdiff_t* self, const char* path, size_t mapsize);
33 | void output_respdiff_destroy(output_respdiff_t* self);
34 | void output_respdiff_commit(output_respdiff_t* self, const char* origname, const char* recvname, uint64_t start_time, uint64_t end_time);
35 |
36 | core_receiver_t output_respdiff_receiver(output_respdiff_t* self);
37 |
--------------------------------------------------------------------------------
/src/core/object/dns/q.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.core.object.dns.q
20 | -- Container of a DNS question
21 | --
22 | -- The object that describes a DNS question.
23 | -- .SS Attributes
24 | -- .TP
25 | -- have_type
26 | -- Set if there is a type.
27 | -- .TP
28 | -- have_class
29 | -- Set if there is a class.
30 | -- .TP
31 | -- type
32 | -- The type.
33 | -- .TP
34 | -- class
35 | -- The class.
36 | -- .TP
37 | -- labels
38 | -- The number of labels found in the question.
39 | module(...,package.seeall)
40 |
41 | require("dnsjit.core.object.dns_h")
42 | local ffi = require("ffi")
43 |
44 | local Q = {}
45 |
46 | -- Create a new question.
47 | function Q.new(size)
48 | return ffi.new("core_object_dns_q_t")
49 | end
50 |
51 | -- dnsjit.core.object.dns (3)
52 | return Q
53 |
--------------------------------------------------------------------------------
/examples/dumpdns2pcap.lua:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dnsjit
2 | local pcap_in = arg[2]
3 | local pcap_out = arg[3]
4 |
5 | if pcap_in == nil or pcap_out == nil then
6 | print("usage: "..arg[1].." ")
7 | return
8 | end
9 |
10 | local object = require("dnsjit.core.objects")
11 | local input = require("dnsjit.input.pcap").new()
12 | local layer = require("dnsjit.filter.layer").new()
13 | local dns = require("dnsjit.core.object.dns").new()
14 | local output = require("dnsjit.output.pcap").new()
15 |
16 | input:open_offline(pcap_in)
17 | layer:producer(input)
18 | local producer, ctx = layer:produce()
19 |
20 | output:open(pcap_out, input:linktype(), input:snaplen())
21 | local receiver, rctx = output:receive()
22 |
23 | local n = 0
24 | while true do
25 | local obj = producer(ctx)
26 | if obj == nil then break end
27 | local pl = obj:cast()
28 | if obj:type() == "payload" and pl.len > 0 then
29 | local protocol = obj.obj_prev
30 | while protocol ~= nil do
31 | if protocol.obj_type == object.UDP or protocol.obj_type == object.TCP then
32 | break
33 | end
34 | protocol = protocol.obj_prev
35 | end
36 |
37 | dns:reset()
38 | if protocol ~= nil and protocol.obj_type == object.TCP then
39 | dns.includes_dnslen = 1
40 | end
41 | dns.obj_prev = obj
42 | if dns:parse_header() == 0 then
43 | receiver(rctx, obj)
44 | n = n + 1
45 | end
46 | end
47 | end
48 |
49 | output:close()
50 | print(n, "DNS packets dumped")
51 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Object files
5 | *.o
6 | *.ko
7 | *.obj
8 | *.elf
9 |
10 | # Linker output
11 | *.ilk
12 | *.map
13 | *.exp
14 |
15 | # Precompiled Headers
16 | *.gch
17 | *.pch
18 |
19 | # Libraries
20 | *.lib
21 | *.a
22 | *.la
23 | *.lo
24 |
25 | # Shared objects (inc. Windows DLLs)
26 | *.dll
27 | *.so
28 | *.so.*
29 | *.dylib
30 |
31 | # Executables
32 | *.exe
33 | *.out
34 | *.app
35 | *.i*86
36 | *.x86_64
37 | *.hex
38 |
39 | # Debug files
40 | *.dSYM/
41 | *.su
42 | *.idb
43 | *.pdb
44 |
45 | # Kernel Module Compile Results
46 | *.mod*
47 | *.cmd
48 | .tmp_versions/
49 | modules.order
50 | Module.symvers
51 | Mkfile.old
52 | dkms.conf
53 |
54 | # Automake
55 | Makefile.in
56 | aclocal.m4
57 | ar-lib
58 | autom4te.cache
59 | compile
60 | config.guess
61 | config.sub
62 | configure
63 | configure~
64 | depcomp
65 | install-sh
66 | ltmain.sh
67 | m4/libtool.m4
68 | m4/ltoptions.m4
69 | m4/ltsugar.m4
70 | m4/ltversion.m4
71 | m4/lt~obsolete.m4
72 | missing
73 | config.h.in
74 | config.h.in~
75 | test-driver
76 |
77 | # Configure
78 | Makefile
79 | config.log
80 | config.status
81 | libtool
82 | .deps
83 | src/config.h
84 | src/stamp-h1
85 | build
86 | .dirstamp
87 |
88 | # Project specific files
89 | *.luao
90 | *.luaho
91 | src/dnsjit
92 | src/dnsjit.1
93 | src/dnsjit.*.3in
94 | src/dnsjit.*.3
95 | src/core/compat.hh
96 | src/core/log_errstr.c
97 | src/test/test-suite.log
98 | src/test/test*.sh.log
99 | src/test/test*.sh.trs
100 | src/test/*.dist
101 | src/test/*-dist
102 |
--------------------------------------------------------------------------------
/src/core.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.core
20 | -- Core modules for dnsjit
21 | --
22 | -- Core modules for handling things like logging, DNS messages and
23 | -- receiver/receive functionality.
24 | -- .SS Global Variables
25 | -- The following global variables exists in
26 | -- .IR dnsjit .
27 | -- .TP
28 | -- .B arg
29 | -- A table with the arguments given on the command line, the first will be
30 | -- the path to the
31 | -- .I dnsjit
32 | -- binary, second will be the path to the
33 | -- .IR script .
34 | module(...,package.seeall)
35 |
36 | -- dnsjit.core.channel (3),
37 | -- dnsjit.core.compat (3),
38 | -- dnsjit.core.log (3),
39 | -- dnsjit.core.object (3),
40 | -- dnsjit.core.objects (3),
41 | -- dnsjit.core.producer (3),
42 | -- dnsjit.core.receiver (3),
43 | -- dnsjit.core.thread (3),
44 | -- dnsjit.core.timespec (3)
45 | return
46 |
--------------------------------------------------------------------------------
/src/output/pcap.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #if 0
22 | typedef struct pcap_dumper {} pcap_dumper_t;
23 | #endif
24 |
25 | // lua:require("dnsjit.core.log")
26 | // lua:require("dnsjit.core.receiver_h")
27 | // lua:require("dnsjit.input.pcap_h")
28 |
29 | typedef struct output_pcap {
30 | core_log_t _log;
31 | pcap_t* pcap;
32 | pcap_dumper_t* dumper;
33 | } output_pcap_t;
34 |
35 | core_log_t* output_pcap_log();
36 | void output_pcap_init(output_pcap_t* self);
37 | void output_pcap_destroy(output_pcap_t* self);
38 | int output_pcap_open(output_pcap_t* self, const char* file, int linktype, int snaplen);
39 | void output_pcap_close(output_pcap_t* self);
40 | int output_pcap_have_errors(output_pcap_t* self);
41 |
42 | core_receiver_t output_pcap_receiver(output_pcap_t* self);
43 |
--------------------------------------------------------------------------------
/src/core/object/pcap.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/pcap.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_pcap_t* core_object_pcap_copy(const core_object_pcap_t* self)
30 | {
31 | core_object_pcap_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_pcap_t) + self->caplen));
35 | memcpy(copy, self, sizeof(core_object_pcap_t));
36 | copy->obj_prev = 0;
37 |
38 | if (copy->bytes) {
39 | copy->bytes = (void*)copy + sizeof(core_object_pcap_t);
40 | memcpy((void*)copy->bytes, self->bytes, self->caplen);
41 | }
42 |
43 | return copy;
44 | }
45 |
46 | void core_object_pcap_free(core_object_pcap_t* self)
47 | {
48 | glassert_self();
49 | free(self);
50 | }
51 |
--------------------------------------------------------------------------------
/src/core/object/payload.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "core/object/payload.h"
24 | #include "core/assert.h"
25 |
26 | #include
27 | #include
28 |
29 | core_object_payload_t* core_object_payload_copy(const core_object_payload_t* self)
30 | {
31 | core_object_payload_t* copy;
32 | glassert_self();
33 |
34 | glfatal_oom(copy = malloc(sizeof(core_object_payload_t) + self->len + self->padding));
35 | memcpy(copy, self, sizeof(core_object_payload_t));
36 | copy->obj_prev = 0;
37 |
38 | if (copy->payload) {
39 | copy->payload = (void*)copy + sizeof(core_object_payload_t);
40 | memcpy((void*)copy->payload, self->payload, self->len + self->padding);
41 | }
42 |
43 | return copy;
44 | }
45 |
46 | void core_object_payload_free(core_object_payload_t* self)
47 | {
48 | glassert_self();
49 | free(self);
50 | }
51 |
--------------------------------------------------------------------------------
/src/filter/layer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 |
40 | #ifndef __dnsjit_filter_layer_h
41 | #define __dnsjit_filter_layer_h
42 |
43 | #include
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/src/lib/clock.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.lib.clock
20 | -- Clock and time functions
21 | -- local clock = require("dnsjit.lib.clock")
22 | -- local sec, nsec = clock.monotonic()
23 | --
24 | -- Functions to get the time from system-wide clocks.
25 | module(...,package.seeall)
26 |
27 | require("dnsjit.lib.clock_h")
28 | local C = require("ffi").C
29 |
30 | Clock = {}
31 |
32 | -- Return the current seconds and nanoseconds (as a list) from the realtime
33 | -- clock.
34 | function Clock.realtime()
35 | local ts = C.lib_clock_gettime("LIB_CLOCK_REALTIME")
36 | return tonumber(ts.sec), tonumber(ts.nsec)
37 | end
38 |
39 | -- Return the current seconds and nanoseconds (as a list) from the monotonic
40 | -- clock.
41 | function Clock.monotonic()
42 | local ts = C.lib_clock_gettime("LIB_CLOCK_MONOTONIC")
43 | return tonumber(ts.sec), tonumber(ts.nsec)
44 | end
45 |
46 | -- clock_gettime (2)
47 | return Clock
48 |
--------------------------------------------------------------------------------
/examples/filter_rcode.lua:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dnsjit
2 | local pcap = arg[2]
3 | local rcode = tonumber(arg[3])
4 |
5 | if pcap == nil or rcode == nil then
6 | print("usage: "..arg[1].." ")
7 | return
8 | end
9 |
10 | local object = require("dnsjit.core.objects")
11 | local input = require("dnsjit.input.pcap").new()
12 | local layer = require("dnsjit.filter.layer").new()
13 | local dns = require("dnsjit.core.object.dns").new()
14 |
15 | input:open_offline(pcap)
16 | layer:producer(input)
17 | local producer, ctx = layer:produce()
18 |
19 | while true do
20 | local obj = producer(ctx)
21 | if obj == nil then break end
22 | local pl = obj:cast()
23 | if obj:type() == "payload" and pl.len > 0 then
24 | local transport = obj.obj_prev
25 | while transport ~= nil do
26 | if transport.obj_type == object.IP or transport.obj_type == object.IP6 then
27 | break
28 | end
29 | transport = transport.obj_prev
30 | end
31 | local protocol = obj.obj_prev
32 | while protocol ~= nil do
33 | if protocol.obj_type == object.UDP or protocol.obj_type == object.TCP then
34 | break
35 | end
36 | protocol = protocol.obj_prev
37 | end
38 |
39 | dns:reset()
40 | if protocol ~= nil and protocol.obj_type == object.TCP then
41 | dns.includes_dnslen = 1
42 | end
43 | dns.obj_prev = obj
44 | if transport ~= nil and dns:parse_header() == 0 and dns.have_rcode == 1 and dns.rcode == rcode then
45 | transport = transport:cast()
46 | print(dns.id, transport:source().." -> "..transport:destination())
47 | end
48 | end
49 | end
50 |
--------------------------------------------------------------------------------
/src/core/object.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #ifndef __dnsjit_core_object_h
22 | #define __dnsjit_core_object_h
23 |
24 | #define CORE_OBJECT_NONE 0
25 | #define CORE_OBJECT_PCAP 1
26 | /* link level objects */
27 | #define CORE_OBJECT_ETHER 10
28 | #define CORE_OBJECT_NULL 11
29 | #define CORE_OBJECT_LOOP 12
30 | #define CORE_OBJECT_LINUXSLL 13
31 | #define CORE_OBJECT_IEEE802 14
32 | #define CORE_OBJECT_GRE 15
33 | #define CORE_OBJECT_LINUXSLL2 16
34 | /* protocol objects */
35 | #define CORE_OBJECT_IP 20
36 | #define CORE_OBJECT_IP6 21
37 | #define CORE_OBJECT_ICMP 22
38 | #define CORE_OBJECT_ICMP6 23
39 | /* payload carrying objects */
40 | #define CORE_OBJECT_UDP 30
41 | #define CORE_OBJECT_TCP 31
42 | /* payload */
43 | #define CORE_OBJECT_PAYLOAD 40
44 | /* service object(s) */
45 | #define CORE_OBJECT_DNS 50
46 |
47 | #include
48 | #include
49 |
50 | #define CORE_OBJECT_INIT(type, prev) (core_object_t*)prev, type
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/examples/modules/output-example/src/output/null.c:
--------------------------------------------------------------------------------
1 | #include "config.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | typedef struct output_null {
9 | core_log_t _log;
10 | core_producer_t prod;
11 | void* ctx;
12 | size_t pkts;
13 | } output_null_t;
14 |
15 | static core_log_t _log = LOG_T_INIT("example.output.null");
16 | static output_null_t _defaults = {
17 | LOG_T_INIT_OBJ("example.output.null"),
18 | 0, 0, 0
19 | };
20 |
21 | core_log_t* output_null_log()
22 | {
23 | return &_log;
24 | }
25 |
26 | void output_null_init(output_null_t* self)
27 | {
28 | mlassert_self();
29 |
30 | *self = _defaults;
31 | }
32 |
33 | void output_null_destroy(output_null_t* self)
34 | {
35 | mlassert_self();
36 | }
37 |
38 | static void _receive(output_null_t* self, const core_object_t* obj)
39 | {
40 | mlassert_self();
41 |
42 | self->pkts++;
43 | }
44 |
45 | core_receiver_t output_null_receiver()
46 | {
47 | return (core_receiver_t)_receive;
48 | }
49 |
50 | void output_null_run(output_null_t* self, int64_t num)
51 | {
52 | mlassert_self();
53 |
54 | if (!self->prod) {
55 | lfatal("no producer set");
56 | }
57 |
58 | if (num > 0) {
59 | while (num--) {
60 | const core_object_t* obj = self->prod(self->ctx);
61 | if (!obj)
62 | break;
63 |
64 | self->pkts++;
65 | }
66 | } else {
67 | for (;;) {
68 | const core_object_t* obj = self->prod(self->ctx);
69 | if (!obj)
70 | break;
71 |
72 | self->pkts++;
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/m4/ax_append_flag.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_append_flag.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
8 | #
9 | # DESCRIPTION
10 | #
11 | # FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
12 | # added in between.
13 | #
14 | # If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
15 | # CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
16 | # FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
17 | # FLAG.
18 | #
19 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
20 | #
21 | # LICENSE
22 | #
23 | # Copyright (c) 2008 Guido U. Draheim
24 | # Copyright (c) 2011 Maarten Bosmans
25 | #
26 | # Copying and distribution of this file, with or without modification, are
27 | # permitted in any medium without royalty provided the copyright notice
28 | # and this notice are preserved. This file is offered as-is, without any
29 | # warranty.
30 |
31 | #serial 8
32 |
33 | AC_DEFUN([AX_APPEND_FLAG],
34 | [dnl
35 | AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
36 | AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
37 | AS_VAR_SET_IF(FLAGS,[
38 | AS_CASE([" AS_VAR_GET(FLAGS) "],
39 | [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
40 | [
41 | AS_VAR_APPEND(FLAGS,[" $1"])
42 | AC_RUN_LOG([: FLAGS="$FLAGS"])
43 | ])
44 | ],
45 | [
46 | AS_VAR_SET(FLAGS,[$1])
47 | AC_RUN_LOG([: FLAGS="$FLAGS"])
48 | ])
49 | AS_VAR_POPDEF([FLAGS])dnl
50 | ])dnl AX_APPEND_FLAG
51 |
--------------------------------------------------------------------------------
/src/core/assert.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #ifndef __dnsjit_core_assert_h
22 | #define __dnsjit_core_assert_h
23 |
24 | #include
25 |
26 | #define mlassert_self() \
27 | if (!self) \
28 | core_log_fatal(&_log, __FILE__, __LINE__, "self is nil")
29 | #define glassert_self() \
30 | if (!self) \
31 | core_log_fatal(0, __FILE__, __LINE__, "self is nil")
32 |
33 | #define lassert(expression, msg...) \
34 | if (!(expression)) \
35 | core_log_fatal(&self->_log, __FILE__, __LINE__, msg)
36 | #define lpassert(expression, msg...) \
37 | if (!(expression)) \
38 | core_log_fatal(self->_log, __FILE__, __LINE__, msg)
39 | #define mlassert(expression, msg...) \
40 | if (!(expression)) \
41 | core_log_fatal(&_log, __FILE__, __LINE__, msg)
42 | #define glassert(expression, msg...) \
43 | if (!(expression)) \
44 | core_log_fatal(0, __FILE__, __LINE__, msg)
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/src/core/object/ip6.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 |
24 | #ifndef __dnsjit_core_object_ip6_h
25 | #define __dnsjit_core_object_ip6_h
26 |
27 | #include
28 |
29 | #include
30 |
31 | #define CORE_OBJECT_IP6_INIT(prev) \
32 | { \
33 | CORE_OBJECT_INIT(CORE_OBJECT_IP6, prev) \
34 | , \
35 | 0, 0, 0, 0, \
36 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \
37 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \
38 | 0, 0, 0, 0, \
39 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \
40 | 0, \
41 | }
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/src/filter/split.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.log")
22 | // lua:require("dnsjit.core.receiver_h")
23 |
24 | typedef enum filter_split_mode {
25 | FILTER_SPLIT_MODE_ROUNDROBIN,
26 | FILTER_SPLIT_MODE_SENDALL
27 | } filter_split_mode_t;
28 |
29 | typedef struct filter_split_recv filter_split_recv_t;
30 | struct filter_split_recv {
31 | filter_split_recv_t* next;
32 | core_receiver_t recv;
33 | void* ctx;
34 | };
35 |
36 | typedef struct filter_split {
37 | core_log_t _log;
38 | filter_split_mode_t mode;
39 | filter_split_recv_t* recv_first;
40 | filter_split_recv_t* recv;
41 | filter_split_recv_t* recv_last;
42 | } filter_split_t;
43 |
44 | core_log_t* filter_split_log();
45 |
46 | void filter_split_init(filter_split_t* self);
47 | void filter_split_destroy(filter_split_t* self);
48 | void filter_split_add(filter_split_t* self, core_receiver_t recv, void* ctx);
49 |
50 | core_receiver_t filter_split_receiver(filter_split_t* self);
51 |
--------------------------------------------------------------------------------
/examples/capture.lua:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env dnsjit
2 | local interface = arg[2]
3 |
4 | if interface == nil then
5 | print("usage: "..arg[1].." ")
6 | return
7 | end
8 |
9 | local object = require("dnsjit.core.objects")
10 | local input = require("dnsjit.input.pcap").new()
11 | local layer = require("dnsjit.filter.layer").new()
12 | local dns = require("dnsjit.core.object.dns").new()
13 |
14 | input:create(interface)
15 | input:activate()
16 | layer:producer(input)
17 | local producer, ctx = layer:produce()
18 |
19 | while true do
20 | local obj = producer(ctx)
21 | if obj == nil then break end
22 | local pl = obj:cast()
23 | if obj:type() == "payload" and pl.len > 0 then
24 | local transport = obj.obj_prev
25 | while transport ~= nil do
26 | if transport.obj_type == object.IP or transport.obj_type == object.IP6 then
27 | break
28 | end
29 | transport = transport.obj_prev
30 | end
31 | local protocol = obj.obj_prev
32 | while protocol ~= nil do
33 | if protocol.obj_type == object.UDP or protocol.obj_type == object.TCP then
34 | break
35 | end
36 | protocol = protocol.obj_prev
37 | end
38 |
39 | dns:reset()
40 | if protocol ~= nil and protocol.obj_type == object.TCP then
41 | dns.includes_dnslen = 1
42 | end
43 | dns.obj_prev = obj
44 | if transport ~= nil and protocol ~= nil then
45 | transport = transport:cast()
46 | protocol = protocol:cast()
47 | print(protocol:type().." "..transport:source()..":"..tonumber(protocol.sport).." -> "..transport:destination()..":"..tonumber(protocol.dport))
48 | dns:print()
49 | end
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/m4/ax_prepend_flag.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_prepend_flag.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_PREPEND_FLAG(FLAG, [FLAGS-VARIABLE])
8 | #
9 | # DESCRIPTION
10 | #
11 | # FLAG is added to the front of the FLAGS-VARIABLE shell variable, with a
12 | # space added in between.
13 | #
14 | # If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
15 | # CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
16 | # FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
17 | # FLAG.
18 | #
19 | # NOTE: Implementation based on AX_APPEND_FLAG.
20 | #
21 | # LICENSE
22 | #
23 | # Copyright (c) 2008 Guido U. Draheim
24 | # Copyright (c) 2011 Maarten Bosmans
25 | # Copyright (c) 2018 John Zaitseff
26 | #
27 | # Copying and distribution of this file, with or without modification, are
28 | # permitted in any medium without royalty provided the copyright notice
29 | # and this notice are preserved. This file is offered as-is, without any
30 | # warranty.
31 |
32 | #serial 2
33 |
34 | AC_DEFUN([AX_PREPEND_FLAG],
35 | [dnl
36 | AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
37 | AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
38 | AS_VAR_SET_IF(FLAGS,[
39 | AS_CASE([" AS_VAR_GET(FLAGS) "],
40 | [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
41 | [
42 | FLAGS="$1 $FLAGS"
43 | AC_RUN_LOG([: FLAGS="$FLAGS"])
44 | ])
45 | ],
46 | [
47 | AS_VAR_SET(FLAGS,[$1])
48 | AC_RUN_LOG([: FLAGS="$FLAGS"])
49 | ])
50 | AS_VAR_POPDEF([FLAGS])dnl
51 | ])dnl AX_PREPEND_FLAG
52 |
--------------------------------------------------------------------------------
/src/core/timespec.lua:
--------------------------------------------------------------------------------
1 | -- Copyright (c) 2018-2025 OARC, Inc.
2 | -- All rights reserved.
3 | --
4 | -- This file is part of dnsjit.
5 | --
6 | -- dnsjit is free software: you can redistribute it and/or modify
7 | -- it under the terms of the GNU General Public License as published by
8 | -- the Free Software Foundation, either version 3 of the License, or
9 | -- (at your option) any later version.
10 | --
11 | -- dnsjit is distributed in the hope that it will be useful,
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | -- GNU General Public License for more details.
15 | --
16 | -- You should have received a copy of the GNU General Public License
17 | -- along with dnsjit. If not, see .
18 |
19 | -- dnsjit.core.receiver
20 | -- Non-system depended time specification structure definition
21 | -- typedef struct core_timespec {
22 | -- int64_t sec;
23 | -- int64_t nsec;
24 | -- } core_timespec_t;
25 | -- .SS C
26 | -- #include "core/timespec.h"
27 | -- .SS Lua
28 | -- require("dnsjit.core.timespec_h")
29 | -- .SS Lua functions
30 | -- local ts = require("dnsjit.core.timespec"):max_init()
31 | --
32 | -- Mainly used in C modules for a system independent time specification
33 | -- structure that can be passed to Lua.
34 | module(...,package.seeall)
35 |
36 | require("dnsjit.core.timespec_h")
37 |
38 | local ffi = require("ffi")
39 |
40 | local Timespec = {}
41 |
42 | -- Return a new structure with both
43 | -- .I sec
44 | -- and
45 | -- .I nsec
46 | -- set to 2LL ^ 62, the maximum positive values according to Lua.
47 | function Timespec:max_init()
48 | local ts = ffi.new("core_timespec_t")
49 | ts.sec = 2LL ^ 62
50 | ts.nsec = 2LL ^ 62
51 | return ts
52 | end
53 |
54 | return Timespec
55 |
--------------------------------------------------------------------------------
/debian/control:
--------------------------------------------------------------------------------
1 | Source: dnsjit
2 | Section: net
3 | Priority: optional
4 | Maintainer: Jerry Lundström
5 | Build-Depends: debhelper (>= 10), build-essential, automake,
6 | autoconf (>= 2.64), libpcap-dev, netbase, libtool,
7 | libluajit-5.1-dev (>= 2.0.0), luajit (>= 2.0.0), pkg-config, liblmdb-dev,
8 | libck-dev, gcc (>= 4:5.0.0) | gcc-5, libgnutls28-dev, liblz4-dev,
9 | libzstd-dev (>= 1.3.0) | libzstd1-dev (>= 1.3.0), zlib1g-dev (>= 1.2.0),
10 | liblzma-dev (>= 5.2.0)
11 | Standards-Version: 3.9.4
12 | Homepage: https://www.dns-oarc.net/tools/dnsjit
13 | Vcs-Git: https://codeberg.org/DNS-OARC/dnsjit.git
14 | Vcs-Browser: https://codeberg.org/DNS-OARC/dnsjit
15 |
16 | Package: dnsjit
17 | Architecture: any
18 | Depends: ${shlibs:Depends}, ${misc:Depends}
19 | Description: Engine for capturing, parsing and replaying DNS
20 | dnsjit is a combination of parts taken from dsc, dnscap, drool,
21 | and put together around Lua to create a script-based engine for easy
22 | capturing, parsing and statistics gathering of DNS message while also
23 | providing facilities for replaying DNS traffic.
24 |
25 | Package: dnsjit-dev
26 | Architecture: any
27 | Depends: libluajit-5.1-dev (>= 2.0.0), luajit (>= 2.0.0), liblmdb-dev,
28 | libck-dev, gcc (>= 4:5.0.0) | gcc-5, libgnutls28-dev, liblz4-dev,
29 | libzstd-dev (>= 1.3.0) | libzstd1-dev (>= 1.3.0), zlib1g-dev (>= 1.2.0),
30 | liblzma-dev (>= 5.2.0)
31 | Description: Engine for capturing, parsing and replaying DNS - development files
32 | dnsjit is a combination of parts taken from dsc, dnscap, drool,
33 | and put together around Lua to create a script-based engine for easy
34 | capturing, parsing and statistics gathering of DNS message while also
35 | providing facilities for replaying DNS traffic.
36 | .
37 | This package includes development files needed to create dnsjit modules.
38 |
--------------------------------------------------------------------------------
/src/filter/timing.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.log")
22 | // lua:require("dnsjit.core.receiver_h")
23 | // lua:require("dnsjit.core.producer_h")
24 | // lua:require("dnsjit.core.timespec_h")
25 |
26 | typedef struct filter_timing {
27 | core_log_t _log;
28 | core_receiver_t recv;
29 | void* ctx;
30 | enum {
31 | TIMING_MODE_KEEP = 0,
32 | TIMING_MODE_INCREASE = 1,
33 | TIMING_MODE_REDUCE = 2,
34 | TIMING_MODE_MULTIPLY = 3,
35 | TIMING_MODE_FIXED = 4,
36 | TIMING_MODE_REALTIME = 5
37 | } mode;
38 | size_t inc, red, fixed, rt_batch;
39 | float mul;
40 | uint64_t rt_drift;
41 |
42 | core_producer_t prod;
43 | void* prod_ctx;
44 | } filter_timing_t;
45 |
46 | core_log_t* filter_timing_log();
47 |
48 | filter_timing_t* filter_timing_new();
49 | void filter_timing_free(filter_timing_t* self);
50 |
51 | core_receiver_t filter_timing_receiver(filter_timing_t* self);
52 | core_producer_t filter_timing_producer(filter_timing_t* self);
53 |
--------------------------------------------------------------------------------
/src/input/pcap.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #if 0
22 | typedef struct pcap {} pcap_t;
23 | #endif
24 |
25 | // lua:require("dnsjit.core.log")
26 | // lua:require("dnsjit.core.receiver_h")
27 | // lua:require("dnsjit.core.producer_h")
28 | // lua:require("dnsjit.core.object.pcap_h")
29 |
30 | typedef struct input_pcap {
31 | core_log_t _log;
32 | core_receiver_t recv;
33 | void* ctx;
34 |
35 | uint8_t is_swapped;
36 |
37 | core_object_pcap_t prod_pkt;
38 |
39 | pcap_t* pcap;
40 | size_t pkts;
41 |
42 | size_t snaplen;
43 | uint32_t linktype;
44 | } input_pcap_t;
45 |
46 | core_log_t* input_pcap_log();
47 |
48 | void input_pcap_init(input_pcap_t* self);
49 | void input_pcap_destroy(input_pcap_t* self);
50 | int input_pcap_create(input_pcap_t* self, const char* source);
51 | int input_pcap_activate(input_pcap_t* self);
52 | int input_pcap_open_offline(input_pcap_t* self, const char* file);
53 | int input_pcap_loop(input_pcap_t* self, int cnt);
54 | int input_pcap_dispatch(input_pcap_t* self, int cnt);
55 |
56 | core_producer_t input_pcap_producer(input_pcap_t* self);
57 |
--------------------------------------------------------------------------------
/src/globals.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | #include "config.h"
22 |
23 | #include "globals.h"
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | void dnsjit_globals(lua_State* L)
30 | {
31 | #ifdef PACKAGE_VERSION
32 | lua_pushstring(L, PACKAGE_VERSION);
33 | #elif defined(VERSION)
34 | lua_pushstring(L, VERSION);
35 | #else
36 | #error "No PACKAGE_VERSION or VERSION defined"
37 | #endif
38 | lua_setglobal(L, "DNSJIT_VERSION");
39 |
40 | lua_pushinteger(L, PACKAGE_MAJOR_VERSION);
41 | lua_setglobal(L, "DNSJIT_MAJOR_VERSION");
42 | lua_pushinteger(L, PACKAGE_MINOR_VERSION);
43 | lua_setglobal(L, "DNSJIT_MINOR_VERSION");
44 | lua_pushinteger(L, PACKAGE_PATCH_VERSION);
45 | lua_setglobal(L, "DNSJIT_PATCH_VERSION");
46 |
47 | #ifdef PACKAGE_BUGREPORT
48 | lua_pushstring(L, PACKAGE_BUGREPORT);
49 | #else
50 | lua_pushstring(L, "none");
51 | #endif
52 | lua_setglobal(L, "DNSJIT_BUGREPORT");
53 |
54 | #ifdef PACKAGE_URL
55 | lua_pushstring(L, PACKAGE_URL);
56 | #else
57 | lua_pushstring(L, "none");
58 | #endif
59 | lua_setglobal(L, "DNSJIT_URL");
60 | }
61 |
--------------------------------------------------------------------------------
/src/core/channel.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.compat_h")
22 | // lua:require("dnsjit.core.log")
23 | // lua:require("dnsjit.core.receiver_h")
24 |
25 | typedef struct core_channel {
26 | core_log_t _log;
27 | ck_ring_buffer_t* ring_buf;
28 | ck_ring_t ring;
29 | int closed;
30 | size_t capacity;
31 |
32 | core_receiver_t recv;
33 | void* ctx;
34 | } core_channel_t;
35 |
36 | core_log_t* core_channel_log();
37 |
38 | void core_channel_init(core_channel_t* self, size_t capacity);
39 | void core_channel_destroy(core_channel_t* self);
40 | void core_channel_put(core_channel_t* self, const void* obj);
41 | int core_channel_try_put(core_channel_t* self, const void* obj);
42 | void* core_channel_get(core_channel_t* self);
43 | void* core_channel_try_get(core_channel_t* self);
44 | int core_channel_size(core_channel_t* self);
45 | bool core_channel_full(core_channel_t* self);
46 | void core_channel_close(core_channel_t* self);
47 |
48 | core_receiver_t core_channel_receiver();
49 | void core_channel_run(core_channel_t* self);
50 |
--------------------------------------------------------------------------------
/examples/modules/filter-example/src/filter/counter.c:
--------------------------------------------------------------------------------
1 | #include "config.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | typedef struct filter_counter {
9 | core_log_t _log;
10 |
11 | core_receiver_t recv;
12 | void* ctx;
13 |
14 | core_producer_t prod;
15 | void* prod_ctx;
16 |
17 | size_t count;
18 | } filter_counter_t;
19 |
20 | static core_log_t _log = LOG_T_INIT("example.filter.counter");
21 | static filter_counter_t _defaults = {
22 | LOG_T_INIT_OBJ("example.filter.counter"),
23 | 0, 0,
24 | 0, 0,
25 | 0
26 | };
27 |
28 | core_log_t* filter_counter_log()
29 | {
30 | return &_log;
31 | }
32 |
33 | void filter_counter_init(filter_counter_t* self)
34 | {
35 | mlassert_self();
36 |
37 | *self = _defaults;
38 | }
39 |
40 | void filter_counter_destroy(filter_counter_t* self)
41 | {
42 | mlassert_self();
43 | }
44 |
45 | static void _receive(filter_counter_t* self, const core_object_t* obj)
46 | {
47 | mlassert_self();
48 | lassert(obj, "obj is nil");
49 |
50 | if (!self->recv) {
51 | lfatal("no receiver set");
52 | }
53 | self->count++;
54 | self->recv(self->ctx, obj);
55 | }
56 |
57 | core_receiver_t filter_counter_receiver()
58 | {
59 | return (core_receiver_t)_receive;
60 | }
61 |
62 | static const core_object_t* _produce(filter_counter_t* self)
63 | {
64 | const core_object_t* obj;
65 | mlassert_self();
66 |
67 | obj = self->prod(self->prod_ctx);
68 | if (obj) {
69 | self->count++;
70 | }
71 |
72 | return obj;
73 | }
74 |
75 | core_producer_t filter_counter_producer(filter_counter_t* self)
76 | {
77 | mlassert_self();
78 |
79 | if (!self->prod) {
80 | lfatal("no producer set");
81 | }
82 |
83 | return (core_producer_t)_produce;
84 | }
85 |
--------------------------------------------------------------------------------
/src/input/mmpcap.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | // lua:require("dnsjit.core.log")
22 | // lua:require("dnsjit.core.receiver_h")
23 | // lua:require("dnsjit.core.producer_h")
24 | // lua:require("dnsjit.core.object.pcap_h")
25 |
26 | typedef struct input_mmpcap {
27 | core_log_t _log;
28 | core_receiver_t recv;
29 | void* ctx;
30 |
31 | uint8_t is_swapped;
32 | uint8_t is_nanosec;
33 | uint8_t is_broken;
34 |
35 | core_object_pcap_t prod_pkt;
36 |
37 | int fd;
38 | size_t len, at;
39 | size_t pkts;
40 | uint8_t* buf;
41 |
42 | uint32_t magic_number;
43 | uint16_t version_major;
44 | uint16_t version_minor;
45 | int32_t thiszone;
46 | uint32_t sigfigs;
47 | uint32_t snaplen;
48 | uint32_t network;
49 |
50 | uint32_t linktype;
51 | } input_mmpcap_t;
52 |
53 | core_log_t* input_mmpcap_log();
54 |
55 | void input_mmpcap_init(input_mmpcap_t* self);
56 | void input_mmpcap_destroy(input_mmpcap_t* self);
57 | int input_mmpcap_open(input_mmpcap_t* self, const char* file);
58 | int input_mmpcap_run(input_mmpcap_t* self);
59 |
60 | core_producer_t input_mmpcap_producer(input_mmpcap_t* self);
61 |
--------------------------------------------------------------------------------
/src/core/log.hh:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018-2025 OARC, Inc.
3 | * All rights reserved.
4 | *
5 | * This file is part of dnsjit.
6 | *
7 | * dnsjit is free software: you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * dnsjit is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with dnsjit. If not, see .
19 | */
20 |
21 | typedef struct core_log_settings {
22 | uint8_t debug;
23 | uint8_t info;
24 | uint8_t notice;
25 | uint8_t warning;
26 | uint8_t display_file_line;
27 | } core_log_settings_t;
28 |
29 | typedef struct core_log {
30 | char name[32];
31 | uint8_t is_obj;
32 | core_log_settings_t settings;
33 | const core_log_settings_t* module;
34 | } core_log_t;
35 |
36 | void core_log_debug(const core_log_t* l, const char* file, size_t line, const char* msg, ...);
37 | void core_log_info(const core_log_t* l, const char* file, size_t line, const char* msg, ...);
38 | void core_log_notice(const core_log_t* l, const char* file, size_t line, const char* msg, ...);
39 | void core_log_warning(const core_log_t* l, const char* file, size_t line, const char* msg, ...);
40 | void core_log_critical(const core_log_t* l, const char* file, size_t line, const char* msg, ...);
41 | void core_log_fatal(const core_log_t* l, const char* file, size_t line, const char* msg, ...);
42 | const char* core_log_errstr(int err);
43 |
44 | core_log_t* core_log_log();
45 |
--------------------------------------------------------------------------------