diff --git a/src/common.h b/src/common.h index 685f51f..900410c 100644 --- a/src/common.h +++ b/src/common.h @@ -11,7 +11,6 @@ #include #include #include -#include #include const static unsigned char* str_ua_begin = "User-Agent: "; diff --git a/src/rkpManager.h b/src/rkpManager.h index 7b83f93..f3cef40 100644 --- a/src/rkpManager.h +++ b/src/rkpManager.h @@ -41,6 +41,8 @@ void rkpManager_del(struct rkpManager* rkpm) u_int8_t rkpManager_execute(struct rkpManager* rkpm, struct sk_buff* skb) { + printk("syn %d ack %d\n", tcp_hdr(skb) -> syn, tcp_hdr(skb) -> ack); + printk("sport %d dport %d\n", tcp_hdr(skb) -> source, tcp_hdr(skb) -> dest); if(rkpSettings_first(skb)) // 新增加一个流或覆盖已经有的流 { @@ -80,12 +82,15 @@ u_int8_t rkpManager_execute(struct rkpManager* rkpm, struct sk_buff* skb) rkps_new -> next = rkpm -> data[id]; rkpm -> data[id] = rkps_new; } + + return NF_ACCEPT; } else // 使用已经有的流 { u_int8_t id = (ntohs(tcp_hdr(skb) -> source) + ntohs(tcp_hdr(skb) -> dest)) & 0xFF; struct rkpStream *rkps = rkpm -> data[id]; + printk("rkpStream_belong %d\n", rkpStream_belong(rkps, skb)); while(rkps != 0) if(rkpStream_belong(rkps, skb)) return rkpStream_execute(rkps, skb); diff --git a/src/rkpStream.h b/src/rkpStream.h index f86c41a..4fb81d7 100644 --- a/src/rkpStream.h +++ b/src/rkpStream.h @@ -76,13 +76,17 @@ void rkpStream_del(struct rkpStream* rkps) } bool rkpStream_belong(const struct rkpStream* rkps, const struct sk_buff* skb) { + printk("rkpStream_belong\n"); + printk("syn %d ack %d\n", tcp_hdr(skb) -> syn, tcp_hdr(skb) -> ack); + printk("sport %d dport %d\n", tcp_hdr(skb) -> source, tcp_hdr(skb) -> dest); + printk("rkpSettings_request %d\n", rkpSettings_request(skb)); if(rkpSettings_request(skb)) { if(rkps -> id[0] != ntohl(ip_hdr(skb) -> saddr)) return false; if(rkps -> id[1] != ntohl(ip_hdr(skb) -> daddr)) return false; - if(rkps -> id[2] != (ntohs(tcp_hdr(skb) -> source) << 16) + ntohs(tcp_hdr(skb) -> dest)) + if(rkps -> id[2] != ((u_int32_t)ntohs(tcp_hdr(skb) -> source) << 16) + ntohs(tcp_hdr(skb) -> dest)) return false; return true; } @@ -92,7 +96,7 @@ bool rkpStream_belong(const struct rkpStream* rkps, const struct sk_buff* skb) return false; if(rkps -> id[1] != ntohl(ip_hdr(skb) -> saddr)) return false; - if(rkps -> id[2] != (ntohs(tcp_hdr(skb) -> dest) << 16) + ntohs(tcp_hdr(skb) -> source)) + if(rkps -> id[2] != ((u_int32_t)ntohs(tcp_hdr(skb) -> dest) << 16) + ntohs(tcp_hdr(skb) -> source)) return false; return true; }