mask-based port selection