1 |
/* |
2 |
* NetPeek.cpp - Utility program for monitoring SheepNet add-on |
3 |
*/ |
4 |
|
5 |
#include "sysdeps.h" |
6 |
#include "sheep_net.h" |
7 |
|
8 |
#include <stdio.h> |
9 |
|
10 |
static area_id buffer_area; // Packet buffer area |
11 |
static net_buffer *net_buffer_ptr; // Pointer to packet buffer |
12 |
|
13 |
int main(void) |
14 |
{ |
15 |
area_id handler_buffer; |
16 |
if ((handler_buffer = find_area("packet buffer")) < B_NO_ERROR) { |
17 |
printf("Can't find packet buffer\n"); |
18 |
return 10; |
19 |
} |
20 |
if ((buffer_area = clone_area("local packet buffer", &net_buffer_ptr, B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, handler_buffer)) < B_NO_ERROR) { |
21 |
printf("Can't clone packet buffer\n"); |
22 |
return 10; |
23 |
} |
24 |
|
25 |
uint8 *p = net_buffer_ptr->ether_addr; |
26 |
printf("Ethernet address : %02x %02x %02x %02x %02x %02x\n", p[0], p[1], p[2], p[3], p[4], p[5]); |
27 |
printf("read_sem : %d\n", net_buffer_ptr->read_sem); |
28 |
printf("read_ofs : %d\n", net_buffer_ptr->read_ofs); |
29 |
printf("read_packet_size : %d\n", net_buffer_ptr->read_packet_size); |
30 |
printf("read_packet_count : %d\n", net_buffer_ptr->read_packet_count); |
31 |
printf("write_sem : %d\n", net_buffer_ptr->write_sem); |
32 |
printf("write_ofs : %d\n", net_buffer_ptr->write_ofs); |
33 |
printf("write_packet_size : %d\n", net_buffer_ptr->write_packet_size); |
34 |
printf("write_packet_count: %d\n", net_buffer_ptr->write_packet_count); |
35 |
|
36 |
printf("\nRead packets:\n"); |
37 |
for (int i=0; i<READ_PACKET_COUNT; i++) { |
38 |
net_packet *p = &net_buffer_ptr->read[i]; |
39 |
printf("cmd : %08lx\n", p->cmd); |
40 |
printf("length: %d\n", p->length); |
41 |
} |
42 |
printf("\nWrite packets:\n"); |
43 |
for (int i=0; i<WRITE_PACKET_COUNT; i++) { |
44 |
net_packet *p = &net_buffer_ptr->write[i]; |
45 |
printf("cmd : %08lx\n", p->cmd); |
46 |
printf("length: %d\n", p->length); |
47 |
} |
48 |
return 0; |
49 |
} |