408f28294a667d3b4a55b51235cff31fcc6a4de6
[reactos.git] / reactos / dll / win32 / ws2_32 / misc / stubs.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 DLL
4 * FILE: misc/stubs.c
5 * PURPOSE: Stubs
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * REVISIONS:
8 * CSH 01/09-2000 Created
9 */
10 #include <ws2_32.h>
11 #include <catalog.h>
12 #include <handle.h>
13
14 /*
15 * @implemented
16 */
17 INT
18 EXPORT
19 getpeername(IN SOCKET s,
20 OUT LPSOCKADDR name,
21 IN OUT INT FAR* namelen)
22 {
23 int Error;
24 INT Errno;
25 PCATALOG_ENTRY Provider;
26
27 if (!WSAINITIALIZED)
28 {
29 WSASetLastError(WSANOTINITIALISED);
30 return SOCKET_ERROR;
31 }
32
33 if (!ReferenceProviderByHandle((HANDLE)s, &Provider))
34 {
35 WSASetLastError(WSAENOTSOCK);
36 return SOCKET_ERROR;
37 }
38
39 Error = Provider->ProcTable.lpWSPGetPeerName(s,
40 name,
41 namelen,
42 &Errno);
43
44 DereferenceProviderByPointer(Provider);
45
46 if (Error == SOCKET_ERROR)
47 {
48 WSASetLastError(Errno);
49 }
50
51 return Error;
52 }
53
54
55
56 /*
57 * @implemented
58 */
59 INT
60 EXPORT
61 getsockname(IN SOCKET s,
62 OUT LPSOCKADDR name,
63 IN OUT INT FAR* namelen)
64 {
65 int Error;
66 INT Errno;
67 PCATALOG_ENTRY Provider;
68
69 if (!WSAINITIALIZED)
70 {
71 WSASetLastError(WSANOTINITIALISED);
72 return SOCKET_ERROR;
73 }
74
75 if (!ReferenceProviderByHandle((HANDLE)s,
76 &Provider))
77 {
78 WSASetLastError(WSAENOTSOCK);
79 return SOCKET_ERROR;
80 }
81
82 Error = Provider->ProcTable.lpWSPGetSockName(s,
83 name,
84 namelen,
85 &Errno);
86
87 DereferenceProviderByPointer(Provider);
88
89 if (Error == SOCKET_ERROR)
90 {
91 WSASetLastError(Errno);
92 }
93
94 return Error;
95 }
96
97
98 /*
99 * @implemented
100 */
101 INT
102 EXPORT
103 getsockopt(IN SOCKET s,
104 IN INT level,
105 IN INT optname,
106 OUT CHAR FAR* optval,
107 IN OUT INT FAR* optlen)
108 {
109 PCATALOG_ENTRY Provider;
110 INT Errno;
111 int Error;
112
113 if (!WSAINITIALIZED)
114 {
115 WSASetLastError(WSANOTINITIALISED);
116 return SOCKET_ERROR;
117 }
118
119 if (!ReferenceProviderByHandle((HANDLE)s,
120 &Provider))
121 {
122 WSASetLastError(WSAENOTSOCK);
123 return SOCKET_ERROR;
124 }
125
126 Error = Provider->ProcTable.lpWSPGetSockOpt(s,
127 level,
128 optname,
129 optval,
130 optlen,
131 &Errno);
132
133 DereferenceProviderByPointer(Provider);
134
135 if (Error == SOCKET_ERROR)
136 {
137 WSASetLastError(Errno);
138 }
139
140 return Error;
141 }
142
143
144 /*
145 * @implemented
146 */
147 INT
148 EXPORT __stdcall
149 setsockopt(IN SOCKET s,
150 IN INT level,
151 IN INT optname,
152 IN CONST CHAR FAR* optval,
153 IN INT optlen)
154 {
155 PCATALOG_ENTRY Provider;
156 INT Errno;
157 int Error;
158
159 if (!WSAINITIALIZED)
160 {
161 WSASetLastError(WSANOTINITIALISED);
162 return SOCKET_ERROR;
163 }
164
165 if(IS_INTRESOURCE(optval))
166 {
167 SetLastError(WSAEFAULT);
168 return SOCKET_ERROR;
169 }
170
171 if (!ReferenceProviderByHandle((HANDLE)s, &Provider))
172 {
173 WSASetLastError(WSAENOTSOCK);
174 return SOCKET_ERROR;
175 }
176
177 Error = Provider->ProcTable.lpWSPSetSockOpt(s,
178 level,
179 optname,
180 optval,
181 optlen,
182 &Errno);
183
184 DereferenceProviderByPointer(Provider);
185
186 if (Error == SOCKET_ERROR)
187 {
188 WSASetLastError(Errno);
189 }
190
191 return Error;
192 }
193
194
195 /*
196 * @implemented
197 */
198 INT
199 EXPORT
200 shutdown(IN SOCKET s,
201 IN INT how)
202 {
203 PCATALOG_ENTRY Provider;
204 INT Errno;
205 int Error;
206
207 if (!WSAINITIALIZED)
208 {
209 WSASetLastError(WSANOTINITIALISED);
210 return SOCKET_ERROR;
211 }
212
213 if (!ReferenceProviderByHandle((HANDLE)s, &Provider))
214 {
215 WSASetLastError(WSAENOTSOCK);
216 return SOCKET_ERROR;
217 }
218
219 Error = Provider->ProcTable.lpWSPShutdown(s,
220 how,
221 &Errno);
222
223 DereferenceProviderByPointer(Provider);
224
225 if (Error == SOCKET_ERROR)
226 {
227 WSASetLastError(Errno);
228 }
229
230 return Error;
231 }
232
233
234 /*
235 * @implemented
236 */
237 INT
238 EXPORT
239 WSAAsyncSelect(IN SOCKET s,
240 IN HWND hWnd,
241 IN UINT wMsg,
242 IN LONG lEvent)
243 {
244 PCATALOG_ENTRY Provider;
245 INT Errno;
246 int Error;
247
248 if (!WSAINITIALIZED)
249 {
250 WSASetLastError(WSANOTINITIALISED);
251 return SOCKET_ERROR;
252 }
253
254 if (!ReferenceProviderByHandle((HANDLE)s, &Provider))
255 {
256 WSASetLastError(WSAENOTSOCK);
257 return SOCKET_ERROR;
258 }
259
260 Error = Provider->ProcTable.lpWSPAsyncSelect(s,
261 hWnd,
262 wMsg,
263 lEvent,
264 &Errno);
265
266 DereferenceProviderByPointer(Provider);
267
268 if (Error == SOCKET_ERROR)
269 {
270 WSASetLastError(Errno);
271 }
272
273 return Error;
274 }
275
276
277 /*
278 * @unimplemented
279 */
280 INT
281 EXPORT
282 WSACancelBlockingCall(VOID)
283 {
284 #if 0
285 INT Errno;
286 int Error;
287 PCATALOG_ENTRY Provider;
288
289 if (!WSAINITIALIZED)
290 {
291 WSASetLastError(WSANOTINITIALISED);
292 return SOCKET_ERROR;
293 }
294
295 if (!ReferenceProviderByHandle((HANDLE)s, &Provider))
296 {
297 WSASetLastError(WSAENOTSOCK);
298 return SOCKET_ERROR;
299 }
300
301 Error = Provider->ProcTable.lpWSPCancelBlockingCall(&Errno);
302
303 DereferenceProviderByPointer(Provider);
304
305 if (Error == SOCKET_ERROR)
306 {
307 WSASetLastError(Errno);
308 }
309
310 return Error;
311 #endif
312
313 UNIMPLEMENTED
314
315 WSASetLastError(WSASYSCALLFAILURE);
316 return SOCKET_ERROR;
317 }
318
319
320 /*
321 * @unimplemented
322 */
323 INT
324 EXPORT
325 WSADuplicateSocketA(IN SOCKET s,
326 IN DWORD dwProcessId,
327 OUT LPWSAPROTOCOL_INFOA lpProtocolInfo)
328 {
329 #if 0
330 WSAPROTOCOL_INFOA ProtocolInfoU;
331
332 Error = WSADuplicateSocketW(s,
333 dwProcessId,
334 &ProtocolInfoU);
335
336 if (Error == NO_ERROR)
337 {
338 UnicodeToAnsi(lpProtocolInfo,
339 ProtocolInfoU,
340 sizeof(
341
342 }
343
344 return Error;
345 #endif
346
347 UNIMPLEMENTED
348
349 WSASetLastError(WSASYSCALLFAILURE);
350 return SOCKET_ERROR;
351 }
352
353
354
355 /*
356 * @implemented
357 */
358 INT
359 EXPORT
360 WSADuplicateSocketW(IN SOCKET s,
361 IN DWORD dwProcessId,
362 OUT LPWSAPROTOCOL_INFOW lpProtocolInfo)
363 {
364 INT Errno;
365 int Error;
366 PCATALOG_ENTRY Provider;
367
368 if (!WSAINITIALIZED)
369 {
370 WSASetLastError(WSANOTINITIALISED);
371 return SOCKET_ERROR;
372 }
373
374 if (!ReferenceProviderByHandle((HANDLE)s, &Provider))
375 {
376 WSASetLastError(WSAENOTSOCK);
377 return SOCKET_ERROR;
378 }
379
380 Error = Provider->ProcTable.lpWSPDuplicateSocket(s,
381 dwProcessId,
382 lpProtocolInfo,
383 &Errno);
384 DereferenceProviderByPointer(Provider);
385
386 if (Error == SOCKET_ERROR)
387 {
388 WSASetLastError(Errno);
389 }
390
391 return Error;
392 }
393
394
395 /*
396 * @unimplemented
397 */
398 INT
399 EXPORT
400 WSAEnumProtocolsA(IN LPINT lpiProtocols,
401 OUT LPWSAPROTOCOL_INFOA lpProtocolBuffer,
402 IN OUT LPDWORD lpdwBufferLength)
403 {
404 UNIMPLEMENTED
405
406 WSASetLastError(WSASYSCALLFAILURE);
407 return SOCKET_ERROR;
408 }
409
410
411 /*
412 * @unimplemented
413 */
414 INT
415 EXPORT
416 WSAEnumProtocolsW(IN LPINT lpiProtocols,
417 OUT LPWSAPROTOCOL_INFOW lpProtocolBuffer,
418 IN OUT LPDWORD lpdwBufferLength)
419 {
420 UNIMPLEMENTED
421
422 WSASetLastError(WSASYSCALLFAILURE);
423 return SOCKET_ERROR;
424 }
425
426
427 /*
428 * @implemented
429 */
430 BOOL
431 EXPORT
432 WSAGetOverlappedResult(IN SOCKET s,
433 IN LPWSAOVERLAPPED lpOverlapped,
434 OUT LPDWORD lpcbTransfer,
435 IN BOOL fWait,
436 OUT LPDWORD lpdwFlags)
437 {
438 INT Errno;
439 BOOL Success;
440 PCATALOG_ENTRY Provider;
441
442 if (!WSAINITIALIZED)
443 {
444 WSASetLastError(WSANOTINITIALISED);
445 return SOCKET_ERROR;
446 }
447
448 if (!ReferenceProviderByHandle((HANDLE)s, &Provider))
449 {
450 WSASetLastError(WSAENOTSOCK);
451 return SOCKET_ERROR;
452 }
453
454 Success = Provider->ProcTable.lpWSPGetOverlappedResult(s,
455 lpOverlapped,
456 lpcbTransfer,
457 fWait,
458 lpdwFlags,
459 &Errno);
460 DereferenceProviderByPointer(Provider);
461
462 if (Success == FALSE)
463 {
464 WSASetLastError(Errno);
465 }
466
467 return Success;
468 }
469
470
471 /*
472 * @unimplemented
473 */
474 BOOL
475 EXPORT
476 WSAGetQOSByName(IN SOCKET s,
477 IN OUT LPWSABUF lpQOSName,
478 OUT LPQOS lpQOS)
479 {
480 UNIMPLEMENTED
481
482 WSASetLastError(WSASYSCALLFAILURE);
483 return FALSE;
484 }
485
486
487 /*
488 * @unimplemented
489 */
490 INT
491 EXPORT
492 WSAHtonl(IN SOCKET s,
493 IN ULONG hostLONG,
494 OUT ULONG FAR* lpnetlong)
495 {
496 UNIMPLEMENTED
497
498 WSASetLastError(WSASYSCALLFAILURE);
499 return SOCKET_ERROR;
500 }
501
502
503 /*
504 * @unimplemented
505 */
506 INT
507 EXPORT
508 WSAHtons(IN SOCKET s,
509 IN USHORT hostshort,
510 OUT USHORT FAR* lpnetshort)
511 {
512 PCATALOG_ENTRY provider;
513 if (!WSAINITIALIZED)
514 {
515 WSASetLastError(WSANOTINITIALISED);
516 return SOCKET_ERROR;
517 }
518
519 if (!ReferenceProviderByHandle((HANDLE)s, &provider))
520 {
521 WSASetLastError(WSAENOTSOCK);
522 return SOCKET_ERROR;
523 }
524
525 switch (provider->ProtocolInfo.iNetworkByteOrder)
526 {
527 case BIGENDIAN:
528 *lpnetshort = htons(hostshort);
529 break;
530 case LITTLEENDIAN:
531 #ifdef LE
532 *lpnetshort = hostshort;
533 #else
534 *lpnetshort = (((hostshort & 0xFF00) >> 8) | ((hostshort & 0x00FF) << 8));
535 #endif
536 break;
537 }
538 return 0;
539 }
540
541
542 /*
543 * @unimplemented
544 */
545 BOOL
546 EXPORT
547 WSAIsBlocking(VOID)
548 {
549 UNIMPLEMENTED
550
551 return FALSE;
552 }
553
554
555 /*
556 * @unimplemented
557 */
558 SOCKET
559 EXPORT
560 WSAJoinLeaf(IN SOCKET s,
561 IN CONST struct sockaddr *name,
562 IN INT namelen,
563 IN LPWSABUF lpCallerData,
564 OUT LPWSABUF lpCalleeData,
565 IN LPQOS lpSQOS,
566 IN LPQOS lpGQOS,
567 IN DWORD dwFlags)
568 {
569 UNIMPLEMENTED
570
571 WSASetLastError(WSASYSCALLFAILURE);
572 return INVALID_SOCKET;
573 }
574
575
576 /*
577 * @unimplemented
578 */
579 INT
580 EXPORT
581 WSANtohl(IN SOCKET s,
582 IN ULONG netlong,
583 OUT ULONG FAR* lphostlong)
584 {
585 UNIMPLEMENTED
586
587 WSASetLastError(WSASYSCALLFAILURE);
588 return SOCKET_ERROR;
589 }
590
591
592 /*
593 * @unimplemented
594 */
595 INT
596 EXPORT
597 WSANtohs(IN SOCKET s,
598 IN USHORT netshort,
599 OUT USHORT FAR* lphostshort)
600 {
601 PCATALOG_ENTRY provider;
602 if (!WSAINITIALIZED)
603 {
604 WSASetLastError(WSANOTINITIALISED);
605 return SOCKET_ERROR;
606 }
607
608 if (!ReferenceProviderByHandle((HANDLE)s, &provider))
609 {
610 WSASetLastError(WSAENOTSOCK);
611 return SOCKET_ERROR;
612 }
613
614 switch (provider->ProtocolInfo.iNetworkByteOrder)
615 {
616 case BIGENDIAN:
617 *lphostshort = ntohs(netshort);
618 break;
619 case LITTLEENDIAN:
620 #ifdef LE
621 *lphostshort = netshort;
622 #else
623 *lphostshort = (((netshort & 0xFF00) >> 8) | ((netshort & 0x00FF) << 8));
624 #endif
625 break;
626 }
627 return 0;
628 }
629
630
631 /*
632 * @unimplemented
633 */
634 FARPROC
635 EXPORT
636 WSASetBlockingHook(IN FARPROC lpBlockFunc)
637 {
638 UNIMPLEMENTED
639
640 return (FARPROC)0;
641 }
642
643
644 /*
645 * @unimplemented
646 */
647 INT
648 EXPORT
649 WSAUnhookBlockingHook(VOID)
650 {
651 UNIMPLEMENTED
652
653 return 0;
654 }
655
656
657 /*
658 * @unimplemented
659 */
660 INT
661 EXPORT
662 WSAProviderConfigChange(IN OUT LPHANDLE lpNotificationHandle,
663 IN LPWSAOVERLAPPED lpOverlapped,
664 IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
665 {
666 UNIMPLEMENTED
667
668 WSASetLastError(WSASYSCALLFAILURE);
669 return SOCKET_ERROR;
670 }
671
672
673 /*
674 * @unimplemented
675 */
676 INT
677 EXPORT
678 WSACancelAsyncRequest(IN HANDLE hAsyncTaskHandle)
679 {
680 UNIMPLEMENTED
681
682 WSASetLastError(WSASYSCALLFAILURE);
683 return SOCKET_ERROR;
684 }
685
686 /* WinSock Service Provider support functions */
687
688 /*
689 * @unimplemented
690 */
691 INT
692 EXPORT
693 WPUCompleteOverlappedRequest(IN SOCKET s,
694 IN LPWSAOVERLAPPED lpOverlapped,
695 IN DWORD dwError,
696 IN DWORD cbTransferred,
697 OUT LPINT lpErrno)
698 {
699 UNIMPLEMENTED
700
701 WSASetLastError(WSASYSCALLFAILURE);
702 return SOCKET_ERROR;
703 }
704
705
706 /*
707 * @unimplemented
708 */
709 INT
710 EXPORT
711 WSCDeinstallProvider(IN LPGUID lpProviderId,
712 OUT LPINT lpErrno)
713 {
714 UNIMPLEMENTED
715
716 WSASetLastError(WSASYSCALLFAILURE);
717 return SOCKET_ERROR;
718 }
719
720
721 /*
722 * @unimplemented
723 */
724 INT
725 EXPORT
726 WSCEnumProtocols(IN LPINT lpiProtocols,
727 OUT LPWSAPROTOCOL_INFOW lpProtocolBuffer,
728 IN OUT LPDWORD lpdwBufferLength,
729 OUT LPINT lpErrno)
730 {
731 UNIMPLEMENTED
732
733 WSASetLastError(WSASYSCALLFAILURE);
734 return SOCKET_ERROR;
735 }
736
737
738 /*
739 * @unimplemented
740 */
741 INT
742 EXPORT
743 WSCGetProviderPath(IN LPGUID lpProviderId,
744 OUT LPWSTR lpszProviderDllPath,
745 IN OUT LPINT lpProviderDllPathLen,
746 OUT LPINT lpErrno)
747 {
748 UNIMPLEMENTED
749
750 WSASetLastError(WSASYSCALLFAILURE);
751 return SOCKET_ERROR;
752 }
753
754
755 /*
756 * @unimplemented
757 */
758 INT
759 EXPORT
760 WSCInstallProvider(IN LPGUID lpProviderId,
761 IN CONST WCHAR* lpszProviderDllPath,
762 IN CONST LPWSAPROTOCOL_INFOW lpProtocolInfoList,
763 IN DWORD dwNumberOfEntries,
764 OUT LPINT lpErrno)
765 {
766 UNIMPLEMENTED
767
768 WSASetLastError(WSASYSCALLFAILURE);
769 return SOCKET_ERROR;
770 }
771
772
773 /*
774 * @unimplemented
775 */
776 INT
777 EXPORT
778 WSCEnableNSProvider(IN LPGUID lpProviderId,
779 IN BOOL fEnable)
780 {
781 UNIMPLEMENTED
782
783 WSASetLastError(WSASYSCALLFAILURE);
784 return SOCKET_ERROR;
785 }
786
787
788 /*
789 * @unimplemented
790 */
791 INT
792 EXPORT
793 WSCInstallNameSpace(IN LPWSTR lpszIdentifier,
794 IN LPWSTR lpszPathName,
795 IN DWORD dwNameSpace,
796 IN DWORD dwVersion,
797 IN LPGUID lpProviderId)
798 {
799 UNIMPLEMENTED
800
801 WSASetLastError(WSASYSCALLFAILURE);
802 return SOCKET_ERROR;
803 }
804
805
806 /*
807 * @unimplemented
808 */
809 INT
810 EXPORT
811 WSCUnInstallNameSpace(IN LPGUID lpProviderId)
812 {
813 UNIMPLEMENTED
814
815 WSASetLastError(WSASYSCALLFAILURE);
816 return SOCKET_ERROR;
817 }
818
819
820 /*
821 * @unimplemented
822 */
823 INT
824 EXPORT
825 WSCWriteProviderOrder(IN LPDWORD lpwdCatalogEntryId,
826 IN DWORD dwNumberOfEntries)
827 {
828 UNIMPLEMENTED
829
830 return WSASYSCALLFAILURE;
831 }
832
833 /*
834 * @unimplemented
835 */
836 INT
837 EXPORT
838 WSANSPIoctl(HANDLE hLookup,
839 DWORD dwControlCode,
840 LPVOID lpvInBuffer,
841 DWORD cbInBuffer,
842 LPVOID lpvOutBuffer,
843 DWORD cbOutBuffer,
844 LPDWORD lpcbBytesReturned,
845 LPWSACOMPLETION lpCompletion)
846 {
847 UNIMPLEMENTED
848
849 WSASetLastError(WSASYSCALLFAILURE);
850 return SOCKET_ERROR;
851 }
852
853
854 /*
855 * @unimplemented
856 */
857 INT
858 EXPORT
859 WSCUpdateProvider(LPGUID lpProviderId,
860 const WCHAR FAR * lpszProviderDllPath,
861 const LPWSAPROTOCOL_INFOW lpProtocolInfoList,
862 DWORD dwNumberOfEntries,
863 LPINT lpErrno)
864 {
865 UNIMPLEMENTED
866
867 WSASetLastError(WSASYSCALLFAILURE);
868 return SOCKET_ERROR;
869 }
870
871 /*
872 * @unimplemented
873 */
874 INT
875 EXPORT
876 WSCWriteNameSpaceOrder(LPGUID lpProviderId,
877 DWORD dwNumberOfEntries)
878 {
879 UNIMPLEMENTED
880
881 return WSASYSCALLFAILURE;
882 }
883
884 /*
885 * @unimplemented
886 */
887 INT
888 EXPORT
889 getnameinfo(const struct sockaddr FAR * sa,
890 socklen_t salen,
891 char FAR * host,
892 DWORD hostlen,
893 char FAR * serv,
894 DWORD servlen,
895 INT flags)
896 {
897 UNIMPLEMENTED
898
899 WSASetLastError(WSASYSCALLFAILURE);
900 return SOCKET_ERROR;
901 }
902
903 /*
904 * @unimplemented
905 */
906 VOID EXPORT WEP()
907 {
908 UNIMPLEMENTED
909 }
910
911 /*
912 * @unimplemented
913 */
914 BOOL EXPORT WSApSetPostRoutine(PVOID Routine)
915 {
916 UNIMPLEMENTED
917
918 return FALSE;
919 }
920
921 /*
922 * @unimplemented
923 */
924 INT
925 EXPORT
926 GetAddrInfoW(IN PCWSTR pszNodeName,
927 IN PCWSTR pszServiceName,
928 IN const ADDRINFOW *ptHints,
929 OUT PADDRINFOW *pptResult)
930 {
931 UNIMPLEMENTED
932
933 WSASetLastError(EAI_FAIL);
934 return EAI_FAIL;
935 }
936
937
938 /* EOF */