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
a7849502
Commit
a7849502
authored
Aug 11, 2021
by
Huw Davies
Committed by
Alexandre Julliard
Aug 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nsiproxy: Implement IP compartment get_all_paramters.
Signed-off-by:
Huw Davies
<
huw@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
68498fc3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
209 additions
and
0 deletions
+209
-0
nsi.c
dlls/nsi/tests/nsi.c
+42
-0
ip.c
dlls/nsiproxy.sys/ip.c
+121
-0
nsiproxy_private.h
dlls/nsiproxy.sys/nsiproxy_private.h
+29
-0
nsi.h
include/wine/nsi.h
+17
-0
No files found.
dlls/nsi/tests/nsi.c
View file @
a7849502
...
...
@@ -411,6 +411,46 @@ static void test_ndis_index_luid( void )
ok
(
err
==
ERROR_FILE_NOT_FOUND
,
"got %d
\n
"
,
err
);
}
static
void
test_ip_cmpt
(
int
family
)
{
DWORD
rw_sizes
[]
=
{
FIELD_OFFSET
(
struct
nsi_ip_cmpt_rw
,
unk2
),
sizeof
(
struct
nsi_ip_cmpt_rw
)
};
const
NPI_MODULEID
*
mod
=
(
family
==
AF_INET
)
?
&
NPI_MS_IPV4_MODULEID
:
&
NPI_MS_IPV6_MODULEID
;
struct
nsi_ip_cmpt_dynamic
dyn
;
struct
nsi_ip_cmpt_rw
rw
;
MIB_IPSTATS
table
;
DWORD
err
,
key
,
i
;
winetest_push_context
(
family
==
AF_INET
?
"AF_INET"
:
"AF_INET6"
);
/* key = 0 also seems to work, but NsiAllocateAndGetTable returns
a single table with key == 1. Presumably this is the compartment id */
key
=
1
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
rw_sizes
);
i
++
)
{
err
=
NsiGetAllParameters
(
1
,
mod
,
2
,
&
key
,
sizeof
(
key
),
&
rw
,
rw_sizes
[
i
],
&
dyn
,
sizeof
(
dyn
),
NULL
,
0
);
if
(
!
err
)
break
;
}
ok
(
!
err
,
"got %x
\n
"
,
err
);
err
=
GetIpStatisticsEx
(
&
table
,
family
);
ok
(
!
err
,
"got %d
\n
"
,
err
);
if
(
err
)
goto
err
;
todo_wine_if
(
family
==
AF_INET6
&&
table
.
dwForwarding
-
1
!=
rw
.
not_forwarding
)
ok
(
table
.
dwForwarding
-
1
==
rw
.
not_forwarding
,
"%x vs %x
\n
"
,
table
.
dwForwarding
,
rw
.
not_forwarding
);
todo_wine_if
(
family
==
AF_INET6
&&
table
.
dwDefaultTTL
!=
rw
.
default_ttl
)
ok
(
table
.
dwDefaultTTL
==
rw
.
default_ttl
,
"%x vs %x
\n
"
,
table
.
dwDefaultTTL
,
rw
.
default_ttl
);
ok
(
table
.
dwNumIf
==
dyn
.
num_ifs
,
"%x vs %x
\n
"
,
table
.
dwNumIf
,
dyn
.
num_ifs
);
todo_wine_if
(
table
.
dwNumAddr
!=
dyn
.
num_addrs
)
ok
(
table
.
dwNumAddr
==
dyn
.
num_addrs
,
"%x vs %x
\n
"
,
table
.
dwNumAddr
,
dyn
.
num_addrs
);
todo_wine_if
(
family
==
AF_INET6
&&
table
.
dwNumRoutes
!=
dyn
.
num_routes
)
ok
(
table
.
dwNumRoutes
==
dyn
.
num_routes
,
"%x vs %x
\n
"
,
table
.
dwNumRoutes
,
dyn
.
num_routes
);
err:
winetest_pop_context
();
}
static
void
test_ip_ipstats
(
int
family
)
{
const
NPI_MODULEID
*
mod
=
(
family
==
AF_INET
)
?
&
NPI_MS_IPV4_MODULEID
:
&
NPI_MS_IPV6_MODULEID
;
...
...
@@ -725,6 +765,8 @@ START_TEST( nsi )
test_ndis_ifinfo
();
test_ndis_index_luid
();
test_ip_cmpt
(
AF_INET
);
test_ip_cmpt
(
AF_INET6
);
test_ip_ipstats
(
AF_INET
);
test_ip_ipstats
(
AF_INET6
);
test_ip_unicast
(
AF_INET
);
...
...
dlls/nsiproxy.sys/ip.c
View file @
a7849502
...
...
@@ -120,6 +120,109 @@ static ULONG64 get_boot_time( void )
return
ti
.
BootTime
.
QuadPart
;
}
#if __linux__
static
NTSTATUS
read_sysctl_int
(
const
char
*
file
,
int
*
val
)
{
FILE
*
fp
;
char
buf
[
128
],
*
endptr
=
buf
;
fp
=
fopen
(
file
,
"r"
);
if
(
!
fp
)
return
STATUS_NOT_SUPPORTED
;
if
(
fgets
(
buf
,
sizeof
(
buf
),
fp
))
*
val
=
strtol
(
buf
,
&
endptr
,
10
);
fclose
(
fp
);
return
(
endptr
==
buf
)
?
STATUS_NOT_SUPPORTED
:
STATUS_SUCCESS
;
}
#endif
static
NTSTATUS
ip_cmpt_get_all_parameters
(
DWORD
fam
,
const
DWORD
*
key
,
DWORD
key_size
,
struct
nsi_ip_cmpt_rw
*
rw_data
,
DWORD
rw_size
,
struct
nsi_ip_cmpt_dynamic
*
dynamic_data
,
DWORD
dynamic_size
,
void
*
static_data
,
DWORD
static_size
)
{
const
NPI_MODULEID
*
ip_mod
=
(
fam
==
AF_INET
)
?
&
NPI_MS_IPV4_MODULEID
:
&
NPI_MS_IPV6_MODULEID
;
struct
nsi_ip_cmpt_rw
rw
;
struct
nsi_ip_cmpt_dynamic
dyn
;
DWORD
count
;
memset
(
&
rw
,
0
,
sizeof
(
rw
)
);
memset
(
&
dyn
,
0
,
sizeof
(
dyn
)
);
if
(
*
key
!=
1
)
return
STATUS_NOT_SUPPORTED
;
#if __linux__
{
const
char
*
fwd
=
(
fam
==
AF_INET
)
?
"/proc/sys/net/ipv4/conf/default/forwarding"
:
"/proc/sys/net/ipv6/conf/default/forwarding"
;
const
char
*
ttl
=
(
fam
==
AF_INET
)
?
"/proc/sys/net/ipv4/ip_default_ttl"
:
"/proc/sys/net/ipv6/conf/default/hop_limit"
;
int
value
;
if
(
!
read_sysctl_int
(
fwd
,
&
value
))
rw
.
not_forwarding
=
!
value
;
if
(
!
read_sysctl_int
(
ttl
,
&
value
))
rw
.
default_ttl
=
value
;
}
#elif defined(HAVE_SYS_SYSCTL_H)
{
int
fwd_4
[]
=
{
CTL_NET
,
PF_INET
,
IPPROTO_IP
,
IPCTL_FORWARDING
};
int
fwd_6
[]
=
{
CTL_NET
,
PF_INET6
,
IPPROTO_IPV6
,
IPV6CTL_FORWARDING
};
int
ttl_4
[]
=
{
CTL_NET
,
PF_INET
,
IPPROTO_IP
,
IPCTL_DEFTTL
};
int
ttl_6
[]
=
{
CTL_NET
,
PF_INET6
,
IPPROTO_IPV6
,
IPV6CTL_DEFHLIM
};
int
value
;
size_t
needed
;
needed
=
sizeof
(
value
);
if
(
!
sysctl
(
(
fam
==
AF_INET
)
?
fwd_4
:
fwd_6
,
ARRAY_SIZE
(
fwd_4
),
&
value
,
&
needed
,
NULL
,
0
))
rw
.
not_forwarding
=
value
;
needed
=
sizeof
(
value
);
if
(
!
sysctl
(
(
fam
==
AF_INET
)
?
ttl_4
:
ttl_6
,
ARRAY_SIZE
(
ttl_4
),
&
value
,
&
needed
,
NULL
,
0
))
rw
.
default_ttl
=
value
;
}
#else
FIXME
(
"forwarding and default ttl not implemented
\n
"
);
#endif
count
=
0
;
if
(
!
nsi_enumerate_all
(
1
,
0
,
&
NPI_MS_NDIS_MODULEID
,
NSI_NDIS_IFINFO_TABLE
,
NULL
,
0
,
NULL
,
0
,
NULL
,
0
,
NULL
,
0
,
&
count
))
dyn
.
num_ifs
=
count
;
count
=
0
;
if
(
!
nsi_enumerate_all
(
1
,
0
,
ip_mod
,
NSI_IP_FORWARD_TABLE
,
NULL
,
0
,
NULL
,
0
,
NULL
,
0
,
NULL
,
0
,
&
count
))
dyn
.
num_routes
=
count
;
count
=
0
;
if
(
!
nsi_enumerate_all
(
1
,
0
,
ip_mod
,
NSI_IP_UNICAST_TABLE
,
NULL
,
0
,
NULL
,
0
,
NULL
,
0
,
NULL
,
0
,
&
count
))
dyn
.
num_addrs
=
count
;
if
(
rw_data
)
*
rw_data
=
rw
;
if
(
dynamic_data
)
*
dynamic_data
=
dyn
;
return
STATUS_SUCCESS
;
}
static
NTSTATUS
ipv4_cmpt_get_all_parameters
(
const
void
*
key
,
DWORD
key_size
,
void
*
rw_data
,
DWORD
rw_size
,
void
*
dynamic_data
,
DWORD
dynamic_size
,
void
*
static_data
,
DWORD
static_size
)
{
TRACE
(
"%p %d %p %d %p %d %p %d
\n
"
,
key
,
key_size
,
rw_data
,
rw_size
,
dynamic_data
,
dynamic_size
,
static_data
,
static_size
);
return
ip_cmpt_get_all_parameters
(
AF_INET
,
key
,
key_size
,
rw_data
,
rw_size
,
dynamic_data
,
dynamic_size
,
static_data
,
static_size
);
}
static
NTSTATUS
ipv6_cmpt_get_all_parameters
(
const
void
*
key
,
DWORD
key_size
,
void
*
rw_data
,
DWORD
rw_size
,
void
*
dynamic_data
,
DWORD
dynamic_size
,
void
*
static_data
,
DWORD
static_size
)
{
TRACE
(
"%p %d %p %d %p %d %p %d
\n
"
,
key
,
key_size
,
rw_data
,
rw_size
,
dynamic_data
,
dynamic_size
,
static_data
,
static_size
);
return
ip_cmpt_get_all_parameters
(
AF_INET6
,
key
,
key_size
,
rw_data
,
rw_size
,
dynamic_data
,
dynamic_size
,
static_data
,
static_size
);
}
static
NTSTATUS
ipv4_ipstats_get_all_parameters
(
const
void
*
key
,
DWORD
key_size
,
void
*
rw_data
,
DWORD
rw_size
,
void
*
dynamic_data
,
DWORD
dynamic_size
,
void
*
static_data
,
DWORD
static_size
)
{
...
...
@@ -870,6 +973,15 @@ static NTSTATUS ipv6_forward_enumerate_all( void *key_data, DWORD key_size, void
static
struct
module_table
ipv4_tables
[]
=
{
{
NSI_IP_COMPARTMENT_TABLE
,
{
sizeof
(
DWORD
),
sizeof
(
struct
nsi_ip_cmpt_rw
),
sizeof
(
struct
nsi_ip_cmpt_dynamic
),
0
},
NULL
,
ipv4_cmpt_get_all_parameters
,
},
{
NSI_IP_IPSTATS_TABLE
,
{
0
,
0
,
...
...
@@ -917,6 +1029,15 @@ const struct module ipv4_module =
static
struct
module_table
ipv6_tables
[]
=
{
{
NSI_IP_COMPARTMENT_TABLE
,
{
sizeof
(
DWORD
),
sizeof
(
struct
nsi_ip_cmpt_rw
),
sizeof
(
struct
nsi_ip_cmpt_dynamic
),
0
},
NULL
,
ipv6_cmpt_get_all_parameters
,
},
{
NSI_IP_IPSTATS_TABLE
,
{
0
,
0
,
...
...
dlls/nsiproxy.sys/nsiproxy_private.h
View file @
a7849502
...
...
@@ -22,6 +22,35 @@ NTSTATUS nsi_enumerate_all_ex( struct nsi_enumerate_all_ex *params ) DECLSPEC_HI
NTSTATUS
nsi_get_all_parameters_ex
(
struct
nsi_get_all_parameters_ex
*
params
)
DECLSPEC_HIDDEN
;
NTSTATUS
nsi_get_parameter_ex
(
struct
nsi_get_parameter_ex
*
params
)
DECLSPEC_HIDDEN
;
static
inline
NTSTATUS
nsi_enumerate_all
(
DWORD
unk
,
DWORD
unk2
,
const
NPI_MODULEID
*
module
,
DWORD
table
,
void
*
key_data
,
DWORD
key_size
,
void
*
rw_data
,
DWORD
rw_size
,
void
*
dynamic_data
,
DWORD
dynamic_size
,
void
*
static_data
,
DWORD
static_size
,
DWORD
*
count
)
{
struct
nsi_enumerate_all_ex
params
;
NTSTATUS
status
;
params
.
unknown
[
0
]
=
0
;
params
.
unknown
[
1
]
=
0
;
params
.
module
=
module
;
params
.
table
=
table
;
params
.
first_arg
=
unk
;
params
.
second_arg
=
unk2
;
params
.
key_data
=
key_data
;
params
.
key_size
=
key_size
;
params
.
rw_data
=
rw_data
;
params
.
rw_size
=
rw_size
;
params
.
dynamic_data
=
dynamic_data
;
params
.
dynamic_size
=
dynamic_size
;
params
.
static_data
=
static_data
;
params
.
static_size
=
static_size
;
params
.
count
=
*
count
;
status
=
nsi_enumerate_all_ex
(
&
params
);
*
count
=
params
.
count
;
return
status
;
}
BOOL
convert_luid_to_unix_name
(
const
NET_LUID
*
luid
,
const
char
**
unix_name
)
DECLSPEC_HIDDEN
;
BOOL
convert_unix_name_to_luid
(
const
char
*
unix_name
,
NET_LUID
*
luid
)
DECLSPEC_HIDDEN
;
...
...
include/wine/nsi.h
View file @
a7849502
...
...
@@ -97,11 +97,28 @@ struct nsi_ndis_ifinfo_static
};
/* Undocumented NSI IP tables */
#define NSI_IP_COMPARTMENT_TABLE 2
#define NSI_IP_IPSTATS_TABLE 6
#define NSI_IP_UNICAST_TABLE 10
#define NSI_IP_NEIGHBOUR_TABLE 11
#define NSI_IP_FORWARD_TABLE 16
struct
nsi_ip_cmpt_rw
{
DWORD
not_forwarding
;
DWORD
unk
;
DWORD
default_ttl
;
DWORD
unk2
;
};
struct
nsi_ip_cmpt_dynamic
{
DWORD
num_ifs
;
DWORD
num_routes
;
DWORD
unk
;
DWORD
num_addrs
;
};
struct
nsi_ip_ipstats_dynamic
{
DWORD
unk
[
4
];
...
...
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