Changeset 25265 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Dec 9, 2009 10:34:36 AM (15 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/bootp.c
r23497 r25265 84 84 if (bc == NULL) 85 85 return NULL; 86 paddr->s_addr = htonl(ntohl( special_addr.s_addr) | (bc->number + START_ADDR));86 paddr->s_addr = htonl(ntohl(pData->special_addr.s_addr) | (bc->number + START_ADDR)); 87 87 bc->addr.s_addr = paddr->s_addr; 88 88 return bc; … … 163 163 bc = &bootp_clients[i]; 164 164 bc->allocated = 1; 165 paddr->s_addr = htonl(ntohl( special_addr.s_addr) | (i + START_ADDR));165 paddr->s_addr = htonl(ntohl(pData->special_addr.s_addr) | (i + START_ADDR)); 166 166 return bc; 167 167 } … … 241 241 } 242 242 #ifndef VBOX_WITH_NAT_SERVICE 243 saddr.s_addr = htonl(ntohl( special_addr.s_addr) | CTL_ALIAS);243 saddr.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_ALIAS); 244 244 #else 245 saddr.s_addr = special_addr.s_addr;245 saddr.s_addr = pData->special_addr.s_addr; 246 246 #endif 247 247 Log(("NAT: DHCP: s_addr:%R[IP4]\n", &saddr)); … … 271 271 if (pData->use_dns_proxy || pData->use_host_resolver) 272 272 { 273 uint32_t addr = htonl(ntohl( special_addr.s_addr) | CTL_DNS);273 uint32_t addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_DNS); 274 274 FILL_BOOTP_EXT(q, RFC1533_DNS, 4, &addr); 275 275 goto skip_dns_servers; 276 276 } 277 277 278 if (!TAILQ_EMPTY(&pData-> dns_list_head))279 { 280 de = TAILQ_LAST(&pData-> dns_list_head, dns_list_head);278 if (!TAILQ_EMPTY(&pData->pDnsList)) 279 { 280 de = TAILQ_LAST(&pData->pDnsList, dns_list_head); 281 281 q_dns_header = q; 282 282 FILL_BOOTP_EXT(q, RFC1533_DNS, 4, &de->de_addr.s_addr); 283 283 } 284 284 285 TAILQ_FOREACH_REVERSE(de, &pData-> dns_list_head, dns_list_head, de_list)286 { 287 if (TAILQ_LAST(&pData-> dns_list_head, dns_list_head) == de)285 TAILQ_FOREACH_REVERSE(de, &pData->pDnsList, dns_list_head, de_list) 286 { 287 if (TAILQ_LAST(&pData->pDnsList, dns_list_head) == de) 288 288 continue; /* first value with head we've ingected before */ 289 289 FILL_BOOTP_APP(q_dns_header, q, RFC1533_DNS, 4, &de->de_addr.s_addr); … … 291 291 292 292 skip_dns_servers: 293 if (LIST_EMPTY(&pData-> dns_domain_list_head))293 if (LIST_EMPTY(&pData->pDomainList)) 294 294 { 295 295 /* Microsoft dhcp client doen't like domain-less dhcp and trimmed packets*/ … … 299 299 if (pData->fPassDomain && !pData->use_host_resolver) 300 300 { 301 LIST_FOREACH(dd, &pData-> dns_domain_list_head, dd_list)301 LIST_FOREACH(dd, &pData->pDomainList, dd_list) 302 302 { 303 303 … … 427 427 else 428 428 { 429 if ((bp->bp_ciaddr.s_addr & htonl(pData->netmask)) != special_addr.s_addr)429 if ((bp->bp_ciaddr.s_addr & htonl(pData->netmask)) != pData->special_addr.s_addr) 430 430 { 431 431 off = dhcp_send_nack(pData, bp, bc, m); … … 449 449 Assert(req_ip != NULL); 450 450 ui32 = *(uint32_t *)(req_ip + 2); 451 if ((ui32 & htonl(pData->netmask)) != special_addr.s_addr)451 if ((ui32 & htonl(pData->netmask)) != pData->special_addr.s_addr) 452 452 { 453 453 LogRel(("NAT: address %R[IP4] has been req.\n", &ui32)); … … 597 597 598 598 pmsg_type = 0; 599 600 599 p = buf; 601 600 p_end = buf + size; 602 601 if (size < 5) 603 602 return; 603 604 604 if (memcmp(p, rfc1533_cookie, 4) != 0) 605 605 return; 606 606 607 p = dhcp_find_option(bp->bp_vend, RFC2132_MSG_TYPE); 607 608 Assert(p); 608 609 if (p == NULL) 609 610 return; 611 610 612 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 611 613 if ((m = m_get(pData)) == NULL) … … 617 619 return; 618 620 } 619 switch (*(p+2))621 switch (*(p+2)) 620 622 { 621 623 case DHCPDISCOVER: … … 626 628 if (rc > 0) 627 629 goto reply; 628 break; 630 break; 631 629 632 case DHCPREQUEST: 630 633 rc = dhcp_decode_request(pData, bp, buf, size, m); 631 634 if (rc > 0) 632 635 goto reply; 633 break; 636 break; 637 634 638 case DHCPRELEASE: 635 639 rc = dhcp_decode_release(pData, bp, buf, size); 636 640 /* no reply required */ 637 break; 641 break; 642 638 643 case DHCPDECLINE: 639 644 p = dhcp_find_option(&bp->bp_vend[0], RFC2132_REQ_ADDR); 640 645 req_ip.s_addr = *(uint32_t *)(p + 2); 641 646 rc = bootp_cache_lookup_ether_by_ip(pData, req_ip.s_addr, NULL); 642 if ( rc != 0)647 if (RT_FAILURE(rc)) 643 648 { 644 649 /* Not registered */ … … 651 656 } 652 657 /* no response required */ 653 break; 658 break; 659 654 660 default: 655 661 AssertMsgFailed(("unsupported DHCP message type")); … … 659 665 m_free(pData, m); 660 666 return; 667 661 668 reply: 662 669 bootp_reply(pData, m, rc, bp->bp_flags); … … 678 685 679 686 #ifndef VBOX_WITH_NAT_SERVICE 680 saddr.sin_addr.s_addr = htonl(ntohl( special_addr.s_addr) | CTL_ALIAS);687 saddr.sin_addr.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_ALIAS); 681 688 #else 682 saddr.sin_addr.s_addr = special_addr.s_addr;689 saddr.sin_addr.s_addr = pData->special_addr.s_addr; 683 690 #endif 684 691 … … 711 718 712 719 if (bp->bp_op == BOOTP_REQUEST) 713 {714 720 dhcp_decode(pData, bp, bp->bp_vend, DHCP_OPT_LEN); 715 }716 721 } 717 722 718 723 int bootp_cache_lookup_ip_by_ether(PNATState pData,const uint8_t* ether, uint32_t *pip) 719 724 { 720 int rc = 1;721 uint32_t ip = INADDR_ANY;722 725 int i; 726 723 727 if (ether == NULL || pip == NULL) 724 return rc; 728 return VERR_INVALID_PARAMETER; 729 725 730 for (i = 0; i < NB_ADDR; i++) 726 731 { … … 728 733 && memcmp(bootp_clients[i].macaddr, ether, ETH_ALEN) == 0) 729 734 { 730 ip = bootp_clients[i].addr.s_addr;731 r c = 0;732 break;733 734 } 735 *pip = ip;736 return rc;735 *pip = bootp_clients[i].addr.s_addr; 736 return VINF_SUCCESS; 737 } 738 } 739 740 *pip = INADDR_ANY; 741 return VERR_NOT_FOUND; 737 742 } 738 743 739 744 int bootp_cache_lookup_ether_by_ip(PNATState pData, uint32_t ip, uint8_t *ether) 740 745 { 741 int rc = 1;742 746 int i; 743 747 for (i = 0; i < NB_ADDR; i++) … … 746 750 && ip == bootp_clients[i].addr.s_addr) 747 751 { 748 if(ether != NULL) memcpy(ether, bootp_clients[i].macaddr, ETH_ALEN); 749 rc = 0; 750 break; 751 } 752 } 753 return rc; 752 if (ether != NULL) 753 memcpy(ether, bootp_clients[i].macaddr, ETH_ALEN); 754 return VINF_SUCCESS; 755 } 756 } 757 758 return VERR_NOT_FOUND; 754 759 } 755 760 … … 760 765 int bootp_dhcp_init(PNATState pData) 761 766 { 762 int rc = 1;763 767 pData->pbootp_clients = RTMemAllocZ(sizeof(BOOTPClient) * NB_ADDR); 764 if (pData->pbootp_clients != NULL) 765 rc = 0; 766 return rc; 768 if (!pData->pbootp_clients) 769 return VERR_NO_MEMORY; 770 771 return VINF_SUCCESS; 767 772 } 768 773 … … 771 776 if (pData->pbootp_clients != NULL) 772 777 RTMemFree(pData->pbootp_clients); 773 return 0; 774 } 778 779 return VINF_SUCCESS; 780 } -
trunk/src/VBox/Devices/Network/slirp/dnsproxy/dnsproxy.c
r23157 r25265 154 154 m->m_len += req->nbyte; 155 155 ip->ip_src.s_addr = so->so_laddr.s_addr; 156 ip->ip_dst.s_addr = htonl(ntohl( special_addr.s_addr) | CTL_DNS);156 ip->ip_dst.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_DNS); 157 157 udp->uh_dport = ntohs(53); 158 158 udp->uh_sport = so->so_lport; … … 273 273 memcpy(&req->client, &fromaddr, sizeof(struct sockaddr_in)); 274 274 memcpy(&req->clientid, &buf[0], 2); 275 req->dns_server = TAILQ_LAST(&pData-> dns_list_head, dns_list_head);275 req->dns_server = TAILQ_LAST(&pData->pDnsList, dns_list_head); 276 276 if (req->dns_server == NULL) 277 277 { -
trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
r23462 r25265 372 372 #endif 373 373 addr.sin_family = AF_INET; 374 if ((ip->ip_dst.s_addr & htonl(pData->netmask)) == special_addr.s_addr)374 if ((ip->ip_dst.s_addr & htonl(pData->netmask)) == pData->special_addr.s_addr) 375 375 { 376 376 /* It's an alias */ -
trunk/src/VBox/Devices/Network/slirp/ip_output.c
r23462 r25265 53 53 static int rt_lookup_in_cache(PNATState pData, uint32_t dst, uint8_t *ether) 54 54 { 55 int rc = 1;55 int rc; 56 56 if (dst == INADDR_BROADCAST) 57 57 { 58 58 memcpy(ether, broadcast_ethaddr, ETH_ALEN); 59 return 0; 60 } 59 return VINF_SUCCESS; 60 } 61 61 62 rc = slirp_arp_lookup_ether_by_ip(pData, dst, ether); 62 if ( rc == 0)63 if (RT_SUCCESS(rc)) 63 64 return rc; 65 64 66 rc = bootp_cache_lookup_ether_by_ip(pData, dst, ether); 65 if ( rc == 0)67 if (RT_SUCCESS(rc)) 66 68 return rc; 67 69 /* … … 69 71 */ 70 72 slirp_arp_who_has(pData, dst); 71 return rc;73 return VERR_NOT_FOUND; 72 74 } 73 75 … … 138 140 { 139 141 error = ENOBUFS; 140 goto bad;142 goto exit_drop_package; 141 143 } 142 144 #endif … … 149 151 { 150 152 rc = rt_lookup_in_cache(pData, ip->ip_dst.s_addr, eth_dst); 151 if ( rc != 0)152 goto bad;153 if (RT_FAILURE(rc)) 154 goto exit_drop_package; 153 155 } 154 156 else … … 163 165 */ 164 166 rc = rt_lookup_in_cache(pData, ip->ip_dst.s_addr, eth_dst); 165 if (rc != 0) 166 goto bad; 167 if (RT_FAILURE(rc)) 168 goto exit_drop_package; 169 167 170 eh = (struct ethhdr *)(m->m_data - ETH_HLEN); 168 171 #endif … … 187 190 STAM_PROFILE_START(&pData->StatALIAS_output, a); 188 191 if (t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0) 189 { 190 rc = LibAliasOut((struct libalias *)&t[1], mtod(m, char *), m_length(m, NULL)); 191 } 192 rc = LibAliasOut((struct libalias *)&t[1], mtod(m, char *), 193 m_length(m, NULL)); 192 194 else 193 {194 195 rc = LibAliasOut(pData->proxy_alias, mtod(m, char *), 195 196 m_length(m, NULL)); 196 } 197 197 198 if (rc == PKT_ALIAS_IGNORED) 198 199 { 199 200 Log(("NAT: packet was droppped\n")); 200 goto bad;201 goto exit_drop_package; 201 202 } 202 203 #endif … … 222 223 error = -1; 223 224 ipstat.ips_cantfrag++; 224 goto bad;225 goto exit_drop_package; 225 226 } 226 227 … … 229 230 { 230 231 error = -1; 231 goto bad;232 goto exit_drop_package; 232 233 } 233 234 … … 238 239 uint8_t *buf; /* intermediate buffer we'll use for copy from orriginal packet*/ 239 240 #endif 240 241 { 241 242 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 242 struct m_tag *t; 243 char *tmpbuf = NULL; 244 int tmplen = 0; 245 #endif 246 int rc; 247 HTONS(ip->ip_len); 248 HTONS(ip->ip_off); 249 ip->ip_sum = 0; 250 ip->ip_sum = cksum(m, hlen); 251 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 252 rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 253 mtod(m, char *), m->m_len); 254 #else 255 if (m->m_next != NULL) 243 struct m_tag *t; 244 char *tmpbuf = NULL; 245 int tmplen = 0; 246 #endif 247 int rc; 248 HTONS(ip->ip_len); 249 HTONS(ip->ip_off); 250 ip->ip_sum = 0; 251 ip->ip_sum = cksum(m, hlen); 252 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 253 rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 254 mtod(m, char *), m->m_len); 255 #else 256 if (m->m_next != NULL) 257 { 258 /*we've receives packet in fragments*/ 259 tmplen = m_length(m, NULL); 260 tmpbuf = RTMemAlloc(tmplen); 261 Assert(tmpbuf); 262 m_copydata(m, 0, tmplen, tmpbuf); 263 } 264 else 265 { 266 tmpbuf = mtod(m, char *); 267 tmplen = m_length(m, NULL); 268 269 } 270 271 if (t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0) 272 rc = LibAliasOut((struct libalias *)&t[1], tmpbuf, tmplen); 273 else 274 rc = LibAliasOut(pData->proxy_alias, tmpbuf, tmplen); 275 276 if (m->m_next != NULL) 277 { 278 if (rc != PKT_ALIAS_IGNORED) 256 279 { 257 /*we've receives packet in fragments*/ 258 tmplen = m_length(m, NULL); 259 tmpbuf = RTMemAlloc(tmplen); 260 Assert(tmpbuf); 261 m_copydata(m, 0, tmplen, tmpbuf); 280 struct ip *tmpip = (struct ip *)tmpbuf; 281 m_copyback(pData, m, 0, ntohs(tmpip->ip_len) + (tmpip->ip_hl << 2), tmpbuf); 262 282 } 263 else 264 { 265 tmpbuf = mtod(m, char *); 266 tmplen = m_length(m, NULL); 267 268 } 269 if (t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0) 270 { 271 rc = LibAliasOut((struct libalias *)&t[1], tmpbuf, tmplen); 272 } 273 else 274 { 275 rc = LibAliasOut(pData->proxy_alias, tmpbuf, tmplen); 276 } 277 if (m->m_next != NULL) 278 { 279 if (rc != PKT_ALIAS_IGNORED) 280 { 281 struct ip *tmpip = (struct ip *)tmpbuf; 282 m_copyback(pData, m, 0, ntohs(tmpip->ip_len) + (tmpip->ip_hl << 2), tmpbuf); 283 } 284 if (tmpbuf != NULL) 285 RTMemFree(tmpbuf); 286 } 287 if (rc == PKT_ALIAS_IGNORED) 288 { 289 Log(("NAT: packet was droppped\n")); 290 goto bad; 291 } 292 #endif 293 NTOHS(ip->ip_len); 294 NTOHS(ip->ip_off); 295 Log2(("NAT: LibAlias return %d\n", rc)); 283 if (tmpbuf != NULL) 284 RTMemFree(tmpbuf); 285 } 286 if (rc == PKT_ALIAS_IGNORED) 287 { 288 Log(("NAT: packet was droppped\n")); 289 goto exit_drop_package; 290 } 291 #endif 292 NTOHS(ip->ip_len); 293 NTOHS(ip->ip_off); 294 Log2(("NAT: LibAlias return %d\n", rc)); 296 295 } 297 296 … … 409 408 done: 410 409 STAM_PROFILE_STOP(&pData->StatIP_output, a); 411 return (error);412 413 bad:410 return error; 411 412 exit_drop_package: 414 413 m_freem(pData, m0); 415 414 STAM_PROFILE_STOP(&pData->StatIP_output, a); 416 goto done;415 return error; 417 416 } -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_dns.c
r24232 r25265 58 58 if ( (ntohs(*ah->dport) == DNS_CONTROL_PORT_NUMBER 59 59 || ntohs(*ah->sport) == DNS_CONTROL_PORT_NUMBER) 60 && (ah->oaddr->s_addr == htonl(ntohl(la-> special_addr.s_addr)|CTL_DNS)))60 && (ah->oaddr->s_addr == htonl(ntohl(la->pData->special_addr.s_addr)|CTL_DNS))) 61 61 return (0); 62 62 return (-1); -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r25205 r25265 22 22 # define DO_ENGAGE_EVENT1(so, fdset, label) \ 23 23 do { \ 24 if ( so->so_poll_index != -1\24 if ( so->so_poll_index != -1 \ 25 25 && so->s == polls[so->so_poll_index].fd) { \ 26 26 polls[so->so_poll_index].events |= N_(fdset ## _poll); \ … … 34 34 polls[poll_index].revents = 0; \ 35 35 poll_index++; \ 36 } while (0)37 38 39 # define DO_ENGAGE_EVENT2(so, fdset1, fdset2, label) \40 do { \41 if ( so->so_poll_index != -1\42 && so->s == polls[so->so_poll_index].fd) { \43 polls[so->so_poll_index].events |= \44 N_(fdset1 ## _poll) | N_(fdset1 ## _poll); \45 break; /* out of this loop */ \46 } \47 AssertRelease(poll_index < (nfds)); \48 polls[poll_index].fd = (so)->s; \49 (so)->so_poll_index = poll_index; \50 polls[poll_index].events = \51 N_(fdset1 ## _poll) | N_(fdset1 ## _poll); \52 poll_index++; \53 } while (0)36 } while (0) 37 38 39 # define DO_ENGAGE_EVENT2(so, fdset1, fdset2, label) \ 40 do { \ 41 if ( so->so_poll_index != -1 \ 42 && so->s == polls[so->so_poll_index].fd) { \ 43 polls[so->so_poll_index].events |= \ 44 N_(fdset1 ## _poll) | N_(fdset1 ## _poll); \ 45 break; /* out of this loop */ \ 46 } \ 47 AssertRelease(poll_index < (nfds)); \ 48 polls[poll_index].fd = (so)->s; \ 49 (so)->so_poll_index = poll_index; \ 50 polls[poll_index].events = \ 51 N_(fdset1 ## _poll) | N_(fdset1 ## _poll); \ 52 poll_index++; \ 53 } while (0) 54 54 55 55 # define DO_POLL_EVENTS(rc, error, so, events, label) do {} while (0) 56 56 57 # define DO_CHECK_FD_SET(so, events, fdset) ( ((so)->so_poll_index != -1) \ 58 && ((so)->so_poll_index <= ndfs) \ 59 && ((so)->s == polls[so->so_poll_index].fd) \ 60 && (polls[(so)->so_poll_index].revents & N_(fdset ## _poll))) 61 # define DO_UNIX_CHECK_FD_SET(so, events, fdset ) DO_CHECK_FD_SET((so), (events), fdset) /*specific for Unix API */ 62 # define DO_WIN_CHECK_FD_SET(so, events, fdset ) 0 /* specific for Windows Winsock API */ 57 # define DO_CHECK_FD_SET(so, events, fdset) \ 58 ( ((so)->so_poll_index != -1) \ 59 && ((so)->so_poll_index <= ndfs) \ 60 && ((so)->s == polls[so->so_poll_index].fd) \ 61 && (polls[(so)->so_poll_index].revents & N_(fdset ## _poll))) 62 63 /* specific for Unix API */ 64 # define DO_UNIX_CHECK_FD_SET(so, events, fdset ) DO_CHECK_FD_SET((so), (events), fdset) 65 /* specific for Windows Winsock API */ 66 # define DO_WIN_CHECK_FD_SET(so, events, fdset ) 0 63 67 64 68 # ifndef RT_OS_WINDOWS … … 84 88 # else /* !RT_OS_WINDOWS */ 85 89 # define DO_WIN_CHECK_FD_SET(so, events, fdset ) DO_CHECK_FD_SET((so), (events), fdset) 86 # define ICMP_ENGAGE_EVENT(so, fdset) do {} while (0)90 # define ICMP_ENGAGE_EVENT(so, fdset) do {} while (0) 87 91 #endif /* RT_OS_WINDOWS */ 88 92 … … 93 97 * So no call to WSAEventSelect necessary. 94 98 */ 95 # define ICMP_ENGAGE_EVENT(so, fdset) do {} while (0)99 # define ICMP_ENGAGE_EVENT(so, fdset) do {} while (0) 96 100 97 101 # define DO_ENGAGE_EVENT1(so, fdset1, label) \ … … 105 109 error, (so), (so)->s, VBOX_SOCKET_EVENT)); \ 106 110 } \ 107 } while (0); \111 } while (0); \ 108 112 CONTINUE(label) 109 113 … … 191 195 192 196 static void activate_port_forwarding(PNATState, struct ethhdr *); 193 static uint32_t find_guest_ip(PNATState, const uint8_t *);194 197 195 198 static const uint8_t special_ethaddr[6] = … … 213 216 const char **ppszDomain) 214 217 { 215 /* Get amount of memory required for operation */216 218 ULONG flags = GAA_FLAG_INCLUDE_PREFIX; /*GAA_FLAG_INCLUDE_ALL_INTERFACES;*/ /* all interfaces registered in NDIS */ 217 PIP_ADAPTER_ADDRESSES addresses= NULL;218 PIP_ADAPTER_ADDRESSES addr = NULL;219 PIP_ADAPTER_DNS_SERVER_ADDRESS dns= NULL;220 ULONG size = 0;219 PIP_ADAPTER_ADDRESSES pAdapterAddr = NULL; 220 PIP_ADAPTER_ADDRESSES pAddr = NULL; 221 PIP_ADAPTER_DNS_SERVER_ADDRESS pDnsAddr = NULL; 222 ULONG size; 221 223 int wlen = 0; 222 char *suffix; 223 struct dns_entry *da = NULL; 224 struct dns_domain_entry *dd = NULL; 224 char *pszSuffix; 225 struct dns_domain_entry *pDomain = NULL; 225 226 ULONG ret = ERROR_SUCCESS; 226 227 227 228 /* @todo add SKIPing flags to get only required information */ 228 229 229 ret = pData->pfGetAdaptersAddresses(AF_INET, 0, NULL /* reserved */, addresses, &size); 230 /* determine size of buffer */ 231 size = 0; 232 ret = pData->pfGetAdaptersAddresses(AF_INET, 0, NULL /* reserved */, pAdapterAddr, &size); 230 233 if (ret != ERROR_BUFFER_OVERFLOW) 231 234 { … … 233 236 return -1; 234 237 } 235 236 238 if (size == 0) 237 239 { … … 240 242 } 241 243 242 addresses= RTMemAllocZ(size);243 if ( addresses == NULL)244 pAdapterAddr = RTMemAllocZ(size); 245 if (!pAdapterAddr) 244 246 { 245 247 LogRel(("NAT: No memory available \n")); 246 248 return -1; 247 249 } 248 249 ret = pData->pfGetAdaptersAddresses(AF_INET, 0, NULL /* reserved */, addresses, &size); 250 ret = pData->pfGetAdaptersAddresses(AF_INET, 0, NULL /* reserved */, pAdapterAddr, &size); 250 251 if (ret != ERROR_SUCCESS) 251 252 { 252 253 LogRel(("NAT: error %lu occurred on fetching adapters info\n", ret)); 253 RTMemFree( addresses);254 RTMemFree(pAdapterAddr); 254 255 return -1; 255 256 } 256 addr = addresses; 257 while(addr != NULL)257 258 for (pAddr = pAdapterAddr; pAddr != NULL; pAddr = pAddr->Next) 258 259 { 259 260 int found; 260 if (addr->OperStatus != IfOperStatusUp) 261 goto next; 262 dns = addr->FirstDnsServerAddress; 263 while (dns != NULL) 264 { 265 struct sockaddr *saddr = dns->Address.lpSockaddr; 266 if (saddr->sa_family != AF_INET) 267 goto next_dns; 261 if (pAddr->OperStatus != IfOperStatusUp) 262 continue; 263 264 for (pDnsAddr = pAddr->FirstDnsServerAddress; pDnsAddr != NULL; pDnsAddr = pDnsAddr->Next) 265 { 266 struct sockaddr *SockAddr = pDnsAddr->Address.lpSockaddr; 267 struct in_addr *InAddr; 268 struct dns_entry *pDns; 269 270 if (SockAddr->sa_family != AF_INET) 271 continue; 272 273 InAddr = ((struct sockaddr_in *)SockAddr)->sin_addr; 274 268 275 /* add dns server to list */ 269 da= RTMemAllocZ(sizeof(struct dns_entry));270 if ( da == NULL)276 pDns = RTMemAllocZ(sizeof(struct dns_entry)); 277 if (!pDns) 271 278 { 272 279 LogRel(("NAT: Can't allocate buffer for DNS entry\n")); 273 RTMemFree( addresses);280 RTMemFree(pAdapterAddr); 274 281 return VERR_NO_MEMORY; 275 282 } 276 LogRel(("NAT: adding %R[IP4] to DNS server list\n", 277 &((struct sockaddr_in *)saddr)->sin_addr)); 278 if (((( struct sockaddr_in *)saddr)->sin_addr.s_addr & htonl(IN_CLASSA_NET)) == 279 ntohl(INADDR_LOOPBACK & IN_CLASSA_NET)) { 280 da->de_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS); 281 } 283 284 LogRel(("NAT: adding %R[IP4] to DNS server list\n", &InAddr)); 285 if (InAddr.s_addr & htonl(IN_CLASSA_NET) == ntohl(INADDR_LOOPBACK & IN_CLASSA_NET)) 286 pDns->de_addr.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_ALIAS); 282 287 else 283 { 284 da->de_addr.s_addr = ((struct sockaddr_in *)saddr)->sin_addr.s_addr; 285 } 286 TAILQ_INSERT_HEAD(&pData->dns_list_head, da, de_list); 287 288 if (addr->DnsSuffix == NULL) 289 goto next_dns; 290 291 /*uniq*/ 292 RTUtf16ToUtf8(addr->DnsSuffix, &suffix); 293 294 if (!suffix || strlen(suffix) == 0) { 295 RTStrFree(suffix); 296 goto next_dns; 288 pDns->de_addr.s_addr = InAddr.s_addr; 289 290 TAILQ_INSERT_HEAD(&pData->pDnsList, pDns, de_list); 291 292 if (pAdddr->DnsSuffix == NULL) 293 continue; 294 295 /* uniq */ 296 RTUtf16ToUtf8(pAdddr->DnsSuffix, &pszSuffix); 297 if (!pszSuffix || strlen(pszSuffix) == 0) 298 { 299 RTStrFree(pszSuffix); 300 continue; 297 301 } 298 302 299 303 found = 0; 300 LIST_FOREACH( dd, &pData->dns_domain_list_head, dd_list)301 { 302 if ( dd->dd_pszDomain != NULL303 && strcmp( dd->dd_pszDomain, suffix) == 0)304 LIST_FOREACH(pDomain, &pData->pDomainList, dd_list) 305 { 306 if ( pDomain->dd_pszDomain != NULL 307 && strcmp(pDomain->dd_pszDomain, pszSuffix) == 0) 304 308 { 305 309 found = 1; 306 RTStrFree( suffix);310 RTStrFree(pszSuffix); 307 311 break; 308 312 } 309 313 } 310 if ( found == 0)311 { 312 dd= RTMemAllocZ(sizeof(struct dns_domain_entry));313 if ( dd == NULL)314 if (!found) 315 { 316 pDomain = RTMemAllocZ(sizeof(struct dns_domain_entry)); 317 if (!pDomain) 314 318 { 315 319 LogRel(("NAT: not enough memory\n")); 316 RTStrFree( suffix);317 RTMemFree( addresses);320 RTStrFree(pszSuffix); 321 RTMemFree(pAdapterAddr); 318 322 return VERR_NO_MEMORY; 319 323 } 320 dd->dd_pszDomain = suffix; 321 LogRel(("NAT: adding domain name %s to search list\n", dd->dd_pszDomain)); 322 LIST_INSERT_HEAD(&pData->dns_domain_list_head, dd, dd_list); 323 } 324 next_dns: 325 dns = dns->Next; 326 } 327 next: 328 addr = addr->Next; 329 } 330 RTMemFree(addresses); 324 pDomain->dd_pszDomain = pszSuffix; 325 LogRel(("NAT: adding domain name %s to search list\n", pDomain->dd_pszDomain)); 326 LIST_INSERT_HEAD(&pData->pDomainList, pDomain, dd_list); 327 } 328 } 329 } 330 RTMemFree(pAdapterAddr); 331 331 return 0; 332 332 } … … 341 341 char *pu8Buf = (char *)pvBuf; 342 342 *pcbRead = 0; 343 while( RT_SUCCESS(rc = RTFileRead(File, &bTest, 1, &cbRead)) 344 && (pu8Buf - (char *)pvBuf) < cbBufSize) 343 344 while ( RT_SUCCESS(rc = RTFileRead(File, &bTest, 1, &cbRead)) 345 && (pu8Buf - (char *)pvBuf) < cbBufSize) 345 346 { 346 347 if (cbRead == 0) 347 348 return VERR_EOF; 349 348 350 if (bTest == '\r' || bTest == '\n') 349 351 { … … 357 359 return rc; 358 360 } 361 359 362 static int get_dns_addr_domain(PNATState pData, bool fVerbose, 360 363 struct in_addr *pdns_addr, … … 410 413 if (ppszDomain) 411 414 *ppszDomain = NULL; 412 Log(("nat: DNS Servers:\n")); 415 416 Log(("NAT: DNS Servers:\n")); 413 417 while ( RT_SUCCESS(rc = RTFileGets(f, buff, 512, &bytes)) 414 418 && rc != VERR_EOF) 415 419 { 416 struct dns_entry * da= NULL;420 struct dns_entry *pDns = NULL; 417 421 if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) 418 422 { 419 423 if (!inet_aton(buff2, &tmp_addr)) 420 424 continue; 421 /*localhost mask */ 422 da = RTMemAllocZ(sizeof (struct dns_entry)); 423 if (da == NULL) 425 426 /* localhost mask */ 427 pDns = RTMemAllocZ(sizeof (struct dns_entry)); 428 if (!pDns) 424 429 { 425 430 LogRel(("can't alloc memory for DNS entry\n")); 426 431 return -1; 427 432 } 428 /*check */ 429 da->de_addr.s_addr = tmp_addr.s_addr; 430 if ((da->de_addr.s_addr & htonl(IN_CLASSA_NET)) == ntohl(INADDR_LOOPBACK & IN_CLASSA_NET)) { 431 da->de_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS); 432 } 433 TAILQ_INSERT_HEAD(&pData->dns_list_head, da, de_list); 433 434 /* check */ 435 pDns->de_addr.s_addr = tmp_addr.s_addr; 436 if ((pDns->de_addr.s_addr & htonl(IN_CLASSA_NET)) == ntohl(INADDR_LOOPBACK & IN_CLASSA_NET)) 437 { 438 pDns->de_addr.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_ALIAS); 439 } 440 TAILQ_INSERT_HEAD(&pData->pDnsList, pDns, de_list); 434 441 found++; 435 442 } … … 438 445 char *tok; 439 446 char *saveptr; 440 struct dns_domain_entry * dd= NULL;447 struct dns_domain_entry *pDomain = NULL; 441 448 int found = 0; 442 449 tok = strtok_r(&buff[6], " \t\n", &saveptr); 443 LIST_FOREACH( dd, &pData->dns_domain_list_head, dd_list)444 { 445 if (tok != NULL446 && strcmp(tok, dd->dd_pszDomain) == 0)450 LIST_FOREACH(pDomain, &pData->pDomainList, dd_list) 451 { 452 if ( tok != NULL 453 && strcmp(tok, pDomain->dd_pszDomain) == 0) 447 454 { 448 455 found = 1; … … 450 457 } 451 458 } 452 if (tok != NULL && found == 0) { 453 dd = RTMemAllocZ(sizeof(struct dns_domain_entry)); 454 if (dd == NULL) 459 if (tok != NULL && found == 0) 460 { 461 pDomain = RTMemAllocZ(sizeof(struct dns_domain_entry)); 462 if (!pDomain) 455 463 { 456 464 LogRel(("NAT: not enought memory to add domain list\n")); 457 465 return VERR_NO_MEMORY; 458 466 } 459 dd->dd_pszDomain = RTStrDup(tok);460 LogRel(("NAT: adding domain name %s to search list\n", dd->dd_pszDomain));461 LIST_INSERT_HEAD(&pData-> dns_domain_list_head, dd, dd_list);467 pDomain->dd_pszDomain = RTStrDup(tok); 468 LogRel(("NAT: adding domain name %s to search list\n", pDomain->dd_pszDomain)); 469 LIST_INSERT_HEAD(&pData->pDomainList, pDomain, dd_list); 462 470 } 463 471 } … … 473 481 static int slirp_init_dns_list(PNATState pData) 474 482 { 475 TAILQ_INIT(&pData-> dns_list_head);476 LIST_INIT(&pData-> dns_domain_list_head);483 TAILQ_INIT(&pData->pDnsList); 484 LIST_INIT(&pData->pDomainList); 477 485 return get_dns_addr_domain(pData, true, NULL, NULL); 478 486 } … … 480 488 static void slirp_release_dns_list(PNATState pData) 481 489 { 482 struct dns_entry *de = NULL; 483 struct dns_domain_entry *dd = NULL; 484 while(!TAILQ_EMPTY(&pData->dns_list_head)) { 485 de = TAILQ_FIRST(&pData->dns_list_head); 486 TAILQ_REMOVE(&pData->dns_list_head, de, de_list); 487 RTMemFree(de); 488 } 489 while(!LIST_EMPTY(&pData->dns_domain_list_head)) { 490 dd = LIST_FIRST(&pData->dns_domain_list_head); 491 LIST_REMOVE(dd, dd_list); 492 if (dd->dd_pszDomain != NULL) 493 RTStrFree(dd->dd_pszDomain); 494 RTMemFree(dd); 490 struct dns_entry *pDns = NULL; 491 struct dns_domain_entry *pDomain = NULL; 492 493 while (!TAILQ_EMPTY(&pData->pDnsList)) 494 { 495 pDns = TAILQ_FIRST(&pData->pDnsList); 496 TAILQ_REMOVE(&pData->pDnsList, pDns, de_list); 497 RTMemFree(pDns); 498 } 499 500 while (!LIST_EMPTY(&pData->pDomainList)) 501 { 502 pDomain = LIST_FIRST(&pData->pDomainList); 503 LIST_REMOVE(pDomain, dd_list); 504 if (pDomain->dd_pszDomain != NULL) 505 RTStrFree(pDomain->dd_pszDomain); 506 RTMemFree(pDomain); 495 507 } 496 508 } … … 564 576 565 577 #ifndef VBOX_WITH_NAT_SERVICE 566 inet_aton(pszNetAddr, & special_addr);578 inet_aton(pszNetAddr, &pData->special_addr); 567 579 #else 568 special_addr.s_addr = u32NetAddr;580 pData->special_addr.s_addr = u32NetAddr; 569 581 #endif 570 582 pData->slirp_ethaddr = &special_ethaddr[0]; 571 alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);583 alias_addr.s_addr = pData->special_addr.s_addr | htonl(CTL_ALIAS); 572 584 /* @todo: add ability to configure this staff */ 573 585 … … 598 610 flags |= PKT_ALIAS_LOG; /* set logging */ 599 611 flags = LibAliasSetMode(pData->proxy_alias, flags, ~0); 600 proxy_addr.s_addr = htonl(ntohl( special_addr.s_addr) | CTL_ALIAS);612 proxy_addr.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_ALIAS); 601 613 LibAliasSetAddress(pData->proxy_alias, proxy_addr); 602 614 ftp_alias_load(pData); … … 684 696 if (pData->use_host_resolver) 685 697 dns_alias_unload(pData); 686 while (!LIST_EMPTY(&instancehead))698 while (!LIST_EMPTY(&instancehead)) 687 699 { 688 700 struct libalias *la = LIST_FIRST(&instancehead); … … 690 702 LibAliasUninit(la); 691 703 } 692 while (!LIST_EMPTY(&pData->arp_cache))704 while (!LIST_EMPTY(&pData->arp_cache)) 693 705 { 694 706 struct arp_cache_entry *ac = LIST_FIRST(&pData->arp_cache); … … 1419 1431 tip = *(uint32_t*)ah->ar_tip; 1420 1432 1421 1422 1433 ar_op = ntohs(ah->ar_op); 1423 switch (ar_op)1434 switch (ar_op) 1424 1435 { 1425 1436 case ARPOP_REQUEST: … … 1446 1457 #endif 1447 1458 #ifdef VBOX_WITH_NAT_SERVICE 1448 if (tip == special_addr.s_addr) goto arp_ok; 1449 #endif 1450 if ((htip & pData->netmask) == ntohl(special_addr.s_addr)) 1459 if (tip == pData->special_addr.s_addr) 1460 goto arp_ok; 1461 #endif 1462 if ((htip & pData->netmask) == ntohl(pData->special_addr.s_addr)) 1451 1463 { 1452 1464 if ( CTL_CHECK(htip, CTL_DNS) … … 1464 1476 m_free(pData, mr); 1465 1477 return; 1466 arp_ok: 1478 1479 arp_ok: 1467 1480 rah->ar_hrd = htons(1); 1468 1481 rah->ar_pro = htons(ETH_P_IP); … … 1487 1500 m_free(pData, m); 1488 1501 } 1489 /* Gratuitous ARP*/1502 /* Gratuitous ARP */ 1490 1503 if ( *(uint32_t *)ah->ar_sip == *(uint32_t *)ah->ar_tip 1491 1504 && memcmp(ah->ar_tha, broadcast_ethaddr, ETH_ALEN) == 0 1492 && 1505 && memcmp(eh->h_dest, broadcast_ethaddr, ETH_ALEN) == 0) 1493 1506 { 1494 1507 /* we've received anounce about address asignment … … 1507 1520 } 1508 1521 break; 1522 1509 1523 case ARPOP_REPLY: 1510 {1511 1524 if (slirp_arp_cache_update(pData, *(uint32_t *)ah->ar_sip, &ah->ar_sha[0]) == 0) 1512 1525 { … … 1515 1528 } 1516 1529 slirp_arp_cache_add(pData, *(uint32_t *)ah->ar_sip, ah->ar_sha); 1517 /* after/save restore we need up port forwarding again*/1530 /* after/save restore we need up port forwarding again */ 1518 1531 if (pData->port_forwarding_activated != pData->port_forwarding_count) 1519 1532 activate_port_forwarding(pData, eh); 1520 1533 m_free(pData, m); 1521 }1522 break; 1534 break; 1535 1523 1536 default: 1524 1537 break; … … 1570 1583 1571 1584 if (pkt_len < MSIZE) 1572 {1573 1585 size = MCLBYTES; 1574 }1575 1586 else if (pkt_len < MCLBYTES) 1576 {1577 1587 size = MCLBYTES; 1578 } 1579 else if(pkt_len < MJUM9BYTES) 1580 { 1588 else if (pkt_len < MJUM9BYTES) 1581 1589 size = MJUM9BYTES; 1582 }1583 1590 else if (pkt_len < MJUM16BYTES) 1584 {1585 1591 size = MJUM16BYTES; 1586 }1587 1592 else 1588 {1589 1593 AssertMsgFailed(("Unsupported size")); 1590 } 1594 1591 1595 m = m_getjcl(pData, M_NOWAIT, MT_HEADER, M_PKTHDR, size); 1592 1596 if (!m) … … 1603 1607 /* Note: we add to align the IP header */ 1604 1608 1605 1606 1609 if (pData->port_forwarding_activated != pData->port_forwarding_count) 1607 1610 activate_port_forwarding(pData, mtod(m, struct ethhdr *)); … … 1612 1615 arp_input(pData, m); 1613 1616 break; 1617 1614 1618 case ETH_P_IP: 1615 1619 /* Update time. Important if the network is very quiet, as otherwise … … 1633 1637 ip_input(pData, m); 1634 1638 break; 1639 1635 1640 case ETH_P_IPV6: 1636 1641 m_free(pData, m); … … 1641 1646 } 1642 1647 break; 1648 1643 1649 default: 1644 1650 Log(("NAT: Unsupported protocol %x\n", proto)); … … 1646 1652 break; 1647 1653 } 1654 1648 1655 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 1649 1656 RTMemFree((void *)pkt); … … 1664 1671 eh = mtod(m, struct ethhdr *); 1665 1672 1666 if (MBUF_HEAD(m) != m->m_data)1673 if (MBUF_HEAD(m) != m->m_data) 1667 1674 { 1668 1675 LogRel(("NAT: ethernet detects corruption of the packet")); … … 1721 1728 { 1722 1729 uint32_t ip = INADDR_ANY; 1730 int rc; 1731 1723 1732 if (eth_addr == NULL) 1724 goto done; 1725 if (memcmp(eth_addr, zerro_ethaddr, ETH_ALEN) == 0 1733 return INADDR_ANY; 1734 1735 if ( memcmp(eth_addr, zerro_ethaddr, ETH_ALEN) == 0 1726 1736 || memcmp(eth_addr, broadcast_ethaddr, ETH_ALEN) == 0) 1727 goto done; 1728 if(slirp_arp_lookup_ip_by_ether(pData, eth_addr, &ip) == 0) 1729 goto done; 1737 return INADDR_ANY; 1738 1739 rc = slirp_arp_lookup_ip_by_ether(pData, eth_addr, &ip); 1740 if (RT_SUCCESS(rc)) 1741 return ip; 1742 1730 1743 bootp_cache_lookup_ip_by_ether(pData, eth_addr, &ip); 1731 done: 1744 /* ignore return code, ip will be set to INADDR_ANY on error */ 1732 1745 return ip; 1733 1746 } … … 1777 1790 #if !defined(VBOX_WITH_NAT_SERVICE) 1778 1791 if (rule->guest_addr.s_addr != guest_addr) 1779 {1780 1792 continue; 1781 }1782 1793 #endif 1783 1794 1784 1795 LogRel(("NAT: set redirect %s hp:%d gp:%d\n", (rule->proto == IPPROTO_UDP?"UDP":"TCP"), 1785 1796 rule->host_port, rule->guest_port)); 1797 1786 1798 if (rule->proto == IPPROTO_UDP) 1787 1799 { … … 1796 1808 pData->port_forwarding_activated++; 1797 1809 } 1810 1798 1811 if (so == NULL) 1799 1812 { … … 1827 1840 alias.s_addr = htonl(ntohl(guest_addr) | CTL_ALIAS); 1828 1841 link = LibAliasRedirectPort(lib, psin->sin_addr, htons(rule->host_port), 1829 alias, htons(rule->guest_port),1830 special_addr, -1, /* not very clear for now*/1831 rule->proto);1832 if ( link == NULL)1842 alias, htons(rule->guest_port), 1843 pData->special_addr, -1, /* not very clear for now */ 1844 rule->proto); 1845 if (!link) 1833 1846 { 1834 1847 LogRel(("NAT: failed redirect %s hp:%d gp:%d\n", (rule->proto == IPPROTO_UDP?"UDP":"TCP"), 1835 rule->host_port, rule->guest_port));1848 rule->host_port, rule->guest_port)); 1836 1849 goto remove_port_forwarding; 1837 1850 } 1851 1838 1852 so->so_la = lib; 1839 1853 rule->activated = 1; 1840 1854 continue; 1855 1841 1856 remove_port_forwarding: 1842 1857 LIST_REMOVE(rule, list); … … 1961 1976 Log2(("next_server:%s\n", next_server)); 1962 1977 if (next_server == NULL) 1963 pData->tftp_server.s_addr = htonl(ntohl( special_addr.s_addr) | CTL_TFTP);1978 pData->tftp_server.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_TFTP); 1964 1979 else 1965 1980 inet_aton(next_server, &pData->tftp_server); … … 1989 2004 } 1990 2005 1991 #define CHECK_ARG(name, val, lim_min, lim_max) \1992 do { \1993 if ((val) < (lim_min) || (val) > (lim_max)) \1994 { \1995 LogRel(("NAT: (" #name ":%d) has been ignored, " \1996 "because out of range (%d, %d)\n", (val), (lim_min), (lim_max))); \1997 return; \1998 } \1999 else \2000 { \2001 LogRel(("NAT: (" #name ":%d)\n", (val))); \2002 } \2003 } while (0)2006 #define CHECK_ARG(name, val, lim_min, lim_max) \ 2007 do { \ 2008 if ((val) < (lim_min) || (val) > (lim_max)) \ 2009 { \ 2010 LogRel(("NAT: (" #name ":%d) has been ignored, " \ 2011 "because out of range (%d, %d)\n", (val), (lim_min), (lim_max))); \ 2012 return; \ 2013 } \ 2014 else \ 2015 { \ 2016 LogRel(("NAT: (" #name ":%d)\n", (val))); \ 2017 } \ 2018 } while (0) 2004 2019 2005 2020 /* don't allow user set less 8kB and more than 1M values */ … … 2029 2044 * Looking for Ether by ip in ARP-cache 2030 2045 * Note: it´s responsible of caller to allocate buffer for result 2031 * @returns 0 - if found, 1 - otherwise2046 * @returns iprt status code 2032 2047 */ 2033 2048 int slirp_arp_lookup_ether_by_ip(PNATState pData, uint32_t ip, uint8_t *ether) 2034 2049 { 2035 2050 struct arp_cache_entry *ac = NULL; 2036 int rc = 1; 2051 2037 2052 if (ether == NULL) 2038 return rc;2053 return VERR_INVALID_PARAMETER; 2039 2054 2040 2055 if (LIST_EMPTY(&pData->arp_cache)) 2041 return rc;2056 return VERR_NOT_FOUND; 2042 2057 2043 2058 LIST_FOREACH(ac, &pData->arp_cache, list) … … 2046 2061 { 2047 2062 memcpy(ether, ac->ether, ETH_ALEN); 2048 rc = 0; 2049 return rc; 2050 } 2051 } 2052 return rc; 2063 return VINF_SUCCESS; 2064 } 2065 } 2066 return VERR_NOT_FOUND; 2053 2067 } 2054 2068 … … 2061 2075 { 2062 2076 struct arp_cache_entry *ac = NULL; 2063 int rc = 1;2064 2077 *ip = INADDR_ANY; 2078 2065 2079 if (LIST_EMPTY(&pData->arp_cache)) 2066 return rc; 2080 return VERR_NOT_FOUND; 2081 2067 2082 LIST_FOREACH(ac, &pData->arp_cache, list) 2068 2083 { … … 2070 2085 { 2071 2086 *ip = ac->ip; 2072 rc = 0; 2073 return rc; 2074 } 2075 } 2076 return rc; 2087 return VINF_SUCCESS; 2088 } 2089 } 2090 return VERR_NOT_FOUND; 2077 2091 } 2078 2092 … … 2102 2116 ahdr->ar_op = htons(ARPOP_REQUEST); 2103 2117 memcpy(ahdr->ar_sha, special_ethaddr, ETH_ALEN); 2104 *(uint32_t *)ahdr->ar_sip = htonl(ntohl( special_addr.s_addr) | CTL_ALIAS);2118 *(uint32_t *)ahdr->ar_sip = htonl(ntohl(pData->special_addr.s_addr) | CTL_ALIAS); 2105 2119 memset(ahdr->ar_tha, 0xff, ETH_ALEN); /*broadcast*/ 2106 2120 *(uint32_t *)ahdr->ar_tip = dst; … … 2159 2173 } 2160 2174 #endif 2161 void slirp_set_dhcp_mtu(PNATState, int); -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r25205 r25265 175 175 ULONG (WINAPI * pfGetAdaptersAddresses)(ULONG, ULONG, PVOID, PIP_ADAPTER_ADDRESSES, PULONG); 176 176 #endif 177 struct dns_list_head dns_list_head;178 struct dns_domain_list_head dns_domain_list_head;177 struct dns_list_head pDnsList; 178 struct dns_domain_list_head pDomainList; 179 179 struct in_addr tftp_server; 180 180 struct in_addr loopback_addr; … … 404 404 # define handler_chain pData->handler_chain 405 405 #endif 406 #define special_addr pData->special_addr407 406 #define dns_addr pData->dns_addr 408 407 #define loopback_addr pData->loopback_addr -
trunk/src/VBox/Devices/Network/slirp/socket.c
r24065 r25265 765 765 paddr = (struct sockaddr_in *)&addr; 766 766 paddr->sin_family = AF_INET; 767 if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr)767 if ((so->so_faddr.s_addr & htonl(pData->netmask)) == pData->special_addr.s_addr) 768 768 { 769 769 /* It's an alias */ -
trunk/src/VBox/Devices/Network/slirp/tcp_subr.c
r23369 r25265 396 396 397 397 addr.sin_family = AF_INET; 398 if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr)398 if ((so->so_faddr.s_addr & htonl(pData->netmask)) == pData->special_addr.s_addr) 399 399 { 400 400 /* It's an alias */ -
trunk/src/VBox/Devices/Network/slirp/udp.c
r23369 r25265 259 259 */ 260 260 if ( pData->use_dns_proxy 261 && (ip->ip_dst.s_addr == htonl(ntohl( special_addr.s_addr) | CTL_DNS))261 && (ip->ip_dst.s_addr == htonl(ntohl(pData->special_addr.s_addr) | CTL_DNS)) 262 262 && (ntohs(uh->uh_dport) == 53)) 263 263 { … … 377 377 378 378 saddr = *addr; 379 if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr)379 if ((so->so_faddr.s_addr & htonl(pData->netmask)) == pData->special_addr.s_addr) 380 380 { 381 381 saddr.sin_addr.s_addr = so->so_faddr.s_addr;
Note:
See TracChangeset
for help on using the changeset viewer.