Changeset 22843 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Sep 8, 2009 4:51:53 PM (15 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Makefile.kmk
r22830 r22843 757 757 Network/slirp/libalias/alias_proxy.c \ 758 758 Network/slirp/libalias/alias_ftp.c \ 759 Network/slirp/libalias/alias_dns.c \ 759 760 Network/slirp/libalias/alias_nbt.c \ 760 761 Network/slirp/libalias/alias_util.c -
trunk/src/VBox/Devices/Network/slirp/ip_input.c
r22013 r22843 66 66 } 67 67 68 static struct libalias *select_alias(PNATState pData, struct mbuf* m) 69 { 70 struct libalias *la = pData->proxy_alias; 71 struct udphdr *udp = NULL; 72 struct ip *pip = NULL; 73 74 if (m->m_la) 75 return m->m_la; 76 77 #if 0 78 pip = mtod(m, struct ip *); 79 if (pip->ip_p == IPPROTO_UDP) { 80 udp = (struct udphdr *)((uint8_t *)pip + (pip->ip_hl << 2)); 81 if ( pip->ip_dst.s_addr == htonl(ntohl(special_addr.s_addr) | CTL_DNS) 82 && htons(udp->uh_dport) == 53) 83 { 84 return pData->dns_alias; 85 } 86 /* here we can add catch for dhcp and tftp servers */ 87 } 88 #endif 89 return la; 90 } 91 68 92 /* 69 93 * Ip input routine. Checksum and byte swap header. If fragmented … … 87 111 int rc; 88 112 STAM_PROFILE_START(&pData->StatALIAS_input, a); 89 rc = LibAliasIn(m->m_la ? m->m_la : pData->proxy_alias, mtod(m, char *), 90 m->m_len); 113 rc = LibAliasIn(select_alias(pData, m), mtod(m, char *), m->m_len); 91 114 STAM_PROFILE_STOP(&pData->StatALIAS_input, a); 92 115 Log2(("NAT: LibAlias return %d\n", rc)); … … 135 158 goto bad; 136 159 } 160 137 161 NTOHS(ip->ip_id); 138 162 NTOHS(ip->ip_off); … … 149 173 goto bad; 150 174 } 175 151 176 /* Should drop packet if mbuf too long? hmmm... */ 152 177 if (m->m_len > ip->ip_len) -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r22674 r22843 207 207 }; 208 208 209 209 210 #ifdef RT_OS_WINDOWS 210 211 static int get_dns_addr_domain(PNATState pData, bool fVerbose, … … 340 341 int found = 0; 341 342 struct in_addr tmp_addr; 343 int nameservers = 0; 342 344 343 345 #ifdef RT_OS_OS2 … … 441 443 442 444 #endif 445 446 static void alias_init(PNATState pData, struct libalias **pla, int la_flags, struct in_addr addr) 447 { 448 int flags = 0; 449 struct libalias *la; 450 la = LibAliasInit(pData, NULL); 451 if (la == NULL) 452 { 453 LogRel(("NAT: LibAlias default rule wasn't initialized\n")); 454 AssertMsgFailed(("NAT: LibAlias default rule wasn't initialized\n")); 455 } 456 flags = LibAliasSetMode(la, 0, 0); 457 #ifndef NO_FW_PUNCH 458 flags |= PKT_ALIAS_PUNCH_FW; 459 #endif 460 #ifdef DEBUG 461 flags |= PKT_ALIAS_LOG; /* set logging */ 462 #endif 463 flags |= la_flags; 464 flags = LibAliasSetMode(la, flags, ~0); 465 LibAliasSetAddress(la, addr); 466 *pla = la; 467 } 443 468 444 469 static int slirp_init_dns_list(PNATState pData) … … 539 564 540 565 /* set default addresses */ 541 inet_aton("127.0.0.1", &loopback_addr);566 loopback_addr.s_addr = INADDR_LOOPBACK; 542 567 if (slirp_init_dns_list(pData) < 0) 543 568 fNATfailed = 1; … … 547 572 getouraddr(pData); 548 573 { 549 int flags = 0;550 574 struct in_addr proxy_addr; 551 pData->proxy_alias = LibAliasInit(pData, NULL);552 if (pData->proxy_alias == NULL)553 {554 LogRel(("NAT: LibAlias default rule wasn't initialized\n"));555 AssertMsgFailed(("NAT: LibAlias default rule wasn't initialized\n"));556 }557 flags = LibAliasSetMode(pData->proxy_alias, 0, 0);558 #ifndef NO_FW_PUNCH559 flags |= PKT_ALIAS_PUNCH_FW;560 #endif561 flags |= PKT_ALIAS_LOG; /* set logging */562 flags = LibAliasSetMode(pData->proxy_alias, flags, ~0);563 575 proxy_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS); 564 LibAliasSetAddress(pData->proxy_alias, proxy_addr); 576 alias_init(pData, &pData->proxy_alias, 0, proxy_addr); 577 578 #if 0 579 proxy_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_DNS); 580 alias_init(pData, &pData->dns_alias, PKT_ALIAS_REVERSE, proxy_addr); 581 #endif 582 565 583 ftp_alias_load(pData); 566 584 nbt_alias_load(pData); 585 dns_alias_load(pData); 567 586 } 568 587 return fNATfailed ? VINF_NAT_DNS : VINF_SUCCESS; … … 643 662 ftp_alias_unload(pData); 644 663 nbt_alias_unload(pData); 664 dns_alias_unload(pData); 645 665 while(!LIST_EMPTY(&instancehead)) 646 666 { … … 1637 1657 psin = (struct sockaddr_in *)&sa; 1638 1658 1639 lib = LibAliasInit(pData, NULL);1640 flags = LibAliasSetMode(lib, 0, 0);1641 flags |= PKT_ALIAS_LOG; /* set logging */1642 flags |= PKT_ALIAS_REVERSE; /* set logging */1643 flags = LibAliasSetMode(lib, flags, ~0);1644 1659 1645 1660 alias.s_addr = htonl(ntohl(guest_addr) | CTL_ALIAS); 1646 link = LibAliasRedirectPort(lib, psin->sin_addr, htons(rule->host_port), 1661 alias_init(pData, &so->so_la, PKT_ALIAS_REVERSE, alias); 1662 link = LibAliasRedirectPort(so->so_la, psin->sin_addr, htons(rule->host_port), 1647 1663 alias, htons(rule->guest_port), 1648 1664 special_addr, -1, /* not very clear for now*/ … … 1654 1670 goto remove_port_forwarding; 1655 1671 } 1656 so->so_la = lib;1657 1672 rule->activated = 1; 1658 1673 continue; -
trunk/src/VBox/Devices/Network/slirp/slirp.h
r22664 r22843 388 388 RTStrPrintfV(buffer, 1024, format, args); 389 389 390 #if defined(DEBUG_vvl) && 0390 #if defined(DEBUG_vvl) 391 391 LogRel(("NAT:ALIAS: %s\n", buffer)); 392 392 #else … … 415 415 int nbt_alias_load(PNATState); 416 416 int nbt_alias_unload(PNATState); 417 417 int dns_alias_load(PNATState); 418 int dns_alias_unload(PNATState); 418 419 int slirp_arp_lookup_ip_by_ether(PNATState, const uint8_t *, uint32_t *); 419 420 int slirp_arp_lookup_ether_by_ip(PNATState, uint32_t, uint8_t *); -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r22664 r22843 249 249 LIST_HEAD(RT_NOTHING, libalias) instancehead; 250 250 struct libalias *proxy_alias; 251 struct libalias *dns_alias; 251 252 LIST_HEAD(handler_chain, proto_handler) handler_chain; 252 253 struct port_forward_rule_list port_forward_rule_head; … … 256 257 struct proto_handler *ftp_module; 257 258 struct proto_handler *nbt_module; 259 struct proto_handler *dns_module; 258 260 259 261 #define PROFILE_COUNTER(name, dsc) STAMPROFILE Stat ## name -
trunk/src/VBox/Devices/Network/slirp/udp.c
r22014 r22843 107 107 */ 108 108 len = ntohs((u_int16_t)uh->uh_ulen); 109 Assert((ip->ip_len == len)); 110 Assert((ip->ip_len + iphlen == m->m_len)); 109 111 110 112 if (ip->ip_len != len) … … 159 161 } 160 162 163 if ( ntohs(uh->uh_dport) == 53 164 && CTL_CHECK(ntohl(ip->ip_dst.s_addr), CTL_DNS)) 165 { 166 struct sockaddr_in dst, src; 167 src.sin_addr.s_addr = ip->ip_dst.s_addr; 168 src.sin_port = uh->uh_dport; 169 dst.sin_addr.s_addr = ip->ip_src.s_addr; 170 dst.sin_port = uh->uh_sport; 171 /* udp_output2 will do opposite operations on mbuf*/ 172 173 m->m_data += sizeof(struct udpiphdr); 174 m->m_len -= sizeof(struct udpiphdr); 175 udp_output2(pData, NULL, m, &src, &dst, IPTOS_LOWDELAY); 176 goto bad; 177 } 161 178 /* 162 179 * handle TFTP … … 234 251 * DNS proxy 235 252 */ 253 #if 0 236 254 if ( (ip->ip_dst.s_addr == htonl(ntohl(special_addr.s_addr) | CTL_DNS)) 237 255 && (ntohs(uh->uh_dport) == 53)) … … 240 258 goto bad; /* it isn't bad, probably better to add additional label done for boot/tftf :) */ 241 259 } 260 #endif 242 261 243 262 iphlen += sizeof(struct udphdr);
Note:
See TracChangeset
for help on using the changeset viewer.