nsiproxy: Implement NDIS ifinfo get_all_parameters.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2021-07-01 09:27:05 +01:00 committed by Alexandre Julliard
parent 0f25a94672
commit b0ceee3476
2 changed files with 54 additions and 6 deletions

View File

@ -66,9 +66,7 @@ static void test_nsi_api( void )
err = NsiGetAllParameters( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE, luid_tbl + i, sizeof(*luid_tbl),
&get_rw, rw_size, &get_dyn, sizeof(get_dyn), &get_stat, sizeof(get_stat) );
todo_wine
ok( !err, "got %d\n", err );
if (err) break;
/* test a selection of members */
ok( IsEqualGUID( &get_rw.network_guid, &rw->network_guid ), "mismatch\n" );
ok( get_rw.alias.Length == rw->alias.Length, "mismatch\n" );
@ -115,7 +113,9 @@ todo_wine
err = NsiGetParameter( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE, luid_tbl + i, sizeof(*luid_tbl),
NSI_PARAM_TYPE_RW, &get_rw.alias, sizeof(get_rw.alias),
FIELD_OFFSET(struct nsi_ndis_ifinfo_rw, alias) );
todo_wine
ok( !err, "got %d\n", err );
if (err) continue;
ok( get_rw.alias.Length == rw->alias.Length, "mismatch\n" );
ok( !memcmp( get_rw.alias.String, rw->alias.String, rw->alias.Length ), "mismatch\n" );
@ -257,11 +257,11 @@ static void test_ndis_ifinfo( void )
{
DWORD rw_sizes[] = { FIELD_OFFSET(struct nsi_ndis_ifinfo_rw, name2), FIELD_OFFSET(struct nsi_ndis_ifinfo_rw, unk),
sizeof(struct nsi_ndis_ifinfo_rw) };
struct nsi_ndis_ifinfo_rw *rw_tbl;
struct nsi_ndis_ifinfo_dynamic *dyn_tbl, *dyn_tbl_2;
struct nsi_ndis_ifinfo_static *stat_tbl;
struct nsi_ndis_ifinfo_rw *rw_tbl, rw_get;
struct nsi_ndis_ifinfo_dynamic *dyn_tbl, *dyn_tbl_2, dyn_get;
struct nsi_ndis_ifinfo_static *stat_tbl, stat_get;
DWORD err, count, i, rw_size;
NET_LUID *luid_tbl, *luid_tbl_2;
NET_LUID *luid_tbl, *luid_tbl_2, luid_get;
MIB_IF_TABLE2 *table;
/* Contents of GetIfTable2() keyed by luids */
@ -356,6 +356,17 @@ static void test_ndis_ifinfo( void )
/* OutQLen */
winetest_pop_context();
}
err = NsiGetAllParameters( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE, luid_tbl, sizeof(*luid_tbl),
&rw_get, rw_size, &dyn_get, sizeof(dyn_get),
&stat_get, sizeof(stat_get) );
ok( !err, "got %d\n", err );
ok( IsEqualGUID( &stat_tbl[0].if_guid, &stat_get.if_guid ), "mismatch\n" );
luid_get.Value = ~0u;
err = NsiGetAllParameters( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE, &luid_get, sizeof(luid_get),
&rw_get, rw_size, &dyn_get, sizeof(dyn_get),
&stat_get, sizeof(stat_get) );
ok( err == ERROR_FILE_NOT_FOUND, "got %d\n", err );
FreeMibTable( table );
NsiFreeTable( luid_tbl_2, NULL, dyn_tbl_2, NULL );

View File

@ -118,6 +118,16 @@ static struct if_entry *find_entry_from_index( DWORD index )
return NULL;
}
static struct if_entry *find_entry_from_luid( const NET_LUID *luid )
{
struct if_entry *entry;
LIST_FOR_EACH_ENTRY( entry, &if_list, struct if_entry, entry )
if (entry->if_luid.Value == luid->Value) return entry;
return NULL;
}
#if defined (SIOCGIFHWADDR) && defined (HAVE_STRUCT_IFREQ_IFR_HWADDR)
static NTSTATUS if_get_physical( const char *name, DWORD *type, IF_PHYSICAL_ADDRESS *phys_addr )
{
@ -479,6 +489,32 @@ static NTSTATUS ifinfo_enumerate_all( void *key_data, DWORD key_size, void *rw_d
return status;
}
static NTSTATUS ifinfo_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 )
{
struct if_entry *entry;
NTSTATUS status = STATUS_OBJECT_NAME_NOT_FOUND;
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 );
EnterCriticalSection( &if_list_cs );
update_if_table();
entry = find_entry_from_luid( (const NET_LUID *)key );
if (entry)
{
ifinfo_fill_entry( entry, NULL, rw_data, dynamic_data, static_data );
status = STATUS_SUCCESS;
}
LeaveCriticalSection( &if_list_cs );
return status;
}
static const struct module_table tables[] =
{
{
@ -488,6 +524,7 @@ static const struct module_table tables[] =
sizeof(struct nsi_ndis_ifinfo_dynamic), sizeof(struct nsi_ndis_ifinfo_static)
},
ifinfo_enumerate_all,
ifinfo_get_all_parameters,
},
{ ~0u }
};