a method for processing packets in a router includes specifying operations on packets as chains of processing elements . each chain is uniquely associated with one interface / protocol pair , and each processing element performs at least one function on a packet . an incoming packet is received , and processed , first by a demultiplexor element which determines the protocol of the next higher level used by the packet . then , the packet is processed by the elements of a decapsulation chain associated with the interface on which the packet was received , and by the elements of an encapsulation chain associated with the interface on which the packet is to be transmitted . the demultiplexor element or operation passes the packet on to a decapsulation chain associated with the protocol and with the incoming interface , depending on protocol information contained in the incoming packet . decapsulation and encapsulation chains can be built dynamically , by inserting new and removing old elements as necessary as new protocols are developed and new features added . a chain walker walks through the chains , passing the processed packet to each element in a chain , until either the end of the chain is reached and processing is complete , or until the packet is dropped because no function can process it , or because a packet is processed by an outside process or by hardware , which may optionally stop the chain walk . a chain walk may be temporarily halted , or may be terminated . if temporarily halted , the chain walk can be resumed at any element in the chain , depending on the packet &# 39 ; s requirements . a chain walk can also begin at any element in a chain .