Huw Davies : nsiproxy: Implement IP unicast get_all_parameters.
Alexandre Julliard
julliard at winehq.org
Tue Jul 20 15:11:04 CDT 2021
Module: wine
Branch: master
Commit: 4c7c7d07d4dd30b0751c7ad0bbc1db5577807b72
URL: https://source.winehq.org/git/wine.git/?a=commit;h=4c7c7d07d4dd30b0751c7ad0bbc1db5577807b72
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Jul 20 08:43:25 2021 +0100
nsiproxy: Implement IP unicast get_all_parameters.
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/nsi/tests/nsi.c | 14 +++++++++----
dlls/nsiproxy.sys/ip.c | 39 ++++++++++++++++++++++++++++++++++++
dlls/nsiproxy.sys/ndis.c | 21 +++++++++++++++++++
dlls/nsiproxy.sys/nsiproxy_private.h | 1 +
4 files changed, 71 insertions(+), 4 deletions(-)
diff --git a/dlls/nsi/tests/nsi.c b/dlls/nsi/tests/nsi.c
index 3408dfae58f..c07653c2ede 100644
--- a/dlls/nsi/tests/nsi.c
+++ b/dlls/nsi/tests/nsi.c
@@ -415,11 +415,11 @@ static void test_ip_unicast( int family )
{
DWORD rw_sizes[] = { FIELD_OFFSET(struct nsi_ip_unicast_rw, unk[0]), FIELD_OFFSET(struct nsi_ip_unicast_rw, unk[1]),
sizeof(struct nsi_ip_unicast_rw) };
- struct nsi_ipv4_unicast_key *key_tbl, *key4;
+ struct nsi_ipv4_unicast_key *key_tbl, *key4, get_key;
struct nsi_ipv6_unicast_key *key6;
- struct nsi_ip_unicast_rw *rw_tbl, *rw;
- struct nsi_ip_unicast_dynamic *dyn_tbl, *dyn;
- struct nsi_ip_unicast_static *stat_tbl, *stat;
+ struct nsi_ip_unicast_rw *rw_tbl, *rw, get_rw;
+ struct nsi_ip_unicast_dynamic *dyn_tbl, *dyn, get_dyn;
+ struct nsi_ip_unicast_static *stat_tbl, *stat, get_stat;
MIB_UNICASTIPADDRESS_TABLE *table;
const NPI_MODULEID *mod = (family == AF_INET) ? &NPI_MS_IPV4_MODULEID : &NPI_MS_IPV6_MODULEID;
DWORD err, count, i, rw_size, key_size = (family == AF_INET) ? sizeof(*key4) : sizeof(*key6);
@@ -475,6 +475,12 @@ todo_wine
winetest_pop_context();
}
+ get_key.luid.Value = ~0u;
+ get_key.addr.s_addr = 0;
+ err = NsiGetAllParameters( 1, &NPI_MS_IPV4_MODULEID, NSI_IP_UNICAST_TABLE, &get_key, sizeof(get_key),
+ &get_rw, rw_size, &get_dyn, sizeof(get_dyn), &get_stat, sizeof(get_stat) );
+ ok( err == ERROR_NOT_FOUND, "got %d\n", err );
+
FreeMibTable( table );
NsiFreeTable( key_tbl, rw_tbl, dyn_tbl, stat_tbl );
winetest_pop_context();
diff --git a/dlls/nsiproxy.sys/ip.c b/dlls/nsiproxy.sys/ip.c
index d5fcc689fc4..ab1b6294bea 100644
--- a/dlls/nsiproxy.sys/ip.c
+++ b/dlls/nsiproxy.sys/ip.c
@@ -180,6 +180,43 @@ static NTSTATUS ip_unicast_enumerate_all( void *key_data, DWORD key_size, void *
return status;
}
+static NTSTATUS ip_unicast_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 )
+{
+ int family = (key_size == sizeof(struct nsi_ipv4_unicast_key)) ? AF_INET : AF_INET6;
+ NTSTATUS status = STATUS_NOT_FOUND;
+ const struct nsi_ipv6_unicast_key *key6 = key;
+ const struct nsi_ipv4_unicast_key *key4 = key;
+ struct ifaddrs *addrs, *entry;
+ const char *unix_name;
+
+ 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 );
+
+ if (!convert_luid_to_unix_name( &key6->luid, &unix_name )) return STATUS_NOT_FOUND;
+
+ if (getifaddrs( &addrs )) return STATUS_NO_MORE_ENTRIES;
+
+ for (entry = addrs; entry; entry = entry->ifa_next)
+ {
+ if (!entry->ifa_addr || entry->ifa_addr->sa_family != family) continue;
+ if (strcmp( entry->ifa_name, unix_name )) continue;
+
+ if (family == AF_INET &&
+ memcmp( &key4->addr, &((struct sockaddr_in *)entry->ifa_addr)->sin_addr, sizeof(key4->addr) )) continue;
+ if (family == AF_INET6 &&
+ memcmp( &key6->addr, &((struct sockaddr_in6 *)entry->ifa_addr)->sin6_addr, sizeof(key6->addr) )) continue;
+
+ unicast_fill_entry( entry, NULL, rw_data, dynamic_data, static_data );
+ status = STATUS_SUCCESS;
+ break;
+ }
+
+ freeifaddrs( addrs );
+ return status;
+}
+
static struct module_table ipv4_tables[] =
{
{
@@ -189,6 +226,7 @@ static struct module_table ipv4_tables[] =
sizeof(struct nsi_ip_unicast_dynamic), sizeof(struct nsi_ip_unicast_static)
},
ip_unicast_enumerate_all,
+ ip_unicast_get_all_parameters,
},
{
~0u
@@ -210,6 +248,7 @@ static struct module_table ipv6_tables[] =
sizeof(struct nsi_ip_unicast_dynamic), sizeof(struct nsi_ip_unicast_static)
},
ip_unicast_enumerate_all,
+ ip_unicast_get_all_parameters,
},
{
~0u
diff --git a/dlls/nsiproxy.sys/ndis.c b/dlls/nsiproxy.sys/ndis.c
index b08d5bbcc79..40a60e45c46 100644
--- a/dlls/nsiproxy.sys/ndis.c
+++ b/dlls/nsiproxy.sys/ndis.c
@@ -634,6 +634,27 @@ BOOL convert_unix_name_to_luid( const char *unix_name, NET_LUID *luid )
return ret;
}
+BOOL convert_luid_to_unix_name( const NET_LUID *luid, const char **unix_name )
+{
+ struct if_entry *entry;
+ BOOL ret = FALSE;
+
+ EnterCriticalSection( &if_list_cs );
+
+ update_if_table();
+
+ LIST_FOR_EACH_ENTRY( entry, &if_list, struct if_entry, entry )
+ if (entry->if_luid.Value == luid->Value)
+ {
+ *unix_name = entry->if_unix_name;
+ ret = TRUE;
+
+ }
+ LeaveCriticalSection( &if_list_cs );
+
+ return ret;
+}
+
static const struct module_table tables[] =
{
{
diff --git a/dlls/nsiproxy.sys/nsiproxy_private.h b/dlls/nsiproxy.sys/nsiproxy_private.h
index 1c62a3df038..0f6e7b05c59 100644
--- a/dlls/nsiproxy.sys/nsiproxy_private.h
+++ b/dlls/nsiproxy.sys/nsiproxy_private.h
@@ -22,6 +22,7 @@ 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;
+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;
struct module_table
More information about the wine-cvs
mailing list