Packet Sniffer SDK DLL Edition

HNFileAdapter :: Properties :: FAdpSetUserFilter

 Previous Next

Sets the handle of HNUserFilter object.

Syntax:

HANDLE __stdcall FAdpSetUserFilter(HANDLE hFAdp, HANDLE hFtr);

Parameters:

hFAdp

[in] HNFileAdapter object handle.

hFtr

[in] HNUserFilter object handle.

Return values:

If the function succeeds the return value will be the handle of the HNUserFilter object. Otherwise the return value will be NULL.

Description:

Use FAdpGetUserFilter to set BPF value for current CAP file.

BPF filters may be used for filtering packets read from a CAP file by FAdpGetNextPacket function, also they will be used by HNFileAdpater object in AutoMode. At the same time the BPF statistics will be counted (see FAdpGetRecvCount, FAdpGetAcceptCount, FAdpGetRejectCount, FAdpGetProcessCount).

To detect HNFileAdapter.UserFilter property value please use FAdpGetUserFilter function.

Please remember, that UserFilter must be used with the UserFilterActive property.
// Create IP filter
HANDLE hBpf = BpfCreate();
...
BpfAddCmd(hBpf,BPF_LD+BPF_H+BPF_ABS, 12);
BpfAddJmp(hBpf,BPF_JMP+BPF_JEQ+BPF_K, ETHERTYPE_IP, 0, 1);
BpfAddCmd(hBpf,BPF_RET+BPF_K, -1);
BpfAddCmd(hBpf,BPF_RET+BPF_K, 0);

FAdpSetUserFilter(hFAdp,hBpf);
FAdpSetUserFilterActive(hFAdp,TRUE);
FAdpOpenFile(hFAdp, "packets.cap");
...
See also:HNFileAdapter, HNUserFilter, FAdpGetUserFilterActive, FAdpSetUserFilterActive, FAdpGetUserFilter, FAdpGetRecvCount, FAdpGetAcceptCount, FAdpGetRejectCount, FAdpGetProcessCount