ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/network_stats.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/network_stats.c (file contents):
Revision 1.54 by tdb, Mon Mar 8 13:48:00 2004 UTC vs.
Revision 1.58 by tdb, Sun Apr 4 21:54:48 2004 UTC

# Line 66 | Line 66 | typedef __uint64_t u64;
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;
# Line 199 | Line 200 | network_stat_t *get_network_stats(int *entries){
200                                   * have the rbytes/obytes values; for instance,
201                                   * the loopback devices have this behaviour
202                                   * (although they do track packets in/out). */
203 +                                /* FIXME: Show packet counts when byte counts
204 +                                 * not available. */
205                                  continue;
206                          }
207  
# Line 320 | Line 323 | network_stat_t *get_network_stats(int *entries){
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
328        long long result;
329        if(new>=old){
330                result = (new-old);
331        }else{
332                result = (MAXVAL+(new-old));
333        }
334
335        return result;
336
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) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines