VirtualBox

Changeset 51332 in vbox for trunk/src/VBox/NetworkServices


Ignore:
Timestamp:
May 22, 2014 1:52:41 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
93816
Message:

pxtcp_pcb_forward_outbound: move code to do sendmsg/WSASend to a
separate function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NAT/pxtcp.c

    r51300 r51332  
    255255static err_t pxtcp_pcb_forward_outbound(struct pxtcp *, struct pbuf *);
    256256static void pxtcp_pcb_forward_outbound_close(struct pxtcp *);
     257
     258static ssize_t pxtcp_sock_send(struct pxtcp *, IOVEC *, size_t);
    257259
    258260static void pxtcp_pcb_forward_inbound(struct pxtcp *);
     
    14281430    int sockerr;
    14291431
    1430 #if defined(MSG_NOSIGNAL)
    1431     const int send_flags = MSG_NOSIGNAL;
    1432 #else
    1433     const int send_flags = 0;
    1434 #endif
    1435 
    1436 
    14371432    LWIP_ASSERT1(pxtcp->unsent == NULL || pxtcp->unsent == p);
    14381433
     
    14451440    qs = p;
    14461441    while (qs != NULL) {
    1447 #ifndef RT_OS_WINDOWS
    1448         struct msghdr mh;
    1449 #else
    1450         int rc;
    1451 #endif
    14521442        IOVEC iov[8];
    14531443        const size_t iovsize = sizeof(iov)/sizeof(iov[0]);
     
    14641454        }
    14651455
    1466 #ifndef RT_OS_WINDOWS
    1467         memset(&mh, 0, sizeof(mh));
    1468         mh.msg_iov = iov;
    1469         mh.msg_iovlen = i;
    1470 
    1471         nsent = sendmsg(pxtcp->sock, &mh, send_flags);
    1472 #else
    1473         /**
    1474          * WSASend(,,,DWORD *,,,) - takes SSIZE_T (64bit value) ... so all nsent's
    1475          * bits should be zeroed before passing to WSASent.
     1456        /*
     1457         * TODO: This is where application-level proxy can hook into
     1458         * to process outbound traffic.
    14761459         */
    1477         nsent = 0;
    1478         rc = WSASend(pxtcp->sock, iov, (DWORD)i, (DWORD *)&nsent, 0, NULL, NULL);
    1479         if (rc == SOCKET_ERROR) {
    1480             /* WSASent reports SOCKET_ERROR and updates error accessible with
    1481              * WSAGetLastError(). We assign nsent to -1, enforcing code below
    1482              * to access error in BSD style.
    1483              */
    1484             warn("pxtcp_pcb_forward_outbound:WSASend error:%d nsent:%d\n",
    1485                  WSAGetLastError(),
    1486                  nsent);
    1487             nsent = -1;
    1488        }
    1489 #endif
     1460        nsent = pxtcp_sock_send(pxtcp, iov, i);
    14901461
    14911462        if (nsent == (ssize_t)fwd1) {
     
    15811552    return ERR_OK;
    15821553}
     1554
     1555
     1556#if !defined(RT_OS_WINDOWS)
     1557static ssize_t
     1558pxtcp_sock_send(struct pxtcp *pxtcp, IOVEC *iov, size_t iovlen)
     1559{
     1560    struct msghdr mh;
     1561    ssize_t nsent;
     1562
     1563#ifdef MSG_NOSIGNAL
     1564    const int send_flags = MSG_NOSIGNAL;
     1565#else
     1566    const int send_flags = 0;
     1567#endif
     1568
     1569    memset(&mh, 0, sizeof(mh));
     1570
     1571    mh.msg_iov = iov;
     1572    mh.msg_iovlen = iovlen;
     1573
     1574    nsent = sendmsg(pxtcp->sock, &mh, send_flags);
     1575
     1576    return nsent;
     1577}
     1578#else /* RT_OS_WINDOWS */
     1579static ssize_t
     1580pxtcp_sock_send(struct pxtcp *pxtcp, IOVEC *iov, size_t iovlen)
     1581{
     1582    DWORD nsent;
     1583    int status;
     1584
     1585    status = WSASend(pxtcp->sock, iov, (DWORD)iovlen, &nsent,
     1586                     0, NULL, NULL);
     1587    if (status == SOCKET_ERROR) {
     1588        nsent = -1;
     1589    }
     1590
     1591    return nsent;
     1592}
     1593#endif /* RT_OS_WINDOWS */
    15831594
    15841595
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