|
1 // wsp_misc.cpp |
|
2 // |
|
3 // Copyright (c) 2002 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include <e32def.h> |
|
14 #include <winsock2.h> |
|
15 #include "wsp_protocolfamily.h" |
|
16 #include "wsp_panic.h" |
|
17 #include "wsp_log.h" |
|
18 |
|
19 |
|
20 extern "C" |
|
21 { |
|
22 IMPORT_C CProtocolFamilyBase* InstallWinSockPrt(); |
|
23 } |
|
24 |
|
25 EXPORT_C CProtocolFamilyBase* InstallWinSockPrt() |
|
26 { |
|
27 WSP_LOG(User::LeaveIfError(WspLog::Open())); |
|
28 WSP_LOG(WspLog::Write(_L("InstallWinSockPrt"))); |
|
29 return CWinSockProtocolFamily::NewL(); |
|
30 } |
|
31 |
|
32 void Panic(TWspPanic aPanic) |
|
33 { |
|
34 _LIT(KWspPanicCategory, "WinSockPrt"); |
|
35 User::Panic(KWspPanicCategory, aPanic); |
|
36 } |
|
37 |
|
38 TInt MapWinSockError(TInt aWinSockError) |
|
39 { |
|
40 switch (aWinSockError) |
|
41 { |
|
42 case 0: |
|
43 return KErrNone; |
|
44 case WSAEINTR: |
|
45 return KErrCancel; |
|
46 case WSAEBADF: |
|
47 return KErrUnknown; |
|
48 case WSAEACCES: |
|
49 return KErrAccessDenied; |
|
50 case WSAEFAULT: |
|
51 return KErrBadName; |
|
52 case WSAEINVAL: |
|
53 return KErrArgument; |
|
54 case WSAEMFILE: |
|
55 Panic(EWinSockPrtUnexpectedTooManyFilesWinSockError); |
|
56 case WSAEWOULDBLOCK: |
|
57 Panic(EWinSockPrtUnexpectedWouldBlockWinSockError); |
|
58 case WSAEINPROGRESS: |
|
59 Panic(EWinSockPrtUnexpectedInProgressWinSockError); |
|
60 case WSAEALREADY: |
|
61 Panic(EWinSockPrtUnexpectedAlreadyInProgressWinSockError); |
|
62 case WSAENOTSOCK: |
|
63 Panic(EWinSockPrtUnexpectedNotASocketWinSockError); |
|
64 case WSAEDESTADDRREQ: |
|
65 return KErrArgument; |
|
66 case WSAEMSGSIZE: |
|
67 return KErrTooBig; |
|
68 case WSAEPROTOTYPE: |
|
69 return KErrArgument; |
|
70 case WSAENOPROTOOPT: |
|
71 return KErrArgument; |
|
72 case WSAEPROTONOSUPPORT: |
|
73 return KErrNotSupported; |
|
74 case WSAESOCKTNOSUPPORT: |
|
75 return KErrNotSupported; |
|
76 case WSAEOPNOTSUPP: |
|
77 return KErrNotSupported; |
|
78 case WSAEPFNOSUPPORT: |
|
79 return KErrNotSupported; |
|
80 case WSAEAFNOSUPPORT: |
|
81 return KErrNotSupported; |
|
82 case WSAEADDRINUSE: |
|
83 return KErrInUse; |
|
84 case WSAEADDRNOTAVAIL: |
|
85 return KErrArgument; |
|
86 case WSAENETDOWN: |
|
87 return KErrDisconnected; |
|
88 case WSAENETUNREACH: |
|
89 return KErrGeneral; |
|
90 case WSAENETRESET: |
|
91 return KErrDisconnected; |
|
92 case WSAECONNABORTED: |
|
93 return KErrCouldNotConnect; |
|
94 case WSAECONNRESET: |
|
95 return KErrDisconnected; |
|
96 case WSAENOBUFS: |
|
97 return KErrNoMemory; |
|
98 case WSAEISCONN: |
|
99 return KErrAlreadyExists; |
|
100 case WSAENOTCONN: |
|
101 return KErrDisconnected; |
|
102 case WSAESHUTDOWN: |
|
103 return KErrDisconnected; |
|
104 case WSAETOOMANYREFS: |
|
105 return KErrTooBig; |
|
106 case WSAETIMEDOUT: |
|
107 return KErrTimedOut; |
|
108 case WSAECONNREFUSED: |
|
109 return KErrAccessDenied; |
|
110 case WSAELOOP: |
|
111 return KErrUnknown; |
|
112 case WSAENAMETOOLONG: |
|
113 return KErrTooBig; |
|
114 case WSAEHOSTDOWN: |
|
115 return KErrCouldNotConnect; |
|
116 case WSAEHOSTUNREACH: |
|
117 return KErrGeneral; |
|
118 case WSAENOTEMPTY: |
|
119 return KErrUnknown; |
|
120 case WSAEPROCLIM: |
|
121 return KErrTooBig; |
|
122 case WSAEUSERS: |
|
123 return KErrUnknown; |
|
124 case WSAEDQUOT: |
|
125 return KErrUnknown; |
|
126 case WSAESTALE: |
|
127 return KErrUnknown; |
|
128 case WSAEREMOTE: |
|
129 return KErrUnknown; |
|
130 case WSASYSNOTREADY: |
|
131 return KErrNotReady; |
|
132 case WSAVERNOTSUPPORTED: |
|
133 return KErrNotSupported; |
|
134 case WSANOTINITIALISED: |
|
135 return KErrGeneral; |
|
136 case WSAEDISCON: |
|
137 Panic(EWinSockPrtUnexpectedShutdownInProgressWinSockError); |
|
138 case WSAENOMORE: |
|
139 return KErrGeneral; |
|
140 case WSAECANCELLED: |
|
141 return KErrCancel; |
|
142 case WSAEINVALIDPROCTABLE: |
|
143 return KErrArgument; |
|
144 case WSAEINVALIDPROVIDER: |
|
145 return KErrArgument; |
|
146 case WSAEPROVIDERFAILEDINIT: |
|
147 return KErrGeneral; |
|
148 case WSASYSCALLFAILURE: |
|
149 return KErrArgument; |
|
150 case WSASERVICE_NOT_FOUND: |
|
151 return KErrNotFound; |
|
152 case WSATYPE_NOT_FOUND: |
|
153 return KErrNotFound; |
|
154 case WSA_E_NO_MORE: |
|
155 return KErrGeneral; |
|
156 case WSA_E_CANCELLED: |
|
157 return KErrCancel; |
|
158 case WSAEREFUSED: |
|
159 return KErrAccessDenied; |
|
160 default: |
|
161 return KErrUnknown; |
|
162 } |
|
163 } |