mirror of
				https://github.com/RangeNetworks/openbts.git
				synced 2025-11-04 05:43:14 +00:00 
			
		
		
		
	Fixes #692 in public. This updates the SR (ip/port) for a user on every SIP transaction. Also standardizes SR interface to use just strings, no more external char*. Will modify actual SR later.
git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@3236 19bc5d8c-e614-43d4-8b26-e1612bc8e597
This commit is contained in:
		@@ -201,26 +201,25 @@ void Control::LocationUpdatingController(const L3LocationUpdatingRequest* lur, L
 | 
			
		||||
			throw UnexpectedMessage();
 | 
			
		||||
		}
 | 
			
		||||
		LOG(INFO) << *resp;
 | 
			
		||||
		const char* new_imei = resp->mobileID().digits();
 | 
			
		||||
		if (!gTMSITable.IMEI(IMSI,new_imei)){
 | 
			
		||||
		string new_imei = resp->mobileID().digits();
 | 
			
		||||
		if (!gTMSITable.IMEI(IMSI,new_imei.c_str())){
 | 
			
		||||
			LOG(WARNING) << "failed access to TMSITable";
 | 
			
		||||
		} 
 | 
			
		||||
 | 
			
		||||
		//query subscriber registry for old imei, update if neccessary
 | 
			
		||||
		string name = string("IMSI") + IMSI;
 | 
			
		||||
		char* old_imei = gSubscriberRegistry.sqlQuery("hardware", "sip_buddies", "name", name.c_str());
 | 
			
		||||
		string old_imei = gSubscriberRegistry.imsiGet(name, "hardware");
 | 
			
		||||
		
 | 
			
		||||
		//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)){
 | 
			
		||||
			ostringstream os2;
 | 
			
		||||
			os2 << "update sip_buddies set RRLPSupported = \"1\", hardware = \"" << new_imei << "\" where name = \"IMSI" << IMSI << "\"";
 | 
			
		||||
		if (!new_imei.empty() && (old_imei.empty() || old_imei != new_imei)){
 | 
			
		||||
			LOG(INFO) << "Updating IMSI" << IMSI << " to IMEI:" << new_imei;
 | 
			
		||||
			if (!gSubscriberRegistry.sqlUpdate(os2.str().c_str())) {
 | 
			
		||||
				LOG(INFO) << "SR update problem";
 | 
			
		||||
			if (!gSubscriberRegistry.imsiSet(name,"RRLPSupported", "1")) {
 | 
			
		||||
			 	LOG(INFO) << "SR RRLPSupported update problem";
 | 
			
		||||
			}
 | 
			
		||||
			if (!gSubscriberRegistry.imsiSet(name,"hardware", new_imei)) {
 | 
			
		||||
				LOG(INFO) << "SR hardware update problem";
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if (old_imei)
 | 
			
		||||
			free(old_imei);
 | 
			
		||||
		delete msg;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -100,14 +100,9 @@ RRLPServer::RRLPServer(L3MobileIdentity wMobileID, LogicalChannel *wDCCH)
 | 
			
		||||
	//if IMEI tagging enabled, check if this IMEI (which is updated elsewhere) has RRLP disabled
 | 
			
		||||
	//otherwise just go on
 | 
			
		||||
	if (gConfig.defines("Control.LUR.QueryIMEI")){
 | 
			
		||||
		unsigned int supported = 0;
 | 
			
		||||
		char* supported_str;
 | 
			
		||||
		//check supported bit
 | 
			
		||||
		supported_str = gSubscriberRegistry.sqlQuery("RRLPSupported", "sip_buddies", "name", name.c_str());
 | 
			
		||||
		if (supported_str)
 | 
			
		||||
			supported = atoi(supported_str);
 | 
			
		||||
			free(supported_str);
 | 
			
		||||
		if(!supported){
 | 
			
		||||
		string supported= gSubscriberRegistry.imsiGet(name, "RRLPSupported");
 | 
			
		||||
		if(supported.empty() || supported == "0"){
 | 
			
		||||
			LOG(INFO) << "RRLP not supported for " << name;
 | 
			
		||||
			trouble = true;
 | 
			
		||||
		}
 | 
			
		||||
@@ -181,17 +176,12 @@ bool RRLPServer::transact()
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// quit if location decoded 
 | 
			
		||||
		if (response.find("latitude") != response.end() && response.find("longitude") != response.end() && response.find("positionError") != response.end()) {
 | 
			
		||||
			ostringstream os;
 | 
			
		||||
			os << "insert into RRLP (name, latitude, longitude, error, time) values (" <<
 | 
			
		||||
				'"' << name << '"' << "," <<
 | 
			
		||||
				response["latitude"] << "," <<
 | 
			
		||||
				response["longitude"] << "," <<
 | 
			
		||||
				response["positionError"] << "," <<
 | 
			
		||||
				"datetime('now')"
 | 
			
		||||
			")";
 | 
			
		||||
			LOG(INFO) << os.str();
 | 
			
		||||
			if (!gSubscriberRegistry.sqlUpdate(os.str().c_str())) {
 | 
			
		||||
		if (response.find("latitude") != response.end() && 
 | 
			
		||||
		    response.find("longitude") != response.end() && 
 | 
			
		||||
		    response.find("positionError") != response.end()) {
 | 
			
		||||
			if (!gSubscriberRegistry.RRLPUpdate(name, response["latitude"], 
 | 
			
		||||
							    response["longitude"], 
 | 
			
		||||
							    response["positionError"])){
 | 
			
		||||
				LOG(INFO) << "SR update problem";
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
@@ -241,7 +231,6 @@ bool RRLPServer::transact()
 | 
			
		||||
		}
 | 
			
		||||
		const unsigned MTI_RR_STATUS = 18;
 | 
			
		||||
		if (resp->MTI() == MTI_RR_STATUS) {
 | 
			
		||||
			ostringstream os2;
 | 
			
		||||
			int cause = resp->peekField(16, 8);
 | 
			
		||||
			delete resp;
 | 
			
		||||
			switch (cause) {
 | 
			
		||||
@@ -250,8 +239,7 @@ bool RRLPServer::transact()
 | 
			
		||||
					//Rejection code only useful if we're gathering IMEIs
 | 
			
		||||
					if (gConfig.defines("Control.LUR.QueryIMEI")){
 | 
			
		||||
						// 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() << "\"";
 | 
			
		||||
						if (!gSubscriberRegistry.sqlUpdate(os2.str().c_str())) {
 | 
			
		||||
						if (!gSubscriberRegistry.imsiSet(name, "RRLPSupported", "0")) {
 | 
			
		||||
							LOG(INFO) << "SR update problem";
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user