1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
/* Metageek WiSPY network protocol interface
* Mike Kershaw/Dragorn <dragorn@kismetwireless.net>
*
* Generic WiSPY userspace container for the Metageek WiSPY
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Extra thanks to Ryan Woodings @ Metageek for interface documentation
*/
/*
* Implementation of the wispy network protocol
* {published url goes here}
*
* All multibyte values are expected to be big-endian
*
* Frames may contain multiple blocks. These blocks must be of the same
* type. Stacking is at the discretion of the sender, and is intended for
* optimization to the TCP window size
*
* All sub-frame types contain a total frame length for future expandability.
*
* !!! NOTE !!!
* THIS IS NOT THE FINAL WISPY PROTOCOL, DON'T USE THIS EXPECTING IT TO STAY
* THE SAME, THIS IS KLUGED TOGETHER AS A PROTOTYPE BEFORE THE FINAL PROTOCOL
* IS DEFINED BY METAGEEK.
*
*/
#ifndef __WISPY_NET_H__
#define __WISPY_NET_H__
#include "config.h"
#ifdef HAVE_STDINT
#include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
/* WiSPY Network Protocol
*
* Multiple (homogenous) subframes may be aggregated into a single frame
* header at the discretion of the server in order to optimize packing into
* frames.
*
* Subframes of different types cannot be mixed in a single header.
*/
#define WISPY_NET_FRAME_DEVICE 0x00
#define WISPY_NET_FRAME_SWEEP 0x01
#define WISPY_NET_FRAME_COMMAND 0x02
#define WISPY_NET_FRAME_MESSAGE 0x03
#define WISPY_NET_SENTINEL 0xDECAFBAD
#define WISPY_NET_PROTO_VERSION 0x01
#define WISPY_NET_DEFAULT_PORT 30569
typedef struct _wispy_fr_header {
uint32_t sentinel;
uint16_t frame_len;
uint8_t proto_version;
uint8_t block_type;
uint8_t num_blocks;
uint8_t data[0];
} __attribute__ ((packed)) wispy_fr_header;
/* Size of a container header */
#define wispy_fr_header_size() (sizeof(wispy_fr_header))
#define WISPY_NET_SWEEPTYPE_CUR 0x01
#define WISPY_NET_SWEEPTYPE_AVG 0x02
#define WISPY_NET_SWEEPTYPE_PEAK 0x03
typedef struct _wispy_fr_sweep {
uint16_t frame_len;
uint32_t device_id;
uint8_t sweep_type;
uint32_t start_sec;
uint32_t start_usec;
uint8_t sample_data[0];
} __attribute__ ((packed)) wispy_fr_sweep;
/* Size of a sweep of N samples */
#define wispy_fr_sweep_size(x) (sizeof(wispy_fr_sweep) + (x))
#define WISPY_NET_DEVTYPE_USB1 0x01
#define WISPY_NET_DEVTYPE_USB2 0x02
#define WISPY_NET_DEVTYPE_LASTDEV 0xFF
#define WISPY_NET_DEVFLAG_NONE 0x00
#define WISPY_NET_DEVFLAG_VARSWEEP 0x01
#define WISPY_NET_DEVFLAG_LOCKED 0x02
typedef struct _wispy_fr_device {
uint16_t frame_len;
uint8_t device_version;
uint16_t device_flags;
uint32_t device_id;
uint8_t device_name_len;
uint8_t device_name[256];
uint32_t amp_offset_mdbm;
uint32_t amp_res_mdbm;
uint16_t rssi_max;
uint32_t def_start_khz;
uint32_t def_res_hz;
uint16_t def_num_samples;
uint32_t start_khz;
uint32_t res_hz;
uint16_t num_samples;
} __attribute__ ((packed)) wispy_fr_device;
/* Size of a device frame of N sample definitions */
#define wispy_fr_device_size() (sizeof(wispy_fr_device))
#define WISPY_NET_TXTTYPE_INFO 0x00
#define WISPY_NET_TXTTYPE_ERROR 0x01
#define WISPY_NET_TXTTYPE_FATAL 0x02
typedef struct _wispy_fr_txtmessage {
uint16_t frame_len;
uint8_t message_type;
uint16_t message_len;
uint8_t message[0];
} __attribute__ ((packed)) wispy_fr_txtmessage;
/* Size of a text message of N characters */
#define wispy_fr_txtmessage_size(x) (sizeof(wispy_fr_txtmessage) + (x))
#define WISPY_NET_COMMAND_NULL 0x00
#define WISPY_NET_COMMAND_ENABLEDEV 0x01
#define WISPY_NET_COMMAND_DISABLEDEV 0x02
#define WISPY_NET_COMMAND_SETSCAN 0x03
#define WISPY_NET_COMMAND_LOCK 0x04
#define WISPY_NET_COMMAND_UNLOCK 0x05
typedef struct _wispy_fr_command {
uint16_t frame_len;
uint8_t command_id;
uint16_t command_len;
uint8_t command_data[0];
} __attribute__ ((packed)) wispy_fr_command;
#define wispy_fr_command_size(x) (sizeof(wispy_fr_command) + (x))
typedef struct _wispy_fr_command_enabledev {
uint32_t device_id;
} __attribute__ ((packed)) wispy_fr_command_enabledev;
#define wispy_fr_command_enabledev_size(x) (sizeof(wispy_fr_command_enabledev))
typedef struct _wispy_fr_command_disabledev {
uint32_t device_id;
} __attribute__ ((packed)) wispy_fr_command_disabledev;
#define wispy_fr_command_disabledev_size(x) (sizeof(wispy_fr_command_disabledev))
typedef struct _wispy_fr_command_setscan {
uint32_t device_id;
uint32_t start_khz;
uint32_t res_hz;
uint32_t filter_bw_hz;
uint16_t sweep_points;
uint8_t lock_dev;
} __attribute__ ((packed)) wispy_fr_command_setscan;
#define wispy_fr_command_setscan_size(x) (sizeof(wispy_fr_command_setscan))
typedef struct _wispy_fr_command_lockdev {
uint32_t device_id;
} __attribute__ ((packed)) wispy_fr_command_lockdev;
#define wispy_fr_command_lockdev_size(x) (sizeof(wispy_fr_command_lockdev))
typedef struct _wispy_fr_command_unlockdev {
uint32_t device_id;
} __attribute__ ((packed)) wispy_fr_command_unlockdev;
#define wispy_fr_command_unlockdev_size(x) (sizeof(wispy_fr_command_unlockdev))
typedef struct _wispy_fr_broadcast {
uint32_t sentinel;
uint8_t version;
uint16_t server_port;
} __attribute__ ((packed)) wispy_fr_broadcast;
#endif
|