VirtualBox

儲存庫 vbox 的更動 17855


忽略:
時間撮記:
2009-3-13 下午06:28:26 (16 年 以前)
作者:
vboxsync
訊息:

Linux ip config fixes

位置:
trunk/src/apps
檔案:
修改 2 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/apps/Makefile.kmk

    r17826 r17855  
    3333 endif
    3434endif
    35 if1of ($(KBUILD_TARGET),darwin solaris)
     35if1of ($(KBUILD_TARGET),darwin solaris linux)
    3636 ifneq ($(wildcard $(PATH_SUB_CURRENT)/adpctl),)
    3737  include $(PATH_SUB_CURRENT)/adpctl/Makefile.kmk
  • trunk/src/apps/adpctl/VBoxNetAdpCtl.cpp

    r17851 r17855  
    3434#define VBOXADPCTL_IFCONFIG_PATH "/sbin/ifconfig"
    3535
     36#ifdef RT_OS_LINUX
     37#define VBOXADPCTL_DEL_CMD "del"
     38#else
     39#define VBOXADPCTL_DEL_CMD "delete"
     40#endif
     41
    3642static void showUsage(void)
    3743{
     
    4248                           const char *pcszArg2 = NULL,
    4349                           const char *pcszArg3 = NULL,
    44                            const char *pcszArg4 = NULL)
     50                           const char *pcszArg4 = NULL,
     51                           const char *pcszArg5 = NULL)
    4552{
    4653    const char * const argv[] =
     
    5259        pcszArg3, /* ['netmask'] */
    5360        pcszArg4, /* [network mask] */
     61        pcszArg5, /* [network mask] */
    5462        NULL  /* terminator */
    5563    };
     
    100108        if (!pszWord || strcmp(pszWord, "inet6"))
    101109            continue;
     110#ifdef RT_OS_LINUX
     111        pszWord = strtok(NULL, " ");
     112        /* Skip "addr:". */
     113        if (!pszWord || strcmp(pszWord, "addr:"))
     114            continue;
     115#endif
    102116        pszWord = strtok(NULL, " ");
    103117        /* Skip link-local addresses. */
     
    110124    for (int i = 0; i < cAddrs; i++)
    111125    {
    112         if (executeIfconfig(pszAdapterName, "inet6", aszAddresses[i], "remove") != EXIT_SUCCESS)
     126        if (executeIfconfig(pszAdapterName, "inet6", VBOXADPCTL_DEL_CMD, aszAddresses[i]) != EXIT_SUCCESS)
    113127            return false;
    114128    }
     
    126140    const char *pszOption = NULL;
    127141    int rc = EXIT_SUCCESS;
     142    bool fRemove = false;
    128143
    129144    switch (argc)
     
    148163                return 1;
    149164            }
    150             pszOption = "remove";
     165            fRemove = true;
    151166            pszAdapterName = argv[1];
    152167            pszAddress = argv[2];
     
    170185    }
    171186
    172     if (strchr(pszAddress, ':'))
    173     {
    174         /*
    175          * Before we set IPv6 address we'd like to remove
    176          * all previously assigned addresses except the
    177          * self-assigned one.
    178          */
    179         if (pszOption && !strcmp(pszOption, "remove"))
    180             rc = executeIfconfig(pszAdapterName, "inet6", pszAddress, pszOption);
    181         else if (!removeAddresses(pszAdapterName))
    182             rc = EXIT_FAILURE;
     187    if (fRemove)
     188    {
     189        if (strchr(pszAddress, ':'))
     190            rc = executeIfconfig(pszAdapterName, "inet6", VBOXADPCTL_DEL_CMD, pszAddress);
    183191        else
    184             rc = executeIfconfig(pszAdapterName, "inet6", pszAddress, pszOption, pszNetworkMask);
     192        {
     193#ifdef RT_OS_LINUX
     194            rc = executeIfconfig(pszAdapterName, "0.0.0.0");
     195#else
     196            rc = executeIfconfig(pszAdapterName, "delete", pszAddress);
     197#endif
     198        }
    185199    }
    186200    else
    187         rc = executeIfconfig(pszAdapterName, pszAddress, pszOption, pszNetworkMask);
     201    {
     202        /* We are setting/replacing address. */
     203        if (strchr(pszAddress, ':'))
     204        {
     205            /*
     206             * Before we set IPv6 address we'd like to remove
     207             * all previously assigned addresses except the
     208             * self-assigned one.
     209             */
     210            if (!removeAddresses(pszAdapterName))
     211                rc = EXIT_FAILURE;
     212            else
     213                rc = executeIfconfig(pszAdapterName, "inet6", "add", pszAddress, pszOption, pszNetworkMask);
     214        }
     215        else
     216            rc = executeIfconfig(pszAdapterName, pszAddress, pszOption, pszNetworkMask);
     217    }
    188218    return rc;
    189219}
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette