VirtualBox

Changeset 48241 in vbox for trunk/src


Ignore:
Timestamp:
Sep 3, 2013 2:07:03 AM (11 years ago)
Author:
vboxsync
Message:

Provide ability to bind proxy socket to a local address - to be used
to implement equivalent of --natbindip<N>.

Location:
trunk/src/VBox/NetworkServices/NAT
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp

    r47950 r48241  
    137137   private:
    138138    struct proxy_options m_ProxyOptions;
     139    struct sockaddr_in m_src4;
     140    struct sockaddr_in6 m_src6;
     141
    139142    uint16_t m_u16Mtu;
    140143    netif m_LwipNetIf;
     
    699702
    700703    m_ProxyOptions.tftp_root = NULL;
     704    m_ProxyOptions.src4 = NULL;
     705    m_ProxyOptions.src6 = NULL;
     706    memset(&m_src4, 0, sizeof(m_src4));
     707    memset(&m_src6, 0, sizeof(m_src6));
     708    m_src4.sin_family = AF_INET;
     709    m_src6.sin6_family = AF_INET6;
     710#if HAVE_SA_LEN
     711    m_src4.sa_len = sizeof(m_src4);
     712    m_src6.sa_len = sizeof(m_src6);
     713#endif
    701714
    702715    m_LwipNetIf.name[0] = 'N';
  • trunk/src/VBox/NetworkServices/NAT/proxytest.c

    r48001 r48241  
    3535static SOCKET proxy_create_socket(int, int);
    3636
     37volatile const struct proxy_options *g_proxy_options;
    3738static sys_thread_t pollmgr_tid;
    3839
     
    4849    int status;
    4950
     51    LWIP_ASSERT1(opts != NULL);
    5052    LWIP_UNUSED_ARG(proxy_netif);
     53
     54    g_proxy_options = opts;
    5155
    5256#if 1
     
    5862#endif
    5963
    60     if (opts != NULL && opts->tftp_root != NULL) {
     64    if (opts->tftp_root != NULL) {
    6165        tftpd_init(proxy_netif, opts->tftp_root);
    6266    }
     
    225229    socklen_t dst_sa_len;
    226230    void *pdst_addr;
     231    const struct sockaddr *psrc_sa;
     232    socklen_t src_sa_len;
    227233    int status;
    228234    SOCKET s;
     
    278284    }
    279285    DPRINTF(("socket %d\n", s));
     286
     287    /* TODO: needs locking if dynamic modifyvm is allowed */
     288    if (sdom == PF_INET6) {
     289        psrc_sa = (const struct sockaddr *)g_proxy_options->src6;
     290        src_sa_len = sizeof(struct sockaddr_in6);
     291    }
     292    else {
     293        psrc_sa = (const struct sockaddr *)g_proxy_options->src4;
     294        src_sa_len = sizeof(struct sockaddr_in);
     295    }
     296    if (psrc_sa != NULL) {
     297        status = bind(s, psrc_sa, src_sa_len);
     298        if (status == SOCKET_ERROR) {
     299            DPRINTF(("socket %d: bind: %s\n", s, strerror(errno)));
     300            closesocket(s);
     301            return INVALID_SOCKET;
     302        }
     303    }
    280304
    281305    status = connect(s, pdst_sa, dst_sa_len);
  • trunk/src/VBox/NetworkServices/NAT/proxytest.h

    r48001 r48241  
    1515struct pbuf;
    1616struct sockaddr;
     17struct sockaddr_in;
     18struct sockaddr_in6;
    1719
    1820struct proxy_options {
    1921    const char *tftp_root;
     22    const struct sockaddr_in *src4;
     23    const struct sockaddr_in6 *src6;
    2024};
    2125
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