ndef: Send empty Hs frame when the Hr version check fails
authorOlivier Guiter <olivier.guiter@linux.intel.com>
Mon, 11 Feb 2013 15:52:30 +0000 (16:52 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 12 Feb 2013 19:12:23 +0000 (20:12 +0100)
This fixes handover validation test #3.

Verify that the remote handover server handles historic and future
handover request version numbers. The test failed on step 4
(Check version 15.0).

src/ndef.c

index 03604bc..081bbf7 100644 (file)
@@ -2096,7 +2096,7 @@ static struct near_ndef_ho_payload *parse_ho_payload(enum record_type rec_type,
            HANDOVER_MAJOR(HANDOVER_VERSION)) {
                near_error("Unsupported version (%d)", ho_payload->version);
                /* Skip parsing and return an empty record */
-               return ho_payload;
+               goto empty_hs;
        }
 
        offset = offset + 1;
@@ -2226,6 +2226,21 @@ static struct near_ndef_ho_payload *parse_ho_payload(enum record_type rec_type,
                g_free(trec);
        }
 
+empty_hs:
+       /*
+        * If there's no ac AND mimes BUT a reply ptr
+        * we have to fill the reply with a message containing
+        * zero alternative carriers.
+        */
+       if ((acs == NULL) && (mimes == NULL)) {
+               if (reply != NULL) {
+                       struct near_ndef_record rec;
+                       rec.ho = ho_payload;
+                       *reply = near_ndef_prepare_handover_record("Hs",
+                                       &rec, NEAR_CARRIER_EMPTY, NULL);
+               }
+       }
+
        if ((acs == NULL) || (mimes == NULL))
                return ho_payload;