Share via


PfGetInterfaceStatistics

[PfGetInterfaceStatistics is available for use in the operating systems listed in the Requirements section. In Windows Server "Longhorn", this function returns ERROR_CALL_NOT_SUPPORTED. The MprConfigInterfaceTransportSetInfo function and the Windows Filtering Platform API Management Functions provide similar functionality.]

The PfGetInterfaceStatistics function retrieves statistics for the specified interface. This function can also, optionally, retrieve statistics for the filters associated with this interface.

DWORD PfGetInterfaceStatistics(
  INTERFACE_HANDLE pInterface,
  PPF_INTERFACE_STATS ppfStats,
  PDWORD pdwBufferSize,
  BOOL fResetCounters
);

Parameters

  • pInterface
    [in] Handle to the interface.

  • ppfStats
    Pointer to a buffer that receives the statistics for the interface.

    If the calling application requires only the statistics for the interface, this buffer should be of a size equal to a PF_INTERFACE_STATS structure. If the caller supplies a buffer that is smaller than this size, PfGetInterfaceStatistics returns PFERROR_BUFFER_TOO_SMALL, and the pdwBufferSize parameter contains a size equal to a PF_INTERFACE_STATS structure.

    If the caller requires the statistics for both the interface and the associated filters, the buffer should be of a size greater than PF_INTERFACE_STATS. If the buffer is still not large enough, PfGetInterfaceStatistics returns ERROR_INSUFFICIENT_BUFFER, and the pdwBufferSize parameter points to a DWORD variable that contains a buffer size large enough to hold both the interface and filter statistics.

  • pdwBufferSize
    [in] Pointer to a DWORD variable that specifies the size of the buffer pointed to by the ppfStats parameter.

  • fResetCounters
    [in] Specifies whether the statistics counters for the interface should be reset. If this parameter is TRUE, the statistics counters are reset.

Return Value

If the function succeeds, the return value is NO_ERROR.

If the function fails, the return value is one of the following error codes.

Value Meaning
ERROR_INSUFFICIENT_BUFFER This error is specific to PfGetInterfaceStatistics and means that the supplied user buffer is too small for the filters. The correct size is returned as the interface statistics that contain the filter counts.
PFERROR_BUFFER_TOO_SMALL This error is specific to PfGetInterfaceStatistics and means the user buffer is too small even for the interface statistics. The returned size is the size of the interface statistics, but does not include space for filters. If the function is called using this size, the return value should be ERROR_INSUFFICIENT_BUFFER.
Other Use FormatMessage to obtain the message string for the returned error.

Remarks

The caller may call PfGetInterfaceStatistics twice. Initially, to obtain the correct buffer size, then a second time to retrieve the statistics. If the caller calls PfGetInterfaceStatistics twice for a shared interface, the second call may fail with ERROR_INSUFFICIENT_BUFFER. This error occurs if other processes sharing the interface add filters to the interface in the interval between the two calls. This type of error should not occur for a UNIQUE interface (an interface that cannot be shared).

Requirements

Server Requires Windows Server 2003 or Windows 2000 Server.
Header

Declared in Fltdefs.h.

Library

Use Iphlpapi.lib.

DLL Requires Iphlpapi.dll.

See Also

PF_INTERFACE_STATS