Routing Via Phonebook

I am trying to route inbound callers with known CID via a “whitelist” setup. I would like to utilize the phonebook and caller Id lookup sources. Is this possible? If yes, what additional coding will be needed?

No it is not. The cid lookup sources does what it describes, matches the cid number with an entry from a database and set’s callerid name value to the name that gets from the db query. Check this if you want dynamic routing

http://www.voipsupport.it/wiki/index.php/Dynamic_Routes

Dynamic routing can be done using the module linked above or a Custom Destination to some custom dialplan. This is the hard part (getting the brackets in the right sequence):

$[${LEN(${DB(cidname/${CALLERID(number)})})}!=0]

The above Asterisk variable expression will evaluate to 1 if the incoming CallerID number is present in the Asterisk phone book, or 0 if not. You will have to ensure that the trunk is delivering the CID in the same format as it’s stored in the database.