VirtualBox

Changeset 65580 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Feb 1, 2017 10:36:52 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
113234
Message:

Main/DHCPServerImpl: use newly introduced RTNetMaskToPrefixIPv4.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/DHCPServerImpl.cpp

    r65571 r65580  
    276276        return E_INVALIDARG;
    277277
     278    /*
     279     * Insist on continuous mask.  May be also accept prefix length
     280     * here or address/prefix for aIPAddress?
     281     */
     282    rc = RTNetMaskToPrefixIPv4(&NetworkMask, NULL);
     283    if (RT_FAILURE(rc))
     284        return E_INVALIDARG;
     285
    278286    /* It's more convenient to convert to host order once */
    279287    IPAddress.u = RT_N2H_U32(IPAddress.u);
     
    288296    {
    289297        return E_INVALIDARG;
    290     }
    291 
    292     /*
    293      * Insist on continuous mask.  May be also accept prefix length
    294      * here or address/prefix for aIPAddress?
    295      */
    296     if (NetworkMask.u != 0) {
    297         /* TODO: factor out mask<->length to <iptr/cidr.h>? */
    298         uint32_t prefixMask = 0xffffffff;
    299         int prefixLen = 32;
    300 
    301         while (prefixLen > 0) {
    302             if (NetworkMask.u == prefixMask)
    303                 break;
    304             --prefixLen;
    305             prefixMask <<= 1;
    306         }
    307 
    308         if (prefixLen == 0)
    309             return E_INVALIDARG;
    310298    }
    311299
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