From: Heidi N. <hei...@us...> - 2005-03-07 09:46:14
|
Update of /cvsroot/sblim/cmpi-network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8530 Modified Files: CHANGE.LOG OSBase_CommonNetwork.c OSBase_IPProtocolEndpoint.c Log Message: bug# 1158159: fixed parsing of /proc/net/dev for systems with high amount of network traffic Index: OSBase_CommonNetwork.c =================================================================== RCS file: /cvsroot/sblim/cmpi-network/OSBase_CommonNetwork.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- OSBase_CommonNetwork.c 4 Dec 2003 14:38:44 -0000 1.6 +++ OSBase_CommonNetwork.c 7 Mar 2005 09:46:00 -0000 1.7 @@ -102,10 +102,8 @@ char ** hdout = NULL; char ** hdchk = NULL; char ** hderr = NULL; - char * str = NULL; - char * ptr = NULL; - char * id = NULL; char * cmd = NULL; + char port[64]; unsigned short type = 0; int i = 2; /* start at third line */ int rc = 0; @@ -117,19 +115,12 @@ if( rc == 0 ) { while( hdout[i] != NULL) { - str = strchr(hdout[i] , ':'); - id = calloc(1, (strlen(hdout[i])-strlen(str)+1)); - strncpy( id, hdout[i], strlen(hdout[i])-strlen(str)); - - ptr = id+strlen(id); - *(ptr) = '\0'; - str = strrchr(id, ' '); - - cmd = calloc(1, (strlen(id)+16) ); + memset(port,0,sizeof(port)); + sscanf(hdout[i]," %[^:]:",port); + + cmd = calloc(1,100); strcpy(cmd, "/sbin/ifconfig "); - if( str == NULL ) { ptr = id; } - else { ptr = id+(strlen(id)-strlen(str)+1); } - strcat(cmd, ptr ); + strcat(cmd, port); rc = runcommand( cmd, NULL , &hdchk , &hderr ); if(cmd) { free(cmd); cmd = NULL; } @@ -140,9 +131,9 @@ if( strstr(hdchk[0], "Local Loopback") != NULL ) { type = 3; } } else { - if( strstr(id, "eth") != NULL ) { type = 1; } - if( strstr(id, "tr") != NULL ) { type = 2; } - if( strstr(id, "lo") != NULL ) { type = 3; } + if( strstr(port,"eth") != NULL ) { type = 1; } + if( strstr(port,"tr") != NULL ) { type = 2; } + if( strstr(port,"lo") != NULL ) { type = 3; } } freeresultbuf(hdchk); freeresultbuf(hderr); @@ -157,15 +148,10 @@ hlp->next = calloc (1,sizeof(struct netPortList)); hlp = hlp->next; } - if( str == NULL ) { - rc = _netPort_data( id, type, &(hlp->sptr)); - } - else { - rc = _netPort_data( id+(strlen(id)-strlen(str)+1), type, &(hlp->sptr)); - } + + rc = _netPort_data( port, type, &(hlp->sptr)); } type = 0; - if(id) free(id); i++; rc = 0; } Index: OSBase_IPProtocolEndpoint.c =================================================================== RCS file: /cvsroot/sblim/cmpi-network/OSBase_IPProtocolEndpoint.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- OSBase_IPProtocolEndpoint.c 4 Dec 2003 14:38:44 -0000 1.6 +++ OSBase_IPProtocolEndpoint.c 7 Mar 2005 09:46:00 -0000 1.7 @@ -51,10 +51,8 @@ int enum_all_ipProtocolEndpoints( struct ipPEndpointList ** lptr ) { struct ipPEndpointList * hlp = NULL; char ** hdout = NULL; - char * str = NULL; - char * ptr = NULL; - char * id = NULL; char * name = NULL; + char port[64]; int i = 2; /* start at third line */ int rc = 0; @@ -75,20 +73,10 @@ hlp = hlp->next; } - str = strchr(hdout[i] , ':'); - id = calloc(1, (strlen(hdout[i])-strlen(str)+1)); - strncpy( id, hdout[i], strlen(hdout[i])-strlen(str)); - ptr = id+strlen(id); - *(ptr) = '\0'; - str = strrchr(id, ' '); + memset(port,0,sizeof(port)); + sscanf(hdout[i]," %[^:]:",port); + name = _get_ipProtocolEndpoint_name( &port ); - if( str == NULL ) { - name = _get_ipProtocolEndpoint_name( id ); - } - else { - name = _get_ipProtocolEndpoint_name( id+(strlen(id)-strlen(str)+1) ); - } - if(id) free(id); rc = _ipProtocolEndpoint_data( name, &(hlp->sptr)); if(name) free(name); Index: CHANGE.LOG =================================================================== RCS file: /cvsroot/sblim/cmpi-network/CHANGE.LOG,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- CHANGE.LOG 20 Sep 2004 12:16:06 -0000 1.5 +++ CHANGE.LOG 7 Mar 2005 09:45:59 -0000 1.6 @@ -21,4 +21,11 @@ * support for property list filter on EnumInstances and GetInstance + +// =================================================================== +// new in version 1.3.1 : + +* bug# 1158159: fixed parsing of /proc/net/dev for systems with high + amount of network traffic + // =================================================================== |