Commit fb1bd1f4 authored by 's avatar

fix in mapi_stats


git-svn-id: file:///home/svn/mapi/trunk@1256 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 34a1ebf1
......@@ -529,9 +529,8 @@ void *mapiipc_comm_thread(void *host){ // reads an IPC message - blocking call
for (fnode=flist_head(((struct host*)host)->stats); fnode!=NULL; fnode=flist_next(fnode)) {
stat=(struct mapi_stat*)fnode->data;
if ( strcmp((char*)dbuf->data+sizeof(struct mapi_stat), stat->dev)==0 ) {
((struct mapi_stat*)dbuf->data)->hostname = strdup(stat->hostname);
((struct mapi_stat*)dbuf->data)->dev = strdup(stat->dev);
if ( strcmp( ((struct mapi_stat*)dbuf->data)->dev, stat->dev)==0 ) {
strncpy( ((struct mapi_stat*)dbuf->data)->hostname, stat->hostname, MAPI_STR_LENGTH );
memcpy(stat, dbuf->data, sizeof(struct mapi_stat));
flist_remove(((struct host*)host)->stats, fnode->id);
break;
......
......@@ -4532,8 +4532,8 @@ int mapi_stats(const char *dev, struct mapi_stat *stats)
flist_init(h->stats);
}
stats[seed].hostname=strdup(hostname);
stats[seed].dev=strdup(k);
strncpy(stats[seed].hostname,hostname,MAPI_STR_LENGTH);
strncpy(stats[seed].dev,k,MAPI_STR_LENGTH);
flist_append(h->stats,seed,&stats[seed]);
dbuf.cmd=MAPI_STATS;
......@@ -4593,8 +4593,8 @@ int mapi_stats(const char *dev, struct mapi_stat *stats)
{
case MAPI_STATS_ACK:
memcpy(stats, qbuf.data, sizeof(struct mapi_stat));
stats->hostname=strdup("localhost");
stats->dev=strdup(dev);
strncpy(stats->hostname,"localhost",MAPI_STR_LENGTH);
strncpy(stats->dev,dev,MAPI_STR_LENGTH);
return 1;
case MAPI_STATS_ERR:
......
......@@ -166,8 +166,8 @@ struct mapi_stat {
unsigned int ps_recv; /* number of packets received */
unsigned int ps_drop; /* number of packets dropped */
unsigned int ps_ifdrop; /* drops by interface */
char *hostname;
char *dev;
char hostname[MAPI_STR_LENGTH];
char dev[MAPI_STR_LENGTH];
};
//Prototype of the mapi_loop callback function
......
......@@ -638,8 +638,7 @@ void *handle_request(void *arg) {
else {
dbuf->cmd = MAPI_STATS_ACK;
memcpy(dbuf->data, &stats, sizeof(struct mapi_stat));
memcpy(dbuf->data+sizeof(struct mapi_stat), dev, strlen(dev));
dbuf->length = BASIC_SIZE+sizeof(struct mapi_stat)+strlen(dev);
dbuf->length = BASIC_SIZE+sizeof(struct mapi_stat);
}
free(dev);
break;
......
......@@ -41,7 +41,8 @@ DOT;
}
printf("Results from mapi_stats:\nreceived: %d\ndropped: %d\ndropped by interface: %d\nHostname: %s\nInterface: %s\n",stats.ps_recv,stats.ps_drop,stats.ps_ifdrop,stats.hostname,stats.dev);
//printf("Results from mapi_stats:\nreceived: %d\ndropped: %d\ndropped by interface: %d\nHostname: %s\nInterface: %s\n",stats[1].ps_recv,stats[1].ps_drop,stats[1].ps_ifdrop,stats[1].hostname,stats[1].dev);
// printf("Results from mapi_stats:\nreceived: %d\ndropped: %d\ndropped by interface: %d\nHostname: %s\nInterface: %s\n",stats[0].ps_recv,stats[0].ps_drop,stats[0].ps_ifdrop,stats[0].hostname,stats[0].dev);
// printf("Results from mapi_stats:\nreceived: %d\ndropped: %d\ndropped by interface: %d\nHostname: %s\nInterface: %s\n",stats[1].ps_recv,stats[1].ps_drop,stats[1].ps_ifdrop,stats[1].hostname,stats[1].dev);
DOT;
if( (fd = mapi_close_flow(fd))<0){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment