fwudp.c revision f0c792e78a8bf77c28c7814441e514bea7c5362b
1N/A/* -*- indent-tabs-mode: nil; -*- */ 1N/A * UDP port-forwarding. 1N/A * Unlike pxudp that uses 1:1 mapping between pcb and socket, for 1N/A * port-forwarded UDP the setup is bit more elaborated. 1N/A * For fwtcp things are simple since incoming TCP connection get a new 1N/A * socket that we just hand off to pxtcp. Thus fwtcp only handles 1N/A * connection initiation. 1N/A * For fwudp all proxied UDP conversations share the same socket, so 1N/A * single fwudp multiplexes to several UDP pcbs. 1N/A * XXX: TODO: Currently pcbs point back directly to fwudp. It might 1N/A * make sense to introduce a per-pcb structure that points to fwudp 1N/A * and carries additional information, like pre-mapped peer address. 1N/A * Our poll manager handler. 1N/A * Forwarding specification. 1N/A * XXX: lwip-format copy of destination 1N/A * Ring-buffer for inbound datagrams. 1N/A/* poll manager callback for fwudp socket */ 1N/A/* lwip thread callbacks called via proxy_lwip_post() */ 1N/A * Linked list of active fwtcp forwarders. /* fwudp_create has put fwudp on the linked list */ /* let pending msg_send be processed before we delete fwudp */ * Poll manager callaback for fwudp::sock /* Check that ring buffer is not full */ if (
beg ==
lim) {
/* no vacant slot */ * Lwip thread callback invoked via fwudp::msg_send /* empty buffer - shouldn't happen! */ #
if 1 /* valgrind hint */ /* XXX: this is *STUPID* */ * XXX: check that its ours and not accidentally created by * ???: Otherwise? Expire it and set pcb = NULL; to create a /* equivalent of udp_bind */ /* equivalent to udp_connect */ DPRINTF((
"%s: pcb %p (fwudp %p); sock %d: expired\n",
/* NB: fwudp is "global" and not deleted */ /* XXX: TODO: delete local reference when we will keep one */ * XXX: This is pxudp_pcb_forward_outbound modulo: * - addr/port (unused in either) dropped * - destination is specified since host socket is not connected * Lwip thread callback invoked via fwudp::msg_delete