Changeset 1168
- Timestamp:
- 11/20/08 16:06:53 (2 months ago)
- Files:
-
- Provider_Common_Library/tags/1.0.2 (modified) (1 prop)
- Provider_Common_Library/tags/1.0.2/Common.cpp (modified) (6 diffs)
- Provider_Common_Library/tags/1.0.2/net_dev.cpp (added)
- Provider_Common_Library/tags/1.0.2/net_dev.h (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Provider_Common_Library/tags/1.0.2
- Property svn:ignore changed from
autom4te.cache
aclocal.m4
config.h.in
configure
Makefile.in
to
autom4te.cache
aclocal.m4
config.h.in
configure
Makefile.in
.project
- Property svn:ignore changed from
Provider_Common_Library/tags/1.0.2/Common.cpp
r1137 r1168 31 31 #include "Common.h" 32 32 #include "net_dev.h" 33 #include <netdb.h> 34 #include <sys/utsname.h> 33 35 34 36 using namespace std; … … 254 256 // If '/bin/hostname -f' fails, it tries to execute '/bin/hostname' without options. 255 257 int CF_getSystemName(string& sysName, string& errorMessage) { 256 string value, errout;258 /* string value, errout; 257 259 if (CF_runCommand("/bin/hostname -f", sysName, errout, errorMessage)!=OK) { 258 260 CF_assert( CF_runCommand("/bin/hostname", sysName, errout, errorMessage)); 259 261 } 260 262 sysName = CF_trimText(sysName); 263 return OK;*/ 264 /*string ip; 265 CF_getMachineIP(ip, errorMessage); 266 struct hostent* host = gethostbyname(ip.c_str()); 267 if (host == NULL) 268 return FAILED; 269 270 sysName = host->h_name; 271 free(host); 272 return OK;*/ 273 274 // Modified by Ilsoo Byun(2008/10/02) 275 struct utsname uts; 276 if (uname(&uts) < 0) { 277 errorMessage = "failed to get system name: " + (string) strerror(errno); 278 return FAILED; 279 } 280 281 sysName = uts.nodename; 261 282 return OK; 262 283 } … … 265 286 // Modified by Frederic Desmons (2007/07/10) 266 287 int CF_getOSName(string& OSName, string& errorMessage) { 267 CF_assert(CF_runCommandFL("/bin/uname -o", OSName, errorMessage)); 288 //CF_assert(CF_runCommandFL("/bin/uname -o", OSName, errorMessage)); 289 //return OK; 290 291 struct utsname uts; 292 if (uname(&uts) < 0) { 293 errorMessage = "failed to get os: " + (string) strerror(errno); 294 return FAILED; 295 } 296 297 OSName = uts.sysname; 268 298 return OK; 269 299 } 270 300 271 301 // Added by Ilsoo Byun (2007/05/09) 302 //Deprecated 272 303 int CF_getEthernetPortNames(vector<string>& result, string& errorMessage) { 273 304 string value, stderr; … … 306 337 // Modified by Frederic Desmons (2007/11/12) 307 338 // Get only the first line of the std output 308 string value;339 /*string value; 309 340 CF_assert( CF_runCommandFL("/sbin/ifconfig "+ethName+" | gawk '/HWaddr/{} /inet addr/{print $2}'", value, errorMessage) ); 310 341 ip = CF_trimText(value); 311 342 if ( CF_startsWithNoCase(ip, "addr:") ) 312 343 ip = ip.substr(5); 344 return OK;*/ 345 346 // Modified by Ilsoo Byun(2008/10/02) 347 const char* result = cf_get_ip(ethName.c_str()); 348 if (result == NULL) { 349 errorMessage = "CF_getIP failed"; 350 return FAILED; 351 } 352 ip = string(result); 353 free((void *) result); 313 354 return OK; 314 355 } … … 356 397 357 398 for (int i = 0; i < count; ++i) { 399 if (!CF_startsWith(devices[i].name, "eth")) continue; 358 400 const char* _ip = cf_get_ip(devices[i].name); 359 401 if (_ip == NULL || strcmp(_ip, "127.0.0.1") == 0) { … … 361 403 continue; 362 404 } else { 405 cout << devices[i].name << endl; 363 406 ip = _ip; 364 407 free((void *) _ip);
