Function to read masked port numbers

Reviewer: @rlane