- Timestamp:
- Sep 15, 2009 11:21:32 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/apps/adpctl/VBoxNetAdpCtl.cpp
r23046 r23048 130 130 if (pid == 0) 131 131 { 132 /* child */ 132 133 close(fds[0]); 133 134 close(STDOUT_FILENO); … … 135 136 if (rc >= 0) 136 137 execve(VBOXADPCTL_IFCONFIG_PATH, argv, envp); 137 } 138 else 139 { 140 close(fds[1]); 141 FILE *fp = fdopen(fds[0], "r"); 142 if (!fp) 138 return false; 139 } 140 141 /* parent */ 142 close(fds[1]); 143 FILE *fp = fdopen(fds[0], "r"); 144 if (!fp) 145 return false; 146 147 int cAddrs; 148 for (cAddrs = 0; cAddrs < MAX_ADDRESSES && fgets(szBuf, sizeof(szBuf), fp);) 149 { 150 int cbSkipWS = strspn(szBuf, " \t"); 151 #if 0 /* Don't use this! assert() breaks the mac build. Use IPRT or be a rectangular building thing. */ 152 assert(cbSkipWS < 20); 153 #endif 154 char *pszWord = strtok(szBuf + cbSkipWS, " "); 155 /* We are concerned with IPv6 address lines only. */ 156 if (!pszWord || strcmp(pszWord, "inet6")) 157 continue; 158 #ifdef RT_OS_LINUX 159 pszWord = strtok(NULL, " "); 160 /* Skip "addr:". */ 161 if (!pszWord || strcmp(pszWord, "addr:")) 162 continue; 163 #endif 164 pszWord = strtok(NULL, " "); 165 /* Skip link-local addresses. */ 166 if (!pszWord || !strncmp(pszWord, "fe80", 4)) 167 continue; 168 strncpy(aszAddresses[cAddrs++], pszWord, MAX_ADDRLEN-1); 169 } 170 fclose(fp); 171 172 for (int i = 0; i < cAddrs; i++) 173 { 174 if (executeIfconfig(pszAdapterName, "inet6", 175 VBOXADPCTL_DEL_CMD, aszAddresses[i]) != EXIT_SUCCESS) 143 176 return false; 144 145 int cAddrs;146 for (cAddrs = 0; cAddrs < MAX_ADDRESSES && fgets(szBuf, sizeof(szBuf), fp);)147 {148 int cbSkipWS = strspn(szBuf, " \t");149 #if 0 /* Don't use this! assert() breaks the mac build. Use IPRT or be a rectangular building thing. */150 assert(cbSkipWS < 20);151 #endif152 char *pszWord = strtok(szBuf + cbSkipWS, " ");153 /* We are concerned with IPv6 address lines only. */154 if (!pszWord || strcmp(pszWord, "inet6"))155 continue;156 #ifdef RT_OS_LINUX157 pszWord = strtok(NULL, " ");158 /* Skip "addr:". */159 if (!pszWord || strcmp(pszWord, "addr:"))160 continue;161 #endif162 pszWord = strtok(NULL, " ");163 /* Skip link-local addresses. */164 if (!pszWord || !strncmp(pszWord, "fe80", 4))165 continue;166 strncpy(aszAddresses[cAddrs++], pszWord, MAX_ADDRLEN-1);167 }168 fclose(fp);169 170 for (int i = 0; i < cAddrs; i++)171 {172 if (executeIfconfig(pszAdapterName, "inet6",173 VBOXADPCTL_DEL_CMD, aszAddresses[i]) != EXIT_SUCCESS)174 return false;175 }176 177 } 177 178 … … 191 192 if (rc == -1) 192 193 { 193 perror("VBoxNetAdpCtl: ioctl failed for " VBOXNETADP_CTL_DEV_NAME); 194 perror("VBoxNetAdpCtl: ioctl failed for " VBOXNETADP_CTL_DEV_NAME); 194 195 rc = ADPCTLERR_IOCTL_FAILED; 195 196 } 196 197 197 198 close(fd); 198 199 199 200 return rc; 200 201 }
Note:
See TracChangeset
for help on using the changeset viewer.