Changeset 43994 in vbox for trunk/src/apps/adpctl
- Timestamp:
- Nov 29, 2012 8:58:17 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 82378
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/apps/adpctl/VBoxNetAdpCtl.cpp
r43516 r43994 301 301 } 302 302 struct ifreq IfReq; 303 struct ethtool_value EthToolVal; 303 304 struct ethtool_cmd EthToolReq; 304 305 int fd = socket(AF_INET, SOCK_DGRAM, 0); … … 310 311 return ADPCTLERR_SOCKET_FAILED; 311 312 } 313 /* Get link status first. */ 314 memset(&EthToolVal, 0, sizeof(EthToolVal)); 312 315 memset(&IfReq, 0, sizeof(IfReq)); 313 316 snprintf(IfReq.ifr_name, sizeof(IfReq.ifr_name), "%s", pszAdapterName); 314 EthToolReq.cmd = ETHTOOL_GSET; 315 IfReq.ifr_data = (caddr_t)&EthToolReq; 317 318 EthToolVal.cmd = ETHTOOL_GLINK; 319 IfReq.ifr_data = (caddr_t)&EthToolVal; 316 320 rc = ioctl(fd, SIOCETHTOOL, &IfReq); 317 321 if (rc == 0) 318 322 { 319 printf("%u", EthToolReq.speed); 323 if (EthToolVal.data) 324 { 325 memset(&IfReq, 0, sizeof(IfReq)); 326 snprintf(IfReq.ifr_name, sizeof(IfReq.ifr_name), "%s", pszAdapterName); 327 EthToolReq.cmd = ETHTOOL_GSET; 328 IfReq.ifr_data = (caddr_t)&EthToolReq; 329 rc = ioctl(fd, SIOCETHTOOL, &IfReq); 330 if (rc == 0) 331 { 332 printf("%u", EthToolReq.speed); 333 } 334 else 335 { 336 fprintf(stderr, "VBoxNetAdpCtl: Error while retrieving link " 337 "speed for %s: ", pszAdapterName); 338 perror("VBoxNetAdpCtl: ioctl failed"); 339 rc = ADPCTLERR_IOCTL_FAILED; 340 } 341 } 342 else 343 printf("0"); 320 344 } 321 345 else 322 346 { 323 347 fprintf(stderr, "VBoxNetAdpCtl: Error while retrieving link " 324 "s peedfor %s: ", pszAdapterName);348 "status for %s: ", pszAdapterName); 325 349 perror("VBoxNetAdpCtl: ioctl failed"); 326 350 rc = ADPCTLERR_IOCTL_FAILED; 327 351 } 352 328 353 close(fd); 329 354 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.