Author: dburgess
Date: 2011-11-19 18:22:41 -0600 (Sat, 19 Nov 2011)
New Revision: 2583
Added:
software/public/subscriberRegistry/features/a3a8/
Modified:
software/public/CommonLibs/trunk/Logger.cpp
software/public/CommonLibs/trunk/Logger.h
software/public/openbts/trunk/CommonLibs/Logger.cpp
software/public/openbts/trunk/CommonLibs/Logger.h
software/public/subscriberRegistry/features/a3a8/Makefile
software/public/subscriberRegistry/features/a3a8/SubscriberRegistry.cpp
software/public/subscriberRegistry/features/a3a8/SubscriberRegistry.h
software/public/subscriberRegistry/trunk/SubscriberRegistry.cpp
Log:
Brining A3/A8 into the sipauthserve public release.
Modified: software/public/CommonLibs/trunk/Logger.cpp
===================================================================
--- software/public/CommonLibs/trunk/Logger.cpp 2011-11-19 20:11:10 UTC (rev 2582)
+++ software/public/CommonLibs/trunk/Logger.cpp 2011-11-20 00:22:41 UTC (rev 2583)
@@ -150,6 +150,7 @@
Log::~Log()
{
+ if (mDummyInit) return;
// Anything at or above LOG_CRIT is an "alarm".
// Save alarms in the local list and echo them to stderr.
if (mPriority <= LOG_CRIT) {
@@ -162,6 +163,13 @@
}
+Log::Log(const char* name, const char* level, int facility)
+{
+ mDummyInit = true;
+ gLogInit(name, level, facility);
+}
+
+
ostringstream& Log::get()
{
assert(mPriority<numLevels);
Modified: software/public/CommonLibs/trunk/Logger.h
===================================================================
--- software/public/CommonLibs/trunk/Logger.h 2011-11-19 20:11:10 UTC (rev 2582)
+++ software/public/CommonLibs/trunk/Logger.h 2011-11-20 00:22:41 UTC (rev 2583)
@@ -40,10 +40,18 @@
#define _LOG(level) \
Log(LOG_##level).get() << pthread_self() \
<< " " __FILE__ ":" << __LINE__ << ":" << __FUNCTION__ << ": "
+
+#ifdef NDEBUG
#define LOG(wLevel) \
+ if (LOG_##wLevel!=LOG_DEBUG && gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel)
+#else
+#define LOG(wLevel) \
if (gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel)
+#endif
+
+
#define OBJLOG(wLevel) \
- if (gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel) << "obj: " << this << ' '
+ LOG(wLevel) << "obj: " << this << ' '
#define LOG_ASSERT(x) { if (!(x)) LOG(EMERG) << "assertion " #x " failed"; } assert(x);
@@ -66,13 +74,16 @@
std::ostringstream mStream; ///< This is where we buffer up the log entry.
int mPriority; ///< Priority of current repot.
+ bool mDummyInit;
public:
Log(int wPriority)
- :mPriority(wPriority)
+ :mPriority(wPriority), mDummyInit(false)
{ }
+ Log(const char* name, const char* level=NULL, int facility=LOG_USER);
+
// Most of the work is in the desctructor.
/** The destructor actually generates the log entry. */
~Log();
Modified: software/public/openbts/trunk/CommonLibs/Logger.cpp
===================================================================
--- software/public/openbts/trunk/CommonLibs/Logger.cpp 2011-11-19 20:11:10 UTC (rev 2582)
+++ software/public/openbts/trunk/CommonLibs/Logger.cpp 2011-11-20 00:22:41 UTC (rev 2583)
@@ -150,6 +150,7 @@
Log::~Log()
{
+ if (mDummyInit) return;
// Anything at or above LOG_CRIT is an "alarm".
// Save alarms in the local list and echo them to stderr.
if (mPriority <= LOG_CRIT) {
@@ -162,6 +163,13 @@
}
+Log::Log(const char* name, const char* level, int facility)
+{
+ mDummyInit = true;
+ gLogInit(name, level, facility);
+}
+
+
ostringstream& Log::get()
{
assert(mPriority<numLevels);
Modified: software/public/openbts/trunk/CommonLibs/Logger.h
===================================================================
--- software/public/openbts/trunk/CommonLibs/Logger.h 2011-11-19 20:11:10 UTC (rev 2582)
+++ software/public/openbts/trunk/CommonLibs/Logger.h 2011-11-20 00:22:41 UTC (rev 2583)
@@ -40,10 +40,18 @@
#define _LOG(level) \
Log(LOG_##level).get() << pthread_self() \
<< " " __FILE__ ":" << __LINE__ << ":" << __FUNCTION__ << ": "
+
+#ifdef NDEBUG
#define LOG(wLevel) \
+ if (LOG_##wLevel!=LOG_DEBUG && gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel)
+#else
+#define LOG(wLevel) \
if (gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel)
+#endif
+
+
#define OBJLOG(wLevel) \
- if (gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel) << "obj: " << this << ' '
+ LOG(wLevel) << "obj: " << this << ' '
#define LOG_ASSERT(x) { if (!(x)) LOG(EMERG) << "assertion " #x " failed"; } assert(x);
@@ -66,13 +74,16 @@
std::ostringstream mStream; ///< This is where we buffer up the log entry.
int mPriority; ///< Priority of current repot.
+ bool mDummyInit;
public:
Log(int wPriority)
- :mPriority(wPriority)
+ :mPriority(wPriority), mDummyInit(false)
{ }
+ Log(const char* name, const char* level=NULL, int facility=LOG_USER);
+
// Most of the work is in the desctructor.
/** The destructor actually generates the log entry. */
~Log();
Modified: software/public/subscriberRegistry/features/a3a8/Makefile
===================================================================
--- software/commercial/subscriberRegistry/trunk/Makefile 2011-11-19 13:50:50 UTC (rev 2578)
+++ software/public/subscriberRegistry/features/a3a8/Makefile 2011-11-20 00:22:41 UTC (rev 2583)
@@ -1,21 +1,14 @@
-TRUNK=../../
-COM=$(TRUNK)/CommonLibs/trunk/
-#SQL=$(TRUNK)/sqlite3/trunk/
-SQL=../../smqueue/trunk/sqlite3/
-SR=$(TRUNK)/subscriberRegistry/trunk
-LOCALLIBS=$(COM)/Logger.cpp $(COM)/Timeval.cpp $(COM)/Threads.cpp $(COM)/Sockets.cpp $(COM)/Configuration.cpp $(SQL)/sqlite3util.cpp $(SR)/SubscriberRegistry.cpp servershare.cpp
-LIBS= -L$(SQL) $(LOCALLIBS) -losipparser2 -losip2 -lc -lpthread -lsqlite
-INCLUDES=-I$(COM) -I$(SQL) -I$(SR)
+TRUNK=../../../openbts/trunk
+COM=$(TRUNK)/CommonLibs
+SQL=$(TRUNK)/sqlite3
+#SR=$(TRUNK)/subscriberRegistry/trunk-public-staging
+LOCALLIBS=$(COM)/Logger.cpp $(COM)/Timeval.cpp $(COM)/Threads.cpp $(COM)/Sockets.cpp $(COM)/Configuration.cpp $(SQL)/sqlite3util.cpp SubscriberRegistry.cpp servershare.cpp
+LIBS=$(LOCALLIBS) -losipparser2 -losip2 -lc -lpthread -lsqlite3
+INCLUDES=-I$(COM) -I$(SQL)
CPPFLAGS=-g -Wall -Wno-deprecated
-all: comp128 srmanager.cgi subscriberserver.cgi sipauthserve
+all: srmanager.cgi sipauthserve
-comp128: comp128.c
- g++ -o comp128 comp128.c
-
-subscriberserver.cgi: subscriberserver.cpp $(LOCALLIBS)
- g++ -o subscriberserver.cgi $(CPPFLAGS) $(INCLUDES) subscriberserver.cpp $(LIBS)
-
srmanager.cgi: srmanager.cpp $(LOCALLIBS)
g++ -o srmanager.cgi $(CPPFLAGS) $(INCLUDES) srmanager.cpp $(LIBS)
@@ -23,21 +16,5 @@
g++ -o sipauthserve $(CPPFLAGS) $(INCLUDES) sipauthserve.cpp $(LIBS)
clean:
- rm -f comp128 subscriberserver.cgi srmanager.cgi sipauthserve test.SubscriberRegistry/test
+ rm -f srmanager.cgi sipauthserve test.SubscriberRegistry/test
rm -r -f *.dSYM
-
-# this needs "local7.debug<at least one tab>/var/log/openbts.log" in /etc/syslog.conf
-test: all
- cd test.SubscriberRegistry; ./runtest
- cd test.sipauthserve; ./runtest
- cd test.srmanager; ./runtest
- cd test.subscriberserver; ./runtest
-
-just3: all
- cd test.SubscriberRegistry; ./runtest
- cd test.srmanager; ./runtest
- cd test.subscriberserver; ./runtest
-
-# specifically for boa web server
-install: all
- cp srmanager.cgi subscriberserver.cgi /var/www
Modified: software/public/subscriberRegistry/features/a3a8/SubscriberRegistry.cpp
===================================================================
--- software/commercial/subscriberRegistry/trunk/SubscriberRegistry.cpp 2011-11-19 13:50:50 UTC (rev 2578)
+++ software/public/subscriberRegistry/features/a3a8/SubscriberRegistry.cpp 2011-11-20 00:22:41 UTC (rev 2583)
@@ -144,8 +144,6 @@
"sres varchar(33) default '', "
"ki varchar(33) default '', "
"kc varchar(33) default '', "
- "prepaid int(1) DEFAULT 0 not null, "
- "secondsRemaining int(11) DEFAULT 0 not null, "
"RRLPSupported int(1) default 1 not null, "
"regTime INTEGER default 0 NOT NULL, " // Unix time of most recent registration
"a3_a8 varchar(45) default NULL"
@@ -512,68 +510,7 @@
-bool SubscriberRegistry::useGateway(const char* ISDN)
-{
- // FIXME -- Do something more general in Asterisk.
- // This is a hack for Burning Man.
- int cmp = strncmp(ISDN,"88351000125",11);
- return cmp!=0;
-}
-
-
-SubscriberRegistry::Status SubscriberRegistry::setPrepaid(const char *IMSI, bool yes)
-{
- ostringstream os;
- os << "update sip_buddies set prepaid = " << (yes ? 1 : 0) << " where name = " << '"' << IMSI << '"';
- return sqlUpdate(os.str().c_str());
-}
-
-
-SubscriberRegistry::Status SubscriberRegistry::isPrepaid(const char *IMSI, bool &yes)
-{
- char *st = sqlQuery("prepaid", "sip_buddies", "name", IMSI);
- if (!st) return FAILURE;
- yes = *st == '1';
- free(st);
- return SUCCESS;
-}
-
-
-SubscriberRegistry::Status SubscriberRegistry::secondsRemaining(const char *IMSI, int &seconds)
-{
- char *st = sqlQuery("secondsRemaining", "sip_buddies", "name", IMSI);
- if (!st) return FAILURE;
- seconds = (int)strtol(st, (char **)NULL, 10);
- free(st);
- return SUCCESS;
-}
-
-
-SubscriberRegistry::Status SubscriberRegistry::addSeconds(const char *IMSI, int secondsToAdd, int &wSecondsRemaining)
-{
- ostringstream os;
- os << "update sip_buddies set secondsRemaining = secondsRemaining + " << secondsToAdd << " where name = " << '"' << IMSI << '"';
- if (sqlUpdate(os.str().c_str()) == FAILURE) return FAILURE;
- int n;
- if (secondsRemaining(IMSI, n) == FAILURE) return FAILURE;
- if (n < 0) {
- wSecondsRemaining = 0;
- } else {
- wSecondsRemaining = n;
- }
- return SUCCESS;
-}
-
-
-SubscriberRegistry::Status SubscriberRegistry::setSeconds(const char *IMSI, int seconds)
-{
- ostringstream os;
- os << "update sip_buddies set secondsRemaining = " << seconds << " where name = " << '"' << IMSI << '"';
- return sqlUpdate(os.str().c_str());
-}
-
-
HttpQuery::HttpQuery(const char *req)
{
sends = map<string,string>();
Modified: software/public/subscriberRegistry/features/a3a8/SubscriberRegistry.h
===================================================================
--- software/commercial/subscriberRegistry/trunk/SubscriberRegistry.h 2011-11-19 13:50:50 UTC (rev 2578)
+++ software/public/subscriberRegistry/features/a3a8/SubscriberRegistry.h 2011-11-20 00:22:41 UTC (rev 2583)
@@ -155,55 +155,6 @@
- bool useGateway(const char* ISDN);
-
-
- /**
- Set whether a subscriber is prepaid.
- @param IMSI Subscriber's IMSI
- @param yes true for prepaid, false for postpaid
- @return SUCCESS or FAILURE
- */
- Status setPrepaid(const char *IMSI, bool yes);
-
-
- /**
- Is a subscriber postpaid?
- @param IMSI Subscriber's IMSI
- @param yes set to true if subscriber is postpaid, false if prepaid
- @return SUCCESS or FAILURE
- */
- Status isPrepaid(const char *IMSI, bool &yes);
-
-
- /**
- Get the seconds remaining in a subscriber's account.
- @param IMSI Subscriber's IMSI
- @param seconds set to number of seconds remaining
- @return SUCCESS or FAILURE
- */
- Status secondsRemaining(const char *IMSI, int &seconds);
-
-
- /**
- Atomic operation to add seconds to subscriber's account and return remaining seconds
- @param IMSI subscriber's IMSI
- @param secondsToAdd seconds to add (negative to subtract)
- @param secondsRemaining set to seconds remaining after addition
- @return SUCCESS or FAILURE
- */
- Status addSeconds(const char *IMSI, int secondsToAdd, int &secondsRemaining);
-
-
- /**
- Set the number of seconds in a subscriber's account
- @param IMSI subscriber's IMSI
- @param seconds number of seconds to which to set subscriber's account
- @return SUCCESS or FAILURE
- */
- Status setSeconds(const char *IMSI, int seconds);
-
-
private:
Modified: software/public/subscriberRegistry/trunk/SubscriberRegistry.cpp
===================================================================
--- software/public/subscriberRegistry/trunk/SubscriberRegistry.cpp 2011-11-19 20:11:10 UTC (rev 2582)
+++ software/public/subscriberRegistry/trunk/SubscriberRegistry.cpp 2011-11-20 00:22:41 UTC (rev 2583)
@@ -144,8 +144,6 @@
"sres varchar(33) default '', "
"ki varchar(33) default '', "
"kc varchar(33) default '', "
- "prepaid int(1) DEFAULT 0 not null, "
- "secondsRemaining int(11) DEFAULT 0 not null, "
"RRLPSupported int(1) default 1 not null, "
"regTime INTEGER default 0 NOT NULL, " // Unix time of most recent registration
"a3_a8 varchar(45) default NULL"
|