Changeset 8009 in vbox for trunk/src/VBox/Devices/Network/slirp
- Timestamp:
- Apr 15, 2008 4:17:52 PM (17 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/bootp.c
r7809 r8009 261 261 *q++ = RFC1533_NETMASK; 262 262 *q++ = 4; 263 *q++ = 0xff;264 *q++ = 0xff;265 *q++ = 0xff;266 *q++ = 0x00;263 *q++ = (pData->netmask & 0xff000000) >> 24; 264 *q++ = (pData->netmask & 0x00ff0000) >> 16; 265 *q++ = (pData->netmask & 0x0000ff00) >> 8; 266 *q++ = (pData->netmask & 0x000000ff); 267 267 268 268 *q++ = RFC1533_GATEWAY; -
trunk/src/VBox/Devices/Network/slirp/ctl.h
r1796 r8009 5 5 #define CTL_BROADCAST 255 6 6 7 #if 0 7 8 #define CTL_SPECIAL "10.0.2.0" 8 9 #define CTL_LOCAL "10.0.2.15" 10 #endif -
trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
r5436 r8009 136 136 /* Send the packet */ 137 137 addr.sin_family = AF_INET; 138 if ((so->so_faddr.s_addr & htonl( 0xffffff00)) == special_addr.s_addr) {138 if ((so->so_faddr.s_addr & htonl(~pData->netmask)) == special_addr.s_addr) { 139 139 /* It's an alias */ 140 switch(ntohl(so->so_faddr.s_addr) & 0xff) {140 switch(ntohl(so->so_faddr.s_addr) & ~pData->netmask) { 141 141 case CTL_DNS: 142 142 addr.sin_addr = dns_addr; -
trunk/src/VBox/Devices/Network/slirp/libslirp.h
r5436 r8009 27 27 #endif 28 28 29 int slirp_init(PNATState *, const char *, bool, const char *, const char *, void *);29 int slirp_init(PNATState *, const char *, uint32_t, bool, const char *, const char *, void *); 30 30 void slirp_term(PNATState); 31 31 void slirp_link_up(PNATState); -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r6761 r8009 195 195 } 196 196 197 int slirp_init(PNATState *ppData, const char *pszNetAddr, bool fPassDomain,198 const char *pszTFTPPrefix, const char *pszBootFile,199 void *pvUser)197 int slirp_init(PNATState *ppData, const char *pszNetAddr, uint32_t u32Netmask, 198 bool fPassDomain, const char *pszTFTPPrefix, 199 const char *pszBootFile, void *pvUser) 200 200 { 201 201 int fNATfailed = 0; … … 204 204 if (!pData) 205 205 return VERR_NO_MEMORY; 206 if (u32Netmask & 0x1f) 207 /* CTL is x.x.x.15, bootp passes up to 16 IPs (15..31) */ 208 return VERR_INVALID_PARAMETER; 206 209 memset(pData, '\0', sizeof(NATState)); 207 210 pData->fPassDomain = fPassDomain; … … 212 215 tftp_prefix = pszTFTPPrefix; 213 216 bootp_filename = pszBootFile; 217 pData->netmask = u32Netmask; 214 218 215 219 #ifdef _WIN32 -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r5999 r8009 84 84 struct in_addr dns_addr; 85 85 struct in_addr loopback_addr; 86 uint32_t netmask; 86 87 uint8_t client_ethaddr[6]; 87 88 struct ex_list *exec_list; -
trunk/src/VBox/Devices/Network/slirp/socket.c
r5716 r8009 497 497 498 498 addr.sin_family = AF_INET; 499 if ((so->so_faddr.s_addr & htonl( 0xffffff00)) == special_addr.s_addr) {499 if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr) { 500 500 /* It's an alias */ 501 switch(ntohl(so->so_faddr.s_addr) & 0xff) { 501 uint32_t last_byte = ntohl(so->so_faddr.s_addr) & ~pData->netmask; 502 switch(last_byte) { 503 #if 0 504 /* handle this case at 'default:' */ 502 505 case CTL_BROADCAST: 503 506 addr.sin_addr.s_addr = INADDR_BROADCAST; 504 # if 0507 # if 0 505 508 /* Send the packet to host to fully emulate broadcast */ 506 509 /** @todo r=klaus: on Linux host this causes the host to receive … … 513 516 sendto(so->s, m->m_data, m->m_len, 0, 514 517 (struct sockaddr *)&host_addr, sizeof (struct sockaddr)); 515 # endif518 # endif 516 519 break; 520 #endif 517 521 case CTL_DNS: 518 522 if (!get_dns_addr(pData, &dns_addr)) … … 523 527 case CTL_ALIAS: 524 528 default: 525 addr.sin_addr = loopback_addr; 529 if (last_byte == ~pData->netmask) 530 addr.sin_addr.s_addr = INADDR_BROADCAST; 531 else 532 addr.sin_addr = loopback_addr; 526 533 break; 527 534 } -
trunk/src/VBox/Devices/Network/slirp/tcp_input.c
r3391 r8009 624 624 * tcp_ctl once connected, otherwise connect 625 625 */ 626 if ((so->so_faddr.s_addr&htonl( 0xffffff00)) == special_addr.s_addr) {627 int lastbyte=ntohl(so->so_faddr.s_addr) & 0xff;626 if ((so->so_faddr.s_addr&htonl(pData->netmask)) == special_addr.s_addr) { 627 int lastbyte=ntohl(so->so_faddr.s_addr) & ~pData->netmask; 628 628 if (lastbyte!=CTL_ALIAS && lastbyte!=CTL_DNS) { 629 629 #if 0 -
trunk/src/VBox/Devices/Network/slirp/tcp_subr.c
r5716 r8009 391 391 392 392 addr.sin_family = AF_INET; 393 if ((so->so_faddr.s_addr & htonl( 0xffffff00)) == special_addr.s_addr) {393 if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr) { 394 394 /* It's an alias */ 395 switch(ntohl(so->so_faddr.s_addr) & 0xff) {395 switch(ntohl(so->so_faddr.s_addr) & ~pData->netmask) { 396 396 case CTL_DNS: 397 397 if (!get_dns_addr(pData, &dns_addr)) -
trunk/src/VBox/Devices/Network/slirp/udp.c
r5723 r8009 302 302 303 303 saddr = *addr; 304 if ((so->so_faddr.s_addr & htonl( 0xffffff00)) == special_addr.s_addr) {304 if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr) { 305 305 saddr.sin_addr.s_addr = so->so_faddr.s_addr; 306 if ((so->so_faddr.s_addr & htonl( 0x000000ff)) == htonl(0xff))306 if ((so->so_faddr.s_addr & htonl(~pData->netmask)) == htonl(~pData->netmask)) 307 307 saddr.sin_addr.s_addr = alias_addr.s_addr; 308 308 }
Note:
See TracChangeset
for help on using the changeset viewer.