Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increased filtering for SR records #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
adding ipaddr/port to subscriber entries
kkroo committed Jan 15, 2015
commit 56861b1a052bb5fae413d507b034346d48b2b615
37 changes: 34 additions & 3 deletions JSONDB/JSONDB.cpp
Original file line number Diff line number Diff line change
@@ -277,6 +277,22 @@ JsonBox::Object JSONDB::query(JsonBox::Object request, unsigned retries)
}
std::string msisdn = jit->second.getString();

jit = fields.find("ipaddr");
if (jit == fields.end()) {
response["code"] = JsonBox::Value(406);
response["data"] = JsonBox::Value("missing ipaddr");
return response;
}
std::string ipaddr = jit->second.getString();

jit = fields.find("port");
if (jit == fields.end()) {
response["code"] = JsonBox::Value(406);
response["data"] = JsonBox::Value("missing port");
return response;
}
std::string port = jit->second.getString();

jit = fields.find("ki");
if (jit == fields.end()) {
response["code"] = JsonBox::Value(406);
@@ -289,8 +305,8 @@ JsonBox::Object JSONDB::query(JsonBox::Object request, unsigned retries)
JsonBox::Object responseSIP;
JsonBox::Object responseDIAL;

queryTMP << "insert into sip_buddies (username, name, callerid, ki, host, allow, ipaddr)";
queryTMP << " values (\"" << imsi << "\",\"" << name << "\",\"" << msisdn << "\",\"" << ki << "\",\"dynamic\",\"gsm\",\"127.0.0.1\")";
queryTMP << "insert into sip_buddies (username, name, callerid, ki, host, allow, ipaddr, port)";
queryTMP << " values (\"" << imsi << "\",\"" << name << "\",\"" << msisdn << "\",\"" << ki << "\",\"dynamic\",\"gsm\",\"" << ipaddr << "\",\"" << port << "\" )";
responseSIP = execOnly(queryTMP.str());

queryTMP.str("");
@@ -343,11 +359,26 @@ JsonBox::Object JSONDB::query(JsonBox::Object request, unsigned retries)
}
std::string msisdn = jit->second.getString();

jit = fields.find("ipaddr");
if (jit == fields.end()) {
response["code"] = JsonBox::Value(406);
response["data"] = JsonBox::Value("missing ipaddr");
return response;
}
std::string ipaddr = jit->second.getString();

jit = fields.find("port");
if (jit == fields.end()) {
response["code"] = JsonBox::Value(406);
response["data"] = JsonBox::Value("missing port");
return response;
}
std::string port = jit->second.getString();
std::stringstream queryTMP;
JsonBox::Object responseSIP;
JsonBox::Object responseDIAL;

queryTMP << "update sip_buddies set name=\"" << name << "\", callerid=\"" << msisdn << "\" where username=\"" << imsi << "\"";
queryTMP << "update sip_buddies set name=\"" << name << "\", callerid=\"" << msisdn << "\", ipaddr=\"" << ipaddr << "\", port=\"" << port << "\" where username=\"" << imsi << "\"";
responseSIP = execOnly(queryTMP.str());

queryTMP.str("");