-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstats.c
79 lines (73 loc) · 1.62 KB
/
stats.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "stats.h"
#include "util.h"
#include <stdio.h>
stats_t eth_nopkt_rx = 0;
stats_t eth_pkt_rx = 0;
stats_t eth_pkt_tx = 0;
stats_t eth_txerr = 0;
stats_t eth_rxerr = 0;
stats_t eth_pkts_buffered = 0;
stats_t ip_arp_pkt_in = 0;
stats_t ip_arp_pkt_out = 0;
stats_t ip_ipv4_pkt_in = 0;
stats_t ip_ipv4_pkt_out = 0;
stats_t ip_icmp4_pkt_in = 0;
stats_t ip_icmp4_pkt_out = 0;
stats_t ip_tcp4_pkt_in = 0;
stats_t ip_tcp4_pkt_out = 0;
stats_t ip_udp4_pkt_in = 0;
stats_t ip_udp4_pkt_out = 0;
stats_t ip_other_pkt = 0;
stats_t ip_stray_pkt = 0;
stats_t ip_bad_checksum = 0;
stats_t wd_interrupts = 0;
stats_t eth_interrupts = 0;
stats_t adc_interrupts = 0;
stats_t t1_interrupts = 0;
stats_t t1_unhandled = 0;
stats_t t1_unhandled_max = 0;
static const __flash char format_string[] =
{
"int adc: %u\n"
"int wd: %u\n"
"int eth: %u\n"
"int t1: %u\n"
"int t1um: %u\n"
"pkt no rx: %u\n"
"pkt rx: %u\n"
"pkt tx: %u\n"
"err rx: %u\n"
"err tx: %u\n"
"buf rx: %u\n"
"arp: %u/%u\n"
"ipv4: %u/%u\n"
"icmp4: %u/%u\n"
"udp4: %u/%u\n"
"tcp4: %u/%u\n"
"other: %u\n"
"stray: %u\n"
"c/s err: %u\n"
};
void stats_generate(uint16_t size, uint8_t *dst)
{
snprintf_P((char *)dst, (size_t)size, (const char *)format_string,
adc_interrupts,
wd_interrupts,
eth_interrupts,
t1_interrupts,
t1_unhandled_max,
eth_nopkt_rx,
eth_pkt_rx,
eth_pkt_tx,
eth_rxerr,
eth_txerr,
eth_pkts_buffered,
ip_arp_pkt_in, ip_arp_pkt_out,
ip_ipv4_pkt_in, ip_ipv4_pkt_out,
ip_icmp4_pkt_in, ip_icmp4_pkt_out,
ip_udp4_pkt_in, ip_udp4_pkt_out,
ip_tcp4_pkt_in, ip_tcp4_pkt_out,
ip_other_pkt,
ip_stray_pkt,
ip_bad_checksum);
}