66 |
|
#include <net/if.h> |
67 |
|
#include <net/if_media.h> |
68 |
|
#include <sys/ioctl.h> |
69 |
+ |
#include <unistd.h> |
70 |
|
#endif |
71 |
|
|
72 |
|
static network_stat_t *network_stats=NULL; |
323 |
|
} |
324 |
|
|
325 |
|
long long transfer_diff(long long new, long long old){ |
326 |
< |
#if defined(SOL7) || defined(LINUX) || defined(FREEBSD) || defined(DFBSD) |
327 |
< |
#define MAXVAL 0xffffffffLL |
326 |
> |
#if defined(SOL7) || defined(LINUX) || defined(FREEBSD) || defined(DFBSD) || defined(OPENBSD) |
327 |
> |
/* 32-bit quantities, so we must explicitly deal with wraparound. */ |
328 |
> |
#define MAXVAL 0x100000000LL |
329 |
> |
if (new >= old) { |
330 |
> |
return new - old; |
331 |
> |
} else { |
332 |
> |
return MAXVAL + new - old; |
333 |
> |
} |
334 |
|
#else |
335 |
< |
#define MAXVAL 0xffffffffffffffffLL |
335 |
> |
/* 64-bit quantities, so plain subtraction works. */ |
336 |
> |
return new - old; |
337 |
|
#endif |
330 |
– |
long long result; |
331 |
– |
if(new>=old){ |
332 |
– |
result = (new-old); |
333 |
– |
}else{ |
334 |
– |
result = (MAXVAL+(new-old)); |
335 |
– |
} |
336 |
– |
|
337 |
– |
return result; |
338 |
– |
|
338 |
|
} |
339 |
|
|
340 |
|
network_stat_t *get_network_stats_diff(int *entries) { |
341 |
|
static network_stat_t *diff = NULL; |
342 |
|
static int diff_count = 0; |
343 |
< |
network_stat_t *src, *dest; |
343 |
> |
network_stat_t *src = NULL, *dest; |
344 |
|
int i, j, new_count; |
345 |
|
|
346 |
|
if (network_stats == NULL) { |