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
5d9fe036
Commit
5d9fe036
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 protocol lookup functions to protocol.c.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
877e3e24
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
144 additions
and
103 deletions
+144
-103
protocol.c
dlls/ws2_32/protocol.c
+144
-0
socket.c
dlls/ws2_32/socket.c
+0
-103
No files found.
dlls/ws2_32/protocol.c
View file @
5d9fe036
...
...
@@ -1388,3 +1388,147 @@ int WINAPI GetHostNameW( WCHAR *name, int namelen )
MultiByteToWideChar
(
CP_ACP
,
0
,
buf
,
-
1
,
name
,
namelen
);
return
0
;
}
static
int
list_size
(
char
**
list
,
int
item_size
)
{
int
i
,
size
=
0
;
if
(
list
)
{
for
(
i
=
0
;
list
[
i
];
i
++
)
size
+=
(
item_size
?
item_size
:
strlen
(
list
[
i
])
+
1
);
size
+=
(
i
+
1
)
*
sizeof
(
char
*
);
}
return
size
;
}
static
int
list_dup
(
char
**
src
,
char
**
dst
,
int
item_size
)
{
char
*
p
;
int
i
;
for
(
i
=
0
;
src
[
i
];
i
++
)
;
p
=
(
char
*
)(
dst
+
i
+
1
);
for
(
i
=
0
;
src
[
i
];
i
++
)
{
int
count
=
item_size
?
item_size
:
strlen
(
src
[
i
])
+
1
;
memcpy
(
p
,
src
[
i
],
count
);
dst
[
i
]
=
p
;
p
+=
count
;
}
dst
[
i
]
=
NULL
;
return
p
-
(
char
*
)
dst
;
}
static
const
struct
{
int
prot
;
const
char
*
names
[
3
];
}
protocols
[]
=
{
{
0
,
{
"ip"
,
"IP"
}},
{
1
,
{
"icmp"
,
"ICMP"
}},
{
3
,
{
"ggp"
,
"GGP"
}},
{
6
,
{
"tcp"
,
"TCP"
}},
{
8
,
{
"egp"
,
"EGP"
}},
{
12
,
{
"pup"
,
"PUP"
}},
{
17
,
{
"udp"
,
"UDP"
}},
{
20
,
{
"hmp"
,
"HMP"
}},
{
22
,
{
"xns-idp"
,
"XNS-IDP"
}},
{
27
,
{
"rdp"
,
"RDP"
}},
{
41
,
{
"ipv6"
,
"IPv6"
}},
{
43
,
{
"ipv6-route"
,
"IPv6-Route"
}},
{
44
,
{
"ipv6-frag"
,
"IPv6-Frag"
}},
{
50
,
{
"esp"
,
"ESP"
}},
{
51
,
{
"ah"
,
"AH"
}},
{
58
,
{
"ipv6-icmp"
,
"IPv6-ICMP"
}},
{
59
,
{
"ipv6-nonxt"
,
"IPv6-NoNxt"
}},
{
60
,
{
"ipv6-opts"
,
"IPv6-Opts"
}},
{
66
,
{
"rvd"
,
"RVD"
}},
};
static
struct
WS_protoent
*
get_protoent_buffer
(
unsigned
int
size
)
{
struct
per_thread_data
*
data
=
get_per_thread_data
();
if
(
data
->
pe_buffer
)
{
if
(
data
->
pe_len
>=
size
)
return
data
->
pe_buffer
;
HeapFree
(
GetProcessHeap
(),
0
,
data
->
pe_buffer
);
}
data
->
pe_len
=
size
;
data
->
pe_buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
!
data
->
pe_buffer
)
SetLastError
(
WSAENOBUFS
);
return
data
->
pe_buffer
;
}
static
struct
WS_protoent
*
create_protoent
(
const
char
*
name
,
char
**
aliases
,
int
prot
)
{
struct
WS_protoent
*
ret
;
unsigned
int
size
=
sizeof
(
*
ret
)
+
strlen
(
name
)
+
sizeof
(
char
*
)
+
list_size
(
aliases
,
0
);
if
(
!
(
ret
=
get_protoent_buffer
(
size
)))
return
NULL
;
ret
->
p_proto
=
prot
;
ret
->
p_name
=
(
char
*
)(
ret
+
1
);
strcpy
(
ret
->
p_name
,
name
);
ret
->
p_aliases
=
(
char
**
)
ret
->
p_name
+
strlen
(
name
)
/
sizeof
(
char
*
)
+
1
;
list_dup
(
aliases
,
ret
->
p_aliases
,
0
);
return
ret
;
}
/***********************************************************************
* getprotobyname (ws2_32.53)
*/
struct
WS_protoent
*
WINAPI
WS_getprotobyname
(
const
char
*
name
)
{
struct
WS_protoent
*
retval
=
NULL
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
protocols
);
i
++
)
{
if
(
!
_strnicmp
(
protocols
[
i
].
names
[
0
],
name
,
-
1
))
{
retval
=
create_protoent
(
protocols
[
i
].
names
[
0
],
(
char
**
)
protocols
[
i
].
names
+
1
,
protocols
[
i
].
prot
);
break
;
}
}
if
(
!
retval
)
{
WARN
(
"protocol %s not found
\n
"
,
debugstr_a
(
name
)
);
SetLastError
(
WSANO_DATA
);
}
TRACE
(
"%s ret %p
\n
"
,
debugstr_a
(
name
),
retval
);
return
retval
;
}
/***********************************************************************
* getprotobynumber (ws2_32.54)
*/
struct
WS_protoent
*
WINAPI
WS_getprotobynumber
(
int
number
)
{
struct
WS_protoent
*
retval
=
NULL
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
protocols
);
i
++
)
{
if
(
protocols
[
i
].
prot
==
number
)
{
retval
=
create_protoent
(
protocols
[
i
].
names
[
0
],
(
char
**
)
protocols
[
i
].
names
+
1
,
protocols
[
i
].
prot
);
break
;
}
}
if
(
!
retval
)
{
WARN
(
"protocol %d not found
\n
"
,
number
);
SetLastError
(
WSANO_DATA
);
}
TRACE
(
"%d ret %p
\n
"
,
number
,
retval
);
return
retval
;
}
dlls/ws2_32/socket.c
View file @
5d9fe036
...
...
@@ -609,7 +609,6 @@ int num_startup;
static
FARPROC
blocking_hook
=
(
FARPROC
)
WSA_DefaultBlockingHook
;
/* function prototypes */
static
struct
WS_protoent
*
WS_create_pe
(
const
char
*
name
,
char
**
aliases
,
int
prot
);
static
struct
WS_servent
*
WS_dup_se
(
const
struct
servent
*
p_se
);
static
int
ws_protocol_info
(
SOCKET
s
,
int
unicode
,
WSAPROTOCOL_INFOW
*
buffer
,
int
*
size
);
...
...
@@ -1578,21 +1577,6 @@ static struct WS_servent *check_buffer_se(int size)
return
ptb
->
se_buffer
;
}
static
struct
WS_protoent
*
check_buffer_pe
(
int
size
)
{
struct
per_thread_data
*
ptb
=
get_per_thread_data
();
if
(
ptb
->
pe_buffer
)
{
if
(
ptb
->
pe_len
>=
size
)
return
ptb
->
pe_buffer
;
HeapFree
(
GetProcessHeap
(),
0
,
ptb
->
pe_buffer
);
}
ptb
->
pe_buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
ptb
->
pe_len
=
size
)
);
if
(
!
ptb
->
pe_buffer
)
SetLastError
(
WSAENOBUFS
);
return
ptb
->
pe_buffer
;
}
/* ----------------------------------- i/o APIs */
static
inline
BOOL
supported_pf
(
int
pf
)
{
switch
(
pf
)
...
...
@@ -5737,79 +5721,6 @@ SOCKET WINAPI WS_socket(int af, int type, int protocol)
}
static
const
struct
{
int
prot
;
const
char
*
names
[
3
];
}
protocols
[]
=
{
{
0
,
{
"ip"
,
"IP"
}},
{
1
,
{
"icmp"
,
"ICMP"
}},
{
3
,
{
"ggp"
,
"GGP"
}},
{
6
,
{
"tcp"
,
"TCP"
}},
{
8
,
{
"egp"
,
"EGP"
}},
{
12
,
{
"pup"
,
"PUP"
}},
{
17
,
{
"udp"
,
"UDP"
}},
{
20
,
{
"hmp"
,
"HMP"
}},
{
22
,
{
"xns-idp"
,
"XNS-IDP"
}},
{
27
,
{
"rdp"
,
"RDP"
}},
{
41
,
{
"ipv6"
,
"IPv6"
}},
{
43
,
{
"ipv6-route"
,
"IPv6-Route"
}},
{
44
,
{
"ipv6-frag"
,
"IPv6-Frag"
}},
{
50
,
{
"esp"
,
"ESP"
}},
{
51
,
{
"ah"
,
"AH"
}},
{
58
,
{
"ipv6-icmp"
,
"IPv6-ICMP"
}},
{
59
,
{
"ipv6-nonxt"
,
"IPv6-NoNxt"
}},
{
60
,
{
"ipv6-opts"
,
"IPv6-Opts"
}},
{
66
,
{
"rvd"
,
"RVD"
}},
};
/***********************************************************************
* getprotobyname (WS2_32.53)
*/
struct
WS_protoent
*
WINAPI
WS_getprotobyname
(
const
char
*
name
)
{
struct
WS_protoent
*
retval
=
NULL
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
protocols
);
i
++
)
{
if
(
_strnicmp
(
protocols
[
i
].
names
[
0
],
name
,
-
1
))
continue
;
retval
=
WS_create_pe
(
protocols
[
i
].
names
[
0
],
(
char
**
)
protocols
[
i
].
names
+
1
,
protocols
[
i
].
prot
);
break
;
}
if
(
!
retval
)
{
WARN
(
"protocol %s not found
\n
"
,
debugstr_a
(
name
)
);
SetLastError
(
WSANO_DATA
);
}
TRACE
(
"%s ret %p
\n
"
,
debugstr_a
(
name
),
retval
);
return
retval
;
}
/***********************************************************************
* getprotobynumber (WS2_32.54)
*/
struct
WS_protoent
*
WINAPI
WS_getprotobynumber
(
int
number
)
{
struct
WS_protoent
*
retval
=
NULL
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
protocols
);
i
++
)
{
if
(
protocols
[
i
].
prot
!=
number
)
continue
;
retval
=
WS_create_pe
(
protocols
[
i
].
names
[
0
],
(
char
**
)
protocols
[
i
].
names
+
1
,
protocols
[
i
].
prot
);
break
;
}
if
(
!
retval
)
{
WARN
(
"protocol %d not found
\n
"
,
number
);
SetLastError
(
WSANO_DATA
);
}
TRACE
(
"%i ret %p
\n
"
,
number
,
retval
);
return
retval
;
}
/***********************************************************************
* getservbyname (WS2_32.55)
*/
...
...
@@ -6313,20 +6224,6 @@ static int list_dup(char** l_src, char** l_to, int item_size)
return
p
-
(
char
*
)
l_to
;
}
static
struct
WS_protoent
*
WS_create_pe
(
const
char
*
name
,
char
**
aliases
,
int
prot
)
{
struct
WS_protoent
*
ret
;
unsigned
int
size
=
sizeof
(
*
ret
)
+
strlen
(
name
)
+
sizeof
(
char
*
)
+
list_size
(
aliases
,
0
);
if
(
!
(
ret
=
check_buffer_pe
(
size
)))
return
NULL
;
ret
->
p_proto
=
prot
;
ret
->
p_name
=
(
char
*
)(
ret
+
1
);
strcpy
(
ret
->
p_name
,
name
);
ret
->
p_aliases
=
(
char
**
)
ret
->
p_name
+
strlen
(
name
)
/
sizeof
(
char
*
)
+
1
;
list_dup
(
aliases
,
ret
->
p_aliases
,
0
);
return
ret
;
}
/* ----- servent */
static
struct
WS_servent
*
WS_dup_se
(
const
struct
servent
*
p_se
)
...
...
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