- Timestamp:
- Oct 29, 2013 12:21:04 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/portfwd.c
r49300 r49315 127 127 128 128 129 130 #ifndef RT_OS_WINDOWS131 129 int 132 130 fwspec_set(struct fwspec *fwspec, int sdom, int stype, … … 182 180 return 0; 183 181 } 184 #else /* RT_OS_WINDOWS */185 /**186 * Windows only provides inet_pton() since Vista, but XP already has187 * WSAStringToAddressA() that does what we want (NB: its AddressString188 * argument is not declared const).189 */190 int191 fwspec_set(struct fwspec *fwspec, int sdom, int stype,192 const char *src_addr_str, uint16_t src_port,193 const char *dst_addr_str, uint16_t dst_port)194 {195 int saf;196 int socklen;197 int status;198 199 LWIP_ASSERT1(sdom == PF_INET || sdom == PF_INET6);200 LWIP_ASSERT1(stype == SOCK_STREAM || stype == SOCK_DGRAM);201 202 fwspec->sdom = sdom;203 fwspec->stype = stype;204 205 saf = (sdom == PF_INET) ? AF_INET : AF_INET6;206 207 fwspec->src.sa.sa_family = saf;208 socklen = sizeof(fwspec->src);209 status = WSAStringToAddressA((char *)src_addr_str, saf, NULL,210 &fwspec->src.sa, &socklen);211 if (status == SOCKET_ERROR) {212 return -1;213 }214 215 fwspec->dst.sa.sa_family = saf;216 socklen = sizeof(fwspec->dst);217 status = WSAStringToAddressA((char *)dst_addr_str, saf, NULL,218 &fwspec->dst.sa, &socklen);219 if (status == SOCKET_ERROR) {220 return -1;221 }222 223 if (sdom == PF_INET) {224 fwspec->src.sin.sin_port = htons(src_port);225 fwspec->dst.sin.sin_port = htons(dst_port);226 }227 else { /* PF_INET6 */228 fwspec->src.sin6.sin6_port = htons(src_port);229 fwspec->dst.sin6.sin6_port = htons(dst_port);230 }231 232 return 0;233 }234 #endif /* RT_OS_WINDOWS */235 182 236 183
Note:
See TracChangeset
for help on using the changeset viewer.