Packet resending + IP filtering issues

ahuguet at cttc.es ahuguet
Mon May 7 03:07:30 PDT 2007


Greetings,

as I've explained on former posts in this mailing list, I'm trying to
modify HostAP driver to perform some lab tests with it.

The main idea is that each station could hold a copy of the important data
sent by other stations, just so, if the original receiver station fails to
receive correctly a packet, it can ask for it to its nearer stations
rather than awaiting for the original station to resend the packet.

In order to achieve that, some steps have been made.
First, a check is done on the MAC header, and if the packet has both type
and subtype fields as data, the skb is copied and stored in a variable
called last_data_rx.

Station runs in promiscuous mode in order to get those packets addressed
to other stations.

Upon the reception of an specific MAC packet, with a reserved subtype
field, the station is meant to retransmit the last_data_rx skb.

Is at this point that my code fails, and causes a kernel crash (linux
freezes)
my first guess would be that there's a check somewhere done, and that
transmitting a packet that has origin different from the address of the
machine is sending data, causes crash.

I was also able to discover that lots of packets fall into the cathegory
of type and subtype data, so it wouldn't be odd that last_data_rx would
hold unneeded skb.

So another step would be to fine-tune the filter that makes the
last_data_rx copy.
The idea is, then, to only keep data which is TCP, for instance.

I've tried different approaches to achieve this, to no avail.

Inside function void hostap_80211_rx() after the switch (fc &
(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) is done:

1)

I tried checking skb->protocol, but its value seems unset,
printk(KERN_DEBUG "Protocol %d \n",skb->protocol); returns always 0

2)
( Used #include <linux/ip.h> )

I tried going to the IP header, to check for the protocol field.
if (skb->len > 40){
 if (skb->nh.raw != NULL) {
	memcpy (&protocol, skb->nh.raw+9,1); /* Protocol is u8 variable, and
protocol field is 9 Bytes after the start of IP header */
	printk(KERN_DEBUG "Protocol %d \n",protocol);
 }
 else
	printk(KERN_DEBUG "The pointer is NULL \n");

which seems to always be NULL.

3)
( Used #include <linux/ip.h> )

I tried using the skb->nh.iph structure, but it fails again, probably due
to the same reason that 2) fails.

4)

I then tried to access the IP header field directly, but seems I'm missing
something, since the printed numbers do not correspond to the expected
protocol types.

if (skb->len > 40){
 memcpy (&protocol,skb->data+20+9,1);
 printk(KERN_DEBUG "Protocol %d \n",protocol);
}

I add the 20, for the MAC header is 20 Bytes lenght, plus the 9 Bytes of
offset corresponding to the IP header that follows. Protocol is a field a
Byte lenght.

I'd welcome some hints as to what I'm doing wrong for the "fine" filter to
work as expected (retreiving correctly the protocol information) and also
regarding the failures on retransmitting stored packets (though this
latter issue might require some further explanation with code pasting)

Thanks in advance.





More information about the Hostap mailing list