wlantest: Add -F option for assuming FCS is included
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 17 Jan 2013 10:55:30 +0000 (12:55 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 17 Jan 2013 10:55:30 +0000 (12:55 +0200)
When using DLT_IEEE802_11 datalink type in a pcap file, wlantest can now
be instructed to assume there is an FCS included in the frame by adding
the new -F command line argument. This will make wlantest validate the
FCS and strip it from the frame before processing.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

wlantest/process.c
wlantest/wlantest.c
wlantest/wlantest.h

index 609a23a..a788a36 100644 (file)
@@ -380,5 +380,19 @@ void wlantest_process_prism(struct wlantest *wt, const u8 *data, size_t len)
 void wlantest_process_80211(struct wlantest *wt, const u8 *data, size_t len)
 {
        wpa_hexdump(MSG_EXCESSIVE, "Process data", data, len);
+
+       if (wt->assume_fcs && len >= 4) {
+               const u8 *fcspos;
+
+               len -= 4;
+               fcspos = data + len;
+               if (check_fcs(data, len, fcspos) < 0) {
+                       wpa_printf(MSG_EXCESSIVE, "Drop RX frame with invalid "
+                                  "FCS");
+                       wt->fcs_error++;
+                       return;
+               }
+       }
+
        rx_frame(wt, data, len);
 }
index 094ed17..9856d6b 100644 (file)
@@ -25,7 +25,7 @@ static void wlantest_terminate(int sig, void *signal_ctx)
 
 static void usage(void)
 {
-       printf("wlantest [-cddhqq] [-i<ifname>] [-r<pcap file>] "
+       printf("wlantest [-cddhqqF] [-i<ifname>] [-r<pcap file>] "
               "[-p<passphrase>]\n"
                "         [-I<wired ifname>] [-R<wired pcap file>] "
               "[-P<RADIUS shared secret>]\n"
@@ -208,7 +208,7 @@ int main(int argc, char *argv[])
        wlantest_init(&wt);
 
        for (;;) {
-               c = getopt(argc, argv, "cdf:hi:I:p:P:qr:R:w:W:");
+               c = getopt(argc, argv, "cdf:Fhi:I:p:P:qr:R:w:W:");
                if (c < 0)
                        break;
                switch (c) {
@@ -223,6 +223,9 @@ int main(int argc, char *argv[])
                        if (add_pmk_file(&wt, optarg) < 0)
                                return -1;
                        break;
+               case 'F':
+                       wt.assume_fcs = 1;
+                       break;
                case 'h':
                        usage();
                        return 0;
index b04e9d0..ab645a8 100644 (file)
@@ -175,6 +175,8 @@ struct wlantest {
        u8 last_hdr[30];
        size_t last_len;
        int last_mgmt_valid;
+
+       unsigned int assume_fcs:1;
 };
 
 int add_wep(struct wlantest *wt, const char *key);