File tree 2 files changed +16
-12
lines changed
2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 15
15
#include <net/netmap.h>
16
16
#define NETMAP_WITH_LIBS
17
17
#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>
19
21
#include <netinet/ip.h>
20
22
#include <netinet/udp.h>
21
23
#include <netinet/tcp.h>
@@ -51,7 +53,7 @@ static inline int
51
53
pkt_select (const char * buf , int udp_port )
52
54
{
53
55
struct ether_header * ethh ;
54
- struct iphdr * iph ;
56
+ struct ip * iph ;
55
57
struct udphdr * udph ;
56
58
57
59
if (udp_port == 0 ) {
@@ -63,15 +65,15 @@ pkt_select(const char *buf, int udp_port)
63
65
/* Filter out non-IP traffic. */
64
66
return 0 ;
65
67
}
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 ) {
68
70
/* Filter out non-UDP traffic. */
69
71
return 0 ;
70
72
}
71
73
udph = (struct udphdr * )(iph + 1 );
72
74
73
75
/* Match the destination port. */
74
- if (udph -> dest != htons (udp_port )) {
76
+ if (udph -> uh_dport != htons (udp_port )) {
75
77
return 0 ;
76
78
}
77
79
Original file line number Diff line number Diff line change 15
15
#include <net/netmap.h>
16
16
#define NETMAP_WITH_LIBS
17
17
#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>
19
21
#include <netinet/ip.h>
20
22
#include <netinet/udp.h>
21
23
#include <netinet/tcp.h>
@@ -53,7 +55,7 @@ static inline int
53
55
pkt_udp_port_swap (char * buf )
54
56
{
55
57
struct ether_header * ethh ;
56
- struct iphdr * iph ;
58
+ struct ip * iph ;
57
59
struct udphdr * udph ;
58
60
uint16_t tmp ;
59
61
@@ -62,15 +64,15 @@ pkt_udp_port_swap(char *buf)
62
64
/* Filter out non-IP traffic. */
63
65
return 0 ;
64
66
}
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 ) {
67
69
/* Filter out non-UDP traffic. */
68
70
return 0 ;
69
71
}
70
72
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 ;
74
76
75
77
return 1 ;
76
78
}
You can’t perform that action at this time.
0 commit comments