Packet classification logic.