NetIf-generic.cpp revision b78a2ee0977fced6695499928b445995ecacfbc0
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync * VirtualBox Main - Generic NetIf implementation.
8502773207230763deba3e622495f2099398dcb0vboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync * available from http://www.virtualbox.org. This file is free software;
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync * you can redistribute it and/or modify it under the terms of the GNU
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync * General Public License (GPL) as published by the Free Software
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync * additional information or have any questions.
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsyncstatic int NetIfAdpCtl(const char * pcszIfName, const char *pszAddr, const char *pszOption, const char *pszMask)
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync const char *args[] = { NULL, pcszIfName, pszAddr, pszOption, pszMask, NULL };
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync int rc = RTPathProgram(szAdpCtl, sizeof(szAdpCtl) - sizeof("/" VBOXNETADPCTL_NAME));
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync LogRel(("NetIfAdpCtl: failed to get program path, rc=%Vrc.\n", rc));
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync LogRel(("NetIfAdpCtl: path %s does not exist. Failed to run " VBOXNETADPCTL_NAME " helper.\n",
8502773207230763deba3e622495f2099398dcb0vboxsync rc = RTProcCreate(szAdpCtl, args, RTENV_DEFAULT, 0, &pid);
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync LogRel(("NetIfAdpCtl: failed to create process for %.\n",
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsyncstatic int NetIfAdpCtl(HostNetworkInterface * pIf, const char *pszAddr, const char *pszOption, const char *pszMask)
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync return NetIfAdpCtl(strName, pszAddr, pszOption, pszMask);
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsyncint NetIfEnableStaticIpConfig(VirtualBox * /* vBox */, HostNetworkInterface * pIf, ULONG aOldIp, ULONG aNewIp, ULONG aMask)
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync RTStrPrintf(szNetMask, sizeof(szNetMask), "%d.%d.%d.%d",
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync RTStrPrintf(szAddress, sizeof(szAddress), "%d.%d.%d.%d",
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync return NetIfAdpCtl(pIf, szAddress, pszOption, pszMask);
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsyncint NetIfEnableStaticIpConfigV6(VirtualBox * /* vBox */, HostNetworkInterface * pIf, IN_BSTR aOldIPV6Address, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength)
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync RTStrPrintf(szAddress, sizeof(szAddress), "%ls/%d",
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync return NetIfAdpCtl(pIf, szAddress, "remove", NULL);
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsyncint NetIfEnableDynamicIpConfig(VirtualBox * /* vBox */, HostNetworkInterface * /* pIf */)
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsyncint NetIfCreateHostOnlyNetworkInterface (VirtualBox *pVBox, IHostNetworkInterface **aHostNetworkInterface, IProgress **aProgress)
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync /* create a progress object */
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync HRESULT rc = pVBox->COMGETTER(Host)(host.asOutParam());
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync int rc = RTPathProgram(szAdpCtl, sizeof(szAdpCtl) - sizeof("/" VBOXNETADPCTL_NAME " add"));
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync progress->notifyComplete(E_FAIL, COM_IIDOF(IHostNetworkInterface), HostNetworkInterface::getComponentName(),
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync progress->notifyComplete(E_FAIL, COM_IIDOF(IHostNetworkInterface), HostNetworkInterface::getComponentName(),
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync "Failed to get config info for %s (as reported by '" VBOXNETADPCTL_NAME " add').\n", szBuf);
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync /* create a new uninitialized host interface object */
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync iface->init(IfName, HostNetworkInterfaceType_HostOnly, &Info);
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync progress->notifyComplete(E_FAIL, COM_IIDOF(IHostNetworkInterface), HostNetworkInterface::getComponentName(), "Failed to execute '"VBOXNETADPCTL_NAME " add' (exit status: %d).", rc);
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsyncint NetIfRemoveHostOnlyNetworkInterface (VirtualBox *pVBox, IN_GUID aId, IHostNetworkInterface **aHostNetworkInterface, IProgress **aProgress)
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync /* create a progress object */
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync HRESULT hr = pVBox->COMGETTER(Host)(host.asOutParam());
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsync if (FAILED (host->FindHostNetworkInterfaceById (Guid(aId).toUtf16(), iface.asOutParam())))
cf9045d402be1e8b7344a439eaefe2ca4c2b53d3vboxsync rc = NetIfAdpCtl(Utf8Str(ifname), "remove", NULL, NULL);
cf9045d402be1e8b7344a439eaefe2ca4c2b53d3vboxsync progress->notifyComplete(E_FAIL, COM_IIDOF(IHostNetworkInterface), HostNetworkInterface::getComponentName(), "Failed to execute '"VBOXNETADPCTL_NAME "' (exit status: %d).", rc);
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsyncint NetIfGetConfig(HostNetworkInterface * /* pIf */, NETIFINFO *)
1e7030f54deae0a8aa27817ab26c5d6d6c246541vboxsyncint NetIfDhcpRediscover(VirtualBox * /* pVbox */, HostNetworkInterface * /* pIf */)