Commit graph

56 commits

Author SHA1 Message Date
Tim Wojtulewicz
460fe24a9a Fix clang-tidy cppcoreguidelines-macro-usage findings (macro functions) 2025-06-04 09:24:05 -07:00
Tim Wojtulewicz
ad99a6821e Fix clang-tidy cppcoreguidelines-macro-usage findings (macros as constants) 2025-06-04 09:24:05 -07:00
Tim Wojtulewicz
02589c349a Fix clang-tidy bugprone-string-literal-with-embedded-nul warnings 2025-05-27 11:58:27 -07:00
Tim Wojtulewicz
896e41c794 Remove unnecessary #includes in base files in repo 2025-05-19 09:50:23 -07:00
Arne Welzel
0f1c1cb754 clang-format: Sort doctest header at the bottom 2024-11-15 17:00:00 +01:00
Arne Welzel
29f5b507b6 Conn/net_utils/fmt_mac: Avoid snprintf(), memcpy() and allocation
The fmt_mac() function returning a std::string means the resulting mac
is copied at least once upon returning. Then, the Assign() in GetVal()
taking a std::string internally allocates a new zeek::String which
hits a malloc (no short-string optimization for zeek::String) and then
also copies the content from the std::string into the malloced memory.

Save a few cycles by directly using the allocated memory with the
String instance. This change improves runtime for a SYN-only pcap
with just base/protocols/conn loaded by some 1-2%.
2024-02-13 19:37:15 +01:00
Benjamin Bannier
f5a76c1aed Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The
one place where we deviate is header include order since Zeek depends on
headers being included in a certain order.
2023-10-30 09:40:55 +01:00
Tim Wojtulewicz
9cb54f5d44 clang-format: Force zeek-config.h to be earlier in the config ordering 2021-09-25 11:52:55 -07:00
Tim Wojtulewicz
b2f171ec69 Reformat the world 2021-09-16 15:35:39 -07:00
Tim Wojtulewicz
b14cd1ef16 GH-1216: Enable Mobile IPv6 support by default
This removes the ENABLE_MOBILE_IPV6 #define variable. It also marks the
--enable-mobile-ipv6 configure argument as deprecated.
2021-06-28 11:11:55 -07:00
Tim Wojtulewicz
9e1f6f95aa Move analyzer-to-port mapping out of analyzer::Manager into packet analyzers 2021-06-02 13:20:10 -07:00
Jon Siwek
8a8a983c49 Add missing zeek/ to header includes
Related to https://github.com/zeek/zeek/pull/1377
2021-01-29 19:16:29 -08:00
Tim Wojtulewicz
96d9115360 GH-1079: Use full paths starting with zeek/ when including files 2020-11-12 12:15:26 -07:00
Jon Siwek
d070709c57 Switch one's complement checksum implementation
Borrows the `in_cksum` code from tcpdump, which borrowed from FreeBSD.
It handles unaligned data better and also unrolls the inner loop to
process 16 two-byte values at a time versus 2 one-byte values at a time
in the previous version.  Generally measured as ~1.5x faster in a
release build.  The new API should generally be more amenable to any
future optimization explorations since all relevant data blocks are
available within a single call rather than spread across multiple.
2020-09-24 09:41:15 -07:00
Tim Wojtulewicz
fe0c22c789 Base: Clean up explicit uses of namespaces in places where they're not necessary.
This commit covers all of the common and base classes.
2020-08-24 12:07:00 -07:00
Tim Wojtulewicz
db36688bf0 Move a few smaller files to zeek namespaces 2020-08-20 16:11:46 -07:00
Tim Wojtulewicz
25c0fc7ab2 Move IP Addr/Prefix/Header classes into namespaces 2020-07-31 16:22:04 -04:00
Tim Wojtulewicz
d53c1454c0 Remove 'using namespace std' from SerialTypes.h
This unfortunately cuases a ton of flow-down changes because a lot of other
code was depending on that definition existing. This has a fairly large chance
to break builds of external plugins, considering how many internal ones it broke.
2020-04-07 15:59:59 -07:00
Tim Wojtulewicz
67fcc9b5af Mark safe_snprintf and safe_vsnprintf as deprecated, remove uses of them
safe_snprintf and safe_vsnprintf just exist to ensure that the resulting strings are always null-terminated. The documentation for snprintf/vsnprintf states that the output of those methods are always null-terminated, thus making the safe versions obsolete.
2020-01-02 15:36:39 -07:00
Tim Wojtulewicz
54752ef9a1 Deprecate the internal int/uint types in favor of the cstdint types they were based on 2019-08-12 13:50:07 -07:00
Robin Sommer
789cb376fd GH-239: Rename bro to zeek, bro-config to zeek-config, and bro-path-dev to zeek-path-dev.
This also installs symlinks from "zeek" and "bro-config" to a wrapper
script that prints a deprecation warning.

The btests pass, but this is still WIP. broctl renaming is still
missing.

#239
2019-05-01 21:43:45 +00:00
Robin Sommer
c57f83d8bf Merge remote-tracking branch 'origin/topic/johanna/gcc-6.2.1'
BIT-1732 #merged

* origin/topic/johanna/gcc-6.2.1:
  Fix alignment issue of ones_complement_checksum
2016-10-24 11:12:05 -07:00
Johanna Amann
24f74cb52e Fix alignment issue of ones_complement_checksum
The ones_complement_checksum function assumes that the bytes passed into
it are aligned on 16 bit boundaries.

When using gcc (GCC) 6.2.1 20160916 (Red Hat 6.2.1-2) with -O2, this
does not seem to hold true anymore; assuming 16 bit alignment will lead
to accesses to uninitialized memory and wrong checksums.

This commit adds a minimally invasive change that does not assume
alignment anymore. This might have a small performance impact for every
single packet we process.

This error occured reproducibly when called from icmp6_checksum.
2016-10-14 15:40:59 -07:00
Robin Sommer
351014f48a Fixing memory leak triggered by new MAC address logging. 2016-06-07 11:46:56 -07:00
Jan Grashoefer
50cf694aae Moved link-layer addresses into endpoints.
The link-layer addresses are now part of the connection endpoints
following the originator-responder-pattern. The addresses are printed
with leading zeros. Additionally link-layer addresses are also extracted
for 802.11 plus RadioTap.
2016-06-02 01:46:26 +02:00
Robin Sommer
3957091e1b Renaming config.h to bro-config.h.
A couple times now I had this conflicting with files of the same name
in other projects.
2015-07-28 11:57:04 -07:00
Robin Sommer
308db797c3 Merge remote-tracking branch 'origin/topic/vladg/dhcp'
* origin/topic/vladg/dhcp:
  DHCP: Adding unit tests.
  DHCP:
  Rework the DHCP analyzer to make it compatible again.
2013-08-03 19:14:00 -07:00
Jon Siwek
27ba3118c1 Change ICMPv6 checksum calculation to use IP_Hdr wrapper.
So that src/dst addresses used in pseudo-header are correct when
there's certain extension headers (routing/destination).

Add ICMP/ICMPv6 checksum unit tests.
2012-04-10 11:37:08 -05:00
Daniel Thayer
69c09a209c Merge remote-tracking branch 'origin/master' into topic/icmp6
Conflicts:
	src/net_util.cc
	src/net_util.h
2012-04-10 09:54:07 -05:00
Jon Siwek
91330f1e1c Add support for mobile IPv6 Mobility Header (RFC 6275).
- Accessible at script-layer through 'mobile_ipv6_message' event.

- All Mobile IPv6 analysis now enabled through --enable-mobile-ipv6
  configure-time option, otherwise the mobility header, routing type 2,
  and Home Address Destination option are ignored.
2012-04-09 14:39:00 -05:00
Daniel Thayer
79a6da285f Merge remote-tracking branch 'origin/master' into topic/icmp6 2012-04-06 15:59:57 -05:00
Jon Siwek
29724415c3 Merge branch 'master' into topic/jsiwek/mobile-ipv6
Conflicts:
	src/IP.cc
2012-04-05 12:05:06 -05:00
Jon Siwek
256c0af98e Merge branch 'master' into topic/robin/log-threads
Conflicts:
	cmake
2012-03-30 12:02:32 -05:00
Jon Siwek
8a1d71dc08 Remove dead tcp_checksum function from net_util 2012-03-28 14:14:20 -05:00
Jon Siwek
f4101b5265 Improve handling of IPv6 routing type 0 extension headers.
- flow_weird event with name argument value of "routing0_hdr" is raised
  for packets containing an IPv6 routing type 0 header because this
  type of header is now deprecated according to RFC 5095.

- packets with a routing type 0 header and non-zero segments left
  now use the last address in that header in order to associate
  with a connection/flow and for calculating TCP/UDP checksums.

- added a set of IPv4/IPv6 TCP/UDP checksum unit tests
2012-03-27 16:05:45 -05:00
Daniel Thayer
9d1e51a91e More code cleanup 2012-03-02 13:52:45 -06:00
Daniel Thayer
6eb9f63e17 Add more icmpv6 events, and general code cleanup 2012-03-02 12:29:18 -06:00
Robin Sommer
edc9bb14af Making exchange of addresses between threads thread-safe.
As we can't use the IPAddr class (because it's not thread-safe), this
involved a bit manual address manipulation and also shuffling some
things around a bit.

Not fully working yet, the tests for remote logging still fail.
2012-02-28 15:57:43 -08:00
Robin Sommer
14916b43f6 Readding deleted functions.
These are needed in debug mode in turns out.
2012-02-27 21:39:56 -08:00
Robin Sommer
d24cdd3ba3 Merge remote-tracking branch 'origin/master' into topic/robin/log-threads
Conflicts:
	src/LogMgr.h
	src/RemoteSerializer.cc
	src/logging/Manager.cc
	src/logging/writers/Ascii.cc
	src/net_util.cc
2012-02-27 19:05:47 -08:00
Daniel Thayer
0a659c0907 Merge remote-tracking branch 'origin/master' into topic/icmp6 2012-02-27 13:33:05 -06:00
Jon Siwek
d7dafe2fe2 Refactoring various usages of new IPAddr class.
Reducing number of places that internal representation was exposed
via GetBytes/CopyIPv6.

Also fixed a bug in remask_addr bif.
2012-02-22 14:45:44 -06:00
Daniel Thayer
8e32e89ce4 Merge remote-tracking branch 'origin/master' into topic/icmp6
Conflicts:
	src/ICMP.cc
	src/net_util.cc
	src/net_util.h
2012-02-20 17:18:55 -06:00
Daniel Thayer
ef31099fd7 Merge branch 'master' into topic/icmp6
Conflicts:
	policy/bro.init
	policy/icmp.bro
	src/Analyzer.cc
	src/AnalyzerTags.h
	src/DPM.cc
	src/ICMP.h
	src/Sessions.cc
	src/event.bif
	src/net_util.cc
2012-02-15 15:58:53 -06:00
Jon Siwek
b3f1f45082 Remove --enable-brov6 flag, IPv6 now supported by default.
Internally, all BROv6 preprocessor switches were removed and
addr/subnet representations wrapped in the new IPAddr/IPPrefix classes.

Some script-layer changes of note:

- dns_AAAA_reply event signature changed: the string representation
  of an IPv6 addr is easily derived from the addr value, it doesn't
  need to be another parameter.  This event also now generated directly
  by the DNS analyzer instead of being "faked" into a dns_A_reply event.

- removed addr_to_count BIF.  It used to return the host-order
  count representation of IPv4 addresses only.  To make it more
  generic, we might later add a BIF to return a vector of counts
  in order to support IPv6.

- changed the result of enclosing addr variables in vertical pipes
  (e.g. |my_addr|) to return the bit-width of the address type which
  is 128 for IPv6 and 32 for IPv4.  It used to function the same
  way as addr_to_count mentioned above.

- remove bro_has_ipv6 BIF
2012-02-03 16:46:58 -06:00
Bernhard Amann
6cc29a7832 make logging with threads compile on mac os and fix a couple of string literal warnings. 2012-01-30 12:12:14 -08:00
Robin Sommer
63b46a0ae2 Fixing a bunch of format strings.
Also leveraging GCC if available to check format specificier.

Closes #567.
2011-10-18 17:39:40 -07:00
Robin Sommer
a08c478079 Fixing a number of reporter calls. 2011-10-06 21:26:49 -07:00
Jon Siwek
495e987938 Remove $Id$ tags 2011-08-04 15:21:18 -05:00
Robin Sommer
66e2c3b623 Renaming the Logger to Reporter.
Also changing output to not include timestamps when we haven't started
processing packets yet.
2011-07-01 09:22:33 -07:00