Filter's use reference
http://blog.9cbs.net/amh/archive/2004/11/09/173560.aspx
After practical discovery, in its text, the function seems to be reached, but some are incorrect.
DWORD ERR = NO_ERROR;
// A creation of a network package filter interface interface_handle hinterface; PfcreateInterface (0, pf_action_forward, // pf_action_drop, use shield all package PF_Action_forward, // pf_action_drop, original text using shield all packs
// If you shield all, then the seemingly shield is successful, but after the program runs, there is no meaning for the settings of the filt rules after the program; false, true, & hinterface;
// Binding the IP address of the network package to filter byte localip [] = {xx, xx, xx, xx}; byte destip [] = {xx, xx, xx, xx}; pfbindinterface, pf_ipv4, localip; // Now we start filating the interface filter_handle fhandle; // fill the rule structure of the filter package pf_filter_dwwflags = fd_filter.dwfilterflags = fd_filter.dwrule = 0; // Contain this value Infilter .pfattype = pf_ipv4; // with IPv4 address infilter.srcaddr = localip; // Set local IP address infilter.srcmask = (pbyte) "/ XFF / XFF / XFF / XFF"; // Set local subnet mask
Infilter.wsrcport = filter_tcpudp_port_any; // Arbitrary Source Port Infilter.wsrcportHighRange = Filter_tcpudp_port_any;
inFilter.DstAddr = DestIp; inFilter.DstMask = (PBYTE) "/ xff / xff / xff / xff"; inFilter.wDstPort = 80; inFilter.wDstPortHighRange = 80; inFilter.fLateBound = LB_SRC_ADDR_USE_DSTADDR_FLAG | LB_DST_ADDR_USE_DSTADDR_FLAG;
Infilter.dwprotocol = filter_proto_any;
/ / Add a filter interface, add it on the exit of the package filter, add it to the entrance in the original text, so it will not have effect.
// Outfilter is the correct placement of this machine's packing filter rules PfaddfiltersTointerface (Hinterface, 0, Null, 1, & Infilter, & fhaandle);
IF (Err! = NO_ERROR) {trace ("pfaddfilterstointerface is wrong / n"); return;} // In this place pop-up dialog box interrupt program, test is successful
MessageBox ("Filter Enabled!");
// Remove the filter interface PfremovefilterHandles (Hinterface, 1, & fhandle); PfunbindInterface (Hinterface); pfdeleteinterface (Hinterface); I hope to help everyone!