winverbs: map WSA error codes to winverbs status values
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 30 Sep 2009 22:37:14 +0000 (22:37 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 30 Sep 2009 22:37:14 +0000 (22:37 +0000)
Intel MPI bases decisions on the correct status value being returned and mapped correctly through uDAPL.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2482 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/winverbs/user/wv_base.h
core/winverbs/user/wv_ep.cpp
core/winverbs/user/wv_main.cpp

index 592fc18..f37cf96 100644 (file)
@@ -40,6 +40,7 @@
 #include <iba\ib_uvp.h>\r
 \r
 HRESULT WvConvertIbStatus(ib_api_status_t status);\r
+HRESULT WvConvertWSAStatus(int status);\r
 HRESULT WvGetUserVerbs(HMODULE hLib, uvp_interface_t *pVerbs);\r
 \r
 \r
@@ -82,4 +83,4 @@ protected:
        }\r
 #endif (_WIN64)\r
 \r
-#endif // _WV_BASE_H_
\ No newline at end of file
+#endif // _WV_BASE_H_\r
index 31a3dfe..28d2f7d 100644 (file)
@@ -192,7 +192,7 @@ BindAddress(SOCKADDR* pAddress)
 \r
        m_Socket = socket(pAddress->sa_family, SOCK_STREAM, IPPROTO_TCP);\r
        if (m_Socket == INVALID_SOCKET) {\r
-               return WSAGetLastError();\r
+               return WvConvertWSAStatus(WSAGetLastError());\r
        }\r
 \r
        hr = bind(m_Socket, pAddress, bytes);\r
@@ -216,7 +216,7 @@ BindAddress(SOCKADDR* pAddress)
        return WV_SUCCESS;\r
 \r
 get_err:\r
-       hr = WSAGetLastError();\r
+       hr = WvConvertWSAStatus(WSAGetLastError());\r
 err:\r
        closesocket(m_Socket);\r
        m_Socket = INVALID_SOCKET;\r
index 361d04b..32d1aae 100644 (file)
@@ -131,3 +131,22 @@ HRESULT WvConvertIbStatus(ib_api_status_t status)
        default:                                                return WV_UNKNOWN_ERROR;\r
        }\r
 }\r
+\r
+HRESULT WvConvertWSAStatus(int status)\r
+{\r
+       switch (status) {\r
+       case 0:                                                 return WV_SUCCESS;\r
+       case WSAEADDRINUSE:                             return WV_ADDRESS_ALREADY_EXISTS;\r
+       case WSAEADDRNOTAVAIL:                  return WV_INVALID_ADDRESS;\r
+       case WSAENETDOWN:                               return WV_HOST_UNREACHABLE;\r
+       case WSAENETUNREACH:                    return WV_HOST_UNREACHABLE;\r
+       case WSAECONNABORTED:                   return WV_CONNECTION_ABORTED;\r
+       case WSAEISCONN:                                return WV_CONNECTION_ACTIVE;\r
+       case WSAENOTCONN:                               return WV_CONNECTION_INVALID;\r
+       case WSAETIMEDOUT:                              return WV_IO_TIMEOUT;\r
+       case WSAECONNREFUSED:                   return WV_CONNECTION_REFUSED;\r
+       case WSAEHOSTUNREACH:                   return WV_HOST_UNREACHABLE;\r
+       case WSAEACCES:                                 return WV_ADDRESS_ALREADY_EXISTS;\r
+       default:                                                return WV_UNKNOWN_ERROR;\r
+       }\r
+}
\ No newline at end of file