Contiki 3.x
sniffer.c
1 /*
2  * Redistribution and use in source and binary forms, with or without
3  * modification, are permitted provided that the following conditions
4  * are met:
5  * 1. Redistributions of source code must retain the above copyright
6  * notice, this list of conditions and the following disclaimer.
7  * 2. Redistributions in binary form must reproduce the above copyright
8  * notice, this list of conditions and the following disclaimer in the
9  * documentation and/or other materials provided with the distribution.
10  * 3. Neither the name of the Institute nor the names of its contributors
11  * may be used to endorse or promote products derived from this software
12  * without specific prior written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * This file is part of the Contiki operating system.
27  *
28  */
29 
30 /*
31  Author: Robert Olsson <robert@radio-sensors.com>
32 */
33 
34 #include "contiki.h"
35 #include "net/rime/rime.h"
36 #include "random.h"
37 #include "dev/button-sensor.h"
38 #include "dev/leds.h"
39 #include <stdio.h>
40 /*---------------------------------------------------------------------------*/
41 
42 PROCESS(sniffer_process, "Sniffer process");
43 AUTOSTART_PROCESSES(&sniffer_process);
44 
45 /*---------------------------------------------------------------------------*/
46 PROCESS_THREAD(sniffer_process, ev, data)
47 {
48  PROCESS_BEGIN();
49 
50  /*
51  To get rf230bb radio in sniff mode we need to have radio in RX_ON.
52  The promisc commands fixes this for us. No need to set PAN and
53  address or MAC to zero is this case. Se Atmel datasheet. There is
54  a chance other radios works the same way.
55  */
56 
57  rf230_set_promiscuous_mode(1);
58 
59  printf("Sniffer started\n");
60 
61  while(1) {
62  PROCESS_YIELD();
63  }
64 
65  PROCESS_END();
66 }
67 /*---------------------------------------------------------------------------*/
#define PROCESS_END()
Define the end of a process.
Definition: process.h:131
#define PROCESS(name, strname)
Declare a process.
Definition: process.h:307
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
Definition: process.h:273
Header file for the Rime stack
#define PROCESS_YIELD()
Yield the currently running process.
Definition: process.h:164
#define PROCESS_BEGIN()
Define the beginning of a process.
Definition: process.h:120