Fixed the whole header setup, now correctly using the kernel headers instead of normal development ones. Ready to go on with original plan of file system hooking

This commit is contained in:
h3xduck
2022-01-06 13:31:52 -05:00
parent 4882ce790c
commit 193d9ec28f
16 changed files with 128072 additions and 50 deletions

View File

@@ -1,9 +1,10 @@
#ifndef __PACKET_MANAGER_H__
#define __PACKET_MANAGER_H__
#include <linux/bpf.h>
/*#include <linux/bpf.h>
#include <linux/if_ether.h>
#include <linux/if.h>
#include <linux/limits.h>
#include <linux/limits.h>*/
#include "newnewvmlinux.h"
/* BOUND CHECKING*/

View File

@@ -1,12 +1,13 @@
#ifndef __IP_HELPER_H__
#define __IP_HELPER_H__
#include <linux/ip.h>
/*#include <linux/ip.h>
#include <linux/types.h>
#include <linux/bpf.h>
#include <linux/bpf.h>*/
#include <bpf/bpf_endian.h>
#include <bpf/bpf_helpers.h>
#include "newnewvmlinux.h"
/**
* IP checksum calculation.
@@ -22,7 +23,7 @@ static __always_inline unsigned short checksum(unsigned short *addr, int nbytes)
nbytes -= 2;
}
if(nbytes>0){
sum +=htons((unsigned char)*addr);
sum +=bpf_htons((unsigned char)*addr);
}
while (sum>>16){

View File

@@ -1,16 +1,16 @@
#ifndef __TCP_HELPER_H__
#define __TCP_HELPER_H__
#include <linux/tcp.h>
#include <linux/ip.h>
/*#include <linux/tcp.h>
#include <linux/ip.h>*/
#include "newnewvmlinux.h"
static __always_inline int get_tcp_src_port(struct tcphdr *tcp){
return ntohs(tcp->source);
return bpf_ntohs(tcp->source);
}
static __always_inline int get_tcp_dest_port(struct tcphdr *tcp){
return ntohs(tcp->dest);
return bpf_ntohs(tcp->dest);
}
/**
@@ -27,7 +27,7 @@ static __always_inline unsigned short tcp_checksum(unsigned short *addr, int nby
nbytes -= 2;
}
if(nbytes>0){
sum += htons((unsigned char)*addr);
sum += bpf_htons((unsigned char)*addr);
}
while (sum>>16){