pfil pfil_head_register pfil_head_unregister pfil_head_get pfil_hook_get pfil_add_hook pfil_remove_hook pfil_run_hooks - packet filter interface
Packet filtering points are registered with
Filtering points are identified by a key (Vt void * ) and a data link type (Vt int ) in the Vt pfil_head structure. Packet filters use the key and data link type to look up the filtering point with which they register themselves. The key is unique to the filtering point. The data link type is a bpf(4) DLT constant indicating what kind of header is present on the packet at the filtering point. Filtering points may be unregistered with the pfil_head_unregister ();
Packet filters register/unregister themselves with a filtering point
and pfil_remove_hook ();
functions, respectively. The head is looked up using the pfil_head_get ();
function, which takes the key and data link type that the packet filter expects. Filters may provide an argument to be passed to the filter when invoked on a packet.
When a filter is invoked, the packet appears just as if it ``came off the wire'' That is, all protocol fields are in network byte order. The filter is called with its specified argument, the pointer to the pointer to the Vt mbuf containing the packet, the pointer to the network interface that the packet is traversing, and the direction ( PFIL_IN or PFIL_OUT that the packet is traveling. The filter may change which mbuf the Vt mbuf ** argument references. The filter returns an error (errno) if the packet processing is to stop, or 0 if the processing is to continue. If the packet processing is to stop, it is the responsibility of the filter to free the packet.
function might sleep!
interface was changed in 1.4T to accept a 3rd parameter to both
and pfil_remove_hook (,);
introducing the capability of per-protocol filtering. This was done primarily in order to support filtering of IPv6.
In 1.5K, the framework was changed to work with an arbitrary number of filtering points, as well as be less IP-centric.
Fine-grained locking was added in Fx 5.2 .
Fx implements only hooks for AF_INET and AF_INET6 Packets diverted through these hooks have data in host byte order contrary to the above statements.
The if_bridge4 diverts AF_INET and AF_INET6 traffic according to its sysctl settings, but contrary to the above statements, the data is provided in host byte order.
is being modified, no traffic is diverted
(to avoid deadlock).
This means that traffic may be dropped unconditionally for a short period
will return Er ENOBUFS to indicate this.
Закладки на сайте
Проследить за страницей
Created 1996-2021 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру