mirror of
https://github.com/h3xduck/TripleCross.git
synced 2025-12-15 23:03:08 +08:00
Updated project structure, and added new list for the next incoming feature.
This commit is contained in:
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"time.h": "c"
|
||||
}
|
||||
}
|
||||
0
apps/.gitkeep
Normal file
0
apps/.gitkeep
Normal file
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@ LIBBPF_OBJ := $(abspath $(OUTPUT)/libbpf.a)
|
||||
VMLINUX := ./vmlinux/newvmlinux.h
|
||||
USER := user
|
||||
EBPF := ebpf
|
||||
COMMON_INCLUDES := -I$(abspath ./include)
|
||||
COMMON_INCLUDES := -I$(abspath ./ebpf/include) -I$(abspath ./user/include)
|
||||
# Use our own libbpf API headers and Linux UAPI headers distributed with
|
||||
# libbpf to avoid dependency on system-wide headers, which could be missing or
|
||||
# outdated
|
||||
|
||||
Binary file not shown.
@@ -20,7 +20,7 @@
|
||||
#include <bpf/bpf_tracing.h>
|
||||
#include <bpf/bpf_core_read.h>
|
||||
|
||||
#include "../user/xdp_filter.h"
|
||||
#include "../user/include/xdp_filter.h"
|
||||
#include "../constants/constants.h"
|
||||
|
||||
#include "packet/packet_manager.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <bpf/libbpf.h>
|
||||
#include "bootstrap.h"
|
||||
#include "include/bootstrap.h"
|
||||
#include "bootstrap.skel.h"
|
||||
|
||||
static struct env {
|
||||
|
||||
54
src/user/utils/structures/fdlist.c
Normal file
54
src/user/utils/structures/fdlist.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "fdlist.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief Creates a new fdlist with a given size
|
||||
*
|
||||
* @param size
|
||||
* @return FdList
|
||||
*/
|
||||
FdList FdList_create(int size){
|
||||
FdList *fd_list = (FdList*)calloc(1, sizeof(FdList));
|
||||
fd_list->max_size = size;
|
||||
fd_list->size = 0;
|
||||
fd_list->list = (int*)calloc(size, sizeof(int));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Adds a new fd to the list
|
||||
*
|
||||
* @param fd_list
|
||||
* @param fd_new
|
||||
* @return 0 ok, -1 error
|
||||
*/
|
||||
int FdList_add(FdList *fd_list, int fd_new){
|
||||
if(fd_list->size+1 >= fd_list->max_size){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Extends size of list
|
||||
*
|
||||
* @param fd_list
|
||||
* @param new_size
|
||||
* @return int
|
||||
*/
|
||||
int FdList_extend(FdList *fd_list, int new_size){
|
||||
fd_list->list = (int*)realloc(fd_list->list, new_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Destroy list
|
||||
*
|
||||
* @param fd_list
|
||||
* @return int
|
||||
*/
|
||||
int FdList_destroy(FdList *fd_list){
|
||||
free(fd_list->list);
|
||||
free(fd_list);
|
||||
}
|
||||
20
src/user/utils/structures/fdlist.h
Normal file
20
src/user/utils/structures/fdlist.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef __FDLIST_H
|
||||
#define __FDLIST_H
|
||||
|
||||
typedef struct FdList{
|
||||
int size;
|
||||
int max_size;
|
||||
int* list;
|
||||
|
||||
} FdList;
|
||||
|
||||
FdList FdList_create(int size);
|
||||
|
||||
int FdList_add(FdList *fd_list, int fd_new);
|
||||
|
||||
int FdList_extend(FdList *fd_list, int new_size);
|
||||
|
||||
int FdList_destroy(FdList *fd_list);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "xdp_filter.skel.h"
|
||||
#include "xdp_filter.h"
|
||||
#include "include/xdp_filter.h"
|
||||
#include "../constants/constants.h"
|
||||
|
||||
static struct env {
|
||||
|
||||
Reference in New Issue
Block a user