The packet dispatcher provides a mechanism for dispatching packets to one of several entities using packet filter technology. The packet dispatcher API allows the user to specify the type of packet filter machinery to be used internally (BPF+, DPF, etc.). The entities register their interest in a type of packet using filter-specific packet descriptions. The packet dispatcher later demultiplexes incoming packets to the correct owner or, if a packet doesn't match any of the previously registered descriptions, to a user-defined default netio. (See Section 7.5 for general information about the netio\ interface.)
The packet dispatcher's architecture is pictured in Figure 39.1. There are two data paths: one for packet description registration and one for packet dispatch. Packet owners register interest in a certain type of packets by calling oskit_packet_dispatcher_register with a description of the packets along with a netio object to which subsequently received, matching packets are pushed. The packet dispatcher's PID (Process ID, for lack of a better term) table provides the level-of-indirection necessary to map filter-generated Filter IDs with caller-supplied PIDs.
The type of packet filter used determines what format the packet descriptions take on. (As of this writing, only a single packet filter is implemented in the OSKit, but the packet dispatcher code is implemented as if more than one were available to ease the burden in future work.)
Because the packet dispatcher uses the OSKit netio interface for both incoming and outgoing channels, the definition of a packet ``owner'' is not restricted in any way: it can run on different threads or the same thread, it can dispatch packets further or process them immediately, it can process them inline or enqueue an event on an event queue. Owners can be flows, threads, processes--whatever model fits the context.
The packet dispatcher can be used in several different contexts: used in conjunction with robust accounting, it can detect a dearth in a packet owner's resources before expending resources processing packets destined to be dropped; the packet dispatcher can be used to process non-traditional packets such as IPv6; in an active network / server environment, the packet dispatcher can be used to dispatch packets to different Execution Environments.