nat: refactor of port/address allocation functions