Changeset 58613 in vbox for trunk/src/VBox/NetworkServices
- Timestamp:
- Nov 9, 2015 2:45:26 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 103987
- Location:
- trunk/src/VBox/NetworkServices/NAT
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/pxdns.c
r56300 r58613 43 43 #include "proxy.h" 44 44 #include "proxy_pollmgr.h" 45 #include "pxtcp.h" 45 46 46 47 #include "lwip/sys.h" 47 48 #include "lwip/tcpip.h" 49 #include "lwip/ip_addr.h" 48 50 #include "lwip/udp.h" 51 #include "lwip/tcp.h" 49 52 50 53 #ifndef RT_OS_WINDOWS … … 84 87 struct udp_pcb *pcb6; 85 88 89 struct tcp_pcb *ltcp; 90 86 91 size_t generation; 87 92 size_t nresolvers; … … 177 182 static void pxdns_create_resolver_sockaddrs(struct pxdns *pxdns, 178 183 const char **nameservers); 184 185 static err_t pxdns_accept_syn(void *arg, struct tcp_pcb *newpcb, struct pbuf *syn); 179 186 180 187 static void pxdns_recv4(void *arg, struct udp_pcb *pcb, struct pbuf *p, … … 211 218 LWIP_UNUSED_ARG(proxy_netif); 212 219 220 pxdns->ltcp = tcp_new(); 221 if (pxdns->ltcp != NULL) { 222 tcp_bind_ip6(pxdns->ltcp, IP6_ADDR_ANY, 53); 223 pxdns->ltcp = tcp_listen_dual(pxdns->ltcp); 224 if (pxdns->ltcp != NULL) { 225 tcp_arg(pxdns->ltcp, pxdns); 226 tcp_accept_syn(pxdns->ltcp, pxdns_accept_syn); 227 } 228 } 229 213 230 pxdns->pmhdl4.callback = pxdns_pmgr_pump; 214 231 pxdns->pmhdl4.data = (void *)pxdns; … … 863 880 pxdns_request_free(req); 864 881 } 882 883 884 /** 885 * TCP DNS proxy. This kicks in for large replies that don't fit into 886 * 512 bytes of UDP payload. Client will retry with TCP to get 887 * complete reply. 888 */ 889 static err_t 890 pxdns_accept_syn(void *arg, struct tcp_pcb *newpcb, struct pbuf *syn) 891 { 892 struct pxdns *pxdns = (struct pxdns *)arg; 893 union sockaddr_inet *si; 894 ipX_addr_t *dst; 895 u16_t dst_port; 896 897 tcp_accepted(pxdns->ltcp); 898 899 if (pxdns->nresolvers == 0) { 900 return ERR_CONN; 901 } 902 903 si = &pxdns->resolvers[0]; 904 905 if (si->sa.sa_family == AF_INET6) { 906 dst = (ipX_addr_t *)&si->sin6.sin6_addr; 907 dst_port = ntohs(si->sin6.sin6_port); 908 } 909 else { 910 dst = (ipX_addr_t *)&si->sin.sin_addr; 911 dst_port = ntohs(si->sin.sin_port); 912 } 913 914 /* 915 * XXX: TODO: need to implement protocol hooks. E.g. here if 916 * connect fails, we should try connecting to a different server. 917 */ 918 return pxtcp_pcb_accept_outbound(newpcb, syn, 919 si->sa.sa_family == AF_INET6, dst, dst_port); 920 } -
trunk/src/VBox/NetworkServices/NAT/pxtcp.c
r58592 r58613 276 276 static void pxtcp_pcb_err(void *, err_t); 277 277 278 static err_t pxtcp_pcb_accept_outbound(struct tcp_pcb *, struct pbuf *, int, ipX_addr_t *, u16_t);279 280 278 static err_t pxtcp_pcb_forward_outbound(struct pxtcp *, struct pbuf *); 281 279 static void pxtcp_pcb_forward_outbound_close(struct pxtcp *); … … 1012 1010 1013 1011 1014 staticerr_t1012 err_t 1015 1013 pxtcp_pcb_accept_outbound(struct tcp_pcb *newpcb, struct pbuf *p, 1016 1014 int is_ipv6, ipX_addr_t *dst_addr, u16_t dst_port) -
trunk/src/VBox/NetworkServices/NAT/pxtcp.h
r56300 r58613 19 19 #define _pxtcp_h_ 20 20 21 #include "lwip/err.h" 22 #include "lwip/ip_addr.h" 23 24 struct pbuf; 25 struct tcp_pcb; 21 26 struct pxtcp; 22 27 struct fwspec; 28 29 err_t pxtcp_pcb_accept_outbound(struct tcp_pcb *, struct pbuf *, int, ipX_addr_t *, u16_t); 23 30 24 31 struct pxtcp *pxtcp_create_forwarded(SOCKET);
Note:
See TracChangeset
for help on using the changeset viewer.