我有一个捕获TCP数据包的Netfilter模块。Netfilter编辑TCP有效负载时崩溃
然后我访问数据有效载荷,然后替换一些单词。但是,它偶尔会出现错误,然后挂断。然后,数据包不能再通过...
只有带有端口80的TCP数据包才会通过。
数据由data = (char *)((unsigned char *)tcp_header + (tcp_header->doff * 4));
while(strstr(data, "the") != NULL){
data = replace_str(data, "the", "REDACTED", 0);
//censors the word "the" and replaces with "REDACTED"
}
printk("Port 80 Web Data:\n %s \n",data);
什么是'replace_str'函数?根据它的名字,它应该将一个字符串替换为另一个字符串,但是如果替换字符串的长度不同会怎样? – Tsyvarev