Merge pull request #1795 from g-oikonomou/contrib/sensniff

Add generic sensniff example and remove legacy sniffers
This commit is contained in:
Antonio Lignan 2016-08-16 14:47:17 +02:00 committed by GitHub
commit 7ddbe640be
53 changed files with 1180 additions and 959 deletions

View file

@ -57,20 +57,6 @@ static RIE_BaseConfigs base_config = ADUCRF101_RADIO_BASE_CONFIG;
static int current_channel = 915000000;
static int current_power = 31;
static int radio_is_on = 0;
/*---------------------------------------------------------------------------*/
/* Sniffer configuration. We can re-use the CC2538 sniffer application
if we also accept CC2538_RF_CONF_SNIFFER. */
#ifndef ADUCRF101_RF_CONF_SNIFFER
#if CC2538_RF_CONF_SNIFFER
#define ADUCRF101_RF_CONF_SNIFFER 1
#endif
#endif
#if ADUCRF101_RF_CONF_SNIFFER
#include "dev/uart.h"
static const uint8_t magic[] = { 0x53, 0x6E, 0x69, 0x66 }; /* Snif */
#endif
/*---------------------------------------------------------------------------*/
/* "Channel" is really frequency, and can be within the bands:
431000000 Hz to 464000000 Hz
@ -246,20 +232,6 @@ read(void *buf, unsigned short buf_len)
/* Re-enter receive mode immediately after receiving a packet */
RadioRxPacketVariableLen();
#if ADUCRF101_RF_CONF_SNIFFER
uart_put(magic[0]);
uart_put(magic[1]);
uart_put(magic[2]);
uart_put(magic[3]);
uart_put(packet_len + 2);
for(int i = 0; i < packet_len; i++) {
uart_put(((uint8_t *)buf)[i]);
}
/* FCS value is Wireshark's "TI CC24xx format" option: */
uart_put(rssi); /* RSSI */
uart_put(0x80); /* CRC is OK, LQI correlation is 0 */
#endif
return packet_len;
}
/*---------------------------------------------------------------------------*/

View file

@ -39,8 +39,6 @@
* On the cc2538, character I/O can be directed over USB or UART. This is
* controlled by a series of configuration directives:
* - SLIP_ARCH_CONF_USB: Controls the operation of slip-arch.
* - CC2538_RF_CONF_SNIFFER_USB: Controls the output of the RF driver when
* operating as a sniffer
* - DBG_CONF_USB: Controls all debugging output
*
* Defaults for those defines are set in contiki-conf.h

View file

@ -91,29 +91,6 @@
/* 192 usec off -> on interval (RX Callib -> SFD Wait). We wait a bit more */
#define ONOFF_TIME RTIMER_ARCH_SECOND / 3125
/*---------------------------------------------------------------------------*/
/* Sniffer configuration */
#ifndef CC2538_RF_CONF_SNIFFER_USB
#define CC2538_RF_CONF_SNIFFER_USB 0
#endif
#if CC2538_RF_CONF_SNIFFER
static const uint8_t magic[] = { 0x53, 0x6E, 0x69, 0x66 }; /** Snif */
#if CC2538_RF_CONF_SNIFFER_USB
#include "usb/usb-serial.h"
#define write_byte(b) usb_serial_writeb(b)
#define flush() usb_serial_flush()
#else
#include "dev/uart.h"
#define write_byte(b) uart_write_byte(CC2538_RF_CONF_SNIFFER_UART, b)
#define flush()
#endif
#else /* CC2538_RF_CONF_SNIFFER */
#define write_byte(b)
#define flush()
#endif /* CC2538_RF_CONF_SNIFFER */
/*---------------------------------------------------------------------------*/
#ifdef CC2538_RF_CONF_AUTOACK
#define CC2538_RF_AUTOACK CC2538_RF_CONF_AUTOACK
#else
@ -526,11 +503,6 @@ init(void)
REG(RFCORE_XREG_FRMCTRL0) |= RFCORE_XREG_FRMCTRL0_AUTOACK;
#endif
/* If we are a sniffer, turn off frame filtering */
#if CC2538_RF_CONF_SNIFFER
REG(RFCORE_XREG_FRMFILT0) &= ~RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN;
#endif
/* Disable source address matching and autopend */
REG(RFCORE_XREG_SRCMATCH) = 0;
@ -798,20 +770,6 @@ read(void *buf, unsigned short bufsize)
return 0;
}
#if CC2538_RF_CONF_SNIFFER
write_byte(magic[0]);
write_byte(magic[1]);
write_byte(magic[2]);
write_byte(magic[3]);
write_byte(len + 2);
for(i = 0; i < len; ++i) {
write_byte(((unsigned char *)(buf))[i]);
}
write_byte(rssi);
write_byte(crc_corr);
flush();
#endif
if(!poll_mode) {
/* If FIFOP==1 and FIFO==0 then we had a FIFO overflow at some point. */
if(REG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_FIFOP) {

View file

@ -101,11 +101,6 @@
#define CC2530_RF_TX_POWER_TXCTRL_MIN_VAL 0x09 /* Value for min TX Power */
#define CC2530_RF_TX_POWER_TXCTRL_DEF_VAL 0x69 /* Reset Value */
/*---------------------------------------------------------------------------*/
#if CC2530_RF_CONF_HEXDUMP
#include "dev/io-arch.h"
static const uint8_t magic[] = { 0x53, 0x6E, 0x69, 0x66 }; /* Snif */
#endif
/*---------------------------------------------------------------------------*/
#ifdef CC2530_RF_CONF_AUTOACK
#define CC2530_RF_AUTOACK CC2530_RF_CONF_AUTOACK
#else
@ -531,15 +526,6 @@ read(void *buf, unsigned short bufsize)
return 0;
}
#if CC2530_RF_CONF_HEXDUMP
/* If we reach here, chances are the FIFO is holding a valid frame */
io_arch_writeb(magic[0]);
io_arch_writeb(magic[1]);
io_arch_writeb(magic[2]);
io_arch_writeb(magic[3]);
io_arch_writeb(len);
#endif
RF_RX_LED_ON();
PUTSTRING("RF: read (0x");
@ -548,9 +534,6 @@ read(void *buf, unsigned short bufsize)
len -= CHECKSUM_LEN;
for(i = 0; i < len; ++i) {
((unsigned char *)(buf))[i] = RFD;
#if CC2530_RF_CONF_HEXDUMP
io_arch_writeb(((unsigned char *)(buf))[i]);
#endif
PUTHEX(((unsigned char *)(buf))[i]);
}
PUTSTRING("\n");
@ -559,12 +542,6 @@ read(void *buf, unsigned short bufsize)
rssi = ((int8_t) RFD) - RSSI_OFFSET;
crc_corr = RFD;
#if CC2530_RF_CONF_HEXDUMP
io_arch_writeb(rssi);
io_arch_writeb(crc_corr);
io_arch_flush();
#endif
/* MS bit CRC OK/Not OK, 7 LS Bits, Correlation value */
if(crc_corr & CRC_BIT_MASK) {
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, rssi);

View file

@ -107,16 +107,6 @@
#define PROP_MODE_USE_CRC16 0
#endif
/*---------------------------------------------------------------------------*/
#ifdef PROP_MODE_CONF_SNIFFER
#define PROP_MODE_SNIFFER PROP_MODE_CONF_SNIFFER
#else
#define PROP_MODE_SNIFFER 0
#endif
#if PROP_MODE_SNIFFER
static const uint8_t magic[] = { 0x53, 0x6E, 0x69, 0x66 };
#endif
/*---------------------------------------------------------------------------*/
/**
* \brief Returns the current status of a running Radio Op command
* \param a A pointer with the buffer used to initiate the command
@ -773,28 +763,7 @@ read_frame(void *buf, unsigned short buf_len)
}
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, (int8_t)data_ptr[len]);
#if PROP_MODE_SNIFFER
{
int i;
cc26xx_uart_write_byte(magic[0]);
cc26xx_uart_write_byte(magic[1]);
cc26xx_uart_write_byte(magic[2]);
cc26xx_uart_write_byte(magic[3]);
cc26xx_uart_write_byte(len + 2);
for(i = 0; i < len; ++i) {
cc26xx_uart_write_byte(((uint8_t *)(buf))[i]);
}
cc26xx_uart_write_byte((uint8_t)rx_stats.lastRssi);
cc26xx_uart_write_byte(0x80);
while(cc26xx_uart_busy() == UART_BUSY);
}
#endif
packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, 0x7F);
}
/* Move read entry pointer to next entry */
@ -1082,6 +1051,8 @@ set_value(radio_param_t param, radio_value_t value)
rv = RADIO_RESULT_ERROR;
}
return RADIO_RESULT_OK;
case RADIO_PARAM_RX_MODE:
return RADIO_RESULT_OK;
case RADIO_PARAM_CCA_THRESHOLD:
rssi_threshold = (int8_t)value;

View file

@ -222,15 +222,5 @@
#define CC1200_RX_LEDS CC1200_CONF_RX_LEDS
#endif
/*---------------------------------------------------------------------------*/
/*
* If set, enable sniff mode: turn radio on (and keep it on), disable
* address filter and auto ack
*/
#ifdef CC1200_CONF_SNIFFER
#define CC1200_SNIFFER CC1200_CONF_SNIFFER
#else
#define CC1200_SNIFFER 0
#endif
/*---------------------------------------------------------------------------*/
#endif /* CC1200_H_ */

View file

@ -374,17 +374,6 @@ extern const cc1200_rf_cfg_t CC1200_RF_CFG;
} while(0)
#endif
/*---------------------------------------------------------------------------*/
/* Sniffer configuration */
#if CC1200_SNIFFER
static const uint8_t magic[] = { 0x53, 0x6E, 0x69, 0x66 };
#include "dev/uart.h"
#define write_byte(b) uart_write_byte(CC1200_RF_CONF_SNIFFER_UART, b)
#define flush()
#else /* CC1200_SNIFFER */
#define write_byte(b)
#define flush()
#endif /* CC1200_SNIFFER */
/*---------------------------------------------------------------------------*/
/* Variables */
/*---------------------------------------------------------------------------*/
/* Flag indicating whether non-interrupt routines are using SPI */
@ -553,11 +542,6 @@ calculate_freq(uint8_t channel);
/* Update rf channel if possible, else postpone it (-> pollhandler). */
static int
set_channel(uint8_t channel);
#if !CC1200_SNIFFER
/* Check broadcast address. */
static int
is_broadcast_addr(uint8_t mode, uint8_t *addr);
#endif /* CC1200_SNIFFER */
/* Validate address and send ACK if requested. */
static int
addr_check_auto_ack(uint8_t *frame, uint16_t frame_len);
@ -574,8 +558,7 @@ PROCESS_THREAD(cc1200_process, ev, data)
PROCESS_BEGIN();
#if CC1200_USE_RX_WATCHDOG && !CC1200_SNIFFER
/* RX watchdog interferes with sniffer. Reason unknown... */
#if CC1200_USE_RX_WATCHDOG
while(1) {
if((rf_flags & (RF_ON | RF_TX_ACTIVE)) == RF_ON) {
@ -716,11 +699,6 @@ init(void)
* configuration of the GPIO0 pin
*/
off();
/* #if CC1200_SNIFFER */
/* on(); */
/* #endif */
}
return 1;
@ -881,10 +859,6 @@ read(void *buf, unsigned short buf_len)
int len = 0;
#if CC1200_SNIFFER
uint8_t i;
#endif
if(rx_pkt_len > 0) {
int8_t rssi = rx_pkt[rx_pkt_len - 2];
@ -911,21 +885,6 @@ read(void *buf, unsigned short buf_len)
packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY,
crc_lqi & ~(1 << 7));
#if CC1200_SNIFFER
write_byte(magic[0]);
write_byte(magic[1]);
write_byte(magic[2]);
write_byte(magic[3]);
write_byte(len + 2);
for(i = 0; i < len; ++i) {
write_byte(((unsigned char *)(buf))[i]);
}
write_byte(rssi);
write_byte(crc_lqi);
flush();
#endif
RIMESTATS_ADD(llrx);
}
@ -2137,7 +2096,6 @@ set_channel(uint8_t channel)
}
/*---------------------------------------------------------------------------*/
/* Check broadcast address. */
#if !CC1200_SNIFFER
static int
is_broadcast_addr(uint8_t mode, uint8_t *addr)
{
@ -2153,30 +2111,7 @@ is_broadcast_addr(uint8_t mode, uint8_t *addr)
return 1;
}
#endif /* CC12100_SNIFFER */
/*---------------------------------------------------------------------------*/
/* Validate address and send ACK if requested. */
#if CC1200_SNIFFER
static int
addr_check_auto_ack(uint8_t *frame, uint16_t frame_len)
{
frame802154_t info154;
if(frame802154_parse(frame, frame_len, &info154) != 0) {
/* We accept all 802.15.4 frames ... */
return ADDR_CHECK_OK;
} else {
/* .. and discard others. */
return INVALID_FRAME;
}
}
#else /* CC1200_SNIFFER */
static int
addr_check_auto_ack(uint8_t *frame, uint16_t frame_len)
{
@ -2245,7 +2180,6 @@ addr_check_auto_ack(uint8_t *frame, uint16_t frame_len)
return INVALID_FRAME;
}
#endif /* CC1200_SNIFFER */
/*---------------------------------------------------------------------------*/
/*
* The CC1200 interrupt handler: called by the hardware interrupt

View file

@ -1,11 +0,0 @@
DEFINES+=PROJECT_CONF_H
PROJECT_SOURCEFILES += stub-rdc.c
CONTIKI_PROJECT = sniffer
all: $(CONTIKI_PROJECT)
CONTIKI = ../../..
CONTIKI_WITH_RIME = 1
include $(CONTIKI)/Makefile.include

View file

@ -1 +0,0 @@
TARGET = cc2530dk

View file

@ -1,49 +0,0 @@
/*
* Copyright (c) 2010, Loughborough University - Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*/
/**
* \file
* Stub file overriding core/net/netstack.c. What we want to achieve
* here is call netstack_init from main without initialising the RDC,
* MAC and Network layers. It will just turn on the radio instead.
*
* \author
* George Oikonomou - <oikonomou@users.sourceforge.net>
*/
#include "netstack.h"
/*---------------------------------------------------------------------------*/
void
netstack_init(void)
{
NETSTACK_RADIO.init();
}
/*---------------------------------------------------------------------------*/

View file

@ -1,56 +0,0 @@
/*
* Copyright (c) 2010, Loughborough University - Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*/
/**
* \file
* Project specific configuration defines for the sniffer example.
*
* \author
* George Oikonomou - <oikonomou@users.sourceforge.net>
*/
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#define CC2530_RF_CONF_HEXDUMP 1
#define CC2530_RF_CONF_AUTOACK 0
#define NETSTACK_CONF_RDC stub_rdc_driver
#define ADC_SENSOR_CONF_ON 0
#define LPM_CONF_MODE 0
#define UART0_CONF_HIGH_SPEED 1
/* Change to 0 to build for the SmartRF + cc2530 EM */
#define MODELS_CONF_CC2531_USB_STICK 1
/* Used by cc2531 USB dongle builds, has no effect on SmartRF builds */
#define USB_SERIAL_CONF_BUFFERED 1
#endif /* PROJECT_CONF_H_ */

View file

@ -1,54 +0,0 @@
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
#include "contiki.h"
#include "cc253x.h"
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
/*---------------------------------------------------------------------------*/
PROCESS(sniffer_process, "Sniffer process");
AUTOSTART_PROCESSES(&sniffer_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sniffer_process, ev, data)
{
PROCESS_BEGIN();
PRINTF("Sniffer started\n");
/* Turn off RF Address Recognition - We need to accept all frames */
FRMFILT0 &= ~0x01;
PROCESS_EXIT();
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View file

@ -1,10 +0,0 @@
DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
PROJECT_SOURCEFILES += stub-rdc.c
CONTIKI_PROJECT = sniffer
all: $(CONTIKI_PROJECT)
CONTIKI = ../../..
CONTIKI_WITH_RIME = 1
include $(CONTIKI)/Makefile.include

View file

@ -1 +0,0 @@
TARGET = cc2538dk

View file

@ -1,96 +0,0 @@
/*
* Copyright (c) 2010, Loughborough University - Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/**
* \file
* Definition of a fake RDC driver to be used with passive
* examples. The sniffer will never send packets and it will never
* push incoming packets up the stack. We do this by defining this
* driver as our RDC. We then drop everything
*
* \author
* George Oikonomou - <oikonomou@users.sourceforge.net>
*/
#include "net/mac/mac.h"
#include "net/mac/rdc.h"
/*---------------------------------------------------------------------------*/
static void
send(mac_callback_t sent, void *ptr)
{
if(sent) {
sent(ptr, MAC_TX_OK, 1);
}
}
/*---------------------------------------------------------------------------*/
static void
send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *list)
{
if(sent) {
sent(ptr, MAC_TX_OK, 1);
}
}
/*---------------------------------------------------------------------------*/
static void
input(void)
{
}
/*---------------------------------------------------------------------------*/
static int
on(void)
{
return 1;
}
/*---------------------------------------------------------------------------*/
static int
off(int keep_radio_on)
{
return keep_radio_on;
}
/*---------------------------------------------------------------------------*/
static unsigned short
cca(void)
{
return 0;
}
/*---------------------------------------------------------------------------*/
static void
init(void)
{
}
/*---------------------------------------------------------------------------*/
const struct rdc_driver stub_rdc_driver = {
"stub-rdc",
init,
send,
send_list,
input,
on,
off,
cca,
};
/*---------------------------------------------------------------------------*/

25
examples/sensniff/Makefile Executable file
View file

@ -0,0 +1,25 @@
DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
CONTIKI_PROJECT = sensniff
PROJECT_SOURCEFILES += sensniff-rdc.c netstack.c
PROJECTDIRS += pool $(TARGET)
ifeq ($(TARGET),)
-include Makefile.target
ifeq ($(TARGET),)
TARGET=srf06-cc26xx
$(info TARGET not defined, using target $(TARGET))
endif
endif
CONTIKI_WITH_RIME = 1
### Optionally, the target can add its own Makefile, to do things like e.g.
### add more source files to the build or define make variables.
-include $(TARGET)/Makefile.$(TARGET)
all: $(CONTIKI_PROJECT)
CONTIKI = ../..
include $(CONTIKI)/Makefile.include

View file

@ -0,0 +1,83 @@
sensniff Contiki Project
========================
This example can be used to create an IEEE 802.15.4 wireless sniffer firmware,
meant to be used in parallel with
[sensniff](https://github.com/g-oikonomou/sensniff).
Running
=======
* Build this example and program your device
* Connect your device to a host
* Run sensniff on your host
* Fire up wireshark and enjoy.
Make sure your device's UART baud rate matches the `-b` argument passed to
sensniff. I strongly recommend using at least 460800. This comment does not
apply if your device is using native USB.
Subsequently, make absolutely certain that your device is tuned to the same RF
channel as the network you are trying to sniff. You can change sniffing channel
through sensniff's text interface.
More details in sensniff's README.
Adding support for more platforms
=================================
Firstly, this example will try to turn off frame filtering and automatic h/w
ACKs by calling `NETSTACK_RADIO.set_value(RADIO_PARAM_RX_MODE, 0)`. If your
radio does not support this, then implementing this is your first step towards
running this example on your board.
Secondly, in order to be able to switch channels and retrieve current/min/max
RF channel supported from sensniff's text interface, your device's radio driver
must also support:
NETSTACK_RADIO.get_value(RADIO_PARAM_CHANNEL, ...)
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, ...)
NETSTACK_RADIO.get_value(RADIO_CONST_CHANNEL_MIN, ...)
NETSTACK_RADIO.get_value(RADIO_CONST_CHANNEL_MAX, ...)
The following radios have been tested:
* CC13xx/CC26xx in PROP and IEEE modes
* CC2538
* CC2530/CC2531
* CC1200
One you have the radio sorted out, you also need to configure character I/O.
The firmware captures wireless frames and streams them over a serial line to
the host where your device is connected. This can be achieved over UART or over
CDC-ACM. The example makes zero assumptions about your hardware's capability,
you have to configure thnigs explicitly.
* Firstly, create a directory named the same as your platform. Crate a header
file therein called `target-conf.h`. This will get included automatically.
* Then look at the header files under `pool`, perhaps your device's CPU is
already supported. If that's the case, then within your `target-conf.h` you
simply need to add a line like this:
#define SENSNIFF_IO_DRIVER_H "pool/cc2538-io.h"
choosing the header that corresponds to your device's CPU. Just look for any of
the platforms already supported to see how you can configure things in a more
fine-grained fashion (e.g. to select UART instance, switch between UART/USB
etc).
* If your CPU is not already supported, then you need to create an additional
header file. In that header file, you will need to define the following three:
#define sensniff_io_byte_out() <driver function that prints bytes>
#define sensniff_io_flush() <for buffered I/O. Can be empty>
#define sensniff_io_set_input() <driver function that sets an input callback>
Those should map to functions implemented by your device's peripheral driver,
e.g. your UART driver. `_byte_out()` and `set_input()` are required, but
`_flush()` is optional and is only really helpful in case of drivers/hardware
that support buffered I/O (as is the case for some Contiki's USB drivers). Once
you have provided those defines, then simple go back to your `target-conf.h`
and:
#define SENSNIFF_IO_DRIVER_H "header-with-my-own-defines.h"
That should be it!

View file

@ -0,0 +1 @@
HAVE_BANKING = 1

View file

@ -1,16 +1,16 @@
/*
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@ -28,45 +28,22 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc2538-examples
* @{
*
* \defgroup cc2538-sniffer cc2538 Sniffer
*
* Sniffer for the CC2538-based platforms. Originally based on the sensinode
* and cc2530dk sniffers.
*
* This example is to be used combined with the sensniff host-side tool,
* which can be downloaded from: https://github.com/g-oikonomou/sensniff
*
* @{
*
* \file
* Implementation of a Sniffer Process Thread
*/
#include "contiki.h"
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
/*---------------------------------------------------------------------------*/
PROCESS(sniffer_process, "Sniffer process");
AUTOSTART_PROCESSES(&sniffer_process);
#ifndef TARGET_CONF_H_
#define TARGET_CONF_H_
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sniffer_process, ev, data)
{
PROCESS_BEGIN();
PRINTF("Sniffer started\n");
PROCESS_EXIT();
PROCESS_END();
}
/* Change to 0 to build for the SmartRF + cc2530 EM */
#define MODELS_CONF_CC2531_USB_STICK 1
/*---------------------------------------------------------------------------*/
/* Don't change below this line */
#define ADC_SENSOR_CONF_ON 0
#define LPM_CONF_MODE 0
#define UART0_CONF_HIGH_SPEED 1
#define UART0_RTSCTS 1
#define UART0_CONF_WITH_INPUT 1
#define USB_SERIAL_CONF_BUFFERED 1
/*---------------------------------------------------------------------------*/
#define SENSNIFF_IO_DRIVER_H "pool/cc2530-cc2531-io.h"
/*---------------------------------------------------------------------------*/
#endif /* TARGET_CONF_H_ */
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View file

@ -0,0 +1,54 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef TARGET_CONF_H_
#define TARGET_CONF_H_
/*---------------------------------------------------------------------------*/
/*
* Selection of Sensniff I/O Interface.
* Define CC2538_IO_CONF_USB as 0 to use UART as sensniff's interface.
* This will default to using UART0, unless you also define
* CC2538_IO_CONF_USE_UART_1 as 1.
*
* Don't forget to also set a correct baud rate (460800 or higher) by defining
* the corresponding UART0_CONF_BAUD_RATE or UART1_CONF_BAUD_RATE
*/
#define CC2538_IO_CONF_USB 1
#define CC2538_IO_CONF_USE_UART1 0
/*---------------------------------------------------------------------------*/
#if CC2538_IO_CONF_USB
#define USB_SERIAL_CONF_ENABLE 1
#endif
/*---------------------------------------------------------------------------*/
#define SENSNIFF_IO_DRIVER_H "pool/cc2538-io.h"
/*---------------------------------------------------------------------------*/
#endif /* TARGET_CONF_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -1,16 +1,16 @@
/*
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@ -28,32 +28,16 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup zoul-cc1200-sniffer
* @{
*
* \file
* Project specific configuration defines for the CC1200 sniffer
*/
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#define CC1200_CONF_SNIFFER 1
#define CC1200_RF_CONF_SNIFFER_UART 0
#define CC1200_CONF_RF_CFG cc1200_802154g_863_870_fsk_50kbps
#undef NETSTACK_CONF_RADIO
#define NETSTACK_CONF_RADIO cc1200_driver
#define CC1200_CONF_USE_GPIO2 0
#define CC1200_CONF_USE_RX_WATCHDOG 0
#define ANTENNA_SW_SELECT_DEF_CONF ANTENNA_SW_SELECT_SUBGHZ
#undef NETSTACK_CONF_RDC
#define NETSTACK_CONF_RDC stub_rdc_driver
#define UART0_CONF_BAUD_RATE 460800
#endif /* PROJECT_CONF_H_ */
/** @} */
/*---------------------------------------------------------------------------*/
#ifndef EV_ADUCRF101MKXZ_IO_H_
#define EV_ADUCRF101MKXZ_IO_H_
/*---------------------------------------------------------------------------*/
#include "contiki-conf.h"
#include "dev/uart.h"
/*---------------------------------------------------------------------------*/
#define sensniff_io_byte_out(b) uart_put(b)
#define sensniff_io_flush()
#define sensniff_io_set_input(f) uart_set_input(f)
/*---------------------------------------------------------------------------*/
#endif /* EV_ADUCRF101MKXZ_IO_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,38 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef TARGET_CONF_H_
#define TARGET_CONF_H_
/*---------------------------------------------------------------------------*/
#define SENSNIFF_IO_DRIVER_H "ev-aducrf101mkxz/ev-aducrf101mkxz-io.h"
/*---------------------------------------------------------------------------*/
#endif /* TARGET_CONF_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,56 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef JN516X_IO_H_
#define JN516X_IO_H_
/*---------------------------------------------------------------------------*/
#include "contiki-conf.h"
#include "dev/uart0.h"
#include "dev/uart1.h"
/*---------------------------------------------------------------------------*/
#ifdef JN516X_IO_CONF_USE_UART1
#define JN516X_IO_USE_UART1 JN516X_IO_CONF_USE_UART1
#else
#define JN516X_IO_USE_UART1 0
#endif
/*---------------------------------------------------------------------------*/
#if JN516X_IO_USE_UART1
#define sensniff_io_byte_out(b) uart1_writeb(b)
#define sensniff_io_flush()
#define sensniff_io_set_input(f) uart1_set_input(f)
#else
#define sensniff_io_byte_out(b) uart0_writeb(b)
#define sensniff_io_flush()
#define sensniff_io_set_input(f) uart0_set_input(f)
#endif
/*---------------------------------------------------------------------------*/
#endif /* JN516X_IO_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,38 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef TARGET_CONF_H_
#define TARGET_CONF_H_
/*---------------------------------------------------------------------------*/
#define SENSNIFF_IO_DRIVER_H "jn516x/jn516x-io.h"
/*---------------------------------------------------------------------------*/
#endif /* TARGET_CONF_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -26,21 +26,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/**
* \file
* Stub file overriding core/net/netstack.c. What we want to achieve
* here is call netstack_init from main without initialising the RDC,
* MAC and Network layers. It will just turn on the radio instead.
*
* \author
* George Oikonomou - <oikonomou@users.sourceforge.net>
*/
/*---------------------------------------------------------------------------*/
#include "netstack.h"
/*---------------------------------------------------------------------------*/
void
netstack_init(void)
{
NETSTACK_RADIO.init();
NETSTACK_RADIO.on();
NETSTACK_RDC.init();
}
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,56 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef TARGET_CONF_H_
#define TARGET_CONF_H_
/*---------------------------------------------------------------------------*/
/*
* Selection of Sensniff I/O Interface.
* Define CC2538_IO_CONF_USB as 0 to use UART as sensniff's interface.
* This will default to using UART0, unless you also define
* CC2538_IO_CONF_USE_UART1 as 1.
*
* Don't forget to also set a correct baud rate (460800 or higher) by defining
* the corresponding UART0_CONF_BAUD_RATE or UART1_CONF_BAUD_RATE
*/
#define CC2538_IO_CONF_USB 0
#define CC2538_IO_CONF_USE_UART1 0
/*---------------------------------------------------------------------------*/
#if CC2538_IO_CONF_USB
#define USB_SERIAL_CONF_ENABLE 1
#else
#define UART0_CONF_BAUD_RATE 460800
#endif
/*---------------------------------------------------------------------------*/
#define SENSNIFF_IO_DRIVER_H "pool/cc2538-io.h"
/*---------------------------------------------------------------------------*/
#endif /* TARGET_CONF_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef CC13XX_CC26XX_IO_H_
#define CC13XX_CC26XX_IO_H_
/*---------------------------------------------------------------------------*/
#include "contiki-conf.h"
#include "dev/cc26xx-uart.h"
/*---------------------------------------------------------------------------*/
#define sensniff_io_byte_out(b) cc26xx_uart_write_byte(b)
#define sensniff_io_flush()
#define sensniff_io_set_input(f) cc26xx_uart_set_input(f)
/*---------------------------------------------------------------------------*/
#endif /* CC13XX_CC26XX_IO_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef CC2530_CC2531_IO_H_
#define CC2530_CC2531_IO_H_
/*---------------------------------------------------------------------------*/
#include "contiki-conf.h"
#include "dev/io-arch.h"
/*---------------------------------------------------------------------------*/
#define sensniff_io_byte_out(b) io_arch_writeb(b)
#define sensniff_io_flush() io_arch_flush()
#define sensniff_io_set_input(f) io_arch_set_input(f)
/*---------------------------------------------------------------------------*/
#endif /* CC2530_CC2531_IO_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,76 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#include "contiki-conf.h"
#include "dev/uart.h"
#include "usb/usb-serial.h"
/*---------------------------------------------------------------------------*/
#ifndef CC2538_IO_H_
#define CC2538_IO_H_
/*---------------------------------------------------------------------------*/
/*
* Select whether to use native USB as sensniff's I/O interface.
* If defined as 0, UART will be used. Set to 1 to use USB.
*/
#ifdef CC2538_IO_CONF_USB
#define CC2538_IO_USB CC2538_IO_CONF_USB
#else
#define CC2538_IO_USB 0
#endif
/*---------------------------------------------------------------------------*/
/*
* UART instance selection. Set to 1 to use UART1.
* Ignored unless CC2538_IO_USB is 0.
*/
#ifdef CC2538_IO_CONF_USE_UART1
#define CC2538_IO_USE_UART1 CC2538_IO_CONF_USE_UART1
#else
#define CC2538_IO_USE_UART1 0
#endif
/*---------------------------------------------------------------------------*/
#if CC2538_IO_USB
#define sensniff_io_byte_out(b) usb_serial_writeb(b)
#define sensniff_io_flush() usb_serial_flush()
#define sensniff_io_set_input(f) usb_serial_set_input(f)
#else
#if CC2538_IO_USE_UART1
#define sensniff_io_byte_out(b) uart_write_byte(1, b)
#define sensniff_io_flush()
#define sensniff_io_set_input(f) uart_set_input(1, f)
#else
#define sensniff_io_byte_out(b) uart_write_byte(0, b)
#define sensniff_io_flush()
#define sensniff_io_set_input(f) uart_set_input(0, f)
#endif /* CC2538_IO_USE_UART_1 */
#endif /* CC2538_IO_USB */
/*---------------------------------------------------------------------------*/
#endif /* CC2538_IO_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,56 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef MSP430_IO_H_
#define MSP430_IO_H_
/*---------------------------------------------------------------------------*/
#include "contiki-conf.h"
#include "dev/uart0.h"
#include "dev/uart1.h"
/*---------------------------------------------------------------------------*/
#ifdef MSP430_IO_CONF_USE_UART1
#define MSP430_IO_USE_UART1 MSP430_IO_CONF_USE_UART1
#else
#define MSP430_IO_USE_UART1 0
#endif
/*---------------------------------------------------------------------------*/
#if MSP430_IO_USE_UART1
#define sensniff_io_byte_out(b) uart1_writeb(b)
#define sensniff_io_flush()
#define sensniff_io_set_input(f) uart1_set_input(f)
#else
#define sensniff_io_byte_out(b) uart0_writeb(b)
#define sensniff_io_flush()
#define sensniff_io_set_input(f) uart0_set_input(f)
#endif
/*---------------------------------------------------------------------------*/
#endif /* MSP430_IO_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -1,16 +1,16 @@
/*
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@ -28,23 +28,14 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc2538-sniffer
* @{
*
* \file
* Project specific configuration defines for the cc2538 sniffer
*/
/*---------------------------------------------------------------------------*/
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#define CC2538_RF_CONF_SNIFFER 1
#define CC2538_RF_CONF_AUTOACK 0
/*---------------------------------------------------------------------------*/
#undef NETSTACK_CONF_RDC
#define NETSTACK_CONF_RDC stub_rdc_driver
#define UART0_CONF_BAUD_RATE 460800
#define NETSTACK_CONF_RDC sensniff_rdc_driver
/*---------------------------------------------------------------------------*/
/* Include platform-specific header */
#include "target-conf.h"
/*---------------------------------------------------------------------------*/
#endif /* PROJECT_CONF_H_ */
/** @} */

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2010, Loughborough University - Computer Science
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* Copyright (c) 2012-2013, Centre National de la Recherche Scientifique.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -10,63 +11,55 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \file
* Definition of a fake RDC driver to be used with passive
* examples. The sniffer will never send packets and it will never
* push incoming packets up the stack. We do this by defining this
* driver as our RDC. We then drop everything
*
* \author
* George Oikonomou - <oikonomou@users.sourceforge.net>
/*---------------------------------------------------------------------------*/
/*
* Author: George Oikonomou
* Loosely based on the example contributed by Etienne Duble (CNRS / LIG), as
* part of the work done for the ANR ARESA2 project.
*/
/*---------------------------------------------------------------------------*/
#include "net/mac/mac.h"
#include "net/mac/rdc.h"
#include "net/netstack.h"
#include "sensniff.h"
/*---------------------------------------------------------------------------*/
static void
send(mac_callback_t sent, void *ptr)
{
if(sent) {
sent(ptr, MAC_TX_OK, 1);
}
}
/*---------------------------------------------------------------------------*/
static void
send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *list)
{
if(sent) {
sent(ptr, MAC_TX_OK, 1);
}
}
/*---------------------------------------------------------------------------*/
static void
input(void)
{
sensniff_output_frame();
}
/*---------------------------------------------------------------------------*/
static int
on(void)
{
NETSTACK_RADIO.on();
return 1;
}
/*---------------------------------------------------------------------------*/
@ -85,10 +78,11 @@ cca(void)
static void
init(void)
{
on();
}
/*---------------------------------------------------------------------------*/
const struct rdc_driver stub_rdc_driver = {
"stub-rdc",
const struct rdc_driver sensniff_rdc_driver = {
"sensniff-rdc",
init,
send,
send_list,

View file

@ -0,0 +1,344 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "sensniff.h"
#include "dev/radio.h"
#include "net/netstack.h"
#include "net/packetbuf.h"
#include "sys/process.h"
#include "sys/ctimer.h"
#include "lib/ringbuf.h"
#include SENSNIFF_IO_DRIVER_H
#include <string.h>
#include <stdint.h>
#include <stdio.h>
/*---------------------------------------------------------------------------*/
#define DEBUG 1
#if DEBUG
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
/*---------------------------------------------------------------------------*/
PROCESS(sensniff_process, "sensniff process");
AUTOSTART_PROCESSES(&sensniff_process);
/*---------------------------------------------------------------------------*/
/* Timeout handling for incoming characters. */
#define TIMEOUT (CLOCK_SECOND >> 1)
static struct ctimer ct;
/*---------------------------------------------------------------------------*/
#define STATE_WAITING_FOR_MAGIC 0x00
#define STATE_WAITING_FOR_VERSION 0x01
#define STATE_WAITING_FOR_CMD 0x02
#define STATE_WAITING_FOR_LEN_1 0x03
#define STATE_WAITING_FOR_LEN_2 0x04
#define STATE_WAITING_FOR_DATA 0x05
static uint8_t state;
static uint8_t in_ct;
/*---------------------------------------------------------------------------*/
#define CMD_FRAME 0x00
#define CMD_CHANNEL 0x01
#define CMD_CHANNEL_MIN 0x02
#define CMD_CHANNEL_MAX 0x03
#define CMD_ERR_NOT_SUPPORTED 0x7F
#define CMD_GET_CHANNEL 0x81
#define CMD_GET_CHANNEL_MIN 0x82
#define CMD_GET_CHANNEL_MAX 0x83
#define CMD_SET_CHANNEL 0x84
/*---------------------------------------------------------------------------*/
#define PROTOCOL_VERSION 2
/*---------------------------------------------------------------------------*/
#define BUFSIZE 32
static struct ringbuf rxbuf;
typedef struct cmd_in_s {
uint8_t cmd;
uint16_t len;
uint8_t data;
} cmd_in_t;
static cmd_in_t command;
uint8_t cmd_buf[BUFSIZE];
/*---------------------------------------------------------------------------*/
static const uint8_t magic[] = { 0xC1, 0x1F, 0xFE, 0x72 };
/*---------------------------------------------------------------------------*/
static void
reset_state(void *byte)
{
state = STATE_WAITING_FOR_MAGIC;
in_ct = 0;
memset(&command, 0, sizeof(command));
}
/*---------------------------------------------------------------------------*/
static void
send_header(uint8_t cmd, uint16_t len)
{
uint16_t i;
/* Send the magic */
for(i = 0; i < 4; i++) {
sensniff_io_byte_out(magic[i]);
}
/* Send the protocol version */
sensniff_io_byte_out(PROTOCOL_VERSION);
/* Send the command byte */
sensniff_io_byte_out(cmd);
/* Send the length, network endianness */
sensniff_io_byte_out(len >> 8);
sensniff_io_byte_out(len & 0xFF);
}
/*---------------------------------------------------------------------------*/
static void
send_error(void)
{
send_header(CMD_ERR_NOT_SUPPORTED, 0);
sensniff_io_flush();
}
/*---------------------------------------------------------------------------*/
static void
send_channel(void)
{
radio_value_t chan;
if(NETSTACK_RADIO.get_value(RADIO_PARAM_CHANNEL, &chan) ==
RADIO_RESULT_OK) {
send_header(CMD_CHANNEL, 1);
sensniff_io_byte_out(chan & 0xFF);
sensniff_io_flush();
return;
}
send_error();
}
/*---------------------------------------------------------------------------*/
static void
set_channel(uint8_t channel)
{
if(NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, channel) ==
RADIO_RESULT_OK) {
send_channel();
return;
}
send_error();
}
/*---------------------------------------------------------------------------*/
static void
send_channel_min(void)
{
radio_value_t chan;
if(NETSTACK_RADIO.get_value(RADIO_CONST_CHANNEL_MIN, &chan) ==
RADIO_RESULT_OK) {
send_header(CMD_CHANNEL_MIN, 1);
sensniff_io_byte_out(chan & 0xFF);
sensniff_io_flush();
return;
}
send_error();
}
/*---------------------------------------------------------------------------*/
static void
send_channel_max(void)
{
radio_value_t chan;
if(NETSTACK_RADIO.get_value(RADIO_CONST_CHANNEL_MAX, &chan) ==
RADIO_RESULT_OK) {
send_header(CMD_CHANNEL_MAX, 1);
sensniff_io_byte_out(chan & 0xFF);
sensniff_io_flush();
return;
}
send_error();
}
/*---------------------------------------------------------------------------*/
static int
char_in(unsigned char c)
{
/* Bump the timeout counter */
ctimer_set(&ct, TIMEOUT, reset_state, NULL);
/* Add the character to our ringbuf and poll the consumer process. */
ringbuf_put(&rxbuf, c);
process_poll(&sensniff_process);
return 1;
}
/*---------------------------------------------------------------------------*/
void
sensniff_output_frame()
{
int i;
uint8_t len = packetbuf_datalen() & 0xFF;
send_header(CMD_FRAME, len + 2);
for(i = 0; i < len; i++) {
sensniff_io_byte_out(((uint8_t *)packetbuf_dataptr())[i]);
}
sensniff_io_byte_out(packetbuf_attr(PACKETBUF_ATTR_RSSI) & 0xFF);
sensniff_io_byte_out(0x80 |
(packetbuf_attr(PACKETBUF_ATTR_LINK_QUALITY) & 0xFF));
sensniff_io_flush();
}
/*---------------------------------------------------------------------------*/
static void
execute_command(void)
{
switch(command.cmd) {
case CMD_GET_CHANNEL:
send_channel();
break;
case CMD_GET_CHANNEL_MIN:
send_channel_min();
break;
case CMD_GET_CHANNEL_MAX:
send_channel_max();
break;
case CMD_SET_CHANNEL:
set_channel(command.data);
break;
default:
send_error();
break;
}
}
/*---------------------------------------------------------------------------*/
static void
process_incoming_data(void)
{
int c = 0;
uint8_t byte_in;
c = ringbuf_get(&rxbuf);
while(c != -1) {
byte_in = (uint8_t)c;
switch(state) {
case STATE_WAITING_FOR_MAGIC:
if(byte_in == magic[in_ct]) {
in_ct++;
if(in_ct == sizeof(magic)) {
state = STATE_WAITING_FOR_VERSION;
in_ct = 0;
}
} else {
reset_state(&byte_in);
}
break;
case STATE_WAITING_FOR_VERSION:
if(byte_in == PROTOCOL_VERSION) {
state = STATE_WAITING_FOR_CMD;
} else {
reset_state(&byte_in);
}
break;
case STATE_WAITING_FOR_CMD:
command.cmd = byte_in;
if(command.cmd == CMD_GET_CHANNEL ||
command.cmd == CMD_GET_CHANNEL_MIN ||
command.cmd == CMD_GET_CHANNEL_MAX) {
execute_command();
reset_state(&byte_in);
} else {
state = STATE_WAITING_FOR_LEN_1;
}
break;
case STATE_WAITING_FOR_LEN_1:
command.len = byte_in << 8;
state = STATE_WAITING_FOR_LEN_2;
break;
case STATE_WAITING_FOR_LEN_2:
command.len |= byte_in;
if(command.len == 1) {
state = STATE_WAITING_FOR_DATA;
} else {
reset_state(&byte_in);
}
break;
case STATE_WAITING_FOR_DATA:
command.data = byte_in;
execute_command();
reset_state(&byte_in);
break;
default:
break;
}
c = ringbuf_get(&rxbuf);
}
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sensniff_process, ev, data)
{
PROCESS_BEGIN();
/* Turn off RF frame filtering and H/W ACKs */
if(NETSTACK_RADIO.set_value(RADIO_PARAM_RX_MODE, 0) != RADIO_RESULT_OK) {
PRINTF("sensniff: Error setting RF in promiscuous mode\n");
PROCESS_EXIT();
}
/* Initialise the ring buffer */
ringbuf_init(&rxbuf, cmd_buf, sizeof(cmd_buf));
/* Initialise the state machine */
reset_state(NULL);
/* Register for char inputs with the character I/O peripheral */
sensniff_io_set_input(&char_in);
while(1) {
PROCESS_YIELD();
if(ev == PROCESS_EVENT_POLL) {
process_incoming_data();
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View file

@ -1,16 +1,16 @@
/*
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@ -28,40 +28,18 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup zoul-examples
* @{
*
* \defgroup zoul-cc1200-sniffer CC1200 Sniffer
*
* Sniffer for the Zolertia's Zoul CC1200 on-board radio
*
* This example is to be used combined with the sensniff host-side tool,
* which can be downloaded from: https://github.com/g-oikonomou/sensniff
*
* @{
*
* \file
* Implementation of a Sniffer Process Thread
*/
#include "contiki.h"
/*---------------------------------------------------------------------------*/
#ifndef SENSNIFF_H_
#define SENSNIFF_H_
/*---------------------------------------------------------------------------*/
#include "contiki-conf.h"
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
#include <stdint.h>
/*---------------------------------------------------------------------------*/
PROCESS(sniffer_process, "Sniffer process");
AUTOSTART_PROCESSES(&sniffer_process);
#define SENSNIFF_ERROR 0xFF
#define SENSNIFF_OK 0x00
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sniffer_process, ev, data)
{
PROCESS_BEGIN();
PRINTF("Sniffer started\n");
PROCESS_EXIT();
PROCESS_END();
}
void sensniff_output_frame(void);
/*---------------------------------------------------------------------------*/
#endif /* SENSNIFF_H_ */
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View file

@ -0,0 +1,42 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef TARGET_CONF_H_
#define TARGET_CONF_H_
/*---------------------------------------------------------------------------*/
#define CC26XX_UART_CONF_BAUD_RATE 460800
#define RF_BLE_CONF_ENABLED 0
#define ROM_BOOTLOADER_ENABLE 1
/*---------------------------------------------------------------------------*/
#define SENSNIFF_IO_DRIVER_H "pool/cc13xx-cc26xx-io.h"
/*---------------------------------------------------------------------------*/
#endif /* TARGET_CONF_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef TARGET_CONF_H_
#define TARGET_CONF_H_
/*---------------------------------------------------------------------------*/
#define MSP430_IO_CONF_USE_UART1 0
#define UART0_CONF_BAUD_RATE 460800
/*---------------------------------------------------------------------------*/
#define SENSNIFF_IO_DRIVER_H "pool/msp430-io.h"
/*---------------------------------------------------------------------------*/
#endif /* TARGET_CONF_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -0,0 +1,71 @@
/*
* Copyright (c) 2016, George Oikonomou - http://www.spd.gr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
#ifndef TARGET_CONF_H_
#define TARGET_CONF_H_
/*---------------------------------------------------------------------------*/
/* Set to 1 for a sub-ghz sniffer with the CC1200 */
#ifndef ZOUL_CONF_SUB_GHZ_SNIFFER
#define ZOUL_CONF_SUB_GHZ_SNIFFER 0
#endif
/*---------------------------------------------------------------------------*/
#if ZOUL_CONF_SUB_GHZ_SNIFFER
#define NETSTACK_CONF_RADIO cc1200_driver
/*
* You will need to configure the defines below to match the configuration of
* your sub-ghz network.
*/
#define CC1200_CONF_RF_CFG cc1200_802154g_863_870_fsk_50kbps
#define CC1200_CONF_USE_GPIO2 0
#define CC1200_CONF_USE_RX_WATCHDOG 0
#define CC1200_CONF_802154G 0
#define CC1200_CONF_802154G_CRC16 0
#define CC1200_CONF_802154G_WHITENING 0
#define ANTENNA_SW_SELECT_DEF_CONF ANTENNA_SW_SELECT_SUBGHZ
#endif
/*---------------------------------------------------------------------------*/
/*
* Selection of Sensniff I/O Interface.
* Define CC2538_IO_CONF_USB as 0 to use UART0 as sensniff's interface.
*/
#define CC2538_IO_CONF_USB 0
/*---------------------------------------------------------------------------*/
#if CC2538_IO_CONF_USB
#define USB_SERIAL_CONF_ENABLE 1
#else
#define UART0_CONF_BAUD_RATE 460800
#endif
/*---------------------------------------------------------------------------*/
#define SENSNIFF_IO_DRIVER_H "pool/cc2538-io.h"
/*---------------------------------------------------------------------------*/
#endif /* TARGET_CONF_H_ */
/*---------------------------------------------------------------------------*/

View file

@ -1,10 +0,0 @@
DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
PROJECT_SOURCEFILES += stub-rdc.c
CONTIKI_PROJECT = sniffer
all: $(CONTIKI_PROJECT)
CONTIKI = ../../../..
CONTIKI_WITH_RIME = 1
include $(CONTIKI)/Makefile.include

View file

@ -1 +0,0 @@
TARGET = zoul

View file

@ -1,35 +0,0 @@
CC1200 README
========================
The CC1200 sniffer is heavily based on the CC2538 sniffer, used with the
IEEE 802.15.4 Sensniff application by George Oikonomou.
Sensniff requires [Wireshark](http://www.wireshark.org/).
Get Wireshark
-----------------
The best way is to go to the Wireshark site and follow the instructions for your
specific OS, in a bundle this will install for Ubuntu/LInux systems:
`sudo apt-get install wireshark`
To allow non-super users to capture packets:
`sudo dpkg-reconfigure wireshark`
Flash the sniffer application to the Zoul
-----------------
make sniffer.upload
Run Sensniff
-----------------
```
git clone https://github.com/g-oikonomou/sensniff
cd sensniff/host
python sensniff.py --non-interactive -d /dev/ttyUSB0 -b 460800
```
On another terminal run:
`sudo wireshark -i /tmp/sensnifff`

View file

@ -1,46 +0,0 @@
/*
* Copyright (c) 2010, Loughborough University - Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/**
* \file
* Stub file overriding core/net/netstack.c. What we want to achieve
* here is call netstack_init from main without initialising the RDC,
* MAC and Network layers. It will just turn on the radio instead.
*
* \author
* George Oikonomou - <oikonomou@users.sourceforge.net>
*/
#include "netstack.h"
/*---------------------------------------------------------------------------*/
void
netstack_init(void)
{
NETSTACK_RADIO.init();
NETSTACK_RADIO.on();
}
/*---------------------------------------------------------------------------*/

View file

@ -1,96 +0,0 @@
/*
* Copyright (c) 2010, Loughborough University - Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/**
* \file
* Definition of a fake RDC driver to be used with passive
* examples. The sniffer will never send packets and it will never
* push incoming packets up the stack. We do this by defining this
* driver as our RDC. We then drop everything
*
* \author
* George Oikonomou - <oikonomou@users.sourceforge.net>
*/
#include "net/mac/mac.h"
#include "net/mac/rdc.h"
/*---------------------------------------------------------------------------*/
static void
send(mac_callback_t sent, void *ptr)
{
if(sent) {
sent(ptr, MAC_TX_OK, 1);
}
}
/*---------------------------------------------------------------------------*/
static void
send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *list)
{
if(sent) {
sent(ptr, MAC_TX_OK, 1);
}
}
/*---------------------------------------------------------------------------*/
static void
input(void)
{
}
/*---------------------------------------------------------------------------*/
static int
on(void)
{
return 1;
}
/*---------------------------------------------------------------------------*/
static int
off(int keep_radio_on)
{
return keep_radio_on;
}
/*---------------------------------------------------------------------------*/
static unsigned short
cca(void)
{
return 0;
}
/*---------------------------------------------------------------------------*/
static void
init(void)
{
}
/*---------------------------------------------------------------------------*/
const struct rdc_driver stub_rdc_driver = {
"stub-rdc",
init,
send,
send_list,
input,
on,
off,
cca,
};
/*---------------------------------------------------------------------------*/

View file

@ -85,17 +85,6 @@
#define UART0_CONF_WITH_INPUT 1
#endif
/* Output all captured frames over the UART in hexdump format */
#ifndef CC2530_RF_CONF_HEXDUMP
#define CC2530_RF_CONF_HEXDUMP 0
#endif
#if CC2530_RF_CONF_HEXDUMP
/* We need UART1 output */
#undef UART_ZERO_CONF_ENABLE
#define UART_ZERO_CONF_ENABLE 1
#endif
/* Code Shortcuts */
/*
* When set, this directive also configures the following bypasses:

View file

@ -337,7 +337,7 @@ More things to play around with
Build a Sniffer - Live Traffic Capture with Wireshark
-----------------------------------------------------
There is a sniffer example in `examples/cc2538dk/sniffer/`
There is a sniffer example in `examples/sensniff/`
Diverging from platform defaults, this example configures the UART to use a baud rate of 460800. The reason is that sniffers operating at 115200 are liable to corrupt frames. This is almost certain to occur when sniffing a ContikiMAC-based deployment. See more details on how to configure UART baud rates in the "Advanced Topics" section.
@ -366,7 +366,6 @@ Switching between UART and USB (CDC-ACM)
By default, everything is configured to use the UART (stdio, border router's SLIP, sniffer's output stream). If you want to change this, these are the relevant lines in contiki-conf.h (0: UART, 1: USB):
#define SLIP_ARCH_CONF_USB 0 /** SLIP over UART by default */
#define CC2538_RF_CONF_SNIFFER_USB 0 /** Sniffer out over UART by default */
#define DBG_CONF_USB 0 /** All debugging over UART by default */
You can multiplex things (for instance, SLIP as well as debugging over USB or SLIP over USB but debugging over UART and other combinations).
@ -377,7 +376,6 @@ By default, everything is configured to use the UART0 (stdio, border router's SL
#define SERIAL_LINE_CONF_UART 0
#define SLIP_ARCH_CONF_UART 0
#define CC2538_RF_CONF_SNIFFER_UART 0
#define DBG_CONF_UART 0
#define UART1_CONF_UART 0

View file

@ -150,10 +150,6 @@ typedef uint32_t rtimer_clock_t;
#define SLIP_ARCH_CONF_USB 0 /**< SLIP over UART by default */
#endif
#ifndef CC2538_RF_CONF_SNIFFER_USB
#define CC2538_RF_CONF_SNIFFER_USB 0 /**< Sniffer out over UART by default */
#endif
#ifndef DBG_CONF_USB
#define DBG_CONF_USB 0 /**< All debugging over UART by default */
#endif
@ -168,12 +164,6 @@ typedef uint32_t rtimer_clock_t;
#endif
#endif
#if !CC2538_RF_CONF_SNIFFER_USB
#ifndef CC2538_RF_CONF_SNIFFER_UART
#define CC2538_RF_CONF_SNIFFER_UART 0 /**< UART to use with sniffer */
#endif
#endif
#if !DBG_CONF_USB
#ifndef DBG_CONF_UART
#define DBG_CONF_UART 0 /**< UART to use for debugging */
@ -200,15 +190,6 @@ typedef uint32_t rtimer_clock_t;
#endif
#endif
/*
* When set, the radio turns off address filtering and sends all captured
* frames down a peripheral (UART or USB, depending on the value of
* CC2538_RF_CONF_SNIFFER_USB)
*/
#ifndef CC2538_RF_CONF_SNIFFER
#define CC2538_RF_CONF_SNIFFER 0
#endif
/**
* \brief Define this as 1 to build a headless node.
*
@ -229,12 +210,6 @@ typedef uint32_t rtimer_clock_t;
#undef STARTUP_CONF_VERBOSE
#define STARTUP_CONF_VERBOSE 0
/* Little sanity check: We can't have quiet sniffers */
#if CC2538_RF_CONF_SNIFFER
#error "CC2538_RF_CONF_SNIFFER == 1 and CC2538_CONF_QUIET == 1"
#error "These values are conflicting. Please set either to 0"
#endif
#endif /* CC2538_CONF_QUIET */
/**
@ -243,8 +218,7 @@ typedef uint32_t rtimer_clock_t;
#ifndef USB_SERIAL_CONF_ENABLE
#define USB_SERIAL_CONF_ENABLE \
((SLIP_ARCH_CONF_USB & SLIP_ARCH_CONF_ENABLED) | \
DBG_CONF_USB | \
(CC2538_RF_CONF_SNIFFER & CC2538_RF_CONF_SNIFFER_USB))
DBG_CONF_USB)
#endif
/*
@ -264,9 +238,6 @@ typedef uint32_t rtimer_clock_t;
#define UART_IN_USE_BY_SLIP(u) (SLIP_ARCH_CONF_ENABLED && \
!SLIP_ARCH_CONF_USB && \
SLIP_ARCH_CONF_UART == (u))
#define UART_IN_USE_BY_RF_SNIFFER(u) (CC2538_RF_CONF_SNIFFER && \
!CC2538_RF_CONF_SNIFFER_USB && \
CC2538_RF_CONF_SNIFFER_UART == (u))
#define UART_IN_USE_BY_DBG(u) (!DBG_CONF_USB && DBG_CONF_UART == (u))
#define UART_IN_USE_BY_UART1(u) (UART1_CONF_UART == (u))
@ -274,7 +245,6 @@ typedef uint32_t rtimer_clock_t;
UART_CONF_ENABLE && \
(UART_IN_USE_BY_SERIAL_LINE(u) || \
UART_IN_USE_BY_SLIP(u) || \
UART_IN_USE_BY_RF_SNIFFER(u) || \
UART_IN_USE_BY_DBG(u) || \
UART_IN_USE_BY_UART1(u)) \
)

View file

@ -199,10 +199,6 @@ typedef uint32_t rtimer_clock_t;
#define SLIP_ARCH_CONF_USB 0 /**< SLIP over UART by default */
#endif
#ifndef CC2538_RF_CONF_SNIFFER_USB
#define CC2538_RF_CONF_SNIFFER_USB 0 /**< Sniffer out over UART by default */
#endif
#ifndef DBG_CONF_USB
#define DBG_CONF_USB 0 /**< All debugging over UART by default */
#endif
@ -217,12 +213,6 @@ typedef uint32_t rtimer_clock_t;
#endif
#endif
#if !CC2538_RF_CONF_SNIFFER_USB
#ifndef CC2538_RF_CONF_SNIFFER_UART
#define CC2538_RF_CONF_SNIFFER_UART 0 /**< UART to use with sniffer */
#endif
#endif
#if !DBG_CONF_USB
#ifndef DBG_CONF_UART
#define DBG_CONF_UART 0 /**< UART to use for debugging */
@ -249,15 +239,6 @@ typedef uint32_t rtimer_clock_t;
#endif
#endif
/*
* When set, the radio turns off address filtering and sends all captured
* frames down a peripheral (UART or USB, depending on the value of
* CC2538_RF_CONF_SNIFFER_USB)
*/
#ifndef CC2538_RF_CONF_SNIFFER
#define CC2538_RF_CONF_SNIFFER 0
#endif
/**
* \brief Define this as 1 to build a headless node.
*
@ -278,12 +259,6 @@ typedef uint32_t rtimer_clock_t;
#undef STARTUP_CONF_VERBOSE
#define STARTUP_CONF_VERBOSE 0
/* Little sanity check: We can't have quiet sniffers */
#if CC2538_RF_CONF_SNIFFER
#error "CC2538_RF_CONF_SNIFFER == 1 and CC2538_CONF_QUIET == 1"
#error "These values are conflicting. Please set either to 0"
#endif
#endif /* CC2538_CONF_QUIET */
/**
@ -292,8 +267,7 @@ typedef uint32_t rtimer_clock_t;
#ifndef USB_SERIAL_CONF_ENABLE
#define USB_SERIAL_CONF_ENABLE \
((SLIP_ARCH_CONF_USB & SLIP_ARCH_CONF_ENABLED) | \
DBG_CONF_USB | \
(CC2538_RF_CONF_SNIFFER & CC2538_RF_CONF_SNIFFER_USB))
DBG_CONF_USB)
#endif
/*
@ -313,9 +287,6 @@ typedef uint32_t rtimer_clock_t;
#define UART_IN_USE_BY_SLIP(u) (SLIP_ARCH_CONF_ENABLED && \
!SLIP_ARCH_CONF_USB && \
SLIP_ARCH_CONF_UART == (u))
#define UART_IN_USE_BY_RF_SNIFFER(u) (CC2538_RF_CONF_SNIFFER && \
!CC2538_RF_CONF_SNIFFER_USB && \
CC2538_RF_CONF_SNIFFER_UART == (u))
#define UART_IN_USE_BY_DBG(u) (!DBG_CONF_USB && DBG_CONF_UART == (u))
#define UART_IN_USE_BY_UART1(u) (UART1_CONF_UART == (u))
@ -323,7 +294,6 @@ typedef uint32_t rtimer_clock_t;
UART_CONF_ENABLE && \
(UART_IN_USE_BY_SERIAL_LINE(u) || \
UART_IN_USE_BY_SLIP(u) || \
UART_IN_USE_BY_RF_SNIFFER(u) || \
UART_IN_USE_BY_DBG(u) || \
UART_IN_USE_BY_UART1(u)) \
)

View file

@ -172,10 +172,6 @@
#ifndef RF_BLE_CONF_ENABLED
#define RF_BLE_CONF_ENABLED 0 /**< 0 to disable BLE support */
#endif
#ifndef PROP_MODE_CONF_SNIFFER
#define PROP_MODE_CONF_SNIFFER 0 /**< 1 to enable sniffer mode */
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/** @} */

View file

@ -104,7 +104,12 @@ static uint8_t is_gateway;
#endif
void init_platform(void);
/*---------------------------------------------------------------------------*/
#ifdef UART0_CONF_BAUD_RATE
#define UART0_BAUD_RATE UART0_CONF_BAUD_RATE
#else
#define UART0_BAUD_RATE 115200
#endif
/*---------------------------------------------------------------------------*/
#if 0
int
@ -202,9 +207,9 @@ main(int argc, char **argv)
clock_wait(100);
uart0_init(BAUD2UBR(115200)); /* Must come before first printf */
uart0_init(BAUD2UBR(UART0_BAUD_RATE)); /* Must come before first printf */
#if NETSTACK_CONF_WITH_IPV4
slip_arch_init(BAUD2UBR(115200));
slip_arch_init(BAUD2UBR(UART0_BAUD_RATE));
#endif /* NETSTACK_CONF_WITH_IPV4 */
xmem_init();

View file

@ -197,10 +197,6 @@ typedef uint32_t rtimer_clock_t;
#define SLIP_ARCH_CONF_USB 0 /**< SLIP over UART by default */
#endif
#ifndef CC2538_RF_CONF_SNIFFER_USB
#define CC2538_RF_CONF_SNIFFER_USB 0 /**< Sniffer out over UART by default */
#endif
#ifndef DBG_CONF_USB
#define DBG_CONF_USB 0 /**< All debugging over UART by default */
#endif
@ -215,12 +211,6 @@ typedef uint32_t rtimer_clock_t;
#endif
#endif
#if !CC2538_RF_CONF_SNIFFER_USB
#ifndef CC2538_RF_CONF_SNIFFER_UART
#define CC2538_RF_CONF_SNIFFER_UART 0 /**< UART to use with sniffer */
#endif
#endif
#if !DBG_CONF_USB
#ifndef DBG_CONF_UART
#define DBG_CONF_UART 0 /**< UART to use for debugging */
@ -247,15 +237,6 @@ typedef uint32_t rtimer_clock_t;
#endif
#endif
/*
* When set, the radio turns off address filtering and sends all captured
* frames down a peripheral (UART or USB, depending on the value of
* CC2538_RF_CONF_SNIFFER_USB)
*/
#ifndef CC2538_RF_CONF_SNIFFER
#define CC2538_RF_CONF_SNIFFER 0
#endif
/**
* \brief Define this as 1 to build a headless node.
*
@ -276,12 +257,6 @@ typedef uint32_t rtimer_clock_t;
#undef STARTUP_CONF_VERBOSE
#define STARTUP_CONF_VERBOSE 0
/* Little sanity check: We can't have quiet sniffers */
#if CC2538_RF_CONF_SNIFFER
#error "CC2538_RF_CONF_SNIFFER == 1 and CC2538_CONF_QUIET == 1"
#error "These values are conflicting. Please set either to 0"
#endif
#endif /* CC2538_CONF_QUIET */
/**
@ -290,8 +265,7 @@ typedef uint32_t rtimer_clock_t;
#ifndef USB_SERIAL_CONF_ENABLE
#define USB_SERIAL_CONF_ENABLE \
((SLIP_ARCH_CONF_USB & SLIP_ARCH_CONF_ENABLED) | \
DBG_CONF_USB | \
(CC2538_RF_CONF_SNIFFER & CC2538_RF_CONF_SNIFFER_USB))
DBG_CONF_USB)
#endif
/*
@ -311,9 +285,6 @@ typedef uint32_t rtimer_clock_t;
#define UART_IN_USE_BY_SLIP(u) (SLIP_ARCH_CONF_ENABLED && \
!SLIP_ARCH_CONF_USB && \
SLIP_ARCH_CONF_UART == (u))
#define UART_IN_USE_BY_RF_SNIFFER(u) (CC2538_RF_CONF_SNIFFER && \
!CC2538_RF_CONF_SNIFFER_USB && \
CC2538_RF_CONF_SNIFFER_UART == (u))
#define UART_IN_USE_BY_DBG(u) (!DBG_CONF_USB && DBG_CONF_UART == (u))
#define UART_IN_USE_BY_UART1(u) (UART1_CONF_UART == (u))
@ -321,7 +292,6 @@ typedef uint32_t rtimer_clock_t;
UART_CONF_ENABLE && \
(UART_IN_USE_BY_SERIAL_LINE(u) || \
UART_IN_USE_BY_SLIP(u) || \
UART_IN_USE_BY_RF_SNIFFER(u) || \
UART_IN_USE_BY_DBG(u) || \
UART_IN_USE_BY_UART1(u)) \
)

View file

@ -35,6 +35,7 @@ wget/minimal-net \
zolertia/z1/z1 \
settings-example/avr-raven \
ipv6/multicast/sky \
sensniff/z1 \
cfs-coffee/sky \
cfs-coffee/z1 \
cfs-coffee/wismote \

View file

@ -6,8 +6,8 @@ hello-world/cc2530dk \
cc2530dk/cc2530dk \
cc2530dk/border-router/cc2530dk \
cc2530dk/udp-ipv6/cc2530dk \
cc2530dk/sniffer/cc2530dk \
ipv6/multicast/cc2530dk \
sensniff/cc2530dk \
TOOLS=

View file

@ -6,7 +6,6 @@ hello-world/ev-aducrf101mkxz \
ipv6/rpl-border-router/ev-aducrf101mkxz \
webserver-ipv6/ev-aducrf101mkxz \
ipv6/multicast/ev-aducrf101mkxz \
cc2538-common/sniffer/ev-aducrf101mkxz \
cc26xx/cc26xx-web-demo/srf06-cc26xx \
cc26xx/very-sleepy-demo/srf06-cc26xx:BOARD=sensortag/cc2650 \
cc26xx/cc26xx-web-demo/srf06-cc26xx:BOARD=sensortag/cc2650 \
@ -24,12 +23,10 @@ cc2538dk/cc2538dk \
cc2538dk/udp-ipv6-echo-server/cc2538dk \
ipv6/multicast/cc2538dk \
cc2538-common/cc2538dk \
cc2538-common/sniffer/cc2538dk \
cc2538-common/mqtt-demo/cc2538dk \
cc2538-common/crypto/cc2538dk \
cc2538-common/pka/cc2538dk \
cc2538-common/zoul \
cc2538-common/sniffer/zoul \
cc2538-common/mqtt-demo/zoul \
cc2538-common/crypto/zoul \
cc2538-common/pka/zoul \
@ -47,6 +44,13 @@ stm32nucleo-spirit1/sensor-demo/stm32nucleo-spirit1 \
ipv6/multicast/stm32nucleo-spirit1 \
udp-ipv6/stm32nucleo-spirit1 \
hello-world/stm32nucleo-spirit1 \
sensniff/cc2538dk \
sensniff/openmote-cc2538 \
sensniff/zoul \
sensniff/zoul:ZOUL_CONF_SUB_GHZ_SNIFFER=1 \
sensniff/srf06-cc26xx \
sensniff/srf06-cc26xx:BOARD=launchpad/cc1310 \
sensniff/ev-aducrf101mkxz \
cfs-coffee/cc2538dk \
cfs-coffee/openmote-cc2538 \
cfs-coffee/zoul \

View file

@ -16,6 +16,7 @@ jn516x/tsch/simple-sensor-network/rpl-border-router/jn516x \
jn516x/tsch/tx-power-verification/node/jn516x \
jn516x/tsch/tx-power-verification/rpl-border-router/jn516x \
jn516x/tsch/uart1-test-node/jn516x \
sensniff/jn516x \
ipv6/rpl-tsch/jn516x \
ipv6/rpl-tsch/jn516x:MAKE_WITH_ORCHESTRA=1 \
ipv6/rpl-tsch/jn516x:MAKE_WITH_SECURITY=1