[ND] reinstate '-i' to install 'default' ND service provider IBAL; reinstate '-r...
authorstansmith <stansmith@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 16 Jul 2009 22:53:40 +0000 (22:53 +0000)
committerstansmith <stansmith@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 16 Jul 2009 22:53:40 +0000 (22:53 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2304 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

tools/ndinstall/user/installsp.c

index 315fe6e..c62ef2a 100644 (file)
 #define PFL_NETWORKDIRECT_PROVIDER          0x00000010\r
 #endif\r
 \r
-/* Initialize the LSP's provider path for Infiband Service Provider dll */\r
+/* Initialize the LSP's provider path for Infiniband Service Provider dll */\r
 #define IBAL_INDEX                     0\r
 #define IBAL_DEBUG_INDEX       1\r
 #define WV_INDEX                       2\r
 #define WV_DEBUG_INDEX         3\r
 #define MAX_INDEX                      4\r
 \r
-int index;\r
+#define DEFAULT_PROVIDER_INDEX IBAL_INDEX\r
+\r
+static int g_index=DEFAULT_PROVIDER_INDEX;\r
 \r
 static const char * const provider_name[MAX_INDEX] = {\r
        "IBAL", "IBAL (debug)", "WinVerbs", "WinVerbs (debug)"\r
@@ -97,14 +99,26 @@ static GUID provider_guid[MAX_INDEX] = {
 static void\r
 show_usage (char *progname)\r
 {\r
-       printf("usage: %s\n", progname);\r
-       printf("\tRemove, install, and list OFA NetworkDirect providers\n\n");\r
-       printf("\t[-[i|r] provider_name]  Install/remove the specified provider\n");\r
-       printf("\t[-d]                    Install/remove debug version of provider\n");\r
-       printf("\t[-l]                    list OFA ND providers\n");\r
-       printf("\tprovider_name must be one of the following:\n");\r
+       char drv[_MAX_DRIVE];\r
+       char dir[_MAX_DIR];\r
+       char fname[_MAX_FNAME];\r
+       char ext[_MAX_EXT];\r
+\r
+       _splitpath(progname,drv,dir,fname,ext); // sad basename() equivalent.\r
+\r
+       printf("usage: %s%s\n",fname,ext);\r
+       printf("\tRemove, install and list OFA NetworkDirect providers\n\n");\r
+       printf("\t[-[i|r] [provider]] Install/remove the specified/default"\r
+                       " provider\n");\r
+       printf("\t[-d]                Install/remove debug version of provider\n");\r
+       printf("\t[-l]                list OFA ND providers\n");\r
+       printf("\t[-q]                Suppress default listing of providers\n");\r
+       printf("\t[-h]                This text\n");\r
+       printf("\tprovider must be one of the following names:\n");\r
        printf("\t\tibal\n");\r
        printf("\t\twinverbs\n");\r
+       printf("\t\t<blank> use the default ND provider '%s'\n",\r
+               provider_name[DEFAULT_PROVIDER_INDEX]);\r
 }\r
 \r
 \r
@@ -179,11 +193,11 @@ static int install_provider(void)
        provider.dwServiceFlags3 = 0;   /* Reserved */\r
        provider.dwServiceFlags4 = 0;   /* Reserved */\r
        provider.dwProviderFlags = PFL_HIDDEN | PFL_NETWORKDIRECT_PROVIDER;\r
-       provider.ProviderId = provider_guid[index];\r
+       provider.ProviderId = provider_guid[g_index];\r
        provider.dwCatalogEntryId = 0;\r
        provider.ProtocolChain.ChainLen = 1;    /* Base Protocol Service Provider */\r
        provider.iVersion = 1;\r
-       if (index == IBAL_INDEX || index == IBAL_DEBUG_INDEX) {\r
+       if (g_index == IBAL_INDEX || g_index == IBAL_DEBUG_INDEX) {\r
                provider.iAddressFamily = AF_INET;\r
                provider.iMaxSockAddr = sizeof(SOCKADDR_IN);\r
        } else {\r
@@ -198,11 +212,11 @@ static int install_provider(void)
        provider.iSecurityScheme = SECURITY_PROTOCOL_NONE;\r
        provider.dwMessageSize = 0xFFFFFFFF; /* IB supports 32-bit lengths for data transfers on RC */\r
        provider.dwProviderReserved = 0;\r
-       wcscpy( provider.szProtocol, provider_desc[index] );\r
+       wcscpy( provider.szProtocol, provider_desc[g_index] );\r
 \r
-       printf("\nInstalling %s provider: ", provider_name[index]);\r
+       printf("\nInstalling %s provider: ", provider_name[g_index]);\r
        rc = WSCInstallProvider(\r
-               &provider_guid[index], provider_path[index], &provider, 1, &err_no );\r
+               &provider_guid[g_index], provider_path[g_index], &provider, 1, &err_no );\r
        if( rc == SOCKET_ERROR )\r
        {\r
                if( err_no == WSANO_RECOVERY )\r
@@ -226,8 +240,8 @@ static int remove_provider(void)
        int rc=0, err_no, rc1;\r
 \r
        /* Remove from the catalog */\r
-       printf("\nRemoving %s provider: ", provider_name[index]);\r
-       rc1 = WSCDeinstallProvider(&provider_guid[index], &err_no);\r
+       printf("\nRemoving %s provider: ", provider_name[g_index]);\r
+       rc1 = WSCDeinstallProvider(&provider_guid[g_index], &err_no);\r
        if (rc1 == SOCKET_ERROR) {\r
                printf ("WSCDeinstallProvider failed: %d\n", err_no);\r
                rc1 = err_no;\r
@@ -238,8 +252,8 @@ static int remove_provider(void)
 \r
 #ifdef _WIN64\r
        /* Remove from the 32-bit catalog too! */\r
-       printf("Removing 32-bit %s provider: ", provider_name[index]);\r
-       rc = WSCDeinstallProvider32(&provider_guid[index], &err_no);\r
+       printf("Removing 32-bit %s provider: ", provider_name[g_index]);\r
+       rc = WSCDeinstallProvider32(&provider_guid[g_index], &err_no);\r
        if (rc == SOCKET_ERROR) {\r
                printf ("WSCDeinstallProvider32 failed: %d\n", err_no);\r
                rc = err_no;\r
@@ -257,9 +271,12 @@ static int get_prov_index(char *name)
 {\r
        int i;\r
 \r
+       if ( !name )\r
+               return 0; /* assumes global 'g_index' set to default provider index. */\r
+\r
        for (i = 0; i < MAX_INDEX; i++) {\r
                if (!_stricmp(provider_name[i], name)) {\r
-                       index = i;\r
+                       g_index = i;\r
                        return 0;\r
                }\r
        }\r
@@ -269,12 +286,14 @@ static int get_prov_index(char *name)
 int __cdecl main (int argc, char *argv[])\r
 {\r
        int ret=0, op;\r
-       int install = 0, remove = 0, debug = 0;\r
+       int install = 0, remove = 0, debug = 0, quiet = 0;\r
        WSADATA wsd;\r
        char *prov;\r
 \r
-       while ((op = getopt(argc, argv, "i:r:dl")) != -1) {\r
+       while ((op = getopt(argc, argv, "hi::r::dlq")) != -1) {\r
                switch (op) {\r
+               case 'h':\r
+                               goto usage;\r
                case 'i':\r
                        if (install || remove || get_prov_index(optarg)) {\r
                                goto usage;\r
@@ -291,13 +310,17 @@ int __cdecl main (int argc, char *argv[])
                        debug = 1;\r
                        break;\r
                case 'l':\r
+                       quiet = 0;\r
+                       break;\r
+               case 'q':\r
+                       quiet = 1;\r
                        break;\r
                default:\r
                        goto usage;\r
                }\r
        }\r
 \r
-       index += debug;\r
+       g_index += debug;\r
 \r
        if (WSAStartup (MAKEWORD (2, 2), &wsd) != 0) {\r
                printf ("InstallSP: Unable to load Winsock: %d\n", GetLastError ());\r
@@ -317,7 +340,8 @@ int __cdecl main (int argc, char *argv[])
                ret = remove_provider();\r
        }\r
 \r
-       print_providers();\r
+       if (quiet == 0)\r
+               print_providers();\r
 \r
 exit:\r
        WSACleanup();\r