#include "getopt.h"\r
#include <rdma\winverbs.h>\r
\r
-IWVDevice *dev;\r
+#define WV_TEST_SHOW_ATTRIBUTES 0x00000001\r
+\r
+IWVDevice *dev;\r
+DWORD flags;\r
\r
static void ShowOptions()\r
{\r
cout << "usage: winverb device [options]" << endl;\r
cout << "device options" << endl;\r
cout << "\t" << "-d index index of device to open" << endl;\r
+ cout << "\t" << "-a show device attributes" << endl;\r
cout << "\t" << "-? display this message" << endl;\r
}\r
\r
-static int GetGuid(int index)\r
+static UINT64 GetGuid(int index)\r
{\r
- return 0;\r
+ UINT64 guids[16];\r
+ SIZE_T size;\r
+ HRESULT hr;\r
+\r
+ size = sizeof guids;\r
+ hr = prov->QueryDeviceList(guids, &size);\r
+ if (FAILED(hr)){\r
+ cout << "Error QueryDeviceList: 0x" << hex << hr << endl;\r
+ return 0;\r
+ }\r
+\r
+ return guids[index];\r
}\r
\r
HRESULT OpenDevice(int Index)\r
prov->Release();\r
}\r
\r
+void ShowAttributes(void)\r
+{\r
+ WV_DEVICE_ATTRIBUTES attr;\r
+ HRESULT hr;\r
+\r
+ hr = dev->Query(&attr);\r
+ if (FAILED(hr)) {\r
+ cout << "Error querying for attributes: 0x" << hex << hr << endl;\r
+ return;\r
+ }\r
+\r
+ printf("PhysPortCount : %d\n", attr.PhysPortCount);\r
+}\r
+\r
HRESULT DeviceTest(int argc, char *argv[])\r
{\r
HRESULT hr;\r
int op;\r
int index = 0;\r
\r
- while ((op = getopt(argc, argv, "d:?")) != -1) {\r
+ while ((op = getopt(argc, argv, "d:a?")) != -1) {\r
switch (op) {\r
case 'd':\r
index = atoi(optarg);\r
break;\r
+ case 'a':\r
+ flags |= WV_TEST_SHOW_ATTRIBUTES;\r
+ break;\r
default:\r
ShowOptions();\r
return 1;\r
}\r
\r
hr = OpenDevice(index);\r
- if (SUCCEEDED(hr)) {\r
- ReleaseDevice();\r
+ if (FAILED(hr)) {\r
+ return hr;\r
+ }\r
+\r
+ if ((flags & WV_TEST_SHOW_ATTRIBUTES) != 0) {\r
+ ShowAttributes();\r
}\r
\r
+ ReleaseDevice();\r
return hr;\r
}\r