29 |
|
#include <string.h> |
30 |
|
#include "statgrab.h" |
31 |
|
#include "vector.h" |
32 |
+ |
#include "tools.h" |
33 |
|
#include <time.h> |
34 |
|
#ifdef SOLARIS |
35 |
|
#include <kstat.h> |
49 |
|
#include <sys/socket.h> |
50 |
|
#include <net/if.h> |
51 |
|
#include <ctype.h> |
51 |
– |
#include "tools.h" |
52 |
|
/* Stuff which could be defined by defining KERNEL, but |
53 |
|
* that would be a bad idea, so we'll just declare it here |
54 |
|
*/ |
125 |
|
} |
126 |
|
network_stat_ptr=network_stats+interfaces; |
127 |
|
|
128 |
< |
if(network_stat_ptr->interface_name!=NULL) free(network_stat_ptr->interface_name); |
129 |
< |
network_stat_ptr->interface_name=strdup(net_ptr->ifa_name); |
130 |
< |
if(network_stat_ptr->interface_name==NULL) return NULL; |
128 |
> |
if (update_string(&network_stat_ptr->interface_name, |
129 |
> |
net_ptr->ifa_name) == NULL) { |
130 |
> |
return NULL; |
131 |
> |
} |
132 |
|
net_data=(struct if_data *)net_ptr->ifa_data; |
133 |
|
network_stat_ptr->rx=net_data->ifi_ibytes; |
134 |
|
network_stat_ptr->tx=net_data->ifi_obytes; |
225 |
|
network_stat_ptr->collisions=knp->value.ui32; |
226 |
|
|
227 |
|
/* Read interface name */ |
228 |
< |
if(network_stat_ptr->interface_name!=NULL){ |
229 |
< |
free(network_stat_ptr->interface_name); |
228 |
> |
if (update_string(&network_stat_ptr->interface_name, |
229 |
> |
ksp->ks_name) == NULL) { |
230 |
> |
return NULL; |
231 |
|
} |
230 |
– |
network_stat_ptr->interface_name=strdup(ksp->ks_name); |
232 |
|
|
233 |
|
/* Store systime */ |
234 |
|
network_stat_ptr->systime=time(NULL); |
332 |
|
src = &network_stats[i]; |
333 |
|
dest = &diff[i]; |
334 |
|
|
335 |
< |
if (dest->interface_name != NULL) { |
336 |
< |
free(dest->interface_name); |
335 |
> |
if (update_string(&dest->interface_name, |
336 |
> |
src->interface_name) == NULL) { |
337 |
> |
return NULL; |
338 |
|
} |
337 |
– |
dest->interface_name = strdup(src->interface_name); |
339 |
|
dest->rx = src->rx; |
340 |
|
dest->tx = src->tx; |
341 |
|
dest->ipackets = src->ipackets; |
450 |
|
network_iface_stat_ptr->up = 0; |
451 |
|
} |
452 |
|
|
453 |
< |
if (network_iface_stat_ptr->interface_name != NULL) free(network_iface_stat_ptr->interface_name); |
454 |
< |
network_iface_stat_ptr->interface_name = strdup(net_ptr->ifa_name); |
455 |
< |
if (network_iface_stat_ptr->interface_name == NULL) return NULL; |
453 |
> |
if (update_string(&network_iface_stat_ptr->interface_name, |
454 |
> |
net_ptr->ifa_name) == NULL) { |
455 |
> |
return NULL; |
456 |
> |
} |
457 |
|
|
458 |
|
network_iface_stat_ptr->speed = 0; |
459 |
|
network_iface_stat_ptr->dup = UNKNOWN_DUPLEX; |
552 |
|
network_iface_stat_ptr = network_iface_stats + ifaces; |
553 |
|
ifaces++; |
554 |
|
|
555 |
< |
if (network_iface_stat_ptr->interface_name != NULL) free(network_iface_stat_ptr->interface_name); |
556 |
< |
network_iface_stat_ptr->interface_name = strdup(ksp->ks_name); |
557 |
< |
if (network_iface_stat_ptr->interface_name == NULL) return NULL; |
555 |
> |
if (update_string(&network_iface_stat_ptr->interface_name, |
556 |
> |
ksp->ks_name) == NULL) { |
557 |
> |
return NULL; |
558 |
> |
} |
559 |
|
|
560 |
|
if ((ifr.ifr_flags & IFF_UP) != 0) { |
561 |
|
network_iface_stat_ptr->up = 1; |
628 |
|
return NULL; |
629 |
|
} |
630 |
|
network_iface_stat_ptr = network_iface_stats + ifaces; |
631 |
< |
network_iface_stat_ptr->interface_name = strdup(name); |
631 |
> |
|
632 |
> |
if (update_string(&network_iface_stat_ptr->interface_name, |
633 |
> |
name) == NULL) { |
634 |
> |
return NULL; |
635 |
> |
} |
636 |
|
if ((ifr.ifr_flags & IFF_UP) != 0) { |
637 |
|
network_iface_stat_ptr->up = 1; |
638 |
|
} else { |