2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Winsock 2 SPI
4 * FILE: lib/mswsock/lib/init.c
5 * PURPOSE: DLL Initialization
13 /* FUNCTIONS *****************************************************************/
20 WSAttemptAutodialAddr(IN CONST SOCKADDR FAR
*Name
,
23 PSOCKADDR_IN Ip
= (PSOCKADDR_IN
)Name
;
24 PSOCKADDR_NB NetBios
= (PSOCKADDR_NB
)Name
;
25 AUTODIAL_ADDR AutodialAddress
;
27 /* Check the family type */
28 switch (Name
->sa_family
)
31 /* Normal IPv4, set the Autodial Address Data */
32 AutodialAddress
.Family
= AutoDialIp
;
33 AutodialAddress
.Ip4Address
= Ip
->sin_addr
;
37 /* NetBIOS, set the Autodial Address Data*/
38 AutodialAddress
.Family
= AutoDialNetBios
;
39 RtlCopyMemory(&AutodialAddress
.NetBiosAddress
,
45 /* Unsupported family type */
49 /* Call the public routine */
50 return AcsHlpAttemptConnection(&AutodialAddress
);
58 WSAttemptAutodialName(IN CONST LPWSAQUERYSETW Restrictions
)
60 AUTODIAL_ADDR AutodialAddress
;
62 LPGUID Guid
= Restrictions
->lpServiceClassId
;
64 /* Make sure we actually have a name */
65 if (!Restrictions
->lpszServiceInstanceName
) return FALSE
;
67 /* Check if this is the Hostname GUID */
68 if (!memcmp(Guid
, &HostnameGuid
, sizeof(GUID
)))
70 /* It is. Set up the Autodial Address Data */
71 AutodialAddress
.Family
= AutoDialIpHost
;
72 WideCharToMultiByte(CP_ACP
,
74 Restrictions
->lpszServiceInstanceName
,
76 AutodialAddress
.HostName
,
77 INTERNET_MAX_PATH_LENGTH
- 1,
81 /* Call the public routine */
82 return AcsHlpAttemptConnection(&AutodialAddress
);
84 else if (!memcmp(Guid
, &AddressGuid
, sizeof(GUID
)))
86 /* It's actually the IP String GUID */
87 AutodialAddress
.Family
= AutoDialIp
;
89 /* Convert the IP String to ANSI and then convert it to IP */
90 WideCharToMultiByte(CP_ACP
,
92 Restrictions
->lpszServiceInstanceName
,
99 AutodialAddress
.Ip4Address
.S_un
.S_addr
= inet_addr(AnsiIp
);
101 /* Make sure the IP is valid */
102 if (AutodialAddress
.Ip4Address
.S_un
.S_addr
== -1) return FALSE
;
104 /* Call the public routine */
105 return AcsHlpAttemptConnection(&AutodialAddress
);
109 /* Unknown GUID type */
119 WSNoteSuccessfulHostentLookup(IN CONST CHAR FAR
*Name
,
120 IN CONST ULONG Address
)
122 AUTODIAL_ADDR AutodialAddress
;
123 AUTODIAL_CONN AutodialConnection
;
125 /* Make sure there actually is a name */
126 if (!(Name
) || !strlen(Name
)) return;
128 /* Setup the Address */
129 AutodialAddress
.Family
= AutoDialIpHost
;
130 strcpy(AutodialAddress
.HostName
, Name
);
132 /* Setup the new connection */
133 AutodialConnection
.Family
= ConnectionIp
;
134 AutodialConnection
.Ip4Address
= Address
;
135 AcsHlpNoteNewConnection(&AutodialAddress
, &AutodialConnection
);