|
|
@ -108,33 +108,28 @@ int CYSFGateway::run()
|
|
|
|
|
|
|
|
|
|
|
|
setlocale(LC_ALL, "C");
|
|
|
|
setlocale(LC_ALL, "C");
|
|
|
|
|
|
|
|
|
|
|
|
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel());
|
|
|
|
|
|
|
|
if (!ret) {
|
|
|
|
|
|
|
|
::fprintf(stderr, "YSFGateway: unable to open the log file\n");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if !defined(_WIN32) && !defined(_WIN64)
|
|
|
|
#if !defined(_WIN32) && !defined(_WIN64)
|
|
|
|
bool m_daemon = m_conf.getDaemon();
|
|
|
|
bool m_daemon = m_conf.getDaemon();
|
|
|
|
if (m_daemon) {
|
|
|
|
if (m_daemon) {
|
|
|
|
// Create new process
|
|
|
|
// Create new process
|
|
|
|
pid_t pid = ::fork();
|
|
|
|
pid_t pid = ::fork();
|
|
|
|
if (pid == -1) {
|
|
|
|
if (pid == -1) {
|
|
|
|
::LogWarning("Couldn't fork() , exiting");
|
|
|
|
::fprintf(stderr, "Couldn't fork() , exiting\n");
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pid != 0)
|
|
|
|
else if (pid != 0) {
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Create new session and process group
|
|
|
|
// Create new session and process group
|
|
|
|
if (::setsid() == -1) {
|
|
|
|
if (::setsid() == -1) {
|
|
|
|
::LogWarning("Couldn't setsid(), exiting");
|
|
|
|
::fprintf(stderr, "Couldn't setsid(), exiting\n");
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Set the working directory to the root directory
|
|
|
|
// Set the working directory to the root directory
|
|
|
|
if (::chdir("/") == -1) {
|
|
|
|
if (::chdir("/") == -1) {
|
|
|
|
::LogWarning("Couldn't cd /, exiting");
|
|
|
|
::fprintf(stderr, "Couldn't cd /, exiting\n");
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -142,37 +137,43 @@ int CYSFGateway::run()
|
|
|
|
::close(STDOUT_FILENO);
|
|
|
|
::close(STDOUT_FILENO);
|
|
|
|
::close(STDERR_FILENO);
|
|
|
|
::close(STDERR_FILENO);
|
|
|
|
|
|
|
|
|
|
|
|
//If we are currently root...
|
|
|
|
// If we are currently root...
|
|
|
|
if (getuid() == 0) {
|
|
|
|
if (getuid() == 0) {
|
|
|
|
struct passwd* user = ::getpwnam("mmdvm");
|
|
|
|
struct passwd* user = ::getpwnam("mmdvm");
|
|
|
|
if (user == NULL) {
|
|
|
|
if (user == NULL) {
|
|
|
|
::LogError("Could not get the mmdvm user, exiting");
|
|
|
|
::fprintf(stderr, "Could not get the mmdvm user, exiting\n");
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uid_t mmdvm_uid = user->pw_uid;
|
|
|
|
uid_t mmdvm_uid = user->pw_uid;
|
|
|
|
gid_t mmdvm_gid = user->pw_gid;
|
|
|
|
gid_t mmdvm_gid = user->pw_gid;
|
|
|
|
|
|
|
|
|
|
|
|
//Set user and group ID's to mmdvm:mmdvm
|
|
|
|
// Set user and group ID's to mmdvm:mmdvm
|
|
|
|
if (setgid(mmdvm_gid) != 0) {
|
|
|
|
if (setgid(mmdvm_gid) != 0) {
|
|
|
|
::LogWarning("Could not set mmdvm GID, exiting");
|
|
|
|
::fprintf(stderr, "Could not set mmdvm GID, exiting\n");
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (setuid(mmdvm_uid) != 0) {
|
|
|
|
if (setuid(mmdvm_uid) != 0) {
|
|
|
|
::LogWarning("Could not set mmdvm UID, exiting");
|
|
|
|
::fprintf(stderr, "Could not set mmdvm UID, exiting\n");
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Double check it worked (AKA Paranoia)
|
|
|
|
// Double check it worked (AKA Paranoia)
|
|
|
|
if (setuid(0) != -1) {
|
|
|
|
if (setuid(0) != -1) {
|
|
|
|
::LogWarning("It's possible to regain root - something is wrong!, exiting");
|
|
|
|
::fprintf(stderr, "It's possible to regain root - something is wrong!, exiting\n");
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel());
|
|
|
|
|
|
|
|
if (!ret) {
|
|
|
|
|
|
|
|
::fprintf(stderr, "YSFGateway: unable to open the log file\n");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_callsign = m_conf.getCallsign();
|
|
|
|
m_callsign = m_conf.getCallsign();
|
|
|
|
m_suffix = m_conf.getSuffix();
|
|
|
|
m_suffix = m_conf.getSuffix();
|
|
|
|
|
|
|
|
|
|
|
@ -343,13 +344,10 @@ int CYSFGateway::run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_current.clear();
|
|
|
|
m_current.clear();
|
|
|
|
m_inactivityTimer.stop();
|
|
|
|
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
|
|
|
|
|
|
|
|
startupLinking();
|
|
|
|
startupLinking();
|
|
|
|
} else {
|
|
|
|
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (m_linkType == LINK_YSF) {
|
|
|
|
if (m_linkType == LINK_YSF) {
|
|
|
@ -366,10 +364,11 @@ int CYSFGateway::run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_current.clear();
|
|
|
|
m_current.clear();
|
|
|
|
m_inactivityTimer.stop();
|
|
|
|
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_lostTimer.clock(ms);
|
|
|
|
m_lostTimer.clock(ms);
|
|
|
@ -386,7 +385,7 @@ int CYSFGateway::run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_current.clear();
|
|
|
|
m_current.clear();
|
|
|
|
m_inactivityTimer.stop();
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -427,9 +426,10 @@ void CYSFGateway::createGPS()
|
|
|
|
std::string hostname = m_conf.getAPRSServer();
|
|
|
|
std::string hostname = m_conf.getAPRSServer();
|
|
|
|
unsigned int port = m_conf.getAPRSPort();
|
|
|
|
unsigned int port = m_conf.getAPRSPort();
|
|
|
|
std::string password = m_conf.getAPRSPassword();
|
|
|
|
std::string password = m_conf.getAPRSPassword();
|
|
|
|
|
|
|
|
std::string suffix = m_conf.getAPRSSuffix();
|
|
|
|
std::string desc = m_conf.getAPRSDescription();
|
|
|
|
std::string desc = m_conf.getAPRSDescription();
|
|
|
|
|
|
|
|
|
|
|
|
m_gps = new CGPS(m_callsign, m_suffix, password, hostname, port);
|
|
|
|
m_gps = new CGPS(m_callsign, m_suffix, password, hostname, port, suffix);
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int txFrequency = m_conf.getTxFrequency();
|
|
|
|
unsigned int txFrequency = m_conf.getTxFrequency();
|
|
|
|
unsigned int rxFrequency = m_conf.getRxFrequency();
|
|
|
|
unsigned int rxFrequency = m_conf.getRxFrequency();
|
|
|
@ -523,7 +523,7 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u
|
|
|
|
m_fcsNetwork->writeUnlink(3U);
|
|
|
|
m_fcsNetwork->writeUnlink(3U);
|
|
|
|
|
|
|
|
|
|
|
|
m_current.clear();
|
|
|
|
m_current.clear();
|
|
|
|
m_inactivityTimer.stop();
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
|
|
|
|
|
|
|
@ -536,7 +536,6 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u
|
|
|
|
bool ok = m_fcsNetwork->writeLink(name);
|
|
|
|
bool ok = m_fcsNetwork->writeLink(name);
|
|
|
|
if (ok) {
|
|
|
|
if (ok) {
|
|
|
|
m_current = name;
|
|
|
|
m_current = name;
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
|
|
|
|
m_lostTimer.start();
|
|
|
|
m_lostTimer.start();
|
|
|
|
m_linkType = LINK_FCS;
|
|
|
|
m_linkType = LINK_FCS;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -552,7 +551,7 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u
|
|
|
|
m_ysfNetwork->clearDestination();
|
|
|
|
m_ysfNetwork->clearDestination();
|
|
|
|
|
|
|
|
|
|
|
|
m_current.clear();
|
|
|
|
m_current.clear();
|
|
|
|
m_inactivityTimer.stop();
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -563,7 +562,7 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, u
|
|
|
|
m_fcsNetwork->clearDestination();
|
|
|
|
m_fcsNetwork->clearDestination();
|
|
|
|
|
|
|
|
|
|
|
|
m_current.clear();
|
|
|
|
m_current.clear();
|
|
|
|
m_inactivityTimer.stop();
|
|
|
|
m_inactivityTimer.start();
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_lostTimer.stop();
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
m_linkType = LINK_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -774,6 +773,8 @@ void CYSFGateway::startupLinking()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_startup.empty())
|
|
|
|
|
|
|
|
LogMessage("No connection startup");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CYSFGateway::readFCSRoomsFile(const std::string& filename)
|
|
|
|
void CYSFGateway::readFCSRoomsFile(const std::string& filename)
|
|
|
|