43 static uint8_t sniff_for_attributes;
46 PROCESS(shell_sniff_process,
"sniff");
49 "sniff: dump incoming packets",
50 &shell_sniff_process);
54 SNIFFER_PACKET_OUTPUT,
55 SNIFFER_ATTRIBUTES_INPUT,
56 SNIFFER_ATTRIBUTES_OUTPUT,
59 struct sniff_attributes_blob {
66 uint16_t transmit_time;
70 struct sniff_packet_blob {
76 sniff_attributes_output(
int type)
78 struct sniff_attributes_blob msg;
81 msg.rssi = packetbuf_attr(PACKETBUF_ATTR_RSSI);
82 msg.lqi = packetbuf_attr(PACKETBUF_ATTR_LINK_QUALITY);
83 msg.timestamp = packetbuf_attr(PACKETBUF_ATTR_TIMESTAMP);
84 msg.listen_time = packetbuf_attr(PACKETBUF_ATTR_LISTEN_TIME);
85 msg.transmit_time = packetbuf_attr(PACKETBUF_ATTR_TRANSMIT_TIME);
86 msg.channel = packetbuf_attr(PACKETBUF_ATTR_CHANNEL);
87 linkaddr_copy(&msg.src, packetbuf_addr(PACKETBUF_ADDR_SENDER));
88 linkaddr_copy(&msg.dest, packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
94 sniff_packet_output(
int type)
96 struct sniff_packet_blob msg;
108 if(sniff_for_attributes) {
109 sniff_attributes_output(SNIFFER_ATTRIBUTES_INPUT);
111 sniff_packet_output(SNIFFER_PACKET_INPUT);
116 output_sniffer(
int mac_status)
118 if(sniff_for_attributes) {
119 sniff_attributes_output(SNIFFER_ATTRIBUTES_OUTPUT);
121 sniff_packet_output(SNIFFER_PACKET_OUTPUT);
127 RIME_SNIFFER(s, input_sniffer, output_sniffer);
131 sniff_for_attributes = 0;
137 sniff_for_attributes = 1;
141 rime_sniffer_add(&s);
146 rime_sniffer_remove(&s);
152 shell_rime_sniff_init(
void)
#define PROCESS_BEGIN()
Define the beginning of a process.
Main header file for the Contiki shell
#define NULL
The null pointer.
uint16_t packetbuf_totlen(void)
Get the total length of the header and data in the packetbuf.
Header file for the Rime stack
void shell_output(struct shell_command *c, void *data1, int len1, const void *data2, int len2)
Output data from a shell command.
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a Rime address.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
#define PROCESS_EXITHANDLER(handler)
Specify an action when a process exits.
void shell_register_command(struct shell_command *c)
Register a command with the shell.
#define PROCESS_WAIT_EVENT_UNTIL(c)
Wait for an event to be posted to the process, with an extra condition.
#define PROCESS(name, strname)
Declare a process.
int shell_event_input
The event number for shell input data.
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
#define SHELL_COMMAND(name, command, description, process)
Define a shell command.