Skip to content

Commit

Permalink
feat: add header and CMake configuration for apfree wifidog eBPF traf…
Browse files Browse the repository at this point in the history
…fic statistics

Signed-off-by: Dengfeng Liu <[email protected]>
  • Loading branch information
liudf0716 committed Feb 3, 2025
1 parent 2496eb6 commit b654b1a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
2 changes: 2 additions & 0 deletions ebpf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_executable(aw-bpfctl aw-bpfctl.c)
target_link_libraries(aw-bpfctl PRIVATE bpf)
15 changes: 1 addition & 14 deletions ebpf/aw-bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,7 @@
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>


struct counters {
__u32 cur_s_bytes;
__u32 prev_s_bytes;
__u64 total_bytes;
__u64 total_packets;
__u32 est_slot;
__u32 reserved;
};

struct traffic_stats {
struct counters incoming;
struct counters outgoing;
};
#include "aw-bpf.h"

// Map for IPv4 addresses
struct {
Expand Down
39 changes: 39 additions & 0 deletions ebpf/aw-bpf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* aw-bpf.h - Header file for WiFiDog eBPF traffic statistics
* Copyright (C) 2025 Dengfeng Liu <[email protected]>
*/

#ifndef AW_BPF_H
#define AW_BPF_H

#ifdef __KERNEL__
#include <linux/types.h>
#else
#include <stdint.h>
#endif

/**
* @struct counters
* @brief Structure to hold network traffic counters
*/
struct counters {
__u32 cur_s_bytes; /* Current session bytes */
__u32 prev_s_bytes; /* Previous session bytes */
__u64 total_bytes; /* Total bytes transferred */
__u64 total_packets; /* Total packets count */
__u32 est_slot; /* Estimation time slot */
__u32 reserved; /* Reserved for future use */
} __attribute__((packed));

/**
* @struct traffic_stats
* @brief Structure to maintain both incoming and outgoing traffic statistics
*/
struct traffic_stats {
struct counters incoming; /* Incoming traffic counters */
struct counters outgoing; /* Outgoing traffic counters */
} __attribute__((packed));

/* Function declarations if any would go here */

#endif /* AW_BPF_H */

0 comments on commit b654b1a

Please sign in to comment.