From efd8d7378b539a479b479582c59f798815fa613f Mon Sep 17 00:00:00 2001 From: wangyu Date: Tue, 11 Jul 2017 18:05:00 +0800 Subject: [PATCH] 7.11 commit --- main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.cpp b/main.cpp index 103afc2..07cb356 100644 --- a/main.cpp +++ b/main.cpp @@ -682,11 +682,20 @@ int on_raw_recv() size = recvfrom(raw_recv_fd, buf, buf_len, 0 ,&saddr , &saddr_size); + if(buf[13]!=8||buf[14]!=0) + { + printf("not an ipv4 packet!\n"); + fflush(stdout); + return 0; + } + char *ip_data=buf+14; struct iphdr *iph = (struct iphdr *) (ip_data); + + if (!(iph->ihl > 0 && iph->ihl < (MTU)/4)) { printf("iph ihl error"); fflush(stdout);