mirror of
https://github.com/RangeNetworks/openbts.git
synced 2025-11-10 16:35:39 +00:00
Fixes #693 in public. Basically, refactoring to force all SR messages through the SR class. Also fixed a memory leak in the SR itself.
git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@3163 19bc5d8c-e614-43d4-8b26-e1612bc8e597
This commit is contained in:
@@ -207,20 +207,20 @@ void Control::LocationUpdatingController(const L3LocationUpdatingRequest* lur, L
|
|||||||
}
|
}
|
||||||
|
|
||||||
//query subscriber registry for old imei, update if neccessary
|
//query subscriber registry for old imei, update if neccessary
|
||||||
char* old_imei;
|
|
||||||
string name = string("IMSI") + IMSI;
|
string name = string("IMSI") + IMSI;
|
||||||
sqlite3_single_lookup(gSubscriberRegistry.db(), "sip_buddies", "name", name.c_str(),
|
char* old_imei = gSubscriberRegistry.sqlQuery("hardware", "sip_buddies", "name", name.c_str());
|
||||||
"hardware", old_imei);
|
|
||||||
|
|
||||||
//if we have a new imei and either there's no old one, or it is different...
|
//if we have a new imei and either there's no old one, or it is different...
|
||||||
if (new_imei && (!old_imei || strncmp(old_imei,new_imei, 15) != 0)){
|
if (new_imei && (!old_imei || strncmp(old_imei,new_imei, 15) != 0)){
|
||||||
ostringstream os2;
|
ostringstream os2;
|
||||||
os2 << "update sip_buddies set RRLPSupported = \"1\", hardware = \"" << new_imei << "\" where name = \"IMSI" << IMSI << "\"";
|
os2 << "update sip_buddies set RRLPSupported = \"1\", hardware = \"" << new_imei << "\" where name = \"IMSI" << IMSI << "\"";
|
||||||
LOG(INFO) << "Updating IMSI" << IMSI << " to IMEI:" << new_imei;
|
LOG(INFO) << "Updating IMSI" << IMSI << " to IMEI:" << new_imei;
|
||||||
if (!sqlite3_command(gSubscriberRegistry.db(), os2.str().c_str())) {
|
if (!gSubscriberRegistry.sqlUpdate(os2.str().c_str())) {
|
||||||
LOG(INFO) << "sqlite3_command problem";
|
LOG(INFO) << "SR update problem";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (old_imei)
|
||||||
|
free(old_imei);
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ using namespace std;
|
|||||||
#include <GSMLogicalChannel.h>
|
#include <GSMLogicalChannel.h>
|
||||||
#include <GSML3MMMessages.h>
|
#include <GSML3MMMessages.h>
|
||||||
|
|
||||||
|
#include <SubscriberRegistry.h>
|
||||||
|
|
||||||
#include <Logger.h>
|
#include <Logger.h>
|
||||||
|
|
||||||
using namespace GSM;
|
using namespace GSM;
|
||||||
@@ -99,9 +101,12 @@ RRLPServer::RRLPServer(L3MobileIdentity wMobileID, LogicalChannel *wDCCH)
|
|||||||
//otherwise just go on
|
//otherwise just go on
|
||||||
if (gConfig.defines("Control.LUR.QueryIMEI")){
|
if (gConfig.defines("Control.LUR.QueryIMEI")){
|
||||||
unsigned int supported = 0;
|
unsigned int supported = 0;
|
||||||
|
char* supported_str;
|
||||||
//check supported bit
|
//check supported bit
|
||||||
sqlite3_single_lookup(gSubscriberRegistry.db(), "sip_buddies", "name", name.c_str(),
|
supported_str = gSubscriberRegistry.sqlQuery("RRLPSupported", "sip_buddies", "name", name.c_str());
|
||||||
"RRLPSupported", supported);
|
if (supported_str)
|
||||||
|
supported = atoi(supported_str);
|
||||||
|
free(supported_str);
|
||||||
if(!supported){
|
if(!supported){
|
||||||
LOG(INFO) << "RRLP not supported for " << name;
|
LOG(INFO) << "RRLP not supported for " << name;
|
||||||
trouble = true;
|
trouble = true;
|
||||||
@@ -186,8 +191,8 @@ bool RRLPServer::transact()
|
|||||||
"datetime('now')"
|
"datetime('now')"
|
||||||
")";
|
")";
|
||||||
LOG(INFO) << os.str();
|
LOG(INFO) << os.str();
|
||||||
if (!sqlite3_command(gSubscriberRegistry.db(), os.str().c_str())) {
|
if (!gSubscriberRegistry.sqlUpdate(os.str().c_str())) {
|
||||||
LOG(INFO) << "sqlite3_command problem";
|
LOG(INFO) << "SR update problem";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -246,8 +251,8 @@ bool RRLPServer::transact()
|
|||||||
if (gConfig.defines("Control.LUR.QueryIMEI")){
|
if (gConfig.defines("Control.LUR.QueryIMEI")){
|
||||||
// flag unsupported in SR so we don't waste time on it again
|
// flag unsupported in SR so we don't waste time on it again
|
||||||
os2 << "update sip_buddies set RRLPSupported = \"0\" where name = \"" << name.c_str() << "\"";
|
os2 << "update sip_buddies set RRLPSupported = \"0\" where name = \"" << name.c_str() << "\"";
|
||||||
if (!sqlite3_command(gSubscriberRegistry.db(), os2.str().c_str())) {
|
if (!gSubscriberRegistry.sqlUpdate(os2.str().c_str())) {
|
||||||
LOG(INFO) << "sqlite3_command problem";
|
LOG(INFO) << "SR update problem";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -312,9 +312,16 @@ SubscriberRegistry::Status SubscriberRegistry::addUser(const char* IMSI, const c
|
|||||||
LOG(WARNING) << "SubscriberRegistry::addUser attempting add of NULL CLID";
|
LOG(WARNING) << "SubscriberRegistry::addUser attempting add of NULL CLID";
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
if (getIMSI(CLID) != NULL || getCLIDLocal(IMSI) != NULL) {
|
//this was a memory leak -kurtis
|
||||||
|
char* old_imsi = getIMSI(CLID);
|
||||||
|
char* old_clid = getCLIDLocal(IMSI);
|
||||||
|
if (old_imsi || old_clid) {
|
||||||
LOG(WARNING) << "SubscriberRegistry::addUser attempting user duplication";
|
LOG(WARNING) << "SubscriberRegistry::addUser attempting user duplication";
|
||||||
// technically this is a failure, but I don't want it to keep trying
|
// technically this is a failure, but I don't want it to keep trying
|
||||||
|
if (old_imsi)
|
||||||
|
free(old_imsi);
|
||||||
|
if (old_clid)
|
||||||
|
free(old_clid);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
LOG(INFO) << "addUser(" << IMSI << "," << CLID << ")";
|
LOG(INFO) << "addUser(" << IMSI << "," << CLID << ")";
|
||||||
|
|||||||
@@ -117,19 +117,8 @@ class SubscriberRegistry {
|
|||||||
bool useGateway(const char* ISDN);
|
bool useGateway(const char* ISDN);
|
||||||
|
|
||||||
|
|
||||||
private:
|
/* Generic Update/Get functions.
|
||||||
|
Make sure your SQL is generic too */
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Run sql statments locally.
|
|
||||||
@param stmt The sql statements.
|
|
||||||
@param resultptr Set this to point to the result of executing the statements.
|
|
||||||
*/
|
|
||||||
Status sqlLocal(const char *stmt, char **resultptr);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Run an sql query (select unknownColumn from table where knownColumn = knownValue).
|
Run an sql query (select unknownColumn from table where knownColumn = knownValue).
|
||||||
@param unknownColumn The column whose value you want.
|
@param unknownColumn The column whose value you want.
|
||||||
@@ -150,6 +139,15 @@ class SubscriberRegistry {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Run sql statments locally.
|
||||||
|
@param stmt The sql statements.
|
||||||
|
@param resultptr Set this to point to the result of executing the statements.
|
||||||
|
*/
|
||||||
|
Status sqlLocal(const char *stmt, char **resultptr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user