common code extraced to packet_filter