189f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach/******************************************************************************
289f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *
389f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *  Copyright (C) 2015 Google Inc.
489f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *
589f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *  Licensed under the Apache License, Version 2.0 (the "License");
689f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *  you may not use this file except in compliance with the License.
789f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *  You may obtain a copy of the License at:
889f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *
989f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *  http://www.apache.org/licenses/LICENSE-2.0
1089f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *
1189f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *  Unless required by applicable law or agreed to in writing, software
1289f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *  distributed under the License is distributed on an "AS IS" BASIS,
1389f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1489f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *  See the License for the specific language governing permissions and
1589f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *  limitations under the License.
1689f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach *
1789f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach ******************************************************************************/
1889f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach
1989f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach#pragma once
2089f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach
2189f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach#include <stdint.h>
2289f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach
2389f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach#define BTSNOOZ_CURRENT_VERSION 0x01
2489f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach
2589f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach// The preamble is stored un-encrypted as the first part
2689f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach// of the file.
2789f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbachtypedef struct btsnooz_preamble_t {
2889f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach  uint8_t version;
2989f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach  uint64_t last_timestamp_ms;
3089f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach} __attribute__((__packed__)) btsnooz_preamble_t;
3189f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach
3289f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach// One header for each HCI packet
3389f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbachtypedef struct btsnooz_header_t {
3489f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach  uint16_t length;
3589f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach  uint32_t delta_time_ms;
3689f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach  uint8_t type;
3789f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach} __attribute__((__packed__)) btsnooz_header_t;
3889f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach
3989f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach// Initializes btsnoop memory logging and registers
4089f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbachvoid btif_debug_btsnoop_init(void);
4189f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach
4289f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbach// Writes btsnoop data base64 encoded to fd
4389f5e411d9ef31436741288a2267e46dd744e273Andre Eisenbachvoid btif_debug_btsnoop_dump(int fd);
44