Compare commits

..

No commits in common. "3e89bbf678322d6b7b243dd214f3b5d5ac6be651" and "f3ce14142ab78a276b839759462f4a8d8ef8c3e7" have entirely different histories.

65 changed files with 69005 additions and 3855 deletions

View file

@ -1,23 +0,0 @@
top=..
all: srpm
prereq: $(top)/rpmbuild
rpm -q git rpm-build >/dev/null || dnf -y install git rpm-build
update-dist-tools: $(top)/dist-tools
( cd "$(top)/dist-tools" && git pull )
$(top)/dist-tools:
git clone https://github.com/jelu/dist-tools.git "$(top)/dist-tools"
$(top)/rpmbuild:
mkdir -p "$(top)"/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
srpm: prereq update-dist-tools
test -f .gitmodules && git submodule update --init || true
echo "$(spec)" | grep -q "develop.spec" && auto_build_number=`date --utc +%s` message="Auto build `date --utc --iso-8601=seconds`" "$(top)/dist-tools/spec-new-changelog-entry" || true
overwrite=yes nosign=yes "$(top)/dist-tools/create-source-packages" rpm
cp ../*.orig.tar.gz "$(top)/rpmbuild/SOURCES/"
echo "$(spec)" | grep -q "develop.spec" && rpmbuild -bs --define "%_topdir $(top)/rpmbuild" --undefine=dist rpm/*.spec || rpmbuild -bs --define "%_topdir $(top)/rpmbuild" --undefine=dist "$(spec)"
cp "$(top)"/rpmbuild/SRPMS/*.src.rpm "$(outdir)"

1
.github/FUNDING.yml vendored
View file

@ -1 +0,0 @@
custom: https://www.dns-oarc.net/donate

View file

@ -1,56 +0,0 @@
name: "CodeQL"
on:
push:
branches: [ "develop", "master" ]
pull_request:
branches: [ "develop" ]
schedule:
- cron: "53 20 * * 4"
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ cpp, python ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Packages (cpp)
if: ${{ matrix.language == 'cpp' }}
run: |
sudo add-apt-repository --yes ppa:dns-oarc/dnscap-pr
sudo apt-get update
sudo apt-get install --yes build-essential automake autoconf libtool pkg-config libpcap-dev libldns-dev libyaml-perl zlib1g-dev libssl-dev libcryptopant-dev
- name: Configure (cpp)
if: ${{ matrix.language == 'cpp' }}
run: |
./autogen.sh
./configure
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ matrix.language }}"

37
.gitignore vendored
View file

@ -1,37 +0,0 @@
*.o
*.lo
*.la
config.log
config.status
stamp-h1
ar-lib
config.guess
config.sub
libtool
ltmain.sh
.deps
.libs
Makefile
Makefile.in
src/dnscap
src/dnscap.1
autom4te.cache
Makefile.old
aclocal.m4
compile
configure
configure~
depcomp
install-sh
missing
test-driver
config.h
config.h.in~
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
build/
config.h.in
dnscap-[0-9]*tar*

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "src/pcap-thread"]
path = src/pcap-thread
url = https://github.com/DNS-OARC/pcap-thread.git

View file

@ -1,26 +0,0 @@
extraction:
cpp:
prepare:
packages:
- build-essential
- automake
- autoconf
- libtool
- pkg-config
- libpcap-dev
- libldns-dev
- libyaml-perl
- zlib1g-dev
- libssl-dev
after_prepare:
- git clone https://github.com/DNS-OARC/cryptopANT.git
- cd cryptopANT
- ./autogen.sh
- ./configure --prefix="$PWD/../root"
- make
- make install
- cd ..
configure:
command:
- ./autogen.sh
- ./configure --with-extra-cflags="-I $PWD/root/include" --with-extra-ldflags="-L$PWD/root/lib"

View file

@ -1,399 +0,0 @@
# CBOR DNS Stream Format version 1 (CDSv1)
This is an experimental format for representing DNS information in CBOR
with the goals to:
- Be able to stream the information
- Support incomplete, broken and/or invalid DNS
- Have close to no data quality and signature degradation
- Support additional non-DNS meta data (such as ICMP/TCP attributes)
## Overview
In CBOR you are expected to have one root element, most likely an array or
map. This format does not have a root element, instead you are expected to
read one CBOR array element at a time as a stream of CBOR elements with the
first array element being the stream initiator object.
```
[stream_init]
[message]
...
[message]
```
Here are some number on the compression rate compared to PCAP:
Uncompressed | PCAP | CDS | Factor
-------------|------------|-----------|-------
client | 458373 | 133640 | 0,2915
zonalizer | 51769844 | 9450475 | 0,1825
large ditl | 1003931674 | 298167709 | 0,2970
small ditl | 1651252 | 603314 | 0,3653
Gzipped | PCAP | CDS | Factor | F/Uncompressed
-------------|------------|-----------|---------|---------------
client | 108136 | 45944 | 0,4248 | 0,1002
zonalizer | 12468329 | 2485620 | 0,1993 | 0,0480
large ditl | 327227203 | 117569598 | 0,3592 | 0,1171
small ditl | 539323 | 253402 | 0,4698 | 0,1534
Xzipped | PCAP | CDS | Factor | F/Uncompressed
-------------|------------|-----------|---------|---------------
client | 76248 | 36308 | 0,4761 | 0,0792
zonalizer | 7894356 | 1695920 | 0,2148 | 0,0327
large ditl | 267031412 | 86747604 | 0,3248 | 0,0864
small ditl | 442260 | 206596 | 0,4671 | 0,1251
- `client` is a couple of hours of DNS from my workstation
- `zonalizer` is half a day from [Zonalizer](https://zonalizer.makeinstall.se) which continuously tests gTLDs
- `large ditl`, `small ditl` are capture from [DITL](https://www.dns-oarc.net/oarc/data/ditl)
## Types
- `int`: A CBOR integer (major type 0x00)
- `uint`: A CBOR integer (value >= 0, major type 0x00)
- `nint`: A CBOR negative integer (value < 0, major type 0x00), this type has special meaning see `Negative Integers`
- `simple`: A CBOR simple value (major type 0xe0)
- `bytes`: A CBOR byte string (major type 0x40)
- `string`: A CBOR UTF-8 string (major type 0x60)
- `any`: Any CBOR value
- `bool`: A CBOR boolean
- `rindex`: A CBOR negative integer that is a reverse index, see `Deduplication`
## Special Keywords
- `union`: Can be used to merge the given array or map into the current object
- `optional`: The attribute or object reference is optional
## Negative Integers
CBOR encodes negative numbers in a special way and this format uses that
for none negative number to tell them apart.
Because of that, all negative numbers needs special decoding:
```
value = -value - 1
```
## Objects
The object code below uses:
- `[` and `]` to indicate the start and end of an array
- `type name` per object attribute
- `name` per object reference
- `...` to indicate a list of previous definition
- `(`, `|` and `)` to indicate list of various types that the attribute can be
### stream_init
The initial object in the stream.
```
[
string version,
union stream_option option,
...
]
```
- `version`: The version of the format
- `option`: A list of stream option objects
### stream_option
A stream option that can specify critical information about the stream and
how it should be decoded, see `Stream Options` for more information.
```
[
uint option_type,
optional any option_value
]
```
- `option_type`: The type of option represented as a number
- `option_value`: The option value
### message
A message object that describes various DNS packets or other information.
```
[
optional bool is_complete,
union timestamp timestamp,
simple message_bits,
union ip_header ip_header,
union ( icmp_message | udp_message | tcp_message | dns_message ) content
]
```
- `is_complete`: Will exist and be false if the message is not complete and following attributes may not exists
- `timestamp`: A timestamp object
- `message_bits`: Bitmap indicating message content
- Bit 0: 0=Not DNS 1=DNS
- Bit 1: if DNS: 0=UDP 1=TCP else: 0=ICMP/ICMPv6 1=TCP
- Bit 2: Fragmented (0=no 1=yes)
- Bit 3: Malformed (0=no 1=yes)
- `ip_header`: An IP header object
- `content`: The message content, may be an ICMP, UDP, TCP or DNS message object
### timestamp
The timestamp object of a message.
```
[
( uint seconds | nint diff_from_last ),
optional uint useconds
optional uint nseconds
]
```
- `seconds`: The seconds of a UNIX timestamp
- `diff_from_last`: The differentially from last `timestamp.seconds`
- `useconds`: The microseconds of a UNIX timestamp or if `diff_from_last` is used it will be the differentially from last `timestamp.useconds`
- `nseconds`: The nanoseconds of a UNIX timestamp or if `diff_from_last` is used it will be the differentially from last `timestamp.nseconds`
### ip_header
The IP header of a message.
```
[
( uint | nint ) ip_bits,
optional bytes src_addr,
optional bytes dest_addr,
optional ( uint | nint ) src_dest_port
]
```
- `ip_bits`: Bitmap indicating IP header content, if the type is `nint` it also indicates that it is a reverse from last, see `Deduplication` for more information
- Bit 0: address family (0=AF_INET, 1=AF_INET6)
- Bit 1: src_addr present
- Bit 2: dest_addr present
- Bit 3: port present
- `src_addr`: The source address with length specifying address family, 4 bytes is IPv4 and 16 is IPv6
- `dest_addr`: The destination address with length specifying address family, 4 bytes is IPv4 and 16 is IPv6
- `src_dest_port`: A combined source and destination port, see `Source And Destination Port`
#### Source And Destination Port
The source and destination port are combined into one value. If both source
and destination exists then the value is larger then 65535, the destination
will be the high 16 bits and source the low otherwise it will only be the
source. If the value is negative then only the destination exists.
```
if value > 0xffff then
src_port = value & 0xffff
dest_port = value >> 16
else if value < 0 then
dest_port = -value - 1
else
src_port = value
```
### icmp_message
`if ip_header.ip_bits.1=0 && ip_header.ip_bits.2=0`
```
[
uint type,
uint code
]
```
- `type`: TODO
- `code`: TODO
### udp_message
`if ip_header.ip_bits.1=1 && ip_header.ip_bits.2=0`
TODO
### tcp_message
`if ip_header.ip_bits.2=1`
```
[
uint seq_nr,
uint ack_nr,
uint tcp_bits,
uint window
]
```
- `seq_nr`: TODO
- `ack_nr`: TODO
- `tcp_bits`: TODO
- 0: URG
- 1: ACK
- 2: PSH
- 3: RST
- 4: SYN
- 5: FIN
- `window`: TODO
### dns_message
A DNS packet.
```
[
optional bool is_complete,
uint id,
uint raw_dns_header, # TODO
optional nint count_bits,
optional uint qdcount,
optional uint ancount,
optional uint nscount,
optional uint arcount,
optional simple rr_bits,
optional [
dns_question question,
...
],
optional [
resource_record answer,
...
],
optional [
resource_record authority,
...
],
optional [
resource_record additional,
...
],
optional bytes malformed
]
```
- `is_complete`: Will exist and be false if the message is not complete and following attributes may not exists
- `id`: DNS identifier
- `raw_dns_header`: TODO
- `count_bits`: Bitmap indicating which counts are present, see `Negative Integers` and `Deduplication`
- Bit 0: qdcount present
- Bit 1: ancount present
- Bit 2: nscount present
- Bit 3: arcount present
- `qdcount`: Number of question records if different from the number of entries in `question`
- `ancount`: Number of answer resource records if different from the number of entries in `answer`
- `nscount`: Number of authority resource records if different from the number of entries in `authority`
- `arcount`: Number of additional resource records if different from the number of entries in `additional`
- `question`: The question records
- `answer`: The answer resource records
- `authority`: The authority resource records
- `additional`: The additional resource records
- `malformed`: Holds the bytes of the message that was not parsed
### question
A DNS question record.
```
[
optional bool is_complete,
( bytes | compressed_name | rindex ) qname,
optional uint qtype,
optional nint qclass
]
```
- `is_complete`: Will exist and be false if the message is not complete and following attributes may not exists
- `qname`: The QNAME as byte string, a name compression object or a reverse index, see `Deduplication`
- `qtype`: The QTYPE, see `Deduplication`
- `qclass`: The QCLASS, see `Negative Integers` and `Deduplication`
### compressed_name
An compressed name which has references to other labels within the same message.
```
[
( bytes label | uint label_index | nint offset | simple extension_bits ),
...
]
```
- `label`: A byte string with a label part
- `label_index`: An index to the N byte string label in the message
- `offset`: The offset specified in the DNS message which could not be translated into a label index
- `extension_bits`: The extension bits if not 0b00 or 0b11 # TODO: add the extension bits
### resource_record
A DNS resource record.
```
[
optional bool is_complete,
( bytes | compressed_name | rindex ) name,
optional simple rr_bits,
optional uint type,
optional uint class,
optional uint ttl,
optional uint rdlength,
( bytes | mixed_rdata ) rdata
]
```
- `is_complete`: Will exist and be false if the message is not complete and following attributes may not exists
- `name`:
- `rr_bits`: Bitmap indicating what is present, see `Deduplication`
- Bit 0: type
- Bit 1: class
- Bit 2: ttl
- Bit 3: rdlength # TODO: reverse index for TTL?
- `type`: The resource record type
- `class`: The resource record class
- `ttl`: The resource record ttl
- `rdlength`: The resource record rdata length
- `rdata`: The resource record data
### mixed_rdata
An array mixed with resource data and compressed names.
```
[
( bytes | compressed_name ) rdata_part,
...
]
```
- `rdata_part`: The parts of the resource records data
## Stream Options
Each option is specified here as OptionName(OptionNumber) and optional
OptionValue type.
- `RLABELS(0) uint`: Indicates how many labels should be stored in the reverse label index before discarding them
- `RLABEL_MIN_SIZE(1) uint`: The minimum size a label must be to be put in the reverse label index
- `RDATA_RINDEX_SIZE(2) uint`: Indicates how many rdata should be stored in the reverse rdata index before discarding them
- `RDATA_RINDEX_MIN_SIZE(3) uint`: The minimum size a rdata must be to be put in the reverse rdata index
- `USE_RDATA_INDEX(4)`: If present then the stream uses rdata indexing
- `RDATA_INDEX_MIN_SIZE(5) uint`: The minimum size a rdata must be to be put in the rdata index
## Deduplication
Deduplication is done in a few different ways, data may be left out to
indicate that it is the same as the previous value, an index may be used to
indicate that it is the same as the N previous value and a reverse index
may be used to indicate that it is the N previous value looking backwards
across the stream.
In other words, using the index deduplication you will need to build a table
of the values you come across during the decoding of the stream, this table
can grow very large.
As an smaller alternative a reverse index can indicate often used data from
the N previous value looking back over the stream. This type of index also
reorder itself to try and put the most used data always in the index.
TODO: details of each attribute and it's deduplication

998
CHANGES
View file

@ -1,998 +0,0 @@
2025-04-24 Jerry Lundström
Release 2.3.1
This patch release fixes issues on 32bit systems when they are using
64bit time structures (`_TIME_BITS` set to 64) and updates pcap-thread
to require libpcap with `DLT_LINUX_SLL2` support.
a5e9a4a pcap-thread v4.1.1
731d9e0 Add support for 64bit time structures on 32bit systems
2025-04-17 Jerry Lundström
Release 2.3.0
This release adds support for Linux cooked v2 link-type, a new output
format, a new plugin and fixes a couple of issues.
The new output format `tcpdns` can be used to generate a file with the
DNS as a TCP stream, first 16bit size (network order) then the DNS
message, which is compatible with `dnsperf -B`.
The new plugin `asudp` can be used to rewrite outgoing packet by taking
the DNS that's found and construct UDP packets from it.
Other changes:
- Fix #314:
- man-page: Clarify that `pktsize` is shown before parsing the IP packet
- `-g`: Quote `,` characters
- Fix #316: Fix handling of L2/ethernet frames that are larger than the IPv4/v6 packet
- Fix multiple print statements w.r.t. `size_t`/`struct timeval`, `%zu`/`%ld` and type casting
- Handle extension function pointers better
- Clarify that `-C` counts uncompressed output
- Block PCAP output if TCP reassemble is used
- Increase maximum DNS messages in a reassembled TCP message
- Add new extension interface for setting output packet
- Update pcap-thread to v4.1.0
e689bc8 pcap-thread v4.1.0
29d184b DLT_LINUX_SLL2
ba793a9 Fixes, asudp plugin, tcpdns output format
6c133d4 Ethernet padding
420548a Diag output
8b92a52 SPEC
a3fb1dd Mailing-list
2024-09-10 Jerry Lundström
Release 2.2.1
This patch release fixes the BPF to correct capture ICMPv6, a typo in
the filter had it matching "ip" and not "ip6".
Other changes are updates to GitHub workflows and man-pages.
ea82cd1 Copyright
aa14a9f ICMP BPF filter
6ef17e2 Badges
6722677 Workflow
1cb22f0 Man-page opt, Dumper
2023-08-23 Jerry Lundström
Release 2.2.0
This release adds anonymization of EDNS Client Subnet to all
anonymizer plugins and improves TCP state handling by adding a hash
table for lookup rather than walking a list.
Plugins that anonymize can now take two new options:
- `-e`: also anonymize EDNS Client Subnet
- `-E`: only anonymize EDNS Client Subnet
Other changes:
- Cleanup and improvements to building and testing
- Mention PowerTools repository for building on CentOS etc
- Remove old workarounds in tests before #133
d4e0b2c TCP state hash table
1ea8d3f Doc
12ea061 EDNS Client Subnet anonymization
c9ed7be pcap-dist
b76f745 Cleanup
7682d41 hashtbl
2023-06-27 Jerry Lundström
Release 2.1.3
This release fixes a memory leak when using pattern matching options
`-x` or `-X`, the LDNS packet was not freed correctly.
The processing of the LDNS packet during matching has also been
improved.
3990795 Test
ee5d554 Pattern match
2023-06-15 Jerry Lundström
Release 2.1.2
This release fixes reusing of TCP state during an out-of-memory event,
the reused structure was not cleared of old information. And fixes
compatibility with OpenSSL v3.0+ due to deprecated functions.
756f78a OpenSSL 3.0+
d2bd12f tcpstate on out of memory
2023-02-03 Jerry Lundström
Release 2.1.1
This release includes fixes to TCP state code, anonymizing plugins and
handling of EDNS extended error code.
- Ken Renards @kdrenard (PR #275) fixed handling of EDNS extended error
code, the previous code looked at `arcount` but ldns "consumes" OPT
records so the count could be zero even with existing extended error
code.
- Changed anonymizing plugins to anonymize both sending and receiving
IP address if both used the server port, part of issue #276 reported
by Duane Wessels @wessels. This fixes situations where clients
weren't anonymize because they sent using that port.
- Fixed multiple issues with garbage collection in TCP state handling.
It was reusing a pointer that was meant to return the current TCP
state so it could return the wrong state when garbage collection
was triggered.
It also just unlinked stale states and didn't free them, new code
uses the discard function so released state is also tagged as
"gc stale".
Lastly the discard function was fixed to clear the current TCP state
pointer used by plugins if the discarded state was it.
7f2ddcf Copyright
fd5b744 CodeQL alerts
726d241 TCP state GC
dff421e Anonymize clients
2eb8489 Add CodeQL workflow for GitHub code scanning
c5a0919 Better test for presence of EDNS option with extended error code
2022-09-09 Jerry Lundström
Release 2.1.0
This release adds a new option (`-o pid_file=<file>`) to specify a PID
file when running as daemon, corrects handling of LDNS include files
for some plugins and updates the Root Server Scaling Measurement (RSSM)
plugin w.r.t. the upcoming version 5 of RSSAC002 specifications.
The RSSM plugin can now optionally generate `label-count` metric. This
is enabled with `-L` and is tagged as `rssac002v5-draft` until v5 is
finalized.
The merge tool `dnscap-rssm-rssac002` has also been updated because of
this, there is now `--skip-unsupported` to skip all unsupported
RSSAC002 version metrics instead of `die()`'ing.
ca7707d RSSAC002v5 label-count metric
3ebee80 Made label count metric optional
41b029a Adding support for label acount metric
799c3fe Missing includes
7089f12 PID file
2022-06-13 Jerry Lundström
Release 2.0.3
Thanks to a patch from Duane Wessels (@wessels) this release fixes
an issue with filtering where DNS messages without a question section
would bypass it.
ba2112c Fix COPR
0e019ab Filtering
c7e1c8f Refactor and fix qtype and qname matching/filtering.
2022-03-08 Jerry Lundström
Release 2.0.2
Thanks to a patch from Duane Wessels (@wessels) this release fixes
memory leaks when using `-x`/`-X` regexp filtering due to incorrect
usage of LDNS library.
Other minor changes:
- Clarify what happens if you don't specify `-i` and add information about `any` and `all`
- Update debhelper compatibility level to 10
a8925a7 ldns_pkt_all() clones RRs which need to be freed with ldns_rr_list_deep_free()
5104814 Doc
30c36aa debhelper
4ae4356 Bye Travis
2021-03-11 Jerry Lundström
Release 2.0.1
Fixed incorrect line break in eventlog's (plugin) output.
5df363c remove trailing newline
2021-02-12 Jerry Lundström
Release 2.0.0
This major release contains three backward incompatible changes, two
new command line options and a completely restructured man-page(!),
please read the change notes carefully before upgrading!
The first backward incompatible change has to do with the removal of
libbind dependency. This library was causing segfaults on OpenBSD due to
shared (and overwritten) symbols with OpenBSD's libc.
It was replaced with LDNS and LDNS renders domain names as Fully
Qualified Domain Names (FQDN, the trailing dot!) so every output of a
domain name has been changed to a FQDN.
This also changes `-X`/`-x`, which will now match against FQDNs.
The second backward incompatible change is that `-6` has been removed.
This was used to alter the BPF in order to "fix" it, dnscap adds
specific filters to IP and UDP headers which does not work for IPv6
traffic.
The generated BPF has been changed to allow IPv6 to always pass, making
the option obsolete. IPv6 filtering is then done in dnscap.
The last backward incompatible change has to do with the output format
of `-g` related to EDNS0 and is now more consistent with the rest of
the parsable output:
- No more spaces in the output
- Fix incorrect `\` and extra empty new-line
- All EDNS0 options are added after `edns0[...]` using comma separation, example: `edns0[],edns0opt[],...`
- Client Subnet format: `edns0opt[ECS,family=nn,source=nn,scope=nn,addr=...]`
- Unknown/unsupported code: `edns0opt[code=nn,codelen=nn]`
- Parsing error messages have changed, they came from libbind, now comes from LDNS
New options:
- Add `-q` and `-Q` to filter on matched/not matched QTYPE
Bugfixes:
- Fix memory leak in EDNS0 ECS address parsing
- `network`: Fix sonarcloud issues, potential `memcpy()` of null pointer
Other changes:
- Fix CBOR output inclusion, LDNS is always available now
- Add macros for Apple and Windows endian functions
- Restructure and correct the man-page
557e5f5 man-page
025529f v6bug, interval
37b79e9 FQDN
ebcf434 QTYPE match, args, tests
0cb5562 v6bug
75f6115 Endian
aaeb213 Sonarcloud
8685946 CBOR output
3e26802 Sonarcloud
30aa366 libbind
3f94d0b Mattermost
2020-10-22 Jerry Lundström
Release 1.12.0
This release fixes the handling of `-?` option for dnscap and all plugins,
previously the handling varied between places and depending on `getopt()`
implementation an invalid option could return the wrong exit code.
Other changes:
- Fix typo in configure help text
- `plugins/anonmask`: Fix typo in help text
- `plugins/rzkeychange`:
- Add `-D`, dry run mode, for testing
- Fix handling of `-a` and error on too many
KNOWN ISSUES:
On OpenBSD the system library libc exports the same symbols as libbind
does and this causes runtime warnings. Until now this has not caused any
known problems but is now also causing segfaults if the packet filter used
(BPF) includes IPv6 addresses.
On all other platforms OARC supports, these symbols are macros and in so
should not cause any problem.
ee478c0 Known issues
2f9d957 Tests
3c663a2 Tests
c88efc5 rzkeychange test
f062f33 Tests
2020-08-20 Jerry Lundström
Release 1.11.1
This release fixes a lot of issues found by code analysis, adds a
explicit memory zeroing function to remove account information (read
when dropping privileges) and adds code coverage reporting.
The `dnscap_memzero()` will use `explicit_bzero()` on FreeBSD and
OpenBSD, or `memset_s()` (if supported), otherwise it will manually
set the memory to zero. This will hopefully ensure that the memory
is zeroed as compilers can optimize out `memset()`'s that is just
before `free()`.
The plugins exit code for the help option `-?` has been changed to 0
to have the same as `dnscap -?`.
d9747ee memzero
1cf17c6 Coverage
19c7120 Coverage
7435676 Sonarcloud
928e181 Sonarcloud
ca4afd0 Sonarcloud
028f5e0 Badges
db0d6a1 LGTM
2020-06-01 Jerry Lundström
Release 1.11.0
This release includes a new plugin called `eventlog`, contributed
by Byron Darrah (@ByronDarrah), output DNS activity as log events,
including answers to A and AAAA queries.
Other changes includes compile warning and code analysis fixes.
382eac4 COPR
4c03650 Compile warn
21d6a67 Slight change -- wording now matches usage() output.
dd19b0b Added the eventlog.so plugin...
1ebf504 Added new dnscap plugin: evenlog.so...
f3f9aaa Compile warnings
2020-03-02 Jerry Lundström
Release 1.10.4
Fixed a bug that would not drop privileges when not specifying any
interface (which is equal to capturing on all interfaces).
Added functionality to set the supplemental groups when dropping
privileges and changing user, or clear them if that is not supported.
Other changes includes corrected man-page about '-w' and update to
documentation.
a0285e4 drop privileges errors, initgroups/setgroups
96336f3 daemon: Attempt to drop supplemental groups
467a9a7 Drop privileges
de940a8 man-page -w
187ec43 README
2019-10-02 Jerry Lundström
Release 1.10.3
Fixed plugins inclusion in deb packages for Debian and Ubuntu.
017ebb2 Deb packages
cf59143 COPR, spec
2019-08-05 Jerry Lundström
Release 1.10.2
Fixed bug in the handling of defragmentation configuration which lead
to the use of a local scope variable later on and caused unexpected
behavior.
91692b8 Frag conf
6a74376 Package
d0d1a6d Package
2019-07-08 Jerry Lundström
Release 1.10.1
Fix various issues found by code analysis tools, a few compiler warnings
removed, undefined bit shift behavior fixed, parameter memory leaks
plugged and documentation updates.
Fixes:
- `dump_dns`: Remove usage of `strcpy()` and use `snprintf()` instead
of `sprintf()`
- `bpft`:
- Use `text_ptr->len` to store length of generated text
- Use `memcpy()` instead of `strcat()`
- Remove unneeded `realloc()` and `strcpy()`
- `plugins/cryptopan`: Fix strict-aliasing warnings
- `network`: Rework part of `dl_pkt()` to remove usage of `strcpy()`
and use `snprintf()` instead of `sprintf()`
- `plugins/anonaes128`: Use `a6` as dest when copying v4 addresses for
readability and code analysis
- `plugins/cryptopan`: Run first pass separate to eliminate a 32bit
shift by 32 (undefined behavior)
- `plugins/cryptopant`: Fix memory leak of `keyfile` if `-k` is
specified more then once
Documentation:
- Update `README.md` with correction to building from git and note
about PCAP on OpenBSD
- Fix #190: Update link to `libbind` source
074923c Funding
5d2e84c libbind
8ee9f2a Travis-CI
6babd09 Fixes
bb2d1c7 README, compile warnings
0d9cd9c LGTM, Travis-CI
2018-12-03 Jerry Lundström
Release 1.10.0
This release adds a new plugin type "filter" and 5 new plugins that can
do anonymization, deanonymization and masking of the IP addresses.
New features:
- Check plugins for `pluginname_type()` which returns `enum plugin_type`,
if missing the plugin is counted as an "output" plugin
- New plugin type "filter" which calls `pluginname_filter()` prior of
outputting any data or calling of "output" plugins, if the new function
returns non-zero then the packet is filtered out (dropped)
- New extension `DNSCAP_EXT_SET_IADDR` that gives access to a function
for setting the from and to IP addresses both in the extracted data
and the wire
New plugins:
- `anonaes128`: Anonymize IP addresses using AES128
- `anonmask`: Pseudo-anonymize IP addresses by masking them
- `cryptopan`: Anonymize IP addresses using an extension to Crypto-PAn
(College of Computing, Georgia Tech) made by David Stott (Lucent)
- `cryptopant`: Anonymize IP addresses using cryptopANT, a different
implementation of Crypto-PAn made by the ANT project at USC/ISI
- `ipcrypt`: Anonymize IP addresses using ipcrypt create by
Jean-Philippe Aumasson
Bugfixes:
- Fix changing `royparse` and `txtout` with other plugins (thanks to
Duane Wessels and Paul Hoffman)
- Free pointers to allocated strings in `text_free()` (thanks to Michał
Kępień)
- Fix IP checksum calculation
Other changes:
- `-B` and `-E` can be used without `-w` (thanks to Duane Wessels)
- Use `pcap_findalldevs()` instead of `pcap_lookupdev()` (thanks to
Michał Kępień)
- Document and add `-?` option to all plugins
- Fix clang `scan-build` bugs and LGTM alerts
- Use `gmtime_r()` instead of `gmtime()`
- Update `pcap-thread` to v4.0.0
67d8e2c Fix
fb0ed02 Plugin documentation
a2c9a6c cryptopant
39db1ca Deanonymize, IPv6 test
afc7107 Crypto-PAn, cryptopANT
f1912cc OpenSSL, anonaes128
f2bab62 ipcrypt, anonmask
158b1e7 anonmask help
60ece58 anonmask
8f1b138 Plugin types, filter plugin, set iaddr extension, anonymization
by masking
b7d7991 IP checksum
641a23a Free pointers to allocated strings in text_free()
4d313bf pcap_findalldevs()
091e0ca Use pcap_findalldevs() instead of pcap_lookupdev()
6a7b25e Clean up use of feature test macros on Linux
cbba14c Configure, uninitialized
f228c9c Code formatting
3fd738c man-page
770168a Test
714e4f5 Fix -B <begin> so that it works when reading offline pcap files.
8675bea Test
911fec9 Implementing test9 as a test of -B and -E command line args.
a7cc72d -B <begin> and -E <end> can work fine without -w <base>.
04c4928 Made the same changes to txtout as were in 165a786
165a786 Workaround for stdio mystery causing duplicate royparse output.
2018-02-28 Jerry Lundström
Release 1.9.0
This release adds a new option to change how the Berkeley Packet Filter
is generated to include the host restrictions for all selections,
previously this restriction would only apply to specific parts.
Additional tweaks to the RSSM plugin has been made to conform to the
RSSAC002v3 specification. One noticeable change is that the plugin now
requires the DNS to be parsed before counted, any error in the parsing
will result in the message being left out of the statistics.
Changes:
- Fix spacing in BPF filter to look better
- Fix #146: Add `bpf_hosts_apply_all`, apply any host restriction to all
- `plugin/rssm`:
- Remove quoting of `start-period` and correctly handle empty hashes
- Issue #152, Issue #91: Parse DNS before processing RSSM counters
- `plugin/rssm/dnscap-rssm-rssac002`: Use `YAML::Dump()` for output
47d892b Issue #152: RSSM YAML output
d4f1466 Issue #152, Issue #91: Parse DNS before processing RSSM counters
68fc1ff BPF, `bpf_hosts_apply_all`
2018-02-07 Jerry Lundström
Release 1.8.0
This release updates the TCP stream code in order to be able to look
at more then just the first query, for handling already ongoing TCP
connections without having seen SYN/ACK and for reassembly of the TCP
stream prior of parsing it for DNS with an additional layer of parsing
(see `reassemble_tcp_bfbparsedns`).
Updates to the Root Server Scaling Measurement (RSSM) plugin have also
been made to bring it up to date with RSSAC002v3 specification, be
able to output the YAML format described and an additional script to
merge YAML files if the interval is less then the RSSAC002v3 24 hour
period. See "Updates to the RSSM plugin" below and
`plugins/rssm/README.md`.
New extended options:
- `parse_ongoing_tcp`: Start tracking TCP connections even if SYN/ACK
has not been seen
- `allow_reset_tcpstate`: Allow external reset of TCP state
- `reassemble_tcp`: Use to enable TCP stream reassembly
- `reassemble_tcp_faultreset`: Number of faults before reseting TCP
state when reassembly is enabled
- `reassemble_tcp_bfbparsedns`: Enable an experimental additional layer
of reassemble that uses `libbind` to parse the payload before accepting
it. If the DNS is invalid it will move 2 bytes within the payload and
treat it as a new payload, taking the DNS length again and restart
the process. Requires `libbind` and `reassemble_tcp`.
New extension functions for plugins:
- `DNSCAP_EXT_TCPSTATE_GETCURR`: Function to get a pointer for the
current TCP state
- `DNSCAP_EXT_TCPSTATE_RESET`: Function to reset a TCP state
New features:
- Parse additional DNS queries in TCP connections
- `-g` and the `txtout` plugin will reset TCP state (if allowed) on
failure to parse DNS
Bugfixes:
- Fix `-g` output, separate error message with a space
- Fix TCP packets wrongfully flagged as DNS when using layers.
- Fix TCP debug output when using layers, `ia_str()` is not safe to call
twice in the same `printf` because of local buffer.
- Fix exported extension functions, need to be file local
New tests for:
- Multiple DNS queries in one TCP connection
- Query over TCP without SYN
- Queries over TCP with first query missing length
- Queries over TCP with middle payloads missing
- Add test with TCP stream that missing multiple packets in the middle
Updates to the RSSM plugin (`plugins/rssm`):
- Add info about saving counts and sources
- Fix memory leak on `fopen()` errors
- Update to RSSAC002v3 specification
- New options:
- `-D` to disable forking on close
- `-Y`: Use RSSAC002v3 YAML format when writing counters, the file
will contain multiple YAML documents, one for each RSSAC002v3 metric
Used with; -S adds custom metric `dnscap-rssm-sources` and -A adds
`dnscap-rssm-aggregated-sources`
- `-n`: Set the service name to use in RSSAC002v3 YAML
- `-S`: Write source IPs into counters file with the prefix `source`
- `-A`: Write aggregated IPv6(/64) sources into counters file with
the prefix `aggregated-source`
- `-a`: Write aggregated IPv6(/64) sources to
`<name>.<timesec>.<timeusec>`
- Add `dnscap-rssm-rssac002` Perl script for merging RSSAC002v3 YAML files
- Add README.md for the plugin man-page for `dnscap-rssm-rssac002`
- Add test for YAML output and merging of YAML files
c7058c8 Use file local functions for all extensions
66b352d RSSM RSSAC002v3 YAML Tool
b09efc2 `plugins/rssm` RSSAC002v3
709aba6 Fix #89: Add additional reassembly layers that parses the
payload byte for byte for valid DNS
04fa013 Fix CID 1463944 (again)
b1cf623 RSSM saving data and forking
fb23305 Fix CID 1463944
0fca1a8 Issue #89: TCP stream reassemble
bb6428c CID 1463814: Check `ns_initparse()` for errors
a57066f Fix #88: TCP handling
2017-12-27 Jerry Lundström
Release 1.7.1
The library used for parsing DNS (libbind) is unable to parse DNS
messages when there is padding at the end (the UDP/TCP payload is larger
then the DNS message). This has been fixed by trying to find the actual
DNS message size, walking all labels and RR data, and then retry parsing.
Other changes and bug-fixes:
- Fix size when there is a VLAN to match output of `use_layers` yes/no
- Add test of VLAN matching
- Fix `hashtbl.c` building in `rssm`
- Add test with padded DNS message
49e5400 Fix #127: If `ns_initparse()` returns `EMSGSIZE`, try and get
actual size and reparse
99bda0b Fix #98: VLAN
2017-12-19 Jerry Lundström
Release 1.7.0
This release adds IP fragmentation handling by using layers in pcap-thread
which also adds a new flag to output and modules. `DNSCAP_OUTPUT_ISLAYER`
indicates that `pkt_copy` is equal to `payload` since the layers of the
traffic have already been parsed. IP fragments are reassembled with the
`pcap_thread_ext_frag` extension that is included in pcap-thread.
New extended (`-o`) options:
- `use_layers`: Use pcap-thread layers to handle the traffic
- `defrag_ipv4`: Enabled IPv4 de-fragmentation
- `defrag_ipv6`: Enabled IPv6 de-fragmentation
- `max_ipv4_fragments`: Set maximum fragmented IPv4 packets to track
- `max_ipv4_fragments_per_packet`: Set the maximum IPv4 fragments per
tracked packet
- `max_ipv6_fragments`: Set maximum fragmented IPv6 packets to track
- `max_ipv6_fragments_per_packet`: Set the maximum IPv6 fragments per
tracked packet
Currently `-w` does not work with `use_layers` and the plugins `pcapdump`
and `royparse` will discard output with the flag `DNSCAP_OUTPUT_ISLAYER`
because they need access to the original packet.
The `rzkeychange` plugin now encodes certain flag bits in the data that
it reports for RFC8145 key tag signaling. The flags of interest are:
`DO`, `CD`, and `RD`. These are encoded in an bit-mask as a hexadecimal
value before the `_ta` component of the query name.
Other changes and bug-fixes:
- Fix #115: document `-g` output, see `OUTPUT FORMATS` `diagnostic` in
`dnscap(1)` man-page
- Add test to match output from non-layers runs with those using layers
- Add test with fragmented DNS queries
- Fix #120: CBOR/CDS compiles again, update tinycbor to v0.4.2
- Fix `ip->ip_len` byte order
- Fix parsing of IP packets with padding or missing parts of payload
0347f74 Add AUTHORS section in man-page
ef1b68c Fix CID 1463073
8a79f89 Layers
a404d08 Update pcap-thread to v3.1.0, add test for padding fixes
08402f1 Fix byte order bug. ip->ip_len must be evaluated with ntohs().
d6d2340 CBOR/CDS and formatting
85ec2d8 Fix #87: IP fragmentation reassembly
22bfd4a Documentation
c35f19f Adding flag bits to rzkeychange RFC8145 key tag signaling data.
This may be useful to find "false" key tag signals from sources
that don't actually perform DNSSEC validation.
2017-12-01 Jerry Lundström
Release 1.6.0
New additions to the plugins:
- `rzkeychange` can now collect RFC8145 key tag signaling. Signals are
saved during the collection interval, and then sent to the specified
`-k <zone>`, one at a time, at the end of the interval. Only root zone
signals are collected. Added by Duane Wessels (@wessels).
- `royparse` is a new plugin to splits a PCAP into two streams, queries
in PCAP format and responses in ASCII format. Created by Roy Arends
(@RoyArends).
- `txtout` new option `-s` for short output, only print QTYPE and QNAME
for IN records. Added by Paul Hoffman (@paulehoffman)
- The extension interface has been extended with `DNSCAP_EXT_IA_STR` to
export the `ia_str()` function.
Bugfixes and other changes:
- Remove duplicated hashtbl code
- `rssm`: fix bug where count in table was taken out as `uint16_t` but
was a `uint64_t`
- Handle return values from hashtbl functions
- `txtout`: removed unused `-f` options
- Change `ia_str()` to use buffers with correct sizes, thanks to
@RoyArends for spotting this!
Commits:
3f78a31 Add copy/author text
1bd914d Fix CID 1462343, 1462344, 1462345
f9bb955 Fix `fprintf()` format for message size
abedf84 Fix #105: `inet_ntop` buffers
bfdcd0d Addresses the suggestions from Jerry.
dda0996 royparse :)
4f6520a royparse plugin finished
f1aa4f2 Fix #103: Remove `opt_f`
32355b7 Rearrange code to keep the change smaller and fix indentation
d6612c1 Added -s to txtout for short output
9d8d1ef Check return of `snprintf()`
55f5aba Format code
9f19ec3 Fixed memory leak in rzkeychange_keytagsignal()
58b8784 Fix memory leaks and better return value checks in
rzkeychange_submit_counts()
b06659f Add server and node to keytag signal query name
705a866 Always free response packets in rzkeychange plugin.
e802843 Implement RFC8145 key tag signal collection in rzkeychange plugin
5fbf6d0 Added extension for ia_str() so it can be used by rzkeychange
plugin.
3be8b8f Split `dnscap.c` into more files
e431d14 Fix #92: hashtbl
2017-08-21 Jerry Lundström
Release 1.5.1
Compatibility fixes for FreeBSD 11.1+ which is now packing `struct ip`
and for OpenBSD.
Commits:
17e3c92 FreeBSD is packing `struct ip`, need to `memcpy()`
f8add66 Code formatting
38cd585 Add documentation about libbind
d1dd55b Fix #82: Update dependencies for OpenBSD
2017-06-06 Jerry Lundström
Release 1.5.0
Added support for writing gzipped PCAP if the `-W` suffix ends with
`.gz` and made `-X` work without `-x`. New inteface for plugins to
tell them what extensions are available and a new plugin `rzkeychange`.
Plugin extensions:
- Call `plugin_extension(ext, arg)` to tell plugin what extensions exists
- Add extension for checking responder (`is_responder()`)
The rzkeychange plugin was developed by Duane Wessels 2016 in support
of the root zone ZSK size increase. It is also being used in support of
the 2017 root KSK rollover and collects the following measurements:
- total number of responses sent
- number of responses with TC bit set
- number of responses over TCP
- number of DNSKEY responses
- number of ICMP_UNREACH_NEEDFRAG messages received
- number of ICMP_TIMXCEED_INTRANS messages received
- number of ICMP_TIMXCEED_REASS messages received
Other fixes (author Duane Wessels):
- 232cbd0: Correct comment description for meaning of IPPROTO_AH
- 181eaa4: Add #include <sys/time.h> for struct timeval on NetBSD
Commits:
1d894e2 Make -x and -X work correctly together and update man-page
34bc54c Make the -X option work without requiring a -x option.
f43222e Fix CID 1440488, 1440489, 1440490
aa54395 Update pcap-thread to v2.1.3
81174ce Prepare SPEC for OSB/COPR
21d7468 New plugin rzkeychange and plugin extensions
38491a3 Config header is generated by autotools
419a8ab Small tweaks and fixes for gzip support
1967abc updated for earlier BSD versions
f135c90 added auto gzip if the -W suffix ends with .gz
Commits during development of rzkeychange (author Duane Wessels):
- 620828d: Add rzkeychange -z option to specify resolver IP addresses
- 1f77987: Add -p and -t options to rzkeychange plugin to configure an
alternate port and TCP. Useful for ssh tunnels.
- 2a571f1: Split ICMP time exceeded counter into two counters for time
exceeded due to TTL and another due to fragmentation
- e4ee2d3: The rzkeychange data collection plugin uses
`DNSCAP_EXT_IS_RESPONDER` extension to know if an IP address is a
"responder" or not, because when dnscap is instructed to collect ICMP
with -I, it processes all ICMP packets, not just those limited to
responders (or initiators).
- cee16b8: Add ICMP Time Exceeded to counters
- ad8a227: Counting source IPs has performance impacts. #ifdef'd out for
now add ICMP "frag needed" counts
- c25e72b: Implemented DNS queries with ldns. First there will be some
test queries to ensure the zone is reachable and configured to receive
data. Then a query naming the fields, followed by the periodic queries
delivering counts.
- fd23be7: Make report zone, server, node command line argumements mandatory
- 137789b: Adding rzkeychange plugin files
2017-03-29 Jerry Lundström
Release 1.4.1
Fixed an issue that when compiled with libpcap that had a specific
feature enabled it would result in a runtime error which could not be
worked around.
Also fixed various compatibility issues and updated dependency
documentation for CentOS.
Commits:
785d4c4 Fix compiler warnings
2d4df8d Fix #65: Update pcap-thread to v2.1.2
26d3fbc Fix #64: Add missing dependency
55e6741 Update pcap-thread to v2.1.1, fix issue with libpcap timestamp
type
c6fdb7a Fix typo and remove unused variables
2017-02-27 Jerry Lundström
Release 1.4.0
Until it can be confirmed that the threaded code works as well as the
non-threaded code it has been made optional and requires a configuration
option to enable it during compilation.
New extended option:
- `-o pcap_buffer_size=<bytes>` can be used to increase the capture
buffer within pcap-thread/libpcap, this can help mitigate dropped
packets by the kernel during breaks (like when closing dump file).
Commits:
1c6fbb2 Update copyright year
63ef665 Suppress OpenBSD warnings about symbols
2c99946 pcap-thread v2.0.0, disable threads, errors handling
4cade97 Fix #56: Update pcap-thread to v1.2.2 and add test
2016-12-23 Jerry Lundström
Release 1.3.0
Rare lockup has been fixed that could happen if a signal was received
in the wrong thread at the wrong time due to `pcap_thread_stop()`
canceling and waiting on threads to join again. The handling of signals
have been improved for threaded and non-threaded operations.
New features:
- Experimental CBOR DNS Stream format output, see `CBOR_DNS_STREAM.md`
- Extended options to specify user and group to use when dropping
privileges, see EXTENDED OPTIONS in man-page
Commits:
a5fa14e Signal and threads
3868104 Use old style C comments
7946be5 Clarify building
d5463b4 RPM spec and various automake fixes
df206bf Resource data indexing and documentation
0e2d0fe Fix #22, fix #43: Update README
5921d73 Add stream option RLABELS and RLABEL_MIN_SIZE
6dd6ec1 Implement experimental CBOR DNS Stream Format
4baf695 Fix #37: Extended options to specifty user/group to use when
dropping privileges
61d830a Fix #35: Use `AC_HEADER_TIME` and fix warning
2016-10-27 Jerry Lundström
Release 1.2.0
Update `pcap-thread` to v1.2.0 to get the new callback queue mode which
puts that mode into using pthread conditions if all pcaps are offline and
keeps us from losing packets.
Use `pcap_thread_dropback()` callback to get the notification when a
packet was dropped because the queue was full, indicating that we can't
process all the packets. Added this stats to the `-S` output as total
and per interface as `ptdrop`. Changed the output for each interface
to not cut of information, for example interface name was cut to
4 characters.
Other changes:
- Add extended options `-o <option>=<value>` because we are running out
of short options.
- Better handling of library checks and automake rules
- New option `-F <format>` to specify the format of the output in `-w`
- Add experimental CBOR output support
- LDNS is used to parse the packets
- Tinycbor is used to construct the CBOR output
- DNS-in-JSON draft [1] for representing the objects
- Check CBOR topic in README.md for more information
- When only reading offline pcap files it will not attempt to drop
privileges and add new option `-N` to explicitly not drop privileges.
Commits:
f42e23f Extended options and CBOR output format
a28f498 Fix #24: Handle packet drops
2308eaa Fix #26: Unable to drop GID to nobody, exiting.
82d65f2 Update pcap-thread to v1.1.2
[1] https://datatracker.ietf.org/doc/draft-hoffman-dns-in-json/
2016-10-11 Jerry Lundström
Release 1.1.0
The ownership of DNSCAP was transferred from ISC to DNS-OARC in
the summer of 2016 and this is the first release since that.
This project now uses Semantic Versioning and these are the changes
since the `dnscap-20160205` release (which can also be found using
the tag `v0.0.0-20160205`).
Highlights:
- Restructure repository and use autotools
- Compiled and tested on Debian, Ubuntu, CentOS, FreeBSD and OpenBSD
using Jenkins and Travis-CI
- Source code static analysis using Coverity Scan
- Compatibility fixes for FreeBSD, OpenBSD and OS X
- ABI change to `output()`, previous `isfrag` is now a `flags` that
represents what the packet is through a bitmask
- Use helper library `pcap-thread` when capturing to solve missing
packets during very low traffic
New command line options:
- `-V`: Prints version and then exits
- `-M`: Enable monitor mode on interfaces
- `-D`: Enable immediate mode on interfaces
- `-W`: Allow to specify a suffix for the pcap dump file
- `-C`: Limit/rotate capture after a certain amount of bytes
Special thanks to:
- Duane Wessels
- Paul Vixie
- Klaus Darilion
Commits:
bc7eb22 Update license after ownership transfer from ISC to DNS-OARC,
update contributors, add build badges and removed SuperFastHash
since apparently it was not used.
778e457 Add `-V` for displaying version and the exiting
71c2d79 Fix #12: Sync man-page and help text
33576ef Swap option C and D, C for this makes more sense. Also ensure
that `capturedbytes` is zero on start.
0077aff Correct dump trace with new `flags`
f9cbba0 Do not use dump suffix unless it set
4dd81d6 Update the man page
7435c49 Change new option C to D because C was already taken
813dddb Fix -B and -E, these options are supported only once
76f19d1 fix usage of -W
519b64f Add -Y option to short usage instructions
348c738 Fix -C feature: capturedbytes was not increased
3db6f94 Improve logging
b567bef New option -C: limit/rotate capture after a certain amount
of bytes
341abdf Add -W feature: allow to specify a suffix for the pcap dump
file, e. g.: '.pcap'
097a3b4 Count every packet which is sent to output(), not only
the normal ones.
75e5968 Close PCAPs after dumper_close() to have statistics still
available during dumper_close(). Otherwise we get a segfault
on shutdown.
c09d61a Add debian/ubuntu package files.
020f2aa Forgot about the compiler warnings and fix the last
Coverity Scan issue
00c834d More Coverity Scan fixes
ad2f230 Fix various Coverity Scan issues
606f0cd Update pcap thread to version 1.1.1
f065cd7 Fix #14: Add options `-M` and `-C` for monitor and
immediate mode, update help and man-page.
b872035 Update to pcap-thread version 1.1.0
1f30637 Update pcap_thread to v1.0.1, add travis check that dnscap
can run
b19efaa Building from Git repository instructions
b5460df Use `calloc()` instead of `malloc()` to be sure the memory
is zeroed
ae6a04d Use pcap_thread v1.0.0
9426a2d Update pcap_thread and add pcap stats
820b2f2 Update pcap_thread and support offline pcaps
a47dd67 Update pcap_thread
237a7a7 CentOS autoreconf complained
7b5568c Use pcap_thread
11d0388 Revert the changes on all lines that had NULL, 0 before.
7d6a7e4 Passing IPv6 fragment payloads may not currently be safe.
Needs more work. For now pass pkt=NULL to be safe for plugins.
ea8f9a4 Make the family of output() functions future proof with a flags
bitmask. Rather than separate 'isfrag' and 'isdns' flags,
they are now set as bitmasks in a single 'flags' value passed
to output() f
472a172 A change to the interface of the family of output() functions.
95a6e62 timeval.* are not unsigned
d3f32de Fix #1: Use NS_*SZ
e555871 Fix compiler warnings
3ed8f29 Fix #1
864cbd7 Can you change #ifdef __APPLE__ to check for the
arpa/nameser_compat.h header and include it if it exists?
796e8ea plugin/rssm needs to include arpa/nameser_compat.h for OS X
so that the HEADER struct is declared.
daf4bd3 In plugin/txtout silence compiler warnings about int vs short
e5bc24b plugin/pcapdump needs to include arpa/nameser_compat.h for OS X
so that the HEADER struct is declared.
0061b57 Work around configure problem detecting libresolv on Mac OS X
Without some #include files, the configure test won't find
the symbol res_mkquery() in libresolv on OS X. It is called
res_9_mkquery()
5309655 Mac OS X doesn't have setresuid() and setresgid().
This patch adds configure checks for setreuid() and setregid()
and will use those instead if the other versions are
not available.
d257a1c Fix compilation on FreeBSD and OpenBSD
07b2a75 Restructure repository and move to Automake.

891
Makefile.in Normal file
View file

@ -0,0 +1,891 @@
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = \
$(top_srcdir)/src/pcap-thread/m4/ax_pcap_thread.m4 \
$(top_srcdir)/src/pcap-thread/m4/ax_pthread.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_cflags_warn_all.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
$(am__configure_deps) $(dist_doc_DATA) $(am__DIST_COMMON)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(docdir)"
DATA = $(dist_doc_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
cscope distdir distdir-am dist dist-all distcheck
am__extra_recursive_targets = gcov-recursive
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in README.md ar-lib compile \
config.guess config.sub install-sh ltmain.sh missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
if test -d "$(distdir)"; then \
find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -rf "$(distdir)" \
|| { sleep 5 && rm -rf "$(distdir)"; }; \
else :; fi
am__post_remove_distdir = $(am__remove_distdir)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
DIST_TARGETS = dist-gzip
# Exists only to be overridden by the user if desired.
AM_DISTCHECK_DVI_TARGET = dvi
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILECMD = @FILECMD@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
RANLIB = @RANLIB@
SECCOMPFLAGS = @SECCOMPFLAGS@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
ax_pthread_config = @ax_pthread_config@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libcrypto_CFLAGS = @libcrypto_CFLAGS@
libcrypto_LIBS = @libcrypto_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
libldns_CFLAGS = @libldns_CFLAGS@
libldns_LIBS = @libldns_LIBS@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
ACLOCAL_AMFLAGS = -I m4 -I src/pcap-thread/m4
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in \
$(srcdir)/src/config.h.in~ \
$(srcdir)/configure
SUBDIRS = src plugins
dist_doc_DATA = README.md LICENSE CONTRIBUTORS
EXTRA_DIST = isc m4 .clang-format fmt.sh
all: all-recursive
.SUFFIXES:
am--refresh: Makefile
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
$(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
$(am__cd) $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool config.lt
install-dist_docDATA: $(dist_doc_DATA)
@$(NORMAL_INSTALL)
@list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \
done
uninstall-dist_docDATA:
@$(NORMAL_UNINSTALL)
@list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir)
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
gcov-local:
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscope: cscope.files
test ! -s cscope.files \
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
clean-cscope:
-rm -f cscope.files
cscope.files: clean-cscope cscopelist
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
$(am__remove_distdir)
test -d "$(distdir)" || mkdir "$(distdir)"
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
-test -n "$(am__skip_mode_fix)" \
|| find "$(distdir)" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
$(am__post_remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
$(am__post_remove_distdir)
dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__post_remove_distdir)
dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
dist-zstd: distdir
tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir)
dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
$(am__post_remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__post_remove_distdir)
dist dist-all:
$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
$(am__post_remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
*.tar.xz*) \
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
*.tar.zst*) \
zstd -dc $(distdir).tar.zst | $(am__untar) ;;\
esac
chmod -R a-w $(distdir)
chmod u+w $(distdir)
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build/sub \
&& ../../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=../.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) $(AM_DISTCHECK_DVI_TARGET) \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
&& cd "$$am__cwd" \
|| exit 1
$(am__post_remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@test -n '$(distuninstallcheck_dir)' || { \
echo 'ERROR: trying to run $@ with an empty' \
'$$(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
$(am__cd) '$(distuninstallcheck_dir)' || { \
echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile $(DATA)
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(docdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-recursive
dvi-am:
gcov: gcov-recursive
gcov-am: gcov-local
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am: install-dist_docDATA
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-recursive
install-html-am:
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-dist_docDATA
.MAKE: $(am__recursive_targets) install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--refresh check check-am clean clean-cscope clean-generic \
clean-libtool cscope cscopelist-am ctags ctags-am dist \
dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \
dist-xz dist-zip dist-zstd distcheck distclean \
distclean-generic distclean-libtool distclean-tags \
distcleancheck distdir distuninstallcheck dvi dvi-am gcov-am \
gcov-local html html-am info info-am install install-am \
install-data install-data-am install-dist_docDATA install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
ps ps-am tags tags-am uninstall uninstall-am \
uninstall-dist_docDATA
.PRECIOUS: Makefile
test: check
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

1581
aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load diff

271
ar-lib Executable file
View file

@ -0,0 +1,271 @@
#! /bin/sh
# Wrapper for Microsoft lib.exe
me=ar-lib
scriptversion=2019-07-04.01; # UTC
# Copyright (C) 2010-2021 Free Software Foundation, Inc.
# Written by Peter Rosin <peda@lysator.liu.se>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
# func_error message
func_error ()
{
echo "$me: $1" 1>&2
exit 1
}
file_conv=
# func_file_conv build_file
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN* | MSYS*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv in
mingw)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin | msys)
file=`cygpath -m "$file" || echo "$file"`
;;
wine)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_at_file at_file operation archive
# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
# for each of them.
# When interpreting the content of the @FILE, do NOT use func_file_conv,
# since the user would need to supply preconverted file names to
# binutils ar, at least for MinGW.
func_at_file ()
{
operation=$2
archive=$3
at_file_contents=`cat "$1"`
eval set x "$at_file_contents"
shift
for member
do
$AR -NOLOGO $operation:"$member" "$archive" || exit $?
done
}
case $1 in
'')
func_error "no command. Try '$0 --help' for more information."
;;
-h | --h*)
cat <<EOF
Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
Members may be specified in a file named with @FILE.
EOF
exit $?
;;
-v | --v*)
echo "$me, version $scriptversion"
exit $?
;;
esac
if test $# -lt 3; then
func_error "you must specify a program, an action and an archive"
fi
AR=$1
shift
while :
do
if test $# -lt 2; then
func_error "you must specify a program, an action and an archive"
fi
case $1 in
-lib | -LIB \
| -ltcg | -LTCG \
| -machine* | -MACHINE* \
| -subsystem* | -SUBSYSTEM* \
| -verbose | -VERBOSE \
| -wx* | -WX* )
AR="$AR $1"
shift
;;
*)
action=$1
shift
break
;;
esac
done
orig_archive=$1
shift
func_file_conv "$orig_archive"
archive=$file
# strip leading dash in $action
action=${action#-}
delete=
extract=
list=
quick=
replace=
index=
create=
while test -n "$action"
do
case $action in
d*) delete=yes ;;
x*) extract=yes ;;
t*) list=yes ;;
q*) quick=yes ;;
r*) replace=yes ;;
s*) index=yes ;;
S*) ;; # the index is always updated implicitly
c*) create=yes ;;
u*) ;; # TODO: don't ignore the update modifier
v*) ;; # TODO: don't ignore the verbose modifier
*)
func_error "unknown action specified"
;;
esac
action=${action#?}
done
case $delete$extract$list$quick$replace,$index in
yes,* | ,yes)
;;
yesyes*)
func_error "more than one action specified"
;;
*)
func_error "no action specified"
;;
esac
if test -n "$delete"; then
if test ! -f "$orig_archive"; then
func_error "archive not found"
fi
for member
do
case $1 in
@*)
func_at_file "${1#@}" -REMOVE "$archive"
;;
*)
func_file_conv "$1"
$AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
;;
esac
done
elif test -n "$extract"; then
if test ! -f "$orig_archive"; then
func_error "archive not found"
fi
if test $# -gt 0; then
for member
do
case $1 in
@*)
func_at_file "${1#@}" -EXTRACT "$archive"
;;
*)
func_file_conv "$1"
$AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
;;
esac
done
else
$AR -NOLOGO -LIST "$archive" | tr -d '\r' | sed -e 's/\\/\\\\/g' \
| while read member
do
$AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
done
fi
elif test -n "$quick$replace"; then
if test ! -f "$orig_archive"; then
if test -z "$create"; then
echo "$me: creating $orig_archive"
fi
orig_archive=
else
orig_archive=$archive
fi
for member
do
case $1 in
@*)
func_file_conv "${1#@}"
set x "$@" "@$file"
;;
*)
func_file_conv "$1"
set x "$@" "$file"
;;
esac
shift
shift
done
if test -n "$orig_archive"; then
$AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
else
$AR -NOLOGO -OUT:"$archive" "$@" || exit $?
fi
elif test -n "$list"; then
if test ! -f "$orig_archive"; then
func_error "archive not found"
fi
$AR -NOLOGO -LIST "$archive" || exit $?
fi

View file

@ -1,3 +0,0 @@
#!/bin/sh -e
autoreconf --force --install --no-recursive --include=m4 --include=src/pcap-thread/m4

348
compile Executable file
View file

@ -0,0 +1,348 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN* | MSYS*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/* | msys/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

1754
config.guess vendored Executable file

File diff suppressed because it is too large Load diff

1890
config.sub vendored Executable file

File diff suppressed because it is too large Load diff

17747
configure vendored Executable file

File diff suppressed because it is too large Load diff

View file

@ -33,7 +33,7 @@
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
AC_PREREQ(2.61) AC_PREREQ(2.61)
AC_INIT([dnscap], [2.3.1], [dnscap-users@dns-oarc.net], [dnscap], [https://github.com/DNS-OARC/dnscap/issues]) AC_INIT([dnscap], [2.3.0], [dnscap-users@dns-oarc.net], [dnscap], [https://github.com/DNS-OARC/dnscap/issues])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects]) AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AC_CONFIG_SRCDIR([src/dnscap.c]) AC_CONFIG_SRCDIR([src/dnscap.c])
AC_CONFIG_HEADER([src/config.h]) AC_CONFIG_HEADER([src/config.h])

View file

@ -1,699 +0,0 @@
#!/usr/bin/env python3
#
# Copyright (c) 2016-2025 OARC, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
import sys
import logging
import optparse
import struct
import socket
from cbor2 import CBORDecoder;
logging.basicConfig(format='%(levelname).5s: %(module)s:%(lineno)d: '
'%(message)s')
log = logging.getLogger(__name__)
class SimpleValue(object):
def __init__(self, value):
self.value = value
def get(self):
return self.value
def __repr__(self):
return "{}".format(self.value)
def decode_simple_value(self, fp, shareable_index=None):
return SimpleValue(struct.unpack('>B', fp.read(1))[0])
try:
from cbor2.types import CBORSimpleValue
except Exception:
CBORSimpleValue = SimpleValue
class LastValues(object):
def __init__(self):
self.reset()
def reset(self):
self.ts = None
self.src_addr4 = None
self.src_port4 = None
self.dest_addr4 = None
self.dest_port4 = None
self.src_addr6 = None
self.src_port6 = None
self.dest_addr6 = None
self.dest_port6 = None
self.rlabel = []
self.mlabel = []
self.rr_type = None
self.rr_class = None
self.rr_ttl = None
last = LastValues()
MAX_RLABELS = 255
MIN_RLABEL_SIZE = 3
def get_rlabel(idx):
rlabel_idx = -idx - 1
try:
label = last.rlabel.pop(rlabel_idx)
last.rlabel.insert(0, label)
return label
except:
raise Exception("rlabel index {} out of range".format(rlabel_idx))
def add_rlabel(label):
size = 0
if isinstance(label, list):
for l in label:
if isinstance(l, str):
size += len(l)
if size < MIN_RLABEL_SIZE:
return
last.rlabel.insert(0, label)
if len(last.rlabel) > MAX_RLABELS:
last.rlabel.pop()
def build_mlabel_label(label):
if isinstance(label, int) and label < 0:
label = get_rlabel(label)
else:
add_rlabel(label)
if isinstance(label, str):
last.mlabel.append(label)
elif isinstance(label, list):
if len(label) and isinstance(label[0], int):
last.mlabel.append(label)
return
label = list(label)
while len(label):
last.mlabel.append(list(label))
label.pop(0)
def build_mlabel(rrs):
for rr in rrs:
if len(rr) and isinstance(rr[0], bool):
continue
if len(rr):
build_mlabel_label(rr[0])
if len(rr) > 1 and isinstance(rr[len(rr)-1], list):
for l in rr[len(rr)-1]:
build_mlabel_label(l)
def parse_label(label, lvl):
if isinstance(label, int) and label < 0:
label = get_rlabel(label)
else:
add_rlabel(label)
if isinstance(label, bytes):
print((" " * lvl)+"label: {}".format(bytes))
elif isinstance(label, list):
if len(label) and isinstance(label[0], int) and label[0] < 0:
dn = list(get_rlabel(label[0]))
else:
dn = list(label)
print((" " * lvl)+"clabel: {}".format(dn))
dnstr = []
seen_mlabel = {}
while len(dn):
while isinstance(dn[0], int):
if dn[0] in seen_mlabel:
dn = [ "{ name compression loop }" ]
break
seen_mlabel[dn[0]] = 1
dn = list(last.mlabel[dn[0]])
dnstr.append(dn.pop(0))
print((" " * lvl)+"label: "+ " . ".join(dnstr))
else:
raise Exception("invalid label type {}".format(type(label)))
def parse_rrs(rrs, lvl):
for rr in rrs:
print((" " * lvl)+"rr:")
lvl+=2
if len(rr) and isinstance(rr[0], bool):
print((" " * lvl)+"incomplete/broken DNS RR, no support for these yet")
continue
parse_label(rr.pop(0), lvl)
bits = 0
if isinstance(rr[0], CBORSimpleValue):
bits = rr.pop(0).value
print((" " * lvl)+"type (0): "+("yes" if bits & 1 else "no"))
print((" " * lvl)+"class (1): "+("yes" if bits & 1<<1 else "no"))
print((" " * lvl)+"ttl (2): "+("yes" if bits & 1<<2 else "no"))
print((" " * lvl)+"rdlength(3): "+("yes" if bits & 1<<3 else "no"))
rr_type = None
rr_class = None
rr_ttl = None
rdlength = None
if not bits:
if len(rr) > 4:
bits = 0xff
elif len(rr) > 1:
raise Exception("invalid rr, expected none (0) or all (4) optional values but got {}".format(len(rr)-1))
if bits & 1:
if not isinstance(rr[0], int):
raise Exception("invalid rr.type, expected int but got: {}".format(type(rr[0])))
rr_type = rr.pop(0)
if bits & 1<<1:
if not isinstance(rr[0], int):
raise Exception("invalid rr.class, expected int but got: {}".format(type(rr[0])))
rr_class = rr.pop(0)
if bits & 1<<2:
if not isinstance(rr[0], int):
raise Exception("invalid rr.ttl, expected int but got: {}".format(type(rr[0])))
rr_ttl = rr.pop(0)
if bits & 1<<3:
if not isinstance(rr[0], int):
raise Exception("invalid rr.rdlength, expected int but got: {}".format(type(rr[0])))
rdlength = rr.pop(0)
if not rr_type:
rr_type = last.rr_type
if not rr_class:
rr_class = last.rr_class
if not rr_ttl:
rr_ttl = last.rr_ttl
print((" " * lvl)+"type: {}".format(rr_type))
print((" " * lvl)+"class: {}".format(rr_class))
print((" " * lvl)+"ttl: {}".format(rr_ttl))
if rdlength:
print((" " * lvl)+"rdlength: {}".format(rdlength))
if rr_type != 41:
last.rr_type = rr_type
last.rr_class = rr_class
last.rr_ttl = rr_ttl
if isinstance(rr[0], bytes):
print((" " * lvl)+"rdata: "+"".join("{:02x}".format(byte) for byte in rr.pop(0)))
elif isinstance(rr[0], list):
rdata = []
for i in rr.pop(0):
if isinstance(i, int) and i < 0:
i = get_rlabel(i)
elif not isinstance(i, bytes):
add_rlabel(i)
if isinstance(i, bytes):
rdata.append("".join("{:02x}".format(byte) for byte in i))
elif isinstance(i, list):
dn = list(i)
dnstr = []
seen_mlabel = {}
while len(dn):
while isinstance(dn[0], int):
if dn[0] in seen_mlabel:
dn = [ "{ name compression loop }" ]
break
seen_mlabel[dn[0]] = 1
dn = list(last.mlabel[dn[0]])
dnstr.append(dn.pop(0))
rdata.append("[ clabel: {} label: ".format(i) + " . ".join(dnstr) + " ]")
else:
raise Exception("invalid rr.rdata[], expected bytes|list but got: {}".format(type(i)))
print((" " * lvl)+"rdata: "+" ".join(rdata))
else:
raise Exception("invalid rr.rdata, expected bytes|list but got: {}".format(type(rr[0])))
lvl-=2
def parse_qrs(qrs, lvl):
for qr in qrs:
print((" " * lvl)+"qr:")
lvl+=2
parse_label(qr.pop(0), lvl)
rr_type = None
rr_class = None
if len(qr):
if not isinstance(qr[0], int):
raise Exception("invalid qr.type|class, expected int but got {}".format(type(qr[0])))
if qr[0] > -1:
rr_type = qr.pop(0)
if len(qr):
if not isinstance(qr[0], int):
raise Exception("invalid qr.class, expected int but got {}".format(type(qr[0])))
elif not qr[0] < 0:
raise Exception("invalid qr.class, expected negative int but got positive")
rr_class = -qr.pop(0) - 1
else:
rr_class = -qr.pop(0) - 1
if not rr_type:
rr_type = last.rr_type
if not rr_class:
rr_class = last.rr_class
print((" " * lvl)+"type: {}".format(rr_type))
print((" " * lvl)+"class: {}".format(rr_class))
if rr_type != 41:
last.rr_type = rr_type
last.rr_class = rr_class
lvl-=2
def parse_dns_message(dns, lvl):
print((" " * lvl)+"dns:")
lvl+=2
if isinstance(dns[0], bool):
print((" " * lvl)+"incomplete/broken DNS packet, no support for these yet")
return
print((" " * lvl)+"header:")
lvl+=2
id = dns.pop(0)
print((" " * lvl)+"id: {}".format(id))
raw = dns.pop(0)
print((" " * lvl)+"raw: 0x{:04x}".format(raw))
lvl+=2
print((" " * lvl)+" QR: "+("yes" if raw & 1<<15 else "no"))
print((" " * lvl)+"Opcode: {}".format(((raw >> 11) & 0xf)))
print((" " * lvl)+" AA: "+("yes" if raw & 1<<10 else "no"))
print((" " * lvl)+" TC: "+("yes" if raw & 1<<9 else "no"))
print((" " * lvl)+" RD: "+("yes" if raw & 1<<8 else "no"))
print((" " * lvl)+" RA: "+("yes" if raw & 1<<7 else "no"))
print((" " * lvl)+" Z: "+("yes" if raw & 1<<6 else "no"))
print((" " * lvl)+" AD: "+("yes" if raw & 1<<5 else "no"))
print((" " * lvl)+" CD: "+("yes" if raw & 1<<4 else "no"))
print((" " * lvl)+" RCODE: {}".format(raw & 0xf))
lvl-=2
bits = 0
if isinstance(dns[0], int) and dns[0] < 0:
bits = -dns.pop(0) - 1
print((" " * lvl)+"qdcount(0): "+("yes" if bits & 1 else "no"))
print((" " * lvl)+"ancount(1): "+("yes" if bits & 1<<1 else "no"))
print((" " * lvl)+"nscount(2): "+("yes" if bits & 1<<2 else "no"))
print((" " * lvl)+"arcount(3): "+("yes" if bits & 1<<3 else "no"))
if not bits:
if isinstance(dns[0], int):
bits = 0xff
if bits & 1:
if not isinstance(dns[0], int):
raise Exception("invalid dns.header.qdcount, expected int but got: {}".format(type(dns[0])))
print((" " * lvl)+"qdcount: {}".format(dns.pop(0)))
if bits & 1<<1:
if not isinstance(dns[0], int):
raise Exception("invalid dns.header.ancount, expected int but got: {}".format(type(dns[0])))
print((" " * lvl)+"ancount: {}".format(dns.pop(0)))
if bits & 1<<2:
if not isinstance(dns[0], int):
raise Exception("invalid dns.header.nscount, expected int but got: {}".format(type(dns[0])))
print((" " * lvl)+"nscount: {}".format(dns.pop(0)))
if bits & 1<<3:
if not isinstance(dns[0], int):
raise Exception("invalid dns.header.arcount, expected int but got: {}".format(type(dns[0])))
print((" " * lvl)+"arcount: {}".format(dns.pop(0)))
bits = 0
if isinstance(dns[0], CBORSimpleValue):
bits = dns.pop(0).value
print((" " * lvl)+"questions (0): "+("yes" if bits & 1 else "no"))
print((" " * lvl)+"answers (1): "+("yes" if bits & 1<<1 else "no"))
print((" " * lvl)+"authorities(2): "+("yes" if bits & 1<<2 else "no"))
print((" " * lvl)+"additionals(3): "+("yes" if bits & 1<<3 else "no"))
last.mlabel = []
rlabel = list(last.rlabel)
for n in range(4):
if len(dns) > n and isinstance(dns[n], list):
build_mlabel(dns[n])
last.rlabel = rlabel
if not bits:
if len(dns) > 3:
bits = 0xff
elif len(dns) > 0:
raise Exception("invalid dns.message rr's, expected none (0) or all (4) but got {}".format(len(dns)))
if bits & 1:
if not isinstance(dns[0], list):
raise Exception("invalid dns.message.questions, expected list but got: {}".format(type(dns[0])))
print((" " * lvl)+"questions:")
parse_qrs(dns.pop(0), lvl+2)
if bits & 1<<1:
if not isinstance(dns[0], list):
raise Exception("invalid dns.message.answers, expected list but got: {}".format(type(dns[0])))
print((" " * lvl)+"answers:")
parse_rrs(dns.pop(0), lvl+2)
if bits & 1<<2:
if not isinstance(dns[0], list):
raise Exception("invalid dns.message.authorities, expected list but got: {}".format(type(dns[0])))
print((" " * lvl)+"authorities:")
parse_rrs(dns.pop(0), lvl+2)
if bits & 1<<3:
if not isinstance(dns[0], list):
raise Exception("invalid dns.message.additionals, expected list but got: {}".format(type(dns[0])))
print((" " * lvl)+"additionals:")
parse_rrs(dns.pop(0), lvl+2)
if len(dns):
if isinstance(dns[0], bytes):
print((" " * lvl)+"malformed: "+"".join("{:02x}".format(byte) for byte in dns.pop(0)))
if len(dns):
raise Exception("invalid dns.message, garbage at end: {}".format(dns))
def parse_ip_header(ip_header, lvl):
print((" " * lvl)+"ip_header:")
lvl+=2
print((" " * lvl)+"bits:")
lvl+=2
bits = ip_header.pop(0)
reverse = False
if isinstance(bits, int):
if bits < 0:
print((" " * lvl)+"reverse: yes")
bits = -bits - 1
reverse = True
print((" " * lvl)+"family (0): "+("INET6" if bits & 1 else "INET"))
print((" " * lvl)+"have_src (1): "+("yes" if bits & 1<<1 else "no"))
print((" " * lvl)+"have_dest(2): "+("yes" if bits & 1<<2 else "no"))
print((" " * lvl)+"have_port(3): "+("yes" if bits & 1<<3 else "no"))
else:
raise Exception("invalid ip_header.bits, expected int but got: {}".format(type(bits)))
lvl-=2
src_addr = None
dest_addr = None
src_port = None
dest_port = None
if bits & 1<<1:
src_addr = ip_header.pop(0)
if not isinstance(src_addr, bytes):
raise Exception("invalid ip_header.src_addr, expected bytes but got: {}".format(type(src_addr)))
else:
if reverse:
src_addr = last.dest_addr6 if bits & 1 else last.dest_addr4
if not src_addr:
raise Exception("invalid ip_header.bits, expected to have last dest addr but don't")
else:
src_addr = last.src_addr6 if bits & 1 else last.src_addr4
if not src_addr:
raise Exception("invalid ip_header.bits, expected to have last src addr but don't")
if bits & 1<<2:
dest_addr = ip_header.pop(0)
if not isinstance(dest_addr, bytes):
raise Exception("invalid ip_header.dest_addr, expected bytes but got: {}".format(type(dest_addr)))
else:
if reverse:
dest_addr = last.src_addr6 if bits & 1 else last.src_addr4
if not dest_addr:
raise Exception("invalid ip_header.bits, expected to have last src addr but don't")
else:
dest_addr = last.dest_addr6 if bits & 1 else last.dest_addr4
if not dest_addr:
raise Exception("invalid ip_header.bits, expected to have last dest addr but don't")
if bits & 1<<3:
ports = ip_header.pop(0)
if not isinstance(ports, int):
raise Exception("invalid ip_header.src_dest_port, expected int but got: {}".format(type(ports)))
if ports > 0xffff:
src_port = ports & 0xffff
dest_port = ports >> 16
elif ports < 0:
if reverse:
src_port = last.dest_port6 if bits & 1 else last.dest_port4
if src_port is None:
raise Exception("invalid ip_header.bits, expected to have last dest port but don't")
else:
src_port = last.src_port6 if bits & 1 else last.src_port4
if src_port is None:
raise Exception("invalid ip_header.bits, expected to have last src port but don't")
dest_port = -ports - 1
else:
src_port = ports
if reverse:
dest_port = last.src_port6 if bits & 1 else last.src_port4
if dest_port is None:
raise Exception("invalid ip_header.bits, expected to have last src port but don't")
else:
dest_port = last.dest_port6 if bits & 1 else last.dest_port4
if dest_port is None:
raise Exception("invalid ip_header.bits, expected to have last dest port but don't")
else:
if reverse:
src_port = last.dest_port6 if bits & 1 else last.dest_port4
if src_port is None:
raise Exception("invalid ip_header.bits, expected to have last dest port but don't")
else:
src_port = last.src_port6 if bits & 1 else last.src_port4
if src_port is None:
raise Exception("invalid ip_header.bits, expected to have last src port but don't")
if reverse:
dest_port = last.src_port6 if bits & 1 else last.src_port4
if dest_port is None:
raise Exception("invalid ip_header.bits, expected to have last src port but don't")
else:
dest_port = last.dest_port6 if bits & 1 else last.dest_port4
if dest_port is None:
raise Exception("invalid ip_header.bits, expected to have last dest port but don't")
print((" " * lvl)+" src addr: " + socket.inet_ntop(socket.AF_INET6 if bits & 1 else socket.AF_INET, src_addr))
print((" " * lvl)+"dest addr: " + socket.inet_ntop(socket.AF_INET6 if bits & 1 else socket.AF_INET, dest_addr))
print((" " * lvl)+" src port: {}".format(src_port))
print((" " * lvl)+"dest port: {}".format(dest_port))
if bits & 1:
last.src_addr6 = src_addr
last.dest_addr6 = dest_addr
last.src_port6 = src_port
last.dest_port6 = dest_port
else:
last.src_addr4 = src_addr
last.dest_addr4 = dest_addr
last.src_port4 = src_port
last.dest_port4 = dest_port
def parse_message_bits(bits, lvl):
print((" " * lvl)+"message_bits:")
lvl+=2
dns = "no"
if isinstance(bits, int):
if bits & 1:
dns = "yes"
print((" " * lvl)+"dns (0): "+dns)
if bits & 1<<1:
proto = "tcp"
elif dns == "yes":
proto = "udp"
else:
proto = "icmp"
print((" " * lvl)+"proto (1): "+proto)
if bits & 1<<2:
frag = "yes"
else:
frag = "no"
print((" " * lvl)+"frag (2): "+frag)
if bits & 1<<3:
malformed = "yes"
else:
malformed = "no"
print((" " * lvl)+"malformed(3): "+malformed)
else:
raise Exception("invalid message_bits, expected int but got: {}".format(type(bits)))
return 1 if dns == "yes" else 0
def parse_timestamp(ts, lvl):
print((" " * lvl)+"timestamp:")
lvl+=2
if isinstance(ts, list):
if ts[0] < 0:
if not last.ts:
raise Exception("invalid timestamp.seconds, got diff from last value but have no last value")
if not len(last.ts) == len(ts):
raise Exception("invalid timestamp.seconds, differentialy precision missmatch")
ts[0] = last.ts[0] + ( -ts[0] - 1 )
print((" " * lvl)+"seconds: {}".format(ts[0]))
if len(ts) > 1:
ts[1] = last.ts[1] + ts[1]
print((" " * lvl)+"useconds: {}".format(ts[1]))
if len(ts) > 2:
ts[2] = last.ts[2] + ts[2]
print((" " * lvl)+"nseconds: {}".format(ts[2]))
else:
print((" " * lvl)+"seconds: {}".format(ts[0]))
if len(ts) > 1:
print((" " * lvl)+"useconds: {}".format(ts[1]))
if len(ts) > 2:
print((" " * lvl)+"nseconds: {}".format(ts[2]))
last.ts = ts
elif isinstance(ts, int):
print((" " * lvl)+"seconds: {}".format(ts))
else:
raise Exception("invalid timestamp, expected list|int but got: {}".format(type(ts)))
def parse(cds):
print("paket:")
try:
parse_timestamp(cds.pop(0), 2)
is_dns = parse_message_bits(cds.pop(0), 2)
parse_ip_header(cds, 2)
if not is_dns:
raise Exception("not dns? huh?")
parse_dns_message(cds, 2)
except IndexError as idx:
if not str(idx) == "pop from empty list":
raise
print(" ...")
except:
raise
def main():
usage = '%prog [-v] [-h] <cds file...>'
parser = optparse.OptionParser(usage, version='%prog 0.01')
parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
help='turn verbose mode on')
(options, args) = parser.parse_args()
if options.verbose == True:
log.setLevel(logging.DEBUG)
log.debug('argv: %s', sys.argv)
log.debug('options: %s', options)
log.debug('args: %s', args)
else:
log.setLevel(logging.WARNING)
if not args:
parser.print_usage()
exit(1)
decoder = CBORDecoder()
# if https://github.com/agronholm/cbor2/pull/5 is not merged/released yet
if 0 not in decoder.special_decoders:
decoder.special_decoders[0] = lambda self, fp, shareable_index=None: SimpleValue(0)
decoder.special_decoders[1] = lambda self, fp, shareable_index=None: SimpleValue(1)
decoder.special_decoders[2] = lambda self, fp, shareable_index=None: SimpleValue(2)
decoder.special_decoders[3] = lambda self, fp, shareable_index=None: SimpleValue(3)
decoder.special_decoders[4] = lambda self, fp, shareable_index=None: SimpleValue(4)
decoder.special_decoders[5] = lambda self, fp, shareable_index=None: SimpleValue(5)
decoder.special_decoders[6] = lambda self, fp, shareable_index=None: SimpleValue(6)
decoder.special_decoders[7] = lambda self, fp, shareable_index=None: SimpleValue(7)
decoder.special_decoders[8] = lambda self, fp, shareable_index=None: SimpleValue(8)
decoder.special_decoders[9] = lambda self, fp, shareable_index=None: SimpleValue(9)
decoder.special_decoders[10] = lambda self, fp, shareable_index=None: SimpleValue(10)
decoder.special_decoders[11] = lambda self, fp, shareable_index=None: SimpleValue(11)
decoder.special_decoders[12] = lambda self, fp, shareable_index=None: SimpleValue(12)
decoder.special_decoders[13] = lambda self, fp, shareable_index=None: SimpleValue(13)
decoder.special_decoders[14] = lambda self, fp, shareable_index=None: SimpleValue(14)
decoder.special_decoders[15] = lambda self, fp, shareable_index=None: SimpleValue(15)
decoder.special_decoders[16] = lambda self, fp, shareable_index=None: SimpleValue(16)
decoder.special_decoders[17] = lambda self, fp, shareable_index=None: SimpleValue(17)
decoder.special_decoders[18] = lambda self, fp, shareable_index=None: SimpleValue(18)
decoder.special_decoders[19] = lambda self, fp, shareable_index=None: SimpleValue(19)
decoder.special_decoders[24] = decode_simple_value
version = None
for f in args:
log.debug('file: %s', f)
with open(f, 'rb') as fp:
obj = None
try:
obj = decoder.decode(fp)
except Exception as e:
if e.__str__().find("index out of range") == -1:
raise
if not isinstance(obj, list):
raise Exception("Invalid element, expected an array but found: {}".format(type(obj)))
version = obj.pop(0)
if version != "CDSv1":
raise Exception("Invalid version, expected CDSv1 but got: {}".format(version))
while len(obj):
opt = obj.pop(0)
if not isinstance(opt, int):
raise Exception("Invalid option, expected int but got: {}".format(type(opt)))
if opt == 0:
MAX_RLABELS = obj.pop(0)
if not isinstance(MAX_RLABELS, int) or MAX_RLABELS < 1:
raise Exception("Invalid option for maximum rlabels, got: {}".format(MAX_RLABELS))
log.debug("Using maximum rlabels {}".format(MAX_RLABELS))
elif opt == 1:
MIN_RLABEL_SIZE = obj.pop(0)
if not isinstance(MIN_RLABEL_SIZE, int) or MIN_RLABEL_SIZE < 1:
raise Exception("Invalid option for minimum rlabel size, got: {}".format(MIN_RLABEL_SIZE))
log.debug("Using minimum rlabel size {}".format(MIN_RLABEL_SIZE))
else:
raise Exception("Unknown option: {}".format(opt))
while True:
obj = None
try:
obj = decoder.decode(fp)
except Exception as e:
if e.__str__().find("index out of range") == -1:
raise
if obj is None:
break
if not isinstance(obj, list):
raise Exception("Invalid element, expected an array but found: {}".format(type(obj)))
parse(obj)
last.reset()
if __name__ == '__main__':
main()

View file

@ -1,797 +0,0 @@
#!/usr/bin/env python3
#
# Copyright (c) 2016-2025 OARC, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
import sys
import logging
import optparse
import struct
from cbor2 import CBORDecoder;
logging.basicConfig(format='%(levelname).5s: %(module)s:%(lineno)d: '
'%(message)s')
log = logging.getLogger(__name__)
class SimpleValue(object):
def __init__(self, value):
self.value = value
def get(self):
return self.value
def __repr__(self):
return "{}".format(self.value)
def decode_simple_value(self, fp, shareable_index=None):
return SimpleValue(struct.unpack('>B', fp.read(1))[0])
try:
from cbor2.types import CBORSimpleValue
except Exception:
CBORSimpleValue = SimpleValue
class LastValues(object):
def __init__(self):
self.reset()
def reset(self):
self.ts = None
self.src_addr4 = None
self.src_port4 = None
self.dest_addr4 = None
self.dest_port4 = None
self.src_addr6 = None
self.src_port6 = None
self.dest_addr6 = None
self.dest_port6 = None
self.rlabel = []
self.mlabel = []
self.rr_type = None
self.rr_class = None
self.rr_ttl = None
self.labels = {}
self.label_len = {}
self.label_parts = {}
self.label_part_len = {}
self.rdata = {}
self.rdata_len = {}
last = LastValues()
MAX_RLABELS = 255
MIN_RLABEL_SIZE = 3
def add_label(label):
size = 0
if isinstance(label, list):
for l in label:
if isinstance(l, str) and len(l) > 2:
if not l in last.label_parts:
last.label_parts[l] = 1
last.label_part_len[l] = len(l)
else:
last.label_parts[l] += 1
if not isinstance(l, int):
size += len(l)
else:
size = len(label)
if size < 3:
return
idx = "{}".format(label)
# print(idx)
if not idx in last.labels:
last.labels[idx] = 1
last.label_len[idx] = size
else:
last.labels[idx] += 1
def add_rdata(rdata):
size = 0
if isinstance(rdata, list):
for l in rdata:
if not isinstance(l, int):
size += len(l)
else:
size = len(rdata)
if size < 3:
return
idx = "{}".format(rdata)
# print(idx)
if not idx in last.rdata:
last.rdata[idx] = 1
last.rdata_len[idx] = size
else:
last.rdata[idx] += 1
def get_rlabel(idx):
rlabel_idx = -idx - 1
try:
label = last.rlabel.pop(rlabel_idx)
last.rlabel.insert(0, label)
return label
except:
raise Exception("rlabel index {} out of range".format(rlabel_idx))
def add_rlabel(label):
size = 0
if isinstance(label, list):
for l in label:
if isinstance(l, str):
size += len(l)
if size < MIN_RLABEL_SIZE:
return
last.rlabel.insert(0, label)
if len(last.rlabel) > MAX_RLABELS:
last.rlabel.pop()
def build_mlabel_label(label):
if isinstance(label, int) and label < 0:
label = get_rlabel(label)
else:
add_rlabel(label)
if isinstance(label, str):
last.mlabel.append(label)
elif isinstance(label, list):
if len(label) and isinstance(label[0], int):
last.mlabel.append(label)
return
label = list(label)
while len(label):
last.mlabel.append(list(label))
label.pop(0)
def build_mlabel(rrs):
for rr in rrs:
if len(rr) and isinstance(rr[0], bool):
continue
if len(rr):
build_mlabel_label(rr[0])
if len(rr) > 1 and isinstance(rr[len(rr)-1], list):
for l in rr[len(rr)-1]:
build_mlabel_label(l)
def parse_label(label, lvl):
if isinstance(label, int) and label < 0:
label = get_rlabel(label)
else:
add_rlabel(label)
add_label(label)
if isinstance(label, bytes):
#print((" " * lvl)+"label: {}".format(bytes))
pass
elif isinstance(label, list):
if len(label) and isinstance(label[0], int) and label[0] < 0:
dn = list(get_rlabel(label[0]))
else:
dn = list(label)
#print((" " * lvl)+"clabel: {}".format(dn))
dnstr = []
seen_mlabel = {}
while len(dn):
while isinstance(dn[0], int):
if dn[0] in seen_mlabel:
dn = [ "{ name compression loop }" ]
break
seen_mlabel[dn[0]] = 1
dn = list(last.mlabel[dn[0]])
dnstr.append(dn.pop(0))
#print((" " * lvl)+"label: "+ " . ".join(dnstr))
else:
raise Exception("invalid label type {}".format(type(label)))
def parse_rrs(rrs, lvl):
for rr in rrs:
#print((" " * lvl)+"rr:")
lvl+=2
if len(rr) and isinstance(rr[0], bool):
#print((" " * lvl)+"incomplete/broken DNS RR, no support for these yet")
continue
parse_label(rr.pop(0), lvl)
bits = 0
if isinstance(rr[0], CBORSimpleValue):
bits = rr.pop(0).value
#print((" " * lvl)+"type (0): "+("yes" if bits & 1 else "no"))
#print((" " * lvl)+"class (1): "+("yes" if bits & 1<<1 else "no"))
#print((" " * lvl)+"ttl (2): "+("yes" if bits & 1<<2 else "no"))
#print((" " * lvl)+"rdlength(3): "+("yes" if bits & 1<<3 else "no"))
rr_type = None
rr_class = None
rr_ttl = None
rdlength = None
if not bits:
if len(rr) > 4:
bits = 0xff
elif len(rr) > 1:
raise Exception("invalid rr, expected none (0) or all (4) optional values but got {}".format(len(rr)-1))
if bits & 1:
if not isinstance(rr[0], int):
raise Exception("invalid rr.type, expected int but got: {}".format(type(rr[0])))
rr_type = rr.pop(0)
if bits & 1<<1:
if not isinstance(rr[0], int):
raise Exception("invalid rr.class, expected int but got: {}".format(type(rr[0])))
rr_class = rr.pop(0)
if bits & 1<<2:
if not isinstance(rr[0], int):
raise Exception("invalid rr.ttl, expected int but got: {}".format(type(rr[0])))
rr_ttl = rr.pop(0)
if bits & 1<<3:
if not isinstance(rr[0], int):
raise Exception("invalid rr.rdlength, expected int but got: {}".format(type(rr[0])))
rdlength = rr.pop(0)
if not rr_type:
rr_type = last.rr_type
if not rr_class:
rr_class = last.rr_class
if not rr_ttl:
rr_ttl = last.rr_ttl
#print((" " * lvl)+"type: {}".format(rr_type))
#print((" " * lvl)+"class: {}".format(rr_class))
#print((" " * lvl)+"ttl: {}".format(rr_ttl))
if rdlength:
#print((" " * lvl)+"rdlength: {}".format(rdlength))
pass
if rr_type != 41:
last.rr_type = rr_type
last.rr_class = rr_class
last.rr_ttl = rr_ttl
if isinstance(rr[0], bytes):
add_rdata(rr[0])
rr.pop(0)
#print((" " * lvl)+"rdata: "+"".join("{:02x}".format(byte) for byte in rr.pop(0)))
elif isinstance(rr[0], list):
add_rdata(rr[0])
rdata = []
for i in rr.pop(0):
if isinstance(i, int) and i < 0:
i = get_rlabel(i)
elif not isinstance(i, bytes):
add_rlabel(i)
add_label(i)
if isinstance(i, bytes):
rdata.append("".join("{:02x}".format(byte) for byte in i))
elif isinstance(i, list):
dn = list(i)
dnstr = []
seen_mlabel = {}
while len(dn):
while isinstance(dn[0], int):
if dn[0] in seen_mlabel:
dn = [ "{ name compression loop }" ]
break
seen_mlabel[dn[0]] = 1
dn = list(last.mlabel[dn[0]])
dnstr.append(dn.pop(0))
rdata.append("[ clabel: {} label: ".format(i) + " . ".join(dnstr) + " ]")
else:
raise Exception("invalid rr.rdata[], expected bytes|list but got: {}".format(type(i)))
#print((" " * lvl)+"rdata: "+" ".join(rdata))
else:
raise Exception("invalid rr.rdata, expected bytes|list but got: {}".format(type(rr[0])))
lvl-=2
def parse_qrs(qrs, lvl):
for qr in qrs:
#print((" " * lvl)+"qr:")
lvl+=2
parse_label(qr.pop(0), lvl)
rr_type = None
rr_class = None
if len(qr):
if not isinstance(qr[0], int):
raise Exception("invalid qr.type|class, expected int but got {}".format(type(qr[0])))
if qr[0] > -1:
rr_type = qr.pop(0)
if len(qr):
if not isinstance(qr[0], int):
raise Exception("invalid qr.class, expected int but got {}".format(type(qr[0])))
elif not qr[0] < 0:
raise Exception("invalid qr.class, expected negative int but got positive")
rr_class = -qr.pop(0) - 1
else:
rr_class = -qr.pop(0) - 1
if not rr_type:
rr_type = last.rr_type
if not rr_class:
rr_class = last.rr_class
#print((" " * lvl)+"type: {}".format(rr_type))
#print((" " * lvl)+"class: {}".format(rr_class))
if rr_type != 41:
last.rr_type = rr_type
last.rr_class = rr_class
lvl-=2
def parse_dns_message(dns, lvl):
#print((" " * lvl)+"dns:")
lvl+=2
if isinstance(dns[0], bool):
#print((" " * lvl)+"incomplete/broken DNS packet, no support for these yet")
return
#print((" " * lvl)+"header:")
lvl+=2
id = dns.pop(0) # lgtm [py/unused-local-variable]
#print((" " * lvl)+"id: {}".format(id))
raw = dns.pop(0) # lgtm [py/unused-local-variable]
#print((" " * lvl)+"raw: 0x{:04x}".format(raw))
lvl+=2
#print((" " * lvl)+" QR: "+("yes" if raw & 1<<15 else "no"))
#print((" " * lvl)+"Opcode: {}".format(((raw >> 11) & 0xf)))
#print((" " * lvl)+" AA: "+("yes" if raw & 1<<10 else "no"))
#print((" " * lvl)+" TC: "+("yes" if raw & 1<<9 else "no"))
#print((" " * lvl)+" RD: "+("yes" if raw & 1<<8 else "no"))
#print((" " * lvl)+" RA: "+("yes" if raw & 1<<7 else "no"))
#print((" " * lvl)+" Z: "+("yes" if raw & 1<<6 else "no"))
#print((" " * lvl)+" AD: "+("yes" if raw & 1<<5 else "no"))
#print((" " * lvl)+" CD: "+("yes" if raw & 1<<4 else "no"))
#print((" " * lvl)+" RCODE: {}".format(raw & 0xf))
lvl-=2
bits = 0
if isinstance(dns[0], int) and dns[0] < 0:
bits = -dns.pop(0) - 1
#print((" " * lvl)+"qdcount(0): "+("yes" if bits & 1 else "no"))
#print((" " * lvl)+"ancount(1): "+("yes" if bits & 1<<1 else "no"))
#print((" " * lvl)+"nscount(2): "+("yes" if bits & 1<<2 else "no"))
#print((" " * lvl)+"arcount(3): "+("yes" if bits & 1<<3 else "no"))
if not bits:
if isinstance(dns[0], int):
bits = 0xff
if bits & 1:
if not isinstance(dns[0], int):
raise Exception("invalid dns.header.qdcount, expected int but got: {}".format(type(dns[0])))
dns.pop(0)
#print((" " * lvl)+"qdcount: {}".format(dns.pop(0)))
if bits & 1<<1:
if not isinstance(dns[0], int):
raise Exception("invalid dns.header.ancount, expected int but got: {}".format(type(dns[0])))
dns.pop(0)
#print((" " * lvl)+"ancount: {}".format(dns.pop(0)))
if bits & 1<<2:
if not isinstance(dns[0], int):
raise Exception("invalid dns.header.nscount, expected int but got: {}".format(type(dns[0])))
dns.pop(0)
#print((" " * lvl)+"nscount: {}".format(dns.pop(0)))
if bits & 1<<3:
if not isinstance(dns[0], int):
raise Exception("invalid dns.header.arcount, expected int but got: {}".format(type(dns[0])))
dns.pop(0)
#print((" " * lvl)+"arcount: {}".format(dns.pop(0)))
bits = 0
if isinstance(dns[0], CBORSimpleValue):
bits = dns.pop(0).value
#print((" " * lvl)+"questions (0): "+("yes" if bits & 1 else "no"))
#print((" " * lvl)+"answers (1): "+("yes" if bits & 1<<1 else "no"))
#print((" " * lvl)+"authorities(2): "+("yes" if bits & 1<<2 else "no"))
#print((" " * lvl)+"additionals(3): "+("yes" if bits & 1<<3 else "no"))
last.mlabel = []
rlabel = list(last.rlabel)
for n in range(4):
if len(dns) > n and isinstance(dns[n], list):
build_mlabel(dns[n])
last.rlabel = rlabel
if not bits:
if len(dns) > 3:
bits = 0xff
elif len(dns) > 0:
raise Exception("invalid dns.message rr's, expected none (0) or all (4) but got {}".format(len(dns)))
if bits & 1:
if not isinstance(dns[0], list):
raise Exception("invalid dns.message.questions, expected list but got: {}".format(type(dns[0])))
#print((" " * lvl)+"questions:")
parse_qrs(dns.pop(0), lvl+2)
if bits & 1<<1:
if not isinstance(dns[0], list):
raise Exception("invalid dns.message.answers, expected list but got: {}".format(type(dns[0])))
#print((" " * lvl)+"answers:")
parse_rrs(dns.pop(0), lvl+2)
if bits & 1<<2:
if not isinstance(dns[0], list):
raise Exception("invalid dns.message.authorities, expected list but got: {}".format(type(dns[0])))
#print((" " * lvl)+"authorities:")
parse_rrs(dns.pop(0), lvl+2)
if bits & 1<<3:
if not isinstance(dns[0], list):
raise Exception("invalid dns.message.additionals, expected list but got: {}".format(type(dns[0])))
#print((" " * lvl)+"additionals:")
parse_rrs(dns.pop(0), lvl+2)
if len(dns):
if isinstance(dns[0], bytes):
dns.pop(0)
#print((" " * lvl)+"malformed: "+"".join("{:02x}".format(byte) for byte in dns.pop(0)))
if len(dns):
raise Exception("invalid dns.message, garbage at end: {}".format(dns))
def parse_ip_header(ip_header, lvl):
#print((" " * lvl)+"ip_header:")
lvl+=2
#print((" " * lvl)+"bits:")
lvl+=2
bits = ip_header.pop(0)
reverse = False
if isinstance(bits, int):
if bits < 0:
#print((" " * lvl)+"reverse: yes")
bits = -bits - 1
reverse = True
#print((" " * lvl)+"family (0): "+("INET6" if bits & 1 else "INET"))
#print((" " * lvl)+"have_src (1): "+("yes" if bits & 1<<1 else "no"))
#print((" " * lvl)+"have_dest(2): "+("yes" if bits & 1<<2 else "no"))
#print((" " * lvl)+"have_port(3): "+("yes" if bits & 1<<3 else "no"))
else:
raise Exception("invalid ip_header.bits, expected int but got: {}".format(type(bits)))
lvl-=2
src_addr = None
dest_addr = None
src_port = None
dest_port = None
if bits & 1<<1:
src_addr = ip_header.pop(0)
if not isinstance(src_addr, bytes):
raise Exception("invalid ip_header.src_addr, expected bytes but got: {}".format(type(src_addr)))
else:
if reverse:
src_addr = last.dest_addr6 if bits & 1 else last.dest_addr4
if not src_addr:
raise Exception("invalid ip_header.bits, expected to have last dest addr but don't")
else:
src_addr = last.src_addr6 if bits & 1 else last.src_addr4
if not src_addr:
raise Exception("invalid ip_header.bits, expected to have last src addr but don't")
if bits & 1<<2:
dest_addr = ip_header.pop(0)
if not isinstance(dest_addr, bytes):
raise Exception("invalid ip_header.dest_addr, expected bytes but got: {}".format(type(dest_addr)))
else:
if reverse:
dest_addr = last.src_addr6 if bits & 1 else last.src_addr4
if not dest_addr:
raise Exception("invalid ip_header.bits, expected to have last src addr but don't")
else:
dest_addr = last.dest_addr6 if bits & 1 else last.dest_addr4
if not dest_addr:
raise Exception("invalid ip_header.bits, expected to have last dest addr but don't")
if bits & 1<<3:
ports = ip_header.pop(0)
if not isinstance(ports, int):
raise Exception("invalid ip_header.src_dest_port, expected int but got: {}".format(type(ports)))
if ports > 0xffff:
src_port = ports & 0xffff
dest_port = ports >> 16
elif ports < 0:
if reverse:
src_port = last.dest_port6 if bits & 1 else last.dest_port4
if src_port is None:
raise Exception("invalid ip_header.bits, expected to have last dest port but don't")
else:
src_port = last.src_port6 if bits & 1 else last.src_port4
if src_port is None:
raise Exception("invalid ip_header.bits, expected to have last src port but don't")
dest_port = -ports - 1
else:
src_port = ports
if reverse:
dest_port = last.src_port6 if bits & 1 else last.src_port4
if dest_port is None:
raise Exception("invalid ip_header.bits, expected to have last src port but don't")
else:
dest_port = last.dest_port6 if bits & 1 else last.dest_port4
if dest_port is None:
raise Exception("invalid ip_header.bits, expected to have last dest port but don't")
else:
if reverse:
src_port = last.dest_port6 if bits & 1 else last.dest_port4
if src_port is None:
raise Exception("invalid ip_header.bits, expected to have last dest port but don't")
else:
src_port = last.src_port6 if bits & 1 else last.src_port4
if src_port is None:
raise Exception("invalid ip_header.bits, expected to have last src port but don't")
if reverse:
dest_port = last.src_port6 if bits & 1 else last.src_port4
if dest_port is None:
raise Exception("invalid ip_header.bits, expected to have last src port but don't")
else:
dest_port = last.dest_port6 if bits & 1 else last.dest_port4
if dest_port is None:
raise Exception("invalid ip_header.bits, expected to have last dest port but don't")
#print((" " * lvl)+" src addr: " + socket.inet_ntop(socket.AF_INET6 if bits & 1 else socket.AF_INET, src_addr))
#print((" " * lvl)+"dest addr: " + socket.inet_ntop(socket.AF_INET6 if bits & 1 else socket.AF_INET, dest_addr))
#print((" " * lvl)+" src port: {}".format(src_port))
#print((" " * lvl)+"dest port: {}".format(dest_port))
if bits & 1:
last.src_addr6 = src_addr
last.dest_addr6 = dest_addr
last.src_port6 = src_port
last.dest_port6 = dest_port
else:
last.src_addr4 = src_addr
last.dest_addr4 = dest_addr
last.src_port4 = src_port
last.dest_port4 = dest_port
def parse_message_bits(bits, lvl):
#print((" " * lvl)+"message_bits:")
lvl+=2
dns = "no"
if isinstance(bits, int):
# if bits & 1:
# dns = "yes"
# #print((" " * lvl)+"dns (0): "+dns)
#
# if bits & 1<<1:
# proto = "tcp"
# elif dns == "yes":
# proto = "udp"
# else:
# proto = "icmp"
# #print((" " * lvl)+"proto (1): "+proto)
#
# if bits & 1<<2:
# frag = "yes"
# else:
# frag = "no"
# #print((" " * lvl)+"frag (2): "+frag)
#
# if bits & 1<<3:
# malformed = "yes"
# else:
# malformed = "no"
# #print((" " * lvl)+"malformed(3): "+malformed)
pass
else:
raise Exception("invalid message_bits, expected int but got: {}".format(type(bits)))
return 1 if dns == "yes" else 0
def parse_timestamp(ts, lvl):
#print((" " * lvl)+"timestamp:")
lvl+=2
if isinstance(ts, list):
if ts[0] < 0:
if not last.ts:
raise Exception("invalid timestamp.seconds, got diff from last value but have no last value")
if not len(last.ts) == len(ts):
raise Exception("invalid timestamp.seconds, differentialy precision missmatch")
ts[0] = last.ts[0] + ( -ts[0] - 1 )
#print((" " * lvl)+"seconds: {}".format(ts[0]))
if len(ts) > 1:
ts[1] = last.ts[1] + ts[1]
#print((" " * lvl)+"useconds: {}".format(ts[1]))
if len(ts) > 2:
ts[2] = last.ts[2] + ts[2]
#print((" " * lvl)+"nseconds: {}".format(ts[2]))
else:
#print((" " * lvl)+"seconds: {}".format(ts[0]))
if len(ts) > 1:
#print((" " * lvl)+"useconds: {}".format(ts[1]))
pass
if len(ts) > 2:
#print((" " * lvl)+"nseconds: {}".format(ts[2]))
pass
last.ts = ts
elif isinstance(ts, int):
#print((" " * lvl)+"seconds: {}".format(ts))
pass
else:
raise Exception("invalid timestamp, expected list|int but got: {}".format(type(ts)))
def parse(cds):
#print("paket:")
try:
parse_timestamp(cds.pop(0), 2)
is_dns = parse_message_bits(cds.pop(0), 2)
parse_ip_header(cds, 2)
if not is_dns:
raise Exception("not dns? huh?")
parse_dns_message(cds, 2)
except IndexError as idx:
if not str(idx) == "pop from empty list":
raise
#print(" ...")
except:
raise
def main():
usage = '%prog [-v] [-h] <cds file...>'
parser = optparse.OptionParser(usage, version='%prog 0.01')
parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
help='turn verbose mode on')
(options, args) = parser.parse_args()
if options.verbose == True:
log.setLevel(logging.DEBUG)
log.debug('argv: %s', sys.argv)
log.debug('options: %s', options)
log.debug('args: %s', args)
else:
log.setLevel(logging.WARNING)
if not args:
parser.print_usage()
exit(1)
decoder = CBORDecoder()
# if https://github.com/agronholm/cbor2/pull/5 is not merged/released yet
if 0 not in decoder.special_decoders:
decoder.special_decoders[0] = lambda self, fp, shareable_index=None: SimpleValue(0)
decoder.special_decoders[1] = lambda self, fp, shareable_index=None: SimpleValue(1)
decoder.special_decoders[2] = lambda self, fp, shareable_index=None: SimpleValue(2)
decoder.special_decoders[3] = lambda self, fp, shareable_index=None: SimpleValue(3)
decoder.special_decoders[4] = lambda self, fp, shareable_index=None: SimpleValue(4)
decoder.special_decoders[5] = lambda self, fp, shareable_index=None: SimpleValue(5)
decoder.special_decoders[6] = lambda self, fp, shareable_index=None: SimpleValue(6)
decoder.special_decoders[7] = lambda self, fp, shareable_index=None: SimpleValue(7)
decoder.special_decoders[8] = lambda self, fp, shareable_index=None: SimpleValue(8)
decoder.special_decoders[9] = lambda self, fp, shareable_index=None: SimpleValue(9)
decoder.special_decoders[10] = lambda self, fp, shareable_index=None: SimpleValue(10)
decoder.special_decoders[11] = lambda self, fp, shareable_index=None: SimpleValue(11)
decoder.special_decoders[12] = lambda self, fp, shareable_index=None: SimpleValue(12)
decoder.special_decoders[13] = lambda self, fp, shareable_index=None: SimpleValue(13)
decoder.special_decoders[14] = lambda self, fp, shareable_index=None: SimpleValue(14)
decoder.special_decoders[15] = lambda self, fp, shareable_index=None: SimpleValue(15)
decoder.special_decoders[16] = lambda self, fp, shareable_index=None: SimpleValue(16)
decoder.special_decoders[17] = lambda self, fp, shareable_index=None: SimpleValue(17)
decoder.special_decoders[18] = lambda self, fp, shareable_index=None: SimpleValue(18)
decoder.special_decoders[19] = lambda self, fp, shareable_index=None: SimpleValue(19)
decoder.special_decoders[24] = decode_simple_value
version = None
for f in args:
log.debug('file: %s', f)
with open(f, 'rb') as fp:
obj = None
try:
obj = decoder.decode(fp)
except Exception as e:
if e.__str__().find("index out of range") == -1:
raise
if not isinstance(obj, list):
raise Exception("Invalid element, expected an array but found: {}".format(type(obj)))
version = obj.pop(0)
if version != "CDSv1":
raise Exception("Invalid version, expected CDSv1 but got: {}".format(version))
while len(obj):
opt = obj.pop(0)
if not isinstance(opt, int):
raise Exception("Invalid option, expected int but got: {}".format(type(opt)))
if opt == 0:
MAX_RLABELS = obj.pop(0)
if not isinstance(MAX_RLABELS, int) or MAX_RLABELS < 1:
raise Exception("Invalid option for maximum rlabels, got: {}".format(MAX_RLABELS))
log.debug("Using maximum rlabels {}".format(MAX_RLABELS))
elif opt == 1:
MIN_RLABEL_SIZE = obj.pop(0)
if not isinstance(MIN_RLABEL_SIZE, int) or MIN_RLABEL_SIZE < 1:
raise Exception("Invalid option for minimum rlabel size, got: {}".format(MIN_RLABEL_SIZE))
log.debug("Using minimum rlabel size {}".format(MIN_RLABEL_SIZE))
else:
raise Exception("Unknown option: {}".format(opt))
while True:
obj = None
try:
obj = decoder.decode(fp)
except Exception as e:
if e.__str__().find("index out of range") == -1:
raise
if obj is None:
break
if not isinstance(obj, list):
raise Exception("Invalid element, expected an array but found: {}".format(type(obj)))
parse(obj)
log.debug("unique labels: {} parts: {} rdata: {}".format(len(last.labels), len(last.label_parts), len(last.rdata)))
n = 0
e = 0
for l in last.labels:
# print("{}: {}".format(l, last.labels[l]))
if last.labels[l] > 1:
n += last.label_len[l] * ( last.labels[l] - 1 )
e += 2 * ( last.labels[l] - 1 )
log.debug("reduce labels: {} - {}".format(n, e))
n = 0
e = 0
for l in last.label_parts:
# print("{}: {}".format(l, last.label_parts[l]))
if last.label_parts[l] > 1:
n += last.label_part_len[l] * ( last.label_parts[l] - 1 )
e += 2 * ( last.label_parts[l] - 1 )
log.debug("reduce label parts: {} - {}".format(n, e))
n = 0
e = 0
for l in last.rdata:
if last.rdata[l] > 1:
n += last.rdata_len[l] * ( last.rdata[l] - 1 )
e += 2 * ( last.rdata[l] - 1 )
# print("{}: {}".format(l, last.rdata[l]))
log.debug("reduce rdata: {} - {}".format(n, e))
last.reset()
if __name__ == '__main__':
main()

8
debian/changelog vendored
View file

@ -1,11 +1,3 @@
dnscap (2.3.1-1) sid; urgency=medium
* Simplifying watch file.
* Merging upstream version 2.3.1.
* Removing time64.patch, included upstream.
-- Daniel Baumann <daniel@debian.org> Thu, 24 Apr 2025 13:53:30 +0200
dnscap (2.3.0-3) sid; urgency=medium dnscap (2.3.0-3) sid; urgency=medium
* Refreshing time64.patch with an updated version from upstream. * Refreshing time64.patch with an updated version from upstream.

View file

@ -1 +1,2 @@
debian/0001-rssm-shebang.patch debian/0001-rssm-shebang.patch
upstream/0001-time64.patch

View file

@ -0,0 +1,271 @@
From 731d9e00c686f1b67660403406252f0c742f38eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jerry=20Lundstr=C3=B6m?= <lundstrom.jerry@gmail.com>
Date: Tue, 22 Apr 2025 09:50:50 +0200
Subject: [PATCH] Add support for 64bit time structures on 32bit systems
- Fix #324:
- Add macros for printing `timeval` when `_TIME_BITS` is set to 64
- Clean up usage and printing of `timeval` structures in `src` and `plugins`
---
plugins/pcapdump/pcapdump.c | 6 +++---
plugins/rssm/rssm.c | 16 ++++++++--------
plugins/rzkeychange/rzkeychange.c | 8 ++++----
plugins/txtout/txtout.c | 2 +-
src/dnscap.c | 4 ++--
src/dnscap_common.h | 15 +++++++++++++++
src/dumper.c | 2 +-
src/network.c | 18 +++++++++---------
8 files changed, 43 insertions(+), 28 deletions(-)
diff --git a/plugins/pcapdump/pcapdump.c b/plugins/pcapdump/pcapdump.c
index 5a93b22..e6f2996 100644
--- a/plugins/pcapdump/pcapdump.c
+++ b/plugins/pcapdump/pcapdump.c
@@ -175,10 +175,10 @@ int pcapdump_open(my_bpftimeval ts)
ts.tv_sec++;
ts.tv_usec -= MILLION;
}
- gmtime_r((time_t*)&ts.tv_sec, &tm);
+ gmtime_r(&ts.tv_sec, &tm);
strftime(sbuf, 64, "%Y%m%d.%H%M%S", &tm);
- if (asprintf(&dumpname, "%s.%s.%06lu",
- dump_base, sbuf, (u_long)ts.tv_usec)
+ if (asprintf(&dumpname, "%s.%s.%06" PRI_tv_usec,
+ dump_base, sbuf, ts.tv_usec)
< 0
|| asprintf(&dumpnamepart, "%s.part", dumpname) < 0) {
logerr("asprintf: %s", strerror(errno));
diff --git a/plugins/rssm/rssm.c b/plugins/rssm/rssm.c
index 8d3428b..e760990 100644
--- a/plugins/rssm/rssm.c
+++ b/plugins/rssm/rssm.c
@@ -286,7 +286,7 @@ void rssm_save_counts(const char* sbuf)
FILE* fp;
int i;
char* tbuf = 0;
- i = asprintf(&tbuf, "%s.%s.%06lu", counts_prefix ? counts_prefix : COUNTS_PREFIX_DEFAULT, sbuf, (u_long)open_ts.tv_usec);
+ i = asprintf(&tbuf, "%s.%s.%06" PRI_tv_usec, counts_prefix ? counts_prefix : COUNTS_PREFIX_DEFAULT, sbuf, open_ts.tv_usec);
if (i < 1 || !tbuf) {
logerr("asprintf: out of memory");
return;
@@ -302,7 +302,7 @@ void rssm_save_counts(const char* sbuf)
char tz[21];
struct tm tm;
- gmtime_r((time_t*)&open_ts.tv_sec, &tm);
+ gmtime_r(&open_ts.tv_sec, &tm);
if (!strftime(tz, sizeof(tz), "%Y-%m-%dT%H:%M:%SZ", &tm)) {
logerr("rssm: strftime failed");
fclose(fp);
@@ -443,8 +443,8 @@ void rssm_save_counts(const char* sbuf)
}
}
} else {
- fprintf(fp, "first-packet-time %ld\n", (long)open_ts.tv_sec);
- fprintf(fp, "last-packet-time %ld\n", (long)close_ts.tv_sec);
+ fprintf(fp, "first-packet-time %" PRI_tv_sec "\n", open_ts.tv_sec);
+ fprintf(fp, "last-packet-time %" PRI_tv_sec "\n", close_ts.tv_sec);
fprintf(fp, "dns-udp-queries-received-ipv4 %" PRIu64 "\n", counts.dns_udp_queries_received_ipv4);
fprintf(fp, "dns-udp-queries-received-ipv6 %" PRIu64 "\n", counts.dns_udp_queries_received_ipv6);
fprintf(fp, "dns-tcp-queries-received-ipv4 %" PRIu64 "\n", counts.dns_tcp_queries_received_ipv4);
@@ -510,7 +510,7 @@ void rssm_save_sources(const char* sbuf)
FILE* fp;
char* tbuf = 0;
int i;
- i = asprintf(&tbuf, "%s.%s.%06lu", sources_prefix, sbuf, (u_long)open_ts.tv_usec);
+ i = asprintf(&tbuf, "%s.%s.%06" PRI_tv_usec, sources_prefix, sbuf, open_ts.tv_usec);
if (i < 1 || !tbuf) {
logerr("asprintf: out of memory");
return;
@@ -535,7 +535,7 @@ void rssm_save_aggregated(const char* sbuf)
FILE* fp;
char* tbuf = 0;
int i;
- i = asprintf(&tbuf, "%s.%s.%06lu", aggregated_prefix, sbuf, (u_long)open_ts.tv_usec);
+ i = asprintf(&tbuf, "%s.%s.%06" PRI_tv_usec, aggregated_prefix, sbuf, open_ts.tv_usec);
if (i < 1 || !tbuf) {
logerr("asprintf: out of memory");
return;
@@ -566,7 +566,7 @@ int rssm_close(my_bpftimeval ts)
struct tm tm;
if (dont_fork_on_close) {
- gmtime_r((time_t*)&open_ts.tv_sec, &tm);
+ gmtime_r(&open_ts.tv_sec, &tm);
strftime(sbuf, sizeof(sbuf), "%Y%m%d.%H%M%S", &tm);
close_ts = ts;
rssm_save_counts(sbuf);
@@ -596,7 +596,7 @@ int rssm_close(my_bpftimeval ts)
exit(0);
}
/* grandchild (2nd gen) continues */
- gmtime_r((time_t*)&open_ts.tv_sec, &tm);
+ gmtime_r(&open_ts.tv_sec, &tm);
strftime(sbuf, sizeof(sbuf), "%Y%m%d.%H%M%S", &tm);
close_ts = ts;
rssm_save_counts(sbuf);
diff --git a/plugins/rzkeychange/rzkeychange.c b/plugins/rzkeychange/rzkeychange.c
index dd99316..540e415 100644
--- a/plugins/rzkeychange/rzkeychange.c
+++ b/plugins/rzkeychange/rzkeychange.c
@@ -290,8 +290,8 @@ void rzkeychange_submit_counts(void)
double elapsed = (double)clos_ts.tv_sec - (double)open_ts.tv_sec + 0.000001 * clos_ts.tv_usec - 0.000001 * open_ts.tv_usec; // NOSONAR
int k;
- k = snprintf(qname, sizeof(qname), "%lu-%u-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 ".%s.%s.%s",
- (u_long)open_ts.tv_sec,
+ k = snprintf(qname, sizeof(qname), "%" PRI_tv_sec "-%u-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 ".%s.%s.%s",
+ open_ts.tv_sec,
(unsigned int)(elapsed + 0.5),
counts.total,
counts.dnskey,
@@ -330,8 +330,8 @@ void rzkeychange_submit_counts(void)
if (*t == '.' || *t == ':')
*t = '-';
- k = snprintf(qname, sizeof(qname), "%lu.%s.%hhx.%s.%s.%s.%s",
- (u_long)open_ts.tv_sec,
+ k = snprintf(qname, sizeof(qname), "%" PRI_tv_sec ".%s.%hhx.%s.%s.%s.%s",
+ open_ts.tv_sec,
s,
key_tag_signals[i].flags,
key_tag_signals[i].signal,
diff --git a/plugins/txtout/txtout.c b/plugins/txtout/txtout.c
index 67b41c3..54c71e7 100644
--- a/plugins/txtout/txtout.c
+++ b/plugins/txtout/txtout.c
@@ -220,7 +220,7 @@ void txtout_output(const char* descr, iaddr from, iaddr to, uint8_t proto, unsig
/*
* IP Stuff
*/
- fprintf(out, "%10ld.%06ld", (long)ts.tv_sec, (long)ts.tv_usec);
+ fprintf(out, "%10" PRI_tv_sec ".%06" PRI_tv_usec, ts.tv_sec, ts.tv_usec);
fprintf(out, " %s %u", ia_str(from), sport);
fprintf(out, " %s %u", ia_str(to), dport);
fprintf(out, " %hhu", proto);
diff --git a/src/dnscap.c b/src/dnscap.c
index 7788f0a..aea8370 100644
--- a/src/dnscap.c
+++ b/src/dnscap.c
@@ -143,8 +143,8 @@ int main(int argc, char* argv[])
struct tm tm;
gmtime_r(&start_time, &tm);
strftime(when, sizeof when, "%F %T", &tm);
- fprintf(stderr, "Sleeping for %d seconds until %s UTC\n",
- (int)(start_time - now.tv_sec), when);
+ fprintf(stderr, "Sleeping for %" PRI_tv_sec " seconds until %s UTC\n",
+ start_time - now.tv_sec, when);
sleep(start_time - now.tv_sec);
fprintf(stderr, "Awake.\n");
}
diff --git a/src/dnscap_common.h b/src/dnscap_common.h
index 719ebf4..f131330 100644
--- a/src/dnscap_common.h
+++ b/src/dnscap_common.h
@@ -49,6 +49,21 @@
#endif
#endif
+/* Macros for printing timeval */
+#include <inttypes.h>
+#if _TIME_BITS == 64
+#define PRI_tv_sec PRId64
+#define PRI_tv_usec PRId64
+#else
+#ifdef __OpenBSD__
+#define PRI_tv_sec PRId64
+#define PRI_tv_usec "ld"
+#else
+#define PRI_tv_sec "ld"
+#define PRI_tv_usec "ld"
+#endif
+#endif
+
/*
* setup MY_BPFTIMEVAL as the timeval structure that bpf packets
* will be assoicated with packets from libpcap
diff --git a/src/dumper.c b/src/dumper.c
index 68783e7..b1e6c9a 100644
--- a/src/dumper.c
+++ b/src/dumper.c
@@ -198,7 +198,7 @@ int dumper_open(my_bpftimeval ts)
gmtime_r((time_t*)&ts.tv_sec, &tm);
strftime(sbuf, 64, "%Y%m%d.%H%M%S", &tm);
- if (asprintf(&dumpname, "%s.%s.%06ld%s",
+ if (asprintf(&dumpname, "%s.%s.%06" PRI_tv_usec "%s",
dump_base, sbuf,
ts.tv_usec, dump_suffix ? dump_suffix : "")
< 0
diff --git a/src/network.c b/src/network.c
index f0a6238..7227752 100644
--- a/src/network.c
+++ b/src/network.c
@@ -192,7 +192,7 @@ void layer_pkt(u_char* user, const pcap_thread_packet_t* packet, const u_char* p
break;
}
- t = (time_t)firstpkt->pkthdr.ts.tv_sec;
+ t = firstpkt->pkthdr.ts.tv_sec;
gmtime_r(&t, &tm);
strftime(when, sizeof(when), "%Y-%m-%d %T", &tm);
@@ -207,7 +207,7 @@ void layer_pkt(u_char* user, const pcap_thread_packet_t* packet, const u_char* p
}
if (vlan != MAX_VLAN) {
- snprintf(descr, sizeof(descr), "[%zu] %s.%06ld [#%zd %s (vlan %u) %u] \\\n",
+ snprintf(descr, sizeof(descr), "[%zu] %s.%06" PRI_tv_usec " [#%zd %s (vlan %u) %u] \\\n",
len,
when,
firstpkt->pkthdr.ts.tv_usec,
@@ -216,7 +216,7 @@ void layer_pkt(u_char* user, const pcap_thread_packet_t* packet, const u_char* p
vlan,
vlan);
} else {
- snprintf(descr, sizeof(descr), "[%zu] %s.%06ld [#%zd %s %u] \\\n",
+ snprintf(descr, sizeof(descr), "[%zu] %s.%06" PRI_tv_usec " [#%zd %s %u] \\\n",
len,
when,
firstpkt->pkthdr.ts.tv_usec,
@@ -426,7 +426,7 @@ void dl_pkt(u_char* user, const struct pcap_pkthdr* hdr, const u_char* pkt, cons
struct tm tm;
time_t t;
- t = (time_t)hdr->ts.tv_sec;
+ t = hdr->ts.tv_sec;
gmtime_r(&t, &tm);
strftime(when, sizeof when, "%Y-%m-%d %T", &tm);
if (vlan != MAX_VLAN) {
@@ -437,7 +437,7 @@ void dl_pkt(u_char* user, const struct pcap_pkthdr* hdr, const u_char* pkt, cons
} else {
viap = "\"some interface\"";
}
- snprintf(descr, sizeof(descr), "[%zu] %s.%06ld [#%zu %s %u] \\\n",
+ snprintf(descr, sizeof(descr), "[%zu] %s.%06" PRI_tv_usec " [#%zu %s %u] \\\n",
len, when, hdr->ts.tv_usec, msgcount, viap, vlan);
} else {
descr[0] = '\0';
@@ -725,9 +725,9 @@ void network_pkt2(const char* descr, my_bpftimeval ts, const pcap_thread_packet_
tcpstate = tcpstate_find(from, to, sport, dport, ts.tv_sec);
if (dumptrace >= 3) {
- fprintf(stderr, "%s: tcp pkt: %" PRIdMAX ".%06ld [%4zu] %15s -> ",
+ fprintf(stderr, "%s: tcp pkt: %" PRI_tv_sec ".%06" PRI_tv_usec " [%4zu] %15s -> ",
ProgramName,
- (intmax_t)ts.tv_sec,
+ ts.tv_sec,
ts.tv_usec,
len,
ia_str(from));
@@ -1327,8 +1327,8 @@ void network_pkt(const char* descr, my_bpftimeval ts, unsigned pf,
tcpstate = tcpstate_find(from, to, sport, dport, ts.tv_sec);
if (dumptrace >= 3) {
- fprintf(stderr, "%s: tcp pkt: %" PRIdMAX ".%06ld [%4zu] ", ProgramName,
- (intmax_t)ts.tv_sec, ts.tv_usec, len);
+ fprintf(stderr, "%s: tcp pkt: %" PRI_tv_sec ".%06" PRI_tv_usec " [%4zu] ", ProgramName,
+ ts.tv_sec, ts.tv_usec, len);
fprintf(stderr, "%15s -> ", ia_str(from));
fprintf(stderr, "%15s; ", ia_str(to));
if (tcpstate)

791
depcomp Executable file
View file

@ -0,0 +1,791 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

541
install-sh Executable file
View file

@ -0,0 +1,541 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2020-11-14.01; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
tab=' '
nl='
'
IFS=" $tab$nl"
# Set DOITPROG to "echo" to test this script.
doit=${DOITPROG-}
doit_exec=${doit:-exec}
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_mkdir=
# Desired mode of installed file.
mode=0755
# Create dirs (including intermediate dirs) using mode 755.
# This is like GNU 'install' as of coreutils 8.32 (2020).
mkdir_umask=22
backupsuffix=
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-p pass -p to $cpprog.
-s $stripprog installed files.
-S SUFFIX attempt to back up existing files, with suffix SUFFIX.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
By default, rm is invoked with -f; when overridden with RMPROG,
it's up to you to specify -f if you want it.
If -S is not specified, no backups are attempted.
Email bug reports to bug-automake@gnu.org.
Automake home page: https://www.gnu.org/software/automake/
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-p) cpprog="$cpprog -p";;
-s) stripcmd=$stripprog;;
-S) backupsuffix="$2"
shift;;
-t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
# Don't chown directories that already exist.
if test $dstdir_status = 0; then
chowncmd=""
fi
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename.
if test -d "$dst"; then
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dstbase=`basename "$src"`
case $dst in
*/) dst=$dst$dstbase;;
*) dst=$dst/$dstbase;;
esac
dstdir_status=0
else
dstdir=`dirname "$dst"`
test -d "$dstdir"
dstdir_status=$?
fi
fi
case $dstdir in
*/) dstdirslash=$dstdir;;
*) dstdirslash=$dstdir/;;
esac
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
# The $RANDOM variable is not portable (e.g., dash). Use it
# here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap '
ret=$?
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
exit $ret
' 0
# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p'.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
oIFS=$IFS
IFS=/
set -f
set fnord $dstdir
shift
set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=${dstdirslash}_inst.$$_
rmtmp=${dstdirslash}_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask &&
{ test -z "$stripcmd" || {
# Create $dsttmp read-write so that cp doesn't create it read-only,
# which would cause strip to fail.
if test -z "$doit"; then
: >"$dsttmp" # No need to fork-exec 'touch'.
else
$doit touch "$dsttmp"
fi
}
} &&
$doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# If $backupsuffix is set, and the file being installed
# already exists, attempt a backup. Don't worry if it fails,
# e.g., if mv doesn't support -f.
if test -n "$backupsuffix" && test -f "$dst"; then
$doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
fi
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

11436
ltmain.sh Executable file

File diff suppressed because it is too large Load diff

8427
m4/libtool.m4 vendored Normal file

File diff suppressed because it is too large Load diff

437
m4/ltoptions.m4 vendored Normal file
View file

@ -0,0 +1,437 @@
# Helper functions for option handling. -*- Autoconf -*-
#
# Copyright (C) 2004-2005, 2007-2009, 2011-2019, 2021-2022 Free
# Software Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 8 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
# ------------------------------------------
m4_define([_LT_MANGLE_OPTION],
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
# ---------------------------------------
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
# saved as a flag.
m4_define([_LT_SET_OPTION],
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
_LT_MANGLE_DEFUN([$1], [$2]),
[m4_warning([Unknown $1 option '$2'])])[]dnl
])
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
# ------------------------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
m4_define([_LT_IF_OPTION],
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
# -------------------------------------------------------
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
# are set.
m4_define([_LT_UNLESS_OPTIONS],
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
[m4_define([$0_found])])])[]dnl
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
])[]dnl
])
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
# ----------------------------------------
# OPTION-LIST is a space-separated list of Libtool options associated
# with MACRO-NAME. If any OPTION has a matching handler declared with
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
# the unknown option and exit.
m4_defun([_LT_SET_OPTIONS],
[# Set options
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[_LT_SET_OPTION([$1], _LT_Option)])
m4_if([$1],[LT_INIT],[
dnl
dnl Simply set some default values (i.e off) if boolean options were not
dnl specified:
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
])
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
])
dnl
dnl If no reference was made to various pairs of opposing options, then
dnl we run the default mode handler for the pair. For example, if neither
dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
dnl archives by default:
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
[_LT_ENABLE_FAST_INSTALL])
_LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
[_LT_WITH_AIX_SONAME([aix])])
])
])# _LT_SET_OPTIONS
## --------------------------------- ##
## Macros to handle LT_INIT options. ##
## --------------------------------- ##
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
# -----------------------------------------
m4_define([_LT_MANGLE_DEFUN],
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
# -----------------------------------------------
m4_define([LT_OPTION_DEFINE],
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
])# LT_OPTION_DEFINE
# dlopen
# ------
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
])
AU_DEFUN([AC_LIBTOOL_DLOPEN],
[_LT_SET_OPTION([LT_INIT], [dlopen])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the 'dlopen' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
# win32-dll
# ---------
# Declare package support for building win32 dll's.
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
[enable_win32_dll=yes
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
;;
esac
test -z "$AS" && AS=as
_LT_DECL([], [AS], [1], [Assembler program])dnl
test -z "$DLLTOOL" && DLLTOOL=dlltool
_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
test -z "$OBJDUMP" && OBJDUMP=objdump
_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
])# win32-dll
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
_LT_SET_OPTION([LT_INIT], [win32-dll])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the 'win32-dll' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
# _LT_ENABLE_SHARED([DEFAULT])
# ----------------------------
# implement the --enable-shared flag, and supports the 'shared' and
# 'disable-shared' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_SHARED],
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([shared],
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_shared=yes ;;
no) enable_shared=no ;;
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
_LT_DECL([build_libtool_libs], [enable_shared], [0],
[Whether or not to build shared libraries])
])# _LT_ENABLE_SHARED
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
# Old names:
AC_DEFUN([AC_ENABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
])
AC_DEFUN([AC_DISABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], [disable-shared])
])
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
# _LT_ENABLE_STATIC([DEFAULT])
# ----------------------------
# implement the --enable-static flag, and support the 'static' and
# 'disable-static' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_STATIC],
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([static],
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_static=yes ;;
no) enable_static=no ;;
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
_LT_DECL([build_old_libs], [enable_static], [0],
[Whether or not to build static libraries])
])# _LT_ENABLE_STATIC
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
# Old names:
AC_DEFUN([AC_ENABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
])
AC_DEFUN([AC_DISABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], [disable-static])
])
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
# ----------------------------------
# implement the --enable-fast-install flag, and support the 'fast-install'
# and 'disable-fast-install' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_FAST_INSTALL],
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([fast-install],
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_fast_install=yes ;;
no) enable_fast_install=no ;;
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
_LT_DECL([fast_install], [enable_fast_install], [0],
[Whether or not to optimize for fast installation])dnl
])# _LT_ENABLE_FAST_INSTALL
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
# Old names:
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the 'fast-install' option into LT_INIT's first parameter.])
])
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the 'disable-fast-install' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# _LT_WITH_AIX_SONAME([DEFAULT])
# ----------------------------------
# implement the --with-aix-soname flag, and support the `aix-soname=aix'
# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'.
m4_define([_LT_WITH_AIX_SONAME],
[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
shared_archive_member_spec=
case $host,$enable_shared in
power*-*-aix[[5-9]]*,yes)
AC_MSG_CHECKING([which variant of shared library versioning to provide])
AC_ARG_WITH([aix-soname],
[AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
[shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
[case $withval in
aix|svr4|both)
;;
*)
AC_MSG_ERROR([Unknown argument to --with-aix-soname])
;;
esac
lt_cv_with_aix_soname=$with_aix_soname],
[AC_CACHE_VAL([lt_cv_with_aix_soname],
[lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
with_aix_soname=$lt_cv_with_aix_soname])
AC_MSG_RESULT([$with_aix_soname])
if test aix != "$with_aix_soname"; then
# For the AIX way of multilib, we name the shared archive member
# based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
# and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
# Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
# the AIX toolchain works better with OBJECT_MODE set (default 32).
if test 64 = "${OBJECT_MODE-32}"; then
shared_archive_member_spec=shr_64
else
shared_archive_member_spec=shr
fi
fi
;;
*)
with_aix_soname=aix
;;
esac
_LT_DECL([], [shared_archive_member_spec], [0],
[Shared archive member basename, for filename based shared library versioning on AIX])dnl
])# _LT_WITH_AIX_SONAME
LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
# _LT_WITH_PIC([MODE])
# --------------------
# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
# LT_INIT options.
# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
[lt_p=${PACKAGE-default}
case $withval in
yes|no) pic_mode=$withval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $withval; do
IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[pic_mode=m4_default([$1], [default])])
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
# Old name:
AU_DEFUN([AC_LIBTOOL_PICMODE],
[_LT_SET_OPTION([LT_INIT], [pic-only])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the 'pic-only' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
## ----------------- ##
## LTDL_INIT Options ##
## ----------------- ##
m4_define([_LTDL_MODE], [])
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
[m4_define([_LTDL_MODE], [nonrecursive])])
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
[m4_define([_LTDL_MODE], [recursive])])
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
[m4_define([_LTDL_MODE], [subproject])])
m4_define([_LTDL_TYPE], [])
LT_OPTION_DEFINE([LTDL_INIT], [installable],
[m4_define([_LTDL_TYPE], [installable])])
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
[m4_define([_LTDL_TYPE], [convenience])])

124
m4/ltsugar.m4 vendored Normal file
View file

@ -0,0 +1,124 @@
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2022 Free Software
# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 6 ltsugar.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
# lt_join(SEP, ARG1, [ARG2...])
# -----------------------------
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
# associated separator.
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
# versions in m4sugar had bugs.
m4_define([lt_join],
[m4_if([$#], [1], [],
[$#], [2], [[$2]],
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
m4_define([_lt_join],
[m4_if([$#$2], [2], [],
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
# lt_car(LIST)
# lt_cdr(LIST)
# ------------
# Manipulate m4 lists.
# These macros are necessary as long as will still need to support
# Autoconf-2.59, which quotes differently.
m4_define([lt_car], [[$1]])
m4_define([lt_cdr],
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
[$#], 1, [],
[m4_dquote(m4_shift($@))])])
m4_define([lt_unquote], $1)
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
# ------------------------------------------
# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
# Note that neither SEPARATOR nor STRING are expanded; they are appended
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
# than defined and empty).
#
# This macro is needed until we can rely on Autoconf 2.62, since earlier
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
m4_define([lt_append],
[m4_define([$1],
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
# ----------------------------------------------------------
# Produce a SEP delimited list of all paired combinations of elements of
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
# has the form PREFIXmINFIXSUFFIXn.
# Needed until we can rely on m4_combine added in Autoconf 2.62.
m4_define([lt_combine],
[m4_if(m4_eval([$# > 3]), [1],
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
[[m4_foreach([_Lt_prefix], [$2],
[m4_foreach([_Lt_suffix],
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
# -----------------------------------------------------------------------
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
m4_define([lt_if_append_uniq],
[m4_ifdef([$1],
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
[lt_append([$1], [$2], [$3])$4],
[$5])],
[lt_append([$1], [$2], [$3])$4])])
# lt_dict_add(DICT, KEY, VALUE)
# -----------------------------
m4_define([lt_dict_add],
[m4_define([$1($2)], [$3])])
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
# --------------------------------------------
m4_define([lt_dict_add_subkey],
[m4_define([$1($2:$3)], [$4])])
# lt_dict_fetch(DICT, KEY, [SUBKEY])
# ----------------------------------
m4_define([lt_dict_fetch],
[m4_ifval([$3],
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
# -----------------------------------------------------------------
m4_define([lt_if_dict_fetch],
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
[$5],
[$6])])
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
# --------------------------------------------------------------
m4_define([lt_dict_filter],
[m4_if([$5], [], [],
[lt_join(m4_quote(m4_default([$4], [[, ]])),
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
])

24
m4/ltversion.m4 vendored Normal file
View file

@ -0,0 +1,24 @@
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
# Copyright (C) 2004, 2011-2019, 2021-2022 Free Software Foundation,
# Inc.
# Written by Scott James Remnant, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# @configure_input@
# serial 4245 ltversion.m4
# This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.4.7])
m4_define([LT_PACKAGE_REVISION], [2.4.7])
AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.4.7'
macro_revision='2.4.7'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])

99
m4/lt~obsolete.m4 vendored Normal file
View file

@ -0,0 +1,99 @@
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
# Copyright (C) 2004-2005, 2007, 2009, 2011-2019, 2021-2022 Free
# Software Foundation, Inc.
# Written by Scott James Remnant, 2004.
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 5 lt~obsolete.m4
# These exist entirely to fool aclocal when bootstrapping libtool.
#
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
# which have later been changed to m4_define as they aren't part of the
# exported API, or moved to Autoconf or Automake where they belong.
#
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
# using a macro with the same name in our local m4/libtool.m4 it'll
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
# and doesn't know about Autoconf macros at all.)
#
# So we provide this file, which has a silly filename so it's always
# included after everything else. This provides aclocal with the
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
# because those macros already exist, or will be overwritten later.
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
#
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
# Yes, that means every name once taken will need to remain here until
# we give up compatibility with versions before 1.7, at which point
# we need to keep only those names which we still refer to.
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])

215
missing Executable file
View file

@ -0,0 +1,215 @@
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try '$0 --help' for more information"
exit 1
fi
case $1 in
--is-lightweight)
# Used by our autoconf macros to check whether the available missing
# script is modern enough.
exit 0
;;
--run)
# Back-compat with the calling convention used by older automake.
shift
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal autoconf autoheader autom4te automake makeinfo
bison yacc flex lex help2man
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
;;
esac
# Run the given program, remember its exit status.
"$@"; st=$?
# If it succeeded, we are done.
test $st -eq 0 && exit 0
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=https://www.perl.org/
flex_URL=https://github.com/westes/flex
gnu_software_URL=https://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
lex*|flex*)
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
help2man*)
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
;;
makeinfo*)
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
give_advice "$1" | sed -e '1s/^/WARNING: /' \
-e '2,$s/^/ /' >&2
# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

649
plugins/Makefile.in Normal file
View file

@ -0,0 +1,649 @@
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = plugins
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = \
$(top_srcdir)/src/pcap-thread/m4/ax_pcap_thread.m4 \
$(top_srcdir)/src/pcap-thread/m4/ax_pthread.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_cflags_warn_all.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
distdir distdir-am
am__extra_recursive_targets = gcov-recursive
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILECMD = @FILECMD@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
RANLIB = @RANLIB@
SECCOMPFLAGS = @SECCOMPFLAGS@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
ax_pthread_config = @ax_pthread_config@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libcrypto_CFLAGS = @libcrypto_CFLAGS@
libcrypto_LIBS = @libcrypto_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
libldns_CFLAGS = @libldns_CFLAGS@
libldns_LIBS = @libldns_LIBS@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
SUBDIRS = pcapdump rssm txtout rzkeychange royparse anonmask ipcrypt \
anonaes128 cryptopan cryptopant eventlog asudp
EXTRA_DIST = template shared
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign plugins/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign plugins/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
gcov-local:
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-recursive
dvi-am:
gcov: gcov-recursive
gcov-am: gcov-local
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-recursive
install-html-am:
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: $(am__recursive_targets) install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
check-am clean clean-generic clean-libtool cscopelist-am ctags \
ctags-am distclean distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am gcov-am gcov-local html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-am
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

File diff suppressed because it is too large Load diff

1059
plugins/anonmask/Makefile.in Normal file

File diff suppressed because it is too large Load diff

1044
plugins/asudp/Makefile.in Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

1045
plugins/eventlog/Makefile.in Normal file

File diff suppressed because it is too large Load diff

1068
plugins/ipcrypt/Makefile.in Normal file

File diff suppressed because it is too large Load diff

1044
plugins/pcapdump/Makefile.in Normal file

File diff suppressed because it is too large Load diff

View file

@ -175,10 +175,10 @@ int pcapdump_open(my_bpftimeval ts)
ts.tv_sec++; ts.tv_sec++;
ts.tv_usec -= MILLION; ts.tv_usec -= MILLION;
} }
gmtime_r(&ts.tv_sec, &tm); gmtime_r((time_t*)&ts.tv_sec, &tm);
strftime(sbuf, 64, "%Y%m%d.%H%M%S", &tm); strftime(sbuf, 64, "%Y%m%d.%H%M%S", &tm);
if (asprintf(&dumpname, "%s.%s.%06" PRI_tv_usec, if (asprintf(&dumpname, "%s.%s.%06lu",
dump_base, sbuf, ts.tv_usec) dump_base, sbuf, (u_long)ts.tv_usec)
< 0 < 0
|| asprintf(&dumpnamepart, "%s.part", dumpname) < 0) { || asprintf(&dumpnamepart, "%s.part", dumpname) < 0) {
logerr("asprintf: %s", strerror(errno)); logerr("asprintf: %s", strerror(errno));

1045
plugins/royparse/Makefile.in Normal file

File diff suppressed because it is too large Load diff

1174
plugins/rssm/Makefile.in Normal file

File diff suppressed because it is too large Load diff

View file

@ -286,7 +286,7 @@ void rssm_save_counts(const char* sbuf)
FILE* fp; FILE* fp;
int i; int i;
char* tbuf = 0; char* tbuf = 0;
i = asprintf(&tbuf, "%s.%s.%06" PRI_tv_usec, counts_prefix ? counts_prefix : COUNTS_PREFIX_DEFAULT, sbuf, open_ts.tv_usec); i = asprintf(&tbuf, "%s.%s.%06lu", counts_prefix ? counts_prefix : COUNTS_PREFIX_DEFAULT, sbuf, (u_long)open_ts.tv_usec);
if (i < 1 || !tbuf) { if (i < 1 || !tbuf) {
logerr("asprintf: out of memory"); logerr("asprintf: out of memory");
return; return;
@ -302,7 +302,7 @@ void rssm_save_counts(const char* sbuf)
char tz[21]; char tz[21];
struct tm tm; struct tm tm;
gmtime_r(&open_ts.tv_sec, &tm); gmtime_r((time_t*)&open_ts.tv_sec, &tm);
if (!strftime(tz, sizeof(tz), "%Y-%m-%dT%H:%M:%SZ", &tm)) { if (!strftime(tz, sizeof(tz), "%Y-%m-%dT%H:%M:%SZ", &tm)) {
logerr("rssm: strftime failed"); logerr("rssm: strftime failed");
fclose(fp); fclose(fp);
@ -443,8 +443,8 @@ void rssm_save_counts(const char* sbuf)
} }
} }
} else { } else {
fprintf(fp, "first-packet-time %" PRI_tv_sec "\n", open_ts.tv_sec); fprintf(fp, "first-packet-time %ld\n", (long)open_ts.tv_sec);
fprintf(fp, "last-packet-time %" PRI_tv_sec "\n", close_ts.tv_sec); fprintf(fp, "last-packet-time %ld\n", (long)close_ts.tv_sec);
fprintf(fp, "dns-udp-queries-received-ipv4 %" PRIu64 "\n", counts.dns_udp_queries_received_ipv4); fprintf(fp, "dns-udp-queries-received-ipv4 %" PRIu64 "\n", counts.dns_udp_queries_received_ipv4);
fprintf(fp, "dns-udp-queries-received-ipv6 %" PRIu64 "\n", counts.dns_udp_queries_received_ipv6); fprintf(fp, "dns-udp-queries-received-ipv6 %" PRIu64 "\n", counts.dns_udp_queries_received_ipv6);
fprintf(fp, "dns-tcp-queries-received-ipv4 %" PRIu64 "\n", counts.dns_tcp_queries_received_ipv4); fprintf(fp, "dns-tcp-queries-received-ipv4 %" PRIu64 "\n", counts.dns_tcp_queries_received_ipv4);
@ -510,7 +510,7 @@ void rssm_save_sources(const char* sbuf)
FILE* fp; FILE* fp;
char* tbuf = 0; char* tbuf = 0;
int i; int i;
i = asprintf(&tbuf, "%s.%s.%06" PRI_tv_usec, sources_prefix, sbuf, open_ts.tv_usec); i = asprintf(&tbuf, "%s.%s.%06lu", sources_prefix, sbuf, (u_long)open_ts.tv_usec);
if (i < 1 || !tbuf) { if (i < 1 || !tbuf) {
logerr("asprintf: out of memory"); logerr("asprintf: out of memory");
return; return;
@ -535,7 +535,7 @@ void rssm_save_aggregated(const char* sbuf)
FILE* fp; FILE* fp;
char* tbuf = 0; char* tbuf = 0;
int i; int i;
i = asprintf(&tbuf, "%s.%s.%06" PRI_tv_usec, aggregated_prefix, sbuf, open_ts.tv_usec); i = asprintf(&tbuf, "%s.%s.%06lu", aggregated_prefix, sbuf, (u_long)open_ts.tv_usec);
if (i < 1 || !tbuf) { if (i < 1 || !tbuf) {
logerr("asprintf: out of memory"); logerr("asprintf: out of memory");
return; return;
@ -566,7 +566,7 @@ int rssm_close(my_bpftimeval ts)
struct tm tm; struct tm tm;
if (dont_fork_on_close) { if (dont_fork_on_close) {
gmtime_r(&open_ts.tv_sec, &tm); gmtime_r((time_t*)&open_ts.tv_sec, &tm);
strftime(sbuf, sizeof(sbuf), "%Y%m%d.%H%M%S", &tm); strftime(sbuf, sizeof(sbuf), "%Y%m%d.%H%M%S", &tm);
close_ts = ts; close_ts = ts;
rssm_save_counts(sbuf); rssm_save_counts(sbuf);
@ -596,7 +596,7 @@ int rssm_close(my_bpftimeval ts)
exit(0); exit(0);
} }
/* grandchild (2nd gen) continues */ /* grandchild (2nd gen) continues */
gmtime_r(&open_ts.tv_sec, &tm); gmtime_r((time_t*)&open_ts.tv_sec, &tm);
strftime(sbuf, sizeof(sbuf), "%Y%m%d.%H%M%S", &tm); strftime(sbuf, sizeof(sbuf), "%Y%m%d.%H%M%S", &tm);
close_ts = ts; close_ts = ts;
rssm_save_counts(sbuf); rssm_save_counts(sbuf);

File diff suppressed because it is too large Load diff

View file

@ -290,8 +290,8 @@ void rzkeychange_submit_counts(void)
double elapsed = (double)clos_ts.tv_sec - (double)open_ts.tv_sec + 0.000001 * clos_ts.tv_usec - 0.000001 * open_ts.tv_usec; // NOSONAR double elapsed = (double)clos_ts.tv_sec - (double)open_ts.tv_sec + 0.000001 * clos_ts.tv_usec - 0.000001 * open_ts.tv_usec; // NOSONAR
int k; int k;
k = snprintf(qname, sizeof(qname), "%" PRI_tv_sec "-%u-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 ".%s.%s.%s", k = snprintf(qname, sizeof(qname), "%lu-%u-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 ".%s.%s.%s",
open_ts.tv_sec, (u_long)open_ts.tv_sec,
(unsigned int)(elapsed + 0.5), (unsigned int)(elapsed + 0.5),
counts.total, counts.total,
counts.dnskey, counts.dnskey,
@ -330,8 +330,8 @@ void rzkeychange_submit_counts(void)
if (*t == '.' || *t == ':') if (*t == '.' || *t == ':')
*t = '-'; *t = '-';
k = snprintf(qname, sizeof(qname), "%" PRI_tv_sec ".%s.%hhx.%s.%s.%s.%s", k = snprintf(qname, sizeof(qname), "%lu.%s.%hhx.%s.%s.%s.%s",
open_ts.tv_sec, (u_long)open_ts.tv_sec,
s, s,
key_tag_signals[i].flags, key_tag_signals[i].flags,
key_tag_signals[i].signal, key_tag_signals[i].signal,

1044
plugins/txtout/Makefile.in Normal file

File diff suppressed because it is too large Load diff

View file

@ -220,7 +220,7 @@ void txtout_output(const char* descr, iaddr from, iaddr to, uint8_t proto, unsig
/* /*
* IP Stuff * IP Stuff
*/ */
fprintf(out, "%10" PRI_tv_sec ".%06" PRI_tv_usec, ts.tv_sec, ts.tv_usec); fprintf(out, "%10ld.%06ld", (long)ts.tv_sec, (long)ts.tv_usec);
fprintf(out, " %s %u", ia_str(from), sport); fprintf(out, " %s %u", ia_str(from), sport);
fprintf(out, " %s %u", ia_str(to), dport); fprintf(out, " %s %u", ia_str(to), dport);
fprintf(out, " %hhu", proto); fprintf(out, " %hhu", proto);

View file

@ -1,756 +0,0 @@
Name: dnscap
Version: 2.3.1
Release: 1%{?dist}
Summary: Network capture utility designed specifically for DNS traffic
Group: Productivity/Networking/DNS/Utilities
License: BSD-3-Clause
URL: https://www.dns-oarc.net/tools/dnscap
# Source needs to be generated by dist-tools/create-source-packages, see
# https://github.com/jelu/dist-tools
Source0: %{name}_%{version}.orig.tar.gz
BuildRequires: libpcap-devel
BuildRequires: ldns-devel
BuildRequires: openssl-devel
BuildRequires: zlib-devel
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
BuildRequires: perl-YAML
BuildRequires: cryptopant-devel
BuildRequires: pkgconfig
%description
dnscap is a network capture utility designed specifically for DNS
traffic. It produces binary data in pcap(3) format. This utility
is similar to tcpdump(1), but has a number of features tailored
to DNS transactions and protocol options.
%prep
%setup -q -n %{name}_%{version}
%build
sh autogen.sh
%configure
%make_build
%install
%make_install
%check
%make_build test
%files
%{_bindir}/*
%{_datadir}/doc/*
%{_mandir}/man1/*
%{_libdir}/*
%changelog
* Thu Apr 24 2025 Jerry Lundström <lundstrom.jerry@gmail.com> 2.3.1-1
- Release 2.3.1
* This patch release fixes issues on 32bit systems when they are using
64bit time structures (`_TIME_BITS` set to 64) and updates pcap-thread
to require libpcap with `DLT_LINUX_SLL2` support.
* Commits:
a5e9a4a pcap-thread v4.1.1
731d9e0 Add support for 64bit time structures on 32bit systems
* Thu Apr 17 2025 Jerry Lundström <lundstrom.jerry@gmail.com> 2.3.0-1
- Release 2.3.0
* This release adds support for Linux cooked v2 link-type, a new output
format, a new plugin and fixes a couple of issues.
* The new output format `tcpdns` can be used to generate a file with the
DNS as a TCP stream, first 16bit size (network order) then the DNS
message, which is compatible with `dnsperf -B`.
* The new plugin `asudp` can be used to rewrite outgoing packet by taking
the DNS that's found and construct UDP packets from it.
* Other changes:
- Fix #314:
- man-page: Clarify that `pktsize` is shown before parsing the IP packet
- `-g`: Quote `,` characters
- Fix #316: Fix handling of L2/ethernet frames that are larger than the IPv4/v6 packet
- Fix multiple print statements w.r.t. `size_t`/`struct timeval`, `%zu`/`%ld` and type casting
- Handle extension function pointers better
- Clarify that `-C` counts uncompressed output
- Block PCAP output if TCP reassemble is used
- Increase maximum DNS messages in a reassembled TCP message
- Add new extension interface for setting output packet
- Update pcap-thread to v4.1.0
* Commits:
e689bc8 pcap-thread v4.1.0
29d184b DLT_LINUX_SLL2
ba793a9 Fixes, asudp plugin, tcpdns output format
6c133d4 Ethernet padding
420548a Diag output
8b92a52 SPEC
a3fb1dd Mailing-list
* Tue Sep 10 2024 Jerry Lundström <lundstrom.jerry@gmail.com> 2.2.1-1
- Release 2.2.1
* This patch release fixes the BPF to correct capture ICMPv6, a typo in
the filter had it matching "ip" and not "ip6".
* Other changes are updates to GitHub workflows and man-pages.
* Commits:
ea82cd1 Copyright
aa14a9f ICMP BPF filter
6ef17e2 Badges
6722677 Workflow
1cb22f0 Man-page opt, Dumper
* Wed Aug 23 2023 Jerry Lundström <lundstrom.jerry@gmail.com> 2.2.0-1
- Release 2.2.0
* This release adds anonymization of EDNS Client Subnet to all
anonymizer plugins and improves TCP state handling by adding a hash
table for lookup rather than walking a list.
* Plugins that anonymize can now take two new options:
- `-e`: also anonymize EDNS Client Subnet
- `-E`: only anonymize EDNS Client Subnet
* Other changes:
- Cleanup and improvements to building and testing
- Mention PowerTools repository for building on CentOS etc
- Remove old workarounds in tests before #133
* Commits:
d4e0b2c TCP state hash table
1ea8d3f Doc
12ea061 EDNS Client Subnet anonymization
c9ed7be pcap-dist
b76f745 Cleanup
7682d41 hashtbl
* Tue Jun 27 2023 Jerry Lundström <lundstrom.jerry@gmail.com> 2.1.3-1
- Release 2.1.3
* This release fixes a memory leak when using pattern matching options
`-x` or `-X`, the LDNS packet was not freed correctly.
* The processing of the LDNS packet during matching has also been
improved.
* Commits:
3990795 Test
ee5d554 Pattern match
* Thu Jun 15 2023 Jerry Lundström <lundstrom.jerry@gmail.com> 2.1.2-1
- Release 2.1.2
* This release fixes reusing of TCP state during an out-of-memory event,
the reused structure was not cleared of old information. And fixes
compatibility with OpenSSL v3.0+ due to deprecated functions.
* Commits:
756f78a OpenSSL 3.0+
d2bd12f tcpstate on out of memory
* Fri Feb 03 2023 Jerry Lundström <lundstrom.jerry@gmail.com> 2.1.1-1
- Release 2.1.1
* This release includes fixes to TCP state code, anonymizing plugins and
handling of EDNS extended error code.
- Ken Renards @kdrenard (PR #275) fixed handling of EDNS extended error
code, the previous code looked at `arcount` but ldns "consumes" OPT
records so the count could be zero even with existing extended error
code.
- Changed anonymizing plugins to anonymize both sending and receiving
IP address if both used the server port, part of issue #276 reported
by Duane Wessels @wessels. This fixes situations where clients
weren't anonymize because they sent using that port.
- Fixed multiple issues with garbage collection in TCP state handling.
It was reusing a pointer that was meant to return the current TCP
state so it could return the wrong state when garbage collection
was triggered.
It also just unlinked stale states and didn't free them, new code
uses the discard function so released state is also tagged as
"gc stale".
Lastly the discard function was fixed to clear the current TCP state
pointer used by plugins if the discarded state was it.
* Commits:
7f2ddcf Copyright
fd5b744 CodeQL alerts
726d241 TCP state GC
dff421e Anonymize clients
2eb8489 Add CodeQL workflow for GitHub code scanning
c5a0919 Better test for presence of EDNS option with extended error code
* Fri Sep 09 2022 Jerry Lundström <lundstrom.jerry@gmail.com> 2.1.0-1
- Release 2.1.0
* This release adds a new option (`-o pid_file=<file>`) to specify a PID
file when running as daemon, corrects handling of LDNS include files
for some plugins and updates the Root Server Scaling Measurement (RSSM)
plugin w.r.t. the upcoming version 5 of RSSAC002 specifications.
* The RSSM plugin can now optionally generate `label-count` metric. This
is enabled with `-L` and is tagged as `rssac002v5-draft` until v5 is
finalized.
The merge tool `dnscap-rssm-rssac002` has also been updated because of
this, there is now `--skip-unsupported` to skip all unsupported
RSSAC002 version metrics instead of `die()`'ing.
* Commits:
ca7707d RSSAC002v5 label-count metric
3ebee80 Made label count metric optional
41b029a Adding support for label acount metric
799c3fe Missing includes
7089f12 PID file
* Mon Jun 13 2022 Jerry Lundström <lundstrom.jerry@gmail.com> 2.0.3-1
- Release 2.0.3
* Thanks to a patch from Duane Wessels (@wessels) this release fixes
an issue with filtering where DNS messages without a question section
would bypass it.
* Commits:
ba2112c Fix COPR
0e019ab Filtering
c7e1c8f Refactor and fix qtype and qname matching/filtering.
* Tue Mar 08 2022 Jerry Lundström <lundstrom.jerry@gmail.com> 2.0.2-1
- Release 2.0.2
* Thanks to a patch from Duane Wessels (@wessels) this release fixes
memory leaks when using `-x`/`-X` regexp filtering due to incorrect
usage of LDNS library.
* Other minor changes:
- Clarify what happens if you don't specify `-i` and add information about `any` and `all`
- Update debhelper compatibility level to 10
* Commits:
a8925a7 ldns_pkt_all() clones RRs which need to be freed with ldns_rr_list_deep_free()
5104814 Doc
30c36aa debhelper
4ae4356 Bye Travis
* Thu Mar 11 2021 Jerry Lundström <lundstrom.jerry@gmail.com> 2.0.1-1
- Release 2.0.1
* Fixed incorrect line break in eventlog's (plugin) output.
* Commits:
5df363c remove trailing newline
* Fri Feb 12 2021 Jerry Lundström <lundstrom.jerry@gmail.com> 2.0.0-1
- Release 2.0.0
* This major release contains three backward incompatible changes, two
new command line options and a completely restructured man-page(!),
please read the change notes carefully before upgrading!
* The first backward incompatible change has to do with the removal of
libbind dependency. This library was causing segfaults on OpenBSD due to
shared (and overwritten) symbols with OpenBSD's libc.
It was replaced with LDNS and LDNS renders domain names as Fully
Qualified Domain Names (FQDN, the trailing dot!) so every output of a
domain name has been changed to a FQDN.
This also changes `-X`/`-x`, which will now match against FQDNs.
* The second backward incompatible change is that `-6` has been removed.
This was used to alter the BPF in order to "fix" it, dnscap adds
specific filters to IP and UDP headers which does not work for IPv6
traffic.
The generated BPF has been changed to allow IPv6 to always pass, making
the option obsolete. IPv6 filtering is then done in dnscap.
* The last backward incompatible change has to do with the output format
of `-g` related to EDNS0 and is now more consistent with the rest of
the parsable output:
- No more spaces in the output
- Fix incorrect `\` and extra empty new-line
- All EDNS0 options are added after `edns0[...]` using comma separation, example: `edns0[],edns0opt[],...`
- Client Subnet format: `edns0opt[ECS,family=nn,source=nn,scope=nn,addr=...]`
- Unknown/unsupported code: `edns0opt[code=nn,codelen=nn]`
- Parsing error messages have changed, they came from libbind, now comes from LDNS
* New options:
- Add `-q` and `-Q` to filter on matched/not matched QTYPE
* Bugfixes:
- Fix memory leak in EDNS0 ECS address parsing
- `network`: Fix sonarcloud issues, potential `memcpy()` of null pointer
* Other changes:
- Fix CBOR output inclusion, LDNS is always available now
- Add macros for Apple and Windows endian functions
- Restructure and correct the man-page
* Commits:
557e5f5 man-page
025529f v6bug, interval
37b79e9 FQDN
ebcf434 QTYPE match, args, tests
0cb5562 v6bug
75f6115 Endian
aaeb213 Sonarcloud
8685946 CBOR output
3e26802 Sonarcloud
30aa366 libbind
3f94d0b Mattermost
* Thu Oct 22 2020 Jerry Lundström <lundstrom.jerry@gmail.com> 1.12.0-1
- Release 1.12.0
* This release fixes the handling of `-?` option for dnscap and all plugins,
previously the handling varied between places and depending on `getopt()`
implementation an invalid option could return the wrong exit code.
* Other changes:
- Fix typo in configure help text
- `plugins/anonmask`: Fix typo in help text
- `plugins/rzkeychange`:
- Add `-D`, dry run mode, for testing
- Fix handling of `-a` and error on too many
* KNOWN ISSUES:
On OpenBSD the system library libc exports the same symbols as libbind
does and this causes runtime warnings. Until now this has not caused any
known problems but is now also causing segfaults if the packet filter used
(BPF) includes IPv6 addresses.
On all other platforms OARC supports, these symbols are macros and in so
should not cause any problem.
* Commits:
ee478c0 Known issues
2f9d957 Tests
3c663a2 Tests
c88efc5 rzkeychange test
f062f33 Tests
* Thu Aug 20 2020 Jerry Lundström <lundstrom.jerry@gmail.com> 1.11.1-1
- Release 1.11.1
* This release fixes a lot of issues found by code analysis, adds a
explicit memory zeroing function to remove account information (read
when dropping privileges) and adds code coverage reporting.
* The `dnscap_memzero()` will use `explicit_bzero()` on FreeBSD and
OpenBSD, or `memset_s()` (if supported), otherwise it will manually
set the memory to zero. This will hopefully ensure that the memory
is zeroed as compilers can optimize out `memset()`'s that is just
before `free()`.
* The plugins exit code for the help option `-?` has been changed to 0
to have the same as `dnscap -?`.
* Commits:
d9747ee memzero
1cf17c6 Coverage
19c7120 Coverage
7435676 Sonarcloud
928e181 Sonarcloud
ca4afd0 Sonarcloud
028f5e0 Badges
db0d6a1 LGTM
* Mon Jun 01 2020 Jerry Lundström <lundstrom.jerry@gmail.com> 1.11.0-1
- Release 1.11.0
* This release includes a new plugin called `eventlog`, contributed
by Byron Darrah (@ByronDarrah), output DNS activity as log events,
including answers to A and AAAA queries.
* Other changes includes compile warning and code analysis fixes.
* Commits:
382eac4 COPR
4c03650 Compile warn
21d6a67 Slight change -- wording now matches usage() output.
dd19b0b Added the eventlog.so plugin...
1ebf504 Added new dnscap plugin: evenlog.so...
f3f9aaa Compile warnings
* Mon Mar 02 2020 Jerry Lundström <lundstrom.jerry@gmail.com> 1.10.4-1
- Release 1.10.4
* Fixed a bug that would not drop privileges when not specifying any
interface (which is equal to capturing on all interfaces).
* Added functionality to set the supplemental groups when dropping
privileges and changing user, or clear them if that is not supported.
* Other changes includes corrected man-page about '-w' and update to
documentation.
* Commits:
a0285e4 drop privileges errors, initgroups/setgroups
96336f3 daemon: Attempt to drop supplemental groups
467a9a7 Drop privileges
de940a8 man-page -w
187ec43 README
* Wed Oct 02 2019 Jerry Lundström <lundstrom.jerry@gmail.com> 1.10.3-1
- Release 1.10.3
* Fixed plugins inclusion in deb packages for Debian and Ubuntu.
* Commits:
017ebb2 Deb packages
cf59143 COPR, spec
* Mon Aug 05 2019 Jerry Lundström <lundstrom.jerry@gmail.com> 1.10.2-1
- Release 1.10.2
* Fixed bug in the handling of defragmentation configuration which lead
to the use of a local scope variable later on and caused unexpected
behavior.
* Commits:
91692b8 Frag conf
6a74376 Package
d0d1a6d Package
* Mon Jul 08 2019 Jerry Lundström <lundstrom.jerry@gmail.com> 1.10.1-1
- Release 1.10.1
* Fix various issues found by code analysis tools, a few compiler warnings
removed, undefined bit shift behavior fixed, parameter memory leaks
plugged and documentation updates.
* Fixes:
- `dump_dns`: Remove usage of `strcpy()` and use `snprintf()` instead
of `sprintf()`
- `bpft`:
- Use `text_ptr->len` to store length of generated text
- Use `memcpy()` instead of `strcat()`
- Remove unneeded `realloc()` and `strcpy()`
- `plugins/cryptopan`: Fix strict-aliasing warnings
- `network`: Rework part of `dl_pkt()` to remove usage of `strcpy()`
and use `snprintf()` instead of `sprintf()`
- `plugins/anonaes128`: Use `a6` as dest when copying v4 addresses for
readability and code analysis
- `plugins/cryptopan`: Run first pass separate to eliminate a 32bit
shift by 32 (undefined behavior)
- `plugins/cryptopant`: Fix memory leak of `keyfile` if `-k` is
specified more then once
* Documentation:
- Update `README.md` with correction to building from git and note
about PCAP on OpenBSD
- Fix #190: Update link to `libbind` source
* Commits:
074923c Funding
5d2e84c libbind
8ee9f2a Travis-CI
6babd09 Fixes
bb2d1c7 README, compile warnings
0d9cd9c LGTM, Travis-CI
* Mon Dec 03 2018 Jerry Lundström <lundstrom.jerry@gmail.com> 1.10.0-1
- Release 1.10.0
* This release adds a new plugin type "filter" and 5 new plugins that can
do anonymization, deanonymization and masking of the IP addresses.
* New features:
- Check plugins for `pluginname_type()` which returns `enum plugin_type`,
if missing the plugin is counted as an "output" plugin
- New plugin type "filter" which calls `pluginname_filter()` prior of
outputting any data or calling of "output" plugins, if the new function
returns non-zero then the packet is filtered out (dropped)
- New extension `DNSCAP_EXT_SET_IADDR` that gives access to a function
for setting the from and to IP addresses both in the extracted data
and the wire
* New plugins:
- `anonaes128`: Anonymize IP addresses using AES128
- `anonmask`: Pseudo-anonymize IP addresses by masking them
- `cryptopan`: Anonymize IP addresses using an extension to Crypto-PAn
(College of Computing, Georgia Tech) made by David Stott (Lucent)
- `cryptopant`: Anonymize IP addresses using cryptopANT, a different
implementation of Crypto-PAn made by the ANT project at USC/ISI
- `ipcrypt`: Anonymize IP addresses using ipcrypt create by
Jean-Philippe Aumasson
* Bugfixes:
- Fix changing `royparse` and `txtout` with other plugins (thanks to
Duane Wessels and Paul Hoffman)
- Free pointers to allocated strings in `text_free()` (thanks to Michał
Kępień)
- Fix IP checksum calculation
* Other changes:
- `-B` and `-E` can be used without `-w` (thanks to Duane Wessels)
- Use `pcap_findalldevs()` instead of `pcap_lookupdev()` (thanks to
Michał Kępień)
- Document and add `-?` option to all plugins
- Fix clang `scan-build` bugs and LGTM alerts
- Use `gmtime_r()` instead of `gmtime()`
- Update `pcap-thread` to v4.0.0
* Commits:
67d8e2c Fix
fb0ed02 Plugin documentation
a2c9a6c cryptopant
39db1ca Deanonymize, IPv6 test
afc7107 Crypto-PAn, cryptopANT
f1912cc OpenSSL, anonaes128
f2bab62 ipcrypt, anonmask
158b1e7 anonmask help
60ece58 anonmask
8f1b138 Plugin types, filter plugin, set iaddr extension, anonymization
by masking
b7d7991 IP checksum
641a23a Free pointers to allocated strings in text_free()
4d313bf pcap_findalldevs()
091e0ca Use pcap_findalldevs() instead of pcap_lookupdev()
6a7b25e Clean up use of feature test macros on Linux
cbba14c Configure, uninitialized
f228c9c Code formatting
3fd738c man-page
770168a Test
714e4f5 Fix -B <begin> so that it works when reading offline pcap files.
8675bea Test
911fec9 Implementing test9 as a test of -B and -E command line args.
a7cc72d -B <begin> and -E <end> can work fine without -w <base>.
04c4928 Made the same changes to txtout as were in 165a786
165a786 Workaround for stdio mystery causing duplicate royparse output.
* Wed Feb 28 2018 Jerry Lundström <lundstrom.jerry@gmail.com> 1.9.0-1
- Release 1.9.0
* This release adds a new option to change how the Berkeley Packet Filter
is generated to include the host restrictions for all selections,
previously this restriction would only apply to specific parts.
* Additional tweaks to the RSSM plugin has been made to conform to the
RSSAC002v3 specification. One noticeable change is that the plugin now
requires the DNS to be parsed before counted, any error in the parsing
will result in the message being left out of the statistics.
* Changes:
- Fix spacing in BPF filter to look better
- Fix #146: Add `bpf_hosts_apply_all`, apply any host restriction to all
- `plugin/rssm`:
- Remove quoting of `start-period` and correctly handle empty hashes
- Issue #152, Issue #91: Parse DNS before processing RSSM counters
- `plugin/rssm/dnscap-rssm-rssac002`: Use `YAML::Dump()` for output
* Commits:
47d892b Issue #152: RSSM YAML output
d4f1466 Issue #152, Issue #91: Parse DNS before processing RSSM counters
68fc1ff BPF, `bpf_hosts_apply_all`
* Wed Feb 07 2018 Jerry Lundström <lundstrom.jerry@gmail.com> 1.8.0-1
- Release 1.8.0
* This release updates the TCP stream code in order to be able to look
at more then just the first query, for handling already ongoing TCP
connections without having seen SYN/ACK and for reassembly of the TCP
stream prior of parsing it for DNS with an additional layer of parsing
(see `reassemble_tcp_bfbparsedns`).
* Updates to the Root Server Scaling Measurement (RSSM) plugin have also
been made to bring it up to date with RSSAC002v3 specification, be
able to output the YAML format described and an additional script to
merge YAML files if the interval is less then the RSSAC002v3 24 hour
period. See "Updates to the RSSM plugin" below and
`plugins/rssm/README.md`.
* New extended options:
- `parse_ongoing_tcp`: Start tracking TCP connections even if SYN/ACK
has not been seen
- `allow_reset_tcpstate`: Allow external reset of TCP state
- `reassemble_tcp`: Use to enable TCP stream reassembly
- `reassemble_tcp_faultreset`: Number of faults before reseting TCP
state when reassembly is enabled
- `reassemble_tcp_bfbparsedns`: Enable an experimental additional layer
of reassemble that uses `libbind` to parse the payload before accepting
it. If the DNS is invalid it will move 2 bytes within the payload and
treat it as a new payload, taking the DNS length again and restart
the process. Requires `libbind` and `reassemble_tcp`.
* New extension functions for plugins:
- `DNSCAP_EXT_TCPSTATE_GETCURR`: Function to get a pointer for the
current TCP state
- `DNSCAP_EXT_TCPSTATE_RESET`: Function to reset a TCP state
* New features:
- Parse additional DNS queries in TCP connections
- `-g` and the `txtout` plugin will reset TCP state (if allowed) on
failure to parse DNS
* Bugfixes:
- Fix `-g` output, separate error message with a space
- Fix TCP packets wrongfully flagged as DNS when using layers.
- Fix TCP debug output when using layers, `ia_str()` is not safe to call
twice in the same `printf` because of local buffer.
- Fix exported extension functions, need to be file local
* New tests for:
- Multiple DNS queries in one TCP connection
- Query over TCP without SYN
- Queries over TCP with first query missing length
- Queries over TCP with middle payloads missing
- Add test with TCP stream that missing multiple packets in the middle
* Updates to the RSSM plugin (`plugins/rssm`):
- Add info about saving counts and sources
- Fix memory leak on `fopen()` errors
- Update to RSSAC002v3 specification
- New options:
- `-D` to disable forking on close
- `-Y`: Use RSSAC002v3 YAML format when writing counters, the file
will contain multiple YAML documents, one for each RSSAC002v3 metric
Used with; -S adds custom metric `dnscap-rssm-sources` and -A adds
`dnscap-rssm-aggregated-sources`
- `-n`: Set the service name to use in RSSAC002v3 YAML
- `-S`: Write source IPs into counters file with the prefix `source`
- `-A`: Write aggregated IPv6(/64) sources into counters file with
the prefix `aggregated-source`
- `-a`: Write aggregated IPv6(/64) sources to
`<name>.<timesec>.<timeusec>`
- Add `dnscap-rssm-rssac002` Perl script for merging RSSAC002v3 YAML files
- Add README.md for the plugin man-page for `dnscap-rssm-rssac002`
- Add test for YAML output and merging of YAML files
* Commits:
c7058c8 Use file local functions for all extensions
66b352d RSSM RSSAC002v3 YAML Tool
b09efc2 `plugins/rssm` RSSAC002v3
709aba6 Fix #89: Add additional reassembly layers that parses the
payload byte for byte for valid DNS
04fa013 Fix CID 1463944 (again)
b1cf623 RSSM saving data and forking
fb23305 Fix CID 1463944
0fca1a8 Issue #89: TCP stream reassemble
bb6428c CID 1463814: Check `ns_initparse()` for errors
a57066f Fix #88: TCP handling
* Wed Dec 27 2017 Jerry Lundström <lundstrom.jerry@gmail.com> 1.7.1-1
- Release 1.7.1
* The library used for parsing DNS (libbind) is unable to parse DNS
messages when there is padding at the end (the UDP/TCP payload is larger
then the DNS message). This has been fixed by trying to find the actual
DNS message size, walking all labels and RR data, and then retry parsing.
* Other changes and bug-fixes:
- Fix size when there is a VLAN to match output of `use_layers` yes/no
- Add test of VLAN matching
- Fix `hashtbl.c` building in `rssm`
- Add test with padded DNS message
* Commits:
49e5400 Fix #127: If `ns_initparse()` returns `EMSGSIZE`, try and get
actual size and reparse
99bda0b Fix #98: VLAN
* Tue Dec 19 2017 Jerry Lundström <lundstrom.jerry@gmail.com> 1.7.0-1
- Release 1.7.0
* This release adds IP fragmentation handling by using layers in pcap-thread
which also adds a new flag to output and modules. `DNSCAP_OUTPUT_ISLAYER`
indicates that `pkt_copy` is equal to `payload` since the layers of the
traffic have already been parsed. IP fragments are reassembled with the
`pcap_thread_ext_frag` extension that is included in pcap-thread.
* New extended (`-o`) options:
- `use_layers`: Use pcap-thread layers to handle the traffic
- `defrag_ipv4`: Enabled IPv4 de-fragmentation
- `defrag_ipv6`: Enabled IPv6 de-fragmentation
- `max_ipv4_fragments`: Set maximum fragmented IPv4 packets to track
- `max_ipv4_fragments_per_packet`: Set the maximum IPv4 fragments per
tracked packet
- `max_ipv6_fragments`: Set maximum fragmented IPv6 packets to track
- `max_ipv6_fragments_per_packet`: Set the maximum IPv6 fragments per
tracked packet
* Currently `-w` does not work with `use_layers` and the plugins `pcapdump`
and `royparse` will discard output with the flag `DNSCAP_OUTPUT_ISLAYER`
because they need access to the original packet.
* The `rzkeychange` plugin now encodes certain flag bits in the data that
it reports for RFC8145 key tag signaling. The flags of interest are:
`DO`, `CD`, and `RD`. These are encoded in an bit-mask as a hexadecimal
value before the `_ta` component of the query name.
* Other changes and bug-fixes:
- Fix #115: document `-g` output, see `OUTPUT FORMATS` `diagnostic` in
`dnscap(1)` man-page
- Add test to match output from non-layers runs with those using layers
- Add test with fragmented DNS queries
- Fix #120: CBOR/CDS compiles again, update tinycbor to v0.4.2
- Fix `ip->ip_len` byte order
- Fix parsing of IP packets with padding or missing parts of payload
* Commits:
0347f74 Add AUTHORS section in man-page
ef1b68c Fix CID 1463073
8a79f89 Layers
a404d08 Update pcap-thread to v3.1.0, add test for padding fixes
08402f1 Fix byte order bug. ip->ip_len must be evaluated with ntohs().
d6d2340 CBOR/CDS and formatting
85ec2d8 Fix #87: IP fragmentation reassembly
22bfd4a Documentation
c35f19f Adding flag bits to rzkeychange RFC8145 key tag signaling data.
This may be useful to find "false" key tag signals from sources
that don't actually perform DNSSEC validation.
* Fri Dec 01 2017 Jerry Lundström <lundstrom.jerry@gmail.com> 1.6.0-1
- Release 1.6.0
* New additions to the plugins:
- `rzkeychange` can now collect RFC8145 key tag signaling. Signals are
saved during the collection interval, and then sent to the specified
`-k <zone>`, one at a time, at the end of the interval. Only root zone
signals are collected. Added by Duane Wessels (@wessels).
- `royparse` is a new plugin to splits a PCAP into two streams, queries
in PCAP format and responses in ASCII format. Created by Roy Arends
(@RoyArends).
- `txtout` new option `-s` for short output, only print QTYPE and QNAME
for IN records. Added by Paul Hoffman (@paulehoffman)
- The extension interface has been extended with `DNSCAP_EXT_IA_STR` to
export the `ia_str()` function.
* Bugfixes and other changes:
- Remove duplicated hashtbl code
- `rssm`: fix bug where count in table was taken out as `uint16_t` but
was a `uint64_t`
- Handle return values from hashtbl functions
- `txtout`: removed unused `-f` options
- Change `ia_str()` to use buffers with correct sizes, thanks to
@RoyArends for spotting this!
* Commits:
3f78a31 Add copy/author text
1bd914d Fix CID 1462343, 1462344, 1462345
f9bb955 Fix `fprintf()` format for message size
abedf84 Fix #105: `inet_ntop` buffers
bfdcd0d Addresses the suggestions from Jerry.
dda0996 royparse :)
4f6520a royparse plugin finished
f1aa4f2 Fix #103: Remove `opt_f`
32355b7 Rearrange code to keep the change smaller and fix indentation
d6612c1 Added -s to txtout for short output
9d8d1ef Check return of `snprintf()`
55f5aba Format code
9f19ec3 Fixed memory leak in rzkeychange_keytagsignal()
58b8784 Fix memory leaks and better return value checks in
rzkeychange_submit_counts()
b06659f Add server and node to keytag signal query name
705a866 Always free response packets in rzkeychange plugin.
e802843 Implement RFC8145 key tag signal collection in rzkeychange plugin
5fbf6d0 Added extension for ia_str() so it can be used by rzkeychange
plugin.
3be8b8f Split `dnscap.c` into more files
e431d14 Fix #92: hashtbl
* Mon Aug 21 2017 Jerry Lundström <lundstrom.jerry@gmail.com> 1.5.1-1
- Release 1.5.1
* Compatibility fixes for FreeBSD 11.1+ which is now packing `struct ip`
and for OpenBSD.
* Commits:
17e3c92 FreeBSD is packing `struct ip`, need to `memcpy()`
f8add66 Code formatting
38cd585 Add documentation about libbind
d1dd55b Fix #82: Update dependencies for OpenBSD
* Tue Jun 06 2017 Jerry Lundström <lundstrom.jerry@gmail.com> 1.5.0-1
- Release 1.5.0
* Added support for writing gzipped PCAP if the `-W` suffix ends with
`.gz` and made `-X` work without `-x`. New inteface for plugins to
tell them what extensions are available and a new plugin `rzkeychange`.
* Plugin extensions:
- Call `plugin_extension(ext, arg)` to tell plugin what extensions exists
- Add extension for checking responder (`is_responder()`)
* The rzkeychange plugin was developed by Duane Wessels 2016 in support
of the root zone ZSK size increase. It is also being used in support of
the 2017 root KSK rollover and collects the following measurements:
- total number of responses sent
- number of responses with TC bit set
- number of responses over TCP
- number of DNSKEY responses
- number of ICMP_UNREACH_NEEDFRAG messages received
- number of ICMP_TIMXCEED_INTRANS messages received
- number of ICMP_TIMXCEED_REASS messages received
* Other fixes (author Duane Wessels):
- 232cbd0: Correct comment description for meaning of IPPROTO_AH
- 181eaa4: Add #include <sys/time.h> for struct timeval on NetBSD
* Commits:
1d894e2 Make -x and -X work correctly together and update man-page
34bc54c Make the -X option work without requiring a -x option.
f43222e Fix CID 1440488, 1440489, 1440490
aa54395 Update pcap-thread to v2.1.3
81174ce Prepare SPEC for OSB/COPR
21d7468 New plugin rzkeychange and plugin extensions
38491a3 Config header is generated by autotools
419a8ab Small tweaks and fixes for gzip support
1967abc updated for earlier BSD versions
f135c90 added auto gzip if the -W suffix ends with .gz
* Commits during development of rzkeychange (author Duane Wessels):
- 620828d: Add rzkeychange -z option to specify resolver IP addresses
- 1f77987: Add -p and -t options to rzkeychange plugin to configure an
alternate port and TCP. Useful for ssh tunnels.
- 2a571f1: Split ICMP time exceeded counter into two counters for time
exceeded due to TTL and another due to fragmentation
- e4ee2d3: The rzkeychange data collection plugin uses
`DNSCAP_EXT_IS_RESPONDER` extension to know if an IP address is a
"responder" or not, because when dnscap is instructed to collect ICMP
with -I, it processes all ICMP packets, not just those limited to
responders (or initiators).
- cee16b8: Add ICMP Time Exceeded to counters
- ad8a227: Counting source IPs has performance impacts. #ifdef'd out for
now add ICMP "frag needed" counts
- c25e72b: Implemented DNS queries with ldns. First there will be some
test queries to ensure the zone is reachable and configured to receive
data. Then a query naming the fields, followed by the periodic queries
delivering counts.
- fd23be7: Make report zone, server, node command line argumements mandatory
- 137789b: Adding rzkeychange plugin files
* Wed Mar 29 2017 Jerry Lundström <lundstrom.jerry@gmail.com> 1.4.1-1
- Release 1.4.1
* Fixed an issue that when compiled with libpcap that had a specific
feature enabled it would result in a runtime error which could not be
worked around.
* Also fixed various compatibility issues and updated dependency
documentation for CentOS.
* Commits:
785d4c4 Fix compiler warnings
2d4df8d Fix #65: Update pcap-thread to v2.1.2
26d3fbc Fix #64: Add missing dependency
55e6741 Update pcap-thread to v2.1.1, fix issue with libpcap timestamp
type
c6fdb7a Fix typo and remove unused variables
* Mon Feb 27 2017 Jerry Lundström <lundstrom.jerry@gmail.com> 1.4.0-1
- Release 1.4.0
* Until it can be confirmed that the threaded code works as well as the
non-threaded code it has been made optional and requires a configuration
option to enable it during compilation.
* New extended option:
- `-o pcap_buffer_size=<bytes>` can be used to increase the capture
buffer within pcap-thread/libpcap, this can help mitigate dropped
packets by the kernel during breaks (like when closing dump file).
* Commits:
1c6fbb2 Update copyright year
63ef665 Suppress OpenBSD warnings about symbols
2c99946 pcap-thread v2.0.0, disable threads, errors handling
4cade97 Fix #56: Update pcap-thread to v1.2.2 and add test
* Fri Dec 23 2016 Jerry Lundström <lundstrom.jerry@gmail.com> 1.3.0-1
- Release 1.3.0
* Rare lockup has been fixed that could happen if a signal was received
in the wrong thread at the wrong time due to `pcap_thread_stop()`
canceling and waiting on threads to join again. The handling of signals
have been improved for threaded and non-threaded operations.
* New features:
- Experimental CBOR DNS Stream format output, see `CBOR_DNS_STREAM.md`
- Extended options to specify user and group to use when dropping
privileges, see EXTENDED OPTIONS in man-page
* Commits:
a5fa14e Signal and threads
3868104 Use old style C comments
7946be5 Clarify building
d5463b4 RPM spec and various automake fixes
df206bf Resource data indexing and documentation
0e2d0fe Fix #22, fix #43: Update README
5921d73 Add stream option RLABELS and RLABEL_MIN_SIZE
6dd6ec1 Implement experimental CBOR DNS Stream Format
4baf695 Fix #37: Extended options to specifty user/group to use when
dropping privileges
61d830a Fix #35: Use `AC_HEADER_TIME` and fix warning
* Thu Dec 15 2016 Jerry Lundström <lundstrom.jerry@gmail.com> 1.2.0-1
- Initial package

View file

@ -1 +0,0 @@
sonar.coverage.exclusions=src/hashtbl.c, src/dump_cbor.c, src/dump_cds.c, src/assert.c

1024
src/Makefile.in Normal file

File diff suppressed because it is too large Load diff

246
src/config.h.in Normal file
View file

@ -0,0 +1,246 @@
/* src/config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */
#undef HAVE_ARPA_NAMESER_COMPAT_H
/* Define to 1 if you have the <arpa/nameser.h> header file. */
#undef HAVE_ARPA_NAMESER_H
/* Define to 1 if you have the <cbor/cbor.h> header file. */
#undef HAVE_CBOR_CBOR_H
/* Define to 1 if you have the <cbor.h> header file. */
#undef HAVE_CBOR_H
/* Define to 1 if you have the <cryptopANT.h> header file. */
#undef HAVE_CRYPTOPANT_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <endian.h> header file. */
#undef HAVE_ENDIAN_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `fopencookie' function. */
#undef HAVE_FOPENCOOKIE
/* Define to 1 if you have the `funopen' function. */
#undef HAVE_FUNOPEN
/* Define to 1 if you have the `gzopen' function. */
#undef HAVE_GZOPEN
/* Define to 1 if you have the `initgroups' function. */
#undef HAVE_INITGROUPS
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <ldns/ldns.h> header file. */
#undef HAVE_LDNS_LDNS_H
/* Define to 1 if you have libcrypto. */
#undef HAVE_LIBCRYPTO
/* Define to 1 if you have the `cryptopANT' library (-lcryptopANT). */
#undef HAVE_LIBCRYPTOPANT
/* Define to 1 if you have the `dl' library (-ldl). */
#undef HAVE_LIBDL
/* Define to 1 if you have the `hplx' library (-lhplx). */
#undef HAVE_LIBHPLX
/* Define to 1 if you have the `md5' library (-lmd5). */
#undef HAVE_LIBMD5
/* Define to 1 if you have the `nsl' library (-lnsl). */
#undef HAVE_LIBNSL
/* Define to 1 if you have the `pcap' library (-lpcap). */
#undef HAVE_LIBPCAP
/* Define to 1 if you have the `rt' library (-lrt). */
#undef HAVE_LIBRT
/* Define to 1 if you have the `socket' library (-lsocket). */
#undef HAVE_LIBSOCKET
/* Define to 1 if you have the `tinycbor' library (-ltinycbor). */
#undef HAVE_LIBTINYCBOR
/* Define to 1 if you have the `z' library (-lz). */
#undef HAVE_LIBZ
/* Define to 1 if you have the <machine/endian.h> header file. */
#undef HAVE_MACHINE_ENDIAN_H
/* Define to 1 if you have the <netdb.h> header file. */
#undef HAVE_NETDB_H
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define to 1 if you have the <openssl/conf.h> header file. */
#undef HAVE_OPENSSL_CONF_H
/* Define to 1 if you have the <openssl/err.h> header file. */
#undef HAVE_OPENSSL_ERR_H
/* Define to 1 if you have the <openssl/evp.h> header file. */
#undef HAVE_OPENSSL_EVP_H
/* Define to 1 if you have the `pcap_activate' function. */
#undef HAVE_PCAP_ACTIVATE
/* Define to 1 if you have the `pcap_create' function. */
#undef HAVE_PCAP_CREATE
/* Define to 1 if the system has the type `pcap_direction_t'. */
#undef HAVE_PCAP_DIRECTION_T
/* Define to 1 if you have the `pcap_open_offline_with_tstamp_precision'
function. */
#undef HAVE_PCAP_OPEN_OFFLINE_WITH_TSTAMP_PRECISION
/* Define to 1 if you have the `pcap_setdirection' function. */
#undef HAVE_PCAP_SETDIRECTION
/* Define to 1 if you have the `pcap_set_immediate_mode' function. */
#undef HAVE_PCAP_SET_IMMEDIATE_MODE
/* Define to 1 if you have the `pcap_set_tstamp_precision' function. */
#undef HAVE_PCAP_SET_TSTAMP_PRECISION
/* Define to 1 if you have the `pcap_set_tstamp_type' function. */
#undef HAVE_PCAP_SET_TSTAMP_TYPE
/* Define if you have POSIX threads libraries and header files. */
#undef HAVE_PTHREAD
/* Have PTHREAD_PRIO_INHERIT. */
#undef HAVE_PTHREAD_PRIO_INHERIT
/* Define to 1 if you have the <resolv.h> header file. */
#undef HAVE_RESOLV_H
/* Define to 1 if you have the `sched_yield' function. */
#undef HAVE_SCHED_YIELD
/* Define to 1 if you have the `setegid' function. */
#undef HAVE_SETEGID
/* Define to 1 if you have the `seteuid' function. */
#undef HAVE_SETEUID
/* Define to 1 if you have the `setgroups' function. */
#undef HAVE_SETGROUPS
/* Define to 1 if you have the `setregid' function. */
#undef HAVE_SETREGID
/* Define to 1 if you have the `setresgid' function. */
#undef HAVE_SETRESGID
/* Define to 1 if you have the `setresuid' function. */
#undef HAVE_SETRESUID
/* Define to 1 if you have the `setreuid' function. */
#undef HAVE_SETREUID
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/endian.h> header file. */
#undef HAVE_SYS_ENDIAN_H
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H
/* Define to 1 if you have the `__assertion_failed' function. */
#undef HAVE___ASSERTION_FAILED
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
#undef PTHREAD_CREATE_JOINABLE
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. This
macro is obsolete. */
#undef TIME_WITH_SYS_TIME
/* Define this to enable Linux seccomp-bpf sandbox. */
#undef USE_SECCOMP
/* Version number of package */
#undef VERSION

View file

@ -143,8 +143,8 @@ int main(int argc, char* argv[])
struct tm tm; struct tm tm;
gmtime_r(&start_time, &tm); gmtime_r(&start_time, &tm);
strftime(when, sizeof when, "%F %T", &tm); strftime(when, sizeof when, "%F %T", &tm);
fprintf(stderr, "Sleeping for %" PRI_tv_sec " seconds until %s UTC\n", fprintf(stderr, "Sleeping for %d seconds until %s UTC\n",
start_time - now.tv_sec, when); (int)(start_time - now.tv_sec), when);
sleep(start_time - now.tv_sec); sleep(start_time - now.tv_sec);
fprintf(stderr, "Awake.\n"); fprintf(stderr, "Awake.\n");
} }

View file

@ -49,21 +49,6 @@
#endif #endif
#endif #endif
/* Macros for printing timeval */
#include <inttypes.h>
#if _TIME_BITS == 64
#define PRI_tv_sec PRId64
#define PRI_tv_usec PRId64
#else
#ifdef __OpenBSD__
#define PRI_tv_sec PRId64
#define PRI_tv_usec "ld"
#else
#define PRI_tv_sec "ld"
#define PRI_tv_usec "ld"
#endif
#endif
/* /*
* setup MY_BPFTIMEVAL as the timeval structure that bpf packets * setup MY_BPFTIMEVAL as the timeval structure that bpf packets
* will be assoicated with packets from libpcap * will be assoicated with packets from libpcap

View file

@ -198,7 +198,7 @@ int dumper_open(my_bpftimeval ts)
gmtime_r((time_t*)&ts.tv_sec, &tm); gmtime_r((time_t*)&ts.tv_sec, &tm);
strftime(sbuf, 64, "%Y%m%d.%H%M%S", &tm); strftime(sbuf, 64, "%Y%m%d.%H%M%S", &tm);
if (asprintf(&dumpname, "%s.%s.%06" PRI_tv_usec "%s", if (asprintf(&dumpname, "%s.%s.%06ld%s",
dump_base, sbuf, dump_base, sbuf,
ts.tv_usec, dump_suffix ? dump_suffix : "") ts.tv_usec, dump_suffix ? dump_suffix : "")
< 0 < 0

View file

@ -192,7 +192,7 @@ void layer_pkt(u_char* user, const pcap_thread_packet_t* packet, const u_char* p
break; break;
} }
t = firstpkt->pkthdr.ts.tv_sec; t = (time_t)firstpkt->pkthdr.ts.tv_sec;
gmtime_r(&t, &tm); gmtime_r(&t, &tm);
strftime(when, sizeof(when), "%Y-%m-%d %T", &tm); strftime(when, sizeof(when), "%Y-%m-%d %T", &tm);
@ -207,7 +207,7 @@ void layer_pkt(u_char* user, const pcap_thread_packet_t* packet, const u_char* p
} }
if (vlan != MAX_VLAN) { if (vlan != MAX_VLAN) {
snprintf(descr, sizeof(descr), "[%zu] %s.%06" PRI_tv_usec " [#%zd %s (vlan %u) %u] \\\n", snprintf(descr, sizeof(descr), "[%zu] %s.%06ld [#%zd %s (vlan %u) %u] \\\n",
len, len,
when, when,
firstpkt->pkthdr.ts.tv_usec, firstpkt->pkthdr.ts.tv_usec,
@ -216,7 +216,7 @@ void layer_pkt(u_char* user, const pcap_thread_packet_t* packet, const u_char* p
vlan, vlan,
vlan); vlan);
} else { } else {
snprintf(descr, sizeof(descr), "[%zu] %s.%06" PRI_tv_usec " [#%zd %s %u] \\\n", snprintf(descr, sizeof(descr), "[%zu] %s.%06ld [#%zd %s %u] \\\n",
len, len,
when, when,
firstpkt->pkthdr.ts.tv_usec, firstpkt->pkthdr.ts.tv_usec,
@ -426,7 +426,7 @@ void dl_pkt(u_char* user, const struct pcap_pkthdr* hdr, const u_char* pkt, cons
struct tm tm; struct tm tm;
time_t t; time_t t;
t = hdr->ts.tv_sec; t = (time_t)hdr->ts.tv_sec;
gmtime_r(&t, &tm); gmtime_r(&t, &tm);
strftime(when, sizeof when, "%Y-%m-%d %T", &tm); strftime(when, sizeof when, "%Y-%m-%d %T", &tm);
if (vlan != MAX_VLAN) { if (vlan != MAX_VLAN) {
@ -437,7 +437,7 @@ void dl_pkt(u_char* user, const struct pcap_pkthdr* hdr, const u_char* pkt, cons
} else { } else {
viap = "\"some interface\""; viap = "\"some interface\"";
} }
snprintf(descr, sizeof(descr), "[%zu] %s.%06" PRI_tv_usec " [#%zu %s %u] \\\n", snprintf(descr, sizeof(descr), "[%zu] %s.%06ld [#%zu %s %u] \\\n",
len, when, hdr->ts.tv_usec, msgcount, viap, vlan); len, when, hdr->ts.tv_usec, msgcount, viap, vlan);
} else { } else {
descr[0] = '\0'; descr[0] = '\0';
@ -725,9 +725,9 @@ void network_pkt2(const char* descr, my_bpftimeval ts, const pcap_thread_packet_
tcpstate = tcpstate_find(from, to, sport, dport, ts.tv_sec); tcpstate = tcpstate_find(from, to, sport, dport, ts.tv_sec);
if (dumptrace >= 3) { if (dumptrace >= 3) {
fprintf(stderr, "%s: tcp pkt: %" PRI_tv_sec ".%06" PRI_tv_usec " [%4zu] %15s -> ", fprintf(stderr, "%s: tcp pkt: %" PRIdMAX ".%06ld [%4zu] %15s -> ",
ProgramName, ProgramName,
ts.tv_sec, (intmax_t)ts.tv_sec,
ts.tv_usec, ts.tv_usec,
len, len,
ia_str(from)); ia_str(from));
@ -1327,8 +1327,8 @@ void network_pkt(const char* descr, my_bpftimeval ts, unsigned pf,
tcpstate = tcpstate_find(from, to, sport, dport, ts.tv_sec); tcpstate = tcpstate_find(from, to, sport, dport, ts.tv_sec);
if (dumptrace >= 3) { if (dumptrace >= 3) {
fprintf(stderr, "%s: tcp pkt: %" PRI_tv_sec ".%06" PRI_tv_usec " [%4zu] ", ProgramName, fprintf(stderr, "%s: tcp pkt: %" PRIdMAX ".%06ld [%4zu] ", ProgramName,
ts.tv_sec, ts.tv_usec, len); (intmax_t)ts.tv_sec, ts.tv_usec, len);
fprintf(stderr, "%15s -> ", ia_str(from)); fprintf(stderr, "%15s -> ", ia_str(from));
fprintf(stderr, "%15s; ", ia_str(to)); fprintf(stderr, "%15s; ", ia_str(to));
if (tcpstate) if (tcpstate)

View file

@ -0,0 +1,15 @@
AC_DEFUN([AX_PCAP_THREAD_PCAP], [
AC_HEADER_TIME
AC_CHECK_LIB([pcap], [pcap_open_live], [], AC_MSG_ERROR([libpcap not found]))
AC_CHECK_HEADER([pcap/pcap.h], [], [AC_MSG_ERROR([libpcap header not found])])
AC_CHECK_HEADERS([endian.h sys/endian.h machine/endian.h sys/time.h])
AC_CHECK_FUNCS([pcap_create pcap_set_tstamp_precision pcap_set_immediate_mode])
AC_CHECK_FUNCS([pcap_set_tstamp_type pcap_setdirection sched_yield])
AC_CHECK_FUNCS([pcap_open_offline_with_tstamp_precision pcap_activate])
AC_CHECK_TYPES([pcap_direction_t], [], [], [[#include <pcap/pcap.h>]])
])
AC_DEFUN([AX_PCAP_THREAD], [
AX_PTHREAD
AX_PCAP_THREAD_PCAP
])

View file

@ -0,0 +1,485 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_pthread.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro figures out how to build C programs using POSIX threads. It
# sets the PTHREAD_LIBS output variable to the threads library and linker
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
# flags that are needed. (The user can also force certain compiler
# flags/libs to be tested by setting these environment variables.)
#
# Also sets PTHREAD_CC to any special C compiler that is needed for
# multi-threaded programs (defaults to the value of CC otherwise). (This
# is necessary on AIX to use the special cc_r compiler alias.)
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also to link with them as well. For example, you might link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
#
# If you are only building threaded programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC:
#
# LIBS="$PTHREAD_LIBS $LIBS"
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# CC="$PTHREAD_CC"
#
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
#
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
# PTHREAD_CFLAGS.
#
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
# is not found. If ACTION-IF-FOUND is not specified, the default action
# will define HAVE_PTHREAD.
#
# Please let the authors know if this macro fails on any platform, or if
# you have any other suggestions or comments. This macro was based on work
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
# grateful for the helpful feedback of numerous users.
#
# Updated for Autoconf 2.68 by Daniel Richard G.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 23
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_SED])
AC_LANG_PUSH([C])
ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on Tru64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
ax_pthread_save_CC="$CC"
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
AC_MSG_RESULT([$ax_pthread_ok])
if test "x$ax_pthread_ok" = "xno"; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
CC="$ax_pthread_save_CC"
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
# (Note: HP C rejects this with "bad form for `-t' option")
# -pthreads: Solaris/gcc (Note: HP C also rejects)
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads and
# -D_REENTRANT too), HP C (must be checked before -lpthread, which
# is present but should not be used directly; and before -mthreads,
# because the compiler interprets this as "-mt" + "-hreads")
# -mthreads: Mingw32/gcc, Lynx/gcc
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case $host_os in
freebsd*)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
ax_pthread_flags="-kthread lthread $ax_pthread_flags"
;;
hpux*)
# From the cc(1) man page: "[-mt] Sets various -D flags to enable
# multi-threading and also sets -lpthread."
ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
;;
openedition*)
# IBM z/OS requires a feature-test macro to be defined in order to
# enable POSIX threads at all, so give the user a hint if this is
# not set. (We don't define these ourselves, as they can affect
# other portions of the system API in unpredictable ways.)
AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
[
# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
AX_PTHREAD_ZOS_MISSING
# endif
],
[AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
;;
solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (N.B.: The stubs are missing
# pthread_cleanup_push, or rather a function called by this macro,
# so we could check for that, but who knows whether they'll stub
# that too in a future libc.) So we'll check first for the
# standard Solaris way of linking pthreads (-mt -lpthread).
ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags"
;;
esac
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
AS_IF([test "x$GCC" = "xyes"],
[ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"])
# The presence of a feature test macro requesting re-entrant function
# definitions is, on some systems, a strong hint that pthreads support is
# correctly enabled
case $host_os in
darwin* | hpux* | linux* | osf* | solaris*)
ax_pthread_check_macro="_REENTRANT"
;;
aix*)
ax_pthread_check_macro="_THREAD_SAFE"
;;
*)
ax_pthread_check_macro="--"
;;
esac
AS_IF([test "x$ax_pthread_check_macro" = "x--"],
[ax_pthread_check_cond=0],
[ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
# Are we compiling with Clang?
AC_CACHE_CHECK([whether $CC is Clang],
[ax_cv_PTHREAD_CLANG],
[ax_cv_PTHREAD_CLANG=no
# Note that Autoconf sets GCC=yes for Clang as well as GCC
if test "x$GCC" = "xyes"; then
AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
[/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
# if defined(__clang__) && defined(__llvm__)
AX_PTHREAD_CC_IS_CLANG
# endif
],
[ax_cv_PTHREAD_CLANG=yes])
fi
])
ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
ax_pthread_clang_warning=no
# Clang needs special handling, because older versions handle the -pthread
# option in a rather... idiosyncratic way
if test "x$ax_pthread_clang" = "xyes"; then
# Clang takes -pthread; it has never supported any other flag
# (Note 1: This will need to be revisited if a system that Clang
# supports has POSIX threads in a separate library. This tends not
# to be the way of modern systems, but it's conceivable.)
# (Note 2: On some systems, notably Darwin, -pthread is not needed
# to get POSIX threads support; the API is always present and
# active. We could reasonably leave PTHREAD_CFLAGS empty. But
# -pthread does define _REENTRANT, and while the Darwin headers
# ignore this macro, third-party headers might not.)
PTHREAD_CFLAGS="-pthread"
PTHREAD_LIBS=
ax_pthread_ok=yes
# However, older versions of Clang make a point of warning the user
# that, in an invocation where only linking and no compilation is
# taking place, the -pthread option has no effect ("argument unused
# during compilation"). They expect -pthread to be passed in only
# when source code is being compiled.
#
# Problem is, this is at odds with the way Automake and most other
# C build frameworks function, which is that the same flags used in
# compilation (CFLAGS) are also used in linking. Many systems
# supported by AX_PTHREAD require exactly this for POSIX threads
# support, and in fact it is often not straightforward to specify a
# flag that is used only in the compilation phase and not in
# linking. Such a scenario is extremely rare in practice.
#
# Even though use of the -pthread flag in linking would only print
# a warning, this can be a nuisance for well-run software projects
# that build with -Werror. So if the active version of Clang has
# this misfeature, we search for an option to squash it.
AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
# Create an alternate version of $ac_link that compiles and
# links in two steps (.c -> .o, .o -> exe) instead of one
# (.c -> exe), because the warning occurs only in the second
# step
ax_pthread_save_ac_link="$ac_link"
ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
ax_pthread_save_CFLAGS="$CFLAGS"
for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
ac_link="$ax_pthread_save_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[ac_link="$ax_pthread_2step_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[break])
])
done
ac_link="$ax_pthread_save_ac_link"
CFLAGS="$ax_pthread_save_CFLAGS"
AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
])
case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
no | unknown) ;;
*) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
esac
fi # $ax_pthread_clang = yes
if test "x$ax_pthread_ok" = "xno"; then
for ax_pthread_try_flag in $ax_pthread_flags; do
case $ax_pthread_try_flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
-mt,pthread)
AC_MSG_CHECKING([whether pthreads work with -mt -lpthread])
PTHREAD_CFLAGS="-mt"
PTHREAD_LIBS="-lpthread"
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
PTHREAD_CFLAGS="$ax_pthread_try_flag"
;;
pthread-config)
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
PTHREAD_LIBS="-l$ax_pthread_try_flag"
;;
esac
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
# if $ax_pthread_check_cond
# error "$ax_pthread_check_macro must be defined"
# endif
static void routine(void *a) { a = 0; }
static void *start_routine(void *a) { return a; }],
[pthread_t th; pthread_attr_t attr;
pthread_create(&th, 0, start_routine, 0);
pthread_join(th, 0);
pthread_attr_init(&attr);
pthread_cleanup_push(routine, 0);
pthread_cleanup_pop(0) /* ; */])],
[ax_pthread_ok=yes],
[])
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
AC_MSG_RESULT([$ax_pthread_ok])
AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Various other checks:
if test "x$ax_pthread_ok" = "xyes"; then
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_CACHE_CHECK([for joinable pthread attribute],
[ax_cv_PTHREAD_JOINABLE_ATTR],
[ax_cv_PTHREAD_JOINABLE_ATTR=unknown
for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[int attr = $ax_pthread_attr; return attr /* ; */])],
[ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
[])
done
])
AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
test "x$ax_pthread_joinable_attr_defined" != "xyes"],
[AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
[$ax_cv_PTHREAD_JOINABLE_ATTR],
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
ax_pthread_joinable_attr_defined=yes
])
AC_CACHE_CHECK([whether more special flags are required for pthreads],
[ax_cv_PTHREAD_SPECIAL_FLAGS],
[ax_cv_PTHREAD_SPECIAL_FLAGS=no
case $host_os in
solaris*)
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
;;
esac
])
AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
test "x$ax_pthread_special_flags_added" != "xyes"],
[PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
ax_pthread_special_flags_added=yes])
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
[ax_cv_PTHREAD_PRIO_INHERIT],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
[[int i = PTHREAD_PRIO_INHERIT;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no])
])
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
test "x$ax_pthread_prio_inherit_defined" != "xyes"],
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
ax_pthread_prio_inherit_defined=yes
])
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
# More AIX lossage: compile with *_r variant
if test "x$GCC" != "xyes"; then
case $host_os in
aix*)
AS_CASE(["x/$CC"],
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
[#handle absolute path differently from PATH based program lookup
AS_CASE(["x$CC"],
[x/*],
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
;;
esac
fi
fi
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
AC_SUBST([PTHREAD_LIBS])
AC_SUBST([PTHREAD_CFLAGS])
AC_SUBST([PTHREAD_CC])
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test "x$ax_pthread_ok" = "xyes"; then
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
:
else
ax_pthread_ok=no
$2
fi
AC_LANG_POP
])dnl AX_PTHREAD

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,658 @@
/*
* Author Jerry Lundström <jerry@dns-oarc.net>
* Copyright (c) 2016-2025 OARC, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __pcap_thread_h
#define __pcap_thread_h
#ifdef HAVE_PTHREAD
#include <pthread.h>
#endif
#include <pcap/pcap.h>
#include <sys/socket.h>
#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif
#include <sys/types.h>
#include <netinet/in.h>
#include <net/if_arp.h>
#include <netinet/if_ether.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#ifdef HAVE_ENDIAN_H
#include <endian.h>
#endif
#ifdef HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
#endif
#ifdef HAVE_MACHINE_ENDIAN_H
#include <machine/endian.h>
#endif
#ifndef __BYTE_ORDER
#if defined(BYTE_ORDER)
#define __BYTE_ORDER BYTE_ORDER
#elif defined(_BYTE_ORDER)
#define __BYTE_ORDER _BYTE_ORDER
#else
#error "No endian byte order define, please fix"
#endif
#endif
#ifndef __LITTLE_ENDIAN
#if defined(LITTLE_ENDIAN)
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#elif defined(_LITTLE_ENDIAN)
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
#else
#error "No little endian define, please fix"
#endif
#endif
#ifndef __BIG_ENDIAN
#if defined(BIG_ENDIAN)
#define __BIG_ENDIAN BIG_ENDIAN
#elif defined(_BIG_ENDIAN)
#define __BIG_ENDIAN _BIG_ENDIAN
#else
#error "No big endian define, please fix"
#endif
#endif
#ifndef PCAP_NETMASK_UNKNOWN
#define PCAP_NETMASK_UNKNOWN 0xffffffff
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* clang-format off */
#define PCAP_THREAD_VERSION_STR "4.1.0"
#define PCAP_THREAD_VERSION_MAJOR 4
#define PCAP_THREAD_VERSION_MINOR 1
#define PCAP_THREAD_VERSION_PATCH 0
#define PCAP_THREAD_DEFAULT_TIMEOUT 1000
#define PCAP_THREAD_DEFAULT_QUEUE_SIZE 64
#define PCAP_THREAD_DEFAULT_QUEUE_MODE PCAP_THREAD_QUEUE_MODE_COND
#define PCAP_THREAD_DEFAULT_ACTIVATE_MODE PCAP_THREAD_ACTIVATE_MODE_IMMEDIATE
#define PCAP_THREAD_OK 0
#define PCAP_THREAD_EPCAP 1
#define PCAP_THREAD_ENOMEM 2
#define PCAP_THREAD_ENOMON 3
#define PCAP_THREAD_ENODIR 4
#define PCAP_THREAD_EINVAL 5
#define PCAP_THREAD_EWOULDBLOCK 6
#define PCAP_THREAD_NOPCAPS 7
#define PCAP_THREAD_NOCALLBACK 8
#define PCAP_THREAD_ERRNO 9
#define PCAP_THREAD_NOYIELD 10
#define PCAP_THREAD_EOBSOLETE 11
#define PCAP_THREAD_ERUNNING 12
#define PCAP_THREAD_ENOPCAPLIST 13
#define PCAP_THREAD_ELAYERCB 14
#define PCAP_THREAD_EPCAP_STR "libpcap error"
#define PCAP_THREAD_ENOMEM_STR "out of memory"
#define PCAP_THREAD_ENOMON_STR "monitor mode requested but not supported"
#define PCAP_THREAD_ENODIR_STR "direction specified but not supported"
#define PCAP_THREAD_EINVAL_STR "invalid argument"
#define PCAP_THREAD_EWOULDBLOCK_STR "nonblocking pcap can not be added"
#define PCAP_THREAD_NOPCAPS_STR "nothing to capture on"
#define PCAP_THREAD_NOCALLBACK_STR "no callback set"
#define PCAP_THREAD_ERRNO_STR "system error, check errno"
#define PCAP_THREAD_NOYIELD_STR "queue more yield requested but not supported"
#define PCAP_THREAD_EOBSOLETE_STR "obsolete function or feature"
#define PCAP_THREAD_ERUNNING_STR "pcap thread are running, can not complete task"
#define PCAP_THREAD_ENOPCAPLIST_STR "no internal reference to the pcap that captured the packet"
#define PCAP_THREAD_ELAYERCB_STR "layer callback already set in lower or higher segment"
/* clang-format on */
struct pcap_thread_linux_sll {
uint16_t packet_type;
uint16_t arp_hardware;
uint16_t link_layer_address_length;
uint8_t link_layer_address[8];
uint16_t ether_type;
};
struct pcap_thread_linux_sll2 {
uint16_t protocol_type;
uint16_t reserved;
uint32_t interface_index;
uint16_t arphrd_type;
uint8_t packet_type;
uint8_t link_layer_address_length;
uint8_t link_layer_address[8];
};
struct pcap_thread_null_hdr {
uint32_t family;
};
struct pcap_thread_loop_hdr {
uint32_t family;
};
struct pcap_thread_ieee802_hdr {
uint16_t tpid;
unsigned short pcp : 3;
unsigned short dei : 1;
unsigned short vid : 12;
uint16_t ether_type;
};
struct pcap_thread_gre_hdr {
uint16_t gre_flags;
uint16_t ether_type;
};
struct pcap_thread_gre {
uint16_t checksum;
uint16_t key;
uint16_t sequence;
};
typedef enum pcap_thread_packet_state pcap_thread_packet_state_t;
enum pcap_thread_packet_state {
PCAP_THREAD_PACKET_OK = 0,
PCAP_THREAD_PACKET_INVALID,
PCAP_THREAD_PACKET_UNSUPPORTED,
PCAP_THREAD_PACKET_UNPROCESSED,
PCAP_THREAD_PACKET_INVALID_ETHER,
PCAP_THREAD_PACKET_INVALID_LINUX_SLL,
PCAP_THREAD_PACKET_INVALID_NULL,
PCAP_THREAD_PACKET_INVALID_LOOP,
PCAP_THREAD_PACKET_INVALID_IEEE802,
PCAP_THREAD_PACKET_INVALID_GRE,
PCAP_THREAD_PACKET_INVALID_IP,
PCAP_THREAD_PACKET_INVALID_IPV4,
PCAP_THREAD_PACKET_INVALID_IPV6,
PCAP_THREAD_PACKET_INVALID_IPV6HDR,
PCAP_THREAD_PACKET_INVALID_ICMP,
PCAP_THREAD_PACKET_INVALID_ICMPV6,
PCAP_THREAD_PACKET_INVALID_UDP,
PCAP_THREAD_PACKET_INVALID_TCP,
PCAP_THREAD_PACKET_IS_FRAGMENT,
PCAP_THREAD_PACKET_INVALID_FRAGMENT,
PCAP_THREAD_PACKET_ENOMEM,
PCAP_THREAD_PACKET_EMUTEX,
PCAP_THREAD_PACKET_FRAGMENTED_GREHDR,
PCAP_THREAD_PACKET_FRAGMENTED_ICMPHDR,
PCAP_THREAD_PACKET_FRAGMENTED_ICMPV6HDR,
PCAP_THREAD_PACKET_FRAGMENTED_UDPHDR,
PCAP_THREAD_PACKET_FRAGMENTED_TCPHDR,
PCAP_THREAD_PACKET_INVALID_LINUX_SLL2
};
typedef struct pcap_thread_packet pcap_thread_packet_t;
struct pcap_thread_packet {
unsigned short have_prevpkt : 1;
unsigned short have_pkthdr : 1;
unsigned short have_linux_sll : 1;
unsigned short have_linux_sll2 : 1;
unsigned short have_ethhdr : 1;
unsigned short have_nullhdr : 1;
unsigned short have_loophdr : 1;
unsigned short have_ieee802hdr : 1;
unsigned short have_grehdr : 1;
unsigned short have_gre : 1;
unsigned short have_iphdr : 1;
unsigned short have_ip6hdr : 1;
unsigned short have_ip6frag : 1;
unsigned short have_ip6rtdst : 1;
unsigned short have_icmphdr : 1;
unsigned short have_icmpv6hdr : 1;
unsigned short have_udphdr : 1;
unsigned short have_tcphdr : 1;
unsigned short have_tcpopts : 1;
unsigned short have_ippadding : 1;
unsigned short have_ip6padding : 1;
const char* name;
int dlt;
pcap_thread_packet_t* prevpkt;
struct pcap_pkthdr pkthdr;
struct pcap_thread_linux_sll linux_sll;
struct pcap_thread_linux_sll2 linux_sll2;
struct ether_header ethhdr;
struct pcap_thread_null_hdr nullhdr;
struct pcap_thread_loop_hdr loophdr;
struct pcap_thread_ieee802_hdr ieee802hdr;
struct pcap_thread_gre_hdr grehdr;
struct pcap_thread_gre gre;
struct ip iphdr;
struct ip6_hdr ip6hdr;
struct ip6_frag ip6frag;
uint8_t ip6frag_payload;
struct in6_addr ip6rtdst;
struct {
u_int8_t type;
u_int8_t code;
u_int16_t checksum;
} icmphdr;
struct {
u_int8_t icmp6_type;
u_int8_t icmp6_code;
u_int16_t icmp6_cksum;
} icmpv6hdr;
struct {
union {
struct {
u_int16_t uh_sport;
u_int16_t uh_dport;
u_int16_t uh_ulen;
u_int16_t uh_sum;
};
struct {
u_int16_t source;
u_int16_t dest;
u_int16_t len;
u_int16_t check;
};
};
} udphdr;
struct {
union {
struct {
u_int16_t th_sport;
u_int16_t th_dport;
u_int32_t th_seq;
u_int32_t th_ack;
#if __BYTE_ORDER == __LITTLE_ENDIAN
u_int8_t th_x2 : 4;
u_int8_t th_off : 4;
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
u_int8_t th_off : 4;
u_int8_t th_x2 : 4;
#endif
u_int8_t th_flags;
u_int16_t th_win;
u_int16_t th_sum;
u_int16_t th_urp;
};
struct {
u_int16_t source;
u_int16_t dest;
u_int32_t seq;
u_int32_t ack_seq;
#if __BYTE_ORDER == __LITTLE_ENDIAN
u_int16_t res1 : 4;
u_int16_t doff : 4;
u_int16_t fin : 1;
u_int16_t syn : 1;
u_int16_t rst : 1;
u_int16_t psh : 1;
u_int16_t ack : 1;
u_int16_t urg : 1;
u_int16_t res2 : 2;
#elif __BYTE_ORDER == __BIG_ENDIAN
u_int16_t doff : 4;
u_int16_t res1 : 4;
u_int16_t res2 : 2;
u_int16_t urg : 1;
u_int16_t ack : 1;
u_int16_t psh : 1;
u_int16_t rst : 1;
u_int16_t syn : 1;
u_int16_t fin : 1;
#endif
u_int16_t window;
u_int16_t check;
u_int16_t urg_ptr;
};
};
} tcphdr;
u_int8_t tcpopts[64];
size_t tcpopts_len;
size_t ippadding;
size_t ip6padding;
pcap_thread_packet_state_t state;
};
typedef enum pcap_thread_queue_mode pcap_thread_queue_mode_t;
typedef struct pcap_thread pcap_thread_t;
typedef void (*pcap_thread_callback_t)(u_char* user, const struct pcap_pkthdr* pkthdr, const u_char* pkt, const char* name, int dlt);
typedef void (*pcap_thread_layer_callback_t)(u_char* user, const pcap_thread_packet_t* packet, const u_char* payload, size_t length);
typedef void (*pcap_thread_stats_callback_t)(u_char* user, const struct pcap_stat* stats, const char* name, int dlt);
#ifndef HAVE_PCAP_DIRECTION_T
typedef int pcap_direction_t;
#endif
typedef struct pcap_thread_pcaplist pcap_thread_pcaplist_t;
typedef enum pcap_thread_activate_mode pcap_thread_activate_mode_t;
enum pcap_thread_queue_mode {
PCAP_THREAD_QUEUE_MODE_COND,
PCAP_THREAD_QUEUE_MODE_WAIT,
PCAP_THREAD_QUEUE_MODE_YIELD,
PCAP_THREAD_QUEUE_MODE_DROP,
PCAP_THREAD_QUEUE_MODE_DIRECT
};
enum pcap_thread_activate_mode {
PCAP_THREAD_ACTIVATE_MODE_IMMEDIATE,
PCAP_THREAD_ACTIVATE_MODE_DELAYED
};
#ifdef HAVE_PCAP_DIRECTION_T
#define PCAP_THREAD_T_INIT_DIRECTION_T 0,
#else
#define PCAP_THREAD_T_INIT_DIRECTION_T
#endif
#ifdef HAVE_PTHREAD
#define PCAP_THREAD_T_INIT_QUEUE PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, \
0, 0, 0, 0, 0, 0,
#else
#define PCAP_THREAD_T_INIT_QUEUE
#endif
#ifdef PCAP_TSTAMP_PRECISION_MICRO
#define PCAP_THREAD_T_INIT_PRECISION PCAP_TSTAMP_PRECISION_MICRO
#else
#define PCAP_THREAD_T_INIT_PRECISION 0
#endif
typedef void* (*pcap_thread_layer_callback_frag_new_t)(void* conf, u_char* user);
typedef void (*pcap_thread_layer_callback_frag_free_t)(void* ctx);
typedef pcap_thread_packet_state_t (*pcap_thread_layer_callback_frag_reassemble_t)(void* ctx, const pcap_thread_packet_t* packet, const u_char* payload, size_t length, pcap_thread_packet_t** whole_packet, const u_char** whole_payload, size_t* whole_length);
typedef void (*pcap_thread_layer_callback_frag_release_t)(void* ctx, const pcap_thread_packet_t* packet, const u_char* payload, size_t length);
/* clang-format off */
#define PCAP_THREAD_LAYER_CALLBACK_FRAG_T_INIT { \
0, 0, 0, 0, 0, \
}
/* clang-format on */
typedef struct pcap_thread_layer_callback_frag pcap_thread_layer_callback_frag_t;
struct pcap_thread_layer_callback_frag {
void* conf;
pcap_thread_layer_callback_frag_new_t new;
pcap_thread_layer_callback_frag_free_t free;
pcap_thread_layer_callback_frag_reassemble_t reassemble;
pcap_thread_layer_callback_frag_release_t release;
};
/* clang-format off */
#define PCAP_THREAD_T_INIT { \
0, 0, 0, 0, \
0, 1, 0, PCAP_THREAD_DEFAULT_QUEUE_MODE, PCAP_THREAD_DEFAULT_QUEUE_SIZE, \
PCAP_THREAD_T_INIT_QUEUE \
0, 0, 0, 0, PCAP_THREAD_DEFAULT_TIMEOUT, \
0, 0, PCAP_THREAD_T_INIT_PRECISION, 0, \
PCAP_THREAD_T_INIT_DIRECTION_T \
0, 0, 0, 1, PCAP_NETMASK_UNKNOWN, \
0, 0, \
0, "", 0, 0, \
{ 0, 0 }, { 0, 0 }, \
PCAP_THREAD_DEFAULT_ACTIVATE_MODE, \
0, 0, 0, 0, 0, 0, 0, 0, 0, PCAP_THREAD_LAYER_CALLBACK_FRAG_T_INIT, 0, PCAP_THREAD_LAYER_CALLBACK_FRAG_T_INIT, 0, 0, 0, 0, \
0 \
}
/* clang-format on */
struct pcap_thread {
unsigned short have_timestamp_precision : 1;
unsigned short have_timestamp_type : 1;
unsigned short have_direction : 1;
unsigned short was_stopped : 1;
int running;
int use_threads;
int use_layers;
pcap_thread_queue_mode_t queue_mode;
size_t queue_size;
#ifdef HAVE_PTHREAD
pthread_cond_t have_packets;
pthread_cond_t can_write;
pthread_mutex_t mutex;
struct pcap_pkthdr* pkthdr;
u_char* pkt;
pcap_thread_pcaplist_t** pcaplist_pkt;
size_t read_pos;
size_t write_pos;
size_t pkts;
#endif
int snapshot;
int snaplen;
int promiscuous;
int monitor;
int timeout;
int buffer_size;
int timestamp_type;
int timestamp_precision;
int immediate_mode;
#ifdef HAVE_PCAP_DIRECTION_T
pcap_direction_t direction;
#endif
char* filter;
size_t filter_len;
int filter_errno;
int filter_optimize;
bpf_u_int32 filter_netmask;
pcap_thread_callback_t callback;
pcap_thread_callback_t dropback;
int status;
char errbuf[PCAP_ERRBUF_SIZE];
pcap_thread_pcaplist_t* pcaplist;
pcap_thread_pcaplist_t* step;
struct timeval timedrun;
struct timeval timedrun_to;
pcap_thread_activate_mode_t activate_mode;
pcap_thread_layer_callback_t callback_linux_sll;
pcap_thread_layer_callback_t callback_linux_sll2;
pcap_thread_layer_callback_t callback_ether;
pcap_thread_layer_callback_t callback_null;
pcap_thread_layer_callback_t callback_loop;
pcap_thread_layer_callback_t callback_ieee802;
pcap_thread_layer_callback_t callback_gre;
pcap_thread_layer_callback_t callback_ip;
pcap_thread_layer_callback_t callback_ipv4;
pcap_thread_layer_callback_frag_t callback_ipv4_frag;
pcap_thread_layer_callback_t callback_ipv6;
pcap_thread_layer_callback_frag_t callback_ipv6_frag;
pcap_thread_layer_callback_t callback_icmp;
pcap_thread_layer_callback_t callback_icmpv6;
pcap_thread_layer_callback_t callback_udp;
pcap_thread_layer_callback_t callback_tcp;
pcap_thread_layer_callback_t callback_invalid;
};
#define PCAP_THREAD_SET_ERRBUF(x, y) strncpy(x->errbuf, y, sizeof(x->errbuf) - 1)
#ifdef HAVE_PTHREAD
#define PCAP_THREAD_PCAPLIST_T_INIT_THREAD 0,
#else
#define PCAP_THREAD_PCAPLIST_T_INIT_THREAD
#endif
/* clang-format off */
#define PCAP_THREAD_PCAPLIST_T_INIT { \
0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, \
0, \
PCAP_THREAD_PCAPLIST_T_INIT_THREAD \
{ 0, 0 }, \
0, \
0, { 0, 0 } \
}
/* clang-format on */
struct pcap_thread_pcaplist {
unsigned short have_bpf : 1;
unsigned short have_ipv4_frag_ctx : 1;
unsigned short have_ipv6_frag_ctx : 1;
pcap_thread_pcaplist_t* next;
char* name;
pcap_t* pcap;
void* user;
int running;
int is_offline;
void* ipv4_frag_ctx;
void* ipv6_frag_ctx;
pcap_thread_t* pcap_thread;
#ifdef HAVE_PTHREAD
pthread_t thread;
#endif
struct bpf_program bpf;
pcap_thread_callback_t layer_callback;
int timedrun;
struct timespec end;
};
const char* pcap_thread_version_str(void);
int pcap_thread_version_major(void);
int pcap_thread_version_minor(void);
int pcap_thread_version_patch(void);
pcap_thread_t* pcap_thread_create(void);
void pcap_thread_free(pcap_thread_t* pcap_thread);
int pcap_thread_use_threads(const pcap_thread_t* pcap_thread);
int pcap_thread_set_use_threads(pcap_thread_t* pcap_thread, const int use_threads);
int pcap_thread_use_layers(const pcap_thread_t* pcap_thread);
int pcap_thread_set_use_layers(pcap_thread_t* pcap_thread, const int use_layers);
pcap_thread_queue_mode_t pcap_thread_queue_mode(const pcap_thread_t* pcap_thread);
int pcap_thread_set_queue_mode(pcap_thread_t* pcap_thread, const pcap_thread_queue_mode_t queue_mode);
struct timeval pcap_thread_queue_wait(const pcap_thread_t* pcap_thread);
int pcap_thread_set_queue_wait(pcap_thread_t* pcap_thread, const struct timeval queue_wait);
pcap_thread_queue_mode_t pcap_thread_callback_queue_mode(const pcap_thread_t* pcap_thread);
int pcap_thread_set_callback_queue_mode(pcap_thread_t* pcap_thread, const pcap_thread_queue_mode_t callback_queue_mode);
struct timeval pcap_thread_callback_queue_wait(const pcap_thread_t* pcap_thread);
int pcap_thread_set_callback_queue_wait(pcap_thread_t* pcap_thread, const struct timeval callback_queue_wait);
int pcap_thread_snapshot(const pcap_thread_t* pcap_thread);
int pcap_thread_snaplen(const pcap_thread_t* pcap_thread);
int pcap_thread_set_snaplen(pcap_thread_t* pcap_thread, const int snaplen);
int pcap_thread_promiscuous(const pcap_thread_t* pcap_thread);
int pcap_thread_set_promiscuous(pcap_thread_t* pcap_thread, const int promiscuous);
int pcap_thread_monitor(const pcap_thread_t* pcap_thread);
int pcap_thread_set_monitor(pcap_thread_t* pcap_thread, const int monitor);
int pcap_thread_timeout(const pcap_thread_t* pcap_thread);
int pcap_thread_set_timeout(pcap_thread_t* pcap_thread, const int timeout);
int pcap_thread_buffer_size(const pcap_thread_t* pcap_thread);
int pcap_thread_set_buffer_size(pcap_thread_t* pcap_thread, const int buffer_size);
int pcap_thread_timestamp_type(const pcap_thread_t* pcap_thread);
int pcap_thread_set_timestamp_type(pcap_thread_t* pcap_thread, const int timestamp_type);
int pcap_thread_timestamp_precision(const pcap_thread_t* pcap_thread);
int pcap_thread_set_timestamp_precision(pcap_thread_t* pcap_thread, const int timestamp_precision);
int pcap_thread_immediate_mode(const pcap_thread_t* pcap_thread);
int pcap_thread_set_immediate_mode(pcap_thread_t* pcap_thread, const int immediate_mode);
pcap_direction_t pcap_thread_direction(const pcap_thread_t* pcap_thread);
int pcap_thread_set_direction(pcap_thread_t* pcap_thread, const pcap_direction_t direction);
const char* pcap_thread_filter(const pcap_thread_t* pcap_thread);
int pcap_thread_set_filter(pcap_thread_t* pcap_thread, const char* filter, const size_t filter_len);
int pcap_thread_clear_filter(pcap_thread_t* pcap_thread);
int pcap_thread_filter_errno(const pcap_thread_t* pcap_thread);
int pcap_thread_filter_optimize(const pcap_thread_t* pcap_thread);
int pcap_thread_set_filter_optimize(pcap_thread_t* pcap_thread, const int filter_optimize);
bpf_u_int32 pcap_thread_filter_netmask(const pcap_thread_t* pcap_thread);
int pcap_thread_set_filter_netmask(pcap_thread_t* pcap_thread, const bpf_u_int32 filter_netmask);
struct timeval pcap_thread_timedrun(const pcap_thread_t* pcap_thread);
int pcap_thread_set_timedrun(pcap_thread_t* pcap_thread, const struct timeval timedrun);
struct timeval pcap_thread_timedrun_to(const pcap_thread_t* pcap_thread);
int pcap_thread_set_timedrun_to(pcap_thread_t* pcap_thread, const struct timeval timedrun_to);
pcap_thread_activate_mode_t pcap_thread_activate_mode(const pcap_thread_t* pcap_thread);
int pcap_thread_set_activate_mode(pcap_thread_t* pcap_thread, const pcap_thread_activate_mode_t activate_mode);
int pcap_thread_was_stopped(const pcap_thread_t* pcap_thread);
size_t pcap_thread_queue_size(const pcap_thread_t* pcap_thread);
int pcap_thread_set_queue_size(pcap_thread_t* pcap_thread, const size_t queue_size);
int pcap_thread_set_callback(pcap_thread_t* pcap_thread, pcap_thread_callback_t callback);
int pcap_thread_set_dropback(pcap_thread_t* pcap_thread, pcap_thread_callback_t dropback);
int pcap_thread_set_callback_linux_sll(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_linux_sll);
int pcap_thread_set_callback_linux_sll2(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_linux_sll2);
int pcap_thread_set_callback_ether(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_ether);
int pcap_thread_set_callback_null(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_null);
int pcap_thread_set_callback_loop(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_loop);
int pcap_thread_set_callback_ieee802(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_ieee802);
int pcap_thread_set_callback_gre(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_gre);
int pcap_thread_set_callback_ip(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_ip);
int pcap_thread_set_callback_ipv4(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_ipv4);
int pcap_thread_set_callback_ipv4_frag(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_frag_t callback_ipv4_frag);
int pcap_thread_set_callback_ipv6(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_ipv6);
int pcap_thread_set_callback_ipv6_frag(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_frag_t callback_ipv6_frag);
int pcap_thread_set_callback_icmp(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_icmp);
int pcap_thread_set_callback_icmpv6(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_icmpv6);
int pcap_thread_set_callback_udp(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_udp);
int pcap_thread_set_callback_tcp(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_tcp);
int pcap_thread_set_callback_invalid(pcap_thread_t* pcap_thread, pcap_thread_layer_callback_t callback_tcp);
int pcap_thread_open(pcap_thread_t* pcap_thread, const char* device, void* user);
int pcap_thread_open_offline(pcap_thread_t* pcap_thread, const char* file, void* user);
int pcap_thread_add(pcap_thread_t* pcap_thread, const char* name, pcap_t* pcap, void* user);
int pcap_thread_activate(pcap_thread_t* pcap_thread);
int pcap_thread_close(pcap_thread_t* pcap_thread);
int pcap_thread_run(pcap_thread_t* pcap_thread);
int pcap_thread_next(pcap_thread_t* pcap_thread);
int pcap_thread_next_reset(pcap_thread_t* pcap_thread);
int pcap_thread_stop(pcap_thread_t* pcap_thread);
int pcap_thread_stats(pcap_thread_t* pcap_thread, pcap_thread_stats_callback_t callback, u_char* user);
int pcap_thread_status(const pcap_thread_t* pcap_thread);
const char* pcap_thread_errbuf(const pcap_thread_t* pcap_thread);
const char* pcap_thread_strerr(int error);
#ifdef __cplusplus
}
#endif
#endif /* __pcap_thread_h */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,131 @@
/*
* Author Jerry Lundström <jerry@dns-oarc.net>
* Copyright (c) 2016-2025 OARC, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "pcap_thread.h"
#ifndef __pcap_thread_ext_frag_h
#define __pcap_thread_ext_frag_h
#ifdef __cplusplus
extern "C" {
#endif
/*
* RFC791 - Handle fragments in an offset ascending order, allow fragments to overlap
* RFC815 - Handle fragments in a receiving order, allow fragments to overlap
* BSD - Handle fragments in an offset descending order, allow fragments to overlap
*/
typedef enum pcap_thread_ext_frag_reassemble_mode pcap_thread_ext_frag_reassemble_mode_t;
enum pcap_thread_ext_frag_reassemble_mode {
PCAP_THREAD_EXT_FRAG_REASSEMBLE_RFC791 = 0,
PCAP_THREAD_EXT_FRAG_REASSEMBLE_RFC815,
PCAP_THREAD_EXT_FRAG_REASSEMBLE_BSD
};
typedef struct pcap_thread_ext_frag_fragment pcap_thread_ext_frag_fragment_t;
struct pcap_thread_ext_frag_fragment {
pcap_thread_ext_frag_fragment_t* next;
unsigned short flag_more_fragments : 1;
u_char* payload;
size_t length;
size_t offset;
};
typedef struct pcap_thread_ext_frag_fragments pcap_thread_ext_frag_fragments_t;
struct pcap_thread_ext_frag_fragments {
pcap_thread_ext_frag_fragments_t* next;
pcap_thread_packet_t packet;
pcap_thread_ext_frag_fragment_t* fragments;
size_t num_fragments;
u_char* payload;
size_t length;
};
typedef void (*pcap_thread_ext_frag_callback_t)(const pcap_thread_packet_t* packet, const u_char* payload, size_t length, const pcap_thread_ext_frag_fragments_t* fragments);
/* clang-format off */
#define PCAP_THREAD_EXT_FRAG_CONF_T_INIT { \
0, 0, \
PCAP_THREAD_EXT_FRAG_REASSEMBLE_RFC791, \
100, 10, { 30, 0 }, \
0, 0 \
}
/* clang-format on */
typedef struct pcap_thread_ext_frag_conf pcap_thread_ext_frag_conf_t;
struct pcap_thread_ext_frag_conf {
unsigned short reject_overlap : 1;
unsigned short check_timeout : 1;
pcap_thread_ext_frag_reassemble_mode_t reassemble_mode;
size_t fragments;
size_t per_packet;
struct timeval timeout;
pcap_thread_ext_frag_callback_t overlap_callback;
pcap_thread_ext_frag_callback_t timeout_callback;
};
pcap_thread_ext_frag_conf_t* pcap_thread_ext_frag_conf_new(void);
void pcap_thread_ext_frag_conf_free(pcap_thread_ext_frag_conf_t* conf);
int pcap_thread_ext_frag_conf_reject_overlap(const pcap_thread_ext_frag_conf_t* conf);
int pcap_thread_ext_frag_conf_set_reject_overlap(pcap_thread_ext_frag_conf_t* conf, const int reject_overlap);
int pcap_thread_ext_frag_conf_check_timeout(const pcap_thread_ext_frag_conf_t* conf);
int pcap_thread_ext_frag_conf_set_check_timeout(pcap_thread_ext_frag_conf_t* conf, const int check_timeout);
pcap_thread_ext_frag_reassemble_mode_t pcap_thread_ext_frag_conf_reassemble_mode(const pcap_thread_ext_frag_conf_t* conf);
int pcap_thread_ext_frag_conf_set_reassemble_mode(pcap_thread_ext_frag_conf_t* conf, const pcap_thread_ext_frag_reassemble_mode_t reassemble_mode);
size_t pcap_thread_ext_frag_conf_fragments(const pcap_thread_ext_frag_conf_t* conf);
int pcap_thread_ext_frag_conf_set_fragments(pcap_thread_ext_frag_conf_t* conf, const size_t fragments);
size_t pcap_thread_ext_frag_conf_per_packet(const pcap_thread_ext_frag_conf_t* conf);
int pcap_thread_ext_frag_conf_set_per_packet(pcap_thread_ext_frag_conf_t* conf, const size_t per_packet);
struct timeval pcap_thread_ext_frag_conf_timeout(const pcap_thread_ext_frag_conf_t* conf);
int pcap_thread_ext_frag_conf_set_timeout(pcap_thread_ext_frag_conf_t* conf, const struct timeval timeout);
pcap_thread_ext_frag_callback_t pcap_thread_ext_frag_conf_overlap_callback(const pcap_thread_ext_frag_conf_t* conf);
int pcap_thread_ext_frag_conf_set_overlap_callback(pcap_thread_ext_frag_conf_t* conf, pcap_thread_ext_frag_callback_t overlap_callback);
pcap_thread_ext_frag_callback_t pcap_thread_ext_frag_conf_timeout_callback(const pcap_thread_ext_frag_conf_t* conf);
int pcap_thread_ext_frag_conf_set_timeout_callback(pcap_thread_ext_frag_conf_t* conf, pcap_thread_ext_frag_callback_t timeout_callback);
pcap_thread_layer_callback_frag_t pcap_thread_ext_frag_layer_callback(pcap_thread_ext_frag_conf_t* conf);
#ifdef __cplusplus
}
#endif
#endif /* __pcap_thread_ext_frag_h */

4
src/test/.gitignore vendored
View file

@ -1,4 +0,0 @@
dns.out
dns.pcap.dist
test*.log
test*.trs

1020
src/test/Makefile.in Normal file

File diff suppressed because it is too large Load diff

153
test-driver Executable file
View file

@ -0,0 +1,153 @@
#! /bin/sh
# test-driver - basic testsuite driver script.
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 2011-2021 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
# Make unconditional expansion of undefined variables an error. This
# helps a lot in preventing typo-related bugs.
set -u
usage_error ()
{
echo "$0: $*" >&2
print_usage >&2
exit 2
}
print_usage ()
{
cat <<END
Usage:
test-driver --test-name NAME --log-file PATH --trs-file PATH
[--expect-failure {yes|no}] [--color-tests {yes|no}]
[--enable-hard-errors {yes|no}] [--]
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
See the GNU Automake documentation for information.
END
}
test_name= # Used for reporting.
log_file= # Where to save the output of the test script.
trs_file= # Where to save the metadata of the test run.
expect_failure=no
color_tests=no
enable_hard_errors=yes
while test $# -gt 0; do
case $1 in
--help) print_usage; exit $?;;
--version) echo "test-driver $scriptversion"; exit $?;;
--test-name) test_name=$2; shift;;
--log-file) log_file=$2; shift;;
--trs-file) trs_file=$2; shift;;
--color-tests) color_tests=$2; shift;;
--expect-failure) expect_failure=$2; shift;;
--enable-hard-errors) enable_hard_errors=$2; shift;;
--) shift; break;;
-*) usage_error "invalid option: '$1'";;
*) break;;
esac
shift
done
missing_opts=
test x"$test_name" = x && missing_opts="$missing_opts --test-name"
test x"$log_file" = x && missing_opts="$missing_opts --log-file"
test x"$trs_file" = x && missing_opts="$missing_opts --trs-file"
if test x"$missing_opts" != x; then
usage_error "the following mandatory options are missing:$missing_opts"
fi
if test $# -eq 0; then
usage_error "missing argument"
fi
if test $color_tests = yes; then
# Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
red='' # Red.
grn='' # Green.
lgn='' # Light green.
blu='' # Blue.
mgn='' # Magenta.
std='' # No color.
else
red= grn= lgn= blu= mgn= std=
fi
do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
trap "st=129; $do_exit" 1
trap "st=130; $do_exit" 2
trap "st=141; $do_exit" 13
trap "st=143; $do_exit" 15
# Test script is run here. We create the file first, then append to it,
# to ameliorate tests themselves also writing to the log file. Our tests
# don't, but others can (automake bug#35762).
: >"$log_file"
"$@" >>"$log_file" 2>&1
estatus=$?
if test $enable_hard_errors = no && test $estatus -eq 99; then
tweaked_estatus=1
else
tweaked_estatus=$estatus
fi
case $tweaked_estatus:$expect_failure in
0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
0:*) col=$grn res=PASS recheck=no gcopy=no;;
77:*) col=$blu res=SKIP recheck=no gcopy=yes;;
99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
*:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
*:*) col=$red res=FAIL recheck=yes gcopy=yes;;
esac
# Report the test outcome and exit status in the logs, so that one can
# know whether the test passed or failed simply by looking at the '.log'
# file, without the need of also peaking into the corresponding '.trs'
# file (automake bug#11814).
echo "$res $test_name (exit status: $estatus)" >>"$log_file"
# Report outcome to console.
echo "${col}${res}${std}: $test_name"
# Register the test result, and other relevant metadata.
echo ":test-result: $res" > $trs_file
echo ":global-test-result: $res" >> $trs_file
echo ":recheck: $recheck" >> $trs_file
echo ":copy-in-global-log: $gcopy" >> $trs_file
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End: