aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/rx_ip.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-01-02 17:12:33 (GMT)
committerJouni Malinen <j@w1.fi>2020-01-02 17:17:10 (GMT)
commita8b00423eabc80eb12f9d17243d3d2aa0d5bac33 (patch)
tree1ee26c90dee9da478a6b4fb8b77e3dfb09879550 /wlantest/rx_ip.c
parent3ea58a05485f7ccdc13973bce676d1896d0a6a5e (diff)
downloadhostap-a8b00423eabc80eb12f9d17243d3d2aa0d5bac33.zip
hostap-a8b00423eabc80eb12f9d17243d3d2aa0d5bac33.tar.gz
hostap-a8b00423eabc80eb12f9d17243d3d2aa0d5bac33.tar.bz2
BSD: Use struct ip rather than struct iphdr
As we define __FAVOR_BSD use the BSD IP header. Compile tested on NetBSD, DragonFlyBSD, and Linux. Signed-off-by: Roy Marples <roy@marples.name>
Diffstat (limited to 'wlantest/rx_ip.c')
-rw-r--r--wlantest/rx_ip.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/wlantest/rx_ip.c b/wlantest/rx_ip.c
index 19b338b..0e833ec 100644
--- a/wlantest/rx_ip.c
+++ b/wlantest/rx_ip.c
@@ -116,62 +116,62 @@ void rx_data_ip(struct wlantest *wt, const u8 *bssid, const u8 *sta_addr,
const u8 *dst, const u8 *src, const u8 *data, size_t len,
const u8 *peer_addr)
{
- const struct iphdr *ip;
+ const struct ip *ip;
const u8 *payload;
size_t plen;
- u16 frag_off, tot_len;
+ uint16_t frag_off, ip_len;
- ip = (const struct iphdr *) data;
+ ip = (const struct ip *) data;
if (len < sizeof(*ip))
return;
- if (ip->version != 4) {
+ if (ip->ip_v != 4) {
if (hwsim_test_packet(data, len)) {
add_note(wt, MSG_INFO, "hwsim_test package");
return;
}
add_note(wt, MSG_DEBUG, "Unexpected IP protocol version %u in "
"IPv4 packet (bssid=" MACSTR " str=" MACSTR
- " dst=" MACSTR ")", ip->version, MAC2STR(bssid),
+ " dst=" MACSTR ")", ip->ip_v, MAC2STR(bssid),
MAC2STR(src), MAC2STR(dst));
return;
}
- if (ip->ihl * 4 < sizeof(*ip)) {
+ if (ip->ip_hl * 4 < sizeof(*ip)) {
add_note(wt, MSG_DEBUG, "Unexpected IP header length %u in "
"IPv4 packet (bssid=" MACSTR " str=" MACSTR
- " dst=" MACSTR ")", ip->ihl, MAC2STR(bssid),
+ " dst=" MACSTR ")", ip->ip_hl, MAC2STR(bssid),
MAC2STR(src), MAC2STR(dst));
return;
}
- if (ip->ihl * 4 > len) {
+ if (ip->ip_hl * 4 > len) {
add_note(wt, MSG_DEBUG, "Truncated IP header (ihl=%u len=%u) "
"in IPv4 packet (bssid=" MACSTR " str=" MACSTR
- " dst=" MACSTR ")", ip->ihl, (unsigned) len,
+ " dst=" MACSTR ")", ip->ip_hl, (unsigned) len,
MAC2STR(bssid), MAC2STR(src), MAC2STR(dst));
return;
}
- /* TODO: check header checksum in ip->check */
+ /* TODO: check header checksum in ip->ip_sum */
- frag_off = be_to_host16(ip->frag_off);
+ frag_off = be_to_host16(ip->ip_off);
if (frag_off & 0x1fff) {
wpa_printf(MSG_EXCESSIVE, "IP fragment reassembly not yet "
"supported");
return;
}
- tot_len = be_to_host16(ip->tot_len);
- if (tot_len > len)
+ ip_len = be_to_host16(ip->ip_len);
+ if (ip_len > len)
return;
- if (tot_len < len)
- len = tot_len;
+ if (ip_len < len)
+ len = ip_len;
- payload = data + 4 * ip->ihl;
- plen = len - 4 * ip->ihl;
+ payload = data + 4 * ip->ip_hl;
+ plen = len - 4 * ip->ip_hl;
- switch (ip->protocol) {
+ switch (ip->ip_p) {
case IPPROTO_ICMP:
- rx_data_icmp(wt, bssid, sta_addr, ip->daddr, ip->saddr,
- payload, plen, peer_addr);
+ rx_data_icmp(wt, bssid, sta_addr, ip->ip_dst.s_addr,
+ ip->ip_src.s_addr, payload, plen, peer_addr);
break;
}
}