snep: Fix Android's handover over SNEP support
authorOlivier Guiter <olivier.guiter@linux.intel.com>
Mon, 11 Feb 2013 15:52:33 +0000 (16:52 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 12 Feb 2013 19:13:03 +0000 (20:13 +0100)
Android does handover over SNEP and recent changes broke the offset used
to check the handover frame validity.

plugins/snep-core.h
plugins/snep.c

index f39b28a..08569d4 100644 (file)
 
 #define SNEP_REQ_PUT_HEADER_LENGTH     6
 #define SNEP_REQ_GET_HEADER_LENGTH     10
+
 /* Default SNEP Resp message header length: Version + code + len */
 #define SNEP_RESP_HEADER_LENGTH                (1 + 1 + 4)
 
+/* Offset of 'H' in Android frame: 3 is the offset in NDEF */
+#define SNEP_REQ_ANDROID               (SNEP_ACC_LENGTH_SIZE + 3)
+
 
 /* TODO: Right now it is dummy, need to get correct value
  * from lower layers */
index b7ca24c..6e6ba5f 100644 (file)
@@ -92,8 +92,13 @@ static near_bool_t snep_default_server_req_get(int client_fd, void *data)
 
        DBG("");
 
-       /* Check if this is a handover request or not ... */
-       if (*(snep_data->nfc_data + 4 + 9) != 'H') {
+       /*
+        * Check if this is a handover request or not ...
+        * snep_data->nfc_data points to the acceptable length field (4 bytes)
+        * and we check the 3 byte in the NDEF message
+        * */
+
+       if (*(snep_data->nfc_data + SNEP_REQ_ANDROID) != 'H') {
                snep_core_response_noinfo(client_fd, SNEP_RESP_NOT_IMPL);
        } else {
                snep_core_parse_handover_record(client_fd, snep_data->nfc_data +