aboutsummaryrefslogtreecommitdiff
path: root/analyzer/utils
diff options
context:
space:
mode:
authorMosder <git@mosder.eu>2026-09-15 15:52:47 +0200
committerMosder <git@mosder.eu>2026-09-15 15:52:47 +0200
commit451a320920c6e2f60445938aa98d4fe817c3d36a (patch)
tree02e6b7bd9a6e2824ef332b0143c98348ff8c85b3 /analyzer/utils
parentad5eb982de97d982bc808ece89903d1113ab9917 (diff)
formatting: run codebase through new .clang-formatHEADmaster
Diffstat (limited to 'analyzer/utils')
-rw-r--r--analyzer/utils/tcp.c11
-rw-r--r--analyzer/utils/tcp.h7
-rw-r--r--analyzer/utils/time.c11
3 files changed, 21 insertions, 8 deletions
diff --git a/analyzer/utils/tcp.c b/analyzer/utils/tcp.c
index a5d0366..8979483 100644
--- a/analyzer/utils/tcp.c
+++ b/analyzer/utils/tcp.c
@@ -56,7 +56,8 @@ TCPSegment get_segment_from_packet(const byte_t *packet, const struct pcap_pkthd
return segment;
// get TCP header
- const struct tcphdr *tcp_header = (const struct tcphdr *)(packet + eth_header_len + ip_header_len);
+ const struct tcphdr *tcp_header =
+ (const struct tcphdr *)(packet + eth_header_len + ip_header_len);
int tcp_header_len = tcp_header->th_off * 4;
// get TCP sequence number and client port
@@ -91,8 +92,9 @@ void remove_parsed_data(TCPStream *stream, size_t parsed_len) {
stream->seq += parsed_len;
}
-// get the index of the first relevant byte in segment (its tcp sequence number is the one stream is expecting)
-// return the index of the first relevant byte in payload or -1 if segment isn't directly connected to stream
+// get the index of the first relevant byte in segment (its tcp sequence number is the one stream is
+// expecting) return the index of the first relevant byte in payload or -1 if segment isn't directly
+// connected to stream
int get_first_relevant_byte_index(TCPStream stream, TCPSegment segment) {
// expected tcp sequence numbers for stream and segment
uint32_t stream_expected = stream.seq + stream.bytes.count;
@@ -124,7 +126,8 @@ void add_pending_segments(TCPStream *stream) {
top_changed = 1;
}
- // remove top if it was just added or no longer is in acceptable range (e.g. was contained within another one pending)
+ // remove top if it was just added or no longer is in acceptable range (e.g. was contained
+ // within another one pending)
if (top_changed || !in_acceptable_range(*stream, *top)) {
heap_top_remove(stream->pending);
}
diff --git a/analyzer/utils/tcp.h b/analyzer/utils/tcp.h
index 55cbf3e..e2906ef 100644
--- a/analyzer/utils/tcp.h
+++ b/analyzer/utils/tcp.h
@@ -3,8 +3,8 @@
#include <pcap.h>
-#include "structures/heap.h"
#include "structures/array.h"
+#include "structures/heap.h"
#ifndef TCP_H
#define TCP_H
@@ -29,7 +29,8 @@ typedef struct {
// - packet_data - metadata about packet
// returns:
// TCPSegment from packet, payload is NULL if the received packet was incorrect
-extern TCPSegment get_segment_from_packet(const byte_t *packet, const struct pcap_pkthdr *packet_data);
+extern TCPSegment
+get_segment_from_packet(const byte_t *packet, const struct pcap_pkthdr *packet_data);
// struct that stores all the information about stream
typedef struct {
@@ -37,7 +38,7 @@ typedef struct {
uint32_t seq; // TCP sequence number of the first byte in the stream
uint16_t port; // client port of currently analyzed connection
ConnectionSource src; // stream's source
- Heap *pending; // min heap of segments yet to be added to stream (sorted by TCP sequence number)
+ Heap *pending; // min heap of segments yet to be added to stream (sorted by TCP sequence number)
} TCPStream;
#define INIT_STREAM_CAPACITY 256
diff --git a/analyzer/utils/time.c b/analyzer/utils/time.c
index d95da65..740b8e9 100644
--- a/analyzer/utils/time.c
+++ b/analyzer/utils/time.c
@@ -6,5 +6,14 @@
void get_date_time_string(char *date_time) {
time_t now = time(NULL);
struct tm *t = localtime(&now);
- sprintf(date_time, "%02d%02d%02d_%02d%02d%02d", t->tm_year - 100, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
+ sprintf(
+ date_time,
+ "%02d%02d%02d_%02d%02d%02d",
+ t->tm_year - 100,
+ t->tm_mon + 1,
+ t->tm_mday,
+ t->tm_hour,
+ t->tm_min,
+ t->tm_sec
+ );
}