From 2c1c69d9e4ac1a01ee65889ceed2769161dc8136 Mon Sep 17 00:00:00 2001 From: Kurtis Heimerl Date: Sat, 24 Mar 2012 22:38:08 +0000 Subject: [PATCH] moved subscriberRegistry code around SIPInterface so that it only updates on an outgoing REGISTER, INVITE, or MESSAGE git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@3361 19bc5d8c-e614-43d4-8b26-e1612bc8e597 --- SIP/SIPInterface.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/SIP/SIPInterface.cpp b/SIP/SIPInterface.cpp index 6ff4324..1f21edc 100644 --- a/SIP/SIPInterface.cpp +++ b/SIP/SIPInterface.cpp @@ -60,15 +60,6 @@ using namespace Control; void SIPMessageMap::write(const std::string& call_id, osip_message_t * msg) { LOG(DEBUG) << "call_id=" << call_id << " msg=" << msg; - string name = osip_message_get_from(msg)->url->username; - if (gSubscriberRegistry.imsiSet(name, "ipaddr", - osip_message_get_from(msg)->url->host)){ - LOG(INFO) << "SR ipaddr Update Problem"; - } - if (gSubscriberRegistry.imsiSet(name, "port", - gConfig.getStr("SIP.Local.Port"))){ - LOG(INFO) << "SR port Update Problem"; - } OSIPMessageFIFO * fifo = mMap.readNoBlock(call_id); if( fifo==NULL ) { // FIXME -- If this write fails, send "call leg non-existent" response on SIP interface. @@ -167,6 +158,21 @@ void SIPInterface::write(const struct sockaddr_in* dest, osip_message_t *msg) LOG(ERR) << "osip_message_to_str produced a NULL pointer."; return; } + //if it's any of these transactions, record it in the database + string name = osip_message_get_from(msg)->url->username; + if (msg->sip_method && + (!strncmp(msg->sip_method, "INVITE", 6) || + !strncmp(msg->sip_method, "REGISTER", 8) || + !strncmp(msg->sip_method, "MESSAGE", 7))) { + if (gSubscriberRegistry.imsiSet(name, "ipaddr", + osip_message_get_from(msg)->url->host)){ + LOG(INFO) << "SR ipaddr Update Problem"; + } + if (gSubscriberRegistry.imsiSet(name, "port", + gConfig.getStr("SIP.Local.Port"))){ + LOG(INFO) << "SR port Update Problem"; + } + } char firstLine[100]; sscanf(str,"%100[^\n]",firstLine); LOG(INFO) << "write " << firstLine;