1. Every domain has their own 3 or 4 digit dial plan. When they call PSTN, their caller id should be the either a prefix plus their internal number or a generic receptionist number, but not the 3/4 digit internal number. Different domains have different prefix. Is there a way to do this without changing the script for every domain?
yes, you append rpid header to the request, which you get from database or radius.
2. Should interdomain calls be prohibited? Is it preferred to send the call to PSTN and hairpin back? I know it consumes more resources but would it provide better privacy? If that's the case, how to prevent interdomain calls, i.e. how to verify from and to URI have the same host parts?
i don't see any point in prohibiting interdomain calls unless you are a telco and want to milk your cows for nothing.
3. When PSTN calls come in, should I use prefix2domain in pdt module to convert the PSTN number to a local domain number? Any pitfalls?
i would use globally unique numbers in register requests and in the from field. otherwise there is likely to be pitfalls in interdomain calls. when you do that, there is no need for conversions when calls come in from pstn.
-- juha