VirtualBox

Changeset 73097 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
Jul 12, 2018 9:06:33 PM (7 years ago)
Author:
vboxsync
Message:

*: Made RT_UOFFSETOF, RT_OFFSETOF, RT_UOFFSETOF_ADD and RT_OFFSETOF_ADD work like builtin_offsetof() and require compile time resolvable requests, adding RT_UOFFSETOF_DYN for the dynamic questions that can only be answered at runtime.

Location:
trunk/src/VBox/Devices/Network
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvTAP.cpp

    r69500 r73097  
    134134
    135135/** Converts a pointer to TAP::INetworkUp to a PRDVTAP. */
    136 #define PDMINETWORKUP_2_DRVTAP(pInterface) ( (PDRVTAP)((uintptr_t)pInterface - RT_OFFSETOF(DRVTAP, INetworkUp)) )
     136#define PDMINETWORKUP_2_DRVTAP(pInterface) ( (PDRVTAP)((uintptr_t)pInterface - RT_UOFFSETOF(DRVTAP, INetworkUp)) )
    137137
    138138
  • trunk/src/VBox/Devices/Network/DrvUDPTunnel.cpp

    r69500 r73097  
    101101
    102102/** Converts a pointer to UDPTUNNEL::INetworkUp to a PRDVUDPTUNNEL. */
    103 #define PDMINETWORKUP_2_DRVUDPTUNNEL(pInterface) ( (PDRVUDPTUNNEL)((uintptr_t)pInterface - RT_OFFSETOF(DRVUDPTUNNEL, INetworkUp)) )
     103#define PDMINETWORKUP_2_DRVUDPTUNNEL(pInterface) ( (PDRVUDPTUNNEL)((uintptr_t)pInterface - RT_UOFFSETOF(DRVUDPTUNNEL, INetworkUp)) )
    104104
    105105
  • trunk/src/VBox/Devices/Network/DrvVDE.cpp

    r69500 r73097  
    107107
    108108/** Converts a pointer to VDE::INetworkUp to a PRDVVDE. */
    109 #define PDMINETWORKUP_2_DRVVDE(pInterface) ( (PDRVVDE)((uintptr_t)pInterface - RT_OFFSETOF(DRVVDE, INetworkUp)) )
     109#define PDMINETWORKUP_2_DRVVDE(pInterface) ( (PDRVVDE)((uintptr_t)pInterface - RT_UOFFSETOF(DRVVDE, INetworkUp)) )
    110110
    111111
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r69500 r73097  
    21082108{
    21092109    PINTNETDSTTAB pDstTab;
    2110     *ppDstTab = pDstTab = (PINTNETDSTTAB)RTMemAlloc(RT_OFFSETOF(INTNETDSTTAB, aIfs[cEntries]));
     2110    *ppDstTab = pDstTab = (PINTNETDSTTAB)RTMemAlloc(RT_UOFFSETOF_DYN(INTNETDSTTAB, aIfs[cEntries]));
    21112111    if (RT_UNLIKELY(!pDstTab))
    21122112        return VERR_NO_MEMORY;
     
    25232523            {
    25242524                /* check if the protocol is UDP */
    2525                 if (    intnetR0SgReadByte(pSG, sizeof(RTNETETHERHDR) + RT_OFFSETOF(RTNETIPV4, ip_p))
     2525                if (    intnetR0SgReadByte(pSG, sizeof(RTNETETHERHDR) + RT_UOFFSETOF(RTNETIPV4, ip_p))
    25262526                    !=  RTNETIPV4_PROT_UDP)
    25272527                    return;
     
    25472547            {
    25482548                /* get the lower byte of the UDP source port number. */
    2549                 b = intnetR0SgReadByte(pSG, sizeof(RTNETETHERHDR) + cbIpHdr + RT_OFFSETOF(RTNETUDP, uh_sport) + 1);
     2549                b = intnetR0SgReadByte(pSG, sizeof(RTNETETHERHDR) + cbIpHdr + RT_UOFFSETOF(RTNETUDP, uh_sport) + 1);
    25502550                if (    b != RTNETIPV4_PORT_BOOTPS
    25512551                    &&  b != RTNETIPV4_PORT_BOOTPC)
    25522552                    return;
    25532553                uint8_t SrcPort = b;
    2554                 b = intnetR0SgReadByte(pSG, sizeof(RTNETETHERHDR) + cbIpHdr + RT_OFFSETOF(RTNETUDP, uh_sport));
     2554                b = intnetR0SgReadByte(pSG, sizeof(RTNETETHERHDR) + cbIpHdr + RT_UOFFSETOF(RTNETUDP, uh_sport));
    25552555                if (b)
    25562556                    return;
    25572557
    25582558                /* get the lower byte of the UDP destination port number. */
    2559                 b = intnetR0SgReadByte(pSG, sizeof(RTNETETHERHDR) + cbIpHdr + RT_OFFSETOF(RTNETUDP, uh_dport) + 1);
     2559                b = intnetR0SgReadByte(pSG, sizeof(RTNETETHERHDR) + cbIpHdr + RT_UOFFSETOF(RTNETUDP, uh_dport) + 1);
    25602560                if (    b != RTNETIPV4_PORT_BOOTPS
    25612561                    &&  b != RTNETIPV4_PORT_BOOTPC)
     
    25632563                if (b == SrcPort)
    25642564                    return;
    2565                 b = intnetR0SgReadByte(pSG, sizeof(RTNETETHERHDR) + cbIpHdr + RT_OFFSETOF(RTNETUDP, uh_dport));
     2565                b = intnetR0SgReadByte(pSG, sizeof(RTNETETHERHDR) + cbIpHdr + RT_UOFFSETOF(RTNETUDP, uh_dport));
    25662566                if (b)
    25672567                    return;
     
    32233223        {
    32243224            uint16_t ar_oper;
    3225             if (!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR) + RT_OFFSETOF(RTNETARPHDR, ar_oper),
     3225            if (!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR) + RT_UOFFSETOF(RTNETARPHDR, ar_oper),
    32263226                                    sizeof(ar_oper), &ar_oper))
    32273227                return false;
     
    32423242        {
    32433243            RTNETADDRIPV4 ip_dst;
    3244             if (!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR) + RT_OFFSETOF(RTNETIPV4, ip_dst),
     3244            if (!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR) + RT_UOFFSETOF(RTNETIPV4, ip_dst),
    32453245                                    sizeof(ip_dst), &ip_dst))
    32463246                return false;
     
    32723272        {
    32733273            RTNETADDRIPV6 ip6_dst;
    3274             if (!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR) + RT_OFFSETOF(RTNETIPV6, ip6_dst),
     3274            if (!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR) + RT_UOFFSETOF(RTNETIPV6, ip6_dst),
    32753275                                    sizeof(ip6_dst), &ip6_dst))
    32763276                return false;
     
    32953295     * Update ethernet destination in the segment.
    32963296     */
    3297     intnetR0SgWritePart(pSG, RT_OFFSETOF(RTNETETHERHDR, DstMac), sizeof(pEthHdr->DstMac), &pEthHdr->DstMac);
     3297    intnetR0SgWritePart(pSG, RT_UOFFSETOF(RTNETETHERHDR, DstMac), sizeof(pEthHdr->DstMac), &pEthHdr->DstMac);
    32983298
    32993299    return true;
     
    34243424                pEthHdr->DstMac = pIf->MacAddr;
    34253425                if ((void *)pEthHdr != pSG->aSegs[0].pv)
    3426                     intnetR0SgWritePart(pSG, RT_OFFSETOF(RTNETETHERHDR, DstMac), sizeof(RTMAC), &pIf->MacAddr);
     3426                    intnetR0SgWritePart(pSG, RT_UOFFSETOF(RTNETETHERHDR, DstMac), sizeof(RTMAC), &pIf->MacAddr);
    34273427            }
    34283428            intnetR0BusyDecIf(pIf);
     
    35573557                Log(("intnetR0NetworkEditDhcpFromIntNet: cleared ip_tos (was %#04x); ip_sum=%#06x -> %#06x\n",
    35583558                     uTos, RT_BE2H_U16(pIpHdr->ip_sum), RT_BE2H_U16(uChecksum) ));
    3559                 intnetR0SgWritePart(pSG, sizeof(RTNETETHERHDR) + RT_OFFSETOF(RTNETIPV4, ip_sum),
     3559                intnetR0SgWritePart(pSG, sizeof(RTNETETHERHDR) + RT_UOFFSETOF(RTNETIPV4, ip_sum),
    35603560                                    sizeof(pIpHdr->ip_sum), &uChecksum);
    35613561            }
     
    37503750    {
    37513751        case RTNET_ETHERTYPE_IPV4:
    3752             if (RT_UNLIKELY(!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR) + RT_OFFSETOF(RTNETIPV4, ip_dst), sizeof(Addr.IPv4), &Addr)))
     3752            if (RT_UNLIKELY(!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR) + RT_UOFFSETOF(RTNETIPV4, ip_dst), sizeof(Addr.IPv4), &Addr)))
    37533753            {
    37543754                Log(("intnetshareduni: failed to read ip_dst! cbTotal=%#x\n", pSG->cbTotal));
     
    37613761
    37623762        case RTNET_ETHERTYPE_IPV6:
    3763             if (RT_UNLIKELY(!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR) + RT_OFFSETOF(RTNETIPV6, ip6_dst), sizeof(Addr.IPv6), &Addr)))
     3763            if (RT_UNLIKELY(!intnetR0SgReadPart(pSG, sizeof(RTNETETHERHDR) + RT_UOFFSETOF(RTNETIPV6, ip6_dst), sizeof(Addr.IPv6), &Addr)))
    37643764            {
    37653765                Log(("intnetshareduni: failed to read ip6_dst! cbTotal=%#x\n", pSG->cbTotal));
     
    57745774     */
    57755775    RTCPUID         cCpus    = RTMpGetCount(); Assert(cCpus > 0);
    5776     PINTNETTRUNKIF  pTrunk = (PINTNETTRUNKIF)RTMemAllocZ(RT_OFFSETOF(INTNETTRUNKIF, apIntDstTabs[cCpus]));
     5776    PINTNETTRUNKIF  pTrunk = (PINTNETTRUNKIF)RTMemAllocZ(RT_UOFFSETOF_DYN(INTNETTRUNKIF, apIntDstTabs[cCpus]));
    57775777    if (!pTrunk)
    57785778        return VERR_NO_MEMORY;
  • trunk/src/VBox/Devices/Network/slirp/bootp.c

    r70842 r73097  
    863863    size_t vlen;
    864864
    865     if (mlen < RT_OFFSETOF(struct bootp_t, bp_vend) + sizeof(rfc1533_cookie))
     865    if (mlen < RT_UOFFSETOF(struct bootp_t, bp_vend) + sizeof(rfc1533_cookie))
    866866    {
    867867        LogRelMax(50, ("NAT: ignoring invalid BOOTP request (mlen %u too short)\n", mlen));
     
    893893    }
    894894
    895     vlen = mlen - RT_OFFSETOF(struct bootp_t, bp_vend);
     895    vlen = mlen - RT_UOFFSETOF(struct bootp_t, bp_vend);
    896896    dhcp_decode(pData, bp, vlen);
    897897}
  • trunk/src/VBox/Devices/Network/slirp/ip_icmpwin.c

    r69500 r73097  
    155155    bufsize += 16; /* whatever that is; empirically at least XP needs it */
    156156
    157     pongsize = RT_OFFSETOF(struct pong, buf) + bufsize;
     157    pongsize = RT_UOFFSETOF(struct pong, buf) + bufsize;
    158158    if (pData->cbIcmpPending + pongsize > 1024 * 1024)
    159159        return;
     
    327327        size_t sz;
    328328
    329         sz = RT_OFFSETOF(struct pong, buf) + pong->bufsize;
     329        sz = RT_UOFFSETOF(struct pong, buf) + pong->bufsize;
    330330        Assert(pData->cbIcmpPending >= sz);
    331331        pData->cbIcmpPending -= sz;
  • trunk/src/VBox/Devices/Network/slirp/tftp.c

    r69500 r73097  
    266266
    267267    pszTftpRRQRaw = (char *)&pcTftpIpHeader->Core;
    268     cbTftpRRQRaw = RT_H2N_U16(pcTftpIpHeader->UdpHdr.uh_ulen) + sizeof(struct ip) - RT_OFFSETOF(TFTPIPHDR, Core);
     268    cbTftpRRQRaw = RT_H2N_U16(pcTftpIpHeader->UdpHdr.uh_ulen) + sizeof(struct ip) - RT_UOFFSETOF(TFTPIPHDR, Core);
    269269    while (cbTftpRRQRaw)
    270270    {
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