K&R formating and warnings fixed.

ki4klf
ac2ie 12 years ago
parent dd4fb774e2
commit 90862645f6

@ -64,12 +64,9 @@ IRCClient::IRCClient( IRCApplication * app, const wxString& update_channel,
this -> app = app; this -> app = app;
if (localAddr.IsEmpty()) if (localAddr.IsEmpty()) {
{
safeStringCopy(local_addr, "0.0.0.0", sizeof local_addr); safeStringCopy(local_addr, "0.0.0.0", sizeof local_addr);
} } else {
else
{
safeStringCopy(local_addr, localAddr.mb_str(), sizeof local_addr); safeStringCopy(local_addr, localAddr.mb_str(), sizeof local_addr);
} }
@ -89,16 +86,14 @@ IRCClient::~IRCClient()
bool IRCClient::startWork() bool IRCClient::startWork()
{ {
if (Create() != wxTHREAD_NO_ERROR) if (Create() != wxTHREAD_NO_ERROR) {
{
wxLogError(wxT("IRCClient::startWork: Could not create the worker thread!")); wxLogError(wxT("IRCClient::startWork: Could not create the worker thread!"));
return false; return false;
} }
terminateThread = false; terminateThread = false;
if (Run() != wxTHREAD_NO_ERROR) if (Run() != wxTHREAD_NO_ERROR) {
{
wxLogError(wxT("IRCClient::startWork: Could not run the worker thread!")); wxLogError(wxT("IRCClient::startWork: Could not run the worker thread!"));
return false; return false;
} }
@ -135,38 +130,30 @@ wxThread::ExitCode IRCClient::Entry ()
result = getAllIPV4Addresses(local_addr, 0, &numAddr, &myaddr, 1); result = getAllIPV4Addresses(local_addr, 0, &numAddr, &myaddr, 1);
if ((result != 0) || (numAddr != 1)) if ((result != 0) || (numAddr != 1)) {
{
wxLogVerbose(wxT("IRCClient::Entry: local address not parseable, using 0.0.0.0")); wxLogVerbose(wxT("IRCClient::Entry: local address not parseable, using 0.0.0.0"));
memset(&myaddr, 0x00, sizeof(struct sockaddr_in)); memset(&myaddr, 0x00, sizeof(struct sockaddr_in));
} }
while (true) while (true) {
{
if (timer > 0) if (timer > 0) {
{
timer --; timer --;
} }
switch (state) switch (state) {
{
case 0: case 0:
if (terminateThread) if (terminateThread) {
{
wxLogVerbose(wxT("IRCClient::Entry: thread terminated at state=%d"), state); wxLogVerbose(wxT("IRCClient::Entry: thread terminated at state=%d"), state);
return 0; return 0;
} }
if (timer == 0) if (timer == 0) {
{
timer = 30; timer = 30;
if (getAllIPV4Addresses(host_name, port, &numAddr, addr, MAXIPV4ADDR) == 0) if (getAllIPV4Addresses(host_name, port, &numAddr, addr, MAXIPV4ADDR) == 0) {
{
wxLogVerbose(wxT("IRCClient::Entry: number of DNS entries %d"), numAddr); wxLogVerbose(wxT("IRCClient::Entry: number of DNS entries %d"), numAddr);
if (numAddr > 0) if (numAddr > 0) {
{
currentAddr = 0; currentAddr = 0;
state = 1; state = 1;
timer = 0; timer = 0;
@ -176,57 +163,47 @@ wxThread::ExitCode IRCClient::Entry ()
break; break;
case 1: case 1:
if (terminateThread) if (terminateThread) {
{
wxLogVerbose(wxT("IRCClient::Entry: thread terminated at state=%d"), state); wxLogVerbose(wxT("IRCClient::Entry: thread terminated at state=%d"), state);
return 0; return 0;
} }
if (timer == 0) if (timer == 0) {
{
sock = socket( PF_INET, SOCK_STREAM, IPPROTO_TCP); sock = socket( PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sock < 0) if (sock < 0) {
{
wxLogSysError(wxT("IRCClient::Entry: socket")); wxLogSysError(wxT("IRCClient::Entry: socket"));
timer = 30; timer = 30;
state = 0; state = 0;
} } else {
else
{
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
u_long nonBlock = 1UL; u_long nonBlock = 1UL;
if (ioctlsocket( sock, FIONBIO, &nonBlock ) != 0) if (ioctlsocket( sock, FIONBIO, &nonBlock ) != 0) {
{
wxLogSysError(wxT("IRCClient::Entry: ioctlsocket")); wxLogSysError(wxT("IRCClient::Entry: ioctlsocket"));
closesocket(sock); closesocket(sock);
timer = 30; timer = 30;
state = 0; state = 0;
} }
#else #else
if (fcntl( sock, F_SETFL, O_NONBLOCK ) < 0) if (fcntl( sock, F_SETFL, O_NONBLOCK ) < 0) {
{
wxLogSysError(wxT("IRCClient::Entry: fcntl")); wxLogSysError(wxT("IRCClient::Entry: fcntl"));
close(sock); close(sock);
timer = 30; timer = 30;
state = 0; state = 0;
} }
#endif #endif
else else {
{
unsigned char * h = (unsigned char *) &(myaddr.sin_addr); unsigned char * h = (unsigned char *) &(myaddr.sin_addr);
int res; int res;
if ((h[0] != 0) || (h[1] != 0) || (h[2] != 0) || (h[3] != 0)) if ((h[0] != 0) || (h[1] != 0) || (h[2] != 0) || (h[3] != 0)) {
{
wxLogVerbose(wxT("IRCClient::Entry: bind: local address %d.%d.%d.%d"), wxLogVerbose(wxT("IRCClient::Entry: bind: local address %d.%d.%d.%d"),
h[0], h[1], h[2], h[3]); h[0], h[1], h[2], h[3]);
} }
res = bind(sock, (struct sockaddr *) &myaddr, sizeof (struct sockaddr_in)); res = bind(sock, (struct sockaddr *) &myaddr, sizeof (struct sockaddr_in));
if (res != 0) if (res != 0) {
{
wxLogSysError(wxT("IRCClient::Entry: bind")); wxLogSysError(wxT("IRCClient::Entry: bind"));
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
@ -246,13 +223,10 @@ wxThread::ExitCode IRCClient::Entry ()
res = connect(sock, (struct sockaddr *) (addr + currentAddr), sizeof (struct sockaddr_in)); res = connect(sock, (struct sockaddr *) (addr + currentAddr), sizeof (struct sockaddr_in));
if (res == 0) if (res == 0) {
{
wxLogVerbose(wxT("IRCClient::Entry: connected")); wxLogVerbose(wxT("IRCClient::Entry: connected"));
state = 4; state = 4;
} } else {
else
{
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
if (WSAGetLastError() == WSAEWOULDBLOCK) if (WSAGetLastError() == WSAEWOULDBLOCK)
#else #else
@ -262,9 +236,7 @@ wxThread::ExitCode IRCClient::Entry ()
wxLogVerbose(wxT("IRCClient::Entry: connect in progress")); wxLogVerbose(wxT("IRCClient::Entry: connect in progress"));
state = 3; state = 3;
timer = 10; // 5 second timeout timer = 10; // 5 second timeout
} } else {
else
{
wxLogSysError(wxT("IRCClient::Entry: connect")); wxLogSysError(wxT("IRCClient::Entry: connect"));
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
closesocket(sock); closesocket(sock);
@ -272,13 +244,10 @@ wxThread::ExitCode IRCClient::Entry ()
close(sock); close(sock);
#endif #endif
currentAddr ++; currentAddr ++;
if (currentAddr >= numAddr) if (currentAddr >= numAddr) {
{
state = 0; state = 0;
timer = 30; timer = 30;
} } else {
else
{
state = 1; state = 1;
timer = 4; timer = 4;
} }
@ -289,8 +258,7 @@ wxThread::ExitCode IRCClient::Entry ()
} }
break; break;
case 3: case 3: {
{
struct timeval tv; struct timeval tv;
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 0; tv.tv_usec = 0;
@ -300,8 +268,7 @@ wxThread::ExitCode IRCClient::Entry ()
int res; int res;
res = select(sock+1, NULL, &myset, NULL, &tv); res = select(sock+1, NULL, &myset, NULL, &tv);
if (res < 0) if (res < 0) {
{
wxLogSysError(wxT("IRCClient::Entry: select")); wxLogSysError(wxT("IRCClient::Entry: select"));
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
closesocket(sock); closesocket(sock);
@ -310,9 +277,7 @@ wxThread::ExitCode IRCClient::Entry ()
#endif #endif
state = 0; state = 0;
timer = 30; timer = 30;
} } else if (res > 0) { // connect is finished
else if (res > 0) // connect is finished
{
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
int val_len; int val_len;
#else #else
@ -322,8 +287,7 @@ wxThread::ExitCode IRCClient::Entry ()
val_len = sizeof value; val_len = sizeof value;
if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (char *) &value, &val_len) < 0) if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (char *) &value, &val_len) < 0) {
{
wxLogSysError(wxT("IRCClient::Entry: getsockopt")); wxLogSysError(wxT("IRCClient::Entry: getsockopt"));
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
closesocket(sock); closesocket(sock);
@ -332,11 +296,8 @@ wxThread::ExitCode IRCClient::Entry ()
#endif #endif
state = 0; state = 0;
timer = 30; timer = 30;
} } else {
else if (value != 0) {
{
if (value != 0)
{
wxLogWarning(wxT("IRCClient::Entry: SO_ERROR=%d"), value); wxLogWarning(wxT("IRCClient::Entry: SO_ERROR=%d"), value);
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
closesocket(sock); closesocket(sock);
@ -344,27 +305,21 @@ wxThread::ExitCode IRCClient::Entry ()
close(sock); close(sock);
#endif #endif
currentAddr ++; currentAddr ++;
if (currentAddr >= numAddr) if (currentAddr >= numAddr) {
{
state = 0; state = 0;
timer = 30; timer = 30;
} } else {
else
{
state = 1; state = 1;
timer = 2; timer = 2;
} }
} } else {
else
{
wxLogVerbose(wxT("IRCClient::Entry: connected2")); wxLogVerbose(wxT("IRCClient::Entry: connected2"));
state = 4; state = 4;
} }
} }
} } else if (timer == 0) {
else if (timer == 0) // select timeout and timer timeout
{ // select timeout and timer timeout
wxLogVerbose(wxT("IRCClient::Entry: connect timeout")); wxLogVerbose(wxT("IRCClient::Entry: connect timeout"));
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
closesocket(sock); closesocket(sock);
@ -372,13 +327,10 @@ wxThread::ExitCode IRCClient::Entry ()
close(sock); close(sock);
#endif #endif
currentAddr ++; currentAddr ++;
if (currentAddr >= numAddr) if (currentAddr >= numAddr) {
{
state = 0; state = 0;
timer = 30; timer = 30;
} } else {
else
{
state = 1; // open new socket state = 1; // open new socket
timer = 2; timer = 2;
} }
@ -387,8 +339,7 @@ wxThread::ExitCode IRCClient::Entry ()
} }
break; break;
case 4: case 4: {
{
recvQ = new IRCMessageQueue(); recvQ = new IRCMessageQueue();
sendQ = new IRCMessageQueue(); sendQ = new IRCMessageQueue();
@ -404,26 +355,19 @@ wxThread::ExitCode IRCClient::Entry ()
case 5: case 5:
if (terminateThread) if (terminateThread) {
{
state = 6; state = 6;
} } else {
else
{
if (recvQ -> isEOF()) if (recvQ -> isEOF()) {
{
timer = 0; timer = 0;
state = 6; state = 6;
} } else if (proto -> processQueues(recvQ, sendQ) == false) {
else if (proto -> processQueues(recvQ, sendQ) == false)
{
timer = 0; timer = 0;
state = 6; state = 6;
} }
while ((state == 5) && sendQ->messageAvailable()) while ((state == 5) && sendQ->messageAvailable()) {
{
IRCMessage * m = sendQ -> getMessage(); IRCMessage * m = sendQ -> getMessage();
wxString out; wxString out;
@ -434,12 +378,10 @@ wxThread::ExitCode IRCClient::Entry ()
safeStringCopy(buf, out.mb_str(wxConvUTF8), sizeof buf); safeStringCopy(buf, out.mb_str(wxConvUTF8), sizeof buf);
int len = strlen(buf); int len = strlen(buf);
if (buf[len - 1] == 10) // is there a NL char at the end? if (buf[len - 1] == 10) { // is there a NL char at the end?
{
int r = send(sock, buf, len, 0); int r = send(sock, buf, len, 0);
if (r != len) if (r != len) {
{
wxLogVerbose(wxT("IRCClient::Entry: short write %d < %d"), r, len); wxLogVerbose(wxT("IRCClient::Entry: short write %d < %d"), r, len);
timer = 0; timer = 0;
@ -449,9 +391,7 @@ wxThread::ExitCode IRCClient::Entry ()
{ {
wxLogVerbose(wxT("write %d bytes (") + out + wxT(")"), len ); wxLogVerbose(wxT("write %d bytes (") + out + wxT(")"), len );
} */ } */
} } else {
else
{
wxLogVerbose(wxT("IRCClient::Entry: no NL at end, len=%d"), len); wxLogVerbose(wxT("IRCClient::Entry: no NL at end, len=%d"), len);
timer = 0; timer = 0;
@ -463,10 +403,8 @@ wxThread::ExitCode IRCClient::Entry ()
} }
break; break;
case 6: case 6: {
{ if (app != NULL) {
if (app != NULL)
{
app->setSendQ(NULL); app->setSendQ(NULL);
app->userListReset(); app->userListReset();
} }
@ -486,8 +424,7 @@ wxThread::ExitCode IRCClient::Entry ()
close(sock); close(sock);
#endif #endif
if (terminateThread) // request to end the thread if (terminateThread) { // request to end the thread
{
wxLogVerbose(wxT("IRCClient::Entry: thread terminated at state=%d"), state); wxLogVerbose(wxT("IRCClient::Entry: thread terminated at state=%d"), state);
return 0; return 0;
} }

@ -28,8 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <wx/wx.h> #include <wx/wx.h>
struct CIRCDDBPrivate struct CIRCDDBPrivate {
{
IRCClient * client; IRCClient * client;
IRCDDBApp * app; IRCDDBApp * app;
}; };
@ -97,32 +96,27 @@ bool CIRCDDB::sendHeard( const wxString& myCall, const wxString& myCallExt,
const wxString& rpt2, unsigned char flag1, const wxString& rpt2, unsigned char flag1,
unsigned char flag2, unsigned char flag3 ) unsigned char flag2, unsigned char flag3 )
{ {
if (myCall.Len() != 8) if (myCall.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:myCall: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:myCall: len != 8"));
return false; return false;
} }
if (myCallExt.Len() != 4) if (myCallExt.Len() != 4) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:myCallExt: len != 4")); wxLogVerbose(wxT("CIRCDDB::sendHeard:myCallExt: len != 4"));
return false; return false;
} }
if (yourCall.Len() != 8) if (yourCall.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:yourCall: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:yourCall: len != 8"));
return false; return false;
} }
if (rpt1.Len() != 8) if (rpt1.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt1: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt1: len != 8"));
return false; return false;
} }
if (rpt2.Len() != 8) if (rpt2.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt2: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt2: len != 8"));
return false; return false;
} }
@ -140,64 +134,52 @@ bool CIRCDDB::sendHeardWithTXMsg( const wxString& myCall, const wxString& myCall
const wxString& network_destination, const wxString& network_destination,
const wxString& tx_message ) const wxString& tx_message )
{ {
if (myCall.Len() != 8) if (myCall.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:myCall: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:myCall: len != 8"));
return false; return false;
} }
if (myCallExt.Len() != 4) if (myCallExt.Len() != 4) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:myCallExt: len != 4")); wxLogVerbose(wxT("CIRCDDB::sendHeard:myCallExt: len != 4"));
return false; return false;
} }
if (yourCall.Len() != 8) if (yourCall.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:yourCall: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:yourCall: len != 8"));
return false; return false;
} }
if (rpt1.Len() != 8) if (rpt1.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt1: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt1: len != 8"));
return false; return false;
} }
if (rpt2.Len() != 8) if (rpt2.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt2: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt2: len != 8"));
return false; return false;
} }
wxString dest = network_destination; wxString dest = network_destination;
if (dest.Len() == 0) if (dest.Len() == 0) {
{
dest = wxT(" "); dest = wxT(" ");
} }
if (dest.Len() != 8) if (dest.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:network_destination: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:network_destination: len != 8"));
return false; return false;
} }
wxString msg; wxString msg;
if (tx_message.Len() == 20) if (tx_message.Len() == 20) {
{
unsigned int i; unsigned int i;
for (i=0; i < tx_message.Len(); i++) for (i=0; i < tx_message.Len(); i++) {
{
wxChar ch = tx_message.GetChar(i); wxChar ch = tx_message.GetChar(i);
if ((ch > 32) && (ch < 127)) if ((ch > 32) && (ch < 127)) {
{
msg.Append(ch); msg.Append(ch);
} } else {
else
{
msg.Append(wxT('_')); msg.Append(wxT('_'));
} }
} }
@ -217,73 +199,59 @@ bool CIRCDDB::sendHeardWithTXStats( const wxString& myCall, const wxString& myCa
int num_dv_silent_frames, int num_dv_silent_frames,
int num_bit_errors ) int num_bit_errors )
{ {
if ((num_dv_frames <= 0) || (num_dv_frames > 65535)) if ((num_dv_frames <= 0) || (num_dv_frames > 65535)) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:num_dv_frames not in range 1-65535")); wxLogVerbose(wxT("CIRCDDB::sendHeard:num_dv_frames not in range 1-65535"));
return false; return false;
} }
if (num_dv_silent_frames > num_dv_frames) if (num_dv_silent_frames > num_dv_frames) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:num_dv_silent_frames > num_dv_frames")); wxLogVerbose(wxT("CIRCDDB::sendHeard:num_dv_silent_frames > num_dv_frames"));
return false; return false;
} }
if (num_bit_errors > (4*num_dv_frames)) // max 4 bit errors per frame if (num_bit_errors > (4*num_dv_frames)) { // max 4 bit errors per frame
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:num_bit_errors > (4*num_dv_frames)")); wxLogVerbose(wxT("CIRCDDB::sendHeard:num_bit_errors > (4*num_dv_frames)"));
return false; return false;
} }
if (myCall.Len() != 8) if (myCall.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:myCall: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:myCall: len != 8"));
return false; return false;
} }
if (myCallExt.Len() != 4) if (myCallExt.Len() != 4) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:myCallExt: len != 4")); wxLogVerbose(wxT("CIRCDDB::sendHeard:myCallExt: len != 4"));
return false; return false;
} }
if (yourCall.Len() != 8) if (yourCall.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:yourCall: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:yourCall: len != 8"));
return false; return false;
} }
if (rpt1.Len() != 8) if (rpt1.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt1: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt1: len != 8"));
return false; return false;
} }
if (rpt2.Len() != 8) if (rpt2.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt2: len != 8")); wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt2: len != 8"));
return false; return false;
} }
wxString stats = wxString::Format(wxT("%04x"), num_dv_frames); wxString stats = wxString::Format(wxT("%04x"), num_dv_frames);
if (num_dv_silent_frames >= 0) if (num_dv_silent_frames >= 0) {
{
wxString s = wxString::Format(wxT("%02x"), (num_dv_silent_frames * 100) / num_dv_frames); wxString s = wxString::Format(wxT("%02x"), (num_dv_silent_frames * 100) / num_dv_frames);
stats.Append(s); stats.Append(s);
if (num_bit_errors >= 0) if (num_bit_errors >= 0) {
{
s = wxString::Format(wxT("%02x"), (num_bit_errors * 125) / (num_dv_frames * 3)); s = wxString::Format(wxT("%02x"), (num_bit_errors * 125) / (num_dv_frames * 3));
stats.Append(s); stats.Append(s);
} } else {
else
{
stats.Append(wxT("__")); stats.Append(wxT("__"));
} }
} } else {
else
{
stats.Append(wxT("____")); stats.Append(wxT("____"));
} }
@ -298,8 +266,7 @@ bool CIRCDDB::sendHeardWithTXStats( const wxString& myCall, const wxString& myCa
// Send query for a gateway/reflector, a false return implies a network error // Send query for a gateway/reflector, a false return implies a network error
bool CIRCDDB::findGateway(const wxString& gatewayCallsign) bool CIRCDDB::findGateway(const wxString& gatewayCallsign)
{ {
if (gatewayCallsign.Len() != 8) if (gatewayCallsign.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::findGateway: len != 8")); wxLogVerbose(wxT("CIRCDDB::findGateway: len != 8"));
return false; return false;
} }
@ -310,8 +277,7 @@ bool CIRCDDB::findGateway(const wxString& gatewayCallsign)
bool CIRCDDB::findRepeater(const wxString& repeaterCallsign) bool CIRCDDB::findRepeater(const wxString& repeaterCallsign)
{ {
if (repeaterCallsign.Len() != 8) if (repeaterCallsign.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::findRepeater: len != 8")); wxLogVerbose(wxT("CIRCDDB::findRepeater: len != 8"));
return false; return false;
} }
@ -322,8 +288,7 @@ bool CIRCDDB::findRepeater(const wxString& repeaterCallsign)
// Send query for a user, a false return implies a network error // Send query for a user, a false return implies a network error
bool CIRCDDB::findUser(const wxString& userCallsign) bool CIRCDDB::findUser(const wxString& userCallsign)
{ {
if (userCallsign.Len() != 8) if (userCallsign.Len() != 8) {
{
wxLogVerbose(wxT("CIRCDDB::findUser: len != 8")); wxLogVerbose(wxT("CIRCDDB::findUser: len != 8"));
return false; return false;
} }
@ -341,32 +306,28 @@ IRCDDB_RESPONSE_TYPE CIRCDDB::getMessageType()
// Get a gateway message, as a result of IDRT_REPEATER returned from getMessageType() // Get a gateway message, as a result of IDRT_REPEATER returned from getMessageType()
// A false return implies a network error // A false return implies a network error
bool CIRCDDB::receiveRepeater(wxString& repeaterCallsign, wxString& gatewayCallsign, wxString& address, DSTAR_PROTOCOL& protocol) bool CIRCDDB::receiveRepeater(wxString& repeaterCallsign, wxString& gatewayCallsign, wxString& address, DSTAR_PROTOCOL& /*protocol*/)
{ {
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType(); IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
if (rt != IDRT_REPEATER) if (rt != IDRT_REPEATER) {
{
wxLogError(wxT("CIRCDDB::receiveRepeater: unexpected response type")); wxLogError(wxT("CIRCDDB::receiveRepeater: unexpected response type"));
return false; return false;
} }
IRCMessage * m = d->app->getReplyMessage(); IRCMessage * m = d->app->getReplyMessage();
if (m == NULL) if (m == NULL) {
{
wxLogError(wxT("CIRCDDB::receiveRepeater: no message")); wxLogError(wxT("CIRCDDB::receiveRepeater: no message"));
return false; return false;
} }
if (!m->getCommand().IsSameAs(wxT("IDRT_REPEATER"))) if (!m->getCommand().IsSameAs(wxT("IDRT_REPEATER"))) {
{
wxLogError(wxT("CIRCDDB::receiveRepeater: wrong message type")); wxLogError(wxT("CIRCDDB::receiveRepeater: wrong message type"));
return false; return false;
} }
if (m->getParamCount() != 3) if (m->getParamCount() != 3) {
{
wxLogError(wxT("CIRCDDB::receiveRepeater: unexpected number of message parameters")); wxLogError(wxT("CIRCDDB::receiveRepeater: unexpected number of message parameters"));
return false; return false;
} }
@ -382,32 +343,28 @@ bool CIRCDDB::receiveRepeater(wxString& repeaterCallsign, wxString& gatewayCalls
// Get a gateway message, as a result of IDRT_GATEWAY returned from getMessageType() // Get a gateway message, as a result of IDRT_GATEWAY returned from getMessageType()
// A false return implies a network error // A false return implies a network error
bool CIRCDDB::receiveGateway(wxString& gatewayCallsign, wxString& address, DSTAR_PROTOCOL& protocol) bool CIRCDDB::receiveGateway(wxString& gatewayCallsign, wxString& address, DSTAR_PROTOCOL& /*protocol*/)
{ {
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType(); IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
if (rt != IDRT_GATEWAY) if (rt != IDRT_GATEWAY) {
{
wxLogError(wxT("CIRCDDB::receiveGateway: unexpected response type")); wxLogError(wxT("CIRCDDB::receiveGateway: unexpected response type"));
return false; return false;
} }
IRCMessage * m = d->app->getReplyMessage(); IRCMessage * m = d->app->getReplyMessage();
if (m == NULL) if (m == NULL) {
{
wxLogError(wxT("CIRCDDB::receiveGateway: no message")); wxLogError(wxT("CIRCDDB::receiveGateway: no message"));
return false; return false;
} }
if (!m->getCommand().IsSameAs(wxT("IDRT_GATEWAY"))) if (!m->getCommand().IsSameAs(wxT("IDRT_GATEWAY"))) {
{
wxLogError(wxT("CIRCDDB::receiveGateway: wrong message type")); wxLogError(wxT("CIRCDDB::receiveGateway: wrong message type"));
return false; return false;
} }
if (m->getParamCount() != 2) if (m->getParamCount() != 2) {
{
wxLogError(wxT("CIRCDDB::receiveGateway: unexpected number of message parameters")); wxLogError(wxT("CIRCDDB::receiveGateway: unexpected number of message parameters"));
return false; return false;
} }
@ -433,28 +390,24 @@ bool CIRCDDB::receiveUser(wxString& userCallsign, wxString& repeaterCallsign, wx
{ {
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType(); IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
if (rt != IDRT_USER) if (rt != IDRT_USER) {
{
wxLogError(wxT("CIRCDDB::receiveUser: unexpected response type")); wxLogError(wxT("CIRCDDB::receiveUser: unexpected response type"));
return false; return false;
} }
IRCMessage * m = d->app->getReplyMessage(); IRCMessage * m = d->app->getReplyMessage();
if (m == NULL) if (m == NULL) {
{
wxLogError(wxT("CIRCDDB::receiveUser: no message")); wxLogError(wxT("CIRCDDB::receiveUser: no message"));
return false; return false;
} }
if (!m->getCommand().IsSameAs(wxT("IDRT_USER"))) if (!m->getCommand().IsSameAs(wxT("IDRT_USER"))) {
{
wxLogError(wxT("CIRCDDB::receiveUser: wrong message type")); wxLogError(wxT("CIRCDDB::receiveUser: wrong message type"));
return false; return false;
} }
if (m->getParamCount() != 5) if (m->getParamCount() != 5) {
{
wxLogError(wxT("CIRCDDB::receiveUser: unexpected number of message parameters")); wxLogError(wxT("CIRCDDB::receiveUser: unexpected number of message parameters"));
return false; return false;
} }

@ -41,7 +41,8 @@ enum DSTAR_PROTOCOL {
struct CIRCDDBPrivate; struct CIRCDDBPrivate;
class CIRCDDB { class CIRCDDB
{
public: public:
CIRCDDB(const wxString& hostName, unsigned int port, const wxString& callsign, const wxString& password, CIRCDDB(const wxString& hostName, unsigned int port, const wxString& callsign, const wxString& password,
const wxString& versionInfo, const wxString& localAddr = wxEmptyString ); const wxString& versionInfo, const wxString& localAddr = wxEmptyString );

@ -52,13 +52,11 @@ class IRCDDBAppUserObject
bool op; bool op;
unsigned int usn; unsigned int usn;
IRCDDBAppUserObject () IRCDDBAppUserObject () {
{
IRCDDBAppUserObject (wxT(""), wxT(""), wxT("")); IRCDDBAppUserObject (wxT(""), wxT(""), wxT(""));
} }
IRCDDBAppUserObject ( const wxString& n, const wxString& nm, const wxString& h ) IRCDDBAppUserObject ( const wxString& n, const wxString& nm, const wxString& h ) {
{
nick = n; nick = n;
name = nm; name = nm;
host = h; host = h;
@ -84,18 +82,15 @@ class IRCDDBAppRptrObject
wxDateTime lastChanged; wxDateTime lastChanged;
wxString zonerp_cs; wxString zonerp_cs;
IRCDDBAppRptrObject () IRCDDBAppRptrObject () {
{
} }
IRCDDBAppRptrObject (wxDateTime& dt, wxString& repeaterCallsign, wxString& gatewayCallsign) IRCDDBAppRptrObject (wxDateTime& dt, wxString& repeaterCallsign, wxString& gatewayCallsign) {
{
arearp_cs = repeaterCallsign; arearp_cs = repeaterCallsign;
lastChanged = dt; lastChanged = dt;
zonerp_cs = gatewayCallsign; zonerp_cs = gatewayCallsign;
if (dt.IsLaterThan(maxTime)) if (dt.IsLaterThan(maxTime)) {
{
maxTime = dt; maxTime = dt;
} }
} }
@ -119,8 +114,7 @@ class IRCDDBAppPrivate
datePattern(wxT("^20[0-9][0-9]-((1[0-2])|(0[1-9]))-((3[01])|([12][0-9])|(0[1-9]))$")), datePattern(wxT("^20[0-9][0-9]-((1[0-2])|(0[1-9]))-((3[01])|([12][0-9])|(0[1-9]))$")),
timePattern(wxT("^((2[0-3])|([01][0-9])):[0-5][0-9]:[0-5][0-9]$")), timePattern(wxT("^((2[0-3])|([01][0-9])):[0-5][0-9]:[0-5][0-9]$")),
dbPattern(wxT("^[0-9A-Z_]{8}$")), dbPattern(wxT("^[0-9A-Z_]{8}$")),
modulePattern(wxT("^[ABCD]D?$")) modulePattern(wxT("^[ABCD]D?$")) {
{
wdTimer = 0; wdTimer = 0;
wdCounter = 0; wdCounter = 0;
} }
@ -190,8 +184,7 @@ IRCDDBApp::IRCDDBApp( const wxString& u_chan )
IRCDDBApp::~IRCDDBApp() IRCDDBApp::~IRCDDBApp()
{ {
if (d->sendQ != NULL) if (d->sendQ != NULL) {
{
delete d->sendQ; delete d->sendQ;
} }
delete d; delete d;
@ -239,8 +232,7 @@ void IRCDDBApp::rptrQRG( const wxString& module, double txFrequency, double dupl
double range, double agl ) double range, double agl )
{ {
if (d->modulePattern.Matches(module)) if (d->modulePattern.Matches(module)) {
{
wxString f = module + wxT(" ") + wxString::Format(wxT("%011.5f %+010.5f %06.2f %06.1f"), wxString f = module + wxT(" ") + wxString::Format(wxT("%011.5f %+010.5f %06.2f %06.1f"),
txFrequency, duplexShift, range / 1609.344, agl ); txFrequency, duplexShift, range / 1609.344, agl );
@ -257,16 +249,13 @@ void IRCDDBApp::rptrQRG( const wxString& module, double txFrequency, double dupl
void IRCDDBApp::kickWatchdog( const wxString& s ) void IRCDDBApp::kickWatchdog( const wxString& s )
{ {
if (s.Len() > 0) if (s.Len() > 0) {
{
wxRegEx nonValid(wxT("[^[:graph:]]")); wxRegEx nonValid(wxT("[^[:graph:]]"));
d->wdInfo = s; d->wdInfo = s;
nonValid.Replace(& d->wdInfo, wxEmptyString); nonValid.Replace(& d->wdInfo, wxEmptyString);
if (d->wdInfo.Len() > 0) if (d->wdInfo.Len() > 0) {
{ if (d->wdTimer == 0) {
if (d->wdTimer == 0)
{
d->wdTimer ++; d->wdTimer ++;
} }
@ -284,23 +273,17 @@ int IRCDDBApp::getConnectionState()
IRCDDB_RESPONSE_TYPE IRCDDBApp::getReplyMessageType() IRCDDB_RESPONSE_TYPE IRCDDBApp::getReplyMessageType()
{ {
IRCMessage * m = d->replyQ.peekFirst(); IRCMessage * m = d->replyQ.peekFirst();
if (m == NULL) if (m == NULL) {
{
return IDRT_NONE; return IDRT_NONE;
} }
wxString msgType = m->getCommand(); wxString msgType = m->getCommand();
if (msgType.IsSameAs(wxT("IDRT_USER"))) if (msgType.IsSameAs(wxT("IDRT_USER"))) {
{
return IDRT_USER; return IDRT_USER;
} } else if (msgType.IsSameAs(wxT("IDRT_REPEATER"))) {
else if (msgType.IsSameAs(wxT("IDRT_REPEATER")))
{
return IDRT_REPEATER; return IDRT_REPEATER;
} } else if (msgType.IsSameAs(wxT("IDRT_GATEWAY"))) {
else if (msgType.IsSameAs(wxT("IDRT_GATEWAY")))
{
return IDRT_GATEWAY; return IDRT_GATEWAY;
} }
@ -320,16 +303,14 @@ IRCMessage * IRCDDBApp::getReplyMessage()
bool IRCDDBApp::startWork() bool IRCDDBApp::startWork()
{ {
if (Create() != wxTHREAD_NO_ERROR) if (Create() != wxTHREAD_NO_ERROR) {
{
wxLogError(wxT("IRCClient::startWork: Could not create the worker thread!")); wxLogError(wxT("IRCClient::startWork: Could not create the worker thread!"));
return false; return false;
} }
d->terminateThread = false; d->terminateThread = false;
if (Run() != wxTHREAD_NO_ERROR) if (Run() != wxTHREAD_NO_ERROR) {
{
wxLogError(wxT("IRCClient::startWork: Could not run the worker thread!")); wxLogError(wxT("IRCClient::startWork: Could not run the worker thread!"));
return false; return false;
} }
@ -358,16 +339,13 @@ void IRCDDBApp::userJoin (const wxString& nick, const wxString& name, const wxSt
// wxLogVerbose(wxT("add %d: (") + u.nick + wxT(") (") + u.host + wxT(")"), d->user.size()); // wxLogVerbose(wxT("add %d: (") + u.nick + wxT(") (") + u.host + wxT(")"), d->user.size());
if (d->initReady) if (d->initReady) {
{
int hyphenPos = nick.Find(wxT('-')); int hyphenPos = nick.Find(wxT('-'));
if ((hyphenPos >= 4) && (hyphenPos <= 6)) if ((hyphenPos >= 4) && (hyphenPos <= 6)) {
{
wxString gatewayCallsign = nick.Mid(0, hyphenPos).Upper(); wxString gatewayCallsign = nick.Mid(0, hyphenPos).Upper();
while (gatewayCallsign.Length() < 7) while (gatewayCallsign.Length() < 7) {
{
gatewayCallsign.Append(wxT(' ')); gatewayCallsign.Append(wxT(' '));
} }
@ -397,22 +375,18 @@ void IRCDDBApp::userLeave (const wxString& nick)
// wxLogVerbose(wxT("rm %d: ") + nick, d->user.size()); // wxLogVerbose(wxT("rm %d: ") + nick, d->user.size());
if (d->currentServer.Len() > 0) if (d->currentServer.Len() > 0) {
{ if (d->user.count(d->myNick) != 1) {
if (d->user.count(d->myNick) != 1)
{
wxLogVerbose(wxT("IRCDDBApp::userLeave: could not find own nick")); wxLogVerbose(wxT("IRCDDBApp::userLeave: could not find own nick"));
return; return;
} }
IRCDDBAppUserObject me = d->user[d->myNick]; IRCDDBAppUserObject me = d->user[d->myNick];
if (me.op == false) if (me.op == false) {
{
// if I am not op, then look for new server // if I am not op, then look for new server
if (d->currentServer.IsSameAs(lnick)) if (d->currentServer.IsSameAs(lnick)) {
{
// currentServer = null; // currentServer = null;
d->state = 2; // choose new server d->state = 2; // choose new server
d->timer = 200; d->timer = 200;
@ -454,13 +428,11 @@ bool IRCDDBApp::findServerUser()
IRCDDBAppUserMap::iterator it; IRCDDBAppUserMap::iterator it;
for( it = d->user.begin(); it != d->user.end(); ++it ) for( it = d->user.begin(); it != d->user.end(); ++it ) {
{
IRCDDBAppUserObject u = it->second; IRCDDBAppUserObject u = it->second;
if (u.nick.StartsWith(wxT("s-")) && u.op && !d->myNick.IsSameAs(u.nick) if (u.nick.StartsWith(wxT("s-")) && u.op && !d->myNick.IsSameAs(u.nick)
&& u.nick.IsSameAs(d->bestServer)) && u.nick.IsSameAs(d->bestServer)) {
{
d->currentServer = u.nick; d->currentServer = u.nick;
found = true; found = true;
break; break;
@ -470,15 +442,12 @@ bool IRCDDBApp::findServerUser()
if (found) if (found)
return true; return true;
if (d->bestServer.Len() == 8) if (d->bestServer.Len() == 8) {
{ for( it = d->user.begin(); it != d->user.end(); ++it ) {
for( it = d->user.begin(); it != d->user.end(); ++it )
{
IRCDDBAppUserObject u = it->second; IRCDDBAppUserObject u = it->second;
if (u.nick.StartsWith(d->bestServer.Mid(0,7)) && u.op && if (u.nick.StartsWith(d->bestServer.Mid(0,7)) && u.op &&
!d->myNick.IsSameAs(u.nick) ) !d->myNick.IsSameAs(u.nick) ) {
{
d->currentServer = u.nick; d->currentServer = u.nick;
found = true; found = true;
break; break;
@ -489,12 +458,10 @@ bool IRCDDBApp::findServerUser()
if (found) if (found)
return true; return true;
for( it = d->user.begin(); it != d->user.end(); ++it ) for( it = d->user.begin(); it != d->user.end(); ++it ) {
{
IRCDDBAppUserObject u = it->second; IRCDDBAppUserObject u = it->second;
if (u.nick.StartsWith(wxT("s-")) && u.op && !d->myNick.IsSameAs(u.nick)) if (u.nick.StartsWith(wxT("s-")) && u.op && !d->myNick.IsSameAs(u.nick)) {
{
d->currentServer = u.nick; d->currentServer = u.nick;
found = true; found = true;
break; break;
@ -511,8 +478,7 @@ void IRCDDBApp::userChanOp (const wxString& nick, bool op)
wxString lnick = nick; wxString lnick = nick;
lnick.MakeLower(); lnick.MakeLower();
if (d->user.count(lnick) == 1) if (d->user.count(lnick) == 1) {
{
d->user[lnick].op = op; d->user[lnick].op = op;
} }
} }
@ -538,17 +504,14 @@ wxString IRCDDBApp::getIPAddress(wxString& zonerp_cs)
int j; int j;
for (j=1; j <= 4; j++) for (j=1; j <= 4; j++) {
{
// int i = 0; // int i = 0;
wxString ircUser = gw.Strip() + wxString::Format(wxT("-%d"), j); wxString ircUser = gw.Strip() + wxString::Format(wxT("-%d"), j);
if (d->user.count(ircUser) == 1) if (d->user.count(ircUser) == 1) {
{
IRCDDBAppUserObject o = d->user[ ircUser ]; IRCDDBAppUserObject o = d->user[ ircUser ];
if (o.usn >= max_usn) if (o.usn >= max_usn) {
{
max_usn = o.usn; max_usn = o.usn;
ipAddr = o.host; ipAddr = o.host;
} }
@ -589,10 +552,8 @@ static void findReflector( const wxString& rptrCall, IRCDDBAppPrivate * d )
safeStringCopy(host_name, host.mb_str(wxConvUTF8), sizeof host_name); safeStringCopy(host_name, host.mb_str(wxConvUTF8), sizeof host_name);
if (getAllIPV4Addresses(host_name, 0, &numAddr, addr, MAXIPV4ADDR) == 0) if (getAllIPV4Addresses(host_name, 0, &numAddr, addr, MAXIPV4ADDR) == 0) {
{ if (numAddr > 0) {
if (numAddr > 0)
{
unsigned char * a = (unsigned char *) &addr[0].sin_addr; unsigned char * a = (unsigned char *) &addr[0].sin_addr;
ipAddr = wxString::Format(wxT("%d.%d.%d.%d"), a[0], a[1], a[2], a[3]); ipAddr = wxString::Format(wxT("%d.%d.%d.%d"), a[0], a[1], a[2], a[3]);
@ -612,8 +573,7 @@ static void findReflector( const wxString& rptrCall, IRCDDBAppPrivate * d )
bool IRCDDBApp::findRepeater(const wxString& rptrCall) bool IRCDDBApp::findRepeater(const wxString& rptrCall)
{ {
if (rptrCall.StartsWith(wxT("XRF")) || rptrCall.StartsWith(wxT("REF"))) if (rptrCall.StartsWith(wxT("XRF")) || rptrCall.StartsWith(wxT("REF"))) {
{
findReflector(rptrCall, d); findReflector(rptrCall, d);
return true; return true;
} }
@ -627,8 +587,7 @@ bool IRCDDBApp::findRepeater(const wxString& rptrCall)
wxString s = wxT("NONE"); wxString s = wxT("NONE");
if (d->rptrMap.count(arearp_cs) == 1) if (d->rptrMap.count(arearp_cs) == 1) {
{
IRCDDBAppRptrObject o = d->rptrMap[arearp_cs]; IRCDDBAppRptrObject o = d->rptrMap[arearp_cs];
zonerp_cs = o.zonerp_cs; zonerp_cs = o.zonerp_cs;
zonerp_cs.Replace(wxT("_"), wxT(" ")); zonerp_cs.Replace(wxT("_"), wxT(" "));
@ -676,8 +635,7 @@ bool IRCDDBApp::sendHeard(const wxString& myCall, const wxString& myCallExt,
wxString srv = d->currentServer; wxString srv = d->currentServer;
IRCMessageQueue * q = getSendQ(); IRCMessageQueue * q = getSendQ();
if ((srv.Len() > 0) && (d->state >= 6) && (q != NULL)) if ((srv.Len() > 0) && (d->state >= 6) && (q != NULL)) {
{
wxString cmd = wxT("UPDATE "); wxString cmd = wxT("UPDATE ");
cmd.Append( getCurrentTime() ); cmd.Append( getCurrentTime() );
@ -688,8 +646,7 @@ bool IRCDDBApp::sendHeard(const wxString& myCall, const wxString& myCallExt,
cmd.Append(wxT(" ")); cmd.Append(wxT(" "));
cmd.Append(r1); cmd.Append(r1);
cmd.Append(wxT(" ")); cmd.Append(wxT(" "));
if (!statsMsg) if (!statsMsg) {
{
cmd.Append(wxT("0 ")); cmd.Append(wxT("0 "));
} }
cmd.Append(r2); cmd.Append(r2);
@ -703,18 +660,14 @@ bool IRCDDBApp::sendHeard(const wxString& myCall, const wxString& myCallExt,
cmd.Append(wxT(" ")); cmd.Append(wxT(" "));
cmd.Append(myext); cmd.Append(myext);
if (statsMsg) if (statsMsg) {
{
cmd.Append(wxT(" # ")); cmd.Append(wxT(" # "));
cmd.Append(tx_stats); cmd.Append(tx_stats);
} } else {
else
{
cmd.Append(wxT(" 00 ")); cmd.Append(wxT(" 00 "));
cmd.Append(dest); cmd.Append(dest);
if (tx_msg.Len() == 20) if (tx_msg.Len() == 20) {
{
cmd.Append(wxT(" ")); cmd.Append(wxT(" "));
cmd.Append(tx_msg); cmd.Append(tx_msg);
} }
@ -725,9 +678,7 @@ bool IRCDDBApp::sendHeard(const wxString& myCall, const wxString& myCallExt,
q->putMessage(m); q->putMessage(m);
return true; return true;
} } else {
else
{
return false; return false;
} }
} }
@ -737,8 +688,7 @@ bool IRCDDBApp::findUser(const wxString& usrCall)
wxString srv = d->currentServer; wxString srv = d->currentServer;
IRCMessageQueue * q = getSendQ(); IRCMessageQueue * q = getSendQ();
if ((srv.Len() > 0) && (d->state >= 6) && (q != NULL)) if ((srv.Len() > 0) && (d->state >= 6) && (q != NULL)) {
{
wxString usr = usrCall; wxString usr = usrCall;
usr.Replace(wxT(" "), wxT("_")); usr.Replace(wxT(" "), wxT("_"));
@ -747,9 +697,7 @@ bool IRCDDBApp::findUser(const wxString& usrCall)
wxT("FIND ") + usr ); wxT("FIND ") + usr );
q->putMessage(m); q->putMessage(m);
} } else {
else
{
IRCMessage * m2 = new IRCMessage(wxT("IDRT_USER")); IRCMessage * m2 = new IRCMessage(wxT("IDRT_USER"));
m2->addParam(usrCall); m2->addParam(usrCall);
m2->addParam(wxT("")); m2->addParam(wxT(""));
@ -765,8 +713,7 @@ bool IRCDDBApp::findUser(const wxString& usrCall)
void IRCDDBApp::msgChannel (IRCMessage * m) void IRCDDBApp::msgChannel (IRCMessage * m)
{ {
if (m->getPrefixNick().StartsWith(wxT("s-")) && (m->numParams >= 2)) // server msg if (m->getPrefixNick().StartsWith(wxT("s-")) && (m->numParams >= 2)) { // server msg
{
doUpdate(m->params[1]); doUpdate(m->params[1]);
} }
} }
@ -778,44 +725,35 @@ void IRCDDBApp::doNotFound ( wxString& msg, wxString& retval )
wxStringTokenizer tkz(msg); wxStringTokenizer tkz(msg);
if (!tkz.HasMoreTokens()) if (!tkz.HasMoreTokens()) {
{
return; // no text in message return; // no text in message
} }
wxString tk = tkz.GetNextToken(); wxString tk = tkz.GetNextToken();
if (d->tablePattern.Matches(tk)) if (d->tablePattern.Matches(tk)) {
{
long i; long i;
if (tk.ToLong(&i)) if (tk.ToLong(&i)) {
{
tableID = i; tableID = i;
if ((tableID < 0) || (tableID >= numberOfTables)) if ((tableID < 0) || (tableID >= numberOfTables)) {
{
wxLogVerbose(wxT("invalid table ID %d"), tableID); wxLogVerbose(wxT("invalid table ID %d"), tableID);
return; return;
} }
} } else {
else
{
return; // not a valid number return; // not a valid number
} }
if (!tkz.HasMoreTokens()) if (!tkz.HasMoreTokens()) {
{
return; // received nothing but the tableID return; // received nothing but the tableID
} }
tk = tkz.GetNextToken(); tk = tkz.GetNextToken();
} }
if (tableID == 0) if (tableID == 0) {
{ if (! d->dbPattern.Matches(tk)) {
if (! d->dbPattern.Matches(tk))
{
return; // no valid key return; // no valid key
} }
@ -829,100 +767,82 @@ void IRCDDBApp::doUpdate ( wxString& msg )
wxStringTokenizer tkz(msg); wxStringTokenizer tkz(msg);
if (!tkz.HasMoreTokens()) if (!tkz.HasMoreTokens()) {
{
return; // no text in message return; // no text in message
} }
wxString tk = tkz.GetNextToken(); wxString tk = tkz.GetNextToken();
if (d->tablePattern.Matches(tk)) if (d->tablePattern.Matches(tk)) {
{
long i; long i;
if (tk.ToLong(&i)) if (tk.ToLong(&i)) {
{
tableID = i; tableID = i;
if ((tableID < 0) || (tableID >= numberOfTables)) if ((tableID < 0) || (tableID >= numberOfTables)) {
{
wxLogVerbose(wxT("invalid table ID %d"), tableID); wxLogVerbose(wxT("invalid table ID %d"), tableID);
return; return;
} }
} } else {
else
{
return; // not a valid number return; // not a valid number
} }
if (!tkz.HasMoreTokens()) if (!tkz.HasMoreTokens()) {
{
return; // received nothing but the tableID return; // received nothing but the tableID
} }
tk = tkz.GetNextToken(); tk = tkz.GetNextToken();
} }
if (d->datePattern.Matches(tk)) if (d->datePattern.Matches(tk)) {
{ if (!tkz.HasMoreTokens()) {
if (!tkz.HasMoreTokens())
{
return; // nothing after date string return; // nothing after date string
} }
wxString timeToken = tkz.GetNextToken(); wxString timeToken = tkz.GetNextToken();
if (! d->timePattern.Matches(timeToken)) if (! d->timePattern.Matches(timeToken)) {
{
return; // no time string after date string return; // no time string after date string
} }
wxDateTime dt; wxDateTime dt;
if (dt.ParseFormat(tk + wxT(" ") + timeToken, wxT("%Y-%m-%d %H:%M:%S")) == NULL) if (dt.ParseFormat(tk + wxT(" ") + timeToken, wxT("%Y-%m-%d %H:%M:%S")) == NULL) {
{
return; // date+time parsing failed return; // date+time parsing failed
} }
if ((tableID == 0) || (tableID == 1)) if ((tableID == 0) || (tableID == 1)) {
{ if (!tkz.HasMoreTokens()) {
if (!tkz.HasMoreTokens())
{
return; // nothing after time string return; // nothing after time string
} }
wxString key = tkz.GetNextToken(); wxString key = tkz.GetNextToken();
if (! d->dbPattern.Matches(key)) if (! d->dbPattern.Matches(key)) {
{
return; // no valid key return; // no valid key
} }
if (!tkz.HasMoreTokens()) if (!tkz.HasMoreTokens()) {
{
return; // nothing after time string return; // nothing after time string
} }
wxString value = tkz.GetNextToken(); wxString value = tkz.GetNextToken();
if (! d->dbPattern.Matches(value)) if (! d->dbPattern.Matches(value)) {
{
return; // no valid key return; // no valid key
} }
//wxLogVerbose(wxT("TABLE %d ") + key + wxT(" ") + value, tableID ); //wxLogVerbose(wxT("TABLE %d ") + key + wxT(" ") + value, tableID );
if (tableID == 1) if (tableID == 1) {
{
wxMutexLocker lock(d->rptrMapMutex); wxMutexLocker lock(d->rptrMapMutex);
IRCDDBAppRptrObject newRptr(dt, key, value); IRCDDBAppRptrObject newRptr(dt, key, value);
d->rptrMap[key] = newRptr; d->rptrMap[key] = newRptr;
if (d->initReady) if (d->initReady) {
{
wxString arearp_cs = key; wxString arearp_cs = key;
wxString zonerp_cs = value; wxString zonerp_cs = value;
@ -936,9 +856,7 @@ void IRCDDBApp::doUpdate ( wxString& msg )
m2->addParam(getIPAddress(value)); m2->addParam(getIPAddress(value));
d->replyQ.putMessage(m2); d->replyQ.putMessage(m2);
} }
} } else if ((tableID == 0) && d->initReady) {
else if ((tableID == 0) && d->initReady)
{
wxMutexLocker lock(d->rptrMapMutex); wxMutexLocker lock(d->rptrMapMutex);
wxString userCallsign = key; wxString userCallsign = key;
@ -949,8 +867,7 @@ void IRCDDBApp::doUpdate ( wxString& msg )
userCallsign.Replace(wxT("_"), wxT(" ")); userCallsign.Replace(wxT("_"), wxT(" "));
arearp_cs.Replace(wxT("_"), wxT(" ")); arearp_cs.Replace(wxT("_"), wxT(" "));
if (d->rptrMap.count(value) == 1) if (d->rptrMap.count(value) == 1) {
{
IRCDDBAppRptrObject o = d->rptrMap[value]; IRCDDBAppRptrObject o = d->rptrMap[value];
zonerp_cs = o.zonerp_cs; zonerp_cs = o.zonerp_cs;
zonerp_cs.Replace(wxT("_"), wxT(" ")); zonerp_cs.Replace(wxT("_"), wxT(" "));
@ -978,23 +895,15 @@ void IRCDDBApp::doUpdate ( wxString& msg )
static wxString getTableIDString( int tableID, bool spaceBeforeNumber ) static wxString getTableIDString( int tableID, bool spaceBeforeNumber )
{ {
if (tableID == 0) if (tableID == 0) {
{
return wxT(""); return wxT("");
} } else if ((tableID > 0) && (tableID < numberOfTables)) {
else if ((tableID > 0) && (tableID < numberOfTables)) if (spaceBeforeNumber) {
{
if (spaceBeforeNumber)
{
return wxString::Format(wxT(" %d"),tableID); return wxString::Format(wxT(" %d"),tableID);
} } else {
else
{
return wxString::Format(wxT("%d "),tableID); return wxString::Format(wxT("%d "),tableID);
} }
} } else {
else
{
return wxT(" TABLE_ID_OUT_OF_RANGE "); return wxT(" TABLE_ID_OUT_OF_RANGE ");
} }
} }
@ -1003,45 +912,33 @@ static wxString getTableIDString( int tableID, bool spaceBeforeNumber )
void IRCDDBApp::msgQuery (IRCMessage * m) void IRCDDBApp::msgQuery (IRCMessage * m)
{ {
if (m->getPrefixNick().StartsWith(wxT("s-")) && (m->numParams >= 2)) // server msg if (m->getPrefixNick().StartsWith(wxT("s-")) && (m->numParams >= 2)) { // server msg
{
wxString msg = m->params[1]; wxString msg = m->params[1];
wxStringTokenizer tkz(msg); wxStringTokenizer tkz(msg);
if (!tkz.HasMoreTokens()) if (!tkz.HasMoreTokens()) {
{
return; // no text in message return; // no text in message
} }
wxString cmd = tkz.GetNextToken(); wxString cmd = tkz.GetNextToken();
if (cmd.IsSameAs(wxT("UPDATE"))) if (cmd.IsSameAs(wxT("UPDATE"))) {
{
wxString restOfLine = tkz.GetString(); wxString restOfLine = tkz.GetString();
doUpdate(restOfLine); doUpdate(restOfLine);
} } else if (cmd.IsSameAs(wxT("LIST_END"))) {
else if (cmd.IsSameAs(wxT("LIST_END"))) if (d->state == 5) { // if in sendlist processing state
{
if (d->state == 5) // if in sendlist processing state
{
d->state = 3; // get next table d->state = 3; // get next table
} }
} } else if (cmd.IsSameAs(wxT("LIST_MORE"))) {
else if (cmd.IsSameAs(wxT("LIST_MORE"))) if (d->state == 5) { // if in sendlist processing state
{
if (d->state == 5) // if in sendlist processing state
{
d->state = 4; // send next SENDLIST d->state = 4; // send next SENDLIST
} }
} } else if (cmd.IsSameAs(wxT("NOT_FOUND"))) {
else if (cmd.IsSameAs(wxT("NOT_FOUND")))
{
wxString callsign; wxString callsign;
wxString restOfLine = tkz.GetString(); wxString restOfLine = tkz.GetString();
doNotFound(restOfLine, callsign); doNotFound(restOfLine, callsign);
if (callsign.Len() > 0) if (callsign.Len() > 0) {
{
callsign.Replace(wxT("_"), wxT(" ")); callsign.Replace(wxT("_"), wxT(" "));
IRCMessage * m2 = new IRCMessage(wxT("IDRT_USER")); IRCMessage * m2 = new IRCMessage(wxT("IDRT_USER"));
@ -1071,8 +968,7 @@ IRCMessageQueue * IRCDDBApp::getSendQ()
static wxString getLastEntryTime(int tableID) static wxString getLastEntryTime(int tableID)
{ {
if (tableID == 1) if (tableID == 1) {
{
wxString max = IRCDDBAppRptrObject::maxTime.Format( wxT("%Y-%m-%d %H:%M:%S") ); wxString max = IRCDDBAppRptrObject::maxTime.Format( wxT("%Y-%m-%d %H:%M:%S") );
return max; return max;
} }
@ -1092,20 +988,16 @@ wxThread::ExitCode IRCDDBApp::Entry()
int sendlistTableID = 0; int sendlistTableID = 0;
while (!d->terminateThread) while (!d->terminateThread) {
{
if (d->timer > 0) if (d->timer > 0) {
{
d->timer --; d->timer --;
} }
switch(d->state) switch(d->state) {
{
case 0: // wait for network to start case 0: // wait for network to start
if (getSendQ() != NULL) if (getSendQ() != NULL) {
{
d->state = 1; d->state = 1;
} }
break; break;
@ -1118,28 +1010,21 @@ wxThread::ExitCode IRCDDBApp::Entry()
case 2: // choose server case 2: // choose server
wxLogVerbose(wxT("IRCDDBApp: state=2 choose new 's-'-user")); wxLogVerbose(wxT("IRCDDBApp: state=2 choose new 's-'-user"));
if (getSendQ() == NULL) if (getSendQ() == NULL) {
{
d->state = 10; d->state = 10;
} } else {
else if (findServerUser()) {
{
if (findServerUser())
{
sendlistTableID = numberOfTables; sendlistTableID = numberOfTables;
d->state = 3; // next: send "SENDLIST" d->state = 3; // next: send "SENDLIST"
} } else if (d->timer == 0) {
else if (d->timer == 0)
{
d->state = 10; d->state = 10;
IRCMessage * m = new IRCMessage(wxT("QUIT")); IRCMessage * m = new IRCMessage(wxT("QUIT"));
m->addParam(wxT("no op user with 's-' found.")); m->addParam(wxT("no op user with 's-' found."));
IRCMessageQueue * q = getSendQ(); IRCMessageQueue * q = getSendQ();
if (q != NULL) if (q != NULL) {
{
q->putMessage(m); q->putMessage(m);
} }
} }
@ -1147,19 +1032,13 @@ wxThread::ExitCode IRCDDBApp::Entry()
break; break;
case 3: case 3:
if (getSendQ() == NULL) if (getSendQ() == NULL) {
{
d->state = 10; // disconnect DB d->state = 10; // disconnect DB
} } else {
else
{
sendlistTableID --; sendlistTableID --;
if (sendlistTableID < 0) if (sendlistTableID < 0) {
{
d->state = 6; // end of sendlist d->state = 6; // end of sendlist
} } else {
else
{
wxLogVerbose(wxT("IRCDDBApp: state=3 tableID=%d"), sendlistTableID); wxLogVerbose(wxT("IRCDDBApp: state=3 tableID=%d"), sendlistTableID);
d->state = 4; // send "SENDLIST" d->state = 4; // send "SENDLIST"
d->timer = 900; // 15 minutes max for update d->timer = 900; // 15 minutes max for update
@ -1168,48 +1047,37 @@ wxThread::ExitCode IRCDDBApp::Entry()
break; break;
case 4: case 4:
if (getSendQ() == NULL) if (getSendQ() == NULL) {
{
d->state = 10; // disconnect DB d->state = 10; // disconnect DB
} } else {
else if (needsDatabaseUpdate(sendlistTableID)) {
{
if (needsDatabaseUpdate(sendlistTableID))
{
IRCMessage * m = new IRCMessage(d->currentServer, IRCMessage * m = new IRCMessage(d->currentServer,
wxT("SENDLIST") + getTableIDString(sendlistTableID, true) wxT("SENDLIST") + getTableIDString(sendlistTableID, true)
+ wxT(" ") + getLastEntryTime(sendlistTableID) ); + wxT(" ") + getLastEntryTime(sendlistTableID) );
IRCMessageQueue * q = getSendQ(); IRCMessageQueue * q = getSendQ();
if (q != NULL) if (q != NULL) {
{
q->putMessage(m); q->putMessage(m);
} }
d->state = 5; // wait for answers d->state = 5; // wait for answers
} } else {
else
{
d->state = 3; // don't send SENDLIST for this table, go to next table d->state = 3; // don't send SENDLIST for this table, go to next table
} }
} }
break; break;
case 5: // sendlist processing case 5: // sendlist processing
if (getSendQ() == NULL) if (getSendQ() == NULL) {
{
d->state = 10; // disconnect DB d->state = 10; // disconnect DB
} } else if (d->timer == 0) {
else if (d->timer == 0)
{
d->state = 10; // disconnect DB d->state = 10; // disconnect DB
IRCMessage * m = new IRCMessage(wxT("QUIT")); IRCMessage * m = new IRCMessage(wxT("QUIT"));
m->addParam(wxT("timeout SENDLIST")); m->addParam(wxT("timeout SENDLIST"));
IRCMessageQueue * q = getSendQ(); IRCMessageQueue * q = getSendQ();
if (q != NULL) if (q != NULL) {
{
q->putMessage(m); q->putMessage(m);
} }
@ -1217,12 +1085,9 @@ wxThread::ExitCode IRCDDBApp::Entry()
break; break;
case 6: case 6:
if (getSendQ() == NULL) if (getSendQ() == NULL) {
{
d->state = 10; // disconnect DB d->state = 10; // disconnect DB
} } else {
else
{
wxLogVerbose(wxT( "IRCDDBApp: state=6 initialization completed")); wxLogVerbose(wxT( "IRCDDBApp: state=6 initialization completed"));
d->infoTimer = 2; d->infoTimer = 2;
@ -1234,37 +1099,30 @@ wxThread::ExitCode IRCDDBApp::Entry()
case 7: // standby state after initialization case 7: // standby state after initialization
if (getSendQ() == NULL) if (getSendQ() == NULL) {
{
d->state = 10; // disconnect DB d->state = 10; // disconnect DB
} }
if (d->infoTimer > 0) if (d->infoTimer > 0) {
{
d->infoTimer --; d->infoTimer --;
if (d->infoTimer == 0) if (d->infoTimer == 0) {
{ if (d->rptrLocation.Len() > 0) {
if (d->rptrLocation.Len() > 0)
{
IRCMessage * m = new IRCMessage(d->currentServer, IRCMessage * m = new IRCMessage(d->currentServer,
wxT("IRCDDB QTH: ") + d->rptrLocation); wxT("IRCDDB QTH: ") + d->rptrLocation);
IRCMessageQueue * q = getSendQ(); IRCMessageQueue * q = getSendQ();
if (q != NULL) if (q != NULL) {
{
q->putMessage(m); q->putMessage(m);
} }
} }
if (d->rptrInfoURL.Len() > 0) if (d->rptrInfoURL.Len() > 0) {
{
IRCMessage * m = new IRCMessage(d->currentServer, IRCMessage * m = new IRCMessage(d->currentServer,
wxT("IRCDDB URL: ") + d->rptrInfoURL); wxT("IRCDDB URL: ") + d->rptrInfoURL);
IRCMessageQueue * q = getSendQ(); IRCMessageQueue * q = getSendQ();
if (q != NULL) if (q != NULL) {
{
q->putMessage(m); q->putMessage(m);
} }
} }
@ -1272,26 +1130,22 @@ wxThread::ExitCode IRCDDBApp::Entry()
wxMutexLocker lock(d->moduleMapMutex); wxMutexLocker lock(d->moduleMapMutex);
IRCDDBAppModuleMap::iterator it; IRCDDBAppModuleMap::iterator it;
for( it = d->moduleMap.begin(); it != d->moduleMap.end(); ++it ) for( it = d->moduleMap.begin(); it != d->moduleMap.end(); ++it ) {
{
wxString value = it->second; wxString value = it->second;
IRCMessage * m = new IRCMessage(d->currentServer, IRCMessage * m = new IRCMessage(d->currentServer,
wxT("IRCDDB QRG: ") + value); wxT("IRCDDB QRG: ") + value);
IRCMessageQueue * q = getSendQ(); IRCMessageQueue * q = getSendQ();
if (q != NULL) if (q != NULL) {
{
q->putMessage(m); q->putMessage(m);
} }
} }
} }
} }
if (d->wdTimer > 0) if (d->wdTimer > 0) {
{
d->wdTimer --; d->wdTimer --;
if (d->wdTimer == 0) if (d->wdTimer == 0) {
{
d->wdTimer = 900; // 15 minutes d->wdTimer = 900; // 15 minutes
IRCMessage * m = new IRCMessage(d->currentServer, IRCMessage * m = new IRCMessage(d->currentServer,
@ -1300,8 +1154,7 @@ wxThread::ExitCode IRCDDBApp::Entry()
wxString::Format(wxT(" %d"), d->wdCounter )); wxString::Format(wxT(" %d"), d->wdCounter ));
IRCMessageQueue * q = getSendQ(); IRCMessageQueue * q = getSendQ();
if (q != NULL) if (q != NULL) {
{
q->putMessage(m); q->putMessage(m);
d->wdCounter = 0; d->wdCounter = 0;
} }

@ -76,19 +76,16 @@ void IRCMessage::parsePrefix()
{ {
unsigned int i; unsigned int i;
for (i=0; i < 3; i++) for (i=0; i < 3; i++) {
{
prefixComponents.Add(wxT("")); prefixComponents.Add(wxT(""));
} }
int state = 0; int state = 0;
for (i=0; i < prefix.Len(); i++) for (i=0; i < prefix.Len(); i++) {
{
wxChar c = prefix.GetChar(i); wxChar c = prefix.GetChar(i);
switch (c) switch (c) {
{
case wxT('!'): case wxT('!'):
state = 1; // next is name state = 1; // next is name
break; break;
@ -108,8 +105,7 @@ void IRCMessage::parsePrefix()
wxString& IRCMessage::getPrefixNick() wxString& IRCMessage::getPrefixNick()
{ {
if (!prefixParsed) if (!prefixParsed) {
{
parsePrefix(); parsePrefix();
} }
@ -118,8 +114,7 @@ wxString& IRCMessage::getPrefixNick()
wxString& IRCMessage::getPrefixName() wxString& IRCMessage::getPrefixName()
{ {
if (!prefixParsed) if (!prefixParsed) {
{
parsePrefix(); parsePrefix();
} }
@ -128,8 +123,7 @@ wxString& IRCMessage::getPrefixName()
wxString& IRCMessage::getPrefixHost() wxString& IRCMessage::getPrefixHost()
{ {
if (!prefixParsed) if (!prefixParsed) {
{
parsePrefix(); parsePrefix();
} }
@ -140,8 +134,7 @@ void IRCMessage::composeMessage ( wxString& output )
{ {
#if defined(DEBUG_IRC) #if defined(DEBUG_IRC)
wxString d = wxT("T [") + prefix + wxT("] [") + command + wxT("]"); wxString d = wxT("T [") + prefix + wxT("] [") + command + wxT("]");
for (int i=0; i < numParams; i++) for (int i=0; i < numParams; i++) {
{
d.Append(wxT(" [") + params[i] + wxT("]") ); d.Append(wxT(" [") + params[i] + wxT("]") );
} }
d.Replace(wxT("%"), wxT("%%"), true); d.Replace(wxT("%"), wxT("%%"), true);
@ -151,21 +144,16 @@ void IRCMessage::composeMessage ( wxString& output )
wxString o; wxString o;
if (prefix.Len() > 0) if (prefix.Len() > 0) {
{
o = wxT(":") + prefix + wxT(" "); o = wxT(":") + prefix + wxT(" ");
} }
o.Append(command); o.Append(command);
for (int i=0; i < numParams; i++) for (int i=0; i < numParams; i++) {
{ if (i == (numParams - 1)) {
if (i == (numParams - 1))
{
o.Append(wxT(" :") + params[i]); o.Append(wxT(" :") + params[i]);
} } else {
else
{
o.Append(wxT(" ") + params[i]); o.Append(wxT(" ") + params[i]);
} }
} }

@ -32,8 +32,7 @@ IRCMessageQueue::IRCMessageQueue()
IRCMessageQueue::~IRCMessageQueue() IRCMessageQueue::~IRCMessageQueue()
{ {
while (messageAvailable()) while (messageAvailable()) {
{
IRCMessage * m = getMessage(); IRCMessage * m = getMessage();
delete m; delete m;
@ -67,8 +66,7 @@ IRCMessage * IRCMessageQueue::peekFirst()
IRCMessageQueueItem * k = first; IRCMessageQueueItem * k = first;
if ( k == NULL ) if ( k == NULL ) {
{
return NULL; return NULL;
} }
@ -82,8 +80,7 @@ IRCMessage * IRCMessageQueue::getMessage()
IRCMessageQueueItem * k; IRCMessageQueueItem * k;
if (first == NULL) if (first == NULL) {
{
return NULL; return NULL;
} }
@ -91,12 +88,9 @@ IRCMessage * IRCMessageQueue::getMessage()
first = k -> next; first = k -> next;
if (k -> next == NULL) if (k -> next == NULL) {
{
last = NULL; last = NULL;
} } else {
else
{
k -> next -> prev = NULL; k -> next -> prev = NULL;
} }
@ -120,12 +114,9 @@ void IRCMessageQueue::putMessage( IRCMessage * m )
k -> prev = last; k -> prev = last;
k -> next = NULL; k -> next = NULL;
if (last == NULL) if (last == NULL) {
{
first = k; first = k;
} } else {
else
{
last -> next = k; last -> next = k;
} }

@ -30,13 +30,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class IRCMessageQueueItem class IRCMessageQueueItem
{ {
public: public:
IRCMessageQueueItem( IRCMessage * m ) IRCMessageQueueItem( IRCMessage * m ) {
{
msg = m; msg = m;
} }
~IRCMessageQueueItem() ~IRCMessageQueueItem() {
{
} }
IRCMessage * msg; IRCMessage * msg;

@ -37,8 +37,7 @@ IRCProtocol::IRCProtocol ( IRCApplication * app,
this->versionInfo = wxT("CIRCDDB:"); this->versionInfo = wxT("CIRCDDB:");
this->versionInfo.Append(wxT(CIRCDDB_VERSION)); this->versionInfo.Append(wxT(CIRCDDB_VERSION));
if (versionInfo.Len() > 0) if (versionInfo.Len() > 0) {
{
this->versionInfo.Append(wxT(" ")); this->versionInfo.Append(wxT(" "));
this->versionInfo.Append(versionInfo); this->versionInfo.Append(versionInfo);
} }
@ -46,8 +45,7 @@ IRCProtocol::IRCProtocol ( IRCApplication * app,
int hyphenPos = callsign.find(wxT('-')); int hyphenPos = callsign.find(wxT('-'));
if (hyphenPos == wxNOT_FOUND) if (hyphenPos == wxNOT_FOUND) {
{
wxString n; wxString n;
n = callsign + wxT("-1"); n = callsign + wxT("-1");
@ -58,9 +56,7 @@ IRCProtocol::IRCProtocol ( IRCApplication * app,
nicks.Add(n); nicks.Add(n);
n = callsign + wxT("-4"); n = callsign + wxT("-4");
nicks.Add(n); nicks.Add(n);
} } else {
else
{
nicks.Add(callsign); nicks.Add(callsign);
} }
@ -87,18 +83,14 @@ void IRCProtocol::chooseNewNick()
void IRCProtocol::setNetworkReady( bool b ) void IRCProtocol::setNetworkReady( bool b )
{ {
if (b == true) if (b == true) {
{ if (state != 0) {
if (state != 0)
{
wxLogError(wxT("IRCProtocol::setNetworkReady: unexpected state")); wxLogError(wxT("IRCProtocol::setNetworkReady: unexpected state"));
} }
state = 1; state = 1;
chooseNewNick(); chooseNewNick();
} } else {
else
{
state = 0; state = 0;
} }
} }
@ -106,19 +98,16 @@ void IRCProtocol::setNetworkReady( bool b )
bool IRCProtocol::processQueues ( IRCMessageQueue * recvQ, IRCMessageQueue * sendQ ) bool IRCProtocol::processQueues ( IRCMessageQueue * recvQ, IRCMessageQueue * sendQ )
{ {
if (timer > 0) if (timer > 0) {
{
timer --; timer --;
} }
while (recvQ->messageAvailable()) while (recvQ->messageAvailable()) {
{
IRCMessage * m = recvQ -> getMessage(); IRCMessage * m = recvQ -> getMessage();
#if defined(DEBUG_IRC) #if defined(DEBUG_IRC)
wxString d = wxT("R [") + m->prefix + wxT("] [") + m->command + wxT("]"); wxString d = wxT("R [") + m->prefix + wxT("] [") + m->command + wxT("]");
for (int i=0; i < m->numParams; i++) for (int i=0; i < m->numParams; i++) {
{
d.Append(wxT(" [") + m->params[i] + wxT("]") ); d.Append(wxT(" [") + m->params[i] + wxT("]") );
} }
d.Replace(wxT("%"), wxT("%%"), true); d.Replace(wxT("%"), wxT("%%"), true);
@ -126,170 +115,111 @@ bool IRCProtocol::processQueues ( IRCMessageQueue * recvQ, IRCMessageQueue * sen
wxLogVerbose(d); wxLogVerbose(d);
#endif #endif
if (m->command.IsSameAs(wxT("004"))) if (m->command.IsSameAs(wxT("004"))) {
{ if (state == 4) {
if (state == 4) if (m->params.GetCount() > 1) {
{
if (m->params.GetCount() > 1)
{
wxRegEx serverNamePattern(wxT("^grp[1-9]s[1-9].ircDDB$")); wxRegEx serverNamePattern(wxT("^grp[1-9]s[1-9].ircDDB$"));
if (serverNamePattern.Matches( m->params[1] )) if (serverNamePattern.Matches( m->params[1] )) {
{
app->setBestServer(wxT("s-") + m->params[1].Mid(0,6)); app->setBestServer(wxT("s-") + m->params[1].Mid(0,6));
} }
} }
state = 5; // next: JOIN state = 5; // next: JOIN
app->setCurrentNick(currentNick); app->setCurrentNick(currentNick);
} }
} } else if (m->command.IsSameAs(wxT("PING"))) {
else if (m->command.IsSameAs(wxT("PING")))
{
IRCMessage * m2 = new IRCMessage(); IRCMessage * m2 = new IRCMessage();
m2->command = wxT("PONG"); m2->command = wxT("PONG");
if (m->params.GetCount() > 0) if (m->params.GetCount() > 0) {
{
m2->numParams = 1; m2->numParams = 1;
m2->params.Add( m->params[0] ); m2->params.Add( m->params[0] );
} }
sendQ -> putMessage(m2); sendQ -> putMessage(m2);
} } else if (m->command.IsSameAs(wxT("JOIN"))) {
else if (m->command.IsSameAs(wxT("JOIN"))) if ((m->numParams >= 1) && m->params[0].IsSameAs(channel)) {
{ if (m->getPrefixNick().IsSameAs(currentNick) && (state == 6)) {
if ((m->numParams >= 1) && m->params[0].IsSameAs(channel)) if (debugChannel.Len() > 0) {
{
if (m->getPrefixNick().IsSameAs(currentNick) && (state == 6))
{
if (debugChannel.Len() > 0)
{
state = 7; // next: join debug_channel state = 7; // next: join debug_channel
} } else {
else
{
state = 10; // next: WHO * state = 10; // next: WHO *
} }
} } else if (app != NULL) {
else if (app != NULL)
{
app->userJoin( m->getPrefixNick(), m->getPrefixName(), m->getPrefixHost()); app->userJoin( m->getPrefixNick(), m->getPrefixName(), m->getPrefixHost());
} }
} }
if ((m->numParams >= 1) && m->params[0].IsSameAs(debugChannel)) if ((m->numParams >= 1) && m->params[0].IsSameAs(debugChannel)) {
{ if (m->getPrefixNick().IsSameAs(currentNick) && (state == 8)) {
if (m->getPrefixNick().IsSameAs(currentNick) && (state == 8))
{
state = 10; // next: WHO * state = 10; // next: WHO *
} }
} }
} } else if (m->command.IsSameAs(wxT("PONG"))) {
else if (m->command.IsSameAs(wxT("PONG"))) if (state == 12) {
{
if (state == 12)
{
timer = pingTimer; timer = pingTimer;
state = 11; state = 11;
} }
} } else if (m->command.IsSameAs(wxT("PART"))) {
else if (m->command.IsSameAs(wxT("PART"))) if ((m->numParams >= 1) && m->params[0].IsSameAs(channel)) {
{ if (app != NULL) {
if ((m->numParams >= 1) && m->params[0].IsSameAs(channel))
{
if (app != NULL)
{
app->userLeave( m->getPrefixNick() ); app->userLeave( m->getPrefixNick() );
} }
} }
} } else if (m->command.IsSameAs(wxT("KICK"))) {
else if (m->command.IsSameAs(wxT("KICK"))) if ((m->numParams >= 2) && m->params[0].IsSameAs(channel)) {
{ if (m->params[1].IsSameAs(currentNick)) {
if ((m->numParams >= 2) && m->params[0].IsSameAs(channel))
{
if (m->params[1].IsSameAs(currentNick))
{
// i was kicked!! // i was kicked!!
delete m; delete m;
return false; return false;
} } else if (app != NULL) {
else if (app != NULL)
{
app->userLeave( m->params[1] ); app->userLeave( m->params[1] );
} }
} }
} } else if (m->command.IsSameAs(wxT("QUIT"))) {
else if (m->command.IsSameAs(wxT("QUIT"))) if (app != NULL) {
{
if (app != NULL)
{
app->userLeave( m->getPrefixNick() ); app->userLeave( m->getPrefixNick() );
} }
} } else if (m->command.IsSameAs(wxT("MODE"))) {
else if (m->command.IsSameAs(wxT("MODE"))) if ((m->numParams >= 3) && m->params[0].IsSameAs(channel)) {
{ if (app != NULL) {
if ((m->numParams >= 3) && m->params[0].IsSameAs(channel))
{
if (app != NULL)
{
size_t i; size_t i;
wxString mode = m->params[1]; wxString mode = m->params[1];
for (i = 1; (i < mode.Len()) && ((size_t) m->numParams >= (i+2)); i++) for (i = 1; (i < mode.Len()) && ((size_t) m->numParams >= (i+2)); i++) {
{ if ( mode[i] == wxT('o') ) {
if ( mode[i] == wxT('o') ) if ( mode[0] == wxT('+') ) {
{
if ( mode[0] == wxT('+') )
{
app->userChanOp(m->params[i+1], true); app->userChanOp(m->params[i+1], true);
} } else if ( mode[0] == wxT('-') ) {
else if ( mode[0] == wxT('-') )
{
app->userChanOp(m->params[i+1], false); app->userChanOp(m->params[i+1], false);
} }
} }
} // for } // for
} }
} }
} } else if (m->command.IsSameAs(wxT("PRIVMSG"))) {
else if (m->command.IsSameAs(wxT("PRIVMSG"))) if ((m->numParams == 2) && (app != NULL)) {
{ if (m->params[0].IsSameAs(channel)) {
if ((m->numParams == 2) && (app != NULL))
{
if (m->params[0].IsSameAs(channel))
{
app->msgChannel(m); app->msgChannel(m);
} } else if (m->params[0].IsSameAs(currentNick)) {
else if (m->params[0].IsSameAs(currentNick))
{
app->msgQuery(m); app->msgQuery(m);
} }
} }
} } else if (m->command.IsSameAs(wxT("352"))) { // WHO list
else if (m->command.IsSameAs(wxT("352"))) // WHO list
{
if ((m->numParams >= 7) && m->params[0].IsSameAs(currentNick) if ((m->numParams >= 7) && m->params[0].IsSameAs(currentNick)
&& m->params[1].IsSameAs(channel)) && m->params[1].IsSameAs(channel)) {
{ if (app != NULL) {
if (app != NULL)
{
app->userJoin( m->params[5], m->params[2], m->params[3]); app->userJoin( m->params[5], m->params[2], m->params[3]);
app->userChanOp ( m->params[5], m->params[6].IsSameAs(wxT("H@"))); app->userChanOp ( m->params[5], m->params[6].IsSameAs(wxT("H@")));
} }
} }
} } else if (m->command.IsSameAs(wxT("433"))) { // nick collision
else if (m->command.IsSameAs(wxT("433"))) // nick collision if (state == 2) {
{
if (state == 2)
{
state = 3; // nick collision, choose new nick state = 3; // nick collision, choose new nick
timer = 10; // wait 5 seconds.. timer = 10; // wait 5 seconds..
} }
} } else if (m->command.IsSameAs(wxT("332")) ||
else if (m->command.IsSameAs(wxT("332")) || m->command.IsSameAs(wxT("TOPIC"))) { // topic
m->command.IsSameAs(wxT("TOPIC"))) // topic
{
if ((m->numParams == 2) && (app != NULL) && if ((m->numParams == 2) && (app != NULL) &&
m->params[0].IsSameAs(channel) ) m->params[0].IsSameAs(channel) ) {
{
app->setTopic(m->params[1]); app->setTopic(m->params[1]);
} }
} }
@ -299,8 +229,7 @@ bool IRCProtocol::processQueues ( IRCMessageQueue * recvQ, IRCMessageQueue * sen
IRCMessage * m; IRCMessage * m;
switch (state) switch (state) {
{
case 1: case 1:
m = new IRCMessage(); m = new IRCMessage();
m->command = wxT("PASS"); m->command = wxT("PASS");
@ -319,8 +248,7 @@ bool IRCProtocol::processQueues ( IRCMessageQueue * recvQ, IRCMessageQueue * sen
break; break;
case 2: case 2:
if (timer == 0) if (timer == 0) {
{
m = new IRCMessage(); m = new IRCMessage();
m->command = wxT("USER"); m->command = wxT("USER");
m->numParams = 4; m->numParams = 4;
@ -336,8 +264,7 @@ bool IRCProtocol::processQueues ( IRCMessageQueue * recvQ, IRCMessageQueue * sen
break; break;
case 3: case 3:
if (timer == 0) if (timer == 0) {
{
chooseNewNick(); chooseNewNick();
m = new IRCMessage(); m = new IRCMessage();
m->command = wxT("NICK"); m->command = wxT("NICK");
@ -351,8 +278,7 @@ bool IRCProtocol::processQueues ( IRCMessageQueue * recvQ, IRCMessageQueue * sen
break; break;
case 4: case 4:
if (timer == 0) if (timer == 0) {
{
// no login message received -> disconnect // no login message received -> disconnect
return false; return false;
} }
@ -370,16 +296,14 @@ bool IRCProtocol::processQueues ( IRCMessageQueue * recvQ, IRCMessageQueue * sen
break; break;
case 6: case 6:
if (timer == 0) if (timer == 0) {
{
// no join message received -> disconnect // no join message received -> disconnect
return false; return false;
} }
break; break;
case 7: case 7:
if (debugChannel.Len() == 0) if (debugChannel.Len() == 0) {
{
return false; // this state cannot be processed if there is no debug_channel return false; // this state cannot be processed if there is no debug_channel
} }
@ -394,8 +318,7 @@ bool IRCProtocol::processQueues ( IRCMessageQueue * recvQ, IRCMessageQueue * sen
break; break;
case 8: case 8:
if (timer == 0) if (timer == 0) {
{
// no join message received -> disconnect // no join message received -> disconnect
return false; return false;
} }
@ -412,15 +335,13 @@ bool IRCProtocol::processQueues ( IRCMessageQueue * recvQ, IRCMessageQueue * sen
timer = pingTimer; timer = pingTimer;
state = 11; // wait for timer and then send ping state = 11; // wait for timer and then send ping
if (app != NULL) if (app != NULL) {
{
app->setSendQ(sendQ); // this switches the application on app->setSendQ(sendQ); // this switches the application on
} }
break; break;
case 11: case 11:
if (timer == 0) if (timer == 0) {
{
m = new IRCMessage(); m = new IRCMessage();
m->command = wxT("PING"); m->command = wxT("PING");
m->numParams = 1; m->numParams = 1;
@ -433,8 +354,7 @@ bool IRCProtocol::processQueues ( IRCMessageQueue * recvQ, IRCMessageQueue * sen
break; break;
case 12: case 12:
if (timer == 0) if (timer == 0) {
{
// no pong message received -> disconnect // no pong message received -> disconnect
return false; return false;
} }

@ -54,16 +54,14 @@ IRCReceiver::~IRCReceiver()
bool IRCReceiver::startWork() bool IRCReceiver::startWork()
{ {
if (Create() != wxTHREAD_NO_ERROR) if (Create() != wxTHREAD_NO_ERROR) {
{
wxLogError(wxT("IRCReceiver::startWork: Could not create the worker thread!")); wxLogError(wxT("IRCReceiver::startWork: Could not create the worker thread!"));
return false; return false;
} }
terminateThread = false; terminateThread = false;
if (Run() != wxTHREAD_NO_ERROR) if (Run() != wxTHREAD_NO_ERROR) {
{
wxLogError(wxT("IRCReceiver::startWork: Could not run the worker thread!")); wxLogError(wxT("IRCReceiver::startWork: Could not run the worker thread!"));
return false; return false;
} }
@ -95,35 +93,25 @@ static int doRead( int sock, char * buf, int buf_size )
res = select(sock+1, &rdset, NULL, &errset, &tv); res = select(sock+1, &rdset, NULL, &errset, &tv);
if ( res < 0 ) if ( res < 0 ) {
{
wxLogSysError(wxT("IRCReceiver::doRead: select")); wxLogSysError(wxT("IRCReceiver::doRead: select"));
return -1; return -1;
} } else if ( res > 0 ) {
else if ( res > 0 ) if (FD_ISSET(sock, &errset)) {
{
if (FD_ISSET(sock, &errset))
{
wxLogVerbose(wxT("IRCReceiver::doRead: select (FD_ISSET(sock, exceptfds))")); wxLogVerbose(wxT("IRCReceiver::doRead: select (FD_ISSET(sock, exceptfds))"));
return -1; return -1;
} }
if (FD_ISSET(sock, &rdset)) if (FD_ISSET(sock, &rdset)) {
{
res = recv(sock, buf, buf_size, 0); res = recv(sock, buf, buf_size, 0);
if (res < 0) if (res < 0) {
{
wxLogSysError(wxT("IRCReceiver::doRead: read")); wxLogSysError(wxT("IRCReceiver::doRead: read"));
return -1; return -1;
} } else if (res == 0) {
else if (res == 0)
{
wxLogVerbose(wxT("IRCReceiver::doRead: EOF read==0")); wxLogVerbose(wxT("IRCReceiver::doRead: EOF read==0"));
return -1; return -1;
} } else {
else
{
return res; return res;
} }
} }
@ -140,96 +128,70 @@ wxThread::ExitCode IRCReceiver::Entry ()
int i; int i;
int state = 0; int state = 0;
while (!terminateThread) while (!terminateThread) {
{
// wxLogVerbose(wxT("IRCReceiver: tick")); // wxLogVerbose(wxT("IRCReceiver: tick"));
char buf[200]; char buf[200];
int r = doRead( sock, buf, sizeof buf ); int r = doRead( sock, buf, sizeof buf );
if (r < 0) if (r < 0) {
{
recvQ -> signalEOF(); recvQ -> signalEOF();
delete m; // delete unfinished IRCMessage delete m; // delete unfinished IRCMessage
break; break;
} }
for (i=0; i < r; i++) for (i=0; i < r; i++) {
{
char b = buf[i]; char b = buf[i];
if (b > 0) if (b > 0) {
{ if (b == 10) {
if (b == 10)
{
recvQ -> putMessage(m); recvQ -> putMessage(m);
m = new IRCMessage(); m = new IRCMessage();
state = 0; state = 0;
} } else if (b == 13) {
else if (b == 13)
{
// do nothing // do nothing
} } else switch (state) {
else switch (state)
{
case 0: case 0:
if (b == ':') if (b == ':') {
{
state = 1; // prefix state = 1; // prefix
} } else if (b == 32) {
else if (b == 32)
{
// do nothing // do nothing
} } else {
else
{
m -> command.Append(wxChar(b)); m -> command.Append(wxChar(b));
state = 2; // command state = 2; // command
} }
break; break;
case 1: case 1:
if (b == 32) if (b == 32) {
{
state = 2; // command is next state = 2; // command is next
} } else {
else
{
m -> prefix.Append(wxChar(b)); m -> prefix.Append(wxChar(b));
} }
break; break;
case 2: case 2:
if (b == 32) if (b == 32) {
{
state = 3; // params state = 3; // params
m -> numParams = 1; m -> numParams = 1;
m -> params.Add(wxT("")); m -> params.Add(wxT(""));
} } else {
else
{
m -> command.Append(wxChar(b)); m -> command.Append(wxChar(b));
} }
break; break;
case 3: case 3:
if (b == 32) if (b == 32) {
{
m -> numParams ++; m -> numParams ++;
if (m -> numParams >= 15) if (m -> numParams >= 15) {
{
state = 5; // ignore the rest state = 5; // ignore the rest
} }
m -> params.Add(wxT("")); m -> params.Add(wxT(""));
} } else if ((b == ':') && (m -> params[ m -> numParams-1 ].Len() == 0)) {
else if ((b == ':') && (m -> params[ m -> numParams-1 ].Len() == 0))
{
state = 4; // rest of line is this param state = 4; // rest of line is this param
} } else {
else
{
m -> params[ m -> numParams-1 ].Append(wxChar(b)); m -> params[ m -> numParams-1 ].Append(wxChar(b));
} }
break; break;

@ -55,23 +55,18 @@ int getAllIPV4Addresses ( const char * name, unsigned short port,
int r = getaddrinfo( name, NULL, &hints, &res ); int r = getaddrinfo( name, NULL, &hints, &res );
if (r == 0) if (r == 0) {
{
struct addrinfo * rp; struct addrinfo * rp;
unsigned int numAddr = 0; unsigned int numAddr = 0;
for (rp = res; rp != NULL; rp = rp->ai_next) for (rp = res; rp != NULL; rp = rp->ai_next) {
{ if (rp->ai_family == AF_INET) {
if (rp->ai_family == AF_INET)
{
numAddr ++; numAddr ++;
} }
} }
if (numAddr > 0) if (numAddr > 0) {
{ if (numAddr > max_addr) {
if (numAddr > max_addr)
{
numAddr = max_addr; numAddr = max_addr;
} }
@ -79,15 +74,12 @@ int getAllIPV4Addresses ( const char * name, unsigned short port,
unsigned int i; unsigned int i;
for (i=0; i < numAddr; i++) for (i=0; i < numAddr; i++) {
{
shuffle[i] = i; shuffle[i] = i;
} }
for (i=0; i < (numAddr - 1); i++) for (i=0; i < (numAddr - 1); i++) {
{ if (rand() & 1) {
if (rand() & 1)
{
int tmp; int tmp;
tmp = shuffle[i]; tmp = shuffle[i];
shuffle[i] = shuffle[i+1]; shuffle[i] = shuffle[i+1];
@ -95,10 +87,8 @@ int getAllIPV4Addresses ( const char * name, unsigned short port,
} }
} }
for (i=(numAddr - 1); i > 0; i--) for (i=(numAddr - 1); i > 0; i--) {
{ if (rand() & 1) {
if (rand() & 1)
{
int tmp; int tmp;
tmp = shuffle[i]; tmp = shuffle[i];
shuffle[i] = shuffle[i-1]; shuffle[i] = shuffle[i-1];
@ -106,10 +96,8 @@ int getAllIPV4Addresses ( const char * name, unsigned short port,
} }
} }
for (rp = res, i=0 ; (rp != NULL) && (i < numAddr); rp = rp->ai_next) for (rp = res, i=0 ; (rp != NULL) && (i < numAddr); rp = rp->ai_next) {
{ if (rp->ai_family == AF_INET) {
if (rp->ai_family == AF_INET)
{
memcpy( addr+shuffle[i], rp->ai_addr, sizeof (struct sockaddr_in) ); memcpy( addr+shuffle[i], rp->ai_addr, sizeof (struct sockaddr_in) );
addr[shuffle[i]].sin_port = htons(port); addr[shuffle[i]].sin_port = htons(port);
@ -127,9 +115,7 @@ int getAllIPV4Addresses ( const char * name, unsigned short port,
return 0; return 0;
} } else {
else
{
wxString e( gai_strerror(r), wxConvUTF8); wxString e( gai_strerror(r), wxConvUTF8);
wxLogWarning(wxT("getaddrinfo: ") + e ); wxLogWarning(wxT("getaddrinfo: ") + e );
@ -148,8 +134,7 @@ void safeStringCopy (char * dest, const char * src, unsigned int buf_size)
{ {
unsigned int i = 0; unsigned int i = 0;
while (i < (buf_size - 1) && (src[i] != 0)) while (i < (buf_size - 1) && (src[i] != 0)) {
{
dest[i] = src[i]; dest[i] = src[i];
i++; i++;
} }

@ -22,8 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dstar_dv.h" #include "dstar_dv.h"
#include "golay23.h" #include "golay23.h"
int bit_pos1[] = int bit_pos1[] = {
{
0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2,
0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2,
0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2,
@ -39,8 +38,7 @@ int bit_pos1[] =
0, 0, 1, 1, 2, 2 0, 0, 1, 1, 2, 2
}; };
int bit_pos2[] = int bit_pos2[] = {
{
23, 11, 23, 11,
23, 11, 23, 11,
23, 11, 23, 11,
@ -100,8 +98,7 @@ static void init_prng(void)
{ {
int i; int i;
for (i=0; i < 4096; i++) for (i=0; i < 4096; i++) {
{
int mask = 0x800000; int mask = 0x800000;
int j; int j;
int pr; int pr;
@ -109,12 +106,10 @@ static void init_prng(void)
prng[i] = 0; prng[i] = 0;
pr = i << 4; pr = i << 4;
for (j=0; j < 24; j++) for (j=0; j < 24; j++) {
{
pr = ((173 * pr) + 13849) & 0xFFFF; pr = ((173 * pr) + 13849) & 0xFFFF;
if ((pr & 0x8000) != 0) if ((pr & 0x8000) != 0) {
{
prng[i] |= mask; prng[i] |= mask;
} }
@ -133,8 +128,7 @@ void dstar_dv_init(void)
decoding_table[0] = 0; decoding_table[0] = 0;
decoding_table[1] = 1; decoding_table[1] = 1;
temp = 1; temp = 1;
for (i=2; i<= 23; i++) for (i=2; i<= 23; i++) {
{
temp = temp << 1; temp = temp << 1;
decoding_table[get_syndrome(temp)] = temp; decoding_table[get_syndrome(temp)] = temp;
} }
@ -143,8 +137,7 @@ void dstar_dv_init(void)
a[2] = 2; a[2] = 2;
temp = arr2int(a,2); temp = arr2int(a,2);
decoding_table[get_syndrome(temp)] = temp; decoding_table[get_syndrome(temp)] = temp;
for (i=1; i<253; i++) for (i=1; i<253; i++) {
{
nextcomb(23,2,a); nextcomb(23,2,a);
temp = arr2int(a,2); temp = arr2int(a,2);
decoding_table[get_syndrome(temp)] = temp; decoding_table[get_syndrome(temp)] = temp;
@ -155,8 +148,7 @@ void dstar_dv_init(void)
a[3] = 3; a[3] = 3;
temp = arr2int(a,3); temp = arr2int(a,3);
decoding_table[get_syndrome(temp)] = temp; decoding_table[get_syndrome(temp)] = temp;
for (i=1; i<1771; i++) for (i=1; i<1771; i++) {
{
nextcomb(23,3,a); nextcomb(23,3,a);
temp = arr2int(a,3); temp = arr2int(a,3);
decoding_table[get_syndrome(temp)] = temp; decoding_table[get_syndrome(temp)] = temp;
@ -175,26 +167,22 @@ static int golay2412 (int data, int *decoded)
int parity_corr = 0; int parity_corr = 0;
int i; int i;
for (i = 0; i < 23; i++) for (i = 0; i < 23; i++) {
{
int mask = 1 << i; int mask = 1 << i;
int bit_rcvd = block & mask; int bit_rcvd = block & mask;
int bit_corr = corrected_block & mask; int bit_corr = corrected_block & mask;
if (bit_corr != 0) if (bit_corr != 0) {
{
parity_corr ++; parity_corr ++;
} }
if (bit_rcvd != bit_corr) if (bit_rcvd != bit_corr) {
{
errs ++; errs ++;
} }
} }
if ((parity_corr & 0x01) != (data & 0x01)) if ((parity_corr & 0x01) != (data & 0x01)) {
{
errs ++; errs ++;
} }
@ -210,13 +198,11 @@ int dstar_dv_decode_first_block (const unsigned char * d, int * errs)
int i; int i;
int data; int data;
for (i=0; i < 3; i++) for (i=0; i < 3; i++) {
{
bits[i] = 0; bits[i] = 0;
} }
for (i=0; i < 72; i++) for (i=0; i < 72; i++) {
{
bits[ bit_pos1[i] ] |= (d[ i >> 3 ] & (0x80 >> (i & 0x07))) ? (1 << bit_pos2[i]) : 0; bits[ bit_pos1[i] ] |= (d[ i >> 3 ] & (0x80 >> (i & 0x07))) ? (1 << bit_pos2[i]) : 0;
} }
@ -232,13 +218,11 @@ int dstar_dv_decode (const unsigned char * d, int data[3])
int i; int i;
int errs; int errs;
for (i=0; i < 3; i++) for (i=0; i < 3; i++) {
{
bits[i] = 0; bits[i] = 0;
} }
for (i=0; i < 72; i++) for (i=0; i < 72; i++) {
{
bits[ bit_pos1[i] ] |= (d[ i >> 3 ] & (0x80 >> (i & 0x07))) ? (1 << bit_pos2[i]) : 0; bits[ bit_pos1[i] ] |= (d[ i >> 3 ] & (0x80 >> (i & 0x07))) ? (1 << bit_pos2[i]) : 0;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -46,23 +46,11 @@ static void calcPFCS(unsigned char rawbytes[58]);
static time_t tNow = 0; static time_t tNow = 0;
static short streamid_raw = 0; static short streamid_raw = 0;
/*** //static unsigned char silence[12] = { 0x4e,0x8d,0x32,0x88,0x26,0x1a,0x3f,0x61,0xe8,0x70,0x4f,0x93 };
static char silence[12] = static unsigned char silence[12] = { 0xfa,0x87,0x1e,0x32,0x30,0x2f,0xea,0x45,0x66,0x70,0x4f,0x93 };
{
0x4e,0x8d,0x32,0x88,0x26,0x1a,0x3f,0x61,0xe8,
0x70,0x4f,0x93
};
***/
static char silence[12] =
{
0xfa,0x87,0x1e,0x32,0x30,0x2f,0xea,0x45,0x66,
0x70,0x4f,0x93
};
static unsigned short crc_tabccitt[256] = {
static unsigned short crc_tabccitt[256] =
{
0x0000,0x1189,0x2312,0x329b,0x4624,0x57ad,0x6536,0x74bf, 0x0000,0x1189,0x2312,0x329b,0x4624,0x57ad,0x6536,0x74bf,
0x8c48,0x9dc1,0xaf5a,0xbed3,0xca6c,0xdbe5,0xe97e,0xf8f7, 0x8c48,0x9dc1,0xaf5a,0xbed3,0xca6c,0xdbe5,0xe97e,0xf8f7,
0x1081,0x0108,0x3393,0x221a,0x56a5,0x472c,0x75b7,0x643e, 0x1081,0x0108,0x3393,0x221a,0x56a5,0x472c,0x75b7,0x643e,
@ -104,8 +92,7 @@ static void calcPFCS(unsigned char rawbytes[58])
unsigned short tmp, short_c; unsigned short tmp, short_c;
short int i; short int i;
for (i = 17; i < 56 ; i++) for (i = 17; i < 56 ; i++) {
{
short_c = 0x00ff & (unsigned short)rawbytes[i]; short_c = 0x00ff & (unsigned short)rawbytes[i];
tmp = (crc_dstar_ffff & 0x00ff) ^ short_c; tmp = (crc_dstar_ffff & 0x00ff) ^ short_c;
crc_dstar_ffff = (crc_dstar_ffff >> 8) ^ crc_tabccitt[tmp]; crc_dstar_ffff = (crc_dstar_ffff >> 8) ^ crc_tabccitt[tmp];
@ -123,14 +110,13 @@ static bool dst_open(char *ip, int port)
int reuse = 1; int reuse = 1;
sockDst = socket(PF_INET,SOCK_DGRAM,0); sockDst = socket(PF_INET,SOCK_DGRAM,0);
if (sockDst == -1) if (sockDst == -1) {
{
printf("Failed to create DSTAR socket\n"); printf("Failed to create DSTAR socket\n");
return false; return false;
} }
if (setsockopt(sockDst,SOL_SOCKET,SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) == -1) if (setsockopt(sockDst,SOL_SOCKET,SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) == -1) {
{ close(sockDst);
close(sockDst); sockDst = -1; sockDst = -1;
printf("setsockopt DSTAR REUSE failed\n"); printf("setsockopt DSTAR REUSE failed\n");
return false; return false;
} }
@ -145,8 +131,7 @@ static bool dst_open(char *ip, int port)
static void dst_close() static void dst_close()
{ {
if (sockDst != -1) if (sockDst != -1) {
{
close(sockDst); close(sockDst);
sockDst = -1; sockDst = -1;
} }
@ -161,8 +146,7 @@ int main(int argc, char **argv)
char RADIO_ID[21]; char RADIO_ID[21];
short int i; short int i;
if (argc != 10) if (argc != 10) {
{
printf("Usage: g2link_test <IPaddress> <port> <textMessage> <repeaterCallsign> <module> <delay_between> <delay_before> <MYCALL> <YRCALL>\n"); printf("Usage: g2link_test <IPaddress> <port> <textMessage> <repeaterCallsign> <module> <delay_between> <delay_before> <MYCALL> <YRCALL>\n");
printf("Example: g2link_test 127.0.0.1 19000 \"HELLO\" KJ4NHF B 20 2 KI4LKF XRF005AL\n"); printf("Example: g2link_test 127.0.0.1 19000 \"HELLO\" KJ4NHF B 20 2 KI4LKF XRF005AL\n");
printf("Where...\n\n"); printf("Where...\n\n");
@ -179,8 +163,7 @@ int main(int argc, char **argv)
return 0; return 0;
} }
if (strlen(argv[4]) > 6) if (strlen(argv[4]) > 6) {
{
printf("repeaterCallsign can not be more than 6 characters, %s is invalid\n", argv[4]); printf("repeaterCallsign can not be more than 6 characters, %s is invalid\n", argv[4]);
return 0; return 0;
} }
@ -188,8 +171,7 @@ int main(int argc, char **argv)
argv[4][i] = toupper(argv[4][i]); argv[4][i] = toupper(argv[4][i]);
if (strlen(argv[8]) > 8) if (strlen(argv[8]) > 8) {
{
printf("MYCALL can not be nore than 8 characters, %s is invalid\n", argv[8]); printf("MYCALL can not be nore than 8 characters, %s is invalid\n", argv[8]);
return 0; return 0;
} }
@ -197,16 +179,14 @@ int main(int argc, char **argv)
argv[8][i] = toupper(argv[8][i]); argv[8][i] = toupper(argv[8][i]);
if (strlen(argv[9]) > 8) if (strlen(argv[9]) > 8) {
{
printf("YRCALL can not be nore than 8 characters, %s is invalid\n", argv[9]); printf("YRCALL can not be nore than 8 characters, %s is invalid\n", argv[9]);
return 0; return 0;
} }
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
argv[9][i] = toupper(argv[9][i]); argv[9][i] = toupper(argv[9][i]);
if ((argv[5][0] != 'A') && (argv[5][0] != 'B') && (argv[5][0] != 'C')) if ((argv[5][0] != 'A') && (argv[5][0] != 'B') && (argv[5][0] != 'C')) {
{
printf("module must be one of A B C\n"); printf("module must be one of A B C\n");
return 0; return 0;
} }
@ -226,8 +206,7 @@ int main(int argc, char **argv)
time(&tNow); time(&tNow);
srand(tNow + getpid()); srand(tNow + getpid());
if (dst_open(argv[1], atoi(argv[2]))) if (dst_open(argv[1], atoi(argv[2]))) {
{
streamid_raw = (short)(::rand() & 0xFFFF); streamid_raw = (short)(::rand() & 0xFFFF);
memcpy(dstar_buf,"DSTR", 4); memcpy(dstar_buf,"DSTR", 4);
dstar_buf[5] = (unsigned char)(G2_COUNTER & 0xff); dstar_buf[5] = (unsigned char)(G2_COUNTER & 0xff);
@ -242,11 +221,9 @@ int main(int argc, char **argv)
dstar_buf[12] = 0x01; dstar_buf[12] = 0x01;
if (argv[5][0] == 'A') if (argv[5][0] == 'A')
dstar_buf[13] = 0x03; dstar_buf[13] = 0x03;
else else if (argv[5][0] == 'B')
if (argv[5][0] == 'B')
dstar_buf[13] = 0x01; dstar_buf[13] = 0x01;
else else if (argv[5][0] == 'C')
if (argv[5][0] == 'C')
dstar_buf[13] = 0x02; dstar_buf[13] = 0x02;
else else
dstar_buf[13] = 0x00; dstar_buf[13] = 0x00;

@ -29,8 +29,7 @@ static FILE *fp = NULL;
static time_t tNow = 0; static time_t tNow = 0;
static short streamid_raw = 0; static short streamid_raw = 0;
static unsigned short crc_tabccitt[256] = static unsigned short crc_tabccitt[256] = {
{
0x0000,0x1189,0x2312,0x329b,0x4624,0x57ad,0x6536,0x74bf, 0x0000,0x1189,0x2312,0x329b,0x4624,0x57ad,0x6536,0x74bf,
0x8c48,0x9dc1,0xaf5a,0xbed3,0xca6c,0xdbe5,0xe97e,0xf8f7, 0x8c48,0x9dc1,0xaf5a,0xbed3,0xca6c,0xdbe5,0xe97e,0xf8f7,
0x1081,0x0108,0x3393,0x221a,0x56a5,0x472c,0x75b7,0x643e, 0x1081,0x0108,0x3393,0x221a,0x56a5,0x472c,0x75b7,0x643e,
@ -73,8 +72,7 @@ static void calcPFCS(unsigned char rawbytes[58])
unsigned short tmp, short_c; unsigned short tmp, short_c;
short int i; short int i;
for (i = 17; i < 56 ; i++) for (i = 17; i < 56 ; i++) {
{
short_c = 0x00ff & (unsigned short)rawbytes[i]; short_c = 0x00ff & (unsigned short)rawbytes[i];
tmp = (crc_dstar_ffff & 0x00ff) ^ short_c; tmp = (crc_dstar_ffff & 0x00ff) ^ short_c;
crc_dstar_ffff = (crc_dstar_ffff >> 8) ^ crc_tabccitt[tmp]; crc_dstar_ffff = (crc_dstar_ffff >> 8) ^ crc_tabccitt[tmp];
@ -93,14 +91,13 @@ static bool dst_open(char *ip, int port)
int reuse = 1; int reuse = 1;
sockDst = socket(PF_INET,SOCK_DGRAM,0); sockDst = socket(PF_INET,SOCK_DGRAM,0);
if (sockDst == -1) if (sockDst == -1) {
{
printf("Failed to create DSTAR socket\n"); printf("Failed to create DSTAR socket\n");
return false; return false;
} }
if (setsockopt(sockDst,SOL_SOCKET,SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) == -1) if (setsockopt(sockDst,SOL_SOCKET,SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) == -1) {
{ close(sockDst);
close(sockDst); sockDst = -1; sockDst = -1;
printf("setsockopt DSTAR REUSE failed\n"); printf("setsockopt DSTAR REUSE failed\n");
return false; return false;
} }
@ -115,8 +112,7 @@ static bool dst_open(char *ip, int port)
static void dst_close() static void dst_close()
{ {
if (sockDst != -1) if (sockDst != -1) {
{
close(sockDst); close(sockDst);
sockDst = -1; sockDst = -1;
} }
@ -135,8 +131,7 @@ int main(int argc, char **argv)
char RADIO_ID[21]; char RADIO_ID[21];
short int TEXT_idx = 0; short int TEXT_idx = 0;
if (argc != 10) if (argc != 10) {
{
printf("Usage: g2link_test_audio <IPaddress> <port> <dvtoolFile> <repeaterCallsign> <module> <delay_between> <delay_before> <MYCALL> <YRCALL>\n"); printf("Usage: g2link_test_audio <IPaddress> <port> <dvtoolFile> <repeaterCallsign> <module> <delay_between> <delay_before> <MYCALL> <YRCALL>\n");
printf("Example: g2link_test_audio 127.0.0.1 19000 somefile.dvtool KJ4NHF B 19 2 KI4LKF CQCQCQ\n"); printf("Example: g2link_test_audio 127.0.0.1 19000 somefile.dvtool KJ4NHF B 19 2 KI4LKF CQCQCQ\n");
printf("Where...\n"); printf("Where...\n");
@ -152,30 +147,26 @@ int main(int argc, char **argv)
return 0; return 0;
} }
if (strlen(argv[4]) > 6) if (strlen(argv[4]) > 6) {
{
printf("repeaterCallsign can not be more than 6 characters, %s is invalid\n", argv[4]); printf("repeaterCallsign can not be more than 6 characters, %s is invalid\n", argv[4]);
return 0; return 0;
} }
for (i = 0; i < strlen(argv[4]); i++) for (i = 0; i < strlen(argv[4]); i++)
argv[4][i] = toupper(argv[4][i]); argv[4][i] = toupper(argv[4][i]);
if ((argv[5][0] != 'A') && (argv[5][0] != 'B') && (argv[5][0] != 'C')) if ((argv[5][0] != 'A') && (argv[5][0] != 'B') && (argv[5][0] != 'C')) {
{
printf("module must be one of A B C\n"); printf("module must be one of A B C\n");
return 0; return 0;
} }
if (strlen(argv[8]) > 8) if (strlen(argv[8]) > 8) {
{
printf("No more than 8 characters in MYCALL\n"); printf("No more than 8 characters in MYCALL\n");
return 0; return 0;
} }
for (i = 0; i < strlen(argv[8]); i++) for (i = 0; i < strlen(argv[8]); i++)
argv[8][i] = toupper(argv[8][i]); argv[8][i] = toupper(argv[8][i]);
if (strlen(argv[9]) > 8) if (strlen(argv[9]) > 8) {
{
printf("No more than 8 characters in YRCALL\n"); printf("No more than 8 characters in YRCALL\n");
return 0; return 0;
} }
@ -184,22 +175,19 @@ int main(int argc, char **argv)
fp = fopen(argv[3], "rb"); fp = fopen(argv[3], "rb");
if (!fp) if (!fp) {
{
printf("Failed to open file %s for reading\n", argv[3]); printf("Failed to open file %s for reading\n", argv[3]);
return 0; return 0;
} }
/* stupid DVTOOL + 4 byte num_of_records */ /* stupid DVTOOL + 4 byte num_of_records */
nread = fread(dstar_buf, 10, 1, fp); nread = fread(dstar_buf, 10, 1, fp);
if (nread != 1) if (nread != 1) {
{
printf("Cant read first 10 bytes\n"); printf("Cant read first 10 bytes\n");
fclose(fp); fclose(fp);
return 0; return 0;
} }
if (memcmp(dstar_buf, "DVTOOL", 6) != 0) if (memcmp(dstar_buf, "DVTOOL", 6) != 0) {
{
printf("DVTOOL not found\n"); printf("DVTOOL not found\n");
fclose(fp); fclose(fp);
return 0; return 0;
@ -216,57 +204,46 @@ int main(int argc, char **argv)
time(&tNow); time(&tNow);
srand(tNow + getpid()); srand(tNow + getpid());
if (dst_open(argv[1], atoi(argv[2]))) if (dst_open(argv[1], atoi(argv[2]))) {
{ while (true) {
while (true)
{
/* 2 byte length */ /* 2 byte length */
nread = fread(&rlen, 2, 1, fp); nread = fread(&rlen, 2, 1, fp);
if (nread != 1) if (nread != 1) {
{
printf("End-Of-File\n"); printf("End-Of-File\n");
break; break;
} }
if (rlen == 56) if (rlen == 56)
streamid_raw = (short)(::rand() & 0xFFFF); streamid_raw = (short)(::rand() & 0xFFFF);
else else if (rlen == 27)
if (rlen == 27)
; ;
else else {
{
printf("Not 56-byte and not 27-byte\n"); printf("Not 56-byte and not 27-byte\n");
break; break;
} }
/* read the packet */ /* read the packet */
nread = fread(dstar_buf, rlen, 1, fp); nread = fread(dstar_buf, rlen, 1, fp);
if (nread == 1) if (nread == 1) {
{ if (memcmp(dstar_buf, "DSVT", 4) != 0) {
if (memcmp(dstar_buf, "DSVT", 4) != 0)
{
printf("DVST not found\n"); printf("DVST not found\n");
break; break;
} }
if (dstar_buf[8] != 0x20) if (dstar_buf[8] != 0x20) {
{
printf("Not Voice type\n"); printf("Not Voice type\n");
break; break;
} }
if (dstar_buf[4] == 0x10) if (dstar_buf[4] == 0x10)
; ;
else else if (dstar_buf[4] == 0x20)
if (dstar_buf[4] == 0x20)
; ;
else else {
{
printf("Not a valid record type\n"); printf("Not a valid record type\n");
break; break;
} }
if (rlen == 56) if (rlen == 56) {
{
memcpy(rptr_buf, "DSTR", 4); memcpy(rptr_buf, "DSTR", 4);
rptr_buf[5] = (unsigned char)(G2_COUNTER & 0xff); rptr_buf[5] = (unsigned char)(G2_COUNTER & 0xff);
rptr_buf[4] = (unsigned char)((G2_COUNTER >> 8) & 0xff); rptr_buf[4] = (unsigned char)((G2_COUNTER >> 8) & 0xff);
@ -305,74 +282,47 @@ int main(int argc, char **argv)
memcpy(rptr_buf + 52, "TEST", 4); memcpy(rptr_buf + 52, "TEST", 4);
calcPFCS(rptr_buf); calcPFCS(rptr_buf);
} } else {
else
{
rptr_buf[5] = (unsigned char)(G2_COUNTER & 0xff); rptr_buf[5] = (unsigned char)(G2_COUNTER & 0xff);
rptr_buf[4] = (unsigned char)((G2_COUNTER >> 8) & 0xff); rptr_buf[4] = (unsigned char)((G2_COUNTER >> 8) & 0xff);
rptr_buf[9] = 0x13; rptr_buf[9] = 0x13;
if ((dstar_buf[24] != 0x55) || if ((dstar_buf[24] != 0x55) ||
(dstar_buf[25] != 0x2d) || (dstar_buf[25] != 0x2d) ||
(dstar_buf[26] != 0x16)) (dstar_buf[26] != 0x16)) {
{ if (TEXT_idx == 0) {
if (TEXT_idx == 0)
{
dstar_buf[24] = '@' ^ 0x70; dstar_buf[24] = '@' ^ 0x70;
dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f; dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f;
dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93; dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93;
} } else if (TEXT_idx == 2) {
else
if (TEXT_idx == 2)
{
dstar_buf[24] = RADIO_ID[TEXT_idx++] ^ 0x70; dstar_buf[24] = RADIO_ID[TEXT_idx++] ^ 0x70;
dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f; dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f;
dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93; dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93;
} } else if (TEXT_idx == 5) {
else
if (TEXT_idx == 5)
{
dstar_buf[24] = 'A' ^ 0x70; dstar_buf[24] = 'A' ^ 0x70;
dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f; dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f;
dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93; dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93;
} } else if (TEXT_idx == 7) {
else
if (TEXT_idx == 7)
{
dstar_buf[24] = RADIO_ID[TEXT_idx++] ^ 0x70; dstar_buf[24] = RADIO_ID[TEXT_idx++] ^ 0x70;
dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f; dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f;
dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93; dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93;
} } else if (TEXT_idx == 10) {
else
if (TEXT_idx == 10)
{
dstar_buf[24] = 'B' ^ 0x70; dstar_buf[24] = 'B' ^ 0x70;
dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f; dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f;
dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93; dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93;
} } else if (TEXT_idx == 12) {
else
if (TEXT_idx == 12)
{
dstar_buf[24] = RADIO_ID[TEXT_idx++] ^ 0x70; dstar_buf[24] = RADIO_ID[TEXT_idx++] ^ 0x70;
dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f; dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f;
dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93; dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93;
} } else if (TEXT_idx == 15) {
else
if (TEXT_idx == 15)
{
dstar_buf[24] = 'C' ^ 0x70; dstar_buf[24] = 'C' ^ 0x70;
dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f; dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f;
dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93; dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93;
} } else if (TEXT_idx == 17) {
else
if (TEXT_idx == 17)
{
dstar_buf[24] = RADIO_ID[TEXT_idx++] ^ 0x70; dstar_buf[24] = RADIO_ID[TEXT_idx++] ^ 0x70;
dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f; dstar_buf[25] = RADIO_ID[TEXT_idx++] ^ 0x4f;
dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93; dstar_buf[26] = RADIO_ID[TEXT_idx++] ^ 0x93;
} } else {
else
{
dstar_buf[24] = 0x70; dstar_buf[24] = 0x70;
dstar_buf[25] = 0x4f; dstar_buf[25] = 0x4f;
dstar_buf[26] = 0x93; dstar_buf[26] = 0x93;

@ -15,7 +15,9 @@ rm -f gwys.va2uv.txt
wget -nv -O gwys.va3uv.txt http://www.va3uv.com/gwys.txt wget -nv -O gwys.va3uv.txt http://www.va3uv.com/gwys.txt
if [ -e gwys.va3uv.txt ]; then if [ -e gwys.va3uv.txt ]; then
awk '$1~/^REF|XRF/&&$2~/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/{print $1, $2, 20001}' gwys.va3uv.txt > gwys.txt # Move DPlus and DExtra to port 20001
awk '$1~/^REF|XRF/{print $1, $2, 20001}' gwys.va3uv.txt > gwys.txt
# Get the DCS reflectors too
awk '$1~/^DCS/{print $1, $2, $3}' gwys.va3uv.txt >> gwys.txt awk '$1~/^DCS/{print $1, $2, $3}' gwys.va3uv.txt >> gwys.txt
else else
echo "Could not get gateways list from www.va3uv.com!" echo "Could not get gateways list from www.va3uv.com!"

@ -17,7 +17,6 @@ REF019 208.87.120.144 20001
REF020 50.199.88.20 20001 REF020 50.199.88.20 20001
REF024 69.41.0.15 20001 REF024 69.41.0.15 20001
REF025 173.10.178.226 20001 REF025 173.10.178.226 20001
REF026 206.12.104.8 20001
REF027 194.116.29.72 20001 REF027 194.116.29.72 20001
REF028 193.190.240.229 20001 REF028 193.190.240.229 20001
REF029 129.123.7.138 20001 REF029 129.123.7.138 20001
@ -31,7 +30,6 @@ REF037 208.111.3.181 20001
REF038 66.6.171.227 20001 REF038 66.6.171.227 20001
REF039 208.93.191.20 20001 REF039 208.93.191.20 20001
REF045 195.251.201.194 20001 REF045 195.251.201.194 20001
REF046 208.111.3.182 20001
REF047 157.7.142.13 20001 REF047 157.7.142.13 20001
REF048 208.88.66.244 20001 REF048 208.88.66.244 20001
REF050 75.147.26.195 20001 REF050 75.147.26.195 20001
@ -68,7 +66,7 @@ XRF021 74.204.50.67 20001
XRF023 141.75.245.225 20001 XRF023 141.75.245.225 20001
XRF025 63.133.189.2 20001 XRF025 63.133.189.2 20001
XRF026 139.13.100.34 20001 XRF026 139.13.100.34 20001
XRF027 194.116.29.66 20001 XRF027 194.116.29.78 20001
XRF028 193.190.240.228 20001 XRF028 193.190.240.228 20001
XRF031 83.241.141.245 20001 XRF031 83.241.141.245 20001
XRF033 46.226.178.81 20001 XRF033 46.226.178.81 20001
@ -87,11 +85,12 @@ XRF123 213.126.90.100 20001
XRF310 199.167.193.147 20001 XRF310 199.167.193.147 20001
XRF333 37.187.103.98 20001 XRF333 37.187.103.98 20001
XRF353 94.173.206.53 20001 XRF353 94.173.206.53 20001
XRF444 71.40.84.59 20001 XRF444 70.125.157.44 20001
XRF500 125.63.57.138 20001
XRF555 199.167.193.205 20001 XRF555 199.167.193.205 20001
XRF559 98.239.113.175 20001
XRF580 67.20.31.79 20001 XRF580 67.20.31.79 20001
XRF603 74.104.179.159 20001 XRF603 74.104.179.159 20001
XRF666 125.63.57.138 20001
XRF719 199.227.117.121 20001 XRF719 199.227.117.121 20001
XRF727 108.33.72.83 20001 XRF727 108.33.72.83 20001
XRF777 62.167.15.53 20001 XRF777 62.167.15.53 20001
@ -101,3 +100,28 @@ XRF858 198.57.255.30 20001
XRF901 199.167.196.109 20001 XRF901 199.167.196.109 20001
XRF905 199.212.121.20 20001 XRF905 199.212.121.20 20001
XRF978 74.104.179.159 20001 XRF978 74.104.179.159 20001
DCS001 dcs001.xreflector.net 30051
DCS002 dcs002.xreflector.net 30051
DCS003 dcs003.xreflector.net 30051
DCS004 dcs004.xreflector.net 30051
DCS005 dcs005.xreflector.net 30051
DCS006 dcs006.xreflector.net 30051
DCS007 dcs007.xreflector.net 30051
DCS008 dcs008.xreflector.net 30051
DCS009 dcs009.xreflector.net 30051
DCS010 dcs010.xreflector.net 30051
DCS011 dcs011.xreflector.net 30051
DCS012 dcs012.xreflector.net 30051
DCS013 dcs013.xreflector.net 30051
DCS014 dcs014.xreflector.net 30051
DCS015 dcs015.xreflector.net 30051
DCS016 dcs016.xreflector.net 30051
DCS017 dcs017.xreflector.net 30051
DCS018 dcs018.xreflector.net 30051
DCS019 dcs019.xreflector.net 30051
DCS020 dcs020.xreflector.net 30051
DCS021 dcs021.xreflector.net 30051
DCS022 dcs022.xreflector.net 30051
DCS023 dcs023.xreflector.net 30051
DCS024 dcs024.xreflector.net 30051
DCS025 dcs025.xreflector.net 30051

Loading…
Cancel
Save

Powered by TurnKey Linux.