Dear Nishar,
From the mentioned URL the configurations need the following changes.
On the top start on configs you need to use: WITH_PSTN and might not need WITH_ASTERISK
#!KAMAILIO
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
#!define WITH_PSTN
The insert your asterisk IP in the following line:
pstn.gw_ip = "<AsteriskIPHere>" desc "PSTN GW Address"
Next your route[LOCATION] is called after the route[PSTN] from default config file so you'll have to put proper regexp/conditions to avoid your regular Extension to Extension calls to go out to PSTN-Asterisk.
Now in route[PSTN] add another condition to return from PSTN route when a local extension is dialed.
if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$") || $rU=~"^([1-5]01[0-9]$"))
return;
That will ensure that your regular extensions set don't route out to PSTN asterisk and infact will enter the route[LOCATION] where a user location DB search is made and an online user is found for the dialed destination and a successful call will be established.
I think that should be all for now.
BR,
Sammy