Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Add FreeBSD support for netspeeds, entropy and ip components
[slstatus.git]
/
components
/
netspeeds.c
diff --git
a/components/netspeeds.c
b/components/netspeeds.c
index
f0f7455
..
0029177
100644
(file)
--- a/
components/netspeeds.c
+++ b/
components/netspeeds.c
@@
-10,8
+10,8
@@
const char *
netspeed_rx(const char *interface)
{
const char *
netspeed_rx(const char *interface)
{
- uint
64
_t oldrxbytes;
- static uint
64_t rxbytes = 0
;
+ uint
max
_t oldrxbytes;
+ static uint
max_t rxbytes
;
extern const unsigned int interval;
char path[PATH_MAX];
extern const unsigned int interval;
char path[PATH_MAX];
@@
-22,22
+22,22
@@
interface) < 0) {
return NULL;
}
interface) < 0) {
return NULL;
}
- if (pscanf(path, "%
ll
u", &rxbytes) != 1) {
+ if (pscanf(path, "%
j
u", &rxbytes) != 1) {
return NULL;
}
if (oldrxbytes == 0) {
return NULL;
}
return NULL;
}
if (oldrxbytes == 0) {
return NULL;
}
- return fmt_human
_2((rxbytes - oldrxbytes) *
-
1000 / interval, "B/s"
);
+ return fmt_human
((rxbytes - oldrxbytes) * 1000 / interval,
+
1024
);
}
const char *
netspeed_tx(const char *interface)
{
}
const char *
netspeed_tx(const char *interface)
{
- uint
64
_t oldtxbytes;
- static uint
64_t txbytes = 0
;
+ uint
max
_t oldtxbytes;
+ static uint
max_t txbytes
;
extern const unsigned int interval;
char path[PATH_MAX];
extern const unsigned int interval;
char path[PATH_MAX];
@@
-48,17
+48,17
@@
interface) < 0) {
return NULL;
}
interface) < 0) {
return NULL;
}
- if (pscanf(path, "%
ll
u", &txbytes) != 1) {
+ if (pscanf(path, "%
j
u", &txbytes) != 1) {
return NULL;
}
if (oldtxbytes == 0) {
return NULL;
}
return NULL;
}
if (oldtxbytes == 0) {
return NULL;
}
- return fmt_human
_2((txbytes - oldtxbytes) *
-
1000 / interval, "B/s"
);
+ return fmt_human
((txbytes - oldtxbytes) * 1000 / interval,
+
1024
);
}
}
-#elif defined(__OpenBSD__)
+#elif defined(__OpenBSD__)
| defined(__FreeBSD__)
#include <string.h>
#include <ifaddrs.h>
#include <sys/types.h>
#include <string.h>
#include <ifaddrs.h>
#include <sys/types.h>
@@
-70,8
+70,8
@@
{
struct ifaddrs *ifal, *ifa;
struct if_data *ifd;
{
struct ifaddrs *ifal, *ifa;
struct if_data *ifd;
- uint
64
_t oldrxbytes;
- static uint
64_t rxbytes = 0
;
+ uint
max
_t oldrxbytes;
+ static uint
max_t rxbytes
;
extern const unsigned int interval;
int if_ok = 0;
extern const unsigned int interval;
int if_ok = 0;
@@
-97,8
+97,8
@@
return NULL;
}
return NULL;
}
- return fmt_human
_2((rxbytes - oldrxbytes) *
-
1000 / interval, "B/s"
);
+ return fmt_human
((rxbytes - oldrxbytes) * 1000 / interval,
+
1024
);
}
const char *
}
const char *
@@
-106,8
+106,8
@@
{
struct ifaddrs *ifal, *ifa;
struct if_data *ifd;
{
struct ifaddrs *ifal, *ifa;
struct if_data *ifd;
- uint
64
_t oldtxbytes;
- static uint
64_t txbytes = 0
;
+ uint
max
_t oldtxbytes;
+ static uint
max_t txbytes
;
extern const unsigned int interval;
int if_ok = 0;
extern const unsigned int interval;
int if_ok = 0;
@@
-133,7
+133,7
@@
return NULL;
}
return NULL;
}
- return fmt_human
_2((txbytes - oldtxbytes) *
-
1000 / interval, "B/s"
);
+ return fmt_human
((txbytes - oldtxbytes) * 1000 / interval,
+
1024
);
}
#endif
}
#endif