Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
877e3e24
Commit
877e3e24
authored
Apr 30, 2021
by
Zebediah Figura
Committed by
Alexandre Julliard
May 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Move name info functions to protocol.c.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ec9f3119
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
81 deletions
+97
-81
protocol.c
dlls/ws2_32/protocol.c
+87
-0
socket.c
dlls/ws2_32/socket.c
+2
-81
ws2_32_private.h
dlls/ws2_32/ws2_32_private.h
+8
-0
No files found.
dlls/ws2_32/protocol.c
View file @
877e3e24
...
...
@@ -854,6 +854,93 @@ void WINAPI FreeAddrInfoExW( ADDRINFOEXW *ai )
}
static
const
int
ws_niflag_map
[][
2
]
=
{
MAP_OPTION
(
NI_NOFQDN
),
MAP_OPTION
(
NI_NUMERICHOST
),
MAP_OPTION
(
NI_NAMEREQD
),
MAP_OPTION
(
NI_NUMERICSERV
),
MAP_OPTION
(
NI_DGRAM
),
};
static
int
convert_niflag_w2u
(
int
winflags
)
{
unsigned
int
i
;
int
unixflags
=
0
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
ws_niflag_map
);
i
++
)
{
if
(
ws_niflag_map
[
i
][
0
]
&
winflags
)
{
unixflags
|=
ws_niflag_map
[
i
][
1
];
winflags
&=
~
ws_niflag_map
[
i
][
0
];
}
}
if
(
winflags
)
FIXME
(
"Unhandled windows NI_xxx flags 0x%x
\n
"
,
winflags
);
return
unixflags
;
}
/***********************************************************************
* getnameinfo (ws2_32.@)
*/
int
WINAPI
WS_getnameinfo
(
const
SOCKADDR
*
addr
,
WS_socklen_t
addr_len
,
char
*
host
,
DWORD
host_len
,
char
*
serv
,
DWORD
serv_len
,
int
flags
)
{
#ifdef HAVE_GETNAMEINFO
int
ret
;
union
generic_unix_sockaddr
uaddr
;
unsigned
int
uaddr_len
;
TRACE
(
"addr %s, addr_len %d, host %p, host_len %u, serv %p, serv_len %d, flags %#x
\n
"
,
debugstr_sockaddr
(
addr
),
addr_len
,
host
,
host_len
,
serv
,
serv_len
,
flags
);
uaddr_len
=
ws_sockaddr_ws2u
(
addr
,
addr_len
,
&
uaddr
);
if
(
!
uaddr_len
)
{
SetLastError
(
WSAEFAULT
);
return
WSA_NOT_ENOUGH_MEMORY
;
}
ret
=
getnameinfo
(
&
uaddr
.
addr
,
uaddr_len
,
host
,
host_len
,
serv
,
serv_len
,
convert_niflag_w2u
(
flags
)
);
return
convert_eai_u2w
(
ret
);
#else
FIXME
(
"getnameinfo() failed, not found during buildtime.
\n
"
);
return
EAI_FAIL
;
#endif
}
/***********************************************************************
* GetNameInfoW (ws2_32.@)
*/
int
WINAPI
GetNameInfoW
(
const
SOCKADDR
*
addr
,
WS_socklen_t
addr_len
,
WCHAR
*
host
,
DWORD
host_len
,
WCHAR
*
serv
,
DWORD
serv_len
,
int
flags
)
{
int
ret
;
char
*
hostA
=
NULL
,
*
servA
=
NULL
;
if
(
host
&&
(
!
(
hostA
=
HeapAlloc
(
GetProcessHeap
(),
0
,
host_len
))))
return
EAI_MEMORY
;
if
(
serv
&&
(
!
(
servA
=
HeapAlloc
(
GetProcessHeap
(),
0
,
serv_len
))))
{
HeapFree
(
GetProcessHeap
(),
0
,
hostA
);
return
EAI_MEMORY
;
}
ret
=
WS_getnameinfo
(
addr
,
addr_len
,
hostA
,
host_len
,
servA
,
serv_len
,
flags
);
if
(
!
ret
)
{
if
(
host
)
MultiByteToWideChar
(
CP_ACP
,
0
,
hostA
,
-
1
,
host
,
host_len
);
if
(
serv
)
MultiByteToWideChar
(
CP_ACP
,
0
,
servA
,
-
1
,
serv
,
serv_len
);
}
HeapFree
(
GetProcessHeap
(),
0
,
hostA
);
HeapFree
(
GetProcessHeap
(),
0
,
servA
);
return
ret
;
}
static
UINT
host_errno_from_unix
(
int
err
)
{
WARN
(
"%d
\n
"
,
err
);
...
...
dlls/ws2_32/socket.c
View file @
877e3e24
...
...
@@ -235,12 +235,6 @@ static unsigned int if_addr_cache_size;
static
SOCKET
*
socket_list
;
static
unsigned
int
socket_list_size
;
union
generic_unix_sockaddr
{
struct
sockaddr
addr
;
char
data
[
128
];
/* should be big enough for all families */
};
const
char
*
debugstr_sockaddr
(
const
struct
WS_sockaddr
*
a
)
{
if
(
!
a
)
return
"(nil)"
;
...
...
@@ -717,15 +711,6 @@ static const int ws_socktype_map[][2] =
{
FROM_PROTOCOL_INFO
,
FROM_PROTOCOL_INFO
},
};
static
const
int
ws_niflag_map
[][
2
]
=
{
MAP_OPTION
(
NI_NOFQDN
),
MAP_OPTION
(
NI_NUMERICHOST
),
MAP_OPTION
(
NI_NAMEREQD
),
MAP_OPTION
(
NI_NUMERICSERV
),
MAP_OPTION
(
NI_DGRAM
),
};
static
const
int
ws_poll_map
[][
2
]
=
{
MAP_OPTION
(
POLLERR
),
...
...
@@ -1633,8 +1618,8 @@ static inline BOOL supported_pf(int pf)
/* Returns the length of the converted address if successful, 0 if it was too
* small to start with or unknown family or invalid address buffer.
*/
static
unsigned
int
ws_sockaddr_ws2u
(
const
struct
WS_sockaddr
*
wsaddr
,
int
wsaddrlen
,
union
generic_unix_sockaddr
*
uaddr
)
unsigned
int
ws_sockaddr_ws2u
(
const
struct
WS_sockaddr
*
wsaddr
,
int
wsaddrlen
,
union
generic_unix_sockaddr
*
uaddr
)
{
unsigned
int
uaddrlen
=
0
;
...
...
@@ -5860,70 +5845,6 @@ struct WS_servent* WINAPI WS_getservbyname(const char *name, const char *proto)
return
retval
;
}
static
int
convert_niflag_w2u
(
int
winflags
)
{
unsigned
int
i
;
int
unixflags
=
0
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
ws_niflag_map
);
i
++
)
if
(
ws_niflag_map
[
i
][
0
]
&
winflags
)
{
unixflags
|=
ws_niflag_map
[
i
][
1
];
winflags
&=
~
ws_niflag_map
[
i
][
0
];
}
if
(
winflags
)
FIXME
(
"Unhandled windows NI_xxx flags 0x%x
\n
"
,
winflags
);
return
unixflags
;
}
int
WINAPI
WS_getnameinfo
(
const
SOCKADDR
*
sa
,
WS_socklen_t
salen
,
PCHAR
host
,
DWORD
hostlen
,
PCHAR
serv
,
DWORD
servlen
,
INT
flags
)
{
#ifdef HAVE_GETNAMEINFO
int
ret
;
union
generic_unix_sockaddr
sa_u
;
unsigned
int
size
;
TRACE
(
"%s %d %p %d %p %d %d
\n
"
,
debugstr_sockaddr
(
sa
),
salen
,
host
,
hostlen
,
serv
,
servlen
,
flags
);
size
=
ws_sockaddr_ws2u
(
sa
,
salen
,
&
sa_u
);
if
(
!
size
)
{
SetLastError
(
WSAEFAULT
);
return
WSA_NOT_ENOUGH_MEMORY
;
}
ret
=
getnameinfo
(
&
sa_u
.
addr
,
size
,
host
,
hostlen
,
serv
,
servlen
,
convert_niflag_w2u
(
flags
));
return
convert_eai_u2w
(
ret
);
#else
FIXME
(
"getnameinfo() failed, not found during buildtime.
\n
"
);
return
EAI_FAIL
;
#endif
}
int
WINAPI
GetNameInfoW
(
const
SOCKADDR
*
sa
,
WS_socklen_t
salen
,
PWCHAR
host
,
DWORD
hostlen
,
PWCHAR
serv
,
DWORD
servlen
,
INT
flags
)
{
int
ret
;
char
*
hostA
=
NULL
,
*
servA
=
NULL
;
if
(
host
&&
(
!
(
hostA
=
HeapAlloc
(
GetProcessHeap
(),
0
,
hostlen
))))
return
EAI_MEMORY
;
if
(
serv
&&
(
!
(
servA
=
HeapAlloc
(
GetProcessHeap
(),
0
,
servlen
))))
{
HeapFree
(
GetProcessHeap
(),
0
,
hostA
);
return
EAI_MEMORY
;
}
ret
=
WS_getnameinfo
(
sa
,
salen
,
hostA
,
hostlen
,
servA
,
servlen
,
flags
);
if
(
!
ret
)
{
if
(
host
)
MultiByteToWideChar
(
CP_ACP
,
0
,
hostA
,
-
1
,
host
,
hostlen
);
if
(
serv
)
MultiByteToWideChar
(
CP_ACP
,
0
,
servA
,
-
1
,
serv
,
servlen
);
}
HeapFree
(
GetProcessHeap
(),
0
,
hostA
);
HeapFree
(
GetProcessHeap
(),
0
,
servA
);
return
ret
;
}
/***********************************************************************
* getservbyport (WS2_32.56)
*/
...
...
dlls/ws2_32/ws2_32_private.h
View file @
877e3e24
...
...
@@ -161,11 +161,19 @@
static
const
char
magic_loopback_addr
[]
=
{
127
,
12
,
34
,
56
};
union
generic_unix_sockaddr
{
struct
sockaddr
addr
;
char
data
[
128
];
/* should be big enough for all families */
};
int
convert_eai_u2w
(
int
ret
)
DECLSPEC_HIDDEN
;
int
convert_socktype_u2w
(
int
type
)
DECLSPEC_HIDDEN
;
int
convert_socktype_w2u
(
int
type
)
DECLSPEC_HIDDEN
;
int
ws_sockaddr_u2ws
(
const
struct
sockaddr
*
unix_addr
,
struct
WS_sockaddr
*
win_addr
,
int
*
win_addr_len
)
DECLSPEC_HIDDEN
;
unsigned
int
ws_sockaddr_ws2u
(
const
struct
WS_sockaddr
*
win_addr
,
int
win_addr_len
,
union
generic_unix_sockaddr
*
unix_addr
)
DECLSPEC_HIDDEN
;
const
char
*
debugstr_sockaddr
(
const
struct
WS_sockaddr
*
addr
)
DECLSPEC_HIDDEN
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment