VirtualBox

Changeset 58555 in vbox


Ignore:
Timestamp:
Nov 4, 2015 3:34:28 AM (9 years ago)
Author:
vboxsync
Message:

lwip: tcp_accept_syn - a proxy like early accept callback for ordinary
listening pcbs. Still need to figure out a way to pass syn pbuf to
the callback. Need to be consistent with proxy version, but can't
abuse callback_arg here since it's actually used in this case.

Location:
trunk/src/VBox/Devices/Network/lwip-new/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/lwip-new/src/core/tcp.c

    r58549 r58555  
    601601  lpcb->accept_any_ip_version = 0;
    602602#endif /* LWIP_IPV6 */
     603#if LWIP_CONNECTION_PROXY
     604  lpcb->accept_on_syn = 0;
     605#endif
    603606  ipX_addr_copy(PCB_ISIPV6(pcb), lpcb->local_ip, pcb->local_ip);
    604607  if (pcb->local_port != 0) {
     
    15591562{
    15601563  tcp_proxy_accept_callback = accept;
     1564}
     1565
     1566
     1567/**
     1568 * A cross between normal accept and proxy early accept.  Like with
     1569 * normal accept there's a normal LISTENing pcb.  Like with proxy, the
     1570 * accept callback will be called on the first SYN.
     1571 */
     1572void
     1573tcp_accept_syn(struct tcp_pcb *pcb, tcp_accept_fn accept)
     1574{
     1575  struct tcp_pcb_listen *lpcb;
     1576
     1577  LWIP_ASSERT("invalid socket state for accept callback", pcb->state == LISTEN);
     1578  lpcb = (struct tcp_pcb_listen *)pcb;
     1579
     1580  lpcb->accept = accept;
     1581  lpcb->accept_on_syn = 1;
    15611582}
    15621583#endif /* LWIP_CONNECTION_PROXY */
  • trunk/src/VBox/Devices/Network/lwip-new/src/core/tcp_in.c

    r58549 r58555  
    569569      &npcb->remote_ip, PCB_ISIPV6(npcb));
    570570#endif /* TCP_CALCULATE_EFF_SEND_MSS */
     571
     572
     573#if LWIP_CONNECTION_PROXY
     574    /* Early accept on SYN, like we do in tcp_proxy_listen_input() */
     575    if (pcb->accept_on_syn) {
     576      err_t err;
     577
     578      /* back off to "delayed" SYN_RCVD, see comments in proxy */
     579      npcb->state = SYN_RCVD_0;
     580
     581      /*
     582       * XXX: TODO: how to pass syn pbuf?  Need to be consistent with
     583       * proxy version, but can't abuse callback_arg here since it's
     584       * actually used in this case.
     585       */
     586      /* Call the accept function. */
     587      TCP_EVENT_ACCEPT(npcb, ERR_OK, err);
     588      if (err != ERR_OK) {
     589        /* If the accept function returns with an error, we abort
     590         * the connection. */
     591        /* Already aborted? */
     592        if (err != ERR_ABRT) {
     593          tcp_abort(npcb);
     594        }
     595        return ERR_ABRT;
     596      }
     597      /* Don't send SYN|ACK now, client will call
     598       * tcp_proxy_accept_confirm(). */
     599      return ERR_OK;
     600    }
     601#endif
    571602
    572603    snmp_inc_tcppassiveopens();
  • trunk/src/VBox/Devices/Network/lwip-new/src/include/lwip/tcp.h

    r47886 r58555  
    301301  u8_t accept_any_ip_version;
    302302#endif /* LWIP_IPV6 */
     303#if LWIP_CONNECTION_PROXY
     304  u8_t accept_on_syn;
     305#endif
    303306};
    304307
     
    331334void             tcp_proxy_arg(void *arg);
    332335void             tcp_proxy_accept(tcp_accept_fn accept);
     336/* but we also provide proxy-like early accept for listening pcbs */
     337void             tcp_accept_syn(struct tcp_pcb *lpcb, tcp_accept_fn accept);
    333338#endif
    334339void             tcp_recv    (struct tcp_pcb *pcb, tcp_recv_fn recv);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette