Changeset 76061 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Dec 7, 2018 3:13:22 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/net/netaddrstr2.cpp
r71435 r76061 196 196 197 197 198 RTDECL(int) RTNetStrToIPv4Cidr(const char *pcszAddr, PRTNETADDRIPV4 pAddr, int *piPrefix) 199 { 200 RTNETADDRIPV4 Addr; 201 uint8_t u8Prefix; 202 char *pszNext; 203 int rc; 204 205 AssertPtrReturn(pcszAddr, VERR_INVALID_PARAMETER); 206 AssertPtrReturn(pAddr, VERR_INVALID_PARAMETER); 207 AssertPtrReturn(piPrefix, VERR_INVALID_PARAMETER); 208 209 pcszAddr = RTStrStripL(pcszAddr); 210 rc = rtNetStrToIPv4AddrEx(pcszAddr, &Addr, &pszNext); 211 if (RT_FAILURE(rc)) 212 return rc; 213 214 /* if prefix is missing, treat is as exact (/32) address specification */ 215 if (*pszNext == '\0' || rc == VWRN_TRAILING_SPACES) 216 { 217 *pAddr = Addr; 218 *piPrefix = 32; 219 return VINF_SUCCESS; 220 } 221 222 if (*pszNext != '/') 223 return VERR_INVALID_PARAMETER; 224 225 ++pszNext; 226 rc = RTStrToUInt8Ex(pszNext, &pszNext, 10, &u8Prefix); 227 if (RT_FAILURE(rc) || rc == VWRN_TRAILING_CHARS) 228 return VERR_INVALID_PARAMETER; 229 230 if (u8Prefix == 0 || u8Prefix > 32) 231 return VERR_INVALID_PARAMETER; 232 233 *pAddr = Addr; 234 *piPrefix = u8Prefix; 235 return VINF_SUCCESS; 236 } 237 RT_EXPORT_SYMBOL(RTNetStrToIPv4Cidr); 238 239 198 240 static int rtNetStrToHexGroup(const char *pcszValue, char **ppszNext, 199 241 uint16_t *pu16)
Note:
See TracChangeset
for help on using the changeset viewer.