diff -up sblim-cmpi-network-1.4.0/cmpiOSBase_NetworkPortImplementsIPEndpoint.c.orig sblim-cmpi-network-1.4.0/cmpiOSBase_NetworkPortImplementsIPEndpoint.c --- sblim-cmpi-network-1.4.0/cmpiOSBase_NetworkPortImplementsIPEndpoint.c.orig 2009-05-23 04:52:50.000000000 +0200 +++ sblim-cmpi-network-1.4.0/cmpiOSBase_NetworkPortImplementsIPEndpoint.c 2012-05-10 10:56:28.840998828 +0200 @@ -104,11 +104,16 @@ CMPIInstance * _assoc_get_networkPort_IN const CMPIObjectPath * ref, CMPIStatus * rc) { CMPIInstance * ci = NULL; + CMPIStatus nprc = {CMPI_RC_OK, NULL}; CMPIObjectPath * op = NULL; CMPIString * name = NULL; - char * targetClass = NULL; + CMPIString * npname = NULL; + char * targetClass[3] = { _RefLeftClassEth, _RefLeftClassTr, _RefLeftClassLo }; char * ptr = NULL; + char * npptr = NULL; char * id = NULL; + int i = 0; + int linkTech = 0; _OSBASE_TRACE(2,("--- _assoc_get_networkPort_INST() called")); @@ -116,10 +121,6 @@ CMPIInstance * _assoc_get_networkPort_IN if( name == NULL ) { goto exit; } ptr = CMGetCharPtr(name); - if( strstr(ptr,"eth") != NULL ) { targetClass = _RefLeftClassEth; } - else if( strstr(ptr,"tr") != NULL ) { targetClass = _RefLeftClassTr; } - else if( strstr(ptr,"lo") != NULL ) { targetClass = _RefLeftClassLo; } - else { goto exit; } /* tool method call to get the unique name of the system */ if( !get_system_name() ) { @@ -129,38 +130,50 @@ CMPIInstance * _assoc_get_networkPort_IN goto exit; } - /* create CMPIObjectPath of subclass of NetworkPort */ - op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(ref,rc)), - targetClass, rc ); - if( CMIsNullObject(op) ) { - CMSetStatusWithChars( _broker, rc, - CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed." ); - _OSBASE_TRACE(2,("--- _assoc_get_networkPort_INST() failed : %s",CMGetCharPtr(rc->msg))); - goto exit; - } - id = calloc(1,(strlen(ptr)-4)); strcpy(id,ptr+5); - CMSetNameSpace(op,CMGetCharPtr(CMGetNameSpace(ref,rc))); - - CMAddKey(op, "SystemCreationClassName", CSCreationClassName, CMPI_chars); - CMAddKey(op, "SystemName", get_system_name(), CMPI_chars); - CMAddKey(op, "CreationClassName", targetClass, CMPI_chars); - CMAddKey(op, "DeviceID", id, CMPI_chars); - - ci = CBGetInstance(_broker,ctx,op,NULL,rc); - if( ci == NULL ) { - CMSetStatusWithChars( _broker, rc, - CMPI_RC_ERR_FAILED, "CBGetInstance(_broker,ctx,op,NULL,rc)" ); - _OSBASE_TRACE(2,("--- _assoc_get_networkPort_INST() failed : %s",CMGetCharPtr(rc->msg))); + for (i = 0; i < 3; i++) + { + /* create CMPIObjectPath of subclass of NetworkPort */ + op = CMNewObjectPath( _broker, CMGetCharPtr(CMGetNameSpace(ref,rc)), targetClass[i], rc ); + if (CMIsNullObject(op)) + { + CMSetStatusWithChars(_broker, rc, CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed."); + _OSBASE_TRACE(2,("--- _assoc_get_networkPort_INST() failed : %s",CMGetCharPtr(rc->msg))); + ci = NULL; + goto exit; + } + + CMSetNameSpace(op,CMGetCharPtr(CMGetNameSpace(ref,rc))); + + CMAddKey(op, "SystemCreationClassName", CSCreationClassName, CMPI_chars); + CMAddKey(op, "SystemName", get_system_name(), CMPI_chars); + CMAddKey(op, "CreationClassName", targetClass[i], CMPI_chars); + CMAddKey(op, "DeviceID", id, CMPI_chars); + + ci = CBGetInstance(_broker,ctx,op,NULL,rc); + if (ci == NULL) + { + CMSetStatusWithChars(_broker, rc, CMPI_RC_ERR_FAILED, "CBGetInstance(_broker,ctx,op,NULL,rc)"); + _OSBASE_TRACE(2,("--- _assoc_get_networkPort_INST() failed : %s",CMGetCharPtr(rc->msg))); + goto exit; + } + + npname = CMGetProperty( ci, "Name", &nprc).value.string; + npptr = CMGetCharPtr(npname); + linkTech = CMGetProperty( ci, "LinkTechnology", &nprc).value.uint16; + + if (strstr(ptr, npptr) && (linkTech == 2 && i == 0 || + linkTech == 7 && i == 1 || linkTech == 1 && i == 2)) + break; } - if(id) free(id); exit: - _OSBASE_TRACE(2,("--- _assoc_get_networkPort_INST() exited")); - return ci; + if(id) free(id); + _OSBASE_TRACE(2,("--- _assoc_get_networkPort_INST() exited")); + return ci; }