VirtualBox

Changeset 45116 in vbox


Ignore:
Timestamp:
Mar 21, 2013 8:08:21 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84410
Message:

patch getopt-cidr.patch from xTracker/5894 with applied recommendations from comment 91.

introduces RTGETOPT_REQ_IPV4CIDR in getop.h

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/getopt.h

    r44528 r45116  
    7070 * (Not a name, but 4 values in the 0..255 range with dots separating them). */
    7171#define RTGETOPT_REQ_IPV4ADDR                   10
    72 #if 0
    7372/** The value must be a valid IPv4 CIDR.
    7473 * As with RTGETOPT_REQ_IPV4ADDR, no name.
    75  * @todo Mix CIDR with types.h or/and net.h first and find a way to make the
    76  *       mask optional like with ifconfig. See RTCidrStrToIPv4. */
     74 */
    7775#define RTGETOPT_REQ_IPV4CIDR                   11
     76#if 0
     77/* take placers */
     78/** The value must be a valid IPv6 addr
     79 * @todo: Add types and parsing routines in (iprt/net.h)
     80 */
     81#define RTGETOPT_REQ_IPV6ADDR                   12
     82/** The value must be a valid IPv6 CIDR
     83 * @todo: Add types and parsing routines in (iprt/net.h)
     84 */
     85#define RTGETOPT_REQ_IPV6CIDR                   13
    7886#endif
    7987/** The value must be a valid ethernet MAC address. */
     
    164172    /** A RTGETOPT_REQ_IPV4ADDR option argument. */
    165173    RTNETADDRIPV4   IPv4Addr;
     174    /** A RTGETOPT_REQ_IPV4CIDR option argument. */
     175    struct
     176    {
     177        RTNETADDRIPV4 IPv4Network;
     178        RTNETADDRIPV4 IPv4Netmask;
     179    } CidrIPv4;
    166180#endif
    167181    /** A RTGETOPT_REQ_MACADDR option argument. */
  • trunk/src/VBox/Runtime/common/misc/getopt.cpp

    r45115 r45116  
    2828*   Header Files                                                               *
    2929*******************************************************************************/
     30#include <iprt/cidr.h>
    3031#include <iprt/net.h>                   /* must come before getopt.h */
    3132#include <iprt/getopt.h>
     
    410411            break;
    411412        }
    412 #if 0  /** @todo CIDR */
    413 #endif
     413
     414        case RTGETOPT_REQ_IPV4CIDR:
     415        {
     416            RTNETADDRIPV4 network;
     417            RTNETADDRIPV4 netmask;
     418            if (RT_FAILURE(RTCidrStrToIPv4(pszValue, &network, &netmask)))
     419              return VERR_GETOPT_INVALID_ARGUMENT_FORMAT;
     420            pValueUnion->CidrIPv4.IPv4Network.u = network.u;
     421            pValueUnion->CidrIPv4.IPv4Netmask.u = netmask.u;
     422            break;
     423        }
    414424
    415425        case RTGETOPT_REQ_MACADDR:
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