Make functions and variables in OpenBTS.cpp static to avoid their use outside of the file.
This commit is contained in:
parent
7a3d355655
commit
0e6f974b1e
|
@ -85,41 +85,40 @@ protected:
|
||||||
int mLockFileFD;
|
int mLockFileFD;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load configuration from a file.
|
/// Load configuration from a file.
|
||||||
ConfigurationTable gConfig("OpenBTS.config");
|
ConfigurationTable gConfig("OpenBTS.config");
|
||||||
// Initialize Logger form the config.
|
/// Initialize Logger form the config.
|
||||||
LogInitializer gLogInitializer;
|
static LogInitializer sgLogInitializer;
|
||||||
// Fork daemon if needed.
|
/// Fork daemon if needed.
|
||||||
DaemonInitializer gDaemonInitializer(gConfig.defines("Server.Daemonize"));
|
static DaemonInitializer sgDaemonInitializer(gConfig.defines("Server.Daemonize"));
|
||||||
|
|
||||||
|
|
||||||
// All of the other globals that rely on the global configuration file need to
|
// All of the other globals that rely on the global configuration file need to
|
||||||
// be declared here.
|
// be declared here.
|
||||||
|
|
||||||
// The global SIPInterface object.
|
/// The global SIPInterface object.
|
||||||
SIP::SIPInterface gSIPInterface;
|
SIP::SIPInterface gSIPInterface;
|
||||||
|
|
||||||
// Configure the BTS object based on the config file.
|
/// Configure the BTS object based on the config file.
|
||||||
// So don't create this until AFTER loading the config file.
|
/// So don't create this until AFTER loading the config file.
|
||||||
GSMConfig gBTS;
|
GSMConfig gBTS;
|
||||||
|
|
||||||
// Our interface to the software-defined radio.
|
/// Our interface to the software-defined radio.
|
||||||
TransceiverManager gTRX(1, gConfig.getStr("TRX.IP"), gConfig.getNum("TRX.Port"));
|
TransceiverManager gTRX(1, gConfig.getStr("TRX.IP"), gConfig.getNum("TRX.Port"));
|
||||||
|
|
||||||
/// Pointer to the server socket if we run remote CLI.
|
/// Pointer to the server socket if we run remote CLI.
|
||||||
ConnectionServerSocket *gCLIServerSock = NULL;
|
static ConnectionServerSocket *sgCLIServerSock = NULL;
|
||||||
|
|
||||||
|
/// We store Transceiver PID if we started it.
|
||||||
|
static pid_t sgTransceiverPid = 0;
|
||||||
|
|
||||||
|
static void restartTransceiver()
|
||||||
pid_t gTransceiverPid = 0;
|
|
||||||
|
|
||||||
void restartTransceiver()
|
|
||||||
{
|
{
|
||||||
// This is harmless - if someone is running OpenBTS they WANT no transceiver
|
// This is harmless - if someone is running OpenBTS they WANT no transceiver
|
||||||
// instance at the start anyway.
|
// instance at the start anyway.
|
||||||
if (gTransceiverPid > 0) {
|
if (sgTransceiverPid > 0) {
|
||||||
LOG(INFO) << "RESTARTING TRANSCEIVER";
|
LOG(INFO) << "RESTARTING TRANSCEIVER";
|
||||||
kill(gTransceiverPid,SIGKILL); // TODO - call on ctrl-c (put in signal?)
|
kill(sgTransceiverPid,SIGKILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the transceiver binary, if the path is defined.
|
// Start the transceiver binary, if the path is defined.
|
||||||
|
@ -130,9 +129,9 @@ void restartTransceiver()
|
||||||
const char *TRXLogLevel = gConfig.getStr("TRX.LogLevel");
|
const char *TRXLogLevel = gConfig.getStr("TRX.LogLevel");
|
||||||
const char *TRXLogFileName = NULL;
|
const char *TRXLogFileName = NULL;
|
||||||
if (gConfig.defines("TRX.LogFileName")) TRXLogFileName=gConfig.getStr("TRX.LogFileName");
|
if (gConfig.defines("TRX.LogFileName")) TRXLogFileName=gConfig.getStr("TRX.LogFileName");
|
||||||
gTransceiverPid = vfork();
|
sgTransceiverPid = vfork();
|
||||||
LOG_ASSERT(gTransceiverPid>=0);
|
LOG_ASSERT(sgTransceiverPid>=0);
|
||||||
if (gTransceiverPid==0) {
|
if (sgTransceiverPid==0) {
|
||||||
// Pid==0 means this is the process that starts the transceiver.
|
// Pid==0 means this is the process that starts the transceiver.
|
||||||
execl(TRXPath,"transceiver",TRXLogLevel,TRXLogFileName,NULL);
|
execl(TRXPath,"transceiver",TRXLogLevel,TRXLogFileName,NULL);
|
||||||
LOG(ERROR) << "cannot start transceiver";
|
LOG(ERROR) << "cannot start transceiver";
|
||||||
|
@ -142,7 +141,7 @@ void restartTransceiver()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void startBTS()
|
static void startBTS()
|
||||||
{
|
{
|
||||||
cout << endl << "Starting the system..." << endl;
|
cout << endl << "Starting the system..." << endl;
|
||||||
|
|
||||||
|
@ -287,21 +286,21 @@ void startBTS()
|
||||||
LOG(INFO) << "system ready";
|
LOG(INFO) << "system ready";
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopBTS()
|
static void stopBTS()
|
||||||
{
|
{
|
||||||
if (!gBTS.hold()) {
|
if (!gBTS.hold()) {
|
||||||
exitBTS(0, cout);
|
exitBTS(0, cout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gTransceiverPid) kill(gTransceiverPid, SIGKILL);
|
if (sgTransceiverPid) kill(sgTransceiverPid, SIGKILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exitCLI()
|
static void exitCLI()
|
||||||
{
|
{
|
||||||
if (gCLIServerSock != NULL) {
|
if (sgCLIServerSock != NULL) {
|
||||||
// Closing server sock
|
// Closing server sock
|
||||||
gCLIServerSock->close();
|
sgCLIServerSock->close();
|
||||||
gCLIServerSock = NULL;
|
sgCLIServerSock = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Closing server standard input to shutdown local CLI
|
// Closing server standard input to shutdown local CLI
|
||||||
|
@ -506,14 +505,14 @@ int main(int argc, char *argv[])
|
||||||
if (strcasecmp(gConfig.getStr("CLI.Type"),"TCP") == 0) {
|
if (strcasecmp(gConfig.getStr("CLI.Type"),"TCP") == 0) {
|
||||||
ConnectionServerSocketTCP serverSock(gConfig.getNum("CLI.TCP.Port"),
|
ConnectionServerSocketTCP serverSock(gConfig.getNum("CLI.TCP.Port"),
|
||||||
gConfig.getStr("CLI.TCP.IP"));
|
gConfig.getStr("CLI.TCP.IP"));
|
||||||
gCLIServerSock = &serverSock;
|
sgCLIServerSock = &serverSock;
|
||||||
runCLIServer(&serverSock);
|
runCLIServer(&serverSock);
|
||||||
gCLIServerSock = NULL;
|
sgCLIServerSock = NULL;
|
||||||
} else if (strcasecmp(gConfig.getStr("CLI.Type"),"Unix") == 0) {
|
} else if (strcasecmp(gConfig.getStr("CLI.Type"),"Unix") == 0) {
|
||||||
ConnectionServerSocketUnix serverSock(gConfig.getStr("CLI.Unix.Path"));
|
ConnectionServerSocketUnix serverSock(gConfig.getStr("CLI.Unix.Path"));
|
||||||
gCLIServerSock = &serverSock;
|
sgCLIServerSock = &serverSock;
|
||||||
runCLIServer(&serverSock);
|
runCLIServer(&serverSock);
|
||||||
gCLIServerSock = NULL;
|
sgCLIServerSock = NULL;
|
||||||
} else {
|
} else {
|
||||||
runCLI(&gParser);
|
runCLI(&gParser);
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue