1c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi/******************************************************************************
2c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *
3c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *  Copyright (C) 2017 Google Inc.
4c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *
5c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *  Licensed under the Apache License, Version 2.0 (the "License");
6c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *  you may not use this file except in compliance with the License.
7c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *  You may obtain a copy of the License at:
8c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *
9c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *  http://www.apache.org/licenses/LICENSE-2.0
10c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *
11c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *  Unless required by applicable law or agreed to in writing, software
12c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *  distributed under the License is distributed on an "AS IS" BASIS,
13c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *  See the License for the specific language governing permissions and
15c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *  limitations under the License.
16c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi *
17c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi ******************************************************************************/
18c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi#ifndef _DEBUG_NFCSNOOP_
19c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi#define _DEBUG_NFCSNOOP_
20c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi
21c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi#include <stdint.h>
22c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi#include "nfc_target.h"
23c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi#include "nfc_types.h"
24c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi
25c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi#define NFCSNOOZ_CURRENT_VERSION 0x01
26c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi
27c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi// The preamble is stored un-encrypted as the first part
28c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi// of the file.
29c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoitypedef struct nfcsnooz_preamble_t {
30c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi  uint8_t version;
31c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi  uint64_t last_timestamp_ms;
32c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi} __attribute__((__packed__)) nfcsnooz_preamble_t;
33c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi
34c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi// One header for each NCI packet
35c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoitypedef struct nfcsnooz_header_t {
36c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi  uint16_t length;
37c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi  uint32_t delta_time_ms;
38c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi  uint8_t is_received;
39c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi} __attribute__((__packed__)) nfcsnooz_header_t;
40c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi
41c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi// Initializes nfcsnoop memory logging and registers
42c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoivoid debug_nfcsnoop_init(void);
43c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi
44c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi// Writes nfcsnoop data base64 encoded to fd
45c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoivoid debug_nfcsnoop_dump(int fd);
46c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi
47c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi// capture the packet
48c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoivoid nfcsnoop_capture(const NFC_HDR* packet, bool is_received);
49c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi
50c0cd1abf314c381ad47114d08a4a3d0750d7a797Ruchi Kandoi#endif /* _DEBUG_NFCSNOOP_ */
51