mirror of
https://github.com/h3xduck/TripleCross.git
synced 2026-01-11 18:33:07 +08:00
Further refactored code and dealt with the verifier issues with string comparisons
This commit is contained in:
@@ -27,6 +27,13 @@ static __always_inline int tcp_header_bound_check(struct tcphdr* tcp, void* data
|
||||
return 0; //OK
|
||||
}
|
||||
|
||||
static __always_inline int tcp_payload_bound_check(char* payload, int payload_size, void* data_end){
|
||||
if ((void *)payload + payload_size > data_end){
|
||||
return -1;
|
||||
}
|
||||
return 0; //OK
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* UTILITIES */
|
||||
@@ -44,4 +51,8 @@ static __always_inline int get_protocol(void* data){
|
||||
}
|
||||
}
|
||||
|
||||
static __always_inline unsigned char* get_payload(struct tcphdr *tcp){
|
||||
return (void *)tcp + tcp->doff*4;
|
||||
}
|
||||
|
||||
#endif
|
||||
16
src/include/packet/protocol/tcp_helper.h
Normal file
16
src/include/packet/protocol/tcp_helper.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef __TCP_HELPER_H__
|
||||
#define __TCP_HELPER_H__
|
||||
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/ip.h>
|
||||
|
||||
|
||||
static __always_inline int get_tcp_src_port(struct tcphdr *tcp){
|
||||
return ntohs(tcp->source);
|
||||
}
|
||||
|
||||
static __always_inline int get_tcp_dest_port(struct tcphdr *tcp){
|
||||
return ntohs(tcp->dest);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user