Changeset 20164 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- May 31, 2009 6:25:55 AM (16 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/ip_input.c
r20053 r20164 76 76 { 77 77 register struct ip *ip; 78 int hlen ;78 int hlen = 0; 79 79 80 80 DEBUG_CALL("ip_input"); 81 81 DEBUG_ARG("m = %lx", (long)m); 82 DEBUG_ARG("m_len = %d", m->m_len); 82 ip = mtod(m, struct ip *); 83 DEBUG_ARG("ip_dst=%R[IP4](len:%d) m_len = %d", &ip->ip_dst, ntohs(ip->ip_len), m->m_len); 84 Log2(("ip_dst=%R[IP4](len:%d) m_len = %d\n", &ip->ip_dst, ntohs(ip->ip_len), m->m_len)); 83 85 84 86 ipstat.ips_total++; … … 86 88 { 87 89 int rc; 88 rc = LibAliasIn(LIST_FIRST(&instancehead), mtod(m, char *), m->m_len); 90 rc = LibAliasIn(m->m_la ? m->m_la : pData->proxy_alias, mtod(m, char *), 91 m->m_len); 89 92 Log2(("NAT: LibAlias return %d\n", rc)); 90 93 } … … 199 202 return; 200 203 bad: 204 Log2(("NAT: IP datagram to %R[IP4] with size(%d) claimed as bad\n", 205 &ip->ip_dst, ip->ip_len)); 201 206 m_freem(pData, m); 202 207 return; -
trunk/src/VBox/Devices/Network/slirp/ip_output.c
r20053 r20164 153 153 { 154 154 int rc; 155 rc = LibAliasOut(LIST_FIRST(&instancehead), mtod(m, char *), m->m_len); 155 rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 156 mtod(m, char *), m->m_len); 156 157 Log2(("NAT: LibAlias return %d\n", rc)); 157 158 } … … 254 255 { 255 256 int rc; 256 rc = LibAliasOut(LIST_FIRST(&instancehead), mtod(m, char *), m->m_len); 257 rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 258 mtod(m, char *), m->m_len); 257 259 Log2(("NAT: LibAlias return %d\n", rc)); 258 260 } … … 269 271 { 270 272 int rc; 271 rc = LibAliasOut(LIST_FIRST(&instancehead), mtod(m, char *), m->m_len); 273 rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 274 mtod(m, char *), m->m_len); 272 275 Log2(("NAT: LibAlias return %d\n", rc)); 273 276 } -
trunk/src/VBox/Devices/Network/slirp/mbuf.c
r15791 r20164 82 82 m->m_nextpkt = 0; 83 83 m->m_prevpkt = 0; 84 #ifdef VBOX_WITH_SLIRP_ALIAS 85 m->m_la = NULL; 86 #endif 84 87 85 88 end_error: -
trunk/src/VBox/Devices/Network/slirp/mbuf.h
r19759 r20164 74 74 caddr_t mh_data; /* Location of data */ 75 75 int mh_len; /* Amount of data in this mbuf */ 76 #ifndef VBOX_SLIRP_ALIAS 77 struct libalias *mh_la; /*Real freebsd store hocksin similar way*/ 78 #endif 76 79 }; 77 80 … … 111 114 #define m_ext M_dat.m_ext_ 112 115 #define m_so m_hdr.mh_so 116 #ifdef VBOX_WITH_SLIRP_ALIAS 117 #define m_la m_hdr.mh_la 118 #endif 113 119 114 120 #define ifq_prev m_prev -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r20053 r20164 686 686 #ifdef VBOX_WITH_SLIRP_ALIAS 687 687 { 688 struct libalias *lib = NULL;689 688 int flags = 0; 690 lib= LibAliasInit(pData, NULL);691 if ( lib== NULL)689 pData->proxy_alias = LibAliasInit(pData, NULL); 690 if (pData->proxy_alias == NULL) 692 691 { 693 692 LogRel(("NAT: LibAlias default rule wasn't initialized\n")); 694 693 AssertMsgFailed(("NAT: LibAlias default rule wasn't initialized\n")); 695 694 } 696 flags = LibAliasSetMode( lib, 0, 0);695 flags = LibAliasSetMode(pData->proxy_alias, 0, 0); 697 696 flags |= PKT_ALIAS_LOG; /* set logging */ 698 flags = LibAliasSetMode( lib, flags, ~0);699 LibAliasSetAddress( lib, special_addr);697 flags = LibAliasSetMode(pData->proxy_alias, flags, ~0); 698 LibAliasSetAddress(pData->proxy_alias, special_addr); 700 699 ftp_alias_load(); 701 700 … … 1541 1540 struct ethhdr *eh = (struct ethhdr*)pkt; 1542 1541 1542 Log2(("NAT: slirp_input %d\n", pkt_len)); 1543 1543 if (pkt_len < ETH_HLEN) 1544 1544 { … … 1546 1546 return; 1547 1547 } 1548 Log4(("NAT: in:%R[ether]->%R[ether]\n", eh->h_source,eh->h_dest));1548 Log4(("NAT: in:%R[ether]->%R[ether]\n", &eh->h_source, &eh->h_dest)); 1549 1549 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER 1550 1550 if (memcmp(eh->h_source, special_ethaddr, ETH_ALEN) == 0) … … 1582 1582 * the first outgoing connection gets an incorrect timestamp. */ 1583 1583 updtime(pData); 1584 m->m_data += ETH_HLEN; 1585 m->m_len -= ETH_HLEN; 1584 m_adj(m, ETH_HLEN); 1586 1585 ip_input(pData, m); 1587 1586 break; … … 1629 1628 memcpy(eh->h_source, special_ethaddr, ETH_ALEN); 1630 1629 Assert(memcmp(eh->h_dest, special_ethaddr, ETH_ALEN) != 0); 1631 Assert(memcmp(eh->h_dest, zerro_ethaddr, ETH_ALEN) != 0); 1630 if (memcmp(eh->h_dest, zerro_ethaddr, ETH_ALEN) == 0) 1631 { 1632 /* don't do anything */ 1633 goto done; 1634 } 1632 1635 } 1633 1636 #endif … … 1638 1641 memcpy(buf, mtod(m, uint8_t *), m->m_len); 1639 1642 slirp_output(pData->pvUser, NULL, buf, m->m_len); 1643 done: 1640 1644 m_free(pData, m); 1641 1645 #endif … … 1646 1650 { 1647 1651 struct socket *so; 1652 #ifdef VBOX_WITH_SLIRP_ALIAS 1653 struct alias_link *link; 1654 struct libalias *lib; 1655 int flags; 1656 struct sockaddr sa; 1657 struct sockaddr_in *psin; 1658 socklen_t socketlen; 1659 struct in_addr alias; 1660 int rc; 1661 #endif 1648 1662 Log2(("NAT: set redirect %s hp:%d gp:%d\n", (is_udp?"UDP":"TCP"), host_port, guest_port)); 1649 1663 if (is_udp) … … 1657 1671 htons(guest_port), 0); 1658 1672 } 1673 #ifndef VBOX_WITH_SLIRP_ALIAS 1659 1674 Log2(("NAT: redirecting socket %R[natsock]\n", so)); 1660 1675 return (so != NULL ? 0 : -1); 1676 #else 1677 1678 psin = (struct sockaddr_in *)&sa; 1679 psin->sin_family = AF_INET; 1680 psin->sin_port = 0; 1681 psin->sin_addr.s_addr = INADDR_ANY; 1682 socketlen = sizeof(struct sockaddr); 1683 1684 rc = getsockname(so->s, &sa, &socketlen); 1685 if (rc < 0 || sa.sa_family != AF_INET) 1686 { 1687 Log(("NAT: can't get socket's name\n")); 1688 return 1; 1689 } 1690 1691 psin = (struct sockaddr_in *)&sa; 1692 1693 #if 1 1694 lib = LibAliasInit(pData, NULL); 1695 flags = LibAliasSetMode(lib, 0, 0); 1696 flags |= PKT_ALIAS_LOG; /* set logging */ 1697 flags |= PKT_ALIAS_REVERSE; /* set logging */ 1698 flags = LibAliasSetMode(lib, flags, ~0); 1699 #else 1700 lib = LIST_FIRST(&instancehead); 1701 #endif 1702 1703 alias.s_addr = htonl(ntohl(guest_addr.s_addr) | CTL_ALIAS); 1704 link = LibAliasRedirectPort(lib, psin->sin_addr, htons(host_port), 1705 alias, htons(guest_port), 1706 special_addr, -1, /* not very clear for now*/ 1707 (is_udp ? IPPROTO_UDP : IPPROTO_TCP)); 1708 if (link == NULL) 1709 { 1710 Log(("NAT: can't create redirect\n")); 1711 return 1; 1712 } 1713 so->so_la = lib; 1714 1715 return 0; 1716 #endif 1661 1717 } 1662 1718 … … 1733 1789 Log2(("proto: %d, dport: %d sport: %d\n", proto, hdport, hsport)); 1734 1790 service = 0; 1735 #if 11791 #if 0 1736 1792 /* Always return 0 here */ 1737 1793 switch (hdport) -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r19981 r20164 228 228 #ifdef VBOX_WITH_SLIRP_ALIAS 229 229 LIST_HEAD(, libalias) instancehead; 230 struct libalias *proxy_alias; 230 231 #endif 231 232 STAMPROFILE StatFill; -
trunk/src/VBox/Devices/Network/slirp/socket.h
r19313 r20164 87 87 unsigned char so_ethaddr[6]; 88 88 #endif 89 #ifdef VBOX_WITH_SLIRP_ALIAS 90 /* required for port-forwarding */ 91 struct libalias *so_la; 92 #endif 89 93 }; 90 94 -
trunk/src/VBox/Devices/Network/slirp/tcp_output.c
r19839 r20164 601 601 } 602 602 #endif 603 #ifdef VBOX_WITH_SLIRP_ALIAS 604 if(so->so_la != NULL) 605 m->m_la = so->so_la; 606 #endif 603 607 error = ip_output(pData, so, m); 604 608 -
trunk/src/VBox/Devices/Network/slirp/tcp_subr.c
r20053 r20164 487 487 so->so_laddr = inso->so_laddr; 488 488 so->so_lport = inso->so_lport; 489 #ifdef VBOX_WITH_SLIRP_ALIAS 490 so->so_la = inso->so_la; 491 #endif 489 492 } 490 493 -
trunk/src/VBox/Devices/Network/slirp/udp.c
r19981 r20164 78 78 DEBUG_CALL("udp_input"); 79 79 DEBUG_ARG("m = %lx", (long)m); 80 ip = mtod(m, struct ip *); 80 81 DEBUG_ARG("iphlen = %d", iphlen); 82 Log2(("%R[IP4] iphlen = %d\n", &ip->ip_dst, iphlen)); 81 83 82 84 udpstat.udps_ipackets++; … … 259 261 m->m_data -= iphlen; 260 262 *ip = save_ip; 261 DEBUG_MISC((dfd,"udp tx errno = %d-%s\n", errno, strerror(errno))); 263 DEBUG_MISC((dfd,"NAT: UDP tx errno = %d-%s (on sent to %R[IP4])\n", errno, 264 strerror(errno), &ip->ip_dst)); 262 265 icmp_error(pData, m, ICMP_UNREACH, ICMP_UNREACH_NET, 0, strerror(errno)); 263 266 /* in case we receive ICMP on this socket we'll aware that ICMP has been already sent to host*/ … … 276 279 277 280 bad: 281 Log2(("NAT: UDP datagram to %R[IP4] with size(%d) claimed as bad\n", 282 &ip->ip_dst, ip->ip_len)); 278 283 m_freem(pData, m); 279 284 return;
Note:
See TracChangeset
for help on using the changeset viewer.