Changeset 19637 in vbox
- Timestamp:
- May 12, 2009 2:54:10 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
r19625 r19637 297 297 #else 298 298 int sd = socket(AF_INET, SOCK_DGRAM, 0); 299 300 301 299 if (sd < 0) /* Socket invalid. */ 300 { 301 VBoxServiceError("Failed to get a socket: Error %d\n", errno); 302 302 return -1; 303 303 } 304 304 305 305 ifconf ifcfg; 306 306 char buffer[1024] = {0}; 307 307 ifcfg.ifc_len = sizeof(buffer); 308 309 310 311 312 313 314 315 316 317 308 ifcfg.ifc_buf = buffer; 309 if (ioctl(sd, SIOCGIFCONF, &ifcfg) < 0) 310 { 311 VBoxServiceError("Failed to ioctl(SIOCGIFCONF) on socket: Error %d\n", errno); 312 return -1; 313 } 314 315 ifreq* ifrequest = ifcfg.ifc_req; 316 ifreq *ifreqitem = NULL; 317 nNumInterfaces = ifcfg.ifc_len / sizeof(ifreq); 318 318 #endif 319 319 char szPropPath [FILENAME_MAX] = {0}; … … 329 329 sockaddr_in *pAddress; 330 330 u_long nFlags = 0; 331 #ifdef RT_OS_WINDOWS 331 #ifdef RT_OS_WINDOWS 332 332 if (InterfaceList[i].iiFlags & IFF_LOOPBACK) /* Skip loopback device. */ 333 333 continue; … … 337 337 if (ioctl(sd, SIOCGIFFLAGS, &ifrequest[i]) < 0) 338 338 { 339 340 339 VBoxServiceError("Failed to ioctl(SIOCGIFFLAGS) on socket: Error %d\n", errno); 340 return -1; 341 341 } 342 342 if (ifrequest[i].ifr_flags & IFF_LOOPBACK) /* Skip loopback device. */ … … 355 355 { 356 356 VBoxServiceError("Failed to ioctl(SIOCGIFBRDADDR) on socket: Error %d\n", errno); 357 357 return -1; 358 358 } 359 359 pAddress = (sockaddr_in *)&ifrequest[i].ifr_broadaddr; … … 368 368 { 369 369 VBoxServiceError("Failed to ioctl(SIOCGIFBRDADDR) on socket: Error %d\n", errno); 370 370 return -1; 371 371 } 372 372 #ifdef RT_OS_SOLARIS … … 379 379 RTStrPrintf(szPropPath, sizeof(szPropPath), "GuestInfo/Net/%d/V4/Netmask", iCurIface); 380 380 VboxServiceWriteProp(g_VMInfoGuestPropSvcClientID, szPropPath, inet_ntoa(pAddress->sin_addr)); 381 382 381 383 382 if (nFlags & IFF_UP) 384 383 RTStrPrintf(szTemp, sizeof(szTemp), "Up"); … … 393 392 #ifdef RT_OS_WINDOWS 394 393 if (sd) closesocket(sd); 395 #else 394 #else 396 395 if (sd) close(sd); 397 396 #endif /* !RT_OS_WINDOWS */
Note:
See TracChangeset
for help on using the changeset viewer.