1. A method for filtering packets, wherein a flow corresponds to a stream of packets for a particular communication session, comprising: identifying a protocol used to transmit a packet; identifying the flow to which the packet belongs; determining whether a rules table exists for the protocol; determining, if the rules table exists, whether a state table includes a matching flow entry corresponding to the flow; determining, if the state table includes the matching flow entry, whether a state of the flow will transition from a current state indicated in the matching flow entry to a valid destination state indicated in a state-transition rule in the rules table; and discarding the packet, if the state of the flow will not transition to the valid destination state.