WDI TLV generator interface overview
C++ overloaded function model
In this model, there is only one function call to generate a TLV byte array from your data structure.
WDI_INDICATION_BSS_ENTRY_LIST_PARAMETERS BssEntryList = ...;
BYTE* pOutput = NULL;
ULONG length = 0;
NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS;
ndisStatus = Generate(
&BssEntryList,
cbHeaderLength,
&Context,
&length,
&pOutput);
The second parameter can be very helpful. Sometimes, the TLV buffer is packed into a bigger data structure, and this parameter allows you to pre-reserve space at the beginning of the buffer for that header. The correct value for cbHeaderLength is often sizeof(WDI_MESSAGE_HEADER)
.
For messages that have no associated data, there are still overloaded Generate APIs, but the first parameter is optional and may simply be passed in as (EmptyMessageStructureType*)NULL
.
When you are done with the TLV data contained in pOutput, you must call back into the library to release the buffer.
FreeGenerated(pOutput);
pOutput = NULL;
C-style function model
In this model, there is a specific Generate routine for each top-level message or structure because C does not support overloaded functions. Otherwise, it behaves the same as the C++ model.
ndisStatus = GenerateWdiGetAdapterCapabilities(
&adapterCapabilities,
(ULONG)sizeof(WFC_COMMAND_HEADER),
&Context,
&length,
&pOutput);
When you are done with the TLV byte array, call back to release the memory in the same way as the C++ model.
FreeGenerated(pOutput);
pOutput = NULL;