A common need is to determine if the caller has dialed his/her own extension. This is often a way to access a voice mail system.
If you can identify that the caller has dialed his own extension you can avoid overhead of lookup("location") and failure route blocks in order to access voice mail.
Here is an example of how to determine if you should send the caller to their voice mail.
loadmodule "/usr/local/lib/ser/modules/avpops.so"
route {
# store the caller in AVP number 34. You can
# think of AVP number 34 as just a temporary
# variable which we store the caller's
# identity in.
avp_write("$from", "i:34");
# compare AVP number 34 to the request URI
# If they are equal then the caller dialed
# his/her own extension
if (avp_check("i:34", "eq/$ruri/i")) {
# If the caller has the "voicemail" group
# membership, then send to voice mail
# otherwise reply with a 486 Busy response
if (is_user_in("Request-URI", "voicemail")) {
# send to voice mail
rewritehostpost("10.3.0.30", "5060");
append_branch();
} else {
# reply with busy
sl_send_reply("486", "Busy");
};
# clean up our AVP we previously created
avp_delete("i:34");
break;
};
}avp_delete("i:34");