Hi All.
I'm using ser-0.8.99-dev21 and I'm trying to create a module which will query MySQL to see if the number dialed is in a table of unassigned DIDs. The reason is that we use a third party for PSTN access and they assign us DIDs. If a DID is dialed that is not assigned to a ser subscriber our sip proxy routes the caller to the PSTN gateway.
But the PSTN gateway provider sees the DID as belonging to our sip proxy so they route it right back to us. And we get in a loop.
I've basically got my custom ser module working but there is a bug that I cannot find. This modules exports a single function called "is_did_unassigned()".
The bug is this - when I dial a number that is unassigned is_did_unassigned() returns "0". But if I dial a number on the PSTN the call to "is_did_unassigned()" hangs. So it appears that when the MySQL query returns zero rows the module freezes.
My question is this - can someone give the attached source code a quick look to see what I've messed up. Please be nice - this is my first stab at ser modules and I'm still very unclear on all the db abstractions.
The MySQL table looks like this
CREATE TABLE unassigned_dids (username char(10))
My ser.cfg looks like this:
loadmodule "/usr/local/lib/ser/modules/dbdid.so" modparam("dbdid", "db_url", "mysql://ser:heslo@localhost/ser")
route { if (!lookup("location")) {
if (isflagset(31)) {
# Send to voicemail route(5);
} else if (does_uri_exist()) {
sl_send_reply("480", "Temporarily Unavailable");
} else if (is_did_unassigned()) {
# User Does Not Exist, but the DID is ours sl_send_reply("480", "Temporarily Unavailable");
} else if (uri=~"^sip:[0-9]{10}@") {
# Send to PSTN Gateway route(3);
} else {
sl_send_reply("404", "User Not Found"); };
break; }; }
And finally the code for the custom module which provided the "is_did_unassigned()" function is attached.
Regards, Paul
__________________________________ Do you Yahoo!? Yahoo! Mail - Find what you need with new enhanced search. http://info.mail.yahoo.com/mail_250
Juha,
I'm sorry if I seem a little dense, but I'm not sure what your saying.
Which enum database are you talking about? Something like enum.org or is it your own private MySQL database? Also, are you simply using the enum module to resolve this?
Regards, Paul
--- Juha Heinanen jh@tutpro.com wrote:
Java Rockx writes:
But the PSTN gateway provider sees the DID as belonging to our sip
proxy so they route it right back to us. And we get in a loop.
we use shadow enum db for these kind of checks.
-- juha
__________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com
Java Rockx writes:
Which enum database are you talking about? Something like enum.org or is it your own private MySQL database? Also, are you simply using the enum module to resolve this?
yes, you create a new enum domain, e.g., e164shadow.arpa, and put all your numbers there. then before forwarding the call to pstn, you check if you find enum match in e164shadow.arpa. if so, you know it is an unallocated number.
-- juha
[quote] If a DID is dialed that is not assigned to a ser subscriber our sip proxy routes the caller to the PSTN gateway. But the PSTN gateway provider sees the DID as belonging to our sip proxy so they route it right back to us. And we get in a loop. [/quote]
So basically it's not your fault but the PSTN gateways fault, it should only send the assigned DID's to you? You are stating that the gateway sees the number as assigned to your proxy while you don't.
(you could also check if the incoming message is coming from an ip address of your pstn gateway)
Kind regards,
E. Versaevel