VirtualBox

Changeset 58589 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Nov 5, 2015 4:00:52 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
103947
Message:

lwip: tcp_restore_pbuf - factor out code to restore syn pbuf passed to
the proxy accept callback into a new function.

File:
1 edited

Legend:

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

    r58581 r58589  
    9595#if LWIP_CONNECTION_PROXY
    9696static err_t tcp_proxy_listen_input(struct pbuf *p);
     97static void tcp_restore_pbuf(struct pbuf *p);
    9798
    9899void
     
    255256       * create ICMP datagram.
    256257       */
    257       pbuf_header(p, ip_current_header_tot_len() + hdrlen * 4);
    258258      tcp_proxy_listen_input(p);
    259259      pbuf_free(p);
     
    613613
    614614#if LWIP_CONNECTION_PROXY
     615/*
     616 * Proxy accept callback will be passed the pbuf with the SYN segment
     617 * so that it can use it for ICMP errors if necessary.  Undo changes
     618 * we've done to the pbuf so that it's suitable to be passed to
     619 * icmp_send_response().
     620 */
     621static void
     622tcp_restore_pbuf(struct pbuf *p)
     623{
     624    u8_t hdrlen = TCPH_HDRLEN(tcphdr);
     625
     626    /* Reveal IP and TCP headers. */
     627    pbuf_header(p, ip_current_header_tot_len() + hdrlen * 4);
     628
     629    /* Convert fields in the TCP header back to network byte order. */
     630    tcphdr->src = htons(tcphdr->src);
     631    tcphdr->dest = htons(tcphdr->dest);
     632    tcphdr->seqno = htonl(tcphdr->seqno);
     633    tcphdr->ackno = htonl(tcphdr->ackno);
     634    tcphdr->wnd = htons(tcphdr->wnd);
     635}
     636
     637
    615638/**
    616639 * We run proxied packets through tcp_input() since it mostly does
     
    707730     * For the proxy to be able to create ICMP unreachable datagram we
    708731     * need to keep the beginning of the pbuf around.  We pass is as
    709      * callback arg here and let callback decide.  Payload is already
    710      * moved back to the IP header by the caller.
     732     * callback arg here and let callback decide.
    711733     */
    712734
    713     /*
    714      * Convert fields in the TCP header back to network byte order
    715      * (for ICMP).  I think it's safe to do now, as tcphdr will not be
    716      * accessed after this.
    717      */
    718     tcphdr->src = htons(tcphdr->src);
    719     tcphdr->dest = htons(tcphdr->dest);
    720     tcphdr->seqno = htonl(tcphdr->seqno);
    721     tcphdr->ackno = htonl(tcphdr->ackno);
    722     tcphdr->wnd = htons(tcphdr->wnd);
    723 
     735    tcp_restore_pbuf(p);
    724736    npcb->callback_arg = (void *)p;
    725737 
Note: See TracChangeset for help on using the changeset viewer.

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