Commit Graph

16 Commits

Author SHA1 Message Date
Aaron Marcher 43a12832a3 Change uint64_t to uintmax_t 2018-07-07 10:50:25 +02:00
Aaron Marcher 825f637e20 netspeeds: Fix indentation 2018-05-22 12:42:31 +02:00
Aaron Marcher cbbf59fd3d Change to fmt_human in netspeeds on OpenBSD
Thanks to Hiltjo
2018-05-22 12:21:52 +02:00
Aaron Marcher 10dbc9543e Merge fmt_human_2 and fmt_human_10 to one function
Now only one function, fmt_human, takes an additional argument "base".
2018-05-21 14:44:21 +02:00
Aaron Marcher ec5c35ec9f Remove units from numbers
This is a first step to decouple formatting from information because of
two reasons:

 1. The components should only gather and return the values by design
 2. Fine grained user control should be a focus

Scaling will be implemented in a different way in a later commit.
2018-05-21 00:16:54 +02:00
Aaron Marcher 3f45a5f7ca Remove initialization to 0 for static vars 2018-05-20 00:17:35 +02:00
Laslo Hunhold 46c4540dd2 Implement fmt_human_2() and fmt_human_10()
These functions take the raw number and a unit and automatically
print it out "scaled down" to a proper SI-prefix, for powers of 2
and 10 respectively.

Apply them to the 2-power cases and keep the 10-power for a later
commit.
2018-05-19 22:58:21 +02:00
Laslo Hunhold 68a3902dc5 Increase precision in netspeeds.c
First dividing by interval before multiplying with 1000 decreases the
precision by +-(interval - 1) * 1000, as interval arithmetic always
applies the Gauß-function to the result.

This is not necessary and simply reordering the operations mitigates
this.
2018-05-19 20:14:09 +02:00
Laslo Hunhold 422cadfd5f Implement esnprintf() and make formatted calls more efficient
Within the components, snprintf() was unchecked and had inefficient
calls in some places.
We implement esnprintf() that does all the dirty laundry for us
and use it exclusively now.
2018-05-19 19:44:02 +02:00
Aaron Marcher d47d78255e Use `int` for flags 2018-05-19 13:29:21 +02:00
Aaron Marcher 06d4447f03 Set {r,t}xbytes 0 before incrementing them on OBSD 2018-05-19 13:19:53 +02:00
Aaron Marcher a37224bf7b Missing assignment for last commit 2018-05-19 13:12:06 +02:00
Aaron Marcher e3ccac3298 Unify and simplify netspeed logic and types 2018-05-19 13:07:05 +02:00
Tobias Tschinkowitz 2321aecff0 netspeeds: added error condition for openbsd
implemented additional error condition for openbsd netstat in case the
interface could not be found in the interface list or if_data is not
readable.
2018-05-19 12:20:25 +02:00
Tobias Tschinkowitz 22175f0d57 implemented openbsd netspeed functions
implemented the netspeed functionality for openbsd.
furthermore the static keyword was removed of the interval variable in
config.def.h for usage as extern variable.
2018-05-19 01:44:36 +02:00
Aaron Marcher 0d05b3d13d Add network speed functions 2018-05-19 00:31:33 +02:00