Skip to content

Commit faf7c49

Browse files
committed
codelab: fe: apply compatibility fixes
1 parent 9e721c6 commit faf7c49

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

codelab/fe.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
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
5658
pkt_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

7880
static void

0 commit comments

Comments
 (0)