File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515#include <net/netmap.h>
1616#define NETMAP_WITH_LIBS
1717#include <net/netmap_user.h>
18- #include <netinet/ether.h>
18+ #include <sys/socket.h>
19+ #include <netinet/in.h>
20+ #include <netinet/if_ether.h>
1921#include <netinet/ip.h>
2022#include <netinet/udp.h>
2123#include <netinet/tcp.h>
@@ -51,7 +53,7 @@ static inline int
5153pkt_select (const char * buf , int udp_port )
5254{
5355 struct ether_header * ethh ;
54- struct iphdr * iph ;
56+ struct ip * iph ;
5557 struct udphdr * udph ;
5658
5759 if (udp_port == 0 ) {
@@ -63,15 +65,15 @@ pkt_select(const char *buf, int udp_port)
6365 /* Filter out non-IP traffic. */
6466 return 0 ;
6567 }
66- iph = (struct iphdr * )(ethh + 1 );
67- if (iph -> protocol != IPPROTO_UDP ) {
68+ iph = (struct ip * )(ethh + 1 );
69+ if (iph -> ip_p != IPPROTO_UDP ) {
6870 /* Filter out non-UDP traffic. */
6971 return 0 ;
7072 }
7173 udph = (struct udphdr * )(iph + 1 );
7274
7375 /* Match the destination port. */
74- if (udph -> dest != htons (udp_port )) {
76+ if (udph -> uh_dport != htons (udp_port )) {
7577 return 0 ;
7678 }
7779
Original file line number Diff line number Diff line change 1515#include <net/netmap.h>
1616#define NETMAP_WITH_LIBS
1717#include <net/netmap_user.h>
18- #include <netinet/ether.h>
18+ #include <sys/socket.h>
19+ #include <netinet/in.h>
20+ #include <netinet/if_ether.h>
1921#include <netinet/ip.h>
2022#include <netinet/udp.h>
2123#include <netinet/tcp.h>
@@ -53,7 +55,7 @@ static inline int
5355pkt_udp_port_swap (char * buf )
5456{
5557 struct ether_header * ethh ;
56- struct iphdr * iph ;
58+ struct ip * iph ;
5759 struct udphdr * udph ;
5860 uint16_t tmp ;
5961
@@ -62,15 +64,15 @@ pkt_udp_port_swap(char *buf)
6264 /* Filter out non-IP traffic. */
6365 return 0 ;
6466 }
65- iph = (struct iphdr * )(ethh + 1 );
66- if (iph -> protocol != IPPROTO_UDP ) {
67+ iph = (struct ip * )(ethh + 1 );
68+ if (iph -> ip_p != IPPROTO_UDP ) {
6769 /* Filter out non-UDP traffic. */
6870 return 0 ;
6971 }
7072 udph = (struct udphdr * )(iph + 1 );
71- tmp = udph -> source ;
72- udph -> source = udph -> dest ;
73- udph -> dest = tmp ;
73+ tmp = udph -> uh_sport ;
74+ udph -> uh_sport = udph -> uh_dport ;
75+ udph -> uh_dport = tmp ;
7476
7577 return 1 ;
7678}
You can’t perform that action at this time.
0 commit comments