File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818#include <net/netmap.h>
1919#define NETMAP_WITH_LIBS
2020#include <net/netmap_user.h>
21- #include <netinet/ether.h>
21+ #include <sys/socket.h>
22+ #include <netinet/in.h>
23+ #include <netinet/if_ether.h>
2224#include <netinet/ip.h>
2325#include <netinet/udp.h>
2426#include <netinet/tcp.h>
@@ -56,23 +58,23 @@ static inline int
5658pkt_get_udp_port (const char * buf )
5759{
5860 struct ether_header * ethh ;
59- struct iphdr * iph ;
61+ struct ip * iph ;
6062 struct udphdr * udph ;
6163
6264 ethh = (struct ether_header * )buf ;
6365 if (ethh -> ether_type != htons (ETHERTYPE_IP )) {
6466 /* Filter out non-IP traffic. */
6567 return 0 ;
6668 }
67- iph = (struct iphdr * )(ethh + 1 );
68- if (iph -> protocol != IPPROTO_UDP ) {
69+ iph = (struct ip * )(ethh + 1 );
70+ if (iph -> ip_p != IPPROTO_UDP ) {
6971 /* Filter out non-UDP traffic. */
7072 return 0 ;
7173 }
7274 udph = (struct udphdr * )(iph + 1 );
7375
7476 /* Return destination port. */
75- return ntohs (udph -> dest );
77+ return ntohs (udph -> uh_dport );
7678}
7779
7880static void
You can’t perform that action at this time.
0 commit comments