Changeset 23059 in vbox for trunk/src/apps/adpctl
- Timestamp:
- Sep 16, 2009 10:26:02 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/apps/adpctl/VBoxNetAdpCtl.cpp
r23049 r23059 201 201 } 202 202 203 int checkAdapterName(const char *pcszNameIn, char *pszNameOut) 204 { 205 int iAdapterIndex = -1; 206 207 if (sscanf(pcszNameIn, "vboxnet%d", &iAdapterIndex) != 1 208 || iAdapterIndex < 0 || iAdapterIndex > 99 ) 209 { 210 fprintf(stderr, "Setting configuration for %s is not supported.\n", pcszNameIn); 211 return 2; 212 } 213 sprintf(pszNameOut, "vboxnet%d", iAdapterIndex); 214 if (strcmp(pszNameOut, pcszNameIn)) 215 { 216 fprintf(stderr, "Invalid adapter name %s.\n", pcszNameIn); 217 return 2; 218 } 219 220 return 0; 221 } 222 203 223 int main(int argc, char *argv[]) 204 224 205 225 { 226 char szAdapterName[VBOXNETADP_MAX_NAME_LEN]; 206 227 char *pszAdapterName; 207 228 const char *pszAddress; … … 242 263 if (strcmp("remove", pszAddress) == 0) 243 264 { 244 snprintf(Req.szName, sizeof(Req.szName), "%s", pszAdapterName); 265 rc = checkAdapterName(pszAdapterName, szAdapterName); 266 if (rc) 267 return rc; 268 snprintf(Req.szName, sizeof(Req.szName), "%s", szAdapterName); 245 269 return doIOCtl(VBOXNETADP_CTL_REMOVE, &Req); 246 270 } … … 263 287 } 264 288 265 if (strncmp("vboxnet", pszAdapterName, 7))266 {267 fprintf(stderr, "Setting configuration for %s is not supported.\n", pszAdapterName);268 return 2; 269 }289 rc = checkAdapterName(pszAdapterName, szAdapterName); 290 if (rc) 291 return rc; 292 293 pszAdapterName = szAdapterName; 270 294 271 295 if (fRemove)
Note:
See TracChangeset
for help on using the changeset viewer.