VirtualBox

Ignore:
Timestamp:
Jan 23, 2021 1:11:06 AM (4 years ago)
Author:
vboxsync
Message:

NAT/Net: Collect VBoxNetBaseService (receive) and lwip (send)
callbacks together, so that packet shuffling is all in one place.

File:
1 edited

Legend:

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

    r87397 r87398  
    922922
    923923
    924 /*static*/ err_t VBoxNetLwipNAT::netifLinkoutput(netif *pNetif, pbuf *pPBuf) RT_NOTHROW_DEF
    925 {
    926     AssertPtrReturn(pNetif, ERR_ARG);
    927     AssertPtrReturn(pPBuf, ERR_ARG);
    928 
    929     VBoxNetLwipNAT *self = static_cast<VBoxNetLwipNAT *>(pNetif->state);
    930     AssertPtrReturn(self, ERR_IF);
    931     AssertReturn(self == g_pLwipNat, ERR_ARG);
    932 
    933     LogFlowFunc(("ENTER: pNetif[%c%c%d], pPbuf:%p\n",
    934                  pNetif->name[0],
    935                  pNetif->name[1],
    936                  pNetif->num,
    937                  pPBuf));
    938 
    939     RT_ZERO(VBoxNetLwipNAT::aXmitSeg);
    940 
    941     size_t idx = 0;
    942     for (struct pbuf *q = pPBuf; q != NULL; q = q->next, ++idx)
    943     {
    944         AssertReturn(idx < RT_ELEMENTS(VBoxNetLwipNAT::aXmitSeg), ERR_MEM);
    945 
    946 #if ETH_PAD_SIZE
    947         if (q == pPBuf)
    948         {
    949             VBoxNetLwipNAT::aXmitSeg[idx].pv = (uint8_t *)q->payload + ETH_PAD_SIZE;
    950             VBoxNetLwipNAT::aXmitSeg[idx].cb = q->len - ETH_PAD_SIZE;
    951         }
    952         else
    953 #endif
    954         {
    955             VBoxNetLwipNAT::aXmitSeg[idx].pv = q->payload;
    956             VBoxNetLwipNAT::aXmitSeg[idx].cb = q->len;
    957         }
    958     }
    959 
    960     int rc = self->sendBufferOnWire(VBoxNetLwipNAT::aXmitSeg, idx,
    961                                     pPBuf->tot_len - ETH_PAD_SIZE);
    962     AssertRCReturn(rc, ERR_IF);
    963 
    964     self->flushWire();
    965 
    966     LogFlowFunc(("LEAVE: %d\n", ERR_OK));
    967     return ERR_OK;
    968 }
    969 
    970 
    971924/*static*/ int VBoxNetLwipNAT::natServicePfRegister(NATSERVICEPORTFORWARDRULE& natPf)
    972925{
     
    10891042
    10901043
     1044/**
     1045 * Process an incoming frame received from the intnet.
     1046 */
    10911047int VBoxNetLwipNAT::processFrame(void *pvFrame, size_t cbFrame)
    10921048{
     
    11281084
    11291085
     1086/**
     1087 * Process an incoming GSO frame received from the intnet.
     1088 */
    11301089int VBoxNetLwipNAT::processGSO(PCPDMNETWORKGSO pGso, size_t cbFrame)
    11311090{
     
    11561115
    11571116    return VINF_SUCCESS;
     1117}
     1118
     1119
     1120/**
     1121 * Send an outgoing frame from lwIP to intnet.
     1122 */
     1123/* static */
     1124err_t VBoxNetLwipNAT::netifLinkoutput(netif *pNetif, pbuf *pPBuf) RT_NOTHROW_DEF
     1125{
     1126    AssertPtrReturn(pNetif, ERR_ARG);
     1127    AssertPtrReturn(pPBuf, ERR_ARG);
     1128
     1129    VBoxNetLwipNAT *self = static_cast<VBoxNetLwipNAT *>(pNetif->state);
     1130    AssertPtrReturn(self, ERR_IF);
     1131    AssertReturn(pNetif == &self->m_LwipNetIf, ERR_IF);
     1132
     1133    LogFlowFunc(("ENTER: pNetif[%c%c%d], pPbuf:%p\n",
     1134                 pNetif->name[0],
     1135                 pNetif->name[1],
     1136                 pNetif->num,
     1137                 pPBuf));
     1138
     1139    RT_ZERO(VBoxNetLwipNAT::aXmitSeg);
     1140
     1141    size_t idx = 0;
     1142    for (struct pbuf *q = pPBuf; q != NULL; q = q->next, ++idx)
     1143    {
     1144        AssertReturn(idx < RT_ELEMENTS(VBoxNetLwipNAT::aXmitSeg), ERR_MEM);
     1145
     1146#if ETH_PAD_SIZE
     1147        if (q == pPBuf)
     1148        {
     1149            VBoxNetLwipNAT::aXmitSeg[idx].pv = (uint8_t *)q->payload + ETH_PAD_SIZE;
     1150            VBoxNetLwipNAT::aXmitSeg[idx].cb = q->len - ETH_PAD_SIZE;
     1151        }
     1152        else
     1153#endif
     1154        {
     1155            VBoxNetLwipNAT::aXmitSeg[idx].pv = q->payload;
     1156            VBoxNetLwipNAT::aXmitSeg[idx].cb = q->len;
     1157        }
     1158    }
     1159
     1160    int rc = self->sendBufferOnWire(VBoxNetLwipNAT::aXmitSeg, idx,
     1161                                    pPBuf->tot_len - ETH_PAD_SIZE);
     1162    AssertRCReturn(rc, ERR_IF);
     1163
     1164    self->flushWire();
     1165
     1166    LogFlowFunc(("LEAVE: %d\n", ERR_OK));
     1167    return ERR_OK;
    11581168}
    11591169
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