winverbs/nd: map completion status to ND values
[mirror/winof/.git] / ulp / netdirect / user / nd_cq.cpp
index 28aabe5..07dabc2 100644 (file)
@@ -116,6 +116,34 @@ Notify(DWORD Type, OVERLAPPED* pOverlapped)
        return NDConvertWVStatus(hr);\r
 }\r
 \r
+STDMETHODIMP_(HRESULT) CNDCompletionQueue::\r
+ConvertStatus(WV_WC_STATUS Status)\r
+{\r
+       switch (Status) {\r
+       case WvWcSuccess:\r
+               return ND_SUCCESS;\r
+       case WvWcFlushed:\r
+               return ND_CANCELED;\r
+       case WvWcLocalLengthError:\r
+               return ND_LOCAL_LENGTH;\r
+       case WvWcRnrRetryError:\r
+       case WvWcTimeoutRetryError:\r
+               return ND_TIMEOUT;\r
+       case WvWcLocalAccessError:\r
+       case WvWcLocalOpError:\r
+       case WvWcLocalProtectionError:\r
+       case WvWcMwBindError:\r
+               return ND_ACCESS_VIOLATION;\r
+       case WvWcRemoteAccessError:\r
+       case WvWcRemoteOpError:\r
+       case WvWcRemoteInvalidRequest:\r
+       case WvWcBadResponse:\r
+               return ND_REMOTE_ERROR;\r
+       default:\r
+               return ND_INTERNAL_ERROR;\r
+       }\r
+}\r
+\r
 STDMETHODIMP_(SIZE_T) CNDCompletionQueue::\r
 GetResults(ND_RESULT* pResults[], SIZE_T nResults)\r
 {\r
@@ -134,7 +162,7 @@ GetResults(ND_RESULT* pResults[], SIZE_T nResults)
                        if (comp[i].Opcode & WvReceive) {\r
                                pResults[total]->BytesTransferred = comp[i].Length;\r
                        }\r
-                       pResults[total++]->Status = comp[i].Status;\r
+                       pResults[total++]->Status = ConvertStatus(comp[i].Status);\r
                }\r
        }\r
        return total;\r