ReactOS  0.4.13-dev-247-g0f29b3f
winsock.c File Reference
#include "precomp.h"
#include <winnls.h>
#include <nsp_dns.h>
Include dependency graph for winsock.c:

Go to the source code of this file.

Functions

BOOL WINAPI WSAttemptAutodialAddr (IN CONST SOCKADDR FAR *Name, IN INT NameLength)
 
BOOL WINAPI WSAttemptAutodialName (IN CONST LPWSAQUERYSETW Restrictions)
 
VOID WINAPI WSNoteSuccessfulHostentLookup (IN CONST CHAR FAR *Name, IN CONST ULONG Address)
 

Function Documentation

◆ WSAttemptAutodialAddr()

BOOL WINAPI WSAttemptAutodialAddr ( IN CONST SOCKADDR FAR Name,
IN INT  NameLength 
)

Definition at line 20 of file winsock.c.

22 {
24  PSOCKADDR_NB NetBios = (PSOCKADDR_NB)Name;
25  AUTODIAL_ADDR AutodialAddress;
26 
27  /* Check the family type */
28  switch (Name->sa_family)
29  {
30  case AF_INET:
31  /* Normal IPv4, set the Autodial Address Data */
32  AutodialAddress.Family = AutoDialIp;
33  AutodialAddress.Ip4Address = Ip->sin_addr;
34  break;
35 
36  case AF_NETBIOS:
37  /* NetBIOS, set the Autodial Address Data*/
38  AutodialAddress.Family = AutoDialNetBios;
39  RtlCopyMemory(&AutodialAddress.NetBiosAddress,
40  NetBios->snb_name,
42  break;
43 
44  default:
45  /* Unsupported family type */
46  return FALSE;
47  }
48 
49  /* Call the public routine */
50  return AcsHlpAttemptConnection(&AutodialAddress);
51 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
IN_ADDR Ip4Address
Definition: precomp.h:58
#define AF_NETBIOS
Definition: winsock.h:363
BOOLEAN WINAPI AcsHlpAttemptConnection(IN PAUTODIAL_ADDR ConnectionAddress)
Definition: autodial.c:89
struct sockaddr_nb * PSOCKADDR_NB
AUTODIAL_FAMILY Family
Definition: precomp.h:55
#define NETBIOS_NAME_LENGTH
Definition: wsnetbs.h:4
struct in_addr sin_addr
Definition: winsock.h:512
struct sockaddr_in * PSOCKADDR_IN
Definition: winsock.h:488
#define AF_INET
Definition: tcpip.h:117
CHAR NetBiosAddress[NETBIOS_NAME_LENGTH]
Definition: precomp.h:60
char snb_name[NETBIOS_NAME_LENGTH]
Definition: wsnetbs.h:14

Referenced by connect().

◆ WSAttemptAutodialName()

BOOL WINAPI WSAttemptAutodialName ( IN CONST LPWSAQUERYSETW  Restrictions)

Definition at line 58 of file winsock.c.

59 {
60  AUTODIAL_ADDR AutodialAddress;
61  CHAR AnsiIp[17];
62  LPGUID Guid = Restrictions->lpServiceClassId;
63 
64  /* Make sure we actually have a name */
65  if (!Restrictions->lpszServiceInstanceName) return FALSE;
66 
67  /* Check if this is the Hostname GUID */
68  if (!memcmp(Guid, &HostnameGuid, sizeof(GUID)))
69  {
70  /* It is. Set up the Autodial Address Data */
71  AutodialAddress.Family = AutoDialIpHost;
73  0,
74  Restrictions->lpszServiceInstanceName,
75  -1,
76  AutodialAddress.HostName,
78  0,
79  0);
80 
81  /* Call the public routine */
82  return AcsHlpAttemptConnection(&AutodialAddress);
83  }
84  else if (!memcmp(Guid, &AddressGuid, sizeof(GUID)))
85  {
86  /* It's actually the IP String GUID */
87  AutodialAddress.Family = AutoDialIp;
88 
89  /* Convert the IP String to ANSI and then convert it to IP */
91  0,
92  Restrictions->lpszServiceInstanceName,
93  -1,
94  AnsiIp,
95  sizeof(AnsiIp) - 1,
96  0,
97  0);
98  _strlwr(AnsiIp);
99  AutodialAddress.Ip4Address.S_un.S_addr = inet_addr(AnsiIp);
100 
101  /* Make sure the IP is valid */
102  if (AutodialAddress.Ip4Address.S_un.S_addr == -1) return FALSE;
103 
104  /* Call the public routine */
105  return AcsHlpAttemptConnection(&AutodialAddress);
106  }
107  else
108  {
109  /* Unknown GUID type */
110  return FALSE;
111  }
112 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define inet_addr(cp)
Definition: inet.h:98
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
char CHAR
Definition: xmlstorage.h:175
IN_ADDR Ip4Address
Definition: precomp.h:58
BOOLEAN WINAPI AcsHlpAttemptConnection(IN PAUTODIAL_ADDR ConnectionAddress)
Definition: autodial.c:89
CHAR HostName[INTERNET_MAX_PATH_LENGTH]
Definition: precomp.h:61
static GUID * Guid
Definition: apphelp.c:93
const GUID DECLSPEC_SELECTANY AddressGuid
Definition: nsp_dns.h:18
AUTODIAL_FAMILY Family
Definition: precomp.h:55
u_long S_addr
Definition: tcpip.h:131
union in_addr::@981 S_un
#define INTERNET_MAX_PATH_LENGTH
Definition: wininet.h:49
_CRTIMP char *__cdecl _strlwr(_Inout_z_ char *_String)
const GUID DECLSPEC_SELECTANY HostnameGuid
Definition: nsp_dns.h:17

Referenced by WsNqLookupServiceNext().

◆ WSNoteSuccessfulHostentLookup()

VOID WINAPI WSNoteSuccessfulHostentLookup ( IN CONST CHAR FAR Name,
IN CONST ULONG  Address 
)

Definition at line 119 of file winsock.c.

121 {
122  AUTODIAL_ADDR AutodialAddress;
123  AUTODIAL_CONN AutodialConnection;
124 
125  /* Make sure there actually is a name */
126  if (!(Name) || !strlen(Name)) return;
127 
128  /* Setup the Address */
129  AutodialAddress.Family = AutoDialIpHost;
130  strcpy(AutodialAddress.HostName, Name);
131 
132  /* Setup the new connection */
133  AutodialConnection.Family = ConnectionIp;
134  AutodialConnection.Ip4Address = Address;
135  AcsHlpNoteNewConnection(&AutodialAddress, &AutodialConnection);
136 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
ULONG Ip4Address
Definition: precomp.h:71
CHAR HostName[INTERNET_MAX_PATH_LENGTH]
Definition: precomp.h:61
static WCHAR Address[46]
Definition: ping.c:68
BOOLEAN WINAPI AcsHlpNoteNewConnection(IN PAUTODIAL_ADDR ConnectionAddress, IN PAUTODIAL_CONN Connection)
Definition: autodial.c:108
AUTODIAL_FAMILY Family
Definition: precomp.h:55
CONNECTION_FAMILY Family
Definition: precomp.h:67
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by gethostbyname().