Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/nsi/tests/nsi.c | 30 ++++++++++++++++++++++++++++++ dlls/nsiproxy.sys/ndis.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+)
diff --git a/dlls/nsi/tests/nsi.c b/dlls/nsi/tests/nsi.c index d7f6ac9c739..cefd42983d4 100644 --- a/dlls/nsi/tests/nsi.c +++ b/dlls/nsi/tests/nsi.c @@ -382,9 +382,39 @@ static void test_ndis_ifinfo( void ) NsiFreeTable( luid_tbl, rw_tbl, dyn_tbl, stat_tbl ); }
+static void test_ndis_index_luid( void ) +{ + DWORD err, count, i; + NET_LUID *luids, luid; + DWORD index; + + /* index -> luid map. NsiAllocateAndGetTable and NsiGetAllParameters fail */ + + /* first get the luids */ + err = NsiAllocateAndGetTable( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_IFINFO_TABLE, (void **)&luids, sizeof(*luids), + NULL, 0, NULL, 0, NULL, 0, &count, 0 ); + ok( !err, "got %d\n", err ); + + for (i = 0; i < count; i++) + { + ConvertInterfaceLuidToIndex( luids + i, &index ); + err = NsiGetParameter( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_INDEX_LUID_TABLE, &index, sizeof(index), + NSI_PARAM_TYPE_STATIC, &luid, sizeof(luid), 0 ); + ok( !err, "got %d\n", err ); + ok( luid.Value == luids[i].Value, "%d: luid mismatch\n", i ); + } + NsiFreeTable( luids, NULL, NULL, NULL ); + + index = ~0u; + err = NsiGetParameter( 1, &NPI_MS_NDIS_MODULEID, NSI_NDIS_INDEX_LUID_TABLE, &index, sizeof(index), + NSI_PARAM_TYPE_STATIC, &luid, sizeof(luid), 0 ); + ok( err == ERROR_FILE_NOT_FOUND, "got %d\n", err ); +} + START_TEST( nsi ) { test_nsi_api();
test_ndis_ifinfo(); + test_ndis_index_luid(); } diff --git a/dlls/nsiproxy.sys/ndis.c b/dlls/nsiproxy.sys/ndis.c index 647fd650cd3..38e6802e3bd 100644 --- a/dlls/nsiproxy.sys/ndis.c +++ b/dlls/nsiproxy.sys/ndis.c @@ -584,6 +584,31 @@ static NTSTATUS ifinfo_get_parameter( const void *key, DWORD key_size, DWORD par return status; }
+static NTSTATUS index_luid_get_parameter( const void *key, DWORD key_size, DWORD param_type, + void *data, DWORD data_size, DWORD data_offset ) +{ + struct if_entry *entry; + NTSTATUS status = STATUS_OBJECT_NAME_NOT_FOUND; + + TRACE( "%p %d %d %p %d %d\n", key, key_size, param_type, data, data_size, data_offset ); + + if (param_type != NSI_PARAM_TYPE_STATIC || data_size != sizeof(NET_LUID) || data_offset != 0) + return STATUS_INVALID_PARAMETER; + + EnterCriticalSection( &if_list_cs ); + + update_if_table(); + + entry = find_entry_from_index( *(DWORD *)key ); + if (entry) + { + *(NET_LUID *)data = entry->if_luid; + status = STATUS_SUCCESS; + } + LeaveCriticalSection( &if_list_cs ); + return status; +} + static const struct module_table tables[] = { { @@ -596,6 +621,16 @@ static const struct module_table tables[] = ifinfo_get_all_parameters, ifinfo_get_parameter }, + { + NSI_NDIS_INDEX_LUID_TABLE, + { + sizeof(DWORD), 0, + 0, sizeof(NET_LUID) + }, + NULL, + NULL, + index_luid_get_parameter + }, { ~0u } };