the new format
git-svn-id: http://172.17.0.253/svn/soft_pkgs/sys_nicmonitor@146 09c3743a-b0dd-45d3-b506-aa74c7a2a6ef
This commit is contained in:
82
code/trunk/test/getmem.c
Normal file
82
code/trunk/test/getmem.c
Normal file
@@ -0,0 +1,82 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nicinfo_shm.h"
|
||||
|
||||
typedef struct net_info{
|
||||
NETCARD_INFO info[MAXNICNUM];
|
||||
}SHM;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
NETCARD_INFO net;
|
||||
#if 0
|
||||
char shm_path[1024];
|
||||
char sem_path[1024];
|
||||
|
||||
memset(shm_path, 0, sizeof(shm_path));
|
||||
memset(sem_path, 0, sizeof(sem_path));
|
||||
|
||||
strcpy(shm_path, getenv("D5000_HOME"));
|
||||
strcat(shm_path, "/conf/nic/shm_sys_netcard_info");
|
||||
strcpy(sem_path, getenv("D5000_HOME"));
|
||||
strcat(sem_path, "/conf/nic/sem_sys_netcard_info");
|
||||
if((ret = init_nic_info(shm_path, sem_path)) == -1){
|
||||
fprintf(stderr, "shm or sem path error!\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
memset(&net, 0, sizeof(NETCARD_INFO));
|
||||
if(argc != 2){
|
||||
fprintf(stderr, "Usage:%s netcard\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
while((ret = get_nic_info(argv[1], &net)) != -1){
|
||||
fprintf(stdout, "==========================网卡信息==============================\n");
|
||||
fprintf(stdout,"DEVICE NAME : %s\nIPADDR : %d.%d.%d.%d\nBROADCAST : %d.%d.%d.%d\nNETMASK : %d.%d.%d.%d\nHWADDR : %02x:%02x:%02x:%02x:%02x:%02x\nFLAGS = %d\nMTU = %d\nTx_queue_len = %d\nTime_stamp = %d\n\nReceive bytes:%llu\nReceive packets:%llu\nReceive errors:%lu\nReceive dropped:%lu\nReceive multicast:%lu\nReceive fifo:%lu\n\nTransmit bytes:%llu\nTransmit packets:%llu\nTransmit errors:%lu\nTransmit dropped:%lu\nTransmit fifo:%lu\nTransmit collisions:%lu\nTransmit carrier:%lu\n\nAverage flow:%d\n",
|
||||
net.charname,
|
||||
(unsigned char)net.addr.sa_data[2],
|
||||
(unsigned char)net.addr.sa_data[3],
|
||||
(unsigned char)net.addr.sa_data[4],
|
||||
(unsigned char)net.addr.sa_data[5],
|
||||
(unsigned char)net.broadaddr.sa_data[2],
|
||||
(unsigned char)net.broadaddr.sa_data[3],
|
||||
(unsigned char)net.broadaddr.sa_data[4],
|
||||
(unsigned char)net.broadaddr.sa_data[5],
|
||||
(unsigned char)net.netmask.sa_data[2],
|
||||
(unsigned char)net.netmask.sa_data[3],
|
||||
(unsigned char)net.netmask.sa_data[4],
|
||||
(unsigned char)net.netmask.sa_data[5],
|
||||
(unsigned char)net.hwaddr.sa_data[0],
|
||||
(unsigned char)net.hwaddr.sa_data[1],
|
||||
(unsigned char)net.hwaddr.sa_data[2],
|
||||
(unsigned char)net.hwaddr.sa_data[3],
|
||||
(unsigned char)net.hwaddr.sa_data[4],
|
||||
(unsigned char)net.hwaddr.sa_data[5],
|
||||
net.flags,
|
||||
net.mtu,
|
||||
net.tx_queue_len,
|
||||
net.time_stamp,
|
||||
net.rx_bytes,
|
||||
net.rx_packets,
|
||||
net.rx_errors,
|
||||
net.rx_dropped,
|
||||
net.rx_multicast,
|
||||
net.rx_fifo_errors,
|
||||
net.tx_bytes,
|
||||
net.tx_packets,
|
||||
net.tx_errors,
|
||||
net.tx_dropped,
|
||||
net.tx_fifo_errors,
|
||||
net.collisions,
|
||||
net.tx_carrier_errors,
|
||||
net.average_flow);
|
||||
getchar();
|
||||
}
|
||||
fprintf(stderr, "No information of %s !\n", argv[1]);
|
||||
|
||||
// rls_nic_info();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user