mirror of
https://github.com/CHN-beta/xmurp-ua.git
synced 2026-01-11 17:29:28 +08:00
搞定了编译时警告和错误
This commit is contained in:
2
Makefile
2
Makefile
@@ -9,7 +9,7 @@ include $(INCLUDE_DIR)/package.mk
|
||||
EXTRA_CFLAGS:= \
|
||||
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
|
||||
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
|
||||
-DVERSION='"$(PKG_RELEASE)"' --verbose
|
||||
-DVERSION="\"\\\"$(PKG_RELEASE)\\\"\"" --verbose
|
||||
|
||||
MAKE_OPTS:=$(KERNEL_MAKE_FLAGS) \
|
||||
SUBDIRS="$(PKG_BUILD_DIR)" \
|
||||
|
||||
15
src/rkp-ua.c
15
src/rkp-ua.c
@@ -6,14 +6,25 @@ static time_t last_flush;
|
||||
|
||||
unsigned int hook_funcion(void *priv, struct sk_buff *skb, const struct nf_hook_state *state)
|
||||
{
|
||||
u_int8_t rtn;
|
||||
static u_int8_t crashed = 0;
|
||||
unsigned rtn;
|
||||
static bool crashed = 0;
|
||||
|
||||
static unsigned n_skb_captured = 0, n_skb_captured_lastPrint = 1;
|
||||
|
||||
if(crashed)
|
||||
return NF_ACCEPT;
|
||||
if(!rkpSettings_capture(skb))
|
||||
return NF_ACCEPT;
|
||||
|
||||
rtn = rkpManager_execute(rkpm, skb);
|
||||
|
||||
n_skb_captured++;
|
||||
if(n_skb_captured == n_skb_captured_lastPrint * 2)
|
||||
{
|
||||
printk("rkp-ua: Captured %d packages.\n", n_skb_captured);
|
||||
n_skb_captured_lastPrint *= 2;
|
||||
}
|
||||
|
||||
if(rtn == NF_DROP_ERR(1))
|
||||
{
|
||||
printk("rkp-ua: Crashed.\n");
|
||||
|
||||
@@ -92,11 +92,8 @@ u_int8_t rkpManager_execute(struct rkpManager* rkpm, struct sk_buff* skb)
|
||||
return rkpStream_execute(rkps, skb);
|
||||
else
|
||||
rkps = rkps -> next;
|
||||
if(rkps == 0)
|
||||
{
|
||||
printk("rkp-ua::rkpStream::rkpStream_execute: Target stream not found.\n");
|
||||
return NF_DROP;
|
||||
}
|
||||
printk("rkp-ua::rkpStream::rkpStream_execute: Target stream not found.\n");
|
||||
return NF_DROP;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ struct sk_buff* __rkpStream_buff_find(const struct sk_buff*, u_int32_t);
|
||||
|
||||
void __rkpStream_buff_execute_core(struct sk_buff**, u_int16_t, bool); // 最核心的步骤,集齐头部后被调用。搜索、替换。参数分别为:数据包链表、最后一个包中 http 头结束的位置、是否保留指定 ua
|
||||
|
||||
struct rkpStream* rpStream_new(const struct sk_buff* skb)
|
||||
struct rkpStream* rkpStream_new(const struct sk_buff* skb)
|
||||
{
|
||||
struct rkpStream* rkps = kmalloc(sizeof(struct rkpStream), GFP_KERNEL);
|
||||
const struct iphdr* iph = ip_hdr(skb);
|
||||
@@ -271,7 +271,7 @@ unsigned char* __rkpStream_skb_appBegin(const struct sk_buff* skb)
|
||||
return (unsigned char*)tcp_hdr(skb) + tcp_hdr(skb) -> doff * 4;
|
||||
}
|
||||
|
||||
u_int16_t __rkpStream_dataLen(const struct sk_buff* skb)
|
||||
u_int16_t __rkpStream_skb_appLen(const struct sk_buff* skb)
|
||||
{
|
||||
return ntohs(ip_hdr(skb) -> tot_len) - ip_hdr(skb) -> ihl * 4 - tcp_hdr(skb) -> doff * 4;
|
||||
}
|
||||
@@ -500,7 +500,7 @@ void __rkpStream_buff_execute_core(struct sk_buff** buff, u_int16_t last_len, bo
|
||||
{
|
||||
unsigned char* replace_begin;
|
||||
u_int16_t replace_len;
|
||||
if(skb_ensure_writable(p, replace_begin + replace_len - p -> data) != 0)
|
||||
if(skb_ensure_writable(p, __rkpStream_skb_appBegin(p) + __rkpStream_skb_appLen(p) - p -> data) != 0)
|
||||
{
|
||||
printk("rkp-ua::rkpStream::__rkpStream_buff_execute_core: Can not make skb writable, may caused by shortage of memory. Ignore it.\n");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user