VBoxNetAdpCtl.cpp revision 0be1c98f1388ddc063a7e830f53e2018f658b348
/* $Id$ */
/** @file
* Apps - VBoxAdpCtl, Configuration tool for vboxnetX adapters.
*/
/*
* Copyright (C) 2009 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define VBOXADPCTL_IFCONFIG_PATH "/sbin/ifconfig"
static void showUsage(void)
{
}
{
const char * const argv[] =
{
pcszArg1, /* [address family] */
pcszArg2, /* address */
pcszArg3, /* ['netmask'] */
pcszArg4, /* [network mask] */
NULL /* terminator */
};
int rc = EXIT_SUCCESS;
switch (childPid)
{
case -1: /* Something went wrong. */
perror("fork() failed");
rc = EXIT_FAILURE;
break;
case 0: /* Child process. */
rc = EXIT_FAILURE;
break;
default: /* Parent process. */
break;
}
return rc;
}
#define MAX_ADDRESSES 128
#define MAX_ADDRLEN 64
static bool removeAddresses(const char *pszAdapterName)
{
if (!fp)
return false;
int cAddrs;
{
/* We are concerned with IPv6 address lines only. */
continue;
/* Skip link-local addresses. */
continue;
}
for (int i = 0; i < cAddrs; i++)
{
return false;
}
return true;
}
{
const char *pszAdapterName;
const char *pszAddress;
const char *pszNetworkMask = NULL;
int rc = EXIT_SUCCESS;
switch (argc)
{
case 5:
{
showUsage();
return 1;
}
pszOption = "netmask";
break;
case 4:
{
showUsage();
return 1;
}
pszOption = "remove";
break;
case 3:
break;
default:
/* Fall through */
case 1:
showUsage();
return 1;
}
{
return 2;
}
{
/*
* Before we set IPv6 address we'd like to remove
* all previously assigned addresses except the
* self-assigned one.
*/
else if (!removeAddresses(pszAdapterName))
rc = EXIT_FAILURE;
else
}
else
return rc;
}